@lmzhen/dsh-evolution-commands 0.46.0 → 0.48.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/lib/index.js +466 -384
- package/lib/types/command-fallback.d.ts +2 -2
- package/lib/types/doctor-view.d.ts +11 -3
- package/lib/types/doctor.d.ts +2 -8
- package/lib/types/generated/host-commands.d.ts +8 -8
- package/lib/types/host-command-defs.d.ts +7 -0
- package/lib/types/params.d.ts +0 -25
- package/lib/types/parse.d.ts +0 -19
- package/lib/types/registry.d.ts +8 -13
- package/package.json +6 -6
- package/lib/types/settings-route.d.ts +0 -27
package/lib/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
|
-
import { DEFAULT_SKILL_LIMITS, DIAGNOSTICS_FACT_KEYS, DIAGNOSTICS_RUNTIME_KEYS, DIAGNOSTICS_VIEW_SCHEMA_VERSION, EVOLUTION_PRESET_IDS, HOST_LOCALES, MAINTAINER_PRESET_ID, MAX_TIMER_DELAY_MS, PARAM_EXPOSURE, PARAM_GROUP_LABELS,
|
|
2
|
+
import { DEFAULT_SKILL_LIMITS, DIAGNOSTICS_FACT_KEYS, DIAGNOSTICS_RUNTIME_KEYS, DIAGNOSTICS_VIEW_SCHEMA_VERSION, EVOLUTION_PRESET_IDS, HOST_LOCALES, MAINTAINER_PRESET_ID, MAX_TIMER_DELAY_MS, PARAM_EXPOSURE, PARAM_GROUP_LABELS, PLATFORM_LINE, REVIEWER_PRESET_ID, absentHostServices, appendEvolutionEvent, applyNamespaceMigration, asRecord, atomicWriteFiles, authorityFrom, buildExtractPlanFromLibrary, buildLearnPrompt, clampedNumber, classifyNamespaceMigration, createSubagentChannel, errorText, errorTextIn, eventsFile, evolutionHome, evolutionRoot, hostSurface, isDeprecatedParamId, isPresent, isRecord, isUnknown, liveBool, mutationLockFrom, newRunRegistry, ownerDecisionText, paramSettingsId, planNamespaceMigration, policyStageLimits, probeMtime, probeText, proposalFromPlan, readProposalReport, reportsSweepLockTarget, resolveParamId, scopedPackageName, scopedProbeReport, sweepReports, transactIo, writeProposalReport } from "@lmzhen/dsh-evolution-core";
|
|
3
3
|
import { HOST_ROUTES, json, methodNotAllowed, registerHostRoutes } from "@lmzhen/dsh-evolution-core/http-routes";
|
|
4
4
|
import { existsSync, readFileSync, readdirSync } from "node:fs";
|
|
5
5
|
import { dirname, join } from "node:path";
|
|
@@ -33,7 +33,6 @@ const COMMAND_FALLBACKS = {
|
|
|
33
33
|
"skill-history": { command: "/evolution skill undo <name> [--to v<N>](查看:/evolution skill history <name>)" },
|
|
34
34
|
"skill-health": { command: "/evolution skills refresh(健康行:/evolution doctor)" },
|
|
35
35
|
merge: { command: "/evolution merge status / pending / approve <id> / report" },
|
|
36
|
-
settings: { command: "/evolution params --group deployment(写入由平台插件管理的 row 配置页承载)" },
|
|
37
36
|
diagnostics: {
|
|
38
37
|
command: "/evolution doctor",
|
|
39
38
|
platformCli: "dsh --json /evolution doctor"
|
|
@@ -41,6 +40,12 @@ const COMMAND_FALLBACKS = {
|
|
|
41
40
|
};
|
|
42
41
|
//#endregion
|
|
43
42
|
//#region lib/types/doctor-view.js
|
|
43
|
+
/** The ONE install-form decision; callers only supply the facts their detection read. */
|
|
44
|
+
function classifyInstallForm(input) {
|
|
45
|
+
if (input.full || input.preset) return input.humanGated ? "human-gated" : input.full ? "full" : "preset";
|
|
46
|
+
if (input.host) return input.layeredPreset ? "layered" : "host";
|
|
47
|
+
return input.presetDirInstalled ? "preset-only" : "none";
|
|
48
|
+
}
|
|
44
49
|
const FACT_HOMES = {
|
|
45
50
|
"platform-line": "README.md(兼容线声明)",
|
|
46
51
|
"family-version": "README.md(家族版本)",
|
|
@@ -70,14 +75,17 @@ const RUNTIME_LABELS = {
|
|
|
70
75
|
"install-form-detected": "实际安装方式"
|
|
71
76
|
};
|
|
72
77
|
/**
|
|
73
|
-
* The install form in reader-facing words. The
|
|
74
|
-
*
|
|
78
|
+
* The install form in reader-facing words. The ids are the SAME seven values DoctorReport
|
|
79
|
+
* carries, so the text, --json and the settings card cannot disagree about the form.
|
|
75
80
|
*/
|
|
76
81
|
const FORM_WORDS = Object.freeze({
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
82
|
+
full: "完整功能包",
|
|
83
|
+
"human-gated": "完整功能包(人工审批)",
|
|
84
|
+
preset: "会话预设包",
|
|
85
|
+
host: "仅宿主插件(无模型工具)",
|
|
86
|
+
layered: "分层安装(会话选用)",
|
|
87
|
+
"preset-only": "仅预设行(未挂载插件包)",
|
|
88
|
+
none: "未安装"
|
|
81
89
|
});
|
|
82
90
|
/**
|
|
83
91
|
* Build the seven documentation facts. Values are READER-FACING prose: the CLI text, --json and
|
|
@@ -262,22 +270,15 @@ function pairingRow(inputs) {
|
|
|
262
270
|
}
|
|
263
271
|
function runtimeOf(inputs) {
|
|
264
272
|
const missing = inputs.missingServices ?? [];
|
|
265
|
-
const fold = inputs.sessionFoldClassifierPresent !== false;
|
|
266
273
|
return [
|
|
267
274
|
channelRow(inputs.channels),
|
|
268
275
|
presetRow(inputs.presets),
|
|
269
276
|
hostRow(inputs.host, inputs.hostRouteCount),
|
|
270
|
-
|
|
277
|
+
{
|
|
271
278
|
key: "session-fold",
|
|
272
279
|
label: RUNTIME_LABELS["session-fold"] ?? "会话事件读取",
|
|
273
280
|
status: "ok",
|
|
274
281
|
detail: "事件读取通道正常:对话内容会被读取,其余记录忽略。"
|
|
275
|
-
} : {
|
|
276
|
-
key: "session-fold",
|
|
277
|
-
label: RUNTIME_LABELS["session-fold"] ?? "会话事件读取",
|
|
278
|
-
status: "fail",
|
|
279
|
-
detail: "事件读取组件缺失,无法确认读取通道正常。",
|
|
280
|
-
remedy: "重新安装完整功能包(evolution-all)。"
|
|
281
282
|
},
|
|
282
283
|
missing.length === 0 ? {
|
|
283
284
|
key: "platform-services",
|
|
@@ -497,20 +498,28 @@ async function assembleDoctorInputs(ctx, extras = {}) {
|
|
|
497
498
|
const hasHost = bundles.some((name) => name.endsWith("dsh-evolution-host"));
|
|
498
499
|
const hasFamilyPreset = listed.some((entry) => typeof entry.id === "string" && EVOLUTION_PRESET_IDS.includes(entry.id));
|
|
499
500
|
const humanGated = get("evolutionApproval")?.isEnabled === true;
|
|
500
|
-
const
|
|
501
|
-
|
|
501
|
+
const detectedId = classifyInstallForm({
|
|
502
|
+
full: hasAll,
|
|
503
|
+
preset: hasPreset,
|
|
504
|
+
host: hasHost,
|
|
505
|
+
humanGated,
|
|
506
|
+
layeredPreset: hasFamilyPreset,
|
|
507
|
+
presetDirInstalled: false
|
|
508
|
+
});
|
|
509
|
+
const detectedForm = detectedId === "full" || detectedId === "preset" || detectedId === "human-gated" ? {
|
|
510
|
+
id: detectedId,
|
|
502
511
|
evidence: [hasAll ? "bundle dsh-evolution-all installed" : "bundle dsh-evolution-preset installed", ...humanGated ? ["approval.enabled: true"] : []],
|
|
503
512
|
confidence: "declared"
|
|
504
|
-
} :
|
|
505
|
-
id: "
|
|
513
|
+
} : detectedId === "layered" ? {
|
|
514
|
+
id: "layered",
|
|
506
515
|
evidence: ["bundle dsh-evolution-host installed", "family agent preset registered"],
|
|
507
516
|
confidence: "declared"
|
|
508
|
-
} : {
|
|
509
|
-
id: "
|
|
517
|
+
} : detectedId === "host" ? {
|
|
518
|
+
id: "host",
|
|
510
519
|
evidence: ["bundle dsh-evolution-host installed"],
|
|
511
520
|
confidence: "declared"
|
|
512
521
|
} : {
|
|
513
|
-
id: "
|
|
522
|
+
id: "none",
|
|
514
523
|
evidence: ["no family bundle was reported by the platform manager"],
|
|
515
524
|
confidence: "inferred"
|
|
516
525
|
};
|
|
@@ -549,7 +558,6 @@ async function assembleDoctorInputs(ctx, extras = {}) {
|
|
|
549
558
|
orphaned: 0
|
|
550
559
|
},
|
|
551
560
|
missingServices,
|
|
552
|
-
sessionFoldClassifierPresent: typeof classifySessionEvent === "function",
|
|
553
561
|
platformPairing: extras.platformPairing ?? pairingOf(extras.hostVersion ?? platformVersion, PLATFORM_LINE)
|
|
554
562
|
};
|
|
555
563
|
}
|
|
@@ -636,150 +644,6 @@ async function withBudget(pending, timeoutMs, fallback) {
|
|
|
636
644
|
}
|
|
637
645
|
}
|
|
638
646
|
//#endregion
|
|
639
|
-
//#region lib/types/settings-route.js
|
|
640
|
-
/**
|
|
641
|
-
* Family settings data plane.
|
|
642
|
-
*
|
|
643
|
-
* The platform RPC only serves its own namespace allowlist, so the browser cannot
|
|
644
|
-
* reach family namespaces through /api/settings.* even though the underlying
|
|
645
|
-
* settings service has them registered. These exact routes reuse the SAME
|
|
646
|
-
* provider (describe/mutate), so storage, schema validation, revision conflicts
|
|
647
|
-
* and redaction stay platform-owned; only the transport is family-scoped.
|
|
648
|
-
* @module @lmzhen/dsh-evolution-commands/settings-route
|
|
649
|
-
*/
|
|
650
|
-
const FAMILY_NAMESPACES = new Set(Object.keys(PARAM_NAMESPACES));
|
|
651
|
-
function normaliseValue(value) {
|
|
652
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) return value;
|
|
653
|
-
const out = {};
|
|
654
|
-
for (const [key, field] of Object.entries(value)) {
|
|
655
|
-
const live = unwrapLive(field);
|
|
656
|
-
out[key] = live === void 0 ? field : live;
|
|
657
|
-
}
|
|
658
|
-
return out;
|
|
659
|
-
}
|
|
660
|
-
function snapshotOf(provider, descriptor) {
|
|
661
|
-
if (descriptor === void 0) return {
|
|
662
|
-
status: "unavailable",
|
|
663
|
-
writable: false,
|
|
664
|
-
value: void 0,
|
|
665
|
-
user: void 0,
|
|
666
|
-
base: void 0,
|
|
667
|
-
revision: void 0,
|
|
668
|
-
reason: "not-served"
|
|
669
|
-
};
|
|
670
|
-
return {
|
|
671
|
-
status: "ready",
|
|
672
|
-
writable: provider.writable,
|
|
673
|
-
value: normaliseValue(descriptor.value),
|
|
674
|
-
user: descriptor.user,
|
|
675
|
-
base: descriptor.base,
|
|
676
|
-
revision: descriptor.revision
|
|
677
|
-
};
|
|
678
|
-
}
|
|
679
|
-
function providerOf(getProvider) {
|
|
680
|
-
return getProvider();
|
|
681
|
-
}
|
|
682
|
-
/**
|
|
683
|
-
* @param getProvider - resolves the live platform settings provider per request.
|
|
684
|
-
* @returns exact routes for family settings describe/mutate.
|
|
685
|
-
*/
|
|
686
|
-
function makeSettingsRoutes(getProvider) {
|
|
687
|
-
return [{
|
|
688
|
-
path: HOST_ROUTES.settings.describe,
|
|
689
|
-
methods: ["GET"],
|
|
690
|
-
requestBody: "buffered",
|
|
691
|
-
fetch: async (request) => {
|
|
692
|
-
if (request.method !== "GET") return methodNotAllowed(["GET"]);
|
|
693
|
-
const provider = providerOf(getProvider);
|
|
694
|
-
if (provider === void 0) return json(503, {
|
|
695
|
-
ok: false,
|
|
696
|
-
error: "settings-service-unavailable"
|
|
697
|
-
});
|
|
698
|
-
try {
|
|
699
|
-
const namespaces = provider.describe({ redactSecrets: true }).filter((item) => FAMILY_NAMESPACES.has(item.ns)).map((item) => ({
|
|
700
|
-
ns: item.ns,
|
|
701
|
-
...snapshotOf(provider, item)
|
|
702
|
-
}));
|
|
703
|
-
return json(200, {
|
|
704
|
-
ok: true,
|
|
705
|
-
data: {
|
|
706
|
-
writable: provider.writable,
|
|
707
|
-
namespaces
|
|
708
|
-
}
|
|
709
|
-
});
|
|
710
|
-
} catch (error) {
|
|
711
|
-
return json(500, {
|
|
712
|
-
ok: false,
|
|
713
|
-
error: error instanceof Error ? error.message : String(error)
|
|
714
|
-
});
|
|
715
|
-
}
|
|
716
|
-
}
|
|
717
|
-
}, {
|
|
718
|
-
path: HOST_ROUTES.settings.mutate,
|
|
719
|
-
methods: ["POST"],
|
|
720
|
-
requestBody: "buffered",
|
|
721
|
-
fetch: async (request) => {
|
|
722
|
-
if (request.method !== "POST") return methodNotAllowed(["POST"]);
|
|
723
|
-
const provider = providerOf(getProvider);
|
|
724
|
-
if (provider === void 0) return json(503, {
|
|
725
|
-
ok: false,
|
|
726
|
-
error: "settings-service-unavailable"
|
|
727
|
-
});
|
|
728
|
-
let body;
|
|
729
|
-
try {
|
|
730
|
-
body = await request.json();
|
|
731
|
-
} catch {
|
|
732
|
-
return json(400, {
|
|
733
|
-
ok: false,
|
|
734
|
-
error: "invalid-json"
|
|
735
|
-
});
|
|
736
|
-
}
|
|
737
|
-
if (typeof body !== "object" || body === null) return json(400, {
|
|
738
|
-
ok: false,
|
|
739
|
-
error: "invalid-body"
|
|
740
|
-
});
|
|
741
|
-
const { ns, ops, expectedRevision } = body;
|
|
742
|
-
if (typeof ns !== "string" || !FAMILY_NAMESPACES.has(ns)) return json(400, {
|
|
743
|
-
ok: false,
|
|
744
|
-
error: "namespace-not-allowed"
|
|
745
|
-
});
|
|
746
|
-
if (!Array.isArray(ops) || ops.length === 0) return json(400, {
|
|
747
|
-
ok: false,
|
|
748
|
-
error: "ops-required"
|
|
749
|
-
});
|
|
750
|
-
if (expectedRevision !== void 0 && typeof expectedRevision !== "number") return json(400, {
|
|
751
|
-
ok: false,
|
|
752
|
-
error: "invalid-revision"
|
|
753
|
-
});
|
|
754
|
-
try {
|
|
755
|
-
await provider.mutate(ns, ops, expectedRevision);
|
|
756
|
-
const descriptor = provider.describe({ redactSecrets: true }).find((item) => item.ns === ns);
|
|
757
|
-
return json(200, {
|
|
758
|
-
ok: true,
|
|
759
|
-
data: {
|
|
760
|
-
writable: provider.writable,
|
|
761
|
-
namespaces: [{
|
|
762
|
-
ns,
|
|
763
|
-
...snapshotOf(provider, descriptor)
|
|
764
|
-
}]
|
|
765
|
-
}
|
|
766
|
-
});
|
|
767
|
-
} catch (error) {
|
|
768
|
-
if (error?.code === "SETTINGS_CONFLICT") return json(409, {
|
|
769
|
-
ok: false,
|
|
770
|
-
error: "settings-conflict",
|
|
771
|
-
actual: error.actual,
|
|
772
|
-
expected: error.expected
|
|
773
|
-
});
|
|
774
|
-
return json(400, {
|
|
775
|
-
ok: false,
|
|
776
|
-
error: error instanceof Error ? error.message : String(error)
|
|
777
|
-
});
|
|
778
|
-
}
|
|
779
|
-
}
|
|
780
|
-
}];
|
|
781
|
-
}
|
|
782
|
-
//#endregion
|
|
783
647
|
//#region lib/types/generated/host-commands.js
|
|
784
648
|
/**
|
|
785
649
|
* GENERATED by packages/scripts/gen-host-commands.mjs — do not edit.
|
|
@@ -1246,14 +1110,14 @@ const HOST_COMMANDS = {
|
|
|
1246
1110
|
"pt": "atualizado — uma nova geração corresponde byte a byte a este arquivo"
|
|
1247
1111
|
},
|
|
1248
1112
|
"doctor.presetDiffers": {
|
|
1249
|
-
"zh": "与最新生成不同 —
|
|
1250
|
-
"en": "DIFFERS from a fresh generation — it is an install-time snapshot; re-run the installer (/
|
|
1251
|
-
"ja": "最新の生成結果と異なります —
|
|
1252
|
-
"es": "DIFIERE de una generación nueva — es una instantánea del momento de instalar; vuelve a ejecutar el instalador (/
|
|
1253
|
-
"fr": "DIFFÈRE d’une nouvelle génération — c’est un instantané de l’installation ; relancez l’installateur (/
|
|
1254
|
-
"de": "WEICHT von einer neuen Erzeugung ab — es ist ein Installations-Snapshot; Installer erneut ausführen (/
|
|
1255
|
-
"ru": "ОТЛИЧАЕТСЯ от новой генерации — это снимок на момент установки; запустите установщик повторно (/
|
|
1256
|
-
"pt": "DIFERE de uma nova geração — é um instantâneo do momento da instalação; execute o instalador novamente (/
|
|
1113
|
+
"zh": "与最新生成不同 — 这是安装时快照;重新运行安装器(all/host)以重新生成",
|
|
1114
|
+
"en": "DIFFERS from a fresh generation — it is an install-time snapshot; re-run the installer (all/host) to regenerate",
|
|
1115
|
+
"ja": "最新の生成結果と異なります — インストール時のスナップショットです。インストーラー(all/host)を再実行して再生成してください",
|
|
1116
|
+
"es": "DIFIERE de una generación nueva — es una instantánea del momento de instalar; vuelve a ejecutar el instalador (all/host) para regenerarla",
|
|
1117
|
+
"fr": "DIFFÈRE d’une nouvelle génération — c’est un instantané de l’installation ; relancez l’installateur (all/host) pour la régénérer",
|
|
1118
|
+
"de": "WEICHT von einer neuen Erzeugung ab — es ist ein Installations-Snapshot; Installer erneut ausführen (all/host), um ihn neu zu erzeugen",
|
|
1119
|
+
"ru": "ОТЛИЧАЕТСЯ от новой генерации — это снимок на момент установки; запустите установщик повторно (all/host)",
|
|
1120
|
+
"pt": "DIFERE de uma nova geração — é um instantâneo do momento da instalação; execute o instalador novamente (all/host)"
|
|
1257
1121
|
},
|
|
1258
1122
|
"doctor.presetUnknown": {
|
|
1259
1123
|
"zh": "未知 — 无法重新生成({detail})",
|
|
@@ -2400,7 +2264,7 @@ async function diagnose(ctx, options = {}) {
|
|
|
2400
2264
|
let pendingTtlMs = null;
|
|
2401
2265
|
const approvalService = ctx.get("evolutionApproval");
|
|
2402
2266
|
if (typeof approvalService?.ttlMs === "number" && Number.isFinite(approvalService.ttlMs)) pendingTtlMs = approvalService.ttlMs;
|
|
2403
|
-
const approvalList = approvalService?.list?.bind(approvalService);
|
|
2267
|
+
const approvalList = (approvalService?.listReadonly ?? approvalService?.list)?.bind(approvalService);
|
|
2404
2268
|
if (approvalList !== void 0) try {
|
|
2405
2269
|
const pendingProbe = await probeBounded(() => approvalList("pending"), "approval pending listing");
|
|
2406
2270
|
const rows = pendingProbe.ok ? pendingProbe.value : void 0;
|
|
@@ -2412,9 +2276,14 @@ async function diagnose(ctx, options = {}) {
|
|
|
2412
2276
|
pendingCount = null;
|
|
2413
2277
|
executingCount = null;
|
|
2414
2278
|
}
|
|
2415
|
-
const
|
|
2416
|
-
|
|
2417
|
-
|
|
2279
|
+
const installForm = classifyInstallForm({
|
|
2280
|
+
full,
|
|
2281
|
+
preset,
|
|
2282
|
+
host,
|
|
2283
|
+
humanGated: ctx.get("evolutionApproval")?.isEnabled === true,
|
|
2284
|
+
layeredPreset: layered,
|
|
2285
|
+
presetDirInstalled
|
|
2286
|
+
});
|
|
2418
2287
|
const mountConflicts = conflicts.filter((row) => !row.includes("DEGRADED"));
|
|
2419
2288
|
const undecidable = mountConflicts.length !== conflicts.length;
|
|
2420
2289
|
const scopedProbe = {
|
|
@@ -2441,19 +2310,26 @@ async function diagnose(ctx, options = {}) {
|
|
|
2441
2310
|
const queryIssues = await sessionQueryIssues(ctx);
|
|
2442
2311
|
if (queryIssues.length > 0) actions.push("Session search is degraded: isolate the session named above (or wait for the platform fix described in the family maintenance notes) before retrying the same query");
|
|
2443
2312
|
if (paramIssues.length > 0) actions.push("Review the parameter divergences above: /evolution params shows every row with its source, /evolution policy set writes a user value, and a declared-but-unreachable row needs its owning plugin row mounted in this profile.");
|
|
2444
|
-
if (budgetIssues.length > 0) actions.push("Align the memory budget: leave memory-files
|
|
2313
|
+
if (budgetIssues.length > 0) actions.push("Align the memory budget: leave memory-files memoryChars/userChars UNSET so the store follows evolution-policy, or set both surfaces to the same value (the review plans against the policy value while the store enforces its own)");
|
|
2445
2314
|
if (scopedProbe.rows !== null && scopedProbe.rows.length > 0 && scopedProbe.verdict === "never-hit") actions.push("The session-scoped rows are mounted but the family-tool probe has never matched in this process — review injection and skill-usage telemetry skipped every session observed. HOST-ONLY install: the model rows (tool-memory / tool-skill-manage) sit in evolution-host devDependencies, so no session carries them; install a bundle that mounts them (see INSTALL.md). VARIANT install: only a session on the Evolution preset matches, so open one — a session on a platform original preset is the intended skip, not a fault. Either way, check that no profile overlay disables those two rows.");
|
|
2446
2315
|
if ((executingCount ?? 0) > 0) actions.push(`${executingCount} staged write(s) are EXECUTING (an approve crashed mid-run — or one is still in flight). Inspect with /evolution pending: if you started the approve, verify the landed write and do not reject it; only reject after verifying no write is intended. For a verified orphan (this build: S2-P2-22), /evolution release <id> returns it to the pending window instead.`);
|
|
2447
2316
|
for (const row of presetFreshness) {
|
|
2448
2317
|
if (row.status !== "differs") continue;
|
|
2449
|
-
actions.push(`Preset row for base "${row.base}" in ${row.destination} DIFFERS from a fresh generation — it is an install-time snapshot; re-run the installer
|
|
2318
|
+
actions.push(`Preset row for base "${row.base}" in ${row.destination} DIFFERS from a fresh generation — it is an install-time snapshot; re-run the package installer to regenerate`);
|
|
2450
2319
|
}
|
|
2451
|
-
const
|
|
2320
|
+
const form = {
|
|
2321
|
+
id: installForm,
|
|
2322
|
+
evidence: runtimeFlags === void 0 ? ["install form read from the cross-profile manifest aggregate"] : ["platform pluginManager enabled rows"],
|
|
2323
|
+
confidence: runtimeFlags === void 0 ? "inferred" : "declared"
|
|
2324
|
+
};
|
|
2325
|
+
const view = buildDoctorView(await assembleDoctorInputs(ctx, options.runs === void 0 ? { form } : {
|
|
2326
|
+
runs: options.runs,
|
|
2327
|
+
form
|
|
2328
|
+
}));
|
|
2452
2329
|
const merge = await mergeDoctorLine(ctx);
|
|
2453
2330
|
if (merge.status !== "ok" && merge.remedy !== void 0) actions.push("合并行:" + merge.remedy);
|
|
2454
2331
|
return {
|
|
2455
2332
|
installForm,
|
|
2456
|
-
deploymentForm,
|
|
2457
2333
|
bundles,
|
|
2458
2334
|
foreignProfiles: homeProfiles(home).filter(({ profile, dir }) => mounted === void 0 || profile !== mounted.profile && dir !== mounted.dir).map(({ profile }) => profile),
|
|
2459
2335
|
conflicts,
|
|
@@ -2506,7 +2382,7 @@ async function mergeDoctorLine(ctx) {
|
|
|
2506
2382
|
}
|
|
2507
2383
|
/**
|
|
2508
2384
|
* S2-12③ (FLOW5-4): the memory budget is configured in TWO places —
|
|
2509
|
-
* `memory-files`' `
|
|
2385
|
+
* `memory-files`' `memoryChars`/`userChars` (what the STORE enforces)
|
|
2510
2386
|
* and `evolution-policy`'s `memoryChars`/`userChars` (what the review PLANS
|
|
2511
2387
|
* against; `memory-files` follows the policy only for an UNSET limit). A
|
|
2512
2388
|
* disagreement therefore means an explicit contradiction, or a `memory-files`
|
|
@@ -2589,8 +2465,8 @@ function memoryBudgetIssues(ctx) {
|
|
|
2589
2465
|
const policy = ctx.get("evolutionPolicy")?.get?.();
|
|
2590
2466
|
if (budget === void 0 || policy === void 0) return [];
|
|
2591
2467
|
const issues = [];
|
|
2592
|
-
if (budget.
|
|
2593
|
-
if (budget.
|
|
2468
|
+
if (budget.memoryChars !== void 0 && policy.memoryChars !== void 0 && budget.memoryChars !== policy.memoryChars) issues.push(`store enforces memoryChars=${budget.memoryChars} (source: ${budget.memorySource ?? "unknown"}) while evolution-policy declares memoryChars=${policy.memoryChars} — the review plans against the policy value and the store refuses what exceeds its own`);
|
|
2469
|
+
if (budget.userChars !== void 0 && policy.userChars !== void 0 && budget.userChars !== policy.userChars) issues.push(`store enforces userChars=${budget.userChars} (source: ${budget.userSource ?? "unknown"}) while evolution-policy declares userChars=${policy.userChars} — same divergence as the memory limit`);
|
|
2594
2470
|
return issues;
|
|
2595
2471
|
}
|
|
2596
2472
|
/** S0-4 (v43 G-1 / J-1): the scoped-row reconciliation line. The verdict is the
|
|
@@ -2661,7 +2537,7 @@ function renderDoctorText(report, locale = "zh") {
|
|
|
2661
2537
|
}));
|
|
2662
2538
|
}
|
|
2663
2539
|
if (report.presetIssues.length > 0) extras.push("agent presets:", ...report.presetIssues.map((line) => ` ! ${line}`));
|
|
2664
|
-
if (report.foreignProfiles.length > 0) extras.push("profiles-foreign: " + report.foreignProfiles.join(", ") + " — not part of this plane:
|
|
2540
|
+
if (report.foreignProfiles.length > 0) extras.push("profiles-foreign: " + report.foreignProfiles.join(", ") + " — not part of this plane: the package installer ignores them, while the bundles (all profiles) line above counts them");
|
|
2665
2541
|
if (report.conflicts.length > 0) extras.push("conflicts:", ...report.conflicts.map((line) => ` ! ${line}`));
|
|
2666
2542
|
if (report.budgetIssues.length > 0) extras.push("memory budget:", ...report.budgetIssues.map((line) => ` ! ${line}`));
|
|
2667
2543
|
if (report.paramIssues.length > 0) extras.push("parameters:", ...report.paramIssues.map((line) => ` ! ${line}`));
|
|
@@ -2849,193 +2725,429 @@ function renderParamJson(rows) {
|
|
|
2849
2725
|
return JSON.stringify({ params: rows }, null, 2);
|
|
2850
2726
|
}
|
|
2851
2727
|
//#endregion
|
|
2852
|
-
//#region lib/types/
|
|
2853
|
-
|
|
2854
|
-
* Subcommand registry — the SINGLE SOURCE for the /evolution command surface.
|
|
2855
|
-
*
|
|
2856
|
-
* 0.3.55 (WD1): the input-declaration hint, the bare `/evolution` help output
|
|
2857
|
-
* and the README command table all render FROM this table; a hand-written
|
|
2858
|
-
* copy anywhere is drift waiting to happen (v10 R-13 proved it once).
|
|
2859
|
-
* PLAN S5.3 (2026-09-16): "the README command table" means the FAMILY README
|
|
2860
|
-
* (`packages/README.md` — the T-WD2 anchor). Package-level READMEs cite that
|
|
2861
|
-
* home instead of restating the table (doc-facts rule N19).
|
|
2862
|
-
* Keep `usage` in the exact shape a user can type after `/evolution`.
|
|
2863
|
-
*/
|
|
2864
|
-
/** The flags the TABLE declares for one subcommand (name → `--flag`), DERIVED from its usage. */
|
|
2865
|
-
function flagsOf(name) {
|
|
2866
|
-
const entry = COMMAND_ENTRIES.find((candidate) => entryName(candidate) === name);
|
|
2867
|
-
return entry === void 0 ? [] : entryFlags(entry);
|
|
2868
|
-
}
|
|
2869
|
-
/**
|
|
2870
|
-
* C7 shape, DERIVED: the entry IDENTITY key, and it is HIERARCHICAL (E-08).
|
|
2871
|
-
*
|
|
2872
|
-
* The key used to be the first token alone, and `flagsOf` finds an entry with `.find(...)` - the FIRST
|
|
2873
|
-
* match - so `maintain handoff` / `maintain cancel` and `skill restore` / `skill history` / `skill undo` /
|
|
2874
|
-
* `skill pin` all derived the SAME key as their parent and every flag lookup silently saw the parent entry
|
|
2875
|
-
* only (nine collisions). A bare parent (`maintain [--timeout]`) keeps its one-token key, so parent lookups
|
|
2876
|
-
* still resolve: the one call site that named an entry by a name the key no longer produced was the preset
|
|
2877
|
-
* dispatch branch, and it now asks for the entry own key (`preset install`).
|
|
2878
|
-
*/
|
|
2879
|
-
function entryName(entry) {
|
|
2880
|
-
const [head = "", second = ""] = entry.usage.split(" ");
|
|
2881
|
-
const name = head.split("|")[0] ?? "";
|
|
2882
|
-
return /^[a-z][a-z-]*$/.test(second) && !second.startsWith("--") ? name + " " + second : name;
|
|
2883
|
-
}
|
|
2884
|
-
/** C7 shape, DERIVED: the flags a `usage` declares, in the form `--flag` (value flags keep their name). */
|
|
2885
|
-
function entryFlags(entry) {
|
|
2886
|
-
const found = [];
|
|
2887
|
-
for (const match of entry.usage.matchAll(/--[a-z][a-z-]*/g)) if (!found.includes(match[0])) found.push(match[0]);
|
|
2888
|
-
return found;
|
|
2889
|
-
}
|
|
2890
|
-
const COMMAND_ENTRIES = [
|
|
2728
|
+
//#region lib/types/host-command-defs.js
|
|
2729
|
+
const HOST_COMMAND_DEFS = [
|
|
2891
2730
|
{
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2731
|
+
id: "merge",
|
|
2732
|
+
words: ["merge"],
|
|
2733
|
+
summaryKey: "summary.merge",
|
|
2734
|
+
helpKey: "help.merge",
|
|
2735
|
+
flags: [],
|
|
2736
|
+
positional: [],
|
|
2737
|
+
readOnly: false,
|
|
2738
|
+
needsRun: false,
|
|
2739
|
+
fallback: "merge <subcommand> [<args>]",
|
|
2740
|
+
usageLine: "merge <subcommand> [<args>]"
|
|
2895
2741
|
},
|
|
2896
2742
|
{
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2743
|
+
id: "pending",
|
|
2744
|
+
words: ["pending"],
|
|
2745
|
+
summaryKey: "summary.pending",
|
|
2746
|
+
helpKey: "help.pending",
|
|
2747
|
+
flags: [{
|
|
2748
|
+
name: "detail",
|
|
2749
|
+
kind: "boolean"
|
|
2750
|
+
}],
|
|
2751
|
+
positional: [],
|
|
2752
|
+
readOnly: true,
|
|
2753
|
+
needsRun: false,
|
|
2754
|
+
fallback: "pending [--detail]",
|
|
2755
|
+
usageLine: "pending [--detail]"
|
|
2900
2756
|
},
|
|
2901
2757
|
{
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2758
|
+
id: "approve",
|
|
2759
|
+
words: ["approve"],
|
|
2760
|
+
summaryKey: "summary.approve",
|
|
2761
|
+
helpKey: "help.approve",
|
|
2762
|
+
flags: [],
|
|
2763
|
+
positional: [],
|
|
2764
|
+
readOnly: false,
|
|
2765
|
+
needsRun: false,
|
|
2766
|
+
fallback: "approve <id>",
|
|
2767
|
+
usageLine: "approve <id>"
|
|
2905
2768
|
},
|
|
2906
2769
|
{
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2770
|
+
id: "reject",
|
|
2771
|
+
words: ["reject"],
|
|
2772
|
+
summaryKey: "summary.reject",
|
|
2773
|
+
helpKey: "help.reject",
|
|
2774
|
+
flags: [],
|
|
2775
|
+
positional: [],
|
|
2776
|
+
readOnly: false,
|
|
2777
|
+
needsRun: false,
|
|
2778
|
+
fallback: "reject <id>",
|
|
2779
|
+
usageLine: "reject <id>"
|
|
2910
2780
|
},
|
|
2911
2781
|
{
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2782
|
+
id: "release",
|
|
2783
|
+
words: ["release"],
|
|
2784
|
+
summaryKey: "summary.release",
|
|
2785
|
+
helpKey: "help.release",
|
|
2786
|
+
flags: [],
|
|
2787
|
+
positional: [],
|
|
2788
|
+
readOnly: false,
|
|
2789
|
+
needsRun: false,
|
|
2790
|
+
fallback: "release <id>",
|
|
2791
|
+
usageLine: "release <id>"
|
|
2915
2792
|
},
|
|
2916
2793
|
{
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2794
|
+
id: "doctor",
|
|
2795
|
+
words: ["doctor"],
|
|
2796
|
+
summaryKey: "summary.doctor",
|
|
2797
|
+
helpKey: "help.doctor",
|
|
2798
|
+
flags: [{
|
|
2799
|
+
name: "json",
|
|
2800
|
+
kind: "boolean"
|
|
2801
|
+
}],
|
|
2802
|
+
positional: [],
|
|
2803
|
+
readOnly: true,
|
|
2804
|
+
needsRun: false,
|
|
2805
|
+
fallback: "doctor [--json]",
|
|
2806
|
+
usageLine: "doctor [--json]"
|
|
2920
2807
|
},
|
|
2921
2808
|
{
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2809
|
+
id: "curator",
|
|
2810
|
+
words: ["curator"],
|
|
2811
|
+
summaryKey: "summary.curator",
|
|
2812
|
+
helpKey: "help.curator",
|
|
2813
|
+
flags: [],
|
|
2814
|
+
positional: [],
|
|
2815
|
+
readOnly: false,
|
|
2816
|
+
needsRun: false,
|
|
2817
|
+
fallback: "curator run|pause|resume|status|report|scope",
|
|
2818
|
+
usageLine: "curator run|pause|resume|status|report|scope"
|
|
2925
2819
|
},
|
|
2926
2820
|
{
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2821
|
+
id: "mutations",
|
|
2822
|
+
words: ["mutations"],
|
|
2823
|
+
summaryKey: "summary.mutations",
|
|
2824
|
+
helpKey: "help.mutations",
|
|
2825
|
+
flags: [],
|
|
2826
|
+
positional: [],
|
|
2827
|
+
readOnly: true,
|
|
2828
|
+
needsRun: false,
|
|
2829
|
+
fallback: "mutations",
|
|
2830
|
+
usageLine: "mutations"
|
|
2930
2831
|
},
|
|
2931
2832
|
{
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2833
|
+
id: "restore",
|
|
2834
|
+
words: ["restore"],
|
|
2835
|
+
summaryKey: "summary.restore",
|
|
2836
|
+
helpKey: "help.restore",
|
|
2837
|
+
flags: [],
|
|
2838
|
+
positional: [],
|
|
2839
|
+
readOnly: false,
|
|
2840
|
+
needsRun: false,
|
|
2841
|
+
fallback: "restore",
|
|
2842
|
+
usageLine: "restore"
|
|
2935
2843
|
},
|
|
2936
2844
|
{
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2845
|
+
id: "skill.restore",
|
|
2846
|
+
words: ["skill", "restore"],
|
|
2847
|
+
summaryKey: "summary.skill restore",
|
|
2848
|
+
helpKey: "help.skill restore",
|
|
2849
|
+
flags: [],
|
|
2850
|
+
positional: [],
|
|
2851
|
+
readOnly: false,
|
|
2852
|
+
needsRun: false,
|
|
2853
|
+
fallback: "skill restore <name>",
|
|
2854
|
+
usageLine: "skill restore <name>"
|
|
2940
2855
|
},
|
|
2941
2856
|
{
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2857
|
+
id: "skill.history",
|
|
2858
|
+
words: ["skill", "history"],
|
|
2859
|
+
summaryKey: "summary.skill history",
|
|
2860
|
+
helpKey: "help.skill history",
|
|
2861
|
+
flags: [],
|
|
2862
|
+
positional: [],
|
|
2863
|
+
readOnly: true,
|
|
2864
|
+
needsRun: false,
|
|
2865
|
+
fallback: "skill history <name>",
|
|
2866
|
+
usageLine: "skill history <name>"
|
|
2945
2867
|
},
|
|
2946
2868
|
{
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2869
|
+
id: "skill.undo",
|
|
2870
|
+
words: ["skill", "undo"],
|
|
2871
|
+
summaryKey: "summary.skill undo",
|
|
2872
|
+
helpKey: "help.skill undo",
|
|
2873
|
+
flags: [{
|
|
2874
|
+
name: "to",
|
|
2875
|
+
kind: "value"
|
|
2876
|
+
}],
|
|
2877
|
+
positional: [],
|
|
2878
|
+
readOnly: false,
|
|
2879
|
+
needsRun: false,
|
|
2880
|
+
fallback: "skill undo <name> [--to v<N>]",
|
|
2881
|
+
usageLine: "skill undo <name> [--to v<N>]"
|
|
2950
2882
|
},
|
|
2951
2883
|
{
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2884
|
+
id: "skill.pin",
|
|
2885
|
+
words: ["skill", "pin"],
|
|
2886
|
+
summaryKey: "summary.skill pin",
|
|
2887
|
+
helpKey: "help.skill pin",
|
|
2888
|
+
flags: [],
|
|
2889
|
+
positional: [],
|
|
2890
|
+
readOnly: false,
|
|
2891
|
+
needsRun: false,
|
|
2892
|
+
fallback: "skill pin <name>",
|
|
2893
|
+
usageLine: "skill pin <name>"
|
|
2955
2894
|
},
|
|
2956
2895
|
{
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2896
|
+
id: "skill.unpin",
|
|
2897
|
+
words: ["skill", "unpin"],
|
|
2898
|
+
summaryKey: "summary.skill unpin",
|
|
2899
|
+
helpKey: "help.skill unpin",
|
|
2900
|
+
flags: [],
|
|
2901
|
+
positional: [],
|
|
2902
|
+
readOnly: false,
|
|
2903
|
+
needsRun: false,
|
|
2904
|
+
fallback: "skill unpin <name>",
|
|
2905
|
+
usageLine: "skill unpin <name>"
|
|
2960
2906
|
},
|
|
2961
2907
|
{
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2908
|
+
id: "propose",
|
|
2909
|
+
words: ["propose"],
|
|
2910
|
+
summaryKey: "summary.propose",
|
|
2911
|
+
helpKey: "help.propose",
|
|
2912
|
+
flags: [],
|
|
2913
|
+
positional: [],
|
|
2914
|
+
readOnly: false,
|
|
2915
|
+
needsRun: false,
|
|
2916
|
+
fallback: "propose",
|
|
2917
|
+
usageLine: "propose"
|
|
2965
2918
|
},
|
|
2966
2919
|
{
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2920
|
+
id: "skills.health",
|
|
2921
|
+
words: ["skills", "health"],
|
|
2922
|
+
summaryKey: "summary.skills health",
|
|
2923
|
+
helpKey: "help.skills health",
|
|
2924
|
+
flags: [],
|
|
2925
|
+
positional: [],
|
|
2926
|
+
readOnly: true,
|
|
2927
|
+
needsRun: false,
|
|
2928
|
+
fallback: "skills health",
|
|
2929
|
+
usageLine: "skills health"
|
|
2970
2930
|
},
|
|
2971
2931
|
{
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2932
|
+
id: "skills.refresh",
|
|
2933
|
+
words: ["skills", "refresh"],
|
|
2934
|
+
summaryKey: "summary.skills refresh",
|
|
2935
|
+
helpKey: "help.skills refresh",
|
|
2936
|
+
flags: [],
|
|
2937
|
+
positional: [],
|
|
2938
|
+
readOnly: false,
|
|
2939
|
+
needsRun: false,
|
|
2940
|
+
fallback: "skills refresh",
|
|
2941
|
+
usageLine: "skills refresh"
|
|
2975
2942
|
},
|
|
2976
2943
|
{
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2944
|
+
id: "learn",
|
|
2945
|
+
words: ["learn"],
|
|
2946
|
+
summaryKey: "summary.learn",
|
|
2947
|
+
helpKey: "help.learn",
|
|
2948
|
+
flags: [],
|
|
2949
|
+
positional: [],
|
|
2950
|
+
readOnly: false,
|
|
2951
|
+
needsRun: false,
|
|
2952
|
+
fallback: "learn [request]",
|
|
2953
|
+
usageLine: "learn [request]"
|
|
2980
2954
|
},
|
|
2981
2955
|
{
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2956
|
+
id: "maintain",
|
|
2957
|
+
words: ["maintain"],
|
|
2958
|
+
summaryKey: "summary.maintain",
|
|
2959
|
+
helpKey: "help.maintain",
|
|
2960
|
+
flags: [{
|
|
2961
|
+
name: "timeout",
|
|
2962
|
+
kind: "value"
|
|
2963
|
+
}, {
|
|
2964
|
+
name: "facts",
|
|
2965
|
+
kind: "boolean"
|
|
2966
|
+
}],
|
|
2967
|
+
positional: [],
|
|
2968
|
+
readOnly: false,
|
|
2969
|
+
needsRun: false,
|
|
2970
|
+
fallback: "maintain [--timeout=<ms> | --facts]",
|
|
2971
|
+
usageLine: "maintain [--timeout=<ms> | --facts]"
|
|
2985
2972
|
},
|
|
2986
2973
|
{
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2974
|
+
id: "maintain.status",
|
|
2975
|
+
words: ["maintain", "status"],
|
|
2976
|
+
summaryKey: "summary.maintain status",
|
|
2977
|
+
helpKey: "help.maintain status",
|
|
2978
|
+
flags: [],
|
|
2979
|
+
positional: [],
|
|
2980
|
+
readOnly: true,
|
|
2981
|
+
needsRun: false,
|
|
2982
|
+
fallback: "maintain status [<id>]",
|
|
2983
|
+
usageLine: "maintain status [<id>]"
|
|
2990
2984
|
},
|
|
2991
2985
|
{
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2986
|
+
id: "maintain.report",
|
|
2987
|
+
words: ["maintain", "report"],
|
|
2988
|
+
summaryKey: "summary.maintain report",
|
|
2989
|
+
helpKey: "help.maintain report",
|
|
2990
|
+
flags: [],
|
|
2991
|
+
positional: [],
|
|
2992
|
+
readOnly: true,
|
|
2993
|
+
needsRun: false,
|
|
2994
|
+
fallback: "maintain report [<id>]",
|
|
2995
|
+
usageLine: "maintain report [<id>]"
|
|
2995
2996
|
},
|
|
2996
2997
|
{
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
2998
|
+
id: "maintain.handoff",
|
|
2999
|
+
words: ["maintain", "handoff"],
|
|
3000
|
+
summaryKey: "summary.maintain handoff",
|
|
3001
|
+
helpKey: "help.maintain handoff",
|
|
3002
|
+
flags: [],
|
|
3003
|
+
positional: [],
|
|
3004
|
+
readOnly: false,
|
|
3005
|
+
needsRun: false,
|
|
3006
|
+
fallback: "maintain handoff [<id>]",
|
|
3007
|
+
usageLine: "maintain handoff [<id>]"
|
|
3000
3008
|
},
|
|
3001
3009
|
{
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3010
|
+
id: "maintain.cancel",
|
|
3011
|
+
words: ["maintain", "cancel"],
|
|
3012
|
+
summaryKey: "summary.maintain cancel",
|
|
3013
|
+
helpKey: "help.maintain cancel",
|
|
3014
|
+
flags: [],
|
|
3015
|
+
positional: [],
|
|
3016
|
+
readOnly: false,
|
|
3017
|
+
needsRun: false,
|
|
3018
|
+
fallback: "maintain cancel [<id>]",
|
|
3019
|
+
usageLine: "maintain cancel [<id>]"
|
|
3005
3020
|
},
|
|
3006
3021
|
{
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3022
|
+
id: "params",
|
|
3023
|
+
words: ["params"],
|
|
3024
|
+
summaryKey: "summary.params",
|
|
3025
|
+
helpKey: "help.params",
|
|
3026
|
+
flags: [{
|
|
3027
|
+
name: "group",
|
|
3028
|
+
kind: "value"
|
|
3029
|
+
}, {
|
|
3030
|
+
name: "json",
|
|
3031
|
+
kind: "boolean"
|
|
3032
|
+
}],
|
|
3033
|
+
positional: [],
|
|
3034
|
+
readOnly: true,
|
|
3035
|
+
needsRun: false,
|
|
3036
|
+
fallback: "params [--group <name>] [--json]",
|
|
3037
|
+
usageLine: "params [--group <name>] [--json]"
|
|
3010
3038
|
},
|
|
3011
3039
|
{
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3040
|
+
id: "restructure",
|
|
3041
|
+
words: ["restructure"],
|
|
3042
|
+
summaryKey: "summary.restructure",
|
|
3043
|
+
helpKey: "help.restructure",
|
|
3044
|
+
flags: [{
|
|
3045
|
+
name: "plan",
|
|
3046
|
+
kind: "value"
|
|
3047
|
+
}],
|
|
3048
|
+
positional: [],
|
|
3049
|
+
readOnly: false,
|
|
3050
|
+
needsRun: false,
|
|
3051
|
+
fallback: "restructure <name> \"<heading>\" <to_file> [--plan <runId>]",
|
|
3052
|
+
usageLine: "restructure <name> \"<heading>\" <to_file> [--plan <runId>]"
|
|
3015
3053
|
},
|
|
3016
3054
|
{
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3055
|
+
id: "extract",
|
|
3056
|
+
words: ["extract"],
|
|
3057
|
+
summaryKey: "summary.extract",
|
|
3058
|
+
helpKey: "help.extract",
|
|
3059
|
+
flags: [
|
|
3060
|
+
{
|
|
3061
|
+
name: "start",
|
|
3062
|
+
kind: "value"
|
|
3063
|
+
},
|
|
3064
|
+
{
|
|
3065
|
+
name: "end",
|
|
3066
|
+
kind: "value"
|
|
3067
|
+
},
|
|
3068
|
+
{
|
|
3069
|
+
name: "outcome",
|
|
3070
|
+
kind: "value"
|
|
3071
|
+
},
|
|
3072
|
+
{
|
|
3073
|
+
name: "proposal",
|
|
3074
|
+
kind: "value"
|
|
3075
|
+
},
|
|
3076
|
+
{
|
|
3077
|
+
name: "owner-covers",
|
|
3078
|
+
kind: "boolean"
|
|
3079
|
+
},
|
|
3080
|
+
{
|
|
3081
|
+
name: "apply",
|
|
3082
|
+
kind: "boolean"
|
|
3083
|
+
}
|
|
3084
|
+
],
|
|
3085
|
+
positional: [],
|
|
3086
|
+
readOnly: false,
|
|
3087
|
+
needsRun: false,
|
|
3088
|
+
fallback: "extract <source> <target> \"<heading>\" [--start <line>] [--end <line>] [--outcome extract|mixed] [--proposal <id>] [--owner-covers] [--apply]",
|
|
3089
|
+
usageLine: "extract <source> <target> \"<heading>\" [--start <line>] [--end <line>] [--outcome extract|mixed] [--proposal <id>] [--owner-covers] [--apply]"
|
|
3020
3090
|
},
|
|
3021
3091
|
{
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3092
|
+
id: "replay",
|
|
3093
|
+
words: ["replay"],
|
|
3094
|
+
summaryKey: "summary.replay",
|
|
3095
|
+
helpKey: "help.replay",
|
|
3096
|
+
flags: [],
|
|
3097
|
+
positional: [],
|
|
3098
|
+
readOnly: true,
|
|
3099
|
+
needsRun: false,
|
|
3100
|
+
fallback: "replay",
|
|
3101
|
+
usageLine: "replay"
|
|
3025
3102
|
}
|
|
3026
3103
|
];
|
|
3104
|
+
//#endregion
|
|
3105
|
+
//#region lib/types/registry.js
|
|
3106
|
+
/**
|
|
3107
|
+
* Command surface rendering. HOST_COMMAND_DEFS is the one table; every renderer here reads it.
|
|
3108
|
+
* Keep `usageLine` in the exact shape a user can type after `/evolution`.
|
|
3109
|
+
*/
|
|
3110
|
+
/** The flags the TABLE declares for one subcommand (name → `--flag`). */
|
|
3111
|
+
function flagsOf(name) {
|
|
3112
|
+
return HOST_COMMAND_DEFS.find((candidate) => entryName(candidate) === name)?.flags.map((flag) => "--" + flag.name) ?? [];
|
|
3113
|
+
}
|
|
3114
|
+
/**
|
|
3115
|
+
* C7 shape, DERIVED: the entry IDENTITY key, and it is HIERARCHICAL (E-08).
|
|
3116
|
+
*
|
|
3117
|
+
* The key used to be the first token alone, and `flagsOf` finds an entry with `.find(...)` - the FIRST
|
|
3118
|
+
* match - so `maintain handoff` / `maintain cancel` and `skill restore` / `skill history` / `skill undo` /
|
|
3119
|
+
* `skill pin` all derived the SAME key as their parent and every flag lookup silently saw the parent entry
|
|
3120
|
+
* only (nine collisions). A bare parent (`maintain [--timeout]`) keeps its one-token key, so parent lookups
|
|
3121
|
+
* still resolve: the one call site that named an entry by a name the key no longer produced was the preset
|
|
3122
|
+
* dispatch branch, and it now asks for the entry own key (`preset install`).
|
|
3123
|
+
*/
|
|
3124
|
+
function entryName(entry) {
|
|
3125
|
+
return entry.words.join(" ");
|
|
3126
|
+
}
|
|
3127
|
+
/** The one summary source: the generated command i18n catalog. */
|
|
3128
|
+
function summaryOf(entry, locale = "zh") {
|
|
3129
|
+
const text = HOST_COMMANDS["summary." + entryName(entry)]?.[locale];
|
|
3130
|
+
if (text === void 0) throw new Error("registry: no generated summary for " + entryName(entry) + " (" + locale + ")");
|
|
3131
|
+
return text;
|
|
3132
|
+
}
|
|
3027
3133
|
/** The input-declaration hint (single line, ` | `-separated). */
|
|
3028
3134
|
function renderHint() {
|
|
3029
|
-
return
|
|
3135
|
+
return HOST_COMMAND_DEFS.map((entry) => entry.usageLine).join(" | ");
|
|
3030
3136
|
}
|
|
3031
3137
|
/** The bare `/evolution` help body (one line per subcommand). */
|
|
3032
3138
|
function renderHelpText(locale = "zh") {
|
|
3033
3139
|
return [
|
|
3034
|
-
(HOST_COMMANDS["help.subcommands"][locale] ?? HOST_COMMANDS["help.subcommands"].en).replace("{count}", String(
|
|
3140
|
+
(HOST_COMMANDS["help.subcommands"][locale] ?? HOST_COMMANDS["help.subcommands"].en).replace("{count}", String(HOST_COMMAND_DEFS.length)),
|
|
3035
3141
|
"",
|
|
3036
|
-
...
|
|
3142
|
+
...HOST_COMMAND_DEFS.map((entry) => ` ${entry.usageLine.padEnd(44)} ${summaryOf(entry, locale)}`)
|
|
3037
3143
|
].join("\n");
|
|
3038
3144
|
}
|
|
3145
|
+
/** Union of every entry's authored value flags. */
|
|
3146
|
+
const VALUE_FLAGS = (() => {
|
|
3147
|
+
const names = [];
|
|
3148
|
+
for (const entry of HOST_COMMAND_DEFS) for (const flag of entry.flags) if (flag.kind === "value" && !names.includes(flag.name)) names.push(flag.name);
|
|
3149
|
+
return names;
|
|
3150
|
+
})();
|
|
3039
3151
|
//#endregion
|
|
3040
3152
|
//#region lib/types/parse.js
|
|
3041
3153
|
/**
|
|
@@ -3053,20 +3165,7 @@ function renderHelpText(locale = "zh") {
|
|
|
3053
3165
|
*
|
|
3054
3166
|
* @module @lmzhen/dsh-evolution-commands/parse
|
|
3055
3167
|
*/
|
|
3056
|
-
/** The flags whose declared form takes a value
|
|
3057
|
-
/**
|
|
3058
|
-
* Exported so the command-table gate can tie it to the table's usage lines (P2: two declarations of
|
|
3059
|
-
* "which flags take a value" would otherwise be free to drift apart).
|
|
3060
|
-
*/
|
|
3061
|
-
const VALUE_FLAGS = [
|
|
3062
|
-
"group",
|
|
3063
|
-
"to",
|
|
3064
|
-
"timeout",
|
|
3065
|
-
"plan",
|
|
3066
|
-
"start",
|
|
3067
|
-
"end",
|
|
3068
|
-
"outcome"
|
|
3069
|
-
];
|
|
3168
|
+
/** The flags whose declared form takes a value, authored in the command table. */
|
|
3070
3169
|
/**
|
|
3071
3170
|
* Narrow a parse result: true when it is the syntax failure rather than a command.
|
|
3072
3171
|
* @param result - what {@link parseSubcommand} answered.
|
|
@@ -3104,25 +3203,6 @@ function tokenize(input) {
|
|
|
3104
3203
|
return tokens;
|
|
3105
3204
|
}
|
|
3106
3205
|
/**
|
|
3107
|
-
* Read one SUB-FORM line: `maintain status`, `maintain report`, … — the shape the regexes used to own.
|
|
3108
|
-
*
|
|
3109
|
-
* A sub-form matches only when: the line parses, the name matches, the first positional is the sub-form,
|
|
3110
|
-
* and every flag the line carries is DECLARED by the table (an undeclared flag keeps the old
|
|
3111
|
-
* "unknown arguments" answer instead of silently becoming a bare flag).
|
|
3112
|
-
* @param input - the text after `/evolution`.
|
|
3113
|
-
* @param name - the subcommand name the table declares (e.g. `maintain`).
|
|
3114
|
-
* @param sub - the sub-form word (e.g. `status`).
|
|
3115
|
-
* @param declaredFlags - the flags the table declares for `name` (`flagsOf(name)`).
|
|
3116
|
-
* @returns the parsed command, or null when this line is not that sub-form.
|
|
3117
|
-
*/
|
|
3118
|
-
function subcommandOf(input, name, sub, declaredFlags) {
|
|
3119
|
-
const parsed = parseSubcommand(input);
|
|
3120
|
-
if (isParseFailure(parsed) || parsed.name !== name) return null;
|
|
3121
|
-
if (parsed.positionals[0] !== sub) return null;
|
|
3122
|
-
for (const flag of parsed.flags.keys()) if (!declaredFlags.includes("--" + flag)) return null;
|
|
3123
|
-
return parsed;
|
|
3124
|
-
}
|
|
3125
|
-
/**
|
|
3126
3206
|
* Parse one command line into its name, flags and positionals.
|
|
3127
3207
|
* @param input - the text after `/evolution`.
|
|
3128
3208
|
* @returns the parsed command, or the syntax failure that refused it.
|
|
@@ -3200,23 +3280,26 @@ function buildSurface(defs, prefix) {
|
|
|
3200
3280
|
};
|
|
3201
3281
|
}
|
|
3202
3282
|
function parseCommand(defs, argv) {
|
|
3203
|
-
const
|
|
3283
|
+
const verb = argv[0];
|
|
3204
3284
|
if (verb === void 0 || verb === "help" || verb === "--help" || verb === "-h") return {
|
|
3205
3285
|
ok: true,
|
|
3206
3286
|
id: "help",
|
|
3207
3287
|
values: {},
|
|
3208
3288
|
help: true
|
|
3209
3289
|
};
|
|
3210
|
-
const candidates = defs.filter((item) => item.words.
|
|
3211
|
-
const
|
|
3290
|
+
const candidates = defs.filter((item) => item.words.length > 0 && item.words.every((word, index) => argv[index] === word));
|
|
3291
|
+
const restOf = (item) => argv.slice(item.words.length);
|
|
3292
|
+
const ordered = [...candidates].sort((left, right) => right.words.length - left.words.length);
|
|
3293
|
+
const def = ordered.find((item) => restOf(item).filter((token) => token.startsWith("--")).every((token) => {
|
|
3212
3294
|
const name = token.slice(2).split("=")[0] ?? "";
|
|
3213
3295
|
return item.flags.some((flag) => flag.name === name);
|
|
3214
|
-
})) ??
|
|
3296
|
+
})) ?? ordered[0];
|
|
3215
3297
|
if (def === void 0) return {
|
|
3216
3298
|
ok: false,
|
|
3217
3299
|
code: "usage",
|
|
3218
3300
|
message: "unknown command: " + verb
|
|
3219
3301
|
};
|
|
3302
|
+
const rest = restOf(def);
|
|
3220
3303
|
const values = {};
|
|
3221
3304
|
const positional = [];
|
|
3222
3305
|
for (let index = 0; index < rest.length; index += 1) {
|
|
@@ -3532,15 +3615,15 @@ function apply(ctx, rawConfig = {}) {
|
|
|
3532
3615
|
return err(hostError("e-306-this-deployment-stages-foreground", { a1: what }));
|
|
3533
3616
|
};
|
|
3534
3617
|
const approval = ctx.get("evolutionApproval");
|
|
3535
|
-
const
|
|
3536
|
-
if (!isParseFailure(
|
|
3618
|
+
const command = parseSubcommand(input);
|
|
3619
|
+
if (!isParseFailure(command) && command.name === "pending" && command.positionals.length === 0 && [...command.flags.keys()].every((flag) => flag === "detail")) {
|
|
3537
3620
|
if (!approval) return err(hostError("e-301-approval-service-not-mounted"));
|
|
3538
3621
|
const listed = [...await approval.list("pending"), ...await approval.list("executing")];
|
|
3539
3622
|
const pending = [...new Map(listed.map((row) => [row.id, row])).values()];
|
|
3540
3623
|
const ttlMs = typeof approval.ttlMs === "number" && Number.isFinite(approval.ttlMs) ? approval.ttlMs : 0;
|
|
3541
3624
|
const ttlNote = ttlMs > 0 ? hostCommandText(hostLocale, "command.pending.ttl", { ttl: ttlMs }) : hostCommandText(hostLocale, "command.pending.neverExpires");
|
|
3542
3625
|
if (pending.length === 0) return ok(hostCommandText(hostLocale, "command.pending.empty") + ttlNote);
|
|
3543
|
-
const detailed =
|
|
3626
|
+
const detailed = command.flags.get("detail") === true;
|
|
3544
3627
|
const nowMs = Date.now();
|
|
3545
3628
|
const attribution = (p) => {
|
|
3546
3629
|
const age = elapsedSince(p.createdAt, nowMs);
|
|
@@ -3806,8 +3889,7 @@ function apply(ctx, rawConfig = {}) {
|
|
|
3806
3889
|
});
|
|
3807
3890
|
return woke ? ok("已向本会话发送学习请求,请现在执行。") : ok("学习请求已排入本会话队列:本宿主没有唤醒通道,会在你下一条消息时读取。");
|
|
3808
3891
|
}
|
|
3809
|
-
|
|
3810
|
-
if (!isParseFailure(factsParsed) && factsParsed.name === "maintain" && factsParsed.flags.get("facts") === true && factsParsed.positionals.length === 0) {
|
|
3892
|
+
if (!isParseFailure(command) && command.name === "maintain" && command.flags.get("facts") === true && command.positionals.length === 0) {
|
|
3811
3893
|
const ioRegistry = ctx.get("evolutionIo");
|
|
3812
3894
|
if (!ioRegistry) return err("未挂载 evolution-io 注册表:维护事实不可用。");
|
|
3813
3895
|
const library = newSkillLibrary({
|
|
@@ -3831,10 +3913,9 @@ function apply(ctx, rawConfig = {}) {
|
|
|
3831
3913
|
const { facts } = buildMaintainFacts(snapshots, enrichment.usageObservedValue, void 0);
|
|
3832
3914
|
return ok(`维护事实(零 token 预览):\n${facts}`);
|
|
3833
3915
|
}
|
|
3834
|
-
const
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
const timeoutFlag = maintainParsed.flags.get("timeout");
|
|
3916
|
+
const maintainFlagsDeclared = [...isParseFailure(command) ? [] : command.flags.keys()].every((flag) => flagsOf("maintain").includes("--" + flag));
|
|
3917
|
+
if (!isParseFailure(command) && command.name === "maintain" && command.positionals.length === 0 && maintainFlagsDeclared) {
|
|
3918
|
+
const timeoutFlag = command.flags.get("timeout");
|
|
3838
3919
|
const runTimeoutMs = typeof timeoutFlag === "string" ? Number(timeoutFlag) : config.maintainTimeoutMs ?? 6e5;
|
|
3839
3920
|
if (!Number.isSafeInteger(runTimeoutMs) || runTimeoutMs <= 0 || runTimeoutMs > MAX_TIMER_DELAY_MS) return err(timeoutFlag !== void 0 ? `--timeout 值不合法:应为不超过 ${MAX_TIMER_DELAY_MS} 的正整数毫秒(例如 /evolution maintain --timeout 600000)。` : `maintainTimeoutMs 配置不合法:应为不超过 ${MAX_TIMER_DELAY_MS} 的正整数毫秒。请修正 evolution-commands 行的配置(maintainTimeoutMs)后重试。`);
|
|
3840
3921
|
const registry = runs;
|
|
@@ -3976,7 +4057,11 @@ function apply(ctx, rawConfig = {}) {
|
|
|
3976
4057
|
`- stop: /evolution maintain cancel ${handle.id}`
|
|
3977
4058
|
].join("\n"));
|
|
3978
4059
|
}
|
|
3979
|
-
const
|
|
4060
|
+
const maintainSub = (sub) => {
|
|
4061
|
+
if (isParseFailure(command) || command.name !== "maintain" || command.positionals[0] !== sub) return null;
|
|
4062
|
+
return [...command.flags.keys()].every((flag) => flagsOf("maintain").includes("--" + flag)) ? command : null;
|
|
4063
|
+
};
|
|
4064
|
+
const maintainStatus = maintainSub("status");
|
|
3980
4065
|
if (maintainStatus !== null) {
|
|
3981
4066
|
const registry = runs;
|
|
3982
4067
|
if (!registry) return err("未挂载 evolution-io 注册表:无法查看运行状态。");
|
|
@@ -3997,7 +4082,7 @@ function apply(ctx, rawConfig = {}) {
|
|
|
3997
4082
|
const recent = all.filter((record) => record.state !== "running").slice(0, 5);
|
|
3998
4083
|
return ok([live.length === 0 ? "No maintenance run in flight." : `In flight:\n${live.map(renderRunRecord).join("\n")}`, recent.length === 0 ? "" : `Recent:\n${recent.map(renderRunRecord).join("\n")}`].filter((part) => part !== "").join("\n"));
|
|
3999
4084
|
}
|
|
4000
|
-
const maintainReport =
|
|
4085
|
+
const maintainReport = maintainSub("report");
|
|
4001
4086
|
if (maintainReport !== null) {
|
|
4002
4087
|
const registry = runs;
|
|
4003
4088
|
if (!registry) return err("未挂载 evolution-io 注册表:无法查看运行结果。");
|
|
@@ -4020,7 +4105,7 @@ function apply(ctx, rawConfig = {}) {
|
|
|
4020
4105
|
if (probed.kind === "unknown") return err(`运行 ${record.id} 有报告但读不出来(${probed.reason}):这「不是」没有结果。`);
|
|
4021
4106
|
return ok(probed.text);
|
|
4022
4107
|
}
|
|
4023
|
-
const maintainCancel =
|
|
4108
|
+
const maintainCancel = maintainSub("cancel");
|
|
4024
4109
|
if (maintainCancel !== null) {
|
|
4025
4110
|
const registry = runs;
|
|
4026
4111
|
if (!registry) return err("未挂载 evolution-io 注册表:无法取消运行。");
|
|
@@ -4042,7 +4127,7 @@ function apply(ctx, rawConfig = {}) {
|
|
|
4042
4127
|
}
|
|
4043
4128
|
return ok(`维护运行 ${record.id} 已取消:扫描会在下一个检查点停止。用 /evolution maintain status ${record.id} 查看终态。`);
|
|
4044
4129
|
}
|
|
4045
|
-
const maintainHandoff =
|
|
4130
|
+
const maintainHandoff = maintainSub("handoff");
|
|
4046
4131
|
if (maintainHandoff !== null) {
|
|
4047
4132
|
const registry = runs;
|
|
4048
4133
|
if (!registry) return err("未挂载 evolution-io 注册表:无法交付报告。");
|
|
@@ -4087,14 +4172,13 @@ function apply(ctx, rawConfig = {}) {
|
|
|
4087
4172
|
}
|
|
4088
4173
|
if (/^maintain\b/.test(input)) return err("未知的 maintain 参数:应为 `maintain`、`maintain --timeout <ms>` / `maintain --timeout=<ms>`、`maintain status [<id>]`、`maintain report [<id>]`、`maintain handoff [<id>]` 或 `maintain cancel [<id>]`。实际收到:" + input);
|
|
4089
4174
|
if (input.startsWith("extract ")) {
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
const
|
|
4093
|
-
const proposalFlag = extractParsed.flags.get("proposal");
|
|
4175
|
+
if (isParseFailure(command) || command.name !== "extract") return err("用法:/evolution extract <source> <target> \"<heading>\" [--start <line>] [--end <line>] [--owner-covers] 或 --proposal <id>");
|
|
4176
|
+
const source = command.positionals[0] ?? "";
|
|
4177
|
+
const proposalFlag = command.flags.get("proposal");
|
|
4094
4178
|
const ioRegistry = ctx.get("evolutionIo");
|
|
4095
4179
|
if (!ioRegistry) return err("未挂载 evolution-io 注册表:无法执行 extract。");
|
|
4096
|
-
let target =
|
|
4097
|
-
let heading =
|
|
4180
|
+
let target = command.positionals[1] ?? "";
|
|
4181
|
+
let heading = command.positionals[2] ?? "";
|
|
4098
4182
|
let start;
|
|
4099
4183
|
let end;
|
|
4100
4184
|
let extractItems = [];
|
|
@@ -4116,8 +4200,8 @@ function apply(ctx, rawConfig = {}) {
|
|
|
4116
4200
|
}));
|
|
4117
4201
|
} else {
|
|
4118
4202
|
if (source === "" || target === "" || heading === "") return err("用法:/evolution extract <source> <target> \"<heading>\" [--start <line>] [--end <line>]");
|
|
4119
|
-
const startFlag =
|
|
4120
|
-
const endFlag =
|
|
4203
|
+
const startFlag = command.flags.get("start");
|
|
4204
|
+
const endFlag = command.flags.get("end");
|
|
4121
4205
|
start = typeof startFlag === "string" ? startFlag : void 0;
|
|
4122
4206
|
end = typeof endFlag === "string" ? endFlag : void 0;
|
|
4123
4207
|
extractItems = [{
|
|
@@ -4127,8 +4211,8 @@ function apply(ctx, rawConfig = {}) {
|
|
|
4127
4211
|
to_skill: target
|
|
4128
4212
|
}];
|
|
4129
4213
|
}
|
|
4130
|
-
const ownerCovers =
|
|
4131
|
-
const outcomeFlag =
|
|
4214
|
+
const ownerCovers = command.flags.has("owner-covers");
|
|
4215
|
+
const outcomeFlag = command.flags.get("outcome");
|
|
4132
4216
|
if (outcomeFlag !== void 0 && outcomeFlag !== "extract" && outcomeFlag !== "mixed") return err("--outcome 只能是 extract 或 mixed。");
|
|
4133
4217
|
const library = newSkillLibrary({
|
|
4134
4218
|
authority: authorityFrom({ origin: "foreground" }),
|
|
@@ -4150,7 +4234,7 @@ function apply(ctx, rawConfig = {}) {
|
|
|
4150
4234
|
if (!built.ok) return err(built.message);
|
|
4151
4235
|
const plan = built.plan;
|
|
4152
4236
|
const warnings = built.warnings === void 0 || built.warnings.length === 0 ? "" : "\n" + built.warnings.join("\n");
|
|
4153
|
-
if (!
|
|
4237
|
+
if (!command.flags.has("apply")) {
|
|
4154
4238
|
const proposal = proposalFromPlan(plan, { runId: "cli-" + Date.now().toString(36) });
|
|
4155
4239
|
const proposalPath = await writeProposalReport(ioRegistry.provider(), proposal).catch(() => {});
|
|
4156
4240
|
return ok("提取计划(未写入;默认 plan,--apply 才写):" + plan.parts.map((part) => "## " + part.heading).join(", ") + " -> " + target + "\n提取判定:outcome=" + plan.outcome + ";target=" + target + ";owner=" + ownerDecisionText(plan.owner) + warnings + "\nproposal_id: " + proposal.id + (proposalPath === void 0 ? "" : "(已写入 reports)"));
|
|
@@ -4187,13 +4271,12 @@ function apply(ctx, rawConfig = {}) {
|
|
|
4187
4271
|
return ok(result.message + "\n提取判定:outcome=" + plan.outcome + ";target=" + target + warnings);
|
|
4188
4272
|
}
|
|
4189
4273
|
if (input.startsWith("restructure ")) {
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
const
|
|
4193
|
-
const
|
|
4194
|
-
const toFile = restParsed.positionals[2] ?? "";
|
|
4274
|
+
if (isParseFailure(command) || command.name !== "restructure") return err("用法:/evolution restructure <name> \"<heading>\" <to_file>");
|
|
4275
|
+
const name = command.positionals[0] ?? "";
|
|
4276
|
+
const heading = command.positionals[1] ?? "";
|
|
4277
|
+
const toFile = command.positionals[2] ?? "";
|
|
4195
4278
|
if (name === "" || heading === "" || toFile === "") return err("用法:/evolution restructure <name> \"<heading>\" <to_file>");
|
|
4196
|
-
const planFlag =
|
|
4279
|
+
const planFlag = command.flags.get("plan");
|
|
4197
4280
|
const planRunId = typeof planFlag === "string" ? planFlag : void 0;
|
|
4198
4281
|
if (!toFile.startsWith("references/")) return err("to_file 必须位于 references/ 之下(日志或明细的落地位置)。");
|
|
4199
4282
|
const ioRegistry = ctx.get("evolutionIo");
|
|
@@ -4251,8 +4334,7 @@ function apply(ctx, rawConfig = {}) {
|
|
|
4251
4334
|
if (!replay) return err(hostError("e-303-replay-service-not-mounted"));
|
|
4252
4335
|
return ok(replay.compare().report);
|
|
4253
4336
|
}
|
|
4254
|
-
|
|
4255
|
-
if (!isParseFailure(paramsParsed) && paramsParsed.name === "params" && paramsParsed.positionals.length === 0 && [...paramsParsed.flags.keys()].every((flag) => flag === "group" || flag === "json")) {
|
|
4337
|
+
if (!isParseFailure(command) && command.name === "params" && command.positionals.length === 0 && [...command.flags.keys()].every((flag) => flag === "group" || flag === "json")) {
|
|
4256
4338
|
const provider = ctx.get("settings");
|
|
4257
4339
|
const sections = /* @__PURE__ */ new Map();
|
|
4258
4340
|
if (provider?.describe !== void 0) try {
|
|
@@ -4267,14 +4349,14 @@ function apply(ctx, rawConfig = {}) {
|
|
|
4267
4349
|
return err(hostError("e-307-the-settings-service-could", { a1: error instanceof Error ? error.message : String(error) }));
|
|
4268
4350
|
}
|
|
4269
4351
|
const rows = paramSurfaceRows(sections, PARAM_EXPOSURE);
|
|
4270
|
-
const groupFlag =
|
|
4352
|
+
const groupFlag = command.flags.get("group");
|
|
4271
4353
|
const group = typeof groupFlag === "string" ? groupFlag : void 0;
|
|
4272
4354
|
const selected = group === void 0 ? rows : rows.filter((row) => row.group === group);
|
|
4273
4355
|
if (group !== void 0 && selected.length === 0) return err(hostError("e-308-unknown-parameter-group-group", {
|
|
4274
4356
|
a1: group,
|
|
4275
4357
|
a2: paramGroups(PARAM_EXPOSURE).join(", ")
|
|
4276
4358
|
}));
|
|
4277
|
-
if (
|
|
4359
|
+
if (command.flags.get("json") === true) return ok(renderParamJson(selected));
|
|
4278
4360
|
return ok(renderParamRows(selected, { providerMounted: provider !== void 0 }));
|
|
4279
4361
|
}
|
|
4280
4362
|
if (input === "doctor" || input === "doctor --json") {
|
|
@@ -4289,7 +4371,7 @@ function apply(ctx, rawConfig = {}) {
|
|
|
4289
4371
|
...mounted,
|
|
4290
4372
|
runs: doctorRuns()
|
|
4291
4373
|
});
|
|
4292
|
-
if (input === "doctor --json") return ok(JSON.stringify(report
|
|
4374
|
+
if (input === "doctor --json") return ok(JSON.stringify(report, null, 2));
|
|
4293
4375
|
return ok(renderDoctorText(report, hostLocale));
|
|
4294
4376
|
}
|
|
4295
4377
|
if (input === "" || input === "help") return ok(hostCommandText(hostLocale, "help.header") + "\n" + renderHelpText(hostLocale));
|
|
@@ -4352,7 +4434,7 @@ function apply(ctx, rawConfig = {}) {
|
|
|
4352
4434
|
ctx.inject(["settings"], () => {
|
|
4353
4435
|
runMigrationOnce();
|
|
4354
4436
|
});
|
|
4355
|
-
registerHostRoutes(ctx, () => [...makeDiagnosticsRoutes(() => assembleDoctorInputs(ctx, { runs: doctorRuns() }))
|
|
4437
|
+
registerHostRoutes(ctx, () => [...makeDiagnosticsRoutes(() => assembleDoctorInputs(ctx, { runs: doctorRuns() }))]);
|
|
4356
4438
|
(async () => {
|
|
4357
4439
|
const loader = ctx.root.loader;
|
|
4358
4440
|
try {
|