dsh-knit 0.4.0 → 0.5.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 +18 -7
- package/README.md +16 -7
- package/package.json +9 -4
- package/src/client/client.js +793 -53
- package/src/host/index.js +232 -47
- package/test/client.test.mjs +491 -1
- package/test/harness.mjs +30 -6
- package/test/host-http.test.mjs +118 -0
- package/test/host.test.mjs +137 -0
- package/test/path.test.mjs +208 -0
- package/test/peek.test.mjs +338 -0
package/README.en.md
CHANGED
|
@@ -12,7 +12,7 @@ inline preview. Note the top line — **before a session has any conversation to
|
|
|
12
12
|
back to newest-first and states its basis instead of pretending to rank.** Send a message and that
|
|
13
13
|
line switches to what you're currently talking about.*
|
|
14
14
|
|
|
15
|
-
Scans the
|
|
15
|
+
Scans Markdown / images / video across the project folder · Order follows the conversation · No model calls, no network
|
|
16
16
|
|
|
17
17
|
```sh
|
|
18
18
|
dsh plugin --profile web add dsh-knit
|
|
@@ -96,9 +96,15 @@ as one of its tabs. Each host is an independent optional dependency; missing one
|
|
|
96
96
|
| Each row shows H1 title (or filename) + relative time + first-paragraph summary | ✅ |
|
|
97
97
|
| Click to preview inline, click again to collapse | ✅ |
|
|
98
98
|
| Relative-path images actually render (`./img/a.png`, `../assets/b.png`) | ✅ |
|
|
99
|
+
| One-click switch between **Docs / Images & video / All** (remembered; defaults to Docs, unchanged); the selected tab is a **neutral grey fill**, with no coloured outline | ✅ |
|
|
100
|
+
| Images & video: square thumbnail grid — **at least 3 columns, more only as the pane gets wider**; cells start at 64px and the baseline is **8 per screen**; past 8 nothing is hidden, the whole grid scales down proportionally; videos auto-grab the first frame with a play glyph and duration badge (no deps, no transcoding) | ✅ |
|
|
101
|
+
| Click an image / video to preview **inline**: large image, playable & seekable video streamed over HTTP Range (no full download) | ✅ |
|
|
102
|
+
| The **All** view splits into **two stacked sections**: docs (max 4, with "View all →" when truncated) and images & video (**never truncated**, count only) | ✅ |
|
|
99
103
|
| Preview pane is height-draggable (20%–80%, remembered), fullscreen-able, `Esc` to exit | ✅ |
|
|
100
104
|
| Double-click opens in a new tab | ✅ |
|
|
101
105
|
| Filter box over title / summary / path | ✅ |
|
|
106
|
+
| **Click the workspace path** to open the project folder in your file manager | ✅ |
|
|
107
|
+
| **Hover the entry button to peek**: a read-only floating list of the 5 most recent docs; click to open the right sidebar (doesn't push the layout) | ✅ |
|
|
102
108
|
| Keyboard: `↑` `↓` move-and-preview, `Enter` toggle, `Esc` collapse | ✅ |
|
|
103
109
|
| Auto-refresh every 5s plus a manual button; docs changed in the last 2 min get 🆕 | ✅ |
|
|
104
110
|
| Bilingual (zh/en), follows the DSH language live — no plugin reload needed | ✅ |
|
|
@@ -111,13 +117,15 @@ as one of its tabs. Each host is an independent optional dependency; missing one
|
|
|
111
117
|
|
|
112
118
|
## What it reads, and what it doesn't
|
|
113
119
|
|
|
114
|
-
-
|
|
120
|
+
- Scans `.md`, images and video **inside the current session workspace** (anything resolving
|
|
121
|
+
outside is rejected); for media it reads metadata only, never the pixels
|
|
115
122
|
- Reads only **the current session's** conversation events (used for ranking)
|
|
116
|
-
- **Makes no outbound network requests**: the client
|
|
123
|
+
- **Makes no outbound network requests**: the client's `fetch` calls all point to
|
|
117
124
|
the plugin's own same-origin routes
|
|
118
125
|
- **No install-time scripts** (no `install` / `postinstall`)
|
|
119
126
|
- **Zero dependencies** — nothing to build, no build-authorisation prompt
|
|
120
|
-
- The file-reading route only allows an **image-extension allowlist
|
|
127
|
+
- The file-reading route only allows an **image/video-extension allowlist** (images ≤ 12MB,
|
|
128
|
+
video ≤ 256MB), serves video over HTTP Range, and responds with
|
|
121
129
|
`nosniff` plus `default-src 'none'; sandbox`
|
|
122
130
|
|
|
123
131
|
The relevance figure only affects ordering — it is **never displayed and never sent anywhere**.
|
|
@@ -133,7 +141,10 @@ The relevance figure only affects ordering — it is **never displayed and never
|
|
|
133
141
|
- **The right sidebar's default page becomes the guide**: DSH's rule is "if there's exactly one
|
|
134
142
|
guide entry, open it directly"; the built-in Files entry takes that slot, so expanding the
|
|
135
143
|
sidebar shows the guide first and Knit needs one more click on its pill
|
|
136
|
-
- **
|
|
144
|
+
- **Media is limited to common formats and sizes**: images `png/jpg/jpeg/gif/webp/avif/bmp/ico/svg`,
|
|
145
|
+
video `mp4/m4v/webm/mov/ogv`; images ≤ 12MB and video ≤ 256MB or they are not listed
|
|
146
|
+
- **Media matches relevance by filename only**: no visual/audio content is parsed — give
|
|
147
|
+
screenshots and recordings searchable names
|
|
137
148
|
- **Right-sidebar state is memory-only**: a refresh or a new session collapses it again
|
|
138
149
|
|
|
139
150
|
---
|
|
@@ -144,7 +155,7 @@ The relevance figure only affects ordering — it is **never displayed and never
|
|
|
144
155
|
git clone https://github.com/PolinniZhong/dsh-knit.git
|
|
145
156
|
cd dsh-knit
|
|
146
157
|
|
|
147
|
-
npm test #
|
|
158
|
+
npm test # 162 tests, zero dependencies, no npm install needed
|
|
148
159
|
```
|
|
149
160
|
|
|
150
161
|
**How changes take effect**: the host half (`src/host/`) **requires a DSH restart** (no hot reload);
|
|
@@ -164,7 +175,7 @@ knit/
|
|
|
164
175
|
│ ├── host/index.js # /knit/api/recent · /doc · /raw
|
|
165
176
|
│ ├── host/relevance.js # the relevance engine (pure functions)
|
|
166
177
|
│ └── client/client.js # dual-host registration + panel UI
|
|
167
|
-
└── test/ #
|
|
178
|
+
└── test/ # 162 tests
|
|
168
179
|
```
|
|
169
180
|
|
|
170
181
|
Details and trade-offs live in the source comments; see [CONTRIBUTING.md](CONTRIBUTING.md)
|
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
注意顶行:**新会话还没聊起来时,它退回按最新排并如实说明依据,不假装排了个序** ——
|
|
12
12
|
一发出消息,这一行就会换成按你正在聊什么排序。*
|
|
13
13
|
|
|
14
|
-
扫整个项目文件夹的 Markdown · 排序跟着对话走 · 不调模型、不联网
|
|
14
|
+
扫整个项目文件夹的 Markdown / 图片 / 视频 · 排序跟着对话走 · 不调模型、不联网
|
|
15
15
|
|
|
16
16
|
```sh
|
|
17
17
|
dsh plugin --profile web add dsh-knit
|
|
@@ -91,9 +91,15 @@ dsh plugin --profile web add dsh-knit
|
|
|
91
91
|
| 每项显示:H1 标题(无则文件名)+ 相对时间 + 首段摘要 | ✅ |
|
|
92
92
|
| 单击就地展开预览,再点收起 | ✅ |
|
|
93
93
|
| 相对路径图片真正渲染(`./img/a.png`、`../assets/b.png`) | ✅ |
|
|
94
|
+
| **文档 / 图片与视频 / 全部** 三类一键切换(偏好记住,默认仍是文档,老体验不变);选中态是**中性灰填充**,不带品牌色描边 | ✅ |
|
|
95
|
+
| 图片与视频:方形缩略图网格,**最少 3 列、宽了才加列**;格子 64px 起步,**一屏基准 8 个**,超过 8 个不隐藏而是整块等比缩小;视频自动取首帧、叠播放三角与时长角标(零依赖、不转码) | ✅ |
|
|
96
|
+
| 点图片 / 视频在面板内**就地预览**:图片大图、视频可播放可拖动(HTTP Range 流式,不全量下载) | ✅ |
|
|
97
|
+
| 「全部」视图**分上下两区**:文档最多 4 条(超出给「查看全部 →」);图片视频**不截断**,只给计数 | ✅ |
|
|
94
98
|
| 预览面板可拖高度(20%–80%,位置记住)、可全屏,`Esc` 退出 | ✅ |
|
|
95
99
|
| 双击在新标签页打开 | ✅ |
|
|
96
100
|
| 过滤框:按标题 / 摘要 / 路径实时过滤 | ✅ |
|
|
101
|
+
| **点工作区路径**:用系统文件管理器打开项目文件夹 | ✅ |
|
|
102
|
+
| **悬停入口按钮偷看**:弹只读浮层列最近 5 篇,点击才进右边栏(不推挤布局) | ✅ |
|
|
97
103
|
| 键盘导航:`↑` `↓` 移动即预览 / `Enter` 切换 / `Esc` 收起 | ✅ |
|
|
98
104
|
| 每 5 秒自动刷新 + 手动刷新;2 分钟内改动过的文档打 🆕 | ✅ |
|
|
99
105
|
| 中英双语,跟随 DSH 语言实时切换(不用重载插件) | ✅ |
|
|
@@ -105,12 +111,13 @@ dsh plugin --profile web add dsh-knit
|
|
|
105
111
|
|
|
106
112
|
## 它读什么,不读什么
|
|
107
113
|
|
|
108
|
-
-
|
|
114
|
+
- 扫描**当前会话工作区内**的 `.md`、图片与视频(路径越出工作区一律拒绝);媒体只取元信息,不读画面内容
|
|
109
115
|
- 只读**当前会话**的对话事件(用来排序)
|
|
110
|
-
-
|
|
116
|
+
- **不发起任何对外网络请求**:客户端的 `fetch` 都指向插件自己的同源路由
|
|
111
117
|
- **没有安装期脚本**(无 `install` / `postinstall`)
|
|
112
118
|
- **零依赖** —— 装完不需要构建授权,也没有构建步骤
|
|
113
|
-
-
|
|
119
|
+
- 按路径读文件的接口只放行**图片 / 视频扩展名白名单**(图片 ≤ 12MB、视频 ≤ 256MB),
|
|
120
|
+
视频走 HTTP Range 按需取字节,响应带 `nosniff` 与 `default-src 'none'; sandbox`
|
|
114
121
|
|
|
115
122
|
面板里那份「相关度」只影响排序,**不显示也不外传**。
|
|
116
123
|
|
|
@@ -122,7 +129,9 @@ dsh plugin --profile web add dsh-knit
|
|
|
122
129
|
- **中文分词是 n-gram 近似**:没有引入分词库(那会带来依赖),效果够用但不算精细
|
|
123
130
|
- **右侧栏默认页会变成 guide**:DSH 的规则是「guide 入口只有一个才直接开那一页」,
|
|
124
131
|
内置 Files 占了一个,所以展开右侧栏先看到 guide,需要点一下胶囊
|
|
125
|
-
-
|
|
132
|
+
- **媒体只认常见格式与大小**:图片 `png/jpg/jpeg/gif/webp/avif/bmp/ico/svg`、
|
|
133
|
+
视频 `mp4/m4v/webm/mov/ogv`;图片 ≤ 12MB、视频 ≤ 256MB,超出不列出
|
|
134
|
+
- **媒体只按文件名参与相关性匹配**:不解析画面 / 语音内容,截图与录屏建议用可检索的文件名
|
|
126
135
|
- **右侧栏状态是 memory-only**:刷新或新会话会回到收起状态
|
|
127
136
|
|
|
128
137
|
---
|
|
@@ -133,7 +142,7 @@ dsh plugin --profile web add dsh-knit
|
|
|
133
142
|
git clone https://github.com/PolinniZhong/dsh-knit.git
|
|
134
143
|
cd dsh-knit
|
|
135
144
|
|
|
136
|
-
npm test #
|
|
145
|
+
npm test # 162 项,零依赖,不需要先 npm install
|
|
137
146
|
```
|
|
138
147
|
|
|
139
148
|
**改动生效方式**:宿主半边(`src/host/`)改了**必须重启 DSH**(实测不热加载);
|
|
@@ -153,7 +162,7 @@ knit/
|
|
|
153
162
|
│ ├── host/index.js # /knit/api/recent · /doc · /raw
|
|
154
163
|
│ ├── host/relevance.js # 相关性引擎(纯函数)
|
|
155
164
|
│ └── client/client.js # 双宿主注册 + 面板 UI
|
|
156
|
-
└── test/ #
|
|
165
|
+
└── test/ # 162 项测试
|
|
157
166
|
```
|
|
158
167
|
|
|
159
168
|
细节和取舍写在源码注释里;贡献流程见 [CONTRIBUTING.md](CONTRIBUTING.md),
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-knit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "Knit — recent Markdown
|
|
5
|
+
"description": "Knit — recent Markdown, images and video in the DSH sidebar, sorted by relevance to the current conversation, with inline previews and HTTP Range streaming. Zero model calls.",
|
|
6
6
|
"main": "./src/host/index.js",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": "./src/host/index.js",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"LICENSE"
|
|
20
20
|
],
|
|
21
21
|
"scripts": {
|
|
22
|
-
"test": "node --test test/host.test.mjs test/client.test.mjs test/tier1.test.mjs test/entry.test.mjs test/i18n.test.mjs test/icon.test.mjs"
|
|
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"
|
|
23
23
|
},
|
|
24
24
|
"dsh": {
|
|
25
25
|
"bundle": {
|
|
@@ -46,9 +46,14 @@
|
|
|
46
46
|
"recent-files",
|
|
47
47
|
"relevance",
|
|
48
48
|
"knowledge-base",
|
|
49
|
+
"images",
|
|
50
|
+
"video",
|
|
51
|
+
"media-gallery",
|
|
52
|
+
"http-range",
|
|
49
53
|
"最近文档",
|
|
50
54
|
"侧边栏",
|
|
51
|
-
"知识管理"
|
|
55
|
+
"知识管理",
|
|
56
|
+
"图片视频"
|
|
52
57
|
],
|
|
53
58
|
"repository": {
|
|
54
59
|
"type": "git",
|