@hcmai/cli 0.4.7 → 0.4.8
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 +191 -90
- package/dist/index.js.map +1 -1
- package/dist/skills/manifest.json +10 -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(path12) {
|
|
527
|
+
const segs = path12.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(path12) {
|
|
1710
|
+
const segs = (path12 ?? "").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
|
}
|
|
@@ -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(path12) {
|
|
3088
|
+
if (statSync(path12).isFile()) return [path12];
|
|
3089
3089
|
const out = [];
|
|
3090
3090
|
const walk = (dir) => {
|
|
3091
3091
|
for (const name of readdirSync(dir).sort()) {
|
|
@@ -3094,7 +3094,7 @@ function collectYmlFiles(path11) {
|
|
|
3094
3094
|
else if (full.endsWith(".yml") || full.endsWith(".yaml")) out.push(full);
|
|
3095
3095
|
}
|
|
3096
3096
|
};
|
|
3097
|
-
walk(
|
|
3097
|
+
walk(path12);
|
|
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(path12, args) {
|
|
3106
3106
|
try {
|
|
3107
|
-
const files = collectYmlFiles(
|
|
3107
|
+
const files = collectYmlFiles(path12);
|
|
3108
3108
|
const fixtures = files.map(
|
|
3109
3109
|
(f) => parseFixture(readFileSync2(f, "utf8"), relative(process.cwd(), f))
|
|
3110
3110
|
);
|
|
@@ -5994,17 +5994,17 @@ async function metaListCommand(args) {
|
|
|
5994
5994
|
fail5(e, args);
|
|
5995
5995
|
}
|
|
5996
5996
|
}
|
|
5997
|
-
async function metaGetCommand(
|
|
5997
|
+
async function metaGetCommand(path12, args) {
|
|
5998
5998
|
try {
|
|
5999
5999
|
const c = await client2(args);
|
|
6000
|
-
const content = await getTenantMeta(c.raw(),
|
|
6000
|
+
const content = await getTenantMeta(c.raw(), path12);
|
|
6001
6001
|
process.stdout.write(content.endsWith("\n") ? content : content + "\n");
|
|
6002
6002
|
process.exit(0);
|
|
6003
6003
|
} catch (e) {
|
|
6004
6004
|
fail5(e, args);
|
|
6005
6005
|
}
|
|
6006
6006
|
}
|
|
6007
|
-
async function metaSetCommand(
|
|
6007
|
+
async function metaSetCommand(path12, args) {
|
|
6008
6008
|
try {
|
|
6009
6009
|
if (!args.file) {
|
|
6010
6010
|
throw new CliError18({
|
|
@@ -6021,7 +6021,7 @@ async function metaSetCommand(path11, args) {
|
|
|
6021
6021
|
}) : await fsp3.readFile(args.file, "utf8");
|
|
6022
6022
|
if (args.dryRun) {
|
|
6023
6023
|
process.stdout.write(
|
|
6024
|
-
`[dry-run] \u5C06\u5199\u5165 ${
|
|
6024
|
+
`[dry-run] \u5C06\u5199\u5165 ${path12}\uFF08${Buffer.byteLength(content)} B\uFF09\u2014\u2014\u672A\u5B9E\u9645\u5199\u5165
|
|
6025
6025
|
---
|
|
6026
6026
|
${content}
|
|
6027
6027
|
`
|
|
@@ -6029,10 +6029,10 @@ ${content}
|
|
|
6029
6029
|
process.exit(0);
|
|
6030
6030
|
}
|
|
6031
6031
|
const c = await client2(args);
|
|
6032
|
-
const result = await saveTenantMeta(c.raw(),
|
|
6032
|
+
const result = await saveTenantMeta(c.raw(), path12, content);
|
|
6033
6033
|
const fmt = args.output ?? "json";
|
|
6034
6034
|
if (fmt !== "json") {
|
|
6035
|
-
process.stdout.write(`\u2705 \u5DF2\u5199\u5165 ${
|
|
6035
|
+
process.stdout.write(`\u2705 \u5DF2\u5199\u5165 ${path12}
|
|
6036
6036
|
\u8BB0\u5F97\u6E05\u7F13\u5B58\uFF1Ahcm cache clear-meta <Model>
|
|
6037
6037
|
`);
|
|
6038
6038
|
}
|
|
@@ -6043,19 +6043,19 @@ ${content}
|
|
|
6043
6043
|
fail5(e, args);
|
|
6044
6044
|
}
|
|
6045
6045
|
}
|
|
6046
|
-
async function metaDeleteCommand(
|
|
6046
|
+
async function metaDeleteCommand(path12, args) {
|
|
6047
6047
|
try {
|
|
6048
6048
|
if (!args.yes) {
|
|
6049
|
-
const ok = await promptConfirm(`\u5C06\u5220\u9664\u5143\u6570\u636E ${
|
|
6049
|
+
const ok = await promptConfirm(`\u5C06\u5220\u9664\u5143\u6570\u636E ${path12}\uFF0C\u6B64\u64CD\u4F5C\u4E0D\u53EF\u9006\u3002\u7EE7\u7EED\uFF1F`);
|
|
6050
6050
|
if (!ok) {
|
|
6051
6051
|
process.stderr.write("\u5DF2\u53D6\u6D88\n");
|
|
6052
6052
|
process.exit(1);
|
|
6053
6053
|
}
|
|
6054
6054
|
}
|
|
6055
6055
|
const c = await client2(args);
|
|
6056
|
-
const result = await deleteTenantMeta(c.raw(),
|
|
6056
|
+
const result = await deleteTenantMeta(c.raw(), path12);
|
|
6057
6057
|
const fmt = args.output ?? "json";
|
|
6058
|
-
if (fmt !== "json") process.stdout.write(`\u{1F5D1}\uFE0F \u5DF2\u5220\u9664 ${
|
|
6058
|
+
if (fmt !== "json") process.stdout.write(`\u{1F5D1}\uFE0F \u5DF2\u5220\u9664 ${path12}
|
|
6059
6059
|
`);
|
|
6060
6060
|
process.stdout.write(formatObject17(result, { format: fmt }) + "\n");
|
|
6061
6061
|
process.exit(0);
|
|
@@ -7501,6 +7501,8 @@ async function identityRemove(name) {
|
|
|
7501
7501
|
|
|
7502
7502
|
// src/commands/delivery-action-policy.ts
|
|
7503
7503
|
init_auth_guard();
|
|
7504
|
+
import { existsSync as existsSync2 } from "fs";
|
|
7505
|
+
import { join as pathJoin } from "path";
|
|
7504
7506
|
import {
|
|
7505
7507
|
HcmClient as HcmClient18,
|
|
7506
7508
|
formatObject as formatObject19
|
|
@@ -7525,7 +7527,17 @@ var GUARDED_EXECUTOR_REASON_CODES = /* @__PURE__ */ new Set([
|
|
|
7525
7527
|
"cache-mutation",
|
|
7526
7528
|
"setting-write",
|
|
7527
7529
|
"credential-reset",
|
|
7528
|
-
"action-write"
|
|
7530
|
+
"action-write",
|
|
7531
|
+
// workspace 侧只收**输入可完整绑进计划**的那两个:它们的入参是 workspace key,
|
|
7532
|
+
// 没有外部载荷文件。
|
|
7533
|
+
//
|
|
7534
|
+
// 🔴 刻意不收 workspace-push / metadata-write / workspace-local-change:
|
|
7535
|
+
// push 读的是整个本地目录、meta set 读 --file 指向的任意文件,而载荷绑定只覆盖
|
|
7536
|
+
// --data-file / --params-file(PAYLOAD_FILE_FLAGS)。绑不住就意味着「批准时看到的内容」
|
|
7537
|
+
// 与「执行时实际读到的内容」可以不同 —— 那正是受控执行要挡住的东西。
|
|
7538
|
+
// 要收它们,得先把目录/文件载荷也纳入绑定与 assertPayloadsUnchanged。
|
|
7539
|
+
"workspace-create",
|
|
7540
|
+
"workspace-activate"
|
|
7529
7541
|
]);
|
|
7530
7542
|
function assessDeliveryCommand(inputArgv, options = {}) {
|
|
7531
7543
|
const argv = inputArgv[0] === "--" ? inputArgv.slice(1) : [...inputArgv];
|
|
@@ -7866,9 +7878,26 @@ async function assessEffectiveDeliveryCommand(inputArgv, dependencies = {}) {
|
|
|
7866
7878
|
const resolution = await (dependencies.resolveAction ?? resolveCoreAction)(request);
|
|
7867
7879
|
return assessDeliveryCommand(inputArgv, { actionResolution: resolution });
|
|
7868
7880
|
}
|
|
7881
|
+
function withProjectReadiness(assessment, projectRoot = ".") {
|
|
7882
|
+
const projectFile = pathJoin(projectRoot, ".hcm-delivery", "project.yml");
|
|
7883
|
+
const projectInitialized = existsSync2(projectFile);
|
|
7884
|
+
if (projectInitialized || !assessment.guardedExecutionAvailable) {
|
|
7885
|
+
return { ...assessment, projectInitialized };
|
|
7886
|
+
}
|
|
7887
|
+
const requirements = [...assessment.requirements ?? []];
|
|
7888
|
+
if (!requirements.includes("delivery-project")) requirements.push("delivery-project");
|
|
7889
|
+
return {
|
|
7890
|
+
...assessment,
|
|
7891
|
+
projectInitialized,
|
|
7892
|
+
requirements,
|
|
7893
|
+
modePolicy: assessment.modePolicy ? { ...assessment.modePolicy, controlled: "deny" } : assessment.modePolicy,
|
|
7894
|
+
projectNextStep: `\u672C\u9879\u76EE\u5C1A\u672A\u521D\u59CB\u5316\uFF08\u7F3A ${projectFile}\uFF09\uFF1B\u5148\u8DD1 hcm delivery init`
|
|
7895
|
+
};
|
|
7896
|
+
}
|
|
7869
7897
|
async function deliveryAssessCommand(argv, args) {
|
|
7870
7898
|
const assessment = await assessEffectiveDeliveryCommand(argv);
|
|
7871
|
-
|
|
7899
|
+
const enriched = withProjectReadiness(assessment);
|
|
7900
|
+
process.stdout.write(formatObject19(enriched, { format: args.output ?? "json" }) + "\n");
|
|
7872
7901
|
}
|
|
7873
7902
|
async function resolveCoreAction(request) {
|
|
7874
7903
|
try {
|
|
@@ -7963,13 +7992,84 @@ function flagValue2(argv, flag) {
|
|
|
7963
7992
|
return index >= 0 ? argv[index + 1] : void 0;
|
|
7964
7993
|
}
|
|
7965
7994
|
|
|
7995
|
+
// src/commands/delivery-init.ts
|
|
7996
|
+
init_exit();
|
|
7997
|
+
import { promises as fs6 } from "fs";
|
|
7998
|
+
import path6 from "path";
|
|
7999
|
+
import { formatObject as formatObject20 } from "@hcmai/sdk";
|
|
8000
|
+
var MODES = ["plan-only", "controlled"];
|
|
8001
|
+
var SCAFFOLD_DIRS = ["work", "decisions", "evidence"];
|
|
8002
|
+
function renderProjectYml(mode) {
|
|
8003
|
+
return [
|
|
8004
|
+
"# HCM \u987E\u95EE\u4EA4\u4ED8\u9879\u76EE\u914D\u7F6E\uFF08hcm delivery init \u751F\u6210\uFF09",
|
|
8005
|
+
"#",
|
|
8006
|
+
"# deliveryMode \u51B3\u5B9A\u8FD9\u4E2A\u9879\u76EE\u5141\u8BB8\u8D70\u5230\u54EA\u4E00\u6B65\uFF1A",
|
|
8007
|
+
"# plan-only \u2014\u2014 \u53EA\u5141\u8BB8 assess / prepare \u51FA\u8BA1\u5212\uFF0Cexecute \u4E00\u5F8B\u62D2\u7EDD",
|
|
8008
|
+
"# controlled \u2014\u2014 \u5141\u8BB8 prepare + execute \u5355\u6B21\u53D7\u63A7\u6267\u884C\uFF08\u4ECD\u9700\u9010\u6B21\u6279\u51C6\uFF09",
|
|
8009
|
+
"#",
|
|
8010
|
+
"# \u{1F534} \u5B83\u4E0D\u653E\u5BBD\u4EFB\u4F55\u98CE\u9669\u5224\u7EA7\uFF1AR3 \u5728\u4E24\u79CD\u6A21\u5F0F\u4E0B\u90FD\u62D2\u7EDD\uFF0CR2 \u4ECD\u8981\u8BA1\u5212\u3001\u56DE\u6EDA\u8BF4\u660E\u4E0E\u6536\u636E\u3002",
|
|
8011
|
+
"# \u6539\u8FD9\u4E00\u884C\u53EA\u6539\u300C\u672C\u9879\u76EE\u5141\u4E0D\u5141\u8BB8\u771F\u7684\u6267\u884C\u300D\uFF0C\u4E0D\u6539\u300C\u8FD9\u6761\u547D\u4EE4\u6709\u591A\u5371\u9669\u300D\u3002",
|
|
8012
|
+
`deliveryMode: ${mode}`,
|
|
8013
|
+
""
|
|
8014
|
+
].join("\n");
|
|
8015
|
+
}
|
|
8016
|
+
async function deliveryInitCommand(args) {
|
|
8017
|
+
try {
|
|
8018
|
+
const mode = args.mode ?? "controlled";
|
|
8019
|
+
if (!MODES.includes(mode)) {
|
|
8020
|
+
throw new Error(
|
|
8021
|
+
`--mode \u53EA\u63A5\u53D7 ${MODES.join(" | ")}\uFF0C\u6536\u5230 "${args.mode}"
|
|
8022
|
+
\u8FD9\u4E24\u4E2A\u503C\u662F delivery prepare \u8BA4\u5F97\u7684\u5168\u90E8\uFF1B\u5199\u522B\u7684\u503C prepare \u4F1A\u62D2\u7EDD\u52A0\u8F7D\u3002`
|
|
8023
|
+
);
|
|
8024
|
+
}
|
|
8025
|
+
const root = path6.resolve(args.project ?? ".");
|
|
8026
|
+
const dir = path6.join(root, ".hcm-delivery");
|
|
8027
|
+
const file = path6.join(dir, "project.yml");
|
|
8028
|
+
let existed = false;
|
|
8029
|
+
try {
|
|
8030
|
+
await fs6.access(file);
|
|
8031
|
+
existed = true;
|
|
8032
|
+
} catch {
|
|
8033
|
+
existed = false;
|
|
8034
|
+
}
|
|
8035
|
+
if (existed && !args.force) {
|
|
8036
|
+
throw new Error(
|
|
8037
|
+
`\u9879\u76EE\u914D\u7F6E\u5DF2\u5B58\u5728\uFF1A${file}
|
|
8038
|
+
\u4E0D\u8986\u76D6\u5DF2\u6709\u914D\u7F6E\u2014\u2014\u5B83\u51B3\u5B9A\u672C\u9879\u76EE\u5141\u4E0D\u5141\u8BB8\u771F\u7684\u6267\u884C\u3002
|
|
8039
|
+
\u786E\u8981\u91CD\u5199\uFF1Ahcm delivery init --force`
|
|
8040
|
+
);
|
|
8041
|
+
}
|
|
8042
|
+
await fs6.mkdir(dir, { recursive: true });
|
|
8043
|
+
await fs6.writeFile(file, renderProjectYml(mode), "utf8");
|
|
8044
|
+
const created = [];
|
|
8045
|
+
for (const sub of SCAFFOLD_DIRS) {
|
|
8046
|
+
const p = path6.join(root, sub);
|
|
8047
|
+
await fs6.mkdir(p, { recursive: true });
|
|
8048
|
+
created.push(sub + "/");
|
|
8049
|
+
}
|
|
8050
|
+
const result = {
|
|
8051
|
+
project: root,
|
|
8052
|
+
projectFile: file,
|
|
8053
|
+
deliveryMode: mode,
|
|
8054
|
+
overwritten: existed,
|
|
8055
|
+
scaffold: created,
|
|
8056
|
+
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"
|
|
8057
|
+
};
|
|
8058
|
+
process.stdout.write(formatObject20(result, { format: args.output ?? "json" }) + "\n");
|
|
8059
|
+
process.exit(0);
|
|
8060
|
+
} catch (e) {
|
|
8061
|
+
exitWithError(e);
|
|
8062
|
+
process.exit(1);
|
|
8063
|
+
}
|
|
8064
|
+
}
|
|
8065
|
+
|
|
7966
8066
|
// src/commands/delivery-doctor.ts
|
|
7967
8067
|
init_auth_guard();
|
|
7968
8068
|
init_exit();
|
|
7969
8069
|
import {
|
|
7970
8070
|
HcmClient as HcmClient19,
|
|
7971
8071
|
fetchReconIdentity,
|
|
7972
|
-
formatObject as
|
|
8072
|
+
formatObject as formatObject21,
|
|
7973
8073
|
fromAxiosError as fromAxiosError18,
|
|
7974
8074
|
httpProbe,
|
|
7975
8075
|
runDoctor
|
|
@@ -7995,7 +8095,7 @@ async function deliveryDoctorCommand(args) {
|
|
|
7995
8095
|
const report = await runDoctor(probe, identity2);
|
|
7996
8096
|
const fmt = args.output ?? "json";
|
|
7997
8097
|
if (fmt !== "json") process.stdout.write(render2(report) + "\n");
|
|
7998
|
-
process.stdout.write(
|
|
8098
|
+
process.stdout.write(formatObject21(report, { format: fmt }) + "\n");
|
|
7999
8099
|
process.exit(report.ok ? 0 : 1);
|
|
8000
8100
|
} catch (e) {
|
|
8001
8101
|
const err = e;
|
|
@@ -8013,7 +8113,7 @@ import {
|
|
|
8013
8113
|
ReconLayout,
|
|
8014
8114
|
ROUND_EXIT_CODES,
|
|
8015
8115
|
computeReconSourceKey,
|
|
8016
|
-
formatObject as
|
|
8116
|
+
formatObject as formatObject22,
|
|
8017
8117
|
fromAxiosError as fromAxiosError19,
|
|
8018
8118
|
httpProbe as httpProbe2,
|
|
8019
8119
|
inspectRound,
|
|
@@ -8033,7 +8133,7 @@ async function deliveryReconCommand(args) {
|
|
|
8033
8133
|
onlyModel: args.model ?? null,
|
|
8034
8134
|
identity: ctx.tenantId ? { requestedTenantId: ctx.tenantId } : null
|
|
8035
8135
|
});
|
|
8036
|
-
process.stdout.write(
|
|
8136
|
+
process.stdout.write(formatObject22(summary, { format: args.output ?? "json" }) + "\n");
|
|
8037
8137
|
} catch (e) {
|
|
8038
8138
|
const err = e;
|
|
8039
8139
|
if (err?.isAxiosError) exitWithError(fromAxiosError19(err, args.env));
|
|
@@ -8047,7 +8147,7 @@ async function deliveryReconRoundCommand(args) {
|
|
|
8047
8147
|
const result = inspectRound(args.dir ?? ".");
|
|
8048
8148
|
const fmt = args.output ?? "json";
|
|
8049
8149
|
if (fmt !== "json") process.stdout.write(renderRound(result));
|
|
8050
|
-
process.stdout.write(
|
|
8150
|
+
process.stdout.write(formatObject22(result, { format: fmt }) + "\n");
|
|
8051
8151
|
code = ROUND_EXIT_CODES[result.state];
|
|
8052
8152
|
} catch (e) {
|
|
8053
8153
|
exitWithError(e);
|
|
@@ -8065,14 +8165,14 @@ import {
|
|
|
8065
8165
|
GAP_REASONS,
|
|
8066
8166
|
deriveAclass,
|
|
8067
8167
|
exitCode as gate0ExitCode,
|
|
8068
|
-
formatObject as
|
|
8168
|
+
formatObject as formatObject23,
|
|
8069
8169
|
inspectRound as inspectRound2,
|
|
8070
8170
|
loadProtocolFacts,
|
|
8071
8171
|
scan
|
|
8072
8172
|
} from "@hcmai/sdk";
|
|
8073
|
-
import * as
|
|
8173
|
+
import * as path7 from "path";
|
|
8074
8174
|
function renderGate0(result, skillRoot) {
|
|
8075
|
-
const where = skillRoot ? `\uFF08${
|
|
8175
|
+
const where = skillRoot ? `\uFF08${path7.resolve(skillRoot)}\uFF09` : "";
|
|
8076
8176
|
const lines = [
|
|
8077
8177
|
`\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`
|
|
8078
8178
|
];
|
|
@@ -8110,7 +8210,7 @@ async function deliveryGate0Command(args) {
|
|
|
8110
8210
|
const merged = { ...result, premise: premise5 };
|
|
8111
8211
|
const fmt = args.output ?? "json";
|
|
8112
8212
|
if (fmt !== "json") process.stdout.write(renderGate0(merged, skillRoot));
|
|
8113
|
-
process.stdout.write(`${
|
|
8213
|
+
process.stdout.write(`${formatObject23(merged, { format: fmt })}
|
|
8114
8214
|
`);
|
|
8115
8215
|
for (const problem of premise5) {
|
|
8116
8216
|
process.stderr.write(`\u{1F534} \u524D\u63D0\u4E0D\u6210\u7ACB\uFF08${problem.reason}\uFF09\uFF1A${problem.message}
|
|
@@ -8183,8 +8283,8 @@ import {
|
|
|
8183
8283
|
writeImportPlan,
|
|
8184
8284
|
writeRisk
|
|
8185
8285
|
} from "@hcmai/sdk";
|
|
8186
|
-
import { existsSync as
|
|
8187
|
-
import * as
|
|
8286
|
+
import { existsSync as existsSync3 } from "fs";
|
|
8287
|
+
import * as path8 from "path";
|
|
8188
8288
|
function premise(message, hint = "") {
|
|
8189
8289
|
process.stderr.write(message + (hint ? `
|
|
8190
8290
|
\u2192 ${hint}` : "") + "\n");
|
|
@@ -8195,7 +8295,7 @@ async function runSeedPlan(args, client3) {
|
|
|
8195
8295
|
const tenant2 = tenantOf(client3);
|
|
8196
8296
|
const work = seedWorkDir({ out, tenant: tenant2, work: args.work ?? null, mapping: args.mapping ?? null });
|
|
8197
8297
|
const mappingPath = seedMappingPath({ out, tenant: tenant2, mapping: args.mapping ?? null }, work);
|
|
8198
|
-
if (!
|
|
8298
|
+
if (!existsSync3(mappingPath)) {
|
|
8199
8299
|
return premise(
|
|
8200
8300
|
`\u8BFB\u4E0D\u5230\u5BFC\u5165\u6620\u5C04\u5DE5\u4EF6\uFF1A${mappingPath}`,
|
|
8201
8301
|
"\u5DE5\u4EF6\u662F\u987E\u95EE\u81EA\u5DF1\u5199\u7684\uFF08\u5951\u7EA6\u89C1 README \u7684 `work/mapping.json` \u4E00\u8282\uFF09\u3002\u5199\u5728\u522B\u5904\u5C31\u7528 `--mapping <\u8DEF\u5F84>` \u6307\u8FC7\u53BB\uFF0C\u6216\u7528 `--work <\u76EE\u5F55>` \u6362 work \u76EE\u5F55\u3002"
|
|
@@ -8211,13 +8311,13 @@ async function runSeedPlan(args, client3) {
|
|
|
8211
8311
|
const reconDir = candidates[0].reconDir;
|
|
8212
8312
|
if (candidates.length > 1) {
|
|
8213
8313
|
process.stderr.write(
|
|
8214
|
-
`\u26A0\uFE0F \u540C\u79DF\u6237\u4E0B\u6709 ${candidates.length} \u4EFD\u57FA\u7EBF\uFF0C\u672C\u8F6E\u8BFB\u7684\u662F \`${
|
|
8314
|
+
`\u26A0\uFE0F \u540C\u79DF\u6237\u4E0B\u6709 ${candidates.length} \u4EFD\u57FA\u7EBF\uFF0C\u672C\u8F6E\u8BFB\u7684\u662F \`${path8.basename(reconDir)}\`\uFF1A` + candidates.slice(1).map((c) => `\`${path8.basename(c.reconDir)}\``).join("\u3001") + " \u672A\u88AB\u8BFB\u53D6 \u2014\u2014 \u4E0D\u540C sourceKey \u7684\u4EA7\u7269**\u4E0D\u53EF\u4E92\u6362**\u3002\n"
|
|
8215
8315
|
);
|
|
8216
8316
|
}
|
|
8217
8317
|
const round = inspectRound3(reconDir);
|
|
8218
8318
|
process.stderr.write(roundWarning(round));
|
|
8219
8319
|
const baseline = {
|
|
8220
|
-
path: `${
|
|
8320
|
+
path: `${path8.basename(path8.dirname(reconDir))}/${path8.basename(reconDir)}`,
|
|
8221
8321
|
roundId: round.roundId ?? null
|
|
8222
8322
|
};
|
|
8223
8323
|
let exemptions = null;
|
|
@@ -8477,9 +8577,9 @@ async function deliverySeedVerifyCommand(args) {
|
|
|
8477
8577
|
}
|
|
8478
8578
|
|
|
8479
8579
|
// src/commands/delivery-seed-find.ts
|
|
8480
|
-
import { existsSync as
|
|
8580
|
+
import { existsSync as existsSync4 } from "fs";
|
|
8481
8581
|
import { readFileSync as readFileSync5 } from "fs";
|
|
8482
|
-
import * as
|
|
8582
|
+
import * as path9 from "path";
|
|
8483
8583
|
import {
|
|
8484
8584
|
INIT_EXIT_CODES as INIT_EXIT_CODES2,
|
|
8485
8585
|
ValueHints,
|
|
@@ -8493,10 +8593,10 @@ import {
|
|
|
8493
8593
|
valuesRoundCaveat
|
|
8494
8594
|
} from "@hcmai/sdk";
|
|
8495
8595
|
function provenance(chosenReconDir, others) {
|
|
8496
|
-
let line = `> \u57FA\u7EBF\uFF1A\`${
|
|
8596
|
+
let line = `> \u57FA\u7EBF\uFF1A\`${path9.basename(chosenReconDir)}\`
|
|
8497
8597
|
`;
|
|
8498
8598
|
if (others.length > 0) {
|
|
8499
|
-
line += `> \u26A0\uFE0F \u540C\u79DF\u6237\u4E0B\u53E6\u6709 ${others.length} \u4EFD\u57FA\u7EBF\u672A\u88AB\u8BFB\u53D6\uFF1A` + others.map((o) => `\`${
|
|
8599
|
+
line += `> \u26A0\uFE0F \u540C\u79DF\u6237\u4E0B\u53E6\u6709 ${others.length} \u4EFD\u57FA\u7EBF\u672A\u88AB\u8BFB\u53D6\uFF1A` + others.map((o) => `\`${path9.basename(o)}\``).join("\u3001") + " \u2014\u2014 \u4E0D\u540C sourceKey \u7684\u4EA7\u7269**\u4E0D\u53EF\u4E92\u6362**\u3002\n";
|
|
8500
8600
|
}
|
|
8501
8601
|
return `${line}
|
|
8502
8602
|
`;
|
|
@@ -8538,7 +8638,7 @@ function runSeedFind(args) {
|
|
|
8538
8638
|
const chosen = { reconDir: picked.reconDir, indexFile: picked.indexFile };
|
|
8539
8639
|
const prefix = picked.prefix;
|
|
8540
8640
|
process.stdout.write(prefix);
|
|
8541
|
-
if (!
|
|
8641
|
+
if (!existsSync4(chosen.indexFile)) {
|
|
8542
8642
|
return premise2(`\u7D22\u5F15\u6587\u4EF6\u5728\u9009\u4E2D\u4E4B\u540E\u6D88\u5931\u4E86\uFF1A${chosen.indexFile}`);
|
|
8543
8643
|
}
|
|
8544
8644
|
const { rows, problems } = loadRows(readFileSync5(chosen.indexFile, "utf-8"));
|
|
@@ -8833,7 +8933,7 @@ import {
|
|
|
8833
8933
|
runTriageRound
|
|
8834
8934
|
} from "@hcmai/sdk";
|
|
8835
8935
|
import { mkdirSync, readFileSync as readFileSync7, writeFileSync as writeFileSync2 } from "fs";
|
|
8836
|
-
import * as
|
|
8936
|
+
import * as path10 from "path";
|
|
8837
8937
|
var DEFAULT_CAPABILITIES4 = "default";
|
|
8838
8938
|
function premise4(message, hint) {
|
|
8839
8939
|
process.stderr.write(`\u{1F534} \u524D\u63D0\u4E0D\u6210\u7ACB\uFF1A${message}
|
|
@@ -8869,8 +8969,8 @@ function renderProblems(rows) {
|
|
|
8869
8969
|
`;
|
|
8870
8970
|
}
|
|
8871
8971
|
function writeTriageArtifact(outDir, body) {
|
|
8872
|
-
const out =
|
|
8873
|
-
mkdirSync(
|
|
8972
|
+
const out = path10.join(outDir, "work", "triage.md");
|
|
8973
|
+
mkdirSync(path10.dirname(out), { recursive: true });
|
|
8874
8974
|
writeFileSync2(out, body, "utf8");
|
|
8875
8975
|
return out;
|
|
8876
8976
|
}
|
|
@@ -8910,9 +9010,9 @@ async function deliveryTriageCommand(args) {
|
|
|
8910
9010
|
// src/commands/delivery-execution.ts
|
|
8911
9011
|
import { createHash as createHash5, randomBytes as secureRandomBytes } from "crypto";
|
|
8912
9012
|
import { spawn } from "child_process";
|
|
8913
|
-
import { createReadStream, promises as
|
|
8914
|
-
import
|
|
8915
|
-
import { CliError as CliError20, CliErrorCode as CliErrorCode19, formatObject as
|
|
9013
|
+
import { createReadStream, promises as fs7 } from "fs";
|
|
9014
|
+
import path11 from "path";
|
|
9015
|
+
import { CliError as CliError20, CliErrorCode as CliErrorCode19, formatObject as formatObject24 } from "@hcmai/sdk";
|
|
8916
9016
|
init_exit();
|
|
8917
9017
|
var EXECUTION_CONTRACT_VERSION = "2026-08-29.controlled-v3";
|
|
8918
9018
|
var DEFAULT_TTL_SECONDS = 15 * 60;
|
|
@@ -8951,11 +9051,11 @@ async function prepareDeliveryExecution(input) {
|
|
|
8951
9051
|
};
|
|
8952
9052
|
const planId = sha2565(canonicalJson(core)).slice(0, 24);
|
|
8953
9053
|
const plan = { ...core, planId };
|
|
8954
|
-
const plansDir =
|
|
9054
|
+
const plansDir = path11.join(project, ".hcm-delivery", "execution-plans");
|
|
8955
9055
|
await safeManagedDirectory(project, ".hcm-delivery/execution-plans", plansDir);
|
|
8956
|
-
const planFile =
|
|
9056
|
+
const planFile = path11.join(plansDir, `${planId}.json`);
|
|
8957
9057
|
try {
|
|
8958
|
-
await
|
|
9058
|
+
await fs7.writeFile(planFile, `${JSON.stringify(plan, null, 2)}
|
|
8959
9059
|
`, {
|
|
8960
9060
|
encoding: "utf8",
|
|
8961
9061
|
mode: 384,
|
|
@@ -8972,7 +9072,7 @@ async function executeDeliveryPlan(input) {
|
|
|
8972
9072
|
if (await readProjectMode(project) !== "controlled") {
|
|
8973
9073
|
throw invalid2("\u9879\u76EE\u4E0D\u662F controlled\uFF0C\u4E0D\u80FD\u6267\u884C R2 \u8BA1\u5212");
|
|
8974
9074
|
}
|
|
8975
|
-
const planFile =
|
|
9075
|
+
const planFile = path11.join(project, ".hcm-delivery", "execution-plans", `${input.planId}.json`);
|
|
8976
9076
|
const plan = await readPlan(project, planFile);
|
|
8977
9077
|
if (plan.planId !== input.planId || computePlanId(plan) !== input.planId) {
|
|
8978
9078
|
throw invalid2("\u6267\u884C\u8BA1\u5212\u5185\u5BB9\u4E0E planId \u6458\u8981\u4E0D\u4E00\u81F4");
|
|
@@ -9003,13 +9103,13 @@ async function executeDeliveryPlan(input) {
|
|
|
9003
9103
|
await assertDocumentUnchanged(project, plan.documents.rollback, "\u56DE\u6EDA\u8BF4\u660E");
|
|
9004
9104
|
await assertPayloadsUnchanged(project, plan.payloads);
|
|
9005
9105
|
const evidenceDir = await bindEvidenceDirectory(project, plan.evidenceDir);
|
|
9006
|
-
const receiptFile =
|
|
9106
|
+
const receiptFile = path11.join(evidenceDir.absolute, `${plan.planId}.receipt.json`);
|
|
9007
9107
|
if (await pathExists(receiptFile)) throw invalid2(`\u6267\u884C\u6536\u636E\u5DF2\u5B58\u5728\uFF0C\u62D2\u7EDD\u518D\u6B21\u6267\u884C\uFF1A${plan.planId}`);
|
|
9008
|
-
const claimsDir =
|
|
9108
|
+
const claimsDir = path11.join(project, ".hcm-delivery", "execution-claims");
|
|
9009
9109
|
await safeManagedDirectory(project, ".hcm-delivery/execution-claims", claimsDir);
|
|
9010
|
-
const claimFile =
|
|
9110
|
+
const claimFile = path11.join(claimsDir, `${plan.planId}.json`);
|
|
9011
9111
|
try {
|
|
9012
|
-
await
|
|
9112
|
+
await fs7.writeFile(
|
|
9013
9113
|
claimFile,
|
|
9014
9114
|
`${JSON.stringify({ schemaVersion: 1, planId: plan.planId, claimedAt: now.toISOString() }, null, 2)}
|
|
9015
9115
|
`,
|
|
@@ -9066,7 +9166,7 @@ async function deliveryPrepareCommand(argv, args) {
|
|
|
9066
9166
|
evidenceDir: args.evidenceDir,
|
|
9067
9167
|
...ttlSeconds === void 0 ? {} : { ttlSeconds }
|
|
9068
9168
|
});
|
|
9069
|
-
process.stdout.write(
|
|
9169
|
+
process.stdout.write(formatObject24(plan, { format: args.output ?? "json" }) + "\n");
|
|
9070
9170
|
process.stderr.write(`
|
|
9071
9171
|
\u4E0B\u4E00\u6B65\uFF08argv \u5FC5\u987B\u4E0E\u672C\u6B21\u5B8C\u5168\u4E00\u81F4\uFF09\uFF1A
|
|
9072
9172
|
${nextCommandHint(plan.planId, args.project, argv)}
|
|
@@ -9087,14 +9187,14 @@ async function deliveryExecuteCommand(planId, argv, args) {
|
|
|
9087
9187
|
planId,
|
|
9088
9188
|
argv
|
|
9089
9189
|
});
|
|
9090
|
-
process.stdout.write(
|
|
9190
|
+
process.stdout.write(formatObject24(receipt, { format: args.output ?? "json" }) + "\n");
|
|
9091
9191
|
process.exitCode = receipt.exitCode;
|
|
9092
9192
|
} catch (cause) {
|
|
9093
9193
|
exitWithError(cause);
|
|
9094
9194
|
}
|
|
9095
9195
|
}
|
|
9096
9196
|
async function readProjectMode(project) {
|
|
9097
|
-
const file =
|
|
9197
|
+
const file = path11.join(project, ".hcm-delivery", "project.yml");
|
|
9098
9198
|
const content = await readSafeFile(project, file, "\u9879\u76EE\u914D\u7F6E");
|
|
9099
9199
|
const match = content.toString("utf8").match(
|
|
9100
9200
|
/^deliveryMode:\s*(?:"(plan-only|controlled)"|'(plan-only|controlled)'|(plan-only|controlled))\s*$/m
|
|
@@ -9106,13 +9206,13 @@ async function readProjectMode(project) {
|
|
|
9106
9206
|
return mode;
|
|
9107
9207
|
}
|
|
9108
9208
|
var SKILLS_LOCK_CANDIDATES = [
|
|
9109
|
-
|
|
9110
|
-
|
|
9209
|
+
path11.join("hcm-skills", ".hcm-skills.json"),
|
|
9210
|
+
path11.join(".claude", "skills", ".hcm-skills.json")
|
|
9111
9211
|
];
|
|
9112
9212
|
async function readSkillsLock(project) {
|
|
9113
9213
|
const found = [];
|
|
9114
9214
|
for (const candidate of SKILLS_LOCK_CANDIDATES) {
|
|
9115
|
-
if (await pathExists(
|
|
9215
|
+
if (await pathExists(path11.join(project, candidate))) found.push(candidate);
|
|
9116
9216
|
}
|
|
9117
9217
|
if (found.length === 0) {
|
|
9118
9218
|
throw invalid2(
|
|
@@ -9124,7 +9224,7 @@ async function readSkillsLock(project) {
|
|
|
9124
9224
|
`\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`
|
|
9125
9225
|
);
|
|
9126
9226
|
}
|
|
9127
|
-
const bytes = await readSafeFile(project,
|
|
9227
|
+
const bytes = await readSafeFile(project, path11.join(project, found[0]), "\u6280\u80FD\u9501");
|
|
9128
9228
|
try {
|
|
9129
9229
|
JSON.parse(bytes.toString("utf8"));
|
|
9130
9230
|
} catch (cause) {
|
|
@@ -9137,7 +9237,7 @@ async function bindDocument(project, reference, label) {
|
|
|
9137
9237
|
if (!(relative2.startsWith("work/") || relative2.startsWith("decisions/"))) {
|
|
9138
9238
|
throw invalid2(`${label}\u5FC5\u987B\u4F4D\u4E8E\u9879\u76EE work/ \u6216 decisions/ \u4E0B`);
|
|
9139
9239
|
}
|
|
9140
|
-
const file =
|
|
9240
|
+
const file = path11.join(project, relative2);
|
|
9141
9241
|
const bytes = await readSafeFile(project, file, label);
|
|
9142
9242
|
return { path: relative2, sha256: sha2565(bytes) };
|
|
9143
9243
|
}
|
|
@@ -9150,11 +9250,11 @@ async function bindEvidenceDirectory(project, reference) {
|
|
|
9150
9250
|
if (!(relative2 === "evidence" || relative2.startsWith("evidence/"))) {
|
|
9151
9251
|
throw invalid2("evidence \u76EE\u5F55\u5FC5\u987B\u4F4D\u4E8E\u9879\u76EE evidence/ \u4E0B");
|
|
9152
9252
|
}
|
|
9153
|
-
const absolute =
|
|
9253
|
+
const absolute = path11.join(project, relative2);
|
|
9154
9254
|
await assertNoSymlinkComponents(project, relative2);
|
|
9155
|
-
const stat = await
|
|
9255
|
+
const stat = await fs7.stat(absolute).catch(() => null);
|
|
9156
9256
|
if (stat === null) {
|
|
9157
|
-
await
|
|
9257
|
+
await fs7.mkdir(absolute, { recursive: true, mode: 448 }).catch((cause) => {
|
|
9158
9258
|
throw invalid2(
|
|
9159
9259
|
`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`,
|
|
9160
9260
|
cause
|
|
@@ -9282,7 +9382,7 @@ async function bindPayloadFiles(project, argv) {
|
|
|
9282
9382
|
}
|
|
9283
9383
|
async function bindPayloadFile(project, reference, label) {
|
|
9284
9384
|
const relative2 = safeRelative(reference, label);
|
|
9285
|
-
const file =
|
|
9385
|
+
const file = path11.join(project, relative2);
|
|
9286
9386
|
const bytes = await readSafeFile(project, file, label);
|
|
9287
9387
|
return { path: relative2, sha256: sha2565(bytes) };
|
|
9288
9388
|
}
|
|
@@ -9343,29 +9443,29 @@ async function runCurrentCliCommand(argv, cwd, streams) {
|
|
|
9343
9443
|
async function writeReceiptExclusive(target, receipt) {
|
|
9344
9444
|
const temp = `${target}.${process.pid}.${Date.now()}.tmp`;
|
|
9345
9445
|
try {
|
|
9346
|
-
await
|
|
9446
|
+
await fs7.writeFile(temp, `${JSON.stringify(receipt, null, 2)}
|
|
9347
9447
|
`, {
|
|
9348
9448
|
encoding: "utf8",
|
|
9349
9449
|
mode: 384,
|
|
9350
9450
|
flag: "wx"
|
|
9351
9451
|
});
|
|
9352
|
-
await
|
|
9452
|
+
await fs7.link(temp, target);
|
|
9353
9453
|
} catch (cause) {
|
|
9354
|
-
throw invalid2(`\u6267\u884C\u6536\u636E\u5199\u5165\u5931\u8D25\u6216\u5DF2\u5B58\u5728\uFF1A${
|
|
9454
|
+
throw invalid2(`\u6267\u884C\u6536\u636E\u5199\u5165\u5931\u8D25\u6216\u5DF2\u5B58\u5728\uFF1A${path11.basename(target)}`, cause);
|
|
9355
9455
|
} finally {
|
|
9356
|
-
await
|
|
9456
|
+
await fs7.unlink(temp).catch(() => void 0);
|
|
9357
9457
|
}
|
|
9358
9458
|
}
|
|
9359
9459
|
async function safeManagedDirectory(project, relative2, absolute) {
|
|
9360
|
-
await assertNoSymlinkComponents(project,
|
|
9361
|
-
const existing = await
|
|
9460
|
+
await assertNoSymlinkComponents(project, path11.dirname(relative2));
|
|
9461
|
+
const existing = await fs7.lstat(absolute).catch(() => void 0);
|
|
9362
9462
|
if (existing?.isSymbolicLink()) throw invalid2(`\u53D7\u7BA1\u76EE\u5F55\u4E0D\u80FD\u662F\u7B26\u53F7\u94FE\u63A5\uFF1A${relative2}`);
|
|
9363
9463
|
if (existing && !existing.isDirectory()) throw invalid2(`\u53D7\u7BA1\u8DEF\u5F84\u4E0D\u662F\u76EE\u5F55\uFF1A${relative2}`);
|
|
9364
|
-
if (!existing) await
|
|
9365
|
-
await
|
|
9464
|
+
if (!existing) await fs7.mkdir(absolute, { mode: 448 });
|
|
9465
|
+
await fs7.chmod(absolute, 448);
|
|
9366
9466
|
}
|
|
9367
9467
|
async function pathExists(file) {
|
|
9368
|
-
return
|
|
9468
|
+
return fs7.lstat(file).then(
|
|
9369
9469
|
() => true,
|
|
9370
9470
|
(cause) => {
|
|
9371
9471
|
if (cause.code === "ENOENT") return false;
|
|
@@ -9374,47 +9474,47 @@ async function pathExists(file) {
|
|
|
9374
9474
|
);
|
|
9375
9475
|
}
|
|
9376
9476
|
async function readSafeFile(project, file, label) {
|
|
9377
|
-
const relative2 =
|
|
9378
|
-
if (relative2.startsWith("../") ||
|
|
9477
|
+
const relative2 = path11.relative(project, file).split(path11.sep).join("/");
|
|
9478
|
+
if (relative2.startsWith("../") || path11.isAbsolute(relative2))
|
|
9379
9479
|
throw invalid2(`${label}\u8DEF\u5F84\u9003\u9038\u9879\u76EE`);
|
|
9380
9480
|
await assertNoSymlinkComponents(project, relative2);
|
|
9381
9481
|
let stat;
|
|
9382
9482
|
try {
|
|
9383
|
-
stat = await
|
|
9483
|
+
stat = await fs7.lstat(file);
|
|
9384
9484
|
} catch (cause) {
|
|
9385
9485
|
throw invalid2(`${label}\u4E0D\u53EF\u7528\uFF1A${relative2}`, cause);
|
|
9386
9486
|
}
|
|
9387
9487
|
if (stat.isSymbolicLink()) throw invalid2(`${label}\u4E0D\u80FD\u662F\u7B26\u53F7\u94FE\u63A5\uFF1A${relative2}`);
|
|
9388
9488
|
if (!stat.isFile()) throw invalid2(`${label}\u4E0D\u662F\u666E\u901A\u6587\u4EF6\uFF1A${relative2}`);
|
|
9389
|
-
return
|
|
9489
|
+
return fs7.readFile(file);
|
|
9390
9490
|
}
|
|
9391
9491
|
async function assertNoSymlinkComponents(project, relative2) {
|
|
9392
9492
|
const parts = relative2.split("/").filter(Boolean);
|
|
9393
9493
|
let current = project;
|
|
9394
9494
|
for (const part of parts) {
|
|
9395
|
-
current =
|
|
9396
|
-
const stat = await
|
|
9495
|
+
current = path11.join(current, part);
|
|
9496
|
+
const stat = await fs7.lstat(current).catch(() => void 0);
|
|
9397
9497
|
if (stat?.isSymbolicLink()) throw invalid2(`\u8DEF\u5F84\u5305\u542B\u7B26\u53F7\u94FE\u63A5\uFF1A${relative2}`);
|
|
9398
9498
|
if (!stat) break;
|
|
9399
9499
|
}
|
|
9400
9500
|
}
|
|
9401
9501
|
async function realProject(requested) {
|
|
9402
|
-
const absolute =
|
|
9502
|
+
const absolute = path11.resolve(requested);
|
|
9403
9503
|
let project;
|
|
9404
9504
|
try {
|
|
9405
|
-
project = await
|
|
9505
|
+
project = await fs7.realpath(absolute);
|
|
9406
9506
|
} catch (cause) {
|
|
9407
9507
|
throw invalid2(`\u9879\u76EE\u76EE\u5F55\u4E0D\u53EF\u7528\uFF1A${absolute}`, cause);
|
|
9408
9508
|
}
|
|
9409
|
-
const stat = await
|
|
9509
|
+
const stat = await fs7.stat(project);
|
|
9410
9510
|
if (!stat.isDirectory()) throw invalid2(`\u9879\u76EE\u8DEF\u5F84\u4E0D\u662F\u76EE\u5F55\uFF1A${absolute}`);
|
|
9411
9511
|
return project;
|
|
9412
9512
|
}
|
|
9413
9513
|
function safeRelative(reference, label) {
|
|
9414
|
-
if (!reference ||
|
|
9514
|
+
if (!reference || path11.isAbsolute(reference) || /[\r\n\0]/.test(reference)) {
|
|
9415
9515
|
throw invalid2(`${label}\u5FC5\u987B\u662F\u9879\u76EE\u5185\u76F8\u5BF9\u8DEF\u5F84`);
|
|
9416
9516
|
}
|
|
9417
|
-
const normalized =
|
|
9517
|
+
const normalized = path11.normalize(reference).split(path11.sep).join("/");
|
|
9418
9518
|
if (normalized === ".." || normalized.startsWith("../") || normalized === ".") {
|
|
9419
9519
|
throw invalid2(`${label}\u8DEF\u5F84\u9003\u9038\u9879\u76EE`);
|
|
9420
9520
|
}
|
|
@@ -9478,7 +9578,7 @@ init_exit();
|
|
|
9478
9578
|
import {
|
|
9479
9579
|
HcmClient as HcmClient24,
|
|
9480
9580
|
adminResetPassword,
|
|
9481
|
-
formatObject as
|
|
9581
|
+
formatObject as formatObject25,
|
|
9482
9582
|
fromAxiosError as fromAxiosError20,
|
|
9483
9583
|
CliError as CliError21,
|
|
9484
9584
|
CliErrorCode as CliErrorCode20
|
|
@@ -9512,7 +9612,7 @@ async function userResetPasswordCommand(args) {
|
|
|
9512
9612
|
const request = buildAdminResetPasswordRequest(args, password);
|
|
9513
9613
|
const client3 = HcmClient24.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
9514
9614
|
const result = await adminResetPassword(client3.raw(), request);
|
|
9515
|
-
process.stdout.write(
|
|
9615
|
+
process.stdout.write(formatObject25(result, { format: args.output ?? "json" }) + "\n");
|
|
9516
9616
|
} catch (cause) {
|
|
9517
9617
|
const err = cause;
|
|
9518
9618
|
if (err?.isAxiosError) exitWithError(fromAxiosError20(err, args.env));
|
|
@@ -9536,7 +9636,7 @@ init_exit();
|
|
|
9536
9636
|
init_auth_guard();
|
|
9537
9637
|
import {
|
|
9538
9638
|
HcmClient as HcmClient25,
|
|
9539
|
-
formatObject as
|
|
9639
|
+
formatObject as formatObject26,
|
|
9540
9640
|
fromAxiosError as fromAxiosError21
|
|
9541
9641
|
} from "@hcmai/sdk";
|
|
9542
9642
|
async function modelsCommand(keyword, args) {
|
|
@@ -9547,7 +9647,7 @@ async function modelsCommand(keyword, args) {
|
|
|
9547
9647
|
const rows = (needle ? all.filter((m) => JSON.stringify(m).toLowerCase().includes(needle)) : all).sort((a, b) => key(a).localeCompare(key(b)));
|
|
9548
9648
|
const fmt = args.output ?? "table";
|
|
9549
9649
|
if (fmt !== "table") {
|
|
9550
|
-
process.stdout.write(
|
|
9650
|
+
process.stdout.write(formatObject26({ total: rows.length, models: rows }, { format: fmt }) + "\n");
|
|
9551
9651
|
process.exit(0);
|
|
9552
9652
|
}
|
|
9553
9653
|
if (rows.length === 0) {
|
|
@@ -9683,6 +9783,7 @@ delivery.command("triage").description(
|
|
|
9683
9783
|
"--recon <dir>",
|
|
9684
9784
|
"\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"
|
|
9685
9785
|
).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));
|
|
9786
|
+
delivery.command("init").description("\u751F\u6210\u53D7\u63A7\u6267\u884C\u6240\u9700\u7684\u9879\u76EE\u9AA8\u67B6\uFF08.hcm-delivery/project.yml + work/ decisions/ evidence/\uFF09").option("--project <dir>", "HCM \u987E\u95EE\u9879\u76EE\u6839\u76EE\u5F55", ".").option("--mode <mode>", "\u4EA4\u4ED8\u6A21\u5F0F\uFF1Acontrolled | plan-only", "controlled").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));
|
|
9686
9787
|
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));
|
|
9687
9788
|
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));
|
|
9688
9789
|
program.command("query <Model>").description("\u67E5\u8BE2 Model \u5217\u8868\u6570\u636E\uFF08\u901A\u8FC7 ModelQueryDsl JSON \u8868\u8FBE\u8FC7\u6EE4/\u6392\u5E8F/\u5206\u9875\uFF09").option(
|