intentdna 1.5.7 → 1.5.9

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.
@@ -52,19 +52,103 @@ genes:
52
52
  contexts: {}
53
53
 
54
54
  roles:
55
+ test_writer:
56
+ description: Writes failing tests before implementation. Can create test files.
57
+ tool_permissions:
58
+ allow: [Read, Edit, Write, Grep, Glob, Bash]
59
+ scope:
60
+ read: ["**/*"]
61
+ write: ["test/**", "tests/**", "spec/**", "__tests__/**"]
62
+ instructions:
63
+ - Write the test FIRST — it must fail initially (red phase)
64
+ - Test should describe the desired behavior, not the implementation
65
+ - One test case per behavior
66
+ - Run the test to confirm it fails for the right reason
67
+ - Do NOT write implementation code
68
+
55
69
  implementer:
56
- description: TDD implementer writes tests first, then code
70
+ description: Writes minimal code to make tests pass.
57
71
  tool_permissions:
58
72
  allow: [Read, Edit, Write, Grep, Glob, Bash]
59
73
  scope:
60
74
  read: ["**/*"]
61
- write: ["src/**", "test/**"]
75
+ write: ["src/**", "lib/**"]
62
76
  instructions:
63
- - Always write the failing test FIRST
64
- - Run the test to confirm it fails (red)
65
- - Write the minimum code to make it pass (green)
66
- - Refactor if needed, keeping tests green
67
- - Never commit with failing tests
68
- post_checks:
69
- - vitest_run
70
- - tsc_no_errors
77
+ - Write the MINIMUM code to make the failing test pass (green phase)
78
+ - Do not add extra functionality beyond what the test requires
79
+ - Do not optimize or clean up code yet
80
+ - Run the test after each change to verify it passes
81
+ - Do not modify test files
82
+
83
+ refactorer:
84
+ description: Cleans up code while keeping tests green.
85
+ tool_permissions:
86
+ allow: [Read, Edit, Write, Grep, Glob, Bash]
87
+ scope:
88
+ read: ["**/*"]
89
+ write: ["src/**", "lib/**"]
90
+ instructions:
91
+ - Clean up the implementation (refactor phase)
92
+ - Run ALL tests after each refactoring step
93
+ - If any test breaks, revert immediately
94
+ - Focus on readability, removing duplication, improving naming
95
+ - Do NOT add new functionality during refactoring
96
+ - Do NOT modify test files
97
+
98
+ workflows:
99
+ tdd-cycle:
100
+ name: TDD Cycle
101
+ description: "Red-Green-Refactor: write failing test, implement minimally, clean up"
102
+ steps:
103
+ - id: write_test
104
+ role: test_writer
105
+ description: "Write a failing test for the desired behavior (RED)."
106
+ prompt: |
107
+ TDD Red Phase:
108
+ 1. Understand the behavior to implement
109
+ 2. Write ONE test that describes this behavior
110
+ 3. Run the test — it MUST fail
111
+ 4. Verify it fails for the right reason (not a syntax error)
112
+ 5. Commit: "test: add failing test for [behavior]"
113
+
114
+ Do NOT write any implementation code.
115
+
116
+ - id: implement
117
+ role: implementer
118
+ depends_on: [write_test]
119
+ description: "Write minimal code to pass the test (GREEN)."
120
+ prompt: |
121
+ TDD Green Phase:
122
+ 1. Read the failing test carefully
123
+ 2. Write the MINIMUM code to make it pass
124
+ 3. Run the test — it must pass now
125
+ 4. Run the full test suite — no regressions
126
+ 5. Commit: "feat: implement [behavior] — test green"
127
+
128
+ Rules:
129
+ - Do NOT add code beyond what the test requires
130
+ - Do NOT optimize yet
131
+ - Do NOT modify test files
132
+
133
+ - id: refactor
134
+ role: refactorer
135
+ depends_on: [implement]
136
+ description: "Clean up code while keeping all tests green (REFACTOR)."
137
+ prompt: |
138
+ TDD Refactor Phase:
139
+ 1. Review the implementation for code smells
140
+ 2. Apply ONE refactoring at a time
141
+ 3. Run ALL tests after each change
142
+ 4. If any test breaks: REVERT immediately
143
+ 5. Commit: "refactor: [what was cleaned up]"
144
+
145
+ Focus on:
146
+ - Remove duplication
147
+ - Improve naming
148
+ - Simplify logic
149
+ - Extract methods/functions if needed
150
+
151
+ Do NOT:
152
+ - Add new features
153
+ - Modify test files
154
+ - Change behavior
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "intentdna",
3
- "version": "1.5.7",
3
+ "version": "1.5.9",
4
4
  "description": "Intent DNA — Declarative policy layer for AI agent behavior",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1,5 +1,15 @@
1
1
  # Spec: flutter-rewrite 模板优化
2
2
 
3
+ ## 最终目标
4
+
5
+ **把 v1 (GetX) 重写为 v2 (Riverpod),行为完全一致。**
6
+
7
+ - behavior-lock: 写测试 = 定义"v1 的行为是什么"
8
+ - rescue: 写代码让测试通过 = "v2 的行为和 v1 一样"
9
+ - 完成标志: 所有测试 green = 重写成功,行为完全一致
10
+
11
+ 所有设计决策必须服务于这个目标。timeout 是安全网(防卡死),不是解法。挂死的测试意味着行为没被验证——rescue 必须修复它们,不能跳过。
12
+
3
13
  ## 问题
4
14
 
5
15
  flutter-rewrite 模板的 behavior-lock 和 rescue 工作流都有设计缺陷,导致:
@@ -47,14 +57,19 @@ commit: "behavior-lock($MODULE): N tests (X green, Y red from behavior change)"
47
57
  3. 增量更新
48
58
  4. 输出 diff 摘要
49
59
 
50
- ### 禁止的模式
60
+ ### 超时策略
51
61
 
52
- | 禁止 | 原因 | 替代 |
53
- |------|------|------|
54
- | `sleep N && check` 轮询 | 浪费时间 | 前台跑 |
55
- | `timeout Nm flutter test` | 测试可能需要很久 | 不设超时 |
56
- | 全量重写已有测试 | 丢失 rescue 成果 | 增量更新 |
57
- | 首次跑 `flutter test` | 没实现,编译不过 | `flutter analyze` |
62
+ | 操作 | 允许? | 原因 |
63
+ |------|--------|------|
64
+ | `flutter test --timeout 30s` | **允许** | per-test 安全网,挂死标 fail 继续下一个 |
65
+ | `timeout Nm flutter test` | 禁止 | 外部杀进程,丢失所有结果 |
66
+ | `sleep N && check` 轮询 | 禁止 | 浪费时间 |
67
+ | 全量重写已有测试 | 禁止 | 丢失 rescue 成果 |
68
+ | 首次跑 `flutter test` | 禁止 | 没实现,编译不过,用 `flutter analyze` |
69
+
70
+ **挂死的测试分类**:标记为 `hung: needs mock infrastructure`,不是 `failed`。区别:
71
+ - `failed` = 行为不一致,rescue 修 v2 代码
72
+ - `hung` = mock 不完整,rescue 先修测试基础设施
58
73
 
59
74
  ---
60
75
 
@@ -131,7 +146,13 @@ investigator:
131
146
  # 现有的保留,新增:
132
147
  - 非首轮:先 review 上轮 git diff,判断方向是否正确
133
148
  - 如果上轮 fix 没有让任何测试从 red→green,警告"无进展"
134
- - 分类时标注严重度:CRITICAL(编译不过)> HIGH(逻辑错误)> LOW(widget 样式)
149
+ - 分类时标注严重度和类型:
150
+ CRITICAL: 编译错误(阻塞一切)
151
+ HIGH-INFRA: mock 不完整导致 test hang(阻塞行为验证,rescue 优先修)
152
+ HIGH-LOGIC: 逻辑测试 fail(行为不一致)
153
+ MEDIUM: widget 测试 fail(渲染/导航差异)
154
+ LOW: 样式差异
155
+ - hung 测试 ≠ failed 测试。hung = mock 基础设施问题,不是 v2 行为问题
135
156
  ```
136
157
 
137
158
  ### 收敛保护
@@ -144,9 +165,19 @@ rescue:
144
165
  输出卡点分析 + 剩余问题清单
145
166
  round_budget: |
146
167
  每轮最多改 5 个文件
147
- 每轮必须让至少 1 个测试从 red/skip → green,否则视为无进展
168
+ 每轮必须让至少 1 个测试从 red/skip/hung → green,否则视为无进展
169
+ priority_order: |
170
+ Phase 1: 修 CRITICAL(编译错误)
171
+ Phase 2: 修 HIGH-INFRA(mock 基础设施,让 hung 测试能跑)
172
+ Phase 3: 修 HIGH-LOGIC(逻辑测试,让 red 变 green)
173
+ Phase 4: 修 MEDIUM(widget 测试,让 red 变 green)
174
+ 每个 phase 完成后才进入下一个
148
175
  ```
149
176
 
177
+ **为什么 HIGH-INFRA 优先于 HIGH-LOGIC?**
178
+
179
+ hung 的测试 = 行为没被验证 = 重写目标的盲区。如果跳过 mock 修复直接改逻辑,可能 20 个 widget 行为从来没被检验过。先让所有测试能跑(pass 或 fail),再让它们变绿。
180
+
150
181
  ### 完整 rescue workflow
151
182
 
152
183
  ```yaml