diff --git a/.beads/issues.jsonl b/.beads/issues.jsonl index a08c31c..a624d2a 100644 --- a/.beads/issues.jsonl +++ b/.beads/issues.jsonl @@ -1,5 +1,11 @@ +{"_type":"issue","id":"killall-agent-i14","title":"Open and merge read-only tool loading PR","description":"Review and validate tool loading and integration tests, push a feature branch, open a PR, wait for hosted checks, address blockers and merge once green.","status":"open","priority":2,"issue_type":"task","owner":"github@pocketcereal.com","created_at":"2026-12-02T23:54:47Z","created_by":"archae0pteryx","updated_at":"2026-12-02T23:54:47Z","dependency_count":0,"dependent_count":0,"comment_count":0} +{"_type":"issue","id":"killall-agent-1kq","title":"Add agent integration tests for read list and search","description":"Exercise each loaded tool through the Rig agent loop with a scripted model and real temporary workspace, keeping integration tests separate from unit tests and avoiding network calls.","status":"closed","priority":2,"issue_type":"task","assignee":"archae0pteryx","owner":"github@pocketcereal.com","created_at":"2026-12-02T23:23:35Z","created_by":"archae0pteryx","updated_at":"2026-12-02T23:25:55Z","started_at":"2026-12-02T23:24:19Z","closed_at":"2026-12-02T23:25:55Z","close_reason":"Added tests/tools.rs with one full agent-loop test each for read/list/search, asserting advertised tools, call identity, successful results and actual workspace content in the next model request. Exposed the existing tools module through src/lib.rs and replaced redundant direct-dispatch tests. All 18 tests, clippy, formatting and diff checks pass; no network or credentials required.","dependency_count":0,"dependent_count":0,"comment_count":0} +{"_type":"issue","id":"killall-agent-500","title":"Review tool loading changes with hall-monitor","description":"Run the hall-monitor script from feat/hall-monitor against current changes, review each finding, make justified improvements, run checks, and regrade.","status":"closed","priority":2,"issue_type":"task","assignee":"archae0pteryx","owner":"github@pocketcereal.com","created_at":"2026-12-02T23:19:47Z","created_by":"archae0pteryx","updated_at":"2026-12-02T23:20:26Z","started_at":"2026-12-02T23:20:21Z","closed_at":"2026-12-02T23:20:26Z","close_reason":"Ran feat/hall-monitor script against current changes using its configured model and effort. All four selected files graded A (non-A JSON output []). No findings required fixes. Formatting, all 18 tests, clippy and diff checks pass. Report saved at /tmp/killall-agent-hall-monitor-initial.json.","dependency_count":0,"dependent_count":0,"comment_count":0} +{"_type":"issue","id":"killall-agent-ip0","title":"Load read-only coding tools into the agent","description":"Add a small workspace-scoped loader for Rig read, list and search; wire into agent runtime and verify registration and execution without network calls.","status":"closed","priority":2,"issue_type":"task","assignee":"archae0pteryx","owner":"github@pocketcereal.com","created_at":"2026-12-02T23:03:17Z","created_by":"archae0pteryx","updated_at":"2026-12-02T23:06:19Z","started_at":"2026-12-02T23:03:22Z","closed_at":"2026-12-02T23:06:19Z","close_reason":"Added workspace-scoped read/list/search loader and wired Rig agent runtime with a 10-turn limit. All 18 tests, formatting, clippy and diff checks pass. No live provider call performed.","dependency_count":0,"dependent_count":0,"comment_count":0} +{"_type":"issue","id":"killall-agent-za2","title":"Preview hall-monitor files before grading","description":"Print the full filtered file list to stderr before the first grading call, retain per-file Grading lines, and preserve JSON-only stdout. Add top-level MODEL=openai-codex/gpt-6.1-sol and EFFORT=medium variables passed through Pi's --model and --thinking flags. Extend the stubbed tests to verify preview ordering, progress messages, and model/effort options. Open a PR after validation; no merge requested.","status":"closed","priority":2,"issue_type":"task","assignee":"archae0pteryx","owner":"github@pocketcereal.com","created_at":"2026-12-02T20:18:49Z","created_by":"archae0pteryx","updated_at":"2026-12-02T21:04:44Z","started_at":"2026-12-02T20:18:54Z","closed_at":"2026-12-02T21:04:44Z","close_reason":"Added the complete filtered-file preview and explicit MODEL/EFFORT settings, verified ordering and CLI flags with stubbed tests under both Bash versions, and opened https://github.com/killallgit/killall-agent/pull/2. ShellCheck, syntax, actionlint, diff checks, and local model-catalog lookup pass; no live grading call or merge performed.","dependency_count":0,"dependent_count":0,"comment_count":0} +{"_type":"issue","id":"killall-agent-11z","title":"Implement file-by-file hall-monitor JSON grading","description":"Replace the draft hall-monitor script with a small read-only grader: discover committed/staged/unstaged/untracked changes relative to main's merge base, apply an explicit file/directory exclusion list, grade each file against a concise AGENTS-derived rubric, validate responses, and emit only non-A grades as a JSON array. No fixes, commits, or live-call CI automation. Validate discovery, exclusions, JSON shape, and failure behavior using a stub Pi.","status":"closed","priority":2,"issue_type":"task","assignee":"archae0pteryx","owner":"github@pocketcereal.com","created_at":"2026-12-02T20:09:48Z","created_by":"archae0pteryx","updated_at":"2026-12-02T20:14:24Z","started_at":"2026-12-02T20:10:36Z","closed_at":"2026-12-02T20:14:24Z","close_reason":"Implemented 72-line hall-monitor with explicit exclusions, a compact repository rubric, isolated tool-free Pi calls, per-file JSON validation, and a final non-A array. Stubbed behavior tests cover all Git change types, duplicate paths, exclusions, supplied context, schema failures, and Pi errors; ShellCheck, Bash syntax, actionlint, and diff checks pass. No live model calls, fixes, commits, or pushes performed.","dependency_count":0,"dependent_count":0,"comment_count":0} {"_type":"issue","id":"killall-agent-8pe","title":"Scope CI to relevant files and lint shell scripts","description":"Run Rust PR/main checks only for src/**, Cargo.toml, Cargo.lock, and .cargo/**. Add ShellCheck for tracked .sh files under scripts/ and .github/scripts/, independently lint workflow YAML, and scope dependency audits to their input files while retaining scheduled audits and full tag-release checks. Validate workflows and shell lint locally before PR.","status":"closed","priority":2,"issue_type":"task","assignee":"archae0pteryx","owner":"github@pocketcereal.com","created_at":"2026-12-02T19:45:56Z","created_by":"archae0pteryx","updated_at":"2026-12-02T19:48:03Z","started_at":"2026-12-02T19:46:56Z","closed_at":"2026-12-02T19:48:03Z","close_reason":"Added relevant-file filters to Rust CI and dependency audits, separate ShellCheck/workflow-lint workflows, and preserved callable release checks and scheduled audits. ShellCheck, actionlint (including exact CI go-run command), workflow security lint, and 28 path-filter expectations pass. Also corrected the unsupported actionlint installer before push.","dependency_count":0,"dependent_count":0,"comment_count":0} -{"_type":"issue","id":"killall-agent-etq","title":"Land the first CLI and CI pull request","description":"Run final local checks, review the full staged diff, push a feature branch with CLI/build/CI/release/Beads changes, exclude scripts/hall-monitor.sh, verify hosted checks, and merge if no blockers. Keep deferred README work and the Beads config validator warning open. No release tag or publication is requested.","status":"in_progress","priority":2,"issue_type":"task","assignee":"archae0pteryx","owner":"github@pocketcereal.com","created_at":"2026-12-02T19:44:30Z","created_by":"archae0pteryx","updated_at":"2026-12-02T19:44:45Z","started_at":"2026-12-02T19:44:45Z","lease_expires_at":"2026-12-02T19:49:45Z","heartbeat_at":"2026-12-02T19:44:45Z","dependency_count":0,"dependent_count":0,"comment_count":0} +{"_type":"issue","id":"killall-agent-etq","title":"Land the first CLI and CI pull request","description":"Run final local checks, review the full staged diff, push a feature branch with CLI/build/CI/release/Beads changes, exclude scripts/hall-monitor.sh, verify hosted checks, and merge if no blockers. Keep deferred README work and the Beads config validator warning open. No release tag or publication is requested.","status":"closed","priority":2,"issue_type":"task","assignee":"archae0pteryx","owner":"github@pocketcereal.com","created_at":"2026-12-02T19:44:30Z","created_by":"archae0pteryx","updated_at":"2026-12-02T19:56:35Z","started_at":"2026-12-02T19:44:45Z","closed_at":"2026-12-02T19:56:35Z","close_reason":"Merged https://github.com/killallgit/killall-agent/pull/1 after all eight hosted checks passed. Hall-monitor excluded, no live Strata call or release tag. README and Beads validator follow-ups remain open.","dependency_count":0,"dependent_count":0,"comment_count":0} {"_type":"issue","id":"killall-agent-w80","title":"Investigate Beads config validation for the Git-backed remote","description":"bd 1.3.4 config validate reports 'federation.remote: required for Dolt sync', while sync.remote and the configured origin Dolt remote are both git+ssh://git@github.com/killallgit/killall-agent.git. Determine whether this is an outdated federation-specific validator or a real configuration requirement before changing remote settings. No remote synchronization was attempted. Existing active settings were preserved during boilerplate cleanup.","status":"open","priority":2,"issue_type":"task","owner":"github@pocketcereal.com","created_at":"2026-12-02T19:43:12Z","created_by":"archae0pteryx","updated_at":"2026-12-02T19:43:12Z","dependency_count":0,"dependent_count":0,"comment_count":0} {"_type":"issue","id":"killall-agent-5pn","title":"Trim setup boilerplate before the first PR","description":"Consolidate duplicate Beads guidance in AGENTS.md, retain only active Beads YAML configuration, remove the generic Beads README and stale commented pi command, and leave scripts/hall-monitor.sh untouched and out of PR staging. Preserve operational hooks and existing behavior. Validate shell syntax, Beads configuration, workflows, and diff.","status":"closed","priority":2,"issue_type":"task","assignee":"archae0pteryx","owner":"github@pocketcereal.com","created_at":"2026-12-02T19:41:13Z","created_by":"archae0pteryx","updated_at":"2026-12-02T19:43:13Z","started_at":"2026-12-02T19:41:26Z","closed_at":"2026-12-02T19:43:13Z","close_reason":"Removed duplicate Beads instructions, inactive YAML examples, generic Beads README, and commented pi command. Preserved generated Codex block to pass its setup check, conservative authorization rules, all operational hooks, and active sync/export settings. Hall-monitor left untouched and unstaged. Shell syntax, Codex setup, hook status, actionlint, and diff checks pass. Separate issue records the config validator federation.remote warning.","dependency_count":0,"dependent_count":0,"comment_count":0} {"_type":"issue","id":"killall-agent-j44","title":"Remove release-version integration test","description":"Remove the release-version test, its npm script, and CI setup used only for that test. Retain release tooling and tag-time Cargo version/lockfile validation. Validate references, workflows, and Rust checks.","status":"closed","priority":2,"issue_type":"task","assignee":"archae0pteryx","owner":"github@pocketcereal.com","created_at":"2026-12-02T19:33:45Z","created_by":"archae0pteryx","updated_at":"2026-12-02T19:34:13Z","started_at":"2026-12-02T19:33:52Z","closed_at":"2026-12-02T19:34:13Z","close_reason":"Removed release-version test, npm test script, test-only Node CI setup, and stale README references. actionlint, formatting, all 11 Rust tests, Clippy, and reference checks pass. Tag-time version and lockfile validation retained.","dependency_count":0,"dependent_count":0,"comment_count":0} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 64639e2..e33d343 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,6 +4,7 @@ on: pull_request: paths: - 'src/**' + - 'tests/**' - Cargo.toml - Cargo.lock - '.cargo/**' @@ -11,6 +12,7 @@ on: branches: [main] paths: - 'src/**' + - 'tests/**' - Cargo.toml - Cargo.lock - '.cargo/**' diff --git a/Cargo.lock b/Cargo.lock index 320b7ed..d3aa8b7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,15 @@ # It is not intended for manual editing. version = 4 +[[package]] +name = "aho-corasick" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c982642fa9e8606056828ee9a8505737230110bb1099153c79efe865c59d12ba" +dependencies = [ + "memchr", +] + [[package]] name = "anstream" version = "1.0.0" @@ -145,6 +154,16 @@ dependencies = [ "hybrid-array", ] +[[package]] +name = "bstr" +version = "1.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a680398c10c7bc0488067c4612226ea905a85f607134b69f3068d505d58c4214" +dependencies = [ + "memchr", + "serde_core", +] + [[package]] name = "bumpalo" version = "3.20.4" @@ -263,6 +282,15 @@ version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be95d4a884358a21a199689323c29e9256b4a1b315e22f183d155422041d3a9a" +[[package]] +name = "convert_case" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "affbf0190ed2caf063e3def54ff444b449371d55c58e513a95ab98eca50adb49" +dependencies = [ + "unicode-segmentation", +] + [[package]] name = "core-foundation" version = "0.9.4" @@ -313,6 +341,31 @@ dependencies = [ "libc", ] +[[package]] +name = "crossbeam-deque" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "622f3fc73690be383c7214310406f28a90e6edeadc3cea882f9d71e495b9711a" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc74980687109a3b14c72fd458107bf0baa1da1a1a805e178d15501ba9b86d9d" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31eee39dddec8330830986fcd7625edb5a24ec90ea038215273bbc3adb08ac6" + [[package]] name = "crypto-common" version = "0.1.7" @@ -402,6 +455,16 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826" +[[package]] +name = "errno" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e35d6e78f4cebb90e51d543db8fe41528851d6deeef6ef21ebd4bfdc1e784776" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + [[package]] name = "fastrand" version = "2.5.0" @@ -588,6 +651,19 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4eba85ea1d0a966a983acd07deee566e67395d2d96b6fb39e62b5a833f1eb0b" +[[package]] +name = "globset" +version = "0.4.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71217a07f20b48b4938c14203b77b610f8a7fa6762c3f75394a10c5f31e5aee0" +dependencies = [ + "aho-corasick", + "bstr", + "log", + "regex-automata", + "regex-syntax", +] + [[package]] name = "gloo-timers" version = "0.4.1" @@ -851,6 +927,22 @@ dependencies = [ "icu_properties", ] +[[package]] +name = "ignore" +version = "0.4.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df0a7d5f105e76bda602bed0a44af048542d3c9af12ec35aaf16f106c6f34270" +dependencies = [ + "crossbeam-deque", + "globset", + "log", + "memchr", + "regex-automata", + "same-file", + "walkdir", + "winapi-util", +] + [[package]] name = "indexmap" version = "2.14.2" @@ -863,6 +955,26 @@ dependencies = [ "serde_core", ] +[[package]] +name = "inotify" +version = "0.11.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cc00ea907cab49550b7da656f80ebb97be1b997d931fbcd28d39734e17ce592" +dependencies = [ + "bitflags", + "inotify-sys", + "libc", +] + +[[package]] +name = "inotify-sys" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c033f80b2c113cdf91ab7a33faa9cbc014726dcad99880c8609af2a370edf37d" +dependencies = [ + "libc", +] + [[package]] name = "ipnet" version = "2.12.3" @@ -957,18 +1069,53 @@ version = "0.1.0" dependencies = [ "anyhow", "clap", + "rig-agent", "rig-core", + "rig-tools", "serde", "serde_json", + "tempfile", "tokio", ] +[[package]] +name = "kqueue" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d763e5b24120b4ddf50de6c92308156765aabfbbccebf401da7cff2d70a41ea" +dependencies = [ + "kqueue-sys", + "libc", +] + +[[package]] +name = "kqueue-sys" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07293a4e297ac234359b510362495713f75ea345d5307140414f20c69ffeb087" +dependencies = [ + "bitflags", + "libc", +] + +[[package]] +name = "lazy_static" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20870f649af7073d53e38067b2a84312175d56ea15217e1b15bc83506ec50afb" + [[package]] name = "libc" version = "0.2.191" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a" +[[package]] +name = "linux-raw-sys" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" + [[package]] name = "litemap" version = "0.8.3" @@ -1016,6 +1163,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "20521a903f02b0a573cd6840e9d0a5a0cc043d361fe924092cd70f8556cc9c4a" dependencies = [ "libc", + "log", "wasi", "windows-sys 0.61.2", ] @@ -1026,6 +1174,43 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "743fb55ba31b18fb1ecef6bdc9aa2743314978ac084044301a7eee33fb99a20d" +[[package]] +name = "notify" +version = "8.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c41a04a5f59df9322cc657286dd2d79f90816119b22c5f847607c850110205ab" +dependencies = [ + "bitflags", + "inotify", + "kqueue", + "libc", + "log", + "mio", + "notify-types", + "objc2-core-foundation", + "objc2-core-services", + "walkdir", + "windows-sys 0.61.2", +] + +[[package]] +name = "notify-types" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbd044e85df3d939d8e32a1c35a3b737c7d0a4eeb7acd737bd207644e00f4e5f" +dependencies = [ + "bitflags", +] + +[[package]] +name = "nu-ansi-term" +version = "0.50.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" +dependencies = [ + "windows-sys 0.61.2", +] + [[package]] name = "num-traits" version = "0.2.19" @@ -1035,6 +1220,25 @@ dependencies = [ "autocfg", ] +[[package]] +name = "objc2-core-foundation" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536" +dependencies = [ + "bitflags", +] + +[[package]] +name = "objc2-core-services" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "583300ad934cba24ff5292aee751ecc070f7ca6b39a574cc21b7b5e588e06a0b" +dependencies = [ + "libc", + "objc2-core-foundation", +] + [[package]] name = "once_cell" version = "1.21.4" @@ -1068,6 +1272,26 @@ version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" +[[package]] +name = "pin-project" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6c2123f4708bbd422630a6dae7c03f678b1ce1f1c99e4c4b3beac69c8174cc9" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "358938fd6df944c1e44bb328b60fb275f13c804aac47ba26a1165d45a3f87756" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + [[package]] name = "pin-project-lite" version = "0.2.19" @@ -1098,6 +1322,15 @@ dependencies = [ "zerocopy", ] +[[package]] +name = "proc-macro-crate" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e67ba7e9b2b56446f1d419b1d807906278ffa1a658a8a5d8a39dcb1f5a78614f" +dependencies = [ + "toml_edit", +] + [[package]] name = "proc-macro2" version = "1.0.107" @@ -1260,6 +1493,35 @@ dependencies = [ "syn 3.0.10", ] +[[package]] +name = "regex" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9807af0e638c12e753aa1b4e601791bf2a8f71274023c8bbeec12fc149950857" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d60ef07df457506a0a1a2073112eb4aae5733dbd2813c3da77d1b0fd441158" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d902046e6a28a1e4c3cab97258a0ce11e994903f01c2d97a9447a0b3df85f4f6" + [[package]] name = "reqwest" version = "0.13.5" @@ -1304,11 +1566,32 @@ dependencies = [ "web-sys", ] +[[package]] +name = "rig-agent" +version = "0.47.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b1af1684614ecfe430d26b141f9bba58d5e8bd0938e3f6781b29d61b1b694d8" +dependencies = [ + "async-stream", + "futures", + "http", + "indexmap", + "rig-core", + "rig-derive", + "rig-memory", + "schemars", + "serde", + "serde_json", + "thiserror", + "tracing", + "tracing-futures", +] + [[package]] name = "rig-core" -version = "0.47.1" +version = "0.47.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea12b6d2a5d2591192636d30af2981ce180b45204e19b7f14ce1347215603c8" +checksum = "434e14d890ae867be160e9fcd1452f888f27c730df43594af13f825c1eda86e9" dependencies = [ "async-stream", "base64", @@ -1322,6 +1605,7 @@ dependencies = [ "mime", "mime_guess", "ordered-float", + "rig-derive", "rig-http", "rig-reqwest", "rig-tungstenite", @@ -1332,16 +1616,30 @@ dependencies = [ "sha2", "thiserror", "tracing", + "tracing-subscriber", "url", "uuid", "web-time", ] +[[package]] +name = "rig-derive" +version = "0.47.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "470c414a9b856a1c9ae0f556fd3910ec16749f1af9041462175e003ab27cd268" +dependencies = [ + "convert_case", + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 3.0.10", +] + [[package]] name = "rig-http" -version = "0.47.1" +version = "0.47.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06e3c63862bb7f08460f95815ee82dc883a59409883c4e60aa19ade0556864a8" +checksum = "9d10b99f1b145617c76292507290ac44dd719c41dae0b0fe765157da5c07ec58" dependencies = [ "bytes", "futures", @@ -1353,11 +1651,25 @@ dependencies = [ "url", ] +[[package]] +name = "rig-memory" +version = "0.47.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fc67ce4d91d7fd947fc4bb4f81ea9d0ca5161cc93451c598d256913746a9173" +dependencies = [ + "base64", + "memchr", + "rig-core", + "serde", + "serde_json", + "thiserror", +] + [[package]] name = "rig-reqwest" -version = "0.47.1" +version = "0.47.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aac938aaebb4c0ab051444da7846c128fec2648c82826dd938ee2af02fbc1963" +checksum = "696257bfd164df114a08bb023be5702a40afbd84d7bf22acfd9901e53855f503" dependencies = [ "bytes", "futures", @@ -1370,11 +1682,32 @@ dependencies = [ "webpki-root-certs", ] +[[package]] +name = "rig-tools" +version = "0.47.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd6725d885839f11c2fa2857e4212e89540567825b3f5e8c5509ba7a9620f4d6" +dependencies = [ + "base64", + "futures", + "ignore", + "libc", + "notify", + "regex", + "rig-core", + "schemars", + "serde", + "serde_json", + "similar", + "unicode-segmentation", + "unicode-width", +] + [[package]] name = "rig-tungstenite" -version = "0.47.1" +version = "0.47.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75c531f43d4f8783c20158337508004853267288a44bd252dfcbdd362187bd7" +checksum = "b74b93730fb0f1a048431ae8ff8181c4fcd31b50ff8b5cdc7e64f1f9ca9b480e" dependencies = [ "futures", "rig-http", @@ -1412,6 +1745,19 @@ dependencies = [ "semver", ] +[[package]] +name = "rustix" +version = "1.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5e76742e5294153d4dde1207dbec5bdd81eef6fabdc0d2118babadabfd858aa" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.61.2", +] + [[package]] name = "rustls" version = "0.23.47" @@ -1664,6 +2010,15 @@ dependencies = [ "digest 0.11.3", ] +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + [[package]] name = "shlex" version = "2.0.1" @@ -1686,6 +2041,15 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" +[[package]] +name = "similar" +version = "3.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2f8bec09ae8fae0f4f265a4559a9334be3929d8504e9b536df0a41302bd1733" +dependencies = [ + "bstr", +] + [[package]] name = "slab" version = "0.4.12" @@ -1789,6 +2153,19 @@ dependencies = [ "libc", ] +[[package]] +name = "tempfile" +version = "3.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" +dependencies = [ + "fastrand", + "getrandom 0.4.3", + "once_cell", + "rustix", + "windows-sys 0.61.2", +] + [[package]] name = "thiserror" version = "2.0.21" @@ -1809,6 +2186,15 @@ dependencies = [ "syn 3.0.10", ] +[[package]] +name = "thread_local" +version = "1.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ad99c4c6d32803332c548b1af0540b357b3f5fc0be8f6c6bfe8b2e6ae784070" +dependencies = [ + "cfg-if", +] + [[package]] name = "tinystr" version = "0.8.5" @@ -1891,6 +2277,36 @@ dependencies = [ "tokio", ] +[[package]] +name = "toml_datetime" +version = "1.1.3+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "173f25c883cd2176a2d8212155638c0a60d484a9d84546d270866f40f56b6e49" +dependencies = [ + "serde_core", +] + +[[package]] +name = "toml_edit" +version = "0.25.21+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88497dab46de5bf343ec66b05c251e48c6213f3e9170c70a70a823f7abe886a4" +dependencies = [ + "indexmap", + "toml_datetime", + "toml_parser", + "winnow", +] + +[[package]] +name = "toml_parser" +version = "1.1.7+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bb28d6e049a9766c3bd91a8326e6179f5b132dec87906bb97018ef7a2f3431a" +dependencies = [ + "winnow", +] + [[package]] name = "tower" version = "0.5.3" @@ -1965,6 +2381,44 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" dependencies = [ "once_cell", + "valuable", +] + +[[package]] +name = "tracing-futures" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2" +dependencies = [ + "futures", + "futures-task", + "pin-project", + "tracing", +] + +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7f578e5945fb242538965c2d0b04418d38ec25c79d160cd279bf0731c8d319" +dependencies = [ + "nu-ansi-term", + "sharded-slab", + "smallvec", + "thread_local", + "tracing-core", + "tracing-log", ] [[package]] @@ -2009,6 +2463,18 @@ version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563" +[[package]] +name = "unicode-segmentation" +version = "1.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8" + +[[package]] +name = "unicode-width" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca718471876992059f251e33aafc334346ada08042b7661dd1fe313a9bced557" + [[package]] name = "untrusted" version = "0.9.0" @@ -2060,6 +2526,12 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "valuable" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" + [[package]] name = "version_check" version = "0.9.5" @@ -2341,6 +2813,15 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" +[[package]] +name = "winnow" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3b93199df0ab874cdf0c6a94f0a0dc3423fe41f1cafb62b8bd7b1deb277aef" +dependencies = [ + "memchr", +] + [[package]] name = "wit-bindgen" version = "0.57.1" diff --git a/Cargo.toml b/Cargo.toml index 710a07f..3b3fd5c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,13 @@ rust-version = "1.97.1" [dependencies] anyhow = "1.0.105" clap = { version = "4.6.10", features = ["derive"] } -rig-core = { version = "0.47.1", default-features = false, features = ["reqwest", "rustls"] } +rig-agent = "0.47.2" +rig-core = { version = "0.47.2", default-features = false, features = ["reqwest", "rustls"] } +rig-tools = "0.47.2" serde = { version = "1.0.229", features = ["derive"] } serde_json = "1.0.154" tokio = { version = "1.54.1", features = ["macros", "rt-multi-thread"] } + +[dev-dependencies] +rig-core = { version = "0.47.2", default-features = false, features = ["test-utils"] } +tempfile = "3.27.0" diff --git a/src/cli.rs b/src/cli.rs index efa01bd..882b0d4 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -1,7 +1,10 @@ use clap::{Parser, ValueEnum}; #[derive(Debug, Parser)] -#[command(version, about = "Send a prompt to an AI model")] +#[command( + version, + about = "Run a read-only coding agent in the current directory" +)] pub struct Args { /// Prompt to send to the model #[arg(short, long, default_value = "Say hello in one short sentence.")] diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..fd2e6d0 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1 @@ +pub mod tools; diff --git a/src/main.rs b/src/main.rs index 318063e..5f411c9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,11 +3,15 @@ mod strata; use anyhow::{Context, Result}; use clap::Parser; -use rig_core::{completion::CompletionRequest, providers::openai::OpenAIConfig}; +use killall_agent::tools; +use rig_agent::AgentBuilder; +use rig_core::providers::openai::OpenAIConfig; #[tokio::main] async fn main() -> Result<()> { let args = cli::Args::parse(); + let workspace = std::env::current_dir().context("Cannot determine workspace directory")?; + let tools = tools::load(&workspace)?; let strata = strata::load()?; let model = strata .models @@ -17,12 +21,16 @@ async fn main() -> Result<()> { let client = OpenAIConfig::new(strata::resolve_api_key(&strata.api_key)?) .with_base_url(strata.base_url) .client(); - let response = client - .chat(&model.id) - .call(CompletionRequest::new(args.prompt)) + let agent = AgentBuilder::new(client.chat(&model.id)) + .tool_server_handle(tools) + .default_max_turns(10) + .preamble("You are a coding assistant with read-only tools. Relative tool paths resolve from the workspace directory. Use the tools when needed to inspect files; do not claim to have changed files.") + .build(); + let response = agent + .prompt(args.prompt) .await - .context("Strata prompt failed")?; + .context("Strata agent run failed")?; - println!("{}", response.text()); + println!("{response}"); Ok(()) } diff --git a/src/tools.rs b/src/tools.rs new file mode 100644 index 0000000..7020f26 --- /dev/null +++ b/src/tools.rs @@ -0,0 +1,85 @@ +use std::path::Path; + +use anyhow::{Context, Result, ensure}; +use rig_agent::tool::server::{ToolServer, ToolServerHandle}; +use rig_tools::{List, Read, Search, workspace::Root}; + +pub fn load(workspace: &Path) -> Result { + let base = workspace + .canonicalize() + .with_context(|| format!("Cannot resolve workspace {}", workspace.display()))?; + ensure!( + base.is_dir(), + "Workspace is not a directory: {}", + base.display() + ); + let root = Root { + base: Some(base), + confine: true, + ..Root::default() + }; + + Ok(ToolServer::new() + .tool(Read { + root: root.clone(), + ..Read::default() + }) + .tool(List { root: root.clone() }) + .tool(Search { root }) + .run()) +} + +#[cfg(test)] +mod tests { + use super::*; + use rig_core::tool::{ToolContext, ToolErrorKind}; + use serde_json::json; + + #[test] + fn registers_only_read_list_and_search() { + let workspace = tempfile::tempdir().unwrap(); + let tools = load(workspace.path()).unwrap().toolset(); + + assert_eq!( + tools.names().collect::>(), + ["read", "list", "search"] + ); + } + + #[test] + fn rejects_a_missing_workspace() { + let workspace = tempfile::tempdir().unwrap(); + assert!(load(&workspace.path().join("missing")).is_err()); + } + + #[test] + fn rejects_a_file_as_the_workspace() { + let file = tempfile::NamedTempFile::new().unwrap(); + assert!(load(file.path()).is_err()); + } + + #[tokio::test] + async fn refuses_paths_outside_the_workspace_for_each_tool() { + let parent = tempfile::tempdir().unwrap(); + let workspace = parent.path().join("workspace"); + std::fs::create_dir(&workspace).unwrap(); + std::fs::write(parent.path().join("outside.txt"), "private\n").unwrap(); + let tools = load(&workspace).unwrap().toolset(); + + for (name, args) in [ + ("read", json!({"path": "../outside.txt"})), + ("list", json!({"path": ".."})), + ("search", json!({"path": "..", "pattern": "private"})), + ] { + let result = tools + .get(name) + .unwrap() + .execute(args.to_string(), &mut ToolContext::default()) + .await; + assert!( + result.is_error_kind(ToolErrorKind::PermissionDenied), + "{name}: {result:?}" + ); + } + } +} diff --git a/tests/tools.rs b/tests/tools.rs new file mode 100644 index 0000000..d0deff1 --- /dev/null +++ b/tests/tools.rs @@ -0,0 +1,85 @@ +use std::path::Path; + +use killall_agent::tools; +use rig_agent::AgentBuilder; +use rig_core::test_utils::{MockCompletionModel, MockTurn}; +use serde_json::{Value, json}; + +async fn run_tool(workspace: &Path, name: &str, args: Value) -> String { + let model = MockCompletionModel::from_turns([ + MockTurn::tool_call("tool-call", name, args), + MockTurn::text("Inspection complete"), + ]); + let agent = AgentBuilder::new(model.clone()) + .tool_server_handle(tools::load(workspace).unwrap()) + .default_max_turns(2) + .build(); + + let response = agent.prompt("Inspect the workspace").await.unwrap(); + assert_eq!(response.to_string(), "Inspection complete"); + + let requests = model.requests(); + assert_eq!(requests.len(), 2); + assert_eq!( + requests[0] + .tools + .iter() + .map(|tool| tool.name.as_str()) + .collect::>(), + ["read", "list", "search"] + ); + let results = requests[1] + .chat_history + .iter() + .flat_map(|message| message.results()) + .collect::>(); + assert_eq!(results.len(), 1); + let result = results[0]; + assert_eq!(result.call.to_string(), "tool-call"); + assert_eq!(result.name.as_str(), name); + assert!(!result.is_error, "{result:?}"); + result + .content + .iter() + .map(|content| content.to_text("image")) + .collect::>() + .join("\n") +} + +#[tokio::test] +async fn read_returns_workspace_file_contents_to_the_model() { + let workspace = tempfile::tempdir().unwrap(); + std::fs::write(workspace.path().join("sample.txt"), "workspace content\n").unwrap(); + + let output = run_tool(workspace.path(), "read", json!({"path": "sample.txt"})).await; + + assert!(output.contains("workspace content"), "{output}"); +} + +#[tokio::test] +async fn list_returns_workspace_entries_to_the_model() { + let workspace = tempfile::tempdir().unwrap(); + std::fs::write(workspace.path().join("sample.txt"), "content\n").unwrap(); + + let output = run_tool(workspace.path(), "list", json!({"path": "."})).await; + + assert!(output.contains("sample.txt"), "{output}"); +} + +#[tokio::test] +async fn search_returns_workspace_matches_to_the_model() { + let workspace = tempfile::tempdir().unwrap(); + std::fs::write(workspace.path().join("sample.txt"), "distinctive needle\n").unwrap(); + std::fs::write(workspace.path().join("unrelated.txt"), "no match here\n").unwrap(); + + let output = run_tool( + workspace.path(), + "search", + json!({"pattern": "needle", "path": "."}), + ) + .await; + + assert!(output.contains("sample.txt"), "{output}"); + assert!(output.contains("distinctive needle"), "{output}"); + assert!(!output.contains("unrelated.txt"), "{output}"); +}