@hcmai/cli 0.7.0 → 0.7.1
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 +198 -392
- package/dist/index.js.map +1 -1
- package/dist/skills/manifest.json +1 -1
- 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, {});
|
|
@@ -6798,7 +6796,7 @@ async function verifyAfterWrite(c, path15) {
|
|
|
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,
|
|
@@ -9532,8 +9325,8 @@ async function chironInitCommand(args, deps) {
|
|
|
9532
9325
|
// src/commands/chiron-doctor.ts
|
|
9533
9326
|
init_auth_guard();
|
|
9534
9327
|
init_exit();
|
|
9535
|
-
import { promises as
|
|
9536
|
-
import
|
|
9328
|
+
import { promises as fs10 } from "fs";
|
|
9329
|
+
import path9 from "path";
|
|
9537
9330
|
import {
|
|
9538
9331
|
HcmClient as HcmClient21,
|
|
9539
9332
|
CliError as CliError23,
|
|
@@ -9558,9 +9351,9 @@ var defaultDeps = {
|
|
|
9558
9351
|
inspectJira: () => inspectJira()
|
|
9559
9352
|
};
|
|
9560
9353
|
async function runChironDoctor(args, deps = defaultDeps) {
|
|
9561
|
-
const root =
|
|
9354
|
+
const root = path9.resolve(args.project ?? ".");
|
|
9562
9355
|
const report = { ok: false, project: root, env: null, envName: null, lines: [] };
|
|
9563
|
-
const envText = await
|
|
9356
|
+
const envText = await fs10.readFile(path9.join(root, ENV_FILE), "utf8").catch(() => null);
|
|
9564
9357
|
if (envText === null) {
|
|
9565
9358
|
report.lines.push({
|
|
9566
9359
|
item: "\u767B\u5F55",
|
|
@@ -9570,32 +9363,32 @@ async function runChironDoctor(args, deps = defaultDeps) {
|
|
|
9570
9363
|
});
|
|
9571
9364
|
return finish(report);
|
|
9572
9365
|
}
|
|
9573
|
-
let
|
|
9366
|
+
let env2;
|
|
9574
9367
|
try {
|
|
9575
|
-
|
|
9368
|
+
env2 = parseEnvYaml(envText);
|
|
9576
9369
|
} catch (e) {
|
|
9577
9370
|
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
9371
|
return finish(report);
|
|
9579
9372
|
}
|
|
9580
|
-
report.env =
|
|
9581
|
-
const found = await findEnvByEndpoint(
|
|
9582
|
-
const loginCmd = `hcm login ${
|
|
9373
|
+
report.env = env2;
|
|
9374
|
+
const found = await findEnvByEndpoint(env2.endpoint, env2.tenant);
|
|
9375
|
+
const loginCmd = `hcm login ${env2.endpoint} --code <\u914D\u5BF9\u7801>`;
|
|
9583
9376
|
if (!found) {
|
|
9584
|
-
report.lines.push({ item: "\u767B\u5F55", verdict: "fail", detail: `\u672C\u673A\u6CA1\u6709\u767B\u5F55\u8FC7 ${
|
|
9377
|
+
report.lines.push({ item: "\u767B\u5F55", verdict: "fail", detail: `\u672C\u673A\u6CA1\u6709\u767B\u5F55\u8FC7 ${env2.endpoint}`, nextStep: loginCmd });
|
|
9585
9378
|
} else {
|
|
9586
9379
|
report.envName = found.name;
|
|
9587
9380
|
try {
|
|
9588
9381
|
const targetEnv = args.env ?? found.name;
|
|
9589
|
-
const { report: anchors, tokenTenant } = await deps.anchors(targetEnv,
|
|
9382
|
+
const { report: anchors, tokenTenant } = await deps.anchors(targetEnv, env2.tenant, args.as);
|
|
9590
9383
|
report.anchors = anchors;
|
|
9591
|
-
const tenantMismatch = tokenTenant && tokenTenant !==
|
|
9384
|
+
const tenantMismatch = tokenTenant && tokenTenant !== env2.tenant;
|
|
9592
9385
|
const bad = anchors.checks.filter((c) => !c.ok && !(tenantMismatch && c.anchor === "identity"));
|
|
9593
9386
|
if (bad.length === 0 && !tenantMismatch) {
|
|
9594
9387
|
const who = found.config.defaultIdentity ? ` \xB7 ${found.config.defaultIdentity}` : "";
|
|
9595
|
-
report.lines.push({ item: "\u767B\u5F55", verdict: "ok", detail: `${found.name} \xB7 ${
|
|
9388
|
+
report.lines.push({ item: "\u767B\u5F55", verdict: "ok", detail: `${found.name} \xB7 ${env2.endpoint} \xB7 \u79DF\u6237 ${env2.tenant}${who}` });
|
|
9596
9389
|
} else {
|
|
9597
|
-
const parts = [`${found.name} \xB7 ${
|
|
9598
|
-
if (tenantMismatch) parts.push(`\u4F60\u7684\u767B\u5F55\u8EAB\u4EFD\u5C5E\u4E8E\u79DF\u6237 ${tokenTenant}\uFF0C\u9879\u76EE\u662F\u79DF\u6237 ${
|
|
9390
|
+
const parts = [`${found.name} \xB7 ${env2.endpoint}`];
|
|
9391
|
+
if (tenantMismatch) parts.push(`\u4F60\u7684\u767B\u5F55\u8EAB\u4EFD\u5C5E\u4E8E\u79DF\u6237 ${tokenTenant}\uFF0C\u9879\u76EE\u662F\u79DF\u6237 ${env2.tenant}`);
|
|
9599
9392
|
if (bad.length) parts.push(`\u951A\u70B9\u672A\u8FC7\uFF1A${bad.map((c) => `${c.anchor}\uFF08${c.detail}\uFF09`).join("\u3001")}`);
|
|
9600
9393
|
report.lines.push({
|
|
9601
9394
|
item: "\u767B\u5F55",
|
|
@@ -9606,15 +9399,15 @@ async function runChironDoctor(args, deps = defaultDeps) {
|
|
|
9606
9399
|
}
|
|
9607
9400
|
} catch (e) {
|
|
9608
9401
|
const msg = e instanceof CliError23 ? e.message : e.message;
|
|
9609
|
-
report.lines.push({ item: "\u767B\u5F55", verdict: "fail", detail: `${found.name} \xB7 ${
|
|
9402
|
+
report.lines.push({ item: "\u767B\u5F55", verdict: "fail", detail: `${found.name} \xB7 ${env2.endpoint}\uFF1A${msg}`, nextStep: loginCmd });
|
|
9610
9403
|
}
|
|
9611
9404
|
}
|
|
9612
9405
|
const skillsLine = async () => {
|
|
9613
|
-
const state = await readSkillsState(
|
|
9406
|
+
const state = await readSkillsState(path9.join(root, SKILLS_DIR));
|
|
9614
9407
|
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
9408
|
const count = Object.keys(state.skills).length;
|
|
9616
|
-
if (state.endpoint && normalizeOrigin(state.endpoint) !==
|
|
9617
|
-
return { item: "\u6280\u80FD", verdict: "fail", detail: `${count} \u4E2A\uFF0C\u4F46\u88C5\u81EA ${state.endpoint}\uFF0C\u4E0D\u662F\u9879\u76EE\u73AF\u5883 ${
|
|
9409
|
+
if (state.endpoint && normalizeOrigin(state.endpoint) !== env2.endpoint) {
|
|
9410
|
+
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" };
|
|
9618
9411
|
}
|
|
9619
9412
|
if (state.target !== "codex") {
|
|
9620
9413
|
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" };
|
|
@@ -9642,7 +9435,7 @@ async function runChironDoctor(args, deps = defaultDeps) {
|
|
|
9642
9435
|
report.lines.push(cases);
|
|
9643
9436
|
const jira2 = await deps.inspectJira();
|
|
9644
9437
|
report.lines.push(
|
|
9645
|
-
jira2.ok ? { item: "Jira", verdict: "ok", detail: `${jira2.who || "\u5DF2\u8FDE\u63A5"} \xB7 \u770B\u5F97\u5230 ${
|
|
9438
|
+
jira2.ok ? { item: "Jira", verdict: "ok", detail: `${jira2.who || "\u5DF2\u8FDE\u63A5"} \xB7 \u770B\u5F97\u5230 ${JIRA_PROJECT2}\uFF08\u4EE4\u724C\u6765\u81EA ${jira2.from}\uFF09` } : { item: "Jira", verdict: "warn", detail: jira2.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" }
|
|
9646
9439
|
);
|
|
9647
9440
|
return finish(report);
|
|
9648
9441
|
}
|
|
@@ -9676,8 +9469,8 @@ async function chironDoctorCommand(args, deps) {
|
|
|
9676
9469
|
// src/commands/chiron-test.ts
|
|
9677
9470
|
init_exit();
|
|
9678
9471
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
9679
|
-
import { promises as
|
|
9680
|
-
import
|
|
9472
|
+
import { promises as fs11 } from "fs";
|
|
9473
|
+
import path10 from "path";
|
|
9681
9474
|
import yaml from "js-yaml";
|
|
9682
9475
|
import { formatObject as formatObject23 } from "@hcmai/sdk";
|
|
9683
9476
|
|
|
@@ -9826,7 +9619,7 @@ function classify(argv, actionResolution) {
|
|
|
9826
9619
|
if (name.startsWith("-")) {
|
|
9827
9620
|
return forbidden(
|
|
9828
9621
|
"malformed-argv",
|
|
9829
|
-
`\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\
|
|
9622
|
+
`\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>\``
|
|
9830
9623
|
);
|
|
9831
9624
|
}
|
|
9832
9625
|
if (argv.some((arg) => APPROVAL_BYPASS_FLAGS.has(flagName(arg)))) {
|
|
@@ -10073,7 +9866,12 @@ function guarded(effect, reasonCode) {
|
|
|
10073
9866
|
execution: "guarded",
|
|
10074
9867
|
effect,
|
|
10075
9868
|
reasonCode,
|
|
10076
|
-
|
|
9869
|
+
// 🔴 这一句是 R2 档的**主文案**,15 个调用方共用它,顾问跑任何写命令都读到它。
|
|
9870
|
+
// 0.7.0 之前它写的是「只允许在 controlled 项目中通过 delivery prepare +
|
|
9871
|
+
// delivery execute 单次受控执行」——那三个概念随受控执行三步一起删了,
|
|
9872
|
+
// 于是它变成一条指向不存在的路的下一步。既然 CLI 不再自建执行闸,
|
|
9873
|
+
// 真正的下一步就是「这条命令不从这里跑」,而不是「换个 CLI 姿势跑」。
|
|
9874
|
+
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"
|
|
10077
9875
|
};
|
|
10078
9876
|
}
|
|
10079
9877
|
function classifyAction(policy) {
|
|
@@ -10480,7 +10278,7 @@ var defaultDeps2 = {
|
|
|
10480
10278
|
return { status: r.status, stdout: r.stdout ?? "", stderr: r.stderr ?? "" };
|
|
10481
10279
|
},
|
|
10482
10280
|
readXlsx: (file) => xlsxRows(file),
|
|
10483
|
-
readText: (file) =>
|
|
10281
|
+
readText: (file) => fs11.readFile(file, "utf8")
|
|
10484
10282
|
};
|
|
10485
10283
|
async function runCase(spec, root, opts = {}, deps = defaultDeps2) {
|
|
10486
10284
|
const results = [];
|
|
@@ -10498,7 +10296,12 @@ async function runCase(spec, root, opts = {}, deps = defaultDeps2) {
|
|
|
10498
10296
|
results.push({
|
|
10499
10297
|
name: c.name,
|
|
10500
10298
|
verdict: "fail",
|
|
10501
|
-
|
|
10299
|
+
// 🔴 `verdict.reason` 里已经带着分档理由与 `next_step=`(见 delivery.ts 的
|
|
10300
|
+
// action-effect-undetermined / action-effect-unrecognized 两支)。此前这里
|
|
10301
|
+
// 把它整个丢掉、自己编了一句「走 delivery assess → prepare → execute」,
|
|
10302
|
+
// 而那三条命令已于 0.7.0 删除 —— 顾问撞到写命令,拿到的是一条不存在的路。
|
|
10303
|
+
// 手上有的就要打出来,不要自己编第二句。
|
|
10304
|
+
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`
|
|
10502
10305
|
});
|
|
10503
10306
|
continue;
|
|
10504
10307
|
}
|
|
@@ -10533,7 +10336,7 @@ async function runCase(spec, root, opts = {}, deps = defaultDeps2) {
|
|
|
10533
10336
|
continue;
|
|
10534
10337
|
}
|
|
10535
10338
|
if (c.file) {
|
|
10536
|
-
const file =
|
|
10339
|
+
const file = path10.resolve(root, fill(c.file));
|
|
10537
10340
|
const want = c.expect ?? {};
|
|
10538
10341
|
const bad = [];
|
|
10539
10342
|
if (want.xlsx_header || want.xlsx_min_rows !== void 0) {
|
|
@@ -10549,7 +10352,7 @@ async function runCase(spec, root, opts = {}, deps = defaultDeps2) {
|
|
|
10549
10352
|
results.push(bad.length ? { name: c.name, verdict: "fail", detail: bad.join("\uFF1B") } : { name: c.name, verdict: "pass", detail: "" });
|
|
10550
10353
|
continue;
|
|
10551
10354
|
}
|
|
10552
|
-
const out =
|
|
10355
|
+
const out = path10.join("evidence", "test", `${spec.name}-${c.name}`.replace(/[^\w一-龥-]+/g, "_") + ".png");
|
|
10553
10356
|
const argv = ["--path", fill(c.page), "--out", out];
|
|
10554
10357
|
if (opts.env) argv.push("--env", opts.env);
|
|
10555
10358
|
const as = c.as ?? opts.as;
|
|
@@ -10565,12 +10368,12 @@ async function runCase(spec, root, opts = {}, deps = defaultDeps2) {
|
|
|
10565
10368
|
return results;
|
|
10566
10369
|
}
|
|
10567
10370
|
async function loadCases(target) {
|
|
10568
|
-
const stat = await
|
|
10569
|
-
const files = stat.isDirectory() ? (await
|
|
10371
|
+
const stat = await fs11.stat(target);
|
|
10372
|
+
const files = stat.isDirectory() ? (await fs11.readdir(target)).filter((f) => /\.ya?ml$/.test(f)).sort().map((f) => path10.join(target, f)) : [target];
|
|
10570
10373
|
const out = [];
|
|
10571
10374
|
for (const f of files) {
|
|
10572
|
-
const spec = yaml.load(await
|
|
10573
|
-
assertUsableSpec(spec,
|
|
10375
|
+
const spec = yaml.load(await fs11.readFile(f, "utf8"));
|
|
10376
|
+
assertUsableSpec(spec, path10.basename(f));
|
|
10574
10377
|
out.push({ file: f, spec });
|
|
10575
10378
|
}
|
|
10576
10379
|
if (out.length === 0) throw new Error(`${target} \u4E0B\u6CA1\u6709\u7528\u4F8B\uFF08*.yml\uFF09`);
|
|
@@ -10578,15 +10381,15 @@ async function loadCases(target) {
|
|
|
10578
10381
|
}
|
|
10579
10382
|
async function chironTestCommand(target, args, deps) {
|
|
10580
10383
|
try {
|
|
10581
|
-
const root =
|
|
10582
|
-
const where =
|
|
10384
|
+
const root = path10.resolve(args.project ?? ".");
|
|
10385
|
+
const where = path10.resolve(root, target ?? "tests");
|
|
10583
10386
|
const cases = await loadCases(where);
|
|
10584
10387
|
const report = [];
|
|
10585
10388
|
let failed2 = 0;
|
|
10586
10389
|
for (const { file, spec } of cases) {
|
|
10587
10390
|
const results = await runCase(spec, root, { env: args.env, as: args.as }, deps);
|
|
10588
10391
|
failed2 += results.filter((r) => r.verdict === "fail").length;
|
|
10589
|
-
report.push({ case: spec.name, file:
|
|
10392
|
+
report.push({ case: spec.name, file: path10.relative(root, file), results });
|
|
10590
10393
|
}
|
|
10591
10394
|
const fmt = args.output ?? "table";
|
|
10592
10395
|
if (fmt === "json" || fmt === "yaml") {
|
|
@@ -10625,10 +10428,12 @@ import {
|
|
|
10625
10428
|
resolveActiveEnv as resolveActiveEnv5
|
|
10626
10429
|
} from "@hcmai/sdk";
|
|
10627
10430
|
init_exit();
|
|
10431
|
+
import { createJiraClient } from "@hcmai/sdk";
|
|
10628
10432
|
|
|
10629
10433
|
// src/jira/refs.ts
|
|
10630
|
-
import { execFileSync
|
|
10631
|
-
|
|
10434
|
+
import { execFileSync } from "child_process";
|
|
10435
|
+
import { CASES_REPO_SLUG, repoIssueUrl } from "@hcmai/sdk";
|
|
10436
|
+
var defaultCnb = (args) => execFileSync("cnb", args, { encoding: "utf8", maxBuffer: 1 << 26, stdio: ["ignore", "pipe", "pipe"] });
|
|
10632
10437
|
var PRODUCT_REPOS = ["hcm/hcm_nx_core", "hcm/hcm_nx_cli", "hcm/hcm_nx_cloud"];
|
|
10633
10438
|
var REF_RE = /hcm\/(hcm_nx_(?:core|cli|cloud))(?:#|\/-\/issues\/)(\d+)/g;
|
|
10634
10439
|
function linkedRepoRefs(text) {
|
|
@@ -10738,6 +10543,7 @@ function parseRef(raw, project, casesSlug = CASES_REPO_SLUG) {
|
|
|
10738
10543
|
var firstLine2 = (s) => String(s ?? "").split("\n").find((l) => l.trim())?.trim() ?? "";
|
|
10739
10544
|
|
|
10740
10545
|
// src/jira/gaps.ts
|
|
10546
|
+
import { CASES_REPO_SLUG as CASES_REPO_SLUG2 } from "@hcmai/sdk";
|
|
10741
10547
|
var MIN_LEN = [
|
|
10742
10548
|
["title", 8],
|
|
10743
10549
|
["phenomenon", 20],
|
|
@@ -10969,7 +10775,7 @@ async function gapSearch({ client: client3, cnb }, keywords, { includeClosed = t
|
|
|
10969
10775
|
const seen = /* @__PURE__ */ new Set();
|
|
10970
10776
|
return { rows: rows.filter((r) => seen.has(r.id) ? false : (seen.add(r.id), true)), jiraError };
|
|
10971
10777
|
}
|
|
10972
|
-
async function gapStatus({ client: client3, cnb }, ref, casesSlug =
|
|
10778
|
+
async function gapStatus({ client: client3, cnb }, ref, casesSlug = CASES_REPO_SLUG2) {
|
|
10973
10779
|
const parsed = parseRef(ref, client3.project, casesSlug);
|
|
10974
10780
|
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
10781
|
if (parsed.kind === "repo") {
|
|
@@ -11382,10 +11188,10 @@ async function jiraStatusCommand(ref, args, deps = defaultDeps3) {
|
|
|
11382
11188
|
emit4(args.output, r, () => [...r.lines, `\u4E0B\u4E00\u6B65\uFF1A${r.nextStep}`].join("\n"));
|
|
11383
11189
|
});
|
|
11384
11190
|
}
|
|
11385
|
-
async function fingerprintText(
|
|
11191
|
+
async function fingerprintText(env2) {
|
|
11386
11192
|
try {
|
|
11387
11193
|
const g = await loadGlobalConfig11();
|
|
11388
|
-
const name = resolveActiveEnv5({ envFlag:
|
|
11194
|
+
const name = resolveActiveEnv5({ envFlag: env2 }, process.env, g);
|
|
11389
11195
|
const cfg = await loadEnv11(name);
|
|
11390
11196
|
if (!cfg?.endpoint) return `\u672A\u53D6\u5230\u6307\u7EB9\uFF08env=${name}\uFF1A\u6CA1\u6709 endpoint\uFF09`;
|
|
11391
11197
|
const http = createHttpClient4({ endpoint: cfg.endpoint.replace(/\/+$/, ""), getAccessToken: async () => null, onRefresh: async () => {
|
|
@@ -11395,7 +11201,7 @@ async function fingerprintText(env3) {
|
|
|
11395
11201
|
const commit = info.commit ?? info.gitCommit ?? info.version ?? "?";
|
|
11396
11202
|
return `backend ${String(commit).slice(0, 12)} \xB7 CLI ${CLI_VERSION} \xB7 env ${name}`;
|
|
11397
11203
|
} catch (e) {
|
|
11398
|
-
return `\u672A\u53D6\u5230\u6307\u7EB9\uFF08env=${
|
|
11204
|
+
return `\u672A\u53D6\u5230\u6307\u7EB9\uFF08env=${env2 ?? "\u672A\u8BBE"}\uFF1B${String(e.message ?? e).split("\n")[0]?.slice(0, 120)}\uFF09`;
|
|
11399
11205
|
}
|
|
11400
11206
|
}
|
|
11401
11207
|
async function jiraSubmitCommand(args, deps = defaultDeps3) {
|
|
@@ -11528,7 +11334,7 @@ import {
|
|
|
11528
11334
|
writeRisk
|
|
11529
11335
|
} from "@hcmai/sdk";
|
|
11530
11336
|
import { existsSync as existsSync2 } from "fs";
|
|
11531
|
-
import * as
|
|
11337
|
+
import * as path11 from "path";
|
|
11532
11338
|
function premise(message, hint = "") {
|
|
11533
11339
|
process.stderr.write(message + (hint ? `
|
|
11534
11340
|
\u2192 ${hint}` : "") + "\n");
|
|
@@ -11555,13 +11361,13 @@ async function runSeedPlan(args, client3) {
|
|
|
11555
11361
|
const reconDir = candidates[0].reconDir;
|
|
11556
11362
|
if (candidates.length > 1) {
|
|
11557
11363
|
process.stderr.write(
|
|
11558
|
-
`\u26A0\uFE0F \u540C\u79DF\u6237\u4E0B\u6709 ${candidates.length} \u4EFD\u57FA\u7EBF\uFF0C\u672C\u8F6E\u8BFB\u7684\u662F \`${
|
|
11364
|
+
`\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
11365
|
);
|
|
11560
11366
|
}
|
|
11561
11367
|
const round = inspectRound2(reconDir);
|
|
11562
11368
|
process.stderr.write(roundWarning(round));
|
|
11563
11369
|
const baseline = {
|
|
11564
|
-
path: `${
|
|
11370
|
+
path: `${path11.basename(path11.dirname(reconDir))}/${path11.basename(reconDir)}`,
|
|
11565
11371
|
roundId: round.roundId ?? null
|
|
11566
11372
|
};
|
|
11567
11373
|
let exemptions = null;
|
|
@@ -11823,7 +11629,7 @@ async function deliverySeedVerifyCommand(args) {
|
|
|
11823
11629
|
// src/commands/delivery-seed-find.ts
|
|
11824
11630
|
import { existsSync as existsSync3 } from "fs";
|
|
11825
11631
|
import { readFileSync as readFileSync7 } from "fs";
|
|
11826
|
-
import * as
|
|
11632
|
+
import * as path12 from "path";
|
|
11827
11633
|
import {
|
|
11828
11634
|
INIT_EXIT_CODES as INIT_EXIT_CODES2,
|
|
11829
11635
|
ValueHints,
|
|
@@ -11837,10 +11643,10 @@ import {
|
|
|
11837
11643
|
valuesRoundCaveat
|
|
11838
11644
|
} from "@hcmai/sdk";
|
|
11839
11645
|
function provenance(chosenReconDir, others) {
|
|
11840
|
-
let line = `> \u57FA\u7EBF\uFF1A\`${
|
|
11646
|
+
let line = `> \u57FA\u7EBF\uFF1A\`${path12.basename(chosenReconDir)}\`
|
|
11841
11647
|
`;
|
|
11842
11648
|
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) => `\`${
|
|
11649
|
+
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
11650
|
}
|
|
11845
11651
|
return `${line}
|
|
11846
11652
|
`;
|
|
@@ -12177,7 +11983,7 @@ import {
|
|
|
12177
11983
|
runTriageRound
|
|
12178
11984
|
} from "@hcmai/sdk";
|
|
12179
11985
|
import { mkdirSync, readFileSync as readFileSync9, writeFileSync as writeFileSync2 } from "fs";
|
|
12180
|
-
import * as
|
|
11986
|
+
import * as path13 from "path";
|
|
12181
11987
|
var DEFAULT_CAPABILITIES3 = "default";
|
|
12182
11988
|
function premise4(message, hint) {
|
|
12183
11989
|
process.stderr.write(`\u{1F534} \u524D\u63D0\u4E0D\u6210\u7ACB\uFF1A${message}
|
|
@@ -12213,8 +12019,8 @@ function renderProblems(rows) {
|
|
|
12213
12019
|
`;
|
|
12214
12020
|
}
|
|
12215
12021
|
function writeTriageArtifact(outDir, body) {
|
|
12216
|
-
const out =
|
|
12217
|
-
mkdirSync(
|
|
12022
|
+
const out = path13.join(outDir, "work", "triage.md");
|
|
12023
|
+
mkdirSync(path13.dirname(out), { recursive: true });
|
|
12218
12024
|
writeFileSync2(out, body, "utf8");
|
|
12219
12025
|
return out;
|
|
12220
12026
|
}
|
|
@@ -12396,15 +12202,15 @@ config.command("set-profile <name>").description("[deprecated] \u7528 `hcm env u
|
|
|
12396
12202
|
config.command("delete <name>").description("[deprecated] \u7528 `hcm env remove --force`").action((n) => configDeleteDeprecated(n));
|
|
12397
12203
|
config.command("set <key> <value>").description("\u8BBE\u7F6E\u5168\u5C40 defaults\uFF0C\u4F8B\u5982 `defaults.output json`").action((k, v) => configSet(k, v));
|
|
12398
12204
|
config.command("get <key>").description("\u8BFB\u53D6\u5168\u5C40 defaults").action((k) => configGet(k));
|
|
12399
|
-
var
|
|
12400
|
-
|
|
12401
|
-
|
|
12402
|
-
|
|
12403
|
-
|
|
12404
|
-
|
|
12405
|
-
|
|
12406
|
-
|
|
12407
|
-
|
|
12205
|
+
var env = program.command("env").description("\u7BA1\u7406 HCM \u73AF\u5883\uFF08\u591A\u540E\u7AEF\u8FDE\u63A5\u914D\u7F6E\uFF09");
|
|
12206
|
+
env.command("list").description("\u5217\u51FA\u5168\u90E8 env").action(() => envList());
|
|
12207
|
+
env.command("current").description("\u663E\u793A\u5F53\u524D\u6FC0\u6D3B\u7684 env").action(() => envCurrent());
|
|
12208
|
+
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));
|
|
12209
|
+
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));
|
|
12210
|
+
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));
|
|
12211
|
+
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));
|
|
12212
|
+
env.command("show [name]").description("\u663E\u793A env \u8BE6\u60C5\uFF08\u542B\u8BE5 env \u4E0B\u7684 identity \u5217\u8868\uFF09").action((name) => envShow({ name }));
|
|
12213
|
+
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
12214
|
var identity = program.command("identity").description("\u7BA1\u7406 HCM \u8EAB\u4EFD\u51ED\u636E\uFF08env \u4E0B\u7684 identity\uFF09");
|
|
12409
12215
|
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
12216
|
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));
|
|
@@ -12621,7 +12427,7 @@ program.command("update <Model>").description("\u66F4\u65B0\u4E00\u6761 Model \u
|
|
|
12621
12427
|
).action((model, opts) => updateCommand(model, opts));
|
|
12622
12428
|
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
12429
|
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((
|
|
12430
|
+
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
12431
|
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
12432
|
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
12433
|
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(
|