diff options
Diffstat (limited to '')
| -rw-r--r-- | .cargo/config.toml | 9 | ||||
| -rw-r--r-- | CHANGELOG.md | 22 | ||||
| -rw-r--r-- | Cargo.lock | 2 | ||||
| -rw-r--r-- | Cargo.toml | 4 | ||||
| -rw-r--r-- | README.md | 16 | ||||
| -rwxr-xr-x | comp.sh | 21 | ||||
| -rw-r--r-- | docs/PLAN.md | 12 | ||||
| -rwxr-xr-x | scripts/mock-provider.py | 3 | ||||
| -rw-r--r-- | src/main.rs | 3 | ||||
| -rw-r--r-- | src/provider.rs | 4 | ||||
| -rw-r--r-- | src/ui.rs | 4 | ||||
| -rw-r--r-- | 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 @@ | |||
| 2 | # On an older glibc the dynamic linker resolves them to NULL (std falls back to | 2 | # On an older glibc the dynamic linker resolves them to NULL (std falls back to |
| 3 | # posix_spawn), but it also prints a warning on every start: | 3 | # posix_spawn), but it also prints a warning on every start: |
| 4 | # | 4 | # |
| 5 | # /lib/i386-linux-gnu/libc.so.6: weak version `GLIBC_2.39' not found | 5 | # /lib/.../libc.so.6: weak version `GLIBC_2.39' not found |
| 6 | # | 6 | # |
| 7 | # Defining them locally as absolute 0 removes the version need while keeping the | 7 | # Defining them locally as absolute 0 removes the version need while keeping the |
| 8 | # same runtime behaviour: the check sees NULL and takes the fallback path. | 8 | # same runtime behaviour: the check sees NULL and takes the fallback path. |
| 9 | |||
| 9 | [target.i686-unknown-linux-gnu] | 10 | [target.i686-unknown-linux-gnu] |
| 10 | rustflags = [ | 11 | rustflags = [ |
| 11 | "-C", "link-arg=-Wl,--defsym,pidfd_spawnp=0", | 12 | "-C", "link-arg=-Wl,--defsym,pidfd_spawnp=0", |
| 12 | "-C", "link-arg=-Wl,--defsym,pidfd_getpid=0", | 13 | "-C", "link-arg=-Wl,--defsym,pidfd_getpid=0", |
| 13 | ] | 14 | ] |
| 15 | |||
| 16 | [target.x86_64-unknown-linux-gnu] | ||
| 17 | rustflags = [ | ||
| 18 | "-C", "link-arg=-Wl,--defsym,pidfd_spawnp=0", | ||
| 19 | "-C", "link-arg=-Wl,--defsym,pidfd_getpid=0", | ||
| 20 | ] | ||
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. | |||
| 7 | file, and the tool schemas the model sees. Anything a script or a resumed session | 7 | file, and the tool schemas the model sees. Anything a script or a resumed session |
| 8 | could depend on counts as API. | 8 | could depend on counts as API. |
| 9 | 9 | ||
| 10 | ## 0.9.2 | ||
| 11 | |||
| 12 | ### Fixed | ||
| 13 | - A missing API key now exits 1 (an operational error), matching `--doctor`, | ||
| 14 | rather than 2 (usage). | ||
| 15 | - `--doctor` reports a one-line message for a non-JSON (HTML) error body instead | ||
| 16 | of dumping it. | ||
| 17 | - A non-terminal no longer prints a diff nobody can approve before denying an | ||
| 18 | edit. | ||
| 19 | - The weak `GLIBC_2.39` warning fix now covers x86_64 gnu too, not just i686, so | ||
| 20 | the README's primary build is clean on Debian 12. | ||
| 21 | |||
| 22 | ### Changed (docs) | ||
| 23 | - Corrected approval scope in PLAN (process, not session). | ||
| 24 | - README: test count, i686 note, glibc-floor wording, built-path note, and the | ||
| 25 | now-documented `AGENT686_DEBUG_STREAM`, `TERM=dumb` and `--resume`. | ||
| 26 | - PLAN dependency list and layout tree updated; 120 s timeout marked adjustable. | ||
| 27 | - CHANGELOG notes the skipped 0.8.1; the package description no longer says | ||
| 28 | "32-bit". | ||
| 29 | |||
| 10 | ## 0.9.1 | 30 | ## 0.9.1 |
| 11 | 31 | ||
| 12 | ### Fixed | 32 | ### Fixed |
| @@ -62,6 +82,8 @@ message covering four different failures. | |||
| 62 | 82 | ||
| 63 | ## 0.8.2 | 83 | ## 0.8.2 |
| 64 | 84 | ||
| 85 | > 0.8.1 was not released (its change was folded straight into 0.8.2). | ||
| 86 | |||
| 65 | ### Changed | 87 | ### Changed |
| 66 | - `comp.sh` now targets the CPU it runs on by default (`-C target-cpu=native`), | 88 | - `comp.sh` now targets the CPU it runs on by default (`-C target-cpu=native`), |
| 67 | which is what "build for this machine" should mean. `--portable` builds the | 89 | which is what "build for this machine" should mean. `--portable` builds the |
| @@ -10,7 +10,7 @@ checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" | |||
| 10 | 10 | ||
| 11 | [[package]] | 11 | [[package]] |
| 12 | name = "agent686" | 12 | name = "agent686" |
| 13 | version = "0.9.0" | 13 | version = "0.9.1" |
| 14 | dependencies = [ | 14 | dependencies = [ |
| 15 | "crossterm", | 15 | "crossterm", |
| 16 | "libc", | 16 | "libc", |
| @@ -1,8 +1,8 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | name = "agent686" | 2 | name = "agent686" |
| 3 | version = "0.9.1" | 3 | version = "0.9.2" |
| 4 | edition = "2021" | 4 | edition = "2021" |
| 5 | description = "A small coding agent for a 32-bit Debian box" | 5 | description = "A small coding agent for Debian-class Linux" |
| 6 | publish = false | 6 | publish = false |
| 7 | 7 | ||
| 8 | [dependencies] | 8 | [dependencies] |
| @@ -29,9 +29,13 @@ binary runs here; `--portable` targets the architecture floor instead. If the | |||
| 29 | binary is for another machine, use `--portable` or run `comp.sh` on that machine | 29 | binary is for another machine, use `--portable` or run `comp.sh` on that machine |
| 30 | — a native build fails with an illegal instruction on older chips. | 30 | — a native build fails with an illegal instruction on older chips. |
| 31 | 31 | ||
| 32 | A glibc build also inherits this machine's glibc floor, which is why the portable | 32 | A glibc build is bounded by the glibc symbols it references, not by this |
| 33 | paths are printed next to it: static musl removes the floor entirely, and building | 33 | machine's glibc version: `check-glibc.sh` reports the real floor (e.g. |
| 34 | inside an older Debian image lowers it. | 34 | `GLIBC_2.34`). Static musl removes the floor entirely, and building inside an |
| 35 | older Debian image lowers it. | ||
| 36 | |||
| 37 | The commands above produce `target/<triple>/release/agent686`; replace | ||
| 38 | `./agent686` below with that path. | ||
| 35 | 39 | ||
| 36 | The gate matters: the dev host's glibc is newer than the target's, so a | 40 | The gate matters: the dev host's glibc is newer than the target's, so a |
| 37 | dependency can silently raise the required symbol version. | 41 | 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 | |||
| 77 | ## Tests | 81 | ## Tests |
| 78 | 82 | ||
| 79 | ```sh | 83 | ```sh |
| 80 | cargo test # 75 tests, no network | 84 | cargo test # 92 tests, no network |
| 81 | python3 scripts/mock-provider.py & # canned SSE provider | 85 | python3 scripts/mock-provider.py & # canned SSE provider |
| 82 | docker run --rm --platform linux/386 \ | 86 | # i686 still builds (comp.sh on a 32-bit host picks it up): |
| 83 | -v "$PWD/target/i686-unknown-linux-gnu/release:/b:ro" debian:12 /b/agent686 --version | 87 | cargo build --release --target i686-unknown-linux-gnu |
| 84 | ``` | 88 | ``` |
| 85 | 89 | ||
| 86 | `tests/sse.rs` feeds the stream one byte at a time, so splits inside lines and | 90 | `tests/sse.rs` feeds the stream one byte at a time, so splits inside lines and |
| @@ -157,12 +157,15 @@ build_flags() { | |||
| 157 | esac | 157 | esac |
| 158 | } | 158 | } |
| 159 | 159 | ||
| 160 | # i686-gnu needs linker flags from .cargo/config.toml. RUSTFLAGS on the command | 160 | # gnu targets need linker flags from .cargo/config.toml (a weak GLIBC_2.39 |
| 161 | # line would shadow them, so repeat them. | 161 | # reference would warn on older glibc). RUSTFLAGS on the command line would |
| 162 | # shadow them, so repeat them here. | ||
| 162 | defsym_flag= | 163 | defsym_flag= |
| 163 | if [ "$triple_gnu" = i686-unknown-linux-gnu ]; then | 164 | case "$triple_gnu" in |
| 164 | defsym_flag="-C link-arg=-Wl,--defsym,pidfd_spawnp=0 -C link-arg=-Wl,--defsym,pidfd_getpid=0" | 165 | *-unknown-linux-gnu) |
| 165 | fi | 166 | defsym_flag="-C link-arg=-Wl,--defsym,pidfd_spawnp=0 -C link-arg=-Wl,--defsym,pidfd_getpid=0" |
| 167 | ;; | ||
| 168 | esac | ||
| 166 | 169 | ||
| 167 | # ---------------------------------------------------------------- report | 170 | # ---------------------------------------------------------------- report |
| 168 | 171 | ||
| @@ -217,7 +220,9 @@ if [ "$plan" = native ] || [ "$plan" = musl ]; then | |||
| 217 | [ "$plan" = musl ] && triple=$triple_musl | 220 | [ "$plan" = musl ] && triple=$triple_musl |
| 218 | 221 | ||
| 219 | flags=$(build_flags) | 222 | flags=$(build_flags) |
| 220 | [ "$triple" = i686-unknown-linux-gnu ] && flags="$flags $defsym_flag" | 223 | case "$triple" in |
| 224 | *-unknown-linux-gnu) flags="$flags $defsym_flag" ;; | ||
| 225 | esac | ||
| 221 | 226 | ||
| 222 | if [ "$cpu" = native ]; then | 227 | if [ "$cpu" = native ]; then |
| 223 | say " # for this CPU${cpu_level:+ (x86-64-$cpu_level)}" | 228 | say " # for this CPU${cpu_level:+ (x86-64-$cpu_level)}" |
| @@ -289,7 +294,9 @@ if [ "$run" -eq 1 ]; then | |||
| 289 | triple=$native_triple | 294 | triple=$native_triple |
| 290 | [ "$plan" = musl ] && triple=$triple_musl | 295 | [ "$plan" = musl ] && triple=$triple_musl |
| 291 | flags=$(build_flags) | 296 | flags=$(build_flags) |
| 292 | [ "$triple" = i686-unknown-linux-gnu ] && flags="$flags $defsym_flag" | 297 | case "$triple" in |
| 298 | *-unknown-linux-gnu) flags="$flags $defsym_flag" ;; | ||
| 299 | esac | ||
| 293 | 300 | ||
| 294 | section "building" | 301 | section "building" |
| 295 | rustup target add "$triple" >/dev/null 2>&1 || true | 302 | 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. | |||
| 7 | 7 | ||
| 8 | | | | | 8 | | | | |
| 9 | |---|---| | 9 | |---|---| |
| 10 | | Target | Debian 12 i386, glibc 2.36, 2 cores, 4 GB | | 10 | | Target | Debian-class Linux; x86-64 primary, i686 still supported | |
| 11 | | Build | `i686-unknown-linux-gnu`, dynamic glibc (see ADR 0001) | | 11 | | Build | `./comp.sh` — detects the machine and prints the build plan | |
| 12 | | Dev host | x86-64, `gcc-multilib`, `i686` + `i686-unknown-linux-musl` targets | | 12 | | Dev host | x86-64, `gcc-multilib`, `i686` + `i686-unknown-linux-musl` targets | |
| 13 | | Provider | OpenCode Go — `https://opencode.ai/inference/go/openai/v1`, `chat/completions` | | 13 | | Provider | OpenCode Go — `https://opencode.ai/inference/go/openai/v1`, `chat/completions` | |
| 14 | | Auth | `OPENCODE_API_KEY`, else `~/.config/agent686/key` (600 perms) | | 14 | | 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. | |||
| 27 | timeout, capped output, exit code), `grep`, `glob`. All native — no dependence | 27 | timeout, capped output, exit code), `grep`, `glob`. All native — no dependence |
| 28 | on `rg` being installed. | 28 | on `rg` being installed. |
| 29 | - **Approval.** Reads free. First `write`/`edit` of a session prompts with a | 29 | - **Approval.** Reads free. First `write`/`edit` of a session prompts with a |
| 30 | unified diff and offers "always" (session-scoped). Every `bash` call prompts | 30 | unified diff and offers "always" (process-scoped: a new process asks again on resume). Every `bash` call prompts |
| 31 | unless `--yolo`. Prompts happen after the stream ends, never mid-token. | 31 | unless `--yolo`. Prompts happen after the stream ends, never mid-token. |
| 32 | - **Turn/step.** A turn ends when the model answers with no tool calls, on user | 32 | - **Turn/step.** A turn ends when the model answers with no tool calls, on user |
| 33 | abort, or on a non-retryable provider error. **No step cap** — the brake is the | 33 | 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. | |||
| 169 | ## Layout | 169 | ## Layout |
| 170 | 170 | ||
| 171 | ``` | 171 | ``` |
| 172 | src/lib.rs module root | ||
| 172 | src/main.rs args, mode selection, exit codes, /paste | 173 | src/main.rs args, mode selection, exit codes, /paste |
| 173 | src/config.rs precedence CLI > env > file; key source | 174 | src/config.rs precedence CLI > env > file; key source |
| 174 | src/provider.rs request construction, retry, SSE parsing, model list | 175 | 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 | |||
| 177 | src/line.rs raw-mode line editor, history | 178 | src/line.rs raw-mode line editor, history |
| 178 | src/signal.rs SIGINT -> cancel flag | 179 | src/signal.rs SIGINT -> cancel flag |
| 179 | src/doctor.rs --doctor checks | 180 | src/doctor.rs --doctor checks |
| 180 | src/tools/ read, write, edit, bash, grep, glob | 181 | src/tools/mod.rs schemas, validation, dispatch |
| 182 | src/tools/fs.rs read, write, edit, grep, glob | ||
| 183 | src/tools/shell.rs bash, timeouts, output caps | ||
| 181 | src/ui.rs streaming render, diffs, approval prompt, status line | 184 | src/ui.rs streaming render, diffs, approval prompt, status line |
| 185 | scripts/ux-check.sh drives tmux to assert the rendered screen | ||
| 182 | tests/mock.rs provider over std TcpListener (SSE, retry, truncation) | 186 | tests/mock.rs provider over std TcpListener (SSE, retry, truncation) |
| 183 | tests/loop.rs agent loop, abort and repair invariants | 187 | tests/loop.rs agent loop, abort and repair invariants |
| 184 | tests/tools.rs tool semantics and edge cases | 188 | 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 | |||
| 5 | a usage frame, with a small pause between them so the renderer can be seen | 5 | a usage frame, with a small pause between them so the renderer can be seen |
| 6 | working incrementally. | 6 | working incrementally. |
| 7 | 7 | ||
| 8 | Serves only POST /chat/completions; it does not serve GET /models, so | ||
| 9 | `--doctor` cannot be exercised against it (it returns an HTML 501). | ||
| 10 | |||
| 8 | scripts/mock-provider.py --port 8765 | 11 | scripts/mock-provider.py --port 8765 |
| 9 | OPENCODE_API_KEY=test ./agent686 --base-url http://127.0.0.1:8765/v1 "hi" | 12 | OPENCODE_API_KEY=test ./agent686 --base-url http://127.0.0.1:8765/v1 "hi" |
| 10 | """ | 13 | """ |
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: | |||
| 29 | -m, --model <ID> model id (default: deepseek-v4.1-flash) | 29 | -m, --model <ID> model id (default: deepseek-v4.1-flash) |
| 30 | --base-url <URL> provider base URL | 30 | --base-url <URL> provider base URL |
| 31 | --session <ID> resume a session, creating it if the id is new | 31 | --session <ID> resume a session, creating it if the id is new |
| 32 | (alias: --resume) | ||
| 32 | -c, --continue resume the most recent session | 33 | -c, --continue resume the most recent session |
| 33 | --list list sessions and exit | 34 | --list list sessions and exit |
| 34 | --show [ID] print a transcript (most recent if no ID) and exit | 35 | --show [ID] print a transcript (most recent if no ID) and exit |
| @@ -220,7 +221,7 @@ fn run(args: Args) { | |||
| 220 | Ok(cfg) => cfg, | 221 | Ok(cfg) => cfg, |
| 221 | Err(message) => { | 222 | Err(message) => { |
| 222 | eprintln!("agent686: {message}"); | 223 | eprintln!("agent686: {message}"); |
| 223 | std::process::exit(2); | 224 | std::process::exit(1); |
| 224 | } | 225 | } |
| 225 | }; | 226 | }; |
| 226 | 227 | ||
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( | |||
| 484 | } | 484 | } |
| 485 | 485 | ||
| 486 | fn error_message(body: &str) -> String { | 486 | fn error_message(body: &str) -> String { |
| 487 | let trimmed = body.trim_start(); | ||
| 488 | if trimmed.starts_with('<') { | ||
| 489 | return "the provider returned an HTML error page rather than JSON".to_string(); | ||
| 490 | } | ||
| 487 | if let Ok(v) = serde_json::from_str::<Value>(body) { | 491 | if let Ok(v) = serde_json::from_str::<Value>(body) { |
| 488 | if let Some(err) = v.get("error") { | 492 | if let Some(err) = v.get("error") { |
| 489 | if let Some(message) = err.get("message").and_then(|m| m.as_str()) { | 493 | if let Some(message) = err.get("message").and_then(|m| m.as_str()) { |
| @@ -269,6 +269,10 @@ impl Approver { | |||
| 269 | if self.yolo || self.edits_allowed { | 269 | if self.yolo || self.edits_allowed { |
| 270 | return true; | 270 | return true; |
| 271 | } | 271 | } |
| 272 | // No point showing a diff that no one is present to approve. | ||
| 273 | if !self.interactive { | ||
| 274 | return false; | ||
| 275 | } | ||
| 272 | println!("{preview}"); | 276 | println!("{preview}"); |
| 273 | // The path is already on the tool line above. | 277 | // The path is already on the tool line above. |
| 274 | let _ = path; | 278 | 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() { | |||
| 34 | .output() | 34 | .output() |
| 35 | .unwrap(); | 35 | .unwrap(); |
| 36 | 36 | ||
| 37 | assert_eq!(output.status.code(), Some(2)); | 37 | assert_eq!(output.status.code(), Some(1)); |
| 38 | let stderr = String::from_utf8_lossy(&output.stderr); | 38 | let stderr = String::from_utf8_lossy(&output.stderr); |
| 39 | assert!(stderr.contains("no API key"), "{stderr}"); | 39 | assert!(stderr.contains("no API key"), "{stderr}"); |
| 40 | assert!(!String::from_utf8_lossy(&output.stdout).contains("agent686 0")); | 40 | assert!(!String::from_utf8_lossy(&output.stdout).contains("agent686 0")); |
