dsh-continual-evolve 0.11.0 → 0.12.1

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 (161) hide show
  1. package/README.md +42 -115
  2. package/README.zh.md +33 -93
  3. package/client/client.js +253 -0
  4. package/cordis.patch.yml +2 -2
  5. package/lib/card-routes.d.ts +32 -0
  6. package/lib/card-routes.js +92 -0
  7. package/lib/index.d.ts +65 -217
  8. package/lib/index.js +74 -234
  9. package/lib/known-workspaces.d.ts +22 -0
  10. package/lib/known-workspaces.js +42 -0
  11. package/lib/memory-guide.d.ts +13 -14
  12. package/lib/memory-guide.js +34 -21
  13. package/lib/memory-section.d.ts +77 -0
  14. package/lib/memory-section.js +189 -0
  15. package/lib/memory-snapshot.d.ts +54 -0
  16. package/lib/memory-snapshot.js +125 -0
  17. package/package.json +8 -17
  18. package/lib/apply.d.ts +0 -22
  19. package/lib/apply.js +0 -157
  20. package/lib/approval.d.ts +0 -73
  21. package/lib/approval.js +0 -127
  22. package/lib/audit-log.d.ts +0 -19
  23. package/lib/audit-log.js +0 -52
  24. package/lib/auto.d.ts +0 -236
  25. package/lib/auto.js +0 -773
  26. package/lib/autocase.d.ts +0 -38
  27. package/lib/autocase.js +0 -76
  28. package/lib/benchmark-command.d.ts +0 -9
  29. package/lib/benchmark-command.js +0 -357
  30. package/lib/benchmark.d.ts +0 -151
  31. package/lib/benchmark.js +0 -250
  32. package/lib/command-util.d.ts +0 -70
  33. package/lib/command-util.js +0 -123
  34. package/lib/command.d.ts +0 -13
  35. package/lib/command.js +0 -134
  36. package/lib/consolidate.d.ts +0 -90
  37. package/lib/consolidate.js +0 -180
  38. package/lib/copy.d.ts +0 -37
  39. package/lib/copy.js +0 -58
  40. package/lib/declines.d.ts +0 -103
  41. package/lib/declines.js +0 -179
  42. package/lib/evaluate.d.ts +0 -74
  43. package/lib/evaluate.js +0 -271
  44. package/lib/evolve-event.d.ts +0 -40
  45. package/lib/evolve-event.js +0 -60
  46. package/lib/extraction-phase.d.ts +0 -132
  47. package/lib/extraction-phase.js +0 -236
  48. package/lib/failures.d.ts +0 -42
  49. package/lib/failures.js +0 -171
  50. package/lib/fate.d.ts +0 -130
  51. package/lib/fate.js +0 -350
  52. package/lib/goal-command.d.ts +0 -7
  53. package/lib/goal-command.js +0 -37
  54. package/lib/goal.d.ts +0 -72
  55. package/lib/goal.js +0 -72
  56. package/lib/inject.d.ts +0 -90
  57. package/lib/inject.js +0 -164
  58. package/lib/injection-caps.d.ts +0 -4
  59. package/lib/injection-caps.js +0 -4
  60. package/lib/injection-directory.d.ts +0 -29
  61. package/lib/injection-directory.js +0 -78
  62. package/lib/injection-rank.d.ts +0 -85
  63. package/lib/injection-rank.js +0 -161
  64. package/lib/listener.d.ts +0 -45
  65. package/lib/listener.js +0 -199
  66. package/lib/llm-text.d.ts +0 -104
  67. package/lib/llm-text.js +0 -140
  68. package/lib/logfile.d.ts +0 -71
  69. package/lib/logfile.js +0 -159
  70. package/lib/maintenance-commands.d.ts +0 -23
  71. package/lib/maintenance-commands.js +0 -136
  72. package/lib/memory-agent.d.ts +0 -93
  73. package/lib/memory-agent.js +0 -300
  74. package/lib/memory-apply.d.ts +0 -44
  75. package/lib/memory-apply.js +0 -202
  76. package/lib/memory-benchmark.d.ts +0 -76
  77. package/lib/memory-benchmark.js +0 -170
  78. package/lib/memory-index.d.ts +0 -114
  79. package/lib/memory-index.js +0 -197
  80. package/lib/memory-manifest.d.ts +0 -16
  81. package/lib/memory-manifest.js +0 -70
  82. package/lib/message-source.d.ts +0 -23
  83. package/lib/message-source.js +0 -12
  84. package/lib/mount-command.d.ts +0 -10
  85. package/lib/mount-command.js +0 -48
  86. package/lib/mount.d.ts +0 -42
  87. package/lib/mount.js +0 -212
  88. package/lib/notify.d.ts +0 -48
  89. package/lib/notify.js +0 -57
  90. package/lib/plan-command.d.ts +0 -12
  91. package/lib/plan-command.js +0 -38
  92. package/lib/plan.d.ts +0 -16
  93. package/lib/plan.js +0 -126
  94. package/lib/planner.d.ts +0 -61
  95. package/lib/planner.js +0 -144
  96. package/lib/pool.d.ts +0 -7
  97. package/lib/pool.js +0 -25
  98. package/lib/prefix-cache.d.ts +0 -79
  99. package/lib/prefix-cache.js +0 -168
  100. package/lib/project.d.ts +0 -28
  101. package/lib/project.js +0 -66
  102. package/lib/projection.d.ts +0 -22
  103. package/lib/projection.js +0 -112
  104. package/lib/promotion.d.ts +0 -94
  105. package/lib/promotion.js +0 -171
  106. package/lib/recall.d.ts +0 -85
  107. package/lib/recall.js +0 -142
  108. package/lib/record-language.d.ts +0 -85
  109. package/lib/record-language.js +0 -152
  110. package/lib/render.d.ts +0 -13
  111. package/lib/render.js +0 -80
  112. package/lib/review-scheduler.d.ts +0 -38
  113. package/lib/review-scheduler.js +0 -183
  114. package/lib/review.d.ts +0 -60
  115. package/lib/review.js +0 -145
  116. package/lib/rollback.d.ts +0 -9
  117. package/lib/rollback.js +0 -68
  118. package/lib/rubric.d.ts +0 -29
  119. package/lib/rubric.js +0 -119
  120. package/lib/runtime-commands.d.ts +0 -14
  121. package/lib/runtime-commands.js +0 -115
  122. package/lib/runtime.d.ts +0 -24
  123. package/lib/runtime.js +0 -87
  124. package/lib/score.d.ts +0 -64
  125. package/lib/score.js +0 -191
  126. package/lib/search.d.ts +0 -83
  127. package/lib/search.js +0 -136
  128. package/lib/service.d.ts +0 -63
  129. package/lib/service.js +0 -253
  130. package/lib/skill-render.d.ts +0 -23
  131. package/lib/skill-render.js +0 -69
  132. package/lib/skill.d.ts +0 -15
  133. package/lib/skill.js +0 -80
  134. package/lib/skillquality.d.ts +0 -85
  135. package/lib/skillquality.js +0 -320
  136. package/lib/source.d.ts +0 -30
  137. package/lib/source.js +0 -43
  138. package/lib/state.d.ts +0 -26
  139. package/lib/state.js +0 -151
  140. package/lib/store.d.ts +0 -61
  141. package/lib/store.js +0 -164
  142. package/lib/token-usage.d.ts +0 -68
  143. package/lib/token-usage.js +0 -211
  144. package/lib/tool.d.ts +0 -34
  145. package/lib/tool.js +0 -320
  146. package/lib/turn-snapshot.d.ts +0 -78
  147. package/lib/turn-snapshot.js +0 -252
  148. package/lib/types.d.ts +0 -218
  149. package/lib/types.js +0 -133
  150. package/lib/usage.d.ts +0 -36
  151. package/lib/usage.js +0 -98
  152. package/lib/validate.d.ts +0 -28
  153. package/lib/validate.js +0 -181
  154. package/lib/wrapup-candidates.d.ts +0 -127
  155. package/lib/wrapup-candidates.js +0 -161
  156. package/lib/wrapup-command.d.ts +0 -10
  157. package/lib/wrapup-command.js +0 -243
  158. package/lib/wrapup-proposals.d.ts +0 -101
  159. package/lib/wrapup-proposals.js +0 -281
  160. package/lib/wrapup.d.ts +0 -56
  161. package/lib/wrapup.js +0 -105
package/lib/wrapup.d.ts DELETED
@@ -1,56 +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
- * Split (2026-10-03 refactor): the candidate domain lives in
22
- * `wrapup-candidates.ts`, the proposal builders in `wrapup-proposals.ts`;
23
- * this module owns the bounded LLM assessment call. Moved symbols are
24
- * re-exported here so the public surface stays on one module.
25
- */
26
- import type { Context } from "@deepseek-ai/cordis";
27
- import type { Agent } from "@deepseek-ai/dsh-agent";
28
- import { type TokenUsageTarget } from "./token-usage.js";
29
- import { type RecordLanguage } from "./record-language.js";
30
- import { type WrapupAssessment, type WrapupCandidate } from "./wrapup-candidates.js";
31
- export * from "./wrapup-candidates.js";
32
- export * from "./wrapup-proposals.js";
33
- 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\".";
34
- export interface AssessOptions {
35
- /** Output token budget for the assessment call. */
36
- maxOutputTokens?: number;
37
- /** Abort signal forwarded to the model call. */
38
- signal?: AbortSignal;
39
- /** Direct-call token ledger destination; phase is selected by the caller. */
40
- tokenUsage?: TokenUsageTarget;
41
- /** Ledger phase for this classifier call (manual wrapup or automatic fate). */
42
- tokenUsagePhase?: "wrapup" | "fate";
43
- /**
44
- * Authoring language for verdict reasons. Absent → resolved per call
45
- * (durable client preference, else `en`; the assessor sees candidate
46
- * snapshots, not user text, so there is no detection tier here).
47
- */
48
- language?: RecordLanguage;
49
- }
50
- /**
51
- * Ask the model to classify the audited local candidates. Routes through the
52
- * calling agent's own provider/model (same model the session runs on), with
53
- * reasoning disabled so the output budget goes to the JSON verdicts.
54
- */
55
- export declare function assessLocalEntries(ctx: Context, agent: Agent, candidates: readonly WrapupCandidate[], options?: AssessOptions): Promise<WrapupAssessment>;
56
- //# sourceMappingURL=wrapup.d.ts.map
package/lib/wrapup.js DELETED
@@ -1,105 +0,0 @@
1
- import { asLlmSessionId, streamText } from "./llm-text.js";
2
- import { createTokenUsageObserver } from "./token-usage.js";
3
- import { recordLanguageInstruction, resolveRecordLanguage } from "./record-language.js";
4
- import { compactText } from "./render.js";
5
- import { candidateKey, parseWrapupAssessment } from "./wrapup-candidates.js";
6
- export * from "./wrapup-candidates.js";
7
- export * from "./wrapup-proposals.js";
8
- export const WRAPUP_ASSESS_SYSTEM_PROMPT = `You are the /evolve session wrap-up assessor.
9
- A session is ending and its local harness entries need a fate. Classify each
10
- listed entry exactly once:
11
-
12
- - "promote" — the content is a stable, durable, CROSS-SESSION reusable lesson:
13
- a durable user preference, a project-level fact or convention, a reusable
14
- procedure or skill. Future sessions would benefit from seeing it.
15
- - "archive" — the content is session-specific task progress, one-off noise,
16
- superseded or obsolete, or already covered by the global store (note
17
- "covered globally" in the reason), or stale (old + never injected — note
18
- "stale (injectionCount=0, recency low)" in the reason), or CONTRADICTED —
19
- newer evidence in the trajectory or the global store disproves or overrides
20
- the entry's content (note what contradicts it in the reason).
21
- - "keep" — still actively useful to this session, or genuinely uncertain.
22
-
23
- Rules:
24
- - CONTRADICTED: when evidence contradicts an entry, set "contradicted": true
25
- on that item (besides the verdict). Entries marked "(contradicted N×
26
- before)" were contradicted in earlier assessments — prefer "archive" for
27
- them unless you have concrete evidence the content is valid again.
28
- - When an entry is marked "covered globally" in the listing, prefer "archive"
29
- or "keep" over "promote" — promoting a duplicate gains nothing.
30
- - When an entry is marked "stale" (injectionCount=0 and low recency), prefer
31
- "archive" — the entry has never been used and is old, so it is unlikely to
32
- be needed again. Only "keep" if the content is clearly valuable despite low
33
- usage (e.g. a safety policy that rarely triggers but is critical).
34
- - Do not promote local task state, work-in-progress notes, or content tied to
35
- one session's ephemeral details.
36
- - Memory entries carry a recall type (user/feedback/project/reference): a
37
- memory WITHOUT one cannot be promoted (the guard skips it) — verdict such
38
- entries "keep" (or "archive" when they qualify) rather than "promote".
39
- - Skills: only "promote" a skill entry that is a genuinely reusable procedure
40
- meeting the DSH skill quality standard; one-off workflows are "archive" or
41
- "keep".
42
- - SPLIT PROMOTION: when an entry mixes a stable, cross-session-reusable part
43
- WITH session-specific snapshot details, do NOT promote it whole. Instead
44
- give verdict "archive" WITH a "promote" sub-object holding a CLEANED
45
- version of only the durable part (a stable title + the persistent facts,
46
- stripped of dates/states/one-off figures). Ephemeral snapshot content stays
47
- out of the sub-object — it is left behind in the archive. A sub-object is
48
- only meaningful on "archive" verdicts.
49
-
50
- Return JSON only:
51
- {
52
- "rationale": "one or two sentences",
53
- "items": [
54
- {"key": "memory:foo", "verdict": "promote|archive|keep", "reason": "why"},
55
- {"key": "memory:bar", "verdict": "archive", "reason": "why", "contradicted": true,
56
- "promote": {"title": "cleaned stable title", "content": "cleaned durable part only"}}
57
- ]
58
- }
59
- Only keys from the provided list are allowed; any entry you omit defaults to "keep".`;
60
- /**
61
- * Ask the model to classify the audited local candidates. Routes through the
62
- * calling agent's own provider/model (same model the session runs on), with
63
- * reasoning disabled so the output budget goes to the JSON verdicts.
64
- */
65
- export async function assessLocalEntries(ctx, agent, candidates, options = {}) {
66
- if (candidates.length === 0) {
67
- return { items: [], rationale: "No local candidates to assess." };
68
- }
69
- if (!agent.options.provider || !agent.options.model) {
70
- throw new Error("evolve: no provider/model route for the wrap-up assessor");
71
- }
72
- const candidateText = candidates
73
- .map((candidate) => {
74
- const key = candidateKey(candidate.kind, candidate.id);
75
- const covered = candidate.coveredGlobally ? " (covered globally)" : "";
76
- const stale = candidate.stale ? ` (stale: injectionCount=${candidate.injectionCount}, recency low)` : "";
77
- const negated = candidate.negativeCount > 0 ? ` (contradicted ${candidate.negativeCount}× before)` : "";
78
- const hints = candidate.globalHints.length > 0
79
- ? ` | global≈${candidate.globalHints.map((hint) => hint.id + ":" + hint.title).join(", ")}`
80
- : "";
81
- return `- ${key} [${candidate.path}, v${candidate.version}] "${candidate.title}"${covered}${stale}${negated}${hints}: ${compactText(candidate.content, 220)}`;
82
- })
83
- .join("\n");
84
- const userPrompt = [
85
- `A local session is wrapping up. Classify each entry below for its fate.`,
86
- `<local_entries>\n${candidateText}\n</local_entries>`,
87
- "Return only JSON. Every item must reference one of the keys above.",
88
- ].join("\n\n");
89
- const text = await streamText(ctx, {
90
- provider: agent.options.provider,
91
- model: agent.options.model,
92
- sessionId: asLlmSessionId(agent.id),
93
- system: `${WRAPUP_ASSESS_SYSTEM_PROMPT}\n\n${recordLanguageInstruction(options.language ?? resolveRecordLanguage({ ctx }))}`,
94
- prompt: userPrompt,
95
- maxTokens: options.maxOutputTokens ?? 4096,
96
- signal: options.signal,
97
- ...(options.tokenUsage
98
- ? {
99
- onUsage: createTokenUsageObserver(options.tokenUsage, options.tokenUsagePhase ?? "wrapup", agent.options.provider, agent.options.model),
100
- }
101
- : {}),
102
- });
103
- return parseWrapupAssessment(text, candidates);
104
- }
105
- //# sourceMappingURL=wrapup.js.map