flypod 0.4.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -11,7 +11,7 @@ npx flypod ./dist
11
11
 
12
12
  - **No auth to deploy** — POST a zip, receive a URL + one-time tokens
13
13
  - **Ephemeral by default** — anonymous deploys expire in 14 days
14
- - **Optional accounts** — sign in once at [`flypod.dev/account`](https://flypod.dev/account) and every site you've deployed from that browser becomes permanently yours. CLI keys (`fk_...`) drop anonymous expiry too. See [`docs/identity.md`](https://github.com/sdserranog/flypod/blob/main/docs/identity.md)
14
+ - **Optional accounts** — sign in once at [`flypod.dev/account`](https://flypod.dev/account) and every site you've deployed from that browser becomes permanently yours. CLI keys (`fk_...`) drop anonymous expiry too.
15
15
  - **Rollback built-in** — every deploy is versioned; roll back with a single call
16
16
  - **Render loop** — optional headless screenshot + console capture on every deploy
17
17
 
@@ -235,7 +235,7 @@ console.log(result.manage_token); // one-time — save to redeploy / rollback /
235
235
  | Option | Type | Default | Description |
236
236
  |--------|------|---------|-------------|
237
237
  | `files` | `Record<string, Uint8Array>` | — | File path → bytes map |
238
- | `baseUrl` | `string` | `https://flypod.dev` | Override for self-hosted servers |
238
+ | `baseUrl` | `string` | `https://flypod.dev` | Override the deploy server |
239
239
  | `handle` | `(req) => Promise<Response>` | `fetch` | Injectable transport (used in tests) |
240
240
 
241
241
  Returns a `DeployResult`:
@@ -311,39 +311,7 @@ For agents and CI, set `FLYPOD_API_KEY=fk_…` and the CLI sends it as
311
311
  GitHub Actions, in your own code.
312
312
 
313
313
  Login on the web uses **magic link** or **email + password** — pick the one you
314
- prefer; both land you in the same account. The full design (Better Auth
315
- `anonymous` + `magicLink` + `apiKey` plugins plus core email/password on
316
- Cloudflare Workers + Turso, with `onLinkAccount` powering bulk claim) is
317
- documented at [docs/identity.md](https://github.com/sdserranog/flypod/blob/main/docs/identity.md).
318
-
319
- ---
320
-
321
- ## Self-hosting
322
-
323
- ```ts
324
- import { createApp } from "flypod/server";
325
- ```
326
-
327
- The server runs on [Cloudflare Workers](https://workers.cloudflare.com) (free tier). Deploy your own instance:
328
-
329
- ```sh
330
- git clone https://github.com/sdserranog/flypod
331
- cd flypod
332
- bunx wrangler deploy
333
- ```
334
-
335
- Environment variables / secrets:
336
-
337
- | Variable | Default | Description |
338
- |----------|---------|-------------|
339
- | `BASE_HOST` | `flypod.dev` | Wildcard subdomain root |
340
- | `PUBLIC_SCHEME` | `https` | `http` or `https` |
341
- | `LIBSQL_URL` | — | Turso/libSQL connection URL |
342
- | `LIBSQL_AUTH_TOKEN` | — | Turso auth token |
343
- | `SAFE_BROWSING_KEY` | — | Enables Google Safe Browsing link scan |
344
- | `BETTER_AUTH_SECRET` | — | _v0.2:_ Better Auth signing secret (32+ random bytes) |
345
- | `RESEND_API_KEY` | — | _v0.2:_ Resend API key for magic-link email delivery |
346
- | `RESEND_FROM` | `notifications@flypod.dev` | _v0.2:_ verified sender address for magic links |
314
+ prefer; both land you in the same account.
347
315
 
348
316
  ---
349
317
 
@@ -154,28 +154,186 @@ async function clearSession(env) {
154
154
  function baseUrlFrom(env = process.env) {
155
155
  return env.DEPLOY_URL ?? "https://flypod.dev";
156
156
  }
157
- function looksLikeApiKey(key) {
158
- return /^fk_[A-Za-z0-9_-]{16,}$/.test(key);
157
+ function siteUrlFrom(site_id, baseUrl) {
158
+ const host = new URL(baseUrl).host;
159
+ const scheme = new URL(baseUrl).protocol.replace(":", "");
160
+ return `${scheme}://${site_id}.${host}`;
159
161
  }
162
+ var SUBCOMMAND_HELP = {
163
+ update: `flypod update [path] [flags]
164
+
165
+ Ship a new version of the site linked to this folder.
166
+
167
+ flypod update Re-deploy this folder as a new version.
168
+ flypod update ./dist Same, with an explicit path.
169
+ flypod update --site <id> Update any site by id (no folder memory needed).
170
+ flypod update --token <tok> Use a manage_token (anonymous sites).
171
+
172
+ Flags:
173
+ --site <id> Target a site by id instead of the linked folder.
174
+ --token <tok> Authorize with a manage_token.
175
+ --json Emit JSON on stdout (for agents/scripts).
176
+ -q, --quiet Minimal output.
177
+ -h, --help Show this help.`,
178
+ versions: `flypod versions [flags]
179
+
180
+ List every version of the site linked to this folder.
181
+
182
+ flypod versions Show version history for the linked site.
183
+ flypod versions --site <id> Show versions for a specific site.
184
+
185
+ Flags:
186
+ --site <id> Target a site by id.
187
+ --token <tok> Authorize with a manage_token.
188
+ --json Emit JSON on stdout.
189
+ -h, --help Show this help.`,
190
+ rollback: `flypod rollback [version] [flags]
191
+
192
+ Roll the site back to a previous version.
193
+
194
+ flypod rollback Roll back to the immediately previous version.
195
+ flypod rollback <version> Roll back to a specific version id (or prefix).
196
+ flypod rollback --site <id> Roll back a site by id.
197
+
198
+ Flags:
199
+ --site <id> Target a site by id.
200
+ --token <tok> Authorize with a manage_token.
201
+ --json Emit JSON on stdout.
202
+ -h, --help Show this help.`,
203
+ forget: `flypod forget [flags]
204
+
205
+ Drop this folder's remembered site link.
206
+
207
+ flypod forget Forget this folder's link.
208
+ flypod forget --site <id> Forget all folders linked to a site id.
209
+
210
+ Flags:
211
+ --site <id> Forget all links to this site.
212
+ -h, --help Show this help.`,
213
+ login: `flypod login [flags]
214
+
215
+ Authenticate with flypod.
216
+
217
+ flypod login Start the device-flow sign-in (open a browser).
218
+ flypod login --key fk_... Save an API key directly (for agents/CI).
219
+
220
+ Flags:
221
+ --key fk_... Save this API key (minted at flypod.dev/account).
222
+ -h, --help Show this help.`,
223
+ logout: `flypod logout
224
+
225
+ Forget the saved API key. Doesn't affect the server.`,
226
+ list: `flypod list
227
+
228
+ List sites you own (requires login or FLYPOD_API_KEY). Outputs JSON on stdout.`,
229
+ claim: `flypod claim <site_id> <claim_token>
230
+
231
+ Attach an anonymous deploy to your account (requires login or FLYPOD_API_KEY). Outputs JSON on stdout.`,
232
+ keys: `flypod keys create
233
+
234
+ Mint a new API key for agents / CI (requires login or FLYPOD_API_KEY). Outputs JSON on stdout.`,
235
+ install: `flypod install skill [targets] [flags]
236
+
237
+ Teach your coding agents (Claude Code, Codex, Cursor, …) how to deploy with flypod.
238
+
239
+ flypod install skill Interactive picker (TTY).
240
+ flypod install skill --claude Write Claude Code skill.
241
+ flypod install skill --all Write every supported target.
242
+ flypod install skill --global Write to home directory (for AGENTS.md, Claude, Gemini).
243
+ flypod install skill --list Print detected targets without writing.
244
+ flypod install skill --dry-run Show what would be written.
245
+ flypod install skill --yes Skip interactive confirmation.
246
+
247
+ Targets:
248
+ --agents AGENTS.md (Codex, Cursor, Copilot, Gemini, Windsurf, +more)
249
+ --claude Claude Code (.claude/skills/flypod/SKILL.md)
250
+ --cursor Cursor (.cursor/rules/flypod.mdc)
251
+ --copilot GitHub Copilot (.github/copilot-instructions.md)
252
+ --windsurf Windsurf (.windsurf/rules/flypod.md)
253
+ --cline Cline (.clinerules/flypod.md)
254
+ --roo Roo Code (.roo/rules/flypod.md)
255
+ --gemini Gemini CLI (GEMINI.md)
256
+
257
+ Flags:
258
+ --all Write every supported target.
259
+ --global Write to home directory instead of project root.
260
+ --list Print detected targets without writing.
261
+ --dry-run Show what would be written (alias: --print).
262
+ --yes, -y Skip the interactive picker.
263
+ -h, --help Show this help.`
264
+ };
265
+ function showSubHelp(name, io) {
266
+ const help = SUBCOMMAND_HELP[name];
267
+ if (help)
268
+ io.err(help);
269
+ else
270
+ io.err(`No help available for "${name}". Run \`flypod --help\` for usage.`);
271
+ }
272
+ function failJson(error, io) {
273
+ io.out(JSON.stringify({ ok: false, error }));
274
+ return 1;
275
+ }
276
+ var POLL_MAX_ATTEMPTS = 120;
160
277
  async function login(args, io) {
278
+ if (args.help) {
279
+ showSubHelp("login", io);
280
+ return 0;
281
+ }
161
282
  const env = io.env ?? process.env;
162
- if (!args.key) {
163
- io.err("flypod login: --key fk_... is required.");
164
- io.err("");
165
- io.err("Mint a key at https://flypod.dev/account (or wherever your");
166
- io.err("flypod server lives) and run:");
167
- io.err(" flypod login --key fk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
168
- return 2;
283
+ const baseUrl = baseUrlFrom(env);
284
+ if (args.key) {
285
+ if (!args.key.startsWith("fk_") || args.key.length < 20) {
286
+ io.err("Invalid key. Expected fk_ followed by at least 16 characters.");
287
+ return 2;
288
+ }
289
+ await saveSession({ api_key: args.key, base_url: baseUrl, created_at: Date.now() }, env);
290
+ io.err("Logged in.");
291
+ return 0;
169
292
  }
170
- if (!looksLikeApiKey(args.key)) {
171
- io.err("flypod login: that doesn't look like a flypod key (expected fk_...).");
172
- return 2;
293
+ const fetchImpl = io.fetch ?? fetch;
294
+ const startRes = await fetchImpl(`${baseUrl}/auth/device`, { method: "POST" });
295
+ if (!startRes.ok) {
296
+ io.err(`flypod login: server returned ${startRes.status}. Is the server running?`);
297
+ return 1;
173
298
  }
174
- const baseUrl = baseUrlFrom(env);
175
- const path = await saveSession({ api_key: args.key, base_url: baseUrl, created_at: Date.now() }, env);
176
- io.err(`Saved your key to ${path}`);
177
- io.err(`Now using ${baseUrl} for every flypod command.`);
178
- return 0;
299
+ const { device_code, user_code, verification_uri, interval } = await startRes.json();
300
+ const confirmUrl = `${verification_uri}?code=${user_code}`;
301
+ io.err("");
302
+ io.err(` Open this URL in your browser to sign in:`);
303
+ io.err(` ${confirmUrl}`);
304
+ io.err("");
305
+ io.err(` Confirmation code: ${user_code}`);
306
+ io.err("");
307
+ const pollMs = (interval ?? 5) * 1000;
308
+ for (let attempt = 0;attempt < POLL_MAX_ATTEMPTS; attempt++) {
309
+ await new Promise((r) => setTimeout(r, pollMs));
310
+ const pollRes = await fetchImpl(`${baseUrl}/auth/device/token`, {
311
+ method: "POST",
312
+ headers: { "content-type": "application/json" },
313
+ body: JSON.stringify({ device_code })
314
+ });
315
+ if (pollRes.status === 202)
316
+ continue;
317
+ if (!pollRes.ok) {
318
+ const body = await pollRes.json().catch(() => ({}));
319
+ if (body.error === "denied") {
320
+ io.err("Authorization denied in browser.");
321
+ return 1;
322
+ }
323
+ if (body.error === "expired") {
324
+ io.err("Code expired. Run `flypod login` to try again.");
325
+ return 1;
326
+ }
327
+ io.err(`flypod login: unexpected error ${pollRes.status}.`);
328
+ return 1;
329
+ }
330
+ const { api_key } = await pollRes.json();
331
+ await saveSession({ api_key, base_url: baseUrl, created_at: Date.now() }, env);
332
+ io.err("Logged in.");
333
+ return 0;
334
+ }
335
+ io.err("Timed out waiting for browser authorization. Run `flypod login` to try again.");
336
+ return 1;
179
337
  }
180
338
  async function logout(_args, io) {
181
339
  const env = io.env ?? process.env;
@@ -189,13 +347,15 @@ async function logout(_args, io) {
189
347
  async function list(_args, io) {
190
348
  const env = io.env ?? process.env;
191
349
  const session = await loadSession(env);
192
- if (!session) {
193
- io.err("Not signed in. Run `flypod login --key fk_...` first.");
350
+ const apiKey = session?.api_key ?? env.FLYPOD_API_KEY;
351
+ const baseUrl = session?.base_url ?? baseUrlFrom(env);
352
+ if (!apiKey) {
353
+ io.err("Not signed in. Run `flypod login` first or set FLYPOD_API_KEY.");
194
354
  return 1;
195
355
  }
196
356
  const fetchImpl = io.fetch ?? fetch;
197
- const res = await fetchImpl(`${session.base_url}/account/sites`, {
198
- headers: { authorization: `Bearer ${session.api_key}` }
357
+ const res = await fetchImpl(`${baseUrl}/account/sites`, {
358
+ headers: { authorization: `Bearer ${apiKey}` }
199
359
  });
200
360
  if (!res.ok) {
201
361
  io.err(`flypod list: server returned ${res.status}.`);
@@ -207,15 +367,16 @@ async function list(_args, io) {
207
367
  io.err("No sites yet. Run `flypod` in a folder to deploy one.");
208
368
  return 0;
209
369
  }
210
- for (const site of sites)
211
- io.out(`${site.site_id} ${site.url}`);
370
+ io.out(JSON.stringify({ ok: true, sites }));
212
371
  return 0;
213
372
  }
214
373
  async function claim(args, io) {
215
374
  const env = io.env ?? process.env;
216
375
  const session = await loadSession(env);
217
- if (!session) {
218
- io.err("Not signed in. Run `flypod login --key fk_...` first.");
376
+ const apiKey = session?.api_key ?? env.FLYPOD_API_KEY;
377
+ const baseUrl = session?.base_url ?? baseUrlFrom(env);
378
+ if (!apiKey) {
379
+ io.err("Not signed in. Run `flypod login` first or set FLYPOD_API_KEY.");
219
380
  return 1;
220
381
  }
221
382
  if (!args.site_id || !args.token) {
@@ -223,11 +384,11 @@ async function claim(args, io) {
223
384
  return 2;
224
385
  }
225
386
  const fetchImpl = io.fetch ?? fetch;
226
- const res = await fetchImpl(`${session.base_url}/sites/${args.site_id}/claim`, {
387
+ const res = await fetchImpl(`${baseUrl}/sites/${args.site_id}/claim`, {
227
388
  method: "POST",
228
389
  headers: {
229
390
  "content-type": "application/json",
230
- authorization: `Bearer ${session.api_key}`
391
+ authorization: `Bearer ${apiKey}`
231
392
  },
232
393
  body: JSON.stringify({ claim_token: args.token })
233
394
  });
@@ -236,28 +397,30 @@ async function claim(args, io) {
236
397
  return 1;
237
398
  }
238
399
  const body = await res.json();
239
- io.out(body.site_id);
400
+ io.out(JSON.stringify({ ok: true, site_id: body.site_id, owner_account_id: body.owner_account_id }));
240
401
  io.err(`Claimed. Owned by ${body.owner_account_id}.`);
241
402
  return 0;
242
403
  }
243
404
  async function keysCreate(_args, io) {
244
405
  const env = io.env ?? process.env;
245
406
  const session = await loadSession(env);
246
- if (!session) {
247
- io.err("Not signed in. Run `flypod login --key fk_...` first.");
407
+ const apiKey = session?.api_key ?? env.FLYPOD_API_KEY;
408
+ const baseUrl = session?.base_url ?? baseUrlFrom(env);
409
+ if (!apiKey) {
410
+ io.err("Not signed in. Run `flypod login` first or set FLYPOD_API_KEY.");
248
411
  return 1;
249
412
  }
250
413
  const fetchImpl = io.fetch ?? fetch;
251
- const res = await fetchImpl(`${session.base_url}/account/api-keys`, {
414
+ const res = await fetchImpl(`${baseUrl}/account/api-keys`, {
252
415
  method: "POST",
253
- headers: { authorization: `Bearer ${session.api_key}` }
416
+ headers: { authorization: `Bearer ${apiKey}` }
254
417
  });
255
418
  if (!res.ok) {
256
419
  io.err(`flypod keys create: server returned ${res.status}.`);
257
420
  return 1;
258
421
  }
259
422
  const body = await res.json();
260
- io.out(body.api_key);
423
+ io.out(JSON.stringify({ ok: true, api_key: body.api_key }));
261
424
  io.err("Save this now. You will not see it again.");
262
425
  return 0;
263
426
  }
@@ -273,7 +436,7 @@ async function resolveTarget(args, io) {
273
436
  async function requestContext(target, args, env) {
274
437
  const session = await loadSession(env);
275
438
  const baseUrl = target.rec?.base_url ?? session?.base_url ?? baseUrlFrom(env);
276
- const auth = args.token ?? target.rec?.manage_token ?? session?.api_key;
439
+ const auth = args.token ?? target.rec?.manage_token ?? session?.api_key ?? env.FLYPOD_API_KEY;
277
440
  return { baseUrl, auth };
278
441
  }
279
442
  function authHeaders(auth, extra = {}) {
@@ -285,7 +448,7 @@ async function healGone(target, io, env) {
285
448
  io.err(`Site ${target.site_id} is gone (expired or deleted). Run 'flypod' to create a new one.`);
286
449
  }
287
450
  function unauthorized(target, io) {
288
- io.err(`Unauthorized for ${target.site_id}. Run 'flypod login' or pass --token <manage_token>.`);
451
+ io.err(`Unauthorized for ${target.site_id}. Run \`flypod login\` or pass --token <manage_token>.`);
289
452
  }
290
453
  async function fetchSite(target, args, io, env) {
291
454
  const { baseUrl, auth } = await requestContext(target, args, env);
@@ -311,10 +474,16 @@ async function touchLink(target, version_id, env) {
311
474
  }
312
475
  }
313
476
  async function update(args, io) {
477
+ if (args.help) {
478
+ showSubHelp("update", io);
479
+ return 0;
480
+ }
314
481
  const env = io.env ?? process.env;
315
482
  const cwd = io.cwd ?? process.cwd();
316
483
  const target = await resolveTarget(args, io);
317
484
  if (!target) {
485
+ if (args.json)
486
+ return failJson(NO_SITE, io);
318
487
  io.err(NO_SITE);
319
488
  return 1;
320
489
  }
@@ -322,14 +491,20 @@ async function update(args, io) {
322
491
  try {
323
492
  dir = await resolveDeployDir({ cwd, explicit: args.path });
324
493
  } catch (e) {
325
- io.err(e.message);
494
+ const msg = e.message;
495
+ if (args.json)
496
+ return failJson(msg, io);
497
+ io.err(msg);
326
498
  return 1;
327
499
  }
328
500
  let files;
329
501
  try {
330
502
  files = await collectDist(dir);
331
503
  } catch (e) {
332
- io.err(`Could not read ${dir}: ${e.message}`);
504
+ const msg = `Could not read ${dir}: ${e.message}`;
505
+ if (args.json)
506
+ return failJson(msg, io);
507
+ io.err(msg);
333
508
  return 1;
334
509
  }
335
510
  const { baseUrl, auth } = await requestContext(target, args, env);
@@ -352,7 +527,6 @@ async function update(args, io) {
352
527
  return 1;
353
528
  }
354
529
  const body = await res.json();
355
- const noop = target.rec?.version_id !== undefined && body.version_id === target.rec.version_id;
356
530
  await touchLink(target, body.version_id, env);
357
531
  if (args.json) {
358
532
  io.out(JSON.stringify({
@@ -363,14 +537,24 @@ async function update(args, io) {
363
537
  }));
364
538
  return 0;
365
539
  }
366
- io.err(noop ? `No changes — already live as ${body.version_id}.` : `→ version ${body.version_id} is now live`);
540
+ if (args.quiet) {
541
+ io.out(body.url);
542
+ return 0;
543
+ }
544
+ io.err(`→ version ${body.version_id} is now live`);
367
545
  io.out(body.url);
368
546
  return 0;
369
547
  }
370
548
  async function versions(args, io) {
549
+ if (args.help) {
550
+ showSubHelp("versions", io);
551
+ return 0;
552
+ }
371
553
  const env = io.env ?? process.env;
372
554
  const target = await resolveTarget(args, io);
373
555
  if (!target) {
556
+ if (args.json)
557
+ return failJson(NO_SITE, io);
374
558
  io.err(NO_SITE);
375
559
  return 1;
376
560
  }
@@ -388,9 +572,15 @@ async function versions(args, io) {
388
572
  return 0;
389
573
  }
390
574
  async function rollback(args, io) {
575
+ if (args.help) {
576
+ showSubHelp("rollback", io);
577
+ return 0;
578
+ }
391
579
  const env = io.env ?? process.env;
392
580
  const target = await resolveTarget(args, io);
393
581
  if (!target) {
582
+ if (args.json)
583
+ return failJson(NO_SITE, io);
394
584
  io.err(NO_SITE);
395
585
  return 1;
396
586
  }
@@ -407,20 +597,32 @@ async function rollback(args, io) {
407
597
  else if (prefixed.length === 1)
408
598
  chosen = prefixed[0]?.version_id;
409
599
  else if (prefixed.length === 0) {
410
- io.err(`No version matches '${args.version}'.`);
600
+ const msg = `No version matches '${args.version}'.`;
601
+ if (args.json)
602
+ return failJson(msg, io);
603
+ io.err(msg);
411
604
  return 1;
412
605
  } else {
413
- io.err(`'${args.version}' is ambiguous — it matches ${prefixed.length} versions.`);
606
+ const msg = `'${args.version}' is ambiguous — it matches ${prefixed.length} versions.`;
607
+ if (args.json)
608
+ return failJson(msg, io);
609
+ io.err(msg);
414
610
  return 1;
415
611
  }
416
612
  } else {
417
613
  if (vers.length < 2) {
418
- io.err("Only one version exists — nothing to roll back to.");
614
+ const msg = "Only one version exists — nothing to roll back to.";
615
+ if (args.json)
616
+ return failJson(msg, io);
617
+ io.err(msg);
419
618
  return 1;
420
619
  }
421
620
  const liveIdx = vers.findIndex((v) => v.version_id === live_version_id);
422
621
  if (liveIdx <= 0) {
423
- io.err("Already at the oldest version.");
622
+ const msg = "Already at the oldest version.";
623
+ if (args.json)
624
+ return failJson(msg, io);
625
+ io.err(msg);
424
626
  return 1;
425
627
  }
426
628
  chosen = vers[liveIdx - 1]?.version_id;
@@ -434,23 +636,38 @@ async function rollback(args, io) {
434
636
  });
435
637
  if (res.status === 404) {
436
638
  await healGone(target, io, env);
639
+ if (args.json)
640
+ return failJson(`Site ${target.site_id} not found.`, io);
437
641
  return 1;
438
642
  }
439
643
  if (!res.ok) {
440
- io.err(`flypod rollback: server returned ${res.status}.`);
644
+ const msg = `flypod rollback: server returned ${res.status}.`;
645
+ if (args.json)
646
+ return failJson(msg, io);
647
+ io.err(msg);
441
648
  return 1;
442
649
  }
443
650
  const body = await res.json();
444
651
  await touchLink(target, body.live_version_id, env);
652
+ const url = target.rec?.url ?? siteUrlFrom(target.site_id, baseUrl);
445
653
  if (args.json) {
446
- io.out(JSON.stringify({ ok: true, site_id: target.site_id, live_version_id: body.live_version_id }));
654
+ io.out(JSON.stringify({
655
+ ok: true,
656
+ site_id: target.site_id,
657
+ live_version_id: body.live_version_id,
658
+ url
659
+ }));
447
660
  return 0;
448
661
  }
449
662
  io.err(`→ rolled back to ${body.live_version_id}`);
450
- io.out(body.live_version_id);
663
+ io.out(url);
451
664
  return 0;
452
665
  }
453
666
  async function forget(args, io) {
667
+ if (args.help) {
668
+ showSubHelp("forget", io);
669
+ return 0;
670
+ }
454
671
  const env = io.env ?? process.env;
455
672
  if (args.site) {
456
673
  const n = await forgetSite(args.site, env);
@@ -1068,31 +1285,20 @@ Run \`flypod --help\` for usage.
1068
1285
  }
1069
1286
  return out;
1070
1287
  }
1071
- function flag(argv, name) {
1072
- const long = `--${name}`;
1073
- const equals = `${long}=`;
1074
- for (let i = 0;i < argv.length; i++) {
1075
- const a = argv[i];
1076
- if (a === long)
1077
- return argv[i + 1];
1078
- if (a.startsWith(equals))
1079
- return a.slice(equals.length);
1080
- }
1081
- return;
1082
- }
1083
1288
  function parseSub(argv) {
1084
1289
  const positionals = [];
1085
1290
  let site;
1086
1291
  let token;
1087
1292
  let json = false;
1088
1293
  let quiet = false;
1294
+ let help = false;
1089
1295
  for (let i = 0;i < argv.length; i++) {
1090
1296
  const a = argv[i];
1091
- if (a === "--site")
1297
+ if (a === "--site" && i + 1 < argv.length)
1092
1298
  site = argv[++i];
1093
1299
  else if (a.startsWith("--site="))
1094
1300
  site = a.slice("--site=".length);
1095
- else if (a === "--token")
1301
+ else if (a === "--token" && i + 1 < argv.length)
1096
1302
  token = argv[++i];
1097
1303
  else if (a.startsWith("--token="))
1098
1304
  token = a.slice("--token=".length);
@@ -1100,10 +1306,12 @@ function parseSub(argv) {
1100
1306
  json = true;
1101
1307
  else if (a === "-q" || a === "--quiet")
1102
1308
  quiet = true;
1309
+ else if (a === "-h" || a === "--help")
1310
+ help = true;
1103
1311
  else if (!a.startsWith("-"))
1104
1312
  positionals.push(a);
1105
1313
  }
1106
- return { positionals, site, token, json, quiet };
1314
+ return { positionals, site, token, json, quiet, help };
1107
1315
  }
1108
1316
  async function runSubcommand(name, argv) {
1109
1317
  const io = {
@@ -1114,23 +1322,36 @@ async function runSubcommand(name, argv) {
1114
1322
  };
1115
1323
  switch (name) {
1116
1324
  case "update": {
1117
- const { positionals, site, token, json, quiet } = parseSub(argv);
1118
- return update({ path: positionals[0], site, token, json, quiet }, io);
1325
+ const { positionals, site, token, json, quiet, help } = parseSub(argv);
1326
+ return update({ path: positionals[0], site, token, json, quiet, help }, io);
1119
1327
  }
1120
1328
  case "versions": {
1121
- const { site, token, json } = parseSub(argv);
1122
- return versions({ site, token, json }, io);
1329
+ const { site, token, json, help } = parseSub(argv);
1330
+ return versions({ site, token, json, help }, io);
1123
1331
  }
1124
1332
  case "rollback": {
1125
- const { positionals, site, token, json } = parseSub(argv);
1126
- return rollback({ version: positionals[0], site, token, json }, io);
1333
+ const { positionals, site, token, json, help } = parseSub(argv);
1334
+ return rollback({ version: positionals[0], site, token, json, help }, io);
1127
1335
  }
1128
1336
  case "forget": {
1129
- const { site } = parseSub(argv);
1130
- return forget({ site }, io);
1337
+ const { site, help } = parseSub(argv);
1338
+ return forget({ site, help }, io);
1339
+ }
1340
+ case "login": {
1341
+ let key;
1342
+ let help = false;
1343
+ for (let i = 0;i < argv.length; i++) {
1344
+ if (argv[i] === "--key" && i + 1 < argv.length) {
1345
+ key = argv[i + 1];
1346
+ i++;
1347
+ } else if (argv[i]?.startsWith("--key=")) {
1348
+ key = argv[i]?.slice("--key=".length);
1349
+ } else if (argv[i] === "-h" || argv[i] === "--help") {
1350
+ help = true;
1351
+ }
1352
+ }
1353
+ return login({ key, help }, io);
1131
1354
  }
1132
- case "login":
1133
- return login({ key: flag(argv, "key") }, io);
1134
1355
  case "logout":
1135
1356
  return logout({}, io);
1136
1357
  case "list":
@@ -1182,10 +1403,10 @@ async function runInstall(argv, io) {
1182
1403
  io.err("Run `flypod install skill --list` to see available targets and flags.");
1183
1404
  return 2;
1184
1405
  }
1185
- const has = (flag2) => argv.includes(flag2);
1406
+ const has = (flag) => argv.includes(flag);
1186
1407
  const targets = [];
1187
- for (const [flag2, id] of Object.entries(TARGET_FLAGS)) {
1188
- if (has(flag2) && !targets.includes(id))
1408
+ for (const [flag, id] of Object.entries(TARGET_FLAGS)) {
1409
+ if (has(flag) && !targets.includes(id))
1189
1410
  targets.push(id);
1190
1411
  }
1191
1412
  const all = has("--all");
@@ -1262,11 +1483,16 @@ Targeting (update / versions / rollback):
1262
1483
  machine that doesn't remember it. Owned sites use your login.
1263
1484
 
1264
1485
  Account (optional — lets deploys live forever and be listed/owned):
1265
- flypod login --key fk_... Save an API key; deploys are then yours forever.
1486
+ flypod login Link this CLI to your flypod account (opens
1487
+ your browser to confirm). Anonymous deploys
1488
+ keep working; logging in just makes future
1489
+ deploys land in your dashboard.
1490
+ flypod login --key fk_... Save an API key directly (skip the browser).
1491
+ Or set FLYPOD_API_KEY for agents/CI.
1266
1492
  flypod logout Forget the saved API key.
1267
- flypod list List sites you own.
1268
- flypod claim <id> <token> Attach an earlier anonymous deploy to your account.
1269
- flypod keys create Mint a new API key (for agents / CI).
1493
+ flypod list List sites you own (JSON on stdout).
1494
+ flypod claim <id> <token> Attach an anonymous deploy to your account.
1495
+ flypod keys create Mint a new API key for agents / CI (JSON on stdout).
1270
1496
  flypod forget [--site <id>] Drop this folder's remembered site link.
1271
1497
 
1272
1498
  Agents:
@@ -1290,7 +1516,6 @@ When no path is given, flypod looks for a build folder in the current directory:
1290
1516
  (each must contain an index.html)
1291
1517
 
1292
1518
  Docs: https://flypod.dev
1293
- Source: https://github.com/sdserranog/flypod
1294
1519
  `;
1295
1520
  process.stdout.write(usage);
1296
1521
  }
@@ -1325,6 +1550,11 @@ async function main() {
1325
1550
  ${style.bold(style.accent("flypod"))} ${style.dim(`v${version}`)}
1326
1551
 
1327
1552
  `);
1553
+ if (!apiKey) {
1554
+ process.stderr.write(` ${style.muted("account")} ${style.dim("anonymous · ")}${style.bold("flypod login")}${style.dim(" to attribute deploys to your account")}
1555
+
1556
+ `);
1557
+ }
1328
1558
  }
1329
1559
  let dir;
1330
1560
  try {
@@ -1443,7 +1673,7 @@ async function main() {
1443
1673
  process.stderr.write(` ${rule}
1444
1674
 
1445
1675
  `);
1446
- const expiry = typeof result.expires_at === "number" ? `in ${Math.max(0, Math.round((result.expires_at - Date.now()) / 86400000))} days . ephemeral by default` : result.owner_account_id ? `never . owned by you (${result.owner_account_id})` : "never (claimed)";
1676
+ const expiry = typeof result.expires_at === "number" ? `in ${Math.max(0, Math.round((result.expires_at - Date.now()) / 86400000))} days . anonymous deploy (run \`flypod login\` to attribute)` : result.owner_account_id ? "never . attributed to your account" : "never (claimed)";
1447
1677
  process.stderr.write(` ${style.muted("expires")} ${style.dim(expiry)}
1448
1678
 
1449
1679
  `);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flypod",
3
- "version": "0.4.0",
3
+ "version": "0.5.1",
4
4
  "description": "Zero-auth deploy primitive. Turns any folder into a live URL in one command. For AI agents and humans.",
5
5
  "module": "src/cli.ts",
6
6
  "type": "module",