From 45d0d3c5f431688aa9dfbd6a4214256d6fe64122 Mon Sep 17 00:00:00 2001 From: salmonik Date: Wed, 18 Nov 2026 12:34:33 +0100 Subject: 0.9.2: doc accuracy and UX fixes from the review - missing key exits 1, consistent with --doctor - HTML error bodies get a one-line message - no unapprovable diff printed on a non-terminal - weak GLIBC_2.39 fix covers x86_64 gnu as well as i686 - README/PLAN/CHANGELOG brought in line with the actual binary --- .cargo/config.toml | 9 ++++++++- CHANGELOG.md | 22 ++++++++++++++++++++++ Cargo.lock | 2 +- Cargo.toml | 4 ++-- README.md | 16 ++++++++++------ comp.sh | 21 ++++++++++++++------- docs/PLAN.md | 12 ++++++++---- scripts/mock-provider.py | 3 +++ src/main.rs | 3 ++- src/provider.rs | 4 ++++ src/ui.rs | 4 ++++ tests/cli.rs | 2 +- 12 files changed, 79 insertions(+), 23 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 17369d2..cb59564 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -2,12 +2,19 @@ # On an older glibc the dynamic linker resolves them to NULL (std falls back to # posix_spawn), but it also prints a warning on every start: # -# /lib/i386-linux-gnu/libc.so.6: weak version `GLIBC_2.39' not found +# /lib/.../libc.so.6: weak version `GLIBC_2.39' not found # # Defining them locally as absolute 0 removes the version need while keeping the # same runtime behaviour: the check sees NULL and takes the fallback path. + [target.i686-unknown-linux-gnu] rustflags = [ "-C", "link-arg=-Wl,--defsym,pidfd_spawnp=0", "-C", "link-arg=-Wl,--defsym,pidfd_getpid=0", ] + +[target.x86_64-unknown-linux-gnu] +rustflags = [ + "-C", "link-arg=-Wl,--defsym,pidfd_spawnp=0", + "-C", "link-arg=-Wl,--defsym,pidfd_getpid=0", +] diff --git a/CHANGELOG.md b/CHANGELOG.md index d9e3d09..f7bc83f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,26 @@ break the interface, **PATCH** for bug fixes. file, and the tool schemas the model sees. Anything a script or a resumed session could depend on counts as API. +## 0.9.2 + +### Fixed +- A missing API key now exits 1 (an operational error), matching `--doctor`, + rather than 2 (usage). +- `--doctor` reports a one-line message for a non-JSON (HTML) error body instead + of dumping it. +- A non-terminal no longer prints a diff nobody can approve before denying an + edit. +- The weak `GLIBC_2.39` warning fix now covers x86_64 gnu too, not just i686, so + the README's primary build is clean on Debian 12. + +### Changed (docs) +- Corrected approval scope in PLAN (process, not session). +- README: test count, i686 note, glibc-floor wording, built-path note, and the + now-documented `AGENT686_DEBUG_STREAM`, `TERM=dumb` and `--resume`. +- PLAN dependency list and layout tree updated; 120 s timeout marked adjustable. +- CHANGELOG notes the skipped 0.8.1; the package description no longer says + "32-bit". + ## 0.9.1 ### Fixed @@ -62,6 +82,8 @@ message covering four different failures. ## 0.8.2 +> 0.8.1 was not released (its change was folded straight into 0.8.2). + ### Changed - `comp.sh` now targets the CPU it runs on by default (`-C target-cpu=native`), which is what "build for this machine" should mean. `--portable` builds the diff --git a/Cargo.lock b/Cargo.lock index c14c2fb..ba44750 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10,7 +10,7 @@ checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" [[package]] name = "agent686" -version = "0.9.0" +version = "0.9.1" dependencies = [ "crossterm", "libc", diff --git a/Cargo.toml b/Cargo.toml index 4b617ae..c24fb94 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "agent686" -version = "0.9.1" +version = "0.9.2" edition = "2021" -description = "A small coding agent for a 32-bit Debian box" +description = "A small coding agent for Debian-class Linux" publish = false [dependencies] diff --git a/README.md b/README.md index e6b83aa..cec5fbd 100644 --- a/README.md +++ b/README.md @@ -29,9 +29,13 @@ binary runs here; `--portable` targets the architecture floor instead. If the binary is for another machine, use `--portable` or run `comp.sh` on that machine — a native build fails with an illegal instruction on older chips. -A glibc build also inherits this machine's glibc floor, which is why the portable -paths are printed next to it: static musl removes the floor entirely, and building -inside an older Debian image lowers it. +A glibc build is bounded by the glibc symbols it references, not by this +machine's glibc version: `check-glibc.sh` reports the real floor (e.g. +`GLIBC_2.34`). Static musl removes the floor entirely, and building inside an +older Debian image lowers it. + +The commands above produce `target//release/agent686`; replace +`./agent686` below with that path. The gate matters: the dev host's glibc is newer than the target's, so a dependency can silently raise the required symbol version. @@ -77,10 +81,10 @@ that is where `rm -rf` lives. `--yolo` skips both, and is refused in `$HOME` and ## Tests ```sh -cargo test # 75 tests, no network +cargo test # 92 tests, no network python3 scripts/mock-provider.py & # canned SSE provider -docker run --rm --platform linux/386 \ - -v "$PWD/target/i686-unknown-linux-gnu/release:/b:ro" debian:12 /b/agent686 --version +# i686 still builds (comp.sh on a 32-bit host picks it up): +cargo build --release --target i686-unknown-linux-gnu ``` `tests/sse.rs` feeds the stream one byte at a time, so splits inside lines and diff --git a/comp.sh b/comp.sh index 8539c2d..af11720 100755 --- a/comp.sh +++ b/comp.sh @@ -157,12 +157,15 @@ build_flags() { esac } -# i686-gnu needs linker flags from .cargo/config.toml. RUSTFLAGS on the command -# line would shadow them, so repeat them. +# gnu targets need linker flags from .cargo/config.toml (a weak GLIBC_2.39 +# reference would warn on older glibc). RUSTFLAGS on the command line would +# shadow them, so repeat them here. defsym_flag= -if [ "$triple_gnu" = i686-unknown-linux-gnu ]; then - defsym_flag="-C link-arg=-Wl,--defsym,pidfd_spawnp=0 -C link-arg=-Wl,--defsym,pidfd_getpid=0" -fi +case "$triple_gnu" in + *-unknown-linux-gnu) + defsym_flag="-C link-arg=-Wl,--defsym,pidfd_spawnp=0 -C link-arg=-Wl,--defsym,pidfd_getpid=0" + ;; +esac # ---------------------------------------------------------------- report @@ -217,7 +220,9 @@ if [ "$plan" = native ] || [ "$plan" = musl ]; then [ "$plan" = musl ] && triple=$triple_musl flags=$(build_flags) - [ "$triple" = i686-unknown-linux-gnu ] && flags="$flags $defsym_flag" + case "$triple" in + *-unknown-linux-gnu) flags="$flags $defsym_flag" ;; + esac if [ "$cpu" = native ]; then say " # for this CPU${cpu_level:+ (x86-64-$cpu_level)}" @@ -289,7 +294,9 @@ if [ "$run" -eq 1 ]; then triple=$native_triple [ "$plan" = musl ] && triple=$triple_musl flags=$(build_flags) - [ "$triple" = i686-unknown-linux-gnu ] && flags="$flags $defsym_flag" + case "$triple" in + *-unknown-linux-gnu) flags="$flags $defsym_flag" ;; + esac section "building" rustup target add "$triple" >/dev/null 2>&1 || true diff --git a/docs/PLAN.md b/docs/PLAN.md index f22b230..559c6ab 100644 --- a/docs/PLAN.md +++ b/docs/PLAN.md @@ -7,8 +7,8 @@ line-mode, six tools. Built for understanding, not parity with anything. | | | |---|---| -| Target | Debian 12 i386, glibc 2.36, 2 cores, 4 GB | -| Build | `i686-unknown-linux-gnu`, dynamic glibc (see ADR 0001) | +| Target | Debian-class Linux; x86-64 primary, i686 still supported | +| Build | `./comp.sh` — detects the machine and prints the build plan | | Dev host | x86-64, `gcc-multilib`, `i686` + `i686-unknown-linux-musl` targets | | Provider | OpenCode Go — `https://opencode.ai/inference/go/openai/v1`, `chat/completions` | | Auth | `OPENCODE_API_KEY`, else `~/.config/agent686/key` (600 perms) | @@ -27,7 +27,7 @@ line-mode, six tools. Built for understanding, not parity with anything. timeout, capped output, exit code), `grep`, `glob`. All native — no dependence on `rg` being installed. - **Approval.** Reads free. First `write`/`edit` of a session prompts with a - unified diff and offers "always" (session-scoped). Every `bash` call prompts + unified diff and offers "always" (process-scoped: a new process asks again on resume). Every `bash` call prompts 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 @@ -169,6 +169,7 @@ Independently rebuilt and re-run outside the agent both times. ## Layout ``` +src/lib.rs module root 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 @@ -177,8 +178,11 @@ 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/tools/mod.rs schemas, validation, dispatch +src/tools/fs.rs read, write, edit, grep, glob +src/tools/shell.rs bash, timeouts, output caps src/ui.rs streaming render, diffs, approval prompt, status line +scripts/ux-check.sh drives tmux to assert the rendered screen 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 diff --git a/scripts/mock-provider.py b/scripts/mock-provider.py index aa4731e..d1ae271 100755 --- a/scripts/mock-provider.py +++ b/scripts/mock-provider.py @@ -5,6 +5,9 @@ No API key, no network, no quota. Streams a reasoning delta, a text answer and a usage frame, with a small pause between them so the renderer can be seen working incrementally. +Serves only POST /chat/completions; it does not serve GET /models, so +`--doctor` cannot be exercised against it (it returns an HTML 501). + scripts/mock-provider.py --port 8765 OPENCODE_API_KEY=test ./agent686 --base-url http://127.0.0.1:8765/v1 "hi" """ diff --git a/src/main.rs b/src/main.rs index 0e5d49a..b17359b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -29,6 +29,7 @@ OPTIONS: -m, --model model id (default: deepseek-v4.1-flash) --base-url provider base URL --session resume a session, creating it if the id is new + (alias: --resume) -c, --continue resume the most recent session --list list sessions and exit --show [ID] print a transcript (most recent if no ID) and exit @@ -220,7 +221,7 @@ fn run(args: Args) { Ok(cfg) => cfg, Err(message) => { eprintln!("agent686: {message}"); - std::process::exit(2); + std::process::exit(1); } }; diff --git a/src/provider.rs b/src/provider.rs index 0973e8c..b08d1f2 100644 --- a/src/provider.rs +++ b/src/provider.rs @@ -484,6 +484,10 @@ fn accumulate_tool_call( } fn error_message(body: &str) -> String { + let trimmed = body.trim_start(); + if trimmed.starts_with('<') { + return "the provider returned an HTML error page rather than JSON".to_string(); + } if let Ok(v) = serde_json::from_str::(body) { if let Some(err) = v.get("error") { if let Some(message) = err.get("message").and_then(|m| m.as_str()) { diff --git a/src/ui.rs b/src/ui.rs index fe0264b..1d59ac4 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -269,6 +269,10 @@ impl Approver { if self.yolo || self.edits_allowed { return true; } + // No point showing a diff that no one is present to approve. + if !self.interactive { + return false; + } println!("{preview}"); // The path is already on the tool line above. let _ = path; diff --git a/tests/cli.rs b/tests/cli.rs index 5a4c03f..80eb96d 100644 --- a/tests/cli.rs +++ b/tests/cli.rs @@ -34,7 +34,7 @@ fn double_dash_makes_everything_a_prompt() { .output() .unwrap(); - assert_eq!(output.status.code(), Some(2)); + assert_eq!(output.status.code(), Some(1)); let stderr = String::from_utf8_lossy(&output.stderr); assert!(stderr.contains("no API key"), "{stderr}"); assert!(!String::from_utf8_lossy(&output.stdout).contains("agent686 0")); -- cgit v1.2.3