Commit Graph

355 Commits

Author SHA1 Message Date
Levi Neely 4bfbe3cc62 Add beads and session management tools for MCP 2026-02-28 18:51:10 +01:00
Levi Neely 8a5d9e8518 Allow bot assignment for subdirectories of project mount 2026-02-28 18:43:21 +01:00
Levi Neely 95efd907fb Add frontend support for mountable beads and remove global mount state
- Add mount management UI to all frontends (anvillm TUI, Assist, anvilwebgw, anvillm.el)
- Mount commands default to directory basename if name not specified
- Server validates directory exists before mounting
- Umount accepts either mount name or cwd path
- Fix server bug: all beads operations now use mount-specific store
- Remove currentMount global - all operations require explicit mount parameter
- Each Tasks window tracks its own windowMount independently
- Bead detail windows receive mount from parent window
- When no mounts exist, show instructions to mount a project
- When unmounting current mount, switch to first available or show empty state
- Mount validation: Select command checks mount exists before switching
- Database path: ~/.beads/<cwd-hyphenated> to prevent cross-contamination
2026-02-28 13:35:46 +01:00
Levi Neely 1e3623920e Add mountable beads projects with per-project databases
- Mount projects: echo "mount /path/to/project name" | 9p write agent/beads/ctl
- Unmount: echo "umount name" | 9p write agent/beads/ctl
- All beads endpoints work in mounts (list, ready, pending, blocked, etc.)
- Add agent/beads/mtab for mount discovery (mount→cwd mappings)
- Store databases at ~/.beads/<cwd-hyphenated> to prevent cross-contamination
- Supervisor auto-assigns claimable beads to idle bots with matching cwd
- Fix supervisor duplicate messages (track assigned beads, filter by assignee)
- Update beads skill with mtab discovery pattern
- Fix race conditions and add proper locking for mount access
2026-02-28 11:35:19 +01:00
Levi Neely 425fa53877 Update beads and p9 implementation 2026-02-27 21:16:03 +01:00
Levi Neely cbace3407c Update changes 2026-02-27 12:12:08 +01:00
Levi Neely 0b612aa0cc Add logging.Init() to all cmd programs
- anvilwebgw: init logging in startCmd
- anvilweb: init logging in main
- anvillm: init logging in main
- Assist: init logging in main

Each program now creates its own timestamped log file
2026-02-27 11:51:50 +01:00
Levi Neely 521f785313 Use timestamped log files: ~/.config/anvillm/logs/<timestamp>-<progname>.log 2026-02-27 11:48:35 +01:00
Levi Neely 2111f19e9f Add zap logging to ~/.config/anvillm/logs with panic recovery
- Created internal/logging package with zap logger
- Added panic recovery to anvilsrv main loop, monitor goroutine, and mail processing
- Replaced log.Printf/Fatal with zap in debug, p9, tmux packages
- Fixed beads race condition: clear assignee before closing issue
- All errors and crashes now logged to ~/.config/anvillm/logs
2026-02-27 11:46:49 +01:00
Levi Neely f252aa9452 Add sandbox enforcement to mcptools scripts 2026-02-27 00:25:01 +01:00
Levi Neely 17ec56fbdd Update messaging skill and execute command 2026-02-27 00:06:13 +01:00
Levi Neely 1f42297107 Fix skills help path: prepend 'agent/' when reading /skills/ paths 2026-02-26 23:51:41 +01:00
Levi Neely 5b567ba5b3 Fix all linting issues in internal/p9
- Replace interface{} with any
- Use strings.CutPrefix instead of HasPrefix+TrimPrefix
- Use strings.SplitSeq for efficiency
- Use slices.Contains instead of manual loops
- Use tagged switches for clarity
- Remove debug logging
2026-02-26 23:12:15 +01:00
Levi Neely 83c9136bdf fix: p9 unused parameter and containsBdRef bounds check 2026-02-26 22:58:32 +01:00
Levi Neely e064f926bf fix: p9 race condition, duplicate handlers, bounds checks, path validation 2026-02-26 22:56:58 +01:00
Levi Neely ccc80eabc7 fix: path inconsistency in skills.go and race conditions in server.go 2026-02-26 22:53:09 +01:00
Levi Neely 631c9fb47e Fix race conditions and path traversal bugs in internal/p9
- Fix race in open(): hold lock during fid modification
- Fix race in write(): copy path before unlock
- Fix race in remove(): read sessionID under lock
- Fix panic in walk(): guard empty qids slice
- Fix sessionID tracking: always update to current session
- Fix path traversal in skills.go: use filepath.Clean + bounds check
- Fix path traversal in tools.go: use filepath.Clean + separator check
- Fix repeated array access in beads.go: extract beadID variable
2026-02-26 22:40:56 +01:00
Levi Neely 2b5e739014 fix: resolve 6 bugs in internal/p9
- Fix race condition in server.go defer cleanup
- Add nil check after GetIssue in beads.go
- Replace strings.Trim with TrimPrefix to fix path traversal (beads.go, skills.go, tools.go)
- Remove unused role parameter in readReady
- Use RLock instead of Lock in read operation
- Add error check for os.Getwd
2026-02-26 22:34:43 +01:00
Levi Neely addcf0a978 Fix crash bugs: remove impossible nil checks, add bounds check for strings.Fields
- mailManager guaranteed non-nil by constructor, removed defensive checks
- Added bounds check for strings.Fields()[0] in slash command validation
- Removed impossible nil check in processMailboxes()
2026-02-26 22:28:16 +01:00
Levi Neely c10a008f3d install mcptools and skills to default dir 2026-02-26 20:21:31 +01:00
Levi Neely 78b95f4709 Final skill optimization pass
Compressed web-dev-browser-screencapture to task:command format.

Final token counts:
- acme-api: ~684 tokens
- rc-shell: ~591 tokens
- denote: ~543 tokens
- agent-kb: ~501 tokens
- github-cli: ~488 tokens
- All others: <450 tokens

Total: ~5,681 tokens (was ~18,000+)
Savings: ~12,300 tokens (68% reduction)

All skills now follow consistent, concise format.
2026-02-26 20:10:25 +01:00
Levi Neely 010e7ac7ff Move capture-browser to mcptools, remove unused files
- Moved capture-browser.sh to mcptools/capture_browser.sh with frontmatter
- Removed ddgr.help.txt (unused)
- Compressed web-dev-browser-screencapture skill
- Removed scripts directory

Saves ~550 tokens, consolidates tools in mcptools.
2026-02-26 20:06:58 +01:00
Levi Neely 9a12c35168 Remove acme-api supporting docs
Deleted examples.md, event-protocol.md, file-reference.md, quick-reference.md.
All essential info now in compressed SKILL.md.

Saves ~13,500 tokens.
2026-02-26 20:03:59 +01:00
Levi Neely e1df81fda6 Compress skills and add network tools
- Compressed skills to <500 tokens each (except rc-shell at 591)
  - beads: 535→59 lines (89% reduction)
  - rc-shell: 270→98 lines (64% reduction)
  - acme-api: 228→85 lines (63% reduction)
  - write-skills: 141→71 lines (50% reduction)
  - github-cli: 133→76 lines (43% reduction)
  - agent-kb: 111→70 lines (37% reduction)
  - jira-to-beads: 129→49 lines (62% reduction)
  - github-to-beads: 109→49 lines (55% reduction)

- Added mcptools for network operations
  - jira-to-beads: fetch Jira hierarchy, create beads
  - github-to-beads: fetch GitHub issues, parse task lists, create beads

- Updated execute_code landrun permissions
  - Added --unrestricted-network for API calls
  - Added user bin dirs: ~/bin, ~/.local/bin, ~/opt, ~/go/bin, $PLAN9/bin

- Documented beads delete behavior (no cascade)

Total token savings: ~2,400 tokens across all skills
2026-02-26 20:02:24 +01:00
Levi Neely 1fb7038419 ls before help 2026-02-26 15:48:48 +01:00
Levi Neely e754fe1759 Update OUTPUT_PROTOCOL.md and SKILLS_PROMPT.md 2026-02-26 15:45:58 +01:00
Levi Neely aa5e1500c5 SKILLS_PROMPT: reduce verbosity, enforce skill-first behavior 2026-02-26 15:28:48 +01:00
Levi Neely ce28a33c0c Simplify anvillm-communication skill, fix tool paths 2026-02-26 15:26:48 +01:00
Levi Neely a5b73adca8 SKILLS_PROMPT: fix 9p paths to use agent/ prefix 2026-02-26 15:18:27 +01:00
Levi Neely 51a078c469 SKILLS_PROMPT: use 9P filesystem for skill discovery 2026-02-26 15:16:05 +01:00
Levi Neely 1120da18d9 anvillm-hook: simplify agentSpawn to always use SKILLS_PROMPT.md 2026-02-26 15:15:12 +01:00
Levi Neely a6b85b6970 skills: add uncategorized intent for skills without intents 2026-02-26 15:08:03 +01:00
Levi Neely 031de8e240 p9: intent-based skills discovery
- Add SkillsFS with intent-based virtual directories
- /skills/help aggregated index: intent/skill-name<tab>description
- Parse YAML front-matter for intent: field
- Add intent: to all existing skills
2026-02-26 14:56:00 +01:00
Levi Neely 4b0bf70794 Remove unused tools: test.sh, set_state.sh 2026-02-26 14:39:09 +01:00
Levi Neely d26e4b5347 Add front-matter to tool scripts 2026-02-26 14:37:45 +01:00
Levi Neely 8b87e3514a Move tool scripts from cmd/anvilmcp to mcptools/ 2026-02-26 14:36:50 +01:00
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