@hcmai/cli 0.7.0 → 0.8.0
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 +1461 -2131
- package/dist/index.js.map +1 -1
- package/dist/skills/manifest.json +29 -107
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -532,8 +532,8 @@ var init_TerminalRenderer = __esm({
|
|
|
532
532
|
}
|
|
533
533
|
}
|
|
534
534
|
/** 来源行(仅子代理触发,agentPath ≥2 段时显示 `↑ 来自 a › b`,对齐 Web)。 */
|
|
535
|
-
originLine(
|
|
536
|
-
const segs =
|
|
535
|
+
originLine(path14) {
|
|
536
|
+
const segs = path14.split(".").filter(Boolean);
|
|
537
537
|
if (segs.length < 2) return "";
|
|
538
538
|
const names = segs.map((k) => agentDisplayName(k));
|
|
539
539
|
return chalk.gray(` \u2191 \u6765\u81EA ${names.join(" \u203A ")}`) + "\n";
|
|
@@ -1715,8 +1715,8 @@ function agentLabel(agentId) {
|
|
|
1715
1715
|
if (/^[0-9a-f]{8}-[0-9a-f-]{27}$/i.test(agentId)) return `agent \u2026${agentId.slice(-4)}`;
|
|
1716
1716
|
return agentDisplayName(agentId);
|
|
1717
1717
|
}
|
|
1718
|
-
function originLine(
|
|
1719
|
-
const segs = (
|
|
1718
|
+
function originLine(path14) {
|
|
1719
|
+
const segs = (path14 ?? "").split(".").filter(Boolean);
|
|
1720
1720
|
if (segs.length < 2) return null;
|
|
1721
1721
|
return `\u6765\u81EA ${segs.map((k) => agentDisplayName(k)).join(" \u203A ")}`;
|
|
1722
1722
|
}
|
|
@@ -2100,21 +2100,21 @@ async function loginPasswordWithFirstLoginChange(input, args) {
|
|
|
2100
2100
|
return loginPassword({ ...input, password: next });
|
|
2101
2101
|
}
|
|
2102
2102
|
}
|
|
2103
|
-
function inferIdentityName(scheme,
|
|
2104
|
-
if (scheme === "password" && extra.username) return `${extra.username}@${
|
|
2103
|
+
function inferIdentityName(scheme, env2, extra) {
|
|
2104
|
+
if (scheme === "password" && extra.username) return `${extra.username}@${env2}`;
|
|
2105
2105
|
if (scheme === "client_credentials" && extra.clientId) {
|
|
2106
|
-
return `${extra.clientId.slice(0, 6)}@${
|
|
2106
|
+
return `${extra.clientId.slice(0, 6)}@${env2}`;
|
|
2107
2107
|
}
|
|
2108
|
-
if (scheme === "pairing" && extra.username) return `${extra.username}@${
|
|
2108
|
+
if (scheme === "pairing" && extra.username) return `${extra.username}@${env2}`;
|
|
2109
2109
|
if (scheme === "pat") {
|
|
2110
|
-
const name = `pat-${Math.random().toString(36).slice(2, 6)}@${
|
|
2110
|
+
const name = `pat-${Math.random().toString(36).slice(2, 6)}@${env2}`;
|
|
2111
2111
|
process.stderr.write(
|
|
2112
2112
|
`[hcm] event=pat_identity_auto_named name=${name} hint="pass --name <id> for a stable identity name across re-logins"
|
|
2113
2113
|
`
|
|
2114
2114
|
);
|
|
2115
2115
|
return name;
|
|
2116
2116
|
}
|
|
2117
|
-
return `default@${
|
|
2117
|
+
return `default@${env2}`;
|
|
2118
2118
|
}
|
|
2119
2119
|
async function migrateProfileTokenToIdentity(envName, identityName) {
|
|
2120
2120
|
const oldStore = new TokenStore(envName);
|
|
@@ -3120,10 +3120,8 @@ async function emitArtifact(result, target, opts, fmt) {
|
|
|
3120
3120
|
}
|
|
3121
3121
|
function printActionResult(result, fmt) {
|
|
3122
3122
|
if (fmt !== "json" && result.taskId) {
|
|
3123
|
-
process.stdout.write(
|
|
3124
|
-
|
|
3125
|
-
`
|
|
3126
|
-
);
|
|
3123
|
+
process.stdout.write(`\u23F3 \u5DF2\u521B\u5EFA\u5F02\u6B65\u4EFB\u52A1\uFF1A${result.taskId}\uFF08\u672C\u547D\u4EE4\u4E0D\u7B49\u5B83\u7ED3\u675F\uFF09
|
|
3124
|
+
`);
|
|
3127
3125
|
} else if (fmt !== "json") {
|
|
3128
3126
|
process.stdout.write("\u2705 action succeeded\n");
|
|
3129
3127
|
}
|
|
@@ -3348,14 +3346,14 @@ async function versionCommand(args) {
|
|
|
3348
3346
|
let endpoint = args.endpoint;
|
|
3349
3347
|
if (!endpoint) {
|
|
3350
3348
|
const g = await loadGlobalConfig5();
|
|
3351
|
-
const
|
|
3352
|
-
if (!
|
|
3349
|
+
const env2 = await loadEnv4(resolveActiveEnv2({ envFlag: args.env }, process.env, g)).catch(() => null);
|
|
3350
|
+
if (!env2?.endpoint) {
|
|
3353
3351
|
throw new CliError12({
|
|
3354
3352
|
code: CliErrorCode11.MISSING_FLAG,
|
|
3355
3353
|
message: "\u672A\u89E3\u6790\u5230 endpoint \u2014\u2014 \u4F20 --endpoint <url>\uFF0C\u6216\u5148 `hcm env add <name> --endpoint <url>`"
|
|
3356
3354
|
});
|
|
3357
3355
|
}
|
|
3358
|
-
endpoint =
|
|
3356
|
+
endpoint = env2.endpoint;
|
|
3359
3357
|
}
|
|
3360
3358
|
const http = createHttpClient({
|
|
3361
3359
|
endpoint: endpoint.replace(/\/+$/, ""),
|
|
@@ -3476,7 +3474,7 @@ function launchBrowser(url, platform = process.platform) {
|
|
|
3476
3474
|
child.unref();
|
|
3477
3475
|
}
|
|
3478
3476
|
async function runOpen(target, args, deps) {
|
|
3479
|
-
const
|
|
3477
|
+
const path14 = normalizeTarget(target);
|
|
3480
3478
|
if (!deps.frontend?.trim()) {
|
|
3481
3479
|
throw new CliError13({
|
|
3482
3480
|
code: CliErrorCode12.INVALID_ARGUMENT,
|
|
@@ -3484,13 +3482,13 @@ async function runOpen(target, args, deps) {
|
|
|
3484
3482
|
});
|
|
3485
3483
|
}
|
|
3486
3484
|
const { ticket, expiresIn } = await deps.mintTicket();
|
|
3487
|
-
const url = buildBrowserLoginUrl(deps.frontend, ticket,
|
|
3485
|
+
const url = buildBrowserLoginUrl(deps.frontend, ticket, path14);
|
|
3488
3486
|
if (args.printUrl) {
|
|
3489
3487
|
deps.write(`${url}
|
|
3490
3488
|
`);
|
|
3491
3489
|
} else {
|
|
3492
3490
|
deps.launch(url);
|
|
3493
|
-
deps.write(`\u5DF2\u7528\u5F53\u524D\u8EAB\u4EFD\u6253\u5F00 ${
|
|
3491
|
+
deps.write(`\u5DF2\u7528\u5F53\u524D\u8EAB\u4EFD\u6253\u5F00 ${path14}\uFF08\u7968\u636E ${expiresIn ?? 60}s \u5185\u6709\u6548\uFF0C\u53EA\u80FD\u7528\u4E00\u6B21\uFF09
|
|
3494
3492
|
`);
|
|
3495
3493
|
}
|
|
3496
3494
|
return { url, expiresIn };
|
|
@@ -3584,8 +3582,8 @@ import {
|
|
|
3584
3582
|
formatObject as formatObject7,
|
|
3585
3583
|
fromAxiosError as fromAxiosError9
|
|
3586
3584
|
} from "@hcmai/sdk";
|
|
3587
|
-
function collectYmlFiles(
|
|
3588
|
-
if (statSync(
|
|
3585
|
+
function collectYmlFiles(path14) {
|
|
3586
|
+
if (statSync(path14).isFile()) return [path14];
|
|
3589
3587
|
const out = [];
|
|
3590
3588
|
const walk = (dir) => {
|
|
3591
3589
|
for (const name of readdirSync(dir).sort()) {
|
|
@@ -3594,7 +3592,7 @@ function collectYmlFiles(path15) {
|
|
|
3594
3592
|
else if (full.endsWith(".yml") || full.endsWith(".yaml")) out.push(full);
|
|
3595
3593
|
}
|
|
3596
3594
|
};
|
|
3597
|
-
walk(
|
|
3595
|
+
walk(path14);
|
|
3598
3596
|
return out.sort();
|
|
3599
3597
|
}
|
|
3600
3598
|
var DRY_RUN_CLIENT = {
|
|
@@ -3602,9 +3600,9 @@ var DRY_RUN_CLIENT = {
|
|
|
3602
3600
|
create: async () => ({ id: "" }),
|
|
3603
3601
|
update: async () => ({})
|
|
3604
3602
|
};
|
|
3605
|
-
async function importCommand(
|
|
3603
|
+
async function importCommand(path14, args) {
|
|
3606
3604
|
try {
|
|
3607
|
-
const files = collectYmlFiles(
|
|
3605
|
+
const files = collectYmlFiles(path14);
|
|
3608
3606
|
const fixtures = files.map(
|
|
3609
3607
|
(f) => parseFixture(readFileSync2(f, "utf8"), relative(process.cwd(), f))
|
|
3610
3608
|
);
|
|
@@ -5443,14 +5441,14 @@ async function resolveEndpoint(args) {
|
|
|
5443
5441
|
if (args.endpoint) return args.endpoint.replace(/\/+$/, "");
|
|
5444
5442
|
const g = await loadGlobalConfig6();
|
|
5445
5443
|
const envName = resolveActiveEnv3({ envFlag: args.env }, process.env, g);
|
|
5446
|
-
const
|
|
5447
|
-
if (!
|
|
5444
|
+
const env2 = await loadEnv6(envName).catch(() => null);
|
|
5445
|
+
if (!env2?.endpoint) {
|
|
5448
5446
|
throw new CliError18({
|
|
5449
5447
|
code: CliErrorCode17.MISSING_FLAG,
|
|
5450
5448
|
message: "\u672A\u89E3\u6790\u5230 endpoint \u2014\u2014 \u4F20 --endpoint <url>\uFF0C\u6216\u5148 `hcm env add <name> --endpoint <url>`\u3002\uFF08\u6280\u80FD\u5E93\u514D\u8BA4\u8BC1\uFF0C\u4E0D\u9700\u8981\u5148 login\uFF09"
|
|
5451
5449
|
});
|
|
5452
5450
|
}
|
|
5453
|
-
return
|
|
5451
|
+
return env2.endpoint.replace(/\/+$/, "");
|
|
5454
5452
|
}
|
|
5455
5453
|
function normalizeEndpoint(endpoint) {
|
|
5456
5454
|
return endpoint.replace(/\/+$/, "");
|
|
@@ -6601,14 +6599,14 @@ async function resolveEndpoint2(args) {
|
|
|
6601
6599
|
if (args.endpoint) return args.endpoint;
|
|
6602
6600
|
const g = await loadGlobalConfig7();
|
|
6603
6601
|
const envName = resolveActiveEnv4({ envFlag: args.env }, process.env, g);
|
|
6604
|
-
const
|
|
6605
|
-
if (!
|
|
6602
|
+
const env2 = await loadEnv7(envName).catch(() => null);
|
|
6603
|
+
if (!env2?.endpoint) {
|
|
6606
6604
|
throw new CliError19({
|
|
6607
6605
|
code: CliErrorCode18.MISSING_FLAG,
|
|
6608
6606
|
message: "\u672A\u89E3\u6790\u5230 endpoint \u2014\u2014 \u4F20 --endpoint <url>\uFF0C\u6216\u5148 `hcm env add <name> --endpoint <url>`"
|
|
6609
6607
|
});
|
|
6610
6608
|
}
|
|
6611
|
-
return
|
|
6609
|
+
return env2.endpoint;
|
|
6612
6610
|
}
|
|
6613
6611
|
async function tenantBootstrapCommand(args) {
|
|
6614
6612
|
try {
|
|
@@ -6720,10 +6718,10 @@ async function metaListCommand(args) {
|
|
|
6720
6718
|
fail6(e, args);
|
|
6721
6719
|
}
|
|
6722
6720
|
}
|
|
6723
|
-
async function metaGetCommand(
|
|
6721
|
+
async function metaGetCommand(path14, args) {
|
|
6724
6722
|
try {
|
|
6725
6723
|
const c = await client2(args);
|
|
6726
|
-
const content = await getTenantMeta(c.raw(),
|
|
6724
|
+
const content = await getTenantMeta(c.raw(), path14);
|
|
6727
6725
|
process.stdout.write(content.endsWith("\n") ? content : content + "\n");
|
|
6728
6726
|
process.exitCode = 0;
|
|
6729
6727
|
return;
|
|
@@ -6732,8 +6730,8 @@ async function metaGetCommand(path15, args) {
|
|
|
6732
6730
|
}
|
|
6733
6731
|
}
|
|
6734
6732
|
var PROBEABLE_META_TYPES = /* @__PURE__ */ new Set(["model", "list", "info", "view", "filter", "page", "wiz", "impexp"]);
|
|
6735
|
-
function parseMetaPath(
|
|
6736
|
-
const base =
|
|
6733
|
+
function parseMetaPath(path14) {
|
|
6734
|
+
const base = path14.split(/[\\/]/).pop() ?? path14;
|
|
6737
6735
|
if (!/\.(yml|yaml)$/i.test(base)) return {};
|
|
6738
6736
|
const parts = base.replace(/\.(yml|yaml)$/i, "").split(".");
|
|
6739
6737
|
return { model: parts[0] || void 0, kind: parts[1] ?? "model", state: parts[2] };
|
|
@@ -6750,10 +6748,10 @@ function unverifiableReason(e) {
|
|
|
6750
6748
|
if (st == null) return `\u8BF7\u6C42\u6CA1\u53D1\u51FA\u53BB\u6216\u6CA1\u56DE\u6765\uFF08${err.code ?? err.message ?? "\u672A\u77E5"}\uFF09`;
|
|
6751
6749
|
return void 0;
|
|
6752
6750
|
}
|
|
6753
|
-
async function verifyAfterWrite(c,
|
|
6754
|
-
const { model, kind, state } = parseMetaPath(
|
|
6751
|
+
async function verifyAfterWrite(c, path14) {
|
|
6752
|
+
const { model, kind, state } = parseMetaPath(path14);
|
|
6755
6753
|
if (!model || !kind) {
|
|
6756
|
-
return { status: "unverified", where: "(\u672A\u63A2)", why: `\u4ECE\u8DEF\u5F84 ${
|
|
6754
|
+
return { status: "unverified", where: "(\u672A\u63A2)", why: `\u4ECE\u8DEF\u5F84 ${path14} \u8BA4\u4E0D\u51FA\u6A21\u578B\u540D/\u5C42\u540D` };
|
|
6757
6755
|
}
|
|
6758
6756
|
try {
|
|
6759
6757
|
await clearMetaCache2(c.raw(), model, {});
|
|
@@ -6784,21 +6782,21 @@ async function verifyAfterWrite(c, path15) {
|
|
|
6784
6782
|
run: () => c.raw().get(`/api/models/${model}`, { params: { state: state ?? "default", size: 1 } })
|
|
6785
6783
|
});
|
|
6786
6784
|
}
|
|
6787
|
-
for (const
|
|
6785
|
+
for (const probe of probes) {
|
|
6788
6786
|
try {
|
|
6789
|
-
await
|
|
6787
|
+
await probe.run();
|
|
6790
6788
|
} catch (e) {
|
|
6791
6789
|
const why = unverifiableReason(e);
|
|
6792
|
-
if (why) return { status: "unverified", where:
|
|
6790
|
+
if (why) return { status: "unverified", where: probe.where, why };
|
|
6793
6791
|
const err = e;
|
|
6794
6792
|
const body = err.response?.data;
|
|
6795
6793
|
const raw = typeof body === "string" ? body : JSON.stringify(body ?? err.message ?? String(e));
|
|
6796
|
-
return { status: "broken", where:
|
|
6794
|
+
return { status: "broken", where: probe.where, raw };
|
|
6797
6795
|
}
|
|
6798
6796
|
}
|
|
6799
6797
|
return { status: "ok" };
|
|
6800
6798
|
}
|
|
6801
|
-
async function metaSetCommand(
|
|
6799
|
+
async function metaSetCommand(path14, args) {
|
|
6802
6800
|
try {
|
|
6803
6801
|
if (!args.file) {
|
|
6804
6802
|
throw new CliError20({
|
|
@@ -6814,9 +6812,9 @@ async function metaSetCommand(path15, args) {
|
|
|
6814
6812
|
process.stdin.on("error", reject);
|
|
6815
6813
|
}) : await fsp3.readFile(args.file, "utf8");
|
|
6816
6814
|
if (!args.skipValidate) {
|
|
6817
|
-
const result2 = validateMetaContent(
|
|
6815
|
+
const result2 = validateMetaContent(path14, content);
|
|
6818
6816
|
if (result2.issues.length > 0) {
|
|
6819
|
-
process.stderr.write(`\u{1F50E} \u5199\u524D\u6821\u9A8C ${
|
|
6817
|
+
process.stderr.write(`\u{1F50E} \u5199\u524D\u6821\u9A8C ${path14}\uFF08schema \u7C7B\u578B\uFF1A${result2.kind ?? "\u672A\u8BC6\u522B"}\uFF09
|
|
6820
6818
|
`);
|
|
6821
6819
|
process.stderr.write(formatMetaIssues(result2, " ") + "\n");
|
|
6822
6820
|
}
|
|
@@ -6835,13 +6833,13 @@ async function metaSetCommand(path15, args) {
|
|
|
6835
6833
|
if (dryFmt === "json" || dryFmt === "yaml") {
|
|
6836
6834
|
process.stdout.write(
|
|
6837
6835
|
formatObject18(
|
|
6838
|
-
{ dryRun: true, path:
|
|
6836
|
+
{ dryRun: true, path: path14, bytes: Buffer.byteLength(content), content },
|
|
6839
6837
|
{ format: dryFmt }
|
|
6840
6838
|
) + "\n"
|
|
6841
6839
|
);
|
|
6842
6840
|
} else {
|
|
6843
6841
|
process.stdout.write(
|
|
6844
|
-
`[dry-run] \u5C06\u5199\u5165 ${
|
|
6842
|
+
`[dry-run] \u5C06\u5199\u5165 ${path14}\uFF08${Buffer.byteLength(content)} B\uFF09\u2014\u2014\u672A\u5B9E\u9645\u5199\u5165
|
|
6845
6843
|
---
|
|
6846
6844
|
${content}
|
|
6847
6845
|
`
|
|
@@ -6855,13 +6853,13 @@ ${content}
|
|
|
6855
6853
|
let backupState = "unknown";
|
|
6856
6854
|
let backupWhy;
|
|
6857
6855
|
try {
|
|
6858
|
-
const prev = await getTenantMeta(c.raw(),
|
|
6856
|
+
const prev = await getTenantMeta(c.raw(), path14);
|
|
6859
6857
|
if (!prev || prev.trim() === "") {
|
|
6860
6858
|
backupState = "absent";
|
|
6861
6859
|
} else {
|
|
6862
6860
|
backupFile = nodePath.join(
|
|
6863
6861
|
os3.tmpdir(),
|
|
6864
|
-
`hcm-meta-backup-${Date.now()}-${
|
|
6862
|
+
`hcm-meta-backup-${Date.now()}-${path14.replace(/[\\/]/g, "_")}`
|
|
6865
6863
|
);
|
|
6866
6864
|
await fsp3.writeFile(backupFile, prev, "utf8");
|
|
6867
6865
|
backupState = "saved";
|
|
@@ -6876,22 +6874,22 @@ ${content}
|
|
|
6876
6874
|
backupWhy = `HTTP ${st ?? "-"}${err.code ? ` ${err.code}` : ""}${err.message ? `\uFF1A${err.message}` : ""}`;
|
|
6877
6875
|
}
|
|
6878
6876
|
}
|
|
6879
|
-
const result = await saveTenantMeta(c.raw(),
|
|
6877
|
+
const result = await saveTenantMeta(c.raw(), path14, content);
|
|
6880
6878
|
const fmt = args.output ?? "json";
|
|
6881
|
-
if (fmt !== "json") process.stdout.write(`\u2705 \u5DF2\u5199\u5165 ${
|
|
6879
|
+
if (fmt !== "json") process.stdout.write(`\u2705 \u5DF2\u5199\u5165 ${path14}
|
|
6882
6880
|
`);
|
|
6883
6881
|
const restoreHint = backupState === "saved" && backupFile ? ` \u65E7\u5185\u5BB9\u5DF2\u5B58\uFF1A${backupFile}
|
|
6884
|
-
\u653E\u56DE\u53BB\uFF1Ahcm meta set ${
|
|
6885
|
-
` : backupState === "absent" ? ` \u8FD9\u4E00\u5C42\u6B64\u524D\u6CA1\u6709\u8986\u76D6\uFF08\u5DF2\u8BC1\u5B9E\uFF09\uFF0C\u6062\u590D\u5373\u5220\u9664\uFF1Ahcm meta delete ${
|
|
6882
|
+
\u653E\u56DE\u53BB\uFF1Ahcm meta set ${path14} --file ${backupFile}${connFlags(args)}
|
|
6883
|
+
` : backupState === "absent" ? ` \u8FD9\u4E00\u5C42\u6B64\u524D\u6CA1\u6709\u8986\u76D6\uFF08\u5DF2\u8BC1\u5B9E\uFF09\uFF0C\u6062\u590D\u5373\u5220\u9664\uFF1Ahcm meta delete ${path14}${connFlags(args)}
|
|
6886
6884
|
` : ` \u26A0\uFE0F \u65E7\u5185\u5BB9**\u6CA1\u5907\u4EFD\u6210**\uFF08${backupWhy ?? "\u539F\u56E0\u672A\u77E5"}\uFF09\u2014\u2014\u65E2\u4E0D\u77E5\u9053\u6B64\u524D\u6709\u6CA1\u6709\u8986\u76D6\uFF0C\u4E5F\u5C31\u7ED9\u4E0D\u51FA\u6062\u590D\u547D\u4EE4\u3002
|
|
6887
|
-
\u5148\u81EA\u5DF1\u8BFB\u4E00\u904D\u786E\u8BA4\uFF1Ahcm meta get ${
|
|
6885
|
+
\u5148\u81EA\u5DF1\u8BFB\u4E00\u904D\u786E\u8BA4\uFF1Ahcm meta get ${path14}${connFlags(args)}
|
|
6888
6886
|
`;
|
|
6889
6887
|
if (args.verify === false) {
|
|
6890
6888
|
process.stderr.write(
|
|
6891
6889
|
"\u26A0\uFE0F --no-verify\uFF1A**\u6CA1\u6709**\u9A8C\u8FC7\u670D\u52A1\u7AEF\u8BFB\u4E0D\u8BFB\u5F97\u52A8\u8FD9\u4EFD meta\u3002\u300C\u5199\u5165\u6210\u529F\u300D\u53EA\u8BF4\u660E\u5B57\u8282\u6536\u4E0B\u4E86\u3002\n \u81EA\u5DF1\u8865\uFF1Ahcm cache clear-meta <Model> \u540E\u6253\u5F00\u9875\u9762\u770B\u4E00\u773C\u3002\n" + restoreHint
|
|
6892
6890
|
);
|
|
6893
6891
|
} else {
|
|
6894
|
-
const outcome = await verifyAfterWrite(c,
|
|
6892
|
+
const outcome = await verifyAfterWrite(c, path14);
|
|
6895
6893
|
if (outcome.status === "broken") {
|
|
6896
6894
|
const human = explainJacksonError(outcome.raw);
|
|
6897
6895
|
process.stderr.write(
|
|
@@ -6924,19 +6922,19 @@ ${content}
|
|
|
6924
6922
|
fail6(e, args);
|
|
6925
6923
|
}
|
|
6926
6924
|
}
|
|
6927
|
-
async function metaDeleteCommand(
|
|
6925
|
+
async function metaDeleteCommand(path14, args) {
|
|
6928
6926
|
try {
|
|
6929
6927
|
if (!args.yes) {
|
|
6930
|
-
const ok = await promptConfirm(`\u5C06\u5220\u9664\u5143\u6570\u636E ${
|
|
6928
|
+
const ok = await promptConfirm(`\u5C06\u5220\u9664\u5143\u6570\u636E ${path14}\uFF0C\u6B64\u64CD\u4F5C\u4E0D\u53EF\u9006\u3002\u7EE7\u7EED\uFF1F`);
|
|
6931
6929
|
if (!ok) {
|
|
6932
6930
|
process.stderr.write("\u5DF2\u53D6\u6D88\n");
|
|
6933
6931
|
process.exit(1);
|
|
6934
6932
|
}
|
|
6935
6933
|
}
|
|
6936
6934
|
const c = await client2(args);
|
|
6937
|
-
const result = await deleteTenantMeta(c.raw(),
|
|
6935
|
+
const result = await deleteTenantMeta(c.raw(), path14);
|
|
6938
6936
|
const fmt = args.output ?? "json";
|
|
6939
|
-
if (fmt !== "json") process.stdout.write(`\u{1F5D1}\uFE0F \u5DF2\u5220\u9664 ${
|
|
6937
|
+
if (fmt !== "json") process.stdout.write(`\u{1F5D1}\uFE0F \u5DF2\u5220\u9664 ${path14}
|
|
6940
6938
|
`);
|
|
6941
6939
|
process.stdout.write(formatObject18(result, { format: fmt }) + "\n");
|
|
6942
6940
|
process.exitCode = 0;
|
|
@@ -6945,7 +6943,7 @@ async function metaDeleteCommand(path15, args) {
|
|
|
6945
6943
|
fail6(e, args);
|
|
6946
6944
|
}
|
|
6947
6945
|
}
|
|
6948
|
-
async function metaValidateCommand(
|
|
6946
|
+
async function metaValidateCommand(path14, args) {
|
|
6949
6947
|
try {
|
|
6950
6948
|
if (!args.file) {
|
|
6951
6949
|
throw new CliError20({
|
|
@@ -6960,13 +6958,13 @@ async function metaValidateCommand(path15, args) {
|
|
|
6960
6958
|
process.stdin.on("end", () => resolve3(buf));
|
|
6961
6959
|
process.stdin.on("error", reject);
|
|
6962
6960
|
}) : await fsp3.readFile(args.file, "utf8");
|
|
6963
|
-
const result = validateMetaContent(
|
|
6961
|
+
const result = validateMetaContent(path14, content);
|
|
6964
6962
|
const fmt = args.output ?? "table";
|
|
6965
6963
|
if (fmt === "json" || fmt === "yaml") {
|
|
6966
6964
|
process.stdout.write(
|
|
6967
6965
|
formatObject18(
|
|
6968
6966
|
{
|
|
6969
|
-
path:
|
|
6967
|
+
path: path14,
|
|
6970
6968
|
kind: result.kind,
|
|
6971
6969
|
schemaKnown: result.schemaKnown,
|
|
6972
6970
|
schemaSourceCommit: META_SCHEMA_SOURCE_COMMIT,
|
|
@@ -6978,7 +6976,7 @@ async function metaValidateCommand(path15, args) {
|
|
|
6978
6976
|
);
|
|
6979
6977
|
} else {
|
|
6980
6978
|
process.stdout.write(
|
|
6981
|
-
`\u{1F50E} ${
|
|
6979
|
+
`\u{1F50E} ${path14}\uFF08schema \u7C7B\u578B\uFF1A${result.kind ?? "\u672A\u8BC6\u522B"}\uFF0C\u6765\u6E90 ${META_SCHEMA_SOURCE_COMMIT.slice(0, 8)}\uFF09
|
|
6982
6980
|
`
|
|
6983
6981
|
);
|
|
6984
6982
|
process.stdout.write(
|
|
@@ -8564,7 +8562,7 @@ var fetchAuthInfo = async (endpoint, accessToken) => {
|
|
|
8564
8562
|
};
|
|
8565
8563
|
async function inspectIdentity(name, fetcher = fetchAuthInfo) {
|
|
8566
8564
|
const meta2 = await loadIdentity4(name);
|
|
8567
|
-
const
|
|
8565
|
+
const env2 = await loadEnv8(meta2.env);
|
|
8568
8566
|
const accessToken = await TokenStore3.forIdentity(name).getStoredAccessToken();
|
|
8569
8567
|
if (!accessToken) {
|
|
8570
8568
|
throw new CliError21({
|
|
@@ -8573,14 +8571,14 @@ async function inspectIdentity(name, fetcher = fetchAuthInfo) {
|
|
|
8573
8571
|
context: { nextStep: `\u91CD\u65B0\u767B\u5F55\u8BE5\u8EAB\u4EFD\uFF1Ahcm login --env ${meta2.env} --name ${name}` }
|
|
8574
8572
|
});
|
|
8575
8573
|
}
|
|
8576
|
-
const raw = await fetcher(
|
|
8574
|
+
const raw = await fetcher(env2.endpoint, accessToken);
|
|
8577
8575
|
const principal = toPrincipal(raw);
|
|
8578
8576
|
const body = raw && typeof raw === "object" && !Array.isArray(raw) ? raw : {};
|
|
8579
8577
|
const serverScopes = Array.isArray(body.scopes) ? body.scopes.map(String) : void 0;
|
|
8580
8578
|
return {
|
|
8581
8579
|
identity: name,
|
|
8582
8580
|
env: meta2.env,
|
|
8583
|
-
endpoint:
|
|
8581
|
+
endpoint: env2.endpoint,
|
|
8584
8582
|
scheme: meta2.scheme,
|
|
8585
8583
|
userId: principal?.userId ?? null,
|
|
8586
8584
|
username: principal?.username ?? null,
|
|
@@ -8611,8 +8609,8 @@ async function identityList(args) {
|
|
|
8611
8609
|
const lines = [];
|
|
8612
8610
|
for (const n of names) {
|
|
8613
8611
|
const meta2 = await loadIdentity4(n);
|
|
8614
|
-
const
|
|
8615
|
-
const isDefault =
|
|
8612
|
+
const env2 = await loadEnv8(meta2.env).catch(() => null);
|
|
8613
|
+
const isDefault = env2?.defaultIdentity === n ? "*" : " ";
|
|
8616
8614
|
const expired = meta2.expiresAt && new Date(meta2.expiresAt) < /* @__PURE__ */ new Date() ? " (expired)" : "";
|
|
8617
8615
|
lines.push(`${isDefault} ${n} scheme=${meta2.scheme} env=${meta2.env}${expired}`);
|
|
8618
8616
|
}
|
|
@@ -8624,14 +8622,14 @@ async function identityList(args) {
|
|
|
8624
8622
|
async function identityUse(name) {
|
|
8625
8623
|
try {
|
|
8626
8624
|
const meta2 = await loadIdentity4(name);
|
|
8627
|
-
const
|
|
8625
|
+
const env2 = await loadEnv8(meta2.env).catch(() => {
|
|
8628
8626
|
throw new CliError21({
|
|
8629
8627
|
code: CliErrorCode20.IDENTITY_NOT_IN_ENV,
|
|
8630
8628
|
message: `identity '${name}' references env '${meta2.env}' which no longer exists. Re-create the env, or remove this orphan: hcm identity remove ${name}`
|
|
8631
8629
|
});
|
|
8632
8630
|
});
|
|
8633
|
-
|
|
8634
|
-
await saveEnv3(meta2.env,
|
|
8631
|
+
env2.defaultIdentity = name;
|
|
8632
|
+
await saveEnv3(meta2.env, env2);
|
|
8635
8633
|
return exitOk(`\u2705 default identity for env '${meta2.env}': ${name}`);
|
|
8636
8634
|
} catch (e) {
|
|
8637
8635
|
exitWithError(e);
|
|
@@ -8649,10 +8647,10 @@ async function identityRemove(name) {
|
|
|
8649
8647
|
);
|
|
8650
8648
|
}
|
|
8651
8649
|
await deleteIdentity3(name);
|
|
8652
|
-
const
|
|
8653
|
-
if (
|
|
8654
|
-
|
|
8655
|
-
await saveEnv3(meta2.env,
|
|
8650
|
+
const env2 = await loadEnv8(meta2.env).catch(() => null);
|
|
8651
|
+
if (env2?.defaultIdentity === name) {
|
|
8652
|
+
env2.defaultIdentity = void 0;
|
|
8653
|
+
await saveEnv3(meta2.env, env2);
|
|
8656
8654
|
}
|
|
8657
8655
|
return exitOk(`\u2705 identity '${name}' removed`);
|
|
8658
8656
|
} catch (e) {
|
|
@@ -8663,8 +8661,8 @@ async function identityRemove(name) {
|
|
|
8663
8661
|
// src/commands/chiron-init.ts
|
|
8664
8662
|
init_auth_guard();
|
|
8665
8663
|
init_exit();
|
|
8666
|
-
import { promises as
|
|
8667
|
-
import
|
|
8664
|
+
import { promises as fs9 } from "fs";
|
|
8665
|
+
import path8 from "path";
|
|
8668
8666
|
import {
|
|
8669
8667
|
CliError as CliError22,
|
|
8670
8668
|
CliErrorCode as CliErrorCode21,
|
|
@@ -8895,219 +8893,14 @@ function upsertBlock(existing, begin, end, block) {
|
|
|
8895
8893
|
}
|
|
8896
8894
|
|
|
8897
8895
|
// src/commands/chiron-project.ts
|
|
8898
|
-
import { promises as fs9 } from "fs";
|
|
8899
|
-
import os5 from "os";
|
|
8900
|
-
import path8 from "path";
|
|
8901
|
-
import { spawnSync } from "child_process";
|
|
8902
|
-
import { hcmConfigDir, listEnvs as listEnvs3, listIdentities as listIdentities4, loadEnv as loadEnv9, loadGlobalConfig as loadGlobalConfig9 } from "@hcmai/sdk";
|
|
8903
|
-
|
|
8904
|
-
// src/jira/client.ts
|
|
8905
|
-
import { execFileSync } from "child_process";
|
|
8906
8896
|
import { promises as fs8 } from "fs";
|
|
8907
8897
|
import os4 from "os";
|
|
8908
8898
|
import path7 from "path";
|
|
8909
|
-
|
|
8910
|
-
|
|
8911
|
-
|
|
8912
|
-
|
|
8913
|
-
|
|
8914
|
-
};
|
|
8915
|
-
var trimSlash = (u) => u.replace(/\/+$/, "");
|
|
8916
|
-
var JIRA_BASE = trimSlash(env("JIRA_BASE", "https://jira.hcmcloud.cn"));
|
|
8917
|
-
var JIRA_PROJECT = env("JIRA_PROJECT", "HCMNX");
|
|
8918
|
-
var JIRA_KEYCHAIN = env("JIRA_KEYCHAIN_SERVICE", "jira-hcmcloud");
|
|
8919
|
-
var CNB_ORIGIN = trimSlash(env("HCM_CNB_ORIGIN", "https://cnb.cool"));
|
|
8920
|
-
var CASES_REPO_SLUG = env("HCM_CASES_REPO", "hcm/chiron-cases");
|
|
8921
|
-
var CASES_REPO_URL = `${CNB_ORIGIN}/${CASES_REPO_SLUG}.git`;
|
|
8922
|
-
var repoIssueUrl = (repo, number) => `${CNB_ORIGIN}/${repo}/-/issues/${number}`;
|
|
8923
|
-
var CNB_FAVICON_URL = `${CNB_ORIGIN}/favicon.ico`;
|
|
8924
|
-
|
|
8925
|
-
// src/jira/client.ts
|
|
8926
|
-
var JIRA_TOKEN_FILE = () => process.env.JIRA_TOKEN_FILE || path7.join(os4.homedir(), ".config", "hcm", "jira-token");
|
|
8927
|
-
async function jiraTokenSource() {
|
|
8928
|
-
if (process.env.JIRA_TOKEN?.trim()) return { token: process.env.JIRA_TOKEN.trim(), from: "\u73AF\u5883\u53D8\u91CF JIRA_TOKEN" };
|
|
8929
|
-
const file = JIRA_TOKEN_FILE();
|
|
8930
|
-
try {
|
|
8931
|
-
const stat = await fs8.stat(file);
|
|
8932
|
-
const value = (await fs8.readFile(file, "utf8")).trim();
|
|
8933
|
-
if (value) {
|
|
8934
|
-
if (stat.mode & 63) process.stderr.write(`[jira] \u8B66\u544A\uFF1A${file} \u5BF9\u5176\u4ED6\u7528\u6237\u53EF\u8BFB\uFF08chmod 600 \u6536\u7D27\uFF09
|
|
8935
|
-
`);
|
|
8936
|
-
return { token: value, from: file };
|
|
8937
|
-
}
|
|
8938
|
-
} catch {
|
|
8939
|
-
}
|
|
8940
|
-
try {
|
|
8941
|
-
const out = execFileSync("security", ["find-generic-password", "-s", JIRA_KEYCHAIN, "-w"], {
|
|
8942
|
-
encoding: "utf8",
|
|
8943
|
-
stdio: ["ignore", "pipe", "ignore"]
|
|
8944
|
-
}).trim();
|
|
8945
|
-
if (out) return { token: out, from: `\u94A5\u5319\u4E32 ${JIRA_KEYCHAIN}` };
|
|
8946
|
-
} catch {
|
|
8947
|
-
}
|
|
8948
|
-
return null;
|
|
8949
|
-
}
|
|
8950
|
-
function jiraTokenHelp() {
|
|
8951
|
-
return `\u62FF\u4E0D\u5230 Jira \u4EE4\u724C\u3002next_step=\u5148\u5728 ${JIRA_BASE} \u53F3\u4E0A\u89D2\u5934\u50CF \u2192 \u4E2A\u4EBA\u8BBE\u7F6E \u2192 Personal Access Tokens \u5EFA\u4E00\u4E2A\uFF0C\u518D\u9009\u4E00\u79CD\u5B58\u6CD5\uFF08\u90FD\u4E0D\u4F1A\u8FDB\u4ED3\u5E93\uFF09\uFF1A
|
|
8952
|
-
\u2460 \u6587\u4EF6\uFF08\u63A8\u8350\uFF0C\u4E0D\u5F39\u7A97\uFF09\uFF1Amkdir -p ~/.config/hcm && (umask 177; cat > ${JIRA_TOKEN_FILE()}) \u7136\u540E\u7C98\u4EE4\u724C\u3001Ctrl-D
|
|
8953
|
-
\u2461 \u94A5\u5319\u4E32\uFF08\u514D\u5F39\u7A97\u8981\u5E26 -A\uFF09\uFF1Asecurity add-generic-password -a "$USER" -s ${JIRA_KEYCHAIN} -A -w
|
|
8954
|
-
\u2462 \u53EA\u7528\u4E00\u6B21\uFF1AJIRA_TOKEN=<\u4EE4\u724C> \u8DD1\u672C\u6B21\u547D\u4EE4`;
|
|
8955
|
-
}
|
|
8956
|
-
var JiraClient = class {
|
|
8957
|
-
base;
|
|
8958
|
-
project;
|
|
8959
|
-
token;
|
|
8960
|
-
fetchImpl;
|
|
8961
|
-
timeoutMs;
|
|
8962
|
-
constructor(o) {
|
|
8963
|
-
this.base = (o.base ?? JIRA_BASE).replace(/\/+$/, "");
|
|
8964
|
-
this.project = o.project ?? JIRA_PROJECT;
|
|
8965
|
-
this.token = o.token;
|
|
8966
|
-
this.fetchImpl = o.fetchImpl ?? fetch;
|
|
8967
|
-
this.timeoutMs = o.timeoutMs ?? 3e4;
|
|
8968
|
-
}
|
|
8969
|
-
browseUrl(key2) {
|
|
8970
|
-
return `${this.base}/browse/${key2}`;
|
|
8971
|
-
}
|
|
8972
|
-
/** 一次 REST 调用。失败时把 Jira 的 errorMessages 原样带出来,不吞。 */
|
|
8973
|
-
async api(p, init = {}) {
|
|
8974
|
-
const method = init.method ?? "GET";
|
|
8975
|
-
const url = p.startsWith("http") ? p : `${this.base}${p}`;
|
|
8976
|
-
const res = await this.fetchImpl(url, {
|
|
8977
|
-
method,
|
|
8978
|
-
headers: {
|
|
8979
|
-
Authorization: `Bearer ${this.token}`,
|
|
8980
|
-
Accept: "application/json",
|
|
8981
|
-
...init.body !== void 0 ? { "Content-Type": "application/json" } : {}
|
|
8982
|
-
},
|
|
8983
|
-
body: init.body !== void 0 ? JSON.stringify(init.body) : void 0,
|
|
8984
|
-
signal: AbortSignal.timeout(this.timeoutMs)
|
|
8985
|
-
});
|
|
8986
|
-
const text = await res.text();
|
|
8987
|
-
if (!res.ok) {
|
|
8988
|
-
let detail = text.slice(0, 600);
|
|
8989
|
-
try {
|
|
8990
|
-
const j = JSON.parse(text);
|
|
8991
|
-
const msgs = [...j.errorMessages ?? [], ...Object.entries(j.errors ?? {}).map(([k, v]) => `${k}: ${v}`)];
|
|
8992
|
-
if (msgs.length) detail = msgs.join("\uFF1B");
|
|
8993
|
-
} catch {
|
|
8994
|
-
}
|
|
8995
|
-
const hint = res.status === 401 ? " next_step=\u4EE4\u724C\u65E0\u6548\u6216\u8FC7\u671F\uFF0C\u91CD\u5EFA PAT \u540E\u91CD\u65B0\u5B58\u4E00\u6B21" : res.status === 403 ? " next_step=\u4EE4\u724C\u6709\u6548\u4F46\u6CA1\u6709\u8FD9\u4E2A\u9879\u76EE\u7684\u6743\u9650\uFF0C\u627E Jira \u7BA1\u7406\u5458\u5F00\u6743\u9650" : "";
|
|
8996
|
-
throw new Error(`Jira ${method} ${p} \u2192 ${res.status}\uFF1A${detail}${hint}`);
|
|
8997
|
-
}
|
|
8998
|
-
return text ? JSON.parse(text) : null;
|
|
8999
|
-
}
|
|
9000
|
-
serverInfo() {
|
|
9001
|
-
return this.api("/rest/api/2/serverInfo");
|
|
9002
|
-
}
|
|
9003
|
-
myself() {
|
|
9004
|
-
return this.api("/rest/api/2/myself");
|
|
9005
|
-
}
|
|
9006
|
-
async search(jql, {
|
|
9007
|
-
fields = ["summary", "status", "priority", "created", "updated", "labels", "issuetype", "reporter", "resolution"],
|
|
9008
|
-
max = 30
|
|
9009
|
-
} = {}) {
|
|
9010
|
-
const q = new URLSearchParams({ jql, maxResults: String(max), fields: fields.join(",") });
|
|
9011
|
-
const r = await this.api(`/rest/api/2/search?${q}`);
|
|
9012
|
-
return r.issues ?? [];
|
|
9013
|
-
}
|
|
9014
|
-
issue(key2, fields) {
|
|
9015
|
-
return this.api(`/rest/api/2/issue/${encodeURIComponent(key2)}${fields ? `?fields=${fields.join(",")}` : ""}`);
|
|
9016
|
-
}
|
|
9017
|
-
async comments(key2) {
|
|
9018
|
-
const r = await this.api(
|
|
9019
|
-
`/rest/api/2/issue/${encodeURIComponent(key2)}/comment?maxResults=50`
|
|
9020
|
-
);
|
|
9021
|
-
return r.comments ?? [];
|
|
9022
|
-
}
|
|
9023
|
-
addComment(key2, body) {
|
|
9024
|
-
return this.api(`/rest/api/2/issue/${encodeURIComponent(key2)}/comment`, { method: "POST", body: { body } });
|
|
9025
|
-
}
|
|
9026
|
-
createIssue(fields) {
|
|
9027
|
-
return this.api("/rest/api/2/issue", { method: "POST", body: { fields } });
|
|
9028
|
-
}
|
|
9029
|
-
async transitions(key2) {
|
|
9030
|
-
const r = await this.api(
|
|
9031
|
-
`/rest/api/2/issue/${encodeURIComponent(key2)}/transitions?expand=transitions.fields`
|
|
9032
|
-
);
|
|
9033
|
-
return r.transitions ?? [];
|
|
9034
|
-
}
|
|
9035
|
-
/** 按流转 id / 流转名 / 目标状态名三种写法找;找不到把可用流转列出来,不猜。 */
|
|
9036
|
-
async transition(key2, nameOrId, comment) {
|
|
9037
|
-
const list = await this.transitions(key2);
|
|
9038
|
-
const hit = list.find((t) => t.id === String(nameOrId)) || list.find((t) => t.name === nameOrId) || list.find((t) => t.to?.name === nameOrId);
|
|
9039
|
-
if (!hit) {
|
|
9040
|
-
throw new Error(
|
|
9041
|
-
`${key2} \u4E0A\u6CA1\u6709\u5230\u300C${nameOrId}\u300D\u7684\u6D41\u8F6C\u3002\u53EF\u7528\uFF1A${list.map((t) => `${t.name}\u2192${t.to?.name}`).join(" / ") || "\uFF08\u65E0\uFF09"}`
|
|
9042
|
-
);
|
|
9043
|
-
}
|
|
9044
|
-
await this.api(`/rest/api/2/issue/${encodeURIComponent(key2)}/transitions`, {
|
|
9045
|
-
method: "POST",
|
|
9046
|
-
body: {
|
|
9047
|
-
transition: { id: hit.id },
|
|
9048
|
-
...comment ? { update: { comment: [{ add: { body: comment } }] } } : {}
|
|
9049
|
-
}
|
|
9050
|
-
});
|
|
9051
|
-
return hit;
|
|
9052
|
-
}
|
|
9053
|
-
/**
|
|
9054
|
-
* 建单前先问 Jira:这个项目有哪些 issuetype、每种哪些字段必填、可选值是什么。
|
|
9055
|
-
*
|
|
9056
|
-
* 🔴 不写死 customfield 编号:同名字段在别的项目里编号不同,写死就是换个项目静默填错格。
|
|
9057
|
-
* Jira 9 起旧的 `createmeta?projectKeys=&expand=` 已移除(11.3.2 实测 404),用按 issuetype 分页的新接口。
|
|
9058
|
-
*/
|
|
9059
|
-
async createMeta(project = this.project) {
|
|
9060
|
-
const list = await this.api(
|
|
9061
|
-
`/rest/api/2/issue/createmeta/${project}/issuetypes`
|
|
9062
|
-
);
|
|
9063
|
-
const types = list.values ?? list.issueTypes ?? [];
|
|
9064
|
-
const out = [];
|
|
9065
|
-
for (const t of types) {
|
|
9066
|
-
if (t.subtask) continue;
|
|
9067
|
-
const f = await this.api(`/rest/api/2/issue/createmeta/${project}/issuetypes/${t.id}`);
|
|
9068
|
-
out.push({ id: t.id, name: t.name, fields: f.values ?? [] });
|
|
9069
|
-
}
|
|
9070
|
-
return out;
|
|
9071
|
-
}
|
|
9072
|
-
projectInfo(project = this.project) {
|
|
9073
|
-
return this.api(`/rest/api/2/project/${project}`);
|
|
9074
|
-
}
|
|
9075
|
-
projectStatuses(project = this.project) {
|
|
9076
|
-
return this.api(`/rest/api/2/project/${project}/statuses`);
|
|
9077
|
-
}
|
|
9078
|
-
/**
|
|
9079
|
-
* 远程链接:把代码库的 issue 挂到 Jira 单的「链接」栏里,而不是埋在评论中。
|
|
9080
|
-
* 公司现有惯例就是这样(HF 的开发任务用链接挂到 HCR 的需求上),照它来。
|
|
9081
|
-
* globalId 用 URL 本身,重复调用是覆盖不是新增。
|
|
9082
|
-
*/
|
|
9083
|
-
addRemoteLink(key2, url, title, relationship = "\u4EE3\u7801\u5E93\u6761\u76EE") {
|
|
9084
|
-
return this.api(`/rest/api/2/issue/${encodeURIComponent(key2)}/remotelink`, {
|
|
9085
|
-
method: "POST",
|
|
9086
|
-
body: {
|
|
9087
|
-
globalId: url,
|
|
9088
|
-
relationship,
|
|
9089
|
-
object: { url, title, icon: { url16x16: CNB_FAVICON_URL, title: "cnb" } }
|
|
9090
|
-
}
|
|
9091
|
-
});
|
|
9092
|
-
}
|
|
9093
|
-
async remoteLinks(key2) {
|
|
9094
|
-
try {
|
|
9095
|
-
return await this.api(`/rest/api/2/issue/${encodeURIComponent(key2)}/remotelink`) ?? [];
|
|
9096
|
-
} catch {
|
|
9097
|
-
return [];
|
|
9098
|
-
}
|
|
9099
|
-
}
|
|
9100
|
-
assign(key2, name) {
|
|
9101
|
-
return this.api(`/rest/api/2/issue/${encodeURIComponent(key2)}/assignee`, { method: "PUT", body: { name } });
|
|
9102
|
-
}
|
|
9103
|
-
};
|
|
9104
|
-
async function createJiraClient(opts = {}) {
|
|
9105
|
-
const src = opts.token ? { token: opts.token, from: "\u53C2\u6570" } : await jiraTokenSource();
|
|
9106
|
-
if (!src) throw new Error(jiraTokenHelp());
|
|
9107
|
-
return new JiraClient({ ...opts, token: src.token });
|
|
9108
|
-
}
|
|
9109
|
-
|
|
9110
|
-
// src/commands/chiron-project.ts
|
|
8899
|
+
import { spawnSync } from "child_process";
|
|
8900
|
+
import { hcmConfigDir, listEnvs as listEnvs3, listIdentities as listIdentities4, loadEnv as loadEnv9, loadGlobalConfig as loadGlobalConfig9 } from "@hcmai/sdk";
|
|
8901
|
+
import { JIRA_BASE, JIRA_PROJECT, jiraTokenSource } from "@hcmai/sdk";
|
|
8902
|
+
import { CASES_REPO_URL } from "@hcmai/sdk";
|
|
8903
|
+
import { JIRA_BASE as JIRA_BASE2, JIRA_PROJECT as JIRA_PROJECT2, JIRA_TOKEN_FILE, jiraTokenSource as jiraTokenSource2 } from "@hcmai/sdk";
|
|
9111
8904
|
var ENV_FILE = "env.yaml";
|
|
9112
8905
|
var SKILLS_DIR = "hcm-skills";
|
|
9113
8906
|
var CASES_MCP_NAME = "chiron-cases";
|
|
@@ -9121,13 +8914,13 @@ var CHIRON_PROJECT_DIRECTORIES = [
|
|
|
9121
8914
|
"gaps",
|
|
9122
8915
|
"customer-docs"
|
|
9123
8916
|
];
|
|
9124
|
-
function renderEnvYaml(
|
|
8917
|
+
function renderEnvYaml(env2) {
|
|
9125
8918
|
return [
|
|
9126
8919
|
"# \u9879\u76EE\u73AF\u5883\uFF08hcm chiron init \u751F\u6210\uFF0C\u968F\u4ED3\u5E93\u63D0\u4EA4\uFF1B\u4E0D\u653E\u8EAB\u4EFD\u3001\u4E0D\u653E\u51ED\u636E\uFF09",
|
|
9127
8920
|
"# \u767B\u5F55\uFF1Ahcm login <endpoint> --code <\u914D\u5BF9\u7801> \u6838\u5BF9\uFF1Ahcm chiron doctor",
|
|
9128
|
-
`endpoint: ${JSON.stringify(
|
|
9129
|
-
`frontend: ${JSON.stringify(
|
|
9130
|
-
`tenant: ${JSON.stringify(
|
|
8921
|
+
`endpoint: ${JSON.stringify(env2.endpoint)}`,
|
|
8922
|
+
`frontend: ${JSON.stringify(env2.frontend)}`,
|
|
8923
|
+
`tenant: ${JSON.stringify(env2.tenant)}`,
|
|
9131
8924
|
""
|
|
9132
8925
|
].join("\n");
|
|
9133
8926
|
}
|
|
@@ -9205,14 +8998,14 @@ function mergeChironAgentInstructions(existing) {
|
|
|
9205
8998
|
return upsertBlock(existing, AGENT_BEGIN, AGENT_END, renderChironAgentInstructions().trimEnd());
|
|
9206
8999
|
}
|
|
9207
9000
|
function caseLibraryDir() {
|
|
9208
|
-
return
|
|
9001
|
+
return path7.join(hcmConfigDir(), CASES_MCP_NAME);
|
|
9209
9002
|
}
|
|
9210
9003
|
function codexConfigFile() {
|
|
9211
|
-
return
|
|
9004
|
+
return path7.join(process.env.HOME ?? os4.homedir(), ".codex", "config.toml");
|
|
9212
9005
|
}
|
|
9213
9006
|
function renderCodexMcpSection(repo, envName, binPath = process.env.PATH ?? "") {
|
|
9214
|
-
const server =
|
|
9215
|
-
const
|
|
9007
|
+
const server = path7.join(repo, "mcp", "server.mjs");
|
|
9008
|
+
const env2 = [
|
|
9216
9009
|
`CASES_REPO = ${JSON.stringify(repo)}`,
|
|
9217
9010
|
`HCM_ENV = ${JSON.stringify(envName)}`,
|
|
9218
9011
|
...binPath ? [`PATH = ${JSON.stringify(binPath)}`] : []
|
|
@@ -9221,7 +9014,7 @@ function renderCodexMcpSection(repo, envName, binPath = process.env.PATH ?? "")
|
|
|
9221
9014
|
`[mcp_servers.${CASES_MCP_NAME}]`,
|
|
9222
9015
|
'command = "node"',
|
|
9223
9016
|
`args = [${JSON.stringify(server)}]`,
|
|
9224
|
-
`env = { ${
|
|
9017
|
+
`env = { ${env2} }`,
|
|
9225
9018
|
""
|
|
9226
9019
|
].join("\n");
|
|
9227
9020
|
}
|
|
@@ -9274,13 +9067,13 @@ async function ensureCaseLibrary(envName, deps = defaultCaseLibraryDeps, paths =
|
|
|
9274
9067
|
const repo = paths.repo ?? caseLibraryDir();
|
|
9275
9068
|
const codexConfig = paths.codexConfig ?? codexConfigFile();
|
|
9276
9069
|
const status = { ok: false, repo, step: "present", serverInstalled: false, codexWired: false };
|
|
9277
|
-
const hasGit = await exists2(
|
|
9070
|
+
const hasGit = await exists2(path7.join(repo, ".git"));
|
|
9278
9071
|
if (hasGit) {
|
|
9279
9072
|
const pull = deps.git(["pull", "--ff-only", "--quiet"], repo);
|
|
9280
9073
|
status.step = pull.status === 0 ? "updated" : "present";
|
|
9281
9074
|
if (pull.status !== 0) status.reason = `\u66F4\u65B0\u5931\u8D25\uFF0C\u6CBF\u7528\u672C\u5730\u7248\u672C\uFF1A${firstLine(pull.stderr, pull.error)}`;
|
|
9282
9075
|
} else {
|
|
9283
|
-
await
|
|
9076
|
+
await fs8.mkdir(path7.dirname(repo), { recursive: true });
|
|
9284
9077
|
const clone = deps.git(["clone", "--depth", "1", "--quiet", CASES_REPO_URL, repo]);
|
|
9285
9078
|
if (clone.status !== 0) {
|
|
9286
9079
|
status.step = "clone-failed";
|
|
@@ -9289,13 +9082,13 @@ async function ensureCaseLibrary(envName, deps = defaultCaseLibraryDeps, paths =
|
|
|
9289
9082
|
}
|
|
9290
9083
|
status.step = "cloned";
|
|
9291
9084
|
}
|
|
9292
|
-
const mcpDir =
|
|
9293
|
-
if (!await exists2(
|
|
9085
|
+
const mcpDir = path7.join(repo, "mcp");
|
|
9086
|
+
if (!await exists2(path7.join(mcpDir, "server.mjs"))) {
|
|
9294
9087
|
status.step = "install-failed";
|
|
9295
9088
|
status.reason = `\u6848\u4F8B\u5E93\u91CC\u6CA1\u6709 mcp/server.mjs\uFF1A${mcpDir}`;
|
|
9296
9089
|
return status;
|
|
9297
9090
|
}
|
|
9298
|
-
if (!await exists2(
|
|
9091
|
+
if (!await exists2(path7.join(mcpDir, "node_modules", "@modelcontextprotocol"))) {
|
|
9299
9092
|
const install = deps.npmInstall(mcpDir);
|
|
9300
9093
|
if (install.status !== 0) {
|
|
9301
9094
|
status.step = "install-failed";
|
|
@@ -9304,10 +9097,10 @@ async function ensureCaseLibrary(envName, deps = defaultCaseLibraryDeps, paths =
|
|
|
9304
9097
|
}
|
|
9305
9098
|
}
|
|
9306
9099
|
status.serverInstalled = true;
|
|
9307
|
-
await
|
|
9308
|
-
const existing = await
|
|
9100
|
+
await fs8.mkdir(path7.dirname(codexConfig), { recursive: true });
|
|
9101
|
+
const existing = await fs8.readFile(codexConfig, "utf8").catch(() => "");
|
|
9309
9102
|
const next = mergeCodexMcpConfig(existing, renderCodexMcpSection(repo, envName));
|
|
9310
|
-
if (next !== existing) await
|
|
9103
|
+
if (next !== existing) await fs8.writeFile(codexConfig, next, "utf8");
|
|
9311
9104
|
status.codexWired = true;
|
|
9312
9105
|
status.ok = true;
|
|
9313
9106
|
return status;
|
|
@@ -9315,9 +9108,9 @@ async function ensureCaseLibrary(envName, deps = defaultCaseLibraryDeps, paths =
|
|
|
9315
9108
|
async function inspectCaseLibrary(paths = {}) {
|
|
9316
9109
|
const repo = paths.repo ?? caseLibraryDir();
|
|
9317
9110
|
const codexConfig = paths.codexConfig ?? codexConfigFile();
|
|
9318
|
-
const cloned = await exists2(
|
|
9319
|
-
const serverInstalled = cloned && await exists2(
|
|
9320
|
-
const codexWired = codexConfigHasCases(await
|
|
9111
|
+
const cloned = await exists2(path7.join(repo, ".git"));
|
|
9112
|
+
const serverInstalled = cloned && await exists2(path7.join(repo, "mcp", "server.mjs")) && await exists2(path7.join(repo, "mcp", "node_modules", "@modelcontextprotocol"));
|
|
9113
|
+
const codexWired = codexConfigHasCases(await fs8.readFile(codexConfig, "utf8").catch(() => ""));
|
|
9321
9114
|
return { repo, cloned, serverInstalled, codexWired };
|
|
9322
9115
|
}
|
|
9323
9116
|
function firstLine(stderr, error) {
|
|
@@ -9359,7 +9152,7 @@ async function inspectJira() {
|
|
|
9359
9152
|
}
|
|
9360
9153
|
async function exists2(file) {
|
|
9361
9154
|
try {
|
|
9362
|
-
await
|
|
9155
|
+
await fs8.access(file);
|
|
9363
9156
|
return true;
|
|
9364
9157
|
} catch {
|
|
9365
9158
|
return false;
|
|
@@ -9383,7 +9176,7 @@ var defaultChironInitDeps = {
|
|
|
9383
9176
|
all: true,
|
|
9384
9177
|
target: "codex",
|
|
9385
9178
|
env: envName,
|
|
9386
|
-
dir:
|
|
9179
|
+
dir: path8.join(root, SKILLS_DIR),
|
|
9387
9180
|
output: "table"
|
|
9388
9181
|
});
|
|
9389
9182
|
} finally {
|
|
@@ -9422,63 +9215,63 @@ async function resolveLoggedInEnv() {
|
|
|
9422
9215
|
const identity2 = config2.defaultIdentity && identities.includes(config2.defaultIdentity) ? config2.defaultIdentity : identities[0];
|
|
9423
9216
|
return { name, env: projectEnvFromConfig(config2), identity: identity2 };
|
|
9424
9217
|
}
|
|
9425
|
-
async function scaffoldChironProject(root,
|
|
9218
|
+
async function scaffoldChironProject(root, env2, envName) {
|
|
9426
9219
|
const result = { created: [], updated: [], preserved: [] };
|
|
9427
|
-
const envFile =
|
|
9428
|
-
const existing = await
|
|
9220
|
+
const envFile = path8.join(root, ENV_FILE);
|
|
9221
|
+
const existing = await fs9.readFile(envFile, "utf8").catch(() => null);
|
|
9429
9222
|
if (existing !== null) {
|
|
9430
9223
|
const recorded = parseEnvYaml(existing);
|
|
9431
|
-
if (recorded.endpoint !==
|
|
9224
|
+
if (recorded.endpoint !== env2.endpoint) {
|
|
9432
9225
|
throw new CliError22({
|
|
9433
9226
|
code: CliErrorCode21.INVALID_ARGUMENT,
|
|
9434
|
-
message: `${ENV_FILE} \u6307\u5411 ${recorded.endpoint}\uFF0C\u800C\u4F60\u5F53\u524D\u767B\u5F55\u7684\u662F ${
|
|
9227
|
+
message: `${ENV_FILE} \u6307\u5411 ${recorded.endpoint}\uFF0C\u800C\u4F60\u5F53\u524D\u767B\u5F55\u7684\u662F ${env2.endpoint}\uFF08env '${envName}'\uFF09\u3002
|
|
9435
9228
|
\u8981\u7528\u8FD9\u4E2A\u9879\u76EE\u7684\u73AF\u5883\uFF1Ahcm login ${recorded.endpoint} --code <\u914D\u5BF9\u7801>\uFF0C\u518D\u91CD\u8DD1 hcm chiron init
|
|
9436
9229
|
\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`
|
|
9437
9230
|
});
|
|
9438
9231
|
}
|
|
9439
|
-
if (recorded.tenant !==
|
|
9232
|
+
if (recorded.tenant !== env2.tenant) {
|
|
9440
9233
|
throw new CliError22({
|
|
9441
9234
|
code: CliErrorCode21.INVALID_ARGUMENT,
|
|
9442
|
-
message: `${ENV_FILE} \u662F\u79DF\u6237 ${recorded.tenant}\uFF0C\u800C\u4F60\u767B\u5F55\u7684\u8EAB\u4EFD\u5C5E\u4E8E\u79DF\u6237 ${
|
|
9443
|
-
\u7528\u9879\u76EE\u79DF\u6237\u7684\u914D\u5BF9\u7801\u91CD\u65B0\u767B\u5F55\uFF1Ahcm login ${
|
|
9235
|
+
message: `${ENV_FILE} \u662F\u79DF\u6237 ${recorded.tenant}\uFF0C\u800C\u4F60\u767B\u5F55\u7684\u8EAB\u4EFD\u5C5E\u4E8E\u79DF\u6237 ${env2.tenant}\u3002
|
|
9236
|
+
\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`
|
|
9444
9237
|
});
|
|
9445
9238
|
}
|
|
9446
9239
|
result.preserved.push(ENV_FILE);
|
|
9447
9240
|
} else {
|
|
9448
|
-
await
|
|
9241
|
+
await fs9.writeFile(envFile, renderEnvYaml(env2), { encoding: "utf8", mode: 420, flag: "wx" });
|
|
9449
9242
|
result.created.push(ENV_FILE);
|
|
9450
9243
|
}
|
|
9451
9244
|
for (const directory of CHIRON_PROJECT_DIRECTORIES) {
|
|
9452
|
-
const absolute =
|
|
9245
|
+
const absolute = path8.join(root, directory);
|
|
9453
9246
|
await ensureDirectory(absolute);
|
|
9454
|
-
await writeIfAbsent(
|
|
9247
|
+
await writeIfAbsent(path8.join(absolute, ".gitkeep"), "", result, `${directory}/.gitkeep`);
|
|
9455
9248
|
}
|
|
9456
|
-
const pageAcceptanceFile =
|
|
9249
|
+
const pageAcceptanceFile = path8.join(root, "page-acceptance.sh");
|
|
9457
9250
|
const created = await writeIfAbsent(pageAcceptanceFile, renderPageAcceptanceSh("evidence"), result, "page-acceptance.sh", 493);
|
|
9458
|
-
if (created) await
|
|
9459
|
-
await mergeManagedFile(
|
|
9460
|
-
await mergeManagedFile(
|
|
9251
|
+
if (created) await fs9.chmod(pageAcceptanceFile, 493);
|
|
9252
|
+
await mergeManagedFile(path8.join(root, "AGENTS.md"), mergeChironAgentInstructions, result, "AGENTS.md");
|
|
9253
|
+
await mergeManagedFile(path8.join(root, "CLAUDE.md"), mergeChironAgentInstructions, result, "CLAUDE.md");
|
|
9461
9254
|
return result;
|
|
9462
9255
|
}
|
|
9463
9256
|
async function runChironInit(args, deps = defaultChironInitDeps) {
|
|
9464
|
-
const root =
|
|
9465
|
-
const { name, env:
|
|
9257
|
+
const root = path8.resolve(args.project ?? ".");
|
|
9258
|
+
const { name, env: env2, identity: identity2 } = await resolveLoggedInEnv();
|
|
9466
9259
|
if (isTempEnv3(name)) {
|
|
9467
9260
|
throw new CliError22({
|
|
9468
9261
|
code: CliErrorCode21.INVALID_ARGUMENT,
|
|
9469
|
-
message: `\u5F53\u524D\u662F\u4E34\u65F6\u73AF\u5883\uFF08${
|
|
9262
|
+
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`,
|
|
9470
9263
|
context: { nextStep: `\u5148\u7ED9\u5B83\u8D77\u4E2A\u540D\u5B57\uFF1Ahcm env save <name>\uFF0C\u7136\u540E\u91CD\u8DD1 hcm chiron init` }
|
|
9471
9264
|
});
|
|
9472
9265
|
}
|
|
9473
9266
|
const say = (line) => process.stderr.write(`[chiron init] ${line}
|
|
9474
9267
|
`);
|
|
9475
|
-
const actual = await deps.tokenTenant(name,
|
|
9476
|
-
if (actual && actual !==
|
|
9477
|
-
say(`env ${name} \u8BB0\u7684\u79DF\u6237\u662F ${
|
|
9478
|
-
|
|
9268
|
+
const actual = await deps.tokenTenant(name, env2.tenant);
|
|
9269
|
+
if (actual && actual !== env2.tenant) {
|
|
9270
|
+
say(`env ${name} \u8BB0\u7684\u79DF\u6237\u662F ${env2.tenant}\uFF0C\u4F46\u4F60\u7684\u767B\u5F55\u8EAB\u4EFD\u5C5E\u4E8E\u79DF\u6237 ${actual}\uFF0C\u6309 ${actual} \u5199 ${ENV_FILE}`);
|
|
9271
|
+
env2.tenant = actual;
|
|
9479
9272
|
}
|
|
9480
|
-
say(`\u73AF\u5883 ${name} \xB7 ${
|
|
9481
|
-
const scaffold = await scaffoldChironProject(root,
|
|
9273
|
+
say(`\u73AF\u5883 ${name} \xB7 ${env2.endpoint} \xB7 \u79DF\u6237 ${env2.tenant} \xB7 \u8EAB\u4EFD ${identity2}`);
|
|
9274
|
+
const scaffold = await scaffoldChironProject(root, env2, name);
|
|
9482
9275
|
say(`\u9AA8\u67B6\uFF1A\u65B0\u5EFA ${scaffold.created.length} \xB7 \u66F4\u65B0 ${scaffold.updated.length} \xB7 \u4FDD\u7559 ${scaffold.preserved.length}`);
|
|
9483
9276
|
let skills2 = "skipped";
|
|
9484
9277
|
if (!args.skipSkills) {
|
|
@@ -9496,9 +9289,9 @@ async function runChironInit(args, deps = defaultChironInitDeps) {
|
|
|
9496
9289
|
return {
|
|
9497
9290
|
project: root,
|
|
9498
9291
|
env: name,
|
|
9499
|
-
endpoint:
|
|
9500
|
-
frontend:
|
|
9501
|
-
tenant:
|
|
9292
|
+
endpoint: env2.endpoint,
|
|
9293
|
+
frontend: env2.frontend,
|
|
9294
|
+
tenant: env2.tenant,
|
|
9502
9295
|
identity: identity2,
|
|
9503
9296
|
scaffold,
|
|
9504
9297
|
skills: skills2,
|
|
@@ -9529,1892 +9322,1440 @@ async function chironInitCommand(args, deps) {
|
|
|
9529
9322
|
}
|
|
9530
9323
|
}
|
|
9531
9324
|
|
|
9532
|
-
// src/commands/
|
|
9533
|
-
|
|
9534
|
-
init_exit();
|
|
9535
|
-
import { promises as fs11 } from "fs";
|
|
9536
|
-
import path10 from "path";
|
|
9325
|
+
// src/commands/gap.ts
|
|
9326
|
+
import { readFileSync as readFileSync5 } from "fs";
|
|
9537
9327
|
import {
|
|
9538
|
-
|
|
9539
|
-
CliError as CliError23,
|
|
9540
|
-
fetchReconIdentity as fetchReconIdentity2,
|
|
9328
|
+
createHttpClient as createHttpClient4,
|
|
9541
9329
|
formatObject as formatObject22,
|
|
9542
|
-
|
|
9543
|
-
|
|
9330
|
+
loadEnv as loadEnv11,
|
|
9331
|
+
loadGlobalConfig as loadGlobalConfig11,
|
|
9332
|
+
resolveActiveEnv as resolveActiveEnv5
|
|
9544
9333
|
} from "@hcmai/sdk";
|
|
9545
|
-
|
|
9546
|
-
|
|
9547
|
-
|
|
9548
|
-
|
|
9549
|
-
|
|
9550
|
-
|
|
9551
|
-
|
|
9552
|
-
|
|
9553
|
-
|
|
9554
|
-
|
|
9555
|
-
|
|
9556
|
-
|
|
9557
|
-
|
|
9558
|
-
|
|
9559
|
-
|
|
9560
|
-
|
|
9561
|
-
|
|
9562
|
-
|
|
9563
|
-
const
|
|
9564
|
-
|
|
9565
|
-
|
|
9566
|
-
|
|
9567
|
-
|
|
9568
|
-
detail: `\u8FD9\u4E2A\u76EE\u5F55\u91CC\u6CA1\u6709 ${ENV_FILE}\uFF0C\u4E0D\u662F\u777F\u620E\u9879\u76EE\u4ED3\uFF08\u6216\u8FD8\u6CA1\u521D\u59CB\u5316\uFF09`,
|
|
9569
|
-
nextStep: "\u65B0\u4ED3\uFF1Ahcm login <\u5730\u5740> --code <\u914D\u5BF9\u7801> \u540E hcm chiron init\uFF1B\u5DF2\u6709\u4ED3\uFF1A\u786E\u8BA4 clone \u7684\u662F\u5BF9\u7684\u4ED3\u3001\u7AD9\u5728\u4ED3\u6839\u76EE\u5F55"
|
|
9570
|
-
});
|
|
9571
|
-
return finish(report);
|
|
9572
|
-
}
|
|
9573
|
-
let env3;
|
|
9574
|
-
try {
|
|
9575
|
-
env3 = parseEnvYaml(envText);
|
|
9576
|
-
} catch (e) {
|
|
9577
|
-
report.lines.push({ item: "\u767B\u5F55", verdict: "fail", detail: e.message, nextStep: `\u6309 hcm chiron init \u751F\u6210\u7684\u4E09\u884C\u5F62\u6001\u4FEE ${ENV_FILE}` });
|
|
9578
|
-
return finish(report);
|
|
9579
|
-
}
|
|
9580
|
-
report.env = env3;
|
|
9581
|
-
const found = await findEnvByEndpoint(env3.endpoint, env3.tenant);
|
|
9582
|
-
const loginCmd = `hcm login ${env3.endpoint} --code <\u914D\u5BF9\u7801>`;
|
|
9583
|
-
if (!found) {
|
|
9584
|
-
report.lines.push({ item: "\u767B\u5F55", verdict: "fail", detail: `\u672C\u673A\u6CA1\u6709\u767B\u5F55\u8FC7 ${env3.endpoint}`, nextStep: loginCmd });
|
|
9585
|
-
} else {
|
|
9586
|
-
report.envName = found.name;
|
|
9587
|
-
try {
|
|
9588
|
-
const targetEnv = args.env ?? found.name;
|
|
9589
|
-
const { report: anchors, tokenTenant } = await deps.anchors(targetEnv, env3.tenant, args.as);
|
|
9590
|
-
report.anchors = anchors;
|
|
9591
|
-
const tenantMismatch = tokenTenant && tokenTenant !== env3.tenant;
|
|
9592
|
-
const bad = anchors.checks.filter((c) => !c.ok && !(tenantMismatch && c.anchor === "identity"));
|
|
9593
|
-
if (bad.length === 0 && !tenantMismatch) {
|
|
9594
|
-
const who = found.config.defaultIdentity ? ` \xB7 ${found.config.defaultIdentity}` : "";
|
|
9595
|
-
report.lines.push({ item: "\u767B\u5F55", verdict: "ok", detail: `${found.name} \xB7 ${env3.endpoint} \xB7 \u79DF\u6237 ${env3.tenant}${who}` });
|
|
9596
|
-
} else {
|
|
9597
|
-
const parts = [`${found.name} \xB7 ${env3.endpoint}`];
|
|
9598
|
-
if (tenantMismatch) parts.push(`\u4F60\u7684\u767B\u5F55\u8EAB\u4EFD\u5C5E\u4E8E\u79DF\u6237 ${tokenTenant}\uFF0C\u9879\u76EE\u662F\u79DF\u6237 ${env3.tenant}`);
|
|
9599
|
-
if (bad.length) parts.push(`\u951A\u70B9\u672A\u8FC7\uFF1A${bad.map((c) => `${c.anchor}\uFF08${c.detail}\uFF09`).join("\u3001")}`);
|
|
9600
|
-
report.lines.push({
|
|
9601
|
-
item: "\u767B\u5F55",
|
|
9602
|
-
verdict: "fail",
|
|
9603
|
-
detail: parts.join("\uFF1B"),
|
|
9604
|
-
nextStep: tenantMismatch ? `${loginCmd}\uFF08\u7528\u9879\u76EE\u79DF\u6237\u7684\u914D\u5BF9\u7801\uFF09` : "\u6309\u4E0A\u9762\u951A\u70B9\u7684\u63D0\u793A\u5904\u7406\uFF1B\u8EAB\u4EFD\u8FC7\u671F\u5C31\u91CD\u65B0 " + loginCmd
|
|
9605
|
-
});
|
|
9606
|
-
}
|
|
9607
|
-
} catch (e) {
|
|
9608
|
-
const msg = e instanceof CliError23 ? e.message : e.message;
|
|
9609
|
-
report.lines.push({ item: "\u767B\u5F55", verdict: "fail", detail: `${found.name} \xB7 ${env3.endpoint}\uFF1A${msg}`, nextStep: loginCmd });
|
|
9610
|
-
}
|
|
9611
|
-
}
|
|
9612
|
-
const skillsLine = async () => {
|
|
9613
|
-
const state = await readSkillsState(path10.join(root, SKILLS_DIR));
|
|
9614
|
-
if (!state) return { item: "\u6280\u80FD", verdict: "fail", detail: `${SKILLS_DIR}/ \u91CC\u6CA1\u6709\u5B89\u88C5\u6E05\u5355`, nextStep: "hcm chiron doctor --fix\uFF08\u6216 hcm chiron init\uFF09" };
|
|
9615
|
-
const count = Object.keys(state.skills).length;
|
|
9616
|
-
if (state.endpoint && normalizeOrigin(state.endpoint) !== env3.endpoint) {
|
|
9617
|
-
return { item: "\u6280\u80FD", verdict: "fail", detail: `${count} \u4E2A\uFF0C\u4F46\u88C5\u81EA ${state.endpoint}\uFF0C\u4E0D\u662F\u9879\u76EE\u73AF\u5883 ${env3.endpoint}`, nextStep: "hcm chiron doctor --fix \u91CD\u88C5" };
|
|
9618
|
-
}
|
|
9619
|
-
if (state.target !== "codex") {
|
|
9620
|
-
return { item: "\u6280\u80FD", verdict: "warn", detail: `${count} \u4E2A\uFF0C\u5E03\u5C40\u662F ${state.target}\uFF08Codex \u8981\u8BFB AGENTS.md \u7D22\u5F15\uFF09`, nextStep: "hcm skills install --all --target codex" };
|
|
9621
|
-
}
|
|
9622
|
-
return { item: "\u6280\u80FD", verdict: "ok", detail: `${count} \u4E2A\uFF0C\u6765\u81EA ${state.endpoint ?? "\u672C\u5730"}${state.all ? "\uFF0C\u8DDF\u968F\u5168\u96C6" : ""}` };
|
|
9623
|
-
};
|
|
9624
|
-
let skills2 = await skillsLine();
|
|
9625
|
-
if (skills2.verdict === "fail" && args.fix && report.envName) {
|
|
9626
|
-
await deps.fixSkills(root, report.envName);
|
|
9627
|
-
skills2 = await skillsLine();
|
|
9628
|
-
}
|
|
9629
|
-
report.lines.push(skills2);
|
|
9630
|
-
const casesLine = async () => {
|
|
9631
|
-
const c = await deps.inspectCases();
|
|
9632
|
-
if (!c.cloned) return { item: "\u6848\u4F8B\u5E93", verdict: "warn", detail: `\u672A clone\uFF08${c.repo}\uFF09`, nextStep: "hcm chiron doctor --fix\uFF1B\u6CA1\u6709 cnb \u6743\u9650\u5C31\u5148\u8DF3\u8FC7\uFF0C\u63D0\u4EA4\u6848\u4F8B/\u7F3A\u53E3\u65F6\u4F1A\u63D0\u793A" };
|
|
9633
|
-
if (!c.serverInstalled) return { item: "\u6848\u4F8B\u5E93", verdict: "warn", detail: "MCP \u4F9D\u8D56\u6CA1\u88C5", nextStep: "hcm chiron doctor --fix" };
|
|
9634
|
-
if (!c.codexWired) return { item: "\u6848\u4F8B\u5E93", verdict: "warn", detail: "Codex \u6CA1\u63A5\u7EBF\uFF08~/.codex/config.toml \u7F3A [mcp_servers.chiron-cases]\uFF09", nextStep: "hcm chiron doctor --fix" };
|
|
9635
|
-
return { item: "\u6848\u4F8B\u5E93", verdict: "ok", detail: `\u5DF2\u63A5\u5165 Codex\uFF08${c.repo}\uFF09` };
|
|
9636
|
-
};
|
|
9637
|
-
let cases = await casesLine();
|
|
9638
|
-
if (cases.verdict !== "ok" && args.fix && report.envName) {
|
|
9639
|
-
await deps.fixCases(report.envName);
|
|
9640
|
-
cases = await casesLine();
|
|
9334
|
+
init_exit();
|
|
9335
|
+
import { createJiraClient } from "@hcmai/sdk";
|
|
9336
|
+
|
|
9337
|
+
// src/jira/gaps.ts
|
|
9338
|
+
import { CASES_REPO_SLUG, repoIssueUrl } from "@hcmai/sdk";
|
|
9339
|
+
import { linkedRepoRefs, parseRef } from "@hcmai/sdk";
|
|
9340
|
+
var MIN_LEN = [
|
|
9341
|
+
["title", 8],
|
|
9342
|
+
["phenomenon", 20],
|
|
9343
|
+
["repro", 10],
|
|
9344
|
+
["expected", 10],
|
|
9345
|
+
["alternative", 5],
|
|
9346
|
+
["q_mechanism", 10],
|
|
9347
|
+
["q_history", 10],
|
|
9348
|
+
["q_skill", 10]
|
|
9349
|
+
];
|
|
9350
|
+
function validateGapInput(x) {
|
|
9351
|
+
if (!x || typeof x !== "object") throw new Error("\u7F3A\u53E3\u8F7D\u8377\u5FC5\u987B\u662F\u4E00\u4E2A JSON \u5BF9\u8C61");
|
|
9352
|
+
const g = x;
|
|
9353
|
+
const problems = [];
|
|
9354
|
+
for (const [k, min] of MIN_LEN) {
|
|
9355
|
+
const v = g[k];
|
|
9356
|
+
if (typeof v !== "string" || v.trim().length < min) problems.push(`${k} \u81F3\u5C11 ${min} \u4E2A\u5B57`);
|
|
9641
9357
|
}
|
|
9642
|
-
|
|
9643
|
-
|
|
9644
|
-
|
|
9645
|
-
|
|
9646
|
-
)
|
|
9647
|
-
|
|
9358
|
+
if (typeof g.title === "string" && g.title.length > 80) problems.push("title \u4E0D\u8D85\u8FC7 80 \u4E2A\u5B57");
|
|
9359
|
+
if (!["\u963B\u65AD", "\u6709\u66FF\u4EE3\u6CD5", "\u63AA\u8F9E\u7EA7"].includes(String(g.severity))) problems.push("severity \u53EA\u80FD\u662F \u963B\u65AD / \u6709\u66FF\u4EE3\u6CD5 / \u63AA\u8F9E\u7EA7");
|
|
9360
|
+
if (!["\u7F3A\u9677", "\u7F3A\u80FD\u529B"].includes(String(g.kind))) problems.push("kind \u53EA\u80FD\u662F \u7F3A\u9677\uFF08\u6545\u969C\uFF09/ \u7F3A\u80FD\u529B\uFF08\u9700\u6C42\uFF09");
|
|
9361
|
+
if (g.module !== void 0 && !["HCM-Core", "HCM-Cloud", "\u4EA7\u54C1\u652F\u6301"].includes(String(g.module))) problems.push("module \u53EA\u80FD\u662F HCM-Core / HCM-Cloud / \u4EA7\u54C1\u652F\u6301");
|
|
9362
|
+
if (problems.length) throw new Error(`\u7F3A\u53E3\u8F7D\u8377\u4E0D\u5408\u683C\uFF0C\u6CA1\u6709\u63D0\uFF1A
|
|
9363
|
+
${problems.join("\n ")}`);
|
|
9364
|
+
return g;
|
|
9648
9365
|
}
|
|
9649
|
-
|
|
9650
|
-
|
|
9651
|
-
|
|
9366
|
+
var gapKeyTag = (g) => `\u3014${[g.model, g.action, g.error_code].filter(Boolean).join("\xB7") || "-"}\u3015`;
|
|
9367
|
+
var gapSummary = (g) => `\u7F3A\u53E3\uFF1A${g.title} ${gapKeyTag(g)}`;
|
|
9368
|
+
function renderGapDescription(g, fingerprintText2) {
|
|
9369
|
+
return [
|
|
9370
|
+
"h2. \u73B0\u8C61",
|
|
9371
|
+
g.phenomenon,
|
|
9372
|
+
"",
|
|
9373
|
+
"h2. \u590D\u73B0",
|
|
9374
|
+
"{code}",
|
|
9375
|
+
g.repro,
|
|
9376
|
+
"{code}",
|
|
9377
|
+
"",
|
|
9378
|
+
"h2. \u671F\u671B",
|
|
9379
|
+
g.expected,
|
|
9380
|
+
"",
|
|
9381
|
+
"h2. \u73AF\u5883\u6307\u7EB9",
|
|
9382
|
+
fingerprintText2,
|
|
9383
|
+
"",
|
|
9384
|
+
"h2. \u66FF\u4EE3\u6CD5",
|
|
9385
|
+
g.alternative,
|
|
9386
|
+
"",
|
|
9387
|
+
"h2. \u4E25\u91CD\u5EA6",
|
|
9388
|
+
`${g.severity}\uFF08\u987E\u95EE\u4FA7\u5224\u5B9A\uFF1A\u963B\u65AD=\u4EA4\u4ED8\u505C\u4E0B / \u6709\u66FF\u4EE3\u6CD5=\u80FD\u7ED5 / \u63AA\u8F9E\u7EA7=\u8F93\u51FA\u5DF2\u7ED9\u8DEF\u6807\uFF09`,
|
|
9389
|
+
"",
|
|
9390
|
+
"h2. \u4E09\u95EE\u81EA\u7B54",
|
|
9391
|
+
`# \u673A\u5236\u8FB9\u754C\uFF1A${g.q_mechanism}`,
|
|
9392
|
+
`# \u5386\u53F2\uFF1A${g.q_history}`,
|
|
9393
|
+
`# \u6280\u80FD\u6709\u6CA1\u6709\u6559\u9519\uFF1A${g.q_skill}`,
|
|
9394
|
+
"",
|
|
9395
|
+
"h2. \u5173\u952E\u8BCD",
|
|
9396
|
+
[g.error_code, g.model, g.action].filter(Boolean).join(" \xB7 ") || "\uFF08\u65E0\uFF09",
|
|
9397
|
+
"",
|
|
9398
|
+
"_\u7531\u987E\u95EE agent \u7ECF `hcm chiron gap submit` \u63D0\u4EA4\u3002\u5206\u8BCA\u4E09\u53BB\u5411\uFF1A\u8F6C\u4EA7\u54C1\u4ED3 issue \u5E76\u56DE\u94FE / \u6539\u6280\u80FD\u5E76\u56DE\u590D / \u5408\u5E76\u8BA1\u6570\u3002\u5904\u7406\u529E\u6CD5\u89C1\u4EA7\u54C1\u4ED3\u6280\u80FD jira-triage\u3002_"
|
|
9399
|
+
].join("\n");
|
|
9652
9400
|
}
|
|
9653
|
-
function
|
|
9654
|
-
const
|
|
9655
|
-
|
|
9656
|
-
|
|
9657
|
-
|
|
9658
|
-
|
|
9401
|
+
function findDuplicateGap(open, summary, keyTag) {
|
|
9402
|
+
const bigrams = (t) => {
|
|
9403
|
+
const x = (t || "").replace(/〔.*?〕/g, "").replace(/[\s,。::、()()「」]/g, "");
|
|
9404
|
+
const out = /* @__PURE__ */ new Set();
|
|
9405
|
+
for (let i = 0; i + 1 < x.length; i++) out.add(x.slice(i, i + 2));
|
|
9406
|
+
return out;
|
|
9407
|
+
};
|
|
9408
|
+
const sim = (a, b) => {
|
|
9409
|
+
const A = bigrams(a);
|
|
9410
|
+
const B = bigrams(b);
|
|
9411
|
+
if (!A.size || !B.size) return 0;
|
|
9412
|
+
let n = 0;
|
|
9413
|
+
for (const s of A) if (B.has(s)) n++;
|
|
9414
|
+
return n / Math.min(A.size, B.size);
|
|
9415
|
+
};
|
|
9416
|
+
for (const i of open) {
|
|
9417
|
+
const t = i.fields.summary ?? "";
|
|
9418
|
+
if (keyTag !== "\u3014-\u3015" && t.includes(keyTag)) return i;
|
|
9419
|
+
if (sim(t, summary) >= 0.6) return i;
|
|
9659
9420
|
}
|
|
9660
|
-
|
|
9661
|
-
out.push(report.ok ? "\u53EF\u4EE5\u5F00\u5DE5\uFF1A\u5728\u8FD9\u4E2A\u76EE\u5F55\u91CC\u542F\u52A8 codex\u3002" : "\u5148\u6309 \u2192 \u5904\u7406\u7EA2\u9879\uFF0C\u518D\u8DD1\u4E00\u6B21 hcm chiron doctor\u3002");
|
|
9662
|
-
return out.join("\n");
|
|
9421
|
+
return null;
|
|
9663
9422
|
}
|
|
9664
|
-
|
|
9665
|
-
|
|
9666
|
-
|
|
9667
|
-
|
|
9668
|
-
|
|
9669
|
-
|
|
9670
|
-
|
|
9671
|
-
|
|
9672
|
-
|
|
9673
|
-
|
|
9674
|
-
|
|
9675
|
-
|
|
9676
|
-
|
|
9677
|
-
init_exit();
|
|
9678
|
-
import { spawnSync as spawnSync2 } from "child_process";
|
|
9679
|
-
import { promises as fs12 } from "fs";
|
|
9680
|
-
import path11 from "path";
|
|
9681
|
-
import yaml from "js-yaml";
|
|
9682
|
-
import { formatObject as formatObject23 } from "@hcmai/sdk";
|
|
9683
|
-
|
|
9684
|
-
// src/commands/delivery-action-policy.ts
|
|
9685
|
-
init_auth_guard();
|
|
9686
|
-
import { HcmClient as HcmClient22, classifyEffect } from "@hcmai/sdk";
|
|
9687
|
-
|
|
9688
|
-
// src/commands/delivery.ts
|
|
9689
|
-
import { createHash as createHash5 } from "crypto";
|
|
9690
|
-
var APPROVAL_BYPASS_FLAGS = /* @__PURE__ */ new Set(["-y", "--yes", "--force", "--auto-approve"]);
|
|
9691
|
-
var CREDENTIAL_FLAGS = /* @__PURE__ */ new Set([
|
|
9692
|
-
"--password",
|
|
9693
|
-
"--password-stdin",
|
|
9694
|
-
"--client-secret",
|
|
9695
|
-
"--pat",
|
|
9696
|
-
"--pat-stdin",
|
|
9697
|
-
"--new-password",
|
|
9698
|
-
"--new-password-stdin"
|
|
9699
|
-
]);
|
|
9700
|
-
var PAYLOAD_FLAGS = ["--data", "--params"];
|
|
9701
|
-
var GUARDED_EXECUTOR_REASON_CODES = /* @__PURE__ */ new Set([
|
|
9702
|
-
"record-create",
|
|
9703
|
-
"record-update",
|
|
9704
|
-
"cache-mutation",
|
|
9705
|
-
"setting-write",
|
|
9706
|
-
"credential-reset",
|
|
9707
|
-
"action-write",
|
|
9708
|
-
// 三态 effect 的 UNKNOWN / 未识别值都按最坏情况视作写操作,走与 WRITES
|
|
9709
|
-
// 完全相同的 prepare + execute 通道。分类函数已经返回 R2 guarded;这里漏登记
|
|
9710
|
-
// 会把 guardedExecutionAvailable 又翻回 false,造成 reason 与 modePolicy 自相矛盾。
|
|
9711
|
-
"action-effect-undetermined",
|
|
9712
|
-
"action-effect-unrecognized",
|
|
9713
|
-
"workspace-create",
|
|
9714
|
-
"workspace-activate",
|
|
9715
|
-
"workspace-deactivate",
|
|
9716
|
-
// bind / add mini / rm 都是受控本地工作区变更;rm 暂存删除,push 再执行远端 DELETE。
|
|
9717
|
-
"workspace-local-change",
|
|
9718
|
-
// 这两个的载荷是**任意文件 / 整棵目录**,此前刻意不收——绑不住就意味着
|
|
9719
|
-
// 「批准时看到的内容」与「执行时实际读到的内容」可以不同。
|
|
9720
|
-
//
|
|
9721
|
-
// 现在绑得住了:PAYLOAD_FILE_FLAGS 收了 --file,PAYLOAD_DIR_FLAGS 收了 --dir
|
|
9722
|
-
// (workspace push 不传 --dir 时按其 option 默认值 '.' 隐式绑定),
|
|
9723
|
-
// 目录按「路径 + 内容、排序稳定」整树摘要,assertPayloadsUnchanged 执行前逐一重算比对。
|
|
9724
|
-
//
|
|
9725
|
-
// 🔴 二次开发的整条链就卡在这两个上:2026-09-01 轨道 A 第四轮验收,
|
|
9726
|
-
// 受控执行第一次跑通了 workspace create,却在 meta set / workspace push 上
|
|
9727
|
-
// 被「该 R2 命令不在首批受控执行器支持面」拦死,远端只多了一个空 workspace。
|
|
9728
|
-
"metadata-write",
|
|
9729
|
-
"workspace-push",
|
|
9730
|
-
// 载荷是**位置参数**(`hcm import <路径>`),既不走 --file 也不走 --dir,
|
|
9731
|
-
// 所以上一刀把文件与目录开关收进来时它仍留在外面(0.4.9 CHANGELOG 逐字记了这一条)。
|
|
9732
|
-
//
|
|
9733
|
-
// 现在收得住了:POSITIONAL_PAYLOAD_COMMANDS 把 argv[1] 这个固定位置钉成载荷,
|
|
9734
|
-
// 目录走整树摘要、单文件走文件摘要,execute 前重算比对(与 --dir 同一套 bind/assert)。
|
|
9735
|
-
// 位置定死而不是「扫第一个非 flag 参数」,是因为 shape 校验与载荷绑定必须对
|
|
9736
|
-
// 「哪个 token 是载荷」看法一致——两处各自解析就能绑 A 执行 B。
|
|
9737
|
-
//
|
|
9738
|
-
// 🔴 客户存量组织导入的整条链就卡在这一个上:2026-09-01 演示环境租户 15,
|
|
9739
|
-
// 531 条组织机构 dry-run 全绿(静态校验 0 失败),正式导入被
|
|
9740
|
-
// 「该 R2 命令不在首批受控执行器支持面」拦死,一个写请求都没发出去。
|
|
9741
|
-
"import-write",
|
|
9742
|
-
// 报表 / 套打模板回传要先 upload 拿 documentId,再挂到业务对象。文件路径是
|
|
9743
|
-
// 固定位置参数,prepare 会钉住项目内普通文件的摘要,execute 前重算后才单次执行。
|
|
9744
|
-
// 2026-09-02 弹性报表顾问仿真已证实这条交付链会在缺受控执行器时中断。
|
|
9745
|
-
"document-upload"
|
|
9746
|
-
]);
|
|
9747
|
-
function normalizeAssessedArgv(inputArgv) {
|
|
9748
|
-
let rest = inputArgv;
|
|
9749
|
-
const dropSeparators = () => {
|
|
9750
|
-
let start = 0;
|
|
9751
|
-
while (rest[start] === "--") start += 1;
|
|
9752
|
-
rest = start > 0 ? rest.slice(start) : rest;
|
|
9753
|
-
};
|
|
9754
|
-
dropSeparators();
|
|
9755
|
-
if (PACKAGE_RUNNERS.has(rest[0] ?? "") && isCliLauncher(rest[1])) {
|
|
9756
|
-
rest = rest.slice(2);
|
|
9757
|
-
} else if (isCliLauncher(rest[0])) {
|
|
9758
|
-
rest = rest.slice(1);
|
|
9759
|
-
}
|
|
9760
|
-
dropSeparators();
|
|
9761
|
-
return rest === inputArgv ? [...inputArgv] : rest;
|
|
9762
|
-
}
|
|
9763
|
-
var PACKAGE_RUNNERS = /* @__PURE__ */ new Set(["npx", "bunx", "pnpx"]);
|
|
9764
|
-
function isCliLauncher(token) {
|
|
9765
|
-
if (!token || token.startsWith("-")) return false;
|
|
9766
|
-
if (token === "@hcmai/cli") return true;
|
|
9767
|
-
const base = token.split(/[\\/]/).pop() ?? token;
|
|
9768
|
-
return base === "hcm" || base === "hcm.js" || base === "hcmai";
|
|
9769
|
-
}
|
|
9770
|
-
function assessDeliveryCommand(inputArgv, options = {}) {
|
|
9771
|
-
const argv = normalizeAssessedArgv(inputArgv);
|
|
9772
|
-
const commandSha256 = sha2564(JSON.stringify(argv));
|
|
9773
|
-
const name = argv[0] ?? "";
|
|
9774
|
-
const subcommand = argv[1] && !argv[1].startsWith("-") ? argv[1] : void 0;
|
|
9775
|
-
const envAlias = flagValue(argv, "--env");
|
|
9776
|
-
const identityAlias = flagValue(argv, "--as");
|
|
9777
|
-
const sensitiveFlags = [
|
|
9778
|
-
...new Set([...PAYLOAD_FLAGS, ...CREDENTIAL_FLAGS].filter((flag) => hasFlag(argv, flag)))
|
|
9779
|
-
];
|
|
9780
|
-
const target = summarizeTarget(argv, options.actionResolution);
|
|
9781
|
-
let classification = classify(argv, options.actionResolution);
|
|
9782
|
-
const invalidPayload = payloadError(argv);
|
|
9783
|
-
if (invalidPayload) {
|
|
9784
|
-
classification = forbidden("invalid-input", "JSON payload \u65E0\u6548\uFF0C\u4E0D\u80FD\u8FDB\u5165\u4EFB\u4F55\u6267\u884C\u8DEF\u5F84\u3002");
|
|
9785
|
-
}
|
|
9786
|
-
const requirements = [];
|
|
9787
|
-
const guardedExecutionAvailable = classification.risk === "R2" && GUARDED_EXECUTOR_REASON_CODES.has(classification.reasonCode);
|
|
9788
|
-
if (classification.risk === "R2") {
|
|
9789
|
-
if (!envAlias) requirements.push("explicit-env");
|
|
9790
|
-
if (!identityAlias) requirements.push("explicit-identity");
|
|
9791
|
-
if (guardedExecutionAvailable) {
|
|
9792
|
-
requirements.push("change-plan", "rollback-plan", "human-approval", "single-use-plan");
|
|
9793
|
-
} else {
|
|
9794
|
-
requirements.push("guarded-executor");
|
|
9795
|
-
}
|
|
9796
|
-
} else if (classification.risk === "R3") {
|
|
9797
|
-
requirements.push("governance-escalation");
|
|
9423
|
+
var KIND_TO_TYPE = { \u7F3A\u9677: ["\u6545\u969C", "Bug", "\u7F3A\u9677"], \u7F3A\u80FD\u529B: ["\u9700\u6C42", "Story", "New Feature"] };
|
|
9424
|
+
var KIND_TO_CATEGORY = { \u7F3A\u9677: "\u7A0B\u5E8FBug", \u7F3A\u80FD\u529B: "\u9700\u6C42" };
|
|
9425
|
+
var SEVERITY_TO_PRIORITY = {
|
|
9426
|
+
\u963B\u65AD: ["\u7D27\u6025", "Highest", "High", "\u9AD8"],
|
|
9427
|
+
\u6709\u66FF\u4EE3\u6CD5: ["Medium", "\u4E2D", "\u4E00\u822C", "High"],
|
|
9428
|
+
\u63AA\u8F9E\u7EA7: ["Low", "\u4F4E", "Lowest"]
|
|
9429
|
+
};
|
|
9430
|
+
var MODULE_DEFAULT_CHILD = { "HCM-Core": "\u57FA\u7840\u8BBE\u7F6E", "HCM-Cloud": "\u5F00\u53D1\u5E73\u53F0", \u4EA7\u54C1\u652F\u6301: "\u4EA7\u54C1\u652F\u6301" };
|
|
9431
|
+
function buildGapFields(g, ctx) {
|
|
9432
|
+
const wanted = KIND_TO_TYPE[g.kind] ?? [];
|
|
9433
|
+
const type = ctx.issuetypeOverride && ctx.types.find((t) => t.name === ctx.issuetypeOverride) || wanted.map((n) => ctx.types.find((t) => t.name === n)).find(Boolean);
|
|
9434
|
+
if (!type) {
|
|
9435
|
+
throw new Error(`\u9879\u76EE ${ctx.project} \u91CC\u6CA1\u6709\u300C${wanted.join(" / ")}\u300D\u8FD9\u7C7B issuetype\uFF0C\u5B9E\u9645\u6709\uFF1A${ctx.types.map((t) => t.name).join(" / ")}`);
|
|
9798
9436
|
}
|
|
9799
|
-
const
|
|
9800
|
-
|
|
9801
|
-
|
|
9802
|
-
|
|
9803
|
-
|
|
9804
|
-
|
|
9805
|
-
|
|
9806
|
-
|
|
9807
|
-
|
|
9808
|
-
|
|
9809
|
-
|
|
9810
|
-
|
|
9811
|
-
|
|
9812
|
-
},
|
|
9813
|
-
target,
|
|
9814
|
-
requirements,
|
|
9815
|
-
evidenceRequirements: evidenceFor(classification.risk),
|
|
9816
|
-
sensitiveFlags,
|
|
9817
|
-
modePolicy: {
|
|
9818
|
-
planOnly: allowed ? "allow" : "deny",
|
|
9819
|
-
controlled: allowed || guardedExecutionAvailable ? "allow" : "deny"
|
|
9820
|
-
}
|
|
9437
|
+
const module = g.module ?? "HCM-Core";
|
|
9438
|
+
const keyTag = gapKeyTag(g);
|
|
9439
|
+
const byName = {
|
|
9440
|
+
\u6982\u8981: gapSummary(g),
|
|
9441
|
+
\u63CF\u8FF0: renderGapDescription(g, ctx.fingerprintText),
|
|
9442
|
+
\u95EE\u9898\u7C7B\u522B: KIND_TO_CATEGORY[g.kind],
|
|
9443
|
+
\u95EE\u9898\u6A21\u5757: module,
|
|
9444
|
+
\u4F18\u5148\u7EA7: SEVERITY_TO_PRIORITY[g.severity],
|
|
9445
|
+
\u62A5\u544A\u4EBA: ctx.me,
|
|
9446
|
+
\u7ECF\u529E\u4EBA: ctx.assignee,
|
|
9447
|
+
Bug\u53D1\u73B0\u4EBA: "\u987E\u95EE",
|
|
9448
|
+
Bug\u91CD\u73B0\u64CD\u4F5C\u6B65\u9AA4: g.repro,
|
|
9449
|
+
Bug\u9519\u8BEF\u53F7: g.error_code || "\u65E0\u9519\u8BEF\u7801\uFF08\u73B0\u8C61\u89C1\u63CF\u8FF0\uFF09"
|
|
9821
9450
|
};
|
|
9822
|
-
}
|
|
9823
|
-
|
|
9824
|
-
const
|
|
9825
|
-
const
|
|
9826
|
-
|
|
9827
|
-
|
|
9828
|
-
|
|
9829
|
-
|
|
9830
|
-
|
|
9831
|
-
}
|
|
9832
|
-
if (argv.some((arg) => APPROVAL_BYPASS_FLAGS.has(flagName(arg)))) {
|
|
9833
|
-
return forbidden("approval-bypass", "\u547D\u4EE4\u5305\u542B\u8DF3\u8FC7\u786E\u8BA4\u7684\u65D7\u6807\uFF0C\u987E\u95EE\u4EA4\u4ED8\u9762\u4E0D\u6267\u884C\u3002");
|
|
9834
|
-
}
|
|
9835
|
-
if (name === "user" && subcommand === "reset-password") {
|
|
9836
|
-
const nonStdinCredential = argv.some((arg) => {
|
|
9837
|
-
const flag = flagName(arg);
|
|
9838
|
-
return CREDENTIAL_FLAGS.has(flag) && flag !== "--password-stdin";
|
|
9839
|
-
});
|
|
9840
|
-
if (nonStdinCredential || !argv.includes("--password-stdin")) {
|
|
9841
|
-
return forbidden(
|
|
9842
|
-
"credential-governance",
|
|
9843
|
-
"\u7528\u6237\u5BC6\u7801\u91CD\u7F6E\u53EA\u80FD\u901A\u8FC7 --password-stdin \u8FDB\u5165\u53D7\u63A7\u51ED\u636E\u6D41\u7A0B\u3002"
|
|
9844
|
-
);
|
|
9845
|
-
}
|
|
9846
|
-
return guarded("credential-write", "credential-reset");
|
|
9847
|
-
}
|
|
9848
|
-
if (argv.some((arg) => CREDENTIAL_FLAGS.has(flagName(arg)))) {
|
|
9849
|
-
return forbidden("credential-governance", "\u547D\u4EE4\u643A\u5E26\u8EAB\u4EFD\u51ED\u636E\u53C2\u6570\uFF0C\u5FC5\u987B\u8F6C\u4EA4\u8EAB\u4EFD\u6CBB\u7406\u6D41\u7A0B\u3002");
|
|
9850
|
-
}
|
|
9851
|
-
if (name === "version") return direct("R0", "product-discovery", "product-discovery");
|
|
9852
|
-
if (name === "open") return direct("R1", "remote-read", "browser-session-open");
|
|
9853
|
-
if (name === "models") return direct("R0", "product-discovery", "model-discovery");
|
|
9854
|
-
if (name === "config") {
|
|
9855
|
-
if (["list", "show", "get"].includes(subcommand))
|
|
9856
|
-
return direct("R0", "local-discovery", "config-read");
|
|
9857
|
-
return forbidden(
|
|
9858
|
-
"identity-governance",
|
|
9859
|
-
"\u4FEE\u6539\u672C\u673A\u5168\u5C40\u914D\u7F6E\u4F1A\u6539\u53D8\u540E\u7EED\u6240\u6709\u547D\u4EE4\u7684\u73AF\u5883\u4E0E\u8EAB\u4EFD\uFF0C\u5C5E\u6CBB\u7406\u64CD\u4F5C\u3002"
|
|
9860
|
-
);
|
|
9861
|
-
}
|
|
9862
|
-
if (name === "upgrade" || name === "self-update") {
|
|
9863
|
-
return direct("R1", "managed-local-write", "cli-self-upgrade");
|
|
9864
|
-
}
|
|
9865
|
-
if (name === "datapackage") {
|
|
9866
|
-
if (subcommand === "pack") return direct("R1", "local-validation", "datapackage-pack");
|
|
9867
|
-
if (subcommand === "status") return direct("R1", "remote-read", "datapackage-status");
|
|
9868
|
-
if (subcommand === "install") return guarded("tenant-data-write", "datapackage-install");
|
|
9869
|
-
return forbidden("unknown-command", "\u672A\u77E5 datapackage \u5B50\u547D\u4EE4\u6309\u6700\u9AD8\u98CE\u9669\u5173\u95ED\u3002");
|
|
9870
|
-
}
|
|
9871
|
-
if (name === "mini") {
|
|
9872
|
-
return forbidden("removed-command", "`hcm mini` \u5DF2\u79FB\u9664\uFF0C\u6539\u7528 `hcm workspace`\u3002");
|
|
9873
|
-
}
|
|
9874
|
-
if (name === "chiron") {
|
|
9875
|
-
if (subcommand === "doctor") return direct("R0", "local-discovery", "chiron-doctor");
|
|
9876
|
-
if (subcommand === "init") return direct("R1", "managed-local-write", "chiron-project-scaffold");
|
|
9877
|
-
if (subcommand === "test") return direct("R1", "remote-read", "chiron-regression-test");
|
|
9878
|
-
return forbidden("unknown-command", "\u672A\u77E5 chiron \u5B50\u547D\u4EE4\u6309\u6700\u9AD8\u98CE\u9669\u5173\u95ED\u3002");
|
|
9879
|
-
}
|
|
9880
|
-
if (name === "jira") {
|
|
9881
|
-
if (["probe", "open", "show", "audit", "search", "status"].includes(subcommand)) {
|
|
9882
|
-
return direct("R1", "remote-read", "jira-read");
|
|
9883
|
-
}
|
|
9884
|
-
if (["comment", "assign", "move", "to-issue", "sync", "verify-pass", "verify-fail", "submit"].includes(subcommand)) {
|
|
9885
|
-
return direct("R1", "external-tracker-write", "jira-tracker-write");
|
|
9886
|
-
}
|
|
9887
|
-
return forbidden("unknown-command", "\u672A\u77E5 jira \u5B50\u547D\u4EE4\u6309\u6700\u9AD8\u98CE\u9669\u5173\u95ED\u3002");
|
|
9888
|
-
}
|
|
9889
|
-
if (name === "skills") {
|
|
9890
|
-
if (subcommand === "list" || subcommand === "show") {
|
|
9891
|
-
return direct("R0", "product-discovery", "skill-discovery");
|
|
9892
|
-
}
|
|
9893
|
-
if (subcommand === "sync" || subcommand === "install") {
|
|
9894
|
-
return direct("R1", "managed-local-write", "skill-managed-write");
|
|
9895
|
-
}
|
|
9896
|
-
return forbidden("unknown-command", "\u672A\u77E5 skills \u5B50\u547D\u4EE4\u6309\u6700\u9AD8\u98CE\u9669\u5173\u95ED\u3002");
|
|
9897
|
-
}
|
|
9898
|
-
if (name === "env") {
|
|
9899
|
-
if (subcommand === "list" || subcommand === "current" || subcommand === "show") {
|
|
9900
|
-
return direct("R0", "local-discovery", "environment-read");
|
|
9901
|
-
}
|
|
9902
|
-
return forbidden("identity-governance", "\u73AF\u5883\u65B0\u589E\u3001\u5207\u6362\u3001\u7F16\u8F91\u6216\u5220\u9664\u5C5E\u4E8E\u6CBB\u7406\u64CD\u4F5C\u3002");
|
|
9903
|
-
}
|
|
9904
|
-
if (name === "identity") {
|
|
9905
|
-
if (subcommand === "list") return direct("R0", "local-discovery", "identity-read");
|
|
9906
|
-
return forbidden("identity-governance", "\u8EAB\u4EFD\u5207\u6362\u6216\u5220\u9664\u5C5E\u4E8E\u6CBB\u7406\u64CD\u4F5C\u3002");
|
|
9907
|
-
}
|
|
9908
|
-
if (name === "query" || name === "describe" || name === "trace") {
|
|
9909
|
-
return direct("R1", "remote-read", "business-read");
|
|
9910
|
-
}
|
|
9911
|
-
if (name === "cache") {
|
|
9912
|
-
if (subcommand === "stats") return direct("R1", "remote-read", "cache-read");
|
|
9913
|
-
if (subcommand === "clear" || subcommand === "clear-meta") {
|
|
9914
|
-
return guarded("operational-write", "cache-mutation");
|
|
9915
|
-
}
|
|
9916
|
-
}
|
|
9917
|
-
if (name === "meta") {
|
|
9918
|
-
if (subcommand === "list" || subcommand === "get") {
|
|
9919
|
-
return direct("R1", "remote-read", "metadata-read");
|
|
9920
|
-
}
|
|
9921
|
-
if (subcommand === "set" && hasFlag(argv, "--dry-run")) {
|
|
9922
|
-
return direct("R1", "local-validation", "metadata-dry-run");
|
|
9923
|
-
}
|
|
9924
|
-
if (subcommand === "set") return guarded("tenant-config-write", "metadata-write");
|
|
9925
|
-
if (subcommand === "delete") return forbidden("destructive", "\u5143\u6570\u636E\u5220\u9664\u4E0D\u53EF\u7531\u987E\u95EE\u63D2\u4EF6\u6267\u884C\u3002");
|
|
9926
|
-
}
|
|
9927
|
-
if (name === "setting") {
|
|
9928
|
-
if (subcommand === "get") return direct("R1", "remote-read", "setting-read");
|
|
9929
|
-
if (subcommand === "set" && hasFlag(argv, "--dry-run")) {
|
|
9930
|
-
return direct("R1", "local-validation", "setting-dry-run");
|
|
9931
|
-
}
|
|
9932
|
-
if (subcommand === "set" || subcommand === "reset") {
|
|
9933
|
-
return guarded("tenant-config-write", "setting-write");
|
|
9934
|
-
}
|
|
9935
|
-
}
|
|
9936
|
-
if (name === "workspace") {
|
|
9937
|
-
if (subcommand === "push" && hasFlag(argv, "--dry-run")) {
|
|
9938
|
-
return direct("R1", "remote-read", "workspace-push-dry-run");
|
|
9939
|
-
}
|
|
9940
|
-
if (["list", "active", "status", "validate", "verify", "preview"].includes(subcommand)) {
|
|
9941
|
-
return direct("R1", "remote-read", "workspace-read");
|
|
9942
|
-
}
|
|
9943
|
-
if (subcommand === "pull") {
|
|
9944
|
-
return direct("R1", "managed-local-write", "workspace-pull");
|
|
9945
|
-
}
|
|
9946
|
-
if (subcommand === "bind" || subcommand === "add" && argv[2] === "mini") {
|
|
9947
|
-
return guarded("managed-local-write", "workspace-local-change");
|
|
9948
|
-
}
|
|
9949
|
-
if (subcommand === "rm") return guarded("managed-local-write", "workspace-local-change");
|
|
9950
|
-
if (subcommand === "create") return guarded("tenant-write", "workspace-create");
|
|
9951
|
-
if (subcommand === "activate") return guarded("tenant-write", "workspace-activate");
|
|
9952
|
-
if (subcommand === "deactivate") return guarded("tenant-write", "workspace-deactivate");
|
|
9953
|
-
if (subcommand === "push") return guarded("tenant-write", "workspace-push");
|
|
9954
|
-
if (["deploy", "release", "promote", "publish"].includes(subcommand)) {
|
|
9955
|
-
return forbidden("publish", "\u90E8\u7F72\u5230 active \u5C5E\u4E8E R3\uFF0C\u987B\u8D70\u53D1\u5E03\u4E0E\u5BA1\u6279\u94FE\u8DEF\u3002");
|
|
9451
|
+
const fields = { project: { key: ctx.project }, issuetype: { id: type.id } };
|
|
9452
|
+
const unfilled = [];
|
|
9453
|
+
const values = (f) => (f.allowedValues ?? []).map((v) => v.value ?? v.name).join("|");
|
|
9454
|
+
for (const f of type.fields ?? []) {
|
|
9455
|
+
if (["project", "issuetype"].includes(f.fieldId)) continue;
|
|
9456
|
+
const want = byName[f.name];
|
|
9457
|
+
if (want === void 0) {
|
|
9458
|
+
if (f.required) unfilled.push(`${f.name}(${f.fieldId})${f.allowedValues ? `=[${values(f)}]` : ""}`);
|
|
9459
|
+
continue;
|
|
9956
9460
|
}
|
|
9957
|
-
|
|
9958
|
-
|
|
9959
|
-
|
|
9960
|
-
|
|
9461
|
+
if (f.schema?.type === "option-with-child") {
|
|
9462
|
+
const parent = (f.allowedValues ?? []).find((v) => (v.value ?? v.name) === want);
|
|
9463
|
+
if (!parent) {
|
|
9464
|
+
if (f.required) unfilled.push(`${f.name}(${f.fieldId}) \u60F3\u586B\u300C${String(want)}\u300D\u4F46\u53EF\u9009\u503C\u53EA\u6709 [${values(f)}]`);
|
|
9465
|
+
continue;
|
|
9466
|
+
}
|
|
9467
|
+
const childName = g.module_detail || MODULE_DEFAULT_CHILD[module];
|
|
9468
|
+
const child = (parent.children ?? []).find((c) => (c.value ?? c.name) === childName);
|
|
9469
|
+
if (!child && (parent.children ?? []).length) {
|
|
9470
|
+
unfilled.push(`${f.name}(${f.fieldId}) \u7684\u4E8C\u7EA7\u9879\u300C${childName}\u300D\u4E0D\u5728 [${(parent.children ?? []).map((c) => c.value ?? c.name).join("|")}] \u91CC`);
|
|
9471
|
+
continue;
|
|
9472
|
+
}
|
|
9473
|
+
fields[f.fieldId] = { id: parent.id, ...child ? { child: { id: child.id } } : {} };
|
|
9474
|
+
continue;
|
|
9961
9475
|
}
|
|
9962
|
-
|
|
9963
|
-
|
|
9964
|
-
|
|
9965
|
-
|
|
9476
|
+
if (f.allowedValues) {
|
|
9477
|
+
const candidates = Array.isArray(want) ? want : [want];
|
|
9478
|
+
const hit = candidates.map((c) => f.allowedValues.find((v) => (v.name ?? v.value) === c)).find(Boolean);
|
|
9479
|
+
if (!hit) {
|
|
9480
|
+
if (f.required) unfilled.push(`${f.name}(${f.fieldId}) \u60F3\u586B\u300C${candidates.join("/")}\u300D\u4F46\u53EF\u9009\u503C\u53EA\u6709 [${values(f)}]`);
|
|
9481
|
+
continue;
|
|
9482
|
+
}
|
|
9483
|
+
fields[f.fieldId] = hit.id ? { id: hit.id } : { name: hit.name ?? hit.value };
|
|
9484
|
+
} else if (f.schema?.type === "user") {
|
|
9485
|
+
if (!want) {
|
|
9486
|
+
if (f.required) unfilled.push(`${f.name}(${f.fieldId}) \u53D6\u4E0D\u5230\u7528\u6237\u540D`);
|
|
9487
|
+
continue;
|
|
9488
|
+
}
|
|
9489
|
+
fields[f.fieldId] = { name: Array.isArray(want) ? want[0] : want };
|
|
9490
|
+
} else {
|
|
9491
|
+
fields[f.fieldId] = Array.isArray(want) ? want[0] : want;
|
|
9966
9492
|
}
|
|
9967
|
-
return guarded("bulk-tenant-write", "import-write");
|
|
9968
9493
|
}
|
|
9969
|
-
if (
|
|
9970
|
-
|
|
9494
|
+
if ((type.fields ?? []).some((f) => f.fieldId === "labels")) {
|
|
9495
|
+
const sev = { \u963B\u65AD: "blocking", \u6709\u66FF\u4EE3\u6CD5: "workaround", \u63AA\u8F9E\u7EA7: "wording" }[g.severity];
|
|
9496
|
+
fields.labels = ["chiron-gap", `severity-${sev}`];
|
|
9971
9497
|
}
|
|
9972
|
-
if (
|
|
9973
|
-
|
|
9974
|
-
|
|
9975
|
-
|
|
9976
|
-
|
|
9977
|
-
}
|
|
9978
|
-
if (actionResolution?.status === "failed") {
|
|
9979
|
-
return forbidden(actionResolution.reasonCode, actionResolution.reason);
|
|
9980
|
-
}
|
|
9981
|
-
return forbidden(
|
|
9982
|
-
"action-effect-unclassified",
|
|
9983
|
-
"\u5C1A\u672A\u8BFB\u53D6 Core Action \u98CE\u63A7\u58F0\u660E\uFF0C\u4E0D\u80FD\u6309\u540D\u79F0\u731C\u6D4B\u540E\u653E\u884C\u3002"
|
|
9498
|
+
if (unfilled.length) {
|
|
9499
|
+
throw new Error(
|
|
9500
|
+
`\u8FD9\u53F0 Jira \u7684\u300C${type.name}\u300D\u6709\u6211\u586B\u4E0D\u4E0A\u7684\u5FC5\u586B\u5B57\u6BB5\uFF0C\u6CA1\u6709\u5EFA\u5355\uFF08\u4E0D\u66FF\u4F60\u731C\uFF09\uFF1A
|
|
9501
|
+
${unfilled.join("\n ")}
|
|
9502
|
+
next_step=\u8BA9 Jira \u7BA1\u7406\u5458\u628A\u8FD9\u4E9B\u5B57\u6BB5\u6539\u6210\u975E\u5FC5\u586B\uFF0C\u6216\u544A\u8BC9\u6211\u8BE5\u586B\u4EC0\u4E48\u3001\u6211\u52A0\u8FDB\u6620\u5C04\u3002\u53F0\u8D26\u5DF2\u7ECF\u5728\u9879\u76EE\u4ED3\u91CC\uFF0C\u4E0D\u4F1A\u4E22\u3002`
|
|
9984
9503
|
);
|
|
9985
9504
|
}
|
|
9986
|
-
|
|
9987
|
-
return forbidden("destructive", "\u5220\u9664\u64CD\u4F5C\u4E0D\u8FDB\u5165\u987E\u95EE\u63D2\u4EF6\u6267\u884C\u9762\u3002");
|
|
9988
|
-
}
|
|
9989
|
-
if (name === "tenant") {
|
|
9990
|
-
return forbidden("tenant-governance", "\u79DF\u6237\u5F00\u901A\u6216\u6CBB\u7406\u5FC5\u987B\u5347\u7EA7\u6CBB\u7406\u4EBA\u5458\u3002");
|
|
9991
|
-
}
|
|
9992
|
-
if (name === "login" || name === "logout") {
|
|
9993
|
-
return forbidden("identity-governance", "\u767B\u5F55\u4E0E\u767B\u51FA\u5C5E\u4E8E\u8EAB\u4EFD\u6CBB\u7406\u64CD\u4F5C\u3002");
|
|
9994
|
-
}
|
|
9995
|
-
if (name === "chat") {
|
|
9996
|
-
return forbidden("agent-autonomy", "\u987E\u95EE\u63D2\u4EF6\u4E0D\u901A\u8FC7\u5D4C\u5957\u6570\u5B57\u5458\u5DE5\u5BF9\u8BDD\u6269\u5927\u81EA\u6CBB\u6267\u884C\u9762\u3002");
|
|
9997
|
-
}
|
|
9998
|
-
return forbidden(
|
|
9999
|
-
"unknown-command",
|
|
10000
|
-
`\u672A\u77E5\u547D\u4EE4\u6309\u6700\u9AD8\u98CE\u9669\u5173\u95ED\uFF1A\u89E3\u6790\u5230\u7684\u547D\u4EE4\u662F ${name || "(\u7A7A)"}` + (subcommand ? ` ${subcommand}` : "") + "\u3002next_step=\u7528 `hcm --help` \u6838\u5BF9\u547D\u4EE4\u540D\uFF1B\u82E5\u4F60\u786E\u4FE1\u8FD9\u6761\u547D\u4EE4\u5B58\u5728\uFF0C\u5148\u8DD1 `hcm upgrade` \u770B CLI \u662F\u4E0D\u662F\u65E7\u7248\uFF08\u98CE\u63A7\u8868\u968F CLI \u53D1\u5E03\u66F4\u65B0\uFF09"
|
|
10001
|
-
);
|
|
9505
|
+
return { fields, type, keyTag, summary: gapSummary(g), module: `${module}/${g.module_detail || MODULE_DEFAULT_CHILD[module]}` };
|
|
10002
9506
|
}
|
|
10003
|
-
function
|
|
10004
|
-
const
|
|
10005
|
-
const
|
|
10006
|
-
const
|
|
10007
|
-
|
|
10008
|
-
|
|
9507
|
+
async function gapSubmit({ client: client3 }, g, { fingerprintText: fingerprintText2, issuetypeOverride, assigneeOverride }) {
|
|
9508
|
+
const summary = gapSummary(g);
|
|
9509
|
+
const keyTag = gapKeyTag(g);
|
|
9510
|
+
const open = await client3.search(`project = ${client3.project} AND resolution = Unresolved ORDER BY created DESC`, { max: 100 });
|
|
9511
|
+
const dup = findDuplicateGap(open, summary, keyTag);
|
|
9512
|
+
if (dup) {
|
|
9513
|
+
const body = `\u53C8\u4E00\u4E2A\u73B0\u573A\uFF08${fingerprintText2}\uFF09
|
|
9514
|
+
|
|
9515
|
+
**\u73B0\u8C61**\uFF1A${g.phenomenon}
|
|
9516
|
+
|
|
9517
|
+
**\u590D\u73B0**\uFF1A
|
|
9518
|
+
{code}
|
|
9519
|
+
${g.repro}
|
|
9520
|
+
{code}
|
|
9521
|
+
|
|
9522
|
+
**\u66FF\u4EE3\u6CD5**\uFF1A${g.alternative}
|
|
9523
|
+
\u4E25\u91CD\u5EA6\uFF1A${g.severity}`;
|
|
9524
|
+
await client3.addComment(dup.key, body);
|
|
9525
|
+
return { outcome: "appended", key: dup.key, url: client3.browseUrl(dup.key), summary: dup.fields.summary ?? "", alternative: g.alternative };
|
|
10009
9526
|
}
|
|
10010
|
-
|
|
10011
|
-
|
|
10012
|
-
|
|
10013
|
-
|
|
9527
|
+
const [types, me, project] = await Promise.all([client3.createMeta(), client3.myself(), client3.projectInfo()]);
|
|
9528
|
+
const built = buildGapFields(g, {
|
|
9529
|
+
types,
|
|
9530
|
+
me: me.name ?? me.key ?? "",
|
|
9531
|
+
assignee: assigneeOverride || project.lead?.name || project.lead?.key,
|
|
9532
|
+
project: client3.project,
|
|
9533
|
+
fingerprintText: fingerprintText2,
|
|
9534
|
+
issuetypeOverride
|
|
9535
|
+
});
|
|
9536
|
+
const created = await client3.createIssue(built.fields);
|
|
9537
|
+
return { outcome: "created", key: created.key, url: client3.browseUrl(created.key), summary: built.summary, type: built.type.name, module: built.module, alternative: g.alternative };
|
|
9538
|
+
}
|
|
9539
|
+
async function gapSearch({ client: client3 }, keywords, { includeClosed = true } = {}) {
|
|
9540
|
+
const rows = [];
|
|
9541
|
+
let jiraError;
|
|
9542
|
+
try {
|
|
9543
|
+
for (const kw of keywords) {
|
|
9544
|
+
const safe = kw.replace(/["\\]/g, " ").trim();
|
|
9545
|
+
const jql = `project = ${client3.project} AND text ~ "${safe}"${includeClosed ? "" : " AND resolution = Unresolved"} ORDER BY updated DESC`;
|
|
9546
|
+
for (const i of await client3.search(jql, { max: 15 })) {
|
|
9547
|
+
rows.push({ where: "Jira", id: i.key, title: i.fields.summary ?? "", state: i.fields.status?.name, resolution: i.fields.resolution?.name, url: client3.browseUrl(i.key) });
|
|
9548
|
+
}
|
|
9549
|
+
}
|
|
9550
|
+
if (!rows.length) {
|
|
9551
|
+
const open = await client3.search(`project = ${client3.project} AND resolution = Unresolved ORDER BY created DESC`, { max: 100 });
|
|
9552
|
+
for (const i of open) {
|
|
9553
|
+
if (keywords.some((k) => (i.fields.summary ?? "").includes(k))) {
|
|
9554
|
+
rows.push({ where: "Jira", id: i.key, title: i.fields.summary ?? "", state: i.fields.status?.name, url: client3.browseUrl(i.key) });
|
|
9555
|
+
}
|
|
9556
|
+
}
|
|
10014
9557
|
}
|
|
9558
|
+
} catch (e) {
|
|
9559
|
+
jiraError = e.message;
|
|
10015
9560
|
}
|
|
10016
|
-
|
|
10017
|
-
|
|
10018
|
-
|
|
10019
|
-
|
|
10020
|
-
|
|
9561
|
+
const seen = /* @__PURE__ */ new Set();
|
|
9562
|
+
return { rows: rows.filter((r) => seen.has(r.id) ? false : (seen.add(r.id), true)), jiraError };
|
|
9563
|
+
}
|
|
9564
|
+
async function gapStatus({ client: client3 }, ref, casesSlug = CASES_REPO_SLUG) {
|
|
9565
|
+
const parsed = parseRef(ref, client3.project, casesSlug);
|
|
9566
|
+
if (!parsed) throw new Error(`\u770B\u4E0D\u61C2 ${ref}\uFF1A\u7ED9 Jira \u5355\u53F7\uFF08HCMNX-12\uFF09`);
|
|
9567
|
+
if (parsed.kind === "repo") {
|
|
9568
|
+
throw new Error(
|
|
9569
|
+
`${parsed.repo}#${parsed.number} \u662F\u4EA7\u54C1\u4ED3\u7F16\u53F7\uFF0C\u987E\u95EE\u4FA7\u67E5\u4E0D\u5230\u5B83\u7684\u72B6\u6001\uFF08\u6CA1\u6709\u90A3\u4E2A\u4ED3\u7684\u8BFB\u6743\u9650\uFF09\u3002next_step=\u7528 Jira \u5355\u53F7\u67E5\uFF08HCMNX-12\uFF09\u3002\u4EA7\u54C1\u4FA7\u7684\u8FDB\u5C55\u4F1A\u56DE\u5199\u5230 Jira \u5355\u4E0A\uFF0C\u90A3\u662F\u4EA7\u54C1\u5BF9\u5916\u7684\u7EDF\u4E00\u9762\u3002`
|
|
9570
|
+
);
|
|
10021
9571
|
}
|
|
10022
|
-
|
|
10023
|
-
|
|
10024
|
-
|
|
10025
|
-
|
|
9572
|
+
const issue = await client3.issue(parsed.key);
|
|
9573
|
+
const cs = await client3.comments(parsed.key);
|
|
9574
|
+
const status = issue.fields.status?.name;
|
|
9575
|
+
const resolution = issue.fields.resolution?.name;
|
|
9576
|
+
const lines = [`Jira ${issue.key} [${status}${resolution ? "\xB7" + resolution : ""}${issue.fields.priority ? " " + issue.fields.priority.name : ""}] ${issue.fields.summary ?? ""}`, ` ${client3.browseUrl(issue.key)}`];
|
|
9577
|
+
const keyComments = cs.filter((c) => /分诊|已转|已修|合入|不做|重复|改技能|产品侧|代码库已关闭/.test(c.body ?? ""));
|
|
9578
|
+
const last = (keyComments.length ? keyComments : cs).at(-1);
|
|
9579
|
+
if (last) lines.push(` \u6700\u65B0\u5904\u7406\uFF08${String(last.created ?? "").slice(0, 10)} ${last.author?.displayName ?? "?"}\uFF09\uFF1A${(last.body ?? "").split("\n").find((l) => l.trim()) ?? ""}`.slice(0, 400));
|
|
9580
|
+
else lines.push(" \u8FD8\u6CA1\u6709\u4EBA\u5904\u7406\uFF08\u4EA7\u54C1\u4FA7\u6BCF\u5468\u6E05\u4E00\u6B21\uFF1B\u963B\u65AD\u7EA7\u8BF7\u5728\u9879\u76EE\u7FA4\u91CC\u70B9\u540D\u8D1F\u8D23\u4EBA\uFF09");
|
|
9581
|
+
const remote = (await client3.remoteLinks(parsed.key)).map((l) => l.object?.url ?? "").join("\n");
|
|
9582
|
+
const links = linkedRepoRefs(`${remote}
|
|
9583
|
+
${issue.fields.description ?? ""}
|
|
9584
|
+
${cs.map((c) => c.body ?? "").join("\n")}`).map((l) => ({
|
|
9585
|
+
...l,
|
|
9586
|
+
url: repoIssueUrl(l.repo, l.number)
|
|
9587
|
+
}));
|
|
9588
|
+
for (const p of links) lines.push(`\u5DF2\u767B\u8BB0\u4EE3\u7801\u5E93\u6761\u76EE ${p.repo}#${p.number}`, ` ${p.url}`);
|
|
9589
|
+
let nextStep;
|
|
9590
|
+
if (resolution) nextStep = "Jira \u8FD9\u5355\u5DF2\u89E3\u51B3\u3002\u76EE\u6807\u73AF\u5883\u90E8\u7F72\u5230\u542B\u4FEE\u590D\u7684\u7248\u672C\u540E\uFF08`hcm version` \u7684 commit \u4F1A\u53D8\uFF09\uFF0C\u8DD1 `hcm skills update`\uFF0C\u518D\u6309\u6280\u80FD\u590D\u9A8C\u4E00\u6B21\u3002";
|
|
9591
|
+
else if (status === "\u5DF2\u4FEE\u590D") nextStep = "\u4FEE\u590D\u5DF2\u5408\u5165\u3001\u8FD8\u6CA1\u53D1\u5230\u4F60\u7684\u73AF\u5883\u3002\u7EE7\u7EED\u7528\u66FF\u4EE3\u6CD5\uFF0C\u53D1\u5E03\u540E\u590D\u9A8C\u3002";
|
|
9592
|
+
else if (links.length) nextStep = "\u5DF2\u5206\u8BCA\u3001\u4EE3\u7801\u5E93\u5DF2\u767B\u8BB0\uFF0C\u8FD8\u5728\u505A\u3002\u7EE7\u7EED\u7528\u66FF\u4EE3\u6CD5\uFF1B\u60F3\u8981\u6392\u671F\u5C31\u5728 Jira \u8FD9\u5355\u4E0B\u7559\u8A00\u3002";
|
|
9593
|
+
else nextStep = `\u7B49\u5206\u8BCA\u3002\u5148\u6309\u66FF\u4EE3\u6CD5\u7EE7\u7EED\u4EA4\u4ED8\uFF0C\u62A5\u544A\u5199 BLOCKED \xB7 \u5DF2\u63D0 ${issue.key}\u3002`;
|
|
9594
|
+
return { ref, lines, nextStep, jira: { key: issue.key, status, resolution, url: client3.browseUrl(issue.key) }, links };
|
|
9595
|
+
}
|
|
9596
|
+
|
|
9597
|
+
// src/commands/gap.ts
|
|
9598
|
+
var defaultDeps = { client: () => createJiraClient() };
|
|
9599
|
+
async function gapDeps(deps) {
|
|
9600
|
+
return { client: await deps.client() };
|
|
9601
|
+
}
|
|
9602
|
+
function emit4(fmt, data, text) {
|
|
9603
|
+
if (fmt === "json" || fmt === "yaml") process.stdout.write(formatObject22(data, { format: fmt }) + "\n");
|
|
9604
|
+
else process.stdout.write(text() + "\n");
|
|
9605
|
+
}
|
|
9606
|
+
async function run(fn) {
|
|
9607
|
+
try {
|
|
9608
|
+
await fn();
|
|
9609
|
+
} catch (e) {
|
|
9610
|
+
exitWithError(e);
|
|
10026
9611
|
}
|
|
10027
|
-
|
|
10028
|
-
|
|
10029
|
-
|
|
10030
|
-
|
|
10031
|
-
|
|
10032
|
-
|
|
10033
|
-
|
|
10034
|
-
|
|
9612
|
+
}
|
|
9613
|
+
async function gapSearchCommand(keywords, args, deps = defaultDeps) {
|
|
9614
|
+
await run(async () => {
|
|
9615
|
+
if (!keywords.length) throw new Error("\u7ED9\u81F3\u5C11\u4E00\u4E2A\u5173\u952E\u8BCD\uFF1A\u9519\u8BEF\u7801 / Model / Action / \u4E00\u53E5\u73B0\u8C61");
|
|
9616
|
+
const r = await gapSearch(await gapDeps(deps), keywords, { includeClosed: args.includeClosed !== false });
|
|
9617
|
+
emit4(args.output, r, () => {
|
|
9618
|
+
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
|
|
9619
|
+
` : "";
|
|
9620
|
+
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`;
|
|
9621
|
+
return `${head}\u547D\u4E2D ${r.rows.length} \u6761\uFF08\u540C\u4E00\u7F3A\u53E3\u5DF2\u6709\u7F16\u53F7\u5C31\u5728\u90A3\u6761\u4E0B\u8FFD\u52A0\u73B0\u573A\uFF0C\u4E0D\u65B0\u5F00\uFF09\uFF1A
|
|
9622
|
+
${r.rows.map((i) => `${i.where} ${i.id} [${i.state}${i.resolution ? "\xB7" + i.resolution : ""}] ${i.title}
|
|
9623
|
+
${i.url}`).join("\n")}`;
|
|
9624
|
+
});
|
|
9625
|
+
});
|
|
9626
|
+
}
|
|
9627
|
+
async function gapStatusCommand(ref, args, deps = defaultDeps) {
|
|
9628
|
+
await run(async () => {
|
|
9629
|
+
const r = await gapStatus(await gapDeps(deps), ref);
|
|
9630
|
+
emit4(args.output, r, () => [...r.lines, `\u4E0B\u4E00\u6B65\uFF1A${r.nextStep}`].join("\n"));
|
|
9631
|
+
});
|
|
9632
|
+
}
|
|
9633
|
+
async function fingerprintText(env2) {
|
|
9634
|
+
try {
|
|
9635
|
+
const g = await loadGlobalConfig11();
|
|
9636
|
+
const name = resolveActiveEnv5({ envFlag: env2 }, process.env, g);
|
|
9637
|
+
const cfg = await loadEnv11(name);
|
|
9638
|
+
if (!cfg?.endpoint) return `\u672A\u53D6\u5230\u6307\u7EB9\uFF08env=${name}\uFF1A\u6CA1\u6709 endpoint\uFF09`;
|
|
9639
|
+
const http = createHttpClient4({ endpoint: cfg.endpoint.replace(/\/+$/, ""), getAccessToken: async () => null, onRefresh: async () => {
|
|
9640
|
+
} });
|
|
9641
|
+
const resp = await http.get("/api/version/backend");
|
|
9642
|
+
const info = resp.data?.data ?? resp.data ?? {};
|
|
9643
|
+
const commit = info.commit ?? info.gitCommit ?? info.version ?? "?";
|
|
9644
|
+
return `backend ${String(commit).slice(0, 12)} \xB7 CLI ${CLI_VERSION} \xB7 env ${name}`;
|
|
9645
|
+
} catch (e) {
|
|
9646
|
+
return `\u672A\u53D6\u5230\u6307\u7EB9\uFF08env=${env2 ?? "\u672A\u8BBE"}\uFF1B${String(e.message ?? e).split("\n")[0]?.slice(0, 120)}\uFF09`;
|
|
9647
|
+
}
|
|
9648
|
+
}
|
|
9649
|
+
async function gapSubmitCommand(args, deps = defaultDeps) {
|
|
9650
|
+
await run(async () => {
|
|
9651
|
+
const raw = args.file ? readFileSync5(args.file, "utf8") : process.stdin.isTTY ? "" : readFileSync5(0, "utf8");
|
|
9652
|
+
if (!raw.trim()) throw new Error("\u7F3A\u53E3\u8F7D\u8377\uFF1A--file <gap.json> \u6216\u4ECE\u6807\u51C6\u8F93\u5165\u5582 JSON");
|
|
9653
|
+
const gap2 = validateGapInput(JSON.parse(raw));
|
|
9654
|
+
const fp = args.fingerprint ?? await fingerprintText(args.env);
|
|
9655
|
+
const r = await gapSubmit(await gapDeps(deps), gap2, { fingerprintText: fp, issuetypeOverride: args.issuetype, assigneeOverride: args.assignee });
|
|
9656
|
+
emit4(
|
|
9657
|
+
args.output,
|
|
9658
|
+
r,
|
|
9659
|
+
() => 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
|
|
9660
|
+
${r.url}
|
|
9661
|
+
\u7ED9\u987E\u95EE\u7684\u8BDD\uFF1A\u8FD9\u4E2A\u95EE\u9898\u5DF2\u7ECF\u5728\u4EA7\u54C1\u90A3\u8FB9\u6392\u7740\uFF0C\u7F16\u53F7 ${r.key}\uFF1B\u5148\u7528\u66FF\u4EE3\u6CD5\u300C${r.alternative}\u300D\u7EE7\u7EED\uFF0C\u5206\u8BCA\u7ED3\u8BBA\u4F1A\u56DE\u5230\u90A3\u5355\u91CC\u3002` : `\u5DF2\u63D0 ${r.key}\uFF08${r.type} \xB7 ${r.module}\uFF09\uFF1A${r.url}
|
|
9662
|
+
\u7ED9\u987E\u95EE\u7684\u8BDD\uFF1A\u7F3A\u53E3\u5DF2\u63D0\uFF0C\u7F16\u53F7 ${r.key}\uFF1B\u5148\u7528\u66FF\u4EE3\u6CD5\u300C${r.alternative}\u300D\u7EE7\u7EED\uFF0C\u4EA7\u54C1\u5206\u8BCA\u540E\u4F1A\u5728\u90A3\u5355\u91CC\u56DE\u590D\u3002\u62A5\u544A\u91CC\u5199\u300CBLOCKED \xB7 \u5DF2\u63D0 ${r.key} \xB7 \u66FF\u4EE3\u6CD5\uFF1A${r.alternative}\u300D\u3002`
|
|
9663
|
+
);
|
|
9664
|
+
});
|
|
9665
|
+
}
|
|
9666
|
+
|
|
9667
|
+
// src/commands/chiron-doctor.ts
|
|
9668
|
+
init_auth_guard();
|
|
9669
|
+
init_exit();
|
|
9670
|
+
import { promises as fs10 } from "fs";
|
|
9671
|
+
import path9 from "path";
|
|
9672
|
+
import {
|
|
9673
|
+
HcmClient as HcmClient21,
|
|
9674
|
+
CliError as CliError23,
|
|
9675
|
+
fetchReconIdentity as fetchReconIdentity2,
|
|
9676
|
+
formatObject as formatObject23,
|
|
9677
|
+
httpProbe as httpProbe2,
|
|
9678
|
+
runDoctor
|
|
9679
|
+
} from "@hcmai/sdk";
|
|
9680
|
+
var defaultDeps2 = {
|
|
9681
|
+
anchors: async (envName, tenant2, as) => {
|
|
9682
|
+
const ctx = await getActiveAuthContextFromCli({ env: envName, as });
|
|
9683
|
+
const client3 = HcmClient21.fromAuthContext(ctx);
|
|
9684
|
+
const probe = httpProbe2(client3.raw(), "default");
|
|
9685
|
+
const identity2 = await fetchReconIdentity2(probe, tenant2);
|
|
9686
|
+
return { report: await runDoctor(probe, identity2), tokenTenant: identity2?.tenantId ? String(identity2.tenantId) : void 0 };
|
|
9687
|
+
},
|
|
9688
|
+
fixSkills: (root, envName) => defaultChironInitDeps.installSkills(root, envName),
|
|
9689
|
+
fixCases: async (envName) => {
|
|
9690
|
+
await ensureCaseLibrary(envName);
|
|
9691
|
+
},
|
|
9692
|
+
inspectCases: () => inspectCaseLibrary(),
|
|
9693
|
+
inspectJira: () => inspectJira()
|
|
9694
|
+
};
|
|
9695
|
+
async function runChironDoctor(args, deps = defaultDeps2) {
|
|
9696
|
+
const root = path9.resolve(args.project ?? ".");
|
|
9697
|
+
const report = { ok: false, project: root, env: null, envName: null, lines: [] };
|
|
9698
|
+
const envText = await fs10.readFile(path9.join(root, ENV_FILE), "utf8").catch(() => null);
|
|
9699
|
+
if (envText === null) {
|
|
9700
|
+
report.lines.push({
|
|
9701
|
+
item: "\u767B\u5F55",
|
|
9702
|
+
verdict: "fail",
|
|
9703
|
+
detail: `\u8FD9\u4E2A\u76EE\u5F55\u91CC\u6CA1\u6709 ${ENV_FILE}\uFF0C\u4E0D\u662F\u777F\u620E\u9879\u76EE\u4ED3\uFF08\u6216\u8FD8\u6CA1\u521D\u59CB\u5316\uFF09`,
|
|
9704
|
+
nextStep: "\u65B0\u4ED3\uFF1Ahcm login <\u5730\u5740> --code <\u914D\u5BF9\u7801> \u540E hcm chiron init\uFF1B\u5DF2\u6709\u4ED3\uFF1A\u786E\u8BA4 clone \u7684\u662F\u5BF9\u7684\u4ED3\u3001\u7AD9\u5728\u4ED3\u6839\u76EE\u5F55"
|
|
9705
|
+
});
|
|
9706
|
+
return finish(report);
|
|
10035
9707
|
}
|
|
10036
|
-
|
|
10037
|
-
|
|
10038
|
-
|
|
10039
|
-
|
|
10040
|
-
|
|
10041
|
-
|
|
10042
|
-
if (isPlainObject(parsed)) target.fieldNames = Object.keys(parsed).sort();
|
|
10043
|
-
} catch {
|
|
10044
|
-
}
|
|
9708
|
+
let env2;
|
|
9709
|
+
try {
|
|
9710
|
+
env2 = parseEnvYaml(envText);
|
|
9711
|
+
} catch (e) {
|
|
9712
|
+
report.lines.push({ item: "\u767B\u5F55", verdict: "fail", detail: e.message, nextStep: `\u6309 hcm chiron init \u751F\u6210\u7684\u4E09\u884C\u5F62\u6001\u4FEE ${ENV_FILE}` });
|
|
9713
|
+
return finish(report);
|
|
10045
9714
|
}
|
|
10046
|
-
|
|
10047
|
-
|
|
10048
|
-
|
|
10049
|
-
|
|
10050
|
-
|
|
10051
|
-
|
|
9715
|
+
report.env = env2;
|
|
9716
|
+
const found = await findEnvByEndpoint(env2.endpoint, env2.tenant);
|
|
9717
|
+
const loginCmd = `hcm login ${env2.endpoint} --code <\u914D\u5BF9\u7801>`;
|
|
9718
|
+
if (!found) {
|
|
9719
|
+
report.lines.push({ item: "\u767B\u5F55", verdict: "fail", detail: `\u672C\u673A\u6CA1\u6709\u767B\u5F55\u8FC7 ${env2.endpoint}`, nextStep: loginCmd });
|
|
9720
|
+
} else {
|
|
9721
|
+
report.envName = found.name;
|
|
10052
9722
|
try {
|
|
10053
|
-
const
|
|
10054
|
-
|
|
10055
|
-
|
|
10056
|
-
|
|
9723
|
+
const targetEnv = args.env ?? found.name;
|
|
9724
|
+
const { report: anchors, tokenTenant } = await deps.anchors(targetEnv, env2.tenant, args.as);
|
|
9725
|
+
report.anchors = anchors;
|
|
9726
|
+
const tenantMismatch = tokenTenant && tokenTenant !== env2.tenant;
|
|
9727
|
+
const bad = anchors.checks.filter((c) => !c.ok && !(tenantMismatch && c.anchor === "identity"));
|
|
9728
|
+
if (bad.length === 0 && !tenantMismatch) {
|
|
9729
|
+
const who = found.config.defaultIdentity ? ` \xB7 ${found.config.defaultIdentity}` : "";
|
|
9730
|
+
report.lines.push({ item: "\u767B\u5F55", verdict: "ok", detail: `${found.name} \xB7 ${env2.endpoint} \xB7 \u79DF\u6237 ${env2.tenant}${who}` });
|
|
9731
|
+
} else {
|
|
9732
|
+
const parts = [`${found.name} \xB7 ${env2.endpoint}`];
|
|
9733
|
+
if (tenantMismatch) parts.push(`\u4F60\u7684\u767B\u5F55\u8EAB\u4EFD\u5C5E\u4E8E\u79DF\u6237 ${tokenTenant}\uFF0C\u9879\u76EE\u662F\u79DF\u6237 ${env2.tenant}`);
|
|
9734
|
+
if (bad.length) parts.push(`\u951A\u70B9\u672A\u8FC7\uFF1A${bad.map((c) => `${c.anchor}\uFF08${c.detail}\uFF09`).join("\u3001")}`);
|
|
9735
|
+
report.lines.push({
|
|
9736
|
+
item: "\u767B\u5F55",
|
|
9737
|
+
verdict: "fail",
|
|
9738
|
+
detail: parts.join("\uFF1B"),
|
|
9739
|
+
nextStep: tenantMismatch ? `${loginCmd}\uFF08\u7528\u9879\u76EE\u79DF\u6237\u7684\u914D\u5BF9\u7801\uFF09` : "\u6309\u4E0A\u9762\u951A\u70B9\u7684\u63D0\u793A\u5904\u7406\uFF1B\u8EAB\u4EFD\u8FC7\u671F\u5C31\u91CD\u65B0 " + loginCmd
|
|
9740
|
+
});
|
|
9741
|
+
}
|
|
9742
|
+
} catch (e) {
|
|
9743
|
+
const msg = e instanceof CliError23 ? e.message : e.message;
|
|
9744
|
+
report.lines.push({ item: "\u767B\u5F55", verdict: "fail", detail: `${found.name} \xB7 ${env2.endpoint}\uFF1A${msg}`, nextStep: loginCmd });
|
|
10057
9745
|
}
|
|
10058
9746
|
}
|
|
10059
|
-
|
|
10060
|
-
|
|
10061
|
-
|
|
10062
|
-
|
|
10063
|
-
|
|
10064
|
-
|
|
10065
|
-
|
|
10066
|
-
|
|
10067
|
-
|
|
10068
|
-
|
|
10069
|
-
}
|
|
10070
|
-
function guarded(effect, reasonCode) {
|
|
10071
|
-
return {
|
|
10072
|
-
risk: "R2",
|
|
10073
|
-
execution: "guarded",
|
|
10074
|
-
effect,
|
|
10075
|
-
reasonCode,
|
|
10076
|
-
reason: "\u666E\u901A\u526F\u4F5C\u7528\u64CD\u4F5C\uFF1B\u53EA\u5141\u8BB8\u5728 controlled \u9879\u76EE\u4E2D\u901A\u8FC7 delivery prepare + delivery execute \u5355\u6B21\u53D7\u63A7\u6267\u884C\u3002"
|
|
9747
|
+
const skillsLine = async () => {
|
|
9748
|
+
const state = await readSkillsState(path9.join(root, SKILLS_DIR));
|
|
9749
|
+
if (!state) return { item: "\u6280\u80FD", verdict: "fail", detail: `${SKILLS_DIR}/ \u91CC\u6CA1\u6709\u5B89\u88C5\u6E05\u5355`, nextStep: "hcm chiron doctor --fix\uFF08\u6216 hcm chiron init\uFF09" };
|
|
9750
|
+
const count = Object.keys(state.skills).length;
|
|
9751
|
+
if (state.endpoint && normalizeOrigin(state.endpoint) !== env2.endpoint) {
|
|
9752
|
+
return { item: "\u6280\u80FD", verdict: "fail", detail: `${count} \u4E2A\uFF0C\u4F46\u88C5\u81EA ${state.endpoint}\uFF0C\u4E0D\u662F\u9879\u76EE\u73AF\u5883 ${env2.endpoint}`, nextStep: "hcm chiron doctor --fix \u91CD\u88C5" };
|
|
9753
|
+
}
|
|
9754
|
+
if (state.target !== "codex") {
|
|
9755
|
+
return { item: "\u6280\u80FD", verdict: "warn", detail: `${count} \u4E2A\uFF0C\u5E03\u5C40\u662F ${state.target}\uFF08Codex \u8981\u8BFB AGENTS.md \u7D22\u5F15\uFF09`, nextStep: "hcm skills install --all --target codex" };
|
|
9756
|
+
}
|
|
9757
|
+
return { item: "\u6280\u80FD", verdict: "ok", detail: `${count} \u4E2A\uFF0C\u6765\u81EA ${state.endpoint ?? "\u672C\u5730"}${state.all ? "\uFF0C\u8DDF\u968F\u5168\u96C6" : ""}` };
|
|
10077
9758
|
};
|
|
10078
|
-
|
|
10079
|
-
|
|
10080
|
-
|
|
10081
|
-
|
|
10082
|
-
risk: "R1",
|
|
10083
|
-
execution: "direct",
|
|
10084
|
-
effect: "remote-read",
|
|
10085
|
-
reasonCode: "action-read-only",
|
|
10086
|
-
reason: "Core \u58F0\u660E\u8BE5 Action \u4E3A\u53EA\u8BFB\uFF0C\u4E0E Moirai \u7684\u53EA\u8BFB Action \u8DEF\u5F84\u4E00\u81F4\uFF0C\u53EF\u76F4\u63A5\u6267\u884C\u3002"
|
|
10087
|
-
};
|
|
10088
|
-
}
|
|
10089
|
-
if (policy.effect === "declared-unknown") {
|
|
10090
|
-
return {
|
|
10091
|
-
risk: "R2",
|
|
10092
|
-
execution: "guarded",
|
|
10093
|
-
effect: "undetermined",
|
|
10094
|
-
reasonCode: "action-effect-undetermined",
|
|
10095
|
-
reason: "\u4EA7\u54C1\u4FA7\u628A\u8FD9\u4E2A Action \u58F0\u660E\u6210 effect=UNKNOWN\uFF1A**\u6CA1\u4EBA\u5224\u8FC7**\u5B83\u5199\u4E0D\u5199\u5E93\u3002\u6309\u6700\u574F\u60C5\u51B5\u8D70\u53D7\u63A7\u6267\u884C\uFF08\u4E0E\u4F1A\u5199\u7684 Action \u540C\u4E00\u6761\u8DEF\u5F84\uFF09\uFF0C\u4F46\u5B83\u4E0D\u7B49\u4E8E\u300C\u786E\u8BA4\u4F1A\u5199\u300D\u3002next_step=\u53BB\u4EA7\u54C1\u4FA7\u7ED9\u8FD9\u4E2A @ClassAction/@ObjectAction \u628A effect \u5224\u6389\uFF08READ_ONLY / WRITES\uFF09\uFF0C\u800C\u4E0D\u662F\u5728 CLI \u8FD9\u8FB9\u653E\u5BBD\u3002"
|
|
10096
|
-
};
|
|
10097
|
-
}
|
|
10098
|
-
if (policy.effect === "unrecognized-effect") {
|
|
10099
|
-
return {
|
|
10100
|
-
risk: "R2",
|
|
10101
|
-
execution: "guarded",
|
|
10102
|
-
effect: "undetermined",
|
|
10103
|
-
reasonCode: "action-effect-unrecognized",
|
|
10104
|
-
reason: `Core \u9001\u6765\u7684 effect \u53D6\u503C ${describeEffectRaw(policy.effectRaw)} \u4E0D\u5728 READ_ONLY / WRITES / UNKNOWN \u4E09\u6001\u5185\uFF08\u62FC\u5199\u6F02\u79FB\uFF1F\u670D\u52A1\u7AEF\u6BD4\u672C CLI \u65B0\u3001\u591A\u4E86\u4E00\u6001\uFF1F\uFF09\u3002fail-closed\uFF1A\u6309 UNKNOWN \u5904\u7F6E\u8D70\u53D7\u63A7\u6267\u884C\uFF0C\u4E0D\u731C\u6210\u53EA\u8BFB\u3002next_step=\u62FF\u8FD9\u4E2A\u539F\u503C\u53BB\u5BF9\u4EA7\u54C1\u4FA7\u7684 ActionEffect \u5B9A\u4E49\uFF0C\u5FC5\u8981\u65F6\u5347\u7EA7 CLI\u3002`
|
|
10105
|
-
};
|
|
9759
|
+
let skills2 = await skillsLine();
|
|
9760
|
+
if (skills2.verdict === "fail" && args.fix && report.envName) {
|
|
9761
|
+
await deps.fixSkills(root, report.envName);
|
|
9762
|
+
skills2 = await skillsLine();
|
|
10106
9763
|
}
|
|
10107
|
-
|
|
10108
|
-
|
|
10109
|
-
|
|
10110
|
-
|
|
10111
|
-
|
|
10112
|
-
|
|
10113
|
-
return
|
|
10114
|
-
}
|
|
10115
|
-
|
|
9764
|
+
report.lines.push(skills2);
|
|
9765
|
+
const casesLine = async () => {
|
|
9766
|
+
const c = await deps.inspectCases();
|
|
9767
|
+
if (!c.cloned) return { item: "\u6848\u4F8B\u5E93", verdict: "warn", detail: `\u672A clone\uFF08${c.repo}\uFF09`, nextStep: "hcm chiron doctor --fix\uFF1B\u6CA1\u6709 cnb \u6743\u9650\u5C31\u5148\u8DF3\u8FC7\uFF0C\u63D0\u4EA4\u6848\u4F8B/\u7F3A\u53E3\u65F6\u4F1A\u63D0\u793A" };
|
|
9768
|
+
if (!c.serverInstalled) return { item: "\u6848\u4F8B\u5E93", verdict: "warn", detail: "MCP \u4F9D\u8D56\u6CA1\u88C5", nextStep: "hcm chiron doctor --fix" };
|
|
9769
|
+
if (!c.codexWired) return { item: "\u6848\u4F8B\u5E93", verdict: "warn", detail: "Codex \u6CA1\u63A5\u7EBF\uFF08~/.codex/config.toml \u7F3A [mcp_servers.chiron-cases]\uFF09", nextStep: "hcm chiron doctor --fix" };
|
|
9770
|
+
return { item: "\u6848\u4F8B\u5E93", verdict: "ok", detail: `\u5DF2\u63A5\u5165 Codex\uFF08${c.repo}\uFF09` };
|
|
9771
|
+
};
|
|
9772
|
+
let cases = await casesLine();
|
|
9773
|
+
if (cases.verdict !== "ok" && args.fix && report.envName) {
|
|
9774
|
+
await deps.fixCases(report.envName);
|
|
9775
|
+
cases = await casesLine();
|
|
10116
9776
|
}
|
|
9777
|
+
report.lines.push(cases);
|
|
9778
|
+
const jira = await deps.inspectJira();
|
|
9779
|
+
report.lines.push(
|
|
9780
|
+
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" }
|
|
9781
|
+
);
|
|
9782
|
+
return finish(report);
|
|
10117
9783
|
}
|
|
10118
|
-
function
|
|
10119
|
-
|
|
9784
|
+
function finish(report) {
|
|
9785
|
+
report.ok = report.lines.every((l) => l.verdict !== "fail");
|
|
9786
|
+
return report;
|
|
10120
9787
|
}
|
|
10121
|
-
function
|
|
10122
|
-
|
|
10123
|
-
|
|
10124
|
-
|
|
10125
|
-
|
|
10126
|
-
|
|
10127
|
-
"explicit-target-aliases",
|
|
10128
|
-
"pre-state-or-dry-run",
|
|
10129
|
-
"rollback-plan",
|
|
10130
|
-
"execution-receipt",
|
|
10131
|
-
"post-verification"
|
|
10132
|
-
];
|
|
9788
|
+
function renderChironDoctor(report) {
|
|
9789
|
+
const mark = { ok: "\u2705", warn: "\u26A0\uFE0F", fail: "\u274C" };
|
|
9790
|
+
const out = [];
|
|
9791
|
+
for (const l of report.lines) {
|
|
9792
|
+
out.push(`${mark[l.verdict]} ${l.item.padEnd(3, "\u3000")} ${l.detail}`);
|
|
9793
|
+
if (l.nextStep && l.verdict !== "ok") out.push(` \u2192 ${l.nextStep}`);
|
|
10133
9794
|
}
|
|
10134
|
-
|
|
9795
|
+
out.push("");
|
|
9796
|
+
out.push(report.ok ? "\u53EF\u4EE5\u5F00\u5DE5\uFF1A\u5728\u8FD9\u4E2A\u76EE\u5F55\u91CC\u542F\u52A8 codex\u3002" : "\u5148\u6309 \u2192 \u5904\u7406\u7EA2\u9879\uFF0C\u518D\u8DD1\u4E00\u6B21 hcm chiron doctor\u3002");
|
|
9797
|
+
return out.join("\n");
|
|
10135
9798
|
}
|
|
10136
|
-
function
|
|
10137
|
-
|
|
10138
|
-
const
|
|
10139
|
-
|
|
10140
|
-
if (
|
|
10141
|
-
|
|
9799
|
+
async function chironDoctorCommand(args, deps) {
|
|
9800
|
+
try {
|
|
9801
|
+
const report = await runChironDoctor(args, deps);
|
|
9802
|
+
const fmt = args.output ?? "table";
|
|
9803
|
+
if (fmt === "json" || fmt === "yaml") process.stdout.write(formatObject23(report, { format: fmt }) + "\n");
|
|
9804
|
+
else process.stdout.write(renderChironDoctor(report) + "\n");
|
|
9805
|
+
process.exitCode = report.ok ? 0 : 1;
|
|
9806
|
+
} catch (e) {
|
|
9807
|
+
exitWithError(e);
|
|
10142
9808
|
}
|
|
10143
|
-
return void 0;
|
|
10144
|
-
}
|
|
10145
|
-
function hasFlag(argv, flag) {
|
|
10146
|
-
return argv.some((arg) => arg === flag || arg.startsWith(`${flag}=`));
|
|
10147
|
-
}
|
|
10148
|
-
function flagName(arg) {
|
|
10149
|
-
const equals = arg.indexOf("=");
|
|
10150
|
-
return equals < 0 ? arg : arg.slice(0, equals);
|
|
10151
9809
|
}
|
|
10152
|
-
|
|
10153
|
-
|
|
10154
|
-
|
|
10155
|
-
|
|
10156
|
-
|
|
10157
|
-
|
|
10158
|
-
|
|
10159
|
-
|
|
9810
|
+
|
|
9811
|
+
// src/commands/chiron-test.ts
|
|
9812
|
+
init_exit();
|
|
9813
|
+
import { spawnSync as spawnSync2 } from "child_process";
|
|
9814
|
+
import { promises as fs11 } from "fs";
|
|
9815
|
+
import path10 from "path";
|
|
9816
|
+
import yaml from "js-yaml";
|
|
9817
|
+
import { formatObject as formatObject24 } from "@hcmai/sdk";
|
|
9818
|
+
|
|
9819
|
+
// src/commands/delivery-action-policy.ts
|
|
9820
|
+
init_auth_guard();
|
|
9821
|
+
import { HcmClient as HcmClient22, classifyEffect } from "@hcmai/sdk";
|
|
9822
|
+
|
|
9823
|
+
// src/commands/delivery.ts
|
|
9824
|
+
import { createHash as createHash5 } from "crypto";
|
|
9825
|
+
var APPROVAL_BYPASS_FLAGS = /* @__PURE__ */ new Set(["-y", "--yes", "--force", "--auto-approve"]);
|
|
9826
|
+
var CREDENTIAL_FLAGS = /* @__PURE__ */ new Set([
|
|
9827
|
+
"--password",
|
|
9828
|
+
"--password-stdin",
|
|
9829
|
+
"--client-secret",
|
|
9830
|
+
"--pat",
|
|
9831
|
+
"--pat-stdin",
|
|
9832
|
+
"--new-password",
|
|
9833
|
+
"--new-password-stdin"
|
|
9834
|
+
]);
|
|
9835
|
+
var PAYLOAD_FLAGS = ["--data", "--params"];
|
|
9836
|
+
var GUARDED_EXECUTOR_REASON_CODES = /* @__PURE__ */ new Set([
|
|
9837
|
+
"record-create",
|
|
9838
|
+
"record-update",
|
|
9839
|
+
"cache-mutation",
|
|
9840
|
+
"setting-write",
|
|
9841
|
+
"credential-reset",
|
|
9842
|
+
"action-write",
|
|
9843
|
+
// 三态 effect 的 UNKNOWN / 未识别值都按最坏情况视作写操作,走与 WRITES
|
|
9844
|
+
// 完全相同的 prepare + execute 通道。分类函数已经返回 R2 guarded;这里漏登记
|
|
9845
|
+
// 会把 guardedExecutionAvailable 又翻回 false,造成 reason 与 modePolicy 自相矛盾。
|
|
9846
|
+
"action-effect-undetermined",
|
|
9847
|
+
"action-effect-unrecognized",
|
|
9848
|
+
"workspace-create",
|
|
9849
|
+
"workspace-activate",
|
|
9850
|
+
"workspace-deactivate",
|
|
9851
|
+
// bind / add mini / rm 都是受控本地工作区变更;rm 暂存删除,push 再执行远端 DELETE。
|
|
9852
|
+
"workspace-local-change",
|
|
9853
|
+
// 这两个的载荷是**任意文件 / 整棵目录**,此前刻意不收——绑不住就意味着
|
|
9854
|
+
// 「批准时看到的内容」与「执行时实际读到的内容」可以不同。
|
|
9855
|
+
//
|
|
9856
|
+
// 现在绑得住了:PAYLOAD_FILE_FLAGS 收了 --file,PAYLOAD_DIR_FLAGS 收了 --dir
|
|
9857
|
+
// (workspace push 不传 --dir 时按其 option 默认值 '.' 隐式绑定),
|
|
9858
|
+
// 目录按「路径 + 内容、排序稳定」整树摘要,assertPayloadsUnchanged 执行前逐一重算比对。
|
|
9859
|
+
//
|
|
9860
|
+
// 🔴 二次开发的整条链就卡在这两个上:2026-09-01 轨道 A 第四轮验收,
|
|
9861
|
+
// 受控执行第一次跑通了 workspace create,却在 meta set / workspace push 上
|
|
9862
|
+
// 被「该 R2 命令不在首批受控执行器支持面」拦死,远端只多了一个空 workspace。
|
|
9863
|
+
"metadata-write",
|
|
9864
|
+
"workspace-push",
|
|
9865
|
+
// 载荷是**位置参数**(`hcm import <路径>`),既不走 --file 也不走 --dir,
|
|
9866
|
+
// 所以上一刀把文件与目录开关收进来时它仍留在外面(0.4.9 CHANGELOG 逐字记了这一条)。
|
|
9867
|
+
//
|
|
9868
|
+
// 现在收得住了:POSITIONAL_PAYLOAD_COMMANDS 把 argv[1] 这个固定位置钉成载荷,
|
|
9869
|
+
// 目录走整树摘要、单文件走文件摘要,execute 前重算比对(与 --dir 同一套 bind/assert)。
|
|
9870
|
+
// 位置定死而不是「扫第一个非 flag 参数」,是因为 shape 校验与载荷绑定必须对
|
|
9871
|
+
// 「哪个 token 是载荷」看法一致——两处各自解析就能绑 A 执行 B。
|
|
9872
|
+
//
|
|
9873
|
+
// 🔴 客户存量组织导入的整条链就卡在这一个上:2026-09-01 演示环境租户 15,
|
|
9874
|
+
// 531 条组织机构 dry-run 全绿(静态校验 0 失败),正式导入被
|
|
9875
|
+
// 「该 R2 命令不在首批受控执行器支持面」拦死,一个写请求都没发出去。
|
|
9876
|
+
"import-write",
|
|
9877
|
+
// 报表 / 套打模板回传要先 upload 拿 documentId,再挂到业务对象。文件路径是
|
|
9878
|
+
// 固定位置参数,prepare 会钉住项目内普通文件的摘要,execute 前重算后才单次执行。
|
|
9879
|
+
// 2026-09-02 弹性报表顾问仿真已证实这条交付链会在缺受控执行器时中断。
|
|
9880
|
+
"document-upload"
|
|
9881
|
+
]);
|
|
9882
|
+
function normalizeAssessedArgv(inputArgv) {
|
|
9883
|
+
let rest = inputArgv;
|
|
9884
|
+
const dropSeparators = () => {
|
|
9885
|
+
let start = 0;
|
|
9886
|
+
while (rest[start] === "--") start += 1;
|
|
9887
|
+
rest = start > 0 ? rest.slice(start) : rest;
|
|
9888
|
+
};
|
|
9889
|
+
dropSeparators();
|
|
9890
|
+
if (PACKAGE_RUNNERS.has(rest[0] ?? "") && isCliLauncher(rest[1])) {
|
|
9891
|
+
rest = rest.slice(2);
|
|
9892
|
+
} else if (isCliLauncher(rest[0])) {
|
|
9893
|
+
rest = rest.slice(1);
|
|
10160
9894
|
}
|
|
10161
|
-
|
|
10162
|
-
|
|
10163
|
-
function sha2564(value) {
|
|
10164
|
-
return createHash5("sha256").update(value).digest("hex");
|
|
9895
|
+
dropSeparators();
|
|
9896
|
+
return rest === inputArgv ? [...inputArgv] : rest;
|
|
10165
9897
|
}
|
|
10166
|
-
|
|
10167
|
-
|
|
9898
|
+
var PACKAGE_RUNNERS = /* @__PURE__ */ new Set(["npx", "bunx", "pnpx"]);
|
|
9899
|
+
function isCliLauncher(token) {
|
|
9900
|
+
if (!token || token.startsWith("-")) return false;
|
|
9901
|
+
if (token === "@hcmai/cli") return true;
|
|
9902
|
+
const base = token.split(/[\\/]/).pop() ?? token;
|
|
9903
|
+
return base === "hcm" || base === "hcm.js" || base === "hcmai";
|
|
10168
9904
|
}
|
|
10169
|
-
|
|
10170
|
-
|
|
10171
|
-
|
|
10172
|
-
const
|
|
10173
|
-
|
|
10174
|
-
const
|
|
10175
|
-
|
|
10176
|
-
|
|
9905
|
+
function assessDeliveryCommand(inputArgv, options = {}) {
|
|
9906
|
+
const argv = normalizeAssessedArgv(inputArgv);
|
|
9907
|
+
const commandSha256 = sha2564(JSON.stringify(argv));
|
|
9908
|
+
const name = argv[0] ?? "";
|
|
9909
|
+
const subcommand = argv[1] && !argv[1].startsWith("-") ? argv[1] : void 0;
|
|
9910
|
+
const envAlias = flagValue(argv, "--env");
|
|
9911
|
+
const identityAlias = flagValue(argv, "--as");
|
|
9912
|
+
const sensitiveFlags = [
|
|
9913
|
+
...new Set([...PAYLOAD_FLAGS, ...CREDENTIAL_FLAGS].filter((flag) => hasFlag(argv, flag)))
|
|
9914
|
+
];
|
|
9915
|
+
const target = summarizeTarget(argv, options.actionResolution);
|
|
9916
|
+
let classification = classify(argv, options.actionResolution);
|
|
9917
|
+
const invalidPayload = payloadError(argv);
|
|
9918
|
+
if (invalidPayload) {
|
|
9919
|
+
classification = forbidden("invalid-input", "JSON payload \u65E0\u6548\uFF0C\u4E0D\u80FD\u8FDB\u5165\u4EFB\u4F55\u6267\u884C\u8DEF\u5F84\u3002");
|
|
10177
9920
|
}
|
|
10178
|
-
const
|
|
10179
|
-
|
|
10180
|
-
|
|
10181
|
-
|
|
10182
|
-
|
|
10183
|
-
|
|
10184
|
-
|
|
10185
|
-
|
|
10186
|
-
|
|
10187
|
-
});
|
|
10188
|
-
const description = await HcmClient22.fromAuthContext(auth).describe(request.model);
|
|
10189
|
-
const named = description.actions.filter((action) => action.name === request.action);
|
|
10190
|
-
if (named.length === 0) {
|
|
10191
|
-
const degraded = description.effectiveActionsAvailable ? "" : `\u26A0\uFE0F \u672C\u6B21\u6BD4\u5BF9\u4E0D\u542B\u811A\u672C Action\u2014\u2014${description.effectiveActionsNote ?? "\u539F\u56E0\u672A\u77E5"}\u3002`;
|
|
10192
|
-
return failed(
|
|
10193
|
-
"action-metadata-not-found",
|
|
10194
|
-
`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`
|
|
10195
|
-
);
|
|
9921
|
+
const requirements = [];
|
|
9922
|
+
const guardedExecutionAvailable = classification.risk === "R2" && GUARDED_EXECUTOR_REASON_CODES.has(classification.reasonCode);
|
|
9923
|
+
if (classification.risk === "R2") {
|
|
9924
|
+
if (!envAlias) requirements.push("explicit-env");
|
|
9925
|
+
if (!identityAlias) requirements.push("explicit-identity");
|
|
9926
|
+
if (guardedExecutionAvailable) {
|
|
9927
|
+
requirements.push("change-plan", "rollback-plan", "human-approval", "single-use-plan");
|
|
9928
|
+
} else {
|
|
9929
|
+
requirements.push("guarded-executor");
|
|
10196
9930
|
}
|
|
10197
|
-
|
|
10198
|
-
|
|
10199
|
-
|
|
10200
|
-
|
|
10201
|
-
|
|
10202
|
-
|
|
10203
|
-
|
|
9931
|
+
} else if (classification.risk === "R3") {
|
|
9932
|
+
requirements.push("governance-escalation");
|
|
9933
|
+
}
|
|
9934
|
+
const allowed = classification.risk === "R0" || classification.risk === "R1";
|
|
9935
|
+
return {
|
|
9936
|
+
schemaVersion: 1,
|
|
9937
|
+
contractVersion: "2026-08-29",
|
|
9938
|
+
assessmentId: sha2564(`2026-08-29
|
|
9939
|
+
${commandSha256}`).slice(0, 24),
|
|
9940
|
+
commandSha256,
|
|
9941
|
+
command: { name: name || "(empty)", ...subcommand ? { subcommand } : {} },
|
|
9942
|
+
...classification,
|
|
9943
|
+
guardedExecutionAvailable,
|
|
9944
|
+
environment: {
|
|
9945
|
+
...envAlias ? { envAlias } : {},
|
|
9946
|
+
...identityAlias ? { identityAlias } : {}
|
|
9947
|
+
},
|
|
9948
|
+
target,
|
|
9949
|
+
requirements,
|
|
9950
|
+
evidenceRequirements: evidenceFor(classification.risk),
|
|
9951
|
+
sensitiveFlags,
|
|
9952
|
+
modePolicy: {
|
|
9953
|
+
planOnly: allowed ? "allow" : "deny",
|
|
9954
|
+
controlled: allowed || guardedExecutionAvailable ? "allow" : "deny"
|
|
10204
9955
|
}
|
|
10205
|
-
|
|
10206
|
-
|
|
10207
|
-
|
|
10208
|
-
|
|
9956
|
+
};
|
|
9957
|
+
}
|
|
9958
|
+
function classify(argv, actionResolution) {
|
|
9959
|
+
const name = argv[0] ?? "";
|
|
9960
|
+
const subcommand = argv[1] ?? "";
|
|
9961
|
+
if (name.startsWith("-")) {
|
|
9962
|
+
return forbidden(
|
|
9963
|
+
"malformed-argv",
|
|
9964
|
+
`\u88AB\u8BC4\u4F30\u7684\u547D\u4EE4\u540D\u89E3\u6790\u6210\u4E86 ${name} \u2014\u2014 \u90A3\u662F\u4E00\u4E2A\u9009\u9879\uFF0C\u4E0D\u662F\u547D\u4EE4\u3002next_step=\u4ECE\u547D\u4EE4\u540D\u5F00\u5934\u5199\u6574\u6761\u547D\u4EE4\uFF0C\u628A ${name} \u632A\u5230\u547D\u4EE4\u540D\u540E\u9762\uFF0C\u4F8B\u5982 \`hcm meta set <Model> --env <env>\``
|
|
9965
|
+
);
|
|
9966
|
+
}
|
|
9967
|
+
if (argv.some((arg) => APPROVAL_BYPASS_FLAGS.has(flagName(arg)))) {
|
|
9968
|
+
return forbidden("approval-bypass", "\u547D\u4EE4\u5305\u542B\u8DF3\u8FC7\u786E\u8BA4\u7684\u65D7\u6807\uFF0C\u987E\u95EE\u4EA4\u4ED8\u9762\u4E0D\u6267\u884C\u3002");
|
|
9969
|
+
}
|
|
9970
|
+
if (name === "user" && subcommand === "reset-password") {
|
|
9971
|
+
const nonStdinCredential = argv.some((arg) => {
|
|
9972
|
+
const flag = flagName(arg);
|
|
9973
|
+
return CREDENTIAL_FLAGS.has(flag) && flag !== "--password-stdin";
|
|
9974
|
+
});
|
|
9975
|
+
if (nonStdinCredential || !argv.includes("--password-stdin")) {
|
|
9976
|
+
return forbidden(
|
|
9977
|
+
"credential-governance",
|
|
9978
|
+
"\u7528\u6237\u5BC6\u7801\u91CD\u7F6E\u53EA\u80FD\u901A\u8FC7 --password-stdin \u8FDB\u5165\u53D7\u63A7\u51ED\u636E\u6D41\u7A0B\u3002"
|
|
10209
9979
|
);
|
|
10210
9980
|
}
|
|
10211
|
-
return
|
|
10212
|
-
}
|
|
10213
|
-
|
|
10214
|
-
|
|
10215
|
-
|
|
9981
|
+
return guarded("credential-write", "credential-reset");
|
|
9982
|
+
}
|
|
9983
|
+
if (argv.some((arg) => CREDENTIAL_FLAGS.has(flagName(arg)))) {
|
|
9984
|
+
return forbidden("credential-governance", "\u547D\u4EE4\u643A\u5E26\u8EAB\u4EFD\u51ED\u636E\u53C2\u6570\uFF0C\u5FC5\u987B\u8F6C\u4EA4\u8EAB\u4EFD\u6CBB\u7406\u6D41\u7A0B\u3002");
|
|
9985
|
+
}
|
|
9986
|
+
if (name === "version") return direct("R0", "product-discovery", "product-discovery");
|
|
9987
|
+
if (name === "open") return direct("R1", "remote-read", "browser-session-open");
|
|
9988
|
+
if (name === "models") return direct("R0", "product-discovery", "model-discovery");
|
|
9989
|
+
if (name === "config") {
|
|
9990
|
+
if (["list", "show", "get"].includes(subcommand))
|
|
9991
|
+
return direct("R0", "local-discovery", "config-read");
|
|
9992
|
+
return forbidden(
|
|
9993
|
+
"identity-governance",
|
|
9994
|
+
"\u4FEE\u6539\u672C\u673A\u5168\u5C40\u914D\u7F6E\u4F1A\u6539\u53D8\u540E\u7EED\u6240\u6709\u547D\u4EE4\u7684\u73AF\u5883\u4E0E\u8EAB\u4EFD\uFF0C\u5C5E\u6CBB\u7406\u64CD\u4F5C\u3002"
|
|
10216
9995
|
);
|
|
10217
9996
|
}
|
|
10218
|
-
|
|
10219
|
-
|
|
10220
|
-
|
|
10221
|
-
|
|
10222
|
-
|
|
10223
|
-
|
|
10224
|
-
|
|
10225
|
-
|
|
10226
|
-
|
|
10227
|
-
|
|
10228
|
-
|
|
10229
|
-
|
|
10230
|
-
|
|
10231
|
-
|
|
9997
|
+
if (name === "upgrade" || name === "self-update") {
|
|
9998
|
+
return direct("R1", "managed-local-write", "cli-self-upgrade");
|
|
9999
|
+
}
|
|
10000
|
+
if (name === "datapackage") {
|
|
10001
|
+
if (subcommand === "pack") return direct("R1", "local-validation", "datapackage-pack");
|
|
10002
|
+
if (subcommand === "status") return direct("R1", "remote-read", "datapackage-status");
|
|
10003
|
+
if (subcommand === "install") return guarded("tenant-data-write", "datapackage-install");
|
|
10004
|
+
return forbidden("unknown-command", "\u672A\u77E5 datapackage \u5B50\u547D\u4EE4\u6309\u6700\u9AD8\u98CE\u9669\u5173\u95ED\u3002");
|
|
10005
|
+
}
|
|
10006
|
+
if (name === "mini") {
|
|
10007
|
+
return forbidden("removed-command", "`hcm mini` \u5DF2\u79FB\u9664\uFF0C\u6539\u7528 `hcm workspace`\u3002");
|
|
10008
|
+
}
|
|
10009
|
+
if (name === "chiron") {
|
|
10010
|
+
if (subcommand === "doctor") return direct("R0", "local-discovery", "chiron-doctor");
|
|
10011
|
+
if (subcommand === "init") return direct("R1", "managed-local-write", "chiron-project-scaffold");
|
|
10012
|
+
if (subcommand === "test") return direct("R1", "remote-read", "chiron-regression-test");
|
|
10013
|
+
if (subcommand === "gap") {
|
|
10014
|
+
const third = argv[2] ?? "";
|
|
10015
|
+
if (["search", "status"].includes(third)) return direct("R1", "remote-read", "gap-read");
|
|
10016
|
+
if (third === "submit") return direct("R1", "external-tracker-write", "gap-submit");
|
|
10017
|
+
return forbidden("unknown-command", "\u672A\u77E5 chiron gap \u5B50\u547D\u4EE4\u6309\u6700\u9AD8\u98CE\u9669\u5173\u95ED\u3002");
|
|
10232
10018
|
}
|
|
10233
|
-
return
|
|
10019
|
+
return forbidden("unknown-command", "\u672A\u77E5 chiron \u5B50\u547D\u4EE4\u6309\u6700\u9AD8\u98CE\u9669\u5173\u95ED\u3002");
|
|
10234
10020
|
}
|
|
10235
|
-
|
|
10236
|
-
|
|
10237
|
-
|
|
10238
|
-
...shape,
|
|
10239
|
-
effect: effectClass,
|
|
10240
|
-
...effectClass === "unrecognized-effect" ? { effectRaw: action.effect } : {},
|
|
10241
|
-
readOnly: effectClass === "read-only"
|
|
10021
|
+
if (name === "skills") {
|
|
10022
|
+
if (subcommand === "list" || subcommand === "show") {
|
|
10023
|
+
return direct("R0", "product-discovery", "skill-discovery");
|
|
10242
10024
|
}
|
|
10243
|
-
|
|
10244
|
-
|
|
10245
|
-
|
|
10246
|
-
|
|
10247
|
-
}
|
|
10248
|
-
function parseActionRequest(inputArgv) {
|
|
10249
|
-
const argv = normalizeAssessedArgv(inputArgv);
|
|
10250
|
-
const spec = argv[1] ?? "";
|
|
10251
|
-
const separator = spec.indexOf(".");
|
|
10252
|
-
if (separator <= 0 || separator === spec.length - 1) {
|
|
10253
|
-
return failed("invalid-action-spec", "Action \u5FC5\u987B\u4F7F\u7528 <Model>.<Action> \u683C\u5F0F\u3002");
|
|
10025
|
+
if (subcommand === "sync" || subcommand === "install") {
|
|
10026
|
+
return direct("R1", "managed-local-write", "skill-managed-write");
|
|
10027
|
+
}
|
|
10028
|
+
return forbidden("unknown-command", "\u672A\u77E5 skills \u5B50\u547D\u4EE4\u6309\u6700\u9AD8\u98CE\u9669\u5173\u95ED\u3002");
|
|
10254
10029
|
}
|
|
10255
|
-
|
|
10256
|
-
|
|
10257
|
-
|
|
10258
|
-
|
|
10030
|
+
if (name === "env") {
|
|
10031
|
+
if (subcommand === "list" || subcommand === "current" || subcommand === "show") {
|
|
10032
|
+
return direct("R0", "local-discovery", "environment-read");
|
|
10033
|
+
}
|
|
10034
|
+
return forbidden("identity-governance", "\u73AF\u5883\u65B0\u589E\u3001\u5207\u6362\u3001\u7F16\u8F91\u6216\u5220\u9664\u5C5E\u4E8E\u6CBB\u7406\u64CD\u4F5C\u3002");
|
|
10259
10035
|
}
|
|
10260
|
-
|
|
10261
|
-
|
|
10262
|
-
|
|
10263
|
-
return failed("invalid-action-scope", "Action scope \u5FC5\u987B\u662F class \u6216 object\u3002");
|
|
10036
|
+
if (name === "identity") {
|
|
10037
|
+
if (subcommand === "list") return direct("R0", "local-discovery", "identity-read");
|
|
10038
|
+
return forbidden("identity-governance", "\u8EAB\u4EFD\u5207\u6362\u6216\u5220\u9664\u5C5E\u4E8E\u6CBB\u7406\u64CD\u4F5C\u3002");
|
|
10264
10039
|
}
|
|
10265
|
-
|
|
10266
|
-
|
|
10267
|
-
|
|
10268
|
-
|
|
10269
|
-
|
|
10270
|
-
|
|
10271
|
-
|
|
10272
|
-
identity: flagValue2(argv, "--as"),
|
|
10273
|
-
profile: flagValue2(argv, "--profile")
|
|
10274
|
-
};
|
|
10275
|
-
}
|
|
10276
|
-
function failed(reasonCode, reason) {
|
|
10277
|
-
return { status: "failed", reasonCode, reason };
|
|
10278
|
-
}
|
|
10279
|
-
function flagValue2(argv, flag) {
|
|
10280
|
-
const equals = argv.find((arg) => arg.startsWith(`${flag}=`));
|
|
10281
|
-
if (equals) return equals.slice(flag.length + 1);
|
|
10282
|
-
const index = argv.indexOf(flag);
|
|
10283
|
-
return index >= 0 ? argv[index + 1] : void 0;
|
|
10284
|
-
}
|
|
10285
|
-
|
|
10286
|
-
// src/commands/xlsx-peek.ts
|
|
10287
|
-
import { readFileSync as readFileSync5 } from "fs";
|
|
10288
|
-
import { inflateRawSync } from "zlib";
|
|
10289
|
-
function readZip(buf, want) {
|
|
10290
|
-
let eocd = -1;
|
|
10291
|
-
for (let i = buf.length - 22; i >= 0 && i > buf.length - 66e3; i--) {
|
|
10292
|
-
if (buf.readUInt32LE(i) === 101010256) {
|
|
10293
|
-
eocd = i;
|
|
10294
|
-
break;
|
|
10040
|
+
if (name === "query" || name === "describe" || name === "trace") {
|
|
10041
|
+
return direct("R1", "remote-read", "business-read");
|
|
10042
|
+
}
|
|
10043
|
+
if (name === "cache") {
|
|
10044
|
+
if (subcommand === "stats") return direct("R1", "remote-read", "cache-read");
|
|
10045
|
+
if (subcommand === "clear" || subcommand === "clear-meta") {
|
|
10046
|
+
return guarded("operational-write", "cache-mutation");
|
|
10295
10047
|
}
|
|
10296
10048
|
}
|
|
10297
|
-
if (
|
|
10298
|
-
|
|
10299
|
-
|
|
10300
|
-
const out = [];
|
|
10301
|
-
for (let n = 0; n < count; n++) {
|
|
10302
|
-
if (buf.readUInt32LE(p) !== 33639248) break;
|
|
10303
|
-
const method = buf.readUInt16LE(p + 10);
|
|
10304
|
-
const compressedSize = buf.readUInt32LE(p + 20);
|
|
10305
|
-
const nameLen = buf.readUInt16LE(p + 28);
|
|
10306
|
-
const extraLen = buf.readUInt16LE(p + 30);
|
|
10307
|
-
const commentLen = buf.readUInt16LE(p + 32);
|
|
10308
|
-
const localOffset = buf.readUInt32LE(p + 42);
|
|
10309
|
-
const name = buf.subarray(p + 46, p + 46 + nameLen).toString("utf8");
|
|
10310
|
-
if (want(name)) {
|
|
10311
|
-
const lnameLen = buf.readUInt16LE(localOffset + 26);
|
|
10312
|
-
const lextraLen = buf.readUInt16LE(localOffset + 28);
|
|
10313
|
-
const start = localOffset + 30 + lnameLen + lextraLen;
|
|
10314
|
-
const raw = buf.subarray(start, start + compressedSize);
|
|
10315
|
-
if (method === 0) out.push({ name, data: Buffer.from(raw) });
|
|
10316
|
-
else if (method === 8) out.push({ name, data: inflateRawSync(raw) });
|
|
10317
|
-
else throw new Error(`xlsx \u91CC\u7684 ${name} \u7528\u4E86\u4E0D\u652F\u6301\u7684\u538B\u7F29\u65B9\u5F0F ${method}`);
|
|
10049
|
+
if (name === "meta") {
|
|
10050
|
+
if (subcommand === "list" || subcommand === "get") {
|
|
10051
|
+
return direct("R1", "remote-read", "metadata-read");
|
|
10318
10052
|
}
|
|
10319
|
-
|
|
10053
|
+
if (subcommand === "set" && hasFlag(argv, "--dry-run")) {
|
|
10054
|
+
return direct("R1", "local-validation", "metadata-dry-run");
|
|
10055
|
+
}
|
|
10056
|
+
if (subcommand === "set") return guarded("tenant-config-write", "metadata-write");
|
|
10057
|
+
if (subcommand === "delete") return forbidden("destructive", "\u5143\u6570\u636E\u5220\u9664\u4E0D\u53EF\u7531\u987E\u95EE\u63D2\u4EF6\u6267\u884C\u3002");
|
|
10320
10058
|
}
|
|
10321
|
-
|
|
10322
|
-
|
|
10323
|
-
|
|
10324
|
-
|
|
10325
|
-
|
|
10326
|
-
|
|
10327
|
-
|
|
10328
|
-
const [shared] = readZip(buf, (n) => n === "xl/sharedStrings.xml");
|
|
10329
|
-
const sharedStrings = [];
|
|
10330
|
-
if (shared) {
|
|
10331
|
-
for (const si of shared.data.toString("utf8").split("<si>").slice(1)) {
|
|
10332
|
-
sharedStrings.push(decode([...si.matchAll(/<t[^>]*>([\s\S]*?)<\/t>/g)].map((m) => m[1] ?? "").join("")));
|
|
10059
|
+
if (name === "setting") {
|
|
10060
|
+
if (subcommand === "get") return direct("R1", "remote-read", "setting-read");
|
|
10061
|
+
if (subcommand === "set" && hasFlag(argv, "--dry-run")) {
|
|
10062
|
+
return direct("R1", "local-validation", "setting-dry-run");
|
|
10063
|
+
}
|
|
10064
|
+
if (subcommand === "set" || subcommand === "reset") {
|
|
10065
|
+
return guarded("tenant-config-write", "setting-write");
|
|
10333
10066
|
}
|
|
10334
10067
|
}
|
|
10335
|
-
|
|
10336
|
-
|
|
10337
|
-
|
|
10338
|
-
|
|
10339
|
-
|
|
10340
|
-
|
|
10341
|
-
|
|
10342
|
-
|
|
10343
|
-
|
|
10344
|
-
|
|
10345
|
-
|
|
10346
|
-
|
|
10347
|
-
|
|
10068
|
+
if (name === "workspace") {
|
|
10069
|
+
if (subcommand === "push" && hasFlag(argv, "--dry-run")) {
|
|
10070
|
+
return direct("R1", "remote-read", "workspace-push-dry-run");
|
|
10071
|
+
}
|
|
10072
|
+
if (["list", "active", "status", "validate", "verify", "preview"].includes(subcommand)) {
|
|
10073
|
+
return direct("R1", "remote-read", "workspace-read");
|
|
10074
|
+
}
|
|
10075
|
+
if (subcommand === "pull") {
|
|
10076
|
+
return direct("R1", "managed-local-write", "workspace-pull");
|
|
10077
|
+
}
|
|
10078
|
+
if (subcommand === "bind" || subcommand === "add" && argv[2] === "mini") {
|
|
10079
|
+
return guarded("managed-local-write", "workspace-local-change");
|
|
10080
|
+
}
|
|
10081
|
+
if (subcommand === "rm") return guarded("managed-local-write", "workspace-local-change");
|
|
10082
|
+
if (subcommand === "create") return guarded("tenant-write", "workspace-create");
|
|
10083
|
+
if (subcommand === "activate") return guarded("tenant-write", "workspace-activate");
|
|
10084
|
+
if (subcommand === "deactivate") return guarded("tenant-write", "workspace-deactivate");
|
|
10085
|
+
if (subcommand === "push") return guarded("tenant-write", "workspace-push");
|
|
10086
|
+
if (["deploy", "release", "promote", "publish"].includes(subcommand)) {
|
|
10087
|
+
return forbidden("publish", "\u90E8\u7F72\u5230 active \u5C5E\u4E8E R3\uFF0C\u987B\u8D70\u53D1\u5E03\u4E0E\u5BA1\u6279\u94FE\u8DEF\u3002");
|
|
10348
10088
|
}
|
|
10349
|
-
rows.push(cells);
|
|
10350
10089
|
}
|
|
10351
|
-
|
|
10352
|
-
|
|
10353
|
-
|
|
10354
|
-
|
|
10355
|
-
var CONTENT_KEYS = ["stdout_contains", "json", "xlsx_header", "xlsx_min_rows", "text_contains"];
|
|
10356
|
-
var hasContentAssertion = (c) => (c.page ? (c.expect_text?.length ?? 0) > 0 : false) || CONTENT_KEYS.some((k) => c.expect?.[k] !== void 0);
|
|
10357
|
-
function assertUsableSpec(spec, where) {
|
|
10358
|
-
if (!spec?.name || !Array.isArray(spec.checks) || spec.checks.length === 0) {
|
|
10359
|
-
throw new Error(`${where}: \u7528\u4F8B\u8981\u6709 name \u4E0E\u81F3\u5C11\u4E00\u6761 checks`);
|
|
10090
|
+
if (name === "script") {
|
|
10091
|
+
if (["dry-run", "manifest-validate", "logs", "task"].includes(subcommand)) {
|
|
10092
|
+
return direct("R1", "remote-read", "script-" + subcommand);
|
|
10093
|
+
}
|
|
10360
10094
|
}
|
|
10361
|
-
|
|
10362
|
-
|
|
10363
|
-
|
|
10364
|
-
const kinds = [c.run, c.file, c.page].filter(Boolean).length;
|
|
10365
|
-
if (kinds !== 1) throw new Error(`${at}: run / file / page \u5FC5\u987B\u4E14\u53EA\u80FD\u6709\u4E00\u4E2A`);
|
|
10366
|
-
if (c.run) {
|
|
10367
|
-
if (!/^hcm\s/.test(c.run.trim())) {
|
|
10368
|
-
throw new Error(`${at}: run \u53EA\u80FD\u8DD1 hcm \u5B50\u547D\u4EE4\uFF08\u4E0D\u63A5\u53D7\u4EFB\u610F shell\uFF1B\u8981\u7ED5\u8FC7 CLI \u7684\u4E8B\u672C\u6765\u5C31\u4E0D\u8BE5\u505A\uFF09`);
|
|
10369
|
-
}
|
|
10370
|
-
tokenize(c.run);
|
|
10095
|
+
if (name === "import") {
|
|
10096
|
+
if (hasFlag(argv, "--dry-run")) {
|
|
10097
|
+
return direct("R1", "local-validation", "import-dry-run");
|
|
10371
10098
|
}
|
|
10372
|
-
|
|
10373
|
-
|
|
10374
|
-
|
|
10375
|
-
|
|
10376
|
-
|
|
10377
|
-
|
|
10099
|
+
return guarded("bulk-tenant-write", "import-write");
|
|
10100
|
+
}
|
|
10101
|
+
if (name === "create" || name === "update") {
|
|
10102
|
+
return guarded("tenant-write", name === "create" ? "record-create" : "record-update");
|
|
10103
|
+
}
|
|
10104
|
+
if (name === "upload") return guarded("tenant-write", "document-upload");
|
|
10105
|
+
if (name === "download") return direct("R1", "managed-local-write", "document-download");
|
|
10106
|
+
if (name === "action") {
|
|
10107
|
+
if (actionResolution?.status === "resolved") {
|
|
10108
|
+
return classifyAction(actionResolution.policy);
|
|
10109
|
+
}
|
|
10110
|
+
if (actionResolution?.status === "failed") {
|
|
10111
|
+
return forbidden(actionResolution.reasonCode, actionResolution.reason);
|
|
10112
|
+
}
|
|
10113
|
+
return forbidden(
|
|
10114
|
+
"action-effect-unclassified",
|
|
10115
|
+
"\u5C1A\u672A\u8BFB\u53D6 Core Action \u98CE\u63A7\u58F0\u660E\uFF0C\u4E0D\u80FD\u6309\u540D\u79F0\u731C\u6D4B\u540E\u653E\u884C\u3002"
|
|
10378
10116
|
);
|
|
10379
10117
|
}
|
|
10118
|
+
if (name === "delete" || name === "meta" && subcommand === "delete") {
|
|
10119
|
+
return forbidden("destructive", "\u5220\u9664\u64CD\u4F5C\u4E0D\u8FDB\u5165\u987E\u95EE\u63D2\u4EF6\u6267\u884C\u9762\u3002");
|
|
10120
|
+
}
|
|
10121
|
+
if (name === "tenant") {
|
|
10122
|
+
return forbidden("tenant-governance", "\u79DF\u6237\u5F00\u901A\u6216\u6CBB\u7406\u5FC5\u987B\u5347\u7EA7\u6CBB\u7406\u4EBA\u5458\u3002");
|
|
10123
|
+
}
|
|
10124
|
+
if (name === "login" || name === "logout") {
|
|
10125
|
+
return forbidden("identity-governance", "\u767B\u5F55\u4E0E\u767B\u51FA\u5C5E\u4E8E\u8EAB\u4EFD\u6CBB\u7406\u64CD\u4F5C\u3002");
|
|
10126
|
+
}
|
|
10127
|
+
if (name === "chat") {
|
|
10128
|
+
return forbidden("agent-autonomy", "\u987E\u95EE\u63D2\u4EF6\u4E0D\u901A\u8FC7\u5D4C\u5957\u6570\u5B57\u5458\u5DE5\u5BF9\u8BDD\u6269\u5927\u81EA\u6CBB\u6267\u884C\u9762\u3002");
|
|
10129
|
+
}
|
|
10130
|
+
return forbidden(
|
|
10131
|
+
"unknown-command",
|
|
10132
|
+
`\u672A\u77E5\u547D\u4EE4\u6309\u6700\u9AD8\u98CE\u9669\u5173\u95ED\uFF1A\u89E3\u6790\u5230\u7684\u547D\u4EE4\u662F ${name || "(\u7A7A)"}` + (subcommand ? ` ${subcommand}` : "") + "\u3002next_step=\u7528 `hcm --help` \u6838\u5BF9\u547D\u4EE4\u540D\uFF1B\u82E5\u4F60\u786E\u4FE1\u8FD9\u6761\u547D\u4EE4\u5B58\u5728\uFF0C\u5148\u8DD1 `hcm upgrade` \u770B CLI \u662F\u4E0D\u662F\u65E7\u7248\uFF08\u98CE\u63A7\u8868\u968F CLI \u53D1\u5E03\u66F4\u65B0\uFF09"
|
|
10133
|
+
);
|
|
10380
10134
|
}
|
|
10381
|
-
function
|
|
10382
|
-
const
|
|
10383
|
-
|
|
10384
|
-
|
|
10385
|
-
|
|
10386
|
-
|
|
10387
|
-
|
|
10388
|
-
|
|
10389
|
-
|
|
10390
|
-
|
|
10391
|
-
|
|
10392
|
-
} else cur += ch;
|
|
10393
|
-
continue;
|
|
10394
|
-
}
|
|
10395
|
-
if (ch === '"' || ch === "'") {
|
|
10396
|
-
quote = ch;
|
|
10397
|
-
started = true;
|
|
10398
|
-
continue;
|
|
10135
|
+
function summarizeTarget(argv, actionResolution) {
|
|
10136
|
+
const name = argv[0] ?? "";
|
|
10137
|
+
const subcommand = argv[1] ?? "";
|
|
10138
|
+
const target = {};
|
|
10139
|
+
if (["query", "describe", "create", "update", "delete"].includes(name) && subcommand) {
|
|
10140
|
+
target.model = subcommand;
|
|
10141
|
+
}
|
|
10142
|
+
if (name === "action" && subcommand) {
|
|
10143
|
+
target.action = subcommand;
|
|
10144
|
+
if (actionResolution?.status === "resolved") {
|
|
10145
|
+
target.actionPolicy = { ...actionResolution.policy };
|
|
10399
10146
|
}
|
|
10400
|
-
|
|
10401
|
-
|
|
10402
|
-
|
|
10403
|
-
|
|
10147
|
+
}
|
|
10148
|
+
if (name === "skills" && argv[2] && !argv[2].startsWith("-")) target.skill = argv[2];
|
|
10149
|
+
if (name === "meta" && argv[2] && !argv[2].startsWith("-")) target.path = argv[2];
|
|
10150
|
+
if (name === "cache" && argv[2] && !argv[2].startsWith("-")) {
|
|
10151
|
+
target.cacheOperation = subcommand;
|
|
10152
|
+
target.model = argv[2];
|
|
10153
|
+
}
|
|
10154
|
+
if (name === "setting" && argv[2] && !argv[2].startsWith("-")) {
|
|
10155
|
+
target.domain = argv[2];
|
|
10156
|
+
const settingKeys = valuesAfterFlag(argv, "--set").map((assignment) => assignment.split("=", 1)[0]).filter((key2) => Boolean(key2)).sort();
|
|
10157
|
+
if (settingKeys.length > 0) target.settingKeys = settingKeys;
|
|
10158
|
+
}
|
|
10159
|
+
const id = flagValue(argv, "--id");
|
|
10160
|
+
if (name === "user" && subcommand === "reset-password") {
|
|
10161
|
+
if (id) target.userIdSha256 = sha2564(id);
|
|
10162
|
+
const username = flagValue(argv, "--username");
|
|
10163
|
+
if (username) target.usernameSha256 = sha2564(username);
|
|
10164
|
+
target.forceChangeOnNextLogin = !hasFlag(argv, "--no-force-change");
|
|
10165
|
+
} else if (id) {
|
|
10166
|
+
target.recordIdSha256 = sha2564(id);
|
|
10167
|
+
}
|
|
10168
|
+
for (const flag of PAYLOAD_FLAGS) {
|
|
10169
|
+
const raw = flagValue(argv, flag);
|
|
10170
|
+
if (!raw) continue;
|
|
10171
|
+
target.payloadSha256 = sha2564(raw);
|
|
10172
|
+
try {
|
|
10173
|
+
const parsed = JSON.parse(raw);
|
|
10174
|
+
if (isPlainObject(parsed)) target.fieldNames = Object.keys(parsed).sort();
|
|
10175
|
+
} catch {
|
|
10404
10176
|
}
|
|
10405
|
-
|
|
10406
|
-
|
|
10407
|
-
|
|
10408
|
-
|
|
10409
|
-
|
|
10410
|
-
|
|
10411
|
-
|
|
10177
|
+
}
|
|
10178
|
+
return target;
|
|
10179
|
+
}
|
|
10180
|
+
function payloadError(argv) {
|
|
10181
|
+
for (const flag of PAYLOAD_FLAGS) {
|
|
10182
|
+
const raw = flagValue(argv, flag);
|
|
10183
|
+
if (raw === void 0) continue;
|
|
10184
|
+
try {
|
|
10185
|
+
const parsed = JSON.parse(raw);
|
|
10186
|
+
if (!isPlainObject(parsed)) return true;
|
|
10187
|
+
} catch {
|
|
10188
|
+
return true;
|
|
10412
10189
|
}
|
|
10413
|
-
cur += ch;
|
|
10414
|
-
started = true;
|
|
10415
10190
|
}
|
|
10416
|
-
|
|
10417
|
-
|
|
10418
|
-
|
|
10191
|
+
return false;
|
|
10192
|
+
}
|
|
10193
|
+
function direct(risk, effect, reasonCode) {
|
|
10194
|
+
return {
|
|
10195
|
+
risk,
|
|
10196
|
+
execution: "direct",
|
|
10197
|
+
effect,
|
|
10198
|
+
reasonCode,
|
|
10199
|
+
reason: risk === "R0" ? "\u7EAF\u53D1\u73B0\u64CD\u4F5C\uFF0C\u53EF\u76F4\u63A5\u6267\u884C\u3002" : "\u53EA\u8BFB\u6216\u53D7\u7BA1\u672C\u5730\u64CD\u4F5C\uFF0C\u53EF\u76F4\u63A5\u6267\u884C\u5E76\u4FDD\u7559\u7ED3\u679C\u3002"
|
|
10200
|
+
};
|
|
10201
|
+
}
|
|
10202
|
+
function guarded(effect, reasonCode) {
|
|
10203
|
+
return {
|
|
10204
|
+
risk: "R2",
|
|
10205
|
+
execution: "guarded",
|
|
10206
|
+
effect,
|
|
10207
|
+
reasonCode,
|
|
10208
|
+
// 🔴 这一句是 R2 档的**主文案**,15 个调用方共用它,顾问跑任何写命令都读到它。
|
|
10209
|
+
// 0.7.0 之前它写的是「只允许在 controlled 项目中通过 delivery prepare +
|
|
10210
|
+
// delivery execute 单次受控执行」——那三个概念随受控执行三步一起删了,
|
|
10211
|
+
// 于是它变成一条指向不存在的路的下一步。既然 CLI 不再自建执行闸,
|
|
10212
|
+
// 真正的下一步就是「这条命令不从这里跑」,而不是「换个 CLI 姿势跑」。
|
|
10213
|
+
reason: "\u8FD9\u6761\u547D\u4EE4\u4F1A\u5199\u6570\u636E\uFF0C\u672C\u901A\u9053\u53EA\u8DD1\u53EA\u8BFB\uFF0C\u6240\u4EE5\u6CA1\u6709\u6267\u884C\u3002next_step=\u8981\u843D\u8FD9\u4E2A\u5199\uFF0C\u6309\u9879\u76EE\u7684\u5199\u6388\u6743\u7EAA\u5F8B\u5728\u73AF\u5883\u91CC\u505A\u6389\uFF08\u8BF4\u660E\u5BF9\u8C61\u3001\u8303\u56F4\u3001\u5F71\u54CD\u4E0E\u56DE\u9000\u5E76\u53D6\u5F97\u672C\u6B21\u786E\u8BA4\uFF09\uFF0C\u518D\u7528\u53EA\u8BFB\u547D\u4EE4\u65AD\u8A00\u5B83\u843D\u5E93\u7684\u6837\u5B50\uFF1B\u5982\u679C\u4F60\u8BA4\u4E3A\u5B83\u5176\u5B9E\u4E0D\u5199\u5E93\uFF0C\u53BB\u4EA7\u54C1\u4FA7\u628A effect \u5224\u6210 READ_ONLY\u3002"
|
|
10214
|
+
};
|
|
10419
10215
|
}
|
|
10420
|
-
function
|
|
10421
|
-
|
|
10422
|
-
|
|
10423
|
-
|
|
10424
|
-
|
|
10425
|
-
|
|
10426
|
-
|
|
10427
|
-
|
|
10428
|
-
|
|
10429
|
-
return JSON.parse(stdout.slice(a, b + 1));
|
|
10430
|
-
} catch {
|
|
10431
|
-
}
|
|
10216
|
+
function classifyAction(policy) {
|
|
10217
|
+
if (policy.readOnly) {
|
|
10218
|
+
return {
|
|
10219
|
+
risk: "R1",
|
|
10220
|
+
execution: "direct",
|
|
10221
|
+
effect: "remote-read",
|
|
10222
|
+
reasonCode: "action-read-only",
|
|
10223
|
+
reason: "Core \u58F0\u660E\u8BE5 Action \u4E3A\u53EA\u8BFB\uFF0C\u4E0E Moirai \u7684\u53EA\u8BFB Action \u8DEF\u5F84\u4E00\u81F4\uFF0C\u53EF\u76F4\u63A5\u6267\u884C\u3002"
|
|
10224
|
+
};
|
|
10432
10225
|
}
|
|
10433
|
-
|
|
10434
|
-
|
|
10435
|
-
|
|
10436
|
-
|
|
10437
|
-
|
|
10438
|
-
|
|
10439
|
-
|
|
10440
|
-
|
|
10441
|
-
if (!Array.isArray(cur)) return void 0;
|
|
10442
|
-
cur = cur[Number(t[1])];
|
|
10443
|
-
} else {
|
|
10444
|
-
if (typeof cur !== "object") return void 0;
|
|
10445
|
-
cur = cur[t[2]];
|
|
10446
|
-
}
|
|
10226
|
+
if (policy.effect === "declared-unknown") {
|
|
10227
|
+
return {
|
|
10228
|
+
risk: "R2",
|
|
10229
|
+
execution: "guarded",
|
|
10230
|
+
effect: "undetermined",
|
|
10231
|
+
reasonCode: "action-effect-undetermined",
|
|
10232
|
+
reason: "\u4EA7\u54C1\u4FA7\u628A\u8FD9\u4E2A Action \u58F0\u660E\u6210 effect=UNKNOWN\uFF1A**\u6CA1\u4EBA\u5224\u8FC7**\u5B83\u5199\u4E0D\u5199\u5E93\u3002\u6309\u6700\u574F\u60C5\u51B5\u8D70\u53D7\u63A7\u6267\u884C\uFF08\u4E0E\u4F1A\u5199\u7684 Action \u540C\u4E00\u6761\u8DEF\u5F84\uFF09\uFF0C\u4F46\u5B83\u4E0D\u7B49\u4E8E\u300C\u786E\u8BA4\u4F1A\u5199\u300D\u3002next_step=\u53BB\u4EA7\u54C1\u4FA7\u7ED9\u8FD9\u4E2A @ClassAction/@ObjectAction \u628A effect \u5224\u6389\uFF08READ_ONLY / WRITES\uFF09\uFF0C\u800C\u4E0D\u662F\u5728 CLI \u8FD9\u8FB9\u653E\u5BBD\u3002"
|
|
10233
|
+
};
|
|
10447
10234
|
}
|
|
10448
|
-
|
|
10235
|
+
if (policy.effect === "unrecognized-effect") {
|
|
10236
|
+
return {
|
|
10237
|
+
risk: "R2",
|
|
10238
|
+
execution: "guarded",
|
|
10239
|
+
effect: "undetermined",
|
|
10240
|
+
reasonCode: "action-effect-unrecognized",
|
|
10241
|
+
reason: `Core \u9001\u6765\u7684 effect \u53D6\u503C ${describeEffectRaw(policy.effectRaw)} \u4E0D\u5728 READ_ONLY / WRITES / UNKNOWN \u4E09\u6001\u5185\uFF08\u62FC\u5199\u6F02\u79FB\uFF1F\u670D\u52A1\u7AEF\u6BD4\u672C CLI \u65B0\u3001\u591A\u4E86\u4E00\u6001\uFF1F\uFF09\u3002fail-closed\uFF1A\u6309 UNKNOWN \u5904\u7F6E\u8D70\u53D7\u63A7\u6267\u884C\uFF0C\u4E0D\u731C\u6210\u53EA\u8BFB\u3002next_step=\u62FF\u8FD9\u4E2A\u539F\u503C\u53BB\u5BF9\u4EA7\u54C1\u4FA7\u7684 ActionEffect \u5B9A\u4E49\uFF0C\u5FC5\u8981\u65F6\u5347\u7EA7 CLI\u3002`
|
|
10242
|
+
};
|
|
10243
|
+
}
|
|
10244
|
+
return guarded("tenant-write", "action-write");
|
|
10449
10245
|
}
|
|
10450
|
-
function
|
|
10451
|
-
|
|
10452
|
-
if (
|
|
10453
|
-
|
|
10454
|
-
|
|
10455
|
-
|
|
10456
|
-
|
|
10457
|
-
switch (op) {
|
|
10458
|
-
case ">":
|
|
10459
|
-
return Number.isFinite(a) && a > n;
|
|
10460
|
-
case "<":
|
|
10461
|
-
return Number.isFinite(a) && a < n;
|
|
10462
|
-
case ">=":
|
|
10463
|
-
return Number.isFinite(a) && a >= n;
|
|
10464
|
-
case "<=":
|
|
10465
|
-
return Number.isFinite(a) && a <= n;
|
|
10466
|
-
case "!=":
|
|
10467
|
-
return String(actual) !== want;
|
|
10468
|
-
default:
|
|
10469
|
-
return String(actual) === want;
|
|
10246
|
+
function describeEffectRaw(raw) {
|
|
10247
|
+
if (raw === null) return "null";
|
|
10248
|
+
if (typeof raw === "string") return JSON.stringify(raw);
|
|
10249
|
+
try {
|
|
10250
|
+
return `${JSON.stringify(raw)}\uFF08${typeof raw}\uFF09`;
|
|
10251
|
+
} catch {
|
|
10252
|
+
return `<\u65E0\u6CD5\u5E8F\u5217\u5316\u7684 ${typeof raw}>`;
|
|
10470
10253
|
}
|
|
10471
10254
|
}
|
|
10472
|
-
|
|
10473
|
-
|
|
10474
|
-
|
|
10475
|
-
|
|
10476
|
-
|
|
10477
|
-
|
|
10478
|
-
|
|
10479
|
-
|
|
10480
|
-
|
|
10481
|
-
|
|
10482
|
-
|
|
10483
|
-
|
|
10484
|
-
|
|
10485
|
-
|
|
10486
|
-
|
|
10487
|
-
const vars = {};
|
|
10488
|
-
const fill = (text) => text.replace(/\$\{(\w+)\}/g, (_, k) => {
|
|
10489
|
-
if (vars[k] === void 0) throw new Error(`\u7528\u5230\u4E86 ${"$"}{${k}} \u4F46\u524D\u9762\u6CA1\u6709\u54EA\u4E00\u6B65\u6355\u83B7\u5B83`);
|
|
10490
|
-
return vars[k];
|
|
10491
|
-
});
|
|
10492
|
-
for (const c of spec.checks) {
|
|
10493
|
-
try {
|
|
10494
|
-
if (c.run) {
|
|
10495
|
-
const argv2 = tokenize(fill(c.run)).slice(1);
|
|
10496
|
-
const verdict = await deps.assess(argv2);
|
|
10497
|
-
if (verdict.execution !== "direct") {
|
|
10498
|
-
results.push({
|
|
10499
|
-
name: c.name,
|
|
10500
|
-
verdict: "fail",
|
|
10501
|
-
detail: `\u8FD9\u6761\u547D\u4EE4\u6309\u4EA4\u4ED8\u98CE\u63A7\u662F ${verdict.risk} / ${verdict.execution}\uFF08${verdict.reasonCode}\uFF09\uFF0C\u6CA1\u6709\u8DD1\u3002\u7528\u4F8B\u53EA\u8DD1\u53EA\u8BFB\uFF1B\u8981\u5199\u6570\u636E\u8D70 hcm delivery assess \u2192 prepare \u2192 execute\u3002`
|
|
10502
|
-
});
|
|
10503
|
-
continue;
|
|
10504
|
-
}
|
|
10505
|
-
if (opts.env && !argv2.includes("--env")) argv2.push("--env", opts.env);
|
|
10506
|
-
const as2 = c.as ?? opts.as;
|
|
10507
|
-
if (as2 && !argv2.includes("--as")) argv2.push("--as", as2);
|
|
10508
|
-
const r2 = deps.hcm(argv2, root);
|
|
10509
|
-
const want = c.expect ?? {};
|
|
10510
|
-
const bad = [];
|
|
10511
|
-
if (want.exit !== void 0 && r2.status !== want.exit) bad.push(`\u9000\u51FA\u7801 ${r2.status} \u2260 ${want.exit}`);
|
|
10512
|
-
for (const t of want.stdout_contains ?? []) if (!r2.stdout.includes(t)) bad.push(`\u8F93\u51FA\u91CC\u6CA1\u6709\u300C${t}\u300D`);
|
|
10513
|
-
for (const t of want.stdout_not_contains ?? []) if (r2.stdout.includes(t)) bad.push(`\u8F93\u51FA\u91CC\u51FA\u73B0\u4E86\u4E0D\u8BE5\u6709\u7684\u300C${t}\u300D`);
|
|
10514
|
-
if (want.json) {
|
|
10515
|
-
const parsed = parseJsonLoose(r2.stdout);
|
|
10516
|
-
if (parsed === void 0) bad.push("\u8F93\u51FA\u4E0D\u662F JSON\uFF0C\u65E0\u6CD5\u6309 json \u5224\u636E\u6BD4\u5BF9");
|
|
10517
|
-
if (parsed !== void 0) {
|
|
10518
|
-
for (const [expr, rule] of Object.entries(want.json)) {
|
|
10519
|
-
const actual = pick(parsed, expr);
|
|
10520
|
-
if (!matches(actual, rule)) bad.push(`${expr} \u5B9E\u9645 ${JSON.stringify(actual)}\uFF0C\u671F\u671B ${rule}`);
|
|
10521
|
-
}
|
|
10522
|
-
}
|
|
10523
|
-
}
|
|
10524
|
-
if (c.capture && bad.length === 0) {
|
|
10525
|
-
const parsed = parseJsonLoose(r2.stdout);
|
|
10526
|
-
for (const [name, expr] of Object.entries(c.capture)) {
|
|
10527
|
-
const v = pick(parsed, expr);
|
|
10528
|
-
if (v === void 0 || v === null || String(v) === "") bad.push(`\u8981\u6355\u83B7\u7684 ${name}\uFF08${expr}\uFF09\u5728\u8F93\u51FA\u91CC\u53D6\u4E0D\u5230`);
|
|
10529
|
-
else vars[name] = String(v);
|
|
10530
|
-
}
|
|
10531
|
-
}
|
|
10532
|
-
results.push(bad.length ? { name: c.name, verdict: "fail", detail: `${bad.join("\uFF1B")}${r2.stderr.trim() ? `\uFF5Cstderr: ${r2.stderr.trim().split("\n")[0]}` : ""}` } : { name: c.name, verdict: hasContentAssertion(c) ? "pass" : "step", detail: c.capture ? `\u6355\u83B7 ${Object.keys(c.capture).join("\u3001")}` : "" });
|
|
10533
|
-
continue;
|
|
10534
|
-
}
|
|
10535
|
-
if (c.file) {
|
|
10536
|
-
const file = path11.resolve(root, fill(c.file));
|
|
10537
|
-
const want = c.expect ?? {};
|
|
10538
|
-
const bad = [];
|
|
10539
|
-
if (want.xlsx_header || want.xlsx_min_rows !== void 0) {
|
|
10540
|
-
const rows = deps.readXlsx(file);
|
|
10541
|
-
const header = (rows[0] ?? []).map((x) => String(x).trim());
|
|
10542
|
-
for (const h of want.xlsx_header ?? []) if (!header.includes(h)) bad.push(`\u8868\u5934\u91CC\u6CA1\u6709\u300C${h}\u300D\uFF0C\u5B9E\u9645\u662F [${header.slice(0, 8).join(", ")}]`);
|
|
10543
|
-
if (want.xlsx_min_rows !== void 0 && rows.length - 1 < want.xlsx_min_rows) bad.push(`\u6570\u636E\u884C ${Math.max(rows.length - 1, 0)} \u5C11\u4E8E ${want.xlsx_min_rows}`);
|
|
10544
|
-
}
|
|
10545
|
-
if (want.text_contains) {
|
|
10546
|
-
const text = await deps.readText(file);
|
|
10547
|
-
for (const t of want.text_contains) if (!text.includes(t)) bad.push(`\u6587\u4EF6\u91CC\u6CA1\u6709\u300C${t}\u300D`);
|
|
10548
|
-
}
|
|
10549
|
-
results.push(bad.length ? { name: c.name, verdict: "fail", detail: bad.join("\uFF1B") } : { name: c.name, verdict: "pass", detail: "" });
|
|
10550
|
-
continue;
|
|
10551
|
-
}
|
|
10552
|
-
const out = path11.join("evidence", "test", `${spec.name}-${c.name}`.replace(/[^\w一-龥-]+/g, "_") + ".png");
|
|
10553
|
-
const argv = ["--path", fill(c.page), "--out", out];
|
|
10554
|
-
if (opts.env) argv.push("--env", opts.env);
|
|
10555
|
-
const as = c.as ?? opts.as;
|
|
10556
|
-
if (as) argv.push("--as", as);
|
|
10557
|
-
for (const t of c.expect_text ?? []) argv.push("--expect-text", t);
|
|
10558
|
-
for (const t of c.reject_text ?? []) argv.push("--reject-text", t);
|
|
10559
|
-
const r = deps.pageAcceptance(root, argv);
|
|
10560
|
-
results.push(r.status === 0 ? { name: c.name, verdict: "pass", detail: out } : { name: c.name, verdict: "fail", detail: (r.stderr || r.stdout).trim().split("\n").slice(-1)[0] ?? `\u9000\u51FA\u7801 ${r.status}` });
|
|
10561
|
-
} catch (e) {
|
|
10562
|
-
results.push({ name: c.name, verdict: "fail", detail: e.message });
|
|
10563
|
-
}
|
|
10255
|
+
function forbidden(reasonCode, reason) {
|
|
10256
|
+
return { risk: "R3", execution: "forbidden", effect: reasonCode, reasonCode, reason };
|
|
10257
|
+
}
|
|
10258
|
+
function evidenceFor(risk) {
|
|
10259
|
+
if (risk === "R0") return ["command-digest", "discovery-result"];
|
|
10260
|
+
if (risk === "R1") return ["command-digest", "target-aliases", "result-summary"];
|
|
10261
|
+
if (risk === "R2") {
|
|
10262
|
+
return [
|
|
10263
|
+
"command-digest",
|
|
10264
|
+
"explicit-target-aliases",
|
|
10265
|
+
"pre-state-or-dry-run",
|
|
10266
|
+
"rollback-plan",
|
|
10267
|
+
"execution-receipt",
|
|
10268
|
+
"post-verification"
|
|
10269
|
+
];
|
|
10564
10270
|
}
|
|
10565
|
-
return
|
|
10271
|
+
return ["governance-decision"];
|
|
10566
10272
|
}
|
|
10567
|
-
|
|
10568
|
-
|
|
10569
|
-
|
|
10570
|
-
|
|
10571
|
-
|
|
10572
|
-
|
|
10573
|
-
assertUsableSpec(spec, path11.basename(f));
|
|
10574
|
-
out.push({ file: f, spec });
|
|
10273
|
+
function flagValue(argv, flag) {
|
|
10274
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
10275
|
+
const arg = argv[index];
|
|
10276
|
+
if (arg === void 0) continue;
|
|
10277
|
+
if (arg === flag) return argv[index + 1];
|
|
10278
|
+
if (arg.startsWith(`${flag}=`)) return arg.slice(flag.length + 1);
|
|
10575
10279
|
}
|
|
10576
|
-
|
|
10577
|
-
return out;
|
|
10280
|
+
return void 0;
|
|
10578
10281
|
}
|
|
10579
|
-
|
|
10580
|
-
|
|
10581
|
-
|
|
10582
|
-
|
|
10583
|
-
|
|
10584
|
-
|
|
10585
|
-
|
|
10586
|
-
|
|
10587
|
-
|
|
10588
|
-
|
|
10589
|
-
|
|
10590
|
-
|
|
10591
|
-
const
|
|
10592
|
-
if (
|
|
10593
|
-
|
|
10594
|
-
} else {
|
|
10595
|
-
for (const c of report) {
|
|
10596
|
-
process.stdout.write(`
|
|
10597
|
-
${c.case}\uFF08${c.file}\uFF09
|
|
10598
|
-
`);
|
|
10599
|
-
for (const r of c.results) {
|
|
10600
|
-
const mark = r.verdict === "pass" ? "\u2705" : r.verdict === "step" ? "\xB7" : r.verdict === "warn" ? "\u26A0\uFE0F" : "\u274C";
|
|
10601
|
-
process.stdout.write(` ${mark} ${r.name}${r.detail ? ` ${r.detail}` : ""}
|
|
10602
|
-
`);
|
|
10603
|
-
}
|
|
10604
|
-
}
|
|
10605
|
-
const verified = report.reduce((n, c) => n + c.results.filter((r) => r.verdict === "pass").length, 0);
|
|
10606
|
-
process.stdout.write(failed2 === 0 ? `
|
|
10607
|
-
\u5168\u90E8\u901A\u8FC7\uFF08\u771F\u5224\u8FC7\u5185\u5BB9\u7684 ${verified} \u6761\uFF1B\u5E26 \xB7 \u7684\u662F\u6B65\u9AA4\uFF0C\u4E0D\u7B97\u9A8C\u8BC1\uFF09\u3002
|
|
10608
|
-
` : `
|
|
10609
|
-
${failed2} \u6761\u6CA1\u8FC7\u2014\u2014\u4E0A\u9762\u6BCF\u6761\u90FD\u5199\u4E86\u5B9E\u9645\u503C\u4E0E\u671F\u671B\uFF0C\u7167\u7740\u67E5\u3002
|
|
10610
|
-
`);
|
|
10611
|
-
}
|
|
10612
|
-
process.exitCode = failed2 === 0 ? 0 : 1;
|
|
10613
|
-
} catch (e) {
|
|
10614
|
-
exitWithError(e);
|
|
10282
|
+
function hasFlag(argv, flag) {
|
|
10283
|
+
return argv.some((arg) => arg === flag || arg.startsWith(`${flag}=`));
|
|
10284
|
+
}
|
|
10285
|
+
function flagName(arg) {
|
|
10286
|
+
const equals = arg.indexOf("=");
|
|
10287
|
+
return equals < 0 ? arg : arg.slice(0, equals);
|
|
10288
|
+
}
|
|
10289
|
+
function valuesAfterFlag(argv, flag) {
|
|
10290
|
+
const index = argv.indexOf(flag);
|
|
10291
|
+
if (index < 0) return [];
|
|
10292
|
+
const values = [];
|
|
10293
|
+
for (let cursor = index + 1; cursor < argv.length; cursor += 1) {
|
|
10294
|
+
const value = argv[cursor];
|
|
10295
|
+
if (value === void 0 || value.startsWith("-")) break;
|
|
10296
|
+
values.push(value);
|
|
10615
10297
|
}
|
|
10298
|
+
return values;
|
|
10299
|
+
}
|
|
10300
|
+
function sha2564(value) {
|
|
10301
|
+
return createHash5("sha256").update(value).digest("hex");
|
|
10302
|
+
}
|
|
10303
|
+
function isPlainObject(value) {
|
|
10304
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
10616
10305
|
}
|
|
10617
10306
|
|
|
10618
|
-
// src/commands/
|
|
10619
|
-
|
|
10620
|
-
|
|
10621
|
-
|
|
10622
|
-
|
|
10623
|
-
|
|
10624
|
-
|
|
10625
|
-
resolveActiveEnv as resolveActiveEnv5
|
|
10626
|
-
} from "@hcmai/sdk";
|
|
10627
|
-
init_exit();
|
|
10628
|
-
|
|
10629
|
-
// src/jira/refs.ts
|
|
10630
|
-
import { execFileSync as execFileSync2 } from "child_process";
|
|
10631
|
-
var defaultCnb = (args) => execFileSync2("cnb", args, { encoding: "utf8", maxBuffer: 1 << 26, stdio: ["ignore", "pipe", "pipe"] });
|
|
10632
|
-
var PRODUCT_REPOS = ["hcm/hcm_nx_core", "hcm/hcm_nx_cli", "hcm/hcm_nx_cloud"];
|
|
10633
|
-
var REF_RE = /hcm\/(hcm_nx_(?:core|cli|cloud))(?:#|\/-\/issues\/)(\d+)/g;
|
|
10634
|
-
function linkedRepoRefs(text) {
|
|
10635
|
-
const out = /* @__PURE__ */ new Map();
|
|
10636
|
-
for (const m of String(text ?? "").matchAll(REF_RE)) {
|
|
10637
|
-
out.set(`hcm/${m[1]}#${m[2]}`, { repo: `hcm/${m[1]}`, number: m[2] });
|
|
10638
|
-
}
|
|
10639
|
-
return [...out.values()];
|
|
10640
|
-
}
|
|
10641
|
-
function parseCnbIssueOutput(raw) {
|
|
10642
|
-
const fields = {};
|
|
10643
|
-
let status;
|
|
10644
|
-
for (const line of raw.split("\n")) {
|
|
10645
|
-
const head = line.match(/^status:\s*(\d+)\s*$/);
|
|
10646
|
-
if (head && status === void 0) {
|
|
10647
|
-
status = Number(head[1]);
|
|
10648
|
-
continue;
|
|
10649
|
-
}
|
|
10650
|
-
const m = line.match(/^\s+(number|title|state|state_reason|priority|url|htmlUrl|created_at|updated_at|closed_at):\s*(.*)$/);
|
|
10651
|
-
if (!m) continue;
|
|
10652
|
-
const key2 = m[1];
|
|
10653
|
-
if (fields[key2] !== void 0) continue;
|
|
10654
|
-
fields[key2] = m[2].trim().replace(/^"|"$/g, "");
|
|
10307
|
+
// src/commands/delivery-action-policy.ts
|
|
10308
|
+
async function assessEffectiveDeliveryCommand(inputArgv, dependencies = {}) {
|
|
10309
|
+
const local = assessDeliveryCommand(inputArgv);
|
|
10310
|
+
if (local.reasonCode !== "action-effect-unclassified") return local;
|
|
10311
|
+
const request = parseActionRequest(inputArgv);
|
|
10312
|
+
if ("status" in request) {
|
|
10313
|
+
return assessDeliveryCommand(inputArgv, { actionResolution: request });
|
|
10655
10314
|
}
|
|
10656
|
-
|
|
10315
|
+
const resolution = await (dependencies.resolveAction ?? resolveCoreAction)(request);
|
|
10316
|
+
return assessDeliveryCommand(inputArgv, { actionResolution: resolution });
|
|
10657
10317
|
}
|
|
10658
|
-
function
|
|
10659
|
-
let raw;
|
|
10318
|
+
async function resolveCoreAction(request) {
|
|
10660
10319
|
try {
|
|
10661
|
-
|
|
10662
|
-
|
|
10663
|
-
|
|
10320
|
+
const auth = await getActiveAuthContextFromCli({
|
|
10321
|
+
env: request.env,
|
|
10322
|
+
as: request.identity,
|
|
10323
|
+
profile: request.profile
|
|
10324
|
+
});
|
|
10325
|
+
const description = await HcmClient22.fromAuthContext(auth).describe(request.model);
|
|
10326
|
+
const named = description.actions.filter((action) => action.name === request.action);
|
|
10327
|
+
if (named.length === 0) {
|
|
10328
|
+
const degraded = description.effectiveActionsAvailable ? "" : `\u26A0\uFE0F \u672C\u6B21\u6BD4\u5BF9\u4E0D\u542B\u811A\u672C Action\u2014\u2014${description.effectiveActionsNote ?? "\u539F\u56E0\u672A\u77E5"}\u3002`;
|
|
10329
|
+
return failed(
|
|
10330
|
+
"action-metadata-not-found",
|
|
10331
|
+
`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`
|
|
10332
|
+
);
|
|
10333
|
+
}
|
|
10334
|
+
const matches2 = request.explicitShape ? named.filter((action) => matchesRequest(action, request)) : named;
|
|
10335
|
+
if (matches2.length === 0) {
|
|
10336
|
+
const shapes = named.map((a) => `scope=${a.scope ?? "?"} method=${(a.httpMethod ?? "?").toUpperCase()}`).join("\uFF1B");
|
|
10337
|
+
return failed(
|
|
10338
|
+
"action-shape-mismatch",
|
|
10339
|
+
`${request.model}.${request.action} \u5B58\u5728\uFF0C\u4F46\u5F62\u6001\u5BF9\u4E0D\u4E0A\uFF1A\u4F60\u7ED9\u7684\u662F scope=${request.scope} method=${request.httpMethod}\uFF0C\u5143\u6570\u636E\u91CC\u662F ${shapes}\u3002next_step=\u53BB\u6389 --scope/--method \u8BA9 CLI \u6309\u5143\u6570\u636E\u81EA\u52A8\u5224\u5B9A\uFF0C\u6216\u6539\u6210\u4E0A\u9762\u7684\u5F62\u6001`
|
|
10340
|
+
);
|
|
10341
|
+
}
|
|
10342
|
+
if (matches2.length > 1) {
|
|
10343
|
+
return failed(
|
|
10344
|
+
"action-metadata-ambiguous",
|
|
10345
|
+
`${request.model}.${request.action} \u5728\u5143\u6570\u636E\u91CC\u6709\u591A\u79CD\u5F62\u6001\uFF0C\u65E0\u6CD5\u552F\u4E00\u5224\u5B9A\u3002next_step=\u7528 --scope \u4E0E --method \u6307\u660E\u8981\u8C03\u54EA\u4E00\u4E2A`
|
|
10346
|
+
);
|
|
10347
|
+
}
|
|
10348
|
+
return policyFromActionMeta(matches2[0], request);
|
|
10349
|
+
} catch {
|
|
10350
|
+
return failed(
|
|
10351
|
+
"action-metadata-unavailable",
|
|
10352
|
+
"\u65E0\u6CD5\u8BFB\u53D6 Core Action \u5143\u6570\u636E\uFF0C\u6309\u5B89\u5168\u9ED8\u8BA4\u62D2\u7EDD\u6267\u884C\u3002"
|
|
10353
|
+
);
|
|
10664
10354
|
}
|
|
10665
|
-
|
|
10666
|
-
|
|
10667
|
-
|
|
10668
|
-
|
|
10355
|
+
}
|
|
10356
|
+
function policyFromActionMeta(action, request) {
|
|
10357
|
+
const shape = {
|
|
10358
|
+
scope: action.scope ?? request.scope,
|
|
10359
|
+
httpMethod: (action.httpMethod ?? request.httpMethod).toUpperCase(),
|
|
10360
|
+
...action.source ? { source: action.source } : {}
|
|
10361
|
+
};
|
|
10362
|
+
const effectClass = classifyEffect(action.effect);
|
|
10363
|
+
if (effectClass === "absent") {
|
|
10364
|
+
if (typeof action.readOnly !== "boolean") {
|
|
10365
|
+
return failed(
|
|
10366
|
+
"action-readonly-unclassified",
|
|
10367
|
+
"Core \u672A\u8FD4\u56DE Action \u7684 effect \u4E09\u6001\u58F0\u660E\uFF0C\u4E5F\u6CA1\u6709\u56DE\u843D\u7528\u7684 readOnly \u5E03\u5C14\uFF0C\u6309\u5B89\u5168\u9ED8\u8BA4\u62D2\u7EDD\u6267\u884C\u3002"
|
|
10368
|
+
);
|
|
10369
|
+
}
|
|
10370
|
+
return { status: "resolved", policy: { ...shape, readOnly: action.readOnly } };
|
|
10669
10371
|
}
|
|
10670
|
-
if (!fields.state) return { kind: "unreadable", repo, number, reason: "cnb \u8F93\u51FA\u91CC\u6CA1\u6709 state \u5B57\u6BB5" };
|
|
10671
10372
|
return {
|
|
10672
|
-
|
|
10673
|
-
|
|
10674
|
-
|
|
10675
|
-
|
|
10676
|
-
|
|
10677
|
-
|
|
10678
|
-
|
|
10679
|
-
url: repoIssueUrl(repo, number)
|
|
10373
|
+
status: "resolved",
|
|
10374
|
+
policy: {
|
|
10375
|
+
...shape,
|
|
10376
|
+
effect: effectClass,
|
|
10377
|
+
...effectClass === "unrecognized-effect" ? { effectRaw: action.effect } : {},
|
|
10378
|
+
readOnly: effectClass === "read-only"
|
|
10379
|
+
}
|
|
10680
10380
|
};
|
|
10681
10381
|
}
|
|
10682
|
-
|
|
10683
|
-
|
|
10684
|
-
if (s.kind === "not-issue") return `${s.repo}#${s.number} \uFF08\u4E0D\u662F issue\uFF0C\u53EF\u80FD\u662F PR \u53F7\uFF1B\u4E0D\u8BA1\u5165\uFF09`;
|
|
10685
|
-
return `${s.repo}#${s.number} \uFF08\u8BFB\u4E0D\u5230\uFF1A${s.reason}\uFF09`;
|
|
10686
|
-
};
|
|
10687
|
-
function parseCnbIssueList(raw, repo) {
|
|
10688
|
-
const out = [];
|
|
10689
|
-
let cur = null;
|
|
10690
|
-
for (const line of raw.split("\n")) {
|
|
10691
|
-
const m = line.match(/^\s*-?\s*(number|title|state|state_reason|priority):\s*(.*)$/);
|
|
10692
|
-
if (!m) continue;
|
|
10693
|
-
const key2 = m[1];
|
|
10694
|
-
const value = m[2].trim().replace(/^"|"$/g, "");
|
|
10695
|
-
if (key2 === "number") {
|
|
10696
|
-
if (cur?.number) out.push(finishRow(cur, repo));
|
|
10697
|
-
cur = { number: value };
|
|
10698
|
-
continue;
|
|
10699
|
-
}
|
|
10700
|
-
if (cur && cur[key2] === void 0) cur[key2] = value;
|
|
10701
|
-
}
|
|
10702
|
-
if (cur?.number) out.push(finishRow(cur, repo));
|
|
10703
|
-
return out;
|
|
10382
|
+
function matchesRequest(action, request) {
|
|
10383
|
+
return action.name === request.action && action.httpMethod?.toUpperCase() === request.httpMethod && action.scope?.toLowerCase() === request.scope;
|
|
10704
10384
|
}
|
|
10705
|
-
function
|
|
10385
|
+
function parseActionRequest(inputArgv) {
|
|
10386
|
+
const argv = normalizeAssessedArgv(inputArgv);
|
|
10387
|
+
const spec = argv[1] ?? "";
|
|
10388
|
+
const separator = spec.indexOf(".");
|
|
10389
|
+
if (separator <= 0 || separator === spec.length - 1) {
|
|
10390
|
+
return failed("invalid-action-spec", "Action \u5FC5\u987B\u4F7F\u7528 <Model>.<Action> \u683C\u5F0F\u3002");
|
|
10391
|
+
}
|
|
10392
|
+
const explicitMethod = flagValue2(argv, "--method");
|
|
10393
|
+
const httpMethod = (explicitMethod ?? "POST").toUpperCase();
|
|
10394
|
+
if (!["GET", "POST", "PUT", "DELETE"].includes(httpMethod)) {
|
|
10395
|
+
return failed("invalid-action-method", "Action method \u5FC5\u987B\u662F GET\u3001POST\u3001PUT \u6216 DELETE\u3002");
|
|
10396
|
+
}
|
|
10397
|
+
const explicitScope = flagValue2(argv, "--scope");
|
|
10398
|
+
const scope = explicitScope ?? (flagValue2(argv, "--id") ? "object" : "class");
|
|
10399
|
+
if (scope !== "class" && scope !== "object") {
|
|
10400
|
+
return failed("invalid-action-scope", "Action scope \u5FC5\u987B\u662F class \u6216 object\u3002");
|
|
10401
|
+
}
|
|
10706
10402
|
return {
|
|
10707
|
-
|
|
10708
|
-
|
|
10709
|
-
|
|
10710
|
-
|
|
10711
|
-
|
|
10712
|
-
|
|
10713
|
-
|
|
10403
|
+
model: spec.slice(0, separator),
|
|
10404
|
+
action: spec.slice(separator + 1),
|
|
10405
|
+
httpMethod,
|
|
10406
|
+
scope,
|
|
10407
|
+
...explicitMethod !== void 0 || explicitScope !== void 0 ? { explicitShape: true } : {},
|
|
10408
|
+
env: flagValue2(argv, "--env"),
|
|
10409
|
+
identity: flagValue2(argv, "--as"),
|
|
10410
|
+
profile: flagValue2(argv, "--profile")
|
|
10714
10411
|
};
|
|
10715
10412
|
}
|
|
10716
|
-
function
|
|
10717
|
-
|
|
10718
|
-
return parseCnbIssueList(
|
|
10719
|
-
cnb(["issues", "list-issues", "--repo", repo, "--keyword", keyword, "--state", state, "--page-size", "20"]),
|
|
10720
|
-
repo
|
|
10721
|
-
);
|
|
10722
|
-
} catch {
|
|
10723
|
-
return [];
|
|
10724
|
-
}
|
|
10413
|
+
function failed(reasonCode, reason) {
|
|
10414
|
+
return { status: "failed", reasonCode, reason };
|
|
10725
10415
|
}
|
|
10726
|
-
function
|
|
10727
|
-
const
|
|
10728
|
-
|
|
10729
|
-
|
|
10730
|
-
|
|
10731
|
-
if (m) return { kind: "repo", repo: casesSlug, number: m[1] };
|
|
10732
|
-
m = r.match(/^([A-Z][A-Z0-9_]+)-(\d+)$/i);
|
|
10733
|
-
if (m) return { kind: "jira", key: `${m[1].toUpperCase()}-${m[2]}` };
|
|
10734
|
-
m = r.match(/^(\d+)$/);
|
|
10735
|
-
if (m) return { kind: "jira", key: `${project}-${m[1]}` };
|
|
10736
|
-
return null;
|
|
10416
|
+
function flagValue2(argv, flag) {
|
|
10417
|
+
const equals = argv.find((arg) => arg.startsWith(`${flag}=`));
|
|
10418
|
+
if (equals) return equals.slice(flag.length + 1);
|
|
10419
|
+
const index = argv.indexOf(flag);
|
|
10420
|
+
return index >= 0 ? argv[index + 1] : void 0;
|
|
10737
10421
|
}
|
|
10738
|
-
var firstLine2 = (s) => String(s ?? "").split("\n").find((l) => l.trim())?.trim() ?? "";
|
|
10739
10422
|
|
|
10740
|
-
// src/
|
|
10741
|
-
|
|
10742
|
-
|
|
10743
|
-
|
|
10744
|
-
|
|
10745
|
-
|
|
10746
|
-
|
|
10747
|
-
|
|
10748
|
-
|
|
10749
|
-
|
|
10750
|
-
];
|
|
10751
|
-
function validateGapInput(x) {
|
|
10752
|
-
if (!x || typeof x !== "object") throw new Error("\u7F3A\u53E3\u8F7D\u8377\u5FC5\u987B\u662F\u4E00\u4E2A JSON \u5BF9\u8C61");
|
|
10753
|
-
const g = x;
|
|
10754
|
-
const problems = [];
|
|
10755
|
-
for (const [k, min] of MIN_LEN) {
|
|
10756
|
-
const v = g[k];
|
|
10757
|
-
if (typeof v !== "string" || v.trim().length < min) problems.push(`${k} \u81F3\u5C11 ${min} \u4E2A\u5B57`);
|
|
10423
|
+
// src/commands/xlsx-peek.ts
|
|
10424
|
+
import { readFileSync as readFileSync6 } from "fs";
|
|
10425
|
+
import { inflateRawSync } from "zlib";
|
|
10426
|
+
function readZip(buf, want) {
|
|
10427
|
+
let eocd = -1;
|
|
10428
|
+
for (let i = buf.length - 22; i >= 0 && i > buf.length - 66e3; i--) {
|
|
10429
|
+
if (buf.readUInt32LE(i) === 101010256) {
|
|
10430
|
+
eocd = i;
|
|
10431
|
+
break;
|
|
10432
|
+
}
|
|
10758
10433
|
}
|
|
10759
|
-
if (
|
|
10760
|
-
|
|
10761
|
-
|
|
10762
|
-
|
|
10763
|
-
|
|
10764
|
-
|
|
10765
|
-
|
|
10766
|
-
|
|
10767
|
-
|
|
10768
|
-
|
|
10769
|
-
|
|
10770
|
-
|
|
10771
|
-
|
|
10772
|
-
|
|
10773
|
-
|
|
10774
|
-
|
|
10775
|
-
|
|
10776
|
-
|
|
10777
|
-
|
|
10778
|
-
|
|
10779
|
-
|
|
10780
|
-
|
|
10781
|
-
|
|
10782
|
-
|
|
10783
|
-
|
|
10784
|
-
"",
|
|
10785
|
-
"h2. \u66FF\u4EE3\u6CD5",
|
|
10786
|
-
g.alternative,
|
|
10787
|
-
"",
|
|
10788
|
-
"h2. \u4E25\u91CD\u5EA6",
|
|
10789
|
-
`${g.severity}\uFF08\u987E\u95EE\u4FA7\u5224\u5B9A\uFF1A\u963B\u65AD=\u4EA4\u4ED8\u505C\u4E0B / \u6709\u66FF\u4EE3\u6CD5=\u80FD\u7ED5 / \u63AA\u8F9E\u7EA7=\u8F93\u51FA\u5DF2\u7ED9\u8DEF\u6807\uFF09`,
|
|
10790
|
-
"",
|
|
10791
|
-
"h2. \u4E09\u95EE\u81EA\u7B54",
|
|
10792
|
-
`# \u673A\u5236\u8FB9\u754C\uFF1A${g.q_mechanism}`,
|
|
10793
|
-
`# \u5386\u53F2\uFF1A${g.q_history}`,
|
|
10794
|
-
`# \u6280\u80FD\u6709\u6CA1\u6709\u6559\u9519\uFF1A${g.q_skill}`,
|
|
10795
|
-
"",
|
|
10796
|
-
"h2. \u5173\u952E\u8BCD",
|
|
10797
|
-
[g.error_code, g.model, g.action].filter(Boolean).join(" \xB7 ") || "\uFF08\u65E0\uFF09",
|
|
10798
|
-
"",
|
|
10799
|
-
"_\u7531\u987E\u95EE agent \u7ECF `hcm jira submit` \u63D0\u4EA4\u3002\u5206\u8BCA\u4E09\u53BB\u5411\uFF1A\u8F6C\u4EA7\u54C1\u4ED3 issue \u5E76\u56DE\u94FE / \u6539\u6280\u80FD\u5E76\u56DE\u590D / \u5408\u5E76\u8BA1\u6570\u3002\u5904\u7406\u529E\u6CD5\u89C1\u4EA7\u54C1\u4ED3\u6280\u80FD jira-triage\u3002_"
|
|
10800
|
-
].join("\n");
|
|
10434
|
+
if (eocd < 0) throw new Error("\u4E0D\u662F\u6709\u6548\u7684 zip/xlsx\uFF08\u627E\u4E0D\u5230\u4E2D\u592E\u76EE\u5F55\uFF09");
|
|
10435
|
+
const count = buf.readUInt16LE(eocd + 10);
|
|
10436
|
+
let p = buf.readUInt32LE(eocd + 16);
|
|
10437
|
+
const out = [];
|
|
10438
|
+
for (let n = 0; n < count; n++) {
|
|
10439
|
+
if (buf.readUInt32LE(p) !== 33639248) break;
|
|
10440
|
+
const method = buf.readUInt16LE(p + 10);
|
|
10441
|
+
const compressedSize = buf.readUInt32LE(p + 20);
|
|
10442
|
+
const nameLen = buf.readUInt16LE(p + 28);
|
|
10443
|
+
const extraLen = buf.readUInt16LE(p + 30);
|
|
10444
|
+
const commentLen = buf.readUInt16LE(p + 32);
|
|
10445
|
+
const localOffset = buf.readUInt32LE(p + 42);
|
|
10446
|
+
const name = buf.subarray(p + 46, p + 46 + nameLen).toString("utf8");
|
|
10447
|
+
if (want(name)) {
|
|
10448
|
+
const lnameLen = buf.readUInt16LE(localOffset + 26);
|
|
10449
|
+
const lextraLen = buf.readUInt16LE(localOffset + 28);
|
|
10450
|
+
const start = localOffset + 30 + lnameLen + lextraLen;
|
|
10451
|
+
const raw = buf.subarray(start, start + compressedSize);
|
|
10452
|
+
if (method === 0) out.push({ name, data: Buffer.from(raw) });
|
|
10453
|
+
else if (method === 8) out.push({ name, data: inflateRawSync(raw) });
|
|
10454
|
+
else throw new Error(`xlsx \u91CC\u7684 ${name} \u7528\u4E86\u4E0D\u652F\u6301\u7684\u538B\u7F29\u65B9\u5F0F ${method}`);
|
|
10455
|
+
}
|
|
10456
|
+
p += 46 + nameLen + extraLen + commentLen;
|
|
10457
|
+
}
|
|
10458
|
+
return out;
|
|
10801
10459
|
}
|
|
10802
|
-
|
|
10803
|
-
|
|
10804
|
-
|
|
10805
|
-
|
|
10806
|
-
|
|
10807
|
-
|
|
10808
|
-
|
|
10809
|
-
|
|
10810
|
-
const
|
|
10811
|
-
|
|
10812
|
-
|
|
10813
|
-
|
|
10814
|
-
|
|
10815
|
-
|
|
10816
|
-
|
|
10817
|
-
|
|
10818
|
-
const
|
|
10819
|
-
|
|
10820
|
-
|
|
10460
|
+
var decode = (s) => s.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/'/g, "'").replace(/&/g, "&");
|
|
10461
|
+
function xlsxRows(file, maxRows = 50) {
|
|
10462
|
+
const buf = readFileSync6(file);
|
|
10463
|
+
const [sheet] = readZip(buf, (n) => n === "xl/worksheets/sheet1.xml");
|
|
10464
|
+
if (!sheet) throw new Error(`${file} \u91CC\u6CA1\u6709 xl/worksheets/sheet1.xml\uFF0C\u53EF\u80FD\u4E0D\u662F xlsx`);
|
|
10465
|
+
const [shared] = readZip(buf, (n) => n === "xl/sharedStrings.xml");
|
|
10466
|
+
const sharedStrings = [];
|
|
10467
|
+
if (shared) {
|
|
10468
|
+
for (const si of shared.data.toString("utf8").split("<si>").slice(1)) {
|
|
10469
|
+
sharedStrings.push(decode([...si.matchAll(/<t[^>]*>([\s\S]*?)<\/t>/g)].map((m) => m[1] ?? "").join("")));
|
|
10470
|
+
}
|
|
10471
|
+
}
|
|
10472
|
+
const xml = sheet.data.toString("utf8");
|
|
10473
|
+
const rows = [];
|
|
10474
|
+
for (const rowXml of xml.split("<row").slice(1)) {
|
|
10475
|
+
if (rows.length >= maxRows) break;
|
|
10476
|
+
const cells = [];
|
|
10477
|
+
for (const m of rowXml.matchAll(/<c\b([^>]*)>([\s\S]*?)<\/c>/g)) {
|
|
10478
|
+
const attrs = m[1] ?? "";
|
|
10479
|
+
const body = m[2] ?? "";
|
|
10480
|
+
const v = /<v>([\s\S]*?)<\/v>/.exec(body)?.[1] ?? "";
|
|
10481
|
+
const inline = [...body.matchAll(/<t[^>]*>([\s\S]*?)<\/t>/g)].map((x) => x[1] ?? "").join("");
|
|
10482
|
+
if (/t="s"/.test(attrs)) cells.push(sharedStrings[Number(v)] ?? "");
|
|
10483
|
+
else if (inline) cells.push(decode(inline));
|
|
10484
|
+
else cells.push(decode(v));
|
|
10485
|
+
}
|
|
10486
|
+
rows.push(cells);
|
|
10821
10487
|
}
|
|
10822
|
-
return
|
|
10488
|
+
return rows;
|
|
10823
10489
|
}
|
|
10824
|
-
|
|
10825
|
-
|
|
10826
|
-
var
|
|
10827
|
-
|
|
10828
|
-
|
|
10829
|
-
|
|
10830
|
-
};
|
|
10831
|
-
var MODULE_DEFAULT_CHILD = { "HCM-Core": "\u57FA\u7840\u8BBE\u7F6E", "HCM-Cloud": "\u5F00\u53D1\u5E73\u53F0", \u4EA7\u54C1\u652F\u6301: "\u4EA7\u54C1\u652F\u6301" };
|
|
10832
|
-
function buildGapFields(g, ctx) {
|
|
10833
|
-
const wanted = KIND_TO_TYPE[g.kind] ?? [];
|
|
10834
|
-
const type = ctx.issuetypeOverride && ctx.types.find((t) => t.name === ctx.issuetypeOverride) || wanted.map((n) => ctx.types.find((t) => t.name === n)).find(Boolean);
|
|
10835
|
-
if (!type) {
|
|
10836
|
-
throw new Error(`\u9879\u76EE ${ctx.project} \u91CC\u6CA1\u6709\u300C${wanted.join(" / ")}\u300D\u8FD9\u7C7B issuetype\uFF0C\u5B9E\u9645\u6709\uFF1A${ctx.types.map((t) => t.name).join(" / ")}`);
|
|
10490
|
+
|
|
10491
|
+
// src/commands/chiron-test.ts
|
|
10492
|
+
var CONTENT_KEYS = ["stdout_contains", "json", "xlsx_header", "xlsx_min_rows", "text_contains"];
|
|
10493
|
+
var hasContentAssertion = (c) => (c.page ? (c.expect_text?.length ?? 0) > 0 : false) || CONTENT_KEYS.some((k) => c.expect?.[k] !== void 0);
|
|
10494
|
+
function assertUsableSpec(spec, where) {
|
|
10495
|
+
if (!spec?.name || !Array.isArray(spec.checks) || spec.checks.length === 0) {
|
|
10496
|
+
throw new Error(`${where}: \u7528\u4F8B\u8981\u6709 name \u4E0E\u81F3\u5C11\u4E00\u6761 checks`);
|
|
10837
10497
|
}
|
|
10838
|
-
|
|
10839
|
-
|
|
10840
|
-
|
|
10841
|
-
|
|
10842
|
-
|
|
10843
|
-
|
|
10844
|
-
|
|
10845
|
-
|
|
10846
|
-
|
|
10847
|
-
|
|
10848
|
-
|
|
10849
|
-
|
|
10850
|
-
|
|
10851
|
-
};
|
|
10852
|
-
|
|
10853
|
-
|
|
10854
|
-
|
|
10855
|
-
|
|
10856
|
-
|
|
10857
|
-
|
|
10858
|
-
|
|
10859
|
-
|
|
10498
|
+
spec.checks.forEach((c, i) => {
|
|
10499
|
+
const at = `${where} \u7B2C ${i + 1} \u6761\u300C${c.name ?? "\u672A\u547D\u540D"}\u300D`;
|
|
10500
|
+
if (!c.name) throw new Error(`${at}: \u7F3A name`);
|
|
10501
|
+
const kinds = [c.run, c.file, c.page].filter(Boolean).length;
|
|
10502
|
+
if (kinds !== 1) throw new Error(`${at}: run / file / page \u5FC5\u987B\u4E14\u53EA\u80FD\u6709\u4E00\u4E2A`);
|
|
10503
|
+
if (c.run) {
|
|
10504
|
+
if (!/^hcm\s/.test(c.run.trim())) {
|
|
10505
|
+
throw new Error(`${at}: run \u53EA\u80FD\u8DD1 hcm \u5B50\u547D\u4EE4\uFF08\u4E0D\u63A5\u53D7\u4EFB\u610F shell\uFF1B\u8981\u7ED5\u8FC7 CLI \u7684\u4E8B\u672C\u6765\u5C31\u4E0D\u8BE5\u505A\uFF09`);
|
|
10506
|
+
}
|
|
10507
|
+
tokenize(c.run);
|
|
10508
|
+
}
|
|
10509
|
+
if (c.page && !c.expect_text?.length) throw new Error(`${at}: \u9875\u9762\u5224\u636E\u81F3\u5C11\u8981\u4E00\u4E2A expect_text\u2014\u2014\u622A\u56FE\u5B58\u5728\u4E0D\u7B49\u4E8E\u9875\u9762\u5BF9`);
|
|
10510
|
+
if (c.file && !hasContentAssertion(c)) throw new Error(`${at}: \u8BFB\u6587\u4EF6\u5374\u6CA1\u6709\u5185\u5BB9\u5224\u636E\uFF08${CONTENT_KEYS.join(" / ")}\uFF09\u2014\u2014\u6587\u4EF6\u5B58\u5728\u4E0D\u7B49\u4E8E\u5185\u5BB9\u5BF9`);
|
|
10511
|
+
});
|
|
10512
|
+
if (!spec.checks.some(hasContentAssertion)) {
|
|
10513
|
+
throw new Error(
|
|
10514
|
+
`${where}: \u6574\u4EFD\u7528\u4F8B\u6CA1\u6709\u4EFB\u4F55\u5185\u5BB9\u5224\u636E\uFF08${CONTENT_KEYS.join(" / ")} / expect_text\uFF09\uFF0C\u53EA\u8DD1\u4E0D\u770B\u7B49\u4E8E\u6CA1\u6D4B\u3002`
|
|
10515
|
+
);
|
|
10516
|
+
}
|
|
10517
|
+
}
|
|
10518
|
+
function tokenize(line) {
|
|
10519
|
+
const out = [];
|
|
10520
|
+
let cur = "";
|
|
10521
|
+
let quote = null;
|
|
10522
|
+
let started = false;
|
|
10523
|
+
for (let i = 0; i < line.length; i++) {
|
|
10524
|
+
const ch = line[i];
|
|
10525
|
+
if (quote) {
|
|
10526
|
+
if (ch === quote) quote = null;
|
|
10527
|
+
else if (ch === "\\" && quote === '"' && i + 1 < line.length) {
|
|
10528
|
+
cur += line[++i];
|
|
10529
|
+
} else cur += ch;
|
|
10860
10530
|
continue;
|
|
10861
10531
|
}
|
|
10862
|
-
if (
|
|
10863
|
-
|
|
10864
|
-
|
|
10865
|
-
if (f.required) unfilled.push(`${f.name}(${f.fieldId}) \u60F3\u586B\u300C${String(want)}\u300D\u4F46\u53EF\u9009\u503C\u53EA\u6709 [${values(f)}]`);
|
|
10866
|
-
continue;
|
|
10867
|
-
}
|
|
10868
|
-
const childName = g.module_detail || MODULE_DEFAULT_CHILD[module];
|
|
10869
|
-
const child = (parent.children ?? []).find((c) => (c.value ?? c.name) === childName);
|
|
10870
|
-
if (!child && (parent.children ?? []).length) {
|
|
10871
|
-
unfilled.push(`${f.name}(${f.fieldId}) \u7684\u4E8C\u7EA7\u9879\u300C${childName}\u300D\u4E0D\u5728 [${(parent.children ?? []).map((c) => c.value ?? c.name).join("|")}] \u91CC`);
|
|
10872
|
-
continue;
|
|
10873
|
-
}
|
|
10874
|
-
fields[f.fieldId] = { id: parent.id, ...child ? { child: { id: child.id } } : {} };
|
|
10532
|
+
if (ch === '"' || ch === "'") {
|
|
10533
|
+
quote = ch;
|
|
10534
|
+
started = true;
|
|
10875
10535
|
continue;
|
|
10876
10536
|
}
|
|
10877
|
-
if (
|
|
10878
|
-
|
|
10879
|
-
|
|
10880
|
-
|
|
10881
|
-
|
|
10882
|
-
|
|
10883
|
-
|
|
10884
|
-
|
|
10885
|
-
|
|
10886
|
-
|
|
10887
|
-
if (f.required) unfilled.push(`${f.name}(${f.fieldId}) \u53D6\u4E0D\u5230\u7528\u6237\u540D`);
|
|
10888
|
-
continue;
|
|
10537
|
+
if (ch === "\\" && i + 1 < line.length) {
|
|
10538
|
+
cur += line[++i];
|
|
10539
|
+
started = true;
|
|
10540
|
+
continue;
|
|
10541
|
+
}
|
|
10542
|
+
if (/\s/.test(ch)) {
|
|
10543
|
+
if (started || cur) {
|
|
10544
|
+
out.push(cur);
|
|
10545
|
+
cur = "";
|
|
10546
|
+
started = false;
|
|
10889
10547
|
}
|
|
10890
|
-
|
|
10891
|
-
} else {
|
|
10892
|
-
fields[f.fieldId] = Array.isArray(want) ? want[0] : want;
|
|
10548
|
+
continue;
|
|
10893
10549
|
}
|
|
10550
|
+
cur += ch;
|
|
10551
|
+
started = true;
|
|
10894
10552
|
}
|
|
10895
|
-
if (
|
|
10896
|
-
|
|
10897
|
-
|
|
10553
|
+
if (quote) throw new Error(`\u547D\u4EE4\u91CC\u7684\u5F15\u53F7\u6CA1\u95ED\u5408\uFF1A${line}`);
|
|
10554
|
+
if (started || cur) out.push(cur);
|
|
10555
|
+
return out;
|
|
10556
|
+
}
|
|
10557
|
+
function parseJsonLoose(stdout) {
|
|
10558
|
+
const candidates = [];
|
|
10559
|
+
const oa = stdout.indexOf("{"), ob = stdout.lastIndexOf("}");
|
|
10560
|
+
const aa = stdout.indexOf("["), ab = stdout.lastIndexOf("]");
|
|
10561
|
+
if (aa >= 0 && ab > aa) candidates.push([aa, ab]);
|
|
10562
|
+
if (oa >= 0 && ob > oa) candidates.push([oa, ob]);
|
|
10563
|
+
candidates.sort((x, y) => x[0] - y[0]);
|
|
10564
|
+
for (const [a, b] of candidates) {
|
|
10565
|
+
try {
|
|
10566
|
+
return JSON.parse(stdout.slice(a, b + 1));
|
|
10567
|
+
} catch {
|
|
10568
|
+
}
|
|
10898
10569
|
}
|
|
10899
|
-
|
|
10900
|
-
|
|
10901
|
-
|
|
10902
|
-
|
|
10903
|
-
|
|
10904
|
-
|
|
10570
|
+
return void 0;
|
|
10571
|
+
}
|
|
10572
|
+
function pick(value, expr) {
|
|
10573
|
+
const tokens = [...expr.replace(/^\$/, "").matchAll(/\[(\d+)\]|([^.[\]]+)/g)];
|
|
10574
|
+
let cur = value;
|
|
10575
|
+
for (const t of tokens) {
|
|
10576
|
+
if (cur === null || cur === void 0) return void 0;
|
|
10577
|
+
if (t[1] !== void 0) {
|
|
10578
|
+
if (!Array.isArray(cur)) return void 0;
|
|
10579
|
+
cur = cur[Number(t[1])];
|
|
10580
|
+
} else {
|
|
10581
|
+
if (typeof cur !== "object") return void 0;
|
|
10582
|
+
cur = cur[t[2]];
|
|
10583
|
+
}
|
|
10905
10584
|
}
|
|
10906
|
-
return
|
|
10585
|
+
return cur;
|
|
10907
10586
|
}
|
|
10908
|
-
|
|
10909
|
-
const
|
|
10910
|
-
|
|
10911
|
-
const
|
|
10912
|
-
|
|
10913
|
-
|
|
10914
|
-
|
|
10915
|
-
|
|
10916
|
-
|
|
10917
|
-
|
|
10918
|
-
|
|
10919
|
-
|
|
10920
|
-
|
|
10921
|
-
|
|
10922
|
-
|
|
10923
|
-
|
|
10924
|
-
|
|
10925
|
-
|
|
10926
|
-
|
|
10587
|
+
function matches(actual, rule) {
|
|
10588
|
+
const r = rule.trim();
|
|
10589
|
+
if (r === "\u975E\u7A7A" || r === "nonempty") return actual !== void 0 && actual !== null && String(actual) !== "" && !(Array.isArray(actual) && actual.length === 0);
|
|
10590
|
+
const m = /^(>=|<=|>|<|!=|=)\s*(.*)$/.exec(r);
|
|
10591
|
+
if (!m) return String(actual) === r;
|
|
10592
|
+
const [, op, want] = m;
|
|
10593
|
+
const n = Number(want), a = Array.isArray(actual) ? actual.length : Number(actual);
|
|
10594
|
+
switch (op) {
|
|
10595
|
+
case ">":
|
|
10596
|
+
return Number.isFinite(a) && a > n;
|
|
10597
|
+
case "<":
|
|
10598
|
+
return Number.isFinite(a) && a < n;
|
|
10599
|
+
case ">=":
|
|
10600
|
+
return Number.isFinite(a) && a >= n;
|
|
10601
|
+
case "<=":
|
|
10602
|
+
return Number.isFinite(a) && a <= n;
|
|
10603
|
+
case "!=":
|
|
10604
|
+
return String(actual) !== want;
|
|
10605
|
+
default:
|
|
10606
|
+
return String(actual) === want;
|
|
10927
10607
|
}
|
|
10928
|
-
const [types, me, project] = await Promise.all([client3.createMeta(), client3.myself(), client3.projectInfo()]);
|
|
10929
|
-
const built = buildGapFields(g, {
|
|
10930
|
-
types,
|
|
10931
|
-
me: me.name ?? me.key ?? "",
|
|
10932
|
-
assignee: assigneeOverride || project.lead?.name || project.lead?.key,
|
|
10933
|
-
project: client3.project,
|
|
10934
|
-
fingerprintText: fingerprintText2,
|
|
10935
|
-
issuetypeOverride
|
|
10936
|
-
});
|
|
10937
|
-
const created = await client3.createIssue(built.fields);
|
|
10938
|
-
return { outcome: "created", key: created.key, url: client3.browseUrl(created.key), summary: built.summary, type: built.type.name, module: built.module, alternative: g.alternative };
|
|
10939
10608
|
}
|
|
10940
|
-
|
|
10941
|
-
|
|
10942
|
-
|
|
10943
|
-
|
|
10944
|
-
|
|
10945
|
-
|
|
10946
|
-
|
|
10947
|
-
|
|
10948
|
-
|
|
10949
|
-
|
|
10950
|
-
|
|
10951
|
-
|
|
10952
|
-
|
|
10953
|
-
|
|
10954
|
-
|
|
10955
|
-
|
|
10609
|
+
var defaultDeps3 = {
|
|
10610
|
+
assess: (argv) => assessEffectiveDeliveryCommand(argv),
|
|
10611
|
+
hcm: (argv, cwd) => {
|
|
10612
|
+
const r = spawnSync2("hcm", argv, { cwd, encoding: "utf8", maxBuffer: 1 << 26, timeout: 6e5 });
|
|
10613
|
+
return { status: r.status, stdout: r.stdout ?? "", stderr: r.stderr ?? "" };
|
|
10614
|
+
},
|
|
10615
|
+
pageAcceptance: (root, argv) => {
|
|
10616
|
+
const r = spawnSync2("./page-acceptance.sh", argv, { cwd: root, encoding: "utf8", maxBuffer: 1 << 24, timeout: 3e5 });
|
|
10617
|
+
return { status: r.status, stdout: r.stdout ?? "", stderr: r.stderr ?? "" };
|
|
10618
|
+
},
|
|
10619
|
+
readXlsx: (file) => xlsxRows(file),
|
|
10620
|
+
readText: (file) => fs11.readFile(file, "utf8")
|
|
10621
|
+
};
|
|
10622
|
+
async function runCase(spec, root, opts = {}, deps = defaultDeps3) {
|
|
10623
|
+
const results = [];
|
|
10624
|
+
const vars = {};
|
|
10625
|
+
const fill = (text) => text.replace(/\$\{(\w+)\}/g, (_, k) => {
|
|
10626
|
+
if (vars[k] === void 0) throw new Error(`\u7528\u5230\u4E86 ${"$"}{${k}} \u4F46\u524D\u9762\u6CA1\u6709\u54EA\u4E00\u6B65\u6355\u83B7\u5B83`);
|
|
10627
|
+
return vars[k];
|
|
10628
|
+
});
|
|
10629
|
+
for (const c of spec.checks) {
|
|
10630
|
+
try {
|
|
10631
|
+
if (c.run) {
|
|
10632
|
+
const argv2 = tokenize(fill(c.run)).slice(1);
|
|
10633
|
+
const verdict = await deps.assess(argv2);
|
|
10634
|
+
if (verdict.execution !== "direct") {
|
|
10635
|
+
results.push({
|
|
10636
|
+
name: c.name,
|
|
10637
|
+
verdict: "fail",
|
|
10638
|
+
// 🔴 `verdict.reason` 里已经带着分档理由与 `next_step=`(见 delivery.ts 的
|
|
10639
|
+
// action-effect-undetermined / action-effect-unrecognized 两支)。此前这里
|
|
10640
|
+
// 把它整个丢掉、自己编了一句「走 delivery assess → prepare → execute」,
|
|
10641
|
+
// 而那三条命令已于 0.7.0 删除 —— 顾问撞到写命令,拿到的是一条不存在的路。
|
|
10642
|
+
// 手上有的就要打出来,不要自己编第二句。
|
|
10643
|
+
detail: `\u8FD9\u6761\u547D\u4EE4\u6309\u4EA4\u4ED8\u98CE\u63A7\u662F ${verdict.risk} / ${verdict.execution}\uFF08${verdict.reasonCode}\uFF09\uFF0C\u6CA1\u6709\u8DD1\u3002${verdict.reason} \u7528\u4F8B\u53EA\u8DD1\u53EA\u8BFB\uFF1A\u8981\u65AD\u8A00\u5199\u64CD\u4F5C\u7684\u7ED3\u679C\uFF0C\u5148\u5728\u73AF\u5883\u91CC\u628A\u5B83\u505A\u6389\uFF0C\u518D\u7528\u53EA\u8BFB\u547D\u4EE4\u65AD\u8A00\u843D\u5E93\u7684\u6837\u5B50\u3002`
|
|
10644
|
+
});
|
|
10645
|
+
continue;
|
|
10956
10646
|
}
|
|
10647
|
+
if (opts.env && !argv2.includes("--env")) argv2.push("--env", opts.env);
|
|
10648
|
+
const as2 = c.as ?? opts.as;
|
|
10649
|
+
if (as2 && !argv2.includes("--as")) argv2.push("--as", as2);
|
|
10650
|
+
const r2 = deps.hcm(argv2, root);
|
|
10651
|
+
const want = c.expect ?? {};
|
|
10652
|
+
const bad = [];
|
|
10653
|
+
if (want.exit !== void 0 && r2.status !== want.exit) bad.push(`\u9000\u51FA\u7801 ${r2.status} \u2260 ${want.exit}`);
|
|
10654
|
+
for (const t of want.stdout_contains ?? []) if (!r2.stdout.includes(t)) bad.push(`\u8F93\u51FA\u91CC\u6CA1\u6709\u300C${t}\u300D`);
|
|
10655
|
+
for (const t of want.stdout_not_contains ?? []) if (r2.stdout.includes(t)) bad.push(`\u8F93\u51FA\u91CC\u51FA\u73B0\u4E86\u4E0D\u8BE5\u6709\u7684\u300C${t}\u300D`);
|
|
10656
|
+
if (want.json) {
|
|
10657
|
+
const parsed = parseJsonLoose(r2.stdout);
|
|
10658
|
+
if (parsed === void 0) bad.push("\u8F93\u51FA\u4E0D\u662F JSON\uFF0C\u65E0\u6CD5\u6309 json \u5224\u636E\u6BD4\u5BF9");
|
|
10659
|
+
if (parsed !== void 0) {
|
|
10660
|
+
for (const [expr, rule] of Object.entries(want.json)) {
|
|
10661
|
+
const actual = pick(parsed, expr);
|
|
10662
|
+
if (!matches(actual, rule)) bad.push(`${expr} \u5B9E\u9645 ${JSON.stringify(actual)}\uFF0C\u671F\u671B ${rule}`);
|
|
10663
|
+
}
|
|
10664
|
+
}
|
|
10665
|
+
}
|
|
10666
|
+
if (c.capture && bad.length === 0) {
|
|
10667
|
+
const parsed = parseJsonLoose(r2.stdout);
|
|
10668
|
+
for (const [name, expr] of Object.entries(c.capture)) {
|
|
10669
|
+
const v = pick(parsed, expr);
|
|
10670
|
+
if (v === void 0 || v === null || String(v) === "") bad.push(`\u8981\u6355\u83B7\u7684 ${name}\uFF08${expr}\uFF09\u5728\u8F93\u51FA\u91CC\u53D6\u4E0D\u5230`);
|
|
10671
|
+
else vars[name] = String(v);
|
|
10672
|
+
}
|
|
10673
|
+
}
|
|
10674
|
+
results.push(bad.length ? { name: c.name, verdict: "fail", detail: `${bad.join("\uFF1B")}${r2.stderr.trim() ? `\uFF5Cstderr: ${r2.stderr.trim().split("\n")[0]}` : ""}` } : { name: c.name, verdict: hasContentAssertion(c) ? "pass" : "step", detail: c.capture ? `\u6355\u83B7 ${Object.keys(c.capture).join("\u3001")}` : "" });
|
|
10675
|
+
continue;
|
|
10957
10676
|
}
|
|
10958
|
-
|
|
10959
|
-
|
|
10960
|
-
|
|
10961
|
-
|
|
10962
|
-
|
|
10963
|
-
|
|
10964
|
-
|
|
10965
|
-
|
|
10966
|
-
|
|
10967
|
-
|
|
10968
|
-
|
|
10969
|
-
|
|
10970
|
-
|
|
10971
|
-
}
|
|
10972
|
-
|
|
10973
|
-
const parsed = parseRef(ref, client3.project, casesSlug);
|
|
10974
|
-
if (!parsed) throw new Error(`\u770B\u4E0D\u61C2 ${ref}\uFF1A\u7ED9 Jira \u5355\u53F7\uFF08HCMNX-12\uFF09\u3001\u4EA7\u54C1\u4ED3\u5F15\u7528\uFF08core#2198\uFF09\u6216\u5386\u53F2\u961F\u5217\u6761\u76EE\uFF08cases#26\uFF09`);
|
|
10975
|
-
if (parsed.kind === "repo") {
|
|
10976
|
-
const s = cnbIssueState(cnb, parsed.repo, parsed.number);
|
|
10977
|
-
if (s.kind !== "issue") throw new Error(`${parsed.repo}#${parsed.number} \u8BFB\u4E0D\u5230\uFF08\u7F16\u53F7\u4E0D\u5BF9\u3001\u662F PR \u53F7\uFF0C\u6216\u4F60\u6CA1\u6709\u8FD9\u4E2A\u4ED3\u7684\u6743\u9650\uFF09`);
|
|
10978
|
-
const where = parsed.repo === casesSlug ? "\u5386\u53F2\u961F\u5217" : "\u4EA7\u54C1\u4ED3";
|
|
10979
|
-
const nextStep2 = s.state === "closed" ? "\u8FD9\u6761\u5DF2\u5173\u3002\u76EE\u6807\u73AF\u5883\u90E8\u7F72\u5230\u542B\u4FEE\u590D\u7684\u7248\u672C\u540E `hcm skills update`\uFF0C\u518D\u6309\u6280\u80FD\u590D\u9A8C\u4E00\u6B21\u3002" : "\u8FD8\u5F00\u7740\u3002\u5148\u6309\u66FF\u4EE3\u6CD5\u7EE7\u7EED\u4EA4\u4ED8\uFF1B\u8981\u6392\u671F\u5C31\u5728\u90A3\u6761\u4E0B\u9762\u7559\u8A00\u3002";
|
|
10980
|
-
return { ref, lines: [`${where} ${s.repo}#${s.number} [${s.state}${s.reason ? "\xB7" + s.reason : ""}${s.priority ? " " + s.priority : ""}] ${s.title}`, ` ${s.url}`], nextStep: nextStep2, repo: s, links: [] };
|
|
10981
|
-
}
|
|
10982
|
-
const issue = await client3.issue(parsed.key);
|
|
10983
|
-
const cs = await client3.comments(parsed.key);
|
|
10984
|
-
const status = issue.fields.status?.name;
|
|
10985
|
-
const resolution = issue.fields.resolution?.name;
|
|
10986
|
-
const lines = [`Jira ${issue.key} [${status}${resolution ? "\xB7" + resolution : ""}${issue.fields.priority ? " " + issue.fields.priority.name : ""}] ${issue.fields.summary ?? ""}`, ` ${client3.browseUrl(issue.key)}`];
|
|
10987
|
-
const keyComments = cs.filter((c) => /分诊|已转|已修|合入|不做|重复|改技能|产品侧|代码库已关闭/.test(c.body ?? ""));
|
|
10988
|
-
const last = (keyComments.length ? keyComments : cs).at(-1);
|
|
10989
|
-
if (last) lines.push(` \u6700\u65B0\u5904\u7406\uFF08${String(last.created ?? "").slice(0, 10)} ${last.author?.displayName ?? "?"}\uFF09\uFF1A${(last.body ?? "").split("\n").find((l) => l.trim()) ?? ""}`.slice(0, 400));
|
|
10990
|
-
else lines.push(" \u8FD8\u6CA1\u6709\u4EBA\u5904\u7406\uFF08\u4EA7\u54C1\u4FA7\u6BCF\u5468\u6E05\u4E00\u6B21\uFF1B\u963B\u65AD\u7EA7\u8BF7\u5728\u9879\u76EE\u7FA4\u91CC\u70B9\u540D\u8D1F\u8D23\u4EBA\uFF09");
|
|
10991
|
-
const remote = (await client3.remoteLinks(parsed.key)).map((l) => l.object?.url ?? "").join("\n");
|
|
10992
|
-
const links = linkedRepoRefs(`${remote}
|
|
10993
|
-
${issue.fields.description ?? ""}
|
|
10994
|
-
${cs.map((c) => c.body ?? "").join("\n")}`).map((l) => cnbIssueState(cnb, l.repo, l.number));
|
|
10995
|
-
const issues = links.filter((l) => l.kind === "issue");
|
|
10996
|
-
for (const p of issues) lines.push(`\u4EA7\u54C1\u4ED3 ${p.repo}#${p.number} [${p.state}${p.reason ? "\xB7" + p.reason : ""}${p.priority ? " " + p.priority : ""}] ${p.title}`, ` ${p.url}`);
|
|
10997
|
-
let nextStep;
|
|
10998
|
-
if (resolution) nextStep = "Jira \u8FD9\u5355\u5DF2\u89E3\u51B3\u3002\u76EE\u6807\u73AF\u5883\u90E8\u7F72\u5230\u542B\u4FEE\u590D\u7684\u7248\u672C\u540E\uFF08`hcm version` \u7684 commit \u4F1A\u53D8\uFF09\uFF0C\u8DD1 `hcm skills update`\uFF0C\u518D\u6309\u6280\u80FD\u590D\u9A8C\u4E00\u6B21\u3002";
|
|
10999
|
-
else if (issues.length && issues.every((s) => s.state === "closed")) nextStep = "\u4EA7\u54C1\u4ED3\u90A3\u6761\u5DF2\u5173\u3001Jira \u8FD8\u6CA1\u5173\uFF0C\u591A\u534A\u5728\u7B49\u53D1\u5E03\u3002\u7EE7\u7EED\u7528\u66FF\u4EE3\u6CD5\uFF0C\u53D1\u5E03\u540E\u590D\u9A8C\u3002";
|
|
11000
|
-
else if (issues.length) nextStep = "\u4EA7\u54C1\u4ED3\u5DF2\u7ACB\u9879\u3001\u8FD8\u6CA1\u5173\u3002\u7EE7\u7EED\u7528\u66FF\u4EE3\u6CD5\uFF1B\u60F3\u8981\u6392\u671F\u5C31\u5728 Jira \u8FD9\u5355\u4E0B\u7559\u8A00\u3002";
|
|
11001
|
-
else nextStep = `\u7B49\u5206\u8BCA\u3002\u5148\u6309\u66FF\u4EE3\u6CD5\u7EE7\u7EED\u4EA4\u4ED8\uFF0C\u62A5\u544A\u5199 BLOCKED \xB7 \u5DF2\u63D0 ${issue.key}\u3002`;
|
|
11002
|
-
return { ref, lines, nextStep, jira: { key: issue.key, status, resolution, url: client3.browseUrl(issue.key) }, links };
|
|
11003
|
-
}
|
|
11004
|
-
|
|
11005
|
-
// src/jira/triage.ts
|
|
11006
|
-
var GAP_PREFIX = "\u7F3A\u53E3\uFF1A";
|
|
11007
|
-
var PENDING_STATUS = "\u65B0\u589E";
|
|
11008
|
-
var SYNC_MARKER = "\u4EE3\u7801\u5E93\u5DF2\u5173\u95ED\uFF1A";
|
|
11009
|
-
var bodyText = (issue, comments, remote = []) => [issue.fields.description ?? "", ...comments.map((c) => c.body ?? ""), ...remote.map((l) => l.object?.url ?? "")].join("\n");
|
|
11010
|
-
var remoteText = (remote) => remote.map((l) => `${l.object?.url ?? ""} ${l.object?.title ?? ""}`).join("\n");
|
|
11011
|
-
var refKeys = (text) => linkedRepoRefs(text).map((l) => `${l.repo}#${l.number}`);
|
|
11012
|
-
async function listOpen(client3, { all = false } = {}) {
|
|
11013
|
-
const every = await client3.search(`project = ${client3.project} AND resolution = Unresolved ORDER BY created DESC`, { max: 100 });
|
|
11014
|
-
const picked = all ? every : every.filter((i) => i.fields.status?.name === PENDING_STATUS);
|
|
11015
|
-
const linked = await Promise.all(picked.map((i) => client3.remoteLinks(i.key).then((r) => refKeys(remoteText(r)))));
|
|
11016
|
-
return {
|
|
11017
|
-
unresolved: every.length,
|
|
11018
|
-
rows: picked.map((i, n) => ({
|
|
11019
|
-
key: i.key,
|
|
11020
|
-
status: i.fields.status?.name ?? "?",
|
|
11021
|
-
priority: i.fields.priority?.name,
|
|
11022
|
-
summary: i.fields.summary ?? "",
|
|
11023
|
-
url: client3.browseUrl(i.key),
|
|
11024
|
-
reporter: i.fields.reporter?.displayName,
|
|
11025
|
-
assignee: i.fields.assignee?.displayName,
|
|
11026
|
-
linkedRefs: linked[n] ?? [],
|
|
11027
|
-
created: String(i.fields.created ?? "").slice(0, 10),
|
|
11028
|
-
fromAgent: (i.fields.summary ?? "").startsWith(GAP_PREFIX)
|
|
11029
|
-
}))
|
|
11030
|
-
};
|
|
11031
|
-
}
|
|
11032
|
-
async function showIssue({ client: client3, cnb }, key2) {
|
|
11033
|
-
const issue = await client3.issue(key2);
|
|
11034
|
-
const comments = await client3.comments(key2);
|
|
11035
|
-
const remoteLinks = await client3.remoteLinks(key2);
|
|
11036
|
-
const inRemote = new Set(refKeys(remoteText(remoteLinks)));
|
|
11037
|
-
const links = linkedRepoRefs(bodyText(issue, comments, remoteLinks)).map((l) => ({
|
|
11038
|
-
...cnbIssueState(cnb, l.repo, l.number),
|
|
11039
|
-
source: inRemote.has(`${l.repo}#${l.number}`) ? "remote" : "comment"
|
|
11040
|
-
}));
|
|
11041
|
-
const transitions = await client3.transitions(key2);
|
|
11042
|
-
return { issue, comments, remoteLinks, links, transitions };
|
|
11043
|
-
}
|
|
11044
|
-
async function commentIssue(client3, key2, body) {
|
|
11045
|
-
await client3.addComment(key2, body);
|
|
11046
|
-
return { key: key2, url: client3.browseUrl(key2) };
|
|
11047
|
-
}
|
|
11048
|
-
async function assignIssue(client3, key2, who) {
|
|
11049
|
-
const name = who === "me" || !who ? (await client3.myself()).name ?? "" : who;
|
|
11050
|
-
if (!name) throw new Error("\u53D6\u4E0D\u5230\u5F53\u524D\u7528\u6237\u540D\uFF0C\u65E0\u6CD5\u63A5\u624B");
|
|
11051
|
-
await client3.assign(key2, name);
|
|
11052
|
-
return { key: key2, who: name, transitions: await client3.transitions(key2) };
|
|
11053
|
-
}
|
|
11054
|
-
async function moveIssue(client3, key2, target, comment) {
|
|
11055
|
-
const transition = await client3.transition(key2, target, comment);
|
|
11056
|
-
return { key: key2, transition };
|
|
11057
|
-
}
|
|
11058
|
-
async function toIssue({ client: client3, cnb }, key2, { repo = "hcm/hcm_nx_core", force = false, priority = "P2" } = {}) {
|
|
11059
|
-
const issue = await client3.issue(key2);
|
|
11060
|
-
const comments = await client3.comments(key2);
|
|
11061
|
-
const remote = await client3.remoteLinks(key2);
|
|
11062
|
-
const existing = linkedRepoRefs(bodyText(issue, comments, remote));
|
|
11063
|
-
if (existing.length && !force) {
|
|
11064
|
-
const remoteText2 = remote.map((l) => `${l.object?.url ?? ""} ${l.object?.title ?? ""}`).join("\n");
|
|
11065
|
-
const linked = [];
|
|
11066
|
-
const alreadyLinked = [];
|
|
11067
|
-
for (const e of existing) {
|
|
11068
|
-
const ref = `${e.repo}#${e.number}`;
|
|
11069
|
-
const url2 = repoIssueUrl(e.repo, e.number);
|
|
11070
|
-
if (remoteText2.includes(url2) || remoteText2.includes(ref)) {
|
|
11071
|
-
alreadyLinked.push(ref);
|
|
10677
|
+
if (c.file) {
|
|
10678
|
+
const file = path10.resolve(root, fill(c.file));
|
|
10679
|
+
const want = c.expect ?? {};
|
|
10680
|
+
const bad = [];
|
|
10681
|
+
if (want.xlsx_header || want.xlsx_min_rows !== void 0) {
|
|
10682
|
+
const rows = deps.readXlsx(file);
|
|
10683
|
+
const header = (rows[0] ?? []).map((x) => String(x).trim());
|
|
10684
|
+
for (const h of want.xlsx_header ?? []) if (!header.includes(h)) bad.push(`\u8868\u5934\u91CC\u6CA1\u6709\u300C${h}\u300D\uFF0C\u5B9E\u9645\u662F [${header.slice(0, 8).join(", ")}]`);
|
|
10685
|
+
if (want.xlsx_min_rows !== void 0 && rows.length - 1 < want.xlsx_min_rows) bad.push(`\u6570\u636E\u884C ${Math.max(rows.length - 1, 0)} \u5C11\u4E8E ${want.xlsx_min_rows}`);
|
|
10686
|
+
}
|
|
10687
|
+
if (want.text_contains) {
|
|
10688
|
+
const text = await deps.readText(file);
|
|
10689
|
+
for (const t of want.text_contains) if (!text.includes(t)) bad.push(`\u6587\u4EF6\u91CC\u6CA1\u6709\u300C${t}\u300D`);
|
|
10690
|
+
}
|
|
10691
|
+
results.push(bad.length ? { name: c.name, verdict: "fail", detail: bad.join("\uFF1B") } : { name: c.name, verdict: "pass", detail: "" });
|
|
11072
10692
|
continue;
|
|
11073
10693
|
}
|
|
11074
|
-
|
|
11075
|
-
|
|
10694
|
+
const out = path10.join("evidence", "test", `${spec.name}-${c.name}`.replace(/[^\w一-龥-]+/g, "_") + ".png");
|
|
10695
|
+
const argv = ["--path", fill(c.page), "--out", out];
|
|
10696
|
+
if (opts.env) argv.push("--env", opts.env);
|
|
10697
|
+
const as = c.as ?? opts.as;
|
|
10698
|
+
if (as) argv.push("--as", as);
|
|
10699
|
+
for (const t of c.expect_text ?? []) argv.push("--expect-text", t);
|
|
10700
|
+
for (const t of c.reject_text ?? []) argv.push("--reject-text", t);
|
|
10701
|
+
const r = deps.pageAcceptance(root, argv);
|
|
10702
|
+
results.push(r.status === 0 ? { name: c.name, verdict: "pass", detail: out } : { name: c.name, verdict: "fail", detail: (r.stderr || r.stdout).trim().split("\n").slice(-1)[0] ?? `\u9000\u51FA\u7801 ${r.status}` });
|
|
10703
|
+
} catch (e) {
|
|
10704
|
+
results.push({ name: c.name, verdict: "fail", detail: e.message });
|
|
11076
10705
|
}
|
|
11077
|
-
return { key: key2, existing: existing.map((e) => `${e.repo}#${e.number}`), linked, alreadyLinked };
|
|
11078
|
-
}
|
|
11079
|
-
const title = `${issue.fields.summary ?? ""}\uFF08Jira ${key2}\uFF09`;
|
|
11080
|
-
const body = [
|
|
11081
|
-
`> \u6765\u81EA Jira ${key2}\uFF1A${client3.browseUrl(key2)}`,
|
|
11082
|
-
`> \u62A5\u544A\u4EBA\uFF1A${issue.fields.reporter?.displayName ?? "?"} \u4F18\u5148\u7EA7\uFF1A${issue.fields.priority?.name ?? "-"}`,
|
|
11083
|
-
"",
|
|
11084
|
-
issue.fields.description || "\uFF08Jira \u6B63\u6587\u4E3A\u7A7A\uFF09"
|
|
11085
|
-
].join("\n");
|
|
11086
|
-
const raw = cnb(["issues", "create-issue", "--repo", repo, "--title", title, "--body", body, "--priority", priority]);
|
|
11087
|
-
const number = raw.match(/number:\s*"?(\d+)/)?.[1];
|
|
11088
|
-
if (!number) throw new Error(`\u4EA7\u54C1\u4ED3 issue \u5EFA\u5931\u8D25\uFF0Ccnb \u539F\u6837\u8F93\u51FA\uFF1A
|
|
11089
|
-
${raw.slice(0, 500)}`);
|
|
11090
|
-
const url = repoIssueUrl(repo, number);
|
|
11091
|
-
await client3.addRemoteLink(key2, url, `${repo}#${number} ${issue.fields.summary ?? ""}`.slice(0, 250));
|
|
11092
|
-
await client3.addComment(key2, `\u5DF2\u5728\u4EE3\u7801\u5E93\u767B\u8BB0\uFF1A${repo}#${number}
|
|
11093
|
-
${url}
|
|
11094
|
-
\u4FEE\u590D\u5408\u5165\u540E\u56DE\u5199\u672C\u5355\u4E3A\u300C\u5DF2\u4FEE\u590D\u300D\uFF0C\u76EE\u6807\u73AF\u5883\u53D1\u5E03\u4E14\u987E\u95EE\u590D\u9A8C\u901A\u8FC7\u540E\u624D\u5173\u95ED\u3002`);
|
|
11095
|
-
const me = (await client3.myself()).name;
|
|
11096
|
-
if (me && issue.fields.assignee?.name !== me) await client3.assign(key2, me);
|
|
11097
|
-
const out = { key: key2, repo, number, url };
|
|
11098
|
-
try {
|
|
11099
|
-
const hit = await client3.transition(key2, "\u6253\u5F00\u95EE\u9898");
|
|
11100
|
-
out.moved = hit.to?.name;
|
|
11101
|
-
} catch (e) {
|
|
11102
|
-
out.moveError = e.message;
|
|
11103
10706
|
}
|
|
11104
|
-
return
|
|
10707
|
+
return results;
|
|
11105
10708
|
}
|
|
11106
|
-
async function
|
|
11107
|
-
const
|
|
11108
|
-
const
|
|
11109
|
-
const
|
|
11110
|
-
const
|
|
11111
|
-
|
|
11112
|
-
|
|
11113
|
-
|
|
11114
|
-
const allClosed = issues.every((l) => l.state === "closed");
|
|
11115
|
-
if (!allClosed) return { key: key2, outcome: "not-closed", links };
|
|
11116
|
-
const already = comments.some((c) => (c.body ?? "").includes(SYNC_MARKER) || (c.body ?? "").includes("\u4EA7\u54C1\u4FA7\u5DF2\u5173\u95ED"));
|
|
11117
|
-
if (already) return { key: key2, outcome: "already-written", links };
|
|
11118
|
-
if (dryRun) return { key: key2, outcome: "dry-run-would-write", links };
|
|
11119
|
-
const summary = issues.map(describeIssueState).join("\u3001");
|
|
11120
|
-
await client3.addComment(
|
|
11121
|
-
key2,
|
|
11122
|
-
`${SYNC_MARKER}${summary}\u3002\u4FEE\u590D\u53EA\u662F\u8FDB\u4E86 main\u2014\u2014\u76EE\u6807\u73AF\u5883\u90E8\u7F72\u5230\u542B\u4FEE\u590D\u7684\u7248\u672C\u540E\uFF0C\u7531\u987E\u95EE\u590D\u9A8C\u901A\u8FC7\u624D\u5173\u672C\u5355\uFF08verify-pass\uFF09\uFF1B\u590D\u9A8C\u4E0D\u8FC7\u8D70 verify-fail \u9000\u56DE\u3002`
|
|
11123
|
-
);
|
|
11124
|
-
const out = { key: key2, outcome: "written", links };
|
|
11125
|
-
try {
|
|
11126
|
-
const hit = await client3.transition(key2, "\u5904\u7406\u5B8C\u6210");
|
|
11127
|
-
out.moved = hit.to?.name;
|
|
11128
|
-
} catch (e) {
|
|
11129
|
-
out.moveError = e.message;
|
|
10709
|
+
async function loadCases(target) {
|
|
10710
|
+
const stat = await fs11.stat(target);
|
|
10711
|
+
const files = stat.isDirectory() ? (await fs11.readdir(target)).filter((f) => /\.ya?ml$/.test(f)).sort().map((f) => path10.join(target, f)) : [target];
|
|
10712
|
+
const out = [];
|
|
10713
|
+
for (const f of files) {
|
|
10714
|
+
const spec = yaml.load(await fs11.readFile(f, "utf8"));
|
|
10715
|
+
assertUsableSpec(spec, path10.basename(f));
|
|
10716
|
+
out.push({ file: f, spec });
|
|
11130
10717
|
}
|
|
10718
|
+
if (out.length === 0) throw new Error(`${target} \u4E0B\u6CA1\u6709\u7528\u4F8B\uFF08*.yml\uFF09`);
|
|
11131
10719
|
return out;
|
|
11132
10720
|
}
|
|
11133
|
-
async function
|
|
11134
|
-
await client3.addComment(key2, `\u987E\u95EE\u590D\u9A8C\u901A\u8FC7\uFF1A${note}`);
|
|
11135
|
-
const hit = await client3.transition(key2, "\u786E\u8BA4\u5173\u95ED");
|
|
11136
|
-
return { key: key2, to: hit.to?.name, url: client3.browseUrl(key2) };
|
|
11137
|
-
}
|
|
11138
|
-
async function verifyFail({ client: client3, cnb }, key2, note) {
|
|
11139
|
-
await client3.addComment(key2, `\u987E\u95EE\u590D\u9A8C\u672A\u901A\u8FC7\uFF0C\u9000\u56DE\uFF1A
|
|
11140
|
-
${note}`);
|
|
11141
|
-
const out = { key: key2, reopened: [], failed: [] };
|
|
10721
|
+
async function chironTestCommand(target, args, deps) {
|
|
11142
10722
|
try {
|
|
11143
|
-
|
|
11144
|
-
|
|
11145
|
-
|
|
11146
|
-
|
|
11147
|
-
|
|
11148
|
-
|
|
11149
|
-
|
|
11150
|
-
|
|
11151
|
-
|
|
11152
|
-
try {
|
|
11153
|
-
cnb(["issues", "update-issue", "--repo", l.repo, "--number", l.number, "--state", "open", "--state-reason", "reopened"]);
|
|
11154
|
-
cnb(["issues", "post-issue-comment", "--repo", l.repo, "--number", l.number, "--body", `\u987E\u95EE\u590D\u9A8C\u672A\u901A\u8FC7\uFF0C\u91CD\u5F00\uFF08Jira ${key2}\uFF09\uFF1A
|
|
11155
|
-
${note}`]);
|
|
11156
|
-
out.reopened.push(`${l.repo}#${l.number}`);
|
|
11157
|
-
} catch {
|
|
11158
|
-
out.failed.push(`${l.repo}#${l.number}`);
|
|
10723
|
+
const root = path10.resolve(args.project ?? ".");
|
|
10724
|
+
const where = path10.resolve(root, target ?? "tests");
|
|
10725
|
+
const cases = await loadCases(where);
|
|
10726
|
+
const report = [];
|
|
10727
|
+
let failed2 = 0;
|
|
10728
|
+
for (const { file, spec } of cases) {
|
|
10729
|
+
const results = await runCase(spec, root, { env: args.env, as: args.as }, deps);
|
|
10730
|
+
failed2 += results.filter((r) => r.verdict === "fail").length;
|
|
10731
|
+
report.push({ case: spec.name, file: path10.relative(root, file), results });
|
|
11159
10732
|
}
|
|
11160
|
-
|
|
11161
|
-
|
|
11162
|
-
}
|
|
11163
|
-
|
|
11164
|
-
|
|
11165
|
-
|
|
11166
|
-
|
|
11167
|
-
|
|
11168
|
-
|
|
11169
|
-
|
|
11170
|
-
|
|
11171
|
-
|
|
11172
|
-
|
|
11173
|
-
const remote = await client3.remoteLinks(i.key);
|
|
11174
|
-
if (refKeys(remoteText(remote)).length) continue;
|
|
11175
|
-
const refs = refKeys(bodyText(await client3.issue(i.key), await client3.comments(i.key), remote));
|
|
11176
|
-
bad.push({ key: i.key, status, url: client3.browseUrl(i.key), kind: refs.length ? "comment-only" : "missing", refs });
|
|
11177
|
-
}
|
|
11178
|
-
return { checked: rows.length, audited, bad };
|
|
11179
|
-
}
|
|
11180
|
-
async function probe(client3) {
|
|
11181
|
-
const [info, me, project] = await Promise.all([client3.serverInfo(), client3.myself(), client3.projectInfo()]);
|
|
11182
|
-
const types = (await client3.createMeta()).map((t) => ({
|
|
11183
|
-
id: t.id,
|
|
11184
|
-
name: t.name,
|
|
11185
|
-
required: (t.fields ?? []).filter((f) => f.required && !["project", "issuetype"].includes(f.fieldId)).map((f) => `${f.name}(${f.fieldId})${f.allowedValues ? `=[${f.allowedValues.slice(0, 8).map((v) => v.name ?? v.value).join("|")}]` : ""}`)
|
|
11186
|
-
}));
|
|
11187
|
-
const flows = (await client3.projectStatuses()).map((t) => ({ name: t.name, statuses: (t.statuses ?? []).map((s) => s.name ?? "") }));
|
|
11188
|
-
return {
|
|
11189
|
-
server: `Jira ${info.version ?? "?"} (${info.deploymentType ?? "?"}) @ ${client3.base}`,
|
|
11190
|
-
me: `${me.displayName ?? "?"} <${me.emailAddress ?? me.name ?? ""}> key=${me.key ?? me.name ?? ""}`,
|
|
11191
|
-
project: `${project.key ?? client3.project} ${project.name ?? ""} lead=${project.lead?.displayName ?? "?"}`,
|
|
11192
|
-
types,
|
|
11193
|
-
flows
|
|
11194
|
-
};
|
|
11195
|
-
}
|
|
11196
|
-
|
|
11197
|
-
// src/commands/jira.ts
|
|
11198
|
-
var defaultDeps3 = { client: () => createJiraClient(), cnb: defaultCnb };
|
|
11199
|
-
async function triageDeps(deps) {
|
|
11200
|
-
return { client: await deps.client(), cnb: deps.cnb };
|
|
11201
|
-
}
|
|
11202
|
-
function emit4(fmt, data, text) {
|
|
11203
|
-
if (fmt === "json" || fmt === "yaml") process.stdout.write(formatObject24(data, { format: fmt }) + "\n");
|
|
11204
|
-
else process.stdout.write(text() + "\n");
|
|
11205
|
-
}
|
|
11206
|
-
function readBody(opts, positional) {
|
|
11207
|
-
if (opts.file) return readFileSync6(opts.file, "utf8");
|
|
11208
|
-
if (opts.body) return opts.body;
|
|
11209
|
-
if (positional && positional.trim()) return positional;
|
|
11210
|
-
if (process.stdin.isTTY) throw new Error("\u7F3A\u6B63\u6587\uFF1A-f <\u6587\u4EF6> / --body <\u6587\u672C> / \u4F4D\u7F6E\u53C2\u6570\uFF0C\u6216\u4ECE\u6807\u51C6\u8F93\u5165\u5582");
|
|
11211
|
-
return readFileSync6(0, "utf8");
|
|
11212
|
-
}
|
|
11213
|
-
async function run(fn) {
|
|
11214
|
-
try {
|
|
11215
|
-
await fn();
|
|
11216
|
-
} catch (e) {
|
|
11217
|
-
exitWithError(e);
|
|
11218
|
-
}
|
|
11219
|
-
}
|
|
11220
|
-
async function jiraProbeCommand(args, deps = defaultDeps3) {
|
|
11221
|
-
await run(async () => {
|
|
11222
|
-
const r = await probe(await deps.client());
|
|
11223
|
-
emit4(
|
|
11224
|
-
args.output,
|
|
11225
|
-
r,
|
|
11226
|
-
() => [
|
|
11227
|
-
r.server,
|
|
11228
|
-
`\u6211\u662F\uFF1A${r.me}`,
|
|
11229
|
-
`\u9879\u76EE\uFF1A${r.project}`,
|
|
11230
|
-
...r.types.map((t) => `issuetype ${t.name}(${t.id}) \u5FC5\u586B\uFF1A${t.required.join(" \xB7 ") || "\uFF08\u65E0\uFF09"}`),
|
|
11231
|
-
...r.flows.map((f) => `\u72B6\u6001\u6D41 ${f.name}\uFF1A${f.statuses.join(" \u2192 ")}`)
|
|
11232
|
-
].join("\n")
|
|
11233
|
-
);
|
|
11234
|
-
});
|
|
11235
|
-
}
|
|
11236
|
-
async function jiraOpenCommand(args, deps = defaultDeps3) {
|
|
11237
|
-
await run(async () => {
|
|
11238
|
-
const r = await listOpen(await deps.client(), { all: !!args.all });
|
|
11239
|
-
emit4(args.output, r, () => {
|
|
11240
|
-
if (!r.rows.length) return args.all ? "\u9879\u76EE\u91CC\u6CA1\u6709\u672A\u89E3\u51B3\u7684\u5355\u3002" : `\u6CA1\u6709\u5F85\u5206\u8BCA\uFF08\u72B6\u6001\u300C\u65B0\u589E\u300D\uFF09\u7684\u5355\uFF1B\u9879\u76EE\u91CC\u672A\u89E3\u51B3\u7684\u5171 ${r.unresolved} \u6761\uFF0C\u770B\u5168\u90E8\u52A0 --all\u3002`;
|
|
11241
|
-
return r.rows.map(
|
|
11242
|
-
(i) => `${i.key} [${i.status}${i.priority ? " " + i.priority : ""}]${i.fromAgent ? "" : " \uFF08\u975E agent \u63D0\u5355\uFF09"} ${i.summary}
|
|
11243
|
-
${i.url} \u62A5\u544A\u4EBA ${i.reporter ?? "?"} \u7ECF\u529E\u4EBA ${i.assignee ?? "\u672A\u63A5\u624B"} \u6761\u76EE ${i.linkedRefs.join(" / ") || "\u94FE\u63A5\u680F\u672A\u6302"} ${i.created}`
|
|
11244
|
-
).join("\n");
|
|
11245
|
-
});
|
|
11246
|
-
});
|
|
11247
|
-
}
|
|
11248
|
-
async function jiraShowCommand(key2, args, deps = defaultDeps3) {
|
|
11249
|
-
await run(async () => {
|
|
11250
|
-
const d = await triageDeps(deps);
|
|
11251
|
-
const r = await showIssue(d, key2);
|
|
11252
|
-
const i = r.issue;
|
|
11253
|
-
emit4(args.output, r, () => {
|
|
11254
|
-
const out = [
|
|
11255
|
-
`${i.key} [${i.fields.status?.name}${i.fields.resolution ? "\xB7" + i.fields.resolution.name : ""}${i.fields.priority ? " " + i.fields.priority.name : ""}] ${i.fields.summary ?? ""}`,
|
|
11256
|
-
`${d.client.browseUrl(i.key)} \u62A5\u544A\u4EBA ${i.fields.reporter?.displayName ?? "?"} \u7ECF\u529E\u4EBA ${i.fields.assignee?.displayName ?? "-"} \u6807\u7B7E ${(i.fields.labels ?? []).join(",") || "-"}`,
|
|
11257
|
-
"",
|
|
11258
|
-
"--- \u6B63\u6587 ---",
|
|
11259
|
-
i.fields.description || "\uFF08\u7A7A\uFF09"
|
|
11260
|
-
];
|
|
11261
|
-
for (const c of r.comments) out.push("", `--- \u8BC4\u8BBA ${c.author?.displayName ?? "?"} ${String(c.created ?? "").slice(0, 10)} ---`, c.body ?? "");
|
|
11262
|
-
for (const l of r.links)
|
|
11263
|
-
out.push("", `\u5173\u8054\u4EE3\u7801\u5E93 ${describeIssueState(l)}${l.source === "comment" ? ` \uFF08\u4EC5\u89C1\u4E8E\u8BC4\u8BBA\uFF0C\u300C\u94FE\u63A5\u300D\u680F\u672A\u6302\uFF1Bhcm jira to-issue ${i.key} \u53EF\u8865\u6302\uFF09` : ""}`);
|
|
11264
|
-
out.push("", `\u53EF\u7528\u6D41\u8F6C\uFF1A${r.transitions.map((t) => `${t.name}\u2192${t.to?.name}`).join(" / ") || "\uFF08\u65E0\uFF09"}`);
|
|
11265
|
-
return out.join("\n");
|
|
11266
|
-
});
|
|
11267
|
-
});
|
|
11268
|
-
}
|
|
11269
|
-
async function jiraCommentCommand(key2, text, args, deps = defaultDeps3) {
|
|
11270
|
-
await run(async () => {
|
|
11271
|
-
const body = readBody(args, text);
|
|
11272
|
-
const r = await commentIssue(await deps.client(), key2, body);
|
|
11273
|
-
emit4(args.output, r, () => `\u5DF2\u56DE\u590D ${r.key}\uFF1A${r.url}`);
|
|
11274
|
-
});
|
|
11275
|
-
}
|
|
11276
|
-
async function jiraAssignCommand(key2, who, args, deps = defaultDeps3) {
|
|
11277
|
-
await run(async () => {
|
|
11278
|
-
const r = await assignIssue(await deps.client(), key2, who);
|
|
11279
|
-
emit4(args.output, r, () => `${r.key} \u5DF2\u6539\u6D3E\u7ED9 ${r.who}\u3002\u73B0\u5728\u53EF\u505A\u7684\u6D41\u8F6C\uFF1A${r.transitions.map((x) => `${x.name}\u2192${x.to?.name}`).join(" / ") || "\uFF08\u65E0\uFF09"}`);
|
|
11280
|
-
});
|
|
11281
|
-
}
|
|
11282
|
-
async function jiraMoveCommand(key2, target, args, deps = defaultDeps3) {
|
|
11283
|
-
await run(async () => {
|
|
11284
|
-
const comment = args.file || args.body ? readBody(args) : void 0;
|
|
11285
|
-
const r = await moveIssue(await deps.client(), key2, target, comment);
|
|
11286
|
-
emit4(args.output, r, () => `${r.key} \u5DF2\u6D41\u8F6C\uFF1A${r.transition.name} \u2192 ${r.transition.to?.name}`);
|
|
11287
|
-
});
|
|
11288
|
-
}
|
|
11289
|
-
async function jiraToIssueCommand(key2, args, deps = defaultDeps3) {
|
|
11290
|
-
await run(async () => {
|
|
11291
|
-
const r = await toIssue(await triageDeps(deps), key2, { repo: args.repo, force: !!args.force });
|
|
11292
|
-
emit4(args.output, r, () => {
|
|
11293
|
-
if ("existing" in r) {
|
|
11294
|
-
const parts = [`${r.key} \u5DF2\u5173\u8054 ${r.existing.join("\u3001")}\uFF0C\u4E0D\u91CD\u590D\u5EFA\u3002\u8981\u518D\u5EFA\u52A0 --force`];
|
|
11295
|
-
if (r.linked.length) parts.push(`\u5DF2\u8865\u6302\u8FDC\u7A0B\u94FE\u63A5\uFF1A${r.linked.join("\u3001")}\uFF08\u539F\u5148\u53EA\u5199\u5728\u6B63\u6587/\u8BC4\u8BBA\u91CC\uFF0CJira\u300C\u94FE\u63A5\u300D\u680F\u770B\u4E0D\u5230\uFF09`);
|
|
11296
|
-
else if (r.alreadyLinked.length) parts.push("\u8FDC\u7A0B\u94FE\u63A5\u5DF2\u9F50\uFF0C\u65E0\u9700\u8865\u6302");
|
|
11297
|
-
return parts.join("\n");
|
|
11298
|
-
}
|
|
11299
|
-
const moved = r.moved ? `\uFF0C\u5DF2\u63A8\u8FDB\u5230 ${r.moved}` : r.moveError ? `\uFF0C\u4F46\u6CA1\u80FD\u63A8\u8FDB\u72B6\u6001\uFF1A${r.moveError}` : "";
|
|
11300
|
-
return `${r.key} \u2192 ${r.repo}#${r.number} ${r.url}${moved}`;
|
|
11301
|
-
});
|
|
11302
|
-
});
|
|
11303
|
-
}
|
|
11304
|
-
async function jiraSyncCommand(key2, args, deps = defaultDeps3) {
|
|
11305
|
-
await run(async () => {
|
|
11306
|
-
const r = await syncIssue(await triageDeps(deps), key2, { dryRun: !!args.dryRun });
|
|
11307
|
-
emit4(args.output, r, () => {
|
|
11308
|
-
const links = r.links.map(describeIssueState).join("\u3001") || "\uFF08\u65E0\uFF09";
|
|
11309
|
-
switch (r.outcome) {
|
|
11310
|
-
case "written":
|
|
11311
|
-
return `${r.key} \u5DF2\u56DE\u5199\uFF1A${links}${r.moved ? ` \u5E76\u63A8\u8FDB\u5230 ${r.moved}` : r.moveError ? `\uFF08\u72B6\u6001\u6CA1\u63A8\u52A8\uFF1A${r.moveError}\uFF09` : ""}`;
|
|
11312
|
-
case "dry-run-would-write":
|
|
11313
|
-
return `${r.key} \u4EE3\u7801\u5E93\u6761\u76EE\u5DF2\u5168\u5173\uFF0C\u5B9E\u8DD1\u4F1A\u56DE\u5199\u5E76\u63A8\u300C\u5904\u7406\u5B8C\u6210\u300D\uFF1A${links}`;
|
|
11314
|
-
case "already-written":
|
|
11315
|
-
return `${r.key} \u5DF2\u56DE\u5199\u8FC7\uFF0C\u8DF3\u8FC7\uFF1A${links}`;
|
|
11316
|
-
case "not-closed":
|
|
11317
|
-
return `${r.key} \u4EA7\u54C1\u4ED3\u8FD8\u6CA1\u5173\uFF1A${links}`;
|
|
11318
|
-
case "blocked-unreadable":
|
|
11319
|
-
return `${r.key} \u6709\u8BFB\u4E0D\u5230\u7684\u4EE3\u7801\u5E93\u6761\u76EE\uFF0C\u4E0D\u6562\u5224\u5DF2\u5173\uFF08fail-closed\uFF09\uFF1A${links}`;
|
|
11320
|
-
default:
|
|
11321
|
-
return `${r.key} \u6CA1\u6709\u5173\u8054\u7684\u4EA7\u54C1\u4ED3 issue\uFF08PR \u53F7\u4E0D\u7B97\uFF09\uFF0C\u5148 to-issue\uFF1A${links}`;
|
|
11322
|
-
}
|
|
11323
|
-
});
|
|
11324
|
-
if (r.outcome === "blocked-unreadable") process.exitCode = 1;
|
|
11325
|
-
});
|
|
11326
|
-
}
|
|
11327
|
-
async function jiraVerifyPassCommand(key2, note, args, deps = defaultDeps3) {
|
|
11328
|
-
await run(async () => {
|
|
11329
|
-
const text = args.file || args.body || note && note.trim() ? readBody(args, note) : "\u987E\u95EE\u5728\u76EE\u6807\u73AF\u5883\u590D\u9A8C\u901A\u8FC7\u3002";
|
|
11330
|
-
const r = await verifyPass(await deps.client(), key2, text);
|
|
11331
|
-
emit4(args.output, r, () => `${r.key} \u5DF2\u5173\u95ED\uFF08${r.to ?? "?"}\uFF09\uFF1A${r.url}`);
|
|
11332
|
-
});
|
|
11333
|
-
}
|
|
11334
|
-
async function jiraVerifyFailCommand(key2, note, args, deps = defaultDeps3) {
|
|
11335
|
-
await run(async () => {
|
|
11336
|
-
const r = await verifyFail(await triageDeps(deps), key2, readBody(args, note));
|
|
11337
|
-
emit4(args.output, r, () => {
|
|
11338
|
-
const moved = r.moved ? `\u5DF2\u9000\u56DE\u5230 ${r.moved}` : `\u72B6\u6001\u6CA1\u9000\u56DE\uFF08${r.moveError ?? "?"}\uFF09`;
|
|
11339
|
-
const failed2 = r.failed.length ? `\uFF1B\u91CD\u5F00\u5931\u8D25\uFF1A${r.failed.join("\u3001")}` : "";
|
|
11340
|
-
return `${r.key} ${moved}\uFF1B\u5DF2\u91CD\u5F00 ${r.reopened.join("\u3001") || "\uFF08\u6CA1\u6709\u53EF\u91CD\u5F00\u7684\u4EE3\u7801\u5E93\u6761\u76EE\uFF09"}${failed2}`;
|
|
11341
|
-
});
|
|
11342
|
-
});
|
|
11343
|
-
}
|
|
11344
|
-
async function jiraAuditCommand(args, deps = defaultDeps3) {
|
|
11345
|
-
await run(async () => {
|
|
11346
|
-
const r = await auditIssues(await deps.client());
|
|
11347
|
-
emit4(args.output, r, () => {
|
|
11348
|
-
if (!r.checked) return "\u9879\u76EE\u91CC\u6CA1\u6709\u672A\u89E3\u51B3\u7684\u7F3A\u53E3\u5355\u3002";
|
|
11349
|
-
const lines = [`\u672C\u8F6E\u6838\u8FC7 ${r.audited.length} \u6761\u5DF2\u53D7\u7406\u7684\u5355\uFF08\u672A\u89E3\u51B3\u5171 ${r.checked} \u6761\uFF0C\u300C\u65B0\u589E\u300D\u7684\u4E0D\u7B97\uFF09\u3002`];
|
|
11350
|
-
for (const b of r.bad) {
|
|
11351
|
-
lines.push(
|
|
11352
|
-
b.kind === "comment-only" ? `\u26A0\uFE0F ${b.key} [${b.status}] \u6761\u76EE\u53EA\u5199\u5728\u8BC4\u8BBA\u91CC\u3001\u300C\u94FE\u63A5\u300D\u680F\u662F\u7A7A\u7684\uFF1A${b.refs.join(" / ")}
|
|
11353
|
-
${b.url}
|
|
11354
|
-
\u8865\u6302\uFF1Ahcm jira to-issue ${b.key}` : `\u26A0\uFE0F ${b.key} [${b.status}] \u6CA1\u6709\u4EFB\u4F55\u4EE3\u7801\u5E93\u6761\u76EE\uFF1A${b.url}
|
|
11355
|
-
\u5148\u5206\u8BCA\uFF1Ahcm jira to-issue ${b.key} --repo hcm/hcm_nx_core`
|
|
11356
|
-
);
|
|
10733
|
+
const fmt = args.output ?? "table";
|
|
10734
|
+
if (fmt === "json" || fmt === "yaml") {
|
|
10735
|
+
process.stdout.write(formatObject24({ ok: failed2 === 0, failed: failed2, cases: report }, { format: fmt }) + "\n");
|
|
10736
|
+
} else {
|
|
10737
|
+
for (const c of report) {
|
|
10738
|
+
process.stdout.write(`
|
|
10739
|
+
${c.case}\uFF08${c.file}\uFF09
|
|
10740
|
+
`);
|
|
10741
|
+
for (const r of c.results) {
|
|
10742
|
+
const mark = r.verdict === "pass" ? "\u2705" : r.verdict === "step" ? "\xB7" : r.verdict === "warn" ? "\u26A0\uFE0F" : "\u274C";
|
|
10743
|
+
process.stdout.write(` ${mark} ${r.name}${r.detail ? ` ${r.detail}` : ""}
|
|
10744
|
+
`);
|
|
10745
|
+
}
|
|
11357
10746
|
}
|
|
11358
|
-
|
|
11359
|
-
|
|
11360
|
-
|
|
11361
|
-
|
|
11362
|
-
|
|
11363
|
-
|
|
11364
|
-
}
|
|
11365
|
-
|
|
11366
|
-
await run(async () => {
|
|
11367
|
-
if (!keywords.length) throw new Error("\u7ED9\u81F3\u5C11\u4E00\u4E2A\u5173\u952E\u8BCD\uFF1A\u9519\u8BEF\u7801 / Model / Action / \u4E00\u53E5\u73B0\u8C61");
|
|
11368
|
-
const r = await gapSearch(await triageDeps(deps), keywords, { includeClosed: args.includeClosed !== false });
|
|
11369
|
-
emit4(args.output, r, () => {
|
|
11370
|
-
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
|
|
11371
|
-
` : "";
|
|
11372
|
-
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`;
|
|
11373
|
-
return `${head}\u547D\u4E2D ${r.rows.length} \u6761\uFF08\u540C\u4E00\u7F3A\u53E3\u5DF2\u6709\u7F16\u53F7\u5C31\u5728\u90A3\u6761\u4E0B\u8FFD\u52A0\u73B0\u573A\uFF0C\u4E0D\u65B0\u5F00\uFF09\uFF1A
|
|
11374
|
-
${r.rows.map((i) => `${i.where} ${i.id} [${i.state}${i.resolution ? "\xB7" + i.resolution : ""}] ${i.title}
|
|
11375
|
-
${i.url}`).join("\n")}`;
|
|
11376
|
-
});
|
|
11377
|
-
});
|
|
11378
|
-
}
|
|
11379
|
-
async function jiraStatusCommand(ref, args, deps = defaultDeps3) {
|
|
11380
|
-
await run(async () => {
|
|
11381
|
-
const r = await gapStatus(await triageDeps(deps), ref);
|
|
11382
|
-
emit4(args.output, r, () => [...r.lines, `\u4E0B\u4E00\u6B65\uFF1A${r.nextStep}`].join("\n"));
|
|
11383
|
-
});
|
|
11384
|
-
}
|
|
11385
|
-
async function fingerprintText(env3) {
|
|
11386
|
-
try {
|
|
11387
|
-
const g = await loadGlobalConfig11();
|
|
11388
|
-
const name = resolveActiveEnv5({ envFlag: env3 }, process.env, g);
|
|
11389
|
-
const cfg = await loadEnv11(name);
|
|
11390
|
-
if (!cfg?.endpoint) return `\u672A\u53D6\u5230\u6307\u7EB9\uFF08env=${name}\uFF1A\u6CA1\u6709 endpoint\uFF09`;
|
|
11391
|
-
const http = createHttpClient4({ endpoint: cfg.endpoint.replace(/\/+$/, ""), getAccessToken: async () => null, onRefresh: async () => {
|
|
11392
|
-
} });
|
|
11393
|
-
const resp = await http.get("/api/version/backend");
|
|
11394
|
-
const info = resp.data?.data ?? resp.data ?? {};
|
|
11395
|
-
const commit = info.commit ?? info.gitCommit ?? info.version ?? "?";
|
|
11396
|
-
return `backend ${String(commit).slice(0, 12)} \xB7 CLI ${CLI_VERSION} \xB7 env ${name}`;
|
|
10747
|
+
const verified = report.reduce((n, c) => n + c.results.filter((r) => r.verdict === "pass").length, 0);
|
|
10748
|
+
process.stdout.write(failed2 === 0 ? `
|
|
10749
|
+
\u5168\u90E8\u901A\u8FC7\uFF08\u771F\u5224\u8FC7\u5185\u5BB9\u7684 ${verified} \u6761\uFF1B\u5E26 \xB7 \u7684\u662F\u6B65\u9AA4\uFF0C\u4E0D\u7B97\u9A8C\u8BC1\uFF09\u3002
|
|
10750
|
+
` : `
|
|
10751
|
+
${failed2} \u6761\u6CA1\u8FC7\u2014\u2014\u4E0A\u9762\u6BCF\u6761\u90FD\u5199\u4E86\u5B9E\u9645\u503C\u4E0E\u671F\u671B\uFF0C\u7167\u7740\u67E5\u3002
|
|
10752
|
+
`);
|
|
10753
|
+
}
|
|
10754
|
+
process.exitCode = failed2 === 0 ? 0 : 1;
|
|
11397
10755
|
} catch (e) {
|
|
11398
|
-
|
|
10756
|
+
exitWithError(e);
|
|
11399
10757
|
}
|
|
11400
10758
|
}
|
|
11401
|
-
async function jiraSubmitCommand(args, deps = defaultDeps3) {
|
|
11402
|
-
await run(async () => {
|
|
11403
|
-
const raw = args.file ? readFileSync6(args.file, "utf8") : process.stdin.isTTY ? "" : readFileSync6(0, "utf8");
|
|
11404
|
-
if (!raw.trim()) throw new Error("\u7F3A\u53E3\u8F7D\u8377\uFF1A--file <gap.json> \u6216\u4ECE\u6807\u51C6\u8F93\u5165\u5582 JSON");
|
|
11405
|
-
const gap = validateGapInput(JSON.parse(raw));
|
|
11406
|
-
const fp = args.fingerprint ?? await fingerprintText(args.env);
|
|
11407
|
-
const r = await gapSubmit(await triageDeps(deps), gap, { fingerprintText: fp, issuetypeOverride: args.issuetype, assigneeOverride: args.assignee });
|
|
11408
|
-
emit4(
|
|
11409
|
-
args.output,
|
|
11410
|
-
r,
|
|
11411
|
-
() => 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
|
|
11412
|
-
${r.url}
|
|
11413
|
-
\u7ED9\u987E\u95EE\u7684\u8BDD\uFF1A\u8FD9\u4E2A\u95EE\u9898\u5DF2\u7ECF\u5728\u4EA7\u54C1\u90A3\u8FB9\u6392\u7740\uFF0C\u7F16\u53F7 ${r.key}\uFF1B\u5148\u7528\u66FF\u4EE3\u6CD5\u300C${r.alternative}\u300D\u7EE7\u7EED\uFF0C\u5206\u8BCA\u7ED3\u8BBA\u4F1A\u56DE\u5230\u90A3\u5355\u91CC\u3002` : `\u5DF2\u63D0 ${r.key}\uFF08${r.type} \xB7 ${r.module}\uFF09\uFF1A${r.url}
|
|
11414
|
-
\u7ED9\u987E\u95EE\u7684\u8BDD\uFF1A\u7F3A\u53E3\u5DF2\u63D0\uFF0C\u7F16\u53F7 ${r.key}\uFF1B\u5148\u7528\u66FF\u4EE3\u6CD5\u300C${r.alternative}\u300D\u7EE7\u7EED\uFF0C\u4EA7\u54C1\u5206\u8BCA\u540E\u4F1A\u5728\u90A3\u5355\u91CC\u56DE\u590D\u3002\u62A5\u544A\u91CC\u5199\u300CBLOCKED \xB7 \u5DF2\u63D0 ${r.key} \xB7 \u66FF\u4EE3\u6CD5\uFF1A${r.alternative}\u300D\u3002`
|
|
11415
|
-
);
|
|
11416
|
-
});
|
|
11417
|
-
}
|
|
11418
10759
|
|
|
11419
10760
|
// src/commands/delivery-recon.ts
|
|
11420
10761
|
init_auth_guard();
|
|
@@ -11436,10 +10777,10 @@ async function deliveryReconCommand(args) {
|
|
|
11436
10777
|
try {
|
|
11437
10778
|
const ctx = await getActiveAuthContextFromCli(args);
|
|
11438
10779
|
const client3 = HcmClient23.fromAuthContext(ctx);
|
|
11439
|
-
const
|
|
11440
|
-
const sourceKey = await computeReconSourceKey(
|
|
10780
|
+
const probe = httpProbe3(client3.raw(), args.capabilities ?? DEFAULT_CAPABILITIES);
|
|
10781
|
+
const sourceKey = await computeReconSourceKey(probe);
|
|
11441
10782
|
const layout = new ReconLayout(args.out ?? ".", ctx.tenantId, sourceKey);
|
|
11442
|
-
const summary = await runRecon(
|
|
10783
|
+
const summary = await runRecon(probe, layout, {
|
|
11443
10784
|
state: args.state ?? "",
|
|
11444
10785
|
onlyModel: args.model ?? null,
|
|
11445
10786
|
identity: ctx.tenantId ? { requestedTenantId: ctx.tenantId } : null
|
|
@@ -11528,7 +10869,7 @@ import {
|
|
|
11528
10869
|
writeRisk
|
|
11529
10870
|
} from "@hcmai/sdk";
|
|
11530
10871
|
import { existsSync as existsSync2 } from "fs";
|
|
11531
|
-
import * as
|
|
10872
|
+
import * as path11 from "path";
|
|
11532
10873
|
function premise(message, hint = "") {
|
|
11533
10874
|
process.stderr.write(message + (hint ? `
|
|
11534
10875
|
\u2192 ${hint}` : "") + "\n");
|
|
@@ -11555,13 +10896,13 @@ async function runSeedPlan(args, client3) {
|
|
|
11555
10896
|
const reconDir = candidates[0].reconDir;
|
|
11556
10897
|
if (candidates.length > 1) {
|
|
11557
10898
|
process.stderr.write(
|
|
11558
|
-
`\u26A0\uFE0F \u540C\u79DF\u6237\u4E0B\u6709 ${candidates.length} \u4EFD\u57FA\u7EBF\uFF0C\u672C\u8F6E\u8BFB\u7684\u662F \`${
|
|
10899
|
+
`\u26A0\uFE0F \u540C\u79DF\u6237\u4E0B\u6709 ${candidates.length} \u4EFD\u57FA\u7EBF\uFF0C\u672C\u8F6E\u8BFB\u7684\u662F \`${path11.basename(reconDir)}\`\uFF1A` + candidates.slice(1).map((c) => `\`${path11.basename(c.reconDir)}\``).join("\u3001") + " \u672A\u88AB\u8BFB\u53D6 \u2014\u2014 \u4E0D\u540C sourceKey \u7684\u4EA7\u7269**\u4E0D\u53EF\u4E92\u6362**\u3002\n"
|
|
11559
10900
|
);
|
|
11560
10901
|
}
|
|
11561
10902
|
const round = inspectRound2(reconDir);
|
|
11562
10903
|
process.stderr.write(roundWarning(round));
|
|
11563
10904
|
const baseline = {
|
|
11564
|
-
path: `${
|
|
10905
|
+
path: `${path11.basename(path11.dirname(reconDir))}/${path11.basename(reconDir)}`,
|
|
11565
10906
|
roundId: round.roundId ?? null
|
|
11566
10907
|
};
|
|
11567
10908
|
let exemptions = null;
|
|
@@ -11823,7 +11164,7 @@ async function deliverySeedVerifyCommand(args) {
|
|
|
11823
11164
|
// src/commands/delivery-seed-find.ts
|
|
11824
11165
|
import { existsSync as existsSync3 } from "fs";
|
|
11825
11166
|
import { readFileSync as readFileSync7 } from "fs";
|
|
11826
|
-
import * as
|
|
11167
|
+
import * as path12 from "path";
|
|
11827
11168
|
import {
|
|
11828
11169
|
INIT_EXIT_CODES as INIT_EXIT_CODES2,
|
|
11829
11170
|
ValueHints,
|
|
@@ -11837,10 +11178,10 @@ import {
|
|
|
11837
11178
|
valuesRoundCaveat
|
|
11838
11179
|
} from "@hcmai/sdk";
|
|
11839
11180
|
function provenance(chosenReconDir, others) {
|
|
11840
|
-
let line = `> \u57FA\u7EBF\uFF1A\`${
|
|
11181
|
+
let line = `> \u57FA\u7EBF\uFF1A\`${path12.basename(chosenReconDir)}\`
|
|
11841
11182
|
`;
|
|
11842
11183
|
if (others.length > 0) {
|
|
11843
|
-
line += `> \u26A0\uFE0F \u540C\u79DF\u6237\u4E0B\u53E6\u6709 ${others.length} \u4EFD\u57FA\u7EBF\u672A\u88AB\u8BFB\u53D6\uFF1A` + others.map((o) => `\`${
|
|
11184
|
+
line += `> \u26A0\uFE0F \u540C\u79DF\u6237\u4E0B\u53E6\u6709 ${others.length} \u4EFD\u57FA\u7EBF\u672A\u88AB\u8BFB\u53D6\uFF1A` + others.map((o) => `\`${path12.basename(o)}\``).join("\u3001") + " \u2014\u2014 \u4E0D\u540C sourceKey \u7684\u4EA7\u7269**\u4E0D\u53EF\u4E92\u6362**\u3002\n";
|
|
11844
11185
|
}
|
|
11845
11186
|
return `${line}
|
|
11846
11187
|
`;
|
|
@@ -12177,7 +11518,7 @@ import {
|
|
|
12177
11518
|
runTriageRound
|
|
12178
11519
|
} from "@hcmai/sdk";
|
|
12179
11520
|
import { mkdirSync, readFileSync as readFileSync9, writeFileSync as writeFileSync2 } from "fs";
|
|
12180
|
-
import * as
|
|
11521
|
+
import * as path13 from "path";
|
|
12181
11522
|
var DEFAULT_CAPABILITIES3 = "default";
|
|
12182
11523
|
function premise4(message, hint) {
|
|
12183
11524
|
process.stderr.write(`\u{1F534} \u524D\u63D0\u4E0D\u6210\u7ACB\uFF1A${message}
|
|
@@ -12213,8 +11554,8 @@ function renderProblems(rows) {
|
|
|
12213
11554
|
`;
|
|
12214
11555
|
}
|
|
12215
11556
|
function writeTriageArtifact(outDir, body) {
|
|
12216
|
-
const out =
|
|
12217
|
-
mkdirSync(
|
|
11557
|
+
const out = path13.join(outDir, "work", "triage.md");
|
|
11558
|
+
mkdirSync(path13.dirname(out), { recursive: true });
|
|
12218
11559
|
writeFileSync2(out, body, "utf8");
|
|
12219
11560
|
return out;
|
|
12220
11561
|
}
|
|
@@ -12228,9 +11569,9 @@ async function runTriage(args) {
|
|
|
12228
11569
|
}
|
|
12229
11570
|
const ctx = await getActiveAuthContextFromCli(args);
|
|
12230
11571
|
const client3 = HcmClient26.fromAuthContext(ctx);
|
|
12231
|
-
const
|
|
12232
|
-
const artifactsDir = args.recon ?? new ReconLayout2(args.out ?? ".", ctx.tenantId, await computeReconSourceKey2(
|
|
12233
|
-
const result = await runTriageRound(
|
|
11572
|
+
const probe = httpProbe4(client3.raw(), args.capabilities ?? DEFAULT_CAPABILITIES3);
|
|
11573
|
+
const artifactsDir = args.recon ?? new ReconLayout2(args.out ?? ".", ctx.tenantId, await computeReconSourceKey2(probe)).dir;
|
|
11574
|
+
const result = await runTriageRound(probe, artifactsDir, entriesIn);
|
|
12234
11575
|
if (result.body === null) {
|
|
12235
11576
|
process.stdout.write(renderProblems(result.problems));
|
|
12236
11577
|
return 1;
|
|
@@ -12396,15 +11737,15 @@ config.command("set-profile <name>").description("[deprecated] \u7528 `hcm env u
|
|
|
12396
11737
|
config.command("delete <name>").description("[deprecated] \u7528 `hcm env remove --force`").action((n) => configDeleteDeprecated(n));
|
|
12397
11738
|
config.command("set <key> <value>").description("\u8BBE\u7F6E\u5168\u5C40 defaults\uFF0C\u4F8B\u5982 `defaults.output json`").action((k, v) => configSet(k, v));
|
|
12398
11739
|
config.command("get <key>").description("\u8BFB\u53D6\u5168\u5C40 defaults").action((k) => configGet(k));
|
|
12399
|
-
var
|
|
12400
|
-
|
|
12401
|
-
|
|
12402
|
-
|
|
12403
|
-
|
|
12404
|
-
|
|
12405
|
-
|
|
12406
|
-
|
|
12407
|
-
|
|
11740
|
+
var env = program.command("env").description("\u7BA1\u7406 HCM \u73AF\u5883\uFF08\u591A\u540E\u7AEF\u8FDE\u63A5\u914D\u7F6E\uFF09");
|
|
11741
|
+
env.command("list").description("\u5217\u51FA\u5168\u90E8 env").action(() => envList());
|
|
11742
|
+
env.command("current").description("\u663E\u793A\u5F53\u524D\u6FC0\u6D3B\u7684 env").action(() => envCurrent());
|
|
11743
|
+
env.command("add <name>").description("\u65B0\u589E env").option("--endpoint <url>", "HCM \u540E\u7AEF URL\uFF08\u5FC5\u586B\uFF09").option("--tenant <id>", "\u9ED8\u8BA4 tenant id", "1").option("--frontend <url>", "\u5BF9\u5E94\u524D\u7AEF URL\uFF0C\u4F8B\u5982 http://127.0.0.1:5176").option("--force", "\u8986\u76D6\u5DF2\u5B58\u5728\u7684\u540C\u540D env").action((name, opts) => envAdd(name, opts));
|
|
11744
|
+
env.command("use <name>").description("\u5207\u5230\u6307\u5B9A env").option("--no-ping", "\u8DF3\u8FC7 endpoint \u5065\u5EB7\u68C0\u67E5").action((name, opts) => envUse(name, opts));
|
|
11745
|
+
env.command("save <name>").description("\u628A\u5F53\u524D\u4E34\u65F6\u73AF\u5883\uFF08login --code \u4EA7\u751F\u7684\uFF09\u5B58\u6210\u5177\u540D env").option("--force", "\u76EE\u6807 env \u5DF2\u5B58\u5728\u65F6\u8986\u76D6\u5B83\u7684\u914D\u7F6E").action((name, opts) => envSave(name, opts));
|
|
11746
|
+
env.command("remove <name>").description("\u5220\u9664 env\uFF08\u7EA7\u8054\u6E05\u9664\u8BE5 env \u7684\u5168\u90E8 identity \u548C token\uFF09").option("--force", "\u8DF3\u8FC7\u786E\u8BA4\u63D0\u793A").action((name, opts) => envRemove(name, opts));
|
|
11747
|
+
env.command("show [name]").description("\u663E\u793A env \u8BE6\u60C5\uFF08\u542B\u8BE5 env \u4E0B\u7684 identity \u5217\u8868\uFF09").action((name) => envShow({ name }));
|
|
11748
|
+
env.command("edit <field> <value>").description("\u7F16\u8F91 env \u5B57\u6BB5\uFF08endpoint / frontend / tenantId / defaultIdentity / defaultAgent\uFF09").option("--env <name>", "\u76EE\u6807 env \u540D\uFF08\u9ED8\u8BA4\u5F53\u524D activeEnv\uFF09").action((field, value, opts) => envEdit(field, value, opts));
|
|
12408
11749
|
var identity = program.command("identity").description("\u7BA1\u7406 HCM \u8EAB\u4EFD\u51ED\u636E\uFF08env \u4E0B\u7684 identity\uFF09");
|
|
12409
11750
|
identity.command("list").description("\u5217\u51FA identity\uFF08\u9ED8\u8BA4\u5217\u5F53\u524D env\uFF0C--env all \u5217\u5168\u90E8\uFF09").option("--env <name>", '\u8FC7\u6EE4 env\uFF1B\u4F20 "all" \u5217\u5168\u90E8', void 0).action((opts) => identityList(opts));
|
|
12410
11751
|
identity.command("show <name>").description("\u5B9E\u65F6\u663E\u793A alias \u5BF9\u5E94\u7684\u670D\u52A1\u7AEF\u7528\u6237\u3001\u79DF\u6237\u4E0E\u89D2\u8272\uFF08\u4E0D\u8F93\u51FA token\uFF09").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((name, opts) => identityShow(name, opts));
|
|
@@ -12423,21 +11764,10 @@ chiron.command("doctor").description(
|
|
|
12423
11764
|
"\u6838\u5BF9\uFF1A\u672C\u673A\u767B\u5F55\u662F\u5426\u5BF9\u7740 env.yaml \u7684\u73AF\u5883\uFF08\u542B\u56DB\u6761\u951A\u70B9\uFF09/ \u6280\u80FD\u88C5\u6CA1\u88C5 / \u6848\u4F8B\u5E93\u63A5\u6CA1\u63A5 / Jira \u80FD\u4E0D\u80FD\u63D0\u5355"
|
|
12424
11765
|
).option("--project <dir>", "\u9879\u76EE\u6839\u76EE\u5F55", ".").option("--env <name>", "\u8986\u76D6\u8981\u6838\u7684\u73AF\u5883\u522B\u540D\uFF08\u9ED8\u8BA4\u53D6 env.yaml\uFF1B\u591A\u73AF\u5883\u9879\u76EE\u7528\u5B83\u6328\u4E2A\u63A2\uFF09").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\u63A2\u951A\u70B9").option("--fix", "\u80FD\u81EA\u52A8\u8865\u7684\u8865\u4E0A\uFF08\u6280\u80FD / \u6848\u4F8B\u5E93\uFF09\u540E\u518D\u6838\u4E00\u904D").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((opts) => chironDoctorCommand(opts));
|
|
12425
11766
|
var OUTPUT_OPT = ["--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table"];
|
|
12426
|
-
var
|
|
12427
|
-
|
|
12428
|
-
|
|
12429
|
-
|
|
12430
|
-
jira.command("comment").description("\u56DE\u590D\uFF08\u5206\u8BCA\u7ED3\u8BBA\u8D70\u8FD9\u6761\uFF09\uFF1A-f \u6587\u4EF6 / --body \u6587\u672C / \u4F4D\u7F6E\u53C2\u6570 / \u6807\u51C6\u8F93\u5165").argument("<key>", "Jira \u5355\u53F7").argument("[text]", "\u6B63\u6587").option("-f, --file <path>", "\u6B63\u6587\u6587\u4EF6").option("--body <text>", "\u6B63\u6587").option(...OUTPUT_OPT).action((key2, text, opts) => jiraCommentCommand(key2, text, opts));
|
|
12431
|
-
jira.command("assign").description("\u63A5\u624B\uFF1A\u6539\u7ECF\u529E\u4EBA\uFF08\u9ED8\u8BA4 me\uFF09").argument("<key>", "Jira \u5355\u53F7").argument("[who]", "\u7528\u6237\u540D\u6216 me", "me").option(...OUTPUT_OPT).action((key2, who, opts) => jiraAssignCommand(key2, who, opts));
|
|
12432
|
-
jira.command("move").description("\u6D41\u8F6C\uFF1A\u76EE\u6807\u72B6\u6001\u540D\u6216\u6D41\u8F6C\u540D\uFF08\u5982 \u63D0\u4EA4\u534F\u8C03 / \u4E0D\u7528\u5904\u7406\u4E86\uFF09\uFF1B\u53EF\u9644\u8BC4\u8BBA").argument("<key>", "Jira \u5355\u53F7").argument("<target>", "\u72B6\u6001\u6216\u6D41\u8F6C\u540D").option("-f, --file <path>", "\u9644\u5E26\u8BC4\u8BBA\u7684\u6587\u4EF6").option("--body <text>", "\u9644\u5E26\u8BC4\u8BBA").option(...OUTPUT_OPT).action((key2, target, opts) => jiraMoveCommand(key2, target, opts));
|
|
12433
|
-
jira.command("to-issue").description("\u5206\u8BCA\u4E3A\u771F\u7F3A\u53E3\uFF1A\u8F6C\u4EA7\u54C1\u4ED3 issue \u5E76\u53CC\u5411\u56DE\u94FE\uFF08\u5EFA\u6761\u76EE \u2192 \u6302\u94FE\u63A5 \u2192 \u63A5\u624B \u2192 \u63A8 OPEN\uFF09").argument("<key>", "Jira \u5355\u53F7").option("--repo <slug>", "\u4EA7\u54C1\u4ED3", "hcm/hcm_nx_core").option("--force", "\u5DF2\u5173\u8054\u8FC7\u4E5F\u518D\u5EFA\u4E00\u6761").option(...OUTPUT_OPT).action((key2, opts) => jiraToIssueCommand(key2, opts));
|
|
12434
|
-
jira.command("sync").description("\u4EE3\u7801\u5E93\u6761\u76EE\u5168\u5173 \u2192 \u56DE\u5199 Jira \u5E76\u63A8\u300C\u5DF2\u4FEE\u590D\u300D\uFF08PR \u53F7\u4E0D\u7B97\u6761\u76EE\uFF1B\u8BFB\u4E0D\u5230\u7684\u6309\u672A\u5173\u5904\u7406\uFF09").argument("<key>", "Jira \u5355\u53F7").option("--dry-run", "\u53EA\u5224\u65AD\u4E0D\u5199").option(...OUTPUT_OPT).action((key2, opts) => jiraSyncCommand(key2, opts));
|
|
12435
|
-
jira.command("verify-pass").description("\u987E\u95EE\u5728\u76EE\u6807\u73AF\u5883\u590D\u9A8C\u901A\u8FC7 \u2192 CLOSE").argument("<key>", "Jira \u5355\u53F7").argument("[note]", "\u8BF4\u660E").option("-f, --file <path>", "\u8BF4\u660E\u6587\u4EF6").option("--body <text>", "\u8BF4\u660E").option(...OUTPUT_OPT).action((key2, note, opts) => jiraVerifyPassCommand(key2, note, opts));
|
|
12436
|
-
jira.command("verify-fail").description("\u590D\u9A8C\u4E0D\u901A\u8FC7 \u2192 \u9000\u56DE OPEN\uFF0C\u5E76\u91CD\u5F00\u4EE3\u7801\u5E93 issue").argument("<key>", "Jira \u5355\u53F7").argument("[note]", "\u4E0D\u901A\u8FC7\u7684\u8BF4\u660E").option("-f, --file <path>", "\u8BF4\u660E\u6587\u4EF6").option("--body <text>", "\u8BF4\u660E").option(...OUTPUT_OPT).action((key2, note, opts) => jiraVerifyFailCommand(key2, note, opts));
|
|
12437
|
-
jira.command("audit").description("\u4E00\u81F4\u6027\uFF1A\u72B6\u6001\u5DF2\u79BB\u5F00\u300C\u65B0\u589E\u300D\u7684\u7F3A\u53E3\u5355\u5FC5\u987B\u6302\u7740\u4EE3\u7801\u5E93\u6761\u76EE").option(...OUTPUT_OPT).action((opts) => jiraAuditCommand(opts));
|
|
12438
|
-
jira.command("search").description("\u987E\u95EE\u4FA7\u67E5\u91CD\uFF1A\u6309\u9519\u8BEF\u7801 / Model / Action / \u4E00\u53E5\u73B0\u8C61\u67E5 Jira \u4E0E\u4EA7\u54C1\u4ED3\uFF0C\u5E26\u56DE\u7F16\u53F7\u4E0E\u72B6\u6001").argument("<keywords...>", "\u5173\u952E\u8BCD\uFF0C\u6BCF\u4E2A\u5355\u72EC\u67E5\u4E00\u6B21").option("--no-include-closed", "\u53EA\u67E5\u672A\u89E3\u51B3\u7684").option(...OUTPUT_OPT).action((keywords, opts) => jiraSearchCommand(keywords, opts));
|
|
12439
|
-
jira.command("status").description("\u987E\u95EE\u4FA7\u67E5\u8FDB\u5EA6\uFF1A\u8BA4 HCMNX-12 / 12 / core#2198 / cases#26").argument("<ref>", "Jira \u5355\u53F7\u6216\u4EE3\u7801\u5E93\u5F15\u7528").option(...OUTPUT_OPT).action((ref, opts) => jiraStatusCommand(ref, opts));
|
|
12440
|
-
jira.command("submit").description("\u987E\u95EE\u4FA7\u63D0\u7F3A\u53E3\uFF1A\u5148\u67E5\u91CD\uFF08\u540C\u4E00\u7F3A\u53E3\u8FFD\u52A0\u300C\u53C8\u4E00\u4E2A\u73B0\u573A\u300D\uFF09\uFF0C\u5426\u5219\u6309 HCMNX \u5FC5\u586B\u683C\u65B0\u5F00\uFF1B\u8F7D\u8377 JSON \u8D70 --file \u6216\u6807\u51C6\u8F93\u5165").option("--file <path>", "\u7F3A\u53E3\u8F7D\u8377 JSON\uFF08title/phenomenon/repro/expected/alternative/q_*/severity/kind/module\u2026\uFF09").option("--env <name>", "\u53D6\u73AF\u5883\u6307\u7EB9\u7528\u7684\u73AF\u5883\u522B\u540D\uFF08\u7F3A\u7701 activeEnv\uFF09").option("--fingerprint <text>", "\u76F4\u63A5\u7ED9\u6307\u7EB9\u6587\u672C\uFF08\u8BAD\u7EC3\u573A\u4ECE \u573A.yml \u53D6\u65F6\u7528\uFF09\uFF0C\u4E0D\u518D\u73B0\u67E5").option("--issuetype <name>", "\u8986\u76D6 issuetype\uFF08\u7F3A\u7701\u6309 kind \u9009 \u6545\u969C / \u9700\u6C42\uFF09").option("--assignee <user>", "\u8986\u76D6\u7ECF\u529E\u4EBA\uFF08\u7F3A\u7701\u9879\u76EE\u8D1F\u8D23\u4EBA\uFF09").option(...OUTPUT_OPT).action((opts) => jiraSubmitCommand(opts));
|
|
11767
|
+
var gap = chiron.command("gap").description("\u7F3A\u53E3\uFF1A\u649E\u5230\u300C\u4EA7\u54C1\u505A\u4E0D\u5230\u300D\u65F6\u7684\u7EDF\u4E00\u51FA\u53E3\uFF0C\u8FDB Jira\uFF08HCMNX\uFF09\u2014\u2014\u67E5\u91CD search / \u67E5\u8FDB\u5EA6 status / \u63D0\u7F3A\u53E3 submit");
|
|
11768
|
+
gap.command("search").description("\u67E5\u91CD\uFF1A\u6309\u9519\u8BEF\u7801 / Model / Action / \u4E00\u53E5\u73B0\u8C61\u67E5 Jira\uFF0C\u5E26\u56DE\u7F16\u53F7\u4E0E\u72B6\u6001").argument("<keywords...>", "\u5173\u952E\u8BCD\uFF0C\u6BCF\u4E2A\u5355\u72EC\u67E5\u4E00\u6B21").option("--no-include-closed", "\u53EA\u67E5\u672A\u89E3\u51B3\u7684").option(...OUTPUT_OPT).action((keywords, opts) => gapSearchCommand(keywords, opts));
|
|
11769
|
+
gap.command("status").description("\u67E5\u8FDB\u5EA6\uFF1A\u7ED9 Jira \u5355\u53F7\uFF08HCMNX-12 \u6216\u88F8\u6570\u5B57 12\uFF09").argument("<ref>", "Jira \u5355\u53F7").option(...OUTPUT_OPT).action((ref, opts) => gapStatusCommand(ref, opts));
|
|
11770
|
+
gap.command("submit").description("\u63D0\u7F3A\u53E3\uFF1A\u5148\u67E5\u91CD\uFF08\u540C\u4E00\u7F3A\u53E3\u8FFD\u52A0\u300C\u53C8\u4E00\u4E2A\u73B0\u573A\u300D\uFF09\uFF0C\u5426\u5219\u6309 HCMNX \u5FC5\u586B\u683C\u65B0\u5F00\uFF1B\u8F7D\u8377 JSON \u8D70 --file \u6216\u6807\u51C6\u8F93\u5165").option("--file <path>", "\u7F3A\u53E3\u8F7D\u8377 JSON\uFF08title/phenomenon/repro/expected/alternative/q_*/severity/kind/module\u2026\uFF09").option("--env <name>", "\u53D6\u73AF\u5883\u6307\u7EB9\u7528\u7684\u73AF\u5883\u522B\u540D\uFF08\u7F3A\u7701 activeEnv\uFF09").option("--fingerprint <text>", "\u76F4\u63A5\u7ED9\u6307\u7EB9\u6587\u672C\uFF08\u8BAD\u7EC3\u573A\u4ECE \u573A.yml \u53D6\u65F6\u7528\uFF09\uFF0C\u4E0D\u518D\u73B0\u67E5").option("--issuetype <name>", "\u8986\u76D6 issuetype\uFF08\u7F3A\u7701\u6309 kind \u9009 \u6545\u969C / \u9700\u6C42\uFF09").option("--assignee <user>", "\u8986\u76D6\u7ECF\u529E\u4EBA\uFF08\u7F3A\u7701\u9879\u76EE\u8D1F\u8D23\u4EBA\uFF09").option(...OUTPUT_OPT).action((opts) => gapSubmitCommand(opts));
|
|
12441
11771
|
var recon = chiron.command("recon").description("\u722C\u4E00\u4EFD\u53EF\u5E26\u8D70\u7684\u57FA\u7EBF\uFF1A\u6A21\u578B / \u5B57\u6BB5 / \u53EA\u8BFB\u95F8 / \u4F9D\u8D56\u56FE / \u7801\u8868 / \u53EF\u5199\u6027\u753B\u50CF").option("--env <name>", "\u76EE\u6807\u73AF\u5883\u522B\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD").option("--out <dir>", "\u4EA7\u7269\u6839\u76EE\u5F55\uFF08\u4EA7\u7269\u843D\u5728 <out>/recon/<\u79DF\u6237\u6BB5>/<\u6765\u6E90\u6BB5>\uFF09", ".").option("--state <s>", "\u53EA\u8BFB\u95F8\u7684 state\uFF08\u4EA7\u54C1\u91CC state \u4E0D\u53EF\u679A\u4E3E\uFF0C\u95F8\u7684\u8986\u76D6\u9762\u6C38\u8FDC\u662F state-scoped\uFF09").option("--model <key>", "\u5B9A\u5411\u91CD\u722C\uFF1A\u53EA\u91CD\u722C\u8FD9\u4E00\u4E2A\u6A21\u578B\uFF0C\u5176\u4F59\u6CBF\u7528\u4E0A\u4E00\u8F6E\u4EA7\u7269").option("--capabilities <s>", "\u722C\u53D6\u65F6\u58F0\u660E\u7684 capability \u4E32\uFF08\u4F1A\u968F\u56DB\u5143\u7EC4\u7559\u6863\uFF09").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((opts) => deliveryReconCommand(opts));
|
|
12442
11772
|
recon.command("round").description("\u96F6\u7F51\u7EDC\uFF1A\u8BFB\u4E00\u4EFD\u5DF2\u843D\u76D8\u7684\u57FA\u7EBF\uFF0C\u5224\u65AD\u5B83\u662F\u4E0D\u662F\u4E00\u8F6E\u5B8C\u6574\u8DD1\u51FA\u6765\u7684\uFF08complete/mixed/unknown\uFF09").option("--dir <dir>", "\u4EA7\u7269\u76EE\u5F55\uFF08<out>/recon/<\u79DF\u6237\u6BB5>/<\u6765\u6E90\u6BB5>\uFF09", ".").action(
|
|
12443
11773
|
(opts, cmd) => deliveryReconRoundCommand({
|
|
@@ -12621,7 +11951,7 @@ program.command("update <Model>").description("\u66F4\u65B0\u4E00\u6761 Model \u
|
|
|
12621
11951
|
).action((model, opts) => updateCommand(model, opts));
|
|
12622
11952
|
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));
|
|
12623
11953
|
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));
|
|
12624
|
-
program.command("open [path]").description("\u7528\u5F53\u524D CLI \u8EAB\u4EFD\u6253\u5F00\u524D\u7AEF\u9875\u9762\uFF1A\u94F8\u4E00\u5F20 60s \u4E00\u6B21\u6027\u7968\u636E\u4EA4\u7ED9\u6D4F\u89C8\u5668\uFF0C\u4F1A\u8BDD token \u4E0D\u8FDB URL").option("--print-url", "\u53EA\u6253\u5370\u767B\u5F55 URL\uFF0C\u4E0D\u5F00\u6D4F\u89C8\u5668\uFF08\u7ED9 agent \u6D4F\u89C8\u5668 navigate \u7528\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("--profile <name>", "[deprecated] \u7528 --env \u66FF\u4EE3").action((
|
|
11954
|
+
program.command("open [path]").description("\u7528\u5F53\u524D CLI \u8EAB\u4EFD\u6253\u5F00\u524D\u7AEF\u9875\u9762\uFF1A\u94F8\u4E00\u5F20 60s \u4E00\u6B21\u6027\u7968\u636E\u4EA4\u7ED9\u6D4F\u89C8\u5668\uFF0C\u4F1A\u8BDD token \u4E0D\u8FDB URL").option("--print-url", "\u53EA\u6253\u5370\u767B\u5F55 URL\uFF0C\u4E0D\u5F00\u6D4F\u89C8\u5668\uFF08\u7ED9 agent \u6D4F\u89C8\u5668 navigate \u7528\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("--profile <name>", "[deprecated] \u7528 --env \u66FF\u4EE3").action((path14, opts) => openCommand(path14, opts));
|
|
12625
11955
|
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");
|
|
12626
11956
|
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));
|
|
12627
11957
|
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(
|