Skip to content
Source
Sign inSign up
TanStack/ai
Open History to see the last commit

README.md

29 lines1.3 KB

1# Harness CLI example
2​
3A notes assistant in your terminal, built with `@tanstack/ai-harness` and `@tanstack/ai-harness-cli`. Ask it to write a note. It asks you before it saves the file.
4​
5## Run it
6​
7From the repo root:
8​
91. `pnpm install`
102. `pnpm build:all` (the example uses the local packages)
113. `OPENAI_API_KEY=sk-... pnpm --filter harness-cli-example start`
12​
13Type `Save a note about the moon landing`. The screen shows the `save_note` call. Press `y`, and the note is in `examples/harness-cli/notes/`.
14​
15## What is in it
16​
17- `src/harness.ts`: the harness. One model, a `list_notes` tool, and a `save_note` tool that needs approval.
18- `src/cli.ts`: `runCli(assistant, { ui: runTui })`. That is the whole entry file.
19- `src/tui.tsx`: an Ink screen on the session view. It shows the messages, tool calls, child agents, sign-ins, approvals (`y` or `n`), and questions.
20​
21## Other modes
22​
23The same entry file has every mode of `runCli`. Run these from `examples/harness-cli`:
24​
25- `pnpm start -p "List my notes"` runs one prompt and prints the answer.
26- `echo "List my notes" | pnpm start` uses line mode.
27- `pnpm start --serve` serves the session protocol over HTTP with a bearer token.
28​
29Read [Run a harness in the terminal](../../docs/harness/cli.md) and [Build your own UI](../../docs/harness/custom-ui.md).