dsh-tiddlywiki 0.1.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 +21 -0
- package/README.md +172 -0
- package/cordis.patch.yml +13 -0
- package/lib/client.bundle.js +1417 -0
- package/lib/client.js +1427 -0
- package/lib/index.js +2153 -0
- package/lib/index.js.map +1 -0
- package/package.json +63 -0
- package/src/client/editor-popup.ts +121 -0
- package/src/client/index.ts +76 -0
- package/src/client/note-widget.ts +210 -0
- package/src/client/panel.ts +304 -0
- package/src/client/settings-page.ts +397 -0
- package/src/client/sidebar-entry.ts +148 -0
- package/src/client/state.ts +39 -0
- package/src/client/styles.ts +235 -0
- package/src/client/toast.ts +22 -0
- package/src/host/admin.ts +408 -0
- package/src/host/config.ts +86 -0
- package/src/host/git.ts +218 -0
- package/src/host/routes.ts +233 -0
- package/src/host/seed-notes.ts +62 -0
- package/src/host/tools.ts +254 -0
- package/src/host/tw-api.ts +157 -0
- package/src/host/wiki.ts +287 -0
- package/src/index.ts +331 -0
- package/src/sdk.ts +198 -0
package/LICENSE
ADDED
|
@@ -0,0 +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.
|
package/README.md
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
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
|
+
| 能力 | 说明 |
|
|
16
|
+
|---|---|
|
|
17
|
+
| Agent 工具 | `tiddlywiki_search` / `get` / `put` / `delete` / `git_sync` |
|
|
18
|
+
| 人编辑 | 侧边栏「TiddlyWiki」入口 → 中央列内嵌完整 TW 编辑器(iframe 直连 TW 服务) |
|
|
19
|
+
| 快速笔记 | 聊天区右下角常驻悬浮控件(可折叠,标题/tag 可自定义,Ctrl+Enter 保存) |
|
|
20
|
+
| 零摩擦生命周期 | 随 dsh 自动启动/关闭;TW 子进程崩溃自动重启(退避);端口/目录/首次 git init 全自动 |
|
|
21
|
+
| 同步 | 单线程交替模型:开工 pull,收工 commit+push,自动 commit(60s 防抖,可关) |
|
|
22
|
+
|
|
23
|
+
## 安装
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
# 本地开发 / 本机安装(link 方式,改源码后重新 build 即生效)
|
|
27
|
+
dsh plugin --profile web add link:C:\Users\bbq\.dsh\plugins\dsh-tiddlywiki
|
|
28
|
+
|
|
29
|
+
# 重启 dsh web(会重新加载 profile 与插件)
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
从 npm 发布包安装则是:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
dsh plugin --profile web add dsh-tiddlywiki
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## 配置
|
|
39
|
+
|
|
40
|
+
插件行默认如下(缺省即用默认值,无需手动配置)。如需自定义,编辑
|
|
41
|
+
`profiles/web/cordis.patch.yml` 或 profile 的 bundle 层,给该行加 `config:`:
|
|
42
|
+
|
|
43
|
+
```yaml
|
|
44
|
+
- id: dsh-tiddlywiki
|
|
45
|
+
name: dsh-tiddlywiki
|
|
46
|
+
config:
|
|
47
|
+
wikiRoot: "$DSH_HOME/tiddlywiki" # 缺省自动展开
|
|
48
|
+
wiki: "main"
|
|
49
|
+
port: 0 # 0 = 自动探测空闲端口
|
|
50
|
+
git:
|
|
51
|
+
autoCommit: true
|
|
52
|
+
debounceMs: 60000
|
|
53
|
+
remote: "" # 空 = 仅本地 commit;填了才 push
|
|
54
|
+
branch: "main"
|
|
55
|
+
note:
|
|
56
|
+
tag: "inbox"
|
|
57
|
+
auth:
|
|
58
|
+
username: "" # 默认 loopback 匿名;暴露到非 loopback 时才需要
|
|
59
|
+
password: ""
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
`config:` 块随 profile 被 dsh-market 带走;wiki 数据(`$DSH_HOME/tiddlywiki`)
|
|
63
|
+
走 git,不走 dsh-market。
|
|
64
|
+
|
|
65
|
+
> 运行时配置:设置页(见「设置页」)写入的 `$:/plugins/dsh-tiddlywiki/config`
|
|
66
|
+
> tiddler 是 `config:` 块之上的覆盖层(tiddler 优先、随 wiki 的 git 同步)。
|
|
67
|
+
> 无需改动 cordis 也能改 note tag / git 开关等。
|
|
68
|
+
|
|
69
|
+
## 使用
|
|
70
|
+
|
|
71
|
+
### Agent(工具)
|
|
72
|
+
|
|
73
|
+
- `tiddlywiki_search {query, tag?}` — 检索非系统 tiddler,返回标题/标签/摘要。
|
|
74
|
+
- `tiddlywiki_get {title}` — 读单个 tiddler 全文。
|
|
75
|
+
- `tiddlywiki_put {title, text, tags?, fields?}` — 写/覆盖 tiddler。
|
|
76
|
+
- `tiddlywiki_delete {title}` — 删除 tiddler。
|
|
77
|
+
- `tiddlywiki_git_sync {action: pull|push|sync, message?}` — git 操作。
|
|
78
|
+
|
|
79
|
+
同步纪律(三条):开工先 `pull --rebase --autostash`;收工 `commit + push`;
|
|
80
|
+
自动 commit 防抖 60s。真冲突 → abort 并报冲突文件,agent 人工处理,不自动吞数据。
|
|
81
|
+
|
|
82
|
+
### 人(GUI)
|
|
83
|
+
|
|
84
|
+
- 侧边栏「TiddlyWiki」按钮开关中央编辑器面板。
|
|
85
|
+
- 右下角「快速笔记」悬浮控件:写草稿/随手记,Ctrl+Enter 保存为独立 tiddler;
|
|
86
|
+
或点「**✏️ 在 TW 中编辑**」——保存后**弹出独立小窗**(可拖动/缩放)加载 TiddlyWiki **原生编辑器**编辑该条。
|
|
87
|
+
- 面板服务异常时显示错误 +「重试」按钮(POST `/dsh-tiddlywiki/restart`)。
|
|
88
|
+
|
|
89
|
+
### 设置页(插件/主题管理 + 配置)
|
|
90
|
+
|
|
91
|
+
DSH **设置 → TiddlyWiki 知识库** 是插件的配置面板(`settings.section`):
|
|
92
|
+
|
|
93
|
+
| 区块 | 内容 |
|
|
94
|
+
|---|---|
|
|
95
|
+
| 状态/重启 | TW 运行状态 + git 概览 + 「重启 TW」按钮 |
|
|
96
|
+
| 常规配置 | 快速笔记默认 tag、git 自动 commit/防抖/远端/分支——改了什么保存什么 |
|
|
97
|
+
| 插件管理 | 自带官方插件勾选(可搜索)→ 应用并自动重启 TW |
|
|
98
|
+
| 主题管理 | 自带主题**多选加载 + 单选活动** → 应用并自动重启 TW |
|
|
99
|
+
| 语言管理 | 自带官方语言包勾选(含 zh-Hans/zh-CN 简体)→ 应用并自动重启 TW |
|
|
100
|
+
|
|
101
|
+
- 配置写入 wiki 内的 `$:/plugins/dsh-tiddlywiki/config` tiddler(JSON),随 git 同步;
|
|
102
|
+
作为 **cordis `config:` 块之上的覆盖层**(tiddler 优先),以后加配置项只需扩展该对象。
|
|
103
|
+
- git 类配置修改后在 **重启 dsh web 后生效**(bootstrap 时读取)。
|
|
104
|
+
- 插件/主题/语言均只管理 tiddlywiki 包**自带**的官方清单(`plugins/tiddlywiki/*`、
|
|
105
|
+
`themes/tiddlywiki/*`、包根 `languages/*`),全部离线、官方原版。
|
|
106
|
+
- **主题机制(重点)**:TW 视觉主题由 **`$:/theme`** tiddler 决定(浏览器 themeManager),
|
|
107
|
+
`info.themes` 只决定**加载哪些主题插件**。主题之间有**依赖链**
|
|
108
|
+
(`plugin.info` 的 `dependents`):`vanilla ← snowwhite ← heavier/centralised/readonly/starlight`,
|
|
109
|
+
`vanilla ← tight/seamless`。设置页因此是**两层**:每行主题一个 `☑ 加载`(多选,
|
|
110
|
+
= TW 里可用的主题)加一个 `◉ 活动`(单选 = 当前视觉主题)。应用时插件会:
|
|
111
|
+
1. 把加载集(含所选活动主题)的**完整依赖链**写入 `info.themes`(如 heavier →
|
|
112
|
+
`[vanilla, snowwhite, heavier]`),否则激活 heavier 时会丢掉 70KB 的 vanilla 基座样式;
|
|
113
|
+
2. 把 **`$:/theme` 设为所选活动主题**(激活它),然后重启 TW。
|
|
114
|
+
样式为空壳的主题(如本版 tight-heavier)会自动从清单里隐藏,避免选了没效果。
|
|
115
|
+
|
|
116
|
+
### 界面语言(中文)
|
|
117
|
+
|
|
118
|
+
TW 的界面语言由**语言插件**决定,不是某个配置字符串。tiddlywiki 包在
|
|
119
|
+
`node_modules/tiddlywiki/languages/` 下**自带全部官方语言包**(zh-Hans 简体、zh-CN、
|
|
120
|
+
zh-Hant、en-GB、ja-JP…),本插件离线启用即可:
|
|
121
|
+
|
|
122
|
+
- **设置 → TiddlyWiki 知识库 → 语言管理**:勾选 `zh-Hans`(简体)→「应用语言(重启 TW)」。
|
|
123
|
+
插件会把它写入 `tiddlywiki.info` 的 `languages` 数组,并固定 `$:/language` 为
|
|
124
|
+
`$:/languages/zh-Hans`,重启后 TW 界面即变为简体中文(已持久化,重启仍在)。
|
|
125
|
+
- **配置自动应用**:在设置页常规配置里写入 `uiLanguage: "zh-Hans"`,每次启动 dsh web 时
|
|
126
|
+
自动启用该语言并固定 `$:/language`(若尚未启用)。留空则不干预。
|
|
127
|
+
- 中文包缺字/想换繁中:语言管理里改勾 `zh-Hant` 或 `zh-TW` 再应用即可。
|
|
128
|
+
|
|
129
|
+
## 开发
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
npm install
|
|
133
|
+
npm run typecheck # tsc --noEmit
|
|
134
|
+
npm run build # clean + host tsdown + client tsdown + wrap
|
|
135
|
+
npm run selftest # headless:spawn TW → REST 读写 → git → 退出回收
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
产物约定(§4.4 教训,发布必守):`lib/` 内**零** `@deepseek-ai` 运行时 import
|
|
139
|
+
(`src/sdk.ts` 自实现 `defineTool` / `dshHomePath`,类型用结构接口)。
|
|
140
|
+
发布前用 `grep -r "@deepseek-ai" lib/` 验证。
|
|
141
|
+
|
|
142
|
+
## 发布
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
# 版本号在 package.json;文件白名单见 files 字段
|
|
146
|
+
npm publish
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
`tiddlywiki` 依赖体较大(含全部语言包/插件),发布文档需注明。
|
|
150
|
+
|
|
151
|
+
## 结构
|
|
152
|
+
|
|
153
|
+
```
|
|
154
|
+
src/
|
|
155
|
+
├── index.ts # host 入口:装配 WikiServer/路由/工具/prompt/自动 commit
|
|
156
|
+
├── sdk.ts # 自包含 defineTool + dshHomePath(零 @deepseek-ai 运行时依赖)
|
|
157
|
+
├── host/
|
|
158
|
+
│ ├── wiki.ts # WikiServer:spawn/kill/自愈/端口探测/就绪轮询
|
|
159
|
+
│ ├── tw-api.ts # TiddlyWeb REST 客户端
|
|
160
|
+
│ ├── git.ts # git init/commit/pull/push/sync/status + AutoCommitter
|
|
161
|
+
│ ├── routes.ts # /status /note /restart /api/* 路由
|
|
162
|
+
│ ├── admin.ts # 设置页后台:tiddlywiki.info 读写 + 目录枚举 + /admin/* 路由
|
|
163
|
+
│ ├── config.ts # ConfigStore:cordis config 基底 + 配置 tiddler 覆盖层
|
|
164
|
+
│ └── tools.ts # 5 个工具(列表式注册,可扩展)
|
|
165
|
+
└── client/
|
|
166
|
+
├── index.ts # client 入口(纯 DOM + settings.section 注册,永不 throw)
|
|
167
|
+
├── styles.ts / state.ts / toast.ts
|
|
168
|
+
├── sidebar-entry.ts # 侧边栏入口
|
|
169
|
+
├── panel.ts # 中央列 iframe 面板(fixed 覆盖层,钉住整列)
|
|
170
|
+
├── note-widget.ts # 悬浮快速笔记
|
|
171
|
+
└── settings-page.ts # 设置页(插件/主题/语言管理 + 常规配置)
|
|
172
|
+
```
|
package/cordis.patch.yml
ADDED
|
@@ -0,0 +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
|