intentdna 1.0.0 → 1.2.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.
Files changed (33) hide show
  1. package/dist/cli/commands/import.d.ts.map +1 -1
  2. package/dist/cli/commands/import.js +4 -3
  3. package/dist/cli/commands/import.js.map +1 -1
  4. package/dist/cli/commands/init.d.ts.map +1 -1
  5. package/dist/cli/commands/init.js +5 -2
  6. package/dist/cli/commands/init.js.map +1 -1
  7. package/dist/cli/commands/sync.d.ts.map +1 -1
  8. package/dist/cli/commands/sync.js +123 -7
  9. package/dist/cli/commands/sync.js.map +1 -1
  10. package/dist/cli/index.js +8 -6
  11. package/dist/cli/index.js.map +1 -1
  12. package/dist/evolution/types.d.ts +1 -1
  13. package/dist/evolution/types.d.ts.map +1 -1
  14. package/dist/evolution/types.js +1 -1
  15. package/dist/evolution/types.js.map +1 -1
  16. package/dist/runtime/agent-md.js +2 -2
  17. package/dist/runtime/agent-md.js.map +1 -1
  18. package/dist/runtime/hooks.js +1 -1
  19. package/dist/runtime/hooks.js.map +1 -1
  20. package/dist/runtime/settings-adapter.d.ts +12 -10
  21. package/dist/runtime/settings-adapter.d.ts.map +1 -1
  22. package/dist/runtime/settings-adapter.js +70 -41
  23. package/dist/runtime/settings-adapter.js.map +1 -1
  24. package/dist/runtime/skill-adapter.d.ts +2 -1
  25. package/dist/runtime/skill-adapter.d.ts.map +1 -1
  26. package/dist/runtime/skill-adapter.js +13 -5
  27. package/dist/runtime/skill-adapter.js.map +1 -1
  28. package/dist/schema/types.d.ts +6 -1
  29. package/dist/schema/types.d.ts.map +1 -1
  30. package/dist/templates/flutter-behavior-lock.dna.yaml +122 -0
  31. package/dist/templates/flutter-refactoring-rescue.dna.yaml +140 -0
  32. package/dist/templates/flutter-rewrite.dna.yaml +216 -0
  33. package/package.json +1 -1
@@ -0,0 +1,122 @@
1
+ # flutter-behavior-lock: 锁定 v1 行为 → 生成测试
2
+ # 场景: 框架迁移前/中,需要把 v1 的所有行为锁定为可执行的测试
3
+ # 产出: 行为文档 + 单元测试 + 端到端测试用例
4
+ # 执行方式: 逐模块,每个模块独立 agent 会话
5
+
6
+ version: "0.1.0"
7
+ id: template_flutter_behavior_lock
8
+ name: Flutter Behavior Lock
9
+ type: project
10
+
11
+ cascade:
12
+ inherits: ["species:default"]
13
+ priority: 100
14
+
15
+ genes:
16
+ scan_not_change:
17
+ description: This workflow only reads v1 and writes docs/tests — never modifies app code
18
+ codons:
19
+ - type: threshold
20
+ condition: "modify_app_source == false"
21
+ action: block
22
+ - type: attract
23
+ target: read_source_generate_docs
24
+ - type: repel
25
+ target: refactor_during_scan
26
+
27
+ function_call_granularity:
28
+ description: Behavior docs at function-call level — not too coarse, not too fine
29
+ codons:
30
+ - type: attract
31
+ target: user_action_to_function_call
32
+ - type: repel
33
+ target: widget_tree_details
34
+ - type: repel
35
+ target: vague_feature_description
36
+ - type: weight
37
+ a: precision
38
+ b: brevity
39
+ ratio: 0.7
40
+
41
+ one_module_per_session:
42
+ description: Each agent session handles exactly one module to avoid context overflow
43
+ codons:
44
+ - type: attract
45
+ target: single_module_focus
46
+ - type: repel
47
+ target: cross_module_scanning
48
+ - type: threshold
49
+ condition: "modules_per_session <= 1"
50
+ action: escalate
51
+
52
+ contexts: {}
53
+
54
+ roles:
55
+ scanner:
56
+ description: Reads v1 source code, outputs behavior document for one module
57
+ tool_permissions:
58
+ allow: [Read, Grep, Glob, Bash]
59
+ deny: [Edit, Write, NotebookEdit]
60
+ scope:
61
+ read: ["**/*"]
62
+ write: []
63
+ instructions:
64
+ - Scan ONE module only (specified in prompt)
65
+ - For each page/screen in the module, list all user-visible actions
66
+ - For each action, trace the call chain to the first service/repository call
67
+ - "Format: 动作 → 函数调用 → 期望返回值/副作用"
68
+ - Output as structured markdown with checkboxes
69
+ - Mark uncertain items as [待确认]
70
+ - Do NOT read v2 code — only v1
71
+
72
+ test_writer:
73
+ description: Reads behavior document, writes unit tests for v2, runs baseline
74
+ tool_permissions:
75
+ allow: [Read, Edit, Write, Grep, Glob, Bash]
76
+ scope:
77
+ read: ["**/*"]
78
+ write: ["test/**", "docs/behavior/**"]
79
+ instructions:
80
+ - Read the behavior document for the specified module
81
+ - Write one test file per page/screen
82
+ - Each user action = one test case
83
+ - "Test the function call level: does the service method return expected result?"
84
+ - Use existing v2 framework patterns (check test/ for examples)
85
+ - Run tests after writing — record pass/fail counts as baseline
86
+ - Append baseline to docs/behavior/{module}.md under a '# Baseline' section
87
+ - Red tests are expected (v2 not yet fixed)
88
+ - Do NOT modify app source code — only write tests
89
+
90
+ qa_verifier:
91
+ description: Runs end-to-end verification on device/emulator via adb
92
+ tool_permissions:
93
+ allow: [Read, Bash, Grep, Glob]
94
+ deny: [Edit, Write, NotebookEdit]
95
+ scope:
96
+ read: ["**/*"]
97
+ write: []
98
+ instructions:
99
+ - Use adb to screencap the target module's page on device
100
+ - Use adb logcat to capture runtime errors
101
+ - If device not connected, skip and report
102
+ - Append screenshots and error logs to docs/behavior/{module}.md
103
+ - Never modify code — only observe and report
104
+
105
+ workflows:
106
+ behavior-lock:
107
+ name: Behavior Lock
108
+ steps:
109
+ - id: scan
110
+ role: scanner
111
+ description: Scan one v1 module, output behavior document
112
+ prompt: "Scan module '{{module}}' in {{v1_path}}. Output behavior document to {{output_path}}/{{module}}.md. Then immediately proceed to write_tests step — do not stop."
113
+ - id: write_tests
114
+ role: test_writer
115
+ depends_on: [scan]
116
+ description: Write unit tests, run baseline, append results to behavior doc
117
+ prompt: "Read {{output_path}}/{{module}}.md. Write tests in {{test_path}}/{{module}}/ for v2 code at {{v2_path}}. Run tests and record pass/fail as baseline in the behavior doc. Then immediately proceed to qa_verify step."
118
+ - id: qa_verify
119
+ role: qa_verifier
120
+ depends_on: [write_tests]
121
+ description: End-to-end verification on device via adb (optional)
122
+ prompt: "Verify '{{module}}' module on device. Use adb screencap + logcat. Append results to {{output_path}}/{{module}}.md. Skip if no device connected but note in summary."
@@ -0,0 +1,140 @@
1
+ # flutter-refactoring-rescue: 修复已迁移但不能用的 Flutter 项目
2
+ # 场景: 框架迁移已完成,但功能链路断裂,需要逐条修复
3
+ # 核心纪律: 一次一条链路,改一个验一个,v1 是 oracle
4
+ # 参考: safe-refactoring + verification-loop + Superpowers systematic-debugging
5
+
6
+ version: "0.1.0"
7
+ id: template_flutter_refactoring_rescue
8
+ name: Flutter Refactoring Rescue
9
+ type: project
10
+
11
+ cascade:
12
+ inherits: ["species:default"]
13
+ priority: 100
14
+
15
+ genes:
16
+ one_chain_at_a_time:
17
+ description: Each session fixes exactly one functional chain (e.g. "send message → receive reply")
18
+ codons:
19
+ - type: attract
20
+ target: single_feature_chain_per_session
21
+ - type: repel
22
+ target: parallel_feature_changes
23
+ - type: repel
24
+ target: cross_module_changes
25
+ - type: threshold
26
+ condition: "files_changed_per_commit <= 5"
27
+ action: escalate
28
+
29
+ v1_is_oracle:
30
+ description: Copy logic from v1, never guess API signatures or behavior
31
+ codons:
32
+ - type: attract
33
+ target: read_v1_source_before_changing_v2
34
+ - type: attract
35
+ target: copy_logic_from_v1
36
+ - type: repel
37
+ target: guess_api_signature
38
+ - type: repel
39
+ target: invent_new_logic
40
+ - type: threshold
41
+ condition: "fabricate_code_without_v1_reference == false"
42
+ action: block
43
+
44
+ runtime_verification:
45
+ description: Every change must be verified on device before commit
46
+ codons:
47
+ - type: attract
48
+ target: adb_screenshot_after_change
49
+ - type: attract
50
+ target: logcat_error_check
51
+ - type: repel
52
+ target: assumed_fix
53
+ - type: threshold
54
+ condition: "commit_without_device_verification == false"
55
+ action: block
56
+ - type: sense
57
+ signal: incomplete_result
58
+ response: retry_with_more_depth
59
+
60
+ small_steps:
61
+ description: Change one file, verify, then move to next
62
+ codons:
63
+ - type: attract
64
+ target: single_file_change
65
+ - type: attract
66
+ target: hot_reload_after_each_change
67
+ - type: repel
68
+ target: batch_file_changes
69
+ - type: weight
70
+ a: safety
71
+ b: speed
72
+ ratio: 0.9
73
+
74
+ preserve_behavior:
75
+ description: Preserve existing behavior including bugs — only change framework
76
+ codons:
77
+ - type: attract
78
+ target: same_inputs_same_outputs
79
+ - type: attract
80
+ target: preserve_bug_behavior
81
+ - type: repel
82
+ target: sneaky_behavior_changes
83
+ - type: repel
84
+ target: improvement_during_refactor
85
+ - type: sense
86
+ signal: uncertain_information
87
+ response: escalate_to_human
88
+
89
+ contexts: {}
90
+
91
+ roles:
92
+ investigator:
93
+ description: Reads v1 code and traces the broken chain — never writes code
94
+ tool_permissions:
95
+ allow: [Read, Grep, Glob, Bash]
96
+ deny: [Edit, Write, NotebookEdit]
97
+ scope:
98
+ read: ["**/*"]
99
+ write: []
100
+ instructions:
101
+ - Trace the full call chain in v1 for the target feature
102
+ - Find the corresponding v2 code for each step in the chain
103
+ - Identify the first breakpoint where v2 diverges from v1
104
+ - Report with exact file paths and line numbers
105
+ - Use adb logcat to capture runtime errors
106
+ - Never suggest code changes — only report findings
107
+
108
+ surgeon:
109
+ description: Fixes one breakpoint at a time by copying logic from v1
110
+ tool_permissions:
111
+ allow: [Read, Edit, Write, Grep, Glob, Bash]
112
+ scope:
113
+ read: ["**/*"]
114
+ write: ["lib/**"]
115
+ instructions:
116
+ - Fix only the breakpoint identified by investigator
117
+ - Copy logic from v1, adapt to v2 framework — do not invent
118
+ - Change at most one file per round
119
+ - After each change, verify with hot reload + adb screenshot
120
+ - If the fix doesn't work, revert and re-analyze
121
+ - Never "improve" code during refactoring — preserve exact behavior
122
+
123
+ workflows:
124
+ rescue-chain:
125
+ name: Chain Rescue
126
+ steps:
127
+ - id: trace
128
+ role: investigator
129
+ description: Trace the broken chain in v1 and v2, identify first breakpoint
130
+ prompt: "Trace the call chain for '{{feature}}' in v1 ({{v1_path}}) and v2 ({{v2_path}}). Find where v2 breaks."
131
+ - id: fix
132
+ role: surgeon
133
+ depends_on: [trace]
134
+ description: Fix the identified breakpoint
135
+ prompt: "Fix the breakpoint identified by investigator. Copy logic from v1, change one file only."
136
+ - id: verify
137
+ role: investigator
138
+ depends_on: [fix]
139
+ description: Verify the fix with adb
140
+ prompt: "Run the feature on device. adb screencap + logcat. Compare with v1 behavior."
@@ -0,0 +1,216 @@
1
+ # flutter-rewrite: 完整重构工作流(统一 DNA,不需要切换)
2
+ # 包含所有阶段的角色和约束,通过 .dna-mode 状态文件切换行为
3
+ # 参考: OMC hooks.json — 一套 hooks 固定注册,状态驱动行为
4
+
5
+ version: "0.1.0"
6
+ id: template_flutter_rewrite
7
+ name: Flutter Rewrite (Unified)
8
+ type: project
9
+
10
+ cascade:
11
+ inherits: ["species:default"]
12
+ priority: 100
13
+
14
+ # 项目级变量 — dna sync 时交互式提问
15
+ variables:
16
+ v1_path:
17
+ description: "v1 源码路径 (v1 的 lib 目录)"
18
+ default: "common/lib"
19
+ v2_path:
20
+ description: "v2 源码路径 (v2 的 packages 目录)"
21
+ default: "v2/packages"
22
+ behavior_docs:
23
+ description: "行为文档输出目录"
24
+ default: "docs/behavior"
25
+ test_path:
26
+ description: "测试输出目录"
27
+ default: "test/behavior"
28
+
29
+ genes:
30
+ # ── 全局约束(所有模式都生效)──
31
+ no_add_no_remove:
32
+ description: Do not add features v1 doesn't have, do not remove features v1 has
33
+ codons:
34
+ - type: threshold
35
+ condition: "add_new_feature == false"
36
+ action: block
37
+ - type: threshold
38
+ condition: "remove_existing_feature == false"
39
+ action: block
40
+ - type: repel
41
+ target: improvement_during_refactor
42
+
43
+ one_module_per_session:
44
+ description: Each session handles exactly one module
45
+ codons:
46
+ - type: attract
47
+ target: single_module_focus
48
+ - type: repel
49
+ target: cross_module_changes
50
+ - type: threshold
51
+ condition: "modules_per_session <= 1"
52
+ action: escalate
53
+
54
+ v1_is_truth:
55
+ description: v1 source code is the only source of truth, not old docs
56
+ codons:
57
+ - type: attract
58
+ target: read_v1_source_before_changing
59
+ - type: repel
60
+ target: guess_api_signature
61
+ - type: threshold
62
+ condition: "fabricate_code_without_v1_reference == false"
63
+ action: block
64
+
65
+ # ── scan 模式约束 ──
66
+ scan_read_only:
67
+ description: In scan mode, never modify app source code
68
+ codons:
69
+ - type: attract
70
+ target: read_source_generate_docs
71
+ - type: repel
72
+ target: refactor_during_scan
73
+
74
+ # ── rescue 模式约束 ──
75
+ rescue_small_steps:
76
+ description: In rescue mode, change one file at a time and verify
77
+ codons:
78
+ - type: attract
79
+ target: single_file_change
80
+ - type: attract
81
+ target: test_after_each_change
82
+ - type: repel
83
+ target: batch_file_changes
84
+ - type: weight
85
+ a: safety
86
+ b: speed
87
+ ratio: 0.9
88
+
89
+ preserve_behavior:
90
+ description: Preserve existing behavior including bugs
91
+ codons:
92
+ - type: attract
93
+ target: same_inputs_same_outputs
94
+ - type: repel
95
+ target: sneaky_behavior_changes
96
+ - type: sense
97
+ signal: uncertain_information
98
+ response: escalate_to_human
99
+
100
+ contexts: {}
101
+
102
+ roles:
103
+ # ── Phase 0/3: behavior-lock 角色 ──
104
+ scanner:
105
+ description: Scans v1 source code, outputs behavior document. Read-only.
106
+ tool_permissions:
107
+ allow: [Read, Grep, Glob, Bash]
108
+ deny: [Edit, Write, NotebookEdit]
109
+ scope:
110
+ read: ["**/*"]
111
+ write: []
112
+ instructions:
113
+ - Scan ONE module only
114
+ - "For each page, list user-visible actions: 动作 → 函数调用 → 返回值"
115
+ - Output as markdown with checkboxes
116
+ - Do NOT read v2 code — only v1
117
+
118
+ test_writer:
119
+ description: Reads behavior document, writes unit tests for v2.
120
+ tool_permissions:
121
+ allow: [Read, Edit, Write, Grep, Glob, Bash]
122
+ scope:
123
+ read: ["**/*"]
124
+ write: ["test/**", "docs/behavior/**"]
125
+ instructions:
126
+ - Read the behavior document for the module
127
+ - Write one test file per page/screen
128
+ - Each user action = one test case
129
+ - Test service/repository layer, not UI
130
+ - Run tests after writing — record baseline
131
+ - Red tests are expected
132
+
133
+ # ── Phase 4: rescue 角色 ──
134
+ investigator:
135
+ description: Traces broken chain in v1 and v2, identifies breakpoint. Read-only.
136
+ tool_permissions:
137
+ allow: [Read, Grep, Glob, Bash]
138
+ deny: [Edit, Write, NotebookEdit]
139
+ scope:
140
+ read: ["**/*"]
141
+ write: []
142
+ instructions:
143
+ - Trace the call chain in v1 for the target feature
144
+ - Find where v2 diverges
145
+ - Report with exact file paths and line numbers
146
+ - Never suggest code changes
147
+
148
+ surgeon:
149
+ description: Fixes one breakpoint at a time by understanding v1 intent and rewriting in v2 style.
150
+ tool_permissions:
151
+ allow: [Read, Edit, Write, Grep, Glob, Bash]
152
+ scope:
153
+ read: ["**/*"]
154
+ write: ["lib/**", "v2/**"]
155
+ instructions:
156
+ - Fix only the identified breakpoint
157
+ - Read v1 to understand intent, rewrite in v2 framework style
158
+ - Do not copy v1 code verbatim — adapt to v2 architecture
159
+ - Change at most one call chain (2-3 files) per round
160
+ - After each change, run tests
161
+ - If fix doesn't work, revert and re-analyze
162
+ - Never "improve" code — preserve exact behavior
163
+ - "UI files: copy from v1, only change state binding syntax (Obx→Consumer, Get.to→context.go)"
164
+
165
+ # ── Core align 角色 ──
166
+ core_aligner:
167
+ description: Aligns v2 core with v1 infrastructure. Can modify core only.
168
+ tool_permissions:
169
+ allow: [Read, Edit, Write, Grep, Glob, Bash]
170
+ scope:
171
+ read: ["**/*"]
172
+ write: ["v2/packages/core/**"]
173
+ instructions:
174
+ - Compare v1 and v2 core module by module
175
+ - MethodChannel names and method signatures must match v1 exactly
176
+ - Only change DI pattern (GetX → Riverpod), not logic
177
+ - Do not add methods v1 doesn't have
178
+ - Do not remove methods v1 has
179
+
180
+ workflows:
181
+ behavior-lock:
182
+ name: Behavior Lock
183
+ description: "Scan v1 module $ARGUMENTS, generate behavior doc and tests for v2"
184
+ steps:
185
+ - id: scan
186
+ role: scanner
187
+ description: "Scan v1 module in {{v1_path}}/. Output behavior doc to {{behavior_docs}}/$ARGUMENTS.md. List all user actions with call chains."
188
+ prompt: "Scan module '$ARGUMENTS' in {{v1_path}}/. For each page, list: action → function() → return value. Output to {{behavior_docs}}/$ARGUMENTS.md. Then immediately proceed to write_tests."
189
+ - id: write_tests
190
+ role: test_writer
191
+ depends_on: [scan]
192
+ description: "Read {{behavior_docs}}/$ARGUMENTS.md, write tests in {{test_path}}/$ARGUMENTS/, run baseline."
193
+ prompt: "Read {{behavior_docs}}/$ARGUMENTS.md. Write tests in {{test_path}}/$ARGUMENTS/. Run tests, record red/green baseline. Append baseline to behavior doc."
194
+
195
+ rescue:
196
+ name: Rescue
197
+ description: "Fix v2 module $ARGUMENTS by making failing tests pass"
198
+ steps:
199
+ - id: investigate
200
+ role: investigator
201
+ description: "Run tests, find first red test, trace the broken call chain in v1 and v2."
202
+ prompt: "Run tests in {{test_path}}/$ARGUMENTS/. For the first red test, trace: what does v1 do vs what does v2 do? Find the breakpoint. Report and wait for user confirmation."
203
+ - id: fix
204
+ role: surgeon
205
+ depends_on: [investigate]
206
+ description: "Fix the breakpoint. Read v1 intent, rewrite in v2 style. Run tests after."
207
+ prompt: "Fix the identified breakpoint. Read v1 in {{v1_path}}/. Rewrite in v2 style in {{v2_path}}/. Run tests. Red→green = done. Still red = revert and re-analyze."
208
+
209
+ core-align:
210
+ name: Core Align
211
+ description: "Align v2 core infrastructure with v1"
212
+ steps:
213
+ - id: align
214
+ role: core_aligner
215
+ description: "Compare {{v1_path}}/ and {{v2_path}}/core/ module by module. Fix mismatches."
216
+ prompt: "Compare v1 ({{v1_path}}/) and v2 core ({{v2_path}}/core/lib/). List mismatches. Fix by copying v1 logic, only changing DI (GetX→Riverpod). Run flutter analyze after each fix."
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "intentdna",
3
- "version": "1.0.0",
3
+ "version": "1.2.0",
4
4
  "description": "Intent DNA — Declarative policy layer for AI agent behavior",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",