@hcmai/cli 0.21.10 → 0.21.12
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 +172 -39
- package/dist/index.js.map +1 -1
- package/dist/skills/manifest.json +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -6790,7 +6790,7 @@ function upsertBlock(existing, begin, end, block) {
|
|
|
6790
6790
|
}
|
|
6791
6791
|
|
|
6792
6792
|
// src/commands/generated/agent-boundary.ts
|
|
6793
|
-
var BUILTIN_BOUNDARY = '# HCM \u987E\u95EE\u9879\u76EE\u8FB9\u754C\n\n- \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\
|
|
6793
|
+
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';
|
|
6794
6794
|
|
|
6795
6795
|
// src/commands/chiron-agent-boundary.ts
|
|
6796
6796
|
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";
|
|
@@ -10346,11 +10346,16 @@ async function workspaceValidateCommand(args) {
|
|
|
10346
10346
|
}
|
|
10347
10347
|
}
|
|
10348
10348
|
async function workspacePushCommand(args) {
|
|
10349
|
+
let recovery2;
|
|
10350
|
+
let pushProgress;
|
|
10351
|
+
let profile = args.env ?? args.profile;
|
|
10349
10352
|
try {
|
|
10350
10353
|
await withWorkspacePushProgress(async (bindHttp, assertRunning) => {
|
|
10351
10354
|
const rootDir = resolveRootDir(args.dir);
|
|
10352
10355
|
await assertWorkspacePushRoot(rootDir);
|
|
10353
10356
|
const context = await requireWorkspaceContext(rootDir);
|
|
10357
|
+
profile ??= context.profile;
|
|
10358
|
+
recovery2 = { command: "push", workspaceKey: context.workspaceKey, dir: rootDir, as: args.as };
|
|
10354
10359
|
const miniApps = await discoverMiniApps(rootDir);
|
|
10355
10360
|
for (const app of miniApps) {
|
|
10356
10361
|
const validation = await validateMiniProject(app.dir);
|
|
@@ -10364,6 +10369,7 @@ async function workspacePushCommand(args) {
|
|
|
10364
10369
|
const client3 = HcmClient22.fromAuthContext(
|
|
10365
10370
|
await getActiveAuthContextFromCli(args, { fallbackEnv: context.profile })
|
|
10366
10371
|
);
|
|
10372
|
+
profile = client3.profile ?? profile;
|
|
10367
10373
|
bindHttp(client3.raw());
|
|
10368
10374
|
if (!args.dryRun) {
|
|
10369
10375
|
requireWorkspaceActivation(await probeActiveWorkspaceKey(client3), context.workspaceKey);
|
|
@@ -10372,7 +10378,11 @@ async function workspacePushCommand(args) {
|
|
|
10372
10378
|
http: client3.raw(),
|
|
10373
10379
|
rootDir,
|
|
10374
10380
|
context,
|
|
10375
|
-
dryRun: !!args.dryRun
|
|
10381
|
+
dryRun: !!args.dryRun,
|
|
10382
|
+
profile,
|
|
10383
|
+
onProgress: (progress) => {
|
|
10384
|
+
pushProgress = progress;
|
|
10385
|
+
}
|
|
10376
10386
|
});
|
|
10377
10387
|
const results = [];
|
|
10378
10388
|
for (const app of miniApps) {
|
|
@@ -10392,7 +10402,22 @@ async function workspacePushCommand(args) {
|
|
|
10392
10402
|
}, args.env ?? args.profile);
|
|
10393
10403
|
return;
|
|
10394
10404
|
} catch (e) {
|
|
10395
|
-
|
|
10405
|
+
let failure2 = e;
|
|
10406
|
+
if (e instanceof CliError25 && pushProgress && !e.context?.push) {
|
|
10407
|
+
failure2 = new CliError25({
|
|
10408
|
+
code: e.code,
|
|
10409
|
+
message: e.message,
|
|
10410
|
+
traceId: e.traceId,
|
|
10411
|
+
profile: e.profile ?? profile,
|
|
10412
|
+
cause: e,
|
|
10413
|
+
context: {
|
|
10414
|
+
...e.context,
|
|
10415
|
+
push: pushProgress,
|
|
10416
|
+
details: { serverDetails: e.context?.details, push: pushProgress }
|
|
10417
|
+
}
|
|
10418
|
+
});
|
|
10419
|
+
}
|
|
10420
|
+
exitWorkspaceError(failure2, profile, recovery2);
|
|
10396
10421
|
}
|
|
10397
10422
|
}
|
|
10398
10423
|
async function workspacePreviewCommand(args) {
|
|
@@ -10558,7 +10583,7 @@ async function assertWorkspacePushRoot(rootDir) {
|
|
|
10558
10583
|
dir = parent;
|
|
10559
10584
|
}
|
|
10560
10585
|
if (!insideMiniApp && (!workspaceRoot || workspaceRoot === realRoot)) return;
|
|
10561
|
-
const target = workspaceRoot ?
|
|
10586
|
+
const target = workspaceRoot ? quoteWorkspaceArg(workspaceRoot) : "<workspace-root>";
|
|
10562
10587
|
throw new CliError25({
|
|
10563
10588
|
code: CliErrorCode26.INVALID_ARGUMENT,
|
|
10564
10589
|
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`,
|
|
@@ -10682,11 +10707,14 @@ async function writeWorkspaceRawState(rootDir, context, files, remoteByLocalPath
|
|
|
10682
10707
|
async function writeWorkspaceRawManifest(rootDir, manifest2) {
|
|
10683
10708
|
const stateDir = path9.join(rootDir, WORKSPACE_STATE_DIR);
|
|
10684
10709
|
await fs8.mkdir(stateDir, { recursive: true });
|
|
10685
|
-
|
|
10686
|
-
|
|
10687
|
-
|
|
10688
|
-
"utf8"
|
|
10689
|
-
|
|
10710
|
+
const target = path9.join(stateDir, WORKSPACE_PULL_MANIFEST_FILE);
|
|
10711
|
+
const temporary = `${target}.${crypto.randomUUID()}.tmp`;
|
|
10712
|
+
try {
|
|
10713
|
+
await fs8.writeFile(temporary, JSON.stringify(manifest2, null, 2) + "\n", { encoding: "utf8", flag: "wx" });
|
|
10714
|
+
await fs8.rename(temporary, target);
|
|
10715
|
+
} finally {
|
|
10716
|
+
await fs8.rm(temporary, { force: true });
|
|
10717
|
+
}
|
|
10690
10718
|
}
|
|
10691
10719
|
async function readWorkspaceRawLocalFiles(rootDir) {
|
|
10692
10720
|
const files = [];
|
|
@@ -10740,32 +10768,102 @@ async function pushWorkspaceRawFiles(args) {
|
|
|
10740
10768
|
};
|
|
10741
10769
|
if (args.dryRun || plan.conflicts.length) return result;
|
|
10742
10770
|
const localByPath = new Map(localFiles.map((file) => [file.localPath, file]));
|
|
10743
|
-
|
|
10744
|
-
|
|
10745
|
-
|
|
10746
|
-
|
|
10747
|
-
|
|
10748
|
-
|
|
10749
|
-
|
|
10750
|
-
|
|
10751
|
-
|
|
10752
|
-
|
|
10753
|
-
|
|
10754
|
-
|
|
10755
|
-
|
|
10756
|
-
|
|
10757
|
-
|
|
10758
|
-
|
|
10759
|
-
|
|
10760
|
-
|
|
10761
|
-
|
|
10771
|
+
const snapshots = new Map(manifest2.files.map((file) => [file.localPath, file]));
|
|
10772
|
+
const committed = [];
|
|
10773
|
+
const operations = plan.operations;
|
|
10774
|
+
for (const [index, operation] of operations.entries()) {
|
|
10775
|
+
if (operation.operation === "skip" && operation.reason === "unchanged") continue;
|
|
10776
|
+
let commitState = "UNKNOWN";
|
|
10777
|
+
let checkpointSaved = true;
|
|
10778
|
+
const progress = () => ({
|
|
10779
|
+
atomic: false,
|
|
10780
|
+
committed: [...committed],
|
|
10781
|
+
failed: [{ ...operation, commitState }],
|
|
10782
|
+
notExecuted: operations.slice(index + 1).filter((item) => item.operation !== "skip"),
|
|
10783
|
+
checkpointSaved
|
|
10784
|
+
});
|
|
10785
|
+
args.onProgress?.(progress());
|
|
10786
|
+
try {
|
|
10787
|
+
if (operation.operation === "delete" || operation.reason === "already deleted remotely") {
|
|
10788
|
+
if (operation.operation === "delete") {
|
|
10789
|
+
if (!operation.fileId) throw new Error(`missing file id: ${operation.remotePath}`);
|
|
10790
|
+
await deleteWorkspaceFile(args.http, operation.fileId);
|
|
10791
|
+
committed.push(operation);
|
|
10792
|
+
}
|
|
10793
|
+
commitState = "COMMITTED";
|
|
10794
|
+
checkpointSaved = false;
|
|
10795
|
+
snapshots.delete(operation.localPath);
|
|
10796
|
+
} else {
|
|
10797
|
+
const localFile = localByPath.get(operation.localPath);
|
|
10798
|
+
if (!localFile) throw new Error(`missing local file: ${operation.localPath}`);
|
|
10799
|
+
const receipt = operation.operation === "create" ? await createWorkspaceFile(args.http, args.context.workspaceKey, operation.remotePath, localFile.content) : operation.operation === "update" && operation.fileId ? await saveWorkspaceFileContent(args.http, operation.fileId, localFile.content) : remoteFiles.find((file) => file.item.relativePath === operation.remotePath)?.item;
|
|
10800
|
+
if (!receipt?.id || receipt.workspaceKey !== args.context.workspaceKey || receipt.relativePath !== operation.remotePath) {
|
|
10801
|
+
throw new Error(`invalid file write receipt: ${operation.remotePath}`);
|
|
10802
|
+
}
|
|
10803
|
+
if (operation.operation !== "skip") {
|
|
10804
|
+
committed.push(operation);
|
|
10805
|
+
commitState = "COMMITTED";
|
|
10806
|
+
checkpointSaved = false;
|
|
10807
|
+
}
|
|
10808
|
+
const savedContent = operation.operation === "skip" ? remoteFiles.find((file) => file.item.id === receipt.id)?.content : receipt.content;
|
|
10809
|
+
if (typeof savedContent !== "string") {
|
|
10810
|
+
throw new Error(`write receipt has no committed content: ${operation.remotePath}`);
|
|
10811
|
+
}
|
|
10812
|
+
snapshots.set(operation.localPath, {
|
|
10813
|
+
localPath: operation.localPath,
|
|
10814
|
+
remotePath: operation.remotePath,
|
|
10815
|
+
fileId: receipt.id,
|
|
10816
|
+
sha256: localFile.sha256,
|
|
10817
|
+
remoteSha256: sha2563(savedContent),
|
|
10818
|
+
size: localFile.size,
|
|
10819
|
+
lastModified: receipt.lastModified
|
|
10820
|
+
});
|
|
10821
|
+
}
|
|
10822
|
+
checkpointSaved = false;
|
|
10823
|
+
args.onProgress?.(progress());
|
|
10824
|
+
await writeWorkspaceRawManifest(args.rootDir, {
|
|
10825
|
+
...manifest2,
|
|
10826
|
+
pulledAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10827
|
+
files: [...snapshots.values()]
|
|
10828
|
+
});
|
|
10829
|
+
checkpointSaved = true;
|
|
10830
|
+
args.onProgress?.({
|
|
10831
|
+
atomic: false,
|
|
10832
|
+
committed: [...committed],
|
|
10833
|
+
failed: [],
|
|
10834
|
+
notExecuted: operations.slice(index + 1).filter((item) => item.operation !== "skip"),
|
|
10835
|
+
checkpointSaved
|
|
10836
|
+
});
|
|
10837
|
+
} catch (error) {
|
|
10838
|
+
const translated = error?.isAxiosError ? fromAxiosError22(error, args.profile ?? args.context.profile) : error;
|
|
10839
|
+
const push = progress();
|
|
10840
|
+
args.onProgress?.(push);
|
|
10841
|
+
throw new CliError25({
|
|
10842
|
+
code: translated instanceof CliError25 ? translated.code : CliErrorCode26.INVALID_ARGUMENT,
|
|
10843
|
+
message: translated instanceof Error ? translated.message : String(translated),
|
|
10844
|
+
traceId: translated instanceof CliError25 ? translated.traceId : void 0,
|
|
10845
|
+
profile: translated instanceof CliError25 ? translated.profile : args.profile ?? args.context.profile,
|
|
10846
|
+
cause: error,
|
|
10847
|
+
context: {
|
|
10848
|
+
...translated instanceof CliError25 ? translated.context : {},
|
|
10849
|
+
workspaceKey: args.context.workspaceKey,
|
|
10850
|
+
push,
|
|
10851
|
+
details: {
|
|
10852
|
+
serverDetails: translated instanceof CliError25 ? translated.context?.details : void 0,
|
|
10853
|
+
push
|
|
10854
|
+
},
|
|
10855
|
+
note: [
|
|
10856
|
+
translated instanceof CliError25 ? translated.context?.note : void 0,
|
|
10857
|
+
"\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"
|
|
10858
|
+
].filter(Boolean).join(" "),
|
|
10859
|
+
nextStep: [
|
|
10860
|
+
translated instanceof CliError25 ? translated.context?.nextStep : void 0,
|
|
10861
|
+
"\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"
|
|
10862
|
+
].filter(Boolean).join(" ")
|
|
10863
|
+
}
|
|
10864
|
+
});
|
|
10762
10865
|
}
|
|
10763
10866
|
}
|
|
10764
|
-
const latestRemoteFiles = await loadWorkspaceRawRemoteFiles(args.http, args.context.workspaceKey);
|
|
10765
|
-
const latestRemoteByLocalPath = new Map(
|
|
10766
|
-
latestRemoteFiles.map((file) => [file.item.relativePath, file.item])
|
|
10767
|
-
);
|
|
10768
|
-
await writeWorkspaceRawState(args.rootDir, args.context, localFiles, latestRemoteByLocalPath);
|
|
10769
10867
|
return result;
|
|
10770
10868
|
}
|
|
10771
10869
|
async function loadWorkspaceRawRemoteFiles(http, workspaceKey) {
|
|
@@ -10788,6 +10886,16 @@ function buildWorkspaceRawPushPlan(manifest2, localFiles, remoteFiles) {
|
|
|
10788
10886
|
const remote = remoteByLocal.get(entry.localPath);
|
|
10789
10887
|
const base = baseByLocal.get(entry.localPath);
|
|
10790
10888
|
const remoteSha = remote ? sha2563(remote.content) : void 0;
|
|
10889
|
+
if ((entry.status === "added" || entry.status === "modified") && remote && remoteSha === entry.sha256) {
|
|
10890
|
+
operations.push({
|
|
10891
|
+
operation: "skip",
|
|
10892
|
+
localPath: entry.localPath,
|
|
10893
|
+
remotePath: entry.remotePath,
|
|
10894
|
+
fileId: remote.item.id,
|
|
10895
|
+
reason: "already matches desired content"
|
|
10896
|
+
});
|
|
10897
|
+
continue;
|
|
10898
|
+
}
|
|
10791
10899
|
if (entry.status === "added") {
|
|
10792
10900
|
if (remote) {
|
|
10793
10901
|
conflicts.push(
|
|
@@ -10805,7 +10913,7 @@ function buildWorkspaceRawPushPlan(manifest2, localFiles, remoteFiles) {
|
|
|
10805
10913
|
if (entry.status === "modified") {
|
|
10806
10914
|
if (!remote) {
|
|
10807
10915
|
conflicts.push(workspaceRawConflict(entry, "remote file was deleted after last pull"));
|
|
10808
|
-
} else if (base && remoteSha !== base.sha256) {
|
|
10916
|
+
} else if (base && remoteSha !== (base.remoteSha256 ?? base.sha256)) {
|
|
10809
10917
|
conflicts.push(workspaceRawConflict(entry, "remote file changed after last pull"));
|
|
10810
10918
|
} else {
|
|
10811
10919
|
operations.push({
|
|
@@ -10825,7 +10933,7 @@ function buildWorkspaceRawPushPlan(manifest2, localFiles, remoteFiles) {
|
|
|
10825
10933
|
remotePath: entry.remotePath,
|
|
10826
10934
|
reason: "already deleted remotely"
|
|
10827
10935
|
});
|
|
10828
|
-
} else if (base && remoteSha !== base.sha256) {
|
|
10936
|
+
} else if (base && remoteSha !== (base.remoteSha256 ?? base.sha256)) {
|
|
10829
10937
|
conflicts.push(workspaceRawConflict(entry, "remote file changed after last pull"));
|
|
10830
10938
|
} else {
|
|
10831
10939
|
operations.push({
|
|
@@ -11359,9 +11467,30 @@ function summarizeStatus(status) {
|
|
|
11359
11467
|
function formatStatusSummary(summary) {
|
|
11360
11468
|
return `added=${summary.added}, modified=${summary.modified}, deleted=${summary.deleted}, unchanged=${summary.unchanged}`;
|
|
11361
11469
|
}
|
|
11362
|
-
function
|
|
11470
|
+
function quoteWorkspaceArg(value) {
|
|
11471
|
+
return `'${value.replace(/'/g, "'\\''")}'`;
|
|
11472
|
+
}
|
|
11473
|
+
function exitWorkspaceError(err, profile, operation) {
|
|
11363
11474
|
const maybeAxios = err;
|
|
11364
11475
|
const translated = maybeAxios?.isAxiosError ? fromAxiosError22(err, profile) : err;
|
|
11476
|
+
if (translated instanceof CliError25 && operation && translated.context?.status === 409 && ["WORKSPACE_REVISION_CONFLICT", "DEPLOY_IN_PROGRESS"].includes(String(translated.context.responseCode))) {
|
|
11477
|
+
const scope = `${profile ? ` --env ${quoteWorkspaceArg(profile)}` : ""}${operation.as ? ` --as ${quoteWorkspaceArg(operation.as)}` : ""}`;
|
|
11478
|
+
const active = "hcm workspace active" + scope + (operation.dir ? ` --dir ${quoteWorkspaceArg(operation.dir)}` : "");
|
|
11479
|
+
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;
|
|
11480
|
+
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`;
|
|
11481
|
+
exitWithError(new CliError25({
|
|
11482
|
+
code: translated.code,
|
|
11483
|
+
message: translated.message,
|
|
11484
|
+
traceId: translated.traceId,
|
|
11485
|
+
profile: translated.profile ?? profile,
|
|
11486
|
+
cause: translated,
|
|
11487
|
+
context: {
|
|
11488
|
+
...translated.context,
|
|
11489
|
+
workspaceKey: operation.workspaceKey,
|
|
11490
|
+
nextStep: [translated.context.nextStep, `\u5148\u6267\u884C ${active} \u6838\u5BF9\u5F53\u524D\u8EAB\u4EFD\u7684\u5F00\u53D1\u6001\u7ED1\u5B9A\uFF08\u8BE5\u547D\u4EE4\u4E0D\u67E5\u8BE2\u90E8\u7F72\u8FDB\u5EA6\uFF09\u3002`, deployment, retry].filter(Boolean).join(" ")
|
|
11491
|
+
}
|
|
11492
|
+
}));
|
|
11493
|
+
}
|
|
11365
11494
|
if (translated instanceof CliError25 && translated.code === CliErrorCode26.AUTH_FAILED) {
|
|
11366
11495
|
exitWithError(new CliError25({
|
|
11367
11496
|
code: translated.code,
|
|
@@ -11426,9 +11555,13 @@ async function requestWorkspaceDeactivation(client3) {
|
|
|
11426
11555
|
return binding;
|
|
11427
11556
|
}
|
|
11428
11557
|
async function workspaceActivateCommand(workspaceKey, args) {
|
|
11558
|
+
let recovery2;
|
|
11559
|
+
let profile = args.env ?? args.profile;
|
|
11429
11560
|
try {
|
|
11430
11561
|
const client3 = HcmClient22.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
11562
|
+
profile = client3.profile ?? profile;
|
|
11431
11563
|
const key2 = normalizeWorkspaceKey(workspaceKey);
|
|
11564
|
+
recovery2 = { command: "activate", workspaceKey: key2, as: args.as };
|
|
11432
11565
|
await setDevModeBinding(client3, key2);
|
|
11433
11566
|
const fmt = args.output ?? "table";
|
|
11434
11567
|
if (fmt === "table") {
|
|
@@ -11443,7 +11576,7 @@ async function workspaceActivateCommand(workspaceKey, args) {
|
|
|
11443
11576
|
process.exitCode = 0;
|
|
11444
11577
|
return;
|
|
11445
11578
|
} catch (e) {
|
|
11446
|
-
exitWorkspaceError(e,
|
|
11579
|
+
exitWorkspaceError(e, profile, recovery2);
|
|
11447
11580
|
}
|
|
11448
11581
|
}
|
|
11449
11582
|
async function workspaceDeactivateCommand(args) {
|
|
@@ -17101,7 +17234,7 @@ async function chironPageCommand(target, args, deps = defaultChironPageDeps) {
|
|
|
17101
17234
|
// src/commands/chiron-test.ts
|
|
17102
17235
|
init_exit();
|
|
17103
17236
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
17104
|
-
import { randomUUID } from "crypto";
|
|
17237
|
+
import { randomUUID as randomUUID2 } from "crypto";
|
|
17105
17238
|
import { promises as fs14 } from "fs";
|
|
17106
17239
|
import path17 from "path";
|
|
17107
17240
|
import yaml3 from "js-yaml";
|
|
@@ -18132,7 +18265,7 @@ async function chironTestCommand(target, args, deps) {
|
|
|
18132
18265
|
const results = await runCase(
|
|
18133
18266
|
spec,
|
|
18134
18267
|
root,
|
|
18135
|
-
{ env: args.env, as: args.as, evidenceRunId:
|
|
18268
|
+
{ env: args.env, as: args.as, evidenceRunId: randomUUID2() },
|
|
18136
18269
|
deps
|
|
18137
18270
|
);
|
|
18138
18271
|
failed2 += results.filter((r) => r.verdict === "fail").length;
|