Commit graph

207 commits

Author SHA1 Message Date
dan 33e307daaa bd sync: 2026-01-14 11:40:40 2026-01-14 11:40:40 -08:00
dan 3cc7540c46 docs: add worklog for HQ deployment and Codex skills integration
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 06:56:49 -08:00
dan 06f5fafd1a bd sync: 2026-01-13 06:51:08 2026-01-13 06:51:08 -08:00
dan e6d777e589 feat: add Codex per-repo skills support
- use-skills.sh: symlink to $CODEX_HOME/skills when CODEX_HOME is set
- docs: update PER-REPO-SKILLS.md and RFC-SKILLS-MANIFEST.md with Codex flow
- hq: add model configuration section (sonnet-4.5, Claude Max)
- hq: update launch commands with explicit --model flag

Closes skills-legi

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 06:50:56 -08:00
dan 2969878553 feat: add Codex support to ai-skills module
- Add codexSkills option for deploying skills to ~/.codex/skills/
- Follows same pattern as claudeCodeSkills and openCodeSkills
- Dotfiles can now configure: services.ai-skills.codexSkills = [ "worklog" "hq" ];

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 05:58:56 -08:00
dan 84830fd5cb Merge feat/skills-zws1 2026-01-12 21:12:19 -08:00
dan 2177b10d50 Add hello world script 2026-01-12 21:11:49 -08:00
dan 119c240ad6 Update issue tracking 2026-01-12 21:11:41 -08:00
dan 04fcba0345 release: add worker v0.1.0 binary tarball
- Add releases/worker_0.1.0_linux_amd64.tar.gz (327KB)
- Update pkgs/worker/default.nix with real SHA256 hash
- Add clear dotfiles integration instructions
- Un-ignore releases/ for distribution via git forge

Dotfiles can now fetch worker binary from:
  https://git.clarun.xyz/dan/skills/raw/branch/master/releases/worker_0.1.0_linux_amd64.tar.gz

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 16:16:19 -08:00
dan dcb29c12cd docs: add HQ deployment and worker release documentation
- Add docs/releasing-worker.md with build and release process
- Add pkgs/worker/default.nix template for nix packaging
- Add skills/hq/README.md with installation and deployment guide
- Update skills/hq/SKILL.md with detailed requirements table
- Add hq and review-gate to skills.nix
- Add releases/ to .gitignore

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 15:36:01 -08:00
dan 560e92e678 hq: add cross-agent instructions and worker templates
- Add Cross-Agent Compatibility section to SKILL.md
- Document concrete launch commands per agent type (Claude, OpenCode, Codex)
- Add worker-system.md template for worker agent prompts
- Add hq-status script for unified status view
- Simplify by documenting patterns rather than building --agent flag

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 13:53:05 -08:00
dan 949250bbe9 bd sync: 2026-01-12 13:52:52 2026-01-12 13:52:52 -08:00
dan 7a73ed9b1c feat: add HQ orchestration skill with architectural boundaries
- Initial SKILL.md defining thin orchestration layer
- Core loop: Assess → Plan → Delegate → Monitor → Iterate → Complete
- Explicit delegation to worker CLI, review-gate, bd, infrastructure
- Communication protocol using tagged single-line format
- Open questions scoped to HQ-specific concerns

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 10:20:14 -08:00
dan 6e81841e8d bd sync: 2026-01-12 10:19:10 2026-01-12 10:19:10 -08:00
dan 0bffc07b5f docs: add worklog for HQ architecture and beads cleanup session
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 21:40:07 -08:00
dan 4da1890fc3 docs: add scenario schema and example test fixtures
Scaffold for agent capability benchmark harness (skills-qng9):
- docs/specs/scenario-schema.md: YAML schema for test scenarios
- tests/scenarios/: Easy, medium, hard example scenarios
- tests/fixtures/: Python fixtures for testing

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 21:24:28 -08:00
dan 7c7733bc64 docs: clarify VPS deployment goal for skills
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 21:24:13 -08:00
dan b13109e8e0 fix: use absolute worktree paths, check sqlite3 availability
- worktreePath() now returns absolute path using findMainRepoDir()
- Fixes 'cannot change to worktrees/...' error from inside worktree
- test-worker.sh now checks sqlite3 is available before running

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 21:24:03 -08:00
dan 62e81b720e bd sync: 2026-01-11 21:23:48 2026-01-11 21:23:48 -08:00
dan d3d23f0cd8 docs: add worklog for worker CLI cleanup session
Documents exit code fixes, P3/P4 refactors, and tech debt resolution.
10 commits, 13 files, +980/-241 lines, 56/56 tests passing.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 16:04:08 -08:00
dan 10ae698e7f bd sync: 2026-01-11 15:50:17 2026-01-11 15:50:17 -08:00
dan b0719d2c59 cleanup: P4 worker code quality fixes
- Extract renderStatusTable() from nested proc in status()
- Add column width constants (ColTask, ColState, etc.)
- Use parseEnum for heartbeat status instead of case statement
- Return bool from startGlobalHeartbeat() to indicate if started
- Remove unused getBranchStatus() function (dead code)

Closes: skills-y76g, skills-f8yd, skills-audh, skills-hx1n, skills-827e

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 15:46:34 -08:00
dan c5fd9a6be2 bd sync: 2026-01-11 15:38:05 2026-01-11 15:38:05 -08:00
dan 3490f28682 refactor: consolidate stale logic, use transaction helper, add migrations
- Add StaleLevel enum (ok, WARN, STALE, DEAD) to types.nim
- Extract computeStaleLevel() as single source of truth
- Simplify isStale() and staleLevel() to use computeStaleLevel()
- Refactor transition() and transitionToFailed() to use withTransaction
- Add schema migration infrastructure:
  - CurrentSchemaVersion constant
  - Migrations sequence for incremental upgrades
  - getSchemaVersion() and runMigrations() procs
  - initSchema() now runs pending migrations

Closes: skills-dtk, skills-8fd, skills-9ny

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 15:37:55 -08:00
dan fb6da27e96 bd sync: 2026-01-11 15:34:25 2026-01-11 15:34:25 -08:00
dan 61cce7e380 refactor: extract helpers and add developer docs
- Add optFromDb generic helper for nullable DbValue conversion
- Extract rowToWorkerInfo helper in state.nim (dedup getWorker/getAllWorkers)
- Extract loadContextFromPath helper in context.nim (dedup readContext/findContext)
- Simplify poll() using optFromDb for optional field extraction
- Add developer guide for compiling, testing, and deployment

Closes: skills-r3k, skills-luzk, skills-dszn, skills-m0e2

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 15:34:15 -08:00
dan 61b4d3a37c bd sync: 2026-01-11 14:28:29 2026-01-11 14:28:29 -08:00
dan de84648563 fix: proper exit codes for state transition errors
- Add try/except blocks in worker commands to catch WorkerNotFound,
  InvalidTransition, and StaleState exceptions
- Return ExitInvalidTransition (3) for state transition errors
- Return ExitNotFound (7) for missing workers
- Fix double ROLLBACK bug in state.nim by removing inline ROLLBACKs
  and letting the except block handle transaction cleanup

Closes: skills-lxb9

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 14:28:21 -08:00
dan 4d7a1d96b0 bd sync: 2026-01-11 00:26:06 2026-01-11 00:26:06 -08:00
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
dan 966d09a7b6 bd sync: 2026-01-10 23:27:38 2026-01-10 23:27:38 -08:00
dan daec0f3b85 docs: ADR-006 Nim language choice for worker CLI
Documents rationale for using Nim with ORC for the worker coordination
CLI: fast startup, single binary, Python-like syntax, excellent SQLite
support via tiny_sqlite, CLI generation via cligen.

Closes skills-q40

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 23:27:32 -08:00
dan b9866b7930 chore: ignore .worker-state runtime directory
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 23:24:53 -08:00
dan 7f264facd9 bd sync: 2026-01-10 23:24:37 2026-01-10 23:24:37 -08:00
dan caff76f618 feat(worker): integrate review-gate with worker CLI
- Add review.nim module for review-gate integration
- spawn: enables review-gate automatically
- status: shows review state column (pending/approved/REJECTED)
- show: displays review status in detailed view
- approve: calls review-gate approve before state transition
- request-changes: calls review-gate reject with comment
- cancel/merge: clean up review state files

Closes skills-byq

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 23:24:33 -08:00
dan f9ac03a8a8 bd sync: 2026-01-10 23:07:31 2026-01-10 23:07:31 -08:00
dan 405e6b9aee fix: varargs binding bug in git.nim runGit/runGitCheck
Nim's varargs doesn't consume the last positional argument when there's
a trailing parameter with a default value. This caused calls like
`runGit("fetch", "origin")` to be parsed as:
  - args = ["fetch"]
  - workDir = "origin"

Instead of the intended:
  - args = ["fetch", "origin"]
  - workDir = ""

Fixed by changing from varargs to openArray, which requires explicit
array syntax at call sites: `runGit(["fetch", "origin"])`.

Also includes P2 bug fixes:
- Start heartbeat before state transition (skills-qekj)
- Reject symlinks when reading context file (skills-16zf)
- Case-insensitive conflict detection (skills-n3qp)

Smoke tested: spawn, status, start, show, cancel all work.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 21:24:41 -08:00
dan 3afd621bb4 fix: P2 bugs - heartbeat timing, symlink check, conflict detection
worker.nim:
- Start heartbeat before state transition in start command
  (prevents WORKING state without heartbeat if startup fails)

context.nim:
- Reject symlinks when reading context file (security)
  (prevents reading arbitrary files via symlinked .worker-ctx.json)

git.nim:
- Use case-insensitive conflict detection in rebase/merge
  (toLowerAscii instead of checking "CONFLICT" and "conflict" separately)

Closes: skills-qekj, skills-16zf, skills-n3qp

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 20:55:15 -08:00
dan c44f2106ee bd sync: 2026-01-10 20:55:02 2026-01-10 20:55:02 -08:00
dan 7e368a2cde bd sync: 2026-01-10 20:41:42 2026-01-10 20:41:42 -08:00
dan 32fc21b089 chore: remove dead code and unused parameters
types.nim:
- Remove unused constants: BusJsonlPath, BlobsDir, WorkersDir

worker.nim:
- Remove unused 'by' and 'comment' parameters from approve()

Note: skills-5ax (unused imports in db.nim) no longer applies -
strutils is used for toHex in genOid fallback path.

Closes: skills-t9ub, skills-5ax, skills-fdu, skills-ghlb

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 20:41:22 -08:00
dan 2f0aad5a25 bd sync: 2026-01-10 20:41:13 2026-01-10 20:41:13 -08:00
dan 09b76605c2 refactor: implement consistent error handling strategy
Error handling helpers in utils.nim:
- logError/logWarn: consistent stderr format
- wrapError template: catch and re-raise with context

db.nim:
- openBusDb: wrap with DbError and path context
- poll: handle malformed JSON gracefully with warning
- tryClaim: log failures instead of silently swallowing

git.nim:
- createWorktree/rebaseOnIntegration: warn on fetch failure
- removeWorktree/removeBranch: log cleanup failures
- getBranchStatus: log parseInt failures

context.nim:
- readContext/findContext: add path context to parse errors
- writeContext: wrap IOError with path

types.nim:
- Extract ContextDateFormat constant
- Add context to date parse errors

Closes: skills-05ah, skills-xcl, skills-266, skills-8xv, skills-8vdo,
        skills-tdfm, skills-koes, skills-8bi, skills-2wjp, skills-3uv9, skills-xgh0

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 20:37:47 -08:00
dan 5121bbb008 bd sync: 2026-01-10 20:37:34 2026-01-10 20:37:34 -08:00
dan d3d22a91e5 refactor: extract common utilities to utils.nim
- Add branchName() and worktreePath() helpers for consistent path generation
- Add msToTime() for epoch ms to Time conversion (8 occurrences consolidated)
- Add validateTaskId() for CLI input validation (prevents path traversal)
- Add optString/optInt64 helpers for nullable DB values
- Add withTransaction template for automatic rollback on error

Closes: skills-lzh2, skills-3d9o, skills-5x2o, skills-qiq0, skills-73yu, skills-vuj2

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 20:32:47 -08:00
dan 5550421ae9 bd sync: 2026-01-10 20:32:36 2026-01-10 20:32:36 -08:00
dan 200c040d3a fix: P1 security bugs - cryptographic IDs and GC-managed heartbeat
- genOid: use std/sysrand for cryptographic randomness instead of rand()
- HeartbeatThread: change from ptr with manual alloc/dealloc to ref object
- Add error handling for DB open in heartbeat thread
- Remove unused globalChannel and times import

Closes: skills-0wk, skills-bk7x, skills-69sz, skills-ib9u, skills-kvdl, skills-n6zf

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 20:26:38 -08:00
dan 02b7054709 bd sync: 2026-01-10 20:26:28 2026-01-10 20:26:28 -08:00
dan 1c66d019bd feat: add worker CLI scaffold in Nim
Multi-agent coordination CLI with SQLite message bus:
- State machine: ASSIGNED -> WORKING -> IN_REVIEW -> APPROVED -> COMPLETED
- Commands: spawn, start, done, approve, merge, cancel, fail, heartbeat
- SQLite WAL mode, dedicated heartbeat thread, channel-based IPC
- cligen for CLI, tiny_sqlite for DB, ORC memory management

Design docs for branch-per-worker, state machine, message passing,
and human observability patterns.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 18:47:47 -08:00
dan 555dbb8ccd bd sync: 2026-01-10 18:04:40 2026-01-10 18:04:40 -08:00