dsh-tiddlywiki 0.1.1 → 0.1.2
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 +21 -21
- package/README.md +203 -201
- package/cordis.patch.yml +13 -13
- package/lib/client.bundle.js +46 -1
- package/lib/client.js +46 -1
- package/lib/index.js +2152 -2152
- package/package.json +79 -79
- package/src/client/editor-popup.ts +121 -121
- package/src/client/index.ts +76 -76
- package/src/client/note-widget.ts +210 -210
- package/src/client/panel.ts +345 -304
- package/src/client/settings-page.ts +397 -397
- package/src/client/sidebar-entry.ts +148 -148
- package/src/client/state.ts +39 -39
- package/src/client/styles.ts +242 -235
- package/src/client/toast.ts +22 -22
- package/src/host/admin.ts +408 -408
- package/src/host/config.ts +86 -86
- package/src/host/git.ts +218 -218
- package/src/host/routes.ts +233 -233
- package/src/host/seed-notes.ts +62 -62
- package/src/host/tools.ts +254 -254
- package/src/host/tw-api.ts +157 -157
- package/src/host/wiki.ts +287 -287
- package/src/index.ts +331 -331
- package/src/sdk.ts +198 -198
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,203 @@
|
|
|
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` `
|
|
63
|
-
| `description` | 见 package.json(一句话说明插件的用途) |
|
|
64
|
-
| `license` | MIT |
|
|
65
|
-
| `homepage` / `repository` / `bugs` | 均指向 https://github.com/bbqisbbq/dsh-tiddlywiki |
|
|
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
|
-
npm
|
|
164
|
-
npm run
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
├── host
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
│ ├──
|
|
190
|
-
│ ├──
|
|
191
|
-
│ ├──
|
|
192
|
-
│ ├──
|
|
193
|
-
│
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
├──
|
|
198
|
-
├──
|
|
199
|
-
├──
|
|
200
|
-
|
|
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
|
+
| 快速笔记 | 聊天区右下角常驻悬浮控件(可折叠,标题/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` `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
|
+
auth:
|
|
89
|
+
username: "" # 默认 loopback 匿名;暴露到非 loopback 时才需要
|
|
90
|
+
password: ""
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
`config:` 块随 profile 被 dsh-market 带走;wiki 数据(`$DSH_HOME/tiddlywiki`)
|
|
94
|
+
走 git,不走 dsh-market。
|
|
95
|
+
|
|
96
|
+
> 运行时配置:设置页(见「设置页」)写入的 `$:/plugins/dsh-tiddlywiki/config`
|
|
97
|
+
> tiddler 是 `config:` 块之上的覆盖层(tiddler 优先、随 wiki 的 git 同步)。
|
|
98
|
+
> 无需改动 cordis 也能改 note tag / git 开关等。
|
|
99
|
+
|
|
100
|
+
## 使用
|
|
101
|
+
|
|
102
|
+
### Agent(工具)
|
|
103
|
+
|
|
104
|
+
- `tiddlywiki_search {query, tag?}` — 检索非系统 tiddler,返回标题/标签/摘要。
|
|
105
|
+
- `tiddlywiki_get {title}` — 读单个 tiddler 全文。
|
|
106
|
+
- `tiddlywiki_put {title, text, tags?, fields?}` — 写/覆盖 tiddler。
|
|
107
|
+
- `tiddlywiki_delete {title}` — 删除 tiddler。
|
|
108
|
+
- `tiddlywiki_git_sync {action: pull|push|sync, message?}` — git 操作。
|
|
109
|
+
|
|
110
|
+
同步纪律(三条):开工先 `pull --rebase --autostash`;收工 `commit + push`;
|
|
111
|
+
自动 commit 防抖 60s。真冲突 → abort 并报冲突文件,agent 人工处理,不自动吞数据。
|
|
112
|
+
|
|
113
|
+
### 人(GUI)
|
|
114
|
+
|
|
115
|
+
- 侧边栏「TiddlyWiki」按钮开关中央编辑器面板。
|
|
116
|
+
- 右下角「快速笔记」悬浮控件:写草稿/随手记,Ctrl+Enter 保存为独立 tiddler;
|
|
117
|
+
或点「**✏️ 在 TW 中编辑**」——保存后**弹出独立小窗**(可拖动/缩放)加载 TiddlyWiki **原生编辑器**编辑该条。
|
|
118
|
+
- 面板服务异常时显示错误 +「重试」按钮(POST `/dsh-tiddlywiki/restart`)。
|
|
119
|
+
|
|
120
|
+
### 设置页(插件/主题管理 + 配置)
|
|
121
|
+
|
|
122
|
+
DSH **设置 → TiddlyWiki 知识库** 是插件的配置面板(`settings.section`):
|
|
123
|
+
|
|
124
|
+
| 区块 | 内容 |
|
|
125
|
+
|---|---|
|
|
126
|
+
| 状态/重启 | TW 运行状态 + git 概览 + 「重启 TW」按钮 |
|
|
127
|
+
| 常规配置 | 快速笔记默认 tag、git 自动 commit/防抖/远端/分支——改了什么保存什么 |
|
|
128
|
+
| 插件管理 | 自带官方插件勾选(可搜索)→ 应用并自动重启 TW |
|
|
129
|
+
| 主题管理 | 自带主题**多选加载 + 单选活动** → 应用并自动重启 TW |
|
|
130
|
+
| 语言管理 | 自带官方语言包勾选(含 zh-Hans/zh-CN 简体)→ 应用并自动重启 TW |
|
|
131
|
+
|
|
132
|
+
- 配置写入 wiki 内的 `$:/plugins/dsh-tiddlywiki/config` tiddler(JSON),随 git 同步;
|
|
133
|
+
作为 **cordis `config:` 块之上的覆盖层**(tiddler 优先),以后加配置项只需扩展该对象。
|
|
134
|
+
- git 类配置修改后在 **重启 dsh web 后生效**(bootstrap 时读取)。
|
|
135
|
+
- 插件/主题/语言均只管理 tiddlywiki 包**自带**的官方清单(`plugins/tiddlywiki/*`、
|
|
136
|
+
`themes/tiddlywiki/*`、包根 `languages/*`),全部离线、官方原版。
|
|
137
|
+
- **主题机制(重点)**:TW 视觉主题由 **`$:/theme`** tiddler 决定(浏览器 themeManager),
|
|
138
|
+
`info.themes` 只决定**加载哪些主题插件**。主题之间有**依赖链**
|
|
139
|
+
(`plugin.info` 的 `dependents`):`vanilla ← snowwhite ← heavier/centralised/readonly/starlight`,
|
|
140
|
+
`vanilla ← tight/seamless`。设置页因此是**两层**:每行主题一个 `☑ 加载`(多选,
|
|
141
|
+
= TW 里可用的主题)加一个 `◉ 活动`(单选 = 当前视觉主题)。应用时插件会:
|
|
142
|
+
1. 把加载集(含所选活动主题)的**完整依赖链**写入 `info.themes`(如 heavier →
|
|
143
|
+
`[vanilla, snowwhite, heavier]`),否则激活 heavier 时会丢掉 70KB 的 vanilla 基座样式;
|
|
144
|
+
2. 把 **`$:/theme` 设为所选活动主题**(激活它),然后重启 TW。
|
|
145
|
+
样式为空壳的主题(如本版 tight-heavier)会自动从清单里隐藏,避免选了没效果。
|
|
146
|
+
|
|
147
|
+
### 界面语言(中文)
|
|
148
|
+
|
|
149
|
+
TW 的界面语言由**语言插件**决定,不是某个配置字符串。tiddlywiki 包在
|
|
150
|
+
`node_modules/tiddlywiki/languages/` 下**自带全部官方语言包**(zh-Hans 简体、zh-CN、
|
|
151
|
+
zh-Hant、en-GB、ja-JP…),本插件离线启用即可:
|
|
152
|
+
|
|
153
|
+
- **设置 → TiddlyWiki 知识库 → 语言管理**:勾选 `zh-Hans`(简体)→「应用语言(重启 TW)」。
|
|
154
|
+
插件会把它写入 `tiddlywiki.info` 的 `languages` 数组,并固定 `$:/language` 为
|
|
155
|
+
`$:/languages/zh-Hans`,重启后 TW 界面即变为简体中文(已持久化,重启仍在)。
|
|
156
|
+
- **配置自动应用**:在设置页常规配置里写入 `uiLanguage: "zh-Hans"`,每次启动 dsh web 时
|
|
157
|
+
自动启用该语言并固定 `$:/language`(若尚未启用)。留空则不干预。
|
|
158
|
+
- 中文包缺字/想换繁中:语言管理里改勾 `zh-Hant` 或 `zh-TW` 再应用即可。
|
|
159
|
+
|
|
160
|
+
## 开发
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
npm install
|
|
164
|
+
npm run typecheck # tsc --noEmit
|
|
165
|
+
npm run build # clean + host tsdown + client tsdown + wrap
|
|
166
|
+
npm run selftest # headless:spawn TW → REST 读写 → git → 退出回收
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
产物约定(§4.4 教训,发布必守):`lib/` 内**零** `@deepseek-ai` 运行时 import
|
|
170
|
+
(`src/sdk.ts` 自实现 `defineTool` / `dshHomePath`,类型用结构接口)。
|
|
171
|
+
发布前用 `grep -r "@deepseek-ai" lib/` 验证。
|
|
172
|
+
|
|
173
|
+
## 发布
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
# 版本号在 package.json;文件白名单见 files 字段
|
|
177
|
+
npm publish
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
`tiddlywiki` 依赖体较大(含全部语言包/插件),发布文档需注明。
|
|
181
|
+
|
|
182
|
+
## 结构
|
|
183
|
+
|
|
184
|
+
```
|
|
185
|
+
src/
|
|
186
|
+
├── index.ts # host 入口:装配 WikiServer/路由/工具/prompt/自动 commit
|
|
187
|
+
├── sdk.ts # 自包含 defineTool + dshHomePath(零 @deepseek-ai 运行时依赖)
|
|
188
|
+
├── host/
|
|
189
|
+
│ ├── wiki.ts # WikiServer:spawn/kill/自愈/端口探测/就绪轮询
|
|
190
|
+
│ ├── tw-api.ts # TiddlyWeb REST 客户端
|
|
191
|
+
│ ├── git.ts # git init/commit/pull/push/sync/status + AutoCommitter
|
|
192
|
+
│ ├── routes.ts # /status /note /restart /api/* 路由
|
|
193
|
+
│ ├── admin.ts # 设置页后台:tiddlywiki.info 读写 + 目录枚举 + /admin/* 路由
|
|
194
|
+
│ ├── config.ts # ConfigStore:cordis config 基底 + 配置 tiddler 覆盖层
|
|
195
|
+
│ └── tools.ts # 5 个工具(列表式注册,可扩展)
|
|
196
|
+
└── client/
|
|
197
|
+
├── index.ts # client 入口(纯 DOM + settings.section 注册,永不 throw)
|
|
198
|
+
├── styles.ts / state.ts / toast.ts
|
|
199
|
+
├── sidebar-entry.ts # 侧边栏入口
|
|
200
|
+
├── panel.ts # 中央列 iframe 面板(fixed 覆盖层,钉住整列)
|
|
201
|
+
├── note-widget.ts # 悬浮快速笔记
|
|
202
|
+
└── settings-page.ts # 设置页(插件/主题/语言管理 + 常规配置)
|
|
203
|
+
```
|
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
|
package/lib/client.bundle.js
CHANGED
|
@@ -74,6 +74,13 @@ html[data-dsh-tw-active] .dshDesktopConversationSurface > :not([data-dsh-tw-view
|
|
|
74
74
|
}
|
|
75
75
|
.dsh-tw-panel-bar button:hover { background: var(--dsw-alias-interactive-bg-hover, rgba(128,128,128,.12)); }
|
|
76
76
|
.dsh-tw-panel-title { font-weight: 600; margin-right: auto; }
|
|
77
|
+
/* dsh-better-sidebar coexistence: the floating toggle cluster (two 28px
|
|
78
|
+
buttons at the viewport's top-right) lives above the panel (z-index is
|
|
79
|
+
handled in JS — the panel stays below the host layer), so reserve the
|
|
80
|
+
cluster's width at the panel bar's right end — mirroring how
|
|
81
|
+
dsh-better-sidebar pads the DSH session header — and the panel's own
|
|
82
|
+
状态/重载 buttons never sit underneath it. */
|
|
83
|
+
.dsh-tw-view[data-sidebar-host] .dsh-tw-panel-bar { padding-right: 80px; }
|
|
77
84
|
.dsh-tw-status-chip { font-variant-numeric: tabular-nums; }
|
|
78
85
|
.dsh-tw-status-chip[data-state="running"] { color: var(--dsw-alias-state-success-primary, #3eaa5f); }
|
|
79
86
|
.dsh-tw-status-chip[data-state="starting"] { color: var(--dsw-alias-state-warning-primary, #d9822b); }
|
|
@@ -429,10 +436,35 @@ const ACTIVATE_EVENT = "dsh-panel-activate";
|
|
|
429
436
|
const PANEL_NAME = "dsh-tiddlywiki";
|
|
430
437
|
/** Overlay z-index: above the shell content, below the note widget (950). */
|
|
431
438
|
const PANEL_Z_INDEX = 40;
|
|
439
|
+
/**
|
|
440
|
+
* dsh-better-sidebar's unified fixed host layer (its persistent
|
|
441
|
+
* expand/collapse toggle cluster lives inside it, at a global z-index of 25
|
|
442
|
+
* — its internal 45 is trapped by the host's stacking context). When this
|
|
443
|
+
* host is present the panel must stay BELOW it, so the sidebar toggle
|
|
444
|
+
* buttons stay visible and clickable above the full-screen TW panel.
|
|
445
|
+
*/
|
|
446
|
+
const PANEL_HOST_SELECTOR = "[data-dsh-panel-host]";
|
|
447
|
+
/** The app's own shell overlay layer (dsh-client-ui-layout pins it at 20). */
|
|
448
|
+
const APP_OVERLAY_Z_INDEX = 20;
|
|
432
449
|
/** Safety re-measure cadence for shell layout changes CSS can't see. */
|
|
433
450
|
const SYNC_INTERVAL_MS = 2e3;
|
|
434
451
|
const STATUS_ENDPOINT$1 = "/dsh-tiddlywiki/status";
|
|
435
452
|
const RESTART_ENDPOINT$1 = "/dsh-tiddlywiki/restart";
|
|
453
|
+
/**
|
|
454
|
+
* The panel's z-index: below any dsh-better-sidebar host layer so its
|
|
455
|
+
* persistent toggle cluster (top-right corner) stays visible and clickable
|
|
456
|
+
* above the full-screen TW panel, otherwise the default 40. The host's live
|
|
457
|
+
* computed z-index is read instead of hardcoding 25, so the rule tracks
|
|
458
|
+
* plugin updates; the panel is still clamped above the app's own shell
|
|
459
|
+
* overlay layer (dsh-client-ui-layout pins it at 20).
|
|
460
|
+
*/
|
|
461
|
+
function resolvePanelZIndex() {
|
|
462
|
+
const host = document.querySelector(PANEL_HOST_SELECTOR);
|
|
463
|
+
if (host === null) return PANEL_Z_INDEX;
|
|
464
|
+
const parsed = parseInt(getComputedStyle(host).zIndex, 10);
|
|
465
|
+
if (!Number.isFinite(parsed)) return PANEL_Z_INDEX;
|
|
466
|
+
return Math.max(APP_OVERLAY_Z_INDEX, Math.min(PANEL_Z_INDEX, parsed - 1));
|
|
467
|
+
}
|
|
436
468
|
function conversationColumn() {
|
|
437
469
|
for (const selector of COLUMN_SELECTORS) {
|
|
438
470
|
const el = document.querySelector(selector);
|
|
@@ -526,13 +558,25 @@ function mountPanel(state) {
|
|
|
526
558
|
if (container.style.width !== width) container.style.width = width;
|
|
527
559
|
if (container.style.height !== height) container.style.height = height;
|
|
528
560
|
};
|
|
561
|
+
/**
|
|
562
|
+
* Coexist with dsh-better-sidebar: keep the panel's z-index below the
|
|
563
|
+
* host layer (so its toggle cluster stays clickable above the panel) and
|
|
564
|
+
* flag the host's presence so CSS can reserve the cluster's width at the
|
|
565
|
+
* panel bar's right end. Re-run whenever the host mounts/unmounts.
|
|
566
|
+
*/
|
|
567
|
+
const applyChrome = () => {
|
|
568
|
+
if (container === void 0) return;
|
|
569
|
+
container.style.zIndex = String(resolvePanelZIndex());
|
|
570
|
+
if (document.querySelector(PANEL_HOST_SELECTOR) !== null) container.dataset.sidebarHost = "1";
|
|
571
|
+
else delete container.dataset.sidebarHost;
|
|
572
|
+
};
|
|
529
573
|
const ensure = () => {
|
|
530
574
|
if (container !== void 0) return;
|
|
531
575
|
columnEl = conversationColumn();
|
|
532
576
|
if (columnEl === void 0) return;
|
|
533
577
|
container = build();
|
|
534
578
|
container.style.position = "fixed";
|
|
535
|
-
|
|
579
|
+
applyChrome();
|
|
536
580
|
document.body.append(container);
|
|
537
581
|
syncRect();
|
|
538
582
|
};
|
|
@@ -634,6 +678,7 @@ function mountPanel(state) {
|
|
|
634
678
|
};
|
|
635
679
|
const waitObserver = new MutationObserver(() => {
|
|
636
680
|
ensure();
|
|
681
|
+
applyChrome();
|
|
637
682
|
});
|
|
638
683
|
waitObserver.observe(document.body, {
|
|
639
684
|
childList: true,
|