Commit Graph

202 Commits

Author SHA1 Message Date
Levi Neely fa127f1d44 Reduce idle window from 30 to 15 seconds before prompting agents 2026-02-17 14:40:21 +01:00
Levi Neely 35b3ff338e Fix 9p-read-inbox to strip .json extension when marking messages complete 2026-02-17 14:37:46 +01:00
Levi Neely 72ffd90bf3 Add Claude hooks integration for AnviLLM
- Created install-claude-hooks.sh to merge hooks into existing settings.json
- Updated mkfile to use merge script instead of overwriting settings.json
- Made agent name configurable via CLAUDE_AGENT_NAME env var
- Added Claude agent configuration and hook scripts
- Removed unused NewClaudeWithContinue/NewClaudeWithResume functions
2026-02-17 10:27:59 +01:00
Levi Neely 50f8cde2ee Remove reserved flag and fix state transitions
- Remove reserved flag and all reservation logic (unnecessary for kiro-cli)
- Fix session ID file creation: detect kiro-cli runs directly in pane
- Add retry loop for FindBackendPID with kiro-cli detection
- Update hooks to use PPID's parent (kiro-cli PID) instead of 15569
- Remove 5-second delay from running->idle transition
- Clean up workflow scripts: remove explicit skill references and communication protocol sections
- Update researcher roles to use knowledge base, web, and codebase
2026-02-16 23:07:35 +01:00
Levi Neely 7dc3e6f4b5 Add state machine verification and error recovery transitions
- Created STATE_MACHINE_VERIFICATION.md documenting all states and transitions
- Added error→idle transition for manual recovery from error state
- Added error→starting transition for restart from error state
- Verified all 21 transition call sites across codebase
2026-02-16 20:46:30 +01:00
Levi Neely 825ce1e415 Implement state machine improvements with reservation system and condition variables 2026-02-16 20:26:50 +01:00
Levi Neely d95b18dab4 Fix: Transition to idle for all outbox messages
Agents were getting stuck in 'running' state after sending messages
to user. Previously only peer messages triggered idle transition.

Now all outbox messages (user and peer) trigger transition to idle,
allowing agents to receive new messages and preventing stuck states.

Verified by comprehensive state machine simulation covering all
transitions, edge cases, concurrency, and session lifecycle.
2026-02-16 18:13:41 +01:00
Levi Neely 9d58f8a9fc fix(session): synchronous message delivery with proper retry handling
- Drain all outbox messages in batch instead of one per tick
- Process inbound messages synchronously to ensure delivery before completion
- Keep failed messages in inbox for retry instead of re-delivering
- Simplify control flow with early continue pattern
2026-02-16 17:12:44 +01:00
Levi Neely c1b3f525da anvilweb: fix attach button, improve UI
- Fix Attach button to launch foot terminal with tmux attach
- Add tmux file to 9P server to expose session:window target
- Replace action buttons with cleaner layout: main actions visible,
  secondary actions in dropdown menu
- Add browser notifications for session state changes
- Preserve open dropdown menu across table refresh
- Remove disabled state from Prompt button (mailbox queues prompts)
2026-02-16 16:41:58 +01:00
Levi Neely 0dd4980392 p9: auto-transition sender to idle on peer message
When an agent sends a message to another agent (not user),
automatically set sender state to idle. This ensures agents
can receive responses without needing explicit STATUS_UPDATE.
2026-02-16 16:01:58 +01:00
Levi Neely 9ff6262d62 Rename peer-bot skill to anvillm-communication
- Rename skill to reflect broader scope (agent-to-agent, agent-to-user)
- Add AnviLLM references to all workflow agent contexts
- Update README example to use mailbox pattern
- Fix heredoc delimiter conflict (EOF -> MSGEOF) in injected prompt
2026-02-16 15:35:46 +01:00
Levi Neely e95c9ad8cd Simplify idle transition via mailbox
Message to user now triggers idle state automatically.
Removed separate idle signal instruction from prompts.
Single action (send to user) replaces two-step process.
2026-02-16 15:11:39 +01:00
Levi Neely 7b950c4eef Add user mailbox for unified communication
- Add agent/user/ directory with inbox/outbox/completed
- User is first-class participant (not a session)
- Bot->user: bot writes to outbox with to="user"
- User->bot: user writes to user/outbox with to="{session-id}"
- User inbox messages written to sender's log file
2026-02-16 15:05:51 +01:00
Levi Neely e6766999dc fix: overly aggressive error state detection 2026-02-16 09:33:21 +01:00
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