@hcmai/cli 0.4.12 → 0.4.14
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
CHANGED
|
@@ -3035,7 +3035,9 @@ async function versionCommand(args) {
|
|
|
3035
3035
|
const fmt = args.output ?? "json";
|
|
3036
3036
|
if (fmt !== "json") process.stdout.write(`${endpoint}
|
|
3037
3037
|
`);
|
|
3038
|
-
process.stdout.write(
|
|
3038
|
+
process.stdout.write(
|
|
3039
|
+
formatObject5({ cli: CLI_VERSION, backend: info }, { format: fmt }) + "\n"
|
|
3040
|
+
);
|
|
3039
3041
|
process.exit(0);
|
|
3040
3042
|
} catch (e) {
|
|
3041
3043
|
const err = e;
|
|
@@ -3044,6 +3046,64 @@ async function versionCommand(args) {
|
|
|
3044
3046
|
}
|
|
3045
3047
|
}
|
|
3046
3048
|
|
|
3049
|
+
// src/commands/upgrade.ts
|
|
3050
|
+
async function fetchLatestVersion() {
|
|
3051
|
+
try {
|
|
3052
|
+
const resp = await fetch("https://registry.npmjs.org/@hcmai/cli/latest", {
|
|
3053
|
+
signal: AbortSignal.timeout(8e3)
|
|
3054
|
+
});
|
|
3055
|
+
if (!resp.ok) return null;
|
|
3056
|
+
const body = await resp.json();
|
|
3057
|
+
return typeof body.version === "string" ? body.version : null;
|
|
3058
|
+
} catch {
|
|
3059
|
+
return null;
|
|
3060
|
+
}
|
|
3061
|
+
}
|
|
3062
|
+
function detectInstallKind() {
|
|
3063
|
+
const entry = process.argv[1] ?? "";
|
|
3064
|
+
if (!entry) return "unknown";
|
|
3065
|
+
const inCwd = entry.startsWith(process.cwd());
|
|
3066
|
+
const inNodeModules = entry.includes("node_modules");
|
|
3067
|
+
if (inNodeModules && inCwd) return "local";
|
|
3068
|
+
if (inNodeModules && !inCwd) return "global";
|
|
3069
|
+
return "unknown";
|
|
3070
|
+
}
|
|
3071
|
+
function upgradeCommands(kind, target) {
|
|
3072
|
+
const spec = `@hcmai/cli@${target}`;
|
|
3073
|
+
switch (kind) {
|
|
3074
|
+
case "global":
|
|
3075
|
+
return [`npm i -g ${spec}`];
|
|
3076
|
+
case "local":
|
|
3077
|
+
return [`npm i ${spec}`];
|
|
3078
|
+
default:
|
|
3079
|
+
return [`npm i -g ${spec}`, `npm i ${spec} # \u9879\u76EE\u5185\u5B89\u88C5\u7528\u8FD9\u6761`];
|
|
3080
|
+
}
|
|
3081
|
+
}
|
|
3082
|
+
async function upgradeCommand(args) {
|
|
3083
|
+
const latest = await fetchLatestVersion();
|
|
3084
|
+
const kind = detectInstallKind();
|
|
3085
|
+
const lines = [`\u5F53\u524D CLI\uFF1A${CLI_VERSION}`];
|
|
3086
|
+
if (latest === null) {
|
|
3087
|
+
lines.push("\u6700\u65B0\u7248\u672C\uFF1A\u67E5\u4E0D\u5230\uFF08registry \u4E0D\u53EF\u8FBE\u6216\u8D85\u65F6\uFF09");
|
|
3088
|
+
} else if (latest === CLI_VERSION) {
|
|
3089
|
+
lines.push(`\u6700\u65B0\u7248\u672C\uFF1A${latest} \u2014\u2014 \u5DF2\u662F\u6700\u65B0\uFF0C\u65E0\u9700\u5347\u7EA7`);
|
|
3090
|
+
process.stdout.write(lines.join("\n") + "\n");
|
|
3091
|
+
process.exit(0);
|
|
3092
|
+
} else {
|
|
3093
|
+
lines.push(`\u6700\u65B0\u7248\u672C\uFF1A${latest}`);
|
|
3094
|
+
}
|
|
3095
|
+
const target = latest ?? "latest";
|
|
3096
|
+
lines.push("");
|
|
3097
|
+
lines.push(kind === "unknown" ? "\u5347\u7EA7\u547D\u4EE4\uFF08\u5224\u4E0D\u51FA\u5B89\u88C5\u65B9\u5F0F\uFF0C\u4E24\u6761\u90FD\u7ED9\uFF09\uFF1A" : "\u5347\u7EA7\u547D\u4EE4\uFF1A");
|
|
3098
|
+
for (const cmd of upgradeCommands(kind, target)) {
|
|
3099
|
+
lines.push(` ${cmd}`);
|
|
3100
|
+
}
|
|
3101
|
+
lines.push("");
|
|
3102
|
+
lines.push("\u5347\u7EA7\u540E\u7528 `hcm version` \u6838\u5BF9\uFF08\u5B83\u4F1A\u540C\u65F6\u62A5 CLI \u4E0E\u540E\u7AEF\u4E24\u4E2A\u7248\u672C\uFF09\u3002");
|
|
3103
|
+
process.stdout.write(lines.join("\n") + "\n");
|
|
3104
|
+
process.exit(args.check && latest !== null && latest !== CLI_VERSION ? 1 : 0);
|
|
3105
|
+
}
|
|
3106
|
+
|
|
3047
3107
|
// src/commands/delete.ts
|
|
3048
3108
|
init_auth_guard();
|
|
3049
3109
|
init_exit();
|
|
@@ -5722,9 +5782,9 @@ async function planSkillUpdate(options) {
|
|
|
5722
5782
|
for (const [id, item] of closure) {
|
|
5723
5783
|
const record = state.skills[id];
|
|
5724
5784
|
const onDisk = await readInstalled(baseDir, id);
|
|
5725
|
-
const
|
|
5785
|
+
const fetch2 = async () => item.kind === "cli" ? await fetchBundled(id) : await fetchDocument(item.skill);
|
|
5726
5786
|
if (onDisk === void 0) {
|
|
5727
|
-
documents.push(await
|
|
5787
|
+
documents.push(await fetch2());
|
|
5728
5788
|
entries.push({
|
|
5729
5789
|
id,
|
|
5730
5790
|
status: "added",
|
|
@@ -5732,7 +5792,7 @@ async function planSkillUpdate(options) {
|
|
|
5732
5792
|
});
|
|
5733
5793
|
continue;
|
|
5734
5794
|
}
|
|
5735
|
-
const remote = await
|
|
5795
|
+
const remote = await fetch2();
|
|
5736
5796
|
const remoteReferences = remote.references ?? [];
|
|
5737
5797
|
let differsFromRemote = remote.markdown !== onDisk;
|
|
5738
5798
|
let editedLocally = record !== void 0 && sha2562(onDisk) !== record.sha256;
|
|
@@ -9109,7 +9169,7 @@ function premise4(message, hint) {
|
|
|
9109
9169
|
`);
|
|
9110
9170
|
return 1;
|
|
9111
9171
|
}
|
|
9112
|
-
var REQUESTS_SHAPE = "`--requests` \u6536\u7684\u662F\u4E00\u4E2A JSON \u6570\u7EC4\uFF0C\u6BCF\u6761\u81F3\u5C11\u8981\u6709 `request` / `verdict` / `evidence` \u4E09\u683C\u3002\
|
|
9172
|
+
var REQUESTS_SHAPE = "`--requests` \u6536\u7684\u662F\u4E00\u4E2A JSON \u6570\u7EC4\uFF0C\u6BCF\u6761\u81F3\u5C11\u8981\u6709 `request` / `verdict` / `evidence` \u4E09\u683C\u3002\u4E03\u683C\u6838\u67E5\u8868\u7531\u672C\u547D\u4EE4\u81EA\u5DF1\u586B\uFF0C\u522B\u624B\u5199\u3002";
|
|
9113
9173
|
function readRequests(file) {
|
|
9114
9174
|
let raw;
|
|
9115
9175
|
try {
|
|
@@ -10036,7 +10096,7 @@ delivery.command("gate0").description(
|
|
|
10036
10096
|
"\u987E\u95EE\u624B\u5199\u7684\u6620\u5C04\u5DE5\u4EF6\uFF08naturalKey \u8FD9\u4E00\u7C7B\u7684\u552F\u4E00\u6765\u6E90\uFF09\uFF1B\u4E0D\u7ED9 \u21D2 \u90A3\u4E00\u7C7B\u6052\u7EFF \u21D2 rc=2"
|
|
10037
10097
|
).option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((opts) => deliveryGate0Command(opts));
|
|
10038
10098
|
delivery.command("triage").description(
|
|
10039
|
-
"\u9700\u6C42\u5206\u8BCA\uFF1A\
|
|
10099
|
+
"\u9700\u6C42\u5206\u8BCA\uFF1A\u4E03\u7C7B\u627F\u8F7D\u7269\u7531\u672C\u547D\u4EE4\u73B0\u63A2\u73B0\u586B\uFF08\u987E\u95EE\u8DF3\u4E0D\u4E86\u6B65\uFF09\uFF0C\u7ED3\u8BBA\u4E0E\u8BC1\u636E\u7531\u4F60\u7ED9\uFF0C\u5B83\u53EA\u5224\u4E24\u8005\u6253\u4E0D\u6253\u67B6"
|
|
10040
10100
|
).requiredOption(
|
|
10041
10101
|
"--requests <file>",
|
|
10042
10102
|
'\u5F85\u5206\u8BCA\u7684\u9700\u6C42\u6E05\u5355\uFF08**\u8FD9\u53F0\u673A\u5668\u4E0A**\u7684\u4E00\u4EFD JSON \u6570\u7EC4\uFF09\uFF1A\u6BCF\u6761 `{"request":\u5BA2\u6237\u539F\u8BDD, "verdict":REUSE|CONFIG|EXTEND|GAP, "evidence":\u51ED\u4EC0\u4E48\u8FD9\u4E48\u5224, "debtAction":\u7F3A\u54EA\u4E2A Action\uFF08GAP \u65F6\uFF09, "blindAcknowledged":true\uFF08\u5224 GAP \u4E14\u6709\u76F2\u533A\u65F6\u5FC5\u987B\u663E\u5F0F\u627F\u8BA4\uFF09}`'
|
|
@@ -10123,8 +10183,9 @@ skills.command("manifest").description("\u6253\u5370\u672C CLI \u7684\u547D\u4EE
|
|
|
10123
10183
|
skills.command("show <id>").description("\u6253\u5370\u6280\u80FD\u539F\u6587\uFF08\u7BA1\u9053\u53CB\u597D\uFF09\uFF1B\u81EA\u5E26\u6280\u80FD\u76F4\u63A5\u8BFB\u672C\u5730\uFF0C\u4E0D\u8FDE\u7F51").option("--source <kind>", "\u8FD9\u4E00\u8D9F\u770B\u54EA\u4E9B\u6765\u6E90\uFF1Acli\uFF08\u53EA\u770B\u81EA\u5E26\uFF0C\u4E0D\u8FDE\u7F51\uFF09| chiron | all", "all").option("--endpoint <url>", "\u6280\u80FD\u5E93\u5730\u5740\uFF08\u9ED8\u8BA4\u53D6 activeEnv \u7684 endpoint\uFF09").option("--env <name>", "\u4ECE\u8BE5 env \u89E3\u6790 endpoint").action((id, opts) => skillsShowCommand(id, opts));
|
|
10124
10184
|
skills.command("install [id]").description("\u8FDE\u540C requires \u524D\u7F6E\u6280\u80FD\u4E0E\u53C2\u8003\u6587\u4EF6\u88C5\u5230 agent \u6280\u80FD\u76EE\u5F55\uFF1B--all \u88C5\u6574\u4E2A\u6280\u80FD\u5E93").option("--all", "\u88C5\u6574\u4E2A\u6280\u80FD\u5E93\uFF0C\u5E76\u8BB0\u4E3A\u300C\u8DDF\u968F\u5168\u96C6\u300D\uFF08\u5F80\u540E update \u4F1A\u81EA\u52A8\u8865\u4E0A\u4EA7\u54C1\u65B0\u589E\u7684\u6280\u80FD\uFF09").option("--target <agent>", "\u88C5\u7ED9\u54EA\u4E2A agent\uFF1Aclaude\uFF08.claude/skills/\uFF09| codex\uFF08hcm-skills/ + AGENTS.md\uFF09| auto", "auto").option("--global", "\u88C5\u5230\u7528\u6237\u7EA7\u76EE\u5F55\u800C\u975E\u5F53\u524D\u9879\u76EE").option("--dir <path>", "\u88C5\u5230\u6307\u5B9A\u76EE\u5F55").option("--from <dir>", "\u4ECE\u672C\u5730\u76EE\u5F55\u88C5\uFF08\u73B0\u573A\u6539\u8FC7\u7684\u7248\u672C\uFF09\uFF0C\u4E0D\u8D70\u7F51\u7EDC").option("--source <kind>", "\u8FD9\u4E00\u8D9F\u770B\u54EA\u4E9B\u6765\u6E90\uFF1Acli\uFF08\u53EA\u770B\u81EA\u5E26\uFF0C\u4E0D\u8FDE\u7F51\uFF09| chiron | all", "all").option("--force", "\u8986\u76D6\u5DF2\u5B58\u5728\u7684\u540C\u540D\u6280\u80FD").option("--endpoint <url>", "\u6280\u80FD\u5E93\u5730\u5740\uFF08\u9ED8\u8BA4\u53D6 activeEnv \u7684 endpoint\uFF09").option("--env <name>", "\u4ECE\u8BE5 env \u89E3\u6790 endpoint").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((id, opts) => skillsInstallCommand(id, opts));
|
|
10125
10185
|
skills.command("update").description("\u628A\u88C5\u8FC7\u7684\u6280\u80FD\u5347\u5230\u76EE\u6807\u73AF\u5883\u8FD9\u4E00\u7248\uFF08\u4EA7\u54C1\u5347\u7EA7\u540E\u8DD1\u5B83\uFF09").option("--all", "\u8FDE\u4EA7\u54C1\u65B0\u589E\u7684\u6280\u80FD\u4E00\u8D77\u88C5\u4E0A\uFF0C\u5E76\u8BB0\u4E3A\u300C\u8DDF\u968F\u5168\u96C6\u300D").option("--check", "\u53EA\u770B\u4F1A\u53D8\u4EC0\u4E48\uFF0C\u4E0D\u5199\u76D8").option("--target <agent>", "claude | codex | auto\uFF08\u9ED8\u8BA4\u6309\u5DF2\u5B89\u88C5\u76EE\u5F55\u63A2\uFF09", "auto").option("--global", "\u5347\u7EA7\u7528\u6237\u7EA7\u76EE\u5F55\u91CC\u7684\u6280\u80FD").option("--dir <path>", "\u5347\u7EA7\u6307\u5B9A\u76EE\u5F55\u91CC\u7684\u6280\u80FD").option("--force", "\u8FDE\u672C\u5730\u6539\u8FC7\u7684\u6280\u80FD\u4E00\u8D77\u8986\u76D6\u6210\u4EA7\u54C1\u8FD9\u4E00\u7248").option("--source <kind>", "\u8FD9\u4E00\u8D9F\u770B\u54EA\u4E9B\u6765\u6E90\uFF1Acli\uFF08\u53EA\u770B\u81EA\u5E26\uFF0C\u4E0D\u8FDE\u7F51\uFF09| chiron | all", "all").option("--endpoint <url>", "\u6280\u80FD\u5E93\u5730\u5740\uFF08\u9ED8\u8BA4\u53D6\u5B89\u88C5\u65F6\u8BB0\u5F55\u7684\u5730\u5740\uFF09").option("--env <name>", "\u4ECE\u8BE5 env \u89E3\u6790 endpoint").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((opts) => skillsUpdateCommand(opts));
|
|
10126
|
-
program.command("update <Model>").description("\u66F4\u65B0\u4E00\u6761 Model \u8BB0\u5F55\uFF08\u8D70\u540E\u7AEF\u5B8C\u6574\u6821\u9A8C\uFF09").requiredOption("--id <id>", "\u8BB0\u5F55 ID").option("--data <JSON>", `\u8981\u66F4\u65B0\u7684\u5B57\u6BB5 JSON\uFF0C\u4F8B\u5982 '{"name":"\u65B0\u540D\u79F0"}'`).option("--data-file <path>", "\u4ECE UTF-8 JSON \u6587\u4EF6\u8BFB\u53D6\u66F4\u65B0\u5B57\u6BB5\uFF08\u4E0E --data \u4E92\u65A5\uFF09").option("--env <name>", "\u4E34\u65F6\u5207\u73AF\u5883\uFF08\u8986\u76D6 activeEnv\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((model, opts) => updateCommand(model, opts));
|
|
10127
|
-
program.command("version").description("\u67E5\u540E\u7AEF\u7248\u672C\uFF08commit / tag / \u6784\u5EFA\u65F6\u95F4\uFF09\u2014\u2014\u514D\u8BA4\u8BC1\uFF0C\u65E0\u9700\u5148 login").option("--endpoint <url>", "\u540E\u7AEF\u5730\u5740\uFF08\u9ED8\u8BA4\u53D6 activeEnv \u7684 endpoint\uFF09").option("--env <name>", "\u4ECE\u8BE5 env \u89E3\u6790 endpoint").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((opts) => versionCommand(opts));
|
|
10186
|
+
program.command("update <Model>").description("\u66F4\u65B0\u4E00\u6761 Model \u8BB0\u5F55\uFF08\u8D70\u540E\u7AEF\u5B8C\u6574\u6821\u9A8C\uFF09\u3002\u5347\u7EA7 CLI \u8BF7\u7528 `hcm upgrade`").requiredOption("--id <id>", "\u8BB0\u5F55 ID").option("--data <JSON>", `\u8981\u66F4\u65B0\u7684\u5B57\u6BB5 JSON\uFF0C\u4F8B\u5982 '{"name":"\u65B0\u540D\u79F0"}'`).option("--data-file <path>", "\u4ECE UTF-8 JSON \u6587\u4EF6\u8BFB\u53D6\u66F4\u65B0\u5B57\u6BB5\uFF08\u4E0E --data \u4E92\u65A5\uFF09").option("--env <name>", "\u4E34\u65F6\u5207\u73AF\u5883\uFF08\u8986\u76D6 activeEnv\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((model, opts) => updateCommand(model, opts));
|
|
10187
|
+
program.command("version").description("\u67E5 CLI \u4E0E\u540E\u7AEF\u4E24\u4E2A\u7248\u672C\uFF08commit / tag / \u6784\u5EFA\u65F6\u95F4\uFF09\u2014\u2014\u514D\u8BA4\u8BC1\uFF0C\u65E0\u9700\u5148 login").option("--endpoint <url>", "\u540E\u7AEF\u5730\u5740\uFF08\u9ED8\u8BA4\u53D6 activeEnv \u7684 endpoint\uFF09").option("--env <name>", "\u4ECE\u8BE5 env \u89E3\u6790 endpoint").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((opts) => versionCommand(opts));
|
|
10188
|
+
program.command("upgrade").alias("self-update").description("\u5347\u7EA7 CLI \u81EA\u5DF1\uFF08\u6CE8\u610F\uFF1A`hcm update` \u662F\u66F4\u65B0\u4E1A\u52A1\u8BB0\u5F55\uFF0C\u4E0D\u662F\u5347\u7EA7\uFF09").option("--check", "\u53EA\u68C0\u67E5\uFF1B\u6709\u65B0\u7248\u672C\u65F6\u4EE5\u9000\u51FA\u7801 1 \u7ED3\u675F\uFF0C\u4FBF\u4E8E\u811A\u672C\u5224\u65AD").action((opts) => upgradeCommand(opts));
|
|
10128
10189
|
var setting = program.command("setting").description("\u79DF\u6237\u7CFB\u7EDF\u53C2\u6570\uFF08\u767B\u5F55\u7B56\u7565 / \u5BC6\u7801\u7B56\u7565 / \u529F\u80FD\u5F00\u5173 / \u96C6\u6210\u53C2\u6570\uFF09");
|
|
10129
10190
|
setting.command("get <domain>").description("\u8BFB\u67D0\u57DF\u53C2\u6570\uFF08\u5B9A\u4E49 + \u79DF\u6237\u8986\u76D6\u503C\u5408\u5E76\uFF0C\u7F3A\u5931\u56DE\u843D\u9ED8\u8BA4\u503C\uFF09").option("--env <name>", "\u4E34\u65F6\u5207\u73AF\u5883\uFF08\u8986\u76D6 activeEnv\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((d, opts) => settingGetCommand(d, opts));
|
|
10130
10191
|
setting.command("set <domain>").description("\u6539\u53C2\u6570\uFF0C\u53EF\u91CD\u590D --set\uFF1B\u8D70\u53D7\u63A7\u6821\u9A8C\u8DEF\u5F84\u800C\u975E\u6807\u51C6 CRUD").option("--set <assignment...>", "namespace.key=value\uFF0C\u4F8B\u5982 security.password.passwordPolicy=complex").option("--dry-run", "\u53EA\u663E\u793A\u5C06\u5199\u5165\u4EC0\u4E48\uFF0C\u4E0D\u5B9E\u9645\u5199\u5165").option("--env <name>", "\u4E34\u65F6\u5207\u73AF\u5883\uFF08\u8986\u76D6 activeEnv\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((d, opts) => settingSetCommand(d, opts));
|