docz-cli 0.2.2 → 0.4.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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Kris
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
@@ -15,21 +15,24 @@
15
15
 
16
16
  ```bash
17
17
  # Login
18
- npx docz-cli login --token <your-token>
18
+ npx docz-cli@latest login --token <your-token>
19
19
 
20
20
  # Browse
21
- npx docz-cli spaces
22
- npx docz-cli ls 研发
23
- npx docz-cli cat 研发:docs/guide.md
21
+ npx docz-cli@latest spaces
22
+ npx docz-cli@latest ls 研发
23
+ npx docz-cli@latest cat 研发:docs/guide.md
24
24
 
25
25
  # Write
26
- npx docz-cli write 吴鹏飞:notes/todo.md '# TODO List'
26
+ npx docz-cli@latest write 吴鹏飞:notes/todo.md '# TODO List'
27
27
  ```
28
28
 
29
29
  ## Features
30
30
 
31
31
  - **Simple addressing** — `<space>:<path>` format, Space supports name or ID
32
+ - **Short URL support** — paste `https://docz.xxx.com/s/slug/f/fileId` directly into cat/ls/log
32
33
  - **Full file operations** — ls, cat, upload, write, mkdir, rm, mv
34
+ - **Share links** — create, list, update, access, delete share links from CLI
35
+ - **File diff** — view file-level unified diff or space-level change summary
33
36
  - **Git-backed** — every write creates a commit, built-in version history
34
37
  - **Trash recovery** — deleted files recoverable within 30 days
35
38
  - **MCP Server** — built-in stdio MCP server for AI agent integration
@@ -40,10 +43,12 @@ npx docz-cli write 吴鹏飞:notes/todo.md '# TODO List'
40
43
  **Requirements:** Node.js >= 22.0.0
41
44
 
42
45
  ```bash
43
- npx docz-cli <command> # Use directly via npx
44
- npm install -g docz-cli # Or global install, then use `docz` shorthand
46
+ npx docz-cli@latest <command> # Always uses the latest version (recommended)
47
+ npm install -g docz-cli # Or global install, then use `docz` shorthand
45
48
  ```
46
49
 
50
+ > **Auto-update**: Using `npx docz-cli@latest` ensures you always run the latest version without manual updates. Global install requires `npm update -g docz-cli` to update.
51
+
47
52
  > Global install registers both `docz-cli` and `docz` commands. Examples below use `docz-cli`; replace with `docz` if installed globally.
48
53
 
49
54
  ## Authentication
@@ -80,6 +85,13 @@ export DOCSYNC_API_TOKEN=<your-token>
80
85
  | `mv <space>:<from> <to>` | Rename or move |
81
86
  | `log <space>[:<path>]` | Show change history |
82
87
  | `trash <space>` | Show deleted files |
88
+ | `diff <space>[:<path>] <commit> [<from>]` | Show changes (file or space level) |
89
+ | `share create <space>:<path>` | Create share link |
90
+ | `share list <space>` | List share links |
91
+ | `share update <space> <link-id>` | Update share link |
92
+ | `share cat <token-or-url>` | Read shared file |
93
+ | `share info <token-or-url>` | Show share link info |
94
+ | `share rm <space> <link-id>` | Delete share link |
83
95
  | `mcp` | Start MCP stdio server |
84
96
 
85
97
  ## Usage Examples
@@ -93,6 +105,22 @@ docz-cli ls 研发:docs # List subdirectory
93
105
  docz-cli cat 研发:docs/guide.md # Read file content
94
106
  ```
95
107
 
108
+ ### Short URL
109
+
110
+ `cat`, `ls`, `log` accept DocSync short URLs directly:
111
+
112
+ ```bash
113
+ # These are equivalent
114
+ docz-cli cat 闫洪康:AI-Coding技巧总结12.md
115
+ docz-cli cat https://docz.zhenguanyu.com/s/yanhongkang/f/NNjrcj8c
116
+
117
+ # List space root via slug
118
+ docz-cli ls https://docz.zhenguanyu.com/s/yanfa
119
+
120
+ # File history via short URL
121
+ docz-cli log https://docz.zhenguanyu.com/s/yanhongkang/f/NNjrcj8c
122
+ ```
123
+
96
124
  ### Write
97
125
 
98
126
  ```bash
@@ -112,6 +140,65 @@ docz-cli log 研发:docs/guide.md # File history
112
140
  docz-cli trash 研发 # View trash
113
141
  ```
114
142
 
143
+ ### Share Links
144
+
145
+ ```bash
146
+ # Create (with optional expiry and visibility)
147
+ docz-cli share create 研发:docs/guide.md --expires 7d --users user@co.com
148
+
149
+ # List all share links in a space
150
+ docz-cli share list 研发
151
+ docz-cli share list 研发 --file docs/guide.md # Filter by file
152
+
153
+ # Access shared content (token or full URL)
154
+ docz-cli share cat xYz123AbC
155
+ docz-cli share cat https://docz.zhenguanyu.com/share/xYz123AbC
156
+ docz-cli share cat xYz123AbC --raw | grep "部署" # Raw output for pipes
157
+
158
+ # View share link info
159
+ docz-cli share info xYz123AbC
160
+
161
+ # Update and delete (requires space context)
162
+ docz-cli share update 研发 <link-id> --expires 30d
163
+ docz-cli share rm 研发 <link-id>
164
+ ```
165
+
166
+ ### Diff
167
+
168
+ ```bash
169
+ # View what changed in a commit (file level)
170
+ docz-cli diff 研发:docs/guide.md af0fb9b
171
+
172
+ # Compare two commits
173
+ docz-cli diff 研发:docs/guide.md af0fb9b b2c3d4e
174
+
175
+ # Space-level: which files changed in a commit
176
+ docz-cli diff 研发 af0fb9b
177
+
178
+ # Typical workflow: log → pick commit → diff
179
+ docz-cli log 研发:docs/guide.md
180
+ docz-cli diff 研发:docs/guide.md af0fb9b
181
+ ```
182
+
183
+ ### Pipes
184
+
185
+ `cat` outputs to stdout, `write ... -` reads from stdin. Combine with any Unix tool:
186
+
187
+ ```bash
188
+ # Search content
189
+ docz-cli cat 研发:docs/guide.md | grep "部署"
190
+
191
+ # Extract CSV columns
192
+ docz-cli cat 研发:data.csv | cut -d',' -f1,3 | head -10
193
+
194
+ # Read → transform → write back
195
+ docz-cli cat 吴鹏飞:config.md | sed 's/old/new/g' | docz-cli write 吴鹏飞:config.md -
196
+
197
+ # Local command output → DocSync
198
+ echo "# Generated at $(date)" | docz-cli write 吴鹏飞:notes/auto.md -
199
+ cat local-file.md | docz-cli write 吴鹏飞:docs/remote.md -
200
+ ```
201
+
115
202
  ## MCP Server
116
203
 
117
204
  Built-in MCP server for AI agent integration (Claude Code, Cursor, etc.).
@@ -123,9 +210,9 @@ Add to your MCP settings:
123
210
  ```json
124
211
  {
125
212
  "mcpServers": {
126
- "docsync": {
213
+ "docz-mcp": {
127
214
  "command": "npx",
128
- "args": ["-y", "docz-cli", "mcp"],
215
+ "args": ["-y", "docz-cli@latest", "mcp"],
129
216
  "env": {
130
217
  "DOCSYNC_API_TOKEN": "<your-token>"
131
218
  }
@@ -134,17 +221,25 @@ Add to your MCP settings:
134
221
  }
135
222
  ```
136
223
 
224
+ > Using `docz-cli@latest` in MCP config ensures AI agents always use the latest version.
225
+
137
226
  ### MCP Tools
138
227
 
139
228
  | Tool | Description |
140
229
  |------|-------------|
141
- | `docsync_list_spaces` | List all accessible spaces |
142
- | `docsync_list_files` | List files in a directory |
143
- | `docsync_read_file` | Read file content |
144
- | `docsync_upload_file` | Upload/create a file |
145
- | `docsync_mkdir` | Create a folder |
146
- | `docsync_delete` | Delete file/folder |
147
- | `docsync_file_history` | View change history |
230
+ | `docz_list_spaces` | List all accessible spaces |
231
+ | `docz_list_files` | List files in a directory |
232
+ | `docz_read_file` | Read file content |
233
+ | `docz_upload_file` | Upload/create a file |
234
+ | `docz_mkdir` | Create a folder |
235
+ | `docz_delete` | Delete file/folder |
236
+ | `docz_file_history` | View change history |
237
+ | `docz_share_create` | Create share link |
238
+ | `docz_share_list` | List share links |
239
+ | `docz_share_read` | Read shared file by token |
240
+ | `docz_share_info` | View share link info |
241
+ | `docz_share_delete` | Delete share link |
242
+ | `docz_diff` | View file or space diff |
148
243
 
149
244
  ## AI Agent Skill
150
245
 
@@ -171,6 +266,14 @@ docz-cli wraps the DocSync REST API:
171
266
  | `mv` | `POST /api/spaces/{id}/files/rename` |
172
267
  | `log` | `GET /api/spaces/{id}/log/[{path}]` |
173
268
  | `trash` | `GET /api/spaces/{id}/trash` |
269
+ | `diff` | `GET /api/spaces/{id}/diff/[{path}]?from=&to=` |
270
+ | `share create` | `POST /api/spaces/{id}/share-links` |
271
+ | `share list` | `GET /api/spaces/{id}/share-links` |
272
+ | `share update` | `PUT /api/spaces/{id}/share-links/{linkId}` |
273
+ | `share cat` | `GET /api/share/{token}` |
274
+ | `share info` | `GET /api/share/{token}/info` |
275
+ | `share rm` | `DELETE /api/spaces/{id}/share-links/{linkId}` |
276
+ | Short URL resolve | `GET /api/spaces/by-slug/{slug}` + `GET /api/file-refs/{fileId}` |
174
277
 
175
278
  Auth: `Authorization: Bearer <token>`. Backend is Git — every write is a commit.
176
279