Commit Graph

38 Commits

Author SHA1 Message Date
Levi Neely 51679e5661 Implement mailbox system for bot-to-bot communication
- Add mailbox manager with inbox/outbox/completed structure
- Expose mailboxes via 9P filesystem (agent/{id}/inbox, outbox, completed)
- Mail processor runs every 5s to deliver messages from outbox to inbox
- Messages delivered when recipient is idle, formatted and sent via in file
- Retry logic: 3 attempts max, then discard with notification to sender
- Race condition fixes: messages moved to completed before sending
- Auto-generate message ID and timestamp if missing from bot's JSON
- Update peer-bot skill to use mailbox system with JSON format
- Update all workflows (DevReview, DevReviewQA, Planning) with:
  - Explicit shell command examples for sending messages
  - plan9 task for all agents
  - Mailbox instructions without markdown code blocks
- Fix idle signaling: bots must write summary to out BEFORE signaling idle
- All messages archived in completed/ with proper metadata
2026-02-15 21:16:00 +01:00
Levi Neely 873f839278 Implement layered sandbox configuration system
- Add global.yaml base config (renamed from sandbox.yaml)
- Add backend-specific configs (claude.yaml, kiro-cli.yaml)
- Add role configs (developer, reviewer, tester, architect, etc.)
- Add task configs (git, docker, go, rust, python, nodejs, etc.)
- Implement config merging: global + backend + role + tasks
- Update workflows to use roles and tasks
- Create tester role with read-only source, execute-only bins
- Fix reviewer role to use rox for bin directories
- Auto-create RW directories that don't exist
- Make backend configs required (fail if missing)
- Update mkfile to install cfg files to ~/.config/anvillm
- Remove Role-Based Sessions from IDEAS.md (now implemented)
2026-02-15 18:57:55 +01:00
Levi Neely 2c0196fbe9 Add idle state signaling and output summary support 2026-02-15 10:57:18 +01:00
Levi Neely a10a70bebd Fix deadlock in agent chat log and improve response tracking
- Add chat log support with new 'log' file (read) and 'out' file (write)
- Fix deadlock: create appendToChatLogLocked for callers holding mutex
- Improve prompts to request comprehensive summaries with actual response text
- Enforce 2MB chat log size limit with smart truncation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-15 10:20:32 +01:00
Levi Neely bef457a3aa Qualify tmux sessions per-namespace
- Extract namespace suffix (e.g., '0' from '/tmp/ns.user.:0/')
- Append suffix to tmux session names (e.g., 'anvillm-kiro-cli-0')
- Allows multiple namespace instances to coexist without conflicts
- Updated backend constructors to accept namespace suffix parameter
2026-02-14 18:35:35 +01:00
Levi Neely 452fc41ea5 basic self-healing 2026-02-14 17:51:28 +01:00
Levi Neely 4a79985bcf explicit signaling for process states 2026-02-14 14:33:57 +01:00
Levi Neely b7a823f120 feat: split monolith into anvilsrv daemon and Assist client
Major architectural refactoring to separate server and UI concerns:

Architecture Changes:
- Split into anvilsrv (server daemon) and Assist (Acme client)
- Removed UI coupling from server (OnAliasChange, WinID tracking)
- Server runs as background daemon, client reconnects as needed
- Client auto-starts server if not running

Server (anvilsrv):
- Add daemon management: start/stop/status commands
- Daemonize by default (fgstart for foreground/debug mode)
- Proper PID file handling in $NAMESPACE (not /tmp)
- Graceful shutdown with SIGTERM handling
- Duplicate start prevention with stale PID detection

Client (Assist):
- Auto-start anvilsrv if not running
- Fixed plan9 package imports (OWRITE/OREAD constants)
- Removed unused context import

Security Fixes:
- Move PID file from /tmp to $NAMESPACE (prevent symlink attacks)
- Add path validation in session creation:
  - Clean path traversal (/../../../etc → /etc)
  - Verify directory exists before creating session
  - Ensure absolute paths
  - Reject non-directory paths
- Add SECURITY.md documenting 9P socket risks

Service Integration:
- Add systemd service files (system, user, template)
- Add runit service files (run, finish)
- Add service documentation and installation instructions

Build & Testing:
- Both binaries build successfully
- All daemon operations verified (start/stop/status/daemonize)
- Path validation tested and working
- Auto-start functionality verified
- Add DevReviewQA workflow script

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-14 11:30:57 +01:00
Levi Neely c445b21206 fix: Stop now preserves tmux window by tracking backend PID
The Stop() method was destroying the tmux window because it killed the
bash shell (pane PID) instead of just the backend process. This commit
fixes the issue by:

1. Added FindBackendPID() to find the actual backend process (child of bash)
2. Modified session creation to store the backend PID, not the shell PID
3. Updated stopInternal() to kill only the backend process:
   - Send Ctrl+C (handles SIGINT)
   - Send second Ctrl+C if still alive (some CLIs need 2x)
   - Use SIGTERM/SIGKILL on backend PID if unresponsive
   - Never kill the bash shell, preserving the tmux window
4. Fixed Restart() to properly clean up and recreate FIFO

Tested successfully:
- Stop kills backend but preserves window ✓
- Session state transitions to "stopped" ✓
- Restart reuses same window and works ✓
- Can send prompts after restart ✓

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-14 10:28:06 +01:00
Levi Neely e25d1658dd feat: add Stop/Restart support and fix critical deadlock bug
Add Stop and Restart commands for session management, allowing graceful
termination and restart of backend processes. Add peer-bot skill for
agent-to-agent communication via 9P filesystem.

Critical fixes:
- Fix double-unlock deadlock in Stop() that would cause immediate panic
- Fix resource leak in Restart() where transitioning flag wasn't cleared on error paths
- Fix race conditions in reader() goroutine from multiple lock/unlock cycles
- Fix busy loop in reader() after EOF by using proper wait loop instead of polling FIFO

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-14 09:47:02 +01:00
Levi Neely 341436a6fd feat: add Refresh command to re-detect session state
- Expose via Acme tag bar and 9P ctl file
- No arg refreshes all sessions, with arg refreshes one
2026-02-13 15:05:11 +01:00
Levi Neely e28d39aab6 fix: improve kiro-cli state detection and add Refresh method
- IsBusy now checks /proc/PID/stat for process state (R/D = busy)
  when no child processes exist, fixing false idle detection
- Add Refresh() to Session interface to re-detect state on demand
2026-02-13 15:03:27 +01:00
Levi Neely f31ea21d5f Remove unused err file from 9P filesystem 2026-02-13 11:47:02 +01:00
Levi Neely 2df14ce071 fix bot-to-bot interaction in claude? 2026-02-13 07:54:06 +01:00
Levi Neely 483ada27d8 bugfix in ctl new, dev-reviewer flow create script 2026-02-12 19:41:51 +01:00
Levi Neely b20f6e95db remove dead/wasteful code 2026-02-12 18:45:29 +01:00
Levi Neely 255c939b2f non-blocking 9p in 2026-02-12 18:23:18 +01:00
Levi Neely fe56df8930 Replace quiescence detection with process tree inspection
Detect idle state by checking if kiro-cli-chat has tool children
rather than relying purely on output quiescence. Fixes premature
idle detection during long-running processes like remote builds.
2026-02-12 16:01:24 +01:00
Levi Neely 6e9a4c612e Add session context, summary, and bot-to-bot communication support
- Add context field to sessions (prepended to every prompt)
- Add summary field (first 100 chars of last response)
- Expose context/summary via 9p filesystem
- Add Alias and Context commands to acme UI
- Improve notify script to show cwd basename and summary
- Simplify Kill command to use session ID instead of PID
- Update list format to include alias column
- Add IDEAS.md notes on bot-to-bot communication
2026-02-12 14:59:35 +01:00
Levi Neely 213dededb4 Add grace time for shell initialization in tmux sessions 2026-02-12 09:04:47 +01:00
Levi Neely f104c6aa5e rethink save/load 2026-02-11 11:35:08 +01:00
Levi Neely 3f570e993e kiro fixes 2026-02-11 09:35:28 +01:00
Levi Neely 326c512976 env support for sandbox 2026-02-11 09:15:59 +01:00
Levi Neely 27530827d7 update docs, never disable sandbox 2026-02-11 08:48:06 +01:00
Levi Neely 528a482fe8 basic sandboxing support with landrun, fail fast 2026-02-11 08:32:14 +01:00
Levi Neely d8fcb8fc89 rm dead code 2026-02-10 22:33:30 +01:00
Levi Neely d76236b95b fix: user messages to stdout/stderr 2026-02-10 22:28:01 +01:00
Levi Neely 3ef93944a1 fix: load session in kiro 2026-02-10 22:20:31 +01:00
Levi Neely 460a6fd75f support multiple backends per Assist instance 2026-02-10 22:02:15 +01:00
Levi Neely 6cb61a7a32 debug mode, don't print to main window, rename go module and main window 2026-02-10 21:45:27 +01:00
Levi Neely 8b80aa0fa9 fix process status display 2026-02-10 21:28:27 +01:00
Levi Neely 20c6255b08 fix process manager 2026-02-10 21:18:15 +01:00
Levi Neely 9be10a14de switched kiro to use tmux instead of pty, probably still buggy 2026-02-10 20:36:25 +01:00
Levi Neely d33bede0f1 warn unsupported actions, attach to tmux from acme, etc. 2026-02-10 20:01:18 +01:00
Levi Neely e7059b94fb claude basic chat support implemented 2026-02-10 11:55:10 +01:00
Levi Neely 5cd8cbc28f refactor done; claude support wip 2026-02-09 21:26:11 +01:00
Levi Neely 7ca987e6eb refactor in progress 2026-02-09 19:45:42 +01:00
Levi Neely d8dccd94b3 initial commit 2026-02-09 17:57:42 +01:00