@lark-apaas/miaoda-cli 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/api/deploy/index.js +13 -1
- package/dist/api/deploy/modern-types.js +23 -0
- package/dist/api/deploy/modern.js +78 -0
- package/dist/api/deploy/plugin-instances-types.js +6 -0
- package/dist/api/deploy/plugin-instances.js +22 -0
- package/dist/cli/commands/app/index.js +84 -2
- package/dist/cli/commands/deploy/modern.js +50 -0
- package/dist/cli/commands/index.js +33 -5
- package/dist/cli/commands/skills/index.js +63 -0
- package/dist/cli/handlers/app/index.js +6 -1
- package/dist/cli/handlers/app/init.js +88 -0
- package/dist/cli/handlers/deploy/modern.js +33 -0
- package/dist/cli/handlers/skills/index.js +7 -0
- package/dist/cli/handlers/skills/status.js +31 -0
- package/dist/cli/handlers/skills/sync.js +38 -0
- package/dist/services/app/init/index.js +12 -0
- package/dist/services/app/init/install.js +101 -0
- package/dist/services/app/init/template.js +87 -0
- package/dist/services/deploy/modern/atoms/build.js +59 -0
- package/dist/services/deploy/modern/atoms/context.js +27 -0
- package/dist/services/deploy/modern/atoms/index.js +17 -0
- package/dist/services/deploy/modern/atoms/local-release.js +27 -0
- package/dist/services/deploy/modern/atoms/pre-release.js +13 -0
- package/dist/services/deploy/modern/atoms/save-plugin-instances.js +72 -0
- package/dist/services/deploy/modern/atoms/upload.js +246 -0
- package/dist/services/deploy/modern/check.js +53 -0
- package/dist/services/deploy/modern/constants.js +13 -0
- package/dist/services/deploy/modern/index.js +16 -0
- package/dist/services/deploy/modern/pipelines/index.js +5 -0
- package/dist/services/deploy/modern/pipelines/local.js +75 -0
- package/dist/services/deploy/modern/protocol.js +122 -0
- package/dist/services/deploy/modern/run-types.js +4 -0
- package/dist/services/deploy/modern/run.js +13 -0
- package/dist/services/deploy/modern/template-key-map.js +22 -0
- package/dist/services/skills/index.js +5 -0
- package/dist/services/skills/status.js +37 -0
- package/dist/utils/coding-steering.js +85 -0
- package/dist/utils/http.js +21 -11
- package/dist/utils/npm-pack.js +55 -0
- package/dist/utils/spark-meta.js +42 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -55,7 +55,7 @@ miaoda file ls --output json
|
|
|
55
55
|
## 环境变量
|
|
56
56
|
|
|
57
57
|
- `MIAODA_APP_ID`:默认应用 ID,等价于 `--app-id`。
|
|
58
|
-
- `MIAODA_CANARY_HEADER
|
|
58
|
+
- `MIAODA_CANARY_HEADER`:HTTP 请求的 `x-tt-env` 小流量头取值。未设置时默认 `boe_miaoda_doubao`;设为空字符串则不带该头(例:`export MIAODA_CANARY_HEADER=boe_xxx`)。值形如 `ppe_xxx` 时额外带上 `x-use-ppe: 1`。
|
|
59
59
|
|
|
60
60
|
## 输出契约
|
|
61
61
|
|
package/dist/api/deploy/index.js
CHANGED
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NodeStatus = exports.nodeStatusFromText = exports.nodeStatusText = exports.errorJobSchema = exports.deployGetSchema = exports.deployHistorySchema = exports.queryPipelineInstance = exports.getErrorLog = exports.listPipelineInstances = exports.createRelease = void 0;
|
|
3
|
+
exports.NodeStatus = exports.nodeStatusFromText = exports.nodeStatusText = exports.errorJobSchema = exports.deployGetSchema = exports.deployHistorySchema = exports.batchSavePluginInstances = exports.LocalReleaseStatus = exports.getModernLastPublishedVersion = exports.getModernReleaseStatus = exports.createModernRelease = exports.callbackStatic = exports.updateLocalRelease = exports.createLocalRelease = exports.preRelease = exports.queryPipelineInstance = exports.getErrorLog = exports.listPipelineInstances = exports.createRelease = void 0;
|
|
4
4
|
var api_1 = require("./api");
|
|
5
5
|
Object.defineProperty(exports, "createRelease", { enumerable: true, get: function () { return api_1.createRelease; } });
|
|
6
6
|
Object.defineProperty(exports, "listPipelineInstances", { enumerable: true, get: function () { return api_1.listPipelineInstances; } });
|
|
7
7
|
Object.defineProperty(exports, "getErrorLog", { enumerable: true, get: function () { return api_1.getErrorLog; } });
|
|
8
8
|
Object.defineProperty(exports, "queryPipelineInstance", { enumerable: true, get: function () { return api_1.queryPipelineInstance; } });
|
|
9
|
+
var modern_1 = require("./modern");
|
|
10
|
+
Object.defineProperty(exports, "preRelease", { enumerable: true, get: function () { return modern_1.preRelease; } });
|
|
11
|
+
Object.defineProperty(exports, "createLocalRelease", { enumerable: true, get: function () { return modern_1.createLocalRelease; } });
|
|
12
|
+
Object.defineProperty(exports, "updateLocalRelease", { enumerable: true, get: function () { return modern_1.updateLocalRelease; } });
|
|
13
|
+
Object.defineProperty(exports, "callbackStatic", { enumerable: true, get: function () { return modern_1.callbackStatic; } });
|
|
14
|
+
Object.defineProperty(exports, "createModernRelease", { enumerable: true, get: function () { return modern_1.createRelease; } });
|
|
15
|
+
Object.defineProperty(exports, "getModernReleaseStatus", { enumerable: true, get: function () { return modern_1.getReleaseStatus; } });
|
|
16
|
+
Object.defineProperty(exports, "getModernLastPublishedVersion", { enumerable: true, get: function () { return modern_1.getLastPublishedVersion; } });
|
|
17
|
+
var modern_types_1 = require("./modern-types");
|
|
18
|
+
Object.defineProperty(exports, "LocalReleaseStatus", { enumerable: true, get: function () { return modern_types_1.LocalReleaseStatus; } });
|
|
19
|
+
var plugin_instances_1 = require("./plugin-instances");
|
|
20
|
+
Object.defineProperty(exports, "batchSavePluginInstances", { enumerable: true, get: function () { return plugin_instances_1.batchSavePluginInstances; } });
|
|
9
21
|
var schemas_1 = require("./schemas");
|
|
10
22
|
Object.defineProperty(exports, "deployHistorySchema", { enumerable: true, get: function () { return schemas_1.deployHistorySchema; } });
|
|
11
23
|
Object.defineProperty(exports, "deployGetSchema", { enumerable: true, get: function () { return schemas_1.deployGetSchema; } });
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// modern deploy 接口的请求 / 响应类型(与服务端发布编排接口对齐)。
|
|
3
|
+
// 第一期落地的链路:本地构建 + 本地部署。
|
|
4
|
+
//
|
|
5
|
+
// 接口分两类:
|
|
6
|
+
// - preRelease:所有"本地构建"链路共用,签发动态配置(含 pre-signed TOS upload URL)
|
|
7
|
+
// - localPublish:本地构建 + 本地部署专用(createReleaseLocalPublish + updateReleaseLocalPublish)
|
|
8
|
+
//
|
|
9
|
+
// 远端部署链路(B/C)所需的 release 接口先预留类型骨架,待 B/C 落地时启用。
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.LocalReleaseStatus = void 0;
|
|
12
|
+
/**
|
|
13
|
+
* localPublish 状态枚举(数值,与服务端 IDL 对齐)。
|
|
14
|
+
* CLI updateLocalRelease 只翻 Finished / Failed 两个终态;其它由后端流转。
|
|
15
|
+
*/
|
|
16
|
+
exports.LocalReleaseStatus = {
|
|
17
|
+
Unspecified: 0,
|
|
18
|
+
Publishing: 1,
|
|
19
|
+
Finished: 2,
|
|
20
|
+
Failed: 3,
|
|
21
|
+
Canceled: 4,
|
|
22
|
+
Rollback: 5,
|
|
23
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// modern deploy 接口客户端。统一走管理端 innerapi(postInnerApi 信封解析)。
|
|
3
|
+
//
|
|
4
|
+
// 第一期落地(本地构建 + 本地部署):
|
|
5
|
+
// - preRelease:拿 pre_release_id + version + 动态配置 data
|
|
6
|
+
// - createLocalRelease / updateLocalRelease:完整本地部署生命周期
|
|
7
|
+
//
|
|
8
|
+
// 远端部署(本地构建+远端部署、远端构建+远端部署)需要 createRelease + getReleaseStatus,
|
|
9
|
+
// 后续 commit 接入;本文件已预留 endpoint 骨架但暂不导出。
|
|
10
|
+
//
|
|
11
|
+
// 约定:所有接口的 appID 走 URL :appID 路径参数,body 不再冗余携带 appID。
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.preRelease = preRelease;
|
|
14
|
+
exports.createLocalRelease = createLocalRelease;
|
|
15
|
+
exports.updateLocalRelease = updateLocalRelease;
|
|
16
|
+
exports.callbackStatic = callbackStatic;
|
|
17
|
+
exports.createRelease = createRelease;
|
|
18
|
+
exports.getReleaseStatus = getReleaseStatus;
|
|
19
|
+
exports.getLastPublishedVersion = getLastPublishedVersion;
|
|
20
|
+
const http_1 = require("../../utils/http");
|
|
21
|
+
const devops_error_1 = require("../../utils/devops-error");
|
|
22
|
+
const DEFAULT_ERR_CODE = 'INTERNAL_DEVOPS_ERROR';
|
|
23
|
+
function envelopeOpts(errPrefix) {
|
|
24
|
+
// modern deploy 接口与 default deploy / app 走同一个 lark.apaas.devops PSM,
|
|
25
|
+
// 业务错误码命名空间共享,直接复用 mapDevopsError 把 BAM 码翻为 AppError。
|
|
26
|
+
return {
|
|
27
|
+
errPrefix,
|
|
28
|
+
defaultErrCode: DEFAULT_ERR_CODE,
|
|
29
|
+
mapErr: devops_error_1.mapDevopsError,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
// ── preRelease ──
|
|
33
|
+
/** POST /v1/devops/app/:appID/pre_release */
|
|
34
|
+
async function preRelease(req) {
|
|
35
|
+
const { appID, ...body } = req;
|
|
36
|
+
const url = `/v1/devops/app/${encodeURIComponent(appID)}/pre_release`;
|
|
37
|
+
return (0, http_1.postInnerApi)(url, body, envelopeOpts('Failed to pre-release'));
|
|
38
|
+
}
|
|
39
|
+
// ── localPublish ──
|
|
40
|
+
/** POST /v1/devops/app/:appID/local_publish/release */
|
|
41
|
+
async function createLocalRelease(req) {
|
|
42
|
+
const { appID, ...body } = req;
|
|
43
|
+
const url = `/v1/devops/app/${encodeURIComponent(appID)}/local_publish/release`;
|
|
44
|
+
return (0, http_1.postInnerApi)(url, body, envelopeOpts('Failed to create local release'));
|
|
45
|
+
}
|
|
46
|
+
/** POST /v1/devops/app/:appID/local_publish/update_release */
|
|
47
|
+
async function updateLocalRelease(req) {
|
|
48
|
+
const { appID, ...body } = req;
|
|
49
|
+
const url = `/v1/devops/app/${encodeURIComponent(appID)}/local_publish/update_release`;
|
|
50
|
+
await (0, http_1.postInnerApi)(url, body, envelopeOpts('Failed to update local release'));
|
|
51
|
+
}
|
|
52
|
+
// ── callbackStatic(PaaS Storage 静态资源上传完成回调) ──
|
|
53
|
+
/** POST /v1/storage/app/:appID/bucket/:bucketID/object/callbackStatic */
|
|
54
|
+
async function callbackStatic(req) {
|
|
55
|
+
const { appID, bucketID, uploadID } = req;
|
|
56
|
+
const url = `/v1/storage/app/${encodeURIComponent(appID)}/bucket/${encodeURIComponent(bucketID)}/object/callbackStatic`;
|
|
57
|
+
return (0, http_1.postInnerApi)(url, { uploadID }, envelopeOpts('Failed to callback static upload'));
|
|
58
|
+
}
|
|
59
|
+
// ── release(远端部署,B / C 链路;本期不导出,类型骨架已就绪) ──
|
|
60
|
+
/** POST /v1/devops/app/:appID/remote_publish/release */
|
|
61
|
+
async function createRelease(req) {
|
|
62
|
+
const { appID, ...body } = req;
|
|
63
|
+
const url = `/v1/devops/app/${encodeURIComponent(appID)}/remote_publish/release`;
|
|
64
|
+
return (0, http_1.postInnerApi)(url, body, envelopeOpts('Failed to create release'));
|
|
65
|
+
}
|
|
66
|
+
/** POST /v1/devops/app/:appID/release/status */
|
|
67
|
+
async function getReleaseStatus(req) {
|
|
68
|
+
const { appID, ...body } = req;
|
|
69
|
+
const url = `/v1/devops/app/${encodeURIComponent(appID)}/release/status`;
|
|
70
|
+
return (0, http_1.postInnerApi)(url, body, envelopeOpts('Failed to query release status'));
|
|
71
|
+
}
|
|
72
|
+
// ── getLastPublishedVersion(URL path 待文档补充) ──
|
|
73
|
+
/** POST /v1/devops/app/:appID/last_published_version(path 待后端确认) */
|
|
74
|
+
async function getLastPublishedVersion(req) {
|
|
75
|
+
const { appID } = req;
|
|
76
|
+
const url = `/v1/devops/app/${encodeURIComponent(appID)}/last_published_version`;
|
|
77
|
+
return (0, http_1.postInnerApi)(url, {}, envelopeOpts('Failed to get last published version'));
|
|
78
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// studio_server 的 plugin_instances 批量保存接口。
|
|
3
|
+
//
|
|
4
|
+
// 后端已统一到 InnerEnvelope(`{data, status_code, message}`)信封;不再手撸
|
|
5
|
+
// 旧 BaseResp 解析,直接复用 utils/http.ts 的 postInnerApi,verbose 下也能拿到
|
|
6
|
+
// `→ POST` / `body:` / `resp:` 的完整日志。
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.batchSavePluginInstances = batchSavePluginInstances;
|
|
9
|
+
const http_1 = require("../../utils/http");
|
|
10
|
+
const URL_PATH = '/api/v1/studio/innerapi/plugin_instances/batch_save';
|
|
11
|
+
/**
|
|
12
|
+
* POST /api/v1/studio/innerapi/plugin_instances/batch_save
|
|
13
|
+
*
|
|
14
|
+
* 把发布版本的 capability 集合注册到 studio_server。
|
|
15
|
+
* 失败时抛 AppError("DEPLOY_PLUGIN_BATCH_SAVE_FAILED"),错误信息来自 envelope.message。
|
|
16
|
+
*/
|
|
17
|
+
async function batchSavePluginInstances(req) {
|
|
18
|
+
await (0, http_1.postInnerApi)(URL_PATH, req, {
|
|
19
|
+
errPrefix: 'Failed to save plugin instances',
|
|
20
|
+
defaultErrCode: 'DEPLOY_PLUGIN_BATCH_SAVE_FAILED',
|
|
21
|
+
});
|
|
22
|
+
}
|
|
@@ -3,8 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.registerAppCommands = registerAppCommands;
|
|
4
4
|
const shared_1 = require("../../../cli/commands/shared");
|
|
5
5
|
const index_1 = require("../../../cli/handlers/app/index");
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
const error_1 = require("../../../utils/error");
|
|
7
|
+
function registerAppCommands(program, opts = {}) {
|
|
8
|
+
const description = opts.includeInit
|
|
9
|
+
? '应用元数据管理:查看 / 修改 / 初始化'
|
|
10
|
+
: '应用元数据管理:查看 / 修改';
|
|
11
|
+
const appCmd = program.command('app').description(description);
|
|
8
12
|
appCmd.action(() => {
|
|
9
13
|
appCmd.outputHelp();
|
|
10
14
|
});
|
|
@@ -15,6 +19,9 @@ function registerAppCommands(program) {
|
|
|
15
19
|
`);
|
|
16
20
|
registerAppGet(appCmd);
|
|
17
21
|
registerAppUpdate(appCmd);
|
|
22
|
+
if (opts.includeInit) {
|
|
23
|
+
registerAppInit(appCmd);
|
|
24
|
+
}
|
|
18
25
|
}
|
|
19
26
|
function registerAppGet(parent) {
|
|
20
27
|
const cmd = parent
|
|
@@ -60,3 +67,78 @@ JSON 输出
|
|
|
60
67
|
});
|
|
61
68
|
}));
|
|
62
69
|
}
|
|
70
|
+
function registerAppInit(parent) {
|
|
71
|
+
const cmd = parent
|
|
72
|
+
.command('init')
|
|
73
|
+
.description('初始化应用代码:抓 template 渲染、装 .agent/steering/ skills、写 .spark/meta.json。.spark/meta.json 已存在则直接退出')
|
|
74
|
+
.option('--template <stack>', `技术栈短名(${index_1.SUPPORTED_STACKS.join(' / ')})`)
|
|
75
|
+
.option('--conf <json>', 'init 配置 JSON。支持 {"version": "<template 版本>"} / {"steeringVersion": "<steering 版本>"},均默认 latest')
|
|
76
|
+
.option('--skip-install', '跳过依赖安装', false)
|
|
77
|
+
.addHelpText('after', `
|
|
78
|
+
幂等
|
|
79
|
+
.spark/meta.json 已存在时直接退出(initialized=false, reason=already_initialized),
|
|
80
|
+
不再触发 template 渲染、不重新拉 skills、不安装依赖。
|
|
81
|
+
meta.json 在 init 流程最后才写,写了 = 已完整成功一次;
|
|
82
|
+
上一次失败留下半渲染状态时(package.json 在但 meta.json 没在)允许重跑。
|
|
83
|
+
|
|
84
|
+
应用身份(appId)
|
|
85
|
+
init 不再持久化 appId。运行端命令(deploy / file / plugin 等)始终从 MIAODA_APP_ID env 读,
|
|
86
|
+
init 阶段也无需感知 appId。
|
|
87
|
+
|
|
88
|
+
依赖安装
|
|
89
|
+
默认:npm install --no-audit --no-fund
|
|
90
|
+
--skip-install: 跳过
|
|
91
|
+
MIAODA_DEP_CACHE_DIR 环境变量:
|
|
92
|
+
若设了且 CWD 含 package.json,先算 md5(package.json),
|
|
93
|
+
命中 \${MIAODA_DEP_CACHE_DIR}/\${hash}.zip 则 unzip 复用缓存;未命中或解压后 node_modules
|
|
94
|
+
为空都会 fallback npm install。
|
|
95
|
+
JSON 模式下子进程 stdout 重定向到 stderr,避免污染最终 emit 的 JSON。
|
|
96
|
+
|
|
97
|
+
JSON 输出
|
|
98
|
+
已初始化:{"data": {"initialized": false, "reason": "already_initialized", "targetDir": "..."}}
|
|
99
|
+
新初始化:{"data": {"initialized": true, "template": "...", "templateVersion": "...", "steeringVersion": "...",
|
|
100
|
+
"installed": true, "installSource": "cache|npm|skipped", "installHash": "...", ...}}
|
|
101
|
+
|
|
102
|
+
示例
|
|
103
|
+
$ miaoda app init --template vite-react
|
|
104
|
+
$ miaoda app init --template vite-react --conf '{"version": "0.1.0-alpha.1"}'
|
|
105
|
+
$ miaoda app init --template vite-react --conf '{"steeringVersion": "0.1.0"}'
|
|
106
|
+
$ miaoda app init --template vite-react --skip-install
|
|
107
|
+
$ MIAODA_DEP_CACHE_DIR=/tmp/dep-cache miaoda app init --template vite-react
|
|
108
|
+
`);
|
|
109
|
+
cmd.action((0, shared_1.withHelp)(cmd, async (rawOpts) => {
|
|
110
|
+
const conf = parseInitConf(rawOpts.conf);
|
|
111
|
+
await (0, index_1.handleAppInit)({
|
|
112
|
+
template: rawOpts.template,
|
|
113
|
+
conf,
|
|
114
|
+
skipInstall: rawOpts.skipInstall,
|
|
115
|
+
});
|
|
116
|
+
}));
|
|
117
|
+
}
|
|
118
|
+
function parseInitConf(raw) {
|
|
119
|
+
if (raw === undefined)
|
|
120
|
+
return undefined;
|
|
121
|
+
let parsed;
|
|
122
|
+
try {
|
|
123
|
+
parsed = JSON.parse(raw);
|
|
124
|
+
}
|
|
125
|
+
catch (err) {
|
|
126
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
127
|
+
throw new error_1.AppError('ARGS_INVALID', `--conf 必须是合法 JSON:${msg}`);
|
|
128
|
+
}
|
|
129
|
+
if (!isPlainObject(parsed)) {
|
|
130
|
+
throw new error_1.AppError('ARGS_INVALID', '--conf 必须是 JSON 对象');
|
|
131
|
+
}
|
|
132
|
+
const version = parsed.version;
|
|
133
|
+
if (version !== undefined && typeof version !== 'string') {
|
|
134
|
+
throw new error_1.AppError('ARGS_INVALID', '--conf.version 必须是字符串');
|
|
135
|
+
}
|
|
136
|
+
const steeringVersion = parsed.steeringVersion;
|
|
137
|
+
if (steeringVersion !== undefined && typeof steeringVersion !== 'string') {
|
|
138
|
+
throw new error_1.AppError('ARGS_INVALID', '--conf.steeringVersion 必须是字符串');
|
|
139
|
+
}
|
|
140
|
+
return { version, steeringVersion };
|
|
141
|
+
}
|
|
142
|
+
function isPlainObject(v) {
|
|
143
|
+
return typeof v === 'object' && v !== null && !Array.isArray(v);
|
|
144
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerDeployCommandsModern = registerDeployCommandsModern;
|
|
4
|
+
const shared_1 = require("../../../cli/commands/shared");
|
|
5
|
+
const modern_1 = require("../../../cli/handlers/deploy/modern");
|
|
6
|
+
/**
|
|
7
|
+
* modern scene (MIAODA_APP_TYPE=7) 专用 deploy 注册。
|
|
8
|
+
* 仅披露顶层 `miaoda deploy`,CLI 表面对齐 openclaw-cli:`--dir / --skip-build`。
|
|
9
|
+
*
|
|
10
|
+
* 与 default 的 registerDeployCommands 完全平行:两套实现 100% 隔离,
|
|
11
|
+
* 不共享分支、不互相依赖。后端调用与编排在 src/services/deploy/modern/。
|
|
12
|
+
*/
|
|
13
|
+
function registerDeployCommandsModern(program) {
|
|
14
|
+
const deployCmd = program
|
|
15
|
+
.command('deploy')
|
|
16
|
+
.description('触发 modern 应用发布:本地构建 + 本地部署(preRelease + localPublish)')
|
|
17
|
+
.option('--dir <path>', '项目目录', '.')
|
|
18
|
+
.option('--skip-build', '跳过 build 步骤(已构建好时使用)', false)
|
|
19
|
+
.addHelpText('after', `
|
|
20
|
+
不要用异步模式或后台模式调用 deploy,否则调用可能提前结束,Agent 会误判发布已完成。
|
|
21
|
+
|
|
22
|
+
前置要求
|
|
23
|
+
- 项目已 init(.spark/meta.json 含 stack)
|
|
24
|
+
- MIAODA_APP_ID 已设置(应用身份从 env 读,不再从 meta.json 读)
|
|
25
|
+
- node_modules 已安装
|
|
26
|
+
- package.json 含 build script
|
|
27
|
+
- 沙箱内预装 tosutil(用于把构建产物上传到 TOS)
|
|
28
|
+
|
|
29
|
+
流程概览(stderr 进度提示)
|
|
30
|
+
1. prepareContext 2. preRelease 3. build
|
|
31
|
+
4. createLocalRelease 5. uploadArtifacts
|
|
32
|
+
6. savePluginInstances(扫描 dist/output_capabilities/*.json 批量注册)
|
|
33
|
+
7. finalizeLocalRelease(Finished|Failed)
|
|
34
|
+
|
|
35
|
+
JSON 输出(stdout)
|
|
36
|
+
{"data": {"appId": "...", "version": <n>, "url": "...", "releaseID": "...", "preReleaseID": "..."}}
|
|
37
|
+
|
|
38
|
+
示例
|
|
39
|
+
$ miaoda deploy
|
|
40
|
+
$ miaoda deploy --dir ./my-app
|
|
41
|
+
$ miaoda deploy --skip-build
|
|
42
|
+
`);
|
|
43
|
+
deployCmd.action((0, shared_1.withHelp)(deployCmd, async (rawOpts) => {
|
|
44
|
+
await (0, modern_1.handleDeployModern)({
|
|
45
|
+
dir: rawOpts.dir ?? '.',
|
|
46
|
+
appId: (0, shared_1.resolveAppId)({}),
|
|
47
|
+
skipBuild: rawOpts.skipBuild,
|
|
48
|
+
});
|
|
49
|
+
}));
|
|
50
|
+
}
|
|
@@ -1,15 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveScene = resolveScene;
|
|
3
4
|
exports.registerCommands = registerCommands;
|
|
4
5
|
const index_1 = require("../../cli/commands/file/index");
|
|
5
6
|
const index_2 = require("../../cli/commands/db/index");
|
|
6
7
|
const index_3 = require("../../cli/commands/observability/index");
|
|
7
8
|
const index_4 = require("../../cli/commands/app/index");
|
|
8
9
|
const index_5 = require("../../cli/commands/deploy/index");
|
|
10
|
+
const modern_1 = require("../../cli/commands/deploy/modern");
|
|
11
|
+
const index_6 = require("../../cli/commands/skills/index");
|
|
12
|
+
function resolveScene(appType, _archType) {
|
|
13
|
+
if (appType === '7')
|
|
14
|
+
return 'modern';
|
|
15
|
+
return 'default';
|
|
16
|
+
}
|
|
17
|
+
const SCENE_REGISTRARS = {
|
|
18
|
+
default: (p) => {
|
|
19
|
+
(0, index_4.registerAppCommands)(p);
|
|
20
|
+
(0, index_5.registerDeployCommands)(p);
|
|
21
|
+
(0, index_2.registerDbCommands)(p);
|
|
22
|
+
(0, index_1.registerFileCommands)(p);
|
|
23
|
+
(0, index_3.registerObservabilityCommands)(p);
|
|
24
|
+
},
|
|
25
|
+
modern: (p) => {
|
|
26
|
+
(0, index_4.registerAppCommands)(p, { includeInit: true });
|
|
27
|
+
(0, modern_1.registerDeployCommandsModern)(p);
|
|
28
|
+
(0, index_6.registerSkillsCommands)(p);
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
function readEnv(name) {
|
|
32
|
+
const v = process.env[name]?.trim();
|
|
33
|
+
return v !== undefined && v !== '' ? v : undefined;
|
|
34
|
+
}
|
|
9
35
|
function registerCommands(program) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
(
|
|
13
|
-
(
|
|
14
|
-
(
|
|
36
|
+
const appType = readEnv('MIAODA_APP_TYPE');
|
|
37
|
+
const archType = readEnv('MIAODA_APP_ARCH_TYPE');
|
|
38
|
+
const scene = resolveScene(appType, archType);
|
|
39
|
+
SCENE_REGISTRARS[scene](program);
|
|
40
|
+
if (process.env.MIAODA_VERBOSE === '1' || process.argv.includes('--verbose')) {
|
|
41
|
+
process.stderr.write(`[miaoda] scene=${scene} app_type=${appType ?? '-'} arch_type=${archType ?? '-'}\n`);
|
|
42
|
+
}
|
|
15
43
|
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerSkillsCommands = registerSkillsCommands;
|
|
4
|
+
const shared_1 = require("../../../cli/commands/shared");
|
|
5
|
+
const index_1 = require("../../../cli/handlers/skills/index");
|
|
6
|
+
/**
|
|
7
|
+
* miaoda skills:本地 agent skills 维护。
|
|
8
|
+
*
|
|
9
|
+
* 当前仅 steering 一类子集(coding-steering 包内的 _common/skills + <stack>/skills + tech.md);
|
|
10
|
+
* 后续如有更多 skill 类型再加 --type。`app init` 会一次性同步装上,独立 `skills sync` 用于
|
|
11
|
+
* 后续单独升级 / pin 版本,不必走完整 init。
|
|
12
|
+
*/
|
|
13
|
+
function registerSkillsCommands(program) {
|
|
14
|
+
const skillsCmd = program.command('skills').description('本地 agent skills(含 steering)维护');
|
|
15
|
+
skillsCmd.action(() => {
|
|
16
|
+
skillsCmd.outputHelp();
|
|
17
|
+
});
|
|
18
|
+
registerSkillsSync(skillsCmd);
|
|
19
|
+
registerSkillsStatus(skillsCmd);
|
|
20
|
+
}
|
|
21
|
+
function registerSkillsSync(parent) {
|
|
22
|
+
const cmd = parent
|
|
23
|
+
.command('sync')
|
|
24
|
+
.description('同步 coding-steering(latest 或指定版本)到 .agent/steering/')
|
|
25
|
+
.argument('[version]', 'coding-steering 包版本或 dist-tag,缺省 latest')
|
|
26
|
+
.option('--dir <path>', '项目目录,默认当前目录', '.')
|
|
27
|
+
.addHelpText('after', `
|
|
28
|
+
前置要求
|
|
29
|
+
当前目录(或 --dir)已走过 'miaoda app init'(.spark/meta.json 含 stack)
|
|
30
|
+
|
|
31
|
+
JSON 输出
|
|
32
|
+
{"data": {"stack": "...", "version": "...", "syncedSkills": [...], "techSynced": true|false}}
|
|
33
|
+
|
|
34
|
+
示例
|
|
35
|
+
$ miaoda skills sync
|
|
36
|
+
$ miaoda skills sync 0.2.0
|
|
37
|
+
$ miaoda skills sync --dir ./my-app
|
|
38
|
+
`);
|
|
39
|
+
cmd.action((0, shared_1.withHelp)(cmd, async (version, rawOpts) => {
|
|
40
|
+
await (0, index_1.handleSkillsSync)({
|
|
41
|
+
dir: rawOpts.dir,
|
|
42
|
+
version,
|
|
43
|
+
});
|
|
44
|
+
}));
|
|
45
|
+
}
|
|
46
|
+
function registerSkillsStatus(parent) {
|
|
47
|
+
const cmd = parent
|
|
48
|
+
.command('status')
|
|
49
|
+
.description('查看本地 .agent/steering/ 的当前状态(不联网)')
|
|
50
|
+
.option('--dir <path>', '项目目录,默认当前目录', '.')
|
|
51
|
+
.addHelpText('after', `
|
|
52
|
+
JSON 输出
|
|
53
|
+
{"data": {"present": true|false, "skills": [...], "techSynced": true|false}}
|
|
54
|
+
|
|
55
|
+
示例
|
|
56
|
+
$ miaoda skills status
|
|
57
|
+
`);
|
|
58
|
+
cmd.action((0, shared_1.withHelp)(cmd, async (rawOpts) => {
|
|
59
|
+
await (0, index_1.handleSkillsStatus)({
|
|
60
|
+
dir: rawOpts.dir,
|
|
61
|
+
});
|
|
62
|
+
}));
|
|
63
|
+
}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.handleAppUpdate = exports.handleAppGet = void 0;
|
|
3
|
+
exports.SUPPORTED_STACKS = exports.handleAppInit = exports.handleAppUpdate = exports.handleAppGet = void 0;
|
|
4
4
|
var get_1 = require("./get");
|
|
5
5
|
Object.defineProperty(exports, "handleAppGet", { enumerable: true, get: function () { return get_1.handleAppGet; } });
|
|
6
6
|
var update_1 = require("./update");
|
|
7
7
|
Object.defineProperty(exports, "handleAppUpdate", { enumerable: true, get: function () { return update_1.handleAppUpdate; } });
|
|
8
|
+
var init_1 = require("./init");
|
|
9
|
+
Object.defineProperty(exports, "handleAppInit", { enumerable: true, get: function () { return init_1.handleAppInit; } });
|
|
10
|
+
// commands 层渲染 help 时需要这份枚举;从 handler barrel 转发,避免 commands → services 越界
|
|
11
|
+
var index_1 = require("../../../services/app/init/index");
|
|
12
|
+
Object.defineProperty(exports, "SUPPORTED_STACKS", { enumerable: true, get: function () { return index_1.SUPPORTED_STACKS; } });
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.handleAppInit = handleAppInit;
|
|
7
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
+
const index_1 = require("../../../services/app/init/index");
|
|
10
|
+
const coding_steering_1 = require("../../../utils/coding-steering");
|
|
11
|
+
const error_1 = require("../../../utils/error");
|
|
12
|
+
const output_1 = require("../../../utils/output");
|
|
13
|
+
/**
|
|
14
|
+
* miaoda app init
|
|
15
|
+
*
|
|
16
|
+
* 只负责本地脚手架:render template、sync skills、install deps,把 {stack, version, archType}
|
|
17
|
+
* 写入 .spark/meta.json。appId 不在此处持久化——deploy 等运行端通过 MIAODA_APP_ID env 拿。
|
|
18
|
+
*
|
|
19
|
+
* 幂等:.spark/meta.json 存在即表示已完整成功一次,直接退出,不重跑任何子步骤。
|
|
20
|
+
* 半渲染状态(package.json 在但 meta.json 不在)会重新跑完整流程。
|
|
21
|
+
*/
|
|
22
|
+
async function handleAppInit(opts) {
|
|
23
|
+
await Promise.resolve();
|
|
24
|
+
const targetDir = opts.targetDir ?? process.cwd();
|
|
25
|
+
const metaPath = node_path_1.default.join(targetDir, '.spark', 'meta.json');
|
|
26
|
+
if (node_fs_1.default.existsSync(metaPath)) {
|
|
27
|
+
if (!(0, output_1.isJsonMode)()) {
|
|
28
|
+
process.stdout.write(`Already initialized: ${metaPath}\n`);
|
|
29
|
+
}
|
|
30
|
+
(0, output_1.emit)({
|
|
31
|
+
data: {
|
|
32
|
+
initialized: false,
|
|
33
|
+
reason: 'already_initialized',
|
|
34
|
+
targetDir,
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const stack = opts.template;
|
|
40
|
+
if (!stack) {
|
|
41
|
+
throw new error_1.AppError('ARGS_INVALID', '缺少 --template <stack>', {
|
|
42
|
+
next_actions: [`可用 stack:${index_1.SUPPORTED_STACKS.join(', ')}`],
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
if (!index_1.SUPPORTED_STACKS.includes(stack)) {
|
|
46
|
+
throw new error_1.AppError('ARGS_INVALID', `不支持的 template: ${stack}`, {
|
|
47
|
+
next_actions: [`可用 stack:${index_1.SUPPORTED_STACKS.join(', ')}`],
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
const version = opts.conf?.version;
|
|
51
|
+
const projectName = node_path_1.default.basename(targetDir);
|
|
52
|
+
const tplResult = (0, index_1.renderTemplate)({ stack, version, targetDir, projectName });
|
|
53
|
+
const steeringResult = (0, coding_steering_1.syncCodingSteering)({
|
|
54
|
+
stack,
|
|
55
|
+
targetDir,
|
|
56
|
+
version: opts.conf?.steeringVersion,
|
|
57
|
+
logPrefix: 'init',
|
|
58
|
+
});
|
|
59
|
+
const installResult = (0, index_1.installDependencies)({
|
|
60
|
+
targetDir,
|
|
61
|
+
skip: opts.skipInstall,
|
|
62
|
+
quietStdout: (0, output_1.isJsonMode)(),
|
|
63
|
+
});
|
|
64
|
+
(0, index_1.writeSparkMeta)(targetDir, {
|
|
65
|
+
stack,
|
|
66
|
+
version: tplResult.version,
|
|
67
|
+
archType: tplResult.archType,
|
|
68
|
+
});
|
|
69
|
+
if (!(0, output_1.isJsonMode)()) {
|
|
70
|
+
process.stdout.write(`✓ Initialized ${stack} (template ${tplResult.version}, steering ${steeringResult.version}, install ${installResult.source}) in ${targetDir}\n`);
|
|
71
|
+
}
|
|
72
|
+
(0, output_1.emit)({
|
|
73
|
+
data: {
|
|
74
|
+
initialized: true,
|
|
75
|
+
template: stack,
|
|
76
|
+
templatePackage: tplResult.packageName,
|
|
77
|
+
templateVersion: tplResult.version,
|
|
78
|
+
steeringVersion: steeringResult.version,
|
|
79
|
+
archType: tplResult.archType,
|
|
80
|
+
syncedSkills: steeringResult.syncedSkills,
|
|
81
|
+
techSynced: steeringResult.techSynced,
|
|
82
|
+
installed: installResult.installed,
|
|
83
|
+
installSource: installResult.source,
|
|
84
|
+
installHash: installResult.hash,
|
|
85
|
+
cacheZip: installResult.cacheZip,
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.handleDeployModern = handleDeployModern;
|
|
7
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
+
const output_1 = require("../../../utils/output");
|
|
9
|
+
const index_1 = require("../../../services/deploy/modern/index");
|
|
10
|
+
/**
|
|
11
|
+
* miaoda deploy(modern scene 专用,CLI 表面对齐 openclaw-cli)
|
|
12
|
+
*
|
|
13
|
+
* 进程信息走 stderr(log_id / step),最终结果通过 emit 输出 envelope 到 stdout。
|
|
14
|
+
*/
|
|
15
|
+
async function handleDeployModern(opts) {
|
|
16
|
+
const projectDir = node_path_1.default.resolve(opts.dir);
|
|
17
|
+
const result = await (0, index_1.runModernDeploy)({
|
|
18
|
+
projectDir,
|
|
19
|
+
appId: opts.appId,
|
|
20
|
+
skipBuild: opts.skipBuild ?? false,
|
|
21
|
+
});
|
|
22
|
+
(0, output_1.emit)({
|
|
23
|
+
data: {
|
|
24
|
+
appId: result.appId,
|
|
25
|
+
version: result.version,
|
|
26
|
+
url: result.url,
|
|
27
|
+
releaseID: result.releaseID,
|
|
28
|
+
preReleaseID: result.preReleaseID,
|
|
29
|
+
},
|
|
30
|
+
next_cursor: null,
|
|
31
|
+
has_more: false,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handleSkillsStatus = exports.handleSkillsSync = void 0;
|
|
4
|
+
var sync_1 = require("./sync");
|
|
5
|
+
Object.defineProperty(exports, "handleSkillsSync", { enumerable: true, get: function () { return sync_1.handleSkillsSync; } });
|
|
6
|
+
var status_1 = require("./status");
|
|
7
|
+
Object.defineProperty(exports, "handleSkillsStatus", { enumerable: true, get: function () { return status_1.handleSkillsStatus; } });
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.handleSkillsStatus = handleSkillsStatus;
|
|
7
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
+
const index_1 = require("../../../services/skills/index");
|
|
9
|
+
const spark_meta_1 = require("../../../utils/spark-meta");
|
|
10
|
+
const output_1 = require("../../../utils/output");
|
|
11
|
+
/**
|
|
12
|
+
* miaoda skills status [--dir <path>]
|
|
13
|
+
*
|
|
14
|
+
* 从 .spark/meta.json 读 stack,扫描 <dir>/.agent/steering/<stack>/,
|
|
15
|
+
* 给出当前装了哪些 skills、tech.md 是否在。纯本地操作,不联网。
|
|
16
|
+
* meta 缺 stack 时返回 present=false(不抛错,方便和 init 的引导分开)。
|
|
17
|
+
*/
|
|
18
|
+
async function handleSkillsStatus(opts) {
|
|
19
|
+
await Promise.resolve();
|
|
20
|
+
const targetDir = node_path_1.default.resolve(opts.dir ?? process.cwd());
|
|
21
|
+
const meta = (0, spark_meta_1.readSparkMeta)(targetDir);
|
|
22
|
+
const status = (0, index_1.readSkillsStatus)({ targetDir, stack: meta.stack });
|
|
23
|
+
(0, output_1.emit)({
|
|
24
|
+
data: {
|
|
25
|
+
stack: meta.stack ?? null,
|
|
26
|
+
present: status.present,
|
|
27
|
+
skills: status.skills,
|
|
28
|
+
techSynced: status.techSynced,
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.handleSkillsSync = handleSkillsSync;
|
|
7
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
+
const coding_steering_1 = require("../../../utils/coding-steering");
|
|
9
|
+
const spark_meta_1 = require("../../../utils/spark-meta");
|
|
10
|
+
const error_1 = require("../../../utils/error");
|
|
11
|
+
const output_1 = require("../../../utils/output");
|
|
12
|
+
/**
|
|
13
|
+
* miaoda skills sync [--dir <path>] [--version <ver>]
|
|
14
|
+
*
|
|
15
|
+
* 从 .spark/meta.json 读 stack,把 coding-steering 包内对应 stack 的 skills + tech.md
|
|
16
|
+
* 同步到 <dir>/.agent/steering/。需要先跑过 `miaoda app init`。
|
|
17
|
+
*/
|
|
18
|
+
async function handleSkillsSync(opts) {
|
|
19
|
+
await Promise.resolve();
|
|
20
|
+
const targetDir = node_path_1.default.resolve(opts.dir ?? process.cwd());
|
|
21
|
+
const meta = (0, spark_meta_1.readSparkMeta)(targetDir);
|
|
22
|
+
if (meta.stack === undefined || meta.stack === '') {
|
|
23
|
+
throw new error_1.AppError('SKILLS_META_INCOMPLETE', '.spark/meta.json missing stack — run `miaoda app init` first');
|
|
24
|
+
}
|
|
25
|
+
const result = (0, coding_steering_1.syncCodingSteering)({
|
|
26
|
+
stack: meta.stack,
|
|
27
|
+
targetDir,
|
|
28
|
+
version: opts.version,
|
|
29
|
+
});
|
|
30
|
+
(0, output_1.emit)({
|
|
31
|
+
data: {
|
|
32
|
+
stack: meta.stack,
|
|
33
|
+
version: result.version,
|
|
34
|
+
syncedSkills: result.syncedSkills,
|
|
35
|
+
techSynced: result.techSynced,
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
}
|