@ancha-labs/cli 0.4.42 → 0.4.43

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.
@@ -43,6 +43,7 @@ Add `--json` to every command. Runs print NDJSON events that end with `run_finis
43
43
  ```
44
44
  - The install follows the project's own manifests and lockfiles; `agent.install` in `ancha.yaml` sets the command instead.
45
45
  6. **Without production traces.** For an agent that calls NetSuite directly, `ancha init` writes a NetSuite world of a private-equity portfolio company (four subsidiaries, two currencies, thousands of transactions) and 25 tests: 10 read tasks and 15 write workflows. For an agent that uses QuickBooks, it writes Pellmont Building Services' 2025 books and two tests: `pellmont-duplicates` reports the duplicate vendors, the invoices and bills entered twice and the money at stake without changing the books, and `pellmont-approved-merge` merges the three duplicate vendor pairs as approved and changes nothing else.
46
+ - Variants: once `pellmont-duplicates` passes, `ancha test vary ancha/tests/pellmont-duplicates.yaml` writes ten variants of it, each changing one thing in the books with the expected findings recalculated; run them with the command it prints.
46
47
  - Your data: `ancha world import netsuite <your exports> --id <id>` reads REST record JSON, SuiteQL results and saved search CSV into `ancha/worlds/<id>.yaml`; check it with `ancha world validate`. To write the seed yourself, `ancha twins seed netsuite` lists its fields.
47
48
  - Your evals: `ancha test import <file>` (JSONL, JSON, CSV or YAML with a question and an expected answer) writes tests for the only world in `ancha/worlds/`, or the one `--world <id>` names; with none, `ancha init --on local --template starter` adds one.
48
49
  - One test from a sentence: `ancha test new "<sentence>" --world <id>`.
@@ -28,6 +28,7 @@
28
28
  ```
29
29
  - The install follows the project's own manifests and lockfiles; `agent.install` in `ancha.yaml` sets the command instead.
30
30
  6. **Without production traces.** For an agent that calls NetSuite directly, `ancha init` writes a NetSuite world of a private-equity portfolio company (four subsidiaries, two currencies, thousands of transactions) and 25 tests: 10 read tasks and 15 write workflows. For an agent that uses QuickBooks, it writes Pellmont Building Services' 2025 books and two tests: `pellmont-duplicates` reports the duplicate vendors, the invoices and bills entered twice and the money at stake without changing the books, and `pellmont-approved-merge` merges the three duplicate vendor pairs as approved and changes nothing else.
31
+ - Variants: once `pellmont-duplicates` passes, `ancha test vary ancha/tests/pellmont-duplicates.yaml` writes ten variants of it, each changing one thing in the books with the expected findings recalculated; run them with the command it prints.
31
32
  - Your data: `ancha world import netsuite <your exports> --id <id>` reads REST record JSON, SuiteQL results and saved search CSV into `ancha/worlds/<id>.yaml`; check it with `ancha world validate`. To write the seed yourself, `ancha twins seed netsuite` lists its fields.
32
33
  - Your evals: `ancha test import <file>` (JSONL, JSON, CSV or YAML with a question and an expected answer) writes tests for the only world in `ancha/worlds/`, or the one `--world <id>` names; with none, `ancha init --on local --template starter` adds one.
33
34
  - One test from a sentence: `ancha test new "<sentence>" --world <id>`.
@@ -36,6 +36,7 @@ Without `--on`, a project with `ancha.yaml` (or `--config`) runs in the workspac
36
36
  ```
37
37
  - The install follows the project's own manifests and lockfiles; `agent.install` in `ancha.yaml` sets the command instead.
38
38
  6. **Without production traces.** For an agent that calls NetSuite directly, `ancha init` writes a NetSuite world of a private-equity portfolio company (four subsidiaries, two currencies, thousands of transactions) and 25 tests: 10 read tasks and 15 write workflows. For an agent that uses QuickBooks, it writes Pellmont Building Services' 2025 books and two tests: `pellmont-duplicates` reports the duplicate vendors, the invoices and bills entered twice and the money at stake without changing the books, and `pellmont-approved-merge` merges the three duplicate vendor pairs as approved and changes nothing else.
39
+ - Variants: once `pellmont-duplicates` passes, `ancha test vary ancha/tests/pellmont-duplicates.yaml` writes ten variants of it, each changing one thing in the books with the expected findings recalculated; run them with the command it prints.
39
40
  - Your data: `ancha world import netsuite <your exports> --id <id>` reads REST record JSON, SuiteQL results and saved search CSV into `ancha/worlds/<id>.yaml`; check it with `ancha world validate`. To write the seed yourself, `ancha twins seed netsuite` lists its fields.
40
41
  - Your evals: `ancha test import <file>` (JSONL, JSON, CSV or YAML with a question and an expected answer) writes tests for the only world in `ancha/worlds/`, or the one `--world <id>` names; with none, `ancha init --on local --template starter` adds one.
41
42
  - One test from a sentence: `ancha test new "<sentence>" --world <id>`.
@@ -73,7 +74,7 @@ Without `--on`, a project with `ancha.yaml` (or `--config`) runs in the workspac
73
74
 
74
75
  `ancha login` prints a link and a code and opens the browser; the engineer approves this computer once (`--no-browser` only prints the link). With `--json` the first line is `{"event": "login_pending", "verificationUrl", "userCode", "expiresIn"}`, for a coding agent to show its user, and the last is the saved login. The CLI saves an API key for the workspace in `~/.config/ancha/credentials.json` (mode 0600; `ANCHA_CREDENTIALS_FILE` moves it). A process started without `HOME` (or `XDG_CONFIG_HOME`) has no saved login. After it signs in, `ancha login` prints the workspace's first steps, done or not (below).
75
76
 
76
- `ancha whoami --json` shows the workspace and where that choice came from (`--server-url`, `server.url` in `ancha.yaml`, `ANCHA_SERVER_URL`, or the saved login). `ancha whoami --verify` also asks the server whether it accepts the key. `ancha logout` forgets the saved login.
77
+ `ancha whoami --json` shows the workspace and where that choice came from (`--server-url`, `server.url` in `ancha.yaml`, `ANCHA_SERVER_URL`, or the saved login). `ancha whoami --verify` also asks the server whether it accepts the key. `ancha logout` revokes the key that `ancha login` created and removes the saved login; `--url <server>` selects a saved server. Other keys and `ANCHA_API_KEY` stay as they are. The result confirms revocation or gives the Settings link to revoke the key. With `--json`, `revoked` is true or false; a failed request adds `revokeError` with the error code (`AUTH_INVALID` for a key already revoked or not valid). Sign-out removes the local entry even when the request fails, and exits 0 once it is removed. For a login saved by an older CLI, use the Settings link in the result to revoke its key.
77
78
 
78
79
  ## Upload the agent
79
80
 
@@ -177,7 +178,7 @@ ancha secrets set COMPOSIO_API_KEY
177
178
  ancha run --on cloud
178
179
  ```
179
180
 
180
- - Declare either route or both. Each test's world decides which routed tools it answers. QuickBooks-only and NetSuite-only tests can use the same agent configuration. A call to a declared tool that the world lacks returns `403 COMPOSIO_ROUTE_REFUSED` with reason `NO_WORLD` and a fix to add the tool to the world or run the call in a test whose world has it. The agent gets that answer and the attempt is graded as usual, as it is when a SuiteQL call's arguments are invalid.
181
+ - Declare either route or both. Each test's world decides which routed tools it answers. QuickBooks-only and NetSuite-only tests can use the same agent configuration. A call to a declared tool that the world lacks returns `403 COMPOSIO_ROUTE_REFUSED` with reason `NO_WORLD` and a fix to add the tool to the world or run the call in a test whose world has it. The agent gets that answer and the attempt is graded as usual, as it is when a SuiteQL call's arguments are invalid. A call to a QuickBooks or NetSuite tool whose toolkit is not under `agent.routes` returns reason `NOT_ROUTED` with the line to add, such as `quickbooks: composio`; the attempt is invalid until the route is declared.
181
182
  - The agent keeps its Composio code. Each attempt sets `COMPOSIO_BASE_URL` to Composio's API through the attempt's gateway (the Composio SDKs read it; a client built with an explicit base URL takes this value) and `COMPOSIO_API_KEY` to a key for this attempt; the gateway sends the project's key to Composio for QuickBooks calls. `QUICKBOOKS_PUBLIC_URL` is this world's QuickBooks at an address Composio reaches for this attempt only; `QUICKBOOKS_ACCESS_TOKEN` and `QUICKBOOKS_REALM_ID` are the world's, as in any test with QuickBooks.
182
183
  - QuickBooks direct executions (`tools.execute`) reach the world whatever user ID or connected account the agent names: the gateway supplies the world's address and credentials on each call. An agent that already passes `custom_auth_params` keeps them: `base_url` is `QUICKBOOKS_PUBLIC_URL` with the world's `Authorization` and `x-quickbooks-realm-id` headers.
183
184
  - When the world has routed QuickBooks, Tool Router sessions reach the world through a QuickBooks connection the attempt creates in the project for its own user (`ancha-…`). Sessions are pinned to it, and the session's MCP URL points at the gateway, so an MCP client in the agent's process reaches the same session. When the attempt ends it deletes the sessions, the connection and its auth config.
@@ -18,6 +18,8 @@ A clean process exit doesn't mean the task passed, and an invalid trial isn't an
18
18
 
19
19
  Fix the agent after reading the evidence, then prove the fix with `ancha run --compare before` against a saved reference: `ancha docs compare`.
20
20
 
21
+ For a variant family, the next run command uses a pattern such as `ancha/tests/pellmont-duplicates-v-*.yaml` when Ancha verifies that it selects exactly the variant files in the run. The parent test and other tests keep their places in the command. Ancha checks the project directory; a cloud run also uses this folder's submission record to confirm the project. Otherwise, the command lists each test file.
22
+
21
23
  ## Replay an attempt
22
24
 
23
25
  `ancha replay latest/trial-<test>-1` runs one attempt again: its world with the same seed, its people answering from what they said in it, and the agent as it is now (or `--agent "<command>"`). Name the attempt as `<run id or latest>/<trial directory>`, as it appears under the runs directory. The replay is saved as a new run, so `ancha explain` and `ancha report` read it.
@@ -40,6 +40,8 @@ When signed in, `ancha run` runs the tests in the cloud, in parallel. Use `--on
40
40
  - Files go beside the parent, or to `--out <dir>`. Each YAML test contains its frozen world, rewritten checks and parent provenance. A `<parent-id>-vary-<suite-prefix>.json` manifest records the changes, expected values and file hashes; it stays out of the agent's cloud bundle.
41
41
  - Repeating the request reuses identical files. An edited destination is a conflict; choose another output directory to keep both. `--idempotency-key <key>` binds a request to its inputs and options.
42
42
 
43
+ Results group variants by parent and show each change with its passed/requested attempts. A variant whose attempts never started says `not run`; a variant with two of three attempts still unrun says `1/3 · 2 not run` when its completed attempt passed. The family headline totals these counts, and summary JSON includes `families[].rows[].notRun`.
44
+
43
45
  ## Tests from your evals
44
46
 
45
47
  `ancha test import <file> --world <id> --json` turns evals, questions with expected answers, into tests on a world in `ancha/tests/` (`--out <dir>` for another folder; `--world` defaults to the only world file). It reads JSON lines, a JSON array, CSV with a header row, or a YAML list:
@@ -34,6 +34,7 @@ Requirements: Node 24 or newer. Install once with `npm install -g @ancha-labs/cl
34
34
  ```
35
35
  - The install follows the project's own manifests and lockfiles; `agent.install` in `ancha.yaml` sets the command instead.
36
36
  6. **Without production traces.** For an agent that calls NetSuite directly, `ancha init` writes a NetSuite world of a private-equity portfolio company (four subsidiaries, two currencies, thousands of transactions) and 25 tests: 10 read tasks and 15 write workflows. For an agent that uses QuickBooks, it writes Pellmont Building Services' 2025 books and two tests: `pellmont-duplicates` reports the duplicate vendors, the invoices and bills entered twice and the money at stake without changing the books, and `pellmont-approved-merge` merges the three duplicate vendor pairs as approved and changes nothing else.
37
+ - Variants: once `pellmont-duplicates` passes, `ancha test vary ancha/tests/pellmont-duplicates.yaml` writes ten variants of it, each changing one thing in the books with the expected findings recalculated; run them with the command it prints.
37
38
  - Your data: `ancha world import netsuite <your exports> --id <id>` reads REST record JSON, SuiteQL results and saved search CSV into `ancha/worlds/<id>.yaml`; check it with `ancha world validate`. To write the seed yourself, `ancha twins seed netsuite` lists its fields.
38
39
  - Your evals: `ancha test import <file>` (JSONL, JSON, CSV or YAML with a question and an expected answer) writes tests for the only world in `ancha/worlds/`, or the one `--world <id>` names; with none, `ancha init --on local --template starter` adds one.
39
40
  - One test from a sentence: `ancha test new "<sentence>" --world <id>`.
@@ -186962,11 +186962,14 @@ function noWorldMessage(toolkit) {
186962
186962
  const name5 = toolkit === "quickbooks" ? "QuickBooks" : "NetSuite";
186963
186963
  return `This test's world has no ${name5}. Add ${name5} to the test's world or run this call in a test whose world has it.`;
186964
186964
  }
186965
+ function notRoutedMessage(toolkit) {
186966
+ return `${toolkit === "quickbooks" ? "QuickBooks" : "NetSuite"} is not routed for this agent. Add ${toolkit}: composio under agent.routes in ancha.yaml.`;
186967
+ }
186965
186968
  var RouteRefusal = class extends Error {
186966
186969
  reason;
186967
186970
  toolkit;
186968
186971
  constructor(reason2, toolkit) {
186969
- super(reason2 === "NO_WORLD" && toolkit ? noWorldMessage(toolkit) : reason2 === "NETSUITE_TOOL" ? NETSUITE_FIX : "Configure this call to use the declared QuickBooks or NetSuite route.");
186972
+ super(reason2 === "NO_WORLD" && toolkit ? noWorldMessage(toolkit) : reason2 === "NOT_ROUTED" && toolkit ? notRoutedMessage(toolkit) : reason2 === "NETSUITE_TOOL" ? NETSUITE_FIX : "Configure this call to use the declared QuickBooks or NetSuite route.");
186970
186973
  this.reason = reason2;
186971
186974
  this.toolkit = toolkit;
186972
186975
  }
@@ -186974,7 +186977,9 @@ var RouteRefusal = class extends Error {
186974
186977
  var activeComposioToolkits = (route15) => route15.activeToolkits ?? route15.toolkits ?? { quickbooks: "composio" };
186975
186978
  function requireWorld(name5, route15) {
186976
186979
  const toolkit = name5.startsWith("QUICKBOOKS_") ? "quickbooks" : name5.startsWith("NETSUITE_") ? "netsuite" : void 0;
186977
- if (toolkit && (route15.toolkits ?? { quickbooks: "composio" })[toolkit] && !activeComposioToolkits(route15)[toolkit]) throw new RouteRefusal("NO_WORLD", toolkit);
186980
+ if (!toolkit) return;
186981
+ if (!(route15.toolkits ?? { quickbooks: "composio" })[toolkit]) throw new RouteRefusal("NOT_ROUTED", toolkit);
186982
+ if (!activeComposioToolkits(route15)[toolkit]) throw new RouteRefusal("NO_WORLD", toolkit);
186978
186983
  }
186979
186984
  var refuse = (reason2) => {
186980
186985
  throw new RouteRefusal(reason2);
@@ -22222,7 +22222,7 @@ function starterCount(tool, key, state) {
22222
22222
  }
22223
22223
 
22224
22224
  // frontend/src/generated/coding-agent-skill.ts
22225
- var codingAgentSkill = "---\nname: ancha\ndescription: Test, debug and fix an AI agent (a Slack bot, a support or on-call agent) against stateful replicas of the tools it uses, built from its production traces, and prove a fix with graded runs in the cloud. Use when asked to test an agent with Ancha, or in a repository that has ancha.yaml.\n---\n\n# Ancha\n\nAncha gives an AI agent the other side of its job: stateful replicas of the tools it uses (Slack, GitHub, Datadog, PagerDuty and more), seeded with one fictional company or rebuilt from a production trace, and checks that grade every attempt from the agent's calls and the world's end state. The verdict comes from the world, not from mocks you wrote yourself. `ancha run --on cloud` runs each attempt on a fresh machine of its own in Ancha's cloud.\n\n## Run the CLI\n\nBefore the CLI is installed, run every command as `npx -y @ancha-labs/cli <command>`. After `npm install -g @ancha-labs/cli` (Node 24 or newer), run `ancha <command>`. Never run `npx` with the bare name `ancha`: that npm name is not this package.\n\nAdd `--json` to every command. Runs print NDJSON events that end with `run_finished`; `ancha traces upload` prints the tests it made. `env list` and `sandbox list` return arrays; trace commands use the fields described in `ancha docs traces`. `ancha schema <kind> --json` prints the JSON Schema of `ancha.yaml`, test files (`scene.yaml`) and these outputs. If your command can time out, give `ancha run` an `--idempotency-key <key>`: running it again with the same key returns the same run instead of starting another.\n\n## First steps\n\n<!-- ancha:first-steps -->\n1. **Install the CLI and sign in.** It needs Node 24 or newer. Approve this computer in the browser, once.\n ```sh\n ancha --version || npm install -g @ancha-labs/cli\n ancha login\n ```\n2. **Set up the project.** Run it in the agent's project: it finds the command that starts the agent and how the agent takes its task, and writes both to `ancha.yaml`. It installs and runs nothing.\n ```sh\n ancha init\n ```\n - To name the command yourself: `ancha init --agent \"<the command that starts your agent>\"`.\n - To name its tools yourself (NetSuite, Slack, ...): `ancha init --tools netsuite,slack`.\n - **Composio agents.** Init detects Python `composio` / `composio_client` and TypeScript `@composio/core`, and finds tools from explicit toolkit lists and tool slugs. It writes each available Composio route under `agent.routes` and adds `COMPOSIO_API_KEY` to `agent.pass_env`, preserving existing settings. The world of each test decides which routed tools answer there.\n - When init asks which tools the agent reaches through Composio, ask the user which tools they use. Set `agent.routes.<tool>: composio` for each routed tool (for example, `agent.routes.quickbooks: composio`) and add `COMPOSIO_API_KEY` to `agent.pass_env` in `ancha.yaml`. Configure the Composio client to read `COMPOSIO_BASE_URL` from the attempt environment.\n - For a routed agent with no tests or traces, init writes a starter test that reads from each routed tool, plus the QuickBooks examples when the agent uses QuickBooks. Routed tests run in the cloud: with `COMPOSIO_API_KEY` in your shell, the steps below store it, upload the agent and run the tests.\n3. **Point the agent at Ancha's tools.** In a test, the agent calls Ancha instead of production:\n - Its clients for Slack, GitHub and the other tools Ancha replicates take the URLs and credentials Ancha supplies: `ancha connect <tool>` prints the settings.\n - Its own functions: wrap them with `wrapTools` from `@ancha-labs/tools` (`ancha.wrap_tools` in Python), or serve them over MCP.\n4. **Store the key it needs.** The agent's own model key, read from your shell, never from an argument: it is stored in your workspace and named under `agent.pass_env` in `ancha.yaml`, so the agent gets it in every cloud attempt.\n ```sh\n ancha secrets set ANTHROPIC_API_KEY\n ```\n5. **Upload your agent.** A fresh machine in the cloud installs the project's dependencies and starts the agent once with a task. It says the agent is ready, or shows the end of its log.\n ```sh\n ancha agent upload\n ```\n - The install follows the project's own manifests and lockfiles; `agent.install` in `ancha.yaml` sets the command instead.\n6. **Without production traces.** For an agent that calls NetSuite directly, `ancha init` writes a NetSuite world of a private-equity portfolio company (four subsidiaries, two currencies, thousands of transactions) and 25 tests: 10 read tasks and 15 write workflows. For an agent that uses QuickBooks, it writes Pellmont Building Services' 2025 books and two tests: `pellmont-duplicates` reports the duplicate vendors, the invoices and bills entered twice and the money at stake without changing the books, and `pellmont-approved-merge` merges the three duplicate vendor pairs as approved and changes nothing else.\n - Your data: `ancha world import netsuite <your exports> --id <id>` reads REST record JSON, SuiteQL results and saved search CSV into `ancha/worlds/<id>.yaml`; check it with `ancha world validate`. To write the seed yourself, `ancha twins seed netsuite` lists its fields.\n - Your evals: `ancha test import <file>` (JSONL, JSON, CSV or YAML with a question and an expected answer) writes tests for the only world in `ancha/worlds/`, or the one `--world <id>` names; with none, `ancha init --on local --template starter` adds one.\n - One test from a sentence: `ancha test new \"<sentence>\" --world <id>`.\n7. **Upload traces.** A file or a folder of traces, runs that went fine and runs that failed: each trace becomes a test, in `scenes/from-traces/` and in your workspace.\n ```sh\n ancha traces upload ./traces\n ```\n - From Langfuse or LangSmith, with your keys on this computer: `ancha traces upload --from langfuse --limit 50`, or `--from langsmith`.\n - A trace of a run that went wrong can say what went wrong: `ancha traces upload <trace file> --expect \"<what went wrong>\"`, or for a test already made, `ancha pull <test id> --expect \"<what went wrong>\"`.\n - Traces your agent already sent to your workspace: `ancha traces`, then `ancha pull <trace id>`.\n - A test lists what one trace cannot settle: answer with `ancha pull <test id> --answer <question>=<answer>`.\n - A check marked `(optional)` is graded and shown, and the required checks decide the test; `ancha pull <test id> --answer checks.success=\"<end state>\"` makes completing the request decide it too.\n8. **Run your tests.** Every test, each attempt on a fresh machine. The run grades each attempt check by check and ends with the link to its result.\n ```sh\n ancha run\n ```\n - Your agent and its worlds run in the cloud, each attempt on a fresh machine of its own; a run keeps going when your laptop closes, and its results land in Runs.\n - `--attempts <n>` sets how many attempts each test gets, `--concurrency <n>` how many run at once.\n - `ancha wait <run id>` follows a run again from any terminal; `ancha explain <run id>` shows why a check failed.\n - `ancha status` shows which of these steps your workspace has done.\n9. **Fix the agent and keep the test.** Keep the failing run as the reference, fix the agent, and run again: exit 0 means every required check passes and nothing regressed.\n ```sh\n ancha baseline save before --from <run id>\n ancha run --compare before\n ```\n - Commit `scenes/from-traces/` so every run, in CI too, keeps it fixed.\n10. **Run it on this computer.** While you develop, `ancha run --on local` runs the agent and its worlds on this computer, with the same checks.\n ```sh\n ancha run --on local --attempts 1\n ```\n - Here the agent gets the keys in `agent.pass_env` from your shell, and model-graded checks need `OPENROUTER_API_KEY`.\n<!-- /ancha:first-steps -->\n\n## Cloud runs\n\n- `ancha run --on cloud` sends the project as one bundle: the agent's files, without hidden directories, dependencies or credential-like files, and its tests with their worlds and checks, which stay with the grader and never reach the agent. Each attempt's machine installs the dependencies, runs the agent and grades it with the same engine as a run on this computer. `--attempts <n>` sets the attempts per test, `--concurrency <n>` how many run at once.\n- The agent gets the workspace's secrets for the names in `agent.pass_env`, and its network reaches its tools and its model providers. Model-graded checks and the people in a world run on the workspace's model credit.\n- The `run_finished` event carries `url` (the result in the workspace) and `summary`, with `counts` of the attempts: requested, completed, invalid, skipped and cancelled. Interrupting the command stops the following, never the run: `ancha wait <run id>` follows it again, and `--detach` returns once the run is accepted.\n- `ancha explain <run id> --json` shows each failed check: what was expected, what happened, and the calls and world events behind it. Read it before guessing from the code; many bugs only show up with the world's data and timing.\n- When every attempt ended before the agent did anything (it exited within seconds without a call, or its command could not start), the run, `ancha wait` and `ancha explain` say that first: \"Your agent didn't run\", the end of its log once, and the likely fix read from it, such as the `agent.env` line that gives the agent its task under the name it reads. `agentNeverRan` in the JSON carries the same. Make that fix first: the failed checks follow from it, and `ancha explain <run id> --all` lists them.\n- `ancha status --json` shows the workspace's three steps (agent uploaded, tests added, tests run in the cloud) and the next command. In CI, `ANCHA_SERVER_URL` and `ANCHA_API_KEY` replace the login. More: `ancha docs cloud`.\n\n## An app, not a command\n\nIf the AI feature lives inside an app (a web app or API server with its database, workers and scheduled jobs), don't wrap it in `agent.command`. Ancha starts the app once per attempt with `agent.start`, waits for `agent.ready_url`, delivers the tools' events to `agent.url`, and a scene's `world_rules.app_calls` call the app's own routes, such as its cron jobs, at a time. Read `ancha docs apps` before writing `ancha.yaml`. The start script gives the app a clean database, cache and seed every attempt: a new world has new URLs and tokens, and stale rows or sync cursors make an app silently do nothing.\n\n## More from production traces\n\n`ancha traces upload <file or folder> --json` sends the traces to the workspace, which rebuilds each one's world and checks, and writes each test to `scenes/from-traces/<name>/scene.yaml`: runs that went fine and runs that failed. `--from langfuse` or `--from langsmith` takes the newest traces there instead (`--limit`, `--since`), with the keys in this shell. For one trace of a failure, `--expect \"<what went wrong>\"` adds a check for it. A test lists the questions one trace cannot settle, each with the default it uses. Ask the user for the answers; don't guess them. Pass them with `ancha pull <test id> --answer <question>=<value>`. `ancha import --offline <trace file> --json` makes the tests on this computer instead, one per conversation, and uploads nothing; there, `--answer` and `--force` go on the import.\n\nA test from a run that failed should fail the same way production did. If it doesn't, run it on this computer: `ancha traces diff <trace file> latest` shows the calls production made and the attempt didn't, and the import also lists the app's own setup calls, which the start script or an `app_call` has to make.\n\nIf the user's workspace takes traces (their agents send them to it), each trace becomes a test there: `ancha pull --all --json` writes every test that is turned on (`--agent <name>` for one agent's), `ancha traces --failed --json` lists the ones where production failed a check, `ancha traces show <id> --json` previews the test, and `ancha pull <id> --json` writes one, with `--answer` for its questions. Checks you add to a pulled `scene.yaml` stay when you pull a newer version; any other edit stops the pull. More: `ancha docs traces`.\n\n## Other tests\n\nThe starter test `ancha init` writes when `scenes/` holds no tests only proves that the agent reaches each tool. For the agent's real job beyond its traces, `ancha test new \"<the test in one sentence>\" --json` drafts a test with people for the project's world (`ancha init --intent \"<company and scenario>\"` makes the world and a first test). Review its checks before you run it. To write a seed yourself, `ancha twins seed <tool> --json` prints the tool's fields, an example that validates as written, and the checks a test can make on it. More: `ancha docs scenes`.\n\n## The rule\n\nFix the agent, not the tests or their checks. `ancha.yaml` says how to start the agent and give it its task and keys: change it for that, never to make a check pass. The exception is a check that is wrong for the real API, such as a method the official SDK never sends. Then don't quietly edit it: tell the user, show the evidence (the call from `ancha explain`, the vendor's documentation), and change it only with their agreement.\n\nNever give the agent under test the tests, checks, seeds or reference companions (`oracle.mjs`, `null.mjs`), and never point it at a real SaaS API.\n\n## What the agent gets\n\nEach attempt gives the agent its tools as environment variables, with fake credentials that only work against the replicas:\n\n- Slack: `SLACK_API_URL` (ends in `/api/`), `SLACK_BOT_TOKEN`\n- GitHub: `GITHUB_API_URL`, `GITHUB_TOKEN`\n- Datadog: `DATADOG_API_URL`, `DD_API_KEY`, `DD_APP_KEY`\n- PagerDuty: `PAGERDUTY_API_URL`, `PAGERDUTY_API_TOKEN`, `PAGERDUTY_FROM_EMAIL`, `PAGERDUTY_ROUTING_KEY`\n- the same pattern for the other tools in the world; `ANCHA_TASK` carries a command-line task, and `ANCHA_TASK_FILE` names a file holding it. An agent that reads its task under another name gets it with `agent.env: { MY_TASK: \"{{task}}\" }` (`{{task_file}}` for the file); `ancha init` writes that line when it finds the name.\n\n`ancha connect <tool> --lang ts|py` prints the SDK settings. `ancha twins coverage <tool>` lists the endpoints each replica implements.\n\nGoogle clients (`googleapis`, `@googleapis/*`) take the replica's URL in each call's options: `drive.files.list(params, { rootUrl: process.env.GOOGLE_DRIVE_API_URL + '/' })`. A `rootUrl` set on the client keeps only the host; Ancha still routes those calls by their token, but the client sends file uploads to www.googleapis.com.\n\nThe agent's own keys are the names in `agent.pass_env` in `ancha.yaml`, such as `agent.pass_env: [OPENAI_API_KEY]`, and `agent.env` sets fixed values, such as the path of a key file. In the cloud each name comes from the workspace's secrets (`ancha secrets set NAME`). `ancha run --on local` starts the agent on this computer instead, with this computer's network and those names from this shell (or `--pass-env NAME`); `--on docker` seals it in a container (`agent.execution: { mode: container, image: node:24-slim }`, which needs Docker). An agent without its model key stops at its first model call.\n\n## When something fails\n\n- Exit 1: a check failed or the comparison regressed (a single check's drop counts, see `comparison.droppedChecks`). Run `ancha explain <run id> --json`.\n- Exit 2: usage, config, test file or authentication error, or a cancelled cloud run. `AUTH_INVALID` means `ancha login` again or a valid `ANCHA_API_KEY`; `CONFIG_INVALID` naming a workspace secret means `ancha secrets set NAME`. Read the `hint`.\n- Exit 3: infrastructure, or an attempt the harness couldn't run or grade. It counts as invalid, never as a failed check, so it's not the agent's fault; run again, and `ancha agent upload --json` if it repeats.\n- Exit 4, only with `--strict`: an endpoint coverage error or a verdict using simulated tool answers. The summary names the tests, trials and evaluated checks using those answers. `ancha explain` lists endpoint errors; `ancha twins coverage <tool>` shows the endpoint inventory.\n\nRead the error's stable `code` and `message`, then follow its `hint` when provided. More: `ancha docs`, `ancha docs <topic>` for setup, run, traces, explain, compare, scenes, integrations, cloud and playgrounds, and https://docs.ancha.io/coding-agents.\n\nTell the user what you ran, where it ran, the pass rate, the evidence and the result link. Never claim a fix until `ancha run --compare` exits 0.\n";
22225
+ var codingAgentSkill = "---\nname: ancha\ndescription: Test, debug and fix an AI agent (a Slack bot, a support or on-call agent) against stateful replicas of the tools it uses, built from its production traces, and prove a fix with graded runs in the cloud. Use when asked to test an agent with Ancha, or in a repository that has ancha.yaml.\n---\n\n# Ancha\n\nAncha gives an AI agent the other side of its job: stateful replicas of the tools it uses (Slack, GitHub, Datadog, PagerDuty and more), seeded with one fictional company or rebuilt from a production trace, and checks that grade every attempt from the agent's calls and the world's end state. The verdict comes from the world, not from mocks you wrote yourself. `ancha run --on cloud` runs each attempt on a fresh machine of its own in Ancha's cloud.\n\n## Run the CLI\n\nBefore the CLI is installed, run every command as `npx -y @ancha-labs/cli <command>`. After `npm install -g @ancha-labs/cli` (Node 24 or newer), run `ancha <command>`. Never run `npx` with the bare name `ancha`: that npm name is not this package.\n\nAdd `--json` to every command. Runs print NDJSON events that end with `run_finished`; `ancha traces upload` prints the tests it made. `env list` and `sandbox list` return arrays; trace commands use the fields described in `ancha docs traces`. `ancha schema <kind> --json` prints the JSON Schema of `ancha.yaml`, test files (`scene.yaml`) and these outputs. If your command can time out, give `ancha run` an `--idempotency-key <key>`: running it again with the same key returns the same run instead of starting another.\n\n## First steps\n\n<!-- ancha:first-steps -->\n1. **Install the CLI and sign in.** It needs Node 24 or newer. Approve this computer in the browser, once.\n ```sh\n ancha --version || npm install -g @ancha-labs/cli\n ancha login\n ```\n2. **Set up the project.** Run it in the agent's project: it finds the command that starts the agent and how the agent takes its task, and writes both to `ancha.yaml`. It installs and runs nothing.\n ```sh\n ancha init\n ```\n - To name the command yourself: `ancha init --agent \"<the command that starts your agent>\"`.\n - To name its tools yourself (NetSuite, Slack, ...): `ancha init --tools netsuite,slack`.\n - **Composio agents.** Init detects Python `composio` / `composio_client` and TypeScript `@composio/core`, and finds tools from explicit toolkit lists and tool slugs. It writes each available Composio route under `agent.routes` and adds `COMPOSIO_API_KEY` to `agent.pass_env`, preserving existing settings. The world of each test decides which routed tools answer there.\n - When init asks which tools the agent reaches through Composio, ask the user which tools they use. Set `agent.routes.<tool>: composio` for each routed tool (for example, `agent.routes.quickbooks: composio`) and add `COMPOSIO_API_KEY` to `agent.pass_env` in `ancha.yaml`. Configure the Composio client to read `COMPOSIO_BASE_URL` from the attempt environment.\n - For a routed agent with no tests or traces, init writes a starter test that reads from each routed tool, plus the QuickBooks examples when the agent uses QuickBooks. Routed tests run in the cloud: with `COMPOSIO_API_KEY` in your shell, the steps below store it, upload the agent and run the tests.\n3. **Point the agent at Ancha's tools.** In a test, the agent calls Ancha instead of production:\n - Its clients for Slack, GitHub and the other tools Ancha replicates take the URLs and credentials Ancha supplies: `ancha connect <tool>` prints the settings.\n - Its own functions: wrap them with `wrapTools` from `@ancha-labs/tools` (`ancha.wrap_tools` in Python), or serve them over MCP.\n4. **Store the key it needs.** The agent's own model key, read from your shell, never from an argument: it is stored in your workspace and named under `agent.pass_env` in `ancha.yaml`, so the agent gets it in every cloud attempt.\n ```sh\n ancha secrets set ANTHROPIC_API_KEY\n ```\n5. **Upload your agent.** A fresh machine in the cloud installs the project's dependencies and starts the agent once with a task. It says the agent is ready, or shows the end of its log.\n ```sh\n ancha agent upload\n ```\n - The install follows the project's own manifests and lockfiles; `agent.install` in `ancha.yaml` sets the command instead.\n6. **Without production traces.** For an agent that calls NetSuite directly, `ancha init` writes a NetSuite world of a private-equity portfolio company (four subsidiaries, two currencies, thousands of transactions) and 25 tests: 10 read tasks and 15 write workflows. For an agent that uses QuickBooks, it writes Pellmont Building Services' 2025 books and two tests: `pellmont-duplicates` reports the duplicate vendors, the invoices and bills entered twice and the money at stake without changing the books, and `pellmont-approved-merge` merges the three duplicate vendor pairs as approved and changes nothing else.\n - Variants: once `pellmont-duplicates` passes, `ancha test vary ancha/tests/pellmont-duplicates.yaml` writes ten variants of it, each changing one thing in the books with the expected findings recalculated; run them with the command it prints.\n - Your data: `ancha world import netsuite <your exports> --id <id>` reads REST record JSON, SuiteQL results and saved search CSV into `ancha/worlds/<id>.yaml`; check it with `ancha world validate`. To write the seed yourself, `ancha twins seed netsuite` lists its fields.\n - Your evals: `ancha test import <file>` (JSONL, JSON, CSV or YAML with a question and an expected answer) writes tests for the only world in `ancha/worlds/`, or the one `--world <id>` names; with none, `ancha init --on local --template starter` adds one.\n - One test from a sentence: `ancha test new \"<sentence>\" --world <id>`.\n7. **Upload traces.** A file or a folder of traces, runs that went fine and runs that failed: each trace becomes a test, in `scenes/from-traces/` and in your workspace.\n ```sh\n ancha traces upload ./traces\n ```\n - From Langfuse or LangSmith, with your keys on this computer: `ancha traces upload --from langfuse --limit 50`, or `--from langsmith`.\n - A trace of a run that went wrong can say what went wrong: `ancha traces upload <trace file> --expect \"<what went wrong>\"`, or for a test already made, `ancha pull <test id> --expect \"<what went wrong>\"`.\n - Traces your agent already sent to your workspace: `ancha traces`, then `ancha pull <trace id>`.\n - A test lists what one trace cannot settle: answer with `ancha pull <test id> --answer <question>=<answer>`.\n - A check marked `(optional)` is graded and shown, and the required checks decide the test; `ancha pull <test id> --answer checks.success=\"<end state>\"` makes completing the request decide it too.\n8. **Run your tests.** Every test, each attempt on a fresh machine. The run grades each attempt check by check and ends with the link to its result.\n ```sh\n ancha run\n ```\n - Your agent and its worlds run in the cloud, each attempt on a fresh machine of its own; a run keeps going when your laptop closes, and its results land in Runs.\n - `--attempts <n>` sets how many attempts each test gets, `--concurrency <n>` how many run at once.\n - `ancha wait <run id>` follows a run again from any terminal; `ancha explain <run id>` shows why a check failed.\n - `ancha status` shows which of these steps your workspace has done.\n9. **Fix the agent and keep the test.** Keep the failing run as the reference, fix the agent, and run again: exit 0 means every required check passes and nothing regressed.\n ```sh\n ancha baseline save before --from <run id>\n ancha run --compare before\n ```\n - Commit `scenes/from-traces/` so every run, in CI too, keeps it fixed.\n10. **Run it on this computer.** While you develop, `ancha run --on local` runs the agent and its worlds on this computer, with the same checks.\n ```sh\n ancha run --on local --attempts 1\n ```\n - Here the agent gets the keys in `agent.pass_env` from your shell, and model-graded checks need `OPENROUTER_API_KEY`.\n<!-- /ancha:first-steps -->\n\n## Cloud runs\n\n- `ancha run --on cloud` sends the project as one bundle: the agent's files, without hidden directories, dependencies or credential-like files, and its tests with their worlds and checks, which stay with the grader and never reach the agent. Each attempt's machine installs the dependencies, runs the agent and grades it with the same engine as a run on this computer. `--attempts <n>` sets the attempts per test, `--concurrency <n>` how many run at once.\n- The agent gets the workspace's secrets for the names in `agent.pass_env`, and its network reaches its tools and its model providers. Model-graded checks and the people in a world run on the workspace's model credit.\n- The `run_finished` event carries `url` (the result in the workspace) and `summary`, with `counts` of the attempts: requested, completed, invalid, skipped and cancelled. Interrupting the command stops the following, never the run: `ancha wait <run id>` follows it again, and `--detach` returns once the run is accepted.\n- `ancha explain <run id> --json` shows each failed check: what was expected, what happened, and the calls and world events behind it. Read it before guessing from the code; many bugs only show up with the world's data and timing.\n- When every attempt ended before the agent did anything (it exited within seconds without a call, or its command could not start), the run, `ancha wait` and `ancha explain` say that first: \"Your agent didn't run\", the end of its log once, and the likely fix read from it, such as the `agent.env` line that gives the agent its task under the name it reads. `agentNeverRan` in the JSON carries the same. Make that fix first: the failed checks follow from it, and `ancha explain <run id> --all` lists them.\n- `ancha status --json` shows the workspace's three steps (agent uploaded, tests added, tests run in the cloud) and the next command. In CI, `ANCHA_SERVER_URL` and `ANCHA_API_KEY` replace the login. More: `ancha docs cloud`.\n\n## An app, not a command\n\nIf the AI feature lives inside an app (a web app or API server with its database, workers and scheduled jobs), don't wrap it in `agent.command`. Ancha starts the app once per attempt with `agent.start`, waits for `agent.ready_url`, delivers the tools' events to `agent.url`, and a scene's `world_rules.app_calls` call the app's own routes, such as its cron jobs, at a time. Read `ancha docs apps` before writing `ancha.yaml`. The start script gives the app a clean database, cache and seed every attempt: a new world has new URLs and tokens, and stale rows or sync cursors make an app silently do nothing.\n\n## More from production traces\n\n`ancha traces upload <file or folder> --json` sends the traces to the workspace, which rebuilds each one's world and checks, and writes each test to `scenes/from-traces/<name>/scene.yaml`: runs that went fine and runs that failed. `--from langfuse` or `--from langsmith` takes the newest traces there instead (`--limit`, `--since`), with the keys in this shell. For one trace of a failure, `--expect \"<what went wrong>\"` adds a check for it. A test lists the questions one trace cannot settle, each with the default it uses. Ask the user for the answers; don't guess them. Pass them with `ancha pull <test id> --answer <question>=<value>`. `ancha import --offline <trace file> --json` makes the tests on this computer instead, one per conversation, and uploads nothing; there, `--answer` and `--force` go on the import.\n\nA test from a run that failed should fail the same way production did. If it doesn't, run it on this computer: `ancha traces diff <trace file> latest` shows the calls production made and the attempt didn't, and the import also lists the app's own setup calls, which the start script or an `app_call` has to make.\n\nIf the user's workspace takes traces (their agents send them to it), each trace becomes a test there: `ancha pull --all --json` writes every test that is turned on (`--agent <name>` for one agent's), `ancha traces --failed --json` lists the ones where production failed a check, `ancha traces show <id> --json` previews the test, and `ancha pull <id> --json` writes one, with `--answer` for its questions. Checks you add to a pulled `scene.yaml` stay when you pull a newer version; any other edit stops the pull. More: `ancha docs traces`.\n\n## Other tests\n\nThe starter test `ancha init` writes when `scenes/` holds no tests only proves that the agent reaches each tool. For the agent's real job beyond its traces, `ancha test new \"<the test in one sentence>\" --json` drafts a test with people for the project's world (`ancha init --intent \"<company and scenario>\"` makes the world and a first test). Review its checks before you run it. To write a seed yourself, `ancha twins seed <tool> --json` prints the tool's fields, an example that validates as written, and the checks a test can make on it. More: `ancha docs scenes`.\n\n## The rule\n\nFix the agent, not the tests or their checks. `ancha.yaml` says how to start the agent and give it its task and keys: change it for that, never to make a check pass. The exception is a check that is wrong for the real API, such as a method the official SDK never sends. Then don't quietly edit it: tell the user, show the evidence (the call from `ancha explain`, the vendor's documentation), and change it only with their agreement.\n\nNever give the agent under test the tests, checks, seeds or reference companions (`oracle.mjs`, `null.mjs`), and never point it at a real SaaS API.\n\n## What the agent gets\n\nEach attempt gives the agent its tools as environment variables, with fake credentials that only work against the replicas:\n\n- Slack: `SLACK_API_URL` (ends in `/api/`), `SLACK_BOT_TOKEN`\n- GitHub: `GITHUB_API_URL`, `GITHUB_TOKEN`\n- Datadog: `DATADOG_API_URL`, `DD_API_KEY`, `DD_APP_KEY`\n- PagerDuty: `PAGERDUTY_API_URL`, `PAGERDUTY_API_TOKEN`, `PAGERDUTY_FROM_EMAIL`, `PAGERDUTY_ROUTING_KEY`\n- the same pattern for the other tools in the world; `ANCHA_TASK` carries a command-line task, and `ANCHA_TASK_FILE` names a file holding it. An agent that reads its task under another name gets it with `agent.env: { MY_TASK: \"{{task}}\" }` (`{{task_file}}` for the file); `ancha init` writes that line when it finds the name.\n\n`ancha connect <tool> --lang ts|py` prints the SDK settings. `ancha twins coverage <tool>` lists the endpoints each replica implements.\n\nGoogle clients (`googleapis`, `@googleapis/*`) take the replica's URL in each call's options: `drive.files.list(params, { rootUrl: process.env.GOOGLE_DRIVE_API_URL + '/' })`. A `rootUrl` set on the client keeps only the host; Ancha still routes those calls by their token, but the client sends file uploads to www.googleapis.com.\n\nThe agent's own keys are the names in `agent.pass_env` in `ancha.yaml`, such as `agent.pass_env: [OPENAI_API_KEY]`, and `agent.env` sets fixed values, such as the path of a key file. In the cloud each name comes from the workspace's secrets (`ancha secrets set NAME`). `ancha run --on local` starts the agent on this computer instead, with this computer's network and those names from this shell (or `--pass-env NAME`); `--on docker` seals it in a container (`agent.execution: { mode: container, image: node:24-slim }`, which needs Docker). An agent without its model key stops at its first model call.\n\n## When something fails\n\n- Exit 1: a check failed or the comparison regressed (a single check's drop counts, see `comparison.droppedChecks`). Run `ancha explain <run id> --json`.\n- Exit 2: usage, config, test file or authentication error, or a cancelled cloud run. `AUTH_INVALID` means `ancha login` again or a valid `ANCHA_API_KEY`; `CONFIG_INVALID` naming a workspace secret means `ancha secrets set NAME`. Read the `hint`.\n- Exit 3: infrastructure, or an attempt the harness couldn't run or grade. It counts as invalid, never as a failed check, so it's not the agent's fault; run again, and `ancha agent upload --json` if it repeats.\n- Exit 4, only with `--strict`: an endpoint coverage error or a verdict using simulated tool answers. The summary names the tests, trials and evaluated checks using those answers. `ancha explain` lists endpoint errors; `ancha twins coverage <tool>` shows the endpoint inventory.\n\nRead the error's stable `code` and `message`, then follow its `hint` when provided. More: `ancha docs`, `ancha docs <topic>` for setup, run, traces, explain, compare, scenes, integrations, cloud and playgrounds, and https://docs.ancha.io/coding-agents.\n\nTell the user what you ran, where it ran, the pass rate, the evidence and the result link. Never claim a fix until `ancha run --compare` exits 0.\n";
22226
22226
 
22227
22227
  // frontend/src/workspace-pages.ts
22228
22228
  var startSentence = "Set up Ancha for this agent: read https://app.ancha.io/llms.txt and follow its first steps.";
package/lib/worker.mjs CHANGED
@@ -71050,9 +71050,14 @@ function noWorldMessage(toolkit) {
71050
71050
  const name5 = toolkit === "quickbooks" ? "QuickBooks" : "NetSuite";
71051
71051
  return `This test's world has no ${name5}. Add ${name5} to the test's world or run this call in a test whose world has it.`;
71052
71052
  }
71053
+ function notRoutedMessage(toolkit) {
71054
+ return `${toolkit === "quickbooks" ? "QuickBooks" : "NetSuite"} is not routed for this agent. Add ${toolkit}: composio under agent.routes in ancha.yaml.`;
71055
+ }
71053
71056
  function requireWorld(name5, route15) {
71054
71057
  const toolkit = name5.startsWith("QUICKBOOKS_") ? "quickbooks" : name5.startsWith("NETSUITE_") ? "netsuite" : void 0;
71055
- if (toolkit && (route15.toolkits ?? { quickbooks: "composio" })[toolkit] && !activeComposioToolkits(route15)[toolkit]) throw new RouteRefusal("NO_WORLD", toolkit);
71058
+ if (!toolkit) return;
71059
+ if (!(route15.toolkits ?? { quickbooks: "composio" })[toolkit]) throw new RouteRefusal("NOT_ROUTED", toolkit);
71060
+ if (!activeComposioToolkits(route15)[toolkit]) throw new RouteRefusal("NO_WORLD", toolkit);
71056
71061
  }
71057
71062
  function parsed2(schema2, value5) {
71058
71063
  const result = schema2.safeParse(value5);
@@ -71399,7 +71404,7 @@ var init_composio = __esm({
71399
71404
  reason;
71400
71405
  toolkit;
71401
71406
  constructor(reason2, toolkit) {
71402
- super(reason2 === "NO_WORLD" && toolkit ? noWorldMessage(toolkit) : reason2 === "NETSUITE_TOOL" ? NETSUITE_FIX : "Configure this call to use the declared QuickBooks or NetSuite route.");
71407
+ super(reason2 === "NO_WORLD" && toolkit ? noWorldMessage(toolkit) : reason2 === "NOT_ROUTED" && toolkit ? notRoutedMessage(toolkit) : reason2 === "NETSUITE_TOOL" ? NETSUITE_FIX : "Configure this call to use the declared QuickBooks or NetSuite route.");
71403
71408
  this.reason = reason2;
71404
71409
  this.toolkit = toolkit;
71405
71410
  }
@@ -72610,6 +72615,7 @@ var init_ingress_client = __esm({
72610
72615
  hash2 = (value5) => createHash5("sha256").update(value5).digest("hex").slice(0, 16);
72611
72616
  REFUSAL_FIX = {
72612
72617
  NO_WORLD: noWorldMessage,
72618
+ NOT_ROUTED: notRoutedMessage,
72613
72619
  NETSUITE_TOOL: "use session.execute or tools.execute with NETSUITE_RUN_SUITEQL_QUERY",
72614
72620
  ROUTE_UNAVAILABLE: "the route had closed; run again",
72615
72621
  PATH: "use QuickBooks tools, sessions and session MCP through COMPOSIO_BASE_URL",
@@ -73653,7 +73659,7 @@ function variantFamilies(summary) {
73653
73659
  for (const name5 of ["requested", "passed", "failed", "invalid"]) family2.attempts[name5] += counts2[name5];
73654
73660
  family2.attempts.ungraded += counts2.ungraded + counts2.skipped;
73655
73661
  family2.attempts.notRun += counts2.pending;
73656
- family2.rows.push({ sceneId: scene2.sceneId, ordinal: v.ordinal, kind: v.kind, change: v.change, passed: counts2.passed, requested: counts2.requested });
73662
+ family2.rows.push({ sceneId: scene2.sceneId, ordinal: v.ordinal, kind: v.kind, change: v.change, passed: counts2.passed, requested: counts2.requested, notRun: counts2.pending });
73657
73663
  }
73658
73664
  return [...families.values()].map((family2) => ({
73659
73665
  ...family2,
@@ -73665,10 +73671,15 @@ function variantFamilyLine(family2) {
73665
73671
  const a = family2.attempts;
73666
73672
  return `${family2.parentId}: ${family2.variantsMet} of ${family2.variants} variants passed \xB7 ${a.passed}/${a.requested} attempts (${family2.passRate === null ? "\u2014" : `${(family2.passRate * 100).toFixed(1)}%`}) \xB7 ${a.failed} failed \xB7 ${a.invalid} invalid \xB7 ${a.ungraded} ungraded \xB7 ${a.notRun} not run`;
73667
73673
  }
73674
+ function variantRowCount(row2) {
73675
+ const notRun = row2.notRun ?? 0;
73676
+ if (row2.requested > 0 && notRun === row2.requested) return "not run";
73677
+ return `${row2.passed}/${row2.requested}${notRun > 0 && notRun < row2.requested ? ` \xB7 ${notRun} not run` : ""}`;
73678
+ }
73668
73679
  function variantFamilyLines(families) {
73669
73680
  return families.flatMap((family2) => ["", variantFamilyLine(family2), ...family2.rows.map((row2) => {
73670
73681
  const change4 = row2.change.replace(/\s+/g, " ");
73671
- return ` ${change4.length > 96 ? `${change4.slice(0, 95)}\u2026` : change4} ${row2.passed}/${row2.requested}`;
73682
+ return ` ${change4.length > 96 ? `${change4.slice(0, 95)}\u2026` : change4} ${variantRowCount(row2)}`;
73672
73683
  })]);
73673
73684
  }
73674
73685
  function runVerdict(scenes, minPassRate) {
@@ -73808,8 +73819,44 @@ function neverRanChecksLine(n2, runId, out) {
73808
73819
  if (n2.checksFailed === 0) return void 0;
73809
73820
  return `${n2.checksFailed} ${n2.checksFailed === 1 ? "check" : "checks"} failed because the agent never ran; ancha explain ${runId}${out === void 0 ? "" : ` --out ${shellWord(out)}`} --all shows them`;
73810
73821
  }
73822
+ function rerunTestWords(summary, tests, readDirectory, quote2 = shellWord) {
73823
+ if (!readDirectory) return tests.map(quote2);
73824
+ const replacements = /* @__PURE__ */ new Map(), omitted = /* @__PURE__ */ new Set();
73825
+ const parents = new Set((summary.scenes ?? []).flatMap((scene2) => scene2.variant ? [scene2.variant.parentId] : []));
73826
+ for (const parent3 of parents) {
73827
+ if (!/^[a-zA-Z0-9_-]+$/.test(parent3)) continue;
73828
+ const matches10 = (name5) => name5.startsWith(`${parent3}-v-`) && name5.endsWith(".yaml");
73829
+ const groups = /* @__PURE__ */ new Map();
73830
+ for (const path8 of tests) {
73831
+ if (replacements.has(path8) || omitted.has(path8) || !matches10(basename2(path8)) || /[*?\[\]{}()!\\]/.test(path8)) continue;
73832
+ const ids3 = summary.provenance?.tests.filter((test2) => test2.path === path8).map((test2) => test2.caseId);
73833
+ const variant = (summary.scenes ?? []).some((scene2) => scene2.variant?.parentId === parent3 && (ids3 ? ids3.includes(scene2.sceneId) : `${scene2.scenarioId ?? scene2.sceneId}.yaml` === basename2(path8)));
73834
+ if (!variant) continue;
73835
+ const directory = dirname(path8), group5 = groups.get(directory) ?? [];
73836
+ group5.push(path8);
73837
+ groups.set(directory, group5);
73838
+ }
73839
+ for (const [directory, paths3] of groups) {
73840
+ let entries3;
73841
+ try {
73842
+ entries3 = readDirectory(directory);
73843
+ } catch {
73844
+ continue;
73845
+ }
73846
+ if (!entries3) continue;
73847
+ if (tests.some((path8) => dirname(path8) === directory && !entries3.includes(basename2(path8)))) continue;
73848
+ const selected3 = new Set(paths3.map((path8) => basename2(path8))), present2 = new Set(entries3.filter(matches10));
73849
+ if (selected3.size !== present2.size || [...selected3].some((name5) => !present2.has(name5))) continue;
73850
+ const first = paths3[0];
73851
+ replacements.set(first, `${directory === "." ? "" : quote2(`${directory}/`)}${parent3}-v-*.yaml`);
73852
+ for (const path8 of paths3) if (path8 !== first) omitted.add(path8);
73853
+ }
73854
+ }
73855
+ return tests.filter((path8) => !omitted.has(path8)).map((path8) => replacements.get(path8) ?? quote2(path8));
73856
+ }
73811
73857
  function retryCommands(s2, opts = {}) {
73812
- const tests = opts.tests !== void 0 && opts.tests.length > 0 && opts.tests.length <= 3 ? ` ${opts.tests.map(shellWord).join(" ")}` : "";
73858
+ const words6 = rerunTestWords(s2, opts.tests ?? s2.testPaths ?? [], opts.readDirectory);
73859
+ const tests = words6.length ? ` ${words6.join(" ")}` : "";
73813
73860
  if (s2.target === "cloud") return ["ancha agent upload", `ancha run --on cloud${tests}`];
73814
73861
  const on = s2.target === "docker" ? " --on docker" : s2.target === "local" ? " --on local" : "";
73815
73862
  return [`ancha run${on}${tests}${opts.out === void 0 ? "" : ` --out ${shellWord(opts.out)}`}`];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ancha-labs/cli",
3
- "version": "0.4.42",
3
+ "version": "0.4.43",
4
4
  "type": "module",
5
5
  "description": "Simulation playgrounds for agents: run your agent against stateful replicas of Slack, GitHub, Datadog and more, each attempt on a fresh cloud machine in your app.ancha.io workspace, or on your computer.",
6
6
  "bugs": {