@lark-apaas/miaoda-cli 0.1.4-alpha.8b6506a → 0.1.4-alpha.a655ae4

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.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  // plugin_instances batch_save 接口的请求 / 响应类型。
3
3
  //
4
- // modern deploy 其它接口走的 lark.apaas.devops PSM 不同,
5
- // 本接口走 lark.apaas.studio_server,响应信封形态也不一样(BaseResp 而非 status_code)。
4
+ // 后端已统一到 InnerEnvelope(`{data, status_code, message}`),与 modern deploy
5
+ // 其它接口一致;旧的 BaseResp 形态已下线,类型也不再保留。
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,30 +1,22 @@
1
1
  "use strict";
2
2
  // studio_server 的 plugin_instances 批量保存接口。
3
- // 与 modern deploy 其余接口(走 devops PSM、InnerEnvelope)信封不同,
4
- // 这里走 studio_server PSM、BaseResp 信封,故自行解析。
3
+ //
4
+ // 后端已统一到 InnerEnvelope(`{data, status_code, message}`)信封;不再手撸
5
+ // 旧 BaseResp 解析,直接复用 utils/http.ts 的 postInnerApi,verbose 下也能拿到
6
+ // `→ POST` / `body:` / `resp:` 的完整日志。
5
7
  Object.defineProperty(exports, "__esModule", { value: true });
6
8
  exports.batchSavePluginInstances = batchSavePluginInstances;
7
9
  const http_1 = require("../../utils/http");
8
- const error_1 = require("../../utils/error");
9
10
  const URL_PATH = '/api/v1/studio/innerapi/plugin_instances/batch_save';
10
11
  /**
11
12
  * POST /api/v1/studio/innerapi/plugin_instances/batch_save
12
13
  *
13
14
  * 把发布版本的 capability 集合注册到 studio_server。
14
- * 失败时抛 AppError("DEPLOY_PLUGIN_BATCH_SAVE_FAILED"),带 BaseResp 错误信息。
15
+ * 失败时抛 AppError("DEPLOY_PLUGIN_BATCH_SAVE_FAILED"),错误信息来自 envelope.message。
15
16
  */
16
17
  async function batchSavePluginInstances(req) {
17
- const response = await (0, http_1.getHttpClient)().post(URL_PATH, req);
18
- if (!response.ok) {
19
- throw new error_1.HttpError(response.status, URL_PATH, `Failed to save plugin instances: ${String(response.status)} ${response.statusText}`);
20
- }
21
- const body = (await response.json());
22
- const baseResp = body.BaseResp;
23
- if (baseResp?.StatusCode !== 0) {
24
- const msg = baseResp?.StatusMessage ?? baseResp?.KStatusMessage ?? 'unknown error';
25
- const code = baseResp?.KStatusCode !== undefined && baseResp.KStatusCode !== ''
26
- ? baseResp.KStatusCode
27
- : String(baseResp?.StatusCode ?? 'unknown');
28
- throw new error_1.AppError('DEPLOY_PLUGIN_BATCH_SAVE_FAILED', `Failed to save plugin instances: status_code=${code} message=${msg}`);
29
- }
18
+ await (0, http_1.postInnerApi)(URL_PATH, req, {
19
+ errPrefix: 'Failed to save plugin instances',
20
+ defaultErrCode: 'DEPLOY_PLUGIN_BATCH_SAVE_FAILED',
21
+ });
30
22
  }
@@ -10,7 +10,7 @@ const node_path_1 = __importDefault(require("node:path"));
10
10
  const npm_pack_1 = require("../../../utils/npm-pack");
11
11
  const error_1 = require("../../../utils/error");
12
12
  const logger_1 = require("../../../utils/logger");
13
- /** 短名 → 包名映射。新增 stack 时改这里。 */
13
+ /** 短名 → 包名映射。新增 stack 时改这里。archType 由 template 包自报,CLI 不维护。 */
14
14
  exports.TEMPLATE_PACKAGE_BY_STACK = {
15
15
  'vite-react': '@lark-apaas/coding-template-vite-react',
16
16
  html: '@lark-apaas/coding-template-html',
@@ -37,12 +37,13 @@ function renderTemplate(opts) {
37
37
  throw new error_1.AppError('TEMPLATE_INVALID', `包 ${packageName}@${fetched.version} 缺少 template/ 目录`);
38
38
  }
39
39
  const pkgJsonPath = node_path_1.default.join(fetched.extractDir, 'package.json');
40
- let archType = '';
40
+ let archType;
41
41
  if (node_fs_1.default.existsSync(pkgJsonPath)) {
42
42
  const pkgJson = JSON.parse(node_fs_1.default.readFileSync(pkgJsonPath, 'utf-8'));
43
- archType = pkgJson.miaodaTemplate?.archType ?? '';
43
+ archType = pkgJson.miaodaTemplate?.archType;
44
44
  }
45
- if (!archType) {
45
+ // 用显式 null/undefined/'' 判,避免把合法值 0 / false 当成"缺失"误抛
46
+ if (archType === undefined || archType === null || archType === '') {
46
47
  throw new error_1.AppError('TEMPLATE_INVALID', `包 ${packageName}@${fetched.version} 缺少 package.json.miaodaTemplate.archType`);
47
48
  }
48
49
  (0, logger_1.log)('init', `Rendering template to ${opts.targetDir}...`);
@@ -1,29 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.resolveTemplateKey = resolveTemplateKey;
4
- const error_1 = require("../../../utils/error");
5
4
  /**
6
5
  * 本地 stack 短名 → 后端发布模板 key 的映射。
7
6
  *
8
- * .spark/meta.json.stack 存的是脚手架模板短名(vite-react / vue-react / html ...),
7
+ * .spark/meta.json.stack 存的是脚手架模板短名(vite-react / html ...),
9
8
  * 而服务端 preRelease 接受的 templateKey 是"部署类别"维度,由后端 tcc 注册。
10
- * 同一类别的多个脚手架共享一个部署 key(典型:所有纯前端 stack client_local_deploy)。
11
- *
12
- * 加新 stack:在表里加一行;新增类别同步跟后端 tcc 配置对齐。
9
+ * 当前所有支持的 stack 都属于纯前端类别,默认映射到 client_local_deploy
10
+ * 未来出现需要走别的 templateKey 的 stack,再在表里加一行覆盖默认。
13
11
  */
12
+ const DEFAULT_TEMPLATE_KEY = 'client_local_deploy';
14
13
  const TEMPLATE_KEY_MAP = {
15
- 'vite-react': 'client_local_deploy',
16
- 'vue-react': 'client_local_deploy',
14
+ 'vite-react': DEFAULT_TEMPLATE_KEY,
15
+ html: DEFAULT_TEMPLATE_KEY,
17
16
  };
18
17
  /**
19
- * 把本地 stack 短名映射到后端 templateKey。未配置的 stack AppError,
20
- * 避免拿原始短名直接打过去导致后端报"empty"或"出错了"等含糊错误。
18
+ * 把本地 stack 短名映射到后端 templateKey;未配置的 stack 走默认 client_local_deploy。
21
19
  */
22
20
  function resolveTemplateKey(template) {
23
- const key = TEMPLATE_KEY_MAP[template];
24
- if (key === undefined) {
25
- throw new error_1.AppError('DEPLOY_TEMPLATE_KEY_UNMAPPED', `Template "${template}" has no mapping to backend templateKey. ` +
26
- `Known: ${Object.keys(TEMPLATE_KEY_MAP).join(', ')}`);
27
- }
28
- return key;
21
+ return TEMPLATE_KEY_MAP[template] ?? DEFAULT_TEMPLATE_KEY;
29
22
  }
@@ -7,7 +7,7 @@ exports.readSkillsStatus = readSkillsStatus;
7
7
  const node_fs_1 = __importDefault(require("node:fs"));
8
8
  const node_path_1 = __importDefault(require("node:path"));
9
9
  /**
10
- * 扫描 <targetDir>/.agent/steering/<stack>/,给出"当前装了什么"的快照。
10
+ * 扫描 <targetDir>/.agent/skills/steering/<stack>/,给出"当前装了什么"的快照。
11
11
  * 不联网、不解析任何 SKILL.md 内容;只列目录名 + tech.md 是否在。
12
12
  *
13
13
  * stack 缺省(meta.json 缺 stack)时直接返回 present=false,
@@ -17,7 +17,7 @@ function readSkillsStatus(opts) {
17
17
  if (opts.stack === undefined || opts.stack === '') {
18
18
  return { present: false, skills: [], techSynced: false };
19
19
  }
20
- const root = node_path_1.default.join(opts.targetDir, '.agent', 'steering', opts.stack);
20
+ const root = node_path_1.default.join(opts.targetDir, '.agent', 'skills', 'steering', opts.stack);
21
21
  if (!node_fs_1.default.existsSync(root)) {
22
22
  return { present: false, skills: [], techSynced: false };
23
23
  }
@@ -27,9 +27,10 @@ function syncCodingSteering(opts) {
27
27
  const steeringRoot = node_path_1.default.join(fetched.extractDir, 'steering');
28
28
  const stackDir = node_path_1.default.join(steeringRoot, opts.stack);
29
29
  const commonSkillsDir = node_path_1.default.join(steeringRoot, '_common', 'skills');
30
- // steering 落到 .agent/steering/<stack>/,让同一 .agent/ 下可以并存多 stack(虽然
31
- // 当前一个项目只有一个 stack,但保持命名空间清晰,避免与其它 steering 生产方撞名)。
32
- const dstRoot = node_path_1.default.join(opts.targetDir, '.agent', 'steering', opts.stack);
30
+ // steering 落到 .agent/skills/steering/<stack>/。.agent/skills/ agent skills 的
31
+ // 公共容器,steering 是其中一个 producer,<stack> 再做命名空间隔离。内部仍保留
32
+ // 包内 steering/<stack>/skills/ 的结构,便于按"包内子目录 本地子目录"一一对应排查。
33
+ const dstRoot = node_path_1.default.join(opts.targetDir, '.agent', 'skills', 'steering', opts.stack);
33
34
  const dstSkillsDir = node_path_1.default.join(dstRoot, 'skills');
34
35
  node_fs_1.default.mkdirSync(dstSkillsDir, { recursive: true });
35
36
  let techSynced = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/miaoda-cli",
3
- "version": "0.1.4-alpha.8b6506a",
3
+ "version": "0.1.4-alpha.a655ae4",
4
4
  "description": "Miaoda 平台命令行工具,面向 Agent 调用",
5
5
  "type": "commonjs",
6
6
  "bin": {