No description
Three agents extracted from ~/scripts/harb-{dev,review}/:
- dev/ — pull-based dev agent (find ready issues → implement → PR → merge)
- review/ — AI code review (structured verdicts, follow-up issues)
- factory/ — supervisor (bash health checks, auto-fix, escalation)
All secrets externalized to .env (see .env.example).
Shared env/helpers in lib/env.sh.
|
||
|---|---|---|
| dev | ||
| factory | ||
| lib | ||
| review | ||
| .env.example | ||
| .gitignore | ||
| README.md | ||
🏭 Dark Factory
Autonomous CI/CD factory for harb. Three agents, zero supervision needed.
Architecture
cron (*/10) ──→ factory-poll.sh ← supervisor (bash checks, zero tokens)
├── all clear? → exit 0
└── problem? → alert (or claude -p for complex fixes)
cron (*/10) ──→ dev-poll.sh ← pulls ready issues, spawns dev-agent
└── dev-agent.sh ← claude -p: implement → PR → CI → review → merge
cron (*/10) ──→ review-poll.sh ← finds unreviewed PRs, spawns review
└── review-pr.sh ← claude -p: review → approve/request changes
Setup
# 1. Clone
git clone ssh://git@codeberg.org/johba/dark-factory.git
cd dark-factory
# 2. Configure
cp .env.example .env
# Fill in your tokens (see .env.example for descriptions)
# 3. Install cron
crontab -e
# Add:
# */10 * * * * /path/to/dark-factory/factory/factory-poll.sh
# */10 * * * * /path/to/dark-factory/dev/dev-poll.sh
# */10 * * * * /path/to/dark-factory/review/review-poll.sh
# 4. Verify
bash factory/factory-poll.sh # should log "all clear"
Directory Structure
dark-factory/
├── .env.example # Template — copy to .env, add secrets
├── .gitignore # Excludes .env, logs, state files
├── lib/
│ └── env.sh # Shared: load .env, PATH, API helpers
├── dev/
│ ├── dev-poll.sh # Cron entry: find ready issues
│ ├── dev-agent.sh # Implementation agent (claude -p)
│ └── ci-debug.sh # Woodpecker CI log helper
├── review/
│ ├── review-poll.sh # Cron entry: find unreviewed PRs
│ └── review-pr.sh # Review agent (claude -p)
└── factory/
└── factory-poll.sh # Supervisor: health checks + auto-fix
How It Works
Dev Agent (Pull System)
dev-poll.shscansbacklog-labeled issues- Checks if all dependencies are merged into master
- Picks the first ready issue, spawns
dev-agent.sh - Agent: creates worktree →
claude -pimplements → commits → pushes → creates PR - Waits for CI. If CI fails: feeds errors back to claude (max 2 attempts per phase)
- Waits for review. If REQUEST_CHANGES: feeds review back to claude
- On APPROVE: merges PR, cleans up, closes issue
Review Agent
review-poll.shfinds open PRs with passing CI and no review- Spawns
review-pr.shwhich runsclaude -pto review the diff - Posts structured review comment with verdict (APPROVE / REQUEST_CHANGES / DISCUSS)
- Creates follow-up issues for pre-existing bugs found during review
Factory Supervisor
factory-poll.shruns pure bash checks every 10 minutes:- CI: stuck or failing pipelines
- PRs: derailed (CI fail + no activity)
- Dev-agent: alive and making progress
- Git: clean state on master
- Infra: RAM, swap, disk, Anvil health
- Review: unreviewed PRs with passing CI
- Auto-fixes simple issues (restart Anvil, retrigger CI)
- Escalates complex issues via openclaw system event
Requirements
- Claude CLI (
claudein PATH) - Foundry (
forge,cast,anvil) - Woodpecker CI (local instance)
- PostgreSQL client (
psql) - OpenClaw (for system event notifications, optional)
jq,curl,git
Design Principles
- Bash for checks, AI for fixes — don't burn tokens on health checks
- Pull system — readiness derived from merged dependencies, not labels
- CI fix loop — each phase gets fresh retry budget
- Prior art — dev-agent searches closed PRs to avoid rework
- No secrets in repo — everything via
.env