# CLI-074 Tasks — Deterministic E2E harness (scripted provider + PTY TUI driver)

Spec: `.agents/spec-docs/active/CLI-074-deterministic-e2e-harness.md`

- [x] T1 (TC-01): agent-transport — `createScriptedProvider(turns)` in `src/testing/` (dev-only `./testing` subpath): replays text/tool_use turns in order, records request message arrays, throws on exhaustion; unit tests
- [x] T2 (TC-02): agent-cli — tool-loop E2E: scripted Read→Edit→Bash turns through `startCli` print mode on a temp repo; file mutation + final response + exit 0 asserted
- [x] T3 (TC-03): agent-cli — permission E2E: `--dry-run` leaves the file untouched; `--denied-tools Edit` surfaces the denial in the tool result
- [x] T4 (TC-04): agent-cli — resume E2E: turn 1 then `-c` turn 2; second-run request contains turn-1 messages; exactly one session file
- [x] T5 (TC-05): agent-cli — output-contract E2E: text/json/stream-json/--bare envelope shapes + exit codes
- [x] T6 (TC-06): agent-cli — slash-command smoke: every registry-listed command executes through print mode returning a result envelope
- [x] T7 (TC-07): agent-transport — PTY driver helper (`spawnTui`/`sendKeys`/`waitFor`/`snapshot`/`expectExit`, node-pty devDependency, dedicated vitest project): boot renders prompt, `/` opens autocomplete, `/help` executes (not paste-bundled) at ≥30ms/key
- [x] T8 (TC-08): agent-transport — PTY `/exit` reaches process exit within 10s (CLI-071 confirmed or reproduced + recorded)
- [x] T9 (TC-09): SPEC sync — transport + cli SPEC test-strategy sections (testing subpath dev-only, PTY isolation)
- [x] T10: build/typecheck/lint/test green; PR to develop; backlog/L2 evidence recording

## Test Plan

Authoritative TC table lives in the spec document (`.agents/spec-docs/active/CLI-074-deterministic-e2e-harness.md` § Test Plan).
Summary: TC-01 unit-tests the scripted provider itself; TC-02..06 are vitest integration suites driving `startCli` print mode with the scripted provider (temp cwd + isolated HOME + provider-env-key neutralization, the `cli-exit-codes.test.ts` harness pattern); TC-07/08 run in a dedicated vitest project using node-pty against the built CLI binary with generous timeouts. Verification: `pnpm --filter @robota-sdk/agent-transport --filter @robota-sdk/agent-cli test` plus the PTY project, workspace typecheck/lint.
