dsh-tiddlywiki 0.1.1 → 0.2.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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 dsh-tiddlywiki contributors
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 dsh-tiddlywiki contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,201 +1,206 @@
1
- # dsh-tiddlywiki
2
-
3
- TiddlyWiki 5 as the DSH **persistent knowledge base**. Agent can read/write
4
- tiddlers through `tiddlywiki_*` tools; the human edits in a full TiddlyWiki
5
- editor embedded in the GUI center column; the chat area gets a floating
6
- quick-note widget. Data syncs/backs up through **git**; configuration moves
7
- between machines through **dsh-market**.
8
-
9
- > 设计文档:`notes/dsh-tiddlywiki-plugin-design.md`(已锁定)。本 README 是安装/配置/使用/发布要点。
10
-
11
- ---
12
-
13
- ## 为什么做这个(初衷)
14
-
15
- 等 agent 干活的时候,人常是干坐着的——想随手写点什么,又不想切来切去:开个便签、再切到笔记软件、再切回来,思路早断了。市面上没找到一款专门给这种「陪跑式摸鱼」用的 DSH 插件;去联动别的笔记软件,又总觉得隔了一层、动静太大。
16
-
17
- TiddlyWiki 的特性正好合适:单文件、纯文本、wiki 语法、自带 git 同步,天生适合**随手写点小东西**。于是把它做成 DSH 的原生插件——不用离开当前界面,聊天区右下角就有个快速笔记,想写就写;要正经编辑,弹出 TW 原生编辑器;写下的东西自动进 git,既是知识库也是备份。
18
-
19
- ---
20
-
21
- ## 它能做什么
22
-
23
- | 能力 | 说明 |
24
- |---|---|
25
- | Agent 工具 | `tiddlywiki_search` / `get` / `put` / `delete` / `git_sync` |
26
- | 人编辑 | 侧边栏「TiddlyWiki」入口 → 中央列内嵌完整 TW 编辑器(iframe 直连 TW 服务) |
27
- | 快速笔记 | 聊天区右下角常驻悬浮控件(可折叠,标题/tag 可自定义,Ctrl+Enter 保存) |
28
- | 零摩擦生命周期 | 随 dsh 自动启动/关闭;TW 子进程崩溃自动重启(退避);端口/目录/首次 git init 全自动 |
29
- | 同步 | 单线程交替模型:开工 pull,收工 commit+push,自动 commit(60s 防抖,可关) |
30
-
31
- ## 安装
32
-
33
- 插件随 dsh 插件系统安装,三种方式任选(装完**重启 dsh web** 生效;把 `--profile web` 换成你自己的 profile 名):
34
-
35
- ```bash
36
- # ① npm 发布包(推荐)
37
- dsh plugin --profile web add dsh-tiddlywiki
38
-
39
- # ② 直接从 GitHub 安装(需要 git;仓库已含预构建的 lib,开箱即用)
40
- dsh plugin --profile web add github:bbqisbbq/dsh-tiddlywiki
41
-
42
- # ③ 本地开发 / 改源码(link 方式:改完 src 后 npm run build 即生效,免重装)
43
- dsh plugin --profile web add link:C:\Users\bbq\.dsh\plugins\dsh-tiddlywiki
44
- ```
45
-
46
- 首次启动会向 wiki **幂等写入**一篇「dsh-tiddlywiki 插件说明」笔记(tag `docs`)。
47
-
48
- ## 发布 / 仓库
49
-
50
- - **GitHub(公开)**:https://github.com/bbqisbbq/dsh-tiddlywiki
51
- - **npm**:`dsh-tiddlywiki`(`npm i dsh-tiddlywiki`;https://www.npmjs.com/package/dsh-tiddlywiki )
52
- - **说明笔记**:插件在首次启动时向 wiki **幂等写入**一篇「`dsh-tiddlywiki 插件说明`」笔记(tag `docs`)——不存在才写、手动编辑不被覆盖、删除后重启会重建;当前 live wiki 里已有一份。
53
-
54
- ## 可被检索的标准字段
55
-
56
- 为方便 GitHub / npm / 搜索引擎发现,包与仓库带以下标准元数据:
57
-
58
- | 字段 | 值 |
59
- |---|---|
60
- | npm 包名 | `dsh-tiddlywiki` |
61
- | npm `keywords` | `dsh` `dsh-plugin` `tiddlywiki` `knowledge-base` `note-taking` `notes` `wiki` `git-sync` `agent-tools` `plugin` |
62
- | GitHub topics | `dsh` `dsh-plugin` `tiddlywiki` `knowledge-base` `note-taking` `wiki` `agent` |
63
- | `description` | 见 package.json(一句话说明插件的用途) |
64
- | `license` | MIT |
65
- | `homepage` / `repository` / `bugs` | 均指向 https://github.com/bbqisbbq/dsh-tiddlywiki |
66
-
67
- ## 配置
68
-
69
- 插件行默认如下(缺省即用默认值,无需手动配置)。如需自定义,编辑
70
- `profiles/web/cordis.patch.yml` 或 profile 的 bundle 层,给该行加 `config:`:
71
-
72
- ```yaml
73
- - id: dsh-tiddlywiki
74
- name: dsh-tiddlywiki
75
- config:
76
- wikiRoot: "$DSH_HOME/tiddlywiki" # 缺省自动展开
77
- wiki: "main"
78
- port: 0 # 0 = 自动探测空闲端口
79
- git:
80
- autoCommit: true
81
- debounceMs: 60000
82
- remote: "" # 空 = 仅本地 commit;填了才 push
83
- branch: "main"
84
- note:
85
- tag: "inbox"
86
- auth:
87
- username: "" # 默认 loopback 匿名;暴露到非 loopback 时才需要
88
- password: ""
89
- ```
90
-
91
- `config:` 块随 profile 被 dsh-market 带走;wiki 数据(`$DSH_HOME/tiddlywiki`)
92
- git,不走 dsh-market。
93
-
94
- > 运行时配置:设置页(见「设置页」)写入的 `$:/plugins/dsh-tiddlywiki/config`
95
- > tiddler 是 `config:` 块之上的覆盖层(tiddler 优先、随 wiki 的 git 同步)。
96
- > 无需改动 cordis 也能改 note tag / git 开关等。
97
-
98
- ## 使用
99
-
100
- ### Agent(工具)
101
-
102
- - `tiddlywiki_search {query, tag?}` — 检索非系统 tiddler,返回标题/标签/摘要。
103
- - `tiddlywiki_get {title}` — 读单个 tiddler 全文。
104
- - `tiddlywiki_put {title, text, tags?, fields?}` — 写/覆盖 tiddler。
105
- - `tiddlywiki_delete {title}` — 删除 tiddler。
106
- - `tiddlywiki_git_sync {action: pull|push|sync, message?}` — git 操作。
107
-
108
- 同步纪律(三条):开工先 `pull --rebase --autostash`;收工 `commit + push`;
109
- 自动 commit 防抖 60s。真冲突 abort 并报冲突文件,agent 人工处理,不自动吞数据。
110
-
111
- ### 人(GUI)
112
-
113
- - 侧边栏「TiddlyWiki」按钮开关中央编辑器面板。
114
- - 右下角「快速笔记」悬浮控件:写草稿/随手记,Ctrl+Enter 保存为独立 tiddler;
115
- 或点「**✏️ 在 TW 中编辑**」——保存后**弹出独立小窗**(可拖动/缩放)加载 TiddlyWiki **原生编辑器**编辑该条。
116
- - 面板服务异常时显示错误 +「重试」按钮(POST `/dsh-tiddlywiki/restart`)。
117
-
118
- ### 设置页(插件/主题管理 + 配置)
119
-
120
- DSH **设置 TiddlyWiki 知识库** 是插件的配置面板(`settings.section`):
121
-
122
- | 区块 | 内容 |
123
- |---|---|
124
- | 状态/重启 | TW 运行状态 + git 概览 + 「重启 TW」按钮 |
125
- | 常规配置 | 快速笔记默认 tag、git 自动 commit/防抖/远端/分支——改了什么保存什么 |
126
- | 插件管理 | 自带官方插件勾选(可搜索)→ 应用并自动重启 TW |
127
- | 主题管理 | 自带主题**多选加载 + 单选活动** → 应用并自动重启 TW |
128
- | 语言管理 | 自带官方语言包勾选(含 zh-Hans/zh-CN 简体)→ 应用并自动重启 TW |
129
-
130
- - 配置写入 wiki 内的 `$:/plugins/dsh-tiddlywiki/config` tiddler(JSON),随 git 同步;
131
- 作为 **cordis `config:` 块之上的覆盖层**(tiddler 优先),以后加配置项只需扩展该对象。
132
- - git 类配置修改后在 **重启 dsh web 后生效**(bootstrap 时读取)。
133
- - 插件/主题/语言均只管理 tiddlywiki 包**自带**的官方清单(`plugins/tiddlywiki/*`、
134
- `themes/tiddlywiki/*`、包根 `languages/*`),全部离线、官方原版。
135
- - **主题机制(重点)**:TW 视觉主题由 **`$:/theme`** tiddler 决定(浏览器 themeManager),
136
- `info.themes` 只决定**加载哪些主题插件**。主题之间有**依赖链**
137
- (`plugin.info` `dependents`):`vanilla snowwhite heavier/centralised/readonly/starlight`,
138
- `vanilla tight/seamless`。设置页因此是**两层**:每行主题一个 `☑ 加载`(多选,
139
- = TW 里可用的主题)加一个 `◉ 活动`(单选 = 当前视觉主题)。应用时插件会:
140
- 1. 把加载集(含所选活动主题)的**完整依赖链**写入 `info.themes`(如 heavier
141
- `[vanilla, snowwhite, heavier]`),否则激活 heavier 时会丢掉 70KB 的 vanilla 基座样式;
142
- 2. **`$:/theme` 设为所选活动主题**(激活它),然后重启 TW。
143
- 样式为空壳的主题(如本版 tight-heavier)会自动从清单里隐藏,避免选了没效果。
144
-
145
- ### 界面语言(中文)
146
-
147
- TW 的界面语言由**语言插件**决定,不是某个配置字符串。tiddlywiki 包在
148
- `node_modules/tiddlywiki/languages/` 下**自带全部官方语言包**(zh-Hans 简体、zh-CN、
149
- zh-Hant、en-GB、ja-JP…),本插件离线启用即可:
150
-
151
- - **设置 → TiddlyWiki 知识库 → 语言管理**:勾选 `zh-Hans`(简体)→「应用语言(重启 TW)」。
152
- 插件会把它写入 `tiddlywiki.info` 的 `languages` 数组,并固定 `$:/language` 为
153
- `$:/languages/zh-Hans`,重启后 TW 界面即变为简体中文(已持久化,重启仍在)。
154
- - **配置自动应用**:在设置页常规配置里写入 `uiLanguage: "zh-Hans"`,每次启动 dsh web 时
155
- 自动启用该语言并固定 `$:/language`(若尚未启用)。留空则不干预。
156
- - 中文包缺字/想换繁中:语言管理里改勾 `zh-Hant` `zh-TW` 再应用即可。
157
-
158
- ## 开发
159
-
160
- ```bash
161
- npm install
162
- npm run typecheck # tsc --noEmit
163
- npm run build # clean + host tsdown + client tsdown + wrap
164
- npm run selftest # headless:spawn TW → REST 读写 → git → 退出回收
165
- ```
166
-
167
- 产物约定(§4.4 教训,发布必守):`lib/` 内**零** `@deepseek-ai` 运行时 import
168
- (`src/sdk.ts` 自实现 `defineTool` / `dshHomePath`,类型用结构接口)。
169
- 发布前用 `grep -r "@deepseek-ai" lib/` 验证。
170
-
171
- ## 发布
172
-
173
- ```bash
174
- # 版本号在 package.json;文件白名单见 files 字段
175
- npm publish
176
- ```
177
-
178
- `tiddlywiki` 依赖体较大(含全部语言包/插件),发布文档需注明。
179
-
180
- ## 结构
181
-
182
- ```
183
- src/
184
- ├── index.ts # host 入口:装配 WikiServer/路由/工具/prompt/自动 commit
185
- ├── sdk.ts # 自包含 defineTool + dshHomePath(零 @deepseek-ai 运行时依赖)
186
- ├── host/
187
- │ ├── wiki.ts # WikiServer:spawn/kill/自愈/端口探测/就绪轮询
188
- │ ├── tw-api.ts # TiddlyWeb REST 客户端
189
- ├── git.ts # git init/commit/pull/push/sync/status + AutoCommitter
190
- ├── routes.ts # /status /note /restart /api/* 路由
191
- ├── admin.ts # 设置页后台:tiddlywiki.info 读写 + 目录枚举 + /admin/* 路由
192
- │ ├── config.ts # ConfigStorecordis config 基底 + 配置 tiddler 覆盖层
193
- └── tools.ts # 5 个工具(列表式注册,可扩展)
194
- └── client/
195
- ├── index.ts # client 入口(纯 DOM + settings.section 注册,永不 throw)
196
- ├── styles.ts / state.ts / toast.ts
197
- ├── sidebar-entry.ts # 侧边栏入口
198
- ├── panel.ts # 中央列 iframe 面板(fixed 覆盖层,钉住整列)
199
- ├── note-widget.ts # 悬浮快速笔记
200
- └── settings-page.ts # 设置页(插件/主题/语言管理 + 常规配置)
201
- ```
1
+ # dsh-tiddlywiki
2
+
3
+ TiddlyWiki 5 as the DSH **persistent knowledge base**. Agent can read/write
4
+ tiddlers through `tiddlywiki_*` tools; the human edits in a full TiddlyWiki
5
+ editor embedded in the GUI center column; the chat area gets a floating
6
+ quick-note widget. Data syncs/backs up through **git**; configuration moves
7
+ between machines through **dsh-market**.
8
+
9
+ > 设计文档:`notes/dsh-tiddlywiki-plugin-design.md`(已锁定)。本 README 是安装/配置/使用/发布要点。
10
+
11
+ ---
12
+
13
+ ## 为什么做这个(初衷)
14
+
15
+ 等 agent 干活的时候,人常是干坐着的——想随手写点什么,又不想切来切去:开个便签、再切到笔记软件、再切回来,思路早断了。市面上没找到一款专门给这种「陪跑式摸鱼」用的 DSH 插件;去联动别的笔记软件,又总觉得隔了一层、动静太大。
16
+
17
+ TiddlyWiki 的特性正好合适:单文件、纯文本、wiki 语法、自带 git 同步,天生适合**随手写点小东西**。于是把它做成 DSH 的原生插件——不用离开当前界面,聊天区右下角就有个快速笔记,想写就写;要正经编辑,弹出 TW 原生编辑器;写下的东西自动进 git,既是知识库也是备份。
18
+
19
+ ---
20
+
21
+ ## 它能做什么
22
+
23
+ | 能力 | 说明 |
24
+ |---|---|
25
+ | Agent 工具 | `tiddlywiki_search` / `get` / `put` / `delete` / `git_sync` |
26
+ | 人编辑 | 侧边栏「TiddlyWiki」入口 → 中央列内嵌完整 TW 编辑器(iframe 直连 TW 服务) |
27
+ | 快速笔记 | 聊天区右下角常驻悬浮控件(可折叠,可多选/自动补全 tagCtrl+Enter 保存;设置页可整体隐藏) |
28
+ | 零摩擦生命周期 | 随 dsh 自动启动/关闭;TW 子进程崩溃自动重启(退避);端口/目录/首次 git init 全自动 |
29
+ | 同步 | 单线程交替模型:开工 pull,收工 commit+push,自动 commit(60s 防抖,可关) |
30
+
31
+ ## 安装
32
+
33
+ 插件随 dsh 插件系统安装,三种方式任选(装完**重启 dsh web** 生效;把 `--profile web` 换成你自己的 profile 名):
34
+
35
+ ```bash
36
+ # ① npm 发布包(推荐)
37
+ dsh plugin --profile web add dsh-tiddlywiki
38
+
39
+ # ② 直接从 GitHub 安装(需要 git;仓库已含预构建的 lib,开箱即用)
40
+ dsh plugin --profile web add github:bbqisbbq/dsh-tiddlywiki
41
+
42
+ # ③ 本地开发 / 改源码(link 方式:改完 src 后 npm run build 即生效,免重装)
43
+ dsh plugin --profile web add link:C:\Users\bbq\.dsh\plugins\dsh-tiddlywiki
44
+ ```
45
+
46
+ 首次启动会向 wiki **写入一次**「dsh-tiddlywiki 插件说明」笔记(tag `docs`),并默认安装「侧边移到左侧.css」界面补丁(把 TW 右侧栏移到左边;被删除后,只要设置页「侧边栏移左 CSS」开关开着就会随启动补丁还原)。
47
+
48
+ ## 发布 / 仓库
49
+
50
+ - **GitHub(公开)**:https://github.com/bbqisbbq/dsh-tiddlywiki
51
+ - **npm**:`dsh-tiddlywiki`(`npm i dsh-tiddlywiki`;https://www.npmjs.com/package/dsh-tiddlywiki )
52
+ - **说明笔记**:插件在**首次启动**时向 wiki **写入一次**「`dsh-tiddlywiki 插件说明`」笔记(tag `docs`)——只写一次、手动编辑不被覆盖、**删除后重启不会自动恢复**(一次性标记;清空 wiki 重装会再写入)。当前 live wiki 里已有一份。
53
+
54
+ ## 可被检索的标准字段
55
+
56
+ 为方便 GitHub / npm / 搜索引擎发现,包与仓库带以下标准元数据:
57
+
58
+ | 字段 | 值 |
59
+ |---|---|
60
+ | npm 包名 | `dsh-tiddlywiki` |
61
+ | npm `keywords` | `dsh` `dsh-plugin` `tiddlywiki` `knowledge-base` `note-taking` `notes` `wiki` `git-sync` `agent-tools` `plugin` |
62
+ | 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 个) |
63
+ | `description` | 见 package.json(一句话说明插件的用途) |
64
+ | `license` | MIT |
65
+ | `homepage` / `repository` / `bugs` | 均指向 https://github.com/bbqisbbq/dsh-tiddlywiki |
66
+
67
+ > 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`)设置。上表已按此执行并覆盖「用途 / 主题 / 语言 / 技术栈」。
68
+
69
+ ## 配置
70
+
71
+ 插件行默认如下(缺省即用默认值,无需手动配置)。如需自定义,编辑
72
+ `profiles/web/cordis.patch.yml` 或 profile 的 bundle 层,给该行加 `config:`:
73
+
74
+ ```yaml
75
+ - id: dsh-tiddlywiki
76
+ name: dsh-tiddlywiki
77
+ config:
78
+ wikiRoot: "$DSH_HOME/tiddlywiki" # 缺省自动展开
79
+ wiki: "main"
80
+ port: 0 # 0 = 自动探测空闲端口
81
+ git:
82
+ autoCommit: true
83
+ debounceMs: 60000
84
+ remote: "" # 空 = 仅本地 commit;填了才 push
85
+ branch: "main"
86
+ note:
87
+ tag: "inbox"
88
+ ui:
89
+ showQuickNote: true # 是否显示右下角「快速笔记」按钮
90
+ sidebarLeftCss: true # 是否启用「侧边移到左侧.css」补丁(被删后随启动还原)
91
+ auth:
92
+ username: "" # 默认 loopback 匿名;暴露到非 loopback 时才需要
93
+ password: ""
94
+ ```
95
+
96
+ `config:` 块随 profile dsh-market 带走;wiki 数据(`$DSH_HOME/tiddlywiki`)
97
+ 走 git,不走 dsh-market。
98
+
99
+ > 运行时配置:设置页(见「设置页」)写入的 `$:/plugins/dsh-tiddlywiki/config`
100
+ > tiddler 是 `config:` 块之上的覆盖层(tiddler 优先、随 wiki 的 git 同步)。
101
+ > 无需改动 cordis 也能改 note tag / git 开关 / ui 开关等。
102
+
103
+ ## 使用
104
+
105
+ ### Agent(工具)
106
+
107
+ - `tiddlywiki_search {query, tag?}` — 检索非系统 tiddler,返回标题/标签/摘要。
108
+ - `tiddlywiki_get {title}` 读单个 tiddler 全文。
109
+ - `tiddlywiki_put {title, text, tags?, fields?}` 写/覆盖 tiddler。
110
+ - `tiddlywiki_delete {title}` — 删除 tiddler。
111
+ - `tiddlywiki_git_sync {action: pull|push|sync, message?}` — git 操作。
112
+
113
+ 同步纪律(三条):开工先 `pull --rebase --autostash`;收工 `commit + push`;
114
+ 自动 commit 防抖 60s。真冲突 → abort 并报冲突文件,agent 人工处理,不自动吞数据。
115
+
116
+ ### 人(GUI)
117
+
118
+ - 侧边栏「TiddlyWiki」按钮开关中央编辑器面板。
119
+ - 右下角「快速笔记」悬浮控件:写草稿/随手记,Ctrl+Enter 保存为独立 tiddler;
120
+ 或点「**✏️ TW 中编辑**」——保存后**弹出独立小窗**(可拖动/缩放)加载 TiddlyWiki **原生编辑器**编辑该条。
121
+ - 面板服务异常时显示错误 +「重试」按钮(POST `/dsh-tiddlywiki/restart`)。
122
+
123
+ ### 设置页(插件/主题管理 + 配置)
124
+
125
+ DSH **设置 TiddlyWiki 知识库** 是插件的配置面板(`settings.section`):
126
+
127
+ | 区块 | 内容 |
128
+ |---|---|
129
+ | 状态/重启 | TW 运行状态 + git 概览 + 「重启 TW」按钮 |
130
+ | 常规配置 | 快速笔记默认 tag、git 自动 commit/防抖/远端/分支——改了什么保存什么 |
131
+ | 插件管理 | 自带官方插件勾选(可搜索)→ 应用并自动重启 TW |
132
+ | 主题管理 | 自带主题**多选加载 + 单选活动** 应用并自动重启 TW |
133
+ | 语言管理 | 自带官方语言包勾选(含 zh-Hans/zh-CN 简体)→ 应用并自动重启 TW |
134
+
135
+ - 配置写入 wiki 内的 `$:/plugins/dsh-tiddlywiki/config` tiddler(JSON),随 git 同步;
136
+ 作为 **cordis `config:` 块之上的覆盖层**(tiddler 优先),以后加配置项只需扩展该对象。
137
+ - git 类配置修改后在 **重启 dsh web 后生效**(bootstrap 时读取)。
138
+ - 插件/主题/语言均只管理 tiddlywiki 包**自带**的官方清单(`plugins/tiddlywiki/*`、
139
+ `themes/tiddlywiki/*`、包根 `languages/*`),全部离线、官方原版。
140
+ - **主题机制(重点)**:TW 视觉主题由 **`$:/theme`** tiddler 决定(浏览器 themeManager),
141
+ `info.themes` 只决定**加载哪些主题插件**。主题之间有**依赖链**
142
+ (`plugin.info` `dependents`):`vanilla snowwhite ← heavier/centralised/readonly/starlight`,
143
+ `vanilla tight/seamless`。设置页因此是**两层**:每行主题一个 `☑ 加载`(多选,
144
+ = TW 里可用的主题)加一个 `◉ 活动`(单选 = 当前视觉主题)。应用时插件会:
145
+ 1. 把加载集(含所选活动主题)的**完整依赖链**写入 `info.themes`(如 heavier →
146
+ `[vanilla, snowwhite, heavier]`),否则激活 heavier 时会丢掉 70KB 的 vanilla 基座样式;
147
+ 2. **`$:/theme` 设为所选活动主题**(激活它),然后重启 TW。
148
+ 样式为空壳的主题(如本版 tight-heavier)会自动从清单里隐藏,避免选了没效果。
149
+
150
+ ### 界面语言(中文)
151
+
152
+ TW 的界面语言由**语言插件**决定,不是某个配置字符串。tiddlywiki 包在
153
+ `node_modules/tiddlywiki/languages/` 下**自带全部官方语言包**(zh-Hans 简体、zh-CN、
154
+ zh-Hant、en-GB、ja-JP…),本插件离线启用即可:
155
+
156
+ - **设置 TiddlyWiki 知识库 → 语言管理**:勾选 `zh-Hans`(简体)→「应用语言(重启 TW)」。
157
+ 插件会把它写入 `tiddlywiki.info` 的 `languages` 数组,并固定 `$:/language` 为
158
+ `$:/languages/zh-Hans`,重启后 TW 界面即变为简体中文(已持久化,重启仍在)。
159
+ - **配置自动应用**:在设置页常规配置里写入 `uiLanguage: "zh-Hans"`,每次启动 dsh web 时
160
+ 自动启用该语言并固定 `$:/language`(若尚未启用)。留空则不干预。
161
+ - 中文包缺字/想换繁中:语言管理里改勾 `zh-Hant` 或 `zh-TW` 再应用即可。
162
+
163
+ ## 开发
164
+
165
+ ```bash
166
+ npm install
167
+ npm run typecheck # tsc --noEmit
168
+ npm run build # clean + host tsdown + client tsdown + wrap
169
+ npm run selftest # headless:spawn TW → REST 读写 → git → 退出回收
170
+ ```
171
+
172
+ 产物约定(§4.4 教训,发布必守):`lib/` 内**零** `@deepseek-ai` 运行时 import
173
+ (`src/sdk.ts` 自实现 `defineTool` / `dshHomePath`,类型用结构接口)。
174
+ 发布前用 `grep -r "@deepseek-ai" lib/` 验证。
175
+
176
+ ## 发布
177
+
178
+ ```bash
179
+ # 版本号在 package.json;文件白名单见 files 字段
180
+ npm publish
181
+ ```
182
+
183
+ `tiddlywiki` 依赖体较大(含全部语言包/插件),发布文档需注明。
184
+
185
+ ## 结构
186
+
187
+ ```
188
+ src/
189
+ ├── index.ts # host 入口:装配 WikiServer/路由/工具/prompt/自动 commit
190
+ ├── sdk.ts # 自包含 defineTool + dshHomePath(零 @deepseek-ai 运行时依赖)
191
+ ├── host/
192
+ │ ├── wiki.ts # WikiServerspawn/kill/自愈/端口探测/就绪轮询
193
+ ├── tw-api.ts # TiddlyWeb REST 客户端
194
+ │ ├── git.ts # git init/commit/pull/push/sync/status + AutoCommitter
195
+ ├── routes.ts # /status /note /restart /api/* 路由
196
+ ├── admin.ts # 设置页后台:tiddlywiki.info 读写 + 目录枚举 + /admin/* 路由
197
+ ├── config.ts # ConfigStore:cordis config 基底 + 配置 tiddler 覆盖层
198
+ │ └── tools.ts # 5 个工具(列表式注册,可扩展)
199
+ └── client/
200
+ ├── index.ts # client 入口(纯 DOM + settings.section 注册,永不 throw)
201
+ ├── styles.ts / state.ts / toast.ts
202
+ ├── sidebar-entry.ts # 侧边栏入口
203
+ ├── panel.ts # 中央列 iframe 面板(fixed 覆盖层,钉住整列)
204
+ ├── note-widget.ts # 悬浮快速笔记
205
+ └── settings-page.ts # 设置页(插件/主题/语言管理 + 常规配置)
206
+ ```
package/cordis.patch.yml CHANGED
@@ -1,13 +1,13 @@
1
- # dsh-tiddlywiki bundle patch: inserts the plugin row into the web profile
2
- # roster. Applied as a profile bundle layer (the `dsh.bundle.patch` manifest
3
- # field) over dsh-base; activate with
4
- # `dsh plugin --profile web add link:<path-to-this-package>` and restart dsh web.
5
- #
6
- # The row is a bare plugin by package name: the node half (exports ".") runs
7
- # in the host process (WikiServer, routes, tiddlywiki_* tools, prompt section,
8
- # auto-commit), and the `dsh.client` declaration in package.json makes the
9
- # browser half (exports "./client", served at /plugins/dsh-tiddlywiki/client.js)
10
- # load in the web GUI.
11
- - insert:
12
- - id: dsh-tiddlywiki
13
- name: dsh-tiddlywiki
1
+ # dsh-tiddlywiki bundle patch: inserts the plugin row into the web profile
2
+ # roster. Applied as a profile bundle layer (the `dsh.bundle.patch` manifest
3
+ # field) over dsh-base; activate with
4
+ # `dsh plugin --profile web add link:<path-to-this-package>` and restart dsh web.
5
+ #
6
+ # The row is a bare plugin by package name: the node half (exports ".") runs
7
+ # in the host process (WikiServer, routes, tiddlywiki_* tools, prompt section,
8
+ # auto-commit), and the `dsh.client` declaration in package.json makes the
9
+ # browser half (exports "./client", served at /plugins/dsh-tiddlywiki/client.js)
10
+ # load in the web GUI.
11
+ - insert:
12
+ - id: dsh-tiddlywiki
13
+ name: dsh-tiddlywiki