@lmzhen/dsh-evolution-commands 0.51.1 → 0.52.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 +0 -361
- package/lib/types/generated/host-commands.d.ts +0 -20
- package/package.json +6 -6
package/lib/index.js
CHANGED
|
@@ -7,7 +7,6 @@ import { dirname, join } from "node:path";
|
|
|
7
7
|
import { fileURLToPath } from "node:url";
|
|
8
8
|
import z from "@deepseek-ai/schemastery";
|
|
9
9
|
import { effectiveSessionPolicy } from "@lmzhen/dsh-evolution-approval";
|
|
10
|
-
import { EXTRACT_PROMPT_V1, buildExtractPlanFromLibrary, ownerCandidatesFromSummaries, ownerDecisionText, proposalFromPlan, readProposalReport, writeProposalReport } from "@lmzhen/dsh-evolution-core/extract";
|
|
11
10
|
import { buildEnrichment, buildMaintainFacts, enrichmentSnapshotOptions, runMaintain, snapshotFromLibrary } from "@lmzhen/dsh-evolution-maintenance";
|
|
12
11
|
import { composePresetEntry, presetRowBlock, presetRowBody, presetRowId, resolveBasePresetPatch } from "@lmzhen/dsh-evolution-core/composition";
|
|
13
12
|
import { processScopeViolations } from "@lmzhen/dsh-evolution-state";
|
|
@@ -1101,16 +1100,6 @@ const HOST_COMMANDS = {
|
|
|
1101
1100
|
"ru": "Записать **строку** пресета Agent самоэволюции в слой патчей текущего профиля (`profiles/<p>/cordis.patch.yml`; bases берутся из bases.json пакета agent)",
|
|
1102
1101
|
"pt": "Gravar a **linha** do preset Agent de autoevolução na camada de patches do perfil atual (`profiles/<p>/cordis.patch.yml`; as bases vêm do bases.json do pacote agent)"
|
|
1103
1102
|
},
|
|
1104
|
-
"summary.restructure": {
|
|
1105
|
-
"zh": "把技能正文的一节移到 references 文件",
|
|
1106
|
-
"en": "Move one section of a skill body into a references file",
|
|
1107
|
-
"ja": "スキル本文の1セクションを references ファイルへ移す",
|
|
1108
|
-
"es": "Mover una sección del cuerpo de un skill a un archivo de references",
|
|
1109
|
-
"fr": "Déplacer une section du corps d’un skill vers un fichier references",
|
|
1110
|
-
"de": "Einen Abschnitt des Skill-Textes in eine references-Datei verschieben",
|
|
1111
|
-
"ru": "Перенести один раздел текста навыка в файл references",
|
|
1112
|
-
"pt": "Mover uma seção do corpo de uma skill para um arquivo references"
|
|
1113
|
-
},
|
|
1114
1103
|
"summary.offload": {
|
|
1115
1104
|
"zh": "把技能正文的会话细节章节移到 references(后台子智能体,--dry-run 只预览)",
|
|
1116
1105
|
"en": "Move session-detail sections from a skill body into references (background subagent; --dry-run previews only)",
|
|
@@ -1131,16 +1120,6 @@ const HOST_COMMANDS = {
|
|
|
1131
1120
|
"ru": "Сжимать текст навыка по разделам (фоновый подагент, повторные небольшие правки; --dry-run только предпросмотр)",
|
|
1132
1121
|
"pt": "Condensar o corpo de uma skill seção por seção (subagente em segundo plano, pequenas edições repetidas; --dry-run apenas pré-visualiza)"
|
|
1133
1122
|
},
|
|
1134
|
-
"summary.extract": {
|
|
1135
|
-
"zh": "预览把源技能的可复用部分提取到已有类级 owner;默认 plan,--apply 才写(多根一次事务)",
|
|
1136
|
-
"en": "Preview extracting a source skill's reusable part into an existing class-level owner; by default it produces a plan, and only --apply writes (multiple roots in one transaction)",
|
|
1137
|
-
"ja": "元スキルの再利用できる部分を既存のクラス担当スキルへ抽出するプレビュー(既定は plan のみ、--apply で書き込み。複数ルートを1トランザクション)",
|
|
1138
|
-
"es": "Previsualizar la extracción de la parte reutilizable de un skill de origen a un skill existente que ya cubre esa clase; por defecto solo genera un plan y solo --apply escribe (varias raíces en una transacción)",
|
|
1139
|
-
"fr": "Prévisualiser l’extraction de la partie réutilisable d’un skill d’origine vers un skill existant qui couvre déjà la classe ; par défaut, elle produit un plan et seul --apply écrit (plusieurs racines en une transaction)",
|
|
1140
|
-
"de": "In der Vorschau zeigen, wie der wiederverwendbare Teil eines Quell-Skills in einen vorhandenen Skill, der die Klasse abdeckt, extrahiert wird; standardmäßig entsteht nur ein Plan, und erst --apply schreibt (mehrere Roots in einer Transaktion)",
|
|
1141
|
-
"ru": "Показать предпросмотр извлечения переиспользуемой части исходного навыка в существующий навык, покрывающий этот класс; по умолчанию только план, запись — с --apply (несколько корней в одной транзакции)",
|
|
1142
|
-
"pt": "Pré-visualizar a extração da parte reutilizável de uma skill de origem para uma skill existente que já cobre a classe; por padrão gera só o plano e --apply é que grava (várias raízes em uma transação)"
|
|
1143
|
-
},
|
|
1144
1123
|
"summary.replay": {
|
|
1145
1124
|
"zh": "比较不同会话与重启之间的计划结果(从活动记录回填)",
|
|
1146
1125
|
"en": "Compare plan results across sessions and restarts (backfilled from the activity log)",
|
|
@@ -1883,31 +1862,6 @@ const HOST_COMMAND_DEFS = [
|
|
|
1883
1862
|
fallback: "params [--group <name>] [--json]",
|
|
1884
1863
|
usageLine: "params [--group <name>] [--json]"
|
|
1885
1864
|
},
|
|
1886
|
-
{
|
|
1887
|
-
id: "restructure",
|
|
1888
|
-
words: ["restructure"],
|
|
1889
|
-
summaryKey: "summary.restructure",
|
|
1890
|
-
helpKey: "help.restructure",
|
|
1891
|
-
flags: [
|
|
1892
|
-
{
|
|
1893
|
-
name: "plan",
|
|
1894
|
-
kind: "value"
|
|
1895
|
-
},
|
|
1896
|
-
{
|
|
1897
|
-
name: "start",
|
|
1898
|
-
kind: "value"
|
|
1899
|
-
},
|
|
1900
|
-
{
|
|
1901
|
-
name: "end",
|
|
1902
|
-
kind: "value"
|
|
1903
|
-
}
|
|
1904
|
-
],
|
|
1905
|
-
positional: [],
|
|
1906
|
-
readOnly: false,
|
|
1907
|
-
needsRun: false,
|
|
1908
|
-
fallback: "restructure <name> \"<heading>\" <to_file> [--start <line>] [--end <line>] [--plan <runId>]",
|
|
1909
|
-
usageLine: "restructure <name> \"<heading>\" <to_file> [--start <line>] [--end <line>] [--plan <runId>]"
|
|
1910
|
-
},
|
|
1911
1865
|
{
|
|
1912
1866
|
id: "offload",
|
|
1913
1867
|
words: ["offload"],
|
|
@@ -1941,43 +1895,6 @@ const HOST_COMMAND_DEFS = [
|
|
|
1941
1895
|
fallback: "condense <name> [--dry-run]",
|
|
1942
1896
|
usageLine: "condense <name> [--dry-run]"
|
|
1943
1897
|
},
|
|
1944
|
-
{
|
|
1945
|
-
id: "extract",
|
|
1946
|
-
words: ["extract"],
|
|
1947
|
-
summaryKey: "summary.extract",
|
|
1948
|
-
helpKey: "help.extract",
|
|
1949
|
-
flags: [
|
|
1950
|
-
{
|
|
1951
|
-
name: "start",
|
|
1952
|
-
kind: "value"
|
|
1953
|
-
},
|
|
1954
|
-
{
|
|
1955
|
-
name: "end",
|
|
1956
|
-
kind: "value"
|
|
1957
|
-
},
|
|
1958
|
-
{
|
|
1959
|
-
name: "outcome",
|
|
1960
|
-
kind: "value"
|
|
1961
|
-
},
|
|
1962
|
-
{
|
|
1963
|
-
name: "proposal",
|
|
1964
|
-
kind: "value"
|
|
1965
|
-
},
|
|
1966
|
-
{
|
|
1967
|
-
name: "owner-covers",
|
|
1968
|
-
kind: "boolean"
|
|
1969
|
-
},
|
|
1970
|
-
{
|
|
1971
|
-
name: "apply",
|
|
1972
|
-
kind: "boolean"
|
|
1973
|
-
}
|
|
1974
|
-
],
|
|
1975
|
-
positional: [],
|
|
1976
|
-
readOnly: false,
|
|
1977
|
-
needsRun: false,
|
|
1978
|
-
fallback: "extract <source> [<target> \"<heading>\"] [--start <line>] [--end <line>] [--outcome extract|mixed] [--proposal <id>] [--owner-covers] [--apply]",
|
|
1979
|
-
usageLine: "extract <source> [<target> \"<heading>\"] [--start <line>] [--end <line>] [--outcome extract|mixed] [--proposal <id>] [--owner-covers] [--apply]"
|
|
1980
|
-
},
|
|
1981
1898
|
{
|
|
1982
1899
|
id: "replay",
|
|
1983
1900
|
words: ["replay"],
|
|
@@ -3870,114 +3787,6 @@ const GOVERNANCE_REPORT_TIMEOUT_MS = 1e4;
|
|
|
3870
3787
|
function newestRun(registry, kind = "maintain") {
|
|
3871
3788
|
return registry.runs(kind).find((record) => record.id.trim() !== "");
|
|
3872
3789
|
}
|
|
3873
|
-
/** Source-only extract discovery: the child proposes an owner; it never writes. */
|
|
3874
|
-
async function discoverExtract(ctx, parent, source, library, io) {
|
|
3875
|
-
const body = await library.read(source);
|
|
3876
|
-
if (body === null) return `技能「${source}」不存在。`;
|
|
3877
|
-
const lookup = ownerCandidatesFromSummaries(source, await library.model.list({
|
|
3878
|
-
withContent: true,
|
|
3879
|
-
withFrontmatter: true
|
|
3880
|
-
}));
|
|
3881
|
-
const support = await library.listSupportFiles(source);
|
|
3882
|
-
const input = JSON.stringify({
|
|
3883
|
-
source,
|
|
3884
|
-
body,
|
|
3885
|
-
support: isPresent(support) ? support.value : null,
|
|
3886
|
-
candidates: lookup.candidates.map((candidate) => ({
|
|
3887
|
-
name: candidate.name,
|
|
3888
|
-
description: candidate.description,
|
|
3889
|
-
whenToUse: candidate.whenToUse ?? null,
|
|
3890
|
-
headings: candidate.headings
|
|
3891
|
-
})),
|
|
3892
|
-
excluded: lookup.excluded
|
|
3893
|
-
});
|
|
3894
|
-
const outcome = await createSubagentChannel(ctx).run({
|
|
3895
|
-
parent,
|
|
3896
|
-
label: "dsh-evolution-extract",
|
|
3897
|
-
kind: "maintainer",
|
|
3898
|
-
allow: ["skill"],
|
|
3899
|
-
promptText: EXTRACT_PROMPT_V1 + "\n\nEXTRACT INPUT\n" + input,
|
|
3900
|
-
timeoutMs: 12e4,
|
|
3901
|
-
outputSchema: {
|
|
3902
|
-
type: "object",
|
|
3903
|
-
additionalProperties: false,
|
|
3904
|
-
required: ["outcome", "reason"],
|
|
3905
|
-
properties: {
|
|
3906
|
-
outcome: {
|
|
3907
|
-
type: "string",
|
|
3908
|
-
enum: [
|
|
3909
|
-
"keep",
|
|
3910
|
-
"extract",
|
|
3911
|
-
"mixed",
|
|
3912
|
-
"owner-gap"
|
|
3913
|
-
]
|
|
3914
|
-
},
|
|
3915
|
-
target: { type: "string" },
|
|
3916
|
-
neededOwner: { type: "string" },
|
|
3917
|
-
reason: { type: "string" },
|
|
3918
|
-
parts: {
|
|
3919
|
-
type: "array",
|
|
3920
|
-
items: {
|
|
3921
|
-
type: "object",
|
|
3922
|
-
additionalProperties: false,
|
|
3923
|
-
required: ["heading"],
|
|
3924
|
-
properties: {
|
|
3925
|
-
heading: { type: "string" },
|
|
3926
|
-
start: { type: "string" },
|
|
3927
|
-
end: { type: "string" }
|
|
3928
|
-
}
|
|
3929
|
-
}
|
|
3930
|
-
}
|
|
3931
|
-
}
|
|
3932
|
-
}
|
|
3933
|
-
});
|
|
3934
|
-
if (outcome.kind !== "ok") return `extract proposal 不可用:${"reason" in outcome ? outcome.reason : outcome.kind}`;
|
|
3935
|
-
const proposal = outcome.structured;
|
|
3936
|
-
const parts = Array.isArray(proposal.parts) ? proposal.parts.map((part) => part.heading).filter((heading) => typeof heading === "string") : [];
|
|
3937
|
-
const outcomeName = proposal.outcome === "extract" || proposal.outcome === "mixed" ? proposal.outcome : proposal.outcome === "keep" ? "keep" : "owner-gap";
|
|
3938
|
-
const runId = "extract-" + Date.now().toString(36);
|
|
3939
|
-
const target = typeof proposal.target === "string" && proposal.target !== "" ? proposal.target : void 0;
|
|
3940
|
-
const record = {
|
|
3941
|
-
version: 1,
|
|
3942
|
-
id: "extract-" + runId + "-" + source,
|
|
3943
|
-
source,
|
|
3944
|
-
outcome: outcomeName,
|
|
3945
|
-
parts: Array.isArray(proposal.parts) ? proposal.parts.filter((part) => typeof part.heading === "string").map((part) => ({
|
|
3946
|
-
heading: part.heading,
|
|
3947
|
-
anchor: { heading: part.heading },
|
|
3948
|
-
reason: "proposed by extract agent"
|
|
3949
|
-
})) : [],
|
|
3950
|
-
owner: {
|
|
3951
|
-
mode: target === void 0 ? "owner-gap" : "covered",
|
|
3952
|
-
...target === void 0 ? {} : { name: target },
|
|
3953
|
-
...proposal.neededOwner === void 0 ? {} : { neededOwner: proposal.neededOwner },
|
|
3954
|
-
triggerCovers: target !== void 0,
|
|
3955
|
-
outcomeCovers: target !== void 0,
|
|
3956
|
-
reason: String(proposal.reason ?? "")
|
|
3957
|
-
},
|
|
3958
|
-
warnings: [],
|
|
3959
|
-
provenance: {
|
|
3960
|
-
promptVersion: "v1",
|
|
3961
|
-
runId,
|
|
3962
|
-
at: Date.now()
|
|
3963
|
-
},
|
|
3964
|
-
status: "proposed"
|
|
3965
|
-
};
|
|
3966
|
-
let proposalLine = "proposal: —";
|
|
3967
|
-
try {
|
|
3968
|
-
await writeProposalReport(io, record);
|
|
3969
|
-
proposalLine = `proposal: ${record.id}\n应用:/evolution extract ${source} --proposal ${record.id}`;
|
|
3970
|
-
} catch {}
|
|
3971
|
-
return [
|
|
3972
|
-
"extract proposal(未写入)",
|
|
3973
|
-
"outcome: " + String(proposal.outcome ?? "unknown"),
|
|
3974
|
-
"target: " + String(proposal.target ?? "—"),
|
|
3975
|
-
"neededOwner: " + String(proposal.neededOwner ?? "—"),
|
|
3976
|
-
"parts: " + (parts.length === 0 ? "—" : parts.join(", ")),
|
|
3977
|
-
"reason: " + String(proposal.reason ?? "—"),
|
|
3978
|
-
proposalLine
|
|
3979
|
-
].join("\n");
|
|
3980
|
-
}
|
|
3981
3790
|
/** Sentence F, ONE wording for the three id-less forms (design `10` cell 13): an index that could
|
|
3982
3791
|
* not be read must never answer as "there is no recent run" (G2/0.20.0). */
|
|
3983
3792
|
function unreadableIndex(note) {
|
|
@@ -4327,176 +4136,6 @@ function apply(ctx, rawConfig = {}) {
|
|
|
4327
4136
|
});
|
|
4328
4137
|
return woke ? ok("已向本会话发送学习请求,请现在执行。") : ok("学习请求已排入本会话队列:本宿主没有唤醒通道,会在你下一条消息时读取。");
|
|
4329
4138
|
}
|
|
4330
|
-
case "extract": {
|
|
4331
|
-
if (isParseFailure(command) || command.name !== "extract") return err("用法:/evolution extract <source> <target> \"<heading>\" [--start <line>] [--end <line>] [--owner-covers] 或 --proposal <id>");
|
|
4332
|
-
const source = command.positionals[0] ?? "";
|
|
4333
|
-
const proposalFlag = command.flags.get("proposal");
|
|
4334
|
-
const ioRegistry = ctx.get("evolutionIo");
|
|
4335
|
-
if (!ioRegistry) return err("未挂载 evolution-io 注册表:无法执行 extract。");
|
|
4336
|
-
const library = newSkillLibrary({
|
|
4337
|
-
authority: authorityFrom({ origin: "foreground" }),
|
|
4338
|
-
config: { root: skillsRootValue },
|
|
4339
|
-
io: ioRegistry.provider(),
|
|
4340
|
-
ctx,
|
|
4341
|
-
threatExemptLabels: config.threatExemptLabels,
|
|
4342
|
-
limits: {
|
|
4343
|
-
...DEFAULT_SKILL_LIMITS,
|
|
4344
|
-
...policyStageLimits(ctx.get("evolutionPolicy")?.get?.())
|
|
4345
|
-
}
|
|
4346
|
-
});
|
|
4347
|
-
let target = command.positionals[1] ?? "";
|
|
4348
|
-
let heading = command.positionals[2] ?? "";
|
|
4349
|
-
let start;
|
|
4350
|
-
let end;
|
|
4351
|
-
let extractItems = [];
|
|
4352
|
-
let proposalOutcome;
|
|
4353
|
-
if (typeof proposalFlag === "string") {
|
|
4354
|
-
if (source === "") return err("用法:/evolution extract <source> --proposal <id>");
|
|
4355
|
-
const proposal = await readProposalReport(ioRegistry.provider(), proposalFlag);
|
|
4356
|
-
if (proposal === null) return err("找不到 extract proposal:" + proposalFlag);
|
|
4357
|
-
if (proposal.outcome === "keep") return err("该 proposal 的结论是 keep,没有可应用提取。");
|
|
4358
|
-
if (proposal.owner.mode !== "covered" || proposal.owner.name === void 0) return err("该 proposal 未覆盖 owner(owner-gap),不能应用。");
|
|
4359
|
-
target = proposal.owner.name;
|
|
4360
|
-
heading = proposal.parts[0]?.heading ?? "";
|
|
4361
|
-
proposalOutcome = proposal.outcome === "extract" || proposal.outcome === "mixed" ? proposal.outcome : void 0;
|
|
4362
|
-
extractItems = proposal.parts.map((part) => ({
|
|
4363
|
-
heading: part.heading,
|
|
4364
|
-
...part.anchor.start === void 0 ? {} : { start: part.anchor.start },
|
|
4365
|
-
...part.anchor.end === void 0 ? {} : { end: part.anchor.end },
|
|
4366
|
-
to_skill: target
|
|
4367
|
-
}));
|
|
4368
|
-
} else {
|
|
4369
|
-
if (source === "") return err("用法:/evolution extract <source> [<target> \"<heading>\"] [--start <line>] [--end <line>]");
|
|
4370
|
-
if (target === "" && heading === "") return ok(await discoverExtract(ctx, invocationAgent, source, library, ioRegistry.provider()));
|
|
4371
|
-
if (target === "" || heading === "") return err("用法:/evolution extract <source> <target> \"<heading>\" [--start <line>] [--end <line>]");
|
|
4372
|
-
const startFlag = command.flags.get("start");
|
|
4373
|
-
const endFlag = command.flags.get("end");
|
|
4374
|
-
start = typeof startFlag === "string" ? startFlag : void 0;
|
|
4375
|
-
end = typeof endFlag === "string" ? endFlag : void 0;
|
|
4376
|
-
extractItems = [{
|
|
4377
|
-
heading,
|
|
4378
|
-
...start === void 0 ? {} : { start },
|
|
4379
|
-
...end === void 0 ? {} : { end },
|
|
4380
|
-
to_skill: target
|
|
4381
|
-
}];
|
|
4382
|
-
}
|
|
4383
|
-
const ownerCovers = command.flags.has("owner-covers");
|
|
4384
|
-
const outcomeFlag = command.flags.get("outcome");
|
|
4385
|
-
if (outcomeFlag !== void 0 && outcomeFlag !== "extract" && outcomeFlag !== "mixed") return err("--outcome 只能是 extract 或 mixed。");
|
|
4386
|
-
const built = await buildExtractPlanFromLibrary(library, {
|
|
4387
|
-
source,
|
|
4388
|
-
items: extractItems,
|
|
4389
|
-
...outcomeFlag === void 0 ? proposalOutcome === void 0 ? {} : { outcome: proposalOutcome } : { outcome: outcomeFlag },
|
|
4390
|
-
...ownerCovers ? { ownerCovers: true } : {}
|
|
4391
|
-
});
|
|
4392
|
-
if (!built.ok) return err(built.message);
|
|
4393
|
-
const plan = built.plan;
|
|
4394
|
-
const warnings = built.warnings === void 0 || built.warnings.length === 0 ? "" : "\n" + built.warnings.join("\n");
|
|
4395
|
-
if (!command.flags.has("apply")) {
|
|
4396
|
-
const proposal = proposalFromPlan(plan, { runId: "cli-" + Date.now().toString(36) });
|
|
4397
|
-
const proposalPath = await writeProposalReport(ioRegistry.provider(), proposal).catch(() => {});
|
|
4398
|
-
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)"));
|
|
4399
|
-
}
|
|
4400
|
-
if (approval) {
|
|
4401
|
-
const session = invocationAgent?.session;
|
|
4402
|
-
const sessionPolicy = effectiveSessionPolicy(ctx, session);
|
|
4403
|
-
const stagesForeground = approval.isEnabled !== false && sessionPolicy !== "never" && approval.stageForeground !== false;
|
|
4404
|
-
if (stagesForeground && session === void 0) return err(hostError("e-306-this-deployment-stages-foreground-2"));
|
|
4405
|
-
if (stagesForeground && !approval.hasRunner("skill")) return err("无法暂存提取:没有注册技能回放运行器:请挂载 tool-skill-manage 行,或禁用 evolution-approval。");
|
|
4406
|
-
const decision = await approval.request({
|
|
4407
|
-
kind: "skill",
|
|
4408
|
-
summary: "/evolution extract " + source + " -> " + target + " " + heading,
|
|
4409
|
-
args: {
|
|
4410
|
-
operation: {
|
|
4411
|
-
action: "extract",
|
|
4412
|
-
name: source,
|
|
4413
|
-
extract: extractItems
|
|
4414
|
-
},
|
|
4415
|
-
origin: "foreground",
|
|
4416
|
-
libraryOrigin: "foreground"
|
|
4417
|
-
},
|
|
4418
|
-
origin: "foreground",
|
|
4419
|
-
...session !== void 0 ? {
|
|
4420
|
-
sessionId: session.id,
|
|
4421
|
-
session
|
|
4422
|
-
} : {},
|
|
4423
|
-
...sessionPolicy !== void 0 ? { sessionPolicy } : {}
|
|
4424
|
-
});
|
|
4425
|
-
if (decision.action === "staged") return ok(decision.message);
|
|
4426
|
-
}
|
|
4427
|
-
const result = await library.extract(plan, "foreground");
|
|
4428
|
-
if (!result.ok) return err(result.message);
|
|
4429
|
-
return ok(result.message + "\n提取判定:outcome=" + plan.outcome + ";target=" + target + warnings);
|
|
4430
|
-
}
|
|
4431
|
-
case "restructure": {
|
|
4432
|
-
if (isParseFailure(command) || command.name !== "restructure") return err("用法:/evolution restructure <name> \"<heading>\" <to_file>");
|
|
4433
|
-
const name = command.positionals[0] ?? "";
|
|
4434
|
-
const heading = command.positionals[1] ?? "";
|
|
4435
|
-
const toFile = command.positionals[2] ?? "";
|
|
4436
|
-
if (name === "" || heading === "" || toFile === "") return err("用法:/evolution restructure <name> \"<heading>\" <to_file>");
|
|
4437
|
-
const planFlag = command.flags.get("plan");
|
|
4438
|
-
const planRunId = typeof planFlag === "string" ? planFlag : void 0;
|
|
4439
|
-
const startFlag = command.flags.get("start");
|
|
4440
|
-
const endFlag = command.flags.get("end");
|
|
4441
|
-
const start = typeof startFlag === "string" ? startFlag : void 0;
|
|
4442
|
-
const end = typeof endFlag === "string" ? endFlag : void 0;
|
|
4443
|
-
if (start === void 0 !== (end === void 0)) return err("--start 和 --end 必须同时提供。");
|
|
4444
|
-
const move = {
|
|
4445
|
-
heading,
|
|
4446
|
-
...start === void 0 ? {} : { start },
|
|
4447
|
-
...end === void 0 ? {} : { end },
|
|
4448
|
-
toFile
|
|
4449
|
-
};
|
|
4450
|
-
if (!toFile.startsWith("references/")) return err("to_file 必须位于 references/ 之下(日志或明细的落地位置)。");
|
|
4451
|
-
const ioRegistry = ctx.get("evolutionIo");
|
|
4452
|
-
if (!ioRegistry) return err("未挂载 evolution-io 注册表:无法重构。");
|
|
4453
|
-
if (approval) {
|
|
4454
|
-
const session = invocationAgent?.session;
|
|
4455
|
-
const sessionPolicy = effectiveSessionPolicy(ctx, session);
|
|
4456
|
-
const stagesForeground = approval.isEnabled !== false && sessionPolicy !== "never" && approval.stageForeground !== false;
|
|
4457
|
-
if (stagesForeground && session === void 0) return err(hostError("e-306-this-deployment-stages-foreground-2"));
|
|
4458
|
-
if (stagesForeground && !approval.hasRunner("skill")) return err("无法暂存重构:没有注册技能回放运行器:请挂载 tool-skill-manage 行(evolution-agent 预设或 evolution-all),或禁用 evolution-approval。");
|
|
4459
|
-
const decision = await approval.request({
|
|
4460
|
-
kind: "skill",
|
|
4461
|
-
summary: `/evolution restructure ${name}${planRunId ? ` (plan ${planRunId})` : ""}`,
|
|
4462
|
-
args: {
|
|
4463
|
-
operation: {
|
|
4464
|
-
action: "restructure",
|
|
4465
|
-
name,
|
|
4466
|
-
restructure: [{
|
|
4467
|
-
heading,
|
|
4468
|
-
...start === void 0 ? {} : { start },
|
|
4469
|
-
...end === void 0 ? {} : { end },
|
|
4470
|
-
to_file: toFile
|
|
4471
|
-
}]
|
|
4472
|
-
},
|
|
4473
|
-
origin: "foreground",
|
|
4474
|
-
libraryOrigin: "foreground"
|
|
4475
|
-
},
|
|
4476
|
-
origin: "foreground",
|
|
4477
|
-
...session !== void 0 ? {
|
|
4478
|
-
sessionId: session.id,
|
|
4479
|
-
session
|
|
4480
|
-
} : {},
|
|
4481
|
-
...sessionPolicy !== void 0 ? { sessionPolicy } : {}
|
|
4482
|
-
});
|
|
4483
|
-
if (decision.action === "staged") return ok(`${decision.message}${planRunId ? `\n[audit] plan=${planRunId}` : ""}`);
|
|
4484
|
-
}
|
|
4485
|
-
const result = await newSkillLibrary({
|
|
4486
|
-
authority: authorityFrom({ origin: "foreground" }),
|
|
4487
|
-
config: { root: skillsRootValue },
|
|
4488
|
-
io: ioRegistry.provider(),
|
|
4489
|
-
ctx,
|
|
4490
|
-
threatExemptLabels: config.threatExemptLabels,
|
|
4491
|
-
limits: {
|
|
4492
|
-
...DEFAULT_SKILL_LIMITS,
|
|
4493
|
-
...policyStageLimits(ctx.get("evolutionPolicy")?.get?.())
|
|
4494
|
-
}
|
|
4495
|
-
}).restructure(name, [move], "foreground");
|
|
4496
|
-
if (!result.ok) return err(result.message);
|
|
4497
|
-
await ctx.get("skillUsage")?.record?.(name, "patch");
|
|
4498
|
-
return ok(planRunId ? `${result.message}\n[audit] plan=${planRunId}` : result.message);
|
|
4499
|
-
}
|
|
4500
4139
|
case "offload": {
|
|
4501
4140
|
if (!("positionals" in command)) return err("用法:/evolution offload <skill> [--heading <heading>] [--dry-run]");
|
|
4502
4141
|
const target = command.positionals[0] ?? "";
|
|
@@ -282,16 +282,6 @@ export declare const HOST_COMMANDS: {
|
|
|
282
282
|
readonly ru: "Записать **строку** пресета Agent самоэволюции в слой патчей текущего профиля (`profiles/<p>/cordis.patch.yml`; bases берутся из bases.json пакета agent)";
|
|
283
283
|
readonly pt: "Gravar a **linha** do preset Agent de autoevolução na camada de patches do perfil atual (`profiles/<p>/cordis.patch.yml`; as bases vêm do bases.json do pacote agent)";
|
|
284
284
|
};
|
|
285
|
-
readonly "summary.restructure": {
|
|
286
|
-
readonly zh: "把技能正文的一节移到 references 文件";
|
|
287
|
-
readonly en: "Move one section of a skill body into a references file";
|
|
288
|
-
readonly ja: "スキル本文の1セクションを references ファイルへ移す";
|
|
289
|
-
readonly es: "Mover una sección del cuerpo de un skill a un archivo de references";
|
|
290
|
-
readonly fr: "Déplacer une section du corps d’un skill vers un fichier references";
|
|
291
|
-
readonly de: "Einen Abschnitt des Skill-Textes in eine references-Datei verschieben";
|
|
292
|
-
readonly ru: "Перенести один раздел текста навыка в файл references";
|
|
293
|
-
readonly pt: "Mover uma seção do corpo de uma skill para um arquivo references";
|
|
294
|
-
};
|
|
295
285
|
readonly "summary.offload": {
|
|
296
286
|
readonly zh: "把技能正文的会话细节章节移到 references(后台子智能体,--dry-run 只预览)";
|
|
297
287
|
readonly en: "Move session-detail sections from a skill body into references (background subagent; --dry-run previews only)";
|
|
@@ -312,16 +302,6 @@ export declare const HOST_COMMANDS: {
|
|
|
312
302
|
readonly ru: "Сжимать текст навыка по разделам (фоновый подагент, повторные небольшие правки; --dry-run только предпросмотр)";
|
|
313
303
|
readonly pt: "Condensar o corpo de uma skill seção por seção (subagente em segundo plano, pequenas edições repetidas; --dry-run apenas pré-visualiza)";
|
|
314
304
|
};
|
|
315
|
-
readonly "summary.extract": {
|
|
316
|
-
readonly zh: "预览把源技能的可复用部分提取到已有类级 owner;默认 plan,--apply 才写(多根一次事务)";
|
|
317
|
-
readonly en: "Preview extracting a source skill's reusable part into an existing class-level owner; by default it produces a plan, and only --apply writes (multiple roots in one transaction)";
|
|
318
|
-
readonly ja: "元スキルの再利用できる部分を既存のクラス担当スキルへ抽出するプレビュー(既定は plan のみ、--apply で書き込み。複数ルートを1トランザクション)";
|
|
319
|
-
readonly es: "Previsualizar la extracción de la parte reutilizable de un skill de origen a un skill existente que ya cubre esa clase; por defecto solo genera un plan y solo --apply escribe (varias raíces en una transacción)";
|
|
320
|
-
readonly fr: "Prévisualiser l’extraction de la partie réutilisable d’un skill d’origine vers un skill existant qui couvre déjà la classe ; par défaut, elle produit un plan et seul --apply écrit (plusieurs racines en une transaction)";
|
|
321
|
-
readonly de: "In der Vorschau zeigen, wie der wiederverwendbare Teil eines Quell-Skills in einen vorhandenen Skill, der die Klasse abdeckt, extrahiert wird; standardmäßig entsteht nur ein Plan, und erst --apply schreibt (mehrere Roots in einer Transaktion)";
|
|
322
|
-
readonly ru: "Показать предпросмотр извлечения переиспользуемой части исходного навыка в существующий навык, покрывающий этот класс; по умолчанию только план, запись — с --apply (несколько корней в одной транзакции)";
|
|
323
|
-
readonly pt: "Pré-visualizar a extração da parte reutilizável de uma skill de origem para uma skill existente que já cobre a classe; por padrão gera só o plano e --apply é que grava (várias raízes em uma transação)";
|
|
324
|
-
};
|
|
325
305
|
readonly "summary.replay": {
|
|
326
306
|
readonly zh: "比较不同会话与重启之间的计划结果(从活动记录回填)";
|
|
327
307
|
readonly en: "Compare plan results across sessions and restarts (backfilled from the activity log)";
|
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.52.0",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -29,13 +29,13 @@
|
|
|
29
29
|
"license": "MIT",
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@deepseek-ai/schemastery": "^3.18.5",
|
|
32
|
-
"@lmzhen/dsh-evolution-approval": "^0.
|
|
33
|
-
"@lmzhen/dsh-evolution-core": "^0.
|
|
34
|
-
"@lmzhen/dsh-evolution-maintenance": "^0.
|
|
35
|
-
"@lmzhen/dsh-evolution-state": "^0.
|
|
32
|
+
"@lmzhen/dsh-evolution-approval": "^0.52.0",
|
|
33
|
+
"@lmzhen/dsh-evolution-core": "^0.52.0",
|
|
34
|
+
"@lmzhen/dsh-evolution-maintenance": "^0.52.0",
|
|
35
|
+
"@lmzhen/dsh-evolution-state": "^0.52.0"
|
|
36
36
|
},
|
|
37
37
|
"optionalDependencies": {
|
|
38
|
-
"@lmzhen/dsh-evolution-agent-preset": "^0.
|
|
38
|
+
"@lmzhen/dsh-evolution-agent-preset": "^0.52.0"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"@deepseek-ai/cordis": "^4.0.5",
|