@hcmai/cli 0.4.20 → 0.4.21
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/README.md +15 -0
- package/dist/index.js +527 -192
- package/dist/index.js.map +1 -1
- package/dist/skills/manifest.json +12 -2
- package/package.json +2 -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(path14) {
|
|
527
|
+
const segs = path14.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(path14) {
|
|
1710
|
+
const segs = (path14 ?? "").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
|
}
|
|
@@ -2298,9 +2298,9 @@ async function loginCommand(args) {
|
|
|
2298
2298
|
} catch (e) {
|
|
2299
2299
|
const err = e;
|
|
2300
2300
|
if (err.isAxiosError) {
|
|
2301
|
-
const { fromAxiosError:
|
|
2301
|
+
const { fromAxiosError: fromAxiosError25 } = await import("@hcmai/sdk");
|
|
2302
2302
|
exitWithError(
|
|
2303
|
-
|
|
2303
|
+
fromAxiosError25(
|
|
2304
2304
|
e,
|
|
2305
2305
|
envName
|
|
2306
2306
|
)
|
|
@@ -2811,16 +2811,7 @@ async function actionCommand(spec, args) {
|
|
|
2811
2811
|
}
|
|
2812
2812
|
const result = await client3.action(model, action, input);
|
|
2813
2813
|
const fmt = args.output ?? "json";
|
|
2814
|
-
|
|
2815
|
-
process.stdout.write(
|
|
2816
|
-
`\u23F3 task created: ${result.taskId} (use \`hcm task ${result.taskId}\` to follow up \u2014 coming Phase 1)
|
|
2817
|
-
`
|
|
2818
|
-
);
|
|
2819
|
-
} else if (fmt !== "json") {
|
|
2820
|
-
process.stdout.write("\u2705 action succeeded\n");
|
|
2821
|
-
}
|
|
2822
|
-
process.stdout.write(formatObject(result, { format: fmt }) + "\n");
|
|
2823
|
-
process.exit(0);
|
|
2814
|
+
printActionResult(result, fmt);
|
|
2824
2815
|
} catch (e) {
|
|
2825
2816
|
const err = e;
|
|
2826
2817
|
if (err?.isAxiosError) {
|
|
@@ -2829,6 +2820,18 @@ async function actionCommand(spec, args) {
|
|
|
2829
2820
|
exitWithError(e);
|
|
2830
2821
|
}
|
|
2831
2822
|
}
|
|
2823
|
+
function printActionResult(result, fmt) {
|
|
2824
|
+
if (fmt !== "json" && result.taskId) {
|
|
2825
|
+
process.stdout.write(
|
|
2826
|
+
`\u23F3 task created: ${result.taskId} (use \`hcm task ${result.taskId}\` to follow up \u2014 coming Phase 1)
|
|
2827
|
+
`
|
|
2828
|
+
);
|
|
2829
|
+
} else if (fmt !== "json") {
|
|
2830
|
+
process.stdout.write("\u2705 action succeeded\n");
|
|
2831
|
+
}
|
|
2832
|
+
process.stdout.write(formatObject(result, { format: fmt }) + "\n");
|
|
2833
|
+
process.exitCode = 0;
|
|
2834
|
+
}
|
|
2832
2835
|
function normalizeMethod(value) {
|
|
2833
2836
|
const raw = (value ?? "POST").toUpperCase();
|
|
2834
2837
|
if (raw === "GET" || raw === "POST" || raw === "PUT" || raw === "DELETE") return raw;
|
|
@@ -3166,7 +3169,7 @@ function launchBrowser(url, platform = process.platform) {
|
|
|
3166
3169
|
child.unref();
|
|
3167
3170
|
}
|
|
3168
3171
|
async function runOpen(target, args, deps) {
|
|
3169
|
-
const
|
|
3172
|
+
const path14 = normalizeTarget(target);
|
|
3170
3173
|
if (!deps.frontend?.trim()) {
|
|
3171
3174
|
throw new CliError12({
|
|
3172
3175
|
code: CliErrorCode11.INVALID_ARGUMENT,
|
|
@@ -3174,13 +3177,13 @@ async function runOpen(target, args, deps) {
|
|
|
3174
3177
|
});
|
|
3175
3178
|
}
|
|
3176
3179
|
const { ticket, expiresIn } = await deps.mintTicket();
|
|
3177
|
-
const url = buildBrowserLoginUrl(deps.frontend, ticket,
|
|
3180
|
+
const url = buildBrowserLoginUrl(deps.frontend, ticket, path14);
|
|
3178
3181
|
if (args.printUrl) {
|
|
3179
3182
|
deps.write(`${url}
|
|
3180
3183
|
`);
|
|
3181
3184
|
} else {
|
|
3182
3185
|
deps.launch(url);
|
|
3183
|
-
deps.write(`\u5DF2\u7528\u5F53\u524D\u8EAB\u4EFD\u6253\u5F00 ${
|
|
3186
|
+
deps.write(`\u5DF2\u7528\u5F53\u524D\u8EAB\u4EFD\u6253\u5F00 ${path14}\uFF08\u7968\u636E ${expiresIn ?? 60}s \u5185\u6709\u6548\uFF0C\u53EA\u80FD\u7528\u4E00\u6B21\uFF09
|
|
3184
3187
|
`);
|
|
3185
3188
|
}
|
|
3186
3189
|
return { url, expiresIn };
|
|
@@ -3272,8 +3275,8 @@ import {
|
|
|
3272
3275
|
formatObject as formatObject7,
|
|
3273
3276
|
fromAxiosError as fromAxiosError9
|
|
3274
3277
|
} from "@hcmai/sdk";
|
|
3275
|
-
function collectYmlFiles(
|
|
3276
|
-
if (statSync(
|
|
3278
|
+
function collectYmlFiles(path14) {
|
|
3279
|
+
if (statSync(path14).isFile()) return [path14];
|
|
3277
3280
|
const out = [];
|
|
3278
3281
|
const walk = (dir) => {
|
|
3279
3282
|
for (const name of readdirSync(dir).sort()) {
|
|
@@ -3282,7 +3285,7 @@ function collectYmlFiles(path13) {
|
|
|
3282
3285
|
else if (full.endsWith(".yml") || full.endsWith(".yaml")) out.push(full);
|
|
3283
3286
|
}
|
|
3284
3287
|
};
|
|
3285
|
-
walk(
|
|
3288
|
+
walk(path14);
|
|
3286
3289
|
return out.sort();
|
|
3287
3290
|
}
|
|
3288
3291
|
var DRY_RUN_CLIENT = {
|
|
@@ -3290,9 +3293,9 @@ var DRY_RUN_CLIENT = {
|
|
|
3290
3293
|
create: async () => ({ id: "" }),
|
|
3291
3294
|
update: async () => ({})
|
|
3292
3295
|
};
|
|
3293
|
-
async function importCommand(
|
|
3296
|
+
async function importCommand(path14, args) {
|
|
3294
3297
|
try {
|
|
3295
|
-
const files = collectYmlFiles(
|
|
3298
|
+
const files = collectYmlFiles(path14);
|
|
3296
3299
|
const fixtures = files.map(
|
|
3297
3300
|
(f) => parseFixture(readFileSync2(f, "utf8"), relative(process.cwd(), f))
|
|
3298
3301
|
);
|
|
@@ -5061,10 +5064,12 @@ async function resolveInstallLayout(args, cwd = process.cwd()) {
|
|
|
5061
5064
|
const target = requested ?? await detectTarget(cwd) ?? "claude";
|
|
5062
5065
|
if (target === "codex") {
|
|
5063
5066
|
const root = args.global ? path4.join(os2.homedir(), ".codex") : cwd;
|
|
5067
|
+
const claudeFile = path4.join(root, "CLAUDE.md");
|
|
5064
5068
|
return {
|
|
5065
5069
|
target,
|
|
5066
5070
|
baseDir: args.dir ? path4.resolve(args.dir) : path4.join(root, "hcm-skills"),
|
|
5067
|
-
agentsFile: path4.join(root, "AGENTS.md")
|
|
5071
|
+
agentsFile: path4.join(root, "AGENTS.md"),
|
|
5072
|
+
companionAgentFiles: !args.global && await exists(claudeFile) ? [claudeFile] : []
|
|
5068
5073
|
};
|
|
5069
5074
|
}
|
|
5070
5075
|
return {
|
|
@@ -5449,10 +5454,11 @@ async function skillsInstallCommand(id, args) {
|
|
|
5449
5454
|
target: layout.target,
|
|
5450
5455
|
all
|
|
5451
5456
|
});
|
|
5452
|
-
const
|
|
5457
|
+
const agentIndexes = layout.agentsFile ? await syncAgentIndexes(layout, manifest2) : [];
|
|
5458
|
+
const agents = agentIndexes[0]?.status;
|
|
5453
5459
|
const fmt = args.output ?? "table";
|
|
5454
5460
|
if (fmt === "json" || fmt === "yaml") {
|
|
5455
|
-
process.stdout.write(formatObject16({ ...result, all, target_agent: layout.target, agentsFile: layout.agentsFile, agents, conflictCheck: conflictNote ? { checked: false, note: conflictNote } : { checked: true } }, { format: fmt }) + "\n");
|
|
5461
|
+
process.stdout.write(formatObject16({ ...result, all, target_agent: layout.target, agentsFile: layout.agentsFile, agents, agentIndexes, conflictCheck: conflictNote ? { checked: false, note: conflictNote } : { checked: true } }, { format: fmt }) + "\n");
|
|
5456
5462
|
} else {
|
|
5457
5463
|
const headline = all ? `\u2705 \u5168\u90E8 ${requestedIds.length} \u4E2A\u6280\u80FD \u2192 ${result.baseDir}` : `\u2705 ${id} \u2192 ${path4.join(result.baseDir, id, "SKILL.md")}`;
|
|
5458
5464
|
process.stdout.write(`${headline}
|
|
@@ -5472,8 +5478,9 @@ async function skillsInstallCommand(id, args) {
|
|
|
5472
5478
|
process.stdout.write(` \u53C2\u8003\u6587\u4EF6 ${referenceCount} \u4E2A\uFF08references/ \u4E0B\uFF09
|
|
5473
5479
|
`);
|
|
5474
5480
|
}
|
|
5475
|
-
|
|
5476
|
-
|
|
5481
|
+
for (const index of agentIndexes) {
|
|
5482
|
+
const reader = path4.basename(index.file) === "CLAUDE.md" ? "Claude Code" : "Codex";
|
|
5483
|
+
process.stdout.write(` \u5DF2${index.status === "created" ? "\u521B\u5EFA" : "\u66F4\u65B0"} ${index.file} \u91CC\u7684\u6280\u80FD\u7D22\u5F15\uFF08${reader} \u8BFB\u8FD9\u91CC\uFF09
|
|
5477
5484
|
`);
|
|
5478
5485
|
}
|
|
5479
5486
|
process.stdout.write(` \u6765\u6E90 ${endpoint ?? (args.from ? path4.resolve(args.from) : `@hcmai/cli@${CLI_VERSION}`)}
|
|
@@ -5530,28 +5537,33 @@ async function fetchSkillDocument(http, skill, endpoint, base) {
|
|
|
5530
5537
|
references
|
|
5531
5538
|
};
|
|
5532
5539
|
}
|
|
5533
|
-
async function
|
|
5534
|
-
if (!layout.agentsFile) return
|
|
5540
|
+
async function syncAgentIndexes(layout, manifest2) {
|
|
5541
|
+
if (!layout.agentsFile) return [];
|
|
5535
5542
|
const state = await readSkillsState(layout.baseDir);
|
|
5536
|
-
if (!state) return
|
|
5543
|
+
if (!state) return [];
|
|
5537
5544
|
const catalog = /* @__PURE__ */ new Map();
|
|
5538
5545
|
for (const category of manifest2?.categories ?? []) {
|
|
5539
5546
|
for (const skill of category.skills ?? []) catalog.set(skill.id, skill);
|
|
5540
5547
|
}
|
|
5541
|
-
const
|
|
5542
|
-
const
|
|
5543
|
-
|
|
5544
|
-
const
|
|
5545
|
-
|
|
5546
|
-
|
|
5547
|
-
|
|
5548
|
-
|
|
5549
|
-
|
|
5550
|
-
|
|
5551
|
-
|
|
5552
|
-
|
|
5553
|
-
|
|
5554
|
-
|
|
5548
|
+
const files = [layout.agentsFile, ...layout.companionAgentFiles ?? []];
|
|
5549
|
+
const results = [];
|
|
5550
|
+
for (const file of files) {
|
|
5551
|
+
const agentsDir = path4.dirname(file);
|
|
5552
|
+
const entries = Object.keys(state.skills).sort().map((id) => {
|
|
5553
|
+
const known = catalog.get(id);
|
|
5554
|
+
const absolute = path4.join(layout.baseDir, id, "SKILL.md");
|
|
5555
|
+
let relative2 = path4.relative(agentsDir, absolute);
|
|
5556
|
+
if (!relative2.startsWith(".")) relative2 = `./${relative2}`;
|
|
5557
|
+
return {
|
|
5558
|
+
id,
|
|
5559
|
+
title: known?.title ?? id,
|
|
5560
|
+
description: known?.description ?? "",
|
|
5561
|
+
relativePath: relative2.split(path4.sep).join("/")
|
|
5562
|
+
};
|
|
5563
|
+
});
|
|
5564
|
+
results.push({ file, status: await upsertAgentsBlock(file, renderAgentsBlock(entries)) });
|
|
5565
|
+
}
|
|
5566
|
+
return results;
|
|
5555
5567
|
}
|
|
5556
5568
|
async function resolveLocalSkillDocuments(sourceRoot, targetId) {
|
|
5557
5569
|
assertSafeSkillId(targetId);
|
|
@@ -6012,8 +6024,8 @@ async function skillsUpdateCommand(args) {
|
|
|
6012
6024
|
all,
|
|
6013
6025
|
directIds: all ? new Set(plan.documents.map((document) => document.id)) : /* @__PURE__ */ new Set()
|
|
6014
6026
|
});
|
|
6015
|
-
if (layout.agentsFile) await syncAgentsIndex(layout, manifest2);
|
|
6016
6027
|
}
|
|
6028
|
+
if (!args.check && layout.agentsFile) await syncAgentIndexes(layout, manifest2);
|
|
6017
6029
|
const changed = plan.entries.filter((e) => e.status === "updated" || e.status === "added");
|
|
6018
6030
|
const fmt = args.output ?? "table";
|
|
6019
6031
|
if (fmt === "json" || fmt === "yaml") {
|
|
@@ -6256,10 +6268,10 @@ async function metaListCommand(args) {
|
|
|
6256
6268
|
fail5(e, args);
|
|
6257
6269
|
}
|
|
6258
6270
|
}
|
|
6259
|
-
async function metaGetCommand(
|
|
6271
|
+
async function metaGetCommand(path14, args) {
|
|
6260
6272
|
try {
|
|
6261
6273
|
const c = await client2(args);
|
|
6262
|
-
const content = await getTenantMeta(c.raw(),
|
|
6274
|
+
const content = await getTenantMeta(c.raw(), path14);
|
|
6263
6275
|
process.stdout.write(content.endsWith("\n") ? content : content + "\n");
|
|
6264
6276
|
process.exit(0);
|
|
6265
6277
|
} catch (e) {
|
|
@@ -6267,8 +6279,8 @@ async function metaGetCommand(path13, args) {
|
|
|
6267
6279
|
}
|
|
6268
6280
|
}
|
|
6269
6281
|
var PROBEABLE_META_TYPES = /* @__PURE__ */ new Set(["model", "list", "info", "view", "filter", "page", "wiz", "impexp"]);
|
|
6270
|
-
function parseMetaPath(
|
|
6271
|
-
const base =
|
|
6282
|
+
function parseMetaPath(path14) {
|
|
6283
|
+
const base = path14.split(/[\\/]/).pop() ?? path14;
|
|
6272
6284
|
if (!/\.(yml|yaml)$/i.test(base)) return {};
|
|
6273
6285
|
const parts = base.replace(/\.(yml|yaml)$/i, "").split(".");
|
|
6274
6286
|
return { model: parts[0] || void 0, kind: parts[1] ?? "model", state: parts[2] };
|
|
@@ -6285,10 +6297,10 @@ function unverifiableReason(e) {
|
|
|
6285
6297
|
if (st == null) return `\u8BF7\u6C42\u6CA1\u53D1\u51FA\u53BB\u6216\u6CA1\u56DE\u6765\uFF08${err.code ?? err.message ?? "\u672A\u77E5"}\uFF09`;
|
|
6286
6298
|
return void 0;
|
|
6287
6299
|
}
|
|
6288
|
-
async function verifyAfterWrite(c,
|
|
6289
|
-
const { model, kind, state } = parseMetaPath(
|
|
6300
|
+
async function verifyAfterWrite(c, path14) {
|
|
6301
|
+
const { model, kind, state } = parseMetaPath(path14);
|
|
6290
6302
|
if (!model || !kind) {
|
|
6291
|
-
return { status: "unverified", where: "(\u672A\u63A2)", why: `\u4ECE\u8DEF\u5F84 ${
|
|
6303
|
+
return { status: "unverified", where: "(\u672A\u63A2)", why: `\u4ECE\u8DEF\u5F84 ${path14} \u8BA4\u4E0D\u51FA\u6A21\u578B\u540D/\u5C42\u540D` };
|
|
6292
6304
|
}
|
|
6293
6305
|
try {
|
|
6294
6306
|
await clearMetaCache2(c.raw(), model, {});
|
|
@@ -6333,7 +6345,7 @@ async function verifyAfterWrite(c, path13) {
|
|
|
6333
6345
|
}
|
|
6334
6346
|
return { status: "ok" };
|
|
6335
6347
|
}
|
|
6336
|
-
async function metaSetCommand(
|
|
6348
|
+
async function metaSetCommand(path14, args) {
|
|
6337
6349
|
try {
|
|
6338
6350
|
if (!args.file) {
|
|
6339
6351
|
throw new CliError19({
|
|
@@ -6349,9 +6361,9 @@ async function metaSetCommand(path13, args) {
|
|
|
6349
6361
|
process.stdin.on("error", reject);
|
|
6350
6362
|
}) : await fsp3.readFile(args.file, "utf8");
|
|
6351
6363
|
if (!args.skipValidate) {
|
|
6352
|
-
const result2 = validateMetaContent(
|
|
6364
|
+
const result2 = validateMetaContent(path14, content);
|
|
6353
6365
|
if (result2.issues.length > 0) {
|
|
6354
|
-
process.stderr.write(`\u{1F50E} \u5199\u524D\u6821\u9A8C ${
|
|
6366
|
+
process.stderr.write(`\u{1F50E} \u5199\u524D\u6821\u9A8C ${path14}\uFF08schema \u7C7B\u578B\uFF1A${result2.kind ?? "\u672A\u8BC6\u522B"}\uFF09
|
|
6355
6367
|
`);
|
|
6356
6368
|
process.stderr.write(formatMetaIssues(result2, " ") + "\n");
|
|
6357
6369
|
}
|
|
@@ -6370,13 +6382,13 @@ async function metaSetCommand(path13, args) {
|
|
|
6370
6382
|
if (dryFmt === "json" || dryFmt === "yaml") {
|
|
6371
6383
|
process.stdout.write(
|
|
6372
6384
|
formatObject18(
|
|
6373
|
-
{ dryRun: true, path:
|
|
6385
|
+
{ dryRun: true, path: path14, bytes: Buffer.byteLength(content), content },
|
|
6374
6386
|
{ format: dryFmt }
|
|
6375
6387
|
) + "\n"
|
|
6376
6388
|
);
|
|
6377
6389
|
} else {
|
|
6378
6390
|
process.stdout.write(
|
|
6379
|
-
`[dry-run] \u5C06\u5199\u5165 ${
|
|
6391
|
+
`[dry-run] \u5C06\u5199\u5165 ${path14}\uFF08${Buffer.byteLength(content)} B\uFF09\u2014\u2014\u672A\u5B9E\u9645\u5199\u5165
|
|
6380
6392
|
---
|
|
6381
6393
|
${content}
|
|
6382
6394
|
`
|
|
@@ -6389,13 +6401,13 @@ ${content}
|
|
|
6389
6401
|
let backupState = "unknown";
|
|
6390
6402
|
let backupWhy;
|
|
6391
6403
|
try {
|
|
6392
|
-
const prev = await getTenantMeta(c.raw(),
|
|
6404
|
+
const prev = await getTenantMeta(c.raw(), path14);
|
|
6393
6405
|
if (!prev || prev.trim() === "") {
|
|
6394
6406
|
backupState = "absent";
|
|
6395
6407
|
} else {
|
|
6396
6408
|
backupFile = nodePath.join(
|
|
6397
6409
|
os3.tmpdir(),
|
|
6398
|
-
`hcm-meta-backup-${Date.now()}-${
|
|
6410
|
+
`hcm-meta-backup-${Date.now()}-${path14.replace(/[\\/]/g, "_")}`
|
|
6399
6411
|
);
|
|
6400
6412
|
await fsp3.writeFile(backupFile, prev, "utf8");
|
|
6401
6413
|
backupState = "saved";
|
|
@@ -6410,22 +6422,22 @@ ${content}
|
|
|
6410
6422
|
backupWhy = `HTTP ${st ?? "-"}${err.code ? ` ${err.code}` : ""}${err.message ? `\uFF1A${err.message}` : ""}`;
|
|
6411
6423
|
}
|
|
6412
6424
|
}
|
|
6413
|
-
const result = await saveTenantMeta(c.raw(),
|
|
6425
|
+
const result = await saveTenantMeta(c.raw(), path14, content);
|
|
6414
6426
|
const fmt = args.output ?? "json";
|
|
6415
|
-
if (fmt !== "json") process.stdout.write(`\u2705 \u5DF2\u5199\u5165 ${
|
|
6427
|
+
if (fmt !== "json") process.stdout.write(`\u2705 \u5DF2\u5199\u5165 ${path14}
|
|
6416
6428
|
`);
|
|
6417
6429
|
const restoreHint = backupState === "saved" && backupFile ? ` \u65E7\u5185\u5BB9\u5DF2\u5B58\uFF1A${backupFile}
|
|
6418
|
-
\u653E\u56DE\u53BB\uFF1Ahcm meta set ${
|
|
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 ${
|
|
6430
|
+
\u653E\u56DE\u53BB\uFF1Ahcm meta set ${path14} --file ${backupFile}${connFlags(args)}
|
|
6431
|
+
` : 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 ${path14}${connFlags(args)}
|
|
6420
6432
|
` : ` \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
|
|
6421
|
-
\u5148\u81EA\u5DF1\u8BFB\u4E00\u904D\u786E\u8BA4\uFF1Ahcm meta get ${
|
|
6433
|
+
\u5148\u81EA\u5DF1\u8BFB\u4E00\u904D\u786E\u8BA4\uFF1Ahcm meta get ${path14}${connFlags(args)}
|
|
6422
6434
|
`;
|
|
6423
6435
|
if (args.verify === false) {
|
|
6424
6436
|
process.stderr.write(
|
|
6425
6437
|
"\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
|
|
6426
6438
|
);
|
|
6427
6439
|
} else {
|
|
6428
|
-
const outcome = await verifyAfterWrite(c,
|
|
6440
|
+
const outcome = await verifyAfterWrite(c, path14);
|
|
6429
6441
|
if (outcome.status === "broken") {
|
|
6430
6442
|
const human = explainJacksonError(outcome.raw);
|
|
6431
6443
|
process.stderr.write(
|
|
@@ -6457,19 +6469,19 @@ ${content}
|
|
|
6457
6469
|
fail5(e, args);
|
|
6458
6470
|
}
|
|
6459
6471
|
}
|
|
6460
|
-
async function metaDeleteCommand(
|
|
6472
|
+
async function metaDeleteCommand(path14, args) {
|
|
6461
6473
|
try {
|
|
6462
6474
|
if (!args.yes) {
|
|
6463
|
-
const ok = await promptConfirm(`\u5C06\u5220\u9664\u5143\u6570\u636E ${
|
|
6475
|
+
const ok = await promptConfirm(`\u5C06\u5220\u9664\u5143\u6570\u636E ${path14}\uFF0C\u6B64\u64CD\u4F5C\u4E0D\u53EF\u9006\u3002\u7EE7\u7EED\uFF1F`);
|
|
6464
6476
|
if (!ok) {
|
|
6465
6477
|
process.stderr.write("\u5DF2\u53D6\u6D88\n");
|
|
6466
6478
|
process.exit(1);
|
|
6467
6479
|
}
|
|
6468
6480
|
}
|
|
6469
6481
|
const c = await client2(args);
|
|
6470
|
-
const result = await deleteTenantMeta(c.raw(),
|
|
6482
|
+
const result = await deleteTenantMeta(c.raw(), path14);
|
|
6471
6483
|
const fmt = args.output ?? "json";
|
|
6472
|
-
if (fmt !== "json") process.stdout.write(`\u{1F5D1}\uFE0F \u5DF2\u5220\u9664 ${
|
|
6484
|
+
if (fmt !== "json") process.stdout.write(`\u{1F5D1}\uFE0F \u5DF2\u5220\u9664 ${path14}
|
|
6473
6485
|
`);
|
|
6474
6486
|
process.stdout.write(formatObject18(result, { format: fmt }) + "\n");
|
|
6475
6487
|
process.exit(0);
|
|
@@ -6477,7 +6489,7 @@ async function metaDeleteCommand(path13, args) {
|
|
|
6477
6489
|
fail5(e, args);
|
|
6478
6490
|
}
|
|
6479
6491
|
}
|
|
6480
|
-
async function metaValidateCommand(
|
|
6492
|
+
async function metaValidateCommand(path14, args) {
|
|
6481
6493
|
try {
|
|
6482
6494
|
if (!args.file) {
|
|
6483
6495
|
throw new CliError19({
|
|
@@ -6492,13 +6504,13 @@ async function metaValidateCommand(path13, args) {
|
|
|
6492
6504
|
process.stdin.on("end", () => resolve4(buf));
|
|
6493
6505
|
process.stdin.on("error", reject);
|
|
6494
6506
|
}) : await fsp3.readFile(args.file, "utf8");
|
|
6495
|
-
const result = validateMetaContent(
|
|
6507
|
+
const result = validateMetaContent(path14, content);
|
|
6496
6508
|
const fmt = args.output ?? "table";
|
|
6497
6509
|
if (fmt === "json" || fmt === "yaml") {
|
|
6498
6510
|
process.stdout.write(
|
|
6499
6511
|
formatObject18(
|
|
6500
6512
|
{
|
|
6501
|
-
path:
|
|
6513
|
+
path: path14,
|
|
6502
6514
|
kind: result.kind,
|
|
6503
6515
|
schemaKnown: result.schemaKnown,
|
|
6504
6516
|
schemaSourceCommit: META_SCHEMA_SOURCE_COMMIT,
|
|
@@ -6510,7 +6522,7 @@ async function metaValidateCommand(path13, args) {
|
|
|
6510
6522
|
);
|
|
6511
6523
|
} else {
|
|
6512
6524
|
process.stdout.write(
|
|
6513
|
-
`\u{1F50E} ${
|
|
6525
|
+
`\u{1F50E} ${path14}\uFF08schema \u7C7B\u578B\uFF1A${result.kind ?? "\u672A\u8BC6\u522B"}\uFF0C\u6765\u6E90 ${META_SCHEMA_SOURCE_COMMIT.slice(0, 8)}\uFF09
|
|
6514
6526
|
`
|
|
6515
6527
|
);
|
|
6516
6528
|
process.stdout.write(
|
|
@@ -7887,7 +7899,13 @@ async function workspaceActivateCommand(workspaceKey, args) {
|
|
|
7887
7899
|
|
|
7888
7900
|
// src/commands/identity.ts
|
|
7889
7901
|
init_exit();
|
|
7902
|
+
import axios4 from "axios";
|
|
7890
7903
|
import {
|
|
7904
|
+
AUTH_INFO_PATH,
|
|
7905
|
+
CliError as CliError20,
|
|
7906
|
+
CliErrorCode as CliErrorCode19,
|
|
7907
|
+
formatObject as formatObject20,
|
|
7908
|
+
fromAxiosError as fromAxiosError20,
|
|
7891
7909
|
loadEnv as loadEnv8,
|
|
7892
7910
|
saveEnv as saveEnv3,
|
|
7893
7911
|
loadIdentity as loadIdentity4,
|
|
@@ -7895,9 +7913,53 @@ import {
|
|
|
7895
7913
|
deleteIdentity as deleteIdentity2,
|
|
7896
7914
|
loadGlobalConfig as loadGlobalConfig8,
|
|
7897
7915
|
TokenStore as TokenStore3,
|
|
7898
|
-
|
|
7899
|
-
CliErrorCode as CliErrorCode19
|
|
7916
|
+
toPrincipal
|
|
7900
7917
|
} from "@hcmai/sdk";
|
|
7918
|
+
var fetchAuthInfo = async (endpoint, accessToken) => {
|
|
7919
|
+
const response = await axios4.get(`${endpoint.replace(/\/$/, "")}${AUTH_INFO_PATH}`, {
|
|
7920
|
+
headers: { Authorization: `Bearer ${accessToken}` },
|
|
7921
|
+
timeout: 3e4
|
|
7922
|
+
});
|
|
7923
|
+
return response.data;
|
|
7924
|
+
};
|
|
7925
|
+
async function inspectIdentity(name, fetcher = fetchAuthInfo) {
|
|
7926
|
+
const meta2 = await loadIdentity4(name);
|
|
7927
|
+
const env2 = await loadEnv8(meta2.env);
|
|
7928
|
+
const accessToken = await TokenStore3.forIdentity(name).getStoredAccessToken();
|
|
7929
|
+
if (!accessToken) {
|
|
7930
|
+
throw new CliError20({
|
|
7931
|
+
code: CliErrorCode19.AUTH_FAILED,
|
|
7932
|
+
message: `identity '${name}' \u6CA1\u6709\u53EF\u8BFB\u53D6\u7684\u6301\u4E45\u5316 token`,
|
|
7933
|
+
context: { nextStep: `\u91CD\u65B0\u767B\u5F55\u8BE5\u8EAB\u4EFD\uFF1Ahcm login --env ${meta2.env} --name ${name}` }
|
|
7934
|
+
});
|
|
7935
|
+
}
|
|
7936
|
+
const raw = await fetcher(env2.endpoint, accessToken);
|
|
7937
|
+
const principal = toPrincipal(raw);
|
|
7938
|
+
const body = raw && typeof raw === "object" && !Array.isArray(raw) ? raw : {};
|
|
7939
|
+
const serverScopes = Array.isArray(body.scopes) ? body.scopes.map(String) : void 0;
|
|
7940
|
+
return {
|
|
7941
|
+
identity: name,
|
|
7942
|
+
env: meta2.env,
|
|
7943
|
+
endpoint: env2.endpoint,
|
|
7944
|
+
scheme: meta2.scheme,
|
|
7945
|
+
userId: principal?.userId ?? null,
|
|
7946
|
+
username: principal?.username ?? null,
|
|
7947
|
+
tenantId: principal?.tenantId ?? null,
|
|
7948
|
+
// null 明确表示服务端没回该字段;[] 才表示服务端确认角色为空。
|
|
7949
|
+
roles: principal?.roles ?? null,
|
|
7950
|
+
scopes: serverScopes ?? meta2.scopes,
|
|
7951
|
+
expiresAt: meta2.expiresAt ?? null,
|
|
7952
|
+
source: AUTH_INFO_PATH
|
|
7953
|
+
};
|
|
7954
|
+
}
|
|
7955
|
+
async function identityShow(name, args) {
|
|
7956
|
+
try {
|
|
7957
|
+
const details = await inspectIdentity(name);
|
|
7958
|
+
exitOk(formatObject20(details, { format: args.output ?? "json" }));
|
|
7959
|
+
} catch (e) {
|
|
7960
|
+
exitWithError(axios4.isAxiosError(e) ? fromAxiosError20(e, name) : e);
|
|
7961
|
+
}
|
|
7962
|
+
}
|
|
7901
7963
|
async function identityList(args) {
|
|
7902
7964
|
try {
|
|
7903
7965
|
const g = await loadGlobalConfig8();
|
|
@@ -7966,7 +8028,7 @@ import { join as pathJoin } from "path";
|
|
|
7966
8028
|
import {
|
|
7967
8029
|
HcmClient as HcmClient20,
|
|
7968
8030
|
classifyEffect,
|
|
7969
|
-
formatObject as
|
|
8031
|
+
formatObject as formatObject21
|
|
7970
8032
|
} from "@hcmai/sdk";
|
|
7971
8033
|
|
|
7972
8034
|
// src/commands/delivery.ts
|
|
@@ -8594,7 +8656,7 @@ function withProjectReadiness(assessment, projectRoot = ".") {
|
|
|
8594
8656
|
deliveryMode,
|
|
8595
8657
|
requirements: requirements2,
|
|
8596
8658
|
modePolicy: assessment.modePolicy ? { ...assessment.modePolicy, controlled: "deny" } : assessment.modePolicy,
|
|
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>"
|
|
8659
|
+
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 --approved-by '<\u9879\u76EE\u8D1F\u8D23\u4EBA>' --reason '<\u672C\u6B21\u5BF9\u8BDD\u6216\u4EFB\u52A1\u4E66\u4E2D\u7684\u660E\u786E\u6388\u6743\u4F9D\u636E>'\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>"
|
|
8598
8660
|
};
|
|
8599
8661
|
}
|
|
8600
8662
|
if (projectInitialized || !assessment.guardedExecutionAvailable) {
|
|
@@ -8613,7 +8675,7 @@ function withProjectReadiness(assessment, projectRoot = ".") {
|
|
|
8613
8675
|
async function deliveryAssessCommand(argv, args) {
|
|
8614
8676
|
const assessment = await assessEffectiveDeliveryCommand(argv);
|
|
8615
8677
|
const enriched = withProjectReadiness(assessment);
|
|
8616
|
-
process.stdout.write(
|
|
8678
|
+
process.stdout.write(formatObject21(enriched, { format: args.output ?? "json" }) + "\n");
|
|
8617
8679
|
}
|
|
8618
8680
|
async function resolveCoreAction(request) {
|
|
8619
8681
|
try {
|
|
@@ -8722,10 +8784,10 @@ function flagValue2(argv, flag) {
|
|
|
8722
8784
|
|
|
8723
8785
|
// src/commands/delivery-init.ts
|
|
8724
8786
|
init_exit();
|
|
8725
|
-
import { promises as
|
|
8726
|
-
import
|
|
8787
|
+
import { promises as fs8 } from "fs";
|
|
8788
|
+
import path8 from "path";
|
|
8727
8789
|
import {
|
|
8728
|
-
formatObject as
|
|
8790
|
+
formatObject as formatObject22,
|
|
8729
8791
|
loadEnv as loadEnv9,
|
|
8730
8792
|
loadGlobalConfig as loadGlobalConfig9,
|
|
8731
8793
|
resolveActiveEnv as resolveActiveEnv5
|
|
@@ -8734,6 +8796,157 @@ import {
|
|
|
8734
8796
|
// src/commands/delivery-project-scaffold.ts
|
|
8735
8797
|
import { promises as fs6 } from "fs";
|
|
8736
8798
|
import path6 from "path";
|
|
8799
|
+
|
|
8800
|
+
// src/commands/delivery-page-acceptance.ts
|
|
8801
|
+
function renderPageAcceptanceSh() {
|
|
8802
|
+
return [
|
|
8803
|
+
"#!/usr/bin/env bash",
|
|
8804
|
+
"set -euo pipefail",
|
|
8805
|
+
"",
|
|
8806
|
+
"usage() {",
|
|
8807
|
+
" cat >&2 <<'USAGE'",
|
|
8808
|
+
"\u7528\u6CD5\uFF1A",
|
|
8809
|
+
" ./page-acceptance.sh --env <\u73AF\u5883> [--as <\u8EAB\u4EFD>] --path </\u7AD9\u5185\u8DEF\u5F84> \\",
|
|
8810
|
+
" --expect-text <\u9875\u9762\u5FC5\u987B\u51FA\u73B0\u7684\u6587\u672C> [--expect-text <\u6587\u672C> ...] \\",
|
|
8811
|
+
" --out <\u8BC1\u636E/.../\u622A\u56FE.png> [--reject-text <\u4E0D\u5F97\u51FA\u73B0\u7684\u6587\u672C>] \\",
|
|
8812
|
+
" [--wait-ms 10000] [--size 1440x900]",
|
|
8813
|
+
"",
|
|
8814
|
+
"\u8BF4\u660E\uFF1A",
|
|
8815
|
+
" - \u8C03\u7528 hcm open \u94F8\u4E00\u6B21\u6027\u767B\u5F55\u7968\u636E\uFF0C\u5E76\u7ACB\u5373\u4EA4\u7ED9\u672C\u673A Chrome/Chromium\u3002",
|
|
8816
|
+
" - \u622A\u56FE\u53EA\u80FD\u5199\u5165\u9879\u76EE\u7684 \u8BC1\u636E/ \u76EE\u5F55\uFF1B\u5DF2\u6709\u6587\u4EF6\u4E0D\u4F1A\u88AB\u8986\u76D6\u3002",
|
|
8817
|
+
" - \u81F3\u5C11\u4E00\u4E2A --expect-text \u662F\u5FC5\u586B\u9879\uFF0C\u9632\u6B62\u628A\u767B\u5F55\u9875\u6216\u9519\u8BEF\u9875\u8BEF\u8BB0\u6210\u901A\u8FC7\u3002",
|
|
8818
|
+
" - \u6D4F\u89C8\u5668\u672A\u5728 PATH \u65F6\uFF0C\u7528 HCM_CHROME_BIN=/\u7EDD\u5BF9\u8DEF\u5F84 \u6307\u5B9A\u3002",
|
|
8819
|
+
"USAGE",
|
|
8820
|
+
"}",
|
|
8821
|
+
"",
|
|
8822
|
+
"fail() {",
|
|
8823
|
+
` printf '\u9875\u9762\u9A8C\u6536\u5931\u8D25\uFF1A%s\\n' "$1" >&2`,
|
|
8824
|
+
' exit "${2:-1}"',
|
|
8825
|
+
"}",
|
|
8826
|
+
"",
|
|
8827
|
+
"need_value() {",
|
|
8828
|
+
' if (( $# < 2 )) || [[ -z "$2" ]]; then fail "$1 \u7F3A\u5C11\u503C" 2; fi',
|
|
8829
|
+
"}",
|
|
8830
|
+
"",
|
|
8831
|
+
'environment=""',
|
|
8832
|
+
'identity=""',
|
|
8833
|
+
'page_path=""',
|
|
8834
|
+
'output=""',
|
|
8835
|
+
'wait_ms="10000"',
|
|
8836
|
+
'size="1440x900"',
|
|
8837
|
+
"expected_texts=()",
|
|
8838
|
+
"rejected_texts=()",
|
|
8839
|
+
"",
|
|
8840
|
+
"while (( $# > 0 )); do",
|
|
8841
|
+
' case "$1" in',
|
|
8842
|
+
' --env) need_value "$@"; environment="$2"; shift 2 ;;',
|
|
8843
|
+
' --as) need_value "$@"; identity="$2"; shift 2 ;;',
|
|
8844
|
+
' --path) need_value "$@"; page_path="$2"; shift 2 ;;',
|
|
8845
|
+
' --out) need_value "$@"; output="$2"; shift 2 ;;',
|
|
8846
|
+
' --expect-text) need_value "$@"; expected_texts+=("$2"); shift 2 ;;',
|
|
8847
|
+
' --reject-text) need_value "$@"; rejected_texts+=("$2"); shift 2 ;;',
|
|
8848
|
+
' --wait-ms) need_value "$@"; wait_ms="$2"; shift 2 ;;',
|
|
8849
|
+
' --size) need_value "$@"; size="$2"; shift 2 ;;',
|
|
8850
|
+
" -h|--help) usage; exit 0 ;;",
|
|
8851
|
+
' *) fail "\u672A\u77E5\u53C2\u6570\uFF1A$1" 2 ;;',
|
|
8852
|
+
" esac",
|
|
8853
|
+
"done",
|
|
8854
|
+
"",
|
|
8855
|
+
'[[ -n "$environment" ]] || fail "\u5FC5\u987B\u663E\u5F0F\u4F20 --env" 2',
|
|
8856
|
+
'[[ -n "$page_path" ]] || fail "\u5FC5\u987B\u4F20 --path" 2',
|
|
8857
|
+
'[[ "$page_path" == /* ]] || fail "--path \u53EA\u63A5\u53D7\u4EE5 / \u5F00\u5934\u7684\u7AD9\u5185\u8DEF\u5F84" 2',
|
|
8858
|
+
'[[ -n "$output" ]] || fail "\u5FC5\u987B\u4F20 --out" 2',
|
|
8859
|
+
'[[ "$output" == *.png ]] || fail "--out \u5FC5\u987B\u4EE5 .png \u7ED3\u5C3E" 2',
|
|
8860
|
+
'(( ${#expected_texts[@]} > 0 )) || fail "\u81F3\u5C11\u4F20\u4E00\u4E2A --expect-text" 2',
|
|
8861
|
+
'[[ "$wait_ms" =~ ^[0-9]+$ ]] || fail "--wait-ms \u5FC5\u987B\u662F\u6574\u6570" 2',
|
|
8862
|
+
'(( wait_ms >= 0 && wait_ms <= 60000 )) || fail "--wait-ms \u5FC5\u987B\u5728 0..60000" 2',
|
|
8863
|
+
'if [[ "$size" =~ ^([0-9]+)x([0-9]+)$ ]]; then',
|
|
8864
|
+
' width="${BASH_REMATCH[1]}"',
|
|
8865
|
+
' height="${BASH_REMATCH[2]}"',
|
|
8866
|
+
"else",
|
|
8867
|
+
' fail "--size \u5FC5\u987B\u662F <\u5BBD>x<\u9AD8>\uFF0C\u4F8B\u5982 1440x900" 2',
|
|
8868
|
+
"fi",
|
|
8869
|
+
'(( width >= 320 && width <= 7680 && height >= 240 && height <= 7680 )) || fail "--size \u8D85\u51FA\u5141\u8BB8\u8303\u56F4\uFF08\u5BBD 320..7680\uFF0C\u9AD8 240..7680\uFF09" 2',
|
|
8870
|
+
"",
|
|
8871
|
+
'project_root="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"',
|
|
8872
|
+
'evidence_root="$project_root/\u8BC1\u636E"',
|
|
8873
|
+
'[[ -d "$evidence_root" && ! -L "$evidence_root" ]] || fail "\u9879\u76EE\u7684 \u8BC1\u636E/ \u5FC5\u987B\u662F\u666E\u901A\u76EE\u5F55\uFF0C\u4E0D\u80FD\u662F\u7B26\u53F7\u94FE\u63A5"',
|
|
8874
|
+
`out_abs="$(node -e "const p=require('node:path'); const root=p.resolve(process.argv[1],'\u8BC1\u636E'); const out=p.resolve(process.argv[1],process.argv[2]); if(out!==root && !out.startsWith(root+p.sep)){process.stderr.write('--out \u5FC5\u987B\u4F4D\u4E8E\u9879\u76EE\u7684 \u8BC1\u636E/ \u76EE\u5F55\\n'); process.exit(2)} process.stdout.write(out)" "$project_root" "$output")" || exit $?`,
|
|
8875
|
+
'[[ ! -e "$out_abs" && ! -L "$out_abs" ]] || fail "\u622A\u56FE\u5DF2\u5B58\u5728\u6216\u662F\u7B26\u53F7\u94FE\u63A5\uFF0C\u62D2\u7EDD\u8986\u76D6\uFF1A$out_abs"',
|
|
8876
|
+
'mkdir -p "$(dirname "$out_abs")"',
|
|
8877
|
+
'canonical_root="$(cd "$evidence_root" && pwd -P)"',
|
|
8878
|
+
'canonical_parent="$(cd "$(dirname "$out_abs")" && pwd -P)"',
|
|
8879
|
+
'case "$canonical_parent/" in',
|
|
8880
|
+
' "$canonical_root/"*) ;;',
|
|
8881
|
+
' *) fail "--out \u7684\u7236\u76EE\u5F55\u7ECF\u7B26\u53F7\u94FE\u63A5\u9003\u51FA\u4E86 \u8BC1\u636E/\uFF1A$output" ;;',
|
|
8882
|
+
"esac",
|
|
8883
|
+
"",
|
|
8884
|
+
"find_browser() {",
|
|
8885
|
+
' if [[ -n "${HCM_CHROME_BIN:-}" ]]; then',
|
|
8886
|
+
' if [[ -x "$HCM_CHROME_BIN" ]]; then printf "%s" "$HCM_CHROME_BIN"; return 0; fi',
|
|
8887
|
+
' if command -v "$HCM_CHROME_BIN" >/dev/null 2>&1; then command -v "$HCM_CHROME_BIN"; return 0; fi',
|
|
8888
|
+
" return 1",
|
|
8889
|
+
" fi",
|
|
8890
|
+
" local candidate",
|
|
8891
|
+
" for candidate in google-chrome-stable google-chrome chromium chromium-browser; do",
|
|
8892
|
+
' if command -v "$candidate" >/dev/null 2>&1; then command -v "$candidate"; return 0; fi',
|
|
8893
|
+
" done",
|
|
8894
|
+
' for candidate in "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" "/Applications/Chromium.app/Contents/MacOS/Chromium"; do',
|
|
8895
|
+
' if [[ -x "$candidate" ]]; then printf "%s" "$candidate"; return 0; fi',
|
|
8896
|
+
" done",
|
|
8897
|
+
" return 1",
|
|
8898
|
+
"}",
|
|
8899
|
+
"",
|
|
8900
|
+
'command -v hcm >/dev/null 2>&1 || fail "\u627E\u4E0D\u5230 hcm\uFF1B\u5148\u8FD0\u884C ./setup.sh"',
|
|
8901
|
+
'browser="$(find_browser)" || fail "\u627E\u4E0D\u5230 Chrome/Chromium\uFF1B\u8BF7\u8BBE\u7F6E HCM_CHROME_BIN"',
|
|
8902
|
+
'temp_dir="$(mktemp -d "${TMPDIR:-/tmp}/hcm-page-acceptance.XXXXXX")"',
|
|
8903
|
+
"cleanup() {",
|
|
8904
|
+
' case "$temp_dir" in "${TMPDIR:-/tmp}"/hcm-page-acceptance.*) rm -rf -- "$temp_dir" ;; esac',
|
|
8905
|
+
"}",
|
|
8906
|
+
"trap cleanup EXIT",
|
|
8907
|
+
'dom_file="$temp_dir/page.dom"',
|
|
8908
|
+
'browser_log="$temp_dir/browser.log"',
|
|
8909
|
+
"",
|
|
8910
|
+
'hcm_args=(open "$page_path" --env "$environment")',
|
|
8911
|
+
'if [[ -n "$identity" ]]; then hcm_args+=(--as "$identity"); fi',
|
|
8912
|
+
"hcm_args+=(--print-url)",
|
|
8913
|
+
'url="$(hcm "${hcm_args[@]}")" || fail "hcm open \u672A\u80FD\u94F8\u51FA\u9875\u9762\u7968\u636E"',
|
|
8914
|
+
`url="\${url//$'\\r'/}"`,
|
|
8915
|
+
'[[ "$url" == http://* || "$url" == https://* ]] || fail "hcm open \u6CA1\u6709\u8FD4\u56DE\u6709\u6548 URL"',
|
|
8916
|
+
"",
|
|
8917
|
+
"browser_args=(",
|
|
8918
|
+
" --headless=new",
|
|
8919
|
+
" --disable-gpu",
|
|
8920
|
+
" --disable-dev-shm-usage",
|
|
8921
|
+
" --hide-scrollbars",
|
|
8922
|
+
" --no-first-run",
|
|
8923
|
+
" --no-default-browser-check",
|
|
8924
|
+
' "--window-size=$size"',
|
|
8925
|
+
' "--virtual-time-budget=$wait_ms"',
|
|
8926
|
+
' "--screenshot=$out_abs"',
|
|
8927
|
+
" --dump-dom",
|
|
8928
|
+
")",
|
|
8929
|
+
'if [[ "$(id -u)" == "0" ]]; then browser_args+=(--no-sandbox); fi',
|
|
8930
|
+
'if ! "$browser" "${browser_args[@]}" "$url" >"$dom_file" 2>"$browser_log"; then',
|
|
8931
|
+
' sed -E "s/(ticket=)[^&[:space:]]+/\\1<redacted>/g" "$browser_log" >&2 || true',
|
|
8932
|
+
' fail "\u6D4F\u89C8\u5668\u622A\u56FE\u8FDB\u7A0B\u5931\u8D25"',
|
|
8933
|
+
"fi",
|
|
8934
|
+
'[[ -s "$out_abs" ]] || fail "\u6D4F\u89C8\u5668\u672A\u751F\u6210\u975E\u7A7A PNG\uFF1A$out_abs"',
|
|
8935
|
+
"",
|
|
8936
|
+
'for text in "${expected_texts[@]}"; do',
|
|
8937
|
+
' grep -Fq -- "$text" "$dom_file" || fail "\u9875\u9762\u672A\u51FA\u73B0\u671F\u671B\u6587\u672C\uFF1A$text\uFF08\u622A\u56FE\u5DF2\u4FDD\u7559\uFF09"',
|
|
8938
|
+
"done",
|
|
8939
|
+
'for text in "${rejected_texts[@]}"; do',
|
|
8940
|
+
' if grep -Fq -- "$text" "$dom_file"; then fail "\u9875\u9762\u51FA\u73B0\u62D2\u7EDD\u6587\u672C\uFF1A$text\uFF08\u622A\u56FE\u5DF2\u4FDD\u7559\uFF09"; fi',
|
|
8941
|
+
"done",
|
|
8942
|
+
"",
|
|
8943
|
+
'browser_version="$("$browser" --version 2>/dev/null | head -n 1 || true)"',
|
|
8944
|
+
`node -e "const fs=require('node:fs'); const result={ok:true,screenshot:process.argv[1],bytes:fs.statSync(process.argv[1]).size,environment:process.argv[2],identity:process.argv[3]||null,path:process.argv[4],viewport:process.argv[5],waitMs:Number(process.argv[6]),browser:process.argv[7]}; process.stdout.write(JSON.stringify(result)+'\\n')" "$out_abs" "$environment" "$identity" "$page_path" "$size" "$wait_ms" "$browser_version"`,
|
|
8945
|
+
""
|
|
8946
|
+
].join("\n");
|
|
8947
|
+
}
|
|
8948
|
+
|
|
8949
|
+
// src/commands/delivery-project-scaffold.ts
|
|
8737
8950
|
var AGENT_BEGIN = "<!-- hcm-delivery-project:begin -->";
|
|
8738
8951
|
var AGENT_END = "<!-- hcm-delivery-project:end -->";
|
|
8739
8952
|
var GITIGNORE_BEGIN = "# >>> hcm delivery local state >>>";
|
|
@@ -8776,8 +8989,11 @@ function renderAgentInstructions() {
|
|
|
8776
8989
|
"- \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
8990
|
"- \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
8991
|
"- 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
|
-
"-
|
|
8992
|
+
"- R2 \u5199\u6388\u6743\u53EA\u8BA4\u53EF\u9879\u76EE\u8D1F\u8D23\u4EBA\u5728**\u672C\u6B21\u5BF9\u8BDD\u6216\u4EFB\u52A1\u4E66**\u91CC\u7684\u660E\u786E\u6279\u51C6\uFF1B\u5BA2\u6237\u53E3\u5934\u8981\u6C42\u6216\u7FA4\u6D88\u606F\u53EA\u662F\u4E1A\u52A1\u9700\u6C42\uFF0C\u4E0D\u662F\u6267\u884C\u6388\u6743\uFF0C\u4E0D\u80FD\u636E\u6B64\u5207\u5230 controlled \u6216\u6267\u884C\u3002",
|
|
8993
|
+
"- \u5199\u524D\u5FC5\u987B\u8BF4\u660E\u5BF9\u8C61\u3001\u8303\u56F4\u3001\u5F71\u54CD\u4E0E\u56DE\u9000\u5E76\u53D6\u5F97\u672C\u6B21\u660E\u786E\u786E\u8BA4\u3002\u975E\u4EA4\u4E92\u8FD0\u884C\u62FF\u4E0D\u5230\u786E\u8BA4\u65F6\uFF0C\u6700\u591A\u505A\u5230 `prepare`\uFF0C\u7ED3\u8BBA\u5FC5\u987B\u4E3A `BLOCKED` \u5E76\u9644\u8BA1\u5212\uFF1B\u4E0D\u5F97\u81EA\u884C `delivery mode --set controlled` \u6216 `execute`\u3002",
|
|
8994
|
+
"- `.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\u6EE1\u8DB3\u4E0A\u8FF0\u6388\u6743\u65F6\uFF0C\u624D\u80FD\u7528 `--approved-by` \u4E0E `--reason` \u7559\u4E0B\u6A21\u5F0F\u5207\u6362\u6536\u636E\uFF0C\u5B8C\u6210\u540E\u7ACB\u5373\u56DE\u5230 plan-only\u3002\u5BA1\u8BA1\u53C2\u6570\u4E0D\u80FD\u66FF\u4EE3\u771F\u5B9E\u6388\u6743\u3002",
|
|
8780
8995
|
"- \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",
|
|
8996
|
+
"- \u9875\u9762\u9A8C\u6536\u7EDF\u4E00\u7528 `./page-acceptance.sh`\uFF1A\u663E\u5F0F\u4F20\u73AF\u5883\u3001\u8EAB\u4EFD\u3001\u7AD9\u5185\u8DEF\u5F84\u3001\u671F\u671B\u6587\u672C\u4E0E `\u8BC1\u636E/` \u4E0B\u7684 PNG \u8DEF\u5F84\uFF1B\u4E0D\u80FD\u53EA\u4EE5\u201C\u751F\u6210\u4E86\u622A\u56FE\u201D\u5224\u901A\u8FC7\u3002",
|
|
8781
8997
|
"- \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
8998
|
AGENT_END,
|
|
8783
8999
|
""
|
|
@@ -8983,6 +9199,15 @@ async function scaffoldDeliveryProject(root, options) {
|
|
|
8983
9199
|
493
|
|
8984
9200
|
);
|
|
8985
9201
|
if (setupCreated) await fs6.chmod(setupFile, 493);
|
|
9202
|
+
const pageAcceptanceFile = path6.join(root, "page-acceptance.sh");
|
|
9203
|
+
const pageAcceptanceCreated = await writeIfAbsent(
|
|
9204
|
+
pageAcceptanceFile,
|
|
9205
|
+
renderPageAcceptanceSh(),
|
|
9206
|
+
result,
|
|
9207
|
+
"page-acceptance.sh",
|
|
9208
|
+
493
|
|
9209
|
+
);
|
|
9210
|
+
if (pageAcceptanceCreated) await fs6.chmod(pageAcceptanceFile, 493);
|
|
8986
9211
|
await mergeManagedFile(path6.join(root, "AGENTS.md"), mergeAgentInstructions, result, "AGENTS.md");
|
|
8987
9212
|
await mergeManagedFile(path6.join(root, "CLAUDE.md"), mergeAgentInstructions, result, "CLAUDE.md");
|
|
8988
9213
|
await mergeManagedFile(path6.join(root, ".gitignore"), mergeDeliveryGitignore, result, ".gitignore");
|
|
@@ -9050,6 +9275,103 @@ function upsertBlock(existing, begin, end, block) {
|
|
|
9050
9275
|
`;
|
|
9051
9276
|
}
|
|
9052
9277
|
|
|
9278
|
+
// src/commands/delivery-mode-approval.ts
|
|
9279
|
+
import { randomUUID } from "crypto";
|
|
9280
|
+
import { promises as fs7 } from "fs";
|
|
9281
|
+
import path7 from "path";
|
|
9282
|
+
function requireControlledModeApproval(mode, approvedBy, reason) {
|
|
9283
|
+
if (mode !== "controlled") return null;
|
|
9284
|
+
const approver = approvedBy?.trim() ?? "";
|
|
9285
|
+
const approvalReason = reason?.trim() ?? "";
|
|
9286
|
+
if (!approver || !approvalReason) {
|
|
9287
|
+
throw new Error(
|
|
9288
|
+
"\u5207\u6362\u5230 controlled \u5FC5\u987B\u540C\u65F6\u4F20 --approved-by <\u9879\u76EE\u8D1F\u8D23\u4EBA> \u4E0E --reason <\u672C\u6B21\u660E\u786E\u6388\u6743\u4F9D\u636E>\u3002\u6388\u6743\u5FC5\u987B\u6765\u81EA\u9879\u76EE\u8D1F\u8D23\u4EBA\u5728\u672C\u6B21\u5BF9\u8BDD\u6216\u4EFB\u52A1\u4E66\u4E2D\u7684\u660E\u786E\u6279\u51C6\uFF1B\u5BA2\u6237\u53E3\u5934\u6216\u7FA4\u6D88\u606F\u4E0D\u662F\u6267\u884C\u6388\u6743"
|
|
9289
|
+
);
|
|
9290
|
+
}
|
|
9291
|
+
return { approvedBy: approver, reason: approvalReason };
|
|
9292
|
+
}
|
|
9293
|
+
async function setDeliveryModeWithReceipt(input) {
|
|
9294
|
+
const approval = requireControlledModeApproval(input.mode, input.approvedBy, input.reason);
|
|
9295
|
+
const root = path7.resolve(input.project);
|
|
9296
|
+
const projectFile = path7.join(root, ".hcm-delivery", "project.yml");
|
|
9297
|
+
const content = await fs7.readFile(projectFile, "utf8").catch((cause) => {
|
|
9298
|
+
throw new Error(`\u9879\u76EE\u672A\u521D\u59CB\u5316\uFF1A\u627E\u4E0D\u5230 ${projectFile}
|
|
9299
|
+
\u4E0B\u4E00\u6B65\uFF1Ahcm delivery init`, {
|
|
9300
|
+
cause
|
|
9301
|
+
});
|
|
9302
|
+
});
|
|
9303
|
+
const update = setDeliveryModeForEnvironment(content, input.environment, input.mode);
|
|
9304
|
+
const changed = (input.now ?? (() => /* @__PURE__ */ new Date()))();
|
|
9305
|
+
if (Number.isNaN(changed.getTime())) throw new Error("\u5F53\u524D\u65F6\u95F4\u65E0\u6548");
|
|
9306
|
+
let receiptFile = null;
|
|
9307
|
+
if (approval) {
|
|
9308
|
+
const relativeDirectory = path7.join("evidence", "delivery-mode");
|
|
9309
|
+
await ensureReceiptDirectory(root);
|
|
9310
|
+
const safeTime = changed.toISOString().replace(/[:.]/g, "-");
|
|
9311
|
+
const id = (input.receiptId ?? randomUUID)();
|
|
9312
|
+
if (!/^[a-zA-Z0-9-]+$/.test(id)) throw new Error("\u6A21\u5F0F\u5207\u6362\u6536\u636E ID \u975E\u6CD5");
|
|
9313
|
+
receiptFile = path7.join(relativeDirectory, `${safeTime}-${id}.receipt.json`);
|
|
9314
|
+
}
|
|
9315
|
+
const receipt = {
|
|
9316
|
+
schemaVersion: 1,
|
|
9317
|
+
receiptType: "delivery-mode-change",
|
|
9318
|
+
changedAt: changed.toISOString(),
|
|
9319
|
+
project: root,
|
|
9320
|
+
projectFile,
|
|
9321
|
+
environment: input.environment,
|
|
9322
|
+
previous: update.previous,
|
|
9323
|
+
deliveryMode: input.mode,
|
|
9324
|
+
canExecuteR2: input.mode === "controlled",
|
|
9325
|
+
migratedLegacy: update.migratedLegacy,
|
|
9326
|
+
approvedBy: approval?.approvedBy ?? null,
|
|
9327
|
+
reason: approval?.reason ?? null,
|
|
9328
|
+
receiptFile
|
|
9329
|
+
};
|
|
9330
|
+
await fs7.writeFile(projectFile, update.content, "utf8");
|
|
9331
|
+
if (receiptFile) {
|
|
9332
|
+
try {
|
|
9333
|
+
await fs7.writeFile(path7.join(root, receiptFile), `${JSON.stringify(receipt, null, 2)}
|
|
9334
|
+
`, {
|
|
9335
|
+
encoding: "utf8",
|
|
9336
|
+
mode: 384,
|
|
9337
|
+
flag: "wx"
|
|
9338
|
+
});
|
|
9339
|
+
} catch (cause) {
|
|
9340
|
+
try {
|
|
9341
|
+
await fs7.writeFile(projectFile, content, "utf8");
|
|
9342
|
+
} catch (rollbackCause) {
|
|
9343
|
+
throw new Error(
|
|
9344
|
+
`\u6A21\u5F0F\u5207\u6362\u6536\u636E\u5199\u5165\u5931\u8D25\uFF0C\u4E14 project.yml \u56DE\u6EDA\u5931\u8D25\uFF1A${String(rollbackCause.message)}`,
|
|
9345
|
+
{ cause }
|
|
9346
|
+
);
|
|
9347
|
+
}
|
|
9348
|
+
throw new Error("\u6A21\u5F0F\u5207\u6362\u6536\u636E\u5199\u5165\u5931\u8D25\uFF1Bproject.yml \u5DF2\u56DE\u6EDA\uFF0C\u4ECD\u4FDD\u6301\u539F\u6A21\u5F0F", { cause });
|
|
9349
|
+
}
|
|
9350
|
+
}
|
|
9351
|
+
return receipt;
|
|
9352
|
+
}
|
|
9353
|
+
async function ensureReceiptDirectory(root) {
|
|
9354
|
+
const evidenceDirectory = path7.join(root, "evidence");
|
|
9355
|
+
await ensurePlainDirectory(evidenceDirectory, false);
|
|
9356
|
+
await ensurePlainDirectory(path7.join(evidenceDirectory, "delivery-mode"), true);
|
|
9357
|
+
}
|
|
9358
|
+
async function ensurePlainDirectory(directory, privateDirectory) {
|
|
9359
|
+
let created = false;
|
|
9360
|
+
try {
|
|
9361
|
+
await fs7.mkdir(directory, { mode: privateDirectory ? 448 : 493 });
|
|
9362
|
+
created = true;
|
|
9363
|
+
} catch (cause) {
|
|
9364
|
+
if (cause.code !== "EEXIST") throw cause;
|
|
9365
|
+
}
|
|
9366
|
+
const stat = await fs7.lstat(directory);
|
|
9367
|
+
if (!stat.isDirectory() || stat.isSymbolicLink()) {
|
|
9368
|
+
throw new Error(`\u6A21\u5F0F\u5207\u6362\u6536\u636E\u8DEF\u5F84\u4E0D\u662F\u666E\u901A\u76EE\u5F55\uFF1A${directory}`);
|
|
9369
|
+
}
|
|
9370
|
+
if (privateDirectory || created) {
|
|
9371
|
+
await fs7.chmod(directory, privateDirectory ? 448 : 493);
|
|
9372
|
+
}
|
|
9373
|
+
}
|
|
9374
|
+
|
|
9053
9375
|
// src/commands/delivery-init.ts
|
|
9054
9376
|
function renderProjectYml(environment, mode) {
|
|
9055
9377
|
return [
|
|
@@ -9076,13 +9398,14 @@ async function deliveryInitCommand(args) {
|
|
|
9076
9398
|
\u8FD9\u4E24\u4E2A\u503C\u662F delivery prepare \u8BA4\u5F97\u7684\u5168\u90E8\uFF1B\u5199\u522B\u7684\u503C prepare \u4F1A\u62D2\u7EDD\u52A0\u8F7D\u3002`
|
|
9077
9399
|
);
|
|
9078
9400
|
}
|
|
9401
|
+
const approval = requireControlledModeApproval(mode, args.approvedBy, args.reason);
|
|
9079
9402
|
const environment = await resolveDeliveryEnvironment(args.env);
|
|
9080
|
-
const root =
|
|
9081
|
-
const dir =
|
|
9082
|
-
const file =
|
|
9403
|
+
const root = path8.resolve(args.project ?? ".");
|
|
9404
|
+
const dir = path8.join(root, ".hcm-delivery");
|
|
9405
|
+
const file = path8.join(dir, "project.yml");
|
|
9083
9406
|
let existed = false;
|
|
9084
9407
|
try {
|
|
9085
|
-
await
|
|
9408
|
+
await fs8.access(file);
|
|
9086
9409
|
existed = true;
|
|
9087
9410
|
} catch {
|
|
9088
9411
|
existed = false;
|
|
@@ -9094,8 +9417,8 @@ async function deliveryInitCommand(args) {
|
|
|
9094
9417
|
\u786E\u8981\u91CD\u5199\uFF1Ahcm delivery init --force`
|
|
9095
9418
|
);
|
|
9096
9419
|
}
|
|
9097
|
-
await
|
|
9098
|
-
await
|
|
9420
|
+
await fs8.mkdir(dir, { recursive: true });
|
|
9421
|
+
await fs8.writeFile(file, renderProjectYml(environment, "plan-only"), "utf8");
|
|
9099
9422
|
const environmentConfig = await loadEnv9(environment).catch(() => null);
|
|
9100
9423
|
const scaffold = await scaffoldDeliveryProject(root, {
|
|
9101
9424
|
environment,
|
|
@@ -9103,6 +9426,13 @@ async function deliveryInitCommand(args) {
|
|
|
9103
9426
|
initialMode: mode,
|
|
9104
9427
|
cliVersion: CLI_VERSION
|
|
9105
9428
|
});
|
|
9429
|
+
const modeReceipt = approval ? await setDeliveryModeWithReceipt({
|
|
9430
|
+
project: root,
|
|
9431
|
+
environment,
|
|
9432
|
+
mode,
|
|
9433
|
+
approvedBy: approval.approvedBy,
|
|
9434
|
+
reason: approval.reason
|
|
9435
|
+
}) : null;
|
|
9106
9436
|
const result = {
|
|
9107
9437
|
project: root,
|
|
9108
9438
|
projectFile: file,
|
|
@@ -9110,9 +9440,10 @@ async function deliveryInitCommand(args) {
|
|
|
9110
9440
|
deliveryMode: mode,
|
|
9111
9441
|
overwritten: existed,
|
|
9112
9442
|
scaffold,
|
|
9443
|
+
...modeReceipt ? { modeReceipt } : {},
|
|
9113
9444
|
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"
|
|
9114
9445
|
};
|
|
9115
|
-
process.stdout.write(
|
|
9446
|
+
process.stdout.write(formatObject22(result, { format: args.output ?? "json" }) + "\n");
|
|
9116
9447
|
process.exit(0);
|
|
9117
9448
|
} catch (e) {
|
|
9118
9449
|
exitWithError(e);
|
|
@@ -9121,12 +9452,12 @@ async function deliveryInitCommand(args) {
|
|
|
9121
9452
|
}
|
|
9122
9453
|
async function deliveryModeCommand(args) {
|
|
9123
9454
|
try {
|
|
9124
|
-
const environment =
|
|
9125
|
-
const root =
|
|
9126
|
-
const file =
|
|
9455
|
+
const environment = requireDeliveryModeEnvironment(args.env);
|
|
9456
|
+
const root = path8.resolve(args.project ?? ".");
|
|
9457
|
+
const file = path8.join(root, ".hcm-delivery", "project.yml");
|
|
9127
9458
|
let content;
|
|
9128
9459
|
try {
|
|
9129
|
-
content = await
|
|
9460
|
+
content = await fs8.readFile(file, "utf8");
|
|
9130
9461
|
} catch {
|
|
9131
9462
|
throw new Error(
|
|
9132
9463
|
`\u9879\u76EE\u672A\u521D\u59CB\u5316\uFF1A\u627E\u4E0D\u5230 ${file}
|
|
@@ -9136,7 +9467,7 @@ async function deliveryModeCommand(args) {
|
|
|
9136
9467
|
if (!args.set) {
|
|
9137
9468
|
const current = deliveryModeForEnvironment(content, environment);
|
|
9138
9469
|
process.stdout.write(
|
|
9139
|
-
|
|
9470
|
+
formatObject22(
|
|
9140
9471
|
{
|
|
9141
9472
|
project: root,
|
|
9142
9473
|
projectFile: file,
|
|
@@ -9156,21 +9487,15 @@ async function deliveryModeCommand(args) {
|
|
|
9156
9487
|
if (!DELIVERY_MODES.includes(next)) {
|
|
9157
9488
|
throw new Error(`--set \u53EA\u63A5\u53D7 ${DELIVERY_MODES.join(" | ")}\uFF0C\u6536\u5230 "${args.set}"`);
|
|
9158
9489
|
}
|
|
9159
|
-
const
|
|
9160
|
-
|
|
9490
|
+
const receipt = await setDeliveryModeWithReceipt({
|
|
9491
|
+
project: root,
|
|
9492
|
+
environment,
|
|
9493
|
+
mode: next,
|
|
9494
|
+
approvedBy: args.approvedBy,
|
|
9495
|
+
reason: args.reason
|
|
9496
|
+
});
|
|
9161
9497
|
process.stdout.write(
|
|
9162
|
-
|
|
9163
|
-
{
|
|
9164
|
-
project: root,
|
|
9165
|
-
projectFile: file,
|
|
9166
|
-
environment,
|
|
9167
|
-
deliveryMode: next,
|
|
9168
|
-
previous: update.previous,
|
|
9169
|
-
canExecuteR2: next === "controlled",
|
|
9170
|
-
migratedLegacy: update.migratedLegacy
|
|
9171
|
-
},
|
|
9172
|
-
{ format: args.output ?? "json" }
|
|
9173
|
-
) + "\n"
|
|
9498
|
+
formatObject22(receipt, { format: args.output ?? "json" }) + "\n"
|
|
9174
9499
|
);
|
|
9175
9500
|
process.exit(0);
|
|
9176
9501
|
} catch (e) {
|
|
@@ -9178,6 +9503,15 @@ async function deliveryModeCommand(args) {
|
|
|
9178
9503
|
process.exit(1);
|
|
9179
9504
|
}
|
|
9180
9505
|
}
|
|
9506
|
+
function requireDeliveryModeEnvironment(envFlag) {
|
|
9507
|
+
const environment = envFlag?.trim();
|
|
9508
|
+
if (!environment) {
|
|
9509
|
+
throw new Error(
|
|
9510
|
+
"hcm delivery mode \u5FC5\u987B\u663E\u5F0F\u4F20 --env <\u73AF\u5883\u522B\u540D>\uFF1B\u9879\u76EE\u4EA4\u4ED8\u6A21\u5F0F\u4E0D\u7EE7\u627F\u5168\u5C40 activeEnv\uFF0C\u907F\u514D\u67E5\u770B\u6216\u4FEE\u6539\u9519\u8BEF\u73AF\u5883"
|
|
9511
|
+
);
|
|
9512
|
+
}
|
|
9513
|
+
return environment;
|
|
9514
|
+
}
|
|
9181
9515
|
async function resolveDeliveryEnvironment(envFlag) {
|
|
9182
9516
|
const global = await loadGlobalConfig9();
|
|
9183
9517
|
const environment = resolveActiveEnv5({ envFlag }, process.env, global);
|
|
@@ -9191,8 +9525,8 @@ init_exit();
|
|
|
9191
9525
|
import {
|
|
9192
9526
|
HcmClient as HcmClient21,
|
|
9193
9527
|
fetchReconIdentity,
|
|
9194
|
-
formatObject as
|
|
9195
|
-
fromAxiosError as
|
|
9528
|
+
formatObject as formatObject23,
|
|
9529
|
+
fromAxiosError as fromAxiosError21,
|
|
9196
9530
|
httpProbe,
|
|
9197
9531
|
runDoctor
|
|
9198
9532
|
} from "@hcmai/sdk";
|
|
@@ -9217,11 +9551,11 @@ async function deliveryDoctorCommand(args) {
|
|
|
9217
9551
|
const report = await runDoctor(probe, identity2);
|
|
9218
9552
|
const fmt = args.output ?? "json";
|
|
9219
9553
|
if (fmt !== "json") process.stdout.write(render2(report) + "\n");
|
|
9220
|
-
process.stdout.write(
|
|
9554
|
+
process.stdout.write(formatObject23(report, { format: fmt }) + "\n");
|
|
9221
9555
|
process.exit(report.ok ? 0 : 1);
|
|
9222
9556
|
} catch (e) {
|
|
9223
9557
|
const err = e;
|
|
9224
|
-
if (err?.isAxiosError) exitWithError(
|
|
9558
|
+
if (err?.isAxiosError) exitWithError(fromAxiosError21(err, args.env));
|
|
9225
9559
|
exitWithError(e);
|
|
9226
9560
|
process.exit(1);
|
|
9227
9561
|
}
|
|
@@ -9235,8 +9569,8 @@ import {
|
|
|
9235
9569
|
ReconLayout,
|
|
9236
9570
|
ROUND_EXIT_CODES,
|
|
9237
9571
|
computeReconSourceKey,
|
|
9238
|
-
formatObject as
|
|
9239
|
-
fromAxiosError as
|
|
9572
|
+
formatObject as formatObject24,
|
|
9573
|
+
fromAxiosError as fromAxiosError22,
|
|
9240
9574
|
httpProbe as httpProbe2,
|
|
9241
9575
|
inspectRound,
|
|
9242
9576
|
renderRound,
|
|
@@ -9255,10 +9589,10 @@ async function deliveryReconCommand(args) {
|
|
|
9255
9589
|
onlyModel: args.model ?? null,
|
|
9256
9590
|
identity: ctx.tenantId ? { requestedTenantId: ctx.tenantId } : null
|
|
9257
9591
|
});
|
|
9258
|
-
process.stdout.write(
|
|
9592
|
+
process.stdout.write(formatObject24(summary, { format: args.output ?? "json" }) + "\n");
|
|
9259
9593
|
} catch (e) {
|
|
9260
9594
|
const err = e;
|
|
9261
|
-
if (err?.isAxiosError) exitWithError(
|
|
9595
|
+
if (err?.isAxiosError) exitWithError(fromAxiosError22(err, args.env));
|
|
9262
9596
|
exitWithError(e);
|
|
9263
9597
|
process.exit(1);
|
|
9264
9598
|
}
|
|
@@ -9269,7 +9603,7 @@ async function deliveryReconRoundCommand(args) {
|
|
|
9269
9603
|
const result = inspectRound(args.dir ?? ".");
|
|
9270
9604
|
const fmt = args.output ?? "json";
|
|
9271
9605
|
if (fmt !== "json") process.stdout.write(renderRound(result));
|
|
9272
|
-
process.stdout.write(
|
|
9606
|
+
process.stdout.write(formatObject24(result, { format: fmt }) + "\n");
|
|
9273
9607
|
code = ROUND_EXIT_CODES[result.state];
|
|
9274
9608
|
} catch (e) {
|
|
9275
9609
|
exitWithError(e);
|
|
@@ -9287,14 +9621,14 @@ import {
|
|
|
9287
9621
|
GAP_REASONS,
|
|
9288
9622
|
deriveAclass,
|
|
9289
9623
|
exitCode as gate0ExitCode,
|
|
9290
|
-
formatObject as
|
|
9624
|
+
formatObject as formatObject25,
|
|
9291
9625
|
inspectRound as inspectRound2,
|
|
9292
9626
|
loadProtocolFacts,
|
|
9293
9627
|
scan
|
|
9294
9628
|
} from "@hcmai/sdk";
|
|
9295
|
-
import * as
|
|
9629
|
+
import * as path9 from "path";
|
|
9296
9630
|
function renderGate0(result, skillRoot) {
|
|
9297
|
-
const where = skillRoot ? `\uFF08${
|
|
9631
|
+
const where = skillRoot ? `\uFF08${path9.resolve(skillRoot)}\uFF09` : "";
|
|
9298
9632
|
const lines = [
|
|
9299
9633
|
`\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`
|
|
9300
9634
|
];
|
|
@@ -9332,7 +9666,7 @@ async function deliveryGate0Command(args) {
|
|
|
9332
9666
|
const merged = { ...result, premise: premise5 };
|
|
9333
9667
|
const fmt = args.output ?? "json";
|
|
9334
9668
|
if (fmt !== "json") process.stdout.write(renderGate0(merged, skillRoot));
|
|
9335
|
-
process.stdout.write(`${
|
|
9669
|
+
process.stdout.write(`${formatObject25(merged, { format: fmt })}
|
|
9336
9670
|
`);
|
|
9337
9671
|
for (const problem of premise5) {
|
|
9338
9672
|
process.stderr.write(`\u{1F534} \u524D\u63D0\u4E0D\u6210\u7ACB\uFF08${problem.reason}\uFF09\uFF1A${problem.message}
|
|
@@ -9406,7 +9740,7 @@ import {
|
|
|
9406
9740
|
writeRisk
|
|
9407
9741
|
} from "@hcmai/sdk";
|
|
9408
9742
|
import { existsSync as existsSync3 } from "fs";
|
|
9409
|
-
import * as
|
|
9743
|
+
import * as path10 from "path";
|
|
9410
9744
|
function premise(message, hint = "") {
|
|
9411
9745
|
process.stderr.write(message + (hint ? `
|
|
9412
9746
|
\u2192 ${hint}` : "") + "\n");
|
|
@@ -9433,13 +9767,13 @@ async function runSeedPlan(args, client3) {
|
|
|
9433
9767
|
const reconDir = candidates[0].reconDir;
|
|
9434
9768
|
if (candidates.length > 1) {
|
|
9435
9769
|
process.stderr.write(
|
|
9436
|
-
`\u26A0\uFE0F \u540C\u79DF\u6237\u4E0B\u6709 ${candidates.length} \u4EFD\u57FA\u7EBF\uFF0C\u672C\u8F6E\u8BFB\u7684\u662F \`${
|
|
9770
|
+
`\u26A0\uFE0F \u540C\u79DF\u6237\u4E0B\u6709 ${candidates.length} \u4EFD\u57FA\u7EBF\uFF0C\u672C\u8F6E\u8BFB\u7684\u662F \`${path10.basename(reconDir)}\`\uFF1A` + candidates.slice(1).map((c) => `\`${path10.basename(c.reconDir)}\``).join("\u3001") + " \u672A\u88AB\u8BFB\u53D6 \u2014\u2014 \u4E0D\u540C sourceKey \u7684\u4EA7\u7269**\u4E0D\u53EF\u4E92\u6362**\u3002\n"
|
|
9437
9771
|
);
|
|
9438
9772
|
}
|
|
9439
9773
|
const round = inspectRound3(reconDir);
|
|
9440
9774
|
process.stderr.write(roundWarning(round));
|
|
9441
9775
|
const baseline = {
|
|
9442
|
-
path: `${
|
|
9776
|
+
path: `${path10.basename(path10.dirname(reconDir))}/${path10.basename(reconDir)}`,
|
|
9443
9777
|
roundId: round.roundId ?? null
|
|
9444
9778
|
};
|
|
9445
9779
|
let exemptions = null;
|
|
@@ -9701,7 +10035,7 @@ async function deliverySeedVerifyCommand(args) {
|
|
|
9701
10035
|
// src/commands/delivery-seed-find.ts
|
|
9702
10036
|
import { existsSync as existsSync4 } from "fs";
|
|
9703
10037
|
import { readFileSync as readFileSync6 } from "fs";
|
|
9704
|
-
import * as
|
|
10038
|
+
import * as path11 from "path";
|
|
9705
10039
|
import {
|
|
9706
10040
|
INIT_EXIT_CODES as INIT_EXIT_CODES2,
|
|
9707
10041
|
ValueHints,
|
|
@@ -9715,10 +10049,10 @@ import {
|
|
|
9715
10049
|
valuesRoundCaveat
|
|
9716
10050
|
} from "@hcmai/sdk";
|
|
9717
10051
|
function provenance(chosenReconDir, others) {
|
|
9718
|
-
let line = `> \u57FA\u7EBF\uFF1A\`${
|
|
10052
|
+
let line = `> \u57FA\u7EBF\uFF1A\`${path11.basename(chosenReconDir)}\`
|
|
9719
10053
|
`;
|
|
9720
10054
|
if (others.length > 0) {
|
|
9721
|
-
line += `> \u26A0\uFE0F \u540C\u79DF\u6237\u4E0B\u53E6\u6709 ${others.length} \u4EFD\u57FA\u7EBF\u672A\u88AB\u8BFB\u53D6\uFF1A` + others.map((o) => `\`${
|
|
10055
|
+
line += `> \u26A0\uFE0F \u540C\u79DF\u6237\u4E0B\u53E6\u6709 ${others.length} \u4EFD\u57FA\u7EBF\u672A\u88AB\u8BFB\u53D6\uFF1A` + others.map((o) => `\`${path11.basename(o)}\``).join("\u3001") + " \u2014\u2014 \u4E0D\u540C sourceKey \u7684\u4EA7\u7269**\u4E0D\u53EF\u4E92\u6362**\u3002\n";
|
|
9722
10056
|
}
|
|
9723
10057
|
return `${line}
|
|
9724
10058
|
`;
|
|
@@ -10055,7 +10389,7 @@ import {
|
|
|
10055
10389
|
runTriageRound
|
|
10056
10390
|
} from "@hcmai/sdk";
|
|
10057
10391
|
import { mkdirSync, readFileSync as readFileSync8, writeFileSync as writeFileSync2 } from "fs";
|
|
10058
|
-
import * as
|
|
10392
|
+
import * as path12 from "path";
|
|
10059
10393
|
var DEFAULT_CAPABILITIES4 = "default";
|
|
10060
10394
|
function premise4(message, hint) {
|
|
10061
10395
|
process.stderr.write(`\u{1F534} \u524D\u63D0\u4E0D\u6210\u7ACB\uFF1A${message}
|
|
@@ -10091,8 +10425,8 @@ function renderProblems(rows) {
|
|
|
10091
10425
|
`;
|
|
10092
10426
|
}
|
|
10093
10427
|
function writeTriageArtifact(outDir, body) {
|
|
10094
|
-
const out =
|
|
10095
|
-
mkdirSync(
|
|
10428
|
+
const out = path12.join(outDir, "work", "triage.md");
|
|
10429
|
+
mkdirSync(path12.dirname(out), { recursive: true });
|
|
10096
10430
|
writeFileSync2(out, body, "utf8");
|
|
10097
10431
|
return out;
|
|
10098
10432
|
}
|
|
@@ -10132,9 +10466,9 @@ async function deliveryTriageCommand(args) {
|
|
|
10132
10466
|
// src/commands/delivery-execution.ts
|
|
10133
10467
|
import { createHash as createHash5, randomBytes as secureRandomBytes } from "crypto";
|
|
10134
10468
|
import { spawn as spawn2 } from "child_process";
|
|
10135
|
-
import { createReadStream, promises as
|
|
10136
|
-
import
|
|
10137
|
-
import { CliError as CliError21, CliErrorCode as CliErrorCode20, formatObject as
|
|
10469
|
+
import { createReadStream, promises as fs9 } from "fs";
|
|
10470
|
+
import path13 from "path";
|
|
10471
|
+
import { CliError as CliError21, CliErrorCode as CliErrorCode20, formatObject as formatObject26 } from "@hcmai/sdk";
|
|
10138
10472
|
init_exit();
|
|
10139
10473
|
var EXECUTION_CONTRACT_VERSION = "2026-09-03.controlled-v4";
|
|
10140
10474
|
var DEFAULT_TTL_SECONDS = 15 * 60;
|
|
@@ -10176,11 +10510,11 @@ async function prepareDeliveryExecution(input) {
|
|
|
10176
10510
|
};
|
|
10177
10511
|
const planId = sha2565(canonicalJson(core)).slice(0, 24);
|
|
10178
10512
|
const plan = { ...core, planId };
|
|
10179
|
-
const plansDir =
|
|
10513
|
+
const plansDir = path13.join(project, ".hcm-delivery", "execution-plans");
|
|
10180
10514
|
await safeManagedDirectory(project, ".hcm-delivery/execution-plans", plansDir);
|
|
10181
|
-
const planFile =
|
|
10515
|
+
const planFile = path13.join(plansDir, `${planId}.json`);
|
|
10182
10516
|
try {
|
|
10183
|
-
await
|
|
10517
|
+
await fs9.writeFile(planFile, `${JSON.stringify(plan, null, 2)}
|
|
10184
10518
|
`, {
|
|
10185
10519
|
encoding: "utf8",
|
|
10186
10520
|
mode: 384,
|
|
@@ -10194,7 +10528,7 @@ async function prepareDeliveryExecution(input) {
|
|
|
10194
10528
|
async function executeDeliveryPlan(input) {
|
|
10195
10529
|
if (!PLAN_ID_PATTERN.test(input.planId)) throw invalid2("planId \u5FC5\u987B\u662F 24 \u4F4D\u5C0F\u5199\u5341\u516D\u8FDB\u5236");
|
|
10196
10530
|
const project = await realProject(input.project);
|
|
10197
|
-
const planFile =
|
|
10531
|
+
const planFile = path13.join(project, ".hcm-delivery", "execution-plans", `${input.planId}.json`);
|
|
10198
10532
|
const plan = await readPlan(project, planFile);
|
|
10199
10533
|
if (plan.planId !== input.planId || computePlanId(plan) !== input.planId) {
|
|
10200
10534
|
throw invalid2("\u6267\u884C\u8BA1\u5212\u5185\u5BB9\u4E0E planId \u6458\u8981\u4E0D\u4E00\u81F4");
|
|
@@ -10231,13 +10565,13 @@ async function executeDeliveryPlan(input) {
|
|
|
10231
10565
|
await assertDocumentUnchanged(project, plan.documents.rollback, "\u56DE\u6EDA\u8BF4\u660E");
|
|
10232
10566
|
await assertPayloadsUnchanged(project, plan.payloads);
|
|
10233
10567
|
const evidenceDir = await bindEvidenceDirectory(project, plan.evidenceDir);
|
|
10234
|
-
const receiptFile =
|
|
10568
|
+
const receiptFile = path13.join(evidenceDir.absolute, `${plan.planId}.receipt.json`);
|
|
10235
10569
|
if (await pathExists(receiptFile)) throw invalid2(`\u6267\u884C\u6536\u636E\u5DF2\u5B58\u5728\uFF0C\u62D2\u7EDD\u518D\u6B21\u6267\u884C\uFF1A${plan.planId}`);
|
|
10236
|
-
const claimsDir =
|
|
10570
|
+
const claimsDir = path13.join(project, ".hcm-delivery", "execution-claims");
|
|
10237
10571
|
await safeManagedDirectory(project, ".hcm-delivery/execution-claims", claimsDir);
|
|
10238
|
-
const claimFile =
|
|
10572
|
+
const claimFile = path13.join(claimsDir, `${plan.planId}.json`);
|
|
10239
10573
|
try {
|
|
10240
|
-
await
|
|
10574
|
+
await fs9.writeFile(
|
|
10241
10575
|
claimFile,
|
|
10242
10576
|
`${JSON.stringify({ schemaVersion: 1, planId: plan.planId, claimedAt: now.toISOString() }, null, 2)}
|
|
10243
10577
|
`,
|
|
@@ -10294,7 +10628,7 @@ async function deliveryPrepareCommand(argv, args) {
|
|
|
10294
10628
|
evidenceDir: args.evidenceDir,
|
|
10295
10629
|
...ttlSeconds === void 0 ? {} : { ttlSeconds }
|
|
10296
10630
|
});
|
|
10297
|
-
process.stdout.write(
|
|
10631
|
+
process.stdout.write(formatObject26(plan, { format: args.output ?? "json" }) + "\n");
|
|
10298
10632
|
process.stderr.write(`
|
|
10299
10633
|
\u4E0B\u4E00\u6B65\uFF08argv \u5FC5\u987B\u4E0E\u672C\u6B21\u5B8C\u5168\u4E00\u81F4\uFF09\uFF1A
|
|
10300
10634
|
${nextCommandHint(plan.planId, args.project, argv)}
|
|
@@ -10315,14 +10649,14 @@ async function deliveryExecuteCommand(planId, argv, args) {
|
|
|
10315
10649
|
planId,
|
|
10316
10650
|
argv
|
|
10317
10651
|
});
|
|
10318
|
-
process.stdout.write(
|
|
10652
|
+
process.stdout.write(formatObject26(receipt, { format: args.output ?? "json" }) + "\n");
|
|
10319
10653
|
process.exitCode = receipt.exitCode;
|
|
10320
10654
|
} catch (cause) {
|
|
10321
10655
|
exitWithError(cause);
|
|
10322
10656
|
}
|
|
10323
10657
|
}
|
|
10324
10658
|
async function readProjectMode(project, environment) {
|
|
10325
|
-
const file =
|
|
10659
|
+
const file = path13.join(project, ".hcm-delivery", "project.yml");
|
|
10326
10660
|
const content = await readSafeFile(project, file, "\u9879\u76EE\u914D\u7F6E");
|
|
10327
10661
|
let mode;
|
|
10328
10662
|
try {
|
|
@@ -10338,13 +10672,13 @@ async function readProjectMode(project, environment) {
|
|
|
10338
10672
|
return mode;
|
|
10339
10673
|
}
|
|
10340
10674
|
var SKILLS_LOCK_CANDIDATES = [
|
|
10341
|
-
|
|
10342
|
-
|
|
10675
|
+
path13.join("hcm-skills", ".hcm-skills.json"),
|
|
10676
|
+
path13.join(".claude", "skills", ".hcm-skills.json")
|
|
10343
10677
|
];
|
|
10344
10678
|
async function readSkillsLock(project) {
|
|
10345
10679
|
const found = [];
|
|
10346
10680
|
for (const candidate of SKILLS_LOCK_CANDIDATES) {
|
|
10347
|
-
if (await pathExists(
|
|
10681
|
+
if (await pathExists(path13.join(project, candidate))) found.push(candidate);
|
|
10348
10682
|
}
|
|
10349
10683
|
if (found.length === 0) {
|
|
10350
10684
|
throw invalid2(
|
|
@@ -10356,7 +10690,7 @@ async function readSkillsLock(project) {
|
|
|
10356
10690
|
`\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`
|
|
10357
10691
|
);
|
|
10358
10692
|
}
|
|
10359
|
-
const bytes = await readSafeFile(project,
|
|
10693
|
+
const bytes = await readSafeFile(project, path13.join(project, found[0]), "\u6280\u80FD\u9501");
|
|
10360
10694
|
try {
|
|
10361
10695
|
JSON.parse(bytes.toString("utf8"));
|
|
10362
10696
|
} catch (cause) {
|
|
@@ -10369,7 +10703,7 @@ async function bindDocument(project, reference, label) {
|
|
|
10369
10703
|
if (!(relative2.startsWith("work/") || relative2.startsWith("decisions/"))) {
|
|
10370
10704
|
throw invalid2(`${label}\u5FC5\u987B\u4F4D\u4E8E\u9879\u76EE work/ \u6216 decisions/ \u4E0B`);
|
|
10371
10705
|
}
|
|
10372
|
-
const file =
|
|
10706
|
+
const file = path13.join(project, relative2);
|
|
10373
10707
|
const bytes = await readSafeFile(project, file, label);
|
|
10374
10708
|
return { path: relative2, sha256: sha2565(bytes) };
|
|
10375
10709
|
}
|
|
@@ -10382,11 +10716,11 @@ async function bindEvidenceDirectory(project, reference) {
|
|
|
10382
10716
|
if (!(relative2 === "evidence" || relative2.startsWith("evidence/"))) {
|
|
10383
10717
|
throw invalid2("evidence \u76EE\u5F55\u5FC5\u987B\u4F4D\u4E8E\u9879\u76EE evidence/ \u4E0B");
|
|
10384
10718
|
}
|
|
10385
|
-
const absolute =
|
|
10719
|
+
const absolute = path13.join(project, relative2);
|
|
10386
10720
|
await assertNoSymlinkComponents(project, relative2);
|
|
10387
|
-
const stat = await
|
|
10721
|
+
const stat = await fs9.stat(absolute).catch(() => null);
|
|
10388
10722
|
if (stat === null) {
|
|
10389
|
-
await
|
|
10723
|
+
await fs9.mkdir(absolute, { recursive: true, mode: 448 }).catch((cause) => {
|
|
10390
10724
|
throw invalid2(
|
|
10391
10725
|
`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`,
|
|
10392
10726
|
cause
|
|
@@ -10566,7 +10900,7 @@ async function bindPayloadPath(project, reference, label) {
|
|
|
10566
10900
|
const relative2 = safeRelative(reference, label);
|
|
10567
10901
|
let stat;
|
|
10568
10902
|
try {
|
|
10569
|
-
stat = await
|
|
10903
|
+
stat = await fs9.stat(path13.join(project, relative2));
|
|
10570
10904
|
} catch (cause) {
|
|
10571
10905
|
throw invalid2(
|
|
10572
10906
|
`${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`,
|
|
@@ -10577,10 +10911,10 @@ async function bindPayloadPath(project, reference, label) {
|
|
|
10577
10911
|
}
|
|
10578
10912
|
async function bindPayloadDirectory(project, reference, label) {
|
|
10579
10913
|
const relative2 = reference === "." ? "." : safeRelative(reference, label);
|
|
10580
|
-
const root =
|
|
10914
|
+
const root = path13.join(project, relative2);
|
|
10581
10915
|
let stat;
|
|
10582
10916
|
try {
|
|
10583
|
-
stat = await
|
|
10917
|
+
stat = await fs9.stat(root);
|
|
10584
10918
|
} catch {
|
|
10585
10919
|
throw invalid2(`${label}\u4E0D\u5B58\u5728\uFF1A${relative2}`);
|
|
10586
10920
|
}
|
|
@@ -10590,10 +10924,10 @@ async function bindPayloadDirectory(project, reference, label) {
|
|
|
10590
10924
|
const skipToolingAtRoot = relative2 === ".";
|
|
10591
10925
|
const entries = [];
|
|
10592
10926
|
const walk = async (dir, prefix) => {
|
|
10593
|
-
const items = await
|
|
10927
|
+
const items = await fs9.readdir(dir, { withFileTypes: true });
|
|
10594
10928
|
for (const item of [...items].sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0)) {
|
|
10595
10929
|
if (skipToolingAtRoot && prefix === "" && TOOLING_DIRS.includes(item.name)) continue;
|
|
10596
|
-
const child =
|
|
10930
|
+
const child = path13.join(dir, item.name);
|
|
10597
10931
|
const rel = prefix ? `${prefix}/${item.name}` : item.name;
|
|
10598
10932
|
if (item.isSymbolicLink()) {
|
|
10599
10933
|
throw invalid2(
|
|
@@ -10618,7 +10952,7 @@ ${sha2565(bytes)}`);
|
|
|
10618
10952
|
}
|
|
10619
10953
|
async function bindPayloadFile(project, reference, label) {
|
|
10620
10954
|
const relative2 = safeRelative(reference, label);
|
|
10621
|
-
const file =
|
|
10955
|
+
const file = path13.join(project, relative2);
|
|
10622
10956
|
const bytes = await readSafeFile(project, file, label);
|
|
10623
10957
|
return { path: relative2, kind: "file", sha256: sha2565(bytes) };
|
|
10624
10958
|
}
|
|
@@ -10681,29 +11015,29 @@ async function runCurrentCliCommand(argv, cwd, streams) {
|
|
|
10681
11015
|
async function writeReceiptExclusive(target, receipt) {
|
|
10682
11016
|
const temp = `${target}.${process.pid}.${Date.now()}.tmp`;
|
|
10683
11017
|
try {
|
|
10684
|
-
await
|
|
11018
|
+
await fs9.writeFile(temp, `${JSON.stringify(receipt, null, 2)}
|
|
10685
11019
|
`, {
|
|
10686
11020
|
encoding: "utf8",
|
|
10687
11021
|
mode: 384,
|
|
10688
11022
|
flag: "wx"
|
|
10689
11023
|
});
|
|
10690
|
-
await
|
|
11024
|
+
await fs9.link(temp, target);
|
|
10691
11025
|
} catch (cause) {
|
|
10692
|
-
throw invalid2(`\u6267\u884C\u6536\u636E\u5199\u5165\u5931\u8D25\u6216\u5DF2\u5B58\u5728\uFF1A${
|
|
11026
|
+
throw invalid2(`\u6267\u884C\u6536\u636E\u5199\u5165\u5931\u8D25\u6216\u5DF2\u5B58\u5728\uFF1A${path13.basename(target)}`, cause);
|
|
10693
11027
|
} finally {
|
|
10694
|
-
await
|
|
11028
|
+
await fs9.unlink(temp).catch(() => void 0);
|
|
10695
11029
|
}
|
|
10696
11030
|
}
|
|
10697
11031
|
async function safeManagedDirectory(project, relative2, absolute) {
|
|
10698
|
-
await assertNoSymlinkComponents(project,
|
|
10699
|
-
const existing = await
|
|
11032
|
+
await assertNoSymlinkComponents(project, path13.dirname(relative2));
|
|
11033
|
+
const existing = await fs9.lstat(absolute).catch(() => void 0);
|
|
10700
11034
|
if (existing?.isSymbolicLink()) throw invalid2(`\u53D7\u7BA1\u76EE\u5F55\u4E0D\u80FD\u662F\u7B26\u53F7\u94FE\u63A5\uFF1A${relative2}`);
|
|
10701
11035
|
if (existing && !existing.isDirectory()) throw invalid2(`\u53D7\u7BA1\u8DEF\u5F84\u4E0D\u662F\u76EE\u5F55\uFF1A${relative2}`);
|
|
10702
|
-
if (!existing) await
|
|
10703
|
-
await
|
|
11036
|
+
if (!existing) await fs9.mkdir(absolute, { mode: 448 });
|
|
11037
|
+
await fs9.chmod(absolute, 448);
|
|
10704
11038
|
}
|
|
10705
11039
|
async function pathExists(file) {
|
|
10706
|
-
return
|
|
11040
|
+
return fs9.lstat(file).then(
|
|
10707
11041
|
() => true,
|
|
10708
11042
|
(cause) => {
|
|
10709
11043
|
if (cause.code === "ENOENT") return false;
|
|
@@ -10712,47 +11046,47 @@ async function pathExists(file) {
|
|
|
10712
11046
|
);
|
|
10713
11047
|
}
|
|
10714
11048
|
async function readSafeFile(project, file, label) {
|
|
10715
|
-
const relative2 =
|
|
10716
|
-
if (relative2.startsWith("../") ||
|
|
11049
|
+
const relative2 = path13.relative(project, file).split(path13.sep).join("/");
|
|
11050
|
+
if (relative2.startsWith("../") || path13.isAbsolute(relative2))
|
|
10717
11051
|
throw invalid2(`${label}\u8DEF\u5F84\u9003\u9038\u9879\u76EE`);
|
|
10718
11052
|
await assertNoSymlinkComponents(project, relative2);
|
|
10719
11053
|
let stat;
|
|
10720
11054
|
try {
|
|
10721
|
-
stat = await
|
|
11055
|
+
stat = await fs9.lstat(file);
|
|
10722
11056
|
} catch (cause) {
|
|
10723
11057
|
throw invalid2(`${label}\u4E0D\u53EF\u7528\uFF1A${relative2}`, cause);
|
|
10724
11058
|
}
|
|
10725
11059
|
if (stat.isSymbolicLink()) throw invalid2(`${label}\u4E0D\u80FD\u662F\u7B26\u53F7\u94FE\u63A5\uFF1A${relative2}`);
|
|
10726
11060
|
if (!stat.isFile()) throw invalid2(`${label}\u4E0D\u662F\u666E\u901A\u6587\u4EF6\uFF1A${relative2}`);
|
|
10727
|
-
return
|
|
11061
|
+
return fs9.readFile(file);
|
|
10728
11062
|
}
|
|
10729
11063
|
async function assertNoSymlinkComponents(project, relative2) {
|
|
10730
11064
|
const parts = relative2.split("/").filter(Boolean);
|
|
10731
11065
|
let current = project;
|
|
10732
11066
|
for (const part of parts) {
|
|
10733
|
-
current =
|
|
10734
|
-
const stat = await
|
|
11067
|
+
current = path13.join(current, part);
|
|
11068
|
+
const stat = await fs9.lstat(current).catch(() => void 0);
|
|
10735
11069
|
if (stat?.isSymbolicLink()) throw invalid2(`\u8DEF\u5F84\u5305\u542B\u7B26\u53F7\u94FE\u63A5\uFF1A${relative2}`);
|
|
10736
11070
|
if (!stat) break;
|
|
10737
11071
|
}
|
|
10738
11072
|
}
|
|
10739
11073
|
async function realProject(requested) {
|
|
10740
|
-
const absolute =
|
|
11074
|
+
const absolute = path13.resolve(requested);
|
|
10741
11075
|
let project;
|
|
10742
11076
|
try {
|
|
10743
|
-
project = await
|
|
11077
|
+
project = await fs9.realpath(absolute);
|
|
10744
11078
|
} catch (cause) {
|
|
10745
11079
|
throw invalid2(`\u9879\u76EE\u76EE\u5F55\u4E0D\u53EF\u7528\uFF1A${absolute}`, cause);
|
|
10746
11080
|
}
|
|
10747
|
-
const stat = await
|
|
11081
|
+
const stat = await fs9.stat(project);
|
|
10748
11082
|
if (!stat.isDirectory()) throw invalid2(`\u9879\u76EE\u8DEF\u5F84\u4E0D\u662F\u76EE\u5F55\uFF1A${absolute}`);
|
|
10749
11083
|
return project;
|
|
10750
11084
|
}
|
|
10751
11085
|
function safeRelative(reference, label) {
|
|
10752
|
-
if (!reference ||
|
|
11086
|
+
if (!reference || path13.isAbsolute(reference) || /[\r\n\0]/.test(reference)) {
|
|
10753
11087
|
throw invalid2(`${label}\u5FC5\u987B\u662F\u9879\u76EE\u5185\u76F8\u5BF9\u8DEF\u5F84`);
|
|
10754
11088
|
}
|
|
10755
|
-
const normalized =
|
|
11089
|
+
const normalized = path13.normalize(reference).split(path13.sep).join("/");
|
|
10756
11090
|
if (normalized === ".." || normalized.startsWith("../") || normalized === ".") {
|
|
10757
11091
|
throw invalid2(`${label}\u8DEF\u5F84\u9003\u9038\u9879\u76EE`);
|
|
10758
11092
|
}
|
|
@@ -10819,8 +11153,8 @@ init_exit();
|
|
|
10819
11153
|
import {
|
|
10820
11154
|
HcmClient as HcmClient26,
|
|
10821
11155
|
adminResetPassword,
|
|
10822
|
-
formatObject as
|
|
10823
|
-
fromAxiosError as
|
|
11156
|
+
formatObject as formatObject27,
|
|
11157
|
+
fromAxiosError as fromAxiosError23,
|
|
10824
11158
|
CliError as CliError22,
|
|
10825
11159
|
CliErrorCode as CliErrorCode21
|
|
10826
11160
|
} from "@hcmai/sdk";
|
|
@@ -10853,10 +11187,10 @@ async function userResetPasswordCommand(args) {
|
|
|
10853
11187
|
const request = buildAdminResetPasswordRequest(args, password);
|
|
10854
11188
|
const client3 = HcmClient26.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
10855
11189
|
const result = await adminResetPassword(client3.raw(), request);
|
|
10856
|
-
process.stdout.write(
|
|
11190
|
+
process.stdout.write(formatObject27(result, { format: args.output ?? "json" }) + "\n");
|
|
10857
11191
|
} catch (cause) {
|
|
10858
11192
|
const err = cause;
|
|
10859
|
-
if (err?.isAxiosError) exitWithError(
|
|
11193
|
+
if (err?.isAxiosError) exitWithError(fromAxiosError23(err, args.env));
|
|
10860
11194
|
exitWithError(cause);
|
|
10861
11195
|
}
|
|
10862
11196
|
}
|
|
@@ -10877,8 +11211,8 @@ init_exit();
|
|
|
10877
11211
|
init_auth_guard();
|
|
10878
11212
|
import {
|
|
10879
11213
|
HcmClient as HcmClient27,
|
|
10880
|
-
formatObject as
|
|
10881
|
-
fromAxiosError as
|
|
11214
|
+
formatObject as formatObject28,
|
|
11215
|
+
fromAxiosError as fromAxiosError24
|
|
10882
11216
|
} from "@hcmai/sdk";
|
|
10883
11217
|
async function modelsCommand(keyword, args) {
|
|
10884
11218
|
try {
|
|
@@ -10888,7 +11222,7 @@ async function modelsCommand(keyword, args) {
|
|
|
10888
11222
|
const rows = (needle ? all.filter((m) => JSON.stringify(m).toLowerCase().includes(needle)) : all).sort((a, b) => key(a).localeCompare(key(b)));
|
|
10889
11223
|
const fmt = args.output ?? "table";
|
|
10890
11224
|
if (fmt !== "table") {
|
|
10891
|
-
process.stdout.write(
|
|
11225
|
+
process.stdout.write(formatObject28({ total: rows.length, models: rows }, { format: fmt }) + "\n");
|
|
10892
11226
|
process.exit(0);
|
|
10893
11227
|
}
|
|
10894
11228
|
if (rows.length === 0) {
|
|
@@ -10912,7 +11246,7 @@ async function modelsCommand(keyword, args) {
|
|
|
10912
11246
|
process.exit(0);
|
|
10913
11247
|
} catch (e) {
|
|
10914
11248
|
const err = e;
|
|
10915
|
-
if (err?.isAxiosError) exitWithError(
|
|
11249
|
+
if (err?.isAxiosError) exitWithError(fromAxiosError24(err, args.profile));
|
|
10916
11250
|
exitWithError(e);
|
|
10917
11251
|
}
|
|
10918
11252
|
}
|
|
@@ -10955,6 +11289,7 @@ env.command("show [name]").description("\u663E\u793A env \u8BE6\u60C5\uFF08\u542
|
|
|
10955
11289
|
env.command("edit <field> <value>").description("\u7F16\u8F91 env \u5B57\u6BB5\uFF08endpoint / frontend / tenantId / defaultIdentity / defaultAgent\uFF09").option("--env <name>", "\u76EE\u6807 env \u540D\uFF08\u9ED8\u8BA4\u5F53\u524D activeEnv\uFF09").action((field, value, opts) => envEdit(field, value, opts));
|
|
10956
11290
|
var identity = program.command("identity").description("\u7BA1\u7406 HCM \u8EAB\u4EFD\u51ED\u636E\uFF08env \u4E0B\u7684 identity\uFF09");
|
|
10957
11291
|
identity.command("list").description("\u5217\u51FA identity\uFF08\u9ED8\u8BA4\u5217\u5F53\u524D env\uFF0C--env all \u5217\u5168\u90E8\uFF09").option("--env <name>", '\u8FC7\u6EE4 env\uFF1B\u4F20 "all" \u5217\u5168\u90E8', void 0).action((opts) => identityList(opts));
|
|
11292
|
+
identity.command("show <name>").description("\u5B9E\u65F6\u663E\u793A alias \u5BF9\u5E94\u7684\u670D\u52A1\u7AEF\u7528\u6237\u3001\u79DF\u6237\u4E0E\u89D2\u8272\uFF08\u4E0D\u8F93\u51FA token\uFF09").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((name, opts) => identityShow(name, opts));
|
|
10958
11293
|
identity.command("use <name>").description("\u628A identity \u8BBE\u4E3A\u5176 env \u7684 default identity").action((name) => identityUse(name));
|
|
10959
11294
|
identity.command("remove <name>").description("\u5220\u9664 identity\uFF08\u6E05 token + \u82E5\u662F env default \u5219\u6E05\u7A7A\uFF09").action((name) => identityRemove(name));
|
|
10960
11295
|
var user = program.command("user").description("\u7BA1\u7406\u79DF\u6237\u7528\u6237\u7684\u4E13\u7528\u51ED\u636E\u6D41\u7A0B");
|
|
@@ -11024,8 +11359,8 @@ delivery.command("triage").description(
|
|
|
11024
11359
|
"--recon <dir>",
|
|
11025
11360
|
"\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"
|
|
11026
11361
|
).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));
|
|
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", ".").
|
|
11362
|
+
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("--approved-by <person>", "\u5207\u5230 controlled \u65F6\u5FC5\u586B\uFF1A\u672C\u6B21\u660E\u786E\u6279\u51C6\u7684\u9879\u76EE\u8D1F\u8D23\u4EBA").option("--reason <text>", "\u5207\u5230 controlled \u65F6\u5FC5\u586B\uFF1A\u672C\u6B21\u5BF9\u8BDD\u6216\u4EFB\u52A1\u4E66\u4E2D\u7684\u6388\u6743\u4F9D\u636E").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));
|
|
11363
|
+
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", ".").requiredOption("--env <name>", "\u76EE\u6807\u73AF\u5883\uFF08\u5FC5\u586B\uFF1B\u4E0D\u7EE7\u627F\u5168\u5C40 activeEnv\uFF09").option("--set <mode>", "\u6539\u4E3A\uFF1Acontrolled | plan-only").option("--approved-by <person>", "\u5207\u5230 controlled \u65F6\u5FC5\u586B\uFF1A\u672C\u6B21\u660E\u786E\u6279\u51C6\u7684\u9879\u76EE\u8D1F\u8D23\u4EBA").option("--reason <text>", "\u5207\u5230 controlled \u65F6\u5FC5\u586B\uFF1A\u672C\u6B21\u5BF9\u8BDD\u6216\u4EFB\u52A1\u4E66\u4E2D\u7684\u6388\u6743\u4F9D\u636E").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((opts) => deliveryModeCommand(opts));
|
|
11029
11364
|
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));
|
|
11030
11365
|
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));
|
|
11031
11366
|
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(
|
|
@@ -11105,12 +11440,12 @@ var skills = program.command("skills").description("\u4EA4\u4ED8\u6280\u80FD\uFF
|
|
|
11105
11440
|
skills.command("list [keyword]").description("\u5217\u51FA\u76EE\u6807\u73AF\u5883\u8FD9\u4E00\u7248\u7684\u4EA4\u4ED8\u6280\u80FD\uFF1B--installed \u6539\u770B\u672C\u5730\u88C5\u4E86\u54EA\u4E9B\uFF08\u4E0D\u8FDE\u7F51\uFF09").option("--installed", "\u53EA\u770B\u672C\u5730\u5DF2\u88C5\u7684\u6280\u80FD\uFF08\u8BFB .hcm-skills.json\uFF0C\u4E0D\u8FDE\u7F51\uFF09").option("--target <agent>", "\u914D\u5408 --installed\uFF1Aclaude | codex | auto", "auto").option("--global", "\u914D\u5408 --installed\uFF1A\u770B\u7528\u6237\u7EA7\u76EE\u5F55").option("--dir <path>", "\u914D\u5408 --installed\uFF1A\u770B\u6307\u5B9A\u76EE\u5F55").option("--category <key>", "\u53EA\u770B\u67D0\u4E2A\u5206\u7C7B").option("--stage <key>", "\u53EA\u770B\u67D0\u4E2A\u4EA4\u4ED8\u9636\u6BB5\uFF1Ahandover | baseline | configure | migrate | integrate | golive | operate").option("--by-stage", "\u6309\u4EA4\u4ED8\u751F\u547D\u5468\u671F\u5206\u7EC4\u5C55\u793A\uFF08\u9ED8\u8BA4\u6309\u529F\u80FD\u5206\u7C7B\uFF09").option("--source <kind>", "\u8FD9\u4E00\u8D9F\u770B\u54EA\u4E9B\u6765\u6E90\uFF1Acli\uFF08\u53EA\u770B\u81EA\u5E26\uFF0C\u4E0D\u8FDE\u7F51\uFF09| chiron | all", "all").option("--endpoint <url>", "\u6280\u80FD\u5E93\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", "table").action((kw, opts) => skillsListCommand(kw, opts));
|
|
11106
11441
|
skills.command("manifest").description("\u6253\u5370\u672C CLI \u7684\u547D\u4EE4\u9762\u4E0E\u81EA\u5E26\u6280\u80FD\u6E05\u5355\uFF08\u4E0D\u8FDE\u7F51\uFF0C\u4F9B\u5B88\u536B\u4E0E\u5916\u90E8\u5DE5\u5177\u6BD4\u5BF9\uFF09").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((opts) => skillsManifestCommand(program, opts));
|
|
11107
11442
|
skills.command("show <id>").description("\u6253\u5370\u6280\u80FD\u539F\u6587\uFF08\u7BA1\u9053\u53CB\u597D\uFF09\uFF1B\u81EA\u5E26\u6280\u80FD\u76F4\u63A5\u8BFB\u672C\u5730\uFF0C\u4E0D\u8FDE\u7F51").option("--source <kind>", "\u8FD9\u4E00\u8D9F\u770B\u54EA\u4E9B\u6765\u6E90\uFF1Acli\uFF08\u53EA\u770B\u81EA\u5E26\uFF0C\u4E0D\u8FDE\u7F51\uFF09| chiron | all", "all").option("--endpoint <url>", "\u6280\u80FD\u5E93\u5730\u5740\uFF08\u9ED8\u8BA4\u53D6 activeEnv \u7684 endpoint\uFF09").option("--env <name>", "\u4ECE\u8BE5 env \u89E3\u6790 endpoint").action((id, opts) => skillsShowCommand(id, opts));
|
|
11108
|
-
skills.command("install [id]").description("\u8FDE\u540C requires \u524D\u7F6E\u6280\u80FD\u4E0E\u53C2\u8003\u6587\u4EF6\u88C5\u5230 agent \u6280\u80FD\u76EE\u5F55\uFF1B--all \u88C5\u6574\u4E2A\u6280\u80FD\u5E93").option("--all", "\u88C5\u6574\u4E2A\u6280\u80FD\u5E93\uFF0C\u5E76\u8BB0\u4E3A\u300C\u8DDF\u968F\u5168\u96C6\u300D\uFF08\u5F80\u540E update \u4F1A\u81EA\u52A8\u8865\u4E0A\u4EA7\u54C1\u65B0\u589E\u7684\u6280\u80FD\uFF09").option("--target <agent>", "\u88C5\u7ED9\u54EA\u4E2A agent\uFF1Aclaude\uFF08.claude/skills/\uFF09| codex\uFF08hcm-skills/ +
|
|
11443
|
+
skills.command("install [id]").description("\u8FDE\u540C requires \u524D\u7F6E\u6280\u80FD\u4E0E\u53C2\u8003\u6587\u4EF6\u88C5\u5230 agent \u6280\u80FD\u76EE\u5F55\uFF1B--all \u88C5\u6574\u4E2A\u6280\u80FD\u5E93").option("--all", "\u88C5\u6574\u4E2A\u6280\u80FD\u5E93\uFF0C\u5E76\u8BB0\u4E3A\u300C\u8DDF\u968F\u5168\u96C6\u300D\uFF08\u5F80\u540E update \u4F1A\u81EA\u52A8\u8865\u4E0A\u4EA7\u54C1\u65B0\u589E\u7684\u6280\u80FD\uFF09").option("--target <agent>", "\u88C5\u7ED9\u54EA\u4E2A agent\uFF1Aclaude\uFF08.claude/skills/\uFF09| codex\uFF08hcm-skills/ + Agent \u7D22\u5F15\uFF09| auto", "auto").option("--global", "\u88C5\u5230\u7528\u6237\u7EA7\u76EE\u5F55\u800C\u975E\u5F53\u524D\u9879\u76EE").option("--dir <path>", "\u88C5\u5230\u6307\u5B9A\u76EE\u5F55").option("--from <dir>", "\u4ECE\u672C\u5730\u76EE\u5F55\u88C5\uFF08\u73B0\u573A\u6539\u8FC7\u7684\u7248\u672C\uFF09\uFF0C\u4E0D\u8D70\u7F51\u7EDC").option("--source <kind>", "\u8FD9\u4E00\u8D9F\u770B\u54EA\u4E9B\u6765\u6E90\uFF1Acli\uFF08\u53EA\u770B\u81EA\u5E26\uFF0C\u4E0D\u8FDE\u7F51\uFF09| chiron | all", "all").option("--force", "\u8986\u76D6\u5DF2\u5B58\u5728\u7684\u540C\u540D\u6280\u80FD").option("--endpoint <url>", "\u6280\u80FD\u5E93\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", "table").action((id, opts) => skillsInstallCommand(id, opts));
|
|
11109
11444
|
skills.command("update").description("\u628A\u88C5\u8FC7\u7684\u6280\u80FD\u5347\u5230\u76EE\u6807\u73AF\u5883\u8FD9\u4E00\u7248\uFF08\u4EA7\u54C1\u5347\u7EA7\u540E\u8DD1\u5B83\uFF09").option("--all", "\u8FDE\u4EA7\u54C1\u65B0\u589E\u7684\u6280\u80FD\u4E00\u8D77\u88C5\u4E0A\uFF0C\u5E76\u8BB0\u4E3A\u300C\u8DDF\u968F\u5168\u96C6\u300D").option("--check", "\u53EA\u770B\u4F1A\u53D8\u4EC0\u4E48\uFF0C\u4E0D\u5199\u76D8").option("--target <agent>", "claude | codex | auto\uFF08\u9ED8\u8BA4\u6309\u5DF2\u5B89\u88C5\u76EE\u5F55\u63A2\uFF09", "auto").option("--global", "\u5347\u7EA7\u7528\u6237\u7EA7\u76EE\u5F55\u91CC\u7684\u6280\u80FD").option("--dir <path>", "\u5347\u7EA7\u6307\u5B9A\u76EE\u5F55\u91CC\u7684\u6280\u80FD").option("--force", "\u8FDE\u672C\u5730\u6539\u8FC7\u7684\u6280\u80FD\u4E00\u8D77\u8986\u76D6\u6210\u4EA7\u54C1\u8FD9\u4E00\u7248").option("--source <kind>", "\u8FD9\u4E00\u8D9F\u770B\u54EA\u4E9B\u6765\u6E90\uFF1Acli\uFF08\u53EA\u770B\u81EA\u5E26\uFF0C\u4E0D\u8FDE\u7F51\uFF09| chiron | all", "all").option("--endpoint <url>", "\u6280\u80FD\u5E93\u5730\u5740\uFF08\u9ED8\u8BA4\u53D6\u5B89\u88C5\u65F6\u8BB0\u5F55\u7684\u5730\u5740\uFF09").option("--env <name>", "\u4ECE\u8BE5 env \u89E3\u6790 endpoint").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((opts) => skillsUpdateCommand(opts));
|
|
11110
11445
|
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));
|
|
11111
11446
|
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));
|
|
11112
11447
|
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));
|
|
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((
|
|
11448
|
+
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((path14, opts) => openCommand(path14, opts));
|
|
11114
11449
|
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");
|
|
11115
11450
|
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));
|
|
11116
11451
|
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));
|