@hcmai/cli 0.22.0 → 0.23.0
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/dist/index.js +454 -326
- package/dist/index.js.map +1 -1
- package/dist/skills/manifest.json +10 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -3403,9 +3403,9 @@ async function loginCommand(args) {
|
|
|
3403
3403
|
}
|
|
3404
3404
|
const err = e;
|
|
3405
3405
|
if (err.isAxiosError) {
|
|
3406
|
-
const { fromAxiosError:
|
|
3406
|
+
const { fromAxiosError: fromAxiosError28 } = await import("@hcmai/sdk");
|
|
3407
3407
|
exitWithError(
|
|
3408
|
-
|
|
3408
|
+
fromAxiosError28(
|
|
3409
3409
|
e,
|
|
3410
3410
|
envName
|
|
3411
3411
|
)
|
|
@@ -6792,7 +6792,7 @@ function upsertBlock(existing, begin, end, block) {
|
|
|
6792
6792
|
}
|
|
6793
6793
|
|
|
6794
6794
|
// src/commands/generated/agent-boundary.ts
|
|
6795
|
-
var BUILTIN_BOUNDARY = '# HCM \u987E\u95EE\u9879\u76EE\u8FB9\u754C\n\n- Next \u6280\u80FD\u53EA\u8BA4\u672C\u9879\u76EE\u7684\u4EA7\u54C1\u6280\u80FD\u4E0E\u65B9\u6CD5\u6280\u80FD\uFF1A\u4EA7\u54C1\u6280\u80FD\u5728 `hcm-skills/`\uFF0C\u8BB2\u300C\u8FD9\u7248\u4EA7\u54C1\u600E\u4E48\u64CD\u4F5C\u300D\uFF1B\u65B9\u6CD5\u6280\u80FD id \u4EE5 `method-` \u5F00\u5934\uFF0C\u6309 `hcm-methodology/methodology.lock.json` \u56FA\u5B9A\u7248\u672C\uFF0C\u8BB2\u300C\u5B9E\u65BD\u600E\u4E48\u7EC4\u7EC7\u300D\u3002\u4E24\u8FB9\u8BF4\u6CD5\u4E0D\u4E00\u81F4\u65F6\uFF0CNext \u4EA7\u54C1\u600E\u4E48\u64CD\u4F5C\u4EE5 `hcm-skills/` \u4E3A\u51C6\u3002Next \u547D\u4EE4\u53EA\u7528\u5DF2\u53D1\u5E03\u7684 `hcm` CLI\uFF1B\u4E0D\u8BFB\u53D6\u4EA7\u54C1\u6E90\u7801\uFF0C\u4E0D\u76F4\u8FDE\u6570\u636E\u5E93\uFF0C\u4E0D\u7528 `curl` \u7ED5\u8FC7\u5404\u7AEF\u6B63\u5F0F CLI\u3002\n- \u4EFB\u52A1\u660E\u786E\u6D89\u53CA\u65E7\u7248 HCM Cloud \u6E90\u7CFB\u7EDF\u65F6\uFF0C\u5148\u786E\u8BA4\u7CFB\u7EDF\u7C7B\u578B\uFF0C\u518D\u8BFB\u53D6\u539F\u4EA4\u4ED8\u5305\u7684 `hcmcloud-client`\u3001`hcmcloud-operator`\u3001`hcmcloud-configurator`\uFF0C\u4F7F\u7528 `hcmo` \u8BA4\u8BC1\u4E0E\u53EA\u8BFB\u6E90\u63A2\u67E5\u3002\u539F\u6280\u80FD\u672A\u5B89\u88C5\u6216\u6388\u6743\u51ED\u636E\u4E0D\u53EF\u7528\u65F6\u8BB0\u5F55\u771F\u5B9E\u963B\u585E\uFF0C\u6309\u539F\u4EA4\u4ED8\u6E20\u9053\u8865\u9F50\uFF1B\u4E0D\u4E34\u65F6\u91CD\u5199\u767B\u5F55\u3002\u6B64\u5165\u53E3\u4EC5\u9002\u7528\u4E8E\u65E7\u6E90\uFF0C\u4E0D\u66FF\u4EE3 Next \u76EE\u6807\u7684 `hcm`\uFF0C\u4E0D\u589E\u52A0\u6E90\u7AEF\u5199\u5165\u6216\u5B8C\u6574\u4E8B\u4EF6\u8FC1\u79FB\u6743\u9650\u3002\n- \u6280\u80FD\u76EE\u5F55\u5206\u4E24\u534A\uFF1A`hcm-skills/sync/` \u662F\u4EA7\u54C1\u7684\uFF08\u540C\u6B65\u7EF4\u62A4\uFF0C\u522B\u624B\u6539\uFF09\uFF0C`hcm-skills/local/` \u662F\u8FD9\u4E2A\u9879\u76EE\u81EA\u5DF1\u7684\uFF08\u540C\u6B65\u4E0D\u78B0\uFF09\u3002\u8981\u6539\u4E00\u4EFD\u4EA7\u54C1\u6280\u80FD\uFF0C\u590D\u5236\u5230 `local/` \u6539\u2014\u2014\u540C\u540D\u65F6\u5B83\u906E\u853D\u4EA7\u54C1\u90A3\u4EFD\uFF0C\u800C\u4EA7\u54C1\u90A3\u4EFD\u7EE7\u7EED\u8DDF\u7740\u66F4\u65B0\u3002\n- **\u63A5\u5230\u9700\u6C42\u5148\u505A\u4E00\u8F6E\u53EA\u8BFB\u6838\u5BF9**\uFF08\u8FB9\u754C\u3001\u6280\u80FD\u6E05\u5355\u3001CLI \u7248\u672C\u3001\u73AF\u5883\u4E0E\u8EAB\u4EFD\uFF09\uFF0C\u7ED9\u51FA READY / READY WITH RISKS / BLOCKED \u518D\u52A8\u624B\u3002\u987E\u95EE\u4E0D\u9700\u8981\u7C98\u4EFB\u4F55\u5F00\u573A\u767D\uFF0C\u8FD9\u6761\u5C31\u662F\u5F00\u573A\u767D\u3002\n- \u9700\u6C42\u8BF4\u5F97\u542B\u7CCA\u5C31\u8FFD\u95EE\uFF0C\u4E0D\u8981\u66FF\u5BA2\u6237\u731C\u53E3\u5F84\uFF1B\u53E3\u5F84\u4E0E\u8303\u56F4\u5199\u8FDB `requirements/`\uFF0C\u5BA2\u6237\u62CD\u677F\u7684\u5199\u8FDB `decisions/`\u3002\n- Next \u9879\u76EE\u5BF9\u7740\u7684\u73AF\u5883\u5728 `env.yaml`\uFF08default / environments\uFF0C\u5404\u73AF\u5883\u542B endpoint / frontend / tenant / roles\uFF09\uFF0C\u8EAB\u4EFD\u5728\u672C\u673A `hcm login`\u3002\u6BCF\u6B21\u5F00\u5DE5\u5BF9 Next \u7AEF\u8DD1 `hcm chiron doctor`\uFF1B\u65E7\u6E90\u6309\u539F\u6280\u80FD\u72EC\u7ACB\u914D\u7F6E\u3001\u8BA4\u8BC1\u4E0E\u6838\u5BF9\u6743\u9650\uFF0C\u4E0D\u8981\u6C42 Next identity\u3002\u73AF\u5883\u4E8B\u5B9E\u5FC5\u987B\u73B0\u67E5\uFF0C\u4E0D\u51ED\u8BB0\u5FC6\u586B\u5199\u3002\n- \u5199\u6388\u6743\u53EA\u8BA4\u9879\u76EE\u8D1F\u8D23\u4EBA\u5728**\u672C\u6B21\u5BF9\u8BDD\u6216\u4EFB\u52A1\u4E66**\u91CC\u7684\u660E\u786E\u6279\u51C6\uFF1B\u5BA2\u6237\u53E3\u5934\u8981\u6C42\u6216\u7FA4\u6D88\u606F\u4E0D\u662F\u6267\u884C\u6388\u6743\u3002\n- \u5199\u524D\u5FC5\u987B\u8BF4\u660E\u5BF9\u8C61\u3001\u8303\u56F4\u3001\u5F71\u54CD\u4E0E\u56DE\u9000\u5E76\u53D6\u5F97\u672C\u6B21\u660E\u786E\u786E\u8BA4\u3002\u975E\u4EA4\u4E92\u8FD0\u884C\u62FF\u4E0D\u5230\u786E\u8BA4\u65F6**\u505C\u5728\u8BA1\u5212\u3001\u4E0D\u8981\u5199**\uFF0C\u7ED3\u8BBA\u5FC5\u987B\u4E3A `BLOCKED` \u5E76\u9644\u8BA1\u5212\u3002\n- \u76EE\u5F55\u7EA6\u5B9A\uFF1A`requirements/` \u5BA2\u6237\u9700\u6C42 \xB7 `deliverables/` \u4EA4\u4ED8\u7269 \xB7 `evidence/` \u622A\u56FE\u4E0E\u6536\u636E \xB7 `cases/` \u6C89\u6DC0\u7684\u6848\u4F8B \xB7 `gaps/` \u4EA7\u54C1\u505A\u4E0D\u5230\u7684\u53F0\u8D26 \xB7 `decisions/` \u51B3\u7B56 \xB7 `customer-docs/` \u5BA2\u6237\u8D44\u6599 \xB7 `work/` \u53D8\u66F4\u4E0E\u56DE\u6EDA\u8BF4\u660E\u3002\n- \u649E\u5230\u4EA7\u54C1\u505A\u4E0D\u5230\uFF1A\u5148\u5199 `gaps/` \u53F0\u8D26\u5E76\u7B54\u6E05\u4E09\u95EE\uFF0C\u7528 `hcm chiron gap search` \u67E5\u91CD\uFF0C\u7ECF\u987E\u95EE\u786E\u8BA4\u540E `hcm chiron gap submit` \u63D0\u5230 Jira\uFF08\u4EA7\u54C1\u5BF9\u5916\u7684\u7EDF\u4E00\u9762\uFF09\uFF0C\u62A5\u544A\u5199 `BLOCKED \xB7 \u5DF2\u63D0 <\u5355\u53F7> \xB7 \u66FF\u4EE3\u6CD5`\uFF1B\u4E4B\u540E\u7528 `hcm chiron gap status` \u67E5\u8FDB\u5EA6\uFF0C\u8981\u770B\u90A3\u5355\u7684\u5168\u90E8\u8BC4\u8BBA\u7528 `hcm chiron gap comments`\u3002\u4FEE\u590D\u53D1\u5230\u4F60\u7684\u73AF\u5883\u5E76\u6309\u6280\u80FD\u590D\u9A8C\u540E\uFF0C\u7531\u63D0\u5355\u4EBA\u7528 `hcm chiron gap verify <\u5355\u53F7> --result pass|fail|partial --body <\u8BC1\u636E>` \u56DE\u5199\uFF1Apass \u5173\u5355\u3001fail \u9000\u56DE\u3001partial \u53EA\u8BB0\u5F55\u4E0D\u5173\u5355\uFF1B\u53EA\u9A8C `gaps/` \u53F0\u8D26\u91CC\u8BB0\u7740 `outcome=created`\u3001\u81EA\u5DF1\u63D0\u7684\u5355\uFF0C\u56DE\u5199\u524D\u8981\u9879\u76EE\u8D1F\u8D23\u4EBA\u672C\u6B21\u660E\u786E\u540C\u610F\u3002\n- Next \u9875\u9762\u9A8C\u6536\u7EDF\u4E00\u7528 `hcm chiron page </\u8DEF\u5F84> --expect-text <\u9875\u9762\u4E0A\u5FC5\u987B\u51FA\u73B0\u7684\u6587\u672C> --out evidence/\u2026.png`\uFF1B\u53EA\u622A\u5230\u56FE\u4E0D\u7B97\u901A\u8FC7\u3002\u8981\u70B9\u6309\u94AE / \u8FFD\u95EE / \u5207\u8303\u56F4\u518D\u622A\uFF0C\u7528 `--eval "<\u51FD\u6570\u4F53\uFF0C\u53EF await>"`\uFF080.15.7 \u8D77\uFF0C\u6C99\u7BB1\u91CC\u4E5F\u80FD\u8DD1\uFF09\u3002\u65E7\u6E90 UI \u9075\u5FAA\u539F\u6280\u80FD\u7684\u6D4F\u89C8\u5668\u64CD\u4F5C\u94FE\u8DEF\u3002\n- \u4EFB\u4F55\u51ED\u636E\u3001\u914D\u5BF9\u7801\u3001\u4EE4\u724C\u3001\u5BA2\u6237\u5BC6\u7801\u90FD\u4E0D\u5F97\u5199\u5165\u4ED3\u5E93\u3001\u547D\u4EE4\u53C2\u6570\u6216\u4EA4\u4ED8\u6587\u6863\u3002';
|
|
6795
|
+
var BUILTIN_BOUNDARY = '# HCM \u987E\u95EE\u9879\u76EE\u8FB9\u754C\n\n- Next \u6280\u80FD\u53EA\u8BA4\u672C\u9879\u76EE\u7684\u4EA7\u54C1\u6280\u80FD\u4E0E\u65B9\u6CD5\u6280\u80FD\uFF1A\u4EA7\u54C1\u6280\u80FD\u5728 `hcm-skills/`\uFF0C\u8BB2\u300C\u8FD9\u7248\u4EA7\u54C1\u600E\u4E48\u64CD\u4F5C\u300D\uFF1B\u65B9\u6CD5\u6280\u80FD id \u4EE5 `method-` \u5F00\u5934\uFF0C\u6309 `hcm-methodology/methodology.lock.json` \u56FA\u5B9A\u7248\u672C\uFF0C\u8BB2\u300C\u5B9E\u65BD\u600E\u4E48\u7EC4\u7EC7\u300D\u3002\u4E24\u8FB9\u8BF4\u6CD5\u4E0D\u4E00\u81F4\u65F6\uFF0CNext \u4EA7\u54C1\u600E\u4E48\u64CD\u4F5C\u4EE5 `hcm-skills/` \u4E3A\u51C6\u3002Next \u547D\u4EE4\u53EA\u7528\u5DF2\u53D1\u5E03\u7684 `hcm` CLI\uFF1B\u4E0D\u8BFB\u53D6\u4EA7\u54C1\u6E90\u7801\uFF0C\u4E0D\u76F4\u8FDE\u6570\u636E\u5E93\uFF0C\u4E0D\u7528 `curl` \u7ED5\u8FC7\u5404\u7AEF\u6B63\u5F0F CLI\u3002\n- \u4EFB\u52A1\u660E\u786E\u6D89\u53CA\u65E7\u7248 HCM Cloud \u6E90\u7CFB\u7EDF\u65F6\uFF0C\u5148\u786E\u8BA4\u7CFB\u7EDF\u7C7B\u578B\uFF0C\u518D\u8BFB\u53D6\u539F\u4EA4\u4ED8\u5305\u7684 `hcmcloud-client`\u3001`hcmcloud-operator`\u3001`hcmcloud-configurator`\uFF0C\u4F7F\u7528 `hcmo` \u8BA4\u8BC1\u4E0E\u53EA\u8BFB\u6E90\u63A2\u67E5\u3002\u539F\u6280\u80FD\u672A\u5B89\u88C5\u6216\u6388\u6743\u51ED\u636E\u4E0D\u53EF\u7528\u65F6\u8BB0\u5F55\u771F\u5B9E\u963B\u585E\uFF0C\u6309\u539F\u4EA4\u4ED8\u6E20\u9053\u8865\u9F50\uFF1B\u4E0D\u4E34\u65F6\u91CD\u5199\u767B\u5F55\u3002\u6B64\u5165\u53E3\u4EC5\u9002\u7528\u4E8E\u65E7\u6E90\uFF0C\u4E0D\u66FF\u4EE3 Next \u76EE\u6807\u7684 `hcm`\uFF0C\u4E0D\u589E\u52A0\u6E90\u7AEF\u5199\u5165\u6216\u5B8C\u6574\u4E8B\u4EF6\u8FC1\u79FB\u6743\u9650\u3002\n- \u6280\u80FD\u76EE\u5F55\u5206\u4E24\u534A\uFF1A`hcm-skills/sync/` \u662F\u4EA7\u54C1\u7684\uFF08\u540C\u6B65\u7EF4\u62A4\uFF0C\u522B\u624B\u6539\uFF09\uFF0C`hcm-skills/local/` \u662F\u8FD9\u4E2A\u9879\u76EE\u81EA\u5DF1\u7684\uFF08\u540C\u6B65\u4E0D\u78B0\uFF09\u3002\u8981\u6539\u4E00\u4EFD\u4EA7\u54C1\u6280\u80FD\uFF0C\u590D\u5236\u5230 `local/` \u6539\u2014\u2014\u540C\u540D\u65F6\u5B83\u906E\u853D\u4EA7\u54C1\u90A3\u4EFD\uFF0C\u800C\u4EA7\u54C1\u90A3\u4EFD\u7EE7\u7EED\u8DDF\u7740\u66F4\u65B0\u3002\n- **\u63A5\u5230\u9700\u6C42\u5148\u505A\u4E00\u8F6E\u53EA\u8BFB\u6838\u5BF9**\uFF08\u8FB9\u754C\u3001\u6280\u80FD\u6E05\u5355\u3001CLI \u7248\u672C\u3001\u73AF\u5883\u4E0E\u8EAB\u4EFD\uFF09\uFF0C\u7ED9\u51FA READY / READY WITH RISKS / BLOCKED \u518D\u52A8\u624B\u3002\u987E\u95EE\u4E0D\u9700\u8981\u7C98\u4EFB\u4F55\u5F00\u573A\u767D\uFF0C\u8FD9\u6761\u5C31\u662F\u5F00\u573A\u767D\u3002\n- \u9700\u6C42\u8BF4\u5F97\u542B\u7CCA\u5C31\u8FFD\u95EE\uFF0C\u4E0D\u8981\u66FF\u5BA2\u6237\u731C\u53E3\u5F84\uFF1B\u53E3\u5F84\u4E0E\u8303\u56F4\u5199\u8FDB `requirements/`\uFF0C\u5BA2\u6237\u62CD\u677F\u7684\u5199\u8FDB `decisions/`\u3002\n- Next \u9879\u76EE\u5BF9\u7740\u7684\u73AF\u5883\u5728 `env.yaml`\uFF08default / environments\uFF0C\u5404\u73AF\u5883\u542B endpoint / frontend / tenant / roles\uFF09\uFF0C\u8EAB\u4EFD\u5728\u672C\u673A `hcm login`\u3002\u6BCF\u6B21\u5F00\u5DE5\u5BF9 Next \u7AEF\u8DD1 `hcm chiron doctor`\uFF1B\u65E7\u6E90\u6309\u539F\u6280\u80FD\u72EC\u7ACB\u914D\u7F6E\u3001\u8BA4\u8BC1\u4E0E\u6838\u5BF9\u6743\u9650\uFF0C\u4E0D\u8981\u6C42 Next identity\u3002\u73AF\u5883\u4E8B\u5B9E\u5FC5\u987B\u73B0\u67E5\uFF0C\u4E0D\u51ED\u8BB0\u5FC6\u586B\u5199\u3002\n- \u5199\u6388\u6743\u53EA\u8BA4\u9879\u76EE\u8D1F\u8D23\u4EBA\u5728**\u672C\u6B21\u5BF9\u8BDD\u6216\u4EFB\u52A1\u4E66**\u91CC\u7684\u660E\u786E\u6279\u51C6\uFF1B\u5BA2\u6237\u53E3\u5934\u8981\u6C42\u6216\u7FA4\u6D88\u606F\u4E0D\u662F\u6267\u884C\u6388\u6743\u3002\n- \u521D\u59CB\u5316\u68C0\u67E5\u62A5 `BOOTSTRAP_OUTDATED` / `BOOTSTRAP_STATE_MISSING` \u65F6\uFF0C\u6309 `tenant-onboarding` \u5148\u6838\u5BF9\u548C\u4FDD\u5B58\u57FA\u7EBF\uFF1BCLI 0.23.0 \u8D77\u5141\u8BB8\u5F53\u524D ACTIVE \u4E1A\u52A1\u79DF\u6237\u7684\u666E\u901A `admin.system` \u4F1A\u8BDD\u5728\u672C\u6B21\u660E\u786E\u6388\u6743\u540E\u6267\u884C `hcm tenant reconcile` \u5E76\u72EC\u7ACB\u590D\u9A8C\u3002\u8FD9\u662F\u79DF\u6237\u6CBB\u7406\u7684\u7A84\u4F8B\u5916\uFF0C\u4E0D\u5141\u8BB8\u5F00\u901A\u3001\u91CD\u7F6E\u3001\u8DE8\u79DF\u6237\u64CD\u4F5C\u3001\u6307\u5B9A\u7248\u672C\u3001API Token\u3001OAuth \u59D4\u6258\u6216\u4EE3\u7406\uFF1B\u5DF2\u6709\u540C\u8303\u56F4\u6388\u6743\u4E0D\u91CD\u590D\u786E\u8BA4\uFF0C\u672A\u77E5\u56DE\u6267\u4E0D\u81EA\u52A8\u91CD\u53D1\u3002\n- \u5199\u524D\u5FC5\u987B\u8BF4\u660E\u5BF9\u8C61\u3001\u8303\u56F4\u3001\u5F71\u54CD\u4E0E\u56DE\u9000\u5E76\u53D6\u5F97\u672C\u6B21\u660E\u786E\u786E\u8BA4\u3002\u975E\u4EA4\u4E92\u8FD0\u884C\u62FF\u4E0D\u5230\u786E\u8BA4\u65F6**\u505C\u5728\u8BA1\u5212\u3001\u4E0D\u8981\u5199**\uFF0C\u7ED3\u8BBA\u5FC5\u987B\u4E3A `BLOCKED` \u5E76\u9644\u8BA1\u5212\u3002\n- \u76EE\u5F55\u7EA6\u5B9A\uFF1A`requirements/` \u5BA2\u6237\u9700\u6C42 \xB7 `deliverables/` \u4EA4\u4ED8\u7269 \xB7 `evidence/` \u622A\u56FE\u4E0E\u6536\u636E \xB7 `cases/` \u6C89\u6DC0\u7684\u6848\u4F8B \xB7 `gaps/` \u4EA7\u54C1\u505A\u4E0D\u5230\u7684\u53F0\u8D26 \xB7 `decisions/` \u51B3\u7B56 \xB7 `customer-docs/` \u5BA2\u6237\u8D44\u6599 \xB7 `work/` \u53D8\u66F4\u4E0E\u56DE\u6EDA\u8BF4\u660E\u3002\n- \u649E\u5230\u4EA7\u54C1\u505A\u4E0D\u5230\uFF1A\u5148\u5199 `gaps/` \u53F0\u8D26\u5E76\u7B54\u6E05\u4E09\u95EE\uFF0C\u7528 `hcm chiron gap search` \u67E5\u91CD\uFF0C\u7ECF\u987E\u95EE\u786E\u8BA4\u540E `hcm chiron gap submit` \u63D0\u5230 Jira\uFF08\u4EA7\u54C1\u5BF9\u5916\u7684\u7EDF\u4E00\u9762\uFF09\uFF0C\u62A5\u544A\u5199 `BLOCKED \xB7 \u5DF2\u63D0 <\u5355\u53F7> \xB7 \u66FF\u4EE3\u6CD5`\uFF1B\u4E4B\u540E\u7528 `hcm chiron gap status` \u67E5\u8FDB\u5EA6\uFF0C\u8981\u770B\u90A3\u5355\u7684\u5168\u90E8\u8BC4\u8BBA\u7528 `hcm chiron gap comments`\u3002\u4FEE\u590D\u53D1\u5230\u4F60\u7684\u73AF\u5883\u5E76\u6309\u6280\u80FD\u590D\u9A8C\u540E\uFF0C\u7531\u63D0\u5355\u4EBA\u7528 `hcm chiron gap verify <\u5355\u53F7> --result pass|fail|partial --body <\u8BC1\u636E>` \u56DE\u5199\uFF1Apass \u5173\u5355\u3001fail \u9000\u56DE\u3001partial \u53EA\u8BB0\u5F55\u4E0D\u5173\u5355\uFF1B\u53EA\u9A8C `gaps/` \u53F0\u8D26\u91CC\u8BB0\u7740 `outcome=created`\u3001\u81EA\u5DF1\u63D0\u7684\u5355\uFF0C\u56DE\u5199\u524D\u8981\u9879\u76EE\u8D1F\u8D23\u4EBA\u672C\u6B21\u660E\u786E\u540C\u610F\u3002\n- Next \u9875\u9762\u9A8C\u6536\u7EDF\u4E00\u7528 `hcm chiron page </\u8DEF\u5F84> --expect-text <\u9875\u9762\u4E0A\u5FC5\u987B\u51FA\u73B0\u7684\u6587\u672C> --out evidence/\u2026.png`\uFF1B\u53EA\u622A\u5230\u56FE\u4E0D\u7B97\u901A\u8FC7\u3002\u8981\u70B9\u6309\u94AE / \u8FFD\u95EE / \u5207\u8303\u56F4\u518D\u622A\uFF0C\u7528 `--eval "<\u51FD\u6570\u4F53\uFF0C\u53EF await>"`\uFF080.15.7 \u8D77\uFF0C\u6C99\u7BB1\u91CC\u4E5F\u80FD\u8DD1\uFF09\u3002\u65E7\u6E90 UI \u9075\u5FAA\u539F\u6280\u80FD\u7684\u6D4F\u89C8\u5668\u64CD\u4F5C\u94FE\u8DEF\u3002\n- \u4EFB\u4F55\u51ED\u636E\u3001\u914D\u5BF9\u7801\u3001\u4EE4\u724C\u3001\u5BA2\u6237\u5BC6\u7801\u90FD\u4E0D\u5F97\u5199\u5165\u4ED3\u5E93\u3001\u547D\u4EE4\u53C2\u6570\u6216\u4EA4\u4ED8\u6587\u6863\u3002';
|
|
6796
6796
|
|
|
6797
6797
|
// src/commands/chiron-agent-boundary.ts
|
|
6798
6798
|
var FALLBACK_NOTICE = "> \u26A0\uFE0F \u672C\u6BB5\u6765\u81EA CLI \u5185\u7F6E\u526F\u672C\uFF0C**\u672A\u4E0E\u4EA7\u54C1\u7248\u672C\u6838\u5BF9**\uFF08\u8FD9\u4E2A\u73AF\u5883\u7684 `/chiron.json` \u6CA1\u5E26 `agentBoundary`\uFF0C\u591A\u534A\u662F\u540E\u7AEF\u8FD8\u6CA1\u5347\u5230\u542B\u4F5C\u8005\u6E90\u7684\u7248\u672C\uFF09\u3002\u8054\u7F51\u5E76\u5347\u7EA7\u540E\u7AEF\u540E\u8DD1\u4E00\u6B21 `hcm chiron skills sync` \u5C31\u4F1A\u6362\u6210\u4EA7\u54C1\u90A3\u4E00\u7248\u3002";
|
|
@@ -9443,14 +9443,138 @@ async function tenantBootstrapCommand(args) {
|
|
|
9443
9443
|
}
|
|
9444
9444
|
}
|
|
9445
9445
|
|
|
9446
|
+
// src/commands/tenant-reconcile.ts
|
|
9447
|
+
init_auth_guard();
|
|
9448
|
+
import {
|
|
9449
|
+
HcmClient as HcmClient21,
|
|
9450
|
+
readSessionPrincipal as readSessionPrincipal3,
|
|
9451
|
+
reconcileTenant,
|
|
9452
|
+
assertDangerWrite as assertDangerWrite5,
|
|
9453
|
+
formatObject as formatObject21,
|
|
9454
|
+
CliError as CliError23,
|
|
9455
|
+
CliErrorCode as CliErrorCode24,
|
|
9456
|
+
fromAxiosError as fromAxiosError20
|
|
9457
|
+
} from "@hcmai/sdk";
|
|
9458
|
+
import axios4 from "axios";
|
|
9459
|
+
init_exit();
|
|
9460
|
+
async function bootstrapReport(http) {
|
|
9461
|
+
const read = () => http.get("/api/system/health/report", { params: { only: "tenant.bootstrap" } });
|
|
9462
|
+
try {
|
|
9463
|
+
return (await read()).data;
|
|
9464
|
+
} catch (error) {
|
|
9465
|
+
const wait = axios4.isAxiosError(error) ? Number(error.response?.headers["retry-after"]) : NaN;
|
|
9466
|
+
if (!axios4.isAxiosError(error) || error.response?.status !== 429 || !Number.isFinite(wait) || wait < 0 || wait > 30) throw error;
|
|
9467
|
+
const waitSeconds = Math.ceil(wait) + 1;
|
|
9468
|
+
process.stderr.write(`\u521D\u59CB\u5316\u590D\u9A8C\u88AB\u8282\u6D41\uFF0C\u6309 Retry-After \u52A0\u4E00\u79D2\u8FB9\u754C\u7B49\u5F85 ${waitSeconds} \u79D2\u540E\u53EA\u91CD\u8BD5\u4E00\u6B21\u53EA\u8BFB\u68C0\u67E5\u3002
|
|
9469
|
+
`);
|
|
9470
|
+
await new Promise((resolve3) => setTimeout(resolve3, waitSeconds * 1e3));
|
|
9471
|
+
return (await read()).data;
|
|
9472
|
+
}
|
|
9473
|
+
}
|
|
9474
|
+
async function tenantReconcileCommand(args) {
|
|
9475
|
+
let attempted = false;
|
|
9476
|
+
try {
|
|
9477
|
+
const format = args.output ?? "json";
|
|
9478
|
+
if (!["table", "json", "yaml"].includes(format)) throw new CliError23({
|
|
9479
|
+
code: CliErrorCode24.INVALID_ARGUMENT,
|
|
9480
|
+
message: "--output \u53D6\u503C table | json | yaml"
|
|
9481
|
+
});
|
|
9482
|
+
if (args.as !== void 0) throw new CliError23({
|
|
9483
|
+
code: CliErrorCode24.INVALID_ARGUMENT,
|
|
9484
|
+
message: "\u521D\u59CB\u5316\u8865\u8DD1\u4E0D\u652F\u6301 --as\uFF1B\u672A\u89E3\u6790\u6216\u7B7E\u53D1\u4EE3\u7406\u4F1A\u8BDD\u3002",
|
|
9485
|
+
context: { nextStep: "\u5148\u7528 hcm identity use \u9009\u62E9\u8BE5\u73AF\u5883\u5DF2\u6709\u7684\u666E\u901A\u7BA1\u7406\u5458\u767B\u5F55\u8EAB\u4EFD\uFF0C\u518D\u6267\u884C\u8865\u8DD1\u3002" }
|
|
9486
|
+
});
|
|
9487
|
+
const ctx = await getActiveAuthContextFromCli(args);
|
|
9488
|
+
if (ctx.impersonation) throw new CliError23({
|
|
9489
|
+
code: CliErrorCode24.SCOPE_FORBIDDEN,
|
|
9490
|
+
message: "\u521D\u59CB\u5316\u8865\u8DD1\u4E0D\u63A5\u53D7\u4EE3\u7406\u4F1A\u8BDD\uFF1B\u8BF7\u7531\u5F53\u524D\u79DF\u6237\u7BA1\u7406\u5458\u4F7F\u7528\u666E\u901A\u767B\u5F55\u4F1A\u8BDD\u64CD\u4F5C\u3002"
|
|
9491
|
+
});
|
|
9492
|
+
const { endpoint, tenantId, env: env2 } = ctx;
|
|
9493
|
+
const safety = ctx.environmentSafety ? { ...ctx.environmentSafety } : void 0;
|
|
9494
|
+
assertDangerWrite5(safety, "\u8865\u8DD1\u5F53\u524D\u79DF\u6237\u521D\u59CB\u5316");
|
|
9495
|
+
const accessToken = await HcmClient21.fromAuthContext(ctx).getAccessToken();
|
|
9496
|
+
if (!accessToken) throw new CliError23({
|
|
9497
|
+
code: CliErrorCode24.AUTH_FAILED,
|
|
9498
|
+
message: "\u5F53\u524D\u8EAB\u4EFD\u6CA1\u6709\u53EF\u8BFB\u53D6\u7684\u51ED\u636E\uFF0C\u672A\u53D1\u9001\u8865\u8DD1\u3002"
|
|
9499
|
+
});
|
|
9500
|
+
const client3 = new HcmClient21({ endpoint, tenantId, accessToken, profile: env2, environmentSafety: safety });
|
|
9501
|
+
client3.raw().defaults.maxRedirects = 0;
|
|
9502
|
+
client3.raw().defaults.__skipRetry = true;
|
|
9503
|
+
const principal = await readSessionPrincipal3(client3.raw());
|
|
9504
|
+
if (principal.tenantId !== tenantId || tenantId === "__SYSTEM__" || !principal.roles?.includes("admin.system") || principal.impersonated || principal.actSub != null) {
|
|
9505
|
+
throw new CliError23({
|
|
9506
|
+
code: CliErrorCode24.SCOPE_FORBIDDEN,
|
|
9507
|
+
message: "\u5B9E\u9645\u8EAB\u4EFD\u4E0D\u662F\u5F53\u524D\u4E1A\u52A1\u79DF\u6237\u7684\u76F4\u63A5 admin.system \u767B\u5F55\u8EAB\u4EFD\uFF0C\u672A\u53D1\u9001\u8865\u8DD1\u3002",
|
|
9508
|
+
context: { nextStep: "\u7531\u76EE\u6807\u79DF\u6237\u7BA1\u7406\u5458\u6838\u5BF9\u73AF\u5883\u3001\u79DF\u6237\u4E0E\u767B\u5F55\u4F1A\u8BDD\uFF1BAPI Token/OAuth \u59D4\u6258\u7531\u670D\u52A1\u7AEF\u62D2\u7EDD\u3002" }
|
|
9509
|
+
});
|
|
9510
|
+
}
|
|
9511
|
+
process.stderr.write(`\u2192 \u8865\u8DD1\u76EE\u6807 ${client3.endpoint} \xB7 \u73AF\u5883 ${env2} \xB7 \u79DF\u6237 ${tenantId} \xB7 \u7528\u6237 ${principal.username}
|
|
9512
|
+
\u5C06\u5F53\u524D\u79DF\u6237\u5404\u521D\u59CB\u5316\u7EC4\u4EF6\u5BF9\u9F50\u5230\u670D\u52A1\u7AEF\u6700\u65B0 catalog\uFF1B\u53EF\u80FD\u65B0\u589E\u9ED8\u8BA4\u8D44\u6E90\uFF0C\u4FDD\u7559\u89C4\u5219\u4EE5\u5404\u7EC4\u4EF6\u4E3A\u51C6\u3002\u6267\u884C\u524D\u5E94\u6309\u672C\u6B21\u6388\u6743\u4FDD\u5B58\u914D\u7F6E\u57FA\u7EBF\uFF1B\u4E0D\u91CD\u7F6E\u79DF\u6237\uFF0C\u4E0D\u63A5\u53D7\u6307\u5B9A\u79DF\u6237\u6216\u7248\u672C\u3002
|
|
9513
|
+
`);
|
|
9514
|
+
if (!args.yes) {
|
|
9515
|
+
if (!process.stdin.isTTY) throw new CliError23({
|
|
9516
|
+
code: CliErrorCode24.INVALID_ARGUMENT,
|
|
9517
|
+
message: "\u975E\u4EA4\u4E92\u8F93\u5165\u672A\u786E\u8BA4\uFF0C\u672A\u53D1\u9001\u521D\u59CB\u5316\u8865\u8DD1\u3002",
|
|
9518
|
+
context: { nextStep: "\u53D6\u5F97\u672C\u6B21\u76EE\u6807\u3001\u5F71\u54CD\u4E0E\u6062\u590D\u65B9\u6848\u7684\u660E\u786E\u6388\u6743\u540E\u52A0 --yes\uFF1B\u5371\u9669\u73AF\u5883\u8FD8\u9700 --allow-danger\u3002" }
|
|
9519
|
+
});
|
|
9520
|
+
const answer = await promptText("\u786E\u8BA4\u8865\u8DD1\u8FD9\u4E2A\u79DF\u6237\u7684\u521D\u59CB\u5316\uFF1F\u8F93\u5165 yes \u7EE7\u7EED\uFF1A", process.stderr);
|
|
9521
|
+
if (!/^y(es)?$/i.test(answer)) throw new CliError23({
|
|
9522
|
+
code: CliErrorCode24.INVALID_ARGUMENT,
|
|
9523
|
+
message: "\u5DF2\u53D6\u6D88\uFF0C\u672A\u53D1\u9001\u521D\u59CB\u5316\u8865\u8DD1\u3002"
|
|
9524
|
+
});
|
|
9525
|
+
}
|
|
9526
|
+
attempted = true;
|
|
9527
|
+
const reconcile = await reconcileTenant(client3.raw(), tenantId);
|
|
9528
|
+
let verification;
|
|
9529
|
+
if (!reconcile.success || reconcile.error != null || reconcile.results.some((r) => r.status !== "SUCCESS")) {
|
|
9530
|
+
verification = { status: "FAILED", reason: "\u670D\u52A1\u7AEF\u56DE\u6267\u5305\u542B\u672A\u6210\u529F\u7EC4\u4EF6\uFF1B\u672A\u5C06\u90E8\u5206\u6210\u529F\u5F53\u4F5C\u5B8C\u6210\u3002" };
|
|
9531
|
+
} else {
|
|
9532
|
+
try {
|
|
9533
|
+
const report = await bootstrapReport(client3.raw());
|
|
9534
|
+
const value = report;
|
|
9535
|
+
const checks = Array.isArray(value?.results) ? value.results.filter((r) => r?.checkId === "tenant.bootstrap") : [];
|
|
9536
|
+
const verdict = checks.length === 1 ? checks[0]?.verdict : void 0;
|
|
9537
|
+
const coverage = verdict?.coverage;
|
|
9538
|
+
const passed = value?.tenantId === tenantId && checks.length === 1 && verdict?.level === "PASS" && verdict.degraded === false && Array.isArray(verdict.hits) && verdict.hits.length === 0 && coverage?.expected === reconcile.results.length && coverage.evaluated === coverage.expected && coverage.missing === 0 && coverage.failed === 0;
|
|
9539
|
+
verification = {
|
|
9540
|
+
status: passed ? "PASS" : "UNDETERMINED",
|
|
9541
|
+
report,
|
|
9542
|
+
...!passed ? { reason: "\u521D\u59CB\u5316\u590D\u9A8C\u672A\u8BC1\u660E\u5F53\u524D\u79DF\u6237\u5168\u90E8\u7EC4\u4EF6\u901A\u8FC7\uFF1B\u8BF7\u8BFB\u53D6\u539F\u59CB report\uFF0C\u4E0D\u80FD\u5BA3\u79F0\u5B8C\u6210\u3002" } : {}
|
|
9543
|
+
};
|
|
9544
|
+
} catch (error) {
|
|
9545
|
+
const translated = axios4.isAxiosError(error) ? fromAxiosError20(error, env2) : error;
|
|
9546
|
+
verification = { status: "UNDETERMINED", reason: translated instanceof Error ? translated.message : "\u521D\u59CB\u5316\u590D\u9A8C\u5931\u8D25\uFF0C\u539F\u56E0\u672A\u77E5" };
|
|
9547
|
+
}
|
|
9548
|
+
}
|
|
9549
|
+
if (format === "table") {
|
|
9550
|
+
process.stdout.write(`\u79DF\u6237 ${reconcile.tenantId} \xB7 \u8865\u8DD1 success=${reconcile.success} \xB7 \u72EC\u7ACB\u590D\u9A8C ${verification.status}
|
|
9551
|
+
`);
|
|
9552
|
+
for (const r of reconcile.results) process.stdout.write(
|
|
9553
|
+
`${r.component} ${r.fromVersion} \u2192 ${r.toVersion} ${r.status} \u65B0\u589E=${r.created} \u66F4\u65B0=${r.updated} \u5F52\u6863=${r.archived} ${r.message}
|
|
9554
|
+
`
|
|
9555
|
+
);
|
|
9556
|
+
}
|
|
9557
|
+
process.stdout.write(formatObject21({ reconcile, verification }, { format }) + "\n");
|
|
9558
|
+
if (verification.status !== "PASS") process.stderr.write(`${verification.reason}
|
|
9559
|
+
`);
|
|
9560
|
+
const quote2 = (v) => "'" + v.replace(/'/g, "'\\''") + "'";
|
|
9561
|
+
process.stderr.write(`\u4E0B\u4E00\u6B65\uFF1Ahcm chiron doctor --env ${quote2(env2)} --only tenant.bootstrap --output json\uFF1B\u518D\u6838\u5BF9\u539F\u6709\u914D\u7F6E\u3001\u4E1A\u52A1\u6570\u636E\u4E0E\u91CD\u590D\u6267\u884C\u662F\u5426\u96F6\u589E\u6539\u3002\u672C\u6B21\u4E0D\u8BC1\u660E\u5B8C\u6574\u4E0A\u7EBF\u68C0\u67E5\u6216\u4E1A\u52A1\u53D1\u5E03\u901A\u8FC7\u3002
|
|
9562
|
+
`);
|
|
9563
|
+
process.exitCode = verification.status === "PASS" ? 0 : 3;
|
|
9564
|
+
} catch (error) {
|
|
9565
|
+
if (attempted) process.stderr.write("TENANT_RECONCILE_RESULT_UNKNOWN\uFF1A\u5DF2\u5C1D\u8BD5\u4E00\u6B21\u8865\u8DD1\uFF0C\u7ED3\u679C\u672A\u786E\u8BA4\uFF0C\u672A\u81EA\u52A8\u91CD\u53D1\uFF1B\u5148\u53EA\u8BFB\u68C0\u67E5 tenant.bootstrap \u4E0E\u670D\u52A1\u7AEF\u65E5\u5FD7\uFF0C\u4E0D\u8981\u76F2\u76EE\u91CD\u8DD1\u3002\n");
|
|
9566
|
+
exitWithError(axios4.isAxiosError(error) ? fromAxiosError20(error, args.env) : error);
|
|
9567
|
+
}
|
|
9568
|
+
}
|
|
9569
|
+
|
|
9446
9570
|
// src/commands/meta.ts
|
|
9447
9571
|
import { promises as fsp3 } from "fs";
|
|
9448
9572
|
import os4 from "os";
|
|
9449
9573
|
import nodePath from "path";
|
|
9450
9574
|
import {
|
|
9451
|
-
HcmClient as
|
|
9452
|
-
formatObject as
|
|
9453
|
-
fromAxiosError as
|
|
9575
|
+
HcmClient as HcmClient22,
|
|
9576
|
+
formatObject as formatObject22,
|
|
9577
|
+
fromAxiosError as fromAxiosError21,
|
|
9454
9578
|
listTenantMeta,
|
|
9455
9579
|
getTenantMeta,
|
|
9456
9580
|
saveTenantMeta,
|
|
@@ -9460,14 +9584,14 @@ import {
|
|
|
9460
9584
|
formatMetaIssues,
|
|
9461
9585
|
explainJacksonError,
|
|
9462
9586
|
META_SCHEMA_SOURCE_COMMIT,
|
|
9463
|
-
CliError as
|
|
9464
|
-
CliErrorCode as
|
|
9587
|
+
CliError as CliError24,
|
|
9588
|
+
CliErrorCode as CliErrorCode25
|
|
9465
9589
|
} from "@hcmai/sdk";
|
|
9466
9590
|
init_exit();
|
|
9467
9591
|
init_impersonation_lifecycle();
|
|
9468
9592
|
init_auth_guard();
|
|
9469
9593
|
async function client2(args) {
|
|
9470
|
-
return
|
|
9594
|
+
return HcmClient22.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
9471
9595
|
}
|
|
9472
9596
|
function formatMetaForbiddenMessage(mode = "write") {
|
|
9473
9597
|
if (mode === "read") {
|
|
@@ -9482,7 +9606,7 @@ function fail7(e, args, mode = "write") {
|
|
|
9482
9606
|
new Error(formatMetaForbiddenMessage(mode))
|
|
9483
9607
|
);
|
|
9484
9608
|
}
|
|
9485
|
-
if (err?.isAxiosError) exitWithError(
|
|
9609
|
+
if (err?.isAxiosError) exitWithError(fromAxiosError21(err, args.env));
|
|
9486
9610
|
exitWithError(e);
|
|
9487
9611
|
process.exit(1);
|
|
9488
9612
|
}
|
|
@@ -9498,7 +9622,7 @@ async function metaListCommand(args) {
|
|
|
9498
9622
|
const fmt = args.output ?? "json";
|
|
9499
9623
|
if (fmt !== "json") process.stdout.write(`\u{1F4C4} ${items.length} \u4EFD${total ? ` / \u5171 ${total}` : ""}
|
|
9500
9624
|
`);
|
|
9501
|
-
process.stdout.write(
|
|
9625
|
+
process.stdout.write(formatObject22(items, { format: fmt }) + "\n");
|
|
9502
9626
|
process.exitCode = 0;
|
|
9503
9627
|
return;
|
|
9504
9628
|
} catch (e) {
|
|
@@ -9586,8 +9710,8 @@ async function verifyAfterWrite(c2, path21) {
|
|
|
9586
9710
|
async function metaSetCommand(path21, args) {
|
|
9587
9711
|
try {
|
|
9588
9712
|
if (!args.file) {
|
|
9589
|
-
throw new
|
|
9590
|
-
code:
|
|
9713
|
+
throw new CliError24({
|
|
9714
|
+
code: CliErrorCode25.MISSING_FLAG,
|
|
9591
9715
|
message: "--file <path> \u5FC5\u586B\uFF08\u4ECE\u6587\u4EF6\u8BFB\u53D6 meta \u539F\u6587\uFF1B\u7528 - \u8868\u793A stdin\uFF09"
|
|
9592
9716
|
});
|
|
9593
9717
|
}
|
|
@@ -9619,7 +9743,7 @@ async function metaSetCommand(path21, args) {
|
|
|
9619
9743
|
const dryFmt = args.output;
|
|
9620
9744
|
if (dryFmt === "json" || dryFmt === "yaml") {
|
|
9621
9745
|
process.stdout.write(
|
|
9622
|
-
|
|
9746
|
+
formatObject22(
|
|
9623
9747
|
{ dryRun: true, path: path21, bytes: Buffer.byteLength(content), content },
|
|
9624
9748
|
{ format: dryFmt }
|
|
9625
9749
|
) + "\n"
|
|
@@ -9702,7 +9826,7 @@ ${content}
|
|
|
9702
9826
|
process.stdout.write(" \u5DF2\u6E05\u5143\u6570\u636E\u7F13\u5B58\uFF0C\u5E76\u771F\u8BFB\u4E86\u4E00\u904D\uFF1A\u670D\u52A1\u7AEF\u8BFB\u5F97\u52A8 \u2714\n");
|
|
9703
9827
|
}
|
|
9704
9828
|
}
|
|
9705
|
-
process.stdout.write(
|
|
9829
|
+
process.stdout.write(formatObject22(result, { format: fmt }) + "\n");
|
|
9706
9830
|
process.exitCode = 0;
|
|
9707
9831
|
return;
|
|
9708
9832
|
} catch (e) {
|
|
@@ -9724,7 +9848,7 @@ async function metaDeleteCommand(path21, args) {
|
|
|
9724
9848
|
const fmt = args.output ?? "json";
|
|
9725
9849
|
if (fmt !== "json") process.stdout.write(`\u{1F5D1}\uFE0F \u5DF2\u5220\u9664 ${path21}
|
|
9726
9850
|
`);
|
|
9727
|
-
process.stdout.write(
|
|
9851
|
+
process.stdout.write(formatObject22(result, { format: fmt }) + "\n");
|
|
9728
9852
|
process.exitCode = 0;
|
|
9729
9853
|
return;
|
|
9730
9854
|
} catch (e) {
|
|
@@ -9734,8 +9858,8 @@ async function metaDeleteCommand(path21, args) {
|
|
|
9734
9858
|
async function metaValidateCommand(path21, args) {
|
|
9735
9859
|
try {
|
|
9736
9860
|
if (!args.file) {
|
|
9737
|
-
throw new
|
|
9738
|
-
code:
|
|
9861
|
+
throw new CliError24({
|
|
9862
|
+
code: CliErrorCode25.MISSING_FLAG,
|
|
9739
9863
|
message: "--file <path> \u5FC5\u586B\uFF08\u8981\u9A8C\u7684\u90A3\u4EFD\u539F\u6587\uFF1B\u7528 - \u8868\u793A stdin\uFF09"
|
|
9740
9864
|
});
|
|
9741
9865
|
}
|
|
@@ -9750,7 +9874,7 @@ async function metaValidateCommand(path21, args) {
|
|
|
9750
9874
|
const fmt = args.output ?? "table";
|
|
9751
9875
|
if (fmt === "json" || fmt === "yaml") {
|
|
9752
9876
|
process.stdout.write(
|
|
9753
|
-
|
|
9877
|
+
formatObject22(
|
|
9754
9878
|
{
|
|
9755
9879
|
path: path21,
|
|
9756
9880
|
kind: result.kind,
|
|
@@ -9791,10 +9915,10 @@ import {
|
|
|
9791
9915
|
createWorkspaceFile,
|
|
9792
9916
|
deleteWorkspaceFile,
|
|
9793
9917
|
formatMiniVerifyReport,
|
|
9794
|
-
formatObject as
|
|
9918
|
+
formatObject as formatObject23,
|
|
9795
9919
|
formatRows as formatRows6,
|
|
9796
9920
|
getMiniStatus,
|
|
9797
|
-
HcmClient as
|
|
9921
|
+
HcmClient as HcmClient23,
|
|
9798
9922
|
initMiniAppProject,
|
|
9799
9923
|
inferMiniWritableTemplateOptionsFromModel,
|
|
9800
9924
|
listWorkspaceFiles,
|
|
@@ -9809,14 +9933,14 @@ import {
|
|
|
9809
9933
|
validateMiniProject,
|
|
9810
9934
|
validateMetaContent as validateMetaContent2,
|
|
9811
9935
|
validateWorkspaceFiles,
|
|
9812
|
-
fromAxiosError as
|
|
9813
|
-
CliError as
|
|
9814
|
-
CliErrorCode as
|
|
9936
|
+
fromAxiosError as fromAxiosError23,
|
|
9937
|
+
CliError as CliError26,
|
|
9938
|
+
CliErrorCode as CliErrorCode27
|
|
9815
9939
|
} from "@hcmai/sdk";
|
|
9816
9940
|
|
|
9817
9941
|
// src/commands/workspace-push-progress.ts
|
|
9818
9942
|
import { isAxiosError } from "axios";
|
|
9819
|
-
import { CliError as
|
|
9943
|
+
import { CliError as CliError25, CliErrorCode as CliErrorCode26, fromAxiosError as fromAxiosError22 } from "@hcmai/sdk";
|
|
9820
9944
|
var PUSH_DEADLINE_MS = 3e5;
|
|
9821
9945
|
var HEARTBEAT_MS = 1e4;
|
|
9822
9946
|
async function withWorkspacePushProgress(run3, profile) {
|
|
@@ -9844,8 +9968,8 @@ async function withWorkspacePushProgress(run3, profile) {
|
|
|
9844
9968
|
let timer;
|
|
9845
9969
|
const deadline = new Promise((_, reject) => {
|
|
9846
9970
|
timer = setTimeout(() => {
|
|
9847
|
-
failure2 = new
|
|
9848
|
-
code:
|
|
9971
|
+
failure2 = new CliError25({
|
|
9972
|
+
code: CliErrorCode26.TIMEOUT,
|
|
9849
9973
|
message: `workspace push \u6574\u4F53\u671F\u9650\u5DF2\u5230\uFF08300 \u79D2\uFF09\uFF1B\u7B49\u5F85 ${requestLabel()}\u3002\u670D\u52A1\u7AEF\u63D0\u4EA4\u72B6\u6001\u672A\u77E5\u3002`,
|
|
9850
9974
|
traceId: traceId(),
|
|
9851
9975
|
profile,
|
|
@@ -9886,8 +10010,8 @@ async function withWorkspacePushProgress(run3, profile) {
|
|
|
9886
10010
|
return await Promise.race([operation, deadline]);
|
|
9887
10011
|
} catch (error) {
|
|
9888
10012
|
if (!isAxiosError(error)) throw error;
|
|
9889
|
-
const translated =
|
|
9890
|
-
throw new
|
|
10013
|
+
const translated = fromAxiosError22(error, profile);
|
|
10014
|
+
throw new CliError25({
|
|
9891
10015
|
code: translated.code,
|
|
9892
10016
|
message: translated.message,
|
|
9893
10017
|
traceId: translated.traceId,
|
|
@@ -9900,7 +10024,7 @@ async function withWorkspacePushProgress(run3, profile) {
|
|
|
9900
10024
|
} : {},
|
|
9901
10025
|
nextStep: [
|
|
9902
10026
|
translated.context?.nextStep,
|
|
9903
|
-
translated.code ===
|
|
10027
|
+
translated.code === CliErrorCode26.AUTH_FAILED ? `\u5148 hcm login --env ${profile ?? "<\u73AF\u5883>"} --username <\u771F\u5B9E\u767B\u5F55\u8D26\u53F7> --password-stdin\uFF0C\u518D hcm workspace active\uFF1B\u8BA4\u8BC1\u672A\u901A\u8FC7\u4E0D\u80FD\u636E\u6B64\u5224\u65AD\u5DE5\u4F5C\u533A\u5931\u6548\u3002` : void 0,
|
|
9904
10028
|
recovery2
|
|
9905
10029
|
].filter(Boolean).join(" ")
|
|
9906
10030
|
}
|
|
@@ -9959,7 +10083,7 @@ var RAW_WORKSPACE_EXCLUDED_DIRS = /* @__PURE__ */ new Set([
|
|
|
9959
10083
|
var RAW_WORKSPACE_EXCLUDED_FILES = /* @__PURE__ */ new Set([WORKSPACE_CONTEXT_FILE, ".DS_Store"]);
|
|
9960
10084
|
async function workspaceListCommand(args) {
|
|
9961
10085
|
try {
|
|
9962
|
-
const client3 =
|
|
10086
|
+
const client3 = HcmClient23.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
9963
10087
|
const limit = parsePositiveInt3(args.limit, 50, "--limit");
|
|
9964
10088
|
const result = await client3.query("TenantExtensionWorkspace", {
|
|
9965
10089
|
keyword: args.keyword,
|
|
@@ -9992,7 +10116,7 @@ async function workspaceActiveCommand(args) {
|
|
|
9992
10116
|
const ctx = await getActiveAuthContextFromCli(args, {
|
|
9993
10117
|
fallbackEnv: localContext?.profile
|
|
9994
10118
|
});
|
|
9995
|
-
const client3 =
|
|
10119
|
+
const client3 = HcmClient23.fromAuthContext(ctx);
|
|
9996
10120
|
const binding = await readWorkspaceDevModeBinding(client3);
|
|
9997
10121
|
const activeWorkspaceKey = binding.enabled ? optionalText(binding.workspaceKey) : null;
|
|
9998
10122
|
const bindingUpdatedAt = typeof binding.updatedAt === "number" && Number.isFinite(binding.updatedAt) && binding.updatedAt > 0 && binding.updatedAt <= 864e13 ? binding.updatedAt : null;
|
|
@@ -10050,7 +10174,7 @@ async function workspaceCreateCommand(workspaceKey, args) {
|
|
|
10050
10174
|
`${WORKSPACE_CONTEXT_FILE} already binds workspace '${existing.workspaceKey}'; use --force to rebind`
|
|
10051
10175
|
);
|
|
10052
10176
|
}
|
|
10053
|
-
const client3 =
|
|
10177
|
+
const client3 = HcmClient23.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
10054
10178
|
const normalizedWorkspaceKey = normalizeWorkspaceKey(workspaceKey);
|
|
10055
10179
|
const resp = await client3.raw().post("/api/models/TenantExtensionWorkspace", {
|
|
10056
10180
|
workspaceKey: normalizedWorkspaceKey,
|
|
@@ -10098,7 +10222,7 @@ async function workspacePullCommand(args) {
|
|
|
10098
10222
|
`workspace key is required; pass --workspace <key> or run hcm workspace bind <key> first`
|
|
10099
10223
|
);
|
|
10100
10224
|
}
|
|
10101
|
-
const client3 =
|
|
10225
|
+
const client3 = HcmClient23.fromAuthContext(
|
|
10102
10226
|
await getActiveAuthContextFromCli(args, { fallbackEnv: existing?.profile })
|
|
10103
10227
|
);
|
|
10104
10228
|
const context = buildWorkspaceContext({
|
|
@@ -10185,6 +10309,7 @@ async function workspaceAddMiniCommand(appCode, args) {
|
|
|
10185
10309
|
workspaceKey: context.workspaceKey,
|
|
10186
10310
|
targetDir: path9.join(rootDir, MINI_APPS_DIR, appCode),
|
|
10187
10311
|
name: args.name,
|
|
10312
|
+
runtimeSdkVersion: args.sdkVersion,
|
|
10188
10313
|
defaultSurface: parseSurface(args.surface),
|
|
10189
10314
|
templateKind,
|
|
10190
10315
|
writableModel: model,
|
|
@@ -10252,7 +10377,7 @@ async function workspaceRmCommand(relativePath, args) {
|
|
|
10252
10377
|
if (!stat) {
|
|
10253
10378
|
if (manifestEntry) {
|
|
10254
10379
|
process.stdout.write(
|
|
10255
|
-
|
|
10380
|
+
formatObject23(
|
|
10256
10381
|
{
|
|
10257
10382
|
workspaceKey: context.workspaceKey,
|
|
10258
10383
|
file: normalized,
|
|
@@ -10277,7 +10402,7 @@ async function workspaceRmCommand(relativePath, args) {
|
|
|
10277
10402
|
next: `hcm workspace push --dir ${args.dir ?? "."}`
|
|
10278
10403
|
};
|
|
10279
10404
|
if (args.output === "json" || args.output === "yaml") {
|
|
10280
|
-
process.stdout.write(
|
|
10405
|
+
process.stdout.write(formatObject23(result, { format: args.output }) + "\n");
|
|
10281
10406
|
} else {
|
|
10282
10407
|
process.stdout.write(`workspace file staged for deletion: ${normalized}
|
|
10283
10408
|
`);
|
|
@@ -10324,7 +10449,7 @@ async function workspaceStatusCommand(args) {
|
|
|
10324
10449
|
}
|
|
10325
10450
|
if (args.output === "json" || args.output === "yaml") {
|
|
10326
10451
|
process.stdout.write(
|
|
10327
|
-
|
|
10452
|
+
formatObject23({ rootDir, miniApps: rows2 }, { format: args.output }) + "\n"
|
|
10328
10453
|
);
|
|
10329
10454
|
} else {
|
|
10330
10455
|
process.stdout.write(formatRows6(rows2, { format: "table" }) + "\n");
|
|
@@ -10385,13 +10510,13 @@ async function workspacePushCommand(args) {
|
|
|
10385
10510
|
for (const app of miniApps) {
|
|
10386
10511
|
const validation = await validateMiniProject(app.dir);
|
|
10387
10512
|
if (!validation.valid) {
|
|
10388
|
-
throw new
|
|
10389
|
-
code:
|
|
10513
|
+
throw new CliError26({
|
|
10514
|
+
code: CliErrorCode27.INVALID_ARGUMENT,
|
|
10390
10515
|
message: `mini app ${app.appCode} validation failed: ${validation.errors.join("; ")}`
|
|
10391
10516
|
});
|
|
10392
10517
|
}
|
|
10393
10518
|
}
|
|
10394
|
-
const client3 =
|
|
10519
|
+
const client3 = HcmClient23.fromAuthContext(
|
|
10395
10520
|
await getActiveAuthContextFromCli(args, { fallbackEnv: context.profile })
|
|
10396
10521
|
);
|
|
10397
10522
|
profile = client3.profile ?? profile;
|
|
@@ -10434,8 +10559,8 @@ async function workspacePushCommand(args) {
|
|
|
10434
10559
|
return;
|
|
10435
10560
|
} catch (e) {
|
|
10436
10561
|
let failure2 = e;
|
|
10437
|
-
if (e instanceof
|
|
10438
|
-
failure2 = new
|
|
10562
|
+
if (e instanceof CliError26 && pushProgress && !e.context?.push) {
|
|
10563
|
+
failure2 = new CliError26({
|
|
10439
10564
|
code: e.code,
|
|
10440
10565
|
message: e.message,
|
|
10441
10566
|
traceId: e.traceId,
|
|
@@ -10472,7 +10597,7 @@ async function workspacePreviewCommand(args) {
|
|
|
10472
10597
|
);
|
|
10473
10598
|
}
|
|
10474
10599
|
if (args.output === "json" || args.output === "yaml") {
|
|
10475
|
-
process.stdout.write(
|
|
10600
|
+
process.stdout.write(formatObject23(rows2, { format: args.output }) + "\n");
|
|
10476
10601
|
} else {
|
|
10477
10602
|
process.stdout.write(formatRows6(rows2, { format: "table" }) + "\n");
|
|
10478
10603
|
}
|
|
@@ -10620,8 +10745,8 @@ async function assertWorkspacePushRoot(rootDir) {
|
|
|
10620
10745
|
}
|
|
10621
10746
|
if (!insideMiniApp && (!workspaceRoot || workspaceRoot === realRoot)) return;
|
|
10622
10747
|
const target = workspaceRoot ? quoteWorkspaceArg(workspaceRoot) : "<workspace-root>";
|
|
10623
|
-
throw new
|
|
10624
|
-
code:
|
|
10748
|
+
throw new CliError26({
|
|
10749
|
+
code: CliErrorCode27.INVALID_ARGUMENT,
|
|
10625
10750
|
message: `workspace push \u5FC5\u987B\u4ECE workspace \u6839\u76EE\u5F55\u6267\u884C\uFF0C\u5F53\u524D\u76EE\u5F55 ${rootDir} \u662F${insideMiniApp ? "\u8F7B\u5E94\u7528\u76EE\u5F55\u6216\u5176\u5B50\u76EE\u5F55" : "\u5DE5\u4F5C\u533A\u5B50\u76EE\u5F55"}\uFF1B\u7EE7\u7EED\u4F1A\u8DF3\u8FC7\u8F7B\u5E94\u7528\u90E8\u7F72\u3002`,
|
|
10626
10751
|
context: {
|
|
10627
10752
|
nextStep: `${workspaceRoot ? `workspace \u6839\u76EE\u5F55\uFF1A${workspaceRoot}\u3002` : `\u672A\u627E\u5230\u4E0A\u5C42 ${WORKSPACE_CONTEXT_FILE}\uFF1B\u8BF7\u5148\u5B9A\u4F4D\u5305\u542B mini_apps/ \u7684 workspace \u6839\u76EE\u5F55\u3002`}\u6267\u884C hcm workspace push --dir ${target}\uFF0C\u4FDD\u7559\u539F\u6709 --env/--as \u7B49\u9009\u9879\u3002`
|
|
@@ -10814,8 +10939,8 @@ async function pushWorkspaceRawFiles(args) {
|
|
|
10814
10939
|
);
|
|
10815
10940
|
if (args.dryRun) return result;
|
|
10816
10941
|
if (result.preflight.status === "failed") {
|
|
10817
|
-
throw new
|
|
10818
|
-
code:
|
|
10942
|
+
throw new CliError26({
|
|
10943
|
+
code: CliErrorCode27.INVALID_ARGUMENT,
|
|
10819
10944
|
message: `\u670D\u52A1\u7AEF\u9884\u68C0\u672A\u901A\u8FC7\uFF0C\u672C\u6B21\u6CA1\u6709\u5199\u5165\u4EFB\u4F55\u6587\u4EF6\uFF1A${result.preflight.issues.length} \u5904\u95EE\u9898
|
|
10820
10945
|
${formatPreflightIssues(result.preflight.issues, " ")}`,
|
|
10821
10946
|
profile: args.profile ?? args.context.profile,
|
|
@@ -10900,29 +11025,29 @@ ${formatPreflightIssues(result.preflight.issues, " ")}`,
|
|
|
10900
11025
|
checkpointSaved
|
|
10901
11026
|
});
|
|
10902
11027
|
} catch (error) {
|
|
10903
|
-
const translated = error?.isAxiosError ?
|
|
11028
|
+
const translated = error?.isAxiosError ? fromAxiosError23(error, args.profile ?? args.context.profile) : error;
|
|
10904
11029
|
const push = progress();
|
|
10905
11030
|
args.onProgress?.(push);
|
|
10906
|
-
throw new
|
|
10907
|
-
code: translated instanceof
|
|
11031
|
+
throw new CliError26({
|
|
11032
|
+
code: translated instanceof CliError26 ? translated.code : CliErrorCode27.INVALID_ARGUMENT,
|
|
10908
11033
|
message: translated instanceof Error ? translated.message : String(translated),
|
|
10909
|
-
traceId: translated instanceof
|
|
10910
|
-
profile: translated instanceof
|
|
11034
|
+
traceId: translated instanceof CliError26 ? translated.traceId : void 0,
|
|
11035
|
+
profile: translated instanceof CliError26 ? translated.profile : args.profile ?? args.context.profile,
|
|
10911
11036
|
cause: error,
|
|
10912
11037
|
context: {
|
|
10913
|
-
...translated instanceof
|
|
11038
|
+
...translated instanceof CliError26 ? translated.context : {},
|
|
10914
11039
|
workspaceKey: args.context.workspaceKey,
|
|
10915
11040
|
push,
|
|
10916
11041
|
details: {
|
|
10917
|
-
serverDetails: translated instanceof
|
|
11042
|
+
serverDetails: translated instanceof CliError26 ? translated.context?.details : void 0,
|
|
10918
11043
|
push
|
|
10919
11044
|
},
|
|
10920
11045
|
note: [
|
|
10921
|
-
translated instanceof
|
|
11046
|
+
translated instanceof CliError26 ? translated.context?.note : void 0,
|
|
10922
11047
|
"\u9010\u6587\u4EF6\u63A8\u9001\u53EF\u80FD\u5DF2\u90E8\u5206\u5199\u5165\uFF1Bcommitted \u662F\u5DF2\u6536\u5230\u6210\u529F\u56DE\u6267\u7684\u6587\u4EF6\uFF0CUNKNOWN \u4E0D\u80FD\u5F53\u4F5C\u672A\u5199\u5165\u3002"
|
|
10923
11048
|
].filter(Boolean).join(" "),
|
|
10924
11049
|
nextStep: [
|
|
10925
|
-
translated instanceof
|
|
11050
|
+
translated instanceof CliError26 ? translated.context?.nextStep : void 0,
|
|
10926
11051
|
"\u5DF2\u786E\u8BA4\u6587\u4EF6\u7684\u8FDB\u5EA6\u9010\u9879\u4FDD\u5B58\uFF1B\u4FEE\u6B63\u5931\u8D25\u6587\u4EF6\u540E\u5148 push --dry-run \u68C0\u67E5\uFF0C\u518D\u666E\u901A push \u7EED\u8DD1\u3002\u5F53\u524D\u5931\u8D25\u9879 checkpointSaved=false \u6216\u63D0\u4EA4\u72B6\u6001 UNKNOWN \u65F6\u987B\u56DE\u8BFB\u6838\u5BF9\uFF1B\u82E5\u6709\u771F\u5B9E\u8FDC\u7AEF\u51B2\u7A81\uFF0C\u5148 pull \u5230\u65B0\u7684\u7A7A\u76EE\u5F55\u6838\u5BF9\u5E76\u5408\u5E76\uFF0C\u7981\u6B62\u5F3A\u5236\u8986\u76D6\u3002"
|
|
10927
11052
|
].filter(Boolean).join(" ")
|
|
10928
11053
|
}
|
|
@@ -10973,7 +11098,7 @@ async function preflightWorkspacePlan(http, workspaceKey, operations, localFiles
|
|
|
10973
11098
|
return { status: "passed", sent, checked: verdict.checked, issues: [] };
|
|
10974
11099
|
} catch (error) {
|
|
10975
11100
|
const status = error?.response?.status;
|
|
10976
|
-
const translated = error?.isAxiosError ?
|
|
11101
|
+
const translated = error?.isAxiosError ? fromAxiosError23(error, profile) : error;
|
|
10977
11102
|
const detail = translated instanceof Error ? translated.message : String(translated);
|
|
10978
11103
|
return {
|
|
10979
11104
|
status: "unavailable",
|
|
@@ -11221,7 +11346,7 @@ async function readMiniStatusSafely(app) {
|
|
|
11221
11346
|
async function loadProfileClient(args) {
|
|
11222
11347
|
try {
|
|
11223
11348
|
const ctx = await getActiveAuthContextFromCli(args);
|
|
11224
|
-
return
|
|
11349
|
+
return HcmClient23.fromAuthContext(ctx);
|
|
11225
11350
|
} catch (e) {
|
|
11226
11351
|
if (args.env || args.profile) throw e;
|
|
11227
11352
|
return null;
|
|
@@ -11388,7 +11513,7 @@ function optionalText(value) {
|
|
|
11388
11513
|
}
|
|
11389
11514
|
function writeWorkspaceListResult(rows2, format, total) {
|
|
11390
11515
|
if (format !== "table") {
|
|
11391
|
-
process.stdout.write(
|
|
11516
|
+
process.stdout.write(formatObject23({ rows: rows2, total }, { format }) + "\n");
|
|
11392
11517
|
return;
|
|
11393
11518
|
}
|
|
11394
11519
|
process.stdout.write(formatRows6(toWorkspaceListRows(rows2), { format: "table" }) + "\n");
|
|
@@ -11399,7 +11524,7 @@ function writeWorkspaceListResult(rows2, format, total) {
|
|
|
11399
11524
|
}
|
|
11400
11525
|
function writeWorkspaceActiveResult(view, format) {
|
|
11401
11526
|
if (format !== "table") {
|
|
11402
|
-
process.stdout.write(
|
|
11527
|
+
process.stdout.write(formatObject23(view, { format }) + "\n");
|
|
11403
11528
|
return;
|
|
11404
11529
|
}
|
|
11405
11530
|
const rows2 = [
|
|
@@ -11424,7 +11549,7 @@ function writeWorkspaceActiveResult(view, format) {
|
|
|
11424
11549
|
}
|
|
11425
11550
|
function writeWorkspaceBindResult(context, rootDir, format) {
|
|
11426
11551
|
if (format !== "table") {
|
|
11427
|
-
process.stdout.write(
|
|
11552
|
+
process.stdout.write(formatObject23({ ...context, rootDir }, { format }) + "\n");
|
|
11428
11553
|
return;
|
|
11429
11554
|
}
|
|
11430
11555
|
process.stdout.write(
|
|
@@ -11438,7 +11563,7 @@ function writeWorkspaceBindResult(context, rootDir, format) {
|
|
|
11438
11563
|
}
|
|
11439
11564
|
function writeWorkspaceCreateResult(result, format) {
|
|
11440
11565
|
if (format !== "table") {
|
|
11441
|
-
process.stdout.write(
|
|
11566
|
+
process.stdout.write(formatObject23(result, { format }) + "\n");
|
|
11442
11567
|
return;
|
|
11443
11568
|
}
|
|
11444
11569
|
process.stdout.write(
|
|
@@ -11454,7 +11579,7 @@ function writeWorkspaceCreateResult(result, format) {
|
|
|
11454
11579
|
}
|
|
11455
11580
|
function writeWorkspacePullResult(result, format) {
|
|
11456
11581
|
if (format !== "table") {
|
|
11457
|
-
process.stdout.write(
|
|
11582
|
+
process.stdout.write(formatObject23(result, { format }) + "\n");
|
|
11458
11583
|
return;
|
|
11459
11584
|
}
|
|
11460
11585
|
const lines = [
|
|
@@ -11472,7 +11597,7 @@ function writeWorkspacePullResult(result, format) {
|
|
|
11472
11597
|
}
|
|
11473
11598
|
function writeWorkspaceAddMiniResult(result, rootDir, format) {
|
|
11474
11599
|
if (format !== "table") {
|
|
11475
|
-
process.stdout.write(
|
|
11600
|
+
process.stdout.write(formatObject23({ ...result, workspaceRoot: rootDir }, { format }) + "\n");
|
|
11476
11601
|
return;
|
|
11477
11602
|
}
|
|
11478
11603
|
process.stdout.write(
|
|
@@ -11488,7 +11613,7 @@ function writeWorkspaceAddMiniResult(result, rootDir, format) {
|
|
|
11488
11613
|
function writeWorkspaceValidateResult(results, format) {
|
|
11489
11614
|
if (format !== "table") {
|
|
11490
11615
|
process.stdout.write(
|
|
11491
|
-
|
|
11616
|
+
formatObject23(
|
|
11492
11617
|
results.map((item) => ({ artifact: item.artifact, ...item.result })),
|
|
11493
11618
|
{ format }
|
|
11494
11619
|
) + "\n"
|
|
@@ -11516,7 +11641,7 @@ ${item.artifact}
|
|
|
11516
11641
|
function writeWorkspacePushResult(rawResult, results, format) {
|
|
11517
11642
|
if (format !== "table") {
|
|
11518
11643
|
process.stdout.write(
|
|
11519
|
-
|
|
11644
|
+
formatObject23(
|
|
11520
11645
|
{
|
|
11521
11646
|
// 预检覆盖整份计划(workspace 文件 + 轻应用文件),放在顶层。
|
|
11522
11647
|
preflight: rawResult.preflight ?? null,
|
|
@@ -11581,7 +11706,7 @@ function writeWorkspaceVerifyResult(context, rootDir, raw, reports, format) {
|
|
|
11581
11706
|
const preflight = raw.plan?.preflight ?? null;
|
|
11582
11707
|
if (format === "json") {
|
|
11583
11708
|
process.stdout.write(
|
|
11584
|
-
|
|
11709
|
+
formatObject23(
|
|
11585
11710
|
{
|
|
11586
11711
|
ok,
|
|
11587
11712
|
workspaceKey: context.workspaceKey,
|
|
@@ -11609,7 +11734,7 @@ function writeWorkspaceVerifyResult(context, rootDir, raw, reports, format) {
|
|
|
11609
11734
|
}
|
|
11610
11735
|
if (format !== "table") {
|
|
11611
11736
|
process.stdout.write(
|
|
11612
|
-
|
|
11737
|
+
formatObject23(
|
|
11613
11738
|
{
|
|
11614
11739
|
ok,
|
|
11615
11740
|
workspaceKey: context.workspaceKey,
|
|
@@ -11665,13 +11790,13 @@ function quoteWorkspaceArg(value) {
|
|
|
11665
11790
|
}
|
|
11666
11791
|
function exitWorkspaceError(err, profile, operation) {
|
|
11667
11792
|
const maybeAxios = err;
|
|
11668
|
-
const translated = maybeAxios?.isAxiosError ?
|
|
11669
|
-
if (translated instanceof
|
|
11793
|
+
const translated = maybeAxios?.isAxiosError ? fromAxiosError23(err, profile) : err;
|
|
11794
|
+
if (translated instanceof CliError26 && operation && translated.context?.status === 409 && ["WORKSPACE_REVISION_CONFLICT", "DEPLOY_IN_PROGRESS"].includes(String(translated.context.responseCode))) {
|
|
11670
11795
|
const scope = `${profile ? ` --env ${quoteWorkspaceArg(profile)}` : ""}${operation.as ? ` --as ${quoteWorkspaceArg(operation.as)}` : ""}`;
|
|
11671
11796
|
const active = "hcm workspace active" + scope + (operation.dir ? ` --dir ${quoteWorkspaceArg(operation.dir)}` : "");
|
|
11672
11797
|
const deployment = translated.context.responseCode === "DEPLOY_IN_PROGRESS" ? `\u6709\u53D1\u5E03\u67E5\u8BE2\u6743\u9650\u65F6\uFF0C\u6267\u884C hcm query TenantExtensionRelease --fields id,workspaceKey,deploymentStatus --limit 20${scope} \u67E5\u770B\u53EF\u89C1\u90E8\u7F72\u8BB0\u5F55\uFF1B\u7A7A\u7ED3\u679C\u4E0D\u80FD\u8BC1\u660E\u9501\u5DF2\u91CA\u653E\u3002` : void 0;
|
|
11673
11798
|
const retry = operation.command === "activate" ? `\u6309\u670D\u52A1\u7AEF\u8BE6\u60C5\u5B8C\u6210\u5904\u7406\u5E76\u786E\u8BA4\u76EE\u6807\u5DE5\u4F5C\u533A\u540E\uFF0C\u518D\u6267\u884C hcm workspace activate ${quoteWorkspaceArg(operation.workspaceKey)}${scope}\u3002` : `\u4FDD\u7559\u672C\u5730\u76EE\u5F55 ${operation.dir}\uFF1B\u6267\u884C hcm workspace pull --workspace ${quoteWorkspaceArg(operation.workspaceKey)} --dir '<\u65B0\u7684\u7A7A\u76EE\u5F55>'${scope}\uFF0C\u6BD4\u5BF9\u540E\u628A\u5F85\u4FDD\u7559\u4FEE\u6539\uFF08\u542B\u5220\u9664\u610F\u56FE\uFF09\u5408\u5E76\u5230\u65B0\u76EE\u5F55\uFF0C\u518D\u6267\u884C hcm workspace push --dir '<\u65B0\u7684\u7A7A\u76EE\u5F55>' --dry-run${scope}\uFF0C\u6838\u5BF9\u8BA1\u5212\u540E\u5728\u65B0\u76EE\u5F55\u53BB\u6389 --dry-run \u63A8\u9001\u3002\u539F\u76EE\u5F55\u4FDD\u7559\u5907\u4EFD\uFF0C\u4E0D\u8981\u8986\u76D6\u6216\u7EE7\u7EED\u4F7F\u7528\u65E7\u57FA\u7EBF\u63A8\u9001\u3002`;
|
|
11674
|
-
exitWithError(new
|
|
11799
|
+
exitWithError(new CliError26({
|
|
11675
11800
|
code: translated.code,
|
|
11676
11801
|
message: translated.message,
|
|
11677
11802
|
traceId: translated.traceId,
|
|
@@ -11684,8 +11809,8 @@ function exitWorkspaceError(err, profile, operation) {
|
|
|
11684
11809
|
}
|
|
11685
11810
|
}));
|
|
11686
11811
|
}
|
|
11687
|
-
if (translated instanceof
|
|
11688
|
-
exitWithError(new
|
|
11812
|
+
if (translated instanceof CliError26 && translated.code === CliErrorCode27.AUTH_FAILED) {
|
|
11813
|
+
exitWithError(new CliError26({
|
|
11689
11814
|
code: translated.code,
|
|
11690
11815
|
message: translated.message,
|
|
11691
11816
|
traceId: translated.traceId,
|
|
@@ -11713,8 +11838,8 @@ async function probeActiveWorkspaceKey(client3) {
|
|
|
11713
11838
|
}
|
|
11714
11839
|
function requireWorkspaceActivation(activeKey, workspaceKey, afterPush = false) {
|
|
11715
11840
|
if (activeKey === workspaceKey) return;
|
|
11716
|
-
throw new
|
|
11717
|
-
code:
|
|
11841
|
+
throw new CliError26({
|
|
11842
|
+
code: CliErrorCode27.INVALID_ARGUMENT,
|
|
11718
11843
|
message: (afterPush ? "\u63A8\u9001\u540E\u7ED1\u5B9A\u5DF2\u53D8\u5316\uFF0C\u6587\u4EF6\u53EF\u80FD\u5DF2\u4FDD\u5B58\u4E3A\u8349\u7A3F\uFF1B" : "") + (activeKey ? `\u5F53\u524D\u8EAB\u4EFD\u6FC0\u6D3B\u7684\u662F "${activeKey}"\uFF0C\u4E0D\u662F\u672C\u7A7A\u95F4 "${workspaceKey}"\uFF1B\u672C\u7A7A\u95F4\u5185\u5BB9\u5C1A\u672A\u7528\u4E8E\u5F00\u53D1\u9884\u89C8\u3002` : `\u5F53\u524D\u8EAB\u4EFD\u672A\u6FC0\u6D3B\u5F00\u53D1\u7A7A\u95F4 "${workspaceKey}"\uFF1B\u672C\u7A7A\u95F4\u5185\u5BB9\u5C1A\u672A\u7528\u4E8E\u5F00\u53D1\u9884\u89C8\u3002`),
|
|
11719
11844
|
context: { workspaceKey, activeWorkspaceKey: activeKey, nextStep: `hcm workspace activate ${workspaceKey}` }
|
|
11720
11845
|
});
|
|
@@ -11751,7 +11876,7 @@ async function workspaceActivateCommand(workspaceKey, args) {
|
|
|
11751
11876
|
let recovery2;
|
|
11752
11877
|
let profile = args.env ?? args.profile;
|
|
11753
11878
|
try {
|
|
11754
|
-
const client3 =
|
|
11879
|
+
const client3 = HcmClient23.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
11755
11880
|
profile = client3.profile ?? profile;
|
|
11756
11881
|
const key2 = normalizeWorkspaceKey(workspaceKey);
|
|
11757
11882
|
recovery2 = { command: "activate", workspaceKey: key2, as: args.as };
|
|
@@ -11763,7 +11888,7 @@ async function workspaceActivateCommand(workspaceKey, args) {
|
|
|
11763
11888
|
process.stdout.write("\u8BE5\u7A7A\u95F4\u7684 metas / scripts / menus / mini_apps \u73B0\u5DF2\u5728\u5F53\u524D\u79DF\u6237\u751F\u6548\u3002\n");
|
|
11764
11889
|
} else {
|
|
11765
11890
|
process.stdout.write(
|
|
11766
|
-
|
|
11891
|
+
formatObject23({ workspaceKey: key2, activated: true }, { format: fmt }) + "\n"
|
|
11767
11892
|
);
|
|
11768
11893
|
}
|
|
11769
11894
|
process.exitCode = 0;
|
|
@@ -11774,7 +11899,7 @@ async function workspaceActivateCommand(workspaceKey, args) {
|
|
|
11774
11899
|
}
|
|
11775
11900
|
async function workspaceDeactivateCommand(args) {
|
|
11776
11901
|
try {
|
|
11777
|
-
const client3 =
|
|
11902
|
+
const client3 = HcmClient23.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
11778
11903
|
const binding = await requestWorkspaceDeactivation(client3);
|
|
11779
11904
|
const result = { ...binding, deactivated: true };
|
|
11780
11905
|
const fmt = args.output ?? "table";
|
|
@@ -11782,7 +11907,7 @@ async function workspaceDeactivateCommand(args) {
|
|
|
11782
11907
|
process.stdout.write("workspace deactivated\n");
|
|
11783
11908
|
process.stdout.write("\u5F53\u524D\u8EAB\u4EFD\u5DF2\u9000\u51FA\u5F00\u53D1\u8005\u6A21\u5F0F\uFF1B\u5F00\u53D1\u7A7A\u95F4\u3001\u672C\u5730\u6587\u4EF6\u4E0E\u5DF2\u53D1\u5E03\u8D44\u4EA7\u5747\u672A\u5220\u9664\u3002\n");
|
|
11784
11909
|
} else {
|
|
11785
|
-
process.stdout.write(
|
|
11910
|
+
process.stdout.write(formatObject23(result, { format: fmt }) + "\n");
|
|
11786
11911
|
}
|
|
11787
11912
|
process.exitCode = 0;
|
|
11788
11913
|
return;
|
|
@@ -11793,14 +11918,14 @@ async function workspaceDeactivateCommand(args) {
|
|
|
11793
11918
|
|
|
11794
11919
|
// src/commands/identity.ts
|
|
11795
11920
|
init_exit();
|
|
11796
|
-
import
|
|
11921
|
+
import axios5 from "axios";
|
|
11797
11922
|
import {
|
|
11798
11923
|
AUTH_INFO_PATH,
|
|
11799
|
-
CliError as
|
|
11800
|
-
CliErrorCode as
|
|
11801
|
-
formatObject as
|
|
11924
|
+
CliError as CliError27,
|
|
11925
|
+
CliErrorCode as CliErrorCode28,
|
|
11926
|
+
formatObject as formatObject24,
|
|
11802
11927
|
formatRows as formatRows7,
|
|
11803
|
-
fromAxiosError as
|
|
11928
|
+
fromAxiosError as fromAxiosError24,
|
|
11804
11929
|
loadEnv as loadEnv4,
|
|
11805
11930
|
saveEnv as saveEnv3,
|
|
11806
11931
|
loadIdentity as loadIdentity4,
|
|
@@ -11813,7 +11938,7 @@ import {
|
|
|
11813
11938
|
toPrincipal
|
|
11814
11939
|
} from "@hcmai/sdk";
|
|
11815
11940
|
var fetchAuthInfo = async (endpoint, accessToken) => {
|
|
11816
|
-
const response = await
|
|
11941
|
+
const response = await axios5.get(`${endpoint.replace(/\/$/, "")}${AUTH_INFO_PATH}`, {
|
|
11817
11942
|
headers: { Authorization: `Bearer ${accessToken}` },
|
|
11818
11943
|
timeout: 3e4
|
|
11819
11944
|
});
|
|
@@ -11824,8 +11949,8 @@ async function inspectIdentity(name, fetcher = fetchAuthInfo) {
|
|
|
11824
11949
|
const env2 = await loadEnv4(meta2.env);
|
|
11825
11950
|
const accessToken = await TokenStore4.forIdentity(name).getStoredAccessToken();
|
|
11826
11951
|
if (!accessToken) {
|
|
11827
|
-
throw new
|
|
11828
|
-
code:
|
|
11952
|
+
throw new CliError27({
|
|
11953
|
+
code: CliErrorCode28.AUTH_FAILED,
|
|
11829
11954
|
message: `identity '${name}' \u6CA1\u6709\u53EF\u8BFB\u53D6\u7684\u6301\u4E45\u5316 token`,
|
|
11830
11955
|
context: { nextStep: `\u91CD\u65B0\u767B\u5F55\u8BE5\u8EAB\u4EFD\uFF1Ahcm login --env ${meta2.env} --name ${name}` }
|
|
11831
11956
|
});
|
|
@@ -11853,9 +11978,9 @@ async function inspectIdentity(name, fetcher = fetchAuthInfo) {
|
|
|
11853
11978
|
async function identityShow(name, args) {
|
|
11854
11979
|
try {
|
|
11855
11980
|
const details = await inspectIdentity(name);
|
|
11856
|
-
return exitOk(
|
|
11981
|
+
return exitOk(formatObject24(details, { format: args.output ?? "json" }));
|
|
11857
11982
|
} catch (e) {
|
|
11858
|
-
exitWithError(
|
|
11983
|
+
exitWithError(axios5.isAxiosError(e) ? fromAxiosError24(e, name) : e);
|
|
11859
11984
|
}
|
|
11860
11985
|
}
|
|
11861
11986
|
async function identityList(args) {
|
|
@@ -11865,7 +11990,7 @@ async function identityList(args) {
|
|
|
11865
11990
|
const names = await listIdentities4(filter);
|
|
11866
11991
|
const fmt = args.output ?? "table";
|
|
11867
11992
|
if (names.length === 0) {
|
|
11868
|
-
return exitOk(fmt === "table" ? "(no identities)" :
|
|
11993
|
+
return exitOk(fmt === "table" ? "(no identities)" : formatObject24([], { format: fmt }));
|
|
11869
11994
|
}
|
|
11870
11995
|
const rows2 = [];
|
|
11871
11996
|
for (const n of names) {
|
|
@@ -11879,7 +12004,7 @@ async function identityList(args) {
|
|
|
11879
12004
|
isDefault: env2?.defaultIdentity === n
|
|
11880
12005
|
});
|
|
11881
12006
|
}
|
|
11882
|
-
return exitOk(fmt === "table" ? formatRows7(rows2, { format: fmt }) :
|
|
12007
|
+
return exitOk(fmt === "table" ? formatRows7(rows2, { format: fmt }) : formatObject24(rows2, { format: fmt }));
|
|
11883
12008
|
} catch (e) {
|
|
11884
12009
|
exitWithError(e);
|
|
11885
12010
|
}
|
|
@@ -11888,8 +12013,8 @@ async function identityUse(name) {
|
|
|
11888
12013
|
try {
|
|
11889
12014
|
const meta2 = await loadIdentity4(name);
|
|
11890
12015
|
const env2 = await loadEnv4(meta2.env).catch(() => {
|
|
11891
|
-
throw new
|
|
11892
|
-
code:
|
|
12016
|
+
throw new CliError27({
|
|
12017
|
+
code: CliErrorCode28.IDENTITY_NOT_IN_ENV,
|
|
11893
12018
|
message: `identity '${name}' references env '${meta2.env}' which no longer exists. Re-create the env, or remove this orphan: hcm identity remove ${name}`
|
|
11894
12019
|
});
|
|
11895
12020
|
});
|
|
@@ -11929,11 +12054,11 @@ init_exit();
|
|
|
11929
12054
|
import { promises as fs9 } from "fs";
|
|
11930
12055
|
import path10 from "path";
|
|
11931
12056
|
import {
|
|
11932
|
-
CliError as
|
|
11933
|
-
CliErrorCode as
|
|
11934
|
-
HcmClient as
|
|
12057
|
+
CliError as CliError28,
|
|
12058
|
+
CliErrorCode as CliErrorCode29,
|
|
12059
|
+
HcmClient as HcmClient24,
|
|
11935
12060
|
fetchReconIdentity,
|
|
11936
|
-
formatObject as
|
|
12061
|
+
formatObject as formatObject25,
|
|
11937
12062
|
httpProbe,
|
|
11938
12063
|
isTempEnv as isTempEnv3,
|
|
11939
12064
|
assertNotReservedEnvName as assertNotReservedEnvName2,
|
|
@@ -11946,7 +12071,7 @@ import {
|
|
|
11946
12071
|
} from "@hcmai/sdk";
|
|
11947
12072
|
async function probeTokenTenant(envName, requested) {
|
|
11948
12073
|
const ctx = await getActiveAuthContextFromCli({ env: envName });
|
|
11949
|
-
const client3 =
|
|
12074
|
+
const client3 = HcmClient24.fromAuthContext(ctx);
|
|
11950
12075
|
const identity3 = await fetchReconIdentity(httpProbe(client3.raw(), "default"), requested);
|
|
11951
12076
|
return identity3?.tenantId ? String(identity3.tenantId) : void 0;
|
|
11952
12077
|
}
|
|
@@ -11991,8 +12116,8 @@ async function resolveInitEnv(root, args, deps) {
|
|
|
11991
12116
|
if (existing && path10.dirname(existing.path) === path10.resolve(root)) {
|
|
11992
12117
|
const name2 = args.env ?? existing.config.default;
|
|
11993
12118
|
const env2 = existing.config.environments[name2];
|
|
11994
|
-
if (!env2) throw new
|
|
11995
|
-
code:
|
|
12119
|
+
if (!env2) throw new CliError28({
|
|
12120
|
+
code: CliErrorCode29.INVALID_ARGUMENT,
|
|
11996
12121
|
message: `${existing.path} \u91CC\u6CA1\u6709\u73AF\u5883 '${name2}'\uFF0C\u53EA\u6709\uFF1A${Object.keys(existing.config.environments).join("\u3001")}`,
|
|
11997
12122
|
// env add 的 endpoint / frontend / tenant 都是必填,少一个照抄就是 required option 报错。
|
|
11998
12123
|
context: { nextStep: `hcm chiron env add ${name2} --endpoint <\u540E\u7AEF\u5730\u5740> --frontend <\u524D\u7AEF\u5730\u5740> --tenant <\u79DF\u6237\u53F7>` }
|
|
@@ -12002,8 +12127,8 @@ async function resolveInitEnv(root, args, deps) {
|
|
|
12002
12127
|
}
|
|
12003
12128
|
if (args.env) {
|
|
12004
12129
|
const config3 = await loadEnv5(args.env).catch(() => null);
|
|
12005
|
-
if (!config3?.endpoint) throw new
|
|
12006
|
-
code:
|
|
12130
|
+
if (!config3?.endpoint) throw new CliError28({
|
|
12131
|
+
code: CliErrorCode29.ENV_NOT_FOUND,
|
|
12007
12132
|
message: `\u672C\u673A\u6CA1\u6709\u540D\u53EB '${args.env}' \u7684\u73AF\u5883\u3002`,
|
|
12008
12133
|
context: { nextStep: "`hcm env list` \u770B\u6709\u54EA\u4E9B\uFF1B\u6216\u5B8C\u5168\u663E\u5F0F\u5730\u5EFA\uFF1A`hcm chiron init --endpoint <\u540E\u7AEF\u5730\u5740> --tenant <\u79DF\u6237\u53F7>`" }
|
|
12009
12134
|
});
|
|
@@ -12013,14 +12138,14 @@ async function resolveInitEnv(root, args, deps) {
|
|
|
12013
12138
|
const name = g.activeEnv;
|
|
12014
12139
|
const config2 = name ? await loadEnv5(name).catch(() => null) : null;
|
|
12015
12140
|
const explicitPaths = " hcm chiron init --env <\u672C\u673A\u73AF\u5883\u540D>\uFF08hcm env list \u770B\u6709\u54EA\u4E9B\uFF09\n hcm chiron init --endpoint <\u540E\u7AEF\u5730\u5740> --tenant <\u79DF\u6237\u53F7>\uFF08\u5B8C\u5168\u663E\u5F0F\uFF0C\u4E0D\u9700\u8981\u5148\u767B\u5F55\uFF09";
|
|
12016
|
-
if (!config2?.endpoint) throw new
|
|
12017
|
-
code:
|
|
12141
|
+
if (!config2?.endpoint) throw new CliError28({
|
|
12142
|
+
code: CliErrorCode29.ENV_NOT_FOUND,
|
|
12018
12143
|
message: "\u6CA1\u8BF4\u8FD9\u4E2A\u9879\u76EE\u5BF9\u7740\u54EA\u4E2A\u73AF\u5883\uFF0C\u672C\u673A\u4E5F\u6CA1\u6709\u53EF\u7528\u7684\u6D3B\u52A8\u73AF\u5883\u3002",
|
|
12019
12144
|
context: { nextStep: `\u4E8C\u9009\u4E00\uFF1A
|
|
12020
12145
|
${explicitPaths}` }
|
|
12021
12146
|
});
|
|
12022
|
-
if (isTempEnv3(name)) throw new
|
|
12023
|
-
code:
|
|
12147
|
+
if (isTempEnv3(name)) throw new CliError28({
|
|
12148
|
+
code: CliErrorCode29.INVALID_ARGUMENT,
|
|
12024
12149
|
message: `\u672C\u673A\u6D3B\u52A8\u73AF\u5883\u662F\u4E34\u65F6\u7684\uFF08${config2.endpoint}\uFF09\uFF0C\u8FD8\u6CA1\u6709\u540D\u5B57\u3002\u9879\u76EE\u8981\u7ED1\u4E00\u4E2A\u7A33\u5B9A\u7684\u73AF\u5883\uFF0C\u5426\u5219\u4E0B\u4E00\u6B21 hcm login --code \u8986\u76D6\u5B83\u4E4B\u540E\uFF0C\u4ED3\u91CC\u8BB0\u7684\u5C31\u5BF9\u4E0D\u4E0A\u4E86\u3002`,
|
|
12025
12150
|
context: { nextStep: `\u5148\u7ED9\u5B83\u8D77\u4E2A\u540D\u5B57\uFF1Ahcm env save <name>\uFF1B\u6216\u76F4\u63A5\u663E\u5F0F\u5EFA\uFF1A
|
|
12026
12151
|
${explicitPaths}` }
|
|
@@ -12028,8 +12153,8 @@ ${explicitPaths}` }
|
|
|
12028
12153
|
const summary = `${name} \xB7 ${config2.endpoint} \xB7 \u79DF\u6237 ${config2.tenantId ?? "1"}`;
|
|
12029
12154
|
if (!args.yes) {
|
|
12030
12155
|
const ok = deps.isTty() && deps.confirm ? await deps.confirm(`\u6CA1\u6307\u5B9A\u73AF\u5883\uFF0C\u7528\u672C\u673A\u5F53\u524D\u6D3B\u52A8\u7684 ${summary} \u5417\uFF1F[y/N] `) : false;
|
|
12031
|
-
if (!ok) throw new
|
|
12032
|
-
code:
|
|
12156
|
+
if (!ok) throw new CliError28({
|
|
12157
|
+
code: CliErrorCode29.INVALID_ARGUMENT,
|
|
12033
12158
|
message: `\u6CA1\u786E\u8BA4\u8981\u7528\u672C\u673A\u6D3B\u52A8\u73AF\u5883\uFF08${summary}\uFF09\u3002\u9879\u76EE\u73AF\u5883\u4F1A\u63D0\u4EA4\u8FDB\u4ED3\u3001\u5F71\u54CD\u6240\u6709\u534F\u4F5C\u8005\uFF0C\u4E0D\u9760\u4E0A\u4E00\u6761\u547D\u4EE4\u7684\u526F\u4F5C\u7528\u51B3\u5B9A\u3002`,
|
|
12034
12159
|
context: { nextStep: `\u786E\u8BA4\u5C31\u52A0 --yes\uFF1B\u6216\u660E\u8BF4\uFF1A
|
|
12035
12160
|
${explicitPaths}` }
|
|
@@ -12045,24 +12170,24 @@ async function scaffoldChironProject(root, env2, envName) {
|
|
|
12045
12170
|
const document2 = parseEnvYaml(existing);
|
|
12046
12171
|
const recorded = Object.values(document2.environments).find((candidate) => candidate.endpoint === env2.endpoint && candidate.tenant === env2.tenant) ?? document2.environments[document2.default];
|
|
12047
12172
|
if (recorded.endpoint !== env2.endpoint) {
|
|
12048
|
-
throw new
|
|
12049
|
-
code:
|
|
12173
|
+
throw new CliError28({
|
|
12174
|
+
code: CliErrorCode29.INVALID_ARGUMENT,
|
|
12050
12175
|
message: `${ENV_FILE} \u6307\u5411 ${recorded.endpoint}\uFF0C\u800C\u4F60\u5F53\u524D\u767B\u5F55\u7684\u662F ${env2.endpoint}\uFF08env '${envName}'\uFF09\u3002
|
|
12051
12176
|
\u8981\u7528\u8FD9\u4E2A\u9879\u76EE\u7684\u73AF\u5883\uFF1Ahcm login ${recorded.endpoint} --code <\u914D\u5BF9\u7801>\uFF0C\u518D\u91CD\u8DD1 hcm chiron init
|
|
12052
12177
|
\u8981\u628A\u9879\u76EE\u6539\u5230\u4F60\u767B\u5F55\u7684\u73AF\u5883\uFF1A\u5220\u6389 ${ENV_FILE} \u540E\u91CD\u8DD1\uFF08\u8FD9\u4F1A\u5F71\u54CD\u6240\u6709\u534F\u4F5C\u8005\uFF0C\u5148\u8DDF\u8D1F\u8D23\u4EBA\u786E\u8BA4\uFF09`
|
|
12053
12178
|
});
|
|
12054
12179
|
}
|
|
12055
12180
|
if (recorded.tenant !== env2.tenant) {
|
|
12056
|
-
throw new
|
|
12057
|
-
code:
|
|
12181
|
+
throw new CliError28({
|
|
12182
|
+
code: CliErrorCode29.INVALID_ARGUMENT,
|
|
12058
12183
|
message: `${ENV_FILE} \u662F\u79DF\u6237 ${recorded.tenant}\uFF0C\u800C\u4F60\u767B\u5F55\u7684\u8EAB\u4EFD\u5C5E\u4E8E\u79DF\u6237 ${env2.tenant}\u3002
|
|
12059
12184
|
\u7528\u9879\u76EE\u79DF\u6237\u7684\u914D\u5BF9\u7801\u91CD\u65B0\u767B\u5F55\uFF1Ahcm login ${env2.endpoint} --code <\u914D\u5BF9\u7801>\uFF0C\u518D\u91CD\u8DD1 hcm chiron init`
|
|
12060
12185
|
});
|
|
12061
12186
|
}
|
|
12062
12187
|
result.preserved.push(ENV_FILE);
|
|
12063
12188
|
} else {
|
|
12064
|
-
if (!envName.trim() || envName.trim() !== envName) throw new
|
|
12065
|
-
code:
|
|
12189
|
+
if (!envName.trim() || envName.trim() !== envName) throw new CliError28({
|
|
12190
|
+
code: CliErrorCode29.INVALID_ARGUMENT,
|
|
12066
12191
|
message: `\u73AF\u5883\u540D '${envName}' \u4E0D\u80FD\u5199\u5165 ${ENV_FILE}\uFF1A\u73AF\u5883\u540D\u5FC5\u987B\u975E\u7A7A\u4E14\u4E0D\u80FD\u542B\u9996\u5C3E\u7A7A\u767D\u3002`,
|
|
12067
12192
|
context: { nextStep: "\u6362\u4E00\u4E2A\u6CA1\u6709\u9996\u5C3E\u7A7A\u767D\u7684\u73AF\u5883\u540D\uFF0C\u518D\u8FD0\u884C hcm chiron init --env <\u73AF\u5883\u540D>\uFF08\u6216 hcm chiron init --endpoint <\u540E\u7AEF\u5730\u5740> --env <\u73AF\u5883\u540D>\uFF09" }
|
|
12068
12193
|
});
|
|
@@ -12075,8 +12200,8 @@ async function scaffoldChironProject(root, env2, envName) {
|
|
|
12075
12200
|
try {
|
|
12076
12201
|
const written = parseEnvYaml(await fs9.readFile(envFile, "utf8"));
|
|
12077
12202
|
if (written.default !== envName || Object.keys(written.environments).length !== 1 || !Object.hasOwn(written.environments, envName)) {
|
|
12078
|
-
throw new
|
|
12079
|
-
code:
|
|
12203
|
+
throw new CliError28({
|
|
12204
|
+
code: CliErrorCode29.CONFIG_PARSE_ERROR,
|
|
12080
12205
|
message: `${ENV_FILE} \u5199\u5165\u540E\u73AF\u5883\u540D\u4E0E\u56DE\u6267 '${envName}' \u4E0D\u4E00\u81F4\u3002`,
|
|
12081
12206
|
context: { nextStep: `\u6838\u5BF9 ${ENV_FILE} \u7684 default \u4E0E environments \u952E\uFF0C\u518D\u91CD\u8DD1 hcm chiron init` }
|
|
12082
12207
|
});
|
|
@@ -12154,7 +12279,7 @@ async function chironInitCommand(args, deps) {
|
|
|
12154
12279
|
const result = await runChironInit(args, deps);
|
|
12155
12280
|
const fmt = args.output ?? "table";
|
|
12156
12281
|
if (fmt === "json" || fmt === "yaml") {
|
|
12157
|
-
process.stdout.write(
|
|
12282
|
+
process.stdout.write(formatObject25(result, { format: fmt }) + "\n");
|
|
12158
12283
|
} else {
|
|
12159
12284
|
const mark = { verified: "\u2705", mismatch: "\u274C", unreachable: "\u26A0\uFE0F", skipped: "\xB7" }[result.tenantCheck.status];
|
|
12160
12285
|
process.stdout.write(
|
|
@@ -12176,9 +12301,9 @@ async function chironInitCommand(args, deps) {
|
|
|
12176
12301
|
// src/commands/gap.ts
|
|
12177
12302
|
import { readFileSync as readFileSync6 } from "fs";
|
|
12178
12303
|
import {
|
|
12179
|
-
CliErrorCode as
|
|
12304
|
+
CliErrorCode as CliErrorCode31,
|
|
12180
12305
|
createHttpClient as createHttpClient4,
|
|
12181
|
-
formatObject as
|
|
12306
|
+
formatObject as formatObject26,
|
|
12182
12307
|
loadGlobalConfig as loadGlobalConfig10,
|
|
12183
12308
|
resolveEnvContext as resolveEnvContext7,
|
|
12184
12309
|
printResolvedEnvironment as printResolvedEnvironment7,
|
|
@@ -12578,8 +12703,8 @@ async function gapComments({ client: client3 }, ref, { limit } = {}, casesSlug =
|
|
|
12578
12703
|
// src/jira/gap-verify.ts
|
|
12579
12704
|
import {
|
|
12580
12705
|
CASES_REPO_SLUG as CASES_REPO_SLUG3,
|
|
12581
|
-
CliError as
|
|
12582
|
-
CliErrorCode as
|
|
12706
|
+
CliError as CliError29,
|
|
12707
|
+
CliErrorCode as CliErrorCode30,
|
|
12583
12708
|
JiraHttpError,
|
|
12584
12709
|
JiraNonBmpContentError,
|
|
12585
12710
|
NON_BMP_RULE_NOTE,
|
|
@@ -12600,14 +12725,14 @@ var VERIFY_PLAN = {
|
|
|
12600
12725
|
function parseVerifyResult(raw) {
|
|
12601
12726
|
const v = String(raw ?? "").trim().toLowerCase();
|
|
12602
12727
|
if (VERIFY_RESULTS.includes(v)) return v;
|
|
12603
|
-
throw new
|
|
12604
|
-
code: raw === void 0 ?
|
|
12728
|
+
throw new CliError29({
|
|
12729
|
+
code: raw === void 0 ? CliErrorCode30.MISSING_FLAG : CliErrorCode30.INVALID_ARGUMENT,
|
|
12605
12730
|
message: `--result \u53EA\u80FD\u662F pass / fail / partial\uFF0C\u7ED9\u7684\u662F\u300C${raw ?? "\uFF08\u6CA1\u7ED9\uFF09"}\u300D`,
|
|
12606
12731
|
context: { nextStep: "pass = \u539F\u6545\u969C\u5728\u76EE\u6807\u73AF\u5883\u4E0D\u518D\u51FA\u73B0\uFF1Bfail = \u4ECD\u7136\u590D\u73B0\u6216\u9A8C\u51FA\u6CA1\u901A\u8FC7\u7684\uFF1Bpartial = \u53EA\u9A8C\u4E86\u4E00\u90E8\u5206\u3001\u9A8C\u8FC7\u7684\u90FD\u901A\u8FC7\uFF08\u4E0D\u5173\u5355\uFF09\u3002" }
|
|
12607
12732
|
});
|
|
12608
12733
|
}
|
|
12609
12734
|
function verifyFailure(reasonCode, code2, written, message, nextStep, extra = {}, cause) {
|
|
12610
|
-
return new
|
|
12735
|
+
return new CliError29({ code: code2, message: `${message}${WRITTEN_TAG[written]}`, context: { reasonCode, written, nextStep, ...extra }, cause });
|
|
12611
12736
|
}
|
|
12612
12737
|
function who(u) {
|
|
12613
12738
|
if (!u) return "\uFF08\u5355\u4E0A\u6CA1\u6709\uFF09";
|
|
@@ -12695,7 +12820,7 @@ function writeFailure(e, key2, what) {
|
|
|
12695
12820
|
if (e instanceof JiraNonBmpContentError) {
|
|
12696
12821
|
return verifyFailure(
|
|
12697
12822
|
"non-bmp-content",
|
|
12698
|
-
|
|
12823
|
+
CliErrorCode30.INVALID_ARGUMENT,
|
|
12699
12824
|
"no",
|
|
12700
12825
|
`\u8FD9\u6B21${what}\u4E00\u4E2A\u5B57\u90FD\u6CA1\u53D1\u51FA\u53BB\uFF1A\u6B63\u6587\u91CC\u6709 ${e.hits.length} \u5904 Jira \u5B58\u4E0D\u4E0B\u7684\u5B57\u7B26`,
|
|
12701
12826
|
// 🔴 清单落 nextStep,不落 cause:CliError 渲染 cause 时 formatCause 截到 300 字,
|
|
@@ -12706,7 +12831,7 @@ ${nonBmpHitLines(e.hits)}`,
|
|
|
12706
12831
|
);
|
|
12707
12832
|
}
|
|
12708
12833
|
if (e instanceof JiraHttpError && e.status >= 400 && e.status < 500) {
|
|
12709
|
-
return verifyFailure("write-rejected",
|
|
12834
|
+
return verifyFailure("write-rejected", CliErrorCode30.BUSINESS_RULE_VIOLATION, "no", `Jira \u4EE5 ${e.status} \u62D2\u7EDD\u4E86\u8FD9\u6B21${what}`, rejectNextStep(e.status, key2), {
|
|
12710
12835
|
key: key2,
|
|
12711
12836
|
status: e.status,
|
|
12712
12837
|
details: e.message
|
|
@@ -12714,7 +12839,7 @@ ${nonBmpHitLines(e.hits)}`,
|
|
|
12714
12839
|
}
|
|
12715
12840
|
return verifyFailure(
|
|
12716
12841
|
"write-unconfirmed",
|
|
12717
|
-
|
|
12842
|
+
CliErrorCode30.NETWORK_ERROR,
|
|
12718
12843
|
"unknown",
|
|
12719
12844
|
`${what}\u8BF7\u6C42\u6CA1\u5F97\u5230\u786E\u8BA4\uFF08${unconfirmedWhy(e)}\uFF09`,
|
|
12720
12845
|
`\u5148\u7528 \`hcm chiron gap status ${key2}\` \u4E0E \`hcm chiron gap comments ${key2}\` \u6838\u5BF9\u5199\u8FDB\u53BB\u6CA1\u6709\uFF0C\u518D\u51B3\u5B9A\u8981\u4E0D\u8981\u91CD\u8DD1\u2014\u2014partial \u91CD\u8DD1\u4F1A\u591A\u4E00\u6761\u8BC4\u8BBA\u3002`,
|
|
@@ -12737,7 +12862,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
|
|
|
12737
12862
|
if (!parsed || parsed.kind !== "jira") {
|
|
12738
12863
|
throw verifyFailure(
|
|
12739
12864
|
"not-jira-key",
|
|
12740
|
-
|
|
12865
|
+
CliErrorCode30.INVALID_ARGUMENT,
|
|
12741
12866
|
"no",
|
|
12742
12867
|
parsed && parsed.kind === "repo" ? `${parsed.repo}#${parsed.number} \u662F\u4EA7\u54C1\u4ED3\u7F16\u53F7\uFF0C\u9A8C\u6536\u8981\u843D\u5728 Jira \u5355\u4E0A` : `\u770B\u4E0D\u61C2 ${ref}`,
|
|
12743
12868
|
"\u7ED9 Jira \u5355\u53F7\uFF08HCMNX-12 \u6216\u88F8\u6570\u5B57 12\uFF09\u2014\u2014\u5C31\u662F `hcm chiron gap submit` \u56DE\u6267\u91CC\u7684\u90A3\u4E2A\u7F16\u53F7\u3002"
|
|
@@ -12747,7 +12872,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
|
|
|
12747
12872
|
const inProject = (k) => k.startsWith(`${client3.project}-`);
|
|
12748
12873
|
const wrongProject = (k) => verifyFailure(
|
|
12749
12874
|
"wrong-project",
|
|
12750
|
-
|
|
12875
|
+
CliErrorCode30.INVALID_ARGUMENT,
|
|
12751
12876
|
"no",
|
|
12752
12877
|
`${k} \u4E0D\u5728 ${client3.project} \u9879\u76EE\u91CC\uFF0C\u9A8C\u6536\u53EA\u5199 ${client3.project} \u7684\u5355`,
|
|
12753
12878
|
`\u7ED9 ${client3.project} \u7684\u5355\u53F7\uFF08\`hcm chiron gap submit\` \u56DE\u6267\u91CC\u7684\u90A3\u4E2A\uFF09\u3002\u522B\u7684\u9879\u76EE\u7684\u5355\u8FD9\u6761\u547D\u4EE4\u4E0D\u78B0\u2014\u2014\u90A3\u91CC\u7684\u72B6\u6001\u540D\u4E0E\u6D41\u8F6C\u540D\u548C ${client3.project} \u540C\u5F62\uFF0C\u5199\u9519\u4E86\u4F1A\u628A\u522B\u5904\u7684\u5355\u5173\u6389\u3002`,
|
|
@@ -12758,7 +12883,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
|
|
|
12758
12883
|
if (evidence.length < EVIDENCE_MIN) {
|
|
12759
12884
|
throw verifyFailure(
|
|
12760
12885
|
"evidence-too-short",
|
|
12761
|
-
|
|
12886
|
+
CliErrorCode30.INVALID_ARGUMENT,
|
|
12762
12887
|
"no",
|
|
12763
12888
|
`\u9A8C\u6536\u8BC1\u636E\u81F3\u5C11 ${EVIDENCE_MIN} \u4E2A\u5B57\uFF0C\u7ED9\u7684\u662F ${evidence.length} \u4E2A\u5B57`,
|
|
12764
12889
|
"\u5199\u6E05\uFF1A\u54EA\u4E2A\u73AF\u5883\u3001\u54EA\u4E2A\u7248\u672C\uFF08`hcm version`\uFF09\u3001\u6309\u6280\u80FD\u8DD1\u4E86\u4EC0\u4E48\u3001\u770B\u5230\u4E86\u4EC0\u4E48\uFF1B\u8BC1\u636E\u6587\u4EF6\u653E\u5728 evidence/ \u4E0B\u5E76\u5199\u4E0A\u8DEF\u5F84\u3002",
|
|
@@ -12784,7 +12909,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
|
|
|
12784
12909
|
if (!sameUser(reporter, me)) {
|
|
12785
12910
|
throw verifyFailure(
|
|
12786
12911
|
"not-reporter",
|
|
12787
|
-
|
|
12912
|
+
CliErrorCode30.BUSINESS_RULE_VIOLATION,
|
|
12788
12913
|
"no",
|
|
12789
12914
|
`\u53EA\u6709\u63D0\u5355\u4EBA\u80FD\u9A8C\u6536 ${key2}\uFF1A\u63D0\u5355\u4EBA\u662F ${who(reporter)}\uFF0C\u5F53\u524D\u8EAB\u4EFD\u662F ${who(me)}`,
|
|
12790
12915
|
"\u8BF7\u63D0\u5355\u4EBA\u590D\u9A8C\u540E\u81EA\u5DF1\u8DD1\u8FD9\u6761\u547D\u4EE4\u3002\u4F60\u624B\u4E0A\u7684\u65B0\u73B0\u573A\u7528 `hcm chiron gap submit` \u8FFD\u52A0\uFF1B\u7ECF\u529E\u4EBA\u3001\u641C\u7D22\u547D\u4E2D\u3001\u5728\u522B\u4EBA\u7684\u5355\u4E0B\u8FFD\u52A0\u8FC7\u73B0\u573A\u90FD\u4E0D\u6784\u6210\u9A8C\u6536\u8D44\u683C\u3002",
|
|
@@ -12798,7 +12923,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
|
|
|
12798
12923
|
if (status !== FIXED_STATUS) {
|
|
12799
12924
|
throw verifyFailure(
|
|
12800
12925
|
"status-not-fixed",
|
|
12801
|
-
|
|
12926
|
+
CliErrorCode30.BUSINESS_RULE_VIOLATION,
|
|
12802
12927
|
"no",
|
|
12803
12928
|
`${key2} \u7684\u72B6\u6001\u662F\u300C${status ?? "?"}\u300D\uFF0C\u9A8C\u6536\u53EA\u5728\u300C${FIXED_STATUS}\u300D\u4E0A\u505A`,
|
|
12804
12929
|
notFixedNextStep(key2, status, o.result),
|
|
@@ -12824,7 +12949,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
|
|
|
12824
12949
|
} else if (o.fingerprint.revision < fixRevision) {
|
|
12825
12950
|
const environmentRevision = o.fingerprint.revision;
|
|
12826
12951
|
const message = `\u73AF\u5883\u5C1A\u672A\u5305\u542B\u4FEE\u590D\uFF08\u5F53\u524D r${environmentRevision} < \u4FEE\u590D r${fixRevision}\uFF09\uFF0C\u8BF7\u7B49\u90E8\u7F72\u540E\u590D\u9A8C\uFF1B\u81EA\u67E5 curl <env>/api/version/backend`;
|
|
12827
|
-
throw verifyFailure("env-behind-fix",
|
|
12952
|
+
throw verifyFailure("env-behind-fix", CliErrorCode30.BUSINESS_RULE_VIOLATION, "no", message, message, { key: key2, fixRevision, environmentRevision });
|
|
12828
12953
|
} else {
|
|
12829
12954
|
const environmentRevision = o.fingerprint.revision;
|
|
12830
12955
|
versionComparison = { status: "passed", text: `\u7248\u672C\u6BD4\u5BF9\uFF1A\u73AF\u5883 r${environmentRevision} \u2265 \u4FEE\u590D r${fixRevision}`, fixRevision, environmentRevision };
|
|
@@ -12842,7 +12967,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
|
|
|
12842
12967
|
const available = list.map((t) => `${t.name}\u2192${t.to?.name ?? "?"}`);
|
|
12843
12968
|
throw verifyFailure(
|
|
12844
12969
|
"transition-unavailable",
|
|
12845
|
-
|
|
12970
|
+
CliErrorCode30.BUSINESS_RULE_VIOLATION,
|
|
12846
12971
|
"no",
|
|
12847
12972
|
`${key2} \u4E0A\u670D\u52A1\u7AEF\u6B64\u523B\u4E0D\u7ED9\u300C${want.name}\u2192${want.to}\u300D\u8FD9\u6761\u6D41\u8F6C\uFF08\u53EF\u7528\uFF1A${available.join(" / ") || "\uFF08\u65E0\uFF09"}\uFF09`,
|
|
12848
12973
|
"\u591A\u534A\u662F\u5DE5\u4F5C\u6D41\u88AB\u6539\u8FC7\uFF0C\u6216\u4F60\u7684\u8D26\u53F7\u5728\u8FD9\u4E2A\u9879\u76EE\u4E0A\u6CA1\u6709\u8FD9\u6761\u6D41\u8F6C\u7684\u6743\u9650\u3002\u628A\u8FD9\u6BB5\u8F93\u51FA\u53D1\u7ED9\u4EA7\u54C1\u4FA7\u5206\u8BCA\u4EBA\uFF1B\u522B\u81EA\u5DF1\u62FC HTTP\uFF0C\u4E5F\u522B\u6539\u95EE\u9898\u7C7B\u578B\u7ED5\u8FC7\u3002",
|
|
@@ -12854,7 +12979,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
|
|
|
12854
12979
|
else if (req.missing.length) {
|
|
12855
12980
|
throw verifyFailure(
|
|
12856
12981
|
"required-fields-missing",
|
|
12857
|
-
|
|
12982
|
+
CliErrorCode30.BUSINESS_RULE_VIOLATION,
|
|
12858
12983
|
"no",
|
|
12859
12984
|
`\u300C${transition.name}\u300D\u8981\u6C42\u8FD9\u4E9B\u5B57\u6BB5\u6709\u503C\uFF0C${key2} \u4E0A\u662F\u7A7A\u7684\uFF1A${req.missing.join("\u3001")}`,
|
|
12860
12985
|
"\u8FD9\u4E9B\u5B57\u6BB5\u7531\u4EA7\u54C1\u4FA7\u7EF4\u62A4\uFF0C\u8BF7\u5206\u8BCA\u4EBA\u8865\u9F50\u540E\u518D\u8DD1\uFF1BCLI \u4E0D\u4EE3\u586B\uFF0C\u4E5F\u522B\u628A\u7ECF\u529E\u4EBA\u6216\u4FEE\u590D\u4EBA\u731C\u6210 Bug\u5F15\u5165\u4EBA\u3002",
|
|
@@ -12896,7 +13021,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
|
|
|
12896
13021
|
} catch (e) {
|
|
12897
13022
|
throw verifyFailure(
|
|
12898
13023
|
"readback-failed",
|
|
12899
|
-
|
|
13024
|
+
CliErrorCode30.NETWORK_ERROR,
|
|
12900
13025
|
"yes",
|
|
12901
13026
|
`${what}\u5DF2\u88AB Jira \u63A5\u53D7\uFF0C\u4F46\u56DE\u8BFB ${key2} \u5931\u8D25\uFF0C\u843D\u5230\u4EC0\u4E48\u72B6\u6001\u6CA1\u786E\u8BA4`,
|
|
12902
13027
|
`\u7528 \`hcm chiron gap status ${key2}\` \u770B\u7ED3\u679C\uFF1B\u522B\u76F4\u63A5\u91CD\u8DD1\uFF08\u4F1A\u518D\u5199\u4E00\u6761\u8BC4\u8BBA\uFF09\u3002`,
|
|
@@ -12910,7 +13035,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
|
|
|
12910
13035
|
const did = plan.outcome === "closed" ? "\u5173\u5355" : "\u9000\u56DE";
|
|
12911
13036
|
throw verifyFailure(
|
|
12912
13037
|
"readback-mismatch",
|
|
12913
|
-
|
|
13038
|
+
CliErrorCode30.SERVER_ERROR,
|
|
12914
13039
|
"yes",
|
|
12915
13040
|
after2.status !== expected ? `${what}\u5DF2\u88AB Jira \u63A5\u53D7\uFF0C\u4F46\u56DE\u8BFB ${key2} \u7684\u72B6\u6001\u662F\u300C${after2.status ?? "?"}\u300D\uFF0C\u9884\u671F\u300C${expected}\u300D` : `${what}\u5DF2\u88AB Jira \u63A5\u53D7\uFF0C${key2} \u56DE\u5230\u4E86\u300C${expected}\u300D\uFF0C\u4F46 resolution \u8FD8\u662F\u300C${after2.resolution}\u300D\u2014\u2014\u5B83\u4F1A\u4ECE\u300C\u672A\u89E3\u51B3\u300D\u7684\u67E5\u8BE2\u91CC\u6D88\u5931`,
|
|
12916
13041
|
after2.status !== expected ? `\u4EE5 \`hcm chiron gap status ${key2}\` \u4E3A\u51C6\uFF0C\u522B\u5F53\u6210\u5DF2\u7ECF${did}\uFF1B\u628A\u8FD9\u6BB5\u8F93\u51FA\u53D1\u7ED9\u4EA7\u54C1\u4FA7\u5206\u8BCA\u4EBA\u3002` : "\u8BF7\u4EA7\u54C1\u4FA7\u5206\u8BCA\u4EBA\u6E05\u6389\u8FD9\u5355\u7684 resolution\uFF08\u300C\u672A\u89E3\u51B3\u300D\u8FD9\u6761\u6D41\u8F6C\u672C\u6765\u4F1A\u6E05\uFF0C\u6CA1\u6E05\u8BF4\u660E\u5DE5\u4F5C\u6D41\u88AB\u6539\u8FC7\uFF09\uFF1B\u628A\u8FD9\u6BB5\u8F93\u51FA\u53D1\u7ED9\u4ED6\u3002",
|
|
@@ -12942,7 +13067,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
|
|
|
12942
13067
|
} catch (e) {
|
|
12943
13068
|
throw verifyFailure(
|
|
12944
13069
|
"readback-failed",
|
|
12945
|
-
|
|
13070
|
+
CliErrorCode30.NETWORK_ERROR,
|
|
12946
13071
|
"yes",
|
|
12947
13072
|
`\u8BC4\u8BBA\u5DF2\u88AB Jira \u63A5\u53D7\uFF0C\u4F46\u56DE\u8BFB ${key2} \u7684\u8BC4\u8BBA\u5931\u8D25\uFF0C\u6CA1\u786E\u8BA4\u5B83\u5728`,
|
|
12948
13073
|
`\u7528 \`hcm chiron gap comments ${key2}\` \u770B\u5B83\u5728\u4E0D\u5728\uFF1B\u522B\u76F4\u63A5\u91CD\u8DD1\uFF08\u4F1A\u518D\u5199\u4E00\u6761\uFF09\u3002`,
|
|
@@ -12956,7 +13081,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
|
|
|
12956
13081
|
} else if (!listed.some((c2) => c2.id === written.id)) {
|
|
12957
13082
|
throw verifyFailure(
|
|
12958
13083
|
"readback-mismatch",
|
|
12959
|
-
|
|
13084
|
+
CliErrorCode30.SERVER_ERROR,
|
|
12960
13085
|
"yes",
|
|
12961
13086
|
`Jira \u56DE\u4E86\u8BC4\u8BBA ${written.id}\uFF0C\u4F46\u56DE\u8BFB ${key2} \u7684\u8BC4\u8BBA\u91CC\u6CA1\u6709\u5B83`,
|
|
12962
13087
|
`\u7528 \`hcm chiron gap comments ${key2}\` \u6838\u5BF9\uFF1B\u522B\u76F4\u63A5\u91CD\u8DD1\uFF0C\u628A\u8FD9\u6BB5\u8F93\u51FA\u53D1\u7ED9\u4EA7\u54C1\u4FA7\u5206\u8BCA\u4EBA\u3002`,
|
|
@@ -12993,7 +13118,7 @@ async function gapDeps(deps) {
|
|
|
12993
13118
|
return { client: await deps.client() };
|
|
12994
13119
|
}
|
|
12995
13120
|
function emit5(fmt, data, text) {
|
|
12996
|
-
if (fmt === "json" || fmt === "yaml") process.stdout.write(
|
|
13121
|
+
if (fmt === "json" || fmt === "yaml") process.stdout.write(formatObject26(data, { format: fmt }) + "\n");
|
|
12997
13122
|
else process.stdout.write(text() + "\n");
|
|
12998
13123
|
}
|
|
12999
13124
|
async function run2(fn) {
|
|
@@ -13098,7 +13223,7 @@ function readEvidence(opts, stdinIsTTY = !!process.stdin.isTTY, readStdin2 = ()
|
|
|
13098
13223
|
if (opts.file !== void 0 && opts.body !== void 0) {
|
|
13099
13224
|
throw verifyFailure(
|
|
13100
13225
|
"evidence-ambiguous",
|
|
13101
|
-
|
|
13226
|
+
CliErrorCode31.INVALID_ARGUMENT,
|
|
13102
13227
|
"no",
|
|
13103
13228
|
"--body \u4E0E --file \u540C\u65F6\u7ED9\u4E86\uFF0C\u4E0D\u77E5\u9053\u8BE5\u7528\u54EA\u4EFD\u505A\u9A8C\u6536\u8BC1\u636E",
|
|
13104
13229
|
"\u53EA\u7559\u4E00\u4E2A\uFF1A\u77ED\u8BC1\u636E\u7528 --body\uFF0C\u957F\u8BC1\u636E\u5199\u8FDB\u6587\u4EF6\u7528 --file\u3002"
|
|
@@ -13110,7 +13235,7 @@ function readEvidence(opts, stdinIsTTY = !!process.stdin.isTTY, readStdin2 = ()
|
|
|
13110
13235
|
} catch (e) {
|
|
13111
13236
|
throw verifyFailure(
|
|
13112
13237
|
"evidence-unreadable",
|
|
13113
|
-
|
|
13238
|
+
CliErrorCode31.INVALID_ARGUMENT,
|
|
13114
13239
|
"no",
|
|
13115
13240
|
`\u8BFB\u4E0D\u5230\u8BC1\u636E\u6587\u4EF6 ${opts.file}`,
|
|
13116
13241
|
"\u6838\u5BF9\u8DEF\u5F84\u4E0E\u6743\u9650\uFF1B\u8BC1\u636E\u6587\u4EF6\u4E00\u822C\u653E\u5728\u9879\u76EE\u4ED3\u7684 evidence/ \u4E0B\u3002",
|
|
@@ -13123,7 +13248,7 @@ function readEvidence(opts, stdinIsTTY = !!process.stdin.isTTY, readStdin2 = ()
|
|
|
13123
13248
|
if (stdinIsTTY) {
|
|
13124
13249
|
throw verifyFailure(
|
|
13125
13250
|
"evidence-missing",
|
|
13126
|
-
|
|
13251
|
+
CliErrorCode31.INVALID_ARGUMENT,
|
|
13127
13252
|
"no",
|
|
13128
13253
|
"\u6CA1\u7ED9\u9A8C\u6536\u8BC1\u636E",
|
|
13129
13254
|
"\u7528 --body <\u6587\u672C> \u6216 --file <\u6587\u4EF6> \u7ED9\u51FA\uFF1A\u54EA\u4E2A\u73AF\u5883\u3001\u54EA\u4E2A\u7248\u672C\u3001\u6309\u6280\u80FD\u8DD1\u4E86\u4EC0\u4E48\u3001\u770B\u5230\u4E86\u4EC0\u4E48\u3002"
|
|
@@ -13180,11 +13305,11 @@ async function gapVerifyCommand(ref, args, deps = defaultDeps) {
|
|
|
13180
13305
|
init_auth_guard();
|
|
13181
13306
|
import { promises as fs12 } from "fs";
|
|
13182
13307
|
import path14 from "path";
|
|
13183
|
-
import
|
|
13308
|
+
import axios10 from "axios";
|
|
13184
13309
|
import {
|
|
13185
|
-
CliError as
|
|
13186
|
-
CliErrorCode as
|
|
13187
|
-
formatObject as
|
|
13310
|
+
CliError as CliError34,
|
|
13311
|
+
CliErrorCode as CliErrorCode35,
|
|
13312
|
+
formatObject as formatObject29,
|
|
13188
13313
|
httpProbe as httpProbe2,
|
|
13189
13314
|
listEnvs as listEnvs2,
|
|
13190
13315
|
loadGlobalConfig as loadGlobalConfig12,
|
|
@@ -13206,12 +13331,12 @@ import yaml from "js-yaml";
|
|
|
13206
13331
|
import {
|
|
13207
13332
|
AUTH_INFO_PATH as AUTH_INFO_PATH2,
|
|
13208
13333
|
assertNotReservedEnvName as assertNotReservedEnvName3,
|
|
13209
|
-
CliError as
|
|
13210
|
-
CliErrorCode as
|
|
13334
|
+
CliError as CliError30,
|
|
13335
|
+
CliErrorCode as CliErrorCode32,
|
|
13211
13336
|
discoverProjectEnv as discoverProjectEnv6,
|
|
13212
13337
|
ENV_FILE as ENV_FILE2,
|
|
13213
13338
|
findEnvByEndpoint as findEnvByEndpoint5,
|
|
13214
|
-
formatObject as
|
|
13339
|
+
formatObject as formatObject27,
|
|
13215
13340
|
listIdentities as listIdentities6,
|
|
13216
13341
|
parseEnvYaml as parseEnvYaml2,
|
|
13217
13342
|
renderEnvYaml as renderEnvYaml2,
|
|
@@ -13230,7 +13355,7 @@ function summarizeReasons(reasons) {
|
|
|
13230
13355
|
return reasons.length === 1 ? reasons[0] : `${reasons[0]} \u7B49 ${reasons.length} \u6761\uFF08--output json \u770B\u5168\u90E8\uFF09`;
|
|
13231
13356
|
}
|
|
13232
13357
|
function invalid2(message, nextStep) {
|
|
13233
|
-
throw new
|
|
13358
|
+
throw new CliError30({ code: CliErrorCode32.INVALID_ARGUMENT, message, context: { nextStep } });
|
|
13234
13359
|
}
|
|
13235
13360
|
function required(value, label) {
|
|
13236
13361
|
if (!value?.trim()) invalid2(`${label} \u4E0D\u80FD\u4E3A\u7A7A\uFF1B\u914D\u7F6E\u672A\u5199\u5165\u3002`, `\u8BF7\u63D0\u4F9B\u975E\u7A7A\u7684 ${label}`);
|
|
@@ -13417,7 +13542,7 @@ async function runChironEnv(action, args = {}) {
|
|
|
13417
13542
|
return report;
|
|
13418
13543
|
}
|
|
13419
13544
|
function formatChironEnvReport(report, output = "table") {
|
|
13420
|
-
if (output !== "table") return
|
|
13545
|
+
if (output !== "table") return formatObject27(report, { format: output });
|
|
13421
13546
|
const lines = [
|
|
13422
13547
|
report.action === "list" ? `\u9879\u76EE\u73AF\u5883\uFF1A${report.path}` : `\u5DF2\u5199\u5165\uFF1A${report.path}`,
|
|
13423
13548
|
formatTable(report.environments.map((env2) => ({
|
|
@@ -13454,8 +13579,8 @@ import os5 from "os";
|
|
|
13454
13579
|
import path12 from "path";
|
|
13455
13580
|
import yaml2 from "js-yaml";
|
|
13456
13581
|
import {
|
|
13457
|
-
CliError as
|
|
13458
|
-
CliErrorCode as
|
|
13582
|
+
CliError as CliError31,
|
|
13583
|
+
CliErrorCode as CliErrorCode33,
|
|
13459
13584
|
METHOD_REPO_DISPLAY,
|
|
13460
13585
|
METHOD_REPO_URL,
|
|
13461
13586
|
assertSafeSkillId as assertSafeSkillId2,
|
|
@@ -13463,7 +13588,7 @@ import {
|
|
|
13463
13588
|
discoverProjectEnv as discoverProjectEnv7,
|
|
13464
13589
|
fetchSkillCatalog as fetchSkillCatalog2,
|
|
13465
13590
|
flattenSkills as flattenSkills2,
|
|
13466
|
-
formatObject as
|
|
13591
|
+
formatObject as formatObject28,
|
|
13467
13592
|
parseSkillFrontmatter as parseSkillFrontmatter3,
|
|
13468
13593
|
resolveChironBase as resolveChironBase2
|
|
13469
13594
|
} from "@hcmai/sdk";
|
|
@@ -13496,8 +13621,8 @@ function gitErrorText(e) {
|
|
|
13496
13621
|
function classifyGitFailure(e, repoDisplay) {
|
|
13497
13622
|
const err = e;
|
|
13498
13623
|
if (err.code === "ENOENT") {
|
|
13499
|
-
return new
|
|
13500
|
-
code:
|
|
13624
|
+
return new CliError31({
|
|
13625
|
+
code: CliErrorCode33.METHOD_GIT_UNAVAILABLE,
|
|
13501
13626
|
message: "\u672C\u673A\u627E\u4E0D\u5230 git\uFF0C\u53D6\u65B9\u6CD5\u5305\u9760\u5B83",
|
|
13502
13627
|
context: { nextStep: "\u88C5\u4E0A git\uFF08`git --version` \u80FD\u8DD1\u901A\uFF09\uFF0C\u518D\u91CD\u8DD1\u8FD9\u6761\u547D\u4EE4" }
|
|
13503
13628
|
});
|
|
@@ -13505,15 +13630,15 @@ function classifyGitFailure(e, repoDisplay) {
|
|
|
13505
13630
|
const text = gitErrorText(e);
|
|
13506
13631
|
const head = text.split("\n").filter(Boolean).slice(-3).join(" / ").slice(0, 400);
|
|
13507
13632
|
if (err.code === "ETIMEDOUT" || err.signal === "SIGTERM") {
|
|
13508
|
-
return new
|
|
13509
|
-
code:
|
|
13633
|
+
return new CliError31({
|
|
13634
|
+
code: CliErrorCode33.METHOD_SOURCE_NETWORK,
|
|
13510
13635
|
message: `git \u5728\u65F6\u9650\u5185\u6CA1\u6709\u8FD4\u56DE\uFF08${repoDisplay}\uFF09`,
|
|
13511
13636
|
context: { nextStep: "\u67E5\u7F51\u7EDC\u6216\u4EE3\u7406\u540E\u91CD\u8DD1\uFF1B\u5DF2\u88C5\u7684\u65B9\u6CD5\u5305\u79BB\u7EBF\u53EF\u8BFB\uFF0C`hcm chiron method status` \u7167\u5E38\u80FD\u7528" }
|
|
13512
13637
|
});
|
|
13513
13638
|
}
|
|
13514
13639
|
if (/could not read Username|Authentication failed|terminal prompts disabled|returned error: 401|HTTP Basic: Access denied|invalid credentials|Permission denied \(publickey/i.test(text)) {
|
|
13515
|
-
return new
|
|
13516
|
-
code:
|
|
13640
|
+
return new CliError31({
|
|
13641
|
+
code: CliErrorCode33.METHOD_SOURCE_AUTH_REQUIRED,
|
|
13517
13642
|
message: `\u65B9\u6CD5\u8BBA\u4ED3\u8981\u8BA4\u8BC1\uFF0C\u672C\u673A\u6CA1\u6709\u53EF\u7528\u7684 git \u51ED\u636E\uFF08${repoDisplay}\uFF09\uFF1A${head}`,
|
|
13518
13643
|
context: { nextStep: "`cnb login` \u4E4B\u540E\u91CD\u8DD1\u3002\u65B9\u6CD5\u5305\u8D70\u7684\u662F git \u51ED\u636E\uFF0C\u4E0D\u662F `hcm login`" }
|
|
13519
13644
|
});
|
|
@@ -13521,8 +13646,8 @@ function classifyGitFailure(e, repoDisplay) {
|
|
|
13521
13646
|
const notFound = /returned error: 404|Repository not found|repository '.*' not found|does not appear to be a git repository/i.test(text);
|
|
13522
13647
|
if (/returned error: 403|403 Forbidden|access denied|not authorized/i.test(text) || notFound) {
|
|
13523
13648
|
const overridden = Boolean(process.env.HCM_METHOD_REPO?.trim() || process.env.HCM_METHOD_REPO_URL?.trim());
|
|
13524
|
-
return new
|
|
13525
|
-
code:
|
|
13649
|
+
return new CliError31({
|
|
13650
|
+
code: CliErrorCode33.METHOD_SOURCE_FORBIDDEN,
|
|
13526
13651
|
message: `\u51ED\u636E\u6709\u6548\u4F46\u8BFB\u4E0D\u5230\u65B9\u6CD5\u8BBA\u4ED3 ${repoDisplay}\uFF1A${head}` + (notFound ? "\uFF08\u8FDC\u7AEF\u5BF9\u65E0\u6743\u8BBF\u95EE\u7684\u79C1\u6709\u4ED3\u4E5F\u53EF\u80FD\u56DE 404\uFF0C\u6240\u4EE5\u8FD9\u91CC\u4E0D\u628A\u5B83\u5224\u6210\u300C\u4ED3\u4E0D\u5B58\u5728\u300D\uFF09" : ""),
|
|
13527
13652
|
context: {
|
|
13528
13653
|
nextStep: "\u627E\u77E5\u8BC6\u7EC4\u7EC7\u7BA1\u7406\u5458\u628A\u4F60\u52A0\u8FDB\u65B9\u6CD5\u8BBA\u4ED3\uFF08\u8981\u4EE3\u7801\u8BFB\u6743\u9650\uFF09" + (overridden ? "\uFF1B\u4F60\u8BBE\u4E86 HCM_METHOD_REPO / HCM_METHOD_REPO_URL\uFF0C\u5148\u6838\u5BF9\u62FC\u5199" : "")
|
|
@@ -13530,14 +13655,14 @@ function classifyGitFailure(e, repoDisplay) {
|
|
|
13530
13655
|
});
|
|
13531
13656
|
}
|
|
13532
13657
|
if (/Could not resolve host|Failed to connect|Connection refused|Connection timed out|Operation timed out|Network is unreachable|Could not connect|SSL|TLS|timed out/i.test(text)) {
|
|
13533
|
-
return new
|
|
13534
|
-
code:
|
|
13658
|
+
return new CliError31({
|
|
13659
|
+
code: CliErrorCode33.METHOD_SOURCE_NETWORK,
|
|
13535
13660
|
message: `\u8FDE\u4E0D\u4E0A\u65B9\u6CD5\u8BBA\u4ED3\uFF08${repoDisplay}\uFF09\uFF1A${head}`,
|
|
13536
13661
|
context: { nextStep: "\u67E5\u7F51\u7EDC\u6216\u4EE3\u7406\u540E\u91CD\u8DD1\uFF1B\u5DF2\u88C5\u7684\u65B9\u6CD5\u5305\u79BB\u7EBF\u53EF\u8BFB\uFF0C`hcm chiron method status` \u7167\u5E38\u80FD\u7528" }
|
|
13537
13662
|
});
|
|
13538
13663
|
}
|
|
13539
|
-
return new
|
|
13540
|
-
code:
|
|
13664
|
+
return new CliError31({
|
|
13665
|
+
code: CliErrorCode33.METHOD_SOURCE_GIT_FAILED,
|
|
13541
13666
|
message: `git \u5931\u8D25\u4E86\uFF0C\u539F\u56E0\u4E0D\u5728\u8BA4\u8BC1 / \u6743\u9650 / \u7F51\u7EDC\u4E09\u7C7B\u91CC\uFF08${repoDisplay}\uFF09\uFF1A${head}`,
|
|
13542
13667
|
context: { nextStep: `\u81EA\u5DF1\u8DD1\u4E00\u6B21 \`git ls-remote --tags <\u65B9\u6CD5\u8BBA\u4ED3\u5730\u5740>\` \u770B\u539F\u8BDD\uFF1B\u628A\u4E0A\u9762\u8FD9\u6BB5\u8FDE\u540C \`git --version\` \u62A5\u7ED9 CLI \u7EF4\u62A4\u8005` }
|
|
13543
13668
|
});
|
|
@@ -13613,8 +13738,8 @@ function resolveRef(tags, ref, deps) {
|
|
|
13613
13738
|
if (ref === void 0) {
|
|
13614
13739
|
const latest = versions[0];
|
|
13615
13740
|
if (!latest) {
|
|
13616
|
-
throw new
|
|
13617
|
-
code:
|
|
13741
|
+
throw new CliError31({
|
|
13742
|
+
code: CliErrorCode33.METHOD_REF_NOT_FOUND,
|
|
13618
13743
|
message: `\u65B9\u6CD5\u8BBA\u4ED3 ${deps.repoDisplay} \u91CC\u4E00\u4E2A vX.Y.Z \u5F62\u5F0F\u7684\u7248\u672C tag \u90FD\u6CA1\u6709`,
|
|
13619
13744
|
context: { nextStep: tags.size ? `\u4ED3\u91CC\u6709\u8FD9\u4E9B tag\uFF1A${[...tags.keys()].slice(0, 10).join("\u3001")}\uFF0C\u7528 --ref \u6307\u5B9A\u4E00\u4E2A` : "\u65B9\u6CD5\u8BBA\u4ED3\u8FD8\u6CA1\u53D1\u8FC7\u7248\uFF0C\u627E\u65B9\u6CD5\u8D1F\u8D23\u4EBA\u786E\u8BA4" }
|
|
13620
13745
|
});
|
|
@@ -13623,8 +13748,8 @@ function resolveRef(tags, ref, deps) {
|
|
|
13623
13748
|
}
|
|
13624
13749
|
const name = tags.has(ref) ? ref : tags.has(`v${ref}`) ? `v${ref}` : void 0;
|
|
13625
13750
|
if (!name) {
|
|
13626
|
-
throw new
|
|
13627
|
-
code:
|
|
13751
|
+
throw new CliError31({
|
|
13752
|
+
code: CliErrorCode33.METHOD_REF_NOT_FOUND,
|
|
13628
13753
|
message: `\u65B9\u6CD5\u8BBA\u4ED3 ${deps.repoDisplay} \u91CC\u6CA1\u6709 tag ${ref}`,
|
|
13629
13754
|
context: { nextStep: versions.length ? `\u53EF\u7528\u7684\u7248\u672C tag\uFF1A${versions.slice(0, 10).join("\u3001")}` : "\u65B9\u6CD5\u8BBA\u4ED3\u8FD8\u6CA1\u53D1\u8FC7\u7248\uFF0C\u627E\u65B9\u6CD5\u8D1F\u8D23\u4EBA\u786E\u8BA4" }
|
|
13630
13755
|
});
|
|
@@ -13632,8 +13757,8 @@ function resolveRef(tags, ref, deps) {
|
|
|
13632
13757
|
return { ref: name, commit: tags.get(name) };
|
|
13633
13758
|
}
|
|
13634
13759
|
function invalidPackage(field, message) {
|
|
13635
|
-
return new
|
|
13636
|
-
code:
|
|
13760
|
+
return new CliError31({
|
|
13761
|
+
code: CliErrorCode33.METHOD_PACKAGE_INVALID,
|
|
13637
13762
|
message: `\u65B9\u6CD5\u5305\u6E05\u5355 package.yml \u4E0D\u5408\u683C\uFF1A${message}`,
|
|
13638
13763
|
context: { field, nextStep: "\u8FD9\u662F\u65B9\u6CD5\u5305\u7684\u7F3A\u9677\uFF0C\u4E0D\u662F\u672C\u673A\u95EE\u9898\uFF1A\u628A\u8FD9\u6BB5\u62A5\u7ED9\u65B9\u6CD5\u8BBA\u4ED3\u8D1F\u8D23\u4EBA\u3002\u5DF2\u88C5\u7684\u65B9\u6CD5\u5305\uFF08\u5982\u6709\uFF09\u4FDD\u6301\u539F\u6837\uFF0C\u6CA1\u52A8" }
|
|
13639
13764
|
});
|
|
@@ -13657,8 +13782,8 @@ function parsePackageManifest(text) {
|
|
|
13657
13782
|
throw invalidPackage("schemaVersion", "\u7F3A schemaVersion\uFF08\u6574\u6570\uFF09");
|
|
13658
13783
|
}
|
|
13659
13784
|
if (!KNOWN_PACKAGE_SCHEMA_VERSIONS.includes(m.schemaVersion)) {
|
|
13660
|
-
throw new
|
|
13661
|
-
code:
|
|
13785
|
+
throw new CliError31({
|
|
13786
|
+
code: CliErrorCode33.METHOD_PACKAGE_SCHEMA_UNSUPPORTED,
|
|
13662
13787
|
message: `\u65B9\u6CD5\u5305\u6E05\u5355\u7684\u683C\u5F0F\u7248\u672C schemaVersion=${m.schemaVersion}\uFF0C\u8FD9\u7248 CLI\uFF08${CLI_VERSION}\uFF09\u53EA\u8BA4\u8BC6 ${KNOWN_PACKAGE_SCHEMA_VERSIONS.join(" / ")}`,
|
|
13663
13788
|
context: { nextStep: "\u5347\u7EA7 CLI\uFF1A`npm install --global @hcmai/cli@latest`\uFF08\u6216 `hcm upgrade`\uFF09\uFF0C\u518D\u91CD\u8DD1\u3002\u5DF2\u88C5\u7684\u65B9\u6CD5\u5305\uFF08\u5982\u6709\uFF09\u4FDD\u6301\u539F\u6837\uFF0C\u6CA1\u52A8" }
|
|
13664
13789
|
});
|
|
@@ -13894,8 +14019,8 @@ function renderConflictBlocks(blocks) {
|
|
|
13894
14019
|
}
|
|
13895
14020
|
function conflictError(blocks, pkg, commit) {
|
|
13896
14021
|
const hits = blocks.flatMap((b) => b.conflicts);
|
|
13897
|
-
return new
|
|
13898
|
-
code:
|
|
14022
|
+
return new CliError31({
|
|
14023
|
+
code: CliErrorCode33.SKILL_ID_CONFLICT,
|
|
13899
14024
|
message: "\u65B9\u6CD5\u5305\u91CC\u7684\u6280\u80FD id \u4E0E\u5DF2\u6709\u6765\u6E90\u540C\u540D\uFF0C\u62D2\u88C5\uFF1A\n" + hits.map((c2) => ` \xB7 \`${c2.id}\`\uFF1A\u65B9\u6CD5 ${pkg.version} @${commit.slice(0, 12)} \u2194 ${c2.other}`).join("\n") + "\n\u672C\u8D9F\u51B2\u7A81\u68C0\u67E5\uFF1A\n" + renderConflictBlocks(blocks).join("\n"),
|
|
13900
14025
|
context: {
|
|
13901
14026
|
nextStep: `\u62A5\u65B9\u6CD5\u8D1F\u8D23\u4EBA\u6539\u540D\u3002\`${METHOD_SKILL_PREFIX}\` \u524D\u7F00\u53EA\u7ED9\u65B9\u6CD5\u6765\u6E90\uFF0C\u7EA6\u5B9A\u751F\u6548\u65F6\u4E0D\u8BE5\u649E\u540D\uFF1B\u649E\u4E86\u8BF4\u660E\u6709\u4E00\u8FB9\u8FDD\u53CD\u4E86\u524D\u7F00\u7EA6\u5B9A\u3002\u5DF2\u88C5\u7684\u65B9\u6CD5\u5305\uFF08\u5982\u6709\uFF09\u4FDD\u6301\u539F\u6837\uFF0C\u6CA1\u52A8`,
|
|
@@ -13910,8 +14035,8 @@ function upsertManagedBlock(existing, begin, end, block, label) {
|
|
|
13910
14035
|
const finish = existing.indexOf(end);
|
|
13911
14036
|
const malformed = start < 0 !== finish < 0 || start >= 0 && (finish < start || existing.lastIndexOf(begin) !== start || existing.lastIndexOf(end) !== finish);
|
|
13912
14037
|
if (malformed) {
|
|
13913
|
-
throw new
|
|
13914
|
-
code:
|
|
14038
|
+
throw new CliError31({
|
|
14039
|
+
code: CliErrorCode33.METHOD_MANAGED_BLOCK_CORRUPT,
|
|
13915
14040
|
message: `${label} \u91CC\u65B9\u6CD5\u53D7\u7BA1\u5757\u7684\u6807\u8BB0\u635F\u574F\u6216\u91CD\u590D\uFF08${begin} \u2026 ${end}\uFF09\uFF0C\u62D2\u7EDD\u8986\u76D6`,
|
|
13916
14041
|
context: { nextStep: `\u624B\u5DE5\u628A ${label} \u91CC\u8FD9\u4E24\u884C\u6807\u8BB0\u4FEE\u6210\u5404\u51FA\u73B0\u4E00\u6B21\u3001begin \u5728\u524D\uFF08\u6216\u8FDE\u540C\u4E2D\u95F4\u5185\u5BB9\u6574\u6BB5\u5220\u6389\uFF09\uFF0C\u518D\u91CD\u8DD1` }
|
|
13917
14042
|
});
|
|
@@ -13975,8 +14100,8 @@ async function readLock(root) {
|
|
|
13975
14100
|
if (e.code === "ENOENT") return void 0;
|
|
13976
14101
|
throw e;
|
|
13977
14102
|
}
|
|
13978
|
-
const bad = (why) => new
|
|
13979
|
-
code:
|
|
14103
|
+
const bad = (why) => new CliError31({
|
|
14104
|
+
code: CliErrorCode33.METHOD_LOCK_INVALID,
|
|
13980
14105
|
message: `\u9501\u6587\u4EF6 ${METHOD_DIR}/${METHOD_LOCK_FILE} \u8BFB\u4E0D\u61C2\uFF1A${why}`,
|
|
13981
14106
|
context: { nextStep: "\u591A\u534A\u662F\u5408\u5E76\u51B2\u7A81\u7559\u4E0B\u7684\u6807\u8BB0\uFF1A\u6309\u9879\u76EE PR \u91CC\u60F3\u8981\u7684\u90A3\u4E00\u7248\u89E3\u51B3\u51B2\u7A81\uFF08\u6216 `git checkout` \u56DE\u4E0A\u4E00\u7248\uFF09\uFF0C\u518D\u8DD1 `hcm chiron method status`" }
|
|
13982
14107
|
});
|
|
@@ -14016,7 +14141,7 @@ async function resolveMethodRoot(project2, log) {
|
|
|
14016
14141
|
async function resolveTarget(root, requested) {
|
|
14017
14142
|
if (requested === "claude" || requested === "codex") return requested;
|
|
14018
14143
|
if (requested !== void 0 && requested !== "auto") {
|
|
14019
|
-
throw new
|
|
14144
|
+
throw new CliError31({ code: CliErrorCode33.INVALID_ARGUMENT, message: `--target \u53EA\u8BA4 claude / codex / auto\uFF0C\u6536\u5230 ${requested}` });
|
|
14020
14145
|
}
|
|
14021
14146
|
return (await readState(root))?.target ?? await detectTarget(root) ?? "claude";
|
|
14022
14147
|
}
|
|
@@ -14158,8 +14283,8 @@ async function runMethodPipeline(input, deps) {
|
|
|
14158
14283
|
const tags = await listRemoteTags(deps);
|
|
14159
14284
|
const r = resolveRef(tags, input.ref, deps);
|
|
14160
14285
|
if (input.expectCommit && r.commit !== input.expectCommit) {
|
|
14161
|
-
throw new
|
|
14162
|
-
code:
|
|
14286
|
+
throw new CliError31({
|
|
14287
|
+
code: CliErrorCode33.METHOD_TAG_MOVED,
|
|
14163
14288
|
message: `\u9501\u6587\u4EF6\u9501\u5B9A ${r.ref} @ ${input.expectCommit}\uFF0C\u800C\u8FD9\u4E2A tag \u73B0\u5728\u6307\u5411 ${r.commit}\uFF08tag \u88AB\u79FB\u52A8\u8FC7\uFF09`,
|
|
14164
14289
|
context: { nextStep: "\u627E\u65B9\u6CD5\u8D1F\u8D23\u4EBA\u786E\u8BA4\u8FD9\u4E2A tag \u4E3A\u4EC0\u4E48\u88AB\u79FB\u52A8\u3002\u786E\u8BA4\u8981\u8DDF\u65B0\u5185\u5BB9\u5C31 `hcm chiron method update --ref <tag>`\uFF08\u9501\u6587\u4EF6\u7684\u53D8\u66F4\u8D70\u9879\u76EE PR \u8BC4\u5BA1\uFF09" }
|
|
14165
14290
|
});
|
|
@@ -14174,8 +14299,8 @@ async function runMethodPipeline(input, deps) {
|
|
|
14174
14299
|
await deps.git(["clone", "--depth", "1", "--filter=blob:none", "--sparse", "--quiet", "--branch", resolved.ref, deps.repoUrl, checkout]);
|
|
14175
14300
|
const head = (await deps.git(["-C", checkout, "rev-parse", "HEAD"], { timeoutMs: 1e4 })).trim();
|
|
14176
14301
|
if (head !== resolved.commit) {
|
|
14177
|
-
throw new
|
|
14178
|
-
code:
|
|
14302
|
+
throw new CliError31({
|
|
14303
|
+
code: CliErrorCode33.METHOD_TAG_MOVED,
|
|
14179
14304
|
message: `\u89E3\u6790\u65F6 ${resolved.ref} \u6307\u5411 ${resolved.commit}\uFF0C\u53D6\u4E0B\u6765\u7684\u5374\u662F ${head}\uFF08tag \u5728\u8FD9\u51E0\u79D2\u91CC\u88AB\u79FB\u52A8\u4E86\uFF09`,
|
|
14180
14305
|
context: { nextStep: "\u91CD\u8DD1\u4E00\u6B21\uFF1B\u518D\u51FA\u73B0\u5C31\u627E\u65B9\u6CD5\u8D1F\u8D23\u4EBA\u786E\u8BA4\u8FD9\u4E2A tag \u4E3A\u4EC0\u4E48\u5728\u52A8" }
|
|
14181
14306
|
});
|
|
@@ -14354,7 +14479,7 @@ async function runMethodStatus(root, deps, opts = {}) {
|
|
|
14354
14479
|
verdict: "fail",
|
|
14355
14480
|
detail: `\u6CA1\u6709 ${METHOD_DIR}/${METHOD_LOCK_FILE}\uFF1A\u8FD9\u4E2A\u9879\u76EE\u8FD8\u6CA1\u88C5\u65B9\u6CD5\u5305`,
|
|
14356
14481
|
nextStep: "\u6709\u77E5\u8BC6\u7EC4\u7EC7\u6388\u6743\u5C31\u8DD1 `hcm chiron method install`\uFF1B\u6CA1\u6709\u6388\u6743\u53EF\u4EE5\u8DF3\u8FC7\uFF0C\u4E0D\u5F71\u54CD\u4EA7\u54C1\u64CD\u4F5C",
|
|
14357
|
-
code:
|
|
14482
|
+
code: CliErrorCode33.METHOD_NOT_INSTALLED
|
|
14358
14483
|
});
|
|
14359
14484
|
return done();
|
|
14360
14485
|
}
|
|
@@ -14368,7 +14493,7 @@ async function runMethodStatus(root, deps, opts = {}) {
|
|
|
14368
14493
|
verdict: "fail",
|
|
14369
14494
|
detail: "\u9501\u6587\u4EF6\u5728\uFF0C\u4F46\u672C\u673A\u6CA1\u6709\u65B9\u6CD5\u5305\u526F\u672C\uFF08\u521A clone \u4E0B\u6765\u7684\u9879\u76EE\u4ED3\u5C31\u662F\u8FD9\u6837\uFF09",
|
|
14370
14495
|
nextStep: "`hcm chiron method install`\uFF08\u6309\u9501\u6587\u4EF6\u7684\u7248\u672C\u88C5\uFF09",
|
|
14371
|
-
code:
|
|
14496
|
+
code: CliErrorCode33.METHOD_NOT_INSTALLED
|
|
14372
14497
|
});
|
|
14373
14498
|
} else {
|
|
14374
14499
|
report.installed.present = true;
|
|
@@ -14379,7 +14504,7 @@ async function runMethodStatus(root, deps, opts = {}) {
|
|
|
14379
14504
|
verdict: "fail",
|
|
14380
14505
|
detail: "\u672C\u673A\u526F\u672C\u7684 package.yml \u4E0E\u9501\u6587\u4EF6\u8BB0\u7684\u6458\u8981\u4E0D\u4E00\u81F4\uFF1A\u88C5\u7684\u4E0D\u662F\u9501\u5B9A\u7684\u90A3\u4E00\u7248",
|
|
14381
14506
|
nextStep: "`hcm chiron method install`\uFF08\u6309\u9501\u6587\u4EF6\u7684 commit \u91CD\u88C5\uFF09",
|
|
14382
|
-
code:
|
|
14507
|
+
code: CliErrorCode33.METHOD_DIGEST_MISMATCH
|
|
14383
14508
|
});
|
|
14384
14509
|
} else {
|
|
14385
14510
|
report.rows.push({ item: "\u5B89\u88C5", verdict: "ok", detail: `\u672C\u673A\u526F\u672C\u5C31\u662F\u9501\u5B9A\u7684\u90A3\u4E00\u7248\uFF08${path12.join(root, METHOD_DIR)}/\uFF09` });
|
|
@@ -14423,13 +14548,13 @@ async function runMethodStatus(root, deps, opts = {}) {
|
|
|
14423
14548
|
verdict: "fail",
|
|
14424
14549
|
detail: `${bad.length} \u4EFD .claude/skills \u65B9\u6CD5\u526F\u672C\u4E0E\u9501\u5B9A\u7248\u672C\u4E0D\u7B26\uFF08\u8FD9\u53F0\u673A\u5668\u73B0\u5728\u7684 target \u662F ${state.target}\uFF0C\u8FD9\u4E9B\u526F\u672C\u662F\u4E4B\u524D\u7528 claude \u76EE\u6807\u88C5\u65F6\u7559\u4E0B\u7684\uFF09\uFF1A${listing}`,
|
|
14425
14550
|
nextStep: "`hcm chiron method install`\uFF08\u4F1A\u4E00\u5E76\u5237\u65B0 .claude/skills \u4E0B\u5DF2\u6709\u7684\u65B9\u6CD5\u526F\u672C\uFF09\uFF1B\u4E0D\u518D\u7528 Claude Code \u5C31\u5220\u6389 `.claude/skills/method-*/`",
|
|
14426
|
-
code:
|
|
14551
|
+
code: CliErrorCode33.METHOD_DIGEST_MISMATCH
|
|
14427
14552
|
} : {
|
|
14428
14553
|
item: "\u6458\u8981",
|
|
14429
14554
|
verdict: "fail",
|
|
14430
14555
|
detail: `${bad.length} \u4EFD\u6587\u4EF6\u4E0E\u6E05\u5355\u4E0D\u7B26\uFF1A${listing}`,
|
|
14431
14556
|
nextStep: "`hcm chiron method install`\uFF08\u6309\u9501\u6587\u4EF6\u7684 commit \u91CD\u88C5\uFF0C\u672C\u673A\u6539\u52A8\u4F1A\u88AB\u8986\u76D6\uFF1B\u8981\u6539\u65B9\u6CD5\u5C31\u53BB\u65B9\u6CD5\u8BBA\u4ED3\u63D0\uFF09",
|
|
14432
|
-
code:
|
|
14557
|
+
code: CliErrorCode33.METHOD_DIGEST_MISMATCH
|
|
14433
14558
|
});
|
|
14434
14559
|
} else {
|
|
14435
14560
|
report.rows.push({
|
|
@@ -14452,7 +14577,7 @@ async function runMethodStatus(root, deps, opts = {}) {
|
|
|
14452
14577
|
verdict: "warn",
|
|
14453
14578
|
detail: `tag ${lock.ref} \u73B0\u5728\u6307\u5411 ${report.remote.lockedTagCommit.slice(0, 12)}\uFF0C\u9501\u5B9A\u7684\u662F ${lock.commit.slice(0, 12)}\uFF08tag \u88AB\u79FB\u52A8\u8FC7\uFF1B\u672C\u673A\u526F\u672C\u4EE5\u9501\u5B9A\u7684 commit \u4E3A\u51C6\uFF09`,
|
|
14454
14579
|
nextStep: "\u627E\u65B9\u6CD5\u8D1F\u8D23\u4EBA\u786E\u8BA4 tag \u4E3A\u4EC0\u4E48\u88AB\u79FB\u52A8\uFF1B\u8981\u8DDF\u65B0\u5185\u5BB9\u5C31 `hcm chiron method update --ref <tag>`",
|
|
14455
|
-
code:
|
|
14580
|
+
code: CliErrorCode33.METHOD_TAG_MOVED
|
|
14456
14581
|
});
|
|
14457
14582
|
} else if (!SEMVER_TAG.test(lock.ref) || !report.remote.latestTag) {
|
|
14458
14583
|
report.remote.undetermined = !SEMVER_TAG.test(lock.ref) ? `\u9501\u5B9A\u7684 ref ${lock.ref} \u4E0D\u662F vX.Y.Z \u7248\u672C tag\uFF0C\u65E0\u6CD5\u5224\u65AD\u662F\u5426\u843D\u540E\uFF08\u8FDC\u7AEF\u6700\u65B0\u7248\u672C tag\uFF1A${report.remote.latestTag ?? "\u65E0"}\uFF09` : "\u8FDC\u7AEF\u4E00\u4E2A vX.Y.Z \u7248\u672C tag \u90FD\u6CA1\u6709\uFF0C\u65E0\u6CD5\u5224\u65AD\u662F\u5426\u843D\u540E";
|
|
@@ -14497,7 +14622,7 @@ async function runMethodStatus(root, deps, opts = {}) {
|
|
|
14497
14622
|
const hits = report.conflictCheck.flatMap((b) => b.conflicts);
|
|
14498
14623
|
const unchecked = report.conflictCheck.filter((b) => !b.checked);
|
|
14499
14624
|
const summary = report.conflictCheck.map((b) => b.checked ? `${b.label}\uFF1A\u5DF2\u6BD4\u5BF9 ${b.compared.length} \u4E2A${b.conflicts.length ? `\uFF0C\u540C\u540D ${b.conflicts.map((c2) => c2.id).join("\u3001")}` : "\uFF0C\u65E0\u540C\u540D"}` : `${b.label}\uFF1A\u672A\u6BD4\u5BF9\uFF08${b.note}\uFF09`).join("\uFF1B");
|
|
14500
|
-
report.rows.push(hits.length ? { item: "\u51B2\u7A81", verdict: "fail", detail: summary, nextStep: "\u62A5\u65B9\u6CD5\u8D1F\u8D23\u4EBA\u6539\u540D\uFF08method- \u524D\u7F00\u53EA\u7ED9\u65B9\u6CD5\u6765\u6E90\uFF09", code:
|
|
14625
|
+
report.rows.push(hits.length ? { item: "\u51B2\u7A81", verdict: "fail", detail: summary, nextStep: "\u62A5\u65B9\u6CD5\u8D1F\u8D23\u4EBA\u6539\u540D\uFF08method- \u524D\u7F00\u53EA\u7ED9\u65B9\u6CD5\u6765\u6E90\uFF09", code: CliErrorCode33.SKILL_ID_CONFLICT } : unchecked.length ? { item: "\u51B2\u7A81", verdict: "warn", detail: `${summary}\u2014\u2014\u6CA1\u6BD4\u5BF9\u7684\u5757\u4E0A\u4E0D\u80FD\u8BF4\u300C\u65E0\u51B2\u7A81\u300D` } : { item: "\u51B2\u7A81", verdict: "ok", detail: summary });
|
|
14501
14626
|
}
|
|
14502
14627
|
report.rows.push(report.remote.checked ? { item: "\u6765\u6E90", verdict: "ok", detail: `\u5728\u7EBF\uFF1Agit \u51ED\u636E\u8BA4\u8BC1\u53D6 tag\uFF0Ccommit \u56FA\u5B9A\uFF08${lock.repo}\uFF09` } : { item: "\u6765\u6E90", verdict: "warn", detail: "\u79BB\u7EBF\uFF1A\u53EA\u6838\u4E86\u672C\u673A\u526F\u672C\u7684\u6458\u8981\uFF0C\u6CA1\u4E0E\u8FDC\u7AEF\u6838\u5BF9 tag" });
|
|
14503
14628
|
return done();
|
|
@@ -14516,10 +14641,10 @@ async function inspectMethodForDoctor(root, deps = quietDeps()) {
|
|
|
14516
14641
|
const row = (item) => s.rows.find((r) => r.item === item);
|
|
14517
14642
|
const lockRow = row("\u9501\u5B9A");
|
|
14518
14643
|
if (!s.lock) {
|
|
14519
|
-
return lockRow.code ===
|
|
14644
|
+
return lockRow.code === CliErrorCode33.METHOD_NOT_INSTALLED ? { verdict: "warn", detail: "\u672A\u5B89\u88C5\uFF08\u9879\u76EE\u91CC\u6CA1\u6709\u65B9\u6CD5\u5305\u9501\u6587\u4EF6\uFF09", nextStep: "\u6709\u77E5\u8BC6\u7EC4\u7EC7\u6388\u6743\u5C31\u8DD1 `hcm chiron method install`\uFF1B\u6CA1\u6709\u6388\u6743\u53EF\u4EE5\u8DF3\u8FC7\uFF0C\u4E0D\u5F71\u54CD\u4EA7\u54C1\u64CD\u4F5C" } : { verdict: "warn", detail: `\u65E0\u6CD5\u5224\u65AD\uFF1A${lockRow.detail}`, nextStep: lockRow.nextStep };
|
|
14520
14645
|
}
|
|
14521
14646
|
const install = row("\u5B89\u88C5");
|
|
14522
|
-
if (install?.code ===
|
|
14647
|
+
if (install?.code === CliErrorCode33.METHOD_NOT_INSTALLED) {
|
|
14523
14648
|
return { verdict: "warn", detail: `\u672A\u5B89\u88C5\uFF08\u9501\u6587\u4EF6\u9501\u5B9A\u65B9\u6CD5 ${s.lock.package.version} \xB7 ${s.lock.ref}\uFF0C\u672C\u673A\u8FD8\u6CA1\u6709\u65B9\u6CD5\u5305\u526F\u672C\uFF09`, nextStep: "\u6709\u77E5\u8BC6\u7EC4\u7EC7\u6388\u6743\u5C31\u8DD1 `hcm chiron method install`\uFF08\u6309\u9501\u6587\u4EF6\u7684\u7248\u672C\u88C5\uFF09\uFF1B\u6CA1\u6709\u6388\u6743\u53EF\u4EE5\u8DF3\u8FC7\uFF0C\u4E0D\u5F71\u54CD\u4EA7\u54C1\u64CD\u4F5C" };
|
|
14524
14649
|
}
|
|
14525
14650
|
const local = [install, row("\u6458\u8981")].find((r) => r && r.verdict === "fail");
|
|
@@ -14536,7 +14661,7 @@ function quietDeps() {
|
|
|
14536
14661
|
} };
|
|
14537
14662
|
}
|
|
14538
14663
|
function emit6(output, data, text) {
|
|
14539
|
-
if (output === "json" || output === "yaml") process.stdout.write(
|
|
14664
|
+
if (output === "json" || output === "yaml") process.stdout.write(formatObject28(data, { format: output }) + "\n");
|
|
14540
14665
|
else process.stdout.write(text() + "\n");
|
|
14541
14666
|
}
|
|
14542
14667
|
async function runMethodInstall(args, deps = defaultMethodDeps()) {
|
|
@@ -14552,8 +14677,8 @@ async function runMethodUpdate(args, deps = defaultMethodDeps()) {
|
|
|
14552
14677
|
const { root, rootSource } = await resolveMethodRoot(args.project, deps.log);
|
|
14553
14678
|
const lock = await readLock(root);
|
|
14554
14679
|
if (!lock) {
|
|
14555
|
-
throw new
|
|
14556
|
-
code:
|
|
14680
|
+
throw new CliError31({
|
|
14681
|
+
code: CliErrorCode33.METHOD_NOT_INSTALLED,
|
|
14557
14682
|
message: `${root} \u91CC\u6CA1\u6709 ${METHOD_DIR}/${METHOD_LOCK_FILE}\uFF1A\u8FD9\u4E2A\u9879\u76EE\u8FD8\u6CA1\u88C5\u65B9\u6CD5\u5305\uFF0C\u6CA1\u6709\u53EF\u4EE5\u66F4\u65B0\u7684\u8D77\u70B9`,
|
|
14558
14683
|
context: { nextStep: "`hcm chiron method install`\uFF08\u88C5\u6700\u65B0\u7684\u7248\u672C tag\uFF09" }
|
|
14559
14684
|
});
|
|
@@ -14602,7 +14727,7 @@ async function methodStatusCommand(args) {
|
|
|
14602
14727
|
// src/commands/doctor/local-checks.ts
|
|
14603
14728
|
import { promises as fs11 } from "fs";
|
|
14604
14729
|
import path13 from "path";
|
|
14605
|
-
import
|
|
14730
|
+
import axios6 from "axios";
|
|
14606
14731
|
import { fetchSkillCatalog as fetchSkillCatalog3, fetchSkillMarkdown as fetchSkillMarkdown2, fetchSkillReference as fetchSkillReference2, normalizeReferences as normalizeReferences2, normalizeOrigin as normalizeOrigin6, resolveChironBase as resolveChironBase3 } from "@hcmai/sdk";
|
|
14607
14732
|
|
|
14608
14733
|
// src/commands/doctor/result.ts
|
|
@@ -14741,7 +14866,7 @@ function hasProductSkills(states) {
|
|
|
14741
14866
|
}
|
|
14742
14867
|
async function inspectSkillsFresh(states, endpoint, signal) {
|
|
14743
14868
|
if (!hasProductSkills(states)) return { level: "NOT_APPLICABLE", summary: NO_PRODUCT_SKILLS, note: "\u672A\u8BF7\u6C42\u6280\u80FD\u76EE\u5F55" };
|
|
14744
|
-
const http =
|
|
14869
|
+
const http = axios6.create({
|
|
14745
14870
|
baseURL: endpoint,
|
|
14746
14871
|
timeout: 5e3,
|
|
14747
14872
|
maxRedirects: 0,
|
|
@@ -14839,11 +14964,11 @@ var localChecks = { project, credential, version, installed, fresh, boundary, me
|
|
|
14839
14964
|
|
|
14840
14965
|
// src/commands/doctor/connect-checks.ts
|
|
14841
14966
|
init_auth_guard();
|
|
14842
|
-
import
|
|
14843
|
-
import { CliError as
|
|
14967
|
+
import axios8 from "axios";
|
|
14968
|
+
import { CliError as CliError32, IMPERSONATION_START_PATH, USER_LOOKUP_PATH, probeDoctorEndpoint, probeDoctorLayer, layerDetail, toPrincipal as toPrincipal3 } from "@hcmai/sdk";
|
|
14844
14969
|
|
|
14845
14970
|
// src/commands/doctor/server-report.ts
|
|
14846
|
-
import
|
|
14971
|
+
import axios7 from "axios";
|
|
14847
14972
|
import { classifyStatus } from "@hcmai/sdk";
|
|
14848
14973
|
var optionalText2 = (value) => value === void 0 || value === null || typeof value === "string";
|
|
14849
14974
|
var fullScope = { stage: null, only: [], skip: [], active: false };
|
|
@@ -14877,7 +15002,7 @@ var requestServerReport = async (endpoint, token, timeoutMs, budgetMs, signal, s
|
|
|
14877
15002
|
...scope.only.length ? { only: scope.only.join(",") } : {},
|
|
14878
15003
|
...scope.skip.length ? { skip: scope.skip.join(",") } : {}
|
|
14879
15004
|
};
|
|
14880
|
-
const res = scope.active ? await
|
|
15005
|
+
const res = scope.active ? await axios7.post("/api/system/health/report", { active: true, budgetMs, ...range }, options) : await axios7.get("/api/system/health/report", { ...options, params: { budgetMs, ...range } });
|
|
14881
15006
|
return {
|
|
14882
15007
|
status: res.status,
|
|
14883
15008
|
body: res.data,
|
|
@@ -14886,7 +15011,7 @@ var requestServerReport = async (endpoint, token, timeoutMs, budgetMs, signal, s
|
|
|
14886
15011
|
};
|
|
14887
15012
|
};
|
|
14888
15013
|
function stoppedWaiting(error, signal) {
|
|
14889
|
-
return signal.aborted ||
|
|
15014
|
+
return signal.aborted || axios7.isAxiosError(error) && error.code === "ECONNABORTED";
|
|
14890
15015
|
}
|
|
14891
15016
|
function httpNote(out) {
|
|
14892
15017
|
return `HTTP ${out.status < 0 ? "\u672A\u53D6\u5F97\u54CD\u5E94" : out.status}${out.headers["x-trace-id"] ? ` \xB7 traceId=${out.headers["x-trace-id"]}` : ""}`;
|
|
@@ -15193,8 +15318,8 @@ var identity = async (ctx, env2, execution) => {
|
|
|
15193
15318
|
if (execution.signal.aborted) await e.close?.();
|
|
15194
15319
|
return observation;
|
|
15195
15320
|
} catch (error) {
|
|
15196
|
-
const detail = error instanceof
|
|
15197
|
-
const errorCode = error instanceof
|
|
15321
|
+
const detail = error instanceof CliError32 ? error.context : void 0;
|
|
15322
|
+
const errorCode = error instanceof CliError32 ? error.code : void 0;
|
|
15198
15323
|
const actorStep = error !== null && typeof error === "object" ? error[AS_ACTOR_STEP] : void 0;
|
|
15199
15324
|
if (actorStep) {
|
|
15200
15325
|
const actorCode = actorStep === "meta" || actorStep === "env" ? "IDENTITY_META_INVALID" : actorStep === "resolve" && errorCode === "IDENTITY_NOT_FOUND" ? "IDENTITY_NOT_LOGGED_IN" : "IDENTITY_UNVERIFIED";
|
|
@@ -15204,11 +15329,11 @@ var identity = async (ctx, env2, execution) => {
|
|
|
15204
15329
|
const code3 = detail.mismatch === "tenant" ? "TENANT_MISMATCH" : "IDENTITY_USER_MISMATCH";
|
|
15205
15330
|
return found(code3, void 0, { note: `\u4EE3\u7406\u524D\u6838\u9A8C\u64CD\u4F5C\u8005\u65F6\u53D1\u73B0\u4E3B\u4F53\u4E0D\u7B26\uFF1A${safeError(error)}` });
|
|
15206
15331
|
}
|
|
15207
|
-
const status =
|
|
15208
|
-
const requestPath =
|
|
15332
|
+
const status = axios8.isAxiosError(error) ? error.response?.status : void 0;
|
|
15333
|
+
const requestPath = axios8.isAxiosError(error) ? error.config?.url ?? "" : "";
|
|
15209
15334
|
const proxyStart = requestPath.endsWith(IMPERSONATION_START_PATH);
|
|
15210
15335
|
const userLookup = requestPath.endsWith(USER_LOOKUP_PATH);
|
|
15211
|
-
const envelope =
|
|
15336
|
+
const envelope = axios8.isAxiosError(error) && obj(error.response?.data) && obj(error.response.data.error) ? error.response.data.error : void 0;
|
|
15212
15337
|
const targetMissing = status === 404 && proxyStart && envelope?.code === "NOT_FOUND";
|
|
15213
15338
|
const targetAdvice = envelope?.details === "\u76EE\u6807\u7528\u6237\u4E0D\u5B58\u5728" ? "\u670D\u52A1\u7AEF\uFF1A\u76EE\u6807\u7528\u6237\u4E0D\u5B58\u5728\uFF1B\u6838\u5BF9\u5F53\u524D\u79DF\u6237\u4E0E\u76EE\u6807\u7528\u6237 UUID" : "\u670D\u52A1\u7AEF\u56DE 404 NOT_FOUND\uFF0C\u672A\u6307\u660E\u76EE\u6807\u7528\u6237\u4E0D\u5B58\u5728\uFF08\u4E5F\u53EF\u80FD\u662F\u540E\u7AEF\u6CA1\u6709\u4EE3\u7406\u63A5\u53E3\uFF09\uFF1B\u6838\u5BF9\u5F53\u524D\u79DF\u6237\u4E0E\u76EE\u6807\u7528\u6237 UUID\uFF0C\u5E76\u6838\u540E\u7AEF\u7248\u672C";
|
|
15214
15339
|
const code2 = status === 403 || targetMissing || errorCode && ["SCOPE_FORBIDDEN", "IDENTITY_NOT_FOUND", "INVALID_ARGUMENT", "IDENTITY_NOT_IN_ENV", "IDENTITY_META_INCOMPLETE"].includes(errorCode) ? "AS_PROXY_DENIED" : errorCode === "AUTH_FAILED" ? "IDENTITY_NOT_LOGGED_IN" : status === 401 ? "TOKEN_REJECTED" : "IDENTITY_UNVERIFIED";
|
|
@@ -15772,11 +15897,11 @@ function renderChironDoctor(report) {
|
|
|
15772
15897
|
|
|
15773
15898
|
// src/commands/doctor/platform-ops.ts
|
|
15774
15899
|
import { createHash as createHash8 } from "crypto";
|
|
15775
|
-
import
|
|
15900
|
+
import axios9 from "axios";
|
|
15776
15901
|
import {
|
|
15777
15902
|
classifyStatus as classifyStatus2,
|
|
15778
|
-
CliError as
|
|
15779
|
-
CliErrorCode as
|
|
15903
|
+
CliError as CliError33,
|
|
15904
|
+
CliErrorCode as CliErrorCode34,
|
|
15780
15905
|
loadGlobalConfig as loadGlobalConfig11,
|
|
15781
15906
|
printResolvedEnvironment as printResolvedEnvironment8,
|
|
15782
15907
|
resolveEnvContext as resolveEnvContext8
|
|
@@ -15842,7 +15967,7 @@ var placeholder = {
|
|
|
15842
15967
|
};
|
|
15843
15968
|
var OPS_DESCRIPTORS = [connectivity2, api, placeholder];
|
|
15844
15969
|
var requestOpsReport = async (endpoint, key2, timeoutMs, budgetMs, signal, scope) => {
|
|
15845
|
-
const res = await
|
|
15970
|
+
const res = await axios9.get(OPS_PATH, {
|
|
15846
15971
|
baseURL: endpoint,
|
|
15847
15972
|
timeout: timeoutMs,
|
|
15848
15973
|
signal,
|
|
@@ -15884,11 +16009,11 @@ async function readPlatformOpsKey(args, io = {
|
|
|
15884
16009
|
} else if (io.isTTY) {
|
|
15885
16010
|
source = "tty";
|
|
15886
16011
|
key2 = await io.prompt();
|
|
15887
|
-
} else throw new
|
|
16012
|
+
} else throw new CliError33({ code: CliErrorCode34.INVALID_ARGUMENT, message: blank ? "HCM_PLATFORM_OPS_KEY \u5DF2\u8BBE\u7F6E\u4F46\u5168\u662F\u7A7A\u767D\uFF0C\u5DF2\u5FFD\u7565\uFF1A\u628A\u5BC6\u94A5\u5199\u8FDB\u8BE5\u53D8\u91CF\u3001\u4F7F\u7528 --platform-ops-key-stdin\uFF0C\u6216\u5728 TTY \u4EA4\u4E92\u8F93\u5165" : "\u7F3A\u5C11\u8FD0\u7EF4\u5BC6\u94A5\uFF1A\u8BBE\u7F6E HCM_PLATFORM_OPS_KEY\u3001\u4F7F\u7528 --platform-ops-key-stdin\uFF0C\u6216\u5728 TTY \u4EA4\u4E92\u8F93\u5165" });
|
|
15888
16013
|
if (blank) io.stderr(`HCM_PLATFORM_OPS_KEY \u5168\u662F\u7A7A\u767D\uFF0C\u5DF2\u5FFD\u7565\uFF1B\u6539\u4ECE ${source} \u8BFB\u53D6
|
|
15889
16014
|
`);
|
|
15890
16015
|
key2 = key2.trim();
|
|
15891
|
-
if (!key2) throw new
|
|
16016
|
+
if (!key2) throw new CliError33({ code: CliErrorCode34.INVALID_ARGUMENT, message: "\u8FD0\u7EF4\u5BC6\u94A5\u4E3A\u7A7A" });
|
|
15892
16017
|
io.stderr(`\u8FD0\u7EF4\u5BC6\u94A5\u6765\u6E90\uFF1A${source} \xB7 \u6307\u7EB9 ${opsKeyFingerprint(key2)}
|
|
15893
16018
|
`);
|
|
15894
16019
|
return { key: key2, source };
|
|
@@ -15897,12 +16022,12 @@ var split = (value) => (Array.isArray(value) ? value : value ? [value] : []).fla
|
|
|
15897
16022
|
function scopeFor(args) {
|
|
15898
16023
|
const only = split(args.only), skip = split(args.skip);
|
|
15899
16024
|
for (const token of [...only, ...skip]) if (!("platform.".startsWith(token) || token.startsWith("platform.")))
|
|
15900
|
-
throw new
|
|
15901
|
-
code:
|
|
16025
|
+
throw new CliError33({
|
|
16026
|
+
code: CliErrorCode34.INVALID_ARGUMENT,
|
|
15902
16027
|
message: `\u8FD0\u7EF4\u89C6\u56FE\u53EA\u770B\u5E73\u53F0\u5C42\uFF1A--only / --skip \u53EA\u63A5\u53D7 platform \u524D\u7F00\uFF0C\u6536\u5230 ${token}`
|
|
15903
16028
|
});
|
|
15904
|
-
if (skip.some((token) => "platform.".startsWith(token))) throw new
|
|
15905
|
-
code:
|
|
16029
|
+
if (skip.some((token) => "platform.".startsWith(token))) throw new CliError33({
|
|
16030
|
+
code: CliErrorCode34.INVALID_ARGUMENT,
|
|
15906
16031
|
message: "\u6392\u9664\u4E86\u5E73\u53F0\u5C42\uFF0C\u8FD0\u7EF4\u89C6\u56FE\u6CA1\u6709\u53EF\u770B\u7684\u68C0\u67E5"
|
|
15907
16032
|
});
|
|
15908
16033
|
return {
|
|
@@ -16058,7 +16183,7 @@ function failure(ctx, env2, health, key2) {
|
|
|
16058
16183
|
}
|
|
16059
16184
|
var ENV_HINT = "hcm env list \u67E5\u770B\u53EF\u9009\u73AF\u5883\uFF1Bhcm env add <\u540D> --endpoint <url> \u767B\u8BB0";
|
|
16060
16185
|
function resolverMessage(error) {
|
|
16061
|
-
if (error instanceof
|
|
16186
|
+
if (error instanceof CliError33 && error.code === CliErrorCode34.NO_ACTIVE_ENV) return "\u672A\u9009\u5B9A\u73AF\u5883\uFF1A\u7528 --env <\u540D> \u6307\u5B9A";
|
|
16062
16187
|
return (error instanceof Error ? error.message : safeError(error)).replace(/\s*(&&\s*)?hcm\s+login\b[^;;\n]*/gi, "");
|
|
16063
16188
|
}
|
|
16064
16189
|
async function runPlatformOps(args, services, readKey = readPlatformOpsKey, onReport) {
|
|
@@ -16067,10 +16192,10 @@ async function runPlatformOps(args, services, readKey = readPlatformOpsKey, onRe
|
|
|
16067
16192
|
try {
|
|
16068
16193
|
resolved = await resolveEnvContext8({ envFlag: args.env }, process.env, await loadGlobalConfig11());
|
|
16069
16194
|
} catch (error2) {
|
|
16070
|
-
throw new
|
|
16195
|
+
throw new CliError33({ code: CliErrorCode34.INVALID_ARGUMENT, message: `${resolverMessage(error2)}\uFF1B${ENV_HINT}` });
|
|
16071
16196
|
}
|
|
16072
|
-
if (!resolved.config.endpoint) throw new
|
|
16073
|
-
code:
|
|
16197
|
+
if (!resolved.config.endpoint) throw new CliError33({
|
|
16198
|
+
code: CliErrorCode34.INVALID_ARGUMENT,
|
|
16074
16199
|
message: `\u672A\u89E3\u6790\u5230 endpoint\uFF1B${ENV_HINT}`
|
|
16075
16200
|
});
|
|
16076
16201
|
printResolvedEnvironment8(resolved);
|
|
@@ -16116,8 +16241,8 @@ async function runPlatformOps(args, services, readKey = readPlatformOpsKey, onRe
|
|
|
16116
16241
|
const error = out && object(out.body) && object(out.body.error) ? out.body.error : void 0;
|
|
16117
16242
|
if (out?.status === 400 && error?.code === "HEALTH_REPORT_INVALID_PARAM") {
|
|
16118
16243
|
const trace = out.headers["x-trace-id"];
|
|
16119
|
-
throw new
|
|
16120
|
-
code:
|
|
16244
|
+
throw new CliError33({
|
|
16245
|
+
code: CliErrorCode34.INVALID_ARGUMENT,
|
|
16121
16246
|
message: `${typeof error.message === "string" ? redact(error.message, key2) : "\u8FD0\u7EF4\u68C0\u67E5\u8303\u56F4\u65E0\u6548"}${scope.only.length || scope.skip.length ? "\uFF1B\u53BB\u6389 --only / --skip \u91CD\u8DD1 hcm chiron doctor --platform-ops \u53EF\u770B\u5230\u5168\u90E8\u5E73\u53F0\u68C0\u67E5" : `\uFF1B\u672C\u6B21\u6CA1\u6709\u5E26 --only / --skip\uFF0C\u53C2\u6570\u4ECD\u88AB\u5224\u65E0\u6548\uFF0C\u5C5E\u670D\u52A1\u7AEF\u7F3A\u9677\uFF1A\u9644 traceId ${trace || "\uFF08\u54CD\u5E94\u672A\u5E26\uFF0C\u9644\u672C\u6B21\u65F6\u95F4\u4E0E\u73AF\u5883\u540D\uFF09"} \u8054\u7CFB\u7814\u53D1`}`
|
|
16122
16247
|
});
|
|
16123
16248
|
}
|
|
@@ -16409,7 +16534,7 @@ var defaultServices = {
|
|
|
16409
16534
|
latestVersion: fetchLatestVersion,
|
|
16410
16535
|
skillsFresh: inspectSkillsFresh,
|
|
16411
16536
|
asAuth: (...args) => ensureAsAuth(...args),
|
|
16412
|
-
probe: (endpoint, token, signal) => httpProbe2(
|
|
16537
|
+
probe: (endpoint, token, signal) => httpProbe2(axios10.create({
|
|
16413
16538
|
baseURL: endpoint,
|
|
16414
16539
|
timeout: 5e3,
|
|
16415
16540
|
maxRedirects: 0,
|
|
@@ -16420,13 +16545,13 @@ var defaultServices = {
|
|
|
16420
16545
|
};
|
|
16421
16546
|
function validate(args) {
|
|
16422
16547
|
for (const [key2, value, choices] of [["output", args.output, ["table", "json", "yaml"]], ["fail-on", args.failOn, ["blocked", "risks"]]])
|
|
16423
|
-
if (value !== void 0 && !choices.includes(value)) throw new
|
|
16424
|
-
code:
|
|
16548
|
+
if (value !== void 0 && !choices.includes(value)) throw new CliError34({
|
|
16549
|
+
code: CliErrorCode35.INVALID_ARGUMENT,
|
|
16425
16550
|
message: `--${key2} \u53EA\u63A5\u53D7 ${choices.join(" / ")}\uFF0C\u6536\u5230 ${value}`
|
|
16426
16551
|
});
|
|
16427
16552
|
const stages = ["handover", "baseline", "configure", "migrate", "integrate", "golive", "operate"];
|
|
16428
|
-
if (args.stage !== void 0 && !stages.includes(args.stage.toLowerCase())) throw new
|
|
16429
|
-
code:
|
|
16553
|
+
if (args.stage !== void 0 && !stages.includes(args.stage.toLowerCase())) throw new CliError34({
|
|
16554
|
+
code: CliErrorCode35.INVALID_ARGUMENT,
|
|
16430
16555
|
message: `--stage \u53EA\u63A5\u53D7 ${stages.join(" / ")}\uFF0C\u6536\u5230 ${args.stage}`
|
|
16431
16556
|
});
|
|
16432
16557
|
if (args.platformOpsKeyStdin && !args.platformOps) invalidScope("--platform-ops-key-stdin \u53EA\u80FD\u4E0E --platform-ops \u540C\u7528");
|
|
@@ -16447,7 +16572,7 @@ var tokens = (value) => (Array.isArray(value) ? value : value ? [value] : []).fl
|
|
|
16447
16572
|
var matches = (id, only, skip) => (!only.length || only.some((t) => id.startsWith(t))) && !skip.some((t) => id.startsWith(t));
|
|
16448
16573
|
var serverCandidate = (t) => ["platform.", "tenant."].some((prefix) => prefix.startsWith(t) || t.startsWith(prefix));
|
|
16449
16574
|
function invalidScope(message) {
|
|
16450
|
-
throw new
|
|
16575
|
+
throw new CliError34({ code: CliErrorCode35.INVALID_ARGUMENT, message });
|
|
16451
16576
|
}
|
|
16452
16577
|
function scopeFor2(args, catalog) {
|
|
16453
16578
|
const only = tokens(args.only), skip = tokens(args.skip), stage = args.stage?.toLowerCase() ?? null;
|
|
@@ -16482,7 +16607,7 @@ async function readCredential(envFlag, root, as) {
|
|
|
16482
16607
|
try {
|
|
16483
16608
|
resolved = await resolveEnvContext9({ envFlag, cwd: root }, process.env, await loadGlobalConfig12());
|
|
16484
16609
|
} catch (error) {
|
|
16485
|
-
if (error instanceof
|
|
16610
|
+
if (error instanceof CliError34 && error.code === CliErrorCode35.ENV_NOT_FOUND) return { resolved: null };
|
|
16486
16611
|
throw error;
|
|
16487
16612
|
}
|
|
16488
16613
|
if (as) return { resolved };
|
|
@@ -16491,14 +16616,14 @@ async function readCredential(envFlag, root, as) {
|
|
|
16491
16616
|
try {
|
|
16492
16617
|
identity3 = await resolveActiveIdentity2({}, process.env, resolved.name);
|
|
16493
16618
|
} catch (error) {
|
|
16494
|
-
if (error instanceof
|
|
16619
|
+
if (error instanceof CliError34 && error.code === CliErrorCode35.IDENTITY_NOT_FOUND) return { resolved, error: found("IDENTITY_NOT_LOGGED_IN") };
|
|
16495
16620
|
throw error;
|
|
16496
16621
|
}
|
|
16497
16622
|
let meta2;
|
|
16498
16623
|
try {
|
|
16499
16624
|
meta2 = await loadIdentity5(identity3);
|
|
16500
16625
|
} catch (error) {
|
|
16501
|
-
if (error instanceof
|
|
16626
|
+
if (error instanceof CliError34 && error.code === CliErrorCode35.IDENTITY_NOT_FOUND) return { resolved, identity: identity3, error: found("IDENTITY_META_INVALID", `\u8EAB\u4EFD ${identity3} \u7684\u5143\u6570\u636E\u4E0D\u5B58\u5728\uFF1B\u91CD\u65B0\u767B\u5F55\u4FEE\u590D`) };
|
|
16502
16627
|
throw error;
|
|
16503
16628
|
}
|
|
16504
16629
|
if (!meta2.env || meta2.env !== resolved.name) return {
|
|
@@ -16540,7 +16665,7 @@ async function prepareContext(args, deps) {
|
|
|
16540
16665
|
const detail = `${safeError(error)}\uFF1B\u53EF\u9009\u73AF\u5883\uFF1A${available.join(", ") || "\uFF08\u65E0\uFF09"}`;
|
|
16541
16666
|
projectObservation = found("ENV_NOT_RESOLVED", detail);
|
|
16542
16667
|
targetEnv = null;
|
|
16543
|
-
const slotMissing = error instanceof
|
|
16668
|
+
const slotMissing = error instanceof CliError34 && error.code === CliErrorCode35.ENV_NOT_FOUND;
|
|
16544
16669
|
const project2 = args.project !== void 0 ? ` --project ${quote(root)}` : "";
|
|
16545
16670
|
const step2 = file ? `hcm chiron env add ${quote(args.env)} --endpoint <\u540E\u7AEF\u5730\u5740> --frontend <\u524D\u7AEF\u5730\u5740> --tenant <\u79DF\u6237\u53F7>${project2}` : slotMissing ? `hcm chiron init --env ${quote(args.env)} --endpoint <\u540E\u7AEF\u5730\u5740> --tenant <\u79DF\u6237\u53F7>${project2}` : `hcm chiron init --env ${quote(args.env)}${project2}`;
|
|
16546
16671
|
if (slotMissing || error instanceof Error && error.message === "\u672C\u673A\u69FD\u4E0D\u5C5E\u4E8E\u5F53\u524D\u9879\u76EE")
|
|
@@ -16708,12 +16833,12 @@ async function chironDoctorCommand(args, deps) {
|
|
|
16708
16833
|
}
|
|
16709
16834
|
}
|
|
16710
16835
|
const data = explainOpsCatalog(args.explain, descriptorReport);
|
|
16711
|
-
process.stdout.write((args.output === "json" || args.output === "yaml" ?
|
|
16836
|
+
process.stdout.write((args.output === "json" || args.output === "yaml" ? formatObject29(data, { format: args.output }) : renderCatalogExplanation(data)) + "\n");
|
|
16712
16837
|
process.exitCode = 0;
|
|
16713
16838
|
return;
|
|
16714
16839
|
}
|
|
16715
16840
|
const report2 = await runPlatformOps(args, { ...defaultServices, ...deps });
|
|
16716
|
-
process.stdout.write((args.output === "json" || args.output === "yaml" ?
|
|
16841
|
+
process.stdout.write((args.output === "json" || args.output === "yaml" ? formatObject29(report2, { format: args.output }) : renderChironDoctor(report2)) + "\n");
|
|
16717
16842
|
process.exitCode = conclude(report2.results, { total: report2.coverage.total, failOn: args.failOn ?? "blocked" }).exitCode;
|
|
16718
16843
|
return;
|
|
16719
16844
|
}
|
|
@@ -16725,12 +16850,12 @@ async function chironDoctorCommand(args, deps) {
|
|
|
16725
16850
|
if (!listing.server.known) process.stderr.write(`\u670D\u52A1\u7AEF\u76EE\u5F55${"partial" in listing.server ? "\u4E0D\u5168" : "\u672A\u53D6\u5230"}\uFF1A${listing.server.reason}
|
|
16726
16851
|
`);
|
|
16727
16852
|
}
|
|
16728
|
-
process.stdout.write((args.output === "json" || args.output === "yaml" ?
|
|
16853
|
+
process.stdout.write((args.output === "json" || args.output === "yaml" ? formatObject29(data, { format: args.output }) : args.list ? renderCatalogList(data) : renderCatalogExplanation(data)) + "\n");
|
|
16729
16854
|
process.exitCode = 0;
|
|
16730
16855
|
return;
|
|
16731
16856
|
}
|
|
16732
16857
|
const report = await runChironDoctor(args, deps);
|
|
16733
|
-
process.stdout.write((args.output === "json" || args.output === "yaml" ?
|
|
16858
|
+
process.stdout.write((args.output === "json" || args.output === "yaml" ? formatObject29(report, { format: args.output }) : renderChironDoctor(report)) + "\n");
|
|
16734
16859
|
process.exitCode = conclude(report.results, {
|
|
16735
16860
|
total: report.coverage.total,
|
|
16736
16861
|
failOn: args.failOn ?? "blocked",
|
|
@@ -16751,11 +16876,11 @@ import { accessSync, constants, readdirSync as readdirSync3 } from "fs";
|
|
|
16751
16876
|
import fs13 from "fs/promises";
|
|
16752
16877
|
import os6 from "os";
|
|
16753
16878
|
import path16 from "path";
|
|
16754
|
-
import { CliError as
|
|
16879
|
+
import { CliError as CliError37, CliErrorCode as CliErrorCode38, formatObject as formatObject30, HcmClient as HcmClient25, loadEnv as loadEnv6 } from "@hcmai/sdk";
|
|
16755
16880
|
import { createRequire } from "module";
|
|
16756
16881
|
|
|
16757
16882
|
// src/commands/chiron-page-cdp.ts
|
|
16758
|
-
import { CliError as
|
|
16883
|
+
import { CliError as CliError35, CliErrorCode as CliErrorCode36 } from "@hcmai/sdk";
|
|
16759
16884
|
|
|
16760
16885
|
// src/commands/chiron-page-shared.ts
|
|
16761
16886
|
function redactTicket(text) {
|
|
@@ -16791,14 +16916,14 @@ function normalizeCdpEndpoint(raw) {
|
|
|
16791
16916
|
try {
|
|
16792
16917
|
url = new URL(candidate);
|
|
16793
16918
|
} catch {
|
|
16794
|
-
throw new
|
|
16919
|
+
throw new CliError35({ code: CliErrorCode36.INVALID_ARGUMENT, message: `--cdp \u8981\u5199\u6210 http://\u4E3B\u673A:\u7AEF\u53E3\uFF08Chrome \u7684 --remote-debugging-port\uFF09\uFF0C\u6536\u5230\u7684\u662F ${text}` });
|
|
16795
16920
|
}
|
|
16796
16921
|
const protocol = url.protocol === "wss:" ? "https:" : url.protocol === "ws:" ? "http:" : url.protocol;
|
|
16797
16922
|
if (protocol !== "http:" && protocol !== "https:") {
|
|
16798
|
-
throw new
|
|
16923
|
+
throw new CliError35({ code: CliErrorCode36.INVALID_ARGUMENT, message: `--cdp \u53EA\u8BA4 http(s) \u6216 ws(s) \u7AEF\u70B9\uFF0C\u6536\u5230\u7684\u662F ${text}` });
|
|
16799
16924
|
}
|
|
16800
16925
|
if (!url.port) {
|
|
16801
|
-
throw new
|
|
16926
|
+
throw new CliError35({ code: CliErrorCode36.INVALID_ARGUMENT, message: `--cdp \u8981\u5E26\u7AEF\u53E3\uFF08Chrome \u542F\u52A8\u65F6 --remote-debugging-port=<\u7AEF\u53E3> \u7684\u90A3\u4E2A\uFF09\uFF0C\u6536\u5230\u7684\u662F ${text}` });
|
|
16802
16927
|
}
|
|
16803
16928
|
return `${protocol}//${url.hostname}:${url.port}`;
|
|
16804
16929
|
}
|
|
@@ -16895,8 +17020,8 @@ async function captureViaCdp(input, io) {
|
|
|
16895
17020
|
const browser = version2?.Browser ? String(version2.Browser) : `attached ${input.endpoint}`;
|
|
16896
17021
|
const target = await io.fetchJson(`${input.endpoint}/json/new?about:blank`, "PUT");
|
|
16897
17022
|
if (!target?.id || !target.webSocketDebuggerUrl) {
|
|
16898
|
-
throw new
|
|
16899
|
-
code:
|
|
17023
|
+
throw new CliError35({
|
|
17024
|
+
code: CliErrorCode36.SERVER_ERROR,
|
|
16900
17025
|
message: `${input.endpoint}/json/new \u6CA1\u6709\u7ED9\u51FA\u6807\u7B7E\u9875\uFF08id / webSocketDebuggerUrl \u7F3A\u5931\uFF09`,
|
|
16901
17026
|
context: { nextStep: "\u786E\u8BA4 Chrome \u662F\u5E26 --remote-debugging-port \u8D77\u7684\uFF0C\u4E14 --cdp \u6307\u5230\u7684\u662F\u5B83" }
|
|
16902
17027
|
});
|
|
@@ -16926,7 +17051,7 @@ async function captureViaCdp(input, io) {
|
|
|
16926
17051
|
});
|
|
16927
17052
|
if (r.exceptionDetails) {
|
|
16928
17053
|
const why = r.exceptionDetails.exception?.description ?? r.exceptionDetails.text ?? "unknown";
|
|
16929
|
-
throw new
|
|
17054
|
+
throw new CliError35({ code: CliErrorCode36.INVALID_ARGUMENT, message: `--eval \u5728\u9875\u9762\u91CC\u629B\u4E86\u5F02\u5E38\uFF1A${redactTicket(why.split("\n")[0] ?? why)}` });
|
|
16930
17055
|
}
|
|
16931
17056
|
evalResult = r.result && "value" in r.result ? toPlainJson(r.result.value) : toPlainJson(r.result?.description);
|
|
16932
17057
|
}
|
|
@@ -16937,7 +17062,7 @@ async function captureViaCdp(input, io) {
|
|
|
16937
17062
|
const dom = typeof domReply.result?.value === "string" ? domReply.result.value : "";
|
|
16938
17063
|
const shot = await session.send("Page.captureScreenshot", { format: "png" });
|
|
16939
17064
|
if (!shot.data) {
|
|
16940
|
-
throw new
|
|
17065
|
+
throw new CliError35({ code: CliErrorCode36.SERVER_ERROR, message: "Page.captureScreenshot \u6CA1\u6709\u8FD4\u56DE\u56FE\u50CF\u6570\u636E" });
|
|
16941
17066
|
}
|
|
16942
17067
|
await io.writeFile(input.screenshot, Buffer.from(shot.data, "base64"));
|
|
16943
17068
|
return { dom, browser, evalResult, navigated, minted };
|
|
@@ -16959,7 +17084,7 @@ var defaultCdpIo = {
|
|
|
16959
17084
|
openSocket: (wsUrl) => new Promise((resolve3, reject) => {
|
|
16960
17085
|
const Ctor = globalThis.WebSocket;
|
|
16961
17086
|
if (!Ctor) {
|
|
16962
|
-
reject(new
|
|
17087
|
+
reject(new CliError35({ code: CliErrorCode36.SERVER_ERROR, message: "\u8FD9\u4E2A Node \u6CA1\u6709\u5168\u5C40 WebSocket\uFF08\u9700\u8981 Node \u2265 22.4\uFF1B22.0\u201322.3 \u8981\u52A0 --experimental-websocket\uFF09" }));
|
|
16963
17088
|
return;
|
|
16964
17089
|
}
|
|
16965
17090
|
const ws = new Ctor(wsUrl);
|
|
@@ -16982,7 +17107,7 @@ var defaultCdpIo = {
|
|
|
16982
17107
|
|
|
16983
17108
|
// src/commands/chiron-page-playwright.ts
|
|
16984
17109
|
import path15 from "path";
|
|
16985
|
-
import { CliError as
|
|
17110
|
+
import { CliError as CliError36, CliErrorCode as CliErrorCode37 } from "@hcmai/sdk";
|
|
16986
17111
|
function playwrightCacheRoot(probe2) {
|
|
16987
17112
|
const override = probe2.env.PLAYWRIGHT_BROWSERS_PATH?.trim();
|
|
16988
17113
|
if (override === "0" && probe2.packageRoot) return path15.join(probe2.packageRoot, ".local-browsers");
|
|
@@ -17025,8 +17150,8 @@ function discoverPlaywrightBrowser(probe2) {
|
|
|
17025
17150
|
const explicit = probe2.env.HCM_PLAYWRIGHT_EXECUTABLE?.trim();
|
|
17026
17151
|
if (explicit) {
|
|
17027
17152
|
if (probe2.executable(explicit)) return { executablePath: explicit, kind: "explicit", from: "HCM_PLAYWRIGHT_EXECUTABLE" };
|
|
17028
|
-
throw new
|
|
17029
|
-
code:
|
|
17153
|
+
throw new CliError36({
|
|
17154
|
+
code: CliErrorCode37.INVALID_ARGUMENT,
|
|
17030
17155
|
message: `HCM_PLAYWRIGHT_EXECUTABLE \u6307\u7684\u6587\u4EF6\u4E0D\u53EF\u6267\u884C\uFF1A${explicit}`,
|
|
17031
17156
|
context: { nextStep: "\u6307\u5230 Playwright \u88C5\u7684 chrome-headless-shell / chrome \u4E8C\u8FDB\u5236\uFF0C\u6216\u53BB\u6389\u8FD9\u4E2A\u53D8\u91CF\u8BA9 CLI \u81EA\u5DF1\u627E" }
|
|
17032
17157
|
});
|
|
@@ -17068,8 +17193,8 @@ async function captureViaPlaywright(input) {
|
|
|
17068
17193
|
}
|
|
17069
17194
|
}
|
|
17070
17195
|
if (!browser) {
|
|
17071
|
-
throw new
|
|
17072
|
-
code:
|
|
17196
|
+
throw new CliError36({
|
|
17197
|
+
code: CliErrorCode37.SERVER_ERROR,
|
|
17073
17198
|
message: `Playwright \u8D77\u4E0D\u4E86\u6D4F\u89C8\u5668\uFF1A${failures.join("\uFF1B")}`,
|
|
17074
17199
|
context: {
|
|
17075
17200
|
nextStep: "\u88C5\u4E00\u4EFD Playwright \u7684 Chromium\uFF1Anpx playwright install chromium-headless-shell\uFF08\u6216 chromium\uFF09\uFF1B\u5DF2\u7ECF\u88C5\u4E86\u4F46\u4E0D\u5728\u7F3A\u7701\u7F13\u5B58\u76EE\u5F55\u5C31 export PLAYWRIGHT_BROWSERS_PATH=<\u76EE\u5F55> \u6216 HCM_PLAYWRIGHT_EXECUTABLE=<\u4E8C\u8FDB\u5236>\uFF1B\u6C99\u7BB1\u8FDE headless shell \u90FD\u8D77\u4E0D\u4E86\u65F6\uFF0C\u5728\u6C99\u7BB1\u5916\u8D77 Chrome \u5E76\u7528 --cdp \u8FDE"
|
|
@@ -17089,7 +17214,7 @@ async function captureViaPlaywright(input) {
|
|
|
17089
17214
|
evalResult = toPlainJson(await page.evaluate(wrapEvalBody(input.evalJs)));
|
|
17090
17215
|
} catch (e) {
|
|
17091
17216
|
const why = (e instanceof Error ? e.message : String(e)).split("\n")[0] ?? "";
|
|
17092
|
-
throw new
|
|
17217
|
+
throw new CliError36({ code: CliErrorCode37.INVALID_ARGUMENT, message: `--eval \u5728\u9875\u9762\u91CC\u629B\u4E86\u5F02\u5E38\uFF1A${redactTicket(why)}` });
|
|
17093
17218
|
}
|
|
17094
17219
|
}
|
|
17095
17220
|
const dom = await page.content();
|
|
@@ -17113,13 +17238,13 @@ function judgePageContent(input) {
|
|
|
17113
17238
|
function parseViewport(size) {
|
|
17114
17239
|
const m = /^(\d+)x(\d+)$/.exec(size.trim());
|
|
17115
17240
|
if (!m) {
|
|
17116
|
-
throw new
|
|
17241
|
+
throw new CliError37({ code: CliErrorCode38.INVALID_ARGUMENT, message: `--size \u8981\u5199\u6210 <\u5BBD>x<\u9AD8>\uFF0C\u4F8B\u5982 1440x900\uFF0C\u6536\u5230\u7684\u662F ${size}` });
|
|
17117
17242
|
}
|
|
17118
17243
|
const width = Number(m[1]);
|
|
17119
17244
|
const height = Number(m[2]);
|
|
17120
17245
|
if (width < VIEWPORT_MIN.width || width > VIEWPORT_MAX.width || height < VIEWPORT_MIN.height || height > VIEWPORT_MAX.height) {
|
|
17121
|
-
throw new
|
|
17122
|
-
code:
|
|
17246
|
+
throw new CliError37({
|
|
17247
|
+
code: CliErrorCode38.INVALID_ARGUMENT,
|
|
17123
17248
|
message: `--size \u8D85\u51FA\u8303\u56F4\uFF1A\u5BBD ${VIEWPORT_MIN.width}..${VIEWPORT_MAX.width}\u3001\u9AD8 ${VIEWPORT_MIN.height}..${VIEWPORT_MAX.height}\uFF0C\u6536\u5230\u7684\u662F ${size}`
|
|
17124
17249
|
});
|
|
17125
17250
|
}
|
|
@@ -17129,23 +17254,23 @@ function parseWaitMs(raw) {
|
|
|
17129
17254
|
if (raw === void 0) return 1e4;
|
|
17130
17255
|
const value = typeof raw === "number" ? raw : Number(raw);
|
|
17131
17256
|
if (!Number.isInteger(value) || value < 0 || value > WAIT_MS_MAX) {
|
|
17132
|
-
throw new
|
|
17257
|
+
throw new CliError37({ code: CliErrorCode38.INVALID_ARGUMENT, message: `--wait-ms \u8981\u662F 0..${WAIT_MS_MAX} \u7684\u6574\u6570\uFF0C\u6536\u5230\u7684\u662F ${raw}` });
|
|
17133
17258
|
}
|
|
17134
17259
|
return value;
|
|
17135
17260
|
}
|
|
17136
17261
|
function resolveEvidenceTarget(projectRoot, out) {
|
|
17137
17262
|
if (!out?.trim()) {
|
|
17138
|
-
throw new
|
|
17263
|
+
throw new CliError37({ code: CliErrorCode38.MISSING_FLAG, message: `\u8981\u4F20 --out <${EVIDENCE_DIR}/\u2026/\u622A\u56FE.png>\uFF1A\u622A\u56FE\u843D\u5728\u54EA\u513F\u5FC5\u987B\u662F\u4F60\u5B9A\u7684\uFF0C\u4E0D\u7531\u547D\u4EE4\u731C` });
|
|
17139
17264
|
}
|
|
17140
17265
|
if (!out.endsWith(".png")) {
|
|
17141
|
-
throw new
|
|
17266
|
+
throw new CliError37({ code: CliErrorCode38.INVALID_ARGUMENT, message: `--out \u8981\u4EE5 .png \u7ED3\u5C3E\uFF0C\u6536\u5230\u7684\u662F ${out}` });
|
|
17142
17267
|
}
|
|
17143
17268
|
const root = path16.resolve(projectRoot);
|
|
17144
17269
|
const evidenceRoot = path16.join(root, EVIDENCE_DIR);
|
|
17145
17270
|
const absolute = path16.resolve(root, out);
|
|
17146
17271
|
if (absolute !== evidenceRoot && !absolute.startsWith(evidenceRoot + path16.sep)) {
|
|
17147
|
-
throw new
|
|
17148
|
-
code:
|
|
17272
|
+
throw new CliError37({
|
|
17273
|
+
code: CliErrorCode38.INVALID_ARGUMENT,
|
|
17149
17274
|
message: `--out \u8981\u843D\u5728\u9879\u76EE\u7684 ${EVIDENCE_DIR}/ \u4E0B\uFF08${evidenceRoot}\uFF09\uFF0C\u6536\u5230\u7684\u662F ${absolute}`
|
|
17150
17275
|
});
|
|
17151
17276
|
}
|
|
@@ -17193,8 +17318,8 @@ async function assertInsideEvidence(deps, evidenceRoot, absolute) {
|
|
|
17193
17318
|
const canonicalParent = await deps.realpath(path16.dirname(absolute));
|
|
17194
17319
|
if (canonicalRoot === null || canonicalParent === null) return;
|
|
17195
17320
|
if (canonicalParent !== canonicalRoot && !canonicalParent.startsWith(canonicalRoot + path16.sep)) {
|
|
17196
|
-
throw new
|
|
17197
|
-
code:
|
|
17321
|
+
throw new CliError37({
|
|
17322
|
+
code: CliErrorCode38.INVALID_ARGUMENT,
|
|
17198
17323
|
message: `--out \u7684\u7236\u76EE\u5F55\u7ECF\u7B26\u53F7\u94FE\u63A5\u8DD1\u51FA\u4E86 ${EVIDENCE_DIR}/\uFF1A${canonicalParent}`
|
|
17199
17324
|
});
|
|
17200
17325
|
}
|
|
@@ -17203,8 +17328,8 @@ async function runChironPage(target, args, deps) {
|
|
|
17203
17328
|
const sitePath = normalizeTarget(target);
|
|
17204
17329
|
const expect = (args.expectText ?? []).filter((t) => t.trim().length > 0);
|
|
17205
17330
|
if (expect.length === 0) {
|
|
17206
|
-
throw new
|
|
17207
|
-
code:
|
|
17331
|
+
throw new CliError37({
|
|
17332
|
+
code: CliErrorCode38.MISSING_FLAG,
|
|
17208
17333
|
message: "\u81F3\u5C11\u8981\u4F20\u4E00\u6761 --expect-text\uFF08\u9875\u9762\u4E0A\u5FC5\u987B\u51FA\u73B0\u7684\u6587\u672C\uFF09\u3002\u53EA\u5224\u300C\u622A\u51FA\u56FE\u4E86\u300D\u4E0D\u7B97\u9A8C\u6536\uFF1A\u767B\u5F55\u9875\u3001\u62A5\u9519\u9875\u3001\u767D\u5C4F\u90FD\u80FD\u622A\u51FA\u56FE\u3002"
|
|
17209
17334
|
});
|
|
17210
17335
|
}
|
|
@@ -17214,8 +17339,8 @@ async function runChironPage(target, args, deps) {
|
|
|
17214
17339
|
const root = path16.resolve(args.project ?? ".");
|
|
17215
17340
|
const { evidenceRoot, absolute } = resolveEvidenceTarget(root, args.out);
|
|
17216
17341
|
if (await deps.present(absolute)) {
|
|
17217
|
-
throw new
|
|
17218
|
-
code:
|
|
17342
|
+
throw new CliError37({
|
|
17343
|
+
code: CliErrorCode38.INVALID_ARGUMENT,
|
|
17219
17344
|
message: `\u622A\u56FE\u5DF2\u5B58\u5728\uFF0C\u4E0D\u8986\u76D6\uFF1A${absolute}\u3002\u6362\u4E2A --out\uFF0C\u6216\u5148\u628A\u65E7\u8BC1\u636E\u632A\u8D70\u3002`
|
|
17220
17345
|
});
|
|
17221
17346
|
}
|
|
@@ -17227,8 +17352,8 @@ async function runChironPage(target, args, deps) {
|
|
|
17227
17352
|
const playwrightBrowser = endpoint || forceSpawn ? null : deps.findPlaywrightBrowser();
|
|
17228
17353
|
const usePlaywright = !endpoint && !forceSpawn && (playwrightBrowser !== null || evalJs !== void 0);
|
|
17229
17354
|
if (evalJs && !endpoint && !usePlaywright) {
|
|
17230
|
-
throw new
|
|
17231
|
-
code:
|
|
17355
|
+
throw new CliError37({
|
|
17356
|
+
code: CliErrorCode38.INVALID_ARGUMENT,
|
|
17232
17357
|
message: "--eval \u9700\u8981 Playwright \u6216 --cdp\uFF1A\u8001\u7684 spawn \u8DEF\u5F84\u53EA\u4F1A --dump-dom\uFF0C\u585E\u4E0D\u8FDB\u811A\u672C\u3002",
|
|
17233
17358
|
context: { nextStep: "npx playwright install chromium-headless-shell\uFF0C\u6216\u5728\u6C99\u7BB1\u5916\u8D77 Chrome \u7528 --cdp \u8FDE" }
|
|
17234
17359
|
});
|
|
@@ -17246,10 +17371,10 @@ async function runChironPage(target, args, deps) {
|
|
|
17246
17371
|
try {
|
|
17247
17372
|
captured = endpoint ? await deps.captureAttached({ endpoint, viewport, waitMs, evalJs, screenshot: absolute, mintUrl: mint }) : await deps.capturePlaywright({ viewport, waitMs, evalJs, screenshot: absolute, browser: playwrightBrowser, mintUrl: mint });
|
|
17248
17373
|
} catch (e) {
|
|
17249
|
-
if (e instanceof
|
|
17374
|
+
if (e instanceof CliError37) throw new CliError37({ code: e.code, message: redactTicket(e.message), context: e.context });
|
|
17250
17375
|
const where = endpoint ? `\u8FDE\u5230 ${endpoint} \u7684 Chrome` : "Playwright \u8D77\u7684\u6D4F\u89C8\u5668";
|
|
17251
|
-
throw new
|
|
17252
|
-
code:
|
|
17376
|
+
throw new CliError37({
|
|
17377
|
+
code: CliErrorCode38.SERVER_ERROR,
|
|
17253
17378
|
message: `${where}\u6CA1\u8DD1\u5B8C\uFF1A${redactTicket(e instanceof Error ? e.message : String(e))}`,
|
|
17254
17379
|
context: {
|
|
17255
17380
|
nextStep: endpoint ? `\u6838\u4E00\u773C ${endpoint}/json/version \u80FD\u4E0D\u80FD\u6253\u5F00\uFF1BChrome \u8981\u5E26 --remote-debugging-port \u8D77\uFF0C\u4E14\u6C99\u7BB1\u653E\u884C\u4E86\u8FD9\u4E2A\u7AEF\u53E3` : "npx playwright install chromium-headless-shell \u540E\u91CD\u8DD1\uFF1B\u6216 HCM_CHIRON_PAGE_DRIVER=spawn \u8D70\u8001\u8DEF\u5F84\u5BF9\u7167"
|
|
@@ -17265,8 +17390,8 @@ async function runChironPage(target, args, deps) {
|
|
|
17265
17390
|
mode = "spawn";
|
|
17266
17391
|
const browser = deps.findBrowser();
|
|
17267
17392
|
if (!browser) {
|
|
17268
|
-
throw new
|
|
17269
|
-
code:
|
|
17393
|
+
throw new CliError37({
|
|
17394
|
+
code: CliErrorCode38.INVALID_ARGUMENT,
|
|
17270
17395
|
message: "\u672C\u673A\u627E\u4E0D\u5230 Playwright \u7684 Chromium\uFF0C\u4E5F\u627E\u4E0D\u5230 Chrome/Chromium\uFF0C\u622A\u4E0D\u4E86\u56FE\u3002",
|
|
17271
17396
|
context: { nextStep: "npx playwright install chromium-headless-shell\uFF08\u6C99\u7BB1\u91CC\u4E5F\u80FD\u8DD1\uFF09\uFF1B\u6216\u88C5\u4E00\u4E2A Chrome / HCM_CHROME_BIN=/\u7EDD\u5BF9\u8DEF\u5F84\uFF1B\u6216\u5728\u6C99\u7BB1\u5916\u8D77 Chrome \u7528 --cdp \u8FDE" }
|
|
17272
17397
|
});
|
|
@@ -17274,8 +17399,8 @@ async function runChironPage(target, args, deps) {
|
|
|
17274
17399
|
minted = await mint();
|
|
17275
17400
|
const result = deps.capture({ browser, argv: chromeArgv({ viewport, waitMs, screenshot: absolute, url: minted.url, isRoot: process.getuid?.() === 0 }) });
|
|
17276
17401
|
if (!result.ok) {
|
|
17277
|
-
throw new
|
|
17278
|
-
code:
|
|
17402
|
+
throw new CliError37({
|
|
17403
|
+
code: CliErrorCode38.SERVER_ERROR,
|
|
17279
17404
|
message: `\u6D4F\u89C8\u5668\u6CA1\u8DD1\u5B8C\uFF1A${redactTicket(result.stderr.trim().split("\n").slice(-1)[0] ?? "\u65E0\u8F93\u51FA")}`,
|
|
17280
17405
|
context: { nextStep: spawnFailureNextStep(browser, result, deps.platform) }
|
|
17281
17406
|
});
|
|
@@ -17285,7 +17410,7 @@ async function runChironPage(target, args, deps) {
|
|
|
17285
17410
|
}
|
|
17286
17411
|
const bytes = await deps.present(absolute) ? await deps.sizeOf(absolute) : 0;
|
|
17287
17412
|
if (bytes === 0) {
|
|
17288
|
-
throw new
|
|
17413
|
+
throw new CliError37({ code: CliErrorCode38.SERVER_ERROR, message: `\u6D4F\u89C8\u5668\u6CA1\u5199\u51FA\u975E\u7A7A PNG\uFF1A${absolute}` });
|
|
17289
17414
|
}
|
|
17290
17415
|
const verdict = judgePageContent({ dom, expect, reject });
|
|
17291
17416
|
return {
|
|
@@ -17348,13 +17473,13 @@ var defaultChironPageDeps = {
|
|
|
17348
17473
|
const envCfg = await loadEnv6(ctx.env);
|
|
17349
17474
|
const frontend = ctx.frontend ?? envCfg.frontend;
|
|
17350
17475
|
if (!frontend?.trim()) {
|
|
17351
|
-
throw new
|
|
17352
|
-
code:
|
|
17476
|
+
throw new CliError37({
|
|
17477
|
+
code: CliErrorCode38.INVALID_ARGUMENT,
|
|
17353
17478
|
message: `env '${ctx.env}' \u6CA1\u914D\u524D\u7AEF\u5730\u5740\uFF0C\u5F00\u4E0D\u4E86\u9875\u9762\u3002`,
|
|
17354
17479
|
context: { nextStep: `hcm env edit frontend <\u524D\u7AEF\u5730\u5740> --env ${ctx.env}` }
|
|
17355
17480
|
});
|
|
17356
17481
|
}
|
|
17357
|
-
const client3 =
|
|
17482
|
+
const client3 = HcmClient25.fromAuthContext(ctx);
|
|
17358
17483
|
const { ticket } = await mintBrowserTicket(client3, ctx.env)();
|
|
17359
17484
|
return { url: buildBrowserLoginUrl(frontend, ticket, sitePath), environment: ctx.env, identity: ctx.identity ?? null };
|
|
17360
17485
|
},
|
|
@@ -17416,7 +17541,7 @@ async function chironPageCommand(target, args, deps = defaultChironPageDeps) {
|
|
|
17416
17541
|
try {
|
|
17417
17542
|
const receipt = await runChironPage(target, args, deps);
|
|
17418
17543
|
const fmt = args.output ?? "table";
|
|
17419
|
-
if (fmt === "json" || fmt === "yaml") process.stdout.write(
|
|
17544
|
+
if (fmt === "json" || fmt === "yaml") process.stdout.write(formatObject30(receipt, { format: fmt }) + "\n");
|
|
17420
17545
|
else process.stdout.write(renderChironPage(receipt) + "\n");
|
|
17421
17546
|
process.exitCode = receipt.ok ? 0 : 3;
|
|
17422
17547
|
} catch (e) {
|
|
@@ -17431,11 +17556,11 @@ import { randomUUID as randomUUID2 } from "crypto";
|
|
|
17431
17556
|
import { promises as fs14 } from "fs";
|
|
17432
17557
|
import path17 from "path";
|
|
17433
17558
|
import yaml3 from "js-yaml";
|
|
17434
|
-
import { formatObject as
|
|
17559
|
+
import { formatObject as formatObject31 } from "@hcmai/sdk";
|
|
17435
17560
|
|
|
17436
17561
|
// src/commands/delivery-action-policy.ts
|
|
17437
17562
|
init_auth_guard();
|
|
17438
|
-
import { HcmClient as
|
|
17563
|
+
import { HcmClient as HcmClient26, classifyEffect } from "@hcmai/sdk";
|
|
17439
17564
|
|
|
17440
17565
|
// src/commands/delivery.ts
|
|
17441
17566
|
import { createHash as createHash9 } from "crypto";
|
|
@@ -17496,7 +17621,8 @@ var GUARDED_EXECUTOR_REASON_CODES = /* @__PURE__ */ new Set([
|
|
|
17496
17621
|
// 报表 / 套打模板回传要先 upload 拿 documentId,再挂到业务对象。文件路径是
|
|
17497
17622
|
// 固定位置参数,prepare 会钉住项目内普通文件的摘要,execute 前重算后才单次执行。
|
|
17498
17623
|
// 2026-09-02 弹性报表顾问仿真已证实这条交付链会在缺受控执行器时中断。
|
|
17499
|
-
"document-upload"
|
|
17624
|
+
"document-upload",
|
|
17625
|
+
"tenant-bootstrap-reconcile"
|
|
17500
17626
|
]);
|
|
17501
17627
|
function normalizeAssessedArgv(inputArgv) {
|
|
17502
17628
|
let rest = inputArgv;
|
|
@@ -17583,7 +17709,7 @@ function classify(argv, actionResolution) {
|
|
|
17583
17709
|
`\u88AB\u8BC4\u4F30\u7684\u547D\u4EE4\u540D\u89E3\u6790\u6210\u4E86 ${name} \u2014\u2014 \u90A3\u662F\u4E00\u4E2A\u9009\u9879\uFF0C\u4E0D\u662F\u547D\u4EE4\u3002next_step=\u4ECE\u547D\u4EE4\u540D\u5F00\u5934\u5199\u6574\u6761\u547D\u4EE4\uFF0C\u628A ${name} \u632A\u5230\u547D\u4EE4\u540D\u540E\u9762\uFF0C\u4F8B\u5982 \`hcm meta set <Model> --env <env>\``
|
|
17584
17710
|
);
|
|
17585
17711
|
}
|
|
17586
|
-
if (argv.some((arg) => APPROVAL_BYPASS_FLAGS.has(flagName(arg)))) {
|
|
17712
|
+
if (argv.some((arg) => APPROVAL_BYPASS_FLAGS.has(flagName(arg)) && !(name === "tenant" && subcommand === "reconcile" && ["-y", "--yes"].includes(flagName(arg))))) {
|
|
17587
17713
|
return forbidden("approval-bypass", "\u547D\u4EE4\u5305\u542B\u8DF3\u8FC7\u786E\u8BA4\u7684\u65D7\u6807\uFF0C\u987E\u95EE\u4EA4\u4ED8\u9762\u4E0D\u6267\u884C\u3002");
|
|
17588
17714
|
}
|
|
17589
17715
|
if (name === "user" && subcommand === "reset-password") {
|
|
@@ -17806,6 +17932,7 @@ function classify(argv, actionResolution) {
|
|
|
17806
17932
|
return forbidden("destructive", "\u5220\u9664\u64CD\u4F5C\u4E0D\u8FDB\u5165\u987E\u95EE\u63D2\u4EF6\u6267\u884C\u9762\u3002");
|
|
17807
17933
|
}
|
|
17808
17934
|
if (name === "tenant") {
|
|
17935
|
+
if (subcommand === "reconcile") return guarded("tenant-config-write", "tenant-bootstrap-reconcile");
|
|
17809
17936
|
return forbidden("tenant-governance", "\u79DF\u6237\u5F00\u901A\u6216\u6CBB\u7406\u5FC5\u987B\u5347\u7EA7\u6CBB\u7406\u4EBA\u5458\u3002");
|
|
17810
17937
|
}
|
|
17811
17938
|
if (name === "login" || name === "logout") {
|
|
@@ -18024,7 +18151,7 @@ async function resolveCoreAction(request) {
|
|
|
18024
18151
|
as: request.identity,
|
|
18025
18152
|
profile: request.profile
|
|
18026
18153
|
});
|
|
18027
|
-
const description = await
|
|
18154
|
+
const description = await HcmClient26.fromAuthContext(auth).describe(request.model);
|
|
18028
18155
|
const named = description.actions.filter((action) => action.name === request.action);
|
|
18029
18156
|
if (named.length === 0) {
|
|
18030
18157
|
const degraded = description.effectiveActionsAvailable ? "" : `\u26A0\uFE0F \u672C\u6B21\u6BD4\u5BF9\u4E0D\u542B\u811A\u672C Action\u2014\u2014${description.effectiveActionsNote ?? "\u539F\u56E0\u672A\u77E5"}\u3002`;
|
|
@@ -18466,7 +18593,7 @@ async function chironTestCommand(target, args, deps) {
|
|
|
18466
18593
|
}
|
|
18467
18594
|
const fmt = args.output ?? "table";
|
|
18468
18595
|
if (fmt === "json" || fmt === "yaml") {
|
|
18469
|
-
process.stdout.write(
|
|
18596
|
+
process.stdout.write(formatObject31({ ok: failed2 === 0, failed: failed2, cases: report }, { format: fmt }) + "\n");
|
|
18470
18597
|
} else {
|
|
18471
18598
|
for (const c2 of report) {
|
|
18472
18599
|
process.stdout.write(`
|
|
@@ -18495,12 +18622,12 @@ ${failed2} \u6761\u6CA1\u8FC7\u2014\u2014\u4E0A\u9762\u6BCF\u6761\u90FD\u5199\u4
|
|
|
18495
18622
|
init_auth_guard();
|
|
18496
18623
|
init_exit();
|
|
18497
18624
|
import {
|
|
18498
|
-
HcmClient as
|
|
18625
|
+
HcmClient as HcmClient27,
|
|
18499
18626
|
ReconLayout,
|
|
18500
18627
|
ROUND_EXIT_CODES,
|
|
18501
18628
|
computeReconSourceKey,
|
|
18502
|
-
formatObject as
|
|
18503
|
-
fromAxiosError as
|
|
18629
|
+
formatObject as formatObject32,
|
|
18630
|
+
fromAxiosError as fromAxiosError25,
|
|
18504
18631
|
httpProbe as httpProbe3,
|
|
18505
18632
|
inspectRound,
|
|
18506
18633
|
renderRound,
|
|
@@ -18510,7 +18637,7 @@ var DEFAULT_CAPABILITIES = "default";
|
|
|
18510
18637
|
async function deliveryReconCommand(args) {
|
|
18511
18638
|
try {
|
|
18512
18639
|
const ctx = await getActiveAuthContextFromCli(args);
|
|
18513
|
-
const client3 =
|
|
18640
|
+
const client3 = HcmClient27.fromAuthContext(ctx);
|
|
18514
18641
|
const probe2 = httpProbe3(client3.raw(), args.capabilities ?? DEFAULT_CAPABILITIES);
|
|
18515
18642
|
const sourceKey = await computeReconSourceKey(probe2);
|
|
18516
18643
|
const layout = new ReconLayout(args.out ?? ".", ctx.tenantId, sourceKey);
|
|
@@ -18519,10 +18646,10 @@ async function deliveryReconCommand(args) {
|
|
|
18519
18646
|
onlyModel: args.model ?? null,
|
|
18520
18647
|
identity: ctx.tenantId ? { requestedTenantId: ctx.tenantId } : null
|
|
18521
18648
|
});
|
|
18522
|
-
process.stdout.write(
|
|
18649
|
+
process.stdout.write(formatObject32(summary, { format: args.output ?? "json" }) + "\n");
|
|
18523
18650
|
} catch (e) {
|
|
18524
18651
|
const err = e;
|
|
18525
|
-
if (err?.isAxiosError) exitWithError(
|
|
18652
|
+
if (err?.isAxiosError) exitWithError(fromAxiosError25(err, args.env));
|
|
18526
18653
|
exitWithError(e);
|
|
18527
18654
|
process.exit(1);
|
|
18528
18655
|
}
|
|
@@ -18533,7 +18660,7 @@ async function deliveryReconRoundCommand(args) {
|
|
|
18533
18660
|
const result = inspectRound(args.dir ?? ".");
|
|
18534
18661
|
const fmt = args.output ?? "json";
|
|
18535
18662
|
if (fmt !== "json") process.stdout.write(renderRound(result));
|
|
18536
|
-
process.stdout.write(
|
|
18663
|
+
process.stdout.write(formatObject32(result, { format: fmt }) + "\n");
|
|
18537
18664
|
code2 = ROUND_EXIT_CODES[result.state];
|
|
18538
18665
|
} catch (e) {
|
|
18539
18666
|
exitWithError(e);
|
|
@@ -18553,7 +18680,7 @@ import {
|
|
|
18553
18680
|
DRY_RUN_TAIL,
|
|
18554
18681
|
DriftDetected,
|
|
18555
18682
|
FORCE_STALE_FLAG,
|
|
18556
|
-
HcmClient as
|
|
18683
|
+
HcmClient as HcmClient28,
|
|
18557
18684
|
fetchReconIdentity as fetchReconIdentity2,
|
|
18558
18685
|
INIT_EXIT_CODES,
|
|
18559
18686
|
JOURNAL_STOP_KINDS,
|
|
@@ -18693,7 +18820,7 @@ async function authOrSignpost(args, cmd) {
|
|
|
18693
18820
|
}
|
|
18694
18821
|
async function deliverySeedPlanCommand(args) {
|
|
18695
18822
|
const ctx = await authOrSignpost(args, "plan");
|
|
18696
|
-
const client3 =
|
|
18823
|
+
const client3 = HcmClient28.fromAuthContext(ctx);
|
|
18697
18824
|
process.exitCode = await runSeedPlan(args, seedClient(client3, ctx));
|
|
18698
18825
|
}
|
|
18699
18826
|
function seedClient(client3, ctx) {
|
|
@@ -18867,7 +18994,7 @@ async function runSeedApply(args, client3) {
|
|
|
18867
18994
|
}
|
|
18868
18995
|
async function deliverySeedApplyCommand(args) {
|
|
18869
18996
|
const ctx = await authOrSignpost(args, "apply");
|
|
18870
|
-
const client3 =
|
|
18997
|
+
const client3 = HcmClient28.fromAuthContext(ctx);
|
|
18871
18998
|
process.exitCode = await runSeedApply(args, seedClient(client3, ctx));
|
|
18872
18999
|
}
|
|
18873
19000
|
async function runSeedVerify(args, client3) {
|
|
@@ -18891,7 +19018,7 @@ async function deliverySeedVerifyCommand(args) {
|
|
|
18891
19018
|
return;
|
|
18892
19019
|
}
|
|
18893
19020
|
const ctx = await authOrSignpost(args, "verify");
|
|
18894
|
-
const client3 =
|
|
19021
|
+
const client3 = HcmClient28.fromAuthContext(ctx);
|
|
18895
19022
|
process.exitCode = await runSeedVerify(args, await seedVerifyClient(client3, ctx));
|
|
18896
19023
|
}
|
|
18897
19024
|
|
|
@@ -19006,7 +19133,7 @@ import {
|
|
|
19006
19133
|
CHANGE_STATES,
|
|
19007
19134
|
CHANGE_UNKNOWN,
|
|
19008
19135
|
CODE_WORDS,
|
|
19009
|
-
HcmClient as
|
|
19136
|
+
HcmClient as HcmClient29,
|
|
19010
19137
|
INIT_EXIT_CODES as INIT_EXIT_CODES3,
|
|
19011
19138
|
META_WRITE_STEPS,
|
|
19012
19139
|
META_VERIFY_STEPS,
|
|
@@ -19234,7 +19361,7 @@ function lowerCaseHeaders2(headers) {
|
|
|
19234
19361
|
}
|
|
19235
19362
|
async function deliveryMetaCommand(args) {
|
|
19236
19363
|
const ctx = await getActiveAuthContextFromCli(args);
|
|
19237
|
-
const client3 =
|
|
19364
|
+
const client3 = HcmClient29.fromAuthContext(ctx);
|
|
19238
19365
|
process.exitCode = await runDeliveryMeta(
|
|
19239
19366
|
{ ...args, tenant: args.tenant ?? String(ctx.tenantId ?? "") },
|
|
19240
19367
|
metaClient(client3, ctx)
|
|
@@ -19246,7 +19373,7 @@ init_auth_guard();
|
|
|
19246
19373
|
init_exit();
|
|
19247
19374
|
import {
|
|
19248
19375
|
computeReconSourceKey as computeReconSourceKey2,
|
|
19249
|
-
HcmClient as
|
|
19376
|
+
HcmClient as HcmClient30,
|
|
19250
19377
|
httpProbe as httpProbe4,
|
|
19251
19378
|
ReconLayout as ReconLayout2,
|
|
19252
19379
|
runTriageRound
|
|
@@ -19302,7 +19429,7 @@ async function runTriage(args) {
|
|
|
19302
19429
|
return premise4(e instanceof Error ? e.message : String(e), REQUESTS_SHAPE);
|
|
19303
19430
|
}
|
|
19304
19431
|
const ctx = await getActiveAuthContextFromCli(args);
|
|
19305
|
-
const client3 =
|
|
19432
|
+
const client3 = HcmClient30.fromAuthContext(ctx);
|
|
19306
19433
|
const probe2 = httpProbe4(client3.raw(), args.capabilities ?? DEFAULT_CAPABILITIES3);
|
|
19307
19434
|
const artifactsDir = args.recon ?? new ReconLayout2(args.out ?? ".", ctx.tenantId, await computeReconSourceKey2(probe2)).dir;
|
|
19308
19435
|
const result = await runTriageRound(probe2, artifactsDir, entriesIn);
|
|
@@ -19331,25 +19458,25 @@ async function deliveryTriageCommand(args) {
|
|
|
19331
19458
|
init_auth_guard();
|
|
19332
19459
|
init_exit();
|
|
19333
19460
|
import {
|
|
19334
|
-
HcmClient as
|
|
19461
|
+
HcmClient as HcmClient31,
|
|
19335
19462
|
adminResetPassword,
|
|
19336
|
-
formatObject as
|
|
19337
|
-
fromAxiosError as
|
|
19338
|
-
CliError as
|
|
19339
|
-
CliErrorCode as
|
|
19463
|
+
formatObject as formatObject33,
|
|
19464
|
+
fromAxiosError as fromAxiosError26,
|
|
19465
|
+
CliError as CliError38,
|
|
19466
|
+
CliErrorCode as CliErrorCode39
|
|
19340
19467
|
} from "@hcmai/sdk";
|
|
19341
19468
|
function buildAdminResetPasswordRequest(args, password) {
|
|
19342
19469
|
const hasId = Boolean(args.id);
|
|
19343
19470
|
const hasUsername = Boolean(args.username);
|
|
19344
19471
|
if (hasId === hasUsername) {
|
|
19345
|
-
throw new
|
|
19346
|
-
code:
|
|
19472
|
+
throw new CliError38({
|
|
19473
|
+
code: CliErrorCode39.INVALID_ARGUMENT,
|
|
19347
19474
|
message: "--id <uuid> \u4E0E --username <user> \u5FC5\u987B\u4E14\u53EA\u80FD\u63D0\u4F9B\u4E00\u4E2A"
|
|
19348
19475
|
});
|
|
19349
19476
|
}
|
|
19350
19477
|
if (!password) {
|
|
19351
|
-
throw new
|
|
19352
|
-
code:
|
|
19478
|
+
throw new CliError38({
|
|
19479
|
+
code: CliErrorCode39.INVALID_ARGUMENT,
|
|
19353
19480
|
message: "\u65B0\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A"
|
|
19354
19481
|
});
|
|
19355
19482
|
}
|
|
@@ -19365,12 +19492,12 @@ async function userResetPasswordCommand(args) {
|
|
|
19365
19492
|
try {
|
|
19366
19493
|
const password = args.passwordStdin ? await readSecretFromStdin() : await promptPasswordTwice();
|
|
19367
19494
|
const request = buildAdminResetPasswordRequest(args, password);
|
|
19368
|
-
const client3 =
|
|
19495
|
+
const client3 = HcmClient31.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
19369
19496
|
const result = await adminResetPassword(client3.raw(), request);
|
|
19370
|
-
process.stdout.write(
|
|
19497
|
+
process.stdout.write(formatObject33(result, { format: args.output ?? "json" }) + "\n");
|
|
19371
19498
|
} catch (cause) {
|
|
19372
19499
|
const err = cause;
|
|
19373
|
-
if (err?.isAxiosError) exitWithError(
|
|
19500
|
+
if (err?.isAxiosError) exitWithError(fromAxiosError26(err, args.env));
|
|
19374
19501
|
exitWithError(cause);
|
|
19375
19502
|
}
|
|
19376
19503
|
}
|
|
@@ -19378,8 +19505,8 @@ async function promptPasswordTwice() {
|
|
|
19378
19505
|
const password = await promptSecret("\u65B0\u5BC6\u7801: ");
|
|
19379
19506
|
const confirmation = await promptSecret("\u518D\u6B21\u8F93\u5165\u65B0\u5BC6\u7801: ");
|
|
19380
19507
|
if (password !== confirmation) {
|
|
19381
|
-
throw new
|
|
19382
|
-
code:
|
|
19508
|
+
throw new CliError38({
|
|
19509
|
+
code: CliErrorCode39.INVALID_ARGUMENT,
|
|
19383
19510
|
message: "\u4E24\u6B21\u8F93\u5165\u7684\u65B0\u5BC6\u7801\u4E0D\u4E00\u81F4"
|
|
19384
19511
|
});
|
|
19385
19512
|
}
|
|
@@ -19390,19 +19517,19 @@ async function promptPasswordTwice() {
|
|
|
19390
19517
|
init_exit();
|
|
19391
19518
|
init_auth_guard();
|
|
19392
19519
|
import {
|
|
19393
|
-
HcmClient as
|
|
19394
|
-
formatObject as
|
|
19395
|
-
fromAxiosError as
|
|
19520
|
+
HcmClient as HcmClient32,
|
|
19521
|
+
formatObject as formatObject34,
|
|
19522
|
+
fromAxiosError as fromAxiosError27
|
|
19396
19523
|
} from "@hcmai/sdk";
|
|
19397
19524
|
async function modelsCommand(keyword, args) {
|
|
19398
19525
|
try {
|
|
19399
|
-
const client3 =
|
|
19526
|
+
const client3 = HcmClient32.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
19400
19527
|
const all = await client3.listModels();
|
|
19401
19528
|
const needle = keyword?.trim().toLowerCase();
|
|
19402
19529
|
const rows2 = (needle ? all.filter((m) => JSON.stringify(m).toLowerCase().includes(needle)) : all).sort((a, b) => key(a).localeCompare(key(b)));
|
|
19403
19530
|
const fmt = args.output ?? "table";
|
|
19404
19531
|
if (fmt !== "table") {
|
|
19405
|
-
process.stdout.write(
|
|
19532
|
+
process.stdout.write(formatObject34({ total: rows2.length, models: rows2 }, { format: fmt }) + "\n");
|
|
19406
19533
|
process.exitCode = 0;
|
|
19407
19534
|
return;
|
|
19408
19535
|
}
|
|
@@ -19429,7 +19556,7 @@ async function modelsCommand(keyword, args) {
|
|
|
19429
19556
|
return;
|
|
19430
19557
|
} catch (e) {
|
|
19431
19558
|
const err = e;
|
|
19432
|
-
if (err?.isAxiosError) exitWithError(
|
|
19559
|
+
if (err?.isAxiosError) exitWithError(fromAxiosError27(err, args.profile));
|
|
19433
19560
|
exitWithError(e);
|
|
19434
19561
|
}
|
|
19435
19562
|
}
|
|
@@ -19676,7 +19803,7 @@ workspace.command("bind <workspaceKey>").description("\u628A\u5F53\u524D\u76EE\u
|
|
|
19676
19803
|
workspace.command("create <workspaceKey>").description("\u65B0\u5EFA\u79DF\u6237\u5F00\u53D1\u7A7A\u95F4\uFF0C\u5E76\u5728\u672C\u5730\u76EE\u5F55\u5199\u5165 workspace \u7ED1\u5B9A").option("--dir <path>", "\u5DE5\u4F5C\u7A7A\u95F4\u672C\u5730\u76EE\u5F55", ".").option("--description <text>", "\u5F00\u53D1\u7A7A\u95F4\u8BF4\u660E").option("--activate", "\u521B\u5EFA\u540E\u7ED1\u5B9A\u4E3A\u5F53\u524D\u5F00\u53D1\u7A7A\u95F4").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--profile <name>", "[deprecated] \u7528 --env \u66FF\u4EE3").option("--force", "\u672C\u5730\u76EE\u5F55\u5DF2\u6709\u4E0D\u540C workspace \u7ED1\u5B9A\u65F6\u5F3A\u5236\u8986\u76D6").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((workspaceKey, opts) => workspaceCreateCommand(workspaceKey, opts));
|
|
19677
19804
|
workspace.command("pull").description("\u4ECE\u5F00\u53D1\u7A7A\u95F4\u62C9\u53D6\u6587\u4EF6\u5305\u5230\u672C\u5730\uFF1Bmini_apps \u4F1A\u751F\u6210\u53EF\u9A8C\u8BC1\u7684 artifact \u4E0A\u4E0B\u6587").option("--workspace <key>", "\u79DF\u6237\u5F00\u53D1\u7A7A\u95F4 key\uFF1B\u672A\u63D0\u4F9B\u65F6\u8BFB\u53D6\u672C\u5730\u7ED1\u5B9A").option("--dir <path>", "\u5DE5\u4F5C\u7A7A\u95F4\u672C\u5730\u76EE\u5F55", ".").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--profile <name>", "[deprecated] \u7528 --env \u66FF\u4EE3").option("--force", "\u5F3A\u5236\u8986\u76D6\u5DF2\u6709\u7684\u672C\u5730\u6587\u4EF6").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((opts) => workspacePullCommand(opts));
|
|
19678
19805
|
var workspaceAdd = workspace.command("add").description("\u5411\u5DF2\u7ED1\u5B9A\u5F00\u53D1\u7A7A\u95F4\u6DFB\u52A0 artifact");
|
|
19679
|
-
workspaceAdd.command("mini <appCode>").description("\u65B0\u589E\u8F7B\u5E94\u7528 artifact\uFF08\u5199\u5165 mini_apps/<appCode>/\uFF09").option("--dir <path>", "\u5DE5\u4F5C\u7A7A\u95F4\u672C\u5730\u76EE\u5F55", ".").option("--name <name>", "\u8F7B\u5E94\u7528\u5C55\u793A\u540D").option("--template <kind>", "\u6A21\u677F\uFF1Adashboard | multi-page | writable-workbench", "dashboard").option("--model <Model>", "\u53EF\u5199\u5DE5\u4F5C\u53F0\u7ED1\u5B9A\u7684 Model\uFF0C\u4F8B\u5982 OrgUnit").option("--fields <csv|auto>", "\u53EF\u5199\u5DE5\u4F5C\u53F0\u8868\u5355\u5B57\u6BB5\u5217\u8868\uFF1B\u4F20 auto \u65F6\u6839\u636E Model \u5143\u6570\u636E\u63A8\u65AD").option("--defaults <JSON|auto>", "\u53EF\u5199\u5DE5\u4F5C\u53F0\u521B\u5EFA\u9ED8\u8BA4\u503C\uFF1B\u4F20 auto \u65F6\u6839\u636E Model \u5143\u6570\u636E\u63A8\u65AD").option(
|
|
19806
|
+
workspaceAdd.command("mini <appCode>").description("\u65B0\u589E\u8F7B\u5E94\u7528 artifact\uFF08\u5199\u5165 mini_apps/<appCode>/\uFF09").option("--dir <path>", "\u5DE5\u4F5C\u7A7A\u95F4\u672C\u5730\u76EE\u5F55", ".").option("--name <name>", "\u8F7B\u5E94\u7528\u5C55\u793A\u540D").option("--template <kind>", "\u6A21\u677F\uFF1Adashboard | multi-page | writable-workbench", "dashboard").option("--sdk-version <semver>", "\u76EE\u6807 Core \u7684\u8F7B\u5E94\u7528\u8FD0\u884C\u65F6 ABI\uFF08\u9ED8\u8BA4 0.1.0\uFF0C\u72EC\u7ACB\u4E8E CLI \u5305\u7248\u672C\uFF1B\u4E0D\u63A2\u6D4B\u7EBF\u4E0A\u7248\u672C\uFF09").option("--model <Model>", "\u53EF\u5199\u5DE5\u4F5C\u53F0\u7ED1\u5B9A\u7684 Model\uFF0C\u4F8B\u5982 OrgUnit").option("--fields <csv|auto>", "\u53EF\u5199\u5DE5\u4F5C\u53F0\u8868\u5355\u5B57\u6BB5\u5217\u8868\uFF1B\u4F20 auto \u65F6\u6839\u636E Model \u5143\u6570\u636E\u63A8\u65AD").option("--defaults <JSON|auto>", "\u53EF\u5199\u5DE5\u4F5C\u53F0\u521B\u5EFA\u9ED8\u8BA4\u503C\uFF1B\u4F20 auto \u65F6\u6839\u636E Model \u5143\u6570\u636E\u63A8\u65AD").option(
|
|
19680
19807
|
"--surface <surface>",
|
|
19681
19808
|
"\u8FD0\u884C\u5F62\u6001\uFF1Aembedded\uFF08\u5D4C\u5165\u4E1A\u52A1\u9875\uFF09| standalone\uFF08\u72EC\u7ACB\u9875\uFF09",
|
|
19682
19809
|
"embedded"
|
|
@@ -19712,6 +19839,7 @@ datapackage.command("pack <packageDir>").description("\u628A\u5305\u76EE\u5F55\u
|
|
|
19712
19839
|
datapackage.command("install <artifact>").description("\u4E0A\u4F20 .hcmpkg \u5236\u54C1\u5E76\u7ECF\u670D\u52A1\u7AEF\u5F02\u6B65\u5B89\u88C5\u5668\u5B89\u88C5\uFF0C\u5B9E\u65F6\u663E\u793A\u8FDB\u5EA6\uFF08admin.system\uFF09").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD").option("--category <name>", "\u5236\u54C1\u4E0A\u4F20\u7684\u5B58\u50A8\u5206\u7C7B\uFF08\u670D\u52A1\u7AEF\u6570\u636E\u975E\u679A\u4E3E\uFF09", "attachment").option("--no-wait", "\u53EA\u53D7\u7406\u4E0D\u7B49\u5F85\uFF0C\u7ACB\u523B\u8FD4\u56DE runId").option("--timeout <sec>", "\u7B49\u5F85\u4E0A\u9650\uFF08\u79D2\uFF09\uFF1B\u7B49\u4E0D\u5230\u4E0D\u662F\u5931\u8D25\uFF0C\u88C5\u8F7D\u5728\u670D\u52A1\u7AEF\u7EE7\u7EED", "900").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((artifact, opts) => datapackageInstallCommand(artifact, opts));
|
|
19713
19840
|
datapackage.command("status <runId>").description("\u67E5\u770B\u88C5\u8F7D\u6D41\u6C34\u8FDB\u5EA6/\u7EC8\u6001\uFF08\u914D\u5408 install --no-wait \u6216\u7B49\u5F85\u8D85\u65F6\u540E\u4F7F\u7528\uFF09").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((runId, opts) => datapackageStatusCommand(runId, opts));
|
|
19714
19841
|
var tenant = program.command("tenant").description("\u79DF\u6237\u5F00\u901A\u4E0E\u751F\u547D\u5468\u671F");
|
|
19842
|
+
tenant.command("reconcile").description("\u4EE5\u5F53\u524D\u79DF\u6237\u7BA1\u7406\u5458\u666E\u901A\u4F1A\u8BDD\u8865\u8DD1\u521D\u59CB\u5316\u5230\u6700\u65B0 catalog\uFF0C\u5E76\u72EC\u7ACB\u590D\u9A8C\uFF1B\u4E0D\u91CD\u7F6E\u3001\u4E0D\u8DE8\u79DF\u6237").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("-y, --yes", "\u5DF2\u53D6\u5F97\u672C\u6B21\u8865\u8DD1\u6388\u6743\uFF0C\u8DF3\u8FC7\u4EA4\u4E92\u786E\u8BA4").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((opts) => tenantReconcileCommand(opts));
|
|
19715
19843
|
tenant.command("reset").description("\u4EE5\u5F53\u524D\u79DF\u6237\u5185\u7F6E admin \u91CD\u7F6E PostgreSQL \u5230\u51FA\u5382\u57FA\u7EBF\uFF1B\u4E0D\u53EF\u9006\uFF0C\u975E PG \u672A\u5904\u7406\u672A\u6838\u9A8C").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4F7F\u7528\u8BE5\u73AF\u5883\u7684\u76F4\u63A5\u767B\u5F55\u8EAB\u4EFD\uFF0C\u4E0D\u63A5\u53D7\u4EE3\u7406").option("-y, --yes", "\u786E\u8BA4\u91CD\u7F6E\u5DF2\u6838\u9A8C\u7684\u5F53\u524D\u79DF\u6237\uFF0C\u8DF3\u8FC7\u4EA4\u4E92").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((opts) => tenantResetCommand(opts));
|
|
19716
19844
|
tenant.command("bootstrap").description("\u5F00\u901A\u65B0\u79DF\u6237\uFF08\u5EFA\u79DF\u6237 + admin \u7528\u6237 + \u7ED3\u6784 reconcile\uFF09\u2014\u2014\u4E0D\u53EF\u9006\uFF0C\u9ED8\u8BA4\u8FC7\u786E\u8BA4\u95F8").requiredOption("--tenant-id <id>", "\u79DF\u6237 ID").option("--admin-username <user>", "\u7BA1\u7406\u5458\u7528\u6237\u540D\uFF08\u670D\u52A1\u7AEF\u4EC5\u63A5\u53D7 admin\uFF09", "admin").option(
|
|
19717
19845
|
"--admin-password <pwd>",
|