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/KNOWN-ISSUES.md | 68 +++++++++++++++++++++++++++++++++++++++++++++++ docs/PLAN.md | 75 ++++++++++++++++++++++++++++++---------------------- 2 files changed, 112 insertions(+), 31 deletions(-) create mode 100644 docs/KNOWN-ISSUES.md (limited to 'docs') diff --git a/docs/KNOWN-ISSUES.md b/docs/KNOWN-ISSUES.md new file mode 100644 index 0000000..44d9f07 --- /dev/null +++ b/docs/KNOWN-ISSUES.md @@ -0,0 +1,68 @@ +# Known issues + +Understood, deliberately not fixed. Each one has a reason, and a note on what +would change the decision. + +## Concurrent sessions can interleave + +Two processes appending to the same session file will interleave messages and +corrupt the conversation, permanently, because history is never rewritten. +`flock(LOCK_EX | LOCK_NB)` on the session fd at open would refuse the second +process. Not done yet because the failure needs deliberately resuming the same +id in two shells, and the fix is easy to add later. If it ever happens once, +add the lock. + +## `--yolo` has no floor + +`--yolo` approves everything, including in `$HOME` or `/`. There is no check +that the directory is a git repository, so the documented undo does not exist in +some of the places it will run. Refusing `--yolo` outside a repository (or in +`$HOME`) would be a small change; it is deferred because the acceptance test runs +in an empty temp directory. + +## `--list` reads every transcript + +Listing costs O(total bytes of all sessions), because it parses each header and +counts messages. At current sizes this is milliseconds; a 200 MB session file +makes it visibly slow. An index or a `--json` format would fix it. + +## `edit` loads the whole file + +`edit` reads the file, matches, and writes it back through a temporary file. On +the 32-bit target a file near the address-space limit fails with an out-of-memory +error rather than a clean refusal. A >32 MB file should be rejected up front with +"too large for edit; use write". + +## Editor width is approximate + +The line editor counts one column per character, so wide (CJK) characters, +combining marks and raw tabs (from a paste) mis-place the caret. The width is +read once per prompt, so a resize mid-edit mis-renders. + +## No transcript viewer + +Reasoning is stored beside each assistant message for humans, but the only way to +read it is `cat` on the JSONL. A `--show ` renderer would make auditing a +`--yolo` run practical. + +## Approval state is per process + +Restarting the harness re-prompts for the first edit even when resuming a +session. That is intentional (see CONTEXT.md), but it is worth knowing. + +## `--doctor` fails on an unlisted model + +If `GET /models` does not list the model id you use (some gateways only list a +subset), doctor exits 1 even though a turn would work. `--doctor --probe` sending +a one-token completion would test what actually matters. + +## Retry budget is fixed + +Four attempts, 1 s / 2 s / 4 s, no jitter, no per-status policy. A 429 for a +model with a long reset window will still fail after ~7 s. + +## No per-turn summary + +The status line reports steps, time, tokens and allowance, but not what changed: +no "3 files written, 5 commands run, 1 denied". For a `--yolo` run that is the +summary you actually want. 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