From d48aa4f0bce28159b6c5ee6bd0085a7f5a82e962 Mon Sep 17 00:00:00 2001 From: salmonik Date: Sun, 15 Nov 2026 15:43:07 +0100 Subject: 0.5.0: visible step counter, one client per turn, docs corrected Also fixes a 32-bit-only rlim_t mismatch found by building the target. --- docs/PLAN.md | 75 +++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 44 insertions(+), 31 deletions(-) (limited to 'docs/PLAN.md') diff --git a/docs/PLAN.md b/docs/PLAN.md index 9be54fa..f22b230 100644 --- a/docs/PLAN.md +++ b/docs/PLAN.md @@ -31,17 +31,23 @@ line-mode, six tools. Built for understanding, not parity with anything. unless `--yolo`. Prompts happen after the stream ends, never mid-token. - **Turn/step.** A turn ends when the model answers with no tool calls, on user abort, or on a non-retryable provider error. **No step cap** — the brake is the - step counter on the status line and Ctrl-C. + step number printed on every tool line, the allowance in the status line, and + Ctrl-C. - **Tool errors are data.** Failures, non-zero exits, and denials are returned to the model as results. Only transport/auth/process failures end a turn. - **Sessions.** Append-only JSONL of wire messages (see ADR 0002). No compaction, no truncation, no summarisation. Overflow is the provider's 400. -- **Prompt.** Snapshot at session start: fixed system prompt, a 3-line - environment block (cwd, platform, git branch), and `AGENTS.md` from cwd up to - the git root. Frozen for the session; mtime change prints a notice only. -- **UI.** Line-mode. ANSI only when stdout is a TTY. Plain `read_line` plus - `/paste` (reads until a lone `.` or EOF). No alt-screen, no raw mode, no - history, no markdown rendering, no syntax highlighting. +- **Prompt.** Snapshot at session start: fixed system prompt, one environment + line (cwd, platform, arch, git branch), and `AGENTS.md` from cwd up to the git + root — never above it, and only the working directory outside a repository. + Frozen for the session; the session records the starting directory and warns if + resumed elsewhere; an mtime change prints a notice only. +- **UI.** Line-mode. ANSI only when stdout is a TTY, and disabled by `NO_COLOR` + or `TERM=dumb`. A small raw-mode line editor: arrow-key history persisted to + disk, bracketed paste as one block, ctrl-a/e/u/k/w editing, ctrl-c abandons the + line, ctrl-d exits. Raw mode is on only while a prompt is being read, so Ctrl-C + during a turn stays a signal. No alt-screen, no markdown rendering, no syntax + highlighting. - **Ctrl-C.** SIGINT handler sets a flag; the stream loop closes the socket and ends the turn. Second Ctrl-C exits. - **No model metadata.** No cost display, no pre-flight context check. Token @@ -163,30 +169,37 @@ Independently rebuilt and re-run outside the agent both times. ## Layout ``` -src/main.rs args, mode selection, exit codes -src/config.rs TOML-free config if possible; env precedence CLI > env > file -src/provider.rs request construction, ureq call, SSE parsing -src/session.rs id, JSONL append/load, replay -src/agent.rs turn/step loop, tool dispatch, approval hooks +src/main.rs args, mode selection, exit codes, /paste +src/config.rs precedence CLI > env > file; key source +src/provider.rs request construction, retry, SSE parsing, model list +src/session.rs id, JSONL append/load/replay, listing, permissions +src/agent.rs turn/step loop, tool dispatch, approval hooks, prompt +src/line.rs raw-mode line editor, history +src/signal.rs SIGINT -> cancel flag +src/doctor.rs --doctor checks src/tools/ read, write, edit, bash, grep, glob -src/ui.rs streaming render, diffs, approval prompt, status line, /paste -tests/mock.rs mock provider over std TcpListener -scripts/check-glibc.sh +src/ui.rs streaming render, diffs, approval prompt, status line +tests/mock.rs provider over std TcpListener (SSE, retry, truncation) +tests/loop.rs agent loop, abort and repair invariants +tests/tools.rs tool semantics and edge cases +tests/sessions.rs session round-trip, listing, permissions +tests/cli.rs argument validation and exit codes +tests/doctor.rs --doctor against a mock provider +tests/sse.rs decoder at every byte boundary +tests/prompt.rs instruction scope +scripts/check-glibc.sh, scripts/mock-provider.py ``` -Input is kept behind a single `read_input() -> Option` function so a -raw-mode editor with history can replace it later without touching the loop. - -## Open questions to settle against the live API - -Blocked on a fresh `OPENCODE_API_KEY` (the stored one returns `api_key_expired`). - -1. Is `stream_options: {"include_usage": true}` honoured, and does usage arrive in - the final chunk? -2. Exact shape and location of `opencode.allowance`; which unit it is in. -3. Is `reasoning_content` the delta field name across all reasoning models, or - only DeepSeek-derived ones? -4. Does the gateway accept `reasoning_effort`, or is reasoning configured - elsewhere? -5. Error body shape for context overflow, to map it to "start a new session". -6. Whether `x-opencode-session` has format constraints (opaque vs UUID). +## Settled against the live API + +1. `stream_options: {"include_usage": true}` is honoured; usage arrives in the + chunk that carries `finish_reason`. ✅ +2. Accounting is nested: `usage.opencode.allowance` and `.list_cost`. ✅ +3. `reasoning_content` is the delta field. ✅ +4. `x-opencode-session` is mandatory: without it the gateway answers 400 + `MissingSessionID`. Any opaque stable id works. ✅ +5. Two consecutive user messages are accepted, so a turn that failed after + writing its prompt can be resumed without editing the transcript. ✅ +6. The default model accepted a 500k-token prompt, so overflow is rarer than + assumed. The exact limit is unknown and deliberately not modelled. ✅ +7. `reasoning_effort`: not sent; unverified. -- cgit v1.2.3