@lmzhen/dsh-evolution-commands 0.42.0 → 0.43.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 +6 -278
- package/lib/types/parse.d.ts +1 -1
- package/package.json +6 -6
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, PARAM_NAMESPACES, PLATFORM_LINE, REVIEWER_PRESET_ID, absentHostServices, appendEvolutionEvent, applyNamespaceMigration, asRecord, atomicWriteFiles, authorityFrom, buildExtractPlanFromLibrary, buildLearnPrompt,
|
|
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, PARAM_NAMESPACES, PLATFORM_LINE, REVIEWER_PRESET_ID, absentHostServices, appendEvolutionEvent, applyNamespaceMigration, asRecord, atomicWriteFiles, authorityFrom, buildExtractPlanFromLibrary, buildLearnPrompt, clampedNumber, classifyNamespaceMigration, classifySessionEvent, createSubagentChannel, errorText, errorTextIn, eventsFile, evolutionHome, evolutionRoot, hostSurface, isDeprecatedParamId, isPresent, isRecord, isUnknown, liveBool, mutationLockFrom, newRunRegistry, ownerDecisionText, paramSettingsId, planNamespaceMigration, policyStageLimits, probeMtime, probeText, proposalFromPlan, readProposalReport, registerOwnerSettings, reportsSweepLockTarget, resolveParamId, scopedPackageName, scopedProbeReport, sweepReports, transactIo, unwrapLive, 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";
|
|
@@ -8,8 +8,8 @@ import z from "@deepseek-ai/schemastery";
|
|
|
8
8
|
import { effectiveSessionPolicy } from "@lmzhen/dsh-evolution-approval";
|
|
9
9
|
import { createUserMessage } from "@lmzhen/dsh-evolution-core/platform";
|
|
10
10
|
import { assertSkillsRootAliasRetired, elapsedSince, newSkillLibrary, partitionVersions, resolveRootConfig } from "@lmzhen/dsh-evolution-core/skills";
|
|
11
|
-
import { composePresetEntry, mergePresetRow, presetPatchText, presetRowBlock, presetRowBody, presetRowId, resolveBasePresetPatch } from "@lmzhen/dsh-evolution-core/composition";
|
|
12
11
|
import { buildEnrichment, buildMaintainFacts, enrichmentSnapshotOptions, runMaintain, snapshotFromLibrary } from "@lmzhen/dsh-evolution-maintenance";
|
|
12
|
+
import { composePresetEntry, presetRowBlock, presetRowBody, presetRowId, resolveBasePresetPatch } from "@lmzhen/dsh-evolution-core/composition";
|
|
13
13
|
import { processScopeViolations } from "@lmzhen/dsh-evolution-state-storage";
|
|
14
14
|
//#region lib/types/command-fallback.js
|
|
15
15
|
/**
|
|
@@ -1769,38 +1769,6 @@ function readTextOrEmpty(path) {
|
|
|
1769
1769
|
function profilePatchText(profileDir) {
|
|
1770
1770
|
return readTextOrEmpty(join(profileDir, PROFILE_PATCH_FILENAME));
|
|
1771
1771
|
}
|
|
1772
|
-
/** Where the preset-install exclusion must look: THIS plane only, or an explicit refusal.
|
|
1773
|
-
*
|
|
1774
|
-
* The write path does NOT scan the home: the mounted profile is the whole question (its started
|
|
1775
|
-
* bundles plus the ones its own manifest declares — either can double-mount), and a question that
|
|
1776
|
-
* cannot be answered still REFUSES. That is what makes a leftover profile from the other plane
|
|
1777
|
-
* harmless here: it is not this plane's profile, so it is never consulted.
|
|
1778
|
-
* @param mounted - the mounted profile, or undefined outside a profile (a bare library mount).
|
|
1779
|
-
* @returns the profile to judge with its bundle rows, or the reason a refusal is mandatory.
|
|
1780
|
-
*/
|
|
1781
|
-
function installExclusionTarget(mounted) {
|
|
1782
|
-
if (mounted === void 0 || mounted.dir === "") return {
|
|
1783
|
-
kind: "undecidable",
|
|
1784
|
-
reason: "本进程没有挂载 profile,因此无法在这里回答双挂载问题"
|
|
1785
|
-
};
|
|
1786
|
-
let manifestFailure;
|
|
1787
|
-
const declared = profileBundles(mounted.dir, (error) => {
|
|
1788
|
-
manifestFailure = error;
|
|
1789
|
-
});
|
|
1790
|
-
const manifestCode = manifestFailure?.code;
|
|
1791
|
-
if (manifestFailure !== void 0 && manifestCode !== "ENOENT") return {
|
|
1792
|
-
kind: "undecidable",
|
|
1793
|
-
reason: "读不出已挂载 profile 的清单"
|
|
1794
|
-
};
|
|
1795
|
-
return {
|
|
1796
|
-
kind: "mounted",
|
|
1797
|
-
profile: {
|
|
1798
|
-
profile: mounted.profile,
|
|
1799
|
-
dir: mounted.dir
|
|
1800
|
-
},
|
|
1801
|
-
bundles: [...mounted.bundles, ...declared]
|
|
1802
|
-
};
|
|
1803
|
-
}
|
|
1804
1772
|
//#endregion
|
|
1805
1773
|
//#region lib/types/doctor.js
|
|
1806
1774
|
/**
|
|
@@ -1995,7 +1963,7 @@ function resolveAgentPresetAsset(asset) {
|
|
|
1995
1963
|
* (minimal) as a double-mount participant.
|
|
1996
1964
|
* @param path - resolved bases.json.
|
|
1997
1965
|
* @returns the rows, or null when the table is unreadable or malformed. */
|
|
1998
|
-
function readAgentPresetBases
|
|
1966
|
+
function readAgentPresetBases(path) {
|
|
1999
1967
|
try {
|
|
2000
1968
|
const parsed = JSON.parse(readFileSync(path, "utf8"));
|
|
2001
1969
|
if (!Array.isArray(parsed.bases)) return null;
|
|
@@ -2067,7 +2035,7 @@ function baseInstallable(base, servicePresent) {
|
|
|
2067
2035
|
*/
|
|
2068
2036
|
function installedLayeredPresetIds(home) {
|
|
2069
2037
|
const basesPath = resolveAgentPresetAsset("bases.json");
|
|
2070
|
-
const bases = basesPath === null ? null : readAgentPresetBases
|
|
2038
|
+
const bases = basesPath === null ? null : readAgentPresetBases(basesPath);
|
|
2071
2039
|
const ids = /* @__PURE__ */ new Set();
|
|
2072
2040
|
for (const text of userPatchTexts(home)) {
|
|
2073
2041
|
if (text === "") continue;
|
|
@@ -2098,7 +2066,7 @@ function installedLayeredPresetIds(home) {
|
|
|
2098
2066
|
function probePresetFreshness(home, servicePresent) {
|
|
2099
2067
|
const basesPath = resolveAgentPresetAsset("bases.json");
|
|
2100
2068
|
const deltaPath = resolveAgentPresetAsset("agent.cordis.yml");
|
|
2101
|
-
const bases = basesPath === null ? null : readAgentPresetBases
|
|
2069
|
+
const bases = basesPath === null ? null : readAgentPresetBases(basesPath);
|
|
2102
2070
|
let delta = null;
|
|
2103
2071
|
let deltaFailure = `${AGENT_PRESET_PACKAGE}/agent.cordis.yml could not be resolved — is the family agent-preset package installed?`;
|
|
2104
2072
|
if (deltaPath !== null) try {
|
|
@@ -2725,32 +2693,6 @@ function renderParamRows(rows, options) {
|
|
|
2725
2693
|
].join("\n");
|
|
2726
2694
|
}
|
|
2727
2695
|
/**
|
|
2728
|
-
* Parse one command-line value into what the settings document stores: JSON
|
|
2729
|
-
* when it parses (numbers, booleans, quoted strings, arrays, objects), the raw
|
|
2730
|
-
* text otherwise, so a bare word like `enforce` stays a word.
|
|
2731
|
-
* @param raw - the text typed after the parameter id.
|
|
2732
|
-
* @returns the value to write.
|
|
2733
|
-
*/
|
|
2734
|
-
function parseParamValue(raw) {
|
|
2735
|
-
const text = raw.trim();
|
|
2736
|
-
try {
|
|
2737
|
-
return JSON.parse(text);
|
|
2738
|
-
} catch {
|
|
2739
|
-
return text;
|
|
2740
|
-
}
|
|
2741
|
-
}
|
|
2742
|
-
/**
|
|
2743
|
-
* Render the write result: the value move, then where it landed and when it
|
|
2744
|
-
* takes effect (the two things a caller cannot infer from the command line).
|
|
2745
|
-
* @param write - the accepted write.
|
|
2746
|
-
* @returns the command text.
|
|
2747
|
-
*/
|
|
2748
|
-
function renderPolicySet(write) {
|
|
2749
|
-
const timing = write.applies === "live" ? "takes effect at the next use (live)" : "takes effect after a host restart (restart)";
|
|
2750
|
-
const origin = write.wasOverridden ? "replacing your earlier override" : "now a user override (the deployment value stays underneath)";
|
|
2751
|
-
return [`${write.id}: ${renderValue(write.before)} → ${renderValue(write.after)}`, `namespace ${write.namespace}; applies ${write.applies} — ${timing}; ${origin}`].join("\n");
|
|
2752
|
-
}
|
|
2753
|
-
/**
|
|
2754
2696
|
* Render the rows as JSON for scripts (same fields, no formatting).
|
|
2755
2697
|
* @param rows - rows from {@link paramSurfaceRows}.
|
|
2756
2698
|
* @returns a JSON document with a `params` array.
|
|
@@ -2913,26 +2855,11 @@ const COMMAND_ENTRIES = [
|
|
|
2913
2855
|
usage: "maintain cancel [<id>]",
|
|
2914
2856
|
summary: "停掉在飞的那次维护扫描(省略 id 仅当最新一条是本进程在跑的那次)"
|
|
2915
2857
|
},
|
|
2916
|
-
{
|
|
2917
|
-
readonly: false,
|
|
2918
|
-
usage: "migrate",
|
|
2919
|
-
summary: "把旧设置文档里家族的旧分区迁进现在的行(幂等;已迁移过就报「已一致」)"
|
|
2920
|
-
},
|
|
2921
|
-
{
|
|
2922
|
-
readonly: false,
|
|
2923
|
-
usage: "policy set <id> <value> [--expect <revision>]",
|
|
2924
|
-
summary: "通过设置服务写入一个你可改的参数 (仅 E3;E1/E2 仍留在 cordis.yml)"
|
|
2925
|
-
},
|
|
2926
2858
|
{
|
|
2927
2859
|
readonly: true,
|
|
2928
2860
|
usage: "params [--group <name>] [--json]",
|
|
2929
2861
|
summary: "列出全部参数:分组、档位、生效时机、来源与当前值(--json 便于脚本处理)"
|
|
2930
2862
|
},
|
|
2931
|
-
{
|
|
2932
|
-
readonly: false,
|
|
2933
|
-
usage: "preset install [--base <name>[,<name>...]]",
|
|
2934
|
-
summary: "把自进化 Agent 预设**行**写进当前 profile 的 patch 层(`profiles/<p>/cordis.patch.yml`;bases 来自 agent 包的 bases.json)"
|
|
2935
|
-
},
|
|
2936
2863
|
{
|
|
2937
2864
|
readonly: false,
|
|
2938
2865
|
usage: "restructure <name> \"<heading>\" <to_file> [--plan <runId>]",
|
|
@@ -2973,7 +2900,7 @@ function renderHelpText(locale = "zh") {
|
|
|
2973
2900
|
*
|
|
2974
2901
|
* This parser is order- and `=`-tolerant, matches the subcommand name case-insensitively, keeps a flag
|
|
2975
2902
|
* VALUE's case intact (the domain layer is the one that validates it), and answers a SYNTAX failure when a
|
|
2976
|
-
* declared value flag is left without its value (F-3: `
|
|
2903
|
+
* declared value flag is left without its value (F-3: `extract --start 3` must not read
|
|
2977
2904
|
* `--expect 3` as the value).
|
|
2978
2905
|
*
|
|
2979
2906
|
* @module @lmzhen/dsh-evolution-commands/parse
|
|
@@ -2985,8 +2912,6 @@ function renderHelpText(locale = "zh") {
|
|
|
2985
2912
|
*/
|
|
2986
2913
|
const VALUE_FLAGS = [
|
|
2987
2914
|
"group",
|
|
2988
|
-
"expect",
|
|
2989
|
-
"base",
|
|
2990
2915
|
"to",
|
|
2991
2916
|
"timeout",
|
|
2992
2917
|
"plan",
|
|
@@ -4014,76 +3939,6 @@ function apply(ctx, rawConfig = {}) {
|
|
|
4014
3939
|
return ok(woke ? `已把运行 ${record.id} 交给模型 —— 报告:${reportDigestPath(record)}。它会读取该文件并执行其中的行动项。` : `已把运行 ${record.id} 交给模型并排队 —— 本宿主没有唤醒通道,因此会在你下一条消息时被读取。`);
|
|
4015
3940
|
}
|
|
4016
3941
|
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);
|
|
4017
|
-
const presetParsed = parseSubcommand(input);
|
|
4018
|
-
const presetInstall = isParseFailure(presetParsed) || presetParsed.name !== "preset" ? null : presetParsed.positionals[0] === "install" && presetParsed.positionals.length === 1 && [...presetParsed.flags.keys()].every((flag) => flagsOf("preset install").includes("--" + flag)) ? presetParsed : false;
|
|
4019
|
-
if (presetInstall !== null && presetInstall !== false) {
|
|
4020
|
-
{
|
|
4021
|
-
const mounted = presetProfileTarget(ctx);
|
|
4022
|
-
const exclusion = installExclusionTarget(mounted === void 0 ? void 0 : {
|
|
4023
|
-
profile: mounted.profile,
|
|
4024
|
-
dir: mounted.profileDir,
|
|
4025
|
-
bundles: mounted.bundles
|
|
4026
|
-
});
|
|
4027
|
-
if (exclusion.kind === "undecidable") return err(`拒绝安装分层 Evolution 预设:${exclusion.reason}:all/preset 双重挂载检查无法执行。请解决该 profile 的访问权限后重试,或改用分层安装器——它会在安装前就执行同一套排除检查。`);
|
|
4028
|
-
const installedBundles = exclusion.bundles;
|
|
4029
|
-
const allBundle = installedBundles.find((name) => name === "dsh-evolution-all" || name.endsWith("/dsh-evolution-all"));
|
|
4030
|
-
const presetBundle = installedBundles.find((name) => name === "dsh-evolution-preset" || name.endsWith("/dsh-evolution-preset"));
|
|
4031
|
-
if (allBundle || presetBundle) return err(`拒绝安装分层 Evolution 预设:本 profile 里已安装「${allBundle ?? presetBundle}」:它的模型行(tool-memory / tool-skill-manage / tool-session-query / skill-catalog)会与预设的重复挂载,profile 启动时会直接报错。只保留一个:安装分层预设前先移除 ${allBundle ? "evolution-all bundle" : "evolution-preset bundle"}(见 /evolution doctor)。`);
|
|
4032
|
-
}
|
|
4033
|
-
try {
|
|
4034
|
-
const source = resolveAgentPresetDir(import.meta.url);
|
|
4035
|
-
const table = readAgentPresetBases(source);
|
|
4036
|
-
const baseFlag = presetInstall.flags.get("base");
|
|
4037
|
-
const requestedRaw = typeof baseFlag === "string" ? baseFlag : table.defaultBase;
|
|
4038
|
-
const requested = [...new Set(requestedRaw.split(",").map((part) => part.trim()).filter((part) => part !== ""))];
|
|
4039
|
-
if (requested.length === 0) return err(`没有指定 agent-preset 基名:${join(source, "bases.json")} 里列出的是 ${table.entries.map((entry) => entry.name).join(", ")}`);
|
|
4040
|
-
const selected = [];
|
|
4041
|
-
for (const name of requested) {
|
|
4042
|
-
const entry = table.entries.find((candidate) => candidate.name === name);
|
|
4043
|
-
if (entry === void 0) return err(`未知的 agent-preset 基名「${name}」:${join(source, "bases.json")} 里列出的是 ${table.entries.map((candidate) => candidate.name).join(", ")}`);
|
|
4044
|
-
selected.push(entry);
|
|
4045
|
-
}
|
|
4046
|
-
const deltaPath = join(source, "agent.cordis.yml");
|
|
4047
|
-
if (!existsSync(deltaPath)) return err(`预设文件在 ${source} 里缺失:是否装了 dsh-evolution-agent-preset 包?`);
|
|
4048
|
-
const profile = presetProfileTarget(ctx);
|
|
4049
|
-
if (profile === void 0) return err("本进程没有挂载任何 profile,因此没有可写入预设行的 profile 补丁:请在由 `dsh --profile <name>` 启动的会话里执行该命令。");
|
|
4050
|
-
const delta = readFileSync(deltaPath, "utf8");
|
|
4051
|
-
const hmr = ctx.get("hmr");
|
|
4052
|
-
const commit = () => {
|
|
4053
|
-
const current = existsSync(profile.patchPath) ? readFileSync(profile.patchPath, "utf8") : "";
|
|
4054
|
-
let merged = current;
|
|
4055
|
-
const written = [];
|
|
4056
|
-
for (const base of selected) {
|
|
4057
|
-
const refusal = baseRefusalReason(base, (name) => ctx.get(name) !== void 0);
|
|
4058
|
-
if (refusal !== void 0) return err(refusal);
|
|
4059
|
-
const basePatch = resolvePresetBasePatch(base.name, profile);
|
|
4060
|
-
const rowId = presetRowId(base.id);
|
|
4061
|
-
const entryText = composePresetEntry(readFileSync(basePatch, "utf8"), delta, {
|
|
4062
|
-
rowId,
|
|
4063
|
-
id: base.id,
|
|
4064
|
-
name: base.display.name,
|
|
4065
|
-
description: base.display.description,
|
|
4066
|
-
order: base.display.order
|
|
4067
|
-
});
|
|
4068
|
-
const next = mergePresetRow(merged, entryText, rowId);
|
|
4069
|
-
written.push(next === merged ? `${base.name} → ${profile.patchPath} (already current)` : `${base.name} → ${rowId} in ${profile.patchPath}`);
|
|
4070
|
-
merged = next;
|
|
4071
|
-
}
|
|
4072
|
-
if (merged !== current) atomicWriteFiles(dirname(profile.patchPath), [{
|
|
4073
|
-
name: PROFILE_PATCH_FILENAME$1,
|
|
4074
|
-
content: presetPatchText(merged)
|
|
4075
|
-
}], void 0, (message) => {
|
|
4076
|
-
ctx.logger.warn(message);
|
|
4077
|
-
});
|
|
4078
|
-
return ok(`已写入 evolution agent preset 行(${written.join("; ")})。重启会话切换器后即可选中它。`);
|
|
4079
|
-
};
|
|
4080
|
-
const runExclusive = hmr?.runExclusive;
|
|
4081
|
-
if (runExclusive === void 0) return commit();
|
|
4082
|
-
return await runExclusive.call(hmr, commit);
|
|
4083
|
-
} catch (error) {
|
|
4084
|
-
return err(`预设安装失败:${error instanceof Error ? error.message : String(error)}`);
|
|
4085
|
-
}
|
|
4086
|
-
}
|
|
4087
3942
|
if (input.startsWith("extract ")) {
|
|
4088
3943
|
const extractParsed = parseSubcommand(rawInputTrimmed);
|
|
4089
3944
|
if (isParseFailure(extractParsed) || extractParsed.name !== "extract") return err("用法:/evolution extract <source> <target> \"<heading>\" [--start <line>] [--end <line>] [--owner-covers] 或 --proposal <id>");
|
|
@@ -4275,87 +4130,6 @@ function apply(ctx, rawConfig = {}) {
|
|
|
4275
4130
|
if (paramsParsed.flags.get("json") === true) return ok(renderParamJson(selected));
|
|
4276
4131
|
return ok(renderParamRows(selected, { providerMounted: provider !== void 0 }));
|
|
4277
4132
|
}
|
|
4278
|
-
const policyParsed = parseSubcommand(input);
|
|
4279
|
-
if (isParseFailure(policyParsed) && policyParsed.name === "policy" && policyParsed.kind === "missing-value") return err("/evolution policy set 需要在 --" + (policyParsed.flag ?? "") + ";用法:policy set <id> <value> [--expect <revision>]");
|
|
4280
|
-
if (!isParseFailure(policyParsed) && policyParsed.name === "policy" && policyParsed.positionals[0] === "set") {
|
|
4281
|
-
const provider = ctx.get("settings");
|
|
4282
|
-
if (provider?.update === void 0 || provider.describe === void 0) return err(hostError("e-311-no-settings-service-is"));
|
|
4283
|
-
const rawId = policyParsed.positionals[1] ?? "";
|
|
4284
|
-
const rawValue = policyParsed.positionals[2] ?? "";
|
|
4285
|
-
let id;
|
|
4286
|
-
try {
|
|
4287
|
-
id = canonicalWriteId(rawId);
|
|
4288
|
-
} catch (error) {
|
|
4289
|
-
return err(hostError("e-312-error-instanceof-Error-error", { a1: error instanceof Error ? error.message : String(error) }));
|
|
4290
|
-
}
|
|
4291
|
-
const entry = PARAM_EXPOSURE.find((candidate) => candidate.id === id);
|
|
4292
|
-
if (entry === void 0) return err(hostError("e-313-unknown-parameter-id-evolution", { a1: id }));
|
|
4293
|
-
if (entry.tier !== "E3") return err(hostError("e-314-id-is-a-deployment", {
|
|
4294
|
-
a1: id,
|
|
4295
|
-
a2: entry.tier,
|
|
4296
|
-
a3: entry.owner
|
|
4297
|
-
}));
|
|
4298
|
-
const namespace = paramSettingsId(entry.owner);
|
|
4299
|
-
if (namespace === void 0) return err(hostError("e-315-id-has-no-user", {
|
|
4300
|
-
a1: id,
|
|
4301
|
-
a2: entry.owner
|
|
4302
|
-
}));
|
|
4303
|
-
let descriptor;
|
|
4304
|
-
try {
|
|
4305
|
-
descriptor = provider.describe({ redactSecrets: false }).find((candidate) => candidate.ns === namespace);
|
|
4306
|
-
} catch (error) {
|
|
4307
|
-
return err(hostError("e-307-the-settings-service-could-2", { a1: error instanceof Error ? error.message : String(error) }));
|
|
4308
|
-
}
|
|
4309
|
-
if (descriptor === void 0) return err(hostError("e-316-namespace-namespace-is-not", {
|
|
4310
|
-
a1: namespace,
|
|
4311
|
-
a2: entry.owner
|
|
4312
|
-
}));
|
|
4313
|
-
const current = descriptor.value;
|
|
4314
|
-
const resolved = typeof current === "object" && current !== null ? current : void 0;
|
|
4315
|
-
const expectFlag = policyParsed.flags.get("expect");
|
|
4316
|
-
const expectedRaw = typeof expectFlag === "string" ? expectFlag : void 0;
|
|
4317
|
-
const expected = expectedRaw === void 0 ? descriptor.revision : Number(expectedRaw);
|
|
4318
|
-
if (expectedRaw !== void 0 && descriptor.revision !== void 0 && Number(expectedRaw) !== descriptor.revision) return err(hostError("e-309-revision-conflict-you-sent", {
|
|
4319
|
-
a1: expectedRaw,
|
|
4320
|
-
a2: descriptor.revision
|
|
4321
|
-
}));
|
|
4322
|
-
const value = parseParamValue(rawValue);
|
|
4323
|
-
const floorId = entry.relation?.atLeast;
|
|
4324
|
-
if (floorId !== void 0 && typeof value === "number") {
|
|
4325
|
-
const sibling = resolved?.[floorId];
|
|
4326
|
-
const floor = typeof sibling === "number" ? sibling : NaN;
|
|
4327
|
-
if (Number.isFinite(floor) && value < floor) return err(hostError("e-322-a-parameter-would-break-a", {
|
|
4328
|
-
a1: id,
|
|
4329
|
-
a2: String(floor),
|
|
4330
|
-
a3: String(value)
|
|
4331
|
-
}));
|
|
4332
|
-
}
|
|
4333
|
-
try {
|
|
4334
|
-
await provider.update(namespace, { [id]: value }, expected);
|
|
4335
|
-
} catch (error) {
|
|
4336
|
-
const code = error?.code;
|
|
4337
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
4338
|
-
if (code === "SETTINGS_CONFLICT") return err(hostError("e-309-revision-conflict-message-Re", { a1: message }));
|
|
4339
|
-
return err(hostError("e-310-the-settings-service-refused", { a1: message }));
|
|
4340
|
-
}
|
|
4341
|
-
return ok(renderPolicySet({
|
|
4342
|
-
id,
|
|
4343
|
-
namespace,
|
|
4344
|
-
applies: entry.applies,
|
|
4345
|
-
before: descriptor.user?.[id] ?? resolved?.[id],
|
|
4346
|
-
after: value,
|
|
4347
|
-
wasOverridden: descriptor.user !== void 0 && Object.hasOwn(descriptor.user, id)
|
|
4348
|
-
}));
|
|
4349
|
-
}
|
|
4350
|
-
if (input === "migrate") {
|
|
4351
|
-
const attempt = await migrateFromContext(ctx);
|
|
4352
|
-
if (!attempt.ok) {
|
|
4353
|
-
if (attempt.problem === "settings") return err(hostError("e-311-no-settings-service-is"));
|
|
4354
|
-
if (attempt.problem === "home") return err(hostError("e-320-the-profile-home-is-not"));
|
|
4355
|
-
return err(hostError("e-321-no-io-provider-is"));
|
|
4356
|
-
}
|
|
4357
|
-
return ok(renderNamespaceMigration(attempt.outcome));
|
|
4358
|
-
}
|
|
4359
4133
|
if (input === "doctor" || input === "doctor --json") {
|
|
4360
4134
|
const mountedForDoctor = presetProfileTarget(ctx);
|
|
4361
4135
|
const mounted = mountedForDoctor === void 0 ? {} : { mounted: {
|
|
@@ -4453,52 +4227,6 @@ function apply(ctx, rawConfig = {}) {
|
|
|
4453
4227
|
* each of them is what kept this path on `standard` while the installer knew
|
|
4454
4228
|
* `ptc` too. Fails loud: a missing table is an incomplete install, never a
|
|
4455
4229
|
* silent fallback to the default base. */
|
|
4456
|
-
function readAgentPresetBases(source) {
|
|
4457
|
-
const path = join(source, "bases.json");
|
|
4458
|
-
const parsed = JSON.parse(readFileSync(path, "utf8"));
|
|
4459
|
-
if (!Array.isArray(parsed.bases) || parsed.bases.length === 0) throw new Error(`${path} carries no bases[]`);
|
|
4460
|
-
const entries = parsed.bases.map((raw) => {
|
|
4461
|
-
const entry = raw;
|
|
4462
|
-
if (typeof entry.name !== "string" || typeof entry.id !== "string") throw new Error(`${path} entry ${JSON.stringify(raw)} needs name/id strings`);
|
|
4463
|
-
const display = entry.display;
|
|
4464
|
-
if (display === null || typeof display !== "object" || typeof display.name !== "string" || display.name === "" || typeof display.description !== "string" || display.description === "" || typeof display.order !== "number" || !Number.isInteger(display.order)) throw new Error(`${path} entry "${entry.name}" needs display { name, description, order }`);
|
|
4465
|
-
const requires = entry.requires;
|
|
4466
|
-
if (requires !== void 0 && (requires === null || typeof requires !== "object" || typeof requires.service !== "string")) throw new Error(`${path} entry "${entry.name}" needs requires.service as a string`);
|
|
4467
|
-
if (entry.unsupported !== void 0 && (typeof entry.unsupported !== "string" || entry.unsupported === "")) throw new Error(`${path} entry "${entry.name}" needs unsupported as a non-empty reason string`);
|
|
4468
|
-
return {
|
|
4469
|
-
name: entry.name,
|
|
4470
|
-
id: entry.id,
|
|
4471
|
-
display: {
|
|
4472
|
-
name: display.name,
|
|
4473
|
-
description: display.description,
|
|
4474
|
-
order: display.order
|
|
4475
|
-
},
|
|
4476
|
-
...requires === void 0 ? {} : { requires: { service: requires.service } },
|
|
4477
|
-
...entry.unsupported === void 0 ? {} : { unsupported: entry.unsupported }
|
|
4478
|
-
};
|
|
4479
|
-
});
|
|
4480
|
-
const declared = parsed.default;
|
|
4481
|
-
if (typeof declared !== "string" || !entries.some((entry) => entry.name === declared)) throw new Error(`${path} default ${JSON.stringify(declared)} is not one of ${entries.map((entry) => entry.name).join(", ")}`);
|
|
4482
|
-
return {
|
|
4483
|
-
defaultBase: declared,
|
|
4484
|
-
entries
|
|
4485
|
-
};
|
|
4486
|
-
}
|
|
4487
|
-
function resolveAgentPresetDir(importMetaUrl) {
|
|
4488
|
-
const overlayCandidate = join(dirname(fileURLToPath(importMetaUrl)), "..", "..", "evolution-agent");
|
|
4489
|
-
if (existsSync(join(overlayCandidate, "agent.cordis.yml")) && existsSync(join(overlayCandidate, "bases.json"))) return overlayCandidate;
|
|
4490
|
-
try {
|
|
4491
|
-
const agentPresetPackage = scopedPackageName("dsh-evolution-agent-preset", importMetaUrl);
|
|
4492
|
-
return dirname(createRequire(importMetaUrl).resolve(agentPresetPackage + "/package.json"));
|
|
4493
|
-
} catch {
|
|
4494
|
-
return overlayCandidate;
|
|
4495
|
-
}
|
|
4496
|
-
}
|
|
4497
|
-
/** F-328: render staged args for `pending --detail`, truncated to 500 chars.
|
|
4498
|
-
* args may be non-JSON (a tool produced garbage), so the render is fail-safe.
|
|
4499
|
-
* V4-19: a truncation is marked with `…(truncated N chars)` so the operator is
|
|
4500
|
-
* never silently shown a partial JSON payload that could even split an escape
|
|
4501
|
-
* sequence — the marker makes the cut explicit rather than looking complete. */
|
|
4502
4230
|
function safeStagedArgs(args) {
|
|
4503
4231
|
try {
|
|
4504
4232
|
const json = JSON.stringify(args);
|
package/lib/types/parse.d.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* This parser is order- and `=`-tolerant, matches the subcommand name case-insensitively, keeps a flag
|
|
10
10
|
* VALUE's case intact (the domain layer is the one that validates it), and answers a SYNTAX failure when a
|
|
11
|
-
* declared value flag is left without its value (F-3: `
|
|
11
|
+
* declared value flag is left without its value (F-3: `extract --start 3` must not read
|
|
12
12
|
* `--expect 3` as the value).
|
|
13
13
|
*
|
|
14
14
|
* @module @lmzhen/dsh-evolution-commands/parse
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lmzhen/dsh-evolution-commands",
|
|
3
3
|
"description": "Human commands for the evolution family (/evolution pending|curator|maintain|doctor) (community build)",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.43.0",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -27,13 +27,13 @@
|
|
|
27
27
|
"license": "MIT",
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@deepseek-ai/schemastery": "^3.18.5",
|
|
30
|
-
"@lmzhen/dsh-evolution-approval": "^0.
|
|
31
|
-
"@lmzhen/dsh-evolution-core": "^0.
|
|
32
|
-
"@lmzhen/dsh-evolution-maintenance": "^0.
|
|
33
|
-
"@lmzhen/dsh-evolution-state-storage": "^0.
|
|
30
|
+
"@lmzhen/dsh-evolution-approval": "^0.43.0",
|
|
31
|
+
"@lmzhen/dsh-evolution-core": "^0.43.0",
|
|
32
|
+
"@lmzhen/dsh-evolution-maintenance": "^0.43.0",
|
|
33
|
+
"@lmzhen/dsh-evolution-state-storage": "^0.43.0"
|
|
34
34
|
},
|
|
35
35
|
"optionalDependencies": {
|
|
36
|
-
"@lmzhen/dsh-evolution-agent-preset": "^0.
|
|
36
|
+
"@lmzhen/dsh-evolution-agent-preset": "^0.43.0"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"@deepseek-ai/cordis": "^4.0.5",
|