Skip to content
Source
Sign inSign up
TanStack/ai

feat(ai-harness-cli)!: no UI library; runCli({ ui }) runs any TUI on a session view #1549

ClosedAlemTuzlakwants to merge 6 commits intofeat/harness-p11-session-view fromfeat/harness-p12-cliopened View on GitHub

AlemTuzlakcommented

To show your own screen in a terminal, pass runCli(harness, { ui }). It works with any TUI library. @tanstack/ai-harness-cli has no UI library now: it does not depend on ink, react, or @types/react. Without ui, a terminal uses line mode, the same as piped input.

Stacked on #1546 (Phase 11) → #1540 → #1538 → #1524 → #1523 → #1522 → #1521 → #1520 → #1519 → #1518 → #1515 → #1513 → #1509. Merge those first.

🎯 Changes

  • runCli(harness, { ui }), with ui: (view: SessionView) => Promise<void> | void. In an interactive terminal, runCli makes createSessionView(session) and waits for view.ready. Then it runs ui(view), waits for it, and disposes the view. Piped input uses line mode, even with ui.
  • No built-in Ink screen. src/interactive.tsx is deleted. Without ui, a terminal uses line mode.
  • Line mode prints from the session view. The new src/printer.ts prints streamed text, and one bracketed line for each tool call, child agent, notice, question, and sign-in. In a terminal, line mode also opens sign-in links in the browser. The old event fold (applyEvent, applyChildEvent, ViewEntry) is deleted. It was internal.
  • An Ink screen in the example. examples/harness-cli/src/tui.tsx is built on the view. It shows the transcript, tool calls, child agents, approvals (y / n), questions, sign-ins (links open in the browser), the goal line from selectGoal, and the status. It has /help, /connect, /disconnect, and /exit. Esc cancels and Enter steers. src/cli.ts gives it to runCli as ui.
  • Dependencies. The example lists ink, react, @tanstack/react-store, and @types/react itself. ts-react-chat moves @tanstack/react-store from ^0.8.0 to ^0.11.1, so sherif sees one version, and ts-solid-chat moves @tanstack/solid-store from ^0.8.0 to ^0.11.1. Nothing in their src imports them. Every direct TanStack Store dependency in the workspace is now on the latest release (0.11.1).

Also in this PR:

  • Docs: docs/harness/cli.md (line mode in a terminal, a new "Run your own screen" section, links to the example and to custom-ui), one line in custom-ui.md, the CLI package README, the USAGE text, and the message in print.ts.
  • Changeset: @tanstack/ai-harness-cli minor. The ! in the title marks the removed Ink screen. The stack is not released yet.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested code changes locally with pnpm run test:pr, or these tests do not apply to this pull request.
  • I fully understand the code in this pull request, including any code generated with AI assistance.
  • Docs: I updated docs/ for this change, or this change is not user-facing.
  • Changeset: I added a changeset (pnpm changeset), or this PR does not change a published package.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Testing

Commands run (not the full pnpm test:pr, see below):

  • ai-harness-cli: vitest run (5 files, 22 tests pass), test:types, test:oxlint (0 errors, 0 warnings), build, and test:build (publint: all good).
  • ai-harness, after the Phase 11 merge: build, and vitest run (30 files, 259 tests pass).
  • Root: install --frozen-lockfile --offline (up to date), test:sherif (0 errors), test:knip (pass, config hints only), test:docs (no broken links), and kiira check docs/harness/cli.md docs/harness/custom-ui.md (3 snippets pass, 6 ignored). The one sherif warning is old: examples/react has no package.json.
  • Examples: tsc --noEmit in examples/harness-cli, and test:types in examples/ts-react-chat and examples/ts-solid-chat pass.
  • I skipped the full pnpm test:pr because it is slow on this machine. CI runs it. No new E2E test: this is terminal behavior of the CLI, and no browser app uses it.

Manual test

No real terminal run was done. A scratch script drove runCli with ui: runTui by fake keystrokes, with the demo model. hi got the demo answer, /help listed the commands, /todos printed its result, and /exit quit with code 0. Piped input still used line mode. To do the real terminal run:

  1. Run pnpm install, then pnpm build:all.
  2. In a real terminal, run pnpm --filter harness-cli-example start. Without an API key, a demo model answers. Expect the Ink screen from src/tui.tsx.
  3. Type hi, then /help, then /todos. Expect the demo answer, the command list, and the todo list. Type /exit. Expect the process to stop with code 0.
  4. Run echo /agents | pnpm --filter harness-cli-example start. Expect plain lines from line mode, not the Ink screen.
  5. To see line mode in a terminal, remove ui: runTui from examples/harness-cli/src/cli.ts, then do step 2 again. Expect plain lines.

How this PR makes testing easy

  • tests/cli.test.ts, custom ui (3 tests): a terminal gets a ready view and runCli waits for ui. Piped input uses line mode, even with ui. A terminal without ui uses line mode.
  • tests/printer.test.ts (3 tests): streamed text, each item printed one time, and line breaks between turns. Long child answers are cut, failed children are reported, and each kind of sign-in prints. mark() hides the history.
  • The old line mode tests pass with no change. cli.test.ts and child-view.test.ts passed 10 runs in a row.
  • The example app: pnpm --filter harness-cli-example start shows the new Ink screen.

Risk / rollback

Low. The stack is not released yet, so no published CLI loses the Ink screen. Two things can change for code on this stack:

  • A CLI that calls runCli(harness) in a terminal now gets line mode, not the Ink screen. To keep a full screen, pass ui. examples/harness-cli/src/tui.tsx is a start.
  • Line mode now reads from the session view, not from session.events(). If a line prints two times or not at all, the cause is in src/printer.ts.

Revert the PR to undo.

Public API change

Before

// In a terminal, this showed the built-in Ink screen.
process.exitCode = await runCli(harness)

After

// In a terminal, this uses line mode.
process.exitCode = await runCli(harness)

// Your own screen, with any TUI library.
process.exitCode = await runCli(harness, {
  ui: async (view) => {
    await render(<Screen view={view} />).waitUntilExit()
  },
})

🤖 Generated with Claude Code

https://claude.ai/code/session_01APYv1qshKyjPPpkFyRZhfZ

    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Important

      Review skipped

      Auto reviews are disabled on base/target branches other than the default branch.

      Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository: TanStack/ai/.coderabbit.yaml

      Review profile: CHILL

      Plan: Advanced

      Run ID: 6811fe6d-28f4-4766-a2da-37fc8d89539a

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review

      Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

      ❤️ Share
      Comment `@coderabbitai help` to get the list of available commands.
    2. nx-cloud[bot](GitHub profile, opens in a new tab)commented

      View your CI Pipeline Execution ↗ for commit 7790e06647e575412419dc7af5349f980e3a9e18

      CommandStatusDurationResult
      nx run-many --targets=build --exclude=examples/...✅ Succeeded2m 23sView ↗

      ☁️ Nx Cloud last updated this comment at 2026-09-28 15:10:09 UTC

    3. pkg-pr-new[bot](GitHub profile, opens in a new tab)commented

      Open in StackBlitz

      @tanstack/ai

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai@1549

      @tanstack/ai-acp

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-acp@1549

      @tanstack/ai-angular

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-angular@1549

      @tanstack/ai-anthropic

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-anthropic@1549

      @tanstack/ai-bedrock

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-bedrock@1549

      @tanstack/ai-byteplus

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-byteplus@1549

      @tanstack/ai-claude-code

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-claude-code@1549

      @tanstack/ai-client

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-client@1549

      @tanstack/ai-cloudflare

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-cloudflare@1549

      @tanstack/ai-code-mode

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-code-mode@1549

      @tanstack/ai-code-mode-snippets

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-code-mode-snippets@1549

      @tanstack/ai-codex

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-codex@1549

      @tanstack/ai-cohere

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-cohere@1549

      @tanstack/ai-compaction

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-compaction@1549

      @tanstack/ai-dashboard

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-dashboard@1549

      @tanstack/ai-devtools-core

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-devtools-core@1549

      @tanstack/ai-durable-stream

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-durable-stream@1549

      @tanstack/ai-elevenlabs

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-elevenlabs@1549

      @tanstack/ai-event-client

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-event-client@1549

      @tanstack/ai-fal

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-fal@1549

      @tanstack/ai-gemini

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-gemini@1549

      @tanstack/ai-grok

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-grok@1549

      @tanstack/ai-grok-build

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-grok-build@1549

      @tanstack/ai-groq

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-groq@1549

      @tanstack/ai-harness

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-harness@1549

      @tanstack/ai-harness-cli

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-harness-cli@1549

      @tanstack/ai-isolate-cloudflare

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-isolate-cloudflare@1549

      @tanstack/ai-isolate-daytona

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-isolate-daytona@1549

      @tanstack/ai-isolate-node

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-isolate-node@1549

      @tanstack/ai-isolate-quickjs

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-isolate-quickjs@1549

      @tanstack/ai-isolate-quickjs-bun

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-isolate-quickjs-bun@1549

      @tanstack/ai-llmgateway

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-llmgateway@1549

      @tanstack/ai-lovable

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-lovable@1549

      @tanstack/ai-mcp

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-mcp@1549

      @tanstack/ai-memory

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-memory@1549

      @tanstack/ai-mistral

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-mistral@1549

      @tanstack/ai-octane

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-octane@1549

      @tanstack/ai-ollama

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-ollama@1549

      @tanstack/ai-openai

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-openai@1549

      @tanstack/ai-opencode

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-opencode@1549

      @tanstack/ai-openrouter

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-openrouter@1549

      @tanstack/ai-perplexity

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-perplexity@1549

      @tanstack/ai-persistence

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-persistence@1549

      @tanstack/ai-preact

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-preact@1549

      @tanstack/ai-react

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-react@1549

      @tanstack/ai-react-ui

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-react-ui@1549

      @tanstack/ai-reactor

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-reactor@1549

      @tanstack/ai-remix

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-remix@1549

      @tanstack/ai-sandbox

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox@1549

      @tanstack/ai-sandbox-blaxel

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-blaxel@1549

      @tanstack/ai-sandbox-boxd

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-boxd@1549

      @tanstack/ai-sandbox-cloudflare

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-cloudflare@1549

      @tanstack/ai-sandbox-daytona

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-daytona@1549

      @tanstack/ai-sandbox-docker

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-docker@1549

      @tanstack/ai-sandbox-e2b

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-e2b@1549

      @tanstack/ai-sandbox-local-process

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-local-process@1549

      @tanstack/ai-sandbox-sprites

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-sprites@1549

      @tanstack/ai-sandbox-upstash-box

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-upstash-box@1549

      @tanstack/ai-sandbox-vercel

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-vercel@1549

      @tanstack/ai-skills

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-skills@1549

      @tanstack/ai-solid

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-solid@1549

      @tanstack/ai-solid-ui

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-solid-ui@1549

      @tanstack/ai-svelte

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-svelte@1549

      @tanstack/ai-typesafe

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-typesafe@1549

      @tanstack/ai-utils

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-utils@1549

      @tanstack/ai-vercel-gateway

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-vercel-gateway@1549

      @tanstack/ai-vertex

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-vertex@1549

      @tanstack/ai-vue

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-vue@1549

      @tanstack/ai-vue-ui

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-vue-ui@1549

      @tanstack/ai-worldlabs

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-worldlabs@1549

      @tanstack/openai-base

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/openai-base@1549

      @tanstack/preact-ai-devtools

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/preact-ai-devtools@1549

      @tanstack/react-ai-devtools

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/react-ai-devtools@1549

      @tanstack/solid-ai-devtools

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/solid-ai-devtools@1549

      @tanstack/svelte-ai-devtools

      npm i https://pkg.pr.new/TanStack/ai/@tanstack/svelte-ai-devtools@1549

      commit: 7790e06

    4. socket-security[bot](GitHub profile, opens in a new tab)commented

      Review the following changes in direct dependencies. Learn more about Socket for GitHub.

      Diff Package Supply Chain
      Security
      Vulnerability Quality Maintenance License
      Addednpm/​@​tanstack/​solid-store@​0.11.1981006993100

      View full report

    5. github-actions[bot](GitHub profile, opens in a new tab) added labelswaiting-on: maintainer

    6. AlemTuzlakcommented

      Closed in favor of the combined PR #1555, which holds this phase and every other phase of the harness (P0 to P14) on one branch against main. All further fixes go there. This PR stays as the review record of P12.

    7. AlemTuzlak closed this

Sign in to join this conversation.