zspace-cli 0.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.
- zspace_cli-0.1.0/LICENSE +21 -0
- zspace_cli-0.1.0/PKG-INFO +291 -0
- zspace_cli-0.1.0/README.md +253 -0
- zspace_cli-0.1.0/pyproject.toml +67 -0
- zspace_cli-0.1.0/setup.cfg +4 -0
- zspace_cli-0.1.0/src/zspace_cli/__init__.py +6 -0
- zspace_cli-0.1.0/src/zspace_cli/auth.py +61 -0
- zspace_cli-0.1.0/src/zspace_cli/cli.py +271 -0
- zspace_cli-0.1.0/src/zspace_cli/client.py +220 -0
- zspace_cli-0.1.0/src/zspace_cli/mcp_server.py +286 -0
- zspace_cli-0.1.0/src/zspace_cli.egg-info/PKG-INFO +291 -0
- zspace_cli-0.1.0/src/zspace_cli.egg-info/SOURCES.txt +14 -0
- zspace_cli-0.1.0/src/zspace_cli.egg-info/dependency_links.txt +1 -0
- zspace_cli-0.1.0/src/zspace_cli.egg-info/entry_points.txt +3 -0
- zspace_cli-0.1.0/src/zspace_cli.egg-info/requires.txt +11 -0
- zspace_cli-0.1.0/src/zspace_cli.egg-info/top_level.txt +1 -0
zspace_cli-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 skyzhao
|
|
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,291 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: zspace-cli
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: CLI & SDK for ZSpace (极空间) NAS — manage files from your terminal or AI agents
|
|
5
|
+
Author: skyzhao
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/skyzhao/zspace-cli
|
|
8
|
+
Project-URL: Documentation, https://github.com/skyzhao/zspace-cli#readme
|
|
9
|
+
Project-URL: Repository, https://github.com/skyzhao/zspace-cli
|
|
10
|
+
Project-URL: Issues, https://github.com/skyzhao/zspace-cli/issues
|
|
11
|
+
Keywords: zspace,nas,cli,sdk,mcp,极空间,file-manager
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
16
|
+
Classifier: Operating System :: MacOS
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Topic :: System :: Filesystems
|
|
24
|
+
Classifier: Topic :: Utilities
|
|
25
|
+
Requires-Python: >=3.9
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
License-File: LICENSE
|
|
28
|
+
Requires-Dist: httpx>=0.24
|
|
29
|
+
Requires-Dist: typer>=0.9
|
|
30
|
+
Requires-Dist: rich>=13.0
|
|
31
|
+
Provides-Extra: mcp
|
|
32
|
+
Requires-Dist: mcp>=1.0; extra == "mcp"
|
|
33
|
+
Provides-Extra: dev
|
|
34
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
35
|
+
Requires-Dist: pytest-asyncio>=0.21; extra == "dev"
|
|
36
|
+
Requires-Dist: ruff>=0.4; extra == "dev"
|
|
37
|
+
Dynamic: license-file
|
|
38
|
+
|
|
39
|
+
# zspace-cli
|
|
40
|
+
|
|
41
|
+
**CLI, SDK & MCP Server for ZSpace (极空间) NAS**
|
|
42
|
+
|
|
43
|
+
> Manage your 极空间 NAS files from the terminal, Python scripts, or AI agents — zero config, no SSH needed.
|
|
44
|
+
|
|
45
|
+
[English](#features) | [中文](#功能特性)
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Why zspace-cli?
|
|
50
|
+
|
|
51
|
+
ZSpace (极空间) is a popular NAS brand in China, but it lacks official CLI tools or developer APIs.
|
|
52
|
+
|
|
53
|
+
**zspace-cli** reverse-engineered the internal API used by the ZSpace desktop client and wraps it into:
|
|
54
|
+
|
|
55
|
+
- **`zs` CLI** — 10 commands covering all file operations, powered by [Rich](https://github.com/Textualize/rich) for beautiful output
|
|
56
|
+
- **Python SDK** — `ZSpaceClient` with a clean, typed interface for automation scripts
|
|
57
|
+
- **MCP Server** — one-line config to add ZSpace file management to Claude, Cursor, or any MCP-compatible AI agent
|
|
58
|
+
|
|
59
|
+
### Zero Configuration
|
|
60
|
+
|
|
61
|
+
Just install and run. zspace-cli reads auth tokens directly from your running ZSpace desktop client — no passwords, no SSH keys, no port forwarding.
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
pip install zspace-cli
|
|
65
|
+
zs check # ✓ Connected, 11.8 TB total, 1.2 TB free
|
|
66
|
+
zs ls # List your NAS files
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Features
|
|
72
|
+
|
|
73
|
+
| Operation | CLI | SDK | MCP |
|
|
74
|
+
|-----------|-----|-----|-----|
|
|
75
|
+
| List directory | `zs ls [path]` | `client.ls(path)` | `zspace_ls` |
|
|
76
|
+
| File info | `zs info <path>` | `client.info(path)` | `zspace_info` |
|
|
77
|
+
| Rename | `zs rename <path> <name>` | `client.rename(path, name)` | `zspace_rename` |
|
|
78
|
+
| Create dir | `zs mkdir <parent> <name>` | `client.mkdir(parent, name)` | `zspace_mkdir` |
|
|
79
|
+
| Move | `zs mv <src> <dest>` | `client.move(src, dest)` | `zspace_move` |
|
|
80
|
+
| Copy | `zs cp <src> <dest>` | `client.copy(src, dest)` | `zspace_copy` |
|
|
81
|
+
| Delete | `zs rm <path>` | `client.remove(path)` | `zspace_remove` |
|
|
82
|
+
| Search | `zs find <keyword>` | `client.search(kw)` | `zspace_search` |
|
|
83
|
+
| Tree view | `zs tree [path]` | `client.tree(path)` | `zspace_tree` |
|
|
84
|
+
| Health check | `zs check` | `client.is_connected()` | `zspace_check` |
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## Installation
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
pip install zspace-cli
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
**Prerequisites:** ZSpace desktop client running on macOS (logged in).
|
|
95
|
+
|
|
96
|
+
### With MCP Server support
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
pip install "zspace-cli[mcp]"
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## Quick Start
|
|
105
|
+
|
|
106
|
+
### CLI
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
# Check connection
|
|
110
|
+
zs check
|
|
111
|
+
|
|
112
|
+
# List files
|
|
113
|
+
zs ls /sata11/my/data
|
|
114
|
+
zs ls -l /sata11/my/data/影视 # detailed view
|
|
115
|
+
|
|
116
|
+
# File operations
|
|
117
|
+
zs mkdir /sata11/my/data 新建文件夹
|
|
118
|
+
zs rename /sata11/my/data/old_name new_name
|
|
119
|
+
zs mv /sata11/my/data/file.mp4 /sata11/my/data/影视
|
|
120
|
+
zs cp /sata11/my/data/important /sata11/my/data/backup
|
|
121
|
+
zs rm /sata11/my/data/temp
|
|
122
|
+
|
|
123
|
+
# Search & explore
|
|
124
|
+
zs find "权力的游戏"
|
|
125
|
+
zs tree /sata11/my/data -d 3
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Python SDK
|
|
129
|
+
|
|
130
|
+
```python
|
|
131
|
+
from zspace_cli import ZSpaceClient
|
|
132
|
+
|
|
133
|
+
with ZSpaceClient() as zs:
|
|
134
|
+
# List files
|
|
135
|
+
for f in zs.ls("/sata11/my/data"):
|
|
136
|
+
print(f"{'📁' if f.is_dir else '📄'} {f.name}")
|
|
137
|
+
|
|
138
|
+
# Batch rename videos
|
|
139
|
+
for f in zs.ls("/sata11/my/data/影视"):
|
|
140
|
+
if f.name.startswith("[raw]"):
|
|
141
|
+
new_name = f.name.replace("[raw]", "").strip()
|
|
142
|
+
zs.rename(f.path, new_name)
|
|
143
|
+
print(f"Renamed: {new_name}")
|
|
144
|
+
|
|
145
|
+
# Organize files
|
|
146
|
+
zs.mkdir("/sata11/my/data", "已整理")
|
|
147
|
+
zs.move("/sata11/my/data/散文件.pdf", "/sata11/my/data/已整理")
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### MCP Server (for AI Agents)
|
|
151
|
+
|
|
152
|
+
Add to your Claude Desktop / Cursor MCP config:
|
|
153
|
+
|
|
154
|
+
```json
|
|
155
|
+
{
|
|
156
|
+
"mcpServers": {
|
|
157
|
+
"zspace": {
|
|
158
|
+
"command": "zs-mcp",
|
|
159
|
+
"args": []
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Then ask your AI: "帮我把 NAS 上影视文件夹里的视频按年份整理一下"
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## How It Works
|
|
170
|
+
|
|
171
|
+
```
|
|
172
|
+
┌─────────────┐ ┌──────────────────┐ ┌──────────┐
|
|
173
|
+
│ zs CLI │ │ ZSpace Desktop │ │ ZSpace │
|
|
174
|
+
│ Python SDK ├─────►│ Client (proxy) ├─────►│ NAS │
|
|
175
|
+
│ MCP Server │ HTTP │ 127.0.0.1:13579 │ P2P │ Device │
|
|
176
|
+
└─────────────┘ └──────────────────┘ └──────────┘
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
The ZSpace desktop client maintains an encrypted tunnel to your NAS and exposes a local HTTP proxy. zspace-cli communicates with this proxy using the same API the official web UI uses.
|
|
180
|
+
|
|
181
|
+
**No direct network access to the NAS is needed** — works even when your NAS is behind NAT or on a different network.
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## API Reference
|
|
186
|
+
|
|
187
|
+
All operations go through the ZSpace internal API at `127.0.0.1:13579`.
|
|
188
|
+
|
|
189
|
+
| Endpoint | Method | Key Parameters |
|
|
190
|
+
|----------|--------|---------------|
|
|
191
|
+
| `/v2/file/list` | POST | `path`, `show_hidden` |
|
|
192
|
+
| `/v2/file/info` | POST | `path` |
|
|
193
|
+
| `/v2/file/modify` | POST | `path`, `newname` |
|
|
194
|
+
| `/v2/file/newdir` | POST | `parent` (not path!), `name`, `rename=0` |
|
|
195
|
+
| `/v2/file/move` | POST | `paths[]` (array), `to` (not dest!) |
|
|
196
|
+
| `/v2/file/copy` | POST | `paths[]` (array), `to` (not dest!) |
|
|
197
|
+
| `/v2/file/remove` | POST | `paths[]` (array) |
|
|
198
|
+
|
|
199
|
+
> **Key discovery:** The parameter names are non-standard — `newdir` uses `parent` instead of `path`, and `move`/`copy` use `to` instead of `dest`. These were found by reverse-engineering the ZSpace web UI.
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## Roadmap
|
|
204
|
+
|
|
205
|
+
- [ ] File upload/download support
|
|
206
|
+
- [ ] Linux client support
|
|
207
|
+
- [ ] Windows client support
|
|
208
|
+
- [ ] Docker image for headless deployment
|
|
209
|
+
- [ ] Batch operations with glob patterns
|
|
210
|
+
- [ ] File watching / sync triggers
|
|
211
|
+
|
|
212
|
+
---
|
|
213
|
+
|
|
214
|
+
## Contributing
|
|
215
|
+
|
|
216
|
+
Contributions are welcome! Please open an issue first to discuss what you'd like to change.
|
|
217
|
+
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
## License
|
|
221
|
+
|
|
222
|
+
MIT
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
226
|
+
<details>
|
|
227
|
+
<summary><h2>中文说明</h2></summary>
|
|
228
|
+
|
|
229
|
+
## 功能特性
|
|
230
|
+
|
|
231
|
+
**zspace-cli** 是极空间 NAS 的命令行工具、Python SDK 和 MCP Server。
|
|
232
|
+
|
|
233
|
+
通过逆向工程极空间桌面客户端的内部 API,实现了**完整的文件管理功能**——无需 SSH,无需 WebDAV,零配置即可使用。
|
|
234
|
+
|
|
235
|
+
### 安装
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
pip install zspace-cli
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
**前提条件:** macOS 上已安装并登录极空间桌面客户端。
|
|
242
|
+
|
|
243
|
+
### 使用方法
|
|
244
|
+
|
|
245
|
+
```bash
|
|
246
|
+
# 检查连接
|
|
247
|
+
zs check
|
|
248
|
+
|
|
249
|
+
# 文件操作
|
|
250
|
+
zs ls # 列出目录
|
|
251
|
+
zs ls -l /sata11/my/data/影视 # 详细模式
|
|
252
|
+
zs info /sata11/my/data/影视 # 查看详情
|
|
253
|
+
zs mkdir /sata11/my/data 新文件夹 # 创建目录
|
|
254
|
+
zs rename /path/old new_name # 重命名
|
|
255
|
+
zs mv /path/src /path/dest # 移动
|
|
256
|
+
zs cp /path/src /path/dest # 复制
|
|
257
|
+
zs rm /path/to/delete # 删除
|
|
258
|
+
zs find "关键词" # 搜索
|
|
259
|
+
zs tree /sata11/my/data -d 3 # 树形视图
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### MCP Server 配置(AI 智能体)
|
|
263
|
+
|
|
264
|
+
在 Claude Desktop 或 Cursor 的 MCP 配置中添加:
|
|
265
|
+
|
|
266
|
+
```json
|
|
267
|
+
{
|
|
268
|
+
"mcpServers": {
|
|
269
|
+
"zspace": {
|
|
270
|
+
"command": "zs-mcp",
|
|
271
|
+
"args": []
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
配置完成后,你可以用自然语言让 AI 管理你的 NAS 文件:
|
|
278
|
+
- "帮我把影视文件夹里的电影按年份分类"
|
|
279
|
+
- "查找所有大于 10GB 的文件"
|
|
280
|
+
- "把百度网盘文件夹里的文档移到文档同步文件夹"
|
|
281
|
+
|
|
282
|
+
### 工作原理
|
|
283
|
+
|
|
284
|
+
极空间桌面客户端在本机 `127.0.0.1:13579` 建立了到 NAS 的加密代理。zspace-cli 通过这个代理调用和官方 Web UI 完全相同的 API,因此:
|
|
285
|
+
|
|
286
|
+
- 不需要 NAS 在局域网内
|
|
287
|
+
- 不需要配置 DDNS 或端口转发
|
|
288
|
+
- 不需要开启 SSH
|
|
289
|
+
- 只要桌面客户端在运行,就能操作
|
|
290
|
+
|
|
291
|
+
</details>
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
# zspace-cli
|
|
2
|
+
|
|
3
|
+
**CLI, SDK & MCP Server for ZSpace (极空间) NAS**
|
|
4
|
+
|
|
5
|
+
> Manage your 极空间 NAS files from the terminal, Python scripts, or AI agents — zero config, no SSH needed.
|
|
6
|
+
|
|
7
|
+
[English](#features) | [中文](#功能特性)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Why zspace-cli?
|
|
12
|
+
|
|
13
|
+
ZSpace (极空间) is a popular NAS brand in China, but it lacks official CLI tools or developer APIs.
|
|
14
|
+
|
|
15
|
+
**zspace-cli** reverse-engineered the internal API used by the ZSpace desktop client and wraps it into:
|
|
16
|
+
|
|
17
|
+
- **`zs` CLI** — 10 commands covering all file operations, powered by [Rich](https://github.com/Textualize/rich) for beautiful output
|
|
18
|
+
- **Python SDK** — `ZSpaceClient` with a clean, typed interface for automation scripts
|
|
19
|
+
- **MCP Server** — one-line config to add ZSpace file management to Claude, Cursor, or any MCP-compatible AI agent
|
|
20
|
+
|
|
21
|
+
### Zero Configuration
|
|
22
|
+
|
|
23
|
+
Just install and run. zspace-cli reads auth tokens directly from your running ZSpace desktop client — no passwords, no SSH keys, no port forwarding.
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
pip install zspace-cli
|
|
27
|
+
zs check # ✓ Connected, 11.8 TB total, 1.2 TB free
|
|
28
|
+
zs ls # List your NAS files
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Features
|
|
34
|
+
|
|
35
|
+
| Operation | CLI | SDK | MCP |
|
|
36
|
+
|-----------|-----|-----|-----|
|
|
37
|
+
| List directory | `zs ls [path]` | `client.ls(path)` | `zspace_ls` |
|
|
38
|
+
| File info | `zs info <path>` | `client.info(path)` | `zspace_info` |
|
|
39
|
+
| Rename | `zs rename <path> <name>` | `client.rename(path, name)` | `zspace_rename` |
|
|
40
|
+
| Create dir | `zs mkdir <parent> <name>` | `client.mkdir(parent, name)` | `zspace_mkdir` |
|
|
41
|
+
| Move | `zs mv <src> <dest>` | `client.move(src, dest)` | `zspace_move` |
|
|
42
|
+
| Copy | `zs cp <src> <dest>` | `client.copy(src, dest)` | `zspace_copy` |
|
|
43
|
+
| Delete | `zs rm <path>` | `client.remove(path)` | `zspace_remove` |
|
|
44
|
+
| Search | `zs find <keyword>` | `client.search(kw)` | `zspace_search` |
|
|
45
|
+
| Tree view | `zs tree [path]` | `client.tree(path)` | `zspace_tree` |
|
|
46
|
+
| Health check | `zs check` | `client.is_connected()` | `zspace_check` |
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Installation
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
pip install zspace-cli
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**Prerequisites:** ZSpace desktop client running on macOS (logged in).
|
|
57
|
+
|
|
58
|
+
### With MCP Server support
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
pip install "zspace-cli[mcp]"
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## Quick Start
|
|
67
|
+
|
|
68
|
+
### CLI
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
# Check connection
|
|
72
|
+
zs check
|
|
73
|
+
|
|
74
|
+
# List files
|
|
75
|
+
zs ls /sata11/my/data
|
|
76
|
+
zs ls -l /sata11/my/data/影视 # detailed view
|
|
77
|
+
|
|
78
|
+
# File operations
|
|
79
|
+
zs mkdir /sata11/my/data 新建文件夹
|
|
80
|
+
zs rename /sata11/my/data/old_name new_name
|
|
81
|
+
zs mv /sata11/my/data/file.mp4 /sata11/my/data/影视
|
|
82
|
+
zs cp /sata11/my/data/important /sata11/my/data/backup
|
|
83
|
+
zs rm /sata11/my/data/temp
|
|
84
|
+
|
|
85
|
+
# Search & explore
|
|
86
|
+
zs find "权力的游戏"
|
|
87
|
+
zs tree /sata11/my/data -d 3
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Python SDK
|
|
91
|
+
|
|
92
|
+
```python
|
|
93
|
+
from zspace_cli import ZSpaceClient
|
|
94
|
+
|
|
95
|
+
with ZSpaceClient() as zs:
|
|
96
|
+
# List files
|
|
97
|
+
for f in zs.ls("/sata11/my/data"):
|
|
98
|
+
print(f"{'📁' if f.is_dir else '📄'} {f.name}")
|
|
99
|
+
|
|
100
|
+
# Batch rename videos
|
|
101
|
+
for f in zs.ls("/sata11/my/data/影视"):
|
|
102
|
+
if f.name.startswith("[raw]"):
|
|
103
|
+
new_name = f.name.replace("[raw]", "").strip()
|
|
104
|
+
zs.rename(f.path, new_name)
|
|
105
|
+
print(f"Renamed: {new_name}")
|
|
106
|
+
|
|
107
|
+
# Organize files
|
|
108
|
+
zs.mkdir("/sata11/my/data", "已整理")
|
|
109
|
+
zs.move("/sata11/my/data/散文件.pdf", "/sata11/my/data/已整理")
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### MCP Server (for AI Agents)
|
|
113
|
+
|
|
114
|
+
Add to your Claude Desktop / Cursor MCP config:
|
|
115
|
+
|
|
116
|
+
```json
|
|
117
|
+
{
|
|
118
|
+
"mcpServers": {
|
|
119
|
+
"zspace": {
|
|
120
|
+
"command": "zs-mcp",
|
|
121
|
+
"args": []
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Then ask your AI: "帮我把 NAS 上影视文件夹里的视频按年份整理一下"
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## How It Works
|
|
132
|
+
|
|
133
|
+
```
|
|
134
|
+
┌─────────────┐ ┌──────────────────┐ ┌──────────┐
|
|
135
|
+
│ zs CLI │ │ ZSpace Desktop │ │ ZSpace │
|
|
136
|
+
│ Python SDK ├─────►│ Client (proxy) ├─────►│ NAS │
|
|
137
|
+
│ MCP Server │ HTTP │ 127.0.0.1:13579 │ P2P │ Device │
|
|
138
|
+
└─────────────┘ └──────────────────┘ └──────────┘
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
The ZSpace desktop client maintains an encrypted tunnel to your NAS and exposes a local HTTP proxy. zspace-cli communicates with this proxy using the same API the official web UI uses.
|
|
142
|
+
|
|
143
|
+
**No direct network access to the NAS is needed** — works even when your NAS is behind NAT or on a different network.
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## API Reference
|
|
148
|
+
|
|
149
|
+
All operations go through the ZSpace internal API at `127.0.0.1:13579`.
|
|
150
|
+
|
|
151
|
+
| Endpoint | Method | Key Parameters |
|
|
152
|
+
|----------|--------|---------------|
|
|
153
|
+
| `/v2/file/list` | POST | `path`, `show_hidden` |
|
|
154
|
+
| `/v2/file/info` | POST | `path` |
|
|
155
|
+
| `/v2/file/modify` | POST | `path`, `newname` |
|
|
156
|
+
| `/v2/file/newdir` | POST | `parent` (not path!), `name`, `rename=0` |
|
|
157
|
+
| `/v2/file/move` | POST | `paths[]` (array), `to` (not dest!) |
|
|
158
|
+
| `/v2/file/copy` | POST | `paths[]` (array), `to` (not dest!) |
|
|
159
|
+
| `/v2/file/remove` | POST | `paths[]` (array) |
|
|
160
|
+
|
|
161
|
+
> **Key discovery:** The parameter names are non-standard — `newdir` uses `parent` instead of `path`, and `move`/`copy` use `to` instead of `dest`. These were found by reverse-engineering the ZSpace web UI.
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## Roadmap
|
|
166
|
+
|
|
167
|
+
- [ ] File upload/download support
|
|
168
|
+
- [ ] Linux client support
|
|
169
|
+
- [ ] Windows client support
|
|
170
|
+
- [ ] Docker image for headless deployment
|
|
171
|
+
- [ ] Batch operations with glob patterns
|
|
172
|
+
- [ ] File watching / sync triggers
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## Contributing
|
|
177
|
+
|
|
178
|
+
Contributions are welcome! Please open an issue first to discuss what you'd like to change.
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## License
|
|
183
|
+
|
|
184
|
+
MIT
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
<details>
|
|
189
|
+
<summary><h2>中文说明</h2></summary>
|
|
190
|
+
|
|
191
|
+
## 功能特性
|
|
192
|
+
|
|
193
|
+
**zspace-cli** 是极空间 NAS 的命令行工具、Python SDK 和 MCP Server。
|
|
194
|
+
|
|
195
|
+
通过逆向工程极空间桌面客户端的内部 API,实现了**完整的文件管理功能**——无需 SSH,无需 WebDAV,零配置即可使用。
|
|
196
|
+
|
|
197
|
+
### 安装
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
pip install zspace-cli
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
**前提条件:** macOS 上已安装并登录极空间桌面客户端。
|
|
204
|
+
|
|
205
|
+
### 使用方法
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
# 检查连接
|
|
209
|
+
zs check
|
|
210
|
+
|
|
211
|
+
# 文件操作
|
|
212
|
+
zs ls # 列出目录
|
|
213
|
+
zs ls -l /sata11/my/data/影视 # 详细模式
|
|
214
|
+
zs info /sata11/my/data/影视 # 查看详情
|
|
215
|
+
zs mkdir /sata11/my/data 新文件夹 # 创建目录
|
|
216
|
+
zs rename /path/old new_name # 重命名
|
|
217
|
+
zs mv /path/src /path/dest # 移动
|
|
218
|
+
zs cp /path/src /path/dest # 复制
|
|
219
|
+
zs rm /path/to/delete # 删除
|
|
220
|
+
zs find "关键词" # 搜索
|
|
221
|
+
zs tree /sata11/my/data -d 3 # 树形视图
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
### MCP Server 配置(AI 智能体)
|
|
225
|
+
|
|
226
|
+
在 Claude Desktop 或 Cursor 的 MCP 配置中添加:
|
|
227
|
+
|
|
228
|
+
```json
|
|
229
|
+
{
|
|
230
|
+
"mcpServers": {
|
|
231
|
+
"zspace": {
|
|
232
|
+
"command": "zs-mcp",
|
|
233
|
+
"args": []
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
配置完成后,你可以用自然语言让 AI 管理你的 NAS 文件:
|
|
240
|
+
- "帮我把影视文件夹里的电影按年份分类"
|
|
241
|
+
- "查找所有大于 10GB 的文件"
|
|
242
|
+
- "把百度网盘文件夹里的文档移到文档同步文件夹"
|
|
243
|
+
|
|
244
|
+
### 工作原理
|
|
245
|
+
|
|
246
|
+
极空间桌面客户端在本机 `127.0.0.1:13579` 建立了到 NAS 的加密代理。zspace-cli 通过这个代理调用和官方 Web UI 完全相同的 API,因此:
|
|
247
|
+
|
|
248
|
+
- 不需要 NAS 在局域网内
|
|
249
|
+
- 不需要配置 DDNS 或端口转发
|
|
250
|
+
- 不需要开启 SSH
|
|
251
|
+
- 只要桌面客户端在运行,就能操作
|
|
252
|
+
|
|
253
|
+
</details>
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=64"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "zspace-cli"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "CLI & SDK for ZSpace (极空间) NAS — manage files from your terminal or AI agents"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
requires-python = ">=3.9"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "skyzhao" },
|
|
14
|
+
]
|
|
15
|
+
keywords = ["zspace", "nas", "cli", "sdk", "mcp", "极空间", "file-manager"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 3 - Alpha",
|
|
18
|
+
"Environment :: Console",
|
|
19
|
+
"Intended Audience :: Developers",
|
|
20
|
+
"Intended Audience :: End Users/Desktop",
|
|
21
|
+
"Operating System :: MacOS",
|
|
22
|
+
"Programming Language :: Python :: 3",
|
|
23
|
+
"Programming Language :: Python :: 3.9",
|
|
24
|
+
"Programming Language :: Python :: 3.10",
|
|
25
|
+
"Programming Language :: Python :: 3.11",
|
|
26
|
+
"Programming Language :: Python :: 3.12",
|
|
27
|
+
"Programming Language :: Python :: 3.13",
|
|
28
|
+
"Topic :: System :: Filesystems",
|
|
29
|
+
"Topic :: Utilities",
|
|
30
|
+
]
|
|
31
|
+
dependencies = [
|
|
32
|
+
"httpx>=0.24",
|
|
33
|
+
"typer>=0.9",
|
|
34
|
+
"rich>=13.0",
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
[project.optional-dependencies]
|
|
38
|
+
mcp = ["mcp>=1.0"]
|
|
39
|
+
dev = [
|
|
40
|
+
"pytest>=7.0",
|
|
41
|
+
"pytest-asyncio>=0.21",
|
|
42
|
+
"ruff>=0.4",
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
[project.urls]
|
|
46
|
+
Homepage = "https://github.com/skyzhao/zspace-cli"
|
|
47
|
+
Documentation = "https://github.com/skyzhao/zspace-cli#readme"
|
|
48
|
+
Repository = "https://github.com/skyzhao/zspace-cli"
|
|
49
|
+
Issues = "https://github.com/skyzhao/zspace-cli/issues"
|
|
50
|
+
|
|
51
|
+
[project.scripts]
|
|
52
|
+
zs = "zspace_cli.cli:app"
|
|
53
|
+
zs-mcp = "zspace_cli.mcp_server:main"
|
|
54
|
+
|
|
55
|
+
[tool.setuptools.packages.find]
|
|
56
|
+
where = ["src"]
|
|
57
|
+
|
|
58
|
+
[tool.ruff]
|
|
59
|
+
target-version = "py39"
|
|
60
|
+
line-length = 100
|
|
61
|
+
|
|
62
|
+
[tool.ruff.lint]
|
|
63
|
+
select = ["E", "F", "I", "N", "W", "UP"]
|
|
64
|
+
|
|
65
|
+
[tool.pytest.ini_options]
|
|
66
|
+
testpaths = ["tests"]
|
|
67
|
+
asyncio_mode = "auto"
|