<p align="center">
  <img src="https://raw.githubusercontent.com/testomatio/testeiya-app/main/assets/testeiya-cli-logo.png" alt="Testeiya" width="220">
</p>

# Testeiya

[![npm](https://img.shields.io/npm/v/testeiya)](https://www.npmjs.com/package/testeiya)
[![licence](https://img.shields.io/npm/l/testeiya)](LICENSE)

An agent, app, and the goddess of testing.

Testeiya is an AI QA agent. This repository is home to two things:

- **Testeiya Desktop**, the app. Download it from [Releases](https://github.com/testomatio/testeiya-app/releases/latest).
- **Testeiya CLI**, the command-line agent for CI. Install it from [npm](https://www.npmjs.com/package/testeiya).

## Desktop app

Chat with a QA agent that works inside your project. It reads your code and
test files, writes and reviews test cases, runs tests, explores a live app in
its own browser, and syncs with your Testomat.io project.

Install it with one command, which needs Node 22.19 or newer:

```bash
npx testeiya install-app
```

It picks the build for your OS and skips the download if the app is already
installed; `--force` reinstalls. The app lands in `/Applications` on macOS
(`~/Applications` without write access), `%LOCALAPPDATA%\Testeiya` on Windows, and
`~/.local/bin` on Linux, with a menu entry on Windows and Linux.

Or download a build yourself:

| OS | Download |
|---|---|
| macOS (Apple Silicon) | [`stable-macos-arm64-Testeiya.dmg`](https://github.com/testomatio/testeiya-app/releases/latest/download/stable-macos-arm64-Testeiya.dmg) |
| macOS (Intel) | [`stable-macos-x64-Testeiya.dmg`](https://github.com/testomatio/testeiya-app/releases/latest/download/stable-macos-x64-Testeiya.dmg) |
| Windows (x64) | [`stable-win-x64-Testeiya.zip`](https://github.com/testomatio/testeiya-app/releases/latest/download/stable-win-x64-Testeiya.zip) |
| Linux (x64) | [`Testeiya-x86_64.AppImage`](https://github.com/testomatio/testeiya-app/releases/latest/download/Testeiya-x86_64.AppImage) |

The builds are unsigned, so each OS warns once on first launch:

- **macOS**: open the `.dmg` and drag Testeiya into Applications. On first launch, right-click it and pick **Open**. If macOS still blocks it, run `xattr -dr com.apple.quarantine /Applications/Testeiya.app`.
- **Windows**: extract the zip to a short path such as `C:\Testeiya` and run `Testeiya\bin\launcher.exe`. If SmartScreen appears, click **More info**, then **Run anyway**.
- **Linux**: `chmod +x Testeiya-x86_64.AppImage && ./Testeiya-x86_64.AppImage`. Without FUSE, add `--appimage-extract-and-run`.

Once installed, the app updates itself. Add an LLM provider key in Settings, or
put one in `~/.testeiya/.env` to share it with the CLI, and open a project folder.

The app's source is not open. This repository holds what the agent reads: its
prompt and skills, shared with the CLI. Report app issues here too.

## CLI

The `testeiya` command is the same agent, built for CI. It reacts to triggers —
a pull request, a new issue, a failed test run, a deploy — runs exactly one
analysis, and delivers its verdict where your team works: a PR comment, a
markdown report, or a Testomat.io project. There is no interactive mode and no human in the loop. That is the point:
you wire it into CI once, and every event that should get QA thinking gets it.

| Folder | What it is |
|---|---|
| `prompt/` | The system prompt: the agent's role, the trigger-run contract, workspace and tool guidance, Testomat.io rules, and the report contract. Plus the comment-thread rules a CI run adds |
| `skills/` | The manifest of skills the agent can invoke. Every folder is fetched from its own upstream repository |
| `src/` | The `testeiya` command-line agent (Node) |

### Install

Requires Node 22.19 or newer, an LLM provider key, and a model.

```bash
npx testeiya doctor
```

`doctor` reports which key won, which skills loaded, and whether Testomat.io is reachable — without spending a token.

The key comes from the environment (`OPENROUTER_API_KEY`, `ANTHROPIC_API_KEY`,
`OPENAI_API_KEY`, `GEMINI_API_KEY`), from `~/.testeiya/.env`, or from
`~/.testeiya/auth.json`. The desktop app reads `~/.testeiya/.env` too, so a key
there covers both. Keys saved in the desktop app's Settings stay in the app.

There is no default model. Name one with `--model <provider>/<id>` or
`TESTEIYA_MODEL`. CI usually has neither set, so a run that resolves no model
exits `2` rather than picking one for you.

```bash
export TESTEIYA_MODEL=openrouter/anthropic/claude-sonnet-5
testeiya models anthropic   # list what your key can reach
```

## How it runs

```bash
testeiya task "<task>"     # run one task, deliver a report, exit
testeiya ask "<question>"  # answer a question, no report
testeiya decide "<question>"  # yes or no from a decision model: exit 0 yes, 1 no
testeiya extract "<what>" -o "<name>: <description>"  # find values, print them
testeiya pipeline <name>   # run several stages in a row, see Pipelines
testeiya skills            # list the skills bundled with this package
testeiya sessions          # list saved sessions for this folder
```

The agent runs one task and exits. Progress goes to stderr, so a run drops into CI as-is:

| Exit code | Meaning |
|---|---|
| `0` | pass, or a positive verdict from the agent |
| `1` | failed run, or a negative verdict — findings that need a human |
| `2` | bad usage |
| `130` | interrupted |

Pass `--exit-zero` when a negative verdict must not fail the job. A broken run
still exits `1`, bad usage still exits `2`, and the verdict is still in the
report and in the run envelope for anything that wants to gate on it.

A task can come from stdin too:

```bash
cat issue-42.md | testeiya task --output report.md
```

### Decide and extract

`decide` asks a decision model, such as TypeSafe's Jev or Cloudflare's Clef, a
yes or no question. It has no tools: it judges the question against the files
you pass with `--context`, or against stdin. It prints `yes` or `no` and exits
`0` or `1`. A failed call exits `1` too, so a gate fails closed.

```bash
export TESTEIYA_DECISION_MODEL=openrouter/cloudflare/clef
testeiya decide "Can we release?" --context report.md --threshold 0.8 && npm publish
```

`extract` runs the agent like a task, but its answer is values, one per
`--output`, printed as `name: value` lines or as JSON with `--json`:

```bash
testeiya extract "A public url for the deployment of this PR" --output "url: public url of a page"
# url: https://pr-42.preview.example.com
```

When a value cannot be found nothing is printed and it exits `1`. Both commands
work as pipeline stages too, see [PIPELINES.md](PIPELINES.md#decisions-and-extractions).

Every command takes `--json` for machine-readable output of the run envelope
(verdict, reason, tokens, session id). `testeiya --help` lists all options;
`testeiya help` is the full guide.

## Scenarios

Each scenario below is a single unattended run. Nobody answers questions; the
agent reads what the trigger gives it and acts on its own judgement. If its
verdict is negative, the job fails — that failure *is* the signal.

### Grill a pull request

Every PR gets a QA review before merge. The agent loads the branch's diff,
analyzes it through the `qa-thinking` skill — edge cases, negative flows,
abuses, data-consistency risks — and posts the findings as a PR comment:

```bash
git fetch origin "$PR_BRANCH"
git checkout "$PR_BRANCH"
testeiya task "Review this pull request as a QA engineer. What could go wrong?" \
  --output gh:pr-comment --output review.json
```

Exit code `1` means the agent found real risk, so you can gate the merge on it.

### Write test cases from a pull request

Same trigger, different deliverable: the `qa-write-test-cases` skill turns the
change into test cases in Testomat.io markdown format, written as a build
artifact ready to commit or import:

```bash
testeiya task "Create test cases covering the changes in this pull request" \
  --output testcases/
```

With `TESTOMATIO` and the project id set, add
`sync them to Testomat.io` to the task and they land straight in the TMS via
`sync-test-cases-with-tms`.

### Create test cases from a new issue

A requirements text arrives from the issue tracker — piped in, no human
summarizing it first. The agent writes a checklist and test cases from it:

```bash
gh issue view 57 --json title,body -q '.title + "\n\n" + .body' \
| testeiya task --output testcases/issue-57.md
```

### Explore a deployed app with Explorbot

After a deploy, point [Explorbot](https://github.com/testomatio/explorbot) — the
autonomous browser-testing CLI the agent drives through the `explorbot-*`
skills — at the staging URL. It researches, plans, and tests the live app in
its own browser, then reports what broke:

```bash
testeiya task "Run explorbot against https://staging.example.com, max 10 tests, report failures" \
  --output explorbot-report.md
```

### Audit the test suite on a schedule

Nightly, the agent walks the Testomat.io project and reports gaps — suites with
no tests, cases gone stale against the current code, coverage holes:

```bash
TESTOMATIO=tstmt_xxx testeiya task \
  "Audit this project: which suites have no automated tests, and which manual cases look automatable?" \
  --output audits/$(date +%F).md
```

## Pipelines

Some QA flows take more than one run, and not every step is the agent: review a
pull request, run Explorbot against staging, then explain what broke. A
pipeline is that flow in one YAML file, run by one command.

```bash
testeiya pipeline                     # list the bundled pipelines
testeiya pipeline web-testing -o gh:pr-comment
testeiya pipeline .github/testeiya/my-flow.yml --dry-run
testeiya pipeline-check .github/testeiya/my-flow.yml   # check the file and every prerequisite
testeiya pipeline-check regression --diagram           # also draw it as a Mermaid chart
```

| Pipeline | What it does |
|---|---|
| `pr-review` | requirements, QA review, test cases, sync to Testomat.io |
| `issue-test-cases` | an issue or epic, with its sub-issues, becomes test cases; set `ISSUE_URL` |
| `web-testing` | review, an Explorbot plan, `explorbot test`, what broke |
| `api-testing` | review lists changed endpoints, Explorbot tests each one |
| `regression` | runs the tests `coverage.tests.yml` maps to the change, explains failures |

To change one, extend it: a file that starts with `$extends: <name>` holds only
the changes, and runs by its path. See [Extending a pipeline](PIPELINES.md#extending-a-pipeline).

### The file

A pipeline is a [scripted-yaml](https://github.com/DavertMik/scripted-yaml) file:
YAML where `key!:` is a formula, `{{ }}` in text is filled in, and `run!sh:` is a
shell command. Its shape is [`pipelines/pipeline.dsl.yml`](pipelines/pipeline.dsl.yml).

```yaml
$dsl: ./pipeline.dsl.yml

name: web-testing
description: Review a pull request, test it in a browser, explain what broke.
target: pr

prerequisites:
  staging:
    $value!: vars.EXPLORBOT_URL != null
    message: No staging URL. Set EXPLORBOT_URL to test in a browser.
  browser:
    $value!sh: ls "${PLAYWRIGHT_BROWSERS_PATH:-$HOME/.cache/ms-playwright}" | grep -q chromium
    message: No browser. Run npx playwright install --with-deps chromium.

stages:
  - id: review
    title: Review
    emoji: 🔍
    session: qa
    task: Review this pull request for {{ vars.EXPLORBOT_URL }}. Write browser scenarios to plan.md. /explorbot-plan
    outputs: [plan.md]
  - id: explore
    title: Browser testing
    emoji: 🌐
    when!: prerequisites.staging and prerequisites.browser
    run!sh: EXPLORBOT_OUTPUT="$STAGE_DIR/explorbot" npx -y explorbot test "$STAGE_DIR/plan.md" '*'
    inputs: [plan.md]
    outputs: [explorbot/]
    timeout: 30m
  - id: results
    title: Results
    emoji: 📊
    session: qa
    task: Read the Explorbot report under explorbot/ and say what broke.
    inputs: [explorbot/]
```

- A stage is a `task` for the agent or a `run!sh` shell command. Its `title` and
  `emoji` head its section in the final report, `### 🔍 Review`. Both are
  optional: the title defaults to the id, the emoji is picked for you.
- Each stage keeps its files in a numbered folder, `1-review/`, `2-explore/`, …,
  so a run reads in order. An agent stage writes `<id>.md` and `<id>.json`, a
  command writes `<id>.log`. `outputs` name the rest. `inputs` are linked into
  the folder from the stage that wrote them, as `$STAGE_DIR/<file>`.
- `prerequisites` are named checks. `$value!:` is a formula over variables,
  `vars.NAME != null` for "is set". `$value!file:`, `$value!sh:` and
  `$value!changes:` (`paths`, `ignore`, `min_files`) are checks the runner makes.
  `when!:` is a formula over them. When it is false the stage is skipped with the
  message of the prerequisite that failed. In the top-level `when!:` it skips the
  whole run.
- `npx scripted-yaml validate pipelines/*.yml --markers sh,file,changes` checks
  a file's shape; `npm run validate:pipelines` does it for the bundled ones.
- `session: <name>` keeps a conversation. Stages with the same name share it.
  No `session` is a fresh one.
- `each_line: file.txt` and `each_file: cases/*.md` run a stage once per item,
  as `$ITEM`.
- A stage that fails, breaks or times out stops the pipeline. `continueOn: fail`
  lets the next stages run after a fail, the run still fails. `optional: true`
  marks a stage whose failure neither stops nor fails the run. `stopOn: [gate]`
  stops the pipeline when the stage was skipped.

The full format is in [PIPELINES.md](PIPELINES.md).

A pipeline with more than one stage ends with a summary: one `### <emoji> <title>`
section per stage holding that stage's report, trimmed, with nothing repeated
between sections. It never adds content of its own. It is the
only thing posted to `--output`. Every other stage runs with `--no-thread`, so
nothing else touches the pull request.

### Rounds

Keep `--dir` between runs, as a CI cache per pull request, and each run is a
round. A re-run on the same commit retries from the stage that stopped. A new
commit starts a new round: `changes` count from the last round's commit, the
last round's files move to `.last/`, and each agent stage updates its own last
result instead of starting over. The summary updates its comment.

```yaml
- uses: actions/cache/restore@v4
  with:
    path: ${{ runner.temp }}/qa
    key: qa-pr-${{ github.event.number }}-${{ github.run_id }}
    restore-keys: qa-pr-${{ github.event.number }}-
- run: npx testeiya@latest pipeline pr-review --dir ${{ runner.temp }}/qa -o gh:pr-comment --exit-zero
- uses: actions/cache/save@v4
  if: always()
  with:
    path: ${{ runner.temp }}/qa
    key: qa-pr-${{ github.event.number }}-${{ github.run_id }}-${{ github.run_attempt }}
```

Stages ignore `TESTEIYA_FOLLOW_UP`, `TESTEIYA_THREAD` and `TESTEIYA_SESSION_FILE`:
those belong to a single task. Use `--thread` on the pipeline instead.

`--set KEY=VALUE` sets a variable for every stage. `--gate NAME:COMMAND` adds a
check from the CI job: when the command fails, the whole run is skipped and exits
0, before any output is checked. Use it for what only the job knows, like
whether this push belongs to a pull request. `--stage ID:YAML` and
`--pipeline YAML` patch a pipeline for one run, e.g. `--stage
'requirements:task: { $after: Never assume credentials. }'`. `$replace`
overwrites, `$add` adds, `$before` and `$after` add text or stages, `$remove`
drops. A file that starts with `$extends: <name>` keeps the same patch in the repo. `--dry-run` prints every
prerequisite and stage and spends nothing. `testeiya pipeline-check` checks the file and
every prerequisite it declares, used or not, and prints the message of each one that
does not pass. `--diagram` also writes the pipeline as a Mermaid chart.
`pipeline.json` in the folder holds each stage's status; `--json` prints it.

## CI setup

Testeiya needs three things in any CI system: a provider key, a model name, and
the checkout of whatever the task reads. Everything else is standard.

### GitHub Actions

GitHub runners ship the [GitHub CLI](https://cli.github.com), so posting back to
the PR is one flag. `GITHUB_TOKEN` authenticates it; keep the LLM key in
repository secrets.

```yaml
name: qa-review
on:
  pull_request:
    types: [opened, synchronize]

permissions:
  pull-requests: write
  contents: read

jobs:
  grill:
    runs-on: ubuntu-latest
    env:
      GH_TOKEN: ${{ github.token }}
      OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
      TESTEIYA_MODEL: openrouter/anthropic/claude-sonnet-5
      # optional, for scenarios that touch Testomat.io
      TESTOMATIO: ${{ secrets.TESTOMATIO }}
      TESTOMATIO_PROJECT_ID: my-project
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - uses: actions/setup-node@v4
        with:
          node-version: 22
      - run: npx testeiya@latest doctor
      - run: |
          npx testeiya@latest task \
            "Review this pull request as a QA engineer. What could go wrong?" \
            --output gh:pr-comment --output review.json
      - uses: actions/upload-artifact@v4
        if: always()
        with:
          name: review
          path: review.json
```

The same shape works for the other scenarios: trigger on `issues` and pipe the
body in for test-case generation, or run on a `schedule` for the nightly audit.

To let reviewers answer in the thread, add `issue_comment` to the triggers, sign
the report with a line that says how to reply, and hand the comment body to the
run as a follow-up:

```yaml
on:
  pull_request:
    types: [opened, synchronize]
  issue_comment:
    types: [created]

jobs:
  grill:
    if: >-
      github.event_name == 'pull_request' ||
      (github.event.issue.pull_request &&
       startsWith(github.event.comment.body, '/testeiya'))
    runs-on: ubuntu-latest
    env:
      GH_TOKEN: ${{ github.token }}
      TESTEIYA_FOLLOW_UP: ${{ github.event.comment.body || '' }}
      PR: ${{ github.event.number || github.event.issue.number }}
    steps:
      # full history, so the round can diff against the commit the last one saw
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      # a comment event checks out the default branch, so move to the pull request
      - run: gh pr checkout $PR
      # the session lives here; without this every round starts empty
      - uses: actions/cache/restore@v4
        with:
          path: ~/.cache/testeiya
          key: testeiya-pr-${{ env.PR }}-${{ github.run_id }}
          restore-keys: testeiya-pr-${{ env.PR }}-
      - run: |
          npx testeiya@latest task \
            "Review this pull request as a QA engineer. What could go wrong?" \
            --session-file ~/.cache/testeiya/pr-$PR.jsonl \
            --footer "> Reply to this comment starting with /testeiya" \
            --output gh:pr-comment
      # save even when the verdict failed the job — that is the round people reply to
      - uses: actions/cache/save@v4
        if: always()
        with:
          path: ~/.cache/testeiya
          key: testeiya-pr-${{ env.PR }}-${{ github.run_id }}
```

`issue_comment` fires on issues as well as pull requests and always runs the
default branch's copy of the workflow, against the default branch's code. The
`github.event.issue.pull_request` check and the `gh pr checkout` step above are
what keep an answer on the right code. Gate the trigger on the author too: every
comment spends tokens.

Two details are load-bearing. The cache is split because `actions/cache` saves
in a post step that a failed job never reaches, and a negative verdict fails the
job — so the round a reviewer is most likely to answer would be the one that
saved no session. Add `--exit-zero` instead if you would rather the verdict live
only in the comment and never red the job. And the key carries `github.run_id`
with a `restore-keys` prefix, because a cache entry is never overwritten: a
fixed key would save the first round and restore it forever, in a green job that
looks fine.

### GitLab CI

GitLab runners do not ship `gh`. The report goes to job artifacts, and when a
token is present the agent also keeps its review on the merge request itself.
Exit code `1` fails the job and blocks the merge when you mark it required.

```yaml
qa-review:
  image: node:22
  rules:
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
  variables:
    TESTEIYA_MODEL: openrouter/anthropic/claude-sonnet-5
    TESTOMATIO_PROJECT_ID: my-project
    # a project access token with the `api` scope; CI_JOB_TOKEN cannot write notes
    GITLAB_TOKEN: $TESTEIYA_GITLAB_TOKEN
  script:
    - git fetch origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME
    - npx testeiya@latest doctor
    - npx testeiya@latest task
        "Review this merge request as a QA engineer. What could go wrong?"
        --output review/report.md --output review/envelope.json
  artifacts:
    when: always
    paths:
      - review/
  parallel:
    # secrets go to Settings > CI/CD > Variables:
    #   OPENROUTER_API_KEY (masked), TESTOMATIO (masked, protected)
```

Without `GITLAB_TOKEN` the run still produces the artifacts, it just posts
nothing. With it, the agent keeps one note per thread and rewrites it each
round. See [Comment threads](#comment-threads).

### Bitbucket Pipelines

There is no Bitbucket CLI, so the agent talks to the REST API directly. Put a
repository access token that can write pull requests in `BITBUCKET_ACCESS_TOKEN`,
and `BITBUCKET_PR_ID` does the rest.

```yaml
pipelines:
  pull-requests:
    '**':
      - step:
          image: node:22
          script:
            - export TESTEIYA_MODEL=openrouter/anthropic/claude-sonnet-5
            # repository variables: OPENROUTER_API_KEY, BITBUCKET_ACCESS_TOKEN
            - npx testeiya@latest task
                "Review this pull request as a QA engineer. What could go wrong?"
                --thread qa-review --output review.md
          artifacts:
            - review.md
```

`BITBUCKET_PR_ID` is only set on a pull request build, so keep the step under
`pull-requests:`. Bitbucket caps a pull request at 200 comments, which is why
the agent resolves its old ones instead of adding a fresh thread each round.

### Anywhere else

Any scheduler that can run a container works — the contract is just stdin,
stdout, and an exit code:

```bash
echo "Audit the checkout suite for gaps" | testeiya task --output audit.md
case $? in
  0) echo "clean" ;;
  1) echo "findings need review" ;;
esac
```

## Where the report goes

`--output` names a destination and can repeat. Without one the report goes to stdout.

```bash
testeiya task "<task>" --output report.md --output run.json --output gh:pr-comment
```

| Destination | What happens |
|---|---|
| `report.md` | the agent writes the report there |
| `run.json` | the run envelope: verdict, reason, report, tokens, session id |
| `gh:pr-comment` | posted on this branch's pull request |
| `gh:pr#123` | posted on that pull request |

Posting uses the GitHub CLI and resolves the PR number from `GITHUB_EVENT_PATH`,
`GITHUB_REF`, or `gh pr view`. On a push with no PR of its own, like a merge to
main, it posts on the PR that brought the commit in. Inside Actions it just works. Every
destination is checked before the run starts, so a missing `gh` costs no tokens.

`--footer "<text>"` adds a line under the report and `--header "<text>"` adds
one above. Both go wherever the report goes: stdout, the file, the posted
comment. A footer is what turns a posted report into a conversation: tell the
reader how to answer, and let the workflow feed their reply back into the same
session.

```bash
testeiya task "Review this pull request" \
  --output gh:pr-comment \
  --footer "> You can reply to this comment by typing /testeiya"
```

Write no footer of your own and the report is signed:

> *🧚🏻‍♀️ Provided by [Testeiya QA Agent](https://testomat.ai/testeiya) & claude-sonnet-5*

Pass `--no-default-footer`, or set `TESTEIYA_NO_DEFAULT_FOOTER`, to drop it.

## Comment threads

Every report opens with a marker that markdown renders as nothing:

```
<!-- testeiya thread=qa-review commit=700fbe1d9c... session=0198f2c1a3b4c -->
```

That line is how a later round finds its own earlier comments, which
conversation they belong to, and what they were written against. It lives in the
thread, not in a cache, so a round that starts with an empty runner still knows
what it last reviewed and can diff from there.

In a thread the agent looks after those comments rather than piling them up.
A thread is any subject it posts into: a pull request, a merge request, an
issue. Each round writes the complete current answer, opening with a short list
of what changed since the last one, and makes the earlier comments recede:

| CI | How the earlier answer recedes |
|---|---|
| GitHub Actions | folded in place, as an outdated comment |
| Bitbucket Pipelines | resolved, which collapses it |
| GitLab CI | one note, rewritten, with the previous answer folded inside it |
| any other CI | the agent reads the host's API and picks whichever of the two fits |

There are two strategies, not one per host. Where the host can fold a whole
comment the agent appends and folds; where it can only fold the body, the
comment chrome would pile up, so it keeps one comment and rewrites it. GitLab is
the odd one out for that reason. A CI we ship no calls for gets both strategies
and picks, from that host's own documentation.

Nothing is ever deleted. A human reply may be sitting under a comment, and every
step here can be undone where a delete cannot.

`--thread <name>` says which conversation a run belongs to. Run two jobs on one
pull request, say one grilling it and one writing test cases, and give each its
own name so neither touches the other's comments. The default is `default`, and
`TESTEIYA_THREAD` does the same from the environment.

```bash
testeiya task "Review this pull request" \
  --thread qa-review --output gh:pr-comment
```

The host comes from the job, not from the checkout: `GITHUB_ACTIONS`,
`GITLAB_CI`, `BITBUCKET_BUILD_NUMBER`, else `CI`. A remote only says where the
code lives, while those say the run has a subject to answer and a token to
answer with. So these rules never reach a developer's own checkout, and the
agent is told about one host, never the others.

## Sessions

Runs are saved under `~/.testeiya`, so a follow-up picks up where the last one
stopped. A resumed run reuses its session's model.

```bash
testeiya task "Review the checkout suite" --name checkout-review --output report.md
testeiya task "Now write the missing cases" -c
testeiya sessions
testeiya task "<task>" --resume <id>
```

Pass `--name` to label a session and `--no-session` to save nothing.

On a machine that keeps its home directory, `--session <label>` continues the
session with that label and starts it the first time, so a job that runs again
and again needs no "does it exist yet" branch. Give each thread its own label.

```bash
testeiya task "Review the new commits" --session "pr-42" --output gh:pr-comment
```

### One file for CI

A CI runner keeps nothing, and `~/.testeiya` is a whole directory to move.
`--session-file <path>` puts the session somewhere the job already caches:

```bash
testeiya task "Review the new commits" \
  --session-file .cache/testeiya/pr-42.jsonl --output gh:pr-comment
```

That one file is the entire thread — the conversation and the catch-up state
below. Restore it before the run, save it after, and the next round continues.
It is written on the first round, so a path that is not there yet is not an
error. `TESTEIYA_SESSION_FILE` sets the same thing from the environment.

Two things to get right. Keep the file out of the working tree, or ignore it
there, so the agent does not read its own transcript back as a file. And make
sure the cache is actually rewritten each round: a cache key that never changes
saves the first round and silently restores it forever.

A saved session records more than the conversation: the commit it ran on, the
branch, the origin, and the pull request it posted to. The next round compares
that against the checkout it wakes up in, and when they differ the agent is told
what it has not read — the commit range to diff, and on a pull request the
comments added since. So a second round reacts to new commits instead of
answering about code that has already moved.

```
Since your last round:

- The checkout moved from a881ad1 to 700fbe1 on main. Read `git log --oneline
  a881ad1..HEAD` and `git diff a881ad1...HEAD` before you answer.
- Pull request #42 may have collected comments since 2026-08-28T20:00:40Z. Read
  them with `gh pr view 42 --comments` and answer what is still open.
```

A round that broke records nothing, so the round after it still catches up from
where the work actually stopped. This rides inside the session, so restoring it
is all a round needs — but the checkout has to reach back far enough to see the
commit the last round stopped on. `--no-session` skips all of it.

### Answering a reply

`--followup` carries what the user said back to the agent. The task stays the
standing instruction and the reply is added under it as a new user message, so
one command serves the first round and every answer after it.

```bash
testeiya task "Review this pull request" --followup "what about the login flow?" \
  --session "pr-42" --output gh:pr-comment
```

`TESTEIYA_FOLLOW_UP` is the same thing from the environment, which is how a
comment body reaches a run without going through the shell. An empty value is
ignored, so the job runs unchanged when nobody replied.

## Testomat.io

Set `TESTOMATIO` to a project API key. The agent can then read and write that
project's tests, suites, runs and plans through `check-tests` and the REST API.

```bash
TESTOMATIO=tstmt_xxx testeiya task --project my-project "Which suites have no tests?"
```

Add the project id and the agent also gets the Testomat.io MCP tools. The id
comes from `--project` or from `TESTOMATIO_PROJECT_ID`; the MCP server needs it,
because a token alone does not say which project to talk to. `TESTOMATIO_URL`
points at a self-hosted instance.

## MCP servers

`TESTEIYA_MCP_SERVERS`, or `--mcp`, gives a run more MCP servers over HTTP. The
Testeiya Hub passes a company's connected services (Linear, Jira, …) this way.
The value is JSON that maps a server name to its url and headers:

```bash
TESTEIYA_MCP_SERVERS='{
  "linear": { "url": "https://mcp.linear.app/mcp", "headers": { "Authorization": "Bearer lin_xxx" } }
}' testeiya task "Write test cases for the issues in the current cycle"
```

- The tools are available in task runs and in every agent stage of a pipeline.
  They do not need a Testomat.io token.
- The model is told which servers are connected.
- Prefer the variable when a header holds a key. Anyone who lists the machine's
  processes can see a command-line option.
- Bad JSON prints a warning, and the run continues without the servers. An entry
  without a url is skipped. A server named `testomatio` becomes `testomatio-env`.
- A cloned repository cannot add a server of its own: `.pi/mcp.json` is never
  read, and `TESTEIYA_MCP_SERVERS` in a `.env` in the checkout is ignored with a
  warning. Set it in the job's environment or in `~/.testeiya/.env`.
- `testeiya doctor` lists the servers it found.

## Environment

The environment and `.env` files configure Testeiya. `.env` files are read from
`~/.testeiya/.env` and from the working directory upward. A variable you export
always overrides one from a file.

| Variable | What it does | Option |
|---|---|---|
| `TESTEIYA_MODEL` | model to run, e.g. `openrouter/anthropic/claude-sonnet-5` | `--model` |
| `TESTEIYA_FOLLOW_UP` | the user's reply; an empty value is ignored | `--followup` |
| `TESTEIYA_THREAD` | which conversation this is, for posted comments | `--thread` |
| `TESTEIYA_SESSION_FILE` | where to keep the session | `--session-file` |
| `TESTEIYA_NO_DEFAULT_FOOTER` | do not sign the report | `--no-default-footer` |
| `TESTEIYA_MCP_SERVERS` | extra [MCP servers](#mcp-servers) as JSON | `--mcp` |
| `TESTEIYA_MODELS_JSON` | path to a pi `models.json`, to point providers at a proxy | |
| `OPENROUTER_API_KEY`, `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, `GEMINI_API_KEY`, `CLOUDFLARE_API_KEY` | provider keys | |
| `TESTOMATIO` | Testomat.io project API key | |
| `TESTOMATIO_PROJECT_ID` | Testomat.io project id; turns on its MCP tools | `--project` |
| `TESTOMATIO_URL` | Testomat.io base url, for self-hosted | |
| `LANGFUSE_PUBLIC_KEY`, `LANGFUSE_SECRET_KEY` | turn on [tracing](#tracing) | |
| `LANGFUSE_BASE_URL` | Langfuse url, for self-hosted | |
| `BASE_BRANCH` | the branch a change is compared to when the CI job does not say; `origin/main` by default | |
| `GITHUB_TOKEN` | `install-app` only: raises GitHub's download rate limit | |
| `TESTEIYA_PIPELINE_SPAWN` | `1` runs each agent stage of a pipeline in its own process | |

`testeiya --help` prints the same list. Code can read it as
`ENVIRONMENT_VARIABLES` from `testeiya/pipeline`. Each entry has `name`,
`group`, `description`, `flag` and `secret`.

## Tracing

Set `LANGFUSE_PUBLIC_KEY` and `LANGFUSE_SECRET_KEY` and every run is sent to
[Langfuse](https://langfuse.com) as a trace. `LANGFUSE_BASE_URL` points at a
self-hosted instance; without it the trace goes to Langfuse Cloud.

```bash
LANGFUSE_PUBLIC_KEY=pk-lf-xxx LANGFUSE_SECRET_KEY=sk-lf-xxx \
  testeiya task "Review this pull request as a QA engineer"
```

One trace per run: the task at the root, a generation for every model call with
its tokens and cost, an observation for every tool call with its arguments and
result. Runs of the same session share a session id, so a task and its follow-up
read as one thread. `testeiya doctor` says whether tracing is on and which file
the keys came from.

Without both keys nothing is sent and nothing is installed for it — the trace is
plain OTLP JSON over `fetch`, so an install carries no OpenTelemetry SDK.

## Skills

A skill is a folder with a `SKILL.md`. The agent sees them all and reaches for
the ones a task calls for. Name one with a slash to make it certain:

```bash
testeiya task "Review this pull request as a QA engineer /qa-thinking"
```

That skill is loaded in front of the task before the run starts, so it does not
depend on the model deciding to open it. A name the package does not ship is
left as plain text, which keeps a task safe to build from someone else's words —
a `/word` in a pull request comment stays a word.

The set is vendored from upstream repositories and moves with every release, so
ask your own install rather than a list in a README:

```bash
testeiya skills             # every bundled skill: name and what it is for
testeiya skills playwright  # filter by name, category or description
testeiya skills --json      # [{name, group, description}]
```

Categories today: requirements, test management, test automation, QA process,
Explorbot. One per plugin of
[testomatio/skills](https://github.com/testomatio/skills).

The skills are not committed here. `node scripts/vendor-skills.js` clones
testomatio/skills and copies them into `skills/`. Every release runs it, so the
published `testeiya` package ships each skill as current on release day.

`skillsOverride` in `src/session.ts` keeps only what is found under that tree,
so an arbitrary clone cannot hand the model its own skills. To add yours, point
`additionalSkillPaths` at your folder. [EXTENDING.md](EXTENDING.md) covers both hooks.

To change a skill, send a pull request to [testomatio/skills](https://github.com/testomatio/skills).

## Building your own agent

The CLI is a thin composition over [pi](https://pi.dev): about 1,500 lines wiring
the SDK to the prompt and skills here. A fork can add pi extensions and custom
tools, or swap the one-shot run loop for pi's full interactive TUI.
[EXTENDING.md](EXTENDING.md) walks through both.

## Contributing

Prompt wording is exactly what an outside contributor can improve, and a change
to it changes how the agent behaves for everyone. Read
[CONTRIBUTING.md](CONTRIBUTING.md) first. It covers what belongs here and what
belongs upstream, in the repository that owns a given skill.

## Issues

This repository is also the public issue tracker for both surfaces:

- Testeiya Desktop app, the packaged desktop application
- Testeiya CLI, the command-line agent in `src/`

## Licence

[MIT](LICENSE).
