Loading...
Loading...
Automated issue loop with checkpoint/resume: fetch open GitHub issues → dependency-aware topological sort → implement each issue end-to-end → review with /review-it → ship with /ship-it → repeat. Persists state to .loop-state.json for crash recovery. Triggers on: loop-it, loop issues, auto implement, 批量实现, 循环实现, 实现所有issue, 恢复循环, resume loop.
npx skill4agent add smallnest/goal-workflow loop-it/review-it/ship-it⚠️ 关键前提:实现步骤由 agent 内联自主完成,不依赖任何外部命令。 本环境中不存在可调用的/goal命令或 skill。因此「实现 issue」这一步必须由 agent 内联完成:直接读取该 issue 的标题与正文(含其引用的 PRD/SPEC 与验收条件),自主完成"理解需求 → 写/改代码 → 跑测试与 lint → 满足全部验收条件"的闭环,持续工作直到该 issue 的验收条件全部满足且测试/构建通过。不要尝试用 Skill 工具调用goal(会报goal),也不要因为找不到goal is a UI command, not a skill而中止循环。/goal、/review-it仍是真实 skill,经 Skill 工具调用。loop-it 循环中不调用/ship-it。/note-it
前置检查 → 读取状态文件 → Fetch Issues → 构建依赖图 → 拓扑排序
|
┌───────────────────────────────────────────────────────────┘
|
v
┌──────────────── 单 Issue 循环 ────────────────┐
| |
| 从检查点恢复?—— 跳过已完成/失败的 |
| |
| 分支准备 (checkout main, pull, create branch) |
| | |
| Skip/Blocked? ── 是 → 标记 skipped/blocked, 写检查点 |
| | |
| 否 |
| | |
| 内联实现 → 出错?→ 分类 → 恢复 → 重试 |
| | | |
| | 失败 → 检查点, 下一个 |
| | |
| /review-it → 有问题?→ 修复 → 重跑 review |
| | |
| /ship-it → 出错?→ 分类 → 恢复 |
| | |
| 分支清理 (checkout main, pull, delete branch) |
| | |
| 检查点 (标记 shipped) |
| | |
└────────┴──────────────────────────────────────┘
|
v
全部完成 → 最终 Summarygh auth status❌ gh CLI 未认证。运行: gh auth logingit rev-parse --is-inside-work-tree❌ 不在 git 仓库中git status --porcelain⚠️ 工作树有未提交的更改git stashgit branch --show-current⚠️ 当前在 {branch} 分支git checkout main && git pullgit ls-remote --heads origin❌ 无法访问远程仓库。检查网络和权限cat .loop-state.json.loop-state.json.gitignore.gitignore{
"version": 1,
"started_at": "2025-06-09T10:00:00Z",
"updated_at": "2025-06-09T10:30:00Z",
"repo": "owner/repo-name",
"total_issues": 8,
"issues": {
"3": {
"status": "shipped",
"branch": "feat/issue-3-add-priority",
"started_at": "2025-06-09T10:00:00Z",
"completed_at": "2025-06-09T10:15:00Z",
"attempts": 1
},
"4": {
"status": "failed",
"phase": "goal",
"error_class": "build_failure",
"branch": "feat/issue-4-filter-tasks",
"started_at": "2025-06-09T10:15:00Z",
"updated_at": "2025-06-09T10:30:00Z",
"attempts": 3,
"last_error": "test TestFilterPriority failed: expected 3, got 0"
},
"7": {
"status": "pending"
}
}
}pendingin_progressskippedshippedfailedblockedpendingin_progressin_progressshippedfailedskippedcat > .loop-state.json << 'LOOPSTATE'\n{json}\nLOOPSTATEgh issue list --state open --json number,title,labels,body --limit 100Dependencies: #3, #5Depends on: #3depends on #3requires #3⚠️ 循环依赖检测到: #A ↔ #B,按编号顺序处理📋 Found N open issues (topological sort):
#1: Add priority field (无依赖)
#3: Display indicator (依赖 #1)
#5: Add selector (依赖 #1)
#7: Filter view (依赖 #1, #3)✅ No open issues found. Nothing to do..loop-state.json📊 从检查点恢复 (上次更新: {updated_at})
✅ Shipped: #1, #3
⏭️ Skipped: #2 (question)
❌ Failed: #4 (build_failure — 3 attempts)
📋 Remaining: #5, #7failedin_progressshippedskippedpending━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔄 Processing Issue #{number}: {title}
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━# 确认在 main 上
git checkout main
git pull
# 创建功能分支
git checkout -b feat/issue-{N}-{short-desc}feat/issue-N-short-descfix/issue-N-short-descwontfixquestiondiscussioninvalidshippedpendingfailedblocked⏭️ Skipping Issue #{number}: {title}
Reason: {why}🔒 Blocking Issue #{number}: {title}
Reason: dependency #{dep_number} not shipped ({status})pendingskippedpendingblockedpendingin_progressphase: "implement"goaltasks/prd-*.mdgo build ./...go vet ./...go test ./...不要尝试用 Skill 工具调用(会报goal),也不要因找不到goal is a UI command, not a skill而中止——实现就是你自己内联完成的工作。/goal
✅ Issue #{number} implementation completephase: "implement_done"⚠️ Issue #{number} failed: {error_class} after {N} attempts
Manual intervention required.in_progressfailedphase: "review"/review-it🔍 Review found N issue(s) for #{number}. Fixing.../review-it✅ Review clean for Issue #{number}phase: "review_done"/ship-it🚀 Issue #{number} shipped successfully!⚠️ Issue #{number} ship failed: {error}. Manual merge required.in_progressfailedphase: "ship"in_progressshippedcompleted_at# 切回 main
git checkout main
git pull
# 删除本地功能分支(仅当 shipped 时)
git branch -d feat/issue-{N}-{short-desc}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📊 Loop Complete — Summary
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✅ Shipped: N issues (#1, #3, ...)
⏭️ Skipped: N issues (#2 — reason, #5 — reason, ...)
🔒 Blocked: N issues (#7 — depends on #4, ...)
❌ Failed: N issues (#4 — error, ...)
📋 Total: N issues
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━| 错误类别 | 检测信号 | 恢复策略 | 最大重试 |
|---|---|---|---|
| build_failure | 编译错误、undefined、类型错误 | 读错误,修代码,重新构建 | 3 |
| test_failure | 断言失败、test failed | 读测试输出,修实现,重跑测试 | 3 |
| lint_failure | lint 错误、格式问题 | 自动修复 (lint --fix),重跑 | 2 |
| merge_conflict | CONFLICT 标记 | rebase origin/main,解决冲突,push | 2 |
| ci_failure | gh pr checks 失败 | 读 CI 日志,本地修复,push | 2 |
| auth_failure | 403、401、认证错误 | 停止,告知用户重新认证 | 0 |
| rate_limit | rate limit、secondary abuse | 等待 60s,重试 | 3 |
| issue_unclear | issue 无验收条件且无法推断需求 | 跳过,标记 failed | 0 |
| network_error | timeout、connection refused | 等待 30s,重试 | 3 |
| unknown | 其他情况 | 记录完整错误,跳过 | 0 |
failedfailedunknown━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📊 Progress: 3/8 issues (37%)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✅ Shipped: #1, #3
⏭️ Skipped: #2 (question), #6 (duplicate)
🔒 Blocked: #7 (depends on #4 — failed)
❌ Failed: #4 (build_failure — 3 attempts)
📋 Remaining: #5, #8
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━| Emoji | Meaning |
|---|---|
| 📋 | Fetch / list |
| 🔄 | Processing issue |
| ⏭️ | Skip |
| 🔒 | Blocked (dependency not shipped) |
| ✅ | Success |
| ❌ | Failure |
| 🔍 | Review |
| 🚀 | Ship |
| ⚠️ | Warning / retry |
| 📊 | Progress / summary |
/review-it/ship-it.loop-state.jsonblockedgoalgoal is a UI command, not a skill| Scenario | Handling |
|---|---|
| No open issues | Print "nothing to do" and exit |
| All issues are questions | Skip all, report summary |
| Print error, suggest |
| Issue has no body | Use title only to decide skip/implement |
| Issue references PRD/SPEC | 读取被引用的 PRD/SPEC 作为上下文,agent 内联实现 |
| Multiple issues depend on each other | Topological sort; dependencies already shipped first |
| Git repo is dirty before starting | 前置检查 Check 3: stash/abort/force |
| State file corrupted (invalid JSON) | 警告用户,提供从头开始或中止选项。绝不自动覆盖 |
| State file from different repo | 检测 repo 字段不匹配,警告,提供从头开始选项 |
Issue | 检查分支是否存在、是否有变更 → 恢复或重新开始 |
| User aborts mid-loop | 状态文件已包含最新检查点,下次运行可恢复 |
| New issues created during loop | 不重新获取。完成当前批次后运行新 |
| Circular dependencies | 打印警告,按编号顺序打破循环 |
| 警告用户添加到 .gitignore,继续 |
误以为需要外部 | 本环境无此命令;「实现 issue」由 agent 内联完成(读 issue → 写代码 → 测试),不要中止循环 |
/loop-it
├── 内联实现 ← implement each issue(agent 自主读 issue、写代码、测试;非外部命令)
├── /review-it ← review code before shipping(skill)
└── /ship-it ← commit, PR, merge, close(skill)/prd → /prd-to-spec → /to-issues → /loop-it (→ 内联实现 → /review-it → /ship-it)×N