dsh-knit 0.19.1 → 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/README.en.md CHANGED
@@ -37,29 +37,31 @@ network, no latency, nothing leaves the machine.
37
37
  > **which things in this project are worth looking at first for the task at hand — and what
38
38
  > happened to them after they were read.**
39
39
 
40
- ![Screenshot from a real machine: the Knit sidebar left on the Code tab, ranking the workspace source files by relevance, with a code preview expanded in place](https://raw.githubusercontent.com/PolinniZhong/dsh-knit/main/docs/screenshot.png)
40
+ ![Screenshot from a real machine: the Knit sidebar left on the Code tab, each row showing its matched passage, with a code preview expanded in place and stopped on that passage](https://raw.githubusercontent.com/PolinniZhong/dsh-knit/main/docs/screenshot.png)
41
41
 
42
42
  *Screenshot from a real machine, not a mock-up: the same workspace, this one left on the **Code tab** —
43
43
  since v0.19 source files are first-class citizens, just like Markdown.*
44
- *The "why" line under each row says how it matched: a direct hit on the task text, a path hit, or a
45
- workspace hit.*
46
- *Click a row to expand the preview **in place**: here `knit/src/host/classification.js`, with line
47
- numbers; the preview header holds only the path and four actions (copy / full screen / open locally / close).*
44
+ *The sub-row under each row says how it matched (a filename hit, a path hit, …) and **which passage**
45
+ of that file matched this query (`命中段 24–38`).*
46
+ *Click a row to expand the preview **in place**, stopped right on that passage: here
47
+ `knit/src/host/passage.js`, line numbers plus syntax highlighting, with the matched lines under a grey
48
+ band; the preview header holds only the path and four actions (copy / full screen / open locally / close).*
48
49
  *The header holds only the path, one count and two toggles; whether the list runs by
49
50
  relevance or by newest-first is decided by that pair of tabs on the left.*
50
51
  *Since v0.14 the list is always one column: the rank number sits in its own column on the far left
51
52
  (vertically centred on the title's first line), then Primary dot + title + relative time (time on the
52
53
  right), then the summary. **The path lives in the preview header only** — the directory collapses to a `…/` placeholder (hover the path for the full relative path); rows no longer repeat it.*
53
54
 
54
- ![Order follows the conversation: send a message and the sidebar re-ranks the document list by it](https://raw.githubusercontent.com/PolinniZhong/dsh-knit/main/docs/demo-reorder.gif)
55
+ ![Order follows the conversation: send a message and the sidebar re-ranks the list by it, each row showing its matched passage](https://raw.githubusercontent.com/PolinniZhong/dsh-knit/main/docs/demo-reorder.gif)
55
56
 
56
- *Order follows the conversation — same workspace, in a freshly opened session: before you have said
57
- anything, the list runs newest-first; ask "how is BM25 weighted for the ranking?" and the next poll
58
- swaps the top of the list, with the tier headings and the **continuous rank numbers across all
59
- three tiers** appearing alongside a one-line "why" under each row (what matched, and how).*
60
- *In this particular frame no document landed in the primary tier, so the groups start at "supporting".*
61
- *⚠️ The panel polls **every 5 seconds**, so the re-rank lands **0–5 s** after the message rather than
62
- instantly, and the GIF runs faster than real time.*
57
+ *Order follows the conversation — same workspace, in a separate session: the conversation had been
58
+ about a release checklist, so the top of the list was that family of documents; ask
59
+ "how is BM25 weighted for the ranking?" and the list swaps over to the BM25 family, keeping the tier
60
+ headings and the **continuous rank numbers across all tiers**, with a one-line "why" under each row
61
+ (what matched, how, and which passage).*
62
+ *⚠️ The panel polls **every 5 seconds**, so the re-rank is not instantaneous: in this take the top rows
63
+ only swapped once that turn had moved along (the tens of seconds in between were cut out).
64
+ The GIF runs faster than real time.*
63
65
 
64
66
  Scans Markdown / images / video across the project folder · Order follows the conversation · No model calls, no network
65
67
 
@@ -144,6 +146,11 @@ as one of its tabs. Each host is an independent optional dependency; missing one
144
146
  | **Sorted by relevance to the current conversation** (BM25 + IDF, fully local, no model) | ✅ |
145
147
  | **The `knit_docs` tool for the agent**: the model can look up this project's most relevant documents itself | ✅ |
146
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`) | ✅ |
147
154
  | One-click toggle between relevance / modification time (preference kept in localStorage) | ✅ |
148
155
  | Scans **documents and code** in the session workspace (recursive, depth ≤ 6, skips `node_modules` / `.git` / `dist` / `build` / `out` / `coverage`) | ✅ |
149
156
  | Each row shows H1 title (or filename) + relative time + first-paragraph summary | ✅ |
@@ -175,20 +182,21 @@ as one of its tabs. Each host is an independent optional dependency; missing one
175
182
  ![Screenshot of the Media tab: a square thumbnail grid, six columns at this panel width](https://raw.githubusercontent.com/PolinniZhong/dsh-knit/main/docs/screenshot-media.png)
176
183
 
177
184
  *Media: square thumbnails, with the **column count following the panel width continuously** —
178
- six columns at this width, cells about 110px. These are the workspace's real image and SVG files; this
179
- particular workspace happens to hold several screenshots, one demo GIF and one single-colour SVG icon
180
- (the solid black square is that icon, not a failed load). Videos get their first frame as a poster with
181
- a play glyph and a duration badge — this workspace simply has no video, so none shows here.*
185
+ six columns at this width, cells about 110px. These are the workspace's real image and SVG files
186
+ (18 of them in this take); this particular workspace holds several screenshots, a demo GIF and one
187
+ single-colour SVG icon (the solid black square is that icon, not a failed load). Videos get their first
188
+ frame as a poster with a play glyph and a duration badge — this workspace simply has no video, so none
189
+ shows here.*
182
190
 
183
191
  ![Screenshot of the All tab: the documents section, the code section, and the media grid below](https://raw.githubusercontent.com/PolinniZhong/dsh-knit/main/docs/screenshot-all.png)
184
192
 
185
193
  *All: the documents section shows at most 4, the **code section** shows at most 4 (each gets its own
186
- "View all →" when truncated — here "4 / 19" and "4 / 17"), and the media grid comes last.*
194
+ "View all →" when truncated — here "4 / 21" and "4 / 8"), and the media grid (11 rows) comes last.*
187
195
 
188
196
  ⚠️ All three sections share the **same 40-item window** the host returns — a category that ranks past
189
197
  40th by relevance drops out of the All view entirely. This screenshot uses the **Newest** sort: in this
190
198
  workspace, under the default Relevance sort, media rank outside that window every time (at `limit=40`
191
- those 40 rows are 34 documents + 6 code files). The **Media** and **Code** tabs are unaffected — they
199
+ those 40 rows are documents + code files). The **Media** and **Code** tabs are unaffected — they
192
200
  request their own kind. A known defect, with reproduction and the fix recorded in
193
201
  [`docs/README.md`](docs/README.md).*
194
202
 
@@ -305,11 +313,122 @@ Current task -> Workspace Retrieval -> Document + Code Candidates
305
313
  version, not recall.
306
314
  - **The type tabs become four**: `Docs / Code / Media / All`. The Code tab is **still driven by the
307
315
  current task** — it is not a file tree of the project.
316
+ - **Syntax highlighting is DSH's own (v0.20)** — the client reuses
317
+ `useCodeHighlighter` from `@deepseek-ai/dsh-client-ui-primitives` and takes every colour from the
318
+ official `--shiki-*` tokens, so light and dark match DSH instead of inventing a palette. Only the
319
+ matched stretch is coloured (60 lines either side, window capped at 800) and the rest stays plain
320
+ text — a file with no match gets no colour at all (an un-capped 4k-line file
321
+ costs ~2 s); if the host does not export the hook (older DSH) or the line counts disagree, it falls
322
+ back to plain text silently.
308
323
  - **No second engine**: no second retrieval path, no second lifecycle, no second store, no new
309
324
  dependencies, no AST, no LSP, no embedding, no model call, no network, no IDE.
310
325
 
311
326
  ---
312
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
+
313
432
  ## Also for the agent: the `knit_docs` tool
314
433
 
315
434
  The same ranking that you see in the panel is also exposed to the model.
@@ -319,7 +438,8 @@ project are most relevant to what we're discussing?"* and get back **the same Co
319
438
  panel shows — the `primary` / `supporting` / `related` tiers, each item carrying its path, title,
320
439
  summary, a **structured reason** (`direct` / `titleMatch` / `summaryMatch` / `bodyMatch` /
321
440
  `linkTarget` / `linkSource` / `related`), its **project role** (`impl` / `test` / `config` /
322
- `design` / `doc`) and the matching snippet — then open one of them with its own `read` tool.
441
+ `design` / `doc`) and the matching snippet **with its line range** (`match: lines 147–163 — …`) —
442
+ then open one of them with its own `read` tool.
323
443
 
324
444
  **Why it helps**: to cite a document that already exists, an agent can only guess paths or glob
325
445
  and `read` them one by one. Knit has **already computed that ranking** every refresh; this tool
@@ -335,7 +455,12 @@ Three details:
335
455
  - **No relevance score in the result.** It is a *relative* score (something is always 100%, and it
336
456
  may be a different document on the next refresh); shown to a model it reads as absolute confidence.
337
457
  **The order is the relevance** — the same rule the panel follows.
338
- - **No document bodies.** The agent has its own `read` tool; Knit *finds*, it does not *carry*.
458
+ - **The whole file is searched** (since v0.20). Every file is split into structural passages and each
459
+ passage is scored, so "the relevant part is past the first 2,500 characters" no longer means
460
+ "unfindable"; a file over 256 KB is indexed only up to that size, and media has no text — both
461
+ boundaries are stated in the output rather than hidden.
462
+ - **No document bodies.** Only the matched passage (one per file at most, ≤200 characters) — the agent
463
+ has its own `read` tool; Knit *finds*, it does not *carry*.
339
464
  - **No workspace means an error, never a fallback.** The HTTP route falls back to the process cwd
340
465
  when a session can't be resolved (for older clients that send no session id); the tool has no such
341
466
  baggage — falling back would scan an unrelated project and return *its* documents.
@@ -537,7 +662,7 @@ Newer messages weigh more: 3 / 2 / 1 / 1 …
537
662
  ```
538
663
  IDF per term first: rarer in the corpus means more valuable
539
664
  ln(1 + (N - df + 0.5) / (df + 0.5))
540
- then a weighted sum over fields: title ×4 + summary ×2 + first 2500 chars of body ×1
665
+ then a weighted sum over fields: title ×4 + summary ×2 + the whole body ×1
541
666
  each field saturated and length-normalised (k1 = 1.2, b = 0.3 / 0.5 / 0.75)
542
667
  plus a 10% recency nudge (relevance still dominates)
543
668
  ```
@@ -674,7 +799,7 @@ feature request.
674
799
  git clone https://github.com/PolinniZhong/dsh-knit.git
675
800
  cd dsh-knit
676
801
 
677
- npm test # 588 tests, zero dependencies, no npm install needed
802
+ npm test # 641 tests, zero dependencies, no npm install needed
678
803
  ```
679
804
 
680
805
  **How changes take effect**: the host half (`src/host/`) **requires a DSH restart** (no hot reload);
@@ -695,11 +820,12 @@ knit/
695
820
  │ ├── host/relevance.js # the relevance engine: BM25 + keyword extraction
696
821
  │ ├── host/links.js # reference parsing (pure; never touches ranking)
697
822
  │ ├── host/classification.js # v0.19 file classification: kind / language / searchable / contextual
823
+ │ ├── host/passage.js # passage layer: chunking / passage scoring / line mapping (pure, zero I/O)
698
824
  │ ├── host/context.js # context assembly: the three-tier Context Pack (pure, zero I/O)
699
825
  │ ├── host/feedback.js # usage feedback: read-time attribution / Context Epoch / delta (pure)
700
826
  │ ├── host/tool.js # the agent tool knit_docs (hand-written ToolDefinition)
701
827
  │ └── client/client.js # dual-host registration + panel UI
702
- └── test/ # 588 tests
828
+ └── test/ # 641 tests
703
829
  ├── eval/ # retrieval quality: corpus + cases + frozen v0.5.2 baseline
704
830
  └── context/ # context tiering: 24-doc corpus + 12 real-task cases
705
831
  ```
package/README.md CHANGED
@@ -34,24 +34,26 @@ Knit 接的是**当前任务**和**整个工作区**之间那一层:从工作
34
34
  > 最近文件记的是「你点开过什么、哪个更新」;Knit 回答的是
35
35
  > **当前这个任务,项目里哪些东西最值得先看 —— 以及看过之后,事情变成了什么样。**
36
36
 
37
- ![Knit 面板真机截图:右侧栏停在「代码」档,按相关性列出工作区源码,就地展开代码预览](https://raw.githubusercontent.com/PolinniZhong/dsh-knit/main/docs/screenshot.png)
37
+ ![Knit 面板真机截图:右侧栏停在「代码」档,每行标出命中段,就地展开代码预览并停在那一段](https://raw.githubusercontent.com/PolinniZhong/dsh-knit/main/docs/screenshot.png)
38
38
 
39
39
  *真机截图(不是原型):同一个工作区,这张停在 **「代码」档** —— v0.19 起,源码和 Markdown 一样是一等公民。*
40
- *每行下面的「为什么」写着它是怎么被命中的(`直接命中:knit · readme` / `路径命中:knit · path` / `直接命中:knit · 工作区`)。*
41
- *点一行**就地**展开预览:这里是 `knit/src/host/classification.js`,带行号;预览头里只有路径和四个动作(复制 / 全屏 / 本地打开 / 关闭)。*
40
+ *每行下面的副行写着它是怎么被命中的(`直接命中 classification · changelog` / `路径命中 agents · classification`),*
41
+ *以及**命中段** —— 这次查询在这份文件里最像的是哪一段(`命中段 24–38`)。*
42
+ *点一行**就地**展开预览,并且**直接停在那一段**上:这里是 `knit/src/host/passage.js`,行号栏 + 语法高亮,*
43
+ *命中的那几行带一条灰底横带;预览头里只有路径和四个动作(复制 / 全屏 / 本地打开 / 关闭)。*
42
44
  *头部只放路径、一个计数与两个开关;列表按「相关」还是「最新」排,由左边那一对页签决定 —— 按「相关」时排的就是你正在聊什么。*
43
- *v0.14 起文档列表永远单列:最左边独立一列是序号(与标题第一行垂直居中),右边第一行=*
45
+ *v0.14 起列表永远单列:最左边独立一列是序号(与标题第一行垂直居中),右边第一行=*
44
46
  *Primary 点 + 标题 + 相对时间(**时间靠右**),摘要再往下;**路径只出现在预览头里**(目录收敛成一个 `…/` 占位,完整相对路径在悬停提示里),列表行不再重复。*
45
47
  *序号是**跨三档连续**的一条(先看 / 辅助 / 背景);「其他相关文档」不在包里、不编号,那一格用一个 `·` 占位 ——*
46
48
  *空着会被读成「漏了一个号」(2026-10-01)。*
47
49
 
48
- ![排序跟着对话走:发一句话,右侧栏的文档列表按这句话重排](https://raw.githubusercontent.com/PolinniZhong/dsh-knit/main/docs/demo-reorder.gif)
50
+ ![排序跟着对话走:发一句话,右侧栏的列表按这句话重排,并标出各自的命中段](https://raw.githubusercontent.com/PolinniZhong/dsh-knit/main/docs/demo-reorder.gif)
49
51
 
50
- *排序跟着对话走(同一个工作区、刚新开一个会话):还没聊什么时,列表按修改时间排;*
51
- *问一句「排序算法用的 BM25 是怎么加权的?」,下一次轮询就把顶上几条整个换掉 ——*
52
- *分组标题与**跨三档连续的序号**随之一起出现,每篇下面多一行「为什么」(命中在哪、怎么命中的)。*
53
- *这一屏里没有文档落进主要层,所以分组从「辅助上下文」开始。*
54
- *⚠️ 面板是**每 5 秒轮询一次**的,所以重排落在发消息之后的 **0–5 秒**内、不是瞬时;动图比真实时间快。*
52
+ *排序跟着对话走(同一个工作区、新开的一个会话):聊天里先聊过一轮发布清单,顶上几条就是发布清单那一族;*
53
+ *再问一句「Knit 里 BM25 的字段权重是怎么定的?」,列表整个换成 BM25 那一族 ——*
54
+ *分组标题与**跨三档连续的序号**随之一起出现,每篇下面多一行「为什么」(命中在哪、怎么命中的、命中段是哪一段)。*
55
+ *⚠️ 面板是**每 5 秒轮询一次**的,重排不是发消息那一瞬间:这一屏里顶上几条是这一轮对话推进之后才整个换掉的*
56
+ *(中间那几十秒被剪掉了)。动图比真实时间快。*
55
57
 
56
58
  扫整个项目文件夹的文档 / 代码 / 图片 / 视频 · 排序跟着对话走 · 不调模型、不联网
57
59
 
@@ -131,6 +133,11 @@ dsh plugin --profile web add dsh-knit
131
133
  |---|---|
132
134
  | **按当前对话相关性排序**(BM25 + IDF,纯本地,零模型) | ✅ |
133
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 个代码文件`) | ✅ |
134
141
  | **给 agent 用的 `knit_docs` 工具**:让模型拿回**三层任务上下文**(不是一条平铺列表) | ✅ |
135
142
  | **文档生命周期**(v0.17):每篇推荐文档现在处于 `未读 / 已读 / 读后已更新 / 修改后已重新读取` 哪一档,另外给出最近读了哪篇、包外读了哪几篇、上下文最近一次怎么变 | ✅ |
136
143
  | 相关性 / 修改时间双模式一键切换(偏好记在 localStorage) | ✅ |
@@ -142,7 +149,7 @@ dsh plugin --profile web add dsh-knit
142
149
  | 单击就地展开预览,再点收起 | ✅ |
143
150
  | 相对路径图片真正渲染(`./img/a.png`、`../assets/b.png`) | ✅ |
144
151
  | **代码上下文**(v0.19):`.js .mjs .cjs .ts .tsx .jsx .py .json .html .htm .css .scss .yaml .yml .sh .bash .zsh` 与 Markdown **进同一个检索池**,共用同一份 BM25、同一个 Context Pack、同一套生命周期 —— 不是第二套「代码搜索」 | ✅ |
145
- | **文档 / 代码 / 媒体 / 全部** 四类一键切换(偏好记住,默认仍是文档,老体验不变);选中态是**中性灰填充**,不带品牌色描边(页签「媒体」2026-10-06 由「图片与视频」改短,「代码」v0.19 加入) | ✅ |
152
+ | **文档 / 代码 / 媒体 / 全部** 四类一键切换(偏好记住,默认仍是文档,老体验不变);选中态是**下划线式页签**(v0.14 起就是这个;不带品牌色描边、也**没**退回灰底按钮 —— 2026-09-29 明确裁定过;页签「媒体」2026-10-06 由「图片与视频」改短,「代码」v0.19 加入) | ✅ |
146
153
  | 图片与视频:方形缩略图网格,**格子基准固定 104px、列数由宽度连续数出来**(320px → 2 列 / 632px → 5 列 / 1200px → 10 列),格子大小基本不变;**纵向有多少行就铺多少行**,超出交给列表滚动;视频自动取首帧、叠播放三角与时长角标(零依赖、不转码) | ✅ |
147
154
  | 点图片 / 视频在面板内**就地预览**:图片大图、视频可播放可拖动(HTTP Range 流式,不全量下载) | ✅ |
148
155
  | 「全部」视图**分上下两区**:文档最多 4 条(超出给「查看全部 →」);图片视频**不截断**,只给计数 | ✅ |
@@ -166,16 +173,16 @@ dsh plugin --profile web add dsh-knit
166
173
  ![媒体档真机截图:方形缩略图网格,这一屏 6 列](https://raw.githubusercontent.com/PolinniZhong/dsh-knit/main/docs/screenshot-media.png)
167
174
 
168
175
  *媒体:方形缩略图,**列数跟着面板宽度连续变** —— 这一屏是 6 列,格子约 110px。*
169
- *列出的就是工作区里真实的图片与 SVG 文件 —— 这个工作区正好有几张截图、一张演示动图和一个*
170
- *单色 SVG 图标,所以看起来像一屏文件缩略图(那个纯黑方块就是图标本身,不是加载失败)。*
176
+ *列出的就是工作区里真实的图片与 SVG 文件(这一屏 18 个媒体),所以看起来像一屏文件缩略图*
177
+ *(那个纯黑方块是单色 SVG 图标本身,不是加载失败)。*
171
178
  *视频会取首帧当海报、中央叠播放三角、右下角叠时长,只是这个工作区里没有视频,所以这一屏看不到。*
172
179
 
173
180
  ![全部档真机截图:上区文档只给前 4 条与「查看全部 →」,中间是代码区,下区是媒体网格](https://raw.githubusercontent.com/PolinniZhong/dsh-knit/main/docs/screenshot-all.png)
174
181
 
175
- *全部:**文档区最多 4 条**、**代码区最多 4 条**(超出时各区右侧给「查看全部 →」,这一屏是「4 / 19」与「4 / 17」),最后是媒体网格。*
182
+ *全部:**文档区最多 4 条**、**代码区最多 4 条**(超出时各区右侧给「查看全部 →」,这一屏是「4 / 21」与「4 / 8」),最后是媒体网格(11 条)。*
176
183
  *⚠️ 三个区共用宿主返回的**同一个 40 条窗口**:某一类如果按相关性排到第 40 名之外,「全部」档就整个看不到它。*
177
184
  *这张图用的是**「最新」排序** —— 在这个工作区里,默认的「相关」排序下媒体恒定掉在 40 条窗口之外*
178
- *(`limit=40` 时那 40 条全是 34 篇文档 + 6 个代码文件)。**「媒体」/「代码」档不受影响**,它们各自单独取。*
185
+ *(`limit=40` 时那 40 条全是文档 + 代码)。**「媒体」/「代码」档不受影响**,它们各自单独取。*
179
186
  *这是已知缺陷,复现与修法记在 [`docs/README.md`](docs/README.md)。*
180
187
 
181
188
  ---
@@ -315,12 +322,95 @@ Markdown 仍是 `title ×4 / summary ×2 / body ×1`。**两套字段权重,
315
322
 
316
323
  点一个代码文件,就在**面板下方就地展开**(和 Markdown 一模一样的位置、一样的交互,
317
324
  没有新的弹窗):行号 + 等宽字体 + 横向滚动,页脚给复制与「本地打开」。
318
- 不做语法高亮、不做代码折叠、不做多标签、不做 git diff —— **Knit 不是代码浏览器**。
325
+ **有语法高亮,但用的是 DSH 自己的那一套**(v0.20,2026-10-07 按用户要求改):客户端复用
326
+ `@deepseek-ai/dsh-client-ui-primitives` 的 `useCodeHighlighter`,颜色全部来自官方的 `--shiki-*` 令牌
327
+ ⇒ **浅色 / 暗色都跟 DSH 一致**,不自己造一套配色。**只给命中段那一带上色**(前后各 60 行,窗口
328
+ 最多 800 行),其余行保持默认正文色 —— 没有命中段的文件一个 token 都不上色(高亮要跑同步分词,
329
+ 4 千行整篇着色要 2 秒量级);宿主没导出这个 hook(旧版 DSH)或行数对不上 ⇒ 静默回落纯文本。
330
+ 不做代码折叠、不做多标签、不做 git diff —— **Knit 不是代码浏览器**。
319
331
 
320
332
  同类入口还有:双击进官方标签页预览(带 DSH 自己的渲染器)、`Esc` 收起、键盘 `↑↓` 预览。
321
333
 
322
334
  ---
323
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
+
324
414
  ## 也给 agent 用:`knit_docs` 工具
325
415
 
326
416
  同一份排序,除了给你看,也开了一个口子给模型。
@@ -330,7 +420,10 @@ Markdown 仍是 `title ×4 / summary ×2 / body ×1`。**两套字段权重,
330
420
  `primary` / `supporting` / `related` 三层,每项带路径 + 标题 + 摘要 +
331
421
  **结构化理由**(`direct` / `summaryMatch` / `bodyMatch` / `linkTarget` / `linkSource` / `related`)
332
422
  + **项目角色**(`impl` / `test` / `config` / `design` / `doc`)+
333
- 命中的那一小段原文,再用它自己的 `read` 打开其中一篇。
423
+ + **来源三值**(`provenance`:`retrieval` / `relation` / `manual`)+ **最多 2 条关系**
424
+ (`relations: references ← docs/x.md:12; imports → src/y.js:3`,`←` 是对方提到本条目)+ 被固定的条目在
425
+ `pinned` 分区里、被排除的条目完全不出现(v0.21)+
426
+ 命中的那一小段原文**和它的行号区间**(`match: lines 147–163 — …`),再用它自己的 `read` 打开其中一篇。
334
427
 
335
428
  **为什么有用**:agent 想引用项目里已有的文档时,只能靠猜路径、或者把 `glob`
336
429
  出来的路径一个个 `read` 试过去。这份排序 Knit **每一轮已经算好了**,这个工具只是把它交出去 ——
@@ -346,7 +439,10 @@ Knit 一装上就有整个项目的历史文档可用。
346
439
  没有两套排序逻辑,也没有两份规则。
347
440
  - **不返回相关度分数**。它是**相对**分数(永远有一篇 100%,每次刷新可能换人当),
348
441
  给模型看会被当成绝对置信度去推理。**顺序即相关度** —— 与面板同一条规矩。
349
- - **不返回正文**。agent 有自己的 `read` 工具;Knit 负责**发现**,不负责**搬运**。
442
+ - **搜的是全文**(v0.20 起)。每篇文件都按结构切成分片、逐片打分,所以「相关内容在前 2500 字之后」
443
+ 不再等于「搜不到」;单文件超过 256 KB 时只索引到那里,媒体没有正文 —— 这两条边界会在输出里如实说明。
444
+ - **不返回正文**。只给命中片段(每篇最多一段、≤200 字符),agent 有自己的 `read` 工具;
445
+ Knit 负责**发现**,不负责**搬运**。
350
446
  - **拿不到会话就报错,不兜底**。HTTP 路由在会话查不到时会兜底到进程 cwd
351
447
  (兼容不带 sessionId 的老客户端),工具**没有这个包袱** ——
352
448
  兜底只会扫到一个不相干的项目并返回它的文档。宁可报错,也不返回错的东西。
@@ -516,7 +612,7 @@ v0.17 的信息都在,但**摞在一行字和几个折叠块里**,读不出
516
612
 
517
613
  ```
518
614
  每个词先算 IDF:在语料里越罕见越值钱 ln(1 + (N - df + 0.5) / (df + 0.5))
519
- 再按字段加权求和:标题 ×4 + 摘要 ×2 + 正文前 2500 字 ×1
615
+ 再按字段加权求和:标题 ×4 + 摘要 ×2 + 正文 ×1
520
616
  每个字段都按 BM25 饱和 + 长度归一化(k1 = 1.2,b = 0.3 / 0.5 / 0.75)
521
617
  再叠 10% 的时间新鲜度微调(主排序仍是相关性)
522
618
  ```
@@ -643,7 +739,8 @@ v0.17 的信息都在,但**摞在一行字和几个折叠块里**,读不出
643
739
  git clone https://github.com/PolinniZhong/dsh-knit.git
644
740
  cd dsh-knit
645
741
 
646
- npm test # 588 项,零依赖,不需要先 npm install
742
+ npm test # 697 项,零依赖,不需要先 npm install
743
+ node tools/clean-room-test.mjs # 发版前闸门:npm pack → 解包 → 在解包目录里再跑一遍测试
647
744
  ```
648
745
 
649
746
  **改动生效方式**:宿主半边(`src/host/`)改了**必须重启 DSH**(实测不热加载);
@@ -664,12 +761,15 @@ knit/
664
761
  │ ├── host/classification.js # 文件分类层:kind / language / 能力位(纯函数,零 I/O)
665
762
  │ ├── host/relevance.js # 相关性引擎:BM25 + 关键词抽取(纯函数)
666
763
  │ ├── host/links.js # 引用关系解析(纯解析,不碰排序)
764
+ │ ├── host/relations.js # 关系事实层:引用 / 导入 / 测试 / 文档(纯函数,零 I/O)
765
+ │ ├── host/passage.js # 内容片段层:切分 / 片段打分 / 行号映射(纯函数,零 I/O)
667
766
  │ ├── host/context.js # 上下文装配:Context Pack 三层(纯函数,零 I/O)
767
+ │ ├── host/control.js # 固定 / 排除:纯逻辑 + 可选 ctx.storage 持久化
668
768
  │ ├── host/feedback.js # 使用反馈:读时归因 / Context Epoch / Delta(纯逻辑,只读事件流)
669
769
  │ ├── host/tool.js # agent 文档工具 knit_docs(手写 ToolDefinition)
670
770
  │ └── client/client.js # 双宿主注册 + 面板 UI
671
- └── test/ # 588 项测试
672
- ├── eval/ # 检索质量评测:语料 + 用例 + 冻结的 v0.5.2 基线
771
+ └── test/ # 697 项测试
772
+ ├── eval/ # 检索质量评测:语料 + 用例 + 冻结的 v0.5.2 基线 + Deep Context 四指标
673
773
  └── context/ # 上下文分层评测:24 篇语料 + 12 条任务型用例
674
774
  ```
675
775
 
package/SECURITY.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  > **Knit 的安全属性 —— 每一条都指向一个真实存在的检查。**
4
4
  >
5
- > 最后更新:2026-10-07(v0.19.1)
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` 不行 |
@@ -47,6 +48,6 @@ Knit 的安全属性其实一直成立 —— 但它们此前只散落在文档
47
48
  ## 如何自己复核
48
49
 
49
50
  ```sh
50
- npm test # 588 项,含本节所有断言
51
+ npm test # 641 项,含本节所有断言
51
52
  npm test -- test/security.test.mjs # 只跑安全守卫
52
53
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-knit",
3
- "version": "0.19.1",
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",
@@ -23,7 +23,8 @@
23
23
  "LICENSE"
24
24
  ],
25
25
  "scripts": {
26
- "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"
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/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"
27
28
  },
28
29
  "dsh": {
29
30
  "bundle": {