skills/src
dan 7660693717 feat(worker): add test suite and fix worktree DB path
Test infrastructure:
- Add comprehensive test-worker.sh with 59 tests
- Cover spawn, start, done, approve, reject, cancel, fail, heartbeat
- Test status filtering, context files, review-gate integration
- Test invalid state transitions and error cases

Bug fixes:
- Fix agent commands failing when run from worktrees (skills-y3f2)
  - Add getMainRepoBusDbPath() to find DB in main repo
  - Update start, done, fail, heartbeat to use correct path
- Fix review.nim crash when review-gate not installed (OSError)
  - Gracefully return exitCode=-1 instead of crashing

Closes skills-y3f2

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 00:26:02 -08:00
..
libs feat: add worker CLI scaffold in Nim 2026-01-10 18:47:47 -08:00
worker feat(worker): add test suite and fix worktree DB path 2026-01-11 00:26:02 -08:00
.gitignore feat: add worker CLI scaffold in Nim 2026-01-10 18:47:47 -08:00
config.nims feat: add worker CLI scaffold in Nim 2026-01-10 18:47:47 -08:00
README.md feat: add worker CLI scaffold in Nim 2026-01-10 18:47:47 -08:00
worker.nim feat(worker): add test suite and fix worktree DB path 2026-01-11 00:26:02 -08:00
worker.nimble feat: add worker CLI scaffold in Nim 2026-01-10 18:47:47 -08:00

Worker CLI

Multi-agent worker coordination CLI written in Nim.

Prerequisites

# Install Nim (>= 2.0.0)
# On NixOS: nix-shell -p nim

# Install dependencies
nimble install tiny_sqlite cligen

Static SQLite (Optional)

For a single static binary, download the SQLite amalgamation:

curl -LO https://sqlite.org/2024/sqlite-amalgamation-3450000.zip
unzip sqlite-amalgamation-3450000.zip
cp sqlite-amalgamation-3450000/sqlite3.c libs/

Build

# Development build
nim c src/worker.nim

# Release build (optimized)
nim c -d:release src/worker.nim

# The binary will be at src/worker

Usage

# Orchestrator commands (human)
worker spawn <task-id>              # Create workspace
worker status [--watch]             # Dashboard
worker approve <task-id>            # Approve work
worker request-changes <task-id>    # Request changes
worker merge <task-id>              # Merge to integration
worker cancel <task-id>             # Abort worker

# Agent commands (from worktree)
worker start                        # Begin work
worker done [--skip-rebase]         # Complete work
worker fail <reason>                # Signal failure
worker heartbeat                    # Manual heartbeat
worker show <task-id>               # Detailed view

Project Structure

src/
├── worker.nim           # CLI entry point (cligen)
├── worker.nimble        # Package definition
├── config.nims          # Build configuration
├── libs/
│   └── sqlite3.c        # SQLite amalgamation (optional)
└── worker/
    ├── types.nim        # Shared types and constants
    ├── db.nim           # SQLite operations
    ├── state.nim        # State machine
    ├── heartbeat.nim    # Background thread
    ├── git.nim          # Git/worktree operations
    └── context.nim      # Worker context handling

Design Docs

See docs/design/:

  • mvp-scope.md - MVP scope and implementation order
  • message-passing-layer.md - SQLite message bus
  • worker-cli-primitives.md - CLI commands
  • worker-state-machine.md - State transitions