@hcmai/cli 0.17.0 → 0.18.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 +854 -142
- package/dist/index.js.map +1 -1
- package/dist/skills/manifest.json +8 -2
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -11,8 +11,8 @@ var __export = (target, all) => {
|
|
|
11
11
|
|
|
12
12
|
// src/utils/impersonation-lifecycle.ts
|
|
13
13
|
import { hasPendingImpersonationSessions, releasePendingImpersonationSessions } from "@hcmai/sdk";
|
|
14
|
-
function deferExitForImpersonation(
|
|
15
|
-
if (hasPendingImpersonationSessions()) throw new HandledExit(
|
|
14
|
+
function deferExitForImpersonation(code2) {
|
|
15
|
+
if (hasPendingImpersonationSessions()) throw new HandledExit(code2);
|
|
16
16
|
}
|
|
17
17
|
function cleanup() {
|
|
18
18
|
cleaning ??= (async () => {
|
|
@@ -28,10 +28,10 @@ function cleanup() {
|
|
|
28
28
|
});
|
|
29
29
|
return cleaning;
|
|
30
30
|
}
|
|
31
|
-
function prepareImpersonationExit(
|
|
31
|
+
function prepareImpersonationExit(code2, brokenStderr = false) {
|
|
32
32
|
stderrBroken ||= brokenStderr;
|
|
33
33
|
terminating ??= (async () => {
|
|
34
|
-
process.exitCode =
|
|
34
|
+
process.exitCode = code2 || process.exitCode || 0;
|
|
35
35
|
const errors = await cleanup();
|
|
36
36
|
await new Promise((resolve3) => {
|
|
37
37
|
let remaining = 2;
|
|
@@ -280,19 +280,19 @@ async function ensureAsAuth(env2, endpoint, configuredTenant, target, expectedTe
|
|
|
280
280
|
});
|
|
281
281
|
}
|
|
282
282
|
if (!local) {
|
|
283
|
-
const
|
|
283
|
+
const matches3 = [];
|
|
284
284
|
for (const name of await listIdentities(env2)) {
|
|
285
285
|
const meta2 = await loadIdentity(name);
|
|
286
|
-
if (meta2.username === target)
|
|
286
|
+
if (meta2.username === target) matches3.push({ name, meta: meta2 });
|
|
287
287
|
}
|
|
288
|
-
if (
|
|
288
|
+
if (matches3.length > 1) {
|
|
289
289
|
throw new CliError2({
|
|
290
290
|
code: CliErrorCode.INVALID_ARGUMENT,
|
|
291
|
-
message: `\u7528\u6237\u540D '${target}' \u5339\u914D\u591A\u4E2A\u672C\u673A\u8EAB\u4EFD\uFF1A${
|
|
291
|
+
message: `\u7528\u6237\u540D '${target}' \u5339\u914D\u591A\u4E2A\u672C\u673A\u8EAB\u4EFD\uFF1A${matches3.map((m) => m.name).join(", ")}`,
|
|
292
292
|
context: { nextStep: "\u7528 --as <\u5B8C\u6574\u672C\u673A\u8EAB\u4EFD\u540D> \u7CBE\u786E\u6307\u5B9A" }
|
|
293
293
|
});
|
|
294
294
|
}
|
|
295
|
-
local =
|
|
295
|
+
local = matches3[0];
|
|
296
296
|
}
|
|
297
297
|
const targetUsername = local ? local.meta.username ?? (local.name.endsWith(`@${env2}`) ? local.name.slice(0, -env2.length - 1) : void 0) : target;
|
|
298
298
|
if (!targetUsername) {
|
|
@@ -612,8 +612,8 @@ var init_TerminalRenderer = __esm({
|
|
|
612
612
|
const rendered = marked.parse(src).replace(/\n+$/, "");
|
|
613
613
|
if (!rendered) return;
|
|
614
614
|
this.ensureLineStart();
|
|
615
|
-
const
|
|
616
|
-
this.write(
|
|
615
|
+
const indented2 = this.depth > 0 ? this.indent() + rendered.replace(/\n/g, "\n" + this.indent()) : rendered;
|
|
616
|
+
this.write(indented2 + "\n\n");
|
|
617
617
|
}
|
|
618
618
|
/** 渲染收口累积正文(终态/块级边界时调)。markdown 关时正文已直写,仅校正行首。 */
|
|
619
619
|
flushChatBuffer() {
|
|
@@ -986,8 +986,8 @@ var init_StreamPresenter = __esm({
|
|
|
986
986
|
this.renderer.delegationEnd(parentToolUseId, totalDurMs, d.toolCount, d.failCount, success, nextSteps);
|
|
987
987
|
this.renderer.startSpinner("\u601D\u8003\u4E2D\u2026");
|
|
988
988
|
},
|
|
989
|
-
onTerminal: (_stopReason,
|
|
990
|
-
this.totalTokens =
|
|
989
|
+
onTerminal: (_stopReason, tokens2) => {
|
|
990
|
+
this.totalTokens = tokens2 || this.totalTokens;
|
|
991
991
|
this.pendingTools.clear();
|
|
992
992
|
for (const [k, d] of this.delgMeta) {
|
|
993
993
|
if (!d.paused) this.delgMeta.delete(k);
|
|
@@ -1117,10 +1117,10 @@ var init_StreamPresenter = __esm({
|
|
|
1117
1117
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1118
1118
|
async toError(ev) {
|
|
1119
1119
|
const fromConn = await this.opts.serverError?.() ?? null;
|
|
1120
|
-
const
|
|
1120
|
+
const code2 = ev.payload?.errorCode ?? ev.payload?.code ?? fromConn?.code;
|
|
1121
1121
|
const message = ev.payload?.message ?? fromConn?.message;
|
|
1122
1122
|
const err = new Error(message ?? "stream failed");
|
|
1123
|
-
err.code =
|
|
1123
|
+
err.code = code2 ?? CliErrorCode16.STREAM_FAILED_NO_SERVER_CODE;
|
|
1124
1124
|
err.traceId = ev.traceId;
|
|
1125
1125
|
return err;
|
|
1126
1126
|
}
|
|
@@ -2404,8 +2404,8 @@ function launchBrowser(url, platform = process.platform, onFailure) {
|
|
|
2404
2404
|
child.on("error", () => {
|
|
2405
2405
|
onFailure?.();
|
|
2406
2406
|
});
|
|
2407
|
-
child.once("exit", (
|
|
2408
|
-
if (
|
|
2407
|
+
child.once("exit", (code2) => {
|
|
2408
|
+
if (code2 !== null && code2 !== 0) onFailure?.();
|
|
2409
2409
|
});
|
|
2410
2410
|
child.unref();
|
|
2411
2411
|
}
|
|
@@ -2496,20 +2496,20 @@ function validateCliLoginEnvironment(endpoint, frontend) {
|
|
|
2496
2496
|
}
|
|
2497
2497
|
function cancellation() {
|
|
2498
2498
|
const controller = new AbortController();
|
|
2499
|
-
let
|
|
2499
|
+
let code2;
|
|
2500
2500
|
const onInt = () => {
|
|
2501
|
-
|
|
2501
|
+
code2 = 130;
|
|
2502
2502
|
controller.abort();
|
|
2503
2503
|
};
|
|
2504
2504
|
const onTerm = () => {
|
|
2505
|
-
|
|
2505
|
+
code2 = 143;
|
|
2506
2506
|
controller.abort();
|
|
2507
2507
|
};
|
|
2508
2508
|
process.on("SIGINT", onInt);
|
|
2509
2509
|
process.on("SIGTERM", onTerm);
|
|
2510
2510
|
return {
|
|
2511
2511
|
controller,
|
|
2512
|
-
error: (error) =>
|
|
2512
|
+
error: (error) => code2 === void 0 ? error : new HandledExit(code2),
|
|
2513
2513
|
dispose: () => {
|
|
2514
2514
|
process.removeListener("SIGINT", onInt);
|
|
2515
2515
|
process.removeListener("SIGTERM", onTerm);
|
|
@@ -2643,10 +2643,10 @@ async function beginBrowserLogin(input) {
|
|
|
2643
2643
|
}
|
|
2644
2644
|
const keys = [...url.searchParams.keys()];
|
|
2645
2645
|
const returnedState = url.searchParams.get("state") ?? "";
|
|
2646
|
-
const
|
|
2646
|
+
const code2 = url.searchParams.get("code");
|
|
2647
2647
|
const denied = url.searchParams.get("error");
|
|
2648
2648
|
const validState = Buffer.byteLength(returnedState) === Buffer.byteLength(state) && timingSafeEqual(Buffer.from(returnedState), Buffer.from(state));
|
|
2649
|
-
if (!validState || keys.length !== 2 || new Set(keys).size !== keys.length || keys.some((key2) => !["state", "code", "error"].includes(key2)) || !
|
|
2649
|
+
if (!validState || keys.length !== 2 || new Set(keys).size !== keys.length || keys.some((key2) => !["state", "code", "error"].includes(key2)) || !code2 && denied !== "access_denied" || code2 !== null && denied !== null) {
|
|
2650
2650
|
reply(response, 400, "\u56DE\u8C03\u6821\u9A8C\u5931\u8D25\uFF0C\u8BF7\u7EE7\u7EED\u539F\u6388\u6743\u6D41\u7A0B");
|
|
2651
2651
|
return;
|
|
2652
2652
|
}
|
|
@@ -2669,7 +2669,7 @@ async function beginBrowserLogin(input) {
|
|
|
2669
2669
|
pendingResponse = response;
|
|
2670
2670
|
void exchangeBrowserAuthorization({
|
|
2671
2671
|
...input,
|
|
2672
|
-
authorizationCode:
|
|
2672
|
+
authorizationCode: code2,
|
|
2673
2673
|
codeVerifier: verifier,
|
|
2674
2674
|
redirectUri,
|
|
2675
2675
|
deadline,
|
|
@@ -6006,14 +6006,14 @@ function describeLlmTraceEmpty(convId, envelope) {
|
|
|
6006
6006
|
return lines;
|
|
6007
6007
|
}
|
|
6008
6008
|
const facts = [];
|
|
6009
|
-
const
|
|
6009
|
+
const code2 = asText(envelope.code);
|
|
6010
6010
|
const reason = envelopeReason(envelope);
|
|
6011
6011
|
const nextStep = asText(envelope.nextStep);
|
|
6012
6012
|
const tenantId = asText(asRecord2(envelope.scope)?.tenantId);
|
|
6013
6013
|
const visible = asRecord2(envelope.conversation)?.visible;
|
|
6014
6014
|
const retention = asText(asRecord2(envelope.capture)?.retention);
|
|
6015
6015
|
const writerLine = writerCountsLine(envelope);
|
|
6016
|
-
if (
|
|
6016
|
+
if (code2) lines.push(`code: ${code2}`);
|
|
6017
6017
|
if (reason) lines.push(`reason: ${unfold(reason)}`);
|
|
6018
6018
|
if (tenantId) facts.push(`tenant ${tenantId}`);
|
|
6019
6019
|
if (typeof visible === "boolean") facts.push(`conversation: ${visible ? "visible" : "not visible"}`);
|
|
@@ -11943,8 +11943,8 @@ function parseVerifyResult(raw) {
|
|
|
11943
11943
|
context: { nextStep: "pass = \u539F\u6545\u969C\u5728\u76EE\u6807\u73AF\u5883\u4E0D\u518D\u51FA\u73B0\uFF1Bfail = \u4ECD\u7136\u590D\u73B0\u6216\u9A8C\u51FA\u6CA1\u901A\u8FC7\u7684\uFF1Bpartial = \u53EA\u9A8C\u4E86\u4E00\u90E8\u5206\u3001\u9A8C\u8FC7\u7684\u90FD\u901A\u8FC7\uFF08\u4E0D\u5173\u5355\uFF09\u3002" }
|
|
11944
11944
|
});
|
|
11945
11945
|
}
|
|
11946
|
-
function verifyFailure(reasonCode,
|
|
11947
|
-
return new CliError26({ code, message: `${message}${WRITTEN_TAG[written]}`, context: { reasonCode, written, nextStep, ...extra }, cause });
|
|
11946
|
+
function verifyFailure(reasonCode, code2, written, message, nextStep, extra = {}, cause) {
|
|
11947
|
+
return new CliError26({ code: code2, message: `${message}${WRITTEN_TAG[written]}`, context: { reasonCode, written, nextStep, ...extra }, cause });
|
|
11948
11948
|
}
|
|
11949
11949
|
function who(u) {
|
|
11950
11950
|
if (!u) return "\uFF08\u5355\u4E0A\u6CA1\u6709\uFF09";
|
|
@@ -12476,7 +12476,7 @@ async function gapVerifyCommand(ref, args, deps = defaultDeps) {
|
|
|
12476
12476
|
init_auth_guard();
|
|
12477
12477
|
import { promises as fs12 } from "fs";
|
|
12478
12478
|
import path14 from "path";
|
|
12479
|
-
import
|
|
12479
|
+
import axios8 from "axios";
|
|
12480
12480
|
import {
|
|
12481
12481
|
CliError as CliError30,
|
|
12482
12482
|
CliErrorCode as CliErrorCode31,
|
|
@@ -13920,11 +13920,11 @@ function judgmentRefFor(checkId) {
|
|
|
13920
13920
|
function pass(summary, extra = {}) {
|
|
13921
13921
|
return { level: "PASS", summary, ...extra };
|
|
13922
13922
|
}
|
|
13923
|
-
function found(
|
|
13924
|
-
return { level: "FOUND", code, summary: summary ??
|
|
13923
|
+
function found(code2, summary, extra = {}) {
|
|
13924
|
+
return { level: "FOUND", code: code2, summary: summary ?? code2, ...extra };
|
|
13925
13925
|
}
|
|
13926
|
-
function unknown(
|
|
13927
|
-
return { level: "UNDETERMINED", code, summary: summary ??
|
|
13926
|
+
function unknown(code2, summary, extra = {}) {
|
|
13927
|
+
return { level: "UNDETERMINED", code: code2, summary: summary ?? code2, reason: "SOURCE_UNAVAILABLE", ...extra };
|
|
13928
13928
|
}
|
|
13929
13929
|
function safeError(error) {
|
|
13930
13930
|
const message = error instanceof Error ? `${error.name}: ${error.message}` : String(error);
|
|
@@ -14094,8 +14094,8 @@ var boundary = async (ctx) => {
|
|
|
14094
14094
|
var method = async (ctx) => {
|
|
14095
14095
|
const status = await ctx.services.inspectMethod(ctx.root);
|
|
14096
14096
|
if (status.verdict === "ok") return pass(status.detail);
|
|
14097
|
-
const
|
|
14098
|
-
return (
|
|
14097
|
+
const code2 = status.detail.startsWith("\u672A\u5B89\u88C5") ? "METHOD_NOT_INSTALLED" : status.detail.startsWith("\u672C\u673A\u526F\u672C") ? "METHOD_COPY_MISMATCH" : status.detail.startsWith("\u7248\u672C\u843D\u540E") ? "METHOD_OUTDATED" : "METHOD_UNCHECKED";
|
|
14098
|
+
return (code2 === "METHOD_UNCHECKED" ? unknown : found)(code2, status.detail, { note: status.nextStep });
|
|
14099
14099
|
};
|
|
14100
14100
|
function caseFailureAdvice(reason, timedOut) {
|
|
14101
14101
|
if (timedOut || /ECONN\w*|ENOTFOUND|EAI_AGAIN|ETIMEDOUT|fetch failed|socket|TLS/i.test(reason ?? "")) return "\u67E5\u7F51\u7EDC\u6216\u4EE3\u7406\u540E\u91CD\u8DD1";
|
|
@@ -14117,9 +14117,9 @@ var cases = async (ctx) => {
|
|
|
14117
14117
|
var jira = async (ctx) => {
|
|
14118
14118
|
const status = await ctx.services.inspectJira({ httpTimeoutMs: 8e3 });
|
|
14119
14119
|
if (status.ok) return pass(`${status.who || "\u5DF2\u8FDE\u63A5"}\uFF0CJira \u9879\u76EE\u53EF\u89C1\uFF08\u53EA\u8BFB\u63A2\u6D3B\uFF09`);
|
|
14120
|
-
const
|
|
14121
|
-
const undetermined = ["JIRA_SERVER_ERROR", "JIRA_UNREACHABLE", "JIRA_TOKEN_UNREADABLE"].includes(
|
|
14122
|
-
return (undetermined ? unknown : found)(
|
|
14120
|
+
const code2 = status.code ?? (status.tokenReadError ? "JIRA_TOKEN_UNREADABLE" : "JIRA_UNREACHABLE");
|
|
14121
|
+
const undetermined = ["JIRA_SERVER_ERROR", "JIRA_UNREACHABLE", "JIRA_TOKEN_UNREADABLE"].includes(code2);
|
|
14122
|
+
return (undetermined ? unknown : found)(code2, void 0, {
|
|
14123
14123
|
note: [status.reason, status.nextStep, !status.code ? "\u672A\u80FD\u5224\u522B\u5931\u8D25\u7C7B\u578B" : void 0].filter(Boolean).join("\uFF1B")
|
|
14124
14124
|
});
|
|
14125
14125
|
};
|
|
@@ -14127,8 +14127,283 @@ var localChecks = { project, credential, version, installed, fresh, boundary, me
|
|
|
14127
14127
|
|
|
14128
14128
|
// src/commands/doctor/connect-checks.ts
|
|
14129
14129
|
init_auth_guard();
|
|
14130
|
-
import
|
|
14130
|
+
import axios7 from "axios";
|
|
14131
14131
|
import { CliError as CliError29, probeDoctorEndpoint, probeDoctorLayer, layerDetail, toPrincipal as toPrincipal3 } from "@hcmai/sdk";
|
|
14132
|
+
|
|
14133
|
+
// src/commands/doctor/server-report.ts
|
|
14134
|
+
import axios6 from "axios";
|
|
14135
|
+
import { classifyStatus } from "@hcmai/sdk";
|
|
14136
|
+
var fullScope = { stage: null, only: [], skip: [], active: false };
|
|
14137
|
+
function serverCatalogKnown(catalog, report) {
|
|
14138
|
+
return !!catalog && !!report && catalog.catalogRevision != null && report.catalogRevision != null;
|
|
14139
|
+
}
|
|
14140
|
+
function catalogChanged(catalog, report) {
|
|
14141
|
+
return serverCatalogKnown(catalog, report) && catalog.catalogRevision !== report.catalogRevision;
|
|
14142
|
+
}
|
|
14143
|
+
function expectedServerIds(catalog, report, requested = fullScope) {
|
|
14144
|
+
const disabled = new Set(report.scope?.policyDisabled?.map((row) => row.id));
|
|
14145
|
+
return new Set(catalog.checks.filter((row) => !disabled.has(row.id) && (!requested.stage || Array.isArray(row.stages) && row.stages.some((s) => s.toLowerCase() === requested.stage?.toLowerCase())) && (!requested.only.length || requested.only.some((t) => row.id.startsWith(t))) && !requested.skip.some((t) => row.id.startsWith(t))).map((row) => row.id));
|
|
14146
|
+
}
|
|
14147
|
+
var object = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
14148
|
+
function parseCatalog(body) {
|
|
14149
|
+
if (!object(body) || !Array.isArray(body.checks) || !Array.isArray(body.reservedCodes) || !(typeof body.catalogRevision === "string" || body.catalogRevision === null) || !object(body.tenantCatalog)) return void 0;
|
|
14150
|
+
if (!body.checks.every((c2) => object(c2) && typeof c2.id === "string")) return void 0;
|
|
14151
|
+
return body;
|
|
14152
|
+
}
|
|
14153
|
+
var requestServerReport = async (endpoint, token, timeoutMs, budgetMs, signal, scope = fullScope) => {
|
|
14154
|
+
const options = {
|
|
14155
|
+
baseURL: endpoint,
|
|
14156
|
+
timeout: timeoutMs,
|
|
14157
|
+
signal,
|
|
14158
|
+
maxRedirects: 0,
|
|
14159
|
+
validateStatus: () => true,
|
|
14160
|
+
headers: { Accept: "application/json", ...token ? { Authorization: `Bearer ${token}` } : {} }
|
|
14161
|
+
};
|
|
14162
|
+
const range = {
|
|
14163
|
+
...scope.stage ? { stage: scope.stage } : {},
|
|
14164
|
+
...scope.only.length ? { only: scope.only.join(",") } : {},
|
|
14165
|
+
...scope.skip.length ? { skip: scope.skip.join(",") } : {}
|
|
14166
|
+
};
|
|
14167
|
+
const res = scope.active ? await axios6.post("/api/system/health/report", { active: true, budgetMs, ...range }, options) : await axios6.get("/api/system/health/report", { ...options, params: { budgetMs, ...range } });
|
|
14168
|
+
return {
|
|
14169
|
+
status: res.status,
|
|
14170
|
+
body: res.data,
|
|
14171
|
+
error: classifyStatus(res.status),
|
|
14172
|
+
headers: Object.fromEntries(Object.entries(res.headers).map(([k, v]) => [k.toLowerCase(), String(v)]))
|
|
14173
|
+
};
|
|
14174
|
+
};
|
|
14175
|
+
function httpNote(out) {
|
|
14176
|
+
return `HTTP ${out.status < 0 ? "\u672A\u53D6\u5F97\u54CD\u5E94" : out.status}${out.headers["x-trace-id"] ? ` \xB7 traceId=${out.headers["x-trace-id"]}` : ""}`;
|
|
14177
|
+
}
|
|
14178
|
+
function throttleNote(out) {
|
|
14179
|
+
const error = object(out.body) && object(out.body.error) ? out.body.error : void 0;
|
|
14180
|
+
const details = object(error?.details) ? error.details : void 0;
|
|
14181
|
+
const retryAfter = out.headers["retry-after"] || details?.retryAfter;
|
|
14182
|
+
return `${httpNote(out)} \xB7 ${retryAfter !== void 0 && retryAfter !== null ? `retryAfter=${retryAfter}` : "\u670D\u52A1\u7AEF\u672A\u63D0\u4F9B retryAfter"}${typeof error?.next_step === "string" ? `\uFF1B${error.next_step}` : ""}`;
|
|
14183
|
+
}
|
|
14184
|
+
function reportEnvelopeError(body) {
|
|
14185
|
+
if (!object(body)) return "\u6B63\u6587\u5FC5\u987B\u662F\u5BF9\u8C61";
|
|
14186
|
+
if (body.schemaVersion === void 0 || body.schemaVersion === null) return "\u7F3A\u5C11 schemaVersion";
|
|
14187
|
+
if (body.schemaVersion !== 1) return `schemaVersion=${String(body.schemaVersion)} \u4E0D\u53D7\u652F\u6301\uFF1B\u5347\u7EA7 CLI`;
|
|
14188
|
+
for (const field of ["results", "scopeIds"]) if (!Array.isArray(body[field])) return `${field} \u5FC5\u987B\u662F\u6570\u7EC4`;
|
|
14189
|
+
for (const field of ["totalCount", "returnedCount"]) if (!Number.isInteger(body[field])) return `${field} \u5FC5\u987B\u662F\u6574\u6570`;
|
|
14190
|
+
for (const [i, row] of body.results.entries()) {
|
|
14191
|
+
if (!object(row) || typeof row.checkId !== "string") return `results[${i}].checkId \u5FC5\u987B\u662F\u5B57\u7B26\u4E32`;
|
|
14192
|
+
if (!["platform", "tenant"].includes(String(row.layer))) return `results[${i}].layer \u5FC5\u987B\u662F platform / tenant`;
|
|
14193
|
+
}
|
|
14194
|
+
if (body.scope !== void 0 && !object(body.scope)) return "scope \u5FC5\u987B\u662F\u5BF9\u8C61";
|
|
14195
|
+
const disabled = object(body.scope) ? body.scope.policyDisabled : void 0;
|
|
14196
|
+
if (disabled !== void 0 && !Array.isArray(disabled)) return "scope.policyDisabled \u5FC5\u987B\u662F\u6570\u7EC4";
|
|
14197
|
+
for (const [i, row] of (disabled ?? []).entries())
|
|
14198
|
+
if (!object(row) || typeof row.id !== "string" || typeof row.cause !== "string") return `scope.policyDisabled[${i}] \u987B\u542B\u5B57\u7B26\u4E32 id \u4E0E cause`;
|
|
14199
|
+
return void 0;
|
|
14200
|
+
}
|
|
14201
|
+
function failedReport(out, env2, as) {
|
|
14202
|
+
const note = httpNote(out);
|
|
14203
|
+
if (out.status === 429) return unknown("REPORT_THROTTLED", "\u670D\u52A1\u7AEF\u4F53\u68C0\u63A5\u53E3\u8BF7\u6C42\u88AB\u9650\u6D41", { note: throttleNote(out) });
|
|
14204
|
+
if ([401, 403].includes(out.status)) return unknown("REPORT_UNAUTHORIZED", "\u670D\u52A1\u7AEF\u4F53\u68C0\u63A5\u53E3\u8BF7\u6C42\u6743\u9650\u4E0D\u8DB3", {
|
|
14205
|
+
reason: "PERMISSION_DENIED",
|
|
14206
|
+
note: `${note}${as ? `\uFF1B${env2.proxied ? "\u4F7F\u7528\u4EE3\u7406 token" : "\u4F7F\u7528\u672C\u673A token"}` : ""}`,
|
|
14207
|
+
nextStep: codeStep("REPORT_UNAUTHORIZED", env2.name)
|
|
14208
|
+
});
|
|
14209
|
+
if (out.status >= 500 || out.error === "network") return unknown("REPORT_UNAVAILABLE", "\u670D\u52A1\u7AEF\u4F53\u68C0\u62A5\u544A\u6682\u4E0D\u53EF\u7528\uFF1B\u7A0D\u540E\u91CD\u8BD5", { note });
|
|
14210
|
+
if (out.status !== 200) return unknown("REPORT_MALFORMED", "\u670D\u52A1\u7AEF\u4F53\u68C0\u63A5\u53E3\u8FD4\u56DE\u975E\u9884\u671F\u72B6\u6001", {
|
|
14211
|
+
reason: "EVALUATOR_ERROR",
|
|
14212
|
+
note: `${note}\uFF1B${(typeof out.body === "string" ? out.body : JSON.stringify(out.body) ?? "").slice(0, 200)}`
|
|
14213
|
+
});
|
|
14214
|
+
const invalid3 = reportEnvelopeError(out.body);
|
|
14215
|
+
if (invalid3) return unknown("REPORT_MALFORMED", "\u670D\u52A1\u7AEF\u4F53\u68C0\u62A5\u544A\u4FE1\u5C01\u4E0D\u5408\u6CD5", { reason: "EVALUATOR_ERROR", note: `${note}\uFF1B${invalid3}` });
|
|
14216
|
+
return void 0;
|
|
14217
|
+
}
|
|
14218
|
+
function placeholderRows(ctx, env2, observation, duration = 0) {
|
|
14219
|
+
env2.report.server.verdict = null;
|
|
14220
|
+
return SERVER_PLACEHOLDERS.filter((d) => !ctx.scope || ctx.scope.serverLayers.has(d.layer)).map((descriptor2) => makeResult(
|
|
14221
|
+
descriptor2,
|
|
14222
|
+
observation,
|
|
14223
|
+
env2.name,
|
|
14224
|
+
true,
|
|
14225
|
+
ctx.requestedAt,
|
|
14226
|
+
duration,
|
|
14227
|
+
codeStep(observation.code ?? "REPORT_UNAVAILABLE", env2.name)
|
|
14228
|
+
));
|
|
14229
|
+
}
|
|
14230
|
+
function verdictViolation(row) {
|
|
14231
|
+
const v = row.verdict, c2 = v?.coverage;
|
|
14232
|
+
if (v === void 0 || v === null) return "verdict \u7F3A\u5931";
|
|
14233
|
+
if (typeof v !== "object" || Array.isArray(v)) return "verdict \u4E0D\u662F\u5BF9\u8C61";
|
|
14234
|
+
if (!["PASS", "FOUND", "UNDETERMINED", "NOT_RUN", "NOT_APPLICABLE"].includes(v.level)) return `level=${String(v.level)} \u4E0D\u5728\u4E94\u6863`;
|
|
14235
|
+
if (v.level === "FOUND" && !["CRITICAL", "WARN"].includes(v.grade ?? "")) return "FOUND \u7F3A grade \u6216 grade \u4E0D\u662F CRITICAL / WARN";
|
|
14236
|
+
if (["UNDETERMINED", "NOT_RUN"].includes(v.level) && (typeof v.reason !== "string" || !v.reason.trim())) return `${v.level} \u7F3A reason`;
|
|
14237
|
+
if (v.level === "PASS" && (!c2 || c2.expected == null || c2.evaluated + (c2.notApplicable ?? 0) !== c2.expected || c2.missing + c2.failed !== 0 || !(c2.evaluated > 0 || c2.expected === 0))) return "PASS \u6CA1\u6570\u6EE1";
|
|
14238
|
+
if (v.level === "NOT_APPLICABLE" && !!c2 && c2.missing + c2.failed > 0) return "NOT_APPLICABLE \u5E26\u7F3A\u53E3";
|
|
14239
|
+
return void 0;
|
|
14240
|
+
}
|
|
14241
|
+
function reconcileReport(ctx, env2, report, requested) {
|
|
14242
|
+
const known = serverCatalogKnown(env2.catalog, report), changed = catalogChanged(env2.catalog, report);
|
|
14243
|
+
const expected = known && !changed ? expectedServerIds(env2.catalog, report, requested) : new Set(report.scopeIds);
|
|
14244
|
+
const scope = new Set(report.scopeIds), rows2 = [];
|
|
14245
|
+
const issues = /* @__PURE__ */ new Map();
|
|
14246
|
+
const layerFor = (id) => {
|
|
14247
|
+
const layer2 = known ? env2.catalog?.checks.find((c2) => c2.id === id)?.spec?.layer : void 0;
|
|
14248
|
+
return layer2 === "platform" || layer2 === "tenant" ? layer2 : String(id).startsWith("platform.") ? "platform" : "tenant";
|
|
14249
|
+
};
|
|
14250
|
+
const issue = (layer2, note) => issues.set(layer2, [...issues.get(layer2) ?? [], note]);
|
|
14251
|
+
const both2 = (note) => {
|
|
14252
|
+
issue("platform", note);
|
|
14253
|
+
issue("tenant", note);
|
|
14254
|
+
};
|
|
14255
|
+
const synthesize = (id, code2, note) => {
|
|
14256
|
+
env2.report.server.verdict = null;
|
|
14257
|
+
const catalogRow = known ? env2.catalog?.checks.find((c2) => c2.id === id) : void 0;
|
|
14258
|
+
return makeResult({
|
|
14259
|
+
id,
|
|
14260
|
+
name: catalogRow?.name ?? id,
|
|
14261
|
+
layer: layerFor(id),
|
|
14262
|
+
requirement: catalogRow?.requirement === "OPTIONAL" ? "OPTIONAL" : "REQUIRED",
|
|
14263
|
+
dependsOn: [],
|
|
14264
|
+
owner: "RND"
|
|
14265
|
+
}, unknown(code2, code2 === "REPORT_ITEM_MISSING" ? "\u670D\u52A1\u7AEF\u62A5\u544A\u91CC\u6CA1\u6709\u8FD9\u4E00\u9879\uFF08CLI \u8865\u9879\uFF09" : "\u670D\u52A1\u7AEF\u68C0\u67E5\u7ED3\u8BBA\u4E0D\u5408\u6CD5\uFF08CLI \u6539\u5199\uFF09", {
|
|
14266
|
+
reason: code2 === "REPORT_ITEM_MISSING" ? "SOURCE_UNAVAILABLE" : "EVALUATOR_ERROR",
|
|
14267
|
+
note
|
|
14268
|
+
}), env2.name, true, ctx.requestedAt, 0, codeStep(code2, env2.name));
|
|
14269
|
+
};
|
|
14270
|
+
const rewrite = (row, originals, why) => {
|
|
14271
|
+
const replacement = synthesize(row.checkId, "SERVER_VERDICT_INVALID", `CLI \u6539\u5199\uFF08${why}\uFF09\uFF1B\u539F\u59CB code\uFF1A${originals.map((r) => r.code ?? "\u65E0").join("\uFF1B")}\uFF1B\u539F\u59CB verdict\uFF1A${originals.map((r) => r.verdict === void 0 ? "\u7F3A\u5931" : JSON.stringify(r.verdict)).join("\uFF1B")}`);
|
|
14272
|
+
return { ...row, env: env2.name, verdict: { ...replacement.verdict }, code: replacement.code, summary: replacement.summary, nextStep: replacement.nextStep };
|
|
14273
|
+
};
|
|
14274
|
+
if (!changed) {
|
|
14275
|
+
if (known) {
|
|
14276
|
+
for (const disabled of report.scope?.policyDisabled ?? []) {
|
|
14277
|
+
if (env2.catalog.checks.find((c2) => c2.id === disabled.id)?.requirement !== "OPTIONAL") issue(layerFor(disabled.id), `${disabled.id}\uFF1ApolicyDisabled \u4E0D\u662F\u76EE\u5F55\u9009\u68C0`);
|
|
14278
|
+
if (scope.has(disabled.id)) issue(layerFor(disabled.id), `${disabled.id}\uFF1ApolicyDisabled \u4E0E scopeIds \u76F8\u4EA4`);
|
|
14279
|
+
}
|
|
14280
|
+
for (const id of /* @__PURE__ */ new Set([...expected, ...scope]))
|
|
14281
|
+
if (expected.has(id) !== scope.has(id)) issue(layerFor(id), `${id}\uFF1AscopeIds \u4E0E\u671F\u671B\u96C6\u5408 E \u4E0D\u4E00\u81F4`);
|
|
14282
|
+
}
|
|
14283
|
+
if (known) {
|
|
14284
|
+
const echo = report.scope;
|
|
14285
|
+
const sameTokens = (a, b) => Array.isArray(a) && a.length === b.length && [...a].sort().every((v, i) => v === [...b].sort()[i]);
|
|
14286
|
+
if ((typeof echo?.stage === "string" ? echo.stage.toLowerCase() : echo?.stage) !== (requested.stage?.toLowerCase() ?? null)) both2("scope.stage \u56DE\u663E\u4E0E\u8BF7\u6C42\u4E0D\u7B26");
|
|
14287
|
+
for (const key2 of ["only", "skip"]) if (!sameTokens(echo?.[key2], requested[key2])) both2(`scope.${key2} \u56DE\u663E\u4E0E\u8BF7\u6C42\u4E0D\u7B26`);
|
|
14288
|
+
if (echo?.active !== requested.active) both2("scope.active \u56DE\u663E\u4E0E\u8BF7\u6C42\u4E0D\u7B26");
|
|
14289
|
+
}
|
|
14290
|
+
if (report.returnedCount !== report.results.length || report.totalCount !== report.scopeIds.length)
|
|
14291
|
+
both2(`\u8BA1\u6570\u4E0D\u7B26\uFF1AreturnedCount=${report.returnedCount}\uFF0Cresults.length=${report.results.length}\uFF1BtotalCount=${report.totalCount}\uFF0CscopeIds.length=${report.scopeIds.length}`);
|
|
14292
|
+
}
|
|
14293
|
+
const groups = /* @__PURE__ */ new Map();
|
|
14294
|
+
for (const row of report.results) groups.set(row.checkId, [...groups.get(row.checkId) ?? [], row]);
|
|
14295
|
+
for (const [id, group] of groups) {
|
|
14296
|
+
const row = group[0];
|
|
14297
|
+
if (!changed && !scope.has(id)) {
|
|
14298
|
+
issue(row.layer, `${id}\uFF1A\u7ED3\u679C\u8D8A\u51FA\u672C\u6B21\u8303\u56F4`);
|
|
14299
|
+
continue;
|
|
14300
|
+
}
|
|
14301
|
+
const why = group.length > 1 ? `\u540C\u4E00 id \u51FA\u73B0 ${group.length} \u6761` : verdictViolation(row);
|
|
14302
|
+
rows2.push(why ? rewrite(row, group, why) : { ...row, env: env2.name });
|
|
14303
|
+
}
|
|
14304
|
+
if (!changed) {
|
|
14305
|
+
for (const id of expected) if (!rows2.some((row) => row.checkId === id))
|
|
14306
|
+
rows2.push(synthesize(id, "REPORT_ITEM_MISSING", "CLI \u8865\u9879\uFF1A\u670D\u52A1\u7AEF\u62A5\u544A\u91CC\u6CA1\u6709\u8FD9\u4E00\u9879"));
|
|
14307
|
+
}
|
|
14308
|
+
const selected = (layer2) => (layer2 === "platform" || layer2 === "tenant") && (!ctx.scope || ctx.scope.serverLayers.has(layer2));
|
|
14309
|
+
const marks = /* @__PURE__ */ new Map();
|
|
14310
|
+
for (const [layer2, notes] of issues) {
|
|
14311
|
+
const home = selected(layer2) ? layer2 : SERVER_PLACEHOLDERS.map((d) => d.layer).find(selected);
|
|
14312
|
+
marks.set(home, [...marks.get(home) ?? [], ...notes.map((note) => home === layer2 ? note : `${String(layer2)} \u5C42\uFF08\u4E0D\u5728\u672C\u6B21\u8303\u56F4\uFF09\uFF1A${note}`)]);
|
|
14313
|
+
}
|
|
14314
|
+
for (const [layer2, notes] of marks) rows2.push(...placeholderRows(
|
|
14315
|
+
ctx,
|
|
14316
|
+
env2,
|
|
14317
|
+
unknown("REPORT_MALFORMED", "\u670D\u52A1\u7AEF\u4F53\u68C0\u62A5\u544A\u5BF9\u8D26\u4E0D\u7B26\uFF08CLI \u6807\u8BB0\uFF09", { reason: "EVALUATOR_ERROR", note: notes.join("\uFF1B") })
|
|
14318
|
+
).filter((r) => r.layer === layer2));
|
|
14319
|
+
return rows2;
|
|
14320
|
+
}
|
|
14321
|
+
async function fetchServerReport(ctx, env2, dependencies, deadline, requested = fullScope) {
|
|
14322
|
+
const [identity3, health] = dependencies;
|
|
14323
|
+
const missing = SERVER_PLACEHOLDERS[0].dependsOn.filter((_, i) => dependencies[i]?.verdict.level !== "PASS");
|
|
14324
|
+
const prerequisites = (note) => placeholderRows(ctx, env2, {
|
|
14325
|
+
level: "NOT_RUN",
|
|
14326
|
+
code: "PREREQUISITE_NOT_MET",
|
|
14327
|
+
reason: "PREREQUISITE_NOT_MET",
|
|
14328
|
+
summary: "\u670D\u52A1\u7AEF\u4F53\u68C0\u62A5\u544A\u672A\u6267\u884C\uFF1A\u524D\u7F6E\u68C0\u67E5\u672A\u901A\u8FC7",
|
|
14329
|
+
note
|
|
14330
|
+
});
|
|
14331
|
+
if (identity3?.verdict.level !== "PASS" || !health || health.verdict.level === "NOT_RUN") return prerequisites(missing.join(", "));
|
|
14332
|
+
if (health.code === "BACKEND_UNSUPPORTED") return placeholderRows(ctx, env2, {
|
|
14333
|
+
level: "NOT_RUN",
|
|
14334
|
+
code: health.code,
|
|
14335
|
+
reason: "CAPABILITY_UNSUPPORTED",
|
|
14336
|
+
summary: "\u540E\u7AEF\u4E0D\u652F\u6301\u4F53\u68C0\u62A5\u544A",
|
|
14337
|
+
note: `${health.verdict.note ?? ""}\uFF1B${env2.report.backend.commit ? `\u540E\u7AEF commit ${env2.report.backend.commit}` : "commit \u672A\u77E5"}`
|
|
14338
|
+
});
|
|
14339
|
+
if (health.verdict.level !== "PASS") {
|
|
14340
|
+
if (["HEALTH_API_ROUTE_MISSING", "REPORT_THROTTLED", "REPORT_UNAUTHORIZED", "REPORT_UNAVAILABLE", "REPORT_MALFORMED"].includes(health.code ?? ""))
|
|
14341
|
+
return placeholderRows(ctx, env2, unknown(health.code, health.summary, {
|
|
14342
|
+
reason: health.code === "REPORT_UNAUTHORIZED" ? "PERMISSION_DENIED" : health.code === "REPORT_MALFORMED" ? "EVALUATOR_ERROR" : "SOURCE_UNAVAILABLE",
|
|
14343
|
+
note: health.verdict.note
|
|
14344
|
+
}));
|
|
14345
|
+
return prerequisites(`connect.health-api\uFF1A${health.code ?? health.verdict.level}`);
|
|
14346
|
+
}
|
|
14347
|
+
const remaining = deadline - Date.now();
|
|
14348
|
+
if (remaining < 3e3) return placeholderRows(ctx, env2, unknown("BUDGET_EXHAUSTED", "\u9884\u7B97\u8017\u5C3D\uFF0C\u672A\u542F\u52A8\uFF1B\u7A0D\u540E\u91CD\u8DD1", { note: "\u9884\u7B97\u8017\u5C3D\uFF0C\u672A\u542F\u52A8" }));
|
|
14349
|
+
const timeoutMs = Math.min(25e3, remaining), budgetMs = Math.min(15e3, timeoutMs - 2e3), started = Date.now();
|
|
14350
|
+
const controller = new AbortController();
|
|
14351
|
+
let timer;
|
|
14352
|
+
try {
|
|
14353
|
+
const expired = new Promise((_, reject) => {
|
|
14354
|
+
timer = setTimeout(() => {
|
|
14355
|
+
controller.abort();
|
|
14356
|
+
reject(new Error("\u5DF2\u505C\u6B62\u7B49\u5F85"));
|
|
14357
|
+
}, timeoutMs);
|
|
14358
|
+
});
|
|
14359
|
+
const request = ctx.scope ? ctx.services.reportRequest(env2.config.endpoint, env2.token, timeoutMs, budgetMs, controller.signal, requested) : ctx.services.reportRequest(env2.config.endpoint, env2.token, timeoutMs, budgetMs, controller.signal);
|
|
14360
|
+
const out = await Promise.race([request, expired]);
|
|
14361
|
+
const error = object(out.body) && object(out.body.error) ? out.body.error : void 0;
|
|
14362
|
+
const details = object(error?.details) ? error.details : void 0;
|
|
14363
|
+
if (out.status === 400 && error?.code === "HEALTH_REPORT_INVALID_PARAM" && Array.isArray(details?.policyDisabled) && details.policyDisabled.length > 0 && details.policyDisabled.every((row) => object(row) && typeof row.id === "string" && typeof row.by === "string" && typeof row.at === "string" && typeof row.cause === "string")) {
|
|
14364
|
+
env2.serverReport = {
|
|
14365
|
+
schemaVersion: 1,
|
|
14366
|
+
results: [],
|
|
14367
|
+
scopeIds: [],
|
|
14368
|
+
totalCount: 0,
|
|
14369
|
+
returnedCount: 0,
|
|
14370
|
+
catalogRevision: env2.catalog?.catalogRevision,
|
|
14371
|
+
scope: { ...requested, policyDisabled: details.policyDisabled },
|
|
14372
|
+
recoveryCommand: typeof error.next_step === "string" ? error.next_step : void 0
|
|
14373
|
+
};
|
|
14374
|
+
env2.report.server.verdict = null;
|
|
14375
|
+
return [];
|
|
14376
|
+
}
|
|
14377
|
+
const failure = failedReport(out, env2, ctx.as);
|
|
14378
|
+
if (failure) return placeholderRows(ctx, env2, failure, Date.now() - started);
|
|
14379
|
+
const report = out.body;
|
|
14380
|
+
env2.serverReport = report;
|
|
14381
|
+
Object.assign(env2.report.server, {
|
|
14382
|
+
deploymentTenancy: report.deploymentTenancy ?? null,
|
|
14383
|
+
instance: report.instance ?? null,
|
|
14384
|
+
verdict: report.verdict ?? null,
|
|
14385
|
+
catalogRevision: report.catalogRevision ?? null
|
|
14386
|
+
});
|
|
14387
|
+
if (catalogChanged(env2.catalog, report)) {
|
|
14388
|
+
try {
|
|
14389
|
+
const refreshed = await ctx.services.probe(env2.config.endpoint, env2.token, controller.signal).get("/api/system/health/checks");
|
|
14390
|
+
const catalog = refreshed.status === 200 ? parseCatalog(refreshed.body) : void 0;
|
|
14391
|
+
if (catalog && catalog.catalogRevision === report.catalogRevision) env2.catalog = catalog;
|
|
14392
|
+
} catch {
|
|
14393
|
+
}
|
|
14394
|
+
}
|
|
14395
|
+
return reconcileReport(ctx, env2, report, requested);
|
|
14396
|
+
} catch (error) {
|
|
14397
|
+
const stopped = controller.signal.aborted || axios6.isAxiosError(error) && ["ECONNABORTED", "ETIMEDOUT"].includes(error.code ?? "");
|
|
14398
|
+
return placeholderRows(ctx, env2, unknown("REPORT_UNAVAILABLE", "\u670D\u52A1\u7AEF\u4F53\u68C0\u62A5\u544A\u6682\u4E0D\u53EF\u7528\uFF1B\u7A0D\u540E\u91CD\u8BD5", {
|
|
14399
|
+
note: `HTTP \u672A\u53D6\u5F97\u54CD\u5E94\uFF1B${stopped ? "\u5DF2\u505C\u6B62\u7B49\u5F85" : safeError(error)}`
|
|
14400
|
+
}), Date.now() - started);
|
|
14401
|
+
} finally {
|
|
14402
|
+
clearTimeout(timer);
|
|
14403
|
+
}
|
|
14404
|
+
}
|
|
14405
|
+
|
|
14406
|
+
// src/commands/doctor/connect-checks.ts
|
|
14132
14407
|
var obj = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
|
|
14133
14408
|
var json = (o) => o.body !== null && o.body !== void 0;
|
|
14134
14409
|
var probe = (ctx, env2, execution, authenticated = true) => ctx.services.probe(env2.config.endpoint, authenticated ? env2.token : void 0, execution.signal);
|
|
@@ -14141,8 +14416,8 @@ var connectivity = async (ctx, env2, execution) => {
|
|
|
14141
14416
|
};
|
|
14142
14417
|
return pass("\u540E\u7AEF\u7248\u672C\u7AEF\u70B9\u53EF\u8FBE\uFF08\u514D\u8BA4\u8BC1\uFF09");
|
|
14143
14418
|
}
|
|
14144
|
-
const
|
|
14145
|
-
return found(
|
|
14419
|
+
const code2 = out.error === "network" ? "BACKEND_UNREACHABLE" : out.error === "server-error" ? "BACKEND_SERVER_ERROR" : out.error === "not-found" ? "BACKEND_NOT_FOUND" : ["unauthorized", "forbidden"].includes(out.error) ? "BACKEND_REJECTED" : out.status >= 200 && out.status < 300 && !json(out) && !/json/i.test(out.headers["content-type"] ?? "") ? "BACKEND_NOT_JSON" : "BACKEND_BAD_RESPONSE";
|
|
14420
|
+
return found(code2, void 0, { note: `HTTP ${out.status < 0 ? "\u672A\u53D6\u5F97\u54CD\u5E94" : out.status}` });
|
|
14146
14421
|
};
|
|
14147
14422
|
function identityOutcome(out, env2, username) {
|
|
14148
14423
|
if (out.status === 401) return found("TOKEN_REJECTED", void 0, { note: "\u53EF\u80FD\u539F\u56E0\uFF1A\u8FC7\u671F / \u88AB\u540A\u9500 / \u8D85\u51FA\u79DF\u6237\u5E76\u53D1\u4F1A\u8BDD\u4E0A\u9650\uFF08\u82E5\u8BE5\u79DF\u6237\u914D\u7F6E\u4E86\uFF09" });
|
|
@@ -14173,6 +14448,7 @@ var identity = async (ctx, env2, execution) => {
|
|
|
14173
14448
|
);
|
|
14174
14449
|
e.close = auth.closeEphemeralSession;
|
|
14175
14450
|
e.token = auth.ephemeralAccessToken;
|
|
14451
|
+
e.proxied = !!auth.impersonation;
|
|
14176
14452
|
const out2 = auth.verifiedPrincipal ? { status: 200, body: auth.verifiedPrincipal, headers: {}, error: "ok" } : await probeDoctorEndpoint(probe(ctx, e, execution), "identity");
|
|
14177
14453
|
const observation = identityOutcome(out2, e, auth.verifiedPrincipal?.username);
|
|
14178
14454
|
if (auth.impersonation) observation.note = `\u7ECF ${auth.impersonation.actorIdentity} \u4EE3\u7406\u6838\u9A8C`;
|
|
@@ -14187,13 +14463,13 @@ var identity = async (ctx, env2, execution) => {
|
|
|
14187
14463
|
const actorCode = actorStep === "meta" || actorStep === "env" ? "IDENTITY_META_INVALID" : actorStep === "resolve" && errorCode === "IDENTITY_NOT_FOUND" ? "IDENTITY_NOT_LOGGED_IN" : "IDENTITY_UNVERIFIED";
|
|
14188
14464
|
return (actorCode === "IDENTITY_UNVERIFIED" ? unknown : found)(actorCode, void 0, { note: `\u64CD\u4F5C\u8005\u8EAB\u4EFD\u4E0D\u53EF\u7528\uFF0C\u672A\u53D1\u8D77\u4EE3\u7406\uFF1A${safeError(error)}` });
|
|
14189
14465
|
}
|
|
14190
|
-
const status =
|
|
14191
|
-
const envelope = status === 404 &&
|
|
14466
|
+
const status = axios7.isAxiosError(error) ? error.response?.status : void 0;
|
|
14467
|
+
const envelope = status === 404 && axios7.isAxiosError(error) && error.config?.url?.endsWith("/impersonation/start") ? error.response?.data?.error : void 0;
|
|
14192
14468
|
const targetMissing = envelope?.code === "NOT_FOUND";
|
|
14193
14469
|
const targetAdvice = envelope?.details === "\u76EE\u6807\u7528\u6237\u4E0D\u5B58\u5728" ? "\u670D\u52A1\u7AEF\uFF1A\u76EE\u6807\u7528\u6237\u4E0D\u5B58\u5728\uFF1B\u6838\u5BF9\u5F53\u524D\u79DF\u6237\u4E0E\u76EE\u6807\u7528\u6237 UUID" : "\u670D\u52A1\u7AEF\u56DE 404 NOT_FOUND\uFF0C\u672A\u6307\u660E\u76EE\u6807\u7528\u6237\u4E0D\u5B58\u5728\uFF08\u4E5F\u53EF\u80FD\u662F\u540E\u7AEF\u6CA1\u6709\u4EE3\u7406\u63A5\u53E3\uFF09\uFF1B\u6838\u5BF9\u5F53\u524D\u79DF\u6237\u4E0E\u76EE\u6807\u7528\u6237 UUID\uFF0C\u5E76\u6838\u540E\u7AEF\u7248\u672C";
|
|
14194
|
-
const
|
|
14470
|
+
const code2 = status === 403 || targetMissing || errorCode && ["SCOPE_FORBIDDEN", "IDENTITY_NOT_FOUND", "INVALID_ARGUMENT", "IDENTITY_NOT_IN_ENV", "IDENTITY_META_INCOMPLETE"].includes(errorCode) ? "AS_PROXY_DENIED" : errorCode === "AUTH_FAILED" ? "IDENTITY_NOT_LOGGED_IN" : status === 401 ? "TOKEN_REJECTED" : "IDENTITY_UNVERIFIED";
|
|
14195
14471
|
const note = detail?.issuance === "unconfirmed" ? "\u4EE3\u7406\u7B7E\u53D1\u8BF7\u6C42\u88AB\u4E2D\u6B62\uFF1B\u670D\u52A1\u7AEF\u53EF\u80FD\u5DF2\u7B7E\u53D1\uFF0C\u5BA2\u6237\u7AEF\u62FF\u4E0D\u5230\u4F1A\u8BDD\uFF0C\u670D\u52A1\u7AEF\u6309\u6709\u6548\u671F\u81EA\u7136\u8FC7\u671F" : detail?.cleanup === "unconfirmed" ? "\u4EE3\u7406\u4F1A\u8BDD\u6536\u5C3E\u5931\u8D25\uFF0C\u670D\u52A1\u7AEF\u6309\u6709\u6548\u671F\u81EA\u7136\u8FC7\u671F" : safeError(error);
|
|
14196
|
-
return (
|
|
14472
|
+
return (code2 === "IDENTITY_UNVERIFIED" ? unknown : found)(code2, void 0, {
|
|
14197
14473
|
note: `${note}${typeof detail?.nextStep === "string" ? `\uFF1B${detail.nextStep}` : targetMissing ? `\uFF1B${targetAdvice}` : ""}`
|
|
14198
14474
|
});
|
|
14199
14475
|
}
|
|
@@ -14224,23 +14500,25 @@ var websocket = async (ctx, env2) => {
|
|
|
14224
14500
|
}
|
|
14225
14501
|
};
|
|
14226
14502
|
function classifyHealthApi(out) {
|
|
14227
|
-
const note =
|
|
14228
|
-
if (out.status === 429) return unknown("REPORT_THROTTLED", void 0, { note:
|
|
14503
|
+
const note = httpNote(out);
|
|
14504
|
+
if (out.status === 429) return unknown("REPORT_THROTTLED", void 0, { note: throttleNote(out) });
|
|
14229
14505
|
if ([401, 403].includes(out.status)) return unknown("REPORT_UNAUTHORIZED", void 0, { reason: "PERMISSION_DENIED", note });
|
|
14230
|
-
if (out.status >= 500
|
|
14506
|
+
if (out.status >= 500) return unknown("REPORT_UNAVAILABLE", "\u670D\u52A1\u7AEF\u4F53\u68C0\u76EE\u5F55\u6682\u4E0D\u53EF\u7528\uFF1B\u7A0D\u540E\u91CD\u8BD5\uFF0C\u82E5\u540E\u7AEF\u65E9\u4E8E #2318 \u5219\u5148\u5347\u7EA7\u540E\u7AEF", { note });
|
|
14507
|
+
if (out.error === "network") return unknown("REPORT_UNAVAILABLE", "\u670D\u52A1\u7AEF\u4F53\u68C0\u76EE\u5F55\u6682\u4E0D\u53EF\u7528\uFF1B\u7A0D\u540E\u91CD\u8BD5", { note });
|
|
14231
14508
|
if (out.status === 404) {
|
|
14232
14509
|
const envelope = obj(out.body) && obj(out.body.error) && out.body.error.code === "NOT_FOUND" && typeof out.body.error.message === "string";
|
|
14233
14510
|
if (out.headers["x-trace-id"] && envelope) return found("BACKEND_UNSUPPORTED", void 0, { note });
|
|
14234
14511
|
return found("HEALTH_API_ROUTE_MISSING", void 0, { evidence: "INFERRED", note: `${note}\uFF1B\u7F3A\u540E\u7AEF traceId \u6216 HCM \u4FE1\u5C01\uFF1B\u4EE3\u7406\u4E5F\u53EF\u80FD\u5265\u6389\u54CD\u5E94\u5934` });
|
|
14235
14512
|
}
|
|
14236
|
-
if (out.status === 200 &&
|
|
14513
|
+
if (out.status === 200 && parseCatalog(out.body)) return pass("\u540E\u7AEF\u652F\u6301\u4F53\u68C0 API");
|
|
14237
14514
|
if (out.status === 200 && /text\/html/i.test(out.headers["content-type"] ?? ""))
|
|
14238
14515
|
return found("HEALTH_API_ROUTE_MISSING", void 0, { evidence: "INFERRED", note: `${note}\uFF1B\u6536\u5230 HTML\uFF0C\u63A8\u65AD\u8DEF\u7531\u843D\u5230\u524D\u7AEF SPA` });
|
|
14239
|
-
return unknown("REPORT_MALFORMED", void 0, { reason: "EVALUATOR_ERROR", note });
|
|
14516
|
+
return unknown("REPORT_MALFORMED", void 0, { reason: "EVALUATOR_ERROR", note: `${note}\uFF1B\u76EE\u5F55\u987B\u542B checks\u3001reservedCodes \u6570\u7EC4\uFF08checks \u6BCF\u9879\u662F\u5E26\u5B57\u7B26\u4E32 id \u7684\u5BF9\u8C61\uFF09\u3001catalogRevision \u5B57\u7B26\u4E32\u6216 null\u3001tenantCatalog \u5BF9\u8C61` });
|
|
14240
14517
|
}
|
|
14241
14518
|
var healthApi = async (ctx, env2, execution) => {
|
|
14242
14519
|
const out = await probeDoctorEndpoint(probe(ctx, env2, execution), "health-api");
|
|
14243
14520
|
const result = classifyHealthApi(out);
|
|
14521
|
+
if (result.level === "PASS") env2.catalog = parseCatalog(out.body);
|
|
14244
14522
|
env2.report.server.supported = result.level === "PASS" ? true : result.code === "BACKEND_UNSUPPORTED" ? false : null;
|
|
14245
14523
|
return result;
|
|
14246
14524
|
};
|
|
@@ -14312,13 +14590,16 @@ var CODE_TABLE = {
|
|
|
14312
14590
|
EXPOSURE_UNCHECKED: c("\u672A\u80FD\u6838\u5B9E\u533F\u540D\u5065\u5EB7\u7AEF\u70B9\uFF1B\u68C0\u67E5\u5165\u53E3\u4E0E\u670D\u52A1", "WARN", "CUSTOMER_OPS"),
|
|
14313
14591
|
BACKEND_UNSUPPORTED: c("\u540E\u7AEF\u6CA1\u6709\u4F53\u68C0\u8DEF\u7531\uFF1B\u5347\u7EA7\u540E\u7AEF"),
|
|
14314
14592
|
HEALTH_API_ROUTE_MISSING: c("\u63A8\u65AD\u4F53\u68C0\u8DEF\u7531\u672A\u5230\u540E\u7AEF\uFF1B\u68C0\u67E5\u53CD\u4EE3\u653E\u884C\u4E0E\u54CD\u5E94\u5934"),
|
|
14315
|
-
REPORT_THROTTLED: c("\u4F53\u68C0\
|
|
14316
|
-
REPORT_UNAUTHORIZED: c("\u4F53\u68C0\
|
|
14317
|
-
REPORT_UNAVAILABLE: c("\u4F53\u68C0\
|
|
14318
|
-
REPORT_MALFORMED: c("\u4F53\u68C0\
|
|
14593
|
+
REPORT_THROTTLED: c("\u670D\u52A1\u7AEF\u4F53\u68C0\u63A5\u53E3\u8BF7\u6C42\u88AB\u9650\u6D41\uFF1B\u6309 retryAfter \u7A0D\u540E\u91CD\u8BD5"),
|
|
14594
|
+
REPORT_UNAUTHORIZED: c("\u670D\u52A1\u7AEF\u4F53\u68C0\u63A5\u53E3\u8BF7\u6C42\u6743\u9650\u4E0D\u8DB3", "WARN", "FDE", login),
|
|
14595
|
+
REPORT_UNAVAILABLE: c("\u670D\u52A1\u7AEF\u4F53\u68C0\u63A5\u53E3\u6682\u4E0D\u53EF\u7528\uFF1B\u7A0D\u540E\u91CD\u8BD5"),
|
|
14596
|
+
REPORT_MALFORMED: c("\u670D\u52A1\u7AEF\u4F53\u68C0\u63A5\u53E3\u54CD\u5E94\u65E0\u6CD5\u89E3\u6790\uFF1B\u8054\u7CFB\u7814\u53D1\u6838\u5BF9\u534F\u8BAE", "WARN", "RND"),
|
|
14597
|
+
REPORT_ITEM_MISSING: c("\u670D\u52A1\u7AEF\u62A5\u544A\u91CC\u6CA1\u6709\u8FD9\u4E00\u9879", "WARN", "RND"),
|
|
14598
|
+
SERVER_VERDICT_INVALID: c("\u670D\u52A1\u7AEF\u68C0\u67E5\u7ED3\u8BBA\u4E0D\u5408\u6CD5\uFF1B\u8054\u7CFB\u7814\u53D1\u6838\u5BF9\u534F\u8BAE", "WARN", "RND"),
|
|
14599
|
+
BUDGET_EXHAUSTED: c("\u9884\u7B97\u8017\u5C3D\uFF0C\u672A\u542F\u52A8\uFF1B\u7A0D\u540E\u91CD\u8DD1")
|
|
14319
14600
|
};
|
|
14320
|
-
function codeStep(
|
|
14321
|
-
const row = CODE_TABLE[
|
|
14601
|
+
function codeStep(code2, env2) {
|
|
14602
|
+
const row = CODE_TABLE[code2];
|
|
14322
14603
|
return { owner: row?.owner ?? "FDE", ...row?.command ? { command: row.command(env2) } : {} };
|
|
14323
14604
|
}
|
|
14324
14605
|
var allStages = ["handover", "baseline", "configure", "migrate", "integrate", "golive", "operate"];
|
|
@@ -14356,33 +14637,73 @@ var CHECKS = [
|
|
|
14356
14637
|
descriptor("connect.health-api", "\u4F53\u68C0 API", ["connect.connectivity", "connect.identity"], ["BACKEND_UNSUPPORTED", "HEALTH_API_ROUTE_MISSING", "REPORT_THROTTLED", "REPORT_UNAUTHORIZED", "REPORT_UNAVAILABLE", "REPORT_MALFORMED"], 1e4, connectChecks.healthApi),
|
|
14357
14638
|
descriptor("connect.exposure", "\u533F\u540D\u66B4\u9732", ["connect.connectivity"], ["ACTUATOR_DETAILS_EXPOSED", "EXPOSURE_UNCHECKED"], 1e4, connectChecks.exposure, false, "CUSTOMER_OPS")
|
|
14358
14639
|
];
|
|
14640
|
+
var SERVER_PLACEHOLDERS = ["platform", "tenant"].map((layer2) => ({
|
|
14641
|
+
id: `${layer2}.server-report`,
|
|
14642
|
+
name: layer2 === "platform" ? "\u5E73\u53F0\u4F53\u68C0\u62A5\u544A" : "\u79DF\u6237\u4F53\u68C0\u62A5\u544A",
|
|
14643
|
+
layer: layer2,
|
|
14644
|
+
requirement: "REQUIRED",
|
|
14645
|
+
owner: "FDE",
|
|
14646
|
+
dependsOn: ["connect.identity", "connect.health-api"],
|
|
14647
|
+
codes: [
|
|
14648
|
+
"BACKEND_UNSUPPORTED",
|
|
14649
|
+
"HEALTH_API_ROUTE_MISSING",
|
|
14650
|
+
"REPORT_THROTTLED",
|
|
14651
|
+
"REPORT_UNAUTHORIZED",
|
|
14652
|
+
"REPORT_UNAVAILABLE",
|
|
14653
|
+
"REPORT_MALFORMED",
|
|
14654
|
+
"REPORT_ITEM_MISSING",
|
|
14655
|
+
"SERVER_VERDICT_INVALID",
|
|
14656
|
+
"BUDGET_EXHAUSTED"
|
|
14657
|
+
]
|
|
14658
|
+
}));
|
|
14359
14659
|
async function executeChecks(ctx, options = {}) {
|
|
14360
14660
|
const deadline = Date.now() + (options.budgetMs ?? 45e3);
|
|
14361
14661
|
const checks = options.checks ?? CHECKS;
|
|
14362
|
-
const jobs = checks.flatMap((d) => d.layer === "connect" || d.id === "local.credential" ? ctx.environments.length ? ctx.environments.map((env2) => ({ d, env: env2 })) : d.id === "local.credential" ? [{ d, env: void 0 }] : [] : [{ d, env: void 0 }])
|
|
14662
|
+
const jobs = checks.flatMap((d) => d.layer === "connect" || d.id === "local.credential" ? ctx.environments.length ? ctx.environments.map((env2) => ({ d, env: env2 })) : d.id === "local.credential" ? [{ d, env: void 0 }] : [] : [{ d, env: void 0 }]).filter(({ d, env: env2 }) => {
|
|
14663
|
+
if (options.onlyTarget && env2 && !env2.report.target) return false;
|
|
14664
|
+
if (!ctx.scope) return true;
|
|
14665
|
+
const selected = (!ctx.scope.stage || d.stages.includes(ctx.scope.stage)) && (!ctx.scope.only.length || ctx.scope.only.some((t) => d.id.startsWith(t))) && !ctx.scope.skip.some((t) => d.id.startsWith(t));
|
|
14666
|
+
return selected || !!env2?.report.target && ctx.scope.addedPrerequisites.includes(d.id);
|
|
14667
|
+
});
|
|
14363
14668
|
const pending = /* @__PURE__ */ new Map();
|
|
14364
14669
|
const key2 = (id, env2) => `${id}:${id === "local.project.env" ? "" : env2?.name ?? ""}`;
|
|
14670
|
+
for (const row of options.precomputed ?? []) pending.set(`${row.checkId}:${row.checkId === "local.project.env" ? "" : row.env ?? ""}`, Promise.resolve(row));
|
|
14365
14671
|
for (const { d, env: env2 } of jobs) {
|
|
14672
|
+
if (pending.has(key2(d.id, env2))) continue;
|
|
14366
14673
|
const job = (async () => {
|
|
14367
14674
|
const dependencies = await Promise.all(d.dependsOn.map((id) => pending.get(key2(id, env2))));
|
|
14368
|
-
const failed2 =
|
|
14675
|
+
const failed2 = d.dependsOn.filter((_, i) => dependencies[i]?.verdict.level !== "PASS");
|
|
14369
14676
|
const finish = (o, duration = 0) => {
|
|
14370
|
-
const
|
|
14677
|
+
const code2 = o.code && CODE_TABLE[o.code];
|
|
14371
14678
|
return makeResult(
|
|
14372
14679
|
d,
|
|
14373
14680
|
{
|
|
14374
14681
|
...o,
|
|
14375
|
-
grade: o.grade ?? (
|
|
14376
|
-
summary: o.summary === o.code &&
|
|
14682
|
+
grade: o.grade ?? (code2 ? code2.grade : void 0),
|
|
14683
|
+
summary: o.summary === o.code && code2 ? code2.summary : o.summary
|
|
14377
14684
|
},
|
|
14378
14685
|
env2?.name ?? null,
|
|
14379
14686
|
!env2 || env2.report.target,
|
|
14380
14687
|
ctx.requestedAt,
|
|
14381
14688
|
duration,
|
|
14382
|
-
o.code &&
|
|
14689
|
+
o.code && code2 ? codeStep(o.code, env2?.name ?? ctx.targetEnv ?? "default") : { owner: d.owner }
|
|
14383
14690
|
);
|
|
14384
14691
|
};
|
|
14385
|
-
if (failed2.length)
|
|
14692
|
+
if (failed2.length) {
|
|
14693
|
+
const missing = failed2.filter((id) => !pending.has(key2(id, env2)));
|
|
14694
|
+
const observation = {
|
|
14695
|
+
level: "NOT_RUN",
|
|
14696
|
+
code: "PREREQUISITE_NOT_MET",
|
|
14697
|
+
summary: missing.length ? "\u524D\u7F6E\u9879\u4E0D\u5728\u672C\u6B21\u8303\u56F4\u5185" : "\u524D\u7F6E\u68C0\u67E5\u672A\u901A\u8FC7",
|
|
14698
|
+
note: failed2.map((id) => missing.includes(id) ? `\u524D\u7F6E\u9879 ${id} \u4E0D\u5728\u672C\u6B21\u8303\u56F4\u5185` : id).join(", "),
|
|
14699
|
+
reason: "PREREQUISITE_NOT_MET"
|
|
14700
|
+
};
|
|
14701
|
+
if (missing.length) observation.nextStep = {
|
|
14702
|
+
owner: d.owner,
|
|
14703
|
+
command: `hcm chiron doctor --env ${quote(env2?.name ?? ctx.targetEnv ?? "<env>")}${ctx.as ? ` --as ${quote(ctx.as)}` : ""} --only ${[d.id, ...missing].join(",")}`
|
|
14704
|
+
};
|
|
14705
|
+
return finish(observation);
|
|
14706
|
+
}
|
|
14386
14707
|
if (Date.now() >= deadline) return finish(unknown("BUDGET_EXHAUSTED", "\u9884\u7B97\u8017\u5C3D\uFF0C\u672A\u542F\u52A8", { note: "\u9884\u7B97\u8017\u5C3D\uFF0C\u672A\u542F\u52A8" }));
|
|
14387
14708
|
const start = Date.now();
|
|
14388
14709
|
const controller = new AbortController();
|
|
@@ -14421,40 +14742,81 @@ async function executeChecks(ctx, options = {}) {
|
|
|
14421
14742
|
})();
|
|
14422
14743
|
pending.set(key2(d.id, env2), job);
|
|
14423
14744
|
}
|
|
14424
|
-
|
|
14745
|
+
const target = ctx.environments.find((env2) => env2.report.target);
|
|
14746
|
+
const serverTask = target && options.fetchReport !== false && (!ctx.scope || ctx.scope.serverLayers.size > 0) ? Promise.all(SERVER_PLACEHOLDERS[0].dependsOn.map((id) => pending.get(key2(id, target)))).then((dependencies) => fetchServerReport(ctx, target, dependencies, deadline, ctx.scope ? { stage: ctx.scope.stage, only: ctx.scope.forwardedOnly, skip: ctx.scope.forwardedSkip, active: ctx.scope.active } : void 0)) : Promise.resolve([]);
|
|
14747
|
+
const [localAndConnect, server] = await Promise.all([Promise.all(jobs.map(({ d, env: env2 }) => pending.get(key2(d.id, env2)))), serverTask]);
|
|
14748
|
+
return [...localAndConnect, ...server];
|
|
14425
14749
|
}
|
|
14426
14750
|
|
|
14427
14751
|
// src/commands/doctor/report.ts
|
|
14752
|
+
var isOptIn = (r) => r.verdict?.level === "NOT_RUN" && r.verdict.reason === "OPT_IN_REQUIRED";
|
|
14428
14753
|
function conclude(results, ctx) {
|
|
14429
|
-
const blocked = results.some((r) => r.verdict
|
|
14430
|
-
const risks = results.some((r) => r.verdict
|
|
14754
|
+
const blocked = results.some((r) => r.verdict?.level === "FOUND" && r.verdict.grade === "CRITICAL");
|
|
14755
|
+
const risks = results.some((r) => r.verdict?.level === "FOUND" || r.verdict?.level === "UNDETERMINED" || r.verdict?.level === "NOT_RUN" && !isOptIn(r));
|
|
14431
14756
|
const verdict = blocked ? "BLOCKED" : risks || ctx.total === null || ctx.total <= 0 ? "READY_WITH_RISKS" : "READY";
|
|
14432
14757
|
return { verdict, exitCode: verdict === "BLOCKED" || ctx.failOn === "risks" && verdict === "READY_WITH_RISKS" ? 3 : 0 };
|
|
14433
14758
|
}
|
|
14759
|
+
var reportCatalogs = /* @__PURE__ */ new WeakMap();
|
|
14434
14760
|
function assembleReport(input) {
|
|
14435
14761
|
const counts = { PASS: 0, FOUND: 0, UNDETERMINED: 0, NOT_RUN: 0, NOT_APPLICABLE: 0 };
|
|
14436
14762
|
const foundByGrade = { CRITICAL: 0, WARN: 0 };
|
|
14437
14763
|
for (const result of input.results) {
|
|
14438
|
-
|
|
14439
|
-
if (
|
|
14764
|
+
const level = result.verdict?.level;
|
|
14765
|
+
if (level && Object.hasOwn(counts, level)) counts[level]++;
|
|
14766
|
+
const grade = result.verdict?.grade;
|
|
14767
|
+
if (level === "FOUND" && (grade === "CRITICAL" || grade === "WARN")) foundByGrade[grade]++;
|
|
14768
|
+
}
|
|
14769
|
+
const targetResults = input.results.filter((r) => r.env === null || r.env === input.targetEnv);
|
|
14770
|
+
const requested = input.scope ? {
|
|
14771
|
+
stage: input.scope.stage,
|
|
14772
|
+
only: input.scope.forwardedOnly,
|
|
14773
|
+
skip: input.scope.forwardedSkip,
|
|
14774
|
+
active: input.scope.active
|
|
14775
|
+
} : { stage: null, only: [], skip: [], active: false };
|
|
14776
|
+
const serverInScope = !input.scope || input.scope.serverLayers.size > 0;
|
|
14777
|
+
const serverRelevant = !input.scope || input.scope.serverRelevant;
|
|
14778
|
+
const known = serverInScope ? serverCatalogKnown(input.catalog, input.serverReport) : serverRelevant && !!input.catalog && input.catalog.catalogRevision !== null;
|
|
14779
|
+
const changed = catalogChanged(input.catalog, input.serverReport);
|
|
14780
|
+
const expected = known && !changed && input.serverReport ? expectedServerIds(input.catalog, input.serverReport, requested) : void 0;
|
|
14781
|
+
const coverageServerIds = changed ? new Set(input.serverReport.scopeIds) : expected;
|
|
14782
|
+
const checked = targetResults.filter((r) => ["PASS", "FOUND", "NOT_APPLICABLE"].includes(r.verdict?.level) && (r.layer === "local" || r.layer === "connect" || !coverageServerIds || coverageServerIds.has(r.checkId))).length;
|
|
14783
|
+
const localConnectTotal = targetResults.filter((r) => r.layer === "local" || r.layer === "connect").length;
|
|
14784
|
+
const total = !serverInScope ? localConnectTotal : known ? localConnectTotal + (coverageServerIds?.size ?? 0) : null;
|
|
14785
|
+
const incomplete = new Set(serverRelevant && !known ? ["server-catalog-unknown"] : []);
|
|
14786
|
+
if (input.scope?.only.length) incomplete.add("only");
|
|
14787
|
+
for (const token of input.scope?.skip ?? []) incomplete.add(`skip:${token}`);
|
|
14788
|
+
if (changed) incomplete.add("catalog-changed");
|
|
14789
|
+
const explicitlyExcluded = (layer2) => {
|
|
14790
|
+
const prefix = `${layer2}.`;
|
|
14791
|
+
return !!input.scope && (input.scope.only.length > 0 && !input.scope.only.some((t) => prefix.startsWith(t) || t.startsWith(prefix)) || input.scope.skip.some((t) => prefix.startsWith(t)));
|
|
14792
|
+
};
|
|
14793
|
+
for (const layer2 of ["local", "connect"]) {
|
|
14794
|
+
if (!targetResults.some((r) => r.layer === layer2) && !explicitlyExcluded(layer2) && (layer2 === "connect" ? !input.environments.length : CHECKS.some((d) => d.layer === layer2))) incomplete.add(`empty-layer:${layer2}`);
|
|
14440
14795
|
}
|
|
14441
|
-
|
|
14442
|
-
|
|
14796
|
+
for (const token of input.serverReport?.scope?.incompleteBecause ?? [])
|
|
14797
|
+
if (token !== "only" && !token.startsWith("skip:") && !token.startsWith("empty-layer:")) incomplete.add(token);
|
|
14798
|
+
if (known && !changed) for (const layer2 of ["platform", "tenant"]) {
|
|
14799
|
+
if (explicitlyExcluded(layer2)) continue;
|
|
14800
|
+
if (layer2 === "tenant" && input.catalog.tenantCatalog.available === false) continue;
|
|
14801
|
+
const stage = input.scope?.stage;
|
|
14802
|
+
if (!input.catalog.checks.some((c2) => c2.spec?.layer === layer2 && (!stage || Array.isArray(c2.stages) && c2.stages.some((s) => s.toLowerCase() === stage)))) incomplete.add(`empty-layer:${layer2}`);
|
|
14803
|
+
}
|
|
14804
|
+
const report = {
|
|
14443
14805
|
schemaVersion: 2,
|
|
14444
|
-
verdict: conclude(input.results, { total
|
|
14806
|
+
verdict: conclude(input.results, { total, failOn: input.failOn }).verdict,
|
|
14445
14807
|
counts,
|
|
14446
14808
|
foundByGrade,
|
|
14447
|
-
coverage: { checked, total
|
|
14809
|
+
coverage: { checked, total },
|
|
14448
14810
|
scope: {
|
|
14449
|
-
stage: null,
|
|
14450
|
-
only: [],
|
|
14451
|
-
skip: [],
|
|
14452
|
-
active: false,
|
|
14453
|
-
serverCatalogKnown:
|
|
14454
|
-
addedPrerequisites: [],
|
|
14455
|
-
policyDisabled: [],
|
|
14456
|
-
incompleteBecause: [
|
|
14457
|
-
complete:
|
|
14811
|
+
stage: input.scope?.stage ?? null,
|
|
14812
|
+
only: input.scope?.only ?? [],
|
|
14813
|
+
skip: input.scope?.skip ?? [],
|
|
14814
|
+
active: input.scope?.active ?? false,
|
|
14815
|
+
serverCatalogKnown: serverRelevant ? known : null,
|
|
14816
|
+
addedPrerequisites: input.scope?.addedPrerequisites ?? [],
|
|
14817
|
+
policyDisabled: input.serverReport?.scope?.policyDisabled ?? [],
|
|
14818
|
+
incompleteBecause: [...incomplete],
|
|
14819
|
+
complete: incomplete.size === 0
|
|
14458
14820
|
},
|
|
14459
14821
|
cli: { version: input.cliVersion },
|
|
14460
14822
|
project: input.project,
|
|
@@ -14464,63 +14826,283 @@ function assembleReport(input) {
|
|
|
14464
14826
|
environments: input.environments,
|
|
14465
14827
|
results: input.results
|
|
14466
14828
|
};
|
|
14829
|
+
if (input.catalog) reportCatalogs.set(report, input.catalog);
|
|
14830
|
+
return report;
|
|
14467
14831
|
}
|
|
14468
14832
|
function firstActions(results) {
|
|
14469
14833
|
const layers = ["local", "connect", "platform", "tenant"];
|
|
14470
|
-
return results.filter((r) => r.verdict
|
|
14834
|
+
return results.filter((r) => r.verdict?.level !== "PASS" && r.verdict?.level !== "NOT_APPLICABLE" && r.code !== "PREREQUISITE_NOT_MET" && r.code !== "PLATFORM_OPS_ONLY" && !isOptIn(r)).sort((a, b) => Number(b.verdict?.level === "FOUND" && b.verdict.grade === "CRITICAL") - Number(a.verdict?.level === "FOUND" && a.verdict.grade === "CRITICAL") || layers.indexOf(a.layer) - layers.indexOf(b.layer));
|
|
14471
14835
|
}
|
|
14472
14836
|
|
|
14473
14837
|
// src/commands/doctor/render.ts
|
|
14838
|
+
var indented = (text, prefix = " ") => String(text).split(/\r?\n/).map((line) => `${prefix}${line}`).join("\n");
|
|
14839
|
+
var reportRecoveryCommands = /* @__PURE__ */ new WeakMap();
|
|
14840
|
+
function policyDescription(row, catalog) {
|
|
14841
|
+
const name = (id) => catalog?.checks.find((c2) => c2.id === id)?.name ?? id;
|
|
14842
|
+
return `${name(row.id)}\uFF08${row.cause.startsWith("PREREQUISITE_DISABLED:") ? `\u968F ${name(row.cause.slice("PREREQUISITE_DISABLED:".length))} \u5173\u95ED\uFF0C` : "\u79DF\u6237\u7B56\u7565\uFF0C"}${row.by} \u4E8E ${row.at} \u5173\u95ED\uFF09`;
|
|
14843
|
+
}
|
|
14844
|
+
function recovery(row, rows2, catalog, recoveryCommand) {
|
|
14845
|
+
let root = row;
|
|
14846
|
+
const visited = /* @__PURE__ */ new Set();
|
|
14847
|
+
while (root.cause.startsWith("PREREQUISITE_DISABLED:") && !visited.has(root.id)) {
|
|
14848
|
+
visited.add(root.id);
|
|
14849
|
+
const parent = rows2.find((r) => r.id === root.cause.slice("PREREQUISITE_DISABLED:".length));
|
|
14850
|
+
if (!parent) break;
|
|
14851
|
+
root = parent;
|
|
14852
|
+
}
|
|
14853
|
+
const id = catalog?.checks.find((c2) => c2.id === root.id)?.definitionId;
|
|
14854
|
+
return recoveryCommand ? `\u6062\u590D\uFF1A${recoveryCommand}` : id ? `\u6062\u590D\uFF1Ahcm action HealthCheckDefinition.resetToDefault --id ${quote(id)}` : "\u6062\u590D\uFF1A\u5148 hcm query HealthCheckDefinition \u53D6\u5F97\u5B9A\u4E49 id";
|
|
14855
|
+
}
|
|
14856
|
+
function renderPolicyDisabled(rows2, catalog, recoveryCommand) {
|
|
14857
|
+
return ["policyDisabled \xB7 \u9009\u68C0\u672A\u542F\u7528\uFF1A", ...rows2.flatMap((row) => [
|
|
14858
|
+
indented(`${policyDescription(row, catalog)} \xB7 cause=${row.cause}`),
|
|
14859
|
+
indented(recovery(row, rows2, catalog, recoveryCommand))
|
|
14860
|
+
])].join("\n");
|
|
14861
|
+
}
|
|
14474
14862
|
function renderChironDoctor(report) {
|
|
14475
14863
|
const target = report.environments.find((env2) => env2.target);
|
|
14476
14864
|
const version2 = target?.backend.version;
|
|
14477
14865
|
const backend = !version2 || version2 === "unknown" ? "\u540E\u7AEF\u7248\u672C\u672A\u77E5" : `\u540E\u7AEF ${version2}`;
|
|
14478
14866
|
const out = [
|
|
14479
|
-
`\u777F\u620E\u4F53\u68C0 \xB7 \u9879\u76EE ${report.project} \xB7 \u76EE\u6807 ${report.targetEnv ?? "\u672A\u89E3\u6790"} \xB7 CLI ${report.cli.version} \xB7 ${backend}${target?.backend.commit ? `\uFF08commit ${target.backend.commit.slice(0, 7)}\uFF09` : ""}`,
|
|
14867
|
+
`\u777F\u620E\u4F53\u68C0 \xB7 \u9879\u76EE ${report.project} \xB7 \u76EE\u6807 ${report.targetEnv ?? "\u672A\u89E3\u6790"}${report.scope.stage ? ` \xB7 \u9636\u6BB5 ${report.scope.stage}` : ""} \xB7 CLI ${report.cli.version} \xB7 ${backend}${target?.backend.commit ? `\uFF08commit ${target.backend.commit.slice(0, 7)}\uFF09` : ""}`,
|
|
14480
14868
|
"\u4E0B\u4E00\u6B65\u547D\u4EE4\u5728\u9879\u76EE\u76EE\u5F55\u6267\u884C\u3002"
|
|
14481
14869
|
];
|
|
14482
14870
|
const groups = [
|
|
14483
14871
|
["\u672C\u673A\u5DE5\u4F4D", report.results.filter((r) => r.layer === "local")],
|
|
14484
14872
|
...report.environments.map((env2) => [`\u8FDE\u63A5\u4E0E\u8EAB\u4EFD \xB7 ${env2.name}${env2.target ? "\uFF08\u76EE\u6807\uFF09" : ""}`, report.results.filter((r) => r.layer === "connect" && r.env === env2.name)])
|
|
14485
14873
|
];
|
|
14486
|
-
|
|
14874
|
+
if (target) groups.push(
|
|
14875
|
+
[`\u5E73\u53F0\u5E95\u5EA7 \xB7 ${target.name}${target.server.deploymentTenancy === "shared" ? "\uFF08\u5171\u4EAB\u5B9E\u4F8B\uFF1A\u5E73\u53F0\u5C42\u53EA\u5BF9\u5E73\u53F0\u8FD0\u7EF4\u5F00\u653E\uFF09" : ""}`, report.results.filter((r) => r.layer === "platform" && r.env === target.name), "platform"],
|
|
14876
|
+
[`\u79DF\u6237\u5C31\u7EEA \xB7 \u79DF\u6237 ${target.tenant}`, report.results.filter((r) => r.layer === "tenant" && r.env === target.name), "tenant"]
|
|
14877
|
+
);
|
|
14878
|
+
for (const [label, rows2, serverLayer] of groups) {
|
|
14487
14879
|
out.push("", label);
|
|
14880
|
+
if (!rows2.length && serverLayer && report.scope.incompleteBecause.includes(`empty-layer:${serverLayer}`)) {
|
|
14881
|
+
const knownLayer = reportCatalogs.get(report)?.checks.some((item) => item.spec?.layer === serverLayer);
|
|
14882
|
+
out.push(` \u2205 ${knownLayer && report.scope.stage ? `\u672C\u5C42\u5728\u9636\u6BB5 ${report.scope.stage} \u6CA1\u6709\u68C0\u67E5` : "\u672C\u5C42\u5728\u670D\u52A1\u7AEF\u76EE\u5F55\u91CC\u6CA1\u6709\u68C0\u67E5"}\uFF08empty-layer:${serverLayer}\uFF09`);
|
|
14883
|
+
}
|
|
14488
14884
|
const folded = /* @__PURE__ */ new Set();
|
|
14489
14885
|
for (const row of rows2) {
|
|
14490
|
-
|
|
14491
|
-
|
|
14886
|
+
const v = row.verdict;
|
|
14887
|
+
if (row.code === "PREREQUISITE_NOT_MET" || row.code === "PLATFORM_OPS_ONLY") {
|
|
14888
|
+
const key2 = row.code === "PLATFORM_OPS_ONLY" ? row.code : `${row.env}:${v.note}`;
|
|
14492
14889
|
if (folded.has(key2)) continue;
|
|
14493
14890
|
folded.add(key2);
|
|
14494
|
-
const matching = rows2.filter((r) => r.code === row.code && r.env === row.env && r.verdict.note ===
|
|
14495
|
-
|
|
14496
|
-
|
|
14891
|
+
const matching = rows2.filter((r) => r.code === row.code && (row.code === "PLATFORM_OPS_ONLY" || r.env === row.env && r.verdict.note === v.note));
|
|
14892
|
+
if (row.code === "PREREQUISITE_NOT_MET") {
|
|
14893
|
+
const outside = row.summary === "\u524D\u7F6E\u9879\u4E0D\u5728\u672C\u6B21\u8303\u56F4\u5185";
|
|
14894
|
+
out.push(indented(`${matching.map((r) => r.name).join("\u3001")}\uFF1A${outside ? "\u524D\u7F6E\u9879\u4E0D\u5728\u672C\u6B21\u8303\u56F4\u5185" : "\u524D\u7F6E\u672A\u901A\u8FC7"}\uFF08${v.note}\uFF09`, " \xB7 "));
|
|
14895
|
+
if (outside) {
|
|
14896
|
+
for (const item of matching) if (item.nextStep?.command)
|
|
14897
|
+
out.push(indented(`\u2192 ${item.nextStep.command} [${item.nextStep.owner}]`));
|
|
14898
|
+
}
|
|
14899
|
+
continue;
|
|
14900
|
+
}
|
|
14901
|
+
out.push(indented(`\u5168\u90E8 ${matching.length} \u9879 \u672A\u6267\u884C\uFF1A${row.summary}`, " ? "));
|
|
14902
|
+
} else {
|
|
14903
|
+
const mark = v?.level === "FOUND" ? v.grade === "CRITICAL" ? "\u2717" : "!" : { PASS: "\u2713", UNDETERMINED: "?", NOT_RUN: "\xB7", NOT_APPLICABLE: "\u2205" }[v?.level] ?? "?";
|
|
14904
|
+
out.push(` ${mark} ${row.name}${row.requirement === "OPTIONAL" ? "\uFF08\u9009\u68C0\uFF09" : ""}${row.layer === "local" && row.env ? ` \xB7 ${row.env}` : ""} ${String(row.summary).replace(/\r?\n/g, "\n ")}`);
|
|
14497
14905
|
}
|
|
14498
|
-
|
|
14499
|
-
|
|
14500
|
-
|
|
14501
|
-
|
|
14502
|
-
|
|
14503
|
-
|
|
14504
|
-
}
|
|
14505
|
-
|
|
14506
|
-
|
|
14507
|
-
|
|
14508
|
-
`\
|
|
14509
|
-
);
|
|
14906
|
+
if (v?.note) out.push(indented(v.note));
|
|
14907
|
+
if (v?.level !== "PASS" && row.nextStep && (v?.level !== "NOT_APPLICABLE" || row.nextStep.command)) out.push(indented(`\u2192 ${row.nextStep.command ?? "\u6309\u672C\u9879\u8BF4\u660E\u5904\u7406\u540E\u91CD\u8DD1 hcm chiron doctor"} [${row.nextStep.owner}]`));
|
|
14908
|
+
}
|
|
14909
|
+
}
|
|
14910
|
+
const active = report.results.filter(isOptIn).length;
|
|
14911
|
+
const coverage = (report.coverage.total === null ? `${report.coverage.checked}/?\uFF08\u670D\u52A1\u7AEF\u68C0\u67E5\u6570\u672A\u77E5\uFF09` : `${report.coverage.checked}/${report.coverage.total}`) + (active ? `\uFF08${active} \u9879\u9700 --active\uFF09` : "");
|
|
14912
|
+
out.push("", `\u7ED3\u8BBA\uFF1A${report.verdict.replaceAll("_", " ")} \xB7 ${report.foundByGrade.CRITICAL} \u963B\u65AD \xB7 ${report.foundByGrade.WARN} \u98CE\u9669 \xB7 ${report.counts.UNDETERMINED + report.counts.NOT_RUN - active} \u672A\u5224 \xB7 \u5DF2\u6838 ${coverage}`);
|
|
14913
|
+
const policyCatalog = reportCatalogs.get(report), disabled = report.scope.policyDisabled;
|
|
14914
|
+
if (disabled.length) out.push(`\u9009\u68C0\u672A\u542F\u7528\uFF1A${disabled.map((r) => policyDescription(r, policyCatalog)).join("\uFF1B")}`);
|
|
14915
|
+
for (const row of disabled.filter((r) => report.scope.only.includes(r.id)))
|
|
14916
|
+
out.push(`\u8BE5\u9879\u5DF2\u6309\u79DF\u6237\u7B56\u7565\u5173\u95ED\uFF1A${policyCatalog?.checks.find((c2) => c2.id === row.id)?.name ?? row.id}\uFF1B${recovery(row, disabled, policyCatalog, reportRecoveryCommands.get(report))}`);
|
|
14917
|
+
if (report.scope.incompleteBecause.includes("catalog-changed")) out.push("\u6838\u9A8C\u671F\u95F4\u68C0\u67E5\u76EE\u5F55\u53D1\u751F\u53D8\u5316\uFF0C\u7A0D\u540E\u91CD\u8DD1");
|
|
14510
14918
|
const actions = firstActions(report.results);
|
|
14511
14919
|
if (actions.length) out.push(`\u5148\u5904\u7406\uFF1A${actions.map((r) => `${r.checkId}${r.env ? `\uFF08${r.env}\uFF09` : ""}`).join("\u3001")}`);
|
|
14512
14920
|
return out.join("\n");
|
|
14513
14921
|
}
|
|
14514
14922
|
|
|
14923
|
+
// src/commands/doctor/catalog.ts
|
|
14924
|
+
var localCriterion = {
|
|
14925
|
+
"local.project.env": "env.yaml \u5B58\u5728\u3001\u53EF\u89E3\u6790\uFF0C\u76EE\u6807\u73AF\u5883\u80FD\u89E3\u6790\u5230\u9879\u76EE\u73AF\u5883",
|
|
14926
|
+
"local.credential": "\u6BCF\u4E2A\u9879\u76EE\u73AF\u5883\u6709\u5339\u914D endpoint \u4E0E\u79DF\u6237\u7684\u672C\u673A\u51ED\u636E\u69FD",
|
|
14927
|
+
"local.cli.version": "\u4E0E npm \u6700\u65B0 CLI \u7248\u672C\u6BD4\u8F83",
|
|
14928
|
+
"local.skills.installed": "\u4E24\u79CD\u5E03\u5C40\u7684\u6280\u80FD\u5E76\u96C6\u3001\u9501\u6587\u4EF6\u4E0E\u76EE\u6807\u73AF\u5883\u4E00\u81F4",
|
|
14929
|
+
"local.skills.fresh": "\u672C\u673A\u6280\u80FD\u4E0E\u76EE\u6807\u73AF\u5883\u7684\u4EA7\u54C1\u6280\u80FD\u76EE\u5F55\u5BF9\u8D26",
|
|
14930
|
+
"local.boundary": "\u9879\u76EE\u8FB9\u754C\u5757\u5B58\u5728\uFF0C\u4E14\u4E0D\u662F CLI fallback \u526F\u672C",
|
|
14931
|
+
"local.method": "\u5B9E\u65BD\u65B9\u6CD5\u5305\u5DF2\u5B89\u88C5\u3001\u7248\u672C\u4E0E\u672C\u673A\u526F\u672C\u4E00\u81F4",
|
|
14932
|
+
"local.cases": "\u6848\u4F8B\u5E93\u7D22\u5F15\u53EF\u8BFB\u53D6\uFF0C\u8FDC\u7AEF\u4E0E\u7F13\u5B58\u6765\u6E90\u53EF\u8FA8",
|
|
14933
|
+
"local.jira": "Jira \u4EE4\u724C\u3001\u672C\u4EBA\u8EAB\u4EFD\u53CA\u9879\u76EE\u53EF\u89C1\u6027\u9010\u9879\u6838\u9A8C",
|
|
14934
|
+
"connect.connectivity": "\u514D\u8BA4\u8BC1\u8BFB\u53D6\u540E\u7AEF\u7248\u672C\u7AEF\u70B9\uFF0C\u786E\u8BA4\u540E\u7AEF\u53EF\u8FBE",
|
|
14935
|
+
"connect.identity": "\u670D\u52A1\u7AEF\u786E\u8BA4 token \u4E3B\u4F53\u53CA\u79DF\u6237\u4E0E\u9879\u76EE\u58F0\u660E\u4E00\u81F4",
|
|
14936
|
+
"connect.config-admin": "\u79DF\u6237 meta \u6E05\u5355\u53EF\u8BFB\uFF0C\u96F6\u6761\u4E5F\u6709\u6548",
|
|
14937
|
+
"connect.layer": "\u80FD\u5224\u51FA\u5F53\u524D workspace \u5C42",
|
|
14938
|
+
"connect.websocket": "\u5BF9\u8BDD WebSocket \u63E1\u624B\u8FD4\u56DE HTTP 101",
|
|
14939
|
+
"connect.health-api": "\u670D\u52A1\u7AEF\u4F53\u68C0\u76EE\u5F55\u53EF\u8BFB\u4E14\u54CD\u5E94\u5F62\u72B6\u5408\u6CD5",
|
|
14940
|
+
"connect.exposure": "\u533F\u540D\u5065\u5EB7\u7AEF\u70B9\u4E0D\u66B4\u9732\u7EC4\u4EF6\u8BE6\u60C5"
|
|
14941
|
+
};
|
|
14942
|
+
var critical = /* @__PURE__ */ new Set([
|
|
14943
|
+
"local.project.env",
|
|
14944
|
+
"local.credential",
|
|
14945
|
+
"local.skills.installed",
|
|
14946
|
+
"connect.connectivity",
|
|
14947
|
+
"connect.identity",
|
|
14948
|
+
"connect.config-admin"
|
|
14949
|
+
]);
|
|
14950
|
+
var special = /* @__PURE__ */ new Set([
|
|
14951
|
+
"NEED_SYSTEM_ADMIN",
|
|
14952
|
+
"NEED_CONFIG_ADMIN",
|
|
14953
|
+
"OPT_IN_REQUIRED",
|
|
14954
|
+
"PLATFORM_OPS_ONLY",
|
|
14955
|
+
"DEFINITION_MISSING",
|
|
14956
|
+
"INVALID_DEFINITION",
|
|
14957
|
+
"DEFINITIONS_UNAVAILABLE"
|
|
14958
|
+
]);
|
|
14959
|
+
var object2 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
14960
|
+
var codeRows = (value) => Array.isArray(value) ? value.filter(object2) : [];
|
|
14961
|
+
var code = (row) => String(row.code ?? "");
|
|
14962
|
+
function listCatalog(ctx, reason) {
|
|
14963
|
+
const catalog = ctx.environments.find((e) => e.report.target)?.catalog;
|
|
14964
|
+
const checks = [
|
|
14965
|
+
...CHECKS.map((d) => ({ id: d.id, layer: d.layer, name: d.name, requirement: d.requirement, stages: d.stages, source: "cli" })),
|
|
14966
|
+
...(catalog?.checks ?? []).map((d) => ({
|
|
14967
|
+
id: d.id,
|
|
14968
|
+
layer: d.spec?.layer,
|
|
14969
|
+
name: d.name,
|
|
14970
|
+
requirement: d.requirement,
|
|
14971
|
+
stages: Array.isArray(d.stages) ? d.stages : [],
|
|
14972
|
+
source: "server"
|
|
14973
|
+
}))
|
|
14974
|
+
];
|
|
14975
|
+
return {
|
|
14976
|
+
checks,
|
|
14977
|
+
placeholders: SERVER_PLACEHOLDERS.map((d) => ({
|
|
14978
|
+
id: d.id,
|
|
14979
|
+
layer: d.layer,
|
|
14980
|
+
note: "\u670D\u52A1\u7AEF\u62A5\u544A\u7F3A\u5E2D\u6216\u5F02\u5E38\u65F6\u4EE3\u8868\u8BE5\u5C42\u8BF7\u6C42\u8303\u56F4\u7684\u5360\u4F4D\u884C\uFF1B\u4E0D\u662F\u53EF\u7B5B\u9009\u7684\u68C0\u67E5"
|
|
14981
|
+
})),
|
|
14982
|
+
server: reason ? { known: false, reason, catalogRevision: null } : { known: true, catalogRevision: catalog?.catalogRevision ?? null }
|
|
14983
|
+
};
|
|
14984
|
+
}
|
|
14985
|
+
function explainCatalog(ctx, id, reason) {
|
|
14986
|
+
const env2 = ctx.targetEnv ?? "<env>";
|
|
14987
|
+
const local = CHECKS.find((d) => d.id === id);
|
|
14988
|
+
if (local) return {
|
|
14989
|
+
id,
|
|
14990
|
+
layer: local.layer,
|
|
14991
|
+
name: local.name,
|
|
14992
|
+
source: "cli",
|
|
14993
|
+
criterion: localCriterion[id],
|
|
14994
|
+
requirement: local.requirement,
|
|
14995
|
+
stages: local.stages,
|
|
14996
|
+
grade: critical.has(id) ? "CRITICAL" : "WARN",
|
|
14997
|
+
dependsOn: local.dependsOn,
|
|
14998
|
+
coverageForm: local.coverageForm,
|
|
14999
|
+
coverageDomain: local.coverageDomain,
|
|
15000
|
+
timeoutMs: local.timeoutMs,
|
|
15001
|
+
codes: local.codes.map((key2) => {
|
|
15002
|
+
const row2 = CODE_TABLE[key2];
|
|
15003
|
+
return {
|
|
15004
|
+
code: key2,
|
|
15005
|
+
summaryTemplate: row2?.summary ?? key2,
|
|
15006
|
+
nextStep: row2?.command?.(env2) ?? null,
|
|
15007
|
+
owner: row2?.owner ?? local.owner
|
|
15008
|
+
};
|
|
15009
|
+
}),
|
|
15010
|
+
skill: null
|
|
15011
|
+
};
|
|
15012
|
+
const placeholder = SERVER_PLACEHOLDERS.find((d) => d.id === id);
|
|
15013
|
+
if (placeholder) return {
|
|
15014
|
+
id,
|
|
15015
|
+
layer: placeholder.layer,
|
|
15016
|
+
name: placeholder.name,
|
|
15017
|
+
source: "cli",
|
|
15018
|
+
note: "\u5360\u4F4D\u884C\uFF1A\u670D\u52A1\u7AEF\u62A5\u544A\u7F3A\u5E2D\u6216\u5F02\u5E38\u65F6\u4EE3\u8868\u8BE5\u5C42\u8BF7\u6C42\u8303\u56F4\uFF0C\u4E0D\u662F\u670D\u52A1\u7AEF\u76EE\u5F55\u91CC\u7684\u53EF\u7B5B\u9009\u68C0\u67E5",
|
|
15019
|
+
requirement: placeholder.requirement,
|
|
15020
|
+
dependsOn: placeholder.dependsOn,
|
|
15021
|
+
codes: placeholder.codes.map((key2) => ({
|
|
15022
|
+
code: key2,
|
|
15023
|
+
summaryTemplate: CODE_TABLE[key2]?.summary ?? key2,
|
|
15024
|
+
nextStep: CODE_TABLE[key2]?.command?.(env2) ?? null,
|
|
15025
|
+
owner: CODE_TABLE[key2]?.owner ?? placeholder.owner
|
|
15026
|
+
}))
|
|
15027
|
+
};
|
|
15028
|
+
if (!id.startsWith("platform.") && !id.startsWith("tenant.")) throw new Error(`\u68C0\u67E5 id ${id} \u4E0D\u5B58\u5728\uFF1B\u53EF\u9009 id \u524D\u7F00\uFF1Alocal.\u3001connect.\u3001platform.\u3001tenant.`);
|
|
15029
|
+
if (reason) throw new Error(`\u670D\u52A1\u7AEF\u76EE\u5F55\u672A\u53D6\u5230\uFF0C\u65E0\u6CD5\u8BF4\u660E ${id}\uFF1A${reason}`);
|
|
15030
|
+
const catalog = ctx.environments.find((e) => e.report.target)?.catalog;
|
|
15031
|
+
const row = catalog?.checks.find((d) => d.id === id);
|
|
15032
|
+
if (!row) throw new Error(`\u68C0\u67E5 id ${id} \u4E0D\u5B58\u5728\uFF1B\u53EF\u9009 id \u524D\u7F00\uFF1Alocal.\u3001connect.\u3001platform.\u3001tenant.`);
|
|
15033
|
+
const spec = object2(row.spec) ? row.spec : {};
|
|
15034
|
+
const reserved = codeRows(catalog?.reservedCodes).filter((item) => {
|
|
15035
|
+
const key2 = code(item);
|
|
15036
|
+
return !special.has(key2) || key2 === "OPT_IN_REQUIRED" && spec.active === true || key2 === "PLATFORM_OPS_ONLY" && spec.layer === "platform" || key2 === "DEFINITION_MISSING" && spec.layer === "tenant" || key2 === "INVALID_DEFINITION" && spec.layer === "tenant" || key2 === "DEFINITIONS_UNAVAILABLE" && spec.layer === "tenant" || key2 === "NEED_SYSTEM_ADMIN" && spec.requiredPermission === "SYSTEM_ADMIN" || key2 === "NEED_CONFIG_ADMIN" && spec.requiredPermission === "CONFIG_ADMIN";
|
|
15037
|
+
});
|
|
15038
|
+
return {
|
|
15039
|
+
id,
|
|
15040
|
+
layer: spec.layer,
|
|
15041
|
+
name: row.name,
|
|
15042
|
+
source: "server",
|
|
15043
|
+
criterion: row.description,
|
|
15044
|
+
requirement: row.requirement,
|
|
15045
|
+
stages: row.stages,
|
|
15046
|
+
grade: row.grade,
|
|
15047
|
+
...row.gradeByStage !== void 0 ? { gradeByStage: row.gradeByStage } : {},
|
|
15048
|
+
dependsOn: row.dependsOn,
|
|
15049
|
+
ruleType: row.ruleType,
|
|
15050
|
+
evaluatorKey: row.evaluatorKey,
|
|
15051
|
+
ruleDsl: row.ruleDsl,
|
|
15052
|
+
coverageForm: spec.coverageForm,
|
|
15053
|
+
coverageDomain: spec.coverageDomain,
|
|
15054
|
+
queryMode: spec.queryMode,
|
|
15055
|
+
requiredPermission: spec.requiredPermission,
|
|
15056
|
+
timeout: spec.timeout,
|
|
15057
|
+
paramSchema: spec.paramSchema,
|
|
15058
|
+
enabled: row.enabled,
|
|
15059
|
+
policySource: row.policySource,
|
|
15060
|
+
definitionId: row.definitionId,
|
|
15061
|
+
by: row.by,
|
|
15062
|
+
at: row.at,
|
|
15063
|
+
codes: codeRows(spec.codes),
|
|
15064
|
+
reservedCodes: reserved,
|
|
15065
|
+
...row.skill ? { skill: row.skill } : {}
|
|
15066
|
+
};
|
|
15067
|
+
}
|
|
15068
|
+
function renderCatalogList(data) {
|
|
15069
|
+
const lines = [
|
|
15070
|
+
"\u68C0\u67E5 id \xB7 \u5C42 \xB7 \u540D\u79F0 \xB7 \u5FC5\u68C0/\u9009\u68C0 \xB7 \u9636\u6BB5",
|
|
15071
|
+
...data.checks.map((d) => `${d.id} \xB7 ${d.layer} \xB7 ${d.name} \xB7 ${d.requirement === "OPTIONAL" ? "\u9009\u68C0" : "\u5FC5\u68C0"} \xB7 ${d.stages.join(", ")}`),
|
|
15072
|
+
"\u5360\u4F4D\u884C\uFF1A",
|
|
15073
|
+
...data.placeholders.map((d) => `${d.id} \xB7 ${d.layer} \xB7 ${d.note}`)
|
|
15074
|
+
];
|
|
15075
|
+
if (!data.server.known) lines.push(`\u670D\u52A1\u7AEF\u76EE\u5F55\u672A\u53D6\u5230\uFF1A${data.server.reason}`);
|
|
15076
|
+
return lines.join("\n");
|
|
15077
|
+
}
|
|
15078
|
+
function renderCatalogExplanation(item) {
|
|
15079
|
+
const row = item;
|
|
15080
|
+
const lines = [
|
|
15081
|
+
`${row.id} \xB7 ${row.name} \xB7 ${row.layer}`,
|
|
15082
|
+
`\u5224\u636E\uFF1A${row.criterion ?? row.note ?? "\u65E0"}`,
|
|
15083
|
+
`\u9636\u6BB5\uFF1A${Array.isArray(row.stages) ? row.stages.join(", ") : "\u65E0"}`,
|
|
15084
|
+
`grade\uFF1A${row.grade ?? "\u65E0"}`,
|
|
15085
|
+
`gradeByStage\uFF1A${row.gradeByStage ? JSON.stringify(row.gradeByStage) : "\u65E0"}`,
|
|
15086
|
+
`\u4F9D\u8D56\uFF1A${Array.isArray(row.dependsOn) && row.dependsOn.length ? row.dependsOn.join(", ") : "\u65E0"}`,
|
|
15087
|
+
`\u5B9A\u4E49\u57DF\uFF1A${row.coverageDomain ?? "\u65E0"}`,
|
|
15088
|
+
`\u6280\u80FD\uFF1A${row.skill ?? "\u65E0"}`,
|
|
15089
|
+
"\u7801\u8868\uFF1A"
|
|
15090
|
+
];
|
|
15091
|
+
for (const item2 of [...codeRows(row.codes), ...codeRows(row.reservedCodes)])
|
|
15092
|
+
lines.push(` ${code(item2)} \xB7 ${item2.summaryTemplate ?? "\u65E0"} \xB7 \u4E0B\u4E00\u6B65\uFF1A${item2.nextStep ?? "\u65E0"} \xB7 owner\uFF1A${item2.owner ?? "\u65E0"}`);
|
|
15093
|
+
return lines.join("\n");
|
|
15094
|
+
}
|
|
15095
|
+
|
|
14515
15096
|
// src/commands/chiron-doctor.ts
|
|
14516
15097
|
var defaultServices = {
|
|
15098
|
+
reportRequest: requestServerReport,
|
|
14517
15099
|
inspectCases: inspectCaseLibrary,
|
|
14518
15100
|
inspectJira,
|
|
14519
15101
|
inspectMethod: inspectMethodForDoctor,
|
|
14520
15102
|
latestVersion: fetchLatestVersion,
|
|
14521
15103
|
skillsFresh: inspectSkillsFresh,
|
|
14522
15104
|
asAuth: (...args) => ensureAsAuth(...args),
|
|
14523
|
-
probe: (endpoint, token, signal) => httpProbe2(
|
|
15105
|
+
probe: (endpoint, token, signal) => httpProbe2(axios8.create({
|
|
14524
15106
|
baseURL: endpoint,
|
|
14525
15107
|
timeout: 5e3,
|
|
14526
15108
|
maxRedirects: 0,
|
|
@@ -14535,6 +15117,47 @@ function validate(args) {
|
|
|
14535
15117
|
code: CliErrorCode31.INVALID_ARGUMENT,
|
|
14536
15118
|
message: `--${key2} \u53EA\u63A5\u53D7 ${choices.join(" / ")}\uFF0C\u6536\u5230 ${value}`
|
|
14537
15119
|
});
|
|
15120
|
+
const stages = ["handover", "baseline", "configure", "migrate", "integrate", "golive", "operate"];
|
|
15121
|
+
if (args.stage !== void 0 && !stages.includes(args.stage.toLowerCase())) throw new CliError30({
|
|
15122
|
+
code: CliErrorCode31.INVALID_ARGUMENT,
|
|
15123
|
+
message: `--stage \u53EA\u63A5\u53D7 ${stages.join(" / ")}\uFF0C\u6536\u5230 ${args.stage}`
|
|
15124
|
+
});
|
|
15125
|
+
if (args.list && args.explain) invalidScope("--list \u4E0E --explain \u4E0D\u80FD\u540C\u7528");
|
|
15126
|
+
if ((args.list || args.explain) && (args.stage !== void 0 || tokens(args.only).length || tokens(args.skip).length || args.active || args.failOn !== void 0)) invalidScope("--list / --explain \u4E0D\u80FD\u4E0E --stage / --only / --skip / --active / --fail-on \u540C\u7528");
|
|
15127
|
+
}
|
|
15128
|
+
var tokens = (value) => (Array.isArray(value) ? value : value ? [value] : []).flatMap((item) => item.split(",")).map((item) => item.trim()).filter(Boolean);
|
|
15129
|
+
var matches = (id, only, skip) => (!only.length || only.some((t) => id.startsWith(t))) && !skip.some((t) => id.startsWith(t));
|
|
15130
|
+
var serverCandidate = (t) => ["platform.", "tenant."].some((prefix) => prefix.startsWith(t) || t.startsWith(prefix));
|
|
15131
|
+
function invalidScope(message) {
|
|
15132
|
+
throw new CliError30({ code: CliErrorCode31.INVALID_ARGUMENT, message });
|
|
15133
|
+
}
|
|
15134
|
+
function scopeFor(args, catalog) {
|
|
15135
|
+
const only = tokens(args.only), skip = tokens(args.skip), stage = args.stage?.toLowerCase() ?? null;
|
|
15136
|
+
const serverChecks = catalog?.checks ?? [];
|
|
15137
|
+
const valid = (t) => CHECKS.some((d) => d.id.startsWith(t)) || serverChecks.some((d) => d.id.startsWith(t)) || catalog?.tenantCatalog.available === false && (t.startsWith("tenant.") || "tenant.".startsWith(t)) || !catalog && serverCandidate(t);
|
|
15138
|
+
for (const t of [...only, ...skip]) if (!valid(t)) invalidScope(`\u8303\u56F4\u524D\u7F00 ${t} \u4E0D\u5B58\u5728\uFF1B\u53EF\u9009\u524D\u7F00\uFF1Alocal.\u3001connect.\u3001platform.\u3001tenant.`);
|
|
15139
|
+
const forwarded = (items) => items.filter((t) => serverChecks.some((d) => d.id.startsWith(t)) || catalog?.tenantCatalog.available === false && (t.startsWith("tenant.") || "tenant.".startsWith(t)) || !catalog && serverCandidate(t));
|
|
15140
|
+
const forwardedOnly = forwarded(only), forwardedSkip = forwarded(skip);
|
|
15141
|
+
const serverIds = new Set(serverChecks.filter((d) => (!stage || Array.isArray(d.stages) && d.stages.some((s) => s.toLowerCase() === stage)) && matches(d.id, only, skip)).map((d) => d.id));
|
|
15142
|
+
const serverLayers = /* @__PURE__ */ new Set();
|
|
15143
|
+
for (const layer2 of ["platform", "tenant"]) {
|
|
15144
|
+
const root = `${layer2}.`;
|
|
15145
|
+
const possible = (!only.length || only.some((t) => root.startsWith(t) || t.startsWith(root))) && !skip.some((t) => root.startsWith(t));
|
|
15146
|
+
if (possible && (!catalog || serverChecks.some((d) => serverIds.has(d.id) && d.spec?.layer === layer2) || layer2 === "tenant" && catalog.tenantCatalog.available === false)) serverLayers.add(layer2);
|
|
15147
|
+
}
|
|
15148
|
+
const serverRelevant = (!only.length || only.some(serverCandidate)) && !["platform.", "tenant."].every((root) => skip.some((t) => root.startsWith(t)));
|
|
15149
|
+
return {
|
|
15150
|
+
stage,
|
|
15151
|
+
only,
|
|
15152
|
+
skip,
|
|
15153
|
+
active: !!args.active,
|
|
15154
|
+
forwardedOnly,
|
|
15155
|
+
forwardedSkip,
|
|
15156
|
+
serverIds,
|
|
15157
|
+
serverLayers,
|
|
15158
|
+
serverRelevant,
|
|
15159
|
+
addedPrerequisites: []
|
|
15160
|
+
};
|
|
14538
15161
|
}
|
|
14539
15162
|
async function readCredential(envFlag, root, as) {
|
|
14540
15163
|
let resolved;
|
|
@@ -14570,8 +15193,7 @@ async function readCredential(envFlag, root, as) {
|
|
|
14570
15193
|
printResolvedEnvironment8(resolved, identity3, resolved.project?.environment.tenant);
|
|
14571
15194
|
return { resolved, identity: identity3, meta: meta2, token };
|
|
14572
15195
|
}
|
|
14573
|
-
async function
|
|
14574
|
-
validate(args);
|
|
15196
|
+
async function prepareContext(args, deps) {
|
|
14575
15197
|
const startedAt = Date.now(), root = path14.resolve(args.project ?? ".");
|
|
14576
15198
|
let file;
|
|
14577
15199
|
let projectObservation = found("ENV_FILE_MISSING", void 0, { evidence: "ABSENT" });
|
|
@@ -14625,29 +15247,113 @@ async function runChironDoctor(args, deps = {}) {
|
|
|
14625
15247
|
}
|
|
14626
15248
|
};
|
|
14627
15249
|
});
|
|
14628
|
-
|
|
14629
|
-
|
|
14630
|
-
|
|
14631
|
-
|
|
14632
|
-
|
|
14633
|
-
|
|
14634
|
-
|
|
14635
|
-
|
|
14636
|
-
|
|
14637
|
-
|
|
14638
|
-
|
|
14639
|
-
|
|
15250
|
+
return { ctx, file, projectObservation, startedAt, root };
|
|
15251
|
+
}
|
|
15252
|
+
async function runChironDoctor(args, deps = {}) {
|
|
15253
|
+
validate(args);
|
|
15254
|
+
for (const t of [...tokens(args.only), ...tokens(args.skip)])
|
|
15255
|
+
if (!CHECKS.some((d) => d.id.startsWith(t)) && !serverCandidate(t)) invalidScope(`\u8303\u56F4\u524D\u7F00 ${t} \u4E0D\u5B58\u5728\uFF1B\u53EF\u9009\u524D\u7F00\uFF1Alocal.\u3001connect.\u3001platform.\u3001tenant.`);
|
|
15256
|
+
const { ctx, file, projectObservation, startedAt, root } = await prepareContext(args, deps);
|
|
15257
|
+
let results = [];
|
|
15258
|
+
try {
|
|
15259
|
+
const mayNeedServer = (!tokens(args.only).length || tokens(args.only).some(serverCandidate)) && !["platform.", "tenant."].every((prefix) => tokens(args.skip).some((t) => prefix.startsWith(t)));
|
|
15260
|
+
const preflight = mayNeedServer && ctx.environments.some((e) => e.report.target) ? await executeChecks(ctx, {
|
|
15261
|
+
checks: CHECKS.filter((d) => ["connect.connectivity", "connect.identity", "connect.health-api"].includes(d.id)),
|
|
15262
|
+
fetchReport: false,
|
|
15263
|
+
onlyTarget: true,
|
|
15264
|
+
budgetMs: Math.max(0, 45e3 - (Date.now() - startedAt))
|
|
15265
|
+
}) : [];
|
|
15266
|
+
const targetBefore = ctx.environments.find((e) => e.report.target);
|
|
15267
|
+
const scope2 = scopeFor(args, targetBefore?.catalog);
|
|
15268
|
+
const selectedLocal = CHECKS.filter((d) => d.layer === "local" && (!scope2.stage || d.stages.includes(scope2.stage)) && matches(d.id, scope2.only, scope2.skip));
|
|
15269
|
+
const selectedConnect = targetBefore ? CHECKS.filter((d) => d.layer === "connect" && (!scope2.stage || d.stages.includes(scope2.stage)) && matches(d.id, scope2.only, scope2.skip)) : [];
|
|
15270
|
+
if (!selectedLocal.length && !selectedConnect.length && !scope2.serverLayers.size) invalidScope(
|
|
15271
|
+
`${!file ? `\u9879\u76EE\u73AF\u5883\u672A\u89E3\u6790\uFF1A${projectObservation.note ?? projectObservation.code ?? "env.yaml \u8BFB\u4E0D\u5230"}\uFF1B\u53BB\u6389 --only \u91CD\u8DD1\u53EF\u770B\u5230 local.project.env \u7684\u7ED3\u8BBA\uFF1B` : ""}\u8FD9\u4E2A\u8303\u56F4\u5185\u6CA1\u6709\u4EFB\u4F55\u68C0\u67E5`
|
|
15272
|
+
);
|
|
15273
|
+
if (scope2.serverLayers.size) scope2.addedPrerequisites = ["connect.connectivity", "connect.identity", "connect.health-api"].filter((id) => !selectedConnect.some((d) => d.id === id));
|
|
15274
|
+
ctx.scope = scope2;
|
|
15275
|
+
const reused = /* @__PURE__ */ new Set([...selectedConnect.map((d) => d.id), ...scope2.addedPrerequisites]);
|
|
15276
|
+
results = await executeChecks(ctx, {
|
|
15277
|
+
precomputed: preflight.filter((row) => reused.has(row.checkId)),
|
|
15278
|
+
budgetMs: Math.max(0, 45e3 - (Date.now() - startedAt))
|
|
15279
|
+
});
|
|
15280
|
+
} finally {
|
|
15281
|
+
await Promise.all(ctx.environments.map(async (env2) => {
|
|
15282
|
+
if (!env2.close) return;
|
|
15283
|
+
try {
|
|
15284
|
+
await env2.close();
|
|
15285
|
+
} catch (error) {
|
|
15286
|
+
const identity3 = results.find((r) => r.checkId === "connect.identity" && r.env === env2.name);
|
|
15287
|
+
if (identity3) identity3.verdict.note = `${identity3.verdict.note ? `${identity3.verdict.note}\uFF1B` : ""}\u4EE3\u7406\u4F1A\u8BDD\u6536\u5C3E\u672A\u786E\u8BA4\uFF1A${safeError(error)}\uFF1B\u670D\u52A1\u7AEF\u6309\u6709\u6548\u671F\u81EA\u7136\u8FC7\u671F`;
|
|
15288
|
+
}
|
|
15289
|
+
}));
|
|
15290
|
+
if (ctx.environments.some((env2) => env2.close)) await releasePendingImpersonationSessions2();
|
|
15291
|
+
}
|
|
15292
|
+
const scope = ctx.scope;
|
|
15293
|
+
const target = ctx.environments.find((env2) => env2.report.target);
|
|
15294
|
+
if (target?.serverReport?.scope?.policyDisabled?.length) process.stderr.write(renderPolicyDisabled(
|
|
15295
|
+
target.serverReport.scope.policyDisabled,
|
|
15296
|
+
target.catalog,
|
|
15297
|
+
target.serverReport.recoveryCommand
|
|
15298
|
+
) + "\n");
|
|
15299
|
+
const report = assembleReport({
|
|
14640
15300
|
results,
|
|
15301
|
+
serverReport: target?.serverReport,
|
|
15302
|
+
catalog: target?.catalog,
|
|
14641
15303
|
environments: ctx.environments.map((e) => e.report),
|
|
14642
|
-
targetEnv,
|
|
15304
|
+
targetEnv: ctx.targetEnv,
|
|
14643
15305
|
project: root,
|
|
14644
15306
|
cliVersion: CLI_VERSION,
|
|
14645
15307
|
startedAt,
|
|
14646
|
-
failOn: args.failOn ?? "blocked"
|
|
15308
|
+
failOn: args.failOn ?? "blocked",
|
|
15309
|
+
scope
|
|
14647
15310
|
});
|
|
15311
|
+
if (target?.serverReport?.recoveryCommand) reportRecoveryCommands.set(report, target.serverReport.recoveryCommand);
|
|
15312
|
+
return report;
|
|
15313
|
+
}
|
|
15314
|
+
async function runChironCatalog(args, deps) {
|
|
15315
|
+
const { ctx } = await prepareContext(args, deps);
|
|
15316
|
+
const target = ctx.environments.find((e) => e.report.target);
|
|
15317
|
+
let preflight = [];
|
|
15318
|
+
try {
|
|
15319
|
+
if (target) preflight = await executeChecks(ctx, {
|
|
15320
|
+
checks: CHECKS.filter((d) => ["connect.connectivity", "connect.identity", "connect.health-api"].includes(d.id)),
|
|
15321
|
+
fetchReport: false,
|
|
15322
|
+
onlyTarget: true
|
|
15323
|
+
});
|
|
15324
|
+
} finally {
|
|
15325
|
+
await Promise.all(ctx.environments.map(async (env2) => {
|
|
15326
|
+
if (env2.close) {
|
|
15327
|
+
try {
|
|
15328
|
+
await env2.close();
|
|
15329
|
+
} catch (error) {
|
|
15330
|
+
process.stderr.write(`\u4EE3\u7406\u4F1A\u8BDD\u6536\u5C3E\u672A\u786E\u8BA4\uFF1A${safeError(error)}
|
|
15331
|
+
`);
|
|
15332
|
+
}
|
|
15333
|
+
}
|
|
15334
|
+
}));
|
|
15335
|
+
if (ctx.environments.some((env2) => env2.close)) await releasePendingImpersonationSessions2();
|
|
15336
|
+
}
|
|
15337
|
+
const blocker = ["connect.connectivity", "connect.identity", "connect.health-api"].map((id) => preflight.find((r) => r.checkId === id && r.env === target?.name)).find((r) => r && r.verdict.level !== "PASS");
|
|
15338
|
+
const project2 = ctx.projectObservation, step2 = project2.code ? codeStep(project2.code, ctx.targetEnv ?? "<env>").command : void 0;
|
|
15339
|
+
const detail = [project2.summary !== project2.code ? project2.summary : void 0, project2.note].filter(Boolean).join("\uFF1B");
|
|
15340
|
+
const reason = !target ? `\u76EE\u6807\u73AF\u5883\u672A\u89E3\u6790\uFF1A${project2.code ?? "env.yaml \u8BFB\u4E0D\u5230"}${project2.code && CODE_TABLE[project2.code] ? ` \xB7 ${CODE_TABLE[project2.code].summary}` : ""}${detail ? `\uFF08${detail}\uFF09` : ""}${step2 ? `\uFF1B\u4E0B\u4E00\u6B65\uFF1A${step2}` : ""}` : blocker ? `${blocker.checkId}\uFF1A${blocker.code ?? blocker.verdict.level} \xB7 ${blocker.summary}${blocker.verdict.note ? `\uFF08${blocker.verdict.note}\uFF09` : ""}\uFF1B\u76EE\u6807 ${target.name} \xB7 ${target.config.endpoint}${blocker.nextStep?.command ? `\uFF1B\u4E0B\u4E00\u6B65\uFF1A${blocker.nextStep.command}` : ""}` : !target.catalog ? "\u4F53\u68C0\u76EE\u5F55\u5C1A\u672A\u53D6\u5F97" : target.catalog.catalogRevision === null || target.catalog.tenantCatalog.available === false ? "\u670D\u52A1\u7AEF\u76EE\u5F55\u7248\u672C\u672A\u77E5\uFF0C\u79DF\u6237\u68C0\u67E5\u5B9A\u4E49\u672A\u53D6\u5230" : void 0;
|
|
15341
|
+
return args.list ? listCatalog(ctx, reason) : explainCatalog(ctx, args.explain, reason);
|
|
14648
15342
|
}
|
|
14649
15343
|
async function chironDoctorCommand(args, deps) {
|
|
14650
15344
|
try {
|
|
15345
|
+
if (args.list || args.explain) {
|
|
15346
|
+
validate(args);
|
|
15347
|
+
const data = await runChironCatalog(args, deps ?? {});
|
|
15348
|
+
if (args.list) {
|
|
15349
|
+
const listing = data;
|
|
15350
|
+
if (!listing.server.known) process.stderr.write(`\u670D\u52A1\u7AEF\u76EE\u5F55\u672A\u53D6\u5230\uFF1A${listing.server.reason}
|
|
15351
|
+
`);
|
|
15352
|
+
}
|
|
15353
|
+
process.stdout.write((args.output === "json" || args.output === "yaml" ? formatObject28(data, { format: args.output }) : args.list ? renderCatalogList(data) : renderCatalogExplanation(data)) + "\n");
|
|
15354
|
+
process.exitCode = 0;
|
|
15355
|
+
return;
|
|
15356
|
+
}
|
|
14651
15357
|
const report = await runChironDoctor(args, deps);
|
|
14652
15358
|
process.stdout.write((args.output === "json" || args.output === "yaml" ? formatObject28(report, { format: args.output }) : renderChironDoctor(report)) + "\n");
|
|
14653
15359
|
process.exitCode = conclude(report.results, { total: report.coverage.total, failOn: args.failOn ?? "blocked" }).exitCode;
|
|
@@ -15540,7 +16246,13 @@ function classify(argv, actionResolution) {
|
|
|
15540
16246
|
return forbidden("removed-command", "`hcm mini` \u5DF2\u79FB\u9664\uFF0C\u6539\u7528 `hcm workspace`\u3002");
|
|
15541
16247
|
}
|
|
15542
16248
|
if (name === "chiron") {
|
|
15543
|
-
if (subcommand === "doctor") return
|
|
16249
|
+
if (subcommand === "doctor") return hasFlag(argv, "--active") ? {
|
|
16250
|
+
risk: "R2",
|
|
16251
|
+
execution: "guarded",
|
|
16252
|
+
effect: "external-probe-accounted",
|
|
16253
|
+
reasonCode: "chiron-doctor-active",
|
|
16254
|
+
reason: "\u4E3B\u52A8\u63A2\u6D4B\u771F\u8C03\u7B2C\u4E09\u65B9\u5E76\u8BB0\u8D26\uFF0C\u4E0D\u5199\u4E1A\u52A1\u6570\u636E\uFF1B\u6309\u9879\u76EE\u7684\u5199\u6388\u6743\u7EAA\u5F8B\u6267\u884C\u3002"
|
|
16255
|
+
} : direct("R1", "remote-read", "chiron-doctor");
|
|
15544
16256
|
if (subcommand === "init") return direct("R1", "managed-local-write", "chiron-project-scaffold");
|
|
15545
16257
|
if (subcommand === "test") return direct("R1", "remote-read", "chiron-regression-test");
|
|
15546
16258
|
if (subcommand === "env") {
|
|
@@ -15926,21 +16638,21 @@ async function resolveCoreAction(request) {
|
|
|
15926
16638
|
`Core \u5143\u6570\u636E\u91CC\u6CA1\u6709 ${request.model}.${request.action} \u8FD9\u4E2A Action\u3002${degraded}next_step=\u7528 \`hcm describe ${request.model}\` \u770B\u5B83\u5217\u51FA\u7684 Action \u540D\uFF08\u811A\u672C Action \u4F1A\u6807 [script]\uFF09`
|
|
15927
16639
|
);
|
|
15928
16640
|
}
|
|
15929
|
-
const
|
|
15930
|
-
if (
|
|
16641
|
+
const matches3 = request.explicitShape ? named.filter((action) => matchesRequest(action, request)) : named;
|
|
16642
|
+
if (matches3.length === 0) {
|
|
15931
16643
|
const shapes = named.map((a) => `scope=${a.scope ?? "?"} method=${(a.httpMethod ?? "?").toUpperCase()}`).join("\uFF1B");
|
|
15932
16644
|
return failed(
|
|
15933
16645
|
"action-shape-mismatch",
|
|
15934
16646
|
`${request.model}.${request.action} \u5B58\u5728\uFF0C\u4F46\u5F62\u6001\u5BF9\u4E0D\u4E0A\uFF1A\u4F60\u7ED9\u7684\u662F scope=${request.scope} method=${request.httpMethod}\uFF0C\u5143\u6570\u636E\u91CC\u662F ${shapes}\u3002next_step=\u53BB\u6389 --scope/--method \u8BA9 CLI \u6309\u5143\u6570\u636E\u81EA\u52A8\u5224\u5B9A\uFF0C\u6216\u6539\u6210\u4E0A\u9762\u7684\u5F62\u6001`
|
|
15935
16647
|
);
|
|
15936
16648
|
}
|
|
15937
|
-
if (
|
|
16649
|
+
if (matches3.length > 1) {
|
|
15938
16650
|
return failed(
|
|
15939
16651
|
"action-metadata-ambiguous",
|
|
15940
16652
|
`${request.model}.${request.action} \u5728\u5143\u6570\u636E\u91CC\u6709\u591A\u79CD\u5F62\u6001\uFF0C\u65E0\u6CD5\u552F\u4E00\u5224\u5B9A\u3002next_step=\u7528 --scope \u4E0E --method \u6307\u660E\u8981\u8C03\u54EA\u4E00\u4E2A`
|
|
15941
16653
|
);
|
|
15942
16654
|
}
|
|
15943
|
-
return policyFromActionMeta(
|
|
16655
|
+
return policyFromActionMeta(matches3[0], request);
|
|
15944
16656
|
} catch {
|
|
15945
16657
|
return failed(
|
|
15946
16658
|
"action-metadata-unavailable",
|
|
@@ -16165,9 +16877,9 @@ function parseJsonLoose(stdout) {
|
|
|
16165
16877
|
return void 0;
|
|
16166
16878
|
}
|
|
16167
16879
|
function pick(value, expr) {
|
|
16168
|
-
const
|
|
16880
|
+
const tokens2 = [...expr.replace(/^\$/, "").matchAll(/\[(\d+)\]|([^.[\]]+)/g)];
|
|
16169
16881
|
let cur = value;
|
|
16170
|
-
for (const t of
|
|
16882
|
+
for (const t of tokens2) {
|
|
16171
16883
|
if (cur === null || cur === void 0) return void 0;
|
|
16172
16884
|
if (t[1] !== void 0) {
|
|
16173
16885
|
if (!Array.isArray(cur)) return void 0;
|
|
@@ -16179,7 +16891,7 @@ function pick(value, expr) {
|
|
|
16179
16891
|
}
|
|
16180
16892
|
return cur;
|
|
16181
16893
|
}
|
|
16182
|
-
function
|
|
16894
|
+
function matches2(actual, rule) {
|
|
16183
16895
|
const r = rule.trim();
|
|
16184
16896
|
if (r === "\u975E\u7A7A" || r === "nonempty") return actual !== void 0 && actual !== null && String(actual) !== "" && !(Array.isArray(actual) && actual.length === 0);
|
|
16185
16897
|
const m = /^(>=|<=|>|<|!=|=)\s*(.*)$/.exec(r);
|
|
@@ -16270,7 +16982,7 @@ async function runCase(spec, root, opts = {}, deps = defaultDeps2) {
|
|
|
16270
16982
|
for (const [expr, rawRule] of Object.entries(want.json)) {
|
|
16271
16983
|
const rule = fill(rawRule);
|
|
16272
16984
|
const actual = pick(parsed, expr);
|
|
16273
|
-
if (!
|
|
16985
|
+
if (!matches2(actual, rule)) bad.push(`${expr} \u5B9E\u9645 ${JSON.stringify(actual)}\uFF0C\u671F\u671B ${rule}`);
|
|
16274
16986
|
}
|
|
16275
16987
|
}
|
|
16276
16988
|
}
|
|
@@ -16421,18 +17133,18 @@ async function deliveryReconCommand(args) {
|
|
|
16421
17133
|
}
|
|
16422
17134
|
}
|
|
16423
17135
|
async function deliveryReconRoundCommand(args) {
|
|
16424
|
-
let
|
|
17136
|
+
let code2;
|
|
16425
17137
|
try {
|
|
16426
17138
|
const result = inspectRound(args.dir ?? ".");
|
|
16427
17139
|
const fmt = args.output ?? "json";
|
|
16428
17140
|
if (fmt !== "json") process.stdout.write(renderRound(result));
|
|
16429
17141
|
process.stdout.write(formatObject31(result, { format: fmt }) + "\n");
|
|
16430
|
-
|
|
17142
|
+
code2 = ROUND_EXIT_CODES[result.state];
|
|
16431
17143
|
} catch (e) {
|
|
16432
17144
|
exitWithError(e);
|
|
16433
|
-
|
|
17145
|
+
code2 = 1;
|
|
16434
17146
|
}
|
|
16435
|
-
process.exitCode =
|
|
17147
|
+
process.exitCode = code2;
|
|
16436
17148
|
return;
|
|
16437
17149
|
}
|
|
16438
17150
|
|
|
@@ -16908,7 +17620,7 @@ import {
|
|
|
16908
17620
|
VERIFY_CRASHED,
|
|
16909
17621
|
VERIFY_WORDS,
|
|
16910
17622
|
WorkLayout,
|
|
16911
|
-
classifyStatus,
|
|
17623
|
+
classifyStatus as classifyStatus2,
|
|
16912
17624
|
runActiveVerify,
|
|
16913
17625
|
runMetaChange,
|
|
16914
17626
|
seedWorkDir as seedWorkDir2
|
|
@@ -16916,9 +17628,9 @@ import {
|
|
|
16916
17628
|
var VERIFY_NOT_ASKED = "verify-not-asked";
|
|
16917
17629
|
var VERIFY_NOT_REACHED = "verify-not-reached";
|
|
16918
17630
|
var VERIFY_ACTIVE_FLAG = "--verify-active";
|
|
16919
|
-
function metaVerifyWords(
|
|
16920
|
-
const word = VERIFY_WORDS[
|
|
16921
|
-
if (word === void 0) throw new Error(`\u6CA1\u6709\u7ED9 ${
|
|
17631
|
+
function metaVerifyWords(code2) {
|
|
17632
|
+
const word = VERIFY_WORDS[code2] ?? CODE_WORDS[code2];
|
|
17633
|
+
if (word === void 0) throw new Error(`\u6CA1\u6709\u7ED9 ${code2} \u914D\u8FC7\u8BDD\uFF1A\u8FD9\u4E2A\u53D6\u503C\u54EA\u5F20\u5224\u8BCD\u8868\u91CC\u90FD\u67E5\u4E0D\u5230`);
|
|
16922
17634
|
return word;
|
|
16923
17635
|
}
|
|
16924
17636
|
function metaRc(change, verify, verifyCode) {
|
|
@@ -17093,7 +17805,7 @@ function metaClient(client3, ctx) {
|
|
|
17093
17805
|
return {
|
|
17094
17806
|
status: res.status,
|
|
17095
17807
|
body: res.data,
|
|
17096
|
-
error:
|
|
17808
|
+
error: classifyStatus2(res.status),
|
|
17097
17809
|
headers: lowerCaseHeaders2(res.headers)
|
|
17098
17810
|
};
|
|
17099
17811
|
} catch (e) {
|
|
@@ -17104,7 +17816,7 @@ function metaClient(client3, ctx) {
|
|
|
17104
17816
|
body: res?.data ?? null,
|
|
17105
17817
|
// 🔴 `-1` **不是** HTTP 状态:网络层没走通与「服务端答了个 4xx」在处置上相反 ——
|
|
17106
17818
|
// 改动轴正是靠这一格把「确认没写」与「不知道写没写」分开。
|
|
17107
|
-
error: status === -1 ? "network" :
|
|
17819
|
+
error: status === -1 ? "network" : classifyStatus2(status),
|
|
17108
17820
|
headers: lowerCaseHeaders2(res?.headers)
|
|
17109
17821
|
};
|
|
17110
17822
|
}
|
|
@@ -17209,14 +17921,14 @@ async function runTriage(args) {
|
|
|
17209
17921
|
return 0;
|
|
17210
17922
|
}
|
|
17211
17923
|
async function deliveryTriageCommand(args) {
|
|
17212
|
-
let
|
|
17924
|
+
let code2;
|
|
17213
17925
|
try {
|
|
17214
|
-
|
|
17926
|
+
code2 = await runTriage(args);
|
|
17215
17927
|
} catch (e) {
|
|
17216
17928
|
exitWithError(e);
|
|
17217
|
-
|
|
17929
|
+
code2 = 1;
|
|
17218
17930
|
}
|
|
17219
|
-
process.exitCode =
|
|
17931
|
+
process.exitCode = code2;
|
|
17220
17932
|
return;
|
|
17221
17933
|
}
|
|
17222
17934
|
|
|
@@ -17406,7 +18118,7 @@ chiron.command("test").description("\u6309\u7528\u4F8B\u8DD1\u4E00\u904D\u5E76\u
|
|
|
17406
18118
|
chiron.command("page").description("\u6253\u5F00\u9875\u9762\u622A\u56FE\u5E76\u5BF9\u7740\u9875\u9762\u5185\u5BB9\u5224\u4E00\u6B21\uFF1A\u81F3\u5C11\u8981\u7ED9\u4E00\u6761 --expect-text\uFF0C\u53EA\u622A\u56FE\u4E0D\u7B97\u9A8C\u6536").argument("<\u8DEF\u5F84>", "\u7AD9\u5185\u8DEF\u5F84\uFF0C\u5982 /dashboard/xxx").requiredOption("--out <file>", "\u622A\u56FE\u843D\u70B9\uFF0C\u5FC5\u987B\u5728\u9879\u76EE\u7684 evidence/ \u4E0B\u4E14\u4EE5 .png \u7ED3\u5C3E").option("--expect-text <text...>", "\u9875\u9762\u4E0A\u5FC5\u987B\u51FA\u73B0\u7684\u6587\u672C\uFF08\u81F3\u5C11\u4E00\u6761\uFF09").option("--reject-text <text...>", "\u9875\u9762\u4E0A\u4E0D\u5F97\u51FA\u73B0\u7684\u6587\u672C").option("--project <dir>", "\u9879\u76EE\u6839\u76EE\u5F55", ".").option("--env <name>", "\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD").option("--wait-ms <ms>", "\u9875\u9762\u6E32\u67D3\u9884\u7B97\u6BEB\u79D2\u6570", "10000").option("--size <WxH>", "\u89C6\u53E3\u5C3A\u5BF8", "1440x900").option("--cdp <endpoint>", "\u4E0D\u81EA\u5DF1\u8D77 Chrome\uFF0C\u8FDE\u5230\u5DF2\u5728\u8DD1\u7684 Chrome\uFF08--remote-debugging-port\uFF09\uFF1A\u6C99\u7BB1\u91CC\u8D77\u4E0D\u4E86 Chrome \u65F6\u7528\uFF1B\u4E5F\u8BFB HCM_CHROME_CDP").option("--eval <js>", "\u622A\u56FE\u524D\u5728\u9875\u9762\u91CC\u8DD1\u7684 JS\uFF08\u51FD\u6570\u4F53\uFF0C\u53EF await\uFF0C\u8FD4\u56DE\u503C\u8FDB\u56DE\u6267\uFF09\uFF1A\u70B9\u6309\u94AE\u3001\u586B\u8868\u3001\u8FFD\u95EE\u90FD\u9760\u5B83\uFF1B\u9700\u8981 Playwright \u6216 --cdp").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((target, opts) => chironPageCommand(target, opts));
|
|
17407
18119
|
chiron.command("doctor").description(
|
|
17408
18120
|
"\u4F53\u68C0\u672C\u673A 9 \u9879\u4E0E\u6BCF\u73AF\u5883\u8FDE\u63A5 7 \u9879\uFF1B\u7ED3\u8BBA READY / READY_WITH_RISKS / BLOCKED"
|
|
17409
|
-
).option("--project <dir>", "\u9879\u76EE\u6839\u76EE\u5F55", ".").option("--env <name>", "\u9009\u5B9A\u76EE\u6807\u73AF\u5883\uFF08\u9ED8\u8BA4 env.yaml default\uFF09\uFF1B\u5176\u4F59\u73AF\u5883\u4ECD\u68C0\u67E5\uFF0C\u5931\u8D25\u8BB0\u98CE\u9669").option("--as <identity>", "\u4EE5\u6307\u5B9A\u8EAB\u4EFD\u4F53\u68C0\uFF08\u6CBF\u7528\u4E1A\u52A1\u547D\u4EE4\u7684\u4EE3\u7406\u56DE\u843D\uFF09").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").option("--fail-on <level>", "\u975E\u96F6\u9000\u51FA\u9608\u503C\uFF1Ablocked | risks
|
|
18121
|
+
).option("--project <dir>", "\u9879\u76EE\u6839\u76EE\u5F55", ".").option("--env <name>", "\u9009\u5B9A\u76EE\u6807\u73AF\u5883\uFF08\u9ED8\u8BA4 env.yaml default\uFF09\uFF1B\u5176\u4F59\u73AF\u5883\u4ECD\u68C0\u67E5\uFF0C\u5931\u8D25\u8BB0\u98CE\u9669").option("--as <identity>", "\u4EE5\u6307\u5B9A\u8EAB\u4EFD\u4F53\u68C0\uFF08\u6CBF\u7528\u4E1A\u52A1\u547D\u4EE4\u7684\u4EE3\u7406\u56DE\u843D\uFF09").option("--stage <stage>", "\u9636\u6BB5\uFF1Ahandover | baseline | configure | migrate | integrate | golive | operate").option("--only <prefix>", "\u53EA\u68C0\u67E5\u8FD9\u4E9B id \u6216\u524D\u7F00\uFF0C\u9017\u53F7\u5206\u9694\uFF1B\u53EF\u91CD\u590D", (value, previous) => [...previous, value], []).option("--skip <prefix>", "\u6392\u9664\u8FD9\u4E9B id \u6216\u524D\u7F00\uFF0C\u9017\u53F7\u5206\u9694\uFF1B\u53EF\u91CD\u590D", (value, previous) => [...previous, value], []).option("--active", "\u5141\u8BB8\u4E3B\u52A8\u63A2\u6D4B\u7B2C\u4E09\u65B9\u5E76\u8BB0\u8D26").option("--list", "\u5217\u51FA\u672C\u673A\u4E0E\u670D\u52A1\u7AEF\u7684\u68C0\u67E5\u76EE\u5F55").option("--explain <id>", "\u8BF4\u660E\u6307\u5B9A\u68C0\u67E5\u7684\u5224\u636E\u3001\u4F9D\u8D56\u548C\u7801\u8868").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").option("--fail-on <level>", "\u975E\u96F6\u9000\u51FA\u9608\u503C\uFF1Ablocked | risks\uFF08\u9ED8\u8BA4 blocked\uFF09").action((opts) => chironDoctorCommand(opts));
|
|
17410
18122
|
var chironSkills = chiron.command("skills").description("\u8FD9\u4E2A\u9879\u76EE\u4ED3\u7684\u6280\u80FD\uFF1A\u8DDF\u76EE\u6807\u73AF\u5883\u5BF9\u9F50");
|
|
17411
18123
|
chironSkills.command("sync").description("\u8BA9\u8FD9\u4E2A\u4ED3\u7684\u6280\u80FD\u8DDF\u76EE\u6807\u73AF\u5883\u5BF9\u9F50\uFF1A\u7B2C\u4E00\u6B21\u5C31\u88C5\u9F50\uFF0C\u4E4B\u540E\u6309\u4EA7\u54C1\u5F53\u524D\u5168\u96C6\u5BF9\u8D26\u3002\u5E42\u7B49\uFF0C\u4EA7\u54C1\u5347\u7EA7\u540E\u8DD1\u5B83").option("--only <id...>", "\u53EA\u8981\u8FD9\u51E0\u4E2A\u6280\u80FD\uFF08\u8FDE\u540C requires \u524D\u7F6E\uFF09\uFF0C\u4E0D\u8BA2\u9605\u5168\u96C6\uFF1B\u8BAD\u7EC3\u573A blind \u6863\u7528").option("--check", "\u53EA\u770B\u4F1A\u53D8\u4EC0\u4E48\uFF0C\u4E0D\u5199\u76D8").option("--target <agent>", "claude\uFF08.claude/skills/\uFF09| codex\uFF08hcm-skills/ + Agent \u7D22\u5F15\uFF09| auto", "auto").option("--global", "\u540C\u6B65\u7528\u6237\u7EA7\u76EE\u5F55\u800C\u975E\u5F53\u524D\u9879\u76EE").option("--dir <path>", "\u540C\u6B65\u6307\u5B9A\u76EE\u5F55").option("--from <dir>", "\u4ECE\u672C\u5730\u76EE\u5F55\u53D6\uFF08\u73B0\u573A\u6539\u8FC7\u7684\u7248\u672C\uFF09\uFF0C\u4E0D\u8D70\u7F51\u7EDC").option("--force", "\u8FDE\u672C\u5730\u6539\u8FC7\u7684\u6280\u80FD\u4E00\u8D77\u8986\u76D6\u6210\u4EA7\u54C1\u8FD9\u4E00\u7248").option("--prune-max <n>", `\u4E00\u8D9F\u6700\u591A\u6E05\u51E0\u4EFD\u4E0A\u6E38\u4E0D\u518D\u53D1\u7684\u6280\u80FD\uFF0C\u8D85\u4E86\u6574\u6279\u62D2\u7EDD\uFF1B0 = \u4E00\u4EFD\u90FD\u522B\u6E05\uFF08\u7F3A\u7701 ${PRUNE_DEFAULT_MAX}\uFF09`).option("--source <kind>", "\u8FD9\u4E00\u8D9F\u770B\u54EA\u4E9B\u6765\u6E90\uFF1Acli\uFF08\u53EA\u770B\u81EA\u5E26\uFF0C\u4E0D\u8FDE\u7F51\uFF09| chiron | all", "all").option("--endpoint <url>", "\u6280\u80FD\u5E93\u5730\u5740\uFF08\u9ED8\u8BA4\u53D6\u9879\u76EE\u73AF\u5883\u6216\u5B89\u88C5\u65F6\u8BB0\u5F55\u7684\u5730\u5740\uFF09").option("--env <name>", "\u4ECE\u8BE5 env \u89E3\u6790 endpoint").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((opts) => skillsSyncCommand(opts));
|
|
17412
18124
|
chironSkills.command("path <id>").description("\u6253\u5370\u8FD9\u4E2A id \u5728\u672C\u9879\u76EE\u5B9E\u9645\u751F\u6548\u90A3\u4E00\u4EFD\u7684\u8DEF\u5F84\uFF08local/ \u906E\u853D sync/\uFF09\uFF0C\u4F9B\u6280\u80FD\u6B63\u6587\u5F15\u7528\uFF0C\u514D\u5F97\u6B63\u6587\u5199\u6B7B\u76EE\u5F55\u5C42\u6570").option("--refs", "\u8981 references/ \u7684\u843D\u70B9\uFF0C\u4E0D\u662F SKILL.md").option("--target <agent>", "claude | codex | auto", "auto").option("--global", "\u770B\u7528\u6237\u7EA7\u76EE\u5F55").option("--dir <path>", "\u770B\u6307\u5B9A\u76EE\u5F55").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((id, opts) => skillsPathCommand(id, opts));
|