@hcmai/cli 0.4.10 → 0.4.12
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 +103 -10
- package/dist/index.js.map +1 -1
- package/dist/skills/manifest.json +9 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -3173,7 +3173,15 @@ function formatDescriptionTable(desc, verbose = false) {
|
|
|
3173
3173
|
const call = [a.scope, a.httpMethod].filter(Boolean).join(" ");
|
|
3174
3174
|
const params = a.params?.length ? ` params: ${a.params.map((p) => `${p.name}:${p.type}`).join(", ")}` : "";
|
|
3175
3175
|
const description = verbose && a.description ? ` ${a.description}` : "";
|
|
3176
|
-
|
|
3176
|
+
const source = a.source && a.source.toLowerCase() !== "java" ? ` [${a.source.toLowerCase()}]` : "";
|
|
3177
|
+
lines.push(
|
|
3178
|
+
` ${a.name.padEnd(20)} ${call.padEnd(12)} ${a.label ?? ""}${source}${params}${description}`
|
|
3179
|
+
);
|
|
3180
|
+
}
|
|
3181
|
+
if (!desc.effectiveActionsAvailable) {
|
|
3182
|
+
lines.push(
|
|
3183
|
+
` \u26A0\uFE0F \u4EE5\u4E0A\u53EA\u542B\u6CE8\u89E3 action\uFF0CYAML \u58F0\u660E\u7684\u811A\u672C Action \u672A\u7EB3\u5165\uFF1A${desc.effectiveActionsNote ?? "\u539F\u56E0\u672A\u77E5"}`
|
|
3184
|
+
);
|
|
3177
3185
|
}
|
|
3178
3186
|
if (desc.relations.length) {
|
|
3179
3187
|
lines.push(`relations: ${desc.relations.map((r) => `${r.key}(via ${r.via})`).join(", ")}`);
|
|
@@ -7560,7 +7568,7 @@ async function identityRemove(name) {
|
|
|
7560
7568
|
|
|
7561
7569
|
// src/commands/delivery-action-policy.ts
|
|
7562
7570
|
init_auth_guard();
|
|
7563
|
-
import { existsSync as existsSync2 } from "fs";
|
|
7571
|
+
import { existsSync as existsSync2, readFileSync as readFileSync5 } from "fs";
|
|
7564
7572
|
import { join as pathJoin } from "path";
|
|
7565
7573
|
import {
|
|
7566
7574
|
HcmClient as HcmClient19,
|
|
@@ -7953,11 +7961,29 @@ async function assessEffectiveDeliveryCommand(inputArgv, dependencies = {}) {
|
|
|
7953
7961
|
const resolution = await (dependencies.resolveAction ?? resolveCoreAction)(request);
|
|
7954
7962
|
return assessDeliveryCommand(inputArgv, { actionResolution: resolution });
|
|
7955
7963
|
}
|
|
7964
|
+
function readDeliveryMode(projectRoot = ".") {
|
|
7965
|
+
const file = pathJoin(projectRoot, ".hcm-delivery", "project.yml");
|
|
7966
|
+
if (!existsSync2(file)) return null;
|
|
7967
|
+
const match = readFileSync5(file, "utf8").match(
|
|
7968
|
+
/^deliveryMode:\s*(?:"(plan-only|controlled)"|'(plan-only|controlled)'|(plan-only|controlled))\s*$/m
|
|
7969
|
+
);
|
|
7970
|
+
return match?.[1] ?? match?.[2] ?? match?.[3] ?? null;
|
|
7971
|
+
}
|
|
7956
7972
|
function withProjectReadiness(assessment, projectRoot = ".") {
|
|
7957
7973
|
const projectFile = pathJoin(projectRoot, ".hcm-delivery", "project.yml");
|
|
7958
7974
|
const projectInitialized = existsSync2(projectFile);
|
|
7975
|
+
const deliveryMode = readDeliveryMode(projectRoot);
|
|
7976
|
+
if (projectInitialized && deliveryMode === "plan-only" && assessment.guardedExecutionAvailable) {
|
|
7977
|
+
return {
|
|
7978
|
+
...assessment,
|
|
7979
|
+
projectInitialized,
|
|
7980
|
+
deliveryMode,
|
|
7981
|
+
modePolicy: assessment.modePolicy ? { ...assessment.modePolicy, controlled: "deny" } : assessment.modePolicy,
|
|
7982
|
+
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"
|
|
7983
|
+
};
|
|
7984
|
+
}
|
|
7959
7985
|
if (projectInitialized || !assessment.guardedExecutionAvailable) {
|
|
7960
|
-
return { ...assessment, projectInitialized };
|
|
7986
|
+
return { ...assessment, projectInitialized, deliveryMode };
|
|
7961
7987
|
}
|
|
7962
7988
|
const requirements = [...assessment.requirements ?? []];
|
|
7963
7989
|
if (!requirements.includes("delivery-project")) requirements.push("delivery-project");
|
|
@@ -7984,9 +8010,10 @@ async function resolveCoreAction(request) {
|
|
|
7984
8010
|
const description = await HcmClient19.fromAuthContext(auth).describe(request.model);
|
|
7985
8011
|
const named = description.actions.filter((action2) => action2.name === request.action);
|
|
7986
8012
|
if (named.length === 0) {
|
|
8013
|
+
const degraded = description.effectiveActionsAvailable ? "" : `\u26A0\uFE0F \u672C\u6B21\u6BD4\u5BF9\u4E0D\u542B\u811A\u672C Action\u2014\u2014${description.effectiveActionsNote ?? "\u539F\u56E0\u672A\u77E5"}\u3002`;
|
|
7987
8014
|
return failed(
|
|
7988
8015
|
"action-metadata-not-found",
|
|
7989
|
-
`Core \u5143\u6570\u636E\u91CC\u6CA1\u6709 ${request.model}.${request.action} \u8FD9\u4E2A Action\
|
|
8016
|
+
`Core \u5143\u6570\u636E\u91CC\u6CA1\u6709 ${request.model}.${request.action} \u8FD9\u4E2A Action\u3002${degraded}next_step=\u7528 \`hcm describe ${request.model}\` \u770B\u5B83\u5217\u51FA\u7684 Action \u540D\uFF08\u811A\u672C Action \u4F1A\u6807 [script]\uFF09`
|
|
7990
8017
|
);
|
|
7991
8018
|
}
|
|
7992
8019
|
const matches = request.explicitShape ? named.filter((action2) => matchesRequest(action2, request)) : named;
|
|
@@ -8137,6 +8164,71 @@ async function deliveryInitCommand(args) {
|
|
|
8137
8164
|
process.exit(1);
|
|
8138
8165
|
}
|
|
8139
8166
|
}
|
|
8167
|
+
async function deliveryModeCommand(args) {
|
|
8168
|
+
try {
|
|
8169
|
+
const root = path6.resolve(args.project ?? ".");
|
|
8170
|
+
const file = path6.join(root, ".hcm-delivery", "project.yml");
|
|
8171
|
+
let content;
|
|
8172
|
+
try {
|
|
8173
|
+
content = await fs6.readFile(file, "utf8");
|
|
8174
|
+
} catch {
|
|
8175
|
+
throw new Error(
|
|
8176
|
+
`\u9879\u76EE\u672A\u521D\u59CB\u5316\uFF1A\u627E\u4E0D\u5230 ${file}
|
|
8177
|
+
\u4E0B\u4E00\u6B65\uFF1Ahcm delivery init`
|
|
8178
|
+
);
|
|
8179
|
+
}
|
|
8180
|
+
const read = () => content.match(
|
|
8181
|
+
/^deliveryMode:\s*(?:"(plan-only|controlled)"|'(plan-only|controlled)'|(plan-only|controlled))\s*$/m
|
|
8182
|
+
);
|
|
8183
|
+
if (!args.set) {
|
|
8184
|
+
const m2 = read();
|
|
8185
|
+
const current = m2?.[1] ?? m2?.[2] ?? m2?.[3] ?? null;
|
|
8186
|
+
process.stdout.write(
|
|
8187
|
+
formatObject21(
|
|
8188
|
+
{
|
|
8189
|
+
project: root,
|
|
8190
|
+
projectFile: file,
|
|
8191
|
+
deliveryMode: current,
|
|
8192
|
+
canExecuteR2: current === "controlled",
|
|
8193
|
+
...current === "plan-only" ? { note: "plan-only \u53EA\u51FA\u8BA1\u5212\u4E0D\u6267\u884C\uFF1Bexecute \u4F1A\u62D2\u7EDD R2 \u8BA1\u5212" } : {}
|
|
8194
|
+
},
|
|
8195
|
+
{ format: args.output ?? "json" }
|
|
8196
|
+
) + "\n"
|
|
8197
|
+
);
|
|
8198
|
+
process.exit(0);
|
|
8199
|
+
}
|
|
8200
|
+
const next = args.set;
|
|
8201
|
+
if (!MODES.includes(next)) {
|
|
8202
|
+
throw new Error(`--set \u53EA\u63A5\u53D7 ${MODES.join(" | ")}\uFF0C\u6536\u5230 "${args.set}"`);
|
|
8203
|
+
}
|
|
8204
|
+
const m = read();
|
|
8205
|
+
if (!m) {
|
|
8206
|
+
throw new Error(
|
|
8207
|
+
`${file} \u91CC\u6CA1\u6709\u5408\u6CD5\u7684 deliveryMode \u884C\uFF0C\u4E0D\u5C31\u5730\u6539\u5199\u4EE5\u514D\u7834\u574F\u914D\u7F6E
|
|
8208
|
+
\u4E0B\u4E00\u6B65\uFF1A\u786E\u8BA4\u6587\u4EF6\u5185\u5BB9\uFF0C\u6216 hcm delivery init --force \u91CD\u65B0\u751F\u6210`
|
|
8209
|
+
);
|
|
8210
|
+
}
|
|
8211
|
+
const before = m[1] ?? m[2] ?? m[3];
|
|
8212
|
+
content = content.replace(m[0], `deliveryMode: ${next}`);
|
|
8213
|
+
await fs6.writeFile(file, content, "utf8");
|
|
8214
|
+
process.stdout.write(
|
|
8215
|
+
formatObject21(
|
|
8216
|
+
{
|
|
8217
|
+
project: root,
|
|
8218
|
+
projectFile: file,
|
|
8219
|
+
deliveryMode: next,
|
|
8220
|
+
previous: before,
|
|
8221
|
+
canExecuteR2: next === "controlled"
|
|
8222
|
+
},
|
|
8223
|
+
{ format: args.output ?? "json" }
|
|
8224
|
+
) + "\n"
|
|
8225
|
+
);
|
|
8226
|
+
process.exit(0);
|
|
8227
|
+
} catch (e) {
|
|
8228
|
+
exitWithError(e);
|
|
8229
|
+
process.exit(1);
|
|
8230
|
+
}
|
|
8231
|
+
}
|
|
8140
8232
|
|
|
8141
8233
|
// src/commands/delivery-doctor.ts
|
|
8142
8234
|
init_auth_guard();
|
|
@@ -8653,7 +8745,7 @@ async function deliverySeedVerifyCommand(args) {
|
|
|
8653
8745
|
|
|
8654
8746
|
// src/commands/delivery-seed-find.ts
|
|
8655
8747
|
import { existsSync as existsSync4 } from "fs";
|
|
8656
|
-
import { readFileSync as
|
|
8748
|
+
import { readFileSync as readFileSync6 } from "fs";
|
|
8657
8749
|
import * as path9 from "path";
|
|
8658
8750
|
import {
|
|
8659
8751
|
INIT_EXIT_CODES as INIT_EXIT_CODES2,
|
|
@@ -8716,7 +8808,7 @@ function runSeedFind(args) {
|
|
|
8716
8808
|
if (!existsSync4(chosen.indexFile)) {
|
|
8717
8809
|
return premise2(`\u7D22\u5F15\u6587\u4EF6\u5728\u9009\u4E2D\u4E4B\u540E\u6D88\u5931\u4E86\uFF1A${chosen.indexFile}`);
|
|
8718
8810
|
}
|
|
8719
|
-
const { rows, problems } = loadRows(
|
|
8811
|
+
const { rows, problems } = loadRows(readFileSync6(chosen.indexFile, "utf-8"));
|
|
8720
8812
|
process.stdout.write(
|
|
8721
8813
|
renderFind(find(rows, args.term), args.term, rows.length, {
|
|
8722
8814
|
prefixBytes: Buffer.byteLength(prefix, "utf-8"),
|
|
@@ -8756,7 +8848,7 @@ function deliverySeedValuesCommand(model, args) {
|
|
|
8756
8848
|
|
|
8757
8849
|
// src/commands/delivery-meta.ts
|
|
8758
8850
|
init_auth_guard();
|
|
8759
|
-
import { readFileSync as
|
|
8851
|
+
import { readFileSync as readFileSync7 } from "fs";
|
|
8760
8852
|
import {
|
|
8761
8853
|
BINDING_WORDS,
|
|
8762
8854
|
CHANGE_STATES,
|
|
@@ -8904,7 +8996,7 @@ function premise3(what, hint) {
|
|
|
8904
8996
|
async function runDeliveryMeta(args, client3) {
|
|
8905
8997
|
let content;
|
|
8906
8998
|
try {
|
|
8907
|
-
content =
|
|
8999
|
+
content = readFileSync7(args.contentFile, "utf-8");
|
|
8908
9000
|
} catch (e) {
|
|
8909
9001
|
return premise3(
|
|
8910
9002
|
`\u8981\u5199\u8FDB\u53BB\u7684\u6B63\u6587\u8BFB\u4E0D\u51FA\u6765\uFF1A${e.message}`,
|
|
@@ -9007,7 +9099,7 @@ import {
|
|
|
9007
9099
|
ReconLayout as ReconLayout2,
|
|
9008
9100
|
runTriageRound
|
|
9009
9101
|
} from "@hcmai/sdk";
|
|
9010
|
-
import { mkdirSync, readFileSync as
|
|
9102
|
+
import { mkdirSync, readFileSync as readFileSync8, writeFileSync as writeFileSync2 } from "fs";
|
|
9011
9103
|
import * as path10 from "path";
|
|
9012
9104
|
var DEFAULT_CAPABILITIES4 = "default";
|
|
9013
9105
|
function premise4(message, hint) {
|
|
@@ -9021,7 +9113,7 @@ var REQUESTS_SHAPE = "`--requests` \u6536\u7684\u662F\u4E00\u4E2A JSON \u6570\u7
|
|
|
9021
9113
|
function readRequests(file) {
|
|
9022
9114
|
let raw;
|
|
9023
9115
|
try {
|
|
9024
|
-
raw = JSON.parse(
|
|
9116
|
+
raw = JSON.parse(readFileSync8(file, "utf8"));
|
|
9025
9117
|
} catch (e) {
|
|
9026
9118
|
throw new Error(`\u9700\u6C42\u6E05\u5355\u8BFB\u4E0D\u51FA\u6765\uFF08${file}\uFF09\uFF1A${e instanceof Error ? e.message : String(e)}`);
|
|
9027
9119
|
}
|
|
@@ -9953,6 +10045,7 @@ delivery.command("triage").description(
|
|
|
9953
10045
|
"\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
10046
|
).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
10047
|
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));
|
|
10048
|
+
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
10049
|
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
10050
|
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
10051
|
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(
|