@lmzhen/dsh-evolution-core 0.39.1 → 0.40.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 +3611 -3274
- package/lib/platform/index.js +2 -2
- package/lib/{platform-Be-_wSVz.js → platform-CFp373_0.js} +3 -1
- package/lib/runtime/plugin.js +1 -1
- package/lib/types/events.d.ts +1 -1
- package/lib/types/evolution-events.d.ts +3 -1
- package/lib/types/evolution-events.js +65 -59
- package/lib/types/home-fence.d.ts +24 -0
- package/lib/types/home-fence.js +62 -0
- package/lib/types/home-owner.d.ts +4 -0
- package/lib/types/home-owner.js +37 -0
- package/lib/types/index.d.ts +4 -0
- package/lib/types/index.js +4 -0
- package/lib/types/lease-store.d.ts +55 -0
- package/lib/types/lease-store.js +116 -0
- package/lib/types/memory-store.d.ts +6 -0
- package/lib/types/memory-store.js +16 -8
- package/lib/types/mutation-authority.d.ts +59 -0
- package/lib/types/mutation-authority.js +126 -0
- package/lib/types/mutation-storage-adapter.js +7 -3
- package/lib/types/mutation-unit.d.ts +13 -0
- package/lib/types/mutation-unit.js +7 -2
- package/lib/types/mutations.d.ts +3 -1
- package/lib/types/mutations.js +40 -34
- package/lib/types/platform/index.d.ts +5 -2
- package/lib/types/platform/index.js +2 -0
- package/lib/types/platform-services.js +1 -0
- package/lib/types/prompts.d.ts +13 -19
- package/lib/types/prompts.js +59 -157
- package/lib/types/proposal-report.d.ts +1 -0
- package/lib/types/proposal-report.js +12 -0
- package/lib/types/run-registry.d.ts +4 -0
- package/lib/types/run-registry.js +10 -3
- package/lib/types/skill-history.d.ts +4 -1
- package/lib/types/skill-history.js +24 -29
- package/lib/types/skill-store.d.ts +11 -3
- package/lib/types/skill-store.js +26 -12
- package/lib/types/unit-storage.d.ts +2 -0
- package/lib/types/unit-transaction.d.ts +6 -1
- package/lib/types/unit-transaction.js +20 -6
- package/lib/types/usage.d.ts +4 -0
- package/lib/types/usage.js +84 -78
- package/package.json +2 -2
- package/persisted-write-inventory.json +9 -0
package/lib/types/prompts.js
CHANGED
|
@@ -26,114 +26,79 @@ import { createHash } from 'node:crypto';
|
|
|
26
26
|
* changes semantically: the bundle digest is the fail-closed signal for
|
|
27
27
|
* review workers, so a stale id across deployments must be distinguishable.
|
|
28
28
|
*/
|
|
29
|
-
export const PROMPT_BUNDLE_VERSION =
|
|
29
|
+
export const PROMPT_BUNDLE_VERSION = 27;
|
|
30
30
|
// 0.3.16 (S1.12, T-5): the id is DERIVED from the version — a one-number bump
|
|
31
31
|
// can no longer drift the two apart.
|
|
32
32
|
export const PROMPT_BUNDLE_ID = `dsh-evolution@${PROMPT_BUNDLE_VERSION}`;
|
|
33
|
-
|
|
34
|
-
Review the conversation above and consider saving to memory if appropriate.
|
|
33
|
+
const MEMORY_REVIEW_BODY = `Focus on durable facts that change future collaboration:
|
|
35
34
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
2. Has the user expressed expectations about how you should behave, their work style, or ways they want you to operate?
|
|
35
|
+
1. The user: role, context, stable preferences, constraints, and facts they would want remembered.
|
|
36
|
+
2. The work: how deliverables should be judged across future tasks — quality bar, format, sources/tools, and collaboration conventions.
|
|
39
37
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
Review the conversation above and update the skill library.
|
|
38
|
+
Do not store task progress or reusable procedures; procedures belong in skills.
|
|
39
|
+
Prefer merging or replacing an existing entry over adding a near-duplicate.
|
|
40
|
+
Keep the entry compact.`;
|
|
41
|
+
const SKILL_REVIEW_BODY = `Review the conversation above and update the skill library.
|
|
44
42
|
|
|
45
|
-
|
|
43
|
+
Update only when the session contains a durable lesson that changes how this class of task should be done. A precise no-op is a valid outcome.
|
|
46
44
|
|
|
47
|
-
|
|
45
|
+
Target: a class-level skill with a compact SKILL.md and a references/ directory for session-specific detail.
|
|
48
46
|
|
|
49
|
-
|
|
50
|
-
• User corrected your style, tone, format, legibility, or verbosity. Frustration signals like 'stop doing X', 'this is too verbose', 'don't format like this', 'why are you explaining', 'just give me the answer', 'you always do Y and I hate it', or an explicit 'remember this' are FIRST-CLASS skill signals, not just memory signals. Update the relevant skill(s) to embed the preference so the next session starts already knowing.
|
|
51
|
-
• User corrected your workflow, approach, or sequence of steps. Encode the correction as a pitfall or explicit step in the skill that governs that class of task.
|
|
52
|
-
• Non-trivial technique, fix, workaround, debugging path, or tool-usage pattern emerged that a future session would benefit from. Capture it.
|
|
53
|
-
• A skill that got loaded or consulted this session turned out to be wrong, missing a step, or outdated. Patch it NOW.
|
|
47
|
+
A skill body contains reusable decisions: when to use it, what to do, and how to verify. Session-specific narratives, dated logs, one-off evidence, and version details that do not change the decision belong in references/. Support files: references/ for detail or knowledge banks; templates/ for starter files; scripts/ for re-runnable checks and generators. When you add a support file, add the SKILL.md line that points to it; a file no pointer reaches is invisible next session. A skill must use only tools, commands, and paths available in this session. If one is unavailable, replace it only with a verified local equivalent; otherwise leave it unchanged and report the limitation. Do not invent command names.
|
|
54
48
|
|
|
55
|
-
|
|
49
|
+
Signals include:
|
|
50
|
+
- The user corrected style, tone, format, verbosity, workflow, or approach.
|
|
51
|
+
- A reusable technique, durable interface or environment fact, repair procedure, or debugging path emerged that will recur.
|
|
52
|
+
- A loaded skill proved wrong, incomplete, or outdated.
|
|
56
53
|
|
|
57
|
-
|
|
58
|
-
1. UPDATE A CURRENTLY-LOADED SKILL. Look back through the conversation for skills the user loaded or you read. If any of them covers the territory of the new learning, PATCH that one first. It is the skill that was in play, so it's the right one to extend.
|
|
59
|
-
2. UPDATE AN EXISTING UMBRELLA. If no loaded skill fits but an existing class-level skill does, patch it. Add a subsection, a pitfall, or broaden a trigger.
|
|
60
|
-
3. ADD A SUPPORT FILE under an existing umbrella. Skills can be packaged with three kinds of support files — use the right directory per kind:
|
|
61
|
-
• references/<topic>.md — session-specific detail (error transcripts, reproduction recipes, provider quirks) AND condensed knowledge banks: quoted research, API docs, external authoritative excerpts, or domain notes you found while working on the problem. Write it concise and for the value of the task, not as a full mirror of upstream docs.
|
|
62
|
-
• templates/<name>.<ext> — starter files meant to be copied and modified (boilerplate configs, scaffolding, a known-good example the agent can reproduce with modifications).
|
|
63
|
-
• scripts/<name>.<ext> — statically re-runnable actions the skill can invoke directly (verification scripts, fixture generators, deterministic probes, anything the agent should run rather than hand-type each time).
|
|
64
|
-
Add support files via skill_manage action=write_file with file_path starting 'references/', 'templates/', or 'scripts/'. The umbrella's SKILL.md should gain a one-line pointer to any new support file so future agents know it exists.
|
|
65
|
-
4. RESTRUCTURE a loaded skill whose body grew log-like — rc/sha/date-dense sections, session-detail spirals, or a fat body with no support files. Use skill_manage action=restructure with restructure: [{"heading": "<the exact ## heading text>", "to_file": "references/<topic>.md"}] — the ENTIRE ## section (from that heading to the next heading) moves into the support file and its position becomes a pointer line. The skill's name and directory never change. Only propose headings that exist verbatim in the body; never invent one, and never restructure a healthy small skill.
|
|
66
|
-
5. CREATE A NEW CLASS-LEVEL UMBRELLA SKILL only when no existing class-level skill covers the class and no existing umbrella can absorb the learning. The name MUST be at the class level. The name MUST NOT be a specific PR number, error string, feature codename, library-alone name, or 'fix-X / debug-Y / audit-Z-today' session artifact. If the proposed name only makes sense for today's task, it's wrong — fall back to (1), (2), or (3).
|
|
54
|
+
Any one of these warrants a decision; it does not by itself require a write.
|
|
67
55
|
|
|
68
|
-
|
|
56
|
+
Read before writing. Update only skills whose body you have read in this review pass. A new skill has no body to read; before choosing, search the existing library with the available skill tools.
|
|
69
57
|
|
|
70
|
-
|
|
58
|
+
Update when an existing class-level owner shares the lesson's trigger and audience.
|
|
71
59
|
|
|
72
|
-
|
|
73
|
-
• PATTERN (reusable — symptom → mechanism → fix → verification, still valuable next session) belongs in the SKILL.md body.
|
|
74
|
-
• LOG (one-off — commit SHAs, npm/profile states, what this release changed, this session's process narrative) belongs in a references/ file, never the body. Body density IS reuse rate. Keep new entries tight: a pattern fits in 2-8 physical lines; prefer changing the current-state pointer over appending history.
|
|
60
|
+
Create a new class-level skill when the lesson has a distinct trigger or audience and would make that owner heterogeneous. A class-level skill can serve at least two different future events; if the lesson serves only this incident, fold it into an existing owner's body or support file.
|
|
75
61
|
|
|
76
|
-
|
|
77
|
-
• Bundled skills (shipped with the platform).
|
|
78
|
-
• Hub-installed skills (installed from a hub).
|
|
79
|
-
Pinned skills are read-only to THIS background review pass — the pinned write guard refuses background changes, so this pass may not update them. They also cannot be archived by any writer (the foreground included): remove the .pinned marker first. Foreground and delegated-subagent update/patch writes to pinned skills remain allowed.
|
|
80
|
-
If the only skills that need updating are protected, say 'Nothing to save.' and stop.
|
|
62
|
+
When only session-specific detail changes, add a support file under the owner.
|
|
81
63
|
|
|
82
|
-
|
|
83
|
-
• Environment-dependent failures: missing binaries, fresh-install errors, post-migration path mismatches, 'command not found', unconfigured credentials, uninstalled packages. The user can fix these — they are not durable rules.
|
|
84
|
-
• Negative claims about tools or features ('browser tools do not work', 'X tool is broken', 'cannot use Y'). These harden into refusals the agent cites against itself for months after the actual problem was fixed.
|
|
85
|
-
• Session-specific transient errors that resolved before the conversation ended. If retrying worked, the lesson is the retry pattern, not the original failure.
|
|
86
|
-
• One-off task narratives. A user asking 'summarize today's market' or 'analyze this PR' is not a class of work that warrants a skill.
|
|
64
|
+
Name a new skill for its class, not for a PR number, error string, feature codename, or session artifact.
|
|
87
65
|
|
|
88
|
-
|
|
66
|
+
A user correction about how a class of task should be done belongs in the skill that governs that task.
|
|
89
67
|
|
|
90
|
-
|
|
91
|
-
export const COMBINED_REVIEW_PROMPT = `[Auto-review]
|
|
92
|
-
Review the conversation above and update two things:
|
|
68
|
+
Leave consolidation to the curator; focus this pass on the smallest edit that carries the session's lesson.
|
|
93
69
|
|
|
94
|
-
|
|
70
|
+
A one-off environment failure, transient error, or "tool X is broken" claim is not a lesson. Capture only a reproducible setup or repair procedure that will recur.
|
|
95
71
|
|
|
96
|
-
|
|
72
|
+
Write skills only through skill_manage. If its guard refuses a write, report the refusal and do not work around it. Respect protected skills (bundled, hub-installed, pinned) and their guards. If a lesson can only live in a protected skill, report it and leave that lesson unapplied; continue with any other lessons. Do not create a near-duplicate to hold it.`;
|
|
73
|
+
const COMBINED_REVIEW_BODY = `[Auto-review]
|
|
74
|
+
Apply both review passes below.
|
|
97
75
|
|
|
98
|
-
|
|
76
|
+
## Memory
|
|
77
|
+
${MEMORY_REVIEW_BODY}
|
|
78
|
+
After the memory pass, continue to the Skills pass. If nothing is worth saving, say "Nothing to save (memory)."
|
|
99
79
|
|
|
100
|
-
|
|
80
|
+
## Skills
|
|
81
|
+
${SKILL_REVIEW_BODY}`;
|
|
82
|
+
export const INJECT_MEMORY_REVIEW_PROMPT = `[Auto-review — Memory]
|
|
83
|
+
${MEMORY_REVIEW_BODY}
|
|
101
84
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
• A skill that was loaded or consulted turned out wrong, missing, or outdated — patch it now.
|
|
85
|
+
If nothing is worth saving, say "Nothing to save." and stop.`;
|
|
86
|
+
export const INJECT_SKILL_REVIEW_PROMPT = `[Auto-review — Skills]
|
|
87
|
+
${SKILL_REVIEW_BODY}
|
|
106
88
|
|
|
107
|
-
|
|
89
|
+
If nothing durable exists, say "Nothing to save." and stop.`;
|
|
90
|
+
export const INJECT_COMBINED_REVIEW_PROMPT = `${COMBINED_REVIEW_BODY}
|
|
108
91
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
3. ADD A SUPPORT FILE under an existing umbrella via skill_manage action=write_file. Three kinds: references/<topic>.md for session-specific detail OR condensed knowledge banks (quoted research, API docs excerpts, domain notes) written concise and task-focused; templates/<name>.<ext> for starter files meant to be copied and modified; scripts/<name>.<ext> for statically re-runnable actions (verification, fixture generators, probes). Add a one-line pointer in SKILL.md so future agents find them.
|
|
113
|
-
4. RESTRUCTURE a loaded skill whose body grew log-like (rc/sha/date-dense sections, session-detail spirals, fat body with no support files) via skill_manage action=restructure with restructure: [{"heading": "<the exact ## heading text>", "to_file": "references/<topic>.md"}] — the ENTIRE ## section moves into the support file and its position becomes a pointer line; the skill's name and directory never change. Only propose headings that exist verbatim in the body.
|
|
114
|
-
5. CREATE A NEW CLASS-LEVEL UMBRELLA only when no existing class-level skill covers the class and no existing umbrella can absorb the learning. Name at the class level — NOT a PR number, error string, codename, library-alone name, or 'fix-X / debug-Y' session artifact. If the name only fits today's task, fall back to (1), (2), or (3).
|
|
92
|
+
If nothing durable exists in either pass, say "Nothing to save." and stop.`;
|
|
93
|
+
export const INJECT_COMPLETION_SKILL_REVIEW_PROMPT = `[Auto-review — Skills · task complete]
|
|
94
|
+
${SKILL_REVIEW_BODY}
|
|
115
95
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
Protected skills (DO NOT edit these):
|
|
123
|
-
• Bundled skills (shipped with the platform).
|
|
124
|
-
• Hub-installed skills (installed from a hub).
|
|
125
|
-
Pinned skills are read-only to THIS background review pass — the pinned write guard refuses background changes, so this pass may not update them. They also cannot be archived by any writer (the foreground included): remove the .pinned marker first. Foreground and delegated-subagent update/patch writes to pinned skills remain allowed.
|
|
126
|
-
If the only skills that need updating are protected, say 'Nothing to save.' and stop.
|
|
127
|
-
|
|
128
|
-
Do NOT capture as skills (these become persistent self-imposed constraints that bite you later when the environment changes):
|
|
129
|
-
• Environment-dependent failures: missing binaries, fresh-install errors, post-migration path mismatches, 'command not found', unconfigured credentials, uninstalled packages. The user can fix these — they are not durable rules.
|
|
130
|
-
• Negative claims about tools or features ('browser tools do not work', 'X tool is broken', 'cannot use Y'). These harden into refusals the agent cites against itself for months after the actual problem was fixed.
|
|
131
|
-
• Session-specific transient errors that resolved before the conversation ended. If retrying worked, the lesson is the retry pattern, not the original failure.
|
|
132
|
-
• One-off task narratives. A user asking 'summarize today's market' or 'analyze this PR' is not a class of work that warrants a skill.
|
|
133
|
-
|
|
134
|
-
If a tool failed because of setup state, capture the FIX (install command, config step, env var to set) under an existing setup or troubleshooting skill — never 'this tool does not work' as a standalone constraint.
|
|
135
|
-
|
|
136
|
-
Act on whichever of the two dimensions has real signal. If genuinely nothing stands out on either, say 'Nothing to save.' and stop — but don't reach for that conclusion as a default.`;
|
|
96
|
+
If nothing durable exists, say "Nothing to save." and stop.`;
|
|
97
|
+
// Inject aliases kept for the foreground delivery path and existing imports.
|
|
98
|
+
export const MEMORY_REVIEW_PROMPT = INJECT_MEMORY_REVIEW_PROMPT;
|
|
99
|
+
export const SKILL_REVIEW_PROMPT = INJECT_SKILL_REVIEW_PROMPT;
|
|
100
|
+
export const COMBINED_REVIEW_PROMPT = INJECT_COMBINED_REVIEW_PROMPT;
|
|
101
|
+
export const COMPLETION_SKILL_REVIEW_PROMPT = INJECT_COMPLETION_SKILL_REVIEW_PROMPT;
|
|
137
102
|
export const CURATOR_PROMPT = `You are the skill curator. Maintain a healthy, class-level skill library, not a flat pile of narrow one-session skills.
|
|
138
103
|
|
|
139
104
|
This is an UMBRELLA-BUILDING consolidation pass, not a passive audit and not a duplicate-finder.
|
|
@@ -197,56 +162,6 @@ This is a PREVIEW pass. Follow every instruction above EXCEPT:
|
|
|
197
162
|
Your output IS the deliverable: produce the exact same human-readable summary and YAML block you would on a live run, describing the actions you WOULD take. A reviewer will decide whether to approve a live run.
|
|
198
163
|
|
|
199
164
|
If you accidentally take a mutating action, say so explicitly in the summary.`;
|
|
200
|
-
export const COMPLETION_SKILL_REVIEW_PROMPT = `[Auto-review — Skills · task complete]
|
|
201
|
-
Review the conversation above and update the skill library. Be ACTIVE — inspect the session and the existing library thoroughly, and prefer a small, precise update when the session teaches something durable. Activity is not a quota: a precise no-op after checking is better than a vague or forced entry.
|
|
202
|
-
|
|
203
|
-
Target shape of the library: CLASS-LEVEL skills, each with a rich SKILL.md and a \`references/\` directory for session-specific detail. Not a long flat list of narrow one-session-one-skill entries. This shapes HOW you update, not WHETHER you update.
|
|
204
|
-
|
|
205
|
-
A skill body is a reusable decision rule (when / do / check); dates, versions, incident narratives, and one-off evidence belong in references when they would otherwise dominate the body.
|
|
206
|
-
|
|
207
|
-
Signals to look for (any one of these warrants action):
|
|
208
|
-
• User corrected your style, tone, format, legibility, or verbosity. Frustration signals like 'stop doing X', 'this is too verbose', 'don't format like this', 'why are you explaining', 'just give me the answer', 'you always do Y and I hate it', or an explicit 'remember this' are FIRST-CLASS skill signals, not just memory signals. Update the relevant skill(s) to embed the preference so the next session starts already knowing.
|
|
209
|
-
• User corrected your workflow, approach, or sequence of steps. Encode the correction as a pitfall or explicit step in the skill that governs that class of task.
|
|
210
|
-
• Non-trivial technique, fix, workaround, debugging path, or tool-usage pattern emerged that a future session would benefit from. Capture it.
|
|
211
|
-
• A skill that got loaded or consulted this session turned out to be wrong, missing a step, or outdated. Patch it NOW.
|
|
212
|
-
|
|
213
|
-
Preference order — prefer the earliest action that fits, but do pick one when a signal above fired:
|
|
214
|
-
1. UPDATE A CURRENTLY-LOADED SKILL. Look back through the conversation for skills the user loaded via /skill-name or you read via skill. If any of them covers the territory of the new learning, PATCH that one first. It is the skill that was in play, so it's the right one to extend.
|
|
215
|
-
2. UPDATE AN EXISTING UMBRELLA (via the skill catalog + skill). If no loaded skill fits but an existing class-level skill does, patch it. Add a subsection, a pitfall, or broaden a trigger.
|
|
216
|
-
3. ADD A SUPPORT FILE under an existing umbrella. Skills can be packaged with three kinds of support files — use the right directory per kind:
|
|
217
|
-
• \`references/<topic>.md\` — session-specific detail (error transcripts, reproduction recipes, provider quirks) AND condensed knowledge banks: quoted research, API docs, external authoritative excerpts, or domain notes you found while working on the problem. Write it concise and for the value of the task, not as a full mirror of upstream docs.
|
|
218
|
-
• \`templates/<name>.<ext>\` — starter files meant to be copied and modified (boilerplate configs, scaffolding, a known-good example the agent can \`reproduce with modifications\`).
|
|
219
|
-
• \`scripts/<name>.<ext>\` — statically re-runnable actions the skill can invoke directly (verification scripts, fixture generators, deterministic probes, anything the agent should run rather than hand-type each time).
|
|
220
|
-
Add support files via skill_manage action=write_file with file_path starting 'references/', 'templates/', or 'scripts/'. The umbrella's SKILL.md should gain a one-line pointer to any new support file so future agents know it exists.
|
|
221
|
-
4. CREATE A NEW CLASS-LEVEL UMBRELLA SKILL only when no existing class-level skill covers the class and no existing umbrella can absorb the learning. The name MUST be at the class level. The name MUST NOT be a specific PR number, error string, feature codename, library-alone name, or 'fix-X / debug-Y / audit-Z-today' session artifact. If the proposed name only makes sense for today's task, it's wrong — fall back to (1), (2), or (3).
|
|
222
|
-
|
|
223
|
-
User-preference embedding (important): when the user expressed a style/format/workflow preference, the update belongs in the SKILL.md body, not just in memory. Memory captures 'who the user is and what the current situation and state of your operations are'; skills capture 'how to do this class of task for this user'. When they complain about how you handled a task, the skill that governs that task needs to carry the lesson.
|
|
224
|
-
|
|
225
|
-
If you notice two existing skills that overlap, note it in your reply — the background curator handles consolidation at scale.
|
|
226
|
-
|
|
227
|
-
Protected skills (DO NOT edit these):
|
|
228
|
-
• Bundled skills (shipped with the platform).
|
|
229
|
-
• Hub-installed skills (installed via the platform hub).
|
|
230
|
-
Pinned skills (marked via skill_manage pin) are read-only to THIS background review pass — the pinned write guard refuses background changes, so this pass may not update them. They also cannot be archived by any writer (the foreground included): remove the .pinned marker first. Foreground and delegated-subagent update/patch writes to pinned skills remain allowed.
|
|
231
|
-
If the only skills that need updating are protected, say
|
|
232
|
-
'Nothing to save.' and stop.
|
|
233
|
-
|
|
234
|
-
Do NOT capture (these become persistent self-imposed constraints that bite you later when the environment changes):
|
|
235
|
-
• Environment-dependent failures: missing binaries, fresh-install errors, post-migration path mismatches, 'command not found', unconfigured credentials, uninstalled packages. The user can fix these — they are not durable rules.
|
|
236
|
-
• Negative claims about tools or features ('browser tools do not work', 'X tool is broken', 'cannot use Y from execute_code'). These harden into refusals the agent cites against itself for months after the actual problem was fixed.
|
|
237
|
-
• Session-specific transient errors that resolved before the conversation ended. If retrying worked, the lesson is the retry pattern, not the original failure.
|
|
238
|
-
• One-off task narratives. A user asking 'summarize today's market' or 'analyze this PR' is not a class of work that warrants a skill.
|
|
239
|
-
|
|
240
|
-
If a tool failed because of setup state, capture the FIX (install command, config step, env var to set) under an existing setup or troubleshooting skill — never 'this tool does not work' as a standalone constraint.
|
|
241
|
-
|
|
242
|
-
'Nothing to save.' is a real option but should NOT be the default. If the session ran smoothly with no corrections and produced no new technique, state what you checked and stop. Otherwise, act.`;
|
|
243
|
-
/**
|
|
244
|
-
* Maintenance-subagent persona (design 011 §6). Constants pin the persona
|
|
245
|
-
* with `{signal:id}` placeholders; the renderer substitutes names from the
|
|
246
|
-
* drift-signals module (single vocabulary). The model-facing contract is the
|
|
247
|
-
* persona + the mechanical-facts block; the signature head lets the model
|
|
248
|
-
* compare the two heads (011 mismatch protocol).
|
|
249
|
-
*/
|
|
250
165
|
export const MAINTAIN_PROMPT = `<<<MAINTAIN_PROMPT v={bundle_version} sig={joint_signature}>>>
|
|
251
166
|
|
|
252
167
|
## 角色
|
|
@@ -340,27 +255,16 @@ export const MAINTAIN_OUTPUT_INSTRUCTION = '按模板契约输出 JSON 维护计
|
|
|
340
255
|
* model to save/repair skills on its own initiative.
|
|
341
256
|
*/
|
|
342
257
|
export const SKILLS_GUIDANCE = `Skills guidance:
|
|
343
|
-
• After
|
|
258
|
+
• After a complex task (5+ tool calls), a tricky fix, or a non-trivial workflow, decide whether an existing owner should be updated or a new class-level skill is needed; search the library before creating.
|
|
344
259
|
• When using a skill and finding it outdated, incomplete, or wrong, patch it immediately with skill_manage (action='patch') — don't wait to be asked. Skills that aren't maintained become liabilities.`;
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
/** Subagent-channel variant: same review policy, channel-limited deliverable (M-2). */
|
|
349
|
-
export const SKILL_REVIEW_PLAN_PROMPT = `${SKILL_REVIEW_PROMPT}${PLAN_CHANNEL_NOTE}`;
|
|
350
|
-
/** Subagent-channel variant of the combined review (M-2). */
|
|
351
|
-
export const COMBINED_REVIEW_PLAN_PROMPT = `${COMBINED_REVIEW_PROMPT}${PLAN_CHANNEL_NOTE}`;
|
|
352
|
-
export function reviewPrompt(kind, channel = 'agent') {
|
|
353
|
-
// 0.3.16 (E-48): kind==='memory' + channel==='plan' used to fall through to
|
|
354
|
-
// MEMORY_REVIEW_PROMPT (the agent-channel prompt whose guidance tells the
|
|
355
|
-
// model to use the memory TOOL) while the plan channel has no memory tool —
|
|
356
|
-
// a silent wrong-channel contract. The plan channel is never memory-only.
|
|
357
|
-
if (channel === 'plan')
|
|
358
|
-
return kind === 'skill' ? SKILL_REVIEW_PLAN_PROMPT : COMBINED_REVIEW_PLAN_PROMPT;
|
|
260
|
+
export function reviewPrompt(kind, surface = 'inject') {
|
|
261
|
+
if (surface === 'aux')
|
|
262
|
+
return kind === 'memory' ? INJECT_MEMORY_REVIEW_PROMPT : INJECT_COMBINED_REVIEW_PROMPT;
|
|
359
263
|
if (kind === 'memory')
|
|
360
|
-
return
|
|
264
|
+
return INJECT_MEMORY_REVIEW_PROMPT;
|
|
361
265
|
if (kind === 'skill')
|
|
362
|
-
return
|
|
363
|
-
return
|
|
266
|
+
return INJECT_SKILL_REVIEW_PROMPT;
|
|
267
|
+
return INJECT_COMBINED_REVIEW_PROMPT;
|
|
364
268
|
}
|
|
365
269
|
function sha256(text) {
|
|
366
270
|
return createHash('sha256').update(text).digest('hex');
|
|
@@ -379,18 +283,16 @@ function createPromptBundle(prompts) {
|
|
|
379
283
|
});
|
|
380
284
|
}
|
|
381
285
|
export const PROMPT_BUNDLE = createPromptBundle({
|
|
382
|
-
memory:
|
|
383
|
-
skill:
|
|
384
|
-
combined:
|
|
385
|
-
skillPlan: SKILL_REVIEW_PLAN_PROMPT,
|
|
386
|
-
combinedPlan: COMBINED_REVIEW_PLAN_PROMPT,
|
|
286
|
+
memory: INJECT_MEMORY_REVIEW_PROMPT,
|
|
287
|
+
skill: INJECT_SKILL_REVIEW_PROMPT,
|
|
288
|
+
combined: INJECT_COMBINED_REVIEW_PROMPT,
|
|
387
289
|
curator: CURATOR_PROMPT,
|
|
388
290
|
// v46 S1.12b (finding T3-07): the curator's dry-run banner rides the bundle too. It is prepended
|
|
389
291
|
// to the curator prompt at run time and used to live outside the digest, so a drifted banner was
|
|
390
292
|
// model-visible text the integrity check could not see. The bundle digest changes with this entry
|
|
391
293
|
// (the intended fail-closed signal), and PROMPT_BUNDLE_VERSION moves 21 -> 22 with it.
|
|
392
294
|
curatorDryRun: CURATOR_DRY_RUN_BANNER,
|
|
393
|
-
completion:
|
|
295
|
+
completion: INJECT_COMPLETION_SKILL_REVIEW_PROMPT,
|
|
394
296
|
maintain: MAINTAIN_PROMPT,
|
|
395
297
|
// F-16: new entry — the maintain subagent's output instruction
|
|
396
298
|
// (see MAINTAIN_OUTPUT_INSTRUCTION). Digest changes with this entry.
|
|
@@ -19,5 +19,6 @@ export declare function writeProposalReport(io: EvolutionIoLike, proposal: Propo
|
|
|
19
19
|
* @param limit - newest rows to return.
|
|
20
20
|
* @returns valid proposals, newest filename first.
|
|
21
21
|
*/
|
|
22
|
+
export declare function readProposalReport(io: EvolutionIoLike, id: string, dir?: string): Promise<ProposalView | null>;
|
|
22
23
|
export declare function readProposalReports(io: EvolutionIoLike, dir?: string, limit?: number): Promise<ProposalView[]>;
|
|
23
24
|
//# sourceMappingURL=proposal-report.d.ts.map
|
|
@@ -35,6 +35,18 @@ function isProposal(value) {
|
|
|
35
35
|
* @param limit - newest rows to return.
|
|
36
36
|
* @returns valid proposals, newest filename first.
|
|
37
37
|
*/
|
|
38
|
+
export async function readProposalReport(io, id, dir = proposalReportDir()) {
|
|
39
|
+
const raw = await probeText(io, join(dir, proposalReportName({ id })));
|
|
40
|
+
if (!isPresent(raw))
|
|
41
|
+
return null;
|
|
42
|
+
try {
|
|
43
|
+
const parsed = JSON.parse(raw.value);
|
|
44
|
+
return isProposal(parsed) ? parsed : null;
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
38
50
|
export async function readProposalReports(io, dir = proposalReportDir(), limit = 10) {
|
|
39
51
|
const listed = await probeList(io, dir);
|
|
40
52
|
if (isUnknown(listed) || !isPresent(listed))
|
|
@@ -179,6 +179,10 @@ export interface RunRegistryOptions {
|
|
|
179
179
|
home: string;
|
|
180
180
|
/** Warn channel for a failed index write (the run itself is unaffected). */
|
|
181
181
|
warn?: (message: string) => void;
|
|
182
|
+
/** Optional family fence; when set, every index RMW runs inside it. */
|
|
183
|
+
fence?: {
|
|
184
|
+
run<T>(body: () => Promise<T>): Promise<T>;
|
|
185
|
+
} | undefined;
|
|
182
186
|
/** Clock seam for tests. */
|
|
183
187
|
now?: () => number;
|
|
184
188
|
/** Retained records (N3-clamped). */
|
|
@@ -124,6 +124,13 @@ export function newRunRegistry(options) {
|
|
|
124
124
|
const maxRecords = clampedNumber(options.maxRecords ?? DEFAULT_RUN_RECORDS, DEFAULT_RUN_RECORDS, { min: 1 });
|
|
125
125
|
const warn = options.warn ?? (() => { });
|
|
126
126
|
const path = runsFile(options.home);
|
|
127
|
+
const writeIndex = async (task) => {
|
|
128
|
+
const run = async () => { await transactIo(options.io, path, task); };
|
|
129
|
+
if (options.fence !== undefined)
|
|
130
|
+
await options.fence.run(run);
|
|
131
|
+
else
|
|
132
|
+
await run();
|
|
133
|
+
};
|
|
127
134
|
/** Rows THIS process started: its memory is the only truth for them. */
|
|
128
135
|
const owned = new Map();
|
|
129
136
|
/** Rows read from the shared index: the file is the only truth for them. */
|
|
@@ -191,7 +198,7 @@ export function newRunRegistry(options) {
|
|
|
191
198
|
// single write a non-owner may make is the orphan verdict for a row whose owner is
|
|
192
199
|
// gone. The row read inside this transaction IS the compare-and-swap: if its owner
|
|
193
200
|
// settled it in between, it no longer reads as `running` and is left alone.
|
|
194
|
-
await
|
|
201
|
+
await writeIndex((current) => {
|
|
195
202
|
const onDisk = parseIndex(current);
|
|
196
203
|
const merged = new Map();
|
|
197
204
|
for (const row of onDisk.records)
|
|
@@ -360,7 +367,7 @@ export function newRunRegistry(options) {
|
|
|
360
367
|
},
|
|
361
368
|
async supersedeKind(kind) {
|
|
362
369
|
let marked = 0;
|
|
363
|
-
await
|
|
370
|
+
await writeIndex((current) => {
|
|
364
371
|
const onDisk = parseIndex(current);
|
|
365
372
|
const merged = new Map();
|
|
366
373
|
for (const row of onDisk.records)
|
|
@@ -402,7 +409,7 @@ export function newRunRegistry(options) {
|
|
|
402
409
|
return owned.get(id)?.state === outcome.state;
|
|
403
410
|
}
|
|
404
411
|
let changed = false;
|
|
405
|
-
await
|
|
412
|
+
await writeIndex((current) => {
|
|
406
413
|
const onDisk = parseIndex(current);
|
|
407
414
|
const row = onDisk.records.find(item => item.id === id);
|
|
408
415
|
if (row === undefined)
|
|
@@ -300,7 +300,10 @@ export declare function loadVersionContent(root: string, io: EvolutionIoLike, na
|
|
|
300
300
|
* @param keep - how many versions to retain per skill.
|
|
301
301
|
* @returns the version numbers, or null when there was no content to record.
|
|
302
302
|
*/
|
|
303
|
-
export
|
|
303
|
+
export interface HistoryFence {
|
|
304
|
+
run<T>(body: () => Promise<T>): Promise<T>;
|
|
305
|
+
}
|
|
306
|
+
export declare function recordVersions(root: string, io: EvolutionIoLike, input: VersionRecordInput, keep: number, fence?: HistoryFence): Promise<RecordedVersions | null>;
|
|
304
307
|
/** What kind of change one recorded version carries, as a CLOSED set. */
|
|
305
308
|
export type VersionActionKind = 'baseline' | 'create' | 'patch' | 'update' | 'restore' | 'delete' | 'archive' | 'consolidate' | 'restructure' | 'extract' | 'merge' | 'support-write' | 'support-remove' | 'other';
|
|
306
309
|
/**
|
|
@@ -496,18 +496,7 @@ export async function loadVersionContent(root, io, name, v) {
|
|
|
496
496
|
}
|
|
497
497
|
return isPresent(probe) ? probe.value : null;
|
|
498
498
|
}
|
|
499
|
-
|
|
500
|
-
* Record the content one mutation produced, best-effort.
|
|
501
|
-
*
|
|
502
|
-
* Blobs are written FIRST: the index must never reference content that is not on disk, and a failed
|
|
503
|
-
* blob write aborts the whole record (the caller warns; the mutation itself stands).
|
|
504
|
-
* @param root - the skills root.
|
|
505
|
-
* @param io - the io seam.
|
|
506
|
-
* @param input - the write being recorded.
|
|
507
|
-
* @param keep - how many versions to retain per skill.
|
|
508
|
-
* @returns the version numbers, or null when there was no content to record.
|
|
509
|
-
*/
|
|
510
|
-
export async function recordVersions(root, io, input, keep) {
|
|
499
|
+
export async function recordVersions(root, io, input, keep, fence) {
|
|
511
500
|
if (input.before === null && input.after === null)
|
|
512
501
|
return null;
|
|
513
502
|
for (const side of [input.before, input.after]) {
|
|
@@ -560,23 +549,29 @@ export async function recordVersions(root, io, input, keep) {
|
|
|
560
549
|
}
|
|
561
550
|
const recorded = {};
|
|
562
551
|
let raceRefused = false;
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
552
|
+
const write = async () => {
|
|
553
|
+
await transactIo(io, file, (current) => {
|
|
554
|
+
const state = readHistoryIndex(current);
|
|
555
|
+
// The old comment here claimed the probe's copy covered a race. It only did when the probe had
|
|
556
|
+
// ALREADY seen the bytes as unreadable; a file that turned unreadable in between had no copy, and
|
|
557
|
+
// deriving the index from `[]` dropped every version it listed (and orphaned their blobs).
|
|
558
|
+
// Returning `current` unchanged is a byte-identical no-op, so the bytes survive and this record
|
|
559
|
+
// is abandoned below. Only an UNREADABLE state refuses: an ABSENT file is a skill with no
|
|
560
|
+
// history yet, and refusing there would abandon every first record (the index must be created).
|
|
561
|
+
if (state.kind === 'unreadable' && probe.kind !== 'unreadable') {
|
|
562
|
+
raceRefused = true;
|
|
563
|
+
return current;
|
|
564
|
+
}
|
|
565
|
+
const { versions, recorded: numbers } = nextHistoryIndex(state.kind === 'ok' ? state.versions : [], input, keep);
|
|
566
|
+
recorded.beforeVersion = numbers.beforeVersion;
|
|
567
|
+
recorded.afterVersion = numbers.afterVersion;
|
|
568
|
+
return JSON.stringify({ version: HISTORY_INDEX_VERSION, versions }, null, 2);
|
|
569
|
+
});
|
|
570
|
+
};
|
|
571
|
+
if (fence !== undefined)
|
|
572
|
+
await fence.run(write);
|
|
573
|
+
else
|
|
574
|
+
await write();
|
|
580
575
|
// v46 lint: `raceRefused` is set inside the transact task (the analyzer sees only the literal
|
|
581
576
|
// initializer), and the refusal is the S3.1 case this branch exists for.
|
|
582
577
|
// oxlint-disable-next-line typescript/no-unnecessary-condition -- set inside the transact task
|
|
@@ -36,12 +36,12 @@ import { type WriteAuthority } from './write-authority.ts';
|
|
|
36
36
|
import { transactIo, type EvolutionIoLike } from './io.ts';
|
|
37
37
|
import { type Probe } from './probe.ts';
|
|
38
38
|
import type { SkillLimits } from './limits.ts';
|
|
39
|
-
import { type MutationResult } from './mutation-unit.ts';
|
|
39
|
+
import { type MutationLockPort, type MutationResult } from './mutation-unit.ts';
|
|
40
40
|
import { SkillModel } from './skill-model.ts';
|
|
41
41
|
import { type ExtractPlanDraft } from './extract-plan.ts';
|
|
42
42
|
import { type MutationRecord } from './mutations.ts';
|
|
43
43
|
import { type RevisionAnchor, type RevisionFile } from './skill-revision.ts';
|
|
44
|
-
import { type UnitHead, type SkillVersion } from './skill-history.ts';
|
|
44
|
+
import { type UnitHead, type HistoryFence, type SkillVersion } from './skill-history.ts';
|
|
45
45
|
import { type SkillHealthAssessment, type SkillHealthThresholds } from './skill-health.ts';
|
|
46
46
|
import type { EvolutionSkillMutatedEvent } from './events.ts';
|
|
47
47
|
export interface SkillSummary {
|
|
@@ -349,10 +349,13 @@ export declare class SkillLibrary {
|
|
|
349
349
|
/** G1/1.1: default authority; a call may override (origin is per-invocation). */
|
|
350
350
|
/** G1/1.1/Stage 2: the ONE default every mutator reads. Per-call overrides still win. */
|
|
351
351
|
private readonly authority;
|
|
352
|
+
/** When supplied by the family MutationAuthority, replaces the per-directory file lock. */
|
|
353
|
+
private readonly mutationLock;
|
|
354
|
+
private readonly fence;
|
|
352
355
|
/** skill-history.ts: the content history is best-effort, so a failure must not be SILENT —
|
|
353
356
|
* but it is a deployment condition, not a per-write event, so it warns once per instance. */
|
|
354
357
|
private historyWarned;
|
|
355
|
-
constructor(root?: string, io?: EvolutionIoLike, limits?: SkillLimits, onMutation?: (event: EvolutionSkillMutatedEvent) => void, transact?: typeof transactIo, threatExemptLabels?: readonly string[], authority?: WriteAuthority);
|
|
358
|
+
constructor(root?: string, io?: EvolutionIoLike, limits?: SkillLimits, onMutation?: (event: EvolutionSkillMutatedEvent) => void, transact?: typeof transactIo, threatExemptLabels?: readonly string[], authority?: WriteAuthority, mutationLock?: MutationLockPort, fence?: HistoryFence);
|
|
356
359
|
/**
|
|
357
360
|
* Transitional root lock for mutators that still own their write path. The
|
|
358
361
|
* extract/restructure path takes the same lock through MutationUnit, so those
|
|
@@ -360,6 +363,7 @@ export declare class SkillLibrary {
|
|
|
360
363
|
*/
|
|
361
364
|
private unitHeadForOps;
|
|
362
365
|
private withMutationLock;
|
|
366
|
+
private lockPort;
|
|
363
367
|
private recovery;
|
|
364
368
|
/** Run the boot recovery once per library instance, before the first write. */
|
|
365
369
|
private ensureRecovered;
|
|
@@ -813,6 +817,7 @@ export declare class SkillLibrary {
|
|
|
813
817
|
* `emit`, so core states the contract without importing the platform type. */
|
|
814
818
|
export interface SkillMutationSink {
|
|
815
819
|
emit: (type: 'evolution/skill-mutated', event: EvolutionSkillMutatedEvent) => unknown;
|
|
820
|
+
get?(name: string): unknown;
|
|
816
821
|
}
|
|
817
822
|
/** V41 P2-26 (0.3.75): the ONE SkillLibrary construction point.
|
|
818
823
|
*
|
|
@@ -835,6 +840,9 @@ export interface NewSkillLibraryOptions {
|
|
|
835
840
|
threatExemptLabels?: readonly string[] | undefined;
|
|
836
841
|
/** G1/1.1: WHO writes through this library. Required: no call site can omit it. */
|
|
837
842
|
authority: WriteAuthority;
|
|
843
|
+
/** Optional family authority lock; absent falls back to per-directory file lock. */
|
|
844
|
+
mutationLock?: MutationLockPort;
|
|
845
|
+
fence?: HistoryFence;
|
|
838
846
|
}
|
|
839
847
|
export declare function newSkillLibrary(options: NewSkillLibraryOptions): SkillLibrary;
|
|
840
848
|
export { DEFAULT_SKILL_LIMITS, DEFAULT_CITATION_POLICY, DEFAULT_REFERENCE_REWRITE_POLICY, DEFAULT_ARCHIVE_RETENTION_POLICY, DEFAULT_SUPPORT_FILE_CHAR_POLICY, POLICY_STAGE_DEFAULTS, policyStageLimits, } from './limits.ts';
|