@hcmai/cli 0.9.1 → 0.9.3
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 +328 -327
- package/dist/index.js.map +1 -1
- package/dist/skills/manifest.json +3 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -8662,13 +8662,13 @@ async function identityRemove(name) {
|
|
|
8662
8662
|
init_auth_guard();
|
|
8663
8663
|
init_exit();
|
|
8664
8664
|
import { promises as fs9 } from "fs";
|
|
8665
|
-
import
|
|
8665
|
+
import path9 from "path";
|
|
8666
8666
|
import {
|
|
8667
|
-
CliError as
|
|
8668
|
-
CliErrorCode as
|
|
8667
|
+
CliError as CliError23,
|
|
8668
|
+
CliErrorCode as CliErrorCode22,
|
|
8669
8669
|
HcmClient as HcmClient20,
|
|
8670
8670
|
fetchReconIdentity,
|
|
8671
|
-
formatObject as
|
|
8671
|
+
formatObject as formatObject22,
|
|
8672
8672
|
httpProbe,
|
|
8673
8673
|
isTempEnv as isTempEnv3,
|
|
8674
8674
|
listIdentities as listIdentities5,
|
|
@@ -8894,16 +8894,282 @@ function upsertBlock(existing, begin, end, block) {
|
|
|
8894
8894
|
|
|
8895
8895
|
// src/commands/chiron-project.ts
|
|
8896
8896
|
import { promises as fs8 } from "fs";
|
|
8897
|
+
|
|
8898
|
+
// src/commands/chiron-case.ts
|
|
8899
|
+
init_exit();
|
|
8900
|
+
import { execFileSync } from "child_process";
|
|
8901
|
+
import { cpSync, existsSync as existsSync2, mkdirSync, mkdtempSync, readFileSync as readFileSync5, rmSync, statSync as statSync4, writeFileSync as writeFileSync2 } from "fs";
|
|
8897
8902
|
import os4 from "os";
|
|
8898
8903
|
import path7 from "path";
|
|
8899
|
-
import {
|
|
8904
|
+
import { CASES_REPO_SLUG, CASES_REPO_URL, CNB_ORIGIN, CliError as CliError22, CliErrorCode as CliErrorCode21, formatObject as formatObject21 } from "@hcmai/sdk";
|
|
8905
|
+
var casesCacheDir = () => process.env.HCM_CASES_CACHE?.trim() || path7.join(os4.homedir(), ".cache", "hcm", "chiron-cases");
|
|
8906
|
+
var INDEX_CACHE = () => path7.join(casesCacheDir(), "index.json");
|
|
8907
|
+
var INDEX_TTL_MS = 60 * 60 * 1e3;
|
|
8908
|
+
var fail7 = (message, nextStep) => new CliError22({ code: CliErrorCode21.INVALID_ARGUMENT, message, context: { nextStep } });
|
|
8909
|
+
var run = (cmd, args, opts = {}) => execFileSync(cmd, args, { encoding: "utf8", maxBuffer: 1 << 26, ...opts });
|
|
8910
|
+
function fetchRepoFile(relPath) {
|
|
8911
|
+
let raw;
|
|
8912
|
+
try {
|
|
8913
|
+
raw = run("cnb", ["git", "get-raw", "--repo", CASES_REPO_SLUG, "--ref-with-path", `main/${relPath}`]);
|
|
8914
|
+
} catch (e) {
|
|
8915
|
+
throw fail7(
|
|
8916
|
+
`\u53D6\u4E0D\u5230\u6848\u4F8B\u5E93\u6587\u4EF6 ${relPath}\uFF1A${String(e.message).split("\n")[0]}`,
|
|
8917
|
+
"\u6848\u4F8B\u5E93\u8BFB\u53D6\u8D70 cnb\uFF08\u9700\u8981\u5DF2 `cnb login` \u4E14\u6709\u8BE5\u4ED3\u8BFB\u6743\u9650\uFF09\u3002\u6CA1\u6709\u6743\u9650\u5C31\u5148\u8DF3\u8FC7\u6848\u4F8B\u5E93\uFF0C\u76F4\u63A5\u6309\u6280\u80FD\u505A\uFF1B\u522B\u628A\u300C\u53D6\u4E0D\u5230\u300D\u5F53\u6210\u300C\u6CA1\u6709\u5148\u4F8B\u300D\u3002"
|
|
8918
|
+
);
|
|
8919
|
+
}
|
|
8920
|
+
const i = raw.indexOf("data: ");
|
|
8921
|
+
if (i < 0) throw fail7(`cnb \u7684\u56DE\u6267\u91CC\u6CA1\u6709 data \u90A3\u4E00\u683C\uFF1A${relPath}`, "\u5347\u7EA7 cnb CLI\uFF0C\u6216\u628A\u8FD9\u6BB5\u539F\u6837\u8D34\u7ED9\u6211\u3002");
|
|
8922
|
+
const body = raw.slice(i + "data: ".length).trim();
|
|
8923
|
+
if (body.startsWith('"')) {
|
|
8924
|
+
try {
|
|
8925
|
+
return JSON.parse(body);
|
|
8926
|
+
} catch {
|
|
8927
|
+
return body;
|
|
8928
|
+
}
|
|
8929
|
+
}
|
|
8930
|
+
return body;
|
|
8931
|
+
}
|
|
8932
|
+
function loadIndex(opts = {}) {
|
|
8933
|
+
const file = INDEX_CACHE();
|
|
8934
|
+
const fresh = !opts.refresh && existsSync2(file) && Date.now() - statSync4(file).mtimeMs < INDEX_TTL_MS;
|
|
8935
|
+
if (fresh) return JSON.parse(readFileSync5(file, "utf8"));
|
|
8936
|
+
let text;
|
|
8937
|
+
try {
|
|
8938
|
+
text = fetchRepoFile("index/index.json");
|
|
8939
|
+
} catch (e) {
|
|
8940
|
+
if (!existsSync2(file)) throw e;
|
|
8941
|
+
process.stderr.write(
|
|
8942
|
+
`[hcm] \u7D22\u5F15\u6CA1\u62C9\u52A8\uFF08${e.message.split("\n")[0]}\uFF09\uFF0C\u7528\u672C\u673A\u7F13\u5B58\u7684\u90A3\u4EFD\uFF1A${file}
|
|
8943
|
+
`
|
|
8944
|
+
);
|
|
8945
|
+
return JSON.parse(readFileSync5(file, "utf8"));
|
|
8946
|
+
}
|
|
8947
|
+
mkdirSync(path7.dirname(file), { recursive: true });
|
|
8948
|
+
writeFileSync2(file, text);
|
|
8949
|
+
return JSON.parse(text);
|
|
8950
|
+
}
|
|
8951
|
+
function backendFingerprint(env2) {
|
|
8952
|
+
if (!env2) return { reason: "\u6CA1\u7ED9 --env\uFF0C\u6CA1\u6CD5\u73B0\u67E5\u6307\u7EB9" };
|
|
8953
|
+
try {
|
|
8954
|
+
const raw = run(process.execPath, [process.argv[1], "version", "--env", env2, "--output", "json"]);
|
|
8955
|
+
const j = JSON.parse(raw.slice(raw.indexOf("{")));
|
|
8956
|
+
const backend = j.backend?.commit ?? j.commit ?? j.server?.commit;
|
|
8957
|
+
if (!backend) return { reason: "\u540E\u7AEF\u56DE\u6267\u91CC\u6CA1\u6709 commit \u5B57\u6BB5" };
|
|
8958
|
+
return { backend: String(backend), cli: String(j.cli?.version ?? j.cliVersion ?? "") };
|
|
8959
|
+
} catch (e) {
|
|
8960
|
+
return { reason: String(e.message).split("\n")[0]?.slice(0, 120) };
|
|
8961
|
+
}
|
|
8962
|
+
}
|
|
8963
|
+
function matchTag(c, fp) {
|
|
8964
|
+
if (!fp.backend) return `\u672A\u6BD4\u5BF9\uFF08${fp.reason ?? "\u6CA1\u6709\u6307\u7EB9"}\uFF09`;
|
|
8965
|
+
const be = String(c.fingerprint?.backend_commit ?? "");
|
|
8966
|
+
if (!be) return "\u6848\u4F8B\u6CA1\u8BB0\u540E\u7AEF\u6307\u7EB9";
|
|
8967
|
+
const a = be.slice(0, 12);
|
|
8968
|
+
const b = fp.backend.slice(0, 12);
|
|
8969
|
+
return a === b ? "\u5339\u914D" : `\u4E0D\u5339\u914D\uFF08\u6848\u4F8B ${a} / \u5F53\u524D ${b}\uFF09`;
|
|
8970
|
+
}
|
|
8971
|
+
function emit4(args, data, text) {
|
|
8972
|
+
if (args.output === "json" || args.output === "yaml") {
|
|
8973
|
+
process.stdout.write(formatObject21(data, { format: args.output }) + "\n");
|
|
8974
|
+
} else {
|
|
8975
|
+
process.stdout.write(text() + "\n");
|
|
8976
|
+
}
|
|
8977
|
+
}
|
|
8978
|
+
async function guard(fn) {
|
|
8979
|
+
try {
|
|
8980
|
+
await fn();
|
|
8981
|
+
} catch (e) {
|
|
8982
|
+
exitWithError(e);
|
|
8983
|
+
}
|
|
8984
|
+
}
|
|
8985
|
+
async function caseSearchCommand(query, args) {
|
|
8986
|
+
await guard(async () => {
|
|
8987
|
+
const idx = loadIndex({ refresh: args.refresh });
|
|
8988
|
+
const fp = backendFingerprint(args.env);
|
|
8989
|
+
let raw;
|
|
8990
|
+
try {
|
|
8991
|
+
raw = run("cnb", [
|
|
8992
|
+
"knowledge-base",
|
|
8993
|
+
"query-knowledge-base-get",
|
|
8994
|
+
"--repo",
|
|
8995
|
+
CASES_REPO_SLUG,
|
|
8996
|
+
"--query",
|
|
8997
|
+
query,
|
|
8998
|
+
"--top-k",
|
|
8999
|
+
String(args.topK ?? 5),
|
|
9000
|
+
"--verbose"
|
|
9001
|
+
]);
|
|
9002
|
+
} catch (e) {
|
|
9003
|
+
throw fail7(
|
|
9004
|
+
`\u6848\u4F8B\u5E93\u68C0\u7D22\u6CA1\u8DD1\u6210\uFF1A${String(e.message).split("\n")[0]}`,
|
|
9005
|
+
"\u68C0\u7D22\u8D70 cnb \u7684\u77E5\u8BC6\u5E93\u63A5\u53E3\uFF0C\u9700\u8981 cnb \u5DF2\u767B\u5F55\u4E14\u6709\u6848\u4F8B\u5E93\u6743\u9650\u3002\u6CA1\u6709\u5C31\u5148\u8DF3\u8FC7\u6848\u4F8B\u5E93\uFF0C\u76F4\u63A5\u6309\u6280\u80FD\u505A\uFF1B\u522B\u628A\u300C\u67E5\u4E0D\u5230\u300D\u5F53\u6210\u300C\u6CA1\u6709\u5148\u4F8B\u300D\u3002"
|
|
9006
|
+
);
|
|
9007
|
+
}
|
|
9008
|
+
const json = JSON.parse(raw.slice(raw.indexOf("{")));
|
|
9009
|
+
const seen = /* @__PURE__ */ new Map();
|
|
9010
|
+
for (const h of json.data ?? []) {
|
|
9011
|
+
const p = h.metadata?.path ?? "";
|
|
9012
|
+
const m = /^cases\/[^/]+\/([^/]+)\//.exec(p);
|
|
9013
|
+
if (!m) continue;
|
|
9014
|
+
const id = m[1];
|
|
9015
|
+
if (seen.has(id)) continue;
|
|
9016
|
+
const c = idx.cases.find((x) => x.id === id);
|
|
9017
|
+
seen.set(id, {
|
|
9018
|
+
id,
|
|
9019
|
+
score: h.score,
|
|
9020
|
+
file: p.split("/").pop(),
|
|
9021
|
+
status: c?.status,
|
|
9022
|
+
tier: c?.tier,
|
|
9023
|
+
skills: c?.skills,
|
|
9024
|
+
customer_ask: c?.customer_ask,
|
|
9025
|
+
match: c ? matchTag(c, fp) : "\u7D22\u5F15\u91CC\u6CA1\u6709\uFF08\u672C\u673A clone \u53EF\u80FD\u65E7\u4E86\uFF0Cgit pull \u4E00\u6B21\uFF09"
|
|
9026
|
+
});
|
|
9027
|
+
}
|
|
9028
|
+
const rows = [...seen.values()];
|
|
9029
|
+
emit4(
|
|
9030
|
+
args,
|
|
9031
|
+
{ query, rows },
|
|
9032
|
+
() => rows.length ? rows.map((r) => `${r.id} [${r.status ?? "?"}\xB7${r.match}] ${r.customer_ask ?? ""}
|
|
9033
|
+
\u6280\u80FD\uFF1A${(r.skills ?? []).join(" / ") || "\uFF08\u672A\u767B\u8BB0\uFF09"}`).join("\n") : `\u6CA1\u6709\u547D\u4E2D\u300C${query}\u300D\u7684\u6848\u4F8B\u3002\u5148\u6309\u6280\u80FD\u505A\uFF0C\u8DD1\u901A\u4E86\u7528 \`hcm chiron case submit\` \u4E0A\u884C\u4E00\u6761\u3002`
|
|
9034
|
+
);
|
|
9035
|
+
});
|
|
9036
|
+
}
|
|
9037
|
+
async function caseShowCommand(id, args) {
|
|
9038
|
+
await guard(async () => {
|
|
9039
|
+
const idx = loadIndex({ refresh: args.refresh });
|
|
9040
|
+
const c = idx.cases.find((x) => x.id === id);
|
|
9041
|
+
if (!c?.path) {
|
|
9042
|
+
throw fail7(
|
|
9043
|
+
`\u7D22\u5F15\u91CC\u6CA1\u6709\u6848\u4F8B ${id}`,
|
|
9044
|
+
`\u5148 \`hcm chiron case search <\u5173\u952E\u8BCD>\` \u62FF\u51C6\u786E\u7684 id\uFF1B\u7D22\u5F15\u53EF\u80FD\u65E7\u4E86\uFF0C\u52A0 --refresh \u518D\u8BD5\u4E00\u6B21\u3002`
|
|
9045
|
+
);
|
|
9046
|
+
}
|
|
9047
|
+
const files = args.file ? [args.file] : ["\u95EE\u9898.md", "\u65B9\u6848.md"];
|
|
9048
|
+
const parts = [];
|
|
9049
|
+
for (const f of files) {
|
|
9050
|
+
try {
|
|
9051
|
+
parts.push(`# ${f}
|
|
9052
|
+
|
|
9053
|
+
${fetchRepoFile(`${c.path}/${f}`)}`);
|
|
9054
|
+
} catch {
|
|
9055
|
+
parts.push(`# ${f}
|
|
9056
|
+
|
|
9057
|
+
\uFF08\u8FD9\u4E2A\u6848\u4F8B\u6CA1\u6709\u8FD9\u4EFD\u6587\u4EF6\uFF09`);
|
|
9058
|
+
}
|
|
9059
|
+
}
|
|
9060
|
+
const meta2 = fetchRepoFile(`${c.path}/case.yml`);
|
|
9061
|
+
emit4(
|
|
9062
|
+
args,
|
|
9063
|
+
{ id, caseYml: meta2, files: parts },
|
|
9064
|
+
() => `case.yml:
|
|
9065
|
+
${meta2}
|
|
9066
|
+
|
|
9067
|
+
${parts.join("\n\n---\n\n")}
|
|
9068
|
+
|
|
9069
|
+
\uFF08\u8BC1\u636E\u6587\u4EF6\u6CA1\u6709\u4E0B\u8F7D \u2014\u2014 \u53BB ${CNB_ORIGIN}/${CASES_REPO_SLUG}/-/tree/main/${c.path} \u770B\uFF09`
|
|
9070
|
+
);
|
|
9071
|
+
});
|
|
9072
|
+
}
|
|
9073
|
+
async function caseMatchCommand(args) {
|
|
9074
|
+
await guard(async () => {
|
|
9075
|
+
const idx = loadIndex({ refresh: args.refresh });
|
|
9076
|
+
const fp = backendFingerprint(args.env);
|
|
9077
|
+
const rows = idx.cases.filter((c) => c.status === "approved").map((c) => ({ id: c.id, match: matchTag(c, fp), skills: c.skills, customer_ask: c.customer_ask }));
|
|
9078
|
+
emit4(args, { fingerprint: fp, rows }, () => {
|
|
9079
|
+
const head = fp.backend ? `\u5F53\u524D\u540E\u7AEF ${fp.backend.slice(0, 12)}\uFF08env ${args.env}\uFF09` : `\u26A0\uFE0F \u6CA1\u53D6\u5230\u5F53\u524D\u6307\u7EB9\uFF08${fp.reason}\uFF09\u2014\u2014\u4E0B\u9762\u6BCF\u4E00\u6761\u90FD\u6807\u7740\u300C\u672A\u6BD4\u5BF9\u300D\uFF0C\u522B\u628A\u5B83\u8BFB\u6210\u300C\u90FD\u80FD\u7167\u505A\u300D`;
|
|
9080
|
+
return [head, ...rows.map((r) => `${r.match === "\u5339\u914D" ? "\u2705" : "\xB7 "} ${r.id} [${r.match}] ${r.customer_ask ?? ""}`)].join("\n");
|
|
9081
|
+
});
|
|
9082
|
+
});
|
|
9083
|
+
}
|
|
9084
|
+
async function caseSubmitCommand(dir, args) {
|
|
9085
|
+
await guard(async () => {
|
|
9086
|
+
const src = path7.resolve(dir);
|
|
9087
|
+
if (!existsSync2(path7.join(src, "case.yml"))) {
|
|
9088
|
+
throw fail7(`${src} \u91CC\u6CA1\u6709 case.yml`, "\u6307\u5230\u9879\u76EE\u4ED3\u7684\u6848\u4F8B\u76EE\u5F55\uFF08\u5982 cases/CASE-20260902-xxx\uFF09\uFF0C\u90A3\u91CC\u5E94\u5F53\u6709 case.yml\u3002");
|
|
9089
|
+
}
|
|
9090
|
+
const yamlText = readFileSync5(path7.join(src, "case.yml"), "utf8");
|
|
9091
|
+
const id = /^\s*(?:id|case_id):\s*(\S+)/m.exec(yamlText)?.[1];
|
|
9092
|
+
if (!id) throw fail7("case.yml \u91CC\u6CA1\u6709 id", "case.yml \u9876\u5C42\u8981\u6709 `id: CASE-YYYYMMDD-xxx`\u3002");
|
|
9093
|
+
const work = mkdtempSync(path7.join(os4.tmpdir(), "hcm-case-submit-"));
|
|
9094
|
+
try {
|
|
9095
|
+
const repo = path7.join(work, "chiron-cases");
|
|
9096
|
+
try {
|
|
9097
|
+
run("git", ["clone", "--depth", "1", "--filter=blob:none", "--quiet", CASES_REPO_URL, repo]);
|
|
9098
|
+
} catch (e) {
|
|
9099
|
+
throw fail7(
|
|
9100
|
+
`clone \u6848\u4F8B\u5E93\u5931\u8D25\uFF1A${String(e.message).split("\n")[0]}`,
|
|
9101
|
+
`\u4E0A\u884C\u8981\u5F80 ${CASES_REPO_SLUG} \u63D0 PR\uFF0C\u9700\u8981\u8BE5\u4ED3\u5199\u6743\u9650\uFF08\`cnb login\` \u4E14\u88AB\u52A0\u8FDB\u4ED3\uFF09\u3002\u6848\u4F8B\u8FD8\u5728\u4F60\u7684\u9879\u76EE\u4ED3\u91CC\uFF0C\u6CA1\u4E22\u3002`
|
|
9102
|
+
);
|
|
9103
|
+
}
|
|
9104
|
+
const branch = `case/${id}-submit`;
|
|
9105
|
+
run("git", ["-C", repo, "checkout", "-q", "-B", branch]);
|
|
9106
|
+
const dst = path7.join(repo, "cases", args.category, id);
|
|
9107
|
+
cpSync(src, dst, { recursive: true, filter: (p) => !p.includes("node_modules") });
|
|
9108
|
+
mkdirSync(path7.join(dst, "evidence"), { recursive: true });
|
|
9109
|
+
let doc = readFileSync5(path7.join(dst, "case.yml"), "utf8");
|
|
9110
|
+
doc = /^\s*tier:/m.test(doc) ? doc.replace(/^\s*tier:.*$/m, "tier: public") : `tier: public
|
|
9111
|
+
${doc}`;
|
|
9112
|
+
doc = /^\s*category:/m.test(doc) ? doc.replace(/^\s*category:.*$/m, `category: ${args.category}`) : `category: ${args.category}
|
|
9113
|
+
${doc}`;
|
|
9114
|
+
doc = /^\s*origin:/m.test(doc) ? doc.replace(/^\s*origin:.*$/m, `origin: ${args.origin}`) : `origin: ${args.origin}
|
|
9115
|
+
${doc}`;
|
|
9116
|
+
if (!/^\s*status:/m.test(doc)) doc = `status: approved
|
|
9117
|
+
${doc}`;
|
|
9118
|
+
writeFileSync2(path7.join(dst, "case.yml"), doc);
|
|
9119
|
+
run("python3", ["scripts/render-readme.py", dst], { cwd: repo });
|
|
9120
|
+
let lint;
|
|
9121
|
+
try {
|
|
9122
|
+
lint = run("python3", ["scripts/lint-case.py"], { cwd: repo });
|
|
9123
|
+
} catch (e) {
|
|
9124
|
+
throw fail7(
|
|
9125
|
+
`\u6848\u4F8B lint \u6CA1\u8FC7\uFF0CPR \u6CA1\u5F00\uFF1A
|
|
9126
|
+
${e.stdout ?? e.message}`,
|
|
9127
|
+
"\u7167 lint \u7684\u63D0\u793A\u8865\u9F50 case.yml \u4E0E\u6B63\u6587\uFF0C\u518D\u8DD1\u4E00\u6B21\u3002\u6848\u4F8B\u8FD8\u5728\u9879\u76EE\u4ED3\u91CC\uFF0C\u6CA1\u4E22\u3002"
|
|
9128
|
+
);
|
|
9129
|
+
}
|
|
9130
|
+
run("python3", ["scripts/build-index.py"], { cwd: repo });
|
|
9131
|
+
run("git", ["-C", repo, "add", "-A"]);
|
|
9132
|
+
run("git", ["-C", repo, "-c", "user.name=hcm-cli", "-c", "user.email=chiron@local", "commit", "-q", "-m", `case: ${id}\uFF08\u9879\u76EE\u6848\u4F8B\u4E0A\u884C\uFF09`]);
|
|
9133
|
+
run("git", ["-C", repo, "push", "-q", "-f", "-u", "origin", branch]);
|
|
9134
|
+
const pr = run("cnb", [
|
|
9135
|
+
"pulls",
|
|
9136
|
+
"post-pull",
|
|
9137
|
+
"--repo",
|
|
9138
|
+
CASES_REPO_SLUG,
|
|
9139
|
+
"--base",
|
|
9140
|
+
"main",
|
|
9141
|
+
"--head",
|
|
9142
|
+
branch,
|
|
9143
|
+
"--title",
|
|
9144
|
+
`case: ${id}\uFF08\u9879\u76EE\u6848\u4F8B\u4E0A\u884C\uFF09`,
|
|
9145
|
+
"--body",
|
|
9146
|
+
`\u6765\u6E90\uFF1A${args.origin}
|
|
9147
|
+
|
|
9148
|
+
\u7531 \`hcm chiron case submit\` \u63D0\u4EA4\uFF0Clint \u5DF2\u8FC7\u3002`
|
|
9149
|
+
]);
|
|
9150
|
+
const num = /number: "?(\d+)/.exec(pr)?.[1];
|
|
9151
|
+
rmSync(INDEX_CACHE(), { force: true });
|
|
9152
|
+
emit4(
|
|
9153
|
+
args,
|
|
9154
|
+
{ id, pr: num, lint: lint.trim() },
|
|
9155
|
+
() => `\u5DF2\u5F00 PR #${num ?? "?"}\uFF1A${CNB_ORIGIN}/${CASES_REPO_SLUG}/-/pulls/${num ?? ""}
|
|
9156
|
+
${lint.trim()}`
|
|
9157
|
+
);
|
|
9158
|
+
} finally {
|
|
9159
|
+
rmSync(work, { recursive: true, force: true });
|
|
9160
|
+
}
|
|
9161
|
+
});
|
|
9162
|
+
}
|
|
9163
|
+
|
|
9164
|
+
// src/commands/chiron-project.ts
|
|
9165
|
+
import os5 from "os";
|
|
9166
|
+
import path8 from "path";
|
|
8900
9167
|
import { hcmConfigDir, listEnvs as listEnvs3, listIdentities as listIdentities4, loadEnv as loadEnv9, loadGlobalConfig as loadGlobalConfig9 } from "@hcmai/sdk";
|
|
8901
9168
|
import { JIRA_BASE, JIRA_PROJECT, jiraTokenSource } from "@hcmai/sdk";
|
|
8902
|
-
import { CASES_REPO_URL } from "@hcmai/sdk";
|
|
9169
|
+
import { CASES_REPO_URL as CASES_REPO_URL2 } from "@hcmai/sdk";
|
|
8903
9170
|
import { JIRA_BASE as JIRA_BASE2, JIRA_PROJECT as JIRA_PROJECT2, JIRA_TOKEN_FILE, jiraTokenSource as jiraTokenSource2 } from "@hcmai/sdk";
|
|
8904
9171
|
var ENV_FILE = "env.yaml";
|
|
8905
9172
|
var SKILLS_DIR = "hcm-skills";
|
|
8906
|
-
var CASES_MCP_NAME = "chiron-cases";
|
|
8907
9173
|
var CHIRON_PROJECT_DIRECTORIES = [
|
|
8908
9174
|
"work",
|
|
8909
9175
|
"decisions",
|
|
@@ -8997,41 +9263,13 @@ function renderChironAgentInstructions() {
|
|
|
8997
9263
|
function mergeChironAgentInstructions(existing) {
|
|
8998
9264
|
return upsertBlock(existing, AGENT_BEGIN, AGENT_END, renderChironAgentInstructions().trimEnd());
|
|
8999
9265
|
}
|
|
9000
|
-
function
|
|
9001
|
-
|
|
9002
|
-
|
|
9003
|
-
|
|
9004
|
-
|
|
9005
|
-
|
|
9006
|
-
return { status: r.status, stderr: r.stderr ?? "", error: r.error };
|
|
9007
|
-
}
|
|
9008
|
-
};
|
|
9009
|
-
async function ensureCaseLibrary(deps = defaultCaseLibraryDeps, paths = {}) {
|
|
9010
|
-
const repo = paths.repo ?? caseLibraryDir();
|
|
9011
|
-
const status = { ok: false, repo, step: "present" };
|
|
9012
|
-
const hasGit = await exists2(path7.join(repo, ".git"));
|
|
9013
|
-
if (hasGit) {
|
|
9014
|
-
const pull = deps.git(["pull", "--ff-only", "--quiet"], repo);
|
|
9015
|
-
status.step = pull.status === 0 ? "updated" : "present";
|
|
9016
|
-
if (pull.status !== 0) status.reason = `\u66F4\u65B0\u5931\u8D25\uFF0C\u6CBF\u7528\u672C\u5730\u7248\u672C\uFF1A${firstLine(pull.stderr, pull.error)}`;
|
|
9017
|
-
} else {
|
|
9018
|
-
await fs8.mkdir(path7.dirname(repo), { recursive: true });
|
|
9019
|
-
const clone = deps.git(["clone", "--depth", "1", "--quiet", CASES_REPO_URL, repo]);
|
|
9020
|
-
if (clone.status !== 0) {
|
|
9021
|
-
status.step = "clone-failed";
|
|
9022
|
-
status.reason = `clone \u5931\u8D25\uFF08\u591A\u534A\u662F\u6CA1\u6709 ${CASES_REPO_URL.replace(/\.git$/, "")} \u7684\u6743\u9650\uFF0C\u6216\u672C\u673A git \u672A\u767B\u5F55 cnb\uFF09\uFF1A${firstLine(clone.stderr, clone.error)}`;
|
|
9023
|
-
return status;
|
|
9024
|
-
}
|
|
9025
|
-
status.step = "cloned";
|
|
9266
|
+
async function inspectCaseLibrary() {
|
|
9267
|
+
try {
|
|
9268
|
+
const idx = loadIndex();
|
|
9269
|
+
return { ok: true, count: idx.cases.length };
|
|
9270
|
+
} catch (e) {
|
|
9271
|
+
return { ok: false, reason: firstLine("", e) };
|
|
9026
9272
|
}
|
|
9027
|
-
status.ok = true;
|
|
9028
|
-
return status;
|
|
9029
|
-
}
|
|
9030
|
-
async function inspectCaseLibrary(paths = {}) {
|
|
9031
|
-
const repo = paths.repo ?? caseLibraryDir();
|
|
9032
|
-
const cloned = await exists2(path7.join(repo, ".git"));
|
|
9033
|
-
const indexed = cloned && await exists2(path7.join(repo, "index", "index.json"));
|
|
9034
|
-
return { repo, cloned, indexed };
|
|
9035
9273
|
}
|
|
9036
9274
|
function firstLine(stderr, error) {
|
|
9037
9275
|
if (error) return error.message;
|
|
@@ -9070,14 +9308,6 @@ async function inspectJira() {
|
|
|
9070
9308
|
return { ok: false, from: src.from, reason: `\u8FDE\u4E0D\u4E0A ${JIRA_BASE}\uFF1A${e.message}` };
|
|
9071
9309
|
}
|
|
9072
9310
|
}
|
|
9073
|
-
async function exists2(file) {
|
|
9074
|
-
try {
|
|
9075
|
-
await fs8.access(file);
|
|
9076
|
-
return true;
|
|
9077
|
-
} catch {
|
|
9078
|
-
return false;
|
|
9079
|
-
}
|
|
9080
|
-
}
|
|
9081
9311
|
|
|
9082
9312
|
// src/commands/chiron-init.ts
|
|
9083
9313
|
async function probeTokenTenant(envName, requested) {
|
|
@@ -9096,7 +9326,7 @@ var defaultChironInitDeps = {
|
|
|
9096
9326
|
all: true,
|
|
9097
9327
|
target: "codex",
|
|
9098
9328
|
env: envName,
|
|
9099
|
-
dir:
|
|
9329
|
+
dir: path9.join(root, SKILLS_DIR),
|
|
9100
9330
|
output: "table"
|
|
9101
9331
|
});
|
|
9102
9332
|
} finally {
|
|
@@ -9105,30 +9335,29 @@ var defaultChironInitDeps = {
|
|
|
9105
9335
|
if (process.exitCode && process.exitCode !== 0) {
|
|
9106
9336
|
throw new Error("\u6280\u80FD\u6CA1\u88C5\u4E0A\uFF08\u4E0A\u9762\u662F skills install \u7684\u8F93\u51FA\uFF09\uFF1B\u4FEE\u597D\u540E\u91CD\u8DD1 hcm chiron init");
|
|
9107
9337
|
}
|
|
9108
|
-
}
|
|
9109
|
-
caseLibrary: () => ensureCaseLibrary()
|
|
9338
|
+
}
|
|
9110
9339
|
};
|
|
9111
9340
|
async function resolveLoggedInEnv() {
|
|
9112
9341
|
const g = await loadGlobalConfig10();
|
|
9113
9342
|
const name = g.activeEnv;
|
|
9114
9343
|
const loginHint = "hcm login https://<\u4F60\u7684 HCM \u5730\u5740> --code <\u914D\u5BF9\u7801>";
|
|
9115
9344
|
if (!name) {
|
|
9116
|
-
throw new
|
|
9117
|
-
code:
|
|
9345
|
+
throw new CliError23({
|
|
9346
|
+
code: CliErrorCode22.ENV_NOT_FOUND,
|
|
9118
9347
|
message: `\u8FD8\u6CA1\u767B\u5F55\u4EFB\u4F55\u73AF\u5883\u3002\u5148\u6267\u884C\uFF1A${loginHint}`
|
|
9119
9348
|
});
|
|
9120
9349
|
}
|
|
9121
9350
|
const config2 = await loadEnv10(name).catch(() => null);
|
|
9122
9351
|
if (!config2?.endpoint) {
|
|
9123
|
-
throw new
|
|
9124
|
-
code:
|
|
9352
|
+
throw new CliError23({
|
|
9353
|
+
code: CliErrorCode22.ENV_NOT_FOUND,
|
|
9125
9354
|
message: `\u5F53\u524D\u73AF\u5883 '${name}' \u6CA1\u6709 endpoint\u3002\u5148\u6267\u884C\uFF1A${loginHint}`
|
|
9126
9355
|
});
|
|
9127
9356
|
}
|
|
9128
9357
|
const identities = await listIdentities5(name).catch(() => []);
|
|
9129
9358
|
if (identities.length === 0) {
|
|
9130
|
-
throw new
|
|
9131
|
-
code:
|
|
9359
|
+
throw new CliError23({
|
|
9360
|
+
code: CliErrorCode22.IDENTITY_NOT_FOUND,
|
|
9132
9361
|
message: `\u73AF\u5883 '${name}'\uFF08${config2.endpoint}\uFF09\u8FD8\u6CA1\u6709\u767B\u5F55\u8EAB\u4EFD\u3002\u5148\u6267\u884C\uFF1Ahcm login ${config2.endpoint} --code <\u914D\u5BF9\u7801>`
|
|
9133
9362
|
});
|
|
9134
9363
|
}
|
|
@@ -9137,21 +9366,21 @@ async function resolveLoggedInEnv() {
|
|
|
9137
9366
|
}
|
|
9138
9367
|
async function scaffoldChironProject(root, env2, envName) {
|
|
9139
9368
|
const result = { created: [], updated: [], preserved: [] };
|
|
9140
|
-
const envFile =
|
|
9369
|
+
const envFile = path9.join(root, ENV_FILE);
|
|
9141
9370
|
const existing = await fs9.readFile(envFile, "utf8").catch(() => null);
|
|
9142
9371
|
if (existing !== null) {
|
|
9143
9372
|
const recorded = parseEnvYaml(existing);
|
|
9144
9373
|
if (recorded.endpoint !== env2.endpoint) {
|
|
9145
|
-
throw new
|
|
9146
|
-
code:
|
|
9374
|
+
throw new CliError23({
|
|
9375
|
+
code: CliErrorCode22.INVALID_ARGUMENT,
|
|
9147
9376
|
message: `${ENV_FILE} \u6307\u5411 ${recorded.endpoint}\uFF0C\u800C\u4F60\u5F53\u524D\u767B\u5F55\u7684\u662F ${env2.endpoint}\uFF08env '${envName}'\uFF09\u3002
|
|
9148
9377
|
\u8981\u7528\u8FD9\u4E2A\u9879\u76EE\u7684\u73AF\u5883\uFF1Ahcm login ${recorded.endpoint} --code <\u914D\u5BF9\u7801>\uFF0C\u518D\u91CD\u8DD1 hcm chiron init
|
|
9149
9378
|
\u8981\u628A\u9879\u76EE\u6539\u5230\u4F60\u767B\u5F55\u7684\u73AF\u5883\uFF1A\u5220\u6389 ${ENV_FILE} \u540E\u91CD\u8DD1\uFF08\u8FD9\u4F1A\u5F71\u54CD\u6240\u6709\u534F\u4F5C\u8005\uFF0C\u5148\u8DDF\u8D1F\u8D23\u4EBA\u786E\u8BA4\uFF09`
|
|
9150
9379
|
});
|
|
9151
9380
|
}
|
|
9152
9381
|
if (recorded.tenant !== env2.tenant) {
|
|
9153
|
-
throw new
|
|
9154
|
-
code:
|
|
9382
|
+
throw new CliError23({
|
|
9383
|
+
code: CliErrorCode22.INVALID_ARGUMENT,
|
|
9155
9384
|
message: `${ENV_FILE} \u662F\u79DF\u6237 ${recorded.tenant}\uFF0C\u800C\u4F60\u767B\u5F55\u7684\u8EAB\u4EFD\u5C5E\u4E8E\u79DF\u6237 ${env2.tenant}\u3002
|
|
9156
9385
|
\u7528\u9879\u76EE\u79DF\u6237\u7684\u914D\u5BF9\u7801\u91CD\u65B0\u767B\u5F55\uFF1Ahcm login ${env2.endpoint} --code <\u914D\u5BF9\u7801>\uFF0C\u518D\u91CD\u8DD1 hcm chiron init`
|
|
9157
9386
|
});
|
|
@@ -9162,23 +9391,23 @@ async function scaffoldChironProject(root, env2, envName) {
|
|
|
9162
9391
|
result.created.push(ENV_FILE);
|
|
9163
9392
|
}
|
|
9164
9393
|
for (const directory of CHIRON_PROJECT_DIRECTORIES) {
|
|
9165
|
-
const absolute =
|
|
9394
|
+
const absolute = path9.join(root, directory);
|
|
9166
9395
|
await ensureDirectory(absolute);
|
|
9167
|
-
await writeIfAbsent(
|
|
9396
|
+
await writeIfAbsent(path9.join(absolute, ".gitkeep"), "", result, `${directory}/.gitkeep`);
|
|
9168
9397
|
}
|
|
9169
|
-
const pageAcceptanceFile =
|
|
9398
|
+
const pageAcceptanceFile = path9.join(root, "page-acceptance.sh");
|
|
9170
9399
|
const created = await writeIfAbsent(pageAcceptanceFile, renderPageAcceptanceSh("evidence"), result, "page-acceptance.sh", 493);
|
|
9171
9400
|
if (created) await fs9.chmod(pageAcceptanceFile, 493);
|
|
9172
|
-
await mergeManagedFile(
|
|
9173
|
-
await mergeManagedFile(
|
|
9401
|
+
await mergeManagedFile(path9.join(root, "AGENTS.md"), mergeChironAgentInstructions, result, "AGENTS.md");
|
|
9402
|
+
await mergeManagedFile(path9.join(root, "CLAUDE.md"), mergeChironAgentInstructions, result, "CLAUDE.md");
|
|
9174
9403
|
return result;
|
|
9175
9404
|
}
|
|
9176
9405
|
async function runChironInit(args, deps = defaultChironInitDeps) {
|
|
9177
|
-
const root =
|
|
9406
|
+
const root = path9.resolve(args.project ?? ".");
|
|
9178
9407
|
const { name, env: env2, identity: identity2 } = await resolveLoggedInEnv();
|
|
9179
9408
|
if (isTempEnv3(name)) {
|
|
9180
|
-
throw new
|
|
9181
|
-
code:
|
|
9409
|
+
throw new CliError23({
|
|
9410
|
+
code: CliErrorCode22.INVALID_ARGUMENT,
|
|
9182
9411
|
message: `\u5F53\u524D\u662F\u4E34\u65F6\u73AF\u5883\uFF08${env2.endpoint}\uFF09\uFF0C\u8FD8\u6CA1\u6709\u540D\u5B57\u3002\u9879\u76EE\u8981\u7ED1\u4E00\u4E2A\u7A33\u5B9A\u7684 env\uFF0C\u5426\u5219\u4E0B\u4E00\u6B21 hcm login --code \u8986\u76D6\u5B83\u4E4B\u540E\uFF0C\u9879\u76EE\u4ED3\u8BB0\u7684\u73AF\u5883\u5C31\u5BF9\u4E0D\u4E0A\u4E86\u3002`,
|
|
9183
9412
|
context: { nextStep: `\u5148\u7ED9\u5B83\u8D77\u4E2A\u540D\u5B57\uFF1Ahcm env save <name>\uFF0C\u7136\u540E\u91CD\u8DD1 hcm chiron init` }
|
|
9184
9413
|
});
|
|
@@ -9199,13 +9428,6 @@ async function runChironInit(args, deps = defaultChironInitDeps) {
|
|
|
9199
9428
|
await deps.installSkills(root, name);
|
|
9200
9429
|
skills2 = "installed";
|
|
9201
9430
|
}
|
|
9202
|
-
let cases = { ok: false, step: "skipped" };
|
|
9203
|
-
if (!args.skipCases) {
|
|
9204
|
-
say("\u63A5\u6848\u4F8B\u5E93\uFF08chiron-cases MCP\uFF09\u2026");
|
|
9205
|
-
cases = await deps.caseLibrary();
|
|
9206
|
-
if (cases.ok) say(`\u6848\u4F8B\u5E93\u5DF2\u63A5\u5165 Codex\uFF1A${cases.repo}`);
|
|
9207
|
-
else say(`\u6848\u4F8B\u5E93\u672A\u63A5\u5165\uFF08\u4E0D\u5F71\u54CD\u5F00\u5DE5\uFF0C\u7528\u5230\u65F6\u4F1A\u63D0\u793A\u6743\u9650\u4E0D\u8DB3\uFF09\uFF1A${cases.reason ?? cases.step}`);
|
|
9208
|
-
}
|
|
9209
9431
|
return {
|
|
9210
9432
|
project: root,
|
|
9211
9433
|
env: name,
|
|
@@ -9215,7 +9437,6 @@ async function runChironInit(args, deps = defaultChironInitDeps) {
|
|
|
9215
9437
|
identity: identity2,
|
|
9216
9438
|
scaffold,
|
|
9217
9439
|
skills: skills2,
|
|
9218
|
-
cases,
|
|
9219
9440
|
nextStep: "hcm chiron doctor \u6838\u5BF9\u4E00\u904D\uFF0C\u7136\u540E\u5728\u8FD9\u4E2A\u76EE\u5F55\u91CC\u542F\u52A8 codex"
|
|
9220
9441
|
};
|
|
9221
9442
|
}
|
|
@@ -9224,14 +9445,13 @@ async function chironInitCommand(args, deps) {
|
|
|
9224
9445
|
const result = await runChironInit(args, deps);
|
|
9225
9446
|
const fmt = args.output ?? "table";
|
|
9226
9447
|
if (fmt === "json" || fmt === "yaml") {
|
|
9227
|
-
process.stdout.write(
|
|
9448
|
+
process.stdout.write(formatObject22(result, { format: fmt }) + "\n");
|
|
9228
9449
|
} else {
|
|
9229
9450
|
process.stdout.write(
|
|
9230
9451
|
[
|
|
9231
9452
|
`\u2705 \u9879\u76EE\u5DF2\u521D\u59CB\u5316\uFF1A${result.project}`,
|
|
9232
9453
|
` \u73AF\u5883 ${result.env} \xB7 ${result.endpoint} \xB7 \u79DF\u6237 ${result.tenant} \xB7 \u8EAB\u4EFD ${result.identity}`,
|
|
9233
9454
|
` \u6280\u80FD ${result.skills === "installed" ? `\u5DF2\u88C5\u5230 ${SKILLS_DIR}/` : "\u672A\u88C5\uFF08--skip-skills\uFF09"}`,
|
|
9234
|
-
` \u6848\u4F8B\u5E93 ${result.cases.ok ? "\u5DF2\u63A5\u5165 Codex" : `\u672A\u63A5\u5165\uFF1A${"reason" in result.cases && result.cases.reason ? result.cases.reason : result.cases.step}`}`,
|
|
9235
9455
|
` \u4E0B\u4E00\u6B65\uFF1A${result.nextStep}`
|
|
9236
9456
|
].join("\n") + "\n"
|
|
9237
9457
|
);
|
|
@@ -9243,10 +9463,10 @@ async function chironInitCommand(args, deps) {
|
|
|
9243
9463
|
}
|
|
9244
9464
|
|
|
9245
9465
|
// src/commands/gap.ts
|
|
9246
|
-
import { readFileSync as
|
|
9466
|
+
import { readFileSync as readFileSync6 } from "fs";
|
|
9247
9467
|
import {
|
|
9248
9468
|
createHttpClient as createHttpClient4,
|
|
9249
|
-
formatObject as
|
|
9469
|
+
formatObject as formatObject23,
|
|
9250
9470
|
loadEnv as loadEnv11,
|
|
9251
9471
|
loadGlobalConfig as loadGlobalConfig11,
|
|
9252
9472
|
resolveActiveEnv as resolveActiveEnv5
|
|
@@ -9255,7 +9475,7 @@ init_exit();
|
|
|
9255
9475
|
import { createJiraClient } from "@hcmai/sdk";
|
|
9256
9476
|
|
|
9257
9477
|
// src/jira/gaps.ts
|
|
9258
|
-
import { CASES_REPO_SLUG, repoIssueUrl } from "@hcmai/sdk";
|
|
9478
|
+
import { CASES_REPO_SLUG as CASES_REPO_SLUG2, repoIssueUrl } from "@hcmai/sdk";
|
|
9259
9479
|
import { linkedRepoRefs, parseRef } from "@hcmai/sdk";
|
|
9260
9480
|
var MIN_LEN = [
|
|
9261
9481
|
["title", 8],
|
|
@@ -9481,7 +9701,7 @@ async function gapSearch({ client: client3 }, keywords, { includeClosed = true }
|
|
|
9481
9701
|
const seen = /* @__PURE__ */ new Set();
|
|
9482
9702
|
return { rows: rows.filter((r) => seen.has(r.id) ? false : (seen.add(r.id), true)), jiraError };
|
|
9483
9703
|
}
|
|
9484
|
-
async function gapStatus({ client: client3 }, ref, casesSlug =
|
|
9704
|
+
async function gapStatus({ client: client3 }, ref, casesSlug = CASES_REPO_SLUG2) {
|
|
9485
9705
|
const parsed = parseRef(ref, client3.project, casesSlug);
|
|
9486
9706
|
if (!parsed) throw new Error(`\u770B\u4E0D\u61C2 ${ref}\uFF1A\u7ED9 Jira \u5355\u53F7\uFF08HCMNX-12\uFF09`);
|
|
9487
9707
|
if (parsed.kind === "repo") {
|
|
@@ -9519,11 +9739,11 @@ var defaultDeps = { client: () => createJiraClient() };
|
|
|
9519
9739
|
async function gapDeps(deps) {
|
|
9520
9740
|
return { client: await deps.client() };
|
|
9521
9741
|
}
|
|
9522
|
-
function
|
|
9523
|
-
if (fmt === "json" || fmt === "yaml") process.stdout.write(
|
|
9742
|
+
function emit5(fmt, data, text) {
|
|
9743
|
+
if (fmt === "json" || fmt === "yaml") process.stdout.write(formatObject23(data, { format: fmt }) + "\n");
|
|
9524
9744
|
else process.stdout.write(text() + "\n");
|
|
9525
9745
|
}
|
|
9526
|
-
async function
|
|
9746
|
+
async function run2(fn) {
|
|
9527
9747
|
try {
|
|
9528
9748
|
await fn();
|
|
9529
9749
|
} catch (e) {
|
|
@@ -9531,10 +9751,10 @@ async function run(fn) {
|
|
|
9531
9751
|
}
|
|
9532
9752
|
}
|
|
9533
9753
|
async function gapSearchCommand(keywords, args, deps = defaultDeps) {
|
|
9534
|
-
await
|
|
9754
|
+
await run2(async () => {
|
|
9535
9755
|
if (!keywords.length) throw new Error("\u7ED9\u81F3\u5C11\u4E00\u4E2A\u5173\u952E\u8BCD\uFF1A\u9519\u8BEF\u7801 / Model / Action / \u4E00\u53E5\u73B0\u8C61");
|
|
9536
9756
|
const r = await gapSearch(await gapDeps(deps), keywords, { includeClosed: args.includeClosed !== false });
|
|
9537
|
-
|
|
9757
|
+
emit5(args.output, r, () => {
|
|
9538
9758
|
const head = r.jiraError ? `\u26A0\uFE0F Jira \u6CA1\u67E5\u6210\uFF08${r.jiraError}\uFF09\uFF0C\u4E0B\u9762\u53EA\u6709\u4EA7\u54C1\u4ED3\u7684\u7ED3\u679C\uFF0C\u4E0D\u4EE3\u8868 Jira \u91CC\u6CA1\u6709\u3002
|
|
9539
9759
|
` : "";
|
|
9540
9760
|
if (!r.rows.length) return `${head}Jira \u4E0E\u4EA7\u54C1\u4ED3\u90FD\u6CA1\u6709\u76F8\u5173\u8BB0\u5F55\u3002\u53EF\u4EE5 submit\uFF0C\u4F46\u5148\u628A\u4E09\u95EE\u7B54\u5B8C\u3002`;
|
|
@@ -9545,9 +9765,9 @@ ${r.rows.map((i) => `${i.where} ${i.id} [${i.state}${i.resolution ? "\xB7" + i.r
|
|
|
9545
9765
|
});
|
|
9546
9766
|
}
|
|
9547
9767
|
async function gapStatusCommand(ref, args, deps = defaultDeps) {
|
|
9548
|
-
await
|
|
9768
|
+
await run2(async () => {
|
|
9549
9769
|
const r = await gapStatus(await gapDeps(deps), ref);
|
|
9550
|
-
|
|
9770
|
+
emit5(args.output, r, () => [...r.lines, `\u4E0B\u4E00\u6B65\uFF1A${r.nextStep}`].join("\n"));
|
|
9551
9771
|
});
|
|
9552
9772
|
}
|
|
9553
9773
|
async function fingerprintText(env2) {
|
|
@@ -9567,13 +9787,13 @@ async function fingerprintText(env2) {
|
|
|
9567
9787
|
}
|
|
9568
9788
|
}
|
|
9569
9789
|
async function gapSubmitCommand(args, deps = defaultDeps) {
|
|
9570
|
-
await
|
|
9571
|
-
const raw = args.file ?
|
|
9790
|
+
await run2(async () => {
|
|
9791
|
+
const raw = args.file ? readFileSync6(args.file, "utf8") : process.stdin.isTTY ? "" : readFileSync6(0, "utf8");
|
|
9572
9792
|
if (!raw.trim()) throw new Error("\u7F3A\u53E3\u8F7D\u8377\uFF1A--file <gap.json> \u6216\u4ECE\u6807\u51C6\u8F93\u5165\u5582 JSON");
|
|
9573
9793
|
const gap2 = validateGapInput(JSON.parse(raw));
|
|
9574
9794
|
const fp = args.fingerprint ?? await fingerprintText(args.env);
|
|
9575
9795
|
const r = await gapSubmit(await gapDeps(deps), gap2, { fingerprintText: fp, issuetypeOverride: args.issuetype, assigneeOverride: args.assignee });
|
|
9576
|
-
|
|
9796
|
+
emit5(
|
|
9577
9797
|
args.output,
|
|
9578
9798
|
r,
|
|
9579
9799
|
() => r.outcome === "appended" ? `Jira \u91CC\u5DF2\u6709\u540C\u4E00\u7F3A\u53E3 ${r.key}\u300C${r.summary}\u300D\uFF0C\u5DF2\u8FFD\u52A0\u300C\u53C8\u4E00\u4E2A\u73B0\u573A\u300D\u8BC4\u8BBA\uFF0C\u6CA1\u6709\u65B0\u5F00\u3002
|
|
@@ -9584,219 +9804,6 @@ ${r.url}
|
|
|
9584
9804
|
});
|
|
9585
9805
|
}
|
|
9586
9806
|
|
|
9587
|
-
// src/commands/chiron-case.ts
|
|
9588
|
-
init_exit();
|
|
9589
|
-
import { execFileSync } from "child_process";
|
|
9590
|
-
import { existsSync as existsSync2, readFileSync as readFileSync6, cpSync, writeFileSync as writeFileSync2, mkdirSync } from "fs";
|
|
9591
|
-
import os5 from "os";
|
|
9592
|
-
import path9 from "path";
|
|
9593
|
-
import { CASES_REPO_SLUG as CASES_REPO_SLUG2, CNB_ORIGIN, CliError as CliError23, CliErrorCode as CliErrorCode22, formatObject as formatObject23 } from "@hcmai/sdk";
|
|
9594
|
-
var casesRepoDir = () => process.env.HCM_CASES_DIR?.trim() || path9.join(os5.homedir(), "Projects", "chiron-cases");
|
|
9595
|
-
var fail7 = (message, nextStep) => new CliError23({ code: CliErrorCode22.INVALID_ARGUMENT, message, context: { nextStep } });
|
|
9596
|
-
var run2 = (cmd, args, opts = {}) => execFileSync(cmd, args, { encoding: "utf8", maxBuffer: 1 << 26, ...opts });
|
|
9597
|
-
function loadIndex(dir = casesRepoDir()) {
|
|
9598
|
-
const file = path9.join(dir, "index", "index.json");
|
|
9599
|
-
if (!existsSync2(file)) {
|
|
9600
|
-
throw fail7(
|
|
9601
|
-
`\u6848\u4F8B\u5E93\u7D22\u5F15\u4E0D\u5728\uFF1A${file}`,
|
|
9602
|
-
`\u5148 clone \u6848\u4F8B\u5E93\uFF08\`hcm chiron doctor --fix\` \u4F1A\u505A\uFF09\uFF0C\u6216\u7528 HCM_CASES_DIR \u6307\u5230\u5DF2\u6709\u7684 clone\u3002\u6CA1\u6709 cnb \u6743\u9650\u5C31\u8DF3\u8FC7\u6848\u4F8B\u5E93\u8FD9\u4E00\u683C\u3002`
|
|
9603
|
-
);
|
|
9604
|
-
}
|
|
9605
|
-
return JSON.parse(readFileSync6(file, "utf8"));
|
|
9606
|
-
}
|
|
9607
|
-
function backendFingerprint(env2) {
|
|
9608
|
-
if (!env2) return { reason: "\u6CA1\u7ED9 --env\uFF0C\u6CA1\u6CD5\u73B0\u67E5\u6307\u7EB9" };
|
|
9609
|
-
try {
|
|
9610
|
-
const raw = run2(process.execPath, [process.argv[1], "version", "--env", env2, "--output", "json"]);
|
|
9611
|
-
const j = JSON.parse(raw.slice(raw.indexOf("{")));
|
|
9612
|
-
const backend = j.backend?.commit ?? j.commit ?? j.server?.commit;
|
|
9613
|
-
if (!backend) return { reason: "\u540E\u7AEF\u56DE\u6267\u91CC\u6CA1\u6709 commit \u5B57\u6BB5" };
|
|
9614
|
-
return { backend: String(backend), cli: String(j.cli?.version ?? j.cliVersion ?? "") };
|
|
9615
|
-
} catch (e) {
|
|
9616
|
-
return { reason: String(e.message).split("\n")[0]?.slice(0, 120) };
|
|
9617
|
-
}
|
|
9618
|
-
}
|
|
9619
|
-
function matchTag(c, fp) {
|
|
9620
|
-
if (!fp.backend) return `\u672A\u6BD4\u5BF9\uFF08${fp.reason ?? "\u6CA1\u6709\u6307\u7EB9"}\uFF09`;
|
|
9621
|
-
const be = String(c.fingerprint?.backend_commit ?? "");
|
|
9622
|
-
if (!be) return "\u6848\u4F8B\u6CA1\u8BB0\u540E\u7AEF\u6307\u7EB9";
|
|
9623
|
-
const a = be.slice(0, 12);
|
|
9624
|
-
const b = fp.backend.slice(0, 12);
|
|
9625
|
-
return a === b ? "\u5339\u914D" : `\u4E0D\u5339\u914D\uFF08\u6848\u4F8B ${a} / \u5F53\u524D ${b}\uFF09`;
|
|
9626
|
-
}
|
|
9627
|
-
function emit5(args, data, text) {
|
|
9628
|
-
if (args.output === "json" || args.output === "yaml") {
|
|
9629
|
-
process.stdout.write(formatObject23(data, { format: args.output }) + "\n");
|
|
9630
|
-
} else {
|
|
9631
|
-
process.stdout.write(text() + "\n");
|
|
9632
|
-
}
|
|
9633
|
-
}
|
|
9634
|
-
async function guard(fn) {
|
|
9635
|
-
try {
|
|
9636
|
-
await fn();
|
|
9637
|
-
} catch (e) {
|
|
9638
|
-
exitWithError(e);
|
|
9639
|
-
}
|
|
9640
|
-
}
|
|
9641
|
-
async function caseSearchCommand(query, args) {
|
|
9642
|
-
await guard(async () => {
|
|
9643
|
-
const idx = loadIndex();
|
|
9644
|
-
const fp = backendFingerprint(args.env);
|
|
9645
|
-
let raw;
|
|
9646
|
-
try {
|
|
9647
|
-
raw = run2("cnb", [
|
|
9648
|
-
"knowledge-base",
|
|
9649
|
-
"query-knowledge-base-get",
|
|
9650
|
-
"--repo",
|
|
9651
|
-
CASES_REPO_SLUG2,
|
|
9652
|
-
"--query",
|
|
9653
|
-
query,
|
|
9654
|
-
"--top-k",
|
|
9655
|
-
String(args.topK ?? 5),
|
|
9656
|
-
"--verbose"
|
|
9657
|
-
]);
|
|
9658
|
-
} catch (e) {
|
|
9659
|
-
throw fail7(
|
|
9660
|
-
`\u6848\u4F8B\u5E93\u68C0\u7D22\u6CA1\u8DD1\u6210\uFF1A${String(e.message).split("\n")[0]}`,
|
|
9661
|
-
"\u68C0\u7D22\u8D70 cnb \u7684\u77E5\u8BC6\u5E93\u63A5\u53E3\uFF0C\u9700\u8981 cnb \u5DF2\u767B\u5F55\u4E14\u6709\u6848\u4F8B\u5E93\u6743\u9650\u3002\u6CA1\u6709\u5C31\u5148\u8DF3\u8FC7\u6848\u4F8B\u5E93\uFF0C\u76F4\u63A5\u6309\u6280\u80FD\u505A\uFF1B\u522B\u628A\u300C\u67E5\u4E0D\u5230\u300D\u5F53\u6210\u300C\u6CA1\u6709\u5148\u4F8B\u300D\u3002"
|
|
9662
|
-
);
|
|
9663
|
-
}
|
|
9664
|
-
const json = JSON.parse(raw.slice(raw.indexOf("{")));
|
|
9665
|
-
const seen = /* @__PURE__ */ new Map();
|
|
9666
|
-
for (const h of json.data ?? []) {
|
|
9667
|
-
const p = h.metadata?.path ?? "";
|
|
9668
|
-
const m = /^cases\/[^/]+\/([^/]+)\//.exec(p);
|
|
9669
|
-
if (!m) continue;
|
|
9670
|
-
const id = m[1];
|
|
9671
|
-
if (seen.has(id)) continue;
|
|
9672
|
-
const c = idx.cases.find((x) => x.id === id);
|
|
9673
|
-
seen.set(id, {
|
|
9674
|
-
id,
|
|
9675
|
-
score: h.score,
|
|
9676
|
-
file: p.split("/").pop(),
|
|
9677
|
-
status: c?.status,
|
|
9678
|
-
tier: c?.tier,
|
|
9679
|
-
skills: c?.skills,
|
|
9680
|
-
customer_ask: c?.customer_ask,
|
|
9681
|
-
match: c ? matchTag(c, fp) : "\u7D22\u5F15\u91CC\u6CA1\u6709\uFF08\u672C\u673A clone \u53EF\u80FD\u65E7\u4E86\uFF0Cgit pull \u4E00\u6B21\uFF09"
|
|
9682
|
-
});
|
|
9683
|
-
}
|
|
9684
|
-
const rows = [...seen.values()];
|
|
9685
|
-
emit5(
|
|
9686
|
-
args,
|
|
9687
|
-
{ query, rows },
|
|
9688
|
-
() => rows.length ? rows.map((r) => `${r.id} [${r.status ?? "?"}\xB7${r.match}] ${r.customer_ask ?? ""}
|
|
9689
|
-
\u6280\u80FD\uFF1A${(r.skills ?? []).join(" / ") || "\uFF08\u672A\u767B\u8BB0\uFF09"}`).join("\n") : `\u6CA1\u6709\u547D\u4E2D\u300C${query}\u300D\u7684\u6848\u4F8B\u3002\u5148\u6309\u6280\u80FD\u505A\uFF0C\u8DD1\u901A\u4E86\u7528 \`hcm chiron case submit\` \u4E0A\u884C\u4E00\u6761\u3002`
|
|
9690
|
-
);
|
|
9691
|
-
});
|
|
9692
|
-
}
|
|
9693
|
-
async function caseShowCommand(id, args) {
|
|
9694
|
-
await guard(async () => {
|
|
9695
|
-
const idx = loadIndex();
|
|
9696
|
-
const c = idx.cases.find((x) => x.id === id);
|
|
9697
|
-
if (!c?.path) {
|
|
9698
|
-
throw fail7(
|
|
9699
|
-
`\u7D22\u5F15\u91CC\u6CA1\u6709\u6848\u4F8B ${id}`,
|
|
9700
|
-
`\u5148 \`hcm chiron case search <\u5173\u952E\u8BCD>\` \u62FF\u51C6\u786E\u7684 id\uFF1B\u672C\u673A clone \u65E7\u4E86\u5C31\u5728 ${casesRepoDir()} \u91CC git pull \u4E00\u6B21\u3002`
|
|
9701
|
-
);
|
|
9702
|
-
}
|
|
9703
|
-
const dir = path9.join(casesRepoDir(), c.path);
|
|
9704
|
-
const files = args.file ? [args.file] : ["\u95EE\u9898.md", "\u65B9\u6848.md"];
|
|
9705
|
-
const parts = files.map((f) => {
|
|
9706
|
-
const p = path9.join(dir, f);
|
|
9707
|
-
return existsSync2(p) ? `# ${f}
|
|
9708
|
-
|
|
9709
|
-
${readFileSync6(p, "utf8")}` : `# ${f}
|
|
9710
|
-
|
|
9711
|
-
\uFF08\u8FD9\u4E2A\u6848\u4F8B\u6CA1\u6709\u8FD9\u4EFD\u6587\u4EF6\uFF09`;
|
|
9712
|
-
});
|
|
9713
|
-
const meta2 = readFileSync6(path9.join(dir, "case.yml"), "utf8");
|
|
9714
|
-
emit5(args, { id, caseYml: meta2, files: parts }, () => `case.yml:
|
|
9715
|
-
${meta2}
|
|
9716
|
-
|
|
9717
|
-
${parts.join("\n\n---\n\n")}`);
|
|
9718
|
-
});
|
|
9719
|
-
}
|
|
9720
|
-
async function caseMatchCommand(args) {
|
|
9721
|
-
await guard(async () => {
|
|
9722
|
-
const idx = loadIndex();
|
|
9723
|
-
const fp = backendFingerprint(args.env);
|
|
9724
|
-
const rows = idx.cases.filter((c) => c.status === "approved").map((c) => ({ id: c.id, match: matchTag(c, fp), skills: c.skills, customer_ask: c.customer_ask }));
|
|
9725
|
-
emit5(args, { fingerprint: fp, rows }, () => {
|
|
9726
|
-
const head = fp.backend ? `\u5F53\u524D\u540E\u7AEF ${fp.backend.slice(0, 12)}\uFF08env ${args.env}\uFF09` : `\u26A0\uFE0F \u6CA1\u53D6\u5230\u5F53\u524D\u6307\u7EB9\uFF08${fp.reason}\uFF09\u2014\u2014\u4E0B\u9762\u6BCF\u4E00\u6761\u90FD\u6807\u7740\u300C\u672A\u6BD4\u5BF9\u300D\uFF0C\u522B\u628A\u5B83\u8BFB\u6210\u300C\u90FD\u80FD\u7167\u505A\u300D`;
|
|
9727
|
-
return [head, ...rows.map((r) => `${r.match === "\u5339\u914D" ? "\u2705" : "\xB7 "} ${r.id} [${r.match}] ${r.customer_ask ?? ""}`)].join("\n");
|
|
9728
|
-
});
|
|
9729
|
-
});
|
|
9730
|
-
}
|
|
9731
|
-
async function caseSubmitCommand(dir, args) {
|
|
9732
|
-
await guard(async () => {
|
|
9733
|
-
const repo = casesRepoDir();
|
|
9734
|
-
const src = path9.resolve(dir);
|
|
9735
|
-
if (!existsSync2(path9.join(src, "case.yml"))) {
|
|
9736
|
-
throw fail7(`${src} \u91CC\u6CA1\u6709 case.yml`, "\u6307\u5230\u9879\u76EE\u4ED3\u7684\u6848\u4F8B\u76EE\u5F55\uFF08\u5982 cases/CASE-20260902-xxx\uFF09\uFF0C\u90A3\u91CC\u5E94\u5F53\u6709 case.yml\u3002");
|
|
9737
|
-
}
|
|
9738
|
-
loadIndex(repo);
|
|
9739
|
-
const yamlText = readFileSync6(path9.join(src, "case.yml"), "utf8");
|
|
9740
|
-
const id = /^\s*(?:id|case_id):\s*(\S+)/m.exec(yamlText)?.[1];
|
|
9741
|
-
if (!id) throw fail7("case.yml \u91CC\u6CA1\u6709 id", "case.yml \u9876\u5C42\u8981\u6709 `id: CASE-YYYYMMDD-xxx`\u3002");
|
|
9742
|
-
run2("git", ["-C", repo, "checkout", "-q", "main"]);
|
|
9743
|
-
run2("git", ["-C", repo, "pull", "-q", "--ff-only", "origin", "main"]);
|
|
9744
|
-
const branch = `case/${id}-submit`;
|
|
9745
|
-
run2("git", ["-C", repo, "checkout", "-q", "-B", branch]);
|
|
9746
|
-
const dst = path9.join(repo, "cases", args.category, id);
|
|
9747
|
-
cpSync(src, dst, { recursive: true, filter: (p) => !p.includes("node_modules") });
|
|
9748
|
-
mkdirSync(path9.join(dst, "evidence"), { recursive: true });
|
|
9749
|
-
let doc = readFileSync6(path9.join(dst, "case.yml"), "utf8");
|
|
9750
|
-
doc = /^\s*tier:/m.test(doc) ? doc.replace(/^\s*tier:.*$/m, "tier: public") : `tier: public
|
|
9751
|
-
${doc}`;
|
|
9752
|
-
doc = /^\s*category:/m.test(doc) ? doc.replace(/^\s*category:.*$/m, `category: ${args.category}`) : `category: ${args.category}
|
|
9753
|
-
${doc}`;
|
|
9754
|
-
doc = /^\s*origin:/m.test(doc) ? doc.replace(/^\s*origin:.*$/m, `origin: ${args.origin}`) : `origin: ${args.origin}
|
|
9755
|
-
${doc}`;
|
|
9756
|
-
if (!/^\s*status:/m.test(doc)) doc = `status: approved
|
|
9757
|
-
${doc}`;
|
|
9758
|
-
writeFileSync2(path9.join(dst, "case.yml"), doc);
|
|
9759
|
-
run2("python3", ["scripts/render-readme.py", dst], { cwd: repo });
|
|
9760
|
-
let lint;
|
|
9761
|
-
try {
|
|
9762
|
-
lint = run2("python3", ["scripts/lint-case.py"], { cwd: repo });
|
|
9763
|
-
} catch (e) {
|
|
9764
|
-
throw fail7(
|
|
9765
|
-
`\u6848\u4F8B lint \u6CA1\u8FC7\uFF0CPR \u6CA1\u5F00\uFF1A
|
|
9766
|
-
${e.stdout ?? e.message}`,
|
|
9767
|
-
"\u7167 lint \u7684\u63D0\u793A\u8865\u9F50 case.yml \u4E0E\u6B63\u6587\uFF0C\u518D\u8DD1\u4E00\u6B21\u3002\u6848\u4F8B\u8FD8\u5728\u9879\u76EE\u4ED3\u91CC\uFF0C\u6CA1\u4E22\u3002"
|
|
9768
|
-
);
|
|
9769
|
-
}
|
|
9770
|
-
run2("python3", ["scripts/build-index.py"], { cwd: repo });
|
|
9771
|
-
run2("git", ["-C", repo, "add", "-A"]);
|
|
9772
|
-
run2("git", ["-C", repo, "-c", "user.name=hcm-cli", "-c", "user.email=chiron@local", "commit", "-q", "-m", `case: ${id}\uFF08\u9879\u76EE\u6848\u4F8B\u4E0A\u884C\uFF09`]);
|
|
9773
|
-
run2("git", ["-C", repo, "push", "-q", "-f", "-u", "origin", branch]);
|
|
9774
|
-
const pr = run2("cnb", [
|
|
9775
|
-
"pulls",
|
|
9776
|
-
"post-pull",
|
|
9777
|
-
"--repo",
|
|
9778
|
-
CASES_REPO_SLUG2,
|
|
9779
|
-
"--base",
|
|
9780
|
-
"main",
|
|
9781
|
-
"--head",
|
|
9782
|
-
branch,
|
|
9783
|
-
"--title",
|
|
9784
|
-
`case: ${id}\uFF08\u9879\u76EE\u6848\u4F8B\u4E0A\u884C\uFF09`,
|
|
9785
|
-
"--body",
|
|
9786
|
-
`\u6765\u6E90\uFF1A${args.origin}
|
|
9787
|
-
|
|
9788
|
-
\u7531 \`hcm chiron case submit\` \u63D0\u4EA4\uFF0Clint \u5DF2\u8FC7\u3002`
|
|
9789
|
-
]);
|
|
9790
|
-
const num = /number: "?(\d+)/.exec(pr)?.[1];
|
|
9791
|
-
emit5(
|
|
9792
|
-
args,
|
|
9793
|
-
{ id, pr: num, lint: lint.trim() },
|
|
9794
|
-
() => `\u5DF2\u5F00 PR #${num ?? "?"}\uFF1A${CNB_ORIGIN}/${CASES_REPO_SLUG2}/-/pulls/${num ?? ""}
|
|
9795
|
-
${lint.trim()}`
|
|
9796
|
-
);
|
|
9797
|
-
});
|
|
9798
|
-
}
|
|
9799
|
-
|
|
9800
9807
|
// src/commands/chiron-doctor.ts
|
|
9801
9808
|
init_auth_guard();
|
|
9802
9809
|
init_exit();
|
|
@@ -9819,9 +9826,6 @@ var defaultDeps2 = {
|
|
|
9819
9826
|
return { report: await runDoctor(probe, identity2), tokenTenant: identity2?.tenantId ? String(identity2.tenantId) : void 0 };
|
|
9820
9827
|
},
|
|
9821
9828
|
fixSkills: (root, envName) => defaultChironInitDeps.installSkills(root, envName),
|
|
9822
|
-
fixCases: async () => {
|
|
9823
|
-
await ensureCaseLibrary();
|
|
9824
|
-
},
|
|
9825
9829
|
inspectCases: () => inspectCaseLibrary(),
|
|
9826
9830
|
inspectJira: () => inspectJira()
|
|
9827
9831
|
};
|
|
@@ -9895,18 +9899,15 @@ async function runChironDoctor(args, deps = defaultDeps2) {
|
|
|
9895
9899
|
skills2 = await skillsLine();
|
|
9896
9900
|
}
|
|
9897
9901
|
report.lines.push(skills2);
|
|
9898
|
-
const
|
|
9899
|
-
|
|
9900
|
-
|
|
9901
|
-
|
|
9902
|
-
|
|
9903
|
-
|
|
9904
|
-
|
|
9905
|
-
|
|
9906
|
-
|
|
9907
|
-
cases = await casesLine();
|
|
9908
|
-
}
|
|
9909
|
-
report.lines.push(cases);
|
|
9902
|
+
const cases = await deps.inspectCases();
|
|
9903
|
+
report.lines.push(
|
|
9904
|
+
cases.ok ? { item: "\u6848\u4F8B\u5E93", verdict: "ok", detail: `\u8BFB\u5F97\u5230\uFF08${cases.count} \u4E2A\u516C\u5171\u6848\u4F8B\uFF09` } : {
|
|
9905
|
+
item: "\u6848\u4F8B\u5E93",
|
|
9906
|
+
verdict: "warn",
|
|
9907
|
+
detail: cases.reason ?? "\u8BFB\u4E0D\u5230",
|
|
9908
|
+
nextStep: "\u6848\u4F8B\u5E93\u8BFB\u53D6\u8D70 cnb\uFF1A\u5148 `cnb login`\uFF0C\u5E76\u8BA9\u8D1F\u8D23\u4EBA\u628A\u4F60\u52A0\u8FDB\u6848\u4F8B\u4ED3\u3002\u6CA1\u6709\u6743\u9650\u4E5F\u80FD\u4EA4\u4ED8\uFF0C\u53EA\u662F\u67E5\u4E0D\u5230\u5148\u4F8B\u3002"
|
|
9909
|
+
}
|
|
9910
|
+
);
|
|
9910
9911
|
const jira = await deps.inspectJira();
|
|
9911
9912
|
report.lines.push(
|
|
9912
9913
|
jira.ok ? { item: "Jira", verdict: "ok", detail: `${jira.who || "\u5DF2\u8FDE\u63A5"} \xB7 \u770B\u5F97\u5230 ${JIRA_PROJECT2}\uFF08\u4EE4\u724C\u6765\u81EA ${jira.from}\uFF09` } : { item: "Jira", verdict: "warn", detail: jira.reason ?? "\u4E0D\u53EF\u7528", nextStep: "\u73B0\u5728\u4E0D\u914D\u4E5F\u80FD\u4EA4\u4ED8\uFF1B\u649E\u5230\u300C\u4EA7\u54C1\u505A\u4E0D\u5230\u300D\u8981\u63D0\u5355\u65F6\u5FC5\u987B\u5148\u914D\u597D" }
|
|
@@ -9942,7 +9943,7 @@ async function chironDoctorCommand(args, deps) {
|
|
|
9942
9943
|
|
|
9943
9944
|
// src/commands/chiron-test.ts
|
|
9944
9945
|
init_exit();
|
|
9945
|
-
import { spawnSync
|
|
9946
|
+
import { spawnSync } from "child_process";
|
|
9946
9947
|
import { promises as fs11 } from "fs";
|
|
9947
9948
|
import path11 from "path";
|
|
9948
9949
|
import yaml from "js-yaml";
|
|
@@ -10741,11 +10742,11 @@ function matches(actual, rule) {
|
|
|
10741
10742
|
var defaultDeps3 = {
|
|
10742
10743
|
assess: (argv) => assessEffectiveDeliveryCommand(argv),
|
|
10743
10744
|
hcm: (argv, cwd) => {
|
|
10744
|
-
const r =
|
|
10745
|
+
const r = spawnSync("hcm", argv, { cwd, encoding: "utf8", maxBuffer: 1 << 26, timeout: 6e5 });
|
|
10745
10746
|
return { status: r.status, stdout: r.stdout ?? "", stderr: r.stderr ?? "" };
|
|
10746
10747
|
},
|
|
10747
10748
|
pageAcceptance: (root, argv) => {
|
|
10748
|
-
const r =
|
|
10749
|
+
const r = spawnSync("./page-acceptance.sh", argv, { cwd: root, encoding: "utf8", maxBuffer: 1 << 24, timeout: 3e5 });
|
|
10749
10750
|
return { status: r.status, stdout: r.stdout ?? "", stderr: r.stderr ?? "" };
|
|
10750
10751
|
},
|
|
10751
10752
|
readXlsx: (file) => xlsxRows(file),
|
|
@@ -11964,7 +11965,7 @@ chiron.command("triage").description(
|
|
|
11964
11965
|
).option(
|
|
11965
11966
|
"--recon <dir>",
|
|
11966
11967
|
"\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"
|
|
11967
|
-
).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));
|
|
11968
|
+
).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").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").action((opts) => deliveryTriageCommand(opts));
|
|
11968
11969
|
program.command("query <Model>").description("\u67E5\u8BE2 Model \u5217\u8868\u6570\u636E\uFF08\u901A\u8FC7 ModelQueryDsl JSON \u8868\u8FBE\u8FC7\u6EE4/\u6392\u5E8F/\u5173\u8054/\u5206\u9875\uFF09").option(
|
|
11969
11970
|
"--filter <JSON>",
|
|
11970
11971
|
`\u8FC7\u6EE4 AST\uFF08ModelQueryDsl\uFF09\uFF1A\u53F6\u5B50 '{"field":"status","op":"eq","value":"ACTIVE"}'\uFF0C\u591A\u6761\u4EF6\u7528 '{"and":[\u53F6\u5B50,\u2026]}'\u3002\u26A0\uFE0F \u4E0D\u63A5\u53D7 {"\u5B57\u6BB5":"\u503C"} \u7B80\u5199\uFF0Cschema \u5C42\u4F1A\u62D2`
|