dsh-continual-evolve 0.15.3 → 0.15.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -9
- package/README.zh.md +13 -9
- package/client/client.js +181 -16
- package/lib/card-routes.d.ts +2 -0
- package/lib/card-routes.js +66 -1
- package/lib/extraction.d.ts +5 -2
- package/lib/extraction.js +84 -7
- package/lib/index.d.ts +4 -2
- package/lib/index.js +7 -2
- package/lib/memory-snapshot.d.ts +52 -0
- package/lib/memory-snapshot.js +100 -4
- package/lib/skill-rules.d.ts +73 -0
- package/lib/skill-rules.js +158 -0
- package/lib/skill-tools.d.ts +9 -0
- package/lib/skill-tools.js +198 -0
- package/lib/store.d.ts +73 -5
- package/lib/store.js +504 -6
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,9 +7,9 @@ English | [中文](README.zh.md)
|
|
|
7
7
|
[](https://github.com/ZK-Andy/dsh-continual-evolve/actions/workflows/ci.yml)
|
|
8
8
|
[](LICENSE)
|
|
9
9
|
[](package.json)
|
|
10
|
-
[]()
|
|
11
|
+
[]()
|
|
12
|
+
[]()
|
|
13
13
|
[]()
|
|
14
14
|
|
|
15
15
|
A workspace-memory plugin for the [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) (`dsh`): every memory lives in one central SQLite database (`~/.dsh/evolve/memory.db`, rows partitioned by workspace), the index is injected at session start, and the plugin's code is the literal **sole writer** — the model proposes, code gates and lands.
|
|
@@ -21,10 +21,10 @@ Reusable experience gathered in one session (user preferences, pitfalls, project
|
|
|
21
21
|
## How it works
|
|
22
22
|
|
|
23
23
|
1. **Session-start injection** — the plugin registers a single system-prompt section: the workspace's memory index as a store query (hooks only, whole-line truncated over budget, ordered feedback > user > reference), the central-library path, and a three-line guide. The section is computed once per session and reused byte-for-byte, keeping the system prompt stable and the prompt cache warm; an empty store costs zero tokens.
|
|
24
|
-
2. **
|
|
24
|
+
2. **Four tools, one writer** — `memory_write` (create/update/delete) is the explicit path for "remember …" / "forget …": every proposal passes the code gates (id shape, type enum, the feedback Why/How contract, secret screening carried over from v1, 64KB body cap) inside one transaction. `memory_read` fetches bodies by id and searches by keyword — whitespace-separated terms are AND-combined, with literal substring matching for short terms and whenever the trigram index misses; the injected index carries hooks only. `skill_write` (create/update/delete in the project, plus an explicit move-to-global) sediments reusable procedures through the same discipline (kebab ids, secret screening, 64KB cap, no duplicate ids or bodies across scopes); every applied skill is materialized by the plugin as `<workspace>/.agents/skills/<id>/SKILL.md` — the database is the source of truth, the files are a read-only projection patrol restores on drift. `skill_read` fetches skill bodies by id and searches project plus global skills (the project shadows a same-named global). On hosts without the tools service the plugin degrades to "tell the user" phrasing and stays functional.
|
|
25
25
|
3. **Proposal-based extraction** — the only background automation, audited in the `extraction_log`: every `agent/turn-stopping` schedules that session's boundary, with state kept **per session** (a run in flight keeps only its newest boundary — coalescing, not queueing; `compaction/start` and session close drain it) and **no idle timer**. A run reads the session increment since its cursor, feeds FTS-similar existing memories to one LLM call, and the model's structured proposal lands through the same gates; failures and rejections never advance the cursor. Internal agents, empty increments, turns without real user prose, and turns that already carried an explicit `memory_write` are mechanically skipped — and every skip is ledgered, consecutive quiet turns of one session as a single row carrying how many wake-ups it stands for.
|
|
26
|
-
4. **Rollback is a ledger, not a mechanism** — every mutation lands an `extraction_log` row with full before/after snapshots; undo means rewriting the `before` values. A hygiene pass rides on every applied run: orphan FTS rows are dropped and secret-bearing rows are quarantined (hidden, never deleted). The read-only card surfaces quarantine anomalies.
|
|
27
|
-
5. **Read-only card** — mounted on the plugin's page in the official plugin manager (the `plugins.bundle.config` slot; hosts without it silently degrade to no card), shaped like the market's own settings card and aligned with ZCode's Settings → Memory viewer: a dropdown scope selector over the store's workspace partitions (opening on the host's current workspace), a search box, per-entry relative updated times, click-to-preview bodies (5 MiB cap), and
|
|
26
|
+
4. **Rollback is a ledger, not a mechanism** — every mutation lands an `extraction_log` row with full before/after snapshots; undo means rewriting the `before` values. Skill mutations land the same way in `skill_log`. A hygiene pass rides on every applied run: orphan FTS rows are dropped and secret-bearing rows are quarantined (hidden, never deleted; a quarantined skill's materialized file is removed so it stops loading). The read-only card surfaces quarantine anomalies.
|
|
27
|
+
5. **Read-only card** — mounted on the plugin's page in the official plugin manager (the `plugins.bundle.config` slot; hosts without it silently degrade to no card), shaped like the market's own settings card and aligned with ZCode's Settings → Memory viewer: a dropdown scope selector over the store's workspace partitions (opening on the host's current workspace), a search box, per-entry relative updated times, click-to-preview bodies (5 MiB cap), patrol warnings, and a skills section listing the workspace's project skills plus visible global skills (global rows badged, project shadowing global) with the same preview. Localized through the host's `locale/*.json` metadata channel; host theme tokens, the `Button` primitive, and zh/en copy that tracks the DSH language. The card is a request-time projection of the database and has no edit path.
|
|
28
28
|
|
|
29
29
|
Memory types follow the ZCode taxonomy: `user` (profile and environment facts), `feedback` (corrected or confirmed practices — bodies must carry **Why:** and **How to apply:** lines), `reference` (resource pointers). The extraction boundary is person- and environment-scoped knowledge only: decisions and trade-offs are repo-scoped by nature and belong to the repo's ADR route, never to memory.
|
|
30
30
|
|
|
@@ -44,7 +44,7 @@ After installing or updating, restart the DSH profile you actually use (`dsh web
|
|
|
44
44
|
|
|
45
45
|
## Usage
|
|
46
46
|
|
|
47
|
-
No commands. On the first session after restart the index is injected automatically. Just tell the model "remember …" / "forget …" — it lands through `memory_write` and the gates. Memories written mid-session become visible in the next session (the section is frozen to protect the prompt cache). To see the whole store, open the plugin's page in the official plugin manager: the read-only card shows each workspace's entries, search, and patrol anomalies. The store requires Node ≥ 22.5 (`node:sqlite`, part of the desktop host's EnsureNode runtime); without it the plugin degrades to a no-op with a console warning.
|
|
47
|
+
No commands. On the first session after restart the index is injected automatically. Just tell the model "remember …" / "forget …" — it lands through `memory_write` and the gates. To sediment a reusable procedure, tell the model to save it as a skill — it lands through `skill_write` in the current project and materializes as a `SKILL.md` the `skill` tool discovers after restart; say "use it everywhere" and the model moves it to the global scope (the project copy archives). Memories and skills written mid-session become visible in the next session (the section is frozen to protect the prompt cache). To see the whole store, open the plugin's page in the official plugin manager: the read-only card shows each workspace's entries and skills, search, and patrol anomalies. The store requires Node ≥ 22.5 (`node:sqlite`, part of the desktop host's EnsureNode runtime); without it the plugin degrades to a no-op with a console warning.
|
|
48
48
|
|
|
49
49
|
## Configuration
|
|
50
50
|
|
|
@@ -71,7 +71,7 @@ Profile patch example:
|
|
|
71
71
|
|
|
72
72
|
```bash
|
|
73
73
|
pnpm install && pnpm build # deps + clean build -> lib/
|
|
74
|
-
pnpm test # vitest (
|
|
74
|
+
pnpm test # vitest (258 tests)
|
|
75
75
|
pnpm test:coverage # v8 coverage, CI-enforced thresholds
|
|
76
76
|
pnpm lint # oxlint src test client
|
|
77
77
|
pnpm check:pack # published-artifact consistency (also runs on prepack)
|
|
@@ -88,6 +88,8 @@ Layout:
|
|
|
88
88
|
│ ├── memory-section.ts # injection: store query / truncate / session freeze
|
|
89
89
|
│ ├── memory-guide.ts # the main-session guide (three lines)
|
|
90
90
|
│ ├── memory-tools.ts # memory_write + memory_read (host-shaped definitions)
|
|
91
|
+
│ ├── skill-rules.ts # skill gates: field checks, SKILL.md rendering, managed paths
|
|
92
|
+
│ ├── skill-tools.ts # skill_write + skill_read (project shadowing global)
|
|
91
93
|
│ ├── extraction.ts # runner + per-session scheduler (turn-level, no idle timer)
|
|
92
94
|
│ ├── extraction-surface.ts # trajectory slicing: cursor, eligibility, serialization
|
|
93
95
|
│ ├── extraction-prompt.ts # the extraction prompt + answer parsing
|
|
@@ -98,7 +100,7 @@ Layout:
|
|
|
98
100
|
├── client/
|
|
99
101
|
│ └── client.js # hand-written client bundle: read-only card in the plugin manager
|
|
100
102
|
├── locale/ # host package metadata: localized display name + description (zh/en)
|
|
101
|
-
├── test/ # vitest suite (
|
|
103
|
+
├── test/ # vitest suite (20 files)
|
|
102
104
|
├── lib/ # build output (tsc)
|
|
103
105
|
├── docs/ # design.md (design) · FAQ.md (real-world pitfalls)
|
|
104
106
|
└── .agents/ # AI collaboration layer (AGENTS.md, skills, ADR notes)
|
|
@@ -111,3 +113,5 @@ Layout:
|
|
|
111
113
|
## License
|
|
112
114
|
|
|
113
115
|
MIT. Independent project — not affiliated with DeepSeek.
|
|
116
|
+
|
|
117
|
+
[](https://github.com/deepseek-ai/deepseek-harness)
|
package/README.zh.md
CHANGED
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
[](https://github.com/ZK-Andy/dsh-continual-evolve/actions/workflows/ci.yml)
|
|
8
8
|
[](LICENSE)
|
|
9
9
|
[](package.json)
|
|
10
|
-
[]()
|
|
11
|
+
[]()
|
|
12
|
+
[]()
|
|
13
13
|
[]()
|
|
14
14
|
|
|
15
15
|
[DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness)(`dsh`)的工作区记忆插件:全部记忆住在一个中央 SQLite 库里(`~/.dsh/evolve/memory.db`,按工作区路径行分区),会话开局注入索引,插件的代码是字面意义的**唯一写者**——模型提议,代码门禁后落盘。
|
|
@@ -21,10 +21,10 @@ Agent 每个会话积累的可复用经验(用户偏好、踩坑教训、项
|
|
|
21
21
|
## 工作原理
|
|
22
22
|
|
|
23
23
|
1. **开局注入** —— 插件只注册一个 system-prompt section:注入本工作区的记忆索引(查库结果,只含钩子,超预算按整行截断,feedback > user > reference 排序)、中央库路径、三行指南。该 section 每会话只算一次并逐字节复用,system prompt 稳定、prompt cache 持续命中;空 store 零 token。
|
|
24
|
-
2.
|
|
24
|
+
2. **四个工具,一个写者** —— `memory_write`(create/update/delete)承接显式的记住/忘掉:每条提案过代码门禁(id 规范、type 枚举、feedback 的 Why/How 契约、v1 移植的 secret 筛查、64KB 正文上限)后在一个事务内落盘。`memory_read` 按 id 取正文、按关键词检索——空格分隔的关键词取 AND,短词与 trigram 未命中时回退字面子串匹配;注入索引只有钩子。`skill_write`(项目内 create/update/delete + 显式搬到全局)沉淀可复用的操作规程,走同一套纪律(短横线 id、secret 筛查、64KB 上限、跨范围禁重名重文);每条落地的技能由插件代码物化为 `<workspace>/.agents/skills/<id>/SKILL.md`——库是唯一真相,文件是只读投影,漂移由巡检按库还原。`skill_read` 按 id 取技能正文、检索项目与全局技能(同名时项目遮蔽全局)。宿主没有工具服务时降级为告诉用户措辞,注入不受影响。
|
|
25
25
|
3. **提案制提取** —— 插件唯一的后台自动化,全程 `extraction_log` 可对账:每个 `agent/turn-stopping` 调度**该会话自己**的边界,状态按会话隔离(运行中只保留最新边界——合并而非排队;`compaction/start` 与会话收尾触发 drain),**没有空闲计时器**。一次运行读取该会话游标之后的轨迹增量,用 FTS 取相似既有记忆喂给一次 LLM 调用,模型的结构化提案过同一套门禁落盘;失败与被拒不推游标,下次触发重试。内部 agent、空增量、无真实用户文本的轮次、当轮已有显式 `memory_write` 的轮次机械跳过——每次跳过都记账,同一会话连续的空转轮次合成一行并累计唤醒次数。
|
|
26
|
-
4. **回滚靠账本,不靠机制** —— 每次变更落一条带 before/after 全文快照的 `extraction_log` 行;undo 就是取 before
|
|
27
|
-
5. **只读卡片** —— 挂在官方插件管理的本 bundle 页面(`plugins.bundle.config` slot,老宿主自动降级为无卡片):形态对齐市场自家设置卡,内容对齐 ZCode 设置的记忆选项卡——下拉作用域选择器列出库里的工作区分区(默认选中宿主当前工作区)、搜索框、每条记忆的相对更新时间、点击行内展开正文预览(5 MiB
|
|
26
|
+
4. **回滚靠账本,不靠机制** —— 每次变更落一条带 before/after 全文快照的 `extraction_log` 行;undo 就是取 before 重写。技能变更同样落 `skill_log`。每次应用后随跑一次巡检:孤儿 FTS 行清除、含密钥条目隔离(隐藏,不物理删除;被隔离技能的物化文件一并撤下,使其不再被加载)。只读卡片显形巡检异常。
|
|
27
|
+
5. **只读卡片** —— 挂在官方插件管理的本 bundle 页面(`plugins.bundle.config` slot,老宿主自动降级为无卡片):形态对齐市场自家设置卡,内容对齐 ZCode 设置的记忆选项卡——下拉作用域选择器列出库里的工作区分区(默认选中宿主当前工作区)、搜索框、每条记忆的相对更新时间、点击行内展开正文预览(5 MiB 上限)、巡检异常警告,以及技能区(本工作区技能 + 可见的全局技能,全局行打标记,同名时项目遮蔽全局),预览同记忆。显示名与描述走宿主 `locale/*.json` 通道双语;宿主主题 token、`Button` 原语、中英文案跟随 DSH 语言。卡片是数据库的请求时投影,没有编辑路径。
|
|
28
28
|
|
|
29
29
|
记忆类型沿 ZCode 分类法:`user`(画像与环境事实)、`feedback`(被纠正/确认的做法——正文必带 **Why:** 与 **How to apply:**)、`reference`(资源指针)。提取边界只收"跟人与环境走的知识":决策与取舍天然属于仓库,走仓库的 ADR 路线,不进记忆库。
|
|
30
30
|
|
|
@@ -44,7 +44,7 @@ dsh plugin add ZK-Andy/dsh-continual-evolve
|
|
|
44
44
|
|
|
45
45
|
## 使用
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
无需命令。重启后第一场会话索引自动注入开场;对模型直接说记住/忘掉,经 `memory_write` 过门禁落盘。想沉淀可复用的操作规程,直接让模型记为技能——经 `skill_write` 落本项目并物化为 `SKILL.md`,重启后 `skill` 工具可发现;说到处都要用则由模型手动搬到全局(项目侧归档)。会话中途写入的记忆下个会话生效(会话内冻结守 prompt cache)。想看记忆库全貌,打开官方插件管理里本插件的页面:只读卡片展示各工作区的记忆条目、搜索与巡检异常。中央库需要 Node ≥ 22.5(`node:sqlite`,桌面宿主的 EnsureNode 运行时自带);运行时过旧时插件整体降级为无操作并打控制台告警。
|
|
48
48
|
|
|
49
49
|
## 配置
|
|
50
50
|
|
|
@@ -71,7 +71,7 @@ profile patch 示例:
|
|
|
71
71
|
|
|
72
72
|
```bash
|
|
73
73
|
pnpm install && pnpm build # 依赖 + 干净构建 -> lib/
|
|
74
|
-
pnpm test # vitest(
|
|
74
|
+
pnpm test # vitest(258 例)
|
|
75
75
|
pnpm test:coverage # v8 覆盖率,CI 强制阈值
|
|
76
76
|
pnpm lint # oxlint src test client
|
|
77
77
|
pnpm check:pack # 发布产物一致性(prepack 也会跑)
|
|
@@ -88,6 +88,8 @@ pnpm check:pack # 发布产物一致性(prepack 也会跑)
|
|
|
88
88
|
│ ├── memory-section.ts # 注入:查库 / 截断 / 会话冻结
|
|
89
89
|
│ ├── memory-guide.ts # 主会话指南(三行)
|
|
90
90
|
│ ├── memory-tools.ts # memory_write + memory_read(宿主形状定义)
|
|
91
|
+
│ ├── skill-rules.ts # 技能门禁:字段校验、SKILL.md 渲染、受管路径
|
|
92
|
+
│ ├── skill-tools.ts # skill_write + skill_read(项目遮蔽全局)
|
|
91
93
|
│ ├── extraction.ts # 运行器 + 按会话分槽的调度器(轮级、无空闲计时器)
|
|
92
94
|
│ ├── extraction-surface.ts # 轨迹切片:游标、资格判定、序列化
|
|
93
95
|
│ ├── extraction-prompt.ts # 提取 prompt + 应答解析
|
|
@@ -98,7 +100,7 @@ pnpm check:pack # 发布产物一致性(prepack 也会跑)
|
|
|
98
100
|
├── client/
|
|
99
101
|
│ └── client.js # 手写 client bundle:官方插件管理内只读卡片
|
|
100
102
|
├── locale/ # 宿主包元数据:显示名 + 描述双语(zh/en)
|
|
101
|
-
├── test/ # vitest 测试(
|
|
103
|
+
├── test/ # vitest 测试(20 个文件)
|
|
102
104
|
├── lib/ # 构建产物(tsc)
|
|
103
105
|
├── docs/ # design.md(设计)· FAQ.md(踩坑)
|
|
104
106
|
└── .agents/ # AI 协作层(AGENTS.md、技能、ADR 笔记)
|
|
@@ -111,3 +113,5 @@ pnpm check:pack # 发布产物一致性(prepack 也会跑)
|
|
|
111
113
|
## License
|
|
112
114
|
|
|
113
115
|
MIT。独立项目——与 DeepSeek 无关联。
|
|
116
|
+
|
|
117
|
+
[](https://github.com/deepseek-ai/deepseek-harness)
|
package/client/client.js
CHANGED
|
@@ -97,6 +97,11 @@ window.__ModuleLoader__.load({
|
|
|
97
97
|
readFailed: "记忆库读取失败:",
|
|
98
98
|
stats: "{files} 条记忆",
|
|
99
99
|
filesHeading: "文件",
|
|
100
|
+
skillsHeading: "技能",
|
|
101
|
+
skillStats: "{files} 个技能",
|
|
102
|
+
skillsEmpty: "该工作区还没有技能——明确告诉模型沉淀为技能即可,重启后生效。",
|
|
103
|
+
skillScopeGlobal: "全局",
|
|
104
|
+
skillPreviewDeleted: "该技能已被删除或搬家,请刷新列表。",
|
|
100
105
|
scopeLabel: "选择工作区",
|
|
101
106
|
searchPlaceholder: "搜索记忆…",
|
|
102
107
|
searchEmpty: "没有匹配的记忆文件。",
|
|
@@ -124,6 +129,11 @@ window.__ModuleLoader__.load({
|
|
|
124
129
|
readFailed: "Failed to read the memory store: ",
|
|
125
130
|
stats: "{files} memories",
|
|
126
131
|
filesHeading: "Files",
|
|
132
|
+
skillsHeading: "Skills",
|
|
133
|
+
skillStats: "{files} skills",
|
|
134
|
+
skillsEmpty: "No skills in this workspace yet — ask the model to save one as a skill, then restart.",
|
|
135
|
+
skillScopeGlobal: "global",
|
|
136
|
+
skillPreviewDeleted: "This skill was deleted or moved — refresh the list.",
|
|
127
137
|
scopeLabel: "Choose workspace",
|
|
128
138
|
searchPlaceholder: "Search memory files…",
|
|
129
139
|
searchEmpty: "No matching memory files.",
|
|
@@ -205,20 +215,34 @@ window.__ModuleLoader__.load({
|
|
|
205
215
|
typeof workspace.label === "string" && workspace.label.trim().length > 0
|
|
206
216
|
? workspace.label
|
|
207
217
|
: workspaceLabel(root);
|
|
218
|
+
var snapshot = null;
|
|
219
|
+
var snapshotError = null;
|
|
220
|
+
var skillSnapshot = null;
|
|
221
|
+
var skillError = null;
|
|
208
222
|
try {
|
|
209
223
|
var snapshotResponse = await fetchImpl(API_ROOT + "/memory?root=" + encodeURIComponent(root));
|
|
210
224
|
if (!snapshotResponse.ok) {
|
|
211
|
-
|
|
225
|
+
snapshotError = "HTTP " + snapshotResponse.status;
|
|
226
|
+
} else {
|
|
227
|
+
snapshot = await snapshotResponse.json();
|
|
212
228
|
}
|
|
213
|
-
return { root: root, label: label, snapshot: await snapshotResponse.json(), error: null };
|
|
214
229
|
} catch (error) {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
230
|
+
snapshotError = error instanceof Error ? error.message : String(error);
|
|
231
|
+
}
|
|
232
|
+
try {
|
|
233
|
+
var skillResponse = await fetchImpl(API_ROOT + "/skills?root=" + encodeURIComponent(root));
|
|
234
|
+
if (!skillResponse.ok) {
|
|
235
|
+
skillError = "HTTP " + skillResponse.status;
|
|
236
|
+
} else {
|
|
237
|
+
skillSnapshot = await skillResponse.json();
|
|
238
|
+
}
|
|
239
|
+
} catch (error) {
|
|
240
|
+
skillError = error instanceof Error ? error.message : String(error);
|
|
221
241
|
}
|
|
242
|
+
if (snapshotError !== null && skillError !== null) {
|
|
243
|
+
return { root: root, label: label, snapshot: null, error: snapshotError, skillSnapshot: null, skillError: skillError };
|
|
244
|
+
}
|
|
245
|
+
return { root: root, label: label, snapshot: snapshot, error: snapshotError, skillSnapshot: skillSnapshot, skillError: skillError };
|
|
222
246
|
}),
|
|
223
247
|
);
|
|
224
248
|
return {
|
|
@@ -267,6 +291,42 @@ window.__ModuleLoader__.load({
|
|
|
267
291
|
}
|
|
268
292
|
}
|
|
269
293
|
|
|
294
|
+
/**
|
|
295
|
+
* Fetch one skill's body for the preview. Outcomes mirror the
|
|
296
|
+
* endpoint's status mapping, same as memory files.
|
|
297
|
+
*
|
|
298
|
+
* @param {typeof fetch} fetchImpl - injectable for tests.
|
|
299
|
+
* @param {string} root - known workspace root.
|
|
300
|
+
* @param {string} id - the skill id visible in that workspace (project shadowing global).
|
|
301
|
+
* @returns {Promise<{status: "ready"|"deleted"|"tooLarge"|"failed", content: string, message: string}>}
|
|
302
|
+
*/
|
|
303
|
+
async function loadSkillContent(fetchImpl, root, id) {
|
|
304
|
+
var url = API_ROOT + "/skills/file?root=" + encodeURIComponent(root) + "&id=" + encodeURIComponent(id);
|
|
305
|
+
try {
|
|
306
|
+
var response = await fetchImpl(url);
|
|
307
|
+
if (response.ok) {
|
|
308
|
+
var body = await response.json();
|
|
309
|
+
return {
|
|
310
|
+
status: "ready",
|
|
311
|
+
content: typeof body.content === "string" ? body.content : "",
|
|
312
|
+
message: "",
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
if (response.status === 404) {
|
|
316
|
+
return { status: "deleted", content: "", message: "" };
|
|
317
|
+
}
|
|
318
|
+
if (response.status === 413) {
|
|
319
|
+
return { status: "tooLarge", content: "", message: "" };
|
|
320
|
+
}
|
|
321
|
+
return { status: "failed", content: "", message: "HTTP " + response.status };
|
|
322
|
+
} catch (error) {
|
|
323
|
+
return {
|
|
324
|
+
status: "failed",
|
|
325
|
+
content: "",
|
|
326
|
+
message: error instanceof Error ? error.message : String(error),
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
}
|
|
270
330
|
/** Display label for a workspace: its directory name (ZCode shows a project name, not a path). */
|
|
271
331
|
function workspaceLabel(root) {
|
|
272
332
|
var normalized = String(root).replace(/[\\/]+$/, "");
|
|
@@ -376,6 +436,7 @@ window.__ModuleLoader__.load({
|
|
|
376
436
|
var preview = props.preview;
|
|
377
437
|
var onToggle = props.onToggle;
|
|
378
438
|
var UI = props.UI;
|
|
439
|
+
var deletedKey = typeof props.deletedKey === "string" ? props.deletedKey : "previewDeleted";
|
|
379
440
|
var rowChildren = [];
|
|
380
441
|
if (UI !== null && UI !== undefined && UI.FileIcon !== undefined && UI.FileIcon !== null) {
|
|
381
442
|
// ZCode's memory rows open with a category tile; the host classifies
|
|
@@ -389,6 +450,9 @@ window.__ModuleLoader__.load({
|
|
|
389
450
|
);
|
|
390
451
|
}
|
|
391
452
|
rowChildren.push(createElement("span", { key: "name", className: "dce-file-name" }, file.title));
|
|
453
|
+
if (typeof props.badge === "string" && props.badge !== "") {
|
|
454
|
+
rowChildren.push(createElement("span", { key: "badge", className: "dce-file-time" }, props.badge));
|
|
455
|
+
}
|
|
392
456
|
var time = formatRelative(file.updatedAt, now, t);
|
|
393
457
|
if (time !== "") {
|
|
394
458
|
rowChildren.push(createElement("span", { key: "time", className: "dce-file-time" }, time));
|
|
@@ -415,7 +479,7 @@ window.__ModuleLoader__.load({
|
|
|
415
479
|
} else if (preview.status === "ready") {
|
|
416
480
|
body = createElement("pre", { className: "dce-pre" }, preview.content);
|
|
417
481
|
} else if (preview.status === "deleted") {
|
|
418
|
-
body = createElement("div", { className: "dce-hint" }, t(
|
|
482
|
+
body = createElement("div", { className: "dce-hint" }, t(deletedKey));
|
|
419
483
|
} else if (preview.status === "tooLarge") {
|
|
420
484
|
body = createElement("div", { className: "dce-hint" }, t("previewTooLarge"));
|
|
421
485
|
} else {
|
|
@@ -620,6 +684,9 @@ window.__ModuleLoader__.load({
|
|
|
620
684
|
var onRefresh = props.onRefresh;
|
|
621
685
|
var query = props.query;
|
|
622
686
|
var onQueryChange = props.onQueryChange;
|
|
687
|
+
var expandedSkill = props.expandedSkill;
|
|
688
|
+
var skillPreview = props.skillPreview;
|
|
689
|
+
var onToggleSkill = props.onToggleSkill;
|
|
623
690
|
var scope = createElement(WorkspaceScopeMenu, {
|
|
624
691
|
key: "scope",
|
|
625
692
|
workspaces: entry.workspaces.map(function (workspace) {
|
|
@@ -729,7 +796,77 @@ window.__ModuleLoader__.load({
|
|
|
729
796
|
}
|
|
730
797
|
body = parts;
|
|
731
798
|
}
|
|
732
|
-
|
|
799
|
+
var skillsBody = (function () {
|
|
800
|
+
var skillData = active.skillSnapshot;
|
|
801
|
+
if ((skillData === null || skillData === undefined) && active.skillError !== null && active.skillError !== undefined) {
|
|
802
|
+
return createElement("div", { key: "skills", className: "dce-error" }, t("readError") + active.skillError);
|
|
803
|
+
}
|
|
804
|
+
if (skillData === null || skillData === undefined || !skillData.exists) {
|
|
805
|
+
return createElement("div", { key: "skills", className: "dce-hint" }, t("skillsEmpty"));
|
|
806
|
+
}
|
|
807
|
+
var rows = Array.isArray(skillData.files) ? skillData.files : [];
|
|
808
|
+
var skillQuery = String(query).trim().toLocaleLowerCase();
|
|
809
|
+
var skillFiles = rows.filter(function (file) {
|
|
810
|
+
if (skillQuery.length === 0) {
|
|
811
|
+
return true;
|
|
812
|
+
}
|
|
813
|
+
return [file.id, file.title, file.description, file.scope]
|
|
814
|
+
.filter(function (value) {
|
|
815
|
+
return typeof value === "string";
|
|
816
|
+
})
|
|
817
|
+
.some(function (value) {
|
|
818
|
+
return value.toLocaleLowerCase().includes(skillQuery);
|
|
819
|
+
});
|
|
820
|
+
});
|
|
821
|
+
var skillParts = [
|
|
822
|
+
createElement(
|
|
823
|
+
"div",
|
|
824
|
+
{ key: "stats", className: "dce-stats" },
|
|
825
|
+
t("skillStats", { files: skillData.fileCount }),
|
|
826
|
+
),
|
|
827
|
+
];
|
|
828
|
+
if (Array.isArray(skillData.quarantined) && skillData.quarantined.length > 0) {
|
|
829
|
+
skillParts.push(
|
|
830
|
+
createElement("div", { key: "quarantined", className: "dce-warn" }, t("quarantined") + skillData.quarantined.map(function (entry) { return entry.id; }).join("、")),
|
|
831
|
+
);
|
|
832
|
+
}
|
|
833
|
+
skillParts.push(
|
|
834
|
+
createElement(
|
|
835
|
+
"div",
|
|
836
|
+
{ key: "head", className: "dce-files-head" },
|
|
837
|
+
createElement("span", { className: "dce-files-title" }, t("skillsHeading")),
|
|
838
|
+
createElement("span", { className: "dce-files-count" }, String(skillFiles.length)),
|
|
839
|
+
),
|
|
840
|
+
);
|
|
841
|
+
if (skillFiles.length === 0) {
|
|
842
|
+
skillParts.push(createElement("div", { key: "none", className: "dce-empty" }, t("skillsEmpty")));
|
|
843
|
+
} else {
|
|
844
|
+
skillParts.push(
|
|
845
|
+
createElement(
|
|
846
|
+
"ul",
|
|
847
|
+
{ key: "files", className: "dce-list" },
|
|
848
|
+
skillFiles.map(function (file) {
|
|
849
|
+
return createElement(FileRow, {
|
|
850
|
+
key: file.id,
|
|
851
|
+
file: file,
|
|
852
|
+
now: now,
|
|
853
|
+
t: t,
|
|
854
|
+
UI: UI,
|
|
855
|
+
badge: file.scope === "global" ? t("skillScopeGlobal") : "",
|
|
856
|
+
deletedKey: "skillPreviewDeleted",
|
|
857
|
+
expanded: expandedSkill === file.id,
|
|
858
|
+
preview: skillPreview,
|
|
859
|
+
onToggle: function () {
|
|
860
|
+
onToggleSkill(file.id);
|
|
861
|
+
},
|
|
862
|
+
});
|
|
863
|
+
}),
|
|
864
|
+
),
|
|
865
|
+
);
|
|
866
|
+
}
|
|
867
|
+
return createElement("div", { key: "skills", className: "dce-workspace" }, skillParts);
|
|
868
|
+
})();
|
|
869
|
+
return createElement("div", { key: "block", className: "dce-workspace" }, scope, body, skillsBody);
|
|
733
870
|
}
|
|
734
871
|
|
|
735
872
|
/**
|
|
@@ -749,12 +886,15 @@ window.__ModuleLoader__.load({
|
|
|
749
886
|
var setModel = state[1];
|
|
750
887
|
var reloadState = useState(0);
|
|
751
888
|
var reload = reloadState[1];
|
|
752
|
-
var selectionState = useState({ root: null, query: "", expandedFile: null });
|
|
889
|
+
var selectionState = useState({ root: null, query: "", expandedFile: null, expandedSkill: null });
|
|
753
890
|
var selection = selectionState[0];
|
|
754
891
|
var setSelection = selectionState[1];
|
|
755
892
|
var previewState = useState({ file: null, status: "loading", content: "", message: "" });
|
|
756
893
|
var preview = previewState[0];
|
|
757
894
|
var setPreview = previewState[1];
|
|
895
|
+
var skillPreviewState = useState({ file: null, status: "loading", content: "", message: "" });
|
|
896
|
+
var skillPreview = skillPreviewState[0];
|
|
897
|
+
var setSkillPreview = skillPreviewState[1];
|
|
758
898
|
var nowState = useState(Date.now());
|
|
759
899
|
var now = nowState[0];
|
|
760
900
|
var setNow = nowState[1];
|
|
@@ -786,9 +926,10 @@ window.__ModuleLoader__.load({
|
|
|
786
926
|
var refresh = function () {
|
|
787
927
|
setModel({ status: "loading", model: null, message: "" });
|
|
788
928
|
setSelection(function (current) {
|
|
789
|
-
return { root: current.root, query: "", expandedFile: null };
|
|
929
|
+
return { root: current.root, query: "", expandedFile: null, expandedSkill: null };
|
|
790
930
|
});
|
|
791
931
|
setPreview({ file: null, status: "loading", content: "", message: "" });
|
|
932
|
+
setSkillPreview({ file: null, status: "loading", content: "", message: "" });
|
|
792
933
|
reload(function (n) {
|
|
793
934
|
return n + 1;
|
|
794
935
|
});
|
|
@@ -846,8 +987,9 @@ window.__ModuleLoader__.load({
|
|
|
846
987
|
entry: model.model,
|
|
847
988
|
selected: selected,
|
|
848
989
|
onSelect: function (root) {
|
|
849
|
-
setSelection({ root: root, query: "", expandedFile: null });
|
|
990
|
+
setSelection({ root: root, query: "", expandedFile: null, expandedSkill: null });
|
|
850
991
|
setPreview({ file: null, status: "loading", content: "", message: "" });
|
|
992
|
+
setSkillPreview({ file: null, status: "loading", content: "", message: "" });
|
|
851
993
|
},
|
|
852
994
|
onRefresh: refresh,
|
|
853
995
|
t: t,
|
|
@@ -855,15 +997,37 @@ window.__ModuleLoader__.load({
|
|
|
855
997
|
now: now,
|
|
856
998
|
expandedFile: selection.expandedFile,
|
|
857
999
|
preview: preview,
|
|
1000
|
+
expandedSkill: selection.expandedSkill,
|
|
1001
|
+
skillPreview: skillPreview,
|
|
1002
|
+
onToggleSkill: function (file) {
|
|
1003
|
+
if (selection.expandedSkill === file) {
|
|
1004
|
+
setSelection(function (current) {
|
|
1005
|
+
return { root: current.root, query: current.query, expandedFile: current.expandedFile, expandedSkill: null };
|
|
1006
|
+
});
|
|
1007
|
+
return;
|
|
1008
|
+
}
|
|
1009
|
+
setSelection(function (current) {
|
|
1010
|
+
return { root: current.root, query: current.query, expandedFile: current.expandedFile, expandedSkill: file };
|
|
1011
|
+
});
|
|
1012
|
+
setSkillPreview({ file: file, status: "loading", content: "", message: "" });
|
|
1013
|
+
loadSkillContent(fetch, selected, file).then(function (result) {
|
|
1014
|
+
setSkillPreview(function (current) {
|
|
1015
|
+
if (current.file !== file) {
|
|
1016
|
+
return current;
|
|
1017
|
+
}
|
|
1018
|
+
return { file: file, status: result.status, content: result.content, message: result.message };
|
|
1019
|
+
});
|
|
1020
|
+
});
|
|
1021
|
+
},
|
|
858
1022
|
onToggleFile: function (file) {
|
|
859
1023
|
if (selection.expandedFile === file) {
|
|
860
1024
|
setSelection(function (current) {
|
|
861
|
-
return { root: current.root, query: current.query, expandedFile: null };
|
|
1025
|
+
return { root: current.root, query: current.query, expandedFile: null, expandedSkill: current.expandedSkill };
|
|
862
1026
|
});
|
|
863
1027
|
return;
|
|
864
1028
|
}
|
|
865
1029
|
setSelection(function (current) {
|
|
866
|
-
return { root: current.root, query: current.query, expandedFile: file };
|
|
1030
|
+
return { root: current.root, query: current.query, expandedFile: file, expandedSkill: current.expandedSkill };
|
|
867
1031
|
});
|
|
868
1032
|
setPreview({ file: file, status: "loading", content: "", message: "" });
|
|
869
1033
|
loadFileContent(fetch, selected, file).then(function (result) {
|
|
@@ -878,7 +1042,7 @@ window.__ModuleLoader__.load({
|
|
|
878
1042
|
query: selection.query,
|
|
879
1043
|
onQueryChange: function (value) {
|
|
880
1044
|
setSelection(function (current) {
|
|
881
|
-
return { root: current.root, query: value, expandedFile: current.expandedFile };
|
|
1045
|
+
return { root: current.root, query: value, expandedFile: current.expandedFile, expandedSkill: current.expandedSkill };
|
|
882
1046
|
});
|
|
883
1047
|
},
|
|
884
1048
|
});
|
|
@@ -901,6 +1065,7 @@ window.__ModuleLoader__.load({
|
|
|
901
1065
|
exports.inject = ["slots", "locale", "theme"];
|
|
902
1066
|
exports.loadCardModel = loadCardModel;
|
|
903
1067
|
exports.loadFileContent = loadFileContent;
|
|
1068
|
+
exports.loadSkillContent = loadSkillContent;
|
|
904
1069
|
exports.apply = function apply(ctx) {
|
|
905
1070
|
var tRaw = null;
|
|
906
1071
|
try {
|
package/lib/card-routes.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ import type { MemoryStore } from "./store.js";
|
|
|
3
3
|
export declare const CARD_API_WORKSPACES_PATH = "/dsh-continual-evolve/api/v1/workspaces";
|
|
4
4
|
export declare const CARD_API_MEMORY_PATH = "/dsh-continual-evolve/api/v1/memory";
|
|
5
5
|
export declare const CARD_API_MEMORY_FILE_PATH = "/dsh-continual-evolve/api/v1/memory/file";
|
|
6
|
+
export declare const CARD_API_SKILLS_PATH = "/dsh-continual-evolve/api/v1/skills";
|
|
7
|
+
export declare const CARD_API_SKILL_FILE_PATH = "/dsh-continual-evolve/api/v1/skills/file";
|
|
6
8
|
/** Minimal request shape the handlers touch (Node IncomingMessage subset). */
|
|
7
9
|
export interface CardRequest {
|
|
8
10
|
method?: string;
|
package/lib/card-routes.js
CHANGED
|
@@ -11,12 +11,14 @@
|
|
|
11
11
|
* so the API cannot probe the filesystem; the content endpoint takes an id,
|
|
12
12
|
* never a path. Handlers are synchronous and never throw past the response.
|
|
13
13
|
*/
|
|
14
|
-
import { memoryEntryContent, listCardWorkspaces, memorySnapshot } from "./memory-snapshot.js";
|
|
14
|
+
import { memoryEntryContent, listCardWorkspaces, memorySnapshot, skillEntryContent, skillSnapshot } from "./memory-snapshot.js";
|
|
15
15
|
import { canonicalPath } from "./workspace-hint.js";
|
|
16
16
|
/** URL prefix of the card API (kind-exact routes registered under it). */
|
|
17
17
|
export const CARD_API_WORKSPACES_PATH = "/dsh-continual-evolve/api/v1/workspaces";
|
|
18
18
|
export const CARD_API_MEMORY_PATH = "/dsh-continual-evolve/api/v1/memory";
|
|
19
19
|
export const CARD_API_MEMORY_FILE_PATH = "/dsh-continual-evolve/api/v1/memory/file";
|
|
20
|
+
export const CARD_API_SKILLS_PATH = "/dsh-continual-evolve/api/v1/skills";
|
|
21
|
+
export const CARD_API_SKILL_FILE_PATH = "/dsh-continual-evolve/api/v1/skills/file";
|
|
20
22
|
function sendJson(response, status, body) {
|
|
21
23
|
response.writeHead(status, { "content-type": "application/json; charset=utf-8" });
|
|
22
24
|
response.end(JSON.stringify(body));
|
|
@@ -116,6 +118,69 @@ export function mountCardRoutes(webServer, store, options = {}) {
|
|
|
116
118
|
});
|
|
117
119
|
},
|
|
118
120
|
}));
|
|
121
|
+
disposers.push(webServer.register({
|
|
122
|
+
kind: "exact",
|
|
123
|
+
path: CARD_API_SKILLS_PATH,
|
|
124
|
+
handler(request, response) {
|
|
125
|
+
if (!isGet(request)) {
|
|
126
|
+
response.writeHead(405, { allow: "GET" });
|
|
127
|
+
response.end();
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
const root = rootParamOf(request);
|
|
131
|
+
if (root === null) {
|
|
132
|
+
sendJson(response, 400, { error: "root query parameter is required and must be an absolute path" });
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
if (!isKnownRoot(store, root)) {
|
|
136
|
+
sendJson(response, 404, { error: "unknown workspace root" });
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
sendJson(response, 200, skillSnapshot(store, root));
|
|
140
|
+
},
|
|
141
|
+
}));
|
|
142
|
+
disposers.push(webServer.register({
|
|
143
|
+
kind: "exact",
|
|
144
|
+
path: CARD_API_SKILL_FILE_PATH,
|
|
145
|
+
handler(request, response) {
|
|
146
|
+
if (!isGet(request)) {
|
|
147
|
+
response.writeHead(405, { allow: "GET" });
|
|
148
|
+
response.end();
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
const root = rootParamOf(request);
|
|
152
|
+
if (root === null) {
|
|
153
|
+
sendJson(response, 400, { error: "root query parameter is required and must be an absolute path" });
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
const id = idParamOf(request);
|
|
157
|
+
if (id === null) {
|
|
158
|
+
sendJson(response, 400, { error: "id query parameter is required" });
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
if (!isKnownRoot(store, root)) {
|
|
162
|
+
// Same fence as the snapshot route.
|
|
163
|
+
sendJson(response, 404, { error: "unknown workspace root" });
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
const content = skillEntryContent(store, root, id);
|
|
167
|
+
if (!content.ok) {
|
|
168
|
+
if (content.reason === "too-large") {
|
|
169
|
+
sendJson(response, 413, { error: "skill body exceeds the 5 MiB preview limit" });
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
sendJson(response, 404, { error: "skill not found" });
|
|
173
|
+
}
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
sendJson(response, 200, {
|
|
177
|
+
id: content.id,
|
|
178
|
+
scope: content.scope,
|
|
179
|
+
content: content.content,
|
|
180
|
+
updatedAtMs: content.updatedAtMs,
|
|
181
|
+
});
|
|
182
|
+
},
|
|
183
|
+
}));
|
|
119
184
|
return () => {
|
|
120
185
|
for (const disposer of disposers) {
|
|
121
186
|
if (typeof disposer === "function") {
|
package/lib/extraction.d.ts
CHANGED
|
@@ -34,8 +34,11 @@ export interface RunOptions {
|
|
|
34
34
|
incrementMaxChars?: number;
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
|
-
* Run one extraction pass for a target. Never throws
|
|
38
|
-
* is
|
|
37
|
+
* Run one extraction pass for a target. Never throws unless the ledger
|
|
38
|
+
* itself is unwritable: every terminal path is either a landed application,
|
|
39
|
+
* a ledgered skip, or a ledgered failure — anything that escapes the
|
|
40
|
+
* per-stage handling inside lands a failed `unexpected-error` ledger row
|
|
41
|
+
* here, so no failure ends as a scheduler warn without an account trace.
|
|
39
42
|
*/
|
|
40
43
|
export declare function runExtraction(deps: ExtractionDeps, target: ExtractionTarget, opts: RunOptions): Promise<ExtractionResult>;
|
|
41
44
|
/** The event wiring surface (duck-typed cordis context). */
|