@lmzhen/dsh-evolution-core 0.1.0-rc.6 → 0.1.0-rc.60

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,53 @@
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
+ /** Consolidation-failure backoff cap, shared by MemoryStore and memory-files' Config default. */
51
+ export declare const DEFAULT_CONSOLIDATION_FAILURES = 3;
52
+ export declare const DEFAULT_SKILL_CONTENT_CHARS = 100000;
53
+ //# sourceMappingURL=constants.d.ts.map
@@ -1,8 +1,13 @@
1
1
  /**
2
2
  * Deterministic skill curator: active → stale → archived transitions.
3
- * Pure function; file moves are performed by SkillLibrary.
3
+ * Pure function with one deliberate side effect: records in the passed
4
+ * `usage` map are MUTATED (state/archived_at) to carry the transition — the
5
+ * caller owns the map and decides whether to clone first (dry-run) or persist
6
+ * after. File moves are performed by SkillLibrary.
4
7
  */
5
- import type { UsageMap } from './usage.ts';
8
+ import type { UsageMap, UsageRecord } from './usage.ts';
9
+ import { EvolutionGateSet } from './gates.ts';
10
+ export { PROTECTED_BUILTIN_SKILLS } from './constants.ts';
6
11
  export interface CuratorConfig {
7
12
  staleAfterDays: number;
8
13
  archiveAfterDays: number;
@@ -12,6 +17,14 @@ export interface CuratorConfig {
12
17
  excludeSkillNames?: ReadonlySet<string>;
13
18
  /** When true, usage records without created_by='agent' also enter the lifecycle. */
14
19
  manageUnmanaged?: boolean;
20
+ /** When true, bundled skills (in `bundledNames`) are curation candidates like agent-created ones. */
21
+ pruneBuiltins?: boolean;
22
+ /** Skill names carrying the bundled marker; only read when `pruneBuiltins` is true. */
23
+ bundledNames?: ReadonlySet<string>;
24
+ /** Skill names the curator archived once and must not fight across re-seeds. */
25
+ suppressedNames?: ReadonlySet<string>;
26
+ /** Skills referenced by scheduled/automated jobs: never auto-transitioned (idle clocks mislead for rarely-firing tasks). */
27
+ referencedSkillNames?: ReadonlySet<string>;
15
28
  }
16
29
  export interface CuratorTransition {
17
30
  name: string;
@@ -25,7 +38,6 @@ export interface CuratorResult {
25
38
  reactivate: string[];
26
39
  markStale: string[];
27
40
  }
28
- export declare const PROTECTED_BUILTIN_SKILLS: ReadonlySet<string>;
29
41
  export interface CuratorArchivedSkill {
30
42
  name: string;
31
43
  path: string;
@@ -36,6 +48,8 @@ export interface CuratorFailedSkill {
36
48
  reason: string;
37
49
  }
38
50
  export interface CuratorRunReport {
51
+ /** Report shape version; readers may ignore unknown fields on later versions. */
52
+ schemaVersion: 1;
39
53
  runId: string;
40
54
  startedAt: string;
41
55
  finishedAt: string;
@@ -44,7 +58,11 @@ export interface CuratorRunReport {
44
58
  archiveCandidates: string[];
45
59
  archived: CuratorArchivedSkill[];
46
60
  failed: CuratorFailedSkill[];
61
+ /** Consolidations actually executed this run (source absorbed into target). */
62
+ consolidated?: CuratorConsolidation[];
47
63
  snapshotPath?: string;
64
+ /** Whether the LLM nomination pass was enabled for this run (decision visibility). */
65
+ llmReviewEnabled?: boolean;
48
66
  }
49
67
  export interface CuratorReportInput {
50
68
  runId: string;
@@ -55,8 +73,57 @@ export interface CuratorReportInput {
55
73
  archiveCandidates: readonly string[];
56
74
  archived: readonly CuratorArchivedSkill[];
57
75
  failed: readonly CuratorFailedSkill[];
76
+ consolidated?: readonly CuratorConsolidation[];
58
77
  snapshotPath?: string;
78
+ llmReviewEnabled?: boolean;
59
79
  }
60
80
  export declare function buildCuratorRunReport(input: CuratorReportInput): CuratorRunReport;
61
- export declare function computeLifecycleTransitions(usage: UsageMap, config: CuratorConfig, now?: Date): CuratorResult;
81
+ /**
82
+ * Render a curator run report as a compact human-readable markdown digest
83
+ * (G6): run metadata first, then the notable sections (archived / failed /
84
+ * stale candidates / LLM nominations).
85
+ */
86
+ export declare function renderCuratorReportMarkdown(report: CuratorRunReport): string;
87
+ /** One LLM-nominated consolidation: `from` merges into the umbrella `into`. */
88
+ export interface CuratorConsolidation {
89
+ from: string;
90
+ into: string;
91
+ }
92
+ /** Structured result of the optional curator LLM nomination pass. */
93
+ export interface CuratorNominations {
94
+ prunings: string[];
95
+ consolidations: CuratorConsolidation[];
96
+ }
97
+ /**
98
+ * Parse the curator LLM's YAML nomination block (consolidations + prunings).
99
+ * Line-oriented and lenient by design: the LLM output is advisory, every name
100
+ * is re-validated against the tree before any file move happens downstream.
101
+ */
102
+ export declare function parseCuratorNominations(text: string): CuratorNominations;
103
+ /**
104
+ * The lifecycle-candidate gate, shared by the transition engine and the scope
105
+ * view so the two can never disagree: records failing ANY of these gates are
106
+ * outside the managed scope.
107
+ */
108
+ export declare function lifecycleCandidate(name: string, record: UsageRecord, config: CuratorConfig, bundled: boolean, gates?: EvolutionGateSet): boolean;
109
+ export interface ScopeView {
110
+ /** Skills inside the lifecycle scope right now (candidate gate + active state). */
111
+ managed: string[];
112
+ /** Managed skills already flagged stale or quality-warned — the ones to watch. */
113
+ watched: string[];
114
+ /** Managed skills flagged low quality (subset of `watched`) — consolidation candidates. */
115
+ qualityWarned: string[];
116
+ /** Explicitly exempted by excludeSkillNames / referencedSkillNames. */
117
+ exempted: string[];
118
+ /** Carrying a protection marker (pinned / bundled / hub-installed). */
119
+ protected: string[];
120
+ }
121
+ /**
122
+ * Read-only scope classification, derived from the SAME gate the transition
123
+ * engine uses (`lifecycleCandidate`), so the view always predicts what a
124
+ * curator pass may touch. `protectedNames` carries the marker info the usage
125
+ * records lack (bundled / hub-installed / pinned from `SkillLibrary.list()`).
126
+ */
127
+ export declare function computeScopeView(usage: UsageMap, config: CuratorConfig, protectedNames?: ReadonlyMap<string, string>, gates?: EvolutionGateSet): ScopeView;
128
+ export declare function computeLifecycleTransitions(usage: UsageMap, config: CuratorConfig, now?: Date, gates?: EvolutionGateSet): CuratorResult;
62
129
  //# sourceMappingURL=curator.d.ts.map
@@ -1,15 +1,28 @@
1
1
  /**
2
- * Durable session events emitted by the evolution family.
3
- * These are non-surface events: they never enter model history, but make
4
- * self-evolution activity replayable and observable by UI/projections.
2
+ * Process-local events emitted by the evolution family on the cordis event
3
+ * bus. Consumers subscribe with `ctx.on(...)`; producers dispatch with
4
+ * `ctx.emit(...)`.
5
+ *
6
+ * These are deliberately NOT session events: a persisted session log may only
7
+ * contain types from the host's generated `KNOWN_SESSION_EVENT_TYPES` set —
8
+ * the persistence read path refuses to interpret a log carrying any other
9
+ * type unless the envelope marks it `ignorable`, and `Session.append` offers
10
+ * no channel to write that marker. Appending any `evolution/*` type therefore
11
+ * made the whole session unresumable (A-line P0-1, fixed in rc.42 by moving
12
+ * these events off `session.append`). Plan-outcome durability lives in the
13
+ * evolution-activity store, not the session log.
5
14
  */
6
15
  export interface EvolutionReviewScheduledEvent {
16
+ /** Owning session (payload v2): process events carry no session envelope. */
17
+ sessionId: string;
7
18
  kind: 'memory' | 'skill' | 'combined';
8
19
  toolCalls: number;
9
20
  userChars: number;
10
21
  assistantChars: number;
11
22
  }
12
23
  export interface EvolutionPlanAppliedEvent {
24
+ /** Owning session (payload v2): process events carry no session envelope. */
25
+ sessionId: string;
13
26
  planId: string;
14
27
  /** Stable fingerprint of the policy snapshot that produced this plan. */
15
28
  policyFingerprint?: string | undefined;
@@ -25,15 +38,10 @@ export interface EvolutionSkillMutatedEvent {
25
38
  filePath?: string;
26
39
  archivedPath?: string;
27
40
  }
28
- declare module '@deepseek-ai/dsh-session/types' {
29
- interface SessionEventMap {
30
- 'evolution/review-scheduled': EvolutionReviewScheduledEvent;
31
- 'evolution/plan-applied': EvolutionPlanAppliedEvent;
32
- 'evolution/skill-mutated': EvolutionSkillMutatedEvent;
33
- }
34
- }
35
41
  declare module '@deepseek-ai/cordis' {
36
42
  interface Events {
43
+ 'evolution/review-scheduled'(event: EvolutionReviewScheduledEvent): void;
44
+ 'evolution/plan-applied'(event: EvolutionPlanAppliedEvent): void;
37
45
  'evolution/skill-mutated'(event: EvolutionSkillMutatedEvent): void;
38
46
  }
39
47
  }
@@ -0,0 +1,38 @@
1
+ /**
2
+ * The control-plane protection sets, held once and queried everywhere
3
+ * (decision B, rc.44 plan M2): the lifecycle engine, the scope view, the LLM
4
+ * nomination gate and the control-plane consolidate all answer "is this name
5
+ * off limits — and why" from the same instance, so the gate sets can never
6
+ * drift apart the way the three pre-rc.46 implementations did.
7
+ *
8
+ * Scope boundary: a GateSet covers NAME-SET protections only. Marker-based
9
+ * protections (pinned / bundled / hub-installed) are file markers resolved by
10
+ * `SkillLibrary.writeProtection` / `deleteProtection` — they depend on the
11
+ * filesystem and the write origin, not on a name list.
12
+ * @module @deepseek-ai/dsh-evolution-core
13
+ */
14
+ export type GateReason = 'excluded' | 'referenced' | 'suppressed' | 'protected-builtin';
15
+ export interface GateSetInputs {
16
+ exclude?: ReadonlySet<string> | undefined;
17
+ referenced?: ReadonlySet<string> | undefined;
18
+ suppressed?: ReadonlySet<string> | undefined;
19
+ }
20
+ export declare class EvolutionGateSet {
21
+ readonly exclude: ReadonlySet<string>;
22
+ readonly referenced: ReadonlySet<string>;
23
+ readonly suppressed: ReadonlySet<string>;
24
+ constructor(inputs?: GateSetInputs);
25
+ /**
26
+ * The first protection blocking this name, or null. Any hit blocks — the
27
+ * order is diagnostic only, so a name in two sets reports the first.
28
+ */
29
+ blockReason(name: string): GateReason | null;
30
+ isBlocked(name: string): boolean;
31
+ }
32
+ /** Build a GateSet from the curator-style config field names. */
33
+ export declare function createGateSet(config: {
34
+ excludeSkillNames?: ReadonlySet<string>;
35
+ referencedSkillNames?: ReadonlySet<string>;
36
+ suppressedNames?: ReadonlySet<string>;
37
+ }): EvolutionGateSet;
38
+ //# sourceMappingURL=gates.d.ts.map
@@ -8,13 +8,18 @@
8
8
  * @module @deepseek-ai/dsh-evolution-core
9
9
  */
10
10
  export * from './curator.ts';
11
+ export * from './gates.ts';
11
12
  export * from './events.ts';
12
13
  export * from './io.ts';
14
+ export * from './learn-prompt.ts';
13
15
  export * from './memory-store.ts';
16
+ export * from './mutations.ts';
14
17
  export * from './prompts.ts';
18
+ export * from './quality.ts';
15
19
  export * from './signals.ts';
16
20
  export * from './skill-store.ts';
17
21
  export * from './state-store.ts';
18
22
  export * from './threats.ts';
19
23
  export * from './usage.ts';
24
+ export * from './constants.ts';
20
25
  //# sourceMappingURL=index.d.ts.map
package/lib/types/io.d.ts CHANGED
@@ -1,9 +1,8 @@
1
1
  /**
2
- * Structural IO seam for the legacy facade stores.
2
+ * Structural IO seam for the evolution plugin family.
3
3
  *
4
- * The facade accepts any object exposing this small async file-tree surface.
5
- * Native DSH packages pass `ctx.evolutionIo.provider()`; standalone consumers
6
- * (and the facade's own tests) can use `nodeEvolutionIo`.
4
+ * Every evolution package passes `ctx.evolutionIo.provider()`; standalone
5
+ * consumers (and the core's own tests) can use `nodeEvolutionIo`.
7
6
  */
8
7
  export interface EvolutionIoLike {
9
8
  readText(path: string): Promise<string | null>;
@@ -13,10 +12,36 @@ export interface EvolutionIoLike {
13
12
  exists(path: string): Promise<boolean>;
14
13
  rename(path: string, destination: string): Promise<void>;
15
14
  copy(path: string, destination: string): Promise<void>;
15
+ /**
16
+ * Optional byte-size probe for the read guard. Return the file's size in
17
+ * bytes, or `null`/`undefined` when unknown (unsupported backend, missing
18
+ * file, stat failure). An implementation without this probe gets no guard:
19
+ * consumers treat an unknown size as "guard not applicable".
20
+ */
21
+ size?(path: string): Promise<number | null>;
22
+ /**
23
+ * Optional atomic read-modify-write on one file: the read and the write run
24
+ * inside a single cross-process lock, so two processes that share DSH_HOME
25
+ * cannot interleave their RMW sequences. `task` receives the current content
26
+ * (`null` when missing) and returns the next content; returning `null`
27
+ * deletes the file. A backend without it falls back to plain read+write and
28
+ * the caller keeps its single-process chain as the second layer.
29
+ */
30
+ transact?(this: void, path: string, task: (current: string | null) => Promise<string | null>): Promise<void>;
31
+ /**
32
+ * Optional symlink probe (G7). `true` = the path is a symlink, `false` = a
33
+ * real entry, `null` = guard not applicable (backend without the probe or
34
+ * the path does not exist). Consumers treat `null` as "let it through".
35
+ */
36
+ isSymlink?(this: void, path: string): Promise<boolean | null>;
16
37
  }
38
+ /**
39
+ * Run `task` inside `io.transact` when the backend provides it; otherwise fall
40
+ * back to a plain read → task → write/remove sequence (no cross-process lock —
41
+ * callers keep their single-process serialize chain as the second layer).
42
+ */
43
+ export declare function transactIo(io: EvolutionIoLike, path: string, task: (current: string | null) => Promise<string | null>): Promise<void>;
17
44
  /** Lazy adapter over an IO provider registry, shared by every evolution consumer. */
18
45
  export declare function evolutionIoAdapter(provider: () => EvolutionIoLike): EvolutionIoLike;
19
46
  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
47
  //# sourceMappingURL=io.d.ts.map
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Open-ended `/evolution learn` prompt builder.
3
+ *
4
+ * `learn` is open-ended: the user can name anything they can describe — a
5
+ * directory of code, an API doc URL, a workflow they just walked the agent
6
+ * through, or pasted notes. The prompt instructs the live agent to gather the
7
+ * named sources with its existing tools, then author a single SKILL.md via
8
+ * `skill_manage` following `DSH_AUTHORING_STANDARDS`. There is no separate
9
+ * distillation engine and no model-tool footprint.
10
+ */
11
+ /**
12
+ * Build the agent prompt for an open-ended `/evolution learn` request.
13
+ *
14
+ * @param userRequest free-text the user gave after `/evolution learn`; an
15
+ * empty string falls back to "the workflow we just went through".
16
+ * @returns a complete instruction the agent runs as a normal turn.
17
+ */
18
+ export declare function buildLearnPrompt(userRequest: string): string;
19
+ //# sourceMappingURL=learn-prompt.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';
@@ -35,26 +35,59 @@ export declare class MemoryStore {
35
35
  private readonly maxFailures;
36
36
  private readonly io;
37
37
  private failureCount;
38
+ private lastFailureAt;
38
39
  constructor(options?: MemoryStoreOptions);
39
40
  limitFor(target: MemoryTarget): number;
41
+ /**
42
+ * Read-guard probe: `{ size, limit }` when the on-disk file exceeds
43
+ * `limit * READ_GUARD_FACTOR` bytes, `null` when it is absent, unknown
44
+ * (backend without a size probe), under the bound, or the target has no
45
+ * limit configured.
46
+ */
47
+ private oversizedFile;
40
48
  read(target: MemoryTarget): Promise<string[]>;
41
49
  write(target: MemoryTarget, entries: string[]): Promise<void>;
42
50
  resetFailures(): void;
43
51
  private failure;
52
+ /**
53
+ * StorageHint percentage must clamp at 100 like the render header: a drifted
54
+ * entry can push chars past the limit, and "Storage at 125%" contradicts the
55
+ * clamped usage indicator.
56
+ */
57
+ private storageHint;
58
+ /**
59
+ * Best-effort raw-copy backup of the on-disk file to `<file>.bak.<stamp>`
60
+ * before a refusal, so an externally modified (or oversized) file stays
61
+ * recoverable. Copies bytes instead of reading them so a pathologically
62
+ * large file is never loaded just to back it up. Failure to back up does
63
+ * not change the refusal semantics.
64
+ */
65
+ private backupFile;
66
+ /**
67
+ * Read-guard refusal for write paths. Returns the refusal result when the
68
+ * target file is oversized, `null` otherwise. The file is skipped for
69
+ * reading (never loaded), backed up by raw copy, and the model is told to
70
+ * fix it manually — mirroring the drift refusal so corrupted state is never
71
+ * silently overwritten.
72
+ */
73
+ private oversizedRefusal;
44
74
  add(target: MemoryTarget, facts: string): Promise<MemoryApplyResult>;
45
- replace(target: MemoryTarget, oldText: string, facts: string): Promise<MemoryApplyResult>;
46
- remove(target: MemoryTarget, oldText: string): Promise<MemoryApplyResult>;
47
- private mutate;
48
75
  applyBatch(target: MemoryTarget, operations: MemoryOperation[]): Promise<MemoryApplyResult>;
49
76
  renderContext(): Promise<string>;
50
- snapshot(): Promise<{
51
- memory: string[];
52
- user: string[];
53
- }>;
54
- restoreSnapshot(snapshot: {
55
- memory: string[];
56
- user: string[];
57
- }): Promise<void>;
77
+ /**
78
+ * Detect on-disk drift: true when the file is not in the canonical
79
+ * `render(normalizeEntries(raw))` form. This catches structural anomalies
80
+ * the writer would quietly normalize away (empty/`§`-only entries, stray
81
+ * blank lines, leading/trailing delimiters) that indicate the file was
82
+ * edited outside MemoryStore. Purely single-canonical content reaches the
83
+ * same serialization and returns false, so a normal write is never flagged.
84
+ *
85
+ * An absent, empty, or whitespace-only file is the "never written" state
86
+ * (rc.42 audit P1-6): it parses to zero entries, so the canonical form
87
+ * `'\n'` can never byte-match it and every write path was permanently
88
+ * refused with "External drift detected" — including the repairs the model
89
+ * would need to make. Such files are adopted instead of flagged.
90
+ */
58
91
  detectDrift(target: MemoryTarget): Promise<boolean>;
59
92
  }
60
93
  //# 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,24 @@
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@5";
7
+ export declare const PROMPT_BUNDLE_VERSION = 5;
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 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
- 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>";
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\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\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 MAY be consolidated into an umbrella \u2014 but only because the curator rewrites scheduled-task skill references to follow consolidations; never simply prune them.\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\nYour toolset:\n - skill_manage action=list / review \u2014 read the current landscape.\n - skill_manage action=patch \u2014 add sections to the umbrella.\n - skill_manage action=create \u2014 create a new umbrella SKILL.md.\n - skill_manage action=write_file \u2014 add a references/, templates/, or scripts/ file under an existing skill (the skill must already exist).\n - skill_manage action=delete \u2014 archive a skill. MUST pass absorbed_into=<umbrella> when you've merged its content into another skill, or absorbed_into=\"\" when you're truly pruning with no forwarding target.\n - skill_manage action=consolidate \u2014 merge source bodies into a target and archive the sources when patching by hand is error-prone.\n - skill_manage action=restore \u2014 bring one archived skill back (recoverability is the archive's contract).\n - For moving support files, keep it inside the skill tree: support files move via reading and writing through skill_manage write_file/remove_file.\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 AND a structured machine-readable block so downstream tooling can distinguish consolidation from pruning. 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 moved 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.";
6
22
  export declare function reviewPrompt(kind: 'memory' | 'skill' | 'combined'): string;
7
23
  export interface PromptBundle {
8
24
  id: string;
@@ -12,5 +28,5 @@ export interface PromptBundle {
12
28
  }
13
29
  export declare const PROMPT_BUNDLE: PromptBundle;
14
30
  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/`.";
31
+ 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/`.";
16
32
  //# sourceMappingURL=prompts.d.ts.map
@@ -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