@stardustlc/dsh-dream 0.5.1 → 0.7.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/CHANGELOG.md +22 -0
- package/README.en.md +39 -14
- package/README.md +43 -18
- package/lib/bridge.d.ts +205 -2
- package/lib/bridge.js +1053 -6
- package/lib/client.js +634 -27
- package/lib/evidence.d.ts +15 -0
- package/lib/evidence.js +123 -0
- package/lib/index.js +3 -1
- package/lib/knowledge-store.d.ts +23 -5
- package/lib/knowledge-store.js +311 -41
- package/lib/knowledge.d.ts +40 -0
- package/lib/knowledge.js +54 -0
- package/lib/mask.d.ts +3 -1
- package/lib/mask.js +8 -2
- package/lib/retrieval.d.ts +12 -0
- package/lib/retrieval.js +68 -3
- package/lib/tools.d.ts +2 -0
- package/lib/tools.js +436 -128
- package/lib/web-actions.d.ts +11 -0
- package/lib/web-actions.js +175 -0
- package/lib/web.d.ts +50 -1
- package/lib/web.js +153 -13
- package/package.json +2 -2
- package/skills/dream-protocol/SKILL.md +9 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.7.0(2026-10-02)
|
|
4
|
+
|
|
5
|
+
- 设置页可直接采纳、驳回、重新送审、标记待复核和处理冲突;页面操作记录为 human,模型工具继续记录为 model。保留 revision 校验,失败时保留填写内容。
|
|
6
|
+
- 展开关联来源可查看核验状态、摘要、记录时间、会话序号和来源校验值;读到来源不等同于证明结论正确。
|
|
7
|
+
- 项目经验可在面板查看 AGENTS.md 差异后应用,预览绑定经验版本与文件哈希,10 分钟失效。写入记录提供确认回滚,管理块外的人工内容保留。
|
|
8
|
+
- 新增独立使用反馈(有用 / 不适用及场景备注),不自动采纳、变更状态或提高证据数量;并发校验、重复请求幂等,明细保留最近 20 次,历史在事件流中。
|
|
9
|
+
- 写操作使用 DSH 0.2.0-rc.2 的认证 Connection 通道,并检查 JSON、来源和请求大小;旧宿主保留对话命令入口。修复真实宿主内部请求地址引起的正常操作拒绝。
|
|
10
|
+
- 窄窗口打开 Dream 时把宿主设置导航改为顶部横向导航,避免面板被压成单字列。详见 [验收范围](docs/validation/0.7.0.md)。
|
|
11
|
+
|
|
12
|
+
## 0.6.0(2026-09-30)
|
|
13
|
+
|
|
14
|
+
- **经验来源核验**:工具读取实际会话记录或工作目录内的本地产物,核对项目、角色、记录序号、引用和哈希;伪造 read 或无法定位的来源降为 claimed,并给出原因。新经验先进入候选;读到用户纠正不再自动冒充用户采纳。
|
|
15
|
+
- **完整审阅**:补充证据保持状态并检查 revision;双向冲突与 prefer/drop/merge 在同一事件中原子保存,校验失败零写入;支持已驳回经验重新送审。平台条件参与检索,Windows 任务不会取到 Linux 专用经验。
|
|
16
|
+
- **桥接预览 / 应用 / 回滚**:预览返回差异和文件状态,新文件允许 null 哈希;应用先持久化恢复记录再原子替换目标,中断或最终审计失败后仍有可用 backupId。处理目标链接、并发修改、BOM、CRLF 与回滚后保留人工追加内容。
|
|
17
|
+
- **面板操作**:日记 / 经验 / 写入记录分开,行动建议直接可见、证据与例外按需展开;冲突选择显示经验标题并要求处理依据。公开编号经过脱敏仍可唯一定位;回滚编号、完整命令和复制按钮能使用。保留正常 Unix 目标路径,路径中的密钥继续脱敏。修复筛选 Escape 误关宿主设置;窄窗单列显示,日记频次标为“常见教训”。
|
|
18
|
+
- **验证范围**:全量回归、8 进程并发、官方前端加载器和 18 插件同载契约检查;实际 Web 宿主使用隔离的合成资料进行操作验收。详细结果与限制见 [0.6.0 验收记录](docs/validation/0.6.0.md)。零新增运行时依赖,旧日志不重写。
|
|
19
|
+
|
|
20
|
+
## 0.5.2(2026-09-29)
|
|
21
|
+
|
|
22
|
+
- **修复窄窗不折叠**:经验区块的两栏布局在容器 ≤620px 时本应折叠为单列,但折叠规则排在基础规则之前、同特异性被覆盖,导致 620px 窄窗下仍挤成两列(长条件文字被压成多行)。现把该断点块移到样式表末尾。
|
|
23
|
+
- 断点按**容器宽度**(≤620px)触发,不是视口宽度:因此 125% 缩放在 1024px 视口下仍是两列,150% 缩放(容器折算 617px)折叠为单列——这是预期行为,与窄窗一致。
|
|
24
|
+
- 实测(离线夹具渲染,620 / 125% / 150% / 1280px 四档):单列 554px / 两列无溢出 / 单列 617px / 两列无溢出,均无横向滚动;`node --check`、官方加载器回归与全量 204 项(203 通过 + 1 默认跳过)通过。
|
|
3
25
|
## 0.5.1(2026-09-29)
|
|
4
26
|
|
|
5
27
|
- **修复两个已发布缺陷**(0.5.0 起):① 日记文件开头有 UTF-8 BOM 时整份日记被读空;② 心境聚合用普通对象做映射,`__proto__` 键被吞、`constructor` 等键会把计数变成字符串(`"function Object()…1"`)。现在 BOM 会被剥离,聚合用无原型对象后返回普通副本,并新增 `skippedLines` 让坏行可诊断。
|
package/README.en.md
CHANGED
|
@@ -4,13 +4,29 @@
|
|
|
4
4
|
|
|
5
5
|
# dsh-dream
|
|
6
6
|
|
|
7
|
+
## 0.7.0 update (2026-10-02)
|
|
8
|
+
|
|
9
|
+
- Direct review buttons, conflict resolution with a required reason, and expandable source records. UI decisions record `human`; model tools still record `model`. Revision conflicts preserve entered text.
|
|
10
|
+
- Project lessons can preview the exact AGENTS.md changes, apply the approved preview, and roll back the managed block while preserving manual content outside it. Previews expire after ten minutes and check both lesson revision and file hash. Lessons without a project directory keep the project-chat preview command.
|
|
11
|
+
- Separate useful / not-applicable feedback with optional context, idempotent retries, and the latest twenty details. Feedback does not automatically accept, reject, validate, or add evidence to a lesson.
|
|
12
|
+
- Mutations use Harness 0.2.0-rc.2's authenticated Connection Fetch carrier. Read-only endpoints and command fallbacks remain. A Dream-scoped narrow-window layout prevents the settings navigation from squeezing the content into single-character columns.
|
|
13
|
+
- See [0.7.0 validation](docs/validation/0.7.0.md) for browser, automatic-test and native Desktop boundaries.
|
|
14
|
+
|
|
15
|
+
## 0.6.0 update (2026-09-30)
|
|
16
|
+
|
|
17
|
+
- **Source verification and review**: reads actual session records or bounded project artifacts. Unverifiable claims stay claimed with a reason. New lessons start as candidates, including user corrections.
|
|
18
|
+
- **Recoverable bridging**: preview / apply / rollback with durable recovery records written before the target. Handles missing-file null hashes, linked paths, CRLF rollback and concurrent edits.
|
|
19
|
+
- **Complete review**: verified evidence attachment, atomic conflict resolution (prefer/drop/merge), reopening rejected lessons, and stable public references.
|
|
20
|
+
- **Usable panel**: separate Journal / Lessons / Write log views, prominent action text, a conflict form with named lessons and a required reason, and copyable rollback commands.
|
|
21
|
+
- See [0.6.0 validation](docs/validation/0.6.0.md) and [CHANGELOG](CHANGELOG.md).
|
|
22
|
+
|
|
7
23
|
## 0.4.1 update (2026-09-29)
|
|
8
24
|
|
|
9
25
|
- **Fixes a Desktop boot failure**: the front-end module id now matches the scoped package name (it used to register as `dsh-dream`, so the host retried the bundle and threw `duplicate factory registration`, ending in `1 entry did not activate`). No journal or config migration.
|
|
10
26
|
|
|
11
27
|
## 0.5.1 update (2026-09-29)
|
|
12
28
|
|
|
13
|
-
- **Fixes**: a leading UTF-8 BOM used to hide the whole journal; mood keys such as `__proto__`/`constructor` corrupted counts. **Retrieval discipline**: candidates and evidence-free lessons are not injected by default, version checks need package context, and the budget packs by rank. **
|
|
29
|
+
- **Fixes**: a leading UTF-8 BOM used to hide the whole journal; mood keys such as `__proto__`/`constructor` corrupted counts. **Retrieval discipline**: candidates and evidence-free lessons are not injected by default, version checks need package context, and the budget packs by rank. **Historical evidence policy**: read evidence used to promote lessons directly; 0.6.0 replaces this with independent source verification and review.
|
|
14
30
|
- 204 tests (203 passing, 1 opt-in concurrency stress test skipped); L1 acceptance 9/9. Known limit: reads/writes still grow with history on very large libraries.
|
|
15
31
|
|
|
16
32
|
## 0.5.0 update (2026-09-29)
|
|
@@ -20,6 +36,7 @@
|
|
|
20
36
|
- **Masking and scope guarantees**: every new write path runs through `mask.ts` when `maskSecrets` is on; evidence stores only masked one-line summaries plus locators — never hidden reasoning, system prompts, tool arguments or result bodies. Lessons are scoped to a project or global; with an unknown project `dream_context` returns global lessons only and never scans across projects.
|
|
21
37
|
- **Compatibility**: the old journal and the six existing tools (dream_digest / dream_save / dream_journal / dream_recall / dream_bridge / dream_health) keep their behaviour and output fields only grow. No migration is required and no old data is rewritten.
|
|
22
38
|
- **New read-only "Lessons" block** in the panel: state (candidate / usable / disputed / stale / rejected), applicability, scope, applicability details (package / versions / platform) and exceptions (only when non-empty), evidence summary and last-validated time. Candidates and disputed lessons are visually distinct, and an empty knowledge store has its own empty state. When the event log is truncated or has bad lines the block shows a notice and says events.jsonl was left untouched. The panel still has no write actions.
|
|
39
|
+
- **Two more read-only blocks (M2)**: "To review" (candidate / disputed / stale lessons plus why each is held back, using the retrieval layer's Chinese skipped-reason labels) and "Write log" (bridge application records from <journalDir>/bridge/: target, time, lessonId@revision, before/after hashes, rollbackable and why). Every lesson gets a "copy review command"; bridgeable (usable) lessons get a "copy preview command"; if the clipboard fails it falls back to selectable text. The panel still has no write methods.
|
|
23
40
|
|
|
24
41
|
## 0.4.0 update (2026-09-29)
|
|
25
42
|
|
|
@@ -31,7 +48,7 @@ Humans consolidate memories by replaying the day during sleep — dsh-dream give
|
|
|
31
48
|
|
|
32
49
|
## Compatibility
|
|
33
50
|
|
|
34
|
-
Validation host: Harness
|
|
51
|
+
Validation host: Harness 0.2.0-rc.1 built from official sources (commit 407e65c8, with local host fixes), Node 24.16.0. Version 0.6.0 is exercised in a real Web host with an isolated profile. Web validation does not certify the native Desktop installer; see the validation record for exact scope. The full scoped client identity remains compatible with the Desktop module loader. Registers 9 tools and dream-protocol with zero runtime dependencies.
|
|
35
52
|
|
|
36
53
|
Reads v0/v1/v2/v3/v4 plaintext JSONL and multi-frame zstd, legacy packed chunks and embedded streams. Only the newest canonical file is selected per session. PTC child calls retain tool names without double counting; system prompts, reasoning, tool arguments and result bodies are excluded.
|
|
37
54
|
|
|
@@ -50,18 +67,18 @@ Restart the web service afterwards. The dream journal lives at `~/.dsh/.dsh-drea
|
|
|
50
67
|
|
|
51
68
|
## Dream journal panel (0.4.0+)
|
|
52
69
|
|
|
53
|
-
Once installed, DSH's **Settings →「梦境日记」(Dream journal)**
|
|
70
|
+
Once installed, DSH's **Settings →「梦境日记」(Dream journal)** provides Journal, Lessons and Write log views. From 0.7.0, reviews and feedback run through the authenticated Connection carrier in Harness 0.2.0-rc.2. Headless hosts keep the tools and skill without a settings page.
|
|
54
71
|
|
|
55
72
|
- **What it shows**: totals, a mood-square strip (never empty for a single dream, wraps when there are many) and the lessons board at the top; below that, a card timeline, newest first, with timestamp, mood, reflection body and lessons. Reflections are expanded by default and collapse to 4 lines with a show-more control beyond 4 lines or 220 characters.
|
|
56
|
-
- **Lessons board**: ranked by occurrences
|
|
73
|
+
- **Lessons board**: ranked by journal occurrences and recency; 3 or more occurrences are labelled common lessons. Frequency does not establish correctness, importance or bridge eligibility. Technical lessons need their own sources, review and a write preview.
|
|
57
74
|
- **Search**: filters by keyword across reflections and lessons, case-insensitively. Mood distribution and the lessons board are computed over the full journal; the timeline is paged by search and limit (latest 50 by default).
|
|
58
75
|
- **Filtering and older dreams**: from 8 dreams on, a Filter menu appears (by mood, or only dreams with lessons; it applies to the loaded window and says so). When 50 dreams are loaded and more exist, the footer offers "show older dreams", which fetches up to the 500-dream route cap in one go.
|
|
59
|
-
- **
|
|
76
|
+
- **Journal reads**: GET /_dsh/dsh-dream/journal is loopback-only; non-GET → 405, non-local Host → 403. Saving, listing and recalling dreams still happen in chat via dream_save / dream_journal / dream_recall. Panel reviews update knowledge events; previews do not write files.
|
|
60
77
|
- **Data file**: the panel renders the journal itself — ~/.dsh/.dsh-dream/dreams.jsonl by default ($DSH_HOME/.dsh-dream/dreams.jsonl; an explicit journalDir wins). The storage format is unchanged: one JSON object per line, safe to remove or read with dream_journal.
|
|
61
|
-
- **Privacy**:
|
|
78
|
+
- **Privacy**: read-only routes mask text again while preserving validated lesson, evidence and backup references for commands. The UI reads local same-origin routes and does not upload to third-party services. Privacy blur is a display effect; DOM text and local logs remain plaintext.
|
|
62
79
|
- **Before the first dream**: the panel shows an empty state pointing you to ask the agent to「做个梦」; a single dream renders as one card, with neither the mood strip nor the lessons board left empty and no misleading charts.
|
|
63
|
-
- **Lessons
|
|
64
|
-
- **
|
|
80
|
+
- **Lessons view**: usable lessons and the review queue appear separately; rejected history is optional. Review buttons save directly with revision checks. Conflict resolution requires a reason. Source records can be expanded; useful / not-applicable feedback is recorded independently of review and validation. Command fallbacks remain available.
|
|
81
|
+
- **Write log and rollback**: `dream_bridge apply` appends an application record with the target, time, lesson revisions, hashes and original managed block. The panel provides a confirmed rollback action while the current block still matches. Text outside the managed block remains intact; externally changed blocks are not overwritten.
|
|
65
82
|
|
|
66
83
|
## Tools
|
|
67
84
|
|
|
@@ -71,13 +88,21 @@ Once installed, DSH's **Settings →「梦境日记」(Dream journal)** grows a
|
|
|
71
88
|
| `dream_save` | Write a reflection + 1-5 lessons + mood to the permanent journal | `reflection` required |
|
|
72
89
|
| `dream_journal` | List dreams, newest first | `limit` |
|
|
73
90
|
| `dream_recall` | Keyword search across the journal | `query` required |
|
|
74
|
-
| `dream_bridge` |
|
|
91
|
+
| `dream_bridge` | Bridge accepted, scope-matched lessons into AGENTS.md (`preview` / `apply` / `rollback`; omitting `mode` keeps the legacy direct write with a deprecation notice) | `mode` optional; `path` / `lessonIds` / `maxLessons` / `expectedSha256` / `previewId` / `projectId` |
|
|
75
92
|
| `dream_health` | Self-check: sessions dir / dream count / config summary | — |
|
|
76
93
|
| `dream_learn` | Submit a candidate technical lesson with evidence (validate / mask / dedupe / scope; evidence-free input stays a candidate) | `kind`, `title`, `action`, `when` required; `evidence` optional (defaults to `[]`) |
|
|
77
|
-
| `dream_context` | Retrieve a few applicable lessons before a task (read-only; candidates are held out by default) | `query` required; `projectId` / `workspaceRoot` / `limit` / `maxChars` / `packageName` / `packageVersion` / `includeCandidates` optional |
|
|
78
|
-
| `dream_review` | Review and transition state: accept / reject / mark stale / mark disputed / attach evidence | `action`, `lessonId`, `expectedRevision` required |
|
|
94
|
+
| `dream_context` | Retrieve a few applicable lessons before a task (read-only; candidates are held out by default) | `query` required; `projectId` / `workspaceRoot` / `limit` / `maxChars` / `packageName` / `packageVersion` / `platform` / `includeCandidates` optional |
|
|
95
|
+
| `dream_review` | Review and transition state: accept / reject / mark stale / mark disputed / resolve conflicts / attach evidence / reopen | `action`, `lessonId`, `expectedRevision` required |
|
|
96
|
+
|
|
97
|
+
Conflict review requires resolution (prefer / drop / merge), affectedIds and note. All parties are validated and updated in one event; invalid groups write nothing. attach-evidence verifies sources without promoting the lesson, and reopen returns a rejected lesson to candidate.
|
|
98
|
+
|
|
99
|
+
`dream_bridge` now has three explicit modes:
|
|
100
|
+
|
|
101
|
+
- `preview` (read-only): returns the real diff, selected lessons and skipped reasons — zero writes;
|
|
102
|
+
- `apply`: requires the preview’s `expectedSha256` (null for a missing file); also pass `previewId` to bind the preview; a concurrent edit returns `conflict` with zero writes. It only replaces the Dream managed block (`<!-- dsh-dream:start/end -->`), preserving text outside the block, BOM and line endings, first fsyncs a pending recovery record, then atomically replaces the target and records applied;
|
|
103
|
+
- `rollback`: locates the record by backupId and rolls back only while the current managed block still equals that apply result, preserving later manual additions outside it.
|
|
79
104
|
|
|
80
|
-
`
|
|
105
|
+
Omitting `mode` keeps the 0.5.x direct write and returns a deprecation notice; new flows should use `preview → apply`. Only `usable`, scope-matched (or explicit global with review.decision accepted) lessons can be bridged — frequency is no longer an admission criterion — and everything written is masked via `mask.ts`. The panel's "Write log" shows these records and whether they are rollbackable.
|
|
81
106
|
|
|
82
107
|
The bundled `dream-protocol` skill teaches the agent when and how to dream (and the journaling discipline: patterns only, never secrets).
|
|
83
108
|
|
|
@@ -85,8 +110,8 @@ The bundled `dream-protocol` skill teaches the agent when and how to dream (and
|
|
|
85
110
|
|
|
86
111
|
The dream journal holds subjective reflections; technical lessons that should be reused go to `<journalDir>/knowledge/`:
|
|
87
112
|
|
|
88
|
-
- **Candidate →
|
|
89
|
-
- **Budgeted retrieval**: `dream_context` returns at most 5 items / 3000 characters by default (hard caps 20 items / 20000 characters). Items are packed whole by rank and packing stops at the first item that does not fit (`skipped: budget-stop`); `title / when / action / exceptions` are never truncated, and no half item is ever returned. Candidates and evidence-free non-usable items are held out of task advice by default (`includeCandidates: false`, reported as `candidate-hold` / `no-evidence`); pass `includeCandidates: true` only when explicitly reviewing candidates, and note that candidates rank after usable lessons and must not be treated as verified. Rejected, stale and unresolved disputed lessons are not injected; `applicability.versions` only counts when the package is identified (explicit `packageName` or a package name in the query).
|
|
113
|
+
- **Candidate → verified source → review**: dream_learn creates candidates. Session evidence needs sessionId, recordSeq and a matching quote (summary is used if omitted); the plugin checks project, role, record and text, then computes sourceHash. User corrections must come from actual user messages. Local artifacts require artifactPath with a real path inside the execution working directory. Failed verification becomes claimed with verificationReason and contributes no independent support. Reading a source is not user acceptance; tool reviews record actor:model. attach-evidence preserves state, and every review checks expectedRevision.
|
|
114
|
+
- **Budgeted retrieval**: `dream_context` returns at most 5 items / 3000 characters by default (hard caps 20 items / 20000 characters). Items are packed whole by rank and packing stops at the first item that does not fit (`skipped: budget-stop`); `title / when / action / exceptions` are never truncated, and no half item is ever returned. Candidates and evidence-free non-usable items are held out of task advice by default (`includeCandidates: false`, reported as `candidate-hold` / `no-evidence`); pass `includeCandidates: true` only when explicitly reviewing candidates, and note that candidates rank after usable lessons and must not be treated as verified. Rejected, stale and unresolved disputed lessons are not injected. An explicit platform wins, otherwise unambiguous task text or the host platform is used; mismatches report platform-mismatch; `applicability.versions` only counts when the package is identified (explicit `packageName` or a package name in the query).
|
|
90
115
|
- **Frequency is not reliability**: resubmitting the same evidence is idempotent; never grind counts by calling `dream_save` / `dream_learn` repeatedly. Repeated occurrences within one session count as a single independent source.
|
|
91
116
|
- **Recoverable storage**: `events.jsonl` is the authoritative append-only event log, `evidence.jsonl` appends evidence and `index.json` is a disposable derived index. Rebuilding the index deletes no source files. When the directory does not exist, the read route returns an empty result and never creates anything.
|
|
92
117
|
- **Removing it**: delete `<journalDir>/knowledge/` to clear lesson memory. The old `dreams.jsonl` journal is unaffected, and older plugin versions can still read it.
|
package/README.md
CHANGED
|
@@ -2,13 +2,28 @@
|
|
|
2
2
|
|
|
3
3
|
# dsh-dream
|
|
4
4
|
|
|
5
|
+
## 0.7.0 更新(2026-10-02)
|
|
6
|
+
|
|
7
|
+
- 设置页直接采纳、驳回、标记待复核和处理冲突;关联来源可展开查看。页面审阅记录为人工操作,模型调用仍记录为模型。
|
|
8
|
+
- 带项目目录的经验可预览实际规则差异后应用,并在写入记录确认回滚。旧预览不能覆盖已变化的经验或文件;块外手工内容保留。
|
|
9
|
+
- 独立记录“这次有用 / 这次不适用”和场景备注,不自动改变审阅状态。失败时保留输入,重复反馈请求不会重复计数。
|
|
10
|
+
- 窄窗口使用顶部横向设置导航;写操作通过官方 DSH 0.2.0-rc.2 认证通道。验收范围见 [0.7.0 记录](docs/validation/0.7.0.md)。
|
|
11
|
+
|
|
12
|
+
## 0.6.0 更新(2026-09-30)
|
|
13
|
+
|
|
14
|
+
- **来源核验与独立审阅**:插件实际读取会话记录或项目内产物核对来源;无法核对时降为 claimed 并说明原因。新经验先进入候选,用户纠正原文也需要单独审阅。
|
|
15
|
+
- **可靠写入**:AGENTS.md 支持预览、应用、回滚;先持久化恢复记录再写目标文件,中断后仍能恢复。修复新文件 null 哈希、路径链接、CRLF 回滚和并发修改保护。
|
|
16
|
+
- **完整审阅**:补充证据、双向冲突、prefer/drop/merge 原子处理、驳回后重新送审;公开编号在面板与命令间保持一致,敏感正文仍脱敏。
|
|
17
|
+
- **更易操作**:日记 / 经验 / 写入记录分开;卡片直接显示“怎么做”,冲突表单要求选择经验和处理依据,写入记录可复制回滚命令;支持窄窗与筛选 Escape。
|
|
18
|
+
- 验证记录见 [0.6.0 验收](docs/validation/0.6.0.md),历史变更见 [CHANGELOG](CHANGELOG.md)。
|
|
19
|
+
|
|
5
20
|
## 0.4.1 更新(2026-09-29)
|
|
6
21
|
|
|
7
22
|
- **修复 Desktop 启动失败**:前端模块注册 ID 现与 scoped 包名一致(此前注册成 `dsh-dream`,宿主会重试加载并抛 `duplicate factory registration`,导致 `1 entry did not activate`)。日记数据与配置不变,无迁移。
|
|
8
23
|
|
|
9
24
|
## 0.5.1 更新(2026-09-29)
|
|
10
25
|
|
|
11
|
-
- **修复**:日记 BOM 导致读空、心境键(`__proto__`/`constructor
|
|
26
|
+
- **修复**:日记 BOM 导致读空、心境键(`__proto__`/`constructor`)污染计数;**检索纪律**:候选与无证据经验默认不注入、版本判定需要包名上下文、预算按排名整条装入;**历史证据策略**:当时 read 可直接成为 usable;0.6.0 已改为实际核验来源并独立审阅。
|
|
12
27
|
- 全量 **204 项 / 203 通过 / 1 默认跳过**;L1 七场景断言 9/9。已知限制:知识库很大时读/写仍随历史线性增长,本版不承诺大库性能。
|
|
13
28
|
|
|
14
29
|
## 0.5.0 更新(2026-09-29)
|
|
@@ -18,6 +33,7 @@
|
|
|
18
33
|
- **脱敏与范围承诺**:所有新写盘路径在 `maskSecrets` 开启时先过 `mask.ts`;证据只保存已脱敏摘要和定位信息,不保存隐藏推理、系统提示、工具参数 / 结果正文。经验按项目或全局范围保存,未知当前项目时 `dream_context` 只返回全局经验,绝不跨项目扫描。
|
|
19
34
|
- **兼容性**:旧日记与六个既有工具(dream_digest / dream_save / dream_journal / dream_recall / dream_bridge / dream_health)行为不变、输出字段只增不减;升级不需要迁移,也不会改写旧数据。
|
|
20
35
|
- **只读面板新增「经验」区块**:展示状态(候选 / 可用 / 有冲突 / 待复核 / 已驳回)、适用条件、范围、适用(package / versions / platform)与例外、证据摘要与最近核验时间;候选与有冲突有明确视觉区分,没有经验时是独立空态;知识日志被截断或有坏行时显示「events.jsonl 未改动」提示。面板仍然没有任何写操作。
|
|
36
|
+
- **面板新增两个只读区块(M2)**:「待核实」(candidate / disputed / stale + 被扣下的原因,来自检索层 skipped reason 的中文映射)与「写入记录」(<journalDir>/bridge/ 的应用记录:目标、时间、lessonId@revision、前后哈希、可否回滚及原因);每条经验给「复制审阅命令」,可桥接(usable)经验给「复制预览命令」,剪贴板不可用时回退为可选中文本。面板仍无写方法。
|
|
21
37
|
|
|
22
38
|
## 0.4.0 更新(2026-09-29)
|
|
23
39
|
|
|
@@ -31,7 +47,7 @@
|
|
|
31
47
|
|
|
32
48
|
## 兼容性
|
|
33
49
|
|
|
34
|
-
验证宿主:官方源码构建的 Harness
|
|
50
|
+
验证宿主:官方源码构建的 Harness 0.2.0-rc.1(commit 407e65c8,含本地宿主修补)+ Node 24.16.0。0.6.0 在隔离 profile 的实际 Web 宿主中验收;Web 验收不等同于原生 Desktop 安装器验收,具体范围见验收记录。保持完整 scoped 前端模块身份,兼容 Desktop 的模块加载契约。本插件注册 9 个工具与 dream-protocol 技能;零运行时依赖。
|
|
35
51
|
|
|
36
52
|
支持 v0/v1/v2/v3/v4 的普通 JSONL 与多帧 zstd、旧 packed-chunk 行及内嵌 stream;升级留下多代文件时只读取每个会话的最新规范文件。PTC 子工具调用保留工具名且不重复计数,不提取系统提示、推理、工具参数或结果正文。
|
|
37
53
|
|
|
@@ -57,18 +73,19 @@ dsh plugin --profile web remove @stardustlc/dsh-dream
|
|
|
57
73
|
|
|
58
74
|
## 梦境日记面板(0.4.0+)
|
|
59
75
|
|
|
60
|
-
装好后,DSH 的「设置 →
|
|
76
|
+
装好后,DSH 的「设置 → 梦境日记」提供日记、经验与写入记录。0.7.0 起可以直接审阅和反馈;写操作使用 DSH 0.2.0-rc.2 的认证 Connection 通道。headless 宿主没有设置页,工具与技能照常可用。
|
|
61
77
|
|
|
62
78
|
- **看什么**:顶部是梦境总数、心境方块序列(单条时不空,多条时自动换行)与教训榜;下面是卡片式时间线,按时间倒序,逐条显示时间、心境、反思正文与教训列表。反思正文默认展开,超过 4 行或 220 字时折叠为 4 行并给出「展开全文」。
|
|
63
|
-
-
|
|
79
|
+
- **教训榜**:按日记出现次数与最近时间排序,≥3 次标为“常见教训”;频率不代表正确性、重要度或桥接资格。技术经验必须另行提交来源、审阅,再预览写入规则。
|
|
64
80
|
- **搜索**:按关键词过滤,命中反思与教训,不区分大小写。心境分布与教训榜基于**全量日记**,时间线按搜索与条数上限(默认最近 50 场)展示。
|
|
65
81
|
- **筛选与更早的梦**:≥8 场时出现「筛选 ▾」(按心境、只看有教训的梦,作用于已加载窗口并在弹层注明);加载满 50 场且总梦数更多时,页脚提供「显示更早的梦」,点击后一次拉满到 500 场(路由上限)。
|
|
66
|
-
-
|
|
82
|
+
- **日记读取**:GET /_dsh/dsh-dream/journal 仅回环地址可达;非 GET → 405,非本机 Host → 403。记梦、翻梦、忆梦仍通过 dream_save / dream_journal / dream_recall 完成。面板审阅只更新经验事件,预览本身不写文件。
|
|
67
83
|
- **数据文件**:面板读的就是梦境日记本身,默认 ~/.dsh/.dsh-dream/dreams.jsonl($DSH_HOME/.dsh-dream/dreams.jsonl;配置了 journalDir 时以配置为准)。存储格式不变,仍是每行一条 JSON 的 JSONL,可直接删除或用 dream_journal 读取。
|
|
68
|
-
-
|
|
84
|
+
- **隐私**:只读路由会再次脱敏正文;已校验的内部经验、证据与备份编号保留以供操作。界面只访问本机同源路由,不上传第三方服务。“隐私模式”仅模糊显示,DOM 仍有文本;日志本身是明文。
|
|
69
85
|
- **还没有梦时**:面板显示空态,提示对 agent 说「做个梦」——它会回放最近的会话、反思之后把第一条梦写进这里;只有一场梦时按单条卡片展示,心境方块与教训榜都不留空、不画失真图表。
|
|
70
|
-
-
|
|
71
|
-
-
|
|
86
|
+
- **经验视图**:可用经验与待核实队列分开,已驳回历史按需查看。来源记录可展开查看核验信息;采纳、驳回、重新送审和标记待复核可以直接点击。处理冲突须选择对方经验和填写依据。每次操作检查版本,冲突时保留输入并提供刷新;对话命令入口仍可使用。
|
|
87
|
+
- **使用反馈**:展开“使用反馈”记录这次有用或不适用,并可填写场景。反馈不会自动改变审阅状态、证据或最后核验时间;最近 20 条明细可恢复,事件流保留历史。
|
|
88
|
+
- **规则变更与回滚**:带项目目录的可用经验提供“预览规则变更”,展示实际目标与新增/删除差异后才可应用。此预览按所选经验重建 Dream 管理块,保留块外内容;经验版本或文件哈希变化时拒绝应用。没有项目目录的经验须在对应项目对话中使用预览命令。写入记录展示备份与“回滚这次变更”;当前管理块仍匹配该次 apply 时才允许回滚。
|
|
72
89
|
|
|
73
90
|
## 工具一览
|
|
74
91
|
|
|
@@ -78,11 +95,13 @@ dsh plugin --profile web remove @stardustlc/dsh-dream
|
|
|
78
95
|
| `dream_save` | 记梦:反思 + 1-5 条教训 + 心境,永久保存 | `reflection` 必填;`lessons`/`mood` 可选 |
|
|
79
96
|
| `dream_journal` | 翻梦:倒序列出历史梦境 | `limit` 可选 |
|
|
80
97
|
| `dream_recall` | 忆梦:关键词检索梦境 | `query` 必填 |
|
|
81
|
-
| `dream_bridge` |
|
|
98
|
+
| `dream_bridge` | 渡梦:把已采纳、范围匹配的经验写入 AGENTS.md(`preview` 预览 / `apply` 应用 / `rollback` 回滚;缺省保留旧直写并给弃用提示) | `mode` 可选;`path` / `lessonIds` / `maxLessons` / `expectedSha256` / `previewId` / `projectId` |
|
|
82
99
|
| `dream_health` | 自检:会话目录/梦境计数/配置汇总 | 无 |
|
|
83
100
|
| `dream_learn` | 提交候选技术经验及证据(校验 / 脱敏 / 去重 / 按范围保存;无证据只能留在候选) | `kind`、`title`、`action`、`when` 必填;`evidence` 可选(缺省 `[]`) |
|
|
84
|
-
| `dream_context` | 任务前取回少量适用经验(只读;候选默认不注入) | `query` 必填;`projectId` / `workspaceRoot` / `limit` / `maxChars` / `packageName` / `packageVersion` / `includeCandidates` 可选 |
|
|
85
|
-
| `dream_review` | 审阅与状态流转:采纳 / 驳回 / 标记过期 / 标记冲突 / 补充证据 | `action`、`lessonId`、`expectedRevision` 必填 |
|
|
101
|
+
| `dream_context` | 任务前取回少量适用经验(只读;候选默认不注入) | `query` 必填;`projectId` / `workspaceRoot` / `limit` / `maxChars` / `packageName` / `packageVersion` / `platform` / `includeCandidates` 可选 |
|
|
102
|
+
| `dream_review` | 审阅与状态流转:采纳 / 驳回 / 标记过期 / 标记冲突 / 处理冲突 / 补充证据 / 重新送审 | `action`、`lessonId`、`expectedRevision` 必填 |
|
|
103
|
+
|
|
104
|
+
处理冲突时必须填写 resolution(prefer / drop / merge)、affectedIds 与 note;所有当事方一并校验并在同一事件中保存,校验失败不改任何经验。attach-evidence 核验并附加来源,reopen 把驳回经验重新置为候选。
|
|
86
105
|
|
|
87
106
|
### 示例
|
|
88
107
|
|
|
@@ -90,15 +109,21 @@ dsh plugin --profile web remove @stardustlc/dsh-dream
|
|
|
90
109
|
dream_digest { maxSessions: 5, mode: 'brief' }
|
|
91
110
|
dream_save { reflection: "用户反复遇到输入法问题,偏好先自查再重启", lessons: ["先问是否重启过应用"], mood: "平静" }
|
|
92
111
|
dream_recall { query: "输入法" }
|
|
93
|
-
dream_bridge { path: "AGENTS.md", maxLessons: 10 }
|
|
94
|
-
dream_context { query: "SMTP 取消投递", projectId: "mailer", packageVersion: "9.0.5" }
|
|
95
|
-
dream_learn { kind: "pitfall", title: "池化发送中 close() 不保证终止投递", action: "取消后验证当前连接确实关闭", when: "使用 Nodemailer 9.0.5 池化发送并处理 AbortSignal 时", evidence: [{ kind: "local-artifact", summary: "本机 SMTP 复现:取消后服务器仍收到正文", verification: "read" }] }
|
|
112
|
+
dream_bridge { mode: "preview", path: "AGENTS.md", maxLessons: 10 }
|
|
113
|
+
dream_context { query: "SMTP 取消投递", projectId: "mailer", packageName: "nodemailer", packageVersion: "9.0.5", platform: "windows" }
|
|
114
|
+
dream_learn { kind: "pitfall", title: "池化发送中 close() 不保证终止投递", action: "取消后验证当前连接确实关闭", when: "使用 Nodemailer 9.0.5 池化发送并处理 AbortSignal 时", evidence: [{ kind: "local-artifact", artifactPath: "test-results/smtp.txt", summary: "本机 SMTP 复现:取消后服务器仍收到正文", verification: "read" }] }
|
|
96
115
|
dream_review { action: "accept", lessonId: "lesson-…", expectedRevision: 1 }
|
|
97
116
|
```
|
|
98
117
|
|
|
99
|
-
##
|
|
118
|
+
## 渡梦:让梦变成长期记忆(M2)
|
|
119
|
+
|
|
120
|
+
`dream_bridge` 现在有显式三模式:
|
|
121
|
+
|
|
122
|
+
- `preview`(只读):返回真实 diff、参与经验与 skipped 原因,零写入;
|
|
123
|
+
- `apply`:必须带预览的 `expectedSha256`(新文件为 null),建议同时带 `previewId`,文件被并发修改时返回 `conflict` 且零写入;只替换 Dream 管理块(`<!-- dsh-dream:start/end -->`),保留块外文字、BOM 与换行风格,先持久化 pending 恢复记录再原子替换文件,最后记录 applied;
|
|
124
|
+
- `rollback`:用 backupId 定位记录,只在当前管理块仍等于该次 apply 结果时回滚,保留块外后来追加的人工内容。
|
|
100
125
|
|
|
101
|
-
`
|
|
126
|
+
缺省不传 `mode` 保持 0.5.x 直写并返回弃用提示;建议新流程一律显式 `preview → apply`。只有 `usable`、scope 匹配当前项目(或显式 global 且 review.decision 为 accepted)的经验可桥接,频次不再准入;写入内容统一过 `mask.ts`。面板的「写入记录」展示备份与可否回滚,0.7.0 起提供确认回滚按钮。
|
|
102
127
|
|
|
103
128
|
## 做梦协议(随包技能)
|
|
104
129
|
|
|
@@ -108,8 +133,8 @@ dream_review { action: "accept", lessonId: "lesson-…", expectedRevision: 1 }
|
|
|
108
133
|
|
|
109
134
|
梦境日记是主观感悟;真正要复用的技术经验走 `<journalDir>/knowledge/`:
|
|
110
135
|
|
|
111
|
-
- **候选 →
|
|
112
|
-
- **取回有预算**:`dream_context` 默认最多返回 5 条、3000 字符(硬上限 20 条 / 20000 字符);按排名整条装入,遇到第一条放不下就停止(`skipped: budget-stop`),`title / when / action / exceptions` 永不截断,绝不返回半条。候选与无独立证据的非 usable 条目默认不注入(`includeCandidates: false`,记 `candidate-hold` / `no-evidence`);显式 `includeCandidates: true`
|
|
136
|
+
- **候选 → 来源核验 → 审阅**:dream_learn 创建 candidate。会话来源需要 sessionId、recordSeq 与可匹配的 quote(省略时用 summary 匹配);插件核对项目、角色、记录和文本并计算 sourceHash。user-correction 必须来自真实用户消息;local-artifact 需要 artifactPath,真实路径必须位于调用工作目录内。核验失败记 claimed 与 verificationReason,不计独立支持数。读到来源不等于用户采纳,工具审阅记录 actor:model。补充证据不会自动改变状态;所有审阅携带 expectedRevision,旧版本会拒绝。
|
|
137
|
+
- **取回有预算**:`dream_context` 默认最多返回 5 条、3000 字符(硬上限 20 条 / 20000 字符);按排名整条装入,遇到第一条放不下就停止(`skipped: budget-stop`),`title / when / action / exceptions` 永不截断,绝不返回半条。候选与无独立证据的非 usable 条目默认不注入(`includeCandidates: false`,记 `candidate-hold` / `no-evidence`);显式 `includeCandidates: true` 可在审阅候选时看到,且候选排在可用经验之后——未经审阅不得当作已证实结论。已驳回、已过期和冲突未解决的不注入;platform 可显式指定,未指定时从明确任务文字识别,否则采用宿主平台,平台不符记 platform-mismatch;`applicability.versions` 只在包名被识别(显式 `packageName` 或 query 中出现包名)时参与判定。
|
|
113
138
|
- **频率不是可靠性**:同一条证据重复提交是幂等的;不要在同一个会话里反复 `dream_save` / `dream_learn` 刷次数。同一个会话中重复出现的教训只算一次独立来源。
|
|
114
139
|
- **存储可恢复**:`events.jsonl` 是权威事件日志(追加写),`evidence.jsonl` 追加证据,`index.json` 是可丢弃重建的派生索引;重建索引不删除任何原文件。目录不存在时读取接口返回空结果,不会为了读而创建目录。
|
|
115
140
|
- **删除新数据**:直接删除 `<journalDir>/knowledge/` 即清空经验记忆;这不会影响 `dreams.jsonl` 里的旧日记,旧版本插件也仍能读取旧日记。
|
package/lib/bridge.d.ts
CHANGED
|
@@ -1,15 +1,218 @@
|
|
|
1
|
+
import type { Lesson } from './knowledge.js';
|
|
2
|
+
/** 新管理块起始标记(整行)。 */
|
|
3
|
+
export declare const DREAM_BLOCK_START = "<!-- dsh-dream:start -->";
|
|
4
|
+
/** 新管理块结束标记(整行)。 */
|
|
5
|
+
export declare const DREAM_BLOCK_END = "<!-- dsh-dream:end -->";
|
|
6
|
+
/** 默认最多桥接条数。 */
|
|
7
|
+
export declare const BRIDGE_DEFAULT_MAX_LESSONS = 5;
|
|
8
|
+
/** 硬上限。 */
|
|
9
|
+
export declare const BRIDGE_HARD_MAX_LESSONS = 20;
|
|
10
|
+
export interface BridgeScope {
|
|
11
|
+
projectId?: string;
|
|
12
|
+
workspaceRoot?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface BridgeLessonView {
|
|
15
|
+
lessonId: string;
|
|
16
|
+
revision: number;
|
|
17
|
+
title: string;
|
|
18
|
+
when: string;
|
|
19
|
+
action: string;
|
|
20
|
+
exceptions: string[];
|
|
21
|
+
scopeLabel: string;
|
|
22
|
+
}
|
|
23
|
+
export interface BridgeSkipped {
|
|
24
|
+
lessonId: string;
|
|
25
|
+
reason: string;
|
|
26
|
+
}
|
|
27
|
+
export interface BridgeFileState {
|
|
28
|
+
exists: boolean;
|
|
29
|
+
/** 文件不存在时为 null;存在时是文件字节 sha256。 */
|
|
30
|
+
sha256: string | null;
|
|
31
|
+
size: number;
|
|
32
|
+
}
|
|
33
|
+
export type BridgeAction = 'create' | 'replace' | 'append' | 'unchanged';
|
|
34
|
+
export interface BridgeTargetOptions {
|
|
35
|
+
/** 当前项目根目录(必须存在)。 */
|
|
36
|
+
projectRoot: string;
|
|
37
|
+
/** 目标文件;缺省 = <projectRoot>/AGENTS.md。 */
|
|
38
|
+
path?: string;
|
|
39
|
+
}
|
|
40
|
+
export interface BridgeOptions extends BridgeTargetOptions {
|
|
41
|
+
/** 应用记录目录 <journalDir>/bridge/。 */
|
|
42
|
+
journalDir: string;
|
|
43
|
+
/** 候选经验(由 tools 层从 KnowledgeStore 提供)。 */
|
|
44
|
+
lessons: Lesson[];
|
|
45
|
+
/** 当前项目标识;两者都没有时只允许显式 global 且已采纳的经验。 */
|
|
46
|
+
projectId?: string;
|
|
47
|
+
workspaceRoot?: string;
|
|
48
|
+
/** 只桥接这些经验(可选)。 */
|
|
49
|
+
lessonIds?: string[];
|
|
50
|
+
/** 条数上限,默认 5,硬上限 20。 */
|
|
51
|
+
maxLessons?: number;
|
|
52
|
+
/** 写盘前是否过 mask.ts;默认 true。 */
|
|
53
|
+
maskSecrets?: boolean;
|
|
54
|
+
}
|
|
55
|
+
export interface BridgeApplyOptions extends BridgeOptions {
|
|
56
|
+
/** apply 必须提供:当前目标文件的 sha256;文件不存在时用 null(preview.expected.sha256 原样回传即可)。 */
|
|
57
|
+
expectedSha256: string | null;
|
|
58
|
+
/** 可选:apply 必须是同一份预览。 */
|
|
59
|
+
previewId?: string;
|
|
60
|
+
}
|
|
61
|
+
export interface BridgeRollbackOptions {
|
|
62
|
+
projectRoot: string;
|
|
63
|
+
path?: string;
|
|
64
|
+
journalDir: string;
|
|
65
|
+
backupId: string;
|
|
66
|
+
}
|
|
67
|
+
export type BridgeErrorCode = 'invalid' | 'conflict' | 'read-only' | 'io' | 'marker' | 'preview-mismatch' | 'not-found' | 'unsupported-encoding' | 'path-outside-project' | 'target-is-directory' | 'not-rollbackable';
|
|
68
|
+
export interface BridgeError {
|
|
69
|
+
code: BridgeErrorCode;
|
|
70
|
+
message: string;
|
|
71
|
+
line?: number;
|
|
72
|
+
hint?: string;
|
|
73
|
+
}
|
|
74
|
+
export interface BridgeFailure {
|
|
75
|
+
ok: false;
|
|
76
|
+
error: BridgeError;
|
|
77
|
+
/** 可选的形状兜底:preview 即使失败也尽量给出 action/expected/resolvedPath,避免调用方读字段崩。 */
|
|
78
|
+
action?: BridgeAction;
|
|
79
|
+
expected?: BridgeFileState;
|
|
80
|
+
resolvedPath?: string;
|
|
81
|
+
}
|
|
82
|
+
export interface BridgePreviewSuccess {
|
|
83
|
+
ok: true;
|
|
84
|
+
action: BridgeAction;
|
|
85
|
+
expected: BridgeFileState;
|
|
86
|
+
resolvedPath: string;
|
|
87
|
+
diff: string;
|
|
88
|
+
lessons: BridgeLessonView[];
|
|
89
|
+
skipped: BridgeSkipped[];
|
|
90
|
+
previewId: string;
|
|
91
|
+
blockPreview: string;
|
|
92
|
+
}
|
|
93
|
+
export interface BridgeApplySuccess {
|
|
94
|
+
ok: true;
|
|
95
|
+
action: BridgeAction;
|
|
96
|
+
unchanged: boolean;
|
|
97
|
+
backupId?: string;
|
|
98
|
+
file: BridgeFileState;
|
|
99
|
+
path: string;
|
|
100
|
+
resolvedPath: string;
|
|
101
|
+
lessons: BridgeLessonView[];
|
|
102
|
+
skipped: BridgeSkipped[];
|
|
103
|
+
previewId?: string;
|
|
104
|
+
/** 目标已应用且可按 backupId 恢复,但最终审计确认未能追加。 */
|
|
105
|
+
warning?: string;
|
|
106
|
+
}
|
|
107
|
+
export interface BridgeRollbackSuccess {
|
|
108
|
+
ok: true;
|
|
109
|
+
backupId: string;
|
|
110
|
+
file: BridgeFileState;
|
|
111
|
+
path: string;
|
|
112
|
+
resolvedPath: string;
|
|
113
|
+
}
|
|
114
|
+
export type BridgePreviewResult = BridgePreviewSuccess | BridgeFailure;
|
|
115
|
+
export type BridgeApplyResult = BridgeApplySuccess | BridgeFailure;
|
|
116
|
+
export type BridgeRollbackResult = BridgeRollbackSuccess | BridgeFailure;
|
|
117
|
+
export interface BridgeRecord {
|
|
118
|
+
schemaVersion: 1;
|
|
119
|
+
backupId: string;
|
|
120
|
+
at: string;
|
|
121
|
+
target: string;
|
|
122
|
+
projectRoot: string;
|
|
123
|
+
action: 'create' | 'replace' | 'append';
|
|
124
|
+
before: BridgeFileState;
|
|
125
|
+
beforeBlock: string | null;
|
|
126
|
+
separator: string;
|
|
127
|
+
afterBlockSha256: string;
|
|
128
|
+
afterFileSha256: string;
|
|
129
|
+
lessons: Array<{
|
|
130
|
+
lessonId: string;
|
|
131
|
+
revision: number;
|
|
132
|
+
}>;
|
|
133
|
+
previewId: string;
|
|
134
|
+
/** 缺省为旧版已完成记录;pending 是先于目标写入持久化的恢复记录。 */
|
|
135
|
+
phase?: 'pending' | 'applied' | 'aborted';
|
|
136
|
+
}
|
|
137
|
+
interface ResolvedTarget {
|
|
138
|
+
/** 跟随链接后的真实写入路径。 */
|
|
139
|
+
path: string;
|
|
140
|
+
projectRoot: string;
|
|
141
|
+
lexical: string;
|
|
142
|
+
}
|
|
143
|
+
type BlockLocation = {
|
|
144
|
+
status: 'none';
|
|
145
|
+
} | {
|
|
146
|
+
status: 'ok';
|
|
147
|
+
start: number;
|
|
148
|
+
end: number;
|
|
149
|
+
text: string;
|
|
150
|
+
startLine: number;
|
|
151
|
+
endLine: number;
|
|
152
|
+
} | {
|
|
153
|
+
status: 'broken';
|
|
154
|
+
message: string;
|
|
155
|
+
line?: number;
|
|
156
|
+
};
|
|
157
|
+
/**
|
|
158
|
+
* 经验资格:state=usable;scope 匹配当前项目;或显式 global 且 review.decision=accepted。
|
|
159
|
+
* 解释为空或不满足一律进 skipped,绝不因频次入选或落选。
|
|
160
|
+
*/
|
|
161
|
+
export declare function selectBridgeLessons(lessons: Lesson[], scope: BridgeScope, options?: {
|
|
162
|
+
lessonIds?: string[];
|
|
163
|
+
maxLessons?: number;
|
|
164
|
+
}): {
|
|
165
|
+
eligible: Lesson[];
|
|
166
|
+
skipped: BridgeSkipped[];
|
|
167
|
+
};
|
|
168
|
+
/** 定位管理块;缺损/重复/嵌套/错位给出位置。 */
|
|
169
|
+
export declare function locateDreamBlock(text: string): BlockLocation;
|
|
170
|
+
/** 生成管理块(内部使用 \n;落盘前按目标换行风格转换)。 */
|
|
171
|
+
export declare function buildDreamBlock(lessons: BridgeLessonView[]): string;
|
|
172
|
+
export declare function resolveBridgeTarget(projectRoot: string, rawPath?: string): {
|
|
173
|
+
ok: true;
|
|
174
|
+
target: ResolvedTarget;
|
|
175
|
+
} | BridgeFailure;
|
|
176
|
+
/** preview:只读计算 diff / expected / 管理块;绝不写盘。 */
|
|
177
|
+
export declare function previewBridge(options: BridgeOptions): BridgePreviewResult;
|
|
178
|
+
/** apply:必须带 expectedSha256;CAS 冲突 → conflict 零写入;只替换管理块。 */
|
|
179
|
+
export declare function applyBridge(options: BridgeApplyOptions): BridgeApplyResult;
|
|
180
|
+
/** rollback:仅当当前管理块仍等于该次 apply 的结果时恢复原管理块。 */
|
|
181
|
+
export declare function rollbackBridge(options: BridgeRollbackOptions): BridgeRollbackResult;
|
|
182
|
+
export interface BridgeApplicationView {
|
|
183
|
+
backupId: string;
|
|
184
|
+
at: string;
|
|
185
|
+
target: string;
|
|
186
|
+
action: 'create' | 'replace' | 'append';
|
|
187
|
+
lessons: Array<{
|
|
188
|
+
lessonId: string;
|
|
189
|
+
revision: number;
|
|
190
|
+
}>;
|
|
191
|
+
beforeSha256: string | null;
|
|
192
|
+
afterSha256: string;
|
|
193
|
+
rollbackable: boolean;
|
|
194
|
+
rollbackReason?: string;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* 只读列出应用记录(按 at 降序)。目录/文件缺失返回 [],绝不写盘。
|
|
198
|
+
* rollbackable 在桥接层按当前文件的管理块重算,供面板直接展示。
|
|
199
|
+
*/
|
|
200
|
+
export declare function listBridgeApplications(journalDir: string): BridgeApplicationView[];
|
|
201
|
+
/** 旧版标记块起始行(历史文件用;新流程不碰它)。 */
|
|
1
202
|
export declare const BRIDGE_START = "<!-- dsh-dream:lessons:start\uFF08\u81EA\u52A8\u751F\u6210\uFF0C\u8BF7\u52FF\u624B\u5DE5\u7F16\u8F91\u5757\u5185\u5185\u5BB9\uFF09 -->";
|
|
203
|
+
/** 旧版标记块结束行。 */
|
|
2
204
|
export declare const BRIDGE_END = "<!-- dsh-dream:lessons:end -->";
|
|
3
|
-
/**
|
|
205
|
+
/** 生成教训块文本(legacy)。 */
|
|
4
206
|
export declare function buildLessonsBlock(lessons: Array<{
|
|
5
207
|
lesson: string;
|
|
6
208
|
count: number;
|
|
7
209
|
}>): string;
|
|
8
210
|
/**
|
|
9
|
-
*
|
|
211
|
+
* legacy:把梦境教训合并进目标文件(0.5.x 行为,直接写;新代码请用 preview/apply)。
|
|
10
212
|
* @returns 动作类型与写入的教训数。
|
|
11
213
|
*/
|
|
12
214
|
export declare function bridgeDreams(journalDir: string, targetPath: string, maxLessons: number): {
|
|
13
215
|
action: 'created' | 'replaced' | 'appended';
|
|
14
216
|
lessonsCount: number;
|
|
15
217
|
};
|
|
218
|
+
export {};
|