flypod 0.11.3 → 0.12.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 CHANGED
@@ -452,6 +452,7 @@ publish something.
452
452
  | `deploy_site`, `update_site`, `rollback_site` | Publish a site, publish a new version, go back to an earlier one |
453
453
  | `get_site`, `compare_versions` | A site's URL, expiry and versions; the files that differ between two versions |
454
454
  | `duplicate_site` | Copy a temporary site to a new URL |
455
+ | `configure_timeline` | Show or hide the version slider on a site's pages |
455
456
  | `list_sites`, `rename_site`, `delete_site` | The sites on your account |
456
457
  | `keep_site` | Attach a temporary site to your account so it no longer expires |
457
458
  | `configure_comments`, `list_comments`, `get_comment_thread` | Turn comments on or off; read threads and the moderation queue |
@@ -494,14 +495,31 @@ The way a static export expects, with nothing to configure:
494
495
  - **Caching.** Files whose name carries a build hash (`app.3f9a2c1b.js`,
495
496
  `assets/index-BjK3x9aZ.css`, anything under `_next/static/` or `_astro/`)
496
497
  are served `immutable` for a year. Everything else revalidates after a
497
- minute, so a `flypod update` shows up promptly.
498
+ minute, so a `flypod update` shows up promptly. For a day after a deploy
499
+ (and on a site with the timeline on) it revalidates on every request
500
+ instead, which costs a `304` and keeps a reloaded page from pairing new
501
+ HTML with an old stylesheet.
502
+ - **Live update.** A page that is open when you deploy reloads itself, so a
503
+ tab on a second screen or a phone follows your work. It applies for a day
504
+ after each deploy: the page asks which version is live, every two seconds
505
+ at first and less often as the site settles, and not at all while the tab
506
+ is hidden. A site that has not been deployed for a day carries no script.
507
+ A page someone has typed into is never reloaded.
498
508
  - **Media.** Non-HTML files answer byte-range requests, which is what lets
499
509
  video and audio play on Safari and iOS.
500
510
  - **Link previews.** A page with no `og:title` or `og:description` gets them
501
- from its own `<title>` and first paragraph, so a pasted URL unfurls with the
502
- page's title instead of a bare address. Tags you wrote are never changed.
503
- `<meta name="flypod" content="none">` turns this and the attribution block
504
- off.
511
+ from its own `<title>` and first paragraph, and a page with no `og:image`
512
+ gets a card: its title and description set in type, with the site's
513
+ address underneath. A pasted URL then unfurls with a picture and the
514
+ page's own words instead of a bare address. The card is drawn the first
515
+ time something asks for it, not at deploy time, and is not a screenshot.
516
+ Tags you wrote are never changed. `<meta name="flypod" content="none">`
517
+ turns this, live update and the attribution block off.
518
+ - **Version timeline** (opt-in). `--timeline` puts a small slider on the
519
+ site's pages that steps through its versions, so a reviewer can compare
520
+ the third attempt with the fifth without anyone rolling back. It is off
521
+ by default because it makes replaced versions public. Versions that are
522
+ not live are kept for seven days.
505
523
  - **Dead links.** An address with no site shows a browser a short page saying
506
524
  that previews last 14 days and how the owner keeps one.
507
525
  - **Read-only.** A site answers `GET` and `HEAD`; anything else gets a `405`.
@@ -565,6 +583,8 @@ Deploy flags:
565
583
  | `--json` | Emit the result as JSON on stdout (replaces the pretty output) |
566
584
  | `--verbose` | More of the same receipt. In a terminal: the rollback and history commands, plus the site id, version id and source folder. With `--json`: also tokens, counts, timing. Also on `flypod update` |
567
585
  | `-q`, `--quiet` | Print only the URL on stdout, and nothing else |
586
+ | `--watch` | Keep running and deploy again each time the folder changes. With `--json`, one line per deploy. Ctrl+C to stop. Also on `flypod update` |
587
+ | `--timeline`, `--no-timeline` | Show or hide the version slider on the site's pages. Also on `flypod update` |
568
588
  | `--comments` | Enable comments on the new site (requires being signed in) |
569
589
  | `--mode <mode>` | With `--comments`: `anonymous` (default), `passcode`, or `approved` |
570
590
  | `-h`, `--help` | Show usage |
@@ -12,7 +12,7 @@ import {
12
12
  resolveCredentials,
13
13
  resolveDeployDir,
14
14
  saveSession
15
- } from "../cli-zc5d42zg.js";
15
+ } from "../cli-6255rw94.js";
16
16
 
17
17
  // bin/deploy.ts
18
18
  import { readFile as readFile2 } from "node:fs/promises";
@@ -471,6 +471,82 @@ function agentNext(opts) {
471
471
  };
472
472
  }
473
473
 
474
+ // src/cli/watch.ts
475
+ import { createHash } from "node:crypto";
476
+ import { readdir, stat } from "node:fs/promises";
477
+ import { join } from "node:path";
478
+ var POLL_MS = 400;
479
+ var RETRY_MS = 5000;
480
+ async function snapshot(path) {
481
+ const parts = [];
482
+ async function walk(current) {
483
+ for (const entry of await readdir(current, { withFileTypes: true })) {
484
+ const full = join(current, entry.name);
485
+ if (entry.isDirectory())
486
+ await walk(full);
487
+ else {
488
+ const info = await stat(full);
489
+ parts.push(`${full}\x00${info.size}\x00${info.mtimeMs}`);
490
+ }
491
+ }
492
+ }
493
+ try {
494
+ const info = await stat(path);
495
+ if (info.isFile())
496
+ return `${path}\x00${info.size}\x00${info.mtimeMs}`;
497
+ await walk(path);
498
+ } catch {
499
+ return null;
500
+ }
501
+ return parts.length === 0 ? null : parts.sort().join(`
502
+ `);
503
+ }
504
+ function contentKey(files) {
505
+ const hash = createHash("sha1");
506
+ for (const name of Object.keys(files).sort()) {
507
+ hash.update(name);
508
+ hash.update("\x00");
509
+ hash.update(files[name]);
510
+ hash.update("\x00");
511
+ }
512
+ return hash.digest("hex");
513
+ }
514
+ function sleepUntil(ms, signal) {
515
+ return new Promise((resolve) => {
516
+ if (signal.aborted)
517
+ return resolve();
518
+ const timer = setTimeout(done, ms);
519
+ function done() {
520
+ clearTimeout(timer);
521
+ signal.removeEventListener("abort", done);
522
+ resolve();
523
+ }
524
+ signal.addEventListener("abort", done);
525
+ });
526
+ }
527
+ async function watchLoop(opts) {
528
+ const sleep = opts.sleep ?? ((ms) => sleepUntil(ms, opts.signal));
529
+ let shipped = opts.baseline;
530
+ let seen = opts.baseline;
531
+ while (!opts.signal.aborted) {
532
+ await sleep(opts.pollMs ?? POLL_MS);
533
+ if (opts.signal.aborted)
534
+ return;
535
+ const now = await opts.snapshot();
536
+ if (now !== seen) {
537
+ seen = now;
538
+ continue;
539
+ }
540
+ if (now === null || now === shipped)
541
+ continue;
542
+ if (await opts.ship() === "retry") {
543
+ await sleep(opts.retryMs ?? RETRY_MS);
544
+ continue;
545
+ }
546
+ shipped = now;
547
+ }
548
+ }
549
+
474
550
  // src/cli/commands.ts
475
551
  function siteUrlFrom(site_id, baseUrl) {
476
552
  const host = new URL(baseUrl).host;
@@ -490,6 +566,10 @@ Ship a new version of the site linked to this folder.
490
566
  Flags:
491
567
  --site <id> Target a site by id instead of the linked folder.
492
568
  --token <tok> Authorize with a manage_token.
569
+ --watch Keep running and deploy again each time the folder changes.
570
+ With --json, one line per deploy. Ctrl+C to stop.
571
+ --timeline Show a version slider on the site's pages, so a visitor can
572
+ step back through earlier versions. --no-timeline hides it.
493
573
  --verbose The full receipt: also the rollback command, and with
494
574
  --json the expiry restated as days and an ISO date.
495
575
  --json Emit JSON on stdout (for agents/scripts).
@@ -904,7 +984,7 @@ async function touchLink(target, version_id, env) {
904
984
  await linkProject(target.dir, { ...target.rec, version_id, last_used: Date.now() }, env);
905
985
  }
906
986
  }
907
- async function update(args, io) {
987
+ async function updateContext(args, io) {
908
988
  const pre = await withTarget("update", args, io);
909
989
  if (typeof pre === "number")
910
990
  return pre;
@@ -916,13 +996,15 @@ async function update(args, io) {
916
996
  } catch (e) {
917
997
  return emitError(noBuildDir(e.message), args, io);
918
998
  }
919
- let files;
920
- try {
921
- files = await collectDist(dir);
922
- } catch (e) {
923
- return fail("no_files", `Could not read ${dir}: ${e.message}`, args, io);
924
- }
925
- const client = await clientForTarget(target, args, io);
999
+ return { env, target, dir, client: await clientForTarget(target, args, io) };
1000
+ }
1001
+ function clock(ms) {
1002
+ const d = new Date(ms);
1003
+ const two = (n) => String(n).padStart(2, "0");
1004
+ return `${two(d.getHours())}:${two(d.getMinutes())}:${two(d.getSeconds())}`;
1005
+ }
1006
+ async function publishUpdate(ctx, files, args, io, opts) {
1007
+ const { env, target, client } = ctx;
926
1008
  let res;
927
1009
  try {
928
1010
  res = await client.redeploy(target.site_id, packDeploy(files));
@@ -933,6 +1015,11 @@ async function update(args, io) {
933
1015
  return failSiteRequest("flypod update", res, target, args, io, env);
934
1016
  const body = await res.json();
935
1017
  await touchLink(target, body.version_id, env);
1018
+ let timeline;
1019
+ if (args.timeline !== undefined && !opts.again) {
1020
+ const ok = await client.setTimeline(target.site_id, args.timeline).then((r) => r.ok).catch(() => false);
1021
+ timeline = ok ? args.timeline : !args.timeline;
1022
+ }
936
1023
  const expiresAt = body.expires_at !== undefined ? body.expires_at : target.rec?.expires_at ?? null;
937
1024
  if (args.json) {
938
1025
  io.out(JSON.stringify({
@@ -943,6 +1030,7 @@ async function update(args, io) {
943
1030
  healed: body.healed ?? [],
944
1031
  warnings: body.warnings ?? [],
945
1032
  expires_at: expiresAt,
1033
+ ...timeline !== undefined ? { timeline } : {},
946
1034
  ...(args.verbose ? agentNext : agentNextCommands)({
947
1035
  siteId: target.site_id,
948
1036
  expiresAt,
@@ -952,7 +1040,15 @@ async function update(args, io) {
952
1040
  return 0;
953
1041
  }
954
1042
  if (args.quiet) {
955
- io.out(body.url);
1043
+ if (!opts.again)
1044
+ io.out(body.url);
1045
+ return 0;
1046
+ }
1047
+ const s = io.style ?? PLAIN;
1048
+ if (opts.again) {
1049
+ io.err(headline("Updated", `${clock(Date.now())} · version ${shortVersion(body.version_id)}`, s));
1050
+ for (const line of warningLines(body.warnings, s))
1051
+ io.err(line);
956
1052
  return 0;
957
1053
  }
958
1054
  for (const line of updateScreen({
@@ -965,10 +1061,85 @@ async function update(args, io) {
965
1061
  })) {
966
1062
  io.err(line);
967
1063
  }
1064
+ if (timeline !== undefined) {
1065
+ for (const line of timelineRows(args.timeline, timeline, s))
1066
+ io.err(line);
1067
+ }
968
1068
  if (!io.interactive)
969
1069
  io.out(body.url);
970
1070
  return 0;
971
1071
  }
1072
+ function timelineRows(asked, now, s) {
1073
+ if (asked !== now) {
1074
+ return [field("timeline", "not changed", "the server refused; run it again", s), ""];
1075
+ }
1076
+ return [
1077
+ field("timeline", now ? "on" : "off", now ? "visitors can step back through versions" : "only the live version is public", s),
1078
+ ""
1079
+ ];
1080
+ }
1081
+ async function watchUpdates(ctx, args, io, state) {
1082
+ const controller = new AbortController;
1083
+ const stop = () => controller.abort();
1084
+ if (io.signal) {
1085
+ if (io.signal.aborted)
1086
+ stop();
1087
+ else
1088
+ io.signal.addEventListener("abort", stop, { once: true });
1089
+ } else {
1090
+ process.once("SIGINT", stop);
1091
+ process.once("SIGTERM", stop);
1092
+ }
1093
+ if (!args.json && !args.quiet) {
1094
+ io.err(field("watching", ctx.dir, "saves deploy · Ctrl+C to stop", io.style ?? PLAIN));
1095
+ io.err("");
1096
+ }
1097
+ let shipped = state.shipped;
1098
+ await watchLoop({
1099
+ baseline: state.baseline,
1100
+ snapshot: () => snapshot(ctx.dir),
1101
+ signal: controller.signal,
1102
+ pollMs: io.watchPollMs,
1103
+ ship: async () => {
1104
+ let files;
1105
+ try {
1106
+ files = await collectDist(ctx.dir);
1107
+ } catch {
1108
+ return "retry";
1109
+ }
1110
+ const key = contentKey(files);
1111
+ if (Object.keys(files).length === 0 || key === shipped)
1112
+ return "done";
1113
+ const code = await publishUpdate(ctx, files, args, io, { again: true });
1114
+ if (code === 0)
1115
+ shipped = key;
1116
+ return code === 4 ? "retry" : "done";
1117
+ }
1118
+ });
1119
+ return 0;
1120
+ }
1121
+ async function update(args, io) {
1122
+ const ctx = await updateContext(args, io);
1123
+ if (typeof ctx === "number")
1124
+ return ctx;
1125
+ const baseline = args.watch ? await snapshot(ctx.dir) : null;
1126
+ let files;
1127
+ try {
1128
+ files = await collectDist(ctx.dir);
1129
+ } catch (e) {
1130
+ return fail("no_files", `Could not read ${ctx.dir}: ${e.message}`, args, io);
1131
+ }
1132
+ const code = await publishUpdate(ctx, files, args, io, { again: false });
1133
+ if (code !== 0 || !args.watch)
1134
+ return code;
1135
+ return watchUpdates(ctx, args, io, { baseline, shipped: contentKey(files) });
1136
+ }
1137
+ async function watchSite(args, io, state) {
1138
+ const ctx = await updateContext(args, io);
1139
+ if (typeof ctx === "number")
1140
+ return ctx;
1141
+ return watchUpdates(ctx, args, io, state);
1142
+ }
972
1143
  async function versions(args, io) {
973
1144
  const pre = await withTarget("versions", args, io);
974
1145
  if (typeof pre === "number")
@@ -1742,6 +1913,11 @@ var INSTALL_FLAG_SPEC = {
1742
1913
  "-y": "bool",
1743
1914
  ...Object.fromEntries(Object.keys(TARGET_FLAGS).map((f) => [f, "bool"]))
1744
1915
  };
1916
+ function timelineFlag(flags) {
1917
+ if (flags["--no-timeline"])
1918
+ return false;
1919
+ return flags["--timeline"] ? true : undefined;
1920
+ }
1745
1921
  var TOP_LEVEL_FLAG_SPEC = {
1746
1922
  "--json": "bool",
1747
1923
  "-q": "bool",
@@ -1752,7 +1928,10 @@ var TOP_LEVEL_FLAG_SPEC = {
1752
1928
  "--version": "bool",
1753
1929
  "--comments": "bool",
1754
1930
  "--mode": "value",
1755
- "--verbose": "bool"
1931
+ "--verbose": "bool",
1932
+ "--watch": "bool",
1933
+ "--timeline": "bool",
1934
+ "--no-timeline": "bool"
1756
1935
  };
1757
1936
  function rejectUnknownFlag(unknown, argv, helpCmd) {
1758
1937
  const err = {
@@ -1783,7 +1962,9 @@ function parseArgs(argv) {
1783
1962
  version: Boolean(flags["-v"] || flags["--version"]),
1784
1963
  comments: Boolean(flags["--comments"]),
1785
1964
  commentsMode: flags["--mode"] ?? "anonymous",
1786
- verbose: Boolean(flags["--verbose"])
1965
+ verbose: Boolean(flags["--verbose"]),
1966
+ watch: Boolean(flags["--watch"]),
1967
+ timeline: timelineFlag(flags)
1787
1968
  };
1788
1969
  }
1789
1970
  var SUB_FLAG_SPEC = {
@@ -1794,7 +1975,10 @@ var SUB_FLAG_SPEC = {
1794
1975
  "--quiet": "bool",
1795
1976
  "-h": "bool",
1796
1977
  "--help": "bool",
1797
- "--verbose": "bool"
1978
+ "--verbose": "bool",
1979
+ "--watch": "bool",
1980
+ "--timeline": "bool",
1981
+ "--no-timeline": "bool"
1798
1982
  };
1799
1983
  var LOGIN_FLAG_SPEC = {
1800
1984
  "--token": "value",
@@ -1819,11 +2003,13 @@ function parseSub(name, argv) {
1819
2003
  json: Boolean(flags["--json"]),
1820
2004
  quiet: Boolean(flags["-q"] || flags["--quiet"]),
1821
2005
  help: Boolean(flags["-h"] || flags["--help"]),
1822
- verbose: Boolean(flags["--verbose"])
2006
+ verbose: Boolean(flags["--verbose"]),
2007
+ watch: Boolean(flags["--watch"]),
2008
+ timeline: timelineFlag(flags)
1823
2009
  };
1824
2010
  }
1825
- async function runSubcommand(name, argv) {
1826
- const io = {
2011
+ function terminalIO() {
2012
+ return {
1827
2013
  out: (line) => process.stdout.write(`${line}
1828
2014
  `),
1829
2015
  err: (line) => process.stderr.write(`${line}
@@ -1831,10 +2017,13 @@ async function runSubcommand(name, argv) {
1831
2017
  interactive: Boolean(process.stdout.isTTY),
1832
2018
  style: makeStyle(colorsEnabled(process.stderr))
1833
2019
  };
2020
+ }
2021
+ async function runSubcommand(name, argv) {
2022
+ const io = terminalIO();
1834
2023
  switch (name) {
1835
2024
  case "update": {
1836
- const { positionals, site, token: token2, json, quiet, help, verbose } = parseSub(name, argv);
1837
- return update({ path: positionals[0], site, token: token2, json, quiet, help, verbose }, io);
2025
+ const { positionals, site, token: token2, json, quiet, help, verbose, watch, timeline } = parseSub(name, argv);
2026
+ return update({ path: positionals[0], site, token: token2, json, quiet, help, verbose, watch, timeline }, io);
1838
2027
  }
1839
2028
  case "versions": {
1840
2029
  const { site, token: token2, json, help } = parseSub(name, argv);
@@ -1995,11 +2184,16 @@ Ownership — two states, one command:
1995
2184
 
1996
2185
  Attribution:
1997
2186
  flypod adds a small block of <meta> and JSON-LD to served HTML so crawlers
1998
- can tell what hosts the page. It renders nothing and runs no script. It also
1999
- fills in link-preview tags a page lacks (og:title, og:description), taken
2000
- from the page's own title and text, so a pasted URL unfurls properly; tags
2001
- you wrote are never changed. To turn all of it off, put this anywhere in
2002
- your page:
2187
+ can tell what hosts the page. It renders nothing. It also fills in the
2188
+ link-preview tags a page lacks (og:title, og:description, and an og:image
2189
+ card drawn from the two), taken from the page's own title and text, so a
2190
+ pasted URL unfurls properly; tags you wrote are never changed.
2191
+
2192
+ For a day after each deploy, pages also carry a few lines of script that
2193
+ reload the page when the next version lands, so an open tab follows your
2194
+ work. A page someone has typed into is left alone.
2195
+
2196
+ To turn all of it off, put this anywhere in your page:
2003
2197
 
2004
2198
  <meta name="flypod" content="none">
2005
2199
 
@@ -2025,7 +2219,15 @@ Agents:
2025
2219
  CLI, Copilot). Add --global for your home dir,
2026
2220
  --list to see the paths, --dry-run to preview.
2027
2221
 
2028
- Deploy flags:
2222
+ Deploy flags (the first three also work on 'flypod update'):
2223
+ --watch Keep running: deploy again each time the folder
2224
+ changes. An open page of the site reloads by
2225
+ itself, so a save shows up in the browser.
2226
+ Ctrl+C to stop. With --json, one line per deploy.
2227
+ --timeline Show a version slider on the site's pages, so a
2228
+ visitor can step back through earlier versions.
2229
+ Off by default: it makes replaced versions public.
2230
+ --no-timeline Turn the slider off again.
2029
2231
  --comments Enable comments on the new site (mode: anonymous).
2030
2232
  --comments --mode <mode> Same, but choose the mode: anonymous|passcode|
2031
2233
  approved.
@@ -2129,6 +2331,7 @@ async function main() {
2129
2331
  } catch (error) {
2130
2332
  fail2(noBuildDir(error.message), args, style);
2131
2333
  }
2334
+ const baseline = args.watch ? await snapshot(dir) : null;
2132
2335
  let files;
2133
2336
  try {
2134
2337
  files = await collectDist(dir);
@@ -2201,13 +2404,31 @@ async function main() {
2201
2404
  } catch {}
2202
2405
  }
2203
2406
  }
2407
+ let timeline;
2408
+ if (args.timeline !== undefined) {
2409
+ const siteClient = owned ? client : await createClient({ overrides: { manageToken: result.manage_token, baseUrl } });
2410
+ const ok = await siteClient.setTimeline(result.site_id, args.timeline).then((r) => r.ok).catch(() => false);
2411
+ timeline = ok ? args.timeline : !args.timeline;
2412
+ }
2413
+ const keepWatching = async () => {
2414
+ if (!args.watch)
2415
+ return;
2416
+ const code = await watchSite({
2417
+ path: dir,
2418
+ json: args.json,
2419
+ quiet: args.quiet,
2420
+ ...linkSaved ? {} : { site: result.site_id, ...owned ? {} : { token: result.manage_token } }
2421
+ }, terminalIO(), { baseline, shipped: contentKey(files) });
2422
+ process.exit(code);
2423
+ };
2204
2424
  if (args.json) {
2205
2425
  const shared = {
2206
2426
  healed: result.healed ?? [],
2207
2427
  warnings: result.warnings ?? [],
2208
2428
  link_saved: linkSaved,
2209
2429
  ...priorLink && priorLink.site_id !== result.site_id ? { replaced_link: { site_id: priorLink.site_id, url: priorLink.url } } : {},
2210
- ...args.comments ? { comments_enabled: commentsEnabled, comments_mode: args.commentsMode } : {}
2430
+ ...args.comments ? { comments_enabled: commentsEnabled, comments_mode: args.commentsMode } : {},
2431
+ ...timeline !== undefined ? { timeline } : {}
2211
2432
  };
2212
2433
  const nextOpts = {
2213
2434
  siteId: result.site_id,
@@ -2240,8 +2461,9 @@ async function main() {
2240
2461
  ...shared,
2241
2462
  ...agentNextCommands(nextOpts)
2242
2463
  };
2243
- process.stdout.write(`${JSON.stringify(receipt, null, 2)}
2464
+ process.stdout.write(`${JSON.stringify(receipt, null, args.watch ? undefined : 2)}
2244
2465
  `);
2466
+ await keepWatching();
2245
2467
  return;
2246
2468
  }
2247
2469
  if (args.quiet) {
@@ -2250,6 +2472,7 @@ async function main() {
2250
2472
  if (!linkSaved && !owned)
2251
2473
  process.stderr.write(`${result.manage_token}
2252
2474
  `);
2475
+ await keepWatching();
2253
2476
  return;
2254
2477
  }
2255
2478
  for (const line of deployScreen({
@@ -2264,6 +2487,12 @@ async function main() {
2264
2487
  process.stderr.write(`${line}
2265
2488
  `);
2266
2489
  }
2490
+ if (timeline !== undefined) {
2491
+ for (const line of timelineRows(args.timeline, timeline, style)) {
2492
+ process.stderr.write(`${line}
2493
+ `);
2494
+ }
2495
+ }
2267
2496
  if (!linkSaved && !owned) {
2268
2497
  for (const line of unsavedLinkNotice({ configPath: projectsFilePath(), manageToken: result.manage_token }, style)) {
2269
2498
  process.stderr.write(`${line}
@@ -2277,6 +2506,7 @@ async function main() {
2277
2506
  if (!process.stdout.isTTY)
2278
2507
  process.stdout.write(`${result.url}
2279
2508
  `);
2509
+ await keepWatching();
2280
2510
  }
2281
2511
  main().catch((error) => {
2282
2512
  const err = unexpectedError(error);
@@ -518,6 +518,36 @@ the site you already made, and the URL holds.
518
518
  flypod update ./dist
519
519
  \`\`\`
520
520
 
521
+ A page of the site that is open in a browser reloads itself when the new
522
+ version lands, for a day after each deploy. Tell the user they can leave the
523
+ tab open; they do not need to refresh.
524
+
525
+ ### Deploy on every save
526
+
527
+ \`\`\`sh
528
+ flypod update ./dist --watch # the linked site
529
+ flypod ./dist --watch # a new site, then keep watching
530
+ \`\`\`
531
+
532
+ \`--watch\` keeps running and ships a new version each time the folder stops
533
+ changing. **It never exits**, so run it in the background and stop it when the
534
+ work is done; do not wait on it. With \`--json\` it prints one line per deploy.
535
+ Use it when the user is iterating with you and watching the page; for a single
536
+ change, a plain \`flypod update\` is simpler.
537
+
538
+ ### Let a reviewer compare versions
539
+
540
+ \`\`\`sh
541
+ flypod update --timeline # --no-timeline turns it off
542
+ \`\`\`
543
+
544
+ \`--timeline\` (also on \`flypod\`) puts a slider on the site's pages that steps
545
+ through its versions without changing what is live. Offer it when the user is
546
+ choosing between iterations. It is off by default because it makes replaced
547
+ versions public: do not turn it on for a site where an earlier version held
548
+ something that was removed on purpose. Versions that are not live are kept
549
+ for seven days.
550
+
521
551
  ## Where sites live
522
552
 
523
553
  Every deployed site — temporary or claimed — is served at
@@ -547,6 +577,11 @@ Every site also answers \`/llms.txt\` with a list of its pages, generated from
547
577
  the deploy unless the folder ships its own. Another agent handed the URL can
548
578
  start there; you do not need to write the file.
549
579
 
580
+ A pasted link unfurls with the page's title, description and a preview card
581
+ drawn from them, unless the page sets its own \`og:\` tags. Give each page a
582
+ real \`<title>\` and a first paragraph that says what it is, and the link looks
583
+ finished wherever the user shares it; you do not need to make an image.
584
+
550
585
  ## Deeper reference
551
586
 
552
587
  Open these when the task calls for them.
@@ -799,6 +834,7 @@ function buildClient(token, baseUrl, fetchImpl, source = "library") {
799
834
  createSite: (zip) => request("POST", "/sites", { zip }),
800
835
  redeploy: (siteId, zip) => request("POST", `/sites/${siteId}/deploys`, { zip }),
801
836
  rollback: (siteId, versionId) => request("POST", `/sites/${siteId}/rollback`, { json: { version_id: versionId } }),
837
+ setTimeline: (siteId, enabled) => request("POST", `/sites/${siteId}/timeline`, { json: { enabled } }),
802
838
  setCommentsMode: (siteId, body) => request("POST", `/api/sites/${siteId}/comments-mode`, { json: body }),
803
839
  listComments: (siteId, query) => request("GET", `/api/sites/${siteId}/comments`, { query }),
804
840
  getThread: (siteId, threadId) => request("GET", `/api/sites/${siteId}/comments/${threadId}`),
@@ -36,6 +36,7 @@ export interface FlypodClient {
36
36
  createSite(zip: Uint8Array): Promise<Response>;
37
37
  redeploy(siteId: string, zip: Uint8Array): Promise<Response>;
38
38
  rollback(siteId: string, versionId: string): Promise<Response>;
39
+ setTimeline(siteId: string, enabled: boolean): Promise<Response>;
39
40
  setCommentsMode(siteId: string, body: {
40
41
  mode?: string;
41
42
  enabled?: boolean;
@@ -19,6 +19,10 @@ export interface CommandIO {
19
19
  * what it has always been.
20
20
  */
21
21
  interactive?: boolean;
22
+ /** Ends a `--watch` loop when aborted. Tests inject one; the binary uses Ctrl+C. */
23
+ signal?: AbortSignal;
24
+ /** How often `--watch` looks at the folder. Tests shorten it; see ./watch.ts for the default. */
25
+ watchPollMs?: number;
22
26
  /** Open a URL in the default browser. Tests inject a no-op. */
23
27
  openUrl?: (url: string) => Promise<void>;
24
28
  /**
@@ -46,7 +50,7 @@ export declare function claim(args: {
46
50
  token?: string;
47
51
  json?: boolean;
48
52
  }, io: CommandIO): Promise<number>;
49
- export declare function update(args: {
53
+ interface UpdateArgs {
50
54
  path?: string;
51
55
  site?: string;
52
56
  token?: string;
@@ -55,7 +59,23 @@ export declare function update(args: {
55
59
  help?: boolean;
56
60
  /** The full receipt instead of the short default. See receipt.ts. */
57
61
  verbose?: boolean;
58
- }, io: CommandIO): Promise<number>;
62
+ /** Keep running and redeploy whenever the folder changes. See ./watch.ts. */
63
+ watch?: boolean;
64
+ /** Turn the version timeline on (`true`) or off (`false`); unset leaves it alone. */
65
+ timeline?: boolean;
66
+ }
67
+ /** What the screen says after `--timeline` / `--no-timeline`. */
68
+ export declare function timelineRows(asked: boolean, now: boolean, s: TailStyle): string[];
69
+ export declare function update(args: UpdateArgs, io: CommandIO): Promise<number>;
70
+ /**
71
+ * Carry on from a first deploy made with `flypod --watch`: the site exists
72
+ * and has just been published, so this only watches. `state` is what that
73
+ * deploy read from disk.
74
+ */
75
+ export declare function watchSite(args: UpdateArgs, io: CommandIO, state: {
76
+ baseline: string | null;
77
+ shipped: string | null;
78
+ }): Promise<number>;
59
79
  export declare function versions(args: {
60
80
  site?: string;
61
81
  token?: string;
@@ -0,0 +1,39 @@
1
+ /**
2
+ * A fingerprint of what is on disk at `path` (a folder or a single file):
3
+ * every file's name, size and modification time. Null when there is nothing
4
+ * to deploy there right now — the path is missing or the folder is empty,
5
+ * which is what the middle of a build looks like.
6
+ */
7
+ export declare function snapshot(path: string): Promise<string | null>;
8
+ /**
9
+ * A fingerprint of the content about to be deployed. A save that changes
10
+ * nothing (an editor rewriting the same bytes, a build that produced identical
11
+ * output) changes the snapshot above but not this, and is not worth a deploy.
12
+ */
13
+ export declare function contentKey(files: Record<string, Uint8Array>): string;
14
+ export interface WatchLoopOptions {
15
+ /** The snapshot of what was last deployed, taken before that deploy read the folder. */
16
+ baseline: string | null;
17
+ snapshot(): Promise<string | null>;
18
+ /**
19
+ * Publish what is on disk now. `"retry"` means it failed for a reason that
20
+ * may pass (the network, a rate limit) and the same content should be tried
21
+ * again; anything else is final until the folder changes.
22
+ */
23
+ ship(): Promise<"done" | "retry">;
24
+ /** Stops the loop. */
25
+ signal: AbortSignal;
26
+ /** Injected by tests. */
27
+ sleep?: (ms: number) => Promise<void>;
28
+ pollMs?: number;
29
+ retryMs?: number;
30
+ }
31
+ /**
32
+ * Poll until stopped, shipping each time the folder has changed and then held
33
+ * still for one tick.
34
+ *
35
+ * "Held still" is the debounce: a build writes its files over a second or
36
+ * two, and deploying the first half of one publishes a broken site. A folder
37
+ * that reads the same on two consecutive ticks has finished changing.
38
+ */
39
+ export declare function watchLoop(opts: WatchLoopOptions): Promise<void>;
package/dist/src/cli.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  collectDist,
5
5
  deploySite,
6
6
  resolveDeployDir
7
- } from "../cli-zc5d42zg.js";
7
+ } from "../cli-6255rw94.js";
8
8
  export {
9
9
  BUILD_DIR_CANDIDATES,
10
10
  DeployError,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flypod",
3
- "version": "0.11.3",
3
+ "version": "0.12.0",
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": "./dist/src/cli.js",
6
6
  "types": "./dist/src/cli.d.ts",