@hcmai/cli 0.4.10 → 0.4.11
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 +92 -8
- package/dist/index.js.map +1 -1
- package/dist/skills/manifest.json +9 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -7560,7 +7560,7 @@ async function identityRemove(name) {
|
|
|
7560
7560
|
|
|
7561
7561
|
// src/commands/delivery-action-policy.ts
|
|
7562
7562
|
init_auth_guard();
|
|
7563
|
-
import { existsSync as existsSync2 } from "fs";
|
|
7563
|
+
import { existsSync as existsSync2, readFileSync as readFileSync5 } from "fs";
|
|
7564
7564
|
import { join as pathJoin } from "path";
|
|
7565
7565
|
import {
|
|
7566
7566
|
HcmClient as HcmClient19,
|
|
@@ -7953,11 +7953,29 @@ async function assessEffectiveDeliveryCommand(inputArgv, dependencies = {}) {
|
|
|
7953
7953
|
const resolution = await (dependencies.resolveAction ?? resolveCoreAction)(request);
|
|
7954
7954
|
return assessDeliveryCommand(inputArgv, { actionResolution: resolution });
|
|
7955
7955
|
}
|
|
7956
|
+
function readDeliveryMode(projectRoot = ".") {
|
|
7957
|
+
const file = pathJoin(projectRoot, ".hcm-delivery", "project.yml");
|
|
7958
|
+
if (!existsSync2(file)) return null;
|
|
7959
|
+
const match = readFileSync5(file, "utf8").match(
|
|
7960
|
+
/^deliveryMode:\s*(?:"(plan-only|controlled)"|'(plan-only|controlled)'|(plan-only|controlled))\s*$/m
|
|
7961
|
+
);
|
|
7962
|
+
return match?.[1] ?? match?.[2] ?? match?.[3] ?? null;
|
|
7963
|
+
}
|
|
7956
7964
|
function withProjectReadiness(assessment, projectRoot = ".") {
|
|
7957
7965
|
const projectFile = pathJoin(projectRoot, ".hcm-delivery", "project.yml");
|
|
7958
7966
|
const projectInitialized = existsSync2(projectFile);
|
|
7967
|
+
const deliveryMode = readDeliveryMode(projectRoot);
|
|
7968
|
+
if (projectInitialized && deliveryMode === "plan-only" && assessment.guardedExecutionAvailable) {
|
|
7969
|
+
return {
|
|
7970
|
+
...assessment,
|
|
7971
|
+
projectInitialized,
|
|
7972
|
+
deliveryMode,
|
|
7973
|
+
modePolicy: assessment.modePolicy ? { ...assessment.modePolicy, controlled: "deny" } : assessment.modePolicy,
|
|
7974
|
+
projectNextStep: "\u672C\u9879\u76EE\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\u6539\u4E3A controlled\uFF08hcm delivery init --mode controlled --force \u4F1A\u8986\u76D6\u6574\u4EFD\u9879\u76EE\u914D\u7F6E\uFF0C\u8BF7\u786E\u8BA4\u540E\u518D\u6267\u884C\uFF09"
|
|
7975
|
+
};
|
|
7976
|
+
}
|
|
7959
7977
|
if (projectInitialized || !assessment.guardedExecutionAvailable) {
|
|
7960
|
-
return { ...assessment, projectInitialized };
|
|
7978
|
+
return { ...assessment, projectInitialized, deliveryMode };
|
|
7961
7979
|
}
|
|
7962
7980
|
const requirements = [...assessment.requirements ?? []];
|
|
7963
7981
|
if (!requirements.includes("delivery-project")) requirements.push("delivery-project");
|
|
@@ -8137,6 +8155,71 @@ async function deliveryInitCommand(args) {
|
|
|
8137
8155
|
process.exit(1);
|
|
8138
8156
|
}
|
|
8139
8157
|
}
|
|
8158
|
+
async function deliveryModeCommand(args) {
|
|
8159
|
+
try {
|
|
8160
|
+
const root = path6.resolve(args.project ?? ".");
|
|
8161
|
+
const file = path6.join(root, ".hcm-delivery", "project.yml");
|
|
8162
|
+
let content;
|
|
8163
|
+
try {
|
|
8164
|
+
content = await fs6.readFile(file, "utf8");
|
|
8165
|
+
} catch {
|
|
8166
|
+
throw new Error(
|
|
8167
|
+
`\u9879\u76EE\u672A\u521D\u59CB\u5316\uFF1A\u627E\u4E0D\u5230 ${file}
|
|
8168
|
+
\u4E0B\u4E00\u6B65\uFF1Ahcm delivery init`
|
|
8169
|
+
);
|
|
8170
|
+
}
|
|
8171
|
+
const read = () => content.match(
|
|
8172
|
+
/^deliveryMode:\s*(?:"(plan-only|controlled)"|'(plan-only|controlled)'|(plan-only|controlled))\s*$/m
|
|
8173
|
+
);
|
|
8174
|
+
if (!args.set) {
|
|
8175
|
+
const m2 = read();
|
|
8176
|
+
const current = m2?.[1] ?? m2?.[2] ?? m2?.[3] ?? null;
|
|
8177
|
+
process.stdout.write(
|
|
8178
|
+
formatObject21(
|
|
8179
|
+
{
|
|
8180
|
+
project: root,
|
|
8181
|
+
projectFile: file,
|
|
8182
|
+
deliveryMode: current,
|
|
8183
|
+
canExecuteR2: current === "controlled",
|
|
8184
|
+
...current === "plan-only" ? { note: "plan-only \u53EA\u51FA\u8BA1\u5212\u4E0D\u6267\u884C\uFF1Bexecute \u4F1A\u62D2\u7EDD R2 \u8BA1\u5212" } : {}
|
|
8185
|
+
},
|
|
8186
|
+
{ format: args.output ?? "json" }
|
|
8187
|
+
) + "\n"
|
|
8188
|
+
);
|
|
8189
|
+
process.exit(0);
|
|
8190
|
+
}
|
|
8191
|
+
const next = args.set;
|
|
8192
|
+
if (!MODES.includes(next)) {
|
|
8193
|
+
throw new Error(`--set \u53EA\u63A5\u53D7 ${MODES.join(" | ")}\uFF0C\u6536\u5230 "${args.set}"`);
|
|
8194
|
+
}
|
|
8195
|
+
const m = read();
|
|
8196
|
+
if (!m) {
|
|
8197
|
+
throw new Error(
|
|
8198
|
+
`${file} \u91CC\u6CA1\u6709\u5408\u6CD5\u7684 deliveryMode \u884C\uFF0C\u4E0D\u5C31\u5730\u6539\u5199\u4EE5\u514D\u7834\u574F\u914D\u7F6E
|
|
8199
|
+
\u4E0B\u4E00\u6B65\uFF1A\u786E\u8BA4\u6587\u4EF6\u5185\u5BB9\uFF0C\u6216 hcm delivery init --force \u91CD\u65B0\u751F\u6210`
|
|
8200
|
+
);
|
|
8201
|
+
}
|
|
8202
|
+
const before = m[1] ?? m[2] ?? m[3];
|
|
8203
|
+
content = content.replace(m[0], `deliveryMode: ${next}`);
|
|
8204
|
+
await fs6.writeFile(file, content, "utf8");
|
|
8205
|
+
process.stdout.write(
|
|
8206
|
+
formatObject21(
|
|
8207
|
+
{
|
|
8208
|
+
project: root,
|
|
8209
|
+
projectFile: file,
|
|
8210
|
+
deliveryMode: next,
|
|
8211
|
+
previous: before,
|
|
8212
|
+
canExecuteR2: next === "controlled"
|
|
8213
|
+
},
|
|
8214
|
+
{ format: args.output ?? "json" }
|
|
8215
|
+
) + "\n"
|
|
8216
|
+
);
|
|
8217
|
+
process.exit(0);
|
|
8218
|
+
} catch (e) {
|
|
8219
|
+
exitWithError(e);
|
|
8220
|
+
process.exit(1);
|
|
8221
|
+
}
|
|
8222
|
+
}
|
|
8140
8223
|
|
|
8141
8224
|
// src/commands/delivery-doctor.ts
|
|
8142
8225
|
init_auth_guard();
|
|
@@ -8653,7 +8736,7 @@ async function deliverySeedVerifyCommand(args) {
|
|
|
8653
8736
|
|
|
8654
8737
|
// src/commands/delivery-seed-find.ts
|
|
8655
8738
|
import { existsSync as existsSync4 } from "fs";
|
|
8656
|
-
import { readFileSync as
|
|
8739
|
+
import { readFileSync as readFileSync6 } from "fs";
|
|
8657
8740
|
import * as path9 from "path";
|
|
8658
8741
|
import {
|
|
8659
8742
|
INIT_EXIT_CODES as INIT_EXIT_CODES2,
|
|
@@ -8716,7 +8799,7 @@ function runSeedFind(args) {
|
|
|
8716
8799
|
if (!existsSync4(chosen.indexFile)) {
|
|
8717
8800
|
return premise2(`\u7D22\u5F15\u6587\u4EF6\u5728\u9009\u4E2D\u4E4B\u540E\u6D88\u5931\u4E86\uFF1A${chosen.indexFile}`);
|
|
8718
8801
|
}
|
|
8719
|
-
const { rows, problems } = loadRows(
|
|
8802
|
+
const { rows, problems } = loadRows(readFileSync6(chosen.indexFile, "utf-8"));
|
|
8720
8803
|
process.stdout.write(
|
|
8721
8804
|
renderFind(find(rows, args.term), args.term, rows.length, {
|
|
8722
8805
|
prefixBytes: Buffer.byteLength(prefix, "utf-8"),
|
|
@@ -8756,7 +8839,7 @@ function deliverySeedValuesCommand(model, args) {
|
|
|
8756
8839
|
|
|
8757
8840
|
// src/commands/delivery-meta.ts
|
|
8758
8841
|
init_auth_guard();
|
|
8759
|
-
import { readFileSync as
|
|
8842
|
+
import { readFileSync as readFileSync7 } from "fs";
|
|
8760
8843
|
import {
|
|
8761
8844
|
BINDING_WORDS,
|
|
8762
8845
|
CHANGE_STATES,
|
|
@@ -8904,7 +8987,7 @@ function premise3(what, hint) {
|
|
|
8904
8987
|
async function runDeliveryMeta(args, client3) {
|
|
8905
8988
|
let content;
|
|
8906
8989
|
try {
|
|
8907
|
-
content =
|
|
8990
|
+
content = readFileSync7(args.contentFile, "utf-8");
|
|
8908
8991
|
} catch (e) {
|
|
8909
8992
|
return premise3(
|
|
8910
8993
|
`\u8981\u5199\u8FDB\u53BB\u7684\u6B63\u6587\u8BFB\u4E0D\u51FA\u6765\uFF1A${e.message}`,
|
|
@@ -9007,7 +9090,7 @@ import {
|
|
|
9007
9090
|
ReconLayout as ReconLayout2,
|
|
9008
9091
|
runTriageRound
|
|
9009
9092
|
} from "@hcmai/sdk";
|
|
9010
|
-
import { mkdirSync, readFileSync as
|
|
9093
|
+
import { mkdirSync, readFileSync as readFileSync8, writeFileSync as writeFileSync2 } from "fs";
|
|
9011
9094
|
import * as path10 from "path";
|
|
9012
9095
|
var DEFAULT_CAPABILITIES4 = "default";
|
|
9013
9096
|
function premise4(message, hint) {
|
|
@@ -9021,7 +9104,7 @@ var REQUESTS_SHAPE = "`--requests` \u6536\u7684\u662F\u4E00\u4E2A JSON \u6570\u7
|
|
|
9021
9104
|
function readRequests(file) {
|
|
9022
9105
|
let raw;
|
|
9023
9106
|
try {
|
|
9024
|
-
raw = JSON.parse(
|
|
9107
|
+
raw = JSON.parse(readFileSync8(file, "utf8"));
|
|
9025
9108
|
} catch (e) {
|
|
9026
9109
|
throw new Error(`\u9700\u6C42\u6E05\u5355\u8BFB\u4E0D\u51FA\u6765\uFF08${file}\uFF09\uFF1A${e instanceof Error ? e.message : String(e)}`);
|
|
9027
9110
|
}
|
|
@@ -9953,6 +10036,7 @@ delivery.command("triage").description(
|
|
|
9953
10036
|
"\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"
|
|
9954
10037
|
).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));
|
|
9955
10038
|
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));
|
|
10039
|
+
delivery.command("mode").description("\u770B/\u6539\u672C\u9879\u76EE\u7684\u4EA4\u4ED8\u6A21\u5F0F\uFF1B\u4E0D\u5E26 --set \u53EA\u8BFB\uFF0C\u5E26 --set \u5C31\u5730\u6539\u90A3\u4E00\u884C\uFF08\u4E0D\u8986\u76D6\u6574\u4EFD\u914D\u7F6E\uFF09").option("--project <dir>", "HCM \u987E\u95EE\u9879\u76EE\u6839\u76EE\u5F55", ".").option("--set <mode>", "\u6539\u4E3A\uFF1Acontrolled | plan-only").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((opts) => deliveryModeCommand(opts));
|
|
9956
10040
|
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));
|
|
9957
10041
|
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));
|
|
9958
10042
|
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(
|