@foleo/cli 0.1.53 → 0.1.55

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AA0CA,OAAO,EAAe,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAEL,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACvB,MAAM,oBAAoB,CAAC;AAuC5B,iGAAiG;AACjG,eAAO,MAAM,uBAAuB,qCAAqC,CAAC;AAO1E,gFAAgF;AAChF,eAAO,MAAM,0BAA0B,sJAW7B,CAAC;AAqDX,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,OAAO,KAAK,CAAC;IACpB,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5C,oBAAoB,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC1E,oBAAoB,CAAC,CACnB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAClE,aAAa,CAAC,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAClD,OAAO,CAAC,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAC1C,KAAK,CAAC,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;QAC5B,WAAW,IAAI,OAAO,CAAC;QACvB,MAAM,IAA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vDD,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAK3E;AA+ED,wBAAsB,sBAAsB,CAC1C,KAAK,EAAE,MAAM,EACb,SAAS,SAAa,GACrB,OAAO,CAAC,eAAe,CAAC,CA+E1B;AAmBD;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,SAAS;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,EAAE,GACnE,MAAM,CAUR;AAED,+EAA+E;AAC/E,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,SAAS;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAAE,GAClD,MAAM,CAWR"}
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import { pathWorkspaceCommand, PATH_WORKSPACE_HELP } from "./path-workspace.js";
6
6
  import { CliEditContext, cliStateRoot } from "./edit-context.js";
7
7
  import { sharedCommand, SHARED_HELP } from "./shared.js";
8
8
  import { membersCommand, MEMBERS_HELP } from "./members.js";
9
- import { workspaceCommand, WORKSPACE_HELP } from "./workspaces.js";
9
+ import { readEditsFile, workspaceCommand, WORKSPACE_HELP, } from "./workspaces.js";
10
10
  import { spawn } from "node:child_process";
11
11
  import { createHash, randomUUID } from "node:crypto";
12
12
  import { constants } from "node:fs";
@@ -17,6 +17,7 @@ import { tmpdir } from "node:os";
17
17
  import { createServer } from "node:http";
18
18
  import { dirname, join, relative, resolve, sep } from "node:path";
19
19
  import { fileURLToPath, pathToFileURL } from "node:url";
20
+ import { parseArgs } from "node:util";
20
21
  import { FoleoError, LocalError, renderFailure, toFoleoError, UsageError, } from "./errors.js";
21
22
  import { auditImages } from "./images.js";
22
23
  import { optimizeImages, } from "./image-encoder.js";
@@ -202,10 +203,17 @@ export async function runCli(argv, deps = {
202
203
  stdout: (message) => process.stdout.write(message),
203
204
  stderr: (message) => process.stderr.write(message),
204
205
  }) {
205
- const wantsJson = argv.includes("--json");
206
+ let wantsJson = argv.includes("--json");
206
207
  let activeDeps = deps;
207
208
  try {
208
209
  const global = parseGlobalFlags(argv);
210
+ const [command, ...rest] = global.argv;
211
+ const optionTokens = [...rest];
212
+ if (command === "edit")
213
+ for (let i = 0; i < rest.length; i++)
214
+ if (EDIT_LITERAL_FLAGS.has(rest[i]) && i + 1 < rest.length)
215
+ optionTokens[++i] = "";
216
+ wantsJson = optionTokens.includes("--json");
209
217
  const selectedDeps = global.environment
210
218
  ? { ...deps, env: { ...deps.env, FOLEO_ENV: global.environment } }
211
219
  : deps;
@@ -258,8 +266,7 @@ export async function runCli(argv, deps = {
258
266
  };
259
267
  activeDeps = commandDeps;
260
268
  jsonOutputs.set(commandDeps, wantsJson);
261
- const [command, ...rest] = global.argv;
262
- if (rest.includes("--optimize-images") &&
269
+ if (optionTokens.includes("--optimize-images") &&
263
270
  !["publish", "update"].includes(command ?? "")) {
264
271
  throw new UsageError("--optimize-images applies to an HTML bundle folder", "image_optimization_not_applicable");
265
272
  }
@@ -292,12 +299,15 @@ export async function runCli(argv, deps = {
292
299
  // cannot plan now refuses the flag rather than ignoring it (spec 089 §D).
293
300
  // Commands in the set below reach their own guard, which names the
294
301
  // operation and stays stable for callers already matching on it.
295
- if (rest.includes("--dry-run") && !DRY_RUN_AWARE_COMMANDS.has(command)) {
296
- throw new UsageError(`--dry-run is not supported by \`foleo ${command}\`. Only \`publish\` on an HTML bundle can plan.`, "dry_run_unsupported", { operation: command });
302
+ if (optionTokens.includes("--dry-run") &&
303
+ !DRY_RUN_AWARE_COMMANDS.has(command) &&
304
+ command !== "edit" &&
305
+ !(command === "workspace" && rest[0] === "edit")) {
306
+ throw new UsageError(`--dry-run is not supported by \`foleo ${command}\`. Use \`foleo edit\`, \`foleo workspace edit\`, or the HTML bundle workflow to preview changes.`, "dry_run_unsupported", { operation: command });
297
307
  }
298
308
  // Same shape as the --dry-run guard: a runtime profile on a command that
299
309
  // cannot send one must fail rather than be silently ignored.
300
- if (rest.includes("--runtime-profile") &&
310
+ if (optionTokens.includes("--runtime-profile") &&
301
311
  !RUNTIME_PROFILE_COMMANDS.has(command)) {
302
312
  throw runtimeProfileNotApplicable({
303
313
  operation: describeArgvToken(command),
@@ -306,6 +316,10 @@ export async function runCli(argv, deps = {
306
316
  if (command === "workspace" ||
307
317
  command === "capabilities" ||
308
318
  command === "approval") {
319
+ if (optionTokens.includes("--help") || optionTokens.includes("-h")) {
320
+ commandDeps.stdout(WORKSPACE_HELP);
321
+ return 0;
322
+ }
309
323
  return await workspaceCommand(command === "capabilities"
310
324
  ? ["capabilities", ...rest]
311
325
  : command === "approval"
@@ -327,24 +341,38 @@ export async function runCli(argv, deps = {
327
341
  }
328
342
  : { headers: { authorization: `Bearer ${credential.token}` } });
329
343
  if (!response.ok)
330
- throw apiResponseError(response.status, await response.json());
344
+ throw apiResponseError(response.status, await response.json(), true);
331
345
  return response;
332
346
  },
333
347
  });
334
348
  }
335
- if (["save", "read", "share", "ls"].includes(command) ||
349
+ if ([
350
+ "save",
351
+ "edit",
352
+ "read",
353
+ "share",
354
+ "ls",
355
+ "search",
356
+ "history",
357
+ "recent",
358
+ "move",
359
+ "trash",
360
+ "undo",
361
+ ].includes(command) ||
336
362
  (command === "list" &&
337
363
  (rest.some((arg) => arg.startsWith("/")) ||
338
364
  rest.includes("--workspace") ||
365
+ rest.includes("--view") ||
366
+ rest.includes("--observe-subtree") ||
339
367
  selectedWorkspace !== undefined))) {
340
- if (rest.includes("--help") || rest.includes("-h")) {
368
+ if (optionTokens.includes("--help") || optionTokens.includes("-h")) {
341
369
  commandDeps.stdout(PATH_WORKSPACE_HELP);
342
370
  return 0;
343
371
  }
344
372
  const credential = await resolveCredentialWithSource(commandDeps);
345
373
  if (!credential)
346
374
  throw new LocalError("credential_missing", "No Foleo credential found.", { next: "Sign in or set FOLEO_TOKEN." });
347
- const sessionAt = rest.indexOf("--session"), session = sessionAt >= 0 ? (rest[sessionAt + 1] ?? "default") : "default";
375
+ const sessionAt = optionTokens.indexOf("--session"), session = sessionAt >= 0 ? (rest[sessionAt + 1] ?? "default") : "default";
348
376
  return await pathWorkspaceCommand(command === "list" ? "ls" : command, rest, {
349
377
  stdout: commandDeps.stdout,
350
378
  readStdin: async () => {
@@ -447,6 +475,8 @@ export async function runCli(argv, deps = {
447
475
  return await publish(rest, commandDeps);
448
476
  if (command === "update")
449
477
  return await update(rest, commandDeps);
478
+ if (command === "republish")
479
+ return await republish(rest, commandDeps);
450
480
  if (command === "name")
451
481
  return await nameCommand(rest, commandDeps);
452
482
  if (command === "names")
@@ -1293,7 +1323,7 @@ async function htmlPublishDryRun(root, name, parsed, deps) {
1293
1323
  const entryHtml = entryFile
1294
1324
  ? new TextDecoder("utf-8").decode(entryFile.bytes)
1295
1325
  : undefined;
1296
- const derived = name ??
1326
+ let derived = name ??
1297
1327
  deriveArtifactName(root, entryHtml, {
1298
1328
  minLength: ARTIFACT_NAME_MIN_LENGTH,
1299
1329
  maxLength: ARTIFACT_NAME_MAX_LENGTH,
@@ -1319,15 +1349,40 @@ async function htmlPublishDryRun(root, name, parsed, deps) {
1319
1349
  let cost = null;
1320
1350
  let executable = false;
1321
1351
  let reclaimable = false;
1352
+ const address = parsed.address ?? "vanity";
1353
+ let previewUrl = address === "vanity" ? artifactPreviewUrl(derived, deps) : null;
1322
1354
  try {
1323
- const result = await requestJson(deps, `/subdomains/${encodeURIComponent(derived)}`, { method: "GET", body: undefined });
1324
- availability = result.status;
1325
- reclaimable = isReclaimableByCaller(result);
1355
+ if (address === "scoped") {
1356
+ const query = new URLSearchParams({ address, name: derived });
1357
+ const result = await fetchPublishAddressPreview(query, deps);
1358
+ if (!result.label || !result.previewUrl) {
1359
+ if (result.errorCode)
1360
+ throw new FoleoError({
1361
+ code: result.errorCode,
1362
+ message: "Foleo could not find an available workspace-scoped address.",
1363
+ source: "api",
1364
+ ...(result.next ? { next: result.next } : {}),
1365
+ });
1366
+ refuseUnavailableName(derived, result.status, "Choose a different --name and preview it with --address scoped.");
1367
+ throw new FoleoError({
1368
+ code: "address_preview_unavailable",
1369
+ message: "The server did not return a candidate address.",
1370
+ source: "api",
1371
+ });
1372
+ }
1373
+ derived = result.suggestedSlug ?? result.slug ?? derived;
1374
+ previewUrl = result.previewUrl;
1375
+ reclaimable = isReclaimableByCaller(result);
1376
+ // The server can choose a suffixed scoped label if the exact slug is taken.
1377
+ availability = reclaimable ? "cooldown" : "available";
1378
+ }
1379
+ else {
1380
+ const result = await requestJson(deps, `/subdomains/${encodeURIComponent(derived)}`, { method: "GET", body: undefined });
1381
+ availability = result.status;
1382
+ reclaimable = isReclaimableByCaller(result);
1383
+ refuseUnavailableName(derived, availability, "Choose a different --name and check it first: foleo name-check <label> --json");
1384
+ }
1326
1385
  checkedAt = new Date((deps.now ?? Date.now)()).toISOString();
1327
- // Spec 089 L859: an unavailable name is a failure, not a plan — it gets
1328
- // the same stable error object a real create would fail with, not a
1329
- // buried `plan.name.availability` field an agent has to know to check.
1330
- refuseUnavailableName(derived, availability, "Choose a different --name and check it first: foleo name-check <label> --json");
1331
1386
  const usage = await requestJson(deps, "/usage", {
1332
1387
  method: "GET",
1333
1388
  body: undefined,
@@ -1367,7 +1422,6 @@ async function htmlPublishDryRun(root, name, parsed, deps) {
1367
1422
  availability = "unknown";
1368
1423
  deps.stderr("Not signed in: this plan is bundle-only and cannot tell you whether the name is free. Run `foleo login` and plan again before publishing.\n");
1369
1424
  }
1370
- const previewUrl = artifactPreviewUrl(derived, deps);
1371
1425
  const plan = {
1372
1426
  ok: true,
1373
1427
  warnings,
@@ -1384,15 +1438,13 @@ async function htmlPublishDryRun(root, name, parsed, deps) {
1384
1438
  checkedAt,
1385
1439
  },
1386
1440
  url: previewUrl,
1387
- // Spec 103: HTML names are vanity labels today; handle-scoped agent
1388
- // addresses (ADR 0049) are a separate, later class.
1389
1441
  address: {
1390
- class: "vanity",
1442
+ class: address,
1391
1443
  hostname: previewUrl === null ? null : new URL(previewUrl).hostname,
1392
1444
  },
1393
1445
  nameQuota: {
1394
- [NAME_QUOTA_DIMENSIONS.claimsPerDay]: 1,
1395
- [NAME_QUOTA_DIMENSIONS.activeNames]: 1,
1446
+ [NAME_QUOTA_DIMENSIONS.claimsPerDay]: address === "scoped" ? 0 : 1,
1447
+ [NAME_QUOTA_DIMENSIONS.activeNames]: address === "scoped" ? 0 : 1,
1396
1448
  },
1397
1449
  title: resolvedTitle,
1398
1450
  visibility: resolvedVisibility.value,
@@ -1447,10 +1499,10 @@ async function htmlPublishDryRun(root, name, parsed, deps) {
1447
1499
  }
1448
1500
  async function htmlPublish(args, deps) {
1449
1501
  resolveUploadRate(deps);
1450
- const parsed = parseFlags(args);
1502
+ const parsed = parseFlags(args, { allowPublishAddress: true });
1451
1503
  const root = parsed.positionals[0];
1452
1504
  if (!root || parsed.positionals.length !== 1 || !parsed.acceptHostingRisk)
1453
- throw new Error("Usage: foleo html-publish <bundle-root> --accept-hosting-risk --name <label> [--settings <json>] [--password-stdin] [--publish-separately] [--runtime-profile auto|open|contained] [--acknowledge-access-widening] [--dry-run] [--json]\nHosted HTML is executable and may run JavaScript, show forms, or initiate downloads. A human must inspect the source and explicitly approve this risk; an agent must not infer approval.");
1505
+ throw new Error("Usage: foleo html-publish <bundle-root> --accept-hosting-risk --name <slug|label> [--address scoped|vanity] [--settings <json>] [--password-stdin] [--publish-separately] [--runtime-profile auto|open|contained] [--acknowledge-access-widening] [--dry-run] [--json]\nHosted HTML is executable and may run JavaScript, show forms, or initiate downloads. A human must inspect the source and explicitly approve this risk; an agent must not infer approval.");
1454
1506
  const settings = { ...(parsed.settings ?? {}) };
1455
1507
  // A dry run may omit --name to obtain a derived suggestion; a real create
1456
1508
  // may not (spec 089 §B).
@@ -1494,7 +1546,10 @@ async function htmlPublish(args, deps) {
1494
1546
  settings.password = password;
1495
1547
  }
1496
1548
  announceApi(deps, parsed.json);
1497
- const result = await publishBundle(root, deps, null, true, parsed.publishSeparately, settings, htmlWireOptions(parsed));
1549
+ const result = await publishBundle(root, deps, null, true, parsed.publishSeparately, settings, {
1550
+ ...htmlWireOptions(parsed),
1551
+ ...(parsed.address ? { address: parsed.address } : {}),
1552
+ });
1498
1553
  writeResult(deps, result, parsed.json);
1499
1554
  return 0;
1500
1555
  }
@@ -1988,6 +2043,7 @@ async function publishBundle(root, deps, update, hostingRiskAcknowledged = false
1988
2043
  uploadId: upload.uploadId,
1989
2044
  manifestHash: upload.manifestHash,
1990
2045
  hostingRiskAcknowledged,
2046
+ ...(wire.address ? { address: wire.address } : {}),
1991
2047
  source,
1992
2048
  ...(publishSeparately ? { allowDuplicate: true } : {}),
1993
2049
  ...(settings && Object.keys(settings).length > 0
@@ -2518,15 +2574,50 @@ async function boundedReadFileBytes(path, maxBytes, realBase) {
2518
2574
  }
2519
2575
  return result;
2520
2576
  }
2577
+ function fetchPublishAddressPreview(query, deps) {
2578
+ return requestJson(deps, "/artifacts/address-preview?" + query, {
2579
+ method: "GET",
2580
+ body: undefined,
2581
+ });
2582
+ }
2583
+ async function previewPublishAddress(args, deps) {
2584
+ const query = new URLSearchParams();
2585
+ for (let i = 0; i < args.length; i++) {
2586
+ const flag = args[i];
2587
+ if (flag === "--json" || flag === "--preview")
2588
+ continue;
2589
+ const field = flag.slice(2);
2590
+ const value = args[++i];
2591
+ if (!["--address", "--name", "--title"].includes(flag) ||
2592
+ query.has(field) ||
2593
+ !value?.trim() ||
2594
+ value.startsWith("--"))
2595
+ throw new UsageError(PUBLISH_PREVIEW_USAGE);
2596
+ query.set(field, value);
2597
+ }
2598
+ if (!query.has("address"))
2599
+ query.set("address", "scoped");
2600
+ if (!["scoped", "vanity"].includes(query.get("address")) ||
2601
+ (!query.has("name") && !query.has("title")))
2602
+ throw new UsageError(PUBLISH_PREVIEW_USAGE);
2603
+ const result = await fetchPublishAddressPreview(query, deps);
2604
+ deps.stdout(JSON.stringify(result, null, 2) + "\n");
2605
+ return 0;
2606
+ }
2607
+ const PUBLISH_PREVIEW_USAGE = "Usage: foleo publish --preview [--address scoped|vanity] (--name <label> | --title <title>) [--json]";
2521
2608
  async function publish(args, deps) {
2609
+ if (args[0] === "--preview")
2610
+ return previewPublishAddress(args, deps);
2522
2611
  resolveUploadRate(deps);
2523
- const parsed = parseFlags(args);
2612
+ const parsed = parseFlags(args, { allowPublishAddress: true });
2524
2613
  const file = parsed.positionals[0];
2525
2614
  if (!file || parsed.positionals.length !== 1)
2526
- throw new Error("Usage: foleo publish <path> [--title <title>] [--settings <json>] [--password-stdin] [--publish-separately] [--accept-hosting-risk] [--name <label>] [--runtime-profile auto|open|contained] [--optimize-images | --no-optimize-images] [--acknowledge-access-widening] [--dry-run] [--json]\nAn HTML site bundle also requires --name <label>; Markdown does not.");
2615
+ throw new Error("Usage: foleo publish <path> [--title <title>] [--settings <json>] [--password-stdin] [--publish-separately] [--accept-hosting-risk] [--name <slug|label>] [--address scoped|vanity] [--runtime-profile auto|open|contained] [--optimize-images | --no-optimize-images] [--acknowledge-access-widening] [--dry-run] [--json]\nAn HTML site bundle also requires --name <label>; Markdown does not.");
2527
2616
  const isDirectory = await pathIsDirectory(file, deps);
2528
2617
  if (parsed.optimizeImages && !isDirectory)
2529
2618
  throw new UsageError("--optimize-images applies to an HTML bundle folder", "image_optimization_not_applicable");
2619
+ if (!isDirectory && parsed.address !== undefined)
2620
+ throw new UsageError("--address applies only to creating or previewing an HTML publication.", "address_not_applicable");
2530
2621
  if (!isDirectory && parsed.dryRun) {
2531
2622
  throw new UsageError("--dry-run is only implemented for HTML site bundles (a directory with --accept-hosting-risk). A Markdown publish is not previewable yet; run it without --dry-run, or use `foleo publish <dir> --accept-hosting-risk --name <label> --dry-run`.", "dry_run_unsupported", { sourceFormat: "markdown" });
2532
2623
  }
@@ -2565,7 +2656,59 @@ async function publish(args, deps) {
2565
2656
  writeResult(deps, withImageReport(result, assets?.warnings ?? []), parsed.json);
2566
2657
  return 0;
2567
2658
  }
2659
+ const ARTIFACT_EDIT_USAGE = "Usage: foleo update <id> --edits <json-file> --base-content-hash <sha256> --revision <etag> --idempotency-key <key> [--json]";
2660
+ async function updateMarkdownEdits(args, deps) {
2661
+ const [id, ...rest] = args;
2662
+ const values = new Map();
2663
+ let json = false;
2664
+ for (let i = 0; i < rest.length; i++) {
2665
+ const flag = rest[i];
2666
+ if (flag === "--json") {
2667
+ json = true;
2668
+ continue;
2669
+ }
2670
+ const value = rest[++i];
2671
+ if (![
2672
+ "--edits",
2673
+ "--base-content-hash",
2674
+ "--revision",
2675
+ "--idempotency-key",
2676
+ ].includes(flag) ||
2677
+ values.has(flag) ||
2678
+ !value ||
2679
+ value.startsWith("--"))
2680
+ throw new UsageError(ARTIFACT_EDIT_USAGE);
2681
+ values.set(flag, value);
2682
+ }
2683
+ const file = values.get("--edits");
2684
+ const baseContentHash = values.get("--base-content-hash");
2685
+ const revision = artifactRevision(values.get("--revision"));
2686
+ const key = values.get("--idempotency-key");
2687
+ if (!id ||
2688
+ !file ||
2689
+ !baseContentHash ||
2690
+ !/^[0-9a-f]{64}$/u.test(baseContentHash) ||
2691
+ !revision ||
2692
+ !key ||
2693
+ !/^[\x21-\x7e]{8,200}$/u.test(key))
2694
+ throw new UsageError(ARTIFACT_EDIT_USAGE);
2695
+ const edits = await readEditsFile(file);
2696
+ const result = await requestJson(deps, `/artifacts/${encodeURIComponent(id)}`, {
2697
+ method: "PUT",
2698
+ headers: artifactMutationHeaders(revision, key),
2699
+ body: {
2700
+ sourceFormat: "markdown",
2701
+ edits,
2702
+ baseContentHash,
2703
+ stagedAssets: [],
2704
+ },
2705
+ });
2706
+ writeResult(deps, result, json);
2707
+ return 0;
2708
+ }
2568
2709
  async function update(args, deps) {
2710
+ if (args[1] === "--edits")
2711
+ return updateMarkdownEdits(args, deps);
2569
2712
  resolveUploadRate(deps);
2570
2713
  const parsed = parseFlags(args);
2571
2714
  const [id, file] = parsed.positionals;
@@ -2901,6 +3044,44 @@ async function uploadMarkdownAssets(markdownPath, markdown, deps, json, reuseFro
2901
3044
  },
2902
3045
  };
2903
3046
  }
3047
+ const REPUBLISH_USAGE = "Usage: foleo republish <id> --revision <etag> --idempotency-key <key> [--acknowledge-access-widening] [--json]";
3048
+ async function republish(args, deps) {
3049
+ const parsed = (() => {
3050
+ try {
3051
+ return parseArgs({
3052
+ args,
3053
+ allowPositionals: true,
3054
+ options: {
3055
+ revision: { type: "string" },
3056
+ "idempotency-key": { type: "string" },
3057
+ "acknowledge-access-widening": { type: "boolean" },
3058
+ json: { type: "boolean" },
3059
+ },
3060
+ });
3061
+ }
3062
+ catch {
3063
+ throw new UsageError(REPUBLISH_USAGE);
3064
+ }
3065
+ })();
3066
+ const [id] = parsed.positionals;
3067
+ const revision = artifactRevision(parsed.values.revision);
3068
+ const key = parsed.values["idempotency-key"];
3069
+ if (!id ||
3070
+ parsed.positionals.length !== 1 ||
3071
+ revision === null ||
3072
+ !key ||
3073
+ !/^[\x21-\x7e]{8,200}$/u.test(key))
3074
+ throw new UsageError(REPUBLISH_USAGE);
3075
+ const result = await withRateLimitRetry(deps, "republishing the artifact", () => requestJson(deps, `/artifacts/${encodeURIComponent(id)}/republish`, {
3076
+ method: "POST",
3077
+ body: parsed.values["acknowledge-access-widening"]
3078
+ ? accessWideningField(true)
3079
+ : undefined,
3080
+ headers: artifactMutationHeaders(revision, key),
3081
+ }));
3082
+ writeResult(deps, result, parsed.values.json === true);
3083
+ return 0;
3084
+ }
2904
3085
  async function unpublish(args, deps) {
2905
3086
  const parsed = parseFlags(args);
2906
3087
  const id = parsed.positionals[0];
@@ -3779,7 +3960,8 @@ async function requestJsonWithToken(deps, path, token, init) {
3779
3960
  const key = init.headers?.["idempotency-key"];
3780
3961
  const receiptWrite = key &&
3781
3962
  (init.method === "POST" || init.method === "PUT") &&
3782
- /^\/(?:artifacts(?:\/html)?|docs)(?:\/[^/]+)?$/u.test(path);
3963
+ (/^\/(?:artifacts(?:\/html)?|docs)(?:\/[^/]+)?$/u.test(path) ||
3964
+ /^\/artifacts\/[^/]+\/republish$/u.test(path));
3783
3965
  let response;
3784
3966
  let body;
3785
3967
  for (let retry = 0;; retry++) {
@@ -3842,7 +4024,7 @@ async function requestJsonWithToken(deps, path, token, init) {
3842
4024
  class ApiRequestError extends FoleoError {
3843
4025
  status;
3844
4026
  body;
3845
- constructor(status, code, body) {
4027
+ constructor(status, code, body, workspace = false) {
3846
4028
  const next = apiErrorNext(body);
3847
4029
  const envelope = isRecord(body) && isRecord(body.error) ? body.error : null;
3848
4030
  // Spec 103: preserve the server's `retryable` verbatim, and carry the
@@ -3854,7 +4036,14 @@ class ApiRequestError extends FoleoError {
3854
4036
  : null;
3855
4037
  super({
3856
4038
  code,
3857
- message: code === "bundle_new_files_limit" &&
4039
+ message: (code === "bundle_new_files_limit" ||
4040
+ code === "site_move_out_unavailable" ||
4041
+ (workspace &&
4042
+ ![
4043
+ "approval_required",
4044
+ "input_required",
4045
+ "acknowledgement_required",
4046
+ ].includes(code))) &&
3858
4047
  typeof envelope?.message === "string"
3859
4048
  ? envelope.message
3860
4049
  : code === "matching_source_exists"
@@ -3888,9 +4077,11 @@ class ApiRequestError extends FoleoError {
3888
4077
  .filter((field) => envelope[field] !== undefined)
3889
4078
  .map((field) => [field, envelope[field]])),
3890
4079
  }
3891
- : references === null
3892
- ? {}
3893
- : { context: { references } }),
4080
+ : references !== null
4081
+ ? { context: { references } }
4082
+ : workspace && isRecord(envelope?.details)
4083
+ ? { context: envelope.details }
4084
+ : {}),
3894
4085
  });
3895
4086
  this.name = "ApiRequestError";
3896
4087
  this.status = status;
@@ -4002,8 +4193,8 @@ allowReplay = false) {
4002
4193
  throw new ApiRequestError(response.status, apiErrorCode(body, response.status), body);
4003
4194
  }
4004
4195
  }
4005
- function apiResponseError(status, body) {
4006
- return new ApiRequestError(status, apiErrorCode(body, status), body);
4196
+ function apiResponseError(status, body, workspace = false) {
4197
+ return new ApiRequestError(status, apiErrorCode(body, status), body, workspace);
4007
4198
  }
4008
4199
  function apiBase(deps) {
4009
4200
  const selected = deps.env.FOLEO_ENV ?? "production";
@@ -4474,6 +4665,7 @@ function parseFlags(args, options = {}) {
4474
4665
  let allowWorkspaces = false;
4475
4666
  let allowWorkspaceSharing = false;
4476
4667
  let name;
4668
+ let address;
4477
4669
  let dryRun = false;
4478
4670
  let optimizeImages;
4479
4671
  let previous;
@@ -4500,6 +4692,13 @@ function parseFlags(args, options = {}) {
4500
4692
  throw new UsageError("--name requires a value", "name_missing");
4501
4693
  continue;
4502
4694
  }
4695
+ if (arg === "--address" && options.allowPublishAddress) {
4696
+ const value = args[++i];
4697
+ if (address || (value !== "scoped" && value !== "vanity"))
4698
+ throw new UsageError("--address requires one of scoped or vanity.", "address_invalid");
4699
+ address = value;
4700
+ continue;
4701
+ }
4503
4702
  if (arg === "--optimize-images") {
4504
4703
  optimizeImages = true;
4505
4704
  continue;
@@ -4684,6 +4883,7 @@ function parseFlags(args, options = {}) {
4684
4883
  allowWorkspaces,
4685
4884
  allowWorkspaceSharing,
4686
4885
  ...(name === undefined ? {} : { name }),
4886
+ ...(address === undefined ? {} : { address }),
4687
4887
  dryRun,
4688
4888
  optimizeImages,
4689
4889
  ...(previous === undefined ? {} : { previous }),
@@ -4864,10 +5064,19 @@ async function workspaceOrganizations(args, deps) {
4864
5064
  }
4865
5065
  return 0;
4866
5066
  }
5067
+ const EDIT_LITERAL_FLAGS = new Set(["--find", "--replace"]);
4867
5068
  function parseGlobalFlags(argv) {
4868
5069
  let workspace;
4869
5070
  const filtered = [];
5071
+ const editLiteralValues = new Set();
4870
5072
  for (let i = 0; i < argv.length; i++) {
5073
+ if (EDIT_LITERAL_FLAGS.has(argv[i]) &&
5074
+ filtered.find((arg) => !["--production", "--staging", "--local"].includes(arg)) === "edit" &&
5075
+ argv[i + 1] !== undefined) {
5076
+ filtered.push(argv[i], argv[++i]);
5077
+ editLiteralValues.add(filtered.length - 1);
5078
+ continue;
5079
+ }
4871
5080
  if (argv[i] !== "--workspace") {
4872
5081
  filtered.push(argv[i]);
4873
5082
  continue;
@@ -4881,17 +5090,32 @@ function parseGlobalFlags(argv) {
4881
5090
  }
4882
5091
  const command = filtered.find((arg) => !["--production", "--staging", "--local"].includes(arg));
4883
5092
  if (workspace && isTreeId(workspace)) {
4884
- if (!["save", "read", "share", "ls", "list"].includes(command ?? ""))
5093
+ if (![
5094
+ "save",
5095
+ "edit",
5096
+ "read",
5097
+ "share",
5098
+ "ls",
5099
+ "list",
5100
+ "search",
5101
+ "history",
5102
+ "recent",
5103
+ "move",
5104
+ "trash",
5105
+ "undo",
5106
+ ].includes(command ?? ""))
4885
5107
  throw new UsageError("A UUID --workspace tree ID is supported only on cloud-file commands.");
4886
5108
  filtered.push("--workspace", workspace);
4887
5109
  }
4888
- const selected = filtered.filter((arg) => ["--production", "--staging", "--local"].includes(arg));
5110
+ const selected = filtered.filter((arg, index) => !editLiteralValues.has(index) &&
5111
+ ["--production", "--staging", "--local"].includes(arg));
4889
5112
  if (new Set(selected).size > 1)
4890
5113
  throw new Error("Choose only one of --production, --staging, or --local");
4891
5114
  const environment = selected[0]?.slice(2);
4892
5115
  return {
4893
5116
  ...(workspace ? { workspace } : {}),
4894
- argv: filtered.filter((arg) => !["--production", "--staging", "--local"].includes(arg)),
5117
+ argv: filtered.filter((arg, index) => editLiteralValues.has(index) ||
5118
+ !["--production", "--staging", "--local"].includes(arg)),
4895
5119
  ...(environment ? { environment } : {}),
4896
5120
  };
4897
5121
  }
@@ -4921,8 +5145,14 @@ function help() {
4921
5145
  " foleo list [--kind <kind>] [--format <format>] [--runtime <class>] [--limit <n>] [--json]",
4922
5146
  " foleo get <id> [--json]",
4923
5147
  " foleo export <id> <dir> [--force] [--json] (source and assets; SHA-256 verified)",
5148
+ " " + PUBLISH_PREVIEW_USAGE.replace("Usage: ", ""),
4924
5149
  " foleo publish <path> [--title <title>] [--settings <json>] [--password-stdin] [--publish-separately] [--acknowledge-access-widening] [--json]",
4925
- " foleo publish <dir> --accept-hosting-risk --name <label> [--runtime-profile auto|open|contained] [--optimize-images | --no-optimize-images] [--dry-run] [--json]",
5150
+ " foleo publish <dir> --accept-hosting-risk --name <slug|label> [--address scoped|vanity] [--runtime-profile auto|open|contained] [--optimize-images | --no-optimize-images] [--dry-run] [--json]",
5151
+ " " + ARTIFACT_EDIT_USAGE.replace("Usage: ", ""),
5152
+ " " + REPUBLISH_USAGE.replace("Usage: ", ""),
5153
+ " foleo approval get <id> [--json]",
5154
+ " foleo approval commit <id> --idempotency-key <key> [--json]",
5155
+ " For a staged publication, open the Foleo review link, check approval status, then commit.",
4926
5156
  " foleo update <id> <path> --revision <etag> [--runtime-profile auto|open|contained] [--optimize-images | --no-optimize-images] [--acknowledge-access-widening] [--dry-run] [--json]",
4927
5157
  " foleo update <id> <file.md> --version <version> [--acknowledge-access-widening] [--json] (compatibility)",
4928
5158
  " Identical updates may return unchanged: true; revision/ETag stay unchanged. Retry an interrupted request with the same idempotency key.",