@lmzhen/dsh-evolution-core 0.1.0-rc.2 → 0.1.0-rc.21

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.
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Shared constants for the dsh-evolution plugin family.
3
+ *
4
+ * Two classes of value live here, deliberately separated by section so future
5
+ * edits do not blur the semantic boundary:
6
+ *
7
+ * 1. **Fixed protocol/format/security invariants** — changing these breaks an
8
+ * on-disk format, a naming/format contract, a path-security boundary, or a
9
+ * cross-component invariant. They are NOT exposed as deployment config.
10
+ *
11
+ * 2. **Cross-package shared tunable defaults** — the same semantic default is
12
+ * read (with a config override path) by more than one package (e.g.
13
+ * `evolution-policy` and `evolution-curator` both default `staleAfterDays`
14
+ * to 30). Centralizing them here means one authoritative default: a config
15
+ * override still applies per package, but the fallback is single-sourced.
16
+ *
17
+ * Package-private tunables (used by exactly one package) stay in that package,
18
+ * not here — see evolution-replay's `DEFAULT_WEIGHTS` and evolution-feedback's
19
+ * threshold, which are intentionally left where they are used.
20
+ * @module @deepseek-ai/dsh-evolution-core
21
+ */
22
+ /** Skill frontmatter `name` validated for the file name (lowercase + hyphen). */
23
+ export declare const SKILL_NAME_RE: RegExp;
24
+ /** Allowed skill support-file subdirectories (path-traversal boundary). */
25
+ export declare const SUPPORT_DIRS: readonly ["references", "templates", "scripts", "assets"];
26
+ /** Delimiter between durable memory entries (on-disk storage format). */
27
+ export declare const ENTRY_DELIMITER = "\n\u00A7\n";
28
+ /** Built-in skill names the curator must never lifecycle-manage. */
29
+ export declare const PROTECTED_BUILTIN_SKILLS: ReadonlySet<string>;
30
+ export declare const MAX_SKILL_NAME_LENGTH = 64;
31
+ export declare const MAX_DESCRIPTION_LENGTH = 1024;
32
+ export declare const MAX_SKILL_CONTENT_CHARS = 100000;
33
+ export declare const MAX_SKILL_FILE_BYTES = 1048576;
34
+ export declare const DEFAULT_REVIEW_MEMORY_INTERVAL = 10;
35
+ export declare const DEFAULT_REVIEW_SKILL_INTERVAL = 10;
36
+ /** Skill-review completion channel trigger mode: 'cadence' | 'completion' | 'both'. */
37
+ export declare const DEFAULT_SKILL_REVIEW_TRIGGER: "both";
38
+ /** Cumulative session tool calls before a session counts as "proven long" for the completion channel. */
39
+ export declare const DEFAULT_SKILL_REVIEW_COMPLETION_MIN_TOOL_CALLS = 20;
40
+ export declare const DEFAULT_SUBSTANTIVE_MIN_TOOL_CALLS = 3;
41
+ export declare const DEFAULT_SUBSTANTIVE_MIN_USER_CHARS = 200;
42
+ export declare const DEFAULT_SUBSTANTIVE_MIN_AGENT_CHARS = 500;
43
+ export declare const DEFAULT_MAX_OPS_PER_PLAN = 32;
44
+ export declare const DEFAULT_CURATOR_INTERVAL_HOURS = 168;
45
+ export declare const DEFAULT_MIN_IDLE_HOURS = 2;
46
+ export declare const DEFAULT_STALE_AFTER_DAYS = 30;
47
+ export declare const DEFAULT_ARCHIVE_AFTER_DAYS = 90;
48
+ export declare const DEFAULT_MEMORY_CHAR_LIMIT = 2200;
49
+ export declare const DEFAULT_USER_CHAR_LIMIT = 1375;
50
+ export declare const DEFAULT_SKILL_CONTENT_CHARS = 100000;
51
+ //# sourceMappingURL=constants.d.ts.map
@@ -3,6 +3,7 @@
3
3
  * Pure function; file moves are performed by SkillLibrary.
4
4
  */
5
5
  import type { UsageMap } from './usage.ts';
6
+ export { PROTECTED_BUILTIN_SKILLS } from './constants.ts';
6
7
  export interface CuratorConfig {
7
8
  staleAfterDays: number;
8
9
  archiveAfterDays: number;
@@ -12,6 +13,14 @@ export interface CuratorConfig {
12
13
  excludeSkillNames?: ReadonlySet<string>;
13
14
  /** When true, usage records without created_by='agent' also enter the lifecycle. */
14
15
  manageUnmanaged?: boolean;
16
+ /** When true, bundled skills (in `bundledNames`) are curation candidates like agent-created ones. */
17
+ pruneBuiltins?: boolean;
18
+ /** Skill names carrying the bundled marker; only read when `pruneBuiltins` is true. */
19
+ bundledNames?: ReadonlySet<string>;
20
+ /** Skill names the curator archived once and must not fight across re-seeds. */
21
+ suppressedNames?: ReadonlySet<string>;
22
+ /** Skills referenced by scheduled/automated jobs: never auto-transitioned (idle clocks mislead for rarely-firing tasks). */
23
+ referencedSkillNames?: ReadonlySet<string>;
15
24
  }
16
25
  export interface CuratorTransition {
17
26
  name: string;
@@ -25,7 +34,6 @@ export interface CuratorResult {
25
34
  reactivate: string[];
26
35
  markStale: string[];
27
36
  }
28
- export declare const PROTECTED_BUILTIN_SKILLS: ReadonlySet<string>;
29
37
  export interface CuratorArchivedSkill {
30
38
  name: string;
31
39
  path: string;
@@ -36,6 +44,8 @@ export interface CuratorFailedSkill {
36
44
  reason: string;
37
45
  }
38
46
  export interface CuratorRunReport {
47
+ /** Report shape version; readers may ignore unknown fields on later versions. */
48
+ schemaVersion: 1;
39
49
  runId: string;
40
50
  startedAt: string;
41
51
  finishedAt: string;
@@ -58,5 +68,21 @@ export interface CuratorReportInput {
58
68
  snapshotPath?: string;
59
69
  }
60
70
  export declare function buildCuratorRunReport(input: CuratorReportInput): CuratorRunReport;
71
+ /** One LLM-nominated consolidation: `from` merges into the umbrella `into`. */
72
+ export interface CuratorConsolidation {
73
+ from: string;
74
+ into: string;
75
+ }
76
+ /** Structured result of the optional curator LLM nomination pass. */
77
+ export interface CuratorNominations {
78
+ prunings: string[];
79
+ consolidations: CuratorConsolidation[];
80
+ }
81
+ /**
82
+ * Parse the curator LLM's YAML nomination block (consolidations + prunings).
83
+ * Line-oriented and lenient by design: the LLM output is advisory, every name
84
+ * is re-validated against the tree before any file move happens downstream.
85
+ */
86
+ export declare function parseCuratorNominations(text: string): CuratorNominations;
61
87
  export declare function computeLifecycleTransitions(usage: UsageMap, config: CuratorConfig, now?: Date): CuratorResult;
62
88
  //# sourceMappingURL=curator.d.ts.map
@@ -11,10 +11,13 @@ export * from './curator.ts';
11
11
  export * from './events.ts';
12
12
  export * from './io.ts';
13
13
  export * from './memory-store.ts';
14
+ export * from './mutations.ts';
14
15
  export * from './prompts.ts';
16
+ export * from './quality.ts';
15
17
  export * from './signals.ts';
16
18
  export * from './skill-store.ts';
17
19
  export * from './state-store.ts';
18
20
  export * from './threats.ts';
19
21
  export * from './usage.ts';
22
+ export * from './constants.ts';
20
23
  //# sourceMappingURL=index.d.ts.map
package/lib/types/io.d.ts CHANGED
@@ -17,6 +17,4 @@ export interface EvolutionIoLike {
17
17
  /** Lazy adapter over an IO provider registry, shared by every evolution consumer. */
18
18
  export declare function evolutionIoAdapter(provider: () => EvolutionIoLike): EvolutionIoLike;
19
19
  export declare function nodeEvolutionIo(): EvolutionIoLike;
20
- /** Absolute path helper kept separate so stores stay platform-correct. */
21
- export declare function childPath(parent: string, ...parts: string[]): string;
22
20
  //# sourceMappingURL=io.d.ts.map
@@ -3,7 +3,7 @@
3
3
  * Stores are MEMORY.md and USER.md under $DSH_HOME/memories (~/.dsh/memories).
4
4
  */
5
5
  import { type EvolutionIoLike } from './io.ts';
6
- export declare const ENTRY_DELIMITER = "\n\u00A7\n";
6
+ export { ENTRY_DELIMITER } from './constants.ts';
7
7
  export type MemoryTarget = 'memory' | 'user';
8
8
  export interface MemoryOperation {
9
9
  action: 'add' | 'replace' | 'remove';
@@ -41,6 +41,14 @@ export declare class MemoryStore {
41
41
  write(target: MemoryTarget, entries: string[]): Promise<void>;
42
42
  resetFailures(): void;
43
43
  private failure;
44
+ /** Percent-based storage hint appended to success message once the target is ≥80% full. */
45
+ private storageHint;
46
+ /**
47
+ * Best-effort copy of the drifted on-disk file to `<file>.bak.<stamp>` before
48
+ * refusing the write, so an external edit stays recoverable. Failure to back
49
+ * up does not change the refusal semantics.
50
+ */
51
+ private backupDrift;
44
52
  add(target: MemoryTarget, facts: string): Promise<MemoryApplyResult>;
45
53
  replace(target: MemoryTarget, oldText: string, facts: string): Promise<MemoryApplyResult>;
46
54
  remove(target: MemoryTarget, oldText: string): Promise<MemoryApplyResult>;
@@ -55,6 +63,14 @@ export declare class MemoryStore {
55
63
  memory: string[];
56
64
  user: string[];
57
65
  }): Promise<void>;
66
+ /**
67
+ * Detect on-disk drift: true when the file is not in the canonical
68
+ * `render(normalizeEntries(raw))` form. This catches structural anomalies
69
+ * the writer would quietly normalize away (empty/`§`-only entries, stray
70
+ * blank lines, leading/trailing delimiters) that indicate the file was
71
+ * edited outside MemoryStore. Purely single-canonical content reaches the
72
+ * same serialization and returns false, so a normal write is never flagged.
73
+ */
58
74
  detectDrift(target: MemoryTarget): Promise<boolean>;
59
75
  }
60
76
  //# sourceMappingURL=memory-store.d.ts.map
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Curator/author audit trail: `.mutations.json` records every skill mutation
3
+ * with before/after content hashes so any automated edit is reviewable and
4
+ * replayable. Best-effort persistence, mirroring the usage sidecar posture.
5
+ * @module @deepseek-ai/dsh-evolution-core
6
+ */
7
+ import { type EvolutionIoLike } from './io.ts';
8
+ export interface MutationRecord {
9
+ skillName: string;
10
+ action: string;
11
+ beforeHash?: string;
12
+ afterHash?: string;
13
+ summary: string;
14
+ at: string;
15
+ }
16
+ export declare const DEFAULT_MUTATION_CAP = 500;
17
+ /** Version of the `.mutations.json` file shape; writers always emit the current one. */
18
+ export declare const MUTATIONS_FILE_VERSION = 1;
19
+ export declare function mutationsFile(root: string): string;
20
+ export declare function contentHash(content: string): string;
21
+ export declare function loadMutations(root: string, io?: EvolutionIoLike): Promise<MutationRecord[]>;
22
+ /** Append one record, trim to `cap`, and write atomically (versioned shape). */
23
+ export declare function recordMutation(root: string, io: EvolutionIoLike, record: MutationRecord, cap?: number): Promise<void>;
24
+ //# sourceMappingURL=mutations.d.ts.map
@@ -1,8 +1,16 @@
1
- export declare const PROMPT_BUNDLE_ID = "dsh-evolution@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@2";
7
+ export declare const PROMPT_BUNDLE_VERSION = 2;
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
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.\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 skills.\n\nSignals that warrant action:\n- The user corrected your style, tone, format, verbosity, workflow, or approach.\n- A non-trivial technique, fix, workaround, or debugging path emerged.\n- A loaded skill turned out wrong, missing, or outdated \u2014 patch it now.\n\nPreference order:\n1. Patch a skill that was loaded or read this session.\n2. Patch an existing umbrella skill.\n3. Add references/, templates/, or scripts/ support under an existing skill.\n4. Create a new class-level umbrella skill only when nothing fits.\n\nProtected skills (bundled/hub-installed) must not be edited. Pinned skills may be patched but not archived.\n\nDo NOT capture:\n- Environment-dependent failures (missing binaries, unconfigured credentials).\n- Negative claims about tools (\"browser tools do not work\").\n- Transient errors that resolved during the session.\n- One-off task narratives.\n\nIf a tool failed because of setup state, capture the FIX under an existing setup 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.";
4
10
  export declare const COMBINED_REVIEW_PROMPT = "[Auto-review]\nReview the conversation above and update two things.\n\n**Memory**: who the user is. Save durable user preferences, personal details, and expectations with the memory tool.\n\n**Skills**: how to do this class of task. Be ACTIVE. Follow the same class-level umbrella policy, preference order, protected-skill rules, and do-not-capture list as a skill review.\n\nAct on whichever dimension 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.";
5
- export declare const CURATOR_PROMPT = "You are the skill curator. Maintain a healthy, class-level skill library.\n\nRules:\n1. NEVER hard-delete a skill. Archive is the maximum destructive action.\n2. Do not touch bundled, hub-installed, or pinned skills.\n3. Do not archive recently-created or never-used skills without strong evidence.\n4. Prefer merging narrow skills into class-level umbrellas.\n5. Before archiving a merged skill, ensure its unique content was preserved.\n\nProduce a YAML summary:\nconsolidations:\n - from: <old-skill-name>\n into: <umbrella-skill-name>\n reason: <one short sentence>\nprunings:\n - name: <skill-name>\n reason: <one short sentence>";
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\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 MAY be consolidated into an umbrella, but never simply pruned.\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.\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 (expect 10-25 clusters).\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.\n3. Keep the umbrella body tight and scannable: exact commands, verbatim paths, ~100-200 lines; never invent flags or APIs.\n\nProduce a YAML summary with exactly this shape:\nconsolidations:\n - from: <old-skill-name>\n into: <umbrella-skill-name>\n reason: <one short sentence>\nprunings:\n - name: <skill-name>\n reason: <one short sentence>\nNominate a pruning only when archival is clearly safe (stale AND genuinely obsolete or fully absorbed elsewhere).";
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 skills loaded 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.";
6
14
  export declare function reviewPrompt(kind: 'memory' | 'skill' | 'combined'): string;
7
15
  export interface PromptBundle {
8
16
  id: string;
@@ -0,0 +1,57 @@
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
+ //# sourceMappingURL=quality.d.ts.map
@@ -7,11 +7,7 @@
7
7
  * move to `.archive/` — never a hard delete.
8
8
  */
9
9
  import { type EvolutionIoLike } from './io.ts';
10
- export declare const SKILL_NAME_RE: RegExp;
11
- export declare const MAX_SKILL_NAME_LENGTH = 64;
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';
15
11
  export interface SkillLimits {
16
12
  maxNameLength: number;
17
13
  maxDescriptionLength: number;
@@ -19,7 +15,6 @@ export interface SkillLimits {
19
15
  maxSkillFileBytes: number;
20
16
  }
21
17
  export declare const DEFAULT_SKILL_LIMITS: SkillLimits;
22
- export declare const SUPPORT_DIRS: readonly ["references", "templates", "scripts", "assets"];
23
18
  export interface SkillSummary {
24
19
  name: string;
25
20
  description: string;
@@ -33,6 +28,17 @@ export interface SkillActionResult {
33
28
  message: string;
34
29
  path?: string;
35
30
  }
31
+ /** Who is writing: a foreground user-directed tool call, or the autonomous review/curator pipeline. */
32
+ export type WriteOrigin = 'foreground' | 'background_review';
33
+ /** Options for `SkillLibrary.archive`. The absorbed-into name and the archival reason are distinct fields. */
34
+ export interface ArchiveOptions {
35
+ /** Umbrella skill this one was consolidated into; when set it must exist (consolidate semantics). */
36
+ absorbedInto?: string;
37
+ /** Human-readable reason written to `.archive-reason`; default derives from `absorbedInto`. */
38
+ reason?: string;
39
+ /** Permit archiving a bundled skill (curator prune-builtins only; hub-installed and pinned stay protected). */
40
+ allowBundled?: boolean;
41
+ }
36
42
  export declare function skillsRoot(env?: NodeJS.ProcessEnv): string;
37
43
  export interface Frontmatter {
38
44
  name?: string;
@@ -51,15 +57,37 @@ export declare class SkillLibrary {
51
57
  constructor(root?: string, io?: EvolutionIoLike, limits?: SkillLimits);
52
58
  list(): Promise<SkillSummary[]>;
53
59
  read(name: string): Promise<string | null>;
54
- writeProtection(name: string): Promise<string | null>;
55
- deleteProtection(name: string): Promise<string | null>;
60
+ writeProtection(name: string, origin?: WriteOrigin): Promise<string | null>;
61
+ deleteProtection(name: string, options?: {
62
+ allowBundled?: boolean;
63
+ }): Promise<string | null>;
56
64
  isManaged(name: string): Promise<boolean>;
65
+ /** Whether the skill carries the bundled marker (curator prune-builtins eligibility). */
66
+ isBundled(name: string): Promise<boolean>;
67
+ /** Count non-empty support subdirectories (richness input for quality scoring). */
68
+ countSupportDirs(name: string): Promise<number>;
69
+ /** Best-effort audit trail entry; never blocks the mutation. */
70
+ private audit;
71
+ /** Recent mutation audit records (read-only inspection surface). */
72
+ listMutations(): Promise<MutationRecord[]>;
57
73
  create(name: string, content: string, origin: 'foreground' | 'background_review'): Promise<SkillActionResult>;
58
- update(name: string, content: string): Promise<SkillActionResult>;
59
- patch(name: string, oldString: string, newString: string, filePath?: string, replaceAll?: boolean): Promise<SkillActionResult>;
60
- archive(name: string, absorbedInto?: string): Promise<SkillActionResult>;
61
- writeSupportFile(name: string, filePath: string, content: string): Promise<SkillActionResult>;
62
- removeSupportFile(name: string, filePath: string): Promise<SkillActionResult>;
74
+ update(name: string, content: string, origin?: WriteOrigin): Promise<SkillActionResult>;
75
+ patch(name: string, oldString: string, newString: string, filePath?: string, replaceAll?: boolean, origin?: WriteOrigin): Promise<SkillActionResult>;
76
+ archive(name: string, options?: ArchiveOptions): Promise<SkillActionResult>;
77
+ /**
78
+ * Merge the bodies of `sources` into `target` and archive the sources with
79
+ * an absorbed-into marker. Hermes-style consolidation: overlapping skills
80
+ * collapse into one, and the originals stay recoverable under `.archive/`.
81
+ */
82
+ consolidate(target: string, sources: string[], origin?: WriteOrigin): Promise<SkillActionResult>;
83
+ /**
84
+ * Restore one skill from `.archive/` back to the active root. Hermes-style
85
+ * recoverability: archival never deletes, and this is the control-plane
86
+ * path back. The `.archive-reason` marker is dropped on restore.
87
+ */
88
+ restoreFromArchive(name: string): Promise<SkillActionResult>;
89
+ writeSupportFile(name: string, filePath: string, content: string, origin?: WriteOrigin): Promise<SkillActionResult>;
90
+ removeSupportFile(name: string, filePath: string, origin?: WriteOrigin): Promise<SkillActionResult>;
63
91
  snapshotAll(reason?: string): Promise<string>;
64
92
  listSnapshots(): Promise<Array<{
65
93
  path: string;
@@ -8,6 +8,13 @@ export declare class JsonState<T> {
8
8
  readonly path: string;
9
9
  private value;
10
10
  constructor(name: string, initial: T, env?: NodeJS.ProcessEnv);
11
+ /**
12
+ * Deep-merge persisted state over the initial defaults. Nested plain
13
+ * objects merge recursively (so a new default field added under an existing
14
+ * object is preserved), while arrays and primitives take the on-disk value
15
+ * wholesale. Keeps forward-compatible defaults across schema additions.
16
+ */
17
+ private static mergeDeep;
11
18
  private loadSync;
12
19
  get(): T;
13
20
  set(value: T): void;
@@ -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
@@ -30,4 +30,14 @@ export declare function bumpUse(map: UsageMap, name: string, when?: Date): void;
30
30
  export declare function bumpPatch(map: UsageMap, name: string, when?: Date): void;
31
31
  export declare function markAgentCreated(map: UsageMap, name: string): void;
32
32
  export declare function latestActivityAt(record: UsageRecord): string | null;
33
+ /**
34
+ * Curator suppression sidecar: built-in skills the curator has archived stay
35
+ * suppressed across re-seeds, so the lifecycle never fights a re-created
36
+ * bundled skill. Best-effort load/save, mirroring the usage sidecar posture.
37
+ * Versioned shape ({ version, names }) with legacy plain-array compat.
38
+ */
39
+ export declare const SUPPRESSED_FILE_VERSION = 1;
40
+ export declare function suppressedFile(root: string): string;
41
+ export declare function loadSuppressedNames(root: string, io?: EvolutionIoLike): Promise<ReadonlySet<string>>;
42
+ export declare function saveSuppressedNames(root: string, names: ReadonlySet<string>, io?: EvolutionIoLike): Promise<void>;
33
43
  //# 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-rc.2",
4
+ "version": "0.1.0-rc.21",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },