siyuan-cli 1.1.0__tar.gz

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.
Files changed (60) hide show
  1. siyuan_cli-1.1.0/LICENSE +21 -0
  2. siyuan_cli-1.1.0/PKG-INFO +234 -0
  3. siyuan_cli-1.1.0/README.md +239 -0
  4. siyuan_cli-1.1.0/README_EN.md +208 -0
  5. siyuan_cli-1.1.0/pyproject.toml +62 -0
  6. siyuan_cli-1.1.0/setup.cfg +4 -0
  7. siyuan_cli-1.1.0/siyuan_cli/__init__.py +7 -0
  8. siyuan_cli-1.1.0/siyuan_cli/__main__.py +5 -0
  9. siyuan_cli-1.1.0/siyuan_cli/audit.py +44 -0
  10. siyuan_cli-1.1.0/siyuan_cli/cli.py +697 -0
  11. siyuan_cli-1.1.0/siyuan_cli/client.py +442 -0
  12. siyuan_cli-1.1.0/siyuan_cli/commands/__init__.py +1 -0
  13. siyuan_cli-1.1.0/siyuan_cli/commands/asset.py +130 -0
  14. siyuan_cli-1.1.0/siyuan_cli/commands/attr.py +56 -0
  15. siyuan_cli-1.1.0/siyuan_cli/commands/backlinks.py +156 -0
  16. siyuan_cli-1.1.0/siyuan_cli/commands/batch.py +318 -0
  17. siyuan_cli-1.1.0/siyuan_cli/commands/block.py +259 -0
  18. siyuan_cli-1.1.0/siyuan_cli/commands/config_cmd.py +108 -0
  19. siyuan_cli-1.1.0/siyuan_cli/commands/daily_note.py +105 -0
  20. siyuan_cli-1.1.0/siyuan_cli/commands/doc.py +338 -0
  21. siyuan_cli-1.1.0/siyuan_cli/commands/export_cmd.py +48 -0
  22. siyuan_cli-1.1.0/siyuan_cli/commands/file_cmd.py +184 -0
  23. siyuan_cli-1.1.0/siyuan_cli/commands/health.py +202 -0
  24. siyuan_cli-1.1.0/siyuan_cli/commands/notebook.py +140 -0
  25. siyuan_cli-1.1.0/siyuan_cli/commands/notify.py +40 -0
  26. siyuan_cli-1.1.0/siyuan_cli/commands/overview.py +160 -0
  27. siyuan_cli-1.1.0/siyuan_cli/commands/search.py +83 -0
  28. siyuan_cli-1.1.0/siyuan_cli/commands/stats.py +102 -0
  29. siyuan_cli-1.1.0/siyuan_cli/commands/tag.py +107 -0
  30. siyuan_cli-1.1.0/siyuan_cli/commands/template.py +52 -0
  31. siyuan_cli-1.1.0/siyuan_cli/commands/workspace_cmd.py +114 -0
  32. siyuan_cli-1.1.0/siyuan_cli/config.py +156 -0
  33. siyuan_cli-1.1.0/siyuan_cli/exceptions.py +195 -0
  34. siyuan_cli-1.1.0/siyuan_cli/permissions.py +180 -0
  35. siyuan_cli-1.1.0/siyuan_cli/utils.py +400 -0
  36. siyuan_cli-1.1.0/siyuan_cli/workspace.py +120 -0
  37. siyuan_cli-1.1.0/siyuan_cli.egg-info/PKG-INFO +234 -0
  38. siyuan_cli-1.1.0/siyuan_cli.egg-info/SOURCES.txt +58 -0
  39. siyuan_cli-1.1.0/siyuan_cli.egg-info/dependency_links.txt +1 -0
  40. siyuan_cli-1.1.0/siyuan_cli.egg-info/entry_points.txt +3 -0
  41. siyuan_cli-1.1.0/siyuan_cli.egg-info/requires.txt +6 -0
  42. siyuan_cli-1.1.0/siyuan_cli.egg-info/top_level.txt +2 -0
  43. siyuan_cli-1.1.0/siyuan_mcp/__init__.py +3 -0
  44. siyuan_cli-1.1.0/siyuan_mcp/__main__.py +5 -0
  45. siyuan_cli-1.1.0/siyuan_mcp/server.py +882 -0
  46. siyuan_cli-1.1.0/tests/test_block.py +246 -0
  47. siyuan_cli-1.1.0/tests/test_client.py +279 -0
  48. siyuan_cli-1.1.0/tests/test_config.py +62 -0
  49. siyuan_cli-1.1.0/tests/test_daily_note.py +58 -0
  50. siyuan_cli-1.1.0/tests/test_doc.py +246 -0
  51. siyuan_cli-1.1.0/tests/test_exceptions.py +137 -0
  52. siyuan_cli-1.1.0/tests/test_integration.py +174 -0
  53. siyuan_cli-1.1.0/tests/test_mcp.py +361 -0
  54. siyuan_cli-1.1.0/tests/test_mcp_server.py +110 -0
  55. siyuan_cli-1.1.0/tests/test_notebook.py +111 -0
  56. siyuan_cli-1.1.0/tests/test_permissions.py +108 -0
  57. siyuan_cli-1.1.0/tests/test_search.py +119 -0
  58. siyuan_cli-1.1.0/tests/test_tag.py +85 -0
  59. siyuan_cli-1.1.0/tests/test_utils.py +224 -0
  60. siyuan_cli-1.1.0/tests/test_workspace.py +112 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 xingrove
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.
@@ -0,0 +1,234 @@
1
+ Metadata-Version: 2.4
2
+ Name: siyuan-cli
3
+ Version: 1.1.0
4
+ Summary: CLI tool + MCP server + Agent Skills for SiYuan Note (思源笔记) — zero deps, permission system, workspace management
5
+ Author: Mino
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/xingrove/siyuan-skills
8
+ Project-URL: Repository, https://github.com/xingrove/siyuan-skills
9
+ Keywords: siyuan,思源笔记,notes,markdown,pkm,self-hosted,agent-skills
10
+ Classifier: Programming Language :: Python :: 3.10
11
+ Classifier: Programming Language :: Python :: 3.11
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Programming Language :: Python :: 3.13
14
+ Classifier: Topic :: Text Editors :: Documentation
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Natural Language :: Chinese (Simplified)
17
+ Requires-Python: >=3.10
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Provides-Extra: dev
21
+ Requires-Dist: pytest>=8; extra == "dev"
22
+ Requires-Dist: pytest-timeout; extra == "dev"
23
+ Requires-Dist: ruff>=0.6; extra == "dev"
24
+ Requires-Dist: mypy>=1.10; extra == "dev"
25
+ Dynamic: license-file
26
+
27
+ # SiYuan Agent Tools
28
+
29
+ [![PyPI](https://img.shields.io/pypi/v/siyuan-cli)](https://pypi.org/project/siyuan-cli/)
30
+ [![CI](https://github.com/xingrove/siyuan-skills/actions/workflows/ci.yml/badge.svg)](https://github.com/xingrove/siyuan-skills/actions)
31
+ [![Python](https://img.shields.io/pypi/pyversions/siyuan-cli)](https://pypi.org/project/siyuan-cli/)
32
+ [![License](https://img.shields.io/pypi/l/siyuan-cli)](LICENSE)
33
+ [![Tests](https://img.shields.io/badge/tests-229%20passed-brightgreen)](https://github.com/xingrove/siyuan-skills)
34
+
35
+ > [中文](README.md)
36
+
37
+ CLI tool, MCP server, and AI Agent Skills for [SiYuan Note](https://github.com/siyuan-note/siyuan). Pure Python, zero dependencies. Compatible with Claude Code, Codex, OpenCode, and Hermes.
38
+
39
+ ---
40
+
41
+ ## Install
42
+
43
+ ```bash
44
+ pip install siyuan-cli
45
+ ```
46
+
47
+ Or the one-command installer:
48
+
49
+ ```bash
50
+ curl -fsSL https://raw.githubusercontent.com/xingrove/siyuan-skills/main/scripts/install.sh | bash
51
+ ```
52
+
53
+ ---
54
+
55
+ ## Quick Start
56
+
57
+ ```bash
58
+ siyuan config url http://127.0.0.1:6806
59
+ siyuan config token your-api-token
60
+
61
+ siyuan stats # verify connectivity
62
+ ```
63
+
64
+ > Token location: SiYuan Desktop → Settings → API; for Docker, in `conf.json`.
65
+
66
+ ---
67
+
68
+ ## CLI Reference
69
+
70
+ ### Documents & Blocks
71
+
72
+ | Command | Description |
73
+ |---------|-------------|
74
+ | `siyuan create /path [content]` | Create a note (`--file` / `--stdin` supported) |
75
+ | `siyuan read /path` | Read document content |
76
+ | `siyuan delete /path [--id]` | Delete a note |
77
+ | `siyuan tree [notebook]` | Document tree |
78
+ | `siyuan doc rename <title>` | Rename document |
79
+ | `siyuan doc move <paths...> [--to-notebook]` | Move documents |
80
+ | `siyuan doc export /path [--id]` | Export as Markdown |
81
+ | `siyuan doc get-path <id>` | Resolve ID to path |
82
+
83
+ ### Block Operations
84
+
85
+ | Command | Description |
86
+ |---------|-------------|
87
+ | `siyuan block get <id>` | Block info |
88
+ | `siyuan block children <id>` | Child blocks |
89
+ | `siyuan block append <id> -c <content>` | Append child block |
90
+ | `siyuan block prepend <id> -c <content>` | Prepend child block |
91
+ | `siyuan block insert <id> -c <content>` | Insert block after sibling |
92
+ | `siyuan block update <id> -c <content>` | Update block |
93
+ | `siyuan block delete <id>` | Delete block |
94
+ | `siyuan block move <id> --parent <pid>` | Move block |
95
+ | `siyuan block fold <id>` | Fold heading |
96
+ | `siyuan block unfold <id>` | Unfold |
97
+
98
+ ### Block References & Embeds
99
+
100
+ | Command | Output | Description |
101
+ |---------|--------|-------------|
102
+ | `siyuan block ref <id>` | `((id 'title'))` | Block reference markup |
103
+ | `siyuan block embed <id>` | `{{embed ((id 'title'))}}` | Block embed markup |
104
+ | `siyuan block link <id>` | `siyuan://blocks/id` | SiYuan internal link |
105
+
106
+ ```bash
107
+ REF=$(siyuan block ref 20200812220555-lj3enxa)
108
+ siyuan create "/article" "As mentioned in $REF..."
109
+ ```
110
+
111
+ ### Notebooks, Search & Daily Notes
112
+
113
+ | Command | Description |
114
+ |---------|-------------|
115
+ | `siyuan notebook list` | List notebooks |
116
+ | `siyuan notebook create <name>` | Create notebook |
117
+ | `siyuan notebook remove <id>` | Remove notebook |
118
+ | `siyuan notebook rename <id> <name>` | Rename |
119
+ | `siyuan notebook conf <id>` | Notebook config |
120
+ | `siyuan search <query>` | Full-text search |
121
+ | `siyuan sql <statement>` | SQL query (SELECT only) |
122
+ | `siyuan daily-note note` | Get or create today's note |
123
+ | `siyuan daily-note append <content>` | Append to today's note |
124
+
125
+ ### Tags, Attributes & Assets
126
+
127
+ | Command | Description |
128
+ |---------|-------------|
129
+ | `siyuan tag list` | All tags |
130
+ | `siyuan tag blocks <tag>` | Find tagged blocks |
131
+ | `siyuan attr get <id>` | Block attributes |
132
+ | `siyuan attr set <id> <key> <val>` | Set attribute |
133
+ | `siyuan asset upload <file>` | Upload asset |
134
+ | `siyuan file list /data/` | List workspace files |
135
+ | `siyuan file put <local> <remote>` | Upload file |
136
+
137
+ ### Batch & Utilities
138
+
139
+ | Command | Description |
140
+ |---------|-------------|
141
+ | `siyuan batch create <file>` | Batch create notes |
142
+ | `siyuan batch delete <file>` | Batch delete notes |
143
+ | `siyuan stats` | Workspace statistics |
144
+ | `siyuan overview` | Workspace overview |
145
+ | `siyuan health` | Diagnostic health check |
146
+ | `siyuan backlinks get <id>` | Block backlinks |
147
+ | `siyuan notify push <msg>` | Push notification to UI |
148
+ | `siyuan mcp` | Start MCP server |
149
+
150
+ ---
151
+
152
+ ## Global Options
153
+
154
+ | Option | Description |
155
+ |--------|-------------|
156
+ | `--format pretty\|json\|compact` | Output format |
157
+ | `--verbose` | Detailed logging |
158
+ | `--no-color` | Disable colored output |
159
+ | `--version` | Show version |
160
+ | `--yes` | Skip confirmation on destructive ops |
161
+ | `--dry-run` | Preview without applying |
162
+ | `@file:/path` | Read content from file |
163
+ | `@stdin` | Read content from stdin |
164
+
165
+ **Read-only mode:** `SIYUAN_READ_ONLY=true siyuan <cmd>` blocks all writes.
166
+
167
+ ---
168
+
169
+ ## Multi-Server
170
+
171
+ ```bash
172
+ siyuan workspace add hk --url http://server:6806 --token xxx
173
+ siyuan workspace use hk
174
+ siyuan workspace list
175
+ ```
176
+
177
+ ---
178
+
179
+ ## Permission System
180
+
181
+ ```bash
182
+ siyuan permission deny --endpoint "*remove*" # Block all deletes
183
+ siyuan permission ask --endpoint "*delete*" # Ask before delete
184
+ siyuan permission list # Show rules
185
+ ```
186
+
187
+ ---
188
+
189
+ ## MCP Server
190
+
191
+ ```bash
192
+ siyuan-mcp
193
+ ```
194
+
195
+ 23 tools: CRUD, search, SQL, block refs/embeds, tags, attributes, health checks. Works with Claude Desktop, Cursor, and any MCP client.
196
+
197
+ ---
198
+
199
+ ## Agent Skills
200
+
201
+ | Agent | Install |
202
+ |-------|---------|
203
+ | **OpenCode** | `git clone https://github.com/xingrove/siyuan-skills.git ~/.opencode/skills/siyuan-skills` |
204
+ | **Codex CLI** | `cp -r skills/* ~/.codex/skills/` |
205
+ | **Hermes** | `cp -r skills/* ~/.hermes/skills/` |
206
+ | **npx** | `npx skills add https://github.com/xingrove/siyuan-skills` |
207
+
208
+ | Skill | Description |
209
+ |-------|-------------|
210
+ | [siyuan-cli](skills/siyuan-cli) | Operate SiYuan via CLI |
211
+ | [siyuan-api](skills/siyuan-api) | Direct REST API calls |
212
+ | [siyuan-markdown](skills/siyuan-markdown) | SiYuan-flavored Markdown reference |
213
+
214
+ ---
215
+
216
+ ## Configuration
217
+
218
+ Priority: `SIYUAN_URL` / `SIYUAN_TOKEN` env vars > active workspace > `~/.siyuan/config.json`
219
+
220
+ ```json
221
+ {"url": "http://127.0.0.1:6806", "token": "your-token"}
222
+ ```
223
+
224
+ Optional keyring storage:
225
+
226
+ ```bash
227
+ pip install keyring
228
+ siyuan keyring-set your-token
229
+ siyuan keyring-unset
230
+ ```
231
+
232
+ ---
233
+
234
+ *Community project, not official.*
@@ -0,0 +1,239 @@
1
+ # SiYuan Agent Tools
2
+
3
+ [![PyPI](https://img.shields.io/pypi/v/siyuan-cli)](https://pypi.org/project/siyuan-cli/)
4
+ [![CI](https://github.com/xingrove/siyuan-skills/actions/workflows/ci.yml/badge.svg)](https://github.com/xingrove/siyuan-skills/actions)
5
+ [![Python](https://img.shields.io/pypi/pyversions/siyuan-cli)](https://pypi.org/project/siyuan-cli/)
6
+ [![License](https://img.shields.io/pypi/l/siyuan-cli)](LICENSE)
7
+ [![Tests](https://img.shields.io/badge/tests-229%20passed-brightgreen)](https://github.com/xingrove/siyuan-skills)
8
+
9
+ > [English](README_EN.md)
10
+
11
+ 面向**思源笔记**的 CLI 工具 + MCP 服务器 + AI Agent 技能包。纯 Python 实现,零依赖,兼容 Claude Code、Codex、OpenCode、Hermes 等 AI 编程助手。
12
+
13
+ ---
14
+
15
+ ## 安装
16
+
17
+ ```bash
18
+ pip install siyuan-cli
19
+ ```
20
+
21
+ 或一键安装脚本:
22
+
23
+ ```bash
24
+ curl -fsSL https://raw.githubusercontent.com/xingrove/siyuan-skills/main/scripts/install.sh | bash
25
+ ```
26
+
27
+ ---
28
+
29
+ ## 快速上手
30
+
31
+ ```bash
32
+ siyuan config url http://127.0.0.1:6806
33
+ siyuan config token 你的API令牌
34
+
35
+ siyuan stats # 验证连接是否正常
36
+ ```
37
+
38
+ > Token 获取:思源桌面端 → 设置 → API;Docker 部署的在 `conf.json` 里。
39
+ >
40
+ > ⚠️ **Windows 用户**:git-bash / MSYS 下路径会被自动翻译,请加前缀:
41
+ > ```bash
42
+ > MSYS_NO_PATHCONV=1 siyuan create /path/to/doc
43
+ > ```
44
+
45
+ ---
46
+
47
+ ## 命令参考
48
+
49
+ ### 笔记操作
50
+
51
+ | 命令 | 说明 |
52
+ |------|------|
53
+ | `siyuan create /路径 [内容]` | 创建笔记(支持 `--file` / `--stdin`) |
54
+ | `siyuan read /路径` | 读取内容 |
55
+ | `siyuan delete /路径 [--id]` | 删除笔记 |
56
+ | `siyuan tree [笔记本]` | 文档树 |
57
+
58
+ **扩展模式** (`siyuan doc`):
59
+
60
+ | 命令 | 说明 |
61
+ |------|------|
62
+ | `siyuan doc create /路径 [内容]` | 创建 |
63
+ | `siyuan doc read /路径` | 读取 |
64
+ | `siyuan doc delete /路径` | 删除 |
65
+ | `siyuan doc tree [笔记本]` | 文档树 |
66
+ | `siyuan doc rename <标题>` | 重命名 |
67
+ | `siyuan doc move <路径...> [--to-notebook]` | 移动 |
68
+ | `siyuan doc export /路径 [--id]` | 导出 Markdown |
69
+ | `siyuan doc get-path <id>` | ID 查路径 |
70
+
71
+ ### 块操作
72
+
73
+ | 命令 | 说明 |
74
+ |------|------|
75
+ | `siyuan block get <id>` | 块信息 |
76
+ | `siyuan block children <id>` | 子块列表 |
77
+ | `siyuan block append <id> -c <内容>` | 追加子块 |
78
+ | `siyuan block prepend <id> -c <内容>` | 前置子块 |
79
+ | `siyuan block insert <id> -c <内容>` | 插入块 |
80
+ | `siyuan block update <id> -c <内容>` | 更新块 |
81
+ | `siyuan block delete <id>` | 删除块 |
82
+ | `siyuan block move <id> --parent <pid>` | 移动块 |
83
+ | `siyuan block fold <id>` | 折叠标题 |
84
+ | `siyuan block unfold <id>` | 展开块 |
85
+
86
+ ### 块引用 & 嵌入
87
+
88
+ | 命令 | 输出 | 说明 |
89
+ |------|------|------|
90
+ | `siyuan block ref <id>` | `((id '标题'))` | 生成块引用标记 |
91
+ | `siyuan block embed <id>` | `{{embed ((id '标题'))}}` | 生成块嵌入标记 |
92
+ | `siyuan block link <id>` | `siyuan://blocks/id` | 生成思源内部链接 |
93
+
94
+ ```bash
95
+ REF=$(siyuan block ref 20200812220555-lj3enxa)
96
+ siyuan create "/文章" "如上文 $REF 所述..."
97
+ ```
98
+
99
+ ### 笔记本管理
100
+
101
+ | 命令 | 说明 |
102
+ |------|------|
103
+ | `siyuan notebook list` | 列表 |
104
+ | `siyuan notebook create <名称>` | 创建 |
105
+ | `siyuan notebook remove <id>` | 删除 |
106
+ | `siyuan notebook rename <id> <名称>` | 重命名 |
107
+ | `siyuan notebook conf <id>` | 查看配置 |
108
+
109
+ ### 搜索
110
+
111
+ | 命令 | 说明 |
112
+ |------|------|
113
+ | `siyuan search <关键词>` | 全文搜索 |
114
+ | `siyuan sql <SELECT 语句>` | SQL 查询 blocks 表 |
115
+
116
+ ### 每日笔记 & 标签
117
+
118
+ | 命令 | 说明 |
119
+ |------|------|
120
+ | `siyuan daily-note note` | 获取/创建今日笔记 |
121
+ | `siyuan daily-note append <内容>` | 追加到今日笔记 |
122
+ | `siyuan tag list` | 所有标签 |
123
+ | `siyuan tag blocks <标签>` | 查找带标签的块 |
124
+ | `siyuan attr get <id>` | 获取块属性 |
125
+ | `siyuan attr set <id> <键> <值>` | 设置块属性 |
126
+
127
+ ### 文件 & 资源
128
+
129
+ | 命令 | 说明 |
130
+ |------|------|
131
+ | `siyuan file list /data/` | 列出文件 |
132
+ | `siyuan file get /路径` | 获取内容 |
133
+ | `siyuan file put <本地> <远程>` | 上传 |
134
+ | `siyuan asset upload <文件>` | 上传资源 |
135
+
136
+ ### 批量 & 其他
137
+
138
+ | 命令 | 说明 |
139
+ |------|------|
140
+ | `siyuan batch create <文件>` | 批量创建 |
141
+ | `siyuan batch delete <文件>` | 批量删除 |
142
+ | `siyuan stats` | 工作空间统计 |
143
+ | `siyuan overview` | 工作空间概览 |
144
+ | `siyuan health` | 诊断健康检查 |
145
+ | `siyuan notify push <消息>` | 推送通知到 UI |
146
+ | `siyuan backlinks get <id>` | 反向链接 |
147
+ | `siyuan mcp` | 启动 MCP 服务 |
148
+
149
+ ---
150
+
151
+ ## 全局选项
152
+
153
+ | 选项 | 说明 |
154
+ |------|------|
155
+ | `--format pretty\|json\|compact` | 输出格式(默认为 pretty) |
156
+ | `--verbose` | 详细日志(含缓存命中/失效信息) |
157
+ | `--no-color` | 禁用颜色输出 |
158
+ | `--version` | 显示版本号 |
159
+ | `--yes` | 跳过破坏性操作确认 |
160
+ | `--dry-run` | 预览操作但不执行 |
161
+ | `@file:/path` | 从文件读取内容 |
162
+ | `@stdin` | 从标准输入读取内容 |
163
+
164
+ **只读模式**:`SIYUAN_READ_ONLY=true siyuan <命令>` 阻止所有写操作。
165
+
166
+ ---
167
+
168
+ ## 多服务器
169
+
170
+ ```bash
171
+ siyuan workspace add 香港 --url http://server:6806 --token xxx
172
+ siyuan workspace use 香港
173
+ siyuan workspace list
174
+ ```
175
+
176
+ ---
177
+
178
+ ## 权限控制
179
+
180
+ 控制 AI Agent 能做什么:
181
+
182
+ ```bash
183
+ siyuan permission deny --endpoint "*remove*" # 禁止删除操作
184
+ siyuan permission ask --endpoint "*delete*" # 删除前询问确认
185
+ siyuan permission list # 查看规则
186
+ ```
187
+
188
+ ---
189
+
190
+ ## MCP 服务器
191
+
192
+ ```bash
193
+ siyuan-mcp
194
+ ```
195
+
196
+ 提供 23 个工具:CRUD、搜索、SQL、块引用/嵌入、标签管理、权限、健康检查。兼容 Claude Desktop、Cursor 等 MCP 客户端。
197
+
198
+ ---
199
+
200
+ ## AI Agent 集成
201
+
202
+ 安装技能到你的 Agent:
203
+
204
+ | Agent | 安装命令 |
205
+ |-------|---------|
206
+ | **OpenCode** | `git clone https://github.com/xingrove/siyuan-skills.git ~/.opencode/skills/siyuan-skills` |
207
+ | **Codex CLI** | `cp -r skills/* ~/.codex/skills/` |
208
+ | **Hermes** | `cp -r skills/* ~/.hermes/skills/` |
209
+ | **npx** | `npx skills add https://github.com/xingrove/siyuan-skills` |
210
+
211
+ 安装后 Agent 可读笔记、写笔记、搜索、分析、块引用/嵌入、批量操作、管理标签。
212
+
213
+ | 技能 | 说明 |
214
+ |------|------|
215
+ | [siyuan-cli](skills/siyuan-cli) | 通过 CLI 操作思源笔记 |
216
+ | [siyuan-api](skills/siyuan-api) | 直接调用思源 REST API |
217
+ | [siyuan-markdown](skills/siyuan-markdown) | 思源特色 Markdown 语法参考 |
218
+
219
+ ---
220
+
221
+ ## 配置说明
222
+
223
+ 优先级:环境变量 > 当前 workspace > `~/.siyuan/config.json`
224
+
225
+ ```json
226
+ {"url": "http://127.0.0.1:6806", "token": "你的Token"}
227
+ ```
228
+
229
+ 可选:Token 加密存储到系统密钥环
230
+
231
+ ```bash
232
+ pip install keyring
233
+ siyuan keyring-set 你的Token
234
+ siyuan keyring-unset
235
+ ```
236
+
237
+ ---
238
+
239
+ *社区项目,非官方。*
@@ -0,0 +1,208 @@
1
+ # SiYuan Agent Tools
2
+
3
+ [![PyPI](https://img.shields.io/pypi/v/siyuan-cli)](https://pypi.org/project/siyuan-cli/)
4
+ [![CI](https://github.com/xingrove/siyuan-skills/actions/workflows/ci.yml/badge.svg)](https://github.com/xingrove/siyuan-skills/actions)
5
+ [![Python](https://img.shields.io/pypi/pyversions/siyuan-cli)](https://pypi.org/project/siyuan-cli/)
6
+ [![License](https://img.shields.io/pypi/l/siyuan-cli)](LICENSE)
7
+ [![Tests](https://img.shields.io/badge/tests-229%20passed-brightgreen)](https://github.com/xingrove/siyuan-skills)
8
+
9
+ > [中文](README.md)
10
+
11
+ CLI tool, MCP server, and AI Agent Skills for [SiYuan Note](https://github.com/siyuan-note/siyuan). Pure Python, zero dependencies. Compatible with Claude Code, Codex, OpenCode, and Hermes.
12
+
13
+ ---
14
+
15
+ ## Install
16
+
17
+ ```bash
18
+ pip install siyuan-cli
19
+ ```
20
+
21
+ Or the one-command installer:
22
+
23
+ ```bash
24
+ curl -fsSL https://raw.githubusercontent.com/xingrove/siyuan-skills/main/scripts/install.sh | bash
25
+ ```
26
+
27
+ ---
28
+
29
+ ## Quick Start
30
+
31
+ ```bash
32
+ siyuan config url http://127.0.0.1:6806
33
+ siyuan config token your-api-token
34
+
35
+ siyuan stats # verify connectivity
36
+ ```
37
+
38
+ > Token location: SiYuan Desktop → Settings → API; for Docker, in `conf.json`.
39
+
40
+ ---
41
+
42
+ ## CLI Reference
43
+
44
+ ### Documents & Blocks
45
+
46
+ | Command | Description |
47
+ |---------|-------------|
48
+ | `siyuan create /path [content]` | Create a note (`--file` / `--stdin` supported) |
49
+ | `siyuan read /path` | Read document content |
50
+ | `siyuan delete /path [--id]` | Delete a note |
51
+ | `siyuan tree [notebook]` | Document tree |
52
+ | `siyuan doc rename <title>` | Rename document |
53
+ | `siyuan doc move <paths...> [--to-notebook]` | Move documents |
54
+ | `siyuan doc export /path [--id]` | Export as Markdown |
55
+ | `siyuan doc get-path <id>` | Resolve ID to path |
56
+
57
+ ### Block Operations
58
+
59
+ | Command | Description |
60
+ |---------|-------------|
61
+ | `siyuan block get <id>` | Block info |
62
+ | `siyuan block children <id>` | Child blocks |
63
+ | `siyuan block append <id> -c <content>` | Append child block |
64
+ | `siyuan block prepend <id> -c <content>` | Prepend child block |
65
+ | `siyuan block insert <id> -c <content>` | Insert block after sibling |
66
+ | `siyuan block update <id> -c <content>` | Update block |
67
+ | `siyuan block delete <id>` | Delete block |
68
+ | `siyuan block move <id> --parent <pid>` | Move block |
69
+ | `siyuan block fold <id>` | Fold heading |
70
+ | `siyuan block unfold <id>` | Unfold |
71
+
72
+ ### Block References & Embeds
73
+
74
+ | Command | Output | Description |
75
+ |---------|--------|-------------|
76
+ | `siyuan block ref <id>` | `((id 'title'))` | Block reference markup |
77
+ | `siyuan block embed <id>` | `{{embed ((id 'title'))}}` | Block embed markup |
78
+ | `siyuan block link <id>` | `siyuan://blocks/id` | SiYuan internal link |
79
+
80
+ ```bash
81
+ REF=$(siyuan block ref 20200812220555-lj3enxa)
82
+ siyuan create "/article" "As mentioned in $REF..."
83
+ ```
84
+
85
+ ### Notebooks, Search & Daily Notes
86
+
87
+ | Command | Description |
88
+ |---------|-------------|
89
+ | `siyuan notebook list` | List notebooks |
90
+ | `siyuan notebook create <name>` | Create notebook |
91
+ | `siyuan notebook remove <id>` | Remove notebook |
92
+ | `siyuan notebook rename <id> <name>` | Rename |
93
+ | `siyuan notebook conf <id>` | Notebook config |
94
+ | `siyuan search <query>` | Full-text search |
95
+ | `siyuan sql <statement>` | SQL query (SELECT only) |
96
+ | `siyuan daily-note note` | Get or create today's note |
97
+ | `siyuan daily-note append <content>` | Append to today's note |
98
+
99
+ ### Tags, Attributes & Assets
100
+
101
+ | Command | Description |
102
+ |---------|-------------|
103
+ | `siyuan tag list` | All tags |
104
+ | `siyuan tag blocks <tag>` | Find tagged blocks |
105
+ | `siyuan attr get <id>` | Block attributes |
106
+ | `siyuan attr set <id> <key> <val>` | Set attribute |
107
+ | `siyuan asset upload <file>` | Upload asset |
108
+ | `siyuan file list /data/` | List workspace files |
109
+ | `siyuan file put <local> <remote>` | Upload file |
110
+
111
+ ### Batch & Utilities
112
+
113
+ | Command | Description |
114
+ |---------|-------------|
115
+ | `siyuan batch create <file>` | Batch create notes |
116
+ | `siyuan batch delete <file>` | Batch delete notes |
117
+ | `siyuan stats` | Workspace statistics |
118
+ | `siyuan overview` | Workspace overview |
119
+ | `siyuan health` | Diagnostic health check |
120
+ | `siyuan backlinks get <id>` | Block backlinks |
121
+ | `siyuan notify push <msg>` | Push notification to UI |
122
+ | `siyuan mcp` | Start MCP server |
123
+
124
+ ---
125
+
126
+ ## Global Options
127
+
128
+ | Option | Description |
129
+ |--------|-------------|
130
+ | `--format pretty\|json\|compact` | Output format |
131
+ | `--verbose` | Detailed logging |
132
+ | `--no-color` | Disable colored output |
133
+ | `--version` | Show version |
134
+ | `--yes` | Skip confirmation on destructive ops |
135
+ | `--dry-run` | Preview without applying |
136
+ | `@file:/path` | Read content from file |
137
+ | `@stdin` | Read content from stdin |
138
+
139
+ **Read-only mode:** `SIYUAN_READ_ONLY=true siyuan <cmd>` blocks all writes.
140
+
141
+ ---
142
+
143
+ ## Multi-Server
144
+
145
+ ```bash
146
+ siyuan workspace add hk --url http://server:6806 --token xxx
147
+ siyuan workspace use hk
148
+ siyuan workspace list
149
+ ```
150
+
151
+ ---
152
+
153
+ ## Permission System
154
+
155
+ ```bash
156
+ siyuan permission deny --endpoint "*remove*" # Block all deletes
157
+ siyuan permission ask --endpoint "*delete*" # Ask before delete
158
+ siyuan permission list # Show rules
159
+ ```
160
+
161
+ ---
162
+
163
+ ## MCP Server
164
+
165
+ ```bash
166
+ siyuan-mcp
167
+ ```
168
+
169
+ 23 tools: CRUD, search, SQL, block refs/embeds, tags, attributes, health checks. Works with Claude Desktop, Cursor, and any MCP client.
170
+
171
+ ---
172
+
173
+ ## Agent Skills
174
+
175
+ | Agent | Install |
176
+ |-------|---------|
177
+ | **OpenCode** | `git clone https://github.com/xingrove/siyuan-skills.git ~/.opencode/skills/siyuan-skills` |
178
+ | **Codex CLI** | `cp -r skills/* ~/.codex/skills/` |
179
+ | **Hermes** | `cp -r skills/* ~/.hermes/skills/` |
180
+ | **npx** | `npx skills add https://github.com/xingrove/siyuan-skills` |
181
+
182
+ | Skill | Description |
183
+ |-------|-------------|
184
+ | [siyuan-cli](skills/siyuan-cli) | Operate SiYuan via CLI |
185
+ | [siyuan-api](skills/siyuan-api) | Direct REST API calls |
186
+ | [siyuan-markdown](skills/siyuan-markdown) | SiYuan-flavored Markdown reference |
187
+
188
+ ---
189
+
190
+ ## Configuration
191
+
192
+ Priority: `SIYUAN_URL` / `SIYUAN_TOKEN` env vars > active workspace > `~/.siyuan/config.json`
193
+
194
+ ```json
195
+ {"url": "http://127.0.0.1:6806", "token": "your-token"}
196
+ ```
197
+
198
+ Optional keyring storage:
199
+
200
+ ```bash
201
+ pip install keyring
202
+ siyuan keyring-set your-token
203
+ siyuan keyring-unset
204
+ ```
205
+
206
+ ---
207
+
208
+ *Community project, not official.*