@lmzhen/dsh-evolution-core 0.1.0-rc.9 → 0.1.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 +2175 -473
- package/lib/types/constants.d.ts +53 -0
- package/lib/types/curator.d.ts +71 -4
- package/lib/types/events.d.ts +18 -10
- package/lib/types/evolution-events.d.ts +111 -0
- package/lib/types/gates.d.ts +38 -0
- package/lib/types/index.d.ts +6 -0
- package/lib/types/io.d.ts +31 -4
- package/lib/types/learn-prompt.d.ts +19 -0
- package/lib/types/memory-store.d.ts +55 -12
- package/lib/types/mutations.d.ts +24 -0
- package/lib/types/prompts.d.ts +26 -6
- package/lib/types/quality.d.ts +70 -0
- package/lib/types/skill-store.d.ts +153 -21
- package/lib/types/state-store.d.ts +2 -15
- package/lib/types/threats.d.ts +16 -4
- package/lib/types/usage.d.ts +69 -2
- package/package.json +5 -5
package/lib/types/prompts.d.ts
CHANGED
|
@@ -1,9 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Prompt bundle identity. Bump both id and version whenever a prompt's text
|
|
3
|
+
* changes semantically: the bundle digest is the fail-closed signal for
|
|
4
|
+
* review workers, so a stale id across deployments must be distinguishable.
|
|
5
|
+
*/
|
|
6
|
+
export declare const PROMPT_BUNDLE_ID = "dsh-evolution@7";
|
|
7
|
+
export declare const PROMPT_BUNDLE_VERSION = 7;
|
|
2
8
|
export declare const MEMORY_REVIEW_PROMPT = "[Auto-review \u2014 Memory]\nReview the conversation above and consider saving to memory if appropriate.\n\nFocus on:\n1. Has the user revealed things about themselves \u2014 persona, desires, preferences, or personal details worth remembering?\n2. Has the user expressed expectations about how you should behave, their work style, or ways they want you to operate?\n\nIf something stands out, save it using the memory tool.\nIf nothing is worth saving, just say \"Nothing to save.\" and stop.";
|
|
3
|
-
export declare const SKILL_REVIEW_PROMPT = "[Auto-review \u2014 Skills]\nReview the conversation above and update the skill library. Be ACTIVE \u2014 most sessions produce at least one skill update, even if small.\n\nTarget shape: CLASS-LEVEL skills with a rich SKILL.md and a references/ directory for session-specific detail. Not a flat list of narrow one-session
|
|
4
|
-
export declare const COMBINED_REVIEW_PROMPT = "[Auto-review]\nReview the conversation above and update two things
|
|
5
|
-
export declare const CURATOR_PROMPT = "You are the skill curator. Maintain a healthy, class-level skill library.\n\
|
|
6
|
-
export declare
|
|
9
|
+
export declare const SKILL_REVIEW_PROMPT = "[Auto-review \u2014 Skills]\nReview the conversation above and update the skill library. Be ACTIVE \u2014 most sessions produce at least one skill update, even if small. A pass that does nothing is a missed learning opportunity, not a neutral outcome.\n\nTarget 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.\n\nSignals to look for (any one of these warrants action):\n \u2022 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.\n \u2022 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.\n \u2022 Non-trivial technique, fix, workaround, debugging path, or tool-usage pattern emerged that a future session would benefit from. Capture it.\n \u2022 A skill that got loaded or consulted this session turned out to be wrong, missing a step, or outdated. Patch it NOW.\n\nRead-before-write (enforced by this channel): update, patch, delete, or write support files ONLY into skills you loaded or read in THIS session \u2014 ops on unread skills are dropped; CREATE of a brand-new umbrella is the only exception.\n\nPreference order \u2014 prefer the earliest action that fits, but do pick one when a signal above fired:\n 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.\n 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.\n 3. ADD A SUPPORT FILE under an existing umbrella. Skills can be packaged with three kinds of support files \u2014 use the right directory per kind:\n \u2022 references/<topic>.md \u2014 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.\n \u2022 templates/<name>.<ext> \u2014 starter files meant to be copied and modified (boilerplate configs, scaffolding, a known-good example the agent can reproduce with modifications).\n \u2022 scripts/<name>.<ext> \u2014 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).\n 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.\n 4. CREATE A NEW CLASS-LEVEL UMBRELLA SKILL when no existing skill covers the class. 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 \u2014 fall back to (1), (2), or (3).\n\nUser-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.\n\nIf you notice two existing skills that overlap, note it in your reply \u2014 the background curator handles consolidation at scale.\n\nTwo-tier deposition discipline (DSH addition, same spirit as the umbrella rule): before writing, classify the knowledge:\n \u2022 PATTERN (reusable \u2014 symptom \u2192 mechanism \u2192 fix \u2192 verification, still valuable next session) belongs in the SKILL.md body.\n \u2022 LOG (one-off \u2014 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.\n\nProtected skills (DO NOT edit these):\n \u2022 Bundled skills (shipped with the platform).\n \u2022 Hub-installed skills (installed from a hub).\nPinned skills are read-only to THIS background review pass \u2014 the pinned write guard refuses background changes, so only the foreground may update or archive them. Foreground and delegated-subagent writes to pinned skills remain allowed.\nIf the only skills that need updating are protected, say 'Nothing to save.' and stop.\n\nDo NOT capture (these become persistent self-imposed constraints that bite you later when the environment changes):\n \u2022 Environment-dependent failures: missing binaries, fresh-install errors, post-migration path mismatches, 'command not found', unconfigured credentials, uninstalled packages. The user can fix these \u2014 they are not durable rules.\n \u2022 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.\n \u2022 Session-specific transient errors that resolved before the conversation ended. If retrying worked, the lesson is the retry pattern, not the original failure.\n \u2022 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.\n\nIf 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 \u2014 never 'this tool does not work' as a standalone constraint.\n\n'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, just say 'Nothing to save.' and stop. Otherwise, act.";
|
|
10
|
+
export declare const COMBINED_REVIEW_PROMPT = "[Auto-review]\nReview the conversation above and update two things:\n\n**Memory**: who the user is. Did the user reveal persona, desires, preferences, personal details, or expectations about how you should behave? Save facts about the user and durable preferences with the memory tool.\n\n**Skills**: how to do this class of task. Be ACTIVE \u2014 most sessions produce at least one skill update. A pass that does nothing is a missed learning opportunity, not a neutral outcome.\n\nTarget shape of the skill library: CLASS-LEVEL skills 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.\n\nSignals that warrant a skill update (any one is enough):\n \u2022 User corrected your style, tone, format, legibility, verbosity, or approach. Frustration is a FIRST-CLASS skill signal, not just a memory signal. 'stop doing X', 'don't format like this', 'I hate when you Y' \u2014 embed the lesson in the skill that governs that task so the next session starts fixed.\n \u2022 Non-trivial technique, fix, workaround, or debugging path emerged.\n \u2022 A skill that was loaded or consulted turned out wrong, missing, or outdated \u2014 patch it now.\n\nRead-before-write (enforced by this channel): update, patch, delete, or write support files ONLY into skills you loaded or read in THIS session \u2014 ops on unread skills are dropped; CREATE of a brand-new umbrella is the only exception.\n\nPreference order for skills \u2014 pick the earliest that fits:\n 1. UPDATE A CURRENTLY-LOADED SKILL. Check what skills were loaded or read in the conversation. If one of them covers the learning, PATCH it first. It was in play; it's the right place.\n 2. UPDATE AN EXISTING UMBRELLA. Patch it.\n 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.\n 4. CREATE A NEW CLASS-LEVEL UMBRELLA when nothing exists. Name at the class level \u2014 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).\n\nTwo-tier deposition discipline (DSH addition): classify before writing \u2014 PATTERN (symptom \u2192 mechanism \u2192 fix \u2192 verification) goes in the SKILL.md body; LOG (commit SHAs, npm/profile states, this release's change list, this session's narrative) goes in a references/ file. Body density IS reuse rate; a pattern fits in 2-8 physical lines.\n\nUser-preference embedding: when the user complains about how you handled a task, update the skill that governs that task \u2014 memory alone isn't enough. Memory says 'who the user is and what the current situation and state of your operations are'; skills say 'how to do this class of task for this user'. Both should carry user-preference lessons when relevant.\n\nIf you notice overlapping existing skills, mention it \u2014 the background curator handles consolidation.\n\nProtected skills (DO NOT edit these):\n \u2022 Bundled skills (shipped with the platform).\n \u2022 Hub-installed skills (installed from a hub).\nPinned skills are read-only to THIS background review pass \u2014 the pinned write guard refuses background changes, so only the foreground may update or archive them. Foreground and delegated-subagent writes to pinned skills remain allowed.\nIf the only skills that need updating are protected, say 'Nothing to save.' and stop.\n\nDo NOT capture as skills (these become persistent self-imposed constraints that bite you later when the environment changes):\n \u2022 Environment-dependent failures: missing binaries, fresh-install errors, post-migration path mismatches, 'command not found', unconfigured credentials, uninstalled packages. The user can fix these \u2014 they are not durable rules.\n \u2022 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.\n \u2022 Session-specific transient errors that resolved before the conversation ended. If retrying worked, the lesson is the retry pattern, not the original failure.\n \u2022 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.\n\nIf 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 \u2014 never 'this tool does not work' as a standalone constraint.\n\nAct on whichever of the two dimensions has real signal. If genuinely nothing stands out on either, say 'Nothing to save.' and stop \u2014 but don't reach for that conclusion as a default.";
|
|
11
|
+
export declare const CURATOR_PROMPT = "You are the skill curator. Maintain a healthy, class-level skill library, not a flat pile of narrow one-session skills.\n\nThis is an UMBRELLA-BUILDING consolidation pass, not a passive audit and not a duplicate-finder.\n\nThe goal is a LIBRARY OF CLASS-LEVEL INSTRUCTIONS. A skill collection of many narrow skills where each captures one session's specific bug is a FAILURE of the library. An agent searching skills matches on descriptions, not exact names; one broad umbrella with labeled subsections beats five narrow siblings for discoverability.\n\nRight target shape: class-level skills with rich SKILL.md + references/, templates/, scripts/ support files for session-specific detail.\n\nHard rules:\n1. NEVER hard-delete a skill. Archive (moving to .archive/) is the maximum destructive action; archives are recoverable, deletion is not.\n2. Do not touch bundled, hub-installed, pinned, or scheduled-task-referenced (referenced) skills. Referenced skills are fully protected \u2014 never consolidated, never pruned (there is no scheduled-task reference-rewriting pass; a referenced skill stays in place by design).\n3. Do not archive recently-created or never-used skills without strong evidence. \"use=0\" is NOT evidence either way \u2014 it only means the trigger has not come up yet. Never archive a never-used skill unless it is at least 30 days old AND its content is genuinely obsolete or fully absorbed elsewhere.\n4. Do NOT reject consolidation on the grounds that \"each skill has a distinct trigger\". The right bar is: would a human maintainer write this as N separate skills, or one skill with N labeled subsections? When the answer is the latter, merge.\n5. Judge overlap on CONTENT, not on usage counters.\n6. Before archiving a merged skill, ensure its unique content was preserved in the umbrella.\n\nHow to work:\n1. Scan the candidate list. Identify PREFIX CLUSTERS \u2014 skills sharing a first word or domain keyword. Expected cluster count scales with the library: a large collection may show 10-25 prefix clusters, a small one often has none \u2014 a clean \"nothing to consolidate\" summary is the correct small-library outcome, not a shortage of ambition.\n2. For each cluster with 2+ members, ask \"what is the UMBRELLA CLASS these skills serve?\" and consolidate:\n a. MERGE INTO AN EXISTING UMBRELLA (patch a labeled section for each sibling's unique insight, then archive the siblings).\n b. CREATE A NEW UMBRELLA SKILL.md covering the shared workflow with short labeled subsections, then archive the absorbed siblings.\n c. DEMOTE session-specific detail to references/, templates/, or scripts/ under the umbrella. Use the right directory per kind:\n \u2022 references/<topic>.md \u2014 session-specific detail OR condensed knowledge banks (quoted research, API docs excerpts, domain notes, provider quirks, reproduction recipes) written concise and task-focused.\n \u2022 templates/<name>.<ext> \u2014 starter files meant to be copied and modified.\n \u2022 scripts/<name>.<ext> \u2014 statically re-runnable actions (verification scripts, fixture generators, probes).\n3. Package integrity \u2014 not optional: inspect each skill as a COMPLETE directory package, not just SKILL.md. A skill root may include references/, templates/, scripts/, and assets/. If the source skill has support files OR its SKILL.md contains relative links to them, DO NOT flatten only SKILL.md into <umbrella>/references/<old>.md. Choose one safe path instead: keep it as a standalone skill, OR fully merge by re-homing every needed support file into the umbrella's canonical directories AND rewriting the destination instructions to the new paths, OR archive the entire original skill package unchanged. Never leave demoted instructions pointing at files left behind under the old skill directory.\n4. Flag skills whose NAME is too narrow (contains a PR number, a feature codename, a specific error string, an 'audit'/'diagnosis'/'salvage' session artifact) \u2014 they almost always belong as a subsection or support file under a class-level umbrella.\n5. Iterate. After one consolidation round, scan the remaining set and look for the NEXT umbrella opportunity. Don't stop after 3 merges.\n\nYou are a NOMINATOR, not an executor: this channel has NO tools. Your single deliverable is the structured YAML block below. Never narrate actions you did not take (\"merged\", \"patched\", \"archived\") \u2014 you are proposing, and the deterministic engine executes only names from the candidate pool it gave you. (A future execution view would expose skill_manage; today it does not.)\n\n'keep' is a legitimate decision ONLY when the skill is already a class-level umbrella and none of the proposed merges would improve discoverability. 'This is narrow but distinct from its siblings' is NOT a reason to keep \u2014 it's a reason to move it under an umbrella as a subsection or support file.\n\nExpected output: real umbrella-ification. Process every obvious cluster. If you end the pass with obvious clusters still untouched, you stopped too early \u2014 go back and look at the clusters you left alone.\n\nKeep the umbrella body tight and scannable: exact commands, verbatim paths, ~100-200 lines; never invent flags or APIs.\n\nWhen done, write a human summary THEN the structured machine-readable block. The block is the contract: every skill you would move to .archive/ MUST appear in exactly one of the two lists. Return ONLY the YAML block after the summary \u2014 no post-block prose. Format EXACTLY:\n\n## Structured summary (required)\n```yaml\nconsolidations:\n - from: <old-skill-name>\n into: <umbrella-skill-name>\n reason: <one short sentence \u2014 why merged, not just 'similar'>\nprunings:\n - name: <skill-name>\n reason: <one short sentence \u2014 why archived with no merge target>\n```\n\nEvery skill you would move to .archive/ MUST appear in exactly one of the two lists. If you consolidated X into umbrella Y (patched Y, wrote a references file to Y, or created Y with X's content absorbed), X goes under consolidations with into: Y. If you archived X with no absorption \u2014 truly stale, irrelevant, or obsolete \u2014 X goes under prunings. Leave a list empty (consolidations: []) if none. Do not omit the block. The block comes AFTER your human-readable summary of clusters processed, patches made, and decisions left alone.";
|
|
12
|
+
export declare const CURATOR_DRY_RUN_BANNER = "\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\nDRY-RUN \u2014 REPORT ONLY. DO NOT MUTATE THE SKILL LIBRARY.\n\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\n\nThis is a PREVIEW pass. Follow every instruction above EXCEPT:\n \u2022 Do NOT call skill_manage with action=create, update, patch, delete, write_file, or remove_file.\n \u2022 Do NOT move, copy, or rewrite any file under the skills tree.\n\nYour 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.\n\nIf you accidentally take a mutating action, say so explicitly in the summary.";
|
|
13
|
+
export declare const COMPLETION_SKILL_REVIEW_PROMPT = "[Auto-review \u2014 Skills \u00B7 task complete]\nYour current task now appears complete. Before wrapping up, review the approach and update the skill library via skill_manage.\n\nFollow the skills review policy: be ACTIVE, prefer class-level umbrellas, patch ONLY skills loaded or read this session, and capture non-trivial techniques and user corrections. Do NOT capture environment-dependent failures, negative claims about tools, or one-off task narratives.\n\nDo NOT modify output files or re-run the task. If you are still mid-task, ignore this.";
|
|
14
|
+
/**
|
|
15
|
+
* System-prompt guidance section (Hermes `SKILLS_GUIDANCE`, DSH-adapted).
|
|
16
|
+
* Registered as a system-prompt section by tool-skill-manage (it mounts
|
|
17
|
+
* exactly when `skill_manage` is available — the DSH analogue of Hermes'
|
|
18
|
+
* `if "skill_manage" in agent.valid_tool_names` condition). Instructs the
|
|
19
|
+
* model to save/repair skills on its own initiative.
|
|
20
|
+
*/
|
|
21
|
+
export declare const SKILLS_GUIDANCE = "Skills guidance:\n\u2022 After completing a complex task (5+ tool calls), fixing a tricky error, or discovering a non-trivial workflow, save the approach as a skill with skill_manage so you can reuse it next time.\n\u2022 When using a skill and finding it outdated, incomplete, or wrong, patch it immediately with skill_manage (action='patch') \u2014 don't wait to be asked. Skills that aren't maintained become liabilities.";
|
|
22
|
+
/** Subagent-channel variant: same review policy, channel-limited deliverable (M-2). */
|
|
23
|
+
export declare const SKILL_REVIEW_PLAN_PROMPT = "[Auto-review \u2014 Skills]\nReview the conversation above and update the skill library. Be ACTIVE \u2014 most sessions produce at least one skill update, even if small. A pass that does nothing is a missed learning opportunity, not a neutral outcome.\n\nTarget 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.\n\nSignals to look for (any one of these warrants action):\n \u2022 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.\n \u2022 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.\n \u2022 Non-trivial technique, fix, workaround, debugging path, or tool-usage pattern emerged that a future session would benefit from. Capture it.\n \u2022 A skill that got loaded or consulted this session turned out to be wrong, missing a step, or outdated. Patch it NOW.\n\nRead-before-write (enforced by this channel): update, patch, delete, or write support files ONLY into skills you loaded or read in THIS session \u2014 ops on unread skills are dropped; CREATE of a brand-new umbrella is the only exception.\n\nPreference order \u2014 prefer the earliest action that fits, but do pick one when a signal above fired:\n 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.\n 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.\n 3. ADD A SUPPORT FILE under an existing umbrella. Skills can be packaged with three kinds of support files \u2014 use the right directory per kind:\n \u2022 references/<topic>.md \u2014 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.\n \u2022 templates/<name>.<ext> \u2014 starter files meant to be copied and modified (boilerplate configs, scaffolding, a known-good example the agent can reproduce with modifications).\n \u2022 scripts/<name>.<ext> \u2014 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).\n 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.\n 4. CREATE A NEW CLASS-LEVEL UMBRELLA SKILL when no existing skill covers the class. 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 \u2014 fall back to (1), (2), or (3).\n\nUser-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.\n\nIf you notice two existing skills that overlap, note it in your reply \u2014 the background curator handles consolidation at scale.\n\nTwo-tier deposition discipline (DSH addition, same spirit as the umbrella rule): before writing, classify the knowledge:\n \u2022 PATTERN (reusable \u2014 symptom \u2192 mechanism \u2192 fix \u2192 verification, still valuable next session) belongs in the SKILL.md body.\n \u2022 LOG (one-off \u2014 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.\n\nProtected skills (DO NOT edit these):\n \u2022 Bundled skills (shipped with the platform).\n \u2022 Hub-installed skills (installed from a hub).\nPinned skills are read-only to THIS background review pass \u2014 the pinned write guard refuses background changes, so only the foreground may update or archive them. Foreground and delegated-subagent writes to pinned skills remain allowed.\nIf the only skills that need updating are protected, say 'Nothing to save.' and stop.\n\nDo NOT capture (these become persistent self-imposed constraints that bite you later when the environment changes):\n \u2022 Environment-dependent failures: missing binaries, fresh-install errors, post-migration path mismatches, 'command not found', unconfigured credentials, uninstalled packages. The user can fix these \u2014 they are not durable rules.\n \u2022 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.\n \u2022 Session-specific transient errors that resolved before the conversation ended. If retrying worked, the lesson is the retry pattern, not the original failure.\n \u2022 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.\n\nIf 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 \u2014 never 'this tool does not work' as a standalone constraint.\n\n'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, just say 'Nothing to save.' and stop. Otherwise, act.\n\nCHANNEL (subagent): this review channel mounts only the read-only `skill` tool \u2014 you have NO `skill_manage`, NO `memory`. Your deliverable is the structured JSON plan below (outputSchema). Describe the patches/creates you RECOMMEND in the plan; never narrate actions you took.";
|
|
24
|
+
/** Subagent-channel variant of the combined review (M-2). */
|
|
25
|
+
export declare const COMBINED_REVIEW_PLAN_PROMPT = "[Auto-review]\nReview the conversation above and update two things:\n\n**Memory**: who the user is. Did the user reveal persona, desires, preferences, personal details, or expectations about how you should behave? Save facts about the user and durable preferences with the memory tool.\n\n**Skills**: how to do this class of task. Be ACTIVE \u2014 most sessions produce at least one skill update. A pass that does nothing is a missed learning opportunity, not a neutral outcome.\n\nTarget shape of the skill library: CLASS-LEVEL skills 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.\n\nSignals that warrant a skill update (any one is enough):\n \u2022 User corrected your style, tone, format, legibility, verbosity, or approach. Frustration is a FIRST-CLASS skill signal, not just a memory signal. 'stop doing X', 'don't format like this', 'I hate when you Y' \u2014 embed the lesson in the skill that governs that task so the next session starts fixed.\n \u2022 Non-trivial technique, fix, workaround, or debugging path emerged.\n \u2022 A skill that was loaded or consulted turned out wrong, missing, or outdated \u2014 patch it now.\n\nRead-before-write (enforced by this channel): update, patch, delete, or write support files ONLY into skills you loaded or read in THIS session \u2014 ops on unread skills are dropped; CREATE of a brand-new umbrella is the only exception.\n\nPreference order for skills \u2014 pick the earliest that fits:\n 1. UPDATE A CURRENTLY-LOADED SKILL. Check what skills were loaded or read in the conversation. If one of them covers the learning, PATCH it first. It was in play; it's the right place.\n 2. UPDATE AN EXISTING UMBRELLA. Patch it.\n 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.\n 4. CREATE A NEW CLASS-LEVEL UMBRELLA when nothing exists. Name at the class level \u2014 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).\n\nTwo-tier deposition discipline (DSH addition): classify before writing \u2014 PATTERN (symptom \u2192 mechanism \u2192 fix \u2192 verification) goes in the SKILL.md body; LOG (commit SHAs, npm/profile states, this release's change list, this session's narrative) goes in a references/ file. Body density IS reuse rate; a pattern fits in 2-8 physical lines.\n\nUser-preference embedding: when the user complains about how you handled a task, update the skill that governs that task \u2014 memory alone isn't enough. Memory says 'who the user is and what the current situation and state of your operations are'; skills say 'how to do this class of task for this user'. Both should carry user-preference lessons when relevant.\n\nIf you notice overlapping existing skills, mention it \u2014 the background curator handles consolidation.\n\nProtected skills (DO NOT edit these):\n \u2022 Bundled skills (shipped with the platform).\n \u2022 Hub-installed skills (installed from a hub).\nPinned skills are read-only to THIS background review pass \u2014 the pinned write guard refuses background changes, so only the foreground may update or archive them. Foreground and delegated-subagent writes to pinned skills remain allowed.\nIf the only skills that need updating are protected, say 'Nothing to save.' and stop.\n\nDo NOT capture as skills (these become persistent self-imposed constraints that bite you later when the environment changes):\n \u2022 Environment-dependent failures: missing binaries, fresh-install errors, post-migration path mismatches, 'command not found', unconfigured credentials, uninstalled packages. The user can fix these \u2014 they are not durable rules.\n \u2022 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.\n \u2022 Session-specific transient errors that resolved before the conversation ended. If retrying worked, the lesson is the retry pattern, not the original failure.\n \u2022 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.\n\nIf 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 \u2014 never 'this tool does not work' as a standalone constraint.\n\nAct on whichever of the two dimensions has real signal. If genuinely nothing stands out on either, say 'Nothing to save.' and stop \u2014 but don't reach for that conclusion as a default.\n\nCHANNEL (subagent): this review channel mounts only the read-only `skill` tool \u2014 you have NO `skill_manage`, NO `memory`. Your deliverable is the structured JSON plan below (outputSchema). Describe the patches/creates you RECOMMEND in the plan; never narrate actions you took.";
|
|
26
|
+
export declare function reviewPrompt(kind: 'memory' | 'skill' | 'combined', channel?: 'agent' | 'plan'): string;
|
|
7
27
|
export interface PromptBundle {
|
|
8
28
|
id: string;
|
|
9
29
|
version: number;
|
|
@@ -12,5 +32,5 @@ export interface PromptBundle {
|
|
|
12
32
|
}
|
|
13
33
|
export declare const PROMPT_BUNDLE: PromptBundle;
|
|
14
34
|
export declare function verifyPromptBundle(bundle?: PromptBundle): boolean;
|
|
15
|
-
export declare const DSH_AUTHORING_STANDARDS = "Follow the Hermes skill-authoring standards, translated to DSH tools.\n\nFrontmatter:\n- name: lowercase-hyphenated, <=64 chars, no spaces.\n- description: ONE sentence, <=60 characters, ends with a period. State the capability, not the implementation. No marketing words. Do NOT repeat the skill name. Count the characters before saving.\n- version: 0.1.0\n- author: always the literal value \"Hermes\". NEVER fill it from the environment, git config, or any identity you can probe.\n- platforms: declare [macos], [linux], and/or [windows] only when the skill is genuinely OS-bound; omit for portable skills.\n- metadata.hermes.tags: a few Capitalized, Relevant, Tags.\n\nBody section order (omit only when empty):\n1. \"# <Human Title>\" then a 2-3 sentence intro: what it does, what it does NOT do, key dependency stance.\n2. \"## When to Use\" \u2014 concrete trigger phrases.\n3. \"## Prerequisites\" \u2014 exact env vars, install steps, credentials.\n4. \"## How to Run\" \u2014 canonical invocation framed through DSH tools.\n5. \"## Quick Reference\" \u2014 flat command/endpoint list.\n6. \"## Procedure\" \u2014 numbered steps with copy-paste-exact commands.\n7. \"## Pitfalls\" \u2014 known limits and rate limits.\n8. \"## Verification\" \u2014 one check proving the skill worked.\n\nDSH-tool framing:\n- Reference DSH tools by name in backticks: `bash`, `str_replace_editor`, `write`, `skill`, `skill_manage`, `memory`.\n- Do not name wrapped shell utilities when a DSH tool already covers them.\n- Larger scripts belong under `scripts/` (written with `skill_manage write_file`) and are referenced from SKILL.md by relative path.\n\nQuality bar:\n- Prefer verbatim flags, paths, and APIs from the source. Never invent them.\n- Keep it tight: ~100 lines simple, ~200 complex.\n- No router/index/hub skills that only point at other skills.\n- References go in `references/`, templates in `templates
|
|
35
|
+
export declare const DSH_AUTHORING_STANDARDS = "Follow the Hermes skill-authoring standards, translated to DSH tools.\n\nFrontmatter:\n- name: lowercase-hyphenated, <=64 chars, no spaces.\n- description: ONE sentence, <=60 characters, ends with a period. State the capability, not the implementation. No marketing words. Do NOT repeat the skill name. Count the characters before saving. If the description contains a colon, wrap the whole value in double quotes.\n- version: 0.1.0\n- author: always the literal value \"Hermes\". NEVER fill it from the environment, git config, or any identity you can probe \u2014 an environment-derived name is a privacy leak the user never opted into (skills get shared and published), and the skill names itself as Hermes.\n- platforms: declare [macos], [linux], and/or [windows] only when the skill is genuinely OS-bound (osascript/apt/systemctl => the matching OS; /proc, signal.SIGKILL => linux; fcntl/termios => POSIX). Prefer fixing it cross-platform first (tempdir, pathlib, pure-Node); omit the field for portable skills.\n- metadata.hermes.tags: a few Capitalized, Relevant, Tags.\n- metadata.hermes.related_skills: [a, b] \u2014 name sibling skills this one builds on or is referenced by (optional; feeds the quality references factor).\n\nBody section order (omit only when empty):\n1. \"# <Human Title>\" then a 2-3 sentence intro: what it does, what it does NOT do, key dependency stance.\n2. \"## When to Use\" \u2014 concrete trigger phrases.\n3. \"## Prerequisites\" \u2014 exact env vars, install steps, credentials.\n4. \"## How to Run\" \u2014 canonical invocation framed through DSH tools.\n5. \"## Quick Reference\" \u2014 flat command/endpoint list.\n6. \"## Procedure\" \u2014 numbered steps with copy-paste-exact commands.\n7. \"## Pitfalls\" \u2014 known limits and rate limits.\n8. \"## Verification\" \u2014 one check proving the skill worked.\n\nDSH-tool framing:\n- Reference DSH tools by name in backticks: `bash`, `str_replace_editor`, `write`, `skill`, `skill_manage`, `memory`.\n- Do not name wrapped shell utilities when a DSH tool already covers them.\n- Larger scripts belong under `scripts/` (written with `skill_manage write_file`) and are referenced from SKILL.md by relative path.\n\nQuality bar:\n- Prefer verbatim flags, paths, and APIs from the source. Never invent them.\n- Keep it tight: ~100 lines simple, ~200 complex.\n- No router/index/hub skills that only point at other skills.\n- References go in `references/`, templates in `templates/`.\n\nLearn workflow (when the user asks you to learn a reusable skill, or you decide to turn a source/request into one):\n1. Gather every source named (files, URLs, \"what we just did\", pasted notes) with the tools you already have \u2014 and treat prose after a source as authoring requirements, not noise.\n2. Apply every requirement and constraint from the request to the SKILL.md you author.\n3. Author exactly ONE SKILL.md and save it with `skill_manage` (action=create); non-trivial scripts go under `scripts/`.\n4. When done, tell the user the skill name, its category, and a one-line summary of what it captured.";
|
|
16
36
|
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Quality scoring and near-duplicate detection for the curated skill library.
|
|
3
|
+
*
|
|
4
|
+
* Pure functions over data inputs so the scoring policy is unit-testable and
|
|
5
|
+
* the same math feeds the usage sidecar, the `skill_manage review` surface and
|
|
6
|
+
* the learning graph. Weights follow the Hermes/hermes-claw six-factor model;
|
|
7
|
+
* mutation maturity is a documented DSH approximation (single per-month patch
|
|
8
|
+
* trend ratio replaces the claw timestamp-trend formula, since DSH usage
|
|
9
|
+
* records only carry the last patched timestamp).
|
|
10
|
+
* @module @deepseek-ai/dsh-evolution-core
|
|
11
|
+
*/
|
|
12
|
+
import type { UsageMap } from './usage.ts';
|
|
13
|
+
export interface QualityFactors {
|
|
14
|
+
/** 0.25 — use_count per day of age, capped at 1. */
|
|
15
|
+
usageFrequency: number;
|
|
16
|
+
/** 0.20 — 1 − patch/use (zero use = stable). */
|
|
17
|
+
stability: number;
|
|
18
|
+
/** 0.20 — 1 under 30 idle days, linear decay to 0 at 180. */
|
|
19
|
+
recency: number;
|
|
20
|
+
/** 0.10 — in-degree / 3 (graph references), capped at 1. */
|
|
21
|
+
references: number;
|
|
22
|
+
/** 0.20 — patch cadence maturity (DSH approximation of the trend formula). */
|
|
23
|
+
mutationMaturity: number;
|
|
24
|
+
/** 0.05 — non-empty support subdirectories × 0.175, capped at 1. */
|
|
25
|
+
richness: number;
|
|
26
|
+
}
|
|
27
|
+
export interface QualityScore {
|
|
28
|
+
score: number;
|
|
29
|
+
factors: QualityFactors;
|
|
30
|
+
warn: boolean;
|
|
31
|
+
}
|
|
32
|
+
export declare const QUALITY_WEIGHTS: {
|
|
33
|
+
readonly usageFrequency: 0.25;
|
|
34
|
+
readonly stability: 0.2;
|
|
35
|
+
readonly recency: 0.2;
|
|
36
|
+
readonly references: 0.1;
|
|
37
|
+
readonly mutationMaturity: 0.2;
|
|
38
|
+
readonly richness: 0.05;
|
|
39
|
+
};
|
|
40
|
+
/** Score below which a skill is flagged for review. */
|
|
41
|
+
export declare const LOW_QUALITY_THRESHOLD = 0.3;
|
|
42
|
+
export declare function computeQualityScores(input: {
|
|
43
|
+
usage: UsageMap;
|
|
44
|
+
referenceCounts?: ReadonlyMap<string, number>;
|
|
45
|
+
supportDirs?: ReadonlyMap<string, number>;
|
|
46
|
+
now?: Date;
|
|
47
|
+
}): Map<string, QualityScore>;
|
|
48
|
+
/**
|
|
49
|
+
* Two-phase near-duplicate clustering: exact normalized-hash groups first,
|
|
50
|
+
* then token-Jaccard edges at {@link DEDUP_SIMILARITY_THRESHOLD} with a token
|
|
51
|
+
* ratio guard, union-find across the whole set.
|
|
52
|
+
*/
|
|
53
|
+
export declare function computeDedupGroups(input: {
|
|
54
|
+
contents: ReadonlyMap<string, string>;
|
|
55
|
+
threshold?: number;
|
|
56
|
+
}): string[][];
|
|
57
|
+
/**
|
|
58
|
+
* Prefix-cluster index over a name set (rc.67 merge heuristic, input side):
|
|
59
|
+
* the curator prompt asks the model to identify "prefix clusters — skills
|
|
60
|
+
* sharing a first word or domain keyword"; the deterministic index supplies
|
|
61
|
+
* stable ground truth instead of letting the model infer clusters from the
|
|
62
|
+
* raw list. Key = first alphanumeric run of the lowercased name; groups with
|
|
63
|
+
* at least two members, largest first then alphabetical. Orientation-only:
|
|
64
|
+
* nomination authority stays with the LLM and the candidate-pool gates.
|
|
65
|
+
*/
|
|
66
|
+
export declare function computePrefixClusters(names: ReadonlyArray<string>): Array<{
|
|
67
|
+
key: string;
|
|
68
|
+
members: string[];
|
|
69
|
+
}>;
|
|
70
|
+
//# sourceMappingURL=quality.d.ts.map
|
|
@@ -7,11 +7,8 @@
|
|
|
7
7
|
* move to `.archive/` — never a hard delete.
|
|
8
8
|
*/
|
|
9
9
|
import { type EvolutionIoLike } from './io.ts';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export declare const MAX_DESCRIPTION_LENGTH = 1024;
|
|
13
|
-
export declare const MAX_SKILL_CONTENT_CHARS = 100000;
|
|
14
|
-
export declare const MAX_SKILL_FILE_BYTES = 1048576;
|
|
10
|
+
import { type MutationRecord } from './mutations.ts';
|
|
11
|
+
import type { EvolutionSkillMutatedEvent } from './events.ts';
|
|
15
12
|
export interface SkillLimits {
|
|
16
13
|
maxNameLength: number;
|
|
17
14
|
maxDescriptionLength: number;
|
|
@@ -19,7 +16,6 @@ export interface SkillLimits {
|
|
|
19
16
|
maxSkillFileBytes: number;
|
|
20
17
|
}
|
|
21
18
|
export declare const DEFAULT_SKILL_LIMITS: SkillLimits;
|
|
22
|
-
export declare const SUPPORT_DIRS: readonly ["references", "templates", "scripts", "assets"];
|
|
23
19
|
export interface SkillSummary {
|
|
24
20
|
name: string;
|
|
25
21
|
description: string;
|
|
@@ -33,7 +29,52 @@ export interface SkillActionResult {
|
|
|
33
29
|
message: string;
|
|
34
30
|
path?: string;
|
|
35
31
|
}
|
|
32
|
+
/** Extra file name carried inside a snapshot's `extras/` directory. */
|
|
33
|
+
export declare const SNAPSHOT_EXTRA_NAME_RE: RegExp;
|
|
34
|
+
/** An opaque side file stored under a snapshot's `extras/` (curator state etc.). */
|
|
35
|
+
export interface SnapshotExtra {
|
|
36
|
+
name: string;
|
|
37
|
+
content: string;
|
|
38
|
+
}
|
|
39
|
+
/** Normalized manifest of a skills snapshot. */
|
|
40
|
+
export interface SnapshotManifest {
|
|
41
|
+
reason: string;
|
|
42
|
+
createdAt: string;
|
|
43
|
+
/** Active skill names at snapshot time. */
|
|
44
|
+
skills: string[];
|
|
45
|
+
/** Co-copied sidecar file names (usage/suppression). */
|
|
46
|
+
sidecars: string[];
|
|
47
|
+
/** Whether `.archive/` was co-copied; absent on legacy manifests (do not touch archive on restore). */
|
|
48
|
+
hasArchive?: boolean;
|
|
49
|
+
/** Extras declared under `extras/`; only these names are ever read back. */
|
|
50
|
+
extras: string[];
|
|
51
|
+
}
|
|
52
|
+
/** Who is writing: a foreground user-directed tool call, or the autonomous review/curator pipeline. */
|
|
53
|
+
export type WriteOrigin = 'foreground' | 'subagent' | 'background_review';
|
|
54
|
+
/** Options for `SkillLibrary.archive`. The absorbed-into name and the archival reason are distinct fields. */
|
|
55
|
+
export interface ArchiveOptions {
|
|
56
|
+
/** Umbrella skill this one was consolidated into; when set it must exist (consolidate semantics). */
|
|
57
|
+
absorbedInto?: string;
|
|
58
|
+
/** Human-readable reason written to `.archive-reason`; default derives from `absorbedInto`. */
|
|
59
|
+
reason?: string;
|
|
60
|
+
/** Permit archiving a bundled skill (curator prune-builtins only; hub-installed and pinned stay protected). */
|
|
61
|
+
allowBundled?: boolean;
|
|
62
|
+
}
|
|
36
63
|
export declare function skillsRoot(env?: NodeJS.ProcessEnv): string;
|
|
64
|
+
/**
|
|
65
|
+
* Map a requesting session onto the two origin surfaces (rc.44 plan M2-2.3):
|
|
66
|
+
* the APPROVAL surface treats every delegated subagent as the autonomous
|
|
67
|
+
* review channel, while the LIBRARY surface keeps the Hermes distinction -
|
|
68
|
+
* the review fork is 'background_review' (the pinned guard blocks its
|
|
69
|
+
* writes) and any other subagent is 'subagent' (agent-authored, not
|
|
70
|
+
* review-channel). `isReview` marks the caller as the background review
|
|
71
|
+
* pipeline itself. Single source: the two tools and the review executor all
|
|
72
|
+
* read this table instead of re-deriving it.
|
|
73
|
+
*/
|
|
74
|
+
export declare function resolveOrigins(headerOrigin: string | undefined, isReview?: boolean): {
|
|
75
|
+
approval: 'foreground' | 'background_review';
|
|
76
|
+
library: WriteOrigin;
|
|
77
|
+
};
|
|
37
78
|
export interface Frontmatter {
|
|
38
79
|
name?: string;
|
|
39
80
|
description?: string;
|
|
@@ -43,41 +84,132 @@ export declare function parseFrontmatter(content: string): {
|
|
|
43
84
|
frontmatter: Frontmatter;
|
|
44
85
|
body: string;
|
|
45
86
|
} | null;
|
|
87
|
+
/**
|
|
88
|
+
* Skill names referenced by a SKILL.md's `related_skills` frontmatter
|
|
89
|
+
* (B-line G3, rc.44): the single parsing source for the quality references
|
|
90
|
+
* factor and the learning-graph edges. The DSH frontmatter parser keeps the
|
|
91
|
+
* YAML value as a string (`"[a, b]"`), so names are scanned out of it; each
|
|
92
|
+
* must satisfy the skill-name shape and the referencing skill itself is
|
|
93
|
+
* excluded. Pure and deduplicated.
|
|
94
|
+
*/
|
|
95
|
+
export declare function relatedSkillNames(content: string, exclude?: string): string[];
|
|
46
96
|
export declare function validateFrontmatter(content: string, expectedName?: string, limits?: SkillLimits): string | null;
|
|
97
|
+
/** Hermes authoring quality bar for descriptions (the 60-char Rule). The
|
|
98
|
+
* platform's own index limit stays in `validateFrontmatter`; this bar is the
|
|
99
|
+
* target the authoring standard names, enforced as ADVISORY feedback. */
|
|
100
|
+
export declare const AUTHORING_DESCRIPTION_BAR = 60;
|
|
101
|
+
export interface AuthoringFeedback {
|
|
102
|
+
/** Frontmatter description length in characters (0 when absent). */
|
|
103
|
+
descriptionChars: number;
|
|
104
|
+
/** Whether the description exceeds the authoring bar (60) while still passing the platform limit. */
|
|
105
|
+
over60: boolean;
|
|
106
|
+
/** Whether the description contains a colon (the standard requires double-quote wrapping). */
|
|
107
|
+
hasColon: boolean;
|
|
108
|
+
/** Advice lines appended to mutation success messages. */
|
|
109
|
+
lines: string[];
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Advisory authoring feedback (P0): evaluate frontmatter against the
|
|
113
|
+
* authoring bar WITHOUT changing platform validation semantics. The bar is
|
|
114
|
+
* the quality target, `validateFrontmatter`'s limits are the compatibility
|
|
115
|
+
* floor, and this bridge layer tells the model when its text would be
|
|
116
|
+
* truncated or route-poor instead of silently shipping it.
|
|
117
|
+
*/
|
|
118
|
+
export declare function authoringFeedback(frontmatter: Frontmatter): AuthoringFeedback;
|
|
47
119
|
export declare class SkillLibrary {
|
|
48
120
|
readonly root: string;
|
|
49
121
|
readonly limits: SkillLimits;
|
|
50
122
|
private readonly io;
|
|
51
|
-
|
|
123
|
+
private readonly onMutation;
|
|
124
|
+
constructor(root?: string, io?: EvolutionIoLike, limits?: SkillLimits, onMutation?: (event: EvolutionSkillMutatedEvent) => void);
|
|
125
|
+
/** Notify the mutation observer after a successful write; observers must never fail the mutation. */
|
|
126
|
+
private notifyMutation;
|
|
52
127
|
list(): Promise<SkillSummary[]>;
|
|
53
|
-
read(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
128
|
+
read(rawName: string): Promise<string | null>;
|
|
129
|
+
/**
|
|
130
|
+
|
|
131
|
+
* Single path-building choke point (rc.42 audit P2-5): every directory path
|
|
132
|
+
|
|
133
|
+
* is built from the TRIMMED name, so a name that passes `badName` (which
|
|
134
|
+
|
|
135
|
+
* trims before validating) can never mint a second, whitespace-padded
|
|
136
|
+
|
|
137
|
+
* directory next to the real one. Callers keep passing raw user input.
|
|
138
|
+
|
|
139
|
+
*/
|
|
140
|
+
private dirOf;
|
|
141
|
+
/** Name-format guard shared by every path-building mutator/reader. */
|
|
142
|
+
private badName;
|
|
143
|
+
writeProtection(rawName: string, origin?: WriteOrigin): Promise<string | null>;
|
|
144
|
+
deleteProtection(rawName: string, options?: {
|
|
145
|
+
allowBundled?: boolean;
|
|
146
|
+
}): Promise<string | null>;
|
|
147
|
+
isManaged(rawName: string): Promise<boolean>;
|
|
148
|
+
/** Whether the skill carries the bundled marker (curator prune-builtins eligibility). */
|
|
149
|
+
isBundled(rawName: string): Promise<boolean>;
|
|
150
|
+
/** Whether the skill carries the pinned marker (the marker is the factual source; usage.pinned mirrors it). */
|
|
151
|
+
isPinned(rawName: string): Promise<boolean>;
|
|
152
|
+
/** Count non-empty support subdirectories (richness input for quality scoring). */
|
|
153
|
+
countSupportDirs(rawName: string): Promise<number>;
|
|
154
|
+
/** Best-effort audit trail entry; never blocks the mutation. */
|
|
155
|
+
private audit;
|
|
156
|
+
/** Recent mutation audit records (read-only inspection surface). */
|
|
157
|
+
listMutations(): Promise<MutationRecord[]>;
|
|
158
|
+
/**
|
|
159
|
+
* Pin or unpin a skill (`.pinned` marker). Pinned skills are protected from
|
|
160
|
+
* deletion, from background-review writes, and from the lifecycle — a
|
|
161
|
+
* protective mutation, so the autonomous pipeline may never call it. The
|
|
162
|
+
* marker write is the only state change; content is untouched.
|
|
163
|
+
*/
|
|
164
|
+
setPinned(name: string, pinned: boolean, origin?: WriteOrigin): Promise<SkillActionResult>;
|
|
165
|
+
create(name: string, content: string, origin?: WriteOrigin): Promise<SkillActionResult>;
|
|
166
|
+
update(rawName: string, content: string, origin?: WriteOrigin): Promise<SkillActionResult>;
|
|
167
|
+
patch(rawName: string, oldString: string, newString: string, filePath?: string, replaceAll?: boolean, origin?: WriteOrigin): Promise<SkillActionResult>;
|
|
168
|
+
archive(rawName: string, options?: ArchiveOptions): Promise<SkillActionResult>;
|
|
61
169
|
/**
|
|
62
170
|
* Merge the bodies of `sources` into `target` and archive the sources with
|
|
63
171
|
* an absorbed-into marker. Hermes-style consolidation: overlapping skills
|
|
64
172
|
* collapse into one, and the originals stay recoverable under `.archive/`.
|
|
65
173
|
*/
|
|
66
|
-
consolidate(target: string, sources: string[]): Promise<SkillActionResult>;
|
|
174
|
+
consolidate(target: string, sources: string[], origin?: WriteOrigin): Promise<SkillActionResult>;
|
|
67
175
|
/**
|
|
68
176
|
* Restore one skill from `.archive/` back to the active root. Hermes-style
|
|
69
177
|
* recoverability: archival never deletes, and this is the control-plane
|
|
70
178
|
* path back. The `.archive-reason` marker is dropped on restore.
|
|
71
179
|
*/
|
|
72
|
-
restoreFromArchive(
|
|
73
|
-
writeSupportFile(
|
|
74
|
-
removeSupportFile(
|
|
75
|
-
|
|
180
|
+
restoreFromArchive(rawName: string): Promise<SkillActionResult>;
|
|
181
|
+
writeSupportFile(rawName: string, filePath: string, content: string, origin?: WriteOrigin): Promise<SkillActionResult>;
|
|
182
|
+
removeSupportFile(rawName: string, filePath: string, origin?: WriteOrigin): Promise<SkillActionResult>;
|
|
183
|
+
/**
|
|
184
|
+
* Snapshot the recoverable skills state: active tree, usage/suppression
|
|
185
|
+
* sidecars, `.archive/` and caller-supplied extras. `extras` are opaque
|
|
186
|
+
* side files the Snapshot owner cares about (curator state); they are
|
|
187
|
+
* listed in the manifest and only those names are ever read back.
|
|
188
|
+
*/
|
|
189
|
+
snapshotAll(reason?: string, extras?: SnapshotExtra[]): Promise<string>;
|
|
190
|
+
/** Read and normalize a snapshot manifest; null when the file is missing or unparsable. */
|
|
191
|
+
readSnapshotManifest(path: string): Promise<SnapshotManifest | null>;
|
|
192
|
+
/** Keep only the newest N snapshots (Hermes keep=5 parity); older ones are removed outright. */
|
|
193
|
+
private retainSnapshots;
|
|
76
194
|
listSnapshots(): Promise<Array<{
|
|
77
195
|
path: string;
|
|
78
196
|
createdAt: string;
|
|
79
197
|
reason: string;
|
|
80
198
|
}>>;
|
|
81
|
-
|
|
199
|
+
/**
|
|
200
|
+
* Read the extras of a snapshot, restricted to the names declared in the
|
|
201
|
+
* manifest — an `extras/` directory is never listed directly, so unknown
|
|
202
|
+
* files cannot leak back as state on the next restore.
|
|
203
|
+
*/
|
|
204
|
+
readSnapshotExtras(path: string): Promise<SnapshotExtra[]>;
|
|
205
|
+
/**
|
|
206
|
+
* Manifest-driven restore of the latest snapshot: active tree, sidecars,
|
|
207
|
+
* `.archive/` and (for full-state snapshots) the extras read back by the
|
|
208
|
+
* caller. `extras` are additionally written into the pre-rollback safety
|
|
209
|
+
* snapshot so the rollback itself is undoable with the same state.
|
|
210
|
+
*/
|
|
211
|
+
restoreLatestSnapshot(extras?: SnapshotExtra[]): Promise<SkillActionResult & {
|
|
212
|
+
extras?: SnapshotExtra[];
|
|
213
|
+
}>;
|
|
82
214
|
}
|
|
83
215
|
//# sourceMappingURL=skill-store.d.ts.map
|
|
@@ -1,19 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Evolution home path helper: `$DSH_HOME/evolution` for plugin-owned sidecar
|
|
3
|
+
* state (reports, activity store, feedback file, state-domain data).
|
|
4
4
|
*/
|
|
5
5
|
export declare function evolutionHome(env?: NodeJS.ProcessEnv): string;
|
|
6
|
-
export declare class JsonState<T> {
|
|
7
|
-
private readonly initial;
|
|
8
|
-
readonly path: string;
|
|
9
|
-
private value;
|
|
10
|
-
constructor(name: string, initial: T, env?: NodeJS.ProcessEnv);
|
|
11
|
-
private loadSync;
|
|
12
|
-
get(): T;
|
|
13
|
-
set(value: T): void;
|
|
14
|
-
update(mutator: (value: T) => void): void;
|
|
15
|
-
flush(): Promise<void>;
|
|
16
|
-
/** Merge-on-load helper for persisted maps/records. */
|
|
17
|
-
reload(): Promise<void>;
|
|
18
|
-
}
|
|
19
6
|
//# sourceMappingURL=state-store.d.ts.map
|
package/lib/types/threats.d.ts
CHANGED
|
@@ -12,17 +12,29 @@ export interface ThreatFinding {
|
|
|
12
12
|
category: string;
|
|
13
13
|
scope: ThreatScope;
|
|
14
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Optional scan controls. Default behavior (`options` omitted) is unchanged:
|
|
17
|
+
* every in-scope pattern blocks. Adapters that need to tolerate a specific
|
|
18
|
+
* benign phrasing (e.g. a skill that legitimately opens with "You are now a ...")
|
|
19
|
+
* can exclude that label by name here. This is opt-in and never widens strict
|
|
20
|
+
* scope; it only permits callers to drop a known-innocent match.
|
|
21
|
+
*/
|
|
22
|
+
export interface ScanOptions {
|
|
23
|
+
/** Pattern labels to skip during this scan. */
|
|
24
|
+
excludeLabels?: readonly string[];
|
|
25
|
+
}
|
|
15
26
|
/**
|
|
16
27
|
* Scan text at `scope`. Patterns are cumulative: `strict` includes all scopes.
|
|
28
|
+
* `options.excludeLabels` removes matching patterns without changing `scope`.
|
|
17
29
|
*/
|
|
18
|
-
export declare function scanThreats(text: string, scope?: ThreatScope, maxScanChars?: number): ThreatFinding[];
|
|
30
|
+
export declare function scanThreats(text: string, scope?: ThreatScope, maxScanChars?: number, options?: ScanOptions): ThreatFinding[];
|
|
19
31
|
/** Blocking policy: any hit blocks. `severity` is deliberately not a gate. */
|
|
20
|
-
export declare function evaluateThreat(text: string, scope?: ThreatScope, maxScanChars?: number): {
|
|
32
|
+
export declare function evaluateThreat(text: string, scope?: ThreatScope, maxScanChars?: number, options?: ScanOptions): {
|
|
21
33
|
blocked: boolean;
|
|
22
34
|
findings: ThreatFinding[];
|
|
23
35
|
};
|
|
24
36
|
/** User-facing block message for memory writes. */
|
|
25
|
-
export declare function scanMemoryThreats(text: string, maxScanChars?: number): string | null;
|
|
37
|
+
export declare function scanMemoryThreats(text: string, maxScanChars?: number, options?: ScanOptions): string | null;
|
|
26
38
|
/** User-facing block message for skill content writes. */
|
|
27
|
-
export declare function scanContentThreats(text: string, maxScanChars?: number): string | null;
|
|
39
|
+
export declare function scanContentThreats(text: string, maxScanChars?: number, options?: ScanOptions): string | null;
|
|
28
40
|
//# sourceMappingURL=threats.d.ts.map
|
package/lib/types/usage.d.ts
CHANGED
|
@@ -16,13 +16,63 @@ export interface UsageRecord {
|
|
|
16
16
|
state: SkillState;
|
|
17
17
|
pinned: boolean;
|
|
18
18
|
archived_at: string | null;
|
|
19
|
-
quality_score?: number;
|
|
20
|
-
quality_warn?: boolean;
|
|
19
|
+
quality_score?: number | undefined;
|
|
20
|
+
quality_warn?: boolean | undefined;
|
|
21
21
|
}
|
|
22
22
|
export type UsageMap = Map<string, UsageRecord>;
|
|
23
23
|
export declare function usageFile(root: string): string;
|
|
24
24
|
export declare function emptyRecord(): UsageRecord;
|
|
25
|
+
/**
|
|
26
|
+
* Field-level normalization for one sidecar record (rc.42 audit P2-3): the
|
|
27
|
+
* spread used to copy any junk through verbatim, so a corrupted file could
|
|
28
|
+
* carry `use_count: "3"` into the quality math and lifecycle comparisons as
|
|
29
|
+
* NaN. Every field falls back to its `emptyRecord()` baseline unless it has
|
|
30
|
+
* exactly the declared type; an invalid `created_at` anchors the age clock at
|
|
31
|
+
* now (first-sight defer semantics for a record whose age is unknowable).
|
|
32
|
+
* Timestamps additionally require a parseable date (N-3): `"not-a-date"`
|
|
33
|
+
* would otherwise survive the type check as Invalid Date.
|
|
34
|
+
* Pure — exported for unit tests; `loadUsage` is the production caller.
|
|
35
|
+
*/
|
|
36
|
+
export declare function normalizeUsageRecord(record: unknown): UsageRecord;
|
|
25
37
|
export declare function loadUsage(root: string, io?: EvolutionIoLike): Promise<UsageMap>;
|
|
38
|
+
/**
|
|
39
|
+
* Atomic read-modify-write on the usage sidecar (rc.50 P2-2): `task` receives
|
|
40
|
+
* the map parsed from the current on-disk state and may mutate it; the result
|
|
41
|
+
* is persisted inside the same transact so a second process sharing DSH_HOME
|
|
42
|
+
* cannot interleave its RMW and lose a counter update. Callers keep their own
|
|
43
|
+
* single-process serialize chain as the second layer.
|
|
44
|
+
*/
|
|
45
|
+
export declare function mutateUsage(root: string, io: EvolutionIoLike, task: (map: UsageMap) => void | Promise<void>): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Curator-owned usage fields (rc.67 K-2): the curator writes ONLY this set —
|
|
48
|
+
* lifecycle state, archive stamp, the six-factor quality pair, and the
|
|
49
|
+
* marker-mirrored pin flag. Counter and activity-stamp fields belong to the
|
|
50
|
+
* tool-telemetry side (skill-usage / tool-skill-manage), which bumps them
|
|
51
|
+
* through its own transact-backed RMW. A whole-record overwrite by either
|
|
52
|
+
* side would clobber the other side's concurrent increment, so cross-side
|
|
53
|
+
* folds copy this set only.
|
|
54
|
+
*/
|
|
55
|
+
export declare function applyCuratorFields(disk: UsageRecord, curated: UsageRecord): void;
|
|
56
|
+
/** Copy only the lifecycle pair (state/archived_at) — see the ownership split
|
|
57
|
+
* rationale on {@link applyCuratorMetaFields}. */
|
|
58
|
+
export declare function applyCuratorLifecycleFields(disk: UsageRecord, curated: UsageRecord): void;
|
|
59
|
+
/**
|
|
60
|
+
* Copy the recomputed meta pair (quality_score/quality_warn + the
|
|
61
|
+
* marker-mirrored pin flag) — refreshed tree-wide each run by design, so a
|
|
62
|
+
* concurrent curator run's lifecycle changes are never reverted by them.
|
|
63
|
+
*/
|
|
64
|
+
export declare function applyCuratorMetaFields(disk: UsageRecord, curated: UsageRecord): void;
|
|
65
|
+
/**
|
|
66
|
+
* Fold a curator run-start snapshot onto the current on-disk map (rc.67 K-2):
|
|
67
|
+
* each curated record is projected onto its disk peer by copying only the
|
|
68
|
+
* curator-owned fields, so a concurrent tool-side bump between snapshot and
|
|
69
|
+
* save survives. Records absent from the snapshot are left untouched; a
|
|
70
|
+
* curated record with no disk peer is seeded from the snapshot. `stateOwned`
|
|
71
|
+
* (rc.72 H-1) restricts the lifecycle pair to the names this run ACTUALLY
|
|
72
|
+
* transitioned — a concurrent curator run's archive/restore is never reverted
|
|
73
|
+
* by a stale snapshot; without it both pairs apply everywhere.
|
|
74
|
+
*/
|
|
75
|
+
export declare function foldCuratorFields(disk: UsageMap, curated: UsageMap, stateOwned?: ReadonlySet<string>): void;
|
|
26
76
|
export declare function saveUsage(root: string, map: UsageMap, io?: EvolutionIoLike): Promise<void>;
|
|
27
77
|
export declare function getRecord(map: UsageMap, name: string): UsageRecord;
|
|
28
78
|
export declare function bumpView(map: UsageMap, name: string, when?: Date): void;
|
|
@@ -30,4 +80,21 @@ export declare function bumpUse(map: UsageMap, name: string, when?: Date): void;
|
|
|
30
80
|
export declare function bumpPatch(map: UsageMap, name: string, when?: Date): void;
|
|
31
81
|
export declare function markAgentCreated(map: UsageMap, name: string): void;
|
|
32
82
|
export declare function latestActivityAt(record: UsageRecord): string | null;
|
|
83
|
+
/**
|
|
84
|
+
* Curator suppression sidecar: built-in skills the curator has archived stay
|
|
85
|
+
* suppressed across re-seeds, so the lifecycle never fights a re-created
|
|
86
|
+
* bundled skill. Best-effort load/save, mirroring the usage sidecar posture.
|
|
87
|
+
* Versioned shape ({ version, names }) with legacy plain-array compat.
|
|
88
|
+
*/
|
|
89
|
+
export declare const SUPPRESSED_FILE_VERSION = 1;
|
|
90
|
+
export declare function suppressedFile(root: string): string;
|
|
91
|
+
export declare function loadSuppressedNames(root: string, io?: EvolutionIoLike): Promise<ReadonlySet<string>>;
|
|
92
|
+
export declare function saveSuppressedNames(root: string, names: ReadonlySet<string>, io?: EvolutionIoLike): Promise<void>;
|
|
93
|
+
/**
|
|
94
|
+
* Atomic read-modify-write on the suppression sidecar (rc.50 P2-2): `task`
|
|
95
|
+
* receives the set parsed from the current on-disk state and may mutate it;
|
|
96
|
+
* the result is persisted inside the same transact so a second process
|
|
97
|
+
* sharing DSH_HOME cannot interleave its RMW. Best-effort posture unchanged.
|
|
98
|
+
*/
|
|
99
|
+
export declare function updateSuppressedNames(root: string, io: EvolutionIoLike, task: (names: Set<string>) => void | Promise<void>): Promise<void>;
|
|
33
100
|
//# sourceMappingURL=usage.d.ts.map
|
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.1.0
|
|
4
|
+
"version": "0.1.0",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -32,13 +32,13 @@
|
|
|
32
32
|
],
|
|
33
33
|
"license": "MIT",
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"@deepseek-ai/dsh-invariants": "^0.1.
|
|
35
|
+
"@deepseek-ai/dsh-invariants": "^0.1.1-rc.2",
|
|
36
36
|
"@deepseek-ai/cordis": "^4.0.1",
|
|
37
|
-
"@deepseek-ai/dsh-session": "^0.1.
|
|
37
|
+
"@deepseek-ai/dsh-session": "^0.1.1-rc.2"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@deepseek-ai/dsh-invariants": "^0.1.
|
|
40
|
+
"@deepseek-ai/dsh-invariants": "^0.1.1-rc.2",
|
|
41
41
|
"@deepseek-ai/cordis": "^4.0.1",
|
|
42
|
-
"@deepseek-ai/dsh-session": "^0.1.
|
|
42
|
+
"@deepseek-ai/dsh-session": "^0.1.1-rc.2"
|
|
43
43
|
}
|
|
44
44
|
}
|