@devtune/agentpicks 0.4.6 → 0.4.8
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 +13 -6
- package/dist/cli.js +613 -269
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1504,7 +1504,7 @@ var require_stringify = __commonJS({
|
|
|
1504
1504
|
props.push(doc.directives.tagString(tag));
|
|
1505
1505
|
return props.join(" ");
|
|
1506
1506
|
}
|
|
1507
|
-
function
|
|
1507
|
+
function stringify4(item, ctx, onComment, onChompKeep) {
|
|
1508
1508
|
if (identity.isPair(item))
|
|
1509
1509
|
return item.toString(ctx, onComment, onChompKeep);
|
|
1510
1510
|
if (identity.isAlias(item)) {
|
|
@@ -1533,7 +1533,7 @@ var require_stringify = __commonJS({
|
|
|
1533
1533
|
${ctx.indent}${str2}`;
|
|
1534
1534
|
}
|
|
1535
1535
|
exports2.createStringifyContext = createStringifyContext;
|
|
1536
|
-
exports2.stringify =
|
|
1536
|
+
exports2.stringify = stringify4;
|
|
1537
1537
|
}
|
|
1538
1538
|
});
|
|
1539
1539
|
|
|
@@ -1543,7 +1543,7 @@ var require_stringifyPair = __commonJS({
|
|
|
1543
1543
|
"use strict";
|
|
1544
1544
|
var identity = require_identity();
|
|
1545
1545
|
var Scalar = require_Scalar();
|
|
1546
|
-
var
|
|
1546
|
+
var stringify4 = require_stringify();
|
|
1547
1547
|
var stringifyComment = require_stringifyComment();
|
|
1548
1548
|
function stringifyPair({ key, value }, ctx, onComment, onChompKeep) {
|
|
1549
1549
|
const { allNullValues, doc, indent, indentStep, options: { commentString, indentSeq, simpleKeys } } = ctx;
|
|
@@ -1565,7 +1565,7 @@ var require_stringifyPair = __commonJS({
|
|
|
1565
1565
|
});
|
|
1566
1566
|
let keyCommentDone = false;
|
|
1567
1567
|
let chompKeep = false;
|
|
1568
|
-
let str2 =
|
|
1568
|
+
let str2 = stringify4.stringify(key, ctx, () => keyCommentDone = true, () => chompKeep = true);
|
|
1569
1569
|
if (!explicitKey && !ctx.inFlow && str2.length > 1024) {
|
|
1570
1570
|
if (simpleKeys)
|
|
1571
1571
|
throw new Error("With simple keys, single line scalar must not span more than 1024 characters");
|
|
@@ -1617,7 +1617,7 @@ ${indent}:`;
|
|
|
1617
1617
|
ctx.indent = ctx.indent.substring(2);
|
|
1618
1618
|
}
|
|
1619
1619
|
let valueCommentDone = false;
|
|
1620
|
-
const valueStr =
|
|
1620
|
+
const valueStr = stringify4.stringify(value, ctx, () => valueCommentDone = true, () => chompKeep = true);
|
|
1621
1621
|
let ws = " ";
|
|
1622
1622
|
if (keyComment || vsb || vcb) {
|
|
1623
1623
|
ws = vsb ? "\n" : "";
|
|
@@ -1758,7 +1758,7 @@ var require_addPairToJSMap = __commonJS({
|
|
|
1758
1758
|
"use strict";
|
|
1759
1759
|
var log = require_log();
|
|
1760
1760
|
var merge2 = require_merge();
|
|
1761
|
-
var
|
|
1761
|
+
var stringify4 = require_stringify();
|
|
1762
1762
|
var identity = require_identity();
|
|
1763
1763
|
var toJS = require_toJS();
|
|
1764
1764
|
function addPairToJSMap(ctx, map2, { key, value }) {
|
|
@@ -1794,7 +1794,7 @@ var require_addPairToJSMap = __commonJS({
|
|
|
1794
1794
|
if (typeof jsKey !== "object")
|
|
1795
1795
|
return String(jsKey);
|
|
1796
1796
|
if (identity.isNode(key) && ctx?.doc) {
|
|
1797
|
-
const strCtx =
|
|
1797
|
+
const strCtx = stringify4.createStringifyContext(ctx.doc, {});
|
|
1798
1798
|
strCtx.anchors = /* @__PURE__ */ new Set();
|
|
1799
1799
|
for (const node2 of ctx.anchors.keys())
|
|
1800
1800
|
strCtx.anchors.add(node2.anchor);
|
|
@@ -1861,12 +1861,12 @@ var require_stringifyCollection = __commonJS({
|
|
|
1861
1861
|
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/stringify/stringifyCollection.js"(exports2) {
|
|
1862
1862
|
"use strict";
|
|
1863
1863
|
var identity = require_identity();
|
|
1864
|
-
var
|
|
1864
|
+
var stringify4 = require_stringify();
|
|
1865
1865
|
var stringifyComment = require_stringifyComment();
|
|
1866
1866
|
function stringifyCollection(collection, ctx, options) {
|
|
1867
1867
|
const flow = ctx.inFlow ?? collection.flow;
|
|
1868
|
-
const
|
|
1869
|
-
return
|
|
1868
|
+
const stringify5 = flow ? stringifyFlowCollection : stringifyBlockCollection;
|
|
1869
|
+
return stringify5(collection, ctx, options);
|
|
1870
1870
|
}
|
|
1871
1871
|
function stringifyBlockCollection({ comment, items }, ctx, { blockItemPrefix, flowChars, itemIndent, onChompKeep, onComment }) {
|
|
1872
1872
|
const { indent, options: { commentString } } = ctx;
|
|
@@ -1891,7 +1891,7 @@ var require_stringifyCollection = __commonJS({
|
|
|
1891
1891
|
}
|
|
1892
1892
|
}
|
|
1893
1893
|
chompKeep = false;
|
|
1894
|
-
let str3 =
|
|
1894
|
+
let str3 = stringify4.stringify(item, itemCtx, () => comment2 = null, () => chompKeep = true);
|
|
1895
1895
|
if (comment2)
|
|
1896
1896
|
str3 += stringifyComment.lineComment(str3, itemIndent, commentString(comment2));
|
|
1897
1897
|
if (chompKeep && comment2)
|
|
@@ -1958,7 +1958,7 @@ ${indent}${line2}` : "\n";
|
|
|
1958
1958
|
}
|
|
1959
1959
|
if (comment)
|
|
1960
1960
|
reqNewline = true;
|
|
1961
|
-
let str2 =
|
|
1961
|
+
let str2 = stringify4.stringify(item, itemCtx, () => comment = null);
|
|
1962
1962
|
reqNewline || (reqNewline = lines.length > linesAtValue || str2.includes("\n"));
|
|
1963
1963
|
if (i < items.length - 1) {
|
|
1964
1964
|
str2 += ",";
|
|
@@ -3319,7 +3319,7 @@ var require_stringifyDocument = __commonJS({
|
|
|
3319
3319
|
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/stringify/stringifyDocument.js"(exports2) {
|
|
3320
3320
|
"use strict";
|
|
3321
3321
|
var identity = require_identity();
|
|
3322
|
-
var
|
|
3322
|
+
var stringify4 = require_stringify();
|
|
3323
3323
|
var stringifyComment = require_stringifyComment();
|
|
3324
3324
|
function stringifyDocument(doc, options) {
|
|
3325
3325
|
const lines = [];
|
|
@@ -3334,7 +3334,7 @@ var require_stringifyDocument = __commonJS({
|
|
|
3334
3334
|
}
|
|
3335
3335
|
if (hasDirectives)
|
|
3336
3336
|
lines.push("---");
|
|
3337
|
-
const ctx =
|
|
3337
|
+
const ctx = stringify4.createStringifyContext(doc, options);
|
|
3338
3338
|
const { commentString } = ctx.options;
|
|
3339
3339
|
if (doc.commentBefore) {
|
|
3340
3340
|
if (lines.length !== 1)
|
|
@@ -3356,7 +3356,7 @@ var require_stringifyDocument = __commonJS({
|
|
|
3356
3356
|
contentComment = doc.contents.comment;
|
|
3357
3357
|
}
|
|
3358
3358
|
const onChompKeep = contentComment ? void 0 : () => chompKeep = true;
|
|
3359
|
-
let body =
|
|
3359
|
+
let body = stringify4.stringify(doc.contents, ctx, () => contentComment = null, onChompKeep);
|
|
3360
3360
|
if (contentComment)
|
|
3361
3361
|
body += stringifyComment.lineComment(body, "", commentString(contentComment));
|
|
3362
3362
|
if ((body[0] === "|" || body[0] === ">") && lines[lines.length - 1] === "---") {
|
|
@@ -3364,7 +3364,7 @@ var require_stringifyDocument = __commonJS({
|
|
|
3364
3364
|
} else
|
|
3365
3365
|
lines.push(body);
|
|
3366
3366
|
} else {
|
|
3367
|
-
lines.push(
|
|
3367
|
+
lines.push(stringify4.stringify(doc.contents, ctx));
|
|
3368
3368
|
}
|
|
3369
3369
|
if (doc.directives?.docEnd) {
|
|
3370
3370
|
if (doc.comment) {
|
|
@@ -5500,7 +5500,7 @@ var require_cst_scalar = __commonJS({
|
|
|
5500
5500
|
var require_cst_stringify = __commonJS({
|
|
5501
5501
|
"../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/parse/cst-stringify.js"(exports2) {
|
|
5502
5502
|
"use strict";
|
|
5503
|
-
var
|
|
5503
|
+
var stringify4 = (cst) => "type" in cst ? stringifyToken(cst) : stringifyItem(cst);
|
|
5504
5504
|
function stringifyToken(token) {
|
|
5505
5505
|
switch (token.type) {
|
|
5506
5506
|
case "block-scalar": {
|
|
@@ -5553,7 +5553,7 @@ var require_cst_stringify = __commonJS({
|
|
|
5553
5553
|
res += stringifyToken(value);
|
|
5554
5554
|
return res;
|
|
5555
5555
|
}
|
|
5556
|
-
exports2.stringify =
|
|
5556
|
+
exports2.stringify = stringify4;
|
|
5557
5557
|
}
|
|
5558
5558
|
});
|
|
5559
5559
|
|
|
@@ -7283,7 +7283,7 @@ var require_public_api = __commonJS({
|
|
|
7283
7283
|
}
|
|
7284
7284
|
return doc.toJS(Object.assign({ reviver: _reviver }, options));
|
|
7285
7285
|
}
|
|
7286
|
-
function
|
|
7286
|
+
function stringify4(value, replacer, options) {
|
|
7287
7287
|
let _replacer = null;
|
|
7288
7288
|
if (typeof replacer === "function" || Array.isArray(replacer)) {
|
|
7289
7289
|
_replacer = replacer;
|
|
@@ -7308,7 +7308,7 @@ var require_public_api = __commonJS({
|
|
|
7308
7308
|
exports2.parse = parse6;
|
|
7309
7309
|
exports2.parseAllDocuments = parseAllDocuments;
|
|
7310
7310
|
exports2.parseDocument = parseDocument3;
|
|
7311
|
-
exports2.stringify =
|
|
7311
|
+
exports2.stringify = stringify4;
|
|
7312
7312
|
}
|
|
7313
7313
|
});
|
|
7314
7314
|
|
|
@@ -7365,17 +7365,17 @@ var require_dist = __commonJS({
|
|
|
7365
7365
|
});
|
|
7366
7366
|
|
|
7367
7367
|
// src/cli.ts
|
|
7368
|
-
var
|
|
7368
|
+
var import_node_path21 = require("node:path");
|
|
7369
7369
|
|
|
7370
7370
|
// src/cli/main.ts
|
|
7371
7371
|
var import_node_crypto10 = require("node:crypto");
|
|
7372
|
-
var
|
|
7372
|
+
var import_node_path20 = require("node:path");
|
|
7373
7373
|
var import_promises5 = require("node:readline/promises");
|
|
7374
7374
|
|
|
7375
7375
|
// package.json
|
|
7376
7376
|
var package_default = {
|
|
7377
7377
|
name: "@devtune/agentpicks",
|
|
7378
|
-
version: "0.4.
|
|
7378
|
+
version: "0.4.8",
|
|
7379
7379
|
description: "The open Agent Picks runner: the agentpicks CLI, which tests the coding agents installed on your machine in fresh Docker containers, and the sandbox code DevTune runs its managed tests on",
|
|
7380
7380
|
license: "Apache-2.0",
|
|
7381
7381
|
engines: {
|
|
@@ -8764,6 +8764,11 @@ function environmentRunsIn(slug2, categorySlug) {
|
|
|
8764
8764
|
if (categorySlug.startsWith("job-")) return false;
|
|
8765
8765
|
return !environment.categories || environment.categories.includes(categorySlug);
|
|
8766
8766
|
}
|
|
8767
|
+
function setupEnvironments(runsIn) {
|
|
8768
|
+
return ENVIRONMENTS.filter(
|
|
8769
|
+
(env) => !isRetiredEnvironment(env.slug) && environmentRunsIn(env.slug, runsIn)
|
|
8770
|
+
);
|
|
8771
|
+
}
|
|
8767
8772
|
|
|
8768
8773
|
// src/catalogue/prompt-intents.ts
|
|
8769
8774
|
var PROMPT_INTENTS = [
|
|
@@ -28847,9 +28852,7 @@ function editedReason(category, file2, entries2, added) {
|
|
|
28847
28852
|
return null;
|
|
28848
28853
|
}
|
|
28849
28854
|
function stackChoices(runsIn) {
|
|
28850
|
-
return
|
|
28851
|
-
(env) => !isRetiredEnvironment(env.slug) && environmentRunsIn(env.slug, runsIn)
|
|
28852
|
-
).map((env) => env.slug).join(", ");
|
|
28855
|
+
return setupEnvironments(runsIn).map((env) => env.slug).join(", ");
|
|
28853
28856
|
}
|
|
28854
28857
|
var escapeEre = (text3) => text3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
28855
28858
|
function watchedPackage(name) {
|
|
@@ -28872,10 +28875,10 @@ function mergeEarlyStop(base, entries2, listedKeys) {
|
|
|
28872
28875
|
const configNames = unique(
|
|
28873
28876
|
stopping.flatMap((tool) => tool.signals.configNames ?? [])
|
|
28874
28877
|
).map(escapeEre);
|
|
28875
|
-
const
|
|
28878
|
+
const join17 = (inherited, added) => [inherited, ...added].filter(Boolean).join("|") || NEVER_PATTERN;
|
|
28876
28879
|
return {
|
|
28877
|
-
installPattern:
|
|
28878
|
-
codePattern:
|
|
28880
|
+
installPattern: join17(base?.installPattern, packages),
|
|
28881
|
+
codePattern: join17(base?.codePattern, configNames),
|
|
28879
28882
|
...base?.pathPattern ? { pathPattern: base.pathPattern } : {}
|
|
28880
28883
|
};
|
|
28881
28884
|
}
|
|
@@ -78280,10 +78283,10 @@ function readRunOptions(argv) {
|
|
|
78280
78283
|
})
|
|
78281
78284
|
);
|
|
78282
78285
|
}
|
|
78283
|
-
function categoryArgs(values,
|
|
78286
|
+
function categoryArgs(values, hint2 = "") {
|
|
78284
78287
|
if (!values.category)
|
|
78285
78288
|
throw new UnknownCategoryError(
|
|
78286
|
-
`Choose a category with --category: ${categoryList()}.${
|
|
78289
|
+
`Choose a category with --category: ${categoryList()}.${hint2}`
|
|
78287
78290
|
);
|
|
78288
78291
|
if (values.stack !== void 0 && values.repo !== void 0)
|
|
78289
78292
|
throw new UsageError(
|
|
@@ -78513,6 +78516,73 @@ function stackList(categorySlug) {
|
|
|
78513
78516
|
).map((env) => env.slug).join(", ");
|
|
78514
78517
|
}
|
|
78515
78518
|
|
|
78519
|
+
// src/cli/catalogue-command.ts
|
|
78520
|
+
var import_node_util2 = require("node:util");
|
|
78521
|
+
function catalogueCommand(argv, ctx) {
|
|
78522
|
+
const { json: json3, slug: slug2 } = parseCatalogueArgs(argv);
|
|
78523
|
+
const pairs = (items) => items.map(({ slug: slug3, name }) => ({ slug: slug3, name }));
|
|
78524
|
+
if (slug2 === null) {
|
|
78525
|
+
const categories = pairs(CATEGORY_REQUESTS);
|
|
78526
|
+
const stacks2 = pairs(setupEnvironments("job-"));
|
|
78527
|
+
if (json3) ctx.out(JSON.stringify({ categories, stacks: stacks2 }, null, 2));
|
|
78528
|
+
else
|
|
78529
|
+
for (const line2 of [
|
|
78530
|
+
"Categories:",
|
|
78531
|
+
...columns(categories),
|
|
78532
|
+
"",
|
|
78533
|
+
"Stacks a job line can run in:",
|
|
78534
|
+
...columns(stacks2)
|
|
78535
|
+
])
|
|
78536
|
+
ctx.out(line2);
|
|
78537
|
+
return 0;
|
|
78538
|
+
}
|
|
78539
|
+
const found = findCategoryRequests(slug2);
|
|
78540
|
+
if (!found)
|
|
78541
|
+
throw new UsageError(
|
|
78542
|
+
`There is no category ${slug2}. List them with: agentpicks catalogue`
|
|
78543
|
+
);
|
|
78544
|
+
const category = { slug: found.slug, name: found.name };
|
|
78545
|
+
const tools = CATEGORY_TOOLS[found.slug] ?? [];
|
|
78546
|
+
const stacks = pairs(setupEnvironments(found.slug));
|
|
78547
|
+
if (json3) ctx.out(JSON.stringify({ category, tools, stacks }, null, 2));
|
|
78548
|
+
else
|
|
78549
|
+
for (const line2 of [
|
|
78550
|
+
...columns([category]),
|
|
78551
|
+
"",
|
|
78552
|
+
"Tools:",
|
|
78553
|
+
...tools.map((key) => ` ${key}`),
|
|
78554
|
+
"",
|
|
78555
|
+
"Stacks:",
|
|
78556
|
+
...columns(stacks)
|
|
78557
|
+
])
|
|
78558
|
+
ctx.out(line2);
|
|
78559
|
+
return 0;
|
|
78560
|
+
}
|
|
78561
|
+
function columns(items) {
|
|
78562
|
+
const width = Math.max(...items.map((item) => item.slug.length));
|
|
78563
|
+
return items.map((item) => ` ${item.slug.padEnd(width)} ${item.name}`);
|
|
78564
|
+
}
|
|
78565
|
+
function parseCatalogueArgs(argv) {
|
|
78566
|
+
let parsed2;
|
|
78567
|
+
try {
|
|
78568
|
+
parsed2 = (0, import_node_util2.parseArgs)({
|
|
78569
|
+
args: argv,
|
|
78570
|
+
strict: true,
|
|
78571
|
+
allowPositionals: true,
|
|
78572
|
+
options: { json: { type: "boolean", default: false } }
|
|
78573
|
+
});
|
|
78574
|
+
} catch (error62) {
|
|
78575
|
+
throw new UsageError(
|
|
78576
|
+
error62 instanceof Error ? error62.message : String(error62)
|
|
78577
|
+
);
|
|
78578
|
+
}
|
|
78579
|
+
if (parsed2.positionals.length > 1)
|
|
78580
|
+
throw new UsageError(
|
|
78581
|
+
"Name one category, or none to list them: agentpicks catalogue [<category>] [--json]"
|
|
78582
|
+
);
|
|
78583
|
+
return { json: parsed2.values.json, slug: parsed2.positionals[0] ?? null };
|
|
78584
|
+
}
|
|
78585
|
+
|
|
78516
78586
|
// src/setup/link.ts
|
|
78517
78587
|
var import_yaml2 = __toESM(require_dist());
|
|
78518
78588
|
function syncState(file2, setup) {
|
|
@@ -80356,7 +80426,7 @@ var messages = {
|
|
|
80356
80426
|
}
|
|
80357
80427
|
};
|
|
80358
80428
|
function loginPage(state) {
|
|
80359
|
-
const { heading, message, hint } = messages[state];
|
|
80429
|
+
const { heading, message, hint: hint2 } = messages[state];
|
|
80360
80430
|
return `<!doctype html>
|
|
80361
80431
|
<html lang="en">
|
|
80362
80432
|
<head>
|
|
@@ -80370,7 +80440,7 @@ function loginPage(state) {
|
|
|
80370
80440
|
<main>
|
|
80371
80441
|
<h1>${heading}</h1>
|
|
80372
80442
|
<p>${message}</p>
|
|
80373
|
-
<p class="hint">${
|
|
80443
|
+
<p class="hint">${hint2}</p>
|
|
80374
80444
|
</main>
|
|
80375
80445
|
</body>
|
|
80376
80446
|
</html>`;
|
|
@@ -81512,15 +81582,17 @@ async function ensureSandboxImage({
|
|
|
81512
81582
|
build = dockerBuild
|
|
81513
81583
|
}) {
|
|
81514
81584
|
const tag = sandboxImageTag(version2);
|
|
81515
|
-
const
|
|
81516
|
-
|
|
81517
|
-
|
|
81518
|
-
|
|
81519
|
-
|
|
81520
|
-
|
|
81521
|
-
|
|
81522
|
-
|
|
81523
|
-
return
|
|
81585
|
+
const present = async () => {
|
|
81586
|
+
const inspect = await run([
|
|
81587
|
+
"image",
|
|
81588
|
+
"inspect",
|
|
81589
|
+
"--format",
|
|
81590
|
+
"{{.Os}}/{{.Architecture}}",
|
|
81591
|
+
tag
|
|
81592
|
+
]);
|
|
81593
|
+
return inspect.exitCode === 0 && inspect.stdout.trim() === platform;
|
|
81594
|
+
};
|
|
81595
|
+
if (await present()) return { tag, built: false, removed: [] };
|
|
81524
81596
|
const code = await build([
|
|
81525
81597
|
"build",
|
|
81526
81598
|
"--platform",
|
|
@@ -81537,6 +81609,10 @@ async function ensureSandboxImage({
|
|
|
81537
81609
|
throw new Error(
|
|
81538
81610
|
`Building the sandbox image ${tag} failed (docker build exit ${code}); Docker's output is above.`
|
|
81539
81611
|
);
|
|
81612
|
+
if (!await present())
|
|
81613
|
+
throw new Error(
|
|
81614
|
+
`docker build finished, but this machine's Docker has no ${tag} for ${platform}, so no run can start. The build went to a builder that keeps its images elsewhere, such as Depot after depot configure-docker. Run depot configure-docker --uninstall, or docker buildx use default, then run agentpicks again.`
|
|
81615
|
+
);
|
|
81540
81616
|
return { tag, built: true, removed: await removeOlderImages(tag, run) };
|
|
81541
81617
|
}
|
|
81542
81618
|
async function removeOlderImages(keep, run = docker) {
|
|
@@ -81579,7 +81655,6 @@ async function labelledImages(run) {
|
|
|
81579
81655
|
const r = await run([
|
|
81580
81656
|
"image",
|
|
81581
81657
|
"ls",
|
|
81582
|
-
"--all",
|
|
81583
81658
|
"--no-trunc",
|
|
81584
81659
|
"--filter",
|
|
81585
81660
|
`label=${DOCKER_SANDBOX_LABEL}`,
|
|
@@ -81626,9 +81701,9 @@ function dockerBuild(args) {
|
|
|
81626
81701
|
|
|
81627
81702
|
// src/cli/init.ts
|
|
81628
81703
|
var import_node_fs8 = require("node:fs");
|
|
81629
|
-
var
|
|
81630
|
-
var
|
|
81631
|
-
var
|
|
81704
|
+
var import_node_path14 = require("node:path");
|
|
81705
|
+
var import_node_util3 = require("node:util");
|
|
81706
|
+
var import_yaml6 = __toESM(require_dist());
|
|
81632
81707
|
|
|
81633
81708
|
// src/cli/init-detect.ts
|
|
81634
81709
|
var import_node_fs7 = require("node:fs");
|
|
@@ -81893,199 +81968,98 @@ function setupSignals(drafted) {
|
|
|
81893
81968
|
return Object.keys(packages).length > 0 || signals.configNames ? parsed2.data : null;
|
|
81894
81969
|
}
|
|
81895
81970
|
|
|
81896
|
-
// src/cli/init.ts
|
|
81897
|
-
|
|
81898
|
-
|
|
81899
|
-
|
|
81971
|
+
// src/cli/init-job-line.ts
|
|
81972
|
+
var import_node_path13 = require("node:path");
|
|
81973
|
+
var import_yaml5 = __toESM(require_dist());
|
|
81974
|
+
|
|
81975
|
+
// src/cli/init-wizard.ts
|
|
81976
|
+
function readGiven(question) {
|
|
81977
|
+
if (question.keys)
|
|
81978
|
+
refuseListNumbers(question.flag, question.given, question.keys);
|
|
81979
|
+
const read = question.read(question.given.trim(), true);
|
|
81980
|
+
if ("problem" in read)
|
|
81900
81981
|
throw new UsageError(
|
|
81901
|
-
|
|
81902
|
-
);
|
|
81903
|
-
const wizard = {
|
|
81904
|
-
yes,
|
|
81905
|
-
ask: ctx.ask,
|
|
81906
|
-
out: ctx.out,
|
|
81907
|
-
err: ctx.err,
|
|
81908
|
-
detected: detectRepository(ctx.cwd, ctx.io),
|
|
81909
|
-
drafting: null
|
|
81910
|
-
};
|
|
81911
|
-
if (!yes) ctx.out("Press Enter to take the default in brackets.");
|
|
81912
|
-
const job = await askJob(wizard);
|
|
81913
|
-
let file2;
|
|
81914
|
-
if ("category" in job) file2 = await askCategoryTools(wizard, job.category);
|
|
81915
|
-
else {
|
|
81916
|
-
wizard.drafting = devtuneDrafting(ctx.io, ctx.err);
|
|
81917
|
-
file2 = await askCustomJob(wizard, job.line);
|
|
81918
|
-
}
|
|
81919
|
-
Object.assign(file2, await askTests(wizard, file2.from));
|
|
81920
|
-
const agents = await askAgents(wizard);
|
|
81921
|
-
if (agents) file2.agents = agents;
|
|
81922
|
-
const runs = await ask(wizard, {
|
|
81923
|
-
label: "Runs per agent and stack",
|
|
81924
|
-
fallback: "1",
|
|
81925
|
-
read: (answer) => /^[1-9]\d*$/.test(answer) && Number(answer) <= 100 ? { value: Number(answer) } : { problem: "Give a whole number of runs, 1 to 100." }
|
|
81926
|
-
});
|
|
81927
|
-
if (runs !== 1) file2.runs = runs;
|
|
81928
|
-
const dir = (0, import_node_path13.join)(wizard.detected.root, SETUPS_DIR);
|
|
81929
|
-
const text3 = `${SCHEMA_LINE}
|
|
81930
|
-
${(0, import_yaml5.stringify)(file2)}`;
|
|
81931
|
-
const name = await ask(wizard, {
|
|
81932
|
-
label: "Name",
|
|
81933
|
-
fallback: file2.from ?? slug(file2.job),
|
|
81934
|
-
read: (answer) => {
|
|
81935
|
-
if (!/^[a-z0-9][a-z0-9-]{0,62}$/.test(answer))
|
|
81936
|
-
return {
|
|
81937
|
-
problem: "A name is lowercase letters, digits and hyphens, such as error-tracking."
|
|
81938
|
-
};
|
|
81939
|
-
const path2 = setupPath(dir, answer);
|
|
81940
|
-
if ((0, import_node_fs8.existsSync)(path2) && !force)
|
|
81941
|
-
return {
|
|
81942
|
-
problem: `${(0, import_node_path13.relative)(ctx.cwd, path2)} exists. Choose another name, or pass --force to replace it.`
|
|
81943
|
-
};
|
|
81944
|
-
const checked = checkSetupText(path2, text3);
|
|
81945
|
-
return checked.problems.length > 0 ? {
|
|
81946
|
-
problem: checked.problems.map((p) => `${p.field}: ${p.message}`).join("\n")
|
|
81947
|
-
} : { value: answer };
|
|
81948
|
-
}
|
|
81949
|
-
});
|
|
81950
|
-
const path = setupPath(dir, name);
|
|
81951
|
-
writeSetup(dir, path, text3, force, ctx.cwd);
|
|
81952
|
-
const shown3 = (0, import_node_path13.relative)(ctx.cwd, path) || path;
|
|
81953
|
-
ctx.out("");
|
|
81954
|
-
ctx.out(`Wrote ${shown3}:`);
|
|
81955
|
-
ctx.out("");
|
|
81956
|
-
for (const line2 of text3.trimEnd().split("\n").slice(1)) ctx.out(` ${line2}`);
|
|
81957
|
-
ctx.out("");
|
|
81958
|
-
if (!file2.agents)
|
|
81959
|
-
ctx.out(
|
|
81960
|
-
"It names no agents, so run uses the one agent installed where it runs."
|
|
81961
|
-
);
|
|
81962
|
-
const custom2 = checkSetupText(path, text3).setup.customReason !== null;
|
|
81963
|
-
if (ctx.io.env.AGENTPICKS_NO_UPLOAD)
|
|
81964
|
-
ctx.out(`Run it with: agentpicks run ${name}`);
|
|
81965
|
-
else if (!signedIn(ctx.io)) {
|
|
81966
|
-
ctx.out(`Run it with: agentpicks run ${name} --no-upload`);
|
|
81967
|
-
ctx.out(
|
|
81968
|
-
`That needs no DevTune account. To upload its runs to DevTune, sign in with agentpicks login${custom2 ? `, then run agentpicks push ${name}` : ""}.`
|
|
81969
|
-
);
|
|
81970
|
-
} else
|
|
81971
|
-
ctx.out(
|
|
81972
|
-
custom2 ? `To upload its runs, first run: agentpicks push ${name}, then agentpicks run ${name}. To keep bundles on this machine only, run: agentpicks run ${name} --no-upload.` : `Run it with: agentpicks run ${name}`
|
|
81982
|
+
`${question.flag}: ${read.problem}${question.keys ? ` List the keys with: ${question.keys}` : ""}`
|
|
81973
81983
|
);
|
|
81974
|
-
return
|
|
81975
|
-
}
|
|
81976
|
-
function signedIn(io) {
|
|
81977
|
-
try {
|
|
81978
|
-
devtuneTarget(io);
|
|
81979
|
-
return true;
|
|
81980
|
-
} catch {
|
|
81981
|
-
return false;
|
|
81982
|
-
}
|
|
81984
|
+
return read.value;
|
|
81983
81985
|
}
|
|
81984
|
-
function
|
|
81985
|
-
|
|
81986
|
-
|
|
81987
|
-
args: argv,
|
|
81988
|
-
strict: true,
|
|
81989
|
-
allowPositionals: false,
|
|
81990
|
-
options: {
|
|
81991
|
-
yes: { type: "boolean", short: "y", default: false },
|
|
81992
|
-
force: { type: "boolean", default: false }
|
|
81993
|
-
}
|
|
81994
|
-
});
|
|
81995
|
-
return { yes: values.yes, force: values.force };
|
|
81996
|
-
} catch (error62) {
|
|
81986
|
+
function refuseListNumbers(flag, value, keys) {
|
|
81987
|
+
const number4 = entries(value).find((entry) => /^\d+(-\d+)?$/.test(entry));
|
|
81988
|
+
if (number4 !== void 0)
|
|
81997
81989
|
throw new UsageError(
|
|
81998
|
-
|
|
81990
|
+
`${flag} takes keys, not list numbers such as ${number4}. Give them from: ${keys}`
|
|
81999
81991
|
);
|
|
82000
|
-
}
|
|
82001
81992
|
}
|
|
82002
81993
|
async function ask(wizard, question) {
|
|
81994
|
+
if (question.given !== void 0)
|
|
81995
|
+
return readGiven({ ...question, given: question.given });
|
|
82003
81996
|
if (wizard.yes) {
|
|
82004
81997
|
if (question.fallback === null)
|
|
82005
81998
|
throw new UsageError(
|
|
82006
81999
|
`agentpicks init --yes ${question.missing ?? `has no default for ${question.label.toLowerCase()}. Run agentpicks init on a terminal to answer it.`}`
|
|
82007
82000
|
);
|
|
82008
|
-
const read = question.read(question.fallback);
|
|
82001
|
+
const read = question.read(question.fallback, false);
|
|
82009
82002
|
if ("problem" in read) throw new UsageError(read.problem);
|
|
82010
82003
|
return read.value;
|
|
82011
82004
|
}
|
|
82005
|
+
if (!wizard.interactive) {
|
|
82006
|
+
const asked = `agentpicks init can't ask "${question.label}" without a terminal`;
|
|
82007
|
+
if (question.fallback !== null)
|
|
82008
|
+
throw new UsageError(
|
|
82009
|
+
`${asked}. Pass ${question.flag ? `${question.flag}, or --yes` : "--yes"} to take its default.`
|
|
82010
|
+
);
|
|
82011
|
+
throw new UsageError(
|
|
82012
|
+
`${asked}, and ${question.missing ?? "it has no default. Answer it on a terminal."}${question.flag ? ` Or pass ${question.flag}.` : ""}`
|
|
82013
|
+
);
|
|
82014
|
+
}
|
|
82015
|
+
hint(wizard);
|
|
82012
82016
|
for (; ; ) {
|
|
82013
82017
|
const shown3 = question.fallback === null ? "" : ` [${question.fallback}]`;
|
|
82014
82018
|
const answer = (await wizard.ask(`${question.label}${shown3}: `)).trim() || question.fallback || "";
|
|
82015
|
-
const read = question.read(answer);
|
|
82019
|
+
const read = question.read(answer, false);
|
|
82016
82020
|
if ("value" in read) return read.value;
|
|
82017
82021
|
wizard.err(read.problem);
|
|
82018
82022
|
}
|
|
82019
82023
|
}
|
|
82024
|
+
function hint(wizard) {
|
|
82025
|
+
if (wizard.hinted) return;
|
|
82026
|
+
wizard.out("Press Enter to take the default in brackets.");
|
|
82027
|
+
wizard.hinted = true;
|
|
82028
|
+
}
|
|
82029
|
+
function showNumbered(wizard, given, title, items, columns2 = items.length > 10 ? 3 : 1) {
|
|
82030
|
+
if (wizard.yes || !wizard.interactive || given !== void 0) return;
|
|
82031
|
+
hint(wizard);
|
|
82032
|
+
wizard.out(title);
|
|
82033
|
+
const rows = Math.ceil(items.length / columns2);
|
|
82034
|
+
const width = Math.max(...items.map((item) => item.length));
|
|
82035
|
+
for (let row = 0; row < rows; row++) {
|
|
82036
|
+
const cells = [];
|
|
82037
|
+
for (let column = 0; column < columns2; column++) {
|
|
82038
|
+
const i = column * rows + row;
|
|
82039
|
+
const item = items[i];
|
|
82040
|
+
if (item !== void 0)
|
|
82041
|
+
cells.push(`${String(i + 1).padStart(2)} ${item.padEnd(width)}`);
|
|
82042
|
+
}
|
|
82043
|
+
wizard.out(` ${cells.join(" ").trimEnd()}`);
|
|
82044
|
+
}
|
|
82045
|
+
}
|
|
82046
|
+
var pickKey = (answer, keys) => /^\d+$/.test(answer) ? keys[Number(answer) - 1] ?? null : keys.includes(answer) ? answer : null;
|
|
82020
82047
|
var entries = (answer) => answer.split(",").map((entry) => entry.trim()).filter(Boolean);
|
|
82048
|
+
var withRanges = (answer, count) => entries(answer).flatMap((entry) => {
|
|
82049
|
+
const range = /^(\d+)-(\d+)$/.exec(entry);
|
|
82050
|
+
if (!range) return [entry];
|
|
82051
|
+
const [from, to] = [Number(range[1]), Number(range[2])];
|
|
82052
|
+
return from >= 1 && from <= to && to <= count ? Array.from({ length: to - from + 1 }, (_, i) => String(from + i)) : [entry];
|
|
82053
|
+
});
|
|
82021
82054
|
var badLength = (text3) => {
|
|
82022
82055
|
const problem = requestTextProblem(text3);
|
|
82023
82056
|
return problem === "too_short" || problem === "too_long";
|
|
82024
82057
|
};
|
|
82025
|
-
|
|
82026
|
-
|
|
82027
|
-
const index = CATEGORY_REQUESTS.findIndex((c) => c.slug === detected);
|
|
82028
|
-
if (!wizard.yes) {
|
|
82029
|
-
wizard.out("Categories:");
|
|
82030
|
-
CATEGORY_REQUESTS.forEach(
|
|
82031
|
-
(category, i) => wizard.out(` ${String(i + 1).padStart(2)} ${category.name}`)
|
|
82032
|
-
);
|
|
82033
|
-
}
|
|
82034
|
-
return ask(wizard, {
|
|
82035
|
-
label: "Job: a category number, or your own job line",
|
|
82036
|
-
fallback: index >= 0 ? String(index + 1) : null,
|
|
82037
|
-
missing: "can't choose a job: neither package.json nor the git remote names a catalogue tool. Run agentpicks init on a terminal to choose one.",
|
|
82038
|
-
read: (answer) => {
|
|
82039
|
-
const count = CATEGORY_REQUESTS.length;
|
|
82040
|
-
if (/^\d+$/.test(answer)) {
|
|
82041
|
-
const category2 = CATEGORY_REQUESTS[Number(answer) - 1];
|
|
82042
|
-
return category2 ? { value: { category: category2.slug } } : {
|
|
82043
|
-
problem: `Choose a category from 1 to ${count}, or write a job line.`
|
|
82044
|
-
};
|
|
82045
|
-
}
|
|
82046
|
-
const category = findCategoryRequests(answer);
|
|
82047
|
-
if (category) return { value: { category: category.slug } };
|
|
82048
|
-
if (!/\s/.test(answer) || // A new job line meets a request's length; the guard is resolveSetup's, which names the field.
|
|
82049
|
-
badLength(answer))
|
|
82050
|
-
return {
|
|
82051
|
-
problem: `Choose a category from 1 to ${count}, or write the job as a line of ${SETUP_REQUEST_MIN_LENGTH} to ${SETUP_TEXT_MAX_LENGTH} characters, such as Add feature flags.`
|
|
82052
|
-
};
|
|
82053
|
-
return { value: { line: answer } };
|
|
82054
|
-
}
|
|
82055
|
-
});
|
|
82056
|
-
}
|
|
82057
|
-
async function askCategoryTools(wizard, category) {
|
|
82058
|
-
const keys = CATEGORY_TOOLS[category] ?? [];
|
|
82059
|
-
const detected = wizard.detected.tool?.key;
|
|
82060
|
-
const own2 = await ask(wizard, {
|
|
82061
|
-
label: `Your tool: a ${category} tool key, or none`,
|
|
82062
|
-
fallback: detected && keys.includes(detected) ? detected : "none",
|
|
82063
|
-
read: (answer) => answer === "none" ? { value: null } : keys.includes(answer) ? { value: answer } : {
|
|
82064
|
-
problem: `${category} has no tool ${answer}. Use one of ${keys.join(", ")}, or none.`
|
|
82065
|
-
}
|
|
82066
|
-
});
|
|
82067
|
-
const competitors = await ask(wizard, {
|
|
82068
|
-
label: `Competitors: ${category} tool keys separated by commas, or all`,
|
|
82069
|
-
fallback: "all",
|
|
82070
|
-
read: (answer) => {
|
|
82071
|
-
if (answer === "all") return { value: null };
|
|
82072
|
-
const chosen = [...new Set(entries(answer))];
|
|
82073
|
-
const unknown2 = chosen.find((key) => !keys.includes(key) || key === own2);
|
|
82074
|
-
if (!unknown2 && chosen.length > SETUP_MAX_COMPETITORS)
|
|
82075
|
-
return {
|
|
82076
|
-
problem: `List at most ${SETUP_MAX_COMPETITORS} competitors, or all.`
|
|
82077
|
-
};
|
|
82078
|
-
return unknown2 ? {
|
|
82079
|
-
problem: unknown2 === own2 ? `${own2} is your tool. List only competitors.` : `${category} has no tool ${unknown2}. Use ${keys.join(", ")}, or all.`
|
|
82080
|
-
} : { value: chosen };
|
|
82081
|
-
}
|
|
82082
|
-
});
|
|
82083
|
-
const tools = {
|
|
82084
|
-
...own2 ? { own: own2 } : {},
|
|
82085
|
-
...competitors ? { competitors } : {}
|
|
82086
|
-
};
|
|
82087
|
-
return { from: category, ...own2 || competitors ? { tools } : {} };
|
|
82058
|
+
function slug(text3) {
|
|
82059
|
+
return text3.normalize("NFKD").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 63).replace(/-+$/, "") || "setup";
|
|
82088
82060
|
}
|
|
82061
|
+
|
|
82062
|
+
// src/cli/init-job-line.ts
|
|
82089
82063
|
var INTENTS = ["add", "recommend", "hosted"];
|
|
82090
82064
|
async function askCustomJob(wizard, line2) {
|
|
82091
82065
|
const drafted = await wizard.drafting?.job(line2) ?? null;
|
|
@@ -82113,8 +82087,15 @@ async function askCustomJob(wizard, line2) {
|
|
|
82113
82087
|
(0, import_yaml5.stringify)(file2)
|
|
82114
82088
|
);
|
|
82115
82089
|
if (checked.problems.length === 0) return file2;
|
|
82116
|
-
|
|
82117
|
-
|
|
82090
|
+
const problems = checked.problems.map(
|
|
82091
|
+
(problem) => `${problem.field}: ${problem.message}`
|
|
82092
|
+
);
|
|
82093
|
+
if (wizard.yes)
|
|
82094
|
+
throw new UsageError(
|
|
82095
|
+
`${problems.join("\n")}
|
|
82096
|
+
Run agentpicks init on a terminal to answer the requests and tools, or write the setup against agentpicks schema.`
|
|
82097
|
+
);
|
|
82098
|
+
for (const problem of problems) wizard.err(problem);
|
|
82118
82099
|
wizard.err("Answer the requests and tools again.");
|
|
82119
82100
|
}
|
|
82120
82101
|
}
|
|
@@ -82216,33 +82197,348 @@ async function toolWithSignals(wizard, tool, job, others, toolDrafts, detected)
|
|
|
82216
82197
|
signals: { packages: { npm: packages } }
|
|
82217
82198
|
};
|
|
82218
82199
|
}
|
|
82200
|
+
|
|
82201
|
+
// src/cli/init.ts
|
|
82202
|
+
async function initCommand(argv, ctx) {
|
|
82203
|
+
const flags = parseInitArgs(argv);
|
|
82204
|
+
const { yes, force } = flags;
|
|
82205
|
+
const wizard = {
|
|
82206
|
+
yes,
|
|
82207
|
+
interactive: Boolean(ctx.interactive),
|
|
82208
|
+
flags,
|
|
82209
|
+
cwd: ctx.cwd,
|
|
82210
|
+
ask: ctx.ask,
|
|
82211
|
+
out: ctx.out,
|
|
82212
|
+
err: ctx.err,
|
|
82213
|
+
detected: detectRepository(ctx.cwd, ctx.io),
|
|
82214
|
+
drafting: null,
|
|
82215
|
+
hinted: false
|
|
82216
|
+
};
|
|
82217
|
+
checkFlags(wizard);
|
|
82218
|
+
const job = await askJob(wizard);
|
|
82219
|
+
let file2;
|
|
82220
|
+
if ("category" in job) file2 = await askCategoryTools(wizard, job.category);
|
|
82221
|
+
else if (flags.tool !== void 0 || flags.competitors !== void 0)
|
|
82222
|
+
throw new UsageError(
|
|
82223
|
+
`--${flags.tool !== void 0 ? "tool" : "competitors"} answers a category's questions, and ${job.line} is a job line. Pass --category, or leave it out.`
|
|
82224
|
+
);
|
|
82225
|
+
else if (!yes && !wizard.interactive)
|
|
82226
|
+
throw new UsageError(
|
|
82227
|
+
"agentpicks init can't ask a job line's requests and tools without a terminal, and they have no flags. Pass --yes to take DevTune's drafts, which needs a sign-in, or write the setup against agentpicks schema."
|
|
82228
|
+
);
|
|
82229
|
+
else {
|
|
82230
|
+
wizard.drafting = devtuneDrafting(ctx.io, ctx.err);
|
|
82231
|
+
file2 = await askCustomJob(wizard, job.line);
|
|
82232
|
+
}
|
|
82233
|
+
Object.assign(file2, await askTests(wizard, file2.from));
|
|
82234
|
+
const agents = await ask(wizard, agentsQuestion(wizard));
|
|
82235
|
+
if (agents) file2.agents = agents;
|
|
82236
|
+
const runs = await ask(wizard, runsQuestion(wizard));
|
|
82237
|
+
if (runs !== 1) file2.runs = runs;
|
|
82238
|
+
const dir = (0, import_node_path14.join)(wizard.detected.root, SETUPS_DIR);
|
|
82239
|
+
const text3 = `${SCHEMA_LINE}
|
|
82240
|
+
${(0, import_yaml6.stringify)(file2)}`;
|
|
82241
|
+
const name = await ask(
|
|
82242
|
+
wizard,
|
|
82243
|
+
nameQuestion(wizard, file2.from ?? slug(file2.job), (answer) => {
|
|
82244
|
+
const checked = checkSetupText(setupPath(dir, answer), text3);
|
|
82245
|
+
return checked.problems.length > 0 ? {
|
|
82246
|
+
problem: checked.problems.map((p) => `${p.field}: ${p.message}`).join("\n")
|
|
82247
|
+
} : { value: answer };
|
|
82248
|
+
})
|
|
82249
|
+
);
|
|
82250
|
+
const path = setupPath(dir, name);
|
|
82251
|
+
writeSetup(dir, path, text3, force, ctx.cwd);
|
|
82252
|
+
const shown3 = (0, import_node_path14.relative)(ctx.cwd, path) || path;
|
|
82253
|
+
ctx.out("");
|
|
82254
|
+
ctx.out(`Wrote ${shown3}:`);
|
|
82255
|
+
ctx.out("");
|
|
82256
|
+
for (const line2 of text3.trimEnd().split("\n").slice(1)) ctx.out(` ${line2}`);
|
|
82257
|
+
ctx.out("");
|
|
82258
|
+
if (file2.from)
|
|
82259
|
+
ctx.out(
|
|
82260
|
+
`To write the same setup in another repository: ${initAgain(file2, name)}`
|
|
82261
|
+
);
|
|
82262
|
+
if (!file2.agents)
|
|
82263
|
+
ctx.out(
|
|
82264
|
+
"It names no agents, so run uses the one agent installed where it runs."
|
|
82265
|
+
);
|
|
82266
|
+
const custom2 = checkSetupText(path, text3).setup.customReason !== null;
|
|
82267
|
+
if (ctx.io.env.AGENTPICKS_NO_UPLOAD)
|
|
82268
|
+
ctx.out(`Run it with: agentpicks run ${name}`);
|
|
82269
|
+
else if (!signedIn(ctx.io)) {
|
|
82270
|
+
ctx.out(`Run it with: agentpicks run ${name} --no-upload`);
|
|
82271
|
+
ctx.out(
|
|
82272
|
+
`That needs no DevTune account. To upload its runs to DevTune, sign in with agentpicks login${custom2 ? `, then run agentpicks push ${name}` : ""}.`
|
|
82273
|
+
);
|
|
82274
|
+
} else
|
|
82275
|
+
ctx.out(
|
|
82276
|
+
custom2 ? `To upload its runs, first run: agentpicks push ${name}, then agentpicks run ${name}. To keep bundles on this machine only, run: agentpicks run ${name} --no-upload.` : `Run it with: agentpicks run ${name}`
|
|
82277
|
+
);
|
|
82278
|
+
return 0;
|
|
82279
|
+
}
|
|
82280
|
+
function signedIn(io) {
|
|
82281
|
+
try {
|
|
82282
|
+
devtuneTarget(io);
|
|
82283
|
+
return true;
|
|
82284
|
+
} catch {
|
|
82285
|
+
return false;
|
|
82286
|
+
}
|
|
82287
|
+
}
|
|
82288
|
+
function initAgain(file2, name) {
|
|
82289
|
+
const { own: own2, competitors } = file2.tools ?? {};
|
|
82290
|
+
return [
|
|
82291
|
+
"agentpicks init",
|
|
82292
|
+
`--category ${file2.from}`,
|
|
82293
|
+
`--tool ${typeof own2 === "string" ? own2 : "none"}`,
|
|
82294
|
+
...competitors ? [`--competitors ${competitors.join(",")}`] : [],
|
|
82295
|
+
...file2.repo ? ["--repo ."] : (file2.stacks ?? []).map((stack) => `--stack ${stack}`),
|
|
82296
|
+
...(file2.agents ?? ["any"]).map((agent) => `--agent ${agent}`),
|
|
82297
|
+
...file2.runs ? [`--runs ${file2.runs}`] : [],
|
|
82298
|
+
`--name ${name}`,
|
|
82299
|
+
"--yes"
|
|
82300
|
+
].join(" ");
|
|
82301
|
+
}
|
|
82302
|
+
function parseInitArgs(argv) {
|
|
82303
|
+
let values;
|
|
82304
|
+
try {
|
|
82305
|
+
({ values } = (0, import_node_util3.parseArgs)({
|
|
82306
|
+
args: argv,
|
|
82307
|
+
strict: true,
|
|
82308
|
+
allowPositionals: false,
|
|
82309
|
+
options: {
|
|
82310
|
+
yes: { type: "boolean", short: "y", default: false },
|
|
82311
|
+
force: { type: "boolean", default: false },
|
|
82312
|
+
category: { type: "string" },
|
|
82313
|
+
job: { type: "string" },
|
|
82314
|
+
tool: { type: "string" },
|
|
82315
|
+
competitors: { type: "string" },
|
|
82316
|
+
repo: { type: "string" },
|
|
82317
|
+
stack: { type: "string", multiple: true, default: [] },
|
|
82318
|
+
agent: { type: "string", multiple: true, default: [] },
|
|
82319
|
+
runs: { type: "string" },
|
|
82320
|
+
name: { type: "string" }
|
|
82321
|
+
}
|
|
82322
|
+
}));
|
|
82323
|
+
} catch (error62) {
|
|
82324
|
+
throw new UsageError(
|
|
82325
|
+
error62 instanceof Error ? error62.message : String(error62)
|
|
82326
|
+
);
|
|
82327
|
+
}
|
|
82328
|
+
if (values.category !== void 0 && values.job !== void 0)
|
|
82329
|
+
throw new UsageError(
|
|
82330
|
+
"Pass --category or --job, not both: a setup tests a category or a job line of its own."
|
|
82331
|
+
);
|
|
82332
|
+
if (values.repo !== void 0 && values.stack.length > 0)
|
|
82333
|
+
throw new UsageError(
|
|
82334
|
+
"Pass --repo or --stack, not both: a setup tests this repository or stacks."
|
|
82335
|
+
);
|
|
82336
|
+
if (values.repo !== void 0 && values.repo !== ".")
|
|
82337
|
+
throw new UsageError(
|
|
82338
|
+
`--repo takes only . (this repository's committed files), not ${values.repo}.`
|
|
82339
|
+
);
|
|
82340
|
+
if (values.stack.some((stack) => entries(stack).includes(".")))
|
|
82341
|
+
throw new UsageError(
|
|
82342
|
+
"--stack takes stack slugs. To test this repository's committed files, pass --repo ."
|
|
82343
|
+
);
|
|
82344
|
+
return values;
|
|
82345
|
+
}
|
|
82346
|
+
function checkFlags(wizard) {
|
|
82347
|
+
const read = (question) => question.given === void 0 ? void 0 : readGiven({ ...question, given: question.given });
|
|
82348
|
+
const job = read(jobQuestion(wizard));
|
|
82349
|
+
const { tool, competitors, stack } = wizard.flags;
|
|
82350
|
+
if (job && "category" in job) {
|
|
82351
|
+
const own2 = read(toolQuestion(wizard, job.category));
|
|
82352
|
+
read(competitorsQuestion(wizard, job.category, own2 ?? null));
|
|
82353
|
+
} else
|
|
82354
|
+
for (const [flag, value] of [
|
|
82355
|
+
["--tool", tool],
|
|
82356
|
+
["--competitors", competitors]
|
|
82357
|
+
])
|
|
82358
|
+
if (value !== void 0)
|
|
82359
|
+
refuseListNumbers(flag, value, "agentpicks catalogue <category>");
|
|
82360
|
+
if (job && stack.length > 0)
|
|
82361
|
+
read(testsQuestion(wizard, "category" in job ? job.category : void 0));
|
|
82362
|
+
else if (stack.length > 0) {
|
|
82363
|
+
const given = stack.join(",");
|
|
82364
|
+
refuseListNumbers("--stack", given, "agentpicks catalogue");
|
|
82365
|
+
const unknown2 = entries(given).find(
|
|
82366
|
+
(slug2) => slug2 !== "all" && (!findEnvironment(slug2) || isRetiredEnvironment(slug2))
|
|
82367
|
+
);
|
|
82368
|
+
if (unknown2 !== void 0)
|
|
82369
|
+
throw new UsageError(
|
|
82370
|
+
`--stack: ${unknown2} isn't a stack. Give stack slugs, or all. List the keys with: agentpicks catalogue`
|
|
82371
|
+
);
|
|
82372
|
+
}
|
|
82373
|
+
read(agentsQuestion(wizard));
|
|
82374
|
+
read(runsQuestion(wizard));
|
|
82375
|
+
read(nameQuestion(wizard, null, (answer) => ({ value: answer })));
|
|
82376
|
+
}
|
|
82377
|
+
async function askJob(wizard) {
|
|
82378
|
+
const question = jobQuestion(wizard);
|
|
82379
|
+
showNumbered(
|
|
82380
|
+
wizard,
|
|
82381
|
+
question.given,
|
|
82382
|
+
"DevTune's public categories. Choose one to write a setup that runs its tests on this machine:",
|
|
82383
|
+
CATEGORY_REQUESTS.map((category) => category.name)
|
|
82384
|
+
);
|
|
82385
|
+
return ask(wizard, question);
|
|
82386
|
+
}
|
|
82387
|
+
function jobQuestion(wizard) {
|
|
82388
|
+
const detected = wizard.detected.tool?.categories[0];
|
|
82389
|
+
const index = CATEGORY_REQUESTS.findIndex((c) => c.slug === detected);
|
|
82390
|
+
const { category, job } = wizard.flags;
|
|
82391
|
+
return {
|
|
82392
|
+
label: "Category number, or your own job line",
|
|
82393
|
+
fallback: index >= 0 ? String(index + 1) : null,
|
|
82394
|
+
missing: "can't choose a job: neither package.json nor the git remote names a catalogue tool. Run agentpicks init on a terminal to choose one.",
|
|
82395
|
+
flag: category !== void 0 ? "--category" : job !== void 0 ? "--job" : "--category or --job",
|
|
82396
|
+
given: category ?? job,
|
|
82397
|
+
keys: category !== void 0 ? "agentpicks catalogue" : void 0,
|
|
82398
|
+
read: (answer, flag) => {
|
|
82399
|
+
const read = readJob(answer, flag);
|
|
82400
|
+
if (category !== void 0 && !("value" in read && "category" in read.value))
|
|
82401
|
+
return { problem: `There is no category ${answer}.` };
|
|
82402
|
+
if ("problem" in read) return read;
|
|
82403
|
+
if (job !== void 0 && "category" in read.value)
|
|
82404
|
+
return {
|
|
82405
|
+
problem: `${answer} names a category. Pass it as --category ${read.value.category}.`
|
|
82406
|
+
};
|
|
82407
|
+
return read;
|
|
82408
|
+
}
|
|
82409
|
+
};
|
|
82410
|
+
}
|
|
82411
|
+
function readJob(answer, flag) {
|
|
82412
|
+
const count = CATEGORY_REQUESTS.length;
|
|
82413
|
+
const line2 = `${flag ? "Write" : `Choose a category from 1 to ${count}, or write`} the job as a line of ${SETUP_REQUEST_MIN_LENGTH} to ${SETUP_TEXT_MAX_LENGTH} characters, such as Add feature flags.`;
|
|
82414
|
+
if (/^\d+$/.test(answer)) {
|
|
82415
|
+
const category2 = CATEGORY_REQUESTS[Number(answer) - 1];
|
|
82416
|
+
return category2 ? { value: { category: category2.slug } } : {
|
|
82417
|
+
problem: flag ? line2 : `Choose a category from 1 to ${count}, or write a job line.`
|
|
82418
|
+
};
|
|
82419
|
+
}
|
|
82420
|
+
const category = findCategoryRequests(answer);
|
|
82421
|
+
if (category) return { value: { category: category.slug } };
|
|
82422
|
+
if (!/\s/.test(answer) || // A new job line meets a request's length; the guard is resolveSetup's, which names the field.
|
|
82423
|
+
badLength(answer))
|
|
82424
|
+
return { problem: line2 };
|
|
82425
|
+
return { value: { line: answer } };
|
|
82426
|
+
}
|
|
82427
|
+
async function askCategoryTools(wizard, category) {
|
|
82428
|
+
const { tool, competitors: rivals } = wizard.flags;
|
|
82429
|
+
showNumbered(
|
|
82430
|
+
wizard,
|
|
82431
|
+
tool !== void 0 && rivals !== void 0 ? tool : void 0,
|
|
82432
|
+
`${findCategoryRequests(category)?.name ?? category} tools DevTune tests:`,
|
|
82433
|
+
CATEGORY_TOOLS[category] ?? []
|
|
82434
|
+
);
|
|
82435
|
+
const own2 = await ask(wizard, toolQuestion(wizard, category));
|
|
82436
|
+
const competitors = await ask(
|
|
82437
|
+
wizard,
|
|
82438
|
+
competitorsQuestion(wizard, category, own2)
|
|
82439
|
+
);
|
|
82440
|
+
const tools = {
|
|
82441
|
+
...own2 ? { own: own2 } : {},
|
|
82442
|
+
...competitors ? { competitors } : {}
|
|
82443
|
+
};
|
|
82444
|
+
return { from: category, ...own2 || competitors ? { tools } : {} };
|
|
82445
|
+
}
|
|
82446
|
+
function toolQuestion(wizard, category) {
|
|
82447
|
+
const keys = CATEGORY_TOOLS[category] ?? [];
|
|
82448
|
+
return {
|
|
82449
|
+
label: "Your tool: its number, or none",
|
|
82450
|
+
fallback: toolDefault(wizard, category),
|
|
82451
|
+
flag: "--tool",
|
|
82452
|
+
given: wizard.flags.tool,
|
|
82453
|
+
keys: `agentpicks catalogue ${category}`,
|
|
82454
|
+
read: (answer, flag) => {
|
|
82455
|
+
if (answer === "none") return { value: null };
|
|
82456
|
+
const key = pickKey(answer, keys);
|
|
82457
|
+
return key ? { value: key } : {
|
|
82458
|
+
problem: `${answer} isn't on the list. Give ${flag ? "a tool key" : `a number from 1 to ${keys.length}`}, or none.`
|
|
82459
|
+
};
|
|
82460
|
+
}
|
|
82461
|
+
};
|
|
82462
|
+
}
|
|
82463
|
+
function competitorsQuestion(wizard, category, own2) {
|
|
82464
|
+
const keys = CATEGORY_TOOLS[category] ?? [];
|
|
82465
|
+
return {
|
|
82466
|
+
label: "Competitors: their numbers or ranges separated by commas (2, 5-8), or all",
|
|
82467
|
+
fallback: "all",
|
|
82468
|
+
flag: "--competitors",
|
|
82469
|
+
given: wizard.flags.competitors,
|
|
82470
|
+
keys: `agentpicks catalogue ${category}`,
|
|
82471
|
+
read: (answer, flag) => {
|
|
82472
|
+
if (answer === "all") return { value: null };
|
|
82473
|
+
const give = `Give ${flag ? "tool keys" : `numbers from 1 to ${keys.length}`}, or all.`;
|
|
82474
|
+
const chosen = [];
|
|
82475
|
+
const given = withRanges(answer, keys.length);
|
|
82476
|
+
if (given.length === 0) return { problem: give };
|
|
82477
|
+
for (const entry of given) {
|
|
82478
|
+
const key = pickKey(entry, keys);
|
|
82479
|
+
if (!key) return { problem: `${entry} isn't on the list. ${give}` };
|
|
82480
|
+
if (key === own2)
|
|
82481
|
+
return {
|
|
82482
|
+
problem: wizard.yes && wizard.flags.tool === void 0 ? `${own2} is your tool, as this repository names it. Pass --tool none, or leave ${own2} out.` : `${own2} is your tool. List only competitors.`
|
|
82483
|
+
};
|
|
82484
|
+
if (!chosen.includes(key)) chosen.push(key);
|
|
82485
|
+
}
|
|
82486
|
+
return chosen.length > SETUP_MAX_COMPETITORS ? {
|
|
82487
|
+
problem: `List at most ${SETUP_MAX_COMPETITORS} competitors, or all.`
|
|
82488
|
+
} : { value: chosen };
|
|
82489
|
+
}
|
|
82490
|
+
};
|
|
82491
|
+
}
|
|
82492
|
+
function toolDefault(wizard, category) {
|
|
82493
|
+
const detected = wizard.detected.tool?.key;
|
|
82494
|
+
return detected && (CATEGORY_TOOLS[category] ?? []).includes(detected) ? detected : "none";
|
|
82495
|
+
}
|
|
82219
82496
|
async function askTests(wizard, from) {
|
|
82220
|
-
const
|
|
82221
|
-
|
|
82222
|
-
|
|
82223
|
-
|
|
82497
|
+
const question = testsQuestion(wizard, from);
|
|
82498
|
+
showNumbered(
|
|
82499
|
+
wizard,
|
|
82500
|
+
question.given,
|
|
82501
|
+
"Stacks: starter apps a run can build in instead of this repository:",
|
|
82502
|
+
setupEnvironments(from ?? "job-").map((env) => env.name),
|
|
82503
|
+
1
|
|
82504
|
+
);
|
|
82505
|
+
return ask(wizard, question);
|
|
82506
|
+
}
|
|
82507
|
+
function testsQuestion(wizard, from) {
|
|
82508
|
+
const choices = setupEnvironments(from ?? "job-").map((env) => env.slug);
|
|
82224
82509
|
const { git, stacks, root } = wizard.detected;
|
|
82225
|
-
const detected = stacks.filter((
|
|
82226
|
-
|
|
82227
|
-
|
|
82228
|
-
|
|
82510
|
+
const detected = stacks.filter((stack2) => choices.includes(stack2));
|
|
82511
|
+
const { repo, stack } = wizard.flags;
|
|
82512
|
+
return {
|
|
82513
|
+
label: "Where to test: this repository (repo), all stacks (all), or stack numbers or ranges separated by commas (1, 3-4)",
|
|
82514
|
+
fallback: git ? "repo" : detected.join(", ") || null,
|
|
82229
82515
|
missing: `found nothing to test in: ${root} isn't a git repository, and its package.json and lockfiles name no framework of a stack (${choices.join(", ")}). Run it in a git repository, or on a terminal to choose stacks.`,
|
|
82230
|
-
|
|
82231
|
-
|
|
82232
|
-
|
|
82233
|
-
|
|
82234
|
-
if (
|
|
82516
|
+
flag: repo !== void 0 ? "--repo" : stack.length > 0 || !git ? "--stack" : "--repo . or --stack",
|
|
82517
|
+
given: repo ?? (stack.length > 0 ? stack.join(",") : void 0),
|
|
82518
|
+
keys: repo === void 0 ? `agentpicks catalogue${from ? ` ${from}` : ""}` : void 0,
|
|
82519
|
+
read: (answer, flag) => {
|
|
82520
|
+
if (answer === "." || !flag && answer === "repo")
|
|
82521
|
+
return { value: { repo: "." } };
|
|
82522
|
+
if (answer === "all") return { value: { stacks: choices } };
|
|
82523
|
+
const given = withRanges(answer, choices.length);
|
|
82524
|
+
const chosen = [
|
|
82525
|
+
...new Set(given.map((entry) => pickKey(entry, choices)))
|
|
82526
|
+
];
|
|
82527
|
+
const unknown2 = given.find((entry) => !pickKey(entry, choices));
|
|
82528
|
+
if (given.length === 0 || unknown2)
|
|
82235
82529
|
return {
|
|
82236
|
-
problem: `${unknown2 ?? "Nothing"} isn't a stack ${from ? `for ${from}` : "for your own job"}. Give
|
|
82530
|
+
problem: `${unknown2 ?? "Nothing"} isn't a stack ${from ? `for ${from}` : "for your own job"}. Give ${flag ? "stack slugs, or all" : `repo, all, or numbers from 1 to ${choices.length}`}.`
|
|
82237
82531
|
};
|
|
82238
|
-
return { value: { stacks: chosen } };
|
|
82532
|
+
return { value: { stacks: chosen.filter((stack2) => stack2 !== null) } };
|
|
82239
82533
|
}
|
|
82240
|
-
}
|
|
82534
|
+
};
|
|
82241
82535
|
}
|
|
82242
|
-
|
|
82243
|
-
return
|
|
82536
|
+
function agentsQuestion(wizard) {
|
|
82537
|
+
return {
|
|
82244
82538
|
label: "Agents separated by commas, or any",
|
|
82245
82539
|
fallback: wizard.detected.agents.join(", ") || "any",
|
|
82540
|
+
flag: "--agent",
|
|
82541
|
+
given: wizard.flags.agent.length > 0 ? wizard.flags.agent.join(",") : void 0,
|
|
82246
82542
|
read: (answer) => {
|
|
82247
82543
|
if (answer === "any") return { value: null };
|
|
82248
82544
|
const chosen = entries(answer).map(
|
|
@@ -82258,31 +82554,57 @@ async function askAgents(wizard) {
|
|
|
82258
82554
|
};
|
|
82259
82555
|
return { value: unique };
|
|
82260
82556
|
}
|
|
82261
|
-
}
|
|
82557
|
+
};
|
|
82262
82558
|
}
|
|
82263
|
-
function
|
|
82264
|
-
return
|
|
82559
|
+
function runsQuestion(wizard) {
|
|
82560
|
+
return {
|
|
82561
|
+
label: "Runs per agent and stack",
|
|
82562
|
+
fallback: "1",
|
|
82563
|
+
flag: "--runs",
|
|
82564
|
+
given: wizard.flags.runs,
|
|
82565
|
+
read: (answer) => /^[1-9]\d*$/.test(answer) && Number(answer) <= 100 ? { value: Number(answer) } : { problem: "Give a whole number of runs, 1 to 100." }
|
|
82566
|
+
};
|
|
82567
|
+
}
|
|
82568
|
+
function nameQuestion(wizard, fallback, written) {
|
|
82569
|
+
return {
|
|
82570
|
+
label: `Setup name, saved as ${SETUPS_DIR}/<name>.yaml`,
|
|
82571
|
+
fallback,
|
|
82572
|
+
flag: "--name",
|
|
82573
|
+
given: wizard.flags.name,
|
|
82574
|
+
read: (answer) => {
|
|
82575
|
+
if (!/^[a-z0-9][a-z0-9-]{0,62}$/.test(answer))
|
|
82576
|
+
return {
|
|
82577
|
+
problem: "A name is lowercase letters, digits and hyphens, such as error-tracking."
|
|
82578
|
+
};
|
|
82579
|
+
const path = setupPath((0, import_node_path14.join)(wizard.detected.root, SETUPS_DIR), answer);
|
|
82580
|
+
if ((0, import_node_fs8.existsSync)(path) && !wizard.flags.force)
|
|
82581
|
+
return {
|
|
82582
|
+
problem: `${(0, import_node_path14.relative)(wizard.cwd, path)} exists. Choose another name, or pass --force to replace it.`
|
|
82583
|
+
};
|
|
82584
|
+
return written(answer);
|
|
82585
|
+
}
|
|
82586
|
+
};
|
|
82265
82587
|
}
|
|
82266
82588
|
function setupPath(dir, name) {
|
|
82267
|
-
return [".yaml", ".yml"].map((ext) => (0,
|
|
82589
|
+
return [".yaml", ".yml"].map((ext) => (0, import_node_path14.join)(dir, `${name}${ext}`)).find(import_node_fs8.existsSync) ?? (0, import_node_path14.join)(dir, `${name}.yaml`);
|
|
82268
82590
|
}
|
|
82269
82591
|
function writeSetup(dir, path, text3, force, cwd) {
|
|
82270
82592
|
try {
|
|
82271
82593
|
writeSetupText(dir, path, text3, {
|
|
82272
82594
|
replace: force,
|
|
82273
|
-
shown: (target) => (0,
|
|
82595
|
+
shown: (target) => (0, import_node_path14.relative)(cwd, target) || target
|
|
82274
82596
|
});
|
|
82275
82597
|
} catch (error62) {
|
|
82276
82598
|
if (error62.code === "EEXIST")
|
|
82277
82599
|
throw new UsageError(
|
|
82278
|
-
`${(0,
|
|
82600
|
+
`${(0, import_node_path14.relative)(cwd, path)} appeared while init ran. Run init again with another name, or pass --force to replace it.`
|
|
82279
82601
|
);
|
|
82280
82602
|
throw error62;
|
|
82281
82603
|
}
|
|
82282
82604
|
}
|
|
82283
82605
|
|
|
82284
82606
|
// src/cli/list-command.ts
|
|
82285
|
-
var
|
|
82607
|
+
var import_node_path15 = require("node:path");
|
|
82286
82608
|
async function listCommand(argv, ctx) {
|
|
82287
82609
|
if (argv.length > 0)
|
|
82288
82610
|
throw new UsageError(
|
|
@@ -82305,7 +82627,7 @@ async function listCommand(argv, ctx) {
|
|
|
82305
82627
|
if (devtune)
|
|
82306
82628
|
return linkedTable(readSetupFiles(root, heldTools(devtune)), devtune, ctx);
|
|
82307
82629
|
if (files.length === 0) {
|
|
82308
|
-
ctx.out(`${(0,
|
|
82630
|
+
ctx.out(`${(0, import_node_path15.join)(root, SETUPS_DIR)} holds no setup files. ${WRITE_ONE}`);
|
|
82309
82631
|
return 0;
|
|
82310
82632
|
}
|
|
82311
82633
|
printSetups(
|
|
@@ -82610,8 +82932,8 @@ function logoPlayer(env, stdout) {
|
|
|
82610
82932
|
|
|
82611
82933
|
// src/cli/pull-command.ts
|
|
82612
82934
|
var import_node_fs9 = require("node:fs");
|
|
82613
|
-
var
|
|
82614
|
-
var
|
|
82935
|
+
var import_node_path16 = require("node:path");
|
|
82936
|
+
var import_node_util4 = require("node:util");
|
|
82615
82937
|
async function pullCommand(argv, ctx) {
|
|
82616
82938
|
const { values, positionals } = parse5(argv);
|
|
82617
82939
|
if (positionals.length > 1)
|
|
@@ -82650,7 +82972,7 @@ async function pullCommand(argv, ctx) {
|
|
|
82650
82972
|
}
|
|
82651
82973
|
function parse5(argv) {
|
|
82652
82974
|
try {
|
|
82653
|
-
return (0,
|
|
82975
|
+
return (0, import_node_util4.parseArgs)({
|
|
82654
82976
|
args: argv,
|
|
82655
82977
|
strict: true,
|
|
82656
82978
|
allowPositionals: true,
|
|
@@ -82662,7 +82984,7 @@ function parse5(argv) {
|
|
|
82662
82984
|
);
|
|
82663
82985
|
}
|
|
82664
82986
|
}
|
|
82665
|
-
var shown = (path, ctx) => (0,
|
|
82987
|
+
var shown = (path, ctx) => (0, import_node_path16.relative)(ctx.cwd, path) || path;
|
|
82666
82988
|
function pullOne(setup, root, files, devtune, force, ctx) {
|
|
82667
82989
|
const name = devtune.names.get(setup.id);
|
|
82668
82990
|
const linked = files.filter((file2) => file2.content?.id === setup.id);
|
|
@@ -82673,7 +82995,7 @@ function pullOne(setup, root, files, devtune, force, ctx) {
|
|
|
82673
82995
|
return false;
|
|
82674
82996
|
}
|
|
82675
82997
|
const [local] = linked;
|
|
82676
|
-
const path = local?.path ?? (0,
|
|
82998
|
+
const path = local?.path ?? (0, import_node_path16.join)(root, SETUPS_DIR, `${name}.yaml`);
|
|
82677
82999
|
if (local) {
|
|
82678
83000
|
const state = syncState(local.content, setup);
|
|
82679
83001
|
if (state === "in_sync") {
|
|
@@ -82702,7 +83024,7 @@ function pullOne(setup, root, files, devtune, force, ctx) {
|
|
|
82702
83024
|
}
|
|
82703
83025
|
try {
|
|
82704
83026
|
writeSetupText(
|
|
82705
|
-
(0,
|
|
83027
|
+
(0, import_node_path16.join)(root, SETUPS_DIR),
|
|
82706
83028
|
path,
|
|
82707
83029
|
`${SCHEMA_LINE}
|
|
82708
83030
|
${linkedSetupYaml(mapped.file, {
|
|
@@ -82731,7 +83053,7 @@ ${linkedSetupYaml(mapped.file, {
|
|
|
82731
83053
|
}
|
|
82732
83054
|
|
|
82733
83055
|
// src/cli/push-command.ts
|
|
82734
|
-
var
|
|
83056
|
+
var import_node_path17 = require("node:path");
|
|
82735
83057
|
async function pushCommand(argv, ctx) {
|
|
82736
83058
|
const flag = argv.find((arg) => arg.startsWith("-"));
|
|
82737
83059
|
if (flag)
|
|
@@ -82752,7 +83074,7 @@ async function pushCommand(argv, ctx) {
|
|
|
82752
83074
|
return failed === 0 ? 0 : 1;
|
|
82753
83075
|
}
|
|
82754
83076
|
async function pushOne(file2, devtune, ctx) {
|
|
82755
|
-
const shown3 = (0,
|
|
83077
|
+
const shown3 = (0, import_node_path17.relative)(ctx.cwd, file2.path) || file2.path;
|
|
82756
83078
|
const content = file2.content;
|
|
82757
83079
|
if (!file2.setup || !content) {
|
|
82758
83080
|
for (const problem of file2.problems)
|
|
@@ -82776,7 +83098,7 @@ async function pushOne(file2, devtune, ctx) {
|
|
|
82776
83098
|
return false;
|
|
82777
83099
|
}
|
|
82778
83100
|
}
|
|
82779
|
-
const repositoryStacks = !current && file2.setup.repo ? detectStacks((0,
|
|
83101
|
+
const repositoryStacks = !current && file2.setup.repo ? detectStacks((0, import_node_path17.resolve)(file2.root, file2.setup.repo.path)).stacks : void 0;
|
|
82780
83102
|
let saved;
|
|
82781
83103
|
try {
|
|
82782
83104
|
const request2 = pushRequest(
|
|
@@ -82811,7 +83133,7 @@ async function pushOne(file2, devtune, ctx) {
|
|
|
82811
83133
|
id: saved.setup.id,
|
|
82812
83134
|
setupDigest: saved.snapshotDigest
|
|
82813
83135
|
},
|
|
82814
|
-
(path) => (0,
|
|
83136
|
+
(path) => (0, import_node_path17.relative)(ctx.cwd, path) || path
|
|
82815
83137
|
);
|
|
82816
83138
|
ctx.out(
|
|
82817
83139
|
current ? `Pushed ${shown3} to DevTune setup ${devtune.names.get(current.id)}.` : `Pushed ${shown3} to DevTune, and linked ${shown3} to the setup it saved.`
|
|
@@ -82835,7 +83157,7 @@ async function linkExisting(file2, content, ctx, shown3, repositoryStacks) {
|
|
|
82835
83157
|
id: existing.id,
|
|
82836
83158
|
setupDigest: existing.snapshot_digest
|
|
82837
83159
|
},
|
|
82838
|
-
(path) => (0,
|
|
83160
|
+
(path) => (0, import_node_path17.relative)(ctx.cwd, path) || path
|
|
82839
83161
|
);
|
|
82840
83162
|
ctx.out(
|
|
82841
83163
|
`DevTune already holds ${shown3} as setup ${after.names.get(existing.id)}; linked ${shown3} to it.`
|
|
@@ -82882,8 +83204,8 @@ function sameSubject(setup, content) {
|
|
|
82882
83204
|
|
|
82883
83205
|
// src/cli/results.ts
|
|
82884
83206
|
var import_node_fs10 = require("node:fs");
|
|
82885
|
-
var
|
|
82886
|
-
var
|
|
83207
|
+
var import_node_path18 = require("node:path");
|
|
83208
|
+
var import_node_util5 = require("node:util");
|
|
82887
83209
|
|
|
82888
83210
|
// src/assets/watch-pick-rule.ts
|
|
82889
83211
|
var POSIX_CLASSES = {
|
|
@@ -83132,7 +83454,7 @@ function resultsCommand(argv, ctx) {
|
|
|
83132
83454
|
const rows = [
|
|
83133
83455
|
...new Set(
|
|
83134
83456
|
dirs.flatMap(
|
|
83135
|
-
(dir) => bundleDirs((0,
|
|
83457
|
+
(dir) => bundleDirs((0, import_node_path18.resolve)(ctx.cwd, dir)).map((bundle) => (0, import_node_path18.resolve)(bundle))
|
|
83136
83458
|
)
|
|
83137
83459
|
)
|
|
83138
83460
|
].map(resultRow).sort(
|
|
@@ -83148,7 +83470,7 @@ function resultsCommand(argv, ctx) {
|
|
|
83148
83470
|
function parseResultsArgs(argv) {
|
|
83149
83471
|
let parsed2;
|
|
83150
83472
|
try {
|
|
83151
|
-
parsed2 = (0,
|
|
83473
|
+
parsed2 = (0, import_node_util5.parseArgs)({
|
|
83152
83474
|
args: argv,
|
|
83153
83475
|
strict: true,
|
|
83154
83476
|
allowPositionals: true,
|
|
@@ -83180,7 +83502,7 @@ function resultRow(dir) {
|
|
|
83180
83502
|
if (!(error62 instanceof BundleError)) throw error62;
|
|
83181
83503
|
return {
|
|
83182
83504
|
dir,
|
|
83183
|
-
runId: (0,
|
|
83505
|
+
runId: (0, import_node_path18.basename)(dir),
|
|
83184
83506
|
setup: null,
|
|
83185
83507
|
agent: null,
|
|
83186
83508
|
model: null,
|
|
@@ -85370,7 +85692,7 @@ function isDockerSandbox(box) {
|
|
|
85370
85692
|
}
|
|
85371
85693
|
|
|
85372
85694
|
// src/cli/validate-command.ts
|
|
85373
|
-
var
|
|
85695
|
+
var import_node_path19 = require("node:path");
|
|
85374
85696
|
function validateCommand(argv, ctx) {
|
|
85375
85697
|
const flag = argv.find((arg) => arg.startsWith("-"));
|
|
85376
85698
|
if (flag)
|
|
@@ -85385,7 +85707,7 @@ function validateCommand(argv, ctx) {
|
|
|
85385
85707
|
}
|
|
85386
85708
|
}) : readSetupFiles(root);
|
|
85387
85709
|
if (files.length === 0) {
|
|
85388
|
-
ctx.out(`${(0,
|
|
85710
|
+
ctx.out(`${(0, import_node_path19.join)(root, SETUPS_DIR)} holds no setup files. ${WRITE_ONE}`);
|
|
85389
85711
|
return 0;
|
|
85390
85712
|
}
|
|
85391
85713
|
let failed = 0;
|
|
@@ -85396,7 +85718,7 @@ function validateCommand(argv, ctx) {
|
|
|
85396
85718
|
continue;
|
|
85397
85719
|
}
|
|
85398
85720
|
if (file2.problems.length === 0) {
|
|
85399
|
-
ctx.out(`${(0,
|
|
85721
|
+
ctx.out(`${(0, import_node_path19.relative)(ctx.cwd, file2.path) || file2.path}: valid`);
|
|
85400
85722
|
continue;
|
|
85401
85723
|
}
|
|
85402
85724
|
failed++;
|
|
@@ -85424,7 +85746,10 @@ var RUNNER = {
|
|
|
85424
85746
|
version: package_default.version
|
|
85425
85747
|
};
|
|
85426
85748
|
var USAGE = `Usage:
|
|
85427
|
-
agentpicks init [--yes] [--force]
|
|
85749
|
+
agentpicks init [--yes] [--force] [--category <category> | --job <line>] [--tool <tool>|none]
|
|
85750
|
+
[--competitors <tool>,...|all] [--repo . | --stack <stack>...|all]
|
|
85751
|
+
[--agent <agent>...|any] [--runs <n>] [--name <name>]
|
|
85752
|
+
agentpicks catalogue [<category>] [--json]
|
|
85428
85753
|
agentpicks run [<setup>] [--stack <stack> | --repo <path> [--ref <commit>]]
|
|
85429
85754
|
[--runs <n>] [--agent claude-code|codex|opencode|pi] [--model <model>]
|
|
85430
85755
|
[--out <dir>] [--no-upload]
|
|
@@ -85446,6 +85771,23 @@ var USAGE = `Usage:
|
|
|
85446
85771
|
init Writes a setup file, agentpicks/<name>.yaml, from questions whose defaults come from
|
|
85447
85772
|
this repository. --yes takes every default without asking. --force replaces a setup
|
|
85448
85773
|
of the same name. Signed in, DevTune drafts the requests and tools of your own job.
|
|
85774
|
+
Each flag answers one question: --category or --job, --tool, --competitors,
|
|
85775
|
+
--repo . or --stack, --agent, --runs and --name. Flags take keys, never list numbers;
|
|
85776
|
+
--stack and --agent repeat or take a comma list, and --stack all takes every stack
|
|
85777
|
+
the job runs in. A question a flag answers isn't
|
|
85778
|
+
asked. A flag value that doesn't read stops init before it asks anything, unless the
|
|
85779
|
+
check needs an earlier answer, such as --competitors against the tool this
|
|
85780
|
+
repository names, which waits for that question. Off a terminal, a question no flag
|
|
85781
|
+
answers takes its default with --yes, where it has one; without --yes, init stops at
|
|
85782
|
+
it and names its flag. A job line's requests and tools
|
|
85783
|
+
have no flags: answer them on a terminal or, signed in, take DevTune's drafts with
|
|
85784
|
+
--yes; off a terminal a job line needs --yes. For a category setup, init ends with
|
|
85785
|
+
the agentpicks init command that writes the same setup in another repository.
|
|
85786
|
+
Typed answers take list numbers or keys; the competitors and stacks answers also
|
|
85787
|
+
take ranges such as 2-4.
|
|
85788
|
+
catalogue Lists the category, tool and stack keys init's flags take: every category and the
|
|
85789
|
+
stacks a job line can run in, or with <category>, its tool keys and stacks. --json
|
|
85790
|
+
prints one JSON object.
|
|
85449
85791
|
run Tests the coding agent installed here in a fresh Docker container per run, writes
|
|
85450
85792
|
one bundle per completed run to --out (default ./agentpicks-runs), and uploads it to
|
|
85451
85793
|
your DevTune project. --no-upload keeps bundles on this machine only, as every run
|
|
@@ -85499,11 +85841,12 @@ describes every field.
|
|
|
85499
85841
|
`;
|
|
85500
85842
|
var INTRO = `Test which tools coding agents pick when they build your kind of app.
|
|
85501
85843
|
|
|
85502
|
-
agentpicks init
|
|
85503
|
-
agentpicks
|
|
85504
|
-
agentpicks
|
|
85505
|
-
agentpicks
|
|
85506
|
-
agentpicks
|
|
85844
|
+
agentpicks init Write a setup file for this repository
|
|
85845
|
+
agentpicks catalogue List the categories, tools and stacks init takes by key
|
|
85846
|
+
agentpicks run Run a setup with the coding agent installed here
|
|
85847
|
+
agentpicks results Show which tool each run picked
|
|
85848
|
+
agentpicks list List this repository's setups and your project's
|
|
85849
|
+
agentpicks login Sign in to DevTune to upload runs for its analysis
|
|
85507
85850
|
|
|
85508
85851
|
Runs need no DevTune account: pass --no-upload to run, or set AGENTPICKS_NO_UPLOAD=1, and
|
|
85509
85852
|
bundles stay on this machine. To upload them later, sign up at ${signUpUrl()}
|
|
@@ -85567,6 +85910,7 @@ async function main(argv, given) {
|
|
|
85567
85910
|
if (command === "validate") return validateCommand(rest, ctx);
|
|
85568
85911
|
if (command === "schema") return schemaCommand(rest, ctx);
|
|
85569
85912
|
if (command === "results") return resultsCommand(rest, ctx);
|
|
85913
|
+
if (command === "catalogue") return catalogueCommand(rest, ctx);
|
|
85570
85914
|
ctx.err(`agentpicks has no ${command} command.
|
|
85571
85915
|
|
|
85572
85916
|
${USAGE}`);
|
|
@@ -85596,7 +85940,7 @@ async function runCommand(argv, ctx) {
|
|
|
85596
85940
|
);
|
|
85597
85941
|
const file2 = await runnableSetup(command.setup, ctx);
|
|
85598
85942
|
if (file2 === null) return 1;
|
|
85599
|
-
const shown3 = (0,
|
|
85943
|
+
const shown3 = (0, import_node_path20.relative)(ctx.cwd, file2.path) || file2.path;
|
|
85600
85944
|
const plan = setupPlan(file2, command.flags, ctx.cwd);
|
|
85601
85945
|
return runPlan(
|
|
85602
85946
|
await linkUploads(plan, file2.setup, file2.content, shown3, ctx),
|
|
@@ -85636,7 +85980,7 @@ async function pickSetup(ctx) {
|
|
|
85636
85980
|
const files = readSetupFiles(root);
|
|
85637
85981
|
if (files.length === 0) {
|
|
85638
85982
|
ctx.err(
|
|
85639
|
-
`${(0,
|
|
85983
|
+
`${(0, import_node_path20.join)(root, SETUPS_DIR)} holds no setup files. Write one with: agentpicks init
|
|
85640
85984
|
|
|
85641
85985
|
Or run a built-in category: agentpicks run --category <category> --stack <stack>.`
|
|
85642
85986
|
);
|
|
@@ -85684,7 +86028,7 @@ async function runPlan(given, ctx, link) {
|
|
|
85684
86028
|
const platform = await dockerAccess.platform();
|
|
85685
86029
|
for (const test of plan.tests) assertStackRuns(test.environment, platform);
|
|
85686
86030
|
if (repository) assertRepositoryRuns(repository.install, platform);
|
|
85687
|
-
const outDir = (0,
|
|
86031
|
+
const outDir = (0, import_node_path20.resolve)(ctx.cwd, plan.out);
|
|
85688
86032
|
const { runs } = plan;
|
|
85689
86033
|
const cells = agentPlans.flatMap(
|
|
85690
86034
|
(agentPlan, a) => plan.tests.map((test) => ({ agentPlan, a, test }))
|
|
@@ -85800,7 +86144,7 @@ async function uploadPrinted(dir, target, ctx, bundle) {
|
|
|
85800
86144
|
}
|
|
85801
86145
|
}
|
|
85802
86146
|
async function uploadCommand(argv, ctx) {
|
|
85803
|
-
const dirs = findBundles((0,
|
|
86147
|
+
const dirs = findBundles((0, import_node_path20.resolve)(ctx.cwd, parseUploadArgs(argv).dir));
|
|
85804
86148
|
let target;
|
|
85805
86149
|
let uploaded = 0;
|
|
85806
86150
|
for (const dir of dirs) {
|
|
@@ -85926,7 +86270,7 @@ function trackSandboxes(inner) {
|
|
|
85926
86270
|
// src/cli.ts
|
|
85927
86271
|
void main(
|
|
85928
86272
|
process.argv.slice(2),
|
|
85929
|
-
defaultContext((0,
|
|
86273
|
+
defaultContext((0, import_node_path21.join)(__dirname, "..", "docker"))
|
|
85930
86274
|
).then((code) => {
|
|
85931
86275
|
process.exitCode = code;
|
|
85932
86276
|
});
|