@boyingliu01/xp-gate 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/xp-gate.js +4 -9
- package/lib/__tests__/audit-log.test.ts +107 -0
- package/lib/__tests__/detect-deps.test.js +212 -42
- package/lib/__tests__/doctor.test.js +1 -0
- package/lib/__tests__/gate-audit.test.ts +59 -0
- package/lib/__tests__/init.test.js +47 -1
- package/lib/__tests__/install-skill.test.js +1 -45
- package/lib/__tests__/ui-detector.test.ts +186 -26
- package/lib/__tests__/ui-review.test.ts +119 -0
- package/lib/__tests__/uninstall.test.js +1 -0
- package/lib/detect-deps.js +180 -37
- package/lib/doctor.js +7 -9
- package/lib/gate-audit.ts +26 -42
- package/lib/init.js +42 -13
- package/lib/install-skill.js +20 -48
- package/lib/rollback.js +1 -16
- package/lib/shared-paths.js +30 -0
- package/lib/shared-utils.js +25 -0
- package/lib/ui-detector.ts +20 -14
- package/lib/ui-review.ts +58 -53
- package/lib/uninstall.js +8 -9
- package/package.json +1 -1
- package/plugins/claude-code/.claude-plugin/plugin.json +1 -1
- package/plugins/claude-code/skills/admin-template-guidelines/SKILL.md +904 -0
- package/plugins/claude-code/skills/delphi-review/.delphi-config.json.example +45 -0
- package/plugins/claude-code/skills/delphi-review/AGENTS.md +66 -0
- package/plugins/claude-code/skills/delphi-review/INSTALL.md +152 -0
- package/plugins/claude-code/skills/delphi-review/SKILL.md +454 -0
- package/plugins/claude-code/skills/delphi-review/opencode.json.delphi.example +56 -0
- package/plugins/claude-code/skills/delphi-review/references/code-walkthrough.md +486 -0
- package/plugins/claude-code/skills/improve-codebase-architecture/SKILL.md +156 -0
- package/plugins/claude-code/skills/ralph-loop/SKILL.md +501 -0
- package/plugins/claude-code/skills/ralph-loop/references/components/memory.md +55 -0
- package/plugins/claude-code/skills/ralph-loop/references/components/middleware.md +54 -0
- package/plugins/claude-code/skills/ralph-loop/references/components/skill-invocations.md +39 -0
- package/plugins/claude-code/skills/ralph-loop/references/components/system-prompt.md +24 -0
- package/plugins/claude-code/skills/ralph-loop/references/components/tool-descriptions.md +32 -0
- package/plugins/claude-code/skills/ralph-loop/references/phase-2-build-ralph.md +89 -0
- package/plugins/claude-code/skills/ralph-loop/templates/progress-log.md +36 -0
- package/plugins/claude-code/skills/sprint-flow/AGENTS.md +68 -0
- package/plugins/claude-code/skills/sprint-flow/SKILL.md +1248 -0
- package/plugins/claude-code/skills/sprint-flow/references/components/memory.md +87 -0
- package/plugins/claude-code/skills/sprint-flow/references/components/middleware.md +72 -0
- package/plugins/claude-code/skills/sprint-flow/references/components/skill-invocations.md +104 -0
- package/plugins/claude-code/skills/sprint-flow/references/components/system-prompt.md +27 -0
- package/plugins/claude-code/skills/sprint-flow/references/components/tool-descriptions.md +96 -0
- package/plugins/claude-code/skills/sprint-flow/references/force-levels.md +203 -0
- package/plugins/claude-code/skills/sprint-flow/references/phase-0-think.md +115 -0
- package/plugins/claude-code/skills/sprint-flow/references/phase-1-plan.md +178 -0
- package/plugins/claude-code/skills/sprint-flow/references/phase-2-build.md +198 -0
- package/plugins/claude-code/skills/sprint-flow/references/phase-3-review.md +213 -0
- package/plugins/claude-code/skills/sprint-flow/references/phase-4-uat.md +125 -0
- package/plugins/claude-code/skills/sprint-flow/references/phase-5-feedback.md +100 -0
- package/plugins/claude-code/skills/sprint-flow/references/phase-6-ship.md +193 -0
- package/plugins/claude-code/skills/sprint-flow/references/phase-7-land.md +140 -0
- package/plugins/claude-code/skills/sprint-flow/references/phase-8-cleanup.md +192 -0
- package/plugins/claude-code/skills/sprint-flow/references/phase-minus-0-5-auto-estimate.md +257 -0
- package/plugins/claude-code/skills/sprint-flow/templates/auto-estimate-learning-log.md +136 -0
- package/plugins/claude-code/skills/sprint-flow/templates/auto-estimate-output-template.md +132 -0
- package/plugins/claude-code/skills/sprint-flow/templates/emergent-issues-template.md +120 -0
- package/plugins/claude-code/skills/sprint-flow/templates/pain-document-template.md +115 -0
- package/plugins/claude-code/skills/sprint-flow/templates/sprint-progress-template.md +151 -0
- package/plugins/claude-code/skills/sprint-flow/templates/sprint-summary-template.md +120 -0
- package/plugins/claude-code/skills/test-driven-development/SKILL.md +71 -0
- package/plugins/claude-code/skills/test-specification-alignment/AGENTS.md +56 -0
- package/plugins/claude-code/skills/test-specification-alignment/SKILL.md +702 -0
- package/plugins/claude-code/skills/test-specification-alignment/references/alignment-verification-algorithm.md +493 -0
- package/plugins/claude-code/skills/test-specification-alignment/references/phase2-constraint-enforcement.md +431 -0
- package/plugins/claude-code/skills/test-specification-alignment/references/specification-format.md +348 -0
- package/plugins/claude-code/skills/to-issues/SKILL.md +277 -0
- package/plugins/opencode/README.md +38 -0
- package/plugins/opencode/index.ts +85 -0
- package/plugins/opencode/package.json +18 -0
- package/plugins/opencode/skills/admin-template-guidelines/SKILL.md +904 -0
- package/plugins/opencode/skills/delphi-review/.delphi-config.json.example +45 -0
- package/plugins/opencode/skills/delphi-review/AGENTS.md +66 -0
- package/plugins/opencode/skills/delphi-review/INSTALL.md +152 -0
- package/plugins/opencode/skills/delphi-review/SKILL.md +454 -0
- package/plugins/opencode/skills/delphi-review/opencode.json.delphi.example +56 -0
- package/plugins/opencode/skills/delphi-review/references/code-walkthrough.md +486 -0
- package/plugins/opencode/skills/improve-codebase-architecture/SKILL.md +156 -0
- package/plugins/opencode/skills/ralph-loop/SKILL.md +501 -0
- package/plugins/opencode/skills/ralph-loop/references/components/memory.md +55 -0
- package/plugins/opencode/skills/ralph-loop/references/components/middleware.md +54 -0
- package/plugins/opencode/skills/ralph-loop/references/components/skill-invocations.md +39 -0
- package/plugins/opencode/skills/ralph-loop/references/components/system-prompt.md +24 -0
- package/plugins/opencode/skills/ralph-loop/references/components/tool-descriptions.md +32 -0
- package/plugins/opencode/skills/ralph-loop/references/phase-2-build-ralph.md +89 -0
- package/plugins/opencode/skills/ralph-loop/templates/progress-log.md +36 -0
- package/plugins/opencode/skills/sprint-flow/AGENTS.md +68 -0
- package/plugins/opencode/skills/sprint-flow/SKILL.md +1248 -0
- package/plugins/opencode/skills/sprint-flow/references/components/memory.md +87 -0
- package/plugins/opencode/skills/sprint-flow/references/components/middleware.md +72 -0
- package/plugins/opencode/skills/sprint-flow/references/components/skill-invocations.md +104 -0
- package/plugins/opencode/skills/sprint-flow/references/components/system-prompt.md +27 -0
- package/plugins/opencode/skills/sprint-flow/references/components/tool-descriptions.md +96 -0
- package/plugins/opencode/skills/sprint-flow/references/force-levels.md +203 -0
- package/plugins/opencode/skills/sprint-flow/references/phase-0-think.md +115 -0
- package/plugins/opencode/skills/sprint-flow/references/phase-1-plan.md +178 -0
- package/plugins/opencode/skills/sprint-flow/references/phase-2-build.md +198 -0
- package/plugins/opencode/skills/sprint-flow/references/phase-3-review.md +213 -0
- package/plugins/opencode/skills/sprint-flow/references/phase-4-uat.md +125 -0
- package/plugins/opencode/skills/sprint-flow/references/phase-5-feedback.md +100 -0
- package/plugins/opencode/skills/sprint-flow/references/phase-6-ship.md +193 -0
- package/plugins/opencode/skills/sprint-flow/references/phase-7-land.md +140 -0
- package/plugins/opencode/skills/sprint-flow/references/phase-8-cleanup.md +192 -0
- package/plugins/opencode/skills/sprint-flow/references/phase-minus-0-5-auto-estimate.md +257 -0
- package/plugins/opencode/skills/sprint-flow/templates/auto-estimate-learning-log.md +136 -0
- package/plugins/opencode/skills/sprint-flow/templates/auto-estimate-output-template.md +132 -0
- package/plugins/opencode/skills/sprint-flow/templates/emergent-issues-template.md +120 -0
- package/plugins/opencode/skills/sprint-flow/templates/pain-document-template.md +115 -0
- package/plugins/opencode/skills/sprint-flow/templates/sprint-progress-template.md +151 -0
- package/plugins/opencode/skills/sprint-flow/templates/sprint-summary-template.md +120 -0
- package/plugins/opencode/skills/test-driven-development/SKILL.md +71 -0
- package/plugins/opencode/skills/test-specification-alignment/AGENTS.md +56 -0
- package/plugins/opencode/skills/test-specification-alignment/SKILL.md +702 -0
- package/plugins/opencode/skills/test-specification-alignment/references/alignment-verification-algorithm.md +493 -0
- package/plugins/opencode/skills/test-specification-alignment/references/phase2-constraint-enforcement.md +431 -0
- package/plugins/opencode/skills/test-specification-alignment/references/specification-format.md +348 -0
- package/plugins/opencode/skills/to-issues/SKILL.md +277 -0
- package/plugins/opencode/tsconfig.json +15 -0
- package/plugins/qoder/skills/admin-template-guidelines/SKILL.md +904 -0
- package/plugins/qoder/skills/delphi-review/.delphi-config.json.example +45 -0
- package/plugins/qoder/skills/delphi-review/AGENTS.md +66 -0
- package/plugins/qoder/skills/delphi-review/INSTALL.md +152 -0
- package/plugins/qoder/skills/delphi-review/SKILL.md +454 -0
- package/plugins/qoder/skills/delphi-review/opencode.json.delphi.example +56 -0
- package/plugins/qoder/skills/delphi-review/references/code-walkthrough.md +486 -0
- package/plugins/qoder/skills/improve-codebase-architecture/SKILL.md +156 -0
- package/plugins/qoder/skills/ralph-loop/SKILL.md +501 -0
- package/plugins/qoder/skills/ralph-loop/references/components/memory.md +55 -0
- package/plugins/qoder/skills/ralph-loop/references/components/middleware.md +54 -0
- package/plugins/qoder/skills/ralph-loop/references/components/skill-invocations.md +39 -0
- package/plugins/qoder/skills/ralph-loop/references/components/system-prompt.md +24 -0
- package/plugins/qoder/skills/ralph-loop/references/components/tool-descriptions.md +32 -0
- package/plugins/qoder/skills/ralph-loop/references/phase-2-build-ralph.md +89 -0
- package/plugins/qoder/skills/ralph-loop/templates/progress-log.md +36 -0
- package/plugins/qoder/skills/sprint-flow/AGENTS.md +68 -0
- package/plugins/qoder/skills/sprint-flow/SKILL.md +1248 -0
- package/plugins/qoder/skills/sprint-flow/references/components/memory.md +87 -0
- package/plugins/qoder/skills/sprint-flow/references/components/middleware.md +72 -0
- package/plugins/qoder/skills/sprint-flow/references/components/skill-invocations.md +104 -0
- package/plugins/qoder/skills/sprint-flow/references/components/system-prompt.md +27 -0
- package/plugins/qoder/skills/sprint-flow/references/components/tool-descriptions.md +96 -0
- package/plugins/qoder/skills/sprint-flow/references/force-levels.md +203 -0
- package/plugins/qoder/skills/sprint-flow/references/phase-0-think.md +115 -0
- package/plugins/qoder/skills/sprint-flow/references/phase-1-plan.md +178 -0
- package/plugins/qoder/skills/sprint-flow/references/phase-2-build.md +198 -0
- package/plugins/qoder/skills/sprint-flow/references/phase-3-review.md +213 -0
- package/plugins/qoder/skills/sprint-flow/references/phase-4-uat.md +125 -0
- package/plugins/qoder/skills/sprint-flow/references/phase-5-feedback.md +100 -0
- package/plugins/qoder/skills/sprint-flow/references/phase-6-ship.md +193 -0
- package/plugins/qoder/skills/sprint-flow/references/phase-7-land.md +140 -0
- package/plugins/qoder/skills/sprint-flow/references/phase-8-cleanup.md +192 -0
- package/plugins/qoder/skills/sprint-flow/references/phase-minus-0-5-auto-estimate.md +257 -0
- package/plugins/qoder/skills/sprint-flow/templates/auto-estimate-learning-log.md +136 -0
- package/plugins/qoder/skills/sprint-flow/templates/auto-estimate-output-template.md +132 -0
- package/plugins/qoder/skills/sprint-flow/templates/emergent-issues-template.md +120 -0
- package/plugins/qoder/skills/sprint-flow/templates/pain-document-template.md +115 -0
- package/plugins/qoder/skills/sprint-flow/templates/sprint-progress-template.md +151 -0
- package/plugins/qoder/skills/sprint-flow/templates/sprint-summary-template.md +120 -0
- package/plugins/qoder/skills/test-driven-development/SKILL.md +71 -0
- package/plugins/qoder/skills/test-specification-alignment/AGENTS.md +56 -0
- package/plugins/qoder/skills/test-specification-alignment/SKILL.md +702 -0
- package/plugins/qoder/skills/test-specification-alignment/references/alignment-verification-algorithm.md +493 -0
- package/plugins/qoder/skills/test-specification-alignment/references/phase2-constraint-enforcement.md +431 -0
- package/plugins/qoder/skills/test-specification-alignment/references/specification-format.md +348 -0
- package/plugins/qoder/skills/to-issues/SKILL.md +277 -0
- package/skills/admin-template-guidelines/SKILL.md +904 -0
- package/skills/delphi-review/SKILL.md +112 -77
- package/skills/improve-codebase-architecture/SKILL.md +156 -0
- package/skills/ralph-loop/SKILL.md +165 -34
- package/skills/sprint-flow/SKILL.md +448 -107
- package/skills/sprint-flow/references/components/skill-invocations.md +1 -1
- package/skills/sprint-flow/references/components/tool-descriptions.md +1 -1
- package/skills/sprint-flow/references/force-levels.md +203 -0
- package/skills/sprint-flow/references/phase-1-plan.md +4 -4
- package/skills/sprint-flow/references/phase-minus-0-5-auto-estimate.md +20 -1
- package/skills/sprint-flow/templates/auto-estimate-output-template.md +7 -5
- package/skills/sprint-flow/templates/sprint-progress-template.md +151 -0
- package/skills/test-driven-development/SKILL.md +71 -0
- package/skills/test-specification-alignment/SKILL.md +98 -24
- package/skills/to-issues/SKILL.md +277 -0
- package/plugins/qoder/AGENTS.md +0 -93
- package/plugins/qoder/README.md +0 -87
- package/plugins/qoder/widgets/quality-report.html +0 -163
- package/plugins/qoder/widgets/sprint-dashboard.html +0 -172
- package/skills/delphi-review/evals/evals.json +0 -82
- package/skills/delphi-review/references/qoder-multi-model.md +0 -191
- package/skills/ralph-loop/evals/evals.json +0 -311
- package/skills/ralph-loop/evolution-history.json +0 -59
- package/skills/ralph-loop/evolution-log.md +0 -16
- package/skills/sprint-flow/evals/evals.json +0 -130
- package/skills/sprint-flow/evolution-history.json +0 -39
- package/skills/sprint-flow/evolution-log.md +0 -23
- package/skills/sprint-flow/references/qoder-adaptation.md +0 -173
- package/skills/test-specification-alignment/evals/evals.json +0 -75
|
@@ -0,0 +1,501 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ralph-loop
|
|
3
|
+
description: Use when executing Sprint-Flow Phase 2 BUILD, processing one REQ, building the next requirement, iterating with clean context, or requiring full regression per requirement.
|
|
4
|
+
maturity: stable
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Ralph Loop — Default REQ-Level Iterative Build
|
|
8
|
+
|
|
9
|
+
## 核心原则
|
|
10
|
+
|
|
11
|
+
| 原则 | 说明 |
|
|
12
|
+
|------|------|
|
|
13
|
+
| **每次迭代 = 全新上下文** | 每个 REQ dispatch 独立 subagent,不累积历史对话 |
|
|
14
|
+
| **一次只处理一个 REQ** | 小粒度执行,避免大任务吞掉整个 context window |
|
|
15
|
+
| **失败不提交** | 验证不通过的代码不 commit,保持代码库绿色 |
|
|
16
|
+
| **全量回归测试** | 每个 REQ 完成后运行 ALL tests(不只是 @test REQ-XXX),检测跨 REQ 回归 |
|
|
17
|
+
| **Git 持久记忆** | 代码变更 + checkpoint 天然持久,不需要在 prompt 里反复解释 |
|
|
18
|
+
| **浓缩型分类学习** | permanent(架构级)+ contextual(最近 3 条)双层 learnings |
|
|
19
|
+
| **AGENTS.md 统一更新** | orchestrator 统一写,subagent 不直接修改 — 无竞态 |
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Triggers
|
|
24
|
+
|
|
25
|
+
**关键词触发**:ralph-loop, process one REQ, build next requirement, Phase 2 BUILD, iterate REQ, isolated REQ build, clean context, full regression
|
|
26
|
+
|
|
27
|
+
**使用场景**:
|
|
28
|
+
- 执行 Sprint-Flow Phase 2 BUILD 阶段
|
|
29
|
+
- 从 specification.yaml 读取需求逐个实现
|
|
30
|
+
- 需要控制每个 REQ 的 token 预算
|
|
31
|
+
- 防止上下文污染(前一个 REQ 的实现细节影响后一个 REQ)
|
|
32
|
+
- 需要全量回归测试保证不引入回归
|
|
33
|
+
- 需要持久化 learnings 供后续 REQ 参考
|
|
34
|
+
|
|
35
|
+
**何时不使用**:
|
|
36
|
+
- 需求数量极少(1-2 个)且相互独立,可以并行
|
|
37
|
+
- 紧急热修复,不需要完整 Sprint Flow
|
|
38
|
+
- 明确使用 `--mode parallel` 切换到并行模式
|
|
39
|
+
|
|
40
|
+
## 作为 Phase 2 默认行为
|
|
41
|
+
|
|
42
|
+
Ralph Loop 是 Sprint-Flow **Phase 2 BUILD 的默认模式**:
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
Sprint-Flow Phase 2 (默认):
|
|
46
|
+
ralph-loop → 逐 REQ 迭代 → 每次干净上下文 → 全量回归 → token 节约 40-67%
|
|
47
|
+
|
|
48
|
+
Sprint-Flow Phase 2 --mode parallel (可选):
|
|
49
|
+
dispatching-parallel-agents → 所有需求一次性并行 → 上下文线性增长
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
**为什么它是默认**: 每个 Sprint 都受 token limit 约束。累积模式在 3+ REQs 时限流频率显著上升。ralph-loop 确保每个 REQ 的 token 预算独立可控。
|
|
53
|
+
|
|
54
|
+
**切换回并行模式**: `/sprint-flow "需求" --mode parallel`
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## 完整流程
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
Phase 0: 准备 → 读取 specification.yaml → 构建依赖图 → 拓扑排序
|
|
62
|
+
│
|
|
63
|
+
▼
|
|
64
|
+
Phase 1: 迭代循环 (max_iterations=15 默认)
|
|
65
|
+
│
|
|
66
|
+
├── 取下一个 READY REQ(依赖已满足,优先级最高)
|
|
67
|
+
│
|
|
68
|
+
├── 测试基础设施检查
|
|
69
|
+
│ 1. 检查 test-utils.ts(或等效文件)是否存在
|
|
70
|
+
│ 2. 检查必需接口契约:createTestApp()、withTestDb()
|
|
71
|
+
│ 3. 不存在或接口缺失 → dispatch "生成测试基础设施" subagent
|
|
72
|
+
│ retry max 2 → 仍失败 → BLOCK 或 fallback inline 生成
|
|
73
|
+
│ 4. 与业务代码合并为同一 commit
|
|
74
|
+
│
|
|
75
|
+
├── 注入测试基础设施摘要到业务代码 subagent context:
|
|
76
|
+
│ 【已有测试基础设施】test-utils.ts 已存在,导出以下 API:
|
|
77
|
+
│ - createTestApp(): 创建应用实例 + 真实测试依赖
|
|
78
|
+
│ - withTestDb(): 测试数据库生命周期(seed + cleanup)
|
|
79
|
+
│ 必须 import 这些函数,禁止重新手搓同名 helper。
|
|
80
|
+
│
|
|
81
|
+
├── Dispatch 独立 subagent
|
|
82
|
+
│ 使用: task(category="unspecified-high", load_skills=["test-driven-development"], timeout=300)
|
|
83
|
+
│ Context:
|
|
84
|
+
│ - 当前 REQ + 所有 AC
|
|
85
|
+
│ - permanent learnings(架构决策,始终传入)
|
|
86
|
+
│ - contextual learnings(最近 3 条)
|
|
87
|
+
│ - retry-failures(仅 retry 时注入失败原因)
|
|
88
|
+
│ - AGENTS.md(项目约定)
|
|
89
|
+
│ - git log --oneline -5
|
|
90
|
+
│ - 【TDD 铁律】RED → GREEN → REFACTOR。任何模块必须先写测试再写实现。
|
|
91
|
+
│ - 【Mock 边界】(覆盖 TDD skill 默认策略)
|
|
92
|
+
│ ✅ MOCK: 外部 HTTP API、LLM 调用、第三方平台(钉钉/微信)
|
|
93
|
+
│ ✅ MOCK: 时间/随机数/UUID(注入依赖)
|
|
94
|
+
│ ❌ NO MOCK: 数据库操作(用真实测试库或 sqlite-in-memory)
|
|
95
|
+
│ ❌ NO MOCK: HTTP 路由(用 app.inject() 真实注入)
|
|
96
|
+
│ ❌ NO MOCK: 模板引擎(用真实 Nunjucks/Jinja 渲染)
|
|
97
|
+
│ ❌ NO MOCK: 纯业务逻辑(用真实输入输出)
|
|
98
|
+
│ - 【Mock 密度上限】测试中 mock/spy/fn 引用行数 > 总测试行数 30% 时,
|
|
99
|
+
│ 必须添加 // @mock-justified: <至少10字符理由> 注释说明为何无法用集成测试。
|
|
100
|
+
│
|
|
101
|
+
├── Subagent 完成 → 三层验证
|
|
102
|
+
│ ├── L1: typecheck + lint → FAIL? → retry
|
|
103
|
+
│ ├── L2: 全量测试(ALL tests)→ FAIL? → retry
|
|
104
|
+
│ └── L3: coverage ≥ 80% → FAIL? → retry
|
|
105
|
+
│
|
|
106
|
+
├── PASS → git commit → 标记 done
|
|
107
|
+
│ → 写 learnings(分类为 permanent/contextual)
|
|
108
|
+
│ → 调用 `gstack/learn` 及时总结经验教训
|
|
109
|
+
│ → orchestrator 统一更新 AGENTS.md
|
|
110
|
+
│ → 原子写 checkpoint
|
|
111
|
+
│ → 继续下一个 READY REQ
|
|
112
|
+
│
|
|
113
|
+
└── FAIL → retry(max 3,注入上次错误摘要)
|
|
114
|
+
└── 仍失败 → BLOCK → 依赖级联 → 用户决策
|
|
115
|
+
│
|
|
116
|
+
▼
|
|
117
|
+
终止条件:
|
|
118
|
+
- 所有 REQ done → COMPLETE → 返回 Phase 3 REVIEW
|
|
119
|
+
- max_iterations 达到 → PARTIAL → 保留 done commits
|
|
120
|
+
- BLOCK → WAIT_USER → skip/manual/stop/rollback
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## 输入格式 (specification.yaml)
|
|
126
|
+
|
|
127
|
+
```yaml
|
|
128
|
+
specification:
|
|
129
|
+
requirements:
|
|
130
|
+
- id: REQ-001
|
|
131
|
+
description: "创建 User Model 和数据库迁移"
|
|
132
|
+
acceptance_criteria:
|
|
133
|
+
- id: AC-001-01
|
|
134
|
+
criteria: "User model 包含 email (unique), password_hash, created_at"
|
|
135
|
+
- id: AC-001-02
|
|
136
|
+
criteria: "Migration 成功执行"
|
|
137
|
+
priority: 1
|
|
138
|
+
status: pending
|
|
139
|
+
|
|
140
|
+
- id: REQ-002
|
|
141
|
+
description: "实现密码加密工具函数"
|
|
142
|
+
depends_on: [REQ-001]
|
|
143
|
+
acceptance_criteria:
|
|
144
|
+
- id: AC-002-01
|
|
145
|
+
criteria: "hashPassword() 返回 bcrypt hash"
|
|
146
|
+
- id: AC-002-02
|
|
147
|
+
criteria: "verifyPassword() 正确比对明文和 hash"
|
|
148
|
+
priority: 2
|
|
149
|
+
status: pending
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
**每个 REQ 自动作为一个迭代单元**,其所有 `AC-XXX-XX` 作为验收标准。
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## 依赖排序
|
|
157
|
+
|
|
158
|
+
1. **拓扑排序**:对所有 pending REQs 构建依赖图(基于 `depends_on`)
|
|
159
|
+
2. **Kahn's algorithm**:执行拓扑排序,检测循环依赖
|
|
160
|
+
3. **同层按 priority**:同一拓扑层内的 REQ 按 `priority` 升序排列
|
|
161
|
+
4. **循环依赖**:→ BLOCK + 报告循环链(`REQ-A → REQ-B → REQ-C → REQ-A`)
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## Learnings 分类
|
|
166
|
+
|
|
167
|
+
| 分类 | 内容 | 传递策略 | 升级条件 |
|
|
168
|
+
|------|------|---------|---------|
|
|
169
|
+
| **permanent** | 架构决策、接口约定、全局约定 | 始终传入(每个 REQ context)| (1) 被 ≥2 个 REQ 引用<br>(2) 涉及模块接口/数据结构<br>(3) 用户手动标记 |
|
|
170
|
+
| **contextual** | 实现细节、一次性 gotchas、临时技巧 | 滑动窗口(最近 3 条) | 满足 permanent 条件自动升级,否则 3 条后过期 |
|
|
171
|
+
|
|
172
|
+
**自动升级示例**:
|
|
173
|
+
- `"migration files must be in src/migrations/"` → 第 2 个 REQ 也引用 → 升级为 permanent
|
|
174
|
+
- `"use bcrypt 不要使用 md5"` → 安全规范 → 自动 permanent
|
|
175
|
+
- `"第 42 行有个 off-by-one"` → 仅影响单个 REQ → 保持 contextual
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
## AGENTS.md 更新机制
|
|
180
|
+
|
|
181
|
+
**由 orchestrator 统一执行,不由 subagent 各自写**:
|
|
182
|
+
|
|
183
|
+
1. subagent 完成后输出 `agentmd_addition` 字段
|
|
184
|
+
2. orchestrator 读取当前 AGENTS.md
|
|
185
|
+
3. orchestrator append `## ralph-loop: [REQ-XXX title] (auto-added)` 段
|
|
186
|
+
4. orchestrator 将 AGENTS.md 变更纳入 git commit
|
|
187
|
+
|
|
188
|
+
当 AGENTS.md > 500 行时触发归档:保留最近 6 个月 entries,更早的归档到 `.sprint-state/ralph-loop/agents-archive/`。
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
## 三层验证 Gate
|
|
193
|
+
|
|
194
|
+
每个 REQ 完成后执行:
|
|
195
|
+
|
|
196
|
+
| 层级 | 范围 | 工具 | 失败行为 |
|
|
197
|
+
|------|------|------|---------|
|
|
198
|
+
| L1 | 变更文件 | `lsp_diagnostics` + linter | retry |
|
|
199
|
+
| L1b | 测试先行比率 | 新增测试行数 / (新增测试 + 新增实现) ≥ 40% | retry |
|
|
200
|
+
| L2 | **全量测试**(不只是 @test REQ-XXX) | 项目测试框架 | retry |
|
|
201
|
+
| L3 | 整体覆盖率 ≥ 80% | coverage report | retry |
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
## 状态机
|
|
206
|
+
|
|
207
|
+
```
|
|
208
|
+
PENDING → test_infra_check → [infra needed?] → test_infra_dispatch
|
|
209
|
+
│ │
|
|
210
|
+
│ FAIL │ pass
|
|
211
|
+
│ (max 2 retry) │
|
|
212
|
+
▼ ▼
|
|
213
|
+
BLOCK/fallback test_infra_ready → in_progress → done (commit)
|
|
214
|
+
│ │
|
|
215
|
+
│ depend not met │ all done → COMPLETE
|
|
216
|
+
│ ┌───────────────┘
|
|
217
|
+
▼ │
|
|
218
|
+
PENDING (waiting)
|
|
219
|
+
│
|
|
220
|
+
│ fail
|
|
221
|
+
▼
|
|
222
|
+
RETRY (n≤3, 注入上次错误)
|
|
223
|
+
│
|
|
224
|
+
│ n≥3
|
|
225
|
+
▼
|
|
226
|
+
BLOCKED → 用户决策 (skip/manual/stop/rollback)
|
|
227
|
+
│
|
|
228
|
+
│ 依赖上游 blocked → 自动 blocked(含依赖链)
|
|
229
|
+
▼
|
|
230
|
+
auto-blocked REQs
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
**REQ 状态转换规则**:
|
|
234
|
+
|
|
235
|
+
| 从 | 到 | 触发 |
|
|
236
|
+
|---|---|---|
|
|
237
|
+
| pending | test_infra_check | 拓扑排序轮到 + 依赖已满足 |
|
|
238
|
+
| test_infra_check | test_infra_dispatch | test-utils.ts 不存在或接口缺失 |
|
|
239
|
+
| test_infra_check | in_progress | test-utils.ts 已存在且接口完整 |
|
|
240
|
+
| test_infra_dispatch | test_infra_ready | 测试基础设施生成完成 |
|
|
241
|
+
| test_infra_dispatch | blocked | retry max 2 仍失败 |
|
|
242
|
+
| test_infra_dispatch | test_infra_ready | fallback inline 生成成功(记录 warning)|
|
|
243
|
+
| test_infra_ready | in_progress | 测试基础设施就绪,dispatch 业务代码 subagent |
|
|
244
|
+
| in_progress | done | L1+L1b+L2+L3 全部通过 |
|
|
245
|
+
| in_progress | retry | 验证失败, n<3 |
|
|
246
|
+
| retry | done | 验证通过 |
|
|
247
|
+
| retry | blocked | n≥3 仍失败 |
|
|
248
|
+
| pending | blocked(auto) | 上游依赖 blocked |
|
|
249
|
+
| blocked | skipped | 用户选择跳过 |
|
|
250
|
+
| blocked | done | 用户手动修复后确认 |
|
|
251
|
+
| 任意 | partial | 用户选择停止 |
|
|
252
|
+
| 任意 | rollback | 用户选择回滚 (git reset) |
|
|
253
|
+
|
|
254
|
+
**崩溃恢复**:启动时检测 checkpoint → 跳过已 done REQs → 从下一个 pending 继续。已 commit 的 REQ 不需要重做。
|
|
255
|
+
|
|
256
|
+
---
|
|
257
|
+
|
|
258
|
+
## Retry 策略
|
|
259
|
+
|
|
260
|
+
| 轮次 | 注入上下文 | 超时 |
|
|
261
|
+
|------|-----------|------|
|
|
262
|
+
| 第 1 次 | 标准上下文 | 300s |
|
|
263
|
+
| 第 2 次 | 标准 + 上次失败摘要 (linter+tests) | 300s |
|
|
264
|
+
| 第 3 次 | 标准 + 前两次失败摘要 + "请使用不同实现方式" | 300s |
|
|
265
|
+
|
|
266
|
+
---
|
|
267
|
+
|
|
268
|
+
## 与 Sprint-Flow 集成
|
|
269
|
+
|
|
270
|
+
**默认启用**:Phase 2 BUILD 自动使用 ralph-loop 模式。
|
|
271
|
+
|
|
272
|
+
```bash
|
|
273
|
+
/sprint-flow "开发用户登录"
|
|
274
|
+
# → Phase 2 自动使用 ralph-loop 模式
|
|
275
|
+
|
|
276
|
+
/sprint-flow "开发小改动" --mode parallel
|
|
277
|
+
# → 可选:切换回旧有的并行模式
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
Phase 0, 1, 3-6 行为完全不变。
|
|
281
|
+
|
|
282
|
+
**与 test-specification-alignment 完全兼容**:
|
|
283
|
+
- Test alignment 仍解析 specification.yaml (REQ/AC 不变)
|
|
284
|
+
- 仍查找 `@test REQ-XXX` / `@covers AC-XXX-XX`
|
|
285
|
+
- PARTIAL 状态下仅检查已 done REQs
|
|
286
|
+
|
|
287
|
+
---
|
|
288
|
+
|
|
289
|
+
## Output Format (MANDATORY)
|
|
290
|
+
|
|
291
|
+
```json
|
|
292
|
+
{
|
|
293
|
+
"skill_name": "ralph-loop",
|
|
294
|
+
"version": "2.0.0",
|
|
295
|
+
"specification_source": "specification.yaml",
|
|
296
|
+
"topology_order": ["REQ-001", "REQ-002", "REQ-003"],
|
|
297
|
+
"requirements": { "total": 6, "done": 4, "pending": 1, "blocked": 1, "skipped": 0 },
|
|
298
|
+
"current_requirement": { "id": "REQ-005", "status": "done", "retry_count": 0 },
|
|
299
|
+
"learnings": {
|
|
300
|
+
"permanent": ["Auth middleware must run before validation"],
|
|
301
|
+
"contextual": ["migration files must be in src/migrations/"]
|
|
302
|
+
},
|
|
303
|
+
"status": "running",
|
|
304
|
+
"checkpoint_at": "2026-05-08T10:30:00Z"
|
|
305
|
+
}
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
**Eval assertions**: `done + pending + blocked + skipped == total`, `iteration <= max_iterations`.
|
|
309
|
+
|
|
310
|
+
---
|
|
311
|
+
|
|
312
|
+
## Workflow Steps (Mandatory Execution Order)
|
|
313
|
+
|
|
314
|
+
**每个 REQ 必须按以下顺序执行,不得跳过或重排**:
|
|
315
|
+
|
|
316
|
+
1. **Load next READY REQ**
|
|
317
|
+
- 从 specification.yaml 读取下一个依赖已满足的 REQ
|
|
318
|
+
- 检查 priority 和 status (pending 状态)
|
|
319
|
+
- 构建依赖图,确认无循环依赖
|
|
320
|
+
|
|
321
|
+
2. **Create isolated context**
|
|
322
|
+
- 清空前一个 REQ 的对话历史
|
|
323
|
+
- 注入:当前 REQ + AC + permanent learnings + contextual learnings (最近 3 条)
|
|
324
|
+
- 注入:AGENTS.md + git log --oneline -5 + 测试基础设施摘要
|
|
325
|
+
|
|
326
|
+
3. **Dispatch build subagent**
|
|
327
|
+
- 使用 `task(category="unspecified-high", load_skills=["test-driven-development"], timeout=300)`
|
|
328
|
+
- 强制 TDD 流程:RED → GREEN → REFACTOR
|
|
329
|
+
- 强制执行 Mock 边界策略(详见 Mock 边界表)
|
|
330
|
+
|
|
331
|
+
4. **Run full regression tests**
|
|
332
|
+
- L1: typecheck + lint on changed files
|
|
333
|
+
- L1b: 检查测试先行比率 (新增测试行数 / 总新增行数 ≥ 40%)
|
|
334
|
+
- **L2: 全量测试运行**(不只是 @test 当前 REQ 的测试)
|
|
335
|
+
- L3: 检查整体覆盖率 ≥ 80%
|
|
336
|
+
|
|
337
|
+
5. **Fix until green or block**
|
|
338
|
+
- 失败 → retry (max 3 次,每次注入失败摘要)
|
|
339
|
+
- 第 3 次仍失败 → BLOCK → 等待用户决策 (skip/manual/stop/rollback)
|
|
340
|
+
- 通过 → git commit + 标记 done
|
|
341
|
+
|
|
342
|
+
6. **Persist learnings**
|
|
343
|
+
- 分类为 permanent(架构级)或 contextual(临时性)
|
|
344
|
+
- 自动升级条件:被≥2 个 REQ 引用 或 涉及接口/数据结构
|
|
345
|
+
- 调用 `gstack/learn` 总结经验教训
|
|
346
|
+
|
|
347
|
+
7. **Update sprint state**
|
|
348
|
+
- orchestrator 统一更新 AGENTS.md(append `## ralph-loop: [REQ-XXX title]`)
|
|
349
|
+
- 原子写 checkpoint (progress.log)
|
|
350
|
+
- 继续下一个 READY REQ
|
|
351
|
+
|
|
352
|
+
**禁止行为**:
|
|
353
|
+
- ❌ 跳过测试基础设施检查
|
|
354
|
+
- ❌ 只运行部分测试(必须全量回归)
|
|
355
|
+
- ❌ 验证失败仍 commit
|
|
356
|
+
- ❌ 多个 subagent 同时写 AGENTS.md
|
|
357
|
+
- ❌ 修改前一个 REQ 的代码(除非修复回归)
|
|
358
|
+
|
|
359
|
+
---
|
|
360
|
+
|
|
361
|
+
## Scope
|
|
362
|
+
|
|
363
|
+
**In Scope**:
|
|
364
|
+
- Phase 2 BUILD 阶段的 REQ 级迭代构建
|
|
365
|
+
- 从 specification.yaml 读取需求并逐个实现
|
|
366
|
+
- 测试先行(TDD)+ 全量回归测试
|
|
367
|
+
- 持久化 learnings 供后续 REQ 参考
|
|
368
|
+
- 依赖排序和循环依赖检测
|
|
369
|
+
- 崩溃恢复(从 checkpoint 继续)
|
|
370
|
+
|
|
371
|
+
**Out of Scope**:
|
|
372
|
+
- Phase 0-1 (THINK/PLAN) 的需求分析和设计
|
|
373
|
+
- Phase 3-6 (REVIEW/USER ACCEPT/FEEDBACK/SHIP) 的后续阶段
|
|
374
|
+
- 并行模式(需显式使用 `--mode parallel` 切换到 `dispatching-parallel-agents`)
|
|
375
|
+
- 紧急热修复(应使用标准 sprint-flow 或手动处理)
|
|
376
|
+
- 非 specification.yaml 定义的需求(临时需求应先纳入 spec 再执行)
|
|
377
|
+
|
|
378
|
+
---
|
|
379
|
+
|
|
380
|
+
## Examples
|
|
381
|
+
|
|
382
|
+
**Example 1: 标准 Sprint Flow 启动**
|
|
383
|
+
```bash
|
|
384
|
+
/sprint-flow "开发用户登录功能,支持 JWT 和 OAuth2" --type web-nextjs
|
|
385
|
+
# → Phase 0-1 完成设计评审后,Phase 2 自动进入 ralph-loop 模式
|
|
386
|
+
# → 按拓扑顺序处理 REQ-001 (User Model) → REQ-002 (Auth Middleware) → REQ-003 (Login API)
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
**Example 2: 单个 REQ 构建**
|
|
390
|
+
```bash
|
|
391
|
+
/ralph-loop
|
|
392
|
+
# → 从 specification.yaml 读取下一个 READY REQ
|
|
393
|
+
# → 创建孤立上下文,dispatch TDD subagent
|
|
394
|
+
# → 全量回归测试通过后 commit
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
**Example 3: 处理阻塞 REQ**
|
|
398
|
+
```
|
|
399
|
+
REQ-005 失败 3 次 → BLOCKED
|
|
400
|
+
→ 用户决策:
|
|
401
|
+
- skip: 跳过此 REQ,继续 REQ-006
|
|
402
|
+
- manual: 手动修复后重新 dispatch
|
|
403
|
+
- stop: 停止整个 ralph-loop,保留已 done commits
|
|
404
|
+
- rollback: git reset 回上一个稳定版本
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
**Example 4: 崩溃恢复**
|
|
408
|
+
```bash
|
|
409
|
+
# 系统崩溃后重新启动
|
|
410
|
+
/ralph-loop --resume
|
|
411
|
+
# → 检测 progress.log → 跳过已 done REQs
|
|
412
|
+
# → 从最后一个 pending REQ 继续,无需重做已完成工作
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
**Example 5: 测试基础设施缺失**
|
|
416
|
+
```
|
|
417
|
+
REQ-001 开始 → 检查 test-utils.ts → 不存在
|
|
418
|
+
→ dispatch "生成测试基础设施" subagent
|
|
419
|
+
→ retry max 2 次 → 仍失败 → BLOCK 或 fallback inline 生成
|
|
420
|
+
→ 基础设施就绪后继续业务代码开发
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
---
|
|
424
|
+
|
|
425
|
+
## Output Contract (Mandatory Checklist)
|
|
426
|
+
|
|
427
|
+
**每个 REQ 完成时必须输出以下结构化检查清单**:
|
|
428
|
+
|
|
429
|
+
```markdown
|
|
430
|
+
## REQ-XXX: [Title] - Execution Summary
|
|
431
|
+
|
|
432
|
+
**Status**: ✅ PASS / ❌ FAIL (retry n/3) / 🚫 BLOCKED
|
|
433
|
+
|
|
434
|
+
**Context Isolation**:
|
|
435
|
+
- [ ] Previous REQ context cleared
|
|
436
|
+
- [ ] Permanent learnings injected (N items)
|
|
437
|
+
- [ ] Contextual learnings injected (≤3 items)
|
|
438
|
+
- [ ] Test infrastructure confirmed ready
|
|
439
|
+
|
|
440
|
+
**TDD Compliance**:
|
|
441
|
+
- [ ] Tests written BEFORE implementation
|
|
442
|
+
- [ ] Test/implementation ratio ≥ 40%
|
|
443
|
+
- [ ] Mock usage justified (if >30% mock density)
|
|
444
|
+
|
|
445
|
+
**Verification Layers**:
|
|
446
|
+
- [ ] L1: typecheck + lint pass
|
|
447
|
+
- [ ] L1b: Test-first ratio check pass
|
|
448
|
+
- [ ] L2: **FULL regression tests** (all tests, not just @test REQ-XXX)
|
|
449
|
+
- [ ] L3: coverage ≥ 80%
|
|
450
|
+
|
|
451
|
+
**Learnings Persisted**:
|
|
452
|
+
- [ ] Permanent: [N items, list key ones]
|
|
453
|
+
- [ ] Contextual: [N items, sliding window]
|
|
454
|
+
- [ ] `gstack/learn` called
|
|
455
|
+
|
|
456
|
+
**State Updated**:
|
|
457
|
+
- [ ] AGENTS.md updated (orchestrator)
|
|
458
|
+
- [ ] progress.log atomically written
|
|
459
|
+
- [ ] Git commit created (if PASS)
|
|
460
|
+
|
|
461
|
+
**Next Step**: [REQ-YYY title / COMPLETE / BLOCKED]
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
**Eval Criteria** (Issue #120, #121):
|
|
465
|
+
- ✅ L2 pass: Structured execution plan visible (checklist format)
|
|
466
|
+
- ✅ L3 pass: All 7 workflow steps followed, full regression tests run
|
|
467
|
+
- ❌ Fail: Missing checklist, partial tests, context pollution
|
|
468
|
+
|
|
469
|
+
---
|
|
470
|
+
|
|
471
|
+
## Anti-Patterns
|
|
472
|
+
|
|
473
|
+
| ❌ 错误 | ✅ 正确 |
|
|
474
|
+
|---|---|
|
|
475
|
+
| 一个 REQ 包含所有需求 | 每个 REQ ≤ 1 context window |
|
|
476
|
+
| 验证失败仍 commit | 不提交 |
|
|
477
|
+
| 只跑 @test REQ-XXX | 全量回归测试 |
|
|
478
|
+
| priority 排序忽略 depends_on | 拓扑排序 + 同层 priority |
|
|
479
|
+
| retry 不注入失败原因 | 每次 retry 注入上次错误 |
|
|
480
|
+
| subagent 各自写 AGENTS.md | orchestrator 统一更新 |
|
|
481
|
+
| progress.log 写长篇大论 | 3-5 行结构化摘要 |
|
|
482
|
+
|
|
483
|
+
---
|
|
484
|
+
|
|
485
|
+
## Token Savings
|
|
486
|
+
|
|
487
|
+
| REQ 数量 | 默认模式 | ralph-loop | 节约 |
|
|
488
|
+
|---------|---------|-----------|------|
|
|
489
|
+
| 3 | ~15k | ~9k | 40% |
|
|
490
|
+
| 5 | ~50k | ~25k | 50% |
|
|
491
|
+
| 10 | ~150k | ~50k | 67% |
|
|
492
|
+
|
|
493
|
+
> 原理: 默认 = sum(i × cost_i), ralph-loop = sum(cost_i)
|
|
494
|
+
|
|
495
|
+
---
|
|
496
|
+
|
|
497
|
+
## References
|
|
498
|
+
|
|
499
|
+
- [Design Doc: ralph-loop v3.0](docs/ralph-loop-design.md) — 完整设计文档 + Delphi 评审记录
|
|
500
|
+
- [Phase 2 Integration](references/phase-2-build-ralph.md) — Sprint-Flow 集成细节
|
|
501
|
+
- [Progress Log Template](templates/progress-log.md)
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# memory.md — Ralph Loop 状态与记忆结构(AHE 组件分解)
|
|
2
|
+
|
|
3
|
+
> **本文是 `skills/ralph-loop/SKILL.md` 中状态管理的 AHE 对齐展开。**
|
|
4
|
+
|
|
5
|
+
## 组件职责
|
|
6
|
+
|
|
7
|
+
定义 Ralph Loop 的进度持久化 Schema、learnings 分类结构。
|
|
8
|
+
|
|
9
|
+
## Progress Log Schema (`progress.log` — YAML)
|
|
10
|
+
|
|
11
|
+
```yaml
|
|
12
|
+
req_progress:
|
|
13
|
+
completed_count: 3
|
|
14
|
+
total_count: 5
|
|
15
|
+
current_req: REQ-XXX-004
|
|
16
|
+
status: running|completed|blocked
|
|
17
|
+
test_infra_status: generated|existing|skipped|fallback
|
|
18
|
+
|
|
19
|
+
learnings:
|
|
20
|
+
permanent:
|
|
21
|
+
- pattern: "描述持久模式"
|
|
22
|
+
evidence: "来源证据"
|
|
23
|
+
contextual:
|
|
24
|
+
- pattern: "描述当前 REQ 有效模式"
|
|
25
|
+
expires_on: "过期条件"
|
|
26
|
+
|
|
27
|
+
cost:
|
|
28
|
+
req_number: 3
|
|
29
|
+
tokens_used: 15000
|
|
30
|
+
cumulative_tokens: 85000
|
|
31
|
+
threshold: 200000
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Test Infra Status 字段
|
|
35
|
+
|
|
36
|
+
| 值 | 含义 |
|
|
37
|
+
|---|------|
|
|
38
|
+
| `generated` | 本 REQ 首次生成 test-utils.ts |
|
|
39
|
+
| `existing` | test-utils.ts 已存在且接口完整 |
|
|
40
|
+
| `skipped` | 非首次 REQ,跳过 test-infra 检查(缓存结果)|
|
|
41
|
+
| `fallback` | test-infra dispatch 失败,使用 inline 生成(含 warning)|
|
|
42
|
+
|
|
43
|
+
## Learnings 分类
|
|
44
|
+
|
|
45
|
+
| 类型 | 生命周期 | 持久化 | 示例 |
|
|
46
|
+
|------|---------|--------|------|
|
|
47
|
+
| `permanent` | 跨所有 REQ | progress.log | "项目使用 ESLint strict 模式" |
|
|
48
|
+
| `contextual` | 当前 REQ 内 | progress.log (过期标记) | "REQ 003 使用 Zod 验证 schema" |
|
|
49
|
+
|
|
50
|
+
## AHE 分类
|
|
51
|
+
|
|
52
|
+
| 字段 | 值 |
|
|
53
|
+
|------|---|
|
|
54
|
+
| 组件类型 | Long-Term Memory |
|
|
55
|
+
| 修改频率预期 | 低 |
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# middleware.md — Ralph Loop 迭代控制逻辑(AHE 组件分解)
|
|
2
|
+
|
|
3
|
+
> **本文是 `skills/ralph-loop/SKILL.md` 中迭代流程的 AHE 对齐展开。**
|
|
4
|
+
|
|
5
|
+
## 组件职责
|
|
6
|
+
|
|
7
|
+
定义 Ralph Loop 的状态机:REQ 级迭代控制、熔断机制、中断续传逻辑。
|
|
8
|
+
|
|
9
|
+
## 状态机
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
REQ N → 加载 learnings → 测试基础设施检查 → [infra missing?] → test_infra_dispatch
|
|
13
|
+
│ │ │
|
|
14
|
+
│ │ infra ready │ FAIL (max 2 retry)
|
|
15
|
+
│ ▼ ▼
|
|
16
|
+
│ TDD → 回归测试 ←───────────── BLOCK/fallback
|
|
17
|
+
│ │
|
|
18
|
+
│ PASS → REQ N+1
|
|
19
|
+
│ FAIL → 重试 (max 3) → BLOCK → 用户决策
|
|
20
|
+
│ ALL_REQS_COMPLETE → 结束,返回控制权给 sprint-flow orchestrator
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## 测试基础设施状态机
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
test_infra_check → [needs infra?] → test_infra_dispatch → FAIL → retry (max 2)
|
|
27
|
+
│ │ │ │
|
|
28
|
+
│ │ infra ready │ pass │ pass
|
|
29
|
+
▼ ▼ ▼ ▼
|
|
30
|
+
in_progress test_infra_ready ─────────→ TDD → regression BLOCK/fallback
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## 熔断机制
|
|
34
|
+
|
|
35
|
+
| 触发条件 | 动作 |
|
|
36
|
+
|---------|------|
|
|
37
|
+
| TDD 失败 > 3 次 | BLOCK + 用户决策 |
|
|
38
|
+
| Token 使用超阈值 | BLOCK + 用户决策 |
|
|
39
|
+
| 回归测试失败 | 记录到 progress.log,通知 sprint-flow orchestrator |
|
|
40
|
+
| test-infra dispatch 失败 (max 2 retry) | BLOCK 或 fallback inline 生成(记录 warning)|
|
|
41
|
+
|
|
42
|
+
## 暂停点
|
|
43
|
+
|
|
44
|
+
| 暂停点 | 触发条件 | 恢复 |
|
|
45
|
+
|--------|---------|------|
|
|
46
|
+
| REQ 完成 | 自动暂停等待确认 | 确认后继续下一个 REQ |
|
|
47
|
+
| 熔断 | 自动触发 | 用户决策后继续或放弃 |
|
|
48
|
+
|
|
49
|
+
## AHE 分类
|
|
50
|
+
|
|
51
|
+
| 字段 | 值 |
|
|
52
|
+
|------|---|
|
|
53
|
+
| 组件类型 | Middleware |
|
|
54
|
+
| 修改频率预期 | 高 |
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# skill-invocations.md — Ralph Loop 技能调用(AHE 组件分解)
|
|
2
|
+
|
|
3
|
+
> **本文是 `skills/ralph-loop/SKILL.md` 中技能调用链的 AHE 对齐展开。**
|
|
4
|
+
|
|
5
|
+
## 组件职责
|
|
6
|
+
|
|
7
|
+
提供 Ralph Loop 在每个 REQ 执行中的技能调用链。
|
|
8
|
+
|
|
9
|
+
## 完整调用链
|
|
10
|
+
|
|
11
|
+
| 步骤 | Skill | 来源 | 参数 |
|
|
12
|
+
|------|-------|------|------|
|
|
13
|
+
| 0 | 测试基础设施检查 | 内置 | 检查 test-utils.ts 存在性 + 接口契约(createTestApp, withTestDb)|
|
|
14
|
+
| 1 | `test-driven-development` | superpowers | `--lang` 注入 + TDD 铁律 + Mock 边界(覆盖默认策略)|
|
|
15
|
+
| 2 | `learn` | gstack | classification: permanent/contextual |
|
|
16
|
+
| 3 | `requesting-code-review` | superpowers | REQ 完成后评审 |
|
|
17
|
+
|
|
18
|
+
## test-infra dispatch 节点
|
|
19
|
+
|
|
20
|
+
当 test-utils.ts 不存在或接口缺失时:
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
task(category="unspecified-high", load_skills=["test-driven-development"], prompt="生成测试基础设施:createTestApp() + withTestDb()。TDD 铁律:先写测试再实现。")
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
- retry max 2 次
|
|
27
|
+
- 仍失败 → BLOCK 或 fallback inline 生成(记录 warning)
|
|
28
|
+
- 成功后与业务代码合并为同一 commit
|
|
29
|
+
|
|
30
|
+
## 上游依赖
|
|
31
|
+
|
|
32
|
+
从 `specification.yaml` 获取 REQ 列表(由 `to-issues` skill 生成)
|
|
33
|
+
|
|
34
|
+
## AHE 分类
|
|
35
|
+
|
|
36
|
+
| 字段 | 值 |
|
|
37
|
+
|------|---|
|
|
38
|
+
| 组件类型 | Skill Invocation Chain |
|
|
39
|
+
| 修改频率预期 | 中 |
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# system-prompt.md — Ralph Loop 行为定义(AHE 组件分解)
|
|
2
|
+
|
|
3
|
+
> **本文是 `skills/ralph-loop/SKILL.md` 核心原则的 AHE 对齐展开。**
|
|
4
|
+
|
|
5
|
+
## 核心职责
|
|
6
|
+
|
|
7
|
+
定义 Ralph Loop (Phase 2 BUILD 默认模式) 的行为边界:逐 REQ/切片 迭代构建,每个 REQ dispatch 独立 subagent,干净上下文,全量回归测试。
|
|
8
|
+
|
|
9
|
+
## 核心原则 (AHE 对齐)
|
|
10
|
+
|
|
11
|
+
| # | 原则 | 说明 |
|
|
12
|
+
|---|------|------|
|
|
13
|
+
| 1 | 逐 REQ 迭代 | 一次处理一个 REQ/切片,干净上下文,避免上下文线性膨胀 |
|
|
14
|
+
| 2 | Token 节约 | 比旧并行模式节约 40-67% token |
|
|
15
|
+
| 3 | 全量回归 | 每个 REQ 完成后跑全量测试 |
|
|
16
|
+
| 4 | 进度持久化 | progress.log 持久化 learnings/permanent/contextual |
|
|
17
|
+
| 5 | 可中断续传 | 中断后可从最后完成 REQ 继续 |
|
|
18
|
+
|
|
19
|
+
## AHE 分类
|
|
20
|
+
|
|
21
|
+
| 字段 | 值 |
|
|
22
|
+
|------|---|
|
|
23
|
+
| 组件类型 | System Prompt |
|
|
24
|
+
| 修改频率预期 | 低 |
|