2026-03-12 12:44:15 +00:00
|
|
|
# 🏭 Dark Factory
|
|
|
|
|
|
|
|
|
|
Autonomous CI/CD factory for [harb](https://codeberg.org/johba/harb). Three agents, zero supervision needed.
|
|
|
|
|
|
|
|
|
|
## Architecture
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
cron (*/10) ──→ factory-poll.sh ← supervisor (bash checks, zero tokens)
|
|
|
|
|
├── all clear? → exit 0
|
2026-03-12 18:10:25 +00:00
|
|
|
└── problem? → claude -p (diagnose, fix, or escalate)
|
2026-03-12 12:44:15 +00:00
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
# 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)
|
|
|
|
|
|
2026-03-12 18:10:25 +00:00
|
|
|
# 3. Install cron (staggered — supervisor first, then review, then dev)
|
2026-03-12 12:44:15 +00:00
|
|
|
crontab -e
|
|
|
|
|
# Add:
|
2026-03-12 18:10:25 +00:00
|
|
|
# 0,10,20,30,40,50 * * * * /path/to/dark-factory/factory/factory-poll.sh
|
|
|
|
|
# 3,13,23,33,43,53 * * * * /path/to/dark-factory/review/review-poll.sh
|
|
|
|
|
# 6,16,26,36,46,56 * * * * /path/to/dark-factory/dev/dev-poll.sh
|
2026-03-12 12:44:15 +00:00
|
|
|
|
|
|
|
|
# 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/
|
2026-03-12 18:10:25 +00:00
|
|
|
│ ├── env.sh # Shared: load .env, PATH, API helpers
|
|
|
|
|
│ └── ci-debug.sh # Woodpecker CI log/failure helper
|
2026-03-12 12:44:15 +00:00
|
|
|
├── dev/
|
|
|
|
|
│ ├── dev-poll.sh # Cron entry: find ready issues
|
2026-03-12 18:10:25 +00:00
|
|
|
│ └── dev-agent.sh # Implementation agent (claude -p)
|
2026-03-12 12:44:15 +00:00
|
|
|
├── review/
|
|
|
|
|
│ ├── review-poll.sh # Cron entry: find unreviewed PRs
|
|
|
|
|
│ └── review-pr.sh # Review agent (claude -p)
|
|
|
|
|
└── factory/
|
2026-03-12 18:10:25 +00:00
|
|
|
├── factory-poll.sh # Supervisor: health checks + claude -p
|
|
|
|
|
├── PROMPT.md # Supervisor's system prompt
|
|
|
|
|
├── update-prompt.sh# Self-learning: append to best-practices
|
|
|
|
|
└── best-practices/ # Progressive disclosure knowledge base
|
|
|
|
|
├── memory.md
|
|
|
|
|
├── disk.md
|
|
|
|
|
├── ci.md
|
|
|
|
|
├── codeberg.md
|
|
|
|
|
├── dev-agent.md
|
|
|
|
|
├── review-agent.md
|
|
|
|
|
└── git.md
|
2026-03-12 12:44:15 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-12 18:10:25 +00:00
|
|
|
## Design Principles
|
|
|
|
|
|
|
|
|
|
- **Bash for checks, AI for judgment** — health checks are shell scripts; AI is only invoked when something needs diagnosing or fixing
|
|
|
|
|
- **Pull over push** — dev-agent derives readiness from merged dependencies, not labels or manual assignment
|
|
|
|
|
- **Progressive disclosure** — the supervisor reads only the best-practices file relevant to the current problem, not all of them
|
|
|
|
|
- **Self-improving** — when the AI fixes something new, it appends the lesson to best-practices for next time
|
2026-03-12 12:44:15 +00:00
|
|
|
|
|
|
|
|
## Requirements
|
|
|
|
|
|
|
|
|
|
- [Claude CLI](https://docs.anthropic.com/en/docs/claude-cli) (`claude` in PATH)
|
|
|
|
|
- [Foundry](https://getfoundry.sh/) (`forge`, `cast`, `anvil`)
|
|
|
|
|
- [Woodpecker CI](https://woodpecker-ci.org/) (local instance)
|
|
|
|
|
- PostgreSQL client (`psql`)
|
2026-03-12 18:10:25 +00:00
|
|
|
- [OpenClaw](https://openclaw.ai/) (for escalation notifications, optional)
|
2026-03-12 12:44:15 +00:00
|
|
|
- `jq`, `curl`, `git`
|