@hcmai/cli 0.4.19 → 0.4.20
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 +744 -198
- package/dist/index.js.map +1 -1
- package/dist/skills/manifest.json +5 -1
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -523,8 +523,8 @@ var init_TerminalRenderer = __esm({
|
|
|
523
523
|
}
|
|
524
524
|
}
|
|
525
525
|
/** 来源行(仅子代理触发,agentPath ≥2 段时显示 `↑ 来自 a › b`,对齐 Web)。 */
|
|
526
|
-
originLine(
|
|
527
|
-
const segs =
|
|
526
|
+
originLine(path13) {
|
|
527
|
+
const segs = path13.split(".").filter(Boolean);
|
|
528
528
|
if (segs.length < 2) return "";
|
|
529
529
|
const names = segs.map((k) => agentDisplayName(k));
|
|
530
530
|
return chalk.gray(` \u2191 \u6765\u81EA ${names.join(" \u203A ")}`) + "\n";
|
|
@@ -1706,8 +1706,8 @@ function agentLabel(agentId) {
|
|
|
1706
1706
|
if (/^[0-9a-f]{8}-[0-9a-f-]{27}$/i.test(agentId)) return `agent \u2026${agentId.slice(-4)}`;
|
|
1707
1707
|
return agentDisplayName(agentId);
|
|
1708
1708
|
}
|
|
1709
|
-
function originLine(
|
|
1710
|
-
const segs = (
|
|
1709
|
+
function originLine(path13) {
|
|
1710
|
+
const segs = (path13 ?? "").split(".").filter(Boolean);
|
|
1711
1711
|
if (segs.length < 2) return null;
|
|
1712
1712
|
return `\u6765\u81EA ${segs.map((k) => agentDisplayName(k)).join(" \u203A ")}`;
|
|
1713
1713
|
}
|
|
@@ -2229,7 +2229,19 @@ async function loginCommand(args) {
|
|
|
2229
2229
|
scopes = record.scopes;
|
|
2230
2230
|
} else {
|
|
2231
2231
|
username = args.username ?? await promptText("username: ");
|
|
2232
|
-
|
|
2232
|
+
if (args.passwordStdin && args.password) {
|
|
2233
|
+
throw new CliError2({
|
|
2234
|
+
code: CliErrorCode.INVALID_ARGUMENT,
|
|
2235
|
+
message: "--password \u4E0E --password-stdin \u53EA\u80FD\u4E8C\u9009\u4E00"
|
|
2236
|
+
});
|
|
2237
|
+
}
|
|
2238
|
+
if (args.password) {
|
|
2239
|
+
process.stderr.write("[hcm] WARNING: --password <p> \u4F1A\u6CC4\u6F0F\u5230 shell history / ps aux\u3002\u63A8\u8350 --password-stdin\u3002\n");
|
|
2240
|
+
}
|
|
2241
|
+
const password = args.passwordStdin ? await readStdin() : args.password ?? await promptSecret("password: ");
|
|
2242
|
+
if (args.passwordStdin && !password) {
|
|
2243
|
+
throw new CliError2({ code: CliErrorCode.INVALID_ARGUMENT, message: "--password-stdin \u8BFB\u5230\u7684\u5BC6\u7801\u4E3A\u7A7A" });
|
|
2244
|
+
}
|
|
2233
2245
|
if (!username || !password) {
|
|
2234
2246
|
throw new CliError2({
|
|
2235
2247
|
code: CliErrorCode.MISSING_FLAG,
|
|
@@ -2644,6 +2656,7 @@ async function queryCommand(model, args) {
|
|
|
2644
2656
|
const dsl = {};
|
|
2645
2657
|
if (args.filter) dsl.filter = parseJsonOrThrow(args.filter, "--filter");
|
|
2646
2658
|
if (args.sort) dsl.sort = parseJsonOrThrow(args.sort, "--sort");
|
|
2659
|
+
if (args.additions) dsl.additions = parseAdditionsOrThrow(args.additions);
|
|
2647
2660
|
if (args.fields) dsl.fields = args.fields.split(",").map((s) => s.trim());
|
|
2648
2661
|
if (args.keyword) dsl.keyword = args.keyword;
|
|
2649
2662
|
if (args.limit) dsl.limit = Number(args.limit);
|
|
@@ -2652,13 +2665,7 @@ async function queryCommand(model, args) {
|
|
|
2652
2665
|
const client3 = HcmClient.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
2653
2666
|
const result = await client3.query(model, dsl);
|
|
2654
2667
|
const fmt = args.output ?? "table";
|
|
2655
|
-
|
|
2656
|
-
process.stdout.write(out + "\n");
|
|
2657
|
-
if (fmt === "table" && result.total !== void 0) {
|
|
2658
|
-
process.stdout.write(`Showing ${result.rows.length} of ${result.total} results.
|
|
2659
|
-
`);
|
|
2660
|
-
}
|
|
2661
|
-
process.exit(0);
|
|
2668
|
+
printQueryResult(result, fmt);
|
|
2662
2669
|
} catch (e) {
|
|
2663
2670
|
const err = e;
|
|
2664
2671
|
if (err?.isAxiosError) {
|
|
@@ -2667,6 +2674,25 @@ async function queryCommand(model, args) {
|
|
|
2667
2674
|
exitWithError(e);
|
|
2668
2675
|
}
|
|
2669
2676
|
}
|
|
2677
|
+
function printQueryResult(result, fmt) {
|
|
2678
|
+
const out = formatRows(result.rows, { format: fmt });
|
|
2679
|
+
process.stdout.write(out + "\n");
|
|
2680
|
+
if (fmt === "table" && result.total !== void 0) {
|
|
2681
|
+
process.stdout.write(`Showing ${result.rows.length} of ${result.total} results.
|
|
2682
|
+
`);
|
|
2683
|
+
}
|
|
2684
|
+
process.exitCode = 0;
|
|
2685
|
+
}
|
|
2686
|
+
function parseAdditionsOrThrow(text) {
|
|
2687
|
+
const parsed = parseJsonOrThrow(text, "--additions");
|
|
2688
|
+
if (!Array.isArray(parsed) || parsed.some((item) => typeof item !== "object" || item === null || Array.isArray(item))) {
|
|
2689
|
+
throw new CliError6({
|
|
2690
|
+
code: CliErrorCode5.INVALID_ARGUMENT,
|
|
2691
|
+
message: `--additions \u5FC5\u987B\u662F JSON \u5BF9\u8C61\u6570\u7EC4\uFF0C\u4F8B\u5982 '[{"key":"employee","model":"Employee"}]'`
|
|
2692
|
+
});
|
|
2693
|
+
}
|
|
2694
|
+
return parsed;
|
|
2695
|
+
}
|
|
2670
2696
|
function parseJsonOrThrow(text, flag) {
|
|
2671
2697
|
try {
|
|
2672
2698
|
return JSON.parse(text);
|
|
@@ -3140,7 +3166,7 @@ function launchBrowser(url, platform = process.platform) {
|
|
|
3140
3166
|
child.unref();
|
|
3141
3167
|
}
|
|
3142
3168
|
async function runOpen(target, args, deps) {
|
|
3143
|
-
const
|
|
3169
|
+
const path13 = normalizeTarget(target);
|
|
3144
3170
|
if (!deps.frontend?.trim()) {
|
|
3145
3171
|
throw new CliError12({
|
|
3146
3172
|
code: CliErrorCode11.INVALID_ARGUMENT,
|
|
@@ -3148,13 +3174,13 @@ async function runOpen(target, args, deps) {
|
|
|
3148
3174
|
});
|
|
3149
3175
|
}
|
|
3150
3176
|
const { ticket, expiresIn } = await deps.mintTicket();
|
|
3151
|
-
const url = buildBrowserLoginUrl(deps.frontend, ticket,
|
|
3177
|
+
const url = buildBrowserLoginUrl(deps.frontend, ticket, path13);
|
|
3152
3178
|
if (args.printUrl) {
|
|
3153
3179
|
deps.write(`${url}
|
|
3154
3180
|
`);
|
|
3155
3181
|
} else {
|
|
3156
3182
|
deps.launch(url);
|
|
3157
|
-
deps.write(`\u5DF2\u7528\u5F53\u524D\u8EAB\u4EFD\u6253\u5F00 ${
|
|
3183
|
+
deps.write(`\u5DF2\u7528\u5F53\u524D\u8EAB\u4EFD\u6253\u5F00 ${path13}\uFF08\u7968\u636E ${expiresIn ?? 60}s \u5185\u6709\u6548\uFF0C\u53EA\u80FD\u7528\u4E00\u6B21\uFF09
|
|
3158
3184
|
`);
|
|
3159
3185
|
}
|
|
3160
3186
|
return { url, expiresIn };
|
|
@@ -3246,8 +3272,8 @@ import {
|
|
|
3246
3272
|
formatObject as formatObject7,
|
|
3247
3273
|
fromAxiosError as fromAxiosError9
|
|
3248
3274
|
} from "@hcmai/sdk";
|
|
3249
|
-
function collectYmlFiles(
|
|
3250
|
-
if (statSync(
|
|
3275
|
+
function collectYmlFiles(path13) {
|
|
3276
|
+
if (statSync(path13).isFile()) return [path13];
|
|
3251
3277
|
const out = [];
|
|
3252
3278
|
const walk = (dir) => {
|
|
3253
3279
|
for (const name of readdirSync(dir).sort()) {
|
|
@@ -3256,7 +3282,7 @@ function collectYmlFiles(path12) {
|
|
|
3256
3282
|
else if (full.endsWith(".yml") || full.endsWith(".yaml")) out.push(full);
|
|
3257
3283
|
}
|
|
3258
3284
|
};
|
|
3259
|
-
walk(
|
|
3285
|
+
walk(path13);
|
|
3260
3286
|
return out.sort();
|
|
3261
3287
|
}
|
|
3262
3288
|
var DRY_RUN_CLIENT = {
|
|
@@ -3264,9 +3290,9 @@ var DRY_RUN_CLIENT = {
|
|
|
3264
3290
|
create: async () => ({ id: "" }),
|
|
3265
3291
|
update: async () => ({})
|
|
3266
3292
|
};
|
|
3267
|
-
async function importCommand(
|
|
3293
|
+
async function importCommand(path13, args) {
|
|
3268
3294
|
try {
|
|
3269
|
-
const files = collectYmlFiles(
|
|
3295
|
+
const files = collectYmlFiles(path13);
|
|
3270
3296
|
const fixtures = files.map(
|
|
3271
3297
|
(f) => parseFixture(readFileSync2(f, "utf8"), relative(process.cwd(), f))
|
|
3272
3298
|
);
|
|
@@ -4503,8 +4529,8 @@ async function scriptManifestValidateCommand(args) {
|
|
|
4503
4529
|
if (!args.file) {
|
|
4504
4530
|
throw new Error("\u7F3A\u5C11 --file\n \u4E0B\u4E00\u6B65\uFF1Ahcm script manifest-validate --file ./manifest.yml");
|
|
4505
4531
|
}
|
|
4506
|
-
const
|
|
4507
|
-
const result = await withClient2(args, (c) => validateScriptManifest(c.raw(),
|
|
4532
|
+
const yaml2 = readFileSync3(args.file, "utf8");
|
|
4533
|
+
const result = await withClient2(args, (c) => validateScriptManifest(c.raw(), yaml2));
|
|
4508
4534
|
emit2(result, args, `\u{1F4CB} manifest \u6821\u9A8C\u5B8C\u6210\uFF1A${args.file}`);
|
|
4509
4535
|
} catch (e) {
|
|
4510
4536
|
fail3(e, args);
|
|
@@ -5499,7 +5525,7 @@ async function fetchSkillDocument(http, skill, endpoint, base) {
|
|
|
5499
5525
|
return {
|
|
5500
5526
|
id: skill.id,
|
|
5501
5527
|
markdown: await fetchSkillMarkdown(http, skill.id, base),
|
|
5502
|
-
source: `${endpoint}${base}
|
|
5528
|
+
source: `${endpoint}${base}/${skill.id}.md`,
|
|
5503
5529
|
sourceKind: "chiron",
|
|
5504
5530
|
references
|
|
5505
5531
|
};
|
|
@@ -6230,10 +6256,10 @@ async function metaListCommand(args) {
|
|
|
6230
6256
|
fail5(e, args);
|
|
6231
6257
|
}
|
|
6232
6258
|
}
|
|
6233
|
-
async function metaGetCommand(
|
|
6259
|
+
async function metaGetCommand(path13, args) {
|
|
6234
6260
|
try {
|
|
6235
6261
|
const c = await client2(args);
|
|
6236
|
-
const content = await getTenantMeta(c.raw(),
|
|
6262
|
+
const content = await getTenantMeta(c.raw(), path13);
|
|
6237
6263
|
process.stdout.write(content.endsWith("\n") ? content : content + "\n");
|
|
6238
6264
|
process.exit(0);
|
|
6239
6265
|
} catch (e) {
|
|
@@ -6241,8 +6267,8 @@ async function metaGetCommand(path12, args) {
|
|
|
6241
6267
|
}
|
|
6242
6268
|
}
|
|
6243
6269
|
var PROBEABLE_META_TYPES = /* @__PURE__ */ new Set(["model", "list", "info", "view", "filter", "page", "wiz", "impexp"]);
|
|
6244
|
-
function parseMetaPath(
|
|
6245
|
-
const base =
|
|
6270
|
+
function parseMetaPath(path13) {
|
|
6271
|
+
const base = path13.split(/[\\/]/).pop() ?? path13;
|
|
6246
6272
|
if (!/\.(yml|yaml)$/i.test(base)) return {};
|
|
6247
6273
|
const parts = base.replace(/\.(yml|yaml)$/i, "").split(".");
|
|
6248
6274
|
return { model: parts[0] || void 0, kind: parts[1] ?? "model", state: parts[2] };
|
|
@@ -6259,10 +6285,10 @@ function unverifiableReason(e) {
|
|
|
6259
6285
|
if (st == null) return `\u8BF7\u6C42\u6CA1\u53D1\u51FA\u53BB\u6216\u6CA1\u56DE\u6765\uFF08${err.code ?? err.message ?? "\u672A\u77E5"}\uFF09`;
|
|
6260
6286
|
return void 0;
|
|
6261
6287
|
}
|
|
6262
|
-
async function verifyAfterWrite(c,
|
|
6263
|
-
const { model, kind, state } = parseMetaPath(
|
|
6288
|
+
async function verifyAfterWrite(c, path13) {
|
|
6289
|
+
const { model, kind, state } = parseMetaPath(path13);
|
|
6264
6290
|
if (!model || !kind) {
|
|
6265
|
-
return { status: "unverified", where: "(\u672A\u63A2)", why: `\u4ECE\u8DEF\u5F84 ${
|
|
6291
|
+
return { status: "unverified", where: "(\u672A\u63A2)", why: `\u4ECE\u8DEF\u5F84 ${path13} \u8BA4\u4E0D\u51FA\u6A21\u578B\u540D/\u5C42\u540D` };
|
|
6266
6292
|
}
|
|
6267
6293
|
try {
|
|
6268
6294
|
await clearMetaCache2(c.raw(), model, {});
|
|
@@ -6307,7 +6333,7 @@ async function verifyAfterWrite(c, path12) {
|
|
|
6307
6333
|
}
|
|
6308
6334
|
return { status: "ok" };
|
|
6309
6335
|
}
|
|
6310
|
-
async function metaSetCommand(
|
|
6336
|
+
async function metaSetCommand(path13, args) {
|
|
6311
6337
|
try {
|
|
6312
6338
|
if (!args.file) {
|
|
6313
6339
|
throw new CliError19({
|
|
@@ -6323,9 +6349,9 @@ async function metaSetCommand(path12, args) {
|
|
|
6323
6349
|
process.stdin.on("error", reject);
|
|
6324
6350
|
}) : await fsp3.readFile(args.file, "utf8");
|
|
6325
6351
|
if (!args.skipValidate) {
|
|
6326
|
-
const result2 = validateMetaContent(
|
|
6352
|
+
const result2 = validateMetaContent(path13, content);
|
|
6327
6353
|
if (result2.issues.length > 0) {
|
|
6328
|
-
process.stderr.write(`\u{1F50E} \u5199\u524D\u6821\u9A8C ${
|
|
6354
|
+
process.stderr.write(`\u{1F50E} \u5199\u524D\u6821\u9A8C ${path13}\uFF08schema \u7C7B\u578B\uFF1A${result2.kind ?? "\u672A\u8BC6\u522B"}\uFF09
|
|
6329
6355
|
`);
|
|
6330
6356
|
process.stderr.write(formatMetaIssues(result2, " ") + "\n");
|
|
6331
6357
|
}
|
|
@@ -6344,13 +6370,13 @@ async function metaSetCommand(path12, args) {
|
|
|
6344
6370
|
if (dryFmt === "json" || dryFmt === "yaml") {
|
|
6345
6371
|
process.stdout.write(
|
|
6346
6372
|
formatObject18(
|
|
6347
|
-
{ dryRun: true, path:
|
|
6373
|
+
{ dryRun: true, path: path13, bytes: Buffer.byteLength(content), content },
|
|
6348
6374
|
{ format: dryFmt }
|
|
6349
6375
|
) + "\n"
|
|
6350
6376
|
);
|
|
6351
6377
|
} else {
|
|
6352
6378
|
process.stdout.write(
|
|
6353
|
-
`[dry-run] \u5C06\u5199\u5165 ${
|
|
6379
|
+
`[dry-run] \u5C06\u5199\u5165 ${path13}\uFF08${Buffer.byteLength(content)} B\uFF09\u2014\u2014\u672A\u5B9E\u9645\u5199\u5165
|
|
6354
6380
|
---
|
|
6355
6381
|
${content}
|
|
6356
6382
|
`
|
|
@@ -6363,13 +6389,13 @@ ${content}
|
|
|
6363
6389
|
let backupState = "unknown";
|
|
6364
6390
|
let backupWhy;
|
|
6365
6391
|
try {
|
|
6366
|
-
const prev = await getTenantMeta(c.raw(),
|
|
6392
|
+
const prev = await getTenantMeta(c.raw(), path13);
|
|
6367
6393
|
if (!prev || prev.trim() === "") {
|
|
6368
6394
|
backupState = "absent";
|
|
6369
6395
|
} else {
|
|
6370
6396
|
backupFile = nodePath.join(
|
|
6371
6397
|
os3.tmpdir(),
|
|
6372
|
-
`hcm-meta-backup-${Date.now()}-${
|
|
6398
|
+
`hcm-meta-backup-${Date.now()}-${path13.replace(/[\\/]/g, "_")}`
|
|
6373
6399
|
);
|
|
6374
6400
|
await fsp3.writeFile(backupFile, prev, "utf8");
|
|
6375
6401
|
backupState = "saved";
|
|
@@ -6384,22 +6410,22 @@ ${content}
|
|
|
6384
6410
|
backupWhy = `HTTP ${st ?? "-"}${err.code ? ` ${err.code}` : ""}${err.message ? `\uFF1A${err.message}` : ""}`;
|
|
6385
6411
|
}
|
|
6386
6412
|
}
|
|
6387
|
-
const result = await saveTenantMeta(c.raw(),
|
|
6413
|
+
const result = await saveTenantMeta(c.raw(), path13, content);
|
|
6388
6414
|
const fmt = args.output ?? "json";
|
|
6389
|
-
if (fmt !== "json") process.stdout.write(`\u2705 \u5DF2\u5199\u5165 ${
|
|
6415
|
+
if (fmt !== "json") process.stdout.write(`\u2705 \u5DF2\u5199\u5165 ${path13}
|
|
6390
6416
|
`);
|
|
6391
6417
|
const restoreHint = backupState === "saved" && backupFile ? ` \u65E7\u5185\u5BB9\u5DF2\u5B58\uFF1A${backupFile}
|
|
6392
|
-
\u653E\u56DE\u53BB\uFF1Ahcm meta set ${
|
|
6393
|
-
` : backupState === "absent" ? ` \u8FD9\u4E00\u5C42\u6B64\u524D\u6CA1\u6709\u8986\u76D6\uFF08\u5DF2\u8BC1\u5B9E\uFF09\uFF0C\u6062\u590D\u5373\u5220\u9664\uFF1Ahcm meta delete ${
|
|
6418
|
+
\u653E\u56DE\u53BB\uFF1Ahcm meta set ${path13} --file ${backupFile}${connFlags(args)}
|
|
6419
|
+
` : backupState === "absent" ? ` \u8FD9\u4E00\u5C42\u6B64\u524D\u6CA1\u6709\u8986\u76D6\uFF08\u5DF2\u8BC1\u5B9E\uFF09\uFF0C\u6062\u590D\u5373\u5220\u9664\uFF1Ahcm meta delete ${path13}${connFlags(args)}
|
|
6394
6420
|
` : ` \u26A0\uFE0F \u65E7\u5185\u5BB9**\u6CA1\u5907\u4EFD\u6210**\uFF08${backupWhy ?? "\u539F\u56E0\u672A\u77E5"}\uFF09\u2014\u2014\u65E2\u4E0D\u77E5\u9053\u6B64\u524D\u6709\u6CA1\u6709\u8986\u76D6\uFF0C\u4E5F\u5C31\u7ED9\u4E0D\u51FA\u6062\u590D\u547D\u4EE4\u3002
|
|
6395
|
-
\u5148\u81EA\u5DF1\u8BFB\u4E00\u904D\u786E\u8BA4\uFF1Ahcm meta get ${
|
|
6421
|
+
\u5148\u81EA\u5DF1\u8BFB\u4E00\u904D\u786E\u8BA4\uFF1Ahcm meta get ${path13}${connFlags(args)}
|
|
6396
6422
|
`;
|
|
6397
6423
|
if (args.verify === false) {
|
|
6398
6424
|
process.stderr.write(
|
|
6399
6425
|
"\u26A0\uFE0F --no-verify\uFF1A**\u6CA1\u6709**\u9A8C\u8FC7\u670D\u52A1\u7AEF\u8BFB\u4E0D\u8BFB\u5F97\u52A8\u8FD9\u4EFD meta\u3002\u300C\u5199\u5165\u6210\u529F\u300D\u53EA\u8BF4\u660E\u5B57\u8282\u6536\u4E0B\u4E86\u3002\n \u81EA\u5DF1\u8865\uFF1Ahcm cache clear-meta <Model> \u540E\u6253\u5F00\u9875\u9762\u770B\u4E00\u773C\u3002\n" + restoreHint
|
|
6400
6426
|
);
|
|
6401
6427
|
} else {
|
|
6402
|
-
const outcome = await verifyAfterWrite(c,
|
|
6428
|
+
const outcome = await verifyAfterWrite(c, path13);
|
|
6403
6429
|
if (outcome.status === "broken") {
|
|
6404
6430
|
const human = explainJacksonError(outcome.raw);
|
|
6405
6431
|
process.stderr.write(
|
|
@@ -6431,19 +6457,19 @@ ${content}
|
|
|
6431
6457
|
fail5(e, args);
|
|
6432
6458
|
}
|
|
6433
6459
|
}
|
|
6434
|
-
async function metaDeleteCommand(
|
|
6460
|
+
async function metaDeleteCommand(path13, args) {
|
|
6435
6461
|
try {
|
|
6436
6462
|
if (!args.yes) {
|
|
6437
|
-
const ok = await promptConfirm(`\u5C06\u5220\u9664\u5143\u6570\u636E ${
|
|
6463
|
+
const ok = await promptConfirm(`\u5C06\u5220\u9664\u5143\u6570\u636E ${path13}\uFF0C\u6B64\u64CD\u4F5C\u4E0D\u53EF\u9006\u3002\u7EE7\u7EED\uFF1F`);
|
|
6438
6464
|
if (!ok) {
|
|
6439
6465
|
process.stderr.write("\u5DF2\u53D6\u6D88\n");
|
|
6440
6466
|
process.exit(1);
|
|
6441
6467
|
}
|
|
6442
6468
|
}
|
|
6443
6469
|
const c = await client2(args);
|
|
6444
|
-
const result = await deleteTenantMeta(c.raw(),
|
|
6470
|
+
const result = await deleteTenantMeta(c.raw(), path13);
|
|
6445
6471
|
const fmt = args.output ?? "json";
|
|
6446
|
-
if (fmt !== "json") process.stdout.write(`\u{1F5D1}\uFE0F \u5DF2\u5220\u9664 ${
|
|
6472
|
+
if (fmt !== "json") process.stdout.write(`\u{1F5D1}\uFE0F \u5DF2\u5220\u9664 ${path13}
|
|
6447
6473
|
`);
|
|
6448
6474
|
process.stdout.write(formatObject18(result, { format: fmt }) + "\n");
|
|
6449
6475
|
process.exit(0);
|
|
@@ -6451,7 +6477,7 @@ async function metaDeleteCommand(path12, args) {
|
|
|
6451
6477
|
fail5(e, args);
|
|
6452
6478
|
}
|
|
6453
6479
|
}
|
|
6454
|
-
async function metaValidateCommand(
|
|
6480
|
+
async function metaValidateCommand(path13, args) {
|
|
6455
6481
|
try {
|
|
6456
6482
|
if (!args.file) {
|
|
6457
6483
|
throw new CliError19({
|
|
@@ -6466,13 +6492,13 @@ async function metaValidateCommand(path12, args) {
|
|
|
6466
6492
|
process.stdin.on("end", () => resolve4(buf));
|
|
6467
6493
|
process.stdin.on("error", reject);
|
|
6468
6494
|
}) : await fsp3.readFile(args.file, "utf8");
|
|
6469
|
-
const result = validateMetaContent(
|
|
6495
|
+
const result = validateMetaContent(path13, content);
|
|
6470
6496
|
const fmt = args.output ?? "table";
|
|
6471
6497
|
if (fmt === "json" || fmt === "yaml") {
|
|
6472
6498
|
process.stdout.write(
|
|
6473
6499
|
formatObject18(
|
|
6474
6500
|
{
|
|
6475
|
-
path:
|
|
6501
|
+
path: path13,
|
|
6476
6502
|
kind: result.kind,
|
|
6477
6503
|
schemaKnown: result.schemaKnown,
|
|
6478
6504
|
schemaSourceCommit: META_SCHEMA_SOURCE_COMMIT,
|
|
@@ -6484,7 +6510,7 @@ async function metaValidateCommand(path12, args) {
|
|
|
6484
6510
|
);
|
|
6485
6511
|
} else {
|
|
6486
6512
|
process.stdout.write(
|
|
6487
|
-
`\u{1F50E} ${
|
|
6513
|
+
`\u{1F50E} ${path13}\uFF08schema \u7C7B\u578B\uFF1A${result.kind ?? "\u672A\u8BC6\u522B"}\uFF0C\u6765\u6E90 ${META_SCHEMA_SOURCE_COMMIT.slice(0, 8)}\uFF09
|
|
6488
6514
|
`
|
|
6489
6515
|
);
|
|
6490
6516
|
process.stdout.write(
|
|
@@ -7963,6 +7989,11 @@ var GUARDED_EXECUTOR_REASON_CODES = /* @__PURE__ */ new Set([
|
|
|
7963
7989
|
"setting-write",
|
|
7964
7990
|
"credential-reset",
|
|
7965
7991
|
"action-write",
|
|
7992
|
+
// 三态 effect 的 UNKNOWN / 未识别值都按最坏情况视作写操作,走与 WRITES
|
|
7993
|
+
// 完全相同的 prepare + execute 通道。分类函数已经返回 R2 guarded;这里漏登记
|
|
7994
|
+
// 会把 guardedExecutionAvailable 又翻回 false,造成 reason 与 modePolicy 自相矛盾。
|
|
7995
|
+
"action-effect-undetermined",
|
|
7996
|
+
"action-effect-unrecognized",
|
|
7966
7997
|
"workspace-create",
|
|
7967
7998
|
"workspace-activate",
|
|
7968
7999
|
// 这两个的载荷是**任意文件 / 整棵目录**,此前刻意不收——绑不住就意味着
|
|
@@ -7988,7 +8019,11 @@ var GUARDED_EXECUTOR_REASON_CODES = /* @__PURE__ */ new Set([
|
|
|
7988
8019
|
// 🔴 客户存量组织导入的整条链就卡在这一个上:2026-09-01 演示环境租户 15,
|
|
7989
8020
|
// 531 条组织机构 dry-run 全绿(静态校验 0 失败),正式导入被
|
|
7990
8021
|
// 「该 R2 命令不在首批受控执行器支持面」拦死,一个写请求都没发出去。
|
|
7991
|
-
"import-write"
|
|
8022
|
+
"import-write",
|
|
8023
|
+
// 报表 / 套打模板回传要先 upload 拿 documentId,再挂到业务对象。文件路径是
|
|
8024
|
+
// 固定位置参数,prepare 会钉住项目内普通文件的摘要,execute 前重算后才单次执行。
|
|
8025
|
+
// 2026-09-02 弹性报表顾问仿真已证实这条交付链会在缺受控执行器时中断。
|
|
8026
|
+
"document-upload"
|
|
7992
8027
|
]);
|
|
7993
8028
|
function normalizeAssessedArgv(inputArgv) {
|
|
7994
8029
|
let rest = inputArgv;
|
|
@@ -8378,6 +8413,151 @@ function isPlainObject(value) {
|
|
|
8378
8413
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8379
8414
|
}
|
|
8380
8415
|
|
|
8416
|
+
// src/commands/delivery-project-config.ts
|
|
8417
|
+
import yaml, { JSON_SCHEMA } from "js-yaml";
|
|
8418
|
+
var DELIVERY_MODES = ["plan-only", "controlled"];
|
|
8419
|
+
function isDeliveryMode(value) {
|
|
8420
|
+
return value === "plan-only" || value === "controlled";
|
|
8421
|
+
}
|
|
8422
|
+
function parseProjectDeliveryModes(content) {
|
|
8423
|
+
let loaded;
|
|
8424
|
+
try {
|
|
8425
|
+
loaded = yaml.load(content, { schema: JSON_SCHEMA });
|
|
8426
|
+
} catch (cause) {
|
|
8427
|
+
throw new Error(`project.yml \u4E0D\u662F\u5408\u6CD5 YAML\uFF1A${String(cause.message)}`);
|
|
8428
|
+
}
|
|
8429
|
+
if (!isRecord(loaded)) throw new Error("project.yml \u9876\u5C42\u5FC5\u987B\u662F\u5BF9\u8C61");
|
|
8430
|
+
const version = loaded.schemaVersion;
|
|
8431
|
+
const raw = loaded.deliveryMode;
|
|
8432
|
+
if (isDeliveryMode(raw)) {
|
|
8433
|
+
if (version !== void 0 && version !== 1) {
|
|
8434
|
+
throw new Error("project.yml \u7684\u6807\u91CF deliveryMode \u53EA\u5C5E\u4E8E schemaVersion 1");
|
|
8435
|
+
}
|
|
8436
|
+
return { kind: "legacy", mode: raw };
|
|
8437
|
+
}
|
|
8438
|
+
if (version !== 2) {
|
|
8439
|
+
throw new Error("project.yml \u7684\u5206\u73AF\u5883 deliveryMode \u5FC5\u987B\u58F0\u660E schemaVersion: 2");
|
|
8440
|
+
}
|
|
8441
|
+
if (raw !== null && raw !== void 0 && !isRecord(raw)) {
|
|
8442
|
+
throw new Error("project.yml \u7684 deliveryMode \u5FC5\u987B\u662F\u201C\u73AF\u5883\u522B\u540D \u2192 \u6A21\u5F0F\u201D\u7684\u6620\u5C04");
|
|
8443
|
+
}
|
|
8444
|
+
const modes = /* @__PURE__ */ Object.create(null);
|
|
8445
|
+
for (const [environment, mode] of Object.entries(raw ?? {})) {
|
|
8446
|
+
if (!environment.trim()) throw new Error("project.yml \u7684 deliveryMode \u542B\u7A7A\u73AF\u5883\u522B\u540D");
|
|
8447
|
+
if (!isDeliveryMode(mode)) {
|
|
8448
|
+
throw new Error(
|
|
8449
|
+
`project.yml \u4E2D\u73AF\u5883 ${JSON.stringify(environment)} \u7684 deliveryMode \u975E\u6CD5\uFF1A${String(mode)}`
|
|
8450
|
+
);
|
|
8451
|
+
}
|
|
8452
|
+
modes[environment] = mode;
|
|
8453
|
+
}
|
|
8454
|
+
return { kind: "per-environment", modes };
|
|
8455
|
+
}
|
|
8456
|
+
function deliveryModeForEnvironment(content, environment) {
|
|
8457
|
+
assertEnvironment(environment);
|
|
8458
|
+
const parsed = parseProjectDeliveryModes(content);
|
|
8459
|
+
return parsed.kind === "per-environment" ? parsed.modes[environment] ?? null : null;
|
|
8460
|
+
}
|
|
8461
|
+
function setDeliveryModeForEnvironment(content, environment, mode) {
|
|
8462
|
+
assertEnvironment(environment);
|
|
8463
|
+
const parsed = parseProjectDeliveryModes(content);
|
|
8464
|
+
const hadFinalNewline = content.endsWith("\n");
|
|
8465
|
+
const lines = content.split("\n");
|
|
8466
|
+
if (hadFinalNewline) lines.pop();
|
|
8467
|
+
if (parsed.kind === "legacy") {
|
|
8468
|
+
const scalarIndex = lines.findIndex(
|
|
8469
|
+
(line) => /^deliveryMode:\s*(?:"(?:plan-only|controlled)"|'(?:plan-only|controlled)'|(?:plan-only|controlled))\s*(?:#.*)?$/.test(line)
|
|
8470
|
+
);
|
|
8471
|
+
if (scalarIndex < 0) {
|
|
8472
|
+
throw new Error("project.yml \u7684\u65E7 deliveryMode \u4E0D\u662F\u53EF\u5B89\u5168\u8FC1\u79FB\u7684\u9876\u5C42\u6807\u91CF\u884C");
|
|
8473
|
+
}
|
|
8474
|
+
const inlineComment = lines[scalarIndex]?.match(/\s+(#.*)$/)?.[1];
|
|
8475
|
+
lines.splice(
|
|
8476
|
+
scalarIndex,
|
|
8477
|
+
1,
|
|
8478
|
+
`deliveryMode:${inlineComment ? ` ${inlineComment}` : ""}`,
|
|
8479
|
+
renderModeEntry(environment, mode)
|
|
8480
|
+
);
|
|
8481
|
+
const versionIndex = lines.findIndex((line) => /^schemaVersion:\s*/.test(line));
|
|
8482
|
+
if (versionIndex >= 0) {
|
|
8483
|
+
const versionComment = lines[versionIndex]?.match(/\s+(#.*)$/)?.[1];
|
|
8484
|
+
lines[versionIndex] = `schemaVersion: 2${versionComment ? ` ${versionComment}` : ""}`;
|
|
8485
|
+
} else {
|
|
8486
|
+
lines.splice(scalarIndex, 0, "schemaVersion: 2");
|
|
8487
|
+
}
|
|
8488
|
+
return {
|
|
8489
|
+
content: finishLines(lines, hadFinalNewline),
|
|
8490
|
+
previous: parsed.mode,
|
|
8491
|
+
migratedLegacy: true
|
|
8492
|
+
};
|
|
8493
|
+
}
|
|
8494
|
+
const sectionStart = lines.findIndex((line) => /^deliveryMode:\s*(?:#.*)?$/.test(line));
|
|
8495
|
+
if (sectionStart < 0) {
|
|
8496
|
+
throw new Error("project.yml \u7F3A\u5C11\u53EF\u5B89\u5168\u66F4\u65B0\u7684\u9876\u5C42 deliveryMode \u6620\u5C04");
|
|
8497
|
+
}
|
|
8498
|
+
let sectionEnd = lines.length;
|
|
8499
|
+
for (let index = sectionStart + 1; index < lines.length; index += 1) {
|
|
8500
|
+
const line = lines[index] ?? "";
|
|
8501
|
+
if (line.trim() === "" || line.trimStart().startsWith("#")) continue;
|
|
8502
|
+
if (!/^\s/.test(line)) {
|
|
8503
|
+
sectionEnd = index;
|
|
8504
|
+
break;
|
|
8505
|
+
}
|
|
8506
|
+
}
|
|
8507
|
+
let lastEntry = sectionStart;
|
|
8508
|
+
let targetIndex = -1;
|
|
8509
|
+
for (let index = sectionStart + 1; index < sectionEnd; index += 1) {
|
|
8510
|
+
const line = lines[index] ?? "";
|
|
8511
|
+
if (!/^ {2}\S/.test(line) || /^ {4}/.test(line)) continue;
|
|
8512
|
+
const entry = parseDirectModeEntry(line);
|
|
8513
|
+
if (!entry) continue;
|
|
8514
|
+
lastEntry = index;
|
|
8515
|
+
if (entry.environment === environment) targetIndex = index;
|
|
8516
|
+
}
|
|
8517
|
+
const previous = parsed.modes[environment] ?? null;
|
|
8518
|
+
if (previous !== null && targetIndex < 0) {
|
|
8519
|
+
throw new Error(
|
|
8520
|
+
`project.yml \u4E2D ${JSON.stringify(environment)} \u4F7F\u7528\u4E86\u65E0\u6CD5\u5B89\u5168\u5C31\u5730\u6539\u5199\u7684 YAML \u5E03\u5C40`
|
|
8521
|
+
);
|
|
8522
|
+
}
|
|
8523
|
+
if (targetIndex >= 0) {
|
|
8524
|
+
const trailingComment = lines[targetIndex]?.match(
|
|
8525
|
+
/(?:"(?:plan-only|controlled)"|'(?:plan-only|controlled)'|(?:plan-only|controlled))\s+(#.*)$/
|
|
8526
|
+
)?.[1];
|
|
8527
|
+
lines[targetIndex] = `${renderModeEntry(environment, mode)}${trailingComment ? ` ${trailingComment}` : ""}`;
|
|
8528
|
+
} else {
|
|
8529
|
+
lines.splice(lastEntry + 1, 0, renderModeEntry(environment, mode));
|
|
8530
|
+
}
|
|
8531
|
+
return {
|
|
8532
|
+
content: finishLines(lines, hadFinalNewline),
|
|
8533
|
+
previous,
|
|
8534
|
+
migratedLegacy: false
|
|
8535
|
+
};
|
|
8536
|
+
}
|
|
8537
|
+
function parseDirectModeEntry(line) {
|
|
8538
|
+
try {
|
|
8539
|
+
const value = yaml.load(line.trim(), { schema: JSON_SCHEMA });
|
|
8540
|
+
if (!isRecord(value)) return null;
|
|
8541
|
+
const entries = Object.entries(value);
|
|
8542
|
+
if (entries.length !== 1 || !isDeliveryMode(entries[0]?.[1])) return null;
|
|
8543
|
+
return { environment: entries[0][0], mode: entries[0][1] };
|
|
8544
|
+
} catch {
|
|
8545
|
+
return null;
|
|
8546
|
+
}
|
|
8547
|
+
}
|
|
8548
|
+
function renderModeEntry(environment, mode) {
|
|
8549
|
+
return ` ${JSON.stringify(environment)}: ${mode}`;
|
|
8550
|
+
}
|
|
8551
|
+
function finishLines(lines, finalNewline) {
|
|
8552
|
+
return `${lines.join("\n")}${finalNewline ? "\n" : ""}`;
|
|
8553
|
+
}
|
|
8554
|
+
function assertEnvironment(environment) {
|
|
8555
|
+
if (!environment.trim()) throw new Error("\u73AF\u5883\u522B\u540D\u4E0D\u80FD\u4E3A\u7A7A");
|
|
8556
|
+
}
|
|
8557
|
+
function isRecord(value) {
|
|
8558
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
8559
|
+
}
|
|
8560
|
+
|
|
8381
8561
|
// src/commands/delivery-action-policy.ts
|
|
8382
8562
|
async function assessEffectiveDeliveryCommand(inputArgv, dependencies = {}) {
|
|
8383
8563
|
const local = assessDeliveryCommand(inputArgv);
|
|
@@ -8389,25 +8569,32 @@ async function assessEffectiveDeliveryCommand(inputArgv, dependencies = {}) {
|
|
|
8389
8569
|
const resolution = await (dependencies.resolveAction ?? resolveCoreAction)(request);
|
|
8390
8570
|
return assessDeliveryCommand(inputArgv, { actionResolution: resolution });
|
|
8391
8571
|
}
|
|
8392
|
-
function readDeliveryMode(projectRoot = ".") {
|
|
8572
|
+
function readDeliveryMode(projectRoot = ".", environment) {
|
|
8393
8573
|
const file = pathJoin(projectRoot, ".hcm-delivery", "project.yml");
|
|
8394
8574
|
if (!existsSync2(file)) return null;
|
|
8395
|
-
|
|
8396
|
-
|
|
8397
|
-
|
|
8398
|
-
|
|
8575
|
+
try {
|
|
8576
|
+
return deliveryModeForEnvironment(readFileSync5(file, "utf8"), environment);
|
|
8577
|
+
} catch {
|
|
8578
|
+
return null;
|
|
8579
|
+
}
|
|
8399
8580
|
}
|
|
8400
8581
|
function withProjectReadiness(assessment, projectRoot = ".") {
|
|
8401
8582
|
const projectFile = pathJoin(projectRoot, ".hcm-delivery", "project.yml");
|
|
8402
8583
|
const projectInitialized = existsSync2(projectFile);
|
|
8403
|
-
const
|
|
8404
|
-
|
|
8584
|
+
const environment = assessment.environment?.envAlias;
|
|
8585
|
+
const deliveryMode = environment ? readDeliveryMode(projectRoot, environment) : null;
|
|
8586
|
+
if (projectInitialized && deliveryMode !== "controlled" && assessment.guardedExecutionAvailable) {
|
|
8587
|
+
const requirements2 = [...assessment.requirements ?? []];
|
|
8588
|
+
if (!requirements2.includes("environment-delivery-mode")) {
|
|
8589
|
+
requirements2.push("environment-delivery-mode");
|
|
8590
|
+
}
|
|
8405
8591
|
return {
|
|
8406
8592
|
...assessment,
|
|
8407
8593
|
projectInitialized,
|
|
8408
8594
|
deliveryMode,
|
|
8595
|
+
requirements: requirements2,
|
|
8409
8596
|
modePolicy: assessment.modePolicy ? { ...assessment.modePolicy, controlled: "deny" } : assessment.modePolicy,
|
|
8410
|
-
projectNextStep: "\
|
|
8597
|
+
projectNextStep: deliveryMode === "plan-only" ? `\u73AF\u5883 ${environment} \u7684\u4EA4\u4ED8\u6A21\u5F0F\u662F plan-only\uFF0C\u53EA\u51FA\u8BA1\u5212\u4E0D\u6267\u884C\u3002\u8981\u771F\u6B63\u6267\u884C R2\uFF0C\u9700\u9879\u76EE\u8D1F\u8D23\u4EBA\u6388\u6743\u540E\u53EA\u5207\u6362\u8FD9\u4E2A\u73AF\u5883\uFF08hcm delivery mode --env ${environment} --set controlled\uFF09` : environment ? `\u73AF\u5883 ${environment} \u5C1A\u672A\u767B\u8BB0\u5408\u6CD5\u4EA4\u4ED8\u6A21\u5F0F\uFF0C\u5DF2 fail-closed\u3002\u5148\u6267\u884C hcm delivery mode --env ${environment} --set plan-only` : "R2 \u547D\u4EE4\u5FC5\u987B\u5728\u88AB\u8BC4\u4F30\u7684 argv \u4E2D\u663E\u5F0F\u5305\u542B --env <\u73AF\u5883\u522B\u540D>"
|
|
8411
8598
|
};
|
|
8412
8599
|
}
|
|
8413
8600
|
if (projectInitialized || !assessment.guardedExecutionAvailable) {
|
|
@@ -8535,40 +8722,367 @@ function flagValue2(argv, flag) {
|
|
|
8535
8722
|
|
|
8536
8723
|
// src/commands/delivery-init.ts
|
|
8537
8724
|
init_exit();
|
|
8725
|
+
import { promises as fs7 } from "fs";
|
|
8726
|
+
import path7 from "path";
|
|
8727
|
+
import {
|
|
8728
|
+
formatObject as formatObject21,
|
|
8729
|
+
loadEnv as loadEnv9,
|
|
8730
|
+
loadGlobalConfig as loadGlobalConfig9,
|
|
8731
|
+
resolveActiveEnv as resolveActiveEnv5
|
|
8732
|
+
} from "@hcmai/sdk";
|
|
8733
|
+
|
|
8734
|
+
// src/commands/delivery-project-scaffold.ts
|
|
8538
8735
|
import { promises as fs6 } from "fs";
|
|
8539
8736
|
import path6 from "path";
|
|
8540
|
-
|
|
8541
|
-
var
|
|
8542
|
-
var
|
|
8543
|
-
|
|
8737
|
+
var AGENT_BEGIN = "<!-- hcm-delivery-project:begin -->";
|
|
8738
|
+
var AGENT_END = "<!-- hcm-delivery-project:end -->";
|
|
8739
|
+
var GITIGNORE_BEGIN = "# >>> hcm delivery local state >>>";
|
|
8740
|
+
var GITIGNORE_END = "# <<< hcm delivery local state <<<";
|
|
8741
|
+
var DELIVERY_PROJECT_DIRECTORIES = [
|
|
8742
|
+
"work",
|
|
8743
|
+
"decisions",
|
|
8744
|
+
"evidence",
|
|
8745
|
+
"hcm-skills",
|
|
8746
|
+
"\u5BA2\u6237\u8D44\u6599",
|
|
8747
|
+
"\u9700\u6C42",
|
|
8748
|
+
"\u4EA4\u4ED8\u7269",
|
|
8749
|
+
"\u8BC1\u636E",
|
|
8750
|
+
"\u51B3\u7B56",
|
|
8751
|
+
"\u6848\u4F8B"
|
|
8752
|
+
];
|
|
8753
|
+
function renderEnvironmentYml(environment, config2, initialMode) {
|
|
8754
|
+
const endpoint = config2?.endpoint ?? "REPLACE_ME";
|
|
8755
|
+
const frontend = config2?.frontend ?? endpoint;
|
|
8756
|
+
const tenant2 = config2?.tenantId ?? "1";
|
|
8757
|
+
return [
|
|
8758
|
+
"# \u5BA2\u6237\u9879\u76EE\u5171\u4EAB\u73AF\u5883\u6E05\u5355\uFF08\u4E0D\u653E\u8EAB\u4EFD\u6216\u51ED\u636E\uFF09",
|
|
8759
|
+
"# owner \u4E0E controlled \u7531\u9879\u76EE\u8D1F\u8D23\u4EBA\u8BC4\u5BA1\uFF1B\u4E2A\u4EBA\u673A\u5668\u4E0A\u7684\u5B9E\u9645\u6A21\u5F0F\u5728 .hcm-delivery/project.yml\u3002",
|
|
8760
|
+
"schemaVersion: 1",
|
|
8761
|
+
"environments:",
|
|
8762
|
+
` - alias: ${JSON.stringify(environment)}`,
|
|
8763
|
+
` endpoint: ${JSON.stringify(endpoint)}`,
|
|
8764
|
+
` frontend: ${JSON.stringify(frontend)}`,
|
|
8765
|
+
` tenant: ${JSON.stringify(tenant2)}`,
|
|
8766
|
+
` controlled: ${initialMode === "controlled" ? "true" : "false"}`,
|
|
8767
|
+
' owner: "TODO: \u9879\u76EE\u8D1F\u8D23\u4EBA"',
|
|
8768
|
+
""
|
|
8769
|
+
].join("\n");
|
|
8770
|
+
}
|
|
8771
|
+
function renderAgentInstructions() {
|
|
8772
|
+
return [
|
|
8773
|
+
AGENT_BEGIN,
|
|
8774
|
+
"# HCM \u987E\u95EE\u9879\u76EE\u8FB9\u754C",
|
|
8775
|
+
"",
|
|
8776
|
+
"- \u53EA\u4F7F\u7528\u672C\u9879\u76EE\u5185\u7684\u777F\u620E\u6280\u80FD\u4E0E\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 CLI\u3002",
|
|
8777
|
+
"- \u6BCF\u6B21\u5F00\u5DE5\u5148\u53EA\u8BFB\u6838\u5BF9 CLI \u7248\u672C\u3001\u76EE\u6807\u73AF\u5883\u3001\u8EAB\u4EFD\u3001\u6280\u80FD\u9501\u4E0E `hcm delivery doctor`\uFF1B\u73AF\u5883\u4E8B\u5B9E\u5FC5\u987B\u73B0\u67E5\uFF0C\u4E0D\u51ED\u8BB0\u5FC6\u586B\u5199\u3002",
|
|
8778
|
+
"- R2 \u5199\u64CD\u4F5C\u5FC5\u987B\u4F9D\u6B21\u7ECF\u8FC7 `hcm delivery assess`\u3001`prepare`\u3001`execute`\uFF0C\u88AB\u6267\u884C argv \u5FC5\u987B\u663E\u5F0F\u5E26 `--env` \u4E0E `--as`\u3002",
|
|
8779
|
+
"- `.hcm-delivery/project.yml` \u662F\u6BCF\u4EBA\u6BCF\u673A\u72B6\u6001\uFF0C\u4E0D\u63D0\u4EA4\uFF1B\u53EA\u6709 `\u73AF\u5883.yml` \u4E2D `controlled: true` \u4E14\u8D1F\u8D23\u4EBA\u6279\u51C6\u65F6\uFF0C\u624D\u80FD\u4E34\u65F6\u5207\u6362\u5BF9\u5E94\u73AF\u5883\uFF0C\u5B8C\u6210\u540E\u7ACB\u5373\u56DE\u5230 plan-only\u3002",
|
|
8780
|
+
"- \u53D8\u66F4/\u56DE\u6EDA\u8BF4\u660E\u653E CLI \u56FA\u5B9A\u7684 `work/` \u6216 `decisions/`\uFF0C\u6536\u636E\u653E `evidence/`\uFF1B\u5BA2\u6237\u5171\u4EAB\u6750\u6599\u5206\u522B\u5F52\u6863\u5230\u4E2D\u6587\u4E1A\u52A1\u76EE\u5F55\u3002",
|
|
8781
|
+
"- \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",
|
|
8782
|
+
AGENT_END,
|
|
8783
|
+
""
|
|
8784
|
+
].join("\n");
|
|
8785
|
+
}
|
|
8786
|
+
function renderSetupSh(cliVersion) {
|
|
8787
|
+
return [
|
|
8788
|
+
"#!/usr/bin/env bash",
|
|
8789
|
+
"set -euo pipefail",
|
|
8790
|
+
"",
|
|
8791
|
+
`expected_hcm_version=${JSON.stringify(cliVersion)}`,
|
|
8792
|
+
'actual_hcm_version="$(hcm --version 2>/dev/null || true)"',
|
|
8793
|
+
'if [[ "$actual_hcm_version" != "$expected_hcm_version" ]]; then',
|
|
8794
|
+
` printf '\u9700\u8981 hcm %s\uFF0C\u5F53\u524D\u662F %s\u3002\u5148\u6267\u884C\uFF1Anpm install --global @hcmai/cli@%s\\n' "$expected_hcm_version" "\${actual_hcm_version:-\u672A\u5B89\u88C5}" "$expected_hcm_version" >&2`,
|
|
8795
|
+
" exit 1",
|
|
8796
|
+
"fi",
|
|
8797
|
+
"",
|
|
8798
|
+
"node <<'HCM_PROJECT_SETUP'",
|
|
8799
|
+
"const fs = require('node:fs');",
|
|
8800
|
+
"const path = require('node:path');",
|
|
8801
|
+
"const { spawnSync } = require('node:child_process');",
|
|
8802
|
+
"",
|
|
8803
|
+
"const project = process.cwd();",
|
|
8804
|
+
"const environmentsFile = path.join(project, '\u73AF\u5883.yml');",
|
|
8805
|
+
"const projectFile = path.join(project, '.hcm-delivery', 'project.yml');",
|
|
8806
|
+
"const skillsLock = path.join(project, 'hcm-skills', '.hcm-skills.json');",
|
|
8807
|
+
"const source = fs.readFileSync(environmentsFile, 'utf8');",
|
|
8808
|
+
"const environments = parseEnvironments(source);",
|
|
8809
|
+
"if (environments.length === 0) throw new Error('\u73AF\u5883.yml \u81F3\u5C11\u8981\u6709\u4E00\u4E2A\u73AF\u5883');",
|
|
8810
|
+
"",
|
|
8811
|
+
"const missingEnvironments = new Set();",
|
|
8812
|
+
"for (const environment of environments) {",
|
|
8813
|
+
" const probe = spawnSync('hcm', ['env', 'show', environment.alias], { encoding: 'utf8' });",
|
|
8814
|
+
" if (probe.error) throw new Error(`\u65E0\u6CD5\u68C0\u67E5\u73AF\u5883 ${environment.alias}\uFF1A${probe.error.message}`);",
|
|
8815
|
+
" if (probe.status === 0) {",
|
|
8816
|
+
" const existing = parseExistingEnvironment(probe.stdout, environment.alias);",
|
|
8817
|
+
" assertEnvironmentMatches(environment, existing);",
|
|
8818
|
+
" process.stdout.write(`[setup] env ${environment.alias} \u5DF2\u5B58\u5728\u4E14\u4E0E \u73AF\u5883.yml \u4E00\u81F4\uFF0C\u4FDD\u7559\u672C\u673A\u8EAB\u4EFD\\n`);",
|
|
8819
|
+
" continue;",
|
|
8820
|
+
" }",
|
|
8821
|
+
" if (/\\bENV_NOT_FOUND\\b/.test(probe.stderr)) {",
|
|
8822
|
+
" missingEnvironments.add(environment.alias);",
|
|
8823
|
+
" continue;",
|
|
8824
|
+
" }",
|
|
8825
|
+
" const detail = probe.stderr.trim() || `\u9000\u51FA\u7801 ${probe.status ?? 'unknown'}`;",
|
|
8826
|
+
" throw new Error(`\u65E0\u6CD5\u68C0\u67E5\u73AF\u5883 ${environment.alias}\uFF1A${detail}`);",
|
|
8827
|
+
"}",
|
|
8828
|
+
"",
|
|
8829
|
+
"let projectInitialized = fs.existsSync(projectFile);",
|
|
8830
|
+
"for (const environment of environments) {",
|
|
8831
|
+
" if (missingEnvironments.has(environment.alias)) {",
|
|
8832
|
+
" const add = ['env', 'add', environment.alias, '--endpoint', environment.endpoint];",
|
|
8833
|
+
" if (environment.frontend) add.push('--frontend', environment.frontend);",
|
|
8834
|
+
" if (environment.tenant) add.push('--tenant', environment.tenant);",
|
|
8835
|
+
" run(add);",
|
|
8836
|
+
" }",
|
|
8837
|
+
" if (!projectInitialized) {",
|
|
8838
|
+
" run(['delivery', 'init', '--project', project, '--env', environment.alias, '--mode', 'plan-only']);",
|
|
8839
|
+
" projectInitialized = true;",
|
|
8840
|
+
" } else {",
|
|
8841
|
+
" run(['delivery', 'mode', '--project', project, '--env', environment.alias, '--set', 'plan-only']);",
|
|
8842
|
+
" }",
|
|
8843
|
+
"}",
|
|
8844
|
+
"",
|
|
8845
|
+
"if (!fs.existsSync(skillsLock)) {",
|
|
8846
|
+
" run(['skills', 'install', '--all', '--target', 'codex', '--env', environments[0].alias]);",
|
|
8847
|
+
"} else {",
|
|
8848
|
+
" process.stdout.write('[setup] \u5DF2\u6709 hcm-skills \u9501\uFF0C\u6309\u4ED3\u5E93\u7248\u672C\u4F7F\u7528\uFF1B\u5347\u7EA7\u6280\u80FD\u8BF7\u53E6\u8D70 PR\\n');",
|
|
8849
|
+
"}",
|
|
8850
|
+
'process.stdout.write("[setup] \u5B8C\u6210\u3002\u4E0B\u4E00\u6B65\uFF1A\u9010\u4E2A\u6267\u884C hcm login --env <alias> --code <\u914D\u5BF9\u7801> --name <\u4F60\u7684\u540D\u5B57>-<alias>\\n");',
|
|
8851
|
+
"",
|
|
8852
|
+
"function run(args) {",
|
|
8853
|
+
" const result = spawnSync('hcm', args, { cwd: project, stdio: 'inherit' });",
|
|
8854
|
+
" if (result.error) throw new Error(`\u65E0\u6CD5\u6267\u884C hcm ${args.join(' ')}\uFF1A${result.error.message}`);",
|
|
8855
|
+
" if (result.status !== 0) process.exit(result.status ?? 1);",
|
|
8856
|
+
"}",
|
|
8857
|
+
"",
|
|
8858
|
+
"function parseEnvironments(text) {",
|
|
8859
|
+
" const result = [];",
|
|
8860
|
+
" let current = null;",
|
|
8861
|
+
" let inEnvironments = false;",
|
|
8862
|
+
" for (const [offset, rawLine] of text.split(/\\r?\\n/).entries()) {",
|
|
8863
|
+
" const lineNo = offset + 1;",
|
|
8864
|
+
' if (!rawLine.trim() || rawLine.trimStart().startsWith("#")) continue;',
|
|
8865
|
+
" if (/^schemaVersion:\\s*1\\s*$/.test(rawLine)) continue;",
|
|
8866
|
+
" if (/^environments:\\s*$/.test(rawLine)) { inEnvironments = true; continue; }",
|
|
8867
|
+
" if (!inEnvironments) throw new Error(`\u73AF\u5883.yml \u7B2C ${lineNo} \u884C\u4E0D\u5C5E\u4E8E environments`);",
|
|
8868
|
+
" const first = rawLine.match(/^ {2}- alias:\\s*(.+)$/);",
|
|
8869
|
+
" if (first) {",
|
|
8870
|
+
" if (current) result.push(validateEnvironment(current, lineNo));",
|
|
8871
|
+
" current = { alias: scalar(first[1], lineNo) };",
|
|
8872
|
+
" continue;",
|
|
8873
|
+
" }",
|
|
8874
|
+
" const field = rawLine.match(/^ {4}(endpoint|frontend|tenant|controlled|owner):\\s*(.+)$/);",
|
|
8875
|
+
" if (!field || !current) throw new Error(`\u73AF\u5883.yml \u7B2C ${lineNo} \u884C\u4E0D\u7B26\u5408\u811A\u624B\u67B6\u683C\u5F0F`);",
|
|
8876
|
+
" current[field[1]] = scalar(field[2], lineNo);",
|
|
8877
|
+
" }",
|
|
8878
|
+
" if (current) result.push(validateEnvironment(current, text.split(/\\r?\\n/).length));",
|
|
8879
|
+
" return result;",
|
|
8880
|
+
"}",
|
|
8881
|
+
"",
|
|
8882
|
+
"function scalar(raw, lineNo) {",
|
|
8883
|
+
" const value = raw.trim();",
|
|
8884
|
+
` if (value.startsWith('"')) {`,
|
|
8885
|
+
" try { return JSON.parse(value); } catch { throw new Error(`\u73AF\u5883.yml \u7B2C ${lineNo} \u884C\u7684\u53CC\u5F15\u53F7\u503C\u975E\u6CD5`); }",
|
|
8886
|
+
" }",
|
|
8887
|
+
` if (value.startsWith("'") && value.endsWith("'")) return value.slice(1, -1).replace(/''/g, "'");`,
|
|
8888
|
+
' const plain = value.replace(/\\s+#.*$/, "").trim();',
|
|
8889
|
+
' if (plain === "true") return true;',
|
|
8890
|
+
' if (plain === "false") return false;',
|
|
8891
|
+
" return plain;",
|
|
8892
|
+
"}",
|
|
8893
|
+
"",
|
|
8894
|
+
"function validateEnvironment(environment, lineNo) {",
|
|
8895
|
+
' for (const key of ["alias", "endpoint"]) {',
|
|
8896
|
+
' if (typeof environment[key] !== "string" || !environment[key].trim()) {',
|
|
8897
|
+
" throw new Error(`\u73AF\u5883.yml \u622A\u81F3\u7B2C ${lineNo} \u884C\u7F3A\u5C11 ${key}`);",
|
|
8898
|
+
" }",
|
|
8899
|
+
" }",
|
|
8900
|
+
' if (environment.endpoint === "REPLACE_ME") {',
|
|
8901
|
+
" throw new Error(`\u73AF\u5883 ${environment.alias} \u7684 endpoint \u4ECD\u662F REPLACE_ME\uFF0C\u8BF7\u5148\u7F16\u8F91 \u73AF\u5883.yml`);",
|
|
8902
|
+
" }",
|
|
8903
|
+
" if (environment.controlled !== true && environment.controlled !== false) {",
|
|
8904
|
+
" throw new Error(`\u73AF\u5883 ${environment.alias} \u7684 controlled \u5FC5\u987B\u662F true \u6216 false`);",
|
|
8905
|
+
" }",
|
|
8906
|
+
' for (const key of ["frontend", "tenant"]) {',
|
|
8907
|
+
' if (environment[key] !== undefined && typeof environment[key] !== "string") {',
|
|
8908
|
+
" environment[key] = String(environment[key]);",
|
|
8909
|
+
" }",
|
|
8910
|
+
" }",
|
|
8911
|
+
" return environment;",
|
|
8912
|
+
"}",
|
|
8913
|
+
"",
|
|
8914
|
+
"function parseExistingEnvironment(text, alias) {",
|
|
8915
|
+
" const result = {};",
|
|
8916
|
+
" for (const [offset, rawLine] of text.split(/\\r?\\n/).entries()) {",
|
|
8917
|
+
' if (!rawLine.trim() || rawLine.startsWith(" ") || rawLine.trimStart().startsWith("#")) continue;',
|
|
8918
|
+
" const field = rawLine.match(/^(endpoint|frontend|tenantId):\\s*(.+)$/);",
|
|
8919
|
+
" if (field) result[field[1]] = scalar(field[2], offset + 1);",
|
|
8920
|
+
" }",
|
|
8921
|
+
' if (typeof result.endpoint !== "string" || !result.endpoint) {',
|
|
8922
|
+
" throw new Error(`hcm env show ${alias} \u672A\u8FD4\u56DE\u6709\u6548 endpoint\uFF0C\u62D2\u7EDD\u7EE7\u7EED`);",
|
|
8923
|
+
" }",
|
|
8924
|
+
" return result;",
|
|
8925
|
+
"}",
|
|
8926
|
+
"",
|
|
8927
|
+
"function assertEnvironmentMatches(expected, actual) {",
|
|
8928
|
+
" const fields = [",
|
|
8929
|
+
' ["endpoint", expected.endpoint, actual.endpoint],',
|
|
8930
|
+
' ["frontend", expected.frontend ?? "", actual.frontend ?? ""],',
|
|
8931
|
+
' ["tenant", expected.tenant ?? "1", actual.tenantId ?? "1"],',
|
|
8932
|
+
" ];",
|
|
8933
|
+
" const mismatches = fields",
|
|
8934
|
+
" .filter(([, wanted, found]) => String(wanted) !== String(found))",
|
|
8935
|
+
" .map(([name, wanted, found]) => `${name}: \u9879\u76EE=${JSON.stringify(wanted)} \u672C\u673A=${JSON.stringify(found)}`);",
|
|
8936
|
+
" if (mismatches.length === 0) return;",
|
|
8937
|
+
" throw new Error(",
|
|
8938
|
+
' `\u73AF\u5883 ${expected.alias} \u5DF2\u5B58\u5728\uFF0C\u4F46\u672C\u673A\u914D\u7F6E\u4E0E \u73AF\u5883.yml \u4E0D\u4E00\u81F4\uFF1A${mismatches.join("\uFF1B")}\u3002` +',
|
|
8939
|
+
' "\u4E3A\u4FDD\u62A4\u672C\u673A\u5DF2\u6709\u8EAB\u4EFD\uFF0Csetup.sh \u4E0D\u4F1A\u7528 --force \u8986\u76D6\uFF1B\u8BF7\u6838\u5BF9\u540E\u663E\u5F0F\u4FEE\u6B63\u672C\u673A\u73AF\u5883\u6216 \u73AF\u5883.yml\u3002",',
|
|
8940
|
+
" );",
|
|
8941
|
+
"}",
|
|
8942
|
+
"HCM_PROJECT_SETUP",
|
|
8943
|
+
""
|
|
8944
|
+
].join("\n");
|
|
8945
|
+
}
|
|
8946
|
+
function mergeDeliveryGitignore(existing) {
|
|
8947
|
+
const block = [
|
|
8948
|
+
GITIGNORE_BEGIN,
|
|
8949
|
+
".hcm-delivery/project.yml",
|
|
8950
|
+
".hcm-delivery/execution-plans/",
|
|
8951
|
+
".hcm-delivery/execution-claims/",
|
|
8952
|
+
GITIGNORE_END
|
|
8953
|
+
].join("\n");
|
|
8954
|
+
return upsertBlock(existing, GITIGNORE_BEGIN, GITIGNORE_END, block);
|
|
8955
|
+
}
|
|
8956
|
+
function mergeAgentInstructions(existing) {
|
|
8957
|
+
return upsertBlock(
|
|
8958
|
+
existing,
|
|
8959
|
+
AGENT_BEGIN,
|
|
8960
|
+
AGENT_END,
|
|
8961
|
+
renderAgentInstructions().trimEnd()
|
|
8962
|
+
);
|
|
8963
|
+
}
|
|
8964
|
+
async function scaffoldDeliveryProject(root, options) {
|
|
8965
|
+
const result = { created: [], updated: [], preserved: [] };
|
|
8966
|
+
for (const directory of DELIVERY_PROJECT_DIRECTORIES) {
|
|
8967
|
+
const absolute = path6.join(root, directory);
|
|
8968
|
+
await ensureDirectory(absolute);
|
|
8969
|
+
await writeIfAbsent(path6.join(absolute, ".gitkeep"), "", result, `${directory}/.gitkeep`);
|
|
8970
|
+
}
|
|
8971
|
+
await writeIfAbsent(
|
|
8972
|
+
path6.join(root, "\u73AF\u5883.yml"),
|
|
8973
|
+
renderEnvironmentYml(options.environment, options.environmentConfig, options.initialMode),
|
|
8974
|
+
result,
|
|
8975
|
+
"\u73AF\u5883.yml"
|
|
8976
|
+
);
|
|
8977
|
+
const setupFile = path6.join(root, "setup.sh");
|
|
8978
|
+
const setupCreated = await writeIfAbsent(
|
|
8979
|
+
setupFile,
|
|
8980
|
+
renderSetupSh(options.cliVersion),
|
|
8981
|
+
result,
|
|
8982
|
+
"setup.sh",
|
|
8983
|
+
493
|
|
8984
|
+
);
|
|
8985
|
+
if (setupCreated) await fs6.chmod(setupFile, 493);
|
|
8986
|
+
await mergeManagedFile(path6.join(root, "AGENTS.md"), mergeAgentInstructions, result, "AGENTS.md");
|
|
8987
|
+
await mergeManagedFile(path6.join(root, "CLAUDE.md"), mergeAgentInstructions, result, "CLAUDE.md");
|
|
8988
|
+
await mergeManagedFile(path6.join(root, ".gitignore"), mergeDeliveryGitignore, result, ".gitignore");
|
|
8989
|
+
return result;
|
|
8990
|
+
}
|
|
8991
|
+
async function mergeManagedFile(file, merge, result, relative2) {
|
|
8992
|
+
const existing = await readRegularFile(file);
|
|
8993
|
+
const next = merge(existing ?? "");
|
|
8994
|
+
if (existing === next) {
|
|
8995
|
+
result.preserved.push(relative2);
|
|
8996
|
+
return;
|
|
8997
|
+
}
|
|
8998
|
+
await fs6.writeFile(file, next, { encoding: "utf8", mode: 420 });
|
|
8999
|
+
(existing === null ? result.created : result.updated).push(relative2);
|
|
9000
|
+
}
|
|
9001
|
+
async function writeIfAbsent(file, content, result, relative2, mode = 420) {
|
|
9002
|
+
try {
|
|
9003
|
+
await fs6.writeFile(file, content, { encoding: "utf8", mode, flag: "wx" });
|
|
9004
|
+
result.created.push(relative2);
|
|
9005
|
+
return true;
|
|
9006
|
+
} catch (cause) {
|
|
9007
|
+
if (cause.code !== "EEXIST") throw cause;
|
|
9008
|
+
await assertRegularFile(file);
|
|
9009
|
+
result.preserved.push(relative2);
|
|
9010
|
+
return false;
|
|
9011
|
+
}
|
|
9012
|
+
}
|
|
9013
|
+
async function ensureDirectory(directory) {
|
|
9014
|
+
await fs6.mkdir(directory, { recursive: true });
|
|
9015
|
+
const stat = await fs6.lstat(directory);
|
|
9016
|
+
if (!stat.isDirectory() || stat.isSymbolicLink()) {
|
|
9017
|
+
throw new Error(`\u811A\u624B\u67B6\u8DEF\u5F84\u4E0D\u662F\u666E\u901A\u76EE\u5F55\uFF1A${directory}`);
|
|
9018
|
+
}
|
|
9019
|
+
}
|
|
9020
|
+
async function readRegularFile(file) {
|
|
9021
|
+
try {
|
|
9022
|
+
await assertRegularFile(file);
|
|
9023
|
+
return await fs6.readFile(file, "utf8");
|
|
9024
|
+
} catch (cause) {
|
|
9025
|
+
if (cause.code === "ENOENT") return null;
|
|
9026
|
+
throw cause;
|
|
9027
|
+
}
|
|
9028
|
+
}
|
|
9029
|
+
async function assertRegularFile(file) {
|
|
9030
|
+
const stat = await fs6.lstat(file);
|
|
9031
|
+
if (!stat.isFile() || stat.isSymbolicLink()) {
|
|
9032
|
+
throw new Error(`\u811A\u624B\u67B6\u8DEF\u5F84\u4E0D\u662F\u666E\u901A\u6587\u4EF6\uFF1A${file}`);
|
|
9033
|
+
}
|
|
9034
|
+
}
|
|
9035
|
+
function upsertBlock(existing, begin, end, block) {
|
|
9036
|
+
const start = existing.indexOf(begin);
|
|
9037
|
+
const finish = existing.indexOf(end);
|
|
9038
|
+
const markersAreMalformed = start < 0 !== finish < 0 || start >= 0 && (finish < start || existing.lastIndexOf(begin) !== start || existing.lastIndexOf(end) !== finish);
|
|
9039
|
+
if (markersAreMalformed) {
|
|
9040
|
+
throw new Error(`\u6258\u7BA1\u5757\u6807\u8BB0\u635F\u574F\u6216\u91CD\u590D\uFF0C\u62D2\u7EDD\u8986\u76D6\uFF1A${begin} \u2026 ${end}`);
|
|
9041
|
+
}
|
|
9042
|
+
let next;
|
|
9043
|
+
if (start >= 0 && finish >= start) {
|
|
9044
|
+
next = `${existing.slice(0, start)}${block}${existing.slice(finish + end.length)}`;
|
|
9045
|
+
} else {
|
|
9046
|
+
const prefix = existing.trimEnd();
|
|
9047
|
+
next = `${prefix}${prefix ? "\n\n" : ""}${block}`;
|
|
9048
|
+
}
|
|
9049
|
+
return `${next.trimEnd()}
|
|
9050
|
+
`;
|
|
9051
|
+
}
|
|
9052
|
+
|
|
9053
|
+
// src/commands/delivery-init.ts
|
|
9054
|
+
function renderProjectYml(environment, mode) {
|
|
8544
9055
|
return [
|
|
8545
9056
|
"# HCM \u987E\u95EE\u4EA4\u4ED8\u9879\u76EE\u914D\u7F6E\uFF08hcm delivery init \u751F\u6210\uFF09",
|
|
8546
9057
|
"#",
|
|
8547
|
-
"# deliveryMode \u51B3\u5B9A\
|
|
9058
|
+
"# deliveryMode \u6309\u76EE\u6807\u73AF\u5883\u51B3\u5B9A\u672C\u673A\u5141\u8BB8\u8D70\u5230\u54EA\u4E00\u6B65\uFF1A",
|
|
8548
9059
|
"# plan-only \u2014\u2014 \u53EA\u5141\u8BB8 assess / prepare \u51FA\u8BA1\u5212\uFF0Cexecute \u4E00\u5F8B\u62D2\u7EDD",
|
|
8549
9060
|
"# controlled \u2014\u2014 \u5141\u8BB8 prepare + execute \u5355\u6B21\u53D7\u63A7\u6267\u884C\uFF08\u4ECD\u9700\u9010\u6B21\u6279\u51C6\uFF09",
|
|
8550
9061
|
"#",
|
|
8551
9062
|
"# \u{1F534} \u5B83\u4E0D\u653E\u5BBD\u4EFB\u4F55\u98CE\u9669\u5224\u7EA7\uFF1AR3 \u5728\u4E24\u79CD\u6A21\u5F0F\u4E0B\u90FD\u62D2\u7EDD\uFF0CR2 \u4ECD\u8981\u8BA1\u5212\u3001\u56DE\u6EDA\u8BF4\u660E\u4E0E\u6536\u636E\u3002",
|
|
8552
|
-
"# \u6539\
|
|
8553
|
-
|
|
9063
|
+
"# \u6539\u4E00\u4E2A\u73AF\u5883\u53EA\u5F71\u54CD\u8BE5\u73AF\u5883\uFF1B\u672A\u767B\u8BB0\u7684\u73AF\u5883 fail-closed\uFF0C\u4E0D\u7EE7\u627F\u5176\u5B83\u73AF\u5883\u7684 controlled\u3002",
|
|
9064
|
+
"schemaVersion: 2",
|
|
9065
|
+
"deliveryMode:",
|
|
9066
|
+
` ${JSON.stringify(environment)}: ${mode}`,
|
|
8554
9067
|
""
|
|
8555
9068
|
].join("\n");
|
|
8556
9069
|
}
|
|
8557
9070
|
async function deliveryInitCommand(args) {
|
|
8558
9071
|
try {
|
|
8559
|
-
const mode = args.mode ?? "
|
|
8560
|
-
if (!
|
|
9072
|
+
const mode = args.mode ?? "plan-only";
|
|
9073
|
+
if (!DELIVERY_MODES.includes(mode)) {
|
|
8561
9074
|
throw new Error(
|
|
8562
|
-
`--mode \u53EA\u63A5\u53D7 ${
|
|
9075
|
+
`--mode \u53EA\u63A5\u53D7 ${DELIVERY_MODES.join(" | ")}\uFF0C\u6536\u5230 "${args.mode}"
|
|
8563
9076
|
\u8FD9\u4E24\u4E2A\u503C\u662F delivery prepare \u8BA4\u5F97\u7684\u5168\u90E8\uFF1B\u5199\u522B\u7684\u503C prepare \u4F1A\u62D2\u7EDD\u52A0\u8F7D\u3002`
|
|
8564
9077
|
);
|
|
8565
9078
|
}
|
|
8566
|
-
const
|
|
8567
|
-
const
|
|
8568
|
-
const
|
|
9079
|
+
const environment = await resolveDeliveryEnvironment(args.env);
|
|
9080
|
+
const root = path7.resolve(args.project ?? ".");
|
|
9081
|
+
const dir = path7.join(root, ".hcm-delivery");
|
|
9082
|
+
const file = path7.join(dir, "project.yml");
|
|
8569
9083
|
let existed = false;
|
|
8570
9084
|
try {
|
|
8571
|
-
await
|
|
9085
|
+
await fs7.access(file);
|
|
8572
9086
|
existed = true;
|
|
8573
9087
|
} catch {
|
|
8574
9088
|
existed = false;
|
|
@@ -8580,20 +9094,22 @@ async function deliveryInitCommand(args) {
|
|
|
8580
9094
|
\u786E\u8981\u91CD\u5199\uFF1Ahcm delivery init --force`
|
|
8581
9095
|
);
|
|
8582
9096
|
}
|
|
8583
|
-
await
|
|
8584
|
-
await
|
|
8585
|
-
const
|
|
8586
|
-
|
|
8587
|
-
|
|
8588
|
-
|
|
8589
|
-
|
|
8590
|
-
|
|
9097
|
+
await fs7.mkdir(dir, { recursive: true });
|
|
9098
|
+
await fs7.writeFile(file, renderProjectYml(environment, mode), "utf8");
|
|
9099
|
+
const environmentConfig = await loadEnv9(environment).catch(() => null);
|
|
9100
|
+
const scaffold = await scaffoldDeliveryProject(root, {
|
|
9101
|
+
environment,
|
|
9102
|
+
environmentConfig,
|
|
9103
|
+
initialMode: mode,
|
|
9104
|
+
cliVersion: CLI_VERSION
|
|
9105
|
+
});
|
|
8591
9106
|
const result = {
|
|
8592
9107
|
project: root,
|
|
8593
9108
|
projectFile: file,
|
|
9109
|
+
environment,
|
|
8594
9110
|
deliveryMode: mode,
|
|
8595
9111
|
overwritten: existed,
|
|
8596
|
-
scaffold
|
|
9112
|
+
scaffold,
|
|
8597
9113
|
nextStep: mode === "controlled" ? "hcm delivery assess <\u547D\u4EE4>\uFF1BR2 \u518D hcm delivery prepare --change-ref \u2026 --rollback-ref \u2026 --evidence-dir \u2026" : "hcm delivery assess <\u547D\u4EE4>\uFF1B\u672C\u9879\u76EE\u4E3A plan-only\uFF0Cexecute \u4F1A\u88AB\u62D2\u7EDD"
|
|
8598
9114
|
};
|
|
8599
9115
|
process.stdout.write(formatObject21(result, { format: args.output ?? "json" }) + "\n");
|
|
@@ -8605,31 +9121,31 @@ async function deliveryInitCommand(args) {
|
|
|
8605
9121
|
}
|
|
8606
9122
|
async function deliveryModeCommand(args) {
|
|
8607
9123
|
try {
|
|
8608
|
-
const
|
|
8609
|
-
const
|
|
9124
|
+
const environment = await resolveDeliveryEnvironment(args.env);
|
|
9125
|
+
const root = path7.resolve(args.project ?? ".");
|
|
9126
|
+
const file = path7.join(root, ".hcm-delivery", "project.yml");
|
|
8610
9127
|
let content;
|
|
8611
9128
|
try {
|
|
8612
|
-
content = await
|
|
9129
|
+
content = await fs7.readFile(file, "utf8");
|
|
8613
9130
|
} catch {
|
|
8614
9131
|
throw new Error(
|
|
8615
9132
|
`\u9879\u76EE\u672A\u521D\u59CB\u5316\uFF1A\u627E\u4E0D\u5230 ${file}
|
|
8616
9133
|
\u4E0B\u4E00\u6B65\uFF1Ahcm delivery init`
|
|
8617
9134
|
);
|
|
8618
9135
|
}
|
|
8619
|
-
const read = () => content.match(
|
|
8620
|
-
/^deliveryMode:\s*(?:"(plan-only|controlled)"|'(plan-only|controlled)'|(plan-only|controlled))\s*$/m
|
|
8621
|
-
);
|
|
8622
9136
|
if (!args.set) {
|
|
8623
|
-
const
|
|
8624
|
-
const current = m2?.[1] ?? m2?.[2] ?? m2?.[3] ?? null;
|
|
9137
|
+
const current = deliveryModeForEnvironment(content, environment);
|
|
8625
9138
|
process.stdout.write(
|
|
8626
9139
|
formatObject21(
|
|
8627
9140
|
{
|
|
8628
9141
|
project: root,
|
|
8629
9142
|
projectFile: file,
|
|
9143
|
+
environment,
|
|
8630
9144
|
deliveryMode: current,
|
|
8631
9145
|
canExecuteR2: current === "controlled",
|
|
8632
|
-
...current === "plan-only" ? { note: "plan-only \u53EA\u51FA\u8BA1\u5212\u4E0D\u6267\u884C\uFF1Bexecute \u4F1A\u62D2\u7EDD R2 \u8BA1\u5212" } : {
|
|
9146
|
+
...current === "plan-only" ? { note: "plan-only \u53EA\u51FA\u8BA1\u5212\u4E0D\u6267\u884C\uFF1Bexecute \u4F1A\u62D2\u7EDD R2 \u8BA1\u5212" } : current === null ? {
|
|
9147
|
+
note: `\u73AF\u5883 ${environment} \u5C1A\u672A\u767B\u8BB0\u4EA4\u4ED8\u6A21\u5F0F\uFF1Bfail-closed\u3002\u5148\u6267\u884C hcm delivery mode --env ${environment} --set plan-only`
|
|
9148
|
+
} : {}
|
|
8633
9149
|
},
|
|
8634
9150
|
{ format: args.output ?? "json" }
|
|
8635
9151
|
) + "\n"
|
|
@@ -8637,27 +9153,21 @@ async function deliveryModeCommand(args) {
|
|
|
8637
9153
|
process.exit(0);
|
|
8638
9154
|
}
|
|
8639
9155
|
const next = args.set;
|
|
8640
|
-
if (!
|
|
8641
|
-
throw new Error(`--set \u53EA\u63A5\u53D7 ${
|
|
9156
|
+
if (!DELIVERY_MODES.includes(next)) {
|
|
9157
|
+
throw new Error(`--set \u53EA\u63A5\u53D7 ${DELIVERY_MODES.join(" | ")}\uFF0C\u6536\u5230 "${args.set}"`);
|
|
8642
9158
|
}
|
|
8643
|
-
const
|
|
8644
|
-
|
|
8645
|
-
throw new Error(
|
|
8646
|
-
`${file} \u91CC\u6CA1\u6709\u5408\u6CD5\u7684 deliveryMode \u884C\uFF0C\u4E0D\u5C31\u5730\u6539\u5199\u4EE5\u514D\u7834\u574F\u914D\u7F6E
|
|
8647
|
-
\u4E0B\u4E00\u6B65\uFF1A\u786E\u8BA4\u6587\u4EF6\u5185\u5BB9\uFF0C\u6216 hcm delivery init --force \u91CD\u65B0\u751F\u6210`
|
|
8648
|
-
);
|
|
8649
|
-
}
|
|
8650
|
-
const before = m[1] ?? m[2] ?? m[3];
|
|
8651
|
-
content = content.replace(m[0], `deliveryMode: ${next}`);
|
|
8652
|
-
await fs6.writeFile(file, content, "utf8");
|
|
9159
|
+
const update = setDeliveryModeForEnvironment(content, environment, next);
|
|
9160
|
+
await fs7.writeFile(file, update.content, "utf8");
|
|
8653
9161
|
process.stdout.write(
|
|
8654
9162
|
formatObject21(
|
|
8655
9163
|
{
|
|
8656
9164
|
project: root,
|
|
8657
9165
|
projectFile: file,
|
|
9166
|
+
environment,
|
|
8658
9167
|
deliveryMode: next,
|
|
8659
|
-
previous:
|
|
8660
|
-
canExecuteR2: next === "controlled"
|
|
9168
|
+
previous: update.previous,
|
|
9169
|
+
canExecuteR2: next === "controlled",
|
|
9170
|
+
migratedLegacy: update.migratedLegacy
|
|
8661
9171
|
},
|
|
8662
9172
|
{ format: args.output ?? "json" }
|
|
8663
9173
|
) + "\n"
|
|
@@ -8668,6 +9178,12 @@ async function deliveryModeCommand(args) {
|
|
|
8668
9178
|
process.exit(1);
|
|
8669
9179
|
}
|
|
8670
9180
|
}
|
|
9181
|
+
async function resolveDeliveryEnvironment(envFlag) {
|
|
9182
|
+
const global = await loadGlobalConfig9();
|
|
9183
|
+
const environment = resolveActiveEnv5({ envFlag }, process.env, global);
|
|
9184
|
+
if (!environment.trim()) throw new Error("\u65E0\u6CD5\u89E3\u6790\u76EE\u6807\u73AF\u5883\uFF1B\u8BF7\u4F20 --env <\u73AF\u5883\u522B\u540D>");
|
|
9185
|
+
return environment;
|
|
9186
|
+
}
|
|
8671
9187
|
|
|
8672
9188
|
// src/commands/delivery-doctor.ts
|
|
8673
9189
|
init_auth_guard();
|
|
@@ -8776,9 +9292,9 @@ import {
|
|
|
8776
9292
|
loadProtocolFacts,
|
|
8777
9293
|
scan
|
|
8778
9294
|
} from "@hcmai/sdk";
|
|
8779
|
-
import * as
|
|
9295
|
+
import * as path8 from "path";
|
|
8780
9296
|
function renderGate0(result, skillRoot) {
|
|
8781
|
-
const where = skillRoot ? `\uFF08${
|
|
9297
|
+
const where = skillRoot ? `\uFF08${path8.resolve(skillRoot)}\uFF09` : "";
|
|
8782
9298
|
const lines = [
|
|
8783
9299
|
`\u626B\u63CF\u9762${where}\uFF1A${result.scanned.length} \u4E2A\u6587\u4EF6\uFF1B\u5224\u7EA2 ${result.red.length} \u6761\uFF1B\u7F3A\u53E3\u653E\u884C ${result.gaps.length} \u6761\u3002`
|
|
8784
9300
|
];
|
|
@@ -8890,7 +9406,7 @@ import {
|
|
|
8890
9406
|
writeRisk
|
|
8891
9407
|
} from "@hcmai/sdk";
|
|
8892
9408
|
import { existsSync as existsSync3 } from "fs";
|
|
8893
|
-
import * as
|
|
9409
|
+
import * as path9 from "path";
|
|
8894
9410
|
function premise(message, hint = "") {
|
|
8895
9411
|
process.stderr.write(message + (hint ? `
|
|
8896
9412
|
\u2192 ${hint}` : "") + "\n");
|
|
@@ -8917,13 +9433,13 @@ async function runSeedPlan(args, client3) {
|
|
|
8917
9433
|
const reconDir = candidates[0].reconDir;
|
|
8918
9434
|
if (candidates.length > 1) {
|
|
8919
9435
|
process.stderr.write(
|
|
8920
|
-
`\u26A0\uFE0F \u540C\u79DF\u6237\u4E0B\u6709 ${candidates.length} \u4EFD\u57FA\u7EBF\uFF0C\u672C\u8F6E\u8BFB\u7684\u662F \`${
|
|
9436
|
+
`\u26A0\uFE0F \u540C\u79DF\u6237\u4E0B\u6709 ${candidates.length} \u4EFD\u57FA\u7EBF\uFF0C\u672C\u8F6E\u8BFB\u7684\u662F \`${path9.basename(reconDir)}\`\uFF1A` + candidates.slice(1).map((c) => `\`${path9.basename(c.reconDir)}\``).join("\u3001") + " \u672A\u88AB\u8BFB\u53D6 \u2014\u2014 \u4E0D\u540C sourceKey \u7684\u4EA7\u7269**\u4E0D\u53EF\u4E92\u6362**\u3002\n"
|
|
8921
9437
|
);
|
|
8922
9438
|
}
|
|
8923
9439
|
const round = inspectRound3(reconDir);
|
|
8924
9440
|
process.stderr.write(roundWarning(round));
|
|
8925
9441
|
const baseline = {
|
|
8926
|
-
path: `${
|
|
9442
|
+
path: `${path9.basename(path9.dirname(reconDir))}/${path9.basename(reconDir)}`,
|
|
8927
9443
|
roundId: round.roundId ?? null
|
|
8928
9444
|
};
|
|
8929
9445
|
let exemptions = null;
|
|
@@ -9185,7 +9701,7 @@ async function deliverySeedVerifyCommand(args) {
|
|
|
9185
9701
|
// src/commands/delivery-seed-find.ts
|
|
9186
9702
|
import { existsSync as existsSync4 } from "fs";
|
|
9187
9703
|
import { readFileSync as readFileSync6 } from "fs";
|
|
9188
|
-
import * as
|
|
9704
|
+
import * as path10 from "path";
|
|
9189
9705
|
import {
|
|
9190
9706
|
INIT_EXIT_CODES as INIT_EXIT_CODES2,
|
|
9191
9707
|
ValueHints,
|
|
@@ -9199,10 +9715,10 @@ import {
|
|
|
9199
9715
|
valuesRoundCaveat
|
|
9200
9716
|
} from "@hcmai/sdk";
|
|
9201
9717
|
function provenance(chosenReconDir, others) {
|
|
9202
|
-
let line = `> \u57FA\u7EBF\uFF1A\`${
|
|
9718
|
+
let line = `> \u57FA\u7EBF\uFF1A\`${path10.basename(chosenReconDir)}\`
|
|
9203
9719
|
`;
|
|
9204
9720
|
if (others.length > 0) {
|
|
9205
|
-
line += `> \u26A0\uFE0F \u540C\u79DF\u6237\u4E0B\u53E6\u6709 ${others.length} \u4EFD\u57FA\u7EBF\u672A\u88AB\u8BFB\u53D6\uFF1A` + others.map((o) => `\`${
|
|
9721
|
+
line += `> \u26A0\uFE0F \u540C\u79DF\u6237\u4E0B\u53E6\u6709 ${others.length} \u4EFD\u57FA\u7EBF\u672A\u88AB\u8BFB\u53D6\uFF1A` + others.map((o) => `\`${path10.basename(o)}\``).join("\u3001") + " \u2014\u2014 \u4E0D\u540C sourceKey \u7684\u4EA7\u7269**\u4E0D\u53EF\u4E92\u6362**\u3002\n";
|
|
9206
9722
|
}
|
|
9207
9723
|
return `${line}
|
|
9208
9724
|
`;
|
|
@@ -9539,7 +10055,7 @@ import {
|
|
|
9539
10055
|
runTriageRound
|
|
9540
10056
|
} from "@hcmai/sdk";
|
|
9541
10057
|
import { mkdirSync, readFileSync as readFileSync8, writeFileSync as writeFileSync2 } from "fs";
|
|
9542
|
-
import * as
|
|
10058
|
+
import * as path11 from "path";
|
|
9543
10059
|
var DEFAULT_CAPABILITIES4 = "default";
|
|
9544
10060
|
function premise4(message, hint) {
|
|
9545
10061
|
process.stderr.write(`\u{1F534} \u524D\u63D0\u4E0D\u6210\u7ACB\uFF1A${message}
|
|
@@ -9575,8 +10091,8 @@ function renderProblems(rows) {
|
|
|
9575
10091
|
`;
|
|
9576
10092
|
}
|
|
9577
10093
|
function writeTriageArtifact(outDir, body) {
|
|
9578
|
-
const out =
|
|
9579
|
-
mkdirSync(
|
|
10094
|
+
const out = path11.join(outDir, "work", "triage.md");
|
|
10095
|
+
mkdirSync(path11.dirname(out), { recursive: true });
|
|
9580
10096
|
writeFileSync2(out, body, "utf8");
|
|
9581
10097
|
return out;
|
|
9582
10098
|
}
|
|
@@ -9616,21 +10132,23 @@ async function deliveryTriageCommand(args) {
|
|
|
9616
10132
|
// src/commands/delivery-execution.ts
|
|
9617
10133
|
import { createHash as createHash5, randomBytes as secureRandomBytes } from "crypto";
|
|
9618
10134
|
import { spawn as spawn2 } from "child_process";
|
|
9619
|
-
import { createReadStream, promises as
|
|
9620
|
-
import
|
|
10135
|
+
import { createReadStream, promises as fs8 } from "fs";
|
|
10136
|
+
import path12 from "path";
|
|
9621
10137
|
import { CliError as CliError21, CliErrorCode as CliErrorCode20, formatObject as formatObject25 } from "@hcmai/sdk";
|
|
9622
10138
|
init_exit();
|
|
9623
|
-
var EXECUTION_CONTRACT_VERSION = "2026-
|
|
10139
|
+
var EXECUTION_CONTRACT_VERSION = "2026-09-03.controlled-v4";
|
|
9624
10140
|
var DEFAULT_TTL_SECONDS = 15 * 60;
|
|
9625
10141
|
var MIN_TTL_SECONDS = 60;
|
|
9626
10142
|
var MAX_TTL_SECONDS = 60 * 60;
|
|
9627
10143
|
var PLAN_ID_PATTERN = /^[a-f0-9]{24}$/;
|
|
9628
10144
|
async function prepareDeliveryExecution(input) {
|
|
9629
10145
|
const project = await realProject(input.project);
|
|
9630
|
-
await readProjectMode(project);
|
|
9631
10146
|
const argv = normalizeCommandArgv(input.argv);
|
|
9632
10147
|
const assessment = await (input.assessCommand ?? assessEffectiveDeliveryCommand)(argv);
|
|
9633
10148
|
assertGuardedAssessment(assessment, argv);
|
|
10149
|
+
const environment = assessment.environment.envAlias;
|
|
10150
|
+
if (!environment) throw invalid2("R2 argv \u5FC5\u987B\u663E\u5F0F\u5305\u542B --env \u73AF\u5883\u522B\u540D");
|
|
10151
|
+
await readProjectMode(project, environment);
|
|
9634
10152
|
const ttlSeconds = input.ttlSeconds ?? DEFAULT_TTL_SECONDS;
|
|
9635
10153
|
if (!Number.isInteger(ttlSeconds) || ttlSeconds < MIN_TTL_SECONDS || ttlSeconds > MAX_TTL_SECONDS) {
|
|
9636
10154
|
throw invalid2(`--ttl-seconds \u5FC5\u987B\u662F ${MIN_TTL_SECONDS} \u5230 ${MAX_TTL_SECONDS} \u7684\u6574\u6570`);
|
|
@@ -9658,11 +10176,11 @@ async function prepareDeliveryExecution(input) {
|
|
|
9658
10176
|
};
|
|
9659
10177
|
const planId = sha2565(canonicalJson(core)).slice(0, 24);
|
|
9660
10178
|
const plan = { ...core, planId };
|
|
9661
|
-
const plansDir =
|
|
10179
|
+
const plansDir = path12.join(project, ".hcm-delivery", "execution-plans");
|
|
9662
10180
|
await safeManagedDirectory(project, ".hcm-delivery/execution-plans", plansDir);
|
|
9663
|
-
const planFile =
|
|
10181
|
+
const planFile = path12.join(plansDir, `${planId}.json`);
|
|
9664
10182
|
try {
|
|
9665
|
-
await
|
|
10183
|
+
await fs8.writeFile(planFile, `${JSON.stringify(plan, null, 2)}
|
|
9666
10184
|
`, {
|
|
9667
10185
|
encoding: "utf8",
|
|
9668
10186
|
mode: 384,
|
|
@@ -9676,14 +10194,16 @@ async function prepareDeliveryExecution(input) {
|
|
|
9676
10194
|
async function executeDeliveryPlan(input) {
|
|
9677
10195
|
if (!PLAN_ID_PATTERN.test(input.planId)) throw invalid2("planId \u5FC5\u987B\u662F 24 \u4F4D\u5C0F\u5199\u5341\u516D\u8FDB\u5236");
|
|
9678
10196
|
const project = await realProject(input.project);
|
|
9679
|
-
|
|
9680
|
-
throw invalid2("\u9879\u76EE\u4E0D\u662F controlled\uFF0C\u4E0D\u80FD\u6267\u884C R2 \u8BA1\u5212");
|
|
9681
|
-
}
|
|
9682
|
-
const planFile = path11.join(project, ".hcm-delivery", "execution-plans", `${input.planId}.json`);
|
|
10197
|
+
const planFile = path12.join(project, ".hcm-delivery", "execution-plans", `${input.planId}.json`);
|
|
9683
10198
|
const plan = await readPlan(project, planFile);
|
|
9684
10199
|
if (plan.planId !== input.planId || computePlanId(plan) !== input.planId) {
|
|
9685
10200
|
throw invalid2("\u6267\u884C\u8BA1\u5212\u5185\u5BB9\u4E0E planId \u6458\u8981\u4E0D\u4E00\u81F4");
|
|
9686
10201
|
}
|
|
10202
|
+
const environment = plan.assessment.environment.envAlias;
|
|
10203
|
+
if (!environment) throw invalid2("\u6267\u884C\u8BA1\u5212\u7F3A\u5C11\u76EE\u6807\u73AF\u5883");
|
|
10204
|
+
if (await readProjectMode(project, environment) !== "controlled") {
|
|
10205
|
+
throw invalid2(`\u73AF\u5883 ${environment} \u4E0D\u662F controlled\uFF0C\u4E0D\u80FD\u6267\u884C R2 \u8BA1\u5212`);
|
|
10206
|
+
}
|
|
9687
10207
|
const now = (input.now ?? (() => /* @__PURE__ */ new Date()))();
|
|
9688
10208
|
if (Number.isNaN(now.getTime())) throw invalid2("\u5F53\u524D\u65F6\u95F4\u65E0\u6548");
|
|
9689
10209
|
const expiresAt = Date.parse(plan.expiresAt);
|
|
@@ -9711,13 +10231,13 @@ async function executeDeliveryPlan(input) {
|
|
|
9711
10231
|
await assertDocumentUnchanged(project, plan.documents.rollback, "\u56DE\u6EDA\u8BF4\u660E");
|
|
9712
10232
|
await assertPayloadsUnchanged(project, plan.payloads);
|
|
9713
10233
|
const evidenceDir = await bindEvidenceDirectory(project, plan.evidenceDir);
|
|
9714
|
-
const receiptFile =
|
|
10234
|
+
const receiptFile = path12.join(evidenceDir.absolute, `${plan.planId}.receipt.json`);
|
|
9715
10235
|
if (await pathExists(receiptFile)) throw invalid2(`\u6267\u884C\u6536\u636E\u5DF2\u5B58\u5728\uFF0C\u62D2\u7EDD\u518D\u6B21\u6267\u884C\uFF1A${plan.planId}`);
|
|
9716
|
-
const claimsDir =
|
|
10236
|
+
const claimsDir = path12.join(project, ".hcm-delivery", "execution-claims");
|
|
9717
10237
|
await safeManagedDirectory(project, ".hcm-delivery/execution-claims", claimsDir);
|
|
9718
|
-
const claimFile =
|
|
10238
|
+
const claimFile = path12.join(claimsDir, `${plan.planId}.json`);
|
|
9719
10239
|
try {
|
|
9720
|
-
await
|
|
10240
|
+
await fs8.writeFile(
|
|
9721
10241
|
claimFile,
|
|
9722
10242
|
`${JSON.stringify({ schemaVersion: 1, planId: plan.planId, claimedAt: now.toISOString() }, null, 2)}
|
|
9723
10243
|
`,
|
|
@@ -9801,26 +10321,30 @@ async function deliveryExecuteCommand(planId, argv, args) {
|
|
|
9801
10321
|
exitWithError(cause);
|
|
9802
10322
|
}
|
|
9803
10323
|
}
|
|
9804
|
-
async function readProjectMode(project) {
|
|
9805
|
-
const file =
|
|
10324
|
+
async function readProjectMode(project, environment) {
|
|
10325
|
+
const file = path12.join(project, ".hcm-delivery", "project.yml");
|
|
9806
10326
|
const content = await readSafeFile(project, file, "\u9879\u76EE\u914D\u7F6E");
|
|
9807
|
-
|
|
9808
|
-
|
|
9809
|
-
|
|
9810
|
-
|
|
9811
|
-
|
|
9812
|
-
|
|
10327
|
+
let mode;
|
|
10328
|
+
try {
|
|
10329
|
+
mode = deliveryModeForEnvironment(content.toString("utf8"), environment);
|
|
10330
|
+
} catch (cause) {
|
|
10331
|
+
throw invalid2(`project.yml \u7684 deliveryMode \u914D\u7F6E\u65E0\u6548\uFF1A${String(cause.message)}`, cause);
|
|
10332
|
+
}
|
|
10333
|
+
if (!mode) {
|
|
10334
|
+
throw invalid2(
|
|
10335
|
+
`project.yml \u672A\u7ED9\u73AF\u5883 ${environment} \u914D\u7F6E deliveryMode\u3002next_step=hcm delivery mode --env ${environment} --set plan-only`
|
|
10336
|
+
);
|
|
9813
10337
|
}
|
|
9814
10338
|
return mode;
|
|
9815
10339
|
}
|
|
9816
10340
|
var SKILLS_LOCK_CANDIDATES = [
|
|
9817
|
-
|
|
9818
|
-
|
|
10341
|
+
path12.join("hcm-skills", ".hcm-skills.json"),
|
|
10342
|
+
path12.join(".claude", "skills", ".hcm-skills.json")
|
|
9819
10343
|
];
|
|
9820
10344
|
async function readSkillsLock(project) {
|
|
9821
10345
|
const found = [];
|
|
9822
10346
|
for (const candidate of SKILLS_LOCK_CANDIDATES) {
|
|
9823
|
-
if (await pathExists(
|
|
10347
|
+
if (await pathExists(path12.join(project, candidate))) found.push(candidate);
|
|
9824
10348
|
}
|
|
9825
10349
|
if (found.length === 0) {
|
|
9826
10350
|
throw invalid2(
|
|
@@ -9832,7 +10356,7 @@ async function readSkillsLock(project) {
|
|
|
9832
10356
|
`\u9879\u76EE\u91CC\u6709\u591A\u4EFD\u6280\u80FD\u9501\uFF08${found.join("\u3001")}\uFF09\uFF0C\u65E0\u6CD5\u552F\u4E00\u5224\u5B9A\u53D7\u63A7\u6267\u884C\u7ED1\u5B9A\u54EA\u4E00\u4EFD\u3002next_step=\u53EA\u4FDD\u7559\u5B9E\u9645\u5728\u7528\u7684\u90A3\u4E2A\u6280\u80FD\u76EE\u5F55`
|
|
9833
10357
|
);
|
|
9834
10358
|
}
|
|
9835
|
-
const bytes = await readSafeFile(project,
|
|
10359
|
+
const bytes = await readSafeFile(project, path12.join(project, found[0]), "\u6280\u80FD\u9501");
|
|
9836
10360
|
try {
|
|
9837
10361
|
JSON.parse(bytes.toString("utf8"));
|
|
9838
10362
|
} catch (cause) {
|
|
@@ -9845,7 +10369,7 @@ async function bindDocument(project, reference, label) {
|
|
|
9845
10369
|
if (!(relative2.startsWith("work/") || relative2.startsWith("decisions/"))) {
|
|
9846
10370
|
throw invalid2(`${label}\u5FC5\u987B\u4F4D\u4E8E\u9879\u76EE work/ \u6216 decisions/ \u4E0B`);
|
|
9847
10371
|
}
|
|
9848
|
-
const file =
|
|
10372
|
+
const file = path12.join(project, relative2);
|
|
9849
10373
|
const bytes = await readSafeFile(project, file, label);
|
|
9850
10374
|
return { path: relative2, sha256: sha2565(bytes) };
|
|
9851
10375
|
}
|
|
@@ -9858,11 +10382,11 @@ async function bindEvidenceDirectory(project, reference) {
|
|
|
9858
10382
|
if (!(relative2 === "evidence" || relative2.startsWith("evidence/"))) {
|
|
9859
10383
|
throw invalid2("evidence \u76EE\u5F55\u5FC5\u987B\u4F4D\u4E8E\u9879\u76EE evidence/ \u4E0B");
|
|
9860
10384
|
}
|
|
9861
|
-
const absolute =
|
|
10385
|
+
const absolute = path12.join(project, relative2);
|
|
9862
10386
|
await assertNoSymlinkComponents(project, relative2);
|
|
9863
|
-
const stat = await
|
|
10387
|
+
const stat = await fs8.stat(absolute).catch(() => null);
|
|
9864
10388
|
if (stat === null) {
|
|
9865
|
-
await
|
|
10389
|
+
await fs8.mkdir(absolute, { recursive: true, mode: 448 }).catch((cause) => {
|
|
9866
10390
|
throw invalid2(
|
|
9867
10391
|
`evidence \u76EE\u5F55\u5EFA\u4E0D\u51FA\u6765\uFF1A${relative2}\u3002next_step=\u68C0\u67E5\u4E0A\u7EA7\u76EE\u5F55\u6743\u9650\uFF0C\u6216\u6362\u4E00\u4E2A evidence/ \u4E0B\u7684\u8DEF\u5F84`,
|
|
9868
10392
|
cause
|
|
@@ -9943,6 +10467,18 @@ function validateSupportedCommandShape(reasonCode, argv) {
|
|
|
9943
10467
|
}
|
|
9944
10468
|
return;
|
|
9945
10469
|
}
|
|
10470
|
+
if (reasonCode === "document-upload") {
|
|
10471
|
+
if (argv[0] !== "upload") {
|
|
10472
|
+
throw invalid2(`upload \u7684\u547D\u4EE4\u540D\u5FC5\u987B\u662F argv \u7684\u7B2C\u4E00\u4E2A token\uFF0C\u5B9E\u9645\u662F\uFF1A${argv[0] ?? "(\u7A7A)"}`);
|
|
10473
|
+
}
|
|
10474
|
+
const file = argv[1];
|
|
10475
|
+
if (!file || file.startsWith("-")) {
|
|
10476
|
+
throw invalid2(
|
|
10477
|
+
"upload \u7684\u6587\u4EF6\u8DEF\u5F84\u5FC5\u987B\u7D27\u8DDF\u5728 upload \u4E4B\u540E\uFF08hcm upload <\u6587\u4EF6> ...\uFF09\u3002next_step=\u628A\u6587\u4EF6\u8DEF\u5F84\u79FB\u5230\u547D\u4EE4\u540D\u540E\u9762\u7684\u7B2C\u4E00\u4E2A\u4F4D\u7F6E\u2014\u2014\u53D7\u63A7\u6267\u884C\u6309\u8FD9\u4E2A\u4F4D\u7F6E\u9489\u4F4F\u8F7D\u8377"
|
|
10478
|
+
);
|
|
10479
|
+
}
|
|
10480
|
+
return;
|
|
10481
|
+
}
|
|
9946
10482
|
if (reasonCode === "record-create") {
|
|
9947
10483
|
requireExactlyOnePayload(argv, "create");
|
|
9948
10484
|
return;
|
|
@@ -9994,7 +10530,10 @@ var PAYLOAD_FILE_FLAGS = ["--data-file", "--params-file", "--file"];
|
|
|
9994
10530
|
var PAYLOAD_DIR_FLAGS = ["--dir"];
|
|
9995
10531
|
var IMPLICIT_DIR_COMMANDS = { "workspace push": "." };
|
|
9996
10532
|
var TOOLING_DIRS = [".git", "node_modules", ".hcm-delivery", "evidence"];
|
|
9997
|
-
var POSITIONAL_PAYLOAD_COMMANDS = {
|
|
10533
|
+
var POSITIONAL_PAYLOAD_COMMANDS = {
|
|
10534
|
+
import: { index: 1, kind: "file-or-directory", label: "import \u6570\u636E\u96C6\u8F7D\u8377" },
|
|
10535
|
+
upload: { index: 1, kind: "file", label: "upload \u6587\u4EF6\u8F7D\u8377" }
|
|
10536
|
+
};
|
|
9998
10537
|
function normalizeCommandArgv(argv) {
|
|
9999
10538
|
return normalizeAssessedArgv(argv);
|
|
10000
10539
|
}
|
|
@@ -10016,7 +10555,10 @@ async function bindPayloadFiles(project, argv) {
|
|
|
10016
10555
|
}
|
|
10017
10556
|
const positional = POSITIONAL_PAYLOAD_COMMANDS[argv[0] ?? ""];
|
|
10018
10557
|
if (positional !== void 0) {
|
|
10019
|
-
|
|
10558
|
+
const reference = argv[positional.index] ?? "";
|
|
10559
|
+
bound.push(
|
|
10560
|
+
await (positional.kind === "file" ? bindPayloadFile(project, reference, positional.label) : bindPayloadPath(project, reference, positional.label))
|
|
10561
|
+
);
|
|
10020
10562
|
}
|
|
10021
10563
|
return bound;
|
|
10022
10564
|
}
|
|
@@ -10024,7 +10566,7 @@ async function bindPayloadPath(project, reference, label) {
|
|
|
10024
10566
|
const relative2 = safeRelative(reference, label);
|
|
10025
10567
|
let stat;
|
|
10026
10568
|
try {
|
|
10027
|
-
stat = await
|
|
10569
|
+
stat = await fs8.stat(path12.join(project, relative2));
|
|
10028
10570
|
} catch (cause) {
|
|
10029
10571
|
throw invalid2(
|
|
10030
10572
|
`${label}\u4E0D\u5B58\u5728\uFF1A${relative2}\u3002next_step=\u628A\u6570\u636E\u96C6\u653E\u8FDB\u9879\u76EE\u76EE\u5F55\u5185\uFF0C\u5E76\u7528\u9879\u76EE\u5185\u76F8\u5BF9\u8DEF\u5F84\u5F15\u7528\uFF08\u53D7\u63A7\u6267\u884C\u53EA\u9489\u5F97\u4F4F\u9879\u76EE\u5185\u7684\u8F7D\u8377\uFF09`,
|
|
@@ -10035,10 +10577,10 @@ async function bindPayloadPath(project, reference, label) {
|
|
|
10035
10577
|
}
|
|
10036
10578
|
async function bindPayloadDirectory(project, reference, label) {
|
|
10037
10579
|
const relative2 = reference === "." ? "." : safeRelative(reference, label);
|
|
10038
|
-
const root =
|
|
10580
|
+
const root = path12.join(project, relative2);
|
|
10039
10581
|
let stat;
|
|
10040
10582
|
try {
|
|
10041
|
-
stat = await
|
|
10583
|
+
stat = await fs8.stat(root);
|
|
10042
10584
|
} catch {
|
|
10043
10585
|
throw invalid2(`${label}\u4E0D\u5B58\u5728\uFF1A${relative2}`);
|
|
10044
10586
|
}
|
|
@@ -10048,10 +10590,10 @@ async function bindPayloadDirectory(project, reference, label) {
|
|
|
10048
10590
|
const skipToolingAtRoot = relative2 === ".";
|
|
10049
10591
|
const entries = [];
|
|
10050
10592
|
const walk = async (dir, prefix) => {
|
|
10051
|
-
const items = await
|
|
10593
|
+
const items = await fs8.readdir(dir, { withFileTypes: true });
|
|
10052
10594
|
for (const item of [...items].sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0)) {
|
|
10053
10595
|
if (skipToolingAtRoot && prefix === "" && TOOLING_DIRS.includes(item.name)) continue;
|
|
10054
|
-
const child =
|
|
10596
|
+
const child = path12.join(dir, item.name);
|
|
10055
10597
|
const rel = prefix ? `${prefix}/${item.name}` : item.name;
|
|
10056
10598
|
if (item.isSymbolicLink()) {
|
|
10057
10599
|
throw invalid2(
|
|
@@ -10068,26 +10610,24 @@ ${sha2565(bytes)}`);
|
|
|
10068
10610
|
}
|
|
10069
10611
|
};
|
|
10070
10612
|
await walk(root, "");
|
|
10071
|
-
return {
|
|
10613
|
+
return {
|
|
10614
|
+
path: relative2,
|
|
10615
|
+
kind: "directory",
|
|
10616
|
+
sha256: sha2565(Buffer.from(entries.join("\n"), "utf8"))
|
|
10617
|
+
};
|
|
10072
10618
|
}
|
|
10073
10619
|
async function bindPayloadFile(project, reference, label) {
|
|
10074
10620
|
const relative2 = safeRelative(reference, label);
|
|
10075
|
-
const file =
|
|
10621
|
+
const file = path12.join(project, relative2);
|
|
10076
10622
|
const bytes = await readSafeFile(project, file, label);
|
|
10077
|
-
return { path: relative2, sha256: sha2565(bytes) };
|
|
10623
|
+
return { path: relative2, kind: "file", sha256: sha2565(bytes) };
|
|
10078
10624
|
}
|
|
10079
10625
|
async function assertPayloadsUnchanged(project, payloads) {
|
|
10080
10626
|
for (const payload of payloads) {
|
|
10081
|
-
|
|
10082
|
-
try {
|
|
10083
|
-
isDirectory = (await fs7.stat(path11.join(project, payload.path))).isDirectory();
|
|
10084
|
-
} catch {
|
|
10085
|
-
isDirectory = false;
|
|
10086
|
-
}
|
|
10087
|
-
const current = isDirectory ? await bindPayloadDirectory(project, payload.path, `\u8F7D\u8377 ${payload.path}`) : await bindPayloadFile(project, payload.path, `\u8F7D\u8377 ${payload.path}`);
|
|
10627
|
+
const current = payload.kind === "directory" ? await bindPayloadDirectory(project, payload.path, `\u8F7D\u8377 ${payload.path}`) : await bindPayloadFile(project, payload.path, `\u8F7D\u8377 ${payload.path}`);
|
|
10088
10628
|
if (current.sha256 !== payload.sha256) {
|
|
10089
10629
|
throw invalid2(
|
|
10090
|
-
`\u8F7D\u8377${
|
|
10630
|
+
`\u8F7D\u8377${payload.kind === "directory" ? "\u76EE\u5F55" : "\u6587\u4EF6"} ${payload.path} \u7684\u5185\u5BB9\u5DF2\u53D8\u66F4\uFF0C\u8BF7\u91CD\u65B0 prepare`
|
|
10091
10631
|
);
|
|
10092
10632
|
}
|
|
10093
10633
|
}
|
|
@@ -10141,29 +10681,29 @@ async function runCurrentCliCommand(argv, cwd, streams) {
|
|
|
10141
10681
|
async function writeReceiptExclusive(target, receipt) {
|
|
10142
10682
|
const temp = `${target}.${process.pid}.${Date.now()}.tmp`;
|
|
10143
10683
|
try {
|
|
10144
|
-
await
|
|
10684
|
+
await fs8.writeFile(temp, `${JSON.stringify(receipt, null, 2)}
|
|
10145
10685
|
`, {
|
|
10146
10686
|
encoding: "utf8",
|
|
10147
10687
|
mode: 384,
|
|
10148
10688
|
flag: "wx"
|
|
10149
10689
|
});
|
|
10150
|
-
await
|
|
10690
|
+
await fs8.link(temp, target);
|
|
10151
10691
|
} catch (cause) {
|
|
10152
|
-
throw invalid2(`\u6267\u884C\u6536\u636E\u5199\u5165\u5931\u8D25\u6216\u5DF2\u5B58\u5728\uFF1A${
|
|
10692
|
+
throw invalid2(`\u6267\u884C\u6536\u636E\u5199\u5165\u5931\u8D25\u6216\u5DF2\u5B58\u5728\uFF1A${path12.basename(target)}`, cause);
|
|
10153
10693
|
} finally {
|
|
10154
|
-
await
|
|
10694
|
+
await fs8.unlink(temp).catch(() => void 0);
|
|
10155
10695
|
}
|
|
10156
10696
|
}
|
|
10157
10697
|
async function safeManagedDirectory(project, relative2, absolute) {
|
|
10158
|
-
await assertNoSymlinkComponents(project,
|
|
10159
|
-
const existing = await
|
|
10698
|
+
await assertNoSymlinkComponents(project, path12.dirname(relative2));
|
|
10699
|
+
const existing = await fs8.lstat(absolute).catch(() => void 0);
|
|
10160
10700
|
if (existing?.isSymbolicLink()) throw invalid2(`\u53D7\u7BA1\u76EE\u5F55\u4E0D\u80FD\u662F\u7B26\u53F7\u94FE\u63A5\uFF1A${relative2}`);
|
|
10161
10701
|
if (existing && !existing.isDirectory()) throw invalid2(`\u53D7\u7BA1\u8DEF\u5F84\u4E0D\u662F\u76EE\u5F55\uFF1A${relative2}`);
|
|
10162
|
-
if (!existing) await
|
|
10163
|
-
await
|
|
10702
|
+
if (!existing) await fs8.mkdir(absolute, { mode: 448 });
|
|
10703
|
+
await fs8.chmod(absolute, 448);
|
|
10164
10704
|
}
|
|
10165
10705
|
async function pathExists(file) {
|
|
10166
|
-
return
|
|
10706
|
+
return fs8.lstat(file).then(
|
|
10167
10707
|
() => true,
|
|
10168
10708
|
(cause) => {
|
|
10169
10709
|
if (cause.code === "ENOENT") return false;
|
|
@@ -10172,65 +10712,68 @@ async function pathExists(file) {
|
|
|
10172
10712
|
);
|
|
10173
10713
|
}
|
|
10174
10714
|
async function readSafeFile(project, file, label) {
|
|
10175
|
-
const relative2 =
|
|
10176
|
-
if (relative2.startsWith("../") ||
|
|
10715
|
+
const relative2 = path12.relative(project, file).split(path12.sep).join("/");
|
|
10716
|
+
if (relative2.startsWith("../") || path12.isAbsolute(relative2))
|
|
10177
10717
|
throw invalid2(`${label}\u8DEF\u5F84\u9003\u9038\u9879\u76EE`);
|
|
10178
10718
|
await assertNoSymlinkComponents(project, relative2);
|
|
10179
10719
|
let stat;
|
|
10180
10720
|
try {
|
|
10181
|
-
stat = await
|
|
10721
|
+
stat = await fs8.lstat(file);
|
|
10182
10722
|
} catch (cause) {
|
|
10183
10723
|
throw invalid2(`${label}\u4E0D\u53EF\u7528\uFF1A${relative2}`, cause);
|
|
10184
10724
|
}
|
|
10185
10725
|
if (stat.isSymbolicLink()) throw invalid2(`${label}\u4E0D\u80FD\u662F\u7B26\u53F7\u94FE\u63A5\uFF1A${relative2}`);
|
|
10186
10726
|
if (!stat.isFile()) throw invalid2(`${label}\u4E0D\u662F\u666E\u901A\u6587\u4EF6\uFF1A${relative2}`);
|
|
10187
|
-
return
|
|
10727
|
+
return fs8.readFile(file);
|
|
10188
10728
|
}
|
|
10189
10729
|
async function assertNoSymlinkComponents(project, relative2) {
|
|
10190
10730
|
const parts = relative2.split("/").filter(Boolean);
|
|
10191
10731
|
let current = project;
|
|
10192
10732
|
for (const part of parts) {
|
|
10193
|
-
current =
|
|
10194
|
-
const stat = await
|
|
10733
|
+
current = path12.join(current, part);
|
|
10734
|
+
const stat = await fs8.lstat(current).catch(() => void 0);
|
|
10195
10735
|
if (stat?.isSymbolicLink()) throw invalid2(`\u8DEF\u5F84\u5305\u542B\u7B26\u53F7\u94FE\u63A5\uFF1A${relative2}`);
|
|
10196
10736
|
if (!stat) break;
|
|
10197
10737
|
}
|
|
10198
10738
|
}
|
|
10199
10739
|
async function realProject(requested) {
|
|
10200
|
-
const absolute =
|
|
10740
|
+
const absolute = path12.resolve(requested);
|
|
10201
10741
|
let project;
|
|
10202
10742
|
try {
|
|
10203
|
-
project = await
|
|
10743
|
+
project = await fs8.realpath(absolute);
|
|
10204
10744
|
} catch (cause) {
|
|
10205
10745
|
throw invalid2(`\u9879\u76EE\u76EE\u5F55\u4E0D\u53EF\u7528\uFF1A${absolute}`, cause);
|
|
10206
10746
|
}
|
|
10207
|
-
const stat = await
|
|
10747
|
+
const stat = await fs8.stat(project);
|
|
10208
10748
|
if (!stat.isDirectory()) throw invalid2(`\u9879\u76EE\u8DEF\u5F84\u4E0D\u662F\u76EE\u5F55\uFF1A${absolute}`);
|
|
10209
10749
|
return project;
|
|
10210
10750
|
}
|
|
10211
10751
|
function safeRelative(reference, label) {
|
|
10212
|
-
if (!reference ||
|
|
10752
|
+
if (!reference || path12.isAbsolute(reference) || /[\r\n\0]/.test(reference)) {
|
|
10213
10753
|
throw invalid2(`${label}\u5FC5\u987B\u662F\u9879\u76EE\u5185\u76F8\u5BF9\u8DEF\u5F84`);
|
|
10214
10754
|
}
|
|
10215
|
-
const normalized =
|
|
10755
|
+
const normalized = path12.normalize(reference).split(path12.sep).join("/");
|
|
10216
10756
|
if (normalized === ".." || normalized.startsWith("../") || normalized === ".") {
|
|
10217
10757
|
throw invalid2(`${label}\u8DEF\u5F84\u9003\u9038\u9879\u76EE`);
|
|
10218
10758
|
}
|
|
10219
10759
|
return normalized.replace(/^\.\//, "");
|
|
10220
10760
|
}
|
|
10221
10761
|
function isRuntimeIdentity(value) {
|
|
10222
|
-
if (!
|
|
10762
|
+
if (!isRecord2(value) || !isSha(value.executableSha256)) return false;
|
|
10223
10763
|
if (value.kind === "executable") return true;
|
|
10224
10764
|
return value.kind === "node-entry" && isSha(value.entrySha256);
|
|
10225
10765
|
}
|
|
10226
10766
|
function isExecutionPlan(value) {
|
|
10227
|
-
if (!
|
|
10228
|
-
return value.schemaVersion === 1 && value.contractVersion === EXECUTION_CONTRACT_VERSION && typeof value.planId === "string" && PLAN_ID_PATTERN.test(value.planId) && typeof value.createdAt === "string" && typeof value.expiresAt === "string" && isSha(value.nonceSha256) && isSha(value.skillsLockSha256) && isRuntimeIdentity(value.runtime) &&
|
|
10767
|
+
if (!isRecord2(value)) return false;
|
|
10768
|
+
return value.schemaVersion === 1 && value.contractVersion === EXECUTION_CONTRACT_VERSION && typeof value.planId === "string" && PLAN_ID_PATTERN.test(value.planId) && typeof value.createdAt === "string" && typeof value.expiresAt === "string" && isSha(value.nonceSha256) && isSha(value.skillsLockSha256) && isRuntimeIdentity(value.runtime) && isRecord2(value.assessment) && isRecord2(value.documents) && isBoundDocument(value.documents.change) && isBoundDocument(value.documents.rollback) && Array.isArray(value.payloads) && value.payloads.every(isBoundPayload) && typeof value.evidenceDir === "string";
|
|
10229
10769
|
}
|
|
10230
10770
|
function isBoundDocument(value) {
|
|
10231
|
-
return
|
|
10771
|
+
return isRecord2(value) && typeof value.path === "string" && isSha(value.sha256);
|
|
10232
10772
|
}
|
|
10233
|
-
function
|
|
10773
|
+
function isBoundPayload(value) {
|
|
10774
|
+
return isBoundDocument(value) && "kind" in value && (value.kind === "file" || value.kind === "directory");
|
|
10775
|
+
}
|
|
10776
|
+
function isRecord2(value) {
|
|
10234
10777
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
10235
10778
|
}
|
|
10236
10779
|
function isSha(value) {
|
|
@@ -10243,7 +10786,7 @@ function parseTtl(value) {
|
|
|
10243
10786
|
}
|
|
10244
10787
|
function canonicalJson(value) {
|
|
10245
10788
|
if (Array.isArray(value)) return `[${value.map(canonicalJson).join(",")}]`;
|
|
10246
|
-
if (
|
|
10789
|
+
if (isRecord2(value)) {
|
|
10247
10790
|
return `{${Object.keys(value).sort().map((key2) => `${JSON.stringify(key2)}:${canonicalJson(value[key2])}`).join(",")}}`;
|
|
10248
10791
|
}
|
|
10249
10792
|
return JSON.stringify(value) ?? "null";
|
|
@@ -10393,7 +10936,7 @@ var exitOnBrokenPipe = (err) => {
|
|
|
10393
10936
|
process.stdout.on("error", exitOnBrokenPipe);
|
|
10394
10937
|
process.stderr.on("error", exitOnBrokenPipe);
|
|
10395
10938
|
program.name("hcm").description("HCM \u547D\u4EE4\u884C\u5DE5\u5177 \u2014 \u64CD\u4F5C HCM API\u3001\u4E0E Moirai \u6570\u5B57\u5458\u5DE5\u5BF9\u8BDD\u3001\u5F00\u53D1\u79DF\u6237\u5F00\u53D1\u7A7A\u95F4").version(CLI_VERSION);
|
|
10396
|
-
program.command("login").description("\u767B\u5F55 HCM\uFF08\u914D\u5BF9\u7801 / \u7528\u6237\u540D\u5BC6\u7801 / client_credentials / PAT \u56DB\u79CD\u65B9\u5F0F\uFF09").argument("[endpoint]", "\u4ECE\u7CFB\u7EDF\u9875\u9762\u300C\u547D\u4EE4\u884C\u5DE5\u5177\u300D\u590D\u5236\u6765\u7684\u5730\u5740\uFF08\u914D\u5BF9\u7801\u65B9\u5F0F\uFF09").option("--code <code>", "\u914D\u5BF9\u7801\uFF0C\u5728\u7CFB\u7EDF\u9875\u9762\u7528\u6237\u83DC\u5355 \u2192\u300C\u547D\u4EE4\u884C\u5DE5\u5177\u300D\u751F\u6210").option("--env <name>", "\u73AF\u5883\u540D\uFF08\u9ED8\u8BA4 activeEnv\uFF09").option("--profile <name>", "[deprecated] \u7528 --env \u66FF\u4EE3").option("--name <id-name>", "\u81EA\u5B9A\u4E49 identity \u540D\uFF08\u9ED8\u8BA4\u6309 scheme \u63A8\u65AD\uFF09").option("--no-activate", "login \u5B8C\u4E0D\u5207\u5230\u8BE5\u73AF\u5883\u4E5F\u4E0D\u8BBE\u4E3A default identity").option("--endpoint <url>", "HCM \u540E\u7AEF\u5730\u5740\uFF0C\u4F8B\u5982 http://localhost:8080").option("--username <user>", "\u7528\u6237\u540D\uFF08\u5BC6\u7801\u767B\u5F55\u6A21\u5F0F\uFF09").option("--password <pwd>", "\u5BC6\u7801\uFF08\u5BC6\u7801\u767B\u5F55\u6A21\u5F0F\uFF09").option("--client-id <id>", "OAuth client_id\uFF08client_credentials \u6A21\u5F0F\uFF09").option("--client-secret <secret>", "OAuth client_secret\uFF08client_credentials \u6A21\u5F0F\uFF09").option("--pat <token>", "PAT \u4E2A\u4EBA\u8BBF\u95EE\u4EE4\u724C\uFF08\u6CE8\u610F\uFF1A\u4F1A\u6CC4\u6F0F\u5230 ps/history\uFF0C\u5EFA\u8BAE\u6539\u7528 --pat-stdin\uFF09").option("--pat-stdin", "\u4ECE\u6807\u51C6\u8F93\u5165\u8BFB\u53D6 PAT\uFF08\u63A8\u8350\uFF09").option("--new-password <pwd>", "\u9996\u767B\u5F3A\u5236\u6539\u5BC6\u65F6\u7684\u65B0\u53E3\u4EE4\uFF08\u4F1A\u6CC4\u6F0F\u5230 history/ps\uFF0C\u5EFA\u8BAE --new-password-stdin\uFF09").option("--new-password-stdin", "\u9996\u767B\u5F3A\u5236\u6539\u5BC6\u65F6\u4ECE\u6807\u51C6\u8F93\u5165\u8BFB\u65B0\u53E3\u4EE4\uFF08\u975E\u4EA4\u4E92\u573A\u666F\uFF09").option("--tenant <tenantId>", "\u79DF\u6237 ID\uFF08\u9ED8\u8BA4 1\uFF09").action((endpoint, opts) => loginCommand({ ...opts, endpointArg: endpoint }));
|
|
10939
|
+
program.command("login").description("\u767B\u5F55 HCM\uFF08\u914D\u5BF9\u7801 / \u7528\u6237\u540D\u5BC6\u7801 / client_credentials / PAT \u56DB\u79CD\u65B9\u5F0F\uFF09").argument("[endpoint]", "\u4ECE\u7CFB\u7EDF\u9875\u9762\u300C\u547D\u4EE4\u884C\u5DE5\u5177\u300D\u590D\u5236\u6765\u7684\u5730\u5740\uFF08\u914D\u5BF9\u7801\u65B9\u5F0F\uFF09").option("--code <code>", "\u914D\u5BF9\u7801\uFF0C\u5728\u7CFB\u7EDF\u9875\u9762\u7528\u6237\u83DC\u5355 \u2192\u300C\u547D\u4EE4\u884C\u5DE5\u5177\u300D\u751F\u6210").option("--env <name>", "\u73AF\u5883\u540D\uFF08\u9ED8\u8BA4 activeEnv\uFF09").option("--profile <name>", "[deprecated] \u7528 --env \u66FF\u4EE3").option("--name <id-name>", "\u81EA\u5B9A\u4E49 identity \u540D\uFF08\u9ED8\u8BA4\u6309 scheme \u63A8\u65AD\uFF09").option("--no-activate", "login \u5B8C\u4E0D\u5207\u5230\u8BE5\u73AF\u5883\u4E5F\u4E0D\u8BBE\u4E3A default identity").option("--endpoint <url>", "HCM \u540E\u7AEF\u5730\u5740\uFF0C\u4F8B\u5982 http://localhost:8080").option("--username <user>", "\u7528\u6237\u540D\uFF08\u5BC6\u7801\u767B\u5F55\u6A21\u5F0F\uFF09").option("--password <pwd>", "\u5BC6\u7801\uFF08\u5BC6\u7801\u767B\u5F55\u6A21\u5F0F\uFF1B\u4F1A\u6CC4\u6F0F\u5230 history/ps\uFF0CAgent/\u53D7\u63A7\u4EA4\u4ED8\u8BF7\u7528 --password-stdin\uFF09").option("--password-stdin", "\u4ECE\u6807\u51C6\u8F93\u5165\u8BFB\u5BC6\u7801\uFF08\u5BC6\u7801\u767B\u5F55\u6A21\u5F0F\uFF0C\u975E\u4EA4\u4E92/\u4E0D\u56DE\u663E\uFF09").option("--client-id <id>", "OAuth client_id\uFF08client_credentials \u6A21\u5F0F\uFF09").option("--client-secret <secret>", "OAuth client_secret\uFF08client_credentials \u6A21\u5F0F\uFF09").option("--pat <token>", "PAT \u4E2A\u4EBA\u8BBF\u95EE\u4EE4\u724C\uFF08\u6CE8\u610F\uFF1A\u4F1A\u6CC4\u6F0F\u5230 ps/history\uFF0C\u5EFA\u8BAE\u6539\u7528 --pat-stdin\uFF09").option("--pat-stdin", "\u4ECE\u6807\u51C6\u8F93\u5165\u8BFB\u53D6 PAT\uFF08\u63A8\u8350\uFF09").option("--new-password <pwd>", "\u9996\u767B\u5F3A\u5236\u6539\u5BC6\u65F6\u7684\u65B0\u53E3\u4EE4\uFF08\u4F1A\u6CC4\u6F0F\u5230 history/ps\uFF0C\u5EFA\u8BAE --new-password-stdin\uFF09").option("--new-password-stdin", "\u9996\u767B\u5F3A\u5236\u6539\u5BC6\u65F6\u4ECE\u6807\u51C6\u8F93\u5165\u8BFB\u65B0\u53E3\u4EE4\uFF08\u975E\u4EA4\u4E92\u573A\u666F\uFF09").option("--tenant <tenantId>", "\u79DF\u6237 ID\uFF08\u9ED8\u8BA4 1\uFF09").action((endpoint, opts) => loginCommand({ ...opts, endpointArg: endpoint }));
|
|
10397
10940
|
program.command("logout").description("\u767B\u51FA HCM\uFF08\u6E05\u9664 identity \u7684 keychain token\uFF09").option("--identity <name>", "\u6307\u5B9A identity\uFF1B\u9ED8\u8BA4\u6E05\u5F53\u524D env \u7684 default identity").option("--env <name>", "\u6307\u5B9A env\uFF08\u5F71\u54CD default identity \u89E3\u6790\uFF09").action((opts) => logoutCommand(opts));
|
|
10398
10941
|
var config = program.command("config").description("\u7BA1\u7406\u5168\u5C40 defaults\uFF08env/identity \u7528 `hcm env` / `hcm identity`\uFF09");
|
|
10399
10942
|
config.command("list").description("[deprecated] \u7528 `hcm env list`").action(() => configListDeprecated());
|
|
@@ -10481,14 +11024,17 @@ delivery.command("triage").description(
|
|
|
10481
11024
|
"--recon <dir>",
|
|
10482
11025
|
"\u57FA\u7EBF\u4EA7\u7269\u76EE\u5F55\uFF08<out>/recon/<\u79DF\u6237\u6BB5>/<\u6765\u6E90\u6BB5>\uFF09\uFF1B\u4E0D\u7ED9\u5219\u6309\u722C\u53D6\u8EAB\u4EFD\u73B0\u7B97\u4E00\u4EFD"
|
|
10483
11026
|
).option("--out <dir>", "\u4EA7\u7269\u6839\uFF08\u5199 work/triage.md\uFF09", ".").option("--capabilities <caps>", "\u672C\u6B21\u63A2\u6D4B\u58F0\u660E\u7684 capability \u4E32", "default").action((opts) => deliveryTriageCommand(opts));
|
|
10484
|
-
delivery.command("init").description("\u751F\u6210\
|
|
10485
|
-
delivery.command("mode").description("\u770B/\u6539\u672C\
|
|
11027
|
+
delivery.command("init").description("\u751F\u6210\u5BA2\u6237\u9879\u76EE\u4ED3\u9AA8\u67B6\u3001\u73AF\u5883\u6E05\u5355\u3001\u6210\u5458 setup \u4E0E\u672C\u673A\u53D7\u63A7\u4EA4\u4ED8\u914D\u7F6E").option("--project <dir>", "HCM \u987E\u95EE\u9879\u76EE\u6839\u76EE\u5F55", ".").option("--env <name>", "\u521D\u59CB\u5316\u54EA\u4E2A\u73AF\u5883\uFF08\u9ED8\u8BA4 HCM_ENV / activeEnv\uFF09").option("--mode <mode>", "\u672C\u673A\u521D\u59CB\u4EA4\u4ED8\u6A21\u5F0F\uFF1Acontrolled | plan-only", "plan-only").option("--force", "\u8986\u76D6\u5DF2\u5B58\u5728\u7684\u9879\u76EE\u914D\u7F6E").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((opts) => deliveryInitCommand(opts));
|
|
11028
|
+
delivery.command("mode").description("\u6309\u73AF\u5883\u770B/\u6539\u672C\u673A\u4EA4\u4ED8\u6A21\u5F0F\uFF1B\u4E0D\u5E26 --set \u53EA\u8BFB\uFF0C\u5E26 --set \u53EA\u6539\u76EE\u6807\u73AF\u5883").option("--project <dir>", "HCM \u987E\u95EE\u9879\u76EE\u6839\u76EE\u5F55", ".").option("--env <name>", "\u76EE\u6807\u73AF\u5883\uFF08\u9ED8\u8BA4 HCM_ENV / activeEnv\uFF09").option("--set <mode>", "\u6539\u4E3A\uFF1Acontrolled | plan-only").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((opts) => deliveryModeCommand(opts));
|
|
10486
11029
|
delivery.command("prepare").description("\u628A\u53D7\u652F\u6301\u7684 R2 argv \u4E0E\u9501\u3001\u8FD0\u884C\u65F6\u548C\u53D8\u66F4/\u56DE\u6EDA\u8BF4\u660E\u7ED1\u5B9A\u4E3A\u77ED\u65F6\u6267\u884C\u8BA1\u5212").requiredOption("--change-ref <file>", "\u9879\u76EE work/ \u6216 decisions/ \u4E0B\u7684\u53D8\u66F4\u8BF4\u660E").requiredOption("--rollback-ref <file>", "\u9879\u76EE work/ \u6216 decisions/ \u4E0B\u7684\u56DE\u6EDA\u8BF4\u660E").requiredOption("--evidence-dir <dir>", "\u9879\u76EE evidence/ \u4E0B\u7684\u6536\u636E\u76EE\u5F55").option("--project <dir>", "HCM \u987E\u95EE\u9879\u76EE\u6839\u76EE\u5F55", ".").option("--ttl-seconds <n>", "\u6709\u6548\u671F\u79D2\u6570\uFF0860-3600\uFF09", "900").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").allowUnknownOption(true).argument("<command...>", "\u88AB\u7ED1\u5B9A\u7684 R2 HCM \u5B50\u547D\u4EE4\u4E0E\u53C2\u6570\uFF0C\u4E0D\u5305\u542B hcm \u672C\u8EAB").action((command, opts) => deliveryPrepareCommand(command, opts));
|
|
10487
11030
|
delivery.command("execute <planId>").description("\u9010\u6B21\u6279\u51C6\u540E\u6D88\u8D39\u77ED\u65F6\u8BA1\u5212\uFF0C\u5E76\u6267\u884C\u4E00\u6B21\u4E0E\u8BA1\u5212\u5B8C\u5168\u76F8\u540C\u7684 R2 argv").option("--project <dir>", "HCM \u987E\u95EE\u9879\u76EE\u6839\u76EE\u5F55", ".").option("--output <fmt>", "\u6536\u636E\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").allowUnknownOption(true).argument("[command...]", "\u4E0E prepare \u5B8C\u5168\u76F8\u540C\u7684 R2 HCM \u5B50\u547D\u4EE4\u4E0E\u53C2\u6570").action((planId, command, opts) => deliveryExecuteCommand(planId, command, opts));
|
|
10488
|
-
program.command("query <Model>").description("\u67E5\u8BE2 Model \u5217\u8868\u6570\u636E\uFF08\u901A\u8FC7 ModelQueryDsl JSON \u8868\u8FBE\u8FC7\u6EE4/\u6392\u5E8F/\u5206\u9875\uFF09").option(
|
|
11031
|
+
program.command("query <Model>").description("\u67E5\u8BE2 Model \u5217\u8868\u6570\u636E\uFF08\u901A\u8FC7 ModelQueryDsl JSON \u8868\u8FBE\u8FC7\u6EE4/\u6392\u5E8F/\u5173\u8054/\u5206\u9875\uFF09").option(
|
|
10489
11032
|
"--filter <JSON>",
|
|
10490
11033
|
`\u8FC7\u6EE4 AST\uFF08ModelQueryDsl\uFF09\uFF1A\u53F6\u5B50 '{"field":"status","op":"eq","value":"ACTIVE"}'\uFF0C\u591A\u6761\u4EF6\u7528 '{"and":[\u53F6\u5B50,\u2026]}'\u3002\u26A0\uFE0F \u4E0D\u63A5\u53D7 {"\u5B57\u6BB5":"\u503C"} \u7B80\u5199\uFF0Cschema \u5C42\u4F1A\u62D2`
|
|
10491
|
-
).option("--sort <JSON>", `\u6392\u5E8F\u6761\u4EF6 JSON\uFF0C\u4F8B\u5982 '[{"field":"hireDate","direction":"desc"}]'`).option(
|
|
11034
|
+
).option("--sort <JSON>", `\u6392\u5E8F\u6761\u4EF6 JSON\uFF0C\u4F8B\u5982 '[{"field":"hireDate","direction":"desc"}]'`).option(
|
|
11035
|
+
"--additions <JSON>",
|
|
11036
|
+
`\u8DE8\u5173\u7CFB JOIN \u7684\u5BF9\u8C61\u6570\u7EC4 JSON\uFF0C\u4F8B\u5982 '[{"key":"employee","model":"Employee"}]'`
|
|
11037
|
+
).option("--fields <list>", "\u8FD4\u56DE\u5B57\u6BB5\u5217\u8868\uFF08\u9017\u53F7\u5206\u9694\uFF09\uFF0C\u4F8B\u5982 name,code,email").option("--keyword <text>", "\u5168\u6587\u68C0\u7D22\u5173\u952E\u5B57").option("--limit <n>", "\u6BCF\u9875\u5927\u5C0F", "20").option("--offset <n>", "\u504F\u79FB\u91CF\uFF08\u6309 limit \u81EA\u52A8\u6362\u7B97 page\uFF09").option("--env <name>", "\u4E34\u65F6\u5207\u73AF\u5883\uFF08\u8986\u76D6 activeEnv\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--profile <name>", "[deprecated] \u7528 --env \u66FF\u4EE3").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((m, opts) => queryCommand(m, opts));
|
|
10492
11038
|
program.command("action <Model.Action>").description("\u8C03\u7528 Model \u4E0A\u7684 Action\uFF08\u4E1A\u52A1\u65B9\u6CD5\uFF09\uFF0C\u4F8B\u5982 Employee.regularize").option("--id <id>", "\u76EE\u6807\u5B9E\u4F53 ID\uFF08object Action \u5FC5\u586B\uFF09").option("--ids <csv>", "\u6279\u91CF ID\uFF08\u9017\u53F7\u5206\u9694\uFF0Cbulk Action \u7528\uFF09").option("--method <method>", "HTTP \u65B9\u6CD5\uFF1AGET | POST | PUT | DELETE\uFF08\u9ED8\u8BA4\u6309 Core \u5143\u6570\u636E\u81EA\u52A8\u5224\u5B9A\uFF09").option("--scope <scope>", "\u5F3A\u5236 Action scope\uFF1Aclass | object\uFF08\u9ED8\u8BA4\uFF1A\u6709 --id \u4E3A object\uFF0C\u5426\u5219 class\uFF09").option("--params <JSON>", `Action \u5165\u53C2 JSON\uFF0C\u4F8B\u5982 '{"effectDate":"2026-06-01"}'`).option("--params-file <path>", "\u4ECE UTF-8 JSON \u6587\u4EF6\u8BFB\u53D6 Action \u5165\u53C2\uFF08\u4E0E --params \u4E92\u65A5\uFF09").option("--env <name>", "\u4E34\u65F6\u5207\u73AF\u5883\uFF08\u8986\u76D6 activeEnv\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--profile <name>", "[deprecated] \u7528 --env \u66FF\u4EE3").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((spec, opts) => actionCommand(spec, opts));
|
|
10493
11039
|
program.command("create <Model>").description("\u521B\u5EFA\u4E00\u6761 Model \u8BB0\u5F55\uFF08\u8D70\u540E\u7AEF\u5B8C\u6574\u6821\u9A8C\uFF09").option("--data <JSON>", `\u8BB0\u5F55\u5B57\u6BB5 JSON\uFF0C\u4F8B\u5982 '{"code":"ORG_SALES","name":"\u9500\u552E\u90E8"}'`).option("--data-file <path>", "\u4ECE UTF-8 JSON \u6587\u4EF6\u8BFB\u53D6\u8BB0\u5F55\u5B57\u6BB5\uFF08\u4E0E --data \u4E92\u65A5\uFF09").option("--env <name>", "\u4E34\u65F6\u5207\u73AF\u5883\uFF08\u8986\u76D6 activeEnv\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--profile <name>", "[deprecated] \u7528 --env \u66FF\u4EE3").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").option("--i18n", "\u591A\u8BED\u8A00\u5B57\u6BB5\u6309 Map \u5B8C\u6574\u66FF\u6362\uFF08\u952E\u7528 zh-CN / en-US \u8FDE\u5B57\u7B26\u5F62\uFF09\uFF1B\u4E0D\u4F20\u5219\u6309\u5B57\u7B26\u4E32\u53EA\u6539\u5F53\u524D\u8BED\u8A00").action((m, opts) => createCommand(m, opts));
|
|
10494
11040
|
program.command("delete <Model>").description("\u5220\u9664\u4E00\u6761 Model \u8BB0\u5F55\uFF08\u8D70\u540E\u7AEF\u5B8C\u6574\u6821\u9A8C\uFF1B\u90E8\u5206 Model \u4F1A\u6267\u884C\u4E1A\u52A1\u64A4\u9500\uFF09").option("--id <id>", "\u76EE\u6807\u5B9E\u4F53 ID\uFF08\u5FC5\u586B\uFF09").option("--env <name>", "\u4E34\u65F6\u5207\u73AF\u5883\uFF08\u8986\u76D6 activeEnv\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--profile <name>", "[deprecated] \u7528 --env \u66FF\u4EE3").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((m, opts) => deleteCommand(m, opts));
|
|
@@ -10564,7 +11110,7 @@ skills.command("update").description("\u628A\u88C5\u8FC7\u7684\u6280\u80FD\u5347
|
|
|
10564
11110
|
program.command("update <Model>").description("\u66F4\u65B0\u4E00\u6761 Model \u8BB0\u5F55\uFF08\u8D70\u540E\u7AEF\u5B8C\u6574\u6821\u9A8C\uFF09\u3002\u5347\u7EA7 CLI \u8BF7\u7528 `hcm upgrade`").requiredOption("--id <id>", "\u8BB0\u5F55 ID").option("--data <JSON>", `\u8981\u66F4\u65B0\u7684\u5B57\u6BB5 JSON\uFF0C\u4F8B\u5982 '{"name":"\u65B0\u540D\u79F0"}'`).option("--data-file <path>", "\u4ECE UTF-8 JSON \u6587\u4EF6\u8BFB\u53D6\u66F4\u65B0\u5B57\u6BB5\uFF08\u4E0E --data \u4E92\u65A5\uFF09").option("--env <name>", "\u4E34\u65F6\u5207\u73AF\u5883\uFF08\u8986\u76D6 activeEnv\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").option("--i18n", "\u591A\u8BED\u8A00\u5B57\u6BB5\u6309 Map \u5B8C\u6574\u66FF\u6362\uFF08\u952E\u7528 zh-CN / en-US \u8FDE\u5B57\u7B26\u5F62\uFF09\uFF1B\u4E0D\u4F20\u5219\u6309\u5B57\u7B26\u4E32\u53EA\u6539\u5F53\u524D\u8BED\u8A00").action((model, opts) => updateCommand(model, opts));
|
|
10565
11111
|
program.command("version").description("\u67E5 CLI \u4E0E\u540E\u7AEF\u4E24\u4E2A\u7248\u672C\uFF08commit / tag / \u6784\u5EFA\u65F6\u95F4\uFF09\u2014\u2014\u514D\u8BA4\u8BC1\uFF0C\u65E0\u9700\u5148 login").option("--endpoint <url>", "\u540E\u7AEF\u5730\u5740\uFF08\u9ED8\u8BA4\u53D6 activeEnv \u7684 endpoint\uFF09").option("--env <name>", "\u4ECE\u8BE5 env \u89E3\u6790 endpoint").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((opts) => versionCommand(opts));
|
|
10566
11112
|
program.command("upgrade").alias("self-update").description("\u5347\u7EA7 CLI \u81EA\u5DF1\uFF08\u6CE8\u610F\uFF1A`hcm update` \u662F\u66F4\u65B0\u4E1A\u52A1\u8BB0\u5F55\uFF0C\u4E0D\u662F\u5347\u7EA7\uFF09").option("--check", "\u53EA\u68C0\u67E5\uFF1B\u6709\u65B0\u7248\u672C\u65F6\u4EE5\u9000\u51FA\u7801 1 \u7ED3\u675F\uFF0C\u4FBF\u4E8E\u811A\u672C\u5224\u65AD").action((opts) => upgradeCommand(opts));
|
|
10567
|
-
program.command("open [path]").description("\u7528\u5F53\u524D CLI \u8EAB\u4EFD\u6253\u5F00\u524D\u7AEF\u9875\u9762\uFF1A\u94F8\u4E00\u5F20 60s \u4E00\u6B21\u6027\u7968\u636E\u4EA4\u7ED9\u6D4F\u89C8\u5668\uFF0C\u4F1A\u8BDD token \u4E0D\u8FDB URL").option("--print-url", "\u53EA\u6253\u5370\u767B\u5F55 URL\uFF0C\u4E0D\u5F00\u6D4F\u89C8\u5668\uFF08\u7ED9 agent \u6D4F\u89C8\u5668 navigate \u7528\uFF09").option("--env <name>", "\u4E34\u65F6\u5207\u73AF\u5883\uFF08\u8986\u76D6 activeEnv\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--profile <name>", "[deprecated] \u7528 --env \u66FF\u4EE3").action((
|
|
11113
|
+
program.command("open [path]").description("\u7528\u5F53\u524D CLI \u8EAB\u4EFD\u6253\u5F00\u524D\u7AEF\u9875\u9762\uFF1A\u94F8\u4E00\u5F20 60s \u4E00\u6B21\u6027\u7968\u636E\u4EA4\u7ED9\u6D4F\u89C8\u5668\uFF0C\u4F1A\u8BDD token \u4E0D\u8FDB URL").option("--print-url", "\u53EA\u6253\u5370\u767B\u5F55 URL\uFF0C\u4E0D\u5F00\u6D4F\u89C8\u5668\uFF08\u7ED9 agent \u6D4F\u89C8\u5668 navigate \u7528\uFF09").option("--env <name>", "\u4E34\u65F6\u5207\u73AF\u5883\uFF08\u8986\u76D6 activeEnv\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--profile <name>", "[deprecated] \u7528 --env \u66FF\u4EE3").action((path13, opts) => openCommand(path13, opts));
|
|
10568
11114
|
var setting = program.command("setting").description("\u79DF\u6237\u7CFB\u7EDF\u53C2\u6570\uFF08\u767B\u5F55\u7B56\u7565 / \u5BC6\u7801\u7B56\u7565 / \u529F\u80FD\u5F00\u5173 / \u96C6\u6210\u53C2\u6570\uFF09");
|
|
10569
11115
|
setting.command("get <domain>").description("\u8BFB\u67D0\u57DF\u53C2\u6570\uFF08\u5B9A\u4E49 + \u79DF\u6237\u8986\u76D6\u503C\u5408\u5E76\uFF0C\u7F3A\u5931\u56DE\u843D\u9ED8\u8BA4\u503C\uFF09").option("--env <name>", "\u4E34\u65F6\u5207\u73AF\u5883\uFF08\u8986\u76D6 activeEnv\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((d, opts) => settingGetCommand(d, opts));
|
|
10570
11116
|
setting.command("set <domain>").description("\u6539\u53C2\u6570\uFF0C\u53EF\u91CD\u590D --set\uFF1B\u8D70\u53D7\u63A7\u6821\u9A8C\u8DEF\u5F84\u800C\u975E\u6807\u51C6 CRUD").option("--set <assignment...>", "namespace.key=value\uFF0C\u4F8B\u5982 security.password.passwordPolicy=complex").option("--dry-run", "\u53EA\u663E\u793A\u5C06\u5199\u5165\u4EC0\u4E48\uFF0C\u4E0D\u5B9E\u9645\u5199\u5165").option("--env <name>", "\u4E34\u65F6\u5207\u73AF\u5883\uFF08\u8986\u76D6 activeEnv\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((d, opts) => settingSetCommand(d, opts));
|