@coderook/cli 0.46.3 → 0.46.5

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.
@@ -135,6 +135,40 @@ function progressLine() {
135
135
  }
136
136
  /** The shared bar, drawn from a percentage and this session's colour setting. */
137
137
  const track = (percent) => (0, progress_js_1.bar)(percent / 100, 18, dim);
138
+ /*
139
+ A line that counts files read while changes are worked out, shown only when
140
+ there are enough to take a while. A folder whose record of its files did not
141
+ match read every file in silence, and a save looked as if it had stopped.
142
+ */
143
+ function readingProgress() {
144
+ let line = null;
145
+ let shown = false;
146
+ let latest = null;
147
+ const draw = (read, toRead) => {
148
+ if (toRead < 200)
149
+ return;
150
+ line ??= progressLine();
151
+ line(` Reading files to find what changed · ${read.toLocaleString()} of ${toRead.toLocaleString()}` +
152
+ dim(" (once; later saves only read what changes)"));
153
+ };
154
+ return {
155
+ report: (read, toRead) => {
156
+ latest = [read, toRead];
157
+ if (shown)
158
+ draw(read, toRead);
159
+ },
160
+ show: () => {
161
+ shown = true;
162
+ if (latest && latest[0] < latest[1])
163
+ draw(latest[0], latest[1]);
164
+ },
165
+ done: () => {
166
+ if (line)
167
+ done(line);
168
+ line = null;
169
+ },
170
+ };
171
+ }
138
172
  const done = (line) => {
139
173
  if (node_process_1.default.stdout.isTTY) {
140
174
  line("");
@@ -254,6 +288,23 @@ async function reconcile(folder, options = {}) {
254
288
  return { link: null, baseline: null, behind: null, member: true };
255
289
  }
256
290
  let member = true;
291
+ /*
292
+ The project's versions and lines asked for at the same time as the list
293
+ that says the project is still this account's, rather than after it:
294
+ each is a round trip of a third to half a second from here, and the three
295
+ in a row were a second of every save. If the project has gone, these two
296
+ are refused and the error below says why.
297
+ */
298
+ const knownId = link?.repositoryId ?? options.adopt?.id;
299
+ const downloader = new download_js_1.Downloader(config_js_1.credentials);
300
+ const early = knownId
301
+ ? {
302
+ versions: downloader.versions(knownId),
303
+ lines: new tracks_js_1.Tracks(config_js_1.credentials).list(knownId),
304
+ }
305
+ : null;
306
+ early?.versions.catch(() => undefined);
307
+ early?.lines.catch(() => undefined);
257
308
  let project = link
258
309
  ? (await (0, api_js_2.projects)()).find((candidate) => candidate.id === link.repositoryId)
259
310
  : options.adopt;
@@ -291,8 +342,7 @@ async function reconcile(folder, options = {}) {
291
342
  // Nothing saved on the account, so everything here is outstanding.
292
343
  return { link: link ?? null, baseline: null, behind: null, member };
293
344
  }
294
- const downloader = new download_js_1.Downloader(config_js_1.credentials);
295
- const all = await downloader.versions(project.id);
345
+ const all = await (early && project.id === knownId ? early.versions : downloader.versions(project.id));
296
346
  /*
297
347
  The head of this folder's line, not the newest version in the project.
298
348
 
@@ -302,7 +352,7 @@ async function reconcile(folder, options = {}) {
302
352
  v42 is not on the line it was saving to. fetchInto learned the same thing.
303
353
  */
304
354
  const lineName = link?.track ?? project.defaultBranch ?? "main";
305
- const line = (await new tracks_js_1.Tracks(config_js_1.credentials).list(project.id)).find((candidate) => candidate.kind === "line" && candidate.name === lineName);
355
+ const line = (await (early && project.id === knownId ? early.lines : new tracks_js_1.Tracks(config_js_1.credentials).list(project.id))).find((candidate) => candidate.kind === "line" && candidate.name === lineName);
306
356
  const latest = (line?.headVersionId && all.find((version) => version.id === line.headVersionId)) ||
307
357
  all[0];
308
358
  if (!latest)
@@ -392,6 +442,42 @@ async function commandSignOut() {
392
442
  console.log("Signed out on this machine.");
393
443
  return 0;
394
444
  }
445
+ /** How big a machine this account's runs get (backend/src/runner_power.ts), shown or changed. */
446
+ async function commandPower(parsed) {
447
+ const asked = parsed.positional[0]?.toLowerCase();
448
+ if (asked && !["standard", "fast", "max"].includes(asked)) {
449
+ console.error(red(`There is no runner power called "${parsed.positional[0]}". Choose standard, fast or max.`));
450
+ return 1;
451
+ }
452
+ const state = asked
453
+ ? await (0, api_js_2.callApi)("/v1/account/runner-power", { method: "PUT", body: { power: asked } })
454
+ : await (0, api_js_2.callApi)("/v1/account/runner-power");
455
+ if (hasFlag(parsed, "json")) {
456
+ console.log(JSON.stringify(state));
457
+ return 0;
458
+ }
459
+ const credits = (value) => String(Math.round(value * 10) / 10);
460
+ const current = state.levels.find((level) => level.id === state.effective) ?? state.levels[0];
461
+ if (current) {
462
+ console.log(`${asked ? "Runner power is now" : "Runner power:"} ${accent(current.label)} · ` +
463
+ `${current.vcpu} CPUs · ${current.memoryGiB} GB · ${credits(current.creditsPerMinute)} credits a minute`);
464
+ }
465
+ if (state.power !== state.effective) {
466
+ console.log(dim(`You chose ${state.power}; free and trial accounts run on Standard.`));
467
+ }
468
+ console.log("");
469
+ const width = Math.max(...state.levels.map((level) => level.id.length));
470
+ for (const level of state.levels) {
471
+ const mark = level.id === state.effective ? accent("●") : " ";
472
+ const machine = `${level.vcpu} CPUs · ${level.memoryGiB} GB`;
473
+ console.log(` ${mark} ${level.id.padEnd(width)} ${machine.padEnd(16)} ${credits(level.creditsPerMinute)} credits a minute`);
474
+ }
475
+ console.log("");
476
+ console.log(dim(state.available
477
+ ? "Change it with cbx power standard|fast|max. A run already going keeps its machine."
478
+ : "More runner power comes with a paid plan; free and trial accounts run on Standard."));
479
+ return 0;
480
+ }
395
481
  async function commandWhoami() {
396
482
  const account = await (0, api_js_2.whoami)();
397
483
  console.log(`${bold(account.displayName)} <${account.email}> · ${account.plan}`);
@@ -509,7 +595,7 @@ async function commandStatus(parsed) {
509
595
  the folder each time it ran. What it learns is kept for the next run.
510
596
  */
511
597
  const knownDigests = link?.repositoryId
512
- ? await (0, config_js_1.readDigests)(link.repositoryId)
598
+ ? await (0, config_js_1.readDigests)(link.repositoryId, folder)
513
599
  : new Map();
514
600
  let learned = 0;
515
601
  const remember = knownDigests.set.bind(knownDigests);
@@ -517,9 +603,12 @@ async function commandStatus(parsed) {
517
603
  learned += 1;
518
604
  return remember(key, value);
519
605
  };
520
- const found = await (0, worktree_js_1.changedFiles)(folder, rules, baseline, "synchronize", knownDigests, undefined, false);
606
+ const reading = readingProgress();
607
+ reading.show();
608
+ const found = await (0, worktree_js_1.changedFiles)(folder, rules, baseline, "synchronize", knownDigests, undefined, false, undefined, reading.report);
609
+ reading.done();
521
610
  if (learned && link?.repositoryId)
522
- await (0, config_js_1.writeDigests)(link.repositoryId, knownDigests);
611
+ await (0, config_js_1.writeDigests)(link.repositoryId, knownDigests, folder);
523
612
  const gone = found.filter((file) => file.deleted);
524
613
  const files = found.filter((file) => !file.deleted);
525
614
  // Tells the project's Actions page what this machine's folder holds; never delays or fails status.
@@ -797,6 +886,15 @@ async function digestOfFile(full) {
797
886
  return null;
798
887
  }
799
888
  }
889
+ /** Whether two path-to-digest maps say the same thing (the early scan's baseline and reconcile's). */
890
+ function sameEntries(left, right) {
891
+ if (!right || left.size !== right.size)
892
+ return false;
893
+ for (const [file, digest] of left)
894
+ if (right.get(file) !== digest)
895
+ return false;
896
+ return true;
897
+ }
800
898
  /**
801
899
  * Say so when files deleted here are still in the saved version.
802
900
  *
@@ -804,12 +902,15 @@ async function digestOfFile(full) {
804
902
  * lives on in every save after it until somebody passes --sync. `status`
805
903
  * already said this; `submit` did not, and from Linux a project turned out to
806
904
  * carry a stale copy of a whole app at its root for weeks. Counted from the
807
- * folder's record of what it holds, so it costs a stat per recorded file.
905
+ * folder's record of what it holds. Given what the scan found (`seen`), only
906
+ * the saved files the scan did not find are looked for on disk — one that an
907
+ * ignore rule now keeps out is still there, not deleted. Without it, a stat
908
+ * per recorded file: two seconds of every save of a 14,000-file project.
808
909
  */
809
- function noteKeptDeletions(folder, baseline, syncing) {
910
+ function noteKeptDeletions(folder, baseline, syncing, seen) {
810
911
  if (syncing || !baseline?.size)
811
912
  return 0;
812
- const gone = [...baseline.keys()].filter((file) => !(0, node_fs_1.existsSync)(node_path_1.default.join(folder, ...file.split("/"))));
913
+ const gone = [...baseline.keys()].filter((file) => !seen?.has(file) && !(0, node_fs_1.existsSync)(node_path_1.default.join(folder, ...file.split("/"))));
813
914
  if (!gone.length)
814
915
  return 0;
815
916
  console.log(dim(`${gone.length} file${gone.length === 1 ? "" : "s"} deleted here ${gone.length === 1 ? "is" : "are"} still in the saved version` +
@@ -876,10 +977,37 @@ async function commandSubmit(parsed) {
876
977
  else
877
978
  parsed.flags.set("name", chosen.name);
878
979
  }
980
+ /* Made before the scan so its capability check overlaps it (prefetchCapabilities). */
981
+ const firstUploader = new upload_js_1.Uploader(config_js_1.credentials);
982
+ firstUploader.prefetchCapabilities();
983
+ /*
984
+ A linked folder's scan, started while the service is asked about the
985
+ project rather than after. The baseline it compares against is this
986
+ folder's own record, which is what reconcile answers with when the folder
987
+ is level; when it answers otherwise, or with another project, this is
988
+ dropped and the scan below runs as it always has. Nothing is written into
989
+ a linked folder before that scan (only a first save adds a LICENSE), so
990
+ starting early changes what it sees by nothing but the moment.
991
+ */
992
+ /* Shown only when a folder has to read a lot to find its changes (readingProgress). */
993
+ const reading = readingProgress();
994
+ const linkedNow = adopt || hasFlag(parsed, "allow-ignored") ? null : await (0, config_js_1.readLink)(folder).catch(() => null);
995
+ const earlyScan = linkedNow?.repositoryId && linkedNow.manifest
996
+ ? (async () => {
997
+ const rules = await (0, worktree_js_1.readRules)(folder);
998
+ const knownDigests = await (0, config_js_1.readDigests)(linkedNow.repositoryId, folder);
999
+ const baseline = new Map(Object.entries(linkedNow.local ?? linkedNow.manifest));
1000
+ const seen = new Set();
1001
+ const listing = { listed: 0, total: 0, sizes: [] };
1002
+ const files = await (0, worktree_js_1.changedFiles)(folder, rules, baseline, hasFlag(parsed, "sync") ? "synchronize" : "add-and-update", knownDigests, listing, true, seen, reading.report);
1003
+ return { repositoryId: linkedNow.repositoryId, rules, knownDigests, baseline, seen, listing, files };
1004
+ })().catch(() => null)
1005
+ : null;
879
1006
  const { link, baseline, behind, member } = await reconcile(folder, {
880
1007
  ...(adopt ? { adopt } : {}),
881
1008
  persist: !dryRun,
882
1009
  });
1010
+ reading.show();
883
1011
  /*
884
1012
  Somebody else's project, cloned from its public page. Reading and
885
1013
  fetching are fine; saving into it is not this account's to do, and the
@@ -963,10 +1091,35 @@ async function commandSubmit(parsed) {
963
1091
  same map serves both — `changedFiles` fills it in place, so what the scan
964
1092
  learns is what the upload is handed.
965
1093
  */
966
- const knownDigests = link?.repositoryId
967
- ? await (0, config_js_1.readDigests)(link.repositoryId)
968
- : new Map();
969
- const files = await (0, worktree_js_1.changedFiles)(folder, rules, baseline, hasFlag(parsed, "sync") ? "synchronize" : "add-and-update", knownDigests);
1094
+ const early = earlyScan ? await earlyScan : null;
1095
+ const reuse = early &&
1096
+ !importing &&
1097
+ link?.repositoryId === early.repositoryId &&
1098
+ early.rules.shared === rules.shared &&
1099
+ early.rules.local === rules.local &&
1100
+ sameEntries(early.baseline, baseline)
1101
+ ? early
1102
+ : null;
1103
+ const knownDigests = reuse
1104
+ ? reuse.knownDigests
1105
+ : link?.repositoryId
1106
+ ? await (0, config_js_1.readDigests)(link.repositoryId, folder)
1107
+ : new Map();
1108
+ const seen = reuse ? reuse.seen : new Set();
1109
+ const listing = reuse ? reuse.listing : { listed: 0, total: 0, sizes: [] };
1110
+ const recordedBefore = new Map(knownDigests);
1111
+ const files = reuse
1112
+ ? reuse.files
1113
+ : await (0, worktree_js_1.changedFiles)(folder, rules, baseline, hasFlag(parsed, "sync") ? "synchronize" : "add-and-update", knownDigests, listing, true, seen, reading.report);
1114
+ reading.done();
1115
+ /*
1116
+ What the scan read, kept now rather than after the save. A save that ends
1117
+ on a merge, a refusal or an error returned before the record was written,
1118
+ so a folder behind its project read every file again on every attempt.
1119
+ */
1120
+ if (link?.repositoryId && [...knownDigests].some(([file, known]) => recordedBefore.get(file)?.sha256 !== known.sha256 || recordedBefore.get(file)?.mtimeMs !== known.mtimeMs)) {
1121
+ await (0, config_js_1.writeDigests)(link.repositoryId, knownDigests, folder);
1122
+ }
970
1123
  /*
971
1124
  An upgraded folder with no materialisation record and something that
972
1125
  differs from its recorded version is ambiguous in the one way that
@@ -1002,10 +1155,10 @@ async function commandSubmit(parsed) {
1002
1155
  deleting a folder from a copy of the Cheat Engine sources.
1003
1156
  */
1004
1157
  if (!hasFlag(parsed, "sync")) {
1005
- const kept = [...(baseline?.keys() ?? [])].some((file) => !(0, node_fs_1.existsSync)(node_path_1.default.join(folder, ...file.split("/"))));
1158
+ const kept = [...(baseline?.keys() ?? [])].some((file) => !seen.has(file) && !(0, node_fs_1.existsSync)(node_path_1.default.join(folder, ...file.split("/"))));
1006
1159
  if (kept) {
1007
1160
  console.log("Nothing new to submit.");
1008
- noteKeptDeletions(folder, baseline, false);
1161
+ noteKeptDeletions(folder, baseline, false, seen);
1009
1162
  return 0;
1010
1163
  }
1011
1164
  }
@@ -1142,7 +1295,7 @@ Pass ${accent("--allow-secrets")} if these are not real keys.`);
1142
1295
  }
1143
1296
  const line = progressLine();
1144
1297
  const uploadDisplay = new upload_progress_js_1.UploadDisplay();
1145
- let uploader = new upload_js_1.Uploader(config_js_1.credentials);
1298
+ let uploader = firstUploader;
1146
1299
  /*
1147
1300
  Built by the shared description, so this and the git remote helper cannot
1148
1301
  drift. They already had: the helper listed deletions in `deletions` alone
@@ -1201,6 +1354,12 @@ Pass ${accent("--allow-secrets")} if these are not real keys.`);
1201
1354
  ...(hasFlag(parsed, "allow-secrets") ? { allowSecrets: true } : {}),
1202
1355
  ...(link ? { known: link.local ?? link.manifest ?? {} } : {}),
1203
1356
  });
1357
+ /* This machine's check-in, recorded with the save when the service can (machine.ts). */
1358
+ if (link?.repositoryId && !node_process_1.default.env.CODEROOK_NO_PRESENCE) {
1359
+ Object.assign(uploadRequest, {
1360
+ presence: await (0, machine_js_1.checkInBody)({ kind: "folder", folder, track: link.track ?? null, changedFiles: 0 }),
1361
+ });
1362
+ }
1204
1363
  /*
1205
1364
  Whether this is walking into a merge, asked before anything is sent.
1206
1365
 
@@ -1211,9 +1370,26 @@ Pass ${accent("--allow-secrets")} if these are not real keys.`);
1211
1370
  publish lands and the publish path decides for real, so this says what is
1212
1371
  coming and gets out of the way.
1213
1372
  */
1214
- if (link?.repositoryId && link.baseVersionId) {
1215
- try {
1216
- const ahead = await (0, api_js_1.collisionCheck)(link.repositoryId, link.baseVersionId, files.filter((file) => !file.deleted).map((file) => file.path));
1373
+ /*
1374
+ Asked while the upload is planned, not before: it is a round trip of its
1375
+ own, and nothing in the plan depends on it. Said before anything is sent.
1376
+ */
1377
+ const aheadAnswer = link?.repositoryId && link.baseVersionId
1378
+ ? (0, api_js_1.collisionCheck)(link.repositoryId, link.baseVersionId, files.filter((file) => !file.deleted).map((file) => file.path)).catch(() => null)
1379
+ : Promise.resolve(null);
1380
+ let aheadSaid = false;
1381
+ const sayAhead = async () => {
1382
+ if (aheadSaid)
1383
+ return;
1384
+ aheadSaid = true;
1385
+ const ahead = await aheadAnswer;
1386
+ /*
1387
+ Advice that cannot be fetched is not a reason to refuse a publish.
1388
+ The service checks properly at the point it matters.
1389
+ */
1390
+ if (!ahead)
1391
+ return;
1392
+ {
1217
1393
  if (ahead.collidingPaths.length) {
1218
1394
  /*
1219
1395
  "1 of your file is" — the plural was on the wrong noun. It is one
@@ -1248,13 +1424,7 @@ Pass ${accent("--allow-secrets")} if these are not real keys.`);
1248
1424
  console.log("");
1249
1425
  }
1250
1426
  }
1251
- catch {
1252
- /*
1253
- Advice that cannot be fetched is not a reason to refuse a publish.
1254
- The service checks properly at the point it matters.
1255
- */
1256
- }
1257
- }
1427
+ };
1258
1428
  let result;
1259
1429
  /*
1260
1430
  How long to wait before picking a dropped upload up again by itself.
@@ -1280,6 +1450,17 @@ Pass ${accent("--allow-secrets")} if these are not real keys.`);
1280
1450
  if (createdRepositoryId && !uploadRequest.repositoryId) {
1281
1451
  Object.assign(uploadRequest, { repositoryId: createdRepositoryId });
1282
1452
  }
1453
+ /*
1454
+ The upload uses this command's own walk of the folder rather than
1455
+ walking it again in each of its two passes (UploadRequest.survey), and a
1456
+ save that goes as one request does not wait on a separate price check
1457
+ first (oneRoundTrip). A dry run still asks the service, so what it shows
1458
+ is the service's answer.
1459
+ */
1460
+ if (!importing)
1461
+ uploadRequest.survey = listing.sizes;
1462
+ if (!dryRun)
1463
+ uploadRequest.oneRoundTrip = true;
1283
1464
  const plan = await uploader.plan(uploadRequest, (progress) => {
1284
1465
  line(` ${track(progress.percent)} ${String(progress.percent).padStart(3)}% ` +
1285
1466
  `${"plan".padEnd(7)} ${progress.files}/${progress.totalFiles} ` +
@@ -1288,12 +1469,17 @@ Pass ${accent("--allow-secrets")} if these are not real keys.`);
1288
1469
  done(line);
1289
1470
  if (plan.repositoryCreated)
1290
1471
  createdRepositoryId = plan.repositoryId;
1291
- console.log(`${accent("Upload plan")} ${bytes(plan.sourceBytes)} selected → ` +
1292
- `${bytes(plan.compactedBytes)} compacted; ${bytes(plan.chargeableBytes)} new storage.`);
1293
- console.log(plan.allowance.exempt
1294
- ? dim("No monthly upload steps on this plan; the storage limit is the only one.")
1295
- : dim(`Monthly stage ${plan.allowance.stage}: ${plan.allowance.unlockedPercent}% unlocked, ` +
1296
- `${bytes(plan.allowance.remainingBytes)} remains after this reservation.`));
1472
+ console.log(plan.estimated
1473
+ ? `${accent("Upload plan")} ${bytes(plan.sourceBytes)} selected; ${bytes(plan.chargeableBytes)} of changes to send.`
1474
+ : `${accent("Upload plan")} ${bytes(plan.sourceBytes)} selected → ` +
1475
+ `${bytes(plan.compactedBytes)} compacted; ${bytes(plan.chargeableBytes)} new storage.`);
1476
+ console.log(plan.estimated
1477
+ ? dim("Storage and the monthly allowance are checked as the save arrives.")
1478
+ : plan.allowance.exempt
1479
+ ? dim("No monthly upload steps on this plan; the storage limit is the only one.")
1480
+ : dim(`Monthly stage ${plan.allowance.stage}: ${plan.allowance.unlockedPercent}% unlocked, ` +
1481
+ `${bytes(plan.allowance.remainingBytes)} remains after this reservation.`));
1482
+ await sayAhead();
1297
1483
  if (dryRun) {
1298
1484
  await uploader.cancelPlan(plan, true);
1299
1485
  const going = files.filter((file) => !file.deleted);
@@ -1306,12 +1492,14 @@ Pass ${accent("--allow-secrets")} if these are not real keys.`);
1306
1492
  for (const file of removing)
1307
1493
  console.log(` ${red("deleted")} ${file.path}`);
1308
1494
  }
1309
- noteKeptDeletions(folder, baseline, hasFlag(parsed, "sync"));
1495
+ noteKeptDeletions(folder, baseline, hasFlag(parsed, "sync"), seen);
1310
1496
  console.log("Nothing was uploaded and no Version was created.");
1311
1497
  return 0;
1312
1498
  }
1313
1499
  result = await uploader.execute(uploadRequest, plan, (progress) => uploadDisplay.report(progress));
1314
1500
  uploadDisplay.done();
1501
+ if (result.presenceRecorded)
1502
+ (0, machine_js_1.markCheckedIn)(result.repositoryId);
1315
1503
  break;
1316
1504
  }
1317
1505
  catch (error) {
@@ -1362,6 +1550,16 @@ The connection failed: ${text}`));
1362
1550
  }
1363
1551
  }
1364
1552
  done(line);
1553
+ /*
1554
+ What this save hashed, kept for the next one, before anything below can
1555
+ return (a save kept on a merge track used to skip it).
1556
+
1557
+ Merged rather than replaced: `digestsTaken` holds only the files actually
1558
+ read this time, and everything served from the existing record has to
1559
+ survive or the next save reads it all again — which is precisely the cost
1560
+ this exists to avoid.
1561
+ */
1562
+ await (0, config_js_1.writeDigests)(result.repositoryId, new Map([...knownDigests, ...uploader.digestsTaken()]), folder);
1365
1563
  if (result.mergeTrack) {
1366
1564
  /*
1367
1565
  The upload is complete and kept, but the project has not changed —
@@ -1427,15 +1625,6 @@ The connection failed: ${text}`));
1427
1625
  */
1428
1626
  ...(link?.track ? { track: link.track } : {}),
1429
1627
  });
1430
- /*
1431
- What this save hashed, kept for the next one.
1432
-
1433
- Merged rather than replaced: `digestsTaken` holds only the files actually
1434
- read this time, and everything served from the existing record has to
1435
- survive or the next save reads it all again — which is precisely the cost
1436
- this exists to avoid.
1437
- */
1438
- await (0, config_js_1.writeDigests)(result.repositoryId, new Map([...knownDigests, ...uploader.digestsTaken()]));
1439
1628
  if (result.repeated) {
1440
1629
  console.log(`Already saved as ${accent(`v${result.sequence}`)} by an earlier attempt;` +
1441
1630
  ` nothing was sent again.`);
@@ -1460,7 +1649,7 @@ The connection failed: ${text}`));
1460
1649
  command does not do.
1461
1650
  */
1462
1651
  ` · the save holds ${bytes(result.sourceBytes)}`);
1463
- noteKeptDeletions(folder, baseline, hasFlag(parsed, "sync"));
1652
+ noteKeptDeletions(folder, baseline, hasFlag(parsed, "sync"), seen);
1464
1653
  noteGitRoute(folder, link?.slug ?? adopt?.slug ?? (0, folder_match_js_1.slugFor)(flagText(parsed, "name") ?? node_path_1.default.basename(folder)));
1465
1654
  /*
1466
1655
  Where the time went, when asked for.
@@ -2363,6 +2552,7 @@ const SPECS = [
2363
2552
  options: [
2364
2553
  { flags: "--token <value>", description: "supply it instead of being asked" },
2365
2554
  ],
2555
+ examples: ["cbx sign-in", "cbx sign-in --token \"$CODEROOK_TOKEN\""],
2366
2556
  run: commandSignIn,
2367
2557
  },
2368
2558
  {
@@ -2370,6 +2560,8 @@ const SPECS = [
2370
2560
  group: "Getting started",
2371
2561
  summary: "who this machine is signed in as",
2372
2562
  usage: "whoami",
2563
+ detail: "Prints the account this machine's token belongs to, its email and its plan. Worth a look before a save, to be sure which account it goes to.",
2564
+ examples: ["cbx whoami"],
2373
2565
  run: () => commandWhoami(),
2374
2566
  },
2375
2567
  {
@@ -2378,6 +2570,8 @@ const SPECS = [
2378
2570
  group: "Getting started",
2379
2571
  summary: "forget the token on this machine",
2380
2572
  usage: "sign-out",
2573
+ detail: "Removes the stored token from this machine. Folders stay linked to their projects. The token itself keeps working anywhere else it is used until you revoke it with cbx tokens --revoke.",
2574
+ examples: ["cbx sign-out"],
2381
2575
  run: commandSignOut,
2382
2576
  },
2383
2577
  {
@@ -2389,6 +2583,7 @@ const SPECS = [
2389
2583
  "changed. Says nothing about other people's work — use `merges` for that.\n\n" +
2390
2584
  "In a folder with a history of its own (see `cbx init`), compares\n" +
2391
2585
  "against the last local save instead.",
2586
+ examples: ["cbx status", "cbx status ../other-game"],
2392
2587
  run: (0, local_commands_js_1.localFirst)(local_commands_js_1.localStatus, commandStatus, (parsed) => folderFor(parsed)),
2393
2588
  },
2394
2589
  {
@@ -2469,6 +2664,7 @@ const SPECS = [
2469
2664
  { flags: "--project <name>", description: "which project" },
2470
2665
  ],
2471
2666
  examples: ["cbx diff", "cbx diff 12", "cbx diff 11 12 --name-only", "cbx diff main~1 main"],
2667
+ arguments: { "[from]": "a save to compare against: 12, v12, a line (main) or main~1; left out, the save this folder is on", "[to]": "a second save; given, the two saves are compared with each other instead of with this folder" },
2472
2668
  run: (0, local_commands_js_1.localFirst)(local_commands_js_1.localDiff, diff_command_js_1.commandDiff),
2473
2669
  },
2474
2670
  {
@@ -2518,6 +2714,7 @@ const SPECS = [
2518
2714
  { flags: "--notes", description: "on CodeRook: print what each one says about itself" },
2519
2715
  ],
2520
2716
  examples: ["cbx log", "cbx log feature --limit 5"],
2717
+ arguments: { "[from]": "a line or a save to start from; left out, the line this folder is on" },
2521
2718
  run: (0, local_commands_js_1.localFirst)(local_commands_js_1.localLog, project_commands_js_1.commandVersions),
2522
2719
  },
2523
2720
  {
@@ -2681,6 +2878,7 @@ const SPECS = [
2681
2878
  { flags: "-n, --new", description: "start this line from where the project is now" },
2682
2879
  ],
2683
2880
  examples: ["cbx track", "cbx track spike --new", "cbx track main"],
2881
+ arguments: { "[name]": "the line to save to from now on; left out, shows the one in use" },
2684
2882
  run: track_commands_js_1.commandTrack,
2685
2883
  },
2686
2884
  {
@@ -2704,6 +2902,8 @@ const SPECS = [
2704
2902
  options: [
2705
2903
  { flags: "--replace", description: "make it an exact copy, discarding local changes" },
2706
2904
  ],
2905
+ detail: "Fetches what has been saved to the project since this folder last saved or fetched. Files you changed here that nobody else changed are kept as they are. --replace makes the folder an exact copy of the saved version instead, throwing away changes made here.",
2906
+ examples: ["cbx get", "cbx get ../other-game", "cbx get --replace"],
2707
2907
  run: announcing(commandGet, false),
2708
2908
  },
2709
2909
  {
@@ -2718,6 +2918,7 @@ const SPECS = [
2718
2918
  },
2719
2919
  ],
2720
2920
  examples: ["cbx clone my-project", "cbx clone my-project --track spike"],
2921
+ detail: "Makes a new folder, fetches the project's newest version into it and links the folder to the project, so status, submit and get work there straight away.",
2721
2922
  run: commandClone,
2722
2923
  },
2723
2924
  {
@@ -2748,6 +2949,7 @@ const SPECS = [
2748
2949
  },
2749
2950
  ],
2750
2951
  examples: ["cbx licence", "cbx licence MIT", "cbx licence Apache-2.0"],
2952
+ arguments: { "[name]": "a licence as the list names it (MIT, Apache-2.0); left out, lists them" },
2751
2953
  run: licence_commands_js_1.commandLicence,
2752
2954
  },
2753
2955
  {
@@ -2774,6 +2976,7 @@ const SPECS = [
2774
2976
  description: "add a ready-made set of rules; `list` shows all 309 of them",
2775
2977
  },
2776
2978
  ],
2979
+ examples: ["cbx ignore", "cbx ignore --init", "cbx ignore --suggest --apply", "cbx ignore --template list", "cbx ignore --template Unity"],
2777
2980
  run: (parsed) =>
2778
2981
  /*
2779
2982
  Two commands under one name, because they are one question. Somebody
@@ -2790,6 +2993,8 @@ const SPECS = [
2790
2993
  group: "Getting started",
2791
2994
  summary: "every project on your account",
2792
2995
  usage: "projects",
2996
+ detail: "One line per project on your account: its name, how many saves it has, how many files, how much it stores and who can see it.",
2997
+ examples: ["cbx projects"],
2793
2998
  run: () => commandProjects(),
2794
2999
  },
2795
3000
  {
@@ -2852,6 +3057,7 @@ const SPECS = [
2852
3057
  { flags: "--interval <seconds>", description: "watch: how often to look (default 20, at least 5)" },
2853
3058
  ],
2854
3059
  examples: ["cbx workspace open my-project --name \"Laptop work\" --key laptop-open-001", "cbx workspace list my-project", "cbx workspace assign my-project <draft> --name Laptop", "cbx workspace checkout my-project <draft>", "cbx workspace push --save -m \"Fix the export dialog\"", "cbx workspace", "cbx workspace say my-project <draft> -m \"Tests updated\" --as GrokBot", "cbx workspace thread my-project <draft> --unread", "cbx workspace watch my-project --as GrokBot --json", "cbx workspace put my-project <draft> website/app/page.tsx website/public/og.png", "cbx workspace starter my-project --apply", "cbx workspace review my-project <draft> --ok -m \"Matches the concept\""],
3060
+ arguments: { "[job]": "a job's name inside a run, for logs and cancel" },
2855
3061
  run: workspace_command_js_1.commandWorkspace,
2856
3062
  },
2857
3063
  {
@@ -2910,6 +3116,7 @@ const SPECS = [
2910
3116
  "cbx visibility unlisted my-project --yes",
2911
3117
  "cbx visibility private my-project",
2912
3118
  ],
3119
+ arguments: { "[level]": "public, unlisted (link only) or private; left out, shows the current level" },
2913
3120
  run: project_commands_js_1.commandVisibility,
2914
3121
  },
2915
3122
  {
@@ -3283,6 +3490,7 @@ const SPECS = [
3283
3490
  'cbx issue rules add welcome -m "Thanks — we read every report."',
3284
3491
  "cbx issue rules off 2",
3285
3492
  ],
3493
+ arguments: { "<number>": "the issue's number (12)", "<name>": "a label's name", "<kind>": "the kind of rule to add (auto-label, welcome)", "<n>": "the rule's number, as cbx issue rules lists it" },
3286
3494
  run: issue_command_js_1.commandIssue,
3287
3495
  },
3288
3496
  {
@@ -3295,6 +3503,7 @@ const SPECS = [
3295
3503
  "downloads), downloads public (the source stays private) or private.\n" +
3296
3504
  "For a public project it also prints the addresses an app or a script\n" +
3297
3505
  "reads them from, which need no account.",
3506
+ examples: ["cbx releases", "cbx releases my-game"],
3298
3507
  run: service_commands_js_1.commandReleases,
3299
3508
  },
3300
3509
  {
@@ -3505,6 +3714,7 @@ const SPECS = [
3505
3714
  "cbx labels add urgent #e0574a",
3506
3715
  "cbx labels remove shipped",
3507
3716
  ],
3717
+ arguments: { "[name]": "the label's name (shipped)", "[colour]": "a colour, by name (green) or as hex (#e0574a)" },
3508
3718
  run: version_commands_js_1.commandLabels,
3509
3719
  },
3510
3720
  {
@@ -3516,6 +3726,7 @@ const SPECS = [
3516
3726
  detail: "A project can be set to hold pushes from anyone below admin until an\n" +
3517
3727
  "admin accepts them. Those versions are real and stored — they are just\n" +
3518
3728
  "not the current version, and not on the public page.",
3729
+ examples: ["cbx held", "cbx held my-game"],
3519
3730
  run: version_commands_js_1.commandHeld,
3520
3731
  },
3521
3732
  {
@@ -3536,6 +3747,7 @@ const SPECS = [
3536
3747
  "cbx review 41 --approve",
3537
3748
  'cbx review 41 --decline --note "wrong branch"',
3538
3749
  ],
3750
+ detail: "A project can hold saves from people below admin until an admin decides; cbx held lists them. --approve makes the save the project's current version. --decline turns it down, and --note says why.",
3539
3751
  run: version_commands_js_1.commandReview,
3540
3752
  },
3541
3753
  {
@@ -3555,6 +3767,7 @@ const SPECS = [
3555
3767
  { flags: "--yes", description: "confirm; without it nothing happens" },
3556
3768
  { flags: "--reason <text>", description: "recorded against the gap" },
3557
3769
  ],
3770
+ examples: ["cbx take-down 12 --yes --reason \"API key in config.json\""],
3558
3771
  run: version_commands_js_1.commandTakeDown,
3559
3772
  },
3560
3773
  {
@@ -3596,6 +3809,7 @@ const SPECS = [
3596
3809
  "cbx release 1.4.0 --downloads public",
3597
3810
  "cbx release --downloads private --version 41",
3598
3811
  ],
3812
+ arguments: { "<name>": "the release's name (v1.0, 2.1.0-beta.1)" },
3599
3813
  run: service_commands_js_1.commandRelease,
3600
3814
  },
3601
3815
  {
@@ -3652,6 +3866,7 @@ const SPECS = [
3652
3866
  "cbx security policy",
3653
3867
  "cbx security policy --on --text SECURITY.md",
3654
3868
  ],
3869
+ arguments: { "<owner/project>": "the project to report to, as owner/name", "<n>": "the report's number, after S- (S-3)" },
3655
3870
  run: community_command_js_1.commandSecurity,
3656
3871
  },
3657
3872
  {
@@ -3864,6 +4079,7 @@ const SPECS = [
3864
4079
  "service keeps deleted projects for 30 days before reclaiming the\n" +
3865
4080
  "storage, so a mistake made today is recoverable this month.",
3866
4081
  options: [{ flags: "--yes", description: "skip the confirmation" }],
4082
+ examples: ["cbx delete old-prototype"],
3867
4083
  run: service_commands_js_1.commandDelete,
3868
4084
  },
3869
4085
  {
@@ -3905,6 +4121,8 @@ const SPECS = [
3905
4121
  { flags: "--email [off]", description: "include it in the daily email" },
3906
4122
  { flags: "--discussions <all|off>", description: "whether workspace messages reach your notifications" },
3907
4123
  ],
4124
+ detail: "With no options, shows what reaches you about the project. --level chooses which events notify you. --email adds them to the daily email; --email off takes them out again.",
4125
+ examples: ["cbx watch", "cbx watch my-game --level releases", "cbx watch my-game --email", "cbx watch my-game --email off"],
3908
4126
  run: service_commands_js_1.commandWatch,
3909
4127
  },
3910
4128
  {
@@ -3916,6 +4134,7 @@ const SPECS = [
3916
4134
  "how you find one that is no longer needed. Create new ones on the\n" +
3917
4135
  "website; they are only shown once.",
3918
4136
  options: [{ flags: "--revoke <id>", description: "stop one working now" }],
4137
+ examples: ["cbx tokens", "cbx tokens --revoke <id>"],
3919
4138
  run: service_commands_js_1.commandTokens,
3920
4139
  },
3921
4140
  {
@@ -3934,6 +4153,7 @@ const SPECS = [
3934
4153
  "Files both sides changed are combined line by line where they can be;\n" +
3935
4154
  "the rest wait for a decision in cbx merge. \"Fixes #12\" in the title or\n" +
3936
4155
  "body closes issue 12 when the proposal lands.",
4156
+ examples: ["cbx propose -m \"New pathfinding\"", "cbx propose -m \"Fixes #12: crash on load\" --body \"Guards the empty save case\"", "cbx propose -m \"Release prep\" --into release"],
3937
4157
  run: commandPropose,
3938
4158
  },
3939
4159
  {
@@ -3942,6 +4162,8 @@ const SPECS = [
3942
4162
  summary: "open proposals on this project",
3943
4163
  usage: "proposals [--all] [folder]",
3944
4164
  options: [{ flags: "--all", description: "include merged and cancelled ones" }],
4165
+ detail: "Lists the proposals on the project this folder is linked to: each one's reference, the line it comes from and goes to, its title, and how many files still need a decision. Run cbx merge <reference> to look at one.",
4166
+ examples: ["cbx proposals", "cbx proposals --all"],
3945
4167
  run: commandProposals,
3946
4168
  },
3947
4169
  {
@@ -3951,6 +4173,7 @@ const SPECS = [
3951
4173
  usage: "merges [folder]",
3952
4174
  detail: "Both merge commands read the project this folder is linked to, so run\n" +
3953
4175
  "them from a working copy — or name one.",
4176
+ examples: ["cbx merges", "cbx merges ../other-game"],
3954
4177
  run: commandMerges,
3955
4178
  },
3956
4179
  {
@@ -3975,6 +4198,7 @@ const SPECS = [
3975
4198
  { flags: "--cancel", description: "call the merge off; your upload stays stored" },
3976
4199
  { flags: "--ask <usernames>", description: "ask people to review it, comma separated" },
3977
4200
  ],
4201
+ examples: ["cbx merge spike", "cbx merge M-3", "cbx merge M-3 --path src/save.c --mine", "cbx merge M-3 --cancel"],
3978
4202
  run: (0, local_commands_js_1.localFirst)(local_commands_js_1.localMerge, commandMerge),
3979
4203
  },
3980
4204
  {
@@ -3982,6 +4206,8 @@ const SPECS = [
3982
4206
  group: "Mods and bundles",
3983
4207
  summary: "pack the project as a .cbx",
3984
4208
  usage: "bundle [folder] [out]",
4209
+ detail: "Packs the folder's files into one .cbx file you can copy, archive or send to somebody without an account. What the ignore rules leave out stays out. Unpack it with cbx unbundle.",
4210
+ examples: ["cbx bundle", "cbx bundle . ../backups/my-game.cbx"],
3985
4211
  run: commandBundle,
3986
4212
  },
3987
4213
  {
@@ -3989,6 +4215,8 @@ const SPECS = [
3989
4215
  group: "Mods and bundles",
3990
4216
  summary: "extract a .cbx",
3991
4217
  usage: "unbundle <file> [dir]",
4218
+ detail: "Unpacks a .cbx made by cbx bundle into a new folder, named after the folder it was made from unless you give one.",
4219
+ examples: ["cbx unbundle my-game.cbx", "cbx unbundle my-game.cbx restored-game"],
3992
4220
  run: commandUnbundle,
3993
4221
  },
3994
4222
  {
@@ -3997,6 +4225,8 @@ const SPECS = [
3997
4225
  summary: "what a .cbx contains",
3998
4226
  usage: "inspect <file>",
3999
4227
  options: [{ flags: "--files", description: "list every file inside" }],
4228
+ detail: "Shows what a .cbx holds without unpacking it. --files lists every file inside.",
4229
+ examples: ["cbx inspect my-game.cbx", "cbx inspect my-game.cbx --files"],
4000
4230
  run: commandInspect,
4001
4231
  },
4002
4232
  {
@@ -4015,6 +4245,21 @@ const SPECS = [
4015
4245
  examples: ["cbx runner my-game --labels windows,signing"],
4016
4246
  run: commandRunner,
4017
4247
  },
4248
+ {
4249
+ name: "power",
4250
+ aliases: ["runner-power"],
4251
+ group: "Actions and builds",
4252
+ summary: "how big a machine your hosted and workspace runs get",
4253
+ usage: "power [standard|fast|max]",
4254
+ detail: "With no level, shows the one your account uses and what each costs. With one, switches to it: the same\n" +
4255
+ "setting as Runner power on the website's Billing page. It applies to hosted and workspace runs on every\n" +
4256
+ "project you pay for. More power finishes sooner and uses credits faster each minute, billed by the second.\n" +
4257
+ "A run already going keeps its machine. Free and trial accounts run on Standard.",
4258
+ arguments: { "[standard|fast|max]": "the level to switch to; left out, shows the one in use and what each costs" },
4259
+ options: [{ flags: "--json", description: "print the levels and your choice as JSON" }],
4260
+ examples: ["cbx power", "cbx power fast", "cbx power standard"],
4261
+ run: commandPower,
4262
+ },
4018
4263
  {
4019
4264
  /*
4020
4265
  The other way to hand this to an assistant is a plugin marketplace,
@@ -4103,6 +4348,8 @@ const SPECS = [
4103
4348
  group: "Getting started",
4104
4349
  summary: "check the service, config and sign-in",
4105
4350
  usage: "doctor",
4351
+ detail: "Prints this cbx's version, where its settings are kept, whether the service answers and which account this machine is signed in as. The first thing to run when something does not work.",
4352
+ examples: ["cbx doctor"],
4106
4353
  run: () => commandDoctor(),
4107
4354
  },
4108
4355
  ];