Commit Graph

319 Commits

Author SHA1 Message Date
Levi Neely 8a55b99864 p9: capability-based tools discovery
- Add front-matter parsing for capabilities/description in tool scripts
- Virtual capability directories: tools appear in multiple caps
- /tools/help aggregated one-liner index
- Update walk/readDir for /tools/<capability>/<tool.sh> paths
2026-02-26 14:36:30 +01:00
Levi Neely 5f8c41b576
Implement MCP code execution pattern (#20)
* Implement MCP code execution pattern

- Add execute_code tool for bash execution in landrun sandbox
- Remove redundant MCP tools (read_inbox, send_message, etc.)
- Implement dynamic tool discovery from ~/.config/anvillm/mcptools/
- Add workspace isolation (~/.cache/anvillm/exec)
- Add security: output limits, concurrency limits, validation, path traversal protection
- Update bot templates (Conductor, Taskmaster) with bash examples
- Update anvillm-communication skill to use execute_code pattern
- Create comprehensive documentation (user guide, migration guide, security guide)
- Add test suite for validation and limitedWriter
- Fix landrun flags: --rox for executables, --env for AGENT_ID passthrough
- Network blocked by default (no --connect-tcp or --unrestricted-network)

Token reduction: 80-99% via progressive tool discovery and subprocess data processing

* Fix code review issues in MCP code execution pattern

- Security: Change security.jsonl permissions from 0644 to 0600
- Bug: Fix limitedWriter to return correct byte count for io.Copy
- Bug: Fix tool schema inconsistency (execute_code requires only 'code')
- Performance: Move whitespace regex to package-level var
- Security: Improve validateCode with regex patterns and normalization
- Cleanup: Remove dead code from main.go and tools.go
- Cleanup: Rewrite shell scripts to use jq for safe JSON construction
- Docs: Fix duplicate sections and JavaScript syntax in bash examples

* Improve code validation security patterns

- Fix rm -rf bypass: allow optional whitespace before /
- Expand rm -rf to block sensitive paths (/home, /var, /usr, etc.)
- Block all network protocols in curl/wget (not just http/https)
- Add test for regex pattern compilation
- Add test cases for tabs, sensitive paths, ftp/file protocols

* Harden shell scripts and improve rate limiting

---------

Co-authored-by: Levi Neely <lkn@darkstar.example.net>
Co-authored-by: Levi Neely <lneely@pascom.net>
2026-02-26 14:02:54 +01:00
Levi Neely 2418f12012 Fix review findings from code review
- Include model in session list output (eliminates N+1 reads)
- Add jq error handling in Supervisor dispatch_ready_beads
- Use process substitution in Supervisor to avoid subshell variable scope
- Fix claude backend Execute to return error (commands go through PTY)
- Make createSubtask return childID (eliminates duplicate O(n) scan)

Fixes: bd-1z2, bd-73r, bd-cid, bd-viu, bd-vdi
2026-02-26 12:05:28 +01:00
Levi Neely 439faf3e98 Add review gate, researcher routing, and slash command support
- Conductor: spawn per-worktree researcher, route worker QUERY_REQUESTs
  through researcher, add post-completion review gate with Reviewer bot,
  auto-approve trivial/docs/config beads
- Taskmaster: handle review rejection by parsing findings into new beads
- claude.go: enable slash command support (pass through to Claude CLI)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-25 19:17:50 +01:00
Levi Neely 700853b8b7 Strip exploration capability from Supervisor worker bots
Workers now send QUERY_REQUEST to user and go idle when needing
information, instead of exploring codebase themselves.

Refs: bd-env.5
2026-02-25 19:17:50 +01:00
Levi Neely 5bcaa38ad7 cost / usage optimization, phase 1 2026-02-25 19:17:50 +01:00
Levi Neely 50ae907741 anvilwebgw: read message timestamp from JSON instead of filename 2026-02-25 15:03:36 +01:00
Levi Neely 74eec073d3 anvilwebgw: fix session list field mapping (alias/backend swap) 2026-02-25 14:57:27 +01:00
Levi Neely 312d2c987d anvillm.el: add ~ path translation for display and input 2026-02-25 14:27:10 +01:00
Levi Neely 1727cb31e7
Merge pull request #15 from lneely/optimize-bead-desc-quality
Optimize bead description quality (bd-3bu)
2026-02-24 13:21:22 +01:00
Levi Neely 18a6448b37 Add extended linting rules and Acme file addressing (bd-9y4, bd-iti)
Extends lintDescription() with 8 new rules: Acme address format correction
(file:N-N → file:N,N), imperative verb start, vague language detection, how
signal, no first-person voice, forbidden vague phrases, inline code (backticks),
and cross-reference on long descriptions (>150 chars). Updates containsLineRef()
to also recognise #N char-position addresses; adds containsAcmeRegexAddr(),
containsHyphenRange(), and containsBdRef() helpers. Adds 32 tests covering every
rule in beads_lint_test.go.

Updates bot-templates/Conductor (6-question cold-completion gate, File Addressing
section), bot-templates/Taskmaster (File Addressing section with grammar
reference), and skills/beads/SKILL.md (Description Quality section with full lint
rule table and Acme addressing guide).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-24 13:07:52 +01:00
Levi Neely 312276582b Optimize bead description quality (bd-3bu)
- Add description lint check to beads new command (bd-3bu.3):
  warns to stderr on missing file path, function/line ref, short
  description, or missing acceptance criterion; --no-lint and
  IDEA:-prefixed titles bypass lint

- Add post-completion write-back convention to beads SKILL.md
  (bd-3bu.2): quality ratings good/missing-location/missing-pattern/
  too-vague, plus anti-pattern for closing without a quality comment

- Update Taskmaster prompt with five-field schema, KB query
  requirement, and type-specific templates bug/feature/refactor/idea
  (bd-3bu.1, bd-3bu.4)

- Add P1/P2 cold-completion gate to Conductor prompt (bd-3bu.5):
  five-question checklist before assigning high-priority beads to bots

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-24 13:07:51 +01:00
Levi Neely 80a9c4f57d hotfix: clarify PROMPT_RESPONSE body format for questions vs tasks in agent template
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-24 13:04:43 +01:00
Levi Neely 029644d46f hotfix: clarify PROMPT_RESPONSE schema applies only to tasks, not questions
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-24 13:03:10 +01:00
Levi Neely 6b2d7dc853 hotfix: claude mcp install 2026-02-24 13:00:37 +01:00
Levi Neely ac8f70ba11 hotfix: claude backend cfg 2026-02-24 12:54:41 +01:00
Levi Neely 2e1c2d8849 hotfix: claude in sandbox 2026-02-24 12:50:05 +01:00
Levi Neely 572ac91d86 Set CLAUDE_CONFIG_DIR at startup and propagate to tmux/shell/sandbox
- anvilsrv sets CLAUDE_CONFIG_DIR to ~/.config/anvillm/claude on start
  if not already set in the environment
- Claude backend includes CLAUDE_CONFIG_DIR in its Environment map so
  it is set in the tmux session and exported to the shell
- tmux backend now exports all b.cfg.Environment vars to the shell
  (via sendKeys) in addition to setting them in the tmux environment,
  both on CreateSession and Restart
- cfg/backends/claude.yaml adds CLAUDE_CONFIG_DIR to the sandbox env
  whitelist so landrun passes it through to the Claude process

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-24 11:49:02 +01:00
Levi Neely 4d79be5177
Merge pull request #16 from lneely/worker-bots-bugfix
Fix worker bot bead protocol in Conductor template
2026-02-24 08:35:19 +01:00
Levi Neely 3a8d00aeec Remove redundant worker bead protocol from Conductor template
The protocol is now canonically defined in skills/beads/SKILL.md,
which all agents load. No need to inject it verbatim into worker contexts.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-24 08:34:21 +01:00
Levi Neely 0f9d441a04 Add hierarchical completion protocol to beads SKILL.md
All bots load this skill, so codifying the child-before-parent completion
rule here makes it universal — not just for Conductor-spawned workers.
Adds a dedicated protocol section, updates Recommended Workflow and
Session Workflow steps, and adds a NEVER anti-pattern entry.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-24 08:34:21 +01:00
Levi Neely 208585dfe4 Fix worker bot bead protocol in Conductor template
Clarify that workers should receive their specific child bead ID (not
parent), and add explicit worker bead protocol steps covering claim,
grandchild checking, and completion sequence.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-24 08:33:57 +01:00
Levi Neely 5d644c467f
Merge pull request #18 from lneely/agent-kb-integration
Add KB protocol integration across bot templates and skills
2026-02-24 08:28:31 +01:00
Levi Neely 0367aa58fc Add KB protocol integration across bot templates and skills
- Add _kb-protocol.md shared protocol document for KB usage rules
- Integrate KB protocol into Conductor and Taskmaster bot templates
- Add denote skill (file naming/frontmatter conventions)
- Refactor agent-kb SKILL.md to defer file naming to denote skill
- Add staleness handling table to agent-kb SKILL.md
- Update beads SKILL.md workflow to include KB lookup step

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-24 07:45:38 +01:00
Levi Neely 88c68720bf
Merge pull request #14 from lneely/tasks-as-context
Add context-leaving guidance to beads skill (bd-3r1)
2026-02-23 22:25:38 +01:00
Levi Neely c43ebc5b7e Add 'Leaving Context for Future Agents' section to beads SKILL.md
Prompts agents to comment on beads with decisions, dead ends, and
discoveries during execution, and to search past beads before starting
non-trivial work. Covers human-authored comments as equally authoritative
context. Implements bd-3r1.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-23 22:23:18 +01:00
Levi Neely 98a659e411 hotfix: mkfile 2026-02-23 22:03:12 +01:00
Levi Neely 96876ea6c8
Add output discipline enforcement (bd-nk8) (#13)
- OUTPUT_PROTOCOL.md: shared protocol injected at session start for all backends
- anvillm-hook: injects OUTPUT_PROTOCOL.md via Kiro agentSpawn
- claude/agent/anvillm-agent.md: Output Protocol section (Claude session-start equivalent)
- bot-templates: Output Protocol block in Conductor and Taskmaster contexts
- anvillm-communication skill: structured body schemas for all message types
- install-hooks.sh: also installs anvillm-agent.md to ~/.claude/agents/
- kiro-cli/README.md: install instructions for prompt files

Co-authored-by: Levi Neely <lkn@darkstar.example.net>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-23 21:48:58 +01:00
Levi Neely 065e4a3295
Add bulk-archive via inline Put notation to inbox and archive windows (#12)
* Add inline Put actions for sessions and tasks windows

Introduce a Put command to both the sessions list and tasks windows,
allowing inline edits via prefixed annotations in the body:

Sessions (cmd/Assist/main.go):
  - `- <id>`              Kill session
  - `~ <id>`              Stop session (graceful)
  - `@ <id> <alias>`      Set alias on session
  - `+ <backend> <path> [alias]`  Start new session

Tasks (cmd/Assist/main.go + internal/p9/beads.go):
  - `- [idx]`   Delete bead
  - `~ [idx]`   Claim bead as user
  - `^ [idx]`   Unclaim bead (clear assignee, reset to open)
  - `x [idx]`   Complete bead
  - `f [idx]`   Fail bead
  - `+ <title>` Create new bead with title pre-filled

Also adds `unclaim` ctl command to BeadsFS and helper functions:
claimBeadAsUser, unclaimBead, completeBead, failBead,
openNewBeadWindowWithTitle.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Add [Failed] [PendingReview] [PendingApproval] filters to tasks window

Extends the tasks window filter bar with three new status filters:

- [Failed]          closed beads whose close_reason != "completed"
- [PendingReview]   beads with status "pending_review"
- [PendingApproval] beads with status "pending_approval"

Implementation details:
- Add CloseReason field (json:"close_reason") to Bead struct so
  fail-vs-complete distinction is available after JSON decode.
- listBeadsWithFilter: add "failed" special case (closed beads with
  non-"completed" close_reason); "pending_review" and
  "pending_approval" fall through the existing status equality path.
- handleTasksWindow: wire Failed/PendingReview/PendingApproval cases
  to set statusFilter and refresh the list.
- refreshTasksWindowWithBeads: update filter bar header line.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Add bulk-archive via inline Put notation to inbox and archive windows

In the inbox window, lines prefixed with "- <shortID>" are parsed on Put
and each matching message is archived (moved to completed). In the archive
window the same notation permanently deletes the message from the archive.

Adds: parseMailEdits, mailEdit type, deleteArchivedMessage in Assist;
DeleteFromCompleted in mailbox.Manager; "delete <msg-id>" command on
user/ctl in the p9 server.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Levi Neely <lkn@darkstar.example.net>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-23 19:58:37 +01:00
Levi Neely 5bba76d2b9 hotfixes, msg trace diagram generator 2026-02-23 12:20:46 +01:00
Levi Neely 50ae1d0dad Add approval gates: beads schema, Conductor, notification daemon, init scripts
Implements bd-i4h (Approval Gates / Human in the Loop):

beads schema (bd-i4h.4):
- Add StatusPendingApproval/StatusPendingReview local status constants
- Add pending-approval, pending-review, resume ctl commands
- Add agent/beads/pending read endpoint
- Document requires-approval/requires-review label conventions
- Update BEADS.md with full Approval Gates section

Conductor bot (bd-i4h.2):
- Read context prompt from stdin when not a terminal (custom prompt support)
- Extend default prompt with approval gate workflow instructions

Human notification daemon (bd-i4h.1):
- Add scripts/anvillm-inbox-notify: streams agent/events, fires notify-send
  for configurable message types (default: APPROVAL_REQUEST, REVIEW_REQUEST)
- Add services/inbox-notify-runit/: runit service
- Add services/systemd/anvillm-inbox-notify.service: systemd user service
- Add services/sysvinit/anvillm-inbox-notify: SysV LSB init script
- Add services/sysvinit/rc.anvillm-inbox-notify: Slackware rc script

anvilsrv init scripts:
- Add services/sysvinit/anvilsrv: SysV LSB init script
- Add services/sysvinit/rc.anvilsrv: Slackware rc script

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-22 18:47:23 +01:00
Levi Neely 45e495a975
Add requires_approval and requires_review flags to bead UI across all frontends (#10)
Implements bd-258: display and toggle of requires_approval / requires_review
boolean flags in all four AnviLLM frontends. Flags are backed by labels
(requires_approval, requires_review) on each bead, read from the labels
array in bead JSON and toggled via label/unlabel ctl commands.

- Acme: adds Labels/HasLabel to Bead struct; shows flags in frontmatter;
  updateBead parses and applies label/unlabel on Put
- TUI: showBead displays flags (green when set); edit dialog adds two
  checkboxes that toggle labels on save
- Web: detail view shows flag status with Set/Unset buttons; new
  toggleBeadFlag() function calls beads ctl API and refreshes
- Emacs: detail buffer shows flag lines; A/R keybindings invoke new
  anvillm-bead-toggle-approval and anvillm-bead-toggle-review commands

Co-authored-by: Levi Neely <lkn@darkstar.example.net>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-22 18:13:12 +01:00
Levi Neely bb721c0429
Fix child relationship handling (#8)
* Fix child relationship handling

* Fix: Remove automatic dependency creation in createSubtask()

Parent-child relationships are hierarchical via ID structure only.
The server was incorrectly creating blocking dependencies between
parent and child beads, causing children to block parents.

---------

Co-authored-by: Levi Neely <lkn@darkstar.example.net>
2026-02-22 16:22:17 +01:00
Levi Neely db501cca26
Add approval/rejection flags and actions to tasks UI (#9)
* Add approval/rejection flags and actions to tasks UI

Adds visual flags for APPROVAL_REQUEST and REVIEW_REQUEST messages across
all UI frontends (Acme, TUI, web, Emacs), with one-click approve/reject
actions and inferred reply type mapping.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Auto-archive messages on approve or reject across all UIs

After an approval or rejection response is sent, the original inbox
message is now automatically completed/archived in all four frontends:

- Acme: handleReplyWindow gains an originalMsgID param; approve/reject
  windows pass the message ID so the original is archived on Send
- TUI: already archived via completeInboxMessage in approveMessage /
  rejectMessage — no change needed
- Web: approveCurrentMessage archives after reply succeeds; rejectCurrent-
  Message sets pendingArchiveId so the reply-form submit handler archives
  on send
- Emacs: anvillm-inbox-approve and anvillm-inbox-reject write "complete
  <id>" to user/ctl and refresh the inbox after sending the response

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Levi Neely <lkn@darkstar.example.net>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-22 15:38:23 +01:00
Levi Neely 4c4b906acd Add anvilmcp connection to Backends in architecture diagram 2026-02-22 12:52:46 +01:00
Levi Neely 3ef9cc54c0 Fix architecture diagram: Web connects to anvilwebgw via HTTP 2026-02-22 12:49:32 +01:00
Levi Neely 36c773bf45
Merge pull request #6 from lneely/bug-anvilweb-sessions-null
fix: handle null sessions case in anvilwebgw
2026-02-22 12:28:04 +01:00
Levi Neely 1b38cbb030
Merge pull request #7 from lneely/update-docs
Tech edit README: improve clarity, concision, and flow
2026-02-22 12:27:48 +01:00
Levi Neely 8fccaa8977 Make autonomous workflow diagram full-width 2026-02-22 12:25:21 +01:00
Levi Neely 36e5de7e3c Replace autonomous workflow with sequence diagram
- Shows full workflow: User → Taskmaster → Beads → Conductor → Bots
- Illustrates dependency management and completion notification
- Increased width to 600px for better readability
- Updated cache-busting to v=3
2026-02-22 12:24:01 +01:00
Levi Neely c5c07a3840 Increase automation workflow diagram to 300px 2026-02-22 12:20:28 +01:00
Levi Neely af83bc26df Rename to Autonomous Workflows and reduce diagram to 250px 2026-02-22 12:19:46 +01:00
Levi Neely b99954c214 Center all images and reduce sandbox config to 250px
- All diagrams now centered with <p align="center">
- Sandbox config reduced from 400px to 250px
2026-02-22 12:18:29 +01:00
Levi Neely 52be2d56c4 Remove leftover ASCII diagram after crash recovery SVG 2026-02-22 12:16:56 +01:00
Levi Neely b0bfc2d777 Scale down smaller diagrams
- sandbox-config: 400px
- session-lifecycle: 500px
- crash-recovery: 500px
- client-interactions: 400px
- events: 400px
- Keeps larger diagrams (architecture, mailbox, automation) at full width
2026-02-22 12:15:38 +01:00
Levi Neely cf83b07b04 Add cache-busting to SVG URLs and use default theme
- Add ?v=2 query parameter to all SVG URLs to bypass GitHub cache
- Regenerate with default theme as requested
2026-02-22 12:13:54 +01:00
Levi Neely 4bb5c4e743 Use forest theme for darker arrows
- Arrows now use #000000 (black) instead of #333333
- Much better visibility on all backgrounds
2026-02-22 12:12:13 +01:00
Levi Neely e3b3c111cd Use default theme for better contrast
- Regenerate SVGs with default theme
- Provides darker arrows and better visibility
2026-02-22 12:11:18 +01:00
Levi Neely b78f798db8 Use neutral theme for diagrams
- Regenerate all SVGs with neutral theme instead of dark
- Improves visibility on both light and dark backgrounds
- Better contrast for arrows and boxes
2026-02-22 12:09:32 +01:00
Levi Neely 41acc805d1 Replace ASCII diagrams with SVG images
- Create Mermaid source files for all diagrams
- Generate SVGs using mermaid-cli
- Replace all ASCII art with embedded SVG images
- Diagrams: architecture, sandbox-config, session-lifecycle, crash-recovery, client-interactions, mailbox-flow, automation-workflow, events
- Fixes alignment issues with ASCII box drawing characters
2026-02-22 12:08:12 +01:00