intentdna 1.5.8 → 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.
@@ -9,7 +9,7 @@
9
9
  {
10
10
  "name": "intentdna",
11
11
  "description": "DNA template compilation + runtime enforcement",
12
- "version": "1.5.8",
12
+ "version": "1.5.9",
13
13
  "source": "./"
14
14
  }
15
15
  ]
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "intentdna",
3
- "version": "1.5.8",
3
+ "version": "1.5.9",
4
4
  "description": "Declarative policy layer for AI agent governance"
5
5
  }
@@ -20,6 +20,7 @@ export interface ActivatedGene {
20
20
  codons: Codon[];
21
21
  tags: string[];
22
22
  expression_level: number;
23
+ role?: "constraint" | "workflow_hint";
23
24
  }
24
25
  /**
25
26
  * Activate a cascaded DNA for a given context and role.
@@ -74,6 +74,7 @@ export function activateDNA(cascaded, contextName = null, activeRole = null) {
74
74
  codons: [...gene.codons],
75
75
  tags: [...(gene.tags ?? [])],
76
76
  expression_level: 1.0,
77
+ role: gene.role,
77
78
  };
78
79
  }
79
80
  // Apply context modifiers if a context is active
@@ -55,6 +55,14 @@ function geneToDirectives(name, gene) {
55
55
  if (weights.length > 0) {
56
56
  parts.push(`Trade-offs: ${weights.join("; ")}.`);
57
57
  }
58
+ // For workflow_hint genes, threshold codons become prompt directives instead of gates
59
+ if (gene.role === "workflow_hint") {
60
+ for (const codon of gene.codons) {
61
+ if (codon.type === "threshold") {
62
+ parts.push(`Condition: ${codon.condition}.`);
63
+ }
64
+ }
65
+ }
58
66
  if (parts.length > 1) {
59
67
  directives.push({
60
68
  priority,
@@ -153,9 +161,11 @@ export function compileDNA(activated, cascaded) {
153
161
  const injections = [];
154
162
  for (const [name, gene] of Object.entries(activated.genes)) {
155
163
  directives.push(...geneToDirectives(name, gene));
156
- toolFilters.push(...geneToToolFilters(name, gene));
157
- gates.push(...geneToGates(name, gene));
158
- validators.push(...geneToValidators(name, gene));
164
+ if (gene.role !== "workflow_hint") {
165
+ toolFilters.push(...geneToToolFilters(name, gene));
166
+ gates.push(...geneToGates(name, gene));
167
+ validators.push(...geneToValidators(name, gene));
168
+ }
159
169
  }
160
170
  // Compile role constraints
161
171
  let roleToolPermissions;
@@ -37,6 +37,7 @@ export interface Gene {
37
37
  description: string;
38
38
  codons: Codon[];
39
39
  tags?: string[];
40
+ role?: "constraint" | "workflow_hint";
40
41
  }
41
42
  export type ModifierAction = "amplify" | "suppress" | "activate" | "deactivate";
42
43
  export interface GeneModifier {
@@ -0,0 +1,152 @@
1
+ version: "0.1.0"
2
+ id: template_code_cleanup
3
+ name: Code Cleanup (Regression-Safe)
4
+ type: project
5
+ namespace: cc
6
+
7
+ cascade:
8
+ inherits: ["species:default"]
9
+ priority: 100
10
+
11
+ genes:
12
+ test_between_passes:
13
+ description: Tests must pass between each cleanup pass
14
+ codons:
15
+ - type: threshold
16
+ condition: "tests_passing == true"
17
+ action: block
18
+ - type: attract
19
+ target: run_tests_after_each_pass
20
+
21
+ no_behavior_change:
22
+ description: Cleanup must not change observable behavior
23
+ codons:
24
+ - type: threshold
25
+ condition: "behavior_changed == false"
26
+ action: block
27
+ - type: repel
28
+ target: modify_public_api
29
+ - type: attract
30
+ target: same_inputs_same_outputs
31
+
32
+ smell_focused:
33
+ description: Clean by smell type in order - dead code, duplication, naming
34
+ role: workflow_hint
35
+ codons:
36
+ - type: attract
37
+ target: categorize_before_cleaning
38
+ - type: attract
39
+ target: one_smell_type_per_pass
40
+
41
+ minimal_cleanup:
42
+ description: Each pass focuses on one type of issue
43
+ codons:
44
+ - type: attract
45
+ target: single_concern_per_pass
46
+ - type: repel
47
+ target: mixed_cleanup_types
48
+ - type: threshold
49
+ condition: "files_changed_per_pass <= 10"
50
+ action: escalate
51
+
52
+ contexts: {}
53
+
54
+ roles:
55
+ analyzer:
56
+ description: Analyzes code for cleanup opportunities. Read-only.
57
+ tool_permissions:
58
+ allow: [Read, Grep, Glob, Bash]
59
+ deny: [Edit, Write, NotebookEdit]
60
+ scope:
61
+ read: ["**/*"]
62
+ write: []
63
+ instructions:
64
+ - Classify code smells by type (dead code, duplication, naming, complexity)
65
+ - Prioritize by impact and risk
66
+ - Do NOT suggest behavioral changes
67
+ - Output a categorized cleanup plan
68
+
69
+ cleaner:
70
+ description: Executes cleanup changes. Can modify code.
71
+ tool_permissions:
72
+ allow: [Read, Edit, Write, Grep, Glob, Bash]
73
+ scope:
74
+ read: ["**/*"]
75
+ write: ["src/**", "lib/**"]
76
+ instructions:
77
+ - Follow the analyzer's cleanup plan
78
+ - One smell type per pass
79
+ - Run tests after each file change
80
+ - Revert if tests fail
81
+ - Do not change public APIs or observable behavior
82
+ - Commit after each successful pass
83
+
84
+ reviewer:
85
+ description: Reviews cleanup changes for correctness. Read-only.
86
+ tool_permissions:
87
+ allow: [Read, Grep, Glob, Bash]
88
+ deny: [Edit, Write, NotebookEdit]
89
+ scope:
90
+ read: ["**/*"]
91
+ write: []
92
+ instructions:
93
+ - Review git diff for each cleanup pass
94
+ - Verify no behavioral changes
95
+ - Check test coverage unchanged
96
+ - "Verdict: APPROVE or REQUEST_CHANGES"
97
+
98
+ workflows:
99
+ cleanup:
100
+ name: Code Cleanup
101
+ description: "Regression-safe code cleanup: analyze, classify, clean by smell type, verify"
102
+ steps:
103
+ - id: lock_behavior
104
+ role: analyzer
105
+ description: "Assess current test coverage and establish behavior baseline."
106
+ prompt: |
107
+ Run existing tests to establish baseline.
108
+ Record: total tests, passing, failing.
109
+ If test coverage is insufficient, warn before proceeding.
110
+ Output: baseline test results + coverage assessment.
111
+
112
+ - id: classify
113
+ role: analyzer
114
+ depends_on: [lock_behavior]
115
+ description: "Scan codebase and categorize code smells."
116
+ prompt: |
117
+ Scan the codebase for code smells. Categorize:
118
+ 1. Dead code (unused imports, unreachable branches, commented-out code)
119
+ 2. Duplication (copy-paste patterns, similar functions)
120
+ 3. Naming (unclear names, inconsistent conventions)
121
+ 4. Complexity (long functions, deep nesting)
122
+
123
+ Prioritize: dead code first (safest), then duplication, then naming.
124
+ Output: categorized cleanup plan with file paths and line numbers.
125
+
126
+ - id: clean
127
+ role: cleaner
128
+ depends_on: [classify]
129
+ description: "Execute cleanup one smell type at a time."
130
+ prompt: |
131
+ Follow the cleanup plan. Rules:
132
+ - One smell type per pass (start with dead code)
133
+ - Run tests after each file change
134
+ - If tests fail: revert immediately, report the issue
135
+ - Maximum 10 files per pass
136
+ - Commit after each successful pass: "cleanup($TYPE): description"
137
+ - Do NOT change any public API signatures
138
+ - Do NOT rename exported symbols
139
+ - Do NOT modify test files (unless removing dead test helpers)
140
+
141
+ - id: verify
142
+ role: reviewer
143
+ depends_on: [clean]
144
+ description: "Verify cleanup preserved behavior."
145
+ prompt: |
146
+ Review all cleanup changes (git diff from baseline):
147
+ 1. Any behavioral changes? (API signatures, return values, side effects)
148
+ 2. Test count unchanged or increased?
149
+ 3. All tests still passing?
150
+ 4. No unintended file modifications?
151
+
152
+ Verdict: APPROVE (cleanup complete) or REQUEST_CHANGES (list issues)
@@ -0,0 +1,144 @@
1
+ version: "0.1.0"
2
+ id: template_persistent_executor
3
+ name: Persistent Executor (PRD-Driven)
4
+ type: project
5
+ namespace: pe
6
+
7
+ cascade:
8
+ inherits: ["species:default"]
9
+ priority: 100
10
+
11
+ genes:
12
+ prd_driven:
13
+ description: Every task must trace back to explicit acceptance criteria
14
+ codons:
15
+ - type: threshold
16
+ condition: "acceptance_criteria_defined == true"
17
+ action: block
18
+ - type: attract
19
+ target: reference_acceptance_criteria
20
+ - type: repel
21
+ target: work_without_spec
22
+
23
+ verify_before_done:
24
+ description: Never claim completion without passing acceptance criteria
25
+ codons:
26
+ - type: threshold
27
+ condition: "all_criteria_verified == true"
28
+ action: block
29
+ - type: attract
30
+ target: run_verification_before_reporting
31
+ - type: repel
32
+ target: claim_done_without_evidence
33
+
34
+ no_partial_completion:
35
+ description: Either fully complete a story or explicitly report what remains
36
+ codons:
37
+ - type: threshold
38
+ condition: "story_fully_complete == true"
39
+ action: escalate
40
+ - type: repel
41
+ target: silent_partial_delivery
42
+
43
+ small_increments:
44
+ description: One story per commit, verifiable increments
45
+ role: workflow_hint
46
+ codons:
47
+ - type: attract
48
+ target: one_story_one_commit
49
+ - type: repel
50
+ target: batch_multiple_stories
51
+ - type: attract
52
+ target: each_commit_passes_tests
53
+
54
+ contexts: {}
55
+
56
+ roles:
57
+ executor:
58
+ description: Implements stories from the PRD. Can modify code.
59
+ tool_permissions:
60
+ allow: [Read, Edit, Write, Grep, Glob, Bash]
61
+ scope:
62
+ read: ["**/*"]
63
+ write: ["src/**", "lib/**", "test/**"]
64
+ instructions:
65
+ - Pick the highest priority incomplete story
66
+ - Read acceptance criteria before starting
67
+ - Implement in small verifiable steps
68
+ - Run tests after each change
69
+ - Commit after each story completion
70
+ - "Commit message: feat($STORY): what was implemented"
71
+ - Do not move to next story until current one is verified
72
+
73
+ verifier:
74
+ description: Independently verifies story completion. Read-only + can run tests.
75
+ tool_permissions:
76
+ allow: [Read, Grep, Glob, Bash]
77
+ deny: [Edit, Write, NotebookEdit]
78
+ scope:
79
+ read: ["**/*"]
80
+ write: []
81
+ instructions:
82
+ - Read the acceptance criteria for the completed story
83
+ - Run tests independently (do not trust executor's output)
84
+ - Check each criterion individually
85
+ - "Mark each: VERIFIED / PARTIAL / MISSING"
86
+ - "Verdict: PASS (all verified) or FAIL (list what's missing)"
87
+ - On FAIL the executor must fix before proceeding
88
+
89
+ workflows:
90
+ persistent-execution:
91
+ name: Persistent Execution
92
+ description: "PRD-driven story execution: pick, implement, verify, repeat until all done"
93
+ steps:
94
+ - id: pick_story
95
+ role: executor
96
+ description: "Select next story from PRD by priority."
97
+ prompt: |
98
+ Read the PRD or task list.
99
+ Select the highest priority incomplete story.
100
+ Confirm: acceptance criteria are clear and testable.
101
+ If criteria are vague, ask for clarification before starting.
102
+ Output: story ID, title, acceptance criteria.
103
+
104
+ - id: implement
105
+ role: executor
106
+ depends_on: [pick_story]
107
+ description: "Implement the selected story."
108
+ prompt: |
109
+ Implement the story. Rules:
110
+ - Read acceptance criteria carefully
111
+ - Small steps: change → test → verify
112
+ - Maximum scope: what the story requires, nothing more
113
+ - Run tests after each meaningful change
114
+ - If stuck for 3 attempts on the same issue: STOP and report blocker
115
+ - Commit when story implementation is complete
116
+ - Do not start the next story
117
+
118
+ - id: verify
119
+ role: verifier
120
+ depends_on: [implement]
121
+ description: "Independent verification of story completion."
122
+ prompt: |
123
+ Verify the completed story independently:
124
+ 1. Read acceptance criteria
125
+ 2. Run all relevant tests (do not trust executor's results)
126
+ 3. Check each criterion: VERIFIED / PARTIAL / MISSING
127
+ 4. Run full test suite for regression check
128
+
129
+ PASS: All criteria verified → story complete, ready for next
130
+ FAIL: List what's missing → executor must fix
131
+
132
+ - id: report
133
+ role: verifier
134
+ depends_on: [verify]
135
+ description: "Report progress and determine next action."
136
+ prompt: |
137
+ Summary:
138
+ - Story: [ID] [title]
139
+ - Criteria: N/M verified
140
+ - Tests: X passing, Y failing
141
+ - Verdict: COMPLETE or NEEDS_FIX
142
+
143
+ If COMPLETE: "Story done. Pick next story to continue."
144
+ If NEEDS_FIX: "Story incomplete. Issues: [list]. Fix before proceeding."
@@ -0,0 +1,147 @@
1
+ version: "0.1.0"
2
+ id: template_qa_loop
3
+ name: QA Loop (Test-Fix Cycle)
4
+ type: project
5
+ namespace: ql
6
+
7
+ cascade:
8
+ inherits: ["species:default"]
9
+ priority: 100
10
+
11
+ genes:
12
+ convergence_protection:
13
+ description: Stop if no progress after 2 consecutive rounds
14
+ codons:
15
+ - type: threshold
16
+ condition: "consecutive_no_progress_rounds <= 2"
17
+ action: block
18
+ - type: attract
19
+ target: track_test_progress_per_round
20
+ - type: repel
21
+ target: infinite_retry_loop
22
+
23
+ separate_test_fix:
24
+ description: Tester and fixer must be separate roles
25
+ codons:
26
+ - type: threshold
27
+ condition: "tester_is_not_fixer == true"
28
+ action: block
29
+ - type: repel
30
+ target: self_test_own_fix
31
+
32
+ evidence_based_diagnosis:
33
+ description: Diagnose from test output, not guessing
34
+ role: workflow_hint
35
+ codons:
36
+ - type: attract
37
+ target: read_error_output_first
38
+ - type: repel
39
+ target: guess_without_running_tests
40
+ - type: attract
41
+ target: categorize_failures_by_type
42
+
43
+ regression_awareness:
44
+ description: Fixes must not introduce new failures
45
+ codons:
46
+ - type: threshold
47
+ condition: "new_failures_introduced == 0"
48
+ action: escalate
49
+ - type: attract
50
+ target: run_full_suite_after_fix
51
+
52
+ contexts: {}
53
+
54
+ roles:
55
+ tester:
56
+ description: Runs tests, diagnoses failures, categorizes issues. Read-only.
57
+ tool_permissions:
58
+ allow: [Read, Grep, Glob, Bash]
59
+ deny: [Edit, Write, NotebookEdit]
60
+ scope:
61
+ read: ["**/*"]
62
+ write: []
63
+ instructions:
64
+ - Run the full test suite
65
+ - Categorize failures by type (compile, logic, integration, flaky)
66
+ - For each failure trace the root cause
67
+ - Prioritize by severity
68
+ - Compare results with previous round — track progress
69
+ - Do NOT suggest code changes
70
+
71
+ fixer:
72
+ description: Fixes issues identified by tester. Can modify code.
73
+ tool_permissions:
74
+ allow: [Read, Edit, Write, Grep, Glob, Bash]
75
+ scope:
76
+ read: ["**/*"]
77
+ write: ["src/**", "lib/**", "test/**"]
78
+ instructions:
79
+ - Fix issues in priority order (compile first, then logic, then integration)
80
+ - One fix at a time, run tests after each
81
+ - If a fix introduces new failures, revert immediately
82
+ - Maximum 5 files per round
83
+ - "Same issue failing 3 times → STOP, report as blocked"
84
+ - Commit after each successful fix batch
85
+
86
+ workflows:
87
+ qa-cycle:
88
+ name: QA Cycle
89
+ description: "Test-fix loop: test, diagnose, fix, retest. Max 5 rounds with convergence protection."
90
+ max_rounds: 5
91
+ convergence_rule: "2 consecutive rounds with 0 test progress → STOP"
92
+ steps:
93
+ - id: test
94
+ role: tester
95
+ description: "Run tests and categorize failures."
96
+ prompt: |
97
+ Run the test suite. Record results:
98
+ - Total tests, passing, failing, skipped
99
+ - If round > 1: compare with previous round results
100
+ - Categorize each failure:
101
+ COMPILE: syntax/import errors — fix first
102
+ LOGIC: assertion failures — fix after compile
103
+ INTEGRATION: cross-module issues — fix after logic
104
+ FLAKY: intermittent failures — deprioritize
105
+ - If 0 failures: "All tests passing. QA complete."
106
+ - If round > 1 and no progress: warn "no improvement"
107
+
108
+ - id: diagnose
109
+ role: tester
110
+ depends_on: [test]
111
+ description: "Root cause analysis for top failures."
112
+ prompt: |
113
+ For the top 3 failures (by severity):
114
+ 1. Read the error output carefully
115
+ 2. Trace to the root cause in source code
116
+ 3. Identify the minimal fix needed
117
+ 4. Check if failures are related (shared root cause)
118
+ Output: prioritized fix list with file paths and line numbers.
119
+
120
+ - id: fix
121
+ role: fixer
122
+ depends_on: [diagnose]
123
+ description: "Apply fixes for diagnosed issues."
124
+ prompt: |
125
+ Fix the diagnosed issues. Rules:
126
+ - Follow the priority order from diagnosis
127
+ - One fix at a time → run tests → verify
128
+ - If fix causes new failures: revert and try different approach
129
+ - Maximum 5 files per round
130
+ - Same issue failed 3 times → STOP and report as blocked
131
+ - Commit: "fix($TYPE): description of what was fixed"
132
+
133
+ - id: retest
134
+ role: tester
135
+ depends_on: [fix]
136
+ description: "Verify fixes and check for regressions."
137
+ prompt: |
138
+ Run the full test suite again:
139
+ 1. Are the targeted failures fixed?
140
+ 2. Any new regressions introduced?
141
+ 3. Test delta: +N fixed, -M new failures
142
+
143
+ Progress check:
144
+ - If all tests pass: "QA complete. All green."
145
+ - If progress made (fewer failures): "Round N: +X fixed. Continue."
146
+ - If no progress (same or more failures): "No progress. [2 rounds → STOP]"
147
+ - If blocked items exist: "Blocked on: [list]. Human intervention needed."
@@ -0,0 +1,116 @@
1
+ # requirements-gate: 需求清晰度门控
2
+ # 在需求明确(>=80%)之前阻止实现,每轮只问一个问题
3
+ # 适用: 任何需要"先澄清需求再动手"的项目
4
+
5
+ version: "0.1.0"
6
+ id: template_requirements_gate
7
+ name: Requirements Clarity Gate
8
+ type: project
9
+ namespace: rg
10
+
11
+ cascade:
12
+ inherits: ["species:default"]
13
+ priority: 100
14
+
15
+ genes:
16
+ clarity_threshold:
17
+ description: Block implementation until requirements are sufficiently clear (>=80%)
18
+ codons:
19
+ - type: threshold
20
+ condition: "requirements_clarity_score >= 80"
21
+ action: block
22
+ - type: attract
23
+ target: clarify_before_building
24
+ - type: repel
25
+ target: implement_with_ambiguity
26
+
27
+ one_question_per_round:
28
+ description: Ask one focused question at a time to reduce cognitive load
29
+ role: workflow_hint
30
+ codons:
31
+ - type: attract
32
+ target: single_focused_question
33
+ - type: repel
34
+ target: question_dump
35
+
36
+ target_weakest_dimension:
37
+ description: Always probe the least clear dimension first
38
+ role: workflow_hint
39
+ codons:
40
+ - type: attract
41
+ target: identify_weakest_area
42
+ - type: repel
43
+ target: redundant_clarification
44
+
45
+ structured_output:
46
+ description: Requirements must be structured and actionable
47
+ codons:
48
+ - type: attract
49
+ target: testable_acceptance_criteria
50
+ - type: repel
51
+ target: vague_requirements
52
+ - type: attract
53
+ target: explicit_constraints
54
+
55
+ contexts: {}
56
+
57
+ roles:
58
+ interviewer:
59
+ description: Evaluates requirements clarity and asks clarifying questions. Read-only.
60
+ tool_permissions:
61
+ allow: [Read, Grep, Glob, Bash]
62
+ deny: [Edit, Write, NotebookEdit]
63
+ scope:
64
+ read: ["**/*"]
65
+ write: []
66
+ instructions:
67
+ - Evaluate requirements across 4 dimensions (Goal, Constraints, Criteria, Context)
68
+ - Score each dimension 0-100
69
+ - If average < 80 output the most critical question targeting the weakest dimension
70
+ - If average >= 80 output structured requirements document
71
+ - One question per round — do not dump multiple questions
72
+ - "80% threshold rationale: below this, >1/5 dimensions are underspecified"
73
+
74
+ workflows:
75
+ requirements-gate:
76
+ name: Requirements Gate
77
+ description: "Evaluate requirements clarity, block if ambiguous, proceed if clear"
78
+ steps:
79
+ - id: clarity_check
80
+ role: interviewer
81
+ description: "Score requirements across 4 dimensions."
82
+ prompt: |
83
+ Evaluate the given requirements across 4 dimensions:
84
+
85
+ 1. Goal (0-100): Is the desired outcome clear and measurable?
86
+ 2. Constraints (0-100): Are boundaries, limitations, and non-goals defined?
87
+ 3. Criteria (0-100): Are acceptance criteria specific and testable?
88
+ 4. Context (0-100): Is the technical/business context sufficient?
89
+
90
+ Calculate average score.
91
+
92
+ If average >= 80:
93
+ Output: structured requirements document with all 4 dimensions filled.
94
+ Status: PROCEED
95
+
96
+ If average < 80:
97
+ Identify the weakest dimension.
98
+ Output: one specific clarifying question targeting that dimension.
99
+ Status: BLOCK — "Requirements clarity at N%. Need clarification on: [dimension]"
100
+
101
+ - id: proceed_or_block
102
+ role: interviewer
103
+ depends_on: [clarity_check]
104
+ description: "Gate decision based on clarity score."
105
+ prompt: |
106
+ Based on clarity check results:
107
+
108
+ If PROCEED: Format the requirements as a structured spec:
109
+ - Goal: [what]
110
+ - Constraints: [boundaries]
111
+ - Acceptance Criteria: [testable conditions]
112
+ - Context: [technical/business background]
113
+ - Out of Scope: [explicit exclusions]
114
+
115
+ If BLOCK: Summarize what's missing and the question to ask.
116
+ Do NOT proceed with implementation planning until clarity >= 80%.
@@ -0,0 +1,145 @@
1
+ # research-orchestration: 并行假设驱动研究
2
+ # 适用: 需要结构化调研、多角度验证、有据可查结论的研究任务
3
+
4
+ version: "0.1.0"
5
+ id: template_research_orchestration
6
+ name: Research Orchestration (Parallel Hypotheses)
7
+ type: project
8
+ namespace: ro
9
+
10
+ cascade:
11
+ inherits: ["species:default"]
12
+ priority: 100
13
+
14
+ genes:
15
+ hypothesis_driven:
16
+ description: Research must start with explicit hypotheses before investigation
17
+ codons:
18
+ - type: threshold
19
+ condition: "hypotheses_defined == true"
20
+ action: block
21
+ - type: attract
22
+ target: state_hypothesis_before_investigating
23
+ - type: repel
24
+ target: undirected_exploration
25
+
26
+ cross_verify:
27
+ description: Findings must be cross-verified by independent researchers
28
+ role: workflow_hint
29
+ codons:
30
+ - type: attract
31
+ target: independent_verification
32
+ - type: repel
33
+ target: single_source_conclusion
34
+
35
+ evidence_graded:
36
+ description: Grade evidence quality and distinguish fact from inference
37
+ role: workflow_hint
38
+ codons:
39
+ - type: attract
40
+ target: grade_source_reliability
41
+ - type: attract
42
+ target: separate_fact_from_interpretation
43
+ - type: repel
44
+ target: treat_all_evidence_equally
45
+
46
+ structured_synthesis:
47
+ description: Synthesis must address all hypotheses with evidence
48
+ codons:
49
+ - type: threshold
50
+ condition: "all_hypotheses_addressed == true"
51
+ action: escalate
52
+ - type: attract
53
+ target: evidence_based_conclusions
54
+
55
+ contexts: {}
56
+
57
+ roles:
58
+ lead_researcher:
59
+ description: Decomposes questions, synthesizes findings. Read-only.
60
+ tool_permissions:
61
+ allow: [Read, Grep, Glob, Bash]
62
+ deny: [Edit, Write, NotebookEdit]
63
+ scope:
64
+ read: ["**/*"]
65
+ write: []
66
+ instructions:
67
+ - Decompose the research question into sub-questions
68
+ - Formulate hypotheses for each sub-question
69
+ - After investigation synthesize findings across all researchers
70
+ - Grade overall confidence in conclusions
71
+ - Identify remaining unknowns and next steps
72
+
73
+ researcher:
74
+ description: Investigates specific sub-questions. Read-only with analysis tools.
75
+ tool_permissions:
76
+ allow: [Read, Grep, Glob, Bash]
77
+ deny: [Edit, Write, NotebookEdit]
78
+ scope:
79
+ read: ["**/*"]
80
+ write: []
81
+ instructions:
82
+ - Focus on assigned sub-question only
83
+ - State hypothesis before investigating
84
+ - Gather evidence from code, docs, logs, tests
85
+ - Grade each piece of evidence (strong/moderate/weak)
86
+ - Report findings with evidence quality ratings
87
+ - Flag uncertainties and assumptions explicitly
88
+
89
+ workflows:
90
+ research:
91
+ name: Research
92
+ description: "Parallel hypothesis research: decompose, investigate, verify, synthesize"
93
+ steps:
94
+ - id: decompose
95
+ role: lead_researcher
96
+ description: "Break research question into sub-questions with hypotheses."
97
+ prompt: |
98
+ Analyze the research question:
99
+ 1. Break into 2-4 independent sub-questions
100
+ 2. For each sub-question:
101
+ - Hypothesis: what do we expect to find?
102
+ - Key sources: where to look (code, docs, logs, external)
103
+ - Success criteria: what constitutes a sufficient answer?
104
+ 3. Identify dependencies between sub-questions
105
+ 4. Assign investigation priority
106
+
107
+ - id: investigate
108
+ role: researcher
109
+ depends_on: [decompose]
110
+ description: "Investigate sub-questions in parallel."
111
+ prompt: |
112
+ Investigate assigned sub-question:
113
+ 1. State the hypothesis clearly
114
+ 2. Gather evidence from identified sources
115
+ 3. For each evidence item:
116
+ - Source: where found
117
+ - Quality: strong / moderate / weak
118
+ - Supports or contradicts hypothesis?
119
+ 4. Preliminary conclusion with confidence level
120
+ 5. List remaining unknowns
121
+
122
+ - id: verify
123
+ role: lead_researcher
124
+ depends_on: [investigate]
125
+ description: "Cross-verify findings across researchers."
126
+ prompt: |
127
+ Cross-verification:
128
+ 1. Do different researchers' findings contradict?
129
+ 2. Are there gaps — sub-questions not fully answered?
130
+ 3. Check: is the evidence quality sufficient for conclusions?
131
+ 4. If contradictions exist: identify the most reliable source
132
+ 5. If gaps exist: note what additional investigation is needed
133
+
134
+ - id: synthesize
135
+ role: lead_researcher
136
+ depends_on: [verify]
137
+ description: "Synthesize all findings into conclusions."
138
+ prompt: |
139
+ Final synthesis:
140
+ 1. For each original sub-question: answer with evidence
141
+ 2. For each hypothesis: confirmed / refuted / inconclusive
142
+ 3. Overall conclusion with confidence level (high/medium/low)
143
+ 4. Key findings (bullet points)
144
+ 5. Remaining unknowns
145
+ 6. Recommended next steps (if any)
@@ -0,0 +1,140 @@
1
+ version: "0.1.0"
2
+ id: template_root_cause_analysis
3
+ name: Root Cause Analysis (Competing Hypotheses)
4
+ type: project
5
+ namespace: rca
6
+
7
+ cascade:
8
+ inherits: ["species:default"]
9
+ priority: 100
10
+
11
+ genes:
12
+ multiple_hypotheses:
13
+ description: Always generate multiple competing hypotheses before investigating
14
+ codons:
15
+ - type: threshold
16
+ condition: "hypotheses_count >= 3"
17
+ action: block
18
+ - type: attract
19
+ target: generate_alternatives
20
+ - type: repel
21
+ target: single_theory_bias
22
+
23
+ falsify_own:
24
+ description: Actively try to disprove your own hypotheses
25
+ codons:
26
+ - type: attract
27
+ target: seek_disconfirming_evidence
28
+ - type: repel
29
+ target: confirmation_bias
30
+ - type: threshold
31
+ condition: "each_hypothesis_has_counter_evidence == true"
32
+ action: escalate
33
+
34
+ evidence_ranked:
35
+ description: Rank evidence by strength and reliability
36
+ role: workflow_hint
37
+ codons:
38
+ - type: attract
39
+ target: grade_evidence_quality
40
+ - type: attract
41
+ target: distinguish_correlation_causation
42
+
43
+ minimal_reproduction:
44
+ description: Create minimal reproduction before investigating
45
+ codons:
46
+ - type: attract
47
+ target: reproduce_before_hypothesizing
48
+ - type: repel
49
+ target: guess_without_evidence
50
+
51
+ contexts: {}
52
+
53
+ roles:
54
+ hypothesis_generator:
55
+ description: Generates competing hypotheses from symptoms. Read-only.
56
+ tool_permissions:
57
+ allow: [Read, Grep, Glob, Bash]
58
+ deny: [Edit, Write, NotebookEdit]
59
+ scope:
60
+ read: ["**/*"]
61
+ write: []
62
+ instructions:
63
+ - Read error messages, logs, and stack traces
64
+ - Generate at least 3 competing hypotheses
65
+ - For each hypothesis state what evidence would confirm AND refute it
66
+ - Rank by prior probability (most likely first)
67
+ - Do NOT suggest fixes yet
68
+
69
+ investigator:
70
+ description: Gathers evidence for/against each hypothesis. Read-only.
71
+ tool_permissions:
72
+ allow: [Read, Grep, Glob, Bash]
73
+ deny: [Edit, Write, NotebookEdit]
74
+ scope:
75
+ read: ["**/*"]
76
+ write: []
77
+ instructions:
78
+ - Test each hypothesis by gathering specific evidence
79
+ - For each hypothesis record evidence FOR and AGAINST
80
+ - Try to DISPROVE the leading hypothesis first
81
+ - Use git blame, logs, test output as evidence
82
+ - Grade evidence strength (strong/moderate/weak)
83
+ - After investigation rank hypotheses by evidence weight
84
+
85
+ workflows:
86
+ root-cause:
87
+ name: Root Cause Analysis
88
+ description: "Competing hypotheses debugging: hypothesize, investigate, rank, synthesize"
89
+ steps:
90
+ - id: reproduce
91
+ role: investigator
92
+ description: "Reproduce the issue and collect symptoms."
93
+ prompt: |
94
+ Reproduce the reported issue:
95
+ 1. Run the failing test or trigger the bug
96
+ 2. Collect all symptoms: error messages, stack traces, logs
97
+ 3. Note: when did it start? What changed recently? (git log)
98
+ 4. Output: symptom summary + reproduction steps
99
+
100
+ - id: hypothesize
101
+ role: hypothesis_generator
102
+ depends_on: [reproduce]
103
+ description: "Generate 3+ competing hypotheses."
104
+ prompt: |
105
+ Based on the symptoms, generate at least 3 competing hypotheses:
106
+ For each hypothesis:
107
+ - Statement: what is the root cause?
108
+ - Prior probability: how likely (high/medium/low)?
109
+ - Confirming evidence: what would prove this?
110
+ - Refuting evidence: what would disprove this?
111
+ - Quick test: what's the fastest way to check?
112
+
113
+ Order by prior probability. Do NOT investigate yet.
114
+
115
+ - id: investigate
116
+ role: investigator
117
+ depends_on: [hypothesize]
118
+ description: "Gather evidence for/against each hypothesis."
119
+ prompt: |
120
+ For each hypothesis, gather evidence:
121
+ 1. Run the quick test suggested
122
+ 2. Check code paths, git blame, recent changes
123
+ 3. Record evidence FOR and AGAINST each hypothesis
124
+ 4. Grade evidence strength: strong / moderate / weak
125
+ 5. Try hardest to DISPROVE the leading hypothesis
126
+
127
+ After all evidence gathered, rank hypotheses by total evidence weight.
128
+
129
+ - id: synthesize
130
+ role: hypothesis_generator
131
+ depends_on: [investigate]
132
+ description: "Determine root cause and recommend fix."
133
+ prompt: |
134
+ Based on evidence:
135
+ 1. Which hypothesis has the strongest evidence?
136
+ 2. Which hypotheses were refuted?
137
+ 3. Are there any remaining unknowns?
138
+ 4. Root cause determination (with confidence level)
139
+ 5. Recommended fix approach
140
+ 6. What regression test would prevent recurrence?
@@ -53,4 +53,98 @@ genes:
53
53
  condition: "bugfix_without_test == false"
54
54
  action: block
55
55
 
56
+ competing_hypotheses:
57
+ description: Always consider multiple possible causes
58
+ codons:
59
+ - type: threshold
60
+ condition: "hypotheses_count >= 2"
61
+ action: escalate
62
+ - type: attract
63
+ target: consider_alternative_explanations
64
+ - type: repel
65
+ target: jump_to_first_theory
66
+
56
67
  contexts: {}
68
+
69
+ roles:
70
+ hypothesis_generator:
71
+ description: Generates competing debugging hypotheses. Read-only.
72
+ tool_permissions:
73
+ allow: [Read, Grep, Glob, Bash]
74
+ deny: [Edit, Write, NotebookEdit]
75
+ scope:
76
+ read: ["**/*"]
77
+ write: []
78
+ instructions:
79
+ - Read error messages, logs, stack traces
80
+ - Generate at least 2 competing hypotheses
81
+ - For each hypothesis state confirming and refuting evidence
82
+ - Rank by likelihood
83
+ - Do NOT suggest fixes
84
+
85
+ debugger:
86
+ description: Investigates hypotheses and applies fixes.
87
+ tool_permissions:
88
+ allow: [Read, Edit, Write, Grep, Glob, Bash]
89
+ scope:
90
+ read: ["**/*"]
91
+ write: ["src/**", "lib/**", "test/**"]
92
+ instructions:
93
+ - Test each hypothesis systematically
94
+ - Start with the most likely hypothesis
95
+ - Use git bisect, logging, and targeted tests
96
+ - When root cause found apply minimal fix
97
+ - Write regression test before fixing
98
+ - Run tests after fix
99
+
100
+ workflows:
101
+ debug-with-hypotheses:
102
+ name: Debug with Hypotheses
103
+ description: "Hypothesis-driven debugging: hypothesize, investigate, fix, verify"
104
+ steps:
105
+ - id: hypothesize
106
+ role: hypothesis_generator
107
+ description: "Generate competing hypotheses from symptoms."
108
+ prompt: |
109
+ Analyze the bug symptoms:
110
+ 1. Reproduce the issue
111
+ 2. Collect error messages, logs, stack traces
112
+ 3. Check recent git changes
113
+ 4. Generate at least 2 competing hypotheses
114
+ 5. For each: what evidence would confirm? What would refute?
115
+ 6. Rank by likelihood
116
+
117
+ - id: investigate
118
+ role: debugger
119
+ depends_on: [hypothesize]
120
+ description: "Test hypotheses and find root cause."
121
+ prompt: |
122
+ Test each hypothesis:
123
+ 1. Start with most likely
124
+ 2. Gather targeted evidence (add logging, run specific tests)
125
+ 3. If confirmed → proceed to fix
126
+ 4. If refuted → move to next hypothesis
127
+ 5. Record evidence for each hypothesis tested
128
+
129
+ - id: fix
130
+ role: debugger
131
+ depends_on: [investigate]
132
+ description: "Apply minimal fix and write regression test."
133
+ prompt: |
134
+ Fix the confirmed root cause:
135
+ 1. Write a regression test that reproduces the bug FIRST
136
+ 2. Apply the minimal fix
137
+ 3. Verify the regression test passes
138
+ 4. Run full test suite for regressions
139
+ 5. Commit: "fix: [description] — root cause: [what and why]"
140
+
141
+ - id: verify
142
+ role: hypothesis_generator
143
+ depends_on: [fix]
144
+ description: "Verify fix is correct and complete."
145
+ prompt: |
146
+ Verify the fix:
147
+ 1. Is the root cause actually addressed (not just symptoms)?
148
+ 2. Does the regression test cover the exact failure mode?
149
+ 3. Any related code paths that might have the same issue?
150
+ 4. Verdict: VERIFIED or INCOMPLETE
@@ -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.8",
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",