@odysx/codemind 0.0.0-stage → 0.1.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.
Files changed (108) hide show
  1. package/README.md +293 -2
  2. package/dist/commands/agents.d.ts +2 -0
  3. package/dist/commands/agents.js +91 -0
  4. package/dist/commands/auth.d.ts +2 -0
  5. package/dist/commands/auth.js +35 -0
  6. package/dist/commands/chat.d.ts +2 -0
  7. package/dist/commands/chat.js +180 -0
  8. package/dist/commands/keys.d.ts +2 -0
  9. package/dist/commands/keys.js +81 -0
  10. package/dist/commands/local.d.ts +2 -0
  11. package/dist/commands/local.js +325 -0
  12. package/dist/commands/mcp.d.ts +2 -0
  13. package/dist/commands/mcp.js +73 -0
  14. package/dist/commands/prompts.d.ts +2 -0
  15. package/dist/commands/prompts.js +59 -0
  16. package/dist/commands/skills.d.ts +2 -0
  17. package/dist/commands/skills.js +41 -0
  18. package/dist/core/auth/index.d.ts +10 -0
  19. package/dist/core/auth/index.js +82 -0
  20. package/dist/core/config/index.d.ts +47 -0
  21. package/dist/core/config/index.js +118 -0
  22. package/dist/core/history.d.ts +14 -0
  23. package/dist/core/history.js +80 -0
  24. package/dist/core/markdown-renderer.d.ts +47 -0
  25. package/dist/core/markdown-renderer.js +385 -0
  26. package/dist/core/permissions/index.d.ts +31 -0
  27. package/dist/core/permissions/index.js +64 -0
  28. package/dist/core/provider/external.d.ts +28 -0
  29. package/dist/core/provider/external.js +248 -0
  30. package/dist/core/provider/index.d.ts +138 -0
  31. package/dist/core/provider/index.js +510 -0
  32. package/dist/core/registry/index.d.ts +25 -0
  33. package/dist/core/registry/index.js +216 -0
  34. package/dist/core/schema/types.d.ts +93 -0
  35. package/dist/core/schema/types.js +12 -0
  36. package/dist/core/terminal.d.ts +40 -0
  37. package/dist/core/terminal.js +134 -0
  38. package/dist/core/workspace/index.d.ts +35 -0
  39. package/dist/core/workspace/index.js +194 -0
  40. package/dist/index.d.ts +10 -0
  41. package/dist/index.js +393 -0
  42. package/dist/ui/app.d.ts +3 -0
  43. package/dist/ui/app.js +554 -0
  44. package/dist/ui/commands/cases/catalog.d.ts +11 -0
  45. package/dist/ui/commands/cases/catalog.js +62 -0
  46. package/dist/ui/commands/cases/misc.d.ts +35 -0
  47. package/dist/ui/commands/cases/misc.js +245 -0
  48. package/dist/ui/commands/cases/tasks.d.ts +13 -0
  49. package/dist/ui/commands/cases/tasks.js +91 -0
  50. package/dist/ui/commands/runCommand.d.ts +22 -0
  51. package/dist/ui/commands/runCommand.js +136 -0
  52. package/dist/ui/components/AgentPicker.d.ts +11 -0
  53. package/dist/ui/components/AgentPicker.js +7 -0
  54. package/dist/ui/components/AuthPicker.d.ts +14 -0
  55. package/dist/ui/components/AuthPicker.js +7 -0
  56. package/dist/ui/components/Banner.d.ts +8 -0
  57. package/dist/ui/components/Banner.js +24 -0
  58. package/dist/ui/components/CommandMenu.d.ts +17 -0
  59. package/dist/ui/components/CommandMenu.js +21 -0
  60. package/dist/ui/components/ErrorBoundary.d.ts +24 -0
  61. package/dist/ui/components/ErrorBoundary.js +51 -0
  62. package/dist/ui/components/InputBar.d.ts +28 -0
  63. package/dist/ui/components/InputBar.js +108 -0
  64. package/dist/ui/components/KeysPanel.d.ts +12 -0
  65. package/dist/ui/components/KeysPanel.js +25 -0
  66. package/dist/ui/components/MessageView.d.ts +29 -0
  67. package/dist/ui/components/MessageView.js +107 -0
  68. package/dist/ui/components/PermissionPrompt.d.ts +10 -0
  69. package/dist/ui/components/PermissionPrompt.js +4 -0
  70. package/dist/ui/components/Pickers.d.ts +43 -0
  71. package/dist/ui/components/Pickers.js +33 -0
  72. package/dist/ui/components/SearchOverlay.d.ts +21 -0
  73. package/dist/ui/components/SearchOverlay.js +14 -0
  74. package/dist/ui/components/SessionPicker.d.ts +12 -0
  75. package/dist/ui/components/SessionPicker.js +8 -0
  76. package/dist/ui/components/WorkingIndicator.d.ts +10 -0
  77. package/dist/ui/components/WorkingIndicator.js +23 -0
  78. package/dist/ui/controls/ApiKeyEntry.d.ts +8 -0
  79. package/dist/ui/controls/ApiKeyEntry.js +5 -0
  80. package/dist/ui/controls/MultiSelect.d.ts +18 -0
  81. package/dist/ui/controls/MultiSelect.js +9 -0
  82. package/dist/ui/hooks/useAgentPicker.d.ts +14 -0
  83. package/dist/ui/hooks/useAgentPicker.js +53 -0
  84. package/dist/ui/hooks/useAuthFlow.d.ts +14 -0
  85. package/dist/ui/hooks/useAuthFlow.js +31 -0
  86. package/dist/ui/hooks/useKeysFlow.d.ts +17 -0
  87. package/dist/ui/hooks/useKeysFlow.js +130 -0
  88. package/dist/ui/hooks/useSessionPicker.d.ts +29 -0
  89. package/dist/ui/hooks/useSessionPicker.js +58 -0
  90. package/dist/ui/hooks/useTerminalSize.d.ts +6 -0
  91. package/dist/ui/hooks/useTerminalSize.js +29 -0
  92. package/dist/ui/input/keyRouter.d.ts +125 -0
  93. package/dist/ui/input/keyRouter.js +574 -0
  94. package/dist/ui/layouts/ScreenLayout.d.ts +98 -0
  95. package/dist/ui/layouts/ScreenLayout.js +56 -0
  96. package/dist/ui/shared/types.d.ts +143 -0
  97. package/dist/ui/shared/types.js +38 -0
  98. package/dist/ui/theme.d.ts +29 -0
  99. package/dist/ui/theme.js +54 -0
  100. package/dist/ui/utils/markdown.d.ts +74 -0
  101. package/dist/ui/utils/markdown.js +187 -0
  102. package/dist/ui/utils/mentions.d.ts +12 -0
  103. package/dist/ui/utils/mentions.js +28 -0
  104. package/dist/ui/utils/terminal-text.d.ts +33 -0
  105. package/dist/ui/utils/terminal-text.js +123 -0
  106. package/dist/ui/utils/text.d.ts +72 -0
  107. package/dist/ui/utils/text.js +171 -0
  108. package/package.json +50 -6
@@ -0,0 +1,81 @@
1
+ /**
2
+ * API key management commands — create, list, revoke, usage.
3
+ */
4
+ import { registerCommand } from "../core/registry/index.js";
5
+ import { apiCall, urlSegment } from "../core/provider/index.js";
6
+ const schema = {
7
+ name: "keys",
8
+ description: "Manage API keys for CLI access",
9
+ aliases: ["k"],
10
+ options: [],
11
+ };
12
+ function parseFlag(args, flag) {
13
+ const idx = args.indexOf(flag);
14
+ return idx !== -1 ? args[idx + 1] : undefined;
15
+ }
16
+ async function handleCreate(args) {
17
+ const name = parseFlag(args, "--name") ?? args.find((a) => !a.startsWith("-"));
18
+ if (!name)
19
+ return { exitCode: 1, error: "Usage: keys create --name <name>" };
20
+ const scopes = parseFlag(args, "--scopes");
21
+ const res = await apiCall("/api/v1/api-keys", {
22
+ method: "POST",
23
+ body: {
24
+ name,
25
+ scopes: scopes ? scopes.split(",").map((s) => s.trim()) : undefined,
26
+ rate_limit_rpm: parseFlag(args, "--rate-limit") ? Number(parseFlag(args, "--rate-limit")) : undefined,
27
+ daily_token_limit: parseFlag(args, "--daily-limit") ? Number(parseFlag(args, "--daily-limit")) : undefined,
28
+ },
29
+ });
30
+ if (!res.ok)
31
+ return { exitCode: 1, error: res.error };
32
+ // The secret is shown exactly once. If the server answers in a shape we
33
+ // don't recognise, say so — printing "undefined" as the key, next to a
34
+ // "save this key" warning, is worse than failing.
35
+ const key = res.data?.key;
36
+ if (typeof key !== "string" || !key) {
37
+ return {
38
+ exitCode: 1,
39
+ error: "Unexpected response: the server did not return the new key",
40
+ };
41
+ }
42
+ return {
43
+ exitCode: 0,
44
+ data: { ...(res.data.api_key ?? {}), key },
45
+ message: `\nKey created. Save this key — it cannot be retrieved later:\n\n ${key}\n`,
46
+ };
47
+ }
48
+ async function handleList() {
49
+ const res = await apiCall("/api/v1/api-keys");
50
+ if (!res.ok)
51
+ return { exitCode: 1, error: res.error };
52
+ return { exitCode: 0, data: res.data };
53
+ }
54
+ async function handleRevoke(keyId) {
55
+ if (!keyId)
56
+ return { exitCode: 1, error: "Usage: keys revoke <key-id>" };
57
+ const res = await apiCall(`/api/v1/api-keys/${urlSegment(keyId)}`, { method: "DELETE" });
58
+ if (!res.ok)
59
+ return { exitCode: 1, error: res.error };
60
+ return { exitCode: 0, message: `Key ${keyId} revoked` };
61
+ }
62
+ async function handleUsage(keyId) {
63
+ if (!keyId)
64
+ return { exitCode: 1, error: "Usage: keys usage <key-id>" };
65
+ const res = await apiCall(`/api/v1/api-keys/${urlSegment(keyId)}/usage/summary`);
66
+ if (!res.ok)
67
+ return { exitCode: 1, error: res.error };
68
+ return { exitCode: 0, data: res.data };
69
+ }
70
+ registerCommand(schema, async (_args, opts) => {
71
+ const sub = opts.args[0];
72
+ const rest = opts.args.slice(1);
73
+ switch (sub) {
74
+ case "create": return handleCreate(rest);
75
+ case "list": return handleList();
76
+ case "revoke": return handleRevoke(rest[0] ?? "");
77
+ case "usage": return handleUsage(rest[0] ?? "");
78
+ default: return handleList();
79
+ }
80
+ });
81
+ //# sourceMappingURL=keys.js.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=local.d.ts.map
@@ -0,0 +1,325 @@
1
+ /**
2
+ * Local execution commands — file read/write, shell exec, system access.
3
+ *
4
+ * All path-touching subcommands are confined to the workspace root
5
+ * (see core/workspace). Destructive ops additionally require the caller to
6
+ * pass --yes (the REPL's y/N prompt adds it after approval).
7
+ */
8
+ import { readFileSync, writeFileSync, existsSync, readdirSync, mkdirSync, statSync, unlinkSync, rmSync, renameSync, } from "node:fs";
9
+ import { execFileSync, execSync } from "node:child_process";
10
+ import { dirname, relative } from "node:path";
11
+ import { registerCommand } from "../core/registry/index.js";
12
+ import { getWorkspaceRoot, confinePath, checkCommand } from "../core/workspace/index.js";
13
+ import { decideLocal, getPermissionMode } from "../core/permissions/index.js";
14
+ const schema = {
15
+ name: "local",
16
+ description: "Local execution — file, shell, and system access (scoped to workspace)",
17
+ aliases: ["l"],
18
+ options: [],
19
+ };
20
+ /** Resolve a user path inside the workspace or produce a refusal result. */
21
+ function scoped(target, fallback = ".") {
22
+ const decision = confinePath(target ?? fallback);
23
+ if (!decision.ok || !decision.resolved) {
24
+ return { refused: { exitCode: 1, error: decision.error } };
25
+ }
26
+ return { abs: decision.resolved };
27
+ }
28
+ function handleRead(filePath, lines) {
29
+ const s = scoped(filePath);
30
+ if (s.refused)
31
+ return s.refused;
32
+ const resolved = s.abs;
33
+ if (!existsSync(resolved))
34
+ return { exitCode: 1, error: `File not found: ${resolved}` };
35
+ try {
36
+ const content = readFileSync(resolved, "utf-8");
37
+ if (lines) {
38
+ // `Number("")` is 0, so "5-" used to mean "slice(4, 0)" — an empty
39
+ // result printed as success. Parse explicitly and validate the range.
40
+ const match = /^(\d+)(?:-(\d*))?$/.exec(lines.trim());
41
+ const start = match ? Number(match[1]) : NaN;
42
+ const endRaw = match?.[2];
43
+ const end = endRaw === undefined || endRaw === "" ? undefined : Number(endRaw);
44
+ if (!match || !Number.isFinite(start) || start < 1) {
45
+ return { exitCode: 1, error: "Usage: --lines <start>-<end> (1-based)" };
46
+ }
47
+ if (end !== undefined && (!Number.isFinite(end) || end < start)) {
48
+ return { exitCode: 1, error: `Invalid line range: end (${endRaw}) is before start (${start})` };
49
+ }
50
+ const allLines = content.split("\n");
51
+ const stop = end ?? allLines.length;
52
+ const from = start - 1;
53
+ const sliced = allLines
54
+ .slice(from, stop)
55
+ .map((l, i) => `${start + i}: ${l}`);
56
+ return { exitCode: 0, data: sliced.join("\n"), formatted: true };
57
+ }
58
+ return { exitCode: 0, data: content, formatted: true };
59
+ }
60
+ catch (err) {
61
+ return { exitCode: 1, error: `Cannot read: ${err instanceof Error ? err.message : err}` };
62
+ }
63
+ }
64
+ function handleWrite(filePath, content) {
65
+ const s = scoped(filePath);
66
+ if (s.refused)
67
+ return s.refused;
68
+ const resolved = s.abs;
69
+ try {
70
+ const dir = dirname(resolved);
71
+ if (!existsSync(dir))
72
+ mkdirSync(dir, { recursive: true });
73
+ writeFileSync(resolved, content, "utf-8");
74
+ return { exitCode: 0, message: `Wrote ${resolved}` };
75
+ }
76
+ catch (err) {
77
+ return { exitCode: 1, error: `Cannot write: ${err instanceof Error ? err.message : err}` };
78
+ }
79
+ }
80
+ function handleExec(command, timeout) {
81
+ // Safety denylist runs before any process spawns.
82
+ const gate = checkCommand(command);
83
+ if (!gate.ok)
84
+ return { exitCode: 1, error: gate.error };
85
+ try {
86
+ const output = execSync(command, {
87
+ cwd: getWorkspaceRoot(),
88
+ timeout: (timeout ?? 30) * 1000,
89
+ encoding: "utf-8",
90
+ // 1 MB was below a chatty test suite's output; ENOBUFS then discarded
91
+ // the very output the user ran the command for.
92
+ maxBuffer: 32 * 1024 * 1024,
93
+ });
94
+ return { exitCode: 0, data: output, formatted: true };
95
+ }
96
+ catch (err) {
97
+ const e = err;
98
+ // A timeout or spawn failure has no exit status; saying "exited with code
99
+ // undefined" hid both the reason and the output the command produced.
100
+ const reason = e.killed || e.signal
101
+ ? `Command timed out after ${timeout ?? 30}s`
102
+ : `Command exited with code ${e.status ?? "unknown"}`;
103
+ return {
104
+ exitCode: e.status ?? 1,
105
+ data: e.stdout ?? e.stderr ?? String(err),
106
+ error: reason,
107
+ formatted: true,
108
+ };
109
+ }
110
+ }
111
+ function handleLs(dirPath, showHidden) {
112
+ const s = scoped(dirPath);
113
+ if (s.refused)
114
+ return s.refused;
115
+ const resolved = s.abs;
116
+ if (!existsSync(resolved))
117
+ return { exitCode: 1, error: `Directory not found: ${resolved}` };
118
+ try {
119
+ const entries = readdirSync(resolved, { withFileTypes: true });
120
+ const items = entries
121
+ .filter((e) => showHidden || !e.name.startsWith("."))
122
+ .map((e) => ({
123
+ name: e.name + (e.isDirectory() ? "/" : ""),
124
+ type: e.isDirectory() ? "dir" : "file",
125
+ }));
126
+ return { exitCode: 0, data: items };
127
+ }
128
+ catch (err) {
129
+ return { exitCode: 1, error: `Cannot list: ${err instanceof Error ? err.message : err}` };
130
+ }
131
+ }
132
+ function handlePwd() {
133
+ return { exitCode: 0, data: getWorkspaceRoot(), formatted: true };
134
+ }
135
+ function handleDelete(target) {
136
+ const s = scoped(target);
137
+ if (s.refused)
138
+ return s.refused;
139
+ const resolved = s.abs;
140
+ if (!existsSync(resolved))
141
+ return { exitCode: 1, error: `Not found: ${resolved}` };
142
+ // Refuse to delete the workspace root itself: every path is "inside" it, so
143
+ // a delete with no argument (or "." / "./") would otherwise wipe the tree.
144
+ const root = getWorkspaceRoot();
145
+ if (resolved === root) {
146
+ return { exitCode: 1, error: `Refused: cannot delete the workspace root (${root})` };
147
+ }
148
+ try {
149
+ const st = statSync(resolved);
150
+ if (st.isDirectory()) {
151
+ // rmSync is recursive+force in one call and never shells out, so paths
152
+ // containing quotes, spaces, or shell metacharacters are handled safely.
153
+ rmSync(resolved, { recursive: true, force: true });
154
+ return { exitCode: 0, message: `Deleted directory ${relative(root, resolved) || "."}` };
155
+ }
156
+ unlinkSync(resolved);
157
+ return { exitCode: 0, message: `Deleted ${relative(root, resolved)}` };
158
+ }
159
+ catch (err) {
160
+ return { exitCode: 1, error: `Cannot delete: ${err instanceof Error ? err.message : err}` };
161
+ }
162
+ }
163
+ function handleMove(from, to) {
164
+ if (!from || !to)
165
+ return { exitCode: 1, error: "Usage: local move <from> <to>" };
166
+ const src = scoped(from);
167
+ if (src.refused)
168
+ return src.refused;
169
+ const dst = scoped(to);
170
+ if (dst.refused)
171
+ return dst.refused;
172
+ if (!existsSync(src.abs))
173
+ return { exitCode: 1, error: `Not found: ${src.abs}` };
174
+ try {
175
+ const dir = dirname(dst.abs);
176
+ if (!existsSync(dir))
177
+ mkdirSync(dir, { recursive: true });
178
+ renameSync(src.abs, dst.abs);
179
+ return { exitCode: 0, message: `Moved ${relative(getWorkspaceRoot(), src.abs)} → ${relative(getWorkspaceRoot(), dst.abs)}` };
180
+ }
181
+ catch (err) {
182
+ return { exitCode: 1, error: `Cannot move: ${err instanceof Error ? err.message : err}` };
183
+ }
184
+ }
185
+ function handleWhich(command) {
186
+ // execFile avoids interpolating the command name into a shell string.
187
+ const lookup = process.platform === "win32" ? ["where", [command]] : ["which", [command]];
188
+ try {
189
+ const output = execFileSync(lookup[0], lookup[1], {
190
+ encoding: "utf-8",
191
+ stdio: ["pipe", "pipe", "pipe"],
192
+ });
193
+ return { exitCode: 0, data: output.trim(), formatted: true };
194
+ }
195
+ catch {
196
+ return { exitCode: 1, error: `${command} not found in PATH` };
197
+ }
198
+ }
199
+ function parseArgs(args) {
200
+ const result = {};
201
+ for (let i = 0; i < args.length; i++) {
202
+ const arg = args[i];
203
+ if (arg === "--path" || arg === "-p")
204
+ result.path = args[++i];
205
+ else if (arg === "--command" || arg === "-c")
206
+ result.command = args[++i];
207
+ else if (arg === "--content")
208
+ result.content = args[++i];
209
+ else if (arg === "--cwd")
210
+ result.cwd = args[++i];
211
+ else if (arg === "--yes" || arg === "-y")
212
+ result.yes = "true";
213
+ else if (arg === "--timeout")
214
+ result.timeout = args[++i];
215
+ else if (arg === "--lines")
216
+ result.lines = args[++i];
217
+ else if (arg === "--hidden" || arg === "-a")
218
+ result.hidden = "true";
219
+ else if (!arg.startsWith("-")) {
220
+ // Positional: first non-flag is the subcommand, then target, then the
221
+ // second path (used by `move`).
222
+ if (!result.sub)
223
+ result.sub = arg;
224
+ else if (!result.target)
225
+ result.target = arg;
226
+ else if (!result.moveTo)
227
+ result.moveTo = arg;
228
+ }
229
+ }
230
+ return result;
231
+ }
232
+ /** Subcommands that mutate state. The mode decides whether they may run. */
233
+ const GATED = new Set(["write", "exec", "delete", "move"]);
234
+ /** Reconstruct the command a `guide` decision hands back to the user. */
235
+ const commandLine = (sub, parsed) => {
236
+ const parts = ["odysx", "local", sub];
237
+ if (parsed.target)
238
+ parts.push(parsed.target);
239
+ if (parsed.moveTo)
240
+ parts.push(parsed.moveTo);
241
+ if (parsed.path && !parsed.target)
242
+ parts.push(parsed.path);
243
+ if (parsed.command)
244
+ parts.push("--command", JSON.stringify(parsed.command));
245
+ if (parsed.content !== undefined)
246
+ parts.push("--content", JSON.stringify(parsed.content));
247
+ if (parsed.lines)
248
+ parts.push("--lines", parsed.lines);
249
+ if (parsed.timeout)
250
+ parts.push("--timeout", parsed.timeout);
251
+ if (parsed.hidden)
252
+ parts.push("--hidden");
253
+ return parts.join(" ");
254
+ };
255
+ registerCommand(schema, async (_args, opts) => {
256
+ const parsed = parseArgs(opts.args);
257
+ const sub = parsed.sub ?? "pwd";
258
+ const approved = opts.yes === true || parsed.yes === "true";
259
+ const mode = getPermissionMode();
260
+ const decision = decideLocal(sub, mode);
261
+ // The mode is consulted before --yes: neither the flag nor an approval from
262
+ // the REPL can override a mode that refuses or hands the command back.
263
+ if (GATED.has(sub)) {
264
+ if (decision === "refuse") {
265
+ return {
266
+ exitCode: 1,
267
+ error: `Refused: '${sub}' is not allowed in ${mode} mode. Switch with /mode or --mode.`,
268
+ };
269
+ }
270
+ if (decision === "guide") {
271
+ // Deliberately exit 0: nothing failed, the user was handed the command.
272
+ return {
273
+ exitCode: 0,
274
+ message: `[guide] nothing was run. To do it yourself:\n\n ${commandLine(sub, parsed)}\n`,
275
+ formatted: true,
276
+ };
277
+ }
278
+ // "allow" (auto mode writes) and "ask" (needs --yes) both land here.
279
+ const needsApproval = decision === "ask";
280
+ if (needsApproval && !approved) {
281
+ return {
282
+ exitCode: 1,
283
+ error: `Refused: '${sub}' requires approval in ${mode} mode. Re-run with --yes.`,
284
+ };
285
+ }
286
+ }
287
+ switch (sub) {
288
+ case "read": return handleRead(parsed.target ?? parsed.path ?? ".", parsed.lines);
289
+ case "write": {
290
+ if (!parsed.target)
291
+ return { exitCode: 1, error: "Usage: local write <path> --content <text>" };
292
+ // Require --content explicitly. Defaulting to "" meant that forgetting
293
+ // the flag (or writing it last with no value) silently emptied an
294
+ // existing file — the most destructive possible reading of a typo.
295
+ if (parsed.content === undefined) {
296
+ return {
297
+ exitCode: 1,
298
+ error: "Refusing to write: --content is required (pass --content \"\" to write an empty file)",
299
+ };
300
+ }
301
+ return handleWrite(parsed.target, parsed.content);
302
+ }
303
+ case "exec": {
304
+ if (!parsed.command)
305
+ return { exitCode: 1, error: "Usage: local exec --command <cmd>" };
306
+ return handleExec(parsed.command, parsed.timeout ? Number(parsed.timeout) : undefined);
307
+ }
308
+ case "delete": {
309
+ if (!parsed.target)
310
+ return { exitCode: 1, error: "Usage: local delete <path>" };
311
+ return handleDelete(parsed.target);
312
+ }
313
+ case "move": return handleMove(parsed.target ?? "", parsed.moveTo ?? "");
314
+ case "ls": return handleLs(parsed.target ?? parsed.path ?? ".", parsed.hidden === "true");
315
+ case "pwd": return handlePwd();
316
+ case "which": {
317
+ if (!parsed.target)
318
+ return { exitCode: 1, error: "Usage: local which <command>" };
319
+ return handleWhich(parsed.target);
320
+ }
321
+ default:
322
+ return { exitCode: 1, error: `Unknown subcommand '${sub}'. Try: read, write, exec, ls, pwd, delete, move, which` };
323
+ }
324
+ });
325
+ //# sourceMappingURL=local.js.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=mcp.d.ts.map
@@ -0,0 +1,73 @@
1
+ /**
2
+ * MCP server commands — list, register, discover tools.
3
+ */
4
+ import { registerCommand } from "../core/registry/index.js";
5
+ import { apiCall } from "../core/provider/index.js";
6
+ const schema = {
7
+ name: "mcp",
8
+ description: "Manage MCP servers and discover tools",
9
+ options: [],
10
+ };
11
+ function parseFlag(args, flag) {
12
+ const idx = args.indexOf(flag);
13
+ return idx !== -1 ? args[idx + 1] : undefined;
14
+ }
15
+ async function handleList() {
16
+ const res = await apiCall("/api/v1/mcp-servers");
17
+ if (!res.ok)
18
+ return { exitCode: 1, error: res.error };
19
+ return { exitCode: 0, data: res.data };
20
+ }
21
+ async function handleGet(serverId) {
22
+ if (!serverId)
23
+ return { exitCode: 1, error: "Usage: mcp get <server-id>" };
24
+ const [serverRes, toolsRes] = await Promise.all([
25
+ apiCall(`/api/v1/mcp-servers/${serverId}`),
26
+ apiCall(`/api/v1/mcp-servers/${serverId}/tools`),
27
+ ]);
28
+ if (!serverRes.ok)
29
+ return { exitCode: 1, error: serverRes.error };
30
+ return { exitCode: 0, data: { ...serverRes.data, tools: toolsRes.ok ? toolsRes.data : [] } };
31
+ }
32
+ async function handleRegister(args) {
33
+ const name = parseFlag(args, "--name");
34
+ const url = parseFlag(args, "--url");
35
+ if (!name || !url)
36
+ return { exitCode: 1, error: "Usage: mcp register --name <name> --url <url>" };
37
+ const res = await apiCall("/api/v1/mcp-servers", {
38
+ method: "POST",
39
+ body: { name, url, transport_type: parseFlag(args, "--transport") ?? "http" },
40
+ });
41
+ if (!res.ok)
42
+ return { exitCode: 1, error: res.error };
43
+ return { exitCode: 0, data: res.data, message: `MCP server registered` };
44
+ }
45
+ async function handleTools(serverId) {
46
+ if (!serverId)
47
+ return { exitCode: 1, error: "Usage: mcp tools <server-id>" };
48
+ const res = await apiCall(`/api/v1/mcp-servers/${serverId}/tools`);
49
+ if (!res.ok)
50
+ return { exitCode: 1, error: res.error };
51
+ return { exitCode: 0, data: res.data };
52
+ }
53
+ async function handleDiscover(serverId) {
54
+ if (!serverId)
55
+ return { exitCode: 1, error: "Usage: mcp discover <server-id>" };
56
+ const res = await apiCall(`/api/v1/mcp-servers/${serverId}/discover`, { method: "POST" });
57
+ if (!res.ok)
58
+ return { exitCode: 1, error: res.error };
59
+ return { exitCode: 0, data: res.data };
60
+ }
61
+ registerCommand(schema, async (_args, opts) => {
62
+ const sub = opts.args[0];
63
+ const rest = opts.args.slice(1);
64
+ switch (sub) {
65
+ case "list": return handleList();
66
+ case "get": return handleGet(rest[0] ?? "");
67
+ case "register": return handleRegister(rest);
68
+ case "tools": return handleTools(rest[0] ?? "");
69
+ case "discover": return handleDiscover(rest[0] ?? "");
70
+ default: return handleList();
71
+ }
72
+ });
73
+ //# sourceMappingURL=mcp.js.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=prompts.d.ts.map
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Prompt template commands — list, get, resolve templates.
3
+ */
4
+ import { registerCommand } from "../core/registry/index.js";
5
+ import { apiCall, urlSegment } from "../core/provider/index.js";
6
+ const schema = {
7
+ name: "prompts",
8
+ description: "Browse and use prompt templates",
9
+ aliases: ["p"],
10
+ options: [],
11
+ };
12
+ async function handleList() {
13
+ const res = await apiCall("/api/v1/prompt-templates");
14
+ if (!res.ok)
15
+ return { exitCode: 1, error: res.error };
16
+ return { exitCode: 0, data: res.data };
17
+ }
18
+ async function handleGet(id) {
19
+ if (!id)
20
+ return { exitCode: 1, error: "Usage: prompts get <id-or-slug>" };
21
+ let res = await apiCall(`/api/v1/prompt-templates/${urlSegment(id)}`);
22
+ if (!res.ok)
23
+ res = await apiCall(`/api/v1/prompt-templates/slug/${urlSegment(id)}`);
24
+ if (!res.ok)
25
+ return { exitCode: 1, error: res.error };
26
+ return { exitCode: 0, data: res.data };
27
+ }
28
+ async function handleResolve(id, varPairs) {
29
+ if (!id)
30
+ return { exitCode: 1, error: "Usage: prompts resolve <id> --var key=val,..." };
31
+ const values = {};
32
+ if (varPairs) {
33
+ for (const pair of varPairs.split(",")) {
34
+ const [k, v] = pair.split("=");
35
+ if (k)
36
+ values[k.trim()] = v?.trim() ?? "";
37
+ }
38
+ }
39
+ const res = await apiCall(`/api/v1/prompt-templates/${urlSegment(id)}/resolve`, {
40
+ method: "POST",
41
+ body: { values },
42
+ });
43
+ if (!res.ok)
44
+ return { exitCode: 1, error: res.error };
45
+ return { exitCode: 0, data: res.data, formatted: true };
46
+ }
47
+ registerCommand(schema, async (_args, opts) => {
48
+ const sub = opts.args[0];
49
+ const id = opts.args[1];
50
+ const varFlag = opts.args.includes("--var")
51
+ ? opts.args[opts.args.indexOf("--var") + 1]
52
+ : undefined;
53
+ switch (sub) {
54
+ case "get": return handleGet(id ?? "");
55
+ case "resolve": return handleResolve(id ?? "", varFlag ?? "");
56
+ default: return handleList();
57
+ }
58
+ });
59
+ //# sourceMappingURL=prompts.js.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=skills.d.ts.map
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Skills commands — browse marketplace, install, manage skills.
3
+ */
4
+ import { registerCommand } from "../core/registry/index.js";
5
+ import { apiCall, urlSegment } from "../core/provider/index.js";
6
+ const schema = {
7
+ name: "skills",
8
+ description: "Browse and manage agent skills",
9
+ aliases: ["s"],
10
+ options: [],
11
+ };
12
+ async function handleList() {
13
+ const res = await apiCall("/api/v1/skills");
14
+ if (!res.ok)
15
+ return { exitCode: 1, error: res.error };
16
+ return { exitCode: 0, data: res.data };
17
+ }
18
+ async function handleMarketplace() {
19
+ const res = await apiCall("/api/v1/skills/marketplace");
20
+ if (!res.ok)
21
+ return { exitCode: 1, error: res.error };
22
+ return { exitCode: 0, data: res.data };
23
+ }
24
+ async function handleGet(skillId) {
25
+ if (!skillId)
26
+ return { exitCode: 1, error: "Usage: skills get <skill-id>" };
27
+ const res = await apiCall(`/api/v1/skills/${urlSegment(skillId)}`);
28
+ if (!res.ok)
29
+ return { exitCode: 1, error: res.error };
30
+ return { exitCode: 0, data: res.data };
31
+ }
32
+ registerCommand(schema, async (_args, opts) => {
33
+ const sub = opts.args[0];
34
+ const id = opts.args[1];
35
+ switch (sub) {
36
+ case "marketplace": return handleMarketplace();
37
+ case "get": return handleGet(id ?? "");
38
+ default: return handleList();
39
+ }
40
+ });
41
+ //# sourceMappingURL=skills.js.map
@@ -0,0 +1,10 @@
1
+ import type { CommandResult } from "../schema/types.js";
2
+ /** Login with username/password → JWT token */
3
+ export declare function login(username: string, password: string, apiUrl?: string): Promise<CommandResult>;
4
+ /** Set API key directly */
5
+ export declare function setApiKey(key: string): Promise<CommandResult>;
6
+ /** Logout — clear stored auth */
7
+ export declare function logout(): CommandResult;
8
+ /** Show current auth status */
9
+ export declare function authStatus(): CommandResult;
10
+ //# sourceMappingURL=index.d.ts.map