@wagq/dsh-obsidian 0.0.0-stage → 1.1.1

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 sdmu-gaoqi
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.en.md ADDED
@@ -0,0 +1,149 @@
1
+ # Knowledge base · Obsidian (@wagq/dsh-obsidian)
2
+
3
+ Connect a local **Obsidian vault** to [DeepSeek Harness](https://github.com/deepseek-ai/dsh) (DSH): the sidebar gains a three-column knowledge workspace, and the assistant in chat gets a matching `kb_*` tool set. Both sides read and write **the same vault** — a note you edit in the panel is instantly visible to the agent, and a note the agent writes appears in the panel on refresh.
4
+
5
+ - Sidebar: library / document / outline · related · Q&A, rendered Markdown reading plus in-place editing
6
+ - Right-click: new note, new folder, rename, delete (moved to `.trash`, reversible) — type a name, never a path
7
+ - Chat: 16 `kb_*` tools for search, read, write, move, delete, mkdir and whole-vault Q&A
8
+ - Zero dependencies: plain `node:fs`, no database, no index files, nothing uploaded
9
+
10
+ ![Three-column knowledge workspace](docs/preview.svg)
11
+
12
+ ## Install
13
+
14
+ **From NPM (recommended; also listed in the plugin marketplace)**
15
+
16
+ ```bash
17
+ dsh plugin --profile web add @wagq/dsh-obsidian
18
+ ```
19
+
20
+ **From source**
21
+
22
+ ```bash
23
+ dsh plugin --profile web add github:sdmu-gaoqi/dsh-obsidian
24
+ ```
25
+
26
+ Refresh the page (or restart DSH) and a **Knowledge base** icon appears in the sidebar.
27
+
28
+ You can also use the GUI: **Settings → Plugins → Add plugin** and paste `@wagq/dsh-obsidian` or the GitHub address above.
29
+
30
+ ## Quick start
31
+
32
+ 1. **Have a vault** — open any vault in Obsidian. On startup the plugin reads `obsidian.json` and connects to the currently open one.
33
+ 2. **Open the panel** — click the **Knowledge base** icon in the sidebar.
34
+ 3. **Check the connection** — the panel header shows the vault name. If it says the vault is not connected, click **Refresh**; if that still fails, set `vaultPath` (an absolute path) in the plugin settings.
35
+ 4. **Use it** — click a note to read it, switch the toolbar to **Edit** to change it and **Save** to write it back; right-click the tree to manage files.
36
+
37
+ ## Interface
38
+
39
+ | Area | Content |
40
+ | --- | --- |
41
+ | **Left · library** | type filter chips (all / notes / PDF / images / other), search box, collapsible folder tree, counts at the bottom |
42
+ | **Middle · document** | breadcrumb → title → tags → metadata chips (words / characters / lines / modified / size) → rendered Markdown |
43
+ | **Right · sidebar** | `Outline` (jump to a heading) · `Related` (backlinks / outgoing links) · `Ask` (whole-vault Q&A) |
44
+
45
+ Toolbar: read-only render / preview / edit / save / rename / delete / fullscreen. Leave fullscreen with `Esc` or ⇱.
46
+
47
+ - The reading view renders headings, paragraphs, lists, quotes, code blocks, tables, `[[wikilinks]]`, inline code and links
48
+ - The edit view is a controlled textarea; while dirty, the header shows an unsaved marker and a save button
49
+ - Search hits show the matching line number (for example `platform :1`)
50
+ - Images use `<img>`, PDFs use `<iframe>`, other files get a download entry
51
+
52
+ ## Right-click menus
53
+
54
+ Right-click anywhere in the left tree; **you type a name, never a path**:
55
+
56
+ | Right-click target | Menu items |
57
+ | --- | --- |
58
+ | folder row | new note · new folder · rename · delete |
59
+ | note row | open · rename · delete |
60
+ | empty tree space | new note · new folder · new knowledge base project |
61
+
62
+ - Creating on a folder puts the item inside it; creating in empty space puts it at the vault root
63
+ - A new note needs only a name — `.md` is appended automatically and the note opens immediately
64
+ - Rename changes the name only; the parent folder stays
65
+ - Delete moves the item to `.trash/`, which is reversible; deleting a folder moves its whole subtree
66
+
67
+ ## Whole-vault Q&A
68
+
69
+ In the **Ask** tab on the right, type a question (`Ctrl+Enter` sends). The plugin
70
+
71
+ 1. tokenizes the query (Chinese and English) and scores the whole vault, taking the top N chunks by heading
72
+ 2. calls the current default model, answering only from those chunks
73
+ 3. returns the answer plus a citation list (click one to jump to that note)
74
+
75
+ If no model is available it falls back to evidence mode: it lists the most relevant chunks instead of inventing an answer. The `kb_ask` tool does the same thing in chat.
76
+
77
+ ## Chat tools
78
+
79
+ Once installed, the agent in any session can call these tools directly, with no extra authorization step:
80
+
81
+ | Tool | Purpose |
82
+ | --- | --- |
83
+ | `kb_status` | connection state, vault path, file counts |
84
+ | `kb_list` | list notes, optionally filtered by subdirectory and type |
85
+ | `kb_search` | full-text search over titles and bodies, returning matching lines |
86
+ | `kb_read` | read one note: body, frontmatter, tags, outline, word count, links |
87
+ | `kb_outline` | headings only |
88
+ | `kb_write` | create or overwrite |
89
+ | `kb_append` | append to the end |
90
+ | `kb_move` | move / rename |
91
+ | `kb_delete` | move to `.trash/` (reversible) |
92
+ | `kb_backlinks` | backlinks |
93
+ | `kb_related` | backlinks plus outgoing links |
94
+ | `kb_ask` | whole-vault Q&A: retrieval, model answer, citations |
95
+ | `kb_tags` | every tag in the vault with usage counts |
96
+ | `kb_mkdir` | create a folder |
97
+ | `kb_rmdir` | delete a folder (whole subtree to `.trash/`) |
98
+ | `kb_create_vault` | create a knowledge base project (vault) and switch to it |
99
+
100
+ Typical requests, straight in chat:
101
+
102
+ - “Find every note in this vault that mentions `deploy`, with titles and line numbers” → `kb_search`
103
+ - “Read `architecture/gateway.md` and add a `Rate limiting` section” → `kb_read` + `kb_append`
104
+ - “Summarize what I did this week from `journal/`” → `kb_list` + `kb_read`
105
+ - “Create a knowledge base project named `Reading notes`” → `kb_create_vault`
106
+
107
+ ## Configuration
108
+
109
+ The plugin settings have one field:
110
+
111
+ | Field | Meaning |
112
+ | --- | --- |
113
+ | `vaultPath` | absolute path of the Obsidian vault. When empty, the plugin auto-detects the currently open vault from `%APPDATA%\obsidian\obsidian.json` (`Application Support` on macOS, `.config` on Linux) |
114
+
115
+ The vault switcher in the panel header moves between registered vaults without touching the config.
116
+
117
+ ## Compatibility
118
+
119
+ | Item | Requirement |
120
+ | --- | --- |
121
+ | DSH | `>=0.2.0 <0.3.0` (desktop or web) |
122
+ | Node | `>=22.19.0` |
123
+ | Platforms | Windows · macOS · Linux (all paths go through `node:path`) |
124
+ | Dependencies | none at runtime; `@deepseek-ai/schemastery` is an optional peer shipped with DSH |
125
+
126
+ ## Boundaries
127
+
128
+ - Only files inside the vault are indexed; escaping paths (`..`, absolute paths, drive letters, UNC) are rejected
129
+ - Hidden directories are not indexed: `.obsidian/`, `.trash/`, `.git/`, `.claudian/` and similar
130
+ - Delete only moves to `.trash/`; nothing is permanently removed
131
+ - A single note is capped at 4 MB; raw file preview is capped at 32 MB
132
+ - The local HTTP surface accepts same-origin requests only (`Origin` must match `Host`) and sends `nosniff`
133
+ - Nothing is uploaded: all reads and writes happen on the local filesystem; only **Ask** sends retrieved chunks to the current session model
134
+
135
+ ## Development
136
+
137
+ ```bash
138
+ git clone https://github.com/sdmu-gaoqi/dsh-obsidian.git
139
+ cd dsh-obsidian
140
+ dsh plugin --profile web add .
141
+ ```
142
+
143
+ `index.js` is the Host face (`export function apply(ctx, config)`, registering `webServer` routes and `tools`); `client.js` is the browser face (`window.__ModuleLoader__.load`, registering the `main` and `sidebar.panellist` slots). A page refresh picks up client changes; Host changes need a DSH restart.
144
+
145
+ ## License
146
+
147
+ [MIT](LICENSE)
148
+
149
+ 中文:[README.md](README.md)
package/README.md CHANGED
@@ -1,3 +1,149 @@
1
- # Temporary Holding Version
1
+ # 知识库 · Obsidian(@wagq/dsh-obsidian)
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ 把本地 **Obsidian vault** 接到 [DeepSeek Harness](https://github.com/deepseek-ai/dsh)(DSH):左侧栏多出一个三栏知识库工作区,对话里的智能体同时获得一套 `kb_*` 工具,两边读写的是**同一个 vault**——你在面板里改的笔记,智能体立刻能读到;智能体写入的笔记,刷新面板就能看到。
4
+
5
+ - 侧栏:文件库 / 文档 / 大纲 · 关联 · 问答 三栏,Markdown 渲染阅读 + 就地编辑保存
6
+ - 右键:新建笔记、新建文件夹、重命名、删除(移入 `.trash`,可逆),只填名称不用手打路径
7
+ - 对话:16 个 `kb_*` 工具,检索、读、写、移动、删除、建目录、全库问答
8
+ - 零依赖:纯 `node:fs` 实现,不装数据库、不建索引、不上传任何内容
9
+
10
+ ![三栏知识库工作区](docs/preview.svg)
11
+
12
+ ## 安装
13
+
14
+ **从 NPM 安装(推荐,插件商城里可搜到)**
15
+
16
+ ```bash
17
+ dsh plugin --profile web add @wagq/dsh-obsidian
18
+ ```
19
+
20
+ **从源码安装**
21
+
22
+ ```bash
23
+ dsh plugin --profile web add github:sdmu-gaoqi/dsh-obsidian
24
+ ```
25
+
26
+ 装完刷新页面(或重启 DSH)即可生效,左侧栏出现「知识库」图标。
27
+
28
+ 也可以走图形界面:**设置 → 插件 → 添加插件**,粘贴包名 `@wagq/dsh-obsidian` 或上面的 GitHub 地址。
29
+
30
+ ## 快速上手
31
+
32
+ 1. **准备一个 vault**:先在 Obsidian 里打开任意一个 vault。插件启动时会读取 `obsidian.json`,自动连上当前打开的那个。
33
+ 2. **打开面板**:点左侧栏的「知识库」图标,进入三栏工作区。
34
+ 3. **确认连接**:面板顶部会显示 vault 名称。显示「未连接知识库」时,点右上角 **刷新**;仍连不上就在插件设置里填 `vaultPath`(绝对路径,见下)。
35
+ 4. **开始用**:左栏点笔记阅读,工具栏切 **编辑** 改内容、**保存** 落盘;树里右键管理文件。
36
+
37
+ ## 界面
38
+
39
+ | 区域 | 内容 |
40
+ | --- | --- |
41
+ | **左 · 文件库** | 类型筛选 chip(全部 / 笔记 / PDF / 图片 / 其他)、搜索框、可折叠文件夹树、底部统计 |
42
+ | **中 · 文档** | 面包屑 → 标题 → 标签行 → 元信息 chip(字数 / 字符 / 行数 / 修改时间 / 大小)→ Markdown 渲染 |
43
+ | **右 · 侧栏** | `大纲`(点击跳转)· `关联`(反链 / 出链)· `问答`(全库问答) |
44
+
45
+ 工具栏:只读渲染 / 预览 / 编辑 / 保存 / 重命名 / 删除 / 全屏。全屏按 `Esc` 或 ⇱ 退出。
46
+
47
+ - 阅读态渲染标题、段落、列表、引用、代码块、表格、`[[wikilink]]`、行内代码与链接
48
+ - 编辑态是受控 textarea,未保存时顶部显示「未保存」并出现保存按钮
49
+ - 搜索命中直接标出行号(如 `平台端 :1`)
50
+ - 图片走 `<img>`、PDF 走 `<iframe>`,其他文件给下载入口
51
+
52
+ ## 右键菜单
53
+
54
+ 左侧树里右键即可操作,**只填名称,不用手打路径**:
55
+
56
+ | 右键位置 | 菜单项 |
57
+ | --- | --- |
58
+ | 文件夹行 | 新建笔记 · 新建文件夹 · 重命名 · 删除 |
59
+ | 笔记行 | 打开 · 重命名 · 删除 |
60
+ | 树内空白处 | 新建笔记 · 新建文件夹 · 新建知识库项目 |
61
+
62
+ - 在文件夹上新建 → 落到该文件夹内;空白处新建 → 落到 vault 根目录
63
+ - 新建笔记只输名称,`.md` 自动补全,创建后立即打开
64
+ - 重命名只改名称,父目录不变
65
+ - 删除移入 `.trash/`,可逆;删除文件夹连整棵子树一起移入
66
+
67
+ ## 全库问答
68
+
69
+ 右栏「问答」标签:输入问题(`Ctrl+Enter` 发送),插件会
70
+
71
+ 1. 用词元切分(中英文)在全库打分检索,按标题分块取 Top-N 片段
72
+ 2. 调用当前默认模型,只依据这些片段作答
73
+ 3. 返回答案 + 出处列表(点开即跳转对应笔记)
74
+
75
+ 模型不可用时会退回「证据模式」:只展示最相关的片段,不会编造答案。对话里同样可用 `kb_ask` 完成这件事。
76
+
77
+ ## 对话工具
78
+
79
+ 装好插件后,任何会话里的智能体都能直接调用下面这些工具,不需要额外授权步骤:
80
+
81
+ | 工具 | 作用 |
82
+ | --- | --- |
83
+ | `kb_status` | 连接状态、vault 路径、各类文件数量 |
84
+ | `kb_list` | 列出笔记,可按子目录与类型过滤 |
85
+ | `kb_search` | 全文检索标题与正文,返回匹配行 |
86
+ | `kb_read` | 读一篇:正文、frontmatter、标签、大纲、字数、链接 |
87
+ | `kb_outline` | 只取标题大纲 |
88
+ | `kb_write` | 新建或覆盖 |
89
+ | `kb_append` | 追加到末尾 |
90
+ | `kb_move` | 移动 / 重命名 |
91
+ | `kb_delete` | 移入 `.trash/`(可逆) |
92
+ | `kb_backlinks` | 反链 |
93
+ | `kb_related` | 反链 + 出链 |
94
+ | `kb_ask` | 全库问答:检索 + 模型作答 + 出处 |
95
+ | `kb_tags` | 全库标签及使用次数 |
96
+ | `kb_mkdir` | 建文件夹 |
97
+ | `kb_rmdir` | 删文件夹(整棵子树移入 `.trash/`) |
98
+ | `kb_create_vault` | 新建一个知识库项目(vault)并切换过去 |
99
+
100
+ 典型用法,直接在对话里说:
101
+
102
+ - 「把这个 vault 里所有提到 `部署` 的笔记找出来,列标题和行号」→ `kb_search`
103
+ - 「读 `架构/网关.md`,帮我补一节『限流』并写回去」→ `kb_read` + `kb_append`
104
+ - 「按 `日记/` 下的记录,总结我这周做了什么」→ `kb_list` + `kb_read`
105
+ - 「新建一个叫 `读书笔记` 的知识库项目」→ `kb_create_vault`
106
+
107
+ ## 配置
108
+
109
+ 插件设置里只有一项:
110
+
111
+ | 字段 | 说明 |
112
+ | --- | --- |
113
+ | `vaultPath` | Obsidian vault 的**绝对路径**。留空时自动检测:读取 `%APPDATA%\obsidian\obsidian.json`(macOS / Linux 对应 `Application Support` / `.config`)里当前打开的 vault |
114
+
115
+ 面板顶部的 vault 切换器可以在已登记的多个 vault 之间切换,不必改配置。
116
+
117
+ ## 兼容与运行要求
118
+
119
+ | 项 | 要求 |
120
+ | --- | --- |
121
+ | DSH | `>=0.2.0 <0.3.0`(桌面版 / Web 版均可) |
122
+ | Node | `>=22.19.0` |
123
+ | 平台 | Windows · macOS · Linux(路径全部走 `node:path`) |
124
+ | 依赖 | 无运行时依赖;仅 `@deepseek-ai/schemastery` 作可选 peer(DSH 自带) |
125
+
126
+ ## 边界与安全
127
+
128
+ - 只索引 vault 内的文件;路径越界(`..`、绝对路径、盘符、UNC)一律拒绝
129
+ - 隐藏目录不索引:`.obsidian/`、`.trash/`、`.git/`、`.claudian/` 等
130
+ - 删除只移入 `.trash/`,不永久删除
131
+ - 单个笔记上限 4 MB,原始文件预览上限 32 MB
132
+ - 本地 HTTP 接口只接受同源请求(`Origin` 与 `Host` 一致),并带 `nosniff`
133
+ - 不上传、不外发:所有读写都在本机文件系统完成;只有「问答」会把检索到的片段交给当前会话的模型
134
+
135
+ ## 开发
136
+
137
+ ```bash
138
+ git clone https://github.com/sdmu-gaoqi/dsh-obsidian.git
139
+ cd dsh-obsidian
140
+ dsh plugin --profile web add .
141
+ ```
142
+
143
+ `index.js` 是 Host 半端(`export function apply(ctx, config)`,注册 `webServer` 路由与 `tools`),`client.js` 是浏览器半端(`window.__ModuleLoader__.load`,注册 `main` 与 `sidebar.panellist` 两个 slot)。改完刷新页面即可,Host 改动需重启 DSH。
144
+
145
+ ## 许可证
146
+
147
+ [MIT](LICENSE)
148
+
149
+ English: [README.en.md](README.en.md)