@devtune/agentpicks 0.4.3 → 0.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +26 -13
  2. package/dist/cli.js +194 -84
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,17 +1,29 @@
1
1
  # @devtune/agentpicks
2
2
 
3
- Test which tools the coding agents installed on your machine pick when they build your kind of app. `agentpicks run` gives an agent a real request (add error tracking, choose a database) in a committed starter app or your own repository, inside a fresh Docker container, writes what it did to a bundle on disk (its transcript, its code changes, every URL it fetched and every package it installed) and uploads the bundle to your DevTune project.
3
+ Test which tools the coding agents installed on your machine pick when they build your kind of app. `agentpicks run` gives an agent a real request (add error tracking, choose a database) in a committed starter app or your own repository, inside a fresh Docker container, and writes what it did to a bundle on disk: its transcript, its code changes, every URL it fetched and every package it installed. `agentpicks results` reads which tool each run picked from those bundles.
4
4
 
5
- Apache-2.0.
5
+ Apache-2.0. None of this needs a DevTune account:
6
6
 
7
7
  ```sh
8
- npx @devtune/agentpicks login
9
- npx @devtune/agentpicks run --category error-tracking --stack nextjs
10
- npx @devtune/agentpicks init # writes a setup file, such as agentpicks/error-tracking.yaml
11
- npx @devtune/agentpicks run error-tracking # runs agentpicks/error-tracking.yaml; see Setups
8
+ npx @devtune/agentpicks init # writes a setup file, such as agentpicks/error-tracking.yaml
9
+ npx @devtune/agentpicks run error-tracking --no-upload # runs it; see Setups
10
+ npx @devtune/agentpicks run --category error-tracking --stack nextjs --no-upload
11
+ npx @devtune/agentpicks results
12
12
  npm install -g @devtune/agentpicks # then: agentpicks run ...
13
13
  ```
14
14
 
15
+ Set `AGENTPICKS_NO_UPLOAD=1` to keep every run on this machine without passing `--no-upload`.
16
+
17
+ To have DevTune analyse the runs (what the agent said it picked, pick rates, loss reasons and the Actions that follow), sign in, save the setup and upload what you already ran:
18
+
19
+ ```sh
20
+ npx @devtune/agentpicks login
21
+ npx @devtune/agentpicks push
22
+ npx @devtune/agentpicks upload ./agentpicks-runs
23
+ ```
24
+
25
+ A kept run uploads once its setup is pushed with the same `from`, add request and tools the run tested. See [Upload](#upload). No DevTune account yet? [Sign up](https://devtune.ai/auth/sign-up) and create a project, or have your coding agent [set one up](https://docs.devtune.ai/getting-started/agent-setup).
26
+
15
27
  ## Requirements
16
28
 
17
29
  - Docker, running. Each run uses a fresh container with 2 CPUs and 4 GB of memory, needs 20 GB free on Docker's disk and may write up to 15 GB there. The image is built for your machine's own architecture, x86_64 or arm64, so nothing is emulated.
@@ -36,7 +48,7 @@ agentpicks run --category error-tracking --repo .
36
48
  | `--agent` | `claude-code`, `codex`, `opencode` or `pi`. Required when several are installed. |
37
49
  | `--model` | The model to ask for. OpenCode and Pi take `anthropic/<model>` or `openai/<model>`. |
38
50
  | `--out` | Where bundles go. Default `./agentpicks-runs`. |
39
- | `--no-upload` | Keep bundles on this machine only. Send them later with `agentpicks upload`, except a custom setup's (see [Setups](#setups)). |
51
+ | `--no-upload` | Keep bundles on this machine only. Send them later with `agentpicks upload`; a custom setup's once `agentpicks push` saves it (see [Setups](#setups)). `AGENTPICKS_NO_UPLOAD`, set to anything, does the same for every run. |
40
52
 
41
53
  `agentpicks --help`, or `--help` after any command, prints the usage and exits successfully.
42
54
 
@@ -103,7 +115,7 @@ Either login is saved to `agentpicks/credentials.json` under `$XDG_CONFIG_HOME`,
103
115
 
104
116
  In CI, set `DEVTUNE_API_KEY` and `DEVTUNE_PROJECT_ID` instead: they override the saved login. Without `DEVTUNE_API_KEY`, a saved sign-in is used only for its own API address and project. `DEVTUNE_API_BASE_URL` sets the API address, default `https://devtune.ai/api/v2`. These are the names the `devtune` CLI reads.
105
117
 
106
- `run` checks for a sign-in or key before anything starts, and refuses without one. Once a run's bundle is written, `run` lists its files, their sizes and the redactions, then uploads it: the manifest to DevTune, and each artifact straight to storage. It prints the run id and the upload's API address. If DevTune refuses the upload, `run` prints DevTune's reason and the command that sends the bundle later, and starts no further runs. The bundle stays on disk either way.
118
+ `run` checks for a sign-in or key before anything starts, and refuses without one unless you pass `--no-upload` or set `AGENTPICKS_NO_UPLOAD`. Once a run's bundle is written, `run` lists its files, their sizes and the redactions, then uploads it: the manifest to DevTune, and each artifact straight to storage. It prints the run id and the upload's API address. If DevTune refuses the upload, `run` prints DevTune's reason and the command that sends the bundle later, and starts no further runs. The bundle stays on disk either way.
107
119
 
108
120
  A `--repo` run needs the repository to have a remote that `agentpicks` records (see [The bundle](#the-bundle)), since DevTune groups a repository's runs by its remote. Without one, `run` refuses before anything starts; add an `origin` remote, or pass `--no-upload`.
109
121
 
@@ -147,6 +159,7 @@ agentpicks init --yes
147
159
  `agentpicks init` writes a setup file from a few questions. Each shows its default in brackets, and Enter takes it:
148
160
 
149
161
  - **Job**: a built-in category, which the file inherits with `from:`, or a job line of your own. The default is the category of your tool.
162
+ - **Requests**, for a job of your own: the add request a run asks, the recommend request `push` saves with it, and a hosted request or none.
150
163
  - **Your tool**: a catalogue tool named by your `package.json` name or scope, or your git remote's repository or owner, such as `sentry` from `getsentry/sentry-docs`.
151
164
  - **Competitors**: for a category, its tools; for your own job, typed as npm packages.
152
165
  - **Where to test**: `repo: .` in a git repository, else the stacks your `package.json` and lockfiles name (`next`, `@tanstack/react-start`, `@sveltejs/kit` and `express`, a pnpm monorepo's apps included, plus FastAPI and Rails).
@@ -209,7 +222,7 @@ runs: 3
209
222
  | `id` | The DevTune setup the file is linked to. `pull` and `push` write it. |
210
223
  | `synced` | What the file and its DevTune setup held when they last matched: `setup`, the setup's digest, and `file`, the file's. `pull` and `push` write it; don't edit it. |
211
224
 
212
- `schema/setup.v1.json` in this package is the file's JSON Schema. An editor with YAML support completes and checks a setup file against it, for example with a first line `# yaml-language-server: $schema=<path or URL of setup.v1.json>`.
225
+ `agentpicks schema` prints the file's JSON Schema. It is `schema/setup.v1.json` in this package, and each version's is at `https://raw.githubusercontent.com/devtunehq/agentpicks/v<version>/schema/setup.v1.json`. `init` and `pull` start a file with `# yaml-language-server: $schema=<that address>`, so an editor with YAML support completes and checks it. To have a coding agent write a setup, give it the schema and this section, and have it run `agentpicks validate` until the file passes.
213
226
 
214
227
  ```sh
215
228
  agentpicks run feature-flags --no-upload
@@ -219,7 +232,7 @@ agentpicks run
219
232
 
220
233
  `agentpicks run <setup>` takes the setup's name or the path of its file. Each run asks the setup's `add` request, once per agent and stack. Claude Code's early stop watches for the `from` category's tools and for the package and config names of the setup's own tools; a tool that yields to another tool in the setup (`yieldsTo`) doesn't stop it, and nor does a tool named by key alone or a full entry with no package or config name, so a setup whose tools are all like these isn't stopped early. Flags override the file: `--stack` or `--repo` replaces its stacks or repo, `--ref` its commit, `--agent` its agents, and `--runs` its runs. `--model` sets one agent's model, so a setup with several agents needs `--agent` with it. On a terminal, `agentpicks run` with no setup and no `--category` lists the setups and asks which to run.
221
234
 
222
- A setup file linked to a DevTune setup (it has an `id`) uploads under that setup. An unlinked setup `from` a category, with no requests or tool signals of its own, uploads as that category. Naming the category's tools under `tools` doesn't change that. Any other setup is custom, and can't share its name with a built-in category: until `agentpicks push` saves it to DevTune, `run` refuses to start it without `--no-upload`, and `upload` refuses its bundles. A run of a linked file whose DevTune setup is gone is refused before it starts, and so is a run of a linked file with changes not pushed (push it first) or whose DevTune setup changed since the file last saw it (pull it first). DevTune refuses an upload whose prompt isn't its setup's current request, as `prompt_mismatch`. With `--no-upload`, such a run's bundles record the unpushed changes, and `upload` refuses them.
235
+ A setup file linked to a DevTune setup (it has an `id`) uploads under that setup. An unlinked setup `from` a category, with no requests or tool signals of its own, uploads as that category. Naming the category's tools under `tools` doesn't change that. Any other setup is custom, and can't share its name with a built-in category: until `agentpicks push` saves it to DevTune, `run` refuses to start it without `--no-upload`. A run of a linked file whose DevTune setup is gone is refused before it starts, and so is a run of a linked file with changes not pushed (push it first) or whose DevTune setup changed since the file last saw it (pull it first). DevTune refuses an upload whose prompt isn't its setup's current request, as `prompt_mismatch`. A `--no-upload` bundle of a custom setup, or of a linked file's changes not pushed, uploads once `agentpicks push` has saved the file with the same `from`, add request and tools the run tested: run `upload` from the repository that holds the file. Adding what `push` needs and a run doesn't, such as a `recommend` request, is fine. A bundle of an add request or tools the file or DevTune no longer holds can't file under the setup; run the setup again.
223
236
 
224
237
  ```sh
225
238
  agentpicks list
@@ -268,7 +281,7 @@ jobs:
268
281
  steps:
269
282
  - uses: actions/checkout@v5
270
283
  - run: npm install -g @anthropic-ai/claude-code@2.1.323
271
- - uses: devtunehq/agentpicks@v0.4.3
284
+ - uses: devtunehq/agentpicks@v0.4.5
272
285
  with:
273
286
  setup: agentpicks/error-tracking.yaml
274
287
  agent: claude-code
@@ -282,7 +295,7 @@ jobs:
282
295
 
283
296
  Use a Linux runner: `ubuntu-latest` has Docker and Node.js 20 or later. Without Docker, `run` refuses; without Node.js 20 or later, the action does. The action uses the runner's Node.js and doesn't change it for later steps.
284
297
 
285
- Pin a release tag, such as `v0.4.3`. The action runs the `@devtune/agentpicks` version in the `package.json` of its ref, so a tag runs the same CLI every time. A branch moves to each new version when the mirror syncs, and fails while that version isn't on npm.
298
+ Pin a release tag, such as `v0.4.5`. The action runs the `@devtune/agentpicks` version in the `package.json` of its ref, so a tag runs the same CLI every time. A branch moves to each new version when the mirror syncs, and fails while that version isn't on npm.
286
299
 
287
300
  | Input | Passed as |
288
301
  |---|---|
@@ -323,7 +336,7 @@ Install Docker, Node.js 20 or later and the agent, set `DEVTUNE_API_KEY`, `DEVTU
323
336
 
324
337
  ```sh
325
338
  npm install -g @anthropic-ai/claude-code@2.1.323
326
- npx --yes @devtune/agentpicks@0.4.3 run error-tracking --agent claude-code
339
+ npx --yes @devtune/agentpicks@0.4.5 run error-tracking --agent claude-code
327
340
  ```
328
341
 
329
342
  ## The bundle
package/dist/cli.js CHANGED
@@ -7365,17 +7365,17 @@ var require_dist = __commonJS({
7365
7365
  });
7366
7366
 
7367
7367
  // src/cli.ts
7368
- var import_node_path19 = require("node:path");
7368
+ var import_node_path20 = require("node:path");
7369
7369
 
7370
7370
  // src/cli/main.ts
7371
7371
  var import_node_crypto10 = require("node:crypto");
7372
- var import_node_path18 = require("node:path");
7372
+ var import_node_path19 = 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.3",
7378
+ version: "0.4.5",
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: {
@@ -7444,10 +7444,6 @@ var package_default = {
7444
7444
  }
7445
7445
  };
7446
7446
 
7447
- // src/sandbox/docker.ts
7448
- var import_node_child_process = require("node:child_process");
7449
- var import_node_crypto = require("node:crypto");
7450
-
7451
7447
  // src/assets/script.ts
7452
7448
  var SANDBOX_ROOT = "/opt/agent-picks";
7453
7449
  function script(strings) {
@@ -7456,6 +7452,13 @@ function script(strings) {
7456
7452
  function shellQuote(value) {
7457
7453
  return `'${value.replaceAll("'", `'\\''`)}'`;
7458
7454
  }
7455
+ function shellArg(value) {
7456
+ return /^[\w./:@%+=,-]+$/.test(value) ? value : shellQuote(value);
7457
+ }
7458
+
7459
+ // src/sandbox/docker.ts
7460
+ var import_node_child_process = require("node:child_process");
7461
+ var import_node_crypto = require("node:crypto");
7459
7462
 
7460
7463
  // src/sandbox/platform.ts
7461
7464
  var PLATFORMS = {
@@ -8786,6 +8789,14 @@ function fileDigest(file2) {
8786
8789
  for (const key of LOCAL_ONLY) delete content[key];
8787
8790
  return (0, import_node_crypto2.createHash)("sha256").update(canonical(content)).digest("hex");
8788
8791
  }
8792
+ function runDigest(file2) {
8793
+ const tested = {
8794
+ from: file2.from,
8795
+ add: file2.requests?.add,
8796
+ tools: file2.tools
8797
+ };
8798
+ return (0, import_node_crypto2.createHash)("sha256").update(canonical(tested)).digest("hex");
8799
+ }
8789
8800
 
8790
8801
  // ../../node_modules/.pnpm/zod@4.6.6_patch_hash=96bd69fd10dbaf45f7f092f491f5876d12a54eb6e3908dd65bb626412caa94b4/node_modules/zod/v4/classic/external.js
8791
8802
  var external_exports = {};
@@ -28862,10 +28873,10 @@ function mergeEarlyStop(base, entries2, listedKeys) {
28862
28873
  const configNames = unique(
28863
28874
  stopping.flatMap((tool) => tool.signals.configNames ?? [])
28864
28875
  ).map(escapeEre);
28865
- const join15 = (inherited, added) => [inherited, ...added].filter(Boolean).join("|") || NEVER_PATTERN;
28876
+ const join16 = (inherited, added) => [inherited, ...added].filter(Boolean).join("|") || NEVER_PATTERN;
28866
28877
  return {
28867
- installPattern: join15(base?.installPattern, packages),
28868
- codePattern: join15(base?.codePattern, configNames),
28878
+ installPattern: join16(base?.installPattern, packages),
28879
+ codePattern: join16(base?.codePattern, configNames),
28869
28880
  ...base?.pathPattern ? { pathPattern: base.pathPattern } : {}
28870
28881
  };
28871
28882
  }
@@ -35620,6 +35631,13 @@ var setupFileSchema = external_exports.object({
35620
35631
  ),
35621
35632
  runs: external_exports.number().int().min(1).max(100).optional().describe("How many runs per agent and stack. Default 1.")
35622
35633
  }).strict();
35634
+ function setupJsonSchema() {
35635
+ return {
35636
+ ...external_exports.toJSONSchema(setupFileSchema, { io: "input" }),
35637
+ title: "Agent Picks setup",
35638
+ description: "What agentpicks run tests: a job, its requests, your tool and its competitors, stacks or your repository, agents and runs. See https://www.npmjs.com/package/@devtune/agentpicks."
35639
+ };
35640
+ }
35623
35641
 
35624
35642
  // src/setup/files.ts
35625
35643
  var SETUPS_DIR = "agentpicks";
@@ -77794,8 +77812,13 @@ var bundleSetupSchema = external_exports.object({
77794
77812
  id: external_exports.string().min(1).nullable(),
77795
77813
  /** The job line. */
77796
77814
  job: external_exports.string().min(1),
77797
- /** Set when the run asked a linked file's changes not yet pushed, so it can't file under its setup. */
77815
+ /** Set when the run asked a linked file's changes not yet pushed, so it files only once they are. */
77798
77816
  unpushed: external_exports.boolean().optional(),
77817
+ /**
77818
+ * The digest of what the run tested (runDigest), for a run kept with --no-upload: `upload` files
77819
+ * a custom setup's run, or one of changes not pushed, once a push has saved a file that tests this.
77820
+ */
77821
+ asked: external_exports.string().regex(/^[0-9a-f]{64}$/).optional(),
77799
77822
  /** The catalogue tools the setup names by key that the run's early stop doesn't hold. */
77800
77823
  unrecognised: external_exports.array(external_exports.string().min(1)).optional()
77801
77824
  });
@@ -80714,6 +80737,10 @@ function apiRoot(value) {
80714
80737
  return null;
80715
80738
  return url2.href.replace(/\/$/, "");
80716
80739
  }
80740
+ function signUpUrl(baseUrl = DEFAULT_API_BASE_URL) {
80741
+ return new URL("/auth/sign-up", baseUrl).href;
80742
+ }
80743
+ var AGENT_SETUP_URL = "https://docs.devtune.ai/getting-started/agent-setup";
80717
80744
  function apiBaseUrl(env) {
80718
80745
  const value = env.DEVTUNE_API_BASE_URL || DEFAULT_API_BASE_URL;
80719
80746
  const root = apiRoot(value);
@@ -80761,7 +80788,7 @@ function devtuneTarget(io, purpose = "upload") {
80761
80788
  const projectId = io.env.DEVTUNE_PROJECT_ID || saved?.projectId;
80762
80789
  if (!apiKey || !projectId)
80763
80790
  throw new NotLoggedInError(
80764
- purpose === "setups" ? "Pushing or pulling setups needs a DevTune sign-in or project API key. Run agentpicks login, or set DEVTUNE_API_KEY and DEVTUNE_PROJECT_ID." : "Uploading needs a DevTune sign-in or project API key. Run agentpicks login, or set DEVTUNE_API_KEY and DEVTUNE_PROJECT_ID. To keep bundles on this machine only, pass --no-upload."
80791
+ purpose === "setups" ? "Pushing or pulling setups needs a DevTune sign-in or project API key. Run agentpicks login, or set DEVTUNE_API_KEY and DEVTUNE_PROJECT_ID." : "Uploading needs a DevTune sign-in or project API key. Run agentpicks login, or set DEVTUNE_API_KEY and DEVTUNE_PROJECT_ID. To keep bundles on this machine only, pass --no-upload, or set AGENTPICKS_NO_UPLOAD=1 for every run."
80765
80792
  );
80766
80793
  if (io.env.DEVTUNE_API_KEY) assertApiKey(apiKey, "DEVTUNE_API_KEY");
80767
80794
  if (!external_exports.uuid().safeParse(projectId).success)
@@ -80956,6 +80983,8 @@ async function readSecretLine(prompt) {
80956
80983
  var import_node_crypto8 = require("node:crypto");
80957
80984
  var import_node_fs5 = require("node:fs");
80958
80985
  var import_node_path9 = require("node:path");
80986
+ var SETUP_SCHEMA_URL = `https://raw.githubusercontent.com/devtunehq/agentpicks/v${package_default.version}/schema/setup.v1.json`;
80987
+ var SCHEMA_LINE = `# yaml-language-server: $schema=${SETUP_SCHEMA_URL}`;
80959
80988
  function isSymlink(path) {
80960
80989
  try {
80961
80990
  return (0, import_node_fs5.lstatSync)(path).isSymbolicLink();
@@ -81075,11 +81104,15 @@ async function linkedSetup(id, shown3, ctx) {
81075
81104
  async function linkUploads(plan, setup, content, shown3, ctx) {
81076
81105
  const unpushed = setup.id !== null && content !== void 0 && hasUnpushedChanges(content);
81077
81106
  if (!plan.upload)
81078
- return unpushed && plan.setup ? {
81107
+ return content && plan.setup ? {
81079
81108
  ...plan,
81080
81109
  setup: {
81081
81110
  ...plan.setup,
81082
- record: { ...plan.setup.record, unpushed: true }
81111
+ record: {
81112
+ ...plan.setup.record,
81113
+ asked: runDigest(content),
81114
+ ...unpushed ? { unpushed: true } : {}
81115
+ }
81083
81116
  }
81084
81117
  } : plan;
81085
81118
  if (setup.id === null) {
@@ -81107,13 +81140,14 @@ async function linkUploads(plan, setup, content, shown3, ctx) {
81107
81140
  };
81108
81141
  }
81109
81142
  async function linkedBundle(bundle, ctx) {
81110
- const id = bundle.setup?.id;
81143
+ const record2 = bundle.setup;
81144
+ if (!record2) return null;
81145
+ const shown3 = `${bundle.dir} (a run of ${record2.name})`;
81146
+ const custom2 = bundle.manifest.request.category.startsWith(
81147
+ CUSTOM_SETUP_CATEGORY_PREFIX
81148
+ );
81149
+ const id = record2.id && !record2.unpushed ? record2.id : record2.unpushed || custom2 ? pushedSince(record2, bundle.dir, shown3, ctx) : null;
81111
81150
  if (!id) return null;
81112
- const shown3 = `${bundle.dir} (a run of ${bundle.setup.name})`;
81113
- if (bundle.setup.unpushed)
81114
- throw new UsageError(
81115
- `${shown3} ran with changes not pushed to its DevTune setup, so it can't file under it. Run agentpicks push ${bundle.setup.name}, then run the setup again.`
81116
- );
81117
81151
  const slug2 = (await linkedSetup(id, shown3, ctx)).category_slug;
81118
81152
  return {
81119
81153
  ...bundle,
@@ -81123,6 +81157,38 @@ async function linkedBundle(bundle, ctx) {
81123
81157
  }
81124
81158
  };
81125
81159
  }
81160
+ function pushedSince(record2, dir, shown3, ctx) {
81161
+ if (!record2.asked) {
81162
+ if (!record2.id) return null;
81163
+ throw new UsageError(
81164
+ `${shown3} ran with changes not pushed to its DevTune setup, so it can't file under it. Run agentpicks push ${record2.name}, then run the setup again.`
81165
+ );
81166
+ }
81167
+ const named = listSetupFiles(setupsRoot(ctx.cwd)).filter(
81168
+ (path) => (0, import_node_path10.basename)(path, (0, import_node_path10.extname)(path)) === record2.name
81169
+ );
81170
+ const content = named.length === 1 ? readSetupFile(named[0]).content : void 0;
81171
+ if (!content)
81172
+ throw new UsageError(
81173
+ `${shown3} uploads under the DevTune setup its file ${record2.name} is linked to, and there is no readable setup ${record2.name} here. Run agentpicks upload from the repository whose agentpicks folder holds it.`
81174
+ );
81175
+ const asked = runDigest(content) === record2.asked;
81176
+ const runAgain = `Run agentpicks run ${record2.name} again to upload its runs.`;
81177
+ if (content.id === void 0 || hasUnpushedChanges(content)) {
81178
+ if (!asked)
81179
+ throw new UsageError(
81180
+ `${shown3} tested a version of ${record2.name} that the file no longer holds, so no push can save what it tested. ${runAgain}`
81181
+ );
81182
+ throw new UsageError(
81183
+ `${shown3} tested what ${record2.name} holds now, which isn't saved to DevTune yet. Run agentpicks push ${record2.name}, then agentpicks upload ${shellArg(dir)} again.`
81184
+ );
81185
+ }
81186
+ if (!asked || record2.id && record2.id !== content.id)
81187
+ throw new UsageError(
81188
+ `${shown3} tested a version of ${record2.name} that DevTune doesn't hold, so it can't file under its setup. ${runAgain}`
81189
+ );
81190
+ return content.id;
81191
+ }
81126
81192
 
81127
81193
  // src/cli/category-copy.ts
81128
81194
  async function categoryCopyPlan(args, ctx) {
@@ -81822,7 +81888,8 @@ async function initCommand(argv, ctx) {
81822
81888
  });
81823
81889
  if (runs !== 1) file2.runs = runs;
81824
81890
  const dir = (0, import_node_path13.join)(wizard.detected.root, SETUPS_DIR);
81825
- const text3 = (0, import_yaml5.stringify)(file2);
81891
+ const text3 = `${SCHEMA_LINE}
81892
+ ${(0, import_yaml5.stringify)(file2)}`;
81826
81893
  const name = await ask(wizard, {
81827
81894
  label: "Name",
81828
81895
  fallback: file2.from ?? slug(file2.job),
@@ -81848,18 +81915,34 @@ async function initCommand(argv, ctx) {
81848
81915
  ctx.out("");
81849
81916
  ctx.out(`Wrote ${shown3}:`);
81850
81917
  ctx.out("");
81851
- for (const line2 of text3.trimEnd().split("\n")) ctx.out(` ${line2}`);
81918
+ for (const line2 of text3.trimEnd().split("\n").slice(1)) ctx.out(` ${line2}`);
81852
81919
  ctx.out("");
81853
81920
  if (!file2.agents)
81854
81921
  ctx.out(
81855
81922
  "It names no agents, so run uses the one agent installed where it runs."
81856
81923
  );
81857
81924
  const custom2 = checkSetupText(path, text3).setup.customReason !== null;
81858
- ctx.out(
81859
- 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}`
81860
- );
81925
+ if (ctx.io.env.AGENTPICKS_NO_UPLOAD)
81926
+ ctx.out(`Run it with: agentpicks run ${name}`);
81927
+ else if (!signedIn(ctx.io)) {
81928
+ ctx.out(`Run it with: agentpicks run ${name} --no-upload`);
81929
+ ctx.out(
81930
+ `That needs no DevTune account. To upload its runs to DevTune, sign in with agentpicks login${custom2 ? `, then run agentpicks push ${name}` : ""}.`
81931
+ );
81932
+ } else
81933
+ ctx.out(
81934
+ 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}`
81935
+ );
81861
81936
  return 0;
81862
81937
  }
81938
+ function signedIn(io) {
81939
+ try {
81940
+ devtuneTarget(io);
81941
+ return true;
81942
+ } catch {
81943
+ return false;
81944
+ }
81945
+ }
81863
81946
  function parseInitArgs(argv) {
81864
81947
  try {
81865
81948
  const { values } = (0, import_node_util2.parseArgs)({
@@ -81999,13 +82082,14 @@ async function askCustomJob(wizard, line2) {
81999
82082
  }
82000
82083
  async function askRequest(wizard, intent, drafted) {
82001
82084
  const draft = drafted?.requests.find((r) => r.intent === intent)?.text;
82085
+ const optional2 = intent === "hosted";
82002
82086
  return ask(wizard, {
82003
- label: intent === "add" ? "The add request, which a run asks" : `The ${intent} request, or none`,
82004
- fallback: draft ?? (intent === "add" ? null : "none"),
82087
+ label: intent === "add" ? "The add request, which a run asks" : intent === "recommend" ? "The recommend request, which DevTune saves with the add request" : `The ${intent} request, or none`,
82088
+ fallback: draft ?? (optional2 ? "none" : null),
82005
82089
  read: (answer) => {
82006
- if (answer === "none" && intent !== "add") return { value: null };
82090
+ if (answer === "none" && optional2) return { value: null };
82007
82091
  return !badLength(answer) ? { value: answer } : {
82008
- problem: `Write the ${intent} request in ${SETUP_REQUEST_MIN_LENGTH} to ${SETUP_TEXT_MAX_LENGTH} characters${intent === "add" ? "" : ", or none"}.`
82092
+ problem: `Write the ${intent} request in ${SETUP_REQUEST_MIN_LENGTH} to ${SETUP_TEXT_MAX_LENGTH} characters${optional2 ? ", or none" : ""}.`
82009
82093
  };
82010
82094
  }
82011
82095
  });
@@ -82372,7 +82456,8 @@ async function loginCommand(argv, ctx) {
82372
82456
  baseUrl,
82373
82457
  notify: (url2) => ctx.out(
82374
82458
  `Open this address in a browser to sign in and choose your project:
82375
- ${url2}`
82459
+ ${url2}
82460
+ No DevTune project yet? Sign up at ${signUpUrl(baseUrl)} and create one, or have your coding agent set one up (${AGENT_SETUP_URL}), then run agentpicks login again.`
82376
82461
  ),
82377
82462
  openBrowser: args.noBrowser ? null : ctx.openBrowser ?? openBrowser,
82378
82463
  browserUnavailable: () => ctx.out(
@@ -82581,10 +82666,11 @@ function pullOne(setup, root, files, devtune, force, ctx) {
82581
82666
  writeSetupText(
82582
82667
  (0, import_node_path15.join)(root, SETUPS_DIR),
82583
82668
  path,
82584
- linkedSetupYaml(mapped.file, {
82669
+ `${SCHEMA_LINE}
82670
+ ${linkedSetupYaml(mapped.file, {
82585
82671
  id: setup.id,
82586
82672
  setupDigest: setup.snapshot_digest
82587
- }),
82673
+ })}`,
82588
82674
  { replace: force || local !== void 0, shown: (at) => shown(at, ctx) }
82589
82675
  );
82590
82676
  } catch (error62) {
@@ -85245,6 +85331,55 @@ function isDockerSandbox(box) {
85245
85331
  return "imageDigest" in box && typeof box.imageDigest === "function";
85246
85332
  }
85247
85333
 
85334
+ // src/cli/validate-command.ts
85335
+ var import_node_path18 = require("node:path");
85336
+ function validateCommand(argv, ctx) {
85337
+ const flag = argv.find((arg) => arg.startsWith("-"));
85338
+ if (flag)
85339
+ throw new UsageError(`agentpicks validate takes no flags, not ${flag}.`);
85340
+ const root = setupsRoot(ctx.cwd);
85341
+ const files = argv.length > 0 ? argv.map((arg) => {
85342
+ try {
85343
+ return readSetupFile(findSetup(arg, ctx.cwd));
85344
+ } catch (error62) {
85345
+ if (!(error62 instanceof UsageError)) throw error62;
85346
+ return { path: arg, error: error62.message };
85347
+ }
85348
+ }) : readSetupFiles(root);
85349
+ if (files.length === 0) {
85350
+ ctx.out(`${(0, import_node_path18.join)(root, SETUPS_DIR)} holds no setup files. ${WRITE_ONE}`);
85351
+ return 0;
85352
+ }
85353
+ let failed = 0;
85354
+ for (const file2 of files) {
85355
+ if ("error" in file2) {
85356
+ failed++;
85357
+ ctx.err(file2.error);
85358
+ continue;
85359
+ }
85360
+ if (file2.problems.length === 0) {
85361
+ ctx.out(`${(0, import_node_path18.relative)(ctx.cwd, file2.path) || file2.path}: valid`);
85362
+ continue;
85363
+ }
85364
+ failed++;
85365
+ for (const problem of file2.problems)
85366
+ ctx.err(formatProblem(file2.path, problem, ctx.cwd));
85367
+ }
85368
+ const count = files.length;
85369
+ ctx.out(
85370
+ `${count - failed} of ${count} setup file${count === 1 ? "" : "s"} valid.`
85371
+ );
85372
+ return failed === 0 ? 0 : 1;
85373
+ }
85374
+ function schemaCommand(argv, ctx) {
85375
+ if (argv.length > 0)
85376
+ throw new UsageError(
85377
+ `agentpicks schema takes no arguments, not ${argv[0]}.`
85378
+ );
85379
+ ctx.out(JSON.stringify(setupJsonSchema(), null, 2));
85380
+ return 0;
85381
+ }
85382
+
85248
85383
  // src/cli/main.ts
85249
85384
  var RUNNER = {
85250
85385
  name: "@devtune/agentpicks",
@@ -85262,6 +85397,7 @@ var USAGE = `Usage:
85262
85397
  agentpicks pull [<setup>] [--force]
85263
85398
  agentpicks push [<setup>]
85264
85399
  agentpicks validate [<setup>...]
85400
+ agentpicks schema
85265
85401
  agentpicks upload <dir>
85266
85402
  agentpicks results [<dir>...] [--json]
85267
85403
  agentpicks login [--no-browser]
@@ -85274,7 +85410,8 @@ init Writes a setup file, agentpicks/<name>.yaml, from questions whose defa
85274
85410
  of the same name. Signed in, DevTune drafts the requests and tools of your own job.
85275
85411
  run Tests the coding agent installed here in a fresh Docker container per run, writes
85276
85412
  one bundle per completed run to --out (default ./agentpicks-runs), and uploads it to
85277
- your DevTune project. --no-upload keeps bundles on this machine only. --repo tests
85413
+ your DevTune project. --no-upload keeps bundles on this machine only, as every run
85414
+ does while AGENTPICKS_NO_UPLOAD is set to anything. --repo tests
85278
85415
  your repository's committed files at HEAD, or at --ref; uncommitted changes aren't
85279
85416
  included. Uploading a --repo run needs the repository to have a remote.
85280
85417
  <setup> is a setup file's name in the repository's agentpicks folder, or its path,
@@ -85297,8 +85434,11 @@ push Saves a setup file, or every one, to DevTune and links it. A setup cha
85297
85434
  DevTune since the file last saw it is refused as setup_changed: pull first.
85298
85435
  validate Checks every setup file, or the ones named, against the setup schema and the
85299
85436
  catalogue. Exits non-zero if any fails, naming the file and field.
85437
+ schema Prints the setup file's JSON Schema, which is also at
85438
+ ${SETUP_SCHEMA_URL}
85300
85439
  upload Uploads a bundle directory, or every bundle in an --out directory. Uploading again
85301
- sends only what isn't stored yet. An unlinked custom setup's bundles are refused.
85440
+ sends only what isn't stored yet. A custom setup's bundle, or one of changes not
85441
+ pushed, uploads once agentpicks push has saved the add request and tools it tested.
85302
85442
  results Shows which tool each run in ./agentpicks-runs, or the directories named, picked: the
85303
85443
  packages it added, or the code or config file that shows the pick, read from its
85304
85444
  bundle as the run's early stop reads it. A run with no pick shows none, and one whose
@@ -85316,15 +85456,21 @@ A setup file, agentpicks/error-tracking.yaml:
85316
85456
  from: error-tracking
85317
85457
  stacks: [nextjs]
85318
85458
 
85319
- Its schema is schema/setup.v1.json in this package; the README describes every field.
85459
+ init and pull start each file with a line that points an editor at the schema; the README
85460
+ describes every field.
85320
85461
  `;
85321
85462
  var INTRO = `Test which tools coding agents pick when they build your kind of app.
85322
85463
 
85323
- agentpicks login Sign in to your DevTune project
85324
85464
  agentpicks init Write a setup file for this repository
85325
85465
  agentpicks run Run a setup with the coding agent installed here
85326
85466
  agentpicks results Show which tool each run picked
85327
85467
  agentpicks list List this repository's setups and your project's
85468
+ agentpicks login Sign in to DevTune to upload runs for its analysis
85469
+
85470
+ Runs need no DevTune account: pass --no-upload to run, or set AGENTPICKS_NO_UPLOAD=1, and
85471
+ bundles stay on this machine. To upload them later, sign up at ${signUpUrl()}
85472
+ and create a project, or have your coding agent set one up:
85473
+ ${AGENT_SETUP_URL}
85328
85474
 
85329
85475
  agentpicks --help lists every command and flag.`;
85330
85476
  function defaultContext(dockerfileDir) {
@@ -85381,6 +85527,7 @@ async function main(argv, given) {
85381
85527
  if (command === "pull") return await pullCommand(rest, ctx);
85382
85528
  if (command === "push") return await pushCommand(rest, ctx);
85383
85529
  if (command === "validate") return validateCommand(rest, ctx);
85530
+ if (command === "schema") return schemaCommand(rest, ctx);
85384
85531
  if (command === "results") return resultsCommand(rest, ctx);
85385
85532
  ctx.err(`agentpicks has no ${command} command.
85386
85533
 
@@ -85401,6 +85548,8 @@ function docker2(ctx) {
85401
85548
  }
85402
85549
  async function runCommand(argv, ctx) {
85403
85550
  const command = parseRunCommand(argv, { picker: Boolean(ctx.interactive) });
85551
+ if (ctx.io.env.AGENTPICKS_NO_UPLOAD)
85552
+ (command.kind === "category" ? command.args : command.flags).upload = false;
85404
85553
  if (command.kind === "category")
85405
85554
  return runPlan(
85406
85555
  categoryPlan(command.args, ctx.cwd),
@@ -85409,7 +85558,7 @@ async function runCommand(argv, ctx) {
85409
85558
  );
85410
85559
  const file2 = await runnableSetup(command.setup, ctx);
85411
85560
  if (file2 === null) return 1;
85412
- const shown3 = (0, import_node_path18.relative)(ctx.cwd, file2.path) || file2.path;
85561
+ const shown3 = (0, import_node_path19.relative)(ctx.cwd, file2.path) || file2.path;
85413
85562
  const plan = setupPlan(file2, command.flags, ctx.cwd);
85414
85563
  return runPlan(
85415
85564
  await linkUploads(plan, file2.setup, file2.content, shown3, ctx),
@@ -85449,7 +85598,7 @@ async function pickSetup(ctx) {
85449
85598
  const files = readSetupFiles(root);
85450
85599
  if (files.length === 0) {
85451
85600
  ctx.err(
85452
- `${(0, import_node_path18.join)(root, SETUPS_DIR)} holds no setup files. Write one with: agentpicks init
85601
+ `${(0, import_node_path19.join)(root, SETUPS_DIR)} holds no setup files. Write one with: agentpicks init
85453
85602
 
85454
85603
  Or run a built-in category: agentpicks run --category <category> --stack <stack>.`
85455
85604
  );
@@ -85497,7 +85646,7 @@ async function runPlan(given, ctx, link) {
85497
85646
  const platform = await dockerAccess.platform();
85498
85647
  for (const test of plan.tests) assertStackRuns(test.environment, platform);
85499
85648
  if (repository) assertRepositoryRuns(repository.install, platform);
85500
- const outDir = (0, import_node_path18.resolve)(ctx.cwd, plan.out);
85649
+ const outDir = (0, import_node_path19.resolve)(ctx.cwd, plan.out);
85501
85650
  const { runs } = plan;
85502
85651
  const cells = agentPlans.flatMap(
85503
85652
  (agentPlan, a) => plan.tests.map((test) => ({ agentPlan, a, test }))
@@ -85516,10 +85665,9 @@ async function runPlan(given, ctx, link) {
85516
85665
  );
85517
85666
  for (const each of credentials)
85518
85667
  for (const line2 of each.summary) ctx.out(line2);
85519
- if (target)
85520
- ctx.out(
85521
- `Uploads each bundle to DevTune project ${target.projectId} once it is written.`
85522
- );
85668
+ ctx.out(
85669
+ target ? `Uploads each bundle to DevTune project ${target.projectId} once it is written.` : `Keeps each bundle on this machine only. agentpicks upload ${shellArg(plan.out)} sends them to DevTune later.`
85670
+ );
85523
85671
  ctx.out(runRequirements());
85524
85672
  const image = await ensureSandboxImage({
85525
85673
  version: RUNNER.version,
@@ -85608,13 +85756,13 @@ async function uploadPrinted(dir, target, ctx, bundle) {
85608
85756
  if (!(error62 instanceof UploadError)) throw error62;
85609
85757
  ctx.err(error62.message);
85610
85758
  ctx.err(
85611
- `The bundle stays in ${dir}. Send it with: agentpicks upload ${dir}`
85759
+ `The bundle stays in ${dir}. Send it with: agentpicks upload ${shellArg(dir)}`
85612
85760
  );
85613
85761
  return false;
85614
85762
  }
85615
85763
  }
85616
85764
  async function uploadCommand(argv, ctx) {
85617
- const dirs = findBundles((0, import_node_path18.resolve)(ctx.cwd, parseUploadArgs(argv).dir));
85765
+ const dirs = findBundles((0, import_node_path19.resolve)(ctx.cwd, parseUploadArgs(argv).dir));
85618
85766
  let target;
85619
85767
  let uploaded = 0;
85620
85768
  for (const dir of dirs) {
@@ -85653,44 +85801,6 @@ async function uploadCommand(argv, ctx) {
85653
85801
  ctx.out(`${uploaded} of ${dirs.length} bundles uploaded to DevTune.`);
85654
85802
  return uploaded === dirs.length ? 0 : 1;
85655
85803
  }
85656
- function validateCommand(argv, ctx) {
85657
- const flag = argv.find((arg) => arg.startsWith("-"));
85658
- if (flag)
85659
- throw new UsageError(`agentpicks validate takes no flags, not ${flag}.`);
85660
- const root = setupsRoot(ctx.cwd);
85661
- const files = argv.length > 0 ? argv.map((arg) => {
85662
- try {
85663
- return readSetupFile(findSetup(arg, ctx.cwd));
85664
- } catch (error62) {
85665
- if (!(error62 instanceof UsageError)) throw error62;
85666
- return { path: arg, error: error62.message };
85667
- }
85668
- }) : readSetupFiles(root);
85669
- if (files.length === 0) {
85670
- ctx.out(`${(0, import_node_path18.join)(root, SETUPS_DIR)} holds no setup files. ${WRITE_ONE}`);
85671
- return 0;
85672
- }
85673
- let failed = 0;
85674
- for (const file2 of files) {
85675
- if ("error" in file2) {
85676
- failed++;
85677
- ctx.err(file2.error);
85678
- continue;
85679
- }
85680
- if (file2.problems.length === 0) {
85681
- ctx.out(`${(0, import_node_path18.relative)(ctx.cwd, file2.path) || file2.path}: valid`);
85682
- continue;
85683
- }
85684
- failed++;
85685
- for (const problem of file2.problems)
85686
- ctx.err(formatProblem(file2.path, problem, ctx.cwd));
85687
- }
85688
- const count = files.length;
85689
- ctx.out(
85690
- `${count - failed} of ${count} setup file${count === 1 ? "" : "s"} valid.`
85691
- );
85692
- return failed === 0 ? 0 : 1;
85693
- }
85694
85804
  async function cleanupCommand(ctx) {
85695
85805
  const dockerAccess = docker2(ctx);
85696
85806
  await dockerAccess.version();
@@ -85778,7 +85888,7 @@ function trackSandboxes(inner) {
85778
85888
  // src/cli.ts
85779
85889
  void main(
85780
85890
  process.argv.slice(2),
85781
- defaultContext((0, import_node_path19.join)(__dirname, "..", "docker"))
85891
+ defaultContext((0, import_node_path20.join)(__dirname, "..", "docker"))
85782
85892
  ).then((code) => {
85783
85893
  process.exitCode = code;
85784
85894
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devtune/agentpicks",
3
- "version": "0.4.3",
3
+ "version": "0.4.5",
4
4
  "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",
5
5
  "license": "Apache-2.0",
6
6
  "engines": {