@boyingliu01/xp-gate 0.8.21 → 0.9.1

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.
Files changed (79) hide show
  1. package/lib/__tests__/check-version.test.js +4 -4
  2. package/mock-policy/AGENTS.md +3 -3
  3. package/mutation/AGENTS.md +3 -3
  4. package/package.json +1 -1
  5. package/plugins/claude-code/.claude-plugin/plugin.json +1 -1
  6. package/plugins/claude-code/skills/admin-template-guidelines/SKILL.md +6 -797
  7. package/plugins/claude-code/skills/admin-template-guidelines/references/rule-1.md +91 -0
  8. package/plugins/claude-code/skills/admin-template-guidelines/references/rule-2.md +155 -0
  9. package/plugins/claude-code/skills/admin-template-guidelines/references/rule-3.md +70 -0
  10. package/plugins/claude-code/skills/admin-template-guidelines/references/rule-4.md +154 -0
  11. package/plugins/claude-code/skills/admin-template-guidelines/references/rule-5.md +126 -0
  12. package/plugins/claude-code/skills/admin-template-guidelines/references/rule-6.md +180 -0
  13. package/plugins/claude-code/skills/delphi-review/AGENTS.md +3 -3
  14. package/plugins/claude-code/skills/delphi-review/SKILL.md +59 -361
  15. package/plugins/claude-code/skills/delphi-review/references/orchestrator-dispatch.md +64 -0
  16. package/plugins/claude-code/skills/delphi-review/references/round-templates.md +67 -0
  17. package/plugins/claude-code/skills/ralph-loop/SKILL.md +87 -428
  18. package/plugins/claude-code/skills/ralph-loop/references/components.md +113 -0
  19. package/plugins/claude-code/skills/ralph-loop/references/workflow-details.md +99 -0
  20. package/plugins/claude-code/skills/sprint-flow/AGENTS.md +3 -3
  21. package/plugins/claude-code/skills/sprint-flow/references/phase-2-build.md +34 -0
  22. package/plugins/claude-code/skills/test-specification-alignment/AGENTS.md +3 -3
  23. package/plugins/claude-code/skills/test-specification-alignment/SKILL.md +97 -599
  24. package/plugins/opencode/package.json +1 -1
  25. package/plugins/opencode/skills/admin-template-guidelines/SKILL.md +6 -797
  26. package/plugins/opencode/skills/admin-template-guidelines/references/rule-1.md +91 -0
  27. package/plugins/opencode/skills/admin-template-guidelines/references/rule-2.md +155 -0
  28. package/plugins/opencode/skills/admin-template-guidelines/references/rule-3.md +70 -0
  29. package/plugins/opencode/skills/admin-template-guidelines/references/rule-4.md +154 -0
  30. package/plugins/opencode/skills/admin-template-guidelines/references/rule-5.md +126 -0
  31. package/plugins/opencode/skills/admin-template-guidelines/references/rule-6.md +180 -0
  32. package/plugins/opencode/skills/delphi-review/AGENTS.md +3 -3
  33. package/plugins/opencode/skills/delphi-review/SKILL.md +59 -361
  34. package/plugins/opencode/skills/delphi-review/references/orchestrator-dispatch.md +64 -0
  35. package/plugins/opencode/skills/delphi-review/references/round-templates.md +67 -0
  36. package/plugins/opencode/skills/ralph-loop/SKILL.md +87 -428
  37. package/plugins/opencode/skills/ralph-loop/references/components.md +113 -0
  38. package/plugins/opencode/skills/ralph-loop/references/workflow-details.md +99 -0
  39. package/plugins/opencode/skills/sprint-flow/AGENTS.md +3 -3
  40. package/plugins/opencode/skills/sprint-flow/references/phase-2-build.md +34 -0
  41. package/plugins/opencode/skills/test-specification-alignment/AGENTS.md +3 -3
  42. package/plugins/opencode/skills/test-specification-alignment/SKILL.md +97 -599
  43. package/plugins/qoder/skills/delphi-review/AGENTS.md +3 -3
  44. package/plugins/qoder/skills/sprint-flow/AGENTS.md +3 -3
  45. package/plugins/qoder/skills/test-specification-alignment/AGENTS.md +3 -3
  46. package/principles/AGENTS.md +3 -3
  47. package/skills/admin-template-guidelines/SKILL.md +6 -797
  48. package/skills/admin-template-guidelines/references/rule-1.md +91 -0
  49. package/skills/admin-template-guidelines/references/rule-2.md +155 -0
  50. package/skills/admin-template-guidelines/references/rule-3.md +70 -0
  51. package/skills/admin-template-guidelines/references/rule-4.md +154 -0
  52. package/skills/admin-template-guidelines/references/rule-5.md +126 -0
  53. package/skills/admin-template-guidelines/references/rule-6.md +180 -0
  54. package/skills/delphi-review/AGENTS.md +3 -3
  55. package/skills/delphi-review/SKILL.md +59 -361
  56. package/skills/delphi-review/references/orchestrator-dispatch.md +64 -0
  57. package/skills/delphi-review/references/round-templates.md +67 -0
  58. package/skills/ralph-loop/SKILL.md +87 -428
  59. package/skills/ralph-loop/references/components.md +113 -0
  60. package/skills/ralph-loop/references/workflow-details.md +99 -0
  61. package/skills/sprint-flow/AGENTS.md +3 -3
  62. package/skills/sprint-flow/references/phase-2-build.md +34 -0
  63. package/skills/test-specification-alignment/AGENTS.md +3 -3
  64. package/skills/test-specification-alignment/SKILL.md +97 -599
  65. package/plugins/claude-code/skills/ralph-loop/references/components/memory.md +0 -55
  66. package/plugins/claude-code/skills/ralph-loop/references/components/middleware.md +0 -54
  67. package/plugins/claude-code/skills/ralph-loop/references/components/skill-invocations.md +0 -39
  68. package/plugins/claude-code/skills/ralph-loop/references/components/system-prompt.md +0 -24
  69. package/plugins/claude-code/skills/ralph-loop/references/components/tool-descriptions.md +0 -32
  70. package/plugins/opencode/skills/ralph-loop/references/components/memory.md +0 -55
  71. package/plugins/opencode/skills/ralph-loop/references/components/middleware.md +0 -54
  72. package/plugins/opencode/skills/ralph-loop/references/components/skill-invocations.md +0 -39
  73. package/plugins/opencode/skills/ralph-loop/references/components/system-prompt.md +0 -24
  74. package/plugins/opencode/skills/ralph-loop/references/components/tool-descriptions.md +0 -32
  75. package/skills/ralph-loop/references/components/memory.md +0 -55
  76. package/skills/ralph-loop/references/components/middleware.md +0 -54
  77. package/skills/ralph-loop/references/components/skill-invocations.md +0 -39
  78. package/skills/ralph-loop/references/components/system-prompt.md +0 -24
  79. package/skills/ralph-loop/references/components/tool-descriptions.md +0 -32
@@ -0,0 +1,113 @@
1
+ # Ralph Loop 组件分解
2
+
3
+ ## 1. System Prompt — 核心原则
4
+
5
+ | # | 原则 | 说明 |
6
+ |---|------|------|
7
+ | 1 | 逐 REQ 迭代 | 一次处理一个 REQ/切片,干净上下文,避免上下文线性膨胀 |
8
+ | 2 | Token 节约 | 比旧并行模式节约 40-67% token |
9
+ | 3 | 全量回归 | 每个 REQ 完成后跑全量测试 |
10
+ | 4 | 进度持久化 | progress.log 持久化 learnings/permanent/contextual |
11
+ | 5 | 可中断续传 | 中断后可从最后完成 REQ 继续 |
12
+
13
+ ## 2. Memory — 状态与记忆结构
14
+
15
+ ### Progress Log Schema (`progress.log` — YAML)
16
+
17
+ ```yaml
18
+ req_progress:
19
+ completed_count: 3
20
+ total_count: 5
21
+ current_req: REQ-XXX-004
22
+ status: running|completed|blocked
23
+ test_infra_status: generated|existing|skipped|fallback
24
+
25
+ learnings:
26
+ permanent:
27
+ - pattern: "描述持久模式"
28
+ evidence: "来源证据"
29
+ contextual:
30
+ - pattern: "描述当前 REQ 有效模式"
31
+ expires_on: "过期条件"
32
+
33
+ cost:
34
+ req_number: 3
35
+ tokens_used: 15000
36
+ cumulative_tokens: 85000
37
+ threshold: 200000
38
+ ```
39
+
40
+ ### Test Infra Status 字段
41
+
42
+ | 值 | 含义 |
43
+ |---|------|
44
+ | `generated` | 本 REQ 首次生成 test-utils.ts |
45
+ | `existing` | test-utils.ts 已存在且接口完整 |
46
+ | `skipped` | 非首次 REQ,跳过 test-infra 检查 |
47
+ | `fallback` | test-infra dispatch 失败,使用 inline 生成 |
48
+
49
+ ### Learnings 分类
50
+
51
+ | 类型 | 生命周期 | 示例 |
52
+ |------|---------|------|
53
+ | `permanent` | 跨所有 REQ | "项目使用 ESLint strict 模式" |
54
+ | `contextual` | 当前 REQ 内 | "REQ 003 使用 Zod 验证 schema" |
55
+
56
+ ## 3. Middleware — 迭代控制逻辑
57
+
58
+ ### 状态机
59
+
60
+ ```
61
+ REQ N → 加载 learnings → 测试基础设施检查 → [infra missing?] → test_infra_dispatch
62
+ │ │ │
63
+ │ │ infra ready │ FAIL (max 2 retry)
64
+ │ ▼ ▼
65
+ │ TDD → 回归测试 ←───────────── BLOCK/fallback
66
+ │ │
67
+ │ PASS → REQ N+1
68
+ │ FAIL → 重试 (max 3) → BLOCK → 用户决策
69
+ │ ALL_REQS_COMPLETE → 结束,返回控制权给 sprint-flow orchestrator
70
+ ```
71
+
72
+ ### 熔断机制
73
+
74
+ | 触发条件 | 动作 |
75
+ |---------|------|
76
+ | TDD 失败 > 3 次 | BLOCK + 用户决策 |
77
+ | Token 使用超阈值 | BLOCK + 用户决策 |
78
+ | 回归测试失败 | 记录到 progress.log,通知 orchestrator |
79
+ | test-infra dispatch 失败 (max 2 retry) | BLOCK 或 fallback inline 生成 |
80
+
81
+ ## 4. Skill Invocations — 技能调用链
82
+
83
+ | 步骤 | Skill | 参数 |
84
+ |------|-------|------|
85
+ | 0 | 测试基础设施检查 | 检查 test-utils.ts 存在性 + 接口契约 |
86
+ | 1 | `test-driven-development` | `--lang` 注入 + TDD 铁律 + Mock 边界 |
87
+ | 2 | `learn` (gstack) | classification: permanent/contextual |
88
+ | 3 | `requesting-code-review` | REQ 完成后评审 |
89
+
90
+ ### test-infra dispatch 节点
91
+
92
+ 当 test-utils.ts 不存在或接口缺失时:
93
+ ```
94
+ task(category="unspecified-high", load_skills=["test-driven-development"],
95
+ prompt="生成测试基础设施:createTestApp() + withTestDb()。TDD 铁律:先写测试再实现。")
96
+ ```
97
+ - retry max 2 次
98
+ - 仍失败 → BLOCK 或 fallback inline 生成(记录 warning)
99
+ - 成功后与业务代码合并为同一 commit
100
+
101
+ ## 5. Tool Descriptions — 构建步骤
102
+
103
+ | 步骤 | 动作 | 说明 |
104
+ |------|------|------|
105
+ | 1 | 加载当前 REQ | 从 specification.yaml 获取下一个 READY REQ |
106
+ | 2 | 加载 learnings | 从 progress.log 加载 permanent + contextual learnings |
107
+ | 3 | 测试基础设施检查 | 检查 test-utils.ts。不存在 → dispatch, retry max 2 |
108
+ | 4 | TDD (RED→GREEN→REFACTOR) | test-driven-development skill |
109
+ | 5 | 全量回归测试 | 运行全部现有测试 |
110
+ | 6 | 测试先行比率检查 (L1b) | 新增测试行数 / 总新增行数 ≥ 40% |
111
+ | 7 | 记录 progress.log | learnings 分类存储 |
112
+ | 8 | 成本检查 | token 使用量是否超阈值 |
113
+ | 9 | 完成/继续 | 所有 REQ 完成 → 结束;否则 → 下一个 |
@@ -0,0 +1,99 @@
1
+ # Ralph Loop Workflow Details
2
+
3
+ ## Mandatory Execution Order
4
+
5
+ 每个 REQ 必须按以下顺序执行,不得跳过或重排:
6
+
7
+ ### 1. Load next READY REQ
8
+ - 从 specification.yaml 读取下一个依赖已满足的 REQ
9
+ - 检查 priority 和 status (pending 状态)
10
+ - 构建依赖图,确认无循环依赖
11
+
12
+ ### 2. Create isolated context
13
+ - 清空前一个 REQ 的对话历史
14
+ - 注入:当前 REQ + AC + permanent learnings + contextual learnings (最近 3 条)
15
+ - 注入:AGENTS.md + git log --oneline -5 + 测试基础设施摘要
16
+
17
+ ### 3. Pre-REQ snapshot(Issue #137)
18
+ 在 dispatch subagent 前记录当前 git HEAD,用于 TDD 合规的基线对比:
19
+ ```bash
20
+ PRE_REQ_HASH=$(git rev-parse HEAD)
21
+ echo "$PRE_REQ_HASH" > .sprint-state/last-req-baseline.txt
22
+ ```
23
+
24
+ ### 4. Dispatch build subagent
25
+ - 使用 `task(category="unspecified-high", load_skills=["test-driven-development"], timeout=300)`
26
+ - 强制 TDD 流程:RED → GREEN → REFACTOR
27
+ - 强制执行 Mock 边界策略
28
+
29
+ ### 5. Run full regression tests
30
+ - **L1**: typecheck + lint on changed files
31
+ - **L1b**: 使用 git diff 验证新增测试行数占总新增行数比例 ≥ 40%
32
+ - **L1b-alt**: 当 diff 为空时,降级检查测试文件是否在 changeset 中
33
+ - **L2**: 全量测试运行(不只是 @test 当前 REQ 的测试)
34
+ - **L3**: 检查整体覆盖率 ≥ 80%
35
+
36
+ ### 6. Fix until green or block
37
+ - 失败 → retry (max 3 次,每次注入失败摘要)
38
+ - 第 3 次仍失败 → BLOCK → 等待用户决策 (skip/manual/stop/rollback)
39
+ - 通过 → git commit + 标记 done
40
+
41
+ ### 7. Persist learnings
42
+ - 分类为 permanent(架构级)或 contextual(临时性)
43
+ - 自动升级条件:被≥2 个 REQ 引用 或 涉及接口/数据结构
44
+ - 调用 `gstack/learn` 总结经验教训
45
+
46
+ ### 8. Update sprint state
47
+ - orchestrator 统一更新 AGENTS.md(append `## ralph-loop: [REQ-XXX title]`)
48
+ - 原子写 checkpoint (progress.log)
49
+ - 继续下一个 READY REQ
50
+
51
+ ### 禁止行为
52
+ - ❌ 跳过测试基础设施检查
53
+ - ❌ 只运行部分测试(必须全量回归)
54
+ - ❌ 验证失败仍 commit
55
+ - ❌ 多个 subagent 同时写 AGENTS.md
56
+ - ❌ 修改前一个 REQ 的代码(除非修复回归)
57
+
58
+ ## Output Contract (Mandatory Checklist)
59
+
60
+ 每个 REQ 完成时必须输出以下结构化检查清单:
61
+
62
+ ```markdown
63
+ ## REQ-XXX: [Title] - Execution Summary
64
+
65
+ **Status**: ✅ PASS / ❌ FAIL (retry n/3) / 🚫 BLOCKED
66
+
67
+ **Context Isolation**:
68
+ - [ ] Previous REQ context cleared
69
+ - [ ] Permanent learnings injected (N items)
70
+ - [ ] Contextual learnings injected (≤3 items)
71
+ - [ ] Test infrastructure confirmed ready
72
+
73
+ **TDD Compliance**:
74
+ - [ ] Tests written BEFORE implementation
75
+ - [ ] Test/implementation ratio ≥ 40% (L1b)
76
+ - [ ] Mock usage justified (if >30% mock density)
77
+ - [ ] Test files present in changeset (L1b-alt)
78
+ - [ ] TDD 合规检查 (test-first or @no-test-required)
79
+
80
+ **Verification Layers**:
81
+ - [ ] L1: typecheck + lint pass
82
+ - [ ] L1b: Test-first ratio check pass
83
+ - [ ] L2: FULL regression tests (all tests)
84
+ - [ ] L3: coverage ≥ 80%
85
+
86
+ **Learnings Persisted**:
87
+ - [ ] Permanent: [N items]
88
+ - [ ] Contextual: [N items, sliding window]
89
+ - [ ] `gstack/learn` called
90
+
91
+ **State Updated**:
92
+ - [ ] AGENTS.md updated (orchestrator)
93
+ - [ ] progress.log atomically written
94
+ - [ ] Git commit created (if PASS)
95
+
96
+ **Next Step**: [REQ-YYY title / COMPLETE / BLOCKED]
97
+ ```
98
+
99
+ **Eval Criteria**: Structured execution plan visible, all 7 workflow steps followed, full regression tests run.
@@ -1,9 +1,9 @@
1
1
  # SKILLS/SPRINT-FLOW KNOWLEDGE BASE
2
2
 
3
- **Generated:** 2026-06-17
4
- **Commit:** c0c52f4
3
+ **Generated:** 2026-06-18
4
+ **Commit:** 33cf3f2
5
5
  **Branch:** main
6
- **Version:** 0.8.21.0
6
+ **Version:** 0.9.1.0
7
7
 
8
8
  ## OVERVIEW
9
9
  **11-phase** development pipeline: ISOLATE → AUTO-ESTIMATE → THINK → PLAN → BUILD → REVIEW → USER ACCEPTANCE → FEEDBACK → SHIP → LAND → CLEANUP. Phase 2 default build mode is **ralph-loop** (REQ-level iteration, 40-67% token savings vs parallel). HARD-GATE in Phase 1: design must pass Delphi review (≥90% consensus) before any coding.
@@ -7,3 +7,37 @@
7
7
  **关键链路**: DELPHI-GATE → parallel-dispatch/ralph-loop → TDD → freeze → blind-review → unfreeze → verification → cost monitor
8
8
 
9
9
  **输出**: MVP v1
10
+
11
+ ---
12
+
13
+ ## Gate 参考表(Phase 2 相关)
14
+
15
+ | Gate | 名称 | 行为 |
16
+ |------|------|------|
17
+ | Gate 5 | 单元测试 + 覆盖率 | 全部通过 + ≥80% 覆盖率 |
18
+ | Gate 5a-BLOCK | 新增 .ts/.tsx 文件测试强制 | 新增 .ts/.tsx 文件无对应测试文件 → BLOCK;修改文件 → WARNING |
19
+ | Gate M2 | Mock 密度检查 | 30% WARNING (Phase 1); 可配置 via `.mockpolicyrc` |
20
+
21
+ ---
22
+
23
+ ## TDD 强制执行
24
+
25
+ ### Gate 5a-BLOCK: 新增文件测试强制
26
+
27
+ - **新增 `.ts/.tsx` 文件**必须有对应的测试文件(`*.test.ts`、`*.spec.ts`、`__tests__/` 目录),否则 **BLOCK** 提交
28
+ - **修改已有文件**仅触发 WARNING(不阻断)
29
+ - **Escape valve**: 非 main/master 分支可设置 `SKIP_GATE_5A_BLOCK=1` 跳过阻断(仅 WARNING)
30
+
31
+ ### Gate M2: Mock 密度阈值调整
32
+
33
+ - Mock 密度阈值从 50% 降低至 **30%**
34
+ - **Phase 1**: WARNING 模式(仅告警,不阻断)
35
+ - **Phase 2**: 将在基线分析后启用 BLOCK 模式
36
+ - 可通过 `.mockpolicyrc` 配置阈值和行为
37
+
38
+ ### Escape Valve
39
+
40
+ ```bash
41
+ # 非 main/master 分支临时跳过 Gate 5a-BLOCK
42
+ SKIP_GATE_5A_BLOCK=1 git commit -m "message"
43
+ ```
@@ -1,9 +1,9 @@
1
1
  # SKILLS/TEST-SPECIFICATION-ALIGNMENT KNOWLEDGE BASE
2
2
 
3
- **Generated:** 2026-06-17
4
- **Commit:** c0c52f4
3
+ **Generated:** 2026-06-18
4
+ **Commit:** 33cf3f2
5
5
  **Branch:** main
6
- **Version:** 0.8.21.0
6
+ **Version:** 0.9.1.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Test-Specification Alignment Engine — two-stage validation ensuring tests accurately reflect requirements and design specs.