@caddis/cli 0.4.88 → 0.4.90

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 (97) hide show
  1. package/README.md +46 -0
  2. package/bundles/antigravity-plugin/agents/preflight.md +4 -0
  3. package/bundles/antigravity-plugin/plugin.json +1 -1
  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_fleet.py +37 -10
  16. package/bundles/antigravity-plugin/scripts/caddis_guide.json +16 -11
  17. package/bundles/antigravity-plugin/scripts/caddis_handoff.py +370 -0
  18. package/bundles/antigravity-plugin/scripts/caddis_heartbeat.py +339 -0
  19. package/bundles/antigravity-plugin/scripts/caddis_hub_collect.py +37 -8
  20. package/bundles/antigravity-plugin/scripts/caddis_roadmap_run.py +130 -63
  21. package/bundles/antigravity-plugin/scripts/caddis_routing.py +36 -0
  22. package/bundles/antigravity-plugin/scripts/caddis_todo.py +55 -10
  23. package/bundles/antigravity-plugin/scripts/caddis_workstreams.py +35 -12
  24. package/bundles/antigravity-plugin/scripts/schemas/hub-collect.schema.json +42 -0
  25. package/bundles/antigravity-plugin/scripts/schemas/hub-plans.schema.json +23 -0
  26. package/bundles/antigravity-plugin/session_end_agy.py +26 -1
  27. package/bundles/antigravity-plugin/skills/code-review/SKILL.md +2 -0
  28. package/bundles/antigravity-plugin/skills/coordinate/SKILL.md +5 -3
  29. package/bundles/antigravity-plugin/skills/cross-review/SKILL.md +1 -0
  30. package/bundles/antigravity-plugin/skills/feature-plan/SKILL.md +47 -19
  31. package/bundles/antigravity-plugin/skills/fleet-open/SKILL.md +1 -1
  32. package/bundles/antigravity-plugin/skills/handoff/SKILL.md +82 -7
  33. package/bundles/antigravity-plugin/skills/implement/SKILL.md +86 -6
  34. package/bundles/antigravity-plugin/skills/park/SKILL.md +1 -0
  35. package/bundles/antigravity-plugin/skills/preflight/SKILL.md +1 -0
  36. package/bundles/antigravity-plugin/skills/roadmap/assets/plan-resume-prompt.md +8 -1
  37. package/bundles/antigravity-plugin/warm_start_agy.py +29 -1
  38. package/bundles/antigravity-plugin-extras/plugin.json +1 -1
  39. package/bundles/antigravity-plugin-extras/skills/cross-review/SKILL.md +1 -0
  40. package/bundles/codex/.codex/skills/coding/code-review/SKILL.md +2 -0
  41. package/bundles/codex/.codex/skills/workflow/preflight/SKILL.md +1 -0
  42. package/bundles/codex/.codex/skills/workflow/roadmap/assets/plan-resume-prompt.md +8 -1
  43. package/bundles/manifest.json +3 -3
  44. package/dist/allowed-urls.txt +3 -2
  45. package/dist/cli.js +554 -275
  46. package/dist/export/assets/export-B7BBDg5I.js +150 -0
  47. package/dist/export/assets/export-HxTgj3z2.css +1 -0
  48. package/dist/export/assets/mark-anim-DZa95SHo.webp +0 -0
  49. package/dist/export/assets/mark-still-CcPgBc_-.png +0 -0
  50. package/dist/export/fonts/ibm-plex-mono-400.6d569bb7.woff2 +0 -0
  51. package/dist/export/fonts/ibm-plex-mono-700.9f478677.woff2 +0 -0
  52. package/dist/export/fonts/ibm-plex-sans-400.17fc1ce7.woff2 +0 -0
  53. package/dist/export/fonts/ibm-plex-sans-500.dcc69acf.woff2 +0 -0
  54. package/dist/export/fonts/ibm-plex-sans-600.d4dad061.woff2 +0 -0
  55. package/dist/export/fonts/ibm-plex-sans-700.40d9a530.woff2 +0 -0
  56. package/dist/export/index.html +2 -2
  57. package/dist/export/licenses/{OFL-MapleMono.txt → OFL-IBMPlexMono.txt} +4 -4
  58. package/dist/{ui/licenses/OFL-MapleMono.txt → export/licenses/OFL-IBMPlexSans.txt} +4 -4
  59. package/dist/ui/assets/{Activity-C9TCizJV.js → Activity-DZKPMOeV.js} +1 -1
  60. package/dist/ui/assets/Guide-5ZFfL6sl.js +9 -0
  61. package/dist/ui/assets/Guide-Dnsb-TRd.css +1 -0
  62. package/dist/ui/assets/RoadmapTab-DPsiSmIF.js +31 -0
  63. package/dist/ui/assets/index-DGlNAmeA.css +1 -0
  64. package/dist/ui/assets/index-xl156OCN.js +231 -0
  65. package/dist/ui/assets/mark-anim-DZa95SHo.webp +0 -0
  66. package/dist/ui/assets/mark-still-CcPgBc_-.png +0 -0
  67. package/dist/ui/fonts/ibm-plex-mono-400.6d569bb7.woff2 +0 -0
  68. package/dist/ui/fonts/ibm-plex-mono-700.9f478677.woff2 +0 -0
  69. package/dist/ui/fonts/ibm-plex-sans-400.17fc1ce7.woff2 +0 -0
  70. package/dist/ui/fonts/ibm-plex-sans-500.dcc69acf.woff2 +0 -0
  71. package/dist/ui/fonts/ibm-plex-sans-600.d4dad061.woff2 +0 -0
  72. package/dist/ui/fonts/ibm-plex-sans-700.40d9a530.woff2 +0 -0
  73. package/dist/ui/index.html +2 -2
  74. package/dist/{export/licenses/OFL-Atkinson.txt → ui/licenses/OFL-IBMPlexMono.txt} +3 -3
  75. package/dist/ui/licenses/{OFL-Atkinson.txt → OFL-IBMPlexSans.txt} +3 -3
  76. package/package.json +4 -1
  77. package/dist/export/assets/export-CEtCs5rg.css +0 -1
  78. package/dist/export/assets/export-v-kcNvPW.js +0 -150
  79. package/dist/export/assets/mark-small-B1q4Vk3J.svg +0 -8
  80. package/dist/export/fonts/atkinson-400.849ae6f0.woff2 +0 -0
  81. package/dist/export/fonts/atkinson-500.21d6ef26.woff2 +0 -0
  82. package/dist/export/fonts/atkinson-600.ce9f3210.woff2 +0 -0
  83. package/dist/export/fonts/atkinson-700.3a9cc18a.woff2 +0 -0
  84. package/dist/export/fonts/maple-mono-400.071799fd.woff2 +0 -0
  85. package/dist/export/fonts/maple-mono-700.1e17b237.woff2 +0 -0
  86. package/dist/ui/assets/Guide-6aEYW9oW.js +0 -9
  87. package/dist/ui/assets/Guide-zcVFGUxR.css +0 -1
  88. package/dist/ui/assets/RoadmapTab-hUK2kzCW.js +0 -31
  89. package/dist/ui/assets/index-DE7v-v_o.css +0 -1
  90. package/dist/ui/assets/index-d44hkSAE.js +0 -221
  91. package/dist/ui/assets/mark-small-B1q4Vk3J.svg +0 -8
  92. package/dist/ui/fonts/atkinson-400.849ae6f0.woff2 +0 -0
  93. package/dist/ui/fonts/atkinson-500.21d6ef26.woff2 +0 -0
  94. package/dist/ui/fonts/atkinson-600.ce9f3210.woff2 +0 -0
  95. package/dist/ui/fonts/atkinson-700.3a9cc18a.woff2 +0 -0
  96. package/dist/ui/fonts/maple-mono-400.071799fd.woff2 +0 -0
  97. package/dist/ui/fonts/maple-mono-700.1e17b237.woff2 +0 -0
package/dist/cli.js CHANGED
@@ -639,8 +639,8 @@ var require_help = __commonJS({
639
639
  * @param {string} str
640
640
  * @returns {number}
641
641
  */
642
- displayWidth(str5) {
643
- return stripColor(str5).length;
642
+ displayWidth(str6) {
643
+ return stripColor(str6).length;
644
644
  }
645
645
  /**
646
646
  * Style the title for displaying in the help. Called with 'Usage:', 'Options:', etc.
@@ -648,11 +648,11 @@ var require_help = __commonJS({
648
648
  * @param {string} str
649
649
  * @returns {string}
650
650
  */
651
- styleTitle(str5) {
652
- return str5;
651
+ styleTitle(str6) {
652
+ return str6;
653
653
  }
654
- styleUsage(str5) {
655
- return str5.split(" ").map((word) => {
654
+ styleUsage(str6) {
655
+ return str6.split(" ").map((word) => {
656
656
  if (word === "[options]") return this.styleOptionText(word);
657
657
  if (word === "[command]") return this.styleSubcommandText(word);
658
658
  if (word[0] === "[" || word[0] === "<")
@@ -660,46 +660,46 @@ var require_help = __commonJS({
660
660
  return this.styleCommandText(word);
661
661
  }).join(" ");
662
662
  }
663
- styleCommandDescription(str5) {
664
- return this.styleDescriptionText(str5);
663
+ styleCommandDescription(str6) {
664
+ return this.styleDescriptionText(str6);
665
665
  }
666
- styleOptionDescription(str5) {
667
- return this.styleDescriptionText(str5);
666
+ styleOptionDescription(str6) {
667
+ return this.styleDescriptionText(str6);
668
668
  }
669
- styleSubcommandDescription(str5) {
670
- return this.styleDescriptionText(str5);
669
+ styleSubcommandDescription(str6) {
670
+ return this.styleDescriptionText(str6);
671
671
  }
672
- styleArgumentDescription(str5) {
673
- return this.styleDescriptionText(str5);
672
+ styleArgumentDescription(str6) {
673
+ return this.styleDescriptionText(str6);
674
674
  }
675
- styleDescriptionText(str5) {
676
- return str5;
675
+ styleDescriptionText(str6) {
676
+ return str6;
677
677
  }
678
- styleOptionTerm(str5) {
679
- return this.styleOptionText(str5);
678
+ styleOptionTerm(str6) {
679
+ return this.styleOptionText(str6);
680
680
  }
681
- styleSubcommandTerm(str5) {
682
- return str5.split(" ").map((word) => {
681
+ styleSubcommandTerm(str6) {
682
+ return str6.split(" ").map((word) => {
683
683
  if (word === "[options]") return this.styleOptionText(word);
684
684
  if (word[0] === "[" || word[0] === "<")
685
685
  return this.styleArgumentText(word);
686
686
  return this.styleSubcommandText(word);
687
687
  }).join(" ");
688
688
  }
689
- styleArgumentTerm(str5) {
690
- return this.styleArgumentText(str5);
689
+ styleArgumentTerm(str6) {
690
+ return this.styleArgumentText(str6);
691
691
  }
692
- styleOptionText(str5) {
693
- return str5;
692
+ styleOptionText(str6) {
693
+ return str6;
694
694
  }
695
- styleArgumentText(str5) {
696
- return str5;
695
+ styleArgumentText(str6) {
696
+ return str6;
697
697
  }
698
- styleSubcommandText(str5) {
699
- return str5;
698
+ styleSubcommandText(str6) {
699
+ return str6;
700
700
  }
701
- styleCommandText(str5) {
702
- return str5;
701
+ styleCommandText(str6) {
702
+ return str6;
703
703
  }
704
704
  /**
705
705
  * Calculate the pad width from the maximum term length.
@@ -722,8 +722,8 @@ var require_help = __commonJS({
722
722
  * @param {string} str
723
723
  * @returns {boolean}
724
724
  */
725
- preformatted(str5) {
726
- return /\n[^\S\r\n]/.test(str5);
725
+ preformatted(str6) {
726
+ return /\n[^\S\r\n]/.test(str6);
727
727
  }
728
728
  /**
729
729
  * Format the "item", which consists of a term and description. Pad the term and wrap the description, indenting the following lines.
@@ -769,9 +769,9 @@ ${itemIndentStr}`);
769
769
  * @param {number} width
770
770
  * @returns {string}
771
771
  */
772
- boxWrap(str5, width) {
773
- if (width < this.minWidthToWrap) return str5;
774
- const rawLines = str5.split(/\r\n|\n/);
772
+ boxWrap(str6, width) {
773
+ if (width < this.minWidthToWrap) return str6;
774
+ const rawLines = str6.split(/\r\n|\n/);
775
775
  const chunkPattern = /[\s]*[^\s]+/g;
776
776
  const wrappedLines = [];
777
777
  rawLines.forEach((line2) => {
@@ -799,9 +799,9 @@ ${itemIndentStr}`);
799
799
  return wrappedLines.join("\n");
800
800
  }
801
801
  };
802
- function stripColor(str5) {
802
+ function stripColor(str6) {
803
803
  const sgrPattern = /\x1b\[\d*(;\d*)*m/g;
804
- return str5.replace(sgrPattern, "");
804
+ return str6.replace(sgrPattern, "");
805
805
  }
806
806
  exports.Help = Help2;
807
807
  exports.stripColor = stripColor;
@@ -1073,9 +1073,9 @@ var require_option = __commonJS({
1073
1073
  return option.negate === (negativeValue === value);
1074
1074
  }
1075
1075
  };
1076
- function camelcase(str5) {
1077
- return str5.split("-").reduce((str6, word) => {
1078
- return str6 + word[0].toUpperCase() + word.slice(1);
1076
+ function camelcase(str6) {
1077
+ return str6.split("-").reduce((str7, word) => {
1078
+ return str7 + word[0].toUpperCase() + word.slice(1);
1079
1079
  });
1080
1080
  }
1081
1081
  function splitOptionFlags(flags) {
@@ -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 path24 = __require("path");
1212
+ var path26 = __require("path");
1213
1213
  var fs = __require("fs");
1214
1214
  var process3 = __require("process");
1215
1215
  var { Argument: Argument2, humanReadableArgName } = require_argument();
@@ -1258,14 +1258,14 @@ var require_command = __commonJS({
1258
1258
  this._showSuggestionAfterError = true;
1259
1259
  this._savedState = null;
1260
1260
  this._outputConfiguration = {
1261
- writeOut: (str5) => process3.stdout.write(str5),
1262
- writeErr: (str5) => process3.stderr.write(str5),
1263
- outputError: (str5, write) => write(str5),
1261
+ writeOut: (str6) => process3.stdout.write(str6),
1262
+ writeErr: (str6) => process3.stderr.write(str6),
1263
+ outputError: (str6, write) => write(str6),
1264
1264
  getOutHelpWidth: () => process3.stdout.isTTY ? process3.stdout.columns : void 0,
1265
1265
  getErrHelpWidth: () => process3.stderr.isTTY ? process3.stderr.columns : void 0,
1266
1266
  getOutHasColors: () => useColor() ?? (process3.stdout.isTTY && process3.stdout.hasColors?.()),
1267
1267
  getErrHasColors: () => useColor() ?? (process3.stderr.isTTY && process3.stderr.hasColors?.()),
1268
- stripColor: (str5) => stripColor(str5)
1268
+ stripColor: (str6) => stripColor(str6)
1269
1269
  };
1270
1270
  this._hidden = false;
1271
1271
  this._helpOption = void 0;
@@ -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 = path24.resolve(baseDir, baseName);
2225
+ const localBin = path26.resolve(baseDir, baseName);
2226
2226
  if (fs.existsSync(localBin)) return localBin;
2227
- if (sourceExt.includes(path24.extname(baseName))) return void 0;
2227
+ if (sourceExt.includes(path26.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 = path24.resolve(
2246
- path24.dirname(resolvedScriptPath),
2245
+ executableDir = path26.resolve(
2246
+ path26.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 = path24.basename(
2253
+ const legacyName = path26.basename(
2254
2254
  this._scriptPath,
2255
- path24.extname(this._scriptPath)
2255
+ path26.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(path24.extname(executableFile));
2266
+ launchWithNode = sourceExt.includes(path26.extname(executableFile));
2267
2267
  let proc;
2268
2268
  if (process3.platform !== "win32") {
2269
2269
  if (launchWithNode) {
@@ -2989,18 +2989,18 @@ Expecting one of '${allowedValues.join("', '")}'`);
2989
2989
  * @param {string} [description]
2990
2990
  * @return {(this | string | undefined)} `this` command for chaining, or version string if no arguments
2991
2991
  */
2992
- version(str5, flags, description) {
2993
- if (str5 === void 0) return this._version;
2994
- this._version = str5;
2992
+ version(str6, flags, description) {
2993
+ if (str6 === void 0) return this._version;
2994
+ this._version = str6;
2995
2995
  flags = flags || "-V, --version";
2996
2996
  description = description || "output the version number";
2997
2997
  const versionOption = this.createOption(flags, description);
2998
2998
  this._versionOptionName = versionOption.attributeName();
2999
2999
  this._registerOption(versionOption);
3000
3000
  this.on("option:" + versionOption.name(), () => {
3001
- this._outputConfiguration.writeOut(`${str5}
3001
+ this._outputConfiguration.writeOut(`${str6}
3002
3002
  `);
3003
- this._exit(0, "commander.version", str5);
3003
+ this._exit(0, "commander.version", str6);
3004
3004
  });
3005
3005
  return this;
3006
3006
  }
@@ -3011,10 +3011,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
3011
3011
  * @param {object} [argsDescription]
3012
3012
  * @return {(string|Command)}
3013
3013
  */
3014
- description(str5, argsDescription) {
3015
- if (str5 === void 0 && argsDescription === void 0)
3014
+ description(str6, argsDescription) {
3015
+ if (str6 === void 0 && argsDescription === void 0)
3016
3016
  return this._description;
3017
- this._description = str5;
3017
+ this._description = str6;
3018
3018
  if (argsDescription) {
3019
3019
  this._argsDescription = argsDescription;
3020
3020
  }
@@ -3026,9 +3026,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
3026
3026
  * @param {string} [str]
3027
3027
  * @return {(string|Command)}
3028
3028
  */
3029
- summary(str5) {
3030
- if (str5 === void 0) return this._summary;
3031
- this._summary = str5;
3029
+ summary(str6) {
3030
+ if (str6 === void 0) return this._summary;
3031
+ this._summary = str6;
3032
3032
  return this;
3033
3033
  }
3034
3034
  /**
@@ -3076,8 +3076,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
3076
3076
  * @param {string} [str]
3077
3077
  * @return {(string|Command)}
3078
3078
  */
3079
- usage(str5) {
3080
- if (str5 === void 0) {
3079
+ usage(str6) {
3080
+ if (str6 === void 0) {
3081
3081
  if (this._usage) return this._usage;
3082
3082
  const args = this.registeredArguments.map((arg) => {
3083
3083
  return humanReadableArgName(arg);
@@ -3088,7 +3088,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
3088
3088
  this.registeredArguments.length ? args : []
3089
3089
  ).join(" ");
3090
3090
  }
3091
- this._usage = str5;
3091
+ this._usage = str6;
3092
3092
  return this;
3093
3093
  }
3094
3094
  /**
@@ -3097,9 +3097,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
3097
3097
  * @param {string} [str]
3098
3098
  * @return {(string|Command)}
3099
3099
  */
3100
- name(str5) {
3101
- if (str5 === void 0) return this._name;
3102
- this._name = str5;
3100
+ name(str6) {
3101
+ if (str6 === void 0) return this._name;
3102
+ this._name = str6;
3103
3103
  return this;
3104
3104
  }
3105
3105
  /**
@@ -3178,7 +3178,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
3178
3178
  * @return {Command}
3179
3179
  */
3180
3180
  nameFromFilename(filename) {
3181
- this._name = path24.basename(filename, path24.extname(filename));
3181
+ this._name = path26.basename(filename, path26.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(path25) {
3196
- if (path25 === void 0) return this._executableDir;
3197
- this._executableDir = path25;
3195
+ executableDir(path27) {
3196
+ if (path27 === void 0) return this._executableDir;
3197
+ this._executableDir = path27;
3198
3198
  return this;
3199
3199
  }
3200
3200
  /**
@@ -3233,17 +3233,17 @@ Expecting one of '${allowedValues.join("', '")}'`);
3233
3233
  let hasColors;
3234
3234
  let helpWidth;
3235
3235
  if (error) {
3236
- baseWrite = (str5) => this._outputConfiguration.writeErr(str5);
3236
+ baseWrite = (str6) => this._outputConfiguration.writeErr(str6);
3237
3237
  hasColors = this._outputConfiguration.getErrHasColors();
3238
3238
  helpWidth = this._outputConfiguration.getErrHelpWidth();
3239
3239
  } else {
3240
- baseWrite = (str5) => this._outputConfiguration.writeOut(str5);
3240
+ baseWrite = (str6) => this._outputConfiguration.writeOut(str6);
3241
3241
  hasColors = this._outputConfiguration.getOutHasColors();
3242
3242
  helpWidth = this._outputConfiguration.getOutHelpWidth();
3243
3243
  }
3244
- const write = (str5) => {
3245
- if (!hasColors) str5 = this._outputConfiguration.stripColor(str5);
3246
- return baseWrite(str5);
3244
+ const write = (str6) => {
3245
+ if (!hasColors) str6 = this._outputConfiguration.stripColor(str6);
3246
+ return baseWrite(str6);
3247
3247
  };
3248
3248
  return { error, write, hasColors, helpWidth };
3249
3249
  }
@@ -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(path24) {
4910
+ function parseKeysFile(path26) {
4911
4911
  let text2;
4912
4912
  try {
4913
- text2 = readFileSync3(path24, "utf8");
4913
+ text2 = readFileSync3(path26, "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(path24) {
5025
+ function restrictPermissions(path26) {
5026
5026
  if (process.platform === "win32") return null;
5027
5027
  try {
5028
- chmodSync(path24, 384);
5028
+ chmodSync(path26, 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 path24 = keysFilePath(process.env);
5036
- const fileKeys = parseKeysFile(path24);
5035
+ const path26 = keysFilePath(process.env);
5036
+ const fileKeys = parseKeysFile(path26);
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 ${path24})
5052
+ process.stdout.write(`no provider keys configured (looked in $ENV and ${path26})
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: ${path24}
5067
+ process.stdout.write(` keys file: ${path26}
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 ${path24}`);
5127
+ Se(`dry run \u2014 would write ${Object.keys(collected).join(", ")} to ${path26}`);
5128
5128
  return 0;
5129
5129
  }
5130
5130
  let existing = "";
5131
5131
  try {
5132
- existing = readFileSync4(path24, "utf8");
5132
+ existing = readFileSync4(path26, "utf8");
5133
5133
  } catch {
5134
5134
  existing = "";
5135
5135
  }
5136
- mkdirSync2(dirname(path24), { recursive: true });
5137
- writeFileSync(path24, upsertKeyLines(existing, collected), { encoding: "utf8" });
5138
- const permWarning = restrictPermissions(path24);
5136
+ mkdirSync2(dirname(path26), { recursive: true });
5137
+ writeFileSync(path26, upsertKeyLines(existing, collected), { encoding: "utf8" });
5138
+ const permWarning = restrictPermissions(path26);
5139
5139
  process.stdout.write(`
5140
- wrote ${Object.keys(collected).join(", ")} to ${path24}
5140
+ wrote ${Object.keys(collected).join(", ")} to ${path26}
5141
5141
  `);
5142
5142
  if (permWarning) process.stdout.write(color2.yellow(` could not set 0600 on the keys file: ${permWarning}
5143
5143
  `));
@@ -5749,6 +5749,9 @@ function hubHome(home) {
5749
5749
  const override = process.env.CADDIS_HUB_HOME;
5750
5750
  return override ? override : hubDir(home);
5751
5751
  }
5752
+ function sessionsPath(home) {
5753
+ return path7.join(hubDir(home), "sessions.json");
5754
+ }
5752
5755
  var configPath, registryPath, keyPath, lockPath, auditPath;
5753
5756
  var init_paths = __esm({
5754
5757
  "src/hub/paths.ts"() {
@@ -6751,9 +6754,86 @@ var init_spawn = __esm({
6751
6754
  }
6752
6755
  });
6753
6756
 
6754
- // src/hub/sources/agents.ts
6755
- import { existsSync as existsSync7, readFileSync as readFileSync11, statSync as statSync2 } from "fs";
6757
+ // src/hub/sources/beats.ts
6758
+ import { readFileSync as readFileSync11, readdirSync as readdirSync4 } from "fs";
6756
6759
  import path15 from "path";
6760
+ function toEntry(raw, opts) {
6761
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) return null;
6762
+ const r2 = raw;
6763
+ const sessionId = str2(r2.session_id);
6764
+ const agent = str2(r2.harness);
6765
+ const status5 = str2(r2.status);
6766
+ const lastSeen = Number(r2.last_seen) * 1e3;
6767
+ if (!sessionId || !agent || agent === "claude" || !status5 || !STATUSES.has(status5)) return null;
6768
+ if (opts.exclude.has(sessionId) || !Number.isFinite(lastSeen)) return null;
6769
+ const age = opts.now - lastSeen;
6770
+ if (age > AGENT_DROP_AFTER_MS) return null;
6771
+ const pid = Number.isInteger(r2.pid) && r2.pid > 0 ? r2.pid : null;
6772
+ if (pid !== null && !opts.alive(pid)) return null;
6773
+ const quiet = age > AGENT_IDLE_AFTER_MS;
6774
+ const shown = status5 === "waiting" ? quiet && pid === null ? "idle" : "waiting" : quiet ? "idle" : "working";
6775
+ const sinceRaw = Number(r2.status_since) * 1e3;
6776
+ const since = Number.isFinite(sinceRaw) && sinceRaw > 0 ? sinceRaw : lastSeen;
6777
+ const waiting = shown === "waiting";
6778
+ const cwd = str2(r2.cwd);
6779
+ return {
6780
+ key: `${agent}:${sessionId}`,
6781
+ pid,
6782
+ session_id: sessionId,
6783
+ name: str2(r2.name),
6784
+ kind: "interactive",
6785
+ agent,
6786
+ cwd,
6787
+ repo_path: repoPathFor(cwd ?? str2(r2.repo_path)),
6788
+ status: shown,
6789
+ waiting_for: waiting ? str2(r2.waiting_for) ?? "input needed" : null,
6790
+ // A stopped agent turn always waits on the owner. The debounce matches the Claude sessions.
6791
+ waiting_class: waiting && opts.now - since >= WAIT_DEBOUNCE_MS ? "owner" : null,
6792
+ waiting_since: waiting ? new Date(since).toISOString() : null,
6793
+ copies: 1
6794
+ };
6795
+ }
6796
+ function readAgentBeats(opts) {
6797
+ const dir = sessionsDir(opts.home);
6798
+ let names;
6799
+ try {
6800
+ names = readdirSync4(dir).sort();
6801
+ } catch {
6802
+ return [];
6803
+ }
6804
+ const out = [];
6805
+ const seen = /* @__PURE__ */ new Set();
6806
+ for (const name of names) {
6807
+ if (!name.endsWith(".json") || name.startsWith(".")) continue;
6808
+ let entry = null;
6809
+ try {
6810
+ entry = toEntry(JSON.parse(readFileSync11(path15.join(dir, name), "utf8")), opts);
6811
+ } catch {
6812
+ continue;
6813
+ }
6814
+ if (entry && !seen.has(entry.session_id)) {
6815
+ seen.add(entry.session_id);
6816
+ out.push(entry);
6817
+ }
6818
+ }
6819
+ return out;
6820
+ }
6821
+ var AGENT_IDLE_AFTER_MS, AGENT_DROP_AFTER_MS, STATUSES, str2;
6822
+ var init_beats = __esm({
6823
+ "src/hub/sources/beats.ts"() {
6824
+ "use strict";
6825
+ init_sessions();
6826
+ init_agents();
6827
+ AGENT_IDLE_AFTER_MS = 10 * 6e4;
6828
+ AGENT_DROP_AFTER_MS = 24 * 36e5;
6829
+ STATUSES = /* @__PURE__ */ new Set(["working", "waiting"]);
6830
+ str2 = (v2) => typeof v2 === "string" && v2 ? v2 : null;
6831
+ }
6832
+ });
6833
+
6834
+ // src/hub/sources/agents.ts
6835
+ import { existsSync as existsSync7, readFileSync as readFileSync12, statSync as statSync2 } from "fs";
6836
+ import path16 from "path";
6757
6837
  function classifyWaiting(waitingFor) {
6758
6838
  const w2 = (waitingFor ?? "").toLowerCase();
6759
6839
  if (w2 === "permission prompt" || w2 === "input needed" || w2.includes("question")) return "owner";
@@ -6761,33 +6841,33 @@ function classifyWaiting(waitingFor) {
6761
6841
  }
6762
6842
  function repoPathFor(cwd) {
6763
6843
  if (!cwd) return null;
6764
- let dir = path15.resolve(cwd);
6844
+ let dir = path16.resolve(cwd);
6765
6845
  for (; ; ) {
6766
- const dotGit = path15.join(dir, ".git");
6846
+ const dotGit = path16.join(dir, ".git");
6767
6847
  if (existsSync7(dotGit)) {
6768
6848
  if (isDir(dotGit)) return normalizeRepoPath(dir);
6769
6849
  if (isFile(dotGit)) return commonRoot(dir, dotGit);
6770
6850
  return null;
6771
6851
  }
6772
- const parent = path15.dirname(dir);
6852
+ const parent = path16.dirname(dir);
6773
6853
  if (parent === dir) return null;
6774
6854
  dir = parent;
6775
6855
  }
6776
6856
  }
6777
6857
  function commonRoot(dir, dotGitFile) {
6778
6858
  try {
6779
- const m2 = /^gitdir:\s*(.+?)\s*$/m.exec(readFileSync11(dotGitFile, "utf8"));
6859
+ const m2 = /^gitdir:\s*(.+?)\s*$/m.exec(readFileSync12(dotGitFile, "utf8"));
6780
6860
  if (!m2) return null;
6781
- const gitdir = path15.resolve(dir, m2[1] ?? "");
6861
+ const gitdir = path16.resolve(dir, m2[1] ?? "");
6782
6862
  let common;
6783
6863
  try {
6784
- const rel = readFileSync11(path15.join(gitdir, "commondir"), "utf8").trim();
6864
+ const rel = readFileSync12(path16.join(gitdir, "commondir"), "utf8").trim();
6785
6865
  if (!rel) return normalizeRepoPath(dir);
6786
- common = path15.resolve(gitdir, rel);
6866
+ common = path16.resolve(gitdir, rel);
6787
6867
  } catch {
6788
6868
  return normalizeRepoPath(dir);
6789
6869
  }
6790
- return normalizeRepoPath(path15.dirname(common));
6870
+ return normalizeRepoPath(path16.dirname(common));
6791
6871
  } catch {
6792
6872
  return null;
6793
6873
  }
@@ -6796,8 +6876,10 @@ function createAgentsSource(opts = {}) {
6796
6876
  const now = opts.now ?? Date.now;
6797
6877
  const spawn2 = opts.spawn ?? spawnBounded;
6798
6878
  const find2 = opts.findClaude ?? (() => findBin("claude"));
6879
+ const alive = opts.alive ?? pidAlive;
6799
6880
  const waitingSince = /* @__PURE__ */ new Map();
6800
6881
  let sessions = null;
6882
+ let others = [];
6801
6883
  let lastOkAt = null;
6802
6884
  let lastError = null;
6803
6885
  let lastRunOk = false;
@@ -6814,10 +6896,10 @@ function createAgentsSource(opts = {}) {
6814
6896
  for (const raw of parsed) {
6815
6897
  if (!raw || typeof raw !== "object") continue;
6816
6898
  const e2 = raw;
6817
- const sessionId = str2(e2.sessionId);
6899
+ const sessionId = str3(e2.sessionId);
6818
6900
  if (!sessionId) continue;
6819
- const kind = str2(e2.kind) ?? "interactive";
6820
- const status5 = str2(e2.status) ?? str2(e2.state) ?? "unknown";
6901
+ const kind = str3(e2.kind) ?? "interactive";
6902
+ const status5 = str3(e2.status) ?? str3(e2.state) ?? "unknown";
6821
6903
  if (kind === "background" && status5 === "done") continue;
6822
6904
  const prior = byId.get(sessionId);
6823
6905
  if (prior) {
@@ -6825,10 +6907,10 @@ function createAgentsSource(opts = {}) {
6825
6907
  continue;
6826
6908
  }
6827
6909
  const pid = typeof e2.pid === "number" ? e2.pid : null;
6828
- const cwd = str2(e2.cwd);
6910
+ const cwd = str3(e2.cwd);
6829
6911
  const isWaiting = status5 === "waiting";
6830
- const waitingFor = isWaiting ? str2(e2.waitingFor) : null;
6831
- const key = `${pid ?? str2(e2.id) ?? kind}:${sessionId}`;
6912
+ const waitingFor = isWaiting ? str3(e2.waitingFor) : null;
6913
+ const key = `${pid ?? str3(e2.id) ?? kind}:${sessionId}`;
6832
6914
  let since = null;
6833
6915
  if (isWaiting) {
6834
6916
  seenWaiting.add(key);
@@ -6840,8 +6922,9 @@ function createAgentsSource(opts = {}) {
6840
6922
  key,
6841
6923
  pid,
6842
6924
  session_id: sessionId,
6843
- name: str2(e2.name),
6925
+ name: str3(e2.name),
6844
6926
  kind,
6927
+ agent: "claude",
6845
6928
  cwd,
6846
6929
  repo_path: repoPathFor(cwd),
6847
6930
  status: status5,
@@ -6877,7 +6960,11 @@ function createAgentsSource(opts = {}) {
6877
6960
  return {
6878
6961
  refresh() {
6879
6962
  if (!running) {
6880
- running = run2().catch((error) => fail2(error instanceof Error ? error.message : String(error))).finally(() => {
6963
+ running = run2().catch((error) => fail2(error instanceof Error ? error.message : String(error))).then(() => {
6964
+ if (opts.home === void 0) return;
6965
+ const exclude = new Set((sessions ?? []).map((s) => s.session_id));
6966
+ others = readAgentBeats({ home: opts.home, now: now(), alive, exclude });
6967
+ }).finally(() => {
6881
6968
  running = null;
6882
6969
  });
6883
6970
  }
@@ -6889,12 +6976,12 @@ function createAgentsSource(opts = {}) {
6889
6976
  last_ok_at: lastOkAt === null ? null : new Date(lastOkAt).toISOString(),
6890
6977
  last_error: lastError,
6891
6978
  stale: lastOkAt === null || now() - lastOkAt > STALE_AFTER_MS2,
6892
- data: sessions
6979
+ data: sessions === null && others.length === 0 ? null : [...sessions ?? [], ...others]
6893
6980
  };
6894
6981
  }
6895
6982
  };
6896
6983
  }
6897
- var STALE_AFTER_MS2, WAIT_DEBOUNCE_MS, RUN_TIMEOUT_MS, FIND_TIMEOUT_MS, isFile, isDir, str2;
6984
+ var STALE_AFTER_MS2, WAIT_DEBOUNCE_MS, RUN_TIMEOUT_MS, FIND_TIMEOUT_MS, isFile, isDir, str3;
6898
6985
  var init_agents = __esm({
6899
6986
  "src/hub/sources/agents.ts"() {
6900
6987
  "use strict";
@@ -6902,6 +6989,8 @@ var init_agents = __esm({
6902
6989
  init_bounded();
6903
6990
  init_spawn();
6904
6991
  init_config();
6992
+ init_sessions();
6993
+ init_beats();
6905
6994
  STALE_AFTER_MS2 = 3 * 6e4;
6906
6995
  WAIT_DEBOUNCE_MS = 45e3;
6907
6996
  RUN_TIMEOUT_MS = 1e4;
@@ -6920,24 +7009,24 @@ var init_agents = __esm({
6920
7009
  return false;
6921
7010
  }
6922
7011
  };
6923
- str2 = (v2) => typeof v2 === "string" && v2 ? v2 : null;
7012
+ str3 = (v2) => typeof v2 === "string" && v2 ? v2 : null;
6924
7013
  }
6925
7014
  });
6926
7015
 
6927
7016
  // src/hub/sources/collector.ts
6928
7017
  import { existsSync as existsSync8 } from "fs";
6929
7018
  import os5 from "os";
6930
- import path16 from "path";
7019
+ import path17 from "path";
6931
7020
  function defaultScriptPath() {
6932
7021
  const name = "caddis_hub_collect.py";
6933
7022
  const bundle = bundlePath("antigravity-plugin", { requireManifest: false });
6934
7023
  if (bundle) {
6935
- const shipped = path16.join(bundle, "scripts", name);
7024
+ const shipped = path17.join(bundle, "scripts", name);
6936
7025
  if (existsSync8(shipped)) return shipped;
6937
7026
  }
6938
- const root = path16.join(packageInfo().root, "..");
6939
- const repoScript = path16.join(root, "scripts", name);
6940
- const mirrorScript = path16.join(root, "bundles", "antigravity-plugin", "scripts", name);
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);
6941
7030
  return !existsSync8(repoScript) && existsSync8(mirrorScript) ? mirrorScript : repoScript;
6942
7031
  }
6943
7032
  async function resolvePython() {
@@ -6954,6 +7043,7 @@ async function resolvePython() {
6954
7043
  function createCollectorSource(opts) {
6955
7044
  const now = opts.now ?? Date.now;
6956
7045
  const spawn2 = opts.spawn ?? spawnBounded;
7046
+ const log = opts.log ?? errorLine;
6957
7047
  const cache2 = /* @__PURE__ */ new Map();
6958
7048
  let spend = null;
6959
7049
  let guide = null;
@@ -6964,6 +7054,7 @@ function createCollectorSource(opts) {
6964
7054
  let updateNeeded = false;
6965
7055
  let lastRunOk = false;
6966
7056
  let running = null;
7057
+ let knownUnsupported = false;
6967
7058
  const fail2 = (message3) => {
6968
7059
  lastError = message3;
6969
7060
  lastRunOk = false;
@@ -6987,6 +7078,7 @@ function createCollectorSource(opts) {
6987
7078
  for (const key of [...cache2.keys()]) if (!keep.has(key)) cache2.delete(key);
6988
7079
  for (const entry of out.repos) {
6989
7080
  if (!entry || typeof entry.path !== "string" || !keep.has(entry.path)) continue;
7081
+ if (entry.unchanged === true) continue;
6990
7082
  const old = cache2.get(entry.path);
6991
7083
  if (entry.error !== void 0 || entry.fingerprint === void 0) {
6992
7084
  if (!old || old.error !== void 0) cache2.set(entry.path, entry);
@@ -7017,8 +7109,14 @@ function createCollectorSource(opts) {
7017
7109
  pre = found.pre;
7018
7110
  }
7019
7111
  const script = opts.scriptPath ?? defaultScriptPath();
7020
- const args = repos.length ? [...pre, script, "--repos", ...repos, "--json"] : [...pre, script, "--repos", path16.join(os5.tmpdir(), "caddis-hub-no-repos"), "--only", "spend,guide", "--json"];
7021
- const result = await spawn2(cmd, args, { timeoutMs: RUN_TIMEOUT_MS2 });
7112
+ 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}`);
7113
+ const args = repos.length ? known.length ? [...pre, script, "--repos", ...repos, "--known", ...known, "--json"] : [...pre, script, "--repos", ...repos, "--json"] : [...pre, script, "--repos", path17.join(os5.tmpdir(), "caddis-hub-no-repos"), "--only", "spend,guide", "--json"];
7114
+ let result = await spawn2(cmd, args, { timeoutMs: RUN_TIMEOUT_MS2 });
7115
+ if (!result.ok && result.code === 2 && known.length && repos.length && /unrecognized arguments:.*--known/.test(result.stderr)) {
7116
+ knownUnsupported = true;
7117
+ log("caddis hub: the collector script does not know --known (old plugin); sending full runs. Update the plugin.");
7118
+ result = await spawn2(cmd, [...pre, script, "--repos", ...repos, "--json"], { timeoutMs: RUN_TIMEOUT_MS2 });
7119
+ }
7022
7120
  if (result.timedOut) return fail2(`collector timed out after ${RUN_TIMEOUT_MS2 / 1e3} s`);
7023
7121
  if (!result.ok) {
7024
7122
  const detail2 = (result.stderr || result.stdout).trim().slice(0, 500);
@@ -7060,6 +7158,7 @@ var init_collector = __esm({
7060
7158
  "use strict";
7061
7159
  init_pkg();
7062
7160
  init_which();
7161
+ init_log();
7063
7162
  init_bounded();
7064
7163
  init_spawn();
7065
7164
  COLLECTOR_SCHEMA = 1;
@@ -7071,8 +7170,8 @@ var init_collector = __esm({
7071
7170
  });
7072
7171
 
7073
7172
  // src/hub/sources/github.ts
7074
- import { readFileSync as readFileSync12 } from "fs";
7075
- import path17 from "path";
7173
+ import { readFileSync as readFileSync13 } from "fs";
7174
+ import path18 from "path";
7076
7175
  function parseGithubRemote(url) {
7077
7176
  const m2 = /^(?:https?:\/\/(?:[^@/]+@)?|ssh:\/\/git@|git@)github\.com[/:]([^/\s]+)\/([^/\s]+?)(?:\.git)?\/?$/i.exec(url.trim());
7078
7177
  return m2 ? `${m2[1]}/${m2[2]}` : null;
@@ -7082,7 +7181,7 @@ function readOriginUrl(repoDir) {
7082
7181
  if (!root) return null;
7083
7182
  let text2;
7084
7183
  try {
7085
- text2 = readFileSync12(path17.join(root, ".git", "config"), "utf8");
7184
+ text2 = readFileSync13(path18.join(root, ".git", "config"), "utf8");
7086
7185
  } catch {
7087
7186
  return null;
7088
7187
  }
@@ -7100,7 +7199,7 @@ function readOriginUrl(repoDir) {
7100
7199
  }
7101
7200
  function readRequiredChecks(repoDir) {
7102
7201
  try {
7103
- const text2 = readFileSync12(path17.join(repoDir, ".caddis", "coordinator.md"), "utf8");
7202
+ const text2 = readFileSync13(path18.join(repoDir, ".caddis", "coordinator.md"), "utf8");
7104
7203
  const m2 = /```json[^\S\r\n]*\r?\n([\s\S]*?)\r?\n[^\S\r\n]*```/.exec(text2);
7105
7204
  if (!m2) return null;
7106
7205
  const parsed = JSON.parse(m2[1] ?? "");
@@ -7238,17 +7337,17 @@ ${url}`;
7238
7337
  const pulls = list(first);
7239
7338
  const prs = [];
7240
7339
  for (const p2 of pulls) {
7241
- const head = str3(rec2(p2.head).sha) ?? "";
7340
+ const head = str4(rec2(p2.head).sha) ?? "";
7242
7341
  const byName = /* @__PURE__ */ new Map();
7243
7342
  if (head) {
7244
7343
  const body = rec2(await getJson(account, token, `/repos/${repo}/commits/${head}/check-runs?per_page=100`));
7245
7344
  for (const c of list(body.check_runs)) {
7246
- const name = str3(c.name);
7345
+ const name = str4(c.name);
7247
7346
  if (!name) continue;
7248
7347
  byName.set(name, {
7249
7348
  name,
7250
- status: str3(c.status) ?? "unknown",
7251
- conclusion: str3(c.conclusion),
7349
+ status: str4(c.status) ?? "unknown",
7350
+ conclusion: str4(c.conclusion),
7252
7351
  required: required === null ? null : required.includes(name)
7253
7352
  });
7254
7353
  }
@@ -7256,12 +7355,12 @@ ${url}`;
7256
7355
  const checks = [...byName.values()];
7257
7356
  prs.push({
7258
7357
  number: Number(p2.number),
7259
- title: str3(p2.title) ?? "",
7358
+ title: str4(p2.title) ?? "",
7260
7359
  head_sha: head,
7261
- author: str3(rec2(p2.user).login),
7360
+ author: str4(rec2(p2.user).login),
7262
7361
  draft: p2.draft === true,
7263
- updated_at: str3(p2.updated_at),
7264
- url: str3(p2.html_url) ?? "",
7362
+ updated_at: str4(p2.updated_at),
7363
+ url: str4(p2.html_url) ?? "",
7265
7364
  checks,
7266
7365
  required_state: requiredState(checks, required)
7267
7366
  });
@@ -7269,21 +7368,21 @@ ${url}`;
7269
7368
  const closed = list(
7270
7369
  await getJson(account, token, `/repos/${repo}/pulls?state=closed&sort=updated&direction=desc&per_page=20`)
7271
7370
  );
7272
- const merged = closed.filter((p2) => str3(p2.merged_at) && str3(p2.merge_commit_sha)).sort((a, b3) => String(b3.merged_at).localeCompare(String(a.merged_at))).slice(0, MERGES_SHOWN);
7371
+ const merged = closed.filter((p2) => str4(p2.merged_at) && str4(p2.merge_commit_sha)).sort((a, b3) => String(b3.merged_at).localeCompare(String(a.merged_at))).slice(0, MERGES_SHOWN);
7273
7372
  const merges = [];
7274
7373
  for (const p2 of merged) {
7275
- const sha = str3(p2.merge_commit_sha) ?? "";
7374
+ const sha = str4(p2.merge_commit_sha) ?? "";
7276
7375
  const body = rec2(await getJson(account, token, `/repos/${repo}/actions/runs?head_sha=${sha}&per_page=10`));
7277
7376
  merges.push({
7278
7377
  number: Number(p2.number),
7279
- title: str3(p2.title) ?? "",
7378
+ title: str4(p2.title) ?? "",
7280
7379
  merge_sha: sha,
7281
- merged_at: str3(p2.merged_at) ?? "",
7380
+ merged_at: str4(p2.merged_at) ?? "",
7282
7381
  runs: list(body.workflow_runs).map((r2) => ({
7283
- name: str3(r2.name) ?? "",
7284
- status: str3(r2.status) ?? "unknown",
7285
- conclusion: str3(r2.conclusion),
7286
- url: str3(r2.html_url) ?? ""
7382
+ name: str4(r2.name) ?? "",
7383
+ status: str4(r2.status) ?? "unknown",
7384
+ conclusion: str4(r2.conclusion),
7385
+ url: str4(r2.html_url) ?? ""
7287
7386
  }))
7288
7387
  });
7289
7388
  }
@@ -7406,7 +7505,7 @@ ${url}`;
7406
7505
  }
7407
7506
  };
7408
7507
  }
7409
- 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, str3, rec2, list, findGh;
7508
+ 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;
7410
7509
  var init_github = __esm({
7411
7510
  "src/hub/sources/github.ts"() {
7412
7511
  "use strict";
@@ -7437,7 +7536,7 @@ var init_github = __esm({
7437
7536
  /** This token cannot see the repo: try the next account. */
7438
7537
  access;
7439
7538
  };
7440
- str3 = (v2) => typeof v2 === "string" && v2 ? v2 : null;
7539
+ str4 = (v2) => typeof v2 === "string" && v2 ? v2 : null;
7441
7540
  rec2 = (v2) => v2 && typeof v2 === "object" ? v2 : {};
7442
7541
  list = (v2) => Array.isArray(v2) ? v2.map(rec2) : [];
7443
7542
  findGh = () => withTimeout(findBin("gh"), FIND_TIMEOUT_MS3, "finding gh");
@@ -7446,20 +7545,20 @@ var init_github = __esm({
7446
7545
 
7447
7546
  // src/hub/state.ts
7448
7547
  import { createHash } from "crypto";
7449
- import { readFileSync as readFileSync13 } from "fs";
7450
- import path18 from "path";
7548
+ import { readFileSync as readFileSync14 } from "fs";
7549
+ import path19 from "path";
7451
7550
  function repoIdFor(nameWithOwner) {
7452
7551
  return nameWithOwner.trim().toLowerCase().replace(/\//g, "__");
7453
7552
  }
7454
7553
  function localRepoId(repoPath) {
7455
7554
  const norm = process.platform === "win32" ? repoPath.toLowerCase().replace(/\//g, "\\") : repoPath;
7456
7555
  const digest = createHash("sha256").update(norm, "utf8").digest("hex").slice(0, 6);
7457
- return `local__${path18.basename(repoPath)}__${digest}`;
7556
+ return `local__${path19.basename(repoPath)}__${digest}`;
7458
7557
  }
7459
7558
  function readPluginVersion(home) {
7460
7559
  try {
7461
- const file = path18.join(home, ".claude", "plugins", "installed_plugins.json");
7462
- const parsed = JSON.parse(readFileSync13(file, "utf8"));
7560
+ const file = path19.join(home, ".claude", "plugins", "installed_plugins.json");
7561
+ const parsed = JSON.parse(readFileSync14(file, "utf8"));
7463
7562
  for (const [key, entries] of Object.entries(parsed.plugins ?? {})) {
7464
7563
  if (!key.startsWith("caddis@") || !Array.isArray(entries)) continue;
7465
7564
  for (const e2 of entries) {
@@ -7561,7 +7660,7 @@ function createHub(opts = {}) {
7561
7660
  return out;
7562
7661
  };
7563
7662
  const collector = opts.collector ?? createCollectorSource({ repos: repoPaths, now });
7564
- const agents = opts.agents ?? createAgentsSource({ now });
7663
+ const agents = opts.agents ?? createAgentsSource({ now, home });
7565
7664
  const github = opts.github ?? createGithubSource({ repos: repoPaths, accounts: () => readConfig(home).value.accounts, now });
7566
7665
  const coordinator = opts.coordinator ?? createCoordinatorSource({ home, now });
7567
7666
  let versionsCache = null;
@@ -7653,7 +7752,7 @@ function createHub(opts = {}) {
7653
7752
  const relays = c?.relays ?? null;
7654
7753
  const out = {
7655
7754
  path: p2,
7656
- name: path18.basename(p2),
7755
+ name: path19.basename(p2),
7657
7756
  pinned: pinned.has(k3),
7658
7757
  roadmaps: c?.roadmaps ?? null,
7659
7758
  plans: c?.plans ?? null,
@@ -7764,7 +7863,7 @@ var init_state = __esm({
7764
7863
 
7765
7864
  // src/hub/actions.ts
7766
7865
  import { randomUUID } from "crypto";
7767
- import path19 from "path";
7866
+ import path20 from "path";
7768
7867
  function parseBody(raw) {
7769
7868
  if (!raw || typeof raw !== "object" || Array.isArray(raw)) throw new Refusal(400, "bad_request", "The body must be a JSON object.");
7770
7869
  const o2 = raw;
@@ -7872,7 +7971,7 @@ function createActions(opts) {
7872
7971
  args: body.what === null ? {} : { what: body.what }
7873
7972
  };
7874
7973
  try {
7875
- await appendLine(path19.join(root(), "repos", body.repo_id, "requests.jsonl"), JSON.stringify(request));
7974
+ await appendLine(path20.join(root(), "repos", body.repo_id, "requests.jsonl"), JSON.stringify(request));
7876
7975
  } catch {
7877
7976
  return refuse(new Refusal(500, "write_failed", "The hub could not write the request."), body);
7878
7977
  }
@@ -7920,6 +8019,8 @@ var init_actions = __esm({
7920
8019
 
7921
8020
  // src/hub/auth.ts
7922
8021
  import { createHash as createHash2, randomBytes as randomBytes3, timingSafeEqual } from "crypto";
8022
+ import { mkdirSync as mkdirSync7, readFileSync as readFileSync15, renameSync as renameSync3, writeFileSync as writeFileSync5 } from "fs";
8023
+ import path21 from "path";
7923
8024
  function randomToken() {
7924
8025
  return randomBytes3(32).toString("base64url");
7925
8026
  }
@@ -7948,22 +8049,84 @@ function parseCookies(header) {
7948
8049
  }
7949
8050
  return out;
7950
8051
  }
7951
- var CODE_TTL_MS, MAX_CODES, MAX_SESSIONS, SESSION_IDLE_MS, SESSION_MAX_MS, AuthStore;
8052
+ var CODE_TTL_MS, MAX_CODES, MAX_SESSIONS, SESSION_IDLE_MS, SESSION_MAX_MS, SEEN_WRITE_MS, hashToken, AuthStore;
7952
8053
  var init_auth = __esm({
7953
8054
  "src/hub/auth.ts"() {
7954
8055
  "use strict";
7955
8056
  CODE_TTL_MS = 6e4;
7956
8057
  MAX_CODES = 20;
7957
8058
  MAX_SESSIONS = 20;
7958
- SESSION_IDLE_MS = 12 * 60 * 60 * 1e3;
7959
- SESSION_MAX_MS = 24 * 60 * 60 * 1e3;
8059
+ SESSION_IDLE_MS = 7 * 24 * 60 * 60 * 1e3;
8060
+ SESSION_MAX_MS = 30 * 24 * 60 * 60 * 1e3;
8061
+ SEEN_WRITE_MS = 5 * 60 * 1e3;
8062
+ hashToken = (v2) => createHash2("sha256").update(v2, "utf8").digest("hex");
7960
8063
  AuthStore = class {
7961
- constructor(now = Date.now) {
8064
+ constructor(now = Date.now, file) {
7962
8065
  this.now = now;
8066
+ this.file = file;
8067
+ this.sessions = this.load();
7963
8068
  }
7964
8069
  now;
8070
+ file;
7965
8071
  codes = [];
7966
8072
  sessions = [];
8073
+ load() {
8074
+ if (!this.file) return [];
8075
+ let raw;
8076
+ try {
8077
+ raw = JSON.parse(readFileSync15(this.file, "utf8"));
8078
+ } catch {
8079
+ return [];
8080
+ }
8081
+ const list2 = raw?.sessions;
8082
+ if (!Array.isArray(list2)) return [];
8083
+ const t = this.now();
8084
+ const out = [];
8085
+ for (const e2 of list2) {
8086
+ if (!e2 || typeof e2 !== "object") continue;
8087
+ const r2 = e2;
8088
+ const ok = (v2) => typeof v2 === "string" && v2.length > 0;
8089
+ const num = (v2) => typeof v2 === "number" && Number.isFinite(v2);
8090
+ if (!ok(r2.id_hash) || !ok(r2.tab_hash) || !ok(r2.csrf) || !num(r2.created_at) || !num(r2.last_seen_at)) continue;
8091
+ const s = {
8092
+ id: "",
8093
+ idHash: r2.id_hash,
8094
+ csrf: r2.csrf,
8095
+ tab: "",
8096
+ tabHash: r2.tab_hash,
8097
+ createdAt: r2.created_at,
8098
+ lastSeenAt: r2.last_seen_at,
8099
+ savedSeenAt: r2.last_seen_at
8100
+ };
8101
+ if (!this.expired(s, t)) out.push(s);
8102
+ }
8103
+ return out.slice(-MAX_SESSIONS);
8104
+ }
8105
+ /** Write the sessions. A write that fails is ignored: the hub keeps working, the login is lost on restart. */
8106
+ save() {
8107
+ if (!this.file) return;
8108
+ const body = {
8109
+ schema: 1,
8110
+ sessions: this.sessions.map((s) => ({
8111
+ id_hash: s.idHash,
8112
+ tab_hash: s.tabHash,
8113
+ csrf: s.csrf,
8114
+ created_at: s.createdAt,
8115
+ last_seen_at: s.lastSeenAt
8116
+ }))
8117
+ };
8118
+ const tmp = `${this.file}.${process.pid}.tmp`;
8119
+ try {
8120
+ mkdirSync7(path21.dirname(this.file), { recursive: true });
8121
+ writeFileSync5(tmp, JSON.stringify(body), { mode: 384 });
8122
+ renameSync3(tmp, this.file);
8123
+ for (const s of this.sessions) s.savedSeenAt = s.lastSeenAt;
8124
+ } catch {
8125
+ }
8126
+ }
8127
+ expired(s, t) {
8128
+ return t - s.lastSeenAt >= SESSION_IDLE_MS || t - s.createdAt >= SESSION_MAX_MS;
8129
+ }
7967
8130
  /** Mint a single-use code. Expired codes are dropped first; then the oldest goes past the cap. */
7968
8131
  mintCode() {
7969
8132
  const t = this.now();
@@ -7990,9 +8153,21 @@ var init_auth = __esm({
7990
8153
  const age = this.now() - found.mintedAt;
7991
8154
  if (age < 0 || age >= CODE_TTL_MS) return null;
7992
8155
  const t = this.now();
7993
- const s = { id: randomToken(), csrf: randomToken(), tab: randomToken(), createdAt: t, lastSeenAt: t };
8156
+ const id = randomToken();
8157
+ const tab = randomToken();
8158
+ const s = {
8159
+ id,
8160
+ idHash: hashToken(id),
8161
+ csrf: randomToken(),
8162
+ tab,
8163
+ tabHash: hashToken(tab),
8164
+ createdAt: t,
8165
+ lastSeenAt: t,
8166
+ savedSeenAt: t
8167
+ };
7994
8168
  this.sessions.push(s);
7995
8169
  while (this.sessions.length > MAX_SESSIONS) this.sessions.shift();
8170
+ this.save();
7996
8171
  return s.id;
7997
8172
  }
7998
8173
  /** Remove a code without making a session (a refused /login still uses up its code). */
@@ -8016,21 +8191,26 @@ var init_auth = __esm({
8016
8191
  }
8017
8192
  findSession(id, tab) {
8018
8193
  if (!id) return null;
8194
+ const idHash = hashToken(id);
8019
8195
  let found = null;
8020
- for (const s of this.sessions) if (safeEqual(s.id, id)) found = s;
8196
+ for (const s of this.sessions) if (safeEqual(s.idHash, idHash)) found = s;
8021
8197
  if (!found) return null;
8022
- if (tab !== null && !safeEqual(found.tab, tab)) return null;
8198
+ if (tab !== null && !safeEqual(found.tabHash, hashToken(tab))) return null;
8023
8199
  const t = this.now();
8024
- if (t - found.lastSeenAt >= SESSION_IDLE_MS || t - found.createdAt >= SESSION_MAX_MS) {
8200
+ if (this.expired(found, t)) {
8025
8201
  this.sessions = this.sessions.filter((x2) => x2 !== found);
8202
+ this.save();
8026
8203
  return null;
8027
8204
  }
8028
8205
  found.lastSeenAt = t;
8206
+ if (t - found.savedSeenAt >= SEEN_WRITE_MS) this.save();
8029
8207
  return found;
8030
8208
  }
8031
8209
  deleteSession(id) {
8032
8210
  const s = this.getSession(id);
8033
- if (s) this.sessions = this.sessions.filter((x2) => x2 !== s);
8211
+ if (!s) return;
8212
+ this.sessions = this.sessions.filter((x2) => x2 !== s);
8213
+ this.save();
8034
8214
  }
8035
8215
  codeCount() {
8036
8216
  return this.codes.length;
@@ -8042,16 +8222,68 @@ var init_auth = __esm({
8042
8222
  }
8043
8223
  });
8044
8224
 
8225
+ // src/hub/phaseText.ts
8226
+ function isRecord(v2) {
8227
+ return typeof v2 === "object" && v2 !== null && !Array.isArray(v2);
8228
+ }
8229
+ function stripPlan(plan2) {
8230
+ if (!isRecord(plan2) || !isRecord(plan2.phases)) return plan2;
8231
+ const phases = {};
8232
+ for (const [k3, v2] of Object.entries(plan2.phases)) {
8233
+ const rawTitle = isRecord(v2) ? v2.title : void 0;
8234
+ phases[k3] = { title: typeof rawTitle === "string" ? rawTitle : "" };
8235
+ }
8236
+ return { ...plan2, phases };
8237
+ }
8238
+ function stripRepo(repo) {
8239
+ if (!isRecord(repo) || !isRecord(repo.plans) || !Array.isArray(repo.plans.plans)) return repo;
8240
+ return {
8241
+ ...repo,
8242
+ plans: {
8243
+ ...repo.plans,
8244
+ plans: repo.plans.plans.map(stripPlan)
8245
+ }
8246
+ };
8247
+ }
8248
+ function stripPhaseText(state) {
8249
+ if (!isRecord(state) || !Array.isArray(state.repos)) return state;
8250
+ return {
8251
+ ...state,
8252
+ repos: state.repos.map(stripRepo)
8253
+ };
8254
+ }
8255
+ function findPhaseSection(state, repoPath, planPath, key) {
8256
+ if (!isRecord(state) || !Array.isArray(state.repos)) return null;
8257
+ const repo = state.repos.find((r2) => isRecord(r2) && r2.path === repoPath);
8258
+ if (!repo || !isRecord(repo.plans) || !Array.isArray(repo.plans.plans)) return null;
8259
+ const plan2 = repo.plans.plans.find((p2) => isRecord(p2) && p2.path === planPath);
8260
+ if (!plan2 || !isRecord(plan2.phases)) return null;
8261
+ if (!Object.prototype.hasOwnProperty.call(plan2.phases, key)) return null;
8262
+ const sec = plan2.phases[key];
8263
+ if (!isRecord(sec)) return null;
8264
+ return {
8265
+ title: String(sec.title ?? ""),
8266
+ text: String(sec.text ?? "")
8267
+ };
8268
+ }
8269
+ var init_phaseText = __esm({
8270
+ "src/hub/phaseText.ts"() {
8271
+ "use strict";
8272
+ }
8273
+ });
8274
+
8045
8275
  // src/hub/server.ts
8046
8276
  import http from "http";
8047
8277
  import { existsSync as existsSync9 } from "fs";
8048
8278
  import { readFile, stat } from "fs/promises";
8049
- import path20 from "path";
8279
+ import path22 from "path";
8050
8280
  import { fileURLToPath as fileURLToPath2 } from "url";
8281
+ import { promisify } from "util";
8282
+ import { gzip } from "zlib";
8051
8283
  function defaultUiDir() {
8052
- const here = path20.dirname(fileURLToPath2(import.meta.url));
8053
- const beside = path20.join(here, "ui");
8054
- return existsSync9(beside) ? beside : path20.resolve(here, "..", "..", "dist", "ui");
8284
+ const here = path22.dirname(fileURLToPath2(import.meta.url));
8285
+ const beside = path22.join(here, "ui");
8286
+ return existsSync9(beside) ? beside : path22.resolve(here, "..", "..", "dist", "ui");
8055
8287
  }
8056
8288
  function resolveStatic(root, urlPath) {
8057
8289
  let decoded;
@@ -8062,9 +8294,9 @@ function resolveStatic(root, urlPath) {
8062
8294
  }
8063
8295
  if (decoded.includes(String.fromCharCode(0)) || decoded.includes(String.fromCharCode(92))) return null;
8064
8296
  if (decoded.split("/").includes("..")) return null;
8065
- const base = path20.resolve(root);
8066
- const file = path20.resolve(base, "." + decoded);
8067
- return file.startsWith(base + path20.sep) ? file : null;
8297
+ const base = path22.resolve(root);
8298
+ const file = path22.resolve(base, "." + decoded);
8299
+ return file.startsWith(base + path22.sep) ? file : null;
8068
8300
  }
8069
8301
  function send(res, status5, body, extra = {}) {
8070
8302
  const text2 = JSON.stringify(body);
@@ -8075,6 +8307,34 @@ function send(res, status5, body, extra = {}) {
8075
8307
  });
8076
8308
  res.end(text2);
8077
8309
  }
8310
+ function acceptsGzip(header) {
8311
+ if (!header) return false;
8312
+ const raw = Array.isArray(header) ? header.join(",") : header;
8313
+ for (const token of raw.split(",")) {
8314
+ const parts = token.split(";").map((p2) => p2.trim());
8315
+ const name = (parts[0] ?? "").toLowerCase();
8316
+ if (name !== "gzip") continue;
8317
+ const qPart = parts.slice(1).find((p2) => p2.startsWith("q="));
8318
+ const q2 = qPart !== void 0 ? Number(qPart.slice(2)) : 1;
8319
+ if (q2 > 0) return true;
8320
+ }
8321
+ return false;
8322
+ }
8323
+ async function sendState(req, res, state) {
8324
+ const text2 = JSON.stringify(state);
8325
+ if (acceptsGzip(req.headers["accept-encoding"])) {
8326
+ const zipped = await gzipAsync(text2);
8327
+ res.writeHead(200, {
8328
+ "Content-Type": "application/json; charset=utf-8",
8329
+ "Content-Encoding": "gzip",
8330
+ "Content-Length": zipped.length,
8331
+ Vary: "Accept-Encoding"
8332
+ });
8333
+ res.end(zipped);
8334
+ return;
8335
+ }
8336
+ return send(res, 200, state, { Vary: "Accept-Encoding" });
8337
+ }
8078
8338
  function readBody(req, limit = MAX_BODY_BYTES) {
8079
8339
  return new Promise((resolve, reject) => {
8080
8340
  const declared = Number(req.headers["content-length"] ?? 0);
@@ -8128,7 +8388,7 @@ async function serveStatic(res, uiDir, urlPath) {
8128
8388
  return fail(res, 404, "not_found");
8129
8389
  }
8130
8390
  res.writeHead(200, {
8131
- "Content-Type": MIME[path20.extname(file).toLowerCase()] ?? "application/octet-stream",
8391
+ "Content-Type": MIME[path22.extname(file).toLowerCase()] ?? "application/octet-stream",
8132
8392
  "Content-Length": body.length,
8133
8393
  "Cache-Control": urlPath === "/" ? "no-store" : "public, max-age=31536000, immutable"
8134
8394
  });
@@ -8144,7 +8404,7 @@ async function startServer(opts) {
8144
8404
  if (typeof opts.key !== "string" || Buffer.byteLength(opts.key, "utf8") < MIN_KEY_BYTES) {
8145
8405
  throw new Error(`the hub server key must be at least ${MIN_KEY_BYTES} bytes`);
8146
8406
  }
8147
- const auth = new AuthStore(opts.now ?? Date.now);
8407
+ const auth = new AuthStore(opts.now ?? Date.now, opts.sessionsFile);
8148
8408
  const { key, versions } = opts;
8149
8409
  const uiDir = opts.uiDir ?? defaultUiDir();
8150
8410
  let port = opts.port;
@@ -8164,23 +8424,23 @@ async function startServer(opts) {
8164
8424
  fail(res, 400, "bad_url");
8165
8425
  return;
8166
8426
  }
8167
- const path24 = url.pathname;
8427
+ const path26 = url.pathname;
8168
8428
  const method = req.method ?? "GET";
8169
- if (path24.startsWith("/api/") || path24 === "/login") res.setHeader("Cache-Control", "no-store");
8429
+ if (path26.startsWith("/api/") || path26 === "/login") res.setHeader("Cache-Control", "no-store");
8170
8430
  if (!hostAllowed(req.headers.host, port)) {
8171
- if (path24 === "/login") auth.discardCode(url.searchParams.get("code") ?? "");
8431
+ if (path26 === "/login") auth.discardCode(url.searchParams.get("code") ?? "");
8172
8432
  fail(res, 403, "bad_host");
8173
8433
  return;
8174
8434
  }
8175
- if (path24 === "/api/hub/whoami" && method === "GET") {
8435
+ if (path26 === "/api/hub/whoami" && method === "GET") {
8176
8436
  if (!opts.instance) return fail(res, 404, "not_found");
8177
8437
  return send(res, 200, { instance: opts.instance });
8178
8438
  }
8179
- if (path24 === "/api/health" && method === "GET") {
8439
+ if (path26 === "/api/health" && method === "GET") {
8180
8440
  if (!keyOk(req, key)) return fail(res, 401, "unauthorized");
8181
8441
  return send(res, 200, { schema: 1, ok: true, versions });
8182
8442
  }
8183
- if (path24 === "/api/hub/code" && method === "POST") {
8443
+ if (path26 === "/api/hub/code" && method === "POST") {
8184
8444
  if (!keyOk(req, key)) return fail(res, 401, "unauthorized");
8185
8445
  try {
8186
8446
  await readBody(req);
@@ -8191,7 +8451,7 @@ async function startServer(opts) {
8191
8451
  const code = auth.mintCode();
8192
8452
  return send(res, 200, { schema: 1, code, expires_at: auth.codeExpiresAt() });
8193
8453
  }
8194
- if (path24 === "/api/hub/stop" && method === "POST") {
8454
+ if (path26 === "/api/hub/stop" && method === "POST") {
8195
8455
  if (!keyOk(req, key)) return fail(res, 401, "unauthorized");
8196
8456
  try {
8197
8457
  await readBody(req);
@@ -8209,7 +8469,7 @@ async function startServer(opts) {
8209
8469
  if (!session) return fail(res, 401, "unauthorized");
8210
8470
  const token = req.headers[CSRF_HEADER];
8211
8471
  if (typeof token !== "string" || !safeEqual(token, session.csrf)) return fail(res, 403, "bad_csrf");
8212
- if (path24 === "/api/actions" && method === "POST" && opts.actions) {
8472
+ if (path26 === "/api/actions" && method === "POST" && opts.actions) {
8213
8473
  if (!tabSessionOf(req)) return fail(res, 401, "unauthorized");
8214
8474
  const type = String(req.headers["content-type"] ?? "").split(";")[0]?.trim().toLowerCase();
8215
8475
  if (type !== "application/json") return fail(res, 415, "json_only");
@@ -8235,36 +8495,36 @@ async function startServer(opts) {
8235
8495
  if (e2 instanceof BodyTooLarge) return tooLarge(req, res);
8236
8496
  throw e2;
8237
8497
  }
8238
- if (path24 === "/api/logout" && method === "POST") {
8239
- auth.deleteSession(session.id);
8498
+ if (path26 === "/api/logout" && method === "POST") {
8499
+ auth.deleteSession(parseCookies(req.headers.cookie)[SESSION_COOKIE] ?? "");
8240
8500
  return send(res, 200, { schema: 1, ok: true }, {
8241
8501
  "Set-Cookie": `${SESSION_COOKIE}=; HttpOnly; SameSite=Strict; Path=/; Max-Age=0`
8242
8502
  });
8243
8503
  }
8244
8504
  return fail(res, 404, "not_found");
8245
8505
  }
8246
- if (path24 === "/" || path24.startsWith("/assets/") || path24.startsWith("/fonts/")) {
8247
- await serveStatic(res, uiDir, path24);
8506
+ if (path26 === "/" || path26.startsWith("/assets/") || path26.startsWith("/fonts/")) {
8507
+ await serveStatic(res, uiDir, path26);
8248
8508
  return;
8249
8509
  }
8250
- if (path24 === "/login") {
8510
+ if (path26 === "/login") {
8251
8511
  const id = auth.redeemCode(url.searchParams.get("code") ?? "");
8252
8512
  const session = id ? auth.getSession(id) : null;
8253
8513
  if (!id || !session) return fail(res, 401, "bad_code");
8254
8514
  res.writeHead(303, {
8255
8515
  Location: `/#tab=${session.tab}`,
8256
- "Set-Cookie": `${SESSION_COOKIE}=${id}; HttpOnly; SameSite=Strict; Path=/`,
8516
+ "Set-Cookie": `${SESSION_COOKIE}=${id}; HttpOnly; SameSite=Strict; Path=/; Max-Age=${Math.floor(SESSION_MAX_MS / 1e3)}`,
8257
8517
  "Content-Length": 0
8258
8518
  });
8259
8519
  res.end();
8260
8520
  return;
8261
8521
  }
8262
- if (path24 === "/api/session") {
8522
+ if (path26 === "/api/session") {
8263
8523
  const session = tabSessionOf(req);
8264
8524
  if (!session) return fail(res, 401, "unauthorized");
8265
8525
  return send(res, 200, { schema: 1, csrf_token: session.csrf, versions });
8266
8526
  }
8267
- if (path24 === "/api/state") {
8527
+ if (path26 === "/api/state") {
8268
8528
  if (!tabSessionOf(req)) return fail(res, 401, "unauthorized");
8269
8529
  let state;
8270
8530
  try {
@@ -8272,7 +8532,22 @@ async function startServer(opts) {
8272
8532
  } catch {
8273
8533
  return fail(res, 500, "state_failed");
8274
8534
  }
8275
- return send(res, 200, state);
8535
+ return sendState(req, res, stripPhaseText(state));
8536
+ }
8537
+ if (path26 === "/api/plan-phase") {
8538
+ if (!tabSessionOf(req)) return fail(res, 401, "unauthorized");
8539
+ const repo = url.searchParams.get("repo") ?? "";
8540
+ const plan2 = url.searchParams.get("plan") ?? "";
8541
+ const phaseKey = url.searchParams.get("key") ?? "";
8542
+ if (!repo || !plan2 || !phaseKey) return fail(res, 400, "bad_request");
8543
+ let state;
8544
+ try {
8545
+ state = await opts.getState();
8546
+ } catch {
8547
+ return fail(res, 500, "state_failed");
8548
+ }
8549
+ const sec = findPhaseSection(state, repo, plan2, phaseKey);
8550
+ return sec ? send(res, 200, { schema: 1, ...sec }) : fail(res, 404, "not_found");
8276
8551
  }
8277
8552
  return fail(res, 404, "not_found");
8278
8553
  }
@@ -8303,12 +8578,13 @@ async function startServer(opts) {
8303
8578
  })
8304
8579
  };
8305
8580
  }
8306
- var SESSION_COOKIE, KEY_HEADER, CSRF_HEADER, TAB_HEADER, MAX_BODY_BYTES, MIN_KEY_BYTES, CSP, NOT_BUILT_HTML, MIME, BodyTooLarge, fail;
8581
+ var SESSION_COOKIE, KEY_HEADER, CSRF_HEADER, TAB_HEADER, MAX_BODY_BYTES, MIN_KEY_BYTES, CSP, NOT_BUILT_HTML, MIME, gzipAsync, BodyTooLarge, fail;
8307
8582
  var init_server = __esm({
8308
8583
  "src/hub/server.ts"() {
8309
8584
  "use strict";
8310
8585
  init_actions();
8311
8586
  init_auth();
8587
+ init_phaseText();
8312
8588
  SESSION_COOKIE = "caddis_hub_session";
8313
8589
  KEY_HEADER = "x-caddis-hub-key";
8314
8590
  CSRF_HEADER = "x-csrf-token";
@@ -8325,11 +8601,13 @@ var init_server = __esm({
8325
8601
  ".json": "application/json; charset=utf-8",
8326
8602
  ".svg": "image/svg+xml",
8327
8603
  ".png": "image/png",
8604
+ ".webp": "image/webp",
8328
8605
  ".ico": "image/x-icon",
8329
8606
  ".woff2": "font/woff2",
8330
8607
  ".txt": "text/plain; charset=utf-8",
8331
8608
  ".map": "application/json; charset=utf-8"
8332
8609
  };
8610
+ gzipAsync = promisify(gzip);
8333
8611
  BodyTooLarge = class extends Error {
8334
8612
  };
8335
8613
  fail = (res, status5, error) => send(res, status5, { schema: 1, error });
@@ -8353,8 +8631,8 @@ __export(hub_exports, {
8353
8631
  startHub: () => startHub
8354
8632
  });
8355
8633
  import http2 from "http";
8356
- import path21 from "path";
8357
- import { mkdirSync as mkdirSync7, readFileSync as readFileSync14 } from "fs";
8634
+ import path23 from "path";
8635
+ import { mkdirSync as mkdirSync8, readFileSync as readFileSync16 } from "fs";
8358
8636
  import { randomBytes as randomBytes4 } from "crypto";
8359
8637
  function defaultVersions2() {
8360
8638
  return { cli: packageInfo().version, caddis: bundleManifest().poolVersion };
@@ -8371,7 +8649,7 @@ function resolvePort(deps) {
8371
8649
  }
8372
8650
  function readKeyQuiet(home) {
8373
8651
  try {
8374
- const k3 = readFileSync14(keyPath(home), "utf8").trim();
8652
+ const k3 = readFileSync16(keyPath(home), "utf8").trim();
8375
8653
  return /^[0-9a-f]{64}$/.test(k3) ? k3 : null;
8376
8654
  } catch {
8377
8655
  return null;
@@ -8439,7 +8717,7 @@ async function isNodeProcess(pid) {
8439
8717
  if (!r2.ok) return false;
8440
8718
  const name = (r2.stdout.split(/\r?\n/)[0] ?? "").replace(/^"([^"]*)".*$/, "$1").trim().toLowerCase();
8441
8719
  if (!name) return false;
8442
- const runtime = path21.basename(process.execPath).toLowerCase().replace(/\.exe$/, "");
8720
+ const runtime = path23.basename(process.execPath).toLowerCase().replace(/\.exe$/, "");
8443
8721
  return name.includes("node") || name.includes(runtime);
8444
8722
  }
8445
8723
  async function defaultOpener(url) {
@@ -8528,7 +8806,8 @@ async function startHub(deps = {}) {
8528
8806
  versions: deps.versions ?? defaultVersions2(),
8529
8807
  now,
8530
8808
  instance: info.instance,
8531
- onStop: () => void stop()
8809
+ onStop: () => void stop(),
8810
+ sessionsFile: sessionsPath(home)
8532
8811
  });
8533
8812
  } catch (e2) {
8534
8813
  releaseLock(process.pid, home);
@@ -8570,7 +8849,7 @@ async function hubServe(deps = {}) {
8570
8849
  process.once("exit", onExit);
8571
8850
  line(`caddis hub serving on ${hubUrl(hub2.port)} (pid ${process.pid}); stop it with: caddis hub stop`);
8572
8851
  const pkgRoot = packageInfo().root;
8573
- const newEntry = path21.join(pkgRoot, "dist", "cli.js");
8852
+ const newEntry = path23.join(pkgRoot, "dist", "cli.js");
8574
8853
  const runningVersion = (deps.versions ?? defaultVersions2()).cli ?? packageInfo().version;
8575
8854
  const restarter = createRestarter({
8576
8855
  currentVersion: runningVersion,
@@ -8646,7 +8925,7 @@ async function hubStart(deps = {}) {
8646
8925
  return 1;
8647
8926
  }
8648
8927
  const cwd = hubDir(home);
8649
- mkdirSync7(cwd, { recursive: true });
8928
+ mkdirSync8(cwd, { recursive: true });
8650
8929
  const child = await (deps.spawn ?? defaultSpawn)(process.execPath, [entry, "hub", "serve"], { cwd });
8651
8930
  let exited = false;
8652
8931
  let exitCode = null;
@@ -8859,30 +9138,30 @@ var init_hub = __esm({
8859
9138
  // src/hub/export/data.ts
8860
9139
  function blocker(raw) {
8861
9140
  const b3 = rec3(raw);
8862
- return { type: str4(b3.type), reason: str4(b3.reason), check: str4(b3.check) };
9141
+ return { type: str5(b3.type), reason: str5(b3.reason), check: str5(b3.check) };
8863
9142
  }
8864
9143
  function phase(raw) {
8865
9144
  const p2 = rec3(raw);
8866
9145
  return {
8867
- ref: str4(p2.ref),
8868
- state: str4(p2.state),
8869
- plan: str4(p2.plan),
9146
+ ref: str5(p2.ref),
9147
+ state: str5(p2.state),
9148
+ plan: str5(p2.plan),
8870
9149
  num: int(p2.num),
8871
- name: str4(p2.name),
8872
- model: str4(p2.model),
8873
- lane: str4(p2.lane),
8874
- risk: str4(p2.risk),
8875
- tracker: str4(p2.tracker),
8876
- tile: str4(p2.tile),
9150
+ name: str5(p2.name),
9151
+ model: str5(p2.model),
9152
+ lane: str5(p2.lane),
9153
+ risk: str5(p2.risk),
9154
+ tracker: str5(p2.tracker),
9155
+ tile: str5(p2.tile),
8877
9156
  prs: arr2(p2.prs).filter((n) => typeof n === "number" && Number.isInteger(n) && n > 0)
8878
9157
  };
8879
9158
  }
8880
9159
  function milestone(raw) {
8881
9160
  const m2 = rec3(raw);
8882
9161
  return {
8883
- id: str4(m2.id),
8884
- status: str4(m2.status),
8885
- owner: str4(m2.owner),
9162
+ id: str5(m2.id),
9163
+ status: str5(m2.status),
9164
+ owner: str5(m2.owner),
8886
9165
  target: strOrNull(m2.target),
8887
9166
  depends: arr2(m2.depends).filter((d3) => typeof d3 === "string"),
8888
9167
  blockers: arr2(m2.blockers).map(blocker),
@@ -8891,19 +9170,19 @@ function milestone(raw) {
8891
9170
  }
8892
9171
  function roadmap(raw) {
8893
9172
  const r2 = rec3(raw);
8894
- if (r2.error !== void 0) return { roadmap: str4(r2.roadmap), error: ERROR_TEXT };
9173
+ if (r2.error !== void 0) return { roadmap: str5(r2.roadmap), error: ERROR_TEXT };
8895
9174
  const next = rec3(r2.next);
8896
9175
  const out = {
8897
- roadmap: str4(r2.roadmap),
9176
+ roadmap: str5(r2.roadmap),
8898
9177
  branch: strOrNull(r2.branch),
8899
9178
  origin_commit: shortSha(r2.origin_commit),
8900
9179
  done: int(r2.done),
8901
9180
  total: int(r2.total),
8902
- next: Object.keys(next).length ? { milestone: str4(next.milestone), plan: str4(next.plan), phase: int(next.phase) } : null,
9181
+ next: Object.keys(next).length ? { milestone: str5(next.milestone), plan: str5(next.plan), phase: int(next.phase) } : null,
8903
9182
  lanes: arr2(r2.lanes).filter((l2) => typeof l2 === "string"),
8904
9183
  waiting: arr2(r2.waiting).map((w2) => {
8905
9184
  const x2 = rec3(w2);
8906
- return { milestone: str4(x2.milestone), reason: str4(x2.reason), check: str4(x2.check) };
9185
+ return { milestone: str5(x2.milestone), reason: str5(x2.reason), check: str5(x2.check) };
8907
9186
  }),
8908
9187
  milestones: arr2(r2.milestones).map(milestone)
8909
9188
  };
@@ -8916,12 +9195,12 @@ function safePlanPath(p2) {
8916
9195
  }
8917
9196
  function plan(raw) {
8918
9197
  const p2 = rec3(raw);
8919
- if (p2.error !== void 0 || !safePlanPath(str4(p2.path))) return null;
9198
+ if (p2.error !== void 0 || !safePlanPath(str5(p2.path))) return null;
8920
9199
  return {
8921
- path: str4(p2.path),
8922
- title: str4(p2.title),
8923
- status: str4(p2.status),
8924
- tracker: arr2(p2.tracker).map((t) => ({ phase: str4(rec3(t).phase), status: str4(rec3(t).status), state: str4(rec3(t).state) })),
9200
+ path: str5(p2.path),
9201
+ title: str5(p2.title),
9202
+ status: str5(p2.status),
9203
+ tracker: arr2(p2.tracker).map((t) => ({ phase: str5(rec3(t).phase), status: str5(rec3(t).status), state: str5(rec3(t).state) })),
8925
9204
  open_rows: int(p2.open_rows)
8926
9205
  };
8927
9206
  }
@@ -8959,7 +9238,7 @@ function derivedDeny(collect, machine) {
8959
9238
  if (s.length >= 3) out.add(s);
8960
9239
  };
8961
9240
  const addPath = (v2) => {
8962
- const s = str4(v2).trim();
9241
+ const s = str5(v2).trim();
8963
9242
  if (!s) return;
8964
9243
  add(s);
8965
9244
  add(s.replace(/\\/g, "/"));
@@ -8985,7 +9264,7 @@ function derivedDeny(collect, machine) {
8985
9264
  if (!GENERIC_NAMES.has(machine.user.toLowerCase())) add(machine.user);
8986
9265
  return [...out];
8987
9266
  }
8988
- var GITHUB_RE, ERROR_TEXT, rec3, arr2, str4, strOrNull, int, shortSha, GENERIC_NAMES;
9267
+ var GITHUB_RE, ERROR_TEXT, rec3, arr2, str5, strOrNull, int, shortSha, GENERIC_NAMES;
8989
9268
  var init_data = __esm({
8990
9269
  "src/hub/export/data.ts"() {
8991
9270
  "use strict";
@@ -8993,11 +9272,11 @@ var init_data = __esm({
8993
9272
  ERROR_TEXT = "could not be read";
8994
9273
  rec3 = (v2) => v2 && typeof v2 === "object" && !Array.isArray(v2) ? v2 : {};
8995
9274
  arr2 = (v2) => Array.isArray(v2) ? v2 : [];
8996
- str4 = (v2) => typeof v2 === "string" ? v2 : "";
9275
+ str5 = (v2) => typeof v2 === "string" ? v2 : "";
8997
9276
  strOrNull = (v2) => typeof v2 === "string" && v2 ? v2 : null;
8998
9277
  int = (v2) => typeof v2 === "number" && Number.isInteger(v2) ? v2 : 0;
8999
9278
  shortSha = (v2) => {
9000
- const s = str4(v2);
9279
+ const s = str5(v2);
9001
9280
  return /^[0-9a-fA-F]{7,}$/.test(s) ? s.slice(0, 7) : null;
9002
9281
  };
9003
9282
  GENERIC_NAMES = /* @__PURE__ */ new Set(["runner", "root", "user", "users", "admin", "administrator", "ubuntu", "localhost", "github"]);
@@ -9005,8 +9284,8 @@ var init_data = __esm({
9005
9284
  });
9006
9285
 
9007
9286
  // src/hub/export/privacy.ts
9008
- import { lstatSync, readdirSync as readdirSync4, readFileSync as readFileSync15 } from "fs";
9009
- import path22 from "path";
9287
+ import { lstatSync, readdirSync as readdirSync5, readFileSync as readFileSync17 } from "fs";
9288
+ import path24 from "path";
9010
9289
  function parseAllowedUrls(text2) {
9011
9290
  const exact = /* @__PURE__ */ new Set();
9012
9291
  const templates = [];
@@ -9019,13 +9298,13 @@ function parseAllowedUrls(text2) {
9019
9298
  return { exact, templates };
9020
9299
  }
9021
9300
  function defaultAllowedUrls() {
9022
- return readFileSync15(new URL("./allowed-urls.txt", import.meta.url), "utf8");
9301
+ return readFileSync17(new URL("./allowed-urls.txt", import.meta.url), "utf8");
9023
9302
  }
9024
9303
  function walk(dir, base = "") {
9025
9304
  const out = [];
9026
- for (const name of readdirSync4(dir).sort()) {
9305
+ for (const name of readdirSync5(dir).sort()) {
9027
9306
  const rel = base ? `${base}/${name}` : name;
9028
- const full = path22.join(dir, name);
9307
+ const full = path24.join(dir, name);
9029
9308
  if (lstatSync(full).isDirectory()) out.push(...walk(full, rel));
9030
9309
  else out.push(rel);
9031
9310
  }
@@ -9061,13 +9340,13 @@ function scanUrls(file, text2, opts, hits) {
9061
9340
  function scanExport(dir, opts) {
9062
9341
  const hits = [];
9063
9342
  for (const file of walk(dir)) {
9064
- const full = path22.join(dir, ...file.split("/"));
9343
+ const full = path24.join(dir, ...file.split("/"));
9065
9344
  if (lstatSync(full).isSymbolicLink()) {
9066
9345
  hits.push({ file, offset: 0, rule: "symbolic-link" });
9067
9346
  continue;
9068
9347
  }
9069
- const buf = readFileSync15(full);
9070
- const binary = BINARY_EXT.has(path22.extname(file).toLowerCase());
9348
+ const buf = readFileSync17(full);
9349
+ const binary = BINARY_EXT.has(path24.extname(file).toLowerCase());
9071
9350
  const text2 = binary ? null : buf.toString("utf8");
9072
9351
  scanDeny(file, buf, text2, opts.deny, hits);
9073
9352
  if (text2 === null) continue;
@@ -9147,19 +9426,18 @@ import {
9147
9426
  copyFileSync,
9148
9427
  existsSync as existsSync10,
9149
9428
  lstatSync as lstatSync2,
9150
- mkdirSync as mkdirSync8,
9151
- readdirSync as readdirSync5,
9152
- readFileSync as readFileSync16,
9153
- renameSync as renameSync3,
9429
+ mkdirSync as mkdirSync9,
9430
+ readdirSync as readdirSync6,
9431
+ readFileSync as readFileSync18,
9154
9432
  rmSync as rmSync4,
9155
9433
  statSync as statSync3,
9156
- writeFileSync as writeFileSync5
9434
+ writeFileSync as writeFileSync6
9157
9435
  } from "fs";
9158
9436
  import os6 from "os";
9159
- import path23 from "path";
9437
+ import path25 from "path";
9160
9438
  function holdsLink(dir) {
9161
- for (const name of readdirSync5(dir)) {
9162
- const full = path23.join(dir, name);
9439
+ for (const name of readdirSync6(dir)) {
9440
+ const full = path25.join(dir, name);
9163
9441
  const st = lstatSync2(full);
9164
9442
  if (st.isSymbolicLink()) return true;
9165
9443
  if (st.isDirectory() && holdsLink(full)) return true;
@@ -9177,8 +9455,8 @@ function checkOut(out, repo) {
9177
9455
  }
9178
9456
  if (st.isSymbolicLink()) return "--out is a link";
9179
9457
  if (!st.isDirectory()) return "--out is a file";
9180
- if (readdirSync5(out).length === 0) return null;
9181
- if (!existsSync10(path23.join(out, MARKER)) || lstatSync2(path23.join(out, MARKER)).isSymbolicLink()) {
9458
+ if (readdirSync6(out).length === 0) return null;
9459
+ if (!existsSync10(path25.join(out, MARKER)) || lstatSync2(path25.join(out, MARKER)).isSymbolicLink()) {
9182
9460
  return `--out is not empty and has no ${MARKER} marker: this command did not make it`;
9183
9461
  }
9184
9462
  if (holdsLink(out)) return "--out holds a link";
@@ -9204,33 +9482,33 @@ function notFoundPage() {
9204
9482
  `;
9205
9483
  }
9206
9484
  function copyFixedSet(dist, dest) {
9207
- mkdirSync8(path23.join(dest, "assets"), { recursive: true });
9208
- mkdirSync8(path23.join(dest, "fonts"), { recursive: true });
9209
- mkdirSync8(path23.join(dest, "licenses"), { recursive: true });
9210
- copyFileSync(path23.join(dist, "index.html"), path23.join(dest, "index.html"));
9211
- for (const name of readdirSync5(path23.join(dist, "assets"))) {
9212
- const from = path23.join(dist, "assets", name);
9213
- if (lstatSync2(from).isFile()) copyFileSync(from, path23.join(dest, "assets", name));
9214
- }
9215
- const fonts = path23.join(dist, "fonts");
9485
+ mkdirSync9(path25.join(dest, "assets"), { recursive: true });
9486
+ mkdirSync9(path25.join(dest, "fonts"), { recursive: true });
9487
+ mkdirSync9(path25.join(dest, "licenses"), { recursive: true });
9488
+ copyFileSync(path25.join(dist, "index.html"), path25.join(dest, "index.html"));
9489
+ for (const name of readdirSync6(path25.join(dist, "assets"))) {
9490
+ const from = path25.join(dist, "assets", name);
9491
+ if (lstatSync2(from).isFile()) copyFileSync(from, path25.join(dest, "assets", name));
9492
+ }
9493
+ const fonts = path25.join(dist, "fonts");
9216
9494
  if (isDir2(fonts)) {
9217
- for (const name of readdirSync5(fonts)) {
9218
- const from = path23.join(fonts, name);
9495
+ for (const name of readdirSync6(fonts)) {
9496
+ const from = path25.join(fonts, name);
9219
9497
  if (!lstatSync2(from).isFile()) continue;
9220
- if (name.endsWith(".woff2")) copyFileSync(from, path23.join(dest, "fonts", name));
9498
+ if (name.endsWith(".woff2")) copyFileSync(from, path25.join(dest, "fonts", name));
9221
9499
  }
9222
9500
  }
9223
- const licenses = path23.join(dist, "licenses");
9501
+ const licenses = path25.join(dist, "licenses");
9224
9502
  if (isDir2(licenses)) {
9225
- for (const name of readdirSync5(licenses)) {
9226
- const from = path23.join(licenses, name);
9227
- if (lstatSync2(from).isFile() && /^(OFL-[A-Za-z]+|LICENSE-Lucide)\.txt$/.test(name)) copyFileSync(from, path23.join(dest, "licenses", name));
9503
+ for (const name of readdirSync6(licenses)) {
9504
+ const from = path25.join(licenses, name);
9505
+ if (lstatSync2(from).isFile() && /^(OFL-[A-Za-z]+|LICENSE-Lucide)\.txt$/.test(name)) copyFileSync(from, path25.join(dest, "licenses", name));
9228
9506
  }
9229
9507
  }
9230
9508
  }
9231
9509
  function countFiles(dir) {
9232
- return readdirSync5(dir).reduce((n, name) => {
9233
- const full = path23.join(dir, name);
9510
+ return readdirSync6(dir).reduce((n, name) => {
9511
+ const full = path25.join(dir, name);
9234
9512
  return n + (lstatSync2(full).isDirectory() ? countFiles(full) : name === MARKER ? 0 : 1);
9235
9513
  }, 0);
9236
9514
  }
@@ -9252,7 +9530,7 @@ async function hubExport(args, deps = {}) {
9252
9530
  return 2;
9253
9531
  }
9254
9532
  if (args.check !== void 0) {
9255
- const dir = path23.resolve(args.check);
9533
+ const dir = path25.resolve(args.check);
9256
9534
  if (!isDir2(dir)) {
9257
9535
  err(`error: --check folder not found: ${args.check}`);
9258
9536
  return 1;
@@ -9276,9 +9554,9 @@ async function hubExport(args, deps = {}) {
9276
9554
  err("error: --commit must be 7 to 40 hex characters");
9277
9555
  return 2;
9278
9556
  }
9279
- const repo = path23.resolve(args.repo);
9280
- const outDir = path23.resolve(args.out);
9281
- if (!existsSync10(path23.join(repo, ".git")) || !(isDir2(path23.join(repo, ".caddis", "roadmaps")) || isDir2(path23.join(repo, ".caddis", "plans")))) {
9557
+ const repo = path25.resolve(args.repo);
9558
+ const outDir = path25.resolve(args.out);
9559
+ if (!existsSync10(path25.join(repo, ".git")) || !(isDir2(path25.join(repo, ".caddis", "roadmaps")) || isDir2(path25.join(repo, ".caddis", "plans")))) {
9282
9560
  err("error: --repo must be a git checkout with .caddis/roadmaps/ or .caddis/plans/");
9283
9561
  return 2;
9284
9562
  }
@@ -9287,8 +9565,8 @@ async function hubExport(args, deps = {}) {
9287
9565
  err(`error: ${refused}`);
9288
9566
  return 2;
9289
9567
  }
9290
- const dist = deps.distDir ?? path23.join(packageInfo().root, "dist", "export");
9291
- if (!existsSync10(path23.join(dist, "index.html")) || !isDir2(path23.join(dist, "assets"))) {
9568
+ const dist = deps.distDir ?? path25.join(packageInfo().root, "dist", "export");
9569
+ if (!existsSync10(path25.join(dist, "index.html")) || !isDir2(path25.join(dist, "assets"))) {
9292
9570
  err(`error: the export app is not built (${dist}). Run: npm run build:ui`);
9293
9571
  return 1;
9294
9572
  }
@@ -9333,12 +9611,12 @@ async function hubExport(args, deps = {}) {
9333
9611
  rmSync4(staging, { recursive: true, force: true });
9334
9612
  try {
9335
9613
  copyFixedSet(dist, staging);
9336
- const indexPath = path23.join(staging, "index.html");
9337
- const html = readFileSync16(indexPath, "utf8");
9614
+ const indexPath = path25.join(staging, "index.html");
9615
+ const html = readFileSync18(indexPath, "utf8");
9338
9616
  if (!html.includes(PLACEHOLDER)) throw new Error("the built index.html has no data placeholder");
9339
9617
  const block = `<script type="application/json" id="caddis-export-data">${escapeJson(JSON.stringify(data))}</script>`;
9340
- writeFileSync5(indexPath, html.replace(PLACEHOLDER, () => block));
9341
- writeFileSync5(path23.join(staging, "404.html"), notFoundPage());
9618
+ writeFileSync6(indexPath, html.replace(PLACEHOLDER, () => block));
9619
+ writeFileSync6(path25.join(staging, "404.html"), notFoundPage());
9342
9620
  const hits = scanExport(staging, { deny, github: args.github ?? null, ...deps.allowedUrls !== void 0 ? { allowedUrls: deps.allowedUrls } : {} });
9343
9621
  if (hits.length) {
9344
9622
  for (const h2 of hits) err(hitLine(h2));
@@ -9346,10 +9624,10 @@ async function hubExport(args, deps = {}) {
9346
9624
  rmSync4(staging, { recursive: true, force: true });
9347
9625
  return 3;
9348
9626
  }
9349
- mkdirSync8(path23.dirname(outDir), { recursive: true });
9627
+ mkdirSync9(path25.dirname(outDir), { recursive: true });
9350
9628
  if (existsSync10(outDir)) rmSync4(outDir, { recursive: true, force: true });
9351
- renameSync3(staging, outDir);
9352
- writeFileSync5(path23.join(outDir, MARKER), "written by caddis hub export\n");
9629
+ renameWithRetry(staging, outDir);
9630
+ writeFileSync6(path25.join(outDir, MARKER), "written by caddis hub export\n");
9353
9631
  out(`[EXPORT] ${countFiles(outDir)} file(s) in ${outDir}`);
9354
9632
  return 0;
9355
9633
  } catch (error) {
@@ -9363,6 +9641,7 @@ var init_export = __esm({
9363
9641
  "src/hub/export/export.ts"() {
9364
9642
  "use strict";
9365
9643
  init_pkg();
9644
+ init_config();
9366
9645
  init_spawn();
9367
9646
  init_collector();
9368
9647
  init_data();
@@ -9379,12 +9658,12 @@ var init_export = __esm({
9379
9658
  }
9380
9659
  };
9381
9660
  samePath = (a, b3) => {
9382
- const norm = (p2) => path23.resolve(p2).replace(/[\\/]+$/, "").toLowerCase();
9661
+ const norm = (p2) => path25.resolve(p2).replace(/[\\/]+$/, "").toLowerCase();
9383
9662
  return norm(a) === norm(b3);
9384
9663
  };
9385
9664
  isInside = (child, parent) => {
9386
- const rel = path23.relative(path23.resolve(parent), path23.resolve(child));
9387
- return rel !== "" && !rel.startsWith("..") && !path23.isAbsolute(rel);
9665
+ const rel = path25.relative(path25.resolve(parent), path25.resolve(child));
9666
+ return rel !== "" && !rel.startsWith("..") && !path25.isAbsolute(rel);
9388
9667
  };
9389
9668
  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]));";
9390
9669
  }
@@ -9445,14 +9724,14 @@ function* pluginBlocks(stdout) {
9445
9724
  if (current) yield current;
9446
9725
  }
9447
9726
  async function detect() {
9448
- const path24 = await findBin(BIN);
9449
- if (!path24) {
9727
+ const path26 = await findBin(BIN);
9728
+ if (!path26) {
9450
9729
  return { present: false, note: "no `claude` binary on PATH" };
9451
9730
  }
9452
9731
  const version = await run(BIN, ["--version"], { timeout: 2e4 });
9453
9732
  return {
9454
9733
  present: true,
9455
- path: path24,
9734
+ path: path26,
9456
9735
  agentVersion: version.ok ? version.stdout.trim().split(/\s+/)[0] || void 0 : void 0,
9457
9736
  note: version.ok ? void 0 : "binary found but `claude --version` failed"
9458
9737
  };