dsh-knit 0.20.0 → 0.21.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 +123 -0
- package/README.en.md +109 -0
- package/README.md +92 -3
- package/SECURITY.md +3 -2
- package/package.json +2 -2
- package/src/client/client.js +530 -50
- package/src/host/context.js +42 -6
- package/src/host/control.js +421 -0
- package/src/host/index.js +224 -6
- package/src/host/links.js +74 -24
- package/src/host/relations.js +306 -0
- package/src/host/tool.js +96 -6
- package/test/client.test.mjs +540 -12
- package/test/code-context.test.mjs +3 -1
- package/test/context-eval.test.mjs +5 -1
- package/test/context.test.mjs +32 -2
- package/test/control.test.mjs +324 -0
- package/test/deep-corpus.mjs +110 -0
- package/test/deep-scale.test.mjs +1 -1
- package/test/harness.mjs +6 -2
- package/test/host-http.test.mjs +107 -0
- package/test/i18n.test.mjs +12 -6
- package/test/links.test.mjs +50 -0
- package/test/relations.test.mjs +360 -0
- package/test/tier1.test.mjs +2 -2
- package/test/tool.test.mjs +79 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,124 @@
|
|
|
3
3
|
本项目的重要变更都记在这里。格式参考 [Keep a Changelog](https://keepachangelog.com/),
|
|
4
4
|
版本号遵循[语义化版本](https://semver.org/lang/zh-CN/)。
|
|
5
5
|
|
|
6
|
+
## [0.21.0] - 2026-10-08
|
|
7
|
+
|
|
8
|
+
> **Relations & Context Control** —— **原 v0.21 与 原 v0.22 合并成一个版本**(用户 2026-10-08 拍板:
|
|
9
|
+
> 两件事在实现上是同一条链路上的前后两环,分两版只会让「关系」先当摆设)。这一版回答两个问题:
|
|
10
|
+
> **「这一篇为什么在这里?」** 与 **「我自己想留住 / 挡掉的那几篇呢?」**
|
|
11
|
+
> —— 前者给**有行号、能 grep 回原文**的关系证据(引用 / 导入 / 测试 / 文档),后者给**固定与排除**,
|
|
12
|
+
> 而且真的活过重启。
|
|
13
|
+
> 硬约束一条没松:**零模型 / 零网络 / 零新依赖 / 无构建步骤**。
|
|
14
|
+
> 两条边界是刻意的:关系**是投影,不是第二个排序阶段**(`rankByRelevance()` 一行未改);
|
|
15
|
+
> 不做调用图 / 依赖图 / 符号索引(没有 AST / LSP / Tree-sitter),Git provenance 推迟
|
|
16
|
+
> (每文件一次 `git log` 在 1000 文件规模上是秒级到十秒级,与 R1 门槛冲突)。
|
|
17
|
+
|
|
18
|
+
### 变化
|
|
19
|
+
|
|
20
|
+
- **新增 `src/host/relations.js`(零 I/O 的纯逻辑)**。只做四类**有证据**的关系,
|
|
21
|
+
数组顺序即截断优先级:`references`(Markdown 里引用了另一篇 Markdown)、
|
|
22
|
+
`documents`(Markdown 里写到了某个代码路径)、`imports`(代码里的 `import … from` / `require(…)`,
|
|
23
|
+
**逐行正则**,含行号)、`tests`(文件名约定上的测试与被测方,**唯一不带行号的一类** ——
|
|
24
|
+
证据是文件名这条可核验的路径事实,不是某一行文字,所以如实不给行号,而不是编一个)。
|
|
25
|
+
导出 `MAX_RELATIONS_PER_ITEM = 3` / `MAX_TOOL_RELATIONS_PER_ITEM = 2` / `RELATION_TYPES` /
|
|
26
|
+
`importsOf` / `resolveSpec` / `testsOf` / `buildRelationFacts` / `relationsOf` / `resetRelationCache`。
|
|
27
|
+
每条边**两端各登记一次**,`line` 属于**提及所在的那个文件**(`dir: 'in'` 时行号读的是对方那一篇)。
|
|
28
|
+
同一 `(type, dir, other)` 去重取最小行号;对端**不在本批候选集**里就不产生边(不硬凑)。
|
|
29
|
+
- **`src/host/links.js` 三处修改**:① 新增 `extractRefsWithLines()`(与 `extractRefs` **同一套正则、
|
|
30
|
+
同一套顺序**,只多给行号;`extractRefs` 现在是它 `.map()` 的结果,一处真源);② 引用目标放开到
|
|
31
|
+
「已索引的文件」(`{anyExt: true}`),**源仍然只有 Markdown** ——
|
|
32
|
+
`test/code-context.test.mjs` 里那条「代码只能被指向、不能当源」的守卫原意一个字没改;
|
|
33
|
+
③ **修掉一个既有缺陷**:引用图缓存的签名原本只是「篇数 + 最大 mtime + 是否截断」,
|
|
34
|
+
**不含候选集身份**,同一进程里连跑两个候选数相同、最大 mtime 落在同一文件的 query 会**串图**
|
|
35
|
+
(实测复现,第二个 query 的关系全落空)。现在签名是逐篇 `rel\u0000mtimeMs` 排序后的精确键,
|
|
36
|
+
不用哈希(碰撞会让关系静默错配),`test/links.test.mjs` 有回归用例。
|
|
37
|
+
- **`src/host/context.js`:`provenance` 三值**(`retrieval` / `relation` / `manual`)。
|
|
38
|
+
⚠️ 字段名**不叫 `source`** —— `source` 从 v0.14 起指的是**文件角色**
|
|
39
|
+
(`impl` / `test` / `config` / `design` / `doc`),两者同时出现在一条记录上,不能混。
|
|
40
|
+
三条既有断言(`test/context.test.mjs` / `test/context-eval.test.mjs` / `test/code-context.test.mjs`)
|
|
41
|
+
已按新键加强。包内条目还会带 `relations`(最多 3 条)与 `relationsTotal`(真实总数);
|
|
42
|
+
**没有关系、也没被截断时这两个键根本不出现**(空数组是纯噪音,9 条要白花一百多字节)。
|
|
43
|
+
- **`src/host/index.js`**:`buildContextFor()` 组装完包后投影关系,并多一个
|
|
44
|
+
`withRelations: false` 开关 —— 它唯一的用途是让「关系不改变任何一层的成员与顺序」这条
|
|
45
|
+
可以被**同一次调用**直接证伪(`test/relations.test.mjs` 的端到端守卫就这么写的)。
|
|
46
|
+
新路由 **`POST /knit/api/control`**(`{action, rel}`,四个动作 `pin` / `unpin` / `exclude` / `restore`)
|
|
47
|
+
是**唯一的写通道**;排除在检索之前生效(`stats.controlSkipped`),固定是排名的下游
|
|
48
|
+
(`applyPinOverride()`:从三层移出、进 `pinned` 区、`provenance: 'manual'`,**零新 I/O**)。
|
|
49
|
+
`/api/recent` 另外回报 `control = {pinned, excluded, skipped, persisted}`,
|
|
50
|
+
其中每个被排除项带 `exists`(「这篇现在还在工作区里吗」——「恢复」按钮只在它真可能回来时给)。
|
|
51
|
+
- **新增 `src/host/control.js`(纯逻辑 + 可选持久化,不 import 任何官方包)**。
|
|
52
|
+
`ctx.storage` 拿得到就用 `kv` 落盘(`unit: knit_control`,表 `pinned` / `excluded`,
|
|
53
|
+
`layout: 'single'`、键 = `` `${root}\u0000${rel}` ``,按工作区隔离),拿不到就退化成内存态。
|
|
54
|
+
写路径**只写差量**,且**串行**。
|
|
55
|
+
- 两条真机缺陷在这一版修掉(都是**先取证再改**):① 插件被重复加载时,每次加载都会新建一份
|
|
56
|
+
登记表,而存储单元「一个进程只有一个活句柄」,于是被模块级变量留下的**最后一个**实例恰好是
|
|
57
|
+
打不开存储的那个 ⇒ 共享那份登记表挂在**后端对象**上(`Symbol.for('dsh-knit.control')`),
|
|
58
|
+
同一进程里的后续加载直接复用;② `persisted` 原本在拿到 `kv` 的那一刻就报 `true`
|
|
59
|
+
(报的是**能力**,不是**结果**),现在**证据到之前一律 `false`**:读成功、或这一次写真的成功,
|
|
60
|
+
才转 `true`;写失败在**同一次响应**里就说出来。面板因此可以诚实地写「本会话有效(未持久化)」。
|
|
61
|
+
- **`src/host/tool.js`:`knit_docs` 每个条目最多 2 条关系**(`relations` / `relationsTotal` 进 schema,
|
|
62
|
+
`provenance` 进 `required`),渲染成一行 `relations: references ← docs/x.md:12; imports → src/y.js:3`
|
|
63
|
+
(`←` = 对方提到本条目,`→` = 本条目提到对方;`tests` 不带行号)。**只给事实,不写理由文案** ——
|
|
64
|
+
理由由既有的 `Why:` 行承担。被固定的条目出现在 `pinned` 分区且 `provenance: manual`;
|
|
65
|
+
被排除的条目**完全不出现**。
|
|
66
|
+
- **面板(`src/client/client.js`)**:相关模式的每一行有一个**弱化的来源词**(`检索` / `关系` / `用户固定`,
|
|
67
|
+
只有这三个词,没有分数没有百分比);**2026-10-09 布局改造**:标题行只留「序号 · 标记 · 标题 · 时间」,
|
|
68
|
+
来源词与 `固定` / `排除` 一起搬到**证据行右端**,顺序 `固定 → 排除 → 检索`,**默认 `visibility:hidden`**
|
|
69
|
+
(鼠标悬停该项 / 键盘光标 / 焦点进入才显形 —— 用 `visibility` 而不是 `opacity:0`,隐藏时**真的退出键盘焦点序**,
|
|
70
|
+
且不占额外高度、不引起横向跳动),证据文本留在左边、过长可截断而操作永不被挤掉;
|
|
71
|
+
**没有命中段也没有理由的条目仍留一条只含右侧操作的空行**(不写占位文字);三个入口都是纯文字按钮、无图标;
|
|
72
|
+
**同日按体验反馈**:三个入口的字号提到与命中段同级(10px → 11px;行高仍由证据行决定,不增高),
|
|
73
|
+
悬停热区左右各加 4px(用等量负外边距把宽度收回 ⇒ 行的宽度与词间距都不变);
|
|
74
|
+
**同日工具栏重排(2026-10-09 第二条规格)**:`相关 / 最新`(排序)|一根浅灰竖线|
|
|
75
|
+
`文档 / 代码 / 媒体 / 全部`(类型)|搜索框靠最右且宽度自适应 —— 类型组从独立一行搬进工具栏
|
|
76
|
+
(`.knit-types` 不再自带左右内边距),`.knit-filter` 用 `flex:1 1 180px` + `max-width:240px`
|
|
77
|
+
+ `min-width:0`(常规面板 180–240px、封顶后靠 `margin-left:auto` 贴右、面板窄了先缩它),
|
|
78
|
+
两组都是 `flex:none` ⇒ **前面的按钮永不被挤**;六个选项彼此独立(切类型不动排序与搜索词,反之亦然);
|
|
79
|
+
「为什么」展开**行级证据**(最多 3 条,
|
|
80
|
+
每条 = 类型标签 + 对方文件 + 第 N 行 + 打开,点开就地预览到那一行;超过 3 条如实写「共 N 条关系」);
|
|
81
|
+
被排除项消失并在上方留一行弱化说明 + 「恢复」;头部一条**检索状态摘要** ——
|
|
82
|
+
**单行、三组、竖线分隔**:`收集 N · 排除 N · 候选 N | BM25 词法检索 · 关系 N 条 · 固定 N | 入包 N`
|
|
83
|
+
(工作区候选 → 检索与调整 → 最终结果;组内中点、组间一根细竖线,**一个箭头都没有** —— 原来那串
|
|
84
|
+
`↓` / `→` 把一条**已经完成**的管线画成了流程图,2026-10-09 用户裁定删除;那个没有名字的光数字
|
|
85
|
+
「→ N」现在叫「候选 N」)。**每一格都是已经发生的事实**,口径逐格钉在守卫里;
|
|
86
|
+
没有图标 / 胶囊 / 色块 / 装饰边框,也**不承担任何交互**(它只负责展示信息)。
|
|
87
|
+
**同日第三条反馈(2026-10-09)**:这一行**紧贴工具栏**、**位置不随开关变** —— 观察层(「使用情况」)
|
|
88
|
+
从摘要上面挪到它的下面,渲染顺序固定为 工具栏 → 状态摘要 → 排除说明 → 通知 → 观察层 → 列表
|
|
89
|
+
(守卫钉着「开关前后摘要的位置一模一样」)。
|
|
90
|
+
**同日第四条反馈(2026-10-09)**:头部那格计数**只留阿拉伯数字**(`9` / 过滤时 `3 / 79`)——
|
|
91
|
+
量词本来随档位变(文档「篇」/ 代码「个代码文件」/ 媒体「个媒体」/ 混排「项」),
|
|
92
|
+
同一位置换个档就换一种中文 ⇒ 整句降级到 `title`(悬停仍读得到「9 个代码文件」),
|
|
93
|
+
`count` / `count.code…` 八条词条照旧在用。
|
|
94
|
+
**同日第五条反馈(2026-10-09)**:点开「检索」长出来的行级证据原来是**压在下一行上面**的 ——
|
|
95
|
+
DocRow 的入场补间用 `fill:'both'`,播完之后**仍然**按入场那一刻量到的高度钉着这一行
|
|
96
|
+
(`el.style.height=''` 清不掉补间效果),于是证据不把下面的行挤下去、而是溢出到它上面;
|
|
97
|
+
现在收尾统一走 `settleEnterAnim(el, anim)`:先 `cancel()` 注销补间、再清那两行内联样式。
|
|
98
|
+
守卫 = `test/client.test.mjs` 的「行级证据是向下延展」那条(替身没有 DOM ⇒ 喂纯对象 + 钉住调用点)。
|
|
99
|
+
**固定不是排序干预**:固定区不编号,三层 `01…0N` 的编号一个都不变。
|
|
100
|
+
- **打包修复(即 v0.20.1 的内容,已在本版树里)**:语料工厂搬进 `test/deep-corpus.mjs`,
|
|
101
|
+
`tools/deep-benchmark.mjs` 变成 CLI 外壳 —— 因为 `tools/` **不在 `package.json` 的 `files` 白名单**里,
|
|
102
|
+
registry 上那份 tarball 里 `npm test` 是 638 pass / 1 fail(3 条 R1 规模门槛用例)。
|
|
103
|
+
**不变式保住了:`tools/` 仍然不进包**。新增 **`tools/clean-room-test.mjs`**:真打 `npm pack` →
|
|
104
|
+
解包到临时目录 → 断言 `package/tools/` 只有白名单那两个文件 → 在解包目录里跑 `npm test` ⇒
|
|
105
|
+
非全绿就非零退出。它是**发版前**闸门(v0.20.0 的清单只在发完之后查,太晚)。
|
|
106
|
+
⚠️ 它必须带 `--cache`,否则会撞 `~/.npm/_cacache/tmp` 的权限(那个目录属于 root)。
|
|
107
|
+
|
|
108
|
+
### 实测
|
|
109
|
+
|
|
110
|
+
- `cd knit && npm test` → **697/697**(28 个测试文件;v0.20.0 的 641 条**一条未删、未放宽、未 skip**,
|
|
111
|
+
v0.21 净增 56 条:关系 / 控制 / 跨面 + 布局与动效收尾守卫)。
|
|
112
|
+
- `node tools/clean-room-test.mjs` → `dsh-knit-0.21.0.tgz` · 56 个文件 · 解包目录 **697 pass / 0 fail** ⇒ exit 0
|
|
113
|
+
(版本号改成 `0.21.0` 当天复跑;改名之前那次是 `dsh-knit-0.20.0.tgz`,文件数与结论相同)。
|
|
114
|
+
- 关系投影的载荷(按 `{type, dir, other, line}` 四字段序列化):**≈252 B/项**
|
|
115
|
+
(两组真实任务各 9 项、合计 4539 B 关系投影);面板总载荷实测 **7857 B / 9 项**(门槛 16000 B)。
|
|
116
|
+
- 真机(`curl` 打运行中的 DSH,工作区 `08_Knit`):三层逐条 `provenance: retrieval` 且
|
|
117
|
+
`relations` 恰好 3 条(`relationsTotal` 实测 11 / 7 / 24 / 22 / 33 / 66 / 12 / 18 / 8,截断说明里的数字是真的);
|
|
118
|
+
固定 `README.md` ⇒ 包里多出 `pinned` 分区、`provenance: manual`、原层里消失;
|
|
119
|
+
排除 `03_发布/真机验收清单.md` ⇒ `skipped: 1`、被排除项**不出现**、`excluded[].exists: true`;
|
|
120
|
+
**重启 DSH 后读回**:`persisted: true`,介质 `~/.dsh/storages/knit_control.json`(475 B,按工作区隔离)。
|
|
121
|
+
- `src/host/tool.js` 与面板**同源**:同一条任务下,面板每项关系的前 2 条与工具侧逐字相同
|
|
122
|
+
(`test/tool.test.mjs` 的跨面守卫,把工具里的截断拿掉即变红)。
|
|
123
|
+
|
|
6
124
|
## [0.20.0] - 2026-10-07
|
|
7
125
|
|
|
8
126
|
> **Deep Context Retrieval**。核心体验从「任务 → 相关文件」升级为
|
|
@@ -248,6 +366,11 @@ embedding / 向量数据库 / LLM / 网络 / LSP / Tree-sitter / AST 依赖图 /
|
|
|
248
366
|
|
|
249
367
|
- **宿主不热加载** ⇒ 升级后要重启 DSH 才会生效(客户端 bundle 随页面刷新)。
|
|
250
368
|
|
|
369
|
+
> ✅ **2026-10-08 已发布**:轻量 tag `v0.20.0` = 发布提交 `2be278486299c721daa21ee127fd26bbe21af284`;npm `latest = 0.20.0`、`gitHead` = 同一个提交、共 **17 个**版本;registry 真包 **51 文件 / 565 078 B tarball / 1 662 961 B 解包 / shasum `7be584a08529379dba7d255028d59a2853624094`**;OIDC 可信发布 + provenance(workflow run `37730146187`,22 s);GitHub Release 正文取自本节(前置「更新后必须重启 DSH」与「已知问题」两条),`publishedAt 2026-10-08T05:08:35Z`。
|
|
370
|
+
> ⚠️ 本地 `npm pack --dry-run` 报 51 文件 / 557.0 kB / shasum `deb8bfe6…` —— **本地字节与 registry 历来对不上**(v0.18 / v0.19.x 都这样),差的只是 tar/gzip 框架元数据,解包后清单与内容逐字一致。
|
|
371
|
+
> ⚠️ **发布后才发现的一条包装缺陷**:`test/deep-scale.test.mjs` 从 `../tools/deep-benchmark.mjs` 取语料工厂,而 `tools/` 不随包发布 ⇒ **解包目录里 `npm test` = 638 pass / 1 fail**(`ERR_MODULE_NOT_FOUND`)。**插件本体不受影响**(`src/` 不引用 `tools/`)。仓库完整套件仍是 641/641;已在 **v0.20.1** 修(把语料工厂搬进 `test/`)。
|
|
372
|
+
> ⚠️ **这一行不在已发布的 tarball 里** —— 它在 publish 成功之后才写进来(下次 `npm view` 看到的是这份仓库里的文件)。
|
|
373
|
+
|
|
251
374
|
## [0.19.1] - 2026-10-07
|
|
252
375
|
|
|
253
376
|
> **定位重构(只改对外叙事,一行代码没动)**。产品已经从 v0.12 时代的「更聪明的最近文件列表」
|
package/README.en.md
CHANGED
|
@@ -146,6 +146,11 @@ as one of its tabs. Each host is an independent optional dependency; missing one
|
|
|
146
146
|
| **Sorted by relevance to the current conversation** (BM25 + IDF, fully local, no model) | ✅ |
|
|
147
147
|
| **The `knit_docs` tool for the agent**: the model can look up this project's most relevant documents itself | ✅ |
|
|
148
148
|
| **Document lifecycle** (v0.17): each recommended document is shown as `Unread / Read / Updated after read / Re-read after update`, alongside the most recent read, how many reads fell outside the pack (expandable to which ones), and the latest context change | ✅ |
|
|
149
|
+
| **Relation evidence** (v0.21): every row carries `retrieval` / `relation` / `pinned`; "why" expands **line-level evidence** (references / imports / tests / documents, with the other file and the line number — at most 3 per item in the panel, 2 through the tool). Every one of them can be grepped back to its original line: not a word of the reasoning is invented | ✅ |
|
|
150
|
+
| **Pin / exclude** (v0.21): pinning moves an item into its own section at the top (unnumbered — the three tiers keep their numbering); excluding takes effect **before retrieval** (the counts and the status summary move together, and it is undoable); with host storage it **survives restarts**, without it the panel says "this session only (not persisted)" instead of pretending | ✅ |
|
|
151
|
+
| **Retrieval status summary** (v0.21.x): one honest line in the panel header — `collected · excluded · candidates | BM25 lexical retrieval · relations · pinned | in pack` (mid-dots inside a group, one thin rule between groups, no arrows); it follows the task, the kind tab, pins and exclusions | ✅ |
|
|
152
|
+
| **Toolbar in one row** (v0.21.x): `Relevance / Newest` (sort) | one light-grey rule | `Docs / Code / Media / All` (kind) | the filter box at the far right, width-adaptive (180–240px in a normal panel; when the panel narrows it shrinks first, the groups are never squeezed); the six options are independent — switching kind does not reset the sort or the query | ✅ |
|
|
153
|
+
| **Header count** (v0.21.x): digits only (`9`, or `3 / 79` while filtering) — the quantifier changes with the kind, so it stays off screen; hovering still gives the full phrase (`9 code files`) | ✅ |
|
|
149
154
|
| One-click toggle between relevance / modification time (preference kept in localStorage) | ✅ |
|
|
150
155
|
| Scans **documents and code** in the session workspace (recursive, depth ≤ 6, skips `node_modules` / `.git` / `dist` / `build` / `out` / `coverage`) | ✅ |
|
|
151
156
|
| Each row shows H1 title (or filename) + relative time + first-paragraph summary | ✅ |
|
|
@@ -320,6 +325,110 @@ Current task -> Workspace Retrieval -> Document + Code Candidates
|
|
|
320
325
|
|
|
321
326
|
---
|
|
322
327
|
|
|
328
|
+
## Relations and context control (v0.21)
|
|
329
|
+
|
|
330
|
+
Ranking answers "which documents look alike". This version answers two other questions: **"why is
|
|
331
|
+
this one here?"** and **"what about the ones I want to keep or block myself?"** (the original v0.21
|
|
332
|
+
and the original v0.22 were merged into one version here.)
|
|
333
|
+
|
|
334
|
+
### Relations are an explanation, not a second ranking stage
|
|
335
|
+
|
|
336
|
+
Every relation needs **evidence you can grep back to the source**. There are exactly four kinds:
|
|
337
|
+
|
|
338
|
+
| Kind | What the evidence is | Example |
|
|
339
|
+
|---|---|---|
|
|
340
|
+
| `references` | one Markdown file referencing another | `README.md` line 81 mentions `docs/guide.md` |
|
|
341
|
+
| `documents` | Markdown naming a code path | a design note's line 12 mentions `src/host/index.js` |
|
|
342
|
+
| `imports` | `import … from` / `require(…)` in code, **line by line** | `test/deep-scale.test.mjs:22` → `../tools/deep-benchmark.mjs` |
|
|
343
|
+
| `tests` | test ↔ subject by filename convention (**the only kind without a line number**) | `context-manager.ts` ↔ `context-manager.test.ts` |
|
|
344
|
+
|
|
345
|
+
- At most **3 relations per item** in the panel and **2** through `knit_docs`; when it has to
|
|
346
|
+
truncate it says "N relations in total" rather than hiding them. The order shown is the priority:
|
|
347
|
+
`references` > `imports` > `tests` > `documents`.
|
|
348
|
+
- `←` = the other file mentions this one, `→` = this one mentions the other; **the line number
|
|
349
|
+
belongs to the file that does the mentioning**.
|
|
350
|
+
- **Relations never take part in ranking**: switch them off and the three tiers hold exactly the same
|
|
351
|
+
members in the same order (there are tests watching this, relation by relation).
|
|
352
|
+
- No AST, no LSP, no Tree-sitter, no call graph, no dependency graph, no symbol index. A path written
|
|
353
|
+
inside a comment does **not** count as a relation, and code can only be *pointed at*, never act as a
|
|
354
|
+
source of references — that has been an assertion since v0.19 and is unchanged.
|
|
355
|
+
|
|
356
|
+
### "Source" is exactly three words
|
|
357
|
+
|
|
358
|
+
In relevance mode each row carries one low-key label: **retrieval** (it matched the current task's
|
|
359
|
+
keywords) / **relation** (it was pulled in by a reference) / **pinned** (you put it there). No score,
|
|
360
|
+
no percentage, no colour scale; in the flat list and under **Newest** none of them appears at all.
|
|
361
|
+
|
|
362
|
+
> ⚠️ Honest boundary: in a real workspace with enough candidates the three tiers are **always filled
|
|
363
|
+
> by keyword-matched documents first**, so the "relation" label is rare — that is a measured result,
|
|
364
|
+
> not an omission. The value of relations is in the **"why"** column: open it and you get line-level
|
|
365
|
+
> evidence (kind + other file + line N + open), where "open" previews the real text around that line
|
|
366
|
+
> (±2 lines, highlighted).
|
|
367
|
+
>
|
|
368
|
+
> The evidence **expands downwards**: opening it pushes the rows below down, closing it puts them
|
|
369
|
+
> back. (v0.21.x fixed an overflow here — the entry animation used `fill:'both'`, which keeps pinning
|
|
370
|
+
> the row height after the animation finishes; the settle step has to `cancel()` it first.)
|
|
371
|
+
|
|
372
|
+
### Pin / exclude
|
|
373
|
+
|
|
374
|
+
- **Where the controls are** (v0.21.x): the title row keeps only "number · marker · title · time";
|
|
375
|
+
the `source` word and `pin` / `exclude` sit together at the **right end of the evidence row**
|
|
376
|
+
(order `pin → exclude → retrieval`), **hidden by default** — they appear when you hover that row,
|
|
377
|
+
when the keyboard cursor is on it, or when focus enters it. They use `visibility`, not `opacity:0`,
|
|
378
|
+
so hidden controls really leave the tab order, add no height and cause no sideways jump. All three
|
|
379
|
+
entries are plain text buttons, no icons.
|
|
380
|
+
- **Pin**: the row moves into a "Pinned context" section at the very top and its `provenance` becomes
|
|
381
|
+
`manual`. **This is not a ranking intervention** — the pinned section is unnumbered and the `01…0N`
|
|
382
|
+
numbering of the three tiers does not change.
|
|
383
|
+
- **Exclude**: it is filtered out **before retrieval** (the header count and the status summary move
|
|
384
|
+
at the same time) and a low-key line with an "undo" entry stays above the list. "Undo" only appears
|
|
385
|
+
when the item is really still in the workspace (switching to the Code tab will not misreport a
|
|
386
|
+
Markdown file as "gone").
|
|
387
|
+
- **It survives restarts** as far as the host allows: given `ctx.storage`'s `kv`, pin and exclude are
|
|
388
|
+
written to `~/.dsh/storages/knit_control.json` (**per workspace**; key = workspace path + relative
|
|
389
|
+
path); without it they degrade to memory and the panel **says** "this session only (not persisted)"
|
|
390
|
+
instead of pretending. Two real-machine defects were fixed here: a duplicated plugin load could
|
|
391
|
+
fight over the storage handle (one unit, one live handle — they now share one registry), and
|
|
392
|
+
`persisted` used to claim "remembered" the moment a store appeared, whereas it should report the
|
|
393
|
+
**result** rather than the capability — it now commits to nothing until there is evidence, and
|
|
394
|
+
reports a write failure in the **same response**.
|
|
395
|
+
|
|
396
|
+
### The retrieval status summary in the header
|
|
397
|
+
|
|
398
|
+
One line of fact in the panel header:
|
|
399
|
+
`collected N · excluded N · candidates N | BM25 lexical retrieval · relations N · pinned N | in pack N`.
|
|
400
|
+
The three groups are the reading order: **workspace candidates** (how many were scanned, how many
|
|
401
|
+
this batch really ruled out, how many went on into retrieval), **retrieval and adjustment** (this
|
|
402
|
+
path is plain local BM25, followed by how many relation evidence items are in the pack and how many
|
|
403
|
+
items were pinned out of the tiers) and **the result** (the items currently in the three tiers).
|
|
404
|
+
Mid-dots inside a group, **one thin rule between the three groups only**, and **no arrows** — the old
|
|
405
|
+
`↓` / `→` chain drew an **already finished** pipeline as a flow chart and read like a progress bar; it
|
|
406
|
+
was deleted outright on 2026-10-09.
|
|
407
|
+
Every cell follows the task, the kind tab, pins and exclusions; it only reports, it takes no
|
|
408
|
+
interaction. It sits **directly under the toolbar** and does not move when you toggle things: opening
|
|
409
|
+
the Usage Lens puts the lens **below** this line (render order = toolbar → status summary → exclusion
|
|
410
|
+
note → notice → lens → list).
|
|
411
|
+
|
|
412
|
+
### The toolbar row (v0.21.x)
|
|
413
|
+
|
|
414
|
+
`Relevance / Newest` (sort) | one light-grey rule | `Docs / Code / Media / All` (kind) | the filter
|
|
415
|
+
box (far right).
|
|
416
|
+
|
|
417
|
+
- **Sort and kind are two conditions, not one segmented control**: that `.knit-bar-sep` (1px,
|
|
418
|
+
`border-l3`, `aria-hidden`) is the boundary. The kind group used to sit on its own row; its selected
|
|
419
|
+
state is still the v0.14 **underline tab** — it did not fall back to a grey-filled button.
|
|
420
|
+
- **The filter box sits at the tail of the toolbar** (it filters the current list further, which is
|
|
421
|
+
the toolbar convention): `flex:1 1 180px` + `max-width:240px` + `margin-left:auto` puts it at
|
|
422
|
+
180–240px against the right edge in a normal panel, and `min-width:0` makes it **shrink first** when
|
|
423
|
+
the panel narrows. The sort and kind groups are both `flex:none`: they are **never squeezed**.
|
|
424
|
+
- **The three conditions are independent**: pick Code and then Newest and you get the newest code; the
|
|
425
|
+
query only filters the current scope and neither resets the sort nor gets reset by switching kind or
|
|
426
|
+
sort (`sort` / `kind` / `query` are three separate pieces of state).
|
|
427
|
+
- No icons, no loud pills; the other entries use secondary text, the selected one an underline plus
|
|
428
|
+
the primary text colour.
|
|
429
|
+
|
|
430
|
+
---
|
|
431
|
+
|
|
323
432
|
## Also for the agent: the `knit_docs` tool
|
|
324
433
|
|
|
325
434
|
The same ranking that you see in the panel is also exposed to the model.
|
package/README.md
CHANGED
|
@@ -133,6 +133,11 @@ dsh plugin --profile web add dsh-knit
|
|
|
133
133
|
|---|---|
|
|
134
134
|
| **按当前对话相关性排序**(BM25 + IDF,纯本地,零模型) | ✅ |
|
|
135
135
|
| **当前任务上下文**:把排序结果拆成 **主要 / 辅助 / 相关** 三层,每条都写明「为什么在这里」 | ✅ |
|
|
136
|
+
| **关系证据**(v0.21):每行标出 `检索` / `关系` / `用户固定`;「为什么」展开**行级证据**(引用 / 导入 / 测试 / 文档,带对方文件与行号,面板最多 3 条、工具最多 2 条)—— 每条都能按行号 grep 回原文,一个字的理由都不是编的 | ✅ |
|
|
137
|
+
| **固定 / 排除**(v0.21):固定进最上方独立区(不编号,三层编号不变);排除在**检索之前**生效(计数与状态摘要同时变,可恢复);宿主给了存储就**活过重启**,没给就写明「本会话有效(未持久化)」 | ✅ |
|
|
138
|
+
| **检索状态摘要**(v0.21.x):面板头部一行如实显示 `收集 · 排除 · 候选 | BM25 词法检索 · 关系 · 固定 | 入包`(组内中点、组间细竖线、没有箭头),换任务 / 换档都跟着变 | ✅ |
|
|
139
|
+
| **工具栏一行**(v0.21.x):`相关 / 最新`(排序)|一根浅灰竖线|`文档 / 代码 / 媒体 / 全部`(类型)|搜索框靠最右、宽度自适应(常规 180–240px,面板窄了先缩它,前面的按钮永不被挤);六个选项彼此独立 —— 切类型不动排序与搜索词 | ✅ |
|
|
140
|
+
| **顶行计数**(v0.21.x):只显示阿拉伯数字(`9` / 过滤时 `3 / 79`)—— 量词随类型档变,索性不上屏;悬停提示里仍是完整那句(`9 个代码文件`) | ✅ |
|
|
136
141
|
| **给 agent 用的 `knit_docs` 工具**:让模型拿回**三层任务上下文**(不是一条平铺列表) | ✅ |
|
|
137
142
|
| **文档生命周期**(v0.17):每篇推荐文档现在处于 `未读 / 已读 / 读后已更新 / 修改后已重新读取` 哪一档,另外给出最近读了哪篇、包外读了哪几篇、上下文最近一次怎么变 | ✅ |
|
|
138
143
|
| 相关性 / 修改时间双模式一键切换(偏好记在 localStorage) | ✅ |
|
|
@@ -144,7 +149,7 @@ dsh plugin --profile web add dsh-knit
|
|
|
144
149
|
| 单击就地展开预览,再点收起 | ✅ |
|
|
145
150
|
| 相对路径图片真正渲染(`./img/a.png`、`../assets/b.png`) | ✅ |
|
|
146
151
|
| **代码上下文**(v0.19):`.js .mjs .cjs .ts .tsx .jsx .py .json .html .htm .css .scss .yaml .yml .sh .bash .zsh` 与 Markdown **进同一个检索池**,共用同一份 BM25、同一个 Context Pack、同一套生命周期 —— 不是第二套「代码搜索」 | ✅ |
|
|
147
|
-
| **文档 / 代码 / 媒体 / 全部**
|
|
152
|
+
| **文档 / 代码 / 媒体 / 全部** 四类一键切换(偏好记住,默认仍是文档,老体验不变);选中态是**下划线式页签**(v0.14 起就是这个;不带品牌色描边、也**没**退回灰底按钮 —— 2026-09-29 明确裁定过;页签「媒体」2026-10-06 由「图片与视频」改短,「代码」v0.19 加入) | ✅ |
|
|
148
153
|
| 图片与视频:方形缩略图网格,**格子基准固定 104px、列数由宽度连续数出来**(320px → 2 列 / 632px → 5 列 / 1200px → 10 列),格子大小基本不变;**纵向有多少行就铺多少行**,超出交给列表滚动;视频自动取首帧、叠播放三角与时长角标(零依赖、不转码) | ✅ |
|
|
149
154
|
| 点图片 / 视频在面板内**就地预览**:图片大图、视频可播放可拖动(HTTP Range 流式,不全量下载) | ✅ |
|
|
150
155
|
| 「全部」视图**分上下两区**:文档最多 4 条(超出给「查看全部 →」);图片视频**不截断**,只给计数 | ✅ |
|
|
@@ -328,6 +333,84 @@ Markdown 仍是 `title ×4 / summary ×2 / body ×1`。**两套字段权重,
|
|
|
328
333
|
|
|
329
334
|
---
|
|
330
335
|
|
|
336
|
+
## 关系与上下文控制(v0.21)
|
|
337
|
+
|
|
338
|
+
排序回答「哪几篇像」。这一版回答另外两个问题:**「它为什么在这里?」** 与
|
|
339
|
+
**「我自己想留住 / 挡掉的那几篇呢?」**(原 v0.21 与 原 v0.22 在这里合并成一个版本。)
|
|
340
|
+
|
|
341
|
+
### 关系是解释,不是第二个排序阶段
|
|
342
|
+
|
|
343
|
+
每条关系都要有**能 grep 回原文的证据**,只做四类:
|
|
344
|
+
|
|
345
|
+
| 类型 | 证据是什么 | 例子 |
|
|
346
|
+
|---|---|---|
|
|
347
|
+
| `references` | Markdown 引用了另一篇 Markdown | `README.md` 第 81 行提到 `docs/guide.md` |
|
|
348
|
+
| `documents` | Markdown 写到了某个代码路径 | 设计文档第 12 行提到 `src/host/index.js` |
|
|
349
|
+
| `imports` | 代码里的 `import … from` / `require(…)`,**逐行正则** | `test/deep-scale.test.mjs:22` → `../tools/deep-benchmark.mjs` |
|
|
350
|
+
| `tests` | 文件名约定上的测试 ↔ 被测方(**唯一不带行号的一类**) | `context-manager.ts` ↔ `context-manager.test.ts` |
|
|
351
|
+
|
|
352
|
+
- 面板每篇最多 **3 条**、`knit_docs` 每篇最多 **2 条**;被截断时如实写「共 N 条关系」。
|
|
353
|
+
顺序即优先级:`references` > `imports` > `tests` > `documents`。
|
|
354
|
+
- `←` = 对方提到这一篇,`→` = 这一篇提到对方;**行号属于「谁在提这件事」的那个文件**。
|
|
355
|
+
- **关系不参与排名**:关掉它,三层的成员与顺序**逐字相同**(有测试逐条盯着)。
|
|
356
|
+
- 没有 AST / LSP / Tree-sitter,也没有调用图 / 依赖图 / 符号索引。注释里写个路径**不算**关系,
|
|
357
|
+
代码也**只能被指向、不能当引用源** —— 这条从 v0.19 起就是断言,原意一个字没改。
|
|
358
|
+
|
|
359
|
+
### 「来源」只有三个词
|
|
360
|
+
|
|
361
|
+
相关模式的每行标题旁一个弱化徽标:**检索**(命中当前任务关键词)/ **关系**(靠引用被带进来)/
|
|
362
|
+
**用户固定**。没有分数、没有百分比、没有色阶;平铺列表与「最新」排序下**一个都不出现**。
|
|
363
|
+
|
|
364
|
+
> ⚠️ 诚实边界:在候选充足的真实工作区里,三层的槽位**总是先被命中文档占满**,
|
|
365
|
+
> 所以「关系」徽标很稀有 —— 这是实测结论,不是没做。关系的价值在**「为什么」那一栏**:
|
|
366
|
+
> 点开是行级证据(类型标签 + 对方文件 + 第 N 行 + 打开),点「打开」预览到那一行真实原文(±2 行、灰底高亮)。
|
|
367
|
+
证据是**向下延展**的:展开时下面的行被挤下去,收起来回到原位(v0.21.x 修过一次溢出 ——
|
|
368
|
+
入场补间 `fill:'both'` 播完仍会钉住行高,收尾必须先 `cancel()`)。
|
|
369
|
+
|
|
370
|
+
### 固定 / 排除
|
|
371
|
+
|
|
372
|
+
- **入口在哪**(v0.21.x):标题行只留「序号 · 标记 · 标题 · 时间」;`来源` 词与 `固定` / `排除` 一起
|
|
373
|
+
排在**证据行的右端**(顺序 `固定 → 排除 → 检索`),**默认不显示** —— 鼠标悬停到该行、键盘光标停在该行、
|
|
374
|
+
或焦点进入该行时才出现(用 `visibility` 而不是 `opacity:0`,隐藏时**真的退出键盘焦点序**,
|
|
375
|
+
也不占额外高度、不引起横向跳动)。三个入口都是纯文字按钮,没有图标。
|
|
376
|
+
- **固定**:该行移到列表最上方的「固定上下文」区,`provenance` 变 `manual`。
|
|
377
|
+
**这不是排序干预** —— 固定区不编号,三层的 `01…0N` 一个都不变。
|
|
378
|
+
- **排除**:在**检索之前**就把它挡掉(顶部计数与状态摘要同时变),列表上方留一行弱化说明 + 「恢复」。
|
|
379
|
+
「恢复」只在它真的还在工作区里时给出(切「代码」档不会把一篇 Markdown 误报成「文件不见了」)。
|
|
380
|
+
- **活过重启**:取决于宿主给不给存储(`ctx.storage` 的 `kv`)。给了就落盘到
|
|
381
|
+
`~/.dsh/storages/knit_control.json`(**按工作区隔离**,键 = 工作区路径 + 相对路径);
|
|
382
|
+
没给就退化成内存态,面板**写明**「本会话有效(未持久化)」而不是假装记住了。
|
|
383
|
+
两条真机缺陷在这一版修掉:① 插件被重复加载时存储句柄会打架(一个 unit 只能有一个活句柄),
|
|
384
|
+
现在共享同一份登记表;② `persisted` 曾经在拿到存储的那一刻就报「已记住」——
|
|
385
|
+
它报的应该是**结果**而不是**能力**,现在证据到之前一律说没把握,写失败在**同一次响应**里就说出来。
|
|
386
|
+
|
|
387
|
+
### 头部那条检索状态摘要
|
|
388
|
+
|
|
389
|
+
面板头部一行事实:`收集 N · 排除 N · 候选 N | BM25 词法检索 · 关系 N 条 · 固定 N | 入包 N`。
|
|
390
|
+
三组就是阅读顺序 —— **工作区候选**(扫描到多少、这一批真的排掉几篇、排除之后剩几篇进入检索)、
|
|
391
|
+
**检索与调整**(这一路是纯本地 BM25 词法检索,后面跟着包里的关系证据条数与被固定移出三层的篇数)、
|
|
392
|
+
**最终结果**(三层现有条目数)。
|
|
393
|
+
组内是中点 `·`、**只有三组之间**一根细竖线;**没有箭头** —— 从前那串 `↓` / `→` 会把一条
|
|
394
|
+
**已经完成**的管线画成流程图,读起来像进度条,2026-10-09 已按用户裁定整体删除。
|
|
395
|
+
换任务、换类型档、有固定或排除时,**每一格都如实跟着变**;它只负责展示信息,不承担任何交互。
|
|
396
|
+
它**紧贴工具栏**、位置不随开关变:点右上「使用情况」时,观察层排在它**下面**,这一行不会被顶下去
|
|
397
|
+
(2026-10-09 用户反馈;渲染顺序 = 工具栏 → 状态摘要 → 排除说明 → 通知 → 观察层 → 列表)。
|
|
398
|
+
|
|
399
|
+
### 工具栏那一行(v0.21.x)
|
|
400
|
+
|
|
401
|
+
`相关 / 最新`(排序)|一根浅灰竖线|`文档 / 代码 / 媒体 / 全部`(类型)|搜索框(最右)。
|
|
402
|
+
|
|
403
|
+
- **排序与类型是两个条件,不做成一个整体**:那根 `.knit-bar-sep`(1px、`border-l3`、`aria-hidden`)
|
|
404
|
+
就是边界。类型组原先自己占一行,现在并进工具栏 —— 选中态仍是 v0.14 的下划线式页签,没退回灰底按钮。
|
|
405
|
+
- **搜索框排在工具栏尾部**(对当前列表再过滤,符合工具栏惯例):`flex:1 1 180px` +
|
|
406
|
+
`max-width:240px` + `margin-left:auto` ⇒ 常规面板里就是 180–240px 并贴住右端;
|
|
407
|
+
`min-width:0` ⇒ 面板变窄时**先缩它**。排序组与类型组都是 `flex:none`,**永不被挤**。
|
|
408
|
+
- **三个条件彼此独立**:选「代码」再选「最新」= 最新的代码;搜索只过滤当前范围,
|
|
409
|
+
不重置排序,也不会被切类型 / 切排序重置(`sort` / `kind` / `query` 三个独立 state)。
|
|
410
|
+
- 没有图标、没有醒目的胶囊;其余项用次级文本,选中项用下划线 + 主色文字。
|
|
411
|
+
|
|
412
|
+
---
|
|
413
|
+
|
|
331
414
|
## 也给 agent 用:`knit_docs` 工具
|
|
332
415
|
|
|
333
416
|
同一份排序,除了给你看,也开了一个口子给模型。
|
|
@@ -337,6 +420,9 @@ Markdown 仍是 `title ×4 / summary ×2 / body ×1`。**两套字段权重,
|
|
|
337
420
|
`primary` / `supporting` / `related` 三层,每项带路径 + 标题 + 摘要 +
|
|
338
421
|
**结构化理由**(`direct` / `summaryMatch` / `bodyMatch` / `linkTarget` / `linkSource` / `related`)
|
|
339
422
|
+ **项目角色**(`impl` / `test` / `config` / `design` / `doc`)+
|
|
423
|
+
+ **来源三值**(`provenance`:`retrieval` / `relation` / `manual`)+ **最多 2 条关系**
|
|
424
|
+
(`relations: references ← docs/x.md:12; imports → src/y.js:3`,`←` 是对方提到本条目)+ 被固定的条目在
|
|
425
|
+
`pinned` 分区里、被排除的条目完全不出现(v0.21)+
|
|
340
426
|
命中的那一小段原文**和它的行号区间**(`match: lines 147–163 — …`),再用它自己的 `read` 打开其中一篇。
|
|
341
427
|
|
|
342
428
|
**为什么有用**:agent 想引用项目里已有的文档时,只能靠猜路径、或者把 `glob`
|
|
@@ -653,7 +739,8 @@ v0.17 的信息都在,但**摞在一行字和几个折叠块里**,读不出
|
|
|
653
739
|
git clone https://github.com/PolinniZhong/dsh-knit.git
|
|
654
740
|
cd dsh-knit
|
|
655
741
|
|
|
656
|
-
npm test #
|
|
742
|
+
npm test # 697 项,零依赖,不需要先 npm install
|
|
743
|
+
node tools/clean-room-test.mjs # 发版前闸门:npm pack → 解包 → 在解包目录里再跑一遍测试
|
|
657
744
|
```
|
|
658
745
|
|
|
659
746
|
**改动生效方式**:宿主半边(`src/host/`)改了**必须重启 DSH**(实测不热加载);
|
|
@@ -674,12 +761,14 @@ knit/
|
|
|
674
761
|
│ ├── host/classification.js # 文件分类层:kind / language / 能力位(纯函数,零 I/O)
|
|
675
762
|
│ ├── host/relevance.js # 相关性引擎:BM25 + 关键词抽取(纯函数)
|
|
676
763
|
│ ├── host/links.js # 引用关系解析(纯解析,不碰排序)
|
|
764
|
+
│ ├── host/relations.js # 关系事实层:引用 / 导入 / 测试 / 文档(纯函数,零 I/O)
|
|
677
765
|
│ ├── host/passage.js # 内容片段层:切分 / 片段打分 / 行号映射(纯函数,零 I/O)
|
|
678
766
|
│ ├── host/context.js # 上下文装配:Context Pack 三层(纯函数,零 I/O)
|
|
767
|
+
│ ├── host/control.js # 固定 / 排除:纯逻辑 + 可选 ctx.storage 持久化
|
|
679
768
|
│ ├── host/feedback.js # 使用反馈:读时归因 / Context Epoch / Delta(纯逻辑,只读事件流)
|
|
680
769
|
│ ├── host/tool.js # agent 文档工具 knit_docs(手写 ToolDefinition)
|
|
681
770
|
│ └── client/client.js # 双宿主注册 + 面板 UI
|
|
682
|
-
└── test/ #
|
|
771
|
+
└── test/ # 697 项测试
|
|
683
772
|
├── eval/ # 检索质量评测:语料 + 用例 + 冻结的 v0.5.2 基线 + Deep Context 四指标
|
|
684
773
|
└── context/ # 上下文分层评测:24 篇语料 + 12 条任务型用例
|
|
685
774
|
```
|
package/SECURITY.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> **Knit 的安全属性 —— 每一条都指向一个真实存在的检查。**
|
|
4
4
|
>
|
|
5
|
-
> 最后更新:2026-10-
|
|
5
|
+
> 最后更新:2026-10-08(v0.21.0)—— 新增 `POST /knit/api/control` 与固定/排除的落盘,两条属性已按实际情况改写
|
|
6
6
|
|
|
7
7
|
## 为什么有这份文件
|
|
8
8
|
|
|
@@ -31,7 +31,8 @@ Knit 的安全属性其实一直成立 —— 但它们此前只散落在文档
|
|
|
31
31
|
| 读文件接口守在会话工作区内 | ✅ | `test/host.test.mjs` 的越界用例(解析后必须落在工作区内,否则一律拒绝) |
|
|
32
32
|
| `/knit/api/doc` 只放行文本类产物 | ✅ | v0.19 起因代码而放宽(原为「仅 Markdown」),所以边界要重新说清:**文档 / 代码 / 生成产物**放行,**媒体与未知后缀一律拒绝**。`test/host.test.mjs` 的 `notPreviewable` 用例 + `test/classification.test.mjs` 的 `isPreviewKind` 闭集断言 |
|
|
33
33
|
| `/knit/api/raw` 叠扩展名白名单 | ✅ | `test/host-http.test.mjs`(非图片/视频扩展名一律拒绝) |
|
|
34
|
-
| 只允许 GET、只允许回环地址 | ✅ | `test/host-http.test.mjs` |
|
|
34
|
+
| 只允许 GET、只允许回环地址 | ✅ | `test/host-http.test.mjs`。**v0.21 起有一个例外**:`POST /knit/api/control`(写固定 / 排除),它同样只认回环地址,且只接受 `pin`/`unpin`/`exclude`/`restore` 四个动作 + 一条工作区内的相对路径;非 POST 打这个路由回 405、坏 body 回 400 |
|
|
35
|
+
| 唯一的写动作 = 固定 / 排除,且只写 DSH 给的存储单元 | ✅ | `src/host/control.js` 只通过 `ctx` 注入的 storage 服务读写单元 `knit_control`(`~/.dsh/storages/knit_control.json`,按工作区隔离),**不碰工作区里的任何文件**;`test/control.test.mjs` + `test/host-http.test.mjs` |
|
|
35
36
|
| 响应带 `nosniff` 与 `default-src 'none'; sandbox` | ✅ | `test/host-http.test.mjs`(两个指令各自断言) |
|
|
36
37
|
| 零网络出口:客户端 `fetch` 全部同源相对路径 | ✅ | `src/client/client.js` 的三个接口常量都是 `/knit/api/*`;`test/security.test.mjs` 断言无协议头。HTML 的「网页预览」按钮是把文件交给 **DSH 自己的**文档预览标签页去渲染(Knit 这一侧一个请求都不发),渲染的沙箱与 CSP 归 DSH 管 —— 所以这条承诺不变 |
|
|
37
38
|
| 宿主半边不 import `@deepseek-ai/*` | ✅ | `test/security.test.mjs` 扫三个宿主文件,注释里提到可以、真实 `import` 不行 |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-knit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Task-aware workspace context retrieval and lifecycle tracking for DeepSeek Harness. Finds the documents, source files and media most relevant to the current conversation, organises them into a Context Pack (primary / supporting / related) in the sidebar with inline preview, and tracks which of them were actually read and what changed afterwards. Zero model calls, zero network, nothing leaves the machine.",
|
|
6
6
|
"main": "./src/host/index.js",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
],
|
|
25
25
|
"scripts": {
|
|
26
26
|
"agents:budget": "node tools/agents-budget.mjs",
|
|
27
|
-
"test": "node --test test/host.test.mjs test/host-http.test.mjs test/client.test.mjs test/tier1.test.mjs test/entry.test.mjs test/i18n.test.mjs test/icon.test.mjs test/path.test.mjs test/peek.test.mjs test/eval.test.mjs test/tool.test.mjs test/label.test.mjs test/links.test.mjs test/security.test.mjs test/context.test.mjs test/context-eval.test.mjs test/feedback.test.mjs test/context-delta.test.mjs test/context-feedback-eval.test.mjs test/context-effectiveness.test.mjs test/document-lifecycle.test.mjs test/classification.test.mjs test/code-context.test.mjs test/deep-context.test.mjs test/deep-eval.test.mjs test/deep-scale.test.mjs"
|
|
27
|
+
"test": "node --test test/host.test.mjs test/host-http.test.mjs test/client.test.mjs test/tier1.test.mjs test/entry.test.mjs test/i18n.test.mjs test/icon.test.mjs test/path.test.mjs test/peek.test.mjs test/eval.test.mjs test/tool.test.mjs test/label.test.mjs test/links.test.mjs test/relations.test.mjs test/control.test.mjs test/security.test.mjs test/context.test.mjs test/context-eval.test.mjs test/feedback.test.mjs test/context-delta.test.mjs test/context-feedback-eval.test.mjs test/context-effectiveness.test.mjs test/document-lifecycle.test.mjs test/classification.test.mjs test/code-context.test.mjs test/deep-context.test.mjs test/deep-eval.test.mjs test/deep-scale.test.mjs"
|
|
28
28
|
},
|
|
29
29
|
"dsh": {
|
|
30
30
|
"bundle": {
|