@hcmai/cli 0.22.1 → 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 +452 -325
- package/dist/index.js.map +1 -1
- package/dist/skills/manifest.json +9 -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({
|
|
@@ -10253,7 +10377,7 @@ async function workspaceRmCommand(relativePath, args) {
|
|
|
10253
10377
|
if (!stat) {
|
|
10254
10378
|
if (manifestEntry) {
|
|
10255
10379
|
process.stdout.write(
|
|
10256
|
-
|
|
10380
|
+
formatObject23(
|
|
10257
10381
|
{
|
|
10258
10382
|
workspaceKey: context.workspaceKey,
|
|
10259
10383
|
file: normalized,
|
|
@@ -10278,7 +10402,7 @@ async function workspaceRmCommand(relativePath, args) {
|
|
|
10278
10402
|
next: `hcm workspace push --dir ${args.dir ?? "."}`
|
|
10279
10403
|
};
|
|
10280
10404
|
if (args.output === "json" || args.output === "yaml") {
|
|
10281
|
-
process.stdout.write(
|
|
10405
|
+
process.stdout.write(formatObject23(result, { format: args.output }) + "\n");
|
|
10282
10406
|
} else {
|
|
10283
10407
|
process.stdout.write(`workspace file staged for deletion: ${normalized}
|
|
10284
10408
|
`);
|
|
@@ -10325,7 +10449,7 @@ async function workspaceStatusCommand(args) {
|
|
|
10325
10449
|
}
|
|
10326
10450
|
if (args.output === "json" || args.output === "yaml") {
|
|
10327
10451
|
process.stdout.write(
|
|
10328
|
-
|
|
10452
|
+
formatObject23({ rootDir, miniApps: rows2 }, { format: args.output }) + "\n"
|
|
10329
10453
|
);
|
|
10330
10454
|
} else {
|
|
10331
10455
|
process.stdout.write(formatRows6(rows2, { format: "table" }) + "\n");
|
|
@@ -10386,13 +10510,13 @@ async function workspacePushCommand(args) {
|
|
|
10386
10510
|
for (const app of miniApps) {
|
|
10387
10511
|
const validation = await validateMiniProject(app.dir);
|
|
10388
10512
|
if (!validation.valid) {
|
|
10389
|
-
throw new
|
|
10390
|
-
code:
|
|
10513
|
+
throw new CliError26({
|
|
10514
|
+
code: CliErrorCode27.INVALID_ARGUMENT,
|
|
10391
10515
|
message: `mini app ${app.appCode} validation failed: ${validation.errors.join("; ")}`
|
|
10392
10516
|
});
|
|
10393
10517
|
}
|
|
10394
10518
|
}
|
|
10395
|
-
const client3 =
|
|
10519
|
+
const client3 = HcmClient23.fromAuthContext(
|
|
10396
10520
|
await getActiveAuthContextFromCli(args, { fallbackEnv: context.profile })
|
|
10397
10521
|
);
|
|
10398
10522
|
profile = client3.profile ?? profile;
|
|
@@ -10435,8 +10559,8 @@ async function workspacePushCommand(args) {
|
|
|
10435
10559
|
return;
|
|
10436
10560
|
} catch (e) {
|
|
10437
10561
|
let failure2 = e;
|
|
10438
|
-
if (e instanceof
|
|
10439
|
-
failure2 = new
|
|
10562
|
+
if (e instanceof CliError26 && pushProgress && !e.context?.push) {
|
|
10563
|
+
failure2 = new CliError26({
|
|
10440
10564
|
code: e.code,
|
|
10441
10565
|
message: e.message,
|
|
10442
10566
|
traceId: e.traceId,
|
|
@@ -10473,7 +10597,7 @@ async function workspacePreviewCommand(args) {
|
|
|
10473
10597
|
);
|
|
10474
10598
|
}
|
|
10475
10599
|
if (args.output === "json" || args.output === "yaml") {
|
|
10476
|
-
process.stdout.write(
|
|
10600
|
+
process.stdout.write(formatObject23(rows2, { format: args.output }) + "\n");
|
|
10477
10601
|
} else {
|
|
10478
10602
|
process.stdout.write(formatRows6(rows2, { format: "table" }) + "\n");
|
|
10479
10603
|
}
|
|
@@ -10621,8 +10745,8 @@ async function assertWorkspacePushRoot(rootDir) {
|
|
|
10621
10745
|
}
|
|
10622
10746
|
if (!insideMiniApp && (!workspaceRoot || workspaceRoot === realRoot)) return;
|
|
10623
10747
|
const target = workspaceRoot ? quoteWorkspaceArg(workspaceRoot) : "<workspace-root>";
|
|
10624
|
-
throw new
|
|
10625
|
-
code:
|
|
10748
|
+
throw new CliError26({
|
|
10749
|
+
code: CliErrorCode27.INVALID_ARGUMENT,
|
|
10626
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`,
|
|
10627
10751
|
context: {
|
|
10628
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`
|
|
@@ -10815,8 +10939,8 @@ async function pushWorkspaceRawFiles(args) {
|
|
|
10815
10939
|
);
|
|
10816
10940
|
if (args.dryRun) return result;
|
|
10817
10941
|
if (result.preflight.status === "failed") {
|
|
10818
|
-
throw new
|
|
10819
|
-
code:
|
|
10942
|
+
throw new CliError26({
|
|
10943
|
+
code: CliErrorCode27.INVALID_ARGUMENT,
|
|
10820
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
|
|
10821
10945
|
${formatPreflightIssues(result.preflight.issues, " ")}`,
|
|
10822
10946
|
profile: args.profile ?? args.context.profile,
|
|
@@ -10901,29 +11025,29 @@ ${formatPreflightIssues(result.preflight.issues, " ")}`,
|
|
|
10901
11025
|
checkpointSaved
|
|
10902
11026
|
});
|
|
10903
11027
|
} catch (error) {
|
|
10904
|
-
const translated = error?.isAxiosError ?
|
|
11028
|
+
const translated = error?.isAxiosError ? fromAxiosError23(error, args.profile ?? args.context.profile) : error;
|
|
10905
11029
|
const push = progress();
|
|
10906
11030
|
args.onProgress?.(push);
|
|
10907
|
-
throw new
|
|
10908
|
-
code: translated instanceof
|
|
11031
|
+
throw new CliError26({
|
|
11032
|
+
code: translated instanceof CliError26 ? translated.code : CliErrorCode27.INVALID_ARGUMENT,
|
|
10909
11033
|
message: translated instanceof Error ? translated.message : String(translated),
|
|
10910
|
-
traceId: translated instanceof
|
|
10911
|
-
profile: translated instanceof
|
|
11034
|
+
traceId: translated instanceof CliError26 ? translated.traceId : void 0,
|
|
11035
|
+
profile: translated instanceof CliError26 ? translated.profile : args.profile ?? args.context.profile,
|
|
10912
11036
|
cause: error,
|
|
10913
11037
|
context: {
|
|
10914
|
-
...translated instanceof
|
|
11038
|
+
...translated instanceof CliError26 ? translated.context : {},
|
|
10915
11039
|
workspaceKey: args.context.workspaceKey,
|
|
10916
11040
|
push,
|
|
10917
11041
|
details: {
|
|
10918
|
-
serverDetails: translated instanceof
|
|
11042
|
+
serverDetails: translated instanceof CliError26 ? translated.context?.details : void 0,
|
|
10919
11043
|
push
|
|
10920
11044
|
},
|
|
10921
11045
|
note: [
|
|
10922
|
-
translated instanceof
|
|
11046
|
+
translated instanceof CliError26 ? translated.context?.note : void 0,
|
|
10923
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"
|
|
10924
11048
|
].filter(Boolean).join(" "),
|
|
10925
11049
|
nextStep: [
|
|
10926
|
-
translated instanceof
|
|
11050
|
+
translated instanceof CliError26 ? translated.context?.nextStep : void 0,
|
|
10927
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"
|
|
10928
11052
|
].filter(Boolean).join(" ")
|
|
10929
11053
|
}
|
|
@@ -10974,7 +11098,7 @@ async function preflightWorkspacePlan(http, workspaceKey, operations, localFiles
|
|
|
10974
11098
|
return { status: "passed", sent, checked: verdict.checked, issues: [] };
|
|
10975
11099
|
} catch (error) {
|
|
10976
11100
|
const status = error?.response?.status;
|
|
10977
|
-
const translated = error?.isAxiosError ?
|
|
11101
|
+
const translated = error?.isAxiosError ? fromAxiosError23(error, profile) : error;
|
|
10978
11102
|
const detail = translated instanceof Error ? translated.message : String(translated);
|
|
10979
11103
|
return {
|
|
10980
11104
|
status: "unavailable",
|
|
@@ -11222,7 +11346,7 @@ async function readMiniStatusSafely(app) {
|
|
|
11222
11346
|
async function loadProfileClient(args) {
|
|
11223
11347
|
try {
|
|
11224
11348
|
const ctx = await getActiveAuthContextFromCli(args);
|
|
11225
|
-
return
|
|
11349
|
+
return HcmClient23.fromAuthContext(ctx);
|
|
11226
11350
|
} catch (e) {
|
|
11227
11351
|
if (args.env || args.profile) throw e;
|
|
11228
11352
|
return null;
|
|
@@ -11389,7 +11513,7 @@ function optionalText(value) {
|
|
|
11389
11513
|
}
|
|
11390
11514
|
function writeWorkspaceListResult(rows2, format, total) {
|
|
11391
11515
|
if (format !== "table") {
|
|
11392
|
-
process.stdout.write(
|
|
11516
|
+
process.stdout.write(formatObject23({ rows: rows2, total }, { format }) + "\n");
|
|
11393
11517
|
return;
|
|
11394
11518
|
}
|
|
11395
11519
|
process.stdout.write(formatRows6(toWorkspaceListRows(rows2), { format: "table" }) + "\n");
|
|
@@ -11400,7 +11524,7 @@ function writeWorkspaceListResult(rows2, format, total) {
|
|
|
11400
11524
|
}
|
|
11401
11525
|
function writeWorkspaceActiveResult(view, format) {
|
|
11402
11526
|
if (format !== "table") {
|
|
11403
|
-
process.stdout.write(
|
|
11527
|
+
process.stdout.write(formatObject23(view, { format }) + "\n");
|
|
11404
11528
|
return;
|
|
11405
11529
|
}
|
|
11406
11530
|
const rows2 = [
|
|
@@ -11425,7 +11549,7 @@ function writeWorkspaceActiveResult(view, format) {
|
|
|
11425
11549
|
}
|
|
11426
11550
|
function writeWorkspaceBindResult(context, rootDir, format) {
|
|
11427
11551
|
if (format !== "table") {
|
|
11428
|
-
process.stdout.write(
|
|
11552
|
+
process.stdout.write(formatObject23({ ...context, rootDir }, { format }) + "\n");
|
|
11429
11553
|
return;
|
|
11430
11554
|
}
|
|
11431
11555
|
process.stdout.write(
|
|
@@ -11439,7 +11563,7 @@ function writeWorkspaceBindResult(context, rootDir, format) {
|
|
|
11439
11563
|
}
|
|
11440
11564
|
function writeWorkspaceCreateResult(result, format) {
|
|
11441
11565
|
if (format !== "table") {
|
|
11442
|
-
process.stdout.write(
|
|
11566
|
+
process.stdout.write(formatObject23(result, { format }) + "\n");
|
|
11443
11567
|
return;
|
|
11444
11568
|
}
|
|
11445
11569
|
process.stdout.write(
|
|
@@ -11455,7 +11579,7 @@ function writeWorkspaceCreateResult(result, format) {
|
|
|
11455
11579
|
}
|
|
11456
11580
|
function writeWorkspacePullResult(result, format) {
|
|
11457
11581
|
if (format !== "table") {
|
|
11458
|
-
process.stdout.write(
|
|
11582
|
+
process.stdout.write(formatObject23(result, { format }) + "\n");
|
|
11459
11583
|
return;
|
|
11460
11584
|
}
|
|
11461
11585
|
const lines = [
|
|
@@ -11473,7 +11597,7 @@ function writeWorkspacePullResult(result, format) {
|
|
|
11473
11597
|
}
|
|
11474
11598
|
function writeWorkspaceAddMiniResult(result, rootDir, format) {
|
|
11475
11599
|
if (format !== "table") {
|
|
11476
|
-
process.stdout.write(
|
|
11600
|
+
process.stdout.write(formatObject23({ ...result, workspaceRoot: rootDir }, { format }) + "\n");
|
|
11477
11601
|
return;
|
|
11478
11602
|
}
|
|
11479
11603
|
process.stdout.write(
|
|
@@ -11489,7 +11613,7 @@ function writeWorkspaceAddMiniResult(result, rootDir, format) {
|
|
|
11489
11613
|
function writeWorkspaceValidateResult(results, format) {
|
|
11490
11614
|
if (format !== "table") {
|
|
11491
11615
|
process.stdout.write(
|
|
11492
|
-
|
|
11616
|
+
formatObject23(
|
|
11493
11617
|
results.map((item) => ({ artifact: item.artifact, ...item.result })),
|
|
11494
11618
|
{ format }
|
|
11495
11619
|
) + "\n"
|
|
@@ -11517,7 +11641,7 @@ ${item.artifact}
|
|
|
11517
11641
|
function writeWorkspacePushResult(rawResult, results, format) {
|
|
11518
11642
|
if (format !== "table") {
|
|
11519
11643
|
process.stdout.write(
|
|
11520
|
-
|
|
11644
|
+
formatObject23(
|
|
11521
11645
|
{
|
|
11522
11646
|
// 预检覆盖整份计划(workspace 文件 + 轻应用文件),放在顶层。
|
|
11523
11647
|
preflight: rawResult.preflight ?? null,
|
|
@@ -11582,7 +11706,7 @@ function writeWorkspaceVerifyResult(context, rootDir, raw, reports, format) {
|
|
|
11582
11706
|
const preflight = raw.plan?.preflight ?? null;
|
|
11583
11707
|
if (format === "json") {
|
|
11584
11708
|
process.stdout.write(
|
|
11585
|
-
|
|
11709
|
+
formatObject23(
|
|
11586
11710
|
{
|
|
11587
11711
|
ok,
|
|
11588
11712
|
workspaceKey: context.workspaceKey,
|
|
@@ -11610,7 +11734,7 @@ function writeWorkspaceVerifyResult(context, rootDir, raw, reports, format) {
|
|
|
11610
11734
|
}
|
|
11611
11735
|
if (format !== "table") {
|
|
11612
11736
|
process.stdout.write(
|
|
11613
|
-
|
|
11737
|
+
formatObject23(
|
|
11614
11738
|
{
|
|
11615
11739
|
ok,
|
|
11616
11740
|
workspaceKey: context.workspaceKey,
|
|
@@ -11666,13 +11790,13 @@ function quoteWorkspaceArg(value) {
|
|
|
11666
11790
|
}
|
|
11667
11791
|
function exitWorkspaceError(err, profile, operation) {
|
|
11668
11792
|
const maybeAxios = err;
|
|
11669
|
-
const translated = maybeAxios?.isAxiosError ?
|
|
11670
|
-
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))) {
|
|
11671
11795
|
const scope = `${profile ? ` --env ${quoteWorkspaceArg(profile)}` : ""}${operation.as ? ` --as ${quoteWorkspaceArg(operation.as)}` : ""}`;
|
|
11672
11796
|
const active = "hcm workspace active" + scope + (operation.dir ? ` --dir ${quoteWorkspaceArg(operation.dir)}` : "");
|
|
11673
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;
|
|
11674
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`;
|
|
11675
|
-
exitWithError(new
|
|
11799
|
+
exitWithError(new CliError26({
|
|
11676
11800
|
code: translated.code,
|
|
11677
11801
|
message: translated.message,
|
|
11678
11802
|
traceId: translated.traceId,
|
|
@@ -11685,8 +11809,8 @@ function exitWorkspaceError(err, profile, operation) {
|
|
|
11685
11809
|
}
|
|
11686
11810
|
}));
|
|
11687
11811
|
}
|
|
11688
|
-
if (translated instanceof
|
|
11689
|
-
exitWithError(new
|
|
11812
|
+
if (translated instanceof CliError26 && translated.code === CliErrorCode27.AUTH_FAILED) {
|
|
11813
|
+
exitWithError(new CliError26({
|
|
11690
11814
|
code: translated.code,
|
|
11691
11815
|
message: translated.message,
|
|
11692
11816
|
traceId: translated.traceId,
|
|
@@ -11714,8 +11838,8 @@ async function probeActiveWorkspaceKey(client3) {
|
|
|
11714
11838
|
}
|
|
11715
11839
|
function requireWorkspaceActivation(activeKey, workspaceKey, afterPush = false) {
|
|
11716
11840
|
if (activeKey === workspaceKey) return;
|
|
11717
|
-
throw new
|
|
11718
|
-
code:
|
|
11841
|
+
throw new CliError26({
|
|
11842
|
+
code: CliErrorCode27.INVALID_ARGUMENT,
|
|
11719
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`),
|
|
11720
11844
|
context: { workspaceKey, activeWorkspaceKey: activeKey, nextStep: `hcm workspace activate ${workspaceKey}` }
|
|
11721
11845
|
});
|
|
@@ -11752,7 +11876,7 @@ async function workspaceActivateCommand(workspaceKey, args) {
|
|
|
11752
11876
|
let recovery2;
|
|
11753
11877
|
let profile = args.env ?? args.profile;
|
|
11754
11878
|
try {
|
|
11755
|
-
const client3 =
|
|
11879
|
+
const client3 = HcmClient23.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
11756
11880
|
profile = client3.profile ?? profile;
|
|
11757
11881
|
const key2 = normalizeWorkspaceKey(workspaceKey);
|
|
11758
11882
|
recovery2 = { command: "activate", workspaceKey: key2, as: args.as };
|
|
@@ -11764,7 +11888,7 @@ async function workspaceActivateCommand(workspaceKey, args) {
|
|
|
11764
11888
|
process.stdout.write("\u8BE5\u7A7A\u95F4\u7684 metas / scripts / menus / mini_apps \u73B0\u5DF2\u5728\u5F53\u524D\u79DF\u6237\u751F\u6548\u3002\n");
|
|
11765
11889
|
} else {
|
|
11766
11890
|
process.stdout.write(
|
|
11767
|
-
|
|
11891
|
+
formatObject23({ workspaceKey: key2, activated: true }, { format: fmt }) + "\n"
|
|
11768
11892
|
);
|
|
11769
11893
|
}
|
|
11770
11894
|
process.exitCode = 0;
|
|
@@ -11775,7 +11899,7 @@ async function workspaceActivateCommand(workspaceKey, args) {
|
|
|
11775
11899
|
}
|
|
11776
11900
|
async function workspaceDeactivateCommand(args) {
|
|
11777
11901
|
try {
|
|
11778
|
-
const client3 =
|
|
11902
|
+
const client3 = HcmClient23.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
11779
11903
|
const binding = await requestWorkspaceDeactivation(client3);
|
|
11780
11904
|
const result = { ...binding, deactivated: true };
|
|
11781
11905
|
const fmt = args.output ?? "table";
|
|
@@ -11783,7 +11907,7 @@ async function workspaceDeactivateCommand(args) {
|
|
|
11783
11907
|
process.stdout.write("workspace deactivated\n");
|
|
11784
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");
|
|
11785
11909
|
} else {
|
|
11786
|
-
process.stdout.write(
|
|
11910
|
+
process.stdout.write(formatObject23(result, { format: fmt }) + "\n");
|
|
11787
11911
|
}
|
|
11788
11912
|
process.exitCode = 0;
|
|
11789
11913
|
return;
|
|
@@ -11794,14 +11918,14 @@ async function workspaceDeactivateCommand(args) {
|
|
|
11794
11918
|
|
|
11795
11919
|
// src/commands/identity.ts
|
|
11796
11920
|
init_exit();
|
|
11797
|
-
import
|
|
11921
|
+
import axios5 from "axios";
|
|
11798
11922
|
import {
|
|
11799
11923
|
AUTH_INFO_PATH,
|
|
11800
|
-
CliError as
|
|
11801
|
-
CliErrorCode as
|
|
11802
|
-
formatObject as
|
|
11924
|
+
CliError as CliError27,
|
|
11925
|
+
CliErrorCode as CliErrorCode28,
|
|
11926
|
+
formatObject as formatObject24,
|
|
11803
11927
|
formatRows as formatRows7,
|
|
11804
|
-
fromAxiosError as
|
|
11928
|
+
fromAxiosError as fromAxiosError24,
|
|
11805
11929
|
loadEnv as loadEnv4,
|
|
11806
11930
|
saveEnv as saveEnv3,
|
|
11807
11931
|
loadIdentity as loadIdentity4,
|
|
@@ -11814,7 +11938,7 @@ import {
|
|
|
11814
11938
|
toPrincipal
|
|
11815
11939
|
} from "@hcmai/sdk";
|
|
11816
11940
|
var fetchAuthInfo = async (endpoint, accessToken) => {
|
|
11817
|
-
const response = await
|
|
11941
|
+
const response = await axios5.get(`${endpoint.replace(/\/$/, "")}${AUTH_INFO_PATH}`, {
|
|
11818
11942
|
headers: { Authorization: `Bearer ${accessToken}` },
|
|
11819
11943
|
timeout: 3e4
|
|
11820
11944
|
});
|
|
@@ -11825,8 +11949,8 @@ async function inspectIdentity(name, fetcher = fetchAuthInfo) {
|
|
|
11825
11949
|
const env2 = await loadEnv4(meta2.env);
|
|
11826
11950
|
const accessToken = await TokenStore4.forIdentity(name).getStoredAccessToken();
|
|
11827
11951
|
if (!accessToken) {
|
|
11828
|
-
throw new
|
|
11829
|
-
code:
|
|
11952
|
+
throw new CliError27({
|
|
11953
|
+
code: CliErrorCode28.AUTH_FAILED,
|
|
11830
11954
|
message: `identity '${name}' \u6CA1\u6709\u53EF\u8BFB\u53D6\u7684\u6301\u4E45\u5316 token`,
|
|
11831
11955
|
context: { nextStep: `\u91CD\u65B0\u767B\u5F55\u8BE5\u8EAB\u4EFD\uFF1Ahcm login --env ${meta2.env} --name ${name}` }
|
|
11832
11956
|
});
|
|
@@ -11854,9 +11978,9 @@ async function inspectIdentity(name, fetcher = fetchAuthInfo) {
|
|
|
11854
11978
|
async function identityShow(name, args) {
|
|
11855
11979
|
try {
|
|
11856
11980
|
const details = await inspectIdentity(name);
|
|
11857
|
-
return exitOk(
|
|
11981
|
+
return exitOk(formatObject24(details, { format: args.output ?? "json" }));
|
|
11858
11982
|
} catch (e) {
|
|
11859
|
-
exitWithError(
|
|
11983
|
+
exitWithError(axios5.isAxiosError(e) ? fromAxiosError24(e, name) : e);
|
|
11860
11984
|
}
|
|
11861
11985
|
}
|
|
11862
11986
|
async function identityList(args) {
|
|
@@ -11866,7 +11990,7 @@ async function identityList(args) {
|
|
|
11866
11990
|
const names = await listIdentities4(filter);
|
|
11867
11991
|
const fmt = args.output ?? "table";
|
|
11868
11992
|
if (names.length === 0) {
|
|
11869
|
-
return exitOk(fmt === "table" ? "(no identities)" :
|
|
11993
|
+
return exitOk(fmt === "table" ? "(no identities)" : formatObject24([], { format: fmt }));
|
|
11870
11994
|
}
|
|
11871
11995
|
const rows2 = [];
|
|
11872
11996
|
for (const n of names) {
|
|
@@ -11880,7 +12004,7 @@ async function identityList(args) {
|
|
|
11880
12004
|
isDefault: env2?.defaultIdentity === n
|
|
11881
12005
|
});
|
|
11882
12006
|
}
|
|
11883
|
-
return exitOk(fmt === "table" ? formatRows7(rows2, { format: fmt }) :
|
|
12007
|
+
return exitOk(fmt === "table" ? formatRows7(rows2, { format: fmt }) : formatObject24(rows2, { format: fmt }));
|
|
11884
12008
|
} catch (e) {
|
|
11885
12009
|
exitWithError(e);
|
|
11886
12010
|
}
|
|
@@ -11889,8 +12013,8 @@ async function identityUse(name) {
|
|
|
11889
12013
|
try {
|
|
11890
12014
|
const meta2 = await loadIdentity4(name);
|
|
11891
12015
|
const env2 = await loadEnv4(meta2.env).catch(() => {
|
|
11892
|
-
throw new
|
|
11893
|
-
code:
|
|
12016
|
+
throw new CliError27({
|
|
12017
|
+
code: CliErrorCode28.IDENTITY_NOT_IN_ENV,
|
|
11894
12018
|
message: `identity '${name}' references env '${meta2.env}' which no longer exists. Re-create the env, or remove this orphan: hcm identity remove ${name}`
|
|
11895
12019
|
});
|
|
11896
12020
|
});
|
|
@@ -11930,11 +12054,11 @@ init_exit();
|
|
|
11930
12054
|
import { promises as fs9 } from "fs";
|
|
11931
12055
|
import path10 from "path";
|
|
11932
12056
|
import {
|
|
11933
|
-
CliError as
|
|
11934
|
-
CliErrorCode as
|
|
11935
|
-
HcmClient as
|
|
12057
|
+
CliError as CliError28,
|
|
12058
|
+
CliErrorCode as CliErrorCode29,
|
|
12059
|
+
HcmClient as HcmClient24,
|
|
11936
12060
|
fetchReconIdentity,
|
|
11937
|
-
formatObject as
|
|
12061
|
+
formatObject as formatObject25,
|
|
11938
12062
|
httpProbe,
|
|
11939
12063
|
isTempEnv as isTempEnv3,
|
|
11940
12064
|
assertNotReservedEnvName as assertNotReservedEnvName2,
|
|
@@ -11947,7 +12071,7 @@ import {
|
|
|
11947
12071
|
} from "@hcmai/sdk";
|
|
11948
12072
|
async function probeTokenTenant(envName, requested) {
|
|
11949
12073
|
const ctx = await getActiveAuthContextFromCli({ env: envName });
|
|
11950
|
-
const client3 =
|
|
12074
|
+
const client3 = HcmClient24.fromAuthContext(ctx);
|
|
11951
12075
|
const identity3 = await fetchReconIdentity(httpProbe(client3.raw(), "default"), requested);
|
|
11952
12076
|
return identity3?.tenantId ? String(identity3.tenantId) : void 0;
|
|
11953
12077
|
}
|
|
@@ -11992,8 +12116,8 @@ async function resolveInitEnv(root, args, deps) {
|
|
|
11992
12116
|
if (existing && path10.dirname(existing.path) === path10.resolve(root)) {
|
|
11993
12117
|
const name2 = args.env ?? existing.config.default;
|
|
11994
12118
|
const env2 = existing.config.environments[name2];
|
|
11995
|
-
if (!env2) throw new
|
|
11996
|
-
code:
|
|
12119
|
+
if (!env2) throw new CliError28({
|
|
12120
|
+
code: CliErrorCode29.INVALID_ARGUMENT,
|
|
11997
12121
|
message: `${existing.path} \u91CC\u6CA1\u6709\u73AF\u5883 '${name2}'\uFF0C\u53EA\u6709\uFF1A${Object.keys(existing.config.environments).join("\u3001")}`,
|
|
11998
12122
|
// env add 的 endpoint / frontend / tenant 都是必填,少一个照抄就是 required option 报错。
|
|
11999
12123
|
context: { nextStep: `hcm chiron env add ${name2} --endpoint <\u540E\u7AEF\u5730\u5740> --frontend <\u524D\u7AEF\u5730\u5740> --tenant <\u79DF\u6237\u53F7>` }
|
|
@@ -12003,8 +12127,8 @@ async function resolveInitEnv(root, args, deps) {
|
|
|
12003
12127
|
}
|
|
12004
12128
|
if (args.env) {
|
|
12005
12129
|
const config3 = await loadEnv5(args.env).catch(() => null);
|
|
12006
|
-
if (!config3?.endpoint) throw new
|
|
12007
|
-
code:
|
|
12130
|
+
if (!config3?.endpoint) throw new CliError28({
|
|
12131
|
+
code: CliErrorCode29.ENV_NOT_FOUND,
|
|
12008
12132
|
message: `\u672C\u673A\u6CA1\u6709\u540D\u53EB '${args.env}' \u7684\u73AF\u5883\u3002`,
|
|
12009
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>`" }
|
|
12010
12134
|
});
|
|
@@ -12014,14 +12138,14 @@ async function resolveInitEnv(root, args, deps) {
|
|
|
12014
12138
|
const name = g.activeEnv;
|
|
12015
12139
|
const config2 = name ? await loadEnv5(name).catch(() => null) : null;
|
|
12016
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";
|
|
12017
|
-
if (!config2?.endpoint) throw new
|
|
12018
|
-
code:
|
|
12141
|
+
if (!config2?.endpoint) throw new CliError28({
|
|
12142
|
+
code: CliErrorCode29.ENV_NOT_FOUND,
|
|
12019
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",
|
|
12020
12144
|
context: { nextStep: `\u4E8C\u9009\u4E00\uFF1A
|
|
12021
12145
|
${explicitPaths}` }
|
|
12022
12146
|
});
|
|
12023
|
-
if (isTempEnv3(name)) throw new
|
|
12024
|
-
code:
|
|
12147
|
+
if (isTempEnv3(name)) throw new CliError28({
|
|
12148
|
+
code: CliErrorCode29.INVALID_ARGUMENT,
|
|
12025
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`,
|
|
12026
12150
|
context: { nextStep: `\u5148\u7ED9\u5B83\u8D77\u4E2A\u540D\u5B57\uFF1Ahcm env save <name>\uFF1B\u6216\u76F4\u63A5\u663E\u5F0F\u5EFA\uFF1A
|
|
12027
12151
|
${explicitPaths}` }
|
|
@@ -12029,8 +12153,8 @@ ${explicitPaths}` }
|
|
|
12029
12153
|
const summary = `${name} \xB7 ${config2.endpoint} \xB7 \u79DF\u6237 ${config2.tenantId ?? "1"}`;
|
|
12030
12154
|
if (!args.yes) {
|
|
12031
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;
|
|
12032
|
-
if (!ok) throw new
|
|
12033
|
-
code:
|
|
12156
|
+
if (!ok) throw new CliError28({
|
|
12157
|
+
code: CliErrorCode29.INVALID_ARGUMENT,
|
|
12034
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`,
|
|
12035
12159
|
context: { nextStep: `\u786E\u8BA4\u5C31\u52A0 --yes\uFF1B\u6216\u660E\u8BF4\uFF1A
|
|
12036
12160
|
${explicitPaths}` }
|
|
@@ -12046,24 +12170,24 @@ async function scaffoldChironProject(root, env2, envName) {
|
|
|
12046
12170
|
const document2 = parseEnvYaml(existing);
|
|
12047
12171
|
const recorded = Object.values(document2.environments).find((candidate) => candidate.endpoint === env2.endpoint && candidate.tenant === env2.tenant) ?? document2.environments[document2.default];
|
|
12048
12172
|
if (recorded.endpoint !== env2.endpoint) {
|
|
12049
|
-
throw new
|
|
12050
|
-
code:
|
|
12173
|
+
throw new CliError28({
|
|
12174
|
+
code: CliErrorCode29.INVALID_ARGUMENT,
|
|
12051
12175
|
message: `${ENV_FILE} \u6307\u5411 ${recorded.endpoint}\uFF0C\u800C\u4F60\u5F53\u524D\u767B\u5F55\u7684\u662F ${env2.endpoint}\uFF08env '${envName}'\uFF09\u3002
|
|
12052
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
|
|
12053
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`
|
|
12054
12178
|
});
|
|
12055
12179
|
}
|
|
12056
12180
|
if (recorded.tenant !== env2.tenant) {
|
|
12057
|
-
throw new
|
|
12058
|
-
code:
|
|
12181
|
+
throw new CliError28({
|
|
12182
|
+
code: CliErrorCode29.INVALID_ARGUMENT,
|
|
12059
12183
|
message: `${ENV_FILE} \u662F\u79DF\u6237 ${recorded.tenant}\uFF0C\u800C\u4F60\u767B\u5F55\u7684\u8EAB\u4EFD\u5C5E\u4E8E\u79DF\u6237 ${env2.tenant}\u3002
|
|
12060
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`
|
|
12061
12185
|
});
|
|
12062
12186
|
}
|
|
12063
12187
|
result.preserved.push(ENV_FILE);
|
|
12064
12188
|
} else {
|
|
12065
|
-
if (!envName.trim() || envName.trim() !== envName) throw new
|
|
12066
|
-
code:
|
|
12189
|
+
if (!envName.trim() || envName.trim() !== envName) throw new CliError28({
|
|
12190
|
+
code: CliErrorCode29.INVALID_ARGUMENT,
|
|
12067
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`,
|
|
12068
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" }
|
|
12069
12193
|
});
|
|
@@ -12076,8 +12200,8 @@ async function scaffoldChironProject(root, env2, envName) {
|
|
|
12076
12200
|
try {
|
|
12077
12201
|
const written = parseEnvYaml(await fs9.readFile(envFile, "utf8"));
|
|
12078
12202
|
if (written.default !== envName || Object.keys(written.environments).length !== 1 || !Object.hasOwn(written.environments, envName)) {
|
|
12079
|
-
throw new
|
|
12080
|
-
code:
|
|
12203
|
+
throw new CliError28({
|
|
12204
|
+
code: CliErrorCode29.CONFIG_PARSE_ERROR,
|
|
12081
12205
|
message: `${ENV_FILE} \u5199\u5165\u540E\u73AF\u5883\u540D\u4E0E\u56DE\u6267 '${envName}' \u4E0D\u4E00\u81F4\u3002`,
|
|
12082
12206
|
context: { nextStep: `\u6838\u5BF9 ${ENV_FILE} \u7684 default \u4E0E environments \u952E\uFF0C\u518D\u91CD\u8DD1 hcm chiron init` }
|
|
12083
12207
|
});
|
|
@@ -12155,7 +12279,7 @@ async function chironInitCommand(args, deps) {
|
|
|
12155
12279
|
const result = await runChironInit(args, deps);
|
|
12156
12280
|
const fmt = args.output ?? "table";
|
|
12157
12281
|
if (fmt === "json" || fmt === "yaml") {
|
|
12158
|
-
process.stdout.write(
|
|
12282
|
+
process.stdout.write(formatObject25(result, { format: fmt }) + "\n");
|
|
12159
12283
|
} else {
|
|
12160
12284
|
const mark = { verified: "\u2705", mismatch: "\u274C", unreachable: "\u26A0\uFE0F", skipped: "\xB7" }[result.tenantCheck.status];
|
|
12161
12285
|
process.stdout.write(
|
|
@@ -12177,9 +12301,9 @@ async function chironInitCommand(args, deps) {
|
|
|
12177
12301
|
// src/commands/gap.ts
|
|
12178
12302
|
import { readFileSync as readFileSync6 } from "fs";
|
|
12179
12303
|
import {
|
|
12180
|
-
CliErrorCode as
|
|
12304
|
+
CliErrorCode as CliErrorCode31,
|
|
12181
12305
|
createHttpClient as createHttpClient4,
|
|
12182
|
-
formatObject as
|
|
12306
|
+
formatObject as formatObject26,
|
|
12183
12307
|
loadGlobalConfig as loadGlobalConfig10,
|
|
12184
12308
|
resolveEnvContext as resolveEnvContext7,
|
|
12185
12309
|
printResolvedEnvironment as printResolvedEnvironment7,
|
|
@@ -12579,8 +12703,8 @@ async function gapComments({ client: client3 }, ref, { limit } = {}, casesSlug =
|
|
|
12579
12703
|
// src/jira/gap-verify.ts
|
|
12580
12704
|
import {
|
|
12581
12705
|
CASES_REPO_SLUG as CASES_REPO_SLUG3,
|
|
12582
|
-
CliError as
|
|
12583
|
-
CliErrorCode as
|
|
12706
|
+
CliError as CliError29,
|
|
12707
|
+
CliErrorCode as CliErrorCode30,
|
|
12584
12708
|
JiraHttpError,
|
|
12585
12709
|
JiraNonBmpContentError,
|
|
12586
12710
|
NON_BMP_RULE_NOTE,
|
|
@@ -12601,14 +12725,14 @@ var VERIFY_PLAN = {
|
|
|
12601
12725
|
function parseVerifyResult(raw) {
|
|
12602
12726
|
const v = String(raw ?? "").trim().toLowerCase();
|
|
12603
12727
|
if (VERIFY_RESULTS.includes(v)) return v;
|
|
12604
|
-
throw new
|
|
12605
|
-
code: raw === void 0 ?
|
|
12728
|
+
throw new CliError29({
|
|
12729
|
+
code: raw === void 0 ? CliErrorCode30.MISSING_FLAG : CliErrorCode30.INVALID_ARGUMENT,
|
|
12606
12730
|
message: `--result \u53EA\u80FD\u662F pass / fail / partial\uFF0C\u7ED9\u7684\u662F\u300C${raw ?? "\uFF08\u6CA1\u7ED9\uFF09"}\u300D`,
|
|
12607
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" }
|
|
12608
12732
|
});
|
|
12609
12733
|
}
|
|
12610
12734
|
function verifyFailure(reasonCode, code2, written, message, nextStep, extra = {}, cause) {
|
|
12611
|
-
return new
|
|
12735
|
+
return new CliError29({ code: code2, message: `${message}${WRITTEN_TAG[written]}`, context: { reasonCode, written, nextStep, ...extra }, cause });
|
|
12612
12736
|
}
|
|
12613
12737
|
function who(u) {
|
|
12614
12738
|
if (!u) return "\uFF08\u5355\u4E0A\u6CA1\u6709\uFF09";
|
|
@@ -12696,7 +12820,7 @@ function writeFailure(e, key2, what) {
|
|
|
12696
12820
|
if (e instanceof JiraNonBmpContentError) {
|
|
12697
12821
|
return verifyFailure(
|
|
12698
12822
|
"non-bmp-content",
|
|
12699
|
-
|
|
12823
|
+
CliErrorCode30.INVALID_ARGUMENT,
|
|
12700
12824
|
"no",
|
|
12701
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`,
|
|
12702
12826
|
// 🔴 清单落 nextStep,不落 cause:CliError 渲染 cause 时 formatCause 截到 300 字,
|
|
@@ -12707,7 +12831,7 @@ ${nonBmpHitLines(e.hits)}`,
|
|
|
12707
12831
|
);
|
|
12708
12832
|
}
|
|
12709
12833
|
if (e instanceof JiraHttpError && e.status >= 400 && e.status < 500) {
|
|
12710
|
-
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), {
|
|
12711
12835
|
key: key2,
|
|
12712
12836
|
status: e.status,
|
|
12713
12837
|
details: e.message
|
|
@@ -12715,7 +12839,7 @@ ${nonBmpHitLines(e.hits)}`,
|
|
|
12715
12839
|
}
|
|
12716
12840
|
return verifyFailure(
|
|
12717
12841
|
"write-unconfirmed",
|
|
12718
|
-
|
|
12842
|
+
CliErrorCode30.NETWORK_ERROR,
|
|
12719
12843
|
"unknown",
|
|
12720
12844
|
`${what}\u8BF7\u6C42\u6CA1\u5F97\u5230\u786E\u8BA4\uFF08${unconfirmedWhy(e)}\uFF09`,
|
|
12721
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`,
|
|
@@ -12738,7 +12862,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
|
|
|
12738
12862
|
if (!parsed || parsed.kind !== "jira") {
|
|
12739
12863
|
throw verifyFailure(
|
|
12740
12864
|
"not-jira-key",
|
|
12741
|
-
|
|
12865
|
+
CliErrorCode30.INVALID_ARGUMENT,
|
|
12742
12866
|
"no",
|
|
12743
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}`,
|
|
12744
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"
|
|
@@ -12748,7 +12872,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
|
|
|
12748
12872
|
const inProject = (k) => k.startsWith(`${client3.project}-`);
|
|
12749
12873
|
const wrongProject = (k) => verifyFailure(
|
|
12750
12874
|
"wrong-project",
|
|
12751
|
-
|
|
12875
|
+
CliErrorCode30.INVALID_ARGUMENT,
|
|
12752
12876
|
"no",
|
|
12753
12877
|
`${k} \u4E0D\u5728 ${client3.project} \u9879\u76EE\u91CC\uFF0C\u9A8C\u6536\u53EA\u5199 ${client3.project} \u7684\u5355`,
|
|
12754
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`,
|
|
@@ -12759,7 +12883,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
|
|
|
12759
12883
|
if (evidence.length < EVIDENCE_MIN) {
|
|
12760
12884
|
throw verifyFailure(
|
|
12761
12885
|
"evidence-too-short",
|
|
12762
|
-
|
|
12886
|
+
CliErrorCode30.INVALID_ARGUMENT,
|
|
12763
12887
|
"no",
|
|
12764
12888
|
`\u9A8C\u6536\u8BC1\u636E\u81F3\u5C11 ${EVIDENCE_MIN} \u4E2A\u5B57\uFF0C\u7ED9\u7684\u662F ${evidence.length} \u4E2A\u5B57`,
|
|
12765
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",
|
|
@@ -12785,7 +12909,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
|
|
|
12785
12909
|
if (!sameUser(reporter, me)) {
|
|
12786
12910
|
throw verifyFailure(
|
|
12787
12911
|
"not-reporter",
|
|
12788
|
-
|
|
12912
|
+
CliErrorCode30.BUSINESS_RULE_VIOLATION,
|
|
12789
12913
|
"no",
|
|
12790
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)}`,
|
|
12791
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",
|
|
@@ -12799,7 +12923,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
|
|
|
12799
12923
|
if (status !== FIXED_STATUS) {
|
|
12800
12924
|
throw verifyFailure(
|
|
12801
12925
|
"status-not-fixed",
|
|
12802
|
-
|
|
12926
|
+
CliErrorCode30.BUSINESS_RULE_VIOLATION,
|
|
12803
12927
|
"no",
|
|
12804
12928
|
`${key2} \u7684\u72B6\u6001\u662F\u300C${status ?? "?"}\u300D\uFF0C\u9A8C\u6536\u53EA\u5728\u300C${FIXED_STATUS}\u300D\u4E0A\u505A`,
|
|
12805
12929
|
notFixedNextStep(key2, status, o.result),
|
|
@@ -12825,7 +12949,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
|
|
|
12825
12949
|
} else if (o.fingerprint.revision < fixRevision) {
|
|
12826
12950
|
const environmentRevision = o.fingerprint.revision;
|
|
12827
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`;
|
|
12828
|
-
throw verifyFailure("env-behind-fix",
|
|
12952
|
+
throw verifyFailure("env-behind-fix", CliErrorCode30.BUSINESS_RULE_VIOLATION, "no", message, message, { key: key2, fixRevision, environmentRevision });
|
|
12829
12953
|
} else {
|
|
12830
12954
|
const environmentRevision = o.fingerprint.revision;
|
|
12831
12955
|
versionComparison = { status: "passed", text: `\u7248\u672C\u6BD4\u5BF9\uFF1A\u73AF\u5883 r${environmentRevision} \u2265 \u4FEE\u590D r${fixRevision}`, fixRevision, environmentRevision };
|
|
@@ -12843,7 +12967,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
|
|
|
12843
12967
|
const available = list.map((t) => `${t.name}\u2192${t.to?.name ?? "?"}`);
|
|
12844
12968
|
throw verifyFailure(
|
|
12845
12969
|
"transition-unavailable",
|
|
12846
|
-
|
|
12970
|
+
CliErrorCode30.BUSINESS_RULE_VIOLATION,
|
|
12847
12971
|
"no",
|
|
12848
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`,
|
|
12849
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",
|
|
@@ -12855,7 +12979,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
|
|
|
12855
12979
|
else if (req.missing.length) {
|
|
12856
12980
|
throw verifyFailure(
|
|
12857
12981
|
"required-fields-missing",
|
|
12858
|
-
|
|
12982
|
+
CliErrorCode30.BUSINESS_RULE_VIOLATION,
|
|
12859
12983
|
"no",
|
|
12860
12984
|
`\u300C${transition.name}\u300D\u8981\u6C42\u8FD9\u4E9B\u5B57\u6BB5\u6709\u503C\uFF0C${key2} \u4E0A\u662F\u7A7A\u7684\uFF1A${req.missing.join("\u3001")}`,
|
|
12861
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",
|
|
@@ -12897,7 +13021,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
|
|
|
12897
13021
|
} catch (e) {
|
|
12898
13022
|
throw verifyFailure(
|
|
12899
13023
|
"readback-failed",
|
|
12900
|
-
|
|
13024
|
+
CliErrorCode30.NETWORK_ERROR,
|
|
12901
13025
|
"yes",
|
|
12902
13026
|
`${what}\u5DF2\u88AB Jira \u63A5\u53D7\uFF0C\u4F46\u56DE\u8BFB ${key2} \u5931\u8D25\uFF0C\u843D\u5230\u4EC0\u4E48\u72B6\u6001\u6CA1\u786E\u8BA4`,
|
|
12903
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`,
|
|
@@ -12911,7 +13035,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
|
|
|
12911
13035
|
const did = plan.outcome === "closed" ? "\u5173\u5355" : "\u9000\u56DE";
|
|
12912
13036
|
throw verifyFailure(
|
|
12913
13037
|
"readback-mismatch",
|
|
12914
|
-
|
|
13038
|
+
CliErrorCode30.SERVER_ERROR,
|
|
12915
13039
|
"yes",
|
|
12916
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`,
|
|
12917
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",
|
|
@@ -12943,7 +13067,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
|
|
|
12943
13067
|
} catch (e) {
|
|
12944
13068
|
throw verifyFailure(
|
|
12945
13069
|
"readback-failed",
|
|
12946
|
-
|
|
13070
|
+
CliErrorCode30.NETWORK_ERROR,
|
|
12947
13071
|
"yes",
|
|
12948
13072
|
`\u8BC4\u8BBA\u5DF2\u88AB Jira \u63A5\u53D7\uFF0C\u4F46\u56DE\u8BFB ${key2} \u7684\u8BC4\u8BBA\u5931\u8D25\uFF0C\u6CA1\u786E\u8BA4\u5B83\u5728`,
|
|
12949
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`,
|
|
@@ -12957,7 +13081,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
|
|
|
12957
13081
|
} else if (!listed.some((c2) => c2.id === written.id)) {
|
|
12958
13082
|
throw verifyFailure(
|
|
12959
13083
|
"readback-mismatch",
|
|
12960
|
-
|
|
13084
|
+
CliErrorCode30.SERVER_ERROR,
|
|
12961
13085
|
"yes",
|
|
12962
13086
|
`Jira \u56DE\u4E86\u8BC4\u8BBA ${written.id}\uFF0C\u4F46\u56DE\u8BFB ${key2} \u7684\u8BC4\u8BBA\u91CC\u6CA1\u6709\u5B83`,
|
|
12963
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`,
|
|
@@ -12994,7 +13118,7 @@ async function gapDeps(deps) {
|
|
|
12994
13118
|
return { client: await deps.client() };
|
|
12995
13119
|
}
|
|
12996
13120
|
function emit5(fmt, data, text) {
|
|
12997
|
-
if (fmt === "json" || fmt === "yaml") process.stdout.write(
|
|
13121
|
+
if (fmt === "json" || fmt === "yaml") process.stdout.write(formatObject26(data, { format: fmt }) + "\n");
|
|
12998
13122
|
else process.stdout.write(text() + "\n");
|
|
12999
13123
|
}
|
|
13000
13124
|
async function run2(fn) {
|
|
@@ -13099,7 +13223,7 @@ function readEvidence(opts, stdinIsTTY = !!process.stdin.isTTY, readStdin2 = ()
|
|
|
13099
13223
|
if (opts.file !== void 0 && opts.body !== void 0) {
|
|
13100
13224
|
throw verifyFailure(
|
|
13101
13225
|
"evidence-ambiguous",
|
|
13102
|
-
|
|
13226
|
+
CliErrorCode31.INVALID_ARGUMENT,
|
|
13103
13227
|
"no",
|
|
13104
13228
|
"--body \u4E0E --file \u540C\u65F6\u7ED9\u4E86\uFF0C\u4E0D\u77E5\u9053\u8BE5\u7528\u54EA\u4EFD\u505A\u9A8C\u6536\u8BC1\u636E",
|
|
13105
13229
|
"\u53EA\u7559\u4E00\u4E2A\uFF1A\u77ED\u8BC1\u636E\u7528 --body\uFF0C\u957F\u8BC1\u636E\u5199\u8FDB\u6587\u4EF6\u7528 --file\u3002"
|
|
@@ -13111,7 +13235,7 @@ function readEvidence(opts, stdinIsTTY = !!process.stdin.isTTY, readStdin2 = ()
|
|
|
13111
13235
|
} catch (e) {
|
|
13112
13236
|
throw verifyFailure(
|
|
13113
13237
|
"evidence-unreadable",
|
|
13114
|
-
|
|
13238
|
+
CliErrorCode31.INVALID_ARGUMENT,
|
|
13115
13239
|
"no",
|
|
13116
13240
|
`\u8BFB\u4E0D\u5230\u8BC1\u636E\u6587\u4EF6 ${opts.file}`,
|
|
13117
13241
|
"\u6838\u5BF9\u8DEF\u5F84\u4E0E\u6743\u9650\uFF1B\u8BC1\u636E\u6587\u4EF6\u4E00\u822C\u653E\u5728\u9879\u76EE\u4ED3\u7684 evidence/ \u4E0B\u3002",
|
|
@@ -13124,7 +13248,7 @@ function readEvidence(opts, stdinIsTTY = !!process.stdin.isTTY, readStdin2 = ()
|
|
|
13124
13248
|
if (stdinIsTTY) {
|
|
13125
13249
|
throw verifyFailure(
|
|
13126
13250
|
"evidence-missing",
|
|
13127
|
-
|
|
13251
|
+
CliErrorCode31.INVALID_ARGUMENT,
|
|
13128
13252
|
"no",
|
|
13129
13253
|
"\u6CA1\u7ED9\u9A8C\u6536\u8BC1\u636E",
|
|
13130
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"
|
|
@@ -13181,11 +13305,11 @@ async function gapVerifyCommand(ref, args, deps = defaultDeps) {
|
|
|
13181
13305
|
init_auth_guard();
|
|
13182
13306
|
import { promises as fs12 } from "fs";
|
|
13183
13307
|
import path14 from "path";
|
|
13184
|
-
import
|
|
13308
|
+
import axios10 from "axios";
|
|
13185
13309
|
import {
|
|
13186
|
-
CliError as
|
|
13187
|
-
CliErrorCode as
|
|
13188
|
-
formatObject as
|
|
13310
|
+
CliError as CliError34,
|
|
13311
|
+
CliErrorCode as CliErrorCode35,
|
|
13312
|
+
formatObject as formatObject29,
|
|
13189
13313
|
httpProbe as httpProbe2,
|
|
13190
13314
|
listEnvs as listEnvs2,
|
|
13191
13315
|
loadGlobalConfig as loadGlobalConfig12,
|
|
@@ -13207,12 +13331,12 @@ import yaml from "js-yaml";
|
|
|
13207
13331
|
import {
|
|
13208
13332
|
AUTH_INFO_PATH as AUTH_INFO_PATH2,
|
|
13209
13333
|
assertNotReservedEnvName as assertNotReservedEnvName3,
|
|
13210
|
-
CliError as
|
|
13211
|
-
CliErrorCode as
|
|
13334
|
+
CliError as CliError30,
|
|
13335
|
+
CliErrorCode as CliErrorCode32,
|
|
13212
13336
|
discoverProjectEnv as discoverProjectEnv6,
|
|
13213
13337
|
ENV_FILE as ENV_FILE2,
|
|
13214
13338
|
findEnvByEndpoint as findEnvByEndpoint5,
|
|
13215
|
-
formatObject as
|
|
13339
|
+
formatObject as formatObject27,
|
|
13216
13340
|
listIdentities as listIdentities6,
|
|
13217
13341
|
parseEnvYaml as parseEnvYaml2,
|
|
13218
13342
|
renderEnvYaml as renderEnvYaml2,
|
|
@@ -13231,7 +13355,7 @@ function summarizeReasons(reasons) {
|
|
|
13231
13355
|
return reasons.length === 1 ? reasons[0] : `${reasons[0]} \u7B49 ${reasons.length} \u6761\uFF08--output json \u770B\u5168\u90E8\uFF09`;
|
|
13232
13356
|
}
|
|
13233
13357
|
function invalid2(message, nextStep) {
|
|
13234
|
-
throw new
|
|
13358
|
+
throw new CliError30({ code: CliErrorCode32.INVALID_ARGUMENT, message, context: { nextStep } });
|
|
13235
13359
|
}
|
|
13236
13360
|
function required(value, label) {
|
|
13237
13361
|
if (!value?.trim()) invalid2(`${label} \u4E0D\u80FD\u4E3A\u7A7A\uFF1B\u914D\u7F6E\u672A\u5199\u5165\u3002`, `\u8BF7\u63D0\u4F9B\u975E\u7A7A\u7684 ${label}`);
|
|
@@ -13418,7 +13542,7 @@ async function runChironEnv(action, args = {}) {
|
|
|
13418
13542
|
return report;
|
|
13419
13543
|
}
|
|
13420
13544
|
function formatChironEnvReport(report, output = "table") {
|
|
13421
|
-
if (output !== "table") return
|
|
13545
|
+
if (output !== "table") return formatObject27(report, { format: output });
|
|
13422
13546
|
const lines = [
|
|
13423
13547
|
report.action === "list" ? `\u9879\u76EE\u73AF\u5883\uFF1A${report.path}` : `\u5DF2\u5199\u5165\uFF1A${report.path}`,
|
|
13424
13548
|
formatTable(report.environments.map((env2) => ({
|
|
@@ -13455,8 +13579,8 @@ import os5 from "os";
|
|
|
13455
13579
|
import path12 from "path";
|
|
13456
13580
|
import yaml2 from "js-yaml";
|
|
13457
13581
|
import {
|
|
13458
|
-
CliError as
|
|
13459
|
-
CliErrorCode as
|
|
13582
|
+
CliError as CliError31,
|
|
13583
|
+
CliErrorCode as CliErrorCode33,
|
|
13460
13584
|
METHOD_REPO_DISPLAY,
|
|
13461
13585
|
METHOD_REPO_URL,
|
|
13462
13586
|
assertSafeSkillId as assertSafeSkillId2,
|
|
@@ -13464,7 +13588,7 @@ import {
|
|
|
13464
13588
|
discoverProjectEnv as discoverProjectEnv7,
|
|
13465
13589
|
fetchSkillCatalog as fetchSkillCatalog2,
|
|
13466
13590
|
flattenSkills as flattenSkills2,
|
|
13467
|
-
formatObject as
|
|
13591
|
+
formatObject as formatObject28,
|
|
13468
13592
|
parseSkillFrontmatter as parseSkillFrontmatter3,
|
|
13469
13593
|
resolveChironBase as resolveChironBase2
|
|
13470
13594
|
} from "@hcmai/sdk";
|
|
@@ -13497,8 +13621,8 @@ function gitErrorText(e) {
|
|
|
13497
13621
|
function classifyGitFailure(e, repoDisplay) {
|
|
13498
13622
|
const err = e;
|
|
13499
13623
|
if (err.code === "ENOENT") {
|
|
13500
|
-
return new
|
|
13501
|
-
code:
|
|
13624
|
+
return new CliError31({
|
|
13625
|
+
code: CliErrorCode33.METHOD_GIT_UNAVAILABLE,
|
|
13502
13626
|
message: "\u672C\u673A\u627E\u4E0D\u5230 git\uFF0C\u53D6\u65B9\u6CD5\u5305\u9760\u5B83",
|
|
13503
13627
|
context: { nextStep: "\u88C5\u4E0A git\uFF08`git --version` \u80FD\u8DD1\u901A\uFF09\uFF0C\u518D\u91CD\u8DD1\u8FD9\u6761\u547D\u4EE4" }
|
|
13504
13628
|
});
|
|
@@ -13506,15 +13630,15 @@ function classifyGitFailure(e, repoDisplay) {
|
|
|
13506
13630
|
const text = gitErrorText(e);
|
|
13507
13631
|
const head = text.split("\n").filter(Boolean).slice(-3).join(" / ").slice(0, 400);
|
|
13508
13632
|
if (err.code === "ETIMEDOUT" || err.signal === "SIGTERM") {
|
|
13509
|
-
return new
|
|
13510
|
-
code:
|
|
13633
|
+
return new CliError31({
|
|
13634
|
+
code: CliErrorCode33.METHOD_SOURCE_NETWORK,
|
|
13511
13635
|
message: `git \u5728\u65F6\u9650\u5185\u6CA1\u6709\u8FD4\u56DE\uFF08${repoDisplay}\uFF09`,
|
|
13512
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" }
|
|
13513
13637
|
});
|
|
13514
13638
|
}
|
|
13515
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)) {
|
|
13516
|
-
return new
|
|
13517
|
-
code:
|
|
13640
|
+
return new CliError31({
|
|
13641
|
+
code: CliErrorCode33.METHOD_SOURCE_AUTH_REQUIRED,
|
|
13518
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}`,
|
|
13519
13643
|
context: { nextStep: "`cnb login` \u4E4B\u540E\u91CD\u8DD1\u3002\u65B9\u6CD5\u5305\u8D70\u7684\u662F git \u51ED\u636E\uFF0C\u4E0D\u662F `hcm login`" }
|
|
13520
13644
|
});
|
|
@@ -13522,8 +13646,8 @@ function classifyGitFailure(e, repoDisplay) {
|
|
|
13522
13646
|
const notFound = /returned error: 404|Repository not found|repository '.*' not found|does not appear to be a git repository/i.test(text);
|
|
13523
13647
|
if (/returned error: 403|403 Forbidden|access denied|not authorized/i.test(text) || notFound) {
|
|
13524
13648
|
const overridden = Boolean(process.env.HCM_METHOD_REPO?.trim() || process.env.HCM_METHOD_REPO_URL?.trim());
|
|
13525
|
-
return new
|
|
13526
|
-
code:
|
|
13649
|
+
return new CliError31({
|
|
13650
|
+
code: CliErrorCode33.METHOD_SOURCE_FORBIDDEN,
|
|
13527
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" : ""),
|
|
13528
13652
|
context: {
|
|
13529
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" : "")
|
|
@@ -13531,14 +13655,14 @@ function classifyGitFailure(e, repoDisplay) {
|
|
|
13531
13655
|
});
|
|
13532
13656
|
}
|
|
13533
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)) {
|
|
13534
|
-
return new
|
|
13535
|
-
code:
|
|
13658
|
+
return new CliError31({
|
|
13659
|
+
code: CliErrorCode33.METHOD_SOURCE_NETWORK,
|
|
13536
13660
|
message: `\u8FDE\u4E0D\u4E0A\u65B9\u6CD5\u8BBA\u4ED3\uFF08${repoDisplay}\uFF09\uFF1A${head}`,
|
|
13537
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" }
|
|
13538
13662
|
});
|
|
13539
13663
|
}
|
|
13540
|
-
return new
|
|
13541
|
-
code:
|
|
13664
|
+
return new CliError31({
|
|
13665
|
+
code: CliErrorCode33.METHOD_SOURCE_GIT_FAILED,
|
|
13542
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}`,
|
|
13543
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` }
|
|
13544
13668
|
});
|
|
@@ -13614,8 +13738,8 @@ function resolveRef(tags, ref, deps) {
|
|
|
13614
13738
|
if (ref === void 0) {
|
|
13615
13739
|
const latest = versions[0];
|
|
13616
13740
|
if (!latest) {
|
|
13617
|
-
throw new
|
|
13618
|
-
code:
|
|
13741
|
+
throw new CliError31({
|
|
13742
|
+
code: CliErrorCode33.METHOD_REF_NOT_FOUND,
|
|
13619
13743
|
message: `\u65B9\u6CD5\u8BBA\u4ED3 ${deps.repoDisplay} \u91CC\u4E00\u4E2A vX.Y.Z \u5F62\u5F0F\u7684\u7248\u672C tag \u90FD\u6CA1\u6709`,
|
|
13620
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" }
|
|
13621
13745
|
});
|
|
@@ -13624,8 +13748,8 @@ function resolveRef(tags, ref, deps) {
|
|
|
13624
13748
|
}
|
|
13625
13749
|
const name = tags.has(ref) ? ref : tags.has(`v${ref}`) ? `v${ref}` : void 0;
|
|
13626
13750
|
if (!name) {
|
|
13627
|
-
throw new
|
|
13628
|
-
code:
|
|
13751
|
+
throw new CliError31({
|
|
13752
|
+
code: CliErrorCode33.METHOD_REF_NOT_FOUND,
|
|
13629
13753
|
message: `\u65B9\u6CD5\u8BBA\u4ED3 ${deps.repoDisplay} \u91CC\u6CA1\u6709 tag ${ref}`,
|
|
13630
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" }
|
|
13631
13755
|
});
|
|
@@ -13633,8 +13757,8 @@ function resolveRef(tags, ref, deps) {
|
|
|
13633
13757
|
return { ref: name, commit: tags.get(name) };
|
|
13634
13758
|
}
|
|
13635
13759
|
function invalidPackage(field, message) {
|
|
13636
|
-
return new
|
|
13637
|
-
code:
|
|
13760
|
+
return new CliError31({
|
|
13761
|
+
code: CliErrorCode33.METHOD_PACKAGE_INVALID,
|
|
13638
13762
|
message: `\u65B9\u6CD5\u5305\u6E05\u5355 package.yml \u4E0D\u5408\u683C\uFF1A${message}`,
|
|
13639
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" }
|
|
13640
13764
|
});
|
|
@@ -13658,8 +13782,8 @@ function parsePackageManifest(text) {
|
|
|
13658
13782
|
throw invalidPackage("schemaVersion", "\u7F3A schemaVersion\uFF08\u6574\u6570\uFF09");
|
|
13659
13783
|
}
|
|
13660
13784
|
if (!KNOWN_PACKAGE_SCHEMA_VERSIONS.includes(m.schemaVersion)) {
|
|
13661
|
-
throw new
|
|
13662
|
-
code:
|
|
13785
|
+
throw new CliError31({
|
|
13786
|
+
code: CliErrorCode33.METHOD_PACKAGE_SCHEMA_UNSUPPORTED,
|
|
13663
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(" / ")}`,
|
|
13664
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" }
|
|
13665
13789
|
});
|
|
@@ -13895,8 +14019,8 @@ function renderConflictBlocks(blocks) {
|
|
|
13895
14019
|
}
|
|
13896
14020
|
function conflictError(blocks, pkg, commit) {
|
|
13897
14021
|
const hits = blocks.flatMap((b) => b.conflicts);
|
|
13898
|
-
return new
|
|
13899
|
-
code:
|
|
14022
|
+
return new CliError31({
|
|
14023
|
+
code: CliErrorCode33.SKILL_ID_CONFLICT,
|
|
13900
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"),
|
|
13901
14025
|
context: {
|
|
13902
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`,
|
|
@@ -13911,8 +14035,8 @@ function upsertManagedBlock(existing, begin, end, block, label) {
|
|
|
13911
14035
|
const finish = existing.indexOf(end);
|
|
13912
14036
|
const malformed = start < 0 !== finish < 0 || start >= 0 && (finish < start || existing.lastIndexOf(begin) !== start || existing.lastIndexOf(end) !== finish);
|
|
13913
14037
|
if (malformed) {
|
|
13914
|
-
throw new
|
|
13915
|
-
code:
|
|
14038
|
+
throw new CliError31({
|
|
14039
|
+
code: CliErrorCode33.METHOD_MANAGED_BLOCK_CORRUPT,
|
|
13916
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`,
|
|
13917
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` }
|
|
13918
14042
|
});
|
|
@@ -13976,8 +14100,8 @@ async function readLock(root) {
|
|
|
13976
14100
|
if (e.code === "ENOENT") return void 0;
|
|
13977
14101
|
throw e;
|
|
13978
14102
|
}
|
|
13979
|
-
const bad = (why) => new
|
|
13980
|
-
code:
|
|
14103
|
+
const bad = (why) => new CliError31({
|
|
14104
|
+
code: CliErrorCode33.METHOD_LOCK_INVALID,
|
|
13981
14105
|
message: `\u9501\u6587\u4EF6 ${METHOD_DIR}/${METHOD_LOCK_FILE} \u8BFB\u4E0D\u61C2\uFF1A${why}`,
|
|
13982
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`" }
|
|
13983
14107
|
});
|
|
@@ -14017,7 +14141,7 @@ async function resolveMethodRoot(project2, log) {
|
|
|
14017
14141
|
async function resolveTarget(root, requested) {
|
|
14018
14142
|
if (requested === "claude" || requested === "codex") return requested;
|
|
14019
14143
|
if (requested !== void 0 && requested !== "auto") {
|
|
14020
|
-
throw new
|
|
14144
|
+
throw new CliError31({ code: CliErrorCode33.INVALID_ARGUMENT, message: `--target \u53EA\u8BA4 claude / codex / auto\uFF0C\u6536\u5230 ${requested}` });
|
|
14021
14145
|
}
|
|
14022
14146
|
return (await readState(root))?.target ?? await detectTarget(root) ?? "claude";
|
|
14023
14147
|
}
|
|
@@ -14159,8 +14283,8 @@ async function runMethodPipeline(input, deps) {
|
|
|
14159
14283
|
const tags = await listRemoteTags(deps);
|
|
14160
14284
|
const r = resolveRef(tags, input.ref, deps);
|
|
14161
14285
|
if (input.expectCommit && r.commit !== input.expectCommit) {
|
|
14162
|
-
throw new
|
|
14163
|
-
code:
|
|
14286
|
+
throw new CliError31({
|
|
14287
|
+
code: CliErrorCode33.METHOD_TAG_MOVED,
|
|
14164
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`,
|
|
14165
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" }
|
|
14166
14290
|
});
|
|
@@ -14175,8 +14299,8 @@ async function runMethodPipeline(input, deps) {
|
|
|
14175
14299
|
await deps.git(["clone", "--depth", "1", "--filter=blob:none", "--sparse", "--quiet", "--branch", resolved.ref, deps.repoUrl, checkout]);
|
|
14176
14300
|
const head = (await deps.git(["-C", checkout, "rev-parse", "HEAD"], { timeoutMs: 1e4 })).trim();
|
|
14177
14301
|
if (head !== resolved.commit) {
|
|
14178
|
-
throw new
|
|
14179
|
-
code:
|
|
14302
|
+
throw new CliError31({
|
|
14303
|
+
code: CliErrorCode33.METHOD_TAG_MOVED,
|
|
14180
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`,
|
|
14181
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" }
|
|
14182
14306
|
});
|
|
@@ -14355,7 +14479,7 @@ async function runMethodStatus(root, deps, opts = {}) {
|
|
|
14355
14479
|
verdict: "fail",
|
|
14356
14480
|
detail: `\u6CA1\u6709 ${METHOD_DIR}/${METHOD_LOCK_FILE}\uFF1A\u8FD9\u4E2A\u9879\u76EE\u8FD8\u6CA1\u88C5\u65B9\u6CD5\u5305`,
|
|
14357
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",
|
|
14358
|
-
code:
|
|
14482
|
+
code: CliErrorCode33.METHOD_NOT_INSTALLED
|
|
14359
14483
|
});
|
|
14360
14484
|
return done();
|
|
14361
14485
|
}
|
|
@@ -14369,7 +14493,7 @@ async function runMethodStatus(root, deps, opts = {}) {
|
|
|
14369
14493
|
verdict: "fail",
|
|
14370
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",
|
|
14371
14495
|
nextStep: "`hcm chiron method install`\uFF08\u6309\u9501\u6587\u4EF6\u7684\u7248\u672C\u88C5\uFF09",
|
|
14372
|
-
code:
|
|
14496
|
+
code: CliErrorCode33.METHOD_NOT_INSTALLED
|
|
14373
14497
|
});
|
|
14374
14498
|
} else {
|
|
14375
14499
|
report.installed.present = true;
|
|
@@ -14380,7 +14504,7 @@ async function runMethodStatus(root, deps, opts = {}) {
|
|
|
14380
14504
|
verdict: "fail",
|
|
14381
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",
|
|
14382
14506
|
nextStep: "`hcm chiron method install`\uFF08\u6309\u9501\u6587\u4EF6\u7684 commit \u91CD\u88C5\uFF09",
|
|
14383
|
-
code:
|
|
14507
|
+
code: CliErrorCode33.METHOD_DIGEST_MISMATCH
|
|
14384
14508
|
});
|
|
14385
14509
|
} else {
|
|
14386
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` });
|
|
@@ -14424,13 +14548,13 @@ async function runMethodStatus(root, deps, opts = {}) {
|
|
|
14424
14548
|
verdict: "fail",
|
|
14425
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}`,
|
|
14426
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-*/`",
|
|
14427
|
-
code:
|
|
14551
|
+
code: CliErrorCode33.METHOD_DIGEST_MISMATCH
|
|
14428
14552
|
} : {
|
|
14429
14553
|
item: "\u6458\u8981",
|
|
14430
14554
|
verdict: "fail",
|
|
14431
14555
|
detail: `${bad.length} \u4EFD\u6587\u4EF6\u4E0E\u6E05\u5355\u4E0D\u7B26\uFF1A${listing}`,
|
|
14432
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",
|
|
14433
|
-
code:
|
|
14557
|
+
code: CliErrorCode33.METHOD_DIGEST_MISMATCH
|
|
14434
14558
|
});
|
|
14435
14559
|
} else {
|
|
14436
14560
|
report.rows.push({
|
|
@@ -14453,7 +14577,7 @@ async function runMethodStatus(root, deps, opts = {}) {
|
|
|
14453
14577
|
verdict: "warn",
|
|
14454
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`,
|
|
14455
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>`",
|
|
14456
|
-
code:
|
|
14580
|
+
code: CliErrorCode33.METHOD_TAG_MOVED
|
|
14457
14581
|
});
|
|
14458
14582
|
} else if (!SEMVER_TAG.test(lock.ref) || !report.remote.latestTag) {
|
|
14459
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";
|
|
@@ -14498,7 +14622,7 @@ async function runMethodStatus(root, deps, opts = {}) {
|
|
|
14498
14622
|
const hits = report.conflictCheck.flatMap((b) => b.conflicts);
|
|
14499
14623
|
const unchecked = report.conflictCheck.filter((b) => !b.checked);
|
|
14500
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");
|
|
14501
|
-
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 });
|
|
14502
14626
|
}
|
|
14503
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" });
|
|
14504
14628
|
return done();
|
|
@@ -14517,10 +14641,10 @@ async function inspectMethodForDoctor(root, deps = quietDeps()) {
|
|
|
14517
14641
|
const row = (item) => s.rows.find((r) => r.item === item);
|
|
14518
14642
|
const lockRow = row("\u9501\u5B9A");
|
|
14519
14643
|
if (!s.lock) {
|
|
14520
|
-
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 };
|
|
14521
14645
|
}
|
|
14522
14646
|
const install = row("\u5B89\u88C5");
|
|
14523
|
-
if (install?.code ===
|
|
14647
|
+
if (install?.code === CliErrorCode33.METHOD_NOT_INSTALLED) {
|
|
14524
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" };
|
|
14525
14649
|
}
|
|
14526
14650
|
const local = [install, row("\u6458\u8981")].find((r) => r && r.verdict === "fail");
|
|
@@ -14537,7 +14661,7 @@ function quietDeps() {
|
|
|
14537
14661
|
} };
|
|
14538
14662
|
}
|
|
14539
14663
|
function emit6(output, data, text) {
|
|
14540
|
-
if (output === "json" || output === "yaml") process.stdout.write(
|
|
14664
|
+
if (output === "json" || output === "yaml") process.stdout.write(formatObject28(data, { format: output }) + "\n");
|
|
14541
14665
|
else process.stdout.write(text() + "\n");
|
|
14542
14666
|
}
|
|
14543
14667
|
async function runMethodInstall(args, deps = defaultMethodDeps()) {
|
|
@@ -14553,8 +14677,8 @@ async function runMethodUpdate(args, deps = defaultMethodDeps()) {
|
|
|
14553
14677
|
const { root, rootSource } = await resolveMethodRoot(args.project, deps.log);
|
|
14554
14678
|
const lock = await readLock(root);
|
|
14555
14679
|
if (!lock) {
|
|
14556
|
-
throw new
|
|
14557
|
-
code:
|
|
14680
|
+
throw new CliError31({
|
|
14681
|
+
code: CliErrorCode33.METHOD_NOT_INSTALLED,
|
|
14558
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`,
|
|
14559
14683
|
context: { nextStep: "`hcm chiron method install`\uFF08\u88C5\u6700\u65B0\u7684\u7248\u672C tag\uFF09" }
|
|
14560
14684
|
});
|
|
@@ -14603,7 +14727,7 @@ async function methodStatusCommand(args) {
|
|
|
14603
14727
|
// src/commands/doctor/local-checks.ts
|
|
14604
14728
|
import { promises as fs11 } from "fs";
|
|
14605
14729
|
import path13 from "path";
|
|
14606
|
-
import
|
|
14730
|
+
import axios6 from "axios";
|
|
14607
14731
|
import { fetchSkillCatalog as fetchSkillCatalog3, fetchSkillMarkdown as fetchSkillMarkdown2, fetchSkillReference as fetchSkillReference2, normalizeReferences as normalizeReferences2, normalizeOrigin as normalizeOrigin6, resolveChironBase as resolveChironBase3 } from "@hcmai/sdk";
|
|
14608
14732
|
|
|
14609
14733
|
// src/commands/doctor/result.ts
|
|
@@ -14742,7 +14866,7 @@ function hasProductSkills(states) {
|
|
|
14742
14866
|
}
|
|
14743
14867
|
async function inspectSkillsFresh(states, endpoint, signal) {
|
|
14744
14868
|
if (!hasProductSkills(states)) return { level: "NOT_APPLICABLE", summary: NO_PRODUCT_SKILLS, note: "\u672A\u8BF7\u6C42\u6280\u80FD\u76EE\u5F55" };
|
|
14745
|
-
const http =
|
|
14869
|
+
const http = axios6.create({
|
|
14746
14870
|
baseURL: endpoint,
|
|
14747
14871
|
timeout: 5e3,
|
|
14748
14872
|
maxRedirects: 0,
|
|
@@ -14840,11 +14964,11 @@ var localChecks = { project, credential, version, installed, fresh, boundary, me
|
|
|
14840
14964
|
|
|
14841
14965
|
// src/commands/doctor/connect-checks.ts
|
|
14842
14966
|
init_auth_guard();
|
|
14843
|
-
import
|
|
14844
|
-
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";
|
|
14845
14969
|
|
|
14846
14970
|
// src/commands/doctor/server-report.ts
|
|
14847
|
-
import
|
|
14971
|
+
import axios7 from "axios";
|
|
14848
14972
|
import { classifyStatus } from "@hcmai/sdk";
|
|
14849
14973
|
var optionalText2 = (value) => value === void 0 || value === null || typeof value === "string";
|
|
14850
14974
|
var fullScope = { stage: null, only: [], skip: [], active: false };
|
|
@@ -14878,7 +15002,7 @@ var requestServerReport = async (endpoint, token, timeoutMs, budgetMs, signal, s
|
|
|
14878
15002
|
...scope.only.length ? { only: scope.only.join(",") } : {},
|
|
14879
15003
|
...scope.skip.length ? { skip: scope.skip.join(",") } : {}
|
|
14880
15004
|
};
|
|
14881
|
-
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 } });
|
|
14882
15006
|
return {
|
|
14883
15007
|
status: res.status,
|
|
14884
15008
|
body: res.data,
|
|
@@ -14887,7 +15011,7 @@ var requestServerReport = async (endpoint, token, timeoutMs, budgetMs, signal, s
|
|
|
14887
15011
|
};
|
|
14888
15012
|
};
|
|
14889
15013
|
function stoppedWaiting(error, signal) {
|
|
14890
|
-
return signal.aborted ||
|
|
15014
|
+
return signal.aborted || axios7.isAxiosError(error) && error.code === "ECONNABORTED";
|
|
14891
15015
|
}
|
|
14892
15016
|
function httpNote(out) {
|
|
14893
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"]}` : ""}`;
|
|
@@ -15194,8 +15318,8 @@ var identity = async (ctx, env2, execution) => {
|
|
|
15194
15318
|
if (execution.signal.aborted) await e.close?.();
|
|
15195
15319
|
return observation;
|
|
15196
15320
|
} catch (error) {
|
|
15197
|
-
const detail = error instanceof
|
|
15198
|
-
const errorCode = error instanceof
|
|
15321
|
+
const detail = error instanceof CliError32 ? error.context : void 0;
|
|
15322
|
+
const errorCode = error instanceof CliError32 ? error.code : void 0;
|
|
15199
15323
|
const actorStep = error !== null && typeof error === "object" ? error[AS_ACTOR_STEP] : void 0;
|
|
15200
15324
|
if (actorStep) {
|
|
15201
15325
|
const actorCode = actorStep === "meta" || actorStep === "env" ? "IDENTITY_META_INVALID" : actorStep === "resolve" && errorCode === "IDENTITY_NOT_FOUND" ? "IDENTITY_NOT_LOGGED_IN" : "IDENTITY_UNVERIFIED";
|
|
@@ -15205,11 +15329,11 @@ var identity = async (ctx, env2, execution) => {
|
|
|
15205
15329
|
const code3 = detail.mismatch === "tenant" ? "TENANT_MISMATCH" : "IDENTITY_USER_MISMATCH";
|
|
15206
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)}` });
|
|
15207
15331
|
}
|
|
15208
|
-
const status =
|
|
15209
|
-
const requestPath =
|
|
15332
|
+
const status = axios8.isAxiosError(error) ? error.response?.status : void 0;
|
|
15333
|
+
const requestPath = axios8.isAxiosError(error) ? error.config?.url ?? "" : "";
|
|
15210
15334
|
const proxyStart = requestPath.endsWith(IMPERSONATION_START_PATH);
|
|
15211
15335
|
const userLookup = requestPath.endsWith(USER_LOOKUP_PATH);
|
|
15212
|
-
const envelope =
|
|
15336
|
+
const envelope = axios8.isAxiosError(error) && obj(error.response?.data) && obj(error.response.data.error) ? error.response.data.error : void 0;
|
|
15213
15337
|
const targetMissing = status === 404 && proxyStart && envelope?.code === "NOT_FOUND";
|
|
15214
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";
|
|
15215
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";
|
|
@@ -15773,11 +15897,11 @@ function renderChironDoctor(report) {
|
|
|
15773
15897
|
|
|
15774
15898
|
// src/commands/doctor/platform-ops.ts
|
|
15775
15899
|
import { createHash as createHash8 } from "crypto";
|
|
15776
|
-
import
|
|
15900
|
+
import axios9 from "axios";
|
|
15777
15901
|
import {
|
|
15778
15902
|
classifyStatus as classifyStatus2,
|
|
15779
|
-
CliError as
|
|
15780
|
-
CliErrorCode as
|
|
15903
|
+
CliError as CliError33,
|
|
15904
|
+
CliErrorCode as CliErrorCode34,
|
|
15781
15905
|
loadGlobalConfig as loadGlobalConfig11,
|
|
15782
15906
|
printResolvedEnvironment as printResolvedEnvironment8,
|
|
15783
15907
|
resolveEnvContext as resolveEnvContext8
|
|
@@ -15843,7 +15967,7 @@ var placeholder = {
|
|
|
15843
15967
|
};
|
|
15844
15968
|
var OPS_DESCRIPTORS = [connectivity2, api, placeholder];
|
|
15845
15969
|
var requestOpsReport = async (endpoint, key2, timeoutMs, budgetMs, signal, scope) => {
|
|
15846
|
-
const res = await
|
|
15970
|
+
const res = await axios9.get(OPS_PATH, {
|
|
15847
15971
|
baseURL: endpoint,
|
|
15848
15972
|
timeout: timeoutMs,
|
|
15849
15973
|
signal,
|
|
@@ -15885,11 +16009,11 @@ async function readPlatformOpsKey(args, io = {
|
|
|
15885
16009
|
} else if (io.isTTY) {
|
|
15886
16010
|
source = "tty";
|
|
15887
16011
|
key2 = await io.prompt();
|
|
15888
|
-
} 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" });
|
|
15889
16013
|
if (blank) io.stderr(`HCM_PLATFORM_OPS_KEY \u5168\u662F\u7A7A\u767D\uFF0C\u5DF2\u5FFD\u7565\uFF1B\u6539\u4ECE ${source} \u8BFB\u53D6
|
|
15890
16014
|
`);
|
|
15891
16015
|
key2 = key2.trim();
|
|
15892
|
-
if (!key2) throw new
|
|
16016
|
+
if (!key2) throw new CliError33({ code: CliErrorCode34.INVALID_ARGUMENT, message: "\u8FD0\u7EF4\u5BC6\u94A5\u4E3A\u7A7A" });
|
|
15893
16017
|
io.stderr(`\u8FD0\u7EF4\u5BC6\u94A5\u6765\u6E90\uFF1A${source} \xB7 \u6307\u7EB9 ${opsKeyFingerprint(key2)}
|
|
15894
16018
|
`);
|
|
15895
16019
|
return { key: key2, source };
|
|
@@ -15898,12 +16022,12 @@ var split = (value) => (Array.isArray(value) ? value : value ? [value] : []).fla
|
|
|
15898
16022
|
function scopeFor(args) {
|
|
15899
16023
|
const only = split(args.only), skip = split(args.skip);
|
|
15900
16024
|
for (const token of [...only, ...skip]) if (!("platform.".startsWith(token) || token.startsWith("platform.")))
|
|
15901
|
-
throw new
|
|
15902
|
-
code:
|
|
16025
|
+
throw new CliError33({
|
|
16026
|
+
code: CliErrorCode34.INVALID_ARGUMENT,
|
|
15903
16027
|
message: `\u8FD0\u7EF4\u89C6\u56FE\u53EA\u770B\u5E73\u53F0\u5C42\uFF1A--only / --skip \u53EA\u63A5\u53D7 platform \u524D\u7F00\uFF0C\u6536\u5230 ${token}`
|
|
15904
16028
|
});
|
|
15905
|
-
if (skip.some((token) => "platform.".startsWith(token))) throw new
|
|
15906
|
-
code:
|
|
16029
|
+
if (skip.some((token) => "platform.".startsWith(token))) throw new CliError33({
|
|
16030
|
+
code: CliErrorCode34.INVALID_ARGUMENT,
|
|
15907
16031
|
message: "\u6392\u9664\u4E86\u5E73\u53F0\u5C42\uFF0C\u8FD0\u7EF4\u89C6\u56FE\u6CA1\u6709\u53EF\u770B\u7684\u68C0\u67E5"
|
|
15908
16032
|
});
|
|
15909
16033
|
return {
|
|
@@ -16059,7 +16183,7 @@ function failure(ctx, env2, health, key2) {
|
|
|
16059
16183
|
}
|
|
16060
16184
|
var ENV_HINT = "hcm env list \u67E5\u770B\u53EF\u9009\u73AF\u5883\uFF1Bhcm env add <\u540D> --endpoint <url> \u767B\u8BB0";
|
|
16061
16185
|
function resolverMessage(error) {
|
|
16062
|
-
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";
|
|
16063
16187
|
return (error instanceof Error ? error.message : safeError(error)).replace(/\s*(&&\s*)?hcm\s+login\b[^;;\n]*/gi, "");
|
|
16064
16188
|
}
|
|
16065
16189
|
async function runPlatformOps(args, services, readKey = readPlatformOpsKey, onReport) {
|
|
@@ -16068,10 +16192,10 @@ async function runPlatformOps(args, services, readKey = readPlatformOpsKey, onRe
|
|
|
16068
16192
|
try {
|
|
16069
16193
|
resolved = await resolveEnvContext8({ envFlag: args.env }, process.env, await loadGlobalConfig11());
|
|
16070
16194
|
} catch (error2) {
|
|
16071
|
-
throw new
|
|
16195
|
+
throw new CliError33({ code: CliErrorCode34.INVALID_ARGUMENT, message: `${resolverMessage(error2)}\uFF1B${ENV_HINT}` });
|
|
16072
16196
|
}
|
|
16073
|
-
if (!resolved.config.endpoint) throw new
|
|
16074
|
-
code:
|
|
16197
|
+
if (!resolved.config.endpoint) throw new CliError33({
|
|
16198
|
+
code: CliErrorCode34.INVALID_ARGUMENT,
|
|
16075
16199
|
message: `\u672A\u89E3\u6790\u5230 endpoint\uFF1B${ENV_HINT}`
|
|
16076
16200
|
});
|
|
16077
16201
|
printResolvedEnvironment8(resolved);
|
|
@@ -16117,8 +16241,8 @@ async function runPlatformOps(args, services, readKey = readPlatformOpsKey, onRe
|
|
|
16117
16241
|
const error = out && object(out.body) && object(out.body.error) ? out.body.error : void 0;
|
|
16118
16242
|
if (out?.status === 400 && error?.code === "HEALTH_REPORT_INVALID_PARAM") {
|
|
16119
16243
|
const trace = out.headers["x-trace-id"];
|
|
16120
|
-
throw new
|
|
16121
|
-
code:
|
|
16244
|
+
throw new CliError33({
|
|
16245
|
+
code: CliErrorCode34.INVALID_ARGUMENT,
|
|
16122
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`}`
|
|
16123
16247
|
});
|
|
16124
16248
|
}
|
|
@@ -16410,7 +16534,7 @@ var defaultServices = {
|
|
|
16410
16534
|
latestVersion: fetchLatestVersion,
|
|
16411
16535
|
skillsFresh: inspectSkillsFresh,
|
|
16412
16536
|
asAuth: (...args) => ensureAsAuth(...args),
|
|
16413
|
-
probe: (endpoint, token, signal) => httpProbe2(
|
|
16537
|
+
probe: (endpoint, token, signal) => httpProbe2(axios10.create({
|
|
16414
16538
|
baseURL: endpoint,
|
|
16415
16539
|
timeout: 5e3,
|
|
16416
16540
|
maxRedirects: 0,
|
|
@@ -16421,13 +16545,13 @@ var defaultServices = {
|
|
|
16421
16545
|
};
|
|
16422
16546
|
function validate(args) {
|
|
16423
16547
|
for (const [key2, value, choices] of [["output", args.output, ["table", "json", "yaml"]], ["fail-on", args.failOn, ["blocked", "risks"]]])
|
|
16424
|
-
if (value !== void 0 && !choices.includes(value)) throw new
|
|
16425
|
-
code:
|
|
16548
|
+
if (value !== void 0 && !choices.includes(value)) throw new CliError34({
|
|
16549
|
+
code: CliErrorCode35.INVALID_ARGUMENT,
|
|
16426
16550
|
message: `--${key2} \u53EA\u63A5\u53D7 ${choices.join(" / ")}\uFF0C\u6536\u5230 ${value}`
|
|
16427
16551
|
});
|
|
16428
16552
|
const stages = ["handover", "baseline", "configure", "migrate", "integrate", "golive", "operate"];
|
|
16429
|
-
if (args.stage !== void 0 && !stages.includes(args.stage.toLowerCase())) throw new
|
|
16430
|
-
code:
|
|
16553
|
+
if (args.stage !== void 0 && !stages.includes(args.stage.toLowerCase())) throw new CliError34({
|
|
16554
|
+
code: CliErrorCode35.INVALID_ARGUMENT,
|
|
16431
16555
|
message: `--stage \u53EA\u63A5\u53D7 ${stages.join(" / ")}\uFF0C\u6536\u5230 ${args.stage}`
|
|
16432
16556
|
});
|
|
16433
16557
|
if (args.platformOpsKeyStdin && !args.platformOps) invalidScope("--platform-ops-key-stdin \u53EA\u80FD\u4E0E --platform-ops \u540C\u7528");
|
|
@@ -16448,7 +16572,7 @@ var tokens = (value) => (Array.isArray(value) ? value : value ? [value] : []).fl
|
|
|
16448
16572
|
var matches = (id, only, skip) => (!only.length || only.some((t) => id.startsWith(t))) && !skip.some((t) => id.startsWith(t));
|
|
16449
16573
|
var serverCandidate = (t) => ["platform.", "tenant."].some((prefix) => prefix.startsWith(t) || t.startsWith(prefix));
|
|
16450
16574
|
function invalidScope(message) {
|
|
16451
|
-
throw new
|
|
16575
|
+
throw new CliError34({ code: CliErrorCode35.INVALID_ARGUMENT, message });
|
|
16452
16576
|
}
|
|
16453
16577
|
function scopeFor2(args, catalog) {
|
|
16454
16578
|
const only = tokens(args.only), skip = tokens(args.skip), stage = args.stage?.toLowerCase() ?? null;
|
|
@@ -16483,7 +16607,7 @@ async function readCredential(envFlag, root, as) {
|
|
|
16483
16607
|
try {
|
|
16484
16608
|
resolved = await resolveEnvContext9({ envFlag, cwd: root }, process.env, await loadGlobalConfig12());
|
|
16485
16609
|
} catch (error) {
|
|
16486
|
-
if (error instanceof
|
|
16610
|
+
if (error instanceof CliError34 && error.code === CliErrorCode35.ENV_NOT_FOUND) return { resolved: null };
|
|
16487
16611
|
throw error;
|
|
16488
16612
|
}
|
|
16489
16613
|
if (as) return { resolved };
|
|
@@ -16492,14 +16616,14 @@ async function readCredential(envFlag, root, as) {
|
|
|
16492
16616
|
try {
|
|
16493
16617
|
identity3 = await resolveActiveIdentity2({}, process.env, resolved.name);
|
|
16494
16618
|
} catch (error) {
|
|
16495
|
-
if (error instanceof
|
|
16619
|
+
if (error instanceof CliError34 && error.code === CliErrorCode35.IDENTITY_NOT_FOUND) return { resolved, error: found("IDENTITY_NOT_LOGGED_IN") };
|
|
16496
16620
|
throw error;
|
|
16497
16621
|
}
|
|
16498
16622
|
let meta2;
|
|
16499
16623
|
try {
|
|
16500
16624
|
meta2 = await loadIdentity5(identity3);
|
|
16501
16625
|
} catch (error) {
|
|
16502
|
-
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`) };
|
|
16503
16627
|
throw error;
|
|
16504
16628
|
}
|
|
16505
16629
|
if (!meta2.env || meta2.env !== resolved.name) return {
|
|
@@ -16541,7 +16665,7 @@ async function prepareContext(args, deps) {
|
|
|
16541
16665
|
const detail = `${safeError(error)}\uFF1B\u53EF\u9009\u73AF\u5883\uFF1A${available.join(", ") || "\uFF08\u65E0\uFF09"}`;
|
|
16542
16666
|
projectObservation = found("ENV_NOT_RESOLVED", detail);
|
|
16543
16667
|
targetEnv = null;
|
|
16544
|
-
const slotMissing = error instanceof
|
|
16668
|
+
const slotMissing = error instanceof CliError34 && error.code === CliErrorCode35.ENV_NOT_FOUND;
|
|
16545
16669
|
const project2 = args.project !== void 0 ? ` --project ${quote(root)}` : "";
|
|
16546
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}`;
|
|
16547
16671
|
if (slotMissing || error instanceof Error && error.message === "\u672C\u673A\u69FD\u4E0D\u5C5E\u4E8E\u5F53\u524D\u9879\u76EE")
|
|
@@ -16709,12 +16833,12 @@ async function chironDoctorCommand(args, deps) {
|
|
|
16709
16833
|
}
|
|
16710
16834
|
}
|
|
16711
16835
|
const data = explainOpsCatalog(args.explain, descriptorReport);
|
|
16712
|
-
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");
|
|
16713
16837
|
process.exitCode = 0;
|
|
16714
16838
|
return;
|
|
16715
16839
|
}
|
|
16716
16840
|
const report2 = await runPlatformOps(args, { ...defaultServices, ...deps });
|
|
16717
|
-
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");
|
|
16718
16842
|
process.exitCode = conclude(report2.results, { total: report2.coverage.total, failOn: args.failOn ?? "blocked" }).exitCode;
|
|
16719
16843
|
return;
|
|
16720
16844
|
}
|
|
@@ -16726,12 +16850,12 @@ async function chironDoctorCommand(args, deps) {
|
|
|
16726
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}
|
|
16727
16851
|
`);
|
|
16728
16852
|
}
|
|
16729
|
-
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");
|
|
16730
16854
|
process.exitCode = 0;
|
|
16731
16855
|
return;
|
|
16732
16856
|
}
|
|
16733
16857
|
const report = await runChironDoctor(args, deps);
|
|
16734
|
-
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");
|
|
16735
16859
|
process.exitCode = conclude(report.results, {
|
|
16736
16860
|
total: report.coverage.total,
|
|
16737
16861
|
failOn: args.failOn ?? "blocked",
|
|
@@ -16752,11 +16876,11 @@ import { accessSync, constants, readdirSync as readdirSync3 } from "fs";
|
|
|
16752
16876
|
import fs13 from "fs/promises";
|
|
16753
16877
|
import os6 from "os";
|
|
16754
16878
|
import path16 from "path";
|
|
16755
|
-
import { CliError as
|
|
16879
|
+
import { CliError as CliError37, CliErrorCode as CliErrorCode38, formatObject as formatObject30, HcmClient as HcmClient25, loadEnv as loadEnv6 } from "@hcmai/sdk";
|
|
16756
16880
|
import { createRequire } from "module";
|
|
16757
16881
|
|
|
16758
16882
|
// src/commands/chiron-page-cdp.ts
|
|
16759
|
-
import { CliError as
|
|
16883
|
+
import { CliError as CliError35, CliErrorCode as CliErrorCode36 } from "@hcmai/sdk";
|
|
16760
16884
|
|
|
16761
16885
|
// src/commands/chiron-page-shared.ts
|
|
16762
16886
|
function redactTicket(text) {
|
|
@@ -16792,14 +16916,14 @@ function normalizeCdpEndpoint(raw) {
|
|
|
16792
16916
|
try {
|
|
16793
16917
|
url = new URL(candidate);
|
|
16794
16918
|
} catch {
|
|
16795
|
-
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}` });
|
|
16796
16920
|
}
|
|
16797
16921
|
const protocol = url.protocol === "wss:" ? "https:" : url.protocol === "ws:" ? "http:" : url.protocol;
|
|
16798
16922
|
if (protocol !== "http:" && protocol !== "https:") {
|
|
16799
|
-
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}` });
|
|
16800
16924
|
}
|
|
16801
16925
|
if (!url.port) {
|
|
16802
|
-
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}` });
|
|
16803
16927
|
}
|
|
16804
16928
|
return `${protocol}//${url.hostname}:${url.port}`;
|
|
16805
16929
|
}
|
|
@@ -16896,8 +17020,8 @@ async function captureViaCdp(input, io) {
|
|
|
16896
17020
|
const browser = version2?.Browser ? String(version2.Browser) : `attached ${input.endpoint}`;
|
|
16897
17021
|
const target = await io.fetchJson(`${input.endpoint}/json/new?about:blank`, "PUT");
|
|
16898
17022
|
if (!target?.id || !target.webSocketDebuggerUrl) {
|
|
16899
|
-
throw new
|
|
16900
|
-
code:
|
|
17023
|
+
throw new CliError35({
|
|
17024
|
+
code: CliErrorCode36.SERVER_ERROR,
|
|
16901
17025
|
message: `${input.endpoint}/json/new \u6CA1\u6709\u7ED9\u51FA\u6807\u7B7E\u9875\uFF08id / webSocketDebuggerUrl \u7F3A\u5931\uFF09`,
|
|
16902
17026
|
context: { nextStep: "\u786E\u8BA4 Chrome \u662F\u5E26 --remote-debugging-port \u8D77\u7684\uFF0C\u4E14 --cdp \u6307\u5230\u7684\u662F\u5B83" }
|
|
16903
17027
|
});
|
|
@@ -16927,7 +17051,7 @@ async function captureViaCdp(input, io) {
|
|
|
16927
17051
|
});
|
|
16928
17052
|
if (r.exceptionDetails) {
|
|
16929
17053
|
const why = r.exceptionDetails.exception?.description ?? r.exceptionDetails.text ?? "unknown";
|
|
16930
|
-
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)}` });
|
|
16931
17055
|
}
|
|
16932
17056
|
evalResult = r.result && "value" in r.result ? toPlainJson(r.result.value) : toPlainJson(r.result?.description);
|
|
16933
17057
|
}
|
|
@@ -16938,7 +17062,7 @@ async function captureViaCdp(input, io) {
|
|
|
16938
17062
|
const dom = typeof domReply.result?.value === "string" ? domReply.result.value : "";
|
|
16939
17063
|
const shot = await session.send("Page.captureScreenshot", { format: "png" });
|
|
16940
17064
|
if (!shot.data) {
|
|
16941
|
-
throw new
|
|
17065
|
+
throw new CliError35({ code: CliErrorCode36.SERVER_ERROR, message: "Page.captureScreenshot \u6CA1\u6709\u8FD4\u56DE\u56FE\u50CF\u6570\u636E" });
|
|
16942
17066
|
}
|
|
16943
17067
|
await io.writeFile(input.screenshot, Buffer.from(shot.data, "base64"));
|
|
16944
17068
|
return { dom, browser, evalResult, navigated, minted };
|
|
@@ -16960,7 +17084,7 @@ var defaultCdpIo = {
|
|
|
16960
17084
|
openSocket: (wsUrl) => new Promise((resolve3, reject) => {
|
|
16961
17085
|
const Ctor = globalThis.WebSocket;
|
|
16962
17086
|
if (!Ctor) {
|
|
16963
|
-
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" }));
|
|
16964
17088
|
return;
|
|
16965
17089
|
}
|
|
16966
17090
|
const ws = new Ctor(wsUrl);
|
|
@@ -16983,7 +17107,7 @@ var defaultCdpIo = {
|
|
|
16983
17107
|
|
|
16984
17108
|
// src/commands/chiron-page-playwright.ts
|
|
16985
17109
|
import path15 from "path";
|
|
16986
|
-
import { CliError as
|
|
17110
|
+
import { CliError as CliError36, CliErrorCode as CliErrorCode37 } from "@hcmai/sdk";
|
|
16987
17111
|
function playwrightCacheRoot(probe2) {
|
|
16988
17112
|
const override = probe2.env.PLAYWRIGHT_BROWSERS_PATH?.trim();
|
|
16989
17113
|
if (override === "0" && probe2.packageRoot) return path15.join(probe2.packageRoot, ".local-browsers");
|
|
@@ -17026,8 +17150,8 @@ function discoverPlaywrightBrowser(probe2) {
|
|
|
17026
17150
|
const explicit = probe2.env.HCM_PLAYWRIGHT_EXECUTABLE?.trim();
|
|
17027
17151
|
if (explicit) {
|
|
17028
17152
|
if (probe2.executable(explicit)) return { executablePath: explicit, kind: "explicit", from: "HCM_PLAYWRIGHT_EXECUTABLE" };
|
|
17029
|
-
throw new
|
|
17030
|
-
code:
|
|
17153
|
+
throw new CliError36({
|
|
17154
|
+
code: CliErrorCode37.INVALID_ARGUMENT,
|
|
17031
17155
|
message: `HCM_PLAYWRIGHT_EXECUTABLE \u6307\u7684\u6587\u4EF6\u4E0D\u53EF\u6267\u884C\uFF1A${explicit}`,
|
|
17032
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" }
|
|
17033
17157
|
});
|
|
@@ -17069,8 +17193,8 @@ async function captureViaPlaywright(input) {
|
|
|
17069
17193
|
}
|
|
17070
17194
|
}
|
|
17071
17195
|
if (!browser) {
|
|
17072
|
-
throw new
|
|
17073
|
-
code:
|
|
17196
|
+
throw new CliError36({
|
|
17197
|
+
code: CliErrorCode37.SERVER_ERROR,
|
|
17074
17198
|
message: `Playwright \u8D77\u4E0D\u4E86\u6D4F\u89C8\u5668\uFF1A${failures.join("\uFF1B")}`,
|
|
17075
17199
|
context: {
|
|
17076
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"
|
|
@@ -17090,7 +17214,7 @@ async function captureViaPlaywright(input) {
|
|
|
17090
17214
|
evalResult = toPlainJson(await page.evaluate(wrapEvalBody(input.evalJs)));
|
|
17091
17215
|
} catch (e) {
|
|
17092
17216
|
const why = (e instanceof Error ? e.message : String(e)).split("\n")[0] ?? "";
|
|
17093
|
-
throw new
|
|
17217
|
+
throw new CliError36({ code: CliErrorCode37.INVALID_ARGUMENT, message: `--eval \u5728\u9875\u9762\u91CC\u629B\u4E86\u5F02\u5E38\uFF1A${redactTicket(why)}` });
|
|
17094
17218
|
}
|
|
17095
17219
|
}
|
|
17096
17220
|
const dom = await page.content();
|
|
@@ -17114,13 +17238,13 @@ function judgePageContent(input) {
|
|
|
17114
17238
|
function parseViewport(size) {
|
|
17115
17239
|
const m = /^(\d+)x(\d+)$/.exec(size.trim());
|
|
17116
17240
|
if (!m) {
|
|
17117
|
-
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}` });
|
|
17118
17242
|
}
|
|
17119
17243
|
const width = Number(m[1]);
|
|
17120
17244
|
const height = Number(m[2]);
|
|
17121
17245
|
if (width < VIEWPORT_MIN.width || width > VIEWPORT_MAX.width || height < VIEWPORT_MIN.height || height > VIEWPORT_MAX.height) {
|
|
17122
|
-
throw new
|
|
17123
|
-
code:
|
|
17246
|
+
throw new CliError37({
|
|
17247
|
+
code: CliErrorCode38.INVALID_ARGUMENT,
|
|
17124
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}`
|
|
17125
17249
|
});
|
|
17126
17250
|
}
|
|
@@ -17130,23 +17254,23 @@ function parseWaitMs(raw) {
|
|
|
17130
17254
|
if (raw === void 0) return 1e4;
|
|
17131
17255
|
const value = typeof raw === "number" ? raw : Number(raw);
|
|
17132
17256
|
if (!Number.isInteger(value) || value < 0 || value > WAIT_MS_MAX) {
|
|
17133
|
-
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}` });
|
|
17134
17258
|
}
|
|
17135
17259
|
return value;
|
|
17136
17260
|
}
|
|
17137
17261
|
function resolveEvidenceTarget(projectRoot, out) {
|
|
17138
17262
|
if (!out?.trim()) {
|
|
17139
|
-
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` });
|
|
17140
17264
|
}
|
|
17141
17265
|
if (!out.endsWith(".png")) {
|
|
17142
|
-
throw new
|
|
17266
|
+
throw new CliError37({ code: CliErrorCode38.INVALID_ARGUMENT, message: `--out \u8981\u4EE5 .png \u7ED3\u5C3E\uFF0C\u6536\u5230\u7684\u662F ${out}` });
|
|
17143
17267
|
}
|
|
17144
17268
|
const root = path16.resolve(projectRoot);
|
|
17145
17269
|
const evidenceRoot = path16.join(root, EVIDENCE_DIR);
|
|
17146
17270
|
const absolute = path16.resolve(root, out);
|
|
17147
17271
|
if (absolute !== evidenceRoot && !absolute.startsWith(evidenceRoot + path16.sep)) {
|
|
17148
|
-
throw new
|
|
17149
|
-
code:
|
|
17272
|
+
throw new CliError37({
|
|
17273
|
+
code: CliErrorCode38.INVALID_ARGUMENT,
|
|
17150
17274
|
message: `--out \u8981\u843D\u5728\u9879\u76EE\u7684 ${EVIDENCE_DIR}/ \u4E0B\uFF08${evidenceRoot}\uFF09\uFF0C\u6536\u5230\u7684\u662F ${absolute}`
|
|
17151
17275
|
});
|
|
17152
17276
|
}
|
|
@@ -17194,8 +17318,8 @@ async function assertInsideEvidence(deps, evidenceRoot, absolute) {
|
|
|
17194
17318
|
const canonicalParent = await deps.realpath(path16.dirname(absolute));
|
|
17195
17319
|
if (canonicalRoot === null || canonicalParent === null) return;
|
|
17196
17320
|
if (canonicalParent !== canonicalRoot && !canonicalParent.startsWith(canonicalRoot + path16.sep)) {
|
|
17197
|
-
throw new
|
|
17198
|
-
code:
|
|
17321
|
+
throw new CliError37({
|
|
17322
|
+
code: CliErrorCode38.INVALID_ARGUMENT,
|
|
17199
17323
|
message: `--out \u7684\u7236\u76EE\u5F55\u7ECF\u7B26\u53F7\u94FE\u63A5\u8DD1\u51FA\u4E86 ${EVIDENCE_DIR}/\uFF1A${canonicalParent}`
|
|
17200
17324
|
});
|
|
17201
17325
|
}
|
|
@@ -17204,8 +17328,8 @@ async function runChironPage(target, args, deps) {
|
|
|
17204
17328
|
const sitePath = normalizeTarget(target);
|
|
17205
17329
|
const expect = (args.expectText ?? []).filter((t) => t.trim().length > 0);
|
|
17206
17330
|
if (expect.length === 0) {
|
|
17207
|
-
throw new
|
|
17208
|
-
code:
|
|
17331
|
+
throw new CliError37({
|
|
17332
|
+
code: CliErrorCode38.MISSING_FLAG,
|
|
17209
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"
|
|
17210
17334
|
});
|
|
17211
17335
|
}
|
|
@@ -17215,8 +17339,8 @@ async function runChironPage(target, args, deps) {
|
|
|
17215
17339
|
const root = path16.resolve(args.project ?? ".");
|
|
17216
17340
|
const { evidenceRoot, absolute } = resolveEvidenceTarget(root, args.out);
|
|
17217
17341
|
if (await deps.present(absolute)) {
|
|
17218
|
-
throw new
|
|
17219
|
-
code:
|
|
17342
|
+
throw new CliError37({
|
|
17343
|
+
code: CliErrorCode38.INVALID_ARGUMENT,
|
|
17220
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`
|
|
17221
17345
|
});
|
|
17222
17346
|
}
|
|
@@ -17228,8 +17352,8 @@ async function runChironPage(target, args, deps) {
|
|
|
17228
17352
|
const playwrightBrowser = endpoint || forceSpawn ? null : deps.findPlaywrightBrowser();
|
|
17229
17353
|
const usePlaywright = !endpoint && !forceSpawn && (playwrightBrowser !== null || evalJs !== void 0);
|
|
17230
17354
|
if (evalJs && !endpoint && !usePlaywright) {
|
|
17231
|
-
throw new
|
|
17232
|
-
code:
|
|
17355
|
+
throw new CliError37({
|
|
17356
|
+
code: CliErrorCode38.INVALID_ARGUMENT,
|
|
17233
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",
|
|
17234
17358
|
context: { nextStep: "npx playwright install chromium-headless-shell\uFF0C\u6216\u5728\u6C99\u7BB1\u5916\u8D77 Chrome \u7528 --cdp \u8FDE" }
|
|
17235
17359
|
});
|
|
@@ -17247,10 +17371,10 @@ async function runChironPage(target, args, deps) {
|
|
|
17247
17371
|
try {
|
|
17248
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 });
|
|
17249
17373
|
} catch (e) {
|
|
17250
|
-
if (e instanceof
|
|
17374
|
+
if (e instanceof CliError37) throw new CliError37({ code: e.code, message: redactTicket(e.message), context: e.context });
|
|
17251
17375
|
const where = endpoint ? `\u8FDE\u5230 ${endpoint} \u7684 Chrome` : "Playwright \u8D77\u7684\u6D4F\u89C8\u5668";
|
|
17252
|
-
throw new
|
|
17253
|
-
code:
|
|
17376
|
+
throw new CliError37({
|
|
17377
|
+
code: CliErrorCode38.SERVER_ERROR,
|
|
17254
17378
|
message: `${where}\u6CA1\u8DD1\u5B8C\uFF1A${redactTicket(e instanceof Error ? e.message : String(e))}`,
|
|
17255
17379
|
context: {
|
|
17256
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"
|
|
@@ -17266,8 +17390,8 @@ async function runChironPage(target, args, deps) {
|
|
|
17266
17390
|
mode = "spawn";
|
|
17267
17391
|
const browser = deps.findBrowser();
|
|
17268
17392
|
if (!browser) {
|
|
17269
|
-
throw new
|
|
17270
|
-
code:
|
|
17393
|
+
throw new CliError37({
|
|
17394
|
+
code: CliErrorCode38.INVALID_ARGUMENT,
|
|
17271
17395
|
message: "\u672C\u673A\u627E\u4E0D\u5230 Playwright \u7684 Chromium\uFF0C\u4E5F\u627E\u4E0D\u5230 Chrome/Chromium\uFF0C\u622A\u4E0D\u4E86\u56FE\u3002",
|
|
17272
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" }
|
|
17273
17397
|
});
|
|
@@ -17275,8 +17399,8 @@ async function runChironPage(target, args, deps) {
|
|
|
17275
17399
|
minted = await mint();
|
|
17276
17400
|
const result = deps.capture({ browser, argv: chromeArgv({ viewport, waitMs, screenshot: absolute, url: minted.url, isRoot: process.getuid?.() === 0 }) });
|
|
17277
17401
|
if (!result.ok) {
|
|
17278
|
-
throw new
|
|
17279
|
-
code:
|
|
17402
|
+
throw new CliError37({
|
|
17403
|
+
code: CliErrorCode38.SERVER_ERROR,
|
|
17280
17404
|
message: `\u6D4F\u89C8\u5668\u6CA1\u8DD1\u5B8C\uFF1A${redactTicket(result.stderr.trim().split("\n").slice(-1)[0] ?? "\u65E0\u8F93\u51FA")}`,
|
|
17281
17405
|
context: { nextStep: spawnFailureNextStep(browser, result, deps.platform) }
|
|
17282
17406
|
});
|
|
@@ -17286,7 +17410,7 @@ async function runChironPage(target, args, deps) {
|
|
|
17286
17410
|
}
|
|
17287
17411
|
const bytes = await deps.present(absolute) ? await deps.sizeOf(absolute) : 0;
|
|
17288
17412
|
if (bytes === 0) {
|
|
17289
|
-
throw new
|
|
17413
|
+
throw new CliError37({ code: CliErrorCode38.SERVER_ERROR, message: `\u6D4F\u89C8\u5668\u6CA1\u5199\u51FA\u975E\u7A7A PNG\uFF1A${absolute}` });
|
|
17290
17414
|
}
|
|
17291
17415
|
const verdict = judgePageContent({ dom, expect, reject });
|
|
17292
17416
|
return {
|
|
@@ -17349,13 +17473,13 @@ var defaultChironPageDeps = {
|
|
|
17349
17473
|
const envCfg = await loadEnv6(ctx.env);
|
|
17350
17474
|
const frontend = ctx.frontend ?? envCfg.frontend;
|
|
17351
17475
|
if (!frontend?.trim()) {
|
|
17352
|
-
throw new
|
|
17353
|
-
code:
|
|
17476
|
+
throw new CliError37({
|
|
17477
|
+
code: CliErrorCode38.INVALID_ARGUMENT,
|
|
17354
17478
|
message: `env '${ctx.env}' \u6CA1\u914D\u524D\u7AEF\u5730\u5740\uFF0C\u5F00\u4E0D\u4E86\u9875\u9762\u3002`,
|
|
17355
17479
|
context: { nextStep: `hcm env edit frontend <\u524D\u7AEF\u5730\u5740> --env ${ctx.env}` }
|
|
17356
17480
|
});
|
|
17357
17481
|
}
|
|
17358
|
-
const client3 =
|
|
17482
|
+
const client3 = HcmClient25.fromAuthContext(ctx);
|
|
17359
17483
|
const { ticket } = await mintBrowserTicket(client3, ctx.env)();
|
|
17360
17484
|
return { url: buildBrowserLoginUrl(frontend, ticket, sitePath), environment: ctx.env, identity: ctx.identity ?? null };
|
|
17361
17485
|
},
|
|
@@ -17417,7 +17541,7 @@ async function chironPageCommand(target, args, deps = defaultChironPageDeps) {
|
|
|
17417
17541
|
try {
|
|
17418
17542
|
const receipt = await runChironPage(target, args, deps);
|
|
17419
17543
|
const fmt = args.output ?? "table";
|
|
17420
|
-
if (fmt === "json" || fmt === "yaml") process.stdout.write(
|
|
17544
|
+
if (fmt === "json" || fmt === "yaml") process.stdout.write(formatObject30(receipt, { format: fmt }) + "\n");
|
|
17421
17545
|
else process.stdout.write(renderChironPage(receipt) + "\n");
|
|
17422
17546
|
process.exitCode = receipt.ok ? 0 : 3;
|
|
17423
17547
|
} catch (e) {
|
|
@@ -17432,11 +17556,11 @@ import { randomUUID as randomUUID2 } from "crypto";
|
|
|
17432
17556
|
import { promises as fs14 } from "fs";
|
|
17433
17557
|
import path17 from "path";
|
|
17434
17558
|
import yaml3 from "js-yaml";
|
|
17435
|
-
import { formatObject as
|
|
17559
|
+
import { formatObject as formatObject31 } from "@hcmai/sdk";
|
|
17436
17560
|
|
|
17437
17561
|
// src/commands/delivery-action-policy.ts
|
|
17438
17562
|
init_auth_guard();
|
|
17439
|
-
import { HcmClient as
|
|
17563
|
+
import { HcmClient as HcmClient26, classifyEffect } from "@hcmai/sdk";
|
|
17440
17564
|
|
|
17441
17565
|
// src/commands/delivery.ts
|
|
17442
17566
|
import { createHash as createHash9 } from "crypto";
|
|
@@ -17497,7 +17621,8 @@ var GUARDED_EXECUTOR_REASON_CODES = /* @__PURE__ */ new Set([
|
|
|
17497
17621
|
// 报表 / 套打模板回传要先 upload 拿 documentId,再挂到业务对象。文件路径是
|
|
17498
17622
|
// 固定位置参数,prepare 会钉住项目内普通文件的摘要,execute 前重算后才单次执行。
|
|
17499
17623
|
// 2026-09-02 弹性报表顾问仿真已证实这条交付链会在缺受控执行器时中断。
|
|
17500
|
-
"document-upload"
|
|
17624
|
+
"document-upload",
|
|
17625
|
+
"tenant-bootstrap-reconcile"
|
|
17501
17626
|
]);
|
|
17502
17627
|
function normalizeAssessedArgv(inputArgv) {
|
|
17503
17628
|
let rest = inputArgv;
|
|
@@ -17584,7 +17709,7 @@ function classify(argv, actionResolution) {
|
|
|
17584
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>\``
|
|
17585
17710
|
);
|
|
17586
17711
|
}
|
|
17587
|
-
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))))) {
|
|
17588
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");
|
|
17589
17714
|
}
|
|
17590
17715
|
if (name === "user" && subcommand === "reset-password") {
|
|
@@ -17807,6 +17932,7 @@ function classify(argv, actionResolution) {
|
|
|
17807
17932
|
return forbidden("destructive", "\u5220\u9664\u64CD\u4F5C\u4E0D\u8FDB\u5165\u987E\u95EE\u63D2\u4EF6\u6267\u884C\u9762\u3002");
|
|
17808
17933
|
}
|
|
17809
17934
|
if (name === "tenant") {
|
|
17935
|
+
if (subcommand === "reconcile") return guarded("tenant-config-write", "tenant-bootstrap-reconcile");
|
|
17810
17936
|
return forbidden("tenant-governance", "\u79DF\u6237\u5F00\u901A\u6216\u6CBB\u7406\u5FC5\u987B\u5347\u7EA7\u6CBB\u7406\u4EBA\u5458\u3002");
|
|
17811
17937
|
}
|
|
17812
17938
|
if (name === "login" || name === "logout") {
|
|
@@ -18025,7 +18151,7 @@ async function resolveCoreAction(request) {
|
|
|
18025
18151
|
as: request.identity,
|
|
18026
18152
|
profile: request.profile
|
|
18027
18153
|
});
|
|
18028
|
-
const description = await
|
|
18154
|
+
const description = await HcmClient26.fromAuthContext(auth).describe(request.model);
|
|
18029
18155
|
const named = description.actions.filter((action) => action.name === request.action);
|
|
18030
18156
|
if (named.length === 0) {
|
|
18031
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`;
|
|
@@ -18467,7 +18593,7 @@ async function chironTestCommand(target, args, deps) {
|
|
|
18467
18593
|
}
|
|
18468
18594
|
const fmt = args.output ?? "table";
|
|
18469
18595
|
if (fmt === "json" || fmt === "yaml") {
|
|
18470
|
-
process.stdout.write(
|
|
18596
|
+
process.stdout.write(formatObject31({ ok: failed2 === 0, failed: failed2, cases: report }, { format: fmt }) + "\n");
|
|
18471
18597
|
} else {
|
|
18472
18598
|
for (const c2 of report) {
|
|
18473
18599
|
process.stdout.write(`
|
|
@@ -18496,12 +18622,12 @@ ${failed2} \u6761\u6CA1\u8FC7\u2014\u2014\u4E0A\u9762\u6BCF\u6761\u90FD\u5199\u4
|
|
|
18496
18622
|
init_auth_guard();
|
|
18497
18623
|
init_exit();
|
|
18498
18624
|
import {
|
|
18499
|
-
HcmClient as
|
|
18625
|
+
HcmClient as HcmClient27,
|
|
18500
18626
|
ReconLayout,
|
|
18501
18627
|
ROUND_EXIT_CODES,
|
|
18502
18628
|
computeReconSourceKey,
|
|
18503
|
-
formatObject as
|
|
18504
|
-
fromAxiosError as
|
|
18629
|
+
formatObject as formatObject32,
|
|
18630
|
+
fromAxiosError as fromAxiosError25,
|
|
18505
18631
|
httpProbe as httpProbe3,
|
|
18506
18632
|
inspectRound,
|
|
18507
18633
|
renderRound,
|
|
@@ -18511,7 +18637,7 @@ var DEFAULT_CAPABILITIES = "default";
|
|
|
18511
18637
|
async function deliveryReconCommand(args) {
|
|
18512
18638
|
try {
|
|
18513
18639
|
const ctx = await getActiveAuthContextFromCli(args);
|
|
18514
|
-
const client3 =
|
|
18640
|
+
const client3 = HcmClient27.fromAuthContext(ctx);
|
|
18515
18641
|
const probe2 = httpProbe3(client3.raw(), args.capabilities ?? DEFAULT_CAPABILITIES);
|
|
18516
18642
|
const sourceKey = await computeReconSourceKey(probe2);
|
|
18517
18643
|
const layout = new ReconLayout(args.out ?? ".", ctx.tenantId, sourceKey);
|
|
@@ -18520,10 +18646,10 @@ async function deliveryReconCommand(args) {
|
|
|
18520
18646
|
onlyModel: args.model ?? null,
|
|
18521
18647
|
identity: ctx.tenantId ? { requestedTenantId: ctx.tenantId } : null
|
|
18522
18648
|
});
|
|
18523
|
-
process.stdout.write(
|
|
18649
|
+
process.stdout.write(formatObject32(summary, { format: args.output ?? "json" }) + "\n");
|
|
18524
18650
|
} catch (e) {
|
|
18525
18651
|
const err = e;
|
|
18526
|
-
if (err?.isAxiosError) exitWithError(
|
|
18652
|
+
if (err?.isAxiosError) exitWithError(fromAxiosError25(err, args.env));
|
|
18527
18653
|
exitWithError(e);
|
|
18528
18654
|
process.exit(1);
|
|
18529
18655
|
}
|
|
@@ -18534,7 +18660,7 @@ async function deliveryReconRoundCommand(args) {
|
|
|
18534
18660
|
const result = inspectRound(args.dir ?? ".");
|
|
18535
18661
|
const fmt = args.output ?? "json";
|
|
18536
18662
|
if (fmt !== "json") process.stdout.write(renderRound(result));
|
|
18537
|
-
process.stdout.write(
|
|
18663
|
+
process.stdout.write(formatObject32(result, { format: fmt }) + "\n");
|
|
18538
18664
|
code2 = ROUND_EXIT_CODES[result.state];
|
|
18539
18665
|
} catch (e) {
|
|
18540
18666
|
exitWithError(e);
|
|
@@ -18554,7 +18680,7 @@ import {
|
|
|
18554
18680
|
DRY_RUN_TAIL,
|
|
18555
18681
|
DriftDetected,
|
|
18556
18682
|
FORCE_STALE_FLAG,
|
|
18557
|
-
HcmClient as
|
|
18683
|
+
HcmClient as HcmClient28,
|
|
18558
18684
|
fetchReconIdentity as fetchReconIdentity2,
|
|
18559
18685
|
INIT_EXIT_CODES,
|
|
18560
18686
|
JOURNAL_STOP_KINDS,
|
|
@@ -18694,7 +18820,7 @@ async function authOrSignpost(args, cmd) {
|
|
|
18694
18820
|
}
|
|
18695
18821
|
async function deliverySeedPlanCommand(args) {
|
|
18696
18822
|
const ctx = await authOrSignpost(args, "plan");
|
|
18697
|
-
const client3 =
|
|
18823
|
+
const client3 = HcmClient28.fromAuthContext(ctx);
|
|
18698
18824
|
process.exitCode = await runSeedPlan(args, seedClient(client3, ctx));
|
|
18699
18825
|
}
|
|
18700
18826
|
function seedClient(client3, ctx) {
|
|
@@ -18868,7 +18994,7 @@ async function runSeedApply(args, client3) {
|
|
|
18868
18994
|
}
|
|
18869
18995
|
async function deliverySeedApplyCommand(args) {
|
|
18870
18996
|
const ctx = await authOrSignpost(args, "apply");
|
|
18871
|
-
const client3 =
|
|
18997
|
+
const client3 = HcmClient28.fromAuthContext(ctx);
|
|
18872
18998
|
process.exitCode = await runSeedApply(args, seedClient(client3, ctx));
|
|
18873
18999
|
}
|
|
18874
19000
|
async function runSeedVerify(args, client3) {
|
|
@@ -18892,7 +19018,7 @@ async function deliverySeedVerifyCommand(args) {
|
|
|
18892
19018
|
return;
|
|
18893
19019
|
}
|
|
18894
19020
|
const ctx = await authOrSignpost(args, "verify");
|
|
18895
|
-
const client3 =
|
|
19021
|
+
const client3 = HcmClient28.fromAuthContext(ctx);
|
|
18896
19022
|
process.exitCode = await runSeedVerify(args, await seedVerifyClient(client3, ctx));
|
|
18897
19023
|
}
|
|
18898
19024
|
|
|
@@ -19007,7 +19133,7 @@ import {
|
|
|
19007
19133
|
CHANGE_STATES,
|
|
19008
19134
|
CHANGE_UNKNOWN,
|
|
19009
19135
|
CODE_WORDS,
|
|
19010
|
-
HcmClient as
|
|
19136
|
+
HcmClient as HcmClient29,
|
|
19011
19137
|
INIT_EXIT_CODES as INIT_EXIT_CODES3,
|
|
19012
19138
|
META_WRITE_STEPS,
|
|
19013
19139
|
META_VERIFY_STEPS,
|
|
@@ -19235,7 +19361,7 @@ function lowerCaseHeaders2(headers) {
|
|
|
19235
19361
|
}
|
|
19236
19362
|
async function deliveryMetaCommand(args) {
|
|
19237
19363
|
const ctx = await getActiveAuthContextFromCli(args);
|
|
19238
|
-
const client3 =
|
|
19364
|
+
const client3 = HcmClient29.fromAuthContext(ctx);
|
|
19239
19365
|
process.exitCode = await runDeliveryMeta(
|
|
19240
19366
|
{ ...args, tenant: args.tenant ?? String(ctx.tenantId ?? "") },
|
|
19241
19367
|
metaClient(client3, ctx)
|
|
@@ -19247,7 +19373,7 @@ init_auth_guard();
|
|
|
19247
19373
|
init_exit();
|
|
19248
19374
|
import {
|
|
19249
19375
|
computeReconSourceKey as computeReconSourceKey2,
|
|
19250
|
-
HcmClient as
|
|
19376
|
+
HcmClient as HcmClient30,
|
|
19251
19377
|
httpProbe as httpProbe4,
|
|
19252
19378
|
ReconLayout as ReconLayout2,
|
|
19253
19379
|
runTriageRound
|
|
@@ -19303,7 +19429,7 @@ async function runTriage(args) {
|
|
|
19303
19429
|
return premise4(e instanceof Error ? e.message : String(e), REQUESTS_SHAPE);
|
|
19304
19430
|
}
|
|
19305
19431
|
const ctx = await getActiveAuthContextFromCli(args);
|
|
19306
|
-
const client3 =
|
|
19432
|
+
const client3 = HcmClient30.fromAuthContext(ctx);
|
|
19307
19433
|
const probe2 = httpProbe4(client3.raw(), args.capabilities ?? DEFAULT_CAPABILITIES3);
|
|
19308
19434
|
const artifactsDir = args.recon ?? new ReconLayout2(args.out ?? ".", ctx.tenantId, await computeReconSourceKey2(probe2)).dir;
|
|
19309
19435
|
const result = await runTriageRound(probe2, artifactsDir, entriesIn);
|
|
@@ -19332,25 +19458,25 @@ async function deliveryTriageCommand(args) {
|
|
|
19332
19458
|
init_auth_guard();
|
|
19333
19459
|
init_exit();
|
|
19334
19460
|
import {
|
|
19335
|
-
HcmClient as
|
|
19461
|
+
HcmClient as HcmClient31,
|
|
19336
19462
|
adminResetPassword,
|
|
19337
|
-
formatObject as
|
|
19338
|
-
fromAxiosError as
|
|
19339
|
-
CliError as
|
|
19340
|
-
CliErrorCode as
|
|
19463
|
+
formatObject as formatObject33,
|
|
19464
|
+
fromAxiosError as fromAxiosError26,
|
|
19465
|
+
CliError as CliError38,
|
|
19466
|
+
CliErrorCode as CliErrorCode39
|
|
19341
19467
|
} from "@hcmai/sdk";
|
|
19342
19468
|
function buildAdminResetPasswordRequest(args, password) {
|
|
19343
19469
|
const hasId = Boolean(args.id);
|
|
19344
19470
|
const hasUsername = Boolean(args.username);
|
|
19345
19471
|
if (hasId === hasUsername) {
|
|
19346
|
-
throw new
|
|
19347
|
-
code:
|
|
19472
|
+
throw new CliError38({
|
|
19473
|
+
code: CliErrorCode39.INVALID_ARGUMENT,
|
|
19348
19474
|
message: "--id <uuid> \u4E0E --username <user> \u5FC5\u987B\u4E14\u53EA\u80FD\u63D0\u4F9B\u4E00\u4E2A"
|
|
19349
19475
|
});
|
|
19350
19476
|
}
|
|
19351
19477
|
if (!password) {
|
|
19352
|
-
throw new
|
|
19353
|
-
code:
|
|
19478
|
+
throw new CliError38({
|
|
19479
|
+
code: CliErrorCode39.INVALID_ARGUMENT,
|
|
19354
19480
|
message: "\u65B0\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A"
|
|
19355
19481
|
});
|
|
19356
19482
|
}
|
|
@@ -19366,12 +19492,12 @@ async function userResetPasswordCommand(args) {
|
|
|
19366
19492
|
try {
|
|
19367
19493
|
const password = args.passwordStdin ? await readSecretFromStdin() : await promptPasswordTwice();
|
|
19368
19494
|
const request = buildAdminResetPasswordRequest(args, password);
|
|
19369
|
-
const client3 =
|
|
19495
|
+
const client3 = HcmClient31.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
19370
19496
|
const result = await adminResetPassword(client3.raw(), request);
|
|
19371
|
-
process.stdout.write(
|
|
19497
|
+
process.stdout.write(formatObject33(result, { format: args.output ?? "json" }) + "\n");
|
|
19372
19498
|
} catch (cause) {
|
|
19373
19499
|
const err = cause;
|
|
19374
|
-
if (err?.isAxiosError) exitWithError(
|
|
19500
|
+
if (err?.isAxiosError) exitWithError(fromAxiosError26(err, args.env));
|
|
19375
19501
|
exitWithError(cause);
|
|
19376
19502
|
}
|
|
19377
19503
|
}
|
|
@@ -19379,8 +19505,8 @@ async function promptPasswordTwice() {
|
|
|
19379
19505
|
const password = await promptSecret("\u65B0\u5BC6\u7801: ");
|
|
19380
19506
|
const confirmation = await promptSecret("\u518D\u6B21\u8F93\u5165\u65B0\u5BC6\u7801: ");
|
|
19381
19507
|
if (password !== confirmation) {
|
|
19382
|
-
throw new
|
|
19383
|
-
code:
|
|
19508
|
+
throw new CliError38({
|
|
19509
|
+
code: CliErrorCode39.INVALID_ARGUMENT,
|
|
19384
19510
|
message: "\u4E24\u6B21\u8F93\u5165\u7684\u65B0\u5BC6\u7801\u4E0D\u4E00\u81F4"
|
|
19385
19511
|
});
|
|
19386
19512
|
}
|
|
@@ -19391,19 +19517,19 @@ async function promptPasswordTwice() {
|
|
|
19391
19517
|
init_exit();
|
|
19392
19518
|
init_auth_guard();
|
|
19393
19519
|
import {
|
|
19394
|
-
HcmClient as
|
|
19395
|
-
formatObject as
|
|
19396
|
-
fromAxiosError as
|
|
19520
|
+
HcmClient as HcmClient32,
|
|
19521
|
+
formatObject as formatObject34,
|
|
19522
|
+
fromAxiosError as fromAxiosError27
|
|
19397
19523
|
} from "@hcmai/sdk";
|
|
19398
19524
|
async function modelsCommand(keyword, args) {
|
|
19399
19525
|
try {
|
|
19400
|
-
const client3 =
|
|
19526
|
+
const client3 = HcmClient32.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
19401
19527
|
const all = await client3.listModels();
|
|
19402
19528
|
const needle = keyword?.trim().toLowerCase();
|
|
19403
19529
|
const rows2 = (needle ? all.filter((m) => JSON.stringify(m).toLowerCase().includes(needle)) : all).sort((a, b) => key(a).localeCompare(key(b)));
|
|
19404
19530
|
const fmt = args.output ?? "table";
|
|
19405
19531
|
if (fmt !== "table") {
|
|
19406
|
-
process.stdout.write(
|
|
19532
|
+
process.stdout.write(formatObject34({ total: rows2.length, models: rows2 }, { format: fmt }) + "\n");
|
|
19407
19533
|
process.exitCode = 0;
|
|
19408
19534
|
return;
|
|
19409
19535
|
}
|
|
@@ -19430,7 +19556,7 @@ async function modelsCommand(keyword, args) {
|
|
|
19430
19556
|
return;
|
|
19431
19557
|
} catch (e) {
|
|
19432
19558
|
const err = e;
|
|
19433
|
-
if (err?.isAxiosError) exitWithError(
|
|
19559
|
+
if (err?.isAxiosError) exitWithError(fromAxiosError27(err, args.profile));
|
|
19434
19560
|
exitWithError(e);
|
|
19435
19561
|
}
|
|
19436
19562
|
}
|
|
@@ -19713,6 +19839,7 @@ datapackage.command("pack <packageDir>").description("\u628A\u5305\u76EE\u5F55\u
|
|
|
19713
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));
|
|
19714
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));
|
|
19715
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));
|
|
19716
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));
|
|
19717
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(
|
|
19718
19845
|
"--admin-password <pwd>",
|