@devtune/agentpicks 0.4.4 → 0.4.6

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 +11 -8
  2. package/dist/cli.js +190 -93
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -12,6 +12,8 @@ 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
+
15
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:
16
18
 
17
19
  ```sh
@@ -20,7 +22,7 @@ npx @devtune/agentpicks push
20
22
  npx @devtune/agentpicks upload ./agentpicks-runs
21
23
  ```
22
24
 
23
- A kept run uploads once its setup is pushed with the same `from`, add request and tools the run tested. See [Upload](#upload).
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).
24
26
 
25
27
  ## Requirements
26
28
 
@@ -46,7 +48,7 @@ agentpicks run --category error-tracking --repo .
46
48
  | `--agent` | `claude-code`, `codex`, `opencode` or `pi`. Required when several are installed. |
47
49
  | `--model` | The model to ask for. OpenCode and Pi take `anthropic/<model>` or `openai/<model>`. |
48
50
  | `--out` | Where bundles go. Default `./agentpicks-runs`. |
49
- | `--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)). |
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. |
50
52
 
51
53
  `agentpicks --help`, or `--help` after any command, prints the usage and exits successfully.
52
54
 
@@ -113,7 +115,7 @@ Either login is saved to `agentpicks/credentials.json` under `$XDG_CONFIG_HOME`,
113
115
 
114
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.
115
117
 
116
- `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.
117
119
 
118
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`.
119
121
 
@@ -157,6 +159,7 @@ agentpicks init --yes
157
159
  `agentpicks init` writes a setup file from a few questions. Each shows its default in brackets, and Enter takes it:
158
160
 
159
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.
160
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`.
161
164
  - **Competitors**: for a category, its tools; for your own job, typed as npm packages.
162
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).
@@ -219,7 +222,7 @@ runs: 3
219
222
  | `id` | The DevTune setup the file is linked to. `pull` and `push` write it. |
220
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. |
221
224
 
222
- `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.
223
226
 
224
227
  ```sh
225
228
  agentpicks run feature-flags --no-upload
@@ -250,7 +253,7 @@ agentpicks run add-feature-flags
250
253
 
251
254
  `agentpicks pull` writes each of the project's DevTune setups to `agentpicks/<name>.yaml`, or into the file already linked to it, with its `id` and `synced`; `pull <setup>` writes one. It leaves a file in sync alone, and refuses to replace a file with changes not yet pushed, or an unlinked file of that name, unless you pass `--force`. A setup's name is its `from` category for an unedited copy of one, else its job line in lowercase with dashes, cut at a word to at most 30 characters.
252
255
 
253
- `agentpicks push` saves every setup file to DevTune, and `push <setup>` one. A new file becomes a new DevTune setup, and push writes its `id` and `synced` into the file. A linked file in sync sends nothing. If the DevTune setup changed since the file last saw it, push refuses with `setup_changed` and saves nothing: pull it, apply your changes again, and push. A setup `from` a category saves as the project's setup of that category, its tools by key; a setup without `from` saves as a job. To add your own tool to a category copy, add it in the DevTune app, then run `agentpicks pull`: pull writes it as a full entry, and push refuses a full entry DevTune doesn't hold as written. DevTune doesn't send the signals of its catalogue's tools, so pull writes a catalogue tool by its key, in a job as in a copy, and push sends the key for DevTune to fill in its signals. A job can name, by key, any tool of a category DevTune publishes; a copy names its category's tools, and another only once it is added to the copy in the DevTune app and pulled. What a file can't say, such as agent models and a job's building blocks, push sends as DevTune holds it. For a new file with `repo`, push detects the repository's stacks from its manifests and lockfiles and saves those to DevTune. The file keeps `repo`, so `run <setup>` still tests your repository. If no supported stack is detected, replace `repo` with `stacks` before pushing and pass `--repo` when running. A linked file with `repo` keeps the stacks DevTune already holds.
256
+ `agentpicks push` saves every setup file to DevTune, and `push <setup>` one. A new file becomes a new DevTune setup, and push writes its `id` and `synced` into the file. A linked file in sync sends nothing. If the DevTune setup changed since the file last saw it, push refuses with `setup_changed` and saves nothing: pull it, apply your changes again, and push. A setup `from` a category saves as the project's setup of that category. Adding or editing a full entry (`key`, `name` and `signals`) for a tool outside DevTune's catalogue, or adding a catalogue tool by key outside the category, saves the category's copy with those tools. Use catalogue keys alone; a full entry with edited catalogue signals is refused. A tool from DevTune's catalogue goes by key alone: `pull` writes it that way, and DevTune fills in its signals when you push. A job or copy can name, by key, any tool of a category DevTune publishes. When adding or editing tools this way, keep `requests.add` and `requests.recommend` as text and `requests.improve` at its inherited or pulled value. Push the tools first, then push any supported request omissions or improve changes separately; `requests.hosted: null` can be saved with the tools. What a file can't say, such as agent models and a job's building blocks, push keeps as DevTune holds it. For a new file with `repo`, push detects the repository's stacks from its manifests and lockfiles and saves those to DevTune. The file keeps `repo`, so `run <setup>` still tests your repository. If no supported stack is detected, replace `repo` with `stacks` before pushing and pass `--repo` when running. A linked file with `repo` keeps the stacks DevTune already holds.
254
257
 
255
258
  `agentpicks run <name>` also runs a DevTune setup that has no file here, by the name `list` shows, and its runs upload under that setup. A job, or a copy that asks an add request of its own, is refused before Docker starts: anyone who can edit the setup in DevTune could change that request, and the agent runs it with your keys. `agentpicks pull` it and run the file.
256
259
 
@@ -278,7 +281,7 @@ jobs:
278
281
  steps:
279
282
  - uses: actions/checkout@v5
280
283
  - run: npm install -g @anthropic-ai/claude-code@2.1.323
281
- - uses: devtunehq/agentpicks@v0.4.4
284
+ - uses: devtunehq/agentpicks@v0.4.6
282
285
  with:
283
286
  setup: agentpicks/error-tracking.yaml
284
287
  agent: claude-code
@@ -292,7 +295,7 @@ jobs:
292
295
 
293
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.
294
297
 
295
- Pin a release tag, such as `v0.4.4`. 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.6`. 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.
296
299
 
297
300
  | Input | Passed as |
298
301
  |---|---|
@@ -333,7 +336,7 @@ Install Docker, Node.js 20 or later and the agent, set `DEVTUNE_API_KEY`, `DEVTU
333
336
 
334
337
  ```sh
335
338
  npm install -g @anthropic-ai/claude-code@2.1.323
336
- npx --yes @devtune/agentpicks@0.4.4 run error-tracking --agent claude-code
339
+ npx --yes @devtune/agentpicks@0.4.6 run error-tracking --agent claude-code
337
340
  ```
338
341
 
339
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.4",
7378
+ version: "0.4.6",
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 = {
@@ -28673,11 +28676,10 @@ function resolveSetup(name, file2, held) {
28673
28676
  }
28674
28677
  const row = held?.find((each) => each.tool_key === ref);
28675
28678
  if (file2.from) {
28676
- const unchecked = !held && file2.id && CATALOGUE_TOOL_KEYS.has(ref);
28677
- if (!catalogueKeys.includes(ref) && !row && !unchecked)
28679
+ if (!catalogueKeys.includes(ref) && !row && !CATALOGUE_TOOL_KEYS.has(ref))
28678
28680
  problems.push({
28679
28681
  field,
28680
- message: `${file2.from} has no tool ${ref}. Use one of ${catalogueKeys.join(", ")}, or add ${ref} to a category copy in the DevTune app, then run agentpicks pull.`
28682
+ message: `${file2.from} has no tool ${ref}. Give the full entry: key, name and signals, and optionally domain; or, for a tool DevTune's catalogue has added since, update agentpicks.`
28681
28683
  });
28682
28684
  } else if (!CATALOGUE_TOOL_KEYS.has(ref) && row?.signals !== null)
28683
28685
  problems.push({
@@ -28870,10 +28872,10 @@ function mergeEarlyStop(base, entries2, listedKeys) {
28870
28872
  const configNames = unique(
28871
28873
  stopping.flatMap((tool) => tool.signals.configNames ?? [])
28872
28874
  ).map(escapeEre);
28873
- const join15 = (inherited, added) => [inherited, ...added].filter(Boolean).join("|") || NEVER_PATTERN;
28875
+ const join16 = (inherited, added) => [inherited, ...added].filter(Boolean).join("|") || NEVER_PATTERN;
28874
28876
  return {
28875
- installPattern: join15(base?.installPattern, packages),
28876
- codePattern: join15(base?.codePattern, configNames),
28877
+ installPattern: join16(base?.installPattern, packages),
28878
+ codePattern: join16(base?.codePattern, configNames),
28877
28879
  ...base?.pathPattern ? { pathPattern: base.pathPattern } : {}
28878
28880
  };
28879
28881
  }
@@ -35628,6 +35630,13 @@ var setupFileSchema = external_exports.object({
35628
35630
  ),
35629
35631
  runs: external_exports.number().int().min(1).max(100).optional().describe("How many runs per agent and stack. Default 1.")
35630
35632
  }).strict();
35633
+ function setupJsonSchema() {
35634
+ return {
35635
+ ...external_exports.toJSONSchema(setupFileSchema, { io: "input" }),
35636
+ title: "Agent Picks setup",
35637
+ 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."
35638
+ };
35639
+ }
35631
35640
 
35632
35641
  // src/setup/files.ts
35633
35642
  var SETUPS_DIR = "agentpicks";
@@ -80096,11 +80105,27 @@ function pushRequest(file2, current, list, shown3, repositoryStacks) {
80096
80105
  ...current ? { setup: current.id } : {}
80097
80106
  };
80098
80107
  if (from) {
80099
- for (const ref of tools)
80100
- if (typeof ref === "string" ? !CATEGORY_TOOLS[from.slug]?.includes(ref) && !current?.tools.some((row) => row.tool_key === ref) : !heldAsWritten(ref, current))
80108
+ const named = [
80109
+ ...file2.tools?.own !== void 0 ? [{ ref: file2.tools.own, field: "tools.own" }] : [],
80110
+ ...(file2.tools?.competitors ?? []).map((ref, index) => ({
80111
+ ref,
80112
+ field: `tools.competitors[${index}]`
80113
+ }))
80114
+ ];
80115
+ for (const { ref, field } of named)
80116
+ if (typeof ref !== "string" && CATALOGUE_TOOL_KEYS.has(ref.key) && !heldAsWritten(ref, current))
80101
80117
  throw new UsageError(
80102
- `${shown3}: ${key(ref)} isn't a tool of ${from.slug}. Add it to a category copy in the DevTune app, then run agentpicks pull.`
80118
+ `${shown3}: ${field}: ${ref.key} is a catalogue tool. Use the key alone (${ref.key}), so pull and push keep the same tool.`
80103
80119
  );
80120
+ }
80121
+ const writesCopy = from && tools.some(
80122
+ (ref) => typeof ref === "string" ? !CATEGORY_TOOLS[from.slug]?.includes(ref) && !current?.tools.some((row) => row.tool_key === ref) : !heldAsWritten(ref, current)
80123
+ );
80124
+ if (writesCopy && current?.kind === "category")
80125
+ throw new UsageError(
80126
+ `${shown3}: this file is linked to a public-category setup, which can't add tools through push. Create a category copy in the DevTune app, pull that copy, then add your tools to its file and push again.`
80127
+ );
80128
+ if (from && !writesCopy) {
80104
80129
  return {
80105
80130
  route: "setup",
80106
80131
  body: {
@@ -80112,11 +80137,12 @@ function pushRequest(file2, current, list, shown3, repositoryStacks) {
80112
80137
  }
80113
80138
  };
80114
80139
  }
80115
- if (file2.requests?.improve != null)
80140
+ if (!from && file2.requests?.improve != null)
80116
80141
  throw new UsageError(
80117
80142
  `${shown3}: requests.improve can't be saved on a job. Remove it, and change it in DevTune instead.`
80118
80143
  );
80119
- const recommend = file2.requests?.recommend;
80144
+ const copyRequests = from ? categoryJobRequests(file2, current, from, shown3) : null;
80145
+ const recommend = copyRequests?.recommend ?? file2.requests?.recommend;
80120
80146
  if (!recommend)
80121
80147
  throw new UsageError(
80122
80148
  `${shown3}: give requests.recommend. DevTune saves a job with its add and recommend requests.`
@@ -80129,18 +80155,23 @@ function pushRequest(file2, current, list, shown3, repositoryStacks) {
80129
80155
  return {
80130
80156
  route: "job",
80131
80157
  body: {
80132
- job: file2.job,
80133
- source_category_id: null,
80134
- requests: {
80158
+ job: from ? current?.name ?? from.name : file2.job,
80159
+ source_category_id: from ? categoryId(list, from.slug, shown3) : null,
80160
+ requests: copyRequests ?? {
80135
80161
  add: file2.requests?.add,
80136
80162
  recommend,
80137
80163
  hosted: file2.requests?.hosted ?? null
80138
80164
  },
80139
- building_blocks: current?.building_blocks ?? NO_BUILDING_BLOCKS,
80165
+ ...!from ? { building_blocks: current?.building_blocks ?? NO_BUILDING_BLOCKS } : {},
80140
80166
  tools: [
80141
80167
  ...tools.map((ref) => jobTool(ref, current)),
80142
- // A tool DevTune measures that is neither yours nor a competitor, which a file can't name.
80143
- ...(current?.tools ?? []).filter((row) => !listed.has(row.tool_key) && !held.has(row.tool_key)).map(heldJobTool)
80168
+ // A new copy inherits every category tool, including ones the file doesn't select.
80169
+ ...(from && !current ? CATEGORY_TOOLS[from.slug] ?? [] : []).filter((tool) => !listed.has(tool)).map((tool_key) => ({ tool_key })),
80170
+ // A tool DevTune measures that is neither yours nor a competitor, which a file can't name. A copy keeps every
80171
+ // tool it holds, as the setup route does; only a job drops a tool its file stops selecting.
80172
+ ...(current?.tools ?? []).filter(
80173
+ (row) => !listed.has(row.tool_key) && (from || !held.has(row.tool_key))
80174
+ ).map(heldJobTool)
80144
80175
  ],
80145
80176
  own_tool_key: file2.tools?.own === void 0 ? null : key(file2.tools.own),
80146
80177
  competitor_tool_keys: (file2.tools?.competitors ?? []).map(key),
@@ -80148,6 +80179,27 @@ function pushRequest(file2, current, list, shown3, repositoryStacks) {
80148
80179
  }
80149
80180
  };
80150
80181
  }
80182
+ function categoryJobRequests(file2, current, from, shown3) {
80183
+ const published = (intent) => from.prompts.find((prompt) => prompt.intent === intent)?.text ?? null;
80184
+ const effective = (intent) => file2.requests?.[intent] === void 0 ? published(intent) : file2.requests[intent];
80185
+ const improve = effective("improve");
80186
+ const heldImprove = current ? current.requests.improve ?? null : published("improve");
80187
+ if (improve !== heldImprove)
80188
+ throw new UsageError(
80189
+ `${shown3}: requests.improve can't be changed while push saves tools to a category copy. Keep the inherited or pulled requests.improve value, then push again.`
80190
+ );
80191
+ const add = effective("add");
80192
+ const recommend = effective("recommend");
80193
+ for (const [intent, text3] of [
80194
+ ["add", add],
80195
+ ["recommend", recommend]
80196
+ ])
80197
+ if (!text3)
80198
+ throw new UsageError(
80199
+ `${shown3}: requests.${intent} can't be left out while push saves tools to a category copy. Give its text, push the tools, then push the omission separately.`
80200
+ );
80201
+ return { add, recommend, hosted: effective("hosted") };
80202
+ }
80151
80203
  var OMITTED_REQUEST = "omitted";
80152
80204
  function setupRequests(file2, current, from) {
80153
80205
  const requests = {};
@@ -80727,6 +80779,10 @@ function apiRoot(value) {
80727
80779
  return null;
80728
80780
  return url2.href.replace(/\/$/, "");
80729
80781
  }
80782
+ function signUpUrl(baseUrl = DEFAULT_API_BASE_URL) {
80783
+ return new URL("/auth/sign-up", baseUrl).href;
80784
+ }
80785
+ var AGENT_SETUP_URL = "https://docs.devtune.ai/getting-started/agent-setup";
80730
80786
  function apiBaseUrl(env) {
80731
80787
  const value = env.DEVTUNE_API_BASE_URL || DEFAULT_API_BASE_URL;
80732
80788
  const root = apiRoot(value);
@@ -80774,7 +80830,7 @@ function devtuneTarget(io, purpose = "upload") {
80774
80830
  const projectId = io.env.DEVTUNE_PROJECT_ID || saved?.projectId;
80775
80831
  if (!apiKey || !projectId)
80776
80832
  throw new NotLoggedInError(
80777
- 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."
80833
+ 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."
80778
80834
  );
80779
80835
  if (io.env.DEVTUNE_API_KEY) assertApiKey(apiKey, "DEVTUNE_API_KEY");
80780
80836
  if (!external_exports.uuid().safeParse(projectId).success)
@@ -80969,6 +81025,8 @@ async function readSecretLine(prompt) {
80969
81025
  var import_node_crypto8 = require("node:crypto");
80970
81026
  var import_node_fs5 = require("node:fs");
80971
81027
  var import_node_path9 = require("node:path");
81028
+ var SETUP_SCHEMA_URL = `https://raw.githubusercontent.com/devtunehq/agentpicks/v${package_default.version}/schema/setup.v1.json`;
81029
+ var SCHEMA_LINE = `# yaml-language-server: $schema=${SETUP_SCHEMA_URL}`;
80972
81030
  function isSymlink(path) {
80973
81031
  try {
80974
81032
  return (0, import_node_fs5.lstatSync)(path).isSymbolicLink();
@@ -81100,10 +81158,6 @@ async function linkUploads(plan, setup, content, shown3, ctx) {
81100
81158
  }
81101
81159
  } : plan;
81102
81160
  if (setup.id === null) {
81103
- if (setup.customReason && content && hasOwnTools(content))
81104
- throw new UsageError(
81105
- `${shown3} is a custom setup (${setup.customReason}), so its runs have no DevTune setup to upload under, and push can't save tools ${setup.from} doesn't have. Add them to a category copy in the DevTune app, run agentpicks pull, and run the pulled setup, or pass --no-upload to keep the bundles on this machine.`
81106
- );
81107
81161
  if (setup.customReason)
81108
81162
  throw new UsageError(
81109
81163
  `${shown3} is a custom setup (${setup.customReason}), so its runs have no DevTune setup to upload under. Run agentpicks push ${setup.name} to save it to DevTune first, or pass --no-upload to keep the bundles on this machine.`
@@ -81164,7 +81218,7 @@ function pushedSince(record2, dir, shown3, ctx) {
81164
81218
  `${shown3} tested a version of ${record2.name} that the file no longer holds, so no push can save what it tested. ${runAgain}`
81165
81219
  );
81166
81220
  throw new UsageError(
81167
- `${shown3} tested what ${record2.name} holds now, which isn't saved to DevTune yet. Run agentpicks push ${record2.name}, then agentpicks upload ${dir} again.`
81221
+ `${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.`
81168
81222
  );
81169
81223
  }
81170
81224
  if (!asked || record2.id && record2.id !== content.id)
@@ -81872,7 +81926,8 @@ async function initCommand(argv, ctx) {
81872
81926
  });
81873
81927
  if (runs !== 1) file2.runs = runs;
81874
81928
  const dir = (0, import_node_path13.join)(wizard.detected.root, SETUPS_DIR);
81875
- const text3 = (0, import_yaml5.stringify)(file2);
81929
+ const text3 = `${SCHEMA_LINE}
81930
+ ${(0, import_yaml5.stringify)(file2)}`;
81876
81931
  const name = await ask(wizard, {
81877
81932
  label: "Name",
81878
81933
  fallback: file2.from ?? slug(file2.job),
@@ -81898,18 +81953,34 @@ async function initCommand(argv, ctx) {
81898
81953
  ctx.out("");
81899
81954
  ctx.out(`Wrote ${shown3}:`);
81900
81955
  ctx.out("");
81901
- for (const line2 of text3.trimEnd().split("\n")) ctx.out(` ${line2}`);
81956
+ for (const line2 of text3.trimEnd().split("\n").slice(1)) ctx.out(` ${line2}`);
81902
81957
  ctx.out("");
81903
81958
  if (!file2.agents)
81904
81959
  ctx.out(
81905
81960
  "It names no agents, so run uses the one agent installed where it runs."
81906
81961
  );
81907
81962
  const custom2 = checkSetupText(path, text3).setup.customReason !== null;
81908
- ctx.out(
81909
- 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}`
81910
- );
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}`
81973
+ );
81911
81974
  return 0;
81912
81975
  }
81976
+ function signedIn(io) {
81977
+ try {
81978
+ devtuneTarget(io);
81979
+ return true;
81980
+ } catch {
81981
+ return false;
81982
+ }
81983
+ }
81913
81984
  function parseInitArgs(argv) {
81914
81985
  try {
81915
81986
  const { values } = (0, import_node_util2.parseArgs)({
@@ -82049,13 +82120,14 @@ async function askCustomJob(wizard, line2) {
82049
82120
  }
82050
82121
  async function askRequest(wizard, intent, drafted) {
82051
82122
  const draft = drafted?.requests.find((r) => r.intent === intent)?.text;
82123
+ const optional2 = intent === "hosted";
82052
82124
  return ask(wizard, {
82053
- label: intent === "add" ? "The add request, which a run asks" : `The ${intent} request, or none`,
82054
- fallback: draft ?? (intent === "add" ? null : "none"),
82125
+ 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`,
82126
+ fallback: draft ?? (optional2 ? "none" : null),
82055
82127
  read: (answer) => {
82056
- if (answer === "none" && intent !== "add") return { value: null };
82128
+ if (answer === "none" && optional2) return { value: null };
82057
82129
  return !badLength(answer) ? { value: answer } : {
82058
- problem: `Write the ${intent} request in ${SETUP_REQUEST_MIN_LENGTH} to ${SETUP_TEXT_MAX_LENGTH} characters${intent === "add" ? "" : ", or none"}.`
82130
+ problem: `Write the ${intent} request in ${SETUP_REQUEST_MIN_LENGTH} to ${SETUP_TEXT_MAX_LENGTH} characters${optional2 ? ", or none" : ""}.`
82059
82131
  };
82060
82132
  }
82061
82133
  });
@@ -82422,7 +82494,8 @@ async function loginCommand(argv, ctx) {
82422
82494
  baseUrl,
82423
82495
  notify: (url2) => ctx.out(
82424
82496
  `Open this address in a browser to sign in and choose your project:
82425
- ${url2}`
82497
+ ${url2}
82498
+ 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.`
82426
82499
  ),
82427
82500
  openBrowser: args.noBrowser ? null : ctx.openBrowser ?? openBrowser,
82428
82501
  browserUnavailable: () => ctx.out(
@@ -82631,10 +82704,11 @@ function pullOne(setup, root, files, devtune, force, ctx) {
82631
82704
  writeSetupText(
82632
82705
  (0, import_node_path15.join)(root, SETUPS_DIR),
82633
82706
  path,
82634
- linkedSetupYaml(mapped.file, {
82707
+ `${SCHEMA_LINE}
82708
+ ${linkedSetupYaml(mapped.file, {
82635
82709
  id: setup.id,
82636
82710
  setupDigest: setup.snapshot_digest
82637
- }),
82711
+ })}`,
82638
82712
  { replace: force || local !== void 0, shown: (at) => shown(at, ctx) }
82639
82713
  );
82640
82714
  } catch (error62) {
@@ -85295,6 +85369,55 @@ function isDockerSandbox(box) {
85295
85369
  return "imageDigest" in box && typeof box.imageDigest === "function";
85296
85370
  }
85297
85371
 
85372
+ // src/cli/validate-command.ts
85373
+ var import_node_path18 = require("node:path");
85374
+ function validateCommand(argv, ctx) {
85375
+ const flag = argv.find((arg) => arg.startsWith("-"));
85376
+ if (flag)
85377
+ throw new UsageError(`agentpicks validate takes no flags, not ${flag}.`);
85378
+ const root = setupsRoot(ctx.cwd);
85379
+ const files = argv.length > 0 ? argv.map((arg) => {
85380
+ try {
85381
+ return readSetupFile(findSetup(arg, ctx.cwd));
85382
+ } catch (error62) {
85383
+ if (!(error62 instanceof UsageError)) throw error62;
85384
+ return { path: arg, error: error62.message };
85385
+ }
85386
+ }) : readSetupFiles(root);
85387
+ if (files.length === 0) {
85388
+ ctx.out(`${(0, import_node_path18.join)(root, SETUPS_DIR)} holds no setup files. ${WRITE_ONE}`);
85389
+ return 0;
85390
+ }
85391
+ let failed = 0;
85392
+ for (const file2 of files) {
85393
+ if ("error" in file2) {
85394
+ failed++;
85395
+ ctx.err(file2.error);
85396
+ continue;
85397
+ }
85398
+ if (file2.problems.length === 0) {
85399
+ ctx.out(`${(0, import_node_path18.relative)(ctx.cwd, file2.path) || file2.path}: valid`);
85400
+ continue;
85401
+ }
85402
+ failed++;
85403
+ for (const problem of file2.problems)
85404
+ ctx.err(formatProblem(file2.path, problem, ctx.cwd));
85405
+ }
85406
+ const count = files.length;
85407
+ ctx.out(
85408
+ `${count - failed} of ${count} setup file${count === 1 ? "" : "s"} valid.`
85409
+ );
85410
+ return failed === 0 ? 0 : 1;
85411
+ }
85412
+ function schemaCommand(argv, ctx) {
85413
+ if (argv.length > 0)
85414
+ throw new UsageError(
85415
+ `agentpicks schema takes no arguments, not ${argv[0]}.`
85416
+ );
85417
+ ctx.out(JSON.stringify(setupJsonSchema(), null, 2));
85418
+ return 0;
85419
+ }
85420
+
85298
85421
  // src/cli/main.ts
85299
85422
  var RUNNER = {
85300
85423
  name: "@devtune/agentpicks",
@@ -85312,6 +85435,7 @@ var USAGE = `Usage:
85312
85435
  agentpicks pull [<setup>] [--force]
85313
85436
  agentpicks push [<setup>]
85314
85437
  agentpicks validate [<setup>...]
85438
+ agentpicks schema
85315
85439
  agentpicks upload <dir>
85316
85440
  agentpicks results [<dir>...] [--json]
85317
85441
  agentpicks login [--no-browser]
@@ -85324,7 +85448,8 @@ init Writes a setup file, agentpicks/<name>.yaml, from questions whose defa
85324
85448
  of the same name. Signed in, DevTune drafts the requests and tools of your own job.
85325
85449
  run Tests the coding agent installed here in a fresh Docker container per run, writes
85326
85450
  one bundle per completed run to --out (default ./agentpicks-runs), and uploads it to
85327
- your DevTune project. --no-upload keeps bundles on this machine only. --repo tests
85451
+ your DevTune project. --no-upload keeps bundles on this machine only, as every run
85452
+ does while AGENTPICKS_NO_UPLOAD is set to anything. --repo tests
85328
85453
  your repository's committed files at HEAD, or at --ref; uncommitted changes aren't
85329
85454
  included. Uploading a --repo run needs the repository to have a remote.
85330
85455
  <setup> is a setup file's name in the repository's agentpicks folder, or its path,
@@ -85347,6 +85472,8 @@ push Saves a setup file, or every one, to DevTune and links it. A setup cha
85347
85472
  DevTune since the file last saw it is refused as setup_changed: pull first.
85348
85473
  validate Checks every setup file, or the ones named, against the setup schema and the
85349
85474
  catalogue. Exits non-zero if any fails, naming the file and field.
85475
+ schema Prints the setup file's JSON Schema, which is also at
85476
+ ${SETUP_SCHEMA_URL}
85350
85477
  upload Uploads a bundle directory, or every bundle in an --out directory. Uploading again
85351
85478
  sends only what isn't stored yet. A custom setup's bundle, or one of changes not
85352
85479
  pushed, uploads once agentpicks push has saved the add request and tools it tested.
@@ -85367,15 +85494,21 @@ A setup file, agentpicks/error-tracking.yaml:
85367
85494
  from: error-tracking
85368
85495
  stacks: [nextjs]
85369
85496
 
85370
- Its schema is schema/setup.v1.json in this package; the README describes every field.
85497
+ init and pull start each file with a line that points an editor at the schema; the README
85498
+ describes every field.
85371
85499
  `;
85372
85500
  var INTRO = `Test which tools coding agents pick when they build your kind of app.
85373
85501
 
85374
- agentpicks login Sign in to your DevTune project
85375
85502
  agentpicks init Write a setup file for this repository
85376
85503
  agentpicks run Run a setup with the coding agent installed here
85377
85504
  agentpicks results Show which tool each run picked
85378
85505
  agentpicks list List this repository's setups and your project's
85506
+ agentpicks login Sign in to DevTune to upload runs for its analysis
85507
+
85508
+ Runs need no DevTune account: pass --no-upload to run, or set AGENTPICKS_NO_UPLOAD=1, and
85509
+ bundles stay on this machine. To upload them later, sign up at ${signUpUrl()}
85510
+ and create a project, or have your coding agent set one up:
85511
+ ${AGENT_SETUP_URL}
85379
85512
 
85380
85513
  agentpicks --help lists every command and flag.`;
85381
85514
  function defaultContext(dockerfileDir) {
@@ -85432,6 +85565,7 @@ async function main(argv, given) {
85432
85565
  if (command === "pull") return await pullCommand(rest, ctx);
85433
85566
  if (command === "push") return await pushCommand(rest, ctx);
85434
85567
  if (command === "validate") return validateCommand(rest, ctx);
85568
+ if (command === "schema") return schemaCommand(rest, ctx);
85435
85569
  if (command === "results") return resultsCommand(rest, ctx);
85436
85570
  ctx.err(`agentpicks has no ${command} command.
85437
85571
 
@@ -85452,6 +85586,8 @@ function docker2(ctx) {
85452
85586
  }
85453
85587
  async function runCommand(argv, ctx) {
85454
85588
  const command = parseRunCommand(argv, { picker: Boolean(ctx.interactive) });
85589
+ if (ctx.io.env.AGENTPICKS_NO_UPLOAD)
85590
+ (command.kind === "category" ? command.args : command.flags).upload = false;
85455
85591
  if (command.kind === "category")
85456
85592
  return runPlan(
85457
85593
  categoryPlan(command.args, ctx.cwd),
@@ -85460,7 +85596,7 @@ async function runCommand(argv, ctx) {
85460
85596
  );
85461
85597
  const file2 = await runnableSetup(command.setup, ctx);
85462
85598
  if (file2 === null) return 1;
85463
- const shown3 = (0, import_node_path18.relative)(ctx.cwd, file2.path) || file2.path;
85599
+ const shown3 = (0, import_node_path19.relative)(ctx.cwd, file2.path) || file2.path;
85464
85600
  const plan = setupPlan(file2, command.flags, ctx.cwd);
85465
85601
  return runPlan(
85466
85602
  await linkUploads(plan, file2.setup, file2.content, shown3, ctx),
@@ -85500,7 +85636,7 @@ async function pickSetup(ctx) {
85500
85636
  const files = readSetupFiles(root);
85501
85637
  if (files.length === 0) {
85502
85638
  ctx.err(
85503
- `${(0, import_node_path18.join)(root, SETUPS_DIR)} holds no setup files. Write one with: agentpicks init
85639
+ `${(0, import_node_path19.join)(root, SETUPS_DIR)} holds no setup files. Write one with: agentpicks init
85504
85640
 
85505
85641
  Or run a built-in category: agentpicks run --category <category> --stack <stack>.`
85506
85642
  );
@@ -85548,7 +85684,7 @@ async function runPlan(given, ctx, link) {
85548
85684
  const platform = await dockerAccess.platform();
85549
85685
  for (const test of plan.tests) assertStackRuns(test.environment, platform);
85550
85686
  if (repository) assertRepositoryRuns(repository.install, platform);
85551
- const outDir = (0, import_node_path18.resolve)(ctx.cwd, plan.out);
85687
+ const outDir = (0, import_node_path19.resolve)(ctx.cwd, plan.out);
85552
85688
  const { runs } = plan;
85553
85689
  const cells = agentPlans.flatMap(
85554
85690
  (agentPlan, a) => plan.tests.map((test) => ({ agentPlan, a, test }))
@@ -85567,10 +85703,9 @@ async function runPlan(given, ctx, link) {
85567
85703
  );
85568
85704
  for (const each of credentials)
85569
85705
  for (const line2 of each.summary) ctx.out(line2);
85570
- if (target)
85571
- ctx.out(
85572
- `Uploads each bundle to DevTune project ${target.projectId} once it is written.`
85573
- );
85706
+ ctx.out(
85707
+ 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.`
85708
+ );
85574
85709
  ctx.out(runRequirements());
85575
85710
  const image = await ensureSandboxImage({
85576
85711
  version: RUNNER.version,
@@ -85659,13 +85794,13 @@ async function uploadPrinted(dir, target, ctx, bundle) {
85659
85794
  if (!(error62 instanceof UploadError)) throw error62;
85660
85795
  ctx.err(error62.message);
85661
85796
  ctx.err(
85662
- `The bundle stays in ${dir}. Send it with: agentpicks upload ${dir}`
85797
+ `The bundle stays in ${dir}. Send it with: agentpicks upload ${shellArg(dir)}`
85663
85798
  );
85664
85799
  return false;
85665
85800
  }
85666
85801
  }
85667
85802
  async function uploadCommand(argv, ctx) {
85668
- const dirs = findBundles((0, import_node_path18.resolve)(ctx.cwd, parseUploadArgs(argv).dir));
85803
+ const dirs = findBundles((0, import_node_path19.resolve)(ctx.cwd, parseUploadArgs(argv).dir));
85669
85804
  let target;
85670
85805
  let uploaded = 0;
85671
85806
  for (const dir of dirs) {
@@ -85704,44 +85839,6 @@ async function uploadCommand(argv, ctx) {
85704
85839
  ctx.out(`${uploaded} of ${dirs.length} bundles uploaded to DevTune.`);
85705
85840
  return uploaded === dirs.length ? 0 : 1;
85706
85841
  }
85707
- function validateCommand(argv, ctx) {
85708
- const flag = argv.find((arg) => arg.startsWith("-"));
85709
- if (flag)
85710
- throw new UsageError(`agentpicks validate takes no flags, not ${flag}.`);
85711
- const root = setupsRoot(ctx.cwd);
85712
- const files = argv.length > 0 ? argv.map((arg) => {
85713
- try {
85714
- return readSetupFile(findSetup(arg, ctx.cwd));
85715
- } catch (error62) {
85716
- if (!(error62 instanceof UsageError)) throw error62;
85717
- return { path: arg, error: error62.message };
85718
- }
85719
- }) : readSetupFiles(root);
85720
- if (files.length === 0) {
85721
- ctx.out(`${(0, import_node_path18.join)(root, SETUPS_DIR)} holds no setup files. ${WRITE_ONE}`);
85722
- return 0;
85723
- }
85724
- let failed = 0;
85725
- for (const file2 of files) {
85726
- if ("error" in file2) {
85727
- failed++;
85728
- ctx.err(file2.error);
85729
- continue;
85730
- }
85731
- if (file2.problems.length === 0) {
85732
- ctx.out(`${(0, import_node_path18.relative)(ctx.cwd, file2.path) || file2.path}: valid`);
85733
- continue;
85734
- }
85735
- failed++;
85736
- for (const problem of file2.problems)
85737
- ctx.err(formatProblem(file2.path, problem, ctx.cwd));
85738
- }
85739
- const count = files.length;
85740
- ctx.out(
85741
- `${count - failed} of ${count} setup file${count === 1 ? "" : "s"} valid.`
85742
- );
85743
- return failed === 0 ? 0 : 1;
85744
- }
85745
85842
  async function cleanupCommand(ctx) {
85746
85843
  const dockerAccess = docker2(ctx);
85747
85844
  await dockerAccess.version();
@@ -85829,7 +85926,7 @@ function trackSandboxes(inner) {
85829
85926
  // src/cli.ts
85830
85927
  void main(
85831
85928
  process.argv.slice(2),
85832
- defaultContext((0, import_node_path19.join)(__dirname, "..", "docker"))
85929
+ defaultContext((0, import_node_path20.join)(__dirname, "..", "docker"))
85833
85930
  ).then((code) => {
85834
85931
  process.exitCode = code;
85835
85932
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devtune/agentpicks",
3
- "version": "0.4.4",
3
+ "version": "0.4.6",
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": {