@caddis/cli 0.4.88 → 0.4.89
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -0
- package/bundles/antigravity-plugin/agents/preflight.md +4 -0
- package/bundles/antigravity-plugin/plugin.json +1 -1
- package/bundles/antigravity-plugin/scripts/__pycache__/caddis_exit.cpython-311.pyc +0 -0
- package/bundles/antigravity-plugin/scripts/__pycache__/caddis_file_lock.cpython-311.pyc +0 -0
- package/bundles/antigravity-plugin/scripts/__pycache__/caddis_frontmatter.cpython-311.pyc +0 -0
- package/bundles/antigravity-plugin/scripts/__pycache__/caddis_redact.cpython-311.pyc +0 -0
- package/bundles/antigravity-plugin/scripts/__pycache__/caddis_roadmap.cpython-311.pyc +0 -0
- package/bundles/antigravity-plugin/scripts/__pycache__/caddis_rows.cpython-311.pyc +0 -0
- package/bundles/antigravity-plugin/scripts/__pycache__/caddis_status.cpython-311.pyc +0 -0
- package/bundles/antigravity-plugin/scripts/__pycache__/caddis_tidy.cpython-311.pyc +0 -0
- package/bundles/antigravity-plugin/scripts/__pycache__/caddis_todo.cpython-311.pyc +0 -0
- package/bundles/antigravity-plugin/scripts/__pycache__/caddis_workstreams.cpython-311.pyc +0 -0
- package/bundles/antigravity-plugin/scripts/__pycache__/caddis_worktree_safety.cpython-311.pyc +0 -0
- package/bundles/antigravity-plugin/scripts/caddis_fleet.py +28 -6
- package/bundles/antigravity-plugin/scripts/caddis_guide.json +16 -11
- package/bundles/antigravity-plugin/scripts/caddis_handoff.py +370 -0
- package/bundles/antigravity-plugin/scripts/caddis_heartbeat.py +339 -0
- package/bundles/antigravity-plugin/scripts/caddis_hub_collect.py +37 -8
- package/bundles/antigravity-plugin/scripts/caddis_routing.py +36 -0
- package/bundles/antigravity-plugin/scripts/caddis_todo.py +55 -10
- package/bundles/antigravity-plugin/scripts/schemas/hub-collect.schema.json +42 -0
- package/bundles/antigravity-plugin/scripts/schemas/hub-plans.schema.json +23 -0
- package/bundles/antigravity-plugin/session_end_agy.py +26 -1
- package/bundles/antigravity-plugin/skills/coordinate/SKILL.md +5 -3
- package/bundles/antigravity-plugin/skills/feature-plan/SKILL.md +47 -19
- package/bundles/antigravity-plugin/skills/fleet-open/SKILL.md +1 -1
- package/bundles/antigravity-plugin/skills/handoff/SKILL.md +77 -6
- package/bundles/antigravity-plugin/skills/implement/SKILL.md +67 -5
- package/bundles/antigravity-plugin/warm_start_agy.py +29 -1
- package/bundles/manifest.json +2 -2
- package/dist/allowed-urls.txt +3 -2
- package/dist/cli.js +545 -274
- package/dist/export/assets/export-B7BBDg5I.js +150 -0
- package/dist/export/assets/export-HxTgj3z2.css +1 -0
- package/dist/export/assets/mark-anim-DZa95SHo.webp +0 -0
- package/dist/export/assets/mark-still-CcPgBc_-.png +0 -0
- package/dist/export/fonts/ibm-plex-mono-400.6d569bb7.woff2 +0 -0
- package/dist/export/fonts/ibm-plex-mono-700.9f478677.woff2 +0 -0
- package/dist/export/fonts/ibm-plex-sans-400.17fc1ce7.woff2 +0 -0
- package/dist/export/fonts/ibm-plex-sans-500.dcc69acf.woff2 +0 -0
- package/dist/export/fonts/ibm-plex-sans-600.d4dad061.woff2 +0 -0
- package/dist/export/fonts/ibm-plex-sans-700.40d9a530.woff2 +0 -0
- package/dist/export/index.html +2 -2
- package/dist/export/licenses/{OFL-MapleMono.txt → OFL-IBMPlexMono.txt} +4 -4
- package/dist/{ui/licenses/OFL-MapleMono.txt → export/licenses/OFL-IBMPlexSans.txt} +4 -4
- package/dist/ui/assets/{Activity-C9TCizJV.js → Activity-DZKPMOeV.js} +1 -1
- package/dist/ui/assets/Guide-5ZFfL6sl.js +9 -0
- package/dist/ui/assets/Guide-Dnsb-TRd.css +1 -0
- package/dist/ui/assets/RoadmapTab-DPsiSmIF.js +31 -0
- package/dist/ui/assets/index-DGlNAmeA.css +1 -0
- package/dist/ui/assets/index-xl156OCN.js +231 -0
- package/dist/ui/assets/mark-anim-DZa95SHo.webp +0 -0
- package/dist/ui/assets/mark-still-CcPgBc_-.png +0 -0
- package/dist/ui/fonts/ibm-plex-mono-400.6d569bb7.woff2 +0 -0
- package/dist/ui/fonts/ibm-plex-mono-700.9f478677.woff2 +0 -0
- package/dist/ui/fonts/ibm-plex-sans-400.17fc1ce7.woff2 +0 -0
- package/dist/ui/fonts/ibm-plex-sans-500.dcc69acf.woff2 +0 -0
- package/dist/ui/fonts/ibm-plex-sans-600.d4dad061.woff2 +0 -0
- package/dist/ui/fonts/ibm-plex-sans-700.40d9a530.woff2 +0 -0
- package/dist/ui/index.html +2 -2
- package/dist/{export/licenses/OFL-Atkinson.txt → ui/licenses/OFL-IBMPlexMono.txt} +3 -3
- package/dist/ui/licenses/{OFL-Atkinson.txt → OFL-IBMPlexSans.txt} +3 -3
- package/package.json +4 -1
- package/dist/export/assets/export-CEtCs5rg.css +0 -1
- package/dist/export/assets/export-v-kcNvPW.js +0 -150
- package/dist/export/assets/mark-small-B1q4Vk3J.svg +0 -8
- package/dist/export/fonts/atkinson-400.849ae6f0.woff2 +0 -0
- package/dist/export/fonts/atkinson-500.21d6ef26.woff2 +0 -0
- package/dist/export/fonts/atkinson-600.ce9f3210.woff2 +0 -0
- package/dist/export/fonts/atkinson-700.3a9cc18a.woff2 +0 -0
- package/dist/export/fonts/maple-mono-400.071799fd.woff2 +0 -0
- package/dist/export/fonts/maple-mono-700.1e17b237.woff2 +0 -0
- package/dist/ui/assets/Guide-6aEYW9oW.js +0 -9
- package/dist/ui/assets/Guide-zcVFGUxR.css +0 -1
- package/dist/ui/assets/RoadmapTab-hUK2kzCW.js +0 -31
- package/dist/ui/assets/index-DE7v-v_o.css +0 -1
- package/dist/ui/assets/index-d44hkSAE.js +0 -221
- package/dist/ui/assets/mark-small-B1q4Vk3J.svg +0 -8
- package/dist/ui/fonts/atkinson-400.849ae6f0.woff2 +0 -0
- package/dist/ui/fonts/atkinson-500.21d6ef26.woff2 +0 -0
- package/dist/ui/fonts/atkinson-600.ce9f3210.woff2 +0 -0
- package/dist/ui/fonts/atkinson-700.3a9cc18a.woff2 +0 -0
- package/dist/ui/fonts/maple-mono-400.071799fd.woff2 +0 -0
- 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(
|
|
643
|
-
return stripColor(
|
|
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(
|
|
652
|
-
return
|
|
651
|
+
styleTitle(str6) {
|
|
652
|
+
return str6;
|
|
653
653
|
}
|
|
654
|
-
styleUsage(
|
|
655
|
-
return
|
|
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(
|
|
664
|
-
return this.styleDescriptionText(
|
|
663
|
+
styleCommandDescription(str6) {
|
|
664
|
+
return this.styleDescriptionText(str6);
|
|
665
665
|
}
|
|
666
|
-
styleOptionDescription(
|
|
667
|
-
return this.styleDescriptionText(
|
|
666
|
+
styleOptionDescription(str6) {
|
|
667
|
+
return this.styleDescriptionText(str6);
|
|
668
668
|
}
|
|
669
|
-
styleSubcommandDescription(
|
|
670
|
-
return this.styleDescriptionText(
|
|
669
|
+
styleSubcommandDescription(str6) {
|
|
670
|
+
return this.styleDescriptionText(str6);
|
|
671
671
|
}
|
|
672
|
-
styleArgumentDescription(
|
|
673
|
-
return this.styleDescriptionText(
|
|
672
|
+
styleArgumentDescription(str6) {
|
|
673
|
+
return this.styleDescriptionText(str6);
|
|
674
674
|
}
|
|
675
|
-
styleDescriptionText(
|
|
676
|
-
return
|
|
675
|
+
styleDescriptionText(str6) {
|
|
676
|
+
return str6;
|
|
677
677
|
}
|
|
678
|
-
styleOptionTerm(
|
|
679
|
-
return this.styleOptionText(
|
|
678
|
+
styleOptionTerm(str6) {
|
|
679
|
+
return this.styleOptionText(str6);
|
|
680
680
|
}
|
|
681
|
-
styleSubcommandTerm(
|
|
682
|
-
return
|
|
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(
|
|
690
|
-
return this.styleArgumentText(
|
|
689
|
+
styleArgumentTerm(str6) {
|
|
690
|
+
return this.styleArgumentText(str6);
|
|
691
691
|
}
|
|
692
|
-
styleOptionText(
|
|
693
|
-
return
|
|
692
|
+
styleOptionText(str6) {
|
|
693
|
+
return str6;
|
|
694
694
|
}
|
|
695
|
-
styleArgumentText(
|
|
696
|
-
return
|
|
695
|
+
styleArgumentText(str6) {
|
|
696
|
+
return str6;
|
|
697
697
|
}
|
|
698
|
-
styleSubcommandText(
|
|
699
|
-
return
|
|
698
|
+
styleSubcommandText(str6) {
|
|
699
|
+
return str6;
|
|
700
700
|
}
|
|
701
|
-
styleCommandText(
|
|
702
|
-
return
|
|
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(
|
|
726
|
-
return /\n[^\S\r\n]/.test(
|
|
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(
|
|
773
|
-
if (width < this.minWidthToWrap) return
|
|
774
|
-
const rawLines =
|
|
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(
|
|
802
|
+
function stripColor(str6) {
|
|
803
803
|
const sgrPattern = /\x1b\[\d*(;\d*)*m/g;
|
|
804
|
-
return
|
|
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(
|
|
1077
|
-
return
|
|
1078
|
-
return
|
|
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
|
|
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: (
|
|
1262
|
-
writeErr: (
|
|
1263
|
-
outputError: (
|
|
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: (
|
|
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 =
|
|
2225
|
+
const localBin = path26.resolve(baseDir, baseName);
|
|
2226
2226
|
if (fs.existsSync(localBin)) return localBin;
|
|
2227
|
-
if (sourceExt.includes(
|
|
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 =
|
|
2246
|
-
|
|
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 =
|
|
2253
|
+
const legacyName = path26.basename(
|
|
2254
2254
|
this._scriptPath,
|
|
2255
|
-
|
|
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(
|
|
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(
|
|
2993
|
-
if (
|
|
2994
|
-
this._version =
|
|
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(`${
|
|
3001
|
+
this._outputConfiguration.writeOut(`${str6}
|
|
3002
3002
|
`);
|
|
3003
|
-
this._exit(0, "commander.version",
|
|
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(
|
|
3015
|
-
if (
|
|
3014
|
+
description(str6, argsDescription) {
|
|
3015
|
+
if (str6 === void 0 && argsDescription === void 0)
|
|
3016
3016
|
return this._description;
|
|
3017
|
-
this._description =
|
|
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(
|
|
3030
|
-
if (
|
|
3031
|
-
this._summary =
|
|
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(
|
|
3080
|
-
if (
|
|
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 =
|
|
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(
|
|
3101
|
-
if (
|
|
3102
|
-
this._name =
|
|
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 =
|
|
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(
|
|
3196
|
-
if (
|
|
3197
|
-
this._executableDir =
|
|
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 = (
|
|
3236
|
+
baseWrite = (str6) => this._outputConfiguration.writeErr(str6);
|
|
3237
3237
|
hasColors = this._outputConfiguration.getErrHasColors();
|
|
3238
3238
|
helpWidth = this._outputConfiguration.getErrHelpWidth();
|
|
3239
3239
|
} else {
|
|
3240
|
-
baseWrite = (
|
|
3240
|
+
baseWrite = (str6) => this._outputConfiguration.writeOut(str6);
|
|
3241
3241
|
hasColors = this._outputConfiguration.getOutHasColors();
|
|
3242
3242
|
helpWidth = this._outputConfiguration.getOutHelpWidth();
|
|
3243
3243
|
}
|
|
3244
|
-
const write = (
|
|
3245
|
-
if (!hasColors)
|
|
3246
|
-
return baseWrite(
|
|
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(
|
|
4910
|
+
function parseKeysFile(path26) {
|
|
4911
4911
|
let text2;
|
|
4912
4912
|
try {
|
|
4913
|
-
text2 = readFileSync3(
|
|
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(
|
|
5025
|
+
function restrictPermissions(path26) {
|
|
5026
5026
|
if (process.platform === "win32") return null;
|
|
5027
5027
|
try {
|
|
5028
|
-
chmodSync(
|
|
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
|
|
5036
|
-
const fileKeys = parseKeysFile(
|
|
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 ${
|
|
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: ${
|
|
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 ${
|
|
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(
|
|
5132
|
+
existing = readFileSync4(path26, "utf8");
|
|
5133
5133
|
} catch {
|
|
5134
5134
|
existing = "";
|
|
5135
5135
|
}
|
|
5136
|
-
mkdirSync2(dirname(
|
|
5137
|
-
writeFileSync(
|
|
5138
|
-
const permWarning = restrictPermissions(
|
|
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 ${
|
|
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/
|
|
6755
|
-
import {
|
|
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 =
|
|
6844
|
+
let dir = path16.resolve(cwd);
|
|
6765
6845
|
for (; ; ) {
|
|
6766
|
-
const dotGit =
|
|
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 =
|
|
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(
|
|
6859
|
+
const m2 = /^gitdir:\s*(.+?)\s*$/m.exec(readFileSync12(dotGitFile, "utf8"));
|
|
6780
6860
|
if (!m2) return null;
|
|
6781
|
-
const gitdir =
|
|
6861
|
+
const gitdir = path16.resolve(dir, m2[1] ?? "");
|
|
6782
6862
|
let common;
|
|
6783
6863
|
try {
|
|
6784
|
-
const rel =
|
|
6864
|
+
const rel = readFileSync12(path16.join(gitdir, "commondir"), "utf8").trim();
|
|
6785
6865
|
if (!rel) return normalizeRepoPath(dir);
|
|
6786
|
-
common =
|
|
6866
|
+
common = path16.resolve(gitdir, rel);
|
|
6787
6867
|
} catch {
|
|
6788
6868
|
return normalizeRepoPath(dir);
|
|
6789
6869
|
}
|
|
6790
|
-
return normalizeRepoPath(
|
|
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 =
|
|
6899
|
+
const sessionId = str3(e2.sessionId);
|
|
6818
6900
|
if (!sessionId) continue;
|
|
6819
|
-
const kind =
|
|
6820
|
-
const status5 =
|
|
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 =
|
|
6910
|
+
const cwd = str3(e2.cwd);
|
|
6829
6911
|
const isWaiting = status5 === "waiting";
|
|
6830
|
-
const waitingFor = isWaiting ?
|
|
6831
|
-
const key = `${pid ??
|
|
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:
|
|
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))).
|
|
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,
|
|
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
|
-
|
|
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
|
|
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 =
|
|
7024
|
+
const shipped = path17.join(bundle, "scripts", name);
|
|
6936
7025
|
if (existsSync8(shipped)) return shipped;
|
|
6937
7026
|
}
|
|
6938
|
-
const root =
|
|
6939
|
-
const repoScript =
|
|
6940
|
-
const mirrorScript =
|
|
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() {
|
|
@@ -6987,6 +7076,7 @@ function createCollectorSource(opts) {
|
|
|
6987
7076
|
for (const key of [...cache2.keys()]) if (!keep.has(key)) cache2.delete(key);
|
|
6988
7077
|
for (const entry of out.repos) {
|
|
6989
7078
|
if (!entry || typeof entry.path !== "string" || !keep.has(entry.path)) continue;
|
|
7079
|
+
if (entry.unchanged === true) continue;
|
|
6990
7080
|
const old = cache2.get(entry.path);
|
|
6991
7081
|
if (entry.error !== void 0 || entry.fingerprint === void 0) {
|
|
6992
7082
|
if (!old || old.error !== void 0) cache2.set(entry.path, entry);
|
|
@@ -7017,7 +7107,8 @@ function createCollectorSource(opts) {
|
|
|
7017
7107
|
pre = found.pre;
|
|
7018
7108
|
}
|
|
7019
7109
|
const script = opts.scriptPath ?? defaultScriptPath();
|
|
7020
|
-
const
|
|
7110
|
+
const known = [...cache2.values()].filter((r2) => r2.error === void 0 && typeof r2.fingerprint === "string" && repos.includes(r2.path)).map((r2) => `${r2.path}=${r2.fingerprint}`);
|
|
7111
|
+
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"];
|
|
7021
7112
|
const result = await spawn2(cmd, args, { timeoutMs: RUN_TIMEOUT_MS2 });
|
|
7022
7113
|
if (result.timedOut) return fail2(`collector timed out after ${RUN_TIMEOUT_MS2 / 1e3} s`);
|
|
7023
7114
|
if (!result.ok) {
|
|
@@ -7071,8 +7162,8 @@ var init_collector = __esm({
|
|
|
7071
7162
|
});
|
|
7072
7163
|
|
|
7073
7164
|
// src/hub/sources/github.ts
|
|
7074
|
-
import { readFileSync as
|
|
7075
|
-
import
|
|
7165
|
+
import { readFileSync as readFileSync13 } from "fs";
|
|
7166
|
+
import path18 from "path";
|
|
7076
7167
|
function parseGithubRemote(url) {
|
|
7077
7168
|
const m2 = /^(?:https?:\/\/(?:[^@/]+@)?|ssh:\/\/git@|git@)github\.com[/:]([^/\s]+)\/([^/\s]+?)(?:\.git)?\/?$/i.exec(url.trim());
|
|
7078
7169
|
return m2 ? `${m2[1]}/${m2[2]}` : null;
|
|
@@ -7082,7 +7173,7 @@ function readOriginUrl(repoDir) {
|
|
|
7082
7173
|
if (!root) return null;
|
|
7083
7174
|
let text2;
|
|
7084
7175
|
try {
|
|
7085
|
-
text2 =
|
|
7176
|
+
text2 = readFileSync13(path18.join(root, ".git", "config"), "utf8");
|
|
7086
7177
|
} catch {
|
|
7087
7178
|
return null;
|
|
7088
7179
|
}
|
|
@@ -7100,7 +7191,7 @@ function readOriginUrl(repoDir) {
|
|
|
7100
7191
|
}
|
|
7101
7192
|
function readRequiredChecks(repoDir) {
|
|
7102
7193
|
try {
|
|
7103
|
-
const text2 =
|
|
7194
|
+
const text2 = readFileSync13(path18.join(repoDir, ".caddis", "coordinator.md"), "utf8");
|
|
7104
7195
|
const m2 = /```json[^\S\r\n]*\r?\n([\s\S]*?)\r?\n[^\S\r\n]*```/.exec(text2);
|
|
7105
7196
|
if (!m2) return null;
|
|
7106
7197
|
const parsed = JSON.parse(m2[1] ?? "");
|
|
@@ -7238,17 +7329,17 @@ ${url}`;
|
|
|
7238
7329
|
const pulls = list(first);
|
|
7239
7330
|
const prs = [];
|
|
7240
7331
|
for (const p2 of pulls) {
|
|
7241
|
-
const head =
|
|
7332
|
+
const head = str4(rec2(p2.head).sha) ?? "";
|
|
7242
7333
|
const byName = /* @__PURE__ */ new Map();
|
|
7243
7334
|
if (head) {
|
|
7244
7335
|
const body = rec2(await getJson(account, token, `/repos/${repo}/commits/${head}/check-runs?per_page=100`));
|
|
7245
7336
|
for (const c of list(body.check_runs)) {
|
|
7246
|
-
const name =
|
|
7337
|
+
const name = str4(c.name);
|
|
7247
7338
|
if (!name) continue;
|
|
7248
7339
|
byName.set(name, {
|
|
7249
7340
|
name,
|
|
7250
|
-
status:
|
|
7251
|
-
conclusion:
|
|
7341
|
+
status: str4(c.status) ?? "unknown",
|
|
7342
|
+
conclusion: str4(c.conclusion),
|
|
7252
7343
|
required: required === null ? null : required.includes(name)
|
|
7253
7344
|
});
|
|
7254
7345
|
}
|
|
@@ -7256,12 +7347,12 @@ ${url}`;
|
|
|
7256
7347
|
const checks = [...byName.values()];
|
|
7257
7348
|
prs.push({
|
|
7258
7349
|
number: Number(p2.number),
|
|
7259
|
-
title:
|
|
7350
|
+
title: str4(p2.title) ?? "",
|
|
7260
7351
|
head_sha: head,
|
|
7261
|
-
author:
|
|
7352
|
+
author: str4(rec2(p2.user).login),
|
|
7262
7353
|
draft: p2.draft === true,
|
|
7263
|
-
updated_at:
|
|
7264
|
-
url:
|
|
7354
|
+
updated_at: str4(p2.updated_at),
|
|
7355
|
+
url: str4(p2.html_url) ?? "",
|
|
7265
7356
|
checks,
|
|
7266
7357
|
required_state: requiredState(checks, required)
|
|
7267
7358
|
});
|
|
@@ -7269,21 +7360,21 @@ ${url}`;
|
|
|
7269
7360
|
const closed = list(
|
|
7270
7361
|
await getJson(account, token, `/repos/${repo}/pulls?state=closed&sort=updated&direction=desc&per_page=20`)
|
|
7271
7362
|
);
|
|
7272
|
-
const merged = closed.filter((p2) =>
|
|
7363
|
+
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
7364
|
const merges = [];
|
|
7274
7365
|
for (const p2 of merged) {
|
|
7275
|
-
const sha =
|
|
7366
|
+
const sha = str4(p2.merge_commit_sha) ?? "";
|
|
7276
7367
|
const body = rec2(await getJson(account, token, `/repos/${repo}/actions/runs?head_sha=${sha}&per_page=10`));
|
|
7277
7368
|
merges.push({
|
|
7278
7369
|
number: Number(p2.number),
|
|
7279
|
-
title:
|
|
7370
|
+
title: str4(p2.title) ?? "",
|
|
7280
7371
|
merge_sha: sha,
|
|
7281
|
-
merged_at:
|
|
7372
|
+
merged_at: str4(p2.merged_at) ?? "",
|
|
7282
7373
|
runs: list(body.workflow_runs).map((r2) => ({
|
|
7283
|
-
name:
|
|
7284
|
-
status:
|
|
7285
|
-
conclusion:
|
|
7286
|
-
url:
|
|
7374
|
+
name: str4(r2.name) ?? "",
|
|
7375
|
+
status: str4(r2.status) ?? "unknown",
|
|
7376
|
+
conclusion: str4(r2.conclusion),
|
|
7377
|
+
url: str4(r2.html_url) ?? ""
|
|
7287
7378
|
}))
|
|
7288
7379
|
});
|
|
7289
7380
|
}
|
|
@@ -7406,7 +7497,7 @@ ${url}`;
|
|
|
7406
7497
|
}
|
|
7407
7498
|
};
|
|
7408
7499
|
}
|
|
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,
|
|
7500
|
+
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
7501
|
var init_github = __esm({
|
|
7411
7502
|
"src/hub/sources/github.ts"() {
|
|
7412
7503
|
"use strict";
|
|
@@ -7437,7 +7528,7 @@ var init_github = __esm({
|
|
|
7437
7528
|
/** This token cannot see the repo: try the next account. */
|
|
7438
7529
|
access;
|
|
7439
7530
|
};
|
|
7440
|
-
|
|
7531
|
+
str4 = (v2) => typeof v2 === "string" && v2 ? v2 : null;
|
|
7441
7532
|
rec2 = (v2) => v2 && typeof v2 === "object" ? v2 : {};
|
|
7442
7533
|
list = (v2) => Array.isArray(v2) ? v2.map(rec2) : [];
|
|
7443
7534
|
findGh = () => withTimeout(findBin("gh"), FIND_TIMEOUT_MS3, "finding gh");
|
|
@@ -7446,20 +7537,20 @@ var init_github = __esm({
|
|
|
7446
7537
|
|
|
7447
7538
|
// src/hub/state.ts
|
|
7448
7539
|
import { createHash } from "crypto";
|
|
7449
|
-
import { readFileSync as
|
|
7450
|
-
import
|
|
7540
|
+
import { readFileSync as readFileSync14 } from "fs";
|
|
7541
|
+
import path19 from "path";
|
|
7451
7542
|
function repoIdFor(nameWithOwner) {
|
|
7452
7543
|
return nameWithOwner.trim().toLowerCase().replace(/\//g, "__");
|
|
7453
7544
|
}
|
|
7454
7545
|
function localRepoId(repoPath) {
|
|
7455
7546
|
const norm = process.platform === "win32" ? repoPath.toLowerCase().replace(/\//g, "\\") : repoPath;
|
|
7456
7547
|
const digest = createHash("sha256").update(norm, "utf8").digest("hex").slice(0, 6);
|
|
7457
|
-
return `local__${
|
|
7548
|
+
return `local__${path19.basename(repoPath)}__${digest}`;
|
|
7458
7549
|
}
|
|
7459
7550
|
function readPluginVersion(home) {
|
|
7460
7551
|
try {
|
|
7461
|
-
const file =
|
|
7462
|
-
const parsed = JSON.parse(
|
|
7552
|
+
const file = path19.join(home, ".claude", "plugins", "installed_plugins.json");
|
|
7553
|
+
const parsed = JSON.parse(readFileSync14(file, "utf8"));
|
|
7463
7554
|
for (const [key, entries] of Object.entries(parsed.plugins ?? {})) {
|
|
7464
7555
|
if (!key.startsWith("caddis@") || !Array.isArray(entries)) continue;
|
|
7465
7556
|
for (const e2 of entries) {
|
|
@@ -7561,7 +7652,7 @@ function createHub(opts = {}) {
|
|
|
7561
7652
|
return out;
|
|
7562
7653
|
};
|
|
7563
7654
|
const collector = opts.collector ?? createCollectorSource({ repos: repoPaths, now });
|
|
7564
|
-
const agents = opts.agents ?? createAgentsSource({ now });
|
|
7655
|
+
const agents = opts.agents ?? createAgentsSource({ now, home });
|
|
7565
7656
|
const github = opts.github ?? createGithubSource({ repos: repoPaths, accounts: () => readConfig(home).value.accounts, now });
|
|
7566
7657
|
const coordinator = opts.coordinator ?? createCoordinatorSource({ home, now });
|
|
7567
7658
|
let versionsCache = null;
|
|
@@ -7653,7 +7744,7 @@ function createHub(opts = {}) {
|
|
|
7653
7744
|
const relays = c?.relays ?? null;
|
|
7654
7745
|
const out = {
|
|
7655
7746
|
path: p2,
|
|
7656
|
-
name:
|
|
7747
|
+
name: path19.basename(p2),
|
|
7657
7748
|
pinned: pinned.has(k3),
|
|
7658
7749
|
roadmaps: c?.roadmaps ?? null,
|
|
7659
7750
|
plans: c?.plans ?? null,
|
|
@@ -7764,7 +7855,7 @@ var init_state = __esm({
|
|
|
7764
7855
|
|
|
7765
7856
|
// src/hub/actions.ts
|
|
7766
7857
|
import { randomUUID } from "crypto";
|
|
7767
|
-
import
|
|
7858
|
+
import path20 from "path";
|
|
7768
7859
|
function parseBody(raw) {
|
|
7769
7860
|
if (!raw || typeof raw !== "object" || Array.isArray(raw)) throw new Refusal(400, "bad_request", "The body must be a JSON object.");
|
|
7770
7861
|
const o2 = raw;
|
|
@@ -7872,7 +7963,7 @@ function createActions(opts) {
|
|
|
7872
7963
|
args: body.what === null ? {} : { what: body.what }
|
|
7873
7964
|
};
|
|
7874
7965
|
try {
|
|
7875
|
-
await appendLine(
|
|
7966
|
+
await appendLine(path20.join(root(), "repos", body.repo_id, "requests.jsonl"), JSON.stringify(request));
|
|
7876
7967
|
} catch {
|
|
7877
7968
|
return refuse(new Refusal(500, "write_failed", "The hub could not write the request."), body);
|
|
7878
7969
|
}
|
|
@@ -7920,6 +8011,8 @@ var init_actions = __esm({
|
|
|
7920
8011
|
|
|
7921
8012
|
// src/hub/auth.ts
|
|
7922
8013
|
import { createHash as createHash2, randomBytes as randomBytes3, timingSafeEqual } from "crypto";
|
|
8014
|
+
import { mkdirSync as mkdirSync7, readFileSync as readFileSync15, renameSync as renameSync3, writeFileSync as writeFileSync5 } from "fs";
|
|
8015
|
+
import path21 from "path";
|
|
7923
8016
|
function randomToken() {
|
|
7924
8017
|
return randomBytes3(32).toString("base64url");
|
|
7925
8018
|
}
|
|
@@ -7948,22 +8041,84 @@ function parseCookies(header) {
|
|
|
7948
8041
|
}
|
|
7949
8042
|
return out;
|
|
7950
8043
|
}
|
|
7951
|
-
var CODE_TTL_MS, MAX_CODES, MAX_SESSIONS, SESSION_IDLE_MS, SESSION_MAX_MS, AuthStore;
|
|
8044
|
+
var CODE_TTL_MS, MAX_CODES, MAX_SESSIONS, SESSION_IDLE_MS, SESSION_MAX_MS, SEEN_WRITE_MS, hashToken, AuthStore;
|
|
7952
8045
|
var init_auth = __esm({
|
|
7953
8046
|
"src/hub/auth.ts"() {
|
|
7954
8047
|
"use strict";
|
|
7955
8048
|
CODE_TTL_MS = 6e4;
|
|
7956
8049
|
MAX_CODES = 20;
|
|
7957
8050
|
MAX_SESSIONS = 20;
|
|
7958
|
-
SESSION_IDLE_MS =
|
|
7959
|
-
SESSION_MAX_MS = 24 * 60 * 60 * 1e3;
|
|
8051
|
+
SESSION_IDLE_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
8052
|
+
SESSION_MAX_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
8053
|
+
SEEN_WRITE_MS = 5 * 60 * 1e3;
|
|
8054
|
+
hashToken = (v2) => createHash2("sha256").update(v2, "utf8").digest("hex");
|
|
7960
8055
|
AuthStore = class {
|
|
7961
|
-
constructor(now = Date.now) {
|
|
8056
|
+
constructor(now = Date.now, file) {
|
|
7962
8057
|
this.now = now;
|
|
8058
|
+
this.file = file;
|
|
8059
|
+
this.sessions = this.load();
|
|
7963
8060
|
}
|
|
7964
8061
|
now;
|
|
8062
|
+
file;
|
|
7965
8063
|
codes = [];
|
|
7966
8064
|
sessions = [];
|
|
8065
|
+
load() {
|
|
8066
|
+
if (!this.file) return [];
|
|
8067
|
+
let raw;
|
|
8068
|
+
try {
|
|
8069
|
+
raw = JSON.parse(readFileSync15(this.file, "utf8"));
|
|
8070
|
+
} catch {
|
|
8071
|
+
return [];
|
|
8072
|
+
}
|
|
8073
|
+
const list2 = raw?.sessions;
|
|
8074
|
+
if (!Array.isArray(list2)) return [];
|
|
8075
|
+
const t = this.now();
|
|
8076
|
+
const out = [];
|
|
8077
|
+
for (const e2 of list2) {
|
|
8078
|
+
if (!e2 || typeof e2 !== "object") continue;
|
|
8079
|
+
const r2 = e2;
|
|
8080
|
+
const ok = (v2) => typeof v2 === "string" && v2.length > 0;
|
|
8081
|
+
const num = (v2) => typeof v2 === "number" && Number.isFinite(v2);
|
|
8082
|
+
if (!ok(r2.id_hash) || !ok(r2.tab_hash) || !ok(r2.csrf) || !num(r2.created_at) || !num(r2.last_seen_at)) continue;
|
|
8083
|
+
const s = {
|
|
8084
|
+
id: "",
|
|
8085
|
+
idHash: r2.id_hash,
|
|
8086
|
+
csrf: r2.csrf,
|
|
8087
|
+
tab: "",
|
|
8088
|
+
tabHash: r2.tab_hash,
|
|
8089
|
+
createdAt: r2.created_at,
|
|
8090
|
+
lastSeenAt: r2.last_seen_at,
|
|
8091
|
+
savedSeenAt: r2.last_seen_at
|
|
8092
|
+
};
|
|
8093
|
+
if (!this.expired(s, t)) out.push(s);
|
|
8094
|
+
}
|
|
8095
|
+
return out.slice(-MAX_SESSIONS);
|
|
8096
|
+
}
|
|
8097
|
+
/** Write the sessions. A write that fails is ignored: the hub keeps working, the login is lost on restart. */
|
|
8098
|
+
save() {
|
|
8099
|
+
if (!this.file) return;
|
|
8100
|
+
const body = {
|
|
8101
|
+
schema: 1,
|
|
8102
|
+
sessions: this.sessions.map((s) => ({
|
|
8103
|
+
id_hash: s.idHash,
|
|
8104
|
+
tab_hash: s.tabHash,
|
|
8105
|
+
csrf: s.csrf,
|
|
8106
|
+
created_at: s.createdAt,
|
|
8107
|
+
last_seen_at: s.lastSeenAt
|
|
8108
|
+
}))
|
|
8109
|
+
};
|
|
8110
|
+
const tmp = `${this.file}.${process.pid}.tmp`;
|
|
8111
|
+
try {
|
|
8112
|
+
mkdirSync7(path21.dirname(this.file), { recursive: true });
|
|
8113
|
+
writeFileSync5(tmp, JSON.stringify(body), { mode: 384 });
|
|
8114
|
+
renameSync3(tmp, this.file);
|
|
8115
|
+
for (const s of this.sessions) s.savedSeenAt = s.lastSeenAt;
|
|
8116
|
+
} catch {
|
|
8117
|
+
}
|
|
8118
|
+
}
|
|
8119
|
+
expired(s, t) {
|
|
8120
|
+
return t - s.lastSeenAt >= SESSION_IDLE_MS || t - s.createdAt >= SESSION_MAX_MS;
|
|
8121
|
+
}
|
|
7967
8122
|
/** Mint a single-use code. Expired codes are dropped first; then the oldest goes past the cap. */
|
|
7968
8123
|
mintCode() {
|
|
7969
8124
|
const t = this.now();
|
|
@@ -7990,9 +8145,21 @@ var init_auth = __esm({
|
|
|
7990
8145
|
const age = this.now() - found.mintedAt;
|
|
7991
8146
|
if (age < 0 || age >= CODE_TTL_MS) return null;
|
|
7992
8147
|
const t = this.now();
|
|
7993
|
-
const
|
|
8148
|
+
const id = randomToken();
|
|
8149
|
+
const tab = randomToken();
|
|
8150
|
+
const s = {
|
|
8151
|
+
id,
|
|
8152
|
+
idHash: hashToken(id),
|
|
8153
|
+
csrf: randomToken(),
|
|
8154
|
+
tab,
|
|
8155
|
+
tabHash: hashToken(tab),
|
|
8156
|
+
createdAt: t,
|
|
8157
|
+
lastSeenAt: t,
|
|
8158
|
+
savedSeenAt: t
|
|
8159
|
+
};
|
|
7994
8160
|
this.sessions.push(s);
|
|
7995
8161
|
while (this.sessions.length > MAX_SESSIONS) this.sessions.shift();
|
|
8162
|
+
this.save();
|
|
7996
8163
|
return s.id;
|
|
7997
8164
|
}
|
|
7998
8165
|
/** Remove a code without making a session (a refused /login still uses up its code). */
|
|
@@ -8016,21 +8183,26 @@ var init_auth = __esm({
|
|
|
8016
8183
|
}
|
|
8017
8184
|
findSession(id, tab) {
|
|
8018
8185
|
if (!id) return null;
|
|
8186
|
+
const idHash = hashToken(id);
|
|
8019
8187
|
let found = null;
|
|
8020
|
-
for (const s of this.sessions) if (safeEqual(s.
|
|
8188
|
+
for (const s of this.sessions) if (safeEqual(s.idHash, idHash)) found = s;
|
|
8021
8189
|
if (!found) return null;
|
|
8022
|
-
if (tab !== null && !safeEqual(found.
|
|
8190
|
+
if (tab !== null && !safeEqual(found.tabHash, hashToken(tab))) return null;
|
|
8023
8191
|
const t = this.now();
|
|
8024
|
-
if (
|
|
8192
|
+
if (this.expired(found, t)) {
|
|
8025
8193
|
this.sessions = this.sessions.filter((x2) => x2 !== found);
|
|
8194
|
+
this.save();
|
|
8026
8195
|
return null;
|
|
8027
8196
|
}
|
|
8028
8197
|
found.lastSeenAt = t;
|
|
8198
|
+
if (t - found.savedSeenAt >= SEEN_WRITE_MS) this.save();
|
|
8029
8199
|
return found;
|
|
8030
8200
|
}
|
|
8031
8201
|
deleteSession(id) {
|
|
8032
8202
|
const s = this.getSession(id);
|
|
8033
|
-
if (s)
|
|
8203
|
+
if (!s) return;
|
|
8204
|
+
this.sessions = this.sessions.filter((x2) => x2 !== s);
|
|
8205
|
+
this.save();
|
|
8034
8206
|
}
|
|
8035
8207
|
codeCount() {
|
|
8036
8208
|
return this.codes.length;
|
|
@@ -8042,16 +8214,68 @@ var init_auth = __esm({
|
|
|
8042
8214
|
}
|
|
8043
8215
|
});
|
|
8044
8216
|
|
|
8217
|
+
// src/hub/phaseText.ts
|
|
8218
|
+
function isRecord(v2) {
|
|
8219
|
+
return typeof v2 === "object" && v2 !== null && !Array.isArray(v2);
|
|
8220
|
+
}
|
|
8221
|
+
function stripPlan(plan2) {
|
|
8222
|
+
if (!isRecord(plan2) || !isRecord(plan2.phases)) return plan2;
|
|
8223
|
+
const phases = {};
|
|
8224
|
+
for (const [k3, v2] of Object.entries(plan2.phases)) {
|
|
8225
|
+
const rawTitle = isRecord(v2) ? v2.title : void 0;
|
|
8226
|
+
phases[k3] = { title: typeof rawTitle === "string" ? rawTitle : "" };
|
|
8227
|
+
}
|
|
8228
|
+
return { ...plan2, phases };
|
|
8229
|
+
}
|
|
8230
|
+
function stripRepo(repo) {
|
|
8231
|
+
if (!isRecord(repo) || !isRecord(repo.plans) || !Array.isArray(repo.plans.plans)) return repo;
|
|
8232
|
+
return {
|
|
8233
|
+
...repo,
|
|
8234
|
+
plans: {
|
|
8235
|
+
...repo.plans,
|
|
8236
|
+
plans: repo.plans.plans.map(stripPlan)
|
|
8237
|
+
}
|
|
8238
|
+
};
|
|
8239
|
+
}
|
|
8240
|
+
function stripPhaseText(state) {
|
|
8241
|
+
if (!isRecord(state) || !Array.isArray(state.repos)) return state;
|
|
8242
|
+
return {
|
|
8243
|
+
...state,
|
|
8244
|
+
repos: state.repos.map(stripRepo)
|
|
8245
|
+
};
|
|
8246
|
+
}
|
|
8247
|
+
function findPhaseSection(state, repoPath, planPath, key) {
|
|
8248
|
+
if (!isRecord(state) || !Array.isArray(state.repos)) return null;
|
|
8249
|
+
const repo = state.repos.find((r2) => isRecord(r2) && r2.path === repoPath);
|
|
8250
|
+
if (!repo || !isRecord(repo.plans) || !Array.isArray(repo.plans.plans)) return null;
|
|
8251
|
+
const plan2 = repo.plans.plans.find((p2) => isRecord(p2) && p2.path === planPath);
|
|
8252
|
+
if (!plan2 || !isRecord(plan2.phases)) return null;
|
|
8253
|
+
if (!Object.prototype.hasOwnProperty.call(plan2.phases, key)) return null;
|
|
8254
|
+
const sec = plan2.phases[key];
|
|
8255
|
+
if (!isRecord(sec)) return null;
|
|
8256
|
+
return {
|
|
8257
|
+
title: String(sec.title ?? ""),
|
|
8258
|
+
text: String(sec.text ?? "")
|
|
8259
|
+
};
|
|
8260
|
+
}
|
|
8261
|
+
var init_phaseText = __esm({
|
|
8262
|
+
"src/hub/phaseText.ts"() {
|
|
8263
|
+
"use strict";
|
|
8264
|
+
}
|
|
8265
|
+
});
|
|
8266
|
+
|
|
8045
8267
|
// src/hub/server.ts
|
|
8046
8268
|
import http from "http";
|
|
8047
8269
|
import { existsSync as existsSync9 } from "fs";
|
|
8048
8270
|
import { readFile, stat } from "fs/promises";
|
|
8049
|
-
import
|
|
8271
|
+
import path22 from "path";
|
|
8050
8272
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
8273
|
+
import { promisify } from "util";
|
|
8274
|
+
import { gzip } from "zlib";
|
|
8051
8275
|
function defaultUiDir() {
|
|
8052
|
-
const here =
|
|
8053
|
-
const beside =
|
|
8054
|
-
return existsSync9(beside) ? beside :
|
|
8276
|
+
const here = path22.dirname(fileURLToPath2(import.meta.url));
|
|
8277
|
+
const beside = path22.join(here, "ui");
|
|
8278
|
+
return existsSync9(beside) ? beside : path22.resolve(here, "..", "..", "dist", "ui");
|
|
8055
8279
|
}
|
|
8056
8280
|
function resolveStatic(root, urlPath) {
|
|
8057
8281
|
let decoded;
|
|
@@ -8062,9 +8286,9 @@ function resolveStatic(root, urlPath) {
|
|
|
8062
8286
|
}
|
|
8063
8287
|
if (decoded.includes(String.fromCharCode(0)) || decoded.includes(String.fromCharCode(92))) return null;
|
|
8064
8288
|
if (decoded.split("/").includes("..")) return null;
|
|
8065
|
-
const base =
|
|
8066
|
-
const file =
|
|
8067
|
-
return file.startsWith(base +
|
|
8289
|
+
const base = path22.resolve(root);
|
|
8290
|
+
const file = path22.resolve(base, "." + decoded);
|
|
8291
|
+
return file.startsWith(base + path22.sep) ? file : null;
|
|
8068
8292
|
}
|
|
8069
8293
|
function send(res, status5, body, extra = {}) {
|
|
8070
8294
|
const text2 = JSON.stringify(body);
|
|
@@ -8075,6 +8299,34 @@ function send(res, status5, body, extra = {}) {
|
|
|
8075
8299
|
});
|
|
8076
8300
|
res.end(text2);
|
|
8077
8301
|
}
|
|
8302
|
+
function acceptsGzip(header) {
|
|
8303
|
+
if (!header) return false;
|
|
8304
|
+
const raw = Array.isArray(header) ? header.join(",") : header;
|
|
8305
|
+
for (const token of raw.split(",")) {
|
|
8306
|
+
const parts = token.split(";").map((p2) => p2.trim());
|
|
8307
|
+
const name = (parts[0] ?? "").toLowerCase();
|
|
8308
|
+
if (name !== "gzip") continue;
|
|
8309
|
+
const qPart = parts.slice(1).find((p2) => p2.startsWith("q="));
|
|
8310
|
+
const q2 = qPart !== void 0 ? Number(qPart.slice(2)) : 1;
|
|
8311
|
+
if (q2 > 0) return true;
|
|
8312
|
+
}
|
|
8313
|
+
return false;
|
|
8314
|
+
}
|
|
8315
|
+
async function sendState(req, res, state) {
|
|
8316
|
+
const text2 = JSON.stringify(state);
|
|
8317
|
+
if (acceptsGzip(req.headers["accept-encoding"])) {
|
|
8318
|
+
const zipped = await gzipAsync(text2);
|
|
8319
|
+
res.writeHead(200, {
|
|
8320
|
+
"Content-Type": "application/json; charset=utf-8",
|
|
8321
|
+
"Content-Encoding": "gzip",
|
|
8322
|
+
"Content-Length": zipped.length,
|
|
8323
|
+
Vary: "Accept-Encoding"
|
|
8324
|
+
});
|
|
8325
|
+
res.end(zipped);
|
|
8326
|
+
return;
|
|
8327
|
+
}
|
|
8328
|
+
return send(res, 200, state, { Vary: "Accept-Encoding" });
|
|
8329
|
+
}
|
|
8078
8330
|
function readBody(req, limit = MAX_BODY_BYTES) {
|
|
8079
8331
|
return new Promise((resolve, reject) => {
|
|
8080
8332
|
const declared = Number(req.headers["content-length"] ?? 0);
|
|
@@ -8128,7 +8380,7 @@ async function serveStatic(res, uiDir, urlPath) {
|
|
|
8128
8380
|
return fail(res, 404, "not_found");
|
|
8129
8381
|
}
|
|
8130
8382
|
res.writeHead(200, {
|
|
8131
|
-
"Content-Type": MIME[
|
|
8383
|
+
"Content-Type": MIME[path22.extname(file).toLowerCase()] ?? "application/octet-stream",
|
|
8132
8384
|
"Content-Length": body.length,
|
|
8133
8385
|
"Cache-Control": urlPath === "/" ? "no-store" : "public, max-age=31536000, immutable"
|
|
8134
8386
|
});
|
|
@@ -8144,7 +8396,7 @@ async function startServer(opts) {
|
|
|
8144
8396
|
if (typeof opts.key !== "string" || Buffer.byteLength(opts.key, "utf8") < MIN_KEY_BYTES) {
|
|
8145
8397
|
throw new Error(`the hub server key must be at least ${MIN_KEY_BYTES} bytes`);
|
|
8146
8398
|
}
|
|
8147
|
-
const auth = new AuthStore(opts.now ?? Date.now);
|
|
8399
|
+
const auth = new AuthStore(opts.now ?? Date.now, opts.sessionsFile);
|
|
8148
8400
|
const { key, versions } = opts;
|
|
8149
8401
|
const uiDir = opts.uiDir ?? defaultUiDir();
|
|
8150
8402
|
let port = opts.port;
|
|
@@ -8164,23 +8416,23 @@ async function startServer(opts) {
|
|
|
8164
8416
|
fail(res, 400, "bad_url");
|
|
8165
8417
|
return;
|
|
8166
8418
|
}
|
|
8167
|
-
const
|
|
8419
|
+
const path26 = url.pathname;
|
|
8168
8420
|
const method = req.method ?? "GET";
|
|
8169
|
-
if (
|
|
8421
|
+
if (path26.startsWith("/api/") || path26 === "/login") res.setHeader("Cache-Control", "no-store");
|
|
8170
8422
|
if (!hostAllowed(req.headers.host, port)) {
|
|
8171
|
-
if (
|
|
8423
|
+
if (path26 === "/login") auth.discardCode(url.searchParams.get("code") ?? "");
|
|
8172
8424
|
fail(res, 403, "bad_host");
|
|
8173
8425
|
return;
|
|
8174
8426
|
}
|
|
8175
|
-
if (
|
|
8427
|
+
if (path26 === "/api/hub/whoami" && method === "GET") {
|
|
8176
8428
|
if (!opts.instance) return fail(res, 404, "not_found");
|
|
8177
8429
|
return send(res, 200, { instance: opts.instance });
|
|
8178
8430
|
}
|
|
8179
|
-
if (
|
|
8431
|
+
if (path26 === "/api/health" && method === "GET") {
|
|
8180
8432
|
if (!keyOk(req, key)) return fail(res, 401, "unauthorized");
|
|
8181
8433
|
return send(res, 200, { schema: 1, ok: true, versions });
|
|
8182
8434
|
}
|
|
8183
|
-
if (
|
|
8435
|
+
if (path26 === "/api/hub/code" && method === "POST") {
|
|
8184
8436
|
if (!keyOk(req, key)) return fail(res, 401, "unauthorized");
|
|
8185
8437
|
try {
|
|
8186
8438
|
await readBody(req);
|
|
@@ -8191,7 +8443,7 @@ async function startServer(opts) {
|
|
|
8191
8443
|
const code = auth.mintCode();
|
|
8192
8444
|
return send(res, 200, { schema: 1, code, expires_at: auth.codeExpiresAt() });
|
|
8193
8445
|
}
|
|
8194
|
-
if (
|
|
8446
|
+
if (path26 === "/api/hub/stop" && method === "POST") {
|
|
8195
8447
|
if (!keyOk(req, key)) return fail(res, 401, "unauthorized");
|
|
8196
8448
|
try {
|
|
8197
8449
|
await readBody(req);
|
|
@@ -8209,7 +8461,7 @@ async function startServer(opts) {
|
|
|
8209
8461
|
if (!session) return fail(res, 401, "unauthorized");
|
|
8210
8462
|
const token = req.headers[CSRF_HEADER];
|
|
8211
8463
|
if (typeof token !== "string" || !safeEqual(token, session.csrf)) return fail(res, 403, "bad_csrf");
|
|
8212
|
-
if (
|
|
8464
|
+
if (path26 === "/api/actions" && method === "POST" && opts.actions) {
|
|
8213
8465
|
if (!tabSessionOf(req)) return fail(res, 401, "unauthorized");
|
|
8214
8466
|
const type = String(req.headers["content-type"] ?? "").split(";")[0]?.trim().toLowerCase();
|
|
8215
8467
|
if (type !== "application/json") return fail(res, 415, "json_only");
|
|
@@ -8235,36 +8487,36 @@ async function startServer(opts) {
|
|
|
8235
8487
|
if (e2 instanceof BodyTooLarge) return tooLarge(req, res);
|
|
8236
8488
|
throw e2;
|
|
8237
8489
|
}
|
|
8238
|
-
if (
|
|
8239
|
-
auth.deleteSession(
|
|
8490
|
+
if (path26 === "/api/logout" && method === "POST") {
|
|
8491
|
+
auth.deleteSession(parseCookies(req.headers.cookie)[SESSION_COOKIE] ?? "");
|
|
8240
8492
|
return send(res, 200, { schema: 1, ok: true }, {
|
|
8241
8493
|
"Set-Cookie": `${SESSION_COOKIE}=; HttpOnly; SameSite=Strict; Path=/; Max-Age=0`
|
|
8242
8494
|
});
|
|
8243
8495
|
}
|
|
8244
8496
|
return fail(res, 404, "not_found");
|
|
8245
8497
|
}
|
|
8246
|
-
if (
|
|
8247
|
-
await serveStatic(res, uiDir,
|
|
8498
|
+
if (path26 === "/" || path26.startsWith("/assets/") || path26.startsWith("/fonts/")) {
|
|
8499
|
+
await serveStatic(res, uiDir, path26);
|
|
8248
8500
|
return;
|
|
8249
8501
|
}
|
|
8250
|
-
if (
|
|
8502
|
+
if (path26 === "/login") {
|
|
8251
8503
|
const id = auth.redeemCode(url.searchParams.get("code") ?? "");
|
|
8252
8504
|
const session = id ? auth.getSession(id) : null;
|
|
8253
8505
|
if (!id || !session) return fail(res, 401, "bad_code");
|
|
8254
8506
|
res.writeHead(303, {
|
|
8255
8507
|
Location: `/#tab=${session.tab}`,
|
|
8256
|
-
"Set-Cookie": `${SESSION_COOKIE}=${id}; HttpOnly; SameSite=Strict; Path
|
|
8508
|
+
"Set-Cookie": `${SESSION_COOKIE}=${id}; HttpOnly; SameSite=Strict; Path=/; Max-Age=${Math.floor(SESSION_MAX_MS / 1e3)}`,
|
|
8257
8509
|
"Content-Length": 0
|
|
8258
8510
|
});
|
|
8259
8511
|
res.end();
|
|
8260
8512
|
return;
|
|
8261
8513
|
}
|
|
8262
|
-
if (
|
|
8514
|
+
if (path26 === "/api/session") {
|
|
8263
8515
|
const session = tabSessionOf(req);
|
|
8264
8516
|
if (!session) return fail(res, 401, "unauthorized");
|
|
8265
8517
|
return send(res, 200, { schema: 1, csrf_token: session.csrf, versions });
|
|
8266
8518
|
}
|
|
8267
|
-
if (
|
|
8519
|
+
if (path26 === "/api/state") {
|
|
8268
8520
|
if (!tabSessionOf(req)) return fail(res, 401, "unauthorized");
|
|
8269
8521
|
let state;
|
|
8270
8522
|
try {
|
|
@@ -8272,7 +8524,22 @@ async function startServer(opts) {
|
|
|
8272
8524
|
} catch {
|
|
8273
8525
|
return fail(res, 500, "state_failed");
|
|
8274
8526
|
}
|
|
8275
|
-
return
|
|
8527
|
+
return sendState(req, res, stripPhaseText(state));
|
|
8528
|
+
}
|
|
8529
|
+
if (path26 === "/api/plan-phase") {
|
|
8530
|
+
if (!tabSessionOf(req)) return fail(res, 401, "unauthorized");
|
|
8531
|
+
const repo = url.searchParams.get("repo") ?? "";
|
|
8532
|
+
const plan2 = url.searchParams.get("plan") ?? "";
|
|
8533
|
+
const phaseKey = url.searchParams.get("key") ?? "";
|
|
8534
|
+
if (!repo || !plan2 || !phaseKey) return fail(res, 400, "bad_request");
|
|
8535
|
+
let state;
|
|
8536
|
+
try {
|
|
8537
|
+
state = await opts.getState();
|
|
8538
|
+
} catch {
|
|
8539
|
+
return fail(res, 500, "state_failed");
|
|
8540
|
+
}
|
|
8541
|
+
const sec = findPhaseSection(state, repo, plan2, phaseKey);
|
|
8542
|
+
return sec ? send(res, 200, { schema: 1, ...sec }) : fail(res, 404, "not_found");
|
|
8276
8543
|
}
|
|
8277
8544
|
return fail(res, 404, "not_found");
|
|
8278
8545
|
}
|
|
@@ -8303,12 +8570,13 @@ async function startServer(opts) {
|
|
|
8303
8570
|
})
|
|
8304
8571
|
};
|
|
8305
8572
|
}
|
|
8306
|
-
var SESSION_COOKIE, KEY_HEADER, CSRF_HEADER, TAB_HEADER, MAX_BODY_BYTES, MIN_KEY_BYTES, CSP, NOT_BUILT_HTML, MIME, BodyTooLarge, fail;
|
|
8573
|
+
var SESSION_COOKIE, KEY_HEADER, CSRF_HEADER, TAB_HEADER, MAX_BODY_BYTES, MIN_KEY_BYTES, CSP, NOT_BUILT_HTML, MIME, gzipAsync, BodyTooLarge, fail;
|
|
8307
8574
|
var init_server = __esm({
|
|
8308
8575
|
"src/hub/server.ts"() {
|
|
8309
8576
|
"use strict";
|
|
8310
8577
|
init_actions();
|
|
8311
8578
|
init_auth();
|
|
8579
|
+
init_phaseText();
|
|
8312
8580
|
SESSION_COOKIE = "caddis_hub_session";
|
|
8313
8581
|
KEY_HEADER = "x-caddis-hub-key";
|
|
8314
8582
|
CSRF_HEADER = "x-csrf-token";
|
|
@@ -8325,11 +8593,13 @@ var init_server = __esm({
|
|
|
8325
8593
|
".json": "application/json; charset=utf-8",
|
|
8326
8594
|
".svg": "image/svg+xml",
|
|
8327
8595
|
".png": "image/png",
|
|
8596
|
+
".webp": "image/webp",
|
|
8328
8597
|
".ico": "image/x-icon",
|
|
8329
8598
|
".woff2": "font/woff2",
|
|
8330
8599
|
".txt": "text/plain; charset=utf-8",
|
|
8331
8600
|
".map": "application/json; charset=utf-8"
|
|
8332
8601
|
};
|
|
8602
|
+
gzipAsync = promisify(gzip);
|
|
8333
8603
|
BodyTooLarge = class extends Error {
|
|
8334
8604
|
};
|
|
8335
8605
|
fail = (res, status5, error) => send(res, status5, { schema: 1, error });
|
|
@@ -8353,8 +8623,8 @@ __export(hub_exports, {
|
|
|
8353
8623
|
startHub: () => startHub
|
|
8354
8624
|
});
|
|
8355
8625
|
import http2 from "http";
|
|
8356
|
-
import
|
|
8357
|
-
import { mkdirSync as
|
|
8626
|
+
import path23 from "path";
|
|
8627
|
+
import { mkdirSync as mkdirSync8, readFileSync as readFileSync16 } from "fs";
|
|
8358
8628
|
import { randomBytes as randomBytes4 } from "crypto";
|
|
8359
8629
|
function defaultVersions2() {
|
|
8360
8630
|
return { cli: packageInfo().version, caddis: bundleManifest().poolVersion };
|
|
@@ -8371,7 +8641,7 @@ function resolvePort(deps) {
|
|
|
8371
8641
|
}
|
|
8372
8642
|
function readKeyQuiet(home) {
|
|
8373
8643
|
try {
|
|
8374
|
-
const k3 =
|
|
8644
|
+
const k3 = readFileSync16(keyPath(home), "utf8").trim();
|
|
8375
8645
|
return /^[0-9a-f]{64}$/.test(k3) ? k3 : null;
|
|
8376
8646
|
} catch {
|
|
8377
8647
|
return null;
|
|
@@ -8439,7 +8709,7 @@ async function isNodeProcess(pid) {
|
|
|
8439
8709
|
if (!r2.ok) return false;
|
|
8440
8710
|
const name = (r2.stdout.split(/\r?\n/)[0] ?? "").replace(/^"([^"]*)".*$/, "$1").trim().toLowerCase();
|
|
8441
8711
|
if (!name) return false;
|
|
8442
|
-
const runtime =
|
|
8712
|
+
const runtime = path23.basename(process.execPath).toLowerCase().replace(/\.exe$/, "");
|
|
8443
8713
|
return name.includes("node") || name.includes(runtime);
|
|
8444
8714
|
}
|
|
8445
8715
|
async function defaultOpener(url) {
|
|
@@ -8528,7 +8798,8 @@ async function startHub(deps = {}) {
|
|
|
8528
8798
|
versions: deps.versions ?? defaultVersions2(),
|
|
8529
8799
|
now,
|
|
8530
8800
|
instance: info.instance,
|
|
8531
|
-
onStop: () => void stop()
|
|
8801
|
+
onStop: () => void stop(),
|
|
8802
|
+
sessionsFile: sessionsPath(home)
|
|
8532
8803
|
});
|
|
8533
8804
|
} catch (e2) {
|
|
8534
8805
|
releaseLock(process.pid, home);
|
|
@@ -8570,7 +8841,7 @@ async function hubServe(deps = {}) {
|
|
|
8570
8841
|
process.once("exit", onExit);
|
|
8571
8842
|
line(`caddis hub serving on ${hubUrl(hub2.port)} (pid ${process.pid}); stop it with: caddis hub stop`);
|
|
8572
8843
|
const pkgRoot = packageInfo().root;
|
|
8573
|
-
const newEntry =
|
|
8844
|
+
const newEntry = path23.join(pkgRoot, "dist", "cli.js");
|
|
8574
8845
|
const runningVersion = (deps.versions ?? defaultVersions2()).cli ?? packageInfo().version;
|
|
8575
8846
|
const restarter = createRestarter({
|
|
8576
8847
|
currentVersion: runningVersion,
|
|
@@ -8646,7 +8917,7 @@ async function hubStart(deps = {}) {
|
|
|
8646
8917
|
return 1;
|
|
8647
8918
|
}
|
|
8648
8919
|
const cwd = hubDir(home);
|
|
8649
|
-
|
|
8920
|
+
mkdirSync8(cwd, { recursive: true });
|
|
8650
8921
|
const child = await (deps.spawn ?? defaultSpawn)(process.execPath, [entry, "hub", "serve"], { cwd });
|
|
8651
8922
|
let exited = false;
|
|
8652
8923
|
let exitCode = null;
|
|
@@ -8859,30 +9130,30 @@ var init_hub = __esm({
|
|
|
8859
9130
|
// src/hub/export/data.ts
|
|
8860
9131
|
function blocker(raw) {
|
|
8861
9132
|
const b3 = rec3(raw);
|
|
8862
|
-
return { type:
|
|
9133
|
+
return { type: str5(b3.type), reason: str5(b3.reason), check: str5(b3.check) };
|
|
8863
9134
|
}
|
|
8864
9135
|
function phase(raw) {
|
|
8865
9136
|
const p2 = rec3(raw);
|
|
8866
9137
|
return {
|
|
8867
|
-
ref:
|
|
8868
|
-
state:
|
|
8869
|
-
plan:
|
|
9138
|
+
ref: str5(p2.ref),
|
|
9139
|
+
state: str5(p2.state),
|
|
9140
|
+
plan: str5(p2.plan),
|
|
8870
9141
|
num: int(p2.num),
|
|
8871
|
-
name:
|
|
8872
|
-
model:
|
|
8873
|
-
lane:
|
|
8874
|
-
risk:
|
|
8875
|
-
tracker:
|
|
8876
|
-
tile:
|
|
9142
|
+
name: str5(p2.name),
|
|
9143
|
+
model: str5(p2.model),
|
|
9144
|
+
lane: str5(p2.lane),
|
|
9145
|
+
risk: str5(p2.risk),
|
|
9146
|
+
tracker: str5(p2.tracker),
|
|
9147
|
+
tile: str5(p2.tile),
|
|
8877
9148
|
prs: arr2(p2.prs).filter((n) => typeof n === "number" && Number.isInteger(n) && n > 0)
|
|
8878
9149
|
};
|
|
8879
9150
|
}
|
|
8880
9151
|
function milestone(raw) {
|
|
8881
9152
|
const m2 = rec3(raw);
|
|
8882
9153
|
return {
|
|
8883
|
-
id:
|
|
8884
|
-
status:
|
|
8885
|
-
owner:
|
|
9154
|
+
id: str5(m2.id),
|
|
9155
|
+
status: str5(m2.status),
|
|
9156
|
+
owner: str5(m2.owner),
|
|
8886
9157
|
target: strOrNull(m2.target),
|
|
8887
9158
|
depends: arr2(m2.depends).filter((d3) => typeof d3 === "string"),
|
|
8888
9159
|
blockers: arr2(m2.blockers).map(blocker),
|
|
@@ -8891,19 +9162,19 @@ function milestone(raw) {
|
|
|
8891
9162
|
}
|
|
8892
9163
|
function roadmap(raw) {
|
|
8893
9164
|
const r2 = rec3(raw);
|
|
8894
|
-
if (r2.error !== void 0) return { roadmap:
|
|
9165
|
+
if (r2.error !== void 0) return { roadmap: str5(r2.roadmap), error: ERROR_TEXT };
|
|
8895
9166
|
const next = rec3(r2.next);
|
|
8896
9167
|
const out = {
|
|
8897
|
-
roadmap:
|
|
9168
|
+
roadmap: str5(r2.roadmap),
|
|
8898
9169
|
branch: strOrNull(r2.branch),
|
|
8899
9170
|
origin_commit: shortSha(r2.origin_commit),
|
|
8900
9171
|
done: int(r2.done),
|
|
8901
9172
|
total: int(r2.total),
|
|
8902
|
-
next: Object.keys(next).length ? { milestone:
|
|
9173
|
+
next: Object.keys(next).length ? { milestone: str5(next.milestone), plan: str5(next.plan), phase: int(next.phase) } : null,
|
|
8903
9174
|
lanes: arr2(r2.lanes).filter((l2) => typeof l2 === "string"),
|
|
8904
9175
|
waiting: arr2(r2.waiting).map((w2) => {
|
|
8905
9176
|
const x2 = rec3(w2);
|
|
8906
|
-
return { milestone:
|
|
9177
|
+
return { milestone: str5(x2.milestone), reason: str5(x2.reason), check: str5(x2.check) };
|
|
8907
9178
|
}),
|
|
8908
9179
|
milestones: arr2(r2.milestones).map(milestone)
|
|
8909
9180
|
};
|
|
@@ -8916,12 +9187,12 @@ function safePlanPath(p2) {
|
|
|
8916
9187
|
}
|
|
8917
9188
|
function plan(raw) {
|
|
8918
9189
|
const p2 = rec3(raw);
|
|
8919
|
-
if (p2.error !== void 0 || !safePlanPath(
|
|
9190
|
+
if (p2.error !== void 0 || !safePlanPath(str5(p2.path))) return null;
|
|
8920
9191
|
return {
|
|
8921
|
-
path:
|
|
8922
|
-
title:
|
|
8923
|
-
status:
|
|
8924
|
-
tracker: arr2(p2.tracker).map((t) => ({ phase:
|
|
9192
|
+
path: str5(p2.path),
|
|
9193
|
+
title: str5(p2.title),
|
|
9194
|
+
status: str5(p2.status),
|
|
9195
|
+
tracker: arr2(p2.tracker).map((t) => ({ phase: str5(rec3(t).phase), status: str5(rec3(t).status), state: str5(rec3(t).state) })),
|
|
8925
9196
|
open_rows: int(p2.open_rows)
|
|
8926
9197
|
};
|
|
8927
9198
|
}
|
|
@@ -8959,7 +9230,7 @@ function derivedDeny(collect, machine) {
|
|
|
8959
9230
|
if (s.length >= 3) out.add(s);
|
|
8960
9231
|
};
|
|
8961
9232
|
const addPath = (v2) => {
|
|
8962
|
-
const s =
|
|
9233
|
+
const s = str5(v2).trim();
|
|
8963
9234
|
if (!s) return;
|
|
8964
9235
|
add(s);
|
|
8965
9236
|
add(s.replace(/\\/g, "/"));
|
|
@@ -8985,7 +9256,7 @@ function derivedDeny(collect, machine) {
|
|
|
8985
9256
|
if (!GENERIC_NAMES.has(machine.user.toLowerCase())) add(machine.user);
|
|
8986
9257
|
return [...out];
|
|
8987
9258
|
}
|
|
8988
|
-
var GITHUB_RE, ERROR_TEXT, rec3, arr2,
|
|
9259
|
+
var GITHUB_RE, ERROR_TEXT, rec3, arr2, str5, strOrNull, int, shortSha, GENERIC_NAMES;
|
|
8989
9260
|
var init_data = __esm({
|
|
8990
9261
|
"src/hub/export/data.ts"() {
|
|
8991
9262
|
"use strict";
|
|
@@ -8993,11 +9264,11 @@ var init_data = __esm({
|
|
|
8993
9264
|
ERROR_TEXT = "could not be read";
|
|
8994
9265
|
rec3 = (v2) => v2 && typeof v2 === "object" && !Array.isArray(v2) ? v2 : {};
|
|
8995
9266
|
arr2 = (v2) => Array.isArray(v2) ? v2 : [];
|
|
8996
|
-
|
|
9267
|
+
str5 = (v2) => typeof v2 === "string" ? v2 : "";
|
|
8997
9268
|
strOrNull = (v2) => typeof v2 === "string" && v2 ? v2 : null;
|
|
8998
9269
|
int = (v2) => typeof v2 === "number" && Number.isInteger(v2) ? v2 : 0;
|
|
8999
9270
|
shortSha = (v2) => {
|
|
9000
|
-
const s =
|
|
9271
|
+
const s = str5(v2);
|
|
9001
9272
|
return /^[0-9a-fA-F]{7,}$/.test(s) ? s.slice(0, 7) : null;
|
|
9002
9273
|
};
|
|
9003
9274
|
GENERIC_NAMES = /* @__PURE__ */ new Set(["runner", "root", "user", "users", "admin", "administrator", "ubuntu", "localhost", "github"]);
|
|
@@ -9005,8 +9276,8 @@ var init_data = __esm({
|
|
|
9005
9276
|
});
|
|
9006
9277
|
|
|
9007
9278
|
// src/hub/export/privacy.ts
|
|
9008
|
-
import { lstatSync, readdirSync as
|
|
9009
|
-
import
|
|
9279
|
+
import { lstatSync, readdirSync as readdirSync5, readFileSync as readFileSync17 } from "fs";
|
|
9280
|
+
import path24 from "path";
|
|
9010
9281
|
function parseAllowedUrls(text2) {
|
|
9011
9282
|
const exact = /* @__PURE__ */ new Set();
|
|
9012
9283
|
const templates = [];
|
|
@@ -9019,13 +9290,13 @@ function parseAllowedUrls(text2) {
|
|
|
9019
9290
|
return { exact, templates };
|
|
9020
9291
|
}
|
|
9021
9292
|
function defaultAllowedUrls() {
|
|
9022
|
-
return
|
|
9293
|
+
return readFileSync17(new URL("./allowed-urls.txt", import.meta.url), "utf8");
|
|
9023
9294
|
}
|
|
9024
9295
|
function walk(dir, base = "") {
|
|
9025
9296
|
const out = [];
|
|
9026
|
-
for (const name of
|
|
9297
|
+
for (const name of readdirSync5(dir).sort()) {
|
|
9027
9298
|
const rel = base ? `${base}/${name}` : name;
|
|
9028
|
-
const full =
|
|
9299
|
+
const full = path24.join(dir, name);
|
|
9029
9300
|
if (lstatSync(full).isDirectory()) out.push(...walk(full, rel));
|
|
9030
9301
|
else out.push(rel);
|
|
9031
9302
|
}
|
|
@@ -9061,13 +9332,13 @@ function scanUrls(file, text2, opts, hits) {
|
|
|
9061
9332
|
function scanExport(dir, opts) {
|
|
9062
9333
|
const hits = [];
|
|
9063
9334
|
for (const file of walk(dir)) {
|
|
9064
|
-
const full =
|
|
9335
|
+
const full = path24.join(dir, ...file.split("/"));
|
|
9065
9336
|
if (lstatSync(full).isSymbolicLink()) {
|
|
9066
9337
|
hits.push({ file, offset: 0, rule: "symbolic-link" });
|
|
9067
9338
|
continue;
|
|
9068
9339
|
}
|
|
9069
|
-
const buf =
|
|
9070
|
-
const binary = BINARY_EXT.has(
|
|
9340
|
+
const buf = readFileSync17(full);
|
|
9341
|
+
const binary = BINARY_EXT.has(path24.extname(file).toLowerCase());
|
|
9071
9342
|
const text2 = binary ? null : buf.toString("utf8");
|
|
9072
9343
|
scanDeny(file, buf, text2, opts.deny, hits);
|
|
9073
9344
|
if (text2 === null) continue;
|
|
@@ -9147,19 +9418,19 @@ import {
|
|
|
9147
9418
|
copyFileSync,
|
|
9148
9419
|
existsSync as existsSync10,
|
|
9149
9420
|
lstatSync as lstatSync2,
|
|
9150
|
-
mkdirSync as
|
|
9151
|
-
readdirSync as
|
|
9152
|
-
readFileSync as
|
|
9153
|
-
renameSync as
|
|
9421
|
+
mkdirSync as mkdirSync9,
|
|
9422
|
+
readdirSync as readdirSync6,
|
|
9423
|
+
readFileSync as readFileSync18,
|
|
9424
|
+
renameSync as renameSync4,
|
|
9154
9425
|
rmSync as rmSync4,
|
|
9155
9426
|
statSync as statSync3,
|
|
9156
|
-
writeFileSync as
|
|
9427
|
+
writeFileSync as writeFileSync6
|
|
9157
9428
|
} from "fs";
|
|
9158
9429
|
import os6 from "os";
|
|
9159
|
-
import
|
|
9430
|
+
import path25 from "path";
|
|
9160
9431
|
function holdsLink(dir) {
|
|
9161
|
-
for (const name of
|
|
9162
|
-
const full =
|
|
9432
|
+
for (const name of readdirSync6(dir)) {
|
|
9433
|
+
const full = path25.join(dir, name);
|
|
9163
9434
|
const st = lstatSync2(full);
|
|
9164
9435
|
if (st.isSymbolicLink()) return true;
|
|
9165
9436
|
if (st.isDirectory() && holdsLink(full)) return true;
|
|
@@ -9177,8 +9448,8 @@ function checkOut(out, repo) {
|
|
|
9177
9448
|
}
|
|
9178
9449
|
if (st.isSymbolicLink()) return "--out is a link";
|
|
9179
9450
|
if (!st.isDirectory()) return "--out is a file";
|
|
9180
|
-
if (
|
|
9181
|
-
if (!existsSync10(
|
|
9451
|
+
if (readdirSync6(out).length === 0) return null;
|
|
9452
|
+
if (!existsSync10(path25.join(out, MARKER)) || lstatSync2(path25.join(out, MARKER)).isSymbolicLink()) {
|
|
9182
9453
|
return `--out is not empty and has no ${MARKER} marker: this command did not make it`;
|
|
9183
9454
|
}
|
|
9184
9455
|
if (holdsLink(out)) return "--out holds a link";
|
|
@@ -9204,33 +9475,33 @@ function notFoundPage() {
|
|
|
9204
9475
|
`;
|
|
9205
9476
|
}
|
|
9206
9477
|
function copyFixedSet(dist, dest) {
|
|
9207
|
-
|
|
9208
|
-
|
|
9209
|
-
|
|
9210
|
-
copyFileSync(
|
|
9211
|
-
for (const name of
|
|
9212
|
-
const from =
|
|
9213
|
-
if (lstatSync2(from).isFile()) copyFileSync(from,
|
|
9214
|
-
}
|
|
9215
|
-
const fonts =
|
|
9478
|
+
mkdirSync9(path25.join(dest, "assets"), { recursive: true });
|
|
9479
|
+
mkdirSync9(path25.join(dest, "fonts"), { recursive: true });
|
|
9480
|
+
mkdirSync9(path25.join(dest, "licenses"), { recursive: true });
|
|
9481
|
+
copyFileSync(path25.join(dist, "index.html"), path25.join(dest, "index.html"));
|
|
9482
|
+
for (const name of readdirSync6(path25.join(dist, "assets"))) {
|
|
9483
|
+
const from = path25.join(dist, "assets", name);
|
|
9484
|
+
if (lstatSync2(from).isFile()) copyFileSync(from, path25.join(dest, "assets", name));
|
|
9485
|
+
}
|
|
9486
|
+
const fonts = path25.join(dist, "fonts");
|
|
9216
9487
|
if (isDir2(fonts)) {
|
|
9217
|
-
for (const name of
|
|
9218
|
-
const from =
|
|
9488
|
+
for (const name of readdirSync6(fonts)) {
|
|
9489
|
+
const from = path25.join(fonts, name);
|
|
9219
9490
|
if (!lstatSync2(from).isFile()) continue;
|
|
9220
|
-
if (name.endsWith(".woff2")) copyFileSync(from,
|
|
9491
|
+
if (name.endsWith(".woff2")) copyFileSync(from, path25.join(dest, "fonts", name));
|
|
9221
9492
|
}
|
|
9222
9493
|
}
|
|
9223
|
-
const licenses =
|
|
9494
|
+
const licenses = path25.join(dist, "licenses");
|
|
9224
9495
|
if (isDir2(licenses)) {
|
|
9225
|
-
for (const name of
|
|
9226
|
-
const from =
|
|
9227
|
-
if (lstatSync2(from).isFile() && /^(OFL-[A-Za-z]+|LICENSE-Lucide)\.txt$/.test(name)) copyFileSync(from,
|
|
9496
|
+
for (const name of readdirSync6(licenses)) {
|
|
9497
|
+
const from = path25.join(licenses, name);
|
|
9498
|
+
if (lstatSync2(from).isFile() && /^(OFL-[A-Za-z]+|LICENSE-Lucide)\.txt$/.test(name)) copyFileSync(from, path25.join(dest, "licenses", name));
|
|
9228
9499
|
}
|
|
9229
9500
|
}
|
|
9230
9501
|
}
|
|
9231
9502
|
function countFiles(dir) {
|
|
9232
|
-
return
|
|
9233
|
-
const full =
|
|
9503
|
+
return readdirSync6(dir).reduce((n, name) => {
|
|
9504
|
+
const full = path25.join(dir, name);
|
|
9234
9505
|
return n + (lstatSync2(full).isDirectory() ? countFiles(full) : name === MARKER ? 0 : 1);
|
|
9235
9506
|
}, 0);
|
|
9236
9507
|
}
|
|
@@ -9252,7 +9523,7 @@ async function hubExport(args, deps = {}) {
|
|
|
9252
9523
|
return 2;
|
|
9253
9524
|
}
|
|
9254
9525
|
if (args.check !== void 0) {
|
|
9255
|
-
const dir =
|
|
9526
|
+
const dir = path25.resolve(args.check);
|
|
9256
9527
|
if (!isDir2(dir)) {
|
|
9257
9528
|
err(`error: --check folder not found: ${args.check}`);
|
|
9258
9529
|
return 1;
|
|
@@ -9276,9 +9547,9 @@ async function hubExport(args, deps = {}) {
|
|
|
9276
9547
|
err("error: --commit must be 7 to 40 hex characters");
|
|
9277
9548
|
return 2;
|
|
9278
9549
|
}
|
|
9279
|
-
const repo =
|
|
9280
|
-
const outDir =
|
|
9281
|
-
if (!existsSync10(
|
|
9550
|
+
const repo = path25.resolve(args.repo);
|
|
9551
|
+
const outDir = path25.resolve(args.out);
|
|
9552
|
+
if (!existsSync10(path25.join(repo, ".git")) || !(isDir2(path25.join(repo, ".caddis", "roadmaps")) || isDir2(path25.join(repo, ".caddis", "plans")))) {
|
|
9282
9553
|
err("error: --repo must be a git checkout with .caddis/roadmaps/ or .caddis/plans/");
|
|
9283
9554
|
return 2;
|
|
9284
9555
|
}
|
|
@@ -9287,8 +9558,8 @@ async function hubExport(args, deps = {}) {
|
|
|
9287
9558
|
err(`error: ${refused}`);
|
|
9288
9559
|
return 2;
|
|
9289
9560
|
}
|
|
9290
|
-
const dist = deps.distDir ??
|
|
9291
|
-
if (!existsSync10(
|
|
9561
|
+
const dist = deps.distDir ?? path25.join(packageInfo().root, "dist", "export");
|
|
9562
|
+
if (!existsSync10(path25.join(dist, "index.html")) || !isDir2(path25.join(dist, "assets"))) {
|
|
9292
9563
|
err(`error: the export app is not built (${dist}). Run: npm run build:ui`);
|
|
9293
9564
|
return 1;
|
|
9294
9565
|
}
|
|
@@ -9333,12 +9604,12 @@ async function hubExport(args, deps = {}) {
|
|
|
9333
9604
|
rmSync4(staging, { recursive: true, force: true });
|
|
9334
9605
|
try {
|
|
9335
9606
|
copyFixedSet(dist, staging);
|
|
9336
|
-
const indexPath =
|
|
9337
|
-
const html =
|
|
9607
|
+
const indexPath = path25.join(staging, "index.html");
|
|
9608
|
+
const html = readFileSync18(indexPath, "utf8");
|
|
9338
9609
|
if (!html.includes(PLACEHOLDER)) throw new Error("the built index.html has no data placeholder");
|
|
9339
9610
|
const block = `<script type="application/json" id="caddis-export-data">${escapeJson(JSON.stringify(data))}</script>`;
|
|
9340
|
-
|
|
9341
|
-
|
|
9611
|
+
writeFileSync6(indexPath, html.replace(PLACEHOLDER, () => block));
|
|
9612
|
+
writeFileSync6(path25.join(staging, "404.html"), notFoundPage());
|
|
9342
9613
|
const hits = scanExport(staging, { deny, github: args.github ?? null, ...deps.allowedUrls !== void 0 ? { allowedUrls: deps.allowedUrls } : {} });
|
|
9343
9614
|
if (hits.length) {
|
|
9344
9615
|
for (const h2 of hits) err(hitLine(h2));
|
|
@@ -9346,10 +9617,10 @@ async function hubExport(args, deps = {}) {
|
|
|
9346
9617
|
rmSync4(staging, { recursive: true, force: true });
|
|
9347
9618
|
return 3;
|
|
9348
9619
|
}
|
|
9349
|
-
|
|
9620
|
+
mkdirSync9(path25.dirname(outDir), { recursive: true });
|
|
9350
9621
|
if (existsSync10(outDir)) rmSync4(outDir, { recursive: true, force: true });
|
|
9351
|
-
|
|
9352
|
-
|
|
9622
|
+
renameSync4(staging, outDir);
|
|
9623
|
+
writeFileSync6(path25.join(outDir, MARKER), "written by caddis hub export\n");
|
|
9353
9624
|
out(`[EXPORT] ${countFiles(outDir)} file(s) in ${outDir}`);
|
|
9354
9625
|
return 0;
|
|
9355
9626
|
} catch (error) {
|
|
@@ -9379,12 +9650,12 @@ var init_export = __esm({
|
|
|
9379
9650
|
}
|
|
9380
9651
|
};
|
|
9381
9652
|
samePath = (a, b3) => {
|
|
9382
|
-
const norm = (p2) =>
|
|
9653
|
+
const norm = (p2) => path25.resolve(p2).replace(/[\\/]+$/, "").toLowerCase();
|
|
9383
9654
|
return norm(a) === norm(b3);
|
|
9384
9655
|
};
|
|
9385
9656
|
isInside = (child, parent) => {
|
|
9386
|
-
const rel =
|
|
9387
|
-
return rel !== "" && !rel.startsWith("..") && !
|
|
9657
|
+
const rel = path25.relative(path25.resolve(parent), path25.resolve(child));
|
|
9658
|
+
return rel !== "" && !rel.startsWith("..") && !path25.isAbsolute(rel);
|
|
9388
9659
|
};
|
|
9389
9660
|
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
9661
|
}
|
|
@@ -9445,14 +9716,14 @@ function* pluginBlocks(stdout) {
|
|
|
9445
9716
|
if (current) yield current;
|
|
9446
9717
|
}
|
|
9447
9718
|
async function detect() {
|
|
9448
|
-
const
|
|
9449
|
-
if (!
|
|
9719
|
+
const path26 = await findBin(BIN);
|
|
9720
|
+
if (!path26) {
|
|
9450
9721
|
return { present: false, note: "no `claude` binary on PATH" };
|
|
9451
9722
|
}
|
|
9452
9723
|
const version = await run(BIN, ["--version"], { timeout: 2e4 });
|
|
9453
9724
|
return {
|
|
9454
9725
|
present: true,
|
|
9455
|
-
path:
|
|
9726
|
+
path: path26,
|
|
9456
9727
|
agentVersion: version.ok ? version.stdout.trim().split(/\s+/)[0] || void 0 : void 0,
|
|
9457
9728
|
note: version.ok ? void 0 : "binary found but `claude --version` failed"
|
|
9458
9729
|
};
|