dsh-knit 0.9.0 → 0.12.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/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "dsh-knit",
3
- "version": "0.9.0",
3
+ "version": "0.12.0",
4
4
  "type": "module",
5
- "description": "Find the doc your agent just wrote. Lists the DSH workspace's Markdown, images and video in the sidebar, ranked by relevance to the current conversation, with inline preview. Zero model calls, zero network.",
5
+ "description": "Find the doc your agent just wrote. Lists the DSH workspace's Markdown, images and video in the sidebar, ranked by relevance to the current conversation, with inline preview — and hands the same ranking to the agent as a tool, returning the passage that matched in each document. Zero model calls, zero network.",
6
6
  "main": "./src/host/index.js",
7
7
  "exports": {
8
8
  ".": "./src/host/index.js",
@@ -15,11 +15,13 @@
15
15
  "src",
16
16
  "test",
17
17
  "cordis.patch.yml",
18
+ "CHANGELOG.md",
18
19
  "README.md",
20
+ "SECURITY.md",
19
21
  "LICENSE"
20
22
  ],
21
23
  "scripts": {
22
- "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"
24
+ "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"
23
25
  },
24
26
  "dsh": {
25
27
  "bundle": {
@@ -81,11 +81,19 @@ window.__ModuleLoader__.load({
81
81
  'preview.exitFullscreen': '退出全屏',
82
82
  'preview.fullscreenTitle': '全屏阅读',
83
83
  'preview.exitFullscreenTitle': '退出全屏(Esc)',
84
- 'preview.newTab': '新标签页',
85
- 'preview.newTabTitle': '在新标签页打开',
86
84
  'preview.openLocal': '{path}\n用系统默认应用打开这篇文档',
85
+ 'preview.openLocalBtn': '在本地打开',
87
86
  'preview.close': '收起预览',
88
87
  'preview.resizeTitle': '拖动调整高度',
88
+ // v0.12 引用条。⚠️ 不放任何表情符号(test/i18n.test.mjs 有守卫)。
89
+ 'links.summary': '被引用 {in} · 引用了 {out}',
90
+ 'links.incoming': '被引用',
91
+ 'links.outgoing': '引用了',
92
+ 'links.noneIn': '没有被引用',
93
+ 'links.noneOut': '没有引用别的文档',
94
+ 'links.more': '还有 {count} 篇',
95
+ 'links.failed': '引用关系读取失败',
96
+ 'links.incomplete': '工作区较大,结果可能不完整',
89
97
  'preview.rawFallback': '原生 Markdown 渲染不可用,下面是纯文本。请看控制台的 [knit] 日志。',
90
98
  'code.copy': '复制',
91
99
  'code.copied': '已复制',
@@ -171,11 +179,18 @@ window.__ModuleLoader__.load({
171
179
  'preview.exitFullscreen': 'Exit fullscreen',
172
180
  'preview.fullscreenTitle': 'Read fullscreen',
173
181
  'preview.exitFullscreenTitle': 'Exit fullscreen (Esc)',
174
- 'preview.newTab': 'New tab',
175
- 'preview.newTabTitle': 'Open in a new tab',
176
182
  'preview.openLocal': '{path}\nOpen this document in your default app',
183
+ 'preview.openLocalBtn': 'Open locally',
177
184
  'preview.close': 'Close preview',
178
185
  'preview.resizeTitle': 'Drag to resize',
186
+ 'links.summary': 'Referenced by {in} · links to {out}',
187
+ 'links.incoming': 'Referenced by',
188
+ 'links.outgoing': 'Links to',
189
+ 'links.noneIn': 'Not referenced by anything',
190
+ 'links.noneOut': 'Links to no other document',
191
+ 'links.more': '{count} more',
192
+ 'links.failed': 'Could not read references',
193
+ 'links.incomplete': 'Large workspace — results may be incomplete',
179
194
  'preview.rawFallback': 'Native Markdown rendering is unavailable — showing plain text. Check the [knit] logs in the console.',
180
195
  'code.copy': 'Copy',
181
196
  'code.copied': 'Copied',
@@ -285,6 +300,9 @@ window.__ModuleLoader__.load({
285
300
  const LIST_API = '/knit/api/recent'
286
301
  const DOC_API = '/knit/api/doc'
287
302
  const RAW_API = '/knit/api/raw'
303
+ // v0.12:某篇的「谁引用了它 / 它引用了谁」。与上面三条一样是**同源相对地址**,
304
+ // 所以仍然满足「客户端零网络出口」那条守卫(test/security.test.mjs)。
305
+ const LINKS_API = '/knit/api/links'
288
306
 
289
307
  /** 轮询间隔。 */
290
308
  const POLL_MS = 5000
@@ -531,6 +549,32 @@ body[data-ds-dark-theme] .knit-preview{box-shadow:0 -8px 24px rgba(0,0,0,.38)}
531
549
  color:var(--dsw-alias-label-secondary,#9aa0a6);font-family:ui-monospace,SFMono-Regular,Menlo,monospace}
532
550
  .knit-preview-note{font-size:11px;color:var(--dsw-alias-label-caption,#80868b);padding:2px 0 8px}
533
551
 
552
+ /* ── 引用条(v0.12)────────────────────────────────────
553
+ 夹在预览头与正文之间的一层。全用中性令牌:它是「信息」,不是「操作」。
554
+ 注意 CSS 里不要写反引号 —— 这段样式是模板字符串,一个反引号就会把它截断。 */
555
+ .knit-links{flex:none;border-bottom:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.08));
556
+ font-size:11px;color:var(--dsw-alias-label-secondary,#9aa0a6)}
557
+ .knit-links-state{padding:5px 12px;color:var(--dsw-alias-label-caption,#80868b)}
558
+ .knit-links-head{box-sizing:border-box;display:flex;align-items:center;gap:6px;width:100%;
559
+ padding:5px 12px;background:transparent;border:none;cursor:pointer;text-align:left;
560
+ font:inherit;color:inherit}
561
+ .knit-links-head:hover{background:var(--knit-hover-bg,rgba(255,255,255,.03))}
562
+ .knit-links-arrow{flex:none;width:10px;font-size:9px;opacity:.75}
563
+ .knit-links-summary{flex:1 1 auto;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
564
+ .knit-links-note{padding:2px 12px 6px;color:var(--dsw-alias-label-caption,#80868b)}
565
+ .knit-links-body{padding:0 12px 8px;max-height:180px;overflow:auto}
566
+ .knit-links-group + .knit-links-group{margin-top:6px}
567
+ .knit-links-label{font-weight:600;color:var(--dsw-alias-label-caption,#80868b);margin-bottom:2px}
568
+ .knit-links-empty{color:var(--dsw-alias-label-caption,#80868b);padding:1px 0}
569
+ .knit-links-list{list-style:none;margin:0;padding:0}
570
+ .knit-link-row{box-sizing:border-box;display:block;width:100%;text-align:left;padding:2px 4px;
571
+ border:none;background:transparent;border-radius:4px;cursor:pointer;font:inherit;color:inherit}
572
+ .knit-link-row:hover{background:var(--knit-hover-bg,rgba(255,255,255,.03))}
573
+ .knit-link-name{display:block;color:var(--dsw-alias-label-primary,#e8eaed);
574
+ overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
575
+ .knit-link-path{display:block;font-size:10px;color:var(--dsw-alias-label-caption,#80868b);
576
+ overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
577
+
534
578
  /* ── 类型切换(文档 / 图片与视频 / 全部)────────────── */
535
579
  /* 选中态与下面的列表行、上面的排序切换共用一套中性灰填充,**不要品牌色描边**:
536
580
  用户的原话是「选中的时候不用加绿色、蓝色的描边,就跟下面列表一样,
@@ -987,13 +1031,79 @@ body[data-ds-dark-theme] .knit-icon{color:#fff}
987
1031
 
988
1032
  /**
989
1033
  * 列表下方的预览面板。
990
- * @param {{preview:object,pathImages:object|null,fullscreen:boolean,onClose:Function,onOpenTab:Function,onToggleFullscreen:Function,onResizeStart:Function}} props - 渲染入参
1034
+ * @param {{preview:object,pathImages:object|null,fullscreen:boolean,onClose:Function,onOpenLocal:Function|null,onToggleFullscreen:Function,onResizeStart:Function}} props - 渲染入参
991
1035
  * @returns {import('react').ReactElement} 元素
992
1036
  */
993
- function PreviewPanel({ preview, pathImages, fullscreen, ratio, reading, onClose, onOpenTab, onOpenLocal, onToggleFullscreen, onResizeStart, onScrollBody }) {
1037
+ function PreviewPanel({ preview, pathImages, fullscreen, ratio, reading, links, linksExpanded, onToggleLinks, onOpenLink, onClose, onOpenLocal, onToggleFullscreen, onResizeStart, onScrollBody }) {
994
1038
  const isMedia = preview.kind === 'image' || preview.kind === 'video'
995
1039
  const previewPath = splitRelPath(preview.rel)
996
1040
 
1041
+ /* ── v0.12 引用条 ────────────────────────────────────
1042
+ * 位置:预览头**下面**、正文**上面** —— 一条可折叠的窄条。
1043
+ *
1044
+ * 为什么不塞进正文:正文是 Markdown 渲染的,插进去会**被滚动带走**,
1045
+ * 还容易跟渲染器打架。预览头也放不下(38px 里已经有面包屑 + 三个按钮 + 拖拽把手)。
1046
+ *
1047
+ * 默认**折叠**,只显示两个计数,展开才占高度。空态与失败态文案**分开** ——
1048
+ * 「没有被引用」是一个结论,「读取失败」是另一个,不能都显示成空白。
1049
+ */
1050
+ const linkItems = (title, items, emptyText) => h('div', { className: 'knit-links-group' },
1051
+ h('div', { className: 'knit-links-label' }, title),
1052
+ items.length === 0
1053
+ ? h('div', { className: 'knit-links-empty' }, emptyText)
1054
+ : h('ul', { className: 'knit-links-list' },
1055
+ items.map((item) => h('li', { key: item.rel },
1056
+ h('button', {
1057
+ type: 'button',
1058
+ className: 'knit-link-row',
1059
+ title: item.rel,
1060
+ onClick: () => onOpenLink(item),
1061
+ },
1062
+ h('span', { className: 'knit-link-name' }, item.title),
1063
+ h('span', { className: 'knit-link-path' }, item.rel))))))
1064
+
1065
+ const linksBar = (() => {
1066
+ if (!links || !onToggleLinks) return null
1067
+ if (links.status === 'loading') {
1068
+ return h('div', { className: 'knit-links' },
1069
+ h('div', { className: 'knit-links-state' }, t('preview.loading')))
1070
+ }
1071
+ if (links.status !== 'ready') {
1072
+ return h('div', { className: 'knit-links' },
1073
+ h('div', { className: 'knit-links-state' }, t('links.failed')))
1074
+ }
1075
+ const incoming = links.incoming || []
1076
+ const outgoing = links.outgoing || []
1077
+ return h('div', { className: `knit-links${linksExpanded ? ' is-open' : ''}` },
1078
+ h('button', {
1079
+ type: 'button',
1080
+ className: 'knit-links-head',
1081
+ 'aria-expanded': linksExpanded ? 'true' : 'false',
1082
+ onClick: onToggleLinks,
1083
+ title: links.rel,
1084
+ },
1085
+ h('span', { className: 'knit-links-arrow' }, linksExpanded ? '▾' : '▸'),
1086
+ h('span', { className: 'knit-links-summary' },
1087
+ t('links.summary', { in: links.incomingTotal || 0, out: links.outgoingTotal || 0 }))),
1088
+ links.limited
1089
+ ? h('div', { className: 'knit-links-note' }, t('links.incomplete'))
1090
+ : null,
1091
+ linksExpanded
1092
+ ? h('div', { className: 'knit-links-body' },
1093
+ linkItems(t('links.incoming'), incoming, t('links.noneIn')),
1094
+ linkItems(t('links.outgoing'), outgoing, t('links.noneOut')),
1095
+ (links.incomingTotal > incoming.length || links.outgoingTotal > outgoing.length)
1096
+ ? h('div', { className: 'knit-links-note' },
1097
+ t('links.more', {
1098
+ count: Math.max(
1099
+ (links.incomingTotal || 0) - incoming.length,
1100
+ (links.outgoingTotal || 0) - outgoing.length,
1101
+ ),
1102
+ }))
1103
+ : null)
1104
+ : null)
1105
+ })()
1106
+
997
1107
  // 图片/视频不读正文,直接用同源字节地址渲染;Markdown 才走加载 / MarkdownText / 降级。
998
1108
  const body = preview.status === 'loading'
999
1109
  ? h('div', { className: 'knit-preview-note' }, t('preview.loading'))
@@ -1048,8 +1158,19 @@ body[data-ds-dark-theme] .knit-icon{color:#fff}
1048
1158
  onClick: onToggleFullscreen,
1049
1159
  title: fullscreen ? t('preview.exitFullscreenTitle') : t('preview.fullscreenTitle'),
1050
1160
  }, fullscreen ? t('preview.exitFullscreen') : t('preview.fullscreen')),
1051
- h('button', { className: 'knit-btn', onClick: onOpenTab, title: t('preview.newTabTitle') }, t('preview.newTab')),
1161
+ // 「在本地打开」= 之前那个「新标签页」的位置(v0.10)。
1162
+ // 「新标签页」开的是官方文档预览,但面板里已经有就地预览,重复度高、用得少;
1163
+ // 而「用默认应用打开这篇文档」原本只藏在路径面包屑的悬停提示里 ——
1164
+ // 把值钱的那个放到显眼处,把鸡肋的那个让位(双击列表行仍能开新标签页)。
1165
+ h('button', {
1166
+ className: 'knit-btn',
1167
+ onClick: () => { if (onOpenLocal) onOpenLocal() },
1168
+ disabled: !onOpenLocal,
1169
+ title: onOpenLocal ? t('preview.openLocal', { path: preview.rel }) : preview.rel,
1170
+ }, t('preview.openLocalBtn')),
1052
1171
  h('button', { className: 'knit-preview-close', onClick: onClose, title: t('preview.close') }, '✕')),
1172
+ // v0.12 引用条:夹在头与正文之间,不参与正文滚动
1173
+ linksBar,
1053
1174
  h('div', {
1054
1175
  className: `knit-preview-body${isMedia ? ' is-media' : ''}`,
1055
1176
  onScroll: onScrollBody,
@@ -1095,6 +1216,12 @@ body[data-ds-dark-theme] .knit-icon{color:#fff}
1095
1216
  // 阅读态也不会丢。放在最后,不动前面任何 hook 的槽位。
1096
1217
  const [readingTick, setReadingTick] = React.useState(0)
1097
1218
 
1219
+ // v0.12 引用关系。`null` = 还没请求;请求回来是 `{status, incoming, outgoing, …}`。
1220
+ // **只跟着 previewRel 走**,绝不进列表轮询路径 —— 那份解析要读全库,
1221
+ // 塞进「每 5 秒一次」会把面板拖垮(SDD §3.5)。
1222
+ const [links, setLinks] = React.useState(null)
1223
+ const [linksExpandedTick, setLinksExpandedTick] = React.useState(0)
1224
+
1098
1225
  React.useEffect(() => {
1099
1226
  const host = listRef.current
1100
1227
  if (!host || typeof ResizeObserver === 'undefined') return undefined
@@ -1314,6 +1441,12 @@ body[data-ds-dark-theme] .knit-icon{color:#fff}
1314
1441
  // 预览进入 loading 时去宿主取正文
1315
1442
  const previewRel = preview && preview.rel
1316
1443
  const previewStatus = preview && preview.status
1444
+ /**
1445
+ * 只有 Markdown 有引用关系 —— 链接图里只有 `.md`,所以对图片/视频请求
1446
+ * 必然拿到 `knit/not-found`,面板会把它显示成「读取失败」。
1447
+ * **与其显示一个假的失败,不如压根不请求、也不显示这一条。**
1448
+ */
1449
+ const previewIsDoc = !preview || (preview.kind !== 'image' && preview.kind !== 'video')
1317
1450
 
1318
1451
  /** 阅读态 = 当前这一篇被滚过。换一篇自然为 false(派生,不用复位 effect)。 */
1319
1452
  const reading = Boolean(previewRel) && readingDocs.has(readingKey(sessionId, previewRel))
@@ -1365,6 +1498,51 @@ body[data-ds-dark-theme] .knit-icon{color:#fff}
1365
1498
  return () => { alive = false }
1366
1499
  }, [previewRel, previewStatus, sessionId])
1367
1500
 
1501
+ /**
1502
+ * v0.12:引用关系。**只在打开某一篇时请求一次**,换篇重取。
1503
+ *
1504
+ * 两条刻意的选择:
1505
+ * - 不依赖 `previewStatus` —— 引用关系与「正文读没读出来」无关
1506
+ * - 不进列表轮询 —— 全库解析很贵,只在用户真打开一篇时才发生
1507
+ * 服务端按签名缓存,所以连续换篇不会重复解析。
1508
+ */
1509
+ React.useEffect(() => {
1510
+ if (!previewRel || !previewIsDoc) {
1511
+ setLinks(null)
1512
+ return undefined
1513
+ }
1514
+ let alive = true
1515
+ setLinks({ status: 'loading' })
1516
+ const run = async () => {
1517
+ try {
1518
+ const url = `${LINKS_API}?sessionId=${encodeURIComponent(sessionId)}&rel=${encodeURIComponent(previewRel)}`
1519
+ const res = await fetch(url, { headers: { accept: 'application/json' }, cache: 'no-store' })
1520
+ const data = await res.json()
1521
+ if (!alive) return
1522
+ setLinks(data && data.ok
1523
+ ? { status: 'ready', ...data }
1524
+ : { status: 'error', error: hostMessage(data) })
1525
+ } catch (error) {
1526
+ if (!alive) return
1527
+ setLinks({ status: 'error', error: String((error && error.message) || error) })
1528
+ }
1529
+ }
1530
+ run()
1531
+ return () => { alive = false }
1532
+ }, [previewRel, previewIsDoc, sessionId])
1533
+
1534
+ /** 展开 / 收起引用条。真相在模块级 `expandedLinks`,组件只留计数器(理由同阅读态)。 */
1535
+ const toggleLinks = React.useCallback(() => {
1536
+ if (!previewRel) return
1537
+ const key = readingKey(sessionId, previewRel)
1538
+ if (expandedLinks.has(key)) expandedLinks.delete(key)
1539
+ else expandedLinks.add(key)
1540
+ setLinksExpandedTick((n) => n + 1)
1541
+ }, [previewRel, sessionId])
1542
+ const linksExpanded = Boolean(previewRel)
1543
+ && expandedLinks.has(readingKey(sessionId, previewRel))
1544
+ void linksExpandedTick
1545
+
1368
1546
  // 相对路径图片解析器:按当前文档所在目录解析。MarkdownText 按引用身份 memo,
1369
1547
  // 所以必须 useMemo 住,否则每帧都会重解析整篇 markdown。
1370
1548
  const pathImages = React.useMemo(
@@ -1545,10 +1723,17 @@ body[data-ds-dark-theme] .knit-icon{color:#fff}
1545
1723
  ratio,
1546
1724
  reading,
1547
1725
  onScrollBody,
1726
+ // v0.12 引用条
1727
+ links,
1728
+ linksExpanded,
1729
+ onToggleLinks: toggleLinks,
1730
+ // 点引用列表里的一项 → 就地预览那一篇。
1731
+ // **走订阅制 requestPreview,不碰列表** —— 用户点一下就该立刻有反应
1732
+ // (AGENTS.md §6.4 的教训:即时信号别藏在轮询里)。
1733
+ onOpenLink: (item) => requestPreview(item),
1548
1734
  // 拿不到绝对路径就不给点(而不是点了没反应)
1549
1735
  onOpenLocal: previewAbsPath ? openPreviewLocal : null,
1550
1736
  onClose: closePreview,
1551
- onOpenTab: () => onOpenTab(null),
1552
1737
  onToggleFullscreen: () => setFullscreen((v) => !v),
1553
1738
  onResizeStart,
1554
1739
  }) : null)
@@ -1916,6 +2101,17 @@ body[data-ds-dark-theme] .knit-icon{color:#fff}
1916
2101
  */
1917
2102
  const readingDocs = new Set()
1918
2103
 
2104
+ /**
2105
+ * 已经**展开过引用条**的文档,key 见 `readingKey`(同一个 key 约定)。
2106
+ *
2107
+ * 与 `readingDocs` 同一条理由(见 `AGENTS.md` §6.9):**「用户做过的事」不能只放
2108
+ * 组件 state** —— 宿主重挂载会把它清零,用户就得再点一次。
2109
+ * 语义是「这一篇在这个会话里被展开过」。
2110
+ *
2111
+ * @type {Set<string>}
2112
+ */
2113
+ const expandedLinks = new Set()
2114
+
1919
2115
  /**
1920
2116
  * 阅读态的 key:同一会话里的同一篇文档算一个。
1921
2117
  * @param {string} sessionId - 会话 id
package/src/host/index.js CHANGED
@@ -19,6 +19,8 @@ import { join, relative, resolve, sep } from 'node:path'
19
19
  import { homedir } from 'node:os'
20
20
  import { extractKeywords, rankByRelevance, topicLabel } from './relevance.js'
21
21
  import { registerKnitDocsTool } from './tool.js'
22
+ // v0.12:引用关系。`links.js` **不反过来 import 本文件**(依赖由这里注入),所以没有环。
23
+ import { buildLinkGraph, linksOf } from './links.js'
22
24
 
23
25
  export const name = 'dsh-knit'
24
26
 
@@ -844,6 +846,21 @@ export function apply(ctx) {
844
846
  return
845
847
  }
846
848
 
849
+ if (url.pathname === `${ROUTE_PREFIX}/api/links`) {
850
+ // v0.12:某篇的「谁引用了它 / 它引用了谁」。
851
+ // 形态逐字照抄 /api/doc —— 缺 rel 走同一个错误码,不新增读文件原语:
852
+ // 图只用 collectDocs / readDocument 建,两者本身已强制「必须在工作区内」。
853
+ const rel = url.searchParams.get('rel') || ''
854
+ if (!rel) {
855
+ sendJson(res, 400, { ok: false, code: ERROR_CODES.missingRel })
856
+ return
857
+ }
858
+ const graph = await buildLinkGraph(root, { list: collectDocs, read: readDocument })
859
+ const payload = linksOf(graph, rel)
860
+ sendJson(res, payload.ok ? 200 : 404, payload)
861
+ return
862
+ }
863
+
847
864
  sendJson(res, 404, { ok: false, code: ERROR_CODES.notFoundRoute })
848
865
  } catch (error) {
849
866
  sendJson(res, 500, { ok: false, code: ERROR_CODES.internal, detail: String((error && error.message) || error) })
@@ -852,7 +869,7 @@ export function apply(ctx) {
852
869
 
853
870
  webCtx.effect(() => {
854
871
  const unregister = webCtx.webServer.register({ kind: 'prefix', path: ROUTE_PREFIX, handler })
855
- console.log(`[${name}] route ready: ${ROUTE_PREFIX}/api/recent, ${ROUTE_PREFIX}/api/doc, ${ROUTE_PREFIX}/api/raw`)
872
+ console.log(`[${name}] route ready: ${ROUTE_PREFIX}/api/recent, ${ROUTE_PREFIX}/api/doc, ${ROUTE_PREFIX}/api/raw, ${ROUTE_PREFIX}/api/links`)
856
873
  return () => unregister()
857
874
  }, 'dsh-knit: host route')
858
875
  })
@@ -864,7 +881,7 @@ export function apply(ctx) {
864
881
  // 两条路互不依赖:没有 tools 服务时,浏览器那半边照常工作。
865
882
  ctx.inject(['tools'], (toolCtx) => {
866
883
  toolCtx.effect(
867
- () => registerKnitDocsTool(toolCtx, scan),
884
+ () => registerKnitDocsTool(toolCtx, scan, readDocument),
868
885
  'dsh-knit: knit_docs tool',
869
886
  )
870
887
  console.log(`[${name}] agent tool ready: knit_docs`)