dsh-continual-evolve 0.10.6 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/README.md +35 -122
  2. package/README.zh.md +26 -97
  3. package/cordis.patch.yml +2 -2
  4. package/lib/index.d.ts +44 -241
  5. package/lib/index.js +30 -253
  6. package/lib/memory-guide.d.ts +13 -14
  7. package/lib/memory-guide.js +32 -21
  8. package/lib/memory-section.d.ts +77 -0
  9. package/lib/memory-section.js +189 -0
  10. package/package.json +2 -17
  11. package/lib/apply.d.ts +0 -22
  12. package/lib/apply.js +0 -157
  13. package/lib/approval.d.ts +0 -72
  14. package/lib/approval.js +0 -127
  15. package/lib/auto.d.ts +0 -236
  16. package/lib/auto.js +0 -773
  17. package/lib/autocase.d.ts +0 -38
  18. package/lib/autocase.js +0 -76
  19. package/lib/benchmark-command.d.ts +0 -9
  20. package/lib/benchmark-command.js +0 -357
  21. package/lib/benchmark.d.ts +0 -151
  22. package/lib/benchmark.js +0 -250
  23. package/lib/command.d.ts +0 -49
  24. package/lib/command.js +0 -568
  25. package/lib/consolidate.d.ts +0 -90
  26. package/lib/consolidate.js +0 -180
  27. package/lib/copy.d.ts +0 -74
  28. package/lib/copy.js +0 -160
  29. package/lib/declines.d.ts +0 -101
  30. package/lib/declines.js +0 -175
  31. package/lib/evaluate.d.ts +0 -74
  32. package/lib/evaluate.js +0 -271
  33. package/lib/evolve-event.d.ts +0 -40
  34. package/lib/evolve-event.js +0 -59
  35. package/lib/failures.d.ts +0 -42
  36. package/lib/failures.js +0 -171
  37. package/lib/fate.d.ts +0 -130
  38. package/lib/fate.js +0 -350
  39. package/lib/goal-command.d.ts +0 -7
  40. package/lib/goal-command.js +0 -37
  41. package/lib/goal.d.ts +0 -72
  42. package/lib/goal.js +0 -72
  43. package/lib/inject.d.ts +0 -196
  44. package/lib/inject.js +0 -412
  45. package/lib/llm-text.d.ts +0 -104
  46. package/lib/llm-text.js +0 -140
  47. package/lib/logfile.d.ts +0 -71
  48. package/lib/logfile.js +0 -159
  49. package/lib/memory-agent.d.ts +0 -129
  50. package/lib/memory-agent.js +0 -568
  51. package/lib/memory-benchmark.d.ts +0 -76
  52. package/lib/memory-benchmark.js +0 -170
  53. package/lib/memory-index.d.ts +0 -114
  54. package/lib/memory-index.js +0 -197
  55. package/lib/message-source.d.ts +0 -23
  56. package/lib/message-source.js +0 -12
  57. package/lib/mount-command.d.ts +0 -10
  58. package/lib/mount-command.js +0 -48
  59. package/lib/mount.d.ts +0 -42
  60. package/lib/mount.js +0 -212
  61. package/lib/notify.d.ts +0 -59
  62. package/lib/notify.js +0 -97
  63. package/lib/plan.d.ts +0 -16
  64. package/lib/plan.js +0 -126
  65. package/lib/planner.d.ts +0 -61
  66. package/lib/planner.js +0 -144
  67. package/lib/pool.d.ts +0 -7
  68. package/lib/pool.js +0 -25
  69. package/lib/prefix-cache.d.ts +0 -78
  70. package/lib/prefix-cache.js +0 -168
  71. package/lib/project.d.ts +0 -28
  72. package/lib/project.js +0 -66
  73. package/lib/projection.d.ts +0 -22
  74. package/lib/projection.js +0 -112
  75. package/lib/promotion.d.ts +0 -94
  76. package/lib/promotion.js +0 -171
  77. package/lib/recall.d.ts +0 -85
  78. package/lib/recall.js +0 -142
  79. package/lib/record-language.d.ts +0 -85
  80. package/lib/record-language.js +0 -152
  81. package/lib/render.d.ts +0 -13
  82. package/lib/render.js +0 -80
  83. package/lib/review-scheduler.d.ts +0 -38
  84. package/lib/review-scheduler.js +0 -191
  85. package/lib/review.d.ts +0 -60
  86. package/lib/review.js +0 -145
  87. package/lib/rollback.d.ts +0 -9
  88. package/lib/rollback.js +0 -68
  89. package/lib/rubric.d.ts +0 -29
  90. package/lib/rubric.js +0 -119
  91. package/lib/runtime.d.ts +0 -24
  92. package/lib/runtime.js +0 -87
  93. package/lib/score.d.ts +0 -64
  94. package/lib/score.js +0 -191
  95. package/lib/search.d.ts +0 -83
  96. package/lib/search.js +0 -136
  97. package/lib/service.d.ts +0 -49
  98. package/lib/service.js +0 -180
  99. package/lib/skill-render.d.ts +0 -23
  100. package/lib/skill-render.js +0 -69
  101. package/lib/skill.d.ts +0 -15
  102. package/lib/skill.js +0 -80
  103. package/lib/skillquality.d.ts +0 -85
  104. package/lib/skillquality.js +0 -320
  105. package/lib/source.d.ts +0 -30
  106. package/lib/source.js +0 -43
  107. package/lib/state.d.ts +0 -26
  108. package/lib/state.js +0 -151
  109. package/lib/store.d.ts +0 -62
  110. package/lib/store.js +0 -164
  111. package/lib/token-usage.d.ts +0 -68
  112. package/lib/token-usage.js +0 -211
  113. package/lib/tool.d.ts +0 -34
  114. package/lib/tool.js +0 -320
  115. package/lib/turn-snapshot.d.ts +0 -72
  116. package/lib/turn-snapshot.js +0 -238
  117. package/lib/types.d.ts +0 -208
  118. package/lib/types.js +0 -127
  119. package/lib/usage.d.ts +0 -36
  120. package/lib/usage.js +0 -98
  121. package/lib/validate.d.ts +0 -28
  122. package/lib/validate.js +0 -181
  123. package/lib/wrapup-command.d.ts +0 -10
  124. package/lib/wrapup-command.js +0 -243
  125. package/lib/wrapup.d.ts +0 -260
  126. package/lib/wrapup.js +0 -539
package/lib/wrapup.d.ts DELETED
@@ -1,260 +0,0 @@
1
- /**
2
- * Session wrap-up: the lifecycle exit for a session's local harness entries.
3
- *
4
- * When a session ends, its local entries default to orphans: a later session
5
- * (not on the parentSession chain) never sees them, and nothing promotes or
6
- * archives them — the exploration results effectively "die" with the session.
7
- * Wrap-up gives those entries a real exit:
8
- *
9
- * - cross-session-reusable content is classified `promote` and moved into the
10
- * global store (through the human approval gate — global is a governed
11
- * resource, exactly like skill proposals);
12
- * - session-specific / superseded / already-covered content is classified
13
- * `archive` (hidden from injection, data stays restorable, rollbackable);
14
- * - everything else is kept.
15
- *
16
- * Division of labor is deliberate: the mechanical audit proposes, the LLM
17
- * classifies, the user approves, the code applies deterministically. The
18
- * apply-side guard (`filterPromotable`) re-checks global coverage at apply
19
- * time so a stale classification can never write a duplicate global entry.
20
- */
21
- import type { Context } from "@deepseek-ai/cordis";
22
- import type { Agent } from "@deepseek-ai/dsh-agent";
23
- import type { HarnessEntry, HarnessState, RefinementKind, RefinementProposal } from "./types.js";
24
- import { type TokenUsageTarget } from "./token-usage.js";
25
- import { type RecordLanguage } from "./record-language.js";
26
- import { type PromotionPolicy } from "./promotion.js";
27
- /** What should happen to one local entry at session end. */
28
- export type WrapupVerdict = "promote" | "archive" | "keep";
29
- /** A classified local entry: `key` matches one audited candidate exactly. */
30
- export interface WrapupItem {
31
- /** `kind:id` of the candidate this verdict refers to. */
32
- key: string;
33
- verdict: WrapupVerdict;
34
- reason: string;
35
- /**
36
- * Optional split-promotion payload (verdict "archive" only): the entry is
37
- * archived as a whole, but a CLEANED cross-session-reusable part is
38
- * offered for promotion — the durable fact distilled out of the mixed
39
- * entry, with the ephemeral snapshot left behind in the archive.
40
- */
41
- promote?: {
42
- title: string;
43
- content: string;
44
- };
45
- /**
46
- * Valence signal (P1 效价反馈): the assessor found trajectory or global
47
- * evidence contradicting this entry's content (user correction, overridden
48
- * fact). Strictly parsed — only an explicit JSON `true` sets it. Keep
49
- * verdicts with this flag get a negative-valence stamp; the assessor is
50
- * instructed to prefer "archive" for contradicted entries.
51
- */
52
- contradicted?: boolean;
53
- }
54
- /** A real global entry worth showing the assessor for the same topic. */
55
- export interface GlobalHint {
56
- id: string;
57
- title: string;
58
- }
59
- /** The model's full classification of a session's local entries. */
60
- export interface WrapupAssessment {
61
- items: WrapupItem[];
62
- rationale: string;
63
- }
64
- /** A local entry offered for assessment, plus its deterministic audit flags. */
65
- export interface WrapupCandidate {
66
- kind: RefinementKind;
67
- id: string;
68
- title: string;
69
- content: string;
70
- path: string;
71
- version: number;
72
- metadata: Record<string, unknown>;
73
- /**
74
- * True when the global store already covers this topic by a STRONG
75
- * signal: a title that normalizes equal to, or (beyond a length floor)
76
- * contains, the candidate's title. Collisions on id alone with a wildly
77
- * different title are deliberately NOT coverage — see {@link globalHintsFor}.
78
- */
79
- coveredGlobally: boolean;
80
- /**
81
- * Actual global entries that touch the same topic (same id, equal
82
- * normalized title, or title overlap). Shown to the assessor so it judges
83
- * against real titles instead of a bare boolean; a bare same-id collision
84
- * shows up here precisely so the model can tell whether the global copy
85
- * really covers the local content.
86
- */
87
- globalHints: GlobalHint[];
88
- /**
89
- * Injection usage count (gap B1): how many times this entry was included
90
- * in a system-prompt assembly. Zero means the entry was never used — a
91
- * strong staleness signal the assessor can weigh.
92
- */
93
- injectionCount: number;
94
- /**
95
- * Staleness flag (gap B2): true when the entry has both zero injection
96
- * usage AND a recency score below the staleness threshold (old + unused).
97
- * The assessor is instructed to prefer "archive" for stale entries.
98
- */
99
- stale: boolean;
100
- /**
101
- * Negative-valence counter (P1 效价反馈): how many prior assessments marked
102
- * this entry contradicted (metadata {@link VALENCE_NEGATIVE_KEY}). Shown to
103
- * the assessor so it can prefer "archive"; also demotes the entry in
104
- * injection ranking (inject.ts rankEntries).
105
- */
106
- negativeCount: number;
107
- }
108
- export declare function candidateKey(kind: RefinementKind, id: string): string;
109
- /**
110
- * Deterministic global-coverage check (STRONG signal): the global store
111
- * already covers a topic when it holds a title that normalizes equal to, or
112
- * (beyond a length floor) contains, the candidate's normalized title.
113
- * Archived global entries count too — the topic was already judged
114
- * cross-session; a local duplicate would only re-sediment it.
115
- *
116
- * The bare same-id case is deliberately NOT coverage: ids are slugs derived
117
- * from titles, so a real collision is usually caught by the title check
118
- * below. A same-id entry with a wildly different title is a weak signal — the
119
- * caller routes it through {@link globalHintsFor} for the assessor to judge
120
- * against the actual global title (real case: local `memory` "用户产品愿景与
121
- * 收入需求(本会话)" vs global `memory` "用户画像(持续更新)").
122
- */
123
- export declare function globalCoverageDetected(globalState: HarnessState, kind: RefinementKind, entry: Pick<HarnessEntry, "id" | "title">): boolean;
124
- /**
125
- * The actual global entries that touch the same topic as a local candidate:
126
- * same id (regardless of title — the weak collision signal that is NOT
127
- * coverage on its own), equal normalized title, or title overlap. The raw ids
128
- * and titles let the assessor judge enrichment against real global content
129
- * (does the global copy already hold what the local one adds?) rather than a
130
- * bare boolean. Bounded: a handful of best matches, never the whole store.
131
- */
132
- export declare function globalHintsFor(globalState: HarnessState, kind: RefinementKind, entry: Pick<HarnessEntry, "id" | "title">): GlobalHint[];
133
- export declare function listLocalCandidates(state: HarnessState, globalState: HarnessState, baseDir?: string): WrapupCandidate[];
134
- /**
135
- * Parse and validate the model's assessment JSON. Defense is mechanical:
136
- * keys outside the candidate list are dropped, verdicts outside the enum
137
- * collapse to "keep", and candidates the model omitted default to "keep" —
138
- * a malformed reply can never change an entry's fate by itself.
139
- *
140
- * Split promotion (verdict "archive" with a `promote` sub-object): the
141
- * sub-object is accepted ONLY on archive verdicts and ONLY when both cleaned
142
- * title and content are non-empty strings — a dropped/malformed sub-object
143
- * silently degrades to a plain archive (the entry is never half-promoted).
144
- */
145
- export declare function parseWrapupAssessment(text: string, candidates: readonly WrapupCandidate[]): WrapupAssessment;
146
- export interface PromotableSplit {
147
- /** Items that may be promoted: classified promote AND not covered globally. */
148
- promotable: WrapupItem[];
149
- /** Items classified promote but blocked by the deterministic guard, with why. */
150
- skipped: {
151
- key: string;
152
- reason: string;
153
- }[];
154
- }
155
- /**
156
- * Apply-time deterministic guard: re-check every promote verdict against the
157
- * global store right before it lands. The LLM classification may be stale
158
- * (a gate ran while assessing) or wrong; this ensures a promote never writes
159
- * a duplicate, project-scoped, or too-thin global entry. Pure and unit-tested.
160
- *
161
- * Guards (2026-08-22 promotion policy):
162
- * - audited candidate list + title coverage (pre-existing),
163
- * - project-scoped content markers (absolute paths / session ids) — the
164
- * global store is shared across projects and must stay portable,
165
- * - thin content below the policy floor (framing outweighs the fact),
166
- * - near-duplicate of an existing global entry by content overlap.
167
- */
168
- export declare function filterPromotable(items: readonly WrapupItem[], globalState: HarnessState, candidates: readonly WrapupCandidate[], policy?: PromotionPolicy): PromotableSplit;
169
- export interface ArchiveReviewSplit {
170
- /** Archives that may proceed silently: topic already covered, no real
171
- * distillation source, or the archive half of an already-approved split. */
172
- silent: WrapupItem[];
173
- /**
174
- * Archives that would bury possibly-reusable content: not covered
175
- * globally AND distilled from real user messages (sourceSeqs present).
176
- * These MAY NOT archive silently — the command must get user
177
- * confirmation first (the symmetric guard to filterPromotable: it stops
178
- * over-archiving, not just over-writing).
179
- */
180
- review: WrapupItem[];
181
- }
182
- /**
183
- * The symmetric archive guard. `filterPromotable` is one-directional: it
184
- * stops the model from WRITING duplicate global entries, but nothing stopped
185
- * an unfounded ARCHIVE from hiding content that was actually only local.
186
- * Guard criteria: an archive needs user confirmation when it is NOT covered
187
- * globally AND the entry carries a real distillation source (sourceSeqs /
188
- * sourceSession — i.e. it was distilled from actual user messages, so it
189
- * may hold reusable value). Operational/empty entries archive silently as
190
- * before. Split archives (archive + promote sub-object) skip this check:
191
- * their promotion already crosses a human approval gate, so the archive is
192
- * the completion of an approved action, not a silent burial.
193
- */
194
- export declare function needsArchiveReview(item: WrapupItem, candidate: WrapupCandidate): boolean;
195
- /** Partition archive items into silent vs review-required (see needsArchiveReview). */
196
- export declare function splitArchiveGuards(items: readonly WrapupItem[], candidates: readonly WrapupCandidate[]): ArchiveReviewSplit;
197
- /**
198
- * Apply-time guard for a split promotion (archive + promote sub-object):
199
- * the cleaned payload must pass the same promotion policy as a whole
200
- * promote — no global coverage duplicate, no project-scoped content, not
201
- * too thin, no near-duplicate global entry. A blocked split is dropped (the
202
- * entry still archives plain) rather than half-promoting a redundancy.
203
- */
204
- export declare function splitPromoteBlocked(item: WrapupItem, globalState: HarnessState, kind: RefinementKind, policy?: PromotionPolicy, candidateMetadata?: Record<string, unknown>): string | undefined;
205
- /**
206
- * Shared proposal builders for a WHOLE promotion — used by both the
207
- * `/evolve wrapup` command and the gate's local-fate dimension so the two
208
- * paths apply IDENTICAL edits (global create + local retirement stamp).
209
- *
210
- * The local stamp is a factory: the `promotedTo` id is only known after the
211
- * global create lands (validation may slugify the id), so the caller applies
212
- * the global proposal first and stamps the local copy with the created id.
213
- */
214
- export declare function wholePromoteProposals(item: WrapupItem, candidate: WrapupCandidate, sessionId: string): {
215
- global: RefinementProposal;
216
- localStamp: (createdId: string) => RefinementProposal;
217
- };
218
- /**
219
- * Shared proposal builders for a SPLIT promotion (A-form): archive a mixed
220
- * local entry but promote ONLY the cleaned durable part the model extracted.
221
- * Same usage contract as {@link wholePromoteProposals}: apply the global
222
- * create, then stamp the original local entry with the created id.
223
- */
224
- export declare function splitPromoteProposals(item: WrapupItem, candidate: WrapupCandidate, sessionId: string): {
225
- global: RefinementProposal;
226
- localStamp: (createdId: string) => RefinementProposal;
227
- };
228
- /**
229
- * Valence stamp (P1 效价反馈): a keep-verdict item the assessor marked
230
- * contradicted gets its negative-valence counter bumped — the entry stays
231
- * live but sinks in injection ranking and the next assessment prefers
232
- * archiving it. Promotes pass untouched (the human-approved global copy is
233
- * the live truth); archives don't need the stamp (they already leave
234
- * injection). Undefined when nothing applies.
235
- */
236
- export declare function valenceStampProposal(item: WrapupItem, candidate: WrapupCandidate): RefinementProposal | undefined;
237
- export declare const WRAPUP_ASSESS_SYSTEM_PROMPT = "You are the /evolve session wrap-up assessor.\nA session is ending and its local harness entries need a fate. Classify each\nlisted entry exactly once:\n\n- \"promote\" \u2014 the content is a stable, durable, CROSS-SESSION reusable lesson:\n a durable user preference, a project-level fact or convention, a reusable\n procedure or skill. Future sessions would benefit from seeing it.\n- \"archive\" \u2014 the content is session-specific task progress, one-off noise,\n superseded or obsolete, or already covered by the global store (note\n \"covered globally\" in the reason), or stale (old + never injected \u2014 note\n \"stale (injectionCount=0, recency low)\" in the reason), or CONTRADICTED \u2014\n newer evidence in the trajectory or the global store disproves or overrides\n the entry's content (note what contradicts it in the reason).\n- \"keep\" \u2014 still actively useful to this session, or genuinely uncertain.\n\nRules:\n- CONTRADICTED: when evidence contradicts an entry, set \"contradicted\": true\n on that item (besides the verdict). Entries marked \"(contradicted N\u00D7\n before)\" were contradicted in earlier assessments \u2014 prefer \"archive\" for\n them unless you have concrete evidence the content is valid again.\n- When an entry is marked \"covered globally\" in the listing, prefer \"archive\"\n or \"keep\" over \"promote\" \u2014 promoting a duplicate gains nothing.\n- When an entry is marked \"stale\" (injectionCount=0 and low recency), prefer\n \"archive\" \u2014 the entry has never been used and is old, so it is unlikely to\n be needed again. Only \"keep\" if the content is clearly valuable despite low\n usage (e.g. a safety policy that rarely triggers but is critical).\n- Do not promote local task state, work-in-progress notes, or content tied to\n one session's ephemeral details.\n- Memory entries carry a recall type (user/feedback/project/reference): a\n memory WITHOUT one cannot be promoted (the guard skips it) \u2014 verdict such\n entries \"keep\" (or \"archive\" when they qualify) rather than \"promote\".\n- Skills: only \"promote\" a skill entry that is a genuinely reusable procedure\n meeting the DSH skill quality standard; one-off workflows are \"archive\" or\n \"keep\".\n- SPLIT PROMOTION: when an entry mixes a stable, cross-session-reusable part\n WITH session-specific snapshot details, do NOT promote it whole. Instead\n give verdict \"archive\" WITH a \"promote\" sub-object holding a CLEANED\n version of only the durable part (a stable title + the persistent facts,\n stripped of dates/states/one-off figures). Ephemeral snapshot content stays\n out of the sub-object \u2014 it is left behind in the archive. A sub-object is\n only meaningful on \"archive\" verdicts.\n\nReturn JSON only:\n{\n \"rationale\": \"one or two sentences\",\n \"items\": [\n {\"key\": \"memory:foo\", \"verdict\": \"promote|archive|keep\", \"reason\": \"why\"},\n {\"key\": \"memory:bar\", \"verdict\": \"archive\", \"reason\": \"why\", \"contradicted\": true,\n \"promote\": {\"title\": \"cleaned stable title\", \"content\": \"cleaned durable part only\"}}\n ]\n}\nOnly keys from the provided list are allowed; any entry you omit defaults to \"keep\".";
238
- export interface AssessOptions {
239
- /** Output token budget for the assessment call. */
240
- maxOutputTokens?: number;
241
- /** Abort signal forwarded to the model call. */
242
- signal?: AbortSignal;
243
- /** Direct-call token ledger destination; phase is selected by the caller. */
244
- tokenUsage?: TokenUsageTarget;
245
- /** Ledger phase for this classifier call (manual wrapup or automatic fate). */
246
- tokenUsagePhase?: "wrapup" | "fate";
247
- /**
248
- * Authoring language for verdict reasons. Absent → resolved per call
249
- * (durable client preference, else `en`; the assessor sees candidate
250
- * snapshots, not user text, so there is no detection tier here).
251
- */
252
- language?: RecordLanguage;
253
- }
254
- /**
255
- * Ask the model to classify the audited local candidates. Routes through the
256
- * calling agent's own provider/model (same model the session runs on), with
257
- * reasoning disabled so the output budget goes to the JSON verdicts.
258
- */
259
- export declare function assessLocalEntries(ctx: Context, agent: Agent, candidates: readonly WrapupCandidate[], options?: AssessOptions): Promise<WrapupAssessment>;
260
- //# sourceMappingURL=wrapup.d.ts.map