dsh-tiddlywiki 0.16.16 → 0.16.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +263 -422
- package/docs/seed-initialization.md +7 -7
- package/lib/client.bundle.js +26 -26
- package/lib/client.js +26 -26
- package/lib/index.js +23 -20
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/src/client/editor-popup.ts +29 -3
- package/src/client/knowledge-fab.ts +8 -2
- package/src/client/note-widget.ts +64 -27
- package/src/client/panel.ts +0 -54
- package/src/client/quick-note-dock.ts +25 -5
- package/src/client/settings-page.ts +19 -1
- package/src/client/ui-config.ts +61 -44
- package/src/host/config.ts +6 -0
- package/src/host/routes.ts +2 -0
- package/src/host/seed-all-articles.ts +1 -1
- package/src/host/seed-home.ts +92 -92
- package/src/host/seed-notes.ts +2 -2
- package/src/host/seeds.ts +3 -3
- package/src/index.ts +6 -4
package/README.md
CHANGED
|
@@ -1,422 +1,263 @@
|
|
|
1
|
-
# dsh-tiddlywiki
|
|
2
|
-
|
|
3
|
-
> TiddlyWiki 5
|
|
4
|
-
|
|
5
|
-
[](https://www.npmjs.com/package/dsh-tiddlywiki)
|
|
6
|
-
[](https://github.com/bbqisbbq/dsh-tiddlywiki/blob/main/LICENSE)
|
|
7
|
-
[](https://github.com/bbqisbbq/dsh-tiddlywiki)
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
|
19
|
-
|
|
20
|
-
|
|
|
21
|
-
|
|
|
22
|
-
|
|
|
23
|
-
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
-
|
|
161
|
-
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
-
|
|
182
|
-
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
-
|
|
236
|
-
-
|
|
237
|
-
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
## 🛠 配置
|
|
265
|
-
|
|
266
|
-
插件行默认如下(缺省即用默认值,无需手动配置)。如需自定义,编辑 `profiles/web/cordis.patch.yml` 或 profile 的 bundle 层,给该行加 `config:`:
|
|
267
|
-
|
|
268
|
-
```yaml
|
|
269
|
-
- id: dsh-tiddlywiki
|
|
270
|
-
name: dsh-tiddlywiki
|
|
271
|
-
config:
|
|
272
|
-
wikiRoot: "$DSH_HOME/tiddlywiki" # 缺省自动展开
|
|
273
|
-
wiki: "main"
|
|
274
|
-
port: 0 # 0 = 自动探测空闲端口
|
|
275
|
-
git:
|
|
276
|
-
autoCommit: true
|
|
277
|
-
debounceMs: 60000
|
|
278
|
-
remote: "" # 空 = 仅本地 commit;填了才 push
|
|
279
|
-
branch: "main"
|
|
280
|
-
note:
|
|
281
|
-
tag: "inbox"
|
|
282
|
-
ui:
|
|
283
|
-
showQuickNote: true # 是否显示「知识库」按钮里的「快速笔记」入口
|
|
284
|
-
showQuickNoteDock: true # 是否显示聊天输入框上方的「快速笔记」快捷按钮
|
|
285
|
-
sidebarLabel: "TiddlyWiki" # 左侧侧边栏 TW 入口的显示名称(可自定义)
|
|
286
|
-
showPanelStatus: true # 是否显示「知识库」按钮里的 TW 面板/重载入口与状态行
|
|
287
|
-
showSyncButton: true # 是否显示「知识库」按钮里的「同步」入口(git 状态点常驻 FAB)
|
|
288
|
-
followDshTheme: true # 嵌入式 TW 是否跟随 DSH 深浅主题(纯内存切换)
|
|
289
|
-
darkPalette: "$:/palettes/CupertinoDark" # DSH 暗色时 TW 使用的深色 palette
|
|
290
|
-
auth:
|
|
291
|
-
username: "" # 默认 loopback 匿名;暴露到非 loopback 时才需要
|
|
292
|
-
password: ""
|
|
293
|
-
```
|
|
294
|
-
|
|
295
|
-
> **运行时配置**:设置页写入的 `$:/plugins/dsh-tiddlywiki/config` tiddler 是 `config:` 块之上的覆盖层(tiddler 优先、随 wiki 的 git 同步)。无需改动 cordis 也能改 note tag / git 开关 / ui 开关等。
|
|
296
|
-
> `config:` 块随 profile 被 dsh-market 带走;wiki 数据走 git,不走 dsh-market。
|
|
297
|
-
>
|
|
298
|
-
> **远程访问(v0.6.0)**:TW 前端的 API 基址来自 `$:/config/tiddlyweb/host`,插件启动时固定为 `/dsh-tiddlywiki/tw/`(同源代理)。TW 子进程始终只监听 `127.0.0.1`;`auth.username/password` 仅在你想把 TW 直接暴露到非回环地址(绕过 DSH)时才需要,正常情况下无需配置。
|
|
299
|
-
|
|
300
|
-
---
|
|
301
|
-
|
|
302
|
-
## 👨💻 开发
|
|
303
|
-
|
|
304
|
-
需要 **Node.js ≥ 22**(DSH 本身已满足)。
|
|
305
|
-
|
|
306
|
-
```bash
|
|
307
|
-
npm install
|
|
308
|
-
npm run typecheck # tsc --noEmit
|
|
309
|
-
npm run build # clean + host tsdown + client tsdown + wrap
|
|
310
|
-
npm run selftest # headless:spawn TW → REST 读写 → git → 退出回收
|
|
311
|
-
node scripts/verify-theme-browser.mjs # 可选:真实浏览器验证「跟随 DSH 主题」的 palette 切换与不持久化(需 puppeteer-core + Chrome,缺则 SKIP)
|
|
312
|
-
node scripts/verify-menubar-theme.mjs # 可选:真实浏览器验证 menubar 顶栏随 palette 换色(浅色→白、深色→深,不再蓝色;可 TW_URL=… 指定活动 wiki)
|
|
313
|
-
node scripts/verify-seed-send-to-agent.mjs # 可选:全新 wiki 上 E2E 验证「发送给 Agent」按钮 seed(bundle 写入/幂等/marker)
|
|
314
|
-
node scripts/verify-seeds-admin.mjs # 可选:全新 wiki + 真实 HTTP 验证 /admin/seeds 状态与 /admin/seeds/run(单跑/全跑/force/unknown id)
|
|
315
|
-
|
|
316
|
-
# 改了 scripts/bundle/send-to-agent/ 下的按钮源码(startup.js / button.tid / icon.svg)后,
|
|
317
|
-
# 重新组装 bundle → 重新生成内置常量:
|
|
318
|
-
node scripts/build-send-to-agent-bundle.mjs
|
|
319
|
-
node scripts/gen-seed-send-to-agent.mjs scripts/bundle/send-to-agent.bundle.json src/host/seed-send-to-agent.ts && npm run build
|
|
320
|
-
node scripts/verify-send-to-agent-bundle.mjs # 可选:校验组装出的 bundle 字段/内容
|
|
321
|
-
|
|
322
|
-
# 改了 wiki 首页「主页 / 所有标签 / 标签笔记」后,重新生成内置 seed 常量:
|
|
323
|
-
node scripts/gen-seed-home.mjs '<wiki>/tiddlers/主页.tid' '<wiki>/tiddlers/所有标签.tid' '<wiki>/tiddlers/标签笔记.tid' src/host/seed-home.ts && npm run build
|
|
324
|
-
```
|
|
325
|
-
|
|
326
|
-
**产物约定**(发布必守):`lib/` 内**零** `@deepseek-ai` 运行时 import(`src/sdk.ts` 自实现 `defineTool` / `dshHomePath`,类型用结构接口)。发布前用 `grep -r "@deepseek-ai" lib/` 验证。
|
|
327
|
-
|
|
328
|
-
**客户端依赖**:快速笔记编辑器用 CodeMirror 6(`@codemirror/*`、`@lezer/*`)做 Markdown 高亮,构建时由 tsdown **打包进 `lib/client.bundle.js`**(它们放在 `devDependencies`,因为运行时用的是预构建 bundle,用户安装无需拉取)。「零依赖自研高亮」已成历史——浏览器端只要求构建产物自包含。
|
|
329
|
-
|
|
330
|
-
### 路由参考(开发者)
|
|
331
|
-
|
|
332
|
-
同源路由(走 DSH web server),Client 直连、无 CORS:
|
|
333
|
-
|
|
334
|
-
| 路由 | 方法 | 用途 |
|
|
335
|
-
|---|---|---|
|
|
336
|
-
| `/dsh-tiddlywiki/status` | GET | 面板健康(service / url / git / tag / ui) |
|
|
337
|
-
| `/dsh-tiddlywiki/note` | POST | 快速笔记 → 独立 tiddler |
|
|
338
|
-
| `/dsh-tiddlywiki/edit` | POST | 打开 TW 原生编辑器(draft) |
|
|
339
|
-
| `/dsh-tiddlywiki/tags` | GET | 现有非系统 tag(自动补全) |
|
|
340
|
-
| `/dsh-tiddlywiki/recent` | GET | 最近修改的笔记(快速笔记「最近」入口) |
|
|
341
|
-
| `/dsh-tiddlywiki/get` | GET | 读单个 tiddler(快速笔记「最近」载入) |
|
|
342
|
-
| `/dsh-tiddlywiki/sync` | POST | 一键 pull → commit → push |
|
|
343
|
-
| `/dsh-tiddlywiki/upload` | POST | 文件上传到 `files/`(原始 body + `X-Filename`) |
|
|
344
|
-
| `/dsh-tiddlywiki/restart` | POST | 重启 TW 子进程 |
|
|
345
|
-
| `/dsh-tiddlywiki/agent/sessions` | GET | 可见会话列表(TW「发送给 Agent」选择器;含每会话 `agentPreset` 模式徽标) |
|
|
346
|
-
| `/dsh-tiddlywiki/agent/modes` | GET | 可用「工作模式」(Agent 预设)清单 + 部署默认;同时返回 `permissions`(权限预设 roster:`{defaultId, items:[{value,name,description}]}`,v0.14.0,来自 `permissionPresets`,缺失时 `null`) |
|
|
347
|
-
| `/dsh-tiddlywiki/agent/send` | POST | 把笔记作为消息注入一个会话(`sessionController.prompt`) |
|
|
348
|
-
| `/dsh-tiddlywiki/agent/create` | POST | 按 cwd 新建/复用 Workspace + 会话(工作区优先);可选 `mode`(Agent 预设)、可选 `permission`(权限预设,创建后经 `permissionPresets.set` 应用到会话日志,v0.14.0;未知预设 400 拒绝) |
|
|
349
|
-
| `/dsh-tiddlywiki/api/*` | any | 透传到 TW 服务(JSON) |
|
|
350
|
-
| `/dsh-tiddlywiki/tw/*` | any | **同源 TW 代理**:整个 TW 前端(index + `/files/*` + TiddlyWeb API)→ 回环 TW(v0.6.0,远程访问核心) |
|
|
351
|
-
| `/dsh-tiddlywiki/admin/seeds` | GET | 一次性预置项实时状态(含 `removable` 标记) |
|
|
352
|
-
| `/dsh-tiddlywiki/admin/seeds/run` | POST | 运行一个/全部 seed(`force` = 重新初始化) |
|
|
353
|
-
| `/dsh-tiddlywiki/admin/seeds/remove` | POST | 反初始化:移除一个/全部可选 seed(核心项 400 拒绝) |
|
|
354
|
-
|
|
355
|
-
---
|
|
356
|
-
|
|
357
|
-
## 📦 发布
|
|
358
|
-
|
|
359
|
-
```bash
|
|
360
|
-
# 版本号在 package.json;文件白名单见 files 字段
|
|
361
|
-
npm publish
|
|
362
|
-
```
|
|
363
|
-
|
|
364
|
-
`tiddlywiki` 依赖体较大(含全部语言包/插件),发布文档需注明。
|
|
365
|
-
|
|
366
|
-
---
|
|
367
|
-
|
|
368
|
-
## 🗂 项目结构
|
|
369
|
-
|
|
370
|
-
```
|
|
371
|
-
docs/
|
|
372
|
-
└── seed-initialization.md # 统一 seed 注册表详解:ONE-SHOT/force 语义、后台 API、设置页操作、重新生成内置常量
|
|
373
|
-
src/
|
|
374
|
-
├── index.ts # host 入口:装配 WikiServer/路由/工具/prompt/自动 commit
|
|
375
|
-
├── sdk.ts # 自包含 defineTool + dshHomePath(零 @deepseek-ai 运行时依赖)
|
|
376
|
-
├── host/
|
|
377
|
-
│ ├── wiki.ts # WikiServer:spawn/kill/自愈/端口探测/就绪轮询;TW_PROXY_PATH 同源代理路径
|
|
378
|
-
│ ├── tw-api.ts # TiddlyWeb REST 客户端
|
|
379
|
-
│ ├── git.ts # git init/commit/pull/push/sync/status + AutoCommitter
|
|
380
|
-
│ ├── routes.ts # /status /note /edit /tags /sync /upload /restart /api/* /tw/* 路由
|
|
381
|
-
│ ├── admin.ts # 设置页后台:tiddlywiki.info 读写 + 目录枚举 + /admin/* 路由
|
|
382
|
-
│ ├── config.ts # ConfigStore:cordis config 基底 + 配置 tiddler 覆盖层
|
|
383
|
-
│ ├── seed-notes.ts # seed: 首次一次性写入「插件说明」笔记(支持 force)
|
|
384
|
-
│ ├── seed-send-to-agent.ts # seed: 首次一次性写入「发送给 Agent」TW 按钮插件(bundle 内嵌常量,支持 force)
|
|
385
|
-
│ ├── seed-home.ts # seed: 默认主页「主页/所有标签/标签笔记」+ $:/DefaultTiddlers(生成自 wiki .tid,支持 force)
|
|
386
|
-
│ ├── seed-all-articles.ts # seed: 「所有文章」两列分页页(支持 force)
|
|
387
|
-
│ ├── seed-menubar-theme.ts # seed: menubar 顶栏主题自适应样式表(支持 force)
|
|
388
|
-
│ ├── seeds.ts # 统一 seed 注册表:doc-note / send-to-agent / home-index / all-articles / menubar-theme / tw-web-host,check + run(force)
|
|
389
|
-
│ └── tools.ts # 5 个工具(列表式注册,可扩展)
|
|
390
|
-
└── client/
|
|
391
|
-
├── index.ts # client 入口(纯 DOM + settings.section 注册,永不 throw)
|
|
392
|
-
├── styles.ts / state.ts / toast.ts
|
|
393
|
-
├── sidebar-entry.ts # 侧边栏入口
|
|
394
|
-
├── panel.ts # 中央列 iframe 面板(fixed 覆盖层,钉住整列)
|
|
395
|
-
├── theme-sync.ts # 跟随 DSH 主题:检测深浅 + 纯内存切 TW palette(不写回 wiki)
|
|
396
|
-
├── note-widget.ts # 悬浮快速笔记
|
|
397
|
-
├── markdown-editor.ts # 快速笔记编辑器(CodeMirror 6 + Lezer Markdown 高亮)
|
|
398
|
-
├── sync-button.ts # 一键同步悬浮按钮
|
|
399
|
-
├── editor-popup.ts # 原生编辑器弹出小窗
|
|
400
|
-
└── settings-page.ts # 设置页(插件/主题/语言管理 + 常规配置)
|
|
401
|
-
```
|
|
402
|
-
|
|
403
|
-
---
|
|
404
|
-
|
|
405
|
-
## 🔗 仓库与发布元数据
|
|
406
|
-
|
|
407
|
-
- **GitHub(公开)**:https://github.com/bbqisbbq/dsh-tiddlywiki
|
|
408
|
-
- **npm**:`dsh-tiddlywiki`(https://www.npmjs.com/package/dsh-tiddlywiki)
|
|
409
|
-
- **说明笔记**:插件在**首次启动**时把「与 dsh 联动、**功能必需**」的一次性项写入 wiki(**统一 seed 注册表**,见 [🧩 初始化](#🧩-初始化一次性预置)):「发送给 Agent」按钮插件(`$:/plugins/dsh/send-to-agent`)、`$:/config/tiddlyweb/host` 同源代理基址——只写一次、手动编辑不被覆盖、**删除后重启不会自动恢复**(一次性标记)。**可选项**(`dsh-tiddlywiki 插件说明` 笔记、默认主页「主页/所有标签/标签笔记」+ `$:/DefaultTiddlers`、「所有文章」两列分页页、`menubar` 顶栏主题自适应样式表 `$:/plugins/dsh-tiddlywiki/menubar-theme`)**默认不写入、不强制**——需要时设置页「初始化」手动「重新初始化」,不想要可「反初始化」移除。
|
|
410
|
-
|
|
411
|
-
**可被检索的标准字段**(为 GitHub / npm / 搜索引擎发现):
|
|
412
|
-
|
|
413
|
-
| 字段 | 值 |
|
|
414
|
-
|---|---|
|
|
415
|
-
| npm 包名 | `dsh-tiddlywiki` |
|
|
416
|
-
| npm `keywords` | `dsh` `dsh-plugin` `tiddlywiki` `knowledge-base` `note-taking` `notes` `wiki` `git-sync` `agent-tools` `plugin` |
|
|
417
|
-
| GitHub topics | `dsh` `dsh-plugin` `tiddlywiki` `wiki` `knowledge-base` `knowledge-management` `note-taking` `notes` `second-brain` `productivity` `git` `git-sync` `plugin` `agent` `agent-tools` `ai` `typescript` `nodejs`(共 18 个) |
|
|
418
|
-
| `description` | 见 package.json(一句话说明插件的用途) |
|
|
419
|
-
| `license` | MIT |
|
|
420
|
-
| `homepage` / `repository` / `bugs` | 均指向 https://github.com/bbqisbbq/dsh-tiddlywiki |
|
|
421
|
-
|
|
422
|
-
> GitHub topics 规范([官方文档](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/classifying-your-repository-with-topics)):仅小写字母/数字/连字符、≤50 字符、每仓库 ≤20 个;用官方 **Replace all repository topics** 端点(`PUT /repos/{owner}/{repo}/topics`)设置。上表已按此执行并覆盖「用途 / 主题 / 语言 / 技术栈」。
|
|
1
|
+
# dsh-tiddlywiki
|
|
2
|
+
|
|
3
|
+
> 把 **TiddlyWiki 5** 变成 DSH 的**持久知识库**:Agent 用 `tiddlywiki_*` 工具读写笔记,你在界面里用完整 TW 编辑器或快速笔记记录,一切通过 **git** 自动同步备份。
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/dsh-tiddlywiki)
|
|
6
|
+
[](https://github.com/bbqisbbq/dsh-tiddlywiki/blob/main/LICENSE)
|
|
7
|
+
[](https://github.com/bbqisbbq/dsh-tiddlywiki)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## ✨ 特性一览
|
|
12
|
+
|
|
13
|
+
| 能力 | 说明 |
|
|
14
|
+
|---|---|
|
|
15
|
+
| 🤖 **Agent 工具** | 10 个 `tiddlywiki_*` 工具:检索、读写、批量、重命名、删除、git 同步与冲突解决 |
|
|
16
|
+
| 📊 **回复流卡片** | 工具结果显示原生 TW 卡片;`[标题](/dsh-tiddlywiki/tw/#标题)` 点击直达 TW 面板 |
|
|
17
|
+
| 📤 **发送给 Agent** | TW 笔记工具栏一键把当前笔记注入所选 dsh 会话(可选工作模式/权限/附加说明) |
|
|
18
|
+
| 🧭 **内嵌编辑器** | 中央列内嵌完整 TW 5 编辑器(同源代理,Tailscale/内网/域名/HTTPS 均可) |
|
|
19
|
+
| 📚 **会话知识库 Tab** | 每个会话顶部汇总本会话读写过的 wiki 笔记,TW 原生渲染 |
|
|
20
|
+
| 📝 **快速笔记** | 输入框上方快捷按钮或右下角「知识库」FAB;原生编辑页或 Markdown 卡片两种模式 |
|
|
21
|
+
| 🌗 **跟随主题** | 内嵌 TW 自适应 DSH 深浅主题(纯内存切换,不进 git) |
|
|
22
|
+
| 🔄 **一键同步** | FAB「同步」一键 pull→commit→push,状态点实时反映 git 状态 |
|
|
23
|
+
| 💾 **数据即备份** | wiki 文件夹本身就是 git 仓库,自动 commit(60s 防抖) |
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## 📦 安装
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
# ① npm 发布包(推荐)
|
|
31
|
+
dsh plugin --profile web add dsh-tiddlywiki
|
|
32
|
+
|
|
33
|
+
# ② 直接从 GitHub 安装
|
|
34
|
+
dsh plugin --profile web add github:bbqisbbq/dsh-tiddlywiki
|
|
35
|
+
|
|
36
|
+
# ③ 本地开发(link 方式,改完 src 后 npm run build 即生效)
|
|
37
|
+
dsh plugin --profile web add link:/path/to/dsh-tiddlywiki
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
装完**重启 dsh web** 生效。首次启动自动完成:初始化 wiki 目录、`git init` 并提交基线、写入**功能必需**的 seed(「发送给 Agent」按钮 + 同源代理基址)。可选项(说明笔记/首页/所有文章/menubar 主题)需在设置页「初始化」手动写入。
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## 🚀 快速开始
|
|
45
|
+
|
|
46
|
+
1. **安装并重启** dsh web。
|
|
47
|
+
2. 侧边栏「**TiddlyWiki**」→ 中央打开完整 TW 编辑器。
|
|
48
|
+
3. **随手记**:点输入框上方「📝」或右下角「知识库」→「快速笔记」,写完保存即成为 tiddler 并自动进 git。
|
|
49
|
+
4. **收工同步**:「知识库」→「🔁 同步」一键 push 备份。
|
|
50
|
+
5. **让 Agent 参与**:直接说「把刚才的会议纪要存进知识库」——Agent 用 `tiddlywiki_*` 工具读写。
|
|
51
|
+
6. **发笔记给 Agent**:TW 里打开笔记 → 工具栏「发送给 Agent」→ 选会话 → 作为消息注入。
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## 📖 使用指南
|
|
56
|
+
|
|
57
|
+
### 🤖 Agent 工具(10 个)
|
|
58
|
+
|
|
59
|
+
| 工具 | 说明 |
|
|
60
|
+
|---|---|
|
|
61
|
+
| `tiddlywiki_search` | 检索(`query` + 可选 `tags[]/tag/since/type/limit`),返回标题/标签/修改时间/摘要 |
|
|
62
|
+
| `tiddlywiki_recent` | 最近修改的笔记(倒序),开工快速了解动态 |
|
|
63
|
+
| `tiddlywiki_list_tags` | 现有非系统 tag 及计数 |
|
|
64
|
+
| `tiddlywiki_get` | 读单个 tiddler 全文 |
|
|
65
|
+
| `tiddlywiki_put` | 写/覆盖;未指定类型时自动默认 `text/markdown`(`$:/` 系统条目除外) |
|
|
66
|
+
| `tiddlywiki_batch_put` | 批量写入(`overwrite=false` 跳过已存在) |
|
|
67
|
+
| `tiddlywiki_rename` | 重命名 + 尽量同步其他条目里的引用 |
|
|
68
|
+
| `tiddlywiki_delete` | 删除(幂等) |
|
|
69
|
+
| `tiddlywiki_git_sync` | `action: pull\|push\|sync` |
|
|
70
|
+
| `tiddlywiki_git_resolve` | pull 冲突后按 tiddler 二选一(`keep-local\|keep-remote`) |
|
|
71
|
+
|
|
72
|
+
**知识库同步纪律**:
|
|
73
|
+
1. 开工先 `tiddlywiki_git_sync action=pull`(rebase + autostash,真冲突会 abort 并报文件)。
|
|
74
|
+
2. 冲突后用 `tiddlywiki_git_resolve` 二选一解决,再重新 sync(**绝不自动覆盖**)。
|
|
75
|
+
3. 收工 `tiddlywiki_git_sync action=sync`(pull → commit → push)。
|
|
76
|
+
|
|
77
|
+
> ⚠️ `fields.type` 是 TW 的**内容类型保留字段**(`text/markdown` 等),业务分类请放 `tags`,别写进 `fields.type`。
|
|
78
|
+
|
|
79
|
+
### 🧑💻 界面操作
|
|
80
|
+
|
|
81
|
+
- **📤 发送给 Agent**:TW 工具栏按钮(首次启动自动写入 wiki,ONE-SHOT)。弹层可选**附加说明**(位于消息末尾)、**工作模式**(Agent 预设)、**权限**(权限预设),按工作区分组选会话或新建。消息自带待办说明。
|
|
82
|
+
- **🧭 中央列编辑器**:侧边栏「TiddlyWiki」开关(显示名可改 `ui.sidebarLabel`)。
|
|
83
|
+
- **📝 快速笔记**:输入框上方快捷按钮(`ui.showQuickNoteDock`)或 FAB;`ui.quickNoteMode` 选打开方式——**native**(默认,直达 TW 原生编辑页,草稿自动续写)或 **card**(CodeMirror 6 Markdown 高亮、文件上传、多选 tag、草稿自动保存、「🕘 最近」载入、Ctrl+Enter 保存)。
|
|
84
|
+
- **📚 会话知识库 Tab**:会话顶部 Tab(`ui.tabLabel` 改名、`ui.showSessionTab` 关闭),自动汇总本会话读写过的 wiki 笔记(写入 volatile `$:/temp`,不落盘不进 git),不可编辑。
|
|
85
|
+
- **🌗 跟随 DSH 主题**:内嵌 TW 随 DSH 深浅切换 palette,纯内存不写回 wiki(`ui.followDshTheme`/`ui.darkPalette`)。
|
|
86
|
+
- **🔧 知识库 FAB**:统一入口(TW 面板开关/重载、快速笔记、同步、TW 服务状态悬停 tip)。同步拉取到新内容会自动重启 TW(同端口)。
|
|
87
|
+
- **⚙️ 设置页**:DSH 设置 →「TiddlyWiki 知识库」:状态/重启、常规配置、插件/主题/语言管理、**初始化**(seed 状态与重新初始化)。配置写入 `$:/plugins/dsh-tiddlywiki/config` tiddler,覆盖 cordis `config:` 块(tiddler 优先)。
|
|
88
|
+
|
|
89
|
+
### 🧩 初始化(一次性预置)
|
|
90
|
+
|
|
91
|
+
seed 注册表分两层(详细见 [docs/seed-initialization.md](docs/seed-initialization.md)):
|
|
92
|
+
|
|
93
|
+
- **核心项**(功能必需,首次启动自动写入、不可移除):`send-to-agent`(发送按钮)、`render-route`(原生渲染路由)、`tw-web-host`(同源代理基址)。
|
|
94
|
+
- **可选项**(默认不写,设置页可「重新初始化」/「反初始化」):`doc-note`(说明笔记)、`home-index`(首页 🏠 主页/所有标签/标签笔记 + `$:/DefaultTiddlers`)、`all-articles`(所有文章两列分页)、`menubar-theme`(menubar 顶栏跟随主题)。
|
|
95
|
+
|
|
96
|
+
语义:**ONE-SHOT**——只写缺失、绝不覆盖你的改动;删掉重启不会自动恢复(用「重新初始化」找回)。
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## 🛠 配置
|
|
101
|
+
|
|
102
|
+
插件行默认配置(缺省即默认,无需手动配置):
|
|
103
|
+
|
|
104
|
+
```yaml
|
|
105
|
+
- id: dsh-tiddlywiki
|
|
106
|
+
config:
|
|
107
|
+
wikiRoot: "$DSH_HOME/tiddlywiki" # 缺省自动展开
|
|
108
|
+
wiki: "main"
|
|
109
|
+
port: 0 # 0 = 自动探测空闲端口
|
|
110
|
+
git:
|
|
111
|
+
autoCommit: true
|
|
112
|
+
debounceMs: 60000
|
|
113
|
+
remote: "" # 空 = 仅本地 commit;填了才 push
|
|
114
|
+
branch: "main"
|
|
115
|
+
note:
|
|
116
|
+
tag: "inbox" # 快速笔记默认 tag
|
|
117
|
+
ui:
|
|
118
|
+
showQuickNote: true # FAB 里显示快速笔记入口
|
|
119
|
+
showQuickNoteDock: true # 输入框上方快捷按钮
|
|
120
|
+
quickNoteMode: "native" # native=TW 原生编辑页 / card=Markdown 卡片
|
|
121
|
+
sidebarLabel: "TiddlyWiki" # 侧边栏入口显示名
|
|
122
|
+
showPanelStatus: true
|
|
123
|
+
showSyncButton: true
|
|
124
|
+
followDshTheme: true # 跟随 DSH 深浅主题
|
|
125
|
+
darkPalette: "$:/palettes/CupertinoDark"
|
|
126
|
+
tabLabel: "知识库" # 会话 Tab 名
|
|
127
|
+
showSessionTab: true
|
|
128
|
+
sendToAgent: { enabled: true }
|
|
129
|
+
uiLanguage: "" # 留空不干预;"zh-Hans" 自动启用简体
|
|
130
|
+
auth:
|
|
131
|
+
username: "" # 默认 loopback 匿名;暴露到非回环才需要
|
|
132
|
+
password: ""
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
> **运行时配置**:设置页写入的 `$:/plugins/dsh-tiddlywiki/config` tiddler 是 `config:` 块之上的覆盖层(tiddler 优先、随 wiki git 同步),改 note tag / git / ui 开关无需动 cordis。
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## 🌐 远程访问
|
|
140
|
+
|
|
141
|
+
TW 子进程只监听 **127.0.0.1 回环**;Agent 工具/快速笔记/同步都走 DSH 宿主进程→回环 TW,不受访问入口影响。浏览器里的 TW 编辑器 iframe 经**同源代理** `<DSH origin>/dsh-tiddlywiki/tw/` 访问(v0.6.0 起),所以通过 Tailscale / 内网 / 域名 / HTTPS 访问 DSH 时编辑器照常工作,且 TW 重启不打断编辑中的内容。
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## 👨💻 开发
|
|
146
|
+
|
|
147
|
+
需要 **Node.js ≥ 22**。
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
npm install
|
|
151
|
+
npm run typecheck # tsc --noEmit
|
|
152
|
+
npm run build # clean + host tsdown + client tsdown + wrap
|
|
153
|
+
npm run selftest # headless:spawn TW → REST 读写 → git → 退出回收
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
**改 bundle/seed 的再生成流水线**(不要手改 `seed-*.ts` 里的生成常量):
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
# 发送给 Agent 按钮(改 scripts/bundle/send-to-agent/ 后)
|
|
160
|
+
node scripts/build-send-to-agent-bundle.mjs
|
|
161
|
+
node scripts/gen-seed-send-to-agent.mjs scripts/bundle/send-to-agent.bundle.json src/host/seed-send-to-agent.ts
|
|
162
|
+
node scripts/verify-send-to-agent-bundle.mjs
|
|
163
|
+
|
|
164
|
+
# 渲染路由(改 scripts/bundle/render/server-routes/render.js 后)
|
|
165
|
+
node scripts/build-render-bundle.mjs
|
|
166
|
+
node scripts/gen-seed-render.mjs scripts/bundle/render.bundle.json src/host/seed-render.ts
|
|
167
|
+
|
|
168
|
+
# 首页(改 wiki 的 🏠 主页/所有标签/标签笔记 .tid 后)
|
|
169
|
+
node scripts/gen-seed-home.mjs '<wiki>/tiddlers/🏠 主页.tid' '<wiki>/tiddlers/所有标签.tid' '<wiki>/tiddlers/标签笔记.tid' src/host/seed-home.ts
|
|
170
|
+
|
|
171
|
+
# 随后 npm run build
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
**产物约定**:`lib/` 内**零** `@deepseek-ai` 运行时 import;client 必须 minify(否则 >1MB 被注册表校验拒绝);`react`/`tiddlywiki` 不打包(运行时解析)。
|
|
175
|
+
|
|
176
|
+
### 路由参考(开发者)
|
|
177
|
+
|
|
178
|
+
| 路由 | 方法 | 用途 |
|
|
179
|
+
|---|---|---|
|
|
180
|
+
| `/dsh-tiddlywiki/status` | GET | 面板健康(service/url/git/tag/ui) |
|
|
181
|
+
| `/dsh-tiddlywiki/note` `/edit` `/tags` `/recent` `/get` `/search` | POST/GET | 快速笔记、打开编辑器、tag/最近/单个/搜索 |
|
|
182
|
+
| `/dsh-tiddlywiki/sync` `/upload` `/restart` | POST | 一键同步、文件上传、重启 TW |
|
|
183
|
+
| `/dsh-tiddlywiki/session/summary` | POST | 会话「知识库」Tab 汇总 |
|
|
184
|
+
| `/dsh-tiddlywiki/agent/sessions` `/modes` `/send` `/create` | GET/POST | TW「发送给 Agent」:会话/模式/发送/新建 |
|
|
185
|
+
| `/dsh-tiddlywiki/api/*` | any | 透传 TW 服务(JSON) |
|
|
186
|
+
| `/dsh-tiddlywiki/tw/*` | any | 同源 TW 代理(远程访问核心) |
|
|
187
|
+
| `/dsh-tiddlywiki/admin/seeds` `/run` `/remove` | GET/POST | seed 状态 / 运行 / 反初始化 |
|
|
188
|
+
|
|
189
|
+
### 项目结构
|
|
190
|
+
|
|
191
|
+
```
|
|
192
|
+
src/
|
|
193
|
+
├── index.ts # host 入口:装配 WikiServer/路由/工具/提示词/自动 commit
|
|
194
|
+
├── sdk.ts # 自包含 defineTool + dshHomePath(零 @deepseek-ai 运行时依赖)
|
|
195
|
+
├── host/
|
|
196
|
+
│ ├── wiki.ts # WikiServer:spawn/kill/自愈/端口探测/就绪轮询;TW_PROXY_PATH 同源代理
|
|
197
|
+
│ ├── tw-api.ts # TiddlyWeb REST 客户端
|
|
198
|
+
│ ├── git.ts # git init/commit/pull/push/sync/status + AutoCommitter
|
|
199
|
+
│ ├── routes.ts # 全部 DSH 路由 + agent-send/create/modes + session/summary
|
|
200
|
+
│ ├── http.ts # 共用 HTTP 助手(readBody/json)
|
|
201
|
+
│ ├── session-summary.ts # 会话「知识库」Tab 后端
|
|
202
|
+
│ ├── admin.ts # 设置页后台:tiddlywiki.info 读写 + /admin/*
|
|
203
|
+
│ ├── config.ts # ConfigStore:cordis config 基底 + 配置 tiddler 覆盖层
|
|
204
|
+
│ ├── seeds.ts # 统一 seed 注册表(7 项:check/run(force)/remove)
|
|
205
|
+
│ ├── seed-*.ts # 各 seed 实现(bundle/首页常量由脚本生成,勿手改)
|
|
206
|
+
│ └── tools.ts # 10 个 tiddlywiki_* 工具(列表式注册)
|
|
207
|
+
└── client/ # 浏览器半部
|
|
208
|
+
├── index.ts # client 入口(inject ['slots'],纯 DOM,永不 throw)
|
|
209
|
+
├── endpoints.ts # 客户端同源端点常量
|
|
210
|
+
├── knowledge-fab.ts / quick-note-dock.ts / note-widget.ts / editor-popup.ts
|
|
211
|
+
│ # 知识库 FAB / 快捷按钮 / 快速笔记 / 原生编辑弹窗
|
|
212
|
+
├── markdown-editor.ts # CodeMirror 6 Markdown 编辑器
|
|
213
|
+
├── session-summary.ts # 会话「知识库」Tab(conversation.view 槽位)
|
|
214
|
+
├── tool-views.ts # 回复流工具卡片(tool.call.toolview)
|
|
215
|
+
├── theme-sync.ts / panel.ts / sidebar-entry.ts / sync-button.ts
|
|
216
|
+
└── settings-page.ts / ui-config.ts / state.ts / styles.ts / toast.ts
|
|
217
|
+
scripts/ # 构建/校验/再生成脚本
|
|
218
|
+
docs/seed-initialization.md # seed 机制详解(权威)
|
|
219
|
+
lib/ # 预构建产物(发布含 lib/**,提交入库;零 @deepseek-ai 运行时 import)
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
## 🕘 版本记录
|
|
225
|
+
|
|
226
|
+
> 最近几个主要版本的一句话记录(完整变更见 [Releases](https://github.com/bbqisbbq/dsh-tiddlywiki/releases) / git log)。
|
|
227
|
+
|
|
228
|
+
- **v0.16.18**(2026-09-07):README 全面精简重写;seed 优化——首页 seed 跟随 wiki 现状(🏠 主页)、修「所有文章」回主页死链、doc-note 文案修正。
|
|
229
|
+
- **v0.16.17**(2026-09-07):点击快速笔记可选直达 TW 原生编辑页(`ui.quickNoteMode`)+ 修「在 TW 中编辑」弹窗 ✕ 关不掉。
|
|
230
|
+
- **v0.16.16**(2026-09-07):修会话知识库 Tab 误入编辑草稿显示源码——三层防误编辑(清残留草稿/吞草稿创建/禁 ✏️)。
|
|
231
|
+
- **v0.16.15**(2026-09-07):`put`/`batch_put` 未指定类型自动默认 `text/markdown`;警告 `fields.type` 是内容类型保留字段。
|
|
232
|
+
- **v0.16.14**(2026-09-07):修知识库 Tab「佚失条目」根因——浏览器端 TW 天生排除 `$:/temp`,改为 iframe 就绪后注入 + 原生 hash 导航。
|
|
233
|
+
- **v0.16.11**(2026-09-06):新增会话顶部「知识库」Tab(本会话相关 wiki 汇总,volatile `$:/temp`)。
|
|
234
|
+
- **v0.16.0**(2026-09-05):回复流原生 TW 工具卡片 + 可点击 wiki 链接(新增 `render-route` seed)。
|
|
235
|
+
- **v0.15.0**(2026-09-05):初始化不强制 + 可反初始化(seed 拆核心/可选两层)。
|
|
236
|
+
- **v0.14.0**(2026-09-05):「发送给 Agent」按钮独立图标 + 附加说明 + 权限选择。
|
|
237
|
+
- **v0.13.0**(2026-09-04):menubar 顶栏主题自适应。
|
|
238
|
+
- **v0.12.0**(2026-09-04):新默认主页 + 「所有文章」两列分页页。
|
|
239
|
+
- **v0.11.0**(2026-09-04):「发送给 Agent」支持选择工作模式(Agent 预设)。
|
|
240
|
+
- **v0.10.0**(2026-09-04):统一 seed 注册表 + 设置页「初始化」。
|
|
241
|
+
- **v0.8.0**(2026-09-04):嵌入式 TW 跟随 DSH 深浅主题。
|
|
242
|
+
- **v0.7.0**(2026-09-03):TW 一键把当前笔记发送到 dsh 会话。
|
|
243
|
+
- **v0.6.0**(2026-09-03):同源代理(远程访问核心)。
|
|
244
|
+
- **v0.5.0**(2026-09-03):Agent 工具扩充 + 快速笔记草稿自动保存 + 统一知识库 FAB。
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
## 📦 发布
|
|
249
|
+
|
|
250
|
+
```bash
|
|
251
|
+
npm publish # 版本号在 package.json;文件白名单见 files 字段
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
`tiddlywiki` 依赖体较大(含全部语言包/插件)。
|
|
255
|
+
|
|
256
|
+
---
|
|
257
|
+
|
|
258
|
+
## 🔗 仓库与发布元数据
|
|
259
|
+
|
|
260
|
+
- **GitHub**:https://github.com/bbqisbbq/dsh-tiddlywiki
|
|
261
|
+
- **npm**:`dsh-tiddlywiki`(https://www.npmjs.com/package/dsh-tiddlywiki)
|
|
262
|
+
- 说明笔记、首页、所有文章等预置内容由 seed 机制写入 wiki(见 [🧩 初始化](#🧩-初始化一次性预置))
|
|
263
|
+
- MIT;Node ≥ 22;GitHub topics:`dsh` `dsh-plugin` `tiddlywiki` `knowledge-base` `note-taking` `git-sync` `agent-tools` 等
|