@lmzhen/dsh-evolution-core 0.40.1 → 0.42.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.
Files changed (62) hide show
  1. package/lib/composition/index.js +2 -2
  2. package/lib/{composition-dy0gJWDd.js → composition-CVafrlEw.js} +2 -2
  3. package/lib/{ensure-B4fjEI0w.js → ensure-BjToTMMj.js} +2 -2
  4. package/lib/errors-BxzLTVbS.js +399 -0
  5. package/lib/guards-3f02mnf2.js +29 -0
  6. package/lib/http-routes.js +205 -1
  7. package/lib/index.js +3588 -15049
  8. package/lib/mutations-jUuOPaCn.js +718 -0
  9. package/lib/platform/index.js +2 -2
  10. package/lib/{platform-CFp373_0.js → platform-B06_h8t-.js} +4 -1
  11. package/lib/restrictor.js +1 -1
  12. package/lib/runtime/plugin.js +2 -2
  13. package/lib/{session-projection-CXUNPkq9.js → session-projection-EB7mUOlJ.js} +63 -63
  14. package/lib/skill-health-BLGZTIv8.js +3773 -0
  15. package/lib/skill-history-_Cssts5o.js +1912 -0
  16. package/lib/skills.js +4067 -0
  17. package/lib/subagent/index.js +1 -1
  18. package/lib/types/errors.d.ts +12 -0
  19. package/lib/types/errors.js +17 -0
  20. package/lib/types/generated/errors.localized.d.ts +320 -0
  21. package/lib/types/generated/errors.localized.js +318 -0
  22. package/lib/types/home-fence.d.ts +7 -0
  23. package/lib/types/home-fence.js +58 -3
  24. package/lib/types/index.d.ts +1 -18
  25. package/lib/types/index.js +1 -18
  26. package/lib/types/io.js +1 -1
  27. package/lib/types/mutation-authority.d.ts +14 -37
  28. package/lib/types/mutation-authority.js +16 -103
  29. package/lib/types/mutation-storage-adapter.js +9 -6
  30. package/lib/types/mutation-unit.d.ts +14 -0
  31. package/lib/types/mutation-unit.js +30 -10
  32. package/lib/types/opt-in.js +1 -1
  33. package/lib/types/platform/index.d.ts +8 -1
  34. package/lib/types/platform/index.js +3 -0
  35. package/lib/types/review-channel.js +3 -1
  36. package/lib/types/review-context.js +3 -1
  37. package/lib/types/run-registry.d.ts +2 -24
  38. package/lib/types/scope.js +1 -1
  39. package/lib/types/signals.d.ts +1 -1
  40. package/lib/types/skill-store.d.ts +7 -1
  41. package/lib/types/skill-store.js +43 -80
  42. package/lib/types/skills.d.ts +11 -0
  43. package/lib/types/skills.js +11 -0
  44. package/lib/types/subagent/types.d.ts +3 -3
  45. package/lib/types/tree-lock.js +4 -1
  46. package/lib/types/unit-claim.d.ts +8 -0
  47. package/lib/types/unit-claim.js +3 -0
  48. package/lib/types/unit-journal.d.ts +3 -1
  49. package/lib/types/unit-journal.js +12 -3
  50. package/lib/types/unit-storage.d.ts +1 -0
  51. package/lib/types/write-gates.d.ts +1 -1
  52. package/lib/types/write-gates.js +3 -1
  53. package/lib/types/write.d.ts +11 -0
  54. package/lib/types/write.js +11 -0
  55. package/lib/write.js +357 -0
  56. package/package.json +16 -4
  57. package/lib/errors-DUcEoTLR.js +0 -58
  58. package/lib/http-routes-_anZVlPf.js +0 -233
  59. package/lib/types/unit-backend.d.ts +0 -5
  60. package/lib/types/unit-backend.js +0 -55
  61. package/lib/types/unit-transaction.d.ts +0 -225
  62. package/lib/types/unit-transaction.js +0 -501
package/lib/write.js ADDED
@@ -0,0 +1,357 @@
1
+ import { r as contentHash } from "./mutations-jUuOPaCn.js";
2
+ import { $ as writeUnitSnapshot, A as unitJournalPort, B as readUnitEvidence, F as readUnitJournal, G as unitIndexPath, H as readUnitReceipt, I as unitJournalPath, J as unitSnapshotsDir, K as unitReceiptPath, L as unitJournalPhaseRank, M as UNIT_JOURNAL_PHASES, N as UNIT_JOURNAL_SCHEMA_VERSION, P as assertUnitJournalTransition, Q as writeUnitReceipt, R as writeUnitJournal, U as readUnitSnapshot, V as readUnitIndex, W as unitEvidencePath, X as upsertUnitIndex, Y as unitStorageKey, Z as writeUnitEvidence, et as MutationUnit, f as entryTarget, j as unitSnapshotPort, k as pruneTreeChangeUnits, nt as validateMutationRequest, q as unitSnapshotPath, rt as WriteKernel, tt as fileMutationLock, z as UNIT_STORAGE_SCHEMA_VERSION } from "./skill-history-_Cssts5o.js";
3
+ //#region lib/types/unit-undo.js
4
+ /**
5
+ * Cross-skill unit undo executor.
6
+ *
7
+ * Phase A is a zero-write preflight: every live path still carries the unit's after-bytes and
8
+ * every pre-unit blob is readable. Phase B restores archived members, applies support files,
9
+ * writes the body last, then archives a target the unit created. Any preflight refusal means
10
+ * no write at all.
11
+ */
12
+ async function executeUnitUndo(plan, sink) {
13
+ const refusals = [...plan.refusals];
14
+ const restores = [];
15
+ for (const restore of plan.restores) {
16
+ if (sink.hasArchived !== void 0) {
17
+ if (!await sink.hasArchived(restore.skill)) refusals.push(`${restore.skill}(归档成员不在 .archive)`);
18
+ else restores.push(restore);
19
+ continue;
20
+ }
21
+ restores.push(restore);
22
+ }
23
+ const prepared = [];
24
+ for (const op of plan.ops) {
25
+ const live = op.path === "" ? await sink.readSkill(op.skill) : await sink.readSupport(op.skill, op.path);
26
+ if (live === null) {
27
+ if (op.remove) continue;
28
+ if (op.expectedHash === contentHash("")) {
29
+ const bytes = op.preUnitHash === void 0 ? null : await sink.readBlob(op.preUnitHash);
30
+ if (bytes === null) {
31
+ refusals.push(`${op.skill}/${op.path === "" ? "SKILL.md" : op.path}(单元前字节读不到:blob ${op.preUnitHash ?? "(missing)"})`);
32
+ continue;
33
+ }
34
+ prepared.push({
35
+ ...op,
36
+ bytes,
37
+ live: "",
38
+ absent: true
39
+ });
40
+ continue;
41
+ }
42
+ refusals.push(`${op.skill}/${op.path === "" ? "SKILL.md" : op.path}(盘上文件不存在)`);
43
+ continue;
44
+ }
45
+ if (contentHash(live) !== op.expectedHash) {
46
+ refusals.push(`${op.skill}/${op.path === "" ? "SKILL.md" : op.path}(盘上字节已变,回退会覆盖别人的改动)`);
47
+ continue;
48
+ }
49
+ if (op.remove) {
50
+ prepared.push({
51
+ ...op,
52
+ bytes: "",
53
+ live,
54
+ absent: false
55
+ });
56
+ continue;
57
+ }
58
+ const bytes = op.preUnitHash === void 0 ? null : await sink.readBlob(op.preUnitHash);
59
+ if (bytes === null) {
60
+ refusals.push(`${op.skill}/${op.path === "" ? "SKILL.md" : op.path}(单元前字节读不到:blob ${op.preUnitHash ?? "(missing)"})`);
61
+ continue;
62
+ }
63
+ prepared.push({
64
+ ...op,
65
+ bytes,
66
+ live,
67
+ absent: false
68
+ });
69
+ }
70
+ if (refusals.length > 0) return {
71
+ ok: false,
72
+ message: `整单元撤销未开始(零写)—— 预检未通过:${refusals.join(";")}。修好后可重试。`,
73
+ reverted: []
74
+ };
75
+ const reverted = [];
76
+ const done = () => reverted.length === 0 ? "无" : reverted.join(", ");
77
+ for (const restore of restores) {
78
+ const result = await sink.restoreFromArchive(restore.skill);
79
+ if (!result.ok) return {
80
+ ok: false,
81
+ message: `恢复「${restore.skill}」失败:${result.message} —— 撤销未完成(已回退:${done()})。`,
82
+ reverted
83
+ };
84
+ reverted.push(restore.skill);
85
+ }
86
+ const supportOps = prepared.filter((op) => op.path !== "");
87
+ const bodyOps = prepared.filter((op) => op.path === "");
88
+ for (const op of supportOps) {
89
+ const result = op.remove ? await sink.removeSupportFile(op.skill, op.path, { sha256: op.expectedHash }) : op.absent ? await sink.writeSupportFile(op.skill, op.path, op.bytes) : await sink.writeSupportFile(op.skill, op.path, op.bytes, { sha256: op.expectedHash });
90
+ if (!result.ok) return {
91
+ ok: false,
92
+ message: `${op.skill}/${op.path}:${result.message} —— 撤销未完成(已回退:${done()})。`,
93
+ reverted
94
+ };
95
+ reverted.push(op.skill + "/" + op.path);
96
+ }
97
+ for (const op of bodyOps) {
98
+ const result = await sink.updateSkill(op.skill, op.bytes, { sha256: op.expectedHash });
99
+ if (!result.ok) return {
100
+ ok: false,
101
+ message: `${op.skill}/SKILL.md:${result.message} —— 撤销未完成(已回退:${done()})。`,
102
+ reverted
103
+ };
104
+ reverted.push(op.skill + "/SKILL.md");
105
+ }
106
+ for (const skill of plan.archiveTargets) {
107
+ const result = await sink.archive(skill, "merge undone");
108
+ if (!result.ok) return {
109
+ ok: false,
110
+ message: `归档新目标「${skill}」失败:${result.message} —— 撤销未完成(已回退:${done()})。`,
111
+ reverted
112
+ };
113
+ reverted.push(skill);
114
+ }
115
+ return {
116
+ ok: true,
117
+ message: `已按单元撤销:${reverted.join(", ")}。`,
118
+ reverted
119
+ };
120
+ }
121
+ //#endregion
122
+ //#region lib/types/unit-undo-plan.js
123
+ /**
124
+ * Cross-skill unit undo planner.
125
+ *
126
+ * The curator's single-skill undo already proves the rule: one path is described by
127
+ * (baseline, oldest after, newest after), and a path the unit created is removed. A merge
128
+ * unit adds two shapes:
129
+ *
130
+ * - a source that the merge ARCHIVED: undo restores it from .archive; it has no live ops;
131
+ * - a target the merge CREATED: undo archives the target (never hard-deletes it); it has no
132
+ * body op.
133
+ *
134
+ * The plan is pure; the executor resolves hashes to bytes and applies anchors. Any refusal
135
+ * means the caller writes nothing.
136
+ */
137
+ function slotsOf(entries) {
138
+ const body = {};
139
+ const support = /* @__PURE__ */ new Map();
140
+ const refusals = [];
141
+ for (const entry of entries) {
142
+ if (!(entry.path !== void 0 && entryTarget(entry, entries) === "support")) {
143
+ if (entry.action === "baseline") body.baseline ??= entry;
144
+ else {
145
+ body.oldest ??= entry;
146
+ body.newest = entry;
147
+ }
148
+ continue;
149
+ }
150
+ const path = entry.path;
151
+ const slot = support.get(path) ?? {};
152
+ support.set(path, slot);
153
+ if (entry.action === "baseline") slot.baseline ??= entry;
154
+ else {
155
+ slot.oldest ??= entry;
156
+ slot.newest = entry;
157
+ }
158
+ }
159
+ for (const [path, slot] of support) if (slot.newest === void 0) refusals.push(`${path}(单元里没有该路径的 after 条目)`);
160
+ return {
161
+ body,
162
+ support,
163
+ refusals
164
+ };
165
+ }
166
+ /** Plan one unit across a live target and any archived sources. */
167
+ function planUnitUndoAcross(members) {
168
+ const ops = [];
169
+ const restores = [];
170
+ const archiveTargets = [];
171
+ const refusals = [];
172
+ for (const member of members) {
173
+ if (member.status === "missing") {
174
+ refusals.push(`${member.skill}(成员技能不在活动树或归档里)`);
175
+ continue;
176
+ }
177
+ if (member.status === "archived") {
178
+ if (member.archivedPath === void 0 || member.archivedPath === "") {
179
+ refusals.push(`${member.skill}(归档成员缺少归档路径)`);
180
+ continue;
181
+ }
182
+ restores.push({
183
+ skill: member.skill,
184
+ archivedPath: member.archivedPath
185
+ });
186
+ continue;
187
+ }
188
+ if (member.createdInUnit === true) {
189
+ archiveTargets.push(member.skill);
190
+ continue;
191
+ }
192
+ const { body, support, refusals: slotRefusals } = slotsOf(member.entries);
193
+ refusals.push(...slotRefusals.map((reason) => member.skill + ":" + reason));
194
+ for (const [path, slot] of support) {
195
+ if (slot.newest === void 0) continue;
196
+ const removal = slot.oldest?.removed === true;
197
+ const preUnitHash = removal ? slot.oldest?.hash : slot.baseline !== void 0 ? slot.baseline.hash : slot.oldest?.beforeHash;
198
+ ops.push({
199
+ skill: member.skill,
200
+ path,
201
+ remove: !removal && preUnitHash === void 0,
202
+ ...preUnitHash === void 0 ? {} : { preUnitHash },
203
+ expectedHash: removal ? contentHash("") : slot.newest.hash
204
+ });
205
+ }
206
+ if (body.newest !== void 0) {
207
+ const preUnitHash = body.baseline !== void 0 ? body.baseline.hash : body.oldest?.beforeHash;
208
+ if (preUnitHash === void 0) refusals.push(`${member.skill}:SKILL.md 缺少单元前字节`);
209
+ else ops.push({
210
+ skill: member.skill,
211
+ path: "",
212
+ remove: false,
213
+ preUnitHash,
214
+ expectedHash: body.newest.hash
215
+ });
216
+ }
217
+ }
218
+ return {
219
+ ops,
220
+ restores,
221
+ archiveTargets,
222
+ refusals
223
+ };
224
+ }
225
+ //#endregion
226
+ //#region lib/types/unit-members.js
227
+ /** Candidate skills: head first, then `sources[]` order, DEDUPLICATED (sources may name the head). */
228
+ function candidateSkills(head) {
229
+ const out = [head.skill];
230
+ for (const source of head.sources) if (!out.includes(source.skill)) out.push(source.skill);
231
+ return out;
232
+ }
233
+ /** @param indexes - skill name -> that skill's index text, or null when the index file is absent. */
234
+ /** The `path` of one manifest move, or the empty string when the record carries no string one.
235
+ * Kept as a function so the read never stringifies an object (the linter refuses
236
+ * `String(unknown)` for exactly that reason) and every call site reads the same way. */
237
+ function movePath(move) {
238
+ const raw = move.path;
239
+ return typeof raw === "string" ? raw : "";
240
+ }
241
+ function resolveUnitMembersFromIndexes(head, indexes, readEntries) {
242
+ const members = [];
243
+ const missing = [];
244
+ for (const skill of candidateSkills(head)) {
245
+ const text = indexes.get(skill);
246
+ if (text === void 0 || text === null) {
247
+ missing.push({
248
+ skill,
249
+ reason: "index-absent"
250
+ });
251
+ continue;
252
+ }
253
+ const entries = readEntries(text).filter((entry) => entry.unitId === head.unitId);
254
+ if (entries.length === 0) {
255
+ missing.push({
256
+ skill,
257
+ reason: "unit-absent"
258
+ });
259
+ continue;
260
+ }
261
+ members.push({
262
+ skill,
263
+ entries
264
+ });
265
+ }
266
+ const conflicts = [];
267
+ const manifest = head.unitHead?.moves ?? void 0;
268
+ if (manifest !== void 0) {
269
+ const shardPaths = [];
270
+ for (const slice of members) for (const entry of slice.entries) for (const move of entry.unitHead?.moves ?? []) {
271
+ const path = movePath(move);
272
+ if (path !== "") shardPaths.push(path);
273
+ }
274
+ const wanted = manifest.map((move) => movePath(move)).filter((p) => p !== "");
275
+ for (const path of wanted) if (!shardPaths.includes(path)) conflicts.push({
276
+ kind: "missing",
277
+ path
278
+ });
279
+ for (const path of shardPaths) if (!wanted.includes(path)) conflicts.push({
280
+ kind: "foreign",
281
+ path
282
+ });
283
+ }
284
+ return {
285
+ members,
286
+ missing,
287
+ conflicts
288
+ };
289
+ }
290
+ /** A unit's members are trustworthy only when nothing is missing and nothing conflicts. */
291
+ function unitMembersAreComplete(members) {
292
+ return members.missing.length === 0 && members.conflicts.length === 0;
293
+ }
294
+ /**
295
+ * The io shell (A19.2): open ONLY the known keys -- never enumerate a directory. A skill whose index
296
+ * file is unreadable becomes `null` (index-absent), which the core then reports by name.
297
+ */
298
+ async function resolveUnitMembers(root, io, head, indexPath, readEntries) {
299
+ const indexes = /* @__PURE__ */ new Map();
300
+ for (const skill of candidateSkills(head)) {
301
+ let text = null;
302
+ try {
303
+ text = await io.readText(indexPath(root, skill));
304
+ } catch {
305
+ text = null;
306
+ }
307
+ indexes.set(skill, text);
308
+ }
309
+ return resolveUnitMembersFromIndexes(head, indexes, (raw) => readEntries(raw));
310
+ }
311
+ /** G3b: a LANDMARK carries the owning skill and no manifest (the two forms never coexist). */
312
+ function isLandmark(entry) {
313
+ const head = entry.unitHead;
314
+ return head !== void 0 && head.moves === void 0 && head.skill !== void 0;
315
+ }
316
+ /** @param entry - the entry being judged. @param ownerEntries - the owner skill's index, or null when
317
+ * the owner has no readable index. */
318
+ function landmarkVerdict(entry, ownerEntries) {
319
+ const head = entry.unitHead;
320
+ if ((isLandmark(entry) ? head?.skill : void 0) === void 0 || entry.unitId === void 0) return {
321
+ jumpable: false,
322
+ reason: "not-a-landmark"
323
+ };
324
+ if (ownerEntries === null) return {
325
+ jumpable: false,
326
+ reason: "owner-absent"
327
+ };
328
+ return ownerEntries.some((candidate) => candidate.unitId === entry.unitId) ? { jumpable: true } : {
329
+ jumpable: false,
330
+ reason: "unit-absent"
331
+ };
332
+ }
333
+ /**
334
+ * Scan a whole corpus (skill name -> index entries, or null when unreadable) for stale route stubs.
335
+ * Sorted by (skill, version, owner): a function of the corpus, not of the caller's map order.
336
+ */
337
+ function staleRouteStubs(indexes) {
338
+ const out = [];
339
+ for (const [skill, entries] of indexes) {
340
+ if (entries === null) continue;
341
+ for (const entry of entries) {
342
+ const head = entry.unitHead;
343
+ const owner = isLandmark(entry) ? head?.skill : void 0;
344
+ if (owner === void 0) continue;
345
+ const verdict = landmarkVerdict(entry, indexes.get(owner) ?? null);
346
+ if (!verdict.jumpable && verdict.reason !== "not-a-landmark") out.push({
347
+ skill,
348
+ v: entry.v,
349
+ owner,
350
+ reason: verdict.reason
351
+ });
352
+ }
353
+ }
354
+ return out.sort((a, b) => a.skill.localeCompare(b.skill) || a.v - b.v || a.owner.localeCompare(b.owner));
355
+ }
356
+ //#endregion
357
+ export { MutationUnit, UNIT_JOURNAL_PHASES, UNIT_JOURNAL_SCHEMA_VERSION, UNIT_STORAGE_SCHEMA_VERSION, WriteKernel, assertUnitJournalTransition, candidateSkills, executeUnitUndo, fileMutationLock, isLandmark, landmarkVerdict, planUnitUndoAcross, pruneTreeChangeUnits, readUnitEvidence, readUnitIndex, readUnitJournal, readUnitReceipt, readUnitSnapshot, resolveUnitMembers, resolveUnitMembersFromIndexes, staleRouteStubs, unitEvidencePath, unitIndexPath, unitJournalPath, unitJournalPhaseRank, unitJournalPort, unitMembersAreComplete, unitReceiptPath, unitSnapshotPath, unitSnapshotPort, unitSnapshotsDir, unitStorageKey, upsertUnitIndex, validateMutationRequest, writeUnitEvidence, writeUnitJournal, writeUnitReceipt, writeUnitSnapshot };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lmzhen/dsh-evolution-core",
3
3
  "description": "Shared stores, prompts, signals and lifecycle logic for the dsh-evolution plugin family (community build)",
4
- "version": "0.40.1",
4
+ "version": "0.42.0",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -42,6 +42,14 @@
42
42
  "types": "./lib/types/restrictor.d.ts",
43
43
  "default": "./lib/restrictor.js"
44
44
  },
45
+ "./write": {
46
+ "types": "./lib/types/write.d.ts",
47
+ "default": "./lib/write.js"
48
+ },
49
+ "./skills": {
50
+ "types": "./lib/types/skills.d.ts",
51
+ "default": "./lib/skills.js"
52
+ },
45
53
  "./package.json": "./package.json",
46
54
  "./row-overrides.json": "./row-overrides.json",
47
55
  "./persisted-write-inventory.json": "./persisted-write-inventory.json"
@@ -57,24 +65,27 @@
57
65
  "yaml": "^2.4.2",
58
66
  "zod": "^4.4.3",
59
67
  "js-yaml": "^4.1.0",
60
- "@lmzhen/dsh-evolution-contract": "^0.40.1"
68
+ "@lmzhen/dsh-evolution-contract": "^0.42.0"
61
69
  },
62
70
  "peerDependencies": {
63
71
  "@deepseek-ai/cordis": "^4.0.5",
64
72
  "@deepseek-ai/dsh-scope": "^0.2.2-rc.0",
65
73
  "@deepseek-ai/dsh-session": "^0.2.2-rc.0",
74
+ "@deepseek-ai/dsh-skill": "^0.2.2-rc.0",
66
75
  "@deepseek-ai/dsh-session-projection": "^0.2.2-rc.0",
67
76
  "@deepseek-ai/dsh-agent": "^0.2.2-rc.0",
68
77
  "@deepseek-ai/dsh-subagent": "^0.2.2-rc.0",
69
78
  "@deepseek-ai/dsh-tools": "^0.2.2-rc.0",
70
79
  "@deepseek-ai/dsh-commands": "^0.2.2-rc.0",
71
80
  "@deepseek-ai/dsh-llm": "^0.2.2-rc.0",
72
- "@deepseek-ai/dsh-system-prompt": "^0.2.2-rc.0"
81
+ "@deepseek-ai/dsh-system-prompt": "^0.2.2-rc.0",
82
+ "@deepseek-ai/dsh-storage-domain": "^0.2.2-rc.0"
73
83
  },
74
84
  "devDependencies": {
75
85
  "@deepseek-ai/cordis": "^4.0.5",
76
86
  "@deepseek-ai/dsh-scope": "^0.2.2-rc.0",
77
87
  "@deepseek-ai/dsh-session": "^0.2.2-rc.0",
88
+ "@deepseek-ai/dsh-skill": "^0.2.2-rc.0",
78
89
  "@deepseek-ai/dsh-session-projection": "^0.2.2-rc.0",
79
90
  "@deepseek-ai/dsh-agent": "^0.2.2-rc.0",
80
91
  "@deepseek-ai/dsh-subagent": "^0.2.2-rc.0",
@@ -83,7 +94,8 @@
83
94
  "js-yaml": "^4.1.0",
84
95
  "@deepseek-ai/dsh-commands": "^0.2.2-rc.0",
85
96
  "@deepseek-ai/dsh-llm": "^0.2.2-rc.0",
86
- "@deepseek-ai/dsh-system-prompt": "^0.2.2-rc.0"
97
+ "@deepseek-ai/dsh-system-prompt": "^0.2.2-rc.0",
98
+ "@deepseek-ai/dsh-storage-domain": "^0.2.2-rc.0"
87
99
  },
88
100
  "engines": {
89
101
  "dsh": ">=0.2.2-rc.0 <0.2.3-0"
@@ -1,58 +0,0 @@
1
- //#region lib/types/errors.js
2
- /**
3
- * THE error-code table: E-301…E-325 with the exact text each one emits (E-317…E-319 are the
4
- * write-admission gates' own refusals).
5
- *
6
- * The codes used to be spelled out at 33 call sites across two packages, so one
7
- * code's wording could drift between the branches that answer it and nothing could
8
- * see the drift. Keys name the SCENARIO rather than the code, because a code
9
- * legitimately carries more than one text (E-301 answers pending / approve / reject
10
- * with different guidance); the code still leads every string, so model- and
11
- * user-facing output is unchanged. Interpolations are written `%aN%` and filled by
12
- * `errorText` from the values the call site used to interpolate inline.
13
- * @module @lmzhen/dsh-evolution-core
14
- */
15
- const EVOLUTION_ERRORS = Object.freeze({
16
- "e-305-this-invocation-carries-no": "E-305: 本次调用没有携带 agent —— `%a1%` 需要由会话支撑的调用(请在 GUI 或 CLI 的会话里运行)。",
17
- "e-306-this-deployment-stages-foreground": "E-306: 本部署会暂存前台写入,但 `/evolution %a1%` 无法通过技能运行器回放 —— 没有可暂存的内容。请在批准策略为 'never' 的会话里运行,或在 evolution-approval 行上设置 `stageForeground: false`,然后重试该命令。",
18
- "e-301-approval-service-not-mounted": "E-301: 批准服务未挂载:待批准写入无法列出或回放。挂载 evolution-approval 行(随 evolution-host/evolution-all 提供)后,运行 /evolution doctor 可查看已挂载的服务。",
19
- "e-301-approval-service-not-mounted-2": "E-301: 批准服务未挂载。下一步:evolution-approval 行随 evolution-host/evolution-all 一起提供 —— 运行 /evolution doctor 查看已挂载的服务。",
20
- "e-304-the-mounted-approval-service": "E-304: 已挂载的批准服务早于本能力发布 —— 请改为驳回该记录。",
21
- "e-302-curator-service-not-mounted": "E-302: 策展服务未挂载。下一步:挂载 evolution-curator 行(evolution-host/evolution-all),并运行 /evolution doctor。",
22
- "e-305-the-invocation-agent-exposes": "E-305: 调用 agent 既没有暴露 `followup` 也没有 `inject` —— %a1% 没有投递通道。",
23
- "e-306-this-deployment-stages-foreground-2": "E-306: 本部署会暂存前台写入,但本次调用没有 agent 会话 —— `/evolution restructure` 会暂存一条没有会话归属的记录。请在 GUI 或 CLI 的会话里运行,或在 `stageForeground: false` 行上设置,然后重试该命令。",
24
- "e-303-replay-service-not-mounted": "E-303: 回放服务未挂载。下一步:挂载 evolution-replay 行(evolution-host/evolution-all),并运行 /evolution doctor。",
25
- "e-307-the-settings-service-could": "E-307: 设置服务无法报告它的分区(%a1%)。/evolution params 需要用户层来区分覆盖值与部署值;运行 /evolution doctor 查看已挂载的服务。",
26
- "e-308-unknown-parameter-group-group": "E-308: 未知的参数分组「%a1%」—— 已知分组:%a2%。",
27
- "e-311-no-settings-service-is": "E-311: 没有挂载设置服务,因此没有可写入的用户层。请挂载 settings 行(packages/settings/settings-file)后重试;本命令从不修改 cordis.yml —— 部署值属于部署。/evolution doctor 会列出已挂载的服务。",
28
- "e-312-error-instanceof-Error-error": "E-312: %a1% —— /evolution params 会列出规范 id。",
29
- "e-313-unknown-parameter-id-evolution": "E-313: 未知参数「%a1%」—— /evolution params 会列出每个已注册 id 及其层级与用户层。",
30
- "e-314-id-is-a-deployment": "E-314: 「%a1%」是部署参数(层级 %a2%,归属 %a3%)—— 它写在 cordis.yml 的插件行或策略行上,而不是从会话写入。/evolution params 会显示每一行由谁可写。",
31
- "e-315-id-has-no-user": "E-315: 「%a1%」没有用户层 —— 归属 %a2% 没有发布设置命名空间,因此该值留在部署层。",
32
- "e-307-the-settings-service-could-2": "E-307: 设置服务无法报告它的分区(%a1%)。/evolution policy set 需要当前修订号才能安全写入;运行 /evolution doctor 查看已挂载的服务。",
33
- "e-316-namespace-namespace-is-not": "E-316: namespace \"%a1%\" 未注册 —— 归属 %a2% 在本组合中未挂载,因此无法从这里写入它的参数。 /evolution params 会把那些行标为 'unregistered'.",
34
- "e-309-revision-conflict-you-sent": "E-309: 修订冲突 —— 你提交的是 %a1%,文档当前为 %a2%。请用 /evolution params --json 重新读取后重试。",
35
- "e-309-revision-conflict-message-Re": "E-309: 修订冲突 —— %a1%。请用 /evolution params --json 重新读取后重试。",
36
- "e-310-the-settings-service-refused": "E-310: 设置服务拒绝了这次写入:%a1% —— 归属插件的规则优先(跨字段成对约束,或只能收紧的上限)。/evolution params 会显示当前值。",
37
- "e-317-skill-write-not-confirmed": "E-317: 技能 \"%a1%\" 未被%a2% —— 确认提示被拒绝或关闭,因此没有写入任何内容。每次创建与裸删除都会出现该提示;只有操作者要求时才重复调用。",
38
- "e-318-skill-write-without-a-read": "E-318: 本会话没有读取技能 \"%a1%\",因此拒绝这次写入。请先用 `skill` 工具读取它(失败的读取不算),然后重复该写入。",
39
- "e-326-support-write-without-a-read": "E-326: 本会话没有读取技能 \"%a1%\" 的支撑文件 \"%a2%\",因此拒绝这次写入。只读技能正文不算读过支撑文件;请先读取该文件(失败的读取不算),然后重复该写入。",
40
- "e-320-the-profile-home-is-not": "E-320: 本宿主没有报告 profile home,因此无法定位旧设置文档。/evolution migrate 读取 `<profile home>/settings.yaml.imported`;请在由 profile 启动的会话里运行。",
41
- "e-322-a-parameter-would-break-a": "E-322: %a1% 至少应为 %a2%,但这次写入把它设成 %a3%。未写入任何内容。",
42
- "e-321-no-io-provider-is": "E-321: 缺少数据读写组件 evolution-io,暂时读不到旧设置。请安装或启用 evolution-io 后重试。",
43
- "e-319-skill-write-confirm-timed-out": "E-319: 技能 \"%a1%\" 未被%a2% —— 确认提示在 %a3% 秒内无人应答,因此该写入被取消。没有人在场决定:把 `skillWriteConfirm` 设为 `auto` 可免提示直接写入,保留 `ask` 则一直等到有人应答,或提高 `skillWriteConfirmTimeoutSeconds`。",
44
- "e-323-subagent-channel-unavailable": "E-323: 审阅/维护代理不可用:程序缺少 subagents/agentPresets 服务,或当前运行方式不支持只读代理。审阅/维护会明确标为不可用,不会静默改在当前会话里跑。运行 /evolution doctor 查看原因。",
45
- "e-324-restricted-preset-unavailable": "E-324: 只读模式创建失败:%a1%。审阅/维护暂时不可用;运行 /evolution doctor 查看原因。",
46
- "e-325-host-data-plane-unavailable": "E-325: 页面拿不到平台连接(缺少 connection 服务),面板与审批不会注册。可改用 /evolution pending、approve、reject 命令完成同样的事;详情见 /evolution doctor。"
47
- });
48
- /**
49
- * Render one table entry, substituting its interpolation slots.
50
- * @param id - the scenario key.
51
- * @param args - values for the entry's `%aN%` slots.
52
- * @returns the message text the call site used to spell out inline.
53
- */
54
- function errorText(id, args = {}) {
55
- return EVOLUTION_ERRORS[id].replace(/%a(\d+)%/g, (_match, n) => String(args["a" + n] ?? ""));
56
- }
57
- //#endregion
58
- export { errorText as n, EVOLUTION_ERRORS as t };