@lark-apaas/miaoda-cli 0.1.22-alpha.2ecdffe → 0.1.22

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.
Files changed (44) hide show
  1. package/README.md +2 -36
  2. package/dist/api/deploy/index.js +1 -3
  3. package/dist/api/deploy/modern-types.js +1 -4
  4. package/dist/api/deploy/modern.js +0 -8
  5. package/dist/api/index.js +1 -3
  6. package/dist/cli/commands/app/index.js +2 -4
  7. package/dist/cli/commands/deploy/modern.js +0 -34
  8. package/dist/cli/commands/index.js +0 -19
  9. package/dist/cli/handlers/app/init.js +2 -6
  10. package/dist/cli/handlers/deploy/index.js +1 -3
  11. package/dist/cli/handlers/skills/sync.js +4 -12
  12. package/dist/services/app/init/template.js +0 -1
  13. package/dist/services/deploy/modern/atoms/index.js +1 -6
  14. package/dist/services/deploy/modern/atoms/upload.js +127 -4
  15. package/dist/services/deploy/modern/check.js +16 -28
  16. package/dist/services/deploy/modern/pipelines/index.js +1 -3
  17. package/dist/services/deploy/modern/protocol.js +0 -7
  18. package/dist/services/deploy/modern/run.js +4 -10
  19. package/dist/services/deploy/modern/template-key-map.js +0 -4
  20. package/dist/utils/http.js +1 -1
  21. package/package.json +1 -1
  22. package/dist/api/comment/api.js +0 -24
  23. package/dist/api/comment/index.js +0 -6
  24. package/dist/api/comment/types.js +0 -6
  25. package/dist/cli/commands/comment/index.js +0 -55
  26. package/dist/cli/commands/registry/index.js +0 -114
  27. package/dist/cli/handlers/comment/index.js +0 -7
  28. package/dist/cli/handlers/comment/list.js +0 -132
  29. package/dist/cli/handlers/comment/resolve.js +0 -44
  30. package/dist/cli/handlers/deploy/patch.js +0 -17
  31. package/dist/cli/handlers/registry/add.js +0 -97
  32. package/dist/cli/handlers/registry/index.js +0 -7
  33. package/dist/cli/handlers/registry/list.js +0 -48
  34. package/dist/cli/handlers/registry/shared.js +0 -25
  35. package/dist/services/deploy/modern/atoms/design-build.js +0 -49
  36. package/dist/services/deploy/modern/atoms/design-upload.js +0 -74
  37. package/dist/services/deploy/modern/atoms/tosutil.js +0 -246
  38. package/dist/services/deploy/modern/patch/actions.js +0 -61
  39. package/dist/services/deploy/modern/patch/content.js +0 -18
  40. package/dist/services/deploy/modern/patch/index.js +0 -46
  41. package/dist/services/deploy/modern/patch/routes.js +0 -37
  42. package/dist/services/deploy/modern/patch/source-scan.js +0 -58
  43. package/dist/services/deploy/modern/pipelines/design-local.js +0 -56
  44. package/dist/services/registry/index.js +0 -293
package/README.md CHANGED
@@ -11,17 +11,12 @@ pnpm add -g @lark-apaas/miaoda-cli
11
11
  ## 使用
12
12
 
13
13
  ```bash
14
- # 设置默认应用(需要应用上下文的命令从 MIAODA_APP_ID 读取)
14
+ # 设置默认应用(需要应用上下文的命令可用 --app-id 覆盖)
15
15
  export MIAODA_APP_ID=app_demo_xxx
16
16
 
17
17
  # 文件操作
18
18
  miaoda file ls
19
19
  miaoda file upload ./local/path
20
-
21
- # 评论操作
22
- miaoda comment list --json
23
- miaoda comment list --only-unresolved --json
24
- miaoda comment resolve 1703677660120110076 --json
25
20
  ```
26
21
 
27
22
  JSON 结构化输出(Agent 推荐):
@@ -46,38 +41,9 @@ miaoda file ls --output json
46
41
  | `miaoda file ...` | 文件操作:上传、下载、元数据、签名下载、批量删除 |
47
42
  | `miaoda db ...` | 数据操作:SQL 执行、表结构查询、数据导入导出 |
48
43
  | `miaoda observability ...` | 线上日志、链路、前端源码堆栈反查、监控指标、运营指标 |
49
- | `miaoda comment ...` | 应用评论:查看评论列表、解决评论 |
50
- | `miaoda registry ...` | 组件 registry:列出 / copy-in design-html SDK 文件(本地执行) |
51
44
 
52
45
  完整命令通过 `miaoda --help` 或 `miaoda <domain> --help` 查看。
53
46
 
54
- ## 组件 registry(design-html)
55
-
56
- `miaoda registry` 为 design-html 技术栈提供 shadcn 式的「组件 registry」:把 SDK 文件**拷进**当前项目(copy-in),而非作为依赖安装。registry 是独立 npm 包,按运行时分发(design-html → buildless runtime → `@lark-apaas/coding-registry-buildless`)。
57
-
58
- 前置:当前目录(或 `--dir`)已走过 `miaoda app init`,`.spark/meta.json` 含 `stack=design-html`。
59
-
60
- ```bash
61
- # 列出可用 SDK 条目(输出各文件 USAGE 注释块原文,便于 Agent 直接读用法)
62
- miaoda registry list
63
- miaoda registry list --json
64
-
65
- # 把条目 copy-in 到当前项目(自动按 USAGE 块的 Depends 解析依赖闭包一并拷入)
66
- miaoda registry add deck-slide
67
- miaoda registry add foo.css theme --dry-run # 只报告将写 / 将跳,不落盘
68
- miaoda registry add deck-slide --overwrite # 目标已存在时覆盖(默认跳过以保护改动)
69
- ```
70
-
71
- 要点:
72
-
73
- - **条目**:registry 包根 `components/` · `scripts/` · `stylesheets/` 三个顶层目录(任意深度)下的代码文件即条目。USAGE 注释块**可选**(有则提供描述 + Depends,无则空描述、无依赖);包根直放文件、其它目录、非代码文件都不算条目。
74
- - **寻址**:`add` / `Depends` 的 token 可写三种形式 —— `name`(去扩展名,如 `foo`)/ 完整文件名(如 `foo.css`)/ relPath(如 `stylesheets/foo.css`)。`name` **不要求唯一**,`list --json` 的 `file`(relPath)是永远无歧义的 canonical 地址。
75
- - **多匹配全拉**:token 命中多个同名条目时全部 copy-in(如 `add foo` 把 `foo.jsx` + `foo.css` 一起拉),想只要其一就用完整文件名或 relPath。
76
- - **拍平落地**:所有文件**拍平**到项目根(`scripts/deck-slide.js` → 项目 `deck-slide.js`,不保留子目录);闭包内同名 basename 撞车时后者覆盖前者。
77
- - **skip-by-disk**:项目已有同名(拍平后的 basename)文件默认跳过,`--overwrite` 才覆盖;不写任何安装记账文件,项目文件树即状态。
78
- - **add 回执带 usage**:`add` 结果的 `entries` 只列**你请求的条目**(不含被 `Depends` 传递拉进来的依赖——依赖照常落地在 `added`/`skipped`,但那是"管道"),逐条给出 `usage`(USAGE 块原文)与 `dependsOn`,Agent `add` 完即可直接读用法,无需再 `registry list`。请求的条目即使已存在被跳过也回带 usage(`status` 标 `added`/`skipped`,据此判断磁盘上是 registry 版还是你改过的旧版)。`--json` 结构为 `{registryVersion, added, skipped, dryRun, entries}`;pretty(默认)输出 `registry@<ver>` + `added:`/`skipped:` 逗号列表 + 各请求条目的 USAGE 块,稳定 label、无 JSON 数组、无截断,对 Agent 与人同样可读。
79
- - `--version <ver>` 指定 registry 包版本或 dist-tag(缺省 `latest`),`--dir <path>` 指定项目目录(缺省当前目录)。
80
-
81
47
  ## 全局参数
82
48
 
83
49
  - `--json [fields]`:输出结构化 JSON,可选字段级选择(如 `--json id,name`)。
@@ -89,7 +55,7 @@ miaoda registry add deck-slide --overwrite # 目标已存在时覆盖(
89
55
  ## 环境变量
90
56
 
91
57
  - `MIAODA_APP_ID`:默认应用 ID,等价于 `--app-id`。
92
- - `MIAODA_CANARY_HEADER`:HTTP 请求的 `x-tt-env` 小流量头取值。未设置时默认 `boe_miaoda_ccm`;设为空字符串则不带该头(例:`export MIAODA_CANARY_HEADER=boe_xxx`)。值形如 `ppe_xxx` 时额外带上 `x-use-ppe: 1`。
58
+ - `MIAODA_CANARY_HEADER`:HTTP 请求的 `x-tt-env` 小流量头取值。未设置时默认 `boe_miaoda_doubao`;设为空字符串则不带该头(例:`export MIAODA_CANARY_HEADER=boe_xxx`)。值形如 `ppe_xxx` 时额外带上 `x-use-ppe: 1`。
93
59
 
94
60
  ## 输出契约
95
61
 
@@ -1,6 +1,6 @@
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.batchSavePluginInstances = exports.TosActionType = exports.LocalReleaseStatus = exports.applyTosDiff = exports.getModernLastPublishedVersion = exports.getModernReleaseStatus = exports.createModernRelease = exports.callbackStatic = exports.updateLocalRelease = exports.createLocalRelease = exports.preRelease = 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; } });
@@ -14,10 +14,8 @@ Object.defineProperty(exports, "callbackStatic", { enumerable: true, get: functi
14
14
  Object.defineProperty(exports, "createModernRelease", { enumerable: true, get: function () { return modern_1.createRelease; } });
15
15
  Object.defineProperty(exports, "getModernReleaseStatus", { enumerable: true, get: function () { return modern_1.getReleaseStatus; } });
16
16
  Object.defineProperty(exports, "getModernLastPublishedVersion", { enumerable: true, get: function () { return modern_1.getLastPublishedVersion; } });
17
- Object.defineProperty(exports, "applyTosDiff", { enumerable: true, get: function () { return modern_1.applyTosDiff; } });
18
17
  var modern_types_1 = require("./modern-types");
19
18
  Object.defineProperty(exports, "LocalReleaseStatus", { enumerable: true, get: function () { return modern_types_1.LocalReleaseStatus; } });
20
- Object.defineProperty(exports, "TosActionType", { enumerable: true, get: function () { return modern_types_1.TosActionType; } });
21
19
  var plugin_instances_1 = require("./plugin-instances");
22
20
  Object.defineProperty(exports, "batchSavePluginInstances", { enumerable: true, get: function () { return plugin_instances_1.batchSavePluginInstances; } });
23
21
  var schemas_1 = require("./schemas");
@@ -8,7 +8,7 @@
8
8
  //
9
9
  // 远端部署链路(B/C)所需的 release 接口先预留类型骨架,待 B/C 落地时启用。
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.TosActionType = exports.LocalReleaseStatus = void 0;
11
+ exports.LocalReleaseStatus = void 0;
12
12
  /**
13
13
  * localPublish 状态枚举(数值,与服务端 IDL 对齐)。
14
14
  * CLI updateLocalRelease 只翻 Finished / Failed 两个终态;其它由后端流转。
@@ -21,6 +21,3 @@ exports.LocalReleaseStatus = {
21
21
  Canceled: 4,
22
22
  Rollback: 5,
23
23
  };
24
- // ── applyTosDiff(design-html 增量发布;后端应用 TOS diff) ──
25
- /** 对齐 IDL publish.TosActionType(UNSPECIFIED=0 不用) */
26
- exports.TosActionType = { CREATE: 1, UPDATE: 2, DELETE: 3 };
@@ -17,7 +17,6 @@ exports.callbackStatic = callbackStatic;
17
17
  exports.createRelease = createRelease;
18
18
  exports.getReleaseStatus = getReleaseStatus;
19
19
  exports.getLastPublishedVersion = getLastPublishedVersion;
20
- exports.applyTosDiff = applyTosDiff;
21
20
  const http_1 = require("../../utils/http");
22
21
  const devops_error_1 = require("../../utils/devops-error");
23
22
  const DEFAULT_ERR_CODE = 'INTERNAL_DEVOPS_ERROR';
@@ -77,10 +76,3 @@ async function getLastPublishedVersion(req) {
77
76
  const url = `/v1/devops/app/${encodeURIComponent(appID)}/last_published_version`;
78
77
  return (0, http_1.postInnerApi)(url, {}, envelopeOpts('Failed to get last published version'));
79
78
  }
80
- // ── applyTosDiff ──
81
- /** POST /v1/devops/app/:appID/apply_tos_diff —— 增量应用 TOS 文件 diff */
82
- async function applyTosDiff(req) {
83
- const { appID, ...body } = req;
84
- const url = `/v1/devops/app/${encodeURIComponent(appID)}/apply_tos_diff`;
85
- return (0, http_1.postInnerApi)(url, body, envelopeOpts('Failed to apply tos diff'));
86
- }
package/dist/api/index.js CHANGED
@@ -33,18 +33,16 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.comment = exports.deploy = exports.app = exports.observability = exports.db = exports.file = exports.plugin = void 0;
36
+ exports.deploy = exports.app = exports.observability = exports.db = exports.file = exports.plugin = void 0;
37
37
  const _plugin = __importStar(require("../api/plugin/index"));
38
38
  const _file = __importStar(require("../api/file/index"));
39
39
  const _db = __importStar(require("../api/db/index"));
40
40
  const _observability = __importStar(require("../api/observability/index"));
41
41
  const _app = __importStar(require("../api/app/index"));
42
42
  const _deploy = __importStar(require("../api/deploy/index"));
43
- const _comment = __importStar(require("../api/comment/index"));
44
43
  exports.plugin = { ..._plugin };
45
44
  exports.file = { ..._file };
46
45
  exports.db = { ..._db };
47
46
  exports.observability = { ..._observability };
48
47
  exports.app = { ..._app };
49
48
  exports.deploy = { ..._deploy };
50
- exports.comment = { ..._comment };
@@ -166,7 +166,7 @@ function registerAppInit(parent) {
166
166
  .option('--template <stack>', `技术栈短名(${index_1.SUPPORTED_STACKS.join(' / ')})`)
167
167
  .option('--app-type <type>', 'aPaaS 业务类型(html / modern_html / jspage / full_stack);未传 --template 时用于解析技术栈')
168
168
  .option('--source-path <path>', '导入源目录:把该目录内容聚合进脚手架 src/(当前仅 --app-type modern_html 生效)')
169
- .option('--conf [json]', 'init 配置 JSON。支持 {"version": "<template 版本>"},默认 latest')
169
+ .option('--conf <json>', 'init 配置 JSON。支持 {"version": "<template 版本>"},默认 latest')
170
170
  .option('--skip-install', '跳过依赖安装', false)
171
171
  .option('--async-install', '派发后台进程装依赖并立即返回(与 --skip-install 互斥)', false)
172
172
  .addOption((0, shared_1.appIdOption)())
@@ -252,9 +252,7 @@ JSON 输出
252
252
  }));
253
253
  }
254
254
  function parseInitConf(raw) {
255
- // --conf 为可选值:未传(undefined)、裸 --conf(Commander 给 true)、空/纯空白字符串
256
- // 一律视为不配置,回退默认(latest)。
257
- if (raw === undefined || typeof raw === 'boolean' || raw.trim() === '')
255
+ if (raw === undefined)
258
256
  return undefined;
259
257
  let parsed;
260
258
  try {
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.registerDeployCommandsModern = registerDeployCommandsModern;
4
4
  const shared_1 = require("../../../cli/commands/shared");
5
5
  const modern_1 = require("../../../cli/handlers/deploy/modern");
6
- const index_1 = require("../../../cli/handlers/deploy/index");
7
6
  /**
8
7
  * modern scene (MIAODA_APP_TYPE=7) 专用 deploy 注册。
9
8
  * 仅披露顶层 `miaoda deploy`,CLI 表面对齐 openclaw-cli:`--dir / --skip-build`。
@@ -57,37 +56,4 @@ JSON 输出(stdout)
57
56
  conf: rawOpts.conf,
58
57
  });
59
58
  }));
60
- const patchCmd = deployCmd
61
- .command('patch')
62
- .description('design-html 增量发布:按文件 create/update/delete,.html 增删时同步 routes.json')
63
- .option('--create <relpath>', '新增文件(可重复)', shared_1.collectRepeatedOption, [])
64
- .option('--update <relpath>', '覆盖已有文件(可重复)', shared_1.collectRepeatedOption, [])
65
- .option('--delete <relpath>', '删除文件(可重复)', shared_1.collectRepeatedOption, [])
66
- .option('--session-id <id>', '会话 ID,发布时透传给下游(可选)')
67
- .addHelpText('after', `
68
- --dir 为项目目录(与 deploy 同名参数,默认当前目录)。
69
- 仅支持 design-html(design_local_deploy)。路径为工程根相对路径(= 服务端 latest 下 key),
70
- 禁绝对路径与 ".."。--create/--update 的本地文件必须存在。.html 被新增/删除(路由集合变化)
71
- 时自动重算并随包更新 routes.json;纯 --update 现有 .html 只改内容,不动 routes.json。
72
- routes.json 每项为 {path, file}:path 为相对路径(不含 base 前缀,由消费侧拼接),file 为
73
- 对应源文件(如 / → index.html)。
74
-
75
- JSON 输出
76
- {"data": {"upsertCount": <n>, "deleteCount": <n>, "actionsSent": <n>, "routesRegenerated": <bool>}}
77
-
78
- 示例
79
- $ miaoda deploy patch --update index.html
80
- $ miaoda deploy patch --create blog/post.html --delete blog/old.html
81
- $ miaoda deploy patch --update assets/app.js --update assets/app.css
82
- `);
83
- patchCmd.action((0, shared_1.withHelp)(patchCmd, async (rawOpts) => {
84
- await (0, index_1.handleDeployPatch)({
85
- appId: (0, shared_1.resolveAppId)({}),
86
- dir: deployCmd.opts().dir ?? '.',
87
- creates: rawOpts.create,
88
- updates: rawOpts.update,
89
- deletes: rawOpts.delete,
90
- sessionId: rawOpts.sessionId,
91
- });
92
- }));
93
59
  }
@@ -9,14 +9,11 @@ const index_4 = require("../../cli/commands/app/index");
9
9
  const index_5 = require("../../cli/commands/deploy/index");
10
10
  const modern_1 = require("../../cli/commands/deploy/modern");
11
11
  const index_6 = require("../../cli/commands/skills/index");
12
- const index_7 = require("../../cli/commands/comment/index");
13
- const index_8 = require("../../cli/commands/registry/index");
14
12
  // scene 跟 dispatcher(MIAODA_APP_TYPE)同语义层级 —— app 业务类型维度,
15
13
  // 对齐后端 devops app_common.AppType 枚举:
16
14
  // 3 = AppType_APPLICATION(全栈应用,当前仅 nestjs-react-fullstack 一个 stack)
17
15
  // 4 = AppType_DESIGN(design-stack,SSR 渲染、无业务逻辑、无数据库)
18
16
  // 7 = miaoda-cli 自定义 modern 占位(后端枚举无 7,沙箱目前不传)
19
- // 8 = AppType_DESIGN_HTML(design-html,buildless 静态 HTML,命令集同 modern)
20
17
  // 其它(0/1/2/5/6 / 未设)→ default(命令全开,本地 dev / CI / 兼容回退)
21
18
  // stack 维度(nestjs-react-fullstack / vite-react / ...)是正交的,
22
19
  // skills sync 内部按 .spark/meta.json.stack 拉对应 coding-steering/steering/<stack>/ 子目录。
@@ -27,8 +24,6 @@ function resolveScene(appType, _archType) {
27
24
  return 'application';
28
25
  if (appType === '4')
29
26
  return 'design';
30
- if (appType === '8')
31
- return 'design-html';
32
27
  return 'default';
33
28
  }
34
29
  const SCENE_REGISTRARS = {
@@ -42,13 +37,11 @@ const SCENE_REGISTRARS = {
42
37
  (0, index_1.registerFileCommands)(p);
43
38
  (0, index_3.registerObservabilityCommands)(p);
44
39
  (0, index_6.registerSkillsCommands)(p);
45
- (0, index_7.registerCommentCommands)(p);
46
40
  },
47
41
  modern: (p) => {
48
42
  (0, index_4.registerAppCommands)(p, { includeInit: true });
49
43
  (0, modern_1.registerDeployCommandsModern)(p);
50
44
  (0, index_6.registerSkillsCommands)(p);
51
- (0, index_7.registerCommentCommands)(p);
52
45
  },
53
46
  // application scene(AppType_APPLICATION=3):
54
47
  // 在 default 命令集基础上加 skills(按 meta.json.stack 拉对应 stack 技能)
@@ -60,7 +53,6 @@ const SCENE_REGISTRARS = {
60
53
  (0, index_1.registerFileCommands)(p);
61
54
  (0, index_3.registerObservabilityCommands)(p);
62
55
  (0, index_6.registerSkillsCommands)(p);
63
- (0, index_7.registerCommentCommands)(p);
64
56
  },
65
57
  // design scene(AppType_DESIGN=4):design-stack 仅 SSR 渲染、无后端业务逻辑、
66
58
  // 无数据库、无 UGC 文件。命令集裁掉 db / file,保留 deploy / observability / app(init) / skills。
@@ -69,17 +61,6 @@ const SCENE_REGISTRARS = {
69
61
  (0, index_5.registerDeployCommands)(p);
70
62
  (0, index_3.registerObservabilityCommands)(p);
71
63
  (0, index_6.registerSkillsCommands)(p);
72
- (0, index_7.registerCommentCommands)(p);
73
- },
74
- // design-html scene(AppType_DESIGN_HTML=8):buildless 静态 HTML,
75
- // 命令集与 modern 一致(app init/sync + modern 拆分版 deploy + skills),不挂 db/file/observability。
76
- // 额外挂 registry(shadcn 式 copy-in SDK,design-html scene 专属)。
77
- 'design-html': (p) => {
78
- (0, index_4.registerAppCommands)(p, { includeInit: true });
79
- (0, modern_1.registerDeployCommandsModern)(p);
80
- (0, index_6.registerSkillsCommands)(p);
81
- (0, index_8.registerRegistryCommands)(p);
82
- (0, index_7.registerCommentCommands)(p);
83
64
  },
84
65
  };
85
66
  function readEnv(name) {
@@ -61,12 +61,8 @@ async function handleAppInit(opts) {
61
61
  // source_path 导入:当前仅 app_type=modern_html 生效。渲染完模板后、装依赖前叠加进 src/。
62
62
  const sourceImport = applySourcePathImport(opts, targetDir);
63
63
  // 先建 logs/,防止 user 跑 dev 之前 AI/工具 redirect 到 logs/*.log 因为父目录不存在直接挂
64
- // (dev.js / dev-local.js 自己也建 logs/,但只在它启动后;启动前的 shell redirect 会先于此)
65
- // 仅本地开发需要:沙箱环境由平台 supervisor 拉起 dev,无 init 前的 shell redirect 场景,
66
- // 不预建 logs/ 以免在沙箱工作区留空目录。
67
- if (!(0, env_1.isSandboxEnv)()) {
68
- (0, logs_dir_1.ensureLogsDir)(targetDir);
69
- }
64
+ // (dev.js / dev-local.js 自己也建 logs/,但只在它启动后;启动前的 shell redirect 会先于此)
65
+ (0, logs_dir_1.ensureLogsDir)(targetDir);
70
66
  // skills 同步软失败:拉不到 coding-steering 包不该阻断 writeSparkMeta /
71
67
  // activateGitHooks(之前会让 .spark/meta.json 没写,下次 init 半渲染状态又得重跑全套)。
72
68
  // 按运行环境(isSandboxEnv:MIAODA_DEP_CACHE_DIR 非空)分流 outputLayout,不绑 stack:
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.handleDeployPatch = exports.DEFAULT_POLL_INTERVAL_MS = exports.waitForPipeline = exports.handleDeployErrorLog = exports.handleDeployHistory = exports.handleDeployGet = exports.handleDeploy = void 0;
3
+ exports.DEFAULT_POLL_INTERVAL_MS = exports.waitForPipeline = exports.handleDeployErrorLog = exports.handleDeployHistory = exports.handleDeployGet = exports.handleDeploy = void 0;
4
4
  var deploy_1 = require("./deploy");
5
5
  Object.defineProperty(exports, "handleDeploy", { enumerable: true, get: function () { return deploy_1.handleDeploy; } });
6
6
  var get_1 = require("./get");
@@ -12,5 +12,3 @@ Object.defineProperty(exports, "handleDeployErrorLog", { enumerable: true, get:
12
12
  var polling_1 = require("./polling");
13
13
  Object.defineProperty(exports, "waitForPipeline", { enumerable: true, get: function () { return polling_1.waitForPipeline; } });
14
14
  Object.defineProperty(exports, "DEFAULT_POLL_INTERVAL_MS", { enumerable: true, get: function () { return polling_1.DEFAULT_POLL_INTERVAL_MS; } });
15
- var patch_1 = require("./patch");
16
- Object.defineProperty(exports, "handleDeployPatch", { enumerable: true, get: function () { return patch_1.handleDeployPatch; } });
@@ -15,13 +15,8 @@ const output_1 = require("../../../utils/output");
15
15
  * 从 .spark/meta.json 读 stack,把 coding-steering 包内对应 stack 的 skills + tech.md
16
16
  * 同步到 <dir>/.agent/steering/。需要先跑过 `miaoda app init`。
17
17
  *
18
- * 版本来源优先级(从高到低):
19
- * 1. CLI `--version` flag(显式指定)
20
- * 2. `FORCE_FRAMEWORK_ENVIRONMENT=boe` → dist-tag `dev`(BOE 测试灰度,跟随
21
- * publish-alpha.sh 在 develop 分支打的 dev tag,便于在 BOE 沙箱里验证预发 steering)
22
- * 3. 默认 `latest`
23
- *
24
- * **不读 meta.json**——steering 版本不在 meta 里钉。
18
+ * 版本来源:CLI `--version` flag 或默认 `latest`。**不读 meta.json**——steering 版本
19
+ * 不在 meta 里钉,每次 sync 都跟随 `--version` 显式传或退回 @latest。
25
20
  */
26
21
  async function handleSkillsSync(opts) {
27
22
  await Promise.resolve();
@@ -30,20 +25,17 @@ async function handleSkillsSync(opts) {
30
25
  if (meta.stack === undefined || meta.stack === '') {
31
26
  throw new error_1.AppError('SKILLS_META_INCOMPLETE', '.spark/meta.json missing stack — run `miaoda app init` first');
32
27
  }
33
- const isBoe = process.env.FORCE_FRAMEWORK_ENVIRONMENT === 'boe';
34
- const effectiveVersion = opts.version ?? (isBoe ? 'dev' : undefined);
35
- const versionSource = opts.version !== undefined ? 'cli-arg' : isBoe ? 'boe-default-dev' : 'default-latest';
36
28
  const result = (0, coding_steering_1.syncCodingSteering)({
37
29
  stack: meta.stack,
38
30
  targetDir,
39
- version: effectiveVersion,
31
+ version: opts.version,
40
32
  outputLayout: opts.local === true ? 'flat' : 'nested',
41
33
  });
42
34
  (0, output_1.emit)({
43
35
  data: {
44
36
  stack: meta.stack,
45
37
  version: result.version,
46
- versionSource,
38
+ versionSource: opts.version !== undefined ? 'cli-arg' : 'default-latest',
47
39
  syncedSkills: result.syncedSkills,
48
40
  techSynced: result.techSynced,
49
41
  ...(result.claudeSkillsLink !== undefined
@@ -16,7 +16,6 @@ exports.TEMPLATE_PACKAGE_BY_STACK = {
16
16
  'vite-react': '@lark-apaas/coding-template-vite-react',
17
17
  html: '@lark-apaas/coding-template-html',
18
18
  'nestjs-react-fullstack': '@lark-apaas/coding-template-nestjs-react-fullstack',
19
- 'design-html': '@lark-apaas/coding-template-design-html',
20
19
  };
21
20
  /**
22
21
  * 短名 → template 包钉版表。renderTemplate 默认按这张表取版本号,表外 stack 跟 npm latest。
@@ -1,17 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.savePluginInstances = exports.LocalReleaseStatus = exports.finalizeLocalRelease = exports.createLocalRelease = exports.uploadArtifacts = exports.uploadDesignArtifacts = exports.cleanDesignDist = exports.buildDesignOutput = exports.runBuild = exports.preRelease = exports.prepareDeployContext = void 0;
3
+ exports.savePluginInstances = exports.LocalReleaseStatus = exports.finalizeLocalRelease = exports.createLocalRelease = exports.uploadArtifacts = exports.runBuild = exports.preRelease = exports.prepareDeployContext = void 0;
4
4
  var context_1 = require("./context");
5
5
  Object.defineProperty(exports, "prepareDeployContext", { enumerable: true, get: function () { return context_1.prepareDeployContext; } });
6
6
  var pre_release_1 = require("./pre-release");
7
7
  Object.defineProperty(exports, "preRelease", { enumerable: true, get: function () { return pre_release_1.preRelease; } });
8
8
  var build_1 = require("./build");
9
9
  Object.defineProperty(exports, "runBuild", { enumerable: true, get: function () { return build_1.runBuild; } });
10
- var design_build_1 = require("./design-build");
11
- Object.defineProperty(exports, "buildDesignOutput", { enumerable: true, get: function () { return design_build_1.buildDesignOutput; } });
12
- Object.defineProperty(exports, "cleanDesignDist", { enumerable: true, get: function () { return design_build_1.cleanDesignDist; } });
13
- var design_upload_1 = require("./design-upload");
14
- Object.defineProperty(exports, "uploadDesignArtifacts", { enumerable: true, get: function () { return design_upload_1.uploadDesignArtifacts; } });
15
10
  var upload_1 = require("./upload");
16
11
  Object.defineProperty(exports, "uploadArtifacts", { enumerable: true, get: function () { return upload_1.uploadArtifacts; } });
17
12
  var local_release_1 = require("./local-release");
@@ -5,13 +5,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.uploadArtifacts = uploadArtifacts;
7
7
  const node_fs_1 = __importDefault(require("node:fs"));
8
+ const node_os_1 = __importDefault(require("node:os"));
8
9
  const node_path_1 = __importDefault(require("node:path"));
10
+ const node_child_process_1 = require("node:child_process");
9
11
  const index_1 = require("../../../../api/deploy/index");
10
12
  const error_1 = require("../../../../utils/error");
11
13
  const logger_1 = require("../../../../utils/logger");
12
14
  const constants_1 = require("../constants");
13
15
  const protocol_1 = require("../protocol");
14
- const tosutil_1 = require("./tosutil");
15
16
  const UPLOAD_PLAN = [
16
17
  {
17
18
  kind: 'tos',
@@ -31,6 +32,28 @@ const UPLOAD_PLAN = [
31
32
  dataKey: protocol_1.DataKey.OUTPUT_STATIC_PAAS_STORAGE_CREDENTIAL,
32
33
  },
33
34
  ];
35
+ function resolveTosutilPath() {
36
+ try {
37
+ const resolved = (0, node_child_process_1.execFileSync)('which', ['tosutil'], { encoding: 'utf-8' }).trim();
38
+ if (resolved)
39
+ return resolved;
40
+ }
41
+ catch {
42
+ /* fallthrough */
43
+ }
44
+ throw new error_1.AppError('DEPLOY_TOSUTIL_MISSING', 'tosutil is not installed or not in PATH. modern deploy requires sandbox preinstalled tosutil.');
45
+ }
46
+ function tosutilUploadFromTos(cred) {
47
+ return {
48
+ accessKeyID: cred.accessKeyID,
49
+ secretAccessKey: cred.secretAccessKey,
50
+ sessionToken: cred.sessionToken,
51
+ endpoint: cred.endpoint,
52
+ region: cred.region,
53
+ bucket: cred.bucket,
54
+ prefix: cred.prefix,
55
+ };
56
+ }
34
57
  function tosutilUploadFromPaasStorage(cred, dataKey) {
35
58
  const { bucket, prefix } = (0, protocol_1.parseTosUploadPrefix)(cred.uploadPrefix, dataKey);
36
59
  return {
@@ -43,6 +66,106 @@ function tosutilUploadFromPaasStorage(cred, dataKey) {
43
66
  prefix,
44
67
  };
45
68
  }
69
+ /**
70
+ * 写一个 tosutil 临时 config 文件,注入 STS 凭证 + endpoint + region。
71
+ * 返回 config 路径,调用方负责清理。
72
+ */
73
+ function writeTosutilConfig(tosutilPath, cred, label) {
74
+ const confPath = node_path_1.default.join(node_os_1.default.tmpdir(), `.tosutilconfig-miaoda-${label}-${String(process.pid)}-${String(Date.now())}`);
75
+ node_fs_1.default.writeFileSync(confPath, '');
76
+ (0, node_child_process_1.execFileSync)(tosutilPath, [
77
+ 'config',
78
+ '-conf',
79
+ confPath,
80
+ '-e',
81
+ cred.endpoint,
82
+ '-i',
83
+ cred.accessKeyID,
84
+ '-k',
85
+ cred.secretAccessKey,
86
+ '-t',
87
+ cred.sessionToken,
88
+ '-re',
89
+ cred.region,
90
+ ], { stdio: 'pipe' });
91
+ return confPath;
92
+ }
93
+ /** 把 tosutil 进程的输出按行回放到 stderr,便于线上排查(沙箱里无法 attach 进程)。 */
94
+ function streamTosutilOutput(output) {
95
+ if (!output)
96
+ return;
97
+ for (const line of output.split('\n')) {
98
+ if (line.length === 0)
99
+ continue;
100
+ process.stderr.write(`[tosutil] ${line}\n`);
101
+ }
102
+ }
103
+ function normalizeTosDest(bucket, prefix) {
104
+ const bucketPart = bucket.startsWith('tos://') ? bucket : `tos://${bucket}`;
105
+ const normalized = prefix.replace(/^\/+/, '');
106
+ return `${bucketPart.replace(/\/+$/, '')}/${normalized}`;
107
+ }
108
+ /**
109
+ * 用 tosutil 把目录批量上传到 tos://bucket/prefix(STS 凭证从 config 文件读取)。
110
+ */
111
+ function uploadDirWithCredential(tosutilPath, sourceDir, cred, label) {
112
+ const entries = node_fs_1.default.readdirSync(sourceDir);
113
+ if (entries.length === 0) {
114
+ (0, logger_1.debug)(`upload: skip empty dir ${sourceDir}`);
115
+ return;
116
+ }
117
+ const dest = normalizeTosDest(cred.bucket, cred.prefix);
118
+ (0, logger_1.debug)(`upload: ${sourceDir} -> ${dest} (${String(entries.length)} entries)`);
119
+ const confPath = writeTosutilConfig(tosutilPath, cred, label);
120
+ let output;
121
+ try {
122
+ output = (0, node_child_process_1.execFileSync)(tosutilPath, [
123
+ 'cp',
124
+ sourceDir,
125
+ dest,
126
+ '-r',
127
+ '-flat',
128
+ '-j',
129
+ '5',
130
+ '-p',
131
+ '3',
132
+ '-ps',
133
+ '10485760',
134
+ '-f',
135
+ '-conf',
136
+ confPath,
137
+ ], { encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'] });
138
+ streamTosutilOutput(output);
139
+ }
140
+ catch (err) {
141
+ const e = err;
142
+ const stderr = (e.stderr ?? '').trim();
143
+ const stdout = (e.stdout ?? '').trim();
144
+ streamTosutilOutput(stdout);
145
+ streamTosutilOutput(stderr);
146
+ throw new error_1.AppError('DEPLOY_UPLOAD_FAILED', `tosutil cp exited with status ${String(e.status ?? -1)} for ${sourceDir}\n` +
147
+ ` stderr: ${stderr || '(empty)'}\n` +
148
+ ` stdout: ${stdout.slice(0, 500) || '(empty)'}`);
149
+ }
150
+ finally {
151
+ try {
152
+ node_fs_1.default.unlinkSync(confPath);
153
+ }
154
+ catch {
155
+ /* ignore */
156
+ }
157
+ }
158
+ const succeedMatch = /Succeed count is:\s*(\d+)/.exec(output);
159
+ const failedMatch = /Failed count is:\s*(\d+)/.exec(output);
160
+ const succeedCount = succeedMatch ? Number.parseInt(succeedMatch[1], 10) : 0;
161
+ const failedCount = failedMatch ? Number.parseInt(failedMatch[1], 10) : 0;
162
+ if (failedCount > 0) {
163
+ throw new error_1.AppError('DEPLOY_UPLOAD_FAILED', `Upload failed: ${String(failedCount)} files failed, ${String(succeedCount)} succeeded. source=${sourceDir}`);
164
+ }
165
+ if (succeedCount === 0) {
166
+ throw new error_1.AppError('DEPLOY_UPLOAD_EMPTY', `Upload failed: 0 files uploaded. source=${sourceDir}. Check tosutil credentials and bucket permissions.`);
167
+ }
168
+ }
46
169
  function uploadTosTarget(tosutilPath, target, localPath, data) {
47
170
  const credRaw = target.required
48
171
  ? (0, protocol_1.requireDataKey)(data, target.dataKey)
@@ -53,7 +176,7 @@ function uploadTosTarget(tosutilPath, target, localPath, data) {
53
176
  }
54
177
  const cred = (0, protocol_1.parseTosUploadCredential)(credRaw, target.dataKey);
55
178
  (0, logger_1.log)('deploy', `Uploading ${target.dir}...`);
56
- (0, tosutil_1.uploadDirWithCredential)(tosutilPath, localPath, (0, tosutil_1.tosutilUploadFromTos)(cred), target.dir);
179
+ uploadDirWithCredential(tosutilPath, localPath, tosutilUploadFromTos(cred), target.dir);
57
180
  return true;
58
181
  }
59
182
  function uploadPaasStorageTarget(tosutilPath, target, localPath, data) {
@@ -65,7 +188,7 @@ function uploadPaasStorageTarget(tosutilPath, target, localPath, data) {
65
188
  }
66
189
  const cred = (0, protocol_1.parsePaasStorageCredential)((0, protocol_1.requireDataKey)(data, target.dataKey), target.dataKey);
67
190
  (0, logger_1.log)('deploy', `Uploading ${target.dir}...`);
68
- (0, tosutil_1.uploadDirWithCredential)(tosutilPath, localPath, tosutilUploadFromPaasStorage(cred, target.dataKey), target.dir);
191
+ uploadDirWithCredential(tosutilPath, localPath, tosutilUploadFromPaasStorage(cred, target.dataKey), target.dir);
69
192
  return cred;
70
193
  }
71
194
  /**
@@ -79,7 +202,7 @@ function uploadPaasStorageTarget(tosutilPath, target, localPath, data) {
79
202
  * 目录不存在的可选项跳过;output 不存在或凭证缺失抛错。
80
203
  */
81
204
  async function uploadArtifacts(opts) {
82
- const tosutilPath = (0, tosutil_1.resolveTosutilPath)();
205
+ const tosutilPath = resolveTosutilPath();
83
206
  const distDir = node_path_1.default.join(opts.projectDir, constants_1.DIST_DIR);
84
207
  const outcome = { uploaded: 0 };
85
208
  for (const target of UPLOAD_PLAN) {
@@ -7,20 +7,16 @@ exports.runDeployChecks = runDeployChecks;
7
7
  const node_fs_1 = __importDefault(require("node:fs"));
8
8
  const node_path_1 = __importDefault(require("node:path"));
9
9
  const error_1 = require("../../../utils/error");
10
- const template_key_map_1 = require("./template-key-map");
11
10
  /**
12
11
  * 项目级 deploy 前置检查:node_modules / .spark/meta.json / package.json.scripts.build。
13
12
  * 任一 error 级别失败抛 AppError,附错误码 DEPLOY_PROJECT_CHECK_FAILED。
14
- *
15
- * design buildless 链路(design_local_deploy,如 design-html)的 build 直接拷源码 + 生成
16
- * routes.json(见 atoms/design-build.ts),不跑 `npm run build`、不读 package.json、不依赖
17
- * node_modules,因此对其跳过 node_modules / package.json / build 脚本三项检查,只保留
18
- * meta.json + stack 校验。
19
13
  */
20
14
  function runDeployChecks(projectDir) {
21
15
  const issues = [];
22
- // 先读 stack 判断是否 design buildless 链路,决定后续是否豁免 node_modules / build 检查。
23
- let stack;
16
+ const nodeModules = node_path_1.default.join(projectDir, 'node_modules');
17
+ if (!node_fs_1.default.existsSync(nodeModules)) {
18
+ issues.push('node_modules not found. Run `npm install` (or equivalent) first.');
19
+ }
24
20
  const metaPath = node_path_1.default.join(projectDir, '.spark', 'meta.json');
25
21
  if (!node_fs_1.default.existsSync(metaPath)) {
26
22
  issues.push('.spark/meta.json not found. Run `miaoda app init` first.');
@@ -28,7 +24,6 @@ function runDeployChecks(projectDir) {
28
24
  else {
29
25
  try {
30
26
  const meta = JSON.parse(node_fs_1.default.readFileSync(metaPath, 'utf-8'));
31
- stack = meta.stack;
32
27
  if (!meta.stack) {
33
28
  issues.push('.spark/meta.json missing fields: stack');
34
29
  }
@@ -37,27 +32,20 @@ function runDeployChecks(projectDir) {
37
32
  issues.push('.spark/meta.json is not valid JSON.');
38
33
  }
39
34
  }
40
- const isDesign = stack !== undefined && (0, template_key_map_1.resolveTemplateKey)(stack) === template_key_map_1.DESIGN_LOCAL_DEPLOY;
41
- if (!isDesign) {
42
- const nodeModules = node_path_1.default.join(projectDir, 'node_modules');
43
- if (!node_fs_1.default.existsSync(nodeModules)) {
44
- issues.push('node_modules not found. Run `npm install` (or equivalent) first.');
45
- }
46
- const pkgPath = node_path_1.default.join(projectDir, 'package.json');
47
- if (!node_fs_1.default.existsSync(pkgPath)) {
48
- issues.push('package.json not found.');
49
- }
50
- else {
51
- try {
52
- const pkg = JSON.parse(node_fs_1.default.readFileSync(pkgPath, 'utf-8'));
53
- if (!pkg.scripts?.build) {
54
- issues.push('package.json missing "build" script.');
55
- }
56
- }
57
- catch {
58
- issues.push('package.json is not valid JSON.');
35
+ const pkgPath = node_path_1.default.join(projectDir, 'package.json');
36
+ if (!node_fs_1.default.existsSync(pkgPath)) {
37
+ issues.push('package.json not found.');
38
+ }
39
+ else {
40
+ try {
41
+ const pkg = JSON.parse(node_fs_1.default.readFileSync(pkgPath, 'utf-8'));
42
+ if (!pkg.scripts?.build) {
43
+ issues.push('package.json missing "build" script.');
59
44
  }
60
45
  }
46
+ catch {
47
+ issues.push('package.json is not valid JSON.');
48
+ }
61
49
  }
62
50
  if (issues.length > 0) {
63
51
  throw new error_1.AppError('DEPLOY_PROJECT_CHECK_FAILED', `Project check failed:\n${issues.map((i) => ` - ${i}`).join('\n')}`);
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.designLocalPublishPipeline = exports.localBuildLocalPublishPipeline = void 0;
3
+ exports.localBuildLocalPublishPipeline = void 0;
4
4
  var local_1 = require("./local");
5
5
  Object.defineProperty(exports, "localBuildLocalPublishPipeline", { enumerable: true, get: function () { return local_1.localBuildLocalPublishPipeline; } });
6
- var design_local_1 = require("./design-local");
7
- Object.defineProperty(exports, "designLocalPublishPipeline", { enumerable: true, get: function () { return design_local_1.designLocalPublishPipeline; } });