@moxt-ai/cli 0.1.9 → 0.2.1

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 CHANGED
@@ -45,42 +45,104 @@ moxt members list -w <workspace-id>
45
45
  moxt members remove -w <workspace-id> <email1>,<email2>
46
46
  ```
47
47
 
48
+ ### space
49
+
50
+ List accessible spaces in a workspace.
51
+
52
+ ```bash
53
+ # List all accessible spaces (personal, team, teammate)
54
+ moxt space list -w <workspace-id>
55
+ ```
56
+
57
+ Output columns: TYPE, TEAM_SPACE_ID, TEAMMATE_ID, NAME
58
+
59
+ - `personal` — Your personal space (Momo). Both IDs are empty; this is the default.
60
+ - `team` — Teamspace. Only `TEAM_SPACE_ID` is populated.
61
+ - `teammate` — AI teammate. Only `TEAMMATE_ID` is populated.
62
+
48
63
  ### file
49
64
 
50
- File operations in workspace.
65
+ File operations on a space. Use `moxt space list` to find available spaces.
51
66
 
52
67
  ```bash
53
- # List directory contents
54
- moxt file list -w <workspace-id> [-p <path>] [-s <personal|team>]
68
+ # List directory contents (defaults to personal space)
69
+ moxt file list -w <workspace-id> [-p <path>]
70
+
71
+ # List directory in personal space (explicit)
72
+ moxt file list -w <workspace-id> --personal [-p <path>]
73
+
74
+ # List directory in a teamspace (by name)
75
+ moxt file list -w <workspace-id> -s <teamspace-name> [-p <path>]
76
+
77
+ # List directory in a teamspace (by ID)
78
+ moxt file list -w <workspace-id> --team-space-id <teamSpaceId> [-p <path>]
79
+
80
+ # List directory in a teammate space (by teammate ID)
81
+ moxt file list -w <workspace-id> --teammate-id <teammateId> [-p <path>]
55
82
 
56
83
  # Read file content by path
57
- moxt file read -w <workspace-id> -p <path> [-s <personal|team>]
84
+ moxt file read -w <workspace-id> -p <path>
85
+
86
+ # Read file content from a teamspace (by name or ID)
87
+ moxt file read -w <workspace-id> -s <teamspace-name> -p <path>
88
+ moxt file read -w <workspace-id> --team-space-id <teamSpaceId> -p <path>
89
+
90
+ # Read file content from a teammate space (by teammate ID)
91
+ moxt file read -w <workspace-id> --teammate-id <teammateId> -p <path>
58
92
 
59
93
  # Read file content by URL
60
94
  moxt file read --url <moxt-url>
61
95
 
62
- # Upload a file
63
- moxt file put -w <workspace-id> -p <path> -l <local-path> [-s <personal|team>] [-r]
96
+ # Resolve the shareable browser URL for a file by path
97
+ moxt file get-url -w <workspace-id> -p <path>
98
+
99
+ # Resolve URL in a teamspace (by name or ID)
100
+ moxt file get-url -w <workspace-id> -s <teamspace-name> -p <path>
101
+ moxt file get-url -w <workspace-id> --team-space-id <teamSpaceId> -p <path>
102
+
103
+ # Resolve URL in a teammate space (by teammate ID)
104
+ moxt file get-url -w <workspace-id> --teammate-id <teammateId> -p <path>
105
+
106
+ # Upload a file by path
107
+ moxt file put -w <workspace-id> -p <path> -l <local-path> [-r]
108
+
109
+ # Upload a file to a teamspace (by name or ID)
110
+ moxt file put -w <workspace-id> -s <teamspace-name> -p <path> -l <local-path> [-r]
111
+ moxt file put -w <workspace-id> --team-space-id <teamSpaceId> -p <path> -l <local-path> [-r]
112
+
113
+ # Upload a file to a teammate space (by teammate ID)
114
+ moxt file put -w <workspace-id> --teammate-id <teammateId> -p <path> -l <local-path> [-r]
115
+
116
+ # Overwrite an existing file by its Moxt URL
117
+ moxt file put --url <moxt-url> -l <local-path>
64
118
 
65
119
  # Create a directory
66
- moxt file mkdir -w <workspace-id> -p <path> [-s <personal|team>] [-r]
120
+ moxt file mkdir -w <workspace-id> -p <path> [-r]
121
+ moxt file mkdir -w <workspace-id> -s <teamspace-name> -p <path> [-r]
67
122
 
68
123
  # Delete a file or empty directory
69
- moxt file del -w <workspace-id> -p <path> [-s <personal|team>]
124
+ moxt file del -w <workspace-id> -p <path>
125
+ moxt file del -w <workspace-id> -s <teamspace-name> -p <path>
70
126
  ```
71
127
 
72
128
  #### File command options
73
129
 
74
130
  | Option | Description |
75
131
  |--------|-------------|
76
- | `-w, --workspace <id>` | Workspace ID |
132
+ | `-w, --workspace <id>` | Workspace ID (required for path mode) |
133
+ | `-s, --space <name>` | Space name (`personal` or teamspace name) |
134
+ | `--personal` | Use personal space (default when no space specified) |
135
+ | `--team-space-id <id>` | Team space ID |
136
+ | `--teammate-id <id>` | Teammate ID (teammate space) |
77
137
  | `-p, --path <path>` | File or directory path |
78
138
  | `-u, --url <url>` | Moxt file URL (e.g., `https://moxt.ai/w/{workspaceId}/{fileId}`) |
79
139
  | `-l, --local-path <path>` | Local file path (for upload) |
80
- | `-s, --space <type>` | Space type: `personal` or `team` (default: `team`) |
81
- | `-r, --recursive` | Create parent directories if needed |
140
+ | `-r, --recursive` | Create parent directories if needed (path mode only) |
82
141
 
83
- > **Note**: For `file read`, use either `--url` or both `--workspace` and `--path`. They are mutually exclusive.
142
+ > **Note**: `-s`, `--personal`, `--team-space-id`, and `--teammate-id` are mutually exclusive.
143
+ > For `file read` and `file put`, use either `--url` or `--workspace` with `--path`. They are mutually exclusive.
144
+ > `--url` with `file put` overwrites an existing file identified by the URL; it never creates new files. Use `--recursive` is not allowed in URL mode.
145
+ > `file get-url` returns a stable Moxt URL (e.g., `https://moxt.ai/w/{workspaceId}/{fileId}`) for the given path; the URL is unchanged across writes to the same path and can be fed back into `file read --url` or `file put --url`.
84
146
 
85
147
  ## Configuration
86
148
 
package/dist/index.js CHANGED
@@ -7,6 +7,118 @@ import updateNotifier from "update-notifier";
7
7
  // src/commands/file.ts
8
8
  import * as fs from "fs";
9
9
 
10
+ // src/utils/file-selector.ts
11
+ var SpaceOptionsError = class extends Error {
12
+ constructor(message) {
13
+ super(message);
14
+ this.name = "SpaceOptionsError";
15
+ }
16
+ };
17
+ function resolveSpaceSelector(options) {
18
+ const { space, teamSpaceId, teammateId } = options;
19
+ const personalIsSet = options.personal === true;
20
+ const spaceIsSet = space != null && space !== "";
21
+ const teamSpaceIdIsSet = teamSpaceId != null && teamSpaceId !== "";
22
+ const teammateIdIsSet = teammateId != null && teammateId !== "";
23
+ const selectorCount = (spaceIsSet ? 1 : 0) + (personalIsSet ? 1 : 0) + (teamSpaceIdIsSet ? 1 : 0) + (teammateIdIsSet ? 1 : 0);
24
+ if (selectorCount > 1) {
25
+ throw new SpaceOptionsError(
26
+ "Error: -s, --personal, --team-space-id, and --teammate-id are mutually exclusive."
27
+ );
28
+ }
29
+ if (teamSpaceId != null && teamSpaceId !== "") {
30
+ return { teamSpaceId };
31
+ }
32
+ if (teammateId != null && teammateId !== "") {
33
+ const parsed = Number.parseInt(teammateId, 10);
34
+ if (!Number.isInteger(parsed) || parsed <= 0 || String(parsed) !== teammateId) {
35
+ throw new SpaceOptionsError(
36
+ `Error: --teammate-id must be a positive integer, got "${teammateId}".`
37
+ );
38
+ }
39
+ return { agentId: parsed };
40
+ }
41
+ if (personalIsSet) {
42
+ return { space: "personal" };
43
+ }
44
+ if (space != null && space !== "") {
45
+ return { space };
46
+ }
47
+ return {};
48
+ }
49
+ function buildFileQueryString(path, spaceParams) {
50
+ const params = new URLSearchParams();
51
+ if (path != null && path !== "") {
52
+ params.set("path", path);
53
+ }
54
+ if (spaceParams.space) {
55
+ params.set("space", spaceParams.space);
56
+ }
57
+ if (spaceParams.teamSpaceId) {
58
+ params.set("teamSpaceId", spaceParams.teamSpaceId);
59
+ }
60
+ if (spaceParams.agentId != null) {
61
+ params.set("agentId", String(spaceParams.agentId));
62
+ }
63
+ const qs = params.toString();
64
+ return qs ? `?${qs}` : "";
65
+ }
66
+ function isBinaryContent(buffer) {
67
+ const sampleSize = Math.min(buffer.length, 8192);
68
+ for (let i = 0; i < sampleSize; i++) {
69
+ const byte = buffer[i];
70
+ if (byte < 32 && byte !== 9 && byte !== 10 && byte !== 13) {
71
+ return true;
72
+ }
73
+ }
74
+ return false;
75
+ }
76
+ function resolveReadMode(options) {
77
+ if (options.url && options.workspace) {
78
+ throw new SpaceOptionsError("Error: --url cannot be used with --workspace");
79
+ }
80
+ if (options.url && options.path) {
81
+ throw new SpaceOptionsError("Error: --url cannot be used with --path");
82
+ }
83
+ if (!options.url && !options.workspace) {
84
+ throw new SpaceOptionsError("Error: Either --url or --workspace is required");
85
+ }
86
+ if (!options.url && !options.path) {
87
+ throw new SpaceOptionsError("Error: --path is required when not using --url");
88
+ }
89
+ if (options.url) {
90
+ return { kind: "by-url", url: options.url };
91
+ }
92
+ if (!options.workspace) {
93
+ throw new SpaceOptionsError("Error: Either --url or --workspace is required");
94
+ }
95
+ if (!options.path) {
96
+ throw new SpaceOptionsError("Error: --path is required when not using --url");
97
+ }
98
+ return { kind: "by-path", workspace: options.workspace, path: options.path };
99
+ }
100
+ function resolveWriteMode(options) {
101
+ if (options.url && options.workspace) {
102
+ throw new SpaceOptionsError("Error: --url cannot be used with --workspace");
103
+ }
104
+ if (options.url && options.path) {
105
+ throw new SpaceOptionsError("Error: --url cannot be used with --path");
106
+ }
107
+ if (options.url && options.recursive) {
108
+ throw new SpaceOptionsError("Error: --recursive cannot be used with --url (the file must already exist)");
109
+ }
110
+ if (!options.url && !options.workspace) {
111
+ throw new SpaceOptionsError("Error: Either --url or --workspace is required");
112
+ }
113
+ if (!options.url && !options.path) {
114
+ throw new SpaceOptionsError("Error: --path is required when not using --url");
115
+ }
116
+ if (options.url) {
117
+ return { kind: "by-url", url: options.url };
118
+ }
119
+ return { kind: "by-path", workspace: options.workspace, path: options.path };
120
+ }
121
+
10
122
  // src/utils/http.ts
11
123
  import { arch, platform } from "os";
12
124
 
@@ -32,7 +144,7 @@ function getApiKey() {
32
144
 
33
145
  // src/utils/http.ts
34
146
  function getUserAgent() {
35
- return `moxt-cli/${"0.1.9"} (${platform()}/${arch()}) node/${process.versions.node}`;
147
+ return `moxt-cli/${"0.2.1"} (${platform()}/${arch()}) node/${process.versions.node}`;
36
148
  }
37
149
  async function request(method, path, body) {
38
150
  const apiKey = getApiKey();
@@ -83,6 +195,7 @@ var colors = {
83
195
  blue: "\x1B[1;34m",
84
196
  green: "\x1B[32m",
85
197
  red: "\x1B[31m",
198
+ cyan: "\x1B[36m",
86
199
  dim: "\x1B[2m",
87
200
  reset: "\x1B[0m"
88
201
  };
@@ -116,23 +229,53 @@ function stopSpinner(success, message) {
116
229
  }
117
230
 
118
231
  // src/commands/file.ts
119
- function isBinaryContent(buffer) {
120
- const sampleSize = Math.min(buffer.length, 8192);
121
- for (let i = 0; i < sampleSize; i++) {
122
- const byte = buffer[i];
123
- if (byte < 32 && byte !== 9 && byte !== 10 && byte !== 13) {
124
- return true;
232
+ function runOrExit(fn) {
233
+ try {
234
+ return fn();
235
+ } catch (err) {
236
+ if (err instanceof SpaceOptionsError) {
237
+ printError(err.message);
238
+ process.exit(1);
125
239
  }
240
+ throw err;
126
241
  }
127
- return false;
242
+ }
243
+ function addSpaceOptions(cmd) {
244
+ return cmd.requiredOption("-w, --workspace <workspaceId>", "Workspace ID").option("-s, --space <name>", "Space name (personal or teamspace name)").option("--personal", "Use personal space (default)").option("--team-space-id <teamSpaceId>", "Team space ID").option("--teammate-id <teammateId>", "Teammate ID (teammate space)");
128
245
  }
129
246
  function registerFileCommand(program2) {
130
247
  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("-s, --space <type>", "Space type: personal or team", "team").action(async (options) => {
132
- const space = options.space;
248
+ addSpaceOptions(
249
+ file.command("get-url").description("Resolve the shareable browser URL for a file").requiredOption("-p, --path <path>", "File path")
250
+ ).action(async (options) => {
251
+ const spaceParams = runOrExit(() => resolveSpaceSelector(options));
252
+ const qs = buildFileQueryString(options.path, spaceParams);
253
+ startSpinner("Resolving URL...");
254
+ const response = await httpGet(
255
+ `/workspaces/${options.workspace}/files/url${qs}`
256
+ );
257
+ if (!response.ok) {
258
+ stopSpinner(false, "Failed");
259
+ if (response.status === 404) {
260
+ print(`${colors.red}\u2620 ${options.path} does not exist${colors.reset}`);
261
+ } else if (response.status === 400) {
262
+ printError(`Error: ${JSON.stringify(response.data)}`);
263
+ } else {
264
+ printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`);
265
+ }
266
+ process.exit(1);
267
+ }
268
+ stopSpinner(true, response.data.path);
269
+ print(`${colors.cyan}${response.data.url}${colors.reset}`);
270
+ });
271
+ addSpaceOptions(
272
+ file.command("list").description("List directory contents").option("-p, --path <path>", "Directory path", "/")
273
+ ).action(async (options) => {
274
+ const spaceParams = runOrExit(() => resolveSpaceSelector(options));
275
+ const qs = buildFileQueryString(options.path, spaceParams);
133
276
  startSpinner("Listing files...");
134
277
  const response = await httpGet(
135
- `/workspaces/${options.workspace}/files/list?path=${encodeURIComponent(options.path)}&space=${space}`
278
+ `/workspaces/${options.workspace}/files/list${qs}`
136
279
  );
137
280
  if (!response.ok) {
138
281
  stopSpinner(false, "Failed");
@@ -157,27 +300,22 @@ function registerFileCommand(program2) {
157
300
  }
158
301
  }
159
302
  });
160
- file.command("read").description("Read file content").option("-w, --workspace <id>", "Workspace ID").option("-p, --path <path>", "File path").option("-s, --space <type>", "Space type: personal or team", "team").option("-u, --url <url>", "Moxt file URL (e.g., https://moxt.ai/w/{workspaceId}/{fileId})").action(async (options) => {
161
- if (options.url && (options.workspace || options.path)) {
162
- printError("Error: --url cannot be used with --workspace or --path");
163
- process.exit(1);
164
- }
165
- if (!options.url && (!options.workspace || !options.path)) {
166
- printError("Error: Either --url or both --workspace and --path are required");
167
- process.exit(1);
168
- }
303
+ file.command("read").description("Read file content").option("-w, --workspace <workspaceId>", "Workspace ID").option("-s, --space <name>", "Space name (personal or teamspace name)").option("--personal", "Use personal space (default)").option("--team-space-id <teamSpaceId>", "Team space ID").option("--teammate-id <teammateId>", "Teammate ID (teammate space)").option("-p, --path <path>", "File path").option("-u, --url <url>", "Moxt file URL (e.g., https://moxt.ai/w/{workspaceId}/{fileId})").action(async (options) => {
304
+ const mode = runOrExit(() => resolveReadMode(options));
169
305
  startSpinner("Reading file...");
170
306
  let response;
171
307
  let displayPath;
172
- if (options.url) {
173
- displayPath = options.url;
308
+ if (mode.kind === "by-url") {
309
+ displayPath = mode.url;
174
310
  response = await httpGet(
175
- `/files/read-by-url?url=${encodeURIComponent(options.url)}`
311
+ `/files/read-by-url?url=${encodeURIComponent(mode.url)}`
176
312
  );
177
313
  } else {
178
- displayPath = options.path;
314
+ displayPath = mode.path;
315
+ const spaceParams = runOrExit(() => resolveSpaceSelector(options));
316
+ const qs = buildFileQueryString(mode.path, spaceParams);
179
317
  response = await httpGet(
180
- `/workspaces/${options.workspace}/files/read?path=${encodeURIComponent(options.path)}&space=${options.space}`
318
+ `/workspaces/${mode.workspace}/files/read${qs}`
181
319
  );
182
320
  }
183
321
  if (!response.ok) {
@@ -198,9 +336,9 @@ function registerFileCommand(program2) {
198
336
  stopSpinner(true, "Done");
199
337
  print(content ?? "");
200
338
  });
201
- 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(
339
+ file.command("put").description("Upload a file").option("-w, --workspace <workspaceId>", "Workspace ID").option("-s, --space <name>", "Space name (personal or teamspace name)").option("--personal", "Use personal space (default)").option("--team-space-id <teamSpaceId>", "Team space ID").option("--teammate-id <teammateId>", "Teammate ID (teammate space)").option("-p, --path <path>", "Remote file path").option("-u, --url <url>", "Moxt file URL (e.g., https://moxt.ai/w/{workspaceId}/{fileId})").requiredOption("-l, --local-path <localPath>", "Local file path").option("-r, --recursive", "Create parent directories if needed").action(
202
340
  async (options) => {
203
- const space = options.space;
341
+ const mode = runOrExit(() => resolveWriteMode(options));
204
342
  if (!fs.existsSync(options.localPath)) {
205
343
  print(`${colors.red}\u2620 Local file not found: ${options.localPath}${colors.reset}`);
206
344
  process.exit(1);
@@ -222,19 +360,35 @@ function registerFileCommand(program2) {
222
360
  }
223
361
  const content = buffer.toString("utf8");
224
362
  startSpinner("Uploading...");
225
- const response = await httpPut(
226
- `/workspaces/${options.workspace}/files/write`,
227
- {
228
- path: options.path,
229
- content,
230
- space,
231
- recursive: options.recursive ?? false
232
- }
233
- );
363
+ let response;
364
+ let displayPath;
365
+ if (mode.kind === "by-url") {
366
+ displayPath = mode.url;
367
+ response = await httpPut("/files/write-by-url", {
368
+ url: mode.url,
369
+ content
370
+ });
371
+ } else {
372
+ displayPath = mode.path;
373
+ const spaceParams = runOrExit(() => resolveSpaceSelector(options));
374
+ response = await httpPut(
375
+ `/workspaces/${mode.workspace}/files/write`,
376
+ {
377
+ path: mode.path,
378
+ content,
379
+ recursive: options.recursive ?? false,
380
+ ...spaceParams
381
+ }
382
+ );
383
+ }
234
384
  if (!response.ok) {
235
385
  stopSpinner(false, "Failed");
236
386
  if (response.status === 404) {
237
- print(`${colors.red}\u2620 Parent directory does not exist${colors.reset}`);
387
+ if (mode.kind === "by-url") {
388
+ print(`${colors.red}\u2620 ${displayPath} does not exist${colors.reset}`);
389
+ } else {
390
+ print(`${colors.red}\u2620 Parent directory does not exist${colors.reset}`);
391
+ }
238
392
  } else if (response.status === 400) {
239
393
  printError(`Error: ${JSON.stringify(response.data)}`);
240
394
  } else {
@@ -246,16 +400,18 @@ function registerFileCommand(program2) {
246
400
  stopSpinner(true, `${action}: ${response.data.path}`);
247
401
  }
248
402
  );
249
- 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(
403
+ addSpaceOptions(
404
+ file.command("mkdir").description("Create a directory").requiredOption("-p, --path <path>", "Directory path").option("-r, --recursive", "Create parent directories if needed")
405
+ ).action(
250
406
  async (options) => {
251
- const space = options.space;
407
+ const spaceParams = runOrExit(() => resolveSpaceSelector(options));
252
408
  startSpinner("Creating directory...");
253
409
  const response = await httpPost(
254
410
  `/workspaces/${options.workspace}/files/mkdir`,
255
411
  {
256
412
  path: options.path,
257
- space,
258
- recursive: options.recursive ?? false
413
+ recursive: options.recursive ?? false,
414
+ ...spaceParams
259
415
  }
260
416
  );
261
417
  if (!response.ok) {
@@ -273,15 +429,17 @@ function registerFileCommand(program2) {
273
429
  stopSpinner(true, `${action}: ${response.data.path}`);
274
430
  }
275
431
  );
276
- 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(
432
+ addSpaceOptions(
433
+ file.command("del").description("Delete a file or empty directory").requiredOption("-p, --path <path>", "File or directory path")
434
+ ).action(
277
435
  async (options) => {
278
- const space = options.space;
436
+ const spaceParams = runOrExit(() => resolveSpaceSelector(options));
279
437
  startSpinner("Deleting...");
280
438
  const response = await httpDelete(
281
439
  `/workspaces/${options.workspace}/files/delete`,
282
440
  {
283
441
  path: options.path,
284
- space
442
+ ...spaceParams
285
443
  }
286
444
  );
287
445
  if (!response.ok) {
@@ -402,14 +560,39 @@ function registerWorkspaceCommand(program2) {
402
560
  }
403
561
  }
404
562
  });
563
+ const space = program2.command("space").description("Manage spaces");
564
+ space.command("list").description("List accessible spaces in a workspace").requiredOption("-w, --workspace <workspaceId>", "Workspace ID").action(async (options) => {
565
+ const { workspace: workspaceId } = options;
566
+ startSpinner("Fetching spaces...");
567
+ const response = await httpGet(`/workspaces/${workspaceId}/spaces`);
568
+ if (!response.ok) {
569
+ stopSpinner(false, "Failed to fetch spaces");
570
+ printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`);
571
+ process.exit(1);
572
+ }
573
+ const { spaces } = response.data;
574
+ if (spaces.length === 0) {
575
+ stopSpinner(true, "No spaces found.");
576
+ return;
577
+ }
578
+ stopSpinner(true, `Found ${spaces.length} space(s)`);
579
+ print(
580
+ `${colors.bold}TYPE${colors.reset} ${colors.bold}TEAM_SPACE_ID${colors.reset} ${colors.bold}TEAMMATE_ID${colors.reset} ${colors.bold}NAME${colors.reset}`
581
+ );
582
+ for (const s of spaces) {
583
+ const teamSpaceId = s.teamSpaceId ?? "";
584
+ const teammateId = s.agentId != null ? String(s.agentId) : "";
585
+ print(`${s.type} ${teamSpaceId} ${teammateId} ${s.name}`);
586
+ }
587
+ });
405
588
  }
406
589
 
407
590
  // src/index.ts
408
591
  updateNotifier({
409
- pkg: { name: "@moxt-ai/cli", version: "0.1.9" }
592
+ pkg: { name: "@moxt-ai/cli", version: "0.2.1" }
410
593
  }).notify();
411
594
  var program = new Command();
412
- program.name("moxt").description("Moxt CLI - AI Workspace").version("0.1.9").action(() => {
595
+ program.name("moxt").description("Moxt CLI - AI Workspace").version("0.2.1").action(() => {
413
596
  program.help();
414
597
  });
415
598
  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 * Detect if a Buffer contains binary content.\n * Text files must not contain control characters (except tab, newline, carriage return).\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 // control chars except 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 .option('-w, --workspace <id>', 'Workspace ID')\n .option('-p, --path <path>', 'File path')\n .option('-s, --space <type>', 'Space type: personal or team', 'team')\n .option('-u, --url <url>', 'Moxt file URL (e.g., https://moxt.ai/w/{workspaceId}/{fileId})')\n .action(async (options: { workspace?: string; path?: string; space: string; url?: string }) => {\n // Validate mutually exclusive options\n if (options.url && (options.workspace || options.path)) {\n printError('Error: --url cannot be used with --workspace or --path')\n process.exit(1)\n }\n if (!options.url && (!options.workspace || !options.path)) {\n printError('Error: Either --url or both --workspace and --path are required')\n process.exit(1)\n }\n\n startSpinner('Reading file...')\n\n let response: { ok: boolean; status: number; data: FileReadResponse }\n let displayPath: string\n\n if (options.url) {\n displayPath = options.url\n response = await httpGet<FileReadResponse>(\n `/files/read-by-url?url=${encodeURIComponent(options.url)}`,\n )\n } else {\n displayPath = options.path!\n response = await httpGet<FileReadResponse>(\n `/workspaces/${options.workspace}/files/read?path=${encodeURIComponent(options.path!)}&space=${options.space}`,\n )\n }\n\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n if (response.status === 404) {\n print(`${colors.red}☠ ${displayPath} 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}☠ ${displayPath} 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 // check local file exists\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 // check it is a file, not a directory\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 // check file size (10MB limit)\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 // read file and check for binary content\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 colors\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,gBAA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B;AACvE;AAAA,MACJ;AAEA,YAAM,iBAAiB,MAAM,WAAW,eAAe,WAAW,YAAY,OAAO,MAAM,EAAE;AAE7F,UAAI,eAAe,IAAI;AACnB,cAAM,GAAG,OAAO,KAAK,SAAI,OAAO,KAAK,IAAI,KAAK,YAAY;AAAA,MAC9D,OAAO;AACH,cAAM,GAAG,OAAO,GAAG,SAAI,OAAO,KAAK,IAAI,KAAK,cAAc,KAAK,UAAU,eAAe,IAAI,CAAC,EAAE;AAAA,MACnG;AAAA,IACJ;AAAA,EACJ,CAAC;AACT;;;AP5IA,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","members"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/commands/file.ts","../src/utils/file-selector.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 {\n buildFileQueryString,\n isBinaryContent,\n resolveReadMode,\n resolveSpaceSelector,\n resolveWriteMode,\n SpaceOptions,\n SpaceOptionsError,\n} from '../utils/file-selector.js'\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\n/**\n * Call a pure resolver that may throw SpaceOptionsError; on error, print the\n * message and exit(1). This keeps the CLI's user-facing contract (stderr +\n * exit code 1) identical to the previous inlined implementation, while the\n * resolver itself stays pure and unit-testable.\n */\nfunction runOrExit<T>(fn: () => T): T {\n try {\n return fn()\n } catch (err) {\n if (err instanceof SpaceOptionsError) {\n printError(err.message)\n process.exit(1)\n }\n throw err\n }\n}\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\ninterface FileUrlResponse {\n path: string\n url: string\n}\n\nfunction addSpaceOptions(cmd: Command): Command {\n return cmd\n .requiredOption('-w, --workspace <workspaceId>', 'Workspace ID')\n .option('-s, --space <name>', 'Space name (personal or teamspace name)')\n .option('--personal', 'Use personal space (default)')\n .option('--team-space-id <teamSpaceId>', 'Team space ID')\n .option('--teammate-id <teammateId>', 'Teammate ID (teammate space)')\n}\n\nexport function registerFileCommand(program: Command): void {\n const file = program.command('file').description('File operations')\n\n addSpaceOptions(\n file.command('get-url')\n .description('Resolve the shareable browser URL for a file')\n .requiredOption('-p, --path <path>', 'File path'),\n ).action(async (options: SpaceOptions & { path: string }) => {\n const spaceParams = runOrExit(() => resolveSpaceSelector(options))\n const qs = buildFileQueryString(options.path, spaceParams)\n\n startSpinner('Resolving URL...')\n const response = await httpGet<FileUrlResponse>(\n `/workspaces/${options.workspace}/files/url${qs}`,\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 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 stopSpinner(true, response.data.path)\n print(`${colors.cyan}${response.data.url}${colors.reset}`)\n })\n\n addSpaceOptions(\n file.command('list')\n .description('List directory contents')\n .option('-p, --path <path>', 'Directory path', '/'),\n ).action(async (options: SpaceOptions & { path: string }) => {\n const spaceParams = runOrExit(() => resolveSpaceSelector(options))\n const qs = buildFileQueryString(options.path, spaceParams)\n\n startSpinner('Listing files...')\n const response = await httpGet<FileReadResponse>(\n `/workspaces/${options.workspace}/files/list${qs}`,\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 .option('-w, --workspace <workspaceId>', 'Workspace ID')\n .option('-s, --space <name>', 'Space name (personal or teamspace name)')\n .option('--personal', 'Use personal space (default)')\n .option('--team-space-id <teamSpaceId>', 'Team space ID')\n .option('--teammate-id <teammateId>', 'Teammate ID (teammate space)')\n .option('-p, --path <path>', 'File path')\n .option('-u, --url <url>', 'Moxt file URL (e.g., https://moxt.ai/w/{workspaceId}/{fileId})')\n .action(async (options: Partial<SpaceOptions> & { path?: string; url?: string }) => {\n const mode = runOrExit(() => resolveReadMode(options))\n\n startSpinner('Reading file...')\n\n let response: { ok: boolean; status: number; data: FileReadResponse }\n let displayPath: string\n\n if (mode.kind === 'by-url') {\n displayPath = mode.url\n response = await httpGet<FileReadResponse>(\n `/files/read-by-url?url=${encodeURIComponent(mode.url)}`,\n )\n } else {\n displayPath = mode.path\n const spaceParams = runOrExit(() => resolveSpaceSelector(options as SpaceOptions))\n const qs = buildFileQueryString(mode.path, spaceParams)\n response = await httpGet<FileReadResponse>(\n `/workspaces/${mode.workspace}/files/read${qs}`,\n )\n }\n\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n if (response.status === 404) {\n print(`${colors.red}☠ ${displayPath} 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}☠ ${displayPath} 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 .option('-w, --workspace <workspaceId>', 'Workspace ID')\n .option('-s, --space <name>', 'Space name (personal or teamspace name)')\n .option('--personal', 'Use personal space (default)')\n .option('--team-space-id <teamSpaceId>', 'Team space ID')\n .option('--teammate-id <teammateId>', 'Teammate ID (teammate space)')\n .option('-p, --path <path>', 'Remote file path')\n .option('-u, --url <url>', 'Moxt file URL (e.g., https://moxt.ai/w/{workspaceId}/{fileId})')\n .requiredOption('-l, --local-path <localPath>', 'Local file path')\n .option('-r, --recursive', 'Create parent directories if needed')\n .action(\n async (options: Partial<SpaceOptions> & {\n path?: string\n url?: string\n localPath: string\n recursive?: boolean\n }) => {\n const mode = runOrExit(() => resolveWriteMode(options))\n\n // check local file exists\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 // check it is a file, not a directory\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 // check file size (10MB limit)\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 // read file and check for binary content\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\n let response: { ok: boolean; status: number; data: FileWriteResponse }\n let displayPath: string\n\n if (mode.kind === 'by-url') {\n displayPath = mode.url\n response = await httpPut<FileWriteResponse>('/files/write-by-url', {\n url: mode.url,\n content,\n })\n } else {\n displayPath = mode.path\n const spaceParams = runOrExit(() => resolveSpaceSelector(options as SpaceOptions))\n response = await httpPut<FileWriteResponse>(\n `/workspaces/${mode.workspace}/files/write`,\n {\n path: mode.path,\n content,\n recursive: options.recursive ?? false,\n ...spaceParams,\n },\n )\n }\n\n if (!response.ok) {\n stopSpinner(false, 'Failed')\n if (response.status === 404) {\n if (mode.kind === 'by-url') {\n print(`${colors.red}☠ ${displayPath} does not exist${colors.reset}`)\n } else {\n print(`${colors.red}☠ Parent directory does not exist${colors.reset}`)\n }\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 addSpaceOptions(\n file.command('mkdir')\n .description('Create a directory')\n .requiredOption('-p, --path <path>', 'Directory path')\n .option('-r, --recursive', 'Create parent directories if needed'),\n ).action(\n async (options: SpaceOptions & {\n path: string\n recursive?: boolean\n }) => {\n const spaceParams = runOrExit(() => resolveSpaceSelector(options))\n\n startSpinner('Creating directory...')\n const response = await httpPost<MkdirResponse>(\n `/workspaces/${options.workspace}/files/mkdir`,\n {\n path: options.path,\n recursive: options.recursive ?? false,\n ...spaceParams,\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 addSpaceOptions(\n file.command('del')\n .description('Delete a file or empty directory')\n .requiredOption('-p, --path <path>', 'File or directory path'),\n ).action(\n async (options: SpaceOptions & {\n path: string\n }) => {\n const spaceParams = runOrExit(() => resolveSpaceSelector(options))\n\n startSpinner('Deleting...')\n const response = await httpDelete<DeleteResponse>(\n `/workspaces/${options.workspace}/files/delete`,\n {\n path: options.path,\n ...spaceParams,\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","/**\n * Pure logic for resolving file-command space selectors and building request URLs.\n *\n * These functions are extracted from commands/file.ts so they can be unit tested\n * without spawning the CLI or mocking process.exit. All error conditions are\n * surfaced as thrown Errors; action handlers are responsible for turning them\n * into user-facing output and exit codes.\n */\n\nexport interface SpaceOptions {\n workspace: string\n space?: string\n personal?: boolean\n teamSpaceId?: string\n teammateId?: string\n}\n\nexport interface SpaceParams {\n space?: string\n teamSpaceId?: string\n agentId?: number\n}\n\n/**\n * Error thrown when selector options violate a contract (mutually exclusive,\n * wrong format, etc). Action handlers catch this and print the message before\n * exiting with code 1.\n */\nexport class SpaceOptionsError extends Error {\n constructor(message: string) {\n super(message)\n this.name = 'SpaceOptionsError'\n }\n}\n\n/**\n * Resolve mutually-exclusive space selector flags into normalized request params.\n *\n * Priority (only one must be set): --team-space-id > --teammate-id > --personal > -s <name>.\n * When none is set, returns empty params (server treats this as personal space).\n */\nexport function resolveSpaceSelector(options: SpaceOptions): SpaceParams {\n // Destructure first so TypeScript's control-flow analysis can narrow each\n // field through the subsequent non-null / non-empty checks without having\n // to re-read options.* at the point of use (which would lose narrowing).\n const { space, teamSpaceId, teammateId } = options\n const personalIsSet = options.personal === true\n\n // Count \"user-set\" selectors explicitly so the mutual-exclusion check\n // reflects intent (\"which flags did the user pass?\") rather than a\n // generic truthiness filter. This keeps the mutual-exclusion check\n // cleanly separated from the downstream format validation (e.g.\n // `parsed <= 0` for teammateId).\n const spaceIsSet = space != null && space !== ''\n const teamSpaceIdIsSet = teamSpaceId != null && teamSpaceId !== ''\n const teammateIdIsSet = teammateId != null && teammateId !== ''\n const selectorCount =\n (spaceIsSet ? 1 : 0) + (personalIsSet ? 1 : 0) + (teamSpaceIdIsSet ? 1 : 0) + (teammateIdIsSet ? 1 : 0)\n if (selectorCount > 1) {\n throw new SpaceOptionsError(\n 'Error: -s, --personal, --team-space-id, and --teammate-id are mutually exclusive.',\n )\n }\n\n // Dispatch via the underlying field checks (not `*IsSet`) so TypeScript\n // narrows each local to `string`, letting us return without `!`.\n if (teamSpaceId != null && teamSpaceId !== '') {\n return { teamSpaceId }\n }\n if (teammateId != null && teammateId !== '') {\n const parsed = Number.parseInt(teammateId, 10)\n if (!Number.isInteger(parsed) || parsed <= 0 || String(parsed) !== teammateId) {\n throw new SpaceOptionsError(\n `Error: --teammate-id must be a positive integer, got \"${teammateId}\".`,\n )\n }\n return { agentId: parsed }\n }\n if (personalIsSet) {\n return { space: 'personal' }\n }\n if (space != null && space !== '') {\n return { space }\n }\n return {}\n}\n\n/**\n * Build the `?path=...&space=...` query string for file endpoints.\n * Returns empty string when no params are set (caller should not append `?`).\n * Values are URL-encoded via URLSearchParams.\n *\n * An empty-string `path` is treated as \"not provided\" and omitted from the query;\n * callers should pass `undefined` rather than `\"\"` when no path is intended.\n */\nexport function buildFileQueryString(path: string | undefined, spaceParams: SpaceParams): string {\n const params = new URLSearchParams()\n if (path != null && path !== '') {\n params.set('path', path)\n }\n if (spaceParams.space) {\n params.set('space', spaceParams.space)\n }\n if (spaceParams.teamSpaceId) {\n params.set('teamSpaceId', spaceParams.teamSpaceId)\n }\n if (spaceParams.agentId != null) {\n params.set('agentId', String(spaceParams.agentId))\n }\n const qs = params.toString()\n return qs ? `?${qs}` : ''\n}\n\n/**\n * Detect if a Buffer contains binary content by sampling the first 8192 bytes.\n * Control characters other than tab (9), LF (10), and CR (13) are treated as binary.\n */\nexport function 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 if (byte < 32 && byte !== 9 && byte !== 10 && byte !== 13) {\n return true\n }\n }\n\n return false\n}\n\n/**\n * Validate `file read` command's top-level mutually-exclusive options (-u vs -w/-p).\n * Returns the resolved mode ('by-url' or 'by-path'). Throws SpaceOptionsError on conflict.\n *\n * Empty strings are treated as \"not provided\" (commander never passes empty strings\n * for optional flags, but callers outside the CLI context should pass undefined instead\n * of \"\" to avoid unexpected branch behaviour).\n */\nexport type ReadMode = { kind: 'by-url'; url: string } | { kind: 'by-path'; workspace: string; path: string }\n\nexport function resolveReadMode(options: {\n url?: string\n workspace?: string\n path?: string\n}): ReadMode {\n if (options.url && options.workspace) {\n throw new SpaceOptionsError('Error: --url cannot be used with --workspace')\n }\n if (options.url && options.path) {\n throw new SpaceOptionsError('Error: --url cannot be used with --path')\n }\n if (!options.url && !options.workspace) {\n throw new SpaceOptionsError('Error: Either --url or --workspace is required')\n }\n if (!options.url && !options.path) {\n throw new SpaceOptionsError('Error: --path is required when not using --url')\n }\n\n if (options.url) {\n return { kind: 'by-url', url: options.url }\n }\n // At this point both workspace and path are guaranteed non-empty by the guards\n // above. Use explicit checks so TypeScript narrows the types without needing `!`.\n if (!options.workspace) {\n throw new SpaceOptionsError('Error: Either --url or --workspace is required')\n }\n if (!options.path) {\n throw new SpaceOptionsError('Error: --path is required when not using --url')\n }\n return { kind: 'by-path', workspace: options.workspace, path: options.path }\n}\n\n/**\n * Validate `file put` command's top-level mutually-exclusive options (-u vs -w/-p).\n *\n * By-URL puts overwrite an existing file (the URL already identifies it), so\n * `--recursive` is meaningless in that mode and is rejected outright to keep the\n * user's intent unambiguous.\n */\nexport type WriteMode =\n | { kind: 'by-url'; url: string }\n | { kind: 'by-path'; workspace: string; path: string }\n\nexport function resolveWriteMode(options: {\n url?: string\n workspace?: string\n path?: string\n recursive?: boolean\n}): WriteMode {\n if (options.url && options.workspace) {\n throw new SpaceOptionsError('Error: --url cannot be used with --workspace')\n }\n if (options.url && options.path) {\n throw new SpaceOptionsError('Error: --url cannot be used with --path')\n }\n if (options.url && options.recursive) {\n throw new SpaceOptionsError('Error: --recursive cannot be used with --url (the file must already exist)')\n }\n if (!options.url && !options.workspace) {\n throw new SpaceOptionsError('Error: Either --url or --workspace is required')\n }\n if (!options.url && !options.path) {\n throw new SpaceOptionsError('Error: --path is required when not using --url')\n }\n\n if (options.url) {\n return { kind: 'by-url', url: options.url }\n }\n return { kind: 'by-path', workspace: options.workspace!, path: options.path! }\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 colors\nexport const colors = {\n bold: '\\x1b[1m',\n blue: '\\x1b[1;34m',\n green: '\\x1b[32m',\n red: '\\x1b[31m',\n cyan: '\\x1b[36m',\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, httpDelete } 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\ninterface SpaceItem {\n type: 'personal' | 'team' | 'teammate'\n name: string\n teamSpaceId: string | null\n agentId: number | null\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 const space = program.command('space').description('Manage spaces')\n\n space\n .command('list')\n .description('List accessible spaces 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 spaces...')\n const response = await httpGet<{ spaces: SpaceItem[] }>(`/workspaces/${workspaceId}/spaces`)\n\n if (!response.ok) {\n stopSpinner(false, 'Failed to fetch spaces')\n printError(`Error [${response.status}]: ${JSON.stringify(response.data)}`)\n process.exit(1)\n }\n\n const { spaces } = response.data\n if (spaces.length === 0) {\n stopSpinner(true, 'No spaces found.')\n return\n }\n\n stopSpinner(true, `Found ${spaces.length} space(s)`)\n\n print(\n `${colors.bold}TYPE${colors.reset}\\t${colors.bold}TEAM_SPACE_ID${colors.reset}\\t${colors.bold}TEAMMATE_ID${colors.reset}\\t${colors.bold}NAME${colors.reset}`,\n )\n for (const s of spaces) {\n const teamSpaceId = s.teamSpaceId ?? ''\n const teammateId = s.agentId != null ? String(s.agentId) : ''\n print(`${s.type}\\t${teamSpaceId}\\t${teammateId}\\t${s.name}`)\n }\n })\n\n}\n"],"mappings":";;;AAAA,SAAS,eAAe;AACxB,OAAO,oBAAoB;;;ACD3B,YAAY,QAAQ;;;AC4Bb,IAAM,oBAAN,cAAgC,MAAM;AAAA,EACzC,YAAY,SAAiB;AACzB,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EAChB;AACJ;AAQO,SAAS,qBAAqB,SAAoC;AAIrE,QAAM,EAAE,OAAO,aAAa,WAAW,IAAI;AAC3C,QAAM,gBAAgB,QAAQ,aAAa;AAO3C,QAAM,aAAa,SAAS,QAAQ,UAAU;AAC9C,QAAM,mBAAmB,eAAe,QAAQ,gBAAgB;AAChE,QAAM,kBAAkB,cAAc,QAAQ,eAAe;AAC7D,QAAM,iBACD,aAAa,IAAI,MAAM,gBAAgB,IAAI,MAAM,mBAAmB,IAAI,MAAM,kBAAkB,IAAI;AACzG,MAAI,gBAAgB,GAAG;AACnB,UAAM,IAAI;AAAA,MACN;AAAA,IACJ;AAAA,EACJ;AAIA,MAAI,eAAe,QAAQ,gBAAgB,IAAI;AAC3C,WAAO,EAAE,YAAY;AAAA,EACzB;AACA,MAAI,cAAc,QAAQ,eAAe,IAAI;AACzC,UAAM,SAAS,OAAO,SAAS,YAAY,EAAE;AAC7C,QAAI,CA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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.9",
3
+ "version": "0.2.1",
4
4
  "description": "Moxt - The Agent-Native Workspace",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -14,6 +14,8 @@
14
14
  "build": "tsup",
15
15
  "dev": "tsup --watch",
16
16
  "test": "vitest run",
17
+ "test:e2e": "vitest run --config vitest.e2e.config.ts",
18
+ "typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.test.json",
17
19
  "prepublishOnly": "pnpm build",
18
20
  "release": "pnpm build && npm publish --access public"
19
21
  },