From 87f1b955af8091cee947bd35dfac26ecb4070254 Mon Sep 17 00:00:00 2001 From: Faisal Reza Date: Mon, 28 Sep 2026 17:20:52 +0100 Subject: [PATCH] chore(SOL-404): add host-neutral eval runner and plugin regression cases - scripts/evals: runner, claude/antigravity/cursor/codex adapters, reference judge - 38 cases across the six integration plugins - README: evals section, structure tree Co-Authored-By: Claude Opus 5.5 --- README.md | 26 +-- scripts/evals/README.md | 166 +++++++++++++++++ scripts/evals/cases.ts | 45 +++++ scripts/evals/cases/README.md | 170 ++++++++++++++++++ .../stackone-agents/helpscout-to-claude.json | 33 ++++ .../jobadder-mcp-link-first.json | 33 ++++ .../langchain-agent-tools.json | 33 ++++ .../limit-tools-in-agent-context.json | 27 +++ .../soap-conditional-element.json | 27 +++ .../stackone-connect/embed-hub-in-react.json | 41 +++++ .../oauth-app-whose-credentials.json | 28 +++ .../connector-catalog-endpoint.json | 28 +++ .../manatal-zinc-sonavate.json | 44 +++++ .../paylocity-available.json | 27 +++ .../plaid-redirect-uri.json | 27 +++ .../sap-erp-connector.json | 27 +++ .../sap-per-user-auth.json | 27 +++ .../teams-publisher-attestation.json | 21 +++ .../workday-actions-available.json | 28 +++ .../workday-documents.json | 28 +++ .../workday-user-impersonation.json | 27 +++ .../account-disconnect-notification.json | 33 ++++ .../account-status-meaning.json | 28 +++ .../accounts-by-connector-profile.json | 27 +++ .../accounts-no-credentials.json | 34 ++++ .../stackone-platform/add-org-member.json | 27 +++ .../api-key-for-jobadder.json | 34 ++++ .../stackone-platform/configure-webhooks.json | 22 +++ .../stackone-platform/connector-billing.json | 21 +++ .../stackone-platform/create-api-key.json | 16 ++ .../stackone-platform/data-sync-off-map.json | 21 +++ .../cases/stackone-platform/debug-401.json | 22 +++ .../stackone-platform/find-request-logs.json | 16 ++ .../list-linked-accounts.json | 38 ++++ .../stackone-platform/log-pii-redaction.json | 27 +++ .../stackone-platform/log-request-source.json | 27 +++ .../org-project-account-hierarchy.json | 28 +++ .../passthrough-idle-timeout.json | 33 ++++ .../stackone-platform/rate-limit-429.json | 22 +++ .../rename-organisation.json | 21 +++ .../retry-backoff-guidance.json | 28 +++ .../cursor-pagination-next.json | 27 +++ scripts/evals/grade.ts | 68 +++++++ scripts/evals/hosts/antigravity.ts | 66 +++++++ scripts/evals/hosts/claude.ts | 68 +++++++ scripts/evals/hosts/codex.ts | 26 +++ scripts/evals/hosts/cursor.ts | 27 +++ scripts/evals/hosts/index.ts | 19 ++ scripts/evals/hosts/liberal-transcript.ts | 60 +++++++ scripts/evals/judge.ts | 140 +++++++++++++++ scripts/evals/package-lock.json | 50 ++++++ scripts/evals/package.json | 17 ++ scripts/evals/process.ts | 68 +++++++ scripts/evals/report.ts | 64 +++++++ scripts/evals/run-host.ts | 157 ++++++++++++++++ scripts/evals/tsconfig.json | 15 ++ scripts/evals/types.ts | 130 ++++++++++++++ 57 files changed, 2430 insertions(+), 10 deletions(-) create mode 100644 scripts/evals/README.md create mode 100644 scripts/evals/cases.ts create mode 100644 scripts/evals/cases/README.md create mode 100644 scripts/evals/cases/stackone-agents/helpscout-to-claude.json create mode 100644 scripts/evals/cases/stackone-agents/jobadder-mcp-link-first.json create mode 100644 scripts/evals/cases/stackone-agents/langchain-agent-tools.json create mode 100644 scripts/evals/cases/stackone-agents/limit-tools-in-agent-context.json create mode 100644 scripts/evals/cases/stackone-cli/soap-conditional-element.json create mode 100644 scripts/evals/cases/stackone-connect/embed-hub-in-react.json create mode 100644 scripts/evals/cases/stackone-connect/oauth-app-whose-credentials.json create mode 100644 scripts/evals/cases/stackone-connectors/connector-catalog-endpoint.json create mode 100644 scripts/evals/cases/stackone-connectors/manatal-zinc-sonavate.json create mode 100644 scripts/evals/cases/stackone-connectors/paylocity-available.json create mode 100644 scripts/evals/cases/stackone-connectors/plaid-redirect-uri.json create mode 100644 scripts/evals/cases/stackone-connectors/sap-erp-connector.json create mode 100644 scripts/evals/cases/stackone-connectors/sap-per-user-auth.json create mode 100644 scripts/evals/cases/stackone-connectors/teams-publisher-attestation.json create mode 100644 scripts/evals/cases/stackone-connectors/workday-actions-available.json create mode 100644 scripts/evals/cases/stackone-connectors/workday-documents.json create mode 100644 scripts/evals/cases/stackone-connectors/workday-user-impersonation.json create mode 100644 scripts/evals/cases/stackone-platform/account-disconnect-notification.json create mode 100644 scripts/evals/cases/stackone-platform/account-status-meaning.json create mode 100644 scripts/evals/cases/stackone-platform/accounts-by-connector-profile.json create mode 100644 scripts/evals/cases/stackone-platform/accounts-no-credentials.json create mode 100644 scripts/evals/cases/stackone-platform/add-org-member.json create mode 100644 scripts/evals/cases/stackone-platform/api-key-for-jobadder.json create mode 100644 scripts/evals/cases/stackone-platform/configure-webhooks.json create mode 100644 scripts/evals/cases/stackone-platform/connector-billing.json create mode 100644 scripts/evals/cases/stackone-platform/create-api-key.json create mode 100644 scripts/evals/cases/stackone-platform/data-sync-off-map.json create mode 100644 scripts/evals/cases/stackone-platform/debug-401.json create mode 100644 scripts/evals/cases/stackone-platform/find-request-logs.json create mode 100644 scripts/evals/cases/stackone-platform/list-linked-accounts.json create mode 100644 scripts/evals/cases/stackone-platform/log-pii-redaction.json create mode 100644 scripts/evals/cases/stackone-platform/log-request-source.json create mode 100644 scripts/evals/cases/stackone-platform/org-project-account-hierarchy.json create mode 100644 scripts/evals/cases/stackone-platform/passthrough-idle-timeout.json create mode 100644 scripts/evals/cases/stackone-platform/rate-limit-429.json create mode 100644 scripts/evals/cases/stackone-platform/rename-organisation.json create mode 100644 scripts/evals/cases/stackone-platform/retry-backoff-guidance.json create mode 100644 scripts/evals/cases/stackone-unified-connectors/cursor-pagination-next.json create mode 100644 scripts/evals/grade.ts create mode 100644 scripts/evals/hosts/antigravity.ts create mode 100644 scripts/evals/hosts/claude.ts create mode 100644 scripts/evals/hosts/codex.ts create mode 100644 scripts/evals/hosts/cursor.ts create mode 100644 scripts/evals/hosts/index.ts create mode 100644 scripts/evals/hosts/liberal-transcript.ts create mode 100644 scripts/evals/judge.ts create mode 100644 scripts/evals/package-lock.json create mode 100644 scripts/evals/package.json create mode 100644 scripts/evals/process.ts create mode 100644 scripts/evals/report.ts create mode 100644 scripts/evals/run-host.ts create mode 100644 scripts/evals/tsconfig.json create mode 100644 scripts/evals/types.ts diff --git a/README.md b/README.md index efdf607..e182515 100644 --- a/README.md +++ b/README.md @@ -57,20 +57,26 @@ Each plugin includes a focused skill, step-by-step workflows, concrete examples, agent-plugins/ ├── .claude-plugin/ │ └── marketplace.json # Marketplace manifest — lists all plugins -└── plugins/ - ├── integrations/ - │ ├── stackone-platform/ - │ ├── stackone-connect/ - │ ├── stackone-agents/ - │ ├── stackone-connectors/ - │ ├── stackone-cli/ - │ └── stackone-unified-connectors/ - └── security/ - └── stackone-defender/ # ships its own hooks/, scripts/, package.json +├── plugins/ +│ ├── integrations/ +│ │ ├── stackone-platform/ +│ │ ├── stackone-connect/ +│ │ ├── stackone-agents/ +│ │ ├── stackone-connectors/ +│ │ ├── stackone-cli/ +│ │ └── stackone-unified-connectors/ +│ └── security/ +│ └── stackone-defender/ # ships its own hooks/, scripts/, package.json +└── scripts/ + └── evals/ # eval runner and, under cases//, each plugin's regression cases ``` Each plugin directory contains its own `.claude-plugin/plugin.json`, a `skills//` folder, and (for `stackone-defender`) the PostToolUse hook config plus ML scripts. +## Evals + +`scripts/evals/cases//` holds regression cases for each integration plugin: a prompt a user might type plus host-neutral checks on the outcome (which docs page the agent fetched, which names its reply used, and optionally a model's judgement against reference facts). They live beside the runner so the plugins ship without them. `scripts/evals/run-host.ts` runs a plugin's cases on Claude Code, Antigravity, Cursor or Codex with the same checks. See the [cases README](scripts/evals/cases/README.md) and the [runner README](scripts/evals/README.md). + ## Design Philosophy These skills **teach workflows** while pointing to **live documentation** for details that change frequently: diff --git a/scripts/evals/README.md b/scripts/evals/README.md new file mode 100644 index 0000000..68fcb3a --- /dev/null +++ b/scripts/evals/README.md @@ -0,0 +1,166 @@ +# Eval runner + +Runs a plugin's eval cases against one agent host, headless, in a throwaway project, and grades every run with the same host-neutral checks. Cases live here too, under `cases//`, one JSON file per case, and `cases/README.md` covers how to write and maintain them. The plugins ship without them. The rest of this directory is the machinery: how a case becomes a run, how a run becomes a verdict, and how to add a host. + +## Requirements + +| Need | Why | +|---|---| +| Node 22.18 or later | The runner is TypeScript that Node executes directly by stripping types. There is no build step and no runtime dependency. | +| The host's CLI, installed and signed in | See the hosts table below for what each one needs. | +| `npm --prefix scripts/evals install` (optional) | Installs `typescript` and `@types/node` for `npm --prefix scripts/evals run typecheck`. Nothing at run time uses them. | + +Type stripping only accepts erasable syntax, so the code uses `interface`, `type` and `import type`, and never enums, namespaces or parameter properties. Imports between modules carry the `.ts` extension because Node resolves them as files. + +## Running + +From the repo root: + +```bash +node scripts/evals/run-host.ts --host claude --plugin plugins/integrations/stackone-platform +``` + +| Flag | Meaning | Default | +|---|---|---| +| `--host` | `claude`, `antigravity`, `cursor` or `codex` | required | +| `--plugin` | Path to the plugin directory to load into the host. Its cases are read from `scripts/evals/cases//`. | required | +| `--cases` | Read cases from this directory instead | derived from `--plugin` | +| `--runs` | Runs per case. Use 3 or more when a case looks flaky. | 1 | +| `--model` | Model name in the host's own vocabulary | the adapter's default | +| `--case` | Run the cases whose file name starts with this. A full name runs one case; a shared prefix runs a group. | all cases | +| `--baseline` | Run the same prompts with no skill installed, to measure the skill's contribution | off | +| `--judge-model` | Model for the reference judge, in Claude Code's vocabulary | `sonnet` | +| `--score-reference` | Count the reference checks toward the run's score instead of reporting them as indicators | off | +| `--json` | Write the machine-readable result to this path | not written | + +Every run prints one line, `PASS` or `FAIL`, with the score, turn count, any failed checks, every URL the agent touched and every skill it reached. The suite ends with cases passed, overall score, cost when the host reports it, and the number of runs that ended in an error. Exit status is 1 when any case has a failing run, so the command works as a CI gate. + +The output directory printed at the start holds each run's transcript as `.run.jsonl` and its stderr as `.run.jsonl.err`. It lives under the operating system's temp directory, which gets cleaned, so pass `--json` and copy the transcripts out if you want to look at them later. + +## What a run does + +1. `cases.ts` reads every `cases//.json`. The file holds the `prompt`, sent as the user's message unchanged, an optional `max_turns`, and the checks. +2. For each case and run, `run-host.ts` makes a fresh working directory under the output directory and calls the adapter's `run`. The adapter launches the host there and returns the raw output. +3. The raw transcript is written to disk, then the adapter's `parse` reduces it to a `Transcript`: the tool calls made, each with its input, plus the final reply, the turn count, the cost and any error. +4. `grade.ts` turns the case's expectation and the transcript into a list of checks. The run's score is the share of scored checks that passed, and the run passes when all of them did. A run with no scored checks scores 1. +5. `report.ts` aggregates per case (mean score, pass rate, runs with errors) and across the suite, prints the summary and produces the `--json` document. + +Grading never sees host output directly, only the `Transcript`. That is what lets one case file grade Claude Code, Antigravity, Cursor and Codex alike. + +## Grading rules + +| Check | Passes when | Scored | +|---|---|---| +| `fetch[]` entry | Some tool call's input matches the regex | yes | +| `no_fetch[]` entry | No tool call's input matches | yes | +| `reply[]` entry | The final reply matches | yes | +| `no_reply[]` entry | The final reply does not match | yes | +| `skill-fired` (when `skill_should_fire` is `true`) | The skill under test was used | no, reported as an indicator | +| `skill-not-invoked` (when `skill_should_fire` is `false`) | The skill under test was not used | no, reported as an indicator | +| `reference-N` (one per `reference[]` fact) | The judge found the reply states fact N, in any wording or as code | only with `--score-reference` | +| `reference-no-contradictions` | The judge found nothing in the reply that contradicts the reference facts | only with `--score-reference` | +| `reference-judge` | Appears only when the judge call failed or its verdict could not be parsed; always failing, never scored | no | + +The details that make these host-neutral: + +- A regex in `match` is applied to the JSON encoding of each tool call's input, or to the reply text. Tool names are ignored, so "fetched" means any tool whose input carries the URL, whether the host calls it `WebFetch`, `read_url_content` or something else. +- A skill counts as used when a tool named `Skill` was called with the skill's name in its input, or when any tool input references `skills//SKILL.md`. The first is how Claude Code loads a skill; the second is how hosts without a skill tool read it from disk. +- Which skill fired is never scored. The verdict belongs to the outcome checks: a right answer reached through a different skill than expected is still a right answer, and a baseline run has no skill to fire, so scoring it would zero every baseline by construction. The per-run `skills:` line lists every skill the run reached, which is how an over-triggering description shows up without deciding a verdict. +- An error on the run (a timeout, a turn cap, a broken isolation check) does not fail it by itself. The checks still run on whatever transcript exists, the error is printed on the run's line, and the summary counts it under runs with errors, because a verdict on a truncated transcript is ambiguous. + +## Reference facts + +The string checks prove the reply was built from the right page with the current names. They cannot tell whether the answer is right. A case that needs that adds `reference[]` to its file: the facts a correct answer states, one per entry, written from the docs page at authoring time and kept to the essentials so they are quick to fix when the page changes. + +```json +"reference": [ + "The backend creates a connect session by calling POST /connect_sessions with the API key, sending origin_owner_id.", + "The frontend installs @stackone/hub and renders the StackOneHub component with the returned token.", + "The API key stays on the backend and is never sent to the browser." +] +``` + +After the run, `judge.ts` makes one model call with the reply and the list and asks, per fact, whether the reply covers it, omits it or contradicts it, and whether anything in the reply contradicts the facts as a whole. Each fact becomes a `reference-N` check with the judge's evidence in its `detail`, printed on failure. The judge is told that different wording, extra detail or a different but compatible approach is not a contradiction, so it grades substance rather than similarity. + +Two properties to know: + +- The judge always runs through Claude Code in print mode, with the same throwaway config directory the Claude adapter uses, whichever host the case ran on. A verdict therefore never depends on the host's model, and nothing beyond Claude Code has to be installed. Pin `--judge-model` when comparing runs. +- Reference checks are indicators until `--score-reference` is passed. Read a few runs' `detail` lines first: a fact the judge keeps reporting missing on correct replies is usually a fact that is not essential, and belongs out of the list rather than in a looser prompt. + +A judge call costs a few cents and its spend is counted in the suite total. A case without `reference[]` makes no judge call. + +## Modules + +| File | Responsibility | +|---|---| +| `run-host.ts` | Entry point. Parses flags, loops over cases and runs, writes transcripts, drives grading and reporting. | +| `types.ts` | The contracts everything else shares: `Expectation`, `EvalCase`, `Transcript`, `RawRun`, `RunContext`, `HostAdapter`, `Check` and the result shapes. | +| `cases.ts` | Loads the case files, separates the prompt and turn cap from the checks, applies the `--case` prefix filter. | +| `grade.ts` | The rules in the table above, plus `usesSkill` and `skillsUsed`. | +| `judge.ts` | The reference judge: builds the prompt, runs the model call, parses the verdict into checks. | +| `report.ts` | Per-run and suite console output, and `summarise`, which builds the `SuiteResult`. | +| `process.ts` | Runs a CLI with a large buffer and a ten minute cap, reads a CLI's version, parses JSON lines, and installs a plugin's skills with the Skills CLI. | +| `hosts/index.ts` | The adapter registry and the `HostName` guard. | +| `hosts/.ts` | One adapter per host. | +| `hosts/liberal-transcript.ts` | A schema-agnostic parser for hosts whose JSON event format has not been pinned down against a live run. | + +## Host adapters + +An adapter is an object with four members: + +| Member | Contract | +|---|---| +| `defaultModel` | Used when `--model` is not given. Pin `--model` when comparing runs so a score change is attributable to the skill and not to a model swap. | +| `version()` | The host CLI's version string, printed in the header and stored in the JSON. | +| `run(context)` | Launches the host headless in `context.workDir` with `context.prompt`, honouring `context.model` and `context.maxTurns`, and installs the plugin from `context.pluginDir` only when `context.withSkill` is true. Returns a `RawRun`: `stdout`, `stderr`, an optional `error`, and an optional `transcript` for hosts that keep the transcript somewhere other than stdout. | +| `parse(raw)` | Reduces the `RawRun` to a `Transcript`. Must be total: return whatever could be recovered and carry `raw.error` through. | + +How each host is driven: + +| Host | Launch | Skill installation | Transcript source | Needs | +|---|---|---|---|---| +| `claude` | `claude -p` with `--output-format stream-json`, `--strict-mcp-config`, `--allowedTools WebFetch Skill`, and a throwaway `CLAUDE_CONFIG_DIR` so no installed plugin, MCP server or user setting loads | `--plugin-dir ` | stdout: `tool_use` blocks on assistant events, reply, turns and cost on the result event | Claude Code signed in | +| `antigravity` | `agy -p` with `--add-dir `, `--dangerously-skip-permissions` and a print timeout | `npx skills add -a antigravity-cli` into `.agents/skills/` | The conversation transcript under `~/.gemini/antigravity-cli/brain/`, found through `cache/last_conversations.json` keyed by working directory; stdout is only the reply | `agy` signed in | +| `cursor` | `cursor-agent -p --output-format stream-json` | `npx skills add -a cursor` | stdout, parsed liberally until the event schema is confirmed | `cursor-agent login` or `CURSOR_API_KEY` | +| `codex` | `codex exec --json` | `npx skills add -a codex` | stdout, parsed liberally until the event schema is confirmed | a working `codex` install | + +Details that affect results: + +- The Claude adapter refuses to trust a run where the init event lists more than one plugin besides Claude Code's built-in ones. That means the throwaway config directory failed to isolate the run and installed plugins leaked in, so the run is marked with an error naming them. It deliberately does not use `--bare`, which would isolate too but drops keychain login. +- Antigravity only sees the installed skills when the working directory is registered with `--add-dir`; the runner always passes the absolute path. Its tool calls take tens of seconds each, so a case runs for minutes. It reports no cost, so the summary shows `n/a`. +- The Skills CLI installer initialises a git repository in the working directory first, because the CLI expects one, and installs with `--copy` so the run does not depend on symlinks into the repo. +- `exec` caps any host at ten minutes and reports `timed out` as the run's error. Raise `max_turns` in the case before assuming the skill is at fault. + +## Adding a host + +1. Create `hosts/.ts` exporting a `HostAdapter`. Copy `cursor.ts` as the starting point: it is the smallest adapter. +2. Add the name to the `HostName` union in `types.ts` and to the registry in `hosts/index.ts`. +3. Decide how the host reaches the skills. If it reads `.agents/skills/` or a similar project directory, `installWithSkillsCli` from `process.ts` does the installation the way a user would; pass the agent name the Skills CLI uses for that host. If it has its own plugin mechanism, pass the plugin directory on the command line instead. +4. Run one case with `--case` and open the transcript in the output directory. Confirm `parse` returns tool calls with their inputs and a non-empty reply; a run that fetched pages but shows no `urls:` line means the inputs are not being found. +5. Run the same case with `--baseline` and confirm no skill check fires, which proves the skill is not leaking in from elsewhere on the machine. +6. Once the host's JSON event schema is understood, replace `parseLiberally` with a parser that reads the known fields, and record the schema in the adapter's header comment. + +## The JSON result + +`--json` writes one document per suite run: + +| Field | Content | +|---|---| +| `host`, `hostVersion`, `model`, `withSkill`, `runsPerCase`, `startedAt` | How the suite was run | +| `cases[]` | One entry per case: `name`, `aggregates` (`score`, `passRate`, `runsWithErrors`) and `runs[]` | +| `cases[].runs[]` | `passed`, `score`, `turns`, `costUsd`, `judgeCostUsd`, `error`, `checks[]` (`name`, `passed`, `scored`, `detail`), `toolCalls[]` (tool names in order), `skillsUsed[]`, `transcriptPath` | +| `aggregates` | `casesTotal`, `casesPassed`, `overallScore`, `overallPassRate`, `runsWithErrors` | +| `costUsd` | Total spend including judge calls, or `null` when nothing reported it | + +A case counts as passed when every one of its runs passed. `overallScore` is the mean of the case scores, and a case score is the mean of its run scores. + +## Comparing runs + +Two comparisons answer most questions. Whether the skill helps at all is the suite with the skill against `--baseline`, same host and model. Whether a change fixed or broke something is the suite on the branch against the same suite on `main`, same host and model. For the second, run the branch's runner and cases against a checkout of `main`'s plugin: + +```bash +mkdir -p /tmp/ap-main && git archive origin/main | tar -x -C /tmp/ap-main +node scripts/evals/run-host.ts --host claude --plugin /tmp/ap-main/plugins/integrations/stackone-platform +``` + +The cases come from `cases/stackone-platform/` on the branch because they are keyed by the plugin directory's name, so nothing has to be copied. diff --git a/scripts/evals/cases.ts b/scripts/evals/cases.ts new file mode 100644 index 0000000..47092ea --- /dev/null +++ b/scripts/evals/cases.ts @@ -0,0 +1,45 @@ +// Loads eval cases from a directory. A case is one JSON file, .json, +// holding the prompt, an optional turn cap and the checks. + +import { readdirSync, readFileSync } from 'node:fs'; +import { basename, join } from 'node:path'; +import type { EvalCase, Expectation } from './types.ts'; + +export interface CaseFilters { + /** Only cases whose file name starts with this run; a full name selects one case. */ + casePrefix?: string; +} + +/** The on-disk shape: the prompt and turn cap sit next to the expectation's checks. */ +interface CaseFile extends Expectation { + prompt: string; + max_turns?: number; +} + +const DEFAULT_MAX_TURNS = 12; + +export function loadCases(evalsDir: string, filters: CaseFilters = {}): EvalCase[] { + const cases: EvalCase[] = []; + for (const fileName of readdirSync(evalsDir).sort()) { + if (!fileName.endsWith('.json')) { + continue; + } + const name = basename(fileName, '.json'); + if (filters.casePrefix && !name.startsWith(filters.casePrefix)) { + continue; + } + const path = join(evalsDir, fileName); + const { prompt, max_turns, ...expectation } = JSON.parse(readFileSync(path, 'utf8')) as CaseFile; + if (typeof prompt !== 'string' || !prompt.trim()) { + throw new Error(`${path}: "prompt" must be a non-empty string`); + } + cases.push({ + name, + path, + prompt: prompt.trim(), + maxTurns: max_turns ?? DEFAULT_MAX_TURNS, + expectation, + }); + } + return cases; +} diff --git a/scripts/evals/cases/README.md b/scripts/evals/cases/README.md new file mode 100644 index 0000000..9ebb8ab --- /dev/null +++ b/scripts/evals/cases/README.md @@ -0,0 +1,170 @@ +# Eval cases + +Regression cases for the integration plugins, graded the same way on every agent host. Each case is a prompt a user might type plus host-neutral checks on the outcome: which documentation URL the agent fetched, which package, field and action names its reply used, and optionally a list of facts a model judges the reply against. Which skill took the question is printed for diagnosis but never graded. + +Cases are grouped by the plugin whose territory the question is in, one directory per plugin, and a run loads only that plugin. Most prompts come from real support conversations, rephrased as questions and anonymised. Two kinds of case sit alongside the documented ones: questions in a plugin's territory that the docs do not answer, and questions no plugin covers. For both, the right reply says the docs do not cover it and points to StackOne support, and the checks fail if the agent invents an answer instead. + +## Cases + +Documented answers: + +| Case | Plugin | Checks | +|---|---|---| +| `debug-401` | platform | fetches `/platform-api/authentication`, never the retired `/overview/authentication` | +| `list-linked-accounts` | platform | reply uses `/v2/accounts`, `connector`, `owner_id`; never `origin_owner_id` or the v1 reference | +| `rate-limit-429` | platform | fetches `/platform-api/rate-limiting`, never the retired `/overview/rate-limits` | +| `retry-backoff-guidance` | platform | fetches the rate limiting page; reply mentions `Retry-After`; facts: wait for the header, no documented retry count | +| `configure-webhooks` | platform | fetches the Webhooks guide or the Platform Events reference; never the retired `/guides/webhooks` | +| `account-disconnect-notification` | platform | fetches Handle Account Events or Webhooks; reply names the `account.*` events | +| `find-request-logs` | platform | fetches the Troubleshooting guide or the List Logs reference | +| `log-request-source` | platform | fetches the logs docs; reply names `source_type` or `source_id`; facts: no fields beyond the reference | +| `create-api-key` | platform | fetches the API Keys page | +| `api-key-for-jobadder` | platform | fetches the API Keys page and the JobAdder docs; facts keep the API key and JobAdder's OAuth app distinct | +| `account-status-meaning` | platform | fetches the v2 accounts reference, never the v1 one; reply avoids `origin_owner_id` | +| `accounts-by-connector-profile` | platform | fetches the v2 accounts reference; reply uses `connector_profile_id` | +| `accounts-no-credentials` | platform | fetches the accounts reference or concept page; never names a credentials endpoint; facts: absent by design, ask support | +| `org-project-account-hierarchy` | platform | fetches the concepts or multi-tenant pages; facts: organisation, project, account and what isolates what | +| `add-org-member` | platform | fetches Manage Team; reply mentions inviting or Admin | +| `data-sync-off-map` | platform | a topic the skill's map does not list: fetches `llms.txt` and then a Data Sync page, proving index-first routing | +| `embed-hub-in-react` | connect | fetches the Hub or Connect Session docs; reply names `@stackone/hub`, a connect session and `origin_owner_id` | +| `oauth-app-whose-credentials` | connect | fetches Use Your Own OAuth Apps; facts: one app, customers authorise through it | +| `langchain-agent-tools` | agents | fetches the Agent SDK or MCP docs; reply names `stackone-ai` or the MCP adapters and the LangChain conversion | +| `jobadder-mcp-link-first` | agents | fetches the JobAdder and MCP docs; facts: link first, OAuth app in the Developer Portal | +| `helpscout-to-claude` | agents | fetches the Help Scout and Claude Desktop docs; reply mentions MCP; facts: profile, custom connector URL, consent | +| `limit-tools-in-agent-context` | agents | fetches Advanced Tool Search, Tool Discovery or Scoping Connectors | +| `workday-actions-available` | connectors | fetches the Workday connector page; reply names at least one `workday_*` action | +| `workday-user-impersonation` | connectors | fetches the Workday docs; reply names the user login flow auth types | +| `workday-documents` | connectors | fetches the Workday page; reply names a `workday_*document*` action, against a stale support reply that said none existed | +| `sap-erp-connector` | connectors | fetches the SAP S/4HANA page; reply names S/4HANA | +| `manatal-zinc-sonavate` | connectors | fetches the Manatal and Zinc pages; never a `connectors/sonavate` URL; facts: two exist, one does not | +| `paylocity-available` | connectors | fetches the Paylocity page | +| `connector-catalog-endpoint` | connectors | fetches the v2 Connectors reference, the RPC page or Actions Metadata for Custom UIs; reply names `/connectors` or `/actions` | +| `soap-conditional-element` | cli | fetches the expression language or soap_request reference; reply uses `present(` | +| `cursor-pagination-next` | unified-connectors | fetches the paginated_request reference; reply mentions the cursor | + +Graceful no. The reply must point to StackOne support, and the facts fail it for inventing a setting, a value or a field: + +| Case | Plugin | Why the docs cannot answer it | +|---|---|---| +| `passthrough-idle-timeout` | platform | no timeout is documented; `no_reply` fails any number of seconds | +| `log-pii-redaction` | platform | no redaction feature is documented | +| `sap-per-user-auth` | connectors | the SAP page documents OAuth profiles only | +| `plaid-redirect-uri` | connectors | the Plaid page does not say which redirect URI to use | +| `rename-organisation` | platform (no plugin covers it) | dashboard administration, no page | +| `connector-billing` | platform (no plugin covers it) | pricing is not in the developer docs | +| `teams-publisher-attestation` | connectors (no plugin covers it) | partner and legal process, no page | + +The three "no plugin covers it" cases sit with the nearest plugin and carry `skill_should_fire: false`; they check that the skill neither answers nor invents. + +Checks match exact URLs and backticked field names rather than prose, because phrasing changes between runs and hosts and those strings do not. + +## How a run works + +1. `scripts/evals/run-host.ts` starts the chosen host headless in a throwaway working directory. Claude Code also gets a throwaway config directory and loads the plugin with `--plugin-dir`; every other host gets the plugin's skill installed into the working directory with `npx skills add -a `, the way a user installs it. Only the plugin under test is present, and nothing personal or project-level is. +2. It sends the case's `prompt` as the user's message and lets the agent work until it finishes or hits `max_turns`. +3. It normalises the host's transcript to the tool calls made, with their inputs, and the final reply. +4. Each check in the case file passes or fails against that. A run's score is the share of scored checks that passed; a case's score is the mean over its runs. Cases with `reference[]` also get one judge call per run. +5. `--baseline` runs the same prompts with no skill installed, so the skill's contribution is visible. + +The repo does not use `claude plugin eval`. One grading implementation across hosts was chosen over a second, Claude-only one that could disagree with it. + +## Layout + +``` +scripts/evals/ + run-host.ts the runner, shared by every plugin in this repo + cases/ + README.md this file + /.json one file per case: the prompt, an optional turn cap, the checks +``` + +The cases sit beside the runner rather than inside the plugins, so the plugins ship without test fixtures. The runner finds a plugin's cases by its directory name: `--plugin plugins/integrations/stackone-platform` reads `cases/stackone-platform/`. + +## The case file + +| Field | Meaning | +|---|---| +| `prompt` | what the user types, sent unchanged | +| `max_turns` | optional turn cap for the agent; 12 when absent | +| `skill` | the skill whose territory the prompt is in, used by the fired indicator | +| `skill_should_fire` | whether you expect that skill to be used; reported per run, never scored | +| `skill_note` | why that skill should or should not be the one answering; for the reader, the runner ignores it | +| `fetch[]` | `{name, match, note}`: some tool call's input must match `match` | +| `no_fetch[]` | no tool call's input may match | +| `reply[]` | the final reply must match | +| `no_reply[]` | the final reply must not match | +| `reference[]` | the facts a correct answer states, one per entry; a model judges the reply against each for coverage and contradiction, reported as indicators until the runner is passed `--score-reference` | + +`match` is a JavaScript regex source, applied to the JSON-encoded tool input or to the reply text. "Fetched" means any tool whose input matches, whatever the host calls its fetch tool. Put backticks around field names (`` `connector` ``) so the check does not match the word "connectors" in prose. + +Which skill fired is never scored. A right answer reached through a different route than expected is still a right answer, hosts reach skills differently (Claude Code has a `Skill` tool, other hosts read the `SKILL.md` file), and a baseline run has no skill to fire. The runner prints a `skills:` line per run listing every skill it reached, so an over-triggering description is visible without deciding a verdict. Detection is either an explicit skill-invocation call naming the skill or a read of `skills//SKILL.md`. + +## Running + +```bash +# one plugin's cases on Claude Code, one run each +node scripts/evals/run-host.ts --host claude --plugin plugins/integrations/stackone-platform + +# one case, three runs, machine-readable result +node scripts/evals/run-host.ts --host claude --plugin plugins/integrations/stackone-platform --case debug-401 --runs 3 --json out.json + +# one case, three runs, on a stronger model; --case also accepts a name prefix +node scripts/evals/run-host.ts --host claude --plugin plugins/integrations/stackone-connect --case embed-hub-in-react --runs 3 --model opus + +# the same prompts with no skill installed +node scripts/evals/run-host.ts --host claude --plugin plugins/integrations/stackone-platform --baseline + +# other hosts +node scripts/evals/run-host.ts --host cursor --plugin plugins/integrations/stackone-platform --model sonnet-4 +node scripts/evals/run-host.ts --host codex --plugin plugins/integrations/stackone-platform --model gpt-5 + +# every plugin's cases +for p in plugins/integrations/*/; do node scripts/evals/run-host.ts --host claude --plugin "$p"; done +``` + +The runner is TypeScript that Node 22.18 or later executes directly, with no dependencies at run time. To typecheck it, `npm --prefix scripts/evals install` once, then `npm --prefix scripts/evals run typecheck`. Host adapters live one per file under `scripts/evals/hosts/`. + +Exit status is 1 when any case has a failing run. `--json` writes `host`, `hostVersion`, `model`, `withSkill`, per-case `aggregates` and per-run `checks`, plus overall `aggregates` and `costUsd`. Every run's transcript and stderr are kept in the output directory printed at the start. + +### Hosts + +How each host is launched, where its transcript comes from, what it needs to be signed in, and how to add a new one are documented in [`scripts/evals/README.md`](../README.md). Two things from there matter when reading results: pin `--model` when comparing runs, so a score change is attributable to the skill and not to a model swap, and remember that hosts name their fetch tools differently (`WebFetch` on Claude Code, `read_url_content` on Antigravity, which also appends `.md` to docs URLs). Checks match on the tool input, never the tool name, for exactly this reason. + +### Two comparisons + +| Question | Run | +|---|---| +| Does the skill help at all? | with the skill and with `--baseline`, same host and model | +| Did my change fix or break something? | the suite against `main` and against your branch, same host and model | + +```bash +mkdir -p /tmp/ap-main && git archive origin/main | tar -x -C /tmp/ap-main +node scripts/evals/run-host.ts --host claude --plugin /tmp/ap-main/plugins/integrations/stackone-platform +``` + +The cases come from this directory on your branch, keyed by the plugin directory's name, so nothing is copied; only the plugin under test comes from `main`. A case that fails on `main` and passes on the branch is the regression signal. + +## Adding a case + +1. Put the file in the directory of the plugin whose territory the question is in, and name it after the user's situation (`debug-401.json`), not after the fix. Related cases can share a name prefix so `--case ` runs them together. +2. Write the `prompt`: what a user would type, with no hint toward the answer you want. Phrase it as a question that can be answered in the reply ("How do I..., show me the code"), not as an instruction to build something: the run's working directory is empty and only fetching and skills are allowed, so "embed X in my app" ends with the agent asking where the app is or asking for write permission, and there is no reply to grade. Add `max_turns` only when 12 is not enough; a case that fetches several pages may need 16. +3. Write the checks, one entry each. The string checks are deterministic and free. If the answer has substance worth judging, add `reference[]`: the facts a correct answer states, written from the docs page, kept to the essentials. That adds one model call per run. For a question the docs cannot answer, the reply check is "contact StackOne support" and the facts say what the agent must not invent. +4. Run the case against `main` first. If it already passes there it is not testing your change; sharpen the check or drop the case. +5. Run it against your branch. Fail on `main`, pass on the branch, is the result you want. +6. Run it on every host the plugin ships to. + +## Maintaining cases + +| Situation | Do | +|---|---| +| A docs URL moves | Update `match` in the `fetch` entry. If the old path now returns 404, add it to `no_fetch` so nobody reintroduces it. | +| A case passes on some runs and fails on others | Run it at least three times. A regression fails every run; a flaky trigger passes some. Sharpen the prompt or the skill's description. Do not loosen the check. | +| A skill's "Do NOT use for" list changes | Add an outcome case in the other plugin's directory, so its suite proves the question still gets answered from the right docs. | +| The `skills:` line shows the skill firing on a question it should not own | The outcome checks decide the verdict, so this is a cost and clarity problem rather than a failure. Sharpen the description with the other plugin's concrete terms, and rerun to confirm the outcome still holds. | +| A check passes on `main` | It is a sanity check, not a regression check. Keep it only if it guards something the change could break. | +| A reference fact is reported missing or contradicted | Read the judge's `detail` and the reply. A contradiction on a correct-looking reply is a real finding about the skill or the docs. A fact reported missing on replies that are otherwise right is usually not essential; drop it from `reference[]` rather than reword it until the judge agrees. | +| The docs gain a page for a graceful-no case | Turn it into a documented case: the fetch anchor becomes that page and the facts become what it says. The support wording stops being the expected answer. | +| A run fails and you are tempted to edit the check | Read the run's transcript in the output directory first. The runner prints the URLs each run touched; most failures are the agent fetching a page you did not expect, which is information about the skill, not the check. | +| A run reports a turn-cap error | The checks ran on a truncated transcript, so the verdict is ambiguous. Raise `max_turns` in the case file until healthy runs finish well under it. A skill that sends the agent through several dead pages needs more turns than one that fetches once, and the baseline arm has no skill at all. | +| A host's score differs from another's | Compare the transcripts before blaming the skill. Hosts default to different models and expose different tools; pin `--model` and check which tool each host used to fetch. | +| Cost climbs | String checks cost nothing; each agent run costs model tokens, plus a few cents per judge call for cases with `reference[]`. Iterate with a cheaper `--model` and `--case`; run the full suite on each host's default model before merging, since that is what most users of the skill will be on. | diff --git a/scripts/evals/cases/stackone-agents/helpscout-to-claude.json b/scripts/evals/cases/stackone-agents/helpscout-to-claude.json new file mode 100644 index 0000000..bd15203 --- /dev/null +++ b/scripts/evals/cases/stackone-agents/helpscout-to-claude.json @@ -0,0 +1,33 @@ +{ + "prompt": "How do I connect Help Scout to Claude through StackOne?", + "max_turns": 16, + "skill": "stackone-agents", + "skill_should_fire": true, + "skill_note": "Connecting Claude over MCP is agents territory; the Help Scout linking half belongs to stackone-connectors. Either may fire; the outcome is what counts.", + "fetch": [ + { + "name": "fetches-helpscout-docs", + "match": "docs\\.stackone\\.com/connectors/helpscout", + "note": "The Help Scout connector page or its connector-profile guide." + }, + { + "name": "fetches-claude-or-mcp-docs", + "match": "docs\\.stackone\\.com/(connect/ai-platforms/claude-desktop|embed/call-actions/mcp|mcp/app-guides/claude-desktop)", + "note": "The Claude Desktop guide, an MCP page, or the older guide path that redirects." + } + ], + "no_fetch": [], + "reply": [ + { + "name": "mentions-mcp", + "match": "MCP", + "note": "Claude connects to StackOne over MCP." + } + ], + "no_reply": [], + "reference": [ + "First link a Help Scout account in StackOne through a connector profile of type OAuth 2.0 - Client Credentials.", + "Then add StackOne to Claude as a custom connector with the remote MCP server URL https://mcp.stackone.com/mcp, from Customize > Connectors, or Organization settings > Connectors for a team.", + "Claude runs the OAuth flow itself; on the consent screen the user picks the project and the linked accounts the client may reach." + ] +} diff --git a/scripts/evals/cases/stackone-agents/jobadder-mcp-link-first.json b/scripts/evals/cases/stackone-agents/jobadder-mcp-link-first.json new file mode 100644 index 0000000..8c71a9e --- /dev/null +++ b/scripts/evals/cases/stackone-agents/jobadder-mcp-link-first.json @@ -0,0 +1,33 @@ +{ + "prompt": "I want to use StackOne's JobAdder MCP with my AI agent. Should I build the agent first and then connect StackOne, or the other way round? And what do I need to set up on the JobAdder side?", + "max_turns": 16, + "skill": "stackone-agents", + "skill_should_fire": true, + "skill_note": "Connecting an agent over MCP is agents territory; the JobAdder setup half belongs to stackone-connectors. Either may fire; the outcome is what counts.", + "fetch": [ + { + "name": "fetches-jobadder-docs", + "match": "docs\\.stackone\\.com/connectors/jobadder", + "note": "The JobAdder connector page or its OAuth connector-profile guide." + }, + { + "name": "fetches-mcp-docs", + "match": "docs\\.stackone\\.com/(embed/call-actions/mcp|connect/ai-platforms|mcp/quickstart)", + "note": "An MCP page, or the older quickstart path that redirects." + } + ], + "no_fetch": [], + "reply": [ + { + "name": "mentions-oauth", + "match": "OAuth", + "note": "JobAdder connects through an OAuth 2.0 connector profile." + } + ], + "no_reply": [], + "reference": [ + "Set up StackOne and link the JobAdder account first, then connect the agent to StackOne over MCP; the agent does not need to exist first.", + "JobAdder uses OAuth 2.0: register an application in the JobAdder Developer Portal with StackOne's redirect URI and put its Client ID and Client Secret in a JobAdder connector profile.", + "Once the account is linked, the agent reaches JobAdder's actions through the StackOne MCP server or the Agent SDK." + ] +} diff --git a/scripts/evals/cases/stackone-agents/langchain-agent-tools.json b/scripts/evals/cases/stackone-agents/langchain-agent-tools.json new file mode 100644 index 0000000..b334b2b --- /dev/null +++ b/scripts/evals/cases/stackone-agents/langchain-agent-tools.json @@ -0,0 +1,33 @@ +{ + "prompt": "How do I add StackOne tools to my LangChain agent in Python so it can list employees from BambooHR? Show me the code.", + "skill": "stackone-agents", + "skill_should_fire": true, + "skill_note": "Putting StackOne tools into an agent framework is stackone-agents territory. Whether it fired is reported, not scored; the checks below are the outcome a user needs.", + "fetch": [ + { + "name": "fetches-agent-sdk-or-mcp-docs", + "match": "docs\\.stackone\\.com/embed/call-actions/|stackone-ai-python|docs\\.stackone\\.com/mcp/quickstart", + "note": "The Agent SDK or MCP pages under Embed, the Python SDK README the skill points at, or the older MCP quickstart path that redirects." + } + ], + "no_fetch": [], + "reply": [ + { + "name": "names-a-documented-package", + "match": "stackone-ai|langchain[-_]mcp[-_]adapters", + "note": "LangChain reaches StackOne tools through the stackone-ai Python SDK or through the MCP adapters package; both are documented paths." + }, + { + "name": "shows-the-langchain-conversion", + "match": "to_langchain\\(|MultiServerMCPClient|load_mcp_tools", + "note": "The SDK converts with to_langchain(); the MCP path loads tools through the adapters client." + } + ], + "no_reply": [], + "reference": [ + "The tools come from the stackone-ai Python package through a StackOneToolSet, or from the StackOne MCP server through LangChain's MCP adapters; either documented path is acceptable.", + "Authentication uses the StackOne API key, read from the STACKONE_API_KEY environment variable or passed explicitly.", + "Tools are fetched for the linked BambooHR account by its account id, and can be narrowed to BambooHR or to the list-employees action with a filter such as actions=[\"bamboohr_*\"].", + "The fetched tools are converted for LangChain with to_langchain() and bound to the chat model, or loaded through the MCP adapters client." + ] +} diff --git a/scripts/evals/cases/stackone-agents/limit-tools-in-agent-context.json b/scripts/evals/cases/stackone-agents/limit-tools-in-agent-context.json new file mode 100644 index 0000000..6e7cab0 --- /dev/null +++ b/scripts/evals/cases/stackone-agents/limit-tools-in-agent-context.json @@ -0,0 +1,27 @@ +{ + "prompt": "My agent is loading far too many StackOne tools and the context is huge. How do I limit which actions are exposed, or discover the right tool at run time instead of loading everything?", + "skill": "stackone-agents", + "skill_should_fire": true, + "skill_note": "Tool discovery and context size are agents territory.", + "fetch": [ + { + "name": "fetches-tool-search-or-scoping-docs", + "match": "docs\\.stackone\\.com/(optimize/advanced-tool-search|features/tool-discovery|secure/scoping-connectors)", + "note": "Advanced Tool Search, Tool Discovery or Scoping Connectors." + } + ], + "no_fetch": [], + "reply": [ + { + "name": "mentions-search-or-scoping", + "match": "[Ss]earch|[Ss]cop", + "note": "The two documented levers: search-based discovery and scoping the profile." + } + ], + "no_reply": [], + "reference": [ + "Scope the connector profile to only the actions the app uses; that limits every linked account on the profile and shrinks the tool set.", + "Use tool search: discover the right action by natural language at run time and then execute it, instead of loading every tool definition into context.", + "Loading hundreds of tool definitions burns tokens and hurts tool selection accuracy, which is why the docs recommend search-based discovery." + ] +} diff --git a/scripts/evals/cases/stackone-cli/soap-conditional-element.json b/scripts/evals/cases/stackone-cli/soap-conditional-element.json new file mode 100644 index 0000000..caf4bc7 --- /dev/null +++ b/scripts/evals/cases/stackone-cli/soap-conditional-element.json @@ -0,0 +1,27 @@ +{ + "prompt": "In a StackOne connector YAML I'm building a SOAP request body. How do I include an XML element only when the action's input for it is set, and leave it out otherwise?", + "skill": "stackone-cli", + "skill_should_fire": true, + "skill_note": "Custom connector YAML is cli territory.", + "fetch": [ + { + "name": "fetches-expression-or-soap-docs", + "match": "docs\\.stackone\\.com/connector-yaml-reference/(expression-language|step-functions/soap-request)", + "note": "The expression language reference or the soap_request step function." + } + ], + "no_fetch": [], + "reply": [ + { + "name": "uses-present", + "match": "present\\(", + "note": "The function that tests whether an input is set." + } + ], + "no_reply": [], + "reference": [ + "The expression language has a present() function for testing whether an input is set.", + "A ternary in an interpolated expression can return the element when present and null when not, for example {{present(inputs.x) ? ... : null}}, and a null value drops the element.", + "Fields also accept a condition using present(), for example condition: '{{present(inputs.filter)}}'." + ] +} diff --git a/scripts/evals/cases/stackone-connect/embed-hub-in-react.json b/scripts/evals/cases/stackone-connect/embed-hub-in-react.json new file mode 100644 index 0000000..2552f77 --- /dev/null +++ b/scripts/evals/cases/stackone-connect/embed-hub-in-react.json @@ -0,0 +1,41 @@ +{ + "prompt": "How do I embed the StackOne integration picker in my React app so customers can connect their HR system? Show me the code for both the backend and the React side.", + "max_turns": 16, + "skill": "stackone-connect", + "skill_should_fire": true, + "skill_note": "Embedding the Hub and linking accounts is stackone-connect territory. Whether it fired is reported, not scored; the checks below are the outcome a user needs.", + "fetch": [ + { + "name": "fetches-account-linking-docs", + "match": "docs\\.stackone\\.com/(embed/(account-linking|connect-session)|guides/(connect-tools-overview|embedding-stackone-hub)|platform/api-reference/connect-sessions/create-connect-session)", + "note": "The Hub and Connect Session pages under Embed, the older guide paths that redirect to them, or the Create Connect Session reference." + } + ], + "no_fetch": [], + "reply": [ + { + "name": "names-hub-package", + "match": "@stackone/hub", + "note": "The React component ships as the @stackone/hub package." + }, + { + "name": "creates-connect-session", + "match": "connect_sessions|[Cc]onnect [Ss]ession", + "note": "The backend must mint a connect session token for the Hub to initialise with." + }, + { + "name": "uses-origin-owner-id", + "match": "origin_owner_id", + "note": "The session request identifies the customer by origin_owner_id." + } + ], + "no_reply": [], + "reference": [ + "The backend creates a connect session by calling POST /connect_sessions with the StackOne API key, sending origin_owner_id to identify the customer's organisation.", + "The response carries a token, and the backend returns that token to the frontend.", + "The frontend installs @stackone/hub and renders the StackOneHub component with that token.", + "The Hub's onSuccess callback receives the linked account id, which the app persists for later action calls.", + "The API key stays on the backend and is never sent to the browser.", + "origin_owner_id is set server-side, never taken from the client request." + ] +} diff --git a/scripts/evals/cases/stackone-connect/oauth-app-whose-credentials.json b/scripts/evals/cases/stackone-connect/oauth-app-whose-credentials.json new file mode 100644 index 0000000..03d66d0 --- /dev/null +++ b/scripts/evals/cases/stackone-connect/oauth-app-whose-credentials.json @@ -0,0 +1,28 @@ +{ + "prompt": "To add a Google connector profile I have to enter my own Google client ID and secret, and that works, but then it seems tied to my Google account rather than my customers' accounts. Do I need each customer's client ID and secret? What am I doing wrong?", + "skill": "stackone-connect", + "skill_should_fire": true, + "skill_note": "OAuth apps and connector profiles for account linking are connect territory.", + "fetch": [ + { + "name": "fetches-oauth-apps-docs", + "match": "docs\\.stackone\\.com/(connect/managing-connectors/using-your-own-oauth-apps|gateway/concepts/connector-profiles)", + "note": "The Use Your Own OAuth Apps page or the connector profile concept." + } + ], + "no_fetch": [], + "reply": [ + { + "name": "mentions-client-id", + "match": "[Cc]lient ID", + "note": "The reply must address whose client ID goes in the profile." + } + ], + "no_reply": [], + "reference": [ + "A connector profile holds one OAuth app's client ID and secret; that app is the client through which every customer authorises their own account, so customers do not supply their own client IDs.", + "The client ID being yours does not tie the linked accounts to your Google account: each customer links their own account by signing in through your app.", + "StackOne's shared OAuth credentials are an alternative for some providers; registering your own app is the normal choice when connecting customers' tools.", + "The reply does not tell the user to collect client IDs and secrets from each customer." + ] +} diff --git a/scripts/evals/cases/stackone-connectors/connector-catalog-endpoint.json b/scripts/evals/cases/stackone-connectors/connector-catalog-endpoint.json new file mode 100644 index 0000000..96bda9c --- /dev/null +++ b/scripts/evals/cases/stackone-connectors/connector-catalog-endpoint.json @@ -0,0 +1,28 @@ +{ + "prompt": "Is there an endpoint I can call to list every connector StackOne supports and the actions each one has? I want to show my customers what they can integrate without scraping your website every few weeks.", + "skill": "stackone-connectors", + "skill_should_fire": true, + "skill_note": "Discovering connectors and actions is connectors territory; the reference endpoints are platform territory. Either may fire; the outcome is what counts.", + "fetch": [ + { + "name": "fetches-catalog-docs", + "match": "docs\\.stackone\\.com/(platform/api-reference/v2/connectors/(list-connectors|get-connector|get-connector-action)|embed/call-actions/rpc-http|features/actions-metadata-for-custom-uis)", + "note": "The v2 Connectors reference, the RPC page that documents GET /actions, or the Actions Metadata for Custom UIs guide." + } + ], + "no_fetch": [], + "reply": [ + { + "name": "names-an-endpoint", + "match": "/connectors|/actions", + "note": "The endpoints that list connectors and actions." + } + ], + "no_reply": [], + "reference": [ + "The v2 Connectors endpoints list connectors and return a connector's actions (List Connectors, Get Connector, Get Connector Action).", + "GET /actions lists the actions available to call, which is the documented way to discover them before making an RPC call.", + "The Actions Metadata for Custom UIs guide covers building exactly this kind of catalogue interface from the API.", + "The reply does not tell the user to scrape the website." + ] +} diff --git a/scripts/evals/cases/stackone-connectors/manatal-zinc-sonavate.json b/scripts/evals/cases/stackone-connectors/manatal-zinc-sonavate.json new file mode 100644 index 0000000..9f6d5e3 --- /dev/null +++ b/scripts/evals/cases/stackone-connectors/manatal-zinc-sonavate.json @@ -0,0 +1,44 @@ +{ + "prompt": "Do you have connectors for Manatal, Zinc and Sonavate?", + "skill": "stackone-connectors", + "skill_should_fire": true, + "skill_note": "Which providers exist is connectors territory. One of the three does not exist, which is the point.", + "fetch": [ + { + "name": "fetches-manatal-page", + "match": "docs\\.stackone\\.com/connectors/manatal", + "note": "Manatal's connector page." + }, + { + "name": "fetches-zinc-page", + "match": "docs\\.stackone\\.com/connectors/zinc", + "note": "Zinc's connector page." + } + ], + "no_fetch": [], + "reply": [ + { + "name": "mentions-manatal", + "match": "Manatal", + "note": "Exists." + }, + { + "name": "mentions-zinc", + "match": "Zinc", + "note": "Exists." + } + ], + "no_reply": [ + { + "name": "no-invented-sonavate-page", + "match": "connectors/sonavate", + "note": "There is no Sonavate connector; a URL for one is invention." + } + ], + "reference": [ + "Manatal has a connector; it uses API token authentication.", + "Zinc has a connector; it authenticates with a Zinc Partner API key used as a bearer token.", + "Sonavate is not a StackOne connector; the reply says so rather than inventing one.", + "The reply checked the current connector docs rather than assuming from memory." + ] +} diff --git a/scripts/evals/cases/stackone-connectors/paylocity-available.json b/scripts/evals/cases/stackone-connectors/paylocity-available.json new file mode 100644 index 0000000..2884857 --- /dev/null +++ b/scripts/evals/cases/stackone-connectors/paylocity-available.json @@ -0,0 +1,27 @@ +{ + "prompt": "Is Paylocity available on StackOne, and would I have to build anything myself to use it?", + "skill": "stackone-connectors", + "skill_should_fire": true, + "skill_note": "Which providers exist is connectors territory.", + "fetch": [ + { + "name": "fetches-paylocity-page", + "match": "docs\\.stackone\\.com/connectors/paylocity", + "note": "The Paylocity connector page." + } + ], + "no_fetch": [], + "reply": [ + { + "name": "mentions-paylocity", + "match": "Paylocity", + "note": "The reply has to answer about Paylocity." + } + ], + "no_reply": [], + "reference": [ + "Paylocity has a StackOne connector with actions and events, documented on its connector page.", + "Using it means creating a connector profile with its authentication method and linking an account; there is no need to build a connector first.", + "The reply cites the connector page rather than guessing." + ] +} diff --git a/scripts/evals/cases/stackone-connectors/plaid-redirect-uri.json b/scripts/evals/cases/stackone-connectors/plaid-redirect-uri.json new file mode 100644 index 0000000..4947cdb --- /dev/null +++ b/scripts/evals/cases/stackone-connectors/plaid-redirect-uri.json @@ -0,0 +1,27 @@ +{ + "prompt": "I'm setting up a Plaid connector profile. The docs say I need to enter a redirect URI that goes to my app. Is that my platform, or my Plaid app? And why isn't it the StackOne callback URL I used for QuickBooks?", + "skill": "stackone-connectors", + "skill_should_fire": true, + "skill_note": "Connectors territory, but the Plaid page does not answer it. Under the rule agreed on 2026-09-28, an undocumented answer is 'not covered, contact support', even if a general OAuth answer would be right.", + "fetch": [ + { + "name": "checked-the-docs", + "match": "docs\\.stackone\\.com/(llms\\.txt|connectors/plaid)", + "note": "The index or the Plaid page." + } + ], + "no_fetch": [], + "reply": [ + { + "name": "points-to-support", + "match": "[Cc]ontact (StackOne('s)? )?[Ss]upport|StackOne [Ss]upport|support team", + "note": "The docs name the channel as StackOne support." + } + ], + "no_reply": [], + "reference": [ + "The Plaid connector page does not explain which redirect URI to enter, so the reply says the docs do not specify it.", + "The reply suggests contacting StackOne support rather than asserting an answer as documented.", + "The reply may explain in general terms how OAuth redirect URIs work, but does not present a Plaid-specific answer as coming from the docs." + ] +} diff --git a/scripts/evals/cases/stackone-connectors/sap-erp-connector.json b/scripts/evals/cases/stackone-connectors/sap-erp-connector.json new file mode 100644 index 0000000..135c5a4 --- /dev/null +++ b/scripts/evals/cases/stackone-connectors/sap-erp-connector.json @@ -0,0 +1,27 @@ +{ + "prompt": "Does StackOne connect to SAP ERP?", + "skill": "stackone-connectors", + "skill_should_fire": true, + "skill_note": "Which providers exist is connectors territory.", + "fetch": [ + { + "name": "fetches-sap-connector-page", + "match": "docs\\.stackone\\.com/connectors/saps4hana", + "note": "The SAP S/4HANA connector page." + } + ], + "no_fetch": [], + "reply": [ + { + "name": "names-s4hana", + "match": "S/4HANA", + "note": "The connector's name." + } + ], + "no_reply": [], + "reference": [ + "Yes: StackOne has an SAP S/4HANA connector.", + "It authenticates with OAuth 2.0 through a connector profile, and its page lists the available actions.", + "The reply points to the connector page rather than guessing at capabilities." + ] +} diff --git a/scripts/evals/cases/stackone-connectors/sap-per-user-auth.json b/scripts/evals/cases/stackone-connectors/sap-per-user-auth.json new file mode 100644 index 0000000..559423e --- /dev/null +++ b/scripts/evals/cases/stackone-connectors/sap-per-user-auth.json @@ -0,0 +1,27 @@ +{ + "prompt": "I connected SAP S/4HANA with OAuth using a super admin account. I want each of our users to be authorised individually so they only see what they are allowed to see in SAP. How do I set that up?", + "skill": "stackone-connectors", + "skill_should_fire": true, + "skill_note": "Connectors territory, but per-user authorisation for SAP is not documented. The right answer is to say so and point to support.", + "fetch": [ + { + "name": "checked-the-docs", + "match": "docs\\.stackone\\.com/(llms\\.txt|connectors/saps4hana)", + "note": "The index or the SAP S/4HANA page." + } + ], + "no_fetch": [], + "reply": [ + { + "name": "points-to-support", + "match": "[Cc]ontact (StackOne('s)? )?[Ss]upport|StackOne [Ss]upport|support team", + "note": "The docs name the channel as StackOne support." + } + ], + "no_reply": [], + "reference": [ + "The SAP S/4HANA connector page documents OAuth 2.0 connector profiles and does not document per-user authorisation.", + "The reply says the docs do not cover it and suggests contacting StackOne support.", + "The reply does not invent a field or setting, such as a username field, as the documented way to do it." + ] +} diff --git a/scripts/evals/cases/stackone-connectors/teams-publisher-attestation.json b/scripts/evals/cases/stackone-connectors/teams-publisher-attestation.json new file mode 100644 index 0000000..4144d6a --- /dev/null +++ b/scripts/evals/cases/stackone-connectors/teams-publisher-attestation.json @@ -0,0 +1,21 @@ +{ + "prompt": "Can StackOne handle Microsoft Teams publisher attestation for our integration, or do we have to do that ourselves?", + "skill": "stackone-connectors", + "skill_should_fire": false, + "skill_note": "No skill covers partner or legal processes. The right answer is to say so and point to support.", + "fetch": [], + "no_fetch": [], + "reply": [ + { + "name": "points-to-support", + "match": "[Cc]ontact (StackOne('s)? )?[Ss]upport|StackOne [Ss]upport|support team", + "note": "The docs name the channel as StackOne support." + } + ], + "no_reply": [], + "reference": [ + "Publisher attestation is not covered by the documentation, so the reply says so.", + "The reply suggests contacting StackOne support.", + "The reply does not state what StackOne will or will not do about attestation as if it were documented." + ] +} diff --git a/scripts/evals/cases/stackone-connectors/workday-actions-available.json b/scripts/evals/cases/stackone-connectors/workday-actions-available.json new file mode 100644 index 0000000..38fbd70 --- /dev/null +++ b/scripts/evals/cases/stackone-connectors/workday-actions-available.json @@ -0,0 +1,28 @@ +{ + "prompt": "Does StackOne support Workday, and which Workday actions can I call?", + "skill": "stackone-connectors", + "skill_should_fire": true, + "skill_note": "Which providers and actions exist is stackone-connectors territory. Whether it fired is reported, not scored; the checks below are the outcome a user needs.", + "fetch": [ + { + "name": "fetches-workday-connector-page", + "match": "docs\\.stackone\\.com/connectors/workday", + "note": "The Workday connector page lists its actions. The connectors index alone cannot say which Workday actions exist." + } + ], + "no_fetch": [], + "reply": [ + { + "name": "names-a-workday-action", + "match": "workday_[a-z_]+", + "note": "Action ids follow provider_operation_entity. A real answer names at least one." + } + ], + "no_reply": [], + "reference": [ + "Workday is supported; the StackOne docs list the connector as Workday (Rest and Soap).", + "The Workday connector page in the docs lists the actions that are available.", + "Actions are named workday__, for example workday_create_employee or workday_get_absence_balance.", + "Actions are called through the Actions RPC endpoint, POST /actions/rpc, authenticated with the API key and the linked account's id in the x-account-id header, or through the SDKs and MCP." + ] +} diff --git a/scripts/evals/cases/stackone-connectors/workday-documents.json b/scripts/evals/cases/stackone-connectors/workday-documents.json new file mode 100644 index 0000000..14e9c21 --- /dev/null +++ b/scripts/evals/cases/stackone-connectors/workday-documents.json @@ -0,0 +1,28 @@ +{ + "prompt": "Are Workday documents exposed through StackOne, for example when I use the Workday connector over MCP?", + "skill": "stackone-connectors", + "skill_should_fire": true, + "skill_note": "What a provider's actions cover is connectors territory. The support reply on record said no document management; the page now lists document actions, so the case tests answering from the page over memory.", + "fetch": [ + { + "name": "fetches-workday-page", + "match": "docs\\.stackone\\.com/connectors/workday", + "note": "The Workday connector page lists its actions." + } + ], + "no_fetch": [], + "reply": [ + { + "name": "names-a-document-action", + "match": "workday_[a-z_]*document[a-z_]*", + "note": "The document actions listed on the page." + } + ], + "no_reply": [], + "reference": [ + "The Workday connector page lists worker document actions, such as getting a worker's documents, putting a worker document and listing year-end documents.", + "Custom reports are also available as actions (execute custom report).", + "Over MCP the same actions are exposed as tools, subject to what the connector profile enables.", + "The reply answers from the connector page's action list rather than from memory." + ] +} diff --git a/scripts/evals/cases/stackone-connectors/workday-user-impersonation.json b/scripts/evals/cases/stackone-connectors/workday-user-impersonation.json new file mode 100644 index 0000000..6116345 --- /dev/null +++ b/scripts/evals/cases/stackone-connectors/workday-user-impersonation.json @@ -0,0 +1,27 @@ +{ + "prompt": "Does the Workday connector support user-level impersonation, so that actions run with a specific user's permissions?", + "skill": "stackone-connectors", + "skill_should_fire": true, + "skill_note": "A provider's authentication options are connectors territory.", + "fetch": [ + { + "name": "fetches-workday-docs", + "match": "docs\\.stackone\\.com/connectors/workday", + "note": "The Workday connector page or one of its connector-profile guides." + } + ], + "no_fetch": [], + "reply": [ + { + "name": "names-user-login-flow", + "match": "[Uu]ser login flow", + "note": "The auth types that authenticate as a user." + } + ], + "no_reply": [], + "reference": [ + "Workday offers OAuth 2.0 user login flow profiles, managed and unmanaged, that authenticate the linked account as a specific user through login.", + "The OAuth 2.0 static refresh token profile is scoped to an individual user and API client.", + "Actions therefore run under the user the account was authenticated as; the docs do not describe a separate impersonation switch." + ] +} diff --git a/scripts/evals/cases/stackone-platform/account-disconnect-notification.json b/scripts/evals/cases/stackone-platform/account-disconnect-notification.json new file mode 100644 index 0000000..79a9a41 --- /dev/null +++ b/scripts/evals/cases/stackone-platform/account-disconnect-notification.json @@ -0,0 +1,33 @@ +{ + "prompt": "Our Bullhorn OAuth connection in StackOne disconnected without warning. Is there a way to get notified when a linked account goes down, instead of finding out when calls start failing?", + "skill": "stackone-platform", + "skill_should_fire": true, + "skill_note": "Account lifecycle webhooks are platform territory.", + "fetch": [ + { + "name": "fetches-account-events-docs", + "match": "docs\\.stackone\\.com/(embed/handle-account-events|connect/webhooks)", + "note": "The Handle Account Events guide or the Webhooks page." + } + ], + "no_fetch": [], + "reply": [ + { + "name": "mentions-webhooks", + "match": "[Ww]ebhook", + "note": "Account status changes are delivered by webhook." + }, + { + "name": "names-account-events", + "match": "account\\.(created|updated|deleted)|account events", + "note": "The events are subscribed by name on the webhook." + } + ], + "no_reply": [], + "reference": [ + "Account lifecycle events are delivered by webhook, so the backend can react to a connection or disconnection instead of polling.", + "Account events are subscribed on the webhook itself, not on a connector profile, by setting the webhook's events array (account.created, account.updated, account.deleted) when creating or updating it.", + "The event payload carries the event name, account_id, provider and the origin identifiers, and the receiver should verify the signature before acting.", + "The docs describe account events as covering a user connecting or disconnecting; the reply maps the disconnection onto those events rather than inventing a separate alerting feature." + ] +} diff --git a/scripts/evals/cases/stackone-platform/account-status-meaning.json b/scripts/evals/cases/stackone-platform/account-status-meaning.json new file mode 100644 index 0000000..92c7270 --- /dev/null +++ b/scripts/evals/cases/stackone-platform/account-status-meaning.json @@ -0,0 +1,28 @@ +{ + "prompt": "One of our linked accounts in StackOne shows a status of expired. What does that mean and what should we do about it?", + "skill": "stackone-platform", + "skill_should_fire": true, + "skill_note": "Interpreting a linked account's status is a platform question, so the skill should fire.", + "fetch": [ + { + "name": "fetches-v2-accounts-reference", + "match": "api-reference/v2/accounts", + "note": "Status values live in the accounts reference, which the skill points to rather than restating." + } + ], + "no_fetch": [ + { + "name": "avoids-v1-accounts-reference", + "match": "api-reference/accounts/list-accounts", + "note": "The uncatalogued v1 reference must not be used. The v2 path has `/v2/` in it and does not match this pattern." + } + ], + "reply": [], + "no_reply": [ + { + "name": "no-legacy-field-names", + "match": "origin_owner_id", + "note": "The reply does not use the retired `origin_owner_id` field name." + } + ] +} diff --git a/scripts/evals/cases/stackone-platform/accounts-by-connector-profile.json b/scripts/evals/cases/stackone-platform/accounts-by-connector-profile.json new file mode 100644 index 0000000..6084166 --- /dev/null +++ b/scripts/evals/cases/stackone-platform/accounts-by-connector-profile.json @@ -0,0 +1,27 @@ +{ + "prompt": "I found two connector profiles in my project when I expected one. How can I see which linked accounts are using which connector profile?", + "skill": "stackone-platform", + "skill_should_fire": true, + "skill_note": "Accounts and connector profiles are platform territory.", + "fetch": [ + { + "name": "fetches-v2-accounts-reference", + "match": "docs\\.stackone\\.com/platform/api-reference/v2/accounts/(list-accounts|get-an-account)", + "note": "The v2 accounts reference carries connector_profile_id." + } + ], + "no_fetch": [], + "reply": [ + { + "name": "uses-connector-profile-id", + "match": "connector_profile_id", + "note": "The field that links an account to its profile." + } + ], + "no_reply": [], + "reference": [ + "The v2 List Accounts endpoint returns connector_profile_id on each account.", + "List Accounts accepts a connector_profile_id filter, so the accounts on one profile can be listed directly.", + "The reply does not invent an audit or profile-usage endpoint that the reference does not list." + ] +} diff --git a/scripts/evals/cases/stackone-platform/accounts-no-credentials.json b/scripts/evals/cases/stackone-platform/accounts-no-credentials.json new file mode 100644 index 0000000..fd173c0 --- /dev/null +++ b/scripts/evals/cases/stackone-platform/accounts-no-credentials.json @@ -0,0 +1,34 @@ +{ + "prompt": "I called GET /accounts expecting the linked account's credentials in the response, but there aren't any. Is that expected, or is something wrong on my side?", + "skill": "stackone-platform", + "skill_should_fire": true, + "skill_note": "Accounts are platform territory. The answer is an absence in the reference, so the case tests reading the schema rather than guessing.", + "fetch": [ + { + "name": "fetches-accounts-reference-or-concept", + "match": "docs\\.stackone\\.com/(platform/api-reference/v2/accounts/(list-accounts|get-an-account)|gateway/concepts/linked-accounts)", + "note": "The v2 accounts reference or the Linked Accounts concept page." + } + ], + "no_fetch": [], + "reply": [ + { + "name": "addresses-credentials", + "match": "[Cc]redentials", + "note": "The reply has to say something about credentials." + } + ], + "no_reply": [ + { + "name": "no-invented-credentials-endpoint", + "match": "accounts/[^\\s\"'`]*credentials", + "note": "There is no credentials endpoint; naming one is invention." + } + ], + "reference": [ + "It is expected: the account response includes fields such as status, provider, origin_owner_id and connector_profile_id, and no credentials.", + "StackOne stores the provider credentials when the user links the account and uses them itself; the account status (active, suspended, error) reflects whether they are still valid.", + "No public endpoint returns an account's credentials; if there is a real need for them, contact StackOne support.", + "The reply does not invent an endpoint or parameter that reveals credentials, and does not tell the user to fix scopes or permissions as if the field should be there." + ] +} diff --git a/scripts/evals/cases/stackone-platform/add-org-member.json b/scripts/evals/cases/stackone-platform/add-org-member.json new file mode 100644 index 0000000..27c484b --- /dev/null +++ b/scripts/evals/cases/stackone-platform/add-org-member.json @@ -0,0 +1,27 @@ +{ + "prompt": "I seem to be the only user on our StackOne account. How do I add another person from my company to our organisation?", + "skill": "stackone-platform", + "skill_should_fire": true, + "skill_note": "Team management sits under Secure in the docs; the platform skill is the nearest owner.", + "fetch": [ + { + "name": "fetches-manage-team-page", + "match": "docs\\.stackone\\.com/secure/identity-and-access/manage-team", + "note": "The page that documents inviting members and roles." + } + ], + "no_fetch": [], + "reply": [ + { + "name": "mentions-invite-or-admin", + "match": "[Ii]nvite|[Aa]dmin", + "note": "Admins invite members." + } + ], + "no_reply": [], + "reference": [ + "Organisation Admins invite members from the organisation's Members settings.", + "There are two independent role layers: an organisation role (Admin or Member) and per-project roles assigned separately.", + "Organisation Admins see every project; Members only see the projects they are granted, directly or through a group." + ] +} diff --git a/scripts/evals/cases/stackone-platform/api-key-for-jobadder.json b/scripts/evals/cases/stackone-platform/api-key-for-jobadder.json new file mode 100644 index 0000000..b4ee290 --- /dev/null +++ b/scripts/evals/cases/stackone-platform/api-key-for-jobadder.json @@ -0,0 +1,34 @@ +{ + "prompt": "I need an API key from StackOne to connect JobAdder. Where do I get one, and what does JobAdder itself need from me?", + "max_turns": 16, + "skill": "stackone-platform", + "skill_should_fire": true, + "skill_note": "API keys are platform territory; the JobAdder half belongs to stackone-connectors. Either may fire; the outcome is what counts.", + "fetch": [ + { + "name": "fetches-api-keys-page", + "match": "docs\\.stackone\\.com/embed/api-keys|docs\\.stackone\\.com/guides/api-keys", + "note": "The API Keys page, or its older path that redirects." + }, + { + "name": "fetches-jobadder-connector-docs", + "match": "docs\\.stackone\\.com/connectors/jobadder", + "note": "The JobAdder connector page or its OAuth connector-profile guide." + } + ], + "no_fetch": [], + "reply": [ + { + "name": "mentions-oauth-for-jobadder", + "match": "OAuth", + "note": "JobAdder connects through an OAuth 2.0 connector profile." + } + ], + "no_reply": [], + "reference": [ + "A StackOne API key is created in the dashboard on the API Keys page and is used to call StackOne's API; it is not what JobAdder needs.", + "Connecting JobAdder needs an OAuth 2.0 connector profile: register an application in the JobAdder Developer Portal and put its Client ID and Client Secret in the profile.", + "The JobAdder application must list StackOne's redirect URI, https://api.stackone.com/connect/oauth2/jobadder/callback.", + "The reply keeps the StackOne API key and the JobAdder OAuth credentials distinct." + ] +} diff --git a/scripts/evals/cases/stackone-platform/configure-webhooks.json b/scripts/evals/cases/stackone-platform/configure-webhooks.json new file mode 100644 index 0000000..2061157 --- /dev/null +++ b/scripts/evals/cases/stackone-platform/configure-webhooks.json @@ -0,0 +1,22 @@ +{ + "prompt": "How do I get notified when one of my customers' StackOne accounts disconnects or its token expires?", + "skill": "stackone-platform", + "skill_should_fire": true, + "skill_note": "Account lifecycle notifications are a platform question, so the skill should fire.", + "fetch": [ + { + "name": "fetches-webhooks-or-platform-events", + "match": "connect/webhooks|platform-api/platform-events", + "note": "The skill routes webhook questions to the Webhooks guide and the Platform Events reference." + } + ], + "no_fetch": [ + { + "name": "avoids-old-webhooks-guide", + "match": "guides/webhooks", + "note": "The retired guide path only survives on a redirect." + } + ], + "reply": [], + "no_reply": [] +} diff --git a/scripts/evals/cases/stackone-platform/connector-billing.json b/scripts/evals/cases/stackone-platform/connector-billing.json new file mode 100644 index 0000000..3749a92 --- /dev/null +++ b/scripts/evals/cases/stackone-platform/connector-billing.json @@ -0,0 +1,21 @@ +{ + "prompt": "How is connector usage billed on StackOne, and is there an extra cost for a Workday sandbox?", + "skill": "stackone-platform", + "skill_should_fire": false, + "skill_note": "No skill covers pricing or billing. The right answer is to say so and point to support or the account team.", + "fetch": [], + "no_fetch": [], + "reply": [ + { + "name": "points-to-support", + "match": "[Cc]ontact (StackOne('s)? )?[Ss]upport|StackOne [Ss]upport|support team|account (team|manager)|sales", + "note": "Billing questions go to support or the account team." + } + ], + "no_reply": [], + "reference": [ + "Pricing and billing are not covered by the developer documentation, so the reply says so.", + "The reply suggests contacting StackOne support or the account team.", + "The reply does not quote prices, tiers or sandbox costs." + ] +} diff --git a/scripts/evals/cases/stackone-platform/create-api-key.json b/scripts/evals/cases/stackone-platform/create-api-key.json new file mode 100644 index 0000000..69ad6a0 --- /dev/null +++ b/scripts/evals/cases/stackone-platform/create-api-key.json @@ -0,0 +1,16 @@ +{ + "prompt": "Where do I create a StackOne API key, and does it belong to my whole organisation or just one project?", + "skill": "stackone-platform", + "skill_should_fire": true, + "skill_note": "API key setup is a platform question, so the skill should fire.", + "fetch": [ + { + "name": "fetches-api-keys-page", + "match": "embed/api-keys", + "note": "The skill routes key management to the API Keys page." + } + ], + "no_fetch": [], + "reply": [], + "no_reply": [] +} diff --git a/scripts/evals/cases/stackone-platform/data-sync-off-map.json b/scripts/evals/cases/stackone-platform/data-sync-off-map.json new file mode 100644 index 0000000..74308b6 --- /dev/null +++ b/scripts/evals/cases/stackone-platform/data-sync-off-map.json @@ -0,0 +1,21 @@ +{ + "prompt": "How does StackOne's Data Sync work and how do I set one up for a linked account?", + "skill": "stackone-platform", + "skill_should_fire": true, + "skill_note": "Data Sync is part of the Platform API, so the skill should fire even though its map has no row for it.", + "fetch": [ + { + "name": "consults-the-index", + "match": "docs\\.stackone\\.com/llms\\.txt", + "note": "The skill's map does not list Data Sync, so the agent must find it through the index. This is the durability rule under test." + }, + { + "name": "fetches-a-data-sync-page", + "match": "[Dd]ata[-_]?[Ss]ync", + "note": "Having searched the index, the agent reads a Data Sync page rather than answering from memory." + } + ], + "no_fetch": [], + "reply": [], + "no_reply": [] +} diff --git a/scripts/evals/cases/stackone-platform/debug-401.json b/scripts/evals/cases/stackone-platform/debug-401.json new file mode 100644 index 0000000..089ac2d --- /dev/null +++ b/scripts/evals/cases/stackone-platform/debug-401.json @@ -0,0 +1,22 @@ +{ + "prompt": "My StackOne API call is returning 401 Unauthorized. I am sending my API key in the Authorization header. What is wrong and where is the current authentication documentation?", + "skill": "stackone-platform", + "skill_should_fire": true, + "skill_note": "A 401 from the StackOne API is a platform question, so the skill should fire.", + "fetch": [ + { + "name": "fetches-current-auth-page", + "match": "platform-api/authentication", + "note": "The skill sends the agent to the current authentication page." + } + ], + "no_fetch": [ + { + "name": "avoids-dead-auth-page", + "match": "overview/authentication", + "note": "The agent never fetches the retired `/overview/authentication` page, which returns 404." + } + ], + "reply": [], + "no_reply": [] +} diff --git a/scripts/evals/cases/stackone-platform/find-request-logs.json b/scripts/evals/cases/stackone-platform/find-request-logs.json new file mode 100644 index 0000000..f378dd7 --- /dev/null +++ b/scripts/evals/cases/stackone-platform/find-request-logs.json @@ -0,0 +1,16 @@ +{ + "prompt": "A StackOne API call for one of our customers failed yesterday and I need to see exactly what happened. Where do I look?", + "skill": "stackone-platform", + "skill_should_fire": true, + "skill_note": "Finding a failed request in the logs is a platform question, so the skill should fire.", + "fetch": [ + { + "name": "fetches-troubleshooting-or-logs", + "match": "connect/troubleshooting|api-reference/logs/list-logs", + "note": "The skill routes log questions to the Troubleshooting guide and the List Logs reference." + } + ], + "no_fetch": [], + "reply": [], + "no_reply": [] +} diff --git a/scripts/evals/cases/stackone-platform/list-linked-accounts.json b/scripts/evals/cases/stackone-platform/list-linked-accounts.json new file mode 100644 index 0000000..1b27415 --- /dev/null +++ b/scripts/evals/cases/stackone-platform/list-linked-accounts.json @@ -0,0 +1,38 @@ +{ + "prompt": "How do I list the accounts my customers have linked in StackOne? Show me the request and explain the fields that come back on each account.", + "skill": "stackone-platform", + "skill_should_fire": true, + "skill_note": "Listing linked accounts is a platform question, so the skill should fire.", + "fetch": [], + "no_fetch": [ + { + "name": "avoids-v1-accounts-reference", + "match": "api-reference/accounts/list-accounts", + "note": "The agent never fetches the uncatalogued v1 accounts reference. The v2 URL has `/v2/` between `api-reference` and `accounts`, so it does not match this pattern." + } + ], + "reply": [ + { + "name": "uses-v2-accounts-endpoint", + "match": "/v2/accounts", + "note": "The reply shows the v2 accounts endpoint, which is the only one the docs catalogue." + }, + { + "name": "names-connector-field", + "match": "`connector`", + "note": "The reply names the `connector` field. The v1 reference called it `provider`." + }, + { + "name": "names-owner-id-field", + "match": "`owner_id`", + "note": "The reply names the `owner_id` field. The v1 reference called it `origin_owner_id`." + } + ], + "no_reply": [ + { + "name": "no-legacy-field-names", + "match": "origin_owner_id", + "note": "The reply does not use the retired `origin_owner_id` field name." + } + ] +} diff --git a/scripts/evals/cases/stackone-platform/log-pii-redaction.json b/scripts/evals/cases/stackone-platform/log-pii-redaction.json new file mode 100644 index 0000000..679ba1e --- /dev/null +++ b/scripts/evals/cases/stackone-platform/log-pii-redaction.json @@ -0,0 +1,27 @@ +{ + "prompt": "The advanced request logs are useful but they contain PII. Is there any redaction, or a way to limit what gets stored?", + "skill": "stackone-platform", + "skill_should_fire": true, + "skill_note": "Platform territory, but redaction is not documented. The right answer is to say so and point to support.", + "fetch": [ + { + "name": "checked-the-docs", + "match": "docs\\.stackone\\.com/(llms\\.txt|features/observability|platform/api-reference/logs)", + "note": "The index, the observability guides or the logs reference." + } + ], + "no_fetch": [], + "reply": [ + { + "name": "points-to-support", + "match": "[Cc]ontact (StackOne('s)? )?[Ss]upport|StackOne [Ss]upport|support team", + "note": "The docs name the channel as StackOne support." + } + ], + "no_reply": [], + "reference": [ + "The docs do not describe a redaction feature for request logs, so the reply says so.", + "The reply suggests contacting StackOne support about redaction or storage controls.", + "The reply does not describe a redaction setting or option as if it existed." + ] +} diff --git a/scripts/evals/cases/stackone-platform/log-request-source.json b/scripts/evals/cases/stackone-platform/log-request-source.json new file mode 100644 index 0000000..7ab1995 --- /dev/null +++ b/scripts/evals/cases/stackone-platform/log-request-source.json @@ -0,0 +1,27 @@ +{ + "prompt": "In the request logs, how can I tell what originated a call: which API key it was, whether it was a session token, or which OAuth user?", + "skill": "stackone-platform", + "skill_should_fire": true, + "skill_note": "Logs are platform territory. The List Logs reference documents the fields that answer this; the reply has to use them rather than guess.", + "fetch": [ + { + "name": "fetches-logs-docs", + "match": "docs\\.stackone\\.com/(platform/api-reference/logs/list-logs|features/observability)", + "note": "The List Logs reference or the observability guides." + } + ], + "no_fetch": [], + "reply": [ + { + "name": "names-auth-or-source-fields", + "match": "auth_type|auth_id|source_type|source_id", + "note": "The documented fields that say what authenticated a call and where it came from." + } + ], + "no_reply": [], + "reference": [ + "The List Logs reference documents auth_type and auth_id, which identify what authenticated the call, such as an API key or a session.", + "It also documents source_type, source_id and source_value, which describe where the call came from, and session_id, agent_id and origin_owner_id.", + "The reply sticks to fields the reference lists; if they do not give the user what they need, it suggests contacting StackOne support rather than inventing more." + ] +} diff --git a/scripts/evals/cases/stackone-platform/org-project-account-hierarchy.json b/scripts/evals/cases/stackone-platform/org-project-account-hierarchy.json new file mode 100644 index 0000000..08d1fdc --- /dev/null +++ b/scripts/evals/cases/stackone-platform/org-project-account-hierarchy.json @@ -0,0 +1,28 @@ +{ + "prompt": "We're an OEM customer with one StackOne organisation. How should we use organisations, projects and accounts to keep each of our customers isolated and to keep dev and prod separate?", + "skill": "stackone-platform", + "skill_should_fire": true, + "skill_note": "Organisation, project and account structure is platform territory.", + "fetch": [ + { + "name": "fetches-hierarchy-docs", + "match": "docs\\.stackone\\.com/(gateway/concepts/(overview|organizations-and-projects)|features/multi-tenant-accounts)", + "note": "The concepts pages or the multi-tenant accounts guide." + } + ], + "no_fetch": [], + "reply": [ + { + "name": "mentions-projects", + "match": "[Pp]roject", + "note": "Projects are the unit of isolation for environments." + } + ], + "no_reply": [], + "reference": [ + "The hierarchy is organisation, then projects, then linked accounts.", + "Projects are isolated workspaces with their own region, API keys and linked accounts, so environments such as dev and prod belong in separate projects.", + "Members and security (roles, MFA, SSO) are managed at the organisation level; organisation Admins see every project and Members only the projects they are granted.", + "Customers are kept apart within a project by the owner identifiers (origin_owner_id) on their linked accounts." + ] +} diff --git a/scripts/evals/cases/stackone-platform/passthrough-idle-timeout.json b/scripts/evals/cases/stackone-platform/passthrough-idle-timeout.json new file mode 100644 index 0000000..e697171 --- /dev/null +++ b/scripts/evals/cases/stackone-platform/passthrough-idle-timeout.json @@ -0,0 +1,33 @@ +{ + "prompt": "I have a custom passthrough action that runs a Workday report. While Workday generates it, the connection goes quiet with no bytes for a long time. What is StackOne's idle timeout on that upstream connection, and which status code do I get back when it gives up?", + "skill": "stackone-platform", + "skill_should_fire": true, + "skill_note": "Platform territory, but the timeout is not documented. The right answer is to say so and point to support, not to guess a number.", + "fetch": [ + { + "name": "checked-the-docs", + "match": "docs\\.stackone\\.com/(llms\\.txt|connect/troubleshooting|platform-api/)", + "note": "The agent must have looked before saying the docs do not cover it." + } + ], + "no_fetch": [], + "reply": [ + { + "name": "points-to-support", + "match": "[Cc]ontact (StackOne('s)? )?[Ss]upport|StackOne [Ss]upport|support team", + "note": "The docs name the channel as StackOne support." + } + ], + "no_reply": [ + { + "name": "no-invented-timeout-value", + "match": "\\b\\d{2,3}\\s?(s|sec|secs|seconds)\\b", + "note": "Any specific number of seconds is invention; the docs give none." + } + ], + "reference": [ + "The documentation does not state an idle or read timeout for upstream connections, so the reply says so rather than giving a number.", + "The reply suggests contacting StackOne support for the timeout and the status code.", + "The reply does not present a specific number of seconds or a specific status code as StackOne's documented behaviour." + ] +} diff --git a/scripts/evals/cases/stackone-platform/rate-limit-429.json b/scripts/evals/cases/stackone-platform/rate-limit-429.json new file mode 100644 index 0000000..7c1aa39 --- /dev/null +++ b/scripts/evals/cases/stackone-platform/rate-limit-429.json @@ -0,0 +1,22 @@ +{ + "prompt": "We are getting 429 Too Many Requests from api.stackone.com. What are StackOne's rate limits and how should our client handle them? Point me at the current documentation.", + "skill": "stackone-platform", + "skill_should_fire": true, + "skill_note": "A 429 from the StackOne API is a platform question, so the skill should fire.", + "fetch": [ + { + "name": "fetches-rate-limiting-page", + "match": "platform-api/rate-limiting", + "note": "The skill sends the agent to the current rate limiting page." + } + ], + "no_fetch": [ + { + "name": "avoids-dead-rate-limits-page", + "match": "overview/rate-limits", + "note": "The agent never fetches the retired `/overview/rate-limits` page, which returns 404." + } + ], + "reply": [], + "no_reply": [] +} diff --git a/scripts/evals/cases/stackone-platform/rename-organisation.json b/scripts/evals/cases/stackone-platform/rename-organisation.json new file mode 100644 index 0000000..f305c8c --- /dev/null +++ b/scripts/evals/cases/stackone-platform/rename-organisation.json @@ -0,0 +1,21 @@ +{ + "prompt": "Our organisation name is spelt wrong in the StackOne dashboard. How do I change it?", + "skill": "stackone-platform", + "skill_should_fire": false, + "skill_note": "No skill covers dashboard administration and the docs have no page for renaming an organisation. The right answer is to say so and point to support.", + "fetch": [], + "no_fetch": [], + "reply": [ + { + "name": "points-to-support", + "match": "[Cc]ontact (StackOne('s)? )?[Ss]upport|StackOne [Ss]upport|support team", + "note": "The docs name the channel as StackOne support." + } + ], + "no_reply": [], + "reference": [ + "Renaming an organisation is not covered by the documentation, so the reply says so.", + "The reply suggests contacting StackOne support.", + "The reply does not describe a settings path for renaming as if it were documented." + ] +} diff --git a/scripts/evals/cases/stackone-platform/retry-backoff-guidance.json b/scripts/evals/cases/stackone-platform/retry-backoff-guidance.json new file mode 100644 index 0000000..67e38cd --- /dev/null +++ b/scripts/evals/cases/stackone-platform/retry-backoff-guidance.json @@ -0,0 +1,28 @@ +{ + "prompt": "When StackOne returns a 429 or a 502, how many times should I retry and with what backoff? Is retrying after one second too soon?", + "skill": "stackone-platform", + "skill_should_fire": true, + "skill_note": "Rate limits and error handling are platform territory.", + "fetch": [ + { + "name": "fetches-rate-limiting-page", + "match": "docs\\.stackone\\.com/platform-api/rate-limiting", + "note": "The page that documents 429, Retry-After and StackOne's own retries." + } + ], + "no_fetch": [], + "reply": [ + { + "name": "mentions-retry-after", + "match": "Retry-After", + "note": "The header that says how long to wait." + } + ], + "no_reply": [], + "reference": [ + "API keys are rate limited per minute and exceeding the limit returns 429 Too Many Requests with a Retry-After header.", + "The client should read the 429 and the Retry-After header and back off for at least that long before retrying; retrying immediately is the wrong approach.", + "For provider rate limits, StackOne retries on the caller's behalf: up to five consecutive attempts using the provider's Retry-After, within a 60-second request lifetime, returning 408 Request Timeout if that is exceeded, so the client does not need provider-specific retry logic.", + "The docs do not prescribe a client-side retry count or backoff schedule beyond honouring Retry-After; the reply may recommend one but does not present it as StackOne's documented policy." + ] +} diff --git a/scripts/evals/cases/stackone-unified-connectors/cursor-pagination-next.json b/scripts/evals/cases/stackone-unified-connectors/cursor-pagination-next.json new file mode 100644 index 0000000..cf6ce64 --- /dev/null +++ b/scripts/evals/cases/stackone-unified-connectors/cursor-pagination-next.json @@ -0,0 +1,27 @@ +{ + "prompt": "For a paginated list action using cursor pagination in a connector YAML, how do I carry the cursor from one page to the next, and what should the step return so the engine requests the following page?", + "skill": "stackone-unified-connectors", + "skill_should_fire": true, + "skill_note": "Pagination configuration is named in the unified-connectors description; stackone-cli may also take it. Either may fire; the outcome is what counts.", + "fetch": [ + { + "name": "fetches-paginated-request-docs", + "match": "docs\\.stackone\\.com/connector-yaml-reference/step-functions/paginated-request", + "note": "The paginated_request step function reference." + } + ], + "no_fetch": [], + "reply": [ + { + "name": "mentions-cursor", + "match": "cursor", + "note": "The pagination position carried between pages." + } + ], + "no_reply": [], + "reference": [ + "The paginated_request step function handles pagination; it takes a cursor input that carries the position (offset, page number or cursor token) over from the previous page.", + "Its configuration has a section controlling how subsequent pages are requested, including the request field that carries the page token, offset or number.", + "It also has a section controlling how each page response is parsed, which selects the data array and where the next cursor is read from." + ] +} diff --git a/scripts/evals/grade.ts b/scripts/evals/grade.ts new file mode 100644 index 0000000..77229e8 --- /dev/null +++ b/scripts/evals/grade.ts @@ -0,0 +1,68 @@ +// Grades a normalised transcript against a case's checks. Every check is +// a regex over either the JSON-encoded tool inputs or the final reply, so the +// same expectation grades every host. "Fetched" means any tool call whose +// input matches, whatever the host names its fetch tool. + +import type { Check, Expectation, ToolCall, Transcript } from './types.ts'; + +export function grade(expectation: Expectation, transcript: Transcript): Check[] { + const checks: Check[] = []; + const inputs = transcript.toolCalls.map((call) => JSON.stringify(call.input ?? '')); + const anyInputMatches = (pattern: string): boolean => inputs.some((input) => new RegExp(pattern).test(input)); + const replyMatches = (pattern: string): boolean => new RegExp(pattern).test(transcript.finalText); + + for (const check of expectation.fetch ?? []) { + checks.push({ name: check.name, passed: anyInputMatches(check.match), scored: true }); + } + for (const check of expectation.no_fetch ?? []) { + checks.push({ name: check.name, passed: !anyInputMatches(check.match), scored: true }); + } + for (const check of expectation.reply ?? []) { + checks.push({ name: check.name, passed: replyMatches(check.match), scored: true }); + } + for (const check of expectation.no_reply ?? []) { + checks.push({ name: check.name, passed: !replyMatches(check.match), scored: true }); + } + + // Which skill fired is reported, never scored. Hosts reach a skill + // differently, a baseline run has no skill to fire, and the verdict belongs + // to the outcome checks above: a right answer reached through the "wrong" + // skill is still a right answer. + if (expectation.skill_should_fire !== undefined) { + const skillUsed = transcript.toolCalls.some((call) => usesSkill(call, expectation.skill)); + checks.push({ + name: expectation.skill_should_fire ? 'skill-fired' : 'skill-not-invoked', + passed: skillUsed === expectation.skill_should_fire, + scored: false, + }); + } + return checks; +} + +// A skill is reached either by an explicit skill-invocation tool or by the +// agent reading its SKILL.md, which is how hosts without a Skill tool load it. +export function usesSkill(call: ToolCall, skillName: string): boolean { + const input = JSON.stringify(call.input ?? ''); + if (/^skill$/i.test(call.name) && input.includes(skillName)) { + return true; + } + return new RegExp(`skills/${skillName}/SKILL\\.md`).test(input); +} + +/** Every skill the run reached, by either route, for the per-run diagnostic line. */ +export function skillsUsed(transcript: Transcript): string[] { + const names = new Set(); + for (const call of transcript.toolCalls) { + const input = JSON.stringify(call.input ?? ''); + if (/^skill$/i.test(call.name)) { + const named = input.match(/"skill":"(?:[^":]*:)?([^"]+)"/); + if (named) { + names.add(named[1]); + } + } + for (const read of input.matchAll(/skills\/([^/"\\]+)\/SKILL\.md/g)) { + names.add(read[1]); + } + } + return [...names]; +} diff --git a/scripts/evals/hosts/antigravity.ts b/scripts/evals/hosts/antigravity.ts new file mode 100644 index 0000000..19412b4 --- /dev/null +++ b/scripts/evals/hosts/antigravity.ts @@ -0,0 +1,66 @@ +// Antigravity CLI (`agy`). Prints only the final reply, but keeps a +// per-conversation transcript with every tool call under +// ~/.gemini/antigravity-cli/brain/. --add-dir registers the working directory +// as a workspace; without it the agent does not see the skills installed there. + +import { existsSync, readFileSync, realpathSync } from 'node:fs'; +import { homedir } from 'node:os'; +import { join } from 'node:path'; +import { commandVersion, exec, installWithSkillsCli, parseJsonLines } from '../process.ts'; +import type { HostAdapter, JsonEvent, RawRun, RunContext, ToolCall, Transcript } from '../types.ts'; + +export const antigravity: HostAdapter = { + defaultModel: 'gemini-3.8-flash-high', + + version(): string { + return commandVersion('agy'); + }, + + run({ prompt, workDir, pluginDir, withSkill, model }: RunContext): RawRun { + if (withSkill) { + installWithSkillsCli(pluginDir, 'antigravity-cli', workDir); + } + const raw = exec( + 'agy', + ['-p', prompt, '--add-dir', workDir, '--dangerously-skip-permissions', '--print-timeout', '5m', '--model', model], + { cwd: workDir }, + ); + raw.transcript = readTranscript(workDir); + return raw; + }, + + parse(raw: RawRun): Transcript { + const toolCalls: ToolCall[] = []; + let turns = 0; + for (const event of parseJsonLines(raw.transcript ?? '')) { + if (event.type === 'PLANNER_RESPONSE') { + turns += 1; + } + for (const call of (event.tool_calls ?? []) as JsonEvent[]) { + toolCalls.push({ name: call.name ?? call.tool_name ?? 'tool', input: call.args ?? call.arguments ?? call.input ?? call }); + } + } + const error = raw.error ?? (raw.transcript ? undefined : 'antigravity transcript not found'); + return { toolCalls, finalText: raw.stdout, turns, error }; + }, +}; + +// agy maps each working directory to its latest conversation id, and stores +// that conversation's full transcript, one JSON event per line, alongside it. +function readTranscript(workDir: string): string | undefined { + const antigravityHome = join(homedir(), '.gemini', 'antigravity-cli'); + const mapPath = join(antigravityHome, 'cache', 'last_conversations.json'); + if (!existsSync(mapPath)) { + return undefined; + } + const conversations = JSON.parse(readFileSync(mapPath, 'utf8')) as Record; + const conversationId = conversations[workDir] ?? conversations[realpathSync(workDir)]; + if (!conversationId) { + return undefined; + } + const transcriptPath = join(antigravityHome, 'brain', conversationId, '.system_generated', 'logs', 'transcript_full.jsonl'); + if (!existsSync(transcriptPath)) { + return undefined; + } + return readFileSync(transcriptPath, 'utf8'); +} diff --git a/scripts/evals/hosts/claude.ts b/scripts/evals/hosts/claude.ts new file mode 100644 index 0000000..1392253 --- /dev/null +++ b/scripts/evals/hosts/claude.ts @@ -0,0 +1,68 @@ +// Claude Code. Runs `claude -p` with a throwaway config directory so no +// installed plugin, MCP server or user setting loads, and passes the plugin +// under test with --plugin-dir. stream-json gives one event per line with +// tool calls on assistant events and the reply and cost on the result event. + +import { mkdtempSync } from 'node:fs'; +import { join } from 'node:path'; +import { commandVersion, exec, parseJsonLines } from '../process.ts'; +import type { HostAdapter, JsonEvent, RawRun, RunContext, ToolCall, Transcript } from '../types.ts'; + +export const claude: HostAdapter = { + defaultModel: 'sonnet', + + version(): string { + return commandVersion('claude'); + }, + + run({ prompt, workDir, pluginDir, withSkill, model, maxTurns }: RunContext): RawRun { + const configDir = mkdtempSync(join(workDir, 'claude-config-')); + const args = [ + '-p', prompt, + '--strict-mcp-config', + '--output-format', 'stream-json', '--verbose', + '--allowedTools', 'WebFetch', 'Skill', + '--max-turns', String(maxTurns), + '--model', model, + ]; + if (withSkill) { + args.push('--plugin-dir', pluginDir); + } + return exec('claude', args, { cwd: workDir, env: { ...process.env, CLAUDE_CONFIG_DIR: configDir } }); + }, + + parse(raw: RawRun): Transcript { + const toolCalls: ToolCall[] = []; + let finalText = ''; + let turns: number | undefined; + let costUsd: number | undefined; + let error: string | undefined = raw.error; + for (const event of parseJsonLines(raw.stdout)) { + if (event.type === 'assistant') { + for (const block of (event.message?.content ?? []) as JsonEvent[]) { + if (block.type === 'tool_use') { + toolCalls.push({ name: block.name, input: block.input }); + } + } + } + if (event.type === 'result') { + finalText = event.result ?? ''; + turns = event.num_turns; + costUsd = event.total_cost_usd; + if (event.is_error) { + error = event.terminal_reason ?? 'error'; + } + } + // With --plugin-dir exactly one plugin should load besides the ones + // Claude Code ships built in; anything more means the throwaway config + // directory did not isolate the run. + if (event.type === 'system' && event.subtype === 'init') { + const loaded = ((event.plugins ?? []) as JsonEvent[]).filter((plugin) => plugin.path !== 'builtin'); + if (loaded.length > 1) { + error = `isolation broken: ${loaded.map((plugin) => plugin.name).join(', ')} loaded`; + } + } + } + return { toolCalls, finalText, turns, costUsd, error }; + }, +}; diff --git a/scripts/evals/hosts/codex.ts b/scripts/evals/hosts/codex.ts new file mode 100644 index 0000000..781419e --- /dev/null +++ b/scripts/evals/hosts/codex.ts @@ -0,0 +1,26 @@ +// OpenAI Codex CLI. Runs `codex exec --json` after installing the plugin's +// skills into the working directory with the Skills CLI. The event schema has +// not been confirmed against a live run yet, so parsing is liberal. + +import { commandVersion, exec, installWithSkillsCli } from '../process.ts'; +import type { HostAdapter, RawRun, RunContext, Transcript } from '../types.ts'; +import { parseLiberally } from './liberal-transcript.ts'; + +export const codex: HostAdapter = { + defaultModel: 'gpt-5', + + version(): string { + return commandVersion('codex'); + }, + + run({ prompt, workDir, pluginDir, withSkill, model }: RunContext): RawRun { + if (withSkill) { + installWithSkillsCli(pluginDir, 'codex', workDir); + } + return exec('codex', ['exec', '--json', '--model', model, prompt], { cwd: workDir }); + }, + + parse(raw: RawRun): Transcript { + return parseLiberally(raw); + }, +}; diff --git a/scripts/evals/hosts/cursor.ts b/scripts/evals/hosts/cursor.ts new file mode 100644 index 0000000..2626212 --- /dev/null +++ b/scripts/evals/hosts/cursor.ts @@ -0,0 +1,27 @@ +// Cursor agent CLI. Runs `cursor-agent -p` with stream-json output after +// installing the plugin's skills into the working directory with the Skills +// CLI. The event schema has not been confirmed against a live run yet, so +// parsing is liberal. + +import { commandVersion, exec, installWithSkillsCli } from '../process.ts'; +import type { HostAdapter, RawRun, RunContext, Transcript } from '../types.ts'; +import { parseLiberally } from './liberal-transcript.ts'; + +export const cursor: HostAdapter = { + defaultModel: 'sonnet-4', + + version(): string { + return commandVersion('cursor-agent'); + }, + + run({ prompt, workDir, pluginDir, withSkill, model }: RunContext): RawRun { + if (withSkill) { + installWithSkillsCli(pluginDir, 'cursor', workDir); + } + return exec('cursor-agent', ['-p', '--output-format', 'stream-json', '--model', model, '-f', prompt], { cwd: workDir }); + }, + + parse(raw: RawRun): Transcript { + return parseLiberally(raw); + }, +}; diff --git a/scripts/evals/hosts/index.ts b/scripts/evals/hosts/index.ts new file mode 100644 index 0000000..fbad057 --- /dev/null +++ b/scripts/evals/hosts/index.ts @@ -0,0 +1,19 @@ +// Registry of host adapters. Adding a host is one file exporting a HostAdapter +// and one line here. + +import type { HostAdapter, HostName } from '../types.ts'; +import { antigravity } from './antigravity.ts'; +import { claude } from './claude.ts'; +import { codex } from './codex.ts'; +import { cursor } from './cursor.ts'; + +export const adapters: Record = { + claude, + antigravity, + cursor, + codex, +}; + +export function isHostName(value: string): value is HostName { + return Object.hasOwn(adapters, value); +} diff --git a/scripts/evals/hosts/liberal-transcript.ts b/scripts/evals/hosts/liberal-transcript.ts new file mode 100644 index 0000000..a437550 --- /dev/null +++ b/scripts/evals/hosts/liberal-transcript.ts @@ -0,0 +1,60 @@ +// For hosts whose JSON event schema is not pinned down yet: collect anything +// shaped like a tool call, and take the last assistant text as the reply. + +import { parseJsonLines } from '../process.ts'; +import type { JsonEvent, RawRun, ToolCall, Transcript } from '../types.ts'; + +export function parseLiberally(raw: RawRun): Transcript { + const toolCalls: ToolCall[] = []; + let finalText = ''; + let turns = 0; + for (const event of parseJsonLines(raw.stdout)) { + walk(event, (node) => { + if (isToolCallShaped(node)) { + toolCalls.push({ name: node.name ?? node.tool ?? 'tool', input: node.input ?? node.arguments ?? node.args ?? node }); + } + }); + if (event.type === 'assistant' || event.role === 'assistant') { + turns += 1; + const text = extractText(event); + if (text) { + finalText = text; + } + } + if (event.type === 'result' && typeof event.result === 'string') { + finalText = event.result; + } + } + return { toolCalls, finalText, turns, error: raw.error }; +} + +function isToolCallShaped(node: unknown): node is JsonEvent { + if (!node || typeof node !== 'object') { + return false; + } + const type = (node as JsonEvent).type; + return type === 'tool_use' || type === 'tool_call' || type === 'function_call'; +} + +function extractText(event: JsonEvent): string { + const content = event.message?.content ?? event.content; + if (typeof content === 'string') { + return content; + } + if (Array.isArray(content)) { + return content + .filter((block: JsonEvent) => block.type === 'text') + .map((block: JsonEvent) => block.text) + .join('\n'); + } + return ''; +} + +function walk(node: unknown, visit: (node: unknown) => void): void { + visit(node); + if (node && typeof node === 'object') { + for (const value of Object.values(node as Record)) { + walk(value, visit); + } + } +} diff --git a/scripts/evals/judge.ts b/scripts/evals/judge.ts new file mode 100644 index 0000000..e15c56c --- /dev/null +++ b/scripts/evals/judge.ts @@ -0,0 +1,140 @@ +// Judges a reply against a case's reference facts with one model call, so a +// case can grade what the answer says and not only which strings it holds. +// The judge asks for coverage and contradiction per fact, never similarity: +// a different but compatible approach must pass. +// +// The judge always runs through Claude Code in print mode with the same +// throwaway config directory the Claude adapter uses, whichever host the case +// ran on, so a verdict does not depend on the host's model. + +import { mkdtempSync } from 'node:fs'; +import { join } from 'node:path'; +import { exec } from './process.ts'; +import type { Check } from './types.ts'; + +export interface JudgeOptions { + model: string; + /** Directory the judge's throwaway config directory is created in. */ + workDir: string; + /** Whether the reference checks count toward the run's score. */ + scored: boolean; +} + +export interface JudgeResult { + checks: Check[]; + costUsd?: number; +} + +type FactStatus = 'covered' | 'missing' | 'contradicted'; + +interface FactVerdict { + index: number; + status: FactStatus; + evidence?: string; +} + +interface JudgeVerdict { + facts: FactVerdict[]; + contradictions?: string[]; +} + +export function judgeReference(reference: string[], reply: string, options: JudgeOptions): JudgeResult { + const configDir = mkdtempSync(join(options.workDir, 'judge-config-')); + const raw = exec( + 'claude', + ['-p', buildPrompt(reference, reply), '--strict-mcp-config', '--output-format', 'json', '--max-turns', '1', '--model', options.model], + { cwd: options.workDir, env: { ...process.env, CLAUDE_CONFIG_DIR: configDir } }, + ); + if (raw.error) { + return { checks: [judgeFailed(`judge did not run: ${raw.error}`)] }; + } + + let resultText = ''; + let costUsd: number | undefined; + try { + const output = JSON.parse(raw.stdout) as { result?: string; total_cost_usd?: number; is_error?: boolean }; + resultText = output.result ?? ''; + costUsd = output.total_cost_usd; + if (output.is_error) { + return { checks: [judgeFailed(`judge run errored: ${resultText.slice(0, 200)}`)], costUsd }; + } + } catch { + return { checks: [judgeFailed(`judge output was not JSON: ${raw.stdout.slice(0, 200)}`)] }; + } + + const verdict = parseVerdict(resultText); + if (!verdict) { + return { checks: [judgeFailed(`judge verdict was not parsable: ${resultText.slice(0, 200)}`)], costUsd }; + } + + const checks: Check[] = reference.map((fact, position) => { + const index = position + 1; + const factVerdict = verdict.facts.find((entry) => entry.index === index); + if (!factVerdict) { + return { name: `reference-${index}`, passed: false, scored: options.scored, detail: 'no verdict from judge' }; + } + const evidence = factVerdict.evidence ? `: ${factVerdict.evidence}` : ''; + return { + name: `reference-${index}`, + passed: factVerdict.status === 'covered', + scored: options.scored, + detail: `${factVerdict.status}${evidence}`, + }; + }); + const contradictions = verdict.contradictions ?? []; + checks.push({ + name: 'reference-no-contradictions', + passed: contradictions.length === 0, + scored: options.scored, + detail: contradictions.length ? contradictions.join('; ') : undefined, + }); + return { checks, costUsd }; +} + +function judgeFailed(detail: string): Check { + return { name: 'reference-judge', passed: false, scored: false, detail }; +} + +function buildPrompt(reference: string[], reply: string): string { + const facts = reference.map((fact, position) => `${position + 1}. ${fact}`).join('\n'); + return [ + "You are grading an AI assistant's reply against reference facts. Do not use any tools.", + '', + 'For each numbered fact, decide whether the reply:', + '- "covered": states the fact, in any wording or as code', + '- "missing": does not address the fact', + '- "contradicted": states something incompatible with the fact', + '', + 'Then list any other claim in the reply that contradicts the reference facts as a whole.', + 'Judge substance only. Different wording, extra detail, or a different but compatible approach is not a contradiction.', + '', + 'Answer with JSON only, no prose before or after, in exactly this shape:', + '{"facts":[{"index":1,"status":"covered","evidence":"short quote or reason"}],"contradictions":[]}', + '', + 'Reference facts:', + facts, + '', + 'Reply:', + '<<>>', + ].join('\n'); +} + +/** Accepts the JSON object anywhere in the text, so a stray sentence or code fence around it does not lose the verdict. */ +function parseVerdict(text: string): JudgeVerdict | undefined { + const start = text.indexOf('{'); + const end = text.lastIndexOf('}'); + if (start === -1 || end <= start) { + return undefined; + } + try { + const parsed = JSON.parse(text.slice(start, end + 1)) as Partial; + if (!Array.isArray(parsed.facts)) { + return undefined; + } + return { facts: parsed.facts, contradictions: parsed.contradictions ?? [] }; + } catch { + return undefined; + } +} diff --git a/scripts/evals/package-lock.json b/scripts/evals/package-lock.json new file mode 100644 index 0000000..1a5eea3 --- /dev/null +++ b/scripts/evals/package-lock.json @@ -0,0 +1,50 @@ +{ + "name": "stackone-agent-plugins-evals", + "version": "0.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "stackone-agent-plugins-evals", + "version": "0.0.0", + "devDependencies": { + "@types/node": "^22.18.0", + "typescript": "^5.9.0" + }, + "engines": { + "node": ">=22.18" + } + }, + "node_modules/@types/node": { + "version": "22.20.3", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.20.3.tgz", + "integrity": "sha512-DZmzkmwHzXrLPAXPyKNDzlIwMMUZCVacoD25ywdy5YTKGbOx/2ld+Q38Im2zJ0vBuZP5Prd3VZutKZyXwkOS8A==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~6.21.0" + } + }, + "node_modules/typescript": { + "version": "5.9.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", + "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/undici-types": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", + "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", + "dev": true, + "license": "MIT" + } + } +} diff --git a/scripts/evals/package.json b/scripts/evals/package.json new file mode 100644 index 0000000..74aed39 --- /dev/null +++ b/scripts/evals/package.json @@ -0,0 +1,17 @@ +{ + "name": "stackone-agent-plugins-evals", + "version": "0.0.0", + "private": true, + "description": "Host-neutral eval runner for the plugins in this repo. Runs on Node 22+ with no dependencies; the dev dependencies exist only to typecheck.", + "type": "module", + "engines": { + "node": ">=22.18" + }, + "scripts": { + "typecheck": "tsc -p ." + }, + "devDependencies": { + "@types/node": "^22.18.0", + "typescript": "^5.9.0" + } +} diff --git a/scripts/evals/process.ts b/scripts/evals/process.ts new file mode 100644 index 0000000..44ab264 --- /dev/null +++ b/scripts/evals/process.ts @@ -0,0 +1,68 @@ +// Process helpers shared by every host adapter: running a CLI, reading its +// version, parsing JSONL output, and installing a plugin's skills the way a +// user of that host would. + +import { spawnSync } from 'node:child_process'; +import type { JsonEvent, RawRun } from './types.ts'; + +export interface ExecOptions { + cwd?: string; + env?: NodeJS.ProcessEnv; +} + +/** Runs a command to completion with a generous buffer and a ten minute cap. */ +export function exec(command: string, args: string[], options: ExecOptions = {}): RawRun { + const spawned = spawnSync(command, args, { + encoding: 'utf8', + maxBuffer: 64 * 1024 * 1024, + timeout: 600_000, + stdio: ['ignore', 'pipe', 'pipe'], + ...options, + }); + let error: string | undefined; + if (spawned.error) { + const code = (spawned.error as NodeJS.ErrnoException).code; + error = code === 'ETIMEDOUT' ? 'timed out' : spawned.error.message; + } + return { stdout: spawned.stdout ?? '', stderr: spawned.stderr ?? '', error }; +} + +export function commandVersion(command: string): string { + const spawned = spawnSync(command, ['--version'], { encoding: 'utf8' }); + return firstLine(spawned.stdout); +} + +export function firstLine(text: string | null | undefined): string { + return (text ?? '').split('\n')[0].trim() || 'unknown'; +} + +/** Parses one JSON object per line, skipping anything that is not one. */ +export function parseJsonLines(text: string): JsonEvent[] { + const events: JsonEvent[] = []; + for (const line of text.split('\n')) { + const trimmed = line.trim(); + if (!trimmed.startsWith('{')) { + continue; + } + try { + events.push(JSON.parse(trimmed) as JsonEvent); + } catch { + // partial or non-JSON line; skip + } + } + return events; +} + +// Installs the plugin's skills into the working directory the way a user of +// that host would, so the host discovers them from the project. +export function installWithSkillsCli(pluginDir: string, agent: string, workDir: string): void { + spawnSync('git', ['init', '-q', '.'], { cwd: workDir }); + const install = spawnSync('npx', ['-y', 'skills', 'add', pluginDir, '-a', agent, '-s', '*', '-y', '--copy'], { + cwd: workDir, + encoding: 'utf8', + timeout: 120_000, + }); + if (install.status !== 0) { + throw new Error(`skills add failed for ${agent}: ${install.stderr || install.stdout}`); + } +} diff --git a/scripts/evals/report.ts b/scripts/evals/report.ts new file mode 100644 index 0000000..36eff40 --- /dev/null +++ b/scripts/evals/report.ts @@ -0,0 +1,64 @@ +// Console output and the machine-readable result for a suite run. + +import type { CaseResult, HostName, RunResult, SuiteResult, Transcript } from './types.ts'; + +export function printRun(caseName: string, runIndex: number, run: RunResult, transcript: Transcript): void { + const label = run.passed ? 'PASS' : 'FAIL'; + const errorLabel = run.error ? ` error=${run.error}` : ''; + console.log(`${label} ${caseName.padEnd(24)} run ${runIndex} score=${run.score.toFixed(2)} turns=${run.turns ?? '?'}${errorLabel}`); + for (const check of run.checks) { + if (!check.passed) { + const detail = check.detail ? `: ${check.detail}` : ''; + console.log(` - ${check.name}${check.scored ? '' : ' (indicator)'}${detail}`); + } + } + const fetchedUrls = transcript.toolCalls + .map((call) => JSON.stringify(call.input ?? '')) + .flatMap((input) => input.match(/https?:\/\/[^"\\\s]+/g) ?? []); + if (fetchedUrls.length) { + console.log(` urls: ${[...new Set(fetchedUrls)].join(' ')}`); + } + if (run.skillsUsed.length) { + console.log(` skills: ${run.skillsUsed.join(' ')}`); + } +} + +export interface SuiteContext { + host: HostName; + hostVersion: string; + model: string; + withSkill: boolean; + runsPerCase: number; + startedAt: string; +} + +export function summarise(cases: CaseResult[], context: SuiteContext): SuiteResult { + const allRuns = cases.flatMap((entry) => entry.runs); + const casesPassed = cases.filter((entry) => entry.aggregates.passRate === 1).length; + const overallScore = cases.reduce((sum, entry) => sum + entry.aggregates.score, 0) / (cases.length || 1); + const runsWithErrors = allRuns.filter((run) => run.error).length; + // Only some hosts report spend; a zero from a host that does not would mislead. + // Judge calls always report theirs, and count toward the total. + const costKnown = allRuns.some((run) => run.costUsd !== undefined || run.judgeCostUsd !== undefined); + const costUsd = allRuns.reduce((sum, run) => sum + (run.costUsd ?? 0) + (run.judgeCostUsd ?? 0), 0); + return { + ...context, + cases, + aggregates: { + casesTotal: cases.length, + casesPassed, + overallScore, + overallPassRate: casesPassed / (cases.length || 1), + runsWithErrors, + }, + costUsd: costKnown ? costUsd : null, + }; +} + +export function printSummary(result: SuiteResult, outputRoot: string): void { + const { casesPassed, casesTotal, overallScore, runsWithErrors } = result.aggregates; + const costLabel = result.costUsd === null ? 'n/a' : `$${result.costUsd.toFixed(2)}`; + const errorLabel = runsWithErrors ? ` runs with errors ${runsWithErrors} (verdicts on those are ambiguous)` : ''; + console.log(''); + console.log(`cases passed ${casesPassed} / ${casesTotal} overall score ${overallScore.toFixed(2)} cost ${costLabel}${errorLabel} transcripts in ${outputRoot}`); +} diff --git a/scripts/evals/run-host.ts b/scripts/evals/run-host.ts new file mode 100644 index 0000000..0319aa4 --- /dev/null +++ b/scripts/evals/run-host.ts @@ -0,0 +1,157 @@ +#!/usr/bin/env node +// Runs a plugin's eval cases against one agent host and grades each run with +// the host-neutral checks in the case file. +// +// Usage: +// node scripts/evals/run-host.ts --host claude --plugin plugins/integrations/stackone-platform +// node scripts/evals/run-host.ts --host antigravity --plugin --model gemini-3.8-flash-high +// node scripts/evals/run-host.ts --host claude --plugin --baseline # same prompts, no skills +// node scripts/evals/run-host.ts --host claude --plugin --case debug-401 --json out.json +// node scripts/evals/run-host.ts --host claude --plugin --case embed-hub --runs 3 --model opus # --case matches a name prefix +// node scripts/evals/run-host.ts --host claude --plugin --score-reference --judge-model sonnet +// +// Cases live beside the runner in cases//, keyed by the plugin +// directory's name, so the plugin ships without its test fixtures; --cases +// overrides the location. Every run gets a throwaway working directory, and +// each host adapter adds whatever else keeps the run isolated to the plugin +// under test. Cases with reference facts get one judge call per run on top of +// the agent run. Runs on Node 22.18 or later with no dependencies (Node strips +// the types itself). +// Typecheck with `npm --prefix scripts/evals install` once, then +// `npm --prefix scripts/evals run typecheck`. + +import { mkdtempSync, writeFileSync } from 'node:fs'; +import { tmpdir } from 'node:os'; +import { basename, join, resolve } from 'node:path'; +import { loadCases } from './cases.ts'; +import { grade, skillsUsed } from './grade.ts'; +import { adapters, isHostName } from './hosts/index.ts'; +import { judgeReference } from './judge.ts'; +import { printRun, printSummary, summarise } from './report.ts'; +import type { CaseResult, RunResult } from './types.ts'; + +type CliOptions = Record; + +function main(argv: string[]): number { + const options = parseArgs(argv); + const host = typeof options.host === 'string' ? options.host : ''; + const pluginOption = typeof options.plugin === 'string' ? options.plugin : ''; + if (!host || !pluginOption) { + console.error('usage: run-host.ts --host --plugin [--runs N] [--model M] [--case NAME-OR-PREFIX] [--baseline] [--cases DIR] [--judge-model M] [--score-reference] [--json out.json]'); + return 2; + } + if (!isHostName(host)) { + console.error(`unknown host ${host}; known: ${Object.keys(adapters).join(', ')}`); + return 2; + } + + const adapter = adapters[host]; + const pluginDir = resolve(pluginOption); + const casesDir = typeof options.cases === 'string' + ? resolve(options.cases) + : join(import.meta.dirname, 'cases', basename(pluginDir)); + const runsPerCase = Number(options.runs ?? 1); + const withSkill = !options.baseline; + const model = typeof options.model === 'string' ? options.model : adapter.defaultModel; + const judgeModel = typeof options['judge-model'] === 'string' ? options['judge-model'] : 'sonnet'; + const scoreReference = Boolean(options['score-reference']); + const outputRoot = mkdtempSync(join(tmpdir(), `evals-${host}-`)); + const hostVersion = adapter.version(); + + console.log(`host: ${host} (${hostVersion})`); + console.log(`plugin: ${pluginDir}${withSkill ? '' : ' [baseline: skills NOT installed]'}`); + console.log(`cases: ${casesDir}`); + console.log(`runs: ${runsPerCase} per case, model ${model}`); + console.log(`judge: ${judgeModel}, reference checks ${scoreReference ? 'scored' : 'reported as indicators'}`); + console.log(`output: ${outputRoot}`); + console.log(''); + + const cases = loadCases(casesDir, { + casePrefix: typeof options.case === 'string' ? options.case : undefined, + }); + + const results: CaseResult[] = []; + for (const evalCase of cases) { + const runs: RunResult[] = []; + for (let runIndex = 0; runIndex < runsPerCase; runIndex += 1) { + const workDir = mkdtempSync(join(outputRoot, `${evalCase.name}.run${runIndex}.`)); + const transcriptPath = join(outputRoot, `${evalCase.name}.run${runIndex}.jsonl`); + const raw = adapter.run({ prompt: evalCase.prompt, workDir, pluginDir, withSkill, model, maxTurns: evalCase.maxTurns }); + writeFileSync(transcriptPath, raw.transcript ?? raw.stdout); + writeFileSync(`${transcriptPath}.err`, raw.stderr); + const transcript = adapter.parse(raw); + const checks = grade(evalCase.expectation, transcript); + let judgeCostUsd: number | undefined; + if (evalCase.expectation.reference?.length) { + const judged = judgeReference(evalCase.expectation.reference, transcript.finalText, { + model: judgeModel, + workDir, + scored: scoreReference, + }); + checks.push(...judged.checks); + judgeCostUsd = judged.costUsd; + } + const scored = checks.filter((check) => check.scored); + const passedCount = scored.filter((check) => check.passed).length; + const run: RunResult = { + passed: scored.every((check) => check.passed), + score: scored.length ? passedCount / scored.length : 1, + turns: transcript.turns, + costUsd: transcript.costUsd, + judgeCostUsd, + error: transcript.error ?? null, + checks, + toolCalls: transcript.toolCalls.map((call) => call.name), + skillsUsed: skillsUsed(transcript), + transcriptPath, + }; + runs.push(run); + printRun(evalCase.name, runIndex, run, transcript); + } + results.push({ + name: evalCase.name, + aggregates: { + score: runs.reduce((sum, run) => sum + run.score, 0) / runs.length, + passRate: runs.filter((run) => run.passed).length / runs.length, + runsWithErrors: runs.filter((run) => run.error).length, + }, + runs, + }); + } + + const result = summarise(results, { + host, + hostVersion, + model, + withSkill, + runsPerCase, + startedAt: new Date().toISOString(), + }); + printSummary(result, outputRoot); + if (typeof options.json === 'string') { + writeFileSync(options.json, JSON.stringify(result, null, 2)); + console.log(`wrote ${options.json}`); + } + return result.aggregates.casesPassed === result.aggregates.casesTotal ? 0 : 1; +} + +function parseArgs(argv: string[]): CliOptions { + const parsed: CliOptions = {}; + for (let index = 0; index < argv.length; index += 1) { + const arg = argv[index]; + if (!arg.startsWith('--')) { + continue; + } + const key = arg.slice(2); + const next = argv[index + 1]; + if (next === undefined || next.startsWith('--')) { + parsed[key] = true; + } else { + parsed[key] = next; + index += 1; + } + } + return parsed; +} + +process.exit(main(process.argv.slice(2))); diff --git a/scripts/evals/tsconfig.json b/scripts/evals/tsconfig.json new file mode 100644 index 0000000..0657f8f --- /dev/null +++ b/scripts/evals/tsconfig.json @@ -0,0 +1,15 @@ +{ + "compilerOptions": { + "target": "es2022", + "module": "nodenext", + "moduleResolution": "nodenext", + "strict": true, + "noEmit": true, + "allowImportingTsExtensions": true, + "erasableSyntaxOnly": true, + "verbatimModuleSyntax": true, + "types": ["node"], + "skipLibCheck": true + }, + "include": ["**/*.ts"] +} diff --git a/scripts/evals/types.ts b/scripts/evals/types.ts new file mode 100644 index 0000000..7d19add --- /dev/null +++ b/scripts/evals/types.ts @@ -0,0 +1,130 @@ +// Shared contracts for the eval runner. A host adapter turns a prompt into a +// RawRun and a RawRun into a Transcript; grading only ever sees the +// Transcript, which is what keeps every check host-neutral. + +export type HostName = 'claude' | 'antigravity' | 'cursor' | 'codex'; + +export interface RegexCheck { + name: string; + /** JavaScript regex source, applied to JSON-encoded tool input or to the reply text. */ + match: string; + note?: string; +} + +/** The host-neutral checks in a case file, everything except the prompt and turn cap. */ +export interface Expectation { + skill: string; + /** Whether the skill is expected to be used. Reported as an indicator, never scored. */ + skill_should_fire?: boolean; + skill_note?: string; + fetch?: RegexCheck[]; + no_fetch?: RegexCheck[]; + reply?: RegexCheck[]; + no_reply?: RegexCheck[]; + /** Facts a correct reply states, one per entry, judged by a model call for coverage and contradiction. */ + reference?: string[]; +} + +export interface EvalCase { + name: string; + path: string; + prompt: string; + maxTurns: number; + expectation: Expectation; +} + +export interface ToolCall { + name: string; + input: unknown; +} + +export interface Transcript { + toolCalls: ToolCall[]; + finalText: string; + turns?: number; + costUsd?: number; + error?: string; +} + +export interface RawRun { + stdout: string; + stderr: string; + error?: string; + /** Hosts that keep the transcript somewhere other than stdout attach it here. */ + transcript?: string; +} + +export interface RunContext { + prompt: string; + workDir: string; + pluginDir: string; + withSkill: boolean; + model: string; + maxTurns: number; +} + +export interface HostAdapter { + defaultModel: string; + version(): string; + run(context: RunContext): RawRun; + parse(raw: RawRun): Transcript; +} + +export interface Check { + name: string; + passed: boolean; + /** Unscored checks are reported as indicators and do not affect the run's score. */ + scored: boolean; + /** Why the check has the verdict it has, when the grader can say. */ + detail?: string; +} + +export interface RunResult { + passed: boolean; + score: number; + turns?: number; + costUsd?: number; + /** Spend of the reference judge call, when a case has reference facts. */ + judgeCostUsd?: number; + error: string | null; + checks: Check[]; + toolCalls: string[]; + skillsUsed: string[]; + transcriptPath: string; +} + +export interface CaseAggregates { + score: number; + passRate: number; + runsWithErrors: number; +} + +export interface CaseResult { + name: string; + aggregates: CaseAggregates; + runs: RunResult[]; +} + +export interface SuiteAggregates { + casesTotal: number; + casesPassed: number; + overallScore: number; + overallPassRate: number; + runsWithErrors: number; +} + +export interface SuiteResult { + host: HostName; + hostVersion: string; + model: string; + withSkill: boolean; + startedAt: string; + runsPerCase: number; + cases: CaseResult[]; + aggregates: SuiteAggregates; + /** Null when the host does not report spend. */ + costUsd: number | null; +} + +/** One parsed line of a JSONL transcript. Shapes differ per host, so fields are read defensively. */ +export type JsonEvent = Record;