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.
- package/README.md +42 -115
- package/README.zh.md +33 -93
- package/client/client.js +253 -0
- package/cordis.patch.yml +2 -2
- package/lib/card-routes.d.ts +32 -0
- package/lib/card-routes.js +92 -0
- package/lib/index.d.ts +65 -217
- package/lib/index.js +74 -234
- package/lib/known-workspaces.d.ts +22 -0
- package/lib/known-workspaces.js +42 -0
- package/lib/memory-guide.d.ts +13 -14
- package/lib/memory-guide.js +34 -21
- package/lib/memory-section.d.ts +77 -0
- package/lib/memory-section.js +189 -0
- package/lib/memory-snapshot.d.ts +54 -0
- package/lib/memory-snapshot.js +125 -0
- package/package.json +8 -17
- package/lib/apply.d.ts +0 -22
- package/lib/apply.js +0 -157
- package/lib/approval.d.ts +0 -73
- package/lib/approval.js +0 -127
- package/lib/audit-log.d.ts +0 -19
- package/lib/audit-log.js +0 -52
- package/lib/auto.d.ts +0 -236
- package/lib/auto.js +0 -773
- package/lib/autocase.d.ts +0 -38
- package/lib/autocase.js +0 -76
- package/lib/benchmark-command.d.ts +0 -9
- package/lib/benchmark-command.js +0 -357
- package/lib/benchmark.d.ts +0 -151
- package/lib/benchmark.js +0 -250
- package/lib/command-util.d.ts +0 -70
- package/lib/command-util.js +0 -123
- package/lib/command.d.ts +0 -13
- package/lib/command.js +0 -134
- package/lib/consolidate.d.ts +0 -90
- package/lib/consolidate.js +0 -180
- package/lib/copy.d.ts +0 -37
- package/lib/copy.js +0 -58
- package/lib/declines.d.ts +0 -103
- package/lib/declines.js +0 -179
- package/lib/evaluate.d.ts +0 -74
- package/lib/evaluate.js +0 -271
- package/lib/evolve-event.d.ts +0 -40
- package/lib/evolve-event.js +0 -60
- package/lib/extraction-phase.d.ts +0 -132
- package/lib/extraction-phase.js +0 -236
- package/lib/failures.d.ts +0 -42
- package/lib/failures.js +0 -171
- package/lib/fate.d.ts +0 -130
- package/lib/fate.js +0 -350
- package/lib/goal-command.d.ts +0 -7
- package/lib/goal-command.js +0 -37
- package/lib/goal.d.ts +0 -72
- package/lib/goal.js +0 -72
- package/lib/inject.d.ts +0 -90
- package/lib/inject.js +0 -164
- package/lib/injection-caps.d.ts +0 -4
- package/lib/injection-caps.js +0 -4
- package/lib/injection-directory.d.ts +0 -29
- package/lib/injection-directory.js +0 -78
- package/lib/injection-rank.d.ts +0 -85
- package/lib/injection-rank.js +0 -161
- package/lib/listener.d.ts +0 -45
- package/lib/listener.js +0 -199
- package/lib/llm-text.d.ts +0 -104
- package/lib/llm-text.js +0 -140
- package/lib/logfile.d.ts +0 -71
- package/lib/logfile.js +0 -159
- package/lib/maintenance-commands.d.ts +0 -23
- package/lib/maintenance-commands.js +0 -136
- package/lib/memory-agent.d.ts +0 -93
- package/lib/memory-agent.js +0 -300
- package/lib/memory-apply.d.ts +0 -44
- package/lib/memory-apply.js +0 -202
- package/lib/memory-benchmark.d.ts +0 -76
- package/lib/memory-benchmark.js +0 -170
- package/lib/memory-index.d.ts +0 -114
- package/lib/memory-index.js +0 -197
- package/lib/memory-manifest.d.ts +0 -16
- package/lib/memory-manifest.js +0 -70
- package/lib/message-source.d.ts +0 -23
- package/lib/message-source.js +0 -12
- package/lib/mount-command.d.ts +0 -10
- package/lib/mount-command.js +0 -48
- package/lib/mount.d.ts +0 -42
- package/lib/mount.js +0 -212
- package/lib/notify.d.ts +0 -48
- package/lib/notify.js +0 -57
- package/lib/plan-command.d.ts +0 -12
- package/lib/plan-command.js +0 -38
- package/lib/plan.d.ts +0 -16
- package/lib/plan.js +0 -126
- package/lib/planner.d.ts +0 -61
- package/lib/planner.js +0 -144
- package/lib/pool.d.ts +0 -7
- package/lib/pool.js +0 -25
- package/lib/prefix-cache.d.ts +0 -79
- package/lib/prefix-cache.js +0 -168
- package/lib/project.d.ts +0 -28
- package/lib/project.js +0 -66
- package/lib/projection.d.ts +0 -22
- package/lib/projection.js +0 -112
- package/lib/promotion.d.ts +0 -94
- package/lib/promotion.js +0 -171
- package/lib/recall.d.ts +0 -85
- package/lib/recall.js +0 -142
- package/lib/record-language.d.ts +0 -85
- package/lib/record-language.js +0 -152
- package/lib/render.d.ts +0 -13
- package/lib/render.js +0 -80
- package/lib/review-scheduler.d.ts +0 -38
- package/lib/review-scheduler.js +0 -183
- package/lib/review.d.ts +0 -60
- package/lib/review.js +0 -145
- package/lib/rollback.d.ts +0 -9
- package/lib/rollback.js +0 -68
- package/lib/rubric.d.ts +0 -29
- package/lib/rubric.js +0 -119
- package/lib/runtime-commands.d.ts +0 -14
- package/lib/runtime-commands.js +0 -115
- package/lib/runtime.d.ts +0 -24
- package/lib/runtime.js +0 -87
- package/lib/score.d.ts +0 -64
- package/lib/score.js +0 -191
- package/lib/search.d.ts +0 -83
- package/lib/search.js +0 -136
- package/lib/service.d.ts +0 -63
- package/lib/service.js +0 -253
- package/lib/skill-render.d.ts +0 -23
- package/lib/skill-render.js +0 -69
- package/lib/skill.d.ts +0 -15
- package/lib/skill.js +0 -80
- package/lib/skillquality.d.ts +0 -85
- package/lib/skillquality.js +0 -320
- package/lib/source.d.ts +0 -30
- package/lib/source.js +0 -43
- package/lib/state.d.ts +0 -26
- package/lib/state.js +0 -151
- package/lib/store.d.ts +0 -61
- package/lib/store.js +0 -164
- package/lib/token-usage.d.ts +0 -68
- package/lib/token-usage.js +0 -211
- package/lib/tool.d.ts +0 -34
- package/lib/tool.js +0 -320
- package/lib/turn-snapshot.d.ts +0 -78
- package/lib/turn-snapshot.js +0 -252
- package/lib/types.d.ts +0 -218
- package/lib/types.js +0 -133
- package/lib/usage.d.ts +0 -36
- package/lib/usage.js +0 -98
- package/lib/validate.d.ts +0 -28
- package/lib/validate.js +0 -181
- package/lib/wrapup-candidates.d.ts +0 -127
- package/lib/wrapup-candidates.js +0 -161
- package/lib/wrapup-command.d.ts +0 -10
- package/lib/wrapup-command.js +0 -243
- package/lib/wrapup-proposals.d.ts +0 -101
- package/lib/wrapup-proposals.js +0 -281
- package/lib/wrapup.d.ts +0 -56
- package/lib/wrapup.js +0 -105
package/README.md
CHANGED
|
@@ -1,171 +1,98 @@
|
|
|
1
1
|
# dsh-continual-evolve
|
|
2
2
|
|
|
3
|
-
[中文](README.zh.md)
|
|
3
|
+
English | [中文](README.zh.md)
|
|
4
4
|
|
|
5
5
|
[](https://awesome-dsh-plugin.com)
|
|
6
6
|
[](https://www.npmjs.com/package/dsh-continual-evolve)
|
|
7
7
|
[](https://github.com/ZK-Andy/dsh-continual-evolve/actions/workflows/ci.yml)
|
|
8
8
|
[](LICENSE)
|
|
9
9
|
[](package.json)
|
|
10
|
-
[]()
|
|
11
11
|
[]()
|
|
12
|
-
[]()
|
|
13
|
+
[]()
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
**The model proposes, the code guarantees.** Every mechanical safety property — schema validation, atomic writes, snapshots, versioning, audit trail, acceptance decisions — is enforced in code, never by prompt discipline.
|
|
15
|
+
A workspace-memory plugin for the [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) (`dsh`): one plain-markdown memory store per workspace (`<workspace>/.evolve/memory/`), the index injected at session start, used by the model with its **native file tools** — and nothing else.
|
|
18
16
|
|
|
19
17
|
## Why
|
|
20
18
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
- **Three scopes** with merge semantics (global < project < local): **local** per-session staging, **project** per-workspace cross-session store, **global** cross-project — plus mechanical promotion guards so only portable, substantial, non-duplicate knowledge reaches global
|
|
24
|
-
- **Typed one-fact memories**: every memory entry carries a recall type (`user | feedback | project | reference`); pitfalls (`feedback`) must include Why + How to apply
|
|
25
|
-
- **Moment-driven background memory agent**: a bounded ZCode-style loop wakes only at low-frequency moments (compaction, goal-blocked streaks, the session-close drain, manual wrapup), searches the frozen memory manifest, and proposes memory-only edits through a closed tool set; it cannot call agents, MCP, the network, or write source files. Successful turns never cost an LLM call — conversation writes own routine sedimentation
|
|
26
|
-
- **Memory recall, projection, and receipts**: `evolve_recall` reads back full memory content by query/kind/scope/type; every memory apply also materializes a readable `MEMORY.md` index plus one fact file per entry; each extraction lands a unified audit receipt (no-op/applied/declined with duration and turn stats) and only applied outcomes notify the session
|
|
27
|
-
- **Deterministic rollback**: inverse edits generated from applied results — no LLM re-guessing
|
|
28
|
-
- **Benchmark loop**: candidate refinements are evaluated against frozen cases by a separate scorer before acceptance (rubric encrypted at rest)
|
|
29
|
-
- **Store hygiene**: `/evolve consolidate` turns write-time conflict hints and zero-use staleness into one approved, fully reversible batch of archives — with `merge`, near-duplicate content folds into the surviving original
|
|
19
|
+
Reusable experience gathered in one session (user preferences, pitfalls, project context) is forgotten by the next. ZCode solves this with a folder: one fact per markdown file plus a `MEMORY.md` index, injected at session start, read and written natively by the model, with no dedicated machinery. This plugin brings that exact shape to DSH.
|
|
30
20
|
|
|
31
21
|
## How it works
|
|
32
22
|
|
|
33
|
-
1. **
|
|
34
|
-
2. **
|
|
35
|
-
3. **
|
|
36
|
-
4. **
|
|
37
|
-
|
|
38
|
-
|
|
23
|
+
1. **Session-start injection** — the plugin registers a single system-prompt section: the `MEMORY.md` index content (whole-line truncated over budget, with a read-the-directory hint), the absolute store path, and the when_to_save guide. The section is computed once per session and reused byte-for-byte, keeping the system prompt stable and the prompt cache warm; an empty store costs zero tokens.
|
|
24
|
+
2. **Native read/write** — DSH fully permits file access inside the workspace (reads are never fenced; the write fence only covers paths outside the workspace, see [`docs/FAQ.md`](docs/FAQ.md) #6). The model reads, writes, and edits memory files and maintains the index directly; the store is bootstrapped on first use.
|
|
25
|
+
3. **Governance is the file** — no versions, no snapshots, no approvals, no background extraction: a bad memory is a visible file in the workspace, and deleting it is the retirement path. Memories are personal context — on bootstrap in a git workspace the store appends `.evolve/` to the workspace `.gitignore` (non-git workspaces are left untouched).
|
|
26
|
+
4. **Read-only card** — the plugin mounts a read-only memory card on its own page in the official plugin manager (the `plugins.bundle.config` slot; hosts without it silently degrade to no card): recently served workspaces, per-workspace entry and index counts, and index-drift warnings (unindexed files, index rows whose file is gone). The card is a request-time projection of the files on disk — the single source of truth remains `.evolve/memory/`; the card has no edit path, edit the files directly.
|
|
27
|
+
|
|
28
|
+
Memory file format (same as ZCode): frontmatter with `name` / `description` (the hook that decides whether a future session recalls it) / `metadata.type` (`user | feedback | project | reference`); `feedback` bodies must carry **Why:** and **How to apply:** lines.
|
|
39
29
|
|
|
40
30
|
## Install
|
|
41
31
|
|
|
42
32
|
```bash
|
|
43
|
-
#
|
|
33
|
+
# From npm (activates on install — ships its own bundle patch)
|
|
44
34
|
dsh plugin add dsh-continual-evolve
|
|
45
35
|
|
|
46
|
-
#
|
|
36
|
+
# Or from source (approve the allowBuilds build step on first GitHub install)
|
|
47
37
|
dsh plugin add ZK-Andy/dsh-continual-evolve
|
|
48
38
|
```
|
|
49
39
|
|
|
50
|
-
|
|
40
|
+
After installing or updating, restart the DSH profile you actually use (`dsh web` or the desktop host).
|
|
51
41
|
|
|
52
42
|
## Usage
|
|
53
43
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
| Command | Effect |
|
|
57
|
-
|---|---|
|
|
58
|
-
| `/evolve` | short help + current local store (`/evolve help all` lists every subcommand) |
|
|
59
|
-
| `/evolve list · history · rollback <id>` | inspect and revert (add `project` for this project's store, `global` for the cross-project store) |
|
|
60
|
-
| `/evolve plan [msg]` | run the LLM planner against the store |
|
|
61
|
-
| `/evolve wrapup` | assess this session's local entries: promote / archive / keep |
|
|
62
|
-
| `/evolve archive · unarchive <id>` | hide from injection (data kept, restorable) |
|
|
63
|
-
| `/evolve consolidate [apply] [merge]` | report (or apply) one batch archive of conflict-hinted + stale zero-use global entries; `merge` folds near-duplicate content into the survivors |
|
|
64
|
-
| `/evolve failures` | aggregated failure classes (gate + benchmark) |
|
|
65
|
-
| `/evolve log [tail N] [session <id>]` | plugin log |
|
|
66
|
-
| `/evolve export · import <path>` | backup / restore a store |
|
|
67
|
-
| `/evolve mount · unmount <skillId>` | hot-mount an executable skill as a live plugin |
|
|
68
|
-
| `/evolve goal [objective · done · block]` | round-driven auto-review goal |
|
|
69
|
-
| `/evolve benchmark …` | case lifecycle, runs, acceptance |
|
|
70
|
-
| `/evolve pause · resume · status` | pause/resume the auto-review gate (manual tools keep working), gate state |
|
|
71
|
-
| `/evolve usage` | per-entry injection counts + exact provider-reported tokens for direct memory/review/planner/wrapup/fate calls (benchmark host subagents excluded) |
|
|
72
|
-
|
|
73
|
-
Model tools: `evolve_list / add / update / delete / rollback / recall` (`evolve_delete` takes `id` or a batch `ids` array — one refinement, one approval; `evolve_recall` filters by query, kinds, scopes, memory types, and limit, and returns full content with version, source, and staleness). Memory reads and writes live in the conversation — the model carries the injected memory index plus `evolve_recall`/`evolve_add` — so there are no `/evolve remember · forget · recall` counterparts: ask in chat.
|
|
74
|
-
|
|
75
|
-
For third-party consumers: every applied evolution (gate or manual) appends a structured `evolve_complete` event to `reviews.jsonl` (`src/evolve-event.ts` defines the shape) alongside the human-readable audit records.
|
|
76
|
-
|
|
77
|
-
`/evolve usage` also reads `evolve/token-usage.jsonl`: exact provider-reported input/cache/output/total tokens for the plugin's direct memory-agent, review, planner, manual-wrapup, and automatic-fate calls. The report covers a retained tail rather than lifetime usage, distinguishes missing provider samples, and explicitly excludes host benchmark subagents, their agent-loop calls, and per-entry injection attribution.
|
|
78
|
-
|
|
79
|
-
Injection shape: prompt notes and delegation specs inject with content (≤6/kind × 180 chars, relevance-ranked). Memories inject as CONTENT at session start: the `evolve:memory-index` section (order 400) carries the when_to_save guide plus every memory body the budget allows, ranked `project > feedback > user > reference`, with overflow degraded to `[memory:type:id] title` hooks and the remainder counted (hard cap `memoryIndex.maxChars`, default 6000 chars; `evolve_recall` reads anything not shown). The section is computed once per session and reused byte-for-byte, so the system prompt stays stable and prompt-cache reads keep hitting — a memory written mid-session appears in the next session. Skills still appear as a relevance-ordered directory index (capped at 15 lines with a fold counter); memories no longer do. Every memory apply also refreshes a readable `MEMORY.md` index plus one fact file per entry in the store directory. With `memoryIndex.guide` off and an empty store, injection is zero tokens.
|
|
44
|
+
No commands, no tools. On the first session after restart, `.evolve/memory/` is created and the index is injected automatically. Just tell the model "remember …" / "forget …" — the memory files plus their index lines are the entire persistent state. Memories written mid-session become visible in the next session (the section is frozen to protect the prompt cache); for an immediate look the model simply reads the directory. To see the whole store, open the plugin's page in the official plugin manager: the read-only card shows each workspace's entries and index drift.
|
|
80
45
|
|
|
81
46
|
## Configuration
|
|
82
47
|
|
|
83
48
|
| Key | Default | Meaning |
|
|
84
49
|
|---|---|---|
|
|
85
|
-
| `
|
|
86
|
-
| `
|
|
87
|
-
| `
|
|
88
|
-
| `
|
|
89
|
-
| `
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
| `requireGlobalApproval` | `true` | global and project edits ask for explicit approval |
|
|
93
|
-
| `recordLanguage` | `auto` | authoring **and dialog** language: `auto` follows the DSH client preference, then the session's own user text, then `en`; `zh`/`en` pin it |
|
|
94
|
-
| `goalBlockedWrapupTurns` | `3` | consecutive blocked-goal idle probes trigger one memory extraction (`0` disables) |
|
|
95
|
-
| `promotionBlockPatterns` | POSIX paths, session ids, `~/.dsh` | content matching these is project-scoped and never promoted to global |
|
|
96
|
-
| `promotionMinChars` | `100` | whole promotions below this length stay local |
|
|
97
|
-
| `injectionDirectoryLines` | `15` | entry-directory lines per build before folding into a counter |
|
|
98
|
-
| `sectionOrder` | `118` | system-prompt section order for the guidance + entries sections |
|
|
99
|
-
| `memoryIndex.enabled` | `true` | register the `evolve:memory-index` content section |
|
|
100
|
-
| `memoryIndex.guide` | `true` | include the when_to_save guide (with the store empty and this off, the section renders nothing) |
|
|
101
|
-
| `memoryIndex.order` | `400` | section order (upstream named slots start at `PLAN_POLICY=500`; the plugin's other sections sit at 118/119) |
|
|
102
|
-
| `memoryIndex.maxChars` | `6000` | hard character budget for the injected memories block |
|
|
103
|
-
| `skillsDir` | `<dshHome>/skills` | where skill entries materialize as SKILL.md bundles |
|
|
104
|
-
| `rubricKey` | auto-generated key file | AES-256-GCM passphrase for benchmark rubrics (`DSH_EVOLVE_RUBRIC_KEY` overrides) |
|
|
105
|
-
| `logToFile` / `logLevel` / `logMaxBytes` | `true` / `1` / 5 MiB | plugin-owned JSONL file log with rotation |
|
|
106
|
-
| `autoRollbackOnReject` | `true` | deterministic rollback after a benchmark rejection |
|
|
107
|
-
| `autoCase` | `true` | failed evolution attempts are captured as draft regression cases (`auto_regression` benchmark) |
|
|
108
|
-
| `reviewModel` | agent's own | optional cheaper model for the dedicated memory agent (`"provider/model"`) |
|
|
109
|
-
| `plannerPrefixCache` | `auto` | Route A session-prefix input when cache evidence exists (`session` always, `off` legacy flat text) |
|
|
110
|
-
| `plannerPrefixMaxChars` | `12000` | session-prefix budget for Route A planning inputs (chars) |
|
|
111
|
-
| `historyRetain` | `{snapshots: 20, refinements: 500, reviews: 500, tokenUsage: 500}` | storage hygiene: snapshots per store, tail lines per store history, shared `reviews.jsonl` tail, and direct-call `token-usage.jsonl` tail |
|
|
112
|
-
|
|
113
|
-
Example profile patch:
|
|
50
|
+
| `memoryIndex.enabled` | `true` | Register the memory section |
|
|
51
|
+
| `memoryIndex.guide` | `true` | Inject the when_to_save guide (zero tokens when off and the index is empty) |
|
|
52
|
+
| `memoryIndex.order` | `400` | Section order (upstream named slots start at `PLAN_POLICY=500`) |
|
|
53
|
+
| `memoryIndex.maxChars` | `6000` | Hard character budget for the injected index |
|
|
54
|
+
| `memoryCard.enabled` | `true` | Read-only memory card in the official plugin manager (degrades to no card when the host lacks `webServer`/`plugins.bundle.config`) |
|
|
55
|
+
|
|
56
|
+
Profile patch example:
|
|
114
57
|
|
|
115
58
|
```yaml
|
|
116
59
|
- id: continual-evolve
|
|
117
60
|
config:
|
|
118
|
-
|
|
61
|
+
memoryIndex:
|
|
62
|
+
maxChars: 8000
|
|
119
63
|
```
|
|
120
64
|
|
|
121
|
-
The Memory Agent listener is registered even when `autoReview` is `false` —
|
|
122
|
-
`autoReview` only supplies the initial default, so an install works without
|
|
123
|
-
editing the profile. Use `/evolve resume` to enable extraction moments
|
|
124
|
-
immediately, `/evolve pause` to suppress new model work, and `/evolve status`
|
|
125
|
-
to inspect the configured default plus the current runtime state. The runtime
|
|
126
|
-
switch is stored in `evolve/runtime.json`; manual `evolve_*` tools and
|
|
127
|
-
`/evolve` commands are not paused. The memory trigger follows ZCode's
|
|
128
|
-
lightweight eligibility: direct user text must contain at least
|
|
129
|
-
`memoryMinUserWords` lexical words (CJK-aware segmentation), while
|
|
130
|
-
empty/internal/direct-memory-write snapshots are skipped. Every extraction
|
|
131
|
-
writes a unified audit receipt (`noop`/`applied`/`declined` with duration and
|
|
132
|
-
turn/search stats) to `reviews.jsonl`; only an applied goal-blocked moment
|
|
133
|
-
queues a visible follow-up, and a closing session lets in-flight extraction
|
|
134
|
-
settle up to `sessionCloseDrainMs` before aborting.
|
|
135
|
-
|
|
136
65
|
## Development
|
|
137
66
|
|
|
138
67
|
```bash
|
|
139
68
|
pnpm install && pnpm build # deps + tsc -> lib/
|
|
140
|
-
pnpm test # vitest (
|
|
141
|
-
pnpm test:coverage # v8 coverage,
|
|
142
|
-
pnpm coverage:gaps # locate uncovered lines per file (read-only)
|
|
69
|
+
pnpm test # vitest (62 tests)
|
|
70
|
+
pnpm test:coverage # v8 coverage, CI-enforced thresholds
|
|
143
71
|
pnpm lint # oxlint src test
|
|
144
72
|
```
|
|
145
73
|
|
|
146
|
-
|
|
74
|
+
Layout:
|
|
147
75
|
|
|
148
76
|
```
|
|
149
|
-
├── src/
|
|
150
|
-
├──
|
|
77
|
+
├── src/
|
|
78
|
+
│ ├── index.ts # registration: the one section + config + card route wiring
|
|
79
|
+
│ ├── memory-section.ts # injection: read index / bootstrap / truncate / session freeze
|
|
80
|
+
│ ├── memory-guide.ts # guide: when_to_save and upkeep (adapted from ZCode)
|
|
81
|
+
│ ├── memory-snapshot.ts # card: read-only store projection (entries / drift / error degrade)
|
|
82
|
+
│ ├── known-workspaces.ts# card: in-process LRU workspace allowlist (the API read fence)
|
|
83
|
+
│ └── card-routes.ts # card: GET-only read API on the host webServer
|
|
84
|
+
├── client/
|
|
85
|
+
│ └── client.js # hand-written client bundle: read-only card in the plugin manager
|
|
86
|
+
├── test/ # vitest suite (7 files)
|
|
151
87
|
├── lib/ # build output (tsc)
|
|
152
|
-
├── docs/
|
|
153
|
-
│ ├── design.md # the one-loop design narrative
|
|
154
|
-
│ ├── FAQ.md # real failure/fix records
|
|
155
|
-
│ ├── gap-analysis.md # vs prime-agent /refine + penguin-harness
|
|
156
|
-
│ ├── research/pi-dsh-competitor-gap-analysis.md # pi/dsh ecosystem competitors
|
|
157
|
-
│ ├── experiment-bootstrap.md
|
|
158
|
-
│ ├── archive/ # closed point-in-time reports
|
|
159
|
-
│ └── research/ # penguin report + prime-agent annotated source
|
|
160
|
-
├── examples/README.md # seed benchmark cases
|
|
88
|
+
├── docs/ # design.md (design) · FAQ.md (real-world pitfalls)
|
|
161
89
|
└── .agents/ # AI collaboration layer (AGENTS.md, skills, ADR notes)
|
|
162
90
|
```
|
|
163
91
|
|
|
164
|
-
## Docs
|
|
92
|
+
## Docs
|
|
165
93
|
|
|
166
|
-
- Design: [`docs/design.md`](docs/design.md) · Pitfalls: [`docs/FAQ.md`](docs/FAQ.md) ·
|
|
167
|
-
- Lineage: **penguin-harness** (concept; Apache-2.0) — report in [`docs/research/penguin-harness-self-evolution.md`](docs/research/penguin-harness-self-evolution.md); **prime-agent `/refine`** (engineering shape; MIT) — annotated reference source in [`docs/research/prime-agent-refinement.ts`](docs/research/prime-agent-refinement.ts). This package is an original implementation on the DSH plugin surface.
|
|
94
|
+
- Design: [`docs/design.md`](docs/design.md) · Pitfalls: [`docs/FAQ.md`](docs/FAQ.md) · Teardown decision: [`.agents/notes/implemented/architecture/2026-10-04-zcode-alignment-teardown.md`](.agents/notes/implemented/architecture/2026-10-04-zcode-alignment-teardown.md)
|
|
168
95
|
|
|
169
96
|
## License
|
|
170
97
|
|
|
171
|
-
|
|
98
|
+
MIT. Independent project — not affiliated with DeepSeek.
|
package/README.zh.md
CHANGED
|
@@ -7,35 +7,25 @@
|
|
|
7
7
|
[](https://github.com/ZK-Andy/dsh-continual-evolve/actions/workflows/ci.yml)
|
|
8
8
|
[](LICENSE)
|
|
9
9
|
[](package.json)
|
|
10
|
-
[]()
|
|
11
11
|
[]()
|
|
12
|
-
[]()
|
|
13
|
+
[]()
|
|
14
14
|
|
|
15
|
-
[DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness)(`dsh
|
|
16
|
-
|
|
17
|
-
**模型提议,代码保证。** 每一项机械化安全属性——schema 校验、原子写入、快照、版本、审计、接受决策——都由代码强制,从不依赖提示词自觉。
|
|
15
|
+
[DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness)(`dsh`)的工作区记忆插件:每个工作区一个纯 markdown 记忆库(`<workspace>/.evolve/memory/`),会话开局注入索引,模型用**原生文件读写工具**直接使用——仅此而已。
|
|
18
16
|
|
|
19
17
|
## 为什么
|
|
20
18
|
|
|
21
|
-
Agent
|
|
22
|
-
|
|
23
|
-
- **三作用域**与合并语义(global < project < local):**local** 本会话暂存、**project** 本项目跨会话库、**global** 跨项目——配合机械化晋升守卫,只有可携带、有分量、非重复的知识才能进全局
|
|
24
|
-
- **类型化单条记忆**:每条 memory 带召回类型(`user | feedback | project | reference`);踩坑(`feedback`)必须含 Why + How to apply
|
|
25
|
-
- **时刻驱动的后台记忆 Agent**:有界 ZCode 式 loop 只在四个低频时刻醒来(压缩、goal 连续受阻、会话收尾 drain、手动 wrapup),检索冻结的 memory manifest,并经闭集工具提出纯 memory 编辑;不能调用 Agent、MCP、网络,也不能写源码。成功回合零 LLM 成本——日常沉淀由对话直写承担
|
|
26
|
-
- **记忆召回、投影与回执**:`evolve_recall` 按 query/kind/scope/type 精确读回记忆全文;每次 memory 落盘同时生成可读的 `MEMORY.md` 索引 + 单事实文件;每次提取留统一审计回执(no-op/applied/declined + 耗时与轮次统计),只有实际沉淀才通知会话
|
|
27
|
-
- **确定性回滚**:逆操作编辑由已应用结果生成——不靠 LLM 重新猜测
|
|
28
|
-
- **benchmark 闭环**:候选沉淀先经冻结用例 + 独立评分者评估再接受(rubric 加密落盘)
|
|
29
|
-
- **store 卫生**:`/evolve consolidate` 把写入时冲突提示与零使用陈旧条目变成一次批准、完全可逆的批量归档——加 `merge` 可将近重复内容并入幸存原条目
|
|
19
|
+
Agent 每个会话积累的可复用经验(用户偏好、踩坑教训、项目背景)下个会话就忘。ZCode 用一个文件夹解决了这件事:一事一文的 md 记忆 + `MEMORY.md` 索引、开局注入、模型原生读写、没有任何专用机器。本插件把同一形态带给 DSH。
|
|
30
20
|
|
|
31
21
|
## 工作原理
|
|
32
22
|
|
|
33
|
-
1.
|
|
34
|
-
2.
|
|
35
|
-
3.
|
|
36
|
-
4.
|
|
37
|
-
|
|
38
|
-
|
|
23
|
+
1. **开局注入** —— 插件只注册一个 system-prompt section:注入 `MEMORY.md` 索引正文(超预算按整行截断并提示读目录)、记忆目录绝对路径、when_to_save 指南。该 section 每会话只算一次并逐字节复用,system prompt 稳定、prompt cache 持续命中;空 store 零 token。
|
|
24
|
+
2. **原生读写** —— DSH 对工作区内文件读写全放行(读路径从不设防,写围栏只围工作区外,见 [`docs/FAQ.md`](docs/FAQ.md) #6)。模型直接 Read/Write/Edit 记忆文件并维护索引;store 不存在时自动 bootstrap。
|
|
25
|
+
3. **治理即文件** —— 无版本、无快照、无审批、无后台提取:一条坏记忆就是工作区里一个可见的文件,删掉它就是退役。记忆是个人上下文——bootstrap 时若工作区是 git 仓库会自动把 `.evolve/` 追加进 `.gitignore`(非 git 工作区不碰任何文件)。
|
|
26
|
+
4. **只读卡片** —— 插件在官方插件管理的本 bundle 页面挂一张只读记忆卡片(`plugins.bundle.config` slot,老宿主自动降级为无卡片):最近服务过的工作区、各自记忆库的条目数/索引行数、索引漂移警告(未索引文件与索引失联文件)。卡片是磁盘文件的请求时投影——单一事实源永远是 `.evolve/memory/` 里的文件,卡片没有编辑路径,编辑请直接改文件。
|
|
27
|
+
|
|
28
|
+
记忆文件格式(与 ZCode 一致):frontmatter 带 `name` / `description`(决定未来会话会不会想起它)/ `metadata.type`(`user | feedback | project | reference`);`feedback` 正文必带 **Why:** 与 **How to apply:**。
|
|
39
29
|
|
|
40
30
|
## 安装
|
|
41
31
|
|
|
@@ -51,107 +41,57 @@ dsh plugin add ZK-Andy/dsh-continual-evolve
|
|
|
51
41
|
|
|
52
42
|
## 使用
|
|
53
43
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
| 命令 | 效果 |
|
|
57
|
-
|---|---|
|
|
58
|
-
| `/evolve` | 简短帮助 + 当前 local store(`/evolve help all` 列全部子命令) |
|
|
59
|
-
| `/evolve list · history · rollback <id>` | 查看与回滚(加 `project` 操作本项目库,`global` 操作跨项目库) |
|
|
60
|
-
| `/evolve plan [msg]` | 对 store 运行 LLM 规划器 |
|
|
61
|
-
| `/evolve wrapup` | 收尾本会话 local 条目:晋升 / 归档 / 保留 |
|
|
62
|
-
| `/evolve archive · unarchive <id>` | 从注入中隐藏(数据保留可恢复) |
|
|
63
|
-
| `/evolve consolidate [apply] [merge]` | 报告(或应用)冲突提示 + 零使用陈旧全局条目的批量归档;`merge` 将近重复内容并入幸存原条目 |
|
|
64
|
-
| `/evolve failures` | 失败类聚合(门禁 + benchmark) |
|
|
65
|
-
| `/evolve log [tail N] [session <id>]` | 插件日志 |
|
|
66
|
-
| `/evolve export · import <path>` | 备份 / 恢复 store |
|
|
67
|
-
| `/evolve mount · unmount <skillId>` | 把可执行技能热挂载为 live 插件 |
|
|
68
|
-
| `/evolve goal [objective · done · block]` | 回合驱动的自进化目标 |
|
|
69
|
-
| `/evolve benchmark …` | 用例生命周期、运行、接受决策 |
|
|
70
|
-
| `/evolve pause · resume · status` | 暂停/恢复自动提取(手动工具不受影响)、运行时状态 |
|
|
71
|
-
| `/evolve usage` | 每条目注入次数 + memory/planner/wrapup 直属调用的 provider 精确 token(不含 benchmark 宿主子代理) |
|
|
72
|
-
|
|
73
|
-
模型工具:`evolve_list / add / update / delete / rollback / recall`(`evolve_delete` 支持 `id` 或批量 `ids` 数组——一次 refinement、一次审批;`evolve_recall` 按 query/kind/scope/memoryType/limit 过滤,返回全文 + 版本 + 来源 + 过时信号)。记忆的读写都在对话里完成——模型手里有注入的记忆索引 + `evolve_recall`/`evolve_add`——因此不再有 `/evolve remember · forget · recall` 对应命令:直接在对话里说。
|
|
74
|
-
|
|
75
|
-
第三方消费:每次进化落地(门禁或手动)都会向 `reviews.jsonl` 追加结构化 `evolve_complete` 事件(shape 见 `src/evolve-event.ts`),与人类可读的审计记录并存。
|
|
76
|
-
|
|
77
|
-
`/evolve usage` 还会读取 `evolve/token-usage.jsonl`:插件直属 memory Agent、planner 与手动 wrapup 调用的 provider 精确 input/cache/output/total token。报告只覆盖保留尾部而非终身累计,单独显示 provider 未返回 usage 的调用,并明确排除宿主 benchmark 子代理、其 agent-loop 调用与逐条 memory 注入归因。
|
|
78
|
-
|
|
79
|
-
注入形态:prompt 补充与委派规格带内容注入(每 kind ≤6 条 × 180 字符,按相关性排序)。memory 以**正文**在会话开场注入:`evolve:memory-index` section(order 400)承载 when_to_save 指南 + 预算内的全部记忆正文,排序 `project > feedback > user > reference`,放不下的降级为 `[memory:type:id] 标题`钩子、其余折叠计数(硬上限 `memoryIndex.maxChars`,默认 6000 字符;未展示的用 `evolve_recall` 读)。该 section 每会话只算一次并逐字节复用,system prompt 因此稳定、prompt cache 持续命中——会话中途写入的记忆下个会话生效。skill 仍以按相关性排序的目录索引出现(15 行封顶 + 折叠计数行),memory 不再列入。每次 memory 落盘同时刷新 store 目录下的可读 `MEMORY.md` 索引 + 单事实文件。`memoryIndex.guide` 关闭且 store 为空时 = 零注入 token。
|
|
44
|
+
无需命令、无需工具。重启后第一场会话,`.evolve/memory/` 会自动生成,索引自动注入开场;对模型直接说"记住……"/"忘掉……"即可,写入的记忆文件 + 索引行就是全部持久状态。会话中途写入的记忆下个会话生效(会话内冻结守 prompt cache);需要立即查看时,模型直接读目录。想看记忆库全貌,打开官方插件管理里本插件的页面:只读卡片展示各工作区的记忆条目与索引漂移。
|
|
80
45
|
|
|
81
46
|
## 配置
|
|
82
47
|
|
|
83
48
|
| 键 | 默认 | 含义 |
|
|
84
49
|
|---|---|---|
|
|
85
|
-
| `
|
|
86
|
-
| `
|
|
87
|
-
| `
|
|
88
|
-
| `
|
|
89
|
-
| `
|
|
90
|
-
| `reviewBudgetTokens` | `4096` | 提取 loop 输出预算 |
|
|
91
|
-
| `notifyOnAutoReview` | `true` | goal 受阻时刻应用后发可见跟进回执(压缩与会话收尾只留审计) |
|
|
92
|
-
| `requireGlobalApproval` | `true` | 全局与项目写入需明确批准 |
|
|
93
|
-
| `recordLanguage` | `auto` | 记录**与弹窗**语言:`auto` 依次跟随 DSH 客户端偏好 → 会话自身用户文本 → `en`;`zh`/`en` 固定 |
|
|
94
|
-
| `goalBlockedWrapupTurns` | `3` | 连续阻塞目标的 idle 探测轮数触发一次记忆提取(`0` 关闭) |
|
|
95
|
-
| `promotionBlockPatterns` | POSIX 路径、session id、`~/.dsh` | 内容命中即判定项目专属,永不晋升全局 |
|
|
96
|
-
| `promotionMinChars` | `100` | 低于此长度的整体晋升留在本地 |
|
|
97
|
-
| `injectionDirectoryLines` | `15` | 每次构建的目录行数上限,超出折叠为计数行 |
|
|
98
|
-
| `sectionOrder` | `118` | 指南与条目两个 section 的系统提示词顺序 |
|
|
99
|
-
| `memoryIndex.enabled` | `true` | 是否注册 `evolve:memory-index` 内容 section |
|
|
100
|
-
| `memoryIndex.guide` | `true` | 是否注入 when_to_save 指南(关闭且 store 为空时该 section 不渲染) |
|
|
101
|
-
| `memoryIndex.order` | `400` | section 顺序(上游命名槽位自 `PLAN_POLICY=500` 起;本插件另两段在 118/119) |
|
|
102
|
-
| `memoryIndex.maxChars` | `6000` | 注入记忆块的硬字符预算 |
|
|
103
|
-
| `skillsDir` | `<dshHome>/skills` | 技能条目物化为 SKILL.md 的根目录 |
|
|
104
|
-
| `rubricKey` | 自动生成本地密钥文件 | benchmark rubric 的 AES-256-GCM 口令(`DSH_EVOLVE_RUBRIC_KEY` 可覆盖) |
|
|
105
|
-
| `logToFile` / `logLevel` / `logMaxBytes` | `true` / `1` / 5 MiB | 插件自带 JSONL 文件日志带轮转 |
|
|
106
|
-
| `autoRollbackOnReject` | `true` | benchmark 拒绝后自动确定性回滚 |
|
|
107
|
-
| `autoCase` | `true` | 失败的进化尝试自动沉淀为 draft 回归用例(`auto_regression` 基准) |
|
|
108
|
-
| `reviewModel` | agent 自身 | 专用 memory Agent 可选更便宜的模型(`"provider/model"`) |
|
|
109
|
-
| `plannerPrefixCache` | `auto` | 有缓存证据时用会话前缀输入(`session` 总是前缀,`off` 保持旧扁平文本) |
|
|
110
|
-
| `plannerPrefixMaxChars` | `12000` | Route A 会话前缀预算(字符) |
|
|
111
|
-
| `historyRetain` | `{snapshots: 20, refinements: 500, reviews: 500, tokenUsage: 500}` | 存储卫生:每 store 快照数、每 store 历史尾行、共享 `reviews.jsonl` 尾行、直属调用 `token-usage.jsonl` 尾行 |
|
|
50
|
+
| `memoryIndex.enabled` | `true` | 是否注册记忆 section |
|
|
51
|
+
| `memoryIndex.guide` | `true` | 是否注入 when_to_save 指南(关闭且索引为空时该 section 零 token) |
|
|
52
|
+
| `memoryIndex.order` | `400` | section 顺序(上游命名槽位自 `PLAN_POLICY=500` 起) |
|
|
53
|
+
| `memoryIndex.maxChars` | `6000` | 注入索引的硬字符预算 |
|
|
54
|
+
| `memoryCard.enabled` | `true` | 官方插件管理内的只读记忆卡片(宿主缺 `webServer`/`plugins.bundle.config` 时自动降级为无卡片) |
|
|
112
55
|
|
|
113
56
|
profile patch 示例:
|
|
114
57
|
|
|
115
58
|
```yaml
|
|
116
59
|
- id: continual-evolve
|
|
117
60
|
config:
|
|
118
|
-
|
|
61
|
+
memoryIndex:
|
|
62
|
+
maxChars: 8000
|
|
119
63
|
```
|
|
120
64
|
|
|
121
|
-
即使 `autoReview` 为 `false`,Memory Agent 监听器也会注册——`autoReview` 只提供初始默认值,装完即用,无需改 profile。使用 `/evolve resume` 立即开启提取时刻,使用 `/evolve pause` 抑制新的模型调用,使用 `/evolve status` 查看配置默认值与运行时状态。开关保存在 `evolve/runtime.json`;手动 `evolve_*` 工具和 `/evolve` 命令不受暂停影响。提取时刻驱动:压缩、goal 连续受阻(`goalBlockedWrapupTurns` 次 idle 探测)、会话收尾 drain(`sessionCloseDrainMs`)与手动 `/evolve wrapup`——成功回合零 LLM 成本。Memory 触发采用 ZCode 的轻量 eligibility:单个直接用户文本至少包含 `memoryMinUserWords` 个词(使用 CJK 分词);空增量、内部 Agent、直接 memory 写入会跳过。每次提取都在 `reviews.jsonl` 留统一审计回执(`noop`/`applied`/`declined` + 耗时与轮次/检索统计);只有 goal 受阻时刻的实际沉淀才排队前台回执,关闭的会话让在途提取在 `sessionCloseDrainMs` 内收尾再 abort。
|
|
122
|
-
|
|
123
65
|
## 开发
|
|
124
66
|
|
|
125
67
|
```bash
|
|
126
68
|
pnpm install && pnpm build # 依赖 + tsc -> lib/
|
|
127
|
-
pnpm test # vitest(
|
|
69
|
+
pnpm test # vitest(62 例)
|
|
128
70
|
pnpm test:coverage # v8 覆盖率,CI 强制阈值
|
|
129
|
-
pnpm coverage:gaps # 定位各文件未覆盖行(只读)
|
|
130
71
|
pnpm lint # oxlint src test
|
|
131
72
|
```
|
|
132
73
|
|
|
133
74
|
目录结构:
|
|
134
75
|
|
|
135
76
|
```
|
|
136
|
-
├── src/
|
|
137
|
-
├──
|
|
77
|
+
├── src/
|
|
78
|
+
│ ├── index.ts # 注册:唯一 section + 配置 + 卡片路由接线
|
|
79
|
+
│ ├── memory-section.ts # 注入:读索引 / bootstrap / 截断 / 会话冻结
|
|
80
|
+
│ ├── memory-guide.ts # 指南:when_to_save 与维护纪律(改编自 ZCode)
|
|
81
|
+
│ ├── memory-snapshot.ts # 卡片:记忆库只读投影(条目 / 漂移 / 错误降级)
|
|
82
|
+
│ ├── known-workspaces.ts# 卡片:进程内 LRU 工作区白名单(API 读围栏)
|
|
83
|
+
│ └── card-routes.ts # 卡片:webServer 上的 GET-only 只读 API
|
|
84
|
+
├── client/
|
|
85
|
+
│ └── client.js # 手写 client bundle:官方插件管理内只读卡片
|
|
86
|
+
├── test/ # vitest 测试(7 个文件)
|
|
138
87
|
├── lib/ # 构建产物(tsc)
|
|
139
|
-
├── docs/
|
|
140
|
-
│ ├── design.md # 一条循环的设计叙事
|
|
141
|
-
│ ├── FAQ.md # 真实踩坑记录
|
|
142
|
-
│ ├── gap-analysis.md # 对照 prime-agent /refine + penguin-harness
|
|
143
|
-
│ ├── research/pi-dsh-competitor-gap-analysis.md # pi/dsh 生态竞品差距分析
|
|
144
|
-
│ ├── experiment-bootstrap.md
|
|
145
|
-
│ ├── archive/ # 已完结的一次性报告
|
|
146
|
-
│ └── research/ # penguin 报告 + prime-agent 注释源码
|
|
147
|
-
├── examples/README.md # 种子 benchmark 用例
|
|
88
|
+
├── docs/ # design.md(设计)· FAQ.md(踩坑)
|
|
148
89
|
└── .agents/ # AI 协作层(AGENTS.md、技能、ADR 笔记)
|
|
149
90
|
```
|
|
150
91
|
|
|
151
|
-
##
|
|
92
|
+
## 文档
|
|
152
93
|
|
|
153
|
-
- 设计:[`docs/design.md`](docs/design.md) · 踩坑:[`docs/FAQ.md`](docs/FAQ.md) ·
|
|
154
|
-
- 血统:**penguin-harness**(概念;Apache-2.0)——报告见 [`docs/research/penguin-harness-self-evolution.md`](docs/research/penguin-harness-self-evolution.md);**prime-agent `/refine`**(工程形态;MIT)——注释参考源码见 [`docs/research/prime-agent-refinement.ts`](docs/research/prime-agent-refinement.ts)。本包是面向 DSH 插件表面的原创实现。
|
|
94
|
+
- 设计:[`docs/design.md`](docs/design.md) · 踩坑:[`docs/FAQ.md`](docs/FAQ.md) · 拆解决策:[`.agents/notes/implemented/architecture/2026-10-04-zcode-alignment-teardown.md`](.agents/notes/implemented/architecture/2026-10-04-zcode-alignment-teardown.md)
|
|
155
95
|
|
|
156
96
|
## License
|
|
157
97
|
|