@muhkoo/cli 0.15.0-alpha.13 → 0.15.0-alpha.15
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 +37 -7
- package/bin/muhkoo.js +7 -1
- package/package.json +9 -5
- package/src/commands/deploy.js +192 -9
- package/src/commands/kv.js +0 -2
- package/src/commands/login.js +49 -3
- package/src/commands/logout.js +4 -2
- package/src/commands/mcp.js +28 -0
- package/src/commands/promote.js +0 -1
- package/src/commands/provision.js +17 -1
- package/src/commands/vfs.js +110 -98
- package/src/index.js +7 -3
- package/src/lib/auth.js +7 -2
- package/src/lib/bases.js +8 -0
- package/src/lib/mount.js +3 -0
- package/src/lib/ui.js +30 -5
- package/src/lib/vfs.js +46 -44
- package/src/lib/webLogin.js +85 -20
- package/src/mcp/node.js +90 -0
- package/src/mcp/run.js +125 -0
- package/src/mcp/secrets.js +130 -0
- package/src/mcp/server.js +87 -0
- package/src/mcp/tools.js +782 -0
package/src/mcp/tools.js
ADDED
|
@@ -0,0 +1,782 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every MCP tool, as data: what Claude sees (name, description, inputs, safety
|
|
3
|
+
* markings) and how a call becomes a CLI command line.
|
|
4
|
+
*
|
|
5
|
+
* One tool per CLI action, not one "run anything" tool, so the client can tell
|
|
6
|
+
* a listing from a production change and ask before the second. The markings:
|
|
7
|
+
*
|
|
8
|
+
* - READ: changes nothing anywhere. Clients may run these without asking.
|
|
9
|
+
* - WRITE: changes something, on the test side or in the developer's own files,
|
|
10
|
+
* that can be changed back.
|
|
11
|
+
* - DESTRUCTIVE: reaches production, deletes, revokes, or mints a credential.
|
|
12
|
+
*
|
|
13
|
+
* MCP treats a tool that is not read-only as destructive unless it says
|
|
14
|
+
* otherwise, so WRITE sets `destructiveHint: false` explicitly.
|
|
15
|
+
*
|
|
16
|
+
* `tests/mcpDrift.test.js` fails when a CLI command has neither a tool here nor
|
|
17
|
+
* an entry in EXCLUDED.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { isAbsolute } from "node:path";
|
|
21
|
+
import { z } from "zod";
|
|
22
|
+
|
|
23
|
+
const READ = { readOnlyHint: true, openWorldHint: true };
|
|
24
|
+
const WRITE = { readOnlyHint: false, destructiveHint: false, openWorldHint: true };
|
|
25
|
+
const DESTRUCTIVE = { readOnlyHint: false, destructiveHint: true, openWorldHint: true };
|
|
26
|
+
|
|
27
|
+
const MIN = 60_000;
|
|
28
|
+
|
|
29
|
+
/** CLI commands deliberately without a tool, and why. */
|
|
30
|
+
export const EXCLUDED = {
|
|
31
|
+
"vfs mount": "long-running: keeps a folder in sync until stopped",
|
|
32
|
+
"vfs cd": "shared working-directory state across calls; every tool takes absolute paths instead",
|
|
33
|
+
"vfs pwd": "shared working-directory state across calls",
|
|
34
|
+
"vfs use-app": "deprecated: prints a notice and does nothing",
|
|
35
|
+
"vfs app": "deprecated: prints a notice and does nothing",
|
|
36
|
+
eject: "runs npx tsx on a local agent file with raw terminal output",
|
|
37
|
+
"vectors query": "needs an app key as input (--key or MUHKOO_APP_KEY), and secrets are never taken as tool input",
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The name of the first argument that looks like a flag (starts with "-"), or
|
|
42
|
+
* null. The CLI's parser reads any "--x" in argv as an option wherever it
|
|
43
|
+
* appears, so a value like appId "--base" followed by a URL would redirect the
|
|
44
|
+
* signed-in session to another host. No legitimate value here starts with "-":
|
|
45
|
+
* Muhkoo and local paths start with "/".
|
|
46
|
+
*/
|
|
47
|
+
export function flagLikeArgument(args) {
|
|
48
|
+
for (const [key, value] of Object.entries(args ?? {})) {
|
|
49
|
+
const values = Array.isArray(value) ? value : [value];
|
|
50
|
+
if (values.some((v) => typeof v === "string" && v.startsWith("-"))) return key;
|
|
51
|
+
}
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// ── inputs ─────────────────────────────────────────────────────────────────
|
|
56
|
+
|
|
57
|
+
/** A path on the developer's computer. Always absolute: the server's own cwd is arbitrary. */
|
|
58
|
+
export function absolutePath(field) {
|
|
59
|
+
return z
|
|
60
|
+
.string()
|
|
61
|
+
.refine((p) => isAbsolute(p) && !p.startsWith("~"), { message: `${field} must be an absolute path` });
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const appId = z.string().min(1).describe("The app id (from apps_ls)");
|
|
65
|
+
const vfsPath = (what = "Path in your Muhkoo filesystem") =>
|
|
66
|
+
z.string().startsWith("/", { message: "filesystem paths start with /" }).describe(`${what}, absolute, e.g. /apps/my-app`);
|
|
67
|
+
const project = z.string().min(1).describe("The project's slug: the folder name under /apps in your filesystem");
|
|
68
|
+
const space = z.string().min(1).describe("Space id, or #channel name");
|
|
69
|
+
|
|
70
|
+
// ── argv helpers ───────────────────────────────────────────────────────────
|
|
71
|
+
|
|
72
|
+
const opt = (flag, value) => (value === undefined || value === null || value === "" ? [] : [flag, String(value)]);
|
|
73
|
+
const bool = (flag, on) => (on ? [flag] : []);
|
|
74
|
+
const list = (flag, values) => (values?.length ? [flag, values.join(",")] : []);
|
|
75
|
+
const pos = (value) => (value === undefined || value === null || value === "" ? [] : [String(value)]);
|
|
76
|
+
|
|
77
|
+
// ── the tools ──────────────────────────────────────────────────────────────
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* @typedef {{ name: string, title: string, description: string, input: Record<string, import("zod").ZodTypeAny>,
|
|
81
|
+
* annotations: Record<string, boolean>, timeoutMs?: number, argv: (a: any) => string[], cwd?: (a: any) => string | undefined }} Tool
|
|
82
|
+
*/
|
|
83
|
+
|
|
84
|
+
/** @type {Tool[]} */
|
|
85
|
+
export const TOOLS = [
|
|
86
|
+
// Account
|
|
87
|
+
{
|
|
88
|
+
name: "login",
|
|
89
|
+
title: "Sign in",
|
|
90
|
+
description:
|
|
91
|
+
"Sign in to Muhkoo in the browser (password, passkey or Google). Opens a sign-in page and waits up to 5 minutes. Also pairs this computer, which the filesystem tools need. Use when another tool says you are not signed in. `base` is only for Muhkoo staff working against staging.",
|
|
92
|
+
input: { base: z.enum(["prod", "staging"]).optional().describe("Platform to sign in to: prod (default) or staging") },
|
|
93
|
+
annotations: WRITE,
|
|
94
|
+
timeoutMs: 5 * MIN,
|
|
95
|
+
argv: (a) => ["login", "--web", ...opt("--base", a.base)],
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
name: "logout",
|
|
99
|
+
title: "Sign out",
|
|
100
|
+
description: "Forget the stored Muhkoo session on this computer.",
|
|
101
|
+
input: {},
|
|
102
|
+
annotations: WRITE,
|
|
103
|
+
argv: () => ["logout"],
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
name: "whoami",
|
|
107
|
+
title: "Who am I",
|
|
108
|
+
description: "Show the signed-in developer and which platform (production or staging) the tools act on. A good first call.",
|
|
109
|
+
input: {},
|
|
110
|
+
annotations: READ,
|
|
111
|
+
argv: () => ["whoami"],
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
name: "devices_ls",
|
|
115
|
+
title: "List paired computers",
|
|
116
|
+
description: "List the computers paired to your account (they can open your filesystem without a password).",
|
|
117
|
+
input: {},
|
|
118
|
+
annotations: READ,
|
|
119
|
+
argv: () => ["devices", "ls"],
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
name: "devices_rm",
|
|
123
|
+
title: "Unpair a computer",
|
|
124
|
+
description: "Withdraw a paired computer's access to your account.",
|
|
125
|
+
input: { factorId: z.string().min(1).describe("From devices_ls") },
|
|
126
|
+
annotations: DESTRUCTIVE,
|
|
127
|
+
argv: (a) => ["devices", "rm", a.factorId],
|
|
128
|
+
},
|
|
129
|
+
|
|
130
|
+
// Apps, keys, tokens
|
|
131
|
+
{
|
|
132
|
+
name: "apps_ls",
|
|
133
|
+
title: "List apps",
|
|
134
|
+
description: "List your Muhkoo apps with their ids and slugs.",
|
|
135
|
+
input: {},
|
|
136
|
+
annotations: READ,
|
|
137
|
+
argv: () => ["apps", "ls"],
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
name: "apps_get",
|
|
141
|
+
title: "Get an app",
|
|
142
|
+
description: "Show one app's details.",
|
|
143
|
+
input: { appId },
|
|
144
|
+
annotations: READ,
|
|
145
|
+
argv: (a) => ["apps", "get", a.appId],
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
name: "apps_create",
|
|
149
|
+
title: "Create an app",
|
|
150
|
+
description:
|
|
151
|
+
"Create a new app. Its hosting address is https://<slug>.apps.muhkoo.dev. The publishable (pk) keys are returned; the secret (sk) keys are saved to a private file and only its path is returned. For a full backend (tables, functions, agents) from a spec, use provision instead.",
|
|
152
|
+
input: {
|
|
153
|
+
slug: z.string().min(1).describe("Lowercase name, used in the app's address; check it with apps_slug first"),
|
|
154
|
+
email: z.string().optional().describe("Billing email, needed the first time a developer account creates an app"),
|
|
155
|
+
origins: z.array(z.string()).optional().describe("Allowed browser origins (CORS)"),
|
|
156
|
+
},
|
|
157
|
+
annotations: WRITE,
|
|
158
|
+
argv: (a) => ["apps", "create", "--slug", a.slug, ...opt("--email", a.email), ...list("--origins", a.origins)],
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
name: "apps_slug",
|
|
162
|
+
title: "Check a slug",
|
|
163
|
+
description: "Check whether an app slug is still available.",
|
|
164
|
+
input: { slug: z.string().min(1) },
|
|
165
|
+
annotations: READ,
|
|
166
|
+
argv: (a) => ["apps", "slug", a.slug],
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
name: "apps_rm",
|
|
170
|
+
title: "Delete an app",
|
|
171
|
+
description: "Delete an app and revoke all its keys. Cannot be undone.",
|
|
172
|
+
input: { appId },
|
|
173
|
+
annotations: DESTRUCTIVE,
|
|
174
|
+
argv: (a) => ["apps", "rm", a.appId],
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
name: "keys_rotate",
|
|
178
|
+
title: "Rotate app keys",
|
|
179
|
+
description:
|
|
180
|
+
"Replace all four of an app's keys; the old ones stop working at once. New secret keys are saved to the project's .muhkoo-app.json when projectDir has one, otherwise to a private file; only the path is returned.",
|
|
181
|
+
input: { appId, projectDir: absolutePath("projectDir").optional().describe("The app's project folder on this computer") },
|
|
182
|
+
annotations: DESTRUCTIVE,
|
|
183
|
+
argv: (a) => ["keys", "rotate", a.appId],
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
name: "tokens_ls",
|
|
187
|
+
title: "List access tokens",
|
|
188
|
+
description: "List an app's scoped access tokens (not their values).",
|
|
189
|
+
input: { appId },
|
|
190
|
+
annotations: READ,
|
|
191
|
+
argv: (a) => ["tokens", "ls", a.appId],
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
name: "tokens_create",
|
|
195
|
+
title: "Create an access token",
|
|
196
|
+
description:
|
|
197
|
+
"Mint a scoped, expiring access token for servers and scripts. The token is saved to a private file and only its path is returned. Needs a paid plan.",
|
|
198
|
+
input: {
|
|
199
|
+
appId,
|
|
200
|
+
scopes: z
|
|
201
|
+
.array(z.string())
|
|
202
|
+
.optional()
|
|
203
|
+
.describe("e.g. db:read, db:write, kv:read, kv:write, storage:read, storage:write, messages:read, messages:write, functions:invoke, ai:infer, vectors:read, vectors:write"),
|
|
204
|
+
env: z.enum(["test", "live"]).optional(),
|
|
205
|
+
expiresInDays: z.number().int().positive().optional(),
|
|
206
|
+
label: z.string().optional(),
|
|
207
|
+
},
|
|
208
|
+
annotations: DESTRUCTIVE,
|
|
209
|
+
argv: (a) => [
|
|
210
|
+
"tokens", "create", a.appId,
|
|
211
|
+
...list("--scopes", a.scopes), ...opt("--env", a.env), ...opt("--expires-in", a.expiresInDays), ...opt("--label", a.label),
|
|
212
|
+
],
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
name: "tokens_revoke",
|
|
216
|
+
title: "Revoke an access token",
|
|
217
|
+
description: "Revoke an access token; anything using it stops working.",
|
|
218
|
+
input: { appId, keyId: z.string().min(1).describe("From tokens_ls") },
|
|
219
|
+
annotations: DESTRUCTIVE,
|
|
220
|
+
argv: (a) => ["tokens", "revoke", a.appId, a.keyId],
|
|
221
|
+
},
|
|
222
|
+
|
|
223
|
+
// Backend
|
|
224
|
+
{
|
|
225
|
+
name: "provision",
|
|
226
|
+
title: "Provision a backend",
|
|
227
|
+
description:
|
|
228
|
+
"Create or update an app's backend from a JSON spec: the app itself, database tables, vector collections, agents and functions. Writes .muhkoo-app.json (with the app's keys) into projectDir, which deploy then uses. Safe to re-run. Use dryRun to preview.",
|
|
229
|
+
input: {
|
|
230
|
+
spec: absolutePath("spec").describe("The spec file, e.g. /Users/me/my-app/muhkoo.json"),
|
|
231
|
+
projectDir: absolutePath("projectDir").describe("The app's project folder; .muhkoo-app.json is written here"),
|
|
232
|
+
dryRun: z.boolean().optional(),
|
|
233
|
+
enable: z.boolean().optional().describe("Second step: enable the spec's agents and functions on their channels, once the app has run"),
|
|
234
|
+
},
|
|
235
|
+
// It (re)deploys the spec's functions, which go live at once, and with
|
|
236
|
+
// enable switches agents and functions on in live channels.
|
|
237
|
+
annotations: DESTRUCTIVE,
|
|
238
|
+
timeoutMs: 10 * MIN,
|
|
239
|
+
argv: (a) => ["provision", "--spec", a.spec, ...bool("--dry-run", a.dryRun), ...bool("--enable", a.enable)],
|
|
240
|
+
cwd: (a) => a.projectDir,
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
name: "tables_ls",
|
|
244
|
+
title: "List tables",
|
|
245
|
+
description: "List an app's database tables.",
|
|
246
|
+
input: { appId },
|
|
247
|
+
annotations: READ,
|
|
248
|
+
argv: (a) => ["tables", "ls", a.appId],
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
name: "tables_get",
|
|
252
|
+
title: "Get a table",
|
|
253
|
+
description: "Show a table's schema.",
|
|
254
|
+
input: { appId, table: z.string().min(1) },
|
|
255
|
+
annotations: READ,
|
|
256
|
+
argv: (a) => ["tables", "get", a.appId, a.table],
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
name: "tables_rm",
|
|
260
|
+
title: "Delete a table",
|
|
261
|
+
description: "Delete a table and its data. Cannot be undone.",
|
|
262
|
+
input: { appId, table: z.string().min(1) },
|
|
263
|
+
annotations: DESTRUCTIVE,
|
|
264
|
+
argv: (a) => ["tables", "rm", a.appId, a.table],
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
name: "vectors_ls",
|
|
268
|
+
title: "List vector collections",
|
|
269
|
+
description: "List an app's vector search collections.",
|
|
270
|
+
input: { appId },
|
|
271
|
+
annotations: READ,
|
|
272
|
+
argv: (a) => ["vectors", "ls", a.appId],
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
name: "vectors_get",
|
|
276
|
+
title: "Get a vector collection",
|
|
277
|
+
description: "Show one vector collection.",
|
|
278
|
+
input: { appId, name: z.string().min(1) },
|
|
279
|
+
annotations: READ,
|
|
280
|
+
argv: (a) => ["vectors", "get", a.appId, a.name],
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
name: "vectors_create",
|
|
284
|
+
title: "Create a vector collection",
|
|
285
|
+
description: "Create a vector search collection. mode 'text' embeds text for you with `model`; mode 'vectors' takes your own vectors of `dimensions` length.",
|
|
286
|
+
input: {
|
|
287
|
+
appId,
|
|
288
|
+
name: z.string().min(1),
|
|
289
|
+
mode: z.enum(["text", "vectors"]),
|
|
290
|
+
model: z.string().optional(),
|
|
291
|
+
dimensions: z.number().int().positive().optional(),
|
|
292
|
+
metric: z.enum(["cosine", "euclidean", "dot-product"]).optional(),
|
|
293
|
+
fields: z.array(z.string()).optional().describe("Filterable fields as name:type, e.g. category:string"),
|
|
294
|
+
access: z.enum(["app", "backend"]).optional(),
|
|
295
|
+
noWait: z.boolean().optional().describe("Return before the collection is ready"),
|
|
296
|
+
},
|
|
297
|
+
annotations: WRITE,
|
|
298
|
+
argv: (a) => [
|
|
299
|
+
"vectors", "create", a.appId, a.name, "--mode", a.mode,
|
|
300
|
+
...opt("--model", a.model), ...opt("--dimensions", a.dimensions), ...opt("--metric", a.metric),
|
|
301
|
+
...list("--fields", a.fields), ...opt("--access", a.access), ...bool("--no-wait", a.noWait),
|
|
302
|
+
],
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
name: "vectors_rm",
|
|
306
|
+
title: "Delete a vector collection",
|
|
307
|
+
description: "Delete a vector collection and everything in it.",
|
|
308
|
+
input: { appId, name: z.string().min(1) },
|
|
309
|
+
annotations: DESTRUCTIVE,
|
|
310
|
+
argv: (a) => ["vectors", "rm", a.appId, a.name],
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
name: "vectors_notices",
|
|
314
|
+
title: "Set vector notices",
|
|
315
|
+
description: "Choose which Spaces are told when a collection changes, per environment.",
|
|
316
|
+
input: {
|
|
317
|
+
appId,
|
|
318
|
+
name: z.string().min(1),
|
|
319
|
+
env: z.enum(["live", "test"]),
|
|
320
|
+
spaces: z.array(z.string()).min(1),
|
|
321
|
+
default: z.string().optional(),
|
|
322
|
+
},
|
|
323
|
+
annotations: DESTRUCTIVE,
|
|
324
|
+
argv: (a) => ["vectors", "notices", a.appId, a.name, "--env", a.env, ...list("--spaces", a.spaces), ...opt("--default", a.default)],
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
name: "agents_ls",
|
|
328
|
+
title: "List agents",
|
|
329
|
+
description: "List an app's programmable agents.",
|
|
330
|
+
input: { appId },
|
|
331
|
+
annotations: READ,
|
|
332
|
+
argv: (a) => ["agents", "ls", a.appId],
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
name: "agents_get",
|
|
336
|
+
title: "Get an agent",
|
|
337
|
+
description: "Show one agent.",
|
|
338
|
+
input: { appId, agentId: z.string().min(1) },
|
|
339
|
+
annotations: READ,
|
|
340
|
+
argv: (a) => ["agents", "get", a.appId, a.agentId],
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
name: "agents_rm",
|
|
344
|
+
title: "Delete an agent",
|
|
345
|
+
description: "Delete an agent.",
|
|
346
|
+
input: { appId, agentId: z.string().min(1) },
|
|
347
|
+
annotations: DESTRUCTIVE,
|
|
348
|
+
argv: (a) => ["agents", "rm", a.appId, a.agentId],
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
name: "agents_enable",
|
|
352
|
+
title: "Enable an agent",
|
|
353
|
+
description: "Turn an agent on in a Space.",
|
|
354
|
+
input: { appId, agentId: z.string().min(1), space },
|
|
355
|
+
annotations: DESTRUCTIVE,
|
|
356
|
+
argv: (a) => ["agents", "enable", a.appId, a.agentId, "--space", a.space],
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
name: "agents_disable",
|
|
360
|
+
title: "Disable an agent",
|
|
361
|
+
description: "Turn an agent off in a Space.",
|
|
362
|
+
input: { appId, agentId: z.string().min(1), space },
|
|
363
|
+
annotations: DESTRUCTIVE,
|
|
364
|
+
argv: (a) => ["agents", "disable", a.appId, a.agentId, "--space", a.space],
|
|
365
|
+
},
|
|
366
|
+
{
|
|
367
|
+
name: "agents_models",
|
|
368
|
+
title: "List agent models",
|
|
369
|
+
description: "List the AI models agents can use.",
|
|
370
|
+
input: {},
|
|
371
|
+
annotations: READ,
|
|
372
|
+
argv: () => ["agents", "models"],
|
|
373
|
+
},
|
|
374
|
+
{
|
|
375
|
+
name: "functions_ls",
|
|
376
|
+
title: "List functions",
|
|
377
|
+
description: "List an app's serverless functions.",
|
|
378
|
+
input: { appId },
|
|
379
|
+
annotations: READ,
|
|
380
|
+
argv: (a) => ["functions", "ls", a.appId],
|
|
381
|
+
},
|
|
382
|
+
{
|
|
383
|
+
name: "functions_get",
|
|
384
|
+
title: "Get a function",
|
|
385
|
+
description: "Show one function's settings.",
|
|
386
|
+
input: { appId, functionId: z.string().min(1) },
|
|
387
|
+
annotations: READ,
|
|
388
|
+
argv: (a) => ["functions", "get", a.appId, a.functionId],
|
|
389
|
+
},
|
|
390
|
+
{
|
|
391
|
+
name: "functions_code",
|
|
392
|
+
title: "Show function code",
|
|
393
|
+
description: "Print a function's deployed source.",
|
|
394
|
+
input: { appId, functionId: z.string().min(1) },
|
|
395
|
+
annotations: READ,
|
|
396
|
+
argv: (a) => ["functions", "code", a.appId, a.functionId],
|
|
397
|
+
},
|
|
398
|
+
{
|
|
399
|
+
name: "functions_deploy",
|
|
400
|
+
title: "Deploy a function",
|
|
401
|
+
description:
|
|
402
|
+
"Deploy a serverless function from a local file. It goes live as soon as it deploys. Use http for a function called directly over HTTP rather than from a channel.",
|
|
403
|
+
input: {
|
|
404
|
+
appId,
|
|
405
|
+
name: z.string().min(1),
|
|
406
|
+
file: absolutePath("file").describe("The function's source file"),
|
|
407
|
+
http: z.boolean().optional(),
|
|
408
|
+
},
|
|
409
|
+
annotations: DESTRUCTIVE,
|
|
410
|
+
argv: (a) => ["functions", "deploy", a.appId, "--name", a.name, "--file", a.file, ...bool("--http", a.http)],
|
|
411
|
+
},
|
|
412
|
+
{
|
|
413
|
+
name: "functions_rm",
|
|
414
|
+
title: "Delete a function",
|
|
415
|
+
description: "Delete a function.",
|
|
416
|
+
input: { appId, functionId: z.string().min(1) },
|
|
417
|
+
annotations: DESTRUCTIVE,
|
|
418
|
+
argv: (a) => ["functions", "rm", a.appId, a.functionId],
|
|
419
|
+
},
|
|
420
|
+
{
|
|
421
|
+
name: "functions_enable",
|
|
422
|
+
title: "Enable a function",
|
|
423
|
+
description: "Run a function on a Space's messages.",
|
|
424
|
+
input: { appId, functionId: z.string().min(1), space },
|
|
425
|
+
annotations: DESTRUCTIVE,
|
|
426
|
+
argv: (a) => ["functions", "enable", a.appId, a.functionId, "--space", a.space],
|
|
427
|
+
},
|
|
428
|
+
{
|
|
429
|
+
name: "functions_disable",
|
|
430
|
+
title: "Disable a function",
|
|
431
|
+
description: "Stop a function running on a Space.",
|
|
432
|
+
input: { appId, functionId: z.string().min(1), space },
|
|
433
|
+
annotations: DESTRUCTIVE,
|
|
434
|
+
argv: (a) => ["functions", "disable", a.appId, a.functionId, "--space", a.space],
|
|
435
|
+
},
|
|
436
|
+
|
|
437
|
+
// Filesystem
|
|
438
|
+
{
|
|
439
|
+
name: "vfs_ls",
|
|
440
|
+
title: "List a folder",
|
|
441
|
+
description: "List a folder in your Muhkoo filesystem (your encrypted files; projects live under /apps).",
|
|
442
|
+
input: { path: vfsPath().optional().describe("Folder, default /") },
|
|
443
|
+
annotations: READ,
|
|
444
|
+
argv: (a) => ["vfs", "ls", a.path ?? "/"],
|
|
445
|
+
},
|
|
446
|
+
{
|
|
447
|
+
name: "vfs_stat",
|
|
448
|
+
title: "File details",
|
|
449
|
+
description: "Size, versions and modified time of a file or folder in your filesystem.",
|
|
450
|
+
input: { path: vfsPath() },
|
|
451
|
+
annotations: READ,
|
|
452
|
+
argv: (a) => ["vfs", "stat", a.path],
|
|
453
|
+
},
|
|
454
|
+
{
|
|
455
|
+
name: "vfs_tree",
|
|
456
|
+
title: "List everything under a folder",
|
|
457
|
+
description: "Every file beneath a folder in your filesystem.",
|
|
458
|
+
input: { path: vfsPath().optional().describe("Folder, default /") },
|
|
459
|
+
annotations: READ,
|
|
460
|
+
argv: (a) => ["vfs", "tree", a.path ?? "/"],
|
|
461
|
+
},
|
|
462
|
+
{
|
|
463
|
+
name: "vfs_cat",
|
|
464
|
+
title: "Read a file",
|
|
465
|
+
description: "Read a text file from your filesystem (up to 1 MB is returned; use vfs_get for binary or larger files).",
|
|
466
|
+
input: { path: vfsPath() },
|
|
467
|
+
annotations: READ,
|
|
468
|
+
argv: (a) => ["vfs", "cat", a.path],
|
|
469
|
+
},
|
|
470
|
+
{
|
|
471
|
+
name: "vfs_find",
|
|
472
|
+
title: "Find files",
|
|
473
|
+
description: "Find files in your filesystem by glob, e.g. /apps/**/*.ts",
|
|
474
|
+
input: { glob: z.string().min(1) },
|
|
475
|
+
annotations: READ,
|
|
476
|
+
argv: (a) => ["vfs", "find", a.glob],
|
|
477
|
+
},
|
|
478
|
+
{
|
|
479
|
+
name: "vfs_history",
|
|
480
|
+
title: "File history",
|
|
481
|
+
description: "A file's earlier versions, newest first (restore one with vfs_restore).",
|
|
482
|
+
input: { path: vfsPath() },
|
|
483
|
+
annotations: READ,
|
|
484
|
+
argv: (a) => ["vfs", "history", a.path],
|
|
485
|
+
},
|
|
486
|
+
{
|
|
487
|
+
name: "vfs_put",
|
|
488
|
+
title: "Upload a file",
|
|
489
|
+
description: "Upload a file from this computer into your filesystem.",
|
|
490
|
+
input: { local: absolutePath("local").describe("File on this computer"), path: vfsPath("Destination") },
|
|
491
|
+
annotations: WRITE,
|
|
492
|
+
argv: (a) => ["vfs", "put", a.local, a.path],
|
|
493
|
+
},
|
|
494
|
+
{
|
|
495
|
+
name: "vfs_get",
|
|
496
|
+
title: "Download a file",
|
|
497
|
+
description: "Download a file from your filesystem to this computer. Replaces a file already at `local`.",
|
|
498
|
+
input: { path: vfsPath(), local: absolutePath("local").describe("Where to save it on this computer") },
|
|
499
|
+
annotations: DESTRUCTIVE,
|
|
500
|
+
argv: (a) => ["vfs", "get", a.path, a.local],
|
|
501
|
+
},
|
|
502
|
+
{
|
|
503
|
+
name: "vfs_mkdir",
|
|
504
|
+
title: "Make a folder",
|
|
505
|
+
description: "Create a folder (and any missing parents) in your filesystem.",
|
|
506
|
+
input: { path: vfsPath() },
|
|
507
|
+
annotations: WRITE,
|
|
508
|
+
argv: (a) => ["vfs", "mkdir", a.path],
|
|
509
|
+
},
|
|
510
|
+
{
|
|
511
|
+
name: "vfs_rm",
|
|
512
|
+
title: "Delete from filesystem",
|
|
513
|
+
description: "Delete a file, or a folder with recursive. A deleted file's history goes with it.",
|
|
514
|
+
input: { path: vfsPath(), recursive: z.boolean().optional() },
|
|
515
|
+
annotations: DESTRUCTIVE,
|
|
516
|
+
argv: (a) => ["vfs", "rm", a.path, ...bool("-r", a.recursive)],
|
|
517
|
+
},
|
|
518
|
+
{
|
|
519
|
+
name: "vfs_cp",
|
|
520
|
+
title: "Copy in filesystem",
|
|
521
|
+
description: "Copy a file or folder within your filesystem.",
|
|
522
|
+
input: { from: vfsPath("Source"), to: vfsPath("Destination") },
|
|
523
|
+
annotations: WRITE,
|
|
524
|
+
argv: (a) => ["vfs", "cp", a.from, a.to],
|
|
525
|
+
},
|
|
526
|
+
{
|
|
527
|
+
name: "vfs_mv",
|
|
528
|
+
title: "Move or rename",
|
|
529
|
+
description: "Move or rename a file or folder within your filesystem.",
|
|
530
|
+
input: { from: vfsPath("Source"), to: vfsPath("Destination") },
|
|
531
|
+
annotations: WRITE,
|
|
532
|
+
argv: (a) => ["vfs", "mv", a.from, a.to],
|
|
533
|
+
},
|
|
534
|
+
{
|
|
535
|
+
name: "vfs_restore",
|
|
536
|
+
title: "Restore a version",
|
|
537
|
+
description: "Put back an earlier version of a file (index from vfs_history, default 0 = the previous one).",
|
|
538
|
+
input: { path: vfsPath(), index: z.number().int().min(0).optional() },
|
|
539
|
+
annotations: DESTRUCTIVE,
|
|
540
|
+
argv: (a) => ["vfs", "restore", a.path, ...pos(a.index)],
|
|
541
|
+
},
|
|
542
|
+
{
|
|
543
|
+
name: "vfs_import",
|
|
544
|
+
title: "Upload a project",
|
|
545
|
+
description:
|
|
546
|
+
"Upload whole project folders from this computer into your filesystem, once (default destination /apps/<folder name>). Upload only: never changes anything on this computer. Skips node_modules, .git, secrets and what .gitignore/.vcsignore exclude. Use dryRun to preview.",
|
|
547
|
+
input: {
|
|
548
|
+
dirs: z.array(absolutePath("dirs")).min(1).describe("Project folders on this computer"),
|
|
549
|
+
path: vfsPath("Destination folder").optional(),
|
|
550
|
+
dryRun: z.boolean().optional(),
|
|
551
|
+
hidden: z.boolean().optional().describe("Also upload dot-files"),
|
|
552
|
+
},
|
|
553
|
+
annotations: WRITE,
|
|
554
|
+
timeoutMs: 10 * MIN,
|
|
555
|
+
argv: (a) => ["vfs", "import", ...a.dirs, ...opt("--path", a.path), ...bool("--dry-run", a.dryRun), ...bool("--hidden", a.hidden)],
|
|
556
|
+
},
|
|
557
|
+
{
|
|
558
|
+
name: "vfs_ignore",
|
|
559
|
+
title: "Ignore rules",
|
|
560
|
+
description:
|
|
561
|
+
"Show whether a local folder's ignore rules (.vcsignore/.gitignore) hold files back from syncing. To accept loosened rules, first call without acceptDigest, check what it would let through, then pass the digest it printed. draft prints a .vcsignore built from the folder's .gitignore files; write saves it.",
|
|
562
|
+
input: {
|
|
563
|
+
dir: absolutePath("dir"),
|
|
564
|
+
acceptDigest: z.string().optional(),
|
|
565
|
+
draft: z.boolean().optional(),
|
|
566
|
+
write: z.boolean().optional(),
|
|
567
|
+
force: z.boolean().optional().describe("With write: replace an existing .vcsignore"),
|
|
568
|
+
},
|
|
569
|
+
annotations: WRITE,
|
|
570
|
+
argv: (a) => [
|
|
571
|
+
"vfs", "ignore", a.dir,
|
|
572
|
+
...opt("--accept", a.acceptDigest), ...bool("--draft", a.draft), ...bool("--write", a.write), ...bool("--force", a.force),
|
|
573
|
+
],
|
|
574
|
+
},
|
|
575
|
+
{
|
|
576
|
+
name: "vfs_sweep",
|
|
577
|
+
title: "Reclaim storage",
|
|
578
|
+
description: "Reclaim records no longer reachable in your filesystem.",
|
|
579
|
+
input: { force: z.boolean().optional() },
|
|
580
|
+
annotations: DESTRUCTIVE,
|
|
581
|
+
argv: (a) => ["vfs", "sweep", ...bool("--force", a.force)],
|
|
582
|
+
},
|
|
583
|
+
{
|
|
584
|
+
name: "vfs_rehome",
|
|
585
|
+
title: "Move app-stored files to your account",
|
|
586
|
+
description: "One-time move of files older IDE/Cloud Drive versions stored under an app onto your own account. Safe to repeat. Use dryRun to list candidates.",
|
|
587
|
+
input: { dryRun: z.boolean().optional() },
|
|
588
|
+
annotations: DESTRUCTIVE,
|
|
589
|
+
timeoutMs: 10 * MIN,
|
|
590
|
+
argv: (a) => ["vfs", "rehome", ...bool("--dry-run", a.dryRun)],
|
|
591
|
+
},
|
|
592
|
+
|
|
593
|
+
// Version control
|
|
594
|
+
{
|
|
595
|
+
name: "vcs_status",
|
|
596
|
+
title: "Project status",
|
|
597
|
+
description: "What has changed in a project since its last commit.",
|
|
598
|
+
input: { project },
|
|
599
|
+
annotations: READ,
|
|
600
|
+
argv: (a) => ["vcs", "status", "--project", a.project],
|
|
601
|
+
},
|
|
602
|
+
{
|
|
603
|
+
name: "vcs_commit",
|
|
604
|
+
title: "Commit",
|
|
605
|
+
description: "Record a project's current state.",
|
|
606
|
+
input: { project, message: z.string().min(1) },
|
|
607
|
+
annotations: WRITE,
|
|
608
|
+
argv: (a) => ["vcs", "commit", "--project", a.project, "-m", a.message],
|
|
609
|
+
},
|
|
610
|
+
{
|
|
611
|
+
name: "vcs_log",
|
|
612
|
+
title: "Project history",
|
|
613
|
+
description: "A project's commits, newest first.",
|
|
614
|
+
input: { project, count: z.number().int().positive().optional() },
|
|
615
|
+
annotations: READ,
|
|
616
|
+
argv: (a) => ["vcs", "log", "--project", a.project, ...opt("-n", a.count)],
|
|
617
|
+
},
|
|
618
|
+
{
|
|
619
|
+
name: "vcs_show",
|
|
620
|
+
title: "Show a commit",
|
|
621
|
+
description: "What one commit changed.",
|
|
622
|
+
input: { project, commit: z.string().min(1) },
|
|
623
|
+
annotations: READ,
|
|
624
|
+
argv: (a) => ["vcs", "show", a.commit, "--project", a.project],
|
|
625
|
+
},
|
|
626
|
+
{
|
|
627
|
+
name: "vcs_diff",
|
|
628
|
+
title: "Compare commits",
|
|
629
|
+
description: "Compare two commits (default: the last commit against now).",
|
|
630
|
+
input: { project, a: z.string().optional(), b: z.string().optional() },
|
|
631
|
+
annotations: READ,
|
|
632
|
+
argv: (a) => ["vcs", "diff", ...pos(a.a), ...pos(a.b), "--project", a.project],
|
|
633
|
+
},
|
|
634
|
+
{
|
|
635
|
+
name: "vcs_branch",
|
|
636
|
+
title: "Branches",
|
|
637
|
+
description: "List a project's branches, or start a new one at the current commit when name is given.",
|
|
638
|
+
input: { project, name: z.string().optional() },
|
|
639
|
+
annotations: WRITE,
|
|
640
|
+
argv: (a) => ["vcs", "branch", ...pos(a.name), "--project", a.project],
|
|
641
|
+
},
|
|
642
|
+
{
|
|
643
|
+
name: "vcs_switch",
|
|
644
|
+
title: "Switch branch",
|
|
645
|
+
description: "Move a project onto a branch. Refuses if there are uncommitted changes.",
|
|
646
|
+
input: { project, name: z.string().min(1) },
|
|
647
|
+
annotations: WRITE,
|
|
648
|
+
argv: (a) => ["vcs", "switch", a.name, "--project", a.project],
|
|
649
|
+
},
|
|
650
|
+
{
|
|
651
|
+
name: "vcs_checkout",
|
|
652
|
+
title: "Check out a commit",
|
|
653
|
+
description: "Put a project's files at an old commit to inspect it (detaches HEAD). Refuses if there are uncommitted changes.",
|
|
654
|
+
input: { project, commit: z.string().min(1) },
|
|
655
|
+
annotations: DESTRUCTIVE,
|
|
656
|
+
argv: (a) => ["vcs", "checkout", a.commit, "--project", a.project],
|
|
657
|
+
},
|
|
658
|
+
{
|
|
659
|
+
name: "vcs_merge",
|
|
660
|
+
title: "Merge",
|
|
661
|
+
description: "Bring a branch into the current one, or abort a merge that stopped for conflicts.",
|
|
662
|
+
input: { project, name: z.string().optional(), abort: z.boolean().optional() },
|
|
663
|
+
annotations: WRITE,
|
|
664
|
+
argv: (a) => ["vcs", "merge", ...pos(a.name), ...bool("--abort", a.abort), "--project", a.project],
|
|
665
|
+
},
|
|
666
|
+
{
|
|
667
|
+
name: "vcs_restore",
|
|
668
|
+
title: "Restore a file from history",
|
|
669
|
+
description: "Put one file back as it was at a commit (default: the last commit).",
|
|
670
|
+
input: { project, path: z.string().min(1).describe("Path within the project"), commit: z.string().optional() },
|
|
671
|
+
annotations: DESTRUCTIVE,
|
|
672
|
+
argv: (a) => ["vcs", "restore", a.path, ...pos(a.commit), "--project", a.project],
|
|
673
|
+
},
|
|
674
|
+
|
|
675
|
+
// Key/value
|
|
676
|
+
{
|
|
677
|
+
name: "kv_ls",
|
|
678
|
+
title: "List personal keys",
|
|
679
|
+
description: "List the keys (never values) in your personal key/value store, optionally under a prefix.",
|
|
680
|
+
input: { prefix: z.string().optional() },
|
|
681
|
+
annotations: READ,
|
|
682
|
+
argv: (a) => ["kv", "ls", ...pos(a.prefix)],
|
|
683
|
+
},
|
|
684
|
+
|
|
685
|
+
// Hosting
|
|
686
|
+
{
|
|
687
|
+
name: "deploy",
|
|
688
|
+
title: "Deploy to test",
|
|
689
|
+
description:
|
|
690
|
+
"Deploy a built web client to the app's TEST environment and return its address. Run the project's build first; uploads <projectDir>/dist (or `dist`). Reads the app from the project's .muhkoo-app.json (from provision). Also copies the project's source to /apps/<slug> in your filesystem. Use promote to put the deployed version into production.",
|
|
691
|
+
input: {
|
|
692
|
+
projectDir: absolutePath("projectDir").describe("The app's project folder (holds .muhkoo-app.json)"),
|
|
693
|
+
dist: z.string().optional().describe("Build output folder, relative to projectDir or absolute; default dist"),
|
|
694
|
+
noFilesystem: z.boolean().optional().describe("Skip copying the source to your filesystem"),
|
|
695
|
+
},
|
|
696
|
+
annotations: WRITE,
|
|
697
|
+
timeoutMs: 10 * MIN,
|
|
698
|
+
argv: (a) => ["deploy", ...opt("--dist", a.dist), ...bool("--no-vfs", a.noFilesystem)],
|
|
699
|
+
cwd: (a) => a.projectDir,
|
|
700
|
+
},
|
|
701
|
+
{
|
|
702
|
+
name: "promote",
|
|
703
|
+
title: "Promote to production",
|
|
704
|
+
description:
|
|
705
|
+
"Put an app's current TEST hosting release and functions into PRODUCTION, in place. Instant and rollback-able (hosting_rollback). Production data and per-environment config are not touched.",
|
|
706
|
+
input: {
|
|
707
|
+
appId: appId.optional().describe("The app id; or give projectDir to read it from .muhkoo-app.json"),
|
|
708
|
+
projectDir: absolutePath("projectDir").optional(),
|
|
709
|
+
},
|
|
710
|
+
annotations: DESTRUCTIVE,
|
|
711
|
+
argv: (a) => ["promote", ...pos(a.appId)],
|
|
712
|
+
cwd: (a) => a.projectDir,
|
|
713
|
+
},
|
|
714
|
+
{
|
|
715
|
+
name: "hosting_status",
|
|
716
|
+
title: "Hosting status",
|
|
717
|
+
description: "An app's hosting: whether it is published and its releases.",
|
|
718
|
+
input: { appId },
|
|
719
|
+
annotations: READ,
|
|
720
|
+
argv: (a) => ["hosting", "status", a.appId],
|
|
721
|
+
},
|
|
722
|
+
{
|
|
723
|
+
name: "hosting_rollback",
|
|
724
|
+
title: "Roll back hosting",
|
|
725
|
+
description: "Point an app's hosting back at an earlier release.",
|
|
726
|
+
input: { appId, releaseId: z.string().min(1).describe("From hosting_status") },
|
|
727
|
+
annotations: DESTRUCTIVE,
|
|
728
|
+
argv: (a) => ["hosting", "rollback", a.appId, "--release", a.releaseId],
|
|
729
|
+
},
|
|
730
|
+
{
|
|
731
|
+
name: "hosting_rm_release",
|
|
732
|
+
title: "Delete a release",
|
|
733
|
+
description: "Delete one hosting release.",
|
|
734
|
+
input: { appId, releaseId: z.string().min(1) },
|
|
735
|
+
annotations: DESTRUCTIVE,
|
|
736
|
+
argv: (a) => ["hosting", "rm-release", a.appId, a.releaseId],
|
|
737
|
+
},
|
|
738
|
+
{
|
|
739
|
+
name: "hosting_unpublish",
|
|
740
|
+
title: "Unpublish",
|
|
741
|
+
description: "Take an app's site offline.",
|
|
742
|
+
input: { appId },
|
|
743
|
+
annotations: DESTRUCTIVE,
|
|
744
|
+
argv: (a) => ["hosting", "unpublish", a.appId],
|
|
745
|
+
},
|
|
746
|
+
{
|
|
747
|
+
name: "domains_ls",
|
|
748
|
+
title: "List domains",
|
|
749
|
+
description: "List an app's custom domains and their certificate status.",
|
|
750
|
+
input: { appId },
|
|
751
|
+
annotations: READ,
|
|
752
|
+
argv: (a) => ["domains", "ls", a.appId],
|
|
753
|
+
},
|
|
754
|
+
{
|
|
755
|
+
name: "domains_add",
|
|
756
|
+
title: "Add a domain",
|
|
757
|
+
description: "Attach a custom domain to an app; the result says which DNS records to create.",
|
|
758
|
+
input: { appId, hostname: z.string().min(1) },
|
|
759
|
+
annotations: WRITE,
|
|
760
|
+
argv: (a) => ["domains", "add", a.appId, a.hostname],
|
|
761
|
+
},
|
|
762
|
+
{
|
|
763
|
+
name: "domains_rm",
|
|
764
|
+
title: "Remove a domain",
|
|
765
|
+
description: "Detach a custom domain from an app; the site stops answering on it.",
|
|
766
|
+
input: { appId, hostname: z.string().min(1) },
|
|
767
|
+
annotations: DESTRUCTIVE,
|
|
768
|
+
argv: (a) => ["domains", "rm", a.appId, a.hostname],
|
|
769
|
+
},
|
|
770
|
+
|
|
771
|
+
// Tools
|
|
772
|
+
{
|
|
773
|
+
name: "logs",
|
|
774
|
+
title: "Server logs",
|
|
775
|
+
description: "Show an app's server-log Space and recent entries (entries are end-to-end encrypted; decrypted viewing is in the portal).",
|
|
776
|
+
input: { appId, env: z.enum(["live", "test"]).optional(), limit: z.number().int().positive().optional() },
|
|
777
|
+
annotations: READ,
|
|
778
|
+
argv: (a) => ["logs", a.appId, ...opt("--env", a.env), ...opt("--limit", a.limit)],
|
|
779
|
+
},
|
|
780
|
+
];
|
|
781
|
+
|
|
782
|
+
export const TOOL_BY_NAME = new Map(TOOLS.map((t) => [t.name, t]));
|