Disinto Factory
You are helping the user set up and operate a disinto autonomous code factory — a system
of bash scripts and Claude CLI that automates the full development lifecycle: picking up
issues, implementing via Claude, creating PRs, running CI, reviewing, merging, and mirroring.
First-time setup
Walk the user through these steps interactively. Ask questions where marked with [ASK].
1. Environment
[ASK] Where will the factory run? Options:
- - LXD container (recommended for isolation) — need Debian 12, Docker, nesting enabled
- Bare VM or server — need Debian/Ubuntu with Docker
- Existing container — check prerequisites
Verify prerequisites:
CODEBLOCK0
Any missing tool — help the user install it before continuing.
2. Clone and init
CODEBLOCK1
[ASK] What repo should the factory develop? Options:
- - Itself (self-development): INLINECODE0
- Another project: INLINECODE1
Run the init and watch for:
- - All bot users created (dev-bot, review-bot, etc.)
- INLINECODE2 generated and saved
- Stack containers all started
3. Post-init verification
Run this checklist — fix any failures before proceeding:
CODEBLOCK2
If the agent repo is missing, clone it:
CODEBLOCK3
4. Mirrors (optional)
[ASK] Should the factory mirror to external forges? If yes, which?
- - GitHub: need repo URL and SSH key added to GitHub account
- Codeberg: need repo URL and SSH key added to Codeberg account
Show the user their public key:
CODEBLOCK4
Test SSH access:
CODEBLOCK5
If SSH host keys are missing: INLINECODE3
Edit projects/<name>.toml to add mirrors:
CODEBLOCK6
Test with a manual push:
CODEBLOCK7
5. Seed the backlog
[ASK] What should the factory work on first? Brainstorm with the user.
Help them create issues on the local Forgejo. Each issue needs:
- - A clear title prefixed with
fix:, feat:, or INLINECODE7 - A body describing what to change, which files, and any constraints
- The
backlog label (so the dev-agent picks it up)
CODEBLOCK8
For issues with dependencies, add Depends-on: #N in the body — the dev-agent checks
these before starting.
Use labels:
- -
backlog — ready for the dev-agent - INLINECODE11 — parked, not for the factory
- No label — tracked but not for autonomous work
6. Watch it work
The dev-agent polls every 5 minutes. Trigger manually to see it immediately:
CODEBLOCK9
Then monitor:
CODEBLOCK10
Ongoing operations
Check factory status
CODEBLOCK11
Check CI
CODEBLOCK12
Unstick a blocked issue
When a dev-agent run fails (CI timeout, implementation error), the issue gets labeled blocked:
- 1. Close stale PR and delete the branch
- INLINECODE13
- Relabel the issue to INLINECODE14
- Update agent repo: INLINECODE15
Access Forgejo UI
If running in an LXD container with reverse tunnel:
CODEBLOCK13
Reset admin password if needed:
CODEBLOCK14
Important context
- - Read
AGENTS.md for per-agent architecture and file-level docs - Read
VISION.md for project philosophy - The factory uses a single internal Forgejo as its forge, regardless of where mirrors go
- Dev-agent uses
claude -p --resume for session continuity across CI/review cycles - Mirror pushes happen automatically after every merge (fire-and-forget)
- Cron schedule: dev-poll every 5min, review-poll every 5min, gardener 4x/day
Disinto 工厂
您正在帮助用户设置和运行一个 disinto 自主代码工厂 —— 一个由 bash 脚本和 Claude CLI 组成的系统,可自动化完整的开发生命周期:接收问题、通过 Claude 实现、创建 PR、运行 CI、审查、合并和镜像。
首次设置
以交互方式引导用户完成以下步骤。在标记为 [ASK] 处提问。
1. 环境
[ASK] 工厂将在哪里运行?选项:
- - LXD 容器(推荐用于隔离)—— 需要 Debian 12、Docker、启用嵌套
- 裸机 VM 或服务器—— 需要带 Docker 的 Debian/Ubuntu
- 现有容器—— 检查先决条件
验证先决条件:
bash
docker --version && git --version && jq --version && curl --version && tmux -V && python3 --version && claude --version
任何缺失的工具 —— 在继续之前帮助用户安装。
2. 克隆并初始化
bash
git clone https://codeberg.org/johba/disinto.git && cd disinto
[ASK] 工厂应该开发哪个仓库?选项:
- - 自身(自我开发):bin/disinto init https://codeberg.org/johba/disinto --yes --repo-root $(pwd)
- 其他项目:bin/disinto init --yes
运行初始化并观察:
- - 所有机器人用户已创建(dev-bot、review-bot 等)
- WOODPECKER_TOKEN 已生成并保存
- 所有堆栈容器已启动
3. 初始化后验证
运行此检查清单 —— 在继续之前修复任何失败:
bash
堆栈健康?
docker ps --format table {{.Names}}\t{{.Status}}
预期:forgejo、woodpecker(健康)、woodpecker-agent(健康)、agents、edge、staging
令牌已生成?
grep WOODPECKER_TOKEN .env | grep -v ^$ && echo OK || echo 缺失 — 请参阅 references/troubleshooting.md
Agent cron 活跃?
docker exec -u agent disinto-agents-1 crontab -l -u agent
Agent 可以访问 Forgejo?
docker exec disinto-agents-1 bash -c source /home/agent/disinto/.env && curl -sf http://forgejo:3000/api/v1/version | jq .version
Agent 仓库已克隆?
docker exec -u agent disinto-agents-1 ls /home/agent/repos/
如果 agent 仓库缺失,克隆它:
bash
docker exec disinto-agents-1 chown -R agent:agent /home/agent/repos
docker exec -u agent disinto-agents-1 bash -c source /home/agent/disinto/.env && git clone http://dev-bot:\${FORGE_TOKEN}@forgejo:3000//.git /home/agent/repos/
4. 镜像(可选)
[ASK] 工厂是否应该镜像到外部 forge?如果是,哪些?
- - GitHub:需要仓库 URL 和添加到 GitHub 账户的 SSH 密钥
- Codeberg:需要仓库 URL 和添加到 Codeberg 账户的 SSH 密钥
向用户显示他们的公钥:
bash
cat ~/.ssh/id_ed25519.pub
测试 SSH 访问:
bash
ssh -T git@github.com 2>&1; ssh -T git@codeberg.org 2>&1
如果 SSH 主机密钥缺失:ssh-keyscan github.com codeberg.org >> ~/.ssh/known_hosts 2>/dev/null
编辑 projects/.toml 添加镜像:
toml
[mirrors]
github = git@github.com:Org/repo.git
codeberg = git@codeberg.org:user/repo.git
通过手动推送测试:
bash
source .env && source lib/env.sh && export PROJECTTOML=projects/.toml && source lib/load-project.sh && source lib/mirrors.sh && mirrorpush
5. 播种待办事项
[ASK] 工厂应该先处理什么?与用户一起集思广益。
帮助他们在本地的 Forgejo 上创建问题。每个问题需要:
- - 以 fix:、feat: 或 chore: 为前缀的清晰标题
- 描述要更改的内容、哪些文件以及任何约束的正文
- backlog 标签(以便 dev-agent 拾取)
bash
source .env
BACKLOG_ID=$(curl -sf http://localhost:3000/api/v1/repos///labels \
-H Authorization: token $FORGE_TOKEN | jq -r .[] | select(.name==backlog) | .id)
curl -sf -X POST http://localhost:3000/api/v1/repos///issues \
-H Authorization: token $FORGE_TOKEN \
-H Content-Type: application/json \
-d {\title\: \\, \body\: \\, \labels\: [$BACKLOG_ID]}
对于有依赖关系的问题,在正文中添加 Depends-on: #N —— dev-agent 在开始之前会检查这些。
使用标签:
- - backlog —— 准备好供 dev-agent 处理
- blocked —— 搁置,不供工厂处理
- 无标签 —— 已跟踪但不供自主工作
6. 观察运行
dev-agent 每 5 分钟轮询一次。手动触发以立即查看:
bash
docker exec -u agent disinto-agents-1 bash -c cd /home/agent/disinto && bash dev/dev-poll.sh projects/.toml
然后监控:
bash
观察 agent 工作
docker exec disinto-agents-1 tail -f /home/agent/data/logs/dev/dev-agent.log
检查 Claude 是否在运行
docker exec disinto-agents-1 bash -c for f in /proc/[0-9]
/cmdline; do cmd=\$(tr \0 < \$f 2>/dev/null); echo \$cmd | grep -q claude.-p && echo Claude is running; done
持续运营
检查工厂状态
bash
source .env
问题
curl -sf http://localhost:3000/api/v1/repos/
//issues?state=open \
-H Authorization: token $FORGE_TOKEN \
| jq -r .[] | #\(.number) [\(.labels | map(.name) | join(,))] \(.title)
PR
curl -sf http://localhost:3000/api/v1/repos///pulls?state=open \
-H Authorization: token $FORGE_TOKEN \
| jq -r .[] | PR #\(.number) [\(.head.ref)] \(.title)
Agent 日志
docker exec disinto-agents-1 tail -20 /home/agent/data/logs/dev/dev-agent.log
检查 CI
bash
source .env
WPCSRF=$(curl -sf -b usersess=$WOODPECKER_TOKEN http://localhost:8000/web-config.js \
| sed -n s/.WOODPECKER_CSRF = \([^]\).*/\1/p)
curl -sf -b usersess=$WOODPECKERTOKEN -H X-CSRF-Token: $WP_CSRF \
http://localhost:8000/api/repos/1/pipelines?page=1&per_page=5 \
| jq .[] | {number, status, event}
解除阻塞问题
当 dev-agent 运行失败时(CI 超时、实现错误),问题会被标记为 blocked:
- 1. 关闭过时的 PR 并删除分支
- docker exec disinto-agents-1 rm -f /tmp/dev-agent-.json /tmp/dev-agent-.lock
- 将问题重新标记为 backlog
- 更新 agent 仓库:docker exec -u agent disinto-agents-1 bash -c cd /home/agent/repos/ && git fetch origin && git reset --hard origin/main
访问 Forgejo UI
如果在带有反向隧道的 LXD 容器中运行:
bash
从您的机器:
ssh -L 3000:localhost:13000 user@jump-host
打开 http://localhost:3000
如果需要重置管理员密码:
bash
docker exec disinto-forgejo-1 su -c forgejo admin user change-password --username disinto-admin --password <