@hcmai/cli 0.3.17 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +417 -72
- package/dist/index.js.map +1 -1
- package/dist/skills/hcm-delivery-seed/SKILL.md +333 -0
- package/dist/skills/llms.txt +1 -0
- package/dist/skills/manifest.json +63 -1
- 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(path11) {
|
|
527
|
+
const segs = path11.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(path11) {
|
|
1710
|
+
const segs = (path11 ?? "").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
|
}
|
|
@@ -1955,7 +1955,7 @@ var init_readline = __esm({
|
|
|
1955
1955
|
|
|
1956
1956
|
// src/index.ts
|
|
1957
1957
|
import { Command } from "commander";
|
|
1958
|
-
import { migrateLegacyProfiles } from "@hcmai/sdk";
|
|
1958
|
+
import { LEDGER_ONLY_FLAG, migrateLegacyProfiles } from "@hcmai/sdk";
|
|
1959
1959
|
|
|
1960
1960
|
// src/package-version.ts
|
|
1961
1961
|
import { readFileSync } from "fs";
|
|
@@ -3084,8 +3084,8 @@ import {
|
|
|
3084
3084
|
formatObject as formatObject7,
|
|
3085
3085
|
fromAxiosError as fromAxiosError8
|
|
3086
3086
|
} from "@hcmai/sdk";
|
|
3087
|
-
function collectYmlFiles(
|
|
3088
|
-
if (statSync(
|
|
3087
|
+
function collectYmlFiles(path11) {
|
|
3088
|
+
if (statSync(path11).isFile()) return [path11];
|
|
3089
3089
|
const out = [];
|
|
3090
3090
|
const walk = (dir) => {
|
|
3091
3091
|
for (const name of readdirSync(dir).sort()) {
|
|
@@ -3094,7 +3094,7 @@ function collectYmlFiles(path10) {
|
|
|
3094
3094
|
else if (full.endsWith(".yml") || full.endsWith(".yaml")) out.push(full);
|
|
3095
3095
|
}
|
|
3096
3096
|
};
|
|
3097
|
-
walk(
|
|
3097
|
+
walk(path11);
|
|
3098
3098
|
return out.sort();
|
|
3099
3099
|
}
|
|
3100
3100
|
var DRY_RUN_CLIENT = {
|
|
@@ -3102,9 +3102,9 @@ var DRY_RUN_CLIENT = {
|
|
|
3102
3102
|
create: async () => ({ id: "" }),
|
|
3103
3103
|
update: async () => ({})
|
|
3104
3104
|
};
|
|
3105
|
-
async function importCommand(
|
|
3105
|
+
async function importCommand(path11, args) {
|
|
3106
3106
|
try {
|
|
3107
|
-
const files = collectYmlFiles(
|
|
3107
|
+
const files = collectYmlFiles(path11);
|
|
3108
3108
|
const fixtures = files.map(
|
|
3109
3109
|
(f) => parseFixture(readFileSync2(f, "utf8"), relative(process.cwd(), f))
|
|
3110
3110
|
);
|
|
@@ -5883,17 +5883,17 @@ async function metaListCommand(args) {
|
|
|
5883
5883
|
fail4(e, args);
|
|
5884
5884
|
}
|
|
5885
5885
|
}
|
|
5886
|
-
async function metaGetCommand(
|
|
5886
|
+
async function metaGetCommand(path11, args) {
|
|
5887
5887
|
try {
|
|
5888
5888
|
const c = await client2(args);
|
|
5889
|
-
const content = await getTenantMeta(c.raw(),
|
|
5889
|
+
const content = await getTenantMeta(c.raw(), path11);
|
|
5890
5890
|
process.stdout.write(content.endsWith("\n") ? content : content + "\n");
|
|
5891
5891
|
process.exit(0);
|
|
5892
5892
|
} catch (e) {
|
|
5893
5893
|
fail4(e, args);
|
|
5894
5894
|
}
|
|
5895
5895
|
}
|
|
5896
|
-
async function metaSetCommand(
|
|
5896
|
+
async function metaSetCommand(path11, args) {
|
|
5897
5897
|
try {
|
|
5898
5898
|
if (!args.file) {
|
|
5899
5899
|
throw new CliError18({
|
|
@@ -5910,7 +5910,7 @@ async function metaSetCommand(path10, args) {
|
|
|
5910
5910
|
}) : await fsp3.readFile(args.file, "utf8");
|
|
5911
5911
|
if (args.dryRun) {
|
|
5912
5912
|
process.stdout.write(
|
|
5913
|
-
`[dry-run] \u5C06\u5199\u5165 ${
|
|
5913
|
+
`[dry-run] \u5C06\u5199\u5165 ${path11}\uFF08${Buffer.byteLength(content)} B\uFF09\u2014\u2014\u672A\u5B9E\u9645\u5199\u5165
|
|
5914
5914
|
---
|
|
5915
5915
|
${content}
|
|
5916
5916
|
`
|
|
@@ -5918,10 +5918,10 @@ ${content}
|
|
|
5918
5918
|
process.exit(0);
|
|
5919
5919
|
}
|
|
5920
5920
|
const c = await client2(args);
|
|
5921
|
-
const result = await saveTenantMeta(c.raw(),
|
|
5921
|
+
const result = await saveTenantMeta(c.raw(), path11, content);
|
|
5922
5922
|
const fmt = args.output ?? "json";
|
|
5923
5923
|
if (fmt !== "json") {
|
|
5924
|
-
process.stdout.write(`\u2705 \u5DF2\u5199\u5165 ${
|
|
5924
|
+
process.stdout.write(`\u2705 \u5DF2\u5199\u5165 ${path11}
|
|
5925
5925
|
\u8BB0\u5F97\u6E05\u7F13\u5B58\uFF1Ahcm cache clear-meta <Model>
|
|
5926
5926
|
`);
|
|
5927
5927
|
}
|
|
@@ -5932,19 +5932,19 @@ ${content}
|
|
|
5932
5932
|
fail4(e, args);
|
|
5933
5933
|
}
|
|
5934
5934
|
}
|
|
5935
|
-
async function metaDeleteCommand(
|
|
5935
|
+
async function metaDeleteCommand(path11, args) {
|
|
5936
5936
|
try {
|
|
5937
5937
|
if (!args.yes) {
|
|
5938
|
-
const ok = await promptConfirm(`\u5C06\u5220\u9664\u5143\u6570\u636E ${
|
|
5938
|
+
const ok = await promptConfirm(`\u5C06\u5220\u9664\u5143\u6570\u636E ${path11}\uFF0C\u6B64\u64CD\u4F5C\u4E0D\u53EF\u9006\u3002\u7EE7\u7EED\uFF1F`);
|
|
5939
5939
|
if (!ok) {
|
|
5940
5940
|
process.stderr.write("\u5DF2\u53D6\u6D88\n");
|
|
5941
5941
|
process.exit(1);
|
|
5942
5942
|
}
|
|
5943
5943
|
}
|
|
5944
5944
|
const c = await client2(args);
|
|
5945
|
-
const result = await deleteTenantMeta(c.raw(),
|
|
5945
|
+
const result = await deleteTenantMeta(c.raw(), path11);
|
|
5946
5946
|
const fmt = args.output ?? "json";
|
|
5947
|
-
if (fmt !== "json") process.stdout.write(`\u{1F5D1}\uFE0F \u5DF2\u5220\u9664 ${
|
|
5947
|
+
if (fmt !== "json") process.stdout.write(`\u{1F5D1}\uFE0F \u5DF2\u5220\u9664 ${path11}
|
|
5948
5948
|
`);
|
|
5949
5949
|
process.stdout.write(formatObject16(result, { format: fmt }) + "\n");
|
|
5950
5950
|
process.exit(0);
|
|
@@ -6035,7 +6035,6 @@ async function workspaceListCommand(args) {
|
|
|
6035
6035
|
"ownerUserName",
|
|
6036
6036
|
"sharedUsers",
|
|
6037
6037
|
"filesCount",
|
|
6038
|
-
"myLockCount",
|
|
6039
6038
|
"devModeEnabled",
|
|
6040
6039
|
"updateTime"
|
|
6041
6040
|
],
|
|
@@ -7898,16 +7897,16 @@ async function deliveryGate0Command(args) {
|
|
|
7898
7897
|
const { aclass, problems: aclassProblems } = deriveAclass(reconDir, args.mapping ?? null);
|
|
7899
7898
|
const { facts, problems: factsProblems } = loadProtocolFacts();
|
|
7900
7899
|
const result = scan(skillRoot, aclass, facts, { aclassProblems, factsProblems });
|
|
7901
|
-
const
|
|
7900
|
+
const premise4 = checkPremise([
|
|
7902
7901
|
...result.premise,
|
|
7903
7902
|
...baselineRoundPremise(inspectRound2(reconDir))
|
|
7904
7903
|
]);
|
|
7905
|
-
const merged = { ...result, premise:
|
|
7904
|
+
const merged = { ...result, premise: premise4 };
|
|
7906
7905
|
const fmt = args.output ?? "json";
|
|
7907
7906
|
if (fmt !== "json") process.stdout.write(renderGate0(merged, skillRoot));
|
|
7908
7907
|
process.stdout.write(`${formatObject21(merged, { format: fmt })}
|
|
7909
7908
|
`);
|
|
7910
|
-
for (const problem of
|
|
7909
|
+
for (const problem of premise4) {
|
|
7911
7910
|
process.stderr.write(`\u{1F534} \u524D\u63D0\u4E0D\u6210\u7ACB\uFF08${problem.reason}\uFF09\uFF1A${problem.message}
|
|
7912
7911
|
`);
|
|
7913
7912
|
}
|
|
@@ -7922,10 +7921,46 @@ async function deliveryGate0Command(args) {
|
|
|
7922
7921
|
// src/commands/delivery-seed.ts
|
|
7923
7922
|
init_auth_guard();
|
|
7924
7923
|
import {
|
|
7924
|
+
APPLY_CAVEAT,
|
|
7925
|
+
ApplyInvariantError,
|
|
7926
|
+
ApplyPremiseError,
|
|
7927
|
+
DRY_RUN_NOTE,
|
|
7928
|
+
DRY_RUN_TAIL,
|
|
7929
|
+
DriftDetected,
|
|
7930
|
+
FORCE_STALE_FLAG,
|
|
7925
7931
|
HcmClient as HcmClient20,
|
|
7926
7932
|
INIT_EXIT_CODES,
|
|
7927
|
-
|
|
7933
|
+
JOURNAL_STOP_KINDS,
|
|
7934
|
+
JOURNAL_STOP_UNKNOWN,
|
|
7935
|
+
Journal,
|
|
7936
|
+
JournalError,
|
|
7937
|
+
LeaseViolation,
|
|
7928
7938
|
MappingError,
|
|
7939
|
+
PlanReadError,
|
|
7940
|
+
WAIVER_REPLAY,
|
|
7941
|
+
acquireLease,
|
|
7942
|
+
applyPlan,
|
|
7943
|
+
applyReportText,
|
|
7944
|
+
applyRc,
|
|
7945
|
+
baselineRoundPremise as baselineRoundPremise2,
|
|
7946
|
+
computeFingerprint,
|
|
7947
|
+
describeWaiver,
|
|
7948
|
+
enforceDriftGate,
|
|
7949
|
+
existingJournalStop,
|
|
7950
|
+
journalNote,
|
|
7951
|
+
judgeDrift,
|
|
7952
|
+
loadMapping,
|
|
7953
|
+
loadRecordedFingerprint,
|
|
7954
|
+
planVsBaselinePremise,
|
|
7955
|
+
buildDeliveryRun,
|
|
7956
|
+
buildReconciliation,
|
|
7957
|
+
isZeroNetwork,
|
|
7958
|
+
ledgerOnlySignpost,
|
|
7959
|
+
notAsked,
|
|
7960
|
+
readImportPlan,
|
|
7961
|
+
verifyRc,
|
|
7962
|
+
verifyText,
|
|
7963
|
+
resolveBaselineDir,
|
|
7929
7964
|
discardedColumnLines,
|
|
7930
7965
|
inspectRound as inspectRound3,
|
|
7931
7966
|
loadExemptions,
|
|
@@ -8020,30 +8055,316 @@ function tenantOf(client3) {
|
|
|
8020
8055
|
const t = client3?.tenantId;
|
|
8021
8056
|
return t === void 0 || t === null ? "" : String(t);
|
|
8022
8057
|
}
|
|
8058
|
+
async function authOrSignpost(args, cmd) {
|
|
8059
|
+
try {
|
|
8060
|
+
return await getActiveAuthContextFromCli(args);
|
|
8061
|
+
} catch (e) {
|
|
8062
|
+
const signpost = ledgerOnlySignpost(cmd);
|
|
8063
|
+
if (!signpost || !(e instanceof Error)) throw e;
|
|
8064
|
+
e.message += signpost;
|
|
8065
|
+
throw e;
|
|
8066
|
+
}
|
|
8067
|
+
}
|
|
8023
8068
|
async function deliverySeedPlanCommand(args) {
|
|
8024
|
-
const ctx = await
|
|
8069
|
+
const ctx = await authOrSignpost(args, "plan");
|
|
8025
8070
|
const client3 = HcmClient20.fromAuthContext(ctx);
|
|
8026
8071
|
process.exitCode = await runSeedPlan(args, seedClient(client3, ctx));
|
|
8027
8072
|
}
|
|
8028
8073
|
function seedClient(client3, ctx) {
|
|
8029
8074
|
const raw = client3.raw();
|
|
8075
|
+
const wrap = async (send) => {
|
|
8076
|
+
try {
|
|
8077
|
+
const res = await send();
|
|
8078
|
+
return {
|
|
8079
|
+
status: res.status,
|
|
8080
|
+
body: res.data,
|
|
8081
|
+
error: "ok",
|
|
8082
|
+
headers: lowerCaseHeaders(res.headers)
|
|
8083
|
+
};
|
|
8084
|
+
} catch (e) {
|
|
8085
|
+
const res = e?.response;
|
|
8086
|
+
const status = res?.status ?? -1;
|
|
8087
|
+
return {
|
|
8088
|
+
status,
|
|
8089
|
+
body: res?.data ?? null,
|
|
8090
|
+
// 🔴 `-1` **不是** HTTP 状态:网络层没走通与「服务端答了个 4xx」在处置上相反,
|
|
8091
|
+
// 执行器正是靠这一格把「确定没建」与「不知道建没建」分开。
|
|
8092
|
+
error: status === -1 ? "network" : `http-${status}`,
|
|
8093
|
+
headers: lowerCaseHeaders(res?.headers)
|
|
8094
|
+
};
|
|
8095
|
+
}
|
|
8096
|
+
};
|
|
8030
8097
|
return {
|
|
8031
8098
|
tenantId: ctx.tenantId,
|
|
8032
|
-
|
|
8033
|
-
|
|
8034
|
-
|
|
8035
|
-
|
|
8036
|
-
|
|
8037
|
-
|
|
8038
|
-
|
|
8039
|
-
|
|
8040
|
-
|
|
8041
|
-
|
|
8042
|
-
|
|
8043
|
-
|
|
8099
|
+
capabilities: DEFAULT_CAPABILITIES3,
|
|
8100
|
+
get: (p, params) => wrap(() => raw.get(p, { params })),
|
|
8101
|
+
post: (p, body) => wrap(() => raw.post(p, body))
|
|
8102
|
+
};
|
|
8103
|
+
}
|
|
8104
|
+
function lowerCaseHeaders(headers) {
|
|
8105
|
+
if (headers === null || typeof headers !== "object") return {};
|
|
8106
|
+
const out = {};
|
|
8107
|
+
for (const [k, v] of Object.entries(headers)) {
|
|
8108
|
+
if (typeof v === "string") out[k.toLowerCase()] = v;
|
|
8109
|
+
}
|
|
8110
|
+
return out;
|
|
8111
|
+
}
|
|
8112
|
+
var DEFAULT_CAPABILITIES3 = "default";
|
|
8113
|
+
async function runSeedApply(args, client3) {
|
|
8114
|
+
const out = args.out ?? ".";
|
|
8115
|
+
const tenant2 = tenantOf(client3);
|
|
8116
|
+
const work = seedWorkDir({ out, tenant: tenant2, work: args.work ?? null, mapping: args.mapping ?? null });
|
|
8117
|
+
const mappingPath = seedMappingPath({ out, tenant: tenant2, mapping: args.mapping ?? null }, work);
|
|
8118
|
+
let plan;
|
|
8119
|
+
try {
|
|
8120
|
+
plan = readImportPlan(work);
|
|
8121
|
+
} catch (e) {
|
|
8122
|
+
if (e instanceof PlanReadError) return premise(`\u8BA1\u5212\u8BFB\u4E0D\u56DE\u6765\uFF1A[${e.reason}] ${e.message}`, e.hint);
|
|
8123
|
+
throw e;
|
|
8124
|
+
}
|
|
8125
|
+
let mapping;
|
|
8126
|
+
try {
|
|
8127
|
+
mapping = loadMapping(mappingPath);
|
|
8128
|
+
} catch (e) {
|
|
8129
|
+
if (e instanceof MappingError) return premise(`\u5DE5\u4EF6\u88C5\u4E0D\u8FDB\u6765\uFF1A[${e.reason}] ${e.message}`, e.hint);
|
|
8130
|
+
return premise(
|
|
8131
|
+
`\u8BFB\u4E0D\u5230\u5DE5\u4EF6\uFF1A${mappingPath}\uFF08${e instanceof Error ? e.message : String(e)}\uFF09`,
|
|
8132
|
+
"`apply` \u8981\u62FF\u5DE5\u4EF6\u4E0E\u8BA1\u5212\u5BF9\u8D26\uFF08\u6A21\u578B\u6E05\u5355\u4E0E\u4E1A\u52A1\u952E\uFF09\u3002\u5DE5\u4EF6\u5199\u5728\u522B\u5904\u5C31\u7528 `--mapping <\u8DEF\u5F84>` \u6307\u8FC7\u53BB\u3002"
|
|
8133
|
+
);
|
|
8134
|
+
}
|
|
8135
|
+
let journal;
|
|
8136
|
+
try {
|
|
8137
|
+
journal = Journal.load(work);
|
|
8138
|
+
} catch (e) {
|
|
8139
|
+
if (e instanceof JournalError) return premise(`\u53F0\u8D26\u8BFB\u4E0D\u56DE\u6765\uFF1A[${e.reason}] ${e.message}`, e.hint);
|
|
8140
|
+
throw e;
|
|
8141
|
+
}
|
|
8142
|
+
if (journal.exists && !args.resume) {
|
|
8143
|
+
return premise(...existingJournalStop(journal.path, journal.entries.length));
|
|
8144
|
+
}
|
|
8145
|
+
for (const waiver of journal.waivers) {
|
|
8146
|
+
process.stderr.write(
|
|
8147
|
+
WAIVER_REPLAY.replace("{flag}", FORCE_STALE_FLAG).replace("{detail}", describeWaiver(waiver)) + "\n"
|
|
8148
|
+
);
|
|
8149
|
+
}
|
|
8150
|
+
if (plan.baseline !== null) {
|
|
8151
|
+
const [baselineDir] = resolveBaselineDir(out, plan.baseline.path);
|
|
8152
|
+
if (baselineDir !== null) {
|
|
8153
|
+
const round = inspectRound3(baselineDir);
|
|
8154
|
+
const stale = planVsBaselinePremise(
|
|
8155
|
+
plan.baseline.path,
|
|
8156
|
+
plan.baseline.roundId,
|
|
8157
|
+
round.roundId ?? null
|
|
8158
|
+
);
|
|
8159
|
+
if (stale !== null) return premise(stale[0], stale[1]);
|
|
8160
|
+
for (const p of baselineRoundPremise2(round)) {
|
|
8161
|
+
if (!args.execute) {
|
|
8162
|
+
process.stderr.write(DRY_RUN_NOTE.replace("{message}", p.message) + "\n");
|
|
8163
|
+
continue;
|
|
8164
|
+
}
|
|
8165
|
+
return premise(
|
|
8166
|
+
p.message,
|
|
8167
|
+
`\`${FORCE_STALE_FLAG}\` **\u4E0D\u8C41\u514D\u8FD9\u4E00\u6761** \u2014\u2014 \u5B83\u7BA1\u7684\u662F\u300C\u57FA\u7EBF\u5BF9\u4E0D\u5BF9\u5F97\u4E0A\u8FD9\u4E2A\u73AF\u5883\u300D\uFF0C\u800C\u8FD9\u4E00\u6761\u95EE\u7684\u662F\u300C\u8FD9\u4EFD\u57FA\u7EBF**\u81EA\u5DF1**\u662F\u4E0D\u662F\u4E00\u8F6E\u5B8C\u6574\u8DD1\u51FA\u6765\u7684\u300D\uFF0C\u4E24\u4EF6\u4E8B\u3002\u{1F534} \u8FD9\u4E00\u8F6E**\u4E00\u53D1\u5199\u8BF7\u6C42\u90FD\u6CA1\u6709\u53D1\u51FA\u53BB**\uFF08\u95F8\u6392\u5728\u7B2C\u4E00\u4E2A\u5199\u8BF7\u6C42\u4E4B\u524D\uFF0C\u4E5F\u6392\u5728\u62FF\u5355\u5199\u8005\u79DF\u7EA6\u4E4B\u524D\uFF09\uFF0C\u6240\u4EE5\u5E93\u91CC\u6CA1\u6709\u591A\u51FA\u4EFB\u4F55\u884C\uFF0C\u76D8\u4E0A\u4E5F\u6CA1\u6709\u7559\u4E0B\u79DF\u7EA6\u3002`
|
|
8168
|
+
);
|
|
8044
8169
|
}
|
|
8045
8170
|
}
|
|
8046
|
-
}
|
|
8171
|
+
}
|
|
8172
|
+
const [recorded, loadCause] = loadRecordedFingerprint(out, plan.baseline?.path ?? null);
|
|
8173
|
+
const current = await computeFingerprint(client3);
|
|
8174
|
+
const verdict = judgeDrift(recorded, current, { baseline: plan.baseline?.path ?? null, loadCause });
|
|
8175
|
+
let note;
|
|
8176
|
+
try {
|
|
8177
|
+
note = enforceDriftGate(verdict, {
|
|
8178
|
+
journal,
|
|
8179
|
+
roundId: plan.roundId,
|
|
8180
|
+
forced: args.forceStale ?? false,
|
|
8181
|
+
dryRun: !args.execute
|
|
8182
|
+
});
|
|
8183
|
+
} catch (e) {
|
|
8184
|
+
if (e instanceof DriftDetected) return premise(e.verdict.message);
|
|
8185
|
+
if (e instanceof JournalError) {
|
|
8186
|
+
return premise(
|
|
8187
|
+
`\u653E\u884C\u8BB0\u5F55\u843D\u4E0D\u8FDB\u53F0\u8D26\uFF1A[${e.reason}] ${e.message}`,
|
|
8188
|
+
(e.hint ?? "") + " \u{1F534} \u8FD9\u4E00\u8F6E**\u4E00\u53D1\u5199\u8BF7\u6C42\u90FD\u6CA1\u6709\u53D1\u51FA\u53BB**\uFF08\u95F8\u6392\u5728\u7B2C\u4E00\u4E2A\u5199\u8BF7\u6C42\u4E4B\u524D\uFF09\uFF0C\u6240\u4EE5\u5E93\u91CC\u6CA1\u6709\u591A\u51FA\u4EFB\u4F55\u884C\u3002" + journalNote(journal.path)
|
|
8189
|
+
);
|
|
8190
|
+
}
|
|
8191
|
+
throw e;
|
|
8192
|
+
}
|
|
8193
|
+
if (note) process.stderr.write(note + "\n");
|
|
8194
|
+
let lease;
|
|
8195
|
+
try {
|
|
8196
|
+
lease = acquireLease(work, plan.roundId);
|
|
8197
|
+
} catch (e) {
|
|
8198
|
+
if (e instanceof LeaseViolation) return premise(`\u62FF\u4E0D\u5230\u5355\u5199\u8005\u79DF\u7EA6\uFF1A[${e.reason}] ${e.message}`, e.hint);
|
|
8199
|
+
throw e;
|
|
8200
|
+
}
|
|
8201
|
+
if (lease.reclaimed) process.stderr.write(`\u26A0\uFE0F \u56DE\u6536\u4E86\u4E00\u4EFD\u9648\u65E7\u79DF\u7EA6\uFF1A${JSON.stringify(lease.reclaimed)}
|
|
8202
|
+
`);
|
|
8203
|
+
let report;
|
|
8204
|
+
try {
|
|
8205
|
+
report = await applyPlan(client3, plan, mapping, journal, {
|
|
8206
|
+
dryRun: !args.execute,
|
|
8207
|
+
sample: args.sample ?? null,
|
|
8208
|
+
onRequestSpent: lease.heartbeatIfDue.bind(lease)
|
|
8209
|
+
});
|
|
8210
|
+
} catch (e) {
|
|
8211
|
+
if (e instanceof ApplyPremiseError) return premise(`\u6267\u884C\u524D\u63D0\u4E0D\u6210\u7ACB\uFF1A[${e.reason}] ${e.message}`, e.hint);
|
|
8212
|
+
if (e instanceof JournalError) {
|
|
8213
|
+
const [headline, nextStep, whenPresent] = JOURNAL_STOP_KINDS[e.reason] ?? JOURNAL_STOP_UNKNOWN;
|
|
8214
|
+
return premise(
|
|
8215
|
+
`${headline}\uFF08[${e.reason}] ${e.message}\uFF09`,
|
|
8216
|
+
(e.hint ?? "") + " " + nextStep + journalNote(journal.path, whenPresent)
|
|
8217
|
+
);
|
|
8218
|
+
}
|
|
8219
|
+
if (e instanceof ApplyInvariantError) {
|
|
8220
|
+
return premise(
|
|
8221
|
+
`\u8FD9\u4E00\u8F6E**\u505C\u5728\u8FD9\u91CC**\uFF1Akit \u7684\u5185\u90E8\u4E0D\u53D8\u91CF\u88AB\u7834\u574F\uFF08${e.name}: ${e.message}\uFF09`,
|
|
8222
|
+
"\u8FD9\u662F kit \u7684\u7F3A\u9677\uFF0C\u4E0D\u662F\u4F60\u7684\u6570\u636E\u95EE\u9898\u3002**\u522B\u6539\u5DE5\u4EF6\u91CD\u8BD5**\uFF0C\u628A\u8FD9\u6BB5\u4FE1\u606F\u539F\u6837\u62A5\u56DE\u6765\uFF1B\u8981\u4E0D\u8981\u7EED\u8DD1\uFF0C\u7B49\u8FD9\u4E2A\u7F3A\u9677\u4FEE\u597D\u4E4B\u540E\u518D\u8BF4\u3002" + journalNote(
|
|
8223
|
+
journal.path,
|
|
8224
|
+
"\u{1F534} **\u62A5\u56DE\u6765\u65F6\u628A\u5B83\u4E00\u8D77\u5E26\u4E0A** \u2014\u2014 \u8FD9\u4E00\u8F6E\u8D70\u5230\u54EA\u4E00\u884C\u3001\u5199\u51FA\u53BB\u4E86\u4EC0\u4E48\uFF0C\u53EA\u6709\u5B83\u8BF4\u5F97\u51FA\u3002"
|
|
8225
|
+
)
|
|
8226
|
+
);
|
|
8227
|
+
}
|
|
8228
|
+
throw e;
|
|
8229
|
+
} finally {
|
|
8230
|
+
lease.release();
|
|
8231
|
+
}
|
|
8232
|
+
process.stdout.write(applyReportText(report) + "\n");
|
|
8233
|
+
if (report.dryRun) process.stdout.write(DRY_RUN_TAIL + "\n");
|
|
8234
|
+
process.stdout.write(APPLY_CAVEAT + "\n");
|
|
8235
|
+
return applyRc(report);
|
|
8236
|
+
}
|
|
8237
|
+
async function deliverySeedApplyCommand(args) {
|
|
8238
|
+
const ctx = await authOrSignpost(args, "apply");
|
|
8239
|
+
const client3 = HcmClient20.fromAuthContext(ctx);
|
|
8240
|
+
process.exitCode = await runSeedApply(args, seedClient(client3, ctx));
|
|
8241
|
+
}
|
|
8242
|
+
async function runSeedVerify(args, client3) {
|
|
8243
|
+
const out = args.out ?? ".";
|
|
8244
|
+
const tenant2 = tenantOf(client3);
|
|
8245
|
+
const work = seedWorkDir({ out, tenant: tenant2, work: args.work ?? null, mapping: args.mapping ?? null });
|
|
8246
|
+
let delivery2;
|
|
8247
|
+
try {
|
|
8248
|
+
delivery2 = buildDeliveryRun(work);
|
|
8249
|
+
} catch (e) {
|
|
8250
|
+
if (e instanceof JournalError) return premise(`\u53F0\u8D26\u8BFB\u4E0D\u56DE\u6765\uFF1A[${e.reason}] ${e.message}`, e.hint ?? "");
|
|
8251
|
+
throw e;
|
|
8252
|
+
}
|
|
8253
|
+
const recon2 = isZeroNetwork(args) ? notAsked(delivery2) : await buildReconciliation(delivery2, client3);
|
|
8254
|
+
process.stdout.write(verifyText(delivery2, recon2));
|
|
8255
|
+
return verifyRc(delivery2, recon2);
|
|
8256
|
+
}
|
|
8257
|
+
async function deliverySeedVerifyCommand(args) {
|
|
8258
|
+
if (isZeroNetwork(args)) {
|
|
8259
|
+
process.exitCode = await runSeedVerify(args, null);
|
|
8260
|
+
return;
|
|
8261
|
+
}
|
|
8262
|
+
const ctx = await authOrSignpost(args, "verify");
|
|
8263
|
+
const client3 = HcmClient20.fromAuthContext(ctx);
|
|
8264
|
+
process.exitCode = await runSeedVerify(args, seedClient(client3, ctx));
|
|
8265
|
+
}
|
|
8266
|
+
|
|
8267
|
+
// src/commands/delivery-seed-find.ts
|
|
8268
|
+
import { existsSync as existsSync3 } from "fs";
|
|
8269
|
+
import { readFileSync as readFileSync4 } from "fs";
|
|
8270
|
+
import * as path8 from "path";
|
|
8271
|
+
import {
|
|
8272
|
+
INIT_EXIT_CODES as INIT_EXIT_CODES2,
|
|
8273
|
+
ValueHints,
|
|
8274
|
+
find,
|
|
8275
|
+
inspectRound as inspectRound4,
|
|
8276
|
+
loadRows,
|
|
8277
|
+
renderFind,
|
|
8278
|
+
renderValues,
|
|
8279
|
+
roundWarning as roundWarning2,
|
|
8280
|
+
seedBaselines as seedBaselines2,
|
|
8281
|
+
valuesRoundCaveat
|
|
8282
|
+
} from "@hcmai/sdk";
|
|
8283
|
+
function provenance(chosenReconDir, others) {
|
|
8284
|
+
let line = `> \u57FA\u7EBF\uFF1A\`${path8.basename(chosenReconDir)}\`
|
|
8285
|
+
`;
|
|
8286
|
+
if (others.length > 0) {
|
|
8287
|
+
line += `> \u26A0\uFE0F \u540C\u79DF\u6237\u4E0B\u53E6\u6709 ${others.length} \u4EFD\u57FA\u7EBF\u672A\u88AB\u8BFB\u53D6\uFF1A` + others.map((o) => `\`${path8.basename(o)}\``).join("\u3001") + " \u2014\u2014 \u4E0D\u540C sourceKey \u7684\u4EA7\u7269**\u4E0D\u53EF\u4E92\u6362**\u3002\n";
|
|
8288
|
+
}
|
|
8289
|
+
return `${line}
|
|
8290
|
+
`;
|
|
8291
|
+
}
|
|
8292
|
+
function premise2(message, hint = "") {
|
|
8293
|
+
process.stderr.write(message + (hint ? `
|
|
8294
|
+
\u2192 ${hint}` : "") + "\n");
|
|
8295
|
+
return INIT_EXIT_CODES2.premise;
|
|
8296
|
+
}
|
|
8297
|
+
function pickBaseline(args) {
|
|
8298
|
+
const out = args.out ?? ".";
|
|
8299
|
+
const tenant2 = args.tenant ?? "";
|
|
8300
|
+
if (!tenant2) {
|
|
8301
|
+
return {
|
|
8302
|
+
rc: premise2(
|
|
8303
|
+
"\u6CA1\u7ED9 `--tenant`\u3002",
|
|
8304
|
+
"\u672C\u547D\u4EE4\u96F6\u7F51\u7EDC\uFF08\u4E0D\u767B\u5F55\u3001\u4E00\u53D1\u8BF7\u6C42\u90FD\u4E0D\u53D1\uFF09\uFF0C\u6240\u4EE5\u5B83\u65E0\u6CD5\u4ECE\u767B\u5F55\u6001\u77E5\u9053\u4F60\u5728\u54EA\u4E2A\u79DF\u6237\u3002\u7ED9\u7684\u503C\u8981\u4E0E\u5F53\u521D\u8DD1 `hcm delivery recon` \u65F6\u90A3\u4E2A\u79DF\u6237\u4E00\u81F4\u3002"
|
|
8305
|
+
)
|
|
8306
|
+
};
|
|
8307
|
+
}
|
|
8308
|
+
const [base, candidates] = seedBaselines2(out, tenant2);
|
|
8309
|
+
if (candidates.length === 0) {
|
|
8310
|
+
return {
|
|
8311
|
+
rc: premise2(
|
|
8312
|
+
`\u672A\u627E\u5230\u7D22\u5F15\uFF1A${base}/*/index/fields.jsonl`,
|
|
8313
|
+
"\u672C\u547D\u4EE4\u53EA\u8BFB `hcm delivery recon` \u843D\u76D8\u7684\u5B57\u6BB5\u76EE\u5F55\u3002\u5148\u8DD1\u4E00\u6B21 `hcm delivery recon`\uFF0C\u6216\u7528 `--out <\u76EE\u5F55>` \u6307\u5230\u4EA7\u7269\u6839\u3002"
|
|
8314
|
+
)
|
|
8315
|
+
};
|
|
8316
|
+
}
|
|
8317
|
+
const chosen = candidates[0];
|
|
8318
|
+
const others = candidates.slice(1).map((c) => c.reconDir);
|
|
8319
|
+
let prefix = provenance(chosen.reconDir, others);
|
|
8320
|
+
prefix += roundWarning2(inspectRound4(chosen.reconDir));
|
|
8321
|
+
return { reconDir: chosen.reconDir, indexFile: chosen.indexFile, prefix };
|
|
8322
|
+
}
|
|
8323
|
+
function runSeedFind(args) {
|
|
8324
|
+
const picked = pickBaseline(args);
|
|
8325
|
+
if ("rc" in picked) return picked.rc;
|
|
8326
|
+
const chosen = { reconDir: picked.reconDir, indexFile: picked.indexFile };
|
|
8327
|
+
const prefix = picked.prefix;
|
|
8328
|
+
process.stdout.write(prefix);
|
|
8329
|
+
if (!existsSync3(chosen.indexFile)) {
|
|
8330
|
+
return premise2(`\u7D22\u5F15\u6587\u4EF6\u5728\u9009\u4E2D\u4E4B\u540E\u6D88\u5931\u4E86\uFF1A${chosen.indexFile}`);
|
|
8331
|
+
}
|
|
8332
|
+
const { rows, problems } = loadRows(readFileSync4(chosen.indexFile, "utf-8"));
|
|
8333
|
+
process.stdout.write(
|
|
8334
|
+
renderFind(find(rows, args.term), args.term, rows.length, {
|
|
8335
|
+
prefixBytes: Buffer.byteLength(prefix, "utf-8"),
|
|
8336
|
+
// 🔴 指路器与检索**读同一份基线**(`pickBaseline` 选的那一份)——
|
|
8337
|
+
// 各选各的会让 find 指出来的对照表与 `values` 打开的不是同一份产物。
|
|
8338
|
+
hints: new ValueHints(chosen.reconDir)
|
|
8339
|
+
})
|
|
8340
|
+
);
|
|
8341
|
+
for (const bad of problems) {
|
|
8342
|
+
process.stderr.write(`\u26A0\uFE0F \u7D22\u5F15\u6709\u574F\u884C\uFF08\u5176\u4F59 ${rows.length} \u884C\u4ECD\u53EF\u7528\uFF09\uFF1A${bad}
|
|
8343
|
+
`);
|
|
8344
|
+
}
|
|
8345
|
+
return INIT_EXIT_CODES2.clean;
|
|
8346
|
+
}
|
|
8347
|
+
function deliverySeedFindCommand(term, args) {
|
|
8348
|
+
process.exitCode = runSeedFind({ ...args, term });
|
|
8349
|
+
}
|
|
8350
|
+
function runSeedValues(args) {
|
|
8351
|
+
const picked = pickBaseline({ term: "", out: args.out, tenant: args.tenant });
|
|
8352
|
+
if ("rc" in picked) return picked.rc;
|
|
8353
|
+
process.stdout.write(picked.prefix);
|
|
8354
|
+
const got = renderValues(picked.reconDir, args.model, {
|
|
8355
|
+
limit: args.limit,
|
|
8356
|
+
roundCaveat: valuesRoundCaveat(inspectRound4(picked.reconDir))
|
|
8357
|
+
});
|
|
8358
|
+
if (!got.ok) {
|
|
8359
|
+
process.stderr.write(`${got.message}
|
|
8360
|
+
`);
|
|
8361
|
+
return INIT_EXIT_CODES2.premise;
|
|
8362
|
+
}
|
|
8363
|
+
process.stdout.write(got.text);
|
|
8364
|
+
return INIT_EXIT_CODES2.clean;
|
|
8365
|
+
}
|
|
8366
|
+
function deliverySeedValuesCommand(model, args) {
|
|
8367
|
+
process.exitCode = runSeedValues({ ...args, model });
|
|
8047
8368
|
}
|
|
8048
8369
|
|
|
8049
8370
|
// src/commands/delivery-triage.ts
|
|
@@ -8056,10 +8377,10 @@ import {
|
|
|
8056
8377
|
ReconLayout as ReconLayout2,
|
|
8057
8378
|
runTriageRound
|
|
8058
8379
|
} from "@hcmai/sdk";
|
|
8059
|
-
import { mkdirSync, readFileSync as
|
|
8060
|
-
import * as
|
|
8061
|
-
var
|
|
8062
|
-
function
|
|
8380
|
+
import { mkdirSync, readFileSync as readFileSync5, writeFileSync as writeFileSync2 } from "fs";
|
|
8381
|
+
import * as path9 from "path";
|
|
8382
|
+
var DEFAULT_CAPABILITIES4 = "default";
|
|
8383
|
+
function premise3(message, hint) {
|
|
8063
8384
|
process.stderr.write(`\u{1F534} \u524D\u63D0\u4E0D\u6210\u7ACB\uFF1A${message}
|
|
8064
8385
|
`);
|
|
8065
8386
|
process.stderr.write(` ${hint}
|
|
@@ -8070,7 +8391,7 @@ var REQUESTS_SHAPE = "`--requests` \u6536\u7684\u662F\u4E00\u4E2A JSON \u6570\u7
|
|
|
8070
8391
|
function readRequests(file) {
|
|
8071
8392
|
let raw;
|
|
8072
8393
|
try {
|
|
8073
|
-
raw = JSON.parse(
|
|
8394
|
+
raw = JSON.parse(readFileSync5(file, "utf8"));
|
|
8074
8395
|
} catch (e) {
|
|
8075
8396
|
throw new Error(`\u9700\u6C42\u6E05\u5355\u8BFB\u4E0D\u51FA\u6765\uFF08${file}\uFF09\uFF1A${e instanceof Error ? e.message : String(e)}`);
|
|
8076
8397
|
}
|
|
@@ -8093,22 +8414,22 @@ function renderProblems(rows) {
|
|
|
8093
8414
|
`;
|
|
8094
8415
|
}
|
|
8095
8416
|
function writeTriageArtifact(outDir, body) {
|
|
8096
|
-
const out =
|
|
8097
|
-
mkdirSync(
|
|
8417
|
+
const out = path9.join(outDir, "work", "triage.md");
|
|
8418
|
+
mkdirSync(path9.dirname(out), { recursive: true });
|
|
8098
8419
|
writeFileSync2(out, body, "utf8");
|
|
8099
8420
|
return out;
|
|
8100
8421
|
}
|
|
8101
8422
|
async function runTriage(args) {
|
|
8102
|
-
if (!args.requests) return
|
|
8423
|
+
if (!args.requests) return premise3("\u6CA1\u7ED9 `--requests`", REQUESTS_SHAPE);
|
|
8103
8424
|
let entriesIn;
|
|
8104
8425
|
try {
|
|
8105
8426
|
entriesIn = readRequests(args.requests);
|
|
8106
8427
|
} catch (e) {
|
|
8107
|
-
return
|
|
8428
|
+
return premise3(e instanceof Error ? e.message : String(e), REQUESTS_SHAPE);
|
|
8108
8429
|
}
|
|
8109
8430
|
const ctx = await getActiveAuthContextFromCli(args);
|
|
8110
8431
|
const client3 = HcmClient21.fromAuthContext(ctx);
|
|
8111
|
-
const probe = httpProbe3(client3.raw(), args.capabilities ??
|
|
8432
|
+
const probe = httpProbe3(client3.raw(), args.capabilities ?? DEFAULT_CAPABILITIES4);
|
|
8112
8433
|
const artifactsDir = args.recon ?? new ReconLayout2(args.out ?? ".", ctx.tenantId, await computeReconSourceKey2(probe)).dir;
|
|
8113
8434
|
const result = await runTriageRound(probe, artifactsDir, entriesIn);
|
|
8114
8435
|
if (result.body === null) {
|
|
@@ -8135,7 +8456,7 @@ async function deliveryTriageCommand(args) {
|
|
|
8135
8456
|
import { createHash as createHash5, randomBytes as secureRandomBytes } from "crypto";
|
|
8136
8457
|
import { spawn } from "child_process";
|
|
8137
8458
|
import { createReadStream, promises as fs6 } from "fs";
|
|
8138
|
-
import
|
|
8459
|
+
import path10 from "path";
|
|
8139
8460
|
import { CliError as CliError20, CliErrorCode as CliErrorCode19, formatObject as formatObject22 } from "@hcmai/sdk";
|
|
8140
8461
|
init_exit();
|
|
8141
8462
|
var EXECUTION_CONTRACT_VERSION = "2026-08-29.controlled-v3";
|
|
@@ -8175,9 +8496,9 @@ async function prepareDeliveryExecution(input) {
|
|
|
8175
8496
|
};
|
|
8176
8497
|
const planId = sha2565(canonicalJson(core)).slice(0, 24);
|
|
8177
8498
|
const plan = { ...core, planId };
|
|
8178
|
-
const plansDir =
|
|
8499
|
+
const plansDir = path10.join(project, ".hcm-delivery", "execution-plans");
|
|
8179
8500
|
await safeManagedDirectory(project, ".hcm-delivery/execution-plans", plansDir);
|
|
8180
|
-
const planFile =
|
|
8501
|
+
const planFile = path10.join(plansDir, `${planId}.json`);
|
|
8181
8502
|
try {
|
|
8182
8503
|
await fs6.writeFile(planFile, `${JSON.stringify(plan, null, 2)}
|
|
8183
8504
|
`, {
|
|
@@ -8196,7 +8517,7 @@ async function executeDeliveryPlan(input) {
|
|
|
8196
8517
|
if (await readProjectMode(project) !== "controlled") {
|
|
8197
8518
|
throw invalid2("\u9879\u76EE\u4E0D\u662F controlled\uFF0C\u4E0D\u80FD\u6267\u884C R2 \u8BA1\u5212");
|
|
8198
8519
|
}
|
|
8199
|
-
const planFile =
|
|
8520
|
+
const planFile = path10.join(project, ".hcm-delivery", "execution-plans", `${input.planId}.json`);
|
|
8200
8521
|
const plan = await readPlan(project, planFile);
|
|
8201
8522
|
if (plan.planId !== input.planId || computePlanId(plan) !== input.planId) {
|
|
8202
8523
|
throw invalid2("\u6267\u884C\u8BA1\u5212\u5185\u5BB9\u4E0E planId \u6458\u8981\u4E0D\u4E00\u81F4");
|
|
@@ -8227,11 +8548,11 @@ async function executeDeliveryPlan(input) {
|
|
|
8227
8548
|
await assertDocumentUnchanged(project, plan.documents.rollback, "\u56DE\u6EDA\u8BF4\u660E");
|
|
8228
8549
|
await assertPayloadsUnchanged(project, plan.payloads);
|
|
8229
8550
|
const evidenceDir = await bindEvidenceDirectory(project, plan.evidenceDir);
|
|
8230
|
-
const receiptFile =
|
|
8551
|
+
const receiptFile = path10.join(evidenceDir.absolute, `${plan.planId}.receipt.json`);
|
|
8231
8552
|
if (await pathExists(receiptFile)) throw invalid2(`\u6267\u884C\u6536\u636E\u5DF2\u5B58\u5728\uFF0C\u62D2\u7EDD\u518D\u6B21\u6267\u884C\uFF1A${plan.planId}`);
|
|
8232
|
-
const claimsDir =
|
|
8553
|
+
const claimsDir = path10.join(project, ".hcm-delivery", "execution-claims");
|
|
8233
8554
|
await safeManagedDirectory(project, ".hcm-delivery/execution-claims", claimsDir);
|
|
8234
|
-
const claimFile =
|
|
8555
|
+
const claimFile = path10.join(claimsDir, `${plan.planId}.json`);
|
|
8235
8556
|
try {
|
|
8236
8557
|
await fs6.writeFile(
|
|
8237
8558
|
claimFile,
|
|
@@ -8318,7 +8639,7 @@ async function deliveryExecuteCommand(planId, argv, args) {
|
|
|
8318
8639
|
}
|
|
8319
8640
|
}
|
|
8320
8641
|
async function readProjectMode(project) {
|
|
8321
|
-
const file =
|
|
8642
|
+
const file = path10.join(project, ".hcm-delivery", "project.yml");
|
|
8322
8643
|
const content = await readSafeFile(project, file, "\u9879\u76EE\u914D\u7F6E");
|
|
8323
8644
|
const match = content.toString("utf8").match(
|
|
8324
8645
|
/^deliveryMode:\s*(?:"(plan-only|controlled)"|'(plan-only|controlled)'|(plan-only|controlled))\s*$/m
|
|
@@ -8330,13 +8651,13 @@ async function readProjectMode(project) {
|
|
|
8330
8651
|
return mode;
|
|
8331
8652
|
}
|
|
8332
8653
|
var SKILLS_LOCK_CANDIDATES = [
|
|
8333
|
-
|
|
8334
|
-
|
|
8654
|
+
path10.join("hcm-skills", ".hcm-skills.json"),
|
|
8655
|
+
path10.join(".claude", "skills", ".hcm-skills.json")
|
|
8335
8656
|
];
|
|
8336
8657
|
async function readSkillsLock(project) {
|
|
8337
8658
|
const found = [];
|
|
8338
8659
|
for (const candidate of SKILLS_LOCK_CANDIDATES) {
|
|
8339
|
-
if (await pathExists(
|
|
8660
|
+
if (await pathExists(path10.join(project, candidate))) found.push(candidate);
|
|
8340
8661
|
}
|
|
8341
8662
|
if (found.length === 0) {
|
|
8342
8663
|
throw invalid2(
|
|
@@ -8348,7 +8669,7 @@ async function readSkillsLock(project) {
|
|
|
8348
8669
|
`\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`
|
|
8349
8670
|
);
|
|
8350
8671
|
}
|
|
8351
|
-
const bytes = await readSafeFile(project,
|
|
8672
|
+
const bytes = await readSafeFile(project, path10.join(project, found[0]), "\u6280\u80FD\u9501");
|
|
8352
8673
|
try {
|
|
8353
8674
|
JSON.parse(bytes.toString("utf8"));
|
|
8354
8675
|
} catch (cause) {
|
|
@@ -8361,7 +8682,7 @@ async function bindDocument(project, reference, label) {
|
|
|
8361
8682
|
if (!(relative2.startsWith("work/") || relative2.startsWith("decisions/"))) {
|
|
8362
8683
|
throw invalid2(`${label}\u5FC5\u987B\u4F4D\u4E8E\u9879\u76EE work/ \u6216 decisions/ \u4E0B`);
|
|
8363
8684
|
}
|
|
8364
|
-
const file =
|
|
8685
|
+
const file = path10.join(project, relative2);
|
|
8365
8686
|
const bytes = await readSafeFile(project, file, label);
|
|
8366
8687
|
return { path: relative2, sha256: sha2565(bytes) };
|
|
8367
8688
|
}
|
|
@@ -8374,7 +8695,7 @@ async function bindEvidenceDirectory(project, reference) {
|
|
|
8374
8695
|
if (!(relative2 === "evidence" || relative2.startsWith("evidence/"))) {
|
|
8375
8696
|
throw invalid2("evidence \u76EE\u5F55\u5FC5\u987B\u4F4D\u4E8E\u9879\u76EE evidence/ \u4E0B");
|
|
8376
8697
|
}
|
|
8377
|
-
const absolute =
|
|
8698
|
+
const absolute = path10.join(project, relative2);
|
|
8378
8699
|
await assertNoSymlinkComponents(project, relative2);
|
|
8379
8700
|
const stat = await fs6.stat(absolute).catch(() => null);
|
|
8380
8701
|
if (stat === null) {
|
|
@@ -8506,7 +8827,7 @@ async function bindPayloadFiles(project, argv) {
|
|
|
8506
8827
|
}
|
|
8507
8828
|
async function bindPayloadFile(project, reference, label) {
|
|
8508
8829
|
const relative2 = safeRelative(reference, label);
|
|
8509
|
-
const file =
|
|
8830
|
+
const file = path10.join(project, relative2);
|
|
8510
8831
|
const bytes = await readSafeFile(project, file, label);
|
|
8511
8832
|
return { path: relative2, sha256: sha2565(bytes) };
|
|
8512
8833
|
}
|
|
@@ -8575,13 +8896,13 @@ async function writeReceiptExclusive(target, receipt) {
|
|
|
8575
8896
|
});
|
|
8576
8897
|
await fs6.link(temp, target);
|
|
8577
8898
|
} catch (cause) {
|
|
8578
|
-
throw invalid2(`\u6267\u884C\u6536\u636E\u5199\u5165\u5931\u8D25\u6216\u5DF2\u5B58\u5728\uFF1A${
|
|
8899
|
+
throw invalid2(`\u6267\u884C\u6536\u636E\u5199\u5165\u5931\u8D25\u6216\u5DF2\u5B58\u5728\uFF1A${path10.basename(target)}`, cause);
|
|
8579
8900
|
} finally {
|
|
8580
8901
|
await fs6.unlink(temp).catch(() => void 0);
|
|
8581
8902
|
}
|
|
8582
8903
|
}
|
|
8583
8904
|
async function safeManagedDirectory(project, relative2, absolute) {
|
|
8584
|
-
await assertNoSymlinkComponents(project,
|
|
8905
|
+
await assertNoSymlinkComponents(project, path10.dirname(relative2));
|
|
8585
8906
|
const existing = await fs6.lstat(absolute).catch(() => void 0);
|
|
8586
8907
|
if (existing?.isSymbolicLink()) throw invalid2(`\u53D7\u7BA1\u76EE\u5F55\u4E0D\u80FD\u662F\u7B26\u53F7\u94FE\u63A5\uFF1A${relative2}`);
|
|
8587
8908
|
if (existing && !existing.isDirectory()) throw invalid2(`\u53D7\u7BA1\u8DEF\u5F84\u4E0D\u662F\u76EE\u5F55\uFF1A${relative2}`);
|
|
@@ -8598,8 +8919,8 @@ async function pathExists(file) {
|
|
|
8598
8919
|
);
|
|
8599
8920
|
}
|
|
8600
8921
|
async function readSafeFile(project, file, label) {
|
|
8601
|
-
const relative2 =
|
|
8602
|
-
if (relative2.startsWith("../") ||
|
|
8922
|
+
const relative2 = path10.relative(project, file).split(path10.sep).join("/");
|
|
8923
|
+
if (relative2.startsWith("../") || path10.isAbsolute(relative2))
|
|
8603
8924
|
throw invalid2(`${label}\u8DEF\u5F84\u9003\u9038\u9879\u76EE`);
|
|
8604
8925
|
await assertNoSymlinkComponents(project, relative2);
|
|
8605
8926
|
let stat;
|
|
@@ -8616,14 +8937,14 @@ async function assertNoSymlinkComponents(project, relative2) {
|
|
|
8616
8937
|
const parts = relative2.split("/").filter(Boolean);
|
|
8617
8938
|
let current = project;
|
|
8618
8939
|
for (const part of parts) {
|
|
8619
|
-
current =
|
|
8940
|
+
current = path10.join(current, part);
|
|
8620
8941
|
const stat = await fs6.lstat(current).catch(() => void 0);
|
|
8621
8942
|
if (stat?.isSymbolicLink()) throw invalid2(`\u8DEF\u5F84\u5305\u542B\u7B26\u53F7\u94FE\u63A5\uFF1A${relative2}`);
|
|
8622
8943
|
if (!stat) break;
|
|
8623
8944
|
}
|
|
8624
8945
|
}
|
|
8625
8946
|
async function realProject(requested) {
|
|
8626
|
-
const absolute =
|
|
8947
|
+
const absolute = path10.resolve(requested);
|
|
8627
8948
|
let project;
|
|
8628
8949
|
try {
|
|
8629
8950
|
project = await fs6.realpath(absolute);
|
|
@@ -8635,10 +8956,10 @@ async function realProject(requested) {
|
|
|
8635
8956
|
return project;
|
|
8636
8957
|
}
|
|
8637
8958
|
function safeRelative(reference, label) {
|
|
8638
|
-
if (!reference ||
|
|
8959
|
+
if (!reference || path10.isAbsolute(reference) || /[\r\n\0]/.test(reference)) {
|
|
8639
8960
|
throw invalid2(`${label}\u5FC5\u987B\u662F\u9879\u76EE\u5185\u76F8\u5BF9\u8DEF\u5F84`);
|
|
8640
8961
|
}
|
|
8641
|
-
const normalized =
|
|
8962
|
+
const normalized = path10.normalize(reference).split(path10.sep).join("/");
|
|
8642
8963
|
if (normalized === ".." || normalized.startsWith("../") || normalized === ".") {
|
|
8643
8964
|
throw invalid2(`${label}\u8DEF\u5F84\u9003\u9038\u9879\u76EE`);
|
|
8644
8965
|
}
|
|
@@ -8855,7 +9176,31 @@ recon.command("round").description("\u96F6\u7F51\u7EDC\uFF1A\u8BFB\u4E00\u4EFD\u
|
|
|
8855
9176
|
var seed = delivery.command("seed").description(
|
|
8856
9177
|
"\u628A\u987E\u95EE\u624B\u4E0A\u7684**\u5BA2\u6237\u8868**\u53D8\u6210\u4EA7\u54C1\u91CC\u7684\u884C\u3002\u26A0\uFE0F \u4E0E\u9876\u5C42 `hcm import <path>` \u4E0D\u662F\u4E00\u56DE\u4E8B\uFF1A\u90A3\u4E00\u6761\u5403 DataPackage YAML\uFF08fixture \u6CE8\u5165\u5668\uFF09\uFF0C\u8FD9\u4E00\u65CF\u5403\u5BA2\u6237\u7684 Excel"
|
|
8857
9178
|
);
|
|
9179
|
+
seed.command("find").argument("<term>", "\u8981\u627E\u7684\u8BCD\uFF1A\u5B57\u6BB5\u540D / \u4E2D\u6587\u540D\u79F0 / \u4E1A\u52A1\u8BDD\u672F\uFF08\u540C\u4E49\u8BCD\u3001\u63CF\u8FF0\u3001\u679A\u4E3E\u6807\u7B7E\u90FD\u641C\uFF09").description(
|
|
9180
|
+
"\u{1F534} **\u96F6\u7F51\u7EDC**\uFF1A\u5728 recon \u843D\u76D8\u7684\u5B57\u6BB5\u76EE\u5F55\u91CC\u8DE8\u6A21\u578B\u627E\u5B57\u6BB5\uFF0C\u4E00\u53D1\u8BF7\u6C42\u90FD\u4E0D\u53D1\uFF08\u6C14\u9699\u673A\u5668\u53EF\u7528\uFF09\u3002\u5199 mapping.json \u4E4B\u524D\u7528\u5B83\u628A\u4E00\u4E2A\u4E2D\u6587\u8BF4\u6CD5\u843D\u5230 `\u6A21\u578B.\u5B57\u6BB5`"
|
|
9181
|
+
).option("--out <dir>", "recon \u4EA7\u7269\u6839\uFF08\u57FA\u7EBF\u5728 <out>/recon/<\u79DF\u6237\u6BB5>/<\u6765\u6E90\u6BB5>\uFF09", ".").option("--tenant <id>", "\u79DF\u6237\uFF08\u96F6\u7F51\u7EDC \u21D2 \u65E0\u6CD5\u4ECE\u767B\u5F55\u6001\u5F97\u77E5\uFF0C\u5FC5\u987B\u7ED9\uFF1B\u8981\u4E0E\u8DD1 recon \u65F6\u90A3\u4E2A\u4E00\u81F4\uFF09").action((term, opts) => deliverySeedFindCommand(term, opts));
|
|
9182
|
+
seed.command("values").argument("<model>", "\u7801\u8868\u6A21\u578B\u540D\uFF08\u5982 CO_0001\uFF09\uFF1B`find` \u7684\u6307\u8DEF\u884C\u4F1A\u544A\u8BC9\u4F60\u662F\u54EA\u4E00\u5F20").description(
|
|
9183
|
+
"\u{1F534} **\u96F6\u7F51\u7EDC**\uFF1A\u6253\u5370\u4E00\u5F20\u7801\u8868\u7684 `id / code / name` \u5BF9\u7167\uFF0C\u62AC\u5934\u5148\u8BF4 completeness\u3002\u987E\u95EE\u6284 id \u5C31\u6284\u8FD9\u4E00\u4EFD\uFF08\u5F15\u7528\u5B57\u6BB5\u5B58\u7684\u662F id \u4E0D\u662F code\uFF09"
|
|
9184
|
+
).option("--out <dir>", "recon \u4EA7\u7269\u6839\uFF08\u57FA\u7EBF\u5728 <out>/recon/<\u79DF\u6237\u6BB5>/<\u6765\u6E90\u6BB5>\uFF09", ".").option("--tenant <id>", "\u79DF\u6237\uFF08\u96F6\u7F51\u7EDC \u21D2 \u65E0\u6CD5\u4ECE\u767B\u5F55\u6001\u5F97\u77E5\uFF0C\u5FC5\u987B\u7ED9\uFF1B\u8981\u4E0E\u8DD1 recon \u65F6\u90A3\u4E2A\u4E00\u81F4\uFF09").option(
|
|
9185
|
+
"--limit <n>",
|
|
9186
|
+
"\u6253\u51E0\u884C\u3002\u4E0D\u7ED9 \u21D2 \u8D70\u5B57\u8282\u9884\u7B97\uFF1B`0` \u21D2 \u5168\u90E8\u6253\u5370\uFF08\u9003\u751F\u95E8\uFF1A\u4F60\u8981\u7684\u90A3\u884C\u6070\u597D\u5728\u88AB\u622A\u6389\u7684\u90A3\u534A\u91CC\u65F6\u7528\u5B83\uFF09",
|
|
9187
|
+
(v) => Number(v)
|
|
9188
|
+
).action((model, opts) => deliverySeedValuesCommand(model, opts));
|
|
8858
9189
|
seed.command("plan").description("\u96F6\u5199\uFF1A\u8BFB\u5DE5\u4EF6 + \u6E90\u8868 + \u5200 2 \u7684\u57FA\u7EBF\uFF0C\u7B97\u51FA\u884C\u7EA7\u8BA1\u5212\u4E0E\u98CE\u9669\u6E05\u5355\u843D\u76D8\uFF08\u4E00\u53D1\u5199\u8BF7\u6C42\u90FD\u4E0D\u53D1\uFF09").option("--env <name>", "\u76EE\u6807\u73AF\u5883\u522B\u540D").option("--profile <name>", "\u8EAB\u4EFD\u6863\u6848").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD").option("--out <dir>", "recon \u4EA7\u7269\u6839\uFF08\u57FA\u7EBF\u5728 <out>/recon/<\u79DF\u6237\u6BB5>/<\u6765\u6E90\u6BB5>\uFF09", ".").option("--work <dir>", "work \u76EE\u5F55\uFF1B\u4E0D\u7ED9 \u21D2 <out>/work/<\u79DF\u6237\u6BB5>/").option("--mapping <file>", "\u5BFC\u5165\u6620\u5C04\u5DE5\u4EF6\uFF1B\u4E0D\u7ED9 \u21D2 <work>/mapping.json").option("--source-dir <dir>", "\u6E90\u8868\u6240\u5728\u76EE\u5F55\uFF08\u5DE5\u4EF6\u91CC\u5199\u7684\u662F\u76F8\u5BF9\u8DEF\u5F84\u65F6\u7528\u5B83\uFF09").option("--exemptions <file>", "\u7B7E\u5B57\u8C41\u514D\u53F0\u8D26\uFF08JSON \u6570\u7EC4\uFF09\uFF1B\u4E0D\u4F20\u4E0E\u4F20\u4E00\u4EFD\u7A7A\u53F0\u8D26\u662F\u4E24\u4E2A\u503C").action((opts) => deliverySeedPlanCommand(opts));
|
|
9190
|
+
seed.command("apply").description(
|
|
9191
|
+
"\u7167\u8BA1\u5212\u628A\u884C\u5EFA\u8FDB\u53BB\u3002**\u9ED8\u8BA4\u5E72\u8DD1**\uFF08\u4E00\u53D1\u5199\u8BF7\u6C42\u90FD\u4E0D\u53D1\uFF09\uFF0C\u8981\u771F\u5199\u5FC5\u987B\u663E\u5F0F `--execute`"
|
|
9192
|
+
).option("--env <name>", "\u76EE\u6807\u73AF\u5883\u522B\u540D").option("--profile <name>", "\u8EAB\u4EFD\u6863\u6848").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD").option("--out <dir>", "recon \u4EA7\u7269\u6839\uFF08\u57FA\u7EBF\u5728 <out>/recon/<\u79DF\u6237\u6BB5>/<\u6765\u6E90\u6BB5>\uFF09", ".").option("--work <dir>", "work \u76EE\u5F55\uFF1B\u4E0D\u7ED9 \u21D2 <out>/work/<\u79DF\u6237\u6BB5>/").option("--mapping <file>", "\u5BFC\u5165\u6620\u5C04\u5DE5\u4EF6\uFF1B\u4E0D\u7ED9 \u21D2 <work>/mapping.json").option("--execute", "\u771F\u5199\u3002\u4E0D\u52A0\u5219\u662F\u5E72\u8DD1", false).option("--resume", "\u8FD9\u4E2A work \u76EE\u5F55\u5DF2\u6709\u53F0\u8D26\u65F6\u63A5\u7740\u8DD1\uFF08kit \u7EDD\u4E0D\u66FF\u4F60\u5220\u53F0\u8D26\uFF09", false).option("--sample <n>", "\u672C\u8F6E\u6700\u591A\u82B1 n \u4E2A\u5199\u8BF7\u6C42\uFF0C\u5E76\u5BF9\u5B83\u4EEC\u9010\u884C\u56DE\u8BFB\u590D\u9A8C", (v) => Number(v)).option(
|
|
9193
|
+
"--force-stale",
|
|
9194
|
+
"\u57FA\u7EBF\u4E0E\u8FD9\u4E2A\u73AF\u5883\u5BF9\u4E0D\u4E0A\u65F6\u4ECD\u7136\u653E\u884C\uFF0C\u5E76\u628A\u8FD9\u4E00\u7B14\u8BB0\u8FDB\u53F0\u8D26\u3002\u26A0\uFE0F \u4E0D\u8C41\u514D\u300C\u8BA1\u5212 vs \u57FA\u7EBF\u300D\u4E0E\u300C\u57FA\u7EBF\u662F\u4E0D\u662F\u4E00\u8F6E\u300D\u4E24\u6761\u524D\u63D0",
|
|
9195
|
+
false
|
|
9196
|
+
).action((opts) => deliverySeedApplyCommand(opts));
|
|
9197
|
+
seed.command("verify").description(
|
|
9198
|
+
"\u628A\u4E24\u5C42\u8BC1\u636E\uFF08\u53F0\u8D26+\u8BA1\u5212 / \u5E93\u91CC\u73B0\u5728\u600E\u4E48\u6837\uFF09\u6E32\u67D3\u6210\u4E00\u9875\u53EF\u7B7E\u5B57\u7684\u7EB8\uFF0C\u518D\u7ED9\u4E00\u4E2A\u9000\u51FA\u7801\u3002\u6C14\u9699\u673A\u5668\u4E0A\u7528 `--ledger-only`\uFF1A\u53EA\u51FA\u53F0\u8D26\u90A3\u4E00\u5C42\uFF0C\u4E00\u53D1\u8BF7\u6C42\u90FD\u4E0D\u53D1"
|
|
9199
|
+
).option("--env <name>", "\u76EE\u6807\u73AF\u5883\u522B\u540D").option("--profile <name>", "\u8EAB\u4EFD\u6863\u6848").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD").option("--out <dir>", "recon \u4EA7\u7269\u6839", ".").option("--work <dir>", "work \u76EE\u5F55\uFF1B\u4E0D\u7ED9 \u21D2 <out>/work/<\u79DF\u6237\u6BB5>/").option(
|
|
9200
|
+
LEDGER_ONLY_FLAG,
|
|
9201
|
+
"\u53EA\u51FA\u53F0\u8D26\u90A3\u4E00\u5C42\uFF08\u96F6\u7F51\u7EDC\uFF0C\u4E00\u53D1\u8BF7\u6C42\u90FD\u4E0D\u53D1\uFF09\u3002\u26A0\uFE0F **\u5E93\u91CC\u73B0\u5728\u600E\u4E48\u6837\uFF0C\u90A3\u4E00\u8D9F\u4E00\u4E2A\u5B57\u90FD\u6CA1\u95EE** \u2014\u2014 \u522B\u62FF\u5B83\u5F53\u9A8C\u6536\u901A\u8FC7",
|
|
9202
|
+
false
|
|
9203
|
+
).action((opts) => deliverySeedVerifyCommand(opts));
|
|
8859
9204
|
delivery.command("gate0").description(
|
|
8860
9205
|
"\u96F6\u7F51\u7EDC\uFF1A\u626B\u4E00\u4EFD skill \u7684\u6B63\u6587\uFF0C\u628A\u73AF\u5883\u4E8B\u5B9E / \u672A\u767B\u8BB0\u7684\u534F\u8BAE\u5F62\u6001 / \u4EA7\u7269\u8DEF\u5F84\u6321\u5728\u6210\u7A3F\u4E4B\u5916"
|
|
8861
9206
|
).requiredOption("--skills <dir>", "\u8981\u626B\u7684 skill \u6839\u76EE\u5F55\uFF08\u6B63\u6587 + references/ \u5168\u76EE\u5F55\uFF0C\u540C\u4E00\u5224\u636E\uFF09").option("--recon <dir>", "\u57FA\u7EBF\u4EA7\u7269\u76EE\u5F55\uFF08<out>/recon/<\u79DF\u6237\u6BB5>/<\u6765\u6E90\u6BB5>\uFF09", ".").option(
|