@moxt-ai/cli 0.1.6 → 0.1.8
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/README.md +18 -7
- package/dist/index.js +76 -13
- package/dist/index.js.map +1 -1
- package/package.json +1 -5
package/README.md
CHANGED
|
@@ -33,25 +33,37 @@ Workspace management.
|
|
|
33
33
|
moxt workspace list
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
+
### members
|
|
37
|
+
|
|
38
|
+
Manage workspace members.
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
# List all members in a workspace
|
|
42
|
+
moxt members list -w <workspace-id>
|
|
43
|
+
|
|
44
|
+
# Remove members by email (comma-separated)
|
|
45
|
+
moxt members remove -w <workspace-id> <email1>,<email2>
|
|
46
|
+
```
|
|
47
|
+
|
|
36
48
|
### file
|
|
37
49
|
|
|
38
50
|
File operations in workspace.
|
|
39
51
|
|
|
40
52
|
```bash
|
|
41
53
|
# List directory contents
|
|
42
|
-
moxt file list -w <workspace-id> [-p <path>] [-
|
|
54
|
+
moxt file list -w <workspace-id> [-p <path>] [-s <personal|team>]
|
|
43
55
|
|
|
44
56
|
# Read file content
|
|
45
|
-
moxt file read -w <workspace-id> -p <path> [-
|
|
57
|
+
moxt file read -w <workspace-id> -p <path> [-s <personal|team>]
|
|
46
58
|
|
|
47
59
|
# Upload a file
|
|
48
|
-
moxt file put -w <workspace-id> -p <path> -l <local-path> [-
|
|
60
|
+
moxt file put -w <workspace-id> -p <path> -l <local-path> [-s <personal|team>] [-r]
|
|
49
61
|
|
|
50
62
|
# Create a directory
|
|
51
|
-
moxt file mkdir -w <workspace-id> -p <path> [-
|
|
63
|
+
moxt file mkdir -w <workspace-id> -p <path> [-s <personal|team>] [-r]
|
|
52
64
|
|
|
53
65
|
# Delete a file or empty directory
|
|
54
|
-
moxt file del -w <workspace-id> -p <path> [-
|
|
66
|
+
moxt file del -w <workspace-id> -p <path> [-s <personal|team>]
|
|
55
67
|
```
|
|
56
68
|
|
|
57
69
|
#### File command options
|
|
@@ -61,8 +73,7 @@ moxt file del -w <workspace-id> -p <path> [-t | -P]
|
|
|
61
73
|
| `-w, --workspace <id>` | Workspace ID (required) |
|
|
62
74
|
| `-p, --path <path>` | File or directory path |
|
|
63
75
|
| `-l, --local-path <path>` | Local file path (for upload) |
|
|
64
|
-
| `-
|
|
65
|
-
| `-P, --personal` | Access personal space |
|
|
76
|
+
| `-s, --space <type>` | Space type: `personal` or `team` (default: `team`) |
|
|
66
77
|
| `-r, --recursive` | Create parent directories if needed |
|
|
67
78
|
|
|
68
79
|
## Configuration
|
package/dist/index.js
CHANGED
|
@@ -32,7 +32,7 @@ function getApiKey() {
|
|
|
32
32
|
|
|
33
33
|
// src/utils/http.ts
|
|
34
34
|
function getUserAgent() {
|
|
35
|
-
return `moxt-cli/${"0.1.
|
|
35
|
+
return `moxt-cli/${"0.1.8"} (${platform()}/${arch()}) node/${process.versions.node}`;
|
|
36
36
|
}
|
|
37
37
|
async function request(method, path, body) {
|
|
38
38
|
const apiKey = getApiKey();
|
|
@@ -128,8 +128,8 @@ function isBinaryContent(buffer) {
|
|
|
128
128
|
}
|
|
129
129
|
function registerFileCommand(program2) {
|
|
130
130
|
const file = program2.command("file").description("File operations");
|
|
131
|
-
file.command("list").description("List directory contents").requiredOption("-w, --workspace <id>", "Workspace ID").option("-p, --path <path>", "Directory path", "/").option("-
|
|
132
|
-
const space = options.
|
|
131
|
+
file.command("list").description("List directory contents").requiredOption("-w, --workspace <id>", "Workspace ID").option("-p, --path <path>", "Directory path", "/").option("-s, --space <type>", "Space type: personal or team", "team").action(async (options) => {
|
|
132
|
+
const space = options.space;
|
|
133
133
|
startSpinner("Listing files...");
|
|
134
134
|
const response = await httpGet(
|
|
135
135
|
`/workspaces/${options.workspace}/files/list?path=${encodeURIComponent(options.path)}&space=${space}`
|
|
@@ -157,8 +157,8 @@ function registerFileCommand(program2) {
|
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
159
|
});
|
|
160
|
-
file.command("read").description("Read file content").requiredOption("-w, --workspace <id>", "Workspace ID").requiredOption("-p, --path <path>", "File path").option("-
|
|
161
|
-
const space = options.
|
|
160
|
+
file.command("read").description("Read file content").requiredOption("-w, --workspace <id>", "Workspace ID").requiredOption("-p, --path <path>", "File path").option("-s, --space <type>", "Space type: personal or team", "team").action(async (options) => {
|
|
161
|
+
const space = options.space;
|
|
162
162
|
startSpinner("Reading file...");
|
|
163
163
|
const response = await httpGet(
|
|
164
164
|
`/workspaces/${options.workspace}/files/read?path=${encodeURIComponent(options.path)}&space=${space}`
|
|
@@ -181,9 +181,9 @@ function registerFileCommand(program2) {
|
|
|
181
181
|
stopSpinner(true, "Done");
|
|
182
182
|
print(content ?? "");
|
|
183
183
|
});
|
|
184
|
-
file.command("put").description("Upload a file").requiredOption("-w, --workspace <id>", "Workspace ID").requiredOption("-p, --path <path>", "Remote file path").requiredOption("-l, --local-path <localPath>", "Local file path").option("-
|
|
184
|
+
file.command("put").description("Upload a file").requiredOption("-w, --workspace <id>", "Workspace ID").requiredOption("-p, --path <path>", "Remote file path").requiredOption("-l, --local-path <localPath>", "Local file path").option("-s, --space <type>", "Space type: personal or team", "team").option("-r, --recursive", "Create parent directories if needed").action(
|
|
185
185
|
async (options) => {
|
|
186
|
-
const space = options.
|
|
186
|
+
const space = options.space;
|
|
187
187
|
if (!fs.existsSync(options.localPath)) {
|
|
188
188
|
print(`${colors.red}\u2620 Local file not found: ${options.localPath}${colors.reset}`);
|
|
189
189
|
process.exit(1);
|
|
@@ -229,9 +229,9 @@ function registerFileCommand(program2) {
|
|
|
229
229
|
stopSpinner(true, `${action}: ${response.data.path}`);
|
|
230
230
|
}
|
|
231
231
|
);
|
|
232
|
-
file.command("mkdir").description("Create a directory").requiredOption("-w, --workspace <id>", "Workspace ID").requiredOption("-p, --path <path>", "Directory path").option("-
|
|
232
|
+
file.command("mkdir").description("Create a directory").requiredOption("-w, --workspace <id>", "Workspace ID").requiredOption("-p, --path <path>", "Directory path").option("-s, --space <type>", "Space type: personal or team", "team").option("-r, --recursive", "Create parent directories if needed").action(
|
|
233
233
|
async (options) => {
|
|
234
|
-
const space = options.
|
|
234
|
+
const space = options.space;
|
|
235
235
|
startSpinner("Creating directory...");
|
|
236
236
|
const response = await httpPost(
|
|
237
237
|
`/workspaces/${options.workspace}/files/mkdir`,
|
|
@@ -256,9 +256,9 @@ function registerFileCommand(program2) {
|
|
|
256
256
|
stopSpinner(true, `${action}: ${response.data.path}`);
|
|
257
257
|
}
|
|
258
258
|
);
|
|
259
|
-
file.command("del").description("Delete a file or empty directory").requiredOption("-w, --workspace <id>", "Workspace ID").requiredOption("-p, --path <path>", "File or directory path").option("-
|
|
259
|
+
file.command("del").description("Delete a file or empty directory").requiredOption("-w, --workspace <id>", "Workspace ID").requiredOption("-p, --path <path>", "File or directory path").option("-s, --space <type>", "Space type: personal or team", "team").action(
|
|
260
260
|
async (options) => {
|
|
261
|
-
const space = options.
|
|
261
|
+
const space = options.space;
|
|
262
262
|
startSpinner("Deleting...");
|
|
263
263
|
const response = await httpDelete(
|
|
264
264
|
`/workspaces/${options.workspace}/files/delete`,
|
|
@@ -301,6 +301,10 @@ function registerWhoamiCommand(program2) {
|
|
|
301
301
|
}
|
|
302
302
|
|
|
303
303
|
// src/commands/workspace.ts
|
|
304
|
+
var emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
|
|
305
|
+
function isValidEmail(email) {
|
|
306
|
+
return emailRegex.test(email);
|
|
307
|
+
}
|
|
304
308
|
function registerWorkspaceCommand(program2) {
|
|
305
309
|
const workspace = program2.command("workspace").description("Workspace management");
|
|
306
310
|
workspace.command("list").description("List all workspaces you belong to").action(async () => {
|
|
@@ -322,14 +326,73 @@ function registerWorkspaceCommand(program2) {
|
|
|
322
326
|
process.exit(1);
|
|
323
327
|
}
|
|
324
328
|
});
|
|
329
|
+
const members = program2.command("members").description("Manage workspace members");
|
|
330
|
+
members.command("list").description("List all members in a workspace").requiredOption("-w, --workspace <workspaceId>", "Workspace ID").action(async (options) => {
|
|
331
|
+
const { workspace: workspaceId } = options;
|
|
332
|
+
startSpinner("Fetching workspace members...");
|
|
333
|
+
const response = await httpGet(`/workspaces/${workspaceId}/members`);
|
|
334
|
+
if (!response.ok) {
|
|
335
|
+
stopSpinner(false, "Failed to fetch members");
|
|
336
|
+
printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`);
|
|
337
|
+
process.exit(1);
|
|
338
|
+
}
|
|
339
|
+
const { members: members2 } = response.data;
|
|
340
|
+
if (members2.length === 0) {
|
|
341
|
+
stopSpinner(true, "No members found.");
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
stopSpinner(true, `Found ${members2.length} member(s)`);
|
|
345
|
+
for (const member of members2) {
|
|
346
|
+
const name = member.displayName || "-";
|
|
347
|
+
print(`${colors.bold}${member.email}${colors.reset} ${name} ${member.role}`);
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
members.command("remove").description("Remove members from a workspace").requiredOption("-w, --workspace <workspaceId>", "Workspace ID").argument("<emails>", "Emails to remove (comma-separated)").action(async (emailsArg, options) => {
|
|
351
|
+
const { workspace: workspaceId } = options;
|
|
352
|
+
const emails = emailsArg.split(",").map((e) => e.trim()).filter(Boolean);
|
|
353
|
+
if (emails.length === 0) {
|
|
354
|
+
printError("No valid emails provided");
|
|
355
|
+
process.exit(1);
|
|
356
|
+
}
|
|
357
|
+
const invalidEmails = emails.filter((e) => !isValidEmail(e));
|
|
358
|
+
if (invalidEmails.length > 0) {
|
|
359
|
+
for (const email of invalidEmails) {
|
|
360
|
+
printError(`Invalid email format: ${email}`);
|
|
361
|
+
}
|
|
362
|
+
process.exit(1);
|
|
363
|
+
}
|
|
364
|
+
startSpinner("Fetching workspace members...");
|
|
365
|
+
const membersResponse = await httpGet(`/workspaces/${workspaceId}/members`);
|
|
366
|
+
if (!membersResponse.ok) {
|
|
367
|
+
stopSpinner(false, "Failed to fetch members");
|
|
368
|
+
printError(`Error [${membersResponse.status}]: ${JSON.stringify(membersResponse.data)}`);
|
|
369
|
+
process.exit(1);
|
|
370
|
+
}
|
|
371
|
+
stopSpinner(true, "Members fetched");
|
|
372
|
+
const { members: members2 } = membersResponse.data;
|
|
373
|
+
const emailToMember = new Map(members2.map((m) => [m.email.toLowerCase(), m]));
|
|
374
|
+
for (const email of emails) {
|
|
375
|
+
const member = emailToMember.get(email.toLowerCase());
|
|
376
|
+
if (!member) {
|
|
377
|
+
print(`${colors.red}\u2717${colors.reset} ${email} - not found in workspace`);
|
|
378
|
+
continue;
|
|
379
|
+
}
|
|
380
|
+
const deleteResponse = await httpDelete(`/workspaces/${workspaceId}/members/${member.userId}`);
|
|
381
|
+
if (deleteResponse.ok) {
|
|
382
|
+
print(`${colors.green}\u2713${colors.reset} ${email} - removed`);
|
|
383
|
+
} else {
|
|
384
|
+
print(`${colors.red}\u2717${colors.reset} ${email} - failed: ${JSON.stringify(deleteResponse.data)}`);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
});
|
|
325
388
|
}
|
|
326
389
|
|
|
327
390
|
// src/index.ts
|
|
328
391
|
updateNotifier({
|
|
329
|
-
pkg: { name: "@moxt-ai/cli", version: "0.1.
|
|
392
|
+
pkg: { name: "@moxt-ai/cli", version: "0.1.8" }
|
|
330
393
|
}).notify();
|
|
331
394
|
var program = new Command();
|
|
332
|
-
program.name("moxt").description("Moxt CLI - AI Workspace").version("0.1.
|
|
395
|
+
program.name("moxt").description("Moxt CLI - AI Workspace").version("0.1.8").action(() => {
|
|
333
396
|
program.help();
|
|
334
397
|
});
|
|
335
398
|
registerWhoamiCommand(program);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/commands/file.ts","../src/utils/http.ts","../src/utils/config.ts","../src/utils/output.ts","../src/utils/spinner.ts","../src/commands/whoami.ts","../src/commands/workspace.ts"],"sourcesContent":["import { Command } from 'commander'\nimport updateNotifier from 'update-notifier'\nimport { registerFileCommand } from './commands/file.js'\nimport { registerWhoamiCommand } from './commands/whoami.js'\nimport { registerWorkspaceCommand } from './commands/workspace.js'\n\ndeclare const __CLI_VERSION__: string\n\nupdateNotifier({\n pkg: { name: '@moxt-ai/cli', version: __CLI_VERSION__ },\n}).notify()\n\nconst program = new Command()\n\nprogram\n .name('moxt')\n .description('Moxt CLI - AI Workspace')\n .version(__CLI_VERSION__)\n .action(() => {\n program.help()\n })\n\nregisterWhoamiCommand(program)\nregisterWorkspaceCommand(program)\nregisterFileCommand(program)\n\nprogram.parseAsync(process.argv).catch((err: unknown) => {\n console.error('CLI Error:', err)\n process.exit(1)\n})\n","import * as fs from 'node:fs'\nimport { Command } from 'commander'\nimport { httpDelete, httpGet, httpPost, httpPut } from '../utils/http.js'\nimport { colors, print, printError } from '../utils/output.js'\nimport { startSpinner, stopSpinner } from '../utils/spinner.js'\n\ninterface FileEntry {\n name: string\n type: 'file' | 'directory'\n size: number | null\n}\n\ninterface FileReadResponse {\n path: string\n type: 'file' | 'directory'\n entries: FileEntry[] | null\n content: string | null\n}\n\ninterface FileWriteResponse {\n path: string\n created: boolean\n}\n\ninterface MkdirResponse {\n path: string\n created: boolean\n}\n\ninterface DeleteResponse {\n path: string\n}\n\n/**\n * 检测 Buffer 是否为二进制内容\n * 文本文件不应包含控制字符(除了 tab、换行、回车)\n */\nfunction isBinaryContent(buffer: Buffer): boolean {\n const sampleSize = Math.min(buffer.length, 8192)\n\n for (let i = 0; i < sampleSize; i++) {\n const byte = buffer[i]\n // 控制字符(除了 tab=9, newline=10, carriage return=13)\n if (byte < 32 && byte !== 9 && byte !== 10 && byte !== 13) {\n return true\n }\n }\n\n return false\n}\n\nexport function registerFileCommand(program: Command): void {\n const file = program.command('file').description('File operations')\n\n file.command('list')\n .description('List directory contents')\n .requiredOption('-w, --workspace <id>', 'Workspace ID')\n .option('-p, --path <path>', 'Directory path', '/')\n .option('-t, --team', 'Access team space (default)')\n .option('-P, --personal', 'Access personal space')\n .action(async (options: { workspace: string; path: string; team?: boolean; personal?: boolean }) => {\n const space = options.personal ? 'personal' : 'team'\n startSpinner('Listing files...')\n const response = await httpGet<FileReadResponse>(\n `/workspaces/${options.workspace}/files/list?path=${encodeURIComponent(options.path)}&space=${space}`,\n )\n\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n if (response.status === 404) {\n print(`${colors.red}☠ ${options.path} does not exist${colors.reset}`)\n } else {\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n }\n process.exit(1)\n }\n\n const { path, entries } = response.data\n\n if (!entries || entries.length === 0) {\n stopSpinner(true, `${path}: empty directory`)\n return\n }\n\n stopSpinner(true, path)\n for (const entry of entries) {\n if (entry.type === 'directory') {\n print(`${colors.blue}${entry.name}/${colors.reset}`)\n } else {\n print(entry.name)\n }\n }\n })\n\n file.command('read')\n .description('Read file content')\n .requiredOption('-w, --workspace <id>', 'Workspace ID')\n .requiredOption('-p, --path <path>', 'File path')\n .option('-t, --team', 'Access team space (default)')\n .option('-P, --personal', 'Access personal space')\n .action(async (options: { workspace: string; path: string; team?: boolean; personal?: boolean }) => {\n const space = options.personal ? 'personal' : 'team'\n startSpinner('Reading file...')\n const response = await httpGet<FileReadResponse>(\n `/workspaces/${options.workspace}/files/read?path=${encodeURIComponent(options.path)}&space=${space}`,\n )\n\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n if (response.status === 404) {\n print(`${colors.red}☠ ${options.path} does not exist${colors.reset}`)\n } else {\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n }\n process.exit(1)\n }\n\n const { type, content } = response.data\n\n if (type === 'directory') {\n stopSpinner(false, 'Failed')\n print(`${colors.red}☠ ${options.path} is a directory${colors.reset}`)\n process.exit(1)\n }\n\n stopSpinner(true, 'Done')\n print(content ?? '')\n })\n\n file.command('put')\n .description('Upload a file')\n .requiredOption('-w, --workspace <id>', 'Workspace ID')\n .requiredOption('-p, --path <path>', 'Remote file path')\n .requiredOption('-l, --local-path <localPath>', 'Local file path')\n .option('-t, --team', 'Access team space (default)')\n .option('-P, --personal', 'Access personal space')\n .option('-r, --recursive', 'Create parent directories if needed')\n .action(\n async (options: {\n workspace: string\n path: string\n localPath: string\n team?: boolean\n personal?: boolean\n recursive?: boolean\n }) => {\n const space = options.personal ? 'personal' : 'team'\n\n // 检查本地文件是否存在\n if (!fs.existsSync(options.localPath)) {\n print(`${colors.red}☠ Local file not found: ${options.localPath}${colors.reset}`)\n process.exit(1)\n }\n\n // 检查是否为文件\n const stats = fs.statSync(options.localPath)\n if (!stats.isFile()) {\n print(`${colors.red}☠ Not a file: ${options.localPath}${colors.reset}`)\n process.exit(1)\n }\n\n // 检查文件大小 (10MB)\n const maxSize = 10 * 1024 * 1024\n if (stats.size > maxSize) {\n print(`${colors.red}☠ File too large (max 10MB): ${options.localPath}${colors.reset}`)\n process.exit(1)\n }\n\n // 读取文件内容并检查是否为二进制\n const buffer = fs.readFileSync(options.localPath)\n if (isBinaryContent(buffer)) {\n print(`${colors.red}☠ Binary files are not allowed. Only text files can be uploaded.${colors.reset}`)\n process.exit(1)\n }\n\n const content = buffer.toString('utf8')\n\n startSpinner('Uploading...')\n const response = await httpPut<FileWriteResponse>(\n `/workspaces/${options.workspace}/files/write`,\n {\n path: options.path,\n content,\n space,\n recursive: options.recursive ?? false,\n },\n )\n\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n if (response.status === 404) {\n print(`${colors.red}☠ Parent directory does not exist${colors.reset}`)\n } else if (response.status === 400) {\n printError(`Error: ${JSON.stringify(response.data)}`)\n } else {\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n }\n process.exit(1)\n }\n\n const action = response.data.created ? 'Created' : 'Updated'\n stopSpinner(true, `${action}: ${response.data.path}`)\n },\n )\n\n file.command('mkdir')\n .description('Create a directory')\n .requiredOption('-w, --workspace <id>', 'Workspace ID')\n .requiredOption('-p, --path <path>', 'Directory path')\n .option('-t, --team', 'Access team space (default)')\n .option('-P, --personal', 'Access personal space')\n .option('-r, --recursive', 'Create parent directories if needed')\n .action(\n async (options: {\n workspace: string\n path: string\n team?: boolean\n personal?: boolean\n recursive?: boolean\n }) => {\n const space = options.personal ? 'personal' : 'team'\n\n startSpinner('Creating directory...')\n const response = await httpPost<MkdirResponse>(\n `/workspaces/${options.workspace}/files/mkdir`,\n {\n path: options.path,\n space,\n recursive: options.recursive ?? false,\n },\n )\n\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n if (response.status === 404) {\n print(`${colors.red}☠ Parent directory does not exist${colors.reset}`)\n } else if (response.status === 400) {\n printError(`Error: ${JSON.stringify(response.data)}`)\n } else {\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n }\n process.exit(1)\n }\n\n const action = response.data.created ? 'Created' : 'Already exists'\n stopSpinner(true, `${action}: ${response.data.path}`)\n },\n )\n\n file.command('del')\n .description('Delete a file or empty directory')\n .requiredOption('-w, --workspace <id>', 'Workspace ID')\n .requiredOption('-p, --path <path>', 'File or directory path')\n .option('-t, --team', 'Access team space (default)')\n .option('-P, --personal', 'Access personal space')\n .action(\n async (options: {\n workspace: string\n path: string\n team?: boolean\n personal?: boolean\n }) => {\n const space = options.personal ? 'personal' : 'team'\n\n startSpinner('Deleting...')\n const response = await httpDelete<DeleteResponse>(\n `/workspaces/${options.workspace}/files/delete`,\n {\n path: options.path,\n space,\n },\n )\n\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n if (response.status === 404) {\n print(`${colors.red}☠ Path not found: ${options.path}${colors.reset}`)\n } else if (response.status === 400) {\n print(`${colors.red}☠ Cannot delete non-empty directory${colors.reset}`)\n } else {\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n }\n process.exit(1)\n }\n\n stopSpinner(true, `Deleted: ${response.data.path}`)\n },\n )\n}\n","import { arch, platform } from 'os'\nimport { getApiBaseUrl, getApiKey } from './config.js'\n\ndeclare const __CLI_VERSION__: string\n\nexport interface ApiResponse<T> {\n ok: boolean\n status: number\n data: T\n}\n\nfunction getUserAgent(): string {\n return `moxt-cli/${__CLI_VERSION__} (${platform()}/${arch()}) node/${process.versions.node}`\n}\n\nasync function request<T>(method: string, path: string, body?: unknown): Promise<ApiResponse<T>> {\n const apiKey = getApiKey()\n const url = `${getApiBaseUrl()}${path}`\n\n const response = await fetch(url, {\n method,\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${apiKey}`,\n 'User-Agent': getUserAgent(),\n },\n body: body ? JSON.stringify(body) : undefined,\n })\n\n let data: T\n const contentType = response.headers.get('content-type')\n if (contentType?.includes('application/json')) {\n data = (await response.json()) as T\n } else {\n data = (await response.text()) as T\n }\n\n if (response.status === 401) {\n console.error('Authentication failed. Check your MOXT_API_KEY.')\n console.error('Get a new key at: https://moxt.ai')\n process.exit(1)\n }\n\n return {\n ok: response.ok,\n status: response.status,\n data,\n }\n}\n\nexport async function httpGet<T>(path: string): Promise<ApiResponse<T>> {\n return request<T>('GET', path)\n}\n\nexport async function httpPut<T>(path: string, body: unknown): Promise<ApiResponse<T>> {\n return request<T>('PUT', path, body)\n}\n\nexport async function httpPost<T>(path: string, body: unknown): Promise<ApiResponse<T>> {\n return request<T>('POST', path, body)\n}\n\nexport async function httpDelete<T>(path: string, body: unknown): Promise<ApiResponse<T>> {\n return request<T>('DELETE', path, body)\n}\n","const DEFAULT_HOST = 'api.moxt.ai'\n\nexport function getApiBaseUrl(): string {\n const host = process.env.MOXT_HOST ?? DEFAULT_HOST\n return `https://${host}/openapi/v1`\n}\n\nexport function getApiKey(): string {\n const apiKey = process.env.MOXT_API_KEY\n\n if (!apiKey) {\n console.error('MOXT_API_KEY environment variable is not set.')\n console.error('')\n console.error('Get your API key at: https://moxt.ai')\n console.error('')\n console.error('Then set it:')\n console.error(' export MOXT_API_KEY=moxt_...')\n process.exit(1)\n }\n\n return apiKey\n}\n","// ANSI 颜色\nexport const colors = {\n bold: '\\x1b[1m',\n blue: '\\x1b[1;34m',\n green: '\\x1b[32m',\n red: '\\x1b[31m',\n dim: '\\x1b[2m',\n reset: '\\x1b[0m',\n}\n\nexport function print(message: string): void {\n console.log(message)\n}\n\nexport function printError(message: string): void {\n console.error(`${colors.red}${message}${colors.reset}`)\n}\n","const frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏']\n\nlet intervalId: ReturnType<typeof setInterval> | null = null\nlet frameIndex = 0\n\nexport function startSpinner(message: string): void {\n frameIndex = 0\n process.stdout.write(`${frames[frameIndex]} ${message}`)\n\n intervalId = setInterval(() => {\n frameIndex = (frameIndex + 1) % frames.length\n process.stdout.write(`\\r${frames[frameIndex]} ${message}`)\n }, 80)\n}\n\nexport function stopSpinner(success: boolean, message?: string): void {\n if (intervalId) {\n clearInterval(intervalId)\n intervalId = null\n }\n\n const symbol = success ? '\\x1b[32m✓\\x1b[0m' : '\\x1b[31m✗\\x1b[0m'\n // \\x1b[2K 清除整行,\\r 回到行首\n process.stdout.write(`\\x1b[2K\\r${symbol} ${message ?? ''}\\n`)\n}\n","import { Command } from 'commander'\nimport { httpGet } from '../utils/http.js'\nimport { colors, print, printError } from '../utils/output.js'\nimport { startSpinner, stopSpinner } from '../utils/spinner.js'\n\ninterface WhoamiResponse {\n nickname: string\n email: string\n}\n\nexport function registerWhoamiCommand(program: Command): void {\n program\n .command('whoami')\n .description('Show current user information')\n .action(async () => {\n startSpinner('Fetching user info...')\n const response = await httpGet<WhoamiResponse>('/users/whoami')\n\n if (response.ok) {\n stopSpinner(true, 'Done')\n print(`${colors.bold}Nickname${colors.reset}: ${response.data.nickname}`)\n print(`${colors.bold}Email${colors.reset}: ${response.data.email}`)\n } else {\n stopSpinner(false, 'Failed')\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n process.exit(1)\n }\n })\n}\n","import { Command } from 'commander'\nimport { httpGet } from '../utils/http.js'\nimport { colors, print, printError } from '../utils/output.js'\nimport { startSpinner, stopSpinner } from '../utils/spinner.js'\n\ninterface WorkspaceItem {\n workspaceId: string\n name: string\n}\n\ninterface WorkspaceListResponse {\n workspaces: WorkspaceItem[]\n}\n\nexport function registerWorkspaceCommand(program: Command): void {\n const workspace = program.command('workspace').description('Workspace management')\n\n workspace\n .command('list')\n .description('List all workspaces you belong to')\n .action(async () => {\n startSpinner('Fetching workspaces...')\n const response = await httpGet<WorkspaceListResponse>('/workspaces')\n\n if (response.ok) {\n const { workspaces } = response.data\n if (workspaces.length === 0) {\n stopSpinner(true, 'No workspaces found.')\n return\n }\n\n stopSpinner(true, `Found ${workspaces.length} workspace(s)`)\n\n for (const ws of workspaces) {\n print(`${colors.bold}${ws.workspaceId}${colors.reset}\\t${ws.name}`)\n }\n } else {\n stopSpinner(false, 'Failed')\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n process.exit(1)\n }\n })\n}\n"],"mappings":";;;AAAA,SAAS,eAAe;AACxB,OAAO,oBAAoB;;;ACD3B,YAAY,QAAQ;;;ACApB,SAAS,MAAM,gBAAgB;;;ACA/B,IAAM,eAAe;AAEd,SAAS,gBAAwB;AACpC,QAAM,OAAO,QAAQ,IAAI,aAAa;AACtC,SAAO,WAAW,IAAI;AAC1B;AAEO,SAAS,YAAoB;AAChC,QAAM,SAAS,QAAQ,IAAI;AAE3B,MAAI,CAAC,QAAQ;AACT,YAAQ,MAAM,+CAA+C;AAC7D,YAAQ,MAAM,EAAE;AAChB,YAAQ,MAAM,sCAAsC;AACpD,YAAQ,MAAM,EAAE;AAChB,YAAQ,MAAM,cAAc;AAC5B,YAAQ,MAAM,gCAAgC;AAC9C,YAAQ,KAAK,CAAC;AAAA,EAClB;AAEA,SAAO;AACX;;;ADVA,SAAS,eAAuB;AAC5B,SAAO,YAAY,OAAe,KAAK,SAAS,CAAC,IAAI,KAAK,CAAC,UAAU,QAAQ,SAAS,IAAI;AAC9F;AAEA,eAAe,QAAW,QAAgB,MAAc,MAAyC;AAC7F,QAAM,SAAS,UAAU;AACzB,QAAM,MA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AM,GAAG,OAAO,IAAI,GAAG,GAAG,WAAW,GAAG,OAAO,KAAK,IAAK,GAAG,IAAI,EAAE;AAAA,MACtE;AAAA,IACJ,OAAO;AACH,kBAAY,OAAO,QAAQ;AAC3B,iBAAW,UAAU,SAAS,MAAM,MAAM,KAAK,UAAU,SAAS,IAAI,CAAC,EAAE;AACzE,cAAQ,KAAK,CAAC;AAAA,IAClB;AAAA,EACJ,CAAC;AACT;;;APlCA,eAAe;AAAA,EACX,KAAK,EAAE,MAAM,gBAAgB,SAAS,QAAgB;AAC1D,CAAC,EAAE,OAAO;AAEV,IAAM,UAAU,IAAI,QAAQ;AAE5B,QACK,KAAK,MAAM,EACX,YAAY,yBAAyB,EACrC,QAAQ,OAAe,EACvB,OAAO,MAAM;AACV,UAAQ,KAAK;AACjB,CAAC;AAEL,sBAAsB,OAAO;AAC7B,yBAAyB,OAAO;AAChC,oBAAoB,OAAO;AAE3B,QAAQ,WAAW,QAAQ,IAAI,EAAE,MAAM,CAAC,QAAiB;AACrD,UAAQ,MAAM,cAAc,GAAG;AAC/B,UAAQ,KAAK,CAAC;AAClB,CAAC;","names":["program","program","program"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/commands/file.ts","../src/utils/http.ts","../src/utils/config.ts","../src/utils/output.ts","../src/utils/spinner.ts","../src/commands/whoami.ts","../src/commands/workspace.ts"],"sourcesContent":["import { Command } from 'commander'\nimport updateNotifier from 'update-notifier'\nimport { registerFileCommand } from './commands/file.js'\nimport { registerWhoamiCommand } from './commands/whoami.js'\nimport { registerWorkspaceCommand } from './commands/workspace.js'\n\ndeclare const __CLI_VERSION__: string\n\nupdateNotifier({\n pkg: { name: '@moxt-ai/cli', version: __CLI_VERSION__ },\n}).notify()\n\nconst program = new Command()\n\nprogram\n .name('moxt')\n .description('Moxt CLI - AI Workspace')\n .version(__CLI_VERSION__)\n .action(() => {\n program.help()\n })\n\nregisterWhoamiCommand(program)\nregisterWorkspaceCommand(program)\nregisterFileCommand(program)\n\nprogram.parseAsync(process.argv).catch((err: unknown) => {\n console.error('CLI Error:', err)\n process.exit(1)\n})\n","import * as fs from 'node:fs'\nimport { Command } from 'commander'\nimport { httpDelete, httpGet, httpPost, httpPut } from '../utils/http.js'\nimport { colors, print, printError } from '../utils/output.js'\nimport { startSpinner, stopSpinner } from '../utils/spinner.js'\n\ninterface FileEntry {\n name: string\n type: 'file' | 'directory'\n size: number | null\n}\n\ninterface FileReadResponse {\n path: string\n type: 'file' | 'directory'\n entries: FileEntry[] | null\n content: string | null\n}\n\ninterface FileWriteResponse {\n path: string\n created: boolean\n}\n\ninterface MkdirResponse {\n path: string\n created: boolean\n}\n\ninterface DeleteResponse {\n path: string\n}\n\n/**\n * 检测 Buffer 是否为二进制内容\n * 文本文件不应包含控制字符(除了 tab、换行、回车)\n */\nfunction isBinaryContent(buffer: Buffer): boolean {\n const sampleSize = Math.min(buffer.length, 8192)\n\n for (let i = 0; i < sampleSize; i++) {\n const byte = buffer[i]\n // 控制字符(除了 tab=9, newline=10, carriage return=13)\n if (byte < 32 && byte !== 9 && byte !== 10 && byte !== 13) {\n return true\n }\n }\n\n return false\n}\n\nexport function registerFileCommand(program: Command): void {\n const file = program.command('file').description('File operations')\n\n file.command('list')\n .description('List directory contents')\n .requiredOption('-w, --workspace <id>', 'Workspace ID')\n .option('-p, --path <path>', 'Directory path', '/')\n .option('-s, --space <type>', 'Space type: personal or team', 'team')\n .action(async (options: { workspace: string; path: string; space: string }) => {\n const space = options.space\n startSpinner('Listing files...')\n const response = await httpGet<FileReadResponse>(\n `/workspaces/${options.workspace}/files/list?path=${encodeURIComponent(options.path)}&space=${space}`,\n )\n\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n if (response.status === 404) {\n print(`${colors.red}☠ ${options.path} does not exist${colors.reset}`)\n } else {\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n }\n process.exit(1)\n }\n\n const { path, entries } = response.data\n\n if (!entries || entries.length === 0) {\n stopSpinner(true, `${path}: empty directory`)\n return\n }\n\n stopSpinner(true, path)\n for (const entry of entries) {\n if (entry.type === 'directory') {\n print(`${colors.blue}${entry.name}/${colors.reset}`)\n } else {\n print(entry.name)\n }\n }\n })\n\n file.command('read')\n .description('Read file content')\n .requiredOption('-w, --workspace <id>', 'Workspace ID')\n .requiredOption('-p, --path <path>', 'File path')\n .option('-s, --space <type>', 'Space type: personal or team', 'team')\n .action(async (options: { workspace: string; path: string; space: string }) => {\n const space = options.space\n startSpinner('Reading file...')\n const response = await httpGet<FileReadResponse>(\n `/workspaces/${options.workspace}/files/read?path=${encodeURIComponent(options.path)}&space=${space}`,\n )\n\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n if (response.status === 404) {\n print(`${colors.red}☠ ${options.path} does not exist${colors.reset}`)\n } else {\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n }\n process.exit(1)\n }\n\n const { type, content } = response.data\n\n if (type === 'directory') {\n stopSpinner(false, 'Failed')\n print(`${colors.red}☠ ${options.path} is a directory${colors.reset}`)\n process.exit(1)\n }\n\n stopSpinner(true, 'Done')\n print(content ?? '')\n })\n\n file.command('put')\n .description('Upload a file')\n .requiredOption('-w, --workspace <id>', 'Workspace ID')\n .requiredOption('-p, --path <path>', 'Remote file path')\n .requiredOption('-l, --local-path <localPath>', 'Local file path')\n .option('-s, --space <type>', 'Space type: personal or team', 'team')\n .option('-r, --recursive', 'Create parent directories if needed')\n .action(\n async (options: {\n workspace: string\n path: string\n localPath: string\n space: string\n recursive?: boolean\n }) => {\n const space = options.space\n\n // 检查本地文件是否存在\n if (!fs.existsSync(options.localPath)) {\n print(`${colors.red}☠ Local file not found: ${options.localPath}${colors.reset}`)\n process.exit(1)\n }\n\n // 检查是否为文件\n const stats = fs.statSync(options.localPath)\n if (!stats.isFile()) {\n print(`${colors.red}☠ Not a file: ${options.localPath}${colors.reset}`)\n process.exit(1)\n }\n\n // 检查文件大小 (10MB)\n const maxSize = 10 * 1024 * 1024\n if (stats.size > maxSize) {\n print(`${colors.red}☠ File too large (max 10MB): ${options.localPath}${colors.reset}`)\n process.exit(1)\n }\n\n // 读取文件内容并检查是否为二进制\n const buffer = fs.readFileSync(options.localPath)\n if (isBinaryContent(buffer)) {\n print(`${colors.red}☠ Binary files are not allowed. Only text files can be uploaded.${colors.reset}`)\n process.exit(1)\n }\n\n const content = buffer.toString('utf8')\n\n startSpinner('Uploading...')\n const response = await httpPut<FileWriteResponse>(\n `/workspaces/${options.workspace}/files/write`,\n {\n path: options.path,\n content,\n space,\n recursive: options.recursive ?? false,\n },\n )\n\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n if (response.status === 404) {\n print(`${colors.red}☠ Parent directory does not exist${colors.reset}`)\n } else if (response.status === 400) {\n printError(`Error: ${JSON.stringify(response.data)}`)\n } else {\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n }\n process.exit(1)\n }\n\n const action = response.data.created ? 'Created' : 'Updated'\n stopSpinner(true, `${action}: ${response.data.path}`)\n },\n )\n\n file.command('mkdir')\n .description('Create a directory')\n .requiredOption('-w, --workspace <id>', 'Workspace ID')\n .requiredOption('-p, --path <path>', 'Directory path')\n .option('-s, --space <type>', 'Space type: personal or team', 'team')\n .option('-r, --recursive', 'Create parent directories if needed')\n .action(\n async (options: {\n workspace: string\n path: string\n space: string\n recursive?: boolean\n }) => {\n const space = options.space\n\n startSpinner('Creating directory...')\n const response = await httpPost<MkdirResponse>(\n `/workspaces/${options.workspace}/files/mkdir`,\n {\n path: options.path,\n space,\n recursive: options.recursive ?? false,\n },\n )\n\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n if (response.status === 404) {\n print(`${colors.red}☠ Parent directory does not exist${colors.reset}`)\n } else if (response.status === 400) {\n printError(`Error: ${JSON.stringify(response.data)}`)\n } else {\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n }\n process.exit(1)\n }\n\n const action = response.data.created ? 'Created' : 'Already exists'\n stopSpinner(true, `${action}: ${response.data.path}`)\n },\n )\n\n file.command('del')\n .description('Delete a file or empty directory')\n .requiredOption('-w, --workspace <id>', 'Workspace ID')\n .requiredOption('-p, --path <path>', 'File or directory path')\n .option('-s, --space <type>', 'Space type: personal or team', 'team')\n .action(\n async (options: {\n workspace: string\n path: string\n space: string\n }) => {\n const space = options.space\n\n startSpinner('Deleting...')\n const response = await httpDelete<DeleteResponse>(\n `/workspaces/${options.workspace}/files/delete`,\n {\n path: options.path,\n space,\n },\n )\n\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n if (response.status === 404) {\n print(`${colors.red}☠ Path not found: ${options.path}${colors.reset}`)\n } else if (response.status === 400) {\n print(`${colors.red}☠ Cannot delete non-empty directory${colors.reset}`)\n } else {\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n }\n process.exit(1)\n }\n\n stopSpinner(true, `Deleted: ${response.data.path}`)\n },\n )\n}\n","import { arch, platform } from 'os'\nimport { getApiBaseUrl, getApiKey } from './config.js'\n\ndeclare const __CLI_VERSION__: string\n\nexport interface ApiResponse<T> {\n ok: boolean\n status: number\n data: T\n}\n\nfunction getUserAgent(): string {\n return `moxt-cli/${__CLI_VERSION__} (${platform()}/${arch()}) node/${process.versions.node}`\n}\n\nasync function request<T>(method: string, path: string, body?: unknown): Promise<ApiResponse<T>> {\n const apiKey = getApiKey()\n const url = `${getApiBaseUrl()}${path}`\n\n const response = await fetch(url, {\n method,\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${apiKey}`,\n 'User-Agent': getUserAgent(),\n },\n body: body ? JSON.stringify(body) : undefined,\n })\n\n let data: T\n const contentType = response.headers.get('content-type')\n if (contentType?.includes('application/json')) {\n data = (await response.json()) as T\n } else {\n data = (await response.text()) as T\n }\n\n if (response.status === 401) {\n console.error('Authentication failed. Check your MOXT_API_KEY.')\n console.error('Get a new key at: https://moxt.ai')\n process.exit(1)\n }\n\n return {\n ok: response.ok,\n status: response.status,\n data,\n }\n}\n\nexport async function httpGet<T>(path: string): Promise<ApiResponse<T>> {\n return request<T>('GET', path)\n}\n\nexport async function httpPut<T>(path: string, body: unknown): Promise<ApiResponse<T>> {\n return request<T>('PUT', path, body)\n}\n\nexport async function httpPost<T>(path: string, body: unknown): Promise<ApiResponse<T>> {\n return request<T>('POST', path, body)\n}\n\nexport async function httpDelete<T>(path: string, body?: unknown): Promise<ApiResponse<T>> {\n return request<T>('DELETE', path, body)\n}\n","const DEFAULT_HOST = 'api.moxt.ai'\n\nexport function getApiBaseUrl(): string {\n const host = process.env.MOXT_HOST ?? DEFAULT_HOST\n return `https://${host}/openapi/v1`\n}\n\nexport function getApiKey(): string {\n const apiKey = process.env.MOXT_API_KEY\n\n if (!apiKey) {\n console.error('MOXT_API_KEY environment variable is not set.')\n console.error('')\n console.error('Get your API key at: https://moxt.ai')\n console.error('')\n console.error('Then set it:')\n console.error(' export MOXT_API_KEY=moxt_...')\n process.exit(1)\n }\n\n return apiKey\n}\n","// ANSI 颜色\nexport const colors = {\n bold: '\\x1b[1m',\n blue: '\\x1b[1;34m',\n green: '\\x1b[32m',\n red: '\\x1b[31m',\n dim: '\\x1b[2m',\n reset: '\\x1b[0m',\n}\n\nexport function print(message: string): void {\n console.log(message)\n}\n\nexport function printError(message: string): void {\n console.error(`${colors.red}${message}${colors.reset}`)\n}\n","const frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏']\n\nlet intervalId: ReturnType<typeof setInterval> | null = null\nlet frameIndex = 0\n\nexport function startSpinner(message: string): void {\n frameIndex = 0\n process.stdout.write(`${frames[frameIndex]} ${message}`)\n\n intervalId = setInterval(() => {\n frameIndex = (frameIndex + 1) % frames.length\n process.stdout.write(`\\r${frames[frameIndex]} ${message}`)\n }, 80)\n}\n\nexport function stopSpinner(success: boolean, message?: string): void {\n if (intervalId) {\n clearInterval(intervalId)\n intervalId = null\n }\n\n const symbol = success ? '\\x1b[32m✓\\x1b[0m' : '\\x1b[31m✗\\x1b[0m'\n // \\x1b[2K 清除整行,\\r 回到行首\n process.stdout.write(`\\x1b[2K\\r${symbol} ${message ?? ''}\\n`)\n}\n","import { Command } from 'commander'\nimport { httpGet } from '../utils/http.js'\nimport { colors, print, printError } from '../utils/output.js'\nimport { startSpinner, stopSpinner } from '../utils/spinner.js'\n\ninterface WhoamiResponse {\n nickname: string\n email: string\n}\n\nexport function registerWhoamiCommand(program: Command): void {\n program\n .command('whoami')\n .description('Show current user information')\n .action(async () => {\n startSpinner('Fetching user info...')\n const response = await httpGet<WhoamiResponse>('/users/whoami')\n\n if (response.ok) {\n stopSpinner(true, 'Done')\n print(`${colors.bold}Nickname${colors.reset}: ${response.data.nickname}`)\n print(`${colors.bold}Email${colors.reset}: ${response.data.email}`)\n } else {\n stopSpinner(false, 'Failed')\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n process.exit(1)\n }\n })\n}\n","import { Command } from 'commander'\nimport { httpDelete, httpGet } from '../utils/http.js'\nimport { colors, print, printError } from '../utils/output.js'\nimport { startSpinner, stopSpinner } from '../utils/spinner.js'\n\ninterface WorkspaceItem {\n workspaceId: string\n name: string\n}\n\ninterface WorkspaceListResponse {\n workspaces: WorkspaceItem[]\n}\n\ninterface MemberItem {\n userId: number\n email: string\n displayName: string | null\n role: string\n}\n\ninterface MembersResponse {\n members: MemberItem[]\n}\n\n// Email regex (same as web/src/utils/email.ts)\nconst emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$/\n\nfunction isValidEmail(email: string): boolean {\n return emailRegex.test(email)\n}\n\nexport function registerWorkspaceCommand(program: Command): void {\n const workspace = program.command('workspace').description('Workspace management')\n\n workspace\n .command('list')\n .description('List all workspaces you belong to')\n .action(async () => {\n startSpinner('Fetching workspaces...')\n const response = await httpGet<WorkspaceListResponse>('/workspaces')\n\n if (response.ok) {\n const { workspaces } = response.data\n if (workspaces.length === 0) {\n stopSpinner(true, 'No workspaces found.')\n return\n }\n\n stopSpinner(true, `Found ${workspaces.length} workspace(s)`)\n\n for (const ws of workspaces) {\n print(`${colors.bold}${ws.workspaceId}${colors.reset}\\t${ws.name}`)\n }\n } else {\n stopSpinner(false, 'Failed')\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n process.exit(1)\n }\n })\n\n const members = program.command('members').description('Manage workspace members')\n\n members\n .command('list')\n .description('List all members in a workspace')\n .requiredOption('-w, --workspace <workspaceId>', 'Workspace ID')\n .action(async (options: { workspace: string }) => {\n const { workspace: workspaceId } = options\n\n startSpinner('Fetching workspace members...')\n const response = await httpGet<MembersResponse>(`/workspaces/${workspaceId}/members`)\n\n if (!response.ok) {\n stopSpinner(false, 'Failed to fetch members')\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n process.exit(1)\n }\n\n const { members } = response.data\n if (members.length === 0) {\n stopSpinner(true, 'No members found.')\n return\n }\n\n stopSpinner(true, `Found ${members.length} member(s)`)\n\n for (const member of members) {\n const name = member.displayName || '-'\n print(`${colors.bold}${member.email}${colors.reset}\\t${name}\\t${member.role}`)\n }\n })\n\n members\n .command('remove')\n .description('Remove members from a workspace')\n .requiredOption('-w, --workspace <workspaceId>', 'Workspace ID')\n .argument('<emails>', 'Emails to remove (comma-separated)')\n .action(async (emailsArg: string, options: { workspace: string }) => {\n const { workspace: workspaceId } = options\n\n const emails = emailsArg.split(',').map((e) => e.trim()).filter(Boolean)\n if (emails.length === 0) {\n printError('No valid emails provided')\n process.exit(1)\n }\n\n // Validate email format\n const invalidEmails = emails.filter((e) => !isValidEmail(e))\n if (invalidEmails.length > 0) {\n for (const email of invalidEmails) {\n printError(`Invalid email format: ${email}`)\n }\n process.exit(1)\n }\n\n // Fetch members to get userId by email\n startSpinner('Fetching workspace members...')\n const membersResponse = await httpGet<MembersResponse>(`/workspaces/${workspaceId}/members`)\n\n if (!membersResponse.ok) {\n stopSpinner(false, 'Failed to fetch members')\n printError(`Error [${membersResponse.status}]: ${JSON.stringify(membersResponse.data)}`)\n process.exit(1)\n }\n\n stopSpinner(true, 'Members fetched')\n\n const { members } = membersResponse.data\n const emailToMember = new Map(members.map((m) => [m.email.toLowerCase(), m]))\n\n // Remove each member\n for (const email of emails) {\n const member = emailToMember.get(email.toLowerCase())\n if (!member) {\n print(`${colors.red}✗${colors.reset} ${email} - not found in workspace`)\n continue\n }\n\n const deleteResponse = await httpDelete(`/workspaces/${workspaceId}/members/${member.userId}`)\n\n if (deleteResponse.ok) {\n print(`${colors.green}✓${colors.reset} ${email} - removed`)\n } else {\n print(`${colors.red}✗${colors.reset} ${email} - failed: ${JSON.stringify(deleteResponse.data)}`)\n }\n }\n })\n}\n"],"mappings":";;;AAAA,SAAS,eAAe;AACxB,OAAO,oBAAoB;;;ACD3B,YAAY,QAAQ;;;ACApB,SAAS,MAAM,gBAAgB;;;ACA/B,IAAM,eAAe;AAEd,SAAS,gBAAwB;AACpC,QAAM,OAAO,QAAQ,IAAI,aAAa;AACtC,SAAO,WAAW,IAAI;AAC1B;AAEO,SAAS,YAAoB;AAChC,QAAM,SAAS,QAAQ,IAAI;AAE3B,MAAI,CAAC,QAAQ;AACT,YAAQ,MAAM,+CAA+C;AAC7D,YAAQ,MAAM,EAAE;AAChB,YAAQ,MAAM,sCAAsC;AACpD,YAAQ,MAAM,EAAE;AAChB,YAAQ,MAAM,cAAc;AAC5B,YAAQ,MAAM,gCAAgC;AAC9C,YAAQ,KAAK,CAAC;AAAA,EAClB;AAEA,SAAO;AACX;;;ADVA,SAAS,eAAuB;AAC5B,SAAO,YAAY,OAAe,KAAK,SAAS,CAAC,IAAI,KAAK,CAAC,UAAU,QAAQ,SAAS,IAAI;AAC9F;AAEA,eAAe,QAAW,QAAgB,MAAc,MAAyC;AAC7F,QAAM,SAAS,UAAU;AACzB,QAAM,MAAM,GAAG,cAAc,CAAC,GAAG,IAAI;AAErC,QAAM,WAAW,MAAM,MAAM,KAAK;AAAA,IAC9B;AAAA,IACA,SAAS;AAAA,MACL,gBAAgB;AAAA,MAChB,eAAe,UAAU,MAAM;A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AQ;AAE5B,QACK,KAAK,MAAM,EACX,YAAY,yBAAyB,EACrC,QAAQ,OAAe,EACvB,OAAO,MAAM;AACV,UAAQ,KAAK;AACjB,CAAC;AAEL,sBAAsB,OAAO;AAC7B,yBAAyB,OAAO;AAChC,oBAAoB,OAAO;AAE3B,QAAQ,WAAW,QAAQ,IAAI,EAAE,MAAM,CAAC,QAAiB;AACrD,UAAQ,MAAM,cAAc,GAAG;AAC/B,UAAQ,KAAK,CAAC;AAClB,CAAC;","names":["program","program","program","members"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moxt-ai/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "Moxt - The Agent-Native Workspace",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -25,10 +25,6 @@
|
|
|
25
25
|
],
|
|
26
26
|
"author": "Moxt",
|
|
27
27
|
"license": "MIT",
|
|
28
|
-
"repository": {
|
|
29
|
-
"type": "git",
|
|
30
|
-
"url": "https://github.com/anthropics/moxt"
|
|
31
|
-
},
|
|
32
28
|
"homepage": "https://moxt.ai",
|
|
33
29
|
"engines": {
|
|
34
30
|
"node": ">=18"
|