flypod 0.6.1 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +425 -187
- package/dist/bin/deploy.js +499 -1038
- package/dist/cli-g2wb2hxm.js +1435 -0
- package/dist/src/cli/client.d.ts +99 -0
- package/dist/src/cli/commands.d.ts +68 -0
- package/dist/src/cli/paths.d.ts +17 -0
- package/dist/src/cli/projects.d.ts +35 -0
- package/dist/src/cli/session.d.ts +11 -0
- package/dist/src/cli/skill.d.ts +135 -0
- package/dist/src/cli/source.d.ts +7 -0
- package/dist/src/cli.d.ts +72 -0
- package/dist/src/cli.js +1 -1
- package/dist/src/deploy-source.d.ts +20 -0
- package/package.json +14 -16
- package/dist/cli-ynzcc4xy.js +0 -709
package/dist/bin/deploy.js
CHANGED
|
@@ -1,52 +1,26 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
+
atomicWriteFile,
|
|
4
|
+
clearSession,
|
|
3
5
|
collectDist,
|
|
6
|
+
createClient,
|
|
4
7
|
deploySite,
|
|
8
|
+
installSkill,
|
|
9
|
+
projectsFilePath,
|
|
10
|
+
resolveCredentials,
|
|
5
11
|
resolveDeployDir,
|
|
12
|
+
saveSession,
|
|
6
13
|
zipSync
|
|
7
|
-
} from "../cli-
|
|
14
|
+
} from "../cli-g2wb2hxm.js";
|
|
8
15
|
|
|
9
16
|
// bin/deploy.ts
|
|
10
|
-
import { readFile as
|
|
11
|
-
import { homedir
|
|
17
|
+
import { readFile as readFile2 } from "node:fs/promises";
|
|
18
|
+
import { homedir } from "node:os";
|
|
12
19
|
import { relative } from "node:path";
|
|
13
20
|
import { fileURLToPath } from "node:url";
|
|
14
21
|
|
|
15
22
|
// src/cli/projects.ts
|
|
16
23
|
import { readFile } from "node:fs/promises";
|
|
17
|
-
|
|
18
|
-
// src/cli/paths.ts
|
|
19
|
-
import { mkdir, rename, writeFile } from "node:fs/promises";
|
|
20
|
-
import { homedir, platform } from "node:os";
|
|
21
|
-
import { dirname, join } from "node:path";
|
|
22
|
-
function configDir(env = process.env) {
|
|
23
|
-
if (env.FLYPOD_CONFIG_DIR)
|
|
24
|
-
return env.FLYPOD_CONFIG_DIR;
|
|
25
|
-
const os = platform();
|
|
26
|
-
if (os === "darwin") {
|
|
27
|
-
return join(homedir(), "Library", "Application Support", "flypod");
|
|
28
|
-
}
|
|
29
|
-
if (os === "win32") {
|
|
30
|
-
const appData = env.APPDATA ?? join(homedir(), "AppData", "Roaming");
|
|
31
|
-
return join(appData, "flypod");
|
|
32
|
-
}
|
|
33
|
-
const xdg = env.XDG_CONFIG_HOME ?? join(homedir(), ".config");
|
|
34
|
-
return join(xdg, "flypod");
|
|
35
|
-
}
|
|
36
|
-
function sessionFilePath(env = process.env) {
|
|
37
|
-
return join(configDir(env), "session.json");
|
|
38
|
-
}
|
|
39
|
-
function projectsFilePath(env = process.env) {
|
|
40
|
-
return join(configDir(env), "projects.json");
|
|
41
|
-
}
|
|
42
|
-
async function atomicWriteFile(path, content) {
|
|
43
|
-
await mkdir(dirname(path), { recursive: true });
|
|
44
|
-
const tmp = `${path}.tmp`;
|
|
45
|
-
await writeFile(tmp, content, { mode: 384 });
|
|
46
|
-
await rename(tmp, path);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// src/cli/projects.ts
|
|
50
24
|
var MAX_PROJECTS = 64;
|
|
51
25
|
function prune(projects, now) {
|
|
52
26
|
const out = {};
|
|
@@ -61,8 +35,14 @@ function cap(projects) {
|
|
|
61
35
|
const entries = Object.entries(projects);
|
|
62
36
|
if (entries.length <= MAX_PROJECTS)
|
|
63
37
|
return projects;
|
|
38
|
+
const irreplaceable = ([, r]) => r.expires_at !== null && typeof r.manage_token === "string";
|
|
64
39
|
entries.sort(([, a], [, b]) => b.last_used - a.last_used);
|
|
65
|
-
|
|
40
|
+
const keep = [
|
|
41
|
+
...entries.filter((e) => irreplaceable(e)),
|
|
42
|
+
...entries.filter((e) => !irreplaceable(e))
|
|
43
|
+
].slice(0, MAX_PROJECTS);
|
|
44
|
+
keep.sort(([, a], [, b]) => b.last_used - a.last_used);
|
|
45
|
+
return Object.fromEntries(keep);
|
|
66
46
|
}
|
|
67
47
|
async function loadProjects(env) {
|
|
68
48
|
try {
|
|
@@ -114,46 +94,7 @@ async function forgetSite(site_id, env) {
|
|
|
114
94
|
return removed;
|
|
115
95
|
}
|
|
116
96
|
|
|
117
|
-
// src/cli/session.ts
|
|
118
|
-
import { readFile as readFile2, unlink } from "node:fs/promises";
|
|
119
|
-
async function resolveAuth(env = process.env) {
|
|
120
|
-
const session = await loadSession(env);
|
|
121
|
-
const apiKey = env.FLYPOD_TOKEN ?? session?.session_token ?? env.FLYPOD_API_KEY;
|
|
122
|
-
const baseUrl = session?.base_url ?? env.DEPLOY_URL ?? "https://flypod.dev";
|
|
123
|
-
return { apiKey, baseUrl };
|
|
124
|
-
}
|
|
125
|
-
async function loadSession(env) {
|
|
126
|
-
try {
|
|
127
|
-
const path = sessionFilePath(env);
|
|
128
|
-
const text = await readFile2(path, "utf8");
|
|
129
|
-
const parsed = JSON.parse(text);
|
|
130
|
-
if (typeof parsed?.session_token === "string" && typeof parsed?.base_url === "string" && typeof parsed?.created_at === "number") {
|
|
131
|
-
return parsed;
|
|
132
|
-
}
|
|
133
|
-
return null;
|
|
134
|
-
} catch {
|
|
135
|
-
return null;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
async function saveSession(session, env) {
|
|
139
|
-
const path = sessionFilePath(env);
|
|
140
|
-
await atomicWriteFile(path, `${JSON.stringify(session, null, 2)}
|
|
141
|
-
`);
|
|
142
|
-
return path;
|
|
143
|
-
}
|
|
144
|
-
async function clearSession(env) {
|
|
145
|
-
try {
|
|
146
|
-
await unlink(sessionFilePath(env));
|
|
147
|
-
return true;
|
|
148
|
-
} catch {
|
|
149
|
-
return false;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
97
|
// src/cli/commands.ts
|
|
154
|
-
function baseUrlFrom(env = process.env) {
|
|
155
|
-
return env.DEPLOY_URL ?? "https://flypod.dev";
|
|
156
|
-
}
|
|
157
98
|
function siteUrlFrom(site_id, baseUrl) {
|
|
158
99
|
const host = new URL(baseUrl).host;
|
|
159
100
|
const scheme = new URL(baseUrl).protocol.replace(":", "");
|
|
@@ -210,6 +151,26 @@ Drop this folder's remembered site link.
|
|
|
210
151
|
Flags:
|
|
211
152
|
--site <id> Forget all links to this site.
|
|
212
153
|
-h, --help Show this help.`,
|
|
154
|
+
token: `flypod token [flags]
|
|
155
|
+
|
|
156
|
+
Reveal the manage token for a site you deployed.
|
|
157
|
+
|
|
158
|
+
The token is a secret: anyone holding it can update, roll back, or claim that
|
|
159
|
+
site. Deploy output hides it by default for exactly that reason — it is already
|
|
160
|
+
saved for this folder, so update/rollback/versions work without it. You only
|
|
161
|
+
need to reveal it to act on the site from a different machine or folder.
|
|
162
|
+
|
|
163
|
+
flypod token Reveal this folder's site token.
|
|
164
|
+
flypod token --site <id> Reveal a remembered site's token by id.
|
|
165
|
+
|
|
166
|
+
The token goes to stdout, so it pipes:
|
|
167
|
+
|
|
168
|
+
flypod token | pbcopy
|
|
169
|
+
TOKEN=$(flypod token)
|
|
170
|
+
|
|
171
|
+
Flags:
|
|
172
|
+
--site <id> Reveal the token for this site id instead of this folder.
|
|
173
|
+
-h, --help Show this help.`,
|
|
213
174
|
login: `flypod login [flags]
|
|
214
175
|
|
|
215
176
|
Authenticate with flypod via the browser (device authorization).
|
|
@@ -228,68 +189,7 @@ Forget the saved session token. Doesn't affect the server.`,
|
|
|
228
189
|
List sites you own (requires login or FLYPOD_TOKEN). Outputs JSON on stdout.`,
|
|
229
190
|
claim: `flypod claim <site_id> <claim_token>
|
|
230
191
|
|
|
231
|
-
Attach an anonymous deploy to your account (requires login or FLYPOD_TOKEN). Outputs JSON on stdout
|
|
232
|
-
comments: `flypod comments <verb> [args]
|
|
233
|
-
|
|
234
|
-
Manage v0.1 comments on a flypod site. All ops talk to the site's host
|
|
235
|
-
(\`DEPLOY_URL\` or the default \`https://flypod.dev\`) over HTTPS.
|
|
236
|
-
|
|
237
|
-
flypod comments mode <anonymous|passcode|approved> --site <id> [--passcode <s>]
|
|
238
|
-
Enable comments and set the access mode.
|
|
239
|
-
flypod comments off --site <id>
|
|
240
|
-
Disable comments (data is preserved).
|
|
241
|
-
flypod comments list <site> [--page <p>] [--open|--resolved|--all] [--limit N] [--json]
|
|
242
|
-
List threads. With --json, prints one thread per line.
|
|
243
|
-
flypod comments show <site> <thread_id> [--json]
|
|
244
|
-
Print a thread with its full comment tree.
|
|
245
|
-
flypod comments post <site> --page <path> --target <json> --body <text> [--json]
|
|
246
|
-
Create a comment. REQUIRES an fau_ token.
|
|
247
|
-
flypod comments resolve <site> <thread_id>
|
|
248
|
-
Mark a thread resolved.
|
|
249
|
-
flypod comments reopen <site> <thread_id>
|
|
250
|
-
Re-open a resolved thread.
|
|
251
|
-
flypod comments webhook set <site> --url <https://...> --secret <s>
|
|
252
|
-
Configure outbound webhooks.
|
|
253
|
-
flypod comments webhook remove <site>
|
|
254
|
-
Stop sending webhooks.
|
|
255
|
-
|
|
256
|
-
Auth:
|
|
257
|
-
Reads FLYPOD_TOKEN (preferred) or your \`flypod login\` session. Write ops
|
|
258
|
-
reject deploy keys (\`fk_\`) with "comments operations require an fau_ token".
|
|
259
|
-
Mint an fau_ token via \`flypod keys create --agent <agent_id>\`.
|
|
260
|
-
|
|
261
|
-
Flags:
|
|
262
|
-
--json Emit JSON on stdout (one thread per line for \`list\`).
|
|
263
|
-
-h, --help Show this help.`,
|
|
264
|
-
install: `flypod install skill [targets] [flags]
|
|
265
|
-
|
|
266
|
-
Teach your coding agents (Claude Code, Codex, Cursor, …) how to deploy with flypod.
|
|
267
|
-
|
|
268
|
-
flypod install skill Interactive picker (TTY).
|
|
269
|
-
flypod install skill --claude Write Claude Code skill.
|
|
270
|
-
flypod install skill --all Write every supported target.
|
|
271
|
-
flypod install skill --global Write to home directory (for AGENTS.md, Claude, Gemini).
|
|
272
|
-
flypod install skill --list Print detected targets without writing.
|
|
273
|
-
flypod install skill --dry-run Show what would be written.
|
|
274
|
-
flypod install skill --yes Skip interactive confirmation.
|
|
275
|
-
|
|
276
|
-
Targets:
|
|
277
|
-
--agents AGENTS.md (Codex, Cursor, Copilot, Gemini, Windsurf, +more)
|
|
278
|
-
--claude Claude Code (.claude/skills/flypod/SKILL.md)
|
|
279
|
-
--cursor Cursor (.cursor/rules/flypod.mdc)
|
|
280
|
-
--copilot GitHub Copilot (.github/copilot-instructions.md)
|
|
281
|
-
--windsurf Windsurf (.windsurf/rules/flypod.md)
|
|
282
|
-
--cline Cline (.clinerules/flypod.md)
|
|
283
|
-
--roo Roo Code (.roo/rules/flypod.md)
|
|
284
|
-
--gemini Gemini CLI (GEMINI.md)
|
|
285
|
-
|
|
286
|
-
Flags:
|
|
287
|
-
--all Write every supported target.
|
|
288
|
-
--global Write to home directory instead of project root.
|
|
289
|
-
--list Print detected targets without writing.
|
|
290
|
-
--dry-run Show what would be written (alias: --print).
|
|
291
|
-
--yes, -y Skip the interactive picker.
|
|
292
|
-
-h, --help Show this help.`
|
|
192
|
+
Attach an anonymous deploy to your account (requires login or FLYPOD_TOKEN). Outputs JSON on stdout.`
|
|
293
193
|
};
|
|
294
194
|
function showSubHelp(name, io) {
|
|
295
195
|
const help = SUBCOMMAND_HELP[name];
|
|
@@ -302,8 +202,13 @@ function failJson(error, io) {
|
|
|
302
202
|
io.out(JSON.stringify({ ok: false, error }));
|
|
303
203
|
return 1;
|
|
304
204
|
}
|
|
305
|
-
|
|
306
|
-
|
|
205
|
+
function fail(msg, args, io, opts = {}) {
|
|
206
|
+
if (args.json)
|
|
207
|
+
return failJson(msg, io);
|
|
208
|
+
if (!opts.silent)
|
|
209
|
+
io.err(msg);
|
|
210
|
+
return 1;
|
|
211
|
+
}
|
|
307
212
|
var POLL_MAX_ATTEMPTS = 120;
|
|
308
213
|
async function login(args, io) {
|
|
309
214
|
if (args.help) {
|
|
@@ -311,19 +216,15 @@ async function login(args, io) {
|
|
|
311
216
|
return 0;
|
|
312
217
|
}
|
|
313
218
|
const env = io.env ?? process.env;
|
|
314
|
-
const baseUrl =
|
|
219
|
+
const baseUrl = resolveCredentials(env, null).baseUrl;
|
|
315
220
|
if (args.token) {
|
|
316
221
|
await saveSession({ session_token: args.token, base_url: baseUrl, created_at: Date.now() }, env);
|
|
317
222
|
io.err("Logged in.");
|
|
318
223
|
await attachAnonymousSites(args.token, baseUrl, io, env);
|
|
319
224
|
return 0;
|
|
320
225
|
}
|
|
321
|
-
const
|
|
322
|
-
const startRes = await
|
|
323
|
-
method: "POST",
|
|
324
|
-
headers: { "content-type": "application/json" },
|
|
325
|
-
body: JSON.stringify({ client_id: DEVICE_CLIENT_ID })
|
|
326
|
-
});
|
|
226
|
+
const client = await createClient({ env, fetch: io.fetch, overrides: { baseUrl } });
|
|
227
|
+
const startRes = await client.deviceCode();
|
|
327
228
|
if (!startRes.ok) {
|
|
328
229
|
io.err(`flypod login: server returned ${startRes.status}. Is the server running?`);
|
|
329
230
|
return 1;
|
|
@@ -339,15 +240,7 @@ async function login(args, io) {
|
|
|
339
240
|
let pollMs = (start.interval ?? 5) * 1000;
|
|
340
241
|
for (let attempt = 0;attempt < POLL_MAX_ATTEMPTS; attempt++) {
|
|
341
242
|
await new Promise((r) => setTimeout(r, pollMs));
|
|
342
|
-
const pollRes = await
|
|
343
|
-
method: "POST",
|
|
344
|
-
headers: { "content-type": "application/json" },
|
|
345
|
-
body: JSON.stringify({
|
|
346
|
-
grant_type: DEVICE_GRANT_TYPE,
|
|
347
|
-
device_code: start.device_code,
|
|
348
|
-
client_id: DEVICE_CLIENT_ID
|
|
349
|
-
})
|
|
350
|
-
});
|
|
243
|
+
const pollRes = await client.deviceToken(start.device_code);
|
|
351
244
|
if (pollRes.ok) {
|
|
352
245
|
const { access_token } = await pollRes.json();
|
|
353
246
|
await saveSession({ session_token: access_token, base_url: baseUrl, created_at: Date.now() }, env);
|
|
@@ -384,17 +277,15 @@ async function attachAnonymousSites(apiKey, baseUrl, io, env) {
|
|
|
384
277
|
const noun = candidates.length === 1 ? "site" : "sites";
|
|
385
278
|
io.err(`Found ${candidates.length} anonymous ${noun} on this machine.`);
|
|
386
279
|
io.err(` Attaching to your account…`);
|
|
387
|
-
const
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
body: JSON.stringify({
|
|
392
|
-
sites: candidates.map(([, rec]) => ({
|
|
393
|
-
site_id: rec.site_id,
|
|
394
|
-
manage_token: rec.manage_token
|
|
395
|
-
}))
|
|
396
|
-
})
|
|
280
|
+
const client = await createClient({
|
|
281
|
+
env,
|
|
282
|
+
fetch: io.fetch,
|
|
283
|
+
overrides: { token: apiKey, baseUrl }
|
|
397
284
|
});
|
|
285
|
+
const res = await client.bulkAttach(candidates.map(([, rec]) => ({
|
|
286
|
+
site_id: rec.site_id,
|
|
287
|
+
manage_token: rec.manage_token
|
|
288
|
+
})));
|
|
398
289
|
if (!res.ok) {
|
|
399
290
|
io.err(` Could not attach (${res.status}). Try again later.`);
|
|
400
291
|
return;
|
|
@@ -405,7 +296,8 @@ async function attachAnonymousSites(apiKey, baseUrl, io, env) {
|
|
|
405
296
|
if (attached.size > 0) {
|
|
406
297
|
for (const [dir, rec] of candidates) {
|
|
407
298
|
if (attached.has(rec.site_id)) {
|
|
408
|
-
|
|
299
|
+
const { manage_token: _dead, ...owned } = rec;
|
|
300
|
+
projects[dir] = { ...owned, expires_at: null };
|
|
409
301
|
}
|
|
410
302
|
}
|
|
411
303
|
await saveProjects(projects, env);
|
|
@@ -429,17 +321,12 @@ async function logout(_args, io) {
|
|
|
429
321
|
}
|
|
430
322
|
async function list(_args, io) {
|
|
431
323
|
const env = io.env ?? process.env;
|
|
432
|
-
const
|
|
433
|
-
|
|
434
|
-
const baseUrl = session?.base_url ?? baseUrlFrom(env);
|
|
435
|
-
if (!apiKey) {
|
|
324
|
+
const client = await createClient({ env, fetch: io.fetch });
|
|
325
|
+
if (!client.token) {
|
|
436
326
|
io.err("Not signed in. Run `flypod login` first or set FLYPOD_TOKEN.");
|
|
437
327
|
return 1;
|
|
438
328
|
}
|
|
439
|
-
const
|
|
440
|
-
const res = await fetchImpl(`${baseUrl}/account/sites`, {
|
|
441
|
-
headers: { authorization: `Bearer ${apiKey}` }
|
|
442
|
-
});
|
|
329
|
+
const res = await client.listSites();
|
|
443
330
|
if (!res.ok) {
|
|
444
331
|
io.err(`flypod list: server returned ${res.status}.`);
|
|
445
332
|
return 1;
|
|
@@ -455,10 +342,8 @@ async function list(_args, io) {
|
|
|
455
342
|
}
|
|
456
343
|
async function claim(args, io) {
|
|
457
344
|
const env = io.env ?? process.env;
|
|
458
|
-
const
|
|
459
|
-
|
|
460
|
-
const baseUrl = session?.base_url ?? baseUrlFrom(env);
|
|
461
|
-
if (!apiKey) {
|
|
345
|
+
const client = await createClient({ env, fetch: io.fetch });
|
|
346
|
+
if (!client.token) {
|
|
462
347
|
io.err("Not signed in. Run `flypod login` first or set FLYPOD_TOKEN.");
|
|
463
348
|
return 1;
|
|
464
349
|
}
|
|
@@ -466,20 +351,25 @@ async function claim(args, io) {
|
|
|
466
351
|
io.err("Usage: flypod claim <site_id> <claim_token>");
|
|
467
352
|
return 2;
|
|
468
353
|
}
|
|
469
|
-
const
|
|
470
|
-
const res = await fetchImpl(`${baseUrl}/sites/${args.site_id}/claim`, {
|
|
471
|
-
method: "POST",
|
|
472
|
-
headers: {
|
|
473
|
-
"content-type": "application/json",
|
|
474
|
-
authorization: `Bearer ${apiKey}`
|
|
475
|
-
},
|
|
476
|
-
body: JSON.stringify({ claim_token: args.token })
|
|
477
|
-
});
|
|
354
|
+
const res = await client.claimSite(args.site_id, args.token);
|
|
478
355
|
if (!res.ok) {
|
|
479
|
-
io.err(`flypod claim: server returned ${res.status}.`);
|
|
356
|
+
io.err(res.status === 409 ? `flypod claim: ${args.site_id} already belongs to another account.` : `flypod claim: server returned ${res.status}.`);
|
|
480
357
|
return 1;
|
|
481
358
|
}
|
|
482
359
|
const body = await res.json();
|
|
360
|
+
try {
|
|
361
|
+
const projects = await loadProjects(env);
|
|
362
|
+
let changed = false;
|
|
363
|
+
for (const [dir, r] of Object.entries(projects)) {
|
|
364
|
+
if (r.site_id === body.site_id && (r.expires_at !== null || r.manage_token)) {
|
|
365
|
+
const { manage_token: _dead, ...owned } = r;
|
|
366
|
+
projects[dir] = { ...owned, expires_at: null };
|
|
367
|
+
changed = true;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
if (changed)
|
|
371
|
+
await saveProjects(projects, env);
|
|
372
|
+
} catch {}
|
|
483
373
|
io.out(JSON.stringify({ ok: true, site_id: body.site_id, owner_account_id: body.owner_account_id }));
|
|
484
374
|
io.err(`Claimed. Owned by ${body.owner_account_id}.`);
|
|
485
375
|
return 0;
|
|
@@ -493,14 +383,28 @@ async function resolveTarget(args, io) {
|
|
|
493
383
|
const rec = await projectForDir(cwd, env);
|
|
494
384
|
return rec ? { site_id: rec.site_id, rec, dir: cwd } : null;
|
|
495
385
|
}
|
|
496
|
-
async function
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
386
|
+
async function withTarget(name, args, io) {
|
|
387
|
+
if (args.help) {
|
|
388
|
+
showSubHelp(name, io);
|
|
389
|
+
return 0;
|
|
390
|
+
}
|
|
391
|
+
const env = io.env ?? process.env;
|
|
392
|
+
const target = await resolveTarget(args, io);
|
|
393
|
+
if (!target)
|
|
394
|
+
return fail(NO_SITE, args, io);
|
|
395
|
+
return { env, target };
|
|
396
|
+
}
|
|
397
|
+
function clientForTarget(target, args, io) {
|
|
398
|
+
return createClient({
|
|
399
|
+
env: io.env ?? process.env,
|
|
400
|
+
fetch: io.fetch,
|
|
401
|
+
cwd: io.cwd,
|
|
402
|
+
overrides: {
|
|
403
|
+
token: args.token,
|
|
404
|
+
manageToken: target.rec?.manage_token,
|
|
405
|
+
baseUrl: target.rec?.base_url
|
|
406
|
+
}
|
|
407
|
+
});
|
|
504
408
|
}
|
|
505
409
|
async function healGone(target, io, env) {
|
|
506
410
|
if (target.dir)
|
|
@@ -511,9 +415,8 @@ function unauthorized(target, io) {
|
|
|
511
415
|
io.err(`Unauthorized for ${target.site_id}. Run \`flypod login\` or pass --token <manage_token>.`);
|
|
512
416
|
}
|
|
513
417
|
async function fetchSite(target, args, io, env) {
|
|
514
|
-
const
|
|
515
|
-
const
|
|
516
|
-
const res = await fetchImpl(`${baseUrl}/sites/${target.site_id}`, { headers: authHeaders(auth) });
|
|
418
|
+
const client = await clientForTarget(target, args, io);
|
|
419
|
+
const res = await client.getSite(target.site_id);
|
|
517
420
|
if (res.status === 401 || res.status === 403) {
|
|
518
421
|
unauthorized(target, io);
|
|
519
422
|
return { error: 1 };
|
|
@@ -534,46 +437,25 @@ async function touchLink(target, version_id, env) {
|
|
|
534
437
|
}
|
|
535
438
|
}
|
|
536
439
|
async function update(args, io) {
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
return
|
|
540
|
-
}
|
|
541
|
-
const env = io.env ?? process.env;
|
|
440
|
+
const pre = await withTarget("update", args, io);
|
|
441
|
+
if (typeof pre === "number")
|
|
442
|
+
return pre;
|
|
443
|
+
const { env, target } = pre;
|
|
542
444
|
const cwd = io.cwd ?? process.cwd();
|
|
543
|
-
const target = await resolveTarget(args, io);
|
|
544
|
-
if (!target) {
|
|
545
|
-
if (args.json)
|
|
546
|
-
return failJson(NO_SITE, io);
|
|
547
|
-
io.err(NO_SITE);
|
|
548
|
-
return 1;
|
|
549
|
-
}
|
|
550
445
|
let dir;
|
|
551
446
|
try {
|
|
552
447
|
dir = await resolveDeployDir({ cwd, explicit: args.path });
|
|
553
448
|
} catch (e) {
|
|
554
|
-
|
|
555
|
-
if (args.json)
|
|
556
|
-
return failJson(msg, io);
|
|
557
|
-
io.err(msg);
|
|
558
|
-
return 1;
|
|
449
|
+
return fail(e.message, args, io);
|
|
559
450
|
}
|
|
560
451
|
let files;
|
|
561
452
|
try {
|
|
562
453
|
files = await collectDist(dir);
|
|
563
454
|
} catch (e) {
|
|
564
|
-
|
|
565
|
-
if (args.json)
|
|
566
|
-
return failJson(msg, io);
|
|
567
|
-
io.err(msg);
|
|
568
|
-
return 1;
|
|
455
|
+
return fail(`Could not read ${dir}: ${e.message}`, args, io);
|
|
569
456
|
}
|
|
570
|
-
const
|
|
571
|
-
const
|
|
572
|
-
const res = await fetchImpl(`${baseUrl}/sites/${target.site_id}/deploys`, {
|
|
573
|
-
method: "POST",
|
|
574
|
-
headers: authHeaders(auth, { "content-type": "application/zip" }),
|
|
575
|
-
body: zipSync(files)
|
|
576
|
-
});
|
|
457
|
+
const client = await clientForTarget(target, args, io);
|
|
458
|
+
const res = await client.redeploy(target.site_id, zipSync(files));
|
|
577
459
|
if (res.status === 401 || res.status === 403) {
|
|
578
460
|
unauthorized(target, io);
|
|
579
461
|
return 1;
|
|
@@ -606,18 +488,10 @@ async function update(args, io) {
|
|
|
606
488
|
return 0;
|
|
607
489
|
}
|
|
608
490
|
async function versions(args, io) {
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
return
|
|
612
|
-
}
|
|
613
|
-
const env = io.env ?? process.env;
|
|
614
|
-
const target = await resolveTarget(args, io);
|
|
615
|
-
if (!target) {
|
|
616
|
-
if (args.json)
|
|
617
|
-
return failJson(NO_SITE, io);
|
|
618
|
-
io.err(NO_SITE);
|
|
619
|
-
return 1;
|
|
620
|
-
}
|
|
491
|
+
const pre = await withTarget("versions", args, io);
|
|
492
|
+
if (typeof pre === "number")
|
|
493
|
+
return pre;
|
|
494
|
+
const { env, target } = pre;
|
|
621
495
|
const site = await fetchSite(target, args, io, env);
|
|
622
496
|
if ("error" in site)
|
|
623
497
|
return site.error;
|
|
@@ -632,18 +506,10 @@ async function versions(args, io) {
|
|
|
632
506
|
return 0;
|
|
633
507
|
}
|
|
634
508
|
async function rollback(args, io) {
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
return
|
|
638
|
-
}
|
|
639
|
-
const env = io.env ?? process.env;
|
|
640
|
-
const target = await resolveTarget(args, io);
|
|
641
|
-
if (!target) {
|
|
642
|
-
if (args.json)
|
|
643
|
-
return failJson(NO_SITE, io);
|
|
644
|
-
io.err(NO_SITE);
|
|
645
|
-
return 1;
|
|
646
|
-
}
|
|
509
|
+
const pre = await withTarget("rollback", args, io);
|
|
510
|
+
if (typeof pre === "number")
|
|
511
|
+
return pre;
|
|
512
|
+
const { env, target } = pre;
|
|
647
513
|
const site = await fetchSite(target, args, io, env);
|
|
648
514
|
if ("error" in site)
|
|
649
515
|
return site.error;
|
|
@@ -657,59 +523,32 @@ async function rollback(args, io) {
|
|
|
657
523
|
else if (prefixed.length === 1)
|
|
658
524
|
chosen = prefixed[0]?.version_id;
|
|
659
525
|
else if (prefixed.length === 0) {
|
|
660
|
-
|
|
661
|
-
if (args.json)
|
|
662
|
-
return failJson(msg, io);
|
|
663
|
-
io.err(msg);
|
|
664
|
-
return 1;
|
|
526
|
+
return fail(`No version matches '${args.version}'.`, args, io);
|
|
665
527
|
} else {
|
|
666
|
-
|
|
667
|
-
if (args.json)
|
|
668
|
-
return failJson(msg, io);
|
|
669
|
-
io.err(msg);
|
|
670
|
-
return 1;
|
|
528
|
+
return fail(`'${args.version}' is ambiguous — it matches ${prefixed.length} versions.`, args, io);
|
|
671
529
|
}
|
|
672
530
|
} else {
|
|
673
531
|
if (vers.length < 2) {
|
|
674
|
-
|
|
675
|
-
if (args.json)
|
|
676
|
-
return failJson(msg, io);
|
|
677
|
-
io.err(msg);
|
|
678
|
-
return 1;
|
|
532
|
+
return fail("Only one version exists — nothing to roll back to.", args, io);
|
|
679
533
|
}
|
|
680
534
|
const liveIdx = vers.findIndex((v) => v.version_id === live_version_id);
|
|
681
535
|
if (liveIdx <= 0) {
|
|
682
|
-
|
|
683
|
-
if (args.json)
|
|
684
|
-
return failJson(msg, io);
|
|
685
|
-
io.err(msg);
|
|
686
|
-
return 1;
|
|
536
|
+
return fail("Already at the oldest version.", args, io);
|
|
687
537
|
}
|
|
688
538
|
chosen = vers[liveIdx - 1]?.version_id;
|
|
689
539
|
}
|
|
690
|
-
const
|
|
691
|
-
const
|
|
692
|
-
const res = await fetchImpl(`${baseUrl}/sites/${target.site_id}/rollback`, {
|
|
693
|
-
method: "POST",
|
|
694
|
-
headers: authHeaders(auth, { "content-type": "application/json" }),
|
|
695
|
-
body: JSON.stringify({ version_id: chosen })
|
|
696
|
-
});
|
|
540
|
+
const client = await clientForTarget(target, args, io);
|
|
541
|
+
const res = await client.rollback(target.site_id, chosen);
|
|
697
542
|
if (res.status === 404) {
|
|
698
543
|
await healGone(target, io, env);
|
|
699
|
-
|
|
700
|
-
return failJson(`Site ${target.site_id} not found.`, io);
|
|
701
|
-
return 1;
|
|
544
|
+
return fail(`Site ${target.site_id} not found.`, args, io, { silent: true });
|
|
702
545
|
}
|
|
703
546
|
if (!res.ok) {
|
|
704
|
-
|
|
705
|
-
if (args.json)
|
|
706
|
-
return failJson(msg, io);
|
|
707
|
-
io.err(msg);
|
|
708
|
-
return 1;
|
|
547
|
+
return fail(`flypod rollback: server returned ${res.status}.`, args, io);
|
|
709
548
|
}
|
|
710
549
|
const body = await res.json();
|
|
711
550
|
await touchLink(target, body.live_version_id, env);
|
|
712
|
-
const url = target.rec?.url ?? siteUrlFrom(target.site_id, baseUrl);
|
|
551
|
+
const url = target.rec?.url ?? siteUrlFrom(target.site_id, client.baseUrl);
|
|
713
552
|
if (args.json) {
|
|
714
553
|
io.out(JSON.stringify({
|
|
715
554
|
ok: true,
|
|
@@ -723,6 +562,26 @@ async function rollback(args, io) {
|
|
|
723
562
|
io.out(url);
|
|
724
563
|
return 0;
|
|
725
564
|
}
|
|
565
|
+
async function token(args, io) {
|
|
566
|
+
if (args.help) {
|
|
567
|
+
showSubHelp("token", io);
|
|
568
|
+
return 0;
|
|
569
|
+
}
|
|
570
|
+
const env = io.env ?? process.env;
|
|
571
|
+
const record = args.site ? Object.values(await loadProjects(env)).find((p) => p.site_id === args.site) : await projectForDir(io.cwd ?? process.cwd(), env);
|
|
572
|
+
if (!record) {
|
|
573
|
+
io.err(args.site ? `No remembered site ${args.site}. Tokens are only stored for sites deployed from this machine.` : "Nothing linked to this folder. Deploy first, or pass --site <id>.");
|
|
574
|
+
return 1;
|
|
575
|
+
}
|
|
576
|
+
if (!record.manage_token) {
|
|
577
|
+
io.err(`Site ${record.site_id} has no stored manage token. If you claimed it, it authenticates with your account — run \`flypod login\`.`);
|
|
578
|
+
return 1;
|
|
579
|
+
}
|
|
580
|
+
io.err(`Manage token for ${record.site_id} — treat it like a password.
|
|
581
|
+
`);
|
|
582
|
+
io.out(record.manage_token);
|
|
583
|
+
return 0;
|
|
584
|
+
}
|
|
726
585
|
async function forget(args, io) {
|
|
727
586
|
if (args.help) {
|
|
728
587
|
showSubHelp("forget", io);
|
|
@@ -741,33 +600,89 @@ async function forget(args, io) {
|
|
|
741
600
|
return 0;
|
|
742
601
|
}
|
|
743
602
|
|
|
603
|
+
// src/cli/flags.ts
|
|
604
|
+
function parseFlags(argv, spec) {
|
|
605
|
+
const flags = {};
|
|
606
|
+
const positionals = [];
|
|
607
|
+
const unknown = [];
|
|
608
|
+
let terminated = false;
|
|
609
|
+
for (let i = 0;i < argv.length; i++) {
|
|
610
|
+
const a = argv[i];
|
|
611
|
+
if (terminated) {
|
|
612
|
+
positionals.push(a);
|
|
613
|
+
continue;
|
|
614
|
+
}
|
|
615
|
+
if (a === "--") {
|
|
616
|
+
terminated = true;
|
|
617
|
+
continue;
|
|
618
|
+
}
|
|
619
|
+
const eq = a.startsWith("--") ? a.indexOf("=") : -1;
|
|
620
|
+
if (eq !== -1) {
|
|
621
|
+
const name = a.slice(0, eq);
|
|
622
|
+
if (spec[name] === "value")
|
|
623
|
+
flags[name] = a.slice(eq + 1);
|
|
624
|
+
else
|
|
625
|
+
unknown.push(a);
|
|
626
|
+
continue;
|
|
627
|
+
}
|
|
628
|
+
const kind = spec[a];
|
|
629
|
+
if (kind === "value") {
|
|
630
|
+
if (i + 1 < argv.length)
|
|
631
|
+
flags[a] = argv[++i];
|
|
632
|
+
else
|
|
633
|
+
unknown.push(a);
|
|
634
|
+
continue;
|
|
635
|
+
}
|
|
636
|
+
if (kind === "bool") {
|
|
637
|
+
flags[a] = true;
|
|
638
|
+
continue;
|
|
639
|
+
}
|
|
640
|
+
if (a.startsWith("-"))
|
|
641
|
+
unknown.push(a);
|
|
642
|
+
else
|
|
643
|
+
positionals.push(a);
|
|
644
|
+
}
|
|
645
|
+
return { flags, positionals, unknown };
|
|
646
|
+
}
|
|
647
|
+
|
|
744
648
|
// src/cli/comments.ts
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
const
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
649
|
+
var NO_SITE2 = "No site given, and no flypod site is linked to this folder. " + "Pass --site <id>, or run this from a folder you have deployed from.";
|
|
650
|
+
async function resolveCommentsSite(explicit, io) {
|
|
651
|
+
if (explicit)
|
|
652
|
+
return explicit;
|
|
653
|
+
const rec = await projectForDir(io.cwd ?? process.cwd(), io.env ?? process.env);
|
|
654
|
+
return rec?.site_id;
|
|
655
|
+
}
|
|
656
|
+
function failNoSite(json, io) {
|
|
657
|
+
if (json) {
|
|
658
|
+
io.out(JSON.stringify({ ok: false, error: "no_site" }));
|
|
659
|
+
return 1;
|
|
660
|
+
}
|
|
661
|
+
io.err(NO_SITE2);
|
|
662
|
+
return 2;
|
|
663
|
+
}
|
|
664
|
+
async function resolveSiteAndThread(f, io) {
|
|
665
|
+
if (f.site)
|
|
666
|
+
return { site: f.site, thread_id: f.positionals[0] };
|
|
667
|
+
if (f.positionals.length >= 2) {
|
|
668
|
+
return { site: f.positionals[0], thread_id: f.positionals[1] };
|
|
669
|
+
}
|
|
670
|
+
return {
|
|
671
|
+
site: await resolveCommentsSite(undefined, io),
|
|
672
|
+
thread_id: f.positionals[0]
|
|
673
|
+
};
|
|
674
|
+
}
|
|
675
|
+
function requireCommentWriteToken(token2, io) {
|
|
676
|
+
if (!token2) {
|
|
677
|
+
io.err("Not signed in. Run `flypod login` or set FLYPOD_TOKEN.");
|
|
757
678
|
return 3;
|
|
758
679
|
}
|
|
759
|
-
if (
|
|
760
|
-
io.err("comments operations require an
|
|
680
|
+
if (token2.startsWith("fk_")) {
|
|
681
|
+
io.err("comments operations require an account session or agent token");
|
|
761
682
|
return 3;
|
|
762
683
|
}
|
|
763
684
|
return null;
|
|
764
685
|
}
|
|
765
|
-
function authHeaders2(token) {
|
|
766
|
-
return token ? { authorization: `Bearer ${token}` } : {};
|
|
767
|
-
}
|
|
768
|
-
function jsonHeaders(token) {
|
|
769
|
-
return { "content-type": "application/json", ...authHeaders2(token) };
|
|
770
|
-
}
|
|
771
686
|
async function readErrorBody(res) {
|
|
772
687
|
try {
|
|
773
688
|
const body = await res.json();
|
|
@@ -780,7 +695,8 @@ async function readErrorBody(res) {
|
|
|
780
695
|
}
|
|
781
696
|
async function commentsMode(args, io) {
|
|
782
697
|
if (!args.mode) {
|
|
783
|
-
io.err(
|
|
698
|
+
io.err(`Usage: flypod comments mode <anonymous|passcode|approved> [--site <id>] [--passcode <s>]
|
|
699
|
+
` + " --site defaults to the site linked to this folder.");
|
|
784
700
|
return 2;
|
|
785
701
|
}
|
|
786
702
|
const allowed = new Set(["anonymous", "passcode", "approved", "open", "review", "members"]);
|
|
@@ -793,20 +709,15 @@ async function commentsMode(args, io) {
|
|
|
793
709
|
return 2;
|
|
794
710
|
}
|
|
795
711
|
const env = io.env ?? process.env;
|
|
796
|
-
const
|
|
797
|
-
if (!token) {
|
|
712
|
+
const client = await createClient({ env, fetch: io.fetch });
|
|
713
|
+
if (!client.token) {
|
|
798
714
|
io.err("Not signed in. Run `flypod login` or set FLYPOD_TOKEN.");
|
|
799
715
|
return 3;
|
|
800
716
|
}
|
|
801
|
-
const fetchImpl = io.fetch ?? fetch;
|
|
802
717
|
const body = { enabled: true, mode: args.mode };
|
|
803
718
|
if (args.passcode)
|
|
804
719
|
body.passcode = args.passcode;
|
|
805
|
-
const res = await
|
|
806
|
-
method: "PUT",
|
|
807
|
-
headers: jsonHeaders(token),
|
|
808
|
-
body: JSON.stringify(body)
|
|
809
|
-
});
|
|
720
|
+
const res = await client.setCommentsMode(args.site, body);
|
|
810
721
|
if (!res.ok) {
|
|
811
722
|
io.err(`flypod comments mode: ${await readErrorBody(res)}`);
|
|
812
723
|
return res.status >= 500 ? 4 : 1;
|
|
@@ -823,17 +734,12 @@ async function commentsOff(args, io) {
|
|
|
823
734
|
return 2;
|
|
824
735
|
}
|
|
825
736
|
const env = io.env ?? process.env;
|
|
826
|
-
const
|
|
827
|
-
if (!token) {
|
|
737
|
+
const client = await createClient({ env, fetch: io.fetch });
|
|
738
|
+
if (!client.token) {
|
|
828
739
|
io.err("Not signed in. Run `flypod login` or set FLYPOD_TOKEN.");
|
|
829
740
|
return 3;
|
|
830
741
|
}
|
|
831
|
-
const
|
|
832
|
-
const res = await fetchImpl(`${baseUrl}/api/comments/${args.site}/config`, {
|
|
833
|
-
method: "PUT",
|
|
834
|
-
headers: jsonHeaders(token),
|
|
835
|
-
body: JSON.stringify({ enabled: false })
|
|
836
|
-
});
|
|
742
|
+
const res = await client.setCommentsMode(args.site, { enabled: false });
|
|
837
743
|
if (!res.ok) {
|
|
838
744
|
io.err(`flypod comments off: ${await readErrorBody(res)}`);
|
|
839
745
|
return res.status >= 500 ? 4 : 1;
|
|
@@ -850,18 +756,12 @@ async function commentsList(args, io) {
|
|
|
850
756
|
return 2;
|
|
851
757
|
}
|
|
852
758
|
const env = io.env ?? process.env;
|
|
853
|
-
const
|
|
854
|
-
const
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
params.set("status", args.status);
|
|
860
|
-
if (args.limit)
|
|
861
|
-
params.set("limit", String(args.limit));
|
|
862
|
-
const qs = params.toString();
|
|
863
|
-
const url = `${baseUrl}/api/comments/${args.site}${qs ? `?${qs}` : ""}`;
|
|
864
|
-
const res = await fetchImpl(url, { headers: authHeaders2(token) });
|
|
759
|
+
const client = await createClient({ env, fetch: io.fetch });
|
|
760
|
+
const res = await client.listComments(args.site, {
|
|
761
|
+
page: args.page,
|
|
762
|
+
status: args.status,
|
|
763
|
+
limit: args.limit !== undefined ? String(args.limit) : undefined
|
|
764
|
+
});
|
|
865
765
|
if (!res.ok) {
|
|
866
766
|
io.err(`flypod comments list: ${await readErrorBody(res)}`);
|
|
867
767
|
return res.status >= 500 ? 4 : 1;
|
|
@@ -884,11 +784,8 @@ async function commentsShow(args, io) {
|
|
|
884
784
|
return 2;
|
|
885
785
|
}
|
|
886
786
|
const env = io.env ?? process.env;
|
|
887
|
-
const
|
|
888
|
-
const
|
|
889
|
-
const res = await fetchImpl(`${baseUrl}/api/comments/${args.site}/threads/${args.thread_id}`, {
|
|
890
|
-
headers: authHeaders2(token)
|
|
891
|
-
});
|
|
787
|
+
const client = await createClient({ env, fetch: io.fetch });
|
|
788
|
+
const res = await client.getThread(args.site, args.thread_id);
|
|
892
789
|
if (!res.ok) {
|
|
893
790
|
io.err(`flypod comments show: ${await readErrorBody(res)}`);
|
|
894
791
|
return res.status >= 500 ? 4 : 1;
|
|
@@ -903,8 +800,8 @@ async function commentsPost(args, io) {
|
|
|
903
800
|
return 2;
|
|
904
801
|
}
|
|
905
802
|
const env = io.env ?? process.env;
|
|
906
|
-
const
|
|
907
|
-
const reject =
|
|
803
|
+
const client = await createClient({ env, fetch: io.fetch });
|
|
804
|
+
const reject = requireCommentWriteToken(client.token, io);
|
|
908
805
|
if (reject !== null)
|
|
909
806
|
return reject;
|
|
910
807
|
let target;
|
|
@@ -914,11 +811,10 @@ async function commentsPost(args, io) {
|
|
|
914
811
|
io.err("Invalid --target JSON.");
|
|
915
812
|
return 2;
|
|
916
813
|
}
|
|
917
|
-
const
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
body: JSON.stringify({ page_path: args.page, anchor: target, body: args.body })
|
|
814
|
+
const res = await client.postComment(args.site, {
|
|
815
|
+
page_path: args.page,
|
|
816
|
+
anchor: target,
|
|
817
|
+
body: args.body
|
|
922
818
|
});
|
|
923
819
|
if (!res.ok) {
|
|
924
820
|
io.err(`flypod comments post: ${await readErrorBody(res)}`);
|
|
@@ -930,16 +826,16 @@ async function commentsPost(args, io) {
|
|
|
930
826
|
}
|
|
931
827
|
async function setThreadStatus(endpoint, args, io) {
|
|
932
828
|
if (!args.site || !args.thread_id) {
|
|
933
|
-
io.err(`Usage: flypod comments ${endpoint} <site> <thread_id
|
|
829
|
+
io.err(`Usage: flypod comments ${endpoint} [<site>] <thread_id>
|
|
830
|
+
` + " The site defaults to the one linked to this folder.");
|
|
934
831
|
return 2;
|
|
935
832
|
}
|
|
936
833
|
const env = io.env ?? process.env;
|
|
937
|
-
const
|
|
938
|
-
const reject =
|
|
834
|
+
const client = await createClient({ env, fetch: io.fetch });
|
|
835
|
+
const reject = requireCommentWriteToken(client.token, io);
|
|
939
836
|
if (reject !== null)
|
|
940
837
|
return reject;
|
|
941
|
-
const
|
|
942
|
-
const res = await fetchImpl(`${baseUrl}/api/comments/${args.site}/threads/${args.thread_id}/${endpoint}`, { method: "POST", headers: jsonHeaders(token) });
|
|
838
|
+
const res = await client.setThreadStatus(args.site, args.thread_id, endpoint);
|
|
943
839
|
if (!res.ok) {
|
|
944
840
|
io.err(`flypod comments ${endpoint}: ${await readErrorBody(res)}`);
|
|
945
841
|
return res.status >= 500 ? 4 : res.status === 401 || res.status === 403 ? 3 : 1;
|
|
@@ -957,189 +853,113 @@ function commentsResolve(args, io) {
|
|
|
957
853
|
function commentsReopen(args, io) {
|
|
958
854
|
return setThreadStatus("reopen", args, io);
|
|
959
855
|
}
|
|
960
|
-
async function commentsWebhookSet(args, io) {
|
|
961
|
-
if (!args.site || !args.url || !args.secret) {
|
|
962
|
-
io.err("Usage: flypod comments webhook set <site> --url <https://...> --secret <s>");
|
|
963
|
-
return 2;
|
|
964
|
-
}
|
|
965
|
-
const env = io.env ?? process.env;
|
|
966
|
-
const { token, baseUrl } = await resolveCommentToken(env);
|
|
967
|
-
if (!token) {
|
|
968
|
-
io.err("Not signed in. Run `flypod login` or set FLYPOD_TOKEN.");
|
|
969
|
-
return 3;
|
|
970
|
-
}
|
|
971
|
-
const fetchImpl = io.fetch ?? fetch;
|
|
972
|
-
const res = await fetchImpl(`${baseUrl}/api/comments/${args.site}/config`, {
|
|
973
|
-
method: "PUT",
|
|
974
|
-
headers: jsonHeaders(token),
|
|
975
|
-
body: JSON.stringify({ webhook_url: args.url, webhook_secret: args.secret })
|
|
976
|
-
});
|
|
977
|
-
if (!res.ok) {
|
|
978
|
-
io.err(`flypod comments webhook set: ${await readErrorBody(res)}`);
|
|
979
|
-
return res.status >= 500 ? 4 : 1;
|
|
980
|
-
}
|
|
981
|
-
if (args.json)
|
|
982
|
-
io.out(JSON.stringify({ ok: true, site_id: args.site, webhook_url: args.url }));
|
|
983
|
-
else
|
|
984
|
-
io.err(`Webhook set for ${args.site}.`);
|
|
985
|
-
return 0;
|
|
986
|
-
}
|
|
987
|
-
async function commentsWebhookRemove(args, io) {
|
|
988
|
-
if (!args.site) {
|
|
989
|
-
io.err("Usage: flypod comments webhook remove <site>");
|
|
990
|
-
return 2;
|
|
991
|
-
}
|
|
992
|
-
const env = io.env ?? process.env;
|
|
993
|
-
const { token, baseUrl } = await resolveCommentToken(env);
|
|
994
|
-
if (!token) {
|
|
995
|
-
io.err("Not signed in. Run `flypod login` or set FLYPOD_TOKEN.");
|
|
996
|
-
return 3;
|
|
997
|
-
}
|
|
998
|
-
const fetchImpl = io.fetch ?? fetch;
|
|
999
|
-
const res = await fetchImpl(`${baseUrl}/api/comments/${args.site}/config`, {
|
|
1000
|
-
method: "PUT",
|
|
1001
|
-
headers: jsonHeaders(token),
|
|
1002
|
-
body: JSON.stringify({ webhook_url: null, webhook_secret: null })
|
|
1003
|
-
});
|
|
1004
|
-
if (!res.ok) {
|
|
1005
|
-
io.err(`flypod comments webhook remove: ${await readErrorBody(res)}`);
|
|
1006
|
-
return res.status >= 500 ? 4 : 1;
|
|
1007
|
-
}
|
|
1008
|
-
if (args.json)
|
|
1009
|
-
io.out(JSON.stringify({ ok: true, site_id: args.site, webhook_url: null }));
|
|
1010
|
-
else
|
|
1011
|
-
io.err(`Webhook removed for ${args.site}.`);
|
|
1012
|
-
return 0;
|
|
1013
|
-
}
|
|
1014
856
|
async function commentsEnable(args, io) {
|
|
1015
857
|
if (!args.site) {
|
|
1016
|
-
io.err(
|
|
858
|
+
io.err(`Usage: flypod comments enable [--site <id>] [--mode anonymous|passcode|approved] [--passcode <s>]
|
|
859
|
+
` + " --site defaults to the site linked to this folder.");
|
|
1017
860
|
return 2;
|
|
1018
861
|
}
|
|
1019
862
|
return commentsMode({ mode: args.mode ?? "anonymous", site: args.site, passcode: args.passcode, json: args.json }, io);
|
|
1020
863
|
}
|
|
864
|
+
var COMMENTS_FLAG_SPEC = {
|
|
865
|
+
"--site": "value",
|
|
866
|
+
"--mode": "value",
|
|
867
|
+
"--page": "value",
|
|
868
|
+
"--target": "value",
|
|
869
|
+
"--body": "value",
|
|
870
|
+
"--url": "value",
|
|
871
|
+
"--secret": "value",
|
|
872
|
+
"--passcode": "value",
|
|
873
|
+
"--limit": "value",
|
|
874
|
+
"--open": "bool",
|
|
875
|
+
"--resolved": "bool",
|
|
876
|
+
"--all": "bool",
|
|
877
|
+
"--json": "bool"
|
|
878
|
+
};
|
|
879
|
+
function parseCommentFlags(tail) {
|
|
880
|
+
const { flags, positionals } = parseFlags(tail, COMMENTS_FLAG_SPEC);
|
|
881
|
+
const limitRaw = flags["--limit"];
|
|
882
|
+
const status = flags["--all"] ? "all" : flags["--resolved"] ? "resolved" : flags["--open"] ? "open" : undefined;
|
|
883
|
+
return {
|
|
884
|
+
positionals,
|
|
885
|
+
site: flags["--site"],
|
|
886
|
+
mode: flags["--mode"],
|
|
887
|
+
page: flags["--page"],
|
|
888
|
+
target: flags["--target"],
|
|
889
|
+
body: flags["--body"],
|
|
890
|
+
url: flags["--url"],
|
|
891
|
+
secret: flags["--secret"],
|
|
892
|
+
passcode: flags["--passcode"],
|
|
893
|
+
limit: limitRaw ? Number(limitRaw) : undefined,
|
|
894
|
+
status,
|
|
895
|
+
json: Boolean(flags["--json"])
|
|
896
|
+
};
|
|
897
|
+
}
|
|
1021
898
|
async function commentsCommand(argv, io) {
|
|
1022
899
|
if (argv.length === 0 || argv[0] === "-h" || argv[0] === "--help") {
|
|
1023
|
-
io.err("Usage: flypod comments <enable|mode|off|list|show|post|resolve|reopen
|
|
900
|
+
io.err("Usage: flypod comments <enable|mode|off|list|show|post|resolve|reopen> [args]");
|
|
1024
901
|
return argv[0] === "-h" || argv[0] === "--help" ? 0 : 2;
|
|
1025
902
|
}
|
|
1026
903
|
const verb = argv[0];
|
|
1027
904
|
const rest = argv.slice(1);
|
|
1028
|
-
function parseFlags(tail) {
|
|
1029
|
-
const out = { positionals: [], json: false };
|
|
1030
|
-
for (let i = 0;i < tail.length; i++) {
|
|
1031
|
-
const a = tail[i];
|
|
1032
|
-
const eat = () => tail[++i];
|
|
1033
|
-
if (a === "--site")
|
|
1034
|
-
out.site = eat();
|
|
1035
|
-
else if (a.startsWith("--site="))
|
|
1036
|
-
out.site = a.slice("--site=".length);
|
|
1037
|
-
else if (a === "--mode")
|
|
1038
|
-
out.mode = eat();
|
|
1039
|
-
else if (a.startsWith("--mode="))
|
|
1040
|
-
out.mode = a.slice("--mode=".length);
|
|
1041
|
-
else if (a === "--page")
|
|
1042
|
-
out.page = eat();
|
|
1043
|
-
else if (a.startsWith("--page="))
|
|
1044
|
-
out.page = a.slice("--page=".length);
|
|
1045
|
-
else if (a === "--target")
|
|
1046
|
-
out.target = eat();
|
|
1047
|
-
else if (a.startsWith("--target="))
|
|
1048
|
-
out.target = a.slice("--target=".length);
|
|
1049
|
-
else if (a === "--body")
|
|
1050
|
-
out.body = eat();
|
|
1051
|
-
else if (a.startsWith("--body="))
|
|
1052
|
-
out.body = a.slice("--body=".length);
|
|
1053
|
-
else if (a === "--url")
|
|
1054
|
-
out.url = eat();
|
|
1055
|
-
else if (a.startsWith("--url="))
|
|
1056
|
-
out.url = a.slice("--url=".length);
|
|
1057
|
-
else if (a === "--secret")
|
|
1058
|
-
out.secret = eat();
|
|
1059
|
-
else if (a.startsWith("--secret="))
|
|
1060
|
-
out.secret = a.slice("--secret=".length);
|
|
1061
|
-
else if (a === "--passcode")
|
|
1062
|
-
out.passcode = eat();
|
|
1063
|
-
else if (a.startsWith("--passcode="))
|
|
1064
|
-
out.passcode = a.slice("--passcode=".length);
|
|
1065
|
-
else if (a === "--limit") {
|
|
1066
|
-
const v = eat();
|
|
1067
|
-
if (v)
|
|
1068
|
-
out.limit = Number(v);
|
|
1069
|
-
} else if (a.startsWith("--limit=")) {
|
|
1070
|
-
out.limit = Number(a.slice("--limit=".length));
|
|
1071
|
-
} else if (a === "--open")
|
|
1072
|
-
out.status = "open";
|
|
1073
|
-
else if (a === "--resolved")
|
|
1074
|
-
out.status = "resolved";
|
|
1075
|
-
else if (a === "--all")
|
|
1076
|
-
out.status = "all";
|
|
1077
|
-
else if (a === "--json")
|
|
1078
|
-
out.json = true;
|
|
1079
|
-
else if (!a.startsWith("-"))
|
|
1080
|
-
out.positionals.push(a);
|
|
1081
|
-
}
|
|
1082
|
-
return out;
|
|
1083
|
-
}
|
|
1084
905
|
switch (verb) {
|
|
1085
906
|
case "enable": {
|
|
1086
|
-
const f =
|
|
1087
|
-
const site = f.site ?? f.positionals[0];
|
|
907
|
+
const f = parseCommentFlags(rest);
|
|
908
|
+
const site = await resolveCommentsSite(f.site ?? f.positionals[0], io);
|
|
909
|
+
if (!site)
|
|
910
|
+
return failNoSite(f.json, io);
|
|
1088
911
|
return commentsEnable({ site, mode: f.mode, passcode: f.passcode, json: f.json }, io);
|
|
1089
912
|
}
|
|
1090
913
|
case "mode": {
|
|
1091
|
-
const f =
|
|
914
|
+
const f = parseCommentFlags(rest);
|
|
1092
915
|
const mode = f.positionals[0];
|
|
1093
|
-
const site = f.site ?? f.positionals[1];
|
|
916
|
+
const site = await resolveCommentsSite(f.site ?? f.positionals[1], io);
|
|
917
|
+
if (!site)
|
|
918
|
+
return failNoSite(f.json, io);
|
|
1094
919
|
return commentsMode({ mode, site, passcode: f.passcode, json: f.json }, io);
|
|
1095
920
|
}
|
|
1096
921
|
case "off": {
|
|
1097
|
-
const f =
|
|
1098
|
-
const site = f.site ?? f.positionals[0];
|
|
922
|
+
const f = parseCommentFlags(rest);
|
|
923
|
+
const site = await resolveCommentsSite(f.site ?? f.positionals[0], io);
|
|
924
|
+
if (!site)
|
|
925
|
+
return failNoSite(f.json, io);
|
|
1099
926
|
return commentsOff({ site, json: f.json }, io);
|
|
1100
927
|
}
|
|
1101
928
|
case "list": {
|
|
1102
|
-
const f =
|
|
1103
|
-
const site = f.positionals[0] ?? f.site;
|
|
929
|
+
const f = parseCommentFlags(rest);
|
|
930
|
+
const site = await resolveCommentsSite(f.positionals[0] ?? f.site, io);
|
|
931
|
+
if (!site)
|
|
932
|
+
return failNoSite(f.json, io);
|
|
1104
933
|
return commentsList({ site, page: f.page, status: f.status, limit: f.limit, json: f.json }, io);
|
|
1105
934
|
}
|
|
1106
935
|
case "show": {
|
|
1107
|
-
const f =
|
|
1108
|
-
const site = f
|
|
1109
|
-
|
|
936
|
+
const f = parseCommentFlags(rest);
|
|
937
|
+
const { site, thread_id } = await resolveSiteAndThread(f, io);
|
|
938
|
+
if (!site)
|
|
939
|
+
return failNoSite(f.json, io);
|
|
1110
940
|
return commentsShow({ site, thread_id, json: f.json }, io);
|
|
1111
941
|
}
|
|
1112
942
|
case "post": {
|
|
1113
|
-
const f =
|
|
1114
|
-
const site = f.positionals[0] ?? f.site;
|
|
943
|
+
const f = parseCommentFlags(rest);
|
|
944
|
+
const site = await resolveCommentsSite(f.positionals[0] ?? f.site, io);
|
|
945
|
+
if (!site)
|
|
946
|
+
return failNoSite(f.json, io);
|
|
1115
947
|
return commentsPost({ site, page: f.page, target: f.target, body: f.body, json: f.json }, io);
|
|
1116
948
|
}
|
|
1117
949
|
case "resolve": {
|
|
1118
|
-
const f =
|
|
1119
|
-
const site = f
|
|
1120
|
-
|
|
950
|
+
const f = parseCommentFlags(rest);
|
|
951
|
+
const { site, thread_id } = await resolveSiteAndThread(f, io);
|
|
952
|
+
if (!site)
|
|
953
|
+
return failNoSite(f.json, io);
|
|
1121
954
|
return commentsResolve({ site, thread_id, json: f.json }, io);
|
|
1122
955
|
}
|
|
1123
956
|
case "reopen": {
|
|
1124
|
-
const f =
|
|
1125
|
-
const site = f
|
|
1126
|
-
|
|
957
|
+
const f = parseCommentFlags(rest);
|
|
958
|
+
const { site, thread_id } = await resolveSiteAndThread(f, io);
|
|
959
|
+
if (!site)
|
|
960
|
+
return failNoSite(f.json, io);
|
|
1127
961
|
return commentsReopen({ site, thread_id, json: f.json }, io);
|
|
1128
962
|
}
|
|
1129
|
-
case "webhook": {
|
|
1130
|
-
const sub = rest[0];
|
|
1131
|
-
const tail = rest.slice(1);
|
|
1132
|
-
const f = parseFlags(tail);
|
|
1133
|
-
const site = f.positionals[0] ?? f.site;
|
|
1134
|
-
if (sub === "set") {
|
|
1135
|
-
return commentsWebhookSet({ site, url: f.url, secret: f.secret, json: f.json }, io);
|
|
1136
|
-
}
|
|
1137
|
-
if (sub === "remove") {
|
|
1138
|
-
return commentsWebhookRemove({ site, json: f.json }, io);
|
|
1139
|
-
}
|
|
1140
|
-
io.err("Usage: flypod comments webhook <set|remove> <site> [flags]");
|
|
1141
|
-
return 2;
|
|
1142
|
-
}
|
|
1143
963
|
default:
|
|
1144
964
|
io.err(`flypod comments: unknown verb "${verb}"`);
|
|
1145
965
|
return 2;
|
|
@@ -1243,360 +1063,6 @@ function multiselect(opts) {
|
|
|
1243
1063
|
});
|
|
1244
1064
|
}
|
|
1245
1065
|
|
|
1246
|
-
// src/cli/skill.ts
|
|
1247
|
-
import { mkdir as mkdir2, readFile as readFile3, stat, writeFile as writeFile2 } from "node:fs/promises";
|
|
1248
|
-
import { homedir as homedir2 } from "node:os";
|
|
1249
|
-
import { dirname as dirname2, join as join2 } from "node:path";
|
|
1250
|
-
var SKILL_NAME = "flypod";
|
|
1251
|
-
var SKILL_DESCRIPTION = "Deploy any folder of static files to a live public URL with flypod (flypod.dev) — no account, config, or build pipeline needed. " + "Use when the user wants to deploy, publish, ship, share, or host a static site, build output, preview, or demo, or asks to put a finished build online or get a URL for it.";
|
|
1252
|
-
var MARK_BEGIN = `<!-- ${SKILL_NAME}:begin -->`;
|
|
1253
|
-
var MARK_END = `<!-- ${SKILL_NAME}:end -->`;
|
|
1254
|
-
function renderBody(sub) {
|
|
1255
|
-
return `flypod turns any folder of static files into a live, public URL with a single
|
|
1256
|
-
command. No account, no config, no build step of its own — you bring the built
|
|
1257
|
-
files, flypod hosts them. Reach for it the moment a build exists and the user
|
|
1258
|
-
wants it online: a site, a preview, a demo, a one-off share.
|
|
1259
|
-
|
|
1260
|
-
${sub} The happy path
|
|
1261
|
-
|
|
1262
|
-
1. Make sure the site is built — there is a folder of static files to ship
|
|
1263
|
-
(e.g. \`dist/\`, \`build/\`, \`out/\`). flypod ships files; it does not build them.
|
|
1264
|
-
2. Deploy that folder. Prefer \`--json\` so you can read the result:
|
|
1265
|
-
|
|
1266
|
-
\`\`\`sh
|
|
1267
|
-
npx flypod ./dist --json
|
|
1268
|
-
\`\`\`
|
|
1269
|
-
|
|
1270
|
-
If flypod is installed globally, drop the \`npx\`: \`flypod ./dist --json\`.
|
|
1271
|
-
3. Read the \`url\` field from the JSON and give it to the user. That is the live
|
|
1272
|
-
site. That's the whole loop.
|
|
1273
|
-
|
|
1274
|
-
If you omit the path, flypod auto-detects a build folder, trying \`dist\`,
|
|
1275
|
-
\`build\`, \`out\`, \`.output/public\`, \`.vercel/output/static\`, \`public\`, \`_site\`
|
|
1276
|
-
(each must contain an \`index.html\`). When in doubt, pass the path explicitly.
|
|
1277
|
-
|
|
1278
|
-
${sub} Is flypod installed?
|
|
1279
|
-
|
|
1280
|
-
Run \`flypod --version\`. If it is missing, **do not install anything** — just
|
|
1281
|
-
prefix commands with \`npx\`: \`npx flypod ...\` downloads and runs it on the fly.
|
|
1282
|
-
To install once: \`npm install -g flypod\`.
|
|
1283
|
-
|
|
1284
|
-
${sub} Reading the result
|
|
1285
|
-
|
|
1286
|
-
\`npx flypod ./dist --json\` prints a JSON object on stdout:
|
|
1287
|
-
|
|
1288
|
-
\`\`\`json
|
|
1289
|
-
{
|
|
1290
|
-
"ok": true,
|
|
1291
|
-
"url": "https://ab12cd34.flypod.dev",
|
|
1292
|
-
"site_id": "ab12cd34",
|
|
1293
|
-
"manage_token": "…",
|
|
1294
|
-
"claim_token": "…",
|
|
1295
|
-
"expires_at": 1782929906088,
|
|
1296
|
-
"files": 12,
|
|
1297
|
-
"bytes": 1234567,
|
|
1298
|
-
"elapsed_ms": 812
|
|
1299
|
-
}
|
|
1300
|
-
\`\`\`
|
|
1301
|
-
|
|
1302
|
-
- \`url\` — the live site. Always surface this to the user.
|
|
1303
|
-
- \`manage_token\` — save it; it is needed to redeploy, roll back, or delete the site.
|
|
1304
|
-
- \`claim_token\` — save it; it attaches an anonymous site to an account later.
|
|
1305
|
-
- \`expires_at\` — anonymous deploys are ephemeral (~14 days); \`null\` once owned.
|
|
1306
|
-
|
|
1307
|
-
Treat \`manage_token\` and \`claim_token\` as secrets — don't paste them into chat
|
|
1308
|
-
unless the user asks. Without \`--json\`, use quiet mode to capture the URL in a
|
|
1309
|
-
shell variable: \`URL=$(npx flypod ./dist -q)\` (URL on stdout, token on stderr).
|
|
1310
|
-
|
|
1311
|
-
${sub} Anonymous vs. signed in
|
|
1312
|
-
|
|
1313
|
-
- **Anonymous (default):** zero auth. The first deploy just works and the site
|
|
1314
|
-
expires in ~14 days. Best for previews and throwaways.
|
|
1315
|
-
- **Signed in:** deploys are attributed to an account, never expire, and show up
|
|
1316
|
-
in \`flypod list\`. Sign in once via the browser:
|
|
1317
|
-
|
|
1318
|
-
\`\`\`sh
|
|
1319
|
-
flypod login
|
|
1320
|
-
\`\`\`
|
|
1321
|
-
|
|
1322
|
-
For agents and CI, skip the session file entirely — set a session token in the
|
|
1323
|
-
environment and every deploy is attributed to the account:
|
|
1324
|
-
|
|
1325
|
-
\`\`\`sh
|
|
1326
|
-
FLYPOD_TOKEN=<session-token> npx flypod ./dist --json
|
|
1327
|
-
\`\`\`
|
|
1328
|
-
|
|
1329
|
-
${sub} Other commands
|
|
1330
|
-
|
|
1331
|
-
\`\`\`sh
|
|
1332
|
-
flypod list # sites you own (requires sign in)
|
|
1333
|
-
flypod claim <site_id> <token> # attach an anonymous deploy to your account
|
|
1334
|
-
flypod logout # forget the saved session token
|
|
1335
|
-
flypod --help # full usage
|
|
1336
|
-
\`\`\`
|
|
1337
|
-
|
|
1338
|
-
${sub} Rules of thumb
|
|
1339
|
-
|
|
1340
|
-
- Build first. Point flypod at the **output** folder, never the project root or source.
|
|
1341
|
-
- Prefer \`--json\` and read \`url\`. Use \`-q\`/\`--quiet\` when you only need the URL.
|
|
1342
|
-
- flypod hosts **static files only** (HTML/CSS/JS/assets). It runs no server or backend.
|
|
1343
|
-
- A missing \`flypod\` binary is fine — use \`npx flypod\`; never block on installing it.`;
|
|
1344
|
-
}
|
|
1345
|
-
function standaloneMarkdown() {
|
|
1346
|
-
return `# Deploy with flypod
|
|
1347
|
-
|
|
1348
|
-
${renderBody("##")}
|
|
1349
|
-
`;
|
|
1350
|
-
}
|
|
1351
|
-
function embedSection() {
|
|
1352
|
-
return `${MARK_BEGIN}
|
|
1353
|
-
## Deploying with flypod
|
|
1354
|
-
|
|
1355
|
-
${renderBody("###")}
|
|
1356
|
-
${MARK_END}`;
|
|
1357
|
-
}
|
|
1358
|
-
function claudeSkillFile() {
|
|
1359
|
-
return `---
|
|
1360
|
-
name: ${SKILL_NAME}
|
|
1361
|
-
description: ${SKILL_DESCRIPTION}
|
|
1362
|
-
---
|
|
1363
|
-
|
|
1364
|
-
${standaloneMarkdown()}`;
|
|
1365
|
-
}
|
|
1366
|
-
function cursorRuleFile() {
|
|
1367
|
-
return `---
|
|
1368
|
-
description: ${SKILL_DESCRIPTION}
|
|
1369
|
-
globs:
|
|
1370
|
-
alwaysApply: false
|
|
1371
|
-
---
|
|
1372
|
-
|
|
1373
|
-
${standaloneMarkdown()}`;
|
|
1374
|
-
}
|
|
1375
|
-
async function exists(path) {
|
|
1376
|
-
try {
|
|
1377
|
-
await stat(path);
|
|
1378
|
-
return true;
|
|
1379
|
-
} catch {
|
|
1380
|
-
return false;
|
|
1381
|
-
}
|
|
1382
|
-
}
|
|
1383
|
-
async function anyExists(root, rels) {
|
|
1384
|
-
for (const rel of rels) {
|
|
1385
|
-
if (await exists(join2(root, rel)))
|
|
1386
|
-
return true;
|
|
1387
|
-
}
|
|
1388
|
-
return false;
|
|
1389
|
-
}
|
|
1390
|
-
var TARGETS = [
|
|
1391
|
-
{
|
|
1392
|
-
id: "agents",
|
|
1393
|
-
label: "AGENTS.md",
|
|
1394
|
-
detail: "universal — Codex, Cursor, Copilot, Gemini, Zed, Jules, +more",
|
|
1395
|
-
kind: "embed",
|
|
1396
|
-
alwaysDefault: true,
|
|
1397
|
-
projectPath: (root) => join2(root, "AGENTS.md"),
|
|
1398
|
-
globalPath: () => join2(homedir2(), ".codex", "AGENTS.md"),
|
|
1399
|
-
detect: () => Promise.resolve(true),
|
|
1400
|
-
render: embedSection
|
|
1401
|
-
},
|
|
1402
|
-
{
|
|
1403
|
-
id: "claude",
|
|
1404
|
-
label: "Claude Code",
|
|
1405
|
-
detail: ".claude/skills/flypod/SKILL.md — loaded on demand",
|
|
1406
|
-
kind: "skill",
|
|
1407
|
-
alwaysDefault: true,
|
|
1408
|
-
projectPath: (root) => join2(root, ".claude", "skills", SKILL_NAME, "SKILL.md"),
|
|
1409
|
-
globalPath: () => join2(homedir2(), ".claude", "skills", SKILL_NAME, "SKILL.md"),
|
|
1410
|
-
detect: (root) => anyExists(root, [".claude", "CLAUDE.md"]),
|
|
1411
|
-
render: claudeSkillFile
|
|
1412
|
-
},
|
|
1413
|
-
{
|
|
1414
|
-
id: "cursor",
|
|
1415
|
-
label: "Cursor",
|
|
1416
|
-
detail: ".cursor/rules/flypod.mdc",
|
|
1417
|
-
kind: "rules",
|
|
1418
|
-
alwaysDefault: false,
|
|
1419
|
-
projectPath: (root) => join2(root, ".cursor", "rules", `${SKILL_NAME}.mdc`),
|
|
1420
|
-
globalPath: () => null,
|
|
1421
|
-
detect: (root) => anyExists(root, [".cursor", ".cursorrules"]),
|
|
1422
|
-
render: cursorRuleFile
|
|
1423
|
-
},
|
|
1424
|
-
{
|
|
1425
|
-
id: "copilot",
|
|
1426
|
-
label: "GitHub Copilot",
|
|
1427
|
-
detail: ".github/copilot-instructions.md",
|
|
1428
|
-
kind: "embed",
|
|
1429
|
-
alwaysDefault: false,
|
|
1430
|
-
projectPath: (root) => join2(root, ".github", "copilot-instructions.md"),
|
|
1431
|
-
globalPath: () => null,
|
|
1432
|
-
detect: (root) => anyExists(root, [".github"]),
|
|
1433
|
-
render: embedSection
|
|
1434
|
-
},
|
|
1435
|
-
{
|
|
1436
|
-
id: "windsurf",
|
|
1437
|
-
label: "Windsurf",
|
|
1438
|
-
detail: ".windsurf/rules/flypod.md",
|
|
1439
|
-
kind: "rules",
|
|
1440
|
-
alwaysDefault: false,
|
|
1441
|
-
projectPath: (root) => join2(root, ".windsurf", "rules", `${SKILL_NAME}.md`),
|
|
1442
|
-
globalPath: () => null,
|
|
1443
|
-
detect: (root) => anyExists(root, [".windsurf", ".windsurfrules"]),
|
|
1444
|
-
render: standaloneMarkdown
|
|
1445
|
-
},
|
|
1446
|
-
{
|
|
1447
|
-
id: "cline",
|
|
1448
|
-
label: "Cline",
|
|
1449
|
-
detail: ".clinerules/flypod.md",
|
|
1450
|
-
kind: "rules",
|
|
1451
|
-
alwaysDefault: false,
|
|
1452
|
-
projectPath: (root) => join2(root, ".clinerules", `${SKILL_NAME}.md`),
|
|
1453
|
-
globalPath: () => null,
|
|
1454
|
-
detect: (root) => anyExists(root, [".clinerules"]),
|
|
1455
|
-
render: standaloneMarkdown
|
|
1456
|
-
},
|
|
1457
|
-
{
|
|
1458
|
-
id: "roo",
|
|
1459
|
-
label: "Roo Code",
|
|
1460
|
-
detail: ".roo/rules/flypod.md",
|
|
1461
|
-
kind: "rules",
|
|
1462
|
-
alwaysDefault: false,
|
|
1463
|
-
projectPath: (root) => join2(root, ".roo", "rules", `${SKILL_NAME}.md`),
|
|
1464
|
-
globalPath: () => null,
|
|
1465
|
-
detect: (root) => anyExists(root, [".roo", ".roorules"]),
|
|
1466
|
-
render: standaloneMarkdown
|
|
1467
|
-
},
|
|
1468
|
-
{
|
|
1469
|
-
id: "gemini",
|
|
1470
|
-
label: "Gemini CLI",
|
|
1471
|
-
detail: "GEMINI.md",
|
|
1472
|
-
kind: "embed",
|
|
1473
|
-
alwaysDefault: false,
|
|
1474
|
-
projectPath: (root) => join2(root, "GEMINI.md"),
|
|
1475
|
-
globalPath: () => join2(homedir2(), ".gemini", "GEMINI.md"),
|
|
1476
|
-
detect: (root) => anyExists(root, ["GEMINI.md", ".gemini"]),
|
|
1477
|
-
render: embedSection
|
|
1478
|
-
}
|
|
1479
|
-
];
|
|
1480
|
-
function spliceBlock(existing, section) {
|
|
1481
|
-
const begin = existing.indexOf(MARK_BEGIN);
|
|
1482
|
-
const end = existing.indexOf(MARK_END);
|
|
1483
|
-
if (begin !== -1 && end !== -1 && end > begin) {
|
|
1484
|
-
const before = existing.slice(0, begin);
|
|
1485
|
-
const after = existing.slice(end + MARK_END.length);
|
|
1486
|
-
return `${before}${section}${after}`;
|
|
1487
|
-
}
|
|
1488
|
-
const trimmed = existing.replace(/\s+$/, "");
|
|
1489
|
-
return trimmed ? `${trimmed}
|
|
1490
|
-
|
|
1491
|
-
${section}
|
|
1492
|
-
` : `${section}
|
|
1493
|
-
`;
|
|
1494
|
-
}
|
|
1495
|
-
async function writeTarget(target, path) {
|
|
1496
|
-
const had = await exists(path);
|
|
1497
|
-
const current = had ? await readFile3(path, "utf8") : "";
|
|
1498
|
-
let next;
|
|
1499
|
-
if (target.kind === "embed") {
|
|
1500
|
-
next = spliceBlock(current, target.render());
|
|
1501
|
-
} else {
|
|
1502
|
-
next = target.render();
|
|
1503
|
-
}
|
|
1504
|
-
if (had && current === next)
|
|
1505
|
-
return { target, path, status: "unchanged" };
|
|
1506
|
-
await mkdir2(dirname2(path), { recursive: true });
|
|
1507
|
-
await writeFile2(path, next, "utf8");
|
|
1508
|
-
return { target, path, status: had ? "updated" : "created" };
|
|
1509
|
-
}
|
|
1510
|
-
async function buildPlan(root, env, global) {
|
|
1511
|
-
const entries = [];
|
|
1512
|
-
for (const target of TARGETS) {
|
|
1513
|
-
const path = global ? target.globalPath(env) : target.projectPath(root);
|
|
1514
|
-
if (!path)
|
|
1515
|
-
continue;
|
|
1516
|
-
const detected = await target.detect(root, env);
|
|
1517
|
-
entries.push({
|
|
1518
|
-
target,
|
|
1519
|
-
path,
|
|
1520
|
-
detected,
|
|
1521
|
-
defaultOn: target.alwaysDefault || detected
|
|
1522
|
-
});
|
|
1523
|
-
}
|
|
1524
|
-
return entries;
|
|
1525
|
-
}
|
|
1526
|
-
async function installSkill(args, io) {
|
|
1527
|
-
const env = io.env ?? process.env;
|
|
1528
|
-
const root = args.cwd ?? process.cwd();
|
|
1529
|
-
const global = Boolean(args.global);
|
|
1530
|
-
const plan = await buildPlan(root, env, global);
|
|
1531
|
-
if (args.list) {
|
|
1532
|
-
io.err(global ? "flypod skill targets (global):" : "flypod skill targets (this project):");
|
|
1533
|
-
io.err("");
|
|
1534
|
-
for (const e of plan) {
|
|
1535
|
-
const mark = e.defaultOn ? "●" : "○";
|
|
1536
|
-
const tag = e.target.alwaysDefault ? "default" : e.detected ? "detected" : "available";
|
|
1537
|
-
io.out(`${mark} ${e.target.id} ${tag} ${e.path}`);
|
|
1538
|
-
}
|
|
1539
|
-
io.err("");
|
|
1540
|
-
io.err("● = installed by default. Run `flypod install skill` to write them.");
|
|
1541
|
-
return 0;
|
|
1542
|
-
}
|
|
1543
|
-
let chosen;
|
|
1544
|
-
if (args.all) {
|
|
1545
|
-
chosen = plan.map((e) => e.target.id);
|
|
1546
|
-
} else if (args.targets && args.targets.length > 0) {
|
|
1547
|
-
const known = new Set(plan.map((e) => e.target.id));
|
|
1548
|
-
const unknown = args.targets.filter((id) => !known.has(id));
|
|
1549
|
-
if (unknown.length > 0) {
|
|
1550
|
-
io.err(`flypod: unknown target(s): ${unknown.join(", ")}`);
|
|
1551
|
-
io.err(`Known targets: ${TARGETS.map((t) => t.id).join(", ")}`);
|
|
1552
|
-
return 2;
|
|
1553
|
-
}
|
|
1554
|
-
chosen = args.targets;
|
|
1555
|
-
} else if (args.picker) {
|
|
1556
|
-
const picked = await args.picker(plan);
|
|
1557
|
-
if (picked === null) {
|
|
1558
|
-
io.err("Cancelled. Nothing written.");
|
|
1559
|
-
return 130;
|
|
1560
|
-
}
|
|
1561
|
-
chosen = picked;
|
|
1562
|
-
} else {
|
|
1563
|
-
chosen = plan.filter((e) => e.defaultOn).map((e) => e.target.id);
|
|
1564
|
-
}
|
|
1565
|
-
const selected = plan.filter((e) => chosen.includes(e.target.id));
|
|
1566
|
-
if (selected.length === 0) {
|
|
1567
|
-
io.err("No targets selected. Nothing written.");
|
|
1568
|
-
return 0;
|
|
1569
|
-
}
|
|
1570
|
-
if (args.dryRun) {
|
|
1571
|
-
io.err("Would write:");
|
|
1572
|
-
for (const e of selected)
|
|
1573
|
-
io.out(e.path);
|
|
1574
|
-
return 0;
|
|
1575
|
-
}
|
|
1576
|
-
const results = [];
|
|
1577
|
-
for (const e of selected) {
|
|
1578
|
-
try {
|
|
1579
|
-
results.push(await writeTarget(e.target, e.path));
|
|
1580
|
-
} catch (error) {
|
|
1581
|
-
io.err(`flypod: failed to write ${e.path}: ${error.message}`);
|
|
1582
|
-
return 1;
|
|
1583
|
-
}
|
|
1584
|
-
}
|
|
1585
|
-
const verb = {
|
|
1586
|
-
created: "created",
|
|
1587
|
-
updated: "updated",
|
|
1588
|
-
unchanged: "up to date"
|
|
1589
|
-
};
|
|
1590
|
-
for (const r of results) {
|
|
1591
|
-
io.err(` ${r.status === "unchanged" ? "·" : "✓"} ${verb[r.status]} ${r.path}`);
|
|
1592
|
-
io.out(r.path);
|
|
1593
|
-
}
|
|
1594
|
-
const changed = results.filter((r) => r.status !== "unchanged").length;
|
|
1595
|
-
io.err("");
|
|
1596
|
-
io.err(changed > 0 ? `Your agents now know how to deploy with flypod. Try asking one to "deploy this with flypod".` : "Everything was already up to date.");
|
|
1597
|
-
return 0;
|
|
1598
|
-
}
|
|
1599
|
-
|
|
1600
1066
|
// src/ui.ts
|
|
1601
1067
|
var ESC2 = "\x1B[";
|
|
1602
1068
|
function envBool(name) {
|
|
@@ -1707,6 +1173,7 @@ var SUBCOMMANDS = new Set([
|
|
|
1707
1173
|
"versions",
|
|
1708
1174
|
"rollback",
|
|
1709
1175
|
"forget",
|
|
1176
|
+
"token",
|
|
1710
1177
|
"login",
|
|
1711
1178
|
"logout",
|
|
1712
1179
|
"list",
|
|
@@ -1715,78 +1182,79 @@ var SUBCOMMANDS = new Set([
|
|
|
1715
1182
|
"comments"
|
|
1716
1183
|
]);
|
|
1717
1184
|
var TARGET_FLAGS = {
|
|
1718
|
-
"--agents": "agents",
|
|
1719
|
-
"--agents-md": "agents",
|
|
1720
1185
|
"--claude": "claude",
|
|
1721
|
-
"--
|
|
1722
|
-
"--
|
|
1723
|
-
"--
|
|
1724
|
-
"--
|
|
1725
|
-
"--
|
|
1726
|
-
"--
|
|
1186
|
+
"--agents": "agents",
|
|
1187
|
+
"--cursor": "agents",
|
|
1188
|
+
"--codex": "agents",
|
|
1189
|
+
"--copilot": "agents",
|
|
1190
|
+
"--gemini": "agents",
|
|
1191
|
+
"--windsurf": "agents",
|
|
1192
|
+
"--cline": "agents",
|
|
1193
|
+
"--roo": "agents"
|
|
1194
|
+
};
|
|
1195
|
+
var INSTALL_FLAG_SPEC = {
|
|
1196
|
+
"--all": "bool",
|
|
1197
|
+
"--global": "bool",
|
|
1198
|
+
"--list": "bool",
|
|
1199
|
+
"--dry-run": "bool",
|
|
1200
|
+
"--print": "bool",
|
|
1201
|
+
"--yes": "bool",
|
|
1202
|
+
"-y": "bool",
|
|
1203
|
+
...Object.fromEntries(Object.keys(TARGET_FLAGS).map((f) => [f, "bool"]))
|
|
1204
|
+
};
|
|
1205
|
+
var TOP_LEVEL_FLAG_SPEC = {
|
|
1206
|
+
"--json": "bool",
|
|
1207
|
+
"-q": "bool",
|
|
1208
|
+
"--quiet": "bool",
|
|
1209
|
+
"-h": "bool",
|
|
1210
|
+
"--help": "bool",
|
|
1211
|
+
"-v": "bool",
|
|
1212
|
+
"--version": "bool",
|
|
1213
|
+
"--comments": "bool",
|
|
1214
|
+
"--mode": "value"
|
|
1727
1215
|
};
|
|
1728
1216
|
function parseArgs(argv) {
|
|
1729
|
-
const
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
help: false,
|
|
1733
|
-
version: false,
|
|
1734
|
-
comments: false,
|
|
1735
|
-
commentsMode: "anonymous"
|
|
1736
|
-
};
|
|
1737
|
-
for (let i = 0;i < argv.length; i++) {
|
|
1738
|
-
const a = argv[i];
|
|
1739
|
-
if (a === "--json")
|
|
1740
|
-
out.json = true;
|
|
1741
|
-
else if (a === "-q" || a === "--quiet")
|
|
1742
|
-
out.quiet = true;
|
|
1743
|
-
else if (a === "-h" || a === "--help")
|
|
1744
|
-
out.help = true;
|
|
1745
|
-
else if (a === "-v" || a === "--version")
|
|
1746
|
-
out.version = true;
|
|
1747
|
-
else if (a === "--comments")
|
|
1748
|
-
out.comments = true;
|
|
1749
|
-
else if (a === "--mode" && i + 1 < argv.length)
|
|
1750
|
-
out.commentsMode = argv[++i];
|
|
1751
|
-
else if (a.startsWith("--mode="))
|
|
1752
|
-
out.commentsMode = a.slice("--mode=".length);
|
|
1753
|
-
else if (a.startsWith("-")) {
|
|
1754
|
-
process.stderr.write(`flypod: unknown flag "${a}"
|
|
1217
|
+
const { flags, positionals, unknown } = parseFlags(argv, TOP_LEVEL_FLAG_SPEC);
|
|
1218
|
+
if (unknown.length > 0) {
|
|
1219
|
+
process.stderr.write(`flypod: unknown flag "${unknown[0]}"
|
|
1755
1220
|
Run \`flypod --help\` for usage.
|
|
1756
1221
|
`);
|
|
1757
|
-
|
|
1758
|
-
} else if (!out.path)
|
|
1759
|
-
out.path = a;
|
|
1222
|
+
process.exit(2);
|
|
1760
1223
|
}
|
|
1761
|
-
return
|
|
1224
|
+
return {
|
|
1225
|
+
path: positionals[0],
|
|
1226
|
+
json: Boolean(flags["--json"]),
|
|
1227
|
+
quiet: Boolean(flags["-q"] || flags["--quiet"]),
|
|
1228
|
+
help: Boolean(flags["-h"] || flags["--help"]),
|
|
1229
|
+
version: Boolean(flags["-v"] || flags["--version"]),
|
|
1230
|
+
comments: Boolean(flags["--comments"]),
|
|
1231
|
+
commentsMode: flags["--mode"] ?? "anonymous"
|
|
1232
|
+
};
|
|
1762
1233
|
}
|
|
1234
|
+
var SUB_FLAG_SPEC = {
|
|
1235
|
+
"--site": "value",
|
|
1236
|
+
"--token": "value",
|
|
1237
|
+
"--json": "bool",
|
|
1238
|
+
"-q": "bool",
|
|
1239
|
+
"--quiet": "bool",
|
|
1240
|
+
"-h": "bool",
|
|
1241
|
+
"--help": "bool"
|
|
1242
|
+
};
|
|
1243
|
+
var LOGIN_FLAG_SPEC = {
|
|
1244
|
+
"--token": "value",
|
|
1245
|
+
"-h": "bool",
|
|
1246
|
+
"--help": "bool"
|
|
1247
|
+
};
|
|
1763
1248
|
function parseSub(argv) {
|
|
1764
|
-
const positionals =
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
site = argv[++i];
|
|
1774
|
-
else if (a.startsWith("--site="))
|
|
1775
|
-
site = a.slice("--site=".length);
|
|
1776
|
-
else if (a === "--token" && i + 1 < argv.length)
|
|
1777
|
-
token = argv[++i];
|
|
1778
|
-
else if (a.startsWith("--token="))
|
|
1779
|
-
token = a.slice("--token=".length);
|
|
1780
|
-
else if (a === "--json")
|
|
1781
|
-
json = true;
|
|
1782
|
-
else if (a === "-q" || a === "--quiet")
|
|
1783
|
-
quiet = true;
|
|
1784
|
-
else if (a === "-h" || a === "--help")
|
|
1785
|
-
help = true;
|
|
1786
|
-
else if (!a.startsWith("-"))
|
|
1787
|
-
positionals.push(a);
|
|
1788
|
-
}
|
|
1789
|
-
return { positionals, site, token, json, quiet, help };
|
|
1249
|
+
const { flags, positionals } = parseFlags(argv, SUB_FLAG_SPEC);
|
|
1250
|
+
return {
|
|
1251
|
+
positionals,
|
|
1252
|
+
site: flags["--site"],
|
|
1253
|
+
token: flags["--token"],
|
|
1254
|
+
json: Boolean(flags["--json"]),
|
|
1255
|
+
quiet: Boolean(flags["-q"] || flags["--quiet"]),
|
|
1256
|
+
help: Boolean(flags["-h"] || flags["--help"])
|
|
1257
|
+
};
|
|
1790
1258
|
}
|
|
1791
1259
|
async function runSubcommand(name, argv) {
|
|
1792
1260
|
const io = {
|
|
@@ -1797,43 +1265,39 @@ async function runSubcommand(name, argv) {
|
|
|
1797
1265
|
};
|
|
1798
1266
|
switch (name) {
|
|
1799
1267
|
case "update": {
|
|
1800
|
-
const { positionals, site, token, json, quiet, help } = parseSub(argv);
|
|
1801
|
-
return update({ path: positionals[0], site, token, json, quiet, help }, io);
|
|
1268
|
+
const { positionals, site, token: token2, json, quiet, help } = parseSub(argv);
|
|
1269
|
+
return update({ path: positionals[0], site, token: token2, json, quiet, help }, io);
|
|
1802
1270
|
}
|
|
1803
1271
|
case "versions": {
|
|
1804
|
-
const { site, token, json, help } = parseSub(argv);
|
|
1805
|
-
return versions({ site, token, json, help }, io);
|
|
1272
|
+
const { site, token: token2, json, help } = parseSub(argv);
|
|
1273
|
+
return versions({ site, token: token2, json, help }, io);
|
|
1806
1274
|
}
|
|
1807
1275
|
case "rollback": {
|
|
1808
|
-
const { positionals, site, token, json, help } = parseSub(argv);
|
|
1809
|
-
return rollback({ version: positionals[0], site, token, json, help }, io);
|
|
1276
|
+
const { positionals, site, token: token2, json, help } = parseSub(argv);
|
|
1277
|
+
return rollback({ version: positionals[0], site, token: token2, json, help }, io);
|
|
1810
1278
|
}
|
|
1811
1279
|
case "forget": {
|
|
1812
1280
|
const { site, help } = parseSub(argv);
|
|
1813
1281
|
return forget({ site, help }, io);
|
|
1814
1282
|
}
|
|
1283
|
+
case "token": {
|
|
1284
|
+
const { site, help } = parseSub(argv);
|
|
1285
|
+
return token({ site, help }, io);
|
|
1286
|
+
}
|
|
1815
1287
|
case "login": {
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
i++;
|
|
1822
|
-
} else if (argv[i]?.startsWith("--token=")) {
|
|
1823
|
-
token = argv[i]?.slice("--token=".length);
|
|
1824
|
-
} else if (argv[i] === "-h" || argv[i] === "--help") {
|
|
1825
|
-
help = true;
|
|
1826
|
-
}
|
|
1827
|
-
}
|
|
1828
|
-
return login({ token, help }, io);
|
|
1288
|
+
const { flags } = parseFlags(argv, LOGIN_FLAG_SPEC);
|
|
1289
|
+
return login({
|
|
1290
|
+
token: flags["--token"],
|
|
1291
|
+
help: Boolean(flags["-h"] || flags["--help"])
|
|
1292
|
+
}, io);
|
|
1829
1293
|
}
|
|
1830
1294
|
case "logout":
|
|
1831
1295
|
return logout({}, io);
|
|
1832
1296
|
case "list":
|
|
1833
1297
|
return list({}, io);
|
|
1834
1298
|
case "claim": {
|
|
1835
|
-
const
|
|
1836
|
-
return claim({ site_id:
|
|
1299
|
+
const { positionals } = parseFlags(argv, {});
|
|
1300
|
+
return claim({ site_id: positionals[0], token: positionals[1] }, io);
|
|
1837
1301
|
}
|
|
1838
1302
|
case "install":
|
|
1839
1303
|
return runInstall(argv, io);
|
|
@@ -1845,45 +1309,35 @@ async function runSubcommand(name, argv) {
|
|
|
1845
1309
|
}
|
|
1846
1310
|
}
|
|
1847
1311
|
function shortHome(path) {
|
|
1848
|
-
const home =
|
|
1312
|
+
const home = homedir();
|
|
1849
1313
|
return path.startsWith(home) ? `~${path.slice(home.length)}` : path;
|
|
1850
1314
|
}
|
|
1851
1315
|
async function runInstall(argv, io) {
|
|
1852
1316
|
const noun = argv.find((a) => !a.startsWith("-"));
|
|
1853
1317
|
if (noun !== "skill" && noun !== "skills") {
|
|
1854
|
-
io.err("Usage: flypod install skill [
|
|
1318
|
+
io.err("Usage: flypod install skill [--claude] [--agents] [--global] [--list] [--dry-run]");
|
|
1855
1319
|
io.err("");
|
|
1856
1320
|
io.err("Teaches your coding agents (Claude Code, Codex, Cursor, …) how to deploy");
|
|
1857
|
-
io.err("with flypod by writing
|
|
1321
|
+
io.err("with flypod by writing an Agent Skill into .claude/skills/ and .agents/skills/.");
|
|
1858
1322
|
return 2;
|
|
1859
1323
|
}
|
|
1860
|
-
const
|
|
1861
|
-
|
|
1862
|
-
"--global",
|
|
1863
|
-
"--list",
|
|
1864
|
-
"--dry-run",
|
|
1865
|
-
"--print",
|
|
1866
|
-
"--yes",
|
|
1867
|
-
"-y",
|
|
1868
|
-
...Object.keys(TARGET_FLAGS)
|
|
1869
|
-
]);
|
|
1870
|
-
const unknownFlag = argv.find((a) => a.startsWith("-") && !KNOWN_FLAGS.has(a));
|
|
1324
|
+
const { flags, unknown } = parseFlags(argv, INSTALL_FLAG_SPEC);
|
|
1325
|
+
const unknownFlag = unknown[0];
|
|
1871
1326
|
if (unknownFlag) {
|
|
1872
1327
|
io.err(`flypod: unknown flag "${unknownFlag}"`);
|
|
1873
1328
|
io.err("Run `flypod install skill --list` to see available targets and flags.");
|
|
1874
1329
|
return 2;
|
|
1875
1330
|
}
|
|
1876
|
-
const has = (flag) => argv.includes(flag);
|
|
1877
1331
|
const targets = [];
|
|
1878
1332
|
for (const [flag, id] of Object.entries(TARGET_FLAGS)) {
|
|
1879
|
-
if (
|
|
1333
|
+
if (flags[flag] && !targets.includes(id))
|
|
1880
1334
|
targets.push(id);
|
|
1881
1335
|
}
|
|
1882
|
-
const all =
|
|
1883
|
-
const global =
|
|
1884
|
-
const list2 =
|
|
1885
|
-
const dryRun =
|
|
1886
|
-
const yes =
|
|
1336
|
+
const all = Boolean(flags["--all"]);
|
|
1337
|
+
const global = Boolean(flags["--global"]);
|
|
1338
|
+
const list2 = Boolean(flags["--list"]);
|
|
1339
|
+
const dryRun = Boolean(flags["--dry-run"] || flags["--print"]);
|
|
1340
|
+
const yes = Boolean(flags["--yes"] || flags["-y"]);
|
|
1887
1341
|
const interactive = !list2 && !dryRun && !all && !yes && targets.length === 0 && canPrompt(process.stdin);
|
|
1888
1342
|
const picker = interactive ? async (plan) => {
|
|
1889
1343
|
const style = makeStyle(colorsEnabled(process.stderr));
|
|
@@ -1894,8 +1348,8 @@ async function runInstall(argv, io) {
|
|
|
1894
1348
|
const choices = plan.map((e) => ({
|
|
1895
1349
|
id: e.target.id,
|
|
1896
1350
|
label: e.target.label,
|
|
1897
|
-
hint:
|
|
1898
|
-
checked:
|
|
1351
|
+
hint: e.target.detail,
|
|
1352
|
+
checked: true
|
|
1899
1353
|
}));
|
|
1900
1354
|
return multiselect({ title: "Install the flypod skill into:", choices, style });
|
|
1901
1355
|
} : undefined;
|
|
@@ -1904,14 +1358,14 @@ async function runInstall(argv, io) {
|
|
|
1904
1358
|
err: (line) => io.err(shortHome(line)),
|
|
1905
1359
|
env: io.env
|
|
1906
1360
|
};
|
|
1907
|
-
return installSkill({ targets, all, global, list: list2, dryRun, picker }, io2);
|
|
1361
|
+
return installSkill({ targets, all: all || yes, global, list: list2, dryRun, picker }, io2);
|
|
1908
1362
|
}
|
|
1909
1363
|
async function readVersion() {
|
|
1910
1364
|
const here = fileURLToPath(import.meta.url);
|
|
1911
1365
|
for (const rel of ["../../package.json", "../package.json"]) {
|
|
1912
1366
|
try {
|
|
1913
1367
|
const url = new URL(rel, `file://${here}`);
|
|
1914
|
-
const text = await
|
|
1368
|
+
const text = await readFile2(url, "utf8");
|
|
1915
1369
|
const version = JSON.parse(text).version;
|
|
1916
1370
|
if (version)
|
|
1917
1371
|
return version;
|
|
@@ -1952,51 +1406,68 @@ Targeting (update / versions / rollback):
|
|
|
1952
1406
|
--token <tok> A site's manage token, for acting on an anonymous site from a
|
|
1953
1407
|
machine that doesn't remember it. Owned sites use your login.
|
|
1954
1408
|
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1409
|
+
Ownership — two states, one command:
|
|
1410
|
+
A deploy with no account is TEMPORARY: live now, gone in 14 days. Run
|
|
1411
|
+
'flypod login' and it becomes YOURS: no expiry, listed on your account.
|
|
1412
|
+
Logging in claims EVERY temporary site this machine remembers, not just the
|
|
1413
|
+
last one — so "deploy now, log in whenever" works. You never need a token.
|
|
1414
|
+
|
|
1415
|
+
flypod login Sign in (opens your browser to confirm) and
|
|
1416
|
+
keep every site deployed from this machine.
|
|
1960
1417
|
flypod login --token <t> Save a session token directly (skip the browser).
|
|
1961
1418
|
Or set FLYPOD_TOKEN for agents/CI.
|
|
1962
1419
|
flypod logout Forget the saved session token.
|
|
1963
1420
|
flypod list List sites you own (JSON on stdout).
|
|
1964
|
-
flypod claim <id> <token> Attach
|
|
1421
|
+
flypod claim <id> <token> Attach one anonymous deploy to your account.
|
|
1422
|
+
'flypod login' is the easier path.
|
|
1965
1423
|
flypod forget [--site <id>] Drop this folder's remembered site link.
|
|
1424
|
+
flypod token [--site <id>] Print a site's manage token on stdout. Deploys
|
|
1425
|
+
don't show it — it's saved for you — so you only
|
|
1426
|
+
need this to act on a site from a machine that
|
|
1427
|
+
doesn't remember it. Treat it like a password.
|
|
1966
1428
|
|
|
1967
1429
|
Agents:
|
|
1968
|
-
flypod install skill Teach your coding agents
|
|
1969
|
-
|
|
1430
|
+
flypod install skill Teach your coding agents how to deploy with
|
|
1431
|
+
flypod. Writes an Agent Skill into
|
|
1432
|
+
.claude/skills/flypod/ (Claude Code) and
|
|
1433
|
+
.agents/skills/flypod/ (Codex, Cursor, Gemini
|
|
1434
|
+
CLI, Copilot). Add --global for your home dir,
|
|
1435
|
+
--list to see the paths, --dry-run to preview.
|
|
1970
1436
|
|
|
1971
1437
|
Deploy flags:
|
|
1972
1438
|
--comments Enable comments on the new site (mode: anonymous).
|
|
1973
1439
|
--comments --mode <mode> Same, but choose the mode: anonymous|passcode|
|
|
1974
1440
|
approved.
|
|
1975
1441
|
|
|
1976
|
-
Comments (
|
|
1977
|
-
|
|
1442
|
+
Comments (off by default — enabling is one command):
|
|
1443
|
+
Every verb below takes the site from --site, or from the folder->site link
|
|
1444
|
+
recorded on your first deploy, so --site is optional inside a linked folder.
|
|
1445
|
+
|
|
1446
|
+
flypod comments enable [--site <id>] [--mode anonymous|passcode|approved]
|
|
1978
1447
|
Enable comments on an existing site.
|
|
1979
|
-
flypod comments mode <anonymous|passcode|approved> --site <id> [--passcode <s>]
|
|
1448
|
+
flypod comments mode <anonymous|passcode|approved> [--site <id>] [--passcode <s>]
|
|
1980
1449
|
Enable comments and set the access mode.
|
|
1981
|
-
flypod comments off --site <id>
|
|
1982
|
-
flypod comments list <site>
|
|
1983
|
-
flypod comments show <site> <thread_id> Print a thread with replies.
|
|
1984
|
-
flypod comments post <site> --page <p> --target <json> --body <text>
|
|
1985
|
-
Post a comment
|
|
1986
|
-
flypod comments resolve <site> <thread_id>
|
|
1987
|
-
flypod comments reopen <site> <thread_id>
|
|
1988
|
-
flypod comments webhook set <site> --url <https://...> --secret <s>
|
|
1989
|
-
flypod comments webhook remove <site>
|
|
1450
|
+
flypod comments off [--site <id>] Disable comments (data preserved).
|
|
1451
|
+
flypod comments list [<site>] List threads (--json for ND-JSON).
|
|
1452
|
+
flypod comments show [<site>] <thread_id> Print a thread with replies.
|
|
1453
|
+
flypod comments post [<site>] --page <p> --target <json> --body <text>
|
|
1454
|
+
Post a comment using your account session.
|
|
1455
|
+
flypod comments resolve [<site>] <thread_id> Mark a thread resolved.
|
|
1456
|
+
flypod comments reopen [<site>] <thread_id> Re-open a thread.
|
|
1990
1457
|
|
|
1991
1458
|
Output:
|
|
1992
1459
|
--json Emit a stable JSON result on stdout (for agents/scripts).
|
|
1993
|
-
|
|
1460
|
+
expires_at is epoch ms, or null once the site is yours.
|
|
1461
|
+
'warnings' lists problems that survived the deploy, each with
|
|
1462
|
+
a fix_recipe; 'healed' lists what flypod fixed for you.
|
|
1463
|
+
-q, --quiet Print only the URL on stdout, and nothing else.
|
|
1994
1464
|
-h, --help Show this help. -v, --version Show the flypod version.
|
|
1995
1465
|
|
|
1996
1466
|
Environment:
|
|
1997
1467
|
FLYPOD_TOKEN Deploy as your account without logging in (agents / CI)
|
|
1998
1468
|
DEPLOY_URL Override the deploy server (default: https://flypod.dev)
|
|
1999
1469
|
FLYPOD_CONFIG_DIR Override where the CLI keeps its session + folder memory
|
|
1470
|
+
FLYPOD_SHOW_TOKEN Set to 1 to print the manage token inline on deploy
|
|
2000
1471
|
NO_COLOR Disable ANSI colors
|
|
2001
1472
|
FORCE_COLOR Force ANSI colors even when stderr is not a TTY
|
|
2002
1473
|
|
|
@@ -2012,6 +1483,21 @@ function shortDir(dir) {
|
|
|
2012
1483
|
const rel = relative(process.cwd(), dir);
|
|
2013
1484
|
return rel === "" || rel.startsWith("..") ? dir : rel || ".";
|
|
2014
1485
|
}
|
|
1486
|
+
function fail2(msg, args, style, opts = {}) {
|
|
1487
|
+
if (args.json) {
|
|
1488
|
+
process.stdout.write(`${JSON.stringify({ ok: false, error: msg })}
|
|
1489
|
+
`);
|
|
1490
|
+
} else if (opts.dimOnly) {
|
|
1491
|
+
process.stderr.write(` ${style.dim(msg)}
|
|
1492
|
+
|
|
1493
|
+
`);
|
|
1494
|
+
} else {
|
|
1495
|
+
process.stderr.write(` ${style.err("✗")} ${msg}
|
|
1496
|
+
|
|
1497
|
+
`);
|
|
1498
|
+
}
|
|
1499
|
+
process.exit(1);
|
|
1500
|
+
}
|
|
2015
1501
|
async function main() {
|
|
2016
1502
|
const rawArgv = process.argv.slice(2);
|
|
2017
1503
|
const version = await readVersion();
|
|
@@ -2031,7 +1517,8 @@ async function main() {
|
|
|
2031
1517
|
`);
|
|
2032
1518
|
return;
|
|
2033
1519
|
}
|
|
2034
|
-
const
|
|
1520
|
+
const client = await createClient({});
|
|
1521
|
+
const { token: apiKey, baseUrl } = client;
|
|
2035
1522
|
const useUI = !args.json && !args.quiet;
|
|
2036
1523
|
const style = makeStyle(colorsEnabled(process.stderr) && useUI);
|
|
2037
1524
|
if (useUI) {
|
|
@@ -2040,7 +1527,7 @@ async function main() {
|
|
|
2040
1527
|
|
|
2041
1528
|
`);
|
|
2042
1529
|
if (!apiKey) {
|
|
2043
|
-
process.stderr.write(` ${style.muted("account")} ${style.dim("anonymous · ")}${style.bold("flypod login")}${style.dim("
|
|
1530
|
+
process.stderr.write(` ${style.muted("account")} ${style.dim("anonymous · deploy now, ")}${style.bold("flypod login")}${style.dim(" later to keep it")}
|
|
2044
1531
|
|
|
2045
1532
|
`);
|
|
2046
1533
|
}
|
|
@@ -2049,45 +1536,18 @@ async function main() {
|
|
|
2049
1536
|
try {
|
|
2050
1537
|
dir = await resolveDeployDir({ explicit: args.path });
|
|
2051
1538
|
} catch (error) {
|
|
2052
|
-
|
|
2053
|
-
if (args.json) {
|
|
2054
|
-
process.stdout.write(`${JSON.stringify({ ok: false, error: msg })}
|
|
2055
|
-
`);
|
|
2056
|
-
} else {
|
|
2057
|
-
process.stderr.write(` ${style.err("✗")} ${msg}
|
|
2058
|
-
|
|
2059
|
-
`);
|
|
2060
|
-
}
|
|
2061
|
-
process.exit(1);
|
|
1539
|
+
fail2(error.message, args, style);
|
|
2062
1540
|
}
|
|
2063
1541
|
let files;
|
|
2064
1542
|
try {
|
|
2065
1543
|
files = await collectDist(dir);
|
|
2066
1544
|
} catch (error) {
|
|
2067
|
-
|
|
2068
|
-
if (args.json) {
|
|
2069
|
-
process.stdout.write(`${JSON.stringify({ ok: false, error: msg })}
|
|
2070
|
-
`);
|
|
2071
|
-
} else {
|
|
2072
|
-
process.stderr.write(` ${style.err("✗")} ${msg}
|
|
2073
|
-
|
|
2074
|
-
`);
|
|
2075
|
-
}
|
|
2076
|
-
process.exit(1);
|
|
1545
|
+
fail2(`Could not read ${shortDir(dir)}: ${error.message}`, args, style);
|
|
2077
1546
|
}
|
|
2078
1547
|
const fileNames = Object.keys(files);
|
|
2079
1548
|
const totalBytes = fileNames.reduce((sum, name) => sum + (files[name]?.byteLength ?? 0), 0);
|
|
2080
1549
|
if (fileNames.length === 0) {
|
|
2081
|
-
|
|
2082
|
-
if (args.json) {
|
|
2083
|
-
process.stdout.write(`${JSON.stringify({ ok: false, error: msg })}
|
|
2084
|
-
`);
|
|
2085
|
-
} else {
|
|
2086
|
-
process.stderr.write(` ${style.err("✗")} ${msg}
|
|
2087
|
-
|
|
2088
|
-
`);
|
|
2089
|
-
}
|
|
2090
|
-
process.exit(1);
|
|
1550
|
+
fail2(`No files found in ${shortDir(dir)}.`, args, style);
|
|
2091
1551
|
}
|
|
2092
1552
|
if (useUI) {
|
|
2093
1553
|
process.stderr.write(` ${style.muted("source")} ${style.bold(shortDir(dir))} ${style.dim(`${fmtCount(fileNames.length, "file")} · ${fmtBytes(totalBytes)}`)}
|
|
@@ -2098,23 +1558,15 @@ async function main() {
|
|
|
2098
1558
|
const started = Date.now();
|
|
2099
1559
|
let result;
|
|
2100
1560
|
try {
|
|
2101
|
-
result = await deploySite({ baseUrl, files, apiKey });
|
|
1561
|
+
result = await deploySite({ baseUrl, files, apiKey, source: client.source });
|
|
2102
1562
|
} catch (error) {
|
|
2103
1563
|
spinner.fail("Deploy failed.");
|
|
2104
|
-
|
|
2105
|
-
if (args.json) {
|
|
2106
|
-
process.stdout.write(`${JSON.stringify({ ok: false, error: msg })}
|
|
2107
|
-
`);
|
|
2108
|
-
} else {
|
|
2109
|
-
process.stderr.write(` ${style.dim(msg)}
|
|
2110
|
-
|
|
2111
|
-
`);
|
|
2112
|
-
}
|
|
2113
|
-
process.exit(1);
|
|
1564
|
+
fail2(error.message, args, style, { dimOnly: true });
|
|
2114
1565
|
}
|
|
2115
1566
|
const elapsed = Date.now() - started;
|
|
2116
1567
|
spinner.success(`Deployed in ${fmtSeconds(elapsed)}`);
|
|
2117
1568
|
const owned = typeof result.owner_account_id === "string";
|
|
1569
|
+
let linkSaved = true;
|
|
2118
1570
|
try {
|
|
2119
1571
|
await linkProject(process.cwd(), {
|
|
2120
1572
|
site_id: result.site_id,
|
|
@@ -2125,7 +1577,9 @@ async function main() {
|
|
|
2125
1577
|
last_used: Date.now(),
|
|
2126
1578
|
version_id: result.version_id
|
|
2127
1579
|
});
|
|
2128
|
-
} catch {
|
|
1580
|
+
} catch {
|
|
1581
|
+
linkSaved = false;
|
|
1582
|
+
}
|
|
2129
1583
|
let commentsEnabled = false;
|
|
2130
1584
|
if (args.comments) {
|
|
2131
1585
|
if (!apiKey) {
|
|
@@ -2137,18 +1591,14 @@ async function main() {
|
|
|
2137
1591
|
try {
|
|
2138
1592
|
const allowed = new Set(["anonymous", "passcode", "approved", "open", "review", "members"]);
|
|
2139
1593
|
const mode = allowed.has(args.commentsMode) ? args.commentsMode : "anonymous";
|
|
2140
|
-
const cr = await
|
|
2141
|
-
method: "PUT",
|
|
2142
|
-
headers: { "content-type": "application/json", authorization: `Bearer ${apiKey}` },
|
|
2143
|
-
body: JSON.stringify({ enabled: true, mode })
|
|
2144
|
-
});
|
|
1594
|
+
const cr = await client.setCommentsMode(result.site_id, { enabled: true, mode });
|
|
2145
1595
|
commentsEnabled = cr.ok;
|
|
2146
1596
|
if (useUI) {
|
|
2147
1597
|
if (cr.ok) {
|
|
2148
1598
|
process.stderr.write(` ${style.muted("comments")} ${style.dim(`enabled (${mode})`)}
|
|
2149
1599
|
`);
|
|
2150
1600
|
} else {
|
|
2151
|
-
process.stderr.write(` ${style.muted("comments")} ${style.dim(
|
|
1601
|
+
process.stderr.write(` ${style.muted("comments")} ${style.dim(`failed to enable — run \`flypod comments enable --site ${result.site_id}\``)}
|
|
2152
1602
|
`);
|
|
2153
1603
|
}
|
|
2154
1604
|
}
|
|
@@ -2169,6 +1619,8 @@ async function main() {
|
|
|
2169
1619
|
files: fileNames.length,
|
|
2170
1620
|
bytes: totalBytes,
|
|
2171
1621
|
elapsed_ms: elapsed,
|
|
1622
|
+
healed: result.healed ?? [],
|
|
1623
|
+
warnings: result.warnings ?? [],
|
|
2172
1624
|
...args.comments ? { comments_enabled: commentsEnabled, comments_mode: args.commentsMode } : {}
|
|
2173
1625
|
}, null, 2)}
|
|
2174
1626
|
`);
|
|
@@ -2177,7 +1629,8 @@ async function main() {
|
|
|
2177
1629
|
if (args.quiet) {
|
|
2178
1630
|
process.stdout.write(`${result.url}
|
|
2179
1631
|
`);
|
|
2180
|
-
|
|
1632
|
+
if (!linkSaved && !owned)
|
|
1633
|
+
process.stderr.write(`${result.manage_token}
|
|
2181
1634
|
`);
|
|
2182
1635
|
return;
|
|
2183
1636
|
}
|
|
@@ -2192,7 +1645,7 @@ async function main() {
|
|
|
2192
1645
|
process.stderr.write(` ${rule}
|
|
2193
1646
|
|
|
2194
1647
|
`);
|
|
2195
|
-
const expiry = typeof result.expires_at === "number" ? `in ${Math.max(0, Math.round((result.expires_at - Date.now()) / 86400000))} days
|
|
1648
|
+
const expiry = typeof result.expires_at === "number" ? `in ${Math.max(0, Math.round((result.expires_at - Date.now()) / 86400000))} days · \`flypod login\` keeps this and every other site you deployed here` : result.owner_account_id ? "never . attributed to your account" : "never (claimed)";
|
|
2196
1649
|
process.stderr.write(` ${style.muted("expires")} ${style.dim(expiry)}
|
|
2197
1650
|
|
|
2198
1651
|
`);
|
|
@@ -2201,9 +1654,17 @@ async function main() {
|
|
|
2201
1654
|
` + ` ${style.muted("history")} ${style.bold("flypod versions")}
|
|
2202
1655
|
|
|
2203
1656
|
`);
|
|
2204
|
-
|
|
1657
|
+
if (!linkSaved && !owned) {
|
|
1658
|
+
process.stderr.write(` ${style.err("!")} ${style.bold("Couldn't remember this site")} ${style.dim(`— can't write ${projectsFilePath()}`)}
|
|
1659
|
+
` + ` ${style.dim("Save this manage token now — without it you can't update or claim this site:")}
|
|
1660
|
+
` + ` ${style.accent(result.manage_token)}
|
|
1661
|
+
|
|
1662
|
+
`);
|
|
1663
|
+
} else if (process.env.FLYPOD_SHOW_TOKEN) {
|
|
1664
|
+
process.stderr.write(` ${style.dim(`manage token ${result.manage_token} — remembered for this folder; needed only with --site elsewhere`)}
|
|
2205
1665
|
|
|
2206
1666
|
`);
|
|
1667
|
+
}
|
|
2207
1668
|
process.stdout.write(`${result.url}
|
|
2208
1669
|
`);
|
|
2209
1670
|
}
|