@hcmai/cli 0.33.0 → 0.34.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 +1149 -147
- package/dist/index.js.map +1 -1
- package/dist/skills/hcm-env-transfer/SKILL.md +5 -2
- package/dist/skills/manifest.json +28 -5
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -785,7 +785,7 @@ import chalk from "chalk";
|
|
|
785
785
|
import ora from "ora";
|
|
786
786
|
import { marked } from "marked";
|
|
787
787
|
import { markedTerminal } from "marked-terminal";
|
|
788
|
-
import { absoluteDownloadUrl } from "@hcmai/sdk";
|
|
788
|
+
import { absoluteDownloadUrl, readTextPart } from "@hcmai/sdk";
|
|
789
789
|
function terminalHyperlink(url, text2) {
|
|
790
790
|
return `\x1B]8;;${url}\x07${text2}\x1B]8;;\x07`;
|
|
791
791
|
}
|
|
@@ -1168,6 +1168,18 @@ var init_TerminalRenderer = __esm({
|
|
|
1168
1168
|
this.blockBoundary();
|
|
1169
1169
|
const type = part.type;
|
|
1170
1170
|
const pad = this.indent();
|
|
1171
|
+
const textPart = readTextPart(part);
|
|
1172
|
+
if (textPart) {
|
|
1173
|
+
if (textPart.notice) {
|
|
1174
|
+
const body = textPart.text.replace(/\n+$/, "") || `[${textPart.notice}]`;
|
|
1175
|
+
const lines = body.split("\n");
|
|
1176
|
+
this.write(lines.map((l) => pad + chalk.gray(l)).join("\n") + "\n");
|
|
1177
|
+
} else if (textPart.text) {
|
|
1178
|
+
this.writeChatChunk(textPart.text);
|
|
1179
|
+
this.flushChatBuffer();
|
|
1180
|
+
}
|
|
1181
|
+
return;
|
|
1182
|
+
}
|
|
1171
1183
|
if (type === "chart") {
|
|
1172
1184
|
this.write(pad + chalk.cyan(`\u25B8 \u56FE\u8868 \xB7 ${part.title ?? ""}`) + "\n");
|
|
1173
1185
|
if (part.insight) this.write(pad + chalk.gray(` ${String(part.insight)}`) + "\n");
|
|
@@ -1433,7 +1445,7 @@ var init_StreamPresenter = __esm({
|
|
|
1433
1445
|
// src/repl/InkRendererBridge.ts
|
|
1434
1446
|
import { marked as marked2 } from "marked";
|
|
1435
1447
|
import { markedTerminal as markedTerminal2 } from "marked-terminal";
|
|
1436
|
-
import { absoluteDownloadUrl as absoluteDownloadUrl2 } from "@hcmai/sdk";
|
|
1448
|
+
import { absoluteDownloadUrl as absoluteDownloadUrl2, readTextPart as readTextPart2 } from "@hcmai/sdk";
|
|
1437
1449
|
function createInkRendererBridge(sinks, apiBase) {
|
|
1438
1450
|
let chatBuffer = "";
|
|
1439
1451
|
let thinkingChars = 0;
|
|
@@ -1515,6 +1527,15 @@ function createInkRendererBridge(sinks, apiBase) {
|
|
|
1515
1527
|
},
|
|
1516
1528
|
contentPartSummary(part) {
|
|
1517
1529
|
flushParagraphs(true);
|
|
1530
|
+
const textPart = readTextPart2(part);
|
|
1531
|
+
if (textPart) {
|
|
1532
|
+
if (textPart.notice) {
|
|
1533
|
+
sinks.appendBlock({ kind: "interactionNote", tone: "info", text: textPart.text || `[${textPart.notice}]` });
|
|
1534
|
+
} else if (textPart.text.trim()) {
|
|
1535
|
+
sinks.appendBlock({ kind: "assistant", ansi: renderAnsi(textPart.text) });
|
|
1536
|
+
}
|
|
1537
|
+
return;
|
|
1538
|
+
}
|
|
1518
1539
|
const type = part.type;
|
|
1519
1540
|
let label;
|
|
1520
1541
|
let detail;
|
|
@@ -3444,9 +3465,9 @@ ${e.stdout ?? e.message}`,
|
|
|
3444
3465
|
|
|
3445
3466
|
\u7531 \`hcm chiron case submit\` \u63D0\u4EA4\uFF0Clint \u5DF2\u8FC7\u3002`
|
|
3446
3467
|
]);
|
|
3447
|
-
const
|
|
3468
|
+
const num2 = /number: "?(\d+)/.exec(pr)?.[1] ?? null;
|
|
3448
3469
|
rmSync(INDEX_CACHE(), { force: true });
|
|
3449
|
-
return { id, pr:
|
|
3470
|
+
return { id, pr: num2, url: `${CNB_ORIGIN}/${CASES_REPO_SLUG}/-/pulls/${num2 ?? ""}`, lint: lint.trim() };
|
|
3450
3471
|
} finally {
|
|
3451
3472
|
rmSync(work, { recursive: true, force: true });
|
|
3452
3473
|
}
|
|
@@ -3557,8 +3578,8 @@ function verifyFailure(reasonCode, code2, written, message, nextStep, extra = {}
|
|
|
3557
3578
|
}
|
|
3558
3579
|
function who(u) {
|
|
3559
3580
|
if (!u) return "\uFF08\u5355\u4E0A\u6CA1\u6709\uFF09";
|
|
3560
|
-
const
|
|
3561
|
-
return u.name && u.name !==
|
|
3581
|
+
const shown2 = u.displayName ?? u.name ?? u.key ?? "?";
|
|
3582
|
+
return u.name && u.name !== shown2 ? `${shown2}\uFF08${u.name}\uFF09` : shown2;
|
|
3562
3583
|
}
|
|
3563
3584
|
function sameUser(a, b) {
|
|
3564
3585
|
if (!a || !b) return false;
|
|
@@ -6635,10 +6656,10 @@ async function loginCommand(args) {
|
|
|
6635
6656
|
}
|
|
6636
6657
|
const err = e;
|
|
6637
6658
|
if (err.isAxiosError) {
|
|
6638
|
-
const { fromAxiosError:
|
|
6659
|
+
const { fromAxiosError: fromAxiosError36 } = await import("@hcmai/sdk");
|
|
6639
6660
|
exitWithError(
|
|
6640
6661
|
withTenantHostMismatchStep(
|
|
6641
|
-
|
|
6662
|
+
fromAxiosError36(
|
|
6642
6663
|
e,
|
|
6643
6664
|
envName
|
|
6644
6665
|
),
|
|
@@ -8348,13 +8369,120 @@ init_exit();
|
|
|
8348
8369
|
init_auth_guard();
|
|
8349
8370
|
import {
|
|
8350
8371
|
HcmClient as HcmClient11,
|
|
8372
|
+
MUTATION_CAPABILITY_OPS,
|
|
8373
|
+
MUTATION_CELL_KEYS,
|
|
8351
8374
|
formatObject as formatObject10,
|
|
8352
|
-
fromAxiosError as fromAxiosError14
|
|
8375
|
+
fromAxiosError as fromAxiosError14,
|
|
8376
|
+
missingKeys
|
|
8353
8377
|
} from "@hcmai/sdk";
|
|
8378
|
+
|
|
8379
|
+
// src/commands/introspection-cli.ts
|
|
8380
|
+
var NOT_PROVIDED = "\u672C\u73AF\u5883\u672A\u63D0\u4F9B";
|
|
8381
|
+
function shellArg(v) {
|
|
8382
|
+
return /^[A-Za-z0-9_./:@=+-]+$/.test(v) || /^[\p{Script=Han}A-Za-z0-9_]+$/u.test(v) ? v : `'${v.replace(/'/g, `'\\''`)}'`;
|
|
8383
|
+
}
|
|
8384
|
+
function parseQuery(q) {
|
|
8385
|
+
try {
|
|
8386
|
+
const out = /* @__PURE__ */ new Map();
|
|
8387
|
+
for (const pair of q.replace(/^\?/, "").split("&")) {
|
|
8388
|
+
if (!pair) continue;
|
|
8389
|
+
const i = pair.indexOf("=");
|
|
8390
|
+
const k = decodeURIComponent((i < 0 ? pair : pair.slice(0, i)).replace(/\+/g, " "));
|
|
8391
|
+
const v = i < 0 ? "" : decodeURIComponent(pair.slice(i + 1).replace(/\+/g, " "));
|
|
8392
|
+
out.set(k, v);
|
|
8393
|
+
}
|
|
8394
|
+
return out;
|
|
8395
|
+
} catch {
|
|
8396
|
+
return void 0;
|
|
8397
|
+
}
|
|
8398
|
+
}
|
|
8399
|
+
function introspectCommandFor(query) {
|
|
8400
|
+
const q = parseQuery(query);
|
|
8401
|
+
if (!q) return void 0;
|
|
8402
|
+
const parts = ["hcm introspect"];
|
|
8403
|
+
for (const [k, v] of q) {
|
|
8404
|
+
if (k === "path") parts.splice(1, 0, shellArg(v));
|
|
8405
|
+
else if (k === "detail" && v === "true") parts.push("--detail");
|
|
8406
|
+
else if (k === "limit" && /^\d+$/.test(v)) parts.push(`--limit ${v}`);
|
|
8407
|
+
else return void 0;
|
|
8408
|
+
}
|
|
8409
|
+
return parts.join(" ");
|
|
8410
|
+
}
|
|
8411
|
+
function modelSearchCommandFor(query) {
|
|
8412
|
+
const q = parseQuery(query);
|
|
8413
|
+
const keyword = q?.get("keyword");
|
|
8414
|
+
if (!q || !keyword) return void 0;
|
|
8415
|
+
const parts = ["hcm models", shellArg(keyword), "--search"];
|
|
8416
|
+
for (const [k, v] of q) {
|
|
8417
|
+
if (k === "keyword") continue;
|
|
8418
|
+
if (k === "limit" && /^\d+$/.test(v)) parts.push(`--limit ${v}`);
|
|
8419
|
+
else return void 0;
|
|
8420
|
+
}
|
|
8421
|
+
return parts.join(" ");
|
|
8422
|
+
}
|
|
8423
|
+
var INTROSPECTION_LINK = /GET \/api\/system\/introspection(\?[^\s((]*)?(?: -H "Accept: application\/json")?/g;
|
|
8424
|
+
var MODEL_SEARCH_LINK = /GET \/api\/system\/models\/search(\?[^\s((]*)/g;
|
|
8425
|
+
function rewriteSelfLinks(text2) {
|
|
8426
|
+
return text2.replace(INTROSPECTION_LINK, (whole, query) => {
|
|
8427
|
+
const cmd = introspectCommandFor(query ?? "");
|
|
8428
|
+
return cmd ? `\`${cmd}\`` : whole;
|
|
8429
|
+
}).replace(MODEL_SEARCH_LINK, (whole, query) => {
|
|
8430
|
+
const cmd = modelSearchCommandFor(query);
|
|
8431
|
+
return cmd ? `\`${cmd}\`` : whole;
|
|
8432
|
+
});
|
|
8433
|
+
}
|
|
8434
|
+
var REST_LEFTOVER = /\b(GET|POST|PUT|DELETE|PATCH) \/api\//;
|
|
8435
|
+
var isCapabilityHeader = (line) => /^(GET|POST|PUT|DELETE|PATCH) \/api\//.test(line);
|
|
8436
|
+
function markRestLeftovers(lines, skip = () => false) {
|
|
8437
|
+
return lines.some((l) => !skip(l) && REST_LEFTOVER.test(l)) ? [...lines, "\u2139\uFE0F \u4E0A\u9762\u539F\u6837\u7559\u7740\u7684 `GET /api/\u2026` \u8FD9\u7C7B\u662F\u670D\u52A1\u7AEF\u539F\u6587\uFF08REST \u5199\u6CD5\uFF09\uFF1Ahcm \u6CA1\u6709\u7B49\u4EF7\u547D\u4EE4\uFF0C\u6216\u7B54\u4E0D\u5168\u90A3\u4E00\u95EE\uFF1B\u5B88\u4EA4\u4ED8\u8FB9\u754C\u65F6\u522B\u7167\u7740 curl\uFF0C\u5230\u90A3\u91CC\u505C\u4E0B\u8BF7\u6709\u6743\u9650\u7684\u4EBA\u505A"] : lines;
|
|
8438
|
+
}
|
|
8439
|
+
function howToCommand(howTo) {
|
|
8440
|
+
if (!howTo) return void 0;
|
|
8441
|
+
const t = howTo.trim();
|
|
8442
|
+
const direct2 = /^(?:GET|POST|PUT|DELETE|PATCH) \/api\/models\/([^/\s]+)\/(?:([^/\s]+)\/)?action\/([^/\s?]+)$/.exec(t);
|
|
8443
|
+
if (direct2) {
|
|
8444
|
+
const [, model, id, action] = direct2;
|
|
8445
|
+
const idArg = id ? ` --id ${id === "{id}" ? "<id>" : shellArg(id)}` : "";
|
|
8446
|
+
return `\`hcm action ${model}.${action}${idArg}\``;
|
|
8447
|
+
}
|
|
8448
|
+
const lookup = /^GET \/api\/models\/([^/\s]+)\/actions → 找 key=([^\s((]+)/.exec(t);
|
|
8449
|
+
if (lookup) {
|
|
8450
|
+
const [, model, action] = lookup;
|
|
8451
|
+
return `\`hcm describe ${model}\`\uFF08\u627E ${action} \u90A3\u4E00\u884C\uFF0C\u770B\u4F5C\u7528\u57DF\u4E0E grant\uFF09\u518D \`hcm action ${model}.${action}\``;
|
|
8452
|
+
}
|
|
8453
|
+
return void 0;
|
|
8454
|
+
}
|
|
8455
|
+
var CAPABILITY_CLI = {
|
|
8456
|
+
"GET /api/system/introspection": "`hcm introspect`",
|
|
8457
|
+
"GET /api/system/models": "`hcm models [\u5173\u952E\u5B57]`",
|
|
8458
|
+
"GET /api/system/models/search": "`hcm models <\u8BF4\u6CD5> --search`",
|
|
8459
|
+
"GET /api/models/{model}/meta": "`hcm describe <Model>`\uFF08\u5B57\u6BB5\u4E0E action \u53C2\u6570\uFF1B\u679A\u4E3E\u52A0 -v\uFF1B\u4E0D\u542B permission \u4E0E\u89C6\u56FE\u5B9A\u4E49\uFF09",
|
|
8460
|
+
"GET /api/models/{model}/actions": "`hcm describe <Model> --state <\u89C6\u56FE>`\uFF08actions \u6BB5\uFF09",
|
|
8461
|
+
"GET /api/models/{model}/mutation-capability": "`hcm describe <Model>`\uFF08\u901A\u7528\u589E\u5220\u6539\u6BB5\uFF09",
|
|
8462
|
+
"GET /api/models/{model}/preset-origin": "`hcm preset-origin <Model>`",
|
|
8463
|
+
"GET /api/version/backend": "`hcm version`",
|
|
8464
|
+
"GET /api/chiron.json": "`hcm skills list`",
|
|
8465
|
+
"GET /api/chiron/skills/{id}.md": "`hcm skills show <id>`",
|
|
8466
|
+
"GET /api/system/health/report": "`hcm chiron doctor`",
|
|
8467
|
+
"POST /api/system/health/report": "`hcm chiron doctor --active`",
|
|
8468
|
+
"GET /api/system/health/checks": "`hcm chiron doctor --list`",
|
|
8469
|
+
"POST /api/script/manifest/validate": "`hcm script manifest-validate`"
|
|
8470
|
+
};
|
|
8471
|
+
var CLI_NOT_PROVIDED = "CLI \u672A\u63D0\u4F9B";
|
|
8472
|
+
function cliCommandForCapability(method3, path49) {
|
|
8473
|
+
if (!method3 || !path49) return null;
|
|
8474
|
+
return CAPABILITY_CLI[`${method3} ${path49}`] ?? null;
|
|
8475
|
+
}
|
|
8476
|
+
|
|
8477
|
+
// src/commands/describe.ts
|
|
8354
8478
|
async function describeCommand(model, args) {
|
|
8355
8479
|
try {
|
|
8356
8480
|
const client4 = HcmClient11.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
8357
|
-
const desc = await client4.describe(model, {
|
|
8481
|
+
const desc = await client4.describe(model, {
|
|
8482
|
+
verbose: !!args.verbose,
|
|
8483
|
+
...args.state !== void 0 ? { state: args.state } : {},
|
|
8484
|
+
withMutationCapability: true
|
|
8485
|
+
});
|
|
8358
8486
|
const fmt = args.output ?? "table";
|
|
8359
8487
|
if (fmt !== "table") {
|
|
8360
8488
|
process.stdout.write(formatObject10(desc, { format: fmt }) + "\n");
|
|
@@ -8376,8 +8504,8 @@ function formatEnumValues(enums) {
|
|
|
8376
8504
|
if (!enums?.length) return "";
|
|
8377
8505
|
const items = enums.map((e) => {
|
|
8378
8506
|
const raw = e.value ?? e.key;
|
|
8379
|
-
const
|
|
8380
|
-
return e.label && e.label !==
|
|
8507
|
+
const shown2 = raw === void 0 || raw === null ? "?" : String(raw);
|
|
8508
|
+
return e.label && e.label !== shown2 ? `${shown2}=${e.label}` : shown2;
|
|
8381
8509
|
});
|
|
8382
8510
|
return `[${items.join("|")}]`;
|
|
8383
8511
|
}
|
|
@@ -8417,14 +8545,14 @@ function formatDescriptionTable(desc, verbose = false) {
|
|
|
8417
8545
|
' \u2139\uFE0F (match) = \u53EF\u7528\u8BED\u4E49\u5339\u914D\uFF1Afilter \u5199 {"field":"<\u5B57\u6BB5>","op":"match","value":"<\u7B80\u79F0\u6216\u53E3\u8BED>"}\uFF0C\u670D\u52A1\u7AEF\u6309\u8BED\u4E49\u7EB3\u5165\u771F\u5B9E\u53D6\u503C\u518D\u6539\u5199\u6210 in\uFF1B\u7EB3\u5165\u4E86\u54EA\u4E9B\u503C\u3001\u662F\u5426\u964D\u7EA7\u4E3A\u5B57\u9762\u5305\u542B\uFF0C\u89C1 hcm query \u6253\u5230 stderr \u7684\u63D0\u793A'
|
|
8418
8546
|
);
|
|
8419
8547
|
}
|
|
8420
|
-
lines.push(`actions (${desc.actions.length}):`);
|
|
8548
|
+
lines.push(`actions (${desc.actions.length}${actionsScopeNote(desc)}):`);
|
|
8421
8549
|
for (const a of desc.actions) {
|
|
8422
8550
|
const call = [a.scope, a.httpMethod].filter(Boolean).join(" ");
|
|
8423
8551
|
const params = a.params?.length ? ` params: ${a.params.map((p) => `${p.name}:${p.type}`).join(", ")}` : "";
|
|
8424
8552
|
const description = verbose && a.description ? ` ${a.description}` : "";
|
|
8425
8553
|
const source = a.source && a.source.toLowerCase() !== "java" ? ` [${a.source.toLowerCase()}]` : "";
|
|
8426
8554
|
lines.push(
|
|
8427
|
-
` ${a.name.padEnd(20)} ${call.padEnd(12)} ${a.label ?? ""}${source}${params}${description}`
|
|
8555
|
+
` ${a.name.padEnd(20)} ${call.padEnd(12)} ${a.label ?? ""}${source} ${actionTags(desc, a, verbose)}${params}${description}`
|
|
8428
8556
|
);
|
|
8429
8557
|
}
|
|
8430
8558
|
if (!desc.effectiveActionsAvailable) {
|
|
@@ -8432,6 +8560,7 @@ function formatDescriptionTable(desc, verbose = false) {
|
|
|
8432
8560
|
` \u26A0\uFE0F \u4EE5\u4E0A\u53EA\u542B\u6CE8\u89E3 action\uFF0CYAML \u58F0\u660E\u7684\u811A\u672C Action \u672A\u7EB3\u5165\uFF1A${desc.effectiveActionsNote ?? "\u539F\u56E0\u672A\u77E5"}`
|
|
8433
8561
|
);
|
|
8434
8562
|
}
|
|
8563
|
+
if (desc.actions.length) lines.push(...actionLegend(desc));
|
|
8435
8564
|
if (desc.relations.length) {
|
|
8436
8565
|
lines.push(`relations: ${desc.relations.map((r) => {
|
|
8437
8566
|
const target = r.target ? ` \u2192 ${r.target}` : "";
|
|
@@ -8441,8 +8570,123 @@ function formatDescriptionTable(desc, verbose = false) {
|
|
|
8441
8570
|
return `${r.key}(via ${r.via}${target}${card}${filter}${declared})`;
|
|
8442
8571
|
}).join(", ")}`);
|
|
8443
8572
|
}
|
|
8573
|
+
if (desc.mutationCapability) lines.push(...formatMutationCapability(desc.model, desc.mutationCapability));
|
|
8444
8574
|
return lines.join("\n");
|
|
8445
8575
|
}
|
|
8576
|
+
function actionsScopeNote(desc) {
|
|
8577
|
+
if (!desc.effectiveActionsAvailable) return "";
|
|
8578
|
+
const state = desc.actionsState === void 0 ? `state=${NOT_PROVIDED}` : desc.actionsState === "" ? "state=\u9ED8\u8BA4\u89C6\u56FE" : `state=${desc.actionsState}`;
|
|
8579
|
+
const coverage = desc.actionsCoverage ?? `coverage=${NOT_PROVIDED}`;
|
|
8580
|
+
return `\uFF0C${state}\uFF0C${coverage}`;
|
|
8581
|
+
}
|
|
8582
|
+
function shown(v, notProvided) {
|
|
8583
|
+
if (notProvided || v === void 0) return NOT_PROVIDED;
|
|
8584
|
+
return typeof v === "string" ? v : JSON.stringify(v);
|
|
8585
|
+
}
|
|
8586
|
+
function grantCell(desc, a) {
|
|
8587
|
+
if (!desc.effectiveActionsAvailable) return "\u672A\u53D6\u5230";
|
|
8588
|
+
if (a.effectiveRow === "not-listed") return "\u4E0D\u5728\u6709\u6548\u96C6";
|
|
8589
|
+
return shown(a.grantForCaller, !!a.notProvided?.includes("grantForCaller"));
|
|
8590
|
+
}
|
|
8591
|
+
function actionTags(desc, a, verbose) {
|
|
8592
|
+
const tags = [
|
|
8593
|
+
`effect=${shown(a.effect, !!a.notProvided?.includes("effect"))}`,
|
|
8594
|
+
`grant=${grantCell(desc, a)}`
|
|
8595
|
+
];
|
|
8596
|
+
if (verbose) {
|
|
8597
|
+
tags.push(
|
|
8598
|
+
`ext=${shown(a.hasExternalDep, false)}`,
|
|
8599
|
+
`sens=${shown(a.sensitiveData, false)}`,
|
|
8600
|
+
`confirm=${shown(a.requiresConfirmation ?? a.confirm, false)}`
|
|
8601
|
+
);
|
|
8602
|
+
if (desc.effectiveActionsAvailable && a.effectiveRow === "listed") tags.push(`conflict=${shown(a.conflict, false)}`);
|
|
8603
|
+
}
|
|
8604
|
+
return tags.join(" ");
|
|
8605
|
+
}
|
|
8606
|
+
var EFFECT_MEANING = {
|
|
8607
|
+
READ_ONLY: "\u5224\u8FC7\u3001\u4E0D\u5199\u5E93",
|
|
8608
|
+
WRITES: "\u5224\u8FC7\u3001\u4F1A\u5199\u5E93",
|
|
8609
|
+
ACCOUNTING_ONLY: "\u4E0D\u5199\u4E1A\u52A1\u6570\u636E\uFF0C\u53EA\u4EA7\u751F\u767B\u8BB0\u5728\u518C\u7684\u8BB0\u8D26\u7C7B\u526F\u4F5C\u7528\uFF08\u9700\u786E\u8BA4\uFF09",
|
|
8610
|
+
UNKNOWN: "\u6CA1\u4EBA\u5224\u8FC7\u2014\u2014\u4E0D\u662F\u300C\u5B89\u5168\u300D\uFF0C\u6309\u4F1A\u5199\u5BF9\u5F85"
|
|
8611
|
+
};
|
|
8612
|
+
var GRANT_MEANING = {
|
|
8613
|
+
GRANTED: "\u5F53\u524D\u8EAB\u4EFD\u6709\u8D44\u683C\u53D1\u8D77",
|
|
8614
|
+
NOT_GRANTED: "\u5F53\u524D\u8EAB\u4EFD\u6CA1\u88AB\u6388\u4E88",
|
|
8615
|
+
NOT_CONSTRAINED: "\u6A21\u578B\u6CA1\u6709 permission \u5757\uFF0C\u6388\u6743\u5C42\u4E0D\u6784\u6210\u7EA6\u675F\u2014\u2014\u4E0D\u7B49\u4E8E\u300C\u53EF\u8C03\u300D\uFF0C\u4E0D\u80FD\u5F53 GRANTED \u7528",
|
|
8616
|
+
NOT_RESOLVED: "\u670D\u52A1\u7AEF\u8FD9\u6B21\u6CA1\u5224\u51FA\u6765\uFF08\u6CA1\u8BFB\u51FA meta\uFF09\u2014\u2014\u4E0D\u662F\u300C\u6CA1\u6743\u9650\u300D\uFF0C\u4E5F\u4E0D\u662F\u300C\u6709\u6743\u300D",
|
|
8617
|
+
\u672A\u53D6\u5230: "\u8FD9\u6B21\u6CA1\u8BFB\u5230 /actions\uFF0C\u6388\u6743\u6863\u4F4D\u65E0\u4ECE\u8BF4\u8D77",
|
|
8618
|
+
\u4E0D\u5728\u6709\u6548\u96C6: "\u672C\u89C6\u56FE\u4E0B /actions \u6CA1\u5217\u8FD9\u4E00\u884C\uFF08\u6362 --state \u518D\u770B\uFF09",
|
|
8619
|
+
[NOT_PROVIDED]: "\u670D\u52A1\u7AEF\u65E9\u4E8E\u8BE5\u5B57\u6BB5\uFF0C\u6CA1\u8BF4\u2014\u2014\u4E0D\u8BB8\u6309\u4EFB\u4F55\u4E00\u6863\u8BFB"
|
|
8620
|
+
};
|
|
8621
|
+
function actionLegend(desc) {
|
|
8622
|
+
const effects = /* @__PURE__ */ new Set();
|
|
8623
|
+
const grants = /* @__PURE__ */ new Set();
|
|
8624
|
+
for (const a of desc.actions) {
|
|
8625
|
+
effects.add(shown(a.effect, !!a.notProvided?.includes("effect")));
|
|
8626
|
+
grants.add(grantCell(desc, a));
|
|
8627
|
+
}
|
|
8628
|
+
const describeSet = (set, meaning) => [...set].map((v) => `${v} ${meaning[v] ?? (v === NOT_PROVIDED ? "\u670D\u52A1\u7AEF\u65E9\u4E8E\u8BE5\u5B57\u6BB5" : "\uFF08\u8FD9\u7248 CLI \u4E0D\u8BA4\u8BC6\u8FD9\u4E00\u6863\uFF0C\u7167\u670D\u52A1\u7AEF\u539F\u6587\u5224\uFF09")}`).join(" \xB7 ");
|
|
8629
|
+
const lines = [
|
|
8630
|
+
` \u2139\uFE0F effect\uFF1A${describeSet(effects, { ...EFFECT_MEANING, [NOT_PROVIDED]: "\u670D\u52A1\u7AEF\u65E9\u4E8E effect \u58F0\u660E\uFF0C\u6CA1\u8BF4" })}`,
|
|
8631
|
+
" \u2139\uFE0F grant = \u5F53\u524D\u8EAB\u4EFD\u80FD\u4E0D\u80FD\u53D1\u8D77\u8FD9\u4E2A action\uFF0C\u53EA\u5224\u5230\u6388\u6743\u5C42\uFF08grant\uFF09\uFF0C\u4E0D\u542B\u884C\u7EA7\u8303\u56F4\uFF1AGRANTED \u4E5F\u4E0D\u4EE3\u8868\u5BF9\u4EFB\u610F\u4E00\u884C\u90FD\u80FD\u8C03\uFF0C\u884C\u7EA7\u8303\u56F4\u5728\u6267\u884C\u65F6\u5224",
|
|
8632
|
+
` ${describeSet(grants, GRANT_MEANING)}`
|
|
8633
|
+
];
|
|
8634
|
+
if (desc.effectiveActionsAvailable) {
|
|
8635
|
+
const view = desc.actionsState === void 0 ? `state=${NOT_PROVIDED} \u7684\u89C6\u56FE` : desc.actionsState ? `state=${desc.actionsState}` : "\u9ED8\u8BA4\u89C6\u56FE";
|
|
8636
|
+
lines.push(` \u2139\uFE0F \u8FD9\u4EFD\u52A8\u4F5C\u96C6\u53EA\u5BF9 ${view} \u6210\u7ACB\uFF08state-scoped\uFF09\uFF0C\u522B\u7684\u89C6\u56FE\u6362 \`--state <\u89C6\u56FE>\` \u518D\u770B\uFF1B\u5916\u90E8\u4F9D\u8D56 / \u654F\u611F\u6570\u636E / \u786E\u8BA4\u8981\u6C42\u52A0 -v \u770B`);
|
|
8637
|
+
}
|
|
8638
|
+
return lines;
|
|
8639
|
+
}
|
|
8640
|
+
function formatMutationCapability(model, mc) {
|
|
8641
|
+
if (!mc.available) {
|
|
8642
|
+
return mc.notProvided ? [`\u901A\u7528\u589E\u5220\u6539\uFF1A${NOT_PROVIDED}\uFF08${mc.note}\uFF09`] : [`\u901A\u7528\u589E\u5220\u6539\uFF1A\u8BFB\u4E0D\u5230\uFF08${mc.note}\uFF09\u2014\u2014\u4E0D\u7B49\u4E8E\u300C\u4E0D\u80FD\u6539\u300D\uFF0C\u4E5F\u4E0D\u7B49\u4E8E\u300C\u80FD\u6539\u300D`];
|
|
8643
|
+
}
|
|
8644
|
+
const lines = ["\u901A\u7528\u589E\u5220\u6539\uFF08hcm create / update / delete \u80FD\u4E0D\u80FD\u76F4\u63A5\u7528\uFF1B\u53EA\u5224\u7ED3\u6784\u4E0E\u6CE8\u89E3\uFF0C\u4E0D\u5224 RBAC\u3001\u4E0D\u5224\u8FD0\u884C\u671F\u95F8\uFF09\uFF1A"];
|
|
8645
|
+
const rbac = /* @__PURE__ */ new Map();
|
|
8646
|
+
const gates = /* @__PURE__ */ new Map();
|
|
8647
|
+
const gateNotProvided = [];
|
|
8648
|
+
const scopes = /* @__PURE__ */ new Set();
|
|
8649
|
+
for (const op of MUTATION_CAPABILITY_OPS) {
|
|
8650
|
+
const key2 = op in mc.ops ? op : op === "batchDelete" && "batch_delete" in mc.ops ? "batch_delete" : void 0;
|
|
8651
|
+
if (!key2) {
|
|
8652
|
+
lines.push(` ${op.padEnd(12)} ${NOT_PROVIDED}`);
|
|
8653
|
+
continue;
|
|
8654
|
+
}
|
|
8655
|
+
const cell2 = mc.ops[key2] ?? {};
|
|
8656
|
+
const missing2 = missingKeys(cell2, MUTATION_CELL_KEYS);
|
|
8657
|
+
const allowed = "allowed" in cell2 ? String(cell2.allowed) : NOT_PROVIDED;
|
|
8658
|
+
let line = ` ${op.padEnd(12)} allowed=${allowed}${key2 !== op ? `\uFF08\u670D\u52A1\u7AEF\u952E\u540D ${key2}\uFF0C\u65E7\u5199\u6CD5\uFF09` : ""}`;
|
|
8659
|
+
if (cell2.allowed !== true && cell2.reason) line += ` \u539F\u56E0\uFF1A${cell2.reason}`;
|
|
8660
|
+
if (missing2.length && missing2.some((k) => k !== "allowed")) line += ` \uFF08\u7F3A ${missing2.filter((k) => k !== "allowed").join("\u3001")}\uFF1A${NOT_PROVIDED}\uFF09`;
|
|
8661
|
+
lines.push(line);
|
|
8662
|
+
const alts = Array.isArray(cell2.alternatives) ? cell2.alternatives : [];
|
|
8663
|
+
if (alts.length) {
|
|
8664
|
+
lines.push(` \u66FF\u4EE3\u5165\u53E3 ${alts.length} \u6761\uFF1A`);
|
|
8665
|
+
for (const alt of alts) {
|
|
8666
|
+
const cmd = howToCommand(alt.howTo);
|
|
8667
|
+
const how = cmd ?? (alt.howTo ? `\u670D\u52A1\u7AEF\u539F\u6587 ${alt.howTo}` : `\u8C03\u7528\u5F62\u6001 ${NOT_PROVIDED}`);
|
|
8668
|
+
const other = alt.model && alt.model !== model ? `\uFF08\u5728 ${alt.model} \u4E0A\uFF09` : "";
|
|
8669
|
+
lines.push(` \xB7 ${how}${other}${alt.when ? ` ${alt.when}` : ""}`);
|
|
8670
|
+
}
|
|
8671
|
+
} else if (cell2.allowed === false && "alternatives" in cell2) {
|
|
8672
|
+
lines.push(" \u66FF\u4EE3\u5165\u53E3\uFF1A\u670D\u52A1\u7AEF\u6CA1\u767B\u8BB0\uFF08\u7A7A\u5217\u8868\uFF09\u2014\u2014\u522B\u731C\u4E00\u4E2A action \u53BB\u8BD5\uFF0C\u5148\u95EE\u4EBA");
|
|
8673
|
+
}
|
|
8674
|
+
if (typeof cell2.scope === "string") scopes.add(cell2.scope);
|
|
8675
|
+
if (typeof cell2.rbacSource === "string") rbac.set(cell2.rbacSource, [...rbac.get(cell2.rbacSource) ?? [], op]);
|
|
8676
|
+
if (typeof cell2.runtimeGateSource === "string") {
|
|
8677
|
+
gates.set(cell2.runtimeGateSource, [...gates.get(cell2.runtimeGateSource) ?? [], op]);
|
|
8678
|
+
} else if (cell2.allowed === true) {
|
|
8679
|
+
gateNotProvided.push(op);
|
|
8680
|
+
}
|
|
8681
|
+
}
|
|
8682
|
+
if (scopes.size) lines.push(` scope=${[...scopes].join(",")}\uFF08\u7ED3\u6784\u9762\uFF1Aallowed=true \u53EA\u4EE3\u8868\u7ED3\u6784\u4E0E\u6CE8\u89E3\u5141\u8BB8\uFF09`);
|
|
8683
|
+
for (const [text2, ops] of rbac) lines.push(` RBAC\uFF08${ops.join(" / ")}\uFF09\uFF1A${text2}`);
|
|
8684
|
+
for (const [text2, ops] of gates) lines.push(` \u8FD0\u884C\u671F\u95F8\uFF08${ops.join(" / ")}\uFF09\uFF1A${text2}`);
|
|
8685
|
+
if (gateNotProvided.length) {
|
|
8686
|
+
lines.push(` \u8FD0\u884C\u671F\u95F8\uFF08${gateNotProvided.join(" / ")}\uFF09\uFF1A${NOT_PROVIDED}\uFF08\u670D\u52A1\u7AEF\u6CA1\u8BF4\u6709\u6CA1\u6709\u8FD0\u884C\u671F\u95F8\u2014\u2014allowed=true \u4E0D\u4EE3\u8868\u771F\u53D1\u8BF7\u6C42\u4E0D\u4F1A\u88AB\u62D2\uFF09`);
|
|
8687
|
+
}
|
|
8688
|
+
return markRestLeftovers(lines);
|
|
8689
|
+
}
|
|
8446
8690
|
|
|
8447
8691
|
// src/commands/chat.ts
|
|
8448
8692
|
import {
|
|
@@ -9098,6 +9342,7 @@ async function chatCommand(prompt, args) {
|
|
|
9098
9342
|
elapsedMs: r.elapsedMs,
|
|
9099
9343
|
stopReason: r.stopReason,
|
|
9100
9344
|
tokens: r.tokens,
|
|
9345
|
+
notices: r.notices,
|
|
9101
9346
|
events: r.events
|
|
9102
9347
|
},
|
|
9103
9348
|
{ format: "json" }
|
|
@@ -9114,6 +9359,8 @@ async function chatCommand(prompt, args) {
|
|
|
9114
9359
|
);
|
|
9115
9360
|
}
|
|
9116
9361
|
}
|
|
9362
|
+
for (const n2 of r.notices) process.stderr.write(chalk2.gray(`${n2.text || `[${n2.notice}]`}
|
|
9363
|
+
`));
|
|
9117
9364
|
process.stdout.write(r.content + "\n");
|
|
9118
9365
|
process.stdout.write(
|
|
9119
9366
|
chalk2.dim(
|
|
@@ -10381,7 +10628,7 @@ function createLaneApi(http2) {
|
|
|
10381
10628
|
},
|
|
10382
10629
|
async presetOrigin(model) {
|
|
10383
10630
|
try {
|
|
10384
|
-
const resp = await http2.get(`/api/models/${model}/preset-origin
|
|
10631
|
+
const resp = await http2.get(`/api/models/${model}/preset-origin`, { params: { includeTenantIds: true } });
|
|
10385
10632
|
return resp.data;
|
|
10386
10633
|
} catch (e) {
|
|
10387
10634
|
if (e.response?.status === 404) return void 0;
|
|
@@ -10531,6 +10778,51 @@ function resolveLanes(metas, metaUnavailable = []) {
|
|
|
10531
10778
|
configModels.sort((a, b) => order(a) - order(b) || a.localeCompare(b));
|
|
10532
10779
|
return { laneSource, configModels, envLocalModels, skipped: skipped2 };
|
|
10533
10780
|
}
|
|
10781
|
+
var idOf = (r) => typeof r.id === "string" ? r.id.toLowerCase() : void 0;
|
|
10782
|
+
var idList = (v) => Array.isArray(v) && v.every((x) => typeof x === "string") ? v.map((x) => x.toLowerCase()) : void 0;
|
|
10783
|
+
var OLD_CORE_HINT = "\u6E90\u73AF\u5883 Core \u4E0D\u56DE\u884C\u7EA7 id\uFF08\u65E9\u4E8E HCMNX-806 \u7684 preset-origin?includeTenantIds\uFF09\uFF0C\u53EA\u80FD\u6309 createById \u731C\uFF1B\u6E90\u73AF\u5883\u5347\u7EA7 Core \u540E\u91CD\u65B0\u5BFC\u51FA\u5373\u53EF\u9010\u884C\u5206\u4FA7";
|
|
10784
|
+
function splitByServerIds(rows2, origin, baseline, original, override) {
|
|
10785
|
+
if (origin.tenantIds === void 0) return void 0;
|
|
10786
|
+
const ovr = idList(origin.tenantIds?.TENANT_OVERRIDE), orig = idList(origin.tenantIds?.TENANT_ORIGINAL);
|
|
10787
|
+
if (!ovr || !orig) {
|
|
10788
|
+
return {
|
|
10789
|
+
tenantRows: [],
|
|
10790
|
+
systemRows: 0,
|
|
10791
|
+
tenantOriginal: original,
|
|
10792
|
+
tenantOverride: override,
|
|
10793
|
+
classification: "COUNTS_MISMATCH",
|
|
10794
|
+
detail: "preset-origin \u56DE\u4E86 tenantIds \u4F46\u5F62\u72B6\u4E0D\u8BA4\u8BC6\uFF08\u5E94\u4E3A TENANT_OVERRIDE / TENANT_ORIGINAL \u4E24\u4E2A id \u5B57\u7B26\u4E32\u6570\u7EC4\uFF09\uFF0C\u4E0D\u6562\u5206\u4FA7"
|
|
10795
|
+
};
|
|
10796
|
+
}
|
|
10797
|
+
if (ovr.length !== override || orig.length !== original) {
|
|
10798
|
+
return {
|
|
10799
|
+
tenantRows: [],
|
|
10800
|
+
systemRows: 0,
|
|
10801
|
+
tenantOriginal: original,
|
|
10802
|
+
tenantOverride: override,
|
|
10803
|
+
classification: "COUNTS_MISMATCH",
|
|
10804
|
+
detail: `\u670D\u52A1\u7AEF id \u6E05\u5355\u4E0E\u8BA1\u6570\u5BF9\u4E0D\u4E0A\uFF1A\u8986\u76D6 id ${ovr.length} / \u8BA1\u6570 ${override}\uFF0C\u539F\u521B id ${orig.length} / \u8BA1\u6570 ${original}`
|
|
10805
|
+
};
|
|
10806
|
+
}
|
|
10807
|
+
const unique = /* @__PURE__ */ new Map();
|
|
10808
|
+
let noId = 0;
|
|
10809
|
+
for (const r of rows2) {
|
|
10810
|
+
const id = idOf(r);
|
|
10811
|
+
if (id === void 0) noId++;
|
|
10812
|
+
else if (!unique.has(id)) unique.set(id, r);
|
|
10813
|
+
}
|
|
10814
|
+
const tenantIds = /* @__PURE__ */ new Set([...ovr, ...orig]), overrideSet = new Set(ovr);
|
|
10815
|
+
const tenantRows = [...unique.entries()].filter(([id]) => tenantIds.has(id)).map(([, r]) => r);
|
|
10816
|
+
const missing2 = [...tenantIds].filter((id) => !unique.has(id));
|
|
10817
|
+
const listedOverride = tenantRows.filter((r) => overrideSet.has(idOf(r))).length;
|
|
10818
|
+
const systemRows = unique.size - tenantRows.length + noId, expectSystem = baseline - override;
|
|
10819
|
+
const split2 = { tenantRows, systemRows, tenantOriginal: tenantRows.length - listedOverride, tenantOverride: listedOverride };
|
|
10820
|
+
const gaps = [];
|
|
10821
|
+
if (missing2.length) gaps.push(`\u670D\u52A1\u7AEF\u5224\u4E3A\u79DF\u6237\u81EA\u6709 ${tenantIds.size} \u884C\uFF0C\u5217\u8868\u53EA\u8BFB\u5230 ${tenantRows.length} \u884C\uFF0C\u7F3A ${missing2.length} \u884C\u672A\u5BFC\u51FA\uFF08\u4F8B\uFF1A${missing2.slice(0, 5).join("\u3001")}\uFF1B\u9010\u884C\u67E5 GET /api/models/{\u6A21\u578B}/preset-origin?id=<id>\uFF0C\u518D\u67E5\u5217\u8868\u4E3A\u4EC0\u4E48\u8BFB\u4E0D\u5230\uFF1A\u6743\u9650 / \u5185\u7F6E\u8FC7\u6EE4\uFF09`);
|
|
10822
|
+
if (systemRows !== expectSystem) gaps.push(`\u5217\u8868\u91CC\u4E0D\u5728\u79DF\u6237\u6E05\u5355\u4E0A\u7684 ${systemRows} \u884C\u4E0E\u7CFB\u7EDF\u4FA7\u8BA1\u6570 ${expectSystem}\uFF08\u57FA\u7EBF ${baseline} \u2212 \u8986\u76D6 ${override}\uFF09\u5BF9\u4E0D\u4E0A${noId ? `\uFF08\u5176\u4E2D ${noId} \u884C\u6CA1\u6709 id\uFF09` : ""}\uFF0C\u591A\u51FA\u6765\u7684\u53EF\u80FD\u662F\u5BFC\u51FA\u671F\u95F4\u65B0\u5EFA\u7684\u79DF\u6237\u884C\uFF0C\u672A\u5BFC\u51FA\uFF1B\u91CD\u65B0\u5BFC\u51FA\u4E00\u6B21\u518D\u770B`);
|
|
10823
|
+
if (!gaps.length) return { ...split2, classification: "SERVER_IDS" };
|
|
10824
|
+
return { ...split2, classification: "SERVER_IDS_UNRECONCILED", detail: gaps.join("\uFF1B") };
|
|
10825
|
+
}
|
|
10534
10826
|
var isTenantByHeuristic = (r) => r.customized === true || typeof r.createById === "string" && r.createById !== SYSTEM_USER_ID;
|
|
10535
10827
|
function splitPresetRows(rows2, origin, isPresetByMeta) {
|
|
10536
10828
|
if (origin && !origin.presetModel) {
|
|
@@ -10563,10 +10855,19 @@ function splitPresetRows(rows2, origin, isPresetByMeta) {
|
|
|
10563
10855
|
}
|
|
10564
10856
|
const baseline = c2.SYSTEM_BASELINE, override = c2.TENANT_OVERRIDE, original = c2.TENANT_ORIGINAL;
|
|
10565
10857
|
if (original + override === 0) return { tenantRows: [], systemRows: rows2.length, tenantOriginal: 0, tenantOverride: 0, classification: "ALL_SYSTEM" };
|
|
10858
|
+
const byIds = splitByServerIds(rows2, origin, baseline, original, override);
|
|
10859
|
+
if (byIds) return byIds;
|
|
10566
10860
|
if (baseline === 0) return { tenantRows: rows2, systemRows: 0, tenantOriginal: original, tenantOverride: override, classification: "ALL_TENANT" };
|
|
10567
10861
|
const expectTenant = original + override, expectSystem = baseline - override;
|
|
10568
10862
|
if (tenant2.length === expectTenant && rows2.length - tenant2.length === expectSystem && overrides === override) {
|
|
10569
|
-
return {
|
|
10863
|
+
return {
|
|
10864
|
+
tenantRows: tenant2,
|
|
10865
|
+
systemRows: expectSystem,
|
|
10866
|
+
tenantOriginal: original,
|
|
10867
|
+
tenantOverride: override,
|
|
10868
|
+
classification: "CREATE_BY_VERIFIED_BY_COUNTS",
|
|
10869
|
+
detail: `\u53EA\u662F\u6761\u6570\u5BF9\u4E0A\uFF1A\u731C\u53CD\u7684\u884C\u6070\u597D\u62B5\u6D88\u65F6\u4E5F\u5BF9\u5F97\u4E0A\uFF0C\u53EF\u80FD\u5BFC\u51FA\u7CFB\u7EDF\u884C\u3001\u6F0F\u6389\u79DF\u6237\u884C\uFF1B${OLD_CORE_HINT}`
|
|
10870
|
+
};
|
|
10570
10871
|
}
|
|
10571
10872
|
return {
|
|
10572
10873
|
tenantRows: [],
|
|
@@ -10574,9 +10875,96 @@ function splitPresetRows(rows2, origin, isPresetByMeta) {
|
|
|
10574
10875
|
tenantOriginal: original,
|
|
10575
10876
|
tenantOverride: override,
|
|
10576
10877
|
classification: "COUNTS_MISMATCH",
|
|
10577
|
-
detail: `\u884C\u7EA7\u5224\u51FA\u79DF\u6237 ${tenant2.length}\uFF08\u8986\u76D6 ${overrides}\uFF09/ \u7CFB\u7EDF ${rows2.length - tenant2.length}\uFF1B\u670D\u52A1\u7AEF\u8BA1\u6570\u671F\u671B\u79DF\u6237 ${expectTenant}\uFF08\u8986\u76D6 ${override}\uFF09/ \u7CFB\u7EDF ${expectSystem}`
|
|
10878
|
+
detail: `\u884C\u7EA7\u5224\u51FA\u79DF\u6237 ${tenant2.length}\uFF08\u8986\u76D6 ${overrides}\uFF09/ \u7CFB\u7EDF ${rows2.length - tenant2.length}\uFF1B\u670D\u52A1\u7AEF\u8BA1\u6570\u671F\u671B\u79DF\u6237 ${expectTenant}\uFF08\u8986\u76D6 ${override}\uFF09/ \u7CFB\u7EDF ${expectSystem}\uFF1B${OLD_CORE_HINT}`
|
|
10578
10879
|
};
|
|
10579
10880
|
}
|
|
10881
|
+
var newLookupState = () => ({ failed: /* @__PURE__ */ new Map(), noKeys: /* @__PURE__ */ new Set(), emptyKey: /* @__PURE__ */ new Map() });
|
|
10882
|
+
var addTo = (m, k, v) => {
|
|
10883
|
+
if (!m.has(k)) m.set(k, /* @__PURE__ */ new Set());
|
|
10884
|
+
m.get(k).add(v);
|
|
10885
|
+
};
|
|
10886
|
+
var EMBEDDED_REF_ALIASES = {
|
|
10887
|
+
org: "OrgUnit",
|
|
10888
|
+
orgUnit: "OrgUnit",
|
|
10889
|
+
dept: "OrgUnit",
|
|
10890
|
+
department: "OrgUnit",
|
|
10891
|
+
unit: "OrgUnit",
|
|
10892
|
+
emp: "Employee",
|
|
10893
|
+
employee: "Employee",
|
|
10894
|
+
person: "Employee",
|
|
10895
|
+
indicator: "AnalyticsIndicator",
|
|
10896
|
+
scheme: "AnalyticsTargetScheme",
|
|
10897
|
+
targetScheme: "AnalyticsTargetScheme",
|
|
10898
|
+
dashboard: "DashboardDefinition",
|
|
10899
|
+
board: "DashboardDefinition",
|
|
10900
|
+
template: "DashboardTemplate"
|
|
10901
|
+
};
|
|
10902
|
+
var EMBEDDED_REF_PROBE_MODELS = ["OrgUnit", "Employee", "Position"];
|
|
10903
|
+
var PLACEHOLDER_VALUE_RE = /^[A-Za-z0-9._-]+$/;
|
|
10904
|
+
var PLACEHOLDER_FIELD_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
10905
|
+
function placeholderSafeKey(key2) {
|
|
10906
|
+
if (PLACEHOLDER_VALUE_RE.test(key2)) return true;
|
|
10907
|
+
const pairs = key2.split(",");
|
|
10908
|
+
return pairs.length > 1 && pairs.every((p) => {
|
|
10909
|
+
const eq = p.indexOf("=");
|
|
10910
|
+
return eq > 0 && PLACEHOLDER_FIELD_RE.test(p.slice(0, eq)) && PLACEHOLDER_VALUE_RE.test(p.slice(eq + 1));
|
|
10911
|
+
});
|
|
10912
|
+
}
|
|
10913
|
+
function embeddedHintModels(hintKey, pathModel, modelNames) {
|
|
10914
|
+
const out = [];
|
|
10915
|
+
const add = (m) => {
|
|
10916
|
+
if (!m) return;
|
|
10917
|
+
const name = modelNames.has(m) ? m : modelNames.has(`${m}Model`) ? `${m}Model` : void 0;
|
|
10918
|
+
if (name && !out.includes(name)) out.push(name);
|
|
10919
|
+
};
|
|
10920
|
+
add(pathModel);
|
|
10921
|
+
const base = hintKey ? /^([A-Za-z][A-Za-z0-9]*?)(?:_?[iI]ds?)$/.exec(hintKey)?.[1] : void 0;
|
|
10922
|
+
if (base) {
|
|
10923
|
+
add(EMBEDDED_REF_ALIASES[base]);
|
|
10924
|
+
add(base.charAt(0).toUpperCase() + base.slice(1));
|
|
10925
|
+
}
|
|
10926
|
+
return out;
|
|
10927
|
+
}
|
|
10928
|
+
var NEAR_KEY_RE = /["']?([A-Za-z_][A-Za-z0-9_]*)["']?\s*[:=]\s*(?:\[\s*(?:["'][^"'\]]*["']\s*,\s*)*)?["']?$/;
|
|
10929
|
+
var PATH_MODEL_RE = /\/page\/([A-Z][A-Za-z0-9_]*)\/$/;
|
|
10930
|
+
function embeddedUuids(value, p) {
|
|
10931
|
+
const segs = p.split(/[.[\]~]/).filter(Boolean);
|
|
10932
|
+
const lastKey = segs.pop() ?? p;
|
|
10933
|
+
const ownerKey = /^\d+$/.test(lastKey) ? [...segs].reverse().find((s) => !/^\d+$/.test(s)) ?? lastKey : lastKey;
|
|
10934
|
+
const out = [];
|
|
10935
|
+
for (const m of value.matchAll(UUID_RE)) {
|
|
10936
|
+
const offset = m.index ?? 0;
|
|
10937
|
+
const before = value.slice(Math.max(0, offset - 1e3), offset);
|
|
10938
|
+
out.push({ uuid: m[0], offset, ownerKey, nearKey: NEAR_KEY_RE.exec(before)?.[1] ?? ownerKey, pathModel: PATH_MODEL_RE.exec(before)?.[1] });
|
|
10939
|
+
}
|
|
10940
|
+
return out;
|
|
10941
|
+
}
|
|
10942
|
+
function resolveEmbedded(e, ctx) {
|
|
10943
|
+
const id = e.uuid.toLowerCase();
|
|
10944
|
+
const names = ctx.modelNames ?? new Set(ctx.idKeys.keys());
|
|
10945
|
+
const hinted = embeddedHintModels(e.nearKey, e.pathModel, names).filter((m) => ctx.idKeys.get(m)?.has(id));
|
|
10946
|
+
const holders = hinted.length ? hinted : [...ctx.idKeys].filter(([, map]) => map.has(id)).map(([m]) => m);
|
|
10947
|
+
if (holders.length === 0) {
|
|
10948
|
+
const st = ctx.lookupState;
|
|
10949
|
+
const candidates = [...embeddedHintModels(e.nearKey, e.pathModel, names), ...EMBEDDED_REF_PROBE_MODELS.filter((m) => names.has(m))];
|
|
10950
|
+
const failed2 = candidates.filter((m) => st?.failed.get(m)?.has(id));
|
|
10951
|
+
if (failed2.length) return { reason: "EMBEDDED_LOOKUP_FAILED", target: failed2.join(" | ") };
|
|
10952
|
+
const empty = candidates.filter((m) => st?.emptyKey.get(m)?.has(id));
|
|
10953
|
+
if (empty.length) return { reason: "EMBEDDED_TARGET_KEY_EMPTY", target: empty.join(" | ") };
|
|
10954
|
+
const noKeys = candidates.filter((m) => st?.noKeys.has(m));
|
|
10955
|
+
if (noKeys.length) return { reason: "EMBEDDED_TARGET_NATURAL_KEY_UNKNOWN", target: noKeys.join(" | ") };
|
|
10956
|
+
return { reason: "EMBEDDED_UUID_NOT_FOUND" };
|
|
10957
|
+
}
|
|
10958
|
+
if (holders.length > 1) return { reason: "EMBEDDED_UUID_AMBIGUOUS", target: holders.join(" | ") };
|
|
10959
|
+
const targetModel = holders[0];
|
|
10960
|
+
const key2 = ctx.idKeys.get(targetModel).get(id);
|
|
10961
|
+
const placeholder2 = `\${ref:${targetModel}:${key2}}`;
|
|
10962
|
+
if (new RegExp(UUID_RE.source, "i").test(key2)) return { reason: "EMBEDDED_KEY_HAS_UUID", target: placeholder2 };
|
|
10963
|
+
if (!placeholderSafeKey(key2)) return { reason: "EMBEDDED_KEY_NOT_PLACEHOLDER_SAFE", target: placeholder2 };
|
|
10964
|
+
const blocked = ctx.packageGuard?.(targetModel, id);
|
|
10965
|
+
if (blocked) return { reason: blocked, target: placeholder2 };
|
|
10966
|
+
return { targetModel, placeholder: placeholder2 };
|
|
10967
|
+
}
|
|
10580
10968
|
function refTargetOf(object3) {
|
|
10581
10969
|
return object3.startsWith("CO_") ? { placeholderModel: "CodeItemData", lookupModel: "CodeItemData" } : { placeholderModel: object3, lookupModel: object3 };
|
|
10582
10970
|
}
|
|
@@ -10598,6 +10986,7 @@ function rewriteRow(row, rowKey, ctx) {
|
|
|
10598
10986
|
const item = {};
|
|
10599
10987
|
const unresolved = [];
|
|
10600
10988
|
const envLocal = [];
|
|
10989
|
+
const rewrites = [];
|
|
10601
10990
|
const selfKeys = ctx.idKeys.get(ctx.model);
|
|
10602
10991
|
for (const f of ctx.fields) {
|
|
10603
10992
|
if (!exportableField(f) || !(f.key in row)) continue;
|
|
@@ -10632,35 +11021,69 @@ function rewriteRow(row, rowKey, ctx) {
|
|
|
10632
11021
|
item[f.key] = Array.isArray(value) ? value.map((v, i) => mapOne(v, `${f.key}[${i}]`)) : mapOne(value, f.key);
|
|
10633
11022
|
continue;
|
|
10634
11023
|
}
|
|
10635
|
-
item[f.key] = scanEmbedded(value, f.key, rowKey, ctx, unresolved, envLocal);
|
|
11024
|
+
item[f.key] = scanEmbedded(value, f.key, rowKey, ctx, { unresolved, envLocal, rewrites });
|
|
10636
11025
|
}
|
|
10637
|
-
return { item, unresolved, envLocal };
|
|
11026
|
+
return { item, unresolved, envLocal, rewrites };
|
|
10638
11027
|
}
|
|
10639
|
-
function scanEmbedded(value, p, rowKey, ctx,
|
|
11028
|
+
function scanEmbedded(value, p, rowKey, ctx, sink) {
|
|
10640
11029
|
if (typeof value === "string") {
|
|
10641
|
-
|
|
10642
|
-
|
|
10643
|
-
|
|
10644
|
-
|
|
10645
|
-
|
|
10646
|
-
|
|
10647
|
-
|
|
10648
|
-
|
|
10649
|
-
|
|
10650
|
-
|
|
10651
|
-
|
|
10652
|
-
|
|
10653
|
-
|
|
10654
|
-
|
|
11030
|
+
const found2 = embeddedUuids(value, p);
|
|
11031
|
+
if (!found2.length) return value;
|
|
11032
|
+
let out = "";
|
|
11033
|
+
let at = 0;
|
|
11034
|
+
for (const e of found2) {
|
|
11035
|
+
out += value.slice(at, e.offset);
|
|
11036
|
+
at = e.offset + e.uuid.length;
|
|
11037
|
+
const fieldPath = e.nearKey !== e.ownerKey ? `${p}~${e.nearKey}` : p;
|
|
11038
|
+
const byId = ctx.envLocalIds.get(e.uuid.toLowerCase());
|
|
11039
|
+
if (byId || ENV_LOCAL_KEY_RE.test(e.nearKey)) {
|
|
11040
|
+
const targetModel = byId ?? `UNKNOWN_ENV_LOCAL(by key ${e.nearKey})`;
|
|
11041
|
+
sink.envLocal.push({ model: ctx.model, rowKey, fieldPath, targetModel, note: "\u76EE\u6807\u73AF\u5883\u88C5\u5305\u540E\u9700\u91CD\u65B0\u7ED1\u5B9A" });
|
|
11042
|
+
out += envLocalMarker(byId ?? "UNKNOWN");
|
|
11043
|
+
continue;
|
|
11044
|
+
}
|
|
11045
|
+
const r = resolveEmbedded(e, ctx);
|
|
11046
|
+
if ("placeholder" in r) {
|
|
11047
|
+
sink.rewrites.push({ model: ctx.model, rowKey, fieldPath, uuidPrefix: e.uuid.slice(0, 8), targetModel: r.targetModel, placeholder: r.placeholder });
|
|
11048
|
+
out += r.placeholder;
|
|
11049
|
+
} else {
|
|
11050
|
+
sink.unresolved.push({ model: ctx.model, rowKey, fieldPath, value: e.uuid, reason: r.reason, ...r.target ? { target: r.target } : {} });
|
|
11051
|
+
out += e.uuid;
|
|
11052
|
+
}
|
|
11053
|
+
}
|
|
11054
|
+
return out + value.slice(at);
|
|
10655
11055
|
}
|
|
10656
|
-
if (Array.isArray(value)) return value.map((v, i) => scanEmbedded(v, `${p}[${i}]`, rowKey, ctx,
|
|
11056
|
+
if (Array.isArray(value)) return value.map((v, i) => scanEmbedded(v, `${p}[${i}]`, rowKey, ctx, sink));
|
|
10657
11057
|
if (value && typeof value === "object") {
|
|
10658
11058
|
const out = {};
|
|
10659
|
-
for (const [k, v] of Object.entries(value)) out[k] = scanEmbedded(v, `${p}.${k}`, rowKey, ctx,
|
|
11059
|
+
for (const [k, v] of Object.entries(value)) out[k] = scanEmbedded(v, `${p}.${k}`, rowKey, ctx, sink);
|
|
10660
11060
|
return out;
|
|
10661
11061
|
}
|
|
10662
11062
|
return value;
|
|
10663
11063
|
}
|
|
11064
|
+
function collectEmbeddedLookups(rows2, fields, ctx, into) {
|
|
11065
|
+
const names = ctx.modelNames ?? new Set(ctx.idKeys.keys());
|
|
11066
|
+
const known = (id) => ctx.envLocalIds.has(id) || [...ctx.idKeys.values()].some((m) => m.has(id));
|
|
11067
|
+
const want = (model, id) => {
|
|
11068
|
+
if (!into.has(model)) into.set(model, /* @__PURE__ */ new Set());
|
|
11069
|
+
into.get(model).add(id);
|
|
11070
|
+
};
|
|
11071
|
+
const walk = (v, p) => {
|
|
11072
|
+
if (typeof v === "string") {
|
|
11073
|
+
for (const e of embeddedUuids(v, p)) {
|
|
11074
|
+
const id = e.uuid.toLowerCase();
|
|
11075
|
+
if (known(id) || ENV_LOCAL_KEY_RE.test(e.nearKey)) continue;
|
|
11076
|
+
for (const m of embeddedHintModels(e.nearKey, e.pathModel, names)) want(m, id);
|
|
11077
|
+
for (const m of EMBEDDED_REF_PROBE_MODELS) if (names.has(m)) want(m, id);
|
|
11078
|
+
}
|
|
11079
|
+
} else if (Array.isArray(v)) v.forEach((x, i) => walk(x, `${p}[${i}]`));
|
|
11080
|
+
else if (v && typeof v === "object") for (const [k, x] of Object.entries(v)) walk(x, `${p}.${k}`);
|
|
11081
|
+
};
|
|
11082
|
+
for (const f of fields) {
|
|
11083
|
+
if (!exportableField(f) || f.object || f.type === "uuid") continue;
|
|
11084
|
+
for (const r of rows2) if (f.key in r) walk(r[f.key], f.key);
|
|
11085
|
+
}
|
|
11086
|
+
}
|
|
10664
11087
|
function scanExtensionUuids(file, text2) {
|
|
10665
11088
|
const out = [];
|
|
10666
11089
|
text2.split("\n").forEach((line, i) => {
|
|
@@ -10704,6 +11127,13 @@ function collectIndicatorRefs(value, out) {
|
|
|
10704
11127
|
return out;
|
|
10705
11128
|
}
|
|
10706
11129
|
var UUID_NEXT_STEP = "\u6E90\u73AF\u5883\u6539\u6210\u6309\u7F16\u7801\u5F15\u7528\uFF08${Model:key}\uFF09\uFF0C\u91CD\u65B0\u5BFC\u51FA";
|
|
11130
|
+
function uuidNextStep(reason) {
|
|
11131
|
+
if (reason === "EMBEDDED_LOOKUP_FAILED") return "\u53CD\u67E5\u6CA1\u67E5\u6210\uFF08\u62A5\u9519\u89C1 degradedReasons \u7684 REFERENCE_LOOKUP_FAILED\uFF09\uFF1A\u6062\u590D\u540E\u91CD\u65B0\u5BFC\u51FA\uFF1B\u4ECD\u6539\u5199\u4E0D\u4E86\u518D\u6309 reason \u5904\u7406";
|
|
11132
|
+
if (reason === "EMBEDDED_UUID_NOT_FOUND") return "\u6E90\u73AF\u5883\u91CC\u67E5\u4E0D\u5230\u8FD9\u884C\uFF1A\u662F\u5F15\u7528\u7684\u8BDD\u6E90\u73AF\u5883\u5DF2\u7ECF\u6307\u7A7A\uFF0C\u6539\u6210\u6309\u7F16\u7801\u5F15\u7528\u6216\u5220\u6389\uFF1B\u4E0D\u6307\u5411\u6570\u636E\u7684\u6807\u8BC6\uFF08\u5982 templateOrigin.creationRequestId\uFF09\u53EF\u5FFD\u7565";
|
|
11133
|
+
if (/^EMBEDDED_REF_/.test(reason)) return "\u5305\u5185\u4F9D\u8D56\u4E0D\u80FD\u5199\u6210\u7F16\u7801\u5F15\u7528\uFF08\u540C\u7C7B\u914D\u7F6E\u4E92\u6307 / \u672C\u5305\u540E\u88C5\u6216\u6CA1\u5BFC\u51FA\u7684\u884C\uFF0C\u88C5\u5305\u6309\u987A\u5E8F\u89E3\u6790\u4E0D\u5230\uFF09\uFF1A\u6E90\u73AF\u5883\u6539\u6210\u8FD0\u884C\u65F6\u6309\u7F16\u7801\u53D6\u6570\uFF0C\u4E0D\u8981\u624B\u5199 ${ref:} \u5360\u4F4D\u7B26\uFF1B\u6216\u88C5\u5305\u540E\u5728\u76EE\u6807\u73AF\u5883\u91CD\u65B0\u6307\u5411";
|
|
11134
|
+
if (reason === "EMBEDDED_KEY_HAS_UUID") return "\u76EE\u6807\u884C\u7684\u81EA\u7136\u952E\u672C\u8EAB\u7531\u5185\u90E8 ID \u7EC4\u6210\uFF0C\u8DE8\u73AF\u5883\u5BF9\u4E0D\u4E0A\uFF1A\u6E90\u73AF\u5883\u6539\u6210\u5F15\u7528\u5B83\u7684\u4E0A\u7EA7\u914D\u7F6E\uFF08\u6309\u7F16\u7801\uFF09\uFF0C\u6216\u88C5\u5305\u540E\u5728\u76EE\u6807\u73AF\u5883\u91CD\u65B0\u6307\u5411";
|
|
11135
|
+
return UUID_NEXT_STEP;
|
|
11136
|
+
}
|
|
10707
11137
|
var HARDCODED_UUID_IN_CODE = "HARDCODED_UUID_IN_CODE";
|
|
10708
11138
|
var OPAQUE_FIELD_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
10709
11139
|
var REF_LIKE_FIELD_RE = /(?:_id|Id)$/;
|
|
@@ -10773,6 +11203,10 @@ async function runExportConfig(api2, opts) {
|
|
|
10773
11203
|
lanes.skipped.push({ model, reason: "PRESET_SPLIT_UNVERIFIABLE", detail: split2.detail });
|
|
10774
11204
|
} else if (split2.classification === "CREATE_BY_HEURISTIC_UNVERIFIED") {
|
|
10775
11205
|
degraded.push(`PRESET_SPLIT_UNVERIFIED: ${model}`);
|
|
11206
|
+
} else if (split2.classification === "SERVER_IDS_UNRECONCILED") {
|
|
11207
|
+
degraded.push(`PRESET_SPLIT_UNRECONCILED: ${model}`);
|
|
11208
|
+
} else if (split2.classification === "CREATE_BY_VERIFIED_BY_COUNTS") {
|
|
11209
|
+
degraded.push(`PRESET_SPLIT_HEURISTIC: ${model}`);
|
|
10776
11210
|
}
|
|
10777
11211
|
if (split2.systemRows > 0 && split2.tenantRows.length === 0 && split2.classification !== "COUNTS_MISMATCH") {
|
|
10778
11212
|
lanes.skipped.push({ model, reason: "PRESET_ROWS_ONLY", detail: `${split2.systemRows} \u884C\u5168\u662F\u7CFB\u7EDF\u9884\u7F6E` });
|
|
@@ -10809,35 +11243,67 @@ async function runExportConfig(api2, opts) {
|
|
|
10809
11243
|
}
|
|
10810
11244
|
}
|
|
10811
11245
|
}
|
|
10812
|
-
|
|
10813
|
-
|
|
10814
|
-
const
|
|
10815
|
-
|
|
10816
|
-
|
|
10817
|
-
|
|
10818
|
-
|
|
10819
|
-
|
|
10820
|
-
|
|
10821
|
-
|
|
10822
|
-
|
|
10823
|
-
|
|
10824
|
-
|
|
11246
|
+
const lookupState = newLookupState();
|
|
11247
|
+
const lookupIds = async (wantedIds) => {
|
|
11248
|
+
for (const [target, ids] of wantedIds) {
|
|
11249
|
+
const tmeta = metas.get(target) ?? await api2.meta(target).catch(() => void 0);
|
|
11250
|
+
const keys = naturalKeysOf(target, tmeta);
|
|
11251
|
+
if (!keys) {
|
|
11252
|
+
lookupState.noKeys.add(target);
|
|
11253
|
+
continue;
|
|
11254
|
+
}
|
|
11255
|
+
const map = idKeys.get(target) ?? /* @__PURE__ */ new Map();
|
|
11256
|
+
const list2 = [...ids].filter((id) => !map.has(id.toLowerCase()));
|
|
11257
|
+
for (let i = 0; i < list2.length; i += 200) {
|
|
11258
|
+
const batch = list2.slice(i, i + 200);
|
|
11259
|
+
try {
|
|
11260
|
+
const fields = target === ROOT_MODEL ? ["id", "parentId", ...keys.keys] : ["id", ...keys.keys];
|
|
11261
|
+
const rows2 = await api2.listAll(target, { fields, filter: { field: "id", op: "in", value: batch }, pageSize: 500 });
|
|
11262
|
+
const asked = new Set(batch.map((x) => x.toLowerCase()));
|
|
11263
|
+
for (const r of rows2) {
|
|
11264
|
+
const k = rootAwareKey(target, keys.keys, r);
|
|
11265
|
+
if (typeof r.id !== "string" || !asked.has(r.id.toLowerCase())) continue;
|
|
11266
|
+
if (k) map.set(r.id.toLowerCase(), k);
|
|
11267
|
+
else addTo(lookupState.emptyKey, target, r.id.toLowerCase());
|
|
11268
|
+
}
|
|
11269
|
+
} catch (e) {
|
|
11270
|
+
for (const id of batch) addTo(lookupState.failed, target, id.toLowerCase());
|
|
11271
|
+
degraded.push(`REFERENCE_LOOKUP_FAILED: ${target}: ${describeError(e)}`);
|
|
10825
11272
|
}
|
|
10826
|
-
} catch (e) {
|
|
10827
|
-
degraded.push(`REFERENCE_LOOKUP_FAILED: ${target}: ${describeError(e)}`);
|
|
10828
11273
|
}
|
|
11274
|
+
idKeys.set(target, map);
|
|
10829
11275
|
}
|
|
10830
|
-
|
|
11276
|
+
};
|
|
11277
|
+
await lookupIds(wanted);
|
|
11278
|
+
const modelNames = new Set(metas.keys());
|
|
11279
|
+
const embeddedWanted = /* @__PURE__ */ new Map();
|
|
11280
|
+
for (const l of loaded) {
|
|
11281
|
+
collectEmbeddedLookups(l.split.tenantRows, l.meta.fields ?? [], { model: l.model, fields: l.meta.fields ?? [], idKeys, envLocalModels: envLocalSet, envLocalIds, modelNames, lookupState }, embeddedWanted);
|
|
10831
11282
|
}
|
|
11283
|
+
await lookupIds(embeddedWanted);
|
|
10832
11284
|
const unresolved = [];
|
|
10833
11285
|
const uuidFindings = [];
|
|
11286
|
+
const uuidRewrites = [];
|
|
10834
11287
|
const opaque = /* @__PURE__ */ new Set();
|
|
10835
11288
|
const envLocalRefs = [];
|
|
10836
11289
|
const manifestModels = [];
|
|
10837
|
-
|
|
11290
|
+
const installIndex = new Map(loaded.map((l, i) => [l.model, i]));
|
|
11291
|
+
const packageRowIds = new Map(loaded.map((l) => [l.model, new Set(l.split.tenantRows.map((r) => String(r.id).toLowerCase()))]));
|
|
11292
|
+
const droppedRowIds = /* @__PURE__ */ new Map();
|
|
11293
|
+
const notExported = new Set(lanes.configModels.filter((m) => !installIndex.has(m) || loaded.find((l) => l.model === m)?.split.classification === "COUNTS_MISMATCH"));
|
|
11294
|
+
for (const [ci, l] of loaded.entries()) {
|
|
10838
11295
|
const entry = entries.find((e) => e.model === l.model);
|
|
10839
11296
|
if (l.split.tenantRows.length === 0 || !l.keys) continue;
|
|
10840
|
-
const
|
|
11297
|
+
const packageGuard = (target, id) => {
|
|
11298
|
+
if (target === l.model) return "EMBEDDED_REF_SAME_MODEL";
|
|
11299
|
+
if (notExported.has(target)) return "EMBEDDED_REF_TARGET_NOT_EXPORTED";
|
|
11300
|
+
const ti = installIndex.get(target);
|
|
11301
|
+
if (ti === void 0 || !packageRowIds.get(target)?.has(id)) return void 0;
|
|
11302
|
+
if (ti > ci) return "EMBEDDED_REF_INSTALLED_LATER";
|
|
11303
|
+
if (droppedRowIds.get(target)?.has(id)) return "EMBEDDED_REF_TARGET_DROPPED";
|
|
11304
|
+
return void 0;
|
|
11305
|
+
};
|
|
11306
|
+
const ctx = { model: l.model, fields: l.meta.fields ?? [], idKeys, envLocalModels: envLocalSet, envLocalIds, modelNames, packageGuard, lookupState };
|
|
10841
11307
|
const keys = l.keys.keys;
|
|
10842
11308
|
const rewrite = (rows2) => {
|
|
10843
11309
|
const ordered = l.meta.fields?.some((f) => f.key === "parentId") ? parentFirst(rows2) : rows2;
|
|
@@ -10850,11 +11316,25 @@ async function runExportConfig(api2, opts) {
|
|
|
10850
11316
|
});
|
|
10851
11317
|
for (const u of res.unresolved) {
|
|
10852
11318
|
const field = topLevelField(u.fieldPath);
|
|
10853
|
-
uuidFindings.push({
|
|
11319
|
+
uuidFindings.push({
|
|
11320
|
+
model: l.model,
|
|
11321
|
+
rowKey,
|
|
11322
|
+
field,
|
|
11323
|
+
fieldPath: u.fieldPath,
|
|
11324
|
+
uuidPrefix: u.value.slice(0, 8),
|
|
11325
|
+
action: drop ? "ROW_DROPPED" : "OPAQUE_DECLARED",
|
|
11326
|
+
reason: u.reason,
|
|
11327
|
+
...u.target ? { target: u.target } : {},
|
|
11328
|
+
nextStep: uuidNextStep(u.reason)
|
|
11329
|
+
});
|
|
10854
11330
|
if (!drop) opaque.add(`${l.model}.${field}`);
|
|
10855
11331
|
}
|
|
10856
|
-
if (drop)
|
|
11332
|
+
if (drop) {
|
|
11333
|
+
addTo(droppedRowIds, l.model, String(r.id).toLowerCase());
|
|
11334
|
+
return [];
|
|
11335
|
+
}
|
|
10857
11336
|
envLocalRefs.push(...res.envLocal);
|
|
11337
|
+
uuidRewrites.push(...res.rewrites);
|
|
10858
11338
|
return [res.item];
|
|
10859
11339
|
});
|
|
10860
11340
|
};
|
|
@@ -11011,7 +11491,7 @@ async function runExportConfig(api2, opts) {
|
|
|
11011
11491
|
const opaqueN = uuidFindings.filter((u) => u.action === "OPAQUE_DECLARED").length;
|
|
11012
11492
|
const droppedRowsN = new Set(uuidFindings.filter((u) => u.action === "ROW_DROPPED").map((u) => `${u.model}|${u.rowKey}`)).size;
|
|
11013
11493
|
if (uuidFindings.length || extensionRedactions.length || droppedGroups.size) {
|
|
11014
|
-
degraded.push(`SOURCE_UUID_HANDLED: \u6570\u636E\u884C\u88F8 UUID ${uuidFindings.length} \u5904\uFF08\u58F0\u660E opaque ${opaqueN} \u5904 / \u5220\u884C ${droppedRowsN} \u884C\uFF09\uFF0C\u6269\u5C55\u63CF\u8FF0\u6587\u672C\u66FF\u6362 ${redactedUuidN} \u5904\uFF0C\u5254\u9664\u5B57\u6BB5\u5951\u7EA6\u5916\u7684\u952E ${unknownKeyN} \u5904\uFF0C\u4EE3\u7801\u8D44\u4EA7\u4E0D\u5BFC\u51FA ${droppedGroups.size} \u4E2A\uFF08\u5220\u5F15\u7528\u52A8\u4F5C ${removedRefs.length} \u4E2A\uFF09\uFF1B\u5305\u7167\u5E38\u4EA7\u51FA\uFF0C\u89C1 uuidFindings / extensionRedactions / skipped`);
|
|
11494
|
+
degraded.push(`SOURCE_UUID_HANDLED: \u6570\u636E\u884C\u6539\u5199\u4E0D\u4E86\u7684\u88F8 UUID ${uuidFindings.length} \u5904\uFF08\u58F0\u660E opaque ${opaqueN} \u5904 / \u5220\u884C ${droppedRowsN} \u884C\uFF1B\u53E6\u6709 ${uuidRewrites.length} \u5904\u5DF2\u6539\u4E3A\u6309\u7F16\u7801\u5F15\u7528\uFF0C\u89C1 uuidRewrites\uFF09\uFF0C\u6269\u5C55\u63CF\u8FF0\u6587\u672C\u66FF\u6362 ${redactedUuidN} \u5904\uFF0C\u5254\u9664\u5B57\u6BB5\u5951\u7EA6\u5916\u7684\u952E ${unknownKeyN} \u5904\uFF0C\u4EE3\u7801\u8D44\u4EA7\u4E0D\u5BFC\u51FA ${droppedGroups.size} \u4E2A\uFF08\u5220\u5F15\u7528\u52A8\u4F5C ${removedRefs.length} \u4E2A\uFF09\uFF1B\u5305\u7167\u5E38\u4EA7\u51FA\uFF0C\u89C1 uuidFindings / extensionRedactions / skipped`);
|
|
11015
11495
|
}
|
|
11016
11496
|
if (dangling.length) degraded.push(`DANGLING_REFERENCES: ${dangling.length} \u5904\u4ECD\u5F15\u7528\u5DF2\u5254\u9664\u7684\u4EE3\u7801\u8D44\u4EA7\uFF0C\u89C1 removedReferences.dangling`);
|
|
11017
11497
|
if (unresolved.length) degraded.push(`UNRESOLVED_REFERENCES: ${unresolved.length} \u5904\u5F15\u7528/UUID \u65E0\u6CD5\u6539\u5199\u4E3A\u81EA\u7136\u952E\uFF0C\u539F\u503C\u4FDD\u7559\uFF08pack \u4F1A\u62D2\uFF09\uFF0C\u89C1 unresolvedReferences`);
|
|
@@ -11057,6 +11537,7 @@ async function runExportConfig(api2, opts) {
|
|
|
11057
11537
|
models: entries,
|
|
11058
11538
|
extensions: { files: extFiles.length, strippedDefinitionIds, nonActive, failed: extFailed },
|
|
11059
11539
|
uuidFindings,
|
|
11540
|
+
uuidRewrites,
|
|
11060
11541
|
opaqueUuidFields: [...opaque].sort(),
|
|
11061
11542
|
extensionRedactions,
|
|
11062
11543
|
removedReferences: { removed: removedRefs, dangling },
|
|
@@ -11151,6 +11632,7 @@ async function envExportConfigCommand(args) {
|
|
|
11151
11632
|
strippedDefinitionIds: r.extensions.strippedDefinitionIds,
|
|
11152
11633
|
unresolvedReferences: r.unresolvedReferences.length,
|
|
11153
11634
|
envLocalReferences: r.envLocalReferences.length,
|
|
11635
|
+
uuidRewrites: r.uuidRewrites.length,
|
|
11154
11636
|
uuidFindings: r.uuidFindings.length,
|
|
11155
11637
|
opaqueUuidFields: r.opaqueUuidFields,
|
|
11156
11638
|
extensionRedactions: r.extensionRedactions.length,
|
|
@@ -11180,7 +11662,7 @@ function renderPreconditions(r) {
|
|
|
11180
11662
|
lines.push(`\u5305\u8EAB\u4EFD\uFF1A${p.name}\uFF08${p.source === "INHERITED_FROM_INSTALLED_PACKAGE" ? `\u6CBF\u7528\u6E90\u73AF\u5883\u5DF2\u88C5\u5305\uFF0C\u6E90\u73AF\u5883\u7248\u672C ${p.inheritedFromVersion ?? "?"}\uFF1B\u88C5\u5230\u88C5\u8FC7\u5B83\u7684\u73AF\u5883\u5373\u5347\u7EA7` : p.source === "FLAG" ? "--package-name \u6307\u5B9A" : `${p.detail ?? "\u672A\u67E5\u5230\u6301\u6709\u6269\u5C55\u6587\u4EF6\u7684\u5DF2\u88C5\u5305"}\uFF0C\u6309\u79DF\u6237\u8D77\u540D\uFF1B\u76EE\u6807\u73AF\u5883\u82E5\u5DF2\u88C5\u8FC7\u522B\u7684\u5305\u540D\uFF0C\u88C5\u5305\u4F1A\u62A5 PACKAGE_EXTENSION_PATH_OWNED_BY_OTHER_PACKAGE\uFF0C\u5C4A\u65F6\u7528 --package-name \u6539\u6210\u90A3\u4E2A\u5305\u540D\u91CD\u5BFC`}\uFF09`);
|
|
11181
11663
|
}
|
|
11182
11664
|
lines.push("\u524D\u63D0\u65AD\u8A00\uFF08\u6E90\u7AEF\uFF09\uFF1A", ` CONFIG \u6A21\u578B\u79DF\u6237\u81EA\u6709\u884C\u6570\uFF08laneSource=${r.laneSource}\uFF09\uFF1A`);
|
|
11183
|
-
for (const m of r.models) lines.push(` ${m.model.padEnd(24)} ${m.tenantOriginal + m.tenantOverride}\uFF08\u539F\u521B ${m.tenantOriginal} / \u8986\u76D6 ${m.tenantOverride}\uFF1B\u7CFB\u7EDF\u9884\u7F6E\u8DF3\u8FC7 ${m.systemRowsSkipped}\uFF1B${m.presetClassification}\uFF09${m.overrideFile ? `\uFF1B\u8986\u76D6\u884C ${m.exportedOverrideRows} \u6761\u5BFC\u51FA\u5230 ${m.overrideFile}\uFF08update_existing: true\uFF09` : ""}`);
|
|
11665
|
+
for (const m of r.models) lines.push(` ${m.model.padEnd(24)} ${m.tenantOriginal + m.tenantOverride}\uFF08\u539F\u521B ${m.tenantOriginal} / \u8986\u76D6 ${m.tenantOverride}\uFF1B\u7CFB\u7EDF\u9884\u7F6E\u8DF3\u8FC7 ${m.systemRowsSkipped}\uFF1B${m.presetClassification}\uFF09${m.detail && m.presetClassification !== "COUNTS_MISMATCH" ? `\uFF1B${m.detail}` : ""}${m.overrideFile ? `\uFF1B\u8986\u76D6\u884C ${m.exportedOverrideRows} \u6761\u5BFC\u51FA\u5230 ${m.overrideFile}\uFF08update_existing: true\uFF09` : ""}`);
|
|
11184
11666
|
lines.push(` \u5408\u8BA1 ${r.preconditions.configTenantRowsTotal}${r.preconditions.configTenantRowsTotal > 0 ? "" : " \u26A0\uFE0F \u4E3A 0\uFF1A\u5BFC\u51FA\u662F\u7A7A\u96C6\u5408\uFF0CE1 \u5224\u636E\u65E0\u6548"}`);
|
|
11185
11667
|
lines.push(" ENV_LOCAL \u6A21\u578B\u884C\u6570\uFF08\u8BC1\u660E\u300CENV_LOCAL \u96F6\u5BFC\u51FA\u300D\u4E0D\u662F\u7A7A\u96C6\u5408\u901A\u8FC7\uFF09\uFF1A");
|
|
11186
11668
|
for (const [m, n2] of Object.entries(r.preconditions.envLocalRows)) {
|
|
@@ -11202,6 +11684,13 @@ function renderNextSteps(outDir, r) {
|
|
|
11202
11684
|
const lines = ["\u4E0B\u4E00\u6B65\uFF1A", ` 1. hcm package pack ${outDir} -o ${artifact}`, ` 2. hcm package install ${artifact} --env <\u76EE\u6807\u73AF\u5883>`];
|
|
11203
11685
|
if (r.unresolvedReferences.length) lines.push(` \u26A0\uFE0F ${r.unresolvedReferences.length} \u5904\u5F15\u7528\u672A\u6539\u5199\uFF08unresolvedReferences\uFF09\uFF0Cpack \u4F1A\u62A5 UUID \u8FDD\u89C4\uFF0C\u5148\u6309\u62A5\u544A\u9010\u6761\u5904\u7406`);
|
|
11204
11686
|
if (r.missingIndicatorRefs.length) lines.push(` \u26A0\uFE0F ${new Set(r.missingIndicatorRefs.map((m) => m.board)).size} \u4E2A\u770B\u677F\u5F15\u7528\u4E86\u5305\u91CC\u6CA1\u6709\u7684\u6307\u6807\uFF08missingIndicatorRefs\uFF09\uFF0C\u88C5\u5B8C\u8FD9\u4E9B\u5757\u4F1A\u62A5\u9519\uFF1B\u6E90\u73AF\u5883\u8865\u4E0A\u6307\u6807\u6216\u6539\u770B\u677F\u540E\u91CD\u5BFC`);
|
|
11687
|
+
if (r.uuidRewrites.length) {
|
|
11688
|
+
const byModel = /* @__PURE__ */ new Map();
|
|
11689
|
+
for (const w of r.uuidRewrites) byModel.set(w.targetModel, (byModel.get(w.targetModel) ?? 0) + 1);
|
|
11690
|
+
lines.push(` ${r.uuidRewrites.length} \u5904\u914D\u7F6E\u91CC\u5199\u6B7B\u7684\u5185\u90E8 ID \u5DF2\u6539\u6210\u6309\u7F16\u7801\u5F15\u7528\uFF08uuidRewrites\uFF1A${[...byModel].map(([m, n2]) => `${m} ${n2}`).join("\u3001")}\uFF09\uFF1B\u76EE\u6807\u73AF\u5883\u987B\u6709\u540C\u7F16\u7801\u7684\u884C\uFF0C\u7F3A\u4E86\u88C5\u5305\u62A5 DATA_PACKAGE_REF_UNRESOLVED`);
|
|
11691
|
+
}
|
|
11692
|
+
const opaqueLeft = r.uuidFindings.filter((u) => u.action === "OPAQUE_DECLARED");
|
|
11693
|
+
if (opaqueLeft.length) lines.push(` \u26A0\uFE0F ${opaqueLeft.length} \u5904\u5185\u90E8 ID \u6539\u5199\u4E0D\u4E86\u3001\u539F\u6837\u88C5\u5165\uFF08uuidFindings\uFF0Creason \u8BF4\u660E\u539F\u56E0\uFF09\uFF1B\u662F\u5F15\u7528\u7684\u8BDD\u76EE\u6807\u73AF\u5883\u90A3\u4E00\u5757\u4F1A\u7A7A\uFF0C\u56DE\u6E90\u73AF\u5883\u6539\u6210\u6309\u7F16\u7801\u5F15\u7528\u540E\u91CD\u5BFC`);
|
|
11205
11694
|
if (r.envLocalReferences.length) lines.push(` \u88C5\u5305\u540E\u5728\u76EE\u6807\u73AF\u5883\u91CD\u65B0\u7ED1\u5B9A ${r.envLocalReferences.length} \u5904 ENV_LOCAL \u5F15\u7528\uFF08envLocalReferences\uFF09`);
|
|
11206
11695
|
if (r.columnSlots.fields.length && r.columnSlots.mode === "keep") lines.push(` \u76EE\u6807\u73AF\u5883\u987B\u5DF2\u5EFA\u597D ${r.columnSlots.fields.length} \u4E2A\u5217\u69FD\uFF08\u89C1\u4E0A\u65B9\u6E05\u5355\uFF09\uFF0C\u5426\u5219\u88C5\u5305\u5931\u8D25`);
|
|
11207
11696
|
return lines.join("\n") + "\n";
|
|
@@ -12737,9 +13226,9 @@ async function skillsListCommand(keyword, args, cwd = process.cwd()) {
|
|
|
12737
13226
|
process.exitCode = 0;
|
|
12738
13227
|
return;
|
|
12739
13228
|
}
|
|
12740
|
-
const
|
|
13229
|
+
const shown2 = cats.flatMap((c2) => c2.skills);
|
|
12741
13230
|
const total = (manifest2?.skillCount ?? 0) + catalog.cli.entries.size;
|
|
12742
|
-
if (
|
|
13231
|
+
if (shown2.length === 0) {
|
|
12743
13232
|
process.stdout.write(`\u6CA1\u6709\u5339\u914D\u7684\u6280\u80FD\uFF08\u8FD9\u4E00\u8D9F\u770B\u7684\u6765\u6E90\u5171 ${total} \u4E2A\uFF09
|
|
12744
13233
|
`);
|
|
12745
13234
|
process.exitCode = 0;
|
|
@@ -12774,7 +13263,7 @@ async function skillsListCommand(keyword, args, cwd = process.cwd()) {
|
|
|
12774
13263
|
}
|
|
12775
13264
|
process.stdout.write("\n");
|
|
12776
13265
|
}
|
|
12777
|
-
process.stdout.write(` \u25CF CLI \u5C31\u7EEA \u25CB \u5F85\u6539\u5199\u52A8\u4F5C\u9762 \u5171 ${
|
|
13266
|
+
process.stdout.write(` \u25CF CLI \u5C31\u7EEA \u25CB \u5F85\u6539\u5199\u52A8\u4F5C\u9762 \u5171 ${shown2.length} \u4E2A
|
|
12778
13267
|
`);
|
|
12779
13268
|
process.stdout.write(` \u88C5\u4E00\u4E2A\uFF1Ahcm chiron skills sync --only <id>
|
|
12780
13269
|
`);
|
|
@@ -12791,7 +13280,7 @@ async function skillsListCommand(keyword, args, cwd = process.cwd()) {
|
|
|
12791
13280
|
}
|
|
12792
13281
|
process.stdout.write("\n");
|
|
12793
13282
|
}
|
|
12794
|
-
process.stdout.write(` \u25CF CLI \u5C31\u7EEA \u25CB \u5F85\u6539\u5199\u52A8\u4F5C\u9762 \u5171 ${
|
|
13283
|
+
process.stdout.write(` \u25CF CLI \u5C31\u7EEA \u25CB \u5F85\u6539\u5199\u52A8\u4F5C\u9762 \u5171 ${shown2.length} \u4E2A
|
|
12795
13284
|
`);
|
|
12796
13285
|
process.stdout.write(` \u88C5\u4E00\u4E2A\uFF1Ahcm chiron skills sync --only <id>
|
|
12797
13286
|
`);
|
|
@@ -12866,7 +13355,7 @@ async function listInstalledSkills(keyword, args, cwd = process.cwd()) {
|
|
|
12866
13355
|
const allRows = [...rows2.filter((r) => !shadowed.has(r.id)), ...localRows].sort((a, b) => a.id.localeCompare(b.id));
|
|
12867
13356
|
const byKeyword = keyword ? allRows.filter((row) => row.id.includes(keyword) || row.title.includes(keyword)) : allRows;
|
|
12868
13357
|
const sourceFilter = parseSourceFilter(args.source);
|
|
12869
|
-
const
|
|
13358
|
+
const shown2 = sourceFilter === "all" ? byKeyword : byKeyword.filter((row) => row.sourceKind === sourceFilter);
|
|
12870
13359
|
const groupOf = (kind) => kind === "cli" ? "CLI \u81EA\u5E26" : kind === "local" ? "\u672C\u9879\u76EE\u81EA\u5DF1\u7684\uFF08hcm-skills/local/\uFF09" : "\u777F\u620E\u6280\u80FD\u5E93";
|
|
12871
13360
|
if (fmt === "json" || fmt === "yaml") {
|
|
12872
13361
|
process.stdout.write(formatObject21({
|
|
@@ -12877,11 +13366,11 @@ async function listInstalledSkills(keyword, args, cwd = process.cwd()) {
|
|
|
12877
13366
|
updatedAt: state?.updatedAt,
|
|
12878
13367
|
// 按来源分组的小计:顾问要能一眼看出「这份是跟着 CLI 走的还是跟着后端走的」
|
|
12879
13368
|
bySource: {
|
|
12880
|
-
cli:
|
|
12881
|
-
chiron:
|
|
12882
|
-
local:
|
|
13369
|
+
cli: shown2.filter((r) => r.sourceKind === "cli").length,
|
|
13370
|
+
chiron: shown2.filter((r) => r.sourceKind === "chiron").length,
|
|
13371
|
+
local: shown2.filter((r) => r.sourceKind === "local").length
|
|
12883
13372
|
},
|
|
12884
|
-
skills:
|
|
13373
|
+
skills: shown2
|
|
12885
13374
|
}, { format: fmt }) + "\n");
|
|
12886
13375
|
process.exitCode = 0;
|
|
12887
13376
|
return;
|
|
@@ -12889,14 +13378,14 @@ async function listInstalledSkills(keyword, args, cwd = process.cwd()) {
|
|
|
12889
13378
|
process.stdout.write(`\u5DF2\u5B89\u88C5\u7684\u6280\u80FD \u2014 ${layout.baseDir}\uFF08${layout.target}\uFF09
|
|
12890
13379
|
`);
|
|
12891
13380
|
process.stdout.write(`\u6765\u6E90 ${state?.endpoint ?? "\uFF08\u672A\u8BB0\u5F55\uFF09"}` + (state?.all ? " \u8DDF\u968F\u5168\u96C6\uFF1A\u662F\n\n" : "\n\n"));
|
|
12892
|
-
if (
|
|
13381
|
+
if (shown2.length === 0) {
|
|
12893
13382
|
process.stdout.write(` \u6CA1\u6709\u5339\u914D\u300C${keyword}\u300D\u7684\u6280\u80FD\uFF08\u5171\u88C5\u4E86 ${rows2.length} \u4E2A\uFF09
|
|
12894
13383
|
`);
|
|
12895
13384
|
process.exitCode = 0;
|
|
12896
13385
|
return;
|
|
12897
13386
|
}
|
|
12898
13387
|
for (const kind of ["chiron", "cli", "local"]) {
|
|
12899
|
-
const group =
|
|
13388
|
+
const group = shown2.filter((row) => row.sourceKind === kind);
|
|
12900
13389
|
if (group.length === 0) continue;
|
|
12901
13390
|
process.stdout.write(` ${groupOf(kind)}\uFF08${group.length}\uFF09
|
|
12902
13391
|
`);
|
|
@@ -12908,13 +13397,13 @@ async function listInstalledSkills(keyword, args, cwd = process.cwd()) {
|
|
|
12908
13397
|
}
|
|
12909
13398
|
process.stdout.write("\n");
|
|
12910
13399
|
}
|
|
12911
|
-
const modified =
|
|
12912
|
-
const missing2 =
|
|
12913
|
-
const indirect =
|
|
13400
|
+
const modified = shown2.filter((row) => row.status === "locally-modified").length;
|
|
13401
|
+
const missing2 = shown2.filter((row) => row.status === "missing").length;
|
|
13402
|
+
const indirect = shown2.filter((row) => row.direct === false).length;
|
|
12914
13403
|
process.stdout.write("\n");
|
|
12915
13404
|
process.stdout.write(` \u25CF \u76F4\u63A5\u5B89\u88C5 \u25CB \u4F9D\u8D56\u5E26\u5165 ! \u672C\u5730\u6539\u8FC7 ? \u6587\u4EF6\u7F3A\u5931
|
|
12916
13405
|
`);
|
|
12917
|
-
process.stdout.write(` \u5171 ${
|
|
13406
|
+
process.stdout.write(` \u5171 ${shown2.length} \u4E2A` + [
|
|
12918
13407
|
indirect > 0 ? `${indirect} \u4E2A\u662F\u4F9D\u8D56\u5E26\u5165` : "",
|
|
12919
13408
|
modified > 0 ? `${modified} \u4E2A\u672C\u5730\u6539\u8FC7` : "",
|
|
12920
13409
|
missing2 > 0 ? `${missing2} \u4E2A\u6587\u4EF6\u7F3A\u5931` : ""
|
|
@@ -20257,9 +20746,9 @@ async function runMethodStatus(root, deps, opts = {}) {
|
|
|
20257
20746
|
if (!existsSync6(copyDir) && state?.target !== "claude") continue;
|
|
20258
20747
|
const prefix = `${path22.posix.dirname(s.path)}/`;
|
|
20259
20748
|
for (const f of manifest2.files.filter((x) => x.path.startsWith(prefix))) {
|
|
20260
|
-
const
|
|
20261
|
-
copyEntries.push({ ...f, path:
|
|
20262
|
-
copyMap.set(
|
|
20749
|
+
const shown2 = `.claude/skills/${s.id}/${f.path.slice(prefix.length)}`;
|
|
20750
|
+
copyEntries.push({ ...f, path: shown2 });
|
|
20751
|
+
copyMap.set(shown2, path22.join(root, shown2));
|
|
20263
20752
|
}
|
|
20264
20753
|
}
|
|
20265
20754
|
const copies = await verifyDigests(copyEntries, (p) => copyMap.get(p));
|
|
@@ -23795,6 +24284,7 @@ function classify(argv, actionResolution) {
|
|
|
23795
24284
|
if (name === "version") return direct("R0", "product-discovery", "product-discovery");
|
|
23796
24285
|
if (name === "open") return direct("R1", "remote-read", "browser-session-open");
|
|
23797
24286
|
if (name === "models") return direct("R0", "product-discovery", "model-discovery");
|
|
24287
|
+
if (name === "introspect") return direct("R0", "product-discovery", "introspection-index");
|
|
23798
24288
|
if (name === "llm") {
|
|
23799
24289
|
if (subcommand === "probe") return {
|
|
23800
24290
|
risk: "R2",
|
|
@@ -23929,6 +24419,7 @@ function classify(argv, actionResolution) {
|
|
|
23929
24419
|
if (name === "query" || name === "describe" || name === "trace") {
|
|
23930
24420
|
return direct("R1", "remote-read", "business-read");
|
|
23931
24421
|
}
|
|
24422
|
+
if (name === "preset-origin") return direct("R1", "remote-read", "preset-origin-read");
|
|
23932
24423
|
if (name === "cache") {
|
|
23933
24424
|
if (subcommand === "stats") return direct("R1", "remote-read", "cache-read");
|
|
23934
24425
|
if (subcommand === "clear" || subcommand === "clear-meta") {
|
|
@@ -24041,7 +24532,7 @@ function summarizeTarget(argv, actionResolution) {
|
|
|
24041
24532
|
const name = argv[0] ?? "";
|
|
24042
24533
|
const subcommand = argv[1] ?? "";
|
|
24043
24534
|
const target = {};
|
|
24044
|
-
if (["query", "describe", "create", "update", "delete"].includes(name) && subcommand) {
|
|
24535
|
+
if (["query", "describe", "create", "update", "delete", "preset-origin"].includes(name) && subcommand) {
|
|
24045
24536
|
target.model = subcommand;
|
|
24046
24537
|
}
|
|
24047
24538
|
if (name === "action" && subcommand) {
|
|
@@ -25602,25 +26093,197 @@ async function promptPasswordTwice() {
|
|
|
25602
26093
|
init_exit();
|
|
25603
26094
|
init_auth_guard();
|
|
25604
26095
|
import {
|
|
26096
|
+
CliError as CliError55,
|
|
26097
|
+
CliErrorCode as CliErrorCode54,
|
|
25605
26098
|
HcmClient as HcmClient38,
|
|
25606
|
-
formatObject as
|
|
26099
|
+
formatObject as formatObject40,
|
|
25607
26100
|
fromAxiosError as fromAxiosError33
|
|
25608
26101
|
} from "@hcmai/sdk";
|
|
26102
|
+
|
|
26103
|
+
// src/commands/models-search.ts
|
|
26104
|
+
import {
|
|
26105
|
+
CliError as CliError54,
|
|
26106
|
+
CliErrorCode as CliErrorCode53,
|
|
26107
|
+
MODEL_SEARCH_DEGRADED_COUNT_KEYS,
|
|
26108
|
+
MODEL_SEARCH_KEYS,
|
|
26109
|
+
MODEL_SEARCH_PATH,
|
|
26110
|
+
classifyEndpointFailure,
|
|
26111
|
+
formatObject as formatObject39,
|
|
26112
|
+
missingKeys as missingKeys2,
|
|
26113
|
+
searchModels
|
|
26114
|
+
} from "@hcmai/sdk";
|
|
26115
|
+
var EVIDENCE_MAX_CHARS = 60;
|
|
26116
|
+
function clip(s) {
|
|
26117
|
+
const chars = [...s.replace(/\s+/g, " ")];
|
|
26118
|
+
return chars.length <= EVIDENCE_MAX_CHARS ? { text: chars.join(""), clipped: false } : { text: `${chars.slice(0, EVIDENCE_MAX_CHARS).join("")}\u2026`, clipped: true };
|
|
26119
|
+
}
|
|
26120
|
+
function num(view, key2, v) {
|
|
26121
|
+
return key2 in view ? String(v) : NOT_PROVIDED;
|
|
26122
|
+
}
|
|
26123
|
+
function renderDegraded(view) {
|
|
26124
|
+
if (!("degraded" in view) || !view.degraded || typeof view.degraded !== "object") {
|
|
26125
|
+
return [`\u964D\u7EA7\uFF1A${NOT_PROVIDED}\uFF08\u670D\u52A1\u7AEF\u6CA1\u8BF4\u6709\u6CA1\u6709\u6A21\u578B\u6CA1\u626B\u5168\u2014\u20140 \u547D\u4E2D\u65F6\u5C24\u5176\u4E0D\u80FD\u5F53\u300C\u67E5\u8FC7\u4E14\u4E3A\u7A7A\u300D\uFF09`];
|
|
26126
|
+
}
|
|
26127
|
+
const d = view.degraded;
|
|
26128
|
+
const missing2 = new Set(missingKeys2(d, MODEL_SEARCH_DEGRADED_COUNT_KEYS));
|
|
26129
|
+
const count = (k, v) => missing2.has(k) ? NOT_PROVIDED : String(v);
|
|
26130
|
+
const lines = [
|
|
26131
|
+
`\u964D\u7EA7\uFF08\u4E09\u4E2A\u6876\u90FD\u8981\u770B\uFF1B0 \u662F\u4E00\u6761\u80AF\u5B9A\u4FE1\u606F\uFF0C\u4E0D\u662F\u300C\u8FD9\u4E2A\u7AEF\u70B9\u4E0D\u62A5\u544A\u964D\u7EA7\u300D\uFF09\uFF1AnotScanned=${count("notScannedCount", d.notScannedCount)} \xB7 scanFailed=${count("scanFailedCount", d.scanFailedCount)} \xB7 metaUnavailable=${count("metaUnavailableCount", d.metaUnavailableCount)}`
|
|
26132
|
+
];
|
|
26133
|
+
const bucket = (label, n2, keys, what) => {
|
|
26134
|
+
if (!n2) return;
|
|
26135
|
+
const listed = keys?.length ?? 0;
|
|
26136
|
+
const tail = listed < n2 ? `\uFF08\u5217\u4E86 ${listed} \u4E2A\uFF0C\u5171 ${n2} \u4E2A\uFF09` : "";
|
|
26137
|
+
lines.push(` ${label}\uFF08${what}\uFF09\uFF1A${(keys ?? []).join("\u3001")}${tail}`);
|
|
26138
|
+
};
|
|
26139
|
+
bucket("notScanned", d.notScannedCount, d.notScannedModels, "\u8FDE\u5B9E\u4F8B\u90FD\u9020\u4E0D\u51FA\u6765\uFF0C\u516B\u7EF4\u4E00\u7EF4\u90FD\u6CA1\u8DD1");
|
|
26140
|
+
bucket("scanFailed", d.scanFailedCount, d.scanFailedModels, "\u626B\u63CF\u4E2D\u9014\u629B\u5F02\u5E38\uFF0C\u90A3\u534A\u4EFD\u4E5F\u88AB\u4E22\u5F03");
|
|
26141
|
+
bucket("metaUnavailable", d.metaUnavailableCount, d.metaUnavailableModels, "\u5408\u5E76\u5143\u6570\u636E\u6CA1\u8BFB\u5230\uFF0C\u4E94\u7EF4\u6CA1\u8DD1\uFF0C\u5DF2\u6709\u4E09\u7EF4\u53EA\u5F53\u5F31\u7EBF\u7D22");
|
|
26142
|
+
if (d.meaning) lines.push(` \u8BF4\u660E\uFF1A${rewriteSelfLinks(d.meaning)}`);
|
|
26143
|
+
return lines;
|
|
26144
|
+
}
|
|
26145
|
+
function renderModelSearch(keyword, view) {
|
|
26146
|
+
const total = view.totalCount;
|
|
26147
|
+
const scanned = view.scannedCount;
|
|
26148
|
+
const lines = [
|
|
26149
|
+
`\u68C0\u7D22\u300C${keyword}\u300D\uFF1A\u626B\u5B8C ${num(view, "scannedCount", scanned)} \u4E2A\u6A21\u578B\uFF0C\u547D\u4E2D ${num(view, "totalCount", total)} \u4E2A\uFF0C\u672C\u6B21\u8FD4\u56DE ${num(view, "returned", view.returned)} \u4E2A\uFF08\u751F\u6548 limit=${num(view, "effectiveLimit", view.effectiveLimit)}\uFF09\u3002`
|
|
26150
|
+
];
|
|
26151
|
+
if (view.limitNote) lines.push(`\u26A0\uFE0F limit \u88AB\u6539\u8FC7\uFF1A${rewriteSelfLinks(view.limitNote)}`);
|
|
26152
|
+
if (!("truncatedBy" in view)) {
|
|
26153
|
+
lines.push(`truncatedBy\uFF1A${NOT_PROVIDED}\uFF08\u670D\u52A1\u7AEF\u6CA1\u8BF4\u8FD9\u4EFD\u662F\u4E0D\u662F\u5168\u96C6\u2014\u2014\u522B\u5F53\u5168\u96C6\u7528\uFF09`);
|
|
26154
|
+
} else if (view.truncatedBy) {
|
|
26155
|
+
lines.push(`\u26A0\uFE0F \u672C\u54CD\u5E94\u4E0D\u662F\u5168\u96C6\uFF1A${rewriteSelfLinks(view.truncatedBy)}`);
|
|
26156
|
+
if (view.nextStep) lines.push(` \u4E0B\u4E00\u6B65\uFF1A${rewriteSelfLinks(view.nextStep)}`);
|
|
26157
|
+
}
|
|
26158
|
+
lines.push(`\u6392\u5E8F\uFF1A${"rankingNote" in view ? rewriteSelfLinks(view.rankingNote ?? "null") : NOT_PROVIDED}`);
|
|
26159
|
+
lines.push("");
|
|
26160
|
+
const hits = Array.isArray(view.models) ? view.models : void 0;
|
|
26161
|
+
let clipped = false;
|
|
26162
|
+
if (!hits) {
|
|
26163
|
+
lines.push(`\u5019\u9009\uFF1A${NOT_PROVIDED}`);
|
|
26164
|
+
} else if (hits.length === 0) {
|
|
26165
|
+
if (scanned === 0) {
|
|
26166
|
+
lines.push(
|
|
26167
|
+
"\u{1F534} \u8FD9\u4E00\u8F6E\u4E00\u4E2A\u6A21\u578B\u90FD\u6CA1\u626B\u5230\uFF08scannedCount=0\uFF09\u2014\u2014\u4E0D\u662F\u300C\u6CA1\u547D\u4E2D\u300D\uFF0C\u662F\u8FD9\u6B21\u68C0\u7D22\u6CA1\u6709\u5206\u6BCD\uFF1A\u670D\u52A1\u7AEF\u626B\u7684\u662F\u5168\u90E8\u6CE8\u518C\u6A21\u578B\u3001\u4E0D\u6309\u8EAB\u4EFD\u8FC7\u6EE4\uFF0C0 \u53EA\u4F1A\u662F\u5168\u90E8\u6A21\u578B\u90FD\u6CA1\u626B\u6210\uFF08\u770B\u4E0B\u9762\u7684\u964D\u7EA7\u6876\uFF09\u2014\u2014\u4E0E\u5F53\u524D\u8EAB\u4EFD\u65E0\u5173\uFF0C\u6362\u8EAB\u4EFD\u6CA1\u7528\u3002",
|
|
26168
|
+
" \u4E0B\u4E00\u6B65\uFF1A\u8FD9\u662F\u670D\u52A1\u7AEF\u626B\u63CF\u9762\u7684\u95EE\u9898\uFF0C\u8BF7\u7BA1\u7406\u5458\u67E5\u540E\u7AEF\u65E5\u5FD7\uFF0C\u6216\u8DD1 `hcm chiron doctor` \u770B\u5E73\u53F0\u5C42\uFF1B\u5728\u90A3\u4E4B\u524D\u8FD9\u6B21\u68C0\u7D22\u7684\u7ED3\u8BBA\u662F\u300C\u4E0D\u77E5\u9053\u300D\uFF0C\u4E0D\u662F\u300C\u6CA1\u6709\u300D\u3002"
|
|
26169
|
+
);
|
|
26170
|
+
} else {
|
|
26171
|
+
lines.push(
|
|
26172
|
+
`\u67E5\u8FC7\u4E14\u4E3A\u7A7A\uFF1A\u626B\u5B8C ${num(view, "scannedCount", scanned)} \u4E2A\u6A21\u578B\uFF0C\u300C${keyword}\u300D\u4E00\u4E2A\u90FD\u6CA1\u547D\u4E2D\u3002`,
|
|
26173
|
+
" \u26A0\uFE0F score \u662F\u8BCD\u6CD5\u5339\u914D\u4E0D\u662F\u8BED\u4E49\u76F8\u4F3C\u5EA6\uFF1A\u540C\u4E49\u8BF4\u6CD5\u6CA1\u767B\u8BB0\u6210 synonyms \u65F6\u4E5F\u662F 0\uFF0C\u8FD9\u548C\u300C\u4EA7\u54C1\u91CC\u6CA1\u6709\u8FD9\u4E2A\u6A21\u578B\u300D\u540C\u5F62\u3002",
|
|
26174
|
+
` \u4E0B\u4E00\u6B65\uFF1A\u6362\u66F4\u63A5\u8FD1\u5B57\u6BB5\u6807\u7B7E / \u6A21\u578B\u540D\u7684\u8BCD\u518D\u641C\uFF1B\u4ECD\u4E3A 0 \u7528 \`hcm models\` \u62C9\u5168\u540D\u518C\u4EBA\u5DE5\u770B\u2014\u2014\u522B\u636E\u6B64\u5224\u300C\u4EA7\u54C1\u6CA1\u6709\u8FD9\u4E2A\u80FD\u529B\u300D\u3002`
|
|
26175
|
+
);
|
|
26176
|
+
}
|
|
26177
|
+
} else {
|
|
26178
|
+
hits.forEach((h, i) => {
|
|
26179
|
+
const tied = typeof h.tiedWith === "number" ? h.tiedWith > 0 ? `\u4E0E\u53E6\u5916 ${h.tiedWith} \u4E2A\u540C\u5206` : "\u5206\u6570\u552F\u4E00" : `\u540C\u5206\u60C5\u51B5 ${NOT_PROVIDED}`;
|
|
26180
|
+
const assurance = h._evidence?.assurance ? ` assurance=${h._evidence.assurance}` : "";
|
|
26181
|
+
const name = h.name && h.name !== h.modelKey ? `\uFF08${h.name}\uFF09` : "";
|
|
26182
|
+
lines.push(`${i + 1}. ${h.modelKey ?? "?"}${name} score=${h.score ?? NOT_PROVIDED} ${tied}${assurance}`);
|
|
26183
|
+
if (!Array.isArray(h.matchedOn)) {
|
|
26184
|
+
lines.push(` \u547D\u4E2D\u8BC1\u636E\uFF1A${NOT_PROVIDED}`);
|
|
26185
|
+
return;
|
|
26186
|
+
}
|
|
26187
|
+
for (const m of h.matchedOn) {
|
|
26188
|
+
const ev = m.evidence ? clip(m.evidence) : void 0;
|
|
26189
|
+
if (ev?.clipped) clipped = true;
|
|
26190
|
+
lines.push(` ${m.dimension ?? "?"} ${m.weight ?? "?"}${ev ? ` \u300C${ev.text}\u300D` : ""}${m.reason ? ` ${m.reason}` : ""}`);
|
|
26191
|
+
}
|
|
26192
|
+
if (h._evidence?.assurance && h._evidence.assurance !== "STRUCTURAL" && h._evidence.source) {
|
|
26193
|
+
lines.push(` \u26A0\uFE0F ${h._evidence.source}`);
|
|
26194
|
+
}
|
|
26195
|
+
});
|
|
26196
|
+
}
|
|
26197
|
+
lines.push("", ...renderDegraded(view));
|
|
26198
|
+
if (clipped) lines.push(`\u2139\uFE0F \u547D\u4E2D\u539F\u6587\u8D85\u8FC7 ${EVIDENCE_MAX_CHARS} \u5B57\u7684\u5DF2\u622A\u65AD\uFF08\u2026\uFF09\uFF0C\u5168\u6587\u52A0 --output json`);
|
|
26199
|
+
lines.push(
|
|
26200
|
+
"\u2139\uFE0F \u53E3\u5F84\uFF1A\u5143\u6570\u636E\u9762\uFF0C\u4E0D\u5224\u6388\u6743\u2014\u2014\u547D\u4E2D\u4E0D\u4EE3\u8868\u4F60\u80FD\u8BFB\u5B83\u7684\u6570\u636E\uFF0C0 \u547D\u4E2D\u4E5F\u4E0D\u662F\u88AB\u89D2\u8272\u88C1\u6389\u3002",
|
|
26201
|
+
"\u4E0B\u4E00\u6B65\uFF1A`hcm describe <Model>` \u770B\u5B57\u6BB5\u3001\u52A8\u4F5C\u4E0E\u901A\u7528\u589E\u5220\u6539\uFF1B`hcm chiron seed find --tenant <\u79DF\u6237> <\u8BF4\u6CD5>` \u843D\u5230 \u6A21\u578B.\u5B57\u6BB5"
|
|
26202
|
+
);
|
|
26203
|
+
return markRestLeftovers(lines).join("\n");
|
|
26204
|
+
}
|
|
26205
|
+
var NOT_PROVIDED_NEXT_STEP = "\u8FD9\u4E2A\u540E\u7AEF\u6CA1\u6709\u6309\u8BF4\u6CD5\u68C0\u7D22\u7684\u7AEF\u70B9\uFF08Core 2026-09-03 \u8D77\u624D\u6709\uFF0C#1989\uFF09\uFF1A\u7528 `hcm version` \u770B\u540E\u7AEF\u7248\u672C\uFF1B\u8FD9\u4E00\u7248\u53EA\u80FD\u9000\u56DE\u540D\u518C\u5185\u5B57\u7B26\u4E32\u5339\u914D `hcm models <\u5173\u952E\u5B57>`\uFF08\u4E0D\u5E26 --search\uFF0C\u4E0D\u6392\u5E8F\u3001\u4E0D\u7ED9\u547D\u4E2D\u8BC1\u636E\uFF09";
|
|
26206
|
+
function parseSearchArgs(keyword, args) {
|
|
26207
|
+
const kw = keyword?.trim();
|
|
26208
|
+
if (!kw) {
|
|
26209
|
+
throw new CliError54({
|
|
26210
|
+
code: CliErrorCode53.MISSING_FLAG,
|
|
26211
|
+
message: "--search \u8981\u5E26\u4E00\u4E2A\u8BF4\u6CD5\uFF1Ahcm models <\u8BF4\u6CD5> --search",
|
|
26212
|
+
context: { nextStep: "\u4F8B\u5982 `hcm models \u5DE5\u53F7 --search`\uFF1B\u53EA\u60F3\u770B\u5168\u90E8\u6A21\u578B\u540D\u518C\u53BB\u6389 --search" }
|
|
26213
|
+
});
|
|
26214
|
+
}
|
|
26215
|
+
let limit;
|
|
26216
|
+
if (args.limit !== void 0) {
|
|
26217
|
+
limit = Number(args.limit);
|
|
26218
|
+
if (!Number.isInteger(limit) || limit < 1) {
|
|
26219
|
+
throw new CliError54({
|
|
26220
|
+
code: CliErrorCode53.INVALID_ARGUMENT,
|
|
26221
|
+
message: `--limit \u5FC5\u987B\u662F\u6B63\u6574\u6570\uFF0C\u6536\u5230 ${JSON.stringify(args.limit)}`,
|
|
26222
|
+
context: { nextStep: "\u53BB\u6389 --limit \u7528\u670D\u52A1\u7AEF\u9ED8\u8BA4\uFF0810\uFF09\uFF1B\u8D8A\u754C\u65F6\u670D\u52A1\u7AEF\u6536\u655B\u5230 [1, 100] \u5E76\u5728 limitNote \u91CC\u8BF4" }
|
|
26223
|
+
});
|
|
26224
|
+
}
|
|
26225
|
+
}
|
|
26226
|
+
return { kw, ...limit !== void 0 ? { limit } : {} };
|
|
26227
|
+
}
|
|
26228
|
+
async function modelsSearch(client4, parsed, args) {
|
|
26229
|
+
const { kw, limit } = parsed;
|
|
26230
|
+
let view;
|
|
26231
|
+
try {
|
|
26232
|
+
view = await searchModels(client4.raw(), kw, limit);
|
|
26233
|
+
} catch (e) {
|
|
26234
|
+
if (e?.isAxiosError && classifyEndpointFailure(e, { modelScoped: false }).kind === "not-provided") {
|
|
26235
|
+
const f = classifyEndpointFailure(e, { modelScoped: false });
|
|
26236
|
+
throw new CliError54({
|
|
26237
|
+
code: CliErrorCode53.PROTOCOL_UNSUPPORTED,
|
|
26238
|
+
message: `${NOT_PROVIDED}\uFF1AGET ${MODEL_SEARCH_PATH} \u2192 ${f.detail}`,
|
|
26239
|
+
context: { nextStep: NOT_PROVIDED_NEXT_STEP }
|
|
26240
|
+
});
|
|
26241
|
+
}
|
|
26242
|
+
throw e;
|
|
26243
|
+
}
|
|
26244
|
+
const fmt = args.output ?? "table";
|
|
26245
|
+
if (fmt !== "table") {
|
|
26246
|
+
const notProvided = missingKeys2(view, MODEL_SEARCH_KEYS);
|
|
26247
|
+
const out = {
|
|
26248
|
+
...view,
|
|
26249
|
+
...view.nextStep ? { cliNextStep: rewriteSelfLinks(view.nextStep) } : {},
|
|
26250
|
+
...notProvided.length ? { notProvided } : {}
|
|
26251
|
+
};
|
|
26252
|
+
process.stdout.write(formatObject39(out, { format: fmt }) + "\n");
|
|
26253
|
+
} else {
|
|
26254
|
+
process.stdout.write(renderModelSearch(kw, view) + "\n");
|
|
26255
|
+
}
|
|
26256
|
+
process.exitCode = 0;
|
|
26257
|
+
}
|
|
26258
|
+
|
|
26259
|
+
// src/commands/models.ts
|
|
25609
26260
|
async function modelsCommand(keyword, args) {
|
|
25610
26261
|
try {
|
|
26262
|
+
if (args.limit !== void 0 && !args.search) {
|
|
26263
|
+
throw new CliError55({
|
|
26264
|
+
code: CliErrorCode54.INVALID_ARGUMENT,
|
|
26265
|
+
message: "--limit \u53EA\u914D\u5408 --search \u7528\uFF08\u540D\u518C\u5217\u8868\u672C\u6765\u5C31\u662F\u5168\u96C6\uFF0C\u4E0D\u622A\u65AD\uFF09",
|
|
26266
|
+
context: { nextStep: "\u8981\u6309\u8BF4\u6CD5\u68C0\u7D22\u5E76\u9650\u6761\u6570\uFF1A`hcm models <\u8BF4\u6CD5> --search --limit <n>`" }
|
|
26267
|
+
});
|
|
26268
|
+
}
|
|
26269
|
+
const parsedSearch = args.search ? parseSearchArgs(keyword, args) : void 0;
|
|
25611
26270
|
const client4 = HcmClient38.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
26271
|
+
if (parsedSearch) {
|
|
26272
|
+
await modelsSearch(client4, parsedSearch, args);
|
|
26273
|
+
return;
|
|
26274
|
+
}
|
|
25612
26275
|
const all = await client4.listModels();
|
|
25613
26276
|
const needle = keyword?.trim().toLowerCase();
|
|
25614
26277
|
const rows2 = (needle ? all.filter((m) => JSON.stringify(m).toLowerCase().includes(needle)) : all).sort((a, b) => key(a).localeCompare(key(b)));
|
|
25615
26278
|
const fmt = args.output ?? "table";
|
|
25616
26279
|
if (fmt !== "table") {
|
|
25617
|
-
process.stdout.write(
|
|
26280
|
+
process.stdout.write(formatObject40({ total: rows2.length, models: rows2 }, { format: fmt }) + "\n");
|
|
25618
26281
|
process.exitCode = 0;
|
|
25619
26282
|
return;
|
|
25620
26283
|
}
|
|
25621
26284
|
if (rows2.length === 0) {
|
|
25622
26285
|
process.stdout.write(
|
|
25623
|
-
needle ? `\u6CA1\u6709\
|
|
26286
|
+
needle ? `\u540D\u518C\u91CC\u6CA1\u6709\u5B57\u9762\u5305\u542B "${keyword}" \u7684 Model\uFF08\u5171 ${all.length} \u4E2A\u53EF\u89C1\uFF09\uFF1B\u6309\u8BF4\u6CD5\u68C0\u7D22\uFF08\u540C\u4E49\u8BCD / \u5B57\u6BB5\u6807\u7B7E / \u7528\u9014\u4E5F\u641C\uFF0C\u5E26\u547D\u4E2D\u8BC1\u636E\uFF09\u7528 \`hcm models <\u8BF4\u6CD5> --search\`\u3002
|
|
25624
26287
|
` : "\u5F53\u524D\u8EAB\u4EFD\u5728\u8FD9\u4E2A\u73AF\u5883\u770B\u4E0D\u5230\u4EFB\u4F55 Model\u3002\n"
|
|
25625
26288
|
);
|
|
25626
26289
|
process.exitCode = 0;
|
|
@@ -25636,12 +26299,12 @@ async function modelsCommand(keyword, args) {
|
|
|
25636
26299
|
process.stdout.write(`
|
|
25637
26300
|
\u5171 ${rows2.length} \u4E2A${needle ? `\uFF08\u5168\u90E8 ${all.length} \u4E2A\u4E2D\u5339\u914D\uFF09` : ""}\u3002
|
|
25638
26301
|
`);
|
|
25639
|
-
process.stdout.write("\u4E0B\u4E00\u6B65\uFF1Ahcm describe <Model> \u770B\u5B57\u6BB5\u3001\u5173\u7CFB\u4E0E Action\u3002\n");
|
|
26302
|
+
process.stdout.write("\u4E0B\u4E00\u6B65\uFF1Ahcm describe <Model> \u770B\u5B57\u6BB5\u3001\u5173\u7CFB\u4E0E Action\uFF1B\u6309\u5BA2\u6237\u8BF4\u6CD5\u627E\u3001\u8981\u547D\u4E2D\u8BC1\u636E\u7528 `hcm models <\u8BF4\u6CD5> --search`\u3002\n");
|
|
25640
26303
|
process.exitCode = 0;
|
|
25641
26304
|
return;
|
|
25642
26305
|
} catch (e) {
|
|
25643
26306
|
const err = e;
|
|
25644
|
-
if (err?.isAxiosError) exitWithError(fromAxiosError33(err, args.profile));
|
|
26307
|
+
if (err?.isAxiosError) exitWithError(fromAxiosError33(err, args.env ?? args.profile));
|
|
25645
26308
|
exitWithError(e);
|
|
25646
26309
|
}
|
|
25647
26310
|
}
|
|
@@ -25649,6 +26312,343 @@ function key(m) {
|
|
|
25649
26312
|
return typeof m.modelKey === "string" && m.modelKey ? m.modelKey : "(\u672A\u547D\u540D)";
|
|
25650
26313
|
}
|
|
25651
26314
|
|
|
26315
|
+
// src/commands/introspect.ts
|
|
26316
|
+
init_exit();
|
|
26317
|
+
init_auth_guard();
|
|
26318
|
+
import {
|
|
26319
|
+
HcmClient as HcmClient39,
|
|
26320
|
+
CliError as CliError56,
|
|
26321
|
+
CliErrorCode as CliErrorCode55,
|
|
26322
|
+
INTROSPECTION_ENVELOPE_KEYS,
|
|
26323
|
+
INTROSPECTION_PATH,
|
|
26324
|
+
classifyEndpointFailure as classifyEndpointFailure2,
|
|
26325
|
+
fetchIntrospection,
|
|
26326
|
+
formatObject as formatObject41,
|
|
26327
|
+
fromAxiosError as fromAxiosError34,
|
|
26328
|
+
missingKeys as missingKeys3
|
|
26329
|
+
} from "@hcmai/sdk";
|
|
26330
|
+
function parseLimit2(raw) {
|
|
26331
|
+
if (raw === void 0) return void 0;
|
|
26332
|
+
const n2 = Number(raw);
|
|
26333
|
+
if (!Number.isInteger(n2) || n2 < 1) {
|
|
26334
|
+
throw new CliError56({
|
|
26335
|
+
code: CliErrorCode55.INVALID_ARGUMENT,
|
|
26336
|
+
message: `--limit \u5FC5\u987B\u662F\u6B63\u6574\u6570\uFF0C\u6536\u5230 ${JSON.stringify(raw)}`,
|
|
26337
|
+
context: { nextStep: "\u53BB\u6389 --limit \u7528\u670D\u52A1\u7AEF\u9ED8\u8BA4\u6863\uFF1B\u8D8A\u754C\u65F6\u670D\u52A1\u7AEF\u4F1A\u6536\u655B\u5230\u8FB9\u754C\u5E76\u5728 truncatedBy \u91CC\u8BF4\u51FA\u5B9E\u9645\u751F\u6548\u7684\u503C" }
|
|
26338
|
+
});
|
|
26339
|
+
}
|
|
26340
|
+
return n2;
|
|
26341
|
+
}
|
|
26342
|
+
function cliCell(c2) {
|
|
26343
|
+
return cliCommandForCapability(c2.method, c2.path) ?? CLI_NOT_PROVIDED;
|
|
26344
|
+
}
|
|
26345
|
+
function renderEnvelope(view, layer2) {
|
|
26346
|
+
const missing2 = new Set(missingKeys3(view, INTROSPECTION_ENVELOPE_KEYS));
|
|
26347
|
+
const show = (k, v) => missing2.has(k) ? NOT_PROVIDED : v === null ? "null" : String(v);
|
|
26348
|
+
const lines = [
|
|
26349
|
+
`\u81EA\u7701\u9762\u5165\u53E3\u7D22\u5F15\uFF08${layer2}\uFF09\uFF1A\u5171 ${show("totalCount", view.totalCount)} \u683C\uFF0C\u672C\u6B21\u8FD4\u56DE ${show("returnedCount", view.returnedCount)} \u683C\u3002`
|
|
26350
|
+
];
|
|
26351
|
+
if (missing2.has("truncatedBy")) {
|
|
26352
|
+
lines.push(`truncatedBy\uFF1A${NOT_PROVIDED}\uFF08\u670D\u52A1\u7AEF\u6CA1\u8BF4\u8FD9\u4EFD\u662F\u4E0D\u662F\u5168\u96C6\u2014\u2014\u522B\u628A\u5B83\u5F53\u5168\u96C6\u7528\uFF09`);
|
|
26353
|
+
} else if (view.truncatedBy) {
|
|
26354
|
+
lines.push(`\u26A0\uFE0F truncatedBy\uFF1A${rewriteSelfLinks(view.truncatedBy)}`);
|
|
26355
|
+
} else {
|
|
26356
|
+
lines.push("truncatedBy\uFF1Anull\uFF08\u6CA1\u6709\u6309 limit \u622A\u65AD\uFF09");
|
|
26357
|
+
}
|
|
26358
|
+
if (missing2.has("nextStep")) lines.push(`nextStep\uFF1A${NOT_PROVIDED}`);
|
|
26359
|
+
else if (view.nextStep) lines.push(`nextStep\uFF1A${rewriteSelfLinks(view.nextStep)}`);
|
|
26360
|
+
if (missing2.has("detailWith")) lines.push(`detailWith\uFF1A${NOT_PROVIDED}`);
|
|
26361
|
+
else if (view.detailWith) lines.push(`detailWith\uFF1A${rewriteSelfLinks(view.detailWith)}`);
|
|
26362
|
+
if ([view.detailWith, view.nextStep, view.truncatedBy].some((t) => typeof t === "string" && t.includes("urlencode"))) {
|
|
26363
|
+
lines.push("\u2139\uFE0F \u670D\u52A1\u7AEF\u539F\u6587\u91CC\u300C\u5FC5\u987B urlencode\u300D\u8BF4\u7684\u662F REST \u5199\u6CD5\uFF1B\u4E0A\u9762\u6362\u597D\u7684 hcm \u547D\u4EE4\u81EA\u5DF1\u7F16\u7801\uFF0Cpath \u7167\u539F\u6837\uFF08\u4E0D\u7F16\u7801\uFF09\u6284");
|
|
26364
|
+
}
|
|
26365
|
+
return lines;
|
|
26366
|
+
}
|
|
26367
|
+
function renderSummary(view) {
|
|
26368
|
+
const caps = view.capabilities ?? [];
|
|
26369
|
+
const lines = renderEnvelope(view, "\u6458\u8981\u5C42");
|
|
26370
|
+
lines.push("");
|
|
26371
|
+
if (!Array.isArray(view.capabilities)) {
|
|
26372
|
+
lines.push(`capabilities\uFF1A${NOT_PROVIDED}`);
|
|
26373
|
+
return lines.join("\n");
|
|
26374
|
+
}
|
|
26375
|
+
for (const c2 of caps) {
|
|
26376
|
+
const blind = typeof c2.blindSpotCount === "number" ? `\u76F2\u533A ${c2.blindSpotCount}` : `\u76F2\u533A ${NOT_PROVIDED}`;
|
|
26377
|
+
lines.push(`${c2.method ?? "?"} ${c2.path ?? "?"} \xB7 ${c2.assurance ?? `assurance ${NOT_PROVIDED}`} \xB7 ${blind}`);
|
|
26378
|
+
if (c2.what) lines.push(` ${rewriteSelfLinks(c2.what)}`);
|
|
26379
|
+
lines.push(` CLI\uFF1A${cliCell(c2)}`);
|
|
26380
|
+
}
|
|
26381
|
+
lines.push(
|
|
26382
|
+
"",
|
|
26383
|
+
"\u2139\uFE0F \u67D0\u4E00\u683C\u7684\u660E\u7EC6\uFF08what \u5168\u6587\u3001\u76F2\u533A\u660E\u7EC6\u3001\u5165\u53C2\u81EA\u8FF0\uFF09\uFF1A`hcm introspect <path>`\uFF0Cpath \u7167\u4E0A\u9762\u539F\u6837\u6284\uFF08\u542B {model} \u8FD9\u7C7B\u6A21\u677F\u6BB5\uFF09",
|
|
26384
|
+
`\u2139\uFE0F \u300C${CLI_NOT_PROVIDED}\u300D= \u8FD9\u4E00\u683C\u4ECA\u5929\u53EA\u80FD\u7ECF REST \u53D6\uFF1B\u5B88\u4EA4\u4ED8\u8FB9\u754C\u65F6\u5230\u8FD9\u91CC\u505C\u4E0B\uFF0C\u8BF7\u6709\u6743\u9650\u7684\u4EBA\u505A\uFF0C\u522B\u6539\u7528 curl`
|
|
26385
|
+
);
|
|
26386
|
+
return markRestLeftovers(lines, isCapabilityHeader).join("\n");
|
|
26387
|
+
}
|
|
26388
|
+
function renderCapabilityDetail(c2, route) {
|
|
26389
|
+
const lines = [`${c2.method ?? "?"} ${c2.path ?? "?"}`, ` CLI\uFF1A${cliCell(c2)}`];
|
|
26390
|
+
lines.push(` what\uFF1A${c2.what ? rewriteSelfLinks(c2.what) : NOT_PROVIDED}`);
|
|
26391
|
+
lines.push(` assurance\uFF1A${c2.assurance ?? NOT_PROVIDED}`);
|
|
26392
|
+
if (c2._evidence) lines.push(` _evidence\uFF1Aorigin=${c2._evidence.origin ?? "?"} source=${c2._evidence.source ?? "?"}`);
|
|
26393
|
+
if (c2.guardedBy !== void 0) lines.push(` guardedBy\uFF1A${c2.guardedBy}`);
|
|
26394
|
+
if (c2.probedBy?.length) lines.push(` probedBy\uFF1A${c2.probedBy.join("\u3001")}`);
|
|
26395
|
+
if (route?.aliases?.length) lines.push(` \u522B\u540D\uFF1A${route.aliases.join("\u3001")}`);
|
|
26396
|
+
if (Array.isArray(c2.blindSpots)) {
|
|
26397
|
+
lines.push(` \u76F2\u533A\uFF08${c2.blindSpots.length}\uFF09\uFF1A`);
|
|
26398
|
+
for (const b of c2.blindSpots) {
|
|
26399
|
+
lines.push(` \xB7 \u7B54\u4E0D\u4E86\uFF1A${b.unknown ?? b.title ?? NOT_PROVIDED}`);
|
|
26400
|
+
if (b.remedy) lines.push(` \u600E\u4E48\u529E\uFF1A${rewriteSelfLinks(b.remedy)}`);
|
|
26401
|
+
}
|
|
26402
|
+
} else if (typeof c2.blindSpotCount === "number") {
|
|
26403
|
+
lines.push(` \u76F2\u533A\uFF1A${c2.blindSpotCount} \u6761\uFF08\u8FD9\u4E00\u5C42\u4E0D\u7ED9\u660E\u7EC6\uFF09`);
|
|
26404
|
+
}
|
|
26405
|
+
if (Array.isArray(c2.params)) {
|
|
26406
|
+
lines.push(` \u5165\u53C2\uFF08${c2.params.length}\uFF09\uFF1A`);
|
|
26407
|
+
for (const p of c2.params) {
|
|
26408
|
+
const dflt = p.defaultValue === null || p.defaultValue === void 0 ? "" : ` \u9ED8\u8BA4 ${typeof p.defaultValue === "string" && p.defaultValue === "" ? '""\uFF08\u7A7A\u4E32\uFF09' : String(p.defaultValue)}`;
|
|
26409
|
+
lines.push(` \xB7 ${p.name ?? "?"}\uFF08${p.in ?? "?"}${p.required ? "\uFF0C\u5FC5\u586B" : ""}${dflt}\uFF09${p.what ? `\uFF1A${rewriteSelfLinks(p.what)}` : ""}`);
|
|
26410
|
+
}
|
|
26411
|
+
}
|
|
26412
|
+
return lines;
|
|
26413
|
+
}
|
|
26414
|
+
function renderDetail(view, layer2) {
|
|
26415
|
+
const lines = renderEnvelope(view, layer2);
|
|
26416
|
+
if (!Array.isArray(view.capabilities)) {
|
|
26417
|
+
lines.push("", `capabilities\uFF1A${NOT_PROVIDED}`);
|
|
26418
|
+
return lines.join("\n");
|
|
26419
|
+
}
|
|
26420
|
+
if (!Array.isArray(view.routes)) lines.push(`routes\uFF08\u5404\u683C\u7684\u522B\u540D\uFF09\uFF1A${NOT_PROVIDED}`);
|
|
26421
|
+
const routes = Array.isArray(view.routes) ? view.routes : [];
|
|
26422
|
+
for (const c2 of view.capabilities) {
|
|
26423
|
+
const route = routes.find((r) => r.path === c2.path && r.method === c2.method);
|
|
26424
|
+
lines.push("", ...renderCapabilityDetail(c2, route));
|
|
26425
|
+
}
|
|
26426
|
+
return markRestLeftovers(lines, isCapabilityHeader).join("\n");
|
|
26427
|
+
}
|
|
26428
|
+
function jsonView(view) {
|
|
26429
|
+
const notProvided = missingKeys3(view, [...INTROSPECTION_ENVELOPE_KEYS, "capabilities"]);
|
|
26430
|
+
return {
|
|
26431
|
+
...view,
|
|
26432
|
+
...Array.isArray(view.capabilities) ? {
|
|
26433
|
+
capabilities: view.capabilities.map((c2) => ({
|
|
26434
|
+
...c2,
|
|
26435
|
+
cliCommand: cliCommandForCapability(c2.method, c2.path)?.replace(/^`([^`]+)`.*$/, "$1") ?? null
|
|
26436
|
+
}))
|
|
26437
|
+
} : {},
|
|
26438
|
+
cliNextStep: view.nextStep ? rewriteSelfLinks(view.nextStep) : null,
|
|
26439
|
+
cliDetailWith: view.detailWith ? rewriteSelfLinks(view.detailWith) : null,
|
|
26440
|
+
...notProvided.length ? { notProvided } : {}
|
|
26441
|
+
};
|
|
26442
|
+
}
|
|
26443
|
+
var NOT_PROVIDED_NEXT_STEP2 = "\u8FD9\u4E2A\u540E\u7AEF\u6CA1\u6709\u81EA\u7701\u5165\u53E3\u7D22\u5F15\uFF08Core 2026-09-03 \u8D77\u624D\u6709\uFF0C#1879 / ADR-332\uFF09\uFF1A\u7528 `hcm version` \u770B\u540E\u7AEF\u7248\u672C\uFF1B\u8FD9\u4E00\u7248\u53EA\u80FD\u9760 `hcm models` / `hcm describe <Model>` \u9010\u4E2A\u95EE";
|
|
26444
|
+
function handleError(e, args, capability) {
|
|
26445
|
+
const err = e;
|
|
26446
|
+
if (!err?.isAxiosError) exitWithError(e);
|
|
26447
|
+
const f = classifyEndpointFailure2(e, { modelScoped: false });
|
|
26448
|
+
if (f.kind === "not-provided") {
|
|
26449
|
+
exitWithError(new CliError56({
|
|
26450
|
+
code: CliErrorCode55.PROTOCOL_UNSUPPORTED,
|
|
26451
|
+
message: `${NOT_PROVIDED}\uFF1AGET ${INTROSPECTION_PATH} \u2192 ${f.detail}`,
|
|
26452
|
+
context: { nextStep: NOT_PROVIDED_NEXT_STEP2 }
|
|
26453
|
+
}));
|
|
26454
|
+
}
|
|
26455
|
+
const ce = fromAxiosError34(err, args.env);
|
|
26456
|
+
const body = err.response?.data?.error;
|
|
26457
|
+
if (capability !== void 0 && body?.code === "INTROSPECTION_PATH_NOT_FOUND") {
|
|
26458
|
+
const available = body?.details?.availablePaths;
|
|
26459
|
+
const list = Array.isArray(available) ? [...new Set(available.map(String))] : [];
|
|
26460
|
+
exitWithError(new CliError56({
|
|
26461
|
+
code: ce.code,
|
|
26462
|
+
message: `\u81EA\u7701\u7D22\u5F15\u91CC\u6CA1\u6709 ${capability} \u8FD9\u4E00\u683C`,
|
|
26463
|
+
context: {
|
|
26464
|
+
nextStep: list.length ? `\u7167\u539F\u6837\u4ECE\u8FD9 ${list.length} \u4E2A\u91CC\u9009\u4E00\u4E2A\u518D\u8DD1 \`hcm introspect <path>\`\uFF1A${list.join("\u3001")}` : "\u5148\u8DD1 `hcm introspect` \u62FF\u5168\u96C6\uFF0C\u7167 capabilities \u7684 path \u539F\u6837\u6284"
|
|
26465
|
+
},
|
|
26466
|
+
traceId: ce.traceId
|
|
26467
|
+
}));
|
|
26468
|
+
}
|
|
26469
|
+
exitWithError(ce);
|
|
26470
|
+
}
|
|
26471
|
+
async function introspectCommand(capability, args) {
|
|
26472
|
+
try {
|
|
26473
|
+
const limit = parseLimit2(args.limit);
|
|
26474
|
+
if (capability !== void 0 && !capability.trim()) {
|
|
26475
|
+
throw new CliError56({
|
|
26476
|
+
code: CliErrorCode55.INVALID_ARGUMENT,
|
|
26477
|
+
message: "capability \u4E0D\u80FD\u662F\u7A7A\u4E32",
|
|
26478
|
+
context: { nextStep: "\u4E0D\u5E26\u53C2\u6570\u8DD1 `hcm introspect` \u770B\u5168\u96C6\uFF1B\u8981\u4E00\u683C\u5C31\u7167\u5B83\u7ED9\u7684 path \u539F\u6837\u6284" }
|
|
26479
|
+
});
|
|
26480
|
+
}
|
|
26481
|
+
if (capability !== void 0 && (args.detail || limit !== void 0)) {
|
|
26482
|
+
process.stderr.write("\u2139\uFE0F \u7ED9\u4E86 capability \u65F6\u53EA\u53D6\u90A3\u4E00\u683C\uFF08\u672C\u6765\u5C31\u662F\u660E\u7EC6\u5F62\u6001\uFF09\uFF0C--detail / --limit \u4E0D\u751F\u6548\n");
|
|
26483
|
+
}
|
|
26484
|
+
const client4 = HcmClient39.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
26485
|
+
const view = await fetchIntrospection(client4.raw(), {
|
|
26486
|
+
...capability !== void 0 ? { path: capability } : {},
|
|
26487
|
+
...args.detail ? { detail: true } : {},
|
|
26488
|
+
...limit !== void 0 ? { limit } : {}
|
|
26489
|
+
});
|
|
26490
|
+
const fmt = args.output ?? "table";
|
|
26491
|
+
if (fmt !== "table") {
|
|
26492
|
+
process.stdout.write(formatObject41(jsonView(view), { format: fmt }) + "\n");
|
|
26493
|
+
} else if (capability !== void 0) {
|
|
26494
|
+
process.stdout.write(renderDetail(view, `\u5355\u683C ${shellArg(capability)}`) + "\n");
|
|
26495
|
+
} else if (args.detail) {
|
|
26496
|
+
process.stdout.write(renderDetail(view, "\u5168\u91CF\u660E\u7EC6\u5C42") + "\n");
|
|
26497
|
+
} else {
|
|
26498
|
+
process.stdout.write(renderSummary(view) + "\n");
|
|
26499
|
+
}
|
|
26500
|
+
process.exitCode = 0;
|
|
26501
|
+
} catch (e) {
|
|
26502
|
+
handleError(e, args, capability);
|
|
26503
|
+
}
|
|
26504
|
+
}
|
|
26505
|
+
|
|
26506
|
+
// src/commands/preset-origin.ts
|
|
26507
|
+
init_exit();
|
|
26508
|
+
init_auth_guard();
|
|
26509
|
+
import {
|
|
26510
|
+
HcmClient as HcmClient40,
|
|
26511
|
+
CliError as CliError57,
|
|
26512
|
+
CliErrorCode as CliErrorCode56,
|
|
26513
|
+
PRESET_ORIGIN_PATH,
|
|
26514
|
+
classifyEndpointFailure as classifyEndpointFailure3,
|
|
26515
|
+
fetchPresetOrigin,
|
|
26516
|
+
formatObject as formatObject42,
|
|
26517
|
+
fromAxiosError as fromAxiosError35,
|
|
26518
|
+
isUuid
|
|
26519
|
+
} from "@hcmai/sdk";
|
|
26520
|
+
var ORIGIN_MEANING = {
|
|
26521
|
+
SYSTEM_BASELINE: "\u5E73\u53F0\u57FA\u7EBF\u884C\uFF0C\u5F53\u524D\u79DF\u6237\u6CA1\u6539\u8FC7\u5B83",
|
|
26522
|
+
TENANT_OVERRIDE: "\u79DF\u6237\u5BF9\u5E73\u53F0\u57FA\u7EBF\u7684\u8986\u76D6",
|
|
26523
|
+
TENANT_ORIGINAL: "\u79DF\u6237\u81EA\u5DF1\u5EFA\u7684\u884C\uFF0C\u57FA\u7EBF\u91CC\u6CA1\u6709\u5BF9\u5E94\u7269",
|
|
26524
|
+
NOT_FOUND: "\u8FD9\u4E2A canonical id \u4E0D\u5728\u5F53\u524D\u79DF\u6237\u7684\u53D8\u4F53\u89C6\u56FE\u91CC",
|
|
26525
|
+
NOT_A_PRESET_MODEL: "\u8FD9\u4E2A\u6A21\u578B\u6CA1\u6709\u300C\u7CFB\u7EDF\u9884\u7F6E / \u79DF\u6237\u539F\u521B\u300D\u8FD9\u6761\u8FB9\u754C\uFF0C\u6BCF\u4E00\u884C\u90FD\u662F\u79DF\u6237\u6570\u636E"
|
|
26526
|
+
};
|
|
26527
|
+
function cliNextStepForOrigin(model, origin, id) {
|
|
26528
|
+
const idArg = id ?? "<id>";
|
|
26529
|
+
switch (origin) {
|
|
26530
|
+
case "SYSTEM_BASELINE":
|
|
26531
|
+
return `\u6539\u5B83\uFF1A\`hcm update ${model} --id ${idArg} --data '<JSON>'\` \u4F1A\u7269\u5316\u51FA\u4E00\u6761\u79DF\u6237\u8986\u76D6\uFF0C\u4E0D\u662F\u5C31\u5730\u6539\u57FA\u7EBF\uFF1B\u54EA\u4E9B\u5B57\u6BB5\u5141\u8BB8\u8986\u76D6\u7531\u6A21\u578B\u81EA\u5DF1\u58F0\u660E\uFF0C\u88AB\u62D2\u65F6\u662F 422 PRESET_FIELD_OVERRIDE_FORBIDDEN`;
|
|
26532
|
+
case "TENANT_OVERRIDE":
|
|
26533
|
+
return `\u64A4\u9500\u8986\u76D6\u3001\u56DE\u843D\u57FA\u7EBF\uFF08\u5E42\u7B49\uFF09\uFF1A\`hcm action ${model}.resetToDefault --id ${idArg}\`\uFF08\u5F53\u524D\u8EAB\u4EFD\u80FD\u4E0D\u80FD\u8C03\u770B \`hcm describe ${model}\` \u91CC resetToDefault \u90A3\u884C\u7684 grant\uFF09\uFF1B\u7EE7\u7EED\u6539\u4ECD\u8D70 \`hcm update ${model} --id ${idArg} --data '<JSON>'\``;
|
|
26534
|
+
case "TENANT_ORIGINAL":
|
|
26535
|
+
return `\u666E\u901A\u79DF\u6237\u6570\u636E\uFF1A\u5220\u9664 \`hcm delete ${model} --id ${idArg}\`\uFF1B\u5B83\u6CA1\u6709\u57FA\u7EBF\u53EF\u56DE\u843D\uFF0CresetToDefault \u5BF9\u5B83\u662F no-op`;
|
|
26536
|
+
case "NOT_FOUND":
|
|
26537
|
+
return `\u5148\u786E\u8BA4\u5B83\u8BFB\u4E0D\u8BFB\u5F97\u5230\uFF1A\`hcm query ${model} --filter '{"field":"id","op":"eq","value":"${idArg}"}'\`\uFF1B\u8BFB\u5F97\u5230\u5374\u4ECD\u662F NOT_FOUND\uFF0C\u8BF4\u660E\u5B83\u4E0D\u5728\u672C\u79DF\u6237\u4E0E __SYSTEM__ \u8FD9\u4E24\u4E2A\u4F5C\u7528\u57DF\u5185`;
|
|
26538
|
+
case "NOT_A_PRESET_MODEL":
|
|
26539
|
+
return `\u6309\u666E\u901A\u6A21\u578B\u7684\u589E\u5220\u6539\u8D70\uFF1B\u7ED3\u6784\u4E0A\u80FD\u4E0D\u80FD\u5220\u770B \`hcm describe ${model}\` \u7684\u901A\u7528\u589E\u5220\u6539\u6BB5`;
|
|
26540
|
+
default:
|
|
26541
|
+
return void 0;
|
|
26542
|
+
}
|
|
26543
|
+
}
|
|
26544
|
+
function originLine2(origin) {
|
|
26545
|
+
if (origin === void 0) return `origin=${NOT_PROVIDED}`;
|
|
26546
|
+
const meaning = ORIGIN_MEANING[origin];
|
|
26547
|
+
return meaning ? `origin=${origin}\uFF08${meaning}\uFF09` : `origin=${origin}\uFF08\u8FD9\u7248 CLI \u4E0D\u8BA4\u8BC6\u8FD9\u4E00\u6863\uFF0C\u7167\u670D\u52A1\u7AEF\u539F\u6587\u5224\uFF09`;
|
|
26548
|
+
}
|
|
26549
|
+
function renderPresetOrigin(model, view, args) {
|
|
26550
|
+
const lines = [];
|
|
26551
|
+
if (!("presetModel" in view)) {
|
|
26552
|
+
lines.push(`${model}\uFF1ApresetModel=${NOT_PROVIDED}`);
|
|
26553
|
+
} else if (view.presetModel === false) {
|
|
26554
|
+
lines.push(`${model} \u4E0D\u662F\u9884\u7F6E\u6A21\u578B\uFF08presetModel=false\uFF09\uFF0C${originLine2(view.origin)}\u3002`);
|
|
26555
|
+
const next = cliNextStepForOrigin(model, view.origin ?? "NOT_A_PRESET_MODEL");
|
|
26556
|
+
if (next) lines.push(`\u4E0B\u4E00\u6B65\uFF1A${next}`);
|
|
26557
|
+
if (view.nextStep) lines.push(`\u670D\u52A1\u7AEF\u539F\u6587\uFF1A${view.nextStep}`);
|
|
26558
|
+
if (args.id || args.includeTenantIds) {
|
|
26559
|
+
lines.push("\u2139\uFE0F \u975E\u9884\u7F6E\u6A21\u578B\u4E0D\u5206\u884C\u7684\u6765\u6E90\uFF0C--id / --include-tenant-ids \u5728\u8FD9\u91CC\u6CA1\u6709\u610F\u4E49\u2014\u2014\u5B83\u7684\u6BCF\u4E00\u884C\u90FD\u662F\u79DF\u6237\u6570\u636E");
|
|
26560
|
+
}
|
|
26561
|
+
return lines.join("\n");
|
|
26562
|
+
} else {
|
|
26563
|
+
lines.push(`${model} \u662F\u9884\u7F6E\u6A21\u578B\uFF08presetModel=true\uFF09\u3002`);
|
|
26564
|
+
}
|
|
26565
|
+
if (view.counts && typeof view.counts === "object") {
|
|
26566
|
+
const total = typeof view.totalVariantRows === "number" ? `\uFF0C\u5171 ${view.totalVariantRows} \u884C` : `\uFF0C\u603B\u884C\u6570 ${NOT_PROVIDED}`;
|
|
26567
|
+
lines.push(`\u6309\u6765\u6E90\u5206\u7EC4\uFF08\u5F53\u524D\u79DF\u6237\u7684\u53D8\u4F53\u89C6\u56FE${total}\uFF09\uFF1A`);
|
|
26568
|
+
for (const [k, v] of Object.entries(view.counts)) {
|
|
26569
|
+
lines.push(` ${k.padEnd(16)} ${String(v).padStart(5)} ${ORIGIN_MEANING[k] ?? ""}`.trimEnd());
|
|
26570
|
+
}
|
|
26571
|
+
} else {
|
|
26572
|
+
lines.push(`\u6309\u6765\u6E90\u5206\u7EC4\uFF1A${NOT_PROVIDED}`);
|
|
26573
|
+
}
|
|
26574
|
+
if (args.includeTenantIds) {
|
|
26575
|
+
if (!view.tenantIds || typeof view.tenantIds !== "object") {
|
|
26576
|
+
lines.push(`\u79DF\u6237\u81EA\u6709\u884C id\uFF1A${NOT_PROVIDED}\uFF08\u670D\u52A1\u7AEF\u65E9\u4E8E includeTenantIds\uFF0C\u53EA\u56DE\u4E86\u8BA1\u6570\uFF09`);
|
|
26577
|
+
} else {
|
|
26578
|
+
lines.push("\u79DF\u6237\u81EA\u6709\u884C id\uFF08\u4E0E\u5217\u8868\u884C\u7684 id \u540C\u4E00\u8EAB\u4EFD\uFF1B\u6761\u6570\u4E0E\u4E0A\u9762\u7684\u8BA1\u6570\u540C\u53E3\u5F84\uFF09\uFF1A");
|
|
26579
|
+
const buckets = [.../* @__PURE__ */ new Set(["TENANT_OVERRIDE", "TENANT_ORIGINAL", ...Object.keys(view.tenantIds)])];
|
|
26580
|
+
for (const k of buckets) {
|
|
26581
|
+
const ids = view.tenantIds[k];
|
|
26582
|
+
if (!Array.isArray(ids)) {
|
|
26583
|
+
lines.push(` ${k}\uFF1A${NOT_PROVIDED}${ids === void 0 ? "" : "\uFF08\u670D\u52A1\u7AEF\u7ED9\u7684\u4E0D\u662F id \u5217\u8868\uFF0C\u8BA4\u4E0D\u51FA\uFF09"}`);
|
|
26584
|
+
continue;
|
|
26585
|
+
}
|
|
26586
|
+
const list = ids.map(String);
|
|
26587
|
+
const expected = view.counts?.[k];
|
|
26588
|
+
const recon2 = typeof expected === "number" ? expected === list.length ? `\u2713 \u4E0E\u8BA1\u6570 ${expected} \u5BF9\u5F97\u4E0A` : `\u26A0\uFE0F \u4E0E\u8BA1\u6570 ${expected} \u5BF9\u4E0D\u4E0A\u2014\u2014\u522B\u62FF\u8FD9\u4EFD\u6E05\u5355\u5F53\u5168\u96C6` : `\u8BA1\u6570 ${NOT_PROVIDED}\uFF0C\u5BF9\u4E0D\u4E86\u8D26`;
|
|
26589
|
+
lines.push(` ${k}\uFF08${list.length}\uFF0C${recon2}\uFF09\uFF1A${list.length ? list.join("\u3001") : "\uFF08\u65E0\uFF09"}`);
|
|
26590
|
+
}
|
|
26591
|
+
}
|
|
26592
|
+
}
|
|
26593
|
+
if (args.id) {
|
|
26594
|
+
lines.push("", `${model} / ${view.id ?? args.id}\uFF1A${originLine2(view.origin)}`);
|
|
26595
|
+
lines.push(` \u7269\u7406\u5C42\uFF1A${Array.isArray(view.layers) ? view.layers.length ? view.layers.join(" + ") : "\uFF08\u65E0\uFF09" : NOT_PROVIDED}`);
|
|
26596
|
+
lines.push(
|
|
26597
|
+
` resetToDefaultApplicable=${"resetToDefaultApplicable" in view ? String(view.resetToDefaultApplicable) : NOT_PROVIDED}\uFF08\u7ED3\u6784\u4E0A\u8FD9\u4E00\u6863\u9002\u4E0D\u9002\u7528 resetToDefault\uFF0C\u4E0D\u662F\u4F60\u6709\u6743\u8C03\u5B83\uFF09`
|
|
26598
|
+
);
|
|
26599
|
+
const next = view.origin ? cliNextStepForOrigin(model, view.origin, args.id) : void 0;
|
|
26600
|
+
if (next) lines.push(`\u4E0B\u4E00\u6B65\uFF1A${next}`);
|
|
26601
|
+
} else {
|
|
26602
|
+
lines.push(
|
|
26603
|
+
args.includeTenantIds ? `\u4E0B\u4E00\u6B65\uFF1A\u95EE\u67D0\u4E00\u884C\u843D\u5728\u54EA\u4E00\u4FA7 \`hcm preset-origin ${model} --id <canonicalId>\`` : `\u4E0B\u4E00\u6B65\uFF1A\u95EE\u67D0\u4E00\u884C\u843D\u5728\u54EA\u4E00\u4FA7 \`hcm preset-origin ${model} --id <canonicalId>\`\uFF1B\u4E00\u6B21\u62FF\u5168\u79DF\u6237\u81EA\u6709\u884C\u7684 id \`hcm preset-origin ${model} --include-tenant-ids\``
|
|
26604
|
+
);
|
|
26605
|
+
}
|
|
26606
|
+
if (view.nextStep) lines.push(`\u670D\u52A1\u7AEF\u539F\u6587\uFF1A${view.nextStep}`);
|
|
26607
|
+
lines.push("\u2139\uFE0F \u5224\u636E\u662F\u670D\u52A1\u7AEF\u7684\u7269\u7406\u884C\u53D8\u4F53\uFF0C\u4E0D\u662F tenantId / isSystem / createById\u2014\u2014\u522B\u62FF\u90A3\u51E0\u4E2A\u5B57\u6BB5\u53BB\u731C");
|
|
26608
|
+
return lines.join("\n");
|
|
26609
|
+
}
|
|
26610
|
+
var NOT_PROVIDED_NEXT_STEP3 = "\u8FD9\u4E2A\u540E\u7AEF\u6CA1\u6709\u884C\u6765\u6E90\u7AEF\u70B9\uFF08Core 2026-09-06 \u8D77\u624D\u6709\uFF0C#2229 / issue #2179\uFF1B--include-tenant-ids \u8981 Core \u542B HCMNX-806\uFF09\uFF1A\u7528 `hcm version` \u770B\u540E\u7AEF\u7248\u672C\u3002\u8FD9\u4E00\u7248\u5224\u4E0D\u4E86\u300C\u8FD9\u4E00\u884C\u662F\u5E73\u53F0\u57FA\u7EBF\u8FD8\u662F\u79DF\u6237\u81EA\u5DF1\u7684\u300D\uFF0C\u6539\u5B83\u4E4B\u524D\u505C\u4E0B\u95EE\u4EBA\uFF0C\u522B\u62FF createById \u53BB\u731C";
|
|
26611
|
+
async function presetOriginCommand(model, args) {
|
|
26612
|
+
try {
|
|
26613
|
+
if (args.id !== void 0 && !isUuid(args.id.trim())) {
|
|
26614
|
+
throw new CliError57({
|
|
26615
|
+
code: CliErrorCode56.INVALID_ARGUMENT,
|
|
26616
|
+
message: `--id \u8981\u7684\u662F\u884C\u7684 canonical id\uFF08UUID\uFF09\uFF0C\u6536\u5230 ${JSON.stringify(args.id)}`,
|
|
26617
|
+
context: { nextStep: `\u4E0D\u77E5\u9053 id \u65F6\u5148 \`hcm preset-origin ${model} --include-tenant-ids\` \u62FF\u79DF\u6237\u81EA\u6709\u884C\u7684 id\uFF0C\u6216\u4ECE \`hcm query ${model}\` \u7684\u7ED3\u679C\u91CC\u6284 id` }
|
|
26618
|
+
});
|
|
26619
|
+
}
|
|
26620
|
+
if (args.id !== void 0 && args.includeTenantIds) {
|
|
26621
|
+
process.stderr.write("\u2139\uFE0F \u540C\u65F6\u7ED9\u4E86 --id \u4E0E --include-tenant-ids\uFF1A\u4E24\u6837\u90FD\u95EE\uFF0C\u8F93\u51FA\u91CC\u4E24\u6BB5\u90FD\u6709\n");
|
|
26622
|
+
}
|
|
26623
|
+
const client4 = HcmClient40.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
26624
|
+
const view = await fetchPresetOrigin(client4.raw(), model, {
|
|
26625
|
+
...args.id !== void 0 ? { id: args.id.trim() } : {},
|
|
26626
|
+
...args.includeTenantIds ? { includeTenantIds: true } : {}
|
|
26627
|
+
});
|
|
26628
|
+
const fmt = args.output ?? "table";
|
|
26629
|
+
if (fmt !== "table") {
|
|
26630
|
+
const origin = view.origin;
|
|
26631
|
+
const cliNextStep = origin ? cliNextStepForOrigin(model, origin, args.id?.trim()) : void 0;
|
|
26632
|
+
process.stdout.write(formatObject42({ ...view, ...cliNextStep ? { cliNextStep } : {} }, { format: fmt }) + "\n");
|
|
26633
|
+
} else {
|
|
26634
|
+
process.stdout.write(renderPresetOrigin(model, view, args) + "\n");
|
|
26635
|
+
}
|
|
26636
|
+
process.exitCode = 0;
|
|
26637
|
+
} catch (e) {
|
|
26638
|
+
const err = e;
|
|
26639
|
+
if (!err?.isAxiosError) exitWithError(e);
|
|
26640
|
+
const f = classifyEndpointFailure3(e, { modelScoped: true });
|
|
26641
|
+
if (f.kind === "not-provided") {
|
|
26642
|
+
exitWithError(new CliError57({
|
|
26643
|
+
code: CliErrorCode56.PROTOCOL_UNSUPPORTED,
|
|
26644
|
+
message: `${NOT_PROVIDED}\uFF1AGET ${PRESET_ORIGIN_PATH(model)} \u2192 ${f.detail}\uFF08\u670D\u52A1\u7AEF\u65E9\u4E8E\u8BE5\u7AEF\u70B9\uFF0C\u8DEF\u7531\u88AB\u5F53\u6210\u6309 id \u8BFB\u884C\uFF09`,
|
|
26645
|
+
context: { nextStep: NOT_PROVIDED_NEXT_STEP3 }
|
|
26646
|
+
}));
|
|
26647
|
+
}
|
|
26648
|
+
exitWithError(fromAxiosError35(err, args.env));
|
|
26649
|
+
}
|
|
26650
|
+
}
|
|
26651
|
+
|
|
25652
26652
|
// src/startup.ts
|
|
25653
26653
|
function needsLegacyProfileMigration(argv) {
|
|
25654
26654
|
const args = argv.slice(2);
|
|
@@ -25663,7 +26663,7 @@ init_error_output();
|
|
|
25663
26663
|
|
|
25664
26664
|
// src/commands/offline/guard.ts
|
|
25665
26665
|
init_state();
|
|
25666
|
-
import { CliError as
|
|
26666
|
+
import { CliError as CliError58, CliErrorCode as CliErrorCode57 } from "@hcmai/sdk";
|
|
25667
26667
|
var OFFLINE_BLOCKED = {
|
|
25668
26668
|
"chiron gap search": "\u56DE\u5916\u7F51\u540E\u8DD1 `hcm chiron gap search \u2026`",
|
|
25669
26669
|
"chiron gap status": "\u56DE\u5916\u7F51\u540E\u8DD1 `hcm chiron gap status`",
|
|
@@ -25687,8 +26687,8 @@ function assertOnlineAllowed(path49, offline2 = () => isOfflineMode()) {
|
|
|
25687
26687
|
const next = OFFLINE_BLOCKED[path49];
|
|
25688
26688
|
if (!next) return;
|
|
25689
26689
|
if (!offline2()) return;
|
|
25690
|
-
throw new
|
|
25691
|
-
code:
|
|
26690
|
+
throw new CliError58({
|
|
26691
|
+
code: CliErrorCode57.OFFLINE_UNAVAILABLE,
|
|
25692
26692
|
message: `\u300Chcm ${path49}\u300D\u8981\u8FDE\u516C\u53F8\u7F51\u7EDC\uFF0C${OFFLINE_REASON}\uFF1B\u672C\u6B21\u6CA1\u6709\u8FDE\u63A5\uFF0C\u4E5F\u6CA1\u6709\u6267\u884C`,
|
|
25693
26693
|
context: { nextStep: next, reasonCode: "offline-kit" }
|
|
25694
26694
|
});
|
|
@@ -25701,13 +26701,13 @@ import { execFileSync as execFileSync2 } from "child_process";
|
|
|
25701
26701
|
import { existsSync as existsSync14, promises as fsp11 } from "fs";
|
|
25702
26702
|
import os9 from "os";
|
|
25703
26703
|
import path38 from "path";
|
|
25704
|
-
import { CliError as
|
|
26704
|
+
import { CliError as CliError64, CliErrorCode as CliErrorCode63 } from "@hcmai/sdk";
|
|
25705
26705
|
|
|
25706
26706
|
// src/commands/offline/assemble-hcm.ts
|
|
25707
26707
|
import { existsSync as existsSync11, promises as fsp7, readFileSync as readFileSync15, realpathSync, statSync as statSync6 } from "fs";
|
|
25708
26708
|
import path32 from "path";
|
|
25709
26709
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
25710
|
-
import { CliError as
|
|
26710
|
+
import { CliError as CliError59, CliErrorCode as CliErrorCode58 } from "@hcmai/sdk";
|
|
25711
26711
|
var SKIPPED_PACKAGES = /* @__PURE__ */ new Set(["keytar"]);
|
|
25712
26712
|
function readPkg(dir) {
|
|
25713
26713
|
return JSON.parse(readFileSync15(path32.join(dir, "package.json"), "utf8"));
|
|
@@ -25731,8 +26731,8 @@ function runningCliPackageDir(from = path32.dirname(fileURLToPath2(import.meta.u
|
|
|
25731
26731
|
if (existsSync11(f) && readPkg(d).name === "@hcmai/cli") return d;
|
|
25732
26732
|
const parent = path32.dirname(d);
|
|
25733
26733
|
if (parent === d) {
|
|
25734
|
-
throw new
|
|
25735
|
-
code:
|
|
26734
|
+
throw new CliError59({
|
|
26735
|
+
code: CliErrorCode58.OFFLINE_KIT_ERROR,
|
|
25736
26736
|
message: `\u4ECE ${from} \u5411\u4E0A\u627E\u4E0D\u5230 @hcmai/cli \u7684 package.json\uFF0C\u6CA1\u6CD5\u628A hcm \u62F7\u8FDB\u79BB\u7EBF\u5305`,
|
|
25737
26737
|
context: { nextStep: "\u7528 npm \u88C5\u7684 hcm\uFF08npm i -g @hcmai/cli\uFF09\u8DD1 hcm offline build" }
|
|
25738
26738
|
});
|
|
@@ -25759,8 +26759,8 @@ function dependencyClosure(cliPkgDir) {
|
|
|
25759
26759
|
const found2 = resolvePackageDir(dir, n2);
|
|
25760
26760
|
if (!found2) {
|
|
25761
26761
|
if (optional) continue;
|
|
25762
|
-
throw new
|
|
25763
|
-
code:
|
|
26762
|
+
throw new CliError59({
|
|
26763
|
+
code: CliErrorCode58.OFFLINE_KIT_ERROR,
|
|
25764
26764
|
message: `${pkg.name ?? dir} \u4F9D\u8D56\u7684 ${n2} \u5728\u672C\u673A\u627E\u4E0D\u5230\uFF0C\u4F9D\u8D56\u6811\u4E0D\u5B8C\u6574\uFF0C\u6CA1\u6709\u51FA\u5305`,
|
|
25765
26765
|
context: { nextStep: "\u91CD\u88C5 @hcmai/cli\uFF08npm i -g @hcmai/cli\uFF09\u540E\u91CD\u8DD1 hcm offline build" }
|
|
25766
26766
|
});
|
|
@@ -25814,16 +26814,16 @@ async function assembleHcm(cliPkgDir, destDir) {
|
|
|
25814
26814
|
for (const d of dirs) await copyPackage(d, path32.join(destDir, path32.relative(root, d)));
|
|
25815
26815
|
const native = await listNativeModules(destDir);
|
|
25816
26816
|
if (native.length) {
|
|
25817
|
-
throw new
|
|
25818
|
-
code:
|
|
26817
|
+
throw new CliError59({
|
|
26818
|
+
code: CliErrorCode58.OFFLINE_KIT_ERROR,
|
|
25819
26819
|
message: `CLI \u7684\u4F9D\u8D56\u91CC\u6709\u5E73\u53F0\u76F8\u5173\u7684\u539F\u751F\u6A21\u5757\uFF0C\u62F7\u8FDB\u79BB\u7EBF\u5305\u540E\u5728\u522B\u7684\u5E73\u53F0\u4E0A\u8DD1\u4E0D\u8D77\u6765\uFF1A${native.join("\u3001")}`,
|
|
25820
26820
|
context: { nextStep: "\u62A5\u7ED9 CLI \u7EF4\u62A4\u65B9\uFF08\u79BB\u7EBF\u5305\u8981\u6C42 hcm \u7684\u8FD0\u884C\u65F6\u4F9D\u8D56\u662F\u7EAF JS\uFF09\uFF1B\u6CA1\u6709\u51FA\u5305", reasonCode: "native-module" }
|
|
25821
26821
|
});
|
|
25822
26822
|
}
|
|
25823
26823
|
const entry = path32.relative(destDir, path32.join(destDir, path32.relative(root, cliPkgDir), "dist", "index.js")).split(path32.sep).join("/");
|
|
25824
26824
|
if (!statSync6(path32.join(destDir, entry), { throwIfNoEntry: false })) {
|
|
25825
|
-
throw new
|
|
25826
|
-
code:
|
|
26825
|
+
throw new CliError59({
|
|
26826
|
+
code: CliErrorCode58.OFFLINE_KIT_ERROR,
|
|
25827
26827
|
message: `\u62F7\u8D1D\u540E\u627E\u4E0D\u5230 hcm \u5165\u53E3 ${entry}`,
|
|
25828
26828
|
context: { nextStep: "\u7528 npm \u88C5\u597D\u7684 hcm \u8DD1 hcm offline build\uFF08\u6E90\u7801\u76EE\u5F55\u8981\u5148 npm run build\uFF09" }
|
|
25829
26829
|
});
|
|
@@ -25837,14 +26837,14 @@ import { createWriteStream, promises as fsp8 } from "fs";
|
|
|
25837
26837
|
import { pipeline } from "stream/promises";
|
|
25838
26838
|
import * as yazl from "yazl";
|
|
25839
26839
|
import path33 from "path";
|
|
25840
|
-
import { CliError as
|
|
26840
|
+
import { CliError as CliError60, CliErrorCode as CliErrorCode59 } from "@hcmai/sdk";
|
|
25841
26841
|
function hasCommand(cmd) {
|
|
25842
26842
|
const probe3 = process.platform === "win32" ? spawnSync4("where", [cmd], { stdio: "ignore" }) : spawnSync4("sh", ["-c", `command -v ${cmd}`], { stdio: "ignore" });
|
|
25843
26843
|
return probe3.status === 0;
|
|
25844
26844
|
}
|
|
25845
26845
|
function missing(what, need) {
|
|
25846
|
-
return new
|
|
25847
|
-
code:
|
|
26846
|
+
return new CliError60({
|
|
26847
|
+
code: CliErrorCode59.OFFLINE_KIT_ERROR,
|
|
25848
26848
|
message: `${what}\u9700\u8981 ${need}\uFF0C\u672C\u673A\u6CA1\u6709`,
|
|
25849
26849
|
context: { nextStep: `\u88C5\u4E0A ${need} \u540E\u91CD\u8DD1 hcm offline build\uFF08macOS \u4E0E Windows 10+ \u81EA\u5E26\u7684 tar \u5373\u53EF\uFF09` }
|
|
25850
26850
|
});
|
|
@@ -25894,8 +26894,8 @@ async function zipDir(dir, prefix, out) {
|
|
|
25894
26894
|
await pipeline(zip.outputStream, createWriteStream(out));
|
|
25895
26895
|
} catch (e) {
|
|
25896
26896
|
await fsp8.rm(out, { force: true });
|
|
25897
|
-
throw new
|
|
25898
|
-
code:
|
|
26897
|
+
throw new CliError60({
|
|
26898
|
+
code: CliErrorCode59.OFFLINE_KIT_ERROR,
|
|
25899
26899
|
message: `\u6253 zip \u5305\u65F6\u8BFB\u6587\u4EF6\u5931\u8D25\uFF08${e.code ?? e.message}\uFF09\uFF1A${e.message}`,
|
|
25900
26900
|
context: { reasonCode: "zip-failed", nextStep: "\u591A\u534A\u662F\u6740\u6BD2\u8F6F\u4EF6\u9501\u4F4F\u4E86\u521A\u89E3\u51FA\u7684\u7A0B\u5E8F\u6587\u4EF6\uFF1A\u628A\u51FA\u5305\u7528\u7684\u4E34\u65F6\u76EE\u5F55\u52A0\u5165\u767D\u540D\u5355\uFF0C\u6216\u6682\u505C\u5B9E\u65F6\u9632\u62A4\u540E\u91CD\u65B0 `hcm offline build`" }
|
|
25901
26901
|
});
|
|
@@ -25915,7 +26915,7 @@ async function findFile(root, name) {
|
|
|
25915
26915
|
|
|
25916
26916
|
// src/commands/offline/components.ts
|
|
25917
26917
|
import { readFileSync as readFileSync16 } from "fs";
|
|
25918
|
-
import { CliError as
|
|
26918
|
+
import { CliError as CliError61, CliErrorCode as CliErrorCode60 } from "@hcmai/sdk";
|
|
25919
26919
|
var PLATFORMS = ["win-x64", "linux-x64", "linux-arm64"];
|
|
25920
26920
|
var NODE = "v22.23.5";
|
|
25921
26921
|
var CRUSH = "0.101.0";
|
|
@@ -25981,16 +26981,16 @@ function componentsFor(p) {
|
|
|
25981
26981
|
try {
|
|
25982
26982
|
table = JSON.parse(readFileSync16(file, "utf8"));
|
|
25983
26983
|
} catch (e) {
|
|
25984
|
-
throw new
|
|
25985
|
-
code:
|
|
26984
|
+
throw new CliError61({
|
|
26985
|
+
code: CliErrorCode60.CONFIG_PARSE_ERROR,
|
|
25986
26986
|
message: `HCM_OFFLINE_COMPONENTS_FILE=${file} \u8BFB\u4E0D\u61C2\uFF1A${e.message}`,
|
|
25987
26987
|
context: { nextStep: "\u4FEE\u597D\u8FD9\u4E2A\u6587\u4EF6\uFF0C\u6216 unset HCM_OFFLINE_COMPONENTS_FILE \u7528\u5185\u7F6E\u7684\u7EC4\u4EF6\u8868" }
|
|
25988
26988
|
});
|
|
25989
26989
|
}
|
|
25990
26990
|
const list = table[p];
|
|
25991
26991
|
if (!Array.isArray(list)) {
|
|
25992
|
-
throw new
|
|
25993
|
-
code:
|
|
26992
|
+
throw new CliError61({
|
|
26993
|
+
code: CliErrorCode60.CONFIG_PARSE_ERROR,
|
|
25994
26994
|
message: `HCM_OFFLINE_COMPONENTS_FILE=${file} \u91CC\u6CA1\u6709\u5E73\u53F0 ${p} \u7684\u7EC4\u4EF6`,
|
|
25995
26995
|
context: { nextStep: `\u8865\u4E0A "${p}": [...]\uFF0C\u6216 unset HCM_OFFLINE_COMPONENTS_FILE` }
|
|
25996
26996
|
});
|
|
@@ -26003,7 +27003,7 @@ import { createHash as createHash10 } from "crypto";
|
|
|
26003
27003
|
import { createReadStream, promises as fsp9 } from "fs";
|
|
26004
27004
|
import os7 from "os";
|
|
26005
27005
|
import path34 from "path";
|
|
26006
|
-
import { CliError as
|
|
27006
|
+
import { CliError as CliError62, CliErrorCode as CliErrorCode61 } from "@hcmai/sdk";
|
|
26007
27007
|
function offlineCacheDir() {
|
|
26008
27008
|
const xdg = process.env.XDG_CACHE_HOME?.trim();
|
|
26009
27009
|
return path34.join(xdg || path34.join(process.env.HOME ?? os7.homedir(), ".cache"), "hcm", "offline");
|
|
@@ -26054,8 +27054,8 @@ async function fetchComponent(a, opts = {}) {
|
|
|
26054
27054
|
const actual = await sha256File2(part);
|
|
26055
27055
|
if (actual !== a.sha256) {
|
|
26056
27056
|
await fsp9.rm(part, { force: true });
|
|
26057
|
-
throw new
|
|
26058
|
-
code:
|
|
27057
|
+
throw new CliError62({
|
|
27058
|
+
code: CliErrorCode61.OFFLINE_KIT_ERROR,
|
|
26059
27059
|
message: `${a.name} ${a.version} \u7684 SHA256 \u4E0D\u5BF9\uFF1A\u671F\u671B ${a.sha256}\uFF0C\u5B9E\u9645 ${actual}\uFF08${url}\uFF09\uFF1B\u6CA1\u6709\u51FA\u5305`,
|
|
26060
27060
|
context: { nextStep: "\u6362\u4E86\u955C\u50CF\u7684\u8BDD\u5148\u786E\u8BA4\u955C\u50CF\u540C\u6B65\u7684\u662F\u540C\u4E00\u4E2A\u6587\u4EF6\uFF1B\u6587\u4EF6\u88AB\u6539\u8FC7\u65F6\u4E0D\u8981\u7528\u5B83\u51FA\u5305", reasonCode: "sha256-mismatch" }
|
|
26061
27061
|
});
|
|
@@ -26064,8 +27064,8 @@ async function fetchComponent(a, opts = {}) {
|
|
|
26064
27064
|
return file;
|
|
26065
27065
|
}
|
|
26066
27066
|
function downloadFailed(a, url, why) {
|
|
26067
|
-
return new
|
|
26068
|
-
code:
|
|
27067
|
+
return new CliError62({
|
|
27068
|
+
code: CliErrorCode61.NETWORK_ERROR,
|
|
26069
27069
|
message: `\u4E0B\u8F7D ${a.name} ${a.version} \u5931\u8D25\uFF08${why}\uFF09\uFF1A${url}`,
|
|
26070
27070
|
context: {
|
|
26071
27071
|
nextStep: `\u56FD\u5185\u4E0B\u4E0D\u52A8\u65F6\u8BBE ${MIRROR_ENV[a.mirror]} \u6362\u955C\u50CF\u524D\u7F00\uFF08\u4F8B\uFF1A${a.mirror === "node" ? "HCM_OFFLINE_MIRROR_NODE=https://npmmirror.com/mirrors/node" : "HCM_OFFLINE_MIRROR_GITHUB=https://<\u955C\u50CF>/github.com\uFF0C\u955C\u50CF\u4E0B\u7684\u8DEF\u5F84\u4E0E github.com \u4E00\u81F4"}\uFF09\uFF0CSHA256 \u7167\u6837\u6BD4\u5BF9\uFF1B\u7136\u540E\u91CD\u8DD1 hcm offline build`
|
|
@@ -26307,7 +27307,7 @@ init_gaps();
|
|
|
26307
27307
|
import { existsSync as existsSync12, promises as fsp10 } from "fs";
|
|
26308
27308
|
import os8 from "os";
|
|
26309
27309
|
import path36 from "path";
|
|
26310
|
-
import { CASES_REPO_SLUG as CASES_REPO_SLUG4, CASES_REPO_URL as CASES_REPO_URL3, CliError as
|
|
27310
|
+
import { CASES_REPO_SLUG as CASES_REPO_SLUG4, CASES_REPO_URL as CASES_REPO_URL3, CliError as CliError63, CliErrorCode as CliErrorCode62, createJiraClient as createJiraClient3, METHOD_REPO_DISPLAY as METHOD_REPO_DISPLAY2, METHOD_REPO_URL as METHOD_REPO_URL2 } from "@hcmai/sdk";
|
|
26311
27311
|
init_knowledge_format();
|
|
26312
27312
|
function defaultKnowledgeDeps(log) {
|
|
26313
27313
|
return {
|
|
@@ -26445,7 +27445,7 @@ async function packCases(dest, withEvidence, deps, missing2) {
|
|
|
26445
27445
|
}
|
|
26446
27446
|
}
|
|
26447
27447
|
var KNOWLEDGE_RETRY_DELAYS_MS = [2e3, 5e3];
|
|
26448
|
-
var isTransient = (e) => e instanceof
|
|
27448
|
+
var isTransient = (e) => e instanceof CliError63 && e.code === CliErrorCode62.METHOD_SOURCE_NETWORK;
|
|
26449
27449
|
async function withRetry(item, label, dest, deps, retries, missing2, run3) {
|
|
26450
27450
|
const delays = deps.retryDelaysMs ?? KNOWLEDGE_RETRY_DELAYS_MS;
|
|
26451
27451
|
for (let n2 = 0; ; n2 += 1) {
|
|
@@ -26630,8 +27630,8 @@ async function placeComponent(a, file, p, kit, work) {
|
|
|
26630
27630
|
const need = async (name) => {
|
|
26631
27631
|
const hit = a.name === "node" && !win ? path38.join(dir, (await fsp11.readdir(dir)).find((e) => e.startsWith("node-")) ?? "", "bin", "node") : await findFile(dir, name);
|
|
26632
27632
|
if (!hit || !existsSync14(hit)) {
|
|
26633
|
-
throw new
|
|
26634
|
-
code:
|
|
27633
|
+
throw new CliError64({
|
|
27634
|
+
code: CliErrorCode63.OFFLINE_KIT_ERROR,
|
|
26635
27635
|
message: `${a.name} ${a.version} \u7684\u53D1\u884C\u5305\u91CC\u627E\u4E0D\u5230 ${name}\uFF08${a.url}\uFF09`,
|
|
26636
27636
|
context: { nextStep: "\u7EC4\u4EF6\u53D1\u884C\u5305\u7684\u7ED3\u6784\u53D8\u4E86\uFF1A\u62A5\u7ED9 CLI \u7EF4\u62A4\u65B9\u66F4\u65B0 components.ts\uFF1B\u6CA1\u6709\u51FA\u5305" }
|
|
26637
27637
|
});
|
|
@@ -26665,7 +27665,7 @@ async function placeComponent(a, file, p, kit, work) {
|
|
|
26665
27665
|
}
|
|
26666
27666
|
case "python": {
|
|
26667
27667
|
const top = path38.join(dir, "python");
|
|
26668
|
-
if (!existsSync14(top)) throw new
|
|
27668
|
+
if (!existsSync14(top)) throw new CliError64({ code: CliErrorCode63.OFFLINE_KIT_ERROR, message: `${a.url} \u89E3\u51FA\u6765\u6CA1\u6709 python/ \u76EE\u5F55`, context: { nextStep: "\u62A5\u7ED9 CLI \u7EF4\u62A4\u65B9\u66F4\u65B0 components.ts\uFF1B\u6CA1\u6709\u51FA\u5305" } });
|
|
26669
27669
|
await fsp11.rename(top, path38.join(kit, "python"));
|
|
26670
27670
|
return;
|
|
26671
27671
|
}
|
|
@@ -26715,8 +27715,8 @@ function bundledSkillRoots(cliPkgDir) {
|
|
|
26715
27715
|
}
|
|
26716
27716
|
async function runOfflineBuild(opts, deps = {}) {
|
|
26717
27717
|
if (!isPlatform(opts.platform)) {
|
|
26718
|
-
throw new
|
|
26719
|
-
code:
|
|
27718
|
+
throw new CliError64({
|
|
27719
|
+
code: CliErrorCode63.INVALID_ARGUMENT,
|
|
26720
27720
|
message: `--platform \u53EA\u80FD\u662F ${PLATFORMS.join(" / ")}\uFF0C\u6536\u5230\u300C${opts.platform}\u300D`,
|
|
26721
27721
|
context: { nextStep: `hcm offline build --platform ${PLATFORMS[0]}` }
|
|
26722
27722
|
});
|
|
@@ -26848,11 +27848,11 @@ import { spawnSync as spawnSync7 } from "child_process";
|
|
|
26848
27848
|
import { existsSync as existsSync19, promises as fsp15, readdirSync as readdirSync6, readFileSync as readFileSync20 } from "fs";
|
|
26849
27849
|
import os11 from "os";
|
|
26850
27850
|
import path43 from "path";
|
|
26851
|
-
import { CliError as
|
|
27851
|
+
import { CliError as CliError68, CliErrorCode as CliErrorCode67, hcmConfigDir as hcmConfigDir2 } from "@hcmai/sdk";
|
|
26852
27852
|
|
|
26853
27853
|
// src/commands/offline/path-env.ts
|
|
26854
27854
|
import { spawnSync as spawnSync5 } from "child_process";
|
|
26855
|
-
import { CliError as
|
|
27855
|
+
import { CliError as CliError65, CliErrorCode as CliErrorCode64 } from "@hcmai/sdk";
|
|
26856
27856
|
import { existsSync as existsSync15, promises as fsp12 } from "fs";
|
|
26857
27857
|
import os10 from "os";
|
|
26858
27858
|
import path39 from "path";
|
|
@@ -26903,8 +27903,8 @@ function addToUserPathWindows(kitBin) {
|
|
|
26903
27903
|
);
|
|
26904
27904
|
const out = `${r.stdout ?? ""}`.trim();
|
|
26905
27905
|
if (r.status === 0 && /ADDED|ALREADY/.test(out)) return out.includes("ALREADY") ? "already" : "added";
|
|
26906
|
-
throw new
|
|
26907
|
-
code:
|
|
27906
|
+
throw new CliError65({
|
|
27907
|
+
code: CliErrorCode64.OFFLINE_KIT_ERROR,
|
|
26908
27908
|
message: `\u6CA1\u80FD\u628A ${kitBin} \u52A0\u5230\u5F53\u524D\u7528\u6237\u7684 PATH\uFF08${r.error?.message ?? `powershell \u9000\u51FA\u7801 ${r.status}\uFF1A${`${r.stderr ?? ""}${out}`.trim().slice(-300)}`}\uFF09`,
|
|
26909
27909
|
context: { reasonCode: "user-path-failed", nextStep: "\u53EF\u4EE5\u5148\u53CC\u51FB\u5B89\u88C5\u76EE\u5F55\u91CC\u7684\u300C\u777F\u620E\u7EC8\u7AEF.cmd\u300D\u7528\uFF1B\u6216\u8DD1 `hcm offline setup --from <\u5B89\u88C5\u76EE\u5F55> --step path` \u91CD\u8BD5\uFF0C\u4E0D\u60F3\u6539 PATH \u5C31\u52A0 --no-path" }
|
|
26910
27910
|
});
|
|
@@ -26951,7 +27951,7 @@ async function writeCrushConfig(kitHome, cfg, now = /* @__PURE__ */ new Date())
|
|
|
26951
27951
|
}
|
|
26952
27952
|
|
|
26953
27953
|
// src/commands/offline/setup-llm.ts
|
|
26954
|
-
import { CliError as
|
|
27954
|
+
import { CliError as CliError66, CliErrorCode as CliErrorCode65 } from "@hcmai/sdk";
|
|
26955
27955
|
|
|
26956
27956
|
// src/commands/offline/http.ts
|
|
26957
27957
|
import http from "http";
|
|
@@ -26984,7 +27984,7 @@ var SMALL_CONTEXT_WINDOW = 131072;
|
|
|
26984
27984
|
var auth = (key2) => key2 ? { authorization: `Bearer ${key2}` } : {};
|
|
26985
27985
|
var normalizeBaseUrl = (u) => u.trim().replace(/\/+$/, "");
|
|
26986
27986
|
function llmError(message, nextStep, reasonCode) {
|
|
26987
|
-
return new
|
|
27987
|
+
return new CliError66({ code: CliErrorCode65.LLM_PROBE_UNAVAILABLE, message, context: { nextStep, reasonCode } });
|
|
26988
27988
|
}
|
|
26989
27989
|
async function probeModels(baseUrl, key2, ca) {
|
|
26990
27990
|
const url = `${normalizeBaseUrl(baseUrl)}/models`;
|
|
@@ -27045,7 +28045,7 @@ init_state();
|
|
|
27045
28045
|
import { spawnSync as spawnSync6 } from "child_process";
|
|
27046
28046
|
import { copyFileSync, existsSync as existsSync17, promises as fsp14, readdirSync as readdirSync5, readFileSync as readFileSync18, rmSync as rmSync2, writeFileSync as writeFileSync5 } from "fs";
|
|
27047
28047
|
import { X509Certificate } from "crypto";
|
|
27048
|
-
import { CliError as
|
|
28048
|
+
import { CliError as CliError67, CliErrorCode as CliErrorCode66 } from "@hcmai/sdk";
|
|
27049
28049
|
import path41 from "path";
|
|
27050
28050
|
import tls from "tls";
|
|
27051
28051
|
var UNTRUSTED = /* @__PURE__ */ new Set([
|
|
@@ -27117,8 +28117,8 @@ async function writeTrustBundle(kitHome, files, systemCa = null) {
|
|
|
27117
28117
|
try {
|
|
27118
28118
|
parts.push(await fsp14.readFile(f, "utf8"));
|
|
27119
28119
|
} catch (e) {
|
|
27120
|
-
throw new
|
|
27121
|
-
code:
|
|
28120
|
+
throw new CliError67({
|
|
28121
|
+
code: CliErrorCode66.OFFLINE_KIT_ERROR,
|
|
27122
28122
|
message: `\u4FE1\u4EFB\u8FC7\u7684\u8BC1\u4E66\u6587\u4EF6 ${f} \u8BFB\u4E0D\u4E86\uFF08${e.code ?? e.message}\uFF09`,
|
|
27123
28123
|
context: { reasonCode: "trust-file-missing", nextStep: "\u8DD1 `hcm offline setup --from <\u5B89\u88C5\u76EE\u5F55> --step llm` \u91CD\u65B0\u8FDE\u4E00\u6B21\uFF0C\u63D0\u95EE\u8BC1\u4E66\u65F6\u7B54 y \u5C31\u4F1A\u91CD\u65B0\u5B58\u4E0B\u6765" }
|
|
27124
28124
|
});
|
|
@@ -27493,7 +28493,7 @@ function defaultKitHome(p, env2 = process.env) {
|
|
|
27493
28493
|
}
|
|
27494
28494
|
var resume = (step2) => `hcm offline setup --from <\u89E3\u538B\u76EE\u5F55> --step ${step2}`;
|
|
27495
28495
|
function kitError(message, step2, reasonCode, nextStep) {
|
|
27496
|
-
return new
|
|
28496
|
+
return new CliError68({ code: CliErrorCode67.OFFLINE_KIT_ERROR, message, context: { nextStep: nextStep ?? `\u5904\u7406\u597D\u540E\u8DD1 \`${resume(step2)}\` \u4ECE\u8FD9\u4E00\u6B65\u7EED\u88C5`, reasonCode } });
|
|
27497
28497
|
}
|
|
27498
28498
|
function readManifest(from) {
|
|
27499
28499
|
const file = path43.join(from, "manifest.json");
|
|
@@ -27576,7 +28576,7 @@ function interactive() {
|
|
|
27576
28576
|
return async (q, def) => {
|
|
27577
28577
|
if (!process.stdin.isTTY) {
|
|
27578
28578
|
if (def !== void 0) return def;
|
|
27579
|
-
throw new
|
|
28579
|
+
throw new CliError68({ code: CliErrorCode67.INVALID_ARGUMENT, message: `\u9700\u8981\u56DE\u7B54\u300C${q}\u300D\uFF0C\u4F46\u8FD9\u91CC\u4E0D\u662F\u7EC8\u7AEF`, context: { nextStep: "\u5728\u7EC8\u7AEF\u91CC\u8FD0\u884C\u5B89\u88C5\uFF0C\u6216\u7528 hcm offline setup --help \u91CC\u7684\u53C2\u6570\u76F4\u63A5\u7ED9\u51FA" } });
|
|
27580
28580
|
}
|
|
27581
28581
|
const ans = await promptText(def ? `${q} [${def}]\uFF1A` : `${q}\uFF1A`);
|
|
27582
28582
|
return ans || def || "";
|
|
@@ -27654,7 +28654,7 @@ function readdirNames(dir) {
|
|
|
27654
28654
|
}
|
|
27655
28655
|
var STEP_LABEL2 = { verify: "\u6821\u9A8C", install: "\u5B89\u88C5", path: "PATH", llm: "\u5927\u6A21\u578B", hcm: "HCM", finish: "\u6536\u5C3E" };
|
|
27656
28656
|
function asStepError(e, step2) {
|
|
27657
|
-
if (e instanceof
|
|
28657
|
+
if (e instanceof CliError68) return e;
|
|
27658
28658
|
const code2 = e?.code;
|
|
27659
28659
|
const hint = code2 === "EPERM" || code2 === "EBUSY" || code2 === "EACCES" ? "\u5173\u6389 crush\u3001\u777F\u620E\u7EC8\u7AEF\u7A97\u53E3\u548C\u505C\u5728\u5B89\u88C5\u76EE\u5F55\u91CC\u7684\u8D44\u6E90\u7BA1\u7406\u5668\u7A97\u53E3\uFF08\u6740\u6BD2\u8F6F\u4EF6\u62E6\u622A\u65F6\u628A\u5B89\u88C5\u76EE\u5F55\u52A0\u5165\u767D\u540D\u5355\uFF09\u540E\uFF0C" : code2 === "ENOSPC" ? "\u817E\u51FA\u78C1\u76D8\u7A7A\u95F4\u540E\uFF0C" : "\u5904\u7406\u597D\u540E\uFF0C";
|
|
27660
28660
|
return kitError(
|
|
@@ -27683,7 +28683,7 @@ async function runSteps(opts, deps, cur) {
|
|
|
27683
28683
|
const from = path43.resolve(opts.from);
|
|
27684
28684
|
const start = opts.step ?? "verify";
|
|
27685
28685
|
if (!SETUP_STEPS.includes(start)) {
|
|
27686
|
-
throw new
|
|
28686
|
+
throw new CliError68({ code: CliErrorCode67.INVALID_ARGUMENT, message: `--step \u53EA\u80FD\u662F ${SETUP_STEPS.join(" / ")}\uFF0C\u6536\u5230\u300C${opts.step}\u300D`, context: { nextStep: resume("verify") } });
|
|
27687
28687
|
}
|
|
27688
28688
|
const at = (s) => SETUP_STEPS.indexOf(s) >= SETUP_STEPS.indexOf(start);
|
|
27689
28689
|
const m = readManifest(from);
|
|
@@ -27757,7 +28757,7 @@ async function runSteps(opts, deps, cur) {
|
|
|
27757
28757
|
try {
|
|
27758
28758
|
log(` \u5DF2\u52A0\u5230 ${await add(p, kitBin)}`);
|
|
27759
28759
|
} catch (e) {
|
|
27760
|
-
if (!(e instanceof
|
|
28760
|
+
if (!(e instanceof CliError68)) throw e;
|
|
27761
28761
|
notes.push(`${e.message}\uFF1B${e.context?.nextStep ?? ""}`);
|
|
27762
28762
|
log(" \u6CA1\u52A0\u4E0A\uFF0C\u7EE7\u7EED\u5F80\u4E0B\u88C5\uFF08\u7ED3\u675F\u65F6\u6709\u63D0\u793A\uFF09");
|
|
27763
28763
|
}
|
|
@@ -27803,7 +28803,7 @@ async function runSteps(opts, deps, cur) {
|
|
|
27803
28803
|
log(` \u6A21\u578B ${llm2.model}\uFF0C\u4E0A\u4E0B\u6587 ${llm2.contextWindow}${progress.ctxSource === "default" ? "\uFF08\u6A21\u578B\u670D\u52A1\u6CA1\u62A5\uFF0C\u6309\u9ED8\u8BA4\uFF09" : ""}\uFF0C\u5355\u6B21\u8F93\u51FA\u4E0A\u9650 ${llm2.maxTokens}\uFF08\u9ED8\u8BA4\uFF09`);
|
|
27804
28804
|
const tool = await probeToolCall(baseUrl, key2, llm2.model, ca);
|
|
27805
28805
|
if (!tool.ok) {
|
|
27806
|
-
throw new
|
|
28806
|
+
throw new CliError68({ code: CliErrorCode67.LLM_PROBE_UNAVAILABLE, message: `\u6A21\u578B ${llm2.model} \u4E0D\u80FD\u8C03\u7528\u5DE5\u5177\uFF0C\u777F\u620E\u9760\u5B83\u6267\u884C\u547D\u4EE4\uFF1A${tool.reason}`, context: { nextStep: TOOL_CALL_HELP, reasonCode: "no-tool-call" } });
|
|
27807
28807
|
}
|
|
27808
28808
|
log(" \u5DE5\u5177\u8C03\u7528\uFF1A\u901A\u8FC7");
|
|
27809
28809
|
const backup = await writeCrushConfig(home, renderCrushConfig({ ...llm2, apiKey: key2 }));
|
|
@@ -27951,7 +28951,7 @@ import { createHash as createHash11 } from "crypto";
|
|
|
27951
28951
|
import { createReadStream as createReadStream2, existsSync as existsSync20, promises as fsp16 } from "fs";
|
|
27952
28952
|
import os12 from "os";
|
|
27953
28953
|
import path44 from "path";
|
|
27954
|
-
import { CliError as
|
|
28954
|
+
import { CliError as CliError69, CliErrorCode as CliErrorCode68 } from "@hcmai/sdk";
|
|
27955
28955
|
init_outbox();
|
|
27956
28956
|
init_state();
|
|
27957
28957
|
var EXPORT_MANIFEST = "export.json";
|
|
@@ -28030,8 +29030,8 @@ async function runOfflineExport(opts = {}) {
|
|
|
28030
29030
|
`));
|
|
28031
29031
|
const state = readOfflineState();
|
|
28032
29032
|
if (!state?.kitHome) {
|
|
28033
|
-
throw new
|
|
28034
|
-
code:
|
|
29033
|
+
throw new CliError69({
|
|
29034
|
+
code: CliErrorCode68.OFFLINE_KIT_ERROR,
|
|
28035
29035
|
message: "\u8FD9\u53F0\u7535\u8111\u4E0D\u662F\u79BB\u7EBF\u5B89\u88C5\u5305\u88C5\u7684\uFF08\u6CA1\u6709 ~/.config/hcm/offline.json \u6216\u91CC\u9762\u6CA1\u6709\u5B89\u88C5\u76EE\u5F55\uFF09\uFF0C\u6CA1\u6709\u5F85\u4EA4\u961F\u5217\u53EF\u5BFC\u51FA",
|
|
28036
29036
|
context: { nextStep: "\u5728\u88C5\u4E86\u79BB\u7EBF\u5305\u7684\u90A3\u53F0\u5BA2\u6237\u7535\u8111\u4E0A\u8DD1 `hcm offline export`", reasonCode: "export-not-offline" }
|
|
28037
29037
|
});
|
|
@@ -28042,8 +29042,8 @@ async function runOfflineExport(opts = {}) {
|
|
|
28042
29042
|
try {
|
|
28043
29043
|
listing = await listOutbox(outboxDirOf(state.kitHome));
|
|
28044
29044
|
} catch (e) {
|
|
28045
|
-
throw new
|
|
28046
|
-
code:
|
|
29045
|
+
throw new CliError69({
|
|
29046
|
+
code: CliErrorCode68.OFFLINE_KIT_ERROR,
|
|
28047
29047
|
message: `\u5F85\u4EA4\u961F\u5217\u8BFB\u4E0D\u4E86\uFF08${e.code ?? e.message}\uFF09\uFF0C\u6CA1\u6709\u5BFC\u51FA`,
|
|
28048
29048
|
context: { nextStep: `\u68C0\u67E5 ${outboxDirOf(state.kitHome)} \u7684\u6743\u9650\u540E\u91CD\u8DD1`, reasonCode: "outbox-unreadable" }
|
|
28049
29049
|
});
|
|
@@ -28057,8 +29057,8 @@ async function runOfflineExport(opts = {}) {
|
|
|
28057
29057
|
const files = projectDir && !projectReason ? await projectFiles(projectDir) : [];
|
|
28058
29058
|
const carry = includeExported ? [...listing.pending, ...listing.exported].sort((a, b) => a.seq - b.seq) : listing.pending;
|
|
28059
29059
|
if (!carry.length && !files.length) {
|
|
28060
|
-
throw new
|
|
28061
|
-
code:
|
|
29060
|
+
throw new CliError69({
|
|
29061
|
+
code: CliErrorCode68.INVALID_ARGUMENT,
|
|
28062
29062
|
message: `\u6CA1\u6709\u53EF\u5E26\u51FA\u7684\uFF1A\u5F85\u4EA4\u961F\u5217\u662F\u7A7A\u7684\uFF08\u4EE5\u524D\u5BFC\u51FA\u8FC7 ${listing.exported.length} \u6761${listing.exported.length ? "\uFF0C\u8981\u518D\u5E26\u7528 --include-exported" : ""}\uFF09${projectReason ? `\uFF0C\u9879\u76EE\u4E5F\u4E0D\u5E26\uFF08${projectReason}\uFF09` : "\uFF0C\u9879\u76EE\u76EE\u5F55\u91CC\u4E5F\u6CA1\u6709\u6587\u4EF6"}`,
|
|
28063
29063
|
context: { nextStep: "\u79BB\u7EBF\u65F6\u63D0\u7684\u7F3A\u53E3 / \u6848\u4F8B\uFF08hcm chiron gap submit\u3001case submit\uFF09\u4F1A\u8FDB\u5F85\u4EA4\u961F\u5217\uFF0C\u6709\u4E86\u518D\u5BFC\u51FA", reasonCode: "export-empty" }
|
|
28064
29064
|
});
|
|
@@ -28162,7 +29162,7 @@ init_exit();
|
|
|
28162
29162
|
import { createHash as createHash12 } from "crypto";
|
|
28163
29163
|
import { createReadStream as createReadStream3, existsSync as existsSync21, promises as fsp18 } from "fs";
|
|
28164
29164
|
import path46 from "path";
|
|
28165
|
-
import { CliError as
|
|
29165
|
+
import { CliError as CliError70, CliErrorCode as CliErrorCode69, hcmConfigDir as hcmConfigDir3 } from "@hcmai/sdk";
|
|
28166
29166
|
|
|
28167
29167
|
// src/commands/offline/unzip.ts
|
|
28168
29168
|
import { createWriteStream as createWriteStream2, promises as fsp17 } from "fs";
|
|
@@ -28228,8 +29228,8 @@ async function extractZipSafe(file, dest) {
|
|
|
28228
29228
|
|
|
28229
29229
|
// src/commands/offline/flush.ts
|
|
28230
29230
|
init_outbox();
|
|
28231
|
-
function flushError(message, nextStep, reasonCode, code2 =
|
|
28232
|
-
return new
|
|
29231
|
+
function flushError(message, nextStep, reasonCode, code2 = CliErrorCode69.INVALID_ARGUMENT) {
|
|
29232
|
+
return new CliError70({ code: code2, message, context: { nextStep, reasonCode } });
|
|
28233
29233
|
}
|
|
28234
29234
|
var sha256File3 = (f) => new Promise((resolve8, reject) => {
|
|
28235
29235
|
const h = createHash12("sha256");
|
|
@@ -28288,7 +29288,7 @@ async function readLedger(dir) {
|
|
|
28288
29288
|
`\u8865\u4EA4\u603B\u8D26\u91CC\u7684 ${file} \u8BFB\u4E0D\u61C2\uFF08${e.message.split("\n")[0]}\uFF09\uFF0C\u6CA1\u6709\u8865\u4EA4`,
|
|
28289
29289
|
`\u5148\u770B\u4E00\u773C\u5B83\uFF08\u91CC\u9762\u662F\u4EA4\u8FC7\u7684\u5355\u53F7 / PR \u53F7\uFF09\uFF1B\u786E\u8BA4\u4E0D\u8981\u4E86\u628A\u5B83\u6539\u540D\u632A\u51FA ${dir} \u518D\u91CD\u8DD1\uFF08\u522B\u5220\uFF1A\u5220\u4E86\u5C31\u8BA4\u4E0D\u51FA\u90A3\u4E00\u6761\u4EA4\u8FC7\uFF09`,
|
|
28290
29290
|
"flush-ledger-corrupt",
|
|
28291
|
-
|
|
29291
|
+
CliErrorCode69.OFFLINE_KIT_ERROR
|
|
28292
29292
|
);
|
|
28293
29293
|
}
|
|
28294
29294
|
}
|
|
@@ -28544,7 +29544,7 @@ import { X509Certificate as X509Certificate2 } from "crypto";
|
|
|
28544
29544
|
import { existsSync as existsSync22, lstatSync, readdirSync as readdirSync7, readFileSync as readFileSync21, realpathSync as realpathSync2, rmSync as rmSync3, promises as fsp19 } from "fs";
|
|
28545
29545
|
import os13 from "os";
|
|
28546
29546
|
import path48 from "path";
|
|
28547
|
-
import { CliError as
|
|
29547
|
+
import { CliError as CliError71, CliErrorCode as CliErrorCode70, hcmConfigDir as hcmConfigDir4 } from "@hcmai/sdk";
|
|
28548
29548
|
init_outbox();
|
|
28549
29549
|
init_state();
|
|
28550
29550
|
async function scanIdentities(configDir) {
|
|
@@ -28591,7 +29591,7 @@ var realOrSelf = (p) => {
|
|
|
28591
29591
|
}
|
|
28592
29592
|
};
|
|
28593
29593
|
function uninstallError(message, reasonCode, nextStep) {
|
|
28594
|
-
return new
|
|
29594
|
+
return new CliError71({ code: CliErrorCode70.OFFLINE_KIT_ERROR, message, context: { reasonCode, nextStep } });
|
|
28595
29595
|
}
|
|
28596
29596
|
function isKitHome(dir) {
|
|
28597
29597
|
try {
|
|
@@ -29288,8 +30288,10 @@ ${DATA_PACKAGE_FIXTURE_SCHEMA_V1.properties.key_field.description}
|
|
|
29288
30288
|
${DATA_PACKAGE_FIXTURE_SCHEMA_V1.properties.key.description}
|
|
29289
30289
|
\u5B8C\u6574\u5B89\u88C5\u5305 manifest \u7684 models[].keys \u7531 hcm package install \u5904\u7406\u3002
|
|
29290
30290
|
`).action((p, opts) => importCommand(p, opts));
|
|
29291
|
-
program.command("
|
|
29292
|
-
program.command("
|
|
30291
|
+
program.command("introspect [capability]").description("\u81EA\u7701\u9762\u5165\u53E3\u7D22\u5F15\uFF1A\u73AF\u5883\u91CC\u6709\u54EA\u4E9B\u81EA\u7701\u7AEF\u70B9\u3001\u5404\u7B54\u4EC0\u4E48\u95EE\u9898\u3001\u6709\u4EC0\u4E48\u76F2\u533A\u3001CLI \u7528\u54EA\u6761\u547D\u4EE4\uFF08\u53EA\u8BFB\uFF09").option("--detail", "\u5168\u91CF\u660E\u7EC6\u5C42\uFF08\u4E00\u6B21\u53EF\u80FD\u5F88\u957F\uFF1B\u53EA\u8981\u67D0\u4E00\u683C\u5C31\u76F4\u63A5 hcm introspect <path>\uFF09").option("--limit <n>", "\u6700\u591A\u8FD4\u56DE\u51E0\u683C\uFF08\u670D\u52A1\u7AEF\u6536\u655B\u5230\u8FB9\u754C\u5E76\u5728 truncatedBy \u91CC\u8BF4\uFF09").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").addHelpText("after", "\n\u4E0D\u5E26\u53C2\u6570\u662F\u6458\u8981\u5C42\uFF1Bcapability \u7167\u6458\u8981\u5C42\u7684 path \u539F\u6837\u6284\uFF08\u542B {model} \u8FD9\u7C7B\u6A21\u677F\u6BB5\uFF09\uFF0C\u7ED9\u51FA\u90A3\u4E00\u683C\u7684\u76F2\u533A\u660E\u7EC6\u4E0E\u5165\u53C2\u81EA\u8FF0\u3002\n\u670D\u52A1\u7AEF\u7ED9\u7684\u4E0B\u4E00\u8DF3\uFF08REST \u5F62\u6001\uFF09\u4F1A\u6362\u6210 hcm \u5199\u6CD5\u518D\u6253\uFF1B\u6807\u300CCLI \u672A\u63D0\u4F9B\u300D\u7684\u683C\u4ECA\u5929\u53EA\u80FD\u7ECF REST \u53D6\uFF0C\u5B88\u4EA4\u4ED8\u8FB9\u754C\u65F6\u5230\u8FD9\u91CC\u505C\u4E0B\u95EE\u4EBA\u3002\n").action((capability, opts) => introspectCommand(capability, opts));
|
|
30292
|
+
program.command("models [keyword]").description("\u5217\u51FA\u76EE\u6807\u73AF\u5883\u6709\u54EA\u4E9B Model\uFF08describe \u7684\u4E0A\u4E00\u6B65\uFF09\uFF1B\u53EF\u5E26\u5173\u952E\u5B57\u8FC7\u6EE4\uFF0C--search \u6309\u5BA2\u6237\u8BF4\u6CD5\u68C0\u7D22\u5E76\u7ED9\u547D\u4E2D\u8BC1\u636E").option("--search", "\u6309\u8BF4\u6CD5\u68C0\u7D22\uFF08\u540C\u4E49\u8BCD / \u7528\u9014 / \u5B57\u6BB5\u6807\u7B7E / \u679A\u4E3E\u6807\u7B7E\u7B49\u516B\u7EF4\u52A0\u6743\uFF09\uFF0C\u6BCF\u4E2A\u5019\u9009\u5E26\u547D\u4E2D\u8BC1\u636E\u4E0E\u964D\u7EA7\u6876").option("--limit <n>", "\u914D\u5408 --search\uFF1A\u6700\u591A\u8FD4\u56DE\u51E0\u4E2A\u5019\u9009\uFF08\u670D\u52A1\u7AEF\u9ED8\u8BA4 10\uFF0C\u4E0A\u9650 100\uFF09").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((keyword, opts) => modelsCommand(keyword, opts));
|
|
30293
|
+
program.command("describe <Model>").description("\u67E5\u770B Model \u5143\u6570\u636E\uFF08\u5B57\u6BB5\u3001\u5173\u7CFB\u3001Action \u5217\u8868\u4E0E\u5404\u81EA\u7684 effect / \u6388\u6743\u6863\u4F4D\u3001\u901A\u7528\u589E\u5220\u6539\u80FD\u4E0D\u80FD\u7528\uFF09").option("-v, --verbose", "\u663E\u793A enum \u53D6\u503C\u57DF\u3001\u81EA\u5B9A\u4E49\u5B57\u6BB5\u7684\u63CF\u8FF0\uFF0C\u4EE5\u53CA action \u7684\u5916\u90E8\u4F9D\u8D56 / \u654F\u611F\u6570\u636E / \u786E\u8BA4\u8981\u6C42").option("--state <\u89C6\u56FE>", "Action \u96C6\u6309\u54EA\u4E2A\u89C6\u56FE\uFF08state\uFF09\u53D6\uFF1B\u4E0D\u7ED9 = \u9ED8\u8BA4\u89C6\u56FE\uFF08Action \u96C6\u53EA\u5BF9\u4E00\u4E2A\u89C6\u56FE\u6210\u7ACB\uFF09").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").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").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((m, opts) => describeCommand(m, opts));
|
|
30294
|
+
program.command("preset-origin <Model>").description("\u9884\u7F6E\u6A21\u578B\u7684\u884C\u6765\u6E90\uFF1A\u8981\u6539\u7684\u90A3\u4E00\u884C\u662F\u5E73\u53F0\u57FA\u7EBF\u3001\u79DF\u6237\u8986\u76D6\u8FD8\u662F\u79DF\u6237\u81EA\u5DF1\u5EFA\u7684\uFF08\u53EA\u8BFB\uFF09").option("--id <canonicalId>", "\u95EE\u67D0\u4E00\u884C\uFF08UUID\uFF09\u843D\u5728\u54EA\u4E00\u4FA7\u3001resetToDefault \u7ED3\u6784\u4E0A\u9002\u4E0D\u9002\u7528").option("--include-tenant-ids", "\u4E00\u6B21\u62FF\u5168\u79DF\u6237\u8986\u76D6 / \u79DF\u6237\u539F\u521B\u90A3\u51E0\u884C\u7684 id\uFF0C\u5E76\u4E0E\u8BA1\u6570\u5BF9\u8D26").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((m, opts) => presetOriginCommand(m, opts));
|
|
29293
30295
|
var interactions = program.command("interactions").description("\u770B\u89C1\u5E76\u5904\u7406\u4F1A\u8BDD\u91CC\u672A\u51B3\u7684\u6682\u505C\uFF08\u786E\u8BA4 / \u8FFD\u95EE\uFF09\u2014\u2014\u4E0D\u53D1\u65B0\u6D88\u606F\uFF0C\u76F4\u63A5\u56DE\u5230\u90A3\u4E00\u6761");
|
|
29294
30296
|
var withInteractionCommonOpts = (cmd) => {
|
|
29295
30297
|
cmd.option("--conversation <id>", "\u76EE\u6807\u4F1A\u8BDD\uFF1B\u4E0D\u4F20\u5219\u7528\u672C env \u4E0A\u4E00\u6B21\u804A\u7684\u90A3\u4E2A").option("--agent <uuid>", "\u6307\u5B9A agent UUID\uFF08\u9ED8\u8BA4\u5185\u7F6E analyst\uFF09").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atext | json", "text");
|