dsh-continual-evolve 0.1.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.
- package/LICENSE +21 -0
- package/README.md +290 -0
- package/README.zh.md +240 -0
- package/cordis.patch.yml +9 -0
- package/lib/apply.d.ts +24 -0
- package/lib/apply.js +131 -0
- package/lib/approval.d.ts +14 -0
- package/lib/approval.js +27 -0
- package/lib/auto.d.ts +34 -0
- package/lib/auto.js +217 -0
- package/lib/benchmark.d.ts +72 -0
- package/lib/benchmark.js +167 -0
- package/lib/command.d.ts +36 -0
- package/lib/command.js +549 -0
- package/lib/evaluate.d.ts +38 -0
- package/lib/evaluate.js +142 -0
- package/lib/goal.d.ts +72 -0
- package/lib/goal.js +72 -0
- package/lib/index.d.ts +93 -0
- package/lib/index.js +116 -0
- package/lib/inject.d.ts +124 -0
- package/lib/inject.js +231 -0
- package/lib/logfile.d.ts +71 -0
- package/lib/logfile.js +159 -0
- package/lib/mount.d.ts +42 -0
- package/lib/mount.js +198 -0
- package/lib/notify.d.ts +31 -0
- package/lib/notify.js +42 -0
- package/lib/plan.d.ts +16 -0
- package/lib/plan.js +121 -0
- package/lib/planner.d.ts +30 -0
- package/lib/planner.js +110 -0
- package/lib/pool.d.ts +7 -0
- package/lib/pool.js +25 -0
- package/lib/render.d.ts +15 -0
- package/lib/render.js +83 -0
- package/lib/review.d.ts +37 -0
- package/lib/review.js +127 -0
- package/lib/rollback.d.ts +11 -0
- package/lib/rollback.js +69 -0
- package/lib/rubric.d.ts +29 -0
- package/lib/rubric.js +119 -0
- package/lib/score.d.ts +31 -0
- package/lib/score.js +81 -0
- package/lib/service.d.ts +30 -0
- package/lib/service.js +42 -0
- package/lib/skill.d.ts +10 -0
- package/lib/skill.js +75 -0
- package/lib/source.d.ts +29 -0
- package/lib/source.js +42 -0
- package/lib/state.d.ts +34 -0
- package/lib/state.js +154 -0
- package/lib/store.d.ts +20 -0
- package/lib/store.js +74 -0
- package/lib/tool.d.ts +15 -0
- package/lib/tool.js +163 -0
- package/lib/types.d.ts +137 -0
- package/lib/types.js +62 -0
- package/lib/validate.d.ts +11 -0
- package/lib/validate.js +55 -0
- package/package.json +67 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 dsh-continual-evolve contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
# dsh-continual-evolve
|
|
2
|
+
|
|
3
|
+
[中文](README.zh.md) | English
|
|
4
|
+
|
|
5
|
+
[](https://awesome-dsh-plugin.com)
|
|
6
|
+
[](https://github.com/ZK-Andy/dsh-continual-evolve/actions/workflows/ci.yml)
|
|
7
|
+
[](LICENSE)
|
|
8
|
+
[](package.json)
|
|
9
|
+
[]()
|
|
10
|
+
[]()
|
|
11
|
+
|
|
12
|
+
Continual self-evolution for [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness): a versioned, auditable, rollback-safe layer of harness state — prompt notes, memories, skills, and subagent specs — refined from session trajectories.
|
|
13
|
+
|
|
14
|
+
> **Status: all phases complete; in long-term maintenance.** Phases 1–3
|
|
15
|
+
> shipped the full evolution loop: the pure-core engine, model tools and
|
|
16
|
+
> the `/evolve` command, the automatic review gate (turn-interval +
|
|
17
|
+
> compaction checkpoints, human approval for global edits), real
|
|
18
|
+
> system-prompt injection (prompt notes + delegation specs, zero token
|
|
19
|
+
> cost when empty), and the benchmark-driven validation loop (code-owned
|
|
20
|
+
> scoring, non-regressive acceptance, rubric ACL). Since then the plugin
|
|
21
|
+
> keeps growing with usage-driven enhancements — the memory layer (ranked
|
|
22
|
+
> injection, trajectory citations, archive), per-installation rubric keys,
|
|
23
|
+
> and plugin-owned file logging. See the Roadmap for the full shipped and
|
|
24
|
+
> candidate lists.
|
|
25
|
+
|
|
26
|
+
## Background
|
|
27
|
+
|
|
28
|
+
This project started as a research question: *can a harness improve itself,
|
|
29
|
+
and what would a production-grade version look like?* Three lines of evidence
|
|
30
|
+
shaped the answer:
|
|
31
|
+
|
|
32
|
+
- **penguin-harness** demonstrated the concept (benchmark → evaluate →
|
|
33
|
+
optimize → accept/rollback) but with **zero code-level enforcement** — every
|
|
34
|
+
guarantee was a prompt contract. Its report (`docs/research/`) became the
|
|
35
|
+
hardening checklist this project implements.
|
|
36
|
+
- **prime-agent `/refine`** proved the engineering shape: versioned harness
|
|
37
|
+
entries, atomic persistence, optimistic concurrency, inverse-op rollback.
|
|
38
|
+
This package is an original implementation of that shape on the DSH plugin
|
|
39
|
+
surface.
|
|
40
|
+
- Academic work (Self-Harness, AHE, HarnessOpt-Bench) supplied the discipline:
|
|
41
|
+
frozen evaluation runtime, code-owned aggregation, non-regressive
|
|
42
|
+
acceptance.
|
|
43
|
+
|
|
44
|
+
The result: **the model proposes, the code guarantees.** Every mechanical
|
|
45
|
+
safety property (schema validation, snapshots, versioning, audit trail,
|
|
46
|
+
acceptance decisions) is enforced in code — never by asking the model to
|
|
47
|
+
behave.
|
|
48
|
+
|
|
49
|
+
## Why
|
|
50
|
+
|
|
51
|
+
Agents accumulate reusable experience in every session — repeated failures, durable facts, reusable procedures — and then forget it at the next turn or session. This plugin makes that experience first-class persistent state:
|
|
52
|
+
|
|
53
|
+
- **Versioned entries** keyed by kind (`prompt` / `memory` / `skill` / `subagent`), each with a recorded provenance and version
|
|
54
|
+
- **Evidence trail**: every refinement appends an event carrying `trigger / changes / evidence / outcome`
|
|
55
|
+
- **Deterministic rollback**: inverse edits are generated from applied results — no LLM re-guessing
|
|
56
|
+
- **Code-enforced safety**, not prompt discipline: schema validation, atomic writes, corrupt-file degrade, optimistic concurrency, immutable base system prompt
|
|
57
|
+
- **Local (session) and global (cross-session) scopes** with merge semantics
|
|
58
|
+
|
|
59
|
+
## Design provenance
|
|
60
|
+
|
|
61
|
+
Inspired by three bodies of work (see [`docs/design.md`](docs/design.md)):
|
|
62
|
+
|
|
63
|
+
- **prime-agent `/refine`** (MIT): the state model, atomic persistence, optimistic concurrency, per-edit validation, and inverse-op rollback this package implements — annotated reference source in [`docs/research/prime-agent-refinement.ts`](docs/research/prime-agent-refinement.ts). The code here is an original implementation, written for the DSH plugin surface.
|
|
64
|
+
- **penguin-harness** (Apache-2.0): the benchmark-driven evolution loop — research report in [`docs/research/penguin-harness-self-evolution.md`](docs/research/penguin-harness-self-evolution.md); its prompt-only contracts are the anti-pattern this package hardens.
|
|
65
|
+
- Academic: Self-Harness (arXiv 2606.09498), AHE (arXiv 2604.25850), HarnessOpt-Bench (arXiv 2608.06301).
|
|
66
|
+
|
|
67
|
+
## Tech stack
|
|
68
|
+
|
|
69
|
+
| Layer | Choice |
|
|
70
|
+
|---|---|
|
|
71
|
+
| Language | TypeScript (strict, ES2024, ESM) |
|
|
72
|
+
| Runtime | Node `^22.19.0 \|\| >=24.0.0` (matches DSH) |
|
|
73
|
+
| Plugin seam | `@deepseek-ai/cordis` (`name` / `apply` / `inject` entry) |
|
|
74
|
+
| Package manager | pnpm (DSH ecosystem standard) |
|
|
75
|
+
| Build | `tsc` → `lib/` (main `lib/index.js`, types `lib/index.d.ts`) |
|
|
76
|
+
| Tests | Vitest |
|
|
77
|
+
| Lint | oxlint (DSH official repo convention) |
|
|
78
|
+
| License | MIT |
|
|
79
|
+
|
|
80
|
+
## Project layout
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
dsh-continual-evolve/
|
|
84
|
+
├── package.json # exports / files / engines / scripts + dsh.bundle manifest
|
|
85
|
+
├── cordis.patch.yml # bundle patch (dsh plugin add activates on install)
|
|
86
|
+
├── tsconfig.json / .oxlintrc.json / .editorconfig / .gitignore
|
|
87
|
+
├── LICENSE / README.md / README.zh.md
|
|
88
|
+
├── docs/
|
|
89
|
+
│ ├── design.md # full design doc (incl. hardening matrix)
|
|
90
|
+
│ └── research/ # penguin-harness report + prime-agent reference source
|
|
91
|
+
├── src/
|
|
92
|
+
│ ├── index.ts # cordis plugin entry (service mount + wiring)
|
|
93
|
+
│ ├── types.ts # HarnessState / entry / edit / result types
|
|
94
|
+
│ ├── state.ts # atomic persistence, corrupt degrade, merge, concurrency
|
|
95
|
+
│ ├── validate.ts # code-enforced edit validation
|
|
96
|
+
│ ├── apply.ts # per-edit apply pass with optimistic locking
|
|
97
|
+
│ ├── rollback.ts # deterministic inverse-op rollback
|
|
98
|
+
│ ├── plan.ts # proposal JSON parsing (truncation-aware)
|
|
99
|
+
│ ├── tool.ts # evolve_* model-facing tools (5)
|
|
100
|
+
│ ├── command.ts # /evolve command (incl. benchmark subcommands)
|
|
101
|
+
│ ├── planner.ts # ctx.llm planner
|
|
102
|
+
│ ├── render.ts # bounded prompt rendering
|
|
103
|
+
│ ├── inject.ts # dynamic system-prompt section (prompt notes + delegation specs, ranked injection)
|
|
104
|
+
│ ├── source.ts # trajectory citations (sessionId + event seqs of distilled entries)
|
|
105
|
+
│ ├── auto.ts # auto-review gate (turn/compaction triggers + audit, global-aware view)
|
|
106
|
+
│ ├── notify.ts # gate visibility — follow-up notice after an approved auto-refine
|
|
107
|
+
│ ├── goal.ts # goal-driven evolution rounds (/evolve goal)
|
|
108
|
+
│ ├── review.ts # gate LLM judgment (declines local duplicates of globally covered topics)
|
|
109
|
+
│ ├── approval.ts # human approval for global edits
|
|
110
|
+
│ ├── skill.ts # skill materialization ($DSH_HOME/skills/)
|
|
111
|
+
│ ├── mount.ts # hot-mounted skill plugins (loader.create + boot restore)
|
|
112
|
+
│ ├── benchmark.ts # benchmark store
|
|
113
|
+
│ ├── rubric.ts # rubric ACL (AES-256-GCM envelopes, auto-generated local key)
|
|
114
|
+
│ ├── logfile.ts # plugin-owned file logging (JSONL exporter + rotation)
|
|
115
|
+
│ ├── score.ts # code-owned aggregation + acceptance rule
|
|
116
|
+
│ ├── evaluate.ts # evaluation matrix runner (structured-output subagents)
|
|
117
|
+
│ ├── pool.ts # bounded-concurrency worker pool for evaluation runs
|
|
118
|
+
│ ├── store.ts # store layout + snapshots + result history
|
|
119
|
+
│ └── service.ts # evolution engine (onApplied hook)
|
|
120
|
+
└── test/ # 20 files, 184 tests
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## In-session usage (after restart)
|
|
124
|
+
|
|
125
|
+
```
|
|
126
|
+
/evolve help + current local store
|
|
127
|
+
/evolve list [global] list entries
|
|
128
|
+
/evolve history applied refinements (ids for rollback)
|
|
129
|
+
/evolve rollback <id> deterministically revert a refinement
|
|
130
|
+
/evolve plan [msg] LLM planner against the current store
|
|
131
|
+
/evolve archive <id> hide an entry from injection (data kept, restorable)
|
|
132
|
+
/evolve unarchive <id> restore an archived entry
|
|
133
|
+
/evolve log [tail N] [session <id>] show the recent plugin log (default 50 lines; optional per-session filter)
|
|
134
|
+
/evolve export <path> backup the local store to JSON
|
|
135
|
+
/evolve import <path> restore a store from an export file
|
|
136
|
+
/evolve mount <skillId> hot-mount a skill entry as a live cordis plugin (tool: skill_<name>)
|
|
137
|
+
/evolve mount list list hot-mounted plugins (restored on boot)
|
|
138
|
+
/evolve unmount <id> remove a hot-mounted plugin
|
|
139
|
+
/evolve goal show the evolution goal (round-driven auto-review)
|
|
140
|
+
/evolve goal <objective> create/update the evolution goal — while active, the review gate runs EVERY round
|
|
141
|
+
/evolve goal done complete the evolution goal
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Model-facing tools: `evolve_list`, `evolve_add`, `evolve_update`, `evolve_delete`, `evolve_rollback`.
|
|
145
|
+
|
|
146
|
+
## Memory layer
|
|
147
|
+
|
|
148
|
+
Beyond the persisted store itself, three features keep injected memory
|
|
149
|
+
"understanding you" as entries grow (gap analysis vs. Mem0 / Letta / Zep /
|
|
150
|
+
LangMem; no external services — everything is pure functions):
|
|
151
|
+
|
|
152
|
+
- **Ranked injection** — when a kind holds more than the 6-entry cap, the
|
|
153
|
+
injected block no longer shows the fixed first six: entries are scored by
|
|
154
|
+
relevance to the agent's most recent direct user messages (keyword/BM25
|
|
155
|
+
level: title hits weigh 2×) and then by recency (`updated_at`, 30-day
|
|
156
|
+
half-life), so the freshest *and most relevant* entries fill the cap. The
|
|
157
|
+
empty-store zero-token behavior is unchanged.
|
|
158
|
+
- **Trajectory citations** — every newly created entry records
|
|
159
|
+
`metadata.sourceSession` + `metadata.sourceSeqs` pointing at the direct
|
|
160
|
+
user messages it was distilled from (DSH sessions are event-sourced with
|
|
161
|
+
contiguous seqs, so the citation expands back into the durable session
|
|
162
|
+
log). Listings show `src=<sessionId>:<seqs>`; old entries are not migrated
|
|
163
|
+
and never error.
|
|
164
|
+
- **Archive** — `/evolve archive <id>` hides an entry from injection
|
|
165
|
+
(`metadata.archivedAt`, data kept, rollback-compatible) and
|
|
166
|
+
`/evolve unarchive <id>` restores it. Archived entries are marked
|
|
167
|
+
`[archived]` in `evolve_list` and skipped by injection; the overflow count
|
|
168
|
+
excludes them.
|
|
169
|
+
- **Global-aware gate** — the auto-review gate and planner judge the merged
|
|
170
|
+
global + local state with every entry's real scope labeled, so a topic
|
|
171
|
+
already covered by a global entry is declined instead of being re-sedimented
|
|
172
|
+
as a local duplicate.
|
|
173
|
+
|
|
174
|
+
## Logging
|
|
175
|
+
|
|
176
|
+
Plugin-owned file logging: every cordis log message (from this plugin or any
|
|
177
|
+
other) is appended to `<dshHome>/evolve/plugin.log` as JSONL (0600, rotated to
|
|
178
|
+
`plugin.log.1` past `logMaxBytes`). It works no matter how `dsh web` is
|
|
179
|
+
launched — no extra component to install, no startup-script dependency.
|
|
180
|
+
View the tail with `/evolve log [tail N]`, or read the file directly:
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
tail -f ~/.dsh/evolve/plugin.log # live
|
|
184
|
+
/evolve log 100 # last 100 lines in the chat
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
For live output in a foreground terminal, the official
|
|
188
|
+
`@deepseek-ai/cordis-plugin-logger-console` plugin can be added to the
|
|
189
|
+
profile (optional; the file log remains the baseline that always exists).
|
|
190
|
+
|
|
191
|
+
## Benchmark-driven validation (Phase 3)
|
|
192
|
+
|
|
193
|
+
```
|
|
194
|
+
/evolve benchmark new <title> [runs] create a benchmark (runs = repeats per case, default 1)
|
|
195
|
+
/evolve benchmark add-case <bid> <title> <statement> <rubric>
|
|
196
|
+
/evolve benchmark list list benchmarks
|
|
197
|
+
/evolve benchmark reset <bid> clear the scoreboard (re-run reference)
|
|
198
|
+
/evolve benchmark status <bid> scoreboard + decisions
|
|
199
|
+
/evolve benchmark run <bid> evaluate current state → reference
|
|
200
|
+
/evolve benchmark run <bid> candidate <refinementId> evaluate post-refinement state → decide
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
The loop: freeze a reference score → evolve a candidate (`/evolve plan`) →
|
|
204
|
+
run the same case × run matrix against the post-refinement state → the
|
|
205
|
+
**code-owned** acceptance rule keeps the candidate only if the overall mean
|
|
206
|
+
strictly improves with no case regressing (Self-Harness style). The model
|
|
207
|
+
produces raw per-cell scores only; aggregation and decisions live in
|
|
208
|
+
`src/score.ts`. Rubric isolation is by construction (the planner never sees
|
|
209
|
+
rubric files); a rejection is recorded in the scoreboard and the refinement
|
|
210
|
+
is rolled back automatically (`autoRollbackOnReject`, on by default).
|
|
211
|
+
|
|
212
|
+
### Real recorded run (ACCEPT)
|
|
213
|
+
|
|
214
|
+
A live `dsh web` session, one case, one candidate — the first genuine
|
|
215
|
+
acceptance:
|
|
216
|
+
|
|
217
|
+
| Step | Command | Outcome |
|
|
218
|
+
|---|---|---|
|
|
219
|
+
| reference | `/evolve benchmark run lint_convention` | **90** — the evaluator agent actually grepped the harness store and reported *"lint/ruff/eslint/mypy appear in zero entries"* |
|
|
220
|
+
| candidate | `/evolve plan 记住:写代码前必须先运行适用的 lint 检查` | creates `memory:convention_lint_before_code` |
|
|
221
|
+
| re-evaluate | `/evolve benchmark run lint_convention candidate <id>` | **100** — evaluator ran `evolve_list`, hit the memory, quoted it verbatim |
|
|
222
|
+
| decision | — | `overall: 90 → 100` · `lint_knowledge: 90 → 100` · **DECISION: ACCEPTED** |
|
|
223
|
+
|
|
224
|
+
The evaluator does not grade model common sense — it inspects the actual
|
|
225
|
+
harness state under test (grep, `evolve_list`) and scores against it, so a
|
|
226
|
+
harness change measurably moves the score. Earlier runs in the same session
|
|
227
|
+
produced honest `REJECTED` decisions (0 → 0 placeholder cases, and 100 → 100
|
|
228
|
+
where the baseline was already perfect).
|
|
229
|
+
|
|
230
|
+
## Configuration
|
|
231
|
+
|
|
232
|
+
| Key | Default | Meaning |
|
|
233
|
+
|---|---|---|
|
|
234
|
+
| `baseDir` | resolved DSH home | root for the `evolve/` stores |
|
|
235
|
+
| `sectionOrder` | 118 | system-prompt section order |
|
|
236
|
+
| `autoReview` | `false` | enable the automatic review gate (costs a cheap model call per interval) |
|
|
237
|
+
| `reviewIntervalTurns` | 6 | gate runs when this many turns passed since the last review |
|
|
238
|
+
| `maxReviewInputChars` | 40000 | trajectory slice handed to the gate |
|
|
239
|
+
| `reviewBudgetTokens` | 4096 | output budget for the gate call |
|
|
240
|
+
| `notifyOnAutoReview` | `true` | after an approved gate run that applied edits, queue a visible follow-up notice in the session (persisted entries + rollback command) |
|
|
241
|
+
| `requireGlobalApproval` | `true` | cross-session (global) edits ask the user for "批准" before applying |
|
|
242
|
+
| `skillsDir` | `<dshHome>/skills` | root where skill entries materialize as SKILL.md bundles |
|
|
243
|
+
| `rubricKey` | auto-generated local key file (`<dshHome>/evolve/rubric.key`, 0600) → dev fallback | passphrase for AES-256-GCM rubric encryption (benchmark rubrics never touch the disk in plaintext). When unset, the plugin generates a random per-installation key file on first use — every install gets its own key, no setup needed; `DSH_EVOLVE_RUBRIC_KEY` is the environment-variable override |
|
|
244
|
+
| `logToFile` | `true` | write all cordis log messages to `<dshHome>/evolve/plugin.log` (JSONL, 0600) — plugin-owned logging works with any launch method, no extra component to install |
|
|
245
|
+
| `logLevel` | `1` | file log level: 0=error, 1=info, 2=warn, 3=debug |
|
|
246
|
+
| `logMaxBytes` | 5 MiB | rotate the log to `plugin.log.1` when it exceeds this size |
|
|
247
|
+
| `autoRollbackOnReject` | `true` | after a benchmark decision rejects a candidate, roll the refinement back automatically (same engine path as `/evolve rollback` — deterministic, snapshotted, audited) |
|
|
248
|
+
|
|
249
|
+
Example (profile `cordis.patch.yml`):
|
|
250
|
+
|
|
251
|
+
```yaml
|
|
252
|
+
- insert:
|
|
253
|
+
- id: continual-evolve
|
|
254
|
+
name: 'dsh-continual-evolve'
|
|
255
|
+
config:
|
|
256
|
+
autoReview: true
|
|
257
|
+
reviewIntervalTurns: 6
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
## Development
|
|
261
|
+
|
|
262
|
+
```bash
|
|
263
|
+
pnpm install # install dev deps
|
|
264
|
+
pnpm build # tsc -> lib/
|
|
265
|
+
pnpm test # vitest run
|
|
266
|
+
pnpm lint # oxlint src test
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
Hit a wall? See [`docs/FAQ.md`](docs/FAQ.md) — real failure/fix records (service planes, schema DSL, structured output, gate counting, verifying prompt injection).
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
## Roadmap
|
|
273
|
+
|
|
274
|
+
**Shipped**
|
|
275
|
+
|
|
276
|
+
- **Phases 1–3 (done)**: pure-core engine (state model, validation, apply, rollback, proposal parsing) → `evolve_*` tools + `/evolve` command + `ctx.llm` planner → auto-refine review gate (turn-interval + compaction checkpoints, visible follow-up notices), global-scope human approval, executable skills, real system-prompt injection (prompt notes + delegation specs, inherited by subagents), benchmark-driven validation loop (code-owned scoreboard, non-regressive acceptance, rubric isolation by construction), hot-mounted skill plugins, goal-driven evolution rounds.
|
|
277
|
+
- **2026-08 maintenance wave (done)**:
|
|
278
|
+
- **memory layer** — ranked injection (relevance + recency scoring fills the per-kind cap), trajectory citations (`metadata.sourceSession` + `sourceSeqs`, shown as `src=session:seqs`), archive/unarchive (`/evolve archive <id>`, injection skips archived entries), global-aware gate (declines local duplicates of globally covered topics)
|
|
279
|
+
- **per-installation rubric key** — auto-generated local key file (`<dshHome>/evolve/rubric.key`, 0600); no more publicly known dev key
|
|
280
|
+
- **plugin-owned file logging** — every cordis log message lands in `<dshHome>/evolve/plugin.log` (JSONL, 0600, rotated), viewable via `/evolve log`; works with any launch method, no extra component to install
|
|
281
|
+
- **trajectory-grounded planning** — `/evolve plan` (and every planner call, including the gate's refine step) now reads the session trajectory: the caller's recent direct user messages are extracted from the session log and fed to the planner as a `<session_trajectory>` block, so proposals are grounded in what the user actually said (explicit `trajectory` overrides; empty trajectory is omitted at zero cost)
|
|
282
|
+
- **gate-proposed archiving** — stale entries are a first-class refine target: the planner can emit `action: "archive"` (kind + id only), which stamps `metadata.archivedAt` through the normal apply path — snapshot, version bump, audit event, and a deterministic rollback inverse that restores the pre-archive state. Archive hides from injection but never deletes; re-archiving an archived entry is rejected, and the base system prompt stays immutable
|
|
283
|
+
- **automatic rollback on benchmark rejection** — the acceptance loop is closed: when the code-owned decision rejects a candidate, the refinement is reverted automatically through the same engine path as `/evolve rollback` (deterministic inverse edits, snapshotted and audited; configurable via `autoRollbackOnReject`, on by default). Failures report the manual fallback instead of throwing
|
|
284
|
+
- **per-session log filtering** — `/evolve log [tail N] [session <id>]` keeps only the lines mentioning a given session id (exact token match, drawn from the rendered message and raw args); gate records now carry the session id in their log line
|
|
285
|
+
|
|
286
|
+
The planned/candidates list is empty for now — future work is driven by real usage.
|
|
287
|
+
|
|
288
|
+
## License
|
|
289
|
+
|
|
290
|
+
MIT. Independent project — not affiliated with DeepSeek.
|
package/README.zh.md
ADDED
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
# dsh-continual-evolve
|
|
2
|
+
|
|
3
|
+
[English](README.md) | 中文
|
|
4
|
+
|
|
5
|
+
[](https://awesome-dsh-plugin.com)
|
|
6
|
+
[](https://github.com/ZK-Andy/dsh-continual-evolve/actions/workflows/ci.yml)
|
|
7
|
+
[](LICENSE)
|
|
8
|
+
[](package.json)
|
|
9
|
+
[]()
|
|
10
|
+
[]()
|
|
11
|
+
|
|
12
|
+
[DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness)(`dsh`)的持续自进化插件:一套**版本化、可审计、可回滚**的 harness 状态层——提示词补充、记忆、技能、子代理规格——从会话轨迹中沉淀而来。
|
|
13
|
+
|
|
14
|
+
> **状态:全部阶段完成,进入长期维护。** Phase 1–3 交付了完整进化闭环:纯核心引擎、模型工具与 `/evolve` 命令、自动 review 门禁(回合间隔 + 压缩检查点、全局写入人工审批)、真实系统提示词注入(prompt 补充 + 委派规格,空 store 零 token 成本)、benchmark 驱动验证闭环(代码所有计分、非退化接受、rubric ACL)。此后插件随真实使用持续增强——记忆层(排序注入、轨迹引用、归档)、每安装实例独立的 rubric 密钥、插件自带文件日志。已交付与候选清单见"路线图"。
|
|
15
|
+
|
|
16
|
+
## 背景
|
|
17
|
+
|
|
18
|
+
这个项目始于一个研究问题:*harness 能自我改进吗?生产级版本长什么样?* 三条证据线塑造了答案:
|
|
19
|
+
|
|
20
|
+
- **penguin-harness** 证明了概念(benchmark → 评估 → 优化 → 接受/回滚),但**代码层零强制**——所有保证都是提示词契约。它的研究报告(`docs/research/`)成了本项目的硬化清单。
|
|
21
|
+
- **prime-agent `/refine`** 证明了工程形态:版本化 harness 条目、原子持久化、乐观并发、逆操作回滚。本包是在 DSH 插件表面上对该形态的原创实现。
|
|
22
|
+
- 学术工作(Self-Harness、AHE、HarnessOpt-Bench)提供了纪律:冻结评估运行时、代码所有聚合、非退化接受。
|
|
23
|
+
|
|
24
|
+
结果:**模型提议,代码保证。** 每一项机械化安全属性(schema 校验、快照、版本、审计、接受决策)都由代码强制——从不要求模型自觉守规矩。
|
|
25
|
+
|
|
26
|
+
## 为什么
|
|
27
|
+
|
|
28
|
+
Agent 在每个会话里积累可复用经验——重复失败、持久事实、可复用流程——然后在下个回合或下个会话忘掉。本插件把这些经验变成一等公民的持久状态:
|
|
29
|
+
|
|
30
|
+
- **版本化条目**:按 `prompt` / `memory` / `skill` / `subagent` 分键,每条带来源与版本
|
|
31
|
+
- **证据链**:每次进化追加一条携带 `trigger / changes / evidence / outcome` 的事件
|
|
32
|
+
- **确定性回滚**:逆操作由已应用的结果生成——不需要 LLM 再猜
|
|
33
|
+
- **代码强制安全**,而非提示词纪律:schema 校验、原子写、损坏降级、乐观并发、基础系统提示词不可变
|
|
34
|
+
- **局部(会话内)与全局(跨会话)双作用域**,带合并语义
|
|
35
|
+
|
|
36
|
+
## 设计来源
|
|
37
|
+
|
|
38
|
+
受三方面工作启发(见 [`docs/design.md`](docs/design.md)):
|
|
39
|
+
|
|
40
|
+
- **prime-agent `/refine`**(MIT):本包实现的状态模型、原子持久化、乐观并发、逐条校验与逆操作回滚——参考源码在 [`docs/research/prime-agent-refinement.ts`](docs/research/prime-agent-refinement.ts)。代码为原创实现,面向 DSH 插件表面编写。
|
|
41
|
+
- **penguin-harness**(Apache-2.0):benchmark 驱动的进化循环——研究报告在 [`docs/research/penguin-harness-self-evolution.md`](docs/research/penguin-harness-self-evolution.md);其"纯提示词契约"正是本包要硬化的反面教材。
|
|
42
|
+
- 学术:Self-Harness(arXiv 2606.09498)、AHE(arXiv 2604.25850)、HarnessOpt-Bench(arXiv 2608.06301)。
|
|
43
|
+
|
|
44
|
+
## 技术栈
|
|
45
|
+
|
|
46
|
+
| 层 | 选择 |
|
|
47
|
+
|---|---|
|
|
48
|
+
| 语言 | TypeScript(strict、ES2024、ESM) |
|
|
49
|
+
| 运行时 | Node `^22.19.0 \|\| >=24.0.0`(与 DSH 一致) |
|
|
50
|
+
| 插件接缝 | `@deepseek-ai/cordis`(`name` / `apply` / `inject` 入口) |
|
|
51
|
+
| 包管理 | pnpm(DSH 生态标准) |
|
|
52
|
+
| 构建 | `tsc` → `lib/`(main `lib/index.js`,types `lib/index.d.ts`) |
|
|
53
|
+
| 测试 | Vitest |
|
|
54
|
+
| Lint | oxlint(DSH 官方仓库惯例) |
|
|
55
|
+
| License | MIT |
|
|
56
|
+
|
|
57
|
+
## 项目结构
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
dsh-continual-evolve/
|
|
61
|
+
├── package.json # exports / files / engines / scripts + dsh.bundle manifest
|
|
62
|
+
├── cordis.patch.yml # bundle patch(dsh plugin add 安装即激活)
|
|
63
|
+
├── tsconfig.json / .oxlintrc.json / .editorconfig / .gitignore
|
|
64
|
+
├── LICENSE / README.md / README.zh.md
|
|
65
|
+
├── docs/
|
|
66
|
+
│ ├── design.md # 完整设计文档(含硬化对照表)
|
|
67
|
+
│ └── research/ # penguin 研究报告 + prime-agent 参考源码
|
|
68
|
+
├── src/
|
|
69
|
+
│ ├── index.ts # cordis 插件入口(服务挂载 + 接线)
|
|
70
|
+
│ ├── types.ts # HarnessState / 条目 / 编辑 / 结果类型
|
|
71
|
+
│ ├── state.ts # 原子持久化、损坏降级、合并、乐观并发
|
|
72
|
+
│ ├── validate.ts # 代码强制编辑校验(基础提示词不可改、skill 契约)
|
|
73
|
+
│ ├── apply.ts # 逐条应用 + 乐观锁
|
|
74
|
+
│ ├── rollback.ts # 确定性逆操作回滚
|
|
75
|
+
│ ├── plan.ts # 提案 JSON 解析(截断诊断)
|
|
76
|
+
│ ├── tool.ts # evolve_* 模型工具(5 个)
|
|
77
|
+
│ ├── command.ts # /evolve 命令(含 benchmark 子命令)
|
|
78
|
+
│ ├── planner.ts # ctx.llm 规划器
|
|
79
|
+
│ ├── render.ts # 有界提示词渲染
|
|
80
|
+
│ ├── inject.ts # 动态系统提示词段(prompt 补充 + 委派规格,打分排序注入)
|
|
81
|
+
│ ├── source.ts # 轨迹引用(沉淀条目的 sessionId + 事件 seq)
|
|
82
|
+
│ ├── auto.ts # 自动 review 门禁(回合/压缩触发 + 审计,global 感知视图)
|
|
83
|
+
│ ├── notify.ts # 门禁可见性——approved 自动沉淀后发送可见通知
|
|
84
|
+
│ ├── goal.ts # goal 驱动的进化轮次(/evolve goal)
|
|
85
|
+
│ ├── review.ts # 门禁 LLM 判断(拒绝 global 已覆盖主题的 local 重复沉淀)
|
|
86
|
+
│ ├── approval.ts # 全局写入人工审批
|
|
87
|
+
│ ├── skill.ts # 技能物化($DSH_HOME/skills/)
|
|
88
|
+
│ ├── mount.ts # 技能热挂载插件(loader.create + 启动恢复)
|
|
89
|
+
│ ├── benchmark.ts # benchmark 存储
|
|
90
|
+
│ ├── rubric.ts # rubric ACL(AES-256-GCM 密文信封,自动生成本地密钥)
|
|
91
|
+
│ ├── logfile.ts # 插件自带文件日志(JSONL exporter + 轮转)
|
|
92
|
+
│ ├── score.ts # 代码所有聚合 + 接受规则
|
|
93
|
+
│ ├── evaluate.ts # 评估矩阵执行器(结构化输出子代理)
|
|
94
|
+
│ ├── pool.ts # 评估运行的有界并发工作池
|
|
95
|
+
│ ├── store.ts # store 布局 + 快照 + 结果历史
|
|
96
|
+
│ └── service.ts # 进化引擎(onApplied 钩子)
|
|
97
|
+
└── test/ # 20 个文件,184 个测试
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## 会话内用法(安装后)
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
/evolve 帮助 + 当前局部 store
|
|
104
|
+
/evolve list [global] 列出条目
|
|
105
|
+
/evolve history 已应用的 refinement(回滚用 id)
|
|
106
|
+
/evolve rollback <id> 确定性回滚某个 refinement
|
|
107
|
+
/evolve plan [msg] LLM 规划器
|
|
108
|
+
/evolve archive <id> 归档条目——不再注入(数据保留,可恢复)
|
|
109
|
+
/evolve unarchive <id> 恢复已归档条目
|
|
110
|
+
/evolve log [tail N] [session <id>] 查看最近插件日志(默认 50 行;可加会话过滤)
|
|
111
|
+
/evolve export <path> 备份局部 store 为 JSON
|
|
112
|
+
/evolve import <path> 从导出文件恢复 store
|
|
113
|
+
/evolve mount <skillId> 热挂载 skill 条目为实时 cordis 插件(工具:skill_<name>)
|
|
114
|
+
/evolve mount list 列出热挂载插件(重启自动恢复)
|
|
115
|
+
/evolve unmount <id> 移除热挂载插件
|
|
116
|
+
/evolve goal 查看进化 goal(轮次驱动自动 review)
|
|
117
|
+
/evolve goal <objective> 创建/更新进化 goal——active 时 review 门禁每轮触发
|
|
118
|
+
/evolve goal done 完成进化 goal
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
模型工具:`evolve_list`、`evolve_add`、`evolve_update`、`evolve_delete`、`evolve_rollback`。
|
|
122
|
+
|
|
123
|
+
## 记忆层
|
|
124
|
+
|
|
125
|
+
在持久 store 之外,四项增强让注入的记忆在条目增多时依然"懂你"(对照 Mem0 / Letta / Zep / LangMem 的差距分析;不引入外部服务——全部是纯函数):
|
|
126
|
+
|
|
127
|
+
- **打分排序注入**——某类条目超过 6 条封顶时,注入块不再固定取前 6 条:先按与 agent 最近直接用户消息的相关度打分(关键词/BM25 级别,标题命中权重 2×),再按新鲜度排序(`updated_at`,30 天半衰期),让"最新 + 最相关"的条目填满封顶。空 store 零 token 行为不变。
|
|
128
|
+
- **轨迹引用**——每条新沉淀条目都会记录 `metadata.sourceSession` + `metadata.sourceSeqs`,指向它蒸馏自的直接用户消息(DSH 会话是事件溯源、seq 连续,引用可展开回持久会话日志)。列表显示 `src=<sessionId>:<seqs>`;旧条目不迁移也不报错。
|
|
129
|
+
- **归档**——`/evolve archive <id>` 让条目不再注入(`metadata.archivedAt`,数据保留、与快照/回滚兼容),`/evolve unarchive <id>` 恢复。归档条目在 `evolve_list` 中标记 `[archived]`,注入跳过,溢出计数不含它们。
|
|
130
|
+
- **global 感知门禁**——自动 review 门禁与规划器评审的是合并后的 global + local 状态,每条条目标注真实 scope;global 已覆盖的主题会被 declined,不再重复沉淀为 local 条目。
|
|
131
|
+
|
|
132
|
+
## 日志
|
|
133
|
+
|
|
134
|
+
插件自带文件日志:所有 cordis 日志消息(本插件或其他插件)追加写入 `<dshHome>/evolve/plugin.log`(JSONL、0600,超过 `logMaxBytes` 轮转到 `plugin.log.1`)。与 `dsh web` 的启动方式无关——无需安装额外组件、不依赖启动脚本。查看方式:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
tail -f ~/.dsh/evolve/plugin.log # 实时跟随
|
|
138
|
+
/evolve log 100 # 在对话里看最近 100 行
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
前台终端想要实时输出时,可(可选)在 profile 加官方 `@deepseek-ai/cordis-plugin-logger-console` 插件;文件日志始终是默认存在的基础。
|
|
142
|
+
|
|
143
|
+
## benchmark 驱动验证(Phase 3)
|
|
144
|
+
|
|
145
|
+
```
|
|
146
|
+
/evolve benchmark new <title> 创建 benchmark
|
|
147
|
+
/evolve benchmark add-case <bid> <title> <statement> <rubric>
|
|
148
|
+
/evolve benchmark list 列出 benchmark
|
|
149
|
+
/evolve benchmark status <bid> 查看计分板 + 决策
|
|
150
|
+
/evolve benchmark reset <bid> 清空计分板(重跑参考线)
|
|
151
|
+
/evolve benchmark run <bid> 评估当前状态 → 参考线
|
|
152
|
+
/evolve benchmark run <bid> candidate <refinementId> 评估进化后状态 → 决策
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
闭环:冻结参考分 → 进化候选(`/evolve plan`)→ 用同一 case × run 矩阵复测进化后状态 → **代码所有**的接受规则只在总体均值严格提高且无 case 退化时保留候选(Self-Harness 风格)。模型只产出原始细胞级分数;聚合与决策都在 `src/score.ts`。rubric 隔离靠构造(规划器的提示词永远不含 rubric 文件);拒绝会记录进 scoreboard 并自动回滚该 refinement(`autoRollbackOnReject`,默认开)。
|
|
156
|
+
|
|
157
|
+
### 真实运行记录(ACCEPT)
|
|
158
|
+
|
|
159
|
+
一次真实的 `dsh web` 会话,一个 case、一个候选——第一次真正的接受:
|
|
160
|
+
|
|
161
|
+
| 步骤 | 命令 | 结果 |
|
|
162
|
+
|---|---|---|
|
|
163
|
+
| 参考线 | `/evolve benchmark run lint_convention` | **90**——评估子代理真的 grep 了 harness store,报告"lint/ruff/eslint/mypy 在所有条目中零出现" |
|
|
164
|
+
| 进化候选 | `/evolve plan 记住:写代码前必须先运行适用的 lint 检查` | 创建 `memory:convention_lint_before_code` |
|
|
165
|
+
| 复测 | `/evolve benchmark run lint_convention candidate <id>` | **100**——评估器跑 `evolve_list` 命中记忆并逐字引用 |
|
|
166
|
+
| 决策 | — | `overall: 90 → 100` · `lint_knowledge: 90 → 100` · **DECISION: ACCEPTED** |
|
|
167
|
+
|
|
168
|
+
评估器评的不是模型常识,而是**被测 harness 状态本身**(grep、`evolve_list` 检查)——所以 harness 的改动会真实地反映在分数上。同一会话早些时候还产生过诚实的 `REJECTED` 决策(0→0 占位符 case、100→100 满分基线无法超越)。
|
|
169
|
+
|
|
170
|
+
## 配置
|
|
171
|
+
|
|
172
|
+
| 键 | 默认值 | 含义 |
|
|
173
|
+
|---|---|---|
|
|
174
|
+
| `baseDir` | 解析后的 DSH home | `evolve/` store 的根 |
|
|
175
|
+
| `sectionOrder` | 118 | 系统提示词段落顺序 |
|
|
176
|
+
| `autoReview` | `false` | 启用自动 review 门禁(每间隔一次廉价模型调用) |
|
|
177
|
+
| `reviewIntervalTurns` | 6 | 距上次 review 满这么多回合时触发门禁 |
|
|
178
|
+
| `maxReviewInputChars` | 40000 | 交给门禁的轨迹切片 |
|
|
179
|
+
| `reviewBudgetTokens` | 4096 | 门禁调用的输出预算 |
|
|
180
|
+
| `notifyOnAutoReview` | `true` | 门禁 approved 且实际应用了编辑后,在会话中排一条可见通知(沉淀条目 + 回滚命令) |
|
|
181
|
+
| `requireGlobalApproval` | `true` | 跨会话(全局)编辑需用户批准"批准"后才应用 |
|
|
182
|
+
| `skillsDir` | `<dshHome>/skills` | 技能条目物化为 SKILL.md 包的根目录 |
|
|
183
|
+
| `rubricKey` | 自动生成的本地密钥文件(`<dshHome>/evolve/rubric.key`,0600)→ dev 兜底 | rubric 加密(AES-256-GCM)口令:benchmark rubric 明文永不着盘。未配置时插件首次使用自动生成随机密钥文件——每台安装实例一把独立密钥,零配置;`DSH_EVOLVE_RUBRIC_KEY` 为环境变量覆盖项 |
|
|
184
|
+
| `logToFile` | `true` | 所有 cordis 日志消息写入 `<dshHome>/evolve/plugin.log`(JSONL、0600)——插件自带日志,与启动方式无关、无需安装额外组件 |
|
|
185
|
+
| `logLevel` | `1` | 文件日志级别:0=error、1=info、2=warn、3=debug |
|
|
186
|
+
| `logMaxBytes` | 5 MiB | 超过该大小轮转到 `plugin.log.1` |
|
|
187
|
+
| `autoRollbackOnReject` | `true` | benchmark 决策拒绝候选后自动回滚该 refinement(与 `/evolve rollback` 同一引擎路径——确定性、快照、审计) |
|
|
188
|
+
|
|
189
|
+
示例(profile `cordis.patch.yml`):
|
|
190
|
+
|
|
191
|
+
```yaml
|
|
192
|
+
- insert:
|
|
193
|
+
- id: continual-evolve
|
|
194
|
+
name: 'dsh-continual-evolve'
|
|
195
|
+
config:
|
|
196
|
+
autoReview: true
|
|
197
|
+
reviewIntervalTurns: 6
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
## 安装
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
# 从 npm 安装(安装即激活,自带 bundle patch)
|
|
204
|
+
dsh plugin --profile web add dsh-continual-evolve
|
|
205
|
+
|
|
206
|
+
# 或从源码安装
|
|
207
|
+
dsh plugin --profile web add /path/to/dsh-continual-evolve
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
## 开发
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
pnpm install # 安装开发依赖
|
|
214
|
+
pnpm dev # tsc --watch
|
|
215
|
+
pnpm build # tsc -> lib/
|
|
216
|
+
pnpm test # vitest run
|
|
217
|
+
pnpm lint # oxlint src test
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
遇到问题先看 [`docs/FAQ.md`](docs/FAQ.md)(真实踩坑记录:服务平面、schema DSL、结构化输出、门禁计数、注入验证等)。
|
|
221
|
+
|
|
222
|
+
## 路线图
|
|
223
|
+
|
|
224
|
+
**已交付**
|
|
225
|
+
|
|
226
|
+
- **Phase 1–3(完成)**:纯核心引擎(状态模型、校验、应用、回滚、提案解析)→ `evolve_*` 工具 + `/evolve` 命令 + `ctx.llm` 规划器 → 自动 review 门禁(回合间隔 + 压缩检查点、approved 后可见通知)、全局人工审批、可执行技能、真实系统提示词注入(prompt 补充 + 委派规格,子代理沿父链继承)、benchmark 驱动验证闭环(代码所有计分板、非退化接受、rubric 构造性隔离)、技能热挂载插件、goal 驱动的进化轮次。
|
|
227
|
+
- **2026-08 维护期增强(完成)**:
|
|
228
|
+
- **记忆层**——排序注入(相关度 + 新鲜度打分填满每类封顶)、轨迹引用(`metadata.sourceSession` + `sourceSeqs`,显示为 `src=session:seqs`)、归档/恢复(`/evolve archive <id>`,注入跳过归档条目)、global 感知门禁(拒绝 global 已覆盖主题的 local 重复沉淀)
|
|
229
|
+
- **每安装独立 rubric 密钥**——自动生成本地密钥文件(`<dshHome>/evolve/rubric.key`,0600);不再有全世界公开的 dev 键
|
|
230
|
+
- **插件自带文件日志**——所有 cordis 日志消息写入 `<dshHome>/evolve/plugin.log`(JSONL、0600、自动轮转),`/evolve log` 查看;与启动方式无关、无需安装额外组件
|
|
231
|
+
- **轨迹接地规划**——`/evolve plan`(及所有规划调用,含门禁 refine 步骤)现在读取会话轨迹:从调用方会话日志提取最近直接用户消息,作为 `<session_trajectory>` 块喂给规划器,提案以用户真实说过的话为依据(显式 `trajectory` 覆盖;空轨迹省略、零成本)
|
|
232
|
+
- **门禁提议归档**——过时条目是一等 refine 目标:规划器可输出 `action: "archive"`(仅需 kind + id),代码经正常 apply 通道盖 `metadata.archivedAt` 戳——快照、版本 +1、审计事件、以及恢复归档前状态的确定性回滚逆编辑。归档隐藏于注入但绝不删除;重复归档被拒绝;基础系统提示词保持不可变
|
|
233
|
+
- **benchmark 拒绝自动回滚**——接受闭环已闭合:代码所有决策拒绝候选时,refinement 经与 `/evolve rollback` 相同的引擎路径自动撤销(确定性逆编辑、快照 + 审计;`autoRollbackOnReject` 配置,默认开)。失败时给出手动回滚提示而不是抛错
|
|
234
|
+
- **日志按会话过滤**——`/evolve log [tail N] [session <id>]` 只保留提及指定会话 id 的行(精确 token 匹配,取自渲染消息与原始 args);门禁记录的行现在携带会话 id
|
|
235
|
+
|
|
236
|
+
规划中/候选清单暂时为空——后续工作随真实使用驱动。
|
|
237
|
+
|
|
238
|
+
## License
|
|
239
|
+
|
|
240
|
+
MIT。独立项目——与 DeepSeek 无关联。
|
package/cordis.patch.yml
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# dsh-continual-evolve bundle layer.
|
|
2
|
+
#
|
|
3
|
+
# Installed via `dsh plugin --profile <name> add dsh-continual-evolve`, this
|
|
4
|
+
# patch inserts the plugin row so it activates without manual profile editing.
|
|
5
|
+
# Conservative defaults: the auto-review gate is OFF (opt in via your profile
|
|
6
|
+
# cordis.patch.yml config) and cross-session edits require human approval.
|
|
7
|
+
- insert:
|
|
8
|
+
- id: continual-evolve
|
|
9
|
+
name: 'dsh-continual-evolve'
|
package/lib/apply.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The apply pass: turn a validated proposal into state changes with full
|
|
3
|
+
* per-edit accounting. Every failure is recorded per edit — a bad edit never
|
|
4
|
+
* invalidates the whole proposal — and optimistic-concurrency checks reject
|
|
5
|
+
* edits whose target entry changed while planning was in flight.
|
|
6
|
+
*/
|
|
7
|
+
import type { EntrySource, HarnessScope, HarnessState, RefinementProposal, RefinementResult } from "./types.js";
|
|
8
|
+
import { entryChangedSince } from "./state.js";
|
|
9
|
+
export interface ApplyOptions {
|
|
10
|
+
id: string;
|
|
11
|
+
scope?: HarnessScope;
|
|
12
|
+
rollbackOf?: string;
|
|
13
|
+
/** State captured before planning; used to reject conflicting edits. */
|
|
14
|
+
baselineState?: HarnessState;
|
|
15
|
+
/**
|
|
16
|
+
* Trajectory citation stamped into newly created entries' metadata
|
|
17
|
+
* (sourceSession + sourceSeqs); updates keep whatever the entry already
|
|
18
|
+
* carries. Omitted entirely when the caller cannot determine it.
|
|
19
|
+
*/
|
|
20
|
+
source?: EntrySource;
|
|
21
|
+
}
|
|
22
|
+
export declare function applyRefinementProposal(state: HarnessState, proposal: RefinementProposal, options: ApplyOptions): RefinementResult;
|
|
23
|
+
export { entryChangedSince };
|
|
24
|
+
//# sourceMappingURL=apply.d.ts.map
|