cruo-agent 0.1.8 → 0.1.9
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/dist/VERSION +1 -1
- package/dist/cli.js +98 -12
- package/package.json +1 -1
package/dist/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.1.
|
|
1
|
+
0.1.9
|
package/dist/cli.js
CHANGED
|
@@ -45913,6 +45913,36 @@ function isKnownCommandWord(first) {
|
|
|
45913
45913
|
function nearestCommands(first) {
|
|
45914
45914
|
return CRUO_COMMANDS.filter((k) => k[0] === first[0]).slice(0, 3);
|
|
45915
45915
|
}
|
|
45916
|
+
function editDistance(a, b) {
|
|
45917
|
+
const row = Array.from({ length: b.length + 1 }, (_, j) => j);
|
|
45918
|
+
for (let i = 1; i <= a.length; i++) {
|
|
45919
|
+
let diagonal = row[0];
|
|
45920
|
+
row[0] = i;
|
|
45921
|
+
for (let j = 1; j <= b.length; j++) {
|
|
45922
|
+
const above = row[j];
|
|
45923
|
+
row[j] = Math.min(row[j] + 1, row[j - 1] + 1, diagonal + (a[i - 1] === b[j - 1] ? 0 : 1));
|
|
45924
|
+
diagonal = above;
|
|
45925
|
+
}
|
|
45926
|
+
}
|
|
45927
|
+
return row[b.length];
|
|
45928
|
+
}
|
|
45929
|
+
function unknownFlags(argv2, valued = [...SUPERVISOR_VALUED, ...CLI_VALUED], switches = SUPERVISOR_SWITCHES) {
|
|
45930
|
+
const known = [...valued, ...switches];
|
|
45931
|
+
const found = [];
|
|
45932
|
+
for (let i = 0; i < argv2.length; i++) {
|
|
45933
|
+
const arg = argv2[i];
|
|
45934
|
+
if (!arg.startsWith("-")) continue;
|
|
45935
|
+
const name = arg.replace(/^-+/, "");
|
|
45936
|
+
if (valued.includes(name)) {
|
|
45937
|
+
i++;
|
|
45938
|
+
continue;
|
|
45939
|
+
}
|
|
45940
|
+
if (switches.includes(name)) continue;
|
|
45941
|
+
const ranked = known.map((k) => ({ k, d: editDistance(name.split("=")[0], k) })).sort((x, y) => x.d - y.d)[0];
|
|
45942
|
+
found.push({ flag: arg, nearest: ranked && ranked.d <= 2 ? `--${ranked.k}` : null });
|
|
45943
|
+
}
|
|
45944
|
+
return found;
|
|
45945
|
+
}
|
|
45916
45946
|
function numericIn(argv2, name, spec = {}) {
|
|
45917
45947
|
const i = argv2.indexOf(`--${name}`);
|
|
45918
45948
|
if (i < 0) return spec.fallback;
|
|
@@ -45947,7 +45977,7 @@ function requiredNumericIn(argv2, name, fallback, spec = {}) {
|
|
|
45947
45977
|
function secondsIn(argv2, name, fallbackSeconds) {
|
|
45948
45978
|
return requiredNumericIn(argv2, name, fallbackSeconds, { unit: "seconds" }) * 1e3;
|
|
45949
45979
|
}
|
|
45950
|
-
var CRUO_COMMANDS, OptionError, flagIn, optIn;
|
|
45980
|
+
var CRUO_COMMANDS, SUPERVISOR_SWITCHES, SUPERVISOR_VALUED, CLI_VALUED, OptionError, flagIn, optIn;
|
|
45951
45981
|
var init_options = __esm({
|
|
45952
45982
|
"src/options.ts"() {
|
|
45953
45983
|
"use strict";
|
|
@@ -45963,8 +45993,32 @@ var init_options = __esm({
|
|
|
45963
45993
|
"stop",
|
|
45964
45994
|
"pause",
|
|
45965
45995
|
"resume",
|
|
45966
|
-
"logs"
|
|
45996
|
+
"logs",
|
|
45997
|
+
"run",
|
|
45998
|
+
"version",
|
|
45999
|
+
"?"
|
|
45967
46000
|
];
|
|
46001
|
+
SUPERVISOR_SWITCHES = ["once", "dry-run", "worktree", "keep-failed", "push", "usage"];
|
|
46002
|
+
SUPERVISOR_VALUED = [
|
|
46003
|
+
"allow",
|
|
46004
|
+
"base",
|
|
46005
|
+
"cwd",
|
|
46006
|
+
"function",
|
|
46007
|
+
"harness",
|
|
46008
|
+
"harness-timeout",
|
|
46009
|
+
"interval",
|
|
46010
|
+
"limit",
|
|
46011
|
+
"max-attempts",
|
|
46012
|
+
"max-interval",
|
|
46013
|
+
"model",
|
|
46014
|
+
"prepare",
|
|
46015
|
+
"prepare-timeout",
|
|
46016
|
+
"project",
|
|
46017
|
+
"push-remote",
|
|
46018
|
+
"repo",
|
|
46019
|
+
"worktree-root"
|
|
46020
|
+
];
|
|
46021
|
+
CLI_VALUED = ["as", "token"];
|
|
45968
46022
|
OptionError = class extends Error {
|
|
45969
46023
|
constructor(message) {
|
|
45970
46024
|
super(message);
|
|
@@ -47829,6 +47883,12 @@ var init_supervisor = __esm({
|
|
|
47829
47883
|
});
|
|
47830
47884
|
options = (() => {
|
|
47831
47885
|
try {
|
|
47886
|
+
const [unknown2] = unknownFlags(argv, SUPERVISOR_VALUED);
|
|
47887
|
+
if (unknown2) {
|
|
47888
|
+
throw new OptionError(
|
|
47889
|
+
`${unknown2.flag} is not a flag the supervisor reads` + (unknown2.nearest ? ` \u2014 did you mean ${unknown2.nearest}?` : ".") + ` Nothing was started.`
|
|
47890
|
+
);
|
|
47891
|
+
}
|
|
47832
47892
|
return readOptions();
|
|
47833
47893
|
} catch (error51) {
|
|
47834
47894
|
if (error51 instanceof OptionError) {
|
|
@@ -47914,8 +47974,10 @@ var USAGE = `cruo \u2014 run a Cruo agent
|
|
|
47914
47974
|
cruo agents list what is remembered (never the tokens)
|
|
47915
47975
|
cruo usage [--days 7] what the agents have been spending
|
|
47916
47976
|
cruo logout [name] forget one, or --all
|
|
47917
|
-
cruo [options]
|
|
47918
|
-
cruo --as <name> \u2026 run a particular one
|
|
47977
|
+
cruo run [options] run the agent's supervisor, in this terminal
|
|
47978
|
+
cruo --as <name> \u2026 run a particular one (flags alone also run it)
|
|
47979
|
+
cruo version which build this is
|
|
47980
|
+
cruo help this list (also: cruo, cruo -h, cruo ?)
|
|
47919
47981
|
|
|
47920
47982
|
Running one in the background
|
|
47921
47983
|
cruo start [options] same, detached \u2014 survives closing the terminal
|
|
@@ -48027,7 +48089,7 @@ ${CONFIG_PATH} is readable only by you.
|
|
|
48027
48089
|
|
|
48028
48090
|
` + (config3.default === name ? `Run \`cruo --dry-run\` to see what it would pick up.
|
|
48029
48091
|
` : `Run \`cruo --as ${name} --dry-run\` to see what it would pick up.
|
|
48030
|
-
|
|
48092
|
+
\`cruo run\` still runs \`${config3.default}\`.
|
|
48031
48093
|
`)
|
|
48032
48094
|
);
|
|
48033
48095
|
}
|
|
@@ -48078,7 +48140,7 @@ Nothing stored for \`${which}\`. Stored: ${names.join(", ") || "(none)"}
|
|
|
48078
48140
|
await writeConfig(config3);
|
|
48079
48141
|
console.log(
|
|
48080
48142
|
`
|
|
48081
|
-
Forgot the token for \`${which}\`.` + (config3.default ? `
|
|
48143
|
+
Forgot the token for \`${which}\`.` + (config3.default ? ` \`cruo run\` now runs \`${config3.default}\`.
|
|
48082
48144
|
` : ` Nothing is stored now.
|
|
48083
48145
|
`)
|
|
48084
48146
|
);
|
|
@@ -48100,7 +48162,7 @@ No tokens stored. \`cruo login <token>\` to add one.
|
|
|
48100
48162
|
console.log(` ${mark} ${name}${who}`);
|
|
48101
48163
|
}
|
|
48102
48164
|
console.log(`
|
|
48103
|
-
* is what
|
|
48165
|
+
* is what \`cruo run\` runs. Use \`--as <name>\` for another.
|
|
48104
48166
|
`);
|
|
48105
48167
|
}
|
|
48106
48168
|
async function targetName(explicit, asName) {
|
|
@@ -48175,13 +48237,14 @@ Either \`cruo start ${stored[0]}\`, or add this one:
|
|
|
48175
48237
|
);
|
|
48176
48238
|
process.exit(2);
|
|
48177
48239
|
}
|
|
48240
|
+
refuseUnknownFlags(argv2.slice(positional ? 2 : 1).filter((a) => a !== "--all"));
|
|
48178
48241
|
await mkdir4(logDir(), { recursive: true });
|
|
48179
48242
|
const logPath = join4(logDir(), `${name}.log`);
|
|
48180
48243
|
const handle = await open(logPath, "a");
|
|
48181
48244
|
const rest = argv2.slice(positional ? 2 : 1).filter((a) => a !== "--all");
|
|
48182
48245
|
const chosen = storedKey ?? positional ?? asName;
|
|
48183
48246
|
const withoutAs = rest.filter((a, i, all) => a !== "--as" && all[i - 1] !== "--as");
|
|
48184
|
-
const forwarded = chosen ? ["--as", chosen, ...withoutAs]
|
|
48247
|
+
const forwarded = ["run", ...chosen ? ["--as", chosen] : [], ...withoutAs];
|
|
48185
48248
|
const child = spawn2(process.execPath, [process.argv[1], ...forwarded], {
|
|
48186
48249
|
detached: true,
|
|
48187
48250
|
stdio: ["ignore", handle.fd, handle.fd],
|
|
@@ -48285,6 +48348,26 @@ A detached run writes one; a foreground run prints to its terminal.
|
|
|
48285
48348
|
});
|
|
48286
48349
|
await new Promise((resolve2) => child.on("close", resolve2));
|
|
48287
48350
|
}
|
|
48351
|
+
async function printVersion() {
|
|
48352
|
+
try {
|
|
48353
|
+
const pkg = JSON.parse(await readFile3(new URL("../package.json", import.meta.url), "utf8"));
|
|
48354
|
+
console.log(`${pkg.name} ${pkg.version}`);
|
|
48355
|
+
} catch {
|
|
48356
|
+
console.log("unknown \u2014 no package.json beside this build");
|
|
48357
|
+
}
|
|
48358
|
+
}
|
|
48359
|
+
function refuseUnknownFlags(argv2) {
|
|
48360
|
+
const unknown2 = unknownFlags(argv2);
|
|
48361
|
+
if (unknown2.length === 0) return;
|
|
48362
|
+
console.error(
|
|
48363
|
+
`
|
|
48364
|
+
${unknown2.map((u) => `\`${u.flag}\` is not a cruo flag.` + (u.nearest ? ` Did you mean ${u.nearest}?` : "")).join("\n")}
|
|
48365
|
+
|
|
48366
|
+
Nothing was started. Everything it takes: cruo help
|
|
48367
|
+
`
|
|
48368
|
+
);
|
|
48369
|
+
process.exit(2);
|
|
48370
|
+
}
|
|
48288
48371
|
async function main2() {
|
|
48289
48372
|
const argv2 = process.argv.slice(2);
|
|
48290
48373
|
const [first] = argv2;
|
|
@@ -48321,10 +48404,11 @@ Usage: cruo login <token> [--as <name>]
|
|
|
48321
48404
|
}
|
|
48322
48405
|
if (first === "usage") {
|
|
48323
48406
|
}
|
|
48324
|
-
if (first === "help" || argv2.includes("--help") || argv2.includes("-h")) {
|
|
48407
|
+
if (first === void 0 || first === "help" || first === "?" || argv2.includes("--help") || argv2.includes("-h")) {
|
|
48325
48408
|
console.log(USAGE);
|
|
48326
48409
|
return;
|
|
48327
48410
|
}
|
|
48411
|
+
if (first === "version" || first === "--version" || first === "-v") return printVersion();
|
|
48328
48412
|
if (!isKnownCommandWord(first)) {
|
|
48329
48413
|
const near = nearestCommands(first);
|
|
48330
48414
|
console.error(
|
|
@@ -48333,13 +48417,15 @@ Usage: cruo login <token> [--as <name>]
|
|
|
48333
48417
|
|
|
48334
48418
|
` + (near.length > 0 ? `Did you mean: ${near.map((k) => `cruo ${k}`).join(" ")}
|
|
48335
48419
|
|
|
48336
|
-
` : "") + `To run the agent
|
|
48337
|
-
Everything it takes:
|
|
48420
|
+
` : "") + `To run the agent: cruo run [options]
|
|
48421
|
+
Everything it takes: cruo help
|
|
48338
48422
|
`
|
|
48339
48423
|
);
|
|
48340
48424
|
process.exit(2);
|
|
48341
48425
|
}
|
|
48342
48426
|
if (first === "start") return startDetached(argv2, flagValue("--as"));
|
|
48427
|
+
const runArgv = first === "run" ? argv2.slice(1) : argv2;
|
|
48428
|
+
if (first !== "usage") refuseUnknownFlags(runArgv);
|
|
48343
48429
|
const flagIndex = argv2.indexOf("--token");
|
|
48344
48430
|
const fromFlag = flagIndex >= 0 ? argv2[flagIndex + 1] : void 0;
|
|
48345
48431
|
if (fromFlag) {
|
|
@@ -48379,7 +48465,7 @@ Get one from Cruo \u2192 Settings \u2192 Members \u2192 Add an agent.
|
|
|
48379
48465
|
process.env.CRUO_IDENTITY = asName ?? config3.default ?? "";
|
|
48380
48466
|
}
|
|
48381
48467
|
process.env.CRUO_TOKEN = token;
|
|
48382
|
-
const passthrough = stripTokenFlag(
|
|
48468
|
+
const passthrough = stripTokenFlag(runArgv).filter((a, i, all) => a !== "--as" && all[i - 1] !== "--as");
|
|
48383
48469
|
process.argv = [process.argv[0], process.argv[1], ...passthrough];
|
|
48384
48470
|
if (first === "usage") {
|
|
48385
48471
|
const { reportUsage: reportUsage2 } = await Promise.resolve().then(() => (init_usage(), usage_exports));
|
package/package.json
CHANGED