@caddis/cli 0.4.97 → 0.4.99

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.
Files changed (51) hide show
  1. package/README.md +4 -0
  2. package/bundles/antigravity-plugin/plugin.json +1 -1
  3. package/bundles/antigravity-plugin/repo_hygiene.py +134 -20
  4. package/bundles/antigravity-plugin/scripts/__pycache__/caddis_exit.cpython-311.pyc +0 -0
  5. package/bundles/antigravity-plugin/scripts/__pycache__/caddis_file_lock.cpython-311.pyc +0 -0
  6. package/bundles/antigravity-plugin/scripts/__pycache__/caddis_frontmatter.cpython-311.pyc +0 -0
  7. package/bundles/antigravity-plugin/scripts/__pycache__/caddis_redact.cpython-311.pyc +0 -0
  8. package/bundles/antigravity-plugin/scripts/__pycache__/caddis_roadmap.cpython-311.pyc +0 -0
  9. package/bundles/antigravity-plugin/scripts/__pycache__/caddis_rows.cpython-311.pyc +0 -0
  10. package/bundles/antigravity-plugin/scripts/__pycache__/caddis_status.cpython-311.pyc +0 -0
  11. package/bundles/antigravity-plugin/scripts/__pycache__/caddis_tidy.cpython-311.pyc +0 -0
  12. package/bundles/antigravity-plugin/scripts/__pycache__/caddis_todo.cpython-311.pyc +0 -0
  13. package/bundles/antigravity-plugin/scripts/__pycache__/caddis_workstreams.cpython-311.pyc +0 -0
  14. package/bundles/antigravity-plugin/scripts/__pycache__/caddis_worktree_safety.cpython-311.pyc +0 -0
  15. package/bundles/antigravity-plugin/scripts/caddis_gate.py +18 -1
  16. package/bundles/antigravity-plugin/scripts/caddis_guide.json +2 -2
  17. package/bundles/antigravity-plugin/scripts/caddis_handoff.py +235 -0
  18. package/bundles/antigravity-plugin/scripts/caddis_hub_collect.py +23 -12
  19. package/bundles/antigravity-plugin/scripts/caddis_review.py +12 -0
  20. package/bundles/antigravity-plugin/scripts/caddis_tidy.py +152 -51
  21. package/bundles/antigravity-plugin/scripts/caddis_todo.py +136 -17
  22. package/bundles/antigravity-plugin/scripts/schemas/hub-collect.schema.json +60 -1
  23. package/bundles/antigravity-plugin/scripts/schemas/hub-plans.schema.json +60 -1
  24. package/bundles/antigravity-plugin/scripts/setup_project_ai.py +60 -2
  25. package/bundles/antigravity-plugin/skills/cross-review/SKILL.md +6 -0
  26. package/bundles/antigravity-plugin/skills/handoff/SKILL.md +80 -15
  27. package/bundles/antigravity-plugin/skills/implement/SKILL.md +6 -0
  28. package/bundles/antigravity-plugin/skills/park/SKILL.md +7 -2
  29. package/bundles/antigravity-plugin/skills/pr-merge/SKILL.md +1 -0
  30. package/bundles/antigravity-plugin/skills/ship-pr/SKILL.md +1 -0
  31. package/bundles/manifest.json +2 -2
  32. package/dist/cli.js +451 -170
  33. package/dist/export/assets/export-B3cUoxL1.js +150 -0
  34. package/dist/export/assets/export-DQss44R1.css +1 -0
  35. package/dist/export/index.html +2 -2
  36. package/dist/ui/assets/Activity-D69HiVjS.js +6 -0
  37. package/dist/ui/assets/{Guide-D-lZVEKf.js → Guide-BUXTwb19.js} +1 -1
  38. package/dist/ui/assets/Guide-DTd261-c.css +1 -0
  39. package/dist/ui/assets/RoadmapTab-CjYa5fye.js +31 -0
  40. package/dist/ui/assets/index--fRgH-8i.js +236 -0
  41. package/dist/ui/assets/index-9pdDzLVp.css +1 -0
  42. package/dist/ui/index.html +2 -2
  43. package/package.json +1 -1
  44. package/dist/export/assets/export-B5Lzo-9e.css +0 -1
  45. package/dist/export/assets/export-PF4z_ff4.js +0 -150
  46. package/dist/ui/assets/Activity-DN1XBfsH.js +0 -6
  47. package/dist/ui/assets/Guide-D-Zy4cUT.css +0 -1
  48. package/dist/ui/assets/RoadmapTab-tqQd2sYq.js +0 -31
  49. package/dist/ui/assets/index-CWslZIzV.js +0 -231
  50. package/dist/ui/assets/index-CwgRPpjT.css +0 -1
  51. package/dist/ui/assets/time-D00tu2ZP.js +0 -1
package/dist/cli.js CHANGED
@@ -1209,7 +1209,7 @@ var require_command = __commonJS({
1209
1209
  "use strict";
1210
1210
  var EventEmitter = __require("events").EventEmitter;
1211
1211
  var childProcess = __require("child_process");
1212
- var path26 = __require("path");
1212
+ var path28 = __require("path");
1213
1213
  var fs = __require("fs");
1214
1214
  var process3 = __require("process");
1215
1215
  var { Argument: Argument2, humanReadableArgName } = require_argument();
@@ -2222,9 +2222,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
2222
2222
  let launchWithNode = false;
2223
2223
  const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
2224
2224
  function findFile(baseDir, baseName) {
2225
- const localBin = path26.resolve(baseDir, baseName);
2225
+ const localBin = path28.resolve(baseDir, baseName);
2226
2226
  if (fs.existsSync(localBin)) return localBin;
2227
- if (sourceExt.includes(path26.extname(baseName))) return void 0;
2227
+ if (sourceExt.includes(path28.extname(baseName))) return void 0;
2228
2228
  const foundExt = sourceExt.find(
2229
2229
  (ext) => fs.existsSync(`${localBin}${ext}`)
2230
2230
  );
@@ -2242,17 +2242,17 @@ Expecting one of '${allowedValues.join("', '")}'`);
2242
2242
  } catch {
2243
2243
  resolvedScriptPath = this._scriptPath;
2244
2244
  }
2245
- executableDir = path26.resolve(
2246
- path26.dirname(resolvedScriptPath),
2245
+ executableDir = path28.resolve(
2246
+ path28.dirname(resolvedScriptPath),
2247
2247
  executableDir
2248
2248
  );
2249
2249
  }
2250
2250
  if (executableDir) {
2251
2251
  let localFile = findFile(executableDir, executableFile);
2252
2252
  if (!localFile && !subcommand._executableFile && this._scriptPath) {
2253
- const legacyName = path26.basename(
2253
+ const legacyName = path28.basename(
2254
2254
  this._scriptPath,
2255
- path26.extname(this._scriptPath)
2255
+ path28.extname(this._scriptPath)
2256
2256
  );
2257
2257
  if (legacyName !== this._name) {
2258
2258
  localFile = findFile(
@@ -2263,7 +2263,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2263
2263
  }
2264
2264
  executableFile = localFile || executableFile;
2265
2265
  }
2266
- launchWithNode = sourceExt.includes(path26.extname(executableFile));
2266
+ launchWithNode = sourceExt.includes(path28.extname(executableFile));
2267
2267
  let proc;
2268
2268
  if (process3.platform !== "win32") {
2269
2269
  if (launchWithNode) {
@@ -3178,7 +3178,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
3178
3178
  * @return {Command}
3179
3179
  */
3180
3180
  nameFromFilename(filename) {
3181
- this._name = path26.basename(filename, path26.extname(filename));
3181
+ this._name = path28.basename(filename, path28.extname(filename));
3182
3182
  return this;
3183
3183
  }
3184
3184
  /**
@@ -3192,9 +3192,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
3192
3192
  * @param {string} [path]
3193
3193
  * @return {(string|null|Command)}
3194
3194
  */
3195
- executableDir(path27) {
3196
- if (path27 === void 0) return this._executableDir;
3197
- this._executableDir = path27;
3195
+ executableDir(path29) {
3196
+ if (path29 === void 0) return this._executableDir;
3197
+ this._executableDir = path29;
3198
3198
  return this;
3199
3199
  }
3200
3200
  /**
@@ -4907,10 +4907,10 @@ function keysFilePath(env) {
4907
4907
  const expanded = expandHome(configured);
4908
4908
  return isAbsolute(expanded) ? expanded : expanded;
4909
4909
  }
4910
- function parseKeysFile(path26) {
4910
+ function parseKeysFile(path28) {
4911
4911
  let text2;
4912
4912
  try {
4913
- text2 = readFileSync3(path26, "utf8");
4913
+ text2 = readFileSync3(path28, "utf8");
4914
4914
  } catch {
4915
4915
  return {};
4916
4916
  }
@@ -5022,18 +5022,18 @@ function upsertKeyLines(existing, updates) {
5022
5022
  if (!text2.endsWith("\n")) text2 += "\n";
5023
5023
  return text2;
5024
5024
  }
5025
- function restrictPermissions(path26) {
5025
+ function restrictPermissions(path28) {
5026
5026
  if (process.platform === "win32") return null;
5027
5027
  try {
5028
- chmodSync(path26, 384);
5028
+ chmodSync(path28, 384);
5029
5029
  return null;
5030
5030
  } catch (error) {
5031
5031
  return error instanceof Error ? error.message : String(error);
5032
5032
  }
5033
5033
  }
5034
5034
  async function keys(options = {}) {
5035
- const path26 = keysFilePath(process.env);
5036
- const fileKeys = parseKeysFile(path26);
5035
+ const path28 = keysFilePath(process.env);
5036
+ const fileKeys = parseKeysFile(path28);
5037
5037
  const names = Object.keys(PROVIDERS).sort();
5038
5038
  const current = names.map((name) => {
5039
5039
  const preset = PROVIDERS[name];
@@ -5049,7 +5049,7 @@ async function keys(options = {}) {
5049
5049
  if (options.check) {
5050
5050
  const configured = current.filter((entry) => entry.value);
5051
5051
  if (!configured.length) {
5052
- process.stdout.write(`no provider keys configured (looked in $ENV and ${path26})
5052
+ process.stdout.write(`no provider keys configured (looked in $ENV and ${path28})
5053
5053
  `);
5054
5054
  return 1;
5055
5055
  }
@@ -5064,7 +5064,7 @@ async function keys(options = {}) {
5064
5064
  return bad ? 1 : 0;
5065
5065
  }
5066
5066
  Ie("caddis keys");
5067
- process.stdout.write(` keys file: ${path26}
5067
+ process.stdout.write(` keys file: ${path28}
5068
5068
 
5069
5069
  `);
5070
5070
  for (const entry of current) {
@@ -5124,20 +5124,20 @@ async function keys(options = {}) {
5124
5124
  return 0;
5125
5125
  }
5126
5126
  if (options.dryRun) {
5127
- Se(`dry run \u2014 would write ${Object.keys(collected).join(", ")} to ${path26}`);
5127
+ Se(`dry run \u2014 would write ${Object.keys(collected).join(", ")} to ${path28}`);
5128
5128
  return 0;
5129
5129
  }
5130
5130
  let existing = "";
5131
5131
  try {
5132
- existing = readFileSync4(path26, "utf8");
5132
+ existing = readFileSync4(path28, "utf8");
5133
5133
  } catch {
5134
5134
  existing = "";
5135
5135
  }
5136
- mkdirSync2(dirname(path26), { recursive: true });
5137
- writeFileSync(path26, upsertKeyLines(existing, collected), { encoding: "utf8" });
5138
- const permWarning = restrictPermissions(path26);
5136
+ mkdirSync2(dirname(path28), { recursive: true });
5137
+ writeFileSync(path28, upsertKeyLines(existing, collected), { encoding: "utf8" });
5138
+ const permWarning = restrictPermissions(path28);
5139
5139
  process.stdout.write(`
5140
- wrote ${Object.keys(collected).join(", ")} to ${path26}
5140
+ wrote ${Object.keys(collected).join(", ")} to ${path28}
5141
5141
  `);
5142
5142
  if (permWarning) process.stdout.write(color2.yellow(` could not set 0600 on the keys file: ${permWarning}
5143
5143
  `));
@@ -5752,7 +5752,7 @@ function hubHome(home) {
5752
5752
  function sessionsPath(home) {
5753
5753
  return path7.join(hubDir(home), "sessions.json");
5754
5754
  }
5755
- var configPath, registryPath, keyPath, lockPath, auditPath;
5755
+ var configPath, registryPath, keyPath, lockPath, logPath, auditPath;
5756
5756
  var init_paths = __esm({
5757
5757
  "src/hub/paths.ts"() {
5758
5758
  "use strict";
@@ -5761,6 +5761,7 @@ var init_paths = __esm({
5761
5761
  registryPath = (home) => path7.join(hubDir(home), "repos.json");
5762
5762
  keyPath = (home) => path7.join(hubDir(home), "key");
5763
5763
  lockPath = (home) => path7.join(hubDir(home), "hub.lock");
5764
+ logPath = (home) => path7.join(hubDir(home), "hub.log");
5764
5765
  auditPath = (home) => path7.join(hubHome(home), "audit.jsonl");
5765
5766
  }
5766
5767
  });
@@ -5822,9 +5823,23 @@ async function enableAutostart(deps = {}) {
5822
5823
  const kind = kindOf(deps.platform ?? process.platform);
5823
5824
  if (kind === "win") {
5824
5825
  const vbs = vbsPath(home);
5825
- writeText(vbs, buildVbs(node, entry));
5826
+ const text2 = buildVbs(node, entry);
5827
+ writeText(vbs, text2);
5826
5828
  const r2 = await runCmd("schtasks", schtasksCreateArgs(vbs));
5827
- return r2.ok ? { ok: true, message: `caddis hub autostart enabled (logon task ${TASK_NAME})` } : { ok: false, message: `schtasks /Create failed (exit ${r2.code})` };
5829
+ const appData = appDataOf(deps);
5830
+ if (r2.ok) {
5831
+ if (appData) rmSync3(startupVbsPath(appData), { force: true });
5832
+ return { ok: true, message: `caddis hub autostart enabled (logon task ${TASK_NAME})` };
5833
+ }
5834
+ if (!appData) {
5835
+ return { ok: false, message: `schtasks /Create failed (exit ${r2.code}) and APPDATA is not set, so there is no Startup folder` };
5836
+ }
5837
+ const startup = startupVbsPath(appData);
5838
+ writeText(startup, text2);
5839
+ return {
5840
+ ok: true,
5841
+ message: `caddis hub autostart enabled (Startup folder: ${startup}); the logon task failed (schtasks exit ${r2.code})`
5842
+ };
5828
5843
  }
5829
5844
  if (kind === "mac") {
5830
5845
  const file2 = plistPath(home);
@@ -5843,7 +5858,12 @@ async function disableAutostart(deps = {}) {
5843
5858
  if (kind === "win") {
5844
5859
  const r2 = await runCmd("schtasks", schtasksDeleteArgs());
5845
5860
  rmSync3(vbsPath(home), { force: true });
5846
- return r2.ok ? { ok: true, message: "caddis hub autostart disabled" } : { ok: true, message: "caddis hub autostart was not enabled (no logon task to delete)" };
5861
+ const appData = appDataOf(deps);
5862
+ const startup = appData ? startupVbsPath(appData) : null;
5863
+ const hadStartup = startup !== null && existsSync6(startup);
5864
+ if (startup) rmSync3(startup, { force: true });
5865
+ const removed = [r2.ok ? `logon task ${TASK_NAME}` : "", hadStartup ? "Startup folder launcher" : ""].filter(Boolean);
5866
+ return removed.length ? { ok: true, message: `caddis hub autostart disabled (removed ${removed.join(" and ")})` } : { ok: true, message: "caddis hub autostart was not enabled (no logon task or Startup launcher to remove)" };
5847
5867
  }
5848
5868
  if (kind === "mac") {
5849
5869
  const file = plistPath(home);
@@ -5858,10 +5878,18 @@ async function autostartStatus(deps = {}) {
5858
5878
  const home = deps.home ?? caddisHome();
5859
5879
  const runCmd = deps.runCmd ?? defaultRun;
5860
5880
  const kind = kindOf(deps.platform ?? process.platform);
5861
- const enabled = kind === "win" ? (await runCmd("schtasks", schtasksQueryArgs())).ok : existsSync6(kind === "mac" ? plistPath(home) : desktopPath(home));
5881
+ if (kind === "win") {
5882
+ const task = (await runCmd("schtasks", schtasksQueryArgs())).ok;
5883
+ const appData = appDataOf(deps);
5884
+ const startup = appData ? startupVbsPath(appData) : null;
5885
+ const how = [task ? `logon task ${TASK_NAME}` : "", startup && existsSync6(startup) ? `Startup folder: ${startup}` : ""];
5886
+ const on = how.filter(Boolean);
5887
+ return on.length ? { ok: true, message: `caddis hub autostart is enabled (${on.join("; ")})` } : { ok: false, message: "caddis hub autostart is not enabled" };
5888
+ }
5889
+ const enabled = existsSync6(kind === "mac" ? plistPath(home) : desktopPath(home));
5862
5890
  return { ok: enabled, message: enabled ? "caddis hub autostart is enabled" : "caddis hub autostart is not enabled" };
5863
5891
  }
5864
- var TASK_NAME, MAC_LABEL, CMD_TIMEOUT_MS, vbsPath, schtasksDeleteArgs, schtasksQueryArgs, xml, plistPath, desktopPath, defaultRun, kindOf;
5892
+ var TASK_NAME, MAC_LABEL, CMD_TIMEOUT_MS, vbsPath, startupVbsPath, schtasksDeleteArgs, schtasksQueryArgs, xml, plistPath, desktopPath, defaultRun, appDataOf, kindOf;
5865
5893
  var init_autostart = __esm({
5866
5894
  "src/hub/autostart.ts"() {
5867
5895
  "use strict";
@@ -5872,6 +5900,7 @@ var init_autostart = __esm({
5872
5900
  MAC_LABEL = "dev.caddis.hub";
5873
5901
  CMD_TIMEOUT_MS = 3e4;
5874
5902
  vbsPath = (home) => path8.join(hubDir(home), "autostart.vbs");
5903
+ startupVbsPath = (appData) => path8.join(appData, "Microsoft", "Windows", "Start Menu", "Programs", "Startup", `${TASK_NAME}.vbs`);
5875
5904
  schtasksDeleteArgs = () => ["/Delete", "/TN", TASK_NAME, "/F"];
5876
5905
  schtasksQueryArgs = () => ["/Query", "/TN", TASK_NAME];
5877
5906
  xml = (s) => s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
@@ -5881,6 +5910,7 @@ var init_autostart = __esm({
5881
5910
  const r2 = await run(cmd, args, { timeout: CMD_TIMEOUT_MS });
5882
5911
  return { ok: r2.ok, code: r2.code };
5883
5912
  };
5913
+ appDataOf = (deps) => deps.appData ?? process.env.APPDATA;
5884
5914
  kindOf = (p2) => p2 === "win32" ? "win" : p2 === "darwin" ? "mac" : "linux";
5885
5915
  }
5886
5916
  });
@@ -5890,7 +5920,7 @@ import { mkdirSync as mkdirSync4, readFileSync as readFileSync6, renameSync as r
5890
5920
  import path9 from "path";
5891
5921
  import { randomBytes } from "crypto";
5892
5922
  function defaultConfig() {
5893
- return { schema: 1, port: DEFAULT_PORT, accounts: {}, pinned: [], hidden: [] };
5923
+ return { schema: 1, port: DEFAULT_PORT, accounts: {}, pinned: [], hidden: [], auto_update: true };
5894
5924
  }
5895
5925
  function defaultRegistry() {
5896
5926
  return { schema: 1, repos: [] };
@@ -5958,6 +5988,7 @@ function normalizeConfig(raw) {
5958
5988
  }
5959
5989
  d3.pinned = strings(raw.pinned);
5960
5990
  d3.hidden = strings(raw.hidden);
5991
+ if (raw.auto_update === false) d3.auto_update = false;
5961
5992
  return d3;
5962
5993
  }
5963
5994
  function normalizeRegistry(raw) {
@@ -6188,12 +6219,42 @@ var init_lock = __esm({
6188
6219
  }
6189
6220
  });
6190
6221
 
6222
+ // src/hub/hubLog.ts
6223
+ import { appendFileSync, mkdirSync as mkdirSync7, renameSync as renameSync3, statSync } from "fs";
6224
+ import path12 from "path";
6225
+ function hubLog(text2, home, now = Date.now) {
6226
+ try {
6227
+ process.stderr.write(`${text2}
6228
+ `);
6229
+ } catch {
6230
+ }
6231
+ const file = logPath(home);
6232
+ try {
6233
+ mkdirSync7(path12.dirname(file), { recursive: true, mode: 448 });
6234
+ try {
6235
+ if (statSync(file).size > LOG_MAX_BYTES) renameSync3(file, `${file}.1`);
6236
+ } catch {
6237
+ }
6238
+ appendFileSync(file, `${new Date(now()).toISOString()} ${text2.replace(/[\r\n]+/g, " ")}
6239
+ `, { mode: 384 });
6240
+ } catch {
6241
+ }
6242
+ }
6243
+ var LOG_MAX_BYTES;
6244
+ var init_hubLog = __esm({
6245
+ "src/hub/hubLog.ts"() {
6246
+ "use strict";
6247
+ init_paths();
6248
+ LOG_MAX_BYTES = 256 * 1024;
6249
+ }
6250
+ });
6251
+
6191
6252
  // src/hub/restart.ts
6192
6253
  import { readFileSync as readFileSync9 } from "fs";
6193
- import path12 from "path";
6254
+ import path13 from "path";
6194
6255
  function readInstalledVersion2(packageRoot) {
6195
6256
  try {
6196
- const parsed = JSON.parse(readFileSync9(path12.join(packageRoot, "package.json"), "utf8"));
6257
+ const parsed = JSON.parse(readFileSync9(path13.join(packageRoot, "package.json"), "utf8"));
6197
6258
  return typeof parsed.version === "string" && parsed.version ? parsed.version : null;
6198
6259
  } catch {
6199
6260
  return null;
@@ -6286,11 +6347,136 @@ var init_restart = __esm({
6286
6347
  }
6287
6348
  });
6288
6349
 
6350
+ // src/hub/selfUpdate.ts
6351
+ import path14 from "path";
6352
+ async function fetchLatestVersion(fetchFn = fetch) {
6353
+ const res = await fetchFn(REGISTRY_URL, {
6354
+ headers: { accept: "application/json" },
6355
+ signal: AbortSignal.timeout(FETCH_TIMEOUT_MS)
6356
+ });
6357
+ if (!res.ok) throw new Error(`the npm registry answered HTTP ${res.status}`);
6358
+ const body = await res.json();
6359
+ return typeof body.version === "string" && PLAIN_VERSION.test(body.version) ? body.version : null;
6360
+ }
6361
+ function isGlobalInstall(packageRoot, globalRoot, platform = process.platform) {
6362
+ const p2 = platform === "win32" ? path14.win32 : path14.posix;
6363
+ const norm = (dir) => {
6364
+ const r2 = p2.resolve(dir).replace(/[\\/]+$/, "");
6365
+ return platform === "win32" ? r2.toLowerCase() : r2;
6366
+ };
6367
+ return norm(packageRoot) === norm(p2.join(globalRoot, "@caddis", "cli"));
6368
+ }
6369
+ function createUpdater(deps) {
6370
+ const tried = /* @__PURE__ */ new Map();
6371
+ const noted = /* @__PURE__ */ new Set();
6372
+ let globalRoot = null;
6373
+ let installing = false;
6374
+ let running = Promise.resolve();
6375
+ let cancel = null;
6376
+ let stopped = false;
6377
+ const once = (key, text2) => {
6378
+ if (noted.has(key)) return;
6379
+ noted.add(key);
6380
+ deps.log(text2);
6381
+ };
6382
+ async function isGlobal() {
6383
+ globalRoot ??= await deps.globalRoot();
6384
+ return globalRoot !== null && isGlobalInstall(deps.packageRoot, globalRoot, deps.platform);
6385
+ }
6386
+ async function check2() {
6387
+ const disk = deps.readVersion();
6388
+ if (disk !== null && disk !== deps.currentVersion) {
6389
+ once(`disk:${disk}`, `caddis hub: version ${disk} is installed (running ${deps.currentVersion}); restarting`);
6390
+ await deps.onInstalled(disk);
6391
+ return;
6392
+ }
6393
+ const latest = await deps.fetchLatest();
6394
+ if (latest === null || compareVersions(latest, deps.currentVersion) !== 1) return;
6395
+ if (!deps.autoUpdate()) {
6396
+ once(`off:${latest}`, `caddis hub: version ${latest} is available (running ${deps.currentVersion}); auto_update is off`);
6397
+ return;
6398
+ }
6399
+ if (!await isGlobal()) {
6400
+ once(
6401
+ `local:${latest}`,
6402
+ `caddis hub: update available ${deps.currentVersion} -> ${latest}; this hub does not run from the global npm install, so it does not install it`
6403
+ );
6404
+ return;
6405
+ }
6406
+ const last = tried.get(latest);
6407
+ if (last !== void 0 && deps.now() - last < RETRY_AFTER_MS) return;
6408
+ tried.set(latest, deps.now());
6409
+ deps.log(`caddis hub: installing @caddis/cli@${latest} (running ${deps.currentVersion})`);
6410
+ let result;
6411
+ installing = true;
6412
+ try {
6413
+ result = await deps.install(latest);
6414
+ } finally {
6415
+ installing = false;
6416
+ }
6417
+ if (!result.ok) {
6418
+ deps.log(`caddis hub: install of ${latest} failed (${result.detail}); keeping ${deps.currentVersion}, next try in 1 h`);
6419
+ return;
6420
+ }
6421
+ const after = deps.readVersion();
6422
+ if (after !== latest) {
6423
+ deps.log(`caddis hub: npm finished, but package.json shows ${after ?? "nothing"}, not ${latest}; no restart`);
6424
+ return;
6425
+ }
6426
+ deps.log(`caddis hub: installed ${latest}; restarting`);
6427
+ await deps.onInstalled(latest);
6428
+ }
6429
+ function tick() {
6430
+ running = check2().catch((e2) => {
6431
+ try {
6432
+ deps.log(`caddis hub: update check failed: ${e2 instanceof Error ? e2.message : String(e2)}`);
6433
+ } catch {
6434
+ }
6435
+ });
6436
+ return running;
6437
+ }
6438
+ function schedule(ms) {
6439
+ if (stopped) return;
6440
+ cancel = deps.after(() => {
6441
+ void tick().then(() => schedule(UPDATE_EVERY_MS));
6442
+ }, ms);
6443
+ }
6444
+ return {
6445
+ start: () => {
6446
+ if (cancel) return;
6447
+ stopped = false;
6448
+ schedule(UPDATE_FIRST_MS);
6449
+ },
6450
+ stop: () => {
6451
+ stopped = true;
6452
+ cancel?.();
6453
+ cancel = null;
6454
+ },
6455
+ tick,
6456
+ installing: () => installing,
6457
+ idle: () => running
6458
+ };
6459
+ }
6460
+ var REGISTRY_URL, UPDATE_FIRST_MS, UPDATE_EVERY_MS, RETRY_AFTER_MS, INSTALL_TIMEOUT_MS, FETCH_TIMEOUT_MS, PLAIN_VERSION;
6461
+ var init_selfUpdate = __esm({
6462
+ "src/hub/selfUpdate.ts"() {
6463
+ "use strict";
6464
+ init_semver();
6465
+ REGISTRY_URL = "https://registry.npmjs.org/@caddis/cli/latest";
6466
+ UPDATE_FIRST_MS = 6e4;
6467
+ UPDATE_EVERY_MS = 30 * 6e4;
6468
+ RETRY_AFTER_MS = 60 * 6e4;
6469
+ INSTALL_TIMEOUT_MS = 5 * 6e4;
6470
+ FETCH_TIMEOUT_MS = 1e4;
6471
+ PLAIN_VERSION = /^\d+\.\d+\.\d+$/;
6472
+ }
6473
+ });
6474
+
6289
6475
  // src/hub/append.ts
6290
6476
  import { mkdir, open } from "fs/promises";
6291
- import path13 from "path";
6477
+ import path15 from "path";
6292
6478
  async function writeLine(file, line2) {
6293
- await mkdir(path13.dirname(file), { recursive: true });
6479
+ await mkdir(path15.dirname(file), { recursive: true });
6294
6480
  const deadline = Date.now() + RETRY_FOR_MS;
6295
6481
  for (; ; ) {
6296
6482
  try {
@@ -6337,7 +6523,7 @@ var init_append = __esm({
6337
6523
  RETRY_CODES = /* @__PURE__ */ new Set(["EBUSY", "EPERM", "EACCES"]);
6338
6524
  RETRY_FOR_MS = 2e3;
6339
6525
  keyOf = (file) => {
6340
- const abs = path13.resolve(file);
6526
+ const abs = path15.resolve(file);
6341
6527
  return process.platform === "win32" ? abs.toLowerCase() : abs;
6342
6528
  };
6343
6529
  }
@@ -6345,7 +6531,7 @@ var init_append = __esm({
6345
6531
 
6346
6532
  // src/hub/sources/coordinator.ts
6347
6533
  import { closeSync as closeSync2, fstatSync, openSync as openSync2, readdirSync as readdirSync3, readFileSync as readFileSync10, readSync } from "fs";
6348
- import path14 from "path";
6534
+ import path16 from "path";
6349
6535
  function stub(repoId, schema) {
6350
6536
  return {
6351
6537
  repo_id: repoId,
@@ -6496,7 +6682,7 @@ function createCoordinatorSource(opts = {}) {
6496
6682
  const errors = /* @__PURE__ */ new Map();
6497
6683
  return {
6498
6684
  refresh() {
6499
- const root = path14.join(hubHome(opts.home), "repos");
6685
+ const root = path16.join(hubHome(opts.home), "repos");
6500
6686
  let ids = [];
6501
6687
  try {
6502
6688
  ids = readdirSync3(root, { withFileTypes: true }).filter((d3) => d3.isDirectory()).map((d3) => d3.name);
@@ -6506,10 +6692,10 @@ function createCoordinatorSource(opts = {}) {
6506
6692
  for (const id of [...lastGood2.keys()]) if (!seen.has(id)) lastGood2.delete(id);
6507
6693
  for (const id of [...errors.keys()]) if (!seen.has(id)) errors.delete(id);
6508
6694
  for (const id of ids) {
6509
- const requests = parseRequests(readTailLines(path14.join(root, id, "requests.jsonl")));
6695
+ const requests = parseRequests(readTailLines(path16.join(root, id, "requests.jsonl")));
6510
6696
  let text2;
6511
6697
  try {
6512
- text2 = readFileSync10(path14.join(root, id, "coordinator.json"), "utf8");
6698
+ text2 = readFileSync10(path16.join(root, id, "coordinator.json"), "utf8");
6513
6699
  } catch (e2) {
6514
6700
  if (e2.code === "ENOENT") {
6515
6701
  lastGood2.delete(id);
@@ -6572,7 +6758,7 @@ var init_coordinator = __esm({
6572
6758
  });
6573
6759
 
6574
6760
  // src/hub/audit.ts
6575
- import { statSync } from "fs";
6761
+ import { statSync as statSync2 } from "fs";
6576
6762
  function parseAudit(lines) {
6577
6763
  const out = [];
6578
6764
  for (const line2 of lines) {
@@ -6603,7 +6789,7 @@ function readAudit(home) {
6603
6789
  const file = auditPath(home);
6604
6790
  let sig;
6605
6791
  try {
6606
- const st = statSync(file);
6792
+ const st = statSync2(file);
6607
6793
  sig = `${st.size}:${st.mtimeMs}`;
6608
6794
  } catch {
6609
6795
  cache.delete(file);
@@ -6756,7 +6942,7 @@ var init_spawn = __esm({
6756
6942
 
6757
6943
  // src/hub/sources/beats.ts
6758
6944
  import { readFileSync as readFileSync11, readdirSync as readdirSync4 } from "fs";
6759
- import path15 from "path";
6945
+ import path17 from "path";
6760
6946
  function toEntry(raw, opts) {
6761
6947
  if (!raw || typeof raw !== "object" || Array.isArray(raw)) return null;
6762
6948
  const r2 = raw;
@@ -6807,7 +6993,7 @@ function readAgentBeats(opts) {
6807
6993
  if (!name.endsWith(".json") || name.startsWith(".")) continue;
6808
6994
  let entry = null;
6809
6995
  try {
6810
- entry = toEntry(JSON.parse(readFileSync11(path15.join(dir, name), "utf8")), opts);
6996
+ entry = toEntry(JSON.parse(readFileSync11(path17.join(dir, name), "utf8")), opts);
6811
6997
  } catch {
6812
6998
  continue;
6813
6999
  }
@@ -6832,8 +7018,8 @@ var init_beats = __esm({
6832
7018
  });
6833
7019
 
6834
7020
  // src/hub/sources/agents.ts
6835
- import { existsSync as existsSync7, readFileSync as readFileSync12, statSync as statSync2 } from "fs";
6836
- import path16 from "path";
7021
+ import { existsSync as existsSync7, readFileSync as readFileSync12, statSync as statSync3 } from "fs";
7022
+ import path18 from "path";
6837
7023
  function classifyWaiting(waitingFor) {
6838
7024
  const w2 = (waitingFor ?? "").toLowerCase();
6839
7025
  if (w2 === "permission prompt" || w2 === "input needed" || w2.includes("question")) return "owner";
@@ -6841,15 +7027,15 @@ function classifyWaiting(waitingFor) {
6841
7027
  }
6842
7028
  function repoPathFor(cwd) {
6843
7029
  if (!cwd) return null;
6844
- let dir = path16.resolve(cwd);
7030
+ let dir = path18.resolve(cwd);
6845
7031
  for (; ; ) {
6846
- const dotGit = path16.join(dir, ".git");
7032
+ const dotGit = path18.join(dir, ".git");
6847
7033
  if (existsSync7(dotGit)) {
6848
7034
  if (isDir(dotGit)) return normalizeRepoPath(dir);
6849
7035
  if (isFile(dotGit)) return commonRoot(dir, dotGit);
6850
7036
  return null;
6851
7037
  }
6852
- const parent = path16.dirname(dir);
7038
+ const parent = path18.dirname(dir);
6853
7039
  if (parent === dir) return null;
6854
7040
  dir = parent;
6855
7041
  }
@@ -6858,16 +7044,16 @@ function commonRoot(dir, dotGitFile) {
6858
7044
  try {
6859
7045
  const m2 = /^gitdir:\s*(.+?)\s*$/m.exec(readFileSync12(dotGitFile, "utf8"));
6860
7046
  if (!m2) return null;
6861
- const gitdir = path16.resolve(dir, m2[1] ?? "");
7047
+ const gitdir = path18.resolve(dir, m2[1] ?? "");
6862
7048
  let common;
6863
7049
  try {
6864
- const rel = readFileSync12(path16.join(gitdir, "commondir"), "utf8").trim();
7050
+ const rel = readFileSync12(path18.join(gitdir, "commondir"), "utf8").trim();
6865
7051
  if (!rel) return normalizeRepoPath(dir);
6866
- common = path16.resolve(gitdir, rel);
7052
+ common = path18.resolve(gitdir, rel);
6867
7053
  } catch {
6868
7054
  return normalizeRepoPath(dir);
6869
7055
  }
6870
- return normalizeRepoPath(path16.dirname(common));
7056
+ return normalizeRepoPath(path18.dirname(common));
6871
7057
  } catch {
6872
7058
  return null;
6873
7059
  }
@@ -6997,14 +7183,14 @@ var init_agents = __esm({
6997
7183
  FIND_TIMEOUT_MS = 1e4;
6998
7184
  isFile = (p2) => {
6999
7185
  try {
7000
- return statSync2(p2).isFile();
7186
+ return statSync3(p2).isFile();
7001
7187
  } catch {
7002
7188
  return false;
7003
7189
  }
7004
7190
  };
7005
7191
  isDir = (p2) => {
7006
7192
  try {
7007
- return statSync2(p2).isDirectory();
7193
+ return statSync3(p2).isDirectory();
7008
7194
  } catch {
7009
7195
  return false;
7010
7196
  }
@@ -7014,19 +7200,19 @@ var init_agents = __esm({
7014
7200
  });
7015
7201
 
7016
7202
  // src/hub/sources/collector.ts
7017
- import { existsSync as existsSync8, mkdirSync as mkdirSync7, writeFileSync as writeFileSync5 } from "fs";
7203
+ import { existsSync as existsSync8, mkdirSync as mkdirSync8, writeFileSync as writeFileSync5 } from "fs";
7018
7204
  import os5 from "os";
7019
- import path17 from "path";
7205
+ import path19 from "path";
7020
7206
  function defaultScriptPath() {
7021
7207
  const name = "caddis_hub_collect.py";
7022
7208
  const bundle = bundlePath("antigravity-plugin", { requireManifest: false });
7023
7209
  if (bundle) {
7024
- const shipped = path17.join(bundle, "scripts", name);
7210
+ const shipped = path19.join(bundle, "scripts", name);
7025
7211
  if (existsSync8(shipped)) return shipped;
7026
7212
  }
7027
- const root = path17.join(packageInfo().root, "..");
7028
- const repoScript = path17.join(root, "scripts", name);
7029
- const mirrorScript = path17.join(root, "bundles", "antigravity-plugin", "scripts", name);
7213
+ const root = path19.join(packageInfo().root, "..");
7214
+ const repoScript = path19.join(root, "scripts", name);
7215
+ const mirrorScript = path19.join(root, "bundles", "antigravity-plugin", "scripts", name);
7030
7216
  return !existsSync8(repoScript) && existsSync8(mirrorScript) ? mirrorScript : repoScript;
7031
7217
  }
7032
7218
  async function resolvePython() {
@@ -7056,10 +7242,20 @@ function createCollectorSource(opts) {
7056
7242
  let running = null;
7057
7243
  let knownUnsupported = false;
7058
7244
  let prsFileUnsupported = false;
7245
+ let doneKnownUnsupported = false;
7059
7246
  const fail2 = (message3) => {
7060
7247
  lastError = message3;
7061
7248
  lastRunOk = false;
7062
7249
  };
7250
+ const withDone = (entry, old) => {
7251
+ const plans = entry.plans;
7252
+ const done = plans?.done;
7253
+ if (!plans || !done || typeof done !== "object" || done.unchanged !== true) return entry;
7254
+ const oldDone = old?.error === void 0 ? old?.plans?.done : void 0;
7255
+ const reuse = oldDone && typeof done.tree === "string" && oldDone.tree === done.tree && Array.isArray(oldDone.plans);
7256
+ if (reuse) return { ...entry, plans: { ...plans, done: oldDone } };
7257
+ return { ...entry, fingerprint: void 0, plans: { ...plans, done: { error: "done plans not cached" } } };
7258
+ };
7063
7259
  const ingest = (parsed, wanted) => {
7064
7260
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return fail2("collector output is not a JSON object");
7065
7261
  const out = parsed;
@@ -7085,7 +7281,7 @@ function createCollectorSource(opts) {
7085
7281
  if (!old || old.error !== void 0) cache2.set(entry.path, entry);
7086
7282
  continue;
7087
7283
  }
7088
- if (!old || old.error !== void 0 || old.fingerprint !== entry.fingerprint) cache2.set(entry.path, entry);
7284
+ if (!old || old.error !== void 0 || old.fingerprint !== entry.fingerprint) cache2.set(entry.path, withDone(entry, old));
7089
7285
  }
7090
7286
  const keepOrError = (next, old) => {
7091
7287
  if (!next || typeof next !== "object") return old;
@@ -7111,28 +7307,46 @@ function createCollectorSource(opts) {
7111
7307
  }
7112
7308
  const script = opts.scriptPath ?? defaultScriptPath();
7113
7309
  const known = [...cache2.values()].filter((r2) => !knownUnsupported && r2.error === void 0 && typeof r2.fingerprint === "string" && repos.includes(r2.path)).map((r2) => `${r2.path}=${r2.fingerprint}`);
7310
+ const doneKnown = [...cache2.values()].filter((r2) => !knownUnsupported && !doneKnownUnsupported && r2.error === void 0 && repos.includes(r2.path)).flatMap((r2) => {
7311
+ const tree = r2.plans?.done?.tree;
7312
+ return typeof tree === "string" && tree ? [`${r2.path}=${tree}`] : [];
7313
+ });
7114
7314
  let prsFlag = [];
7115
7315
  if (opts.prs && opts.prsFile && repos.length > 0 && !prsFileUnsupported) {
7116
7316
  try {
7117
- mkdirSync7(path17.dirname(opts.prsFile), { recursive: true });
7317
+ mkdirSync8(path19.dirname(opts.prsFile), { recursive: true });
7118
7318
  writeFileSync5(opts.prsFile, JSON.stringify({ schema: 1, repos: opts.prs() }));
7119
7319
  prsFlag = ["--prs-file", opts.prsFile];
7120
7320
  } catch {
7121
7321
  }
7122
7322
  }
7123
- const args = repos.length ? known.length ? [...pre, script, "--repos", ...repos, "--known", ...known, ...prsFlag, "--json"] : [...pre, script, "--repos", ...repos, ...prsFlag, "--json"] : [...pre, script, "--repos", path17.join(os5.tmpdir(), "caddis-hub-no-repos"), "--only", "spend,guide", "--json"];
7124
- let result = await spawn2(cmd, args, { timeoutMs: RUN_TIMEOUT_MS2 });
7125
- if (!result.ok && prsFlag.length && /unrecognized arguments:.*--prs-file/.test(result.stderr)) {
7126
- prsFileUnsupported = true;
7127
- prsFlag = [];
7128
- log("caddis hub: the collector script does not know --prs-file (old plugin); branch progress is off. Update the plugin.");
7129
- const retryArgs = known.length ? [...pre, script, "--repos", ...repos, "--known", ...known, "--json"] : [...pre, script, "--repos", ...repos, "--json"];
7130
- result = await spawn2(cmd, retryArgs, { timeoutMs: RUN_TIMEOUT_MS2 });
7131
- }
7132
- if (!result.ok && result.code === 2 && known.length && repos.length && /unrecognized arguments:.*--known/.test(result.stderr)) {
7133
- knownUnsupported = true;
7134
- log("caddis hub: the collector script does not know --known (old plugin); sending full runs. Update the plugin.");
7135
- result = await spawn2(cmd, [...pre, script, "--repos", ...repos, ...prsFlag, "--json"], { timeoutMs: RUN_TIMEOUT_MS2 });
7323
+ const build = () => repos.length ? [
7324
+ ...pre,
7325
+ script,
7326
+ "--repos",
7327
+ ...repos,
7328
+ ...known.length ? ["--known", ...known] : [],
7329
+ ...doneKnown.length ? ["--done-known", ...doneKnown] : [],
7330
+ ...prsFlag,
7331
+ "--json"
7332
+ ] : [...pre, script, "--repos", path19.join(os5.tmpdir(), "caddis-hub-no-repos"), "--only", "spend,guide", "--json"];
7333
+ let result = await spawn2(cmd, build(), { timeoutMs: RUN_TIMEOUT_MS2 });
7334
+ for (let attempt = 0; attempt < 3 && !result.ok; attempt += 1) {
7335
+ if (prsFlag.length && /unrecognized arguments:.*--prs-file/.test(result.stderr)) {
7336
+ prsFileUnsupported = true;
7337
+ prsFlag = [];
7338
+ log("caddis hub: the collector script does not know --prs-file (old plugin); branch progress is off. Update the plugin.");
7339
+ } else if (result.code === 2 && known.length && repos.length && /unrecognized arguments:.*--known/.test(result.stderr)) {
7340
+ knownUnsupported = true;
7341
+ known.length = 0;
7342
+ doneKnown.length = 0;
7343
+ log("caddis hub: the collector script does not know --known (old plugin); sending full runs. Update the plugin.");
7344
+ } else if (result.code === 2 && doneKnown.length && /unrecognized arguments:.*--done-known/.test(result.stderr)) {
7345
+ doneKnownUnsupported = true;
7346
+ doneKnown.length = 0;
7347
+ log("caddis hub: the collector script does not know --done-known (old plugin); done plans are sent in full. Update the plugin.");
7348
+ } else break;
7349
+ result = await spawn2(cmd, build(), { timeoutMs: RUN_TIMEOUT_MS2 });
7136
7350
  }
7137
7351
  if (result.timedOut) return fail2(`collector timed out after ${RUN_TIMEOUT_MS2 / 1e3} s`);
7138
7352
  if (!result.ok) {
@@ -7188,7 +7402,7 @@ var init_collector = __esm({
7188
7402
 
7189
7403
  // src/hub/sources/github.ts
7190
7404
  import { readFileSync as readFileSync13 } from "fs";
7191
- import path18 from "path";
7405
+ import path20 from "path";
7192
7406
  function parseGithubRemote(url) {
7193
7407
  const m2 = /^(?:https?:\/\/(?:[^@/]+@)?|ssh:\/\/git@|git@)github\.com[/:]([^/\s]+)\/([^/\s]+?)(?:\.git)?\/?$/i.exec(url.trim());
7194
7408
  return m2 ? `${m2[1]}/${m2[2]}` : null;
@@ -7198,7 +7412,7 @@ function readOriginUrl(repoDir) {
7198
7412
  if (!root) return null;
7199
7413
  let text2;
7200
7414
  try {
7201
- text2 = readFileSync13(path18.join(root, ".git", "config"), "utf8");
7415
+ text2 = readFileSync13(path20.join(root, ".git", "config"), "utf8");
7202
7416
  } catch {
7203
7417
  return null;
7204
7418
  }
@@ -7216,7 +7430,7 @@ function readOriginUrl(repoDir) {
7216
7430
  }
7217
7431
  function readRequiredChecks(repoDir) {
7218
7432
  try {
7219
- const text2 = readFileSync13(path18.join(repoDir, ".caddis", "coordinator.md"), "utf8");
7433
+ const text2 = readFileSync13(path20.join(repoDir, ".caddis", "coordinator.md"), "utf8");
7220
7434
  const m2 = /```json[^\S\r\n]*\r?\n([\s\S]*?)\r?\n[^\S\r\n]*```/.exec(text2);
7221
7435
  if (!m2) return null;
7222
7436
  const parsed = JSON.parse(m2[1] ?? "");
@@ -7344,8 +7558,8 @@ ${url}`;
7344
7558
  "User-Agent": "caddis-hub"
7345
7559
  };
7346
7560
  if (cached2) headers["If-None-Match"] = cached2.etag;
7347
- const signal = AbortSignal.timeout(FETCH_TIMEOUT_MS);
7348
- const res = await withTimeout(doFetch(url, { headers, signal }), FETCH_TIMEOUT_MS + 1e3, "GitHub request");
7561
+ const signal = AbortSignal.timeout(FETCH_TIMEOUT_MS2);
7562
+ const res = await withTimeout(doFetch(url, { headers, signal }), FETCH_TIMEOUT_MS2 + 1e3, "GitHub request");
7349
7563
  noteRate(account, res);
7350
7564
  if (res.status === 304) {
7351
7565
  if (cached2) return cached2.body;
@@ -7355,7 +7569,7 @@ ${url}`;
7355
7569
  const limited = (res.status === 403 || res.status === 429) && (res.headers.get("x-ratelimit-remaining") === "0" || res.headers.get("retry-after") !== null);
7356
7570
  throw new HttpError(res.status, limited, limited ? "GitHub rate limit reached" : `GitHub answered ${res.status}`);
7357
7571
  }
7358
- const body = await withTimeout(res.json(), FETCH_TIMEOUT_MS + 1e3, "GitHub response");
7572
+ const body = await withTimeout(res.json(), FETCH_TIMEOUT_MS2 + 1e3, "GitHub response");
7359
7573
  const etag = res.headers.get("etag");
7360
7574
  if (etag) etags.set(key, { etag, body });
7361
7575
  return body;
@@ -7544,7 +7758,7 @@ ${url}`;
7544
7758
  }
7545
7759
  };
7546
7760
  }
7547
- var STALE_AFTER_MS4, POLL_MS2, SLOW_POLL_MS, RATE_RESERVE, API, TOKEN_TIMEOUT_MS, FIND_TIMEOUT_MS3, FETCH_TIMEOUT_MS, MERGES_SHOWN, FAILED, PASSED, HttpError, str4, rec2, list, findGh;
7761
+ var STALE_AFTER_MS4, POLL_MS2, SLOW_POLL_MS, RATE_RESERVE, API, TOKEN_TIMEOUT_MS, FIND_TIMEOUT_MS3, FETCH_TIMEOUT_MS2, MERGES_SHOWN, FAILED, PASSED, HttpError, str4, rec2, list, findGh;
7548
7762
  var init_github = __esm({
7549
7763
  "src/hub/sources/github.ts"() {
7550
7764
  "use strict";
@@ -7559,7 +7773,7 @@ var init_github = __esm({
7559
7773
  API = "https://api.github.com";
7560
7774
  TOKEN_TIMEOUT_MS = 1e4;
7561
7775
  FIND_TIMEOUT_MS3 = 1e4;
7562
- FETCH_TIMEOUT_MS = 15e3;
7776
+ FETCH_TIMEOUT_MS2 = 15e3;
7563
7777
  MERGES_SHOWN = 5;
7564
7778
  FAILED = /* @__PURE__ */ new Set(["failure", "cancelled", "timed_out", "action_required", "startup_failure", "stale"]);
7565
7779
  PASSED = /* @__PURE__ */ new Set(["success", "neutral", "skipped"]);
@@ -7585,18 +7799,18 @@ var init_github = __esm({
7585
7799
  // src/hub/state.ts
7586
7800
  import { createHash } from "crypto";
7587
7801
  import { readFileSync as readFileSync14 } from "fs";
7588
- import path19 from "path";
7802
+ import path21 from "path";
7589
7803
  function repoIdFor(nameWithOwner) {
7590
7804
  return nameWithOwner.trim().toLowerCase().replace(/\//g, "__");
7591
7805
  }
7592
7806
  function localRepoId(repoPath) {
7593
7807
  const norm = process.platform === "win32" ? repoPath.toLowerCase().replace(/\//g, "\\") : repoPath;
7594
7808
  const digest = createHash("sha256").update(norm, "utf8").digest("hex").slice(0, 6);
7595
- return `local__${path19.basename(repoPath)}__${digest}`;
7809
+ return `local__${path21.basename(repoPath)}__${digest}`;
7596
7810
  }
7597
7811
  function readPluginVersion(home) {
7598
7812
  try {
7599
- const file = path19.join(home, ".claude", "plugins", "installed_plugins.json");
7813
+ const file = path21.join(home, ".claude", "plugins", "installed_plugins.json");
7600
7814
  const parsed = JSON.parse(readFileSync14(file, "utf8"));
7601
7815
  for (const [key, entries] of Object.entries(parsed.plugins ?? {})) {
7602
7816
  if (!key.startsWith("caddis@") || !Array.isArray(entries)) continue;
@@ -7703,7 +7917,7 @@ function createHub(opts = {}) {
7703
7917
  repos: repoPaths,
7704
7918
  now,
7705
7919
  prs: () => prHeads(github.get().data),
7706
- prsFile: path19.join(hubDir(home), "collector-prs.json")
7920
+ prsFile: path21.join(hubDir(home), "collector-prs.json")
7707
7921
  });
7708
7922
  const agents = opts.agents ?? createAgentsSource({ now, home });
7709
7923
  const coordinator = opts.coordinator ?? createCoordinatorSource({ home, now });
@@ -7796,7 +8010,7 @@ function createHub(opts = {}) {
7796
8010
  const relays = c?.relays ?? null;
7797
8011
  const out = {
7798
8012
  path: p2,
7799
- name: path19.basename(p2),
8013
+ name: path21.basename(p2),
7800
8014
  pinned: pinned.has(k3),
7801
8015
  roadmaps: c?.roadmaps ?? null,
7802
8016
  plans: c?.plans ?? null,
@@ -7908,7 +8122,7 @@ var init_state = __esm({
7908
8122
 
7909
8123
  // src/hub/actions.ts
7910
8124
  import { randomUUID } from "crypto";
7911
- import path20 from "path";
8125
+ import path22 from "path";
7912
8126
  function parseBody(raw) {
7913
8127
  if (!raw || typeof raw !== "object" || Array.isArray(raw)) throw new Refusal(400, "bad_request", "The body must be a JSON object.");
7914
8128
  const o2 = raw;
@@ -8016,7 +8230,7 @@ function createActions(opts) {
8016
8230
  args: body.what === null ? {} : { what: body.what }
8017
8231
  };
8018
8232
  try {
8019
- await appendLine(path20.join(root(), "repos", body.repo_id, "requests.jsonl"), JSON.stringify(request));
8233
+ await appendLine(path22.join(root(), "repos", body.repo_id, "requests.jsonl"), JSON.stringify(request));
8020
8234
  } catch {
8021
8235
  return refuse(new Refusal(500, "write_failed", "The hub could not write the request."), body);
8022
8236
  }
@@ -8064,8 +8278,8 @@ var init_actions = __esm({
8064
8278
 
8065
8279
  // src/hub/auth.ts
8066
8280
  import { createHash as createHash2, randomBytes as randomBytes3, timingSafeEqual } from "crypto";
8067
- import { mkdirSync as mkdirSync8, readFileSync as readFileSync15, renameSync as renameSync3, writeFileSync as writeFileSync6 } from "fs";
8068
- import path21 from "path";
8281
+ import { mkdirSync as mkdirSync9, readFileSync as readFileSync15, renameSync as renameSync4, writeFileSync as writeFileSync6 } from "fs";
8282
+ import path23 from "path";
8069
8283
  function randomToken() {
8070
8284
  return randomBytes3(32).toString("base64url");
8071
8285
  }
@@ -8162,9 +8376,9 @@ var init_auth = __esm({
8162
8376
  };
8163
8377
  const tmp = `${this.file}.${process.pid}.tmp`;
8164
8378
  try {
8165
- mkdirSync8(path21.dirname(this.file), { recursive: true });
8379
+ mkdirSync9(path23.dirname(this.file), { recursive: true });
8166
8380
  writeFileSync6(tmp, JSON.stringify(body), { mode: 384 });
8167
- renameSync3(tmp, this.file);
8381
+ renameSync4(tmp, this.file);
8168
8382
  for (const s of this.sessions) s.savedSeenAt = s.lastSeenAt;
8169
8383
  } catch {
8170
8384
  }
@@ -8321,14 +8535,14 @@ var init_phaseText = __esm({
8321
8535
  import http from "http";
8322
8536
  import { existsSync as existsSync9 } from "fs";
8323
8537
  import { readFile, stat } from "fs/promises";
8324
- import path22 from "path";
8538
+ import path24 from "path";
8325
8539
  import { fileURLToPath as fileURLToPath2 } from "url";
8326
8540
  import { promisify } from "util";
8327
8541
  import { gzip } from "zlib";
8328
8542
  function defaultUiDir() {
8329
- const here = path22.dirname(fileURLToPath2(import.meta.url));
8330
- const beside = path22.join(here, "ui");
8331
- return existsSync9(beside) ? beside : path22.resolve(here, "..", "..", "dist", "ui");
8543
+ const here = path24.dirname(fileURLToPath2(import.meta.url));
8544
+ const beside = path24.join(here, "ui");
8545
+ return existsSync9(beside) ? beside : path24.resolve(here, "..", "..", "dist", "ui");
8332
8546
  }
8333
8547
  function resolveStatic(root, urlPath) {
8334
8548
  let decoded;
@@ -8339,9 +8553,9 @@ function resolveStatic(root, urlPath) {
8339
8553
  }
8340
8554
  if (decoded.includes(String.fromCharCode(0)) || decoded.includes(String.fromCharCode(92))) return null;
8341
8555
  if (decoded.split("/").includes("..")) return null;
8342
- const base = path22.resolve(root);
8343
- const file = path22.resolve(base, "." + decoded);
8344
- return file.startsWith(base + path22.sep) ? file : null;
8556
+ const base = path24.resolve(root);
8557
+ const file = path24.resolve(base, "." + decoded);
8558
+ return file.startsWith(base + path24.sep) ? file : null;
8345
8559
  }
8346
8560
  function send(res, status5, body, extra = {}) {
8347
8561
  const text2 = JSON.stringify(body);
@@ -8433,7 +8647,7 @@ async function serveStatic(res, uiDir, urlPath) {
8433
8647
  return fail(res, 404, "not_found");
8434
8648
  }
8435
8649
  res.writeHead(200, {
8436
- "Content-Type": MIME[path22.extname(file).toLowerCase()] ?? "application/octet-stream",
8650
+ "Content-Type": MIME[path24.extname(file).toLowerCase()] ?? "application/octet-stream",
8437
8651
  "Content-Length": body.length,
8438
8652
  "Cache-Control": urlPath === "/" ? "no-store" : "public, max-age=31536000, immutable"
8439
8653
  });
@@ -8469,23 +8683,23 @@ async function startServer(opts) {
8469
8683
  fail(res, 400, "bad_url");
8470
8684
  return;
8471
8685
  }
8472
- const path26 = url.pathname;
8686
+ const path28 = url.pathname;
8473
8687
  const method = req.method ?? "GET";
8474
- if (path26.startsWith("/api/") || path26 === "/login") res.setHeader("Cache-Control", "no-store");
8688
+ if (path28.startsWith("/api/") || path28 === "/login") res.setHeader("Cache-Control", "no-store");
8475
8689
  if (!hostAllowed(req.headers.host, port)) {
8476
- if (path26 === "/login") auth.discardCode(url.searchParams.get("code") ?? "");
8690
+ if (path28 === "/login") auth.discardCode(url.searchParams.get("code") ?? "");
8477
8691
  fail(res, 403, "bad_host");
8478
8692
  return;
8479
8693
  }
8480
- if (path26 === "/api/hub/whoami" && method === "GET") {
8694
+ if (path28 === "/api/hub/whoami" && method === "GET") {
8481
8695
  if (!opts.instance) return fail(res, 404, "not_found");
8482
8696
  return send(res, 200, { instance: opts.instance });
8483
8697
  }
8484
- if (path26 === "/api/health" && method === "GET") {
8698
+ if (path28 === "/api/health" && method === "GET") {
8485
8699
  if (!keyOk(req, key)) return fail(res, 401, "unauthorized");
8486
8700
  return send(res, 200, { schema: 1, ok: true, versions });
8487
8701
  }
8488
- if (path26 === "/api/hub/code" && method === "POST") {
8702
+ if (path28 === "/api/hub/code" && method === "POST") {
8489
8703
  if (!keyOk(req, key)) return fail(res, 401, "unauthorized");
8490
8704
  try {
8491
8705
  await readBody(req);
@@ -8496,7 +8710,7 @@ async function startServer(opts) {
8496
8710
  const code = auth.mintCode();
8497
8711
  return send(res, 200, { schema: 1, code, expires_at: auth.codeExpiresAt() });
8498
8712
  }
8499
- if (path26 === "/api/hub/stop" && method === "POST") {
8713
+ if (path28 === "/api/hub/stop" && method === "POST") {
8500
8714
  if (!keyOk(req, key)) return fail(res, 401, "unauthorized");
8501
8715
  try {
8502
8716
  await readBody(req);
@@ -8514,7 +8728,7 @@ async function startServer(opts) {
8514
8728
  if (!session) return fail(res, 401, "unauthorized");
8515
8729
  const token = req.headers[CSRF_HEADER];
8516
8730
  if (typeof token !== "string" || !safeEqual(token, session.csrf)) return fail(res, 403, "bad_csrf");
8517
- if (path26 === "/api/actions" && method === "POST" && opts.actions) {
8731
+ if (path28 === "/api/actions" && method === "POST" && opts.actions) {
8518
8732
  if (!tabSessionOf(req)) return fail(res, 401, "unauthorized");
8519
8733
  const type = String(req.headers["content-type"] ?? "").split(";")[0]?.trim().toLowerCase();
8520
8734
  if (type !== "application/json") return fail(res, 415, "json_only");
@@ -8540,7 +8754,7 @@ async function startServer(opts) {
8540
8754
  if (e2 instanceof BodyTooLarge) return tooLarge(req, res);
8541
8755
  throw e2;
8542
8756
  }
8543
- if (path26 === "/api/logout" && method === "POST") {
8757
+ if (path28 === "/api/logout" && method === "POST") {
8544
8758
  auth.deleteSession(parseCookies(req.headers.cookie)[SESSION_COOKIE] ?? "");
8545
8759
  return send(res, 200, { schema: 1, ok: true }, {
8546
8760
  "Set-Cookie": `${SESSION_COOKIE}=; HttpOnly; SameSite=Strict; Path=/; Max-Age=0`
@@ -8548,11 +8762,11 @@ async function startServer(opts) {
8548
8762
  }
8549
8763
  return fail(res, 404, "not_found");
8550
8764
  }
8551
- if (path26 === "/" || path26.startsWith("/assets/") || path26.startsWith("/fonts/")) {
8552
- await serveStatic(res, uiDir, path26);
8765
+ if (path28 === "/" || path28.startsWith("/assets/") || path28.startsWith("/fonts/")) {
8766
+ await serveStatic(res, uiDir, path28);
8553
8767
  return;
8554
8768
  }
8555
- if (path26 === "/login") {
8769
+ if (path28 === "/login") {
8556
8770
  const id = auth.redeemCode(url.searchParams.get("code") ?? "");
8557
8771
  const session = id ? auth.getSession(id) : null;
8558
8772
  if (!id || !session) return fail(res, 401, "bad_code");
@@ -8564,12 +8778,12 @@ async function startServer(opts) {
8564
8778
  res.end();
8565
8779
  return;
8566
8780
  }
8567
- if (path26 === "/api/session") {
8781
+ if (path28 === "/api/session") {
8568
8782
  const session = tabSessionOf(req);
8569
8783
  if (!session) return fail(res, 401, "unauthorized");
8570
8784
  return send(res, 200, { schema: 1, csrf_token: session.csrf, versions });
8571
8785
  }
8572
- if (path26 === "/api/state") {
8786
+ if (path28 === "/api/state") {
8573
8787
  if (!tabSessionOf(req)) return fail(res, 401, "unauthorized");
8574
8788
  let state;
8575
8789
  try {
@@ -8579,7 +8793,7 @@ async function startServer(opts) {
8579
8793
  }
8580
8794
  return sendState(req, res, stripPhaseText(state));
8581
8795
  }
8582
- if (path26 === "/api/plan-phase") {
8796
+ if (path28 === "/api/plan-phase") {
8583
8797
  if (!tabSessionOf(req)) return fail(res, 401, "unauthorized");
8584
8798
  const repo = url.searchParams.get("repo") ?? "";
8585
8799
  const plan2 = url.searchParams.get("plan") ?? "";
@@ -8676,8 +8890,8 @@ __export(hub_exports, {
8676
8890
  startHub: () => startHub
8677
8891
  });
8678
8892
  import http2 from "http";
8679
- import path23 from "path";
8680
- import { mkdirSync as mkdirSync9, readFileSync as readFileSync16 } from "fs";
8893
+ import path25 from "path";
8894
+ import { mkdirSync as mkdirSync10, readFileSync as readFileSync16 } from "fs";
8681
8895
  import { randomBytes as randomBytes4 } from "crypto";
8682
8896
  function defaultVersions2() {
8683
8897
  return { cli: packageInfo().version, caddis: bundleManifest().poolVersion };
@@ -8762,7 +8976,7 @@ async function isNodeProcess(pid) {
8762
8976
  if (!r2.ok) return false;
8763
8977
  const name = (r2.stdout.split(/\r?\n/)[0] ?? "").replace(/^"([^"]*)".*$/, "$1").trim().toLowerCase();
8764
8978
  if (!name) return false;
8765
- const runtime = path23.basename(process.execPath).toLowerCase().replace(/\.exe$/, "");
8979
+ const runtime = path25.basename(process.execPath).toLowerCase().replace(/\.exe$/, "");
8766
8980
  return name.includes("node") || name.includes(runtime);
8767
8981
  }
8768
8982
  async function defaultOpener(url) {
@@ -8865,6 +9079,17 @@ async function startHub(deps = {}) {
8865
9079
  state.start();
8866
9080
  return { port: server.port, stop, done };
8867
9081
  }
9082
+ async function npmGlobalRoot(cwd) {
9083
+ const r2 = await run("npm", ["root", "-g"], { cwd, timeout: TOOL_TIMEOUT_MS * 2 });
9084
+ const root = r2.stdout.trim().split(/\r?\n/).pop() ?? "";
9085
+ return r2.ok && root ? root : null;
9086
+ }
9087
+ async function npmInstall(version, cwd) {
9088
+ const r2 = await run("npm", ["i", "-g", `@caddis/cli@${version}`], { cwd, timeout: INSTALL_TIMEOUT_MS });
9089
+ if (r2.ok) return { ok: true, detail: "" };
9090
+ const tail3 = (r2.failure ?? r2.stderr.trim().split(/\r?\n/).slice(-3).join(" ")) || `exit ${r2.code}`;
9091
+ return { ok: false, detail: tail3.slice(0, 300) };
9092
+ }
8868
9093
  async function killChild(child, deps) {
8869
9094
  if (child.pid && (deps.alive ?? pidAlive)(child.pid)) await (deps.kill ?? killTree2)(child.pid);
8870
9095
  }
@@ -8894,11 +9119,14 @@ async function hubServe(deps = {}) {
8894
9119
  process.once("exit", onExit);
8895
9120
  line(`caddis hub serving on ${hubUrl(hub2.port)} (pid ${process.pid}); stop it with: caddis hub stop`);
8896
9121
  const pkgRoot = packageInfo().root;
8897
- const newEntry = path23.join(pkgRoot, "dist", "cli.js");
9122
+ const newEntry = path25.join(pkgRoot, "dist", "cli.js");
8898
9123
  const runningVersion = (deps.versions ?? defaultVersions2()).cli ?? packageInfo().version;
9124
+ const log = (text2) => hubLog(text2, home, deps.now);
9125
+ let installing = () => false;
8899
9126
  const restarter = createRestarter({
8900
9127
  currentVersion: runningVersion,
8901
- readVersion: () => readInstalledVersion2(pkgRoot),
9128
+ // While npm replaces the package, package.json can show the new version before all files are there.
9129
+ readVersion: () => installing() ? null : readInstalledVersion2(pkgRoot),
8902
9130
  closeServer: async () => {
8903
9131
  restarting = true;
8904
9132
  await hub2.stop();
@@ -8926,7 +9154,7 @@ async function hubServe(deps = {}) {
8926
9154
  exitCode = code;
8927
9155
  resolveFinished();
8928
9156
  },
8929
- log: errorLine,
9157
+ log,
8930
9158
  every: (fn, ms) => {
8931
9159
  const t = setInterval(fn, ms);
8932
9160
  t.unref();
@@ -8934,9 +9162,31 @@ async function hubServe(deps = {}) {
8934
9162
  },
8935
9163
  ...deps.restart
8936
9164
  });
9165
+ const updater = createUpdater({
9166
+ currentVersion: runningVersion,
9167
+ packageRoot: pkgRoot,
9168
+ autoUpdate: () => readConfig(home).value.auto_update,
9169
+ fetchLatest: () => fetchLatestVersion(),
9170
+ globalRoot: () => npmGlobalRoot(hubDir(home)),
9171
+ install: (version) => npmInstall(version, hubDir(home)),
9172
+ readVersion: () => readInstalledVersion2(pkgRoot),
9173
+ // The restarter does the hand-over: close, release the lock, start the new server, exit.
9174
+ onInstalled: () => restarter.tick(),
9175
+ log,
9176
+ now: deps.now ?? Date.now,
9177
+ after: (fn, ms) => {
9178
+ const t = setTimeout(fn, ms);
9179
+ t.unref();
9180
+ return () => clearTimeout(t);
9181
+ },
9182
+ ...deps.update
9183
+ });
9184
+ installing = updater.installing;
8937
9185
  restarter.start();
9186
+ updater.start();
8938
9187
  await finished;
8939
9188
  restarter.stop();
9189
+ updater.stop();
8940
9190
  process.off("SIGINT", onSignal);
8941
9191
  process.off("SIGTERM", onSignal);
8942
9192
  process.off("exit", onExit);
@@ -8970,7 +9220,7 @@ async function hubStart(deps = {}) {
8970
9220
  return 1;
8971
9221
  }
8972
9222
  const cwd = hubDir(home);
8973
- mkdirSync9(cwd, { recursive: true });
9223
+ mkdirSync10(cwd, { recursive: true });
8974
9224
  const child = await (deps.spawn ?? defaultSpawn)(process.execPath, [entry, "hub", "serve"], { cwd });
8975
9225
  let exited = false;
8976
9226
  let exitCode = null;
@@ -9146,8 +9396,10 @@ var init_hub = __esm({
9146
9396
  init_config();
9147
9397
  init_keyfile();
9148
9398
  init_lock();
9399
+ init_hubLog();
9149
9400
  init_paths();
9150
9401
  init_restart();
9402
+ init_selfUpdate();
9151
9403
  init_actions();
9152
9404
  init_server();
9153
9405
  init_state();
@@ -9250,6 +9502,16 @@ function plan(raw) {
9250
9502
  overlay: planOverlay(p2.overlay)
9251
9503
  };
9252
9504
  }
9505
+ function dateText(v2) {
9506
+ if (typeof v2 !== "number" || !Number.isInteger(v2) || v2 < 0) return null;
9507
+ const d3 = new Date(v2 * 1e3);
9508
+ return Number.isNaN(d3.getTime()) ? null : d3.toISOString().slice(0, 10);
9509
+ }
9510
+ function donePlan(raw) {
9511
+ const p2 = rec3(raw);
9512
+ if (p2.error !== void 0 || !safePlanPath(str5(p2.path))) return null;
9513
+ return { path: str5(p2.path), title: str5(p2.title), closed_at: dateText(p2.closed_at), phases: int(p2.phases), pr: posInt(p2.pr) ? p2.pr : null };
9514
+ }
9253
9515
  function planOverlay(raw) {
9254
9516
  const o2 = rec3(raw);
9255
9517
  if (!posInt(o2.pr)) return null;
@@ -9287,6 +9549,7 @@ function exportData(collect, opts) {
9287
9549
  commit,
9288
9550
  roadmaps: arr2(slot.roadmaps).map(roadmap),
9289
9551
  plans: arr2(rec3(repo.plans).plans).map(plan).filter((p2) => p2 !== null),
9552
+ done_plans: arr2(rec3(rec3(repo.plans).done).plans).map(donePlan).filter((p2) => p2 !== null),
9290
9553
  overlay: repoOverlay(rec3(repo.plans).overlay)
9291
9554
  };
9292
9555
  }
@@ -9346,7 +9609,7 @@ var init_data = __esm({
9346
9609
 
9347
9610
  // src/hub/export/privacy.ts
9348
9611
  import { lstatSync, readdirSync as readdirSync5, readFileSync as readFileSync17 } from "fs";
9349
- import path24 from "path";
9612
+ import path26 from "path";
9350
9613
  function parseAllowedUrls(text2) {
9351
9614
  const exact = /* @__PURE__ */ new Set();
9352
9615
  const templates = [];
@@ -9365,7 +9628,7 @@ function walk(dir, base = "") {
9365
9628
  const out = [];
9366
9629
  for (const name of readdirSync5(dir).sort()) {
9367
9630
  const rel = base ? `${base}/${name}` : name;
9368
- const full = path24.join(dir, name);
9631
+ const full = path26.join(dir, name);
9369
9632
  if (lstatSync(full).isDirectory()) out.push(...walk(full, rel));
9370
9633
  else out.push(rel);
9371
9634
  }
@@ -9398,16 +9661,25 @@ function scanUrls(file, text2, opts, hits) {
9398
9661
  hits.push({ file, offset: m2.index ?? 0, rule: "url-not-allowed" });
9399
9662
  }
9400
9663
  }
9664
+ function isPrivateText(text2, deny) {
9665
+ if (PRIVATE_NAMES.some((name) => text2.includes(name))) return true;
9666
+ if (PATTERNS.some(({ re }) => new RegExp(re.source, re.flags.replace("g", "")).test(text2))) return true;
9667
+ return deny.some((value) => {
9668
+ if (value === "") return false;
9669
+ const re = isNumeric(value) ? new RegExp(`(?<![0-9])${escapeRe(value)}(?![0-9])`, "i") : new RegExp(escapeRe(value), "i");
9670
+ return re.test(text2);
9671
+ });
9672
+ }
9401
9673
  function scanExport(dir, opts) {
9402
9674
  const hits = [];
9403
9675
  for (const file of walk(dir)) {
9404
- const full = path24.join(dir, ...file.split("/"));
9676
+ const full = path26.join(dir, ...file.split("/"));
9405
9677
  if (lstatSync(full).isSymbolicLink()) {
9406
9678
  hits.push({ file, offset: 0, rule: "symbolic-link" });
9407
9679
  continue;
9408
9680
  }
9409
9681
  const buf = readFileSync17(full);
9410
- const binary = BINARY_EXT.has(path24.extname(file).toLowerCase());
9682
+ const binary = BINARY_EXT.has(path26.extname(file).toLowerCase());
9411
9683
  const text2 = binary ? null : buf.toString("utf8");
9412
9684
  scanDeny(file, buf, text2, opts.deny, hits);
9413
9685
  if (text2 === null) continue;
@@ -9488,15 +9760,15 @@ import {
9488
9760
  copyFileSync,
9489
9761
  existsSync as existsSync10,
9490
9762
  lstatSync as lstatSync2,
9491
- mkdirSync as mkdirSync10,
9763
+ mkdirSync as mkdirSync11,
9492
9764
  readdirSync as readdirSync6,
9493
9765
  readFileSync as readFileSync18,
9494
9766
  rmSync as rmSync4,
9495
- statSync as statSync3,
9767
+ statSync as statSync4,
9496
9768
  writeFileSync as writeFileSync7
9497
9769
  } from "fs";
9498
9770
  import os6 from "os";
9499
- import path25 from "path";
9771
+ import path27 from "path";
9500
9772
  function prsForCollector(gh, repo) {
9501
9773
  if (!Array.isArray(gh)) return null;
9502
9774
  const heads = [];
@@ -9516,7 +9788,7 @@ function prsForCollector(gh, repo) {
9516
9788
  }
9517
9789
  function holdsLink(dir) {
9518
9790
  for (const name of readdirSync6(dir)) {
9519
- const full = path25.join(dir, name);
9791
+ const full = path27.join(dir, name);
9520
9792
  const st = lstatSync2(full);
9521
9793
  if (st.isSymbolicLink()) return true;
9522
9794
  if (st.isDirectory() && holdsLink(full)) return true;
@@ -9535,7 +9807,7 @@ function checkOut(out, repo) {
9535
9807
  if (st.isSymbolicLink()) return "--out is a link";
9536
9808
  if (!st.isDirectory()) return "--out is a file";
9537
9809
  if (readdirSync6(out).length === 0) return null;
9538
- if (!existsSync10(path25.join(out, MARKER)) || lstatSync2(path25.join(out, MARKER)).isSymbolicLink()) {
9810
+ if (!existsSync10(path27.join(out, MARKER)) || lstatSync2(path27.join(out, MARKER)).isSymbolicLink()) {
9539
9811
  return `--out is not empty and has no ${MARKER} marker: this command did not make it`;
9540
9812
  }
9541
9813
  if (holdsLink(out)) return "--out holds a link";
@@ -9561,33 +9833,33 @@ function notFoundPage() {
9561
9833
  `;
9562
9834
  }
9563
9835
  function copyFixedSet(dist, dest) {
9564
- mkdirSync10(path25.join(dest, "assets"), { recursive: true });
9565
- mkdirSync10(path25.join(dest, "fonts"), { recursive: true });
9566
- mkdirSync10(path25.join(dest, "licenses"), { recursive: true });
9567
- copyFileSync(path25.join(dist, "index.html"), path25.join(dest, "index.html"));
9568
- for (const name of readdirSync6(path25.join(dist, "assets"))) {
9569
- const from = path25.join(dist, "assets", name);
9570
- if (lstatSync2(from).isFile()) copyFileSync(from, path25.join(dest, "assets", name));
9571
- }
9572
- const fonts = path25.join(dist, "fonts");
9836
+ mkdirSync11(path27.join(dest, "assets"), { recursive: true });
9837
+ mkdirSync11(path27.join(dest, "fonts"), { recursive: true });
9838
+ mkdirSync11(path27.join(dest, "licenses"), { recursive: true });
9839
+ copyFileSync(path27.join(dist, "index.html"), path27.join(dest, "index.html"));
9840
+ for (const name of readdirSync6(path27.join(dist, "assets"))) {
9841
+ const from = path27.join(dist, "assets", name);
9842
+ if (lstatSync2(from).isFile()) copyFileSync(from, path27.join(dest, "assets", name));
9843
+ }
9844
+ const fonts = path27.join(dist, "fonts");
9573
9845
  if (isDir2(fonts)) {
9574
9846
  for (const name of readdirSync6(fonts)) {
9575
- const from = path25.join(fonts, name);
9847
+ const from = path27.join(fonts, name);
9576
9848
  if (!lstatSync2(from).isFile()) continue;
9577
- if (name.endsWith(".woff2")) copyFileSync(from, path25.join(dest, "fonts", name));
9849
+ if (name.endsWith(".woff2")) copyFileSync(from, path27.join(dest, "fonts", name));
9578
9850
  }
9579
9851
  }
9580
- const licenses = path25.join(dist, "licenses");
9852
+ const licenses = path27.join(dist, "licenses");
9581
9853
  if (isDir2(licenses)) {
9582
9854
  for (const name of readdirSync6(licenses)) {
9583
- const from = path25.join(licenses, name);
9584
- if (lstatSync2(from).isFile() && /^(OFL-[A-Za-z]+|LICENSE-Lucide)\.txt$/.test(name)) copyFileSync(from, path25.join(dest, "licenses", name));
9855
+ const from = path27.join(licenses, name);
9856
+ if (lstatSync2(from).isFile() && /^(OFL-[A-Za-z]+|LICENSE-Lucide)\.txt$/.test(name)) copyFileSync(from, path27.join(dest, "licenses", name));
9585
9857
  }
9586
9858
  }
9587
9859
  }
9588
9860
  function countFiles(dir) {
9589
9861
  return readdirSync6(dir).reduce((n, name) => {
9590
- const full = path25.join(dir, name);
9862
+ const full = path27.join(dir, name);
9591
9863
  return n + (lstatSync2(full).isDirectory() ? countFiles(full) : name === MARKER ? 0 : 1);
9592
9864
  }, 0);
9593
9865
  }
@@ -9609,7 +9881,7 @@ async function hubExport(args, deps = {}) {
9609
9881
  return 2;
9610
9882
  }
9611
9883
  if (args.check !== void 0) {
9612
- const dir = path25.resolve(args.check);
9884
+ const dir = path27.resolve(args.check);
9613
9885
  if (!isDir2(dir)) {
9614
9886
  err(`error: --check folder not found: ${args.check}`);
9615
9887
  return 1;
@@ -9633,9 +9905,9 @@ async function hubExport(args, deps = {}) {
9633
9905
  err("error: --commit must be 7 to 40 hex characters");
9634
9906
  return 2;
9635
9907
  }
9636
- const repo = path25.resolve(args.repo);
9637
- const outDir = path25.resolve(args.out);
9638
- if (!existsSync10(path25.join(repo, ".git")) || !(isDir2(path25.join(repo, ".caddis", "roadmaps")) || isDir2(path25.join(repo, ".caddis", "plans")))) {
9908
+ const repo = path27.resolve(args.repo);
9909
+ const outDir = path27.resolve(args.out);
9910
+ if (!existsSync10(path27.join(repo, ".git")) || !(isDir2(path27.join(repo, ".caddis", "roadmaps")) || isDir2(path27.join(repo, ".caddis", "plans")))) {
9639
9911
  err("error: --repo must be a git checkout with .caddis/roadmaps/ or .caddis/plans/");
9640
9912
  return 2;
9641
9913
  }
@@ -9644,8 +9916,8 @@ async function hubExport(args, deps = {}) {
9644
9916
  err(`error: ${refused}`);
9645
9917
  return 2;
9646
9918
  }
9647
- const dist = deps.distDir ?? path25.join(packageInfo().root, "dist", "export");
9648
- if (!existsSync10(path25.join(dist, "index.html")) || !isDir2(path25.join(dist, "assets"))) {
9919
+ const dist = deps.distDir ?? path27.join(packageInfo().root, "dist", "export");
9920
+ if (!existsSync10(path27.join(dist, "index.html")) || !isDir2(path27.join(dist, "assets"))) {
9649
9921
  err(`error: the export app is not built (${dist}). Run: npm run build:ui`);
9650
9922
  return 1;
9651
9923
  }
@@ -9695,7 +9967,7 @@ async function hubExport(args, deps = {}) {
9695
9967
  if (args.prs !== void 0) {
9696
9968
  let gh = null;
9697
9969
  try {
9698
- gh = JSON.parse(readFileSync18(path25.resolve(args.prs), "utf8"));
9970
+ gh = JSON.parse(readFileSync18(path27.resolve(args.prs), "utf8"));
9699
9971
  } catch {
9700
9972
  gh = null;
9701
9973
  }
@@ -9705,7 +9977,7 @@ async function hubExport(args, deps = {}) {
9705
9977
  } else {
9706
9978
  prsFile = `${outDir}.prs-${process.pid}.json`;
9707
9979
  try {
9708
- mkdirSync10(path25.dirname(prsFile), { recursive: true });
9980
+ mkdirSync11(path27.dirname(prsFile), { recursive: true });
9709
9981
  writeFileSync7(prsFile, JSON.stringify(body));
9710
9982
  } catch (error) {
9711
9983
  rmSync4(prsFile, { force: true });
@@ -9723,6 +9995,14 @@ async function hubExport(args, deps = {}) {
9723
9995
  if (data.overlay?.state === "on") out(`[OVERLAY] on: ${data.overlay.count} plan(s) from PR branches`);
9724
9996
  else if (data.overlay?.state === "off") out(`[OVERLAY] off: ${data.overlay.reason ?? "unknown"}`);
9725
9997
  let deny = derivedDeny(first.value, machine);
9998
+ const dropPrivateDone = (page) => {
9999
+ const rows = page.done_plans ?? [];
10000
+ const kept = rows.filter((p2) => !isPrivateText(p2.path, deny) && !isPrivateText(p2.title, deny));
10001
+ if (kept.length === rows.length) return;
10002
+ page.done_plans = kept;
10003
+ out(`[DONE] ${rows.length - kept.length} done plan(s) left out: private words in the name`);
10004
+ };
10005
+ dropPrivateDone(data);
9726
10006
  const scanOpts = () => ({
9727
10007
  deny,
9728
10008
  github: args.github ?? null,
@@ -9732,12 +10012,12 @@ async function hubExport(args, deps = {}) {
9732
10012
  const build = (page) => {
9733
10013
  rmSync4(staging, { recursive: true, force: true });
9734
10014
  copyFixedSet(dist, staging);
9735
- const indexPath = path25.join(staging, "index.html");
10015
+ const indexPath = path27.join(staging, "index.html");
9736
10016
  const html = readFileSync18(indexPath, "utf8");
9737
10017
  if (!html.includes(PLACEHOLDER)) throw new Error("the built index.html has no data placeholder");
9738
10018
  const block = `<script type="application/json" id="caddis-export-data">${escapeJson(JSON.stringify(page))}</script>`;
9739
10019
  writeFileSync7(indexPath, html.replace(PLACEHOLDER, () => block));
9740
- writeFileSync7(path25.join(staging, "404.html"), notFoundPage());
10020
+ writeFileSync7(path27.join(staging, "404.html"), notFoundPage());
9741
10021
  };
9742
10022
  try {
9743
10023
  build(data);
@@ -9753,6 +10033,7 @@ async function hubExport(args, deps = {}) {
9753
10033
  mainOnly.overlay = { state: "off", reason: "privacy hit in branch content", count: 0 };
9754
10034
  deny = [.../* @__PURE__ */ new Set([...deny, ...derivedDeny(second.value, machine)])];
9755
10035
  data = mainOnly;
10036
+ dropPrivateDone(data);
9756
10037
  build(data);
9757
10038
  hits = scanExport(staging, scanOpts());
9758
10039
  }
@@ -9762,10 +10043,10 @@ async function hubExport(args, deps = {}) {
9762
10043
  rmSync4(staging, { recursive: true, force: true });
9763
10044
  return 3;
9764
10045
  }
9765
- mkdirSync10(path25.dirname(outDir), { recursive: true });
10046
+ mkdirSync11(path27.dirname(outDir), { recursive: true });
9766
10047
  if (existsSync10(outDir)) rmSync4(outDir, { recursive: true, force: true });
9767
10048
  renameWithRetry(staging, outDir);
9768
- writeFileSync7(path25.join(outDir, MARKER), "written by caddis hub export\n");
10049
+ writeFileSync7(path27.join(outDir, MARKER), "written by caddis hub export\n");
9769
10050
  out(`[EXPORT] ${countFiles(outDir)} file(s) in ${outDir}`);
9770
10051
  return 0;
9771
10052
  } catch (error) {
@@ -9795,18 +10076,18 @@ var init_export = __esm({
9795
10076
  FIXED_FILES = ["index.html", "404.html"];
9796
10077
  isDir2 = (p2) => {
9797
10078
  try {
9798
- return statSync3(p2).isDirectory();
10079
+ return statSync4(p2).isDirectory();
9799
10080
  } catch {
9800
10081
  return false;
9801
10082
  }
9802
10083
  };
9803
10084
  samePath = (a, b3) => {
9804
- const norm = (p2) => path25.resolve(p2).replace(/[\\/]+$/, "").toLowerCase();
10085
+ const norm = (p2) => path27.resolve(p2).replace(/[\\/]+$/, "").toLowerCase();
9805
10086
  return norm(a) === norm(b3);
9806
10087
  };
9807
10088
  isInside = (child, parent) => {
9808
- const rel = path25.relative(path25.resolve(parent), path25.resolve(child));
9809
- return rel !== "" && !rel.startsWith("..") && !path25.isAbsolute(rel);
10089
+ const rel = path27.relative(path27.resolve(parent), path27.resolve(child));
10090
+ return rel !== "" && !rel.startsWith("..") && !path27.isAbsolute(rel);
9810
10091
  };
9811
10092
  NOT_FOUND_SCRIPT = "var p=location.pathname.split('/');var f=p.pop();p.pop();var m=/^([A-Za-z0-9._-]+)\\.html$/.exec(f);if(m&&p.length>1)location.replace(p.join('/')+'/#/roadmap/'+encodeURIComponent(m[1]));";
9812
10093
  }
@@ -9867,14 +10148,14 @@ function* pluginBlocks(stdout) {
9867
10148
  if (current) yield current;
9868
10149
  }
9869
10150
  async function detect() {
9870
- const path26 = await findBin(BIN);
9871
- if (!path26) {
10151
+ const path28 = await findBin(BIN);
10152
+ if (!path28) {
9872
10153
  return { present: false, note: "no `claude` binary on PATH" };
9873
10154
  }
9874
10155
  const version = await run(BIN, ["--version"], { timeout: 2e4 });
9875
10156
  return {
9876
10157
  present: true,
9877
- path: path26,
10158
+ path: path28,
9878
10159
  agentVersion: version.ok ? version.stdout.trim().split(/\s+/)[0] || void 0 : void 0,
9879
10160
  note: version.ok ? void 0 : "binary found but `claude --version` failed"
9880
10161
  };