skill-evolution 0.0.0-stage → 0.3.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/CHANGELOG.md +52 -0
- package/LICENSE +21 -0
- package/README.en.md +208 -0
- package/README.md +207 -2
- package/assets/icon-180.png +0 -0
- package/assets/screenshots/workbench.png +0 -0
- package/client.js +2135 -0
- package/cordis.patch.yml +41 -0
- package/icon.svg +6 -0
- package/index.js +884 -0
- package/lib/applier.js +221 -0
- package/lib/collector.js +356 -0
- package/lib/consolidation.js +344 -0
- package/lib/gatekeeper.js +293 -0
- package/lib/http-api.js +919 -0
- package/lib/ledger.js +316 -0
- package/lib/prompts.js +514 -0
- package/lib/provenance.js +103 -0
- package/lib/reflector.js +226 -0
- package/lib/synthesizer.js +295 -0
- package/lib/tidy.js +263 -0
- package/lib/usage.js +223 -0
- package/locale/en.json +8 -0
- package/locale/zh.json +8 -0
- package/package.json +87 -4
- package/screenshots.json +3 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `skill-evolution` will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [0.3.1] - 2026-11-10
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- **Native Web UI (`client.js` rewrite)**: the workbench now follows the host settings page design language instead of a self-made layout — 720px container, 20/14/12 type scale, `.5px` row separators, and colors taken only from host `--dsw-alias-*` tokens so light and dark themes are followed automatically.
|
|
14
|
+
- **Native switch control**: `NativeSwitch` renders a 36×20 button with `role="switch"` and `aria-checked`, replacing the previous custom toggle.
|
|
15
|
+
- **Split renderers**: `settings.section` now renders engine parameters and status only, while the full five-view workbench (overview / drafts / skills / ledger / settings) mounts in `main` and `sidebar.panellist`.
|
|
16
|
+
- **`settings.section.icon` registration**: the settings section now has its own icon entry.
|
|
17
|
+
- **`client.inject` expands to six UI packages**: `@deepseek-ai/dsh-client-ui-sidebar` and `@deepseek-ai/dsh-client-ui-layout` are now injected so `sidebar.panellist` and `main` resolve.
|
|
18
|
+
- **Auxiliary LLM review channel**: `runAuxiliaryReview` calls an OpenAI-compatible endpoint directly (`DSH_EVOLUTION_BASE_URL` / `DSH_EVOLUTION_API_KEY` / `DSH_EVOLUTION_MODEL`), so a review can run outside the session lock during short-lived or headless exits.
|
|
19
|
+
- **`scripts/sanitize-check.mjs`**: sanitization gate with 11 needles (home paths, private package scope, loopback address and hostname, private key marker, internal IP segment, internal gateway and cloud vendor names, API key and GitHub token prefixes) plus checks for `.bak-*` files and `node_modules/`. Vendored Hermes sources are excluded from content scanning and the skip count is printed.
|
|
20
|
+
- **CI sanitization step**, and `npm run sanitize` for local use.
|
|
21
|
+
|
|
22
|
+
### Changed
|
|
23
|
+
- **`reviewModel` now inherits by default**: `provider` and `model` default to empty strings, meaning the review uses the current session model; set them (or the env vars) to use a cheaper auxiliary model.
|
|
24
|
+
- **Review channel selection**: when no auxiliary endpoint is configured, reviews go through the host subagent fork instead of assuming a local endpoint exists.
|
|
25
|
+
- **Throttle defaults**: `minTurnsBetween` 3 → 1, `minMinutesBetween` 5 → 2 (both in `index.js` and `cordis.patch.yml`).
|
|
26
|
+
- **`consolidate` / `consolidateDryRun` documented in the bundle patch**: umbrella consolidation stays off by default and previews only.
|
|
27
|
+
- **`package.json`**: version 0.3.1, `private` removed, `publishConfig` (`access: public`, `provenance: true`), `@deepseek-ai/schemastery` declared as a peer dependency (`>=3.0.0-0`), `engines` set to Node `>=20.11`, and `assets/icon-180.png` / `README.en.md` / `CHANGELOG.md` added to `files`.
|
|
28
|
+
- **README.md / README.en.md restructured to one shared outline** (what it does / how it works / install / config / limitations / development / license) and all numbers checked against the code and test output: 70 tests, 41/41 capability audit, 2 prompt blocks byte-identical.
|
|
29
|
+
|
|
30
|
+
### Fixed
|
|
31
|
+
- The HTTP request parser no longer embeds a loopback literal: relative URLs are parsed against a reserved placeholder origin. `pathname` and `searchParams` behavior is unchanged.
|
|
32
|
+
- Removed the private package scope from the client module id, test header and bundles patch, so the published package carries no private scope.
|
|
33
|
+
|
|
34
|
+
## [0.3.0] - 2026-11-08
|
|
35
|
+
|
|
36
|
+
### Added
|
|
37
|
+
- **Chinese Briefing & Mandatory User Directive Fusion**:
|
|
38
|
+
- Added `.briefing.json` generation and `ReviewBrief` UI card displaying plain-language summaries (`whatItIs`, `keyRules`, `ifApprove`, `ifReject`).
|
|
39
|
+
- Added mandatory user directive (`comment`) input with quick-directive chips and AI-powered draft refinement (`POST /dsh-evolution/api/refine-draft` and `evolveWithComment` in `POST /dsh-evolution/api/promote`).
|
|
40
|
+
- **Full Desktop, Mobile PWA & Remote App Support**:
|
|
41
|
+
- Mounted the workbench into `main`, `sidebar.panellist` (order 15) and `settings.section` (order 30).
|
|
42
|
+
- Added standalone Mobile PWA workbench (`GET /dsh-evolution/mobile` and fixed port `18890`) with bottom tab bar and iOS `16px` zoom prevention.
|
|
43
|
+
- Added `evolution_review_center` tool (with native `ask_user_question` interactive cards for Remote/Mobile apps) and `/evolution brief|refine|approve|reject` slash commands.
|
|
44
|
+
- **LLM Umbrella Consolidation Workbench**:
|
|
45
|
+
- Ported `CURATOR_REVIEW_PROMPT` and implemented `lib/consolidation.js` for prefix-cluster umbrella merging (`create`, `patch`, `write_file`, `archive` with mandatory `absorbedInto`).
|
|
46
|
+
- **Short-Lived Process Flush Barrier**:
|
|
47
|
+
- Subscribed to `session/flush` with `inflightPromises` barrier so one-shot/headless runs never truncate in-flight reviews before exit.
|
|
48
|
+
|
|
49
|
+
### Fixed
|
|
50
|
+
- Fixed DSH `session/event` nested `ev.data` envelope parsing and filtered system-injected `<system-reminder>` / runtime-context blocks.
|
|
51
|
+
- Fixed `SettingsPanel` child component focus loss by hoisting field components to module scope.
|
|
52
|
+
- Refined `NEGATIVE_CLAIM_PATTERNS` in `lib/gatekeeper.js` to avoid false positives on cautionary prose.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 veritaswiki
|
|
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.en.md
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
# 🧬 Skill Evolution (`skill-evolution`)
|
|
2
|
+
|
|
3
|
+
[](https://github.com/veritaswiki/skill-evolution/actions/workflows/ci.yml)
|
|
4
|
+
[](./LICENSE)
|
|
5
|
+
[](#development)
|
|
6
|
+
[](#development)
|
|
7
|
+
[](#capability-parity-and-audits)
|
|
8
|
+
|
|
9
|
+
> In DSH the `skill` tool can load skills but cannot write them back. This plugin adds that write-back path: after a turn ends it reviews the session, distills the lesson into a skill draft, runs four code-level gates, and waits for your directive — with a ledger and single-entry rollback.
|
|
10
|
+
|
|
11
|
+
[中文文档 (README.md)](./README.md) · [Changelog (CHANGELOG.md)](./CHANGELOG.md)
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Screenshots
|
|
16
|
+
|
|
17
|
+

|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## What it does
|
|
22
|
+
|
|
23
|
+
1. **Post-turn review** — listens on `turn/end` and `session/flush`, detects `user-correction`, `new-technique` and `skill-was-wrong` signals, throttles by `minTurnsBetween` turns / `minMinutesBetween` minutes (`.throttle.json`, cross-process), and bounds the snapshot by `maxMessages` and `maxChars`.
|
|
24
|
+
2. **The review is read-only** — it runs either in a host subagent fork (`subagents.startActivation`, tool allowlist `skill` / `glob` / `grep` / `read`) or against an OpenAI-compatible auxiliary endpoint. Neither path writes files: writes happen in the plugin, after the gates. A newer turn aborts the previous review, and every run has a timeout.
|
|
25
|
+
3. **Drafts by default** — with `mode: draft` output goes to `<skillsRoot>/.staging/` and the real skill library stays untouched. Promotion moves the draft into the skills directory, where DSH's skill filesystem hot-reloads it.
|
|
26
|
+
4. **Four code-level gates plus provenance protection** — see the gate table below. Only skills with `metadata.createdBy: agent` are ever auto-modified; user-authored skills are left alone.
|
|
27
|
+
5. **Ledger and single-entry rollback** — every create / patch / directive refinement / promotion / consolidation / archive appends to `.evolution_ledger.jsonl`, and file contents are stored deduplicated by SHA-256 under `.evolution_backups/blobs/`. Rollback takes a safety snapshot first and refuses (fail-closed) when that snapshot fails.
|
|
28
|
+
6. **Lifecycle and umbrella consolidation** — sidecar `.usage.json` telemetry drives `active → stale(14d) → archived(30d)` (zero-use immunity, `pinned` exemption, protected built-ins, archive never deletes). An LLM umbrella pass can merge narrow skills into class-level ones; it previews by default and does not touch disk.
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## How it works
|
|
33
|
+
|
|
34
|
+
### Pipeline modules
|
|
35
|
+
|
|
36
|
+
| Stage | File | What it does |
|
|
37
|
+
|---|---|---|
|
|
38
|
+
| Collect | `lib/collector.js` | Strips system-injected blocks, detects review signals, throttles, digests older turns, trims to `maxChars` |
|
|
39
|
+
| Review | `lib/reflector.js` + `lib/prompts.js` | Read-only fork or auxiliary endpoint; prompts are verbatim from Hermes (see `vendor/hermes/`) |
|
|
40
|
+
| Synthesize | `lib/synthesizer.js` | Structured JSON → `SKILL.md` content (pure functions) |
|
|
41
|
+
| Gate | `lib/gatekeeper.js` | Four static checks, see the table below |
|
|
42
|
+
| Apply | `lib/applier.js` | draft/apply destination, provenance protection, draft promotion |
|
|
43
|
+
| Record | `lib/ledger.js` | JSONL ledger, SHA-256 blobs, single-entry rollback, rotation and blob GC |
|
|
44
|
+
| Lifecycle | `lib/usage.js` | `.usage.json` telemetry, three states, pinned/protected skills, adopt/disown |
|
|
45
|
+
| Consolidate | `lib/consolidation.js` | Prefix clustering plus LLM plan validation (atomic: one non-compliant entry rejects the batch) |
|
|
46
|
+
| Surface | `client.js` + `lib/http-api.js` | Web workbench and `/dsh-evolution/api/*` |
|
|
47
|
+
|
|
48
|
+
### The four gates (`lib/gatekeeper.js`)
|
|
49
|
+
|
|
50
|
+
| # | Check | Rejects |
|
|
51
|
+
|---|---|---|
|
|
52
|
+
| 1 | Name | Non-kebab-case, over 64 chars, session artifacts such as `fix-X` / `debug-Y` / PR numbers / dates, bare library names |
|
|
53
|
+
| 2 | Frontmatter | Missing `description`; `description` over 80 chars; `frontmatter.name` not matching the target |
|
|
54
|
+
| 3 | Forbidden content | Negative tool claims (`X tool does not work`), environment failures (`command not found`), one-off narratives |
|
|
55
|
+
| 4 | Size and paths | Body over 24000 chars; `add_reference` paths that are not `references/<topic>.md` or that carry date stamps |
|
|
56
|
+
|
|
57
|
+
### Client mount points (`client.js`)
|
|
58
|
+
|
|
59
|
+
| Slot | order | Content |
|
|
60
|
+
|---|---|---|
|
|
61
|
+
| `main` | — | Full workbench: overview / drafts / skills / ledger / settings views |
|
|
62
|
+
| `sidebar.panellist` | 15 | Sidebar entry |
|
|
63
|
+
| `settings.section` | 30 | Engine settings and status only, not the review workbench |
|
|
64
|
+
| `settings.section.icon` | — | Settings section icon |
|
|
65
|
+
|
|
66
|
+
Styling uses only host `--dsw-alias-*` tokens so it follows light and dark themes (720px container, 20/14/12 type scale, `.5px` row separators, 36×20 native switch).
|
|
67
|
+
|
|
68
|
+
### HTTP API (`lib/http-api.js`)
|
|
69
|
+
|
|
70
|
+
Prefix `/dsh-evolution`; `GET /dsh-evolution/mobile` returns the standalone mobile page.
|
|
71
|
+
|
|
72
|
+
| Method | Path | Purpose |
|
|
73
|
+
|---|---|---|
|
|
74
|
+
| GET | `/dsh-evolution/api/status` | Full state (skill counts, drafts with bodies and briefings, ledger, last review, throttle, config) |
|
|
75
|
+
| GET | `/dsh-evolution/api/skills` | Skill list (lifecycle state, use count, whether created by the agent) |
|
|
76
|
+
| GET | `/dsh-evolution/api/drafts` | Pending drafts (full `SKILL.md` plus `briefing`) |
|
|
77
|
+
| GET | `/dsh-evolution/api/skill/:name` | One skill in detail |
|
|
78
|
+
| GET | `/dsh-evolution/api/ledger` | Ledger entries (`?limit=`) |
|
|
79
|
+
| GET | `/dsh-evolution/api/ledger/:id` | One ledger entry with before/after SHA lists |
|
|
80
|
+
| GET | `/dsh-evolution/api/candidates` | Skills eligible for consolidation |
|
|
81
|
+
| POST | `/dsh-evolution/api/refine-draft` | Rewrite a draft from your directive and refresh the briefing |
|
|
82
|
+
| POST | `/dsh-evolution/api/promote` | Promote a draft (optionally fusing the directive first) |
|
|
83
|
+
| POST | `/dsh-evolution/api/promote-batch` | Atomic batch promotion |
|
|
84
|
+
| POST | `/dsh-evolution/api/discard` | Reject a draft |
|
|
85
|
+
| POST | `/dsh-evolution/api/tidy` | One-click triage of a draft backlog |
|
|
86
|
+
| POST | `/dsh-evolution/api/rollback` | Roll back by ledger `id` |
|
|
87
|
+
| POST | `/dsh-evolution/api/pin` | Pin / unpin |
|
|
88
|
+
| POST | `/dsh-evolution/api/adopt` · `/disown` | Take over / release a skill |
|
|
89
|
+
| POST | `/dsh-evolution/api/consolidate` | Umbrella consolidation (`dryRun: true` previews) |
|
|
90
|
+
| POST | `/dsh-evolution/api/config` | Save config |
|
|
91
|
+
| POST | `/dsh-evolution/api/review` | Trigger one review manually |
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## Install
|
|
96
|
+
|
|
97
|
+
**Option A: plugin manager**
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
# installs into the given profile (a pnpm add inside that profile)
|
|
101
|
+
dsh plugin add github:veritaswiki/skill-evolution
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Then add the package name to that profile's `dsh.profile.bundles` and restart DSH. The plugin's own `cordis.patch.yml` carries the defaults (it tightens the DSH skill catalog description cap from 500 to 80 chars, and inserts its own config).
|
|
105
|
+
|
|
106
|
+
**Option B: config file**
|
|
107
|
+
|
|
108
|
+
Skip the bundle and write into `~/.dsh/cordis.patch.yml`:
|
|
109
|
+
|
|
110
|
+
```yaml
|
|
111
|
+
- id: tool-skill
|
|
112
|
+
config:
|
|
113
|
+
catalogDescriptionMaxLength: 80
|
|
114
|
+
- insert:
|
|
115
|
+
- id: skill-evolution
|
|
116
|
+
name: 'skill-evolution'
|
|
117
|
+
config:
|
|
118
|
+
enabled: true
|
|
119
|
+
mode: draft
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
**Option C: from source**
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
git clone https://github.com/veritaswiki/skill-evolution.git
|
|
126
|
+
dsh plugin add ./skill-evolution
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
After installing, `/evolution status` should show the skills root, mode, skill count, draft count and ledger entry count.
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## Configuration
|
|
134
|
+
|
|
135
|
+
Defaults in `cordis.patch.yml` match the Schemastery definition in `index.js`:
|
|
136
|
+
|
|
137
|
+
| Key | Type | Default | Meaning |
|
|
138
|
+
|---|---|---|---|
|
|
139
|
+
| `enabled` | boolean | `true` | Enable post-turn review |
|
|
140
|
+
| `skillsRoot` | string | `""` (→ `~/.dsh/skills`) | Skills root; drafts, ledger and telemetry live here |
|
|
141
|
+
| `mode` | `"draft" \| "apply"` | `"draft"` | `draft` writes only to `.staging/`; `apply` writes into the library after the gates |
|
|
142
|
+
| `minTurnsBetween` | number | `1` | Minimum reviewable turns between two reviews |
|
|
143
|
+
| `minMinutesBetween` | number | `2` | Minimum minutes between two reviews |
|
|
144
|
+
| `maxMessages` | number | `24` | Recent messages kept in the snapshot |
|
|
145
|
+
| `maxChars` | number | `24000` | Snapshot character budget per review |
|
|
146
|
+
| `reviewTimeoutSeconds` | number | `180` | Per-review timeout |
|
|
147
|
+
| `reviewModel.provider` | string | `""` | Review-only provider; empty inherits the session model |
|
|
148
|
+
| `reviewModel.model` | string | `""` | Review-only model; empty inherits the session model |
|
|
149
|
+
| `reviewModel.reasoningEffort` | string | `""` | Passed through to the host |
|
|
150
|
+
| `curatorEnabled` | boolean | `true` | Enable lifecycle maintenance |
|
|
151
|
+
| `consolidate` | boolean | `false` | Run umbrella consolidation in the curator timer |
|
|
152
|
+
| `consolidateDryRun` | boolean | `true` | Consolidation previews only |
|
|
153
|
+
| `staleAfterDays` | number | `14` | Days of non-use before `stale` |
|
|
154
|
+
| `archiveAfterDays` | number | `30` | Days of non-use before moving to `.archive/` (no delete) |
|
|
155
|
+
|
|
156
|
+
Environment variables (all optional):
|
|
157
|
+
|
|
158
|
+
| Variable | Purpose |
|
|
159
|
+
|---|---|
|
|
160
|
+
| `DSH_EVOLUTION_BASE_URL` | OpenAI-compatible auxiliary endpoint (e.g. `https://host/v1`). Unset means reviews go through the host subagent fork |
|
|
161
|
+
| `DSH_EVOLUTION_API_KEY` | Bearer token for that endpoint |
|
|
162
|
+
| `DSH_EVOLUTION_MODEL` | Model name used on that endpoint |
|
|
163
|
+
| `DSH_EVOLUTION_PORT` | Fixed port for the standalone mobile service, default `18890` |
|
|
164
|
+
| `DSH_HOME` | DSH home directory, default `~/.dsh` |
|
|
165
|
+
|
|
166
|
+
### Commands and tools
|
|
167
|
+
|
|
168
|
+
`/evolution` subcommands: `brief [name]` / `drafts`, `refine <name> <directive>`, `approve <name> <directive>` (`promote` is an alias and also requires a directive), `reject <name> <directive>` (`discard` is an alias), `ledger`, `skills`, `adopt <name>`, `disown <name>`, `rollback <id>`, `review`, `consolidate [--apply]`, `status` (default).
|
|
169
|
+
|
|
170
|
+
The `evolution_review_center` tool targets chat and mobile clients: `action` is one of `brief`, `interactive_review` (default), `refine`, `approve`, `reject`.
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## Known limitations
|
|
175
|
+
|
|
176
|
+
- **The auxiliary channel is yours to configure**: the package ships no gateway address and no credentials. Without `DSH_EVOLUTION_BASE_URL`, reviews go through the host subagent fork and you do not get the low-latency auxiliary path.
|
|
177
|
+
- **Gates cannot judge value**: the four gates are static checks (name, frontmatter, forbidden content, size). Whether a lesson is worth recording is still the model's call, so drafts need a human read.
|
|
178
|
+
- **The UI is Chinese only**: `locale/en.json` covers just the plugin name and description; the workbench has no English UI.
|
|
179
|
+
- **Interactive cards need host support**: `evolution_review_center` asks through the host `userQuestions` service. Without it, the tool falls back to Chinese briefing text and the user replies with a directive.
|
|
180
|
+
- **The local HTTP API has no authentication**: the fixed-port service binds `0.0.0.0:18890` for local or trusted-network use; if the port is taken it silently skips.
|
|
181
|
+
- **`mode: apply` writes the real skill library**: only for skills with `metadata.createdBy: agent`; the default is still `draft`.
|
|
182
|
+
- **Archiving does not free disk**: skills move to `.archive/` and you delete them yourself.
|
|
183
|
+
- **Body cap is 24000 chars**: beyond that, depth has to go into `references/`.
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
## Development
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
npm test # 70 unit tests (node --test test/*.test.js)
|
|
191
|
+
npm run audit:parity # 41-item capability audit (37 Hermes capabilities + 4 DSH-only)
|
|
192
|
+
npm run audit:prompts # byte-level prompt fidelity (LESSON_LAYER_BLOCK / _DO_NOT_CAPTURE_BLOCK)
|
|
193
|
+
npm run sanitize # sanitization gate, must report 0 hits
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
Requires Node ≥ 20.11 (`tools/*.mjs` use `import.meta.dirname`). CI runs the syntax check, the 70 tests, both audits and the sanitization gate.
|
|
197
|
+
|
|
198
|
+
### Capability parity and audits
|
|
199
|
+
|
|
200
|
+
`npm run audit:parity` checks each ported Hermes capability and lists the 4 DSH-only ones. `npm run audit:prompts` compares the two prompt blocks in `lib/prompts.js` byte for byte against `vendor/hermes/background_review.py` (currently 2098 / 1690 chars, identical).
|
|
201
|
+
|
|
202
|
+
`vendor/hermes/` is a verbatim copy of Nous Research `hermes-agent` (MIT), see [`vendor/hermes/PROVENANCE.md`](./vendor/hermes/PROVENANCE.md).
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
## License
|
|
207
|
+
|
|
208
|
+
[MIT](./LICENSE). Reference sources under `vendor/hermes/` come from Nous Research `hermes-agent`, also MIT.
|
package/README.md
CHANGED
|
@@ -1,3 +1,208 @@
|
|
|
1
|
-
#
|
|
1
|
+
# 🧬 Skill Evolution (`skill-evolution`)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://github.com/veritaswiki/skill-evolution/actions/workflows/ci.yml)
|
|
4
|
+
[](./LICENSE)
|
|
5
|
+
[](#开发)
|
|
6
|
+
[](#开发)
|
|
7
|
+
[](#能力对齐与审计)
|
|
8
|
+
|
|
9
|
+
> DSH 的 `skill` 工具只能加载技能,不能写回技能。这个插件补上写回的那一段:回合结束后自动复盘会话、把经验蒸馏成技能草稿、过四道代码级闸门后等你批示,全程记账、可单条回滚。
|
|
10
|
+
|
|
11
|
+
[English Documentation (README.en.md)](./README.en.md) · [变更日志 (CHANGELOG.md)](./CHANGELOG.md)
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## 界面
|
|
16
|
+
|
|
17
|
+

|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## 它做什么
|
|
22
|
+
|
|
23
|
+
1. **回合后自动复盘** — 监听 `turn/end` 与 `session/flush`,识别 `user-correction`、`new-technique`、`skill-was-wrong` 三类信号;按 `minTurnsBetween` 回合 / `minMinutesBetween` 分钟双重节流(`.throttle.json` 跨进程持久化),快照有界(`maxMessages` 条、`maxChars` 字符)。
|
|
24
|
+
2. **复盘是只读的** — 复盘跑在宿主 subagent fork(`subagents.startActivation`,工具白名单 `skill` / `glob` / `grep` / `read`)或一个 OpenAI-compatible 辅助端点;两条通道都不写文件,写入由插件在闸门之后自己做,且新回合到来会打断上一次复盘、单次有超时。
|
|
25
|
+
3. **默认只产草稿** — `mode: draft` 时产物只写 `<skillsRoot>/.staging/`,正式技能库零改动;采纳后由 `promote` 落进正式技能目录,靠 DSH 技能文件系统的热更新自动生效。
|
|
26
|
+
4. **四道代码级闸门 + 归属保护** — 见下方闸门表;只有 `metadata.createdBy: agent` 的技能会被自动改写,用户手写技能一律不碰。
|
|
27
|
+
5. **账本与单条回滚** — 每次创建 / 补丁 / 批示修订 / 采纳 / 合并 / 归档都追加一条 `.evolution_ledger.jsonl`,文件内容按 SHA-256 去重存进 `.evolution_backups/blobs/`;回滚前先做安全捕获,捕获失败就拒绝回滚(fail-closed)。
|
|
28
|
+
6. **生命周期与建伞合并** — `.usage.json` 旁路遥测驱动 `active → stale(14d) → archived(30d)`(零使用不归档、`pinned` 豁免、内置技能受保护、只移动不删除);另有 LLM 建伞合并把多个窄技能并成类级别伞技能,默认只预览不执行。
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## 它怎么做
|
|
33
|
+
|
|
34
|
+
### 流水线模块
|
|
35
|
+
|
|
36
|
+
| 环节 | 文件 | 做什么 |
|
|
37
|
+
|---|---|---|
|
|
38
|
+
| 采集 | `lib/collector.js` | 剥离系统注入块,识别复盘信号,节流,压缩历史为摘要,裁剪到 `maxChars` |
|
|
39
|
+
| 复盘 | `lib/reflector.js` + `lib/prompts.js` | fork 只读复盘或调辅助端点;提示词逐字取自 Hermes(见 `vendor/hermes/`) |
|
|
40
|
+
| 蒸馏 | `lib/synthesizer.js` | 结构化 JSON → `SKILL.md` 内容(纯函数) |
|
|
41
|
+
| 闸门 | `lib/gatekeeper.js` | 四道静态检查,见下表 |
|
|
42
|
+
| 落盘 | `lib/applier.js` | draft/apply 两种落盘位置,归属保护,提升草稿 |
|
|
43
|
+
| 记账 | `lib/ledger.js` | JSONL 账本、SHA-256 blob、单条回滚、轮转与 blob GC |
|
|
44
|
+
| 生命周期 | `lib/usage.js` | `.usage.json` 遥测、三态转换、pinned/保护技能、adopt/disown |
|
|
45
|
+
| 建伞合并 | `lib/consolidation.js` | 前缀聚类 + LLM 计划校验(原子性:一条不合规整批拒绝) |
|
|
46
|
+
| 展示 | `client.js` + `lib/http-api.js` | Web 工作台与 `/dsh-evolution/api/*` |
|
|
47
|
+
|
|
48
|
+
### 四道闸门(`lib/gatekeeper.js`)
|
|
49
|
+
|
|
50
|
+
| # | 检查 | 拒绝什么 |
|
|
51
|
+
|---|---|---|
|
|
52
|
+
| 1 | 命名 | 非 kebab-case、超 64 字符、`fix-X` / `debug-Y` / PR 号 / 日期戳这类一次性会话产物、裸库名 |
|
|
53
|
+
| 2 | Frontmatter | 缺 `description`;`description` 超 80 字符;`frontmatter.name` 与目标名不一致 |
|
|
54
|
+
| 3 | 禁词扫描 | 负面断言(`X tool does not work`)、环境失败(`command not found`)、一次性叙事 |
|
|
55
|
+
| 4 | 体积与路径 | 正文超 24000 字符;`add_reference` 的路径不是 `references/<topic>.md` 或带日期戳 |
|
|
56
|
+
|
|
57
|
+
### 前端挂载点(`client.js`)
|
|
58
|
+
|
|
59
|
+
| 插槽 | order | 内容 |
|
|
60
|
+
|---|---|---|
|
|
61
|
+
| `main` | — | 完整工作台:概览 / 待审草稿 / 技能库 / 账本 / 参数五个视图 |
|
|
62
|
+
| `sidebar.panellist` | 15 | 侧栏入口 |
|
|
63
|
+
| `settings.section` | 30 | 只放引擎参数与状态,不放审阅工作台 |
|
|
64
|
+
| `settings.section.icon` | — | 设置段图标 |
|
|
65
|
+
|
|
66
|
+
界面样式只取宿主 `--dsw-alias-*` token 跟随明暗主题(720px 容器、20/14/12 号字阶梯、`.5px` 行分割线、36×20 原生开关)。
|
|
67
|
+
|
|
68
|
+
### HTTP API(`lib/http-api.js`)
|
|
69
|
+
|
|
70
|
+
前缀 `/dsh-evolution`,`GET /dsh-evolution/mobile` 返回独立手机端页面。
|
|
71
|
+
|
|
72
|
+
| 方法 | 路径 | 作用 |
|
|
73
|
+
|---|---|---|
|
|
74
|
+
| GET | `/dsh-evolution/api/status` | 完整状态(技能数、草稿含正文与中文简报、账本、最近复盘、节流、配置) |
|
|
75
|
+
| GET | `/dsh-evolution/api/skills` | 技能列表(生命周期状态、使用次数、是否 agent 创建) |
|
|
76
|
+
| GET | `/dsh-evolution/api/drafts` | 待审草稿(含完整 `SKILL.md` 与 `briefing`) |
|
|
77
|
+
| GET | `/dsh-evolution/api/skill/:name` | 单个技能详情 |
|
|
78
|
+
| GET | `/dsh-evolution/api/ledger` | 账本记录(`?limit=`) |
|
|
79
|
+
| GET | `/dsh-evolution/api/ledger/:id` | 单条账本(含前后文件 SHA 清单) |
|
|
80
|
+
| GET | `/dsh-evolution/api/candidates` | 可参与建伞合并的候选技能 |
|
|
81
|
+
| POST | `/dsh-evolution/api/refine-draft` | 按批示让 AI 重写草稿并更新简报 |
|
|
82
|
+
| POST | `/dsh-evolution/api/promote` | 采纳草稿(可先融合批示) |
|
|
83
|
+
| POST | `/dsh-evolution/api/promote-batch` | 原子批量采纳 |
|
|
84
|
+
| POST | `/dsh-evolution/api/discard` | 驳回草稿 |
|
|
85
|
+
| POST | `/dsh-evolution/api/tidy` | 待审积压一键分诊 |
|
|
86
|
+
| POST | `/dsh-evolution/api/rollback` | 按账本 `id` 回滚 |
|
|
87
|
+
| POST | `/dsh-evolution/api/pin` | 固定 / 取消固定 |
|
|
88
|
+
| POST | `/dsh-evolution/api/adopt` · `/disown` | 纳入 / 取消纳管 |
|
|
89
|
+
| POST | `/dsh-evolution/api/consolidate` | 建伞合并(`dryRun: true` 预览) |
|
|
90
|
+
| POST | `/dsh-evolution/api/config` | 保存配置 |
|
|
91
|
+
| POST | `/dsh-evolution/api/review` | 手动触发一次复盘 |
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## 安装
|
|
96
|
+
|
|
97
|
+
**方式 A:插件管理器**
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
# 装进指定 profile(等价于在该 profile 目录执行 pnpm add)
|
|
101
|
+
dsh plugin add github:veritaswiki/skill-evolution
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
然后把包名加入该 profile 的 `dsh.profile.bundles`,重启 DSH。插件自己的 `cordis.patch.yml` 会带上默认配置(把 DSH 技能目录描述上限从 500 收到 80 字符,并对本插件 `insert` 一份配置)。
|
|
105
|
+
|
|
106
|
+
**方式 B:配置文件**
|
|
107
|
+
|
|
108
|
+
不装 bundle,直接在 `~/.dsh/cordis.patch.yml` 写:
|
|
109
|
+
|
|
110
|
+
```yaml
|
|
111
|
+
- id: tool-skill
|
|
112
|
+
config:
|
|
113
|
+
catalogDescriptionMaxLength: 80
|
|
114
|
+
- insert:
|
|
115
|
+
- id: skill-evolution
|
|
116
|
+
name: 'skill-evolution'
|
|
117
|
+
config:
|
|
118
|
+
enabled: true
|
|
119
|
+
mode: draft
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
**方式 C:源码**
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
git clone https://github.com/veritaswiki/skill-evolution.git
|
|
126
|
+
dsh plugin add ./skill-evolution
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
装好之后,`/evolution status` 应能看到技能根目录、模式、技能数、待审草稿数与账本条数。
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## 配置
|
|
134
|
+
|
|
135
|
+
`cordis.patch.yml` 里的默认值与 `index.js` 的 Schemastery 定义一致:
|
|
136
|
+
|
|
137
|
+
| 键 | 类型 | 默认值 | 说明 |
|
|
138
|
+
|---|---|---|---|
|
|
139
|
+
| `enabled` | boolean | `true` | 是否启用回合后自动复盘 |
|
|
140
|
+
| `skillsRoot` | string | `""`(→ `~/.dsh/skills`) | 技能根目录;草稿、账本、遥测都放这里 |
|
|
141
|
+
| `mode` | `"draft" \| "apply"` | `"draft"` | `draft` 只写 `.staging/`;`apply` 过闸后直接落盘 |
|
|
142
|
+
| `minTurnsBetween` | number | `1` | 两次复盘之间至少间隔多少个可复盘回合 |
|
|
143
|
+
| `minMinutesBetween` | number | `2` | 两次复盘之间至少间隔多少分钟 |
|
|
144
|
+
| `maxMessages` | number | `24` | 快照保留的最近消息条数 |
|
|
145
|
+
| `maxChars` | number | `24000` | 单次复盘快照字符上限 |
|
|
146
|
+
| `reviewTimeoutSeconds` | number | `180` | 单次复盘超时 |
|
|
147
|
+
| `reviewModel.provider` | string | `""` | 复盘专用模型 provider;留空继承当前会话模型 |
|
|
148
|
+
| `reviewModel.model` | string | `""` | 复盘专用模型名;留空继承当前会话模型 |
|
|
149
|
+
| `reviewModel.reasoningEffort` | string | `""` | 透传给宿主的 reasoning effort |
|
|
150
|
+
| `curatorEnabled` | boolean | `true` | 是否启用生命周期维护 |
|
|
151
|
+
| `consolidate` | boolean | `false` | 定时 curator 是否自动跑建伞合并 |
|
|
152
|
+
| `consolidateDryRun` | boolean | `true` | 建伞合并只出计划、不改盘 |
|
|
153
|
+
| `staleAfterDays` | number | `14` | 多少天未使用标记 `stale` |
|
|
154
|
+
| `archiveAfterDays` | number | `30` | 多少天未使用移入 `.archive/`(不删除) |
|
|
155
|
+
|
|
156
|
+
环境变量(全部可选):
|
|
157
|
+
|
|
158
|
+
| 变量 | 作用 |
|
|
159
|
+
|---|---|
|
|
160
|
+
| `DSH_EVOLUTION_BASE_URL` | OpenAI-compatible 辅助端点(如 `https://host/v1`)。不设则复盘走宿主 subagent fork |
|
|
161
|
+
| `DSH_EVOLUTION_API_KEY` | 辅助端点的 Bearer token |
|
|
162
|
+
| `DSH_EVOLUTION_MODEL` | 辅助端点使用的模型名 |
|
|
163
|
+
| `DSH_EVOLUTION_PORT` | 独立手机端服务的固定端口,默认 `18890` |
|
|
164
|
+
| `DSH_HOME` | DSH 主目录,默认 `~/.dsh` |
|
|
165
|
+
|
|
166
|
+
### 命令与工具
|
|
167
|
+
|
|
168
|
+
`/evolution` 子命令:`brief [name]` / `drafts`、`refine <name> <批示>`、`approve <name> <批示>`(`promote` 同义,同样必须带批示)、`reject <name> <批示>`(`discard` 同义)、`ledger`、`skills`、`adopt <name>`、`disown <name>`、`rollback <id>`、`review`、`consolidate [--apply]`、`status`(默认)。
|
|
169
|
+
|
|
170
|
+
`evolution_review_center` 工具面向聊天端 / 手机端:`action` 取 `brief`、`interactive_review`(默认)、`refine`、`approve`、`reject`。
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## 已知限制
|
|
175
|
+
|
|
176
|
+
- **辅助通道需要你自己配**:不带任何网关地址或凭据。不设 `DSH_EVOLUTION_BASE_URL` 时复盘走宿主 subagent fork,走不了低延迟辅助模型那条路。
|
|
177
|
+
- **闸门挡不住「没价值」**:四道闸门只做静态检查(命名、frontmatter、禁词、体积),「这条经验值不值得记」仍由模型判断,草稿需要人看。
|
|
178
|
+
- **界面只有中文**:`locale/en.json` 只覆盖插件名与描述,工作台没有英文 UI。
|
|
179
|
+
- **交互卡片依赖宿主**:`evolution_review_center` 的卡片走宿主 `userQuestions` 服务;宿主没有这个服务时退化为返回中文简报文本,需要用户直接回复批示。
|
|
180
|
+
- **本地 HTTP 无鉴权**:固定端口服务绑 `0.0.0.0:18890`,供本机或可信网络使用;端口被占用时静默跳过。
|
|
181
|
+
- **`mode: apply` 会直接改正式技能库**:只对 `metadata.createdBy: agent` 的技能生效,默认仍是 `draft`。
|
|
182
|
+
- **归档不释放磁盘**:移进 `.archive/`,要回收得自己删。
|
|
183
|
+
- **正文上限 24000 字符**:超了必须拆到 `references/`。
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
## 开发
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
npm test # 70 个单元测试(node --test test/*.test.js)
|
|
191
|
+
npm run audit:parity # 41 项能力对齐审计(37 项 Hermes 能力 + 4 项 DSH 独有)
|
|
192
|
+
npm run audit:prompts # 两段提示词逐字节保真度(LESSON_LAYER_BLOCK / _DO_NOT_CAPTURE_BLOCK)
|
|
193
|
+
npm run sanitize # 脱敏门禁,0 命中才通过
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
需要 Node ≥ 20.11(`tools/*.mjs` 用 `import.meta.dirname`)。CI 会跑语法检查、70 个测试、两道审计和脱敏门禁。
|
|
197
|
+
|
|
198
|
+
### 能力对齐与审计
|
|
199
|
+
|
|
200
|
+
`npm run audit:parity` 逐项核对 Hermes 能力是否落地,并列出 4 项 DSH 独有能力;`npm run audit:prompts` 把 `lib/prompts.js` 里的两段提示词与 `vendor/hermes/background_review.py` 的原文逐字节比对(当前 2098 / 1690 字符全等)。
|
|
201
|
+
|
|
202
|
+
`vendor/hermes/` 是 Nous Research `hermes-agent` 的逐字副本(MIT),见 [`vendor/hermes/PROVENANCE.md`](./vendor/hermes/PROVENANCE.md)。
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
## License
|
|
207
|
+
|
|
208
|
+
[MIT](./LICENSE)。`vendor/hermes/` 下的参考源码来自 Nous Research `hermes-agent`,同样遵循 MIT。
|
|
Binary file
|
|
Binary file
|