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 +21 -0
- package/README.md +119 -16
- package/dist/chunk-WH5WLKFJ.js +544 -0
- package/dist/chunk-WH5WLKFJ.js.map +1 -0
- package/dist/index.js +3 -209
- package/dist/index.js.map +1 -1
- package/dist/{mcp-EJZJGAX6.js → mcp-PAPGDW5K.js} +147 -19
- package/dist/mcp-PAPGDW5K.js.map +1 -0
- package/package.json +1 -1
- package/dist/chunk-N4DS7U4I.js +0 -138
- package/dist/chunk-N4DS7U4I.js.map +0 -1
- package/dist/mcp-EJZJGAX6.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,221 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
getConfigPath,
|
|
6
|
-
getToken,
|
|
7
|
-
saveConfig
|
|
8
|
-
} from "./chunk-N4DS7U4I.js";
|
|
3
|
+
registerCommands
|
|
4
|
+
} from "./chunk-WH5WLKFJ.js";
|
|
9
5
|
|
|
10
6
|
// src/index.ts
|
|
11
7
|
import { Command } from "commander";
|
|
12
|
-
|
|
13
|
-
// src/commands.ts
|
|
14
|
-
import { readFileSync } from "fs";
|
|
15
|
-
import { basename, dirname } from "path";
|
|
16
|
-
function getClient() {
|
|
17
|
-
const token = getToken();
|
|
18
|
-
if (!token) {
|
|
19
|
-
console.error(
|
|
20
|
-
"Error: No token configured.\nRun `docz login` or set DOCSYNC_API_TOKEN environment variable."
|
|
21
|
-
);
|
|
22
|
-
process.exit(1);
|
|
23
|
-
}
|
|
24
|
-
return new DocSyncClient(getBaseUrl(), token);
|
|
25
|
-
}
|
|
26
|
-
function parseTarget(args) {
|
|
27
|
-
if (args.length === 0) {
|
|
28
|
-
console.error(
|
|
29
|
-
"Error: space is required. Usage: docz <cmd> <space>[:<path>]"
|
|
30
|
-
);
|
|
31
|
-
process.exit(1);
|
|
32
|
-
}
|
|
33
|
-
const first = args[0];
|
|
34
|
-
if (first.includes(":")) {
|
|
35
|
-
const [space, ...rest] = first.split(":");
|
|
36
|
-
return { space, path: rest.join(":") };
|
|
37
|
-
}
|
|
38
|
-
return { space: first, path: args.slice(1).join(" ") };
|
|
39
|
-
}
|
|
40
|
-
function formatSize(bytes) {
|
|
41
|
-
if (bytes < 1024) return `${bytes} B`;
|
|
42
|
-
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
|
|
43
|
-
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
44
|
-
}
|
|
45
|
-
function registerCommands(program2) {
|
|
46
|
-
program2.command("login").description("Configure DocSync credentials").option("-u, --url <url>", "DocSync server URL").option("-t, --token <token>", "API token").action(async (opts) => {
|
|
47
|
-
const url = opts.url ?? getBaseUrl();
|
|
48
|
-
const token = opts.token;
|
|
49
|
-
if (!token) {
|
|
50
|
-
console.error(
|
|
51
|
-
"Error: --token is required.\nGet one at: " + url + " \u2192 Settings \u2192 API Tokens"
|
|
52
|
-
);
|
|
53
|
-
process.exit(1);
|
|
54
|
-
}
|
|
55
|
-
const client = new DocSyncClient(url, token);
|
|
56
|
-
try {
|
|
57
|
-
const user = await client.me();
|
|
58
|
-
saveConfig(url, token);
|
|
59
|
-
console.log(`Logged in as ${user.name} (${user.email})`);
|
|
60
|
-
console.log(`Config saved to ${getConfigPath()}`);
|
|
61
|
-
} catch (err) {
|
|
62
|
-
console.error(
|
|
63
|
-
`Error: ${err instanceof Error ? err.message : String(err)}`
|
|
64
|
-
);
|
|
65
|
-
process.exit(1);
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
program2.command("whoami").description("Show current user").action(async () => {
|
|
69
|
-
const client = getClient();
|
|
70
|
-
const user = await client.me();
|
|
71
|
-
console.log(`${user.name} (${user.email})`);
|
|
72
|
-
});
|
|
73
|
-
program2.command("spaces").description("List all accessible spaces").action(async () => {
|
|
74
|
-
const client = getClient();
|
|
75
|
-
const spaces = await client.listSpaces();
|
|
76
|
-
for (const s of spaces) {
|
|
77
|
-
const tag = s.is_private ? "private" : "team";
|
|
78
|
-
console.log(`${s.name} ${tag} ${s.member_count} members ${s.id}`);
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
program2.command("ls").description("List files \u2014 docz ls <space>[:<path>]").argument("<target...>").action(async (args) => {
|
|
82
|
-
const { space, path } = parseTarget(args);
|
|
83
|
-
const client = getClient();
|
|
84
|
-
const s = await client.resolveSpace(space);
|
|
85
|
-
const entries = await client.ls(s.id, path);
|
|
86
|
-
if (entries.length === 0) {
|
|
87
|
-
console.log("(empty)");
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
for (const e of entries) {
|
|
91
|
-
if (e.type === "tree") {
|
|
92
|
-
console.log(`${e.name}/`);
|
|
93
|
-
} else {
|
|
94
|
-
console.log(`${e.name} ${formatSize(e.size)}`);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
program2.command("cat").description("Read file content \u2014 docz cat <space>:<path>").argument("<target...>").action(async (args) => {
|
|
99
|
-
const { space, path } = parseTarget(args);
|
|
100
|
-
if (!path) {
|
|
101
|
-
console.error(
|
|
102
|
-
"Error: file path is required. Usage: docz cat <space>:<path>"
|
|
103
|
-
);
|
|
104
|
-
process.exit(1);
|
|
105
|
-
}
|
|
106
|
-
const client = getClient();
|
|
107
|
-
const s = await client.resolveSpace(space);
|
|
108
|
-
const content = await client.cat(s.id, path);
|
|
109
|
-
process.stdout.write(content);
|
|
110
|
-
});
|
|
111
|
-
program2.command("upload").description("Upload file \u2014 docz upload <local-file> <space>[:<dir>]").argument("<file>", "Local file to upload").argument("<target...>").action(async (file, args) => {
|
|
112
|
-
const { space, path: dir } = parseTarget(args);
|
|
113
|
-
const client = getClient();
|
|
114
|
-
const s = await client.resolveSpace(space);
|
|
115
|
-
const content = readFileSync(file);
|
|
116
|
-
const filename = basename(file);
|
|
117
|
-
const targetDir = dir || "";
|
|
118
|
-
const result = await client.upload(s.id, targetDir, filename, content);
|
|
119
|
-
console.log(`Uploaded: ${result.path}`);
|
|
120
|
-
});
|
|
121
|
-
program2.command("write").description("Write content to file \u2014 docz write <space>:<path> <content>").argument("<target>", "space:dir/filename.md").argument("<content>", "File content (or - for stdin)").action(async (target, content) => {
|
|
122
|
-
const { space, path } = parseTarget([target]);
|
|
123
|
-
if (!path) {
|
|
124
|
-
console.error(
|
|
125
|
-
"Error: path is required. Usage: docz write <space>:<dir/filename> <content>"
|
|
126
|
-
);
|
|
127
|
-
process.exit(1);
|
|
128
|
-
}
|
|
129
|
-
const client = getClient();
|
|
130
|
-
const s = await client.resolveSpace(space);
|
|
131
|
-
const filename = basename(path);
|
|
132
|
-
const dir = dirname(path);
|
|
133
|
-
let body;
|
|
134
|
-
if (content === "-") {
|
|
135
|
-
const chunks = [];
|
|
136
|
-
for await (const chunk of process.stdin) {
|
|
137
|
-
chunks.push(chunk);
|
|
138
|
-
}
|
|
139
|
-
body = Buffer.concat(chunks).toString("utf-8");
|
|
140
|
-
} else {
|
|
141
|
-
body = content;
|
|
142
|
-
}
|
|
143
|
-
const result = await client.upload(
|
|
144
|
-
s.id,
|
|
145
|
-
dir === "." ? "" : dir,
|
|
146
|
-
filename,
|
|
147
|
-
body
|
|
148
|
-
);
|
|
149
|
-
console.log(`Written: ${result.path}`);
|
|
150
|
-
});
|
|
151
|
-
program2.command("mkdir").description("Create folder \u2014 docz mkdir <space>:<path>").argument("<target...>").action(async (args) => {
|
|
152
|
-
const { space, path } = parseTarget(args);
|
|
153
|
-
if (!path) {
|
|
154
|
-
console.error("Error: path is required.");
|
|
155
|
-
process.exit(1);
|
|
156
|
-
}
|
|
157
|
-
const client = getClient();
|
|
158
|
-
const s = await client.resolveSpace(space);
|
|
159
|
-
await client.mkdir(s.id, path);
|
|
160
|
-
console.log(`Created: ${path}`);
|
|
161
|
-
});
|
|
162
|
-
program2.command("rm").description("Delete file/folder \u2014 docz rm <space>:<path>").argument("<target...>").action(async (args) => {
|
|
163
|
-
const { space, path } = parseTarget(args);
|
|
164
|
-
if (!path) {
|
|
165
|
-
console.error("Error: path is required.");
|
|
166
|
-
process.exit(1);
|
|
167
|
-
}
|
|
168
|
-
const client = getClient();
|
|
169
|
-
const s = await client.resolveSpace(space);
|
|
170
|
-
await client.rm(s.id, path);
|
|
171
|
-
console.log(`Deleted: ${path} (recoverable from trash for 30 days)`);
|
|
172
|
-
});
|
|
173
|
-
program2.command("mv").description("Rename/move \u2014 docz mv <space>:<from> <to>").argument("<target>", "space:old-path").argument("<to>", "new-path").action(async (target, to) => {
|
|
174
|
-
const { space, path: from } = parseTarget([target]);
|
|
175
|
-
if (!from) {
|
|
176
|
-
console.error("Error: source path is required.");
|
|
177
|
-
process.exit(1);
|
|
178
|
-
}
|
|
179
|
-
const client = getClient();
|
|
180
|
-
const s = await client.resolveSpace(space);
|
|
181
|
-
await client.mv(s.id, from, to);
|
|
182
|
-
console.log(`Moved: ${from} \u2192 ${to}`);
|
|
183
|
-
});
|
|
184
|
-
program2.command("log").description("Show change history \u2014 docz log <space>[:<path>]").argument("<target...>").action(async (args) => {
|
|
185
|
-
const { space, path } = parseTarget(args);
|
|
186
|
-
const client = getClient();
|
|
187
|
-
const s = await client.resolveSpace(space);
|
|
188
|
-
const logs = await client.log(s.id, path || void 0);
|
|
189
|
-
if (logs.length === 0) {
|
|
190
|
-
console.log("No history.");
|
|
191
|
-
return;
|
|
192
|
-
}
|
|
193
|
-
for (const l of logs) {
|
|
194
|
-
console.log(`${l.hash.substring(0, 7)} ${l.date} ${l.message}`);
|
|
195
|
-
}
|
|
196
|
-
});
|
|
197
|
-
program2.command("trash").description("Show deleted files \u2014 docz trash <space>").argument("<space>").action(async (spaceName) => {
|
|
198
|
-
const client = getClient();
|
|
199
|
-
const s = await client.resolveSpace(spaceName);
|
|
200
|
-
const items = await client.trash(s.id);
|
|
201
|
-
if (items.length === 0) {
|
|
202
|
-
console.log("Trash is empty.");
|
|
203
|
-
return;
|
|
204
|
-
}
|
|
205
|
-
for (const t of items) {
|
|
206
|
-
console.log(
|
|
207
|
-
`${t.path} deleted ${t.deleted_at} ${t.commit.substring(0, 7)}`
|
|
208
|
-
);
|
|
209
|
-
}
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
// src/index.ts
|
|
214
8
|
var program = new Command();
|
|
215
9
|
program.name("docz").description("DocSync CLI \u2014 read and write company documents").version("0.1.1");
|
|
216
10
|
registerCommands(program);
|
|
217
11
|
program.command("mcp").description("Start MCP stdio server for AI agent integration").action(async () => {
|
|
218
|
-
const { startMcpServer } = await import("./mcp-
|
|
12
|
+
const { startMcpServer } = await import("./mcp-PAPGDW5K.js");
|
|
219
13
|
await startMcpServer();
|
|
220
14
|
});
|
|
221
15
|
program.parse();
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/commands.ts"],"sourcesContent":["import { Command } from 'commander';\nimport { registerCommands } from './commands.js';\n\nconst program = new Command();\n\nprogram\n .name('docz')\n .description('DocSync CLI — read and write company documents')\n .version('0.1.1');\n\nregisterCommands(program);\n\nprogram\n .command('mcp')\n .description('Start MCP stdio server for AI agent integration')\n .action(async () => {\n const { startMcpServer } = await import('./mcp.js');\n await startMcpServer();\n });\n\nprogram.parse();\n","/**\n * CLI Commands\n */\n\nimport { readFileSync } from 'node:fs';\nimport { basename, dirname } from 'node:path';\nimport type { Command } from 'commander';\nimport { DocSyncClient } from './client.js';\nimport { getBaseUrl, getConfigPath, getToken, saveConfig } from './config.js';\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nfunction getClient(): DocSyncClient {\n const token = getToken();\n if (!token) {\n console.error(\n 'Error: No token configured.\\n' +\n 'Run `docz login` or set DOCSYNC_API_TOKEN environment variable.'\n );\n process.exit(1);\n }\n return new DocSyncClient(getBaseUrl(), token);\n}\n\n/** Parse \"space:path\" or \"space path\" format */\nfunction parseTarget(args: string[]): { space: string; path: string } {\n if (args.length === 0) {\n console.error(\n 'Error: space is required. Usage: docz <cmd> <space>[:<path>]'\n );\n process.exit(1);\n }\n const first = args[0];\n if (first.includes(':')) {\n const [space, ...rest] = first.split(':');\n return { space, path: rest.join(':') };\n }\n return { space: first, path: args.slice(1).join(' ') };\n}\n\nfunction formatSize(bytes: number): string {\n if (bytes < 1024) return `${bytes} B`;\n if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;\n return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;\n}\n\n// ---------------------------------------------------------------------------\n// Commands\n// ---------------------------------------------------------------------------\n\nexport function registerCommands(program: Command): void {\n // --- login ---\n program\n .command('login')\n .description('Configure DocSync credentials')\n .option('-u, --url <url>', 'DocSync server URL')\n .option('-t, --token <token>', 'API token')\n .action(async (opts) => {\n const url = opts.url ?? getBaseUrl();\n const token = opts.token;\n if (!token) {\n console.error(\n 'Error: --token is required.\\n' +\n 'Get one at: ' +\n url +\n ' → Settings → API Tokens'\n );\n process.exit(1);\n }\n // Verify token\n const client = new DocSyncClient(url, token);\n try {\n const user = await client.me();\n saveConfig(url, token);\n console.log(`Logged in as ${user.name} (${user.email})`);\n console.log(`Config saved to ${getConfigPath()}`);\n } catch (err) {\n console.error(\n `Error: ${err instanceof Error ? err.message : String(err)}`\n );\n process.exit(1);\n }\n });\n\n // --- whoami ---\n program\n .command('whoami')\n .description('Show current user')\n .action(async () => {\n const client = getClient();\n const user = await client.me();\n console.log(`${user.name} (${user.email})`);\n });\n\n // --- spaces ---\n program\n .command('spaces')\n .description('List all accessible spaces')\n .action(async () => {\n const client = getClient();\n const spaces = await client.listSpaces();\n for (const s of spaces) {\n const tag = s.is_private ? 'private' : 'team';\n console.log(`${s.name}\\t${tag}\\t${s.member_count} members\\t${s.id}`);\n }\n });\n\n // --- ls ---\n program\n .command('ls')\n .description('List files — docz ls <space>[:<path>]')\n .argument('<target...>')\n .action(async (args: string[]) => {\n const { space, path } = parseTarget(args);\n const client = getClient();\n const s = await client.resolveSpace(space);\n const entries = await client.ls(s.id, path);\n if (entries.length === 0) {\n console.log('(empty)');\n return;\n }\n for (const e of entries) {\n if (e.type === 'tree') {\n console.log(`${e.name}/`);\n } else {\n console.log(`${e.name}\\t${formatSize(e.size)}`);\n }\n }\n });\n\n // --- cat ---\n program\n .command('cat')\n .description('Read file content — docz cat <space>:<path>')\n .argument('<target...>')\n .action(async (args: string[]) => {\n const { space, path } = parseTarget(args);\n if (!path) {\n console.error(\n 'Error: file path is required. Usage: docz cat <space>:<path>'\n );\n process.exit(1);\n }\n const client = getClient();\n const s = await client.resolveSpace(space);\n const content = await client.cat(s.id, path);\n process.stdout.write(content);\n });\n\n // --- upload ---\n program\n .command('upload')\n .description('Upload file — docz upload <local-file> <space>[:<dir>]')\n .argument('<file>', 'Local file to upload')\n .argument('<target...>')\n .action(async (file: string, args: string[]) => {\n const { space, path: dir } = parseTarget(args);\n const client = getClient();\n const s = await client.resolveSpace(space);\n const content = readFileSync(file);\n const filename = basename(file);\n const targetDir = dir || '';\n const result = await client.upload(s.id, targetDir, filename, content);\n console.log(`Uploaded: ${result.path}`);\n });\n\n // --- write ---\n program\n .command('write')\n .description('Write content to file — docz write <space>:<path> <content>')\n .argument('<target>', 'space:dir/filename.md')\n .argument('<content>', 'File content (or - for stdin)')\n .action(async (target: string, content: string) => {\n const { space, path } = parseTarget([target]);\n if (!path) {\n console.error(\n 'Error: path is required. Usage: docz write <space>:<dir/filename> <content>'\n );\n process.exit(1);\n }\n const client = getClient();\n const s = await client.resolveSpace(space);\n const filename = basename(path);\n const dir = dirname(path);\n let body: string;\n if (content === '-') {\n // Read from stdin\n const chunks: Buffer[] = [];\n for await (const chunk of process.stdin) {\n chunks.push(chunk as Buffer);\n }\n body = Buffer.concat(chunks).toString('utf-8');\n } else {\n body = content;\n }\n const result = await client.upload(\n s.id,\n dir === '.' ? '' : dir,\n filename,\n body\n );\n console.log(`Written: ${result.path}`);\n });\n\n // --- mkdir ---\n program\n .command('mkdir')\n .description('Create folder — docz mkdir <space>:<path>')\n .argument('<target...>')\n .action(async (args: string[]) => {\n const { space, path } = parseTarget(args);\n if (!path) {\n console.error('Error: path is required.');\n process.exit(1);\n }\n const client = getClient();\n const s = await client.resolveSpace(space);\n await client.mkdir(s.id, path);\n console.log(`Created: ${path}`);\n });\n\n // --- rm ---\n program\n .command('rm')\n .description('Delete file/folder — docz rm <space>:<path>')\n .argument('<target...>')\n .action(async (args: string[]) => {\n const { space, path } = parseTarget(args);\n if (!path) {\n console.error('Error: path is required.');\n process.exit(1);\n }\n const client = getClient();\n const s = await client.resolveSpace(space);\n await client.rm(s.id, path);\n console.log(`Deleted: ${path} (recoverable from trash for 30 days)`);\n });\n\n // --- mv ---\n program\n .command('mv')\n .description('Rename/move — docz mv <space>:<from> <to>')\n .argument('<target>', 'space:old-path')\n .argument('<to>', 'new-path')\n .action(async (target: string, to: string) => {\n const { space, path: from } = parseTarget([target]);\n if (!from) {\n console.error('Error: source path is required.');\n process.exit(1);\n }\n const client = getClient();\n const s = await client.resolveSpace(space);\n await client.mv(s.id, from, to);\n console.log(`Moved: ${from} → ${to}`);\n });\n\n // --- log ---\n program\n .command('log')\n .description('Show change history — docz log <space>[:<path>]')\n .argument('<target...>')\n .action(async (args: string[]) => {\n const { space, path } = parseTarget(args);\n const client = getClient();\n const s = await client.resolveSpace(space);\n const logs = await client.log(s.id, path || undefined);\n if (logs.length === 0) {\n console.log('No history.');\n return;\n }\n for (const l of logs) {\n console.log(`${l.hash.substring(0, 7)} ${l.date} ${l.message}`);\n }\n });\n\n // --- trash ---\n program\n .command('trash')\n .description('Show deleted files — docz trash <space>')\n .argument('<space>')\n .action(async (spaceName: string) => {\n const client = getClient();\n const s = await client.resolveSpace(spaceName);\n const items = await client.trash(s.id);\n if (items.length === 0) {\n console.log('Trash is empty.');\n return;\n }\n for (const t of items) {\n console.log(\n `${t.path}\\tdeleted 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OAAO,EAAE;AAAA,IAClE;AAAA,EACF,CAAC;AAGH,EAAAA,SACG,QAAQ,OAAO,EACf,YAAY,8CAAyC,EACrD,SAAS,SAAS,EAClB,OAAO,OAAO,cAAsB;AACnC,UAAM,SAAS,UAAU;AACzB,UAAM,IAAI,MAAM,OAAO,aAAa,SAAS;AAC7C,UAAM,QAAQ,MAAM,OAAO,MAAM,EAAE,EAAE;AACrC,QAAI,MAAM,WAAW,GAAG;AACtB,cAAQ,IAAI,iBAAiB;AAC7B;AAAA,IACF;AACA,eAAW,KAAK,OAAO;AACrB,cAAQ;AAAA,QACN,GAAG,EAAE,IAAI,YAAa,EAAE,UAAU,IAAK,EAAE,OAAO,UAAU,GAAG,CAAC,CAAC;AAAA,MACjE;AAAA,IACF;AAAA,EACF,CAAC;AACL;;;ADrSA,IAAM,UAAU,IAAI,QAAQ;AAE5B,QACG,KAAK,MAAM,EACX,YAAY,qDAAgD,EAC5D,QAAQ,OAAO;AAElB,iBAAiB,OAAO;AAExB,QACG,QAAQ,KAAK,EACb,YAAY,iDAAiD,EAC7D,OAAO,YAAY;AAClB,QAAM,EAAE,eAAe,IAAI,MAAM,OAAO,mBAAU;AAClD,QAAM,eAAe;AACvB,CAAC;AAEH,QAAQ,MAAM;","names":["program"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { Command } from 'commander';\nimport { registerCommands } from './commands.js';\n\nconst program = new Command();\n\nprogram\n .name('docz')\n .description('DocSync CLI — read and write company documents')\n .version('0.1.1');\n\nregisterCommands(program);\n\nprogram\n .command('mcp')\n .description('Start MCP stdio server for AI agent integration')\n .action(async () => {\n const { startMcpServer } = await import('./mcp.js');\n await startMcpServer();\n });\n\nprogram.parse();\n"],"mappings":";;;;;;AAAA,SAAS,eAAe;AAGxB,IAAM,UAAU,IAAI,QAAQ;AAE5B,QACG,KAAK,MAAM,EACX,YAAY,qDAAgD,EAC5D,QAAQ,OAAO;AAElB,iBAAiB,OAAO;AAExB,QACG,QAAQ,KAAK,EACb,YAAY,iDAAiD,EAC7D,OAAO,YAAY;AAClB,QAAM,EAAE,eAAe,IAAI,MAAM,OAAO,mBAAU;AAClD,QAAM,eAAe;AACvB,CAAC;AAEH,QAAQ,MAAM;","names":[]}
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
import {
|
|
3
3
|
DocSyncClient,
|
|
4
4
|
getBaseUrl,
|
|
5
|
-
getToken
|
|
6
|
-
|
|
5
|
+
getToken,
|
|
6
|
+
parseExpires
|
|
7
|
+
} from "./chunk-WH5WLKFJ.js";
|
|
7
8
|
|
|
8
9
|
// src/mcp.ts
|
|
9
10
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
@@ -46,18 +47,18 @@ function fail(err) {
|
|
|
46
47
|
}
|
|
47
48
|
async function startMcpServer() {
|
|
48
49
|
const server = new Server(
|
|
49
|
-
{ name: "
|
|
50
|
+
{ name: "docz-mcp", version: "0.5.0" },
|
|
50
51
|
{ capabilities: { tools: {} } }
|
|
51
52
|
);
|
|
52
53
|
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
53
54
|
tools: [
|
|
54
55
|
{
|
|
55
|
-
name: "
|
|
56
|
+
name: "docz_list_spaces",
|
|
56
57
|
description: "\u5217\u51FA\u6240\u6709\u53EF\u8BBF\u95EE\u7684 DocSync Space\uFF08\u4E2A\u4EBA\u7A7A\u95F4\u548C\u56E2\u961F\u7A7A\u95F4\uFF09",
|
|
57
58
|
inputSchema: { type: "object", properties: {} }
|
|
58
59
|
},
|
|
59
60
|
{
|
|
60
|
-
name: "
|
|
61
|
+
name: "docz_list_files",
|
|
61
62
|
description: "\u5217\u51FA DocSync Space \u4E2D\u6307\u5B9A\u76EE\u5F55\u7684\u6587\u4EF6\u548C\u6587\u4EF6\u5939",
|
|
62
63
|
inputSchema: {
|
|
63
64
|
type: "object",
|
|
@@ -76,7 +77,7 @@ async function startMcpServer() {
|
|
|
76
77
|
}
|
|
77
78
|
},
|
|
78
79
|
{
|
|
79
|
-
name: "
|
|
80
|
+
name: "docz_read_file",
|
|
80
81
|
description: "\u8BFB\u53D6 DocSync \u6587\u4EF6\u5185\u5BB9\uFF08Markdown\u3001CSV\u3001HTML \u7B49\u6587\u672C\u6587\u4EF6\uFF09",
|
|
81
82
|
inputSchema: {
|
|
82
83
|
type: "object",
|
|
@@ -91,7 +92,7 @@ async function startMcpServer() {
|
|
|
91
92
|
}
|
|
92
93
|
},
|
|
93
94
|
{
|
|
94
|
-
name: "
|
|
95
|
+
name: "docz_upload_file",
|
|
95
96
|
description: "\u4E0A\u4F20/\u521B\u5EFA\u6587\u4EF6\u5230 DocSync Space",
|
|
96
97
|
inputSchema: {
|
|
97
98
|
type: "object",
|
|
@@ -114,7 +115,7 @@ async function startMcpServer() {
|
|
|
114
115
|
}
|
|
115
116
|
},
|
|
116
117
|
{
|
|
117
|
-
name: "
|
|
118
|
+
name: "docz_mkdir",
|
|
118
119
|
description: "\u5728 DocSync Space \u4E2D\u521B\u5EFA\u6587\u4EF6\u5939",
|
|
119
120
|
inputSchema: {
|
|
120
121
|
type: "object",
|
|
@@ -132,7 +133,7 @@ async function startMcpServer() {
|
|
|
132
133
|
}
|
|
133
134
|
},
|
|
134
135
|
{
|
|
135
|
-
name: "
|
|
136
|
+
name: "docz_delete",
|
|
136
137
|
description: "\u5220\u9664\u6587\u4EF6\u6216\u6587\u4EF6\u5939\uFF08\u8FDB\u5165\u56DE\u6536\u7AD9\uFF0C30 \u5929\u5185\u53EF\u6062\u590D\uFF09",
|
|
137
138
|
inputSchema: {
|
|
138
139
|
type: "object",
|
|
@@ -147,7 +148,7 @@ async function startMcpServer() {
|
|
|
147
148
|
}
|
|
148
149
|
},
|
|
149
150
|
{
|
|
150
|
-
name: "
|
|
151
|
+
name: "docz_file_history",
|
|
151
152
|
description: "\u67E5\u770B\u6587\u4EF6\u7684\u53D8\u66F4\u5386\u53F2\uFF08\u57FA\u4E8E Git \u7248\u672C\u63A7\u5236\uFF09",
|
|
152
153
|
inputSchema: {
|
|
153
154
|
type: "object",
|
|
@@ -160,6 +161,81 @@ async function startMcpServer() {
|
|
|
160
161
|
},
|
|
161
162
|
required: ["space"]
|
|
162
163
|
}
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
name: "docz_share_create",
|
|
167
|
+
description: "\u521B\u5EFA\u6587\u4EF6\u5206\u4EAB\u94FE\u63A5",
|
|
168
|
+
inputSchema: {
|
|
169
|
+
type: "object",
|
|
170
|
+
properties: {
|
|
171
|
+
space: { type: "string", description: "Space \u540D\u79F0\u6216 ID" },
|
|
172
|
+
path: { type: "string", description: "\u6587\u4EF6\u8DEF\u5F84" },
|
|
173
|
+
expires: { type: "string", description: "\u8FC7\u671F\u65F6\u95F4\uFF0C\u5982 7d, 24h" },
|
|
174
|
+
userIds: { type: "array", items: { type: "string" }, description: "\u53EF\u89C1\u7528\u6237 ID \u5217\u8868" },
|
|
175
|
+
groupIds: { type: "array", items: { type: "string" }, description: "\u53EF\u89C1\u7EC4 ID \u5217\u8868" }
|
|
176
|
+
},
|
|
177
|
+
required: ["space", "path"]
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
name: "docz_share_list",
|
|
182
|
+
description: "\u5217\u51FA\u7A7A\u95F4\u7684\u5206\u4EAB\u94FE\u63A5",
|
|
183
|
+
inputSchema: {
|
|
184
|
+
type: "object",
|
|
185
|
+
properties: {
|
|
186
|
+
space: { type: "string", description: "Space \u540D\u79F0\u6216 ID" },
|
|
187
|
+
filePath: { type: "string", description: "\u6309\u6587\u4EF6\u8DEF\u5F84\u8FC7\u6EE4" }
|
|
188
|
+
},
|
|
189
|
+
required: ["space"]
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
name: "docz_share_read",
|
|
194
|
+
description: "\u901A\u8FC7\u5206\u4EAB token \u8BFB\u53D6\u6587\u4EF6\u5185\u5BB9",
|
|
195
|
+
inputSchema: {
|
|
196
|
+
type: "object",
|
|
197
|
+
properties: {
|
|
198
|
+
token: { type: "string", description: "\u5206\u4EAB\u94FE\u63A5 token" }
|
|
199
|
+
},
|
|
200
|
+
required: ["token"]
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
name: "docz_share_info",
|
|
205
|
+
description: "\u67E5\u770B\u5206\u4EAB\u94FE\u63A5\u4FE1\u606F",
|
|
206
|
+
inputSchema: {
|
|
207
|
+
type: "object",
|
|
208
|
+
properties: {
|
|
209
|
+
token: { type: "string", description: "\u5206\u4EAB\u94FE\u63A5 token" }
|
|
210
|
+
},
|
|
211
|
+
required: ["token"]
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
name: "docz_share_delete",
|
|
216
|
+
description: "\u5220\u9664\u5206\u4EAB\u94FE\u63A5",
|
|
217
|
+
inputSchema: {
|
|
218
|
+
type: "object",
|
|
219
|
+
properties: {
|
|
220
|
+
space: { type: "string", description: "Space \u540D\u79F0\u6216 ID" },
|
|
221
|
+
linkId: { type: "string", description: "\u5206\u4EAB\u94FE\u63A5 ID" }
|
|
222
|
+
},
|
|
223
|
+
required: ["space", "linkId"]
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
name: "docz_diff",
|
|
228
|
+
description: "\u67E5\u770B\u6587\u4EF6\u6216 Space \u7684\u53D8\u66F4 diff",
|
|
229
|
+
inputSchema: {
|
|
230
|
+
type: "object",
|
|
231
|
+
properties: {
|
|
232
|
+
space: { type: "string", description: "Space \u540D\u79F0\u6216 ID" },
|
|
233
|
+
path: { type: "string", description: "\u6587\u4EF6\u8DEF\u5F84\uFF08\u7A7A\u5219\u8FD4\u56DE\u53D8\u66F4\u6587\u4EF6\u5217\u8868\uFF09" },
|
|
234
|
+
to: { type: "string", description: "\u76EE\u6807 commit hash" },
|
|
235
|
+
from: { type: "string", description: "\u8D77\u59CB commit hash\uFF08\u9ED8\u8BA4 to^\uFF09" }
|
|
236
|
+
},
|
|
237
|
+
required: ["space", "to"]
|
|
238
|
+
}
|
|
163
239
|
}
|
|
164
240
|
]
|
|
165
241
|
}));
|
|
@@ -168,14 +244,14 @@ async function startMcpServer() {
|
|
|
168
244
|
try {
|
|
169
245
|
const client = getClient();
|
|
170
246
|
switch (request.params.name) {
|
|
171
|
-
case "
|
|
247
|
+
case "docz_list_spaces": {
|
|
172
248
|
const spaces = await client.listSpaces();
|
|
173
249
|
const lines = spaces.map(
|
|
174
250
|
(s) => `${s.name} (${s.is_private ? "\u79C1\u6709" : "\u56E2\u961F"}, ${s.member_count} \u4EBA) id=${s.id}`
|
|
175
251
|
);
|
|
176
252
|
return ok(lines.join("\n"));
|
|
177
253
|
}
|
|
178
|
-
case "
|
|
254
|
+
case "docz_list_files": {
|
|
179
255
|
const sid = await resolveSpaceId(client, String(args.space));
|
|
180
256
|
const entries = await client.ls(sid, String(args.path ?? ""));
|
|
181
257
|
if (entries.length === 0) return ok("\uFF08\u7A7A\u76EE\u5F55\uFF09");
|
|
@@ -186,12 +262,12 @@ async function startMcpServer() {
|
|
|
186
262
|
});
|
|
187
263
|
return ok(lines.join("\n"));
|
|
188
264
|
}
|
|
189
|
-
case "
|
|
265
|
+
case "docz_read_file": {
|
|
190
266
|
const sid = await resolveSpaceId(client, String(args.space));
|
|
191
267
|
const content = await client.cat(sid, String(args.path));
|
|
192
268
|
return ok(content);
|
|
193
269
|
}
|
|
194
|
-
case "
|
|
270
|
+
case "docz_upload_file": {
|
|
195
271
|
const sid = await resolveSpaceId(client, String(args.space));
|
|
196
272
|
const result = await client.upload(
|
|
197
273
|
sid,
|
|
@@ -201,17 +277,17 @@ async function startMcpServer() {
|
|
|
201
277
|
);
|
|
202
278
|
return ok(`\u5DF2\u4E0A\u4F20: ${result.path}`);
|
|
203
279
|
}
|
|
204
|
-
case "
|
|
280
|
+
case "docz_mkdir": {
|
|
205
281
|
const sid = await resolveSpaceId(client, String(args.space));
|
|
206
282
|
await client.mkdir(sid, String(args.path));
|
|
207
283
|
return ok(`\u5DF2\u521B\u5EFA: ${args.path}`);
|
|
208
284
|
}
|
|
209
|
-
case "
|
|
285
|
+
case "docz_delete": {
|
|
210
286
|
const sid = await resolveSpaceId(client, String(args.space));
|
|
211
287
|
await client.rm(sid, String(args.path));
|
|
212
288
|
return ok(`\u5DF2\u5220\u9664: ${args.path}\uFF0830 \u5929\u5185\u53EF\u4ECE\u56DE\u6536\u7AD9\u6062\u590D\uFF09`);
|
|
213
289
|
}
|
|
214
|
-
case "
|
|
290
|
+
case "docz_file_history": {
|
|
215
291
|
const sid = await resolveSpaceId(client, String(args.space));
|
|
216
292
|
const logs = await client.log(
|
|
217
293
|
sid,
|
|
@@ -219,10 +295,62 @@ async function startMcpServer() {
|
|
|
219
295
|
);
|
|
220
296
|
if (logs.length === 0) return ok("\u6CA1\u6709\u53D8\u66F4\u5386\u53F2\u3002");
|
|
221
297
|
const lines = logs.map(
|
|
222
|
-
(l) => `${l.hash
|
|
298
|
+
(l) => `${l.hash} ${l.date} ${l.message}`
|
|
223
299
|
);
|
|
224
300
|
return ok(lines.join("\n"));
|
|
225
301
|
}
|
|
302
|
+
case "docz_share_create": {
|
|
303
|
+
const sharePath = String(args.path ?? "");
|
|
304
|
+
if (!sharePath) return fail("path is required");
|
|
305
|
+
const sid = await resolveSpaceId(client, String(args.space));
|
|
306
|
+
const opts = {};
|
|
307
|
+
if (args.expires) opts.expiresAt = parseExpires(String(args.expires));
|
|
308
|
+
if (args.userIds) opts.userIds = args.userIds;
|
|
309
|
+
if (args.groupIds) opts.groupIds = args.groupIds;
|
|
310
|
+
const link = await client.createShareLink(sid, sharePath, opts);
|
|
311
|
+
return ok(`\u5DF2\u521B\u5EFA\u5206\u4EAB\u94FE\u63A5:
|
|
312
|
+
token: ${link.token}
|
|
313
|
+
url: ${getBaseUrl()}/share/${link.token}
|
|
314
|
+
\u8FC7\u671F: ${link.expires_at ?? "\u6C38\u4E0D"}`);
|
|
315
|
+
}
|
|
316
|
+
case "docz_share_list": {
|
|
317
|
+
const sid = await resolveSpaceId(client, String(args.space));
|
|
318
|
+
const links = await client.listShareLinks(sid, args.filePath ? String(args.filePath) : void 0);
|
|
319
|
+
if (links.length === 0) return ok("\u6CA1\u6709\u5206\u4EAB\u94FE\u63A5\u3002");
|
|
320
|
+
const lines = links.map(
|
|
321
|
+
(l) => `${l.token} ${l.file_path} \u8FC7\u671F: ${l.expires_at ?? "\u6C38\u4E0D"} \u521B\u5EFA\u8005: ${l.created_by_name ?? l.created_by_email ?? l.created_by}`
|
|
322
|
+
);
|
|
323
|
+
return ok(lines.join("\n"));
|
|
324
|
+
}
|
|
325
|
+
case "docz_share_read": {
|
|
326
|
+
const content = await client.getSharedFile(String(args.token));
|
|
327
|
+
return ok(content);
|
|
328
|
+
}
|
|
329
|
+
case "docz_share_info": {
|
|
330
|
+
const info = await client.getSharedFileInfo(String(args.token));
|
|
331
|
+
return ok(`\u6587\u4EF6: ${info.file_path}
|
|
332
|
+
Space: ${info.space_name}
|
|
333
|
+
\u5206\u4EAB\u8005: ${info.created_by_name}
|
|
334
|
+
\u8FC7\u671F: ${info.expires_at ?? "\u6C38\u4E0D"}`);
|
|
335
|
+
}
|
|
336
|
+
case "docz_share_delete": {
|
|
337
|
+
const sid = await resolveSpaceId(client, String(args.space));
|
|
338
|
+
await client.deleteShareLink(sid, String(args.linkId));
|
|
339
|
+
return ok(`\u5DF2\u5220\u9664\u5206\u4EAB\u94FE\u63A5: ${args.linkId}`);
|
|
340
|
+
}
|
|
341
|
+
case "docz_diff": {
|
|
342
|
+
const sid = await resolveSpaceId(client, String(args.space));
|
|
343
|
+
const path = args.path ? String(args.path) : "";
|
|
344
|
+
const from = args.from ? String(args.from) : void 0;
|
|
345
|
+
if (path) {
|
|
346
|
+
const result2 = await client.diffFile(sid, path, String(args.to), from);
|
|
347
|
+
return ok(result2.diff || "\u6CA1\u6709\u53D8\u66F4\u3002");
|
|
348
|
+
}
|
|
349
|
+
const result = await client.diffSummary(sid, String(args.to), from);
|
|
350
|
+
if (result.files.length === 0) return ok("\u6CA1\u6709\u53D8\u66F4\u3002");
|
|
351
|
+
const lines = result.files.map((f) => `${f.status} ${f.path}`);
|
|
352
|
+
return ok(lines.join("\n"));
|
|
353
|
+
}
|
|
226
354
|
default:
|
|
227
355
|
return fail(`Unknown tool: ${request.params.name}`);
|
|
228
356
|
}
|
|
@@ -236,4 +364,4 @@ async function startMcpServer() {
|
|
|
236
364
|
export {
|
|
237
365
|
startMcpServer
|
|
238
366
|
};
|
|
239
|
-
//# sourceMappingURL=mcp-
|
|
367
|
+
//# sourceMappingURL=mcp-PAPGDW5K.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/mcp.ts"],"sourcesContent":["/**\n * DocSync MCP Server (stdio transport)\n *\n * Usage:\n * docz mcp\n *\n * 环境变量:\n * DOCSYNC_API_TOKEN — 必须\n * DOCSYNC_BASE_URL — 可选,默认 https://docz.zhenguanyu.com\n */\n\nimport { Server } from '@modelcontextprotocol/sdk/server/index.js';\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport {\n CallToolRequestSchema,\n ListToolsRequestSchema,\n} from '@modelcontextprotocol/sdk/types.js';\nimport { DocSyncClient } from './client.js';\nimport { parseExpires } from './commands.js';\nimport { getBaseUrl, getToken } from './config.js';\n\nfunction getClient(): DocSyncClient {\n const token = getToken();\n if (!token) {\n throw new Error(\n 'DOCSYNC_API_TOKEN not set. Run `docz login --token <token>` or set the env var.'\n );\n }\n return new DocSyncClient(getBaseUrl(), token);\n}\n\nasync function resolveSpaceId(\n client: DocSyncClient,\n nameOrId: string\n): Promise<string> {\n const space = await client.resolveSpace(nameOrId);\n return space.id;\n}\n\nfunction formatSize(bytes: number): string {\n if (bytes < 1024) return `${bytes} B`;\n if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;\n return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;\n}\n\nfunction ok(text: string) {\n return { content: [{ type: 'text' as const, text }] };\n}\n\nfunction fail(err: unknown) {\n return {\n content: [\n {\n type: 'text' as const,\n text: `Error: ${err instanceof Error ? err.message : String(err)}`,\n },\n ],\n isError: true,\n };\n}\n\nexport async function startMcpServer(): Promise<void> {\n const server = new Server(\n { name: 'docz-mcp', version: '0.5.0' },\n { capabilities: { tools: {} } }\n );\n\n server.setRequestHandler(ListToolsRequestSchema, async () => ({\n tools: [\n {\n name: 'docz_list_spaces',\n description: '列出所有可访问的 DocSync Space(个人空间和团队空间)',\n inputSchema: { type: 'object' as const, properties: {} },\n },\n {\n name: 'docz_list_files',\n description: '列出 DocSync Space 中指定目录的文件和文件夹',\n inputSchema: {\n type: 'object' as const,\n properties: {\n space: {\n type: 'string',\n description: 'Space 名称或 ID',\n },\n path: {\n type: 'string',\n description: '目录路径,空字符串表示根目录',\n default: '',\n },\n },\n required: ['space'],\n },\n },\n {\n name: 'docz_read_file',\n description: '读取 DocSync 文件内容(Markdown、CSV、HTML 等文本文件)',\n inputSchema: {\n type: 'object' as const,\n properties: {\n space: {\n type: 'string',\n description: 'Space 名称或 ID',\n },\n path: { type: 'string', description: '文件路径' },\n },\n required: ['space', 'path'],\n },\n },\n {\n name: 'docz_upload_file',\n description: '上传/创建文件到 DocSync Space',\n inputSchema: {\n type: 'object' as const,\n properties: {\n space: {\n type: 'string',\n description: 'Space 名称或 ID',\n },\n path: {\n type: 'string',\n description: '目标目录路径(如 reports)',\n },\n filename: {\n type: 'string',\n description: '文件名(如 summary.md)',\n },\n content: { type: 'string', description: '文件内容' },\n },\n required: ['space', 'filename', 'content'],\n },\n },\n {\n name: 'docz_mkdir',\n description: '在 DocSync Space 中创建文件夹',\n inputSchema: {\n type: 'object' as const,\n properties: {\n space: {\n type: 'string',\n description: 'Space 名称或 ID',\n },\n path: {\n type: 'string',\n description: '要创建的文件夹路径',\n },\n },\n required: ['space', 'path'],\n },\n },\n {\n name: 'docz_delete',\n description: '删除文件或文件夹(进入回收站,30 天内可恢复)',\n inputSchema: {\n type: 'object' as const,\n properties: {\n space: {\n type: 'string',\n description: 'Space 名称或 ID',\n },\n path: { type: 'string', description: '要删除的路径' },\n },\n required: ['space', 'path'],\n },\n },\n {\n name: 'docz_file_history',\n description: '查看文件的变更历史(基于 Git 版本控制)',\n inputSchema: {\n type: 'object' as const,\n properties: {\n space: {\n type: 'string',\n description: 'Space 名称或 ID',\n },\n path: { type: 'string', description: '文件路径' },\n },\n required: ['space'],\n },\n },\n {\n name: 'docz_share_create',\n description: '创建文件分享链接',\n inputSchema: {\n type: 'object' as const,\n properties: {\n space: { type: 'string', description: 'Space 名称或 ID' },\n path: { type: 'string', description: '文件路径' },\n expires: { type: 'string', description: '过期时间,如 7d, 24h' },\n userIds: { type: 'array', items: { type: 'string' }, description: '可见用户 ID 列表' },\n groupIds: { type: 'array', items: { type: 'string' }, description: '可见组 ID 列表' },\n },\n required: ['space', 'path'],\n },\n },\n {\n name: 'docz_share_list',\n description: '列出空间的分享链接',\n inputSchema: {\n type: 'object' as const,\n properties: {\n space: { type: 'string', description: 'Space 名称或 ID' },\n filePath: { type: 'string', description: '按文件路径过滤' },\n },\n required: ['space'],\n },\n },\n {\n name: 'docz_share_read',\n description: '通过分享 token 读取文件内容',\n inputSchema: {\n type: 'object' as const,\n properties: {\n token: { type: 'string', description: '分享链接 token' },\n },\n required: ['token'],\n },\n },\n {\n name: 'docz_share_info',\n description: '查看分享链接信息',\n inputSchema: {\n type: 'object' as const,\n properties: {\n token: { type: 'string', description: '分享链接 token' },\n },\n required: ['token'],\n },\n },\n {\n name: 'docz_share_delete',\n description: '删除分享链接',\n inputSchema: {\n type: 'object' as const,\n properties: {\n space: { type: 'string', description: 'Space 名称或 ID' },\n linkId: { type: 'string', description: '分享链接 ID' },\n },\n required: ['space', 'linkId'],\n },\n },\n {\n name: 'docz_diff',\n description: '查看文件或 Space 的变更 diff',\n inputSchema: {\n type: 'object' as const,\n properties: {\n space: { type: 'string', description: 'Space 名称或 ID' },\n path: { type: 'string', description: '文件路径(空则返回变更文件列表)' },\n to: { type: 'string', description: '目标 commit hash' },\n from: { type: 'string', description: '起始 commit hash(默认 to^)' },\n },\n required: ['space', 'to'],\n },\n },\n ],\n }));\n\n server.setRequestHandler(CallToolRequestSchema, async (request) => {\n const args = (request.params.arguments ?? {}) as Record<string, unknown>;\n\n try {\n const client = getClient();\n\n switch (request.params.name) {\n case 'docz_list_spaces': {\n const spaces = await client.listSpaces();\n const lines = spaces.map(\n (s) =>\n `${s.name} (${s.is_private ? '私有' : '团队'}, ${s.member_count} 人) id=${s.id}`\n );\n return ok(lines.join('\\n'));\n }\n\n case 'docz_list_files': {\n const sid = await resolveSpaceId(client, String(args.space));\n const entries = await client.ls(sid, String(args.path ?? ''));\n if (entries.length === 0) return ok('(空目录)');\n const lines = entries.map((e) => {\n const icon = e.type === 'tree' ? '📁' : '📄';\n const size = e.type === 'blob' ? ` (${formatSize(e.size)})` : '';\n return `${icon} ${e.name}${size}`;\n });\n return ok(lines.join('\\n'));\n }\n\n case 'docz_read_file': {\n const sid = await resolveSpaceId(client, String(args.space));\n const content = await client.cat(sid, String(args.path));\n return ok(content);\n }\n\n case 'docz_upload_file': {\n const sid = await resolveSpaceId(client, String(args.space));\n const result = await client.upload(\n sid,\n String(args.path ?? ''),\n String(args.filename),\n String(args.content)\n );\n return ok(`已上传: ${result.path}`);\n }\n\n case 'docz_mkdir': {\n const sid = await resolveSpaceId(client, String(args.space));\n await client.mkdir(sid, String(args.path));\n return ok(`已创建: ${args.path}`);\n }\n\n case 'docz_delete': {\n const sid = await resolveSpaceId(client, String(args.space));\n await client.rm(sid, String(args.path));\n return ok(`已删除: ${args.path}(30 天内可从回收站恢复)`);\n }\n\n case 'docz_file_history': {\n const sid = await resolveSpaceId(client, String(args.space));\n const logs = await client.log(\n sid,\n args.path ? String(args.path) : undefined\n );\n if (logs.length === 0) return ok('没有变更历史。');\n const lines = logs.map(\n (l) => `${l.hash} ${l.date} ${l.message}`\n );\n return ok(lines.join('\\n'));\n }\n\n case 'docz_share_create': {\n const sharePath = String(args.path ?? '');\n if (!sharePath) return fail('path is required');\n const sid = await resolveSpaceId(client, String(args.space));\n const opts: { expiresAt?: string; userIds?: string[]; groupIds?: string[] } = {};\n if (args.expires) opts.expiresAt = parseExpires(String(args.expires));\n if (args.userIds) opts.userIds = args.userIds as string[];\n if (args.groupIds) opts.groupIds = args.groupIds as string[];\n const link = await client.createShareLink(sid, sharePath, opts);\n return ok(`已创建分享链接:\\ntoken: ${link.token}\\nurl: ${getBaseUrl()}/share/${link.token}\\n过期: ${link.expires_at ?? '永不'}`);\n }\n\n case 'docz_share_list': {\n const sid = await resolveSpaceId(client, String(args.space));\n const links = await client.listShareLinks(sid, args.filePath ? String(args.filePath) : undefined);\n if (links.length === 0) return ok('没有分享链接。');\n const lines = links.map(\n (l) => `${l.token} ${l.file_path} 过期: ${l.expires_at ?? '永不'} 创建者: ${l.created_by_name ?? l.created_by_email ?? l.created_by}`\n );\n return ok(lines.join('\\n'));\n }\n\n case 'docz_share_read': {\n const content = await client.getSharedFile(String(args.token));\n return ok(content);\n }\n\n case 'docz_share_info': {\n const info = await client.getSharedFileInfo(String(args.token));\n return ok(`文件: ${info.file_path}\\nSpace: ${info.space_name}\\n分享者: ${info.created_by_name}\\n过期: ${info.expires_at ?? '永不'}`);\n }\n\n case 'docz_share_delete': {\n const sid = await resolveSpaceId(client, String(args.space));\n await client.deleteShareLink(sid, String(args.linkId));\n return ok(`已删除分享链接: ${args.linkId}`);\n }\n\n case 'docz_diff': {\n const sid = await resolveSpaceId(client, String(args.space));\n const path = args.path ? String(args.path) : '';\n const from = args.from ? String(args.from) : undefined;\n if (path) {\n const result = await client.diffFile(sid, path, String(args.to), from);\n return ok(result.diff || '没有变更。');\n }\n const result = await client.diffSummary(sid, String(args.to), from);\n if (result.files.length === 0) return ok('没有变更。');\n const lines = result.files.map((f) => `${f.status} ${f.path}`);\n return ok(lines.join('\\n'));\n }\n\n default:\n return fail(`Unknown tool: ${request.params.name}`);\n }\n } catch (err) {\n return fail(err);\n }\n });\n\n const transport = new StdioServerTransport();\n await server.connect(transport);\n}\n"],"mappings":";;;;;;;;;AAWA,SAAS,cAAc;AACvB,SAAS,4BAA4B;AACrC;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAKP,SAAS,YAA2B;AAClC,QAAM,QAAQ,SAAS;AACvB,MAAI,CAAC,OAAO;AACV,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SAAO,IAAI,cAAc,WAAW,GAAG,KAAK;AAC9C;AAEA,eAAe,eACb,QACA,UACiB;AACjB,QAAM,QAAQ,MAAM,OAAO,aAAa,QAAQ;AAChD,SAAO,MAAM;AACf;AAEA,SAAS,WAAW,OAAuB;AACzC,MAAI,QAAQ,KAAM,QAAO,GAAG,KAAK;AACjC,MAAI,QAAQ,OAAO,KAAM,QAAO,IAAI,QAAQ,MAAM,QAAQ,CAAC,CAAC;AAC5D,SAAO,IAAI,SAAS,OAAO,OAAO,QAAQ,CAAC,CAAC;AAC9C;AAEA,SAAS,GAAG,MAAc;AACxB,SAAO,EAAE,SAAS,CAAC,EAAE,MAAM,QAAiB,KAAK,CAAC,EAAE;AACtD;AAEA,SAAS,KAAK,KAAc;AAC1B,SAAO;AAAA,IACL,SAAS;AAAA,MACP;AAAA,QACE,MAAM;AAAA,QACN,MAAM,UAAU,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,CAAC;AAAA,MAClE;AAAA,IACF;AAAA,IACA,SAAS;AAAA,EACX;AACF;AAEA,eAAsB,iBAAgC;AACpD,QAAM,SAAS,IAAI;AAAA,IACjB,EAAE,MAAM,YAAY,SAAS,QAAQ;AAAA,IACrC,EAAE,cAAc,EAAE,OAAO,CAAC,EAAE,EAAE;AAAA,EAChC;AAEA,SAAO,kBAAkB,wBAAwB,aAAa;AAAA,IAC5D,OAAO;AAAA,MACL;AAAA,QACE,MAAM;AAAA,QACN,aAAa;AAAA,QACb,aAAa,EAAE,MAAM,UAAmB,YAAY,CA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