@cluesmith/codev 2.0.0-rc.10 → 2.0.0-rc.12

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 (31) hide show
  1. package/dist/commands/consult/index.d.ts.map +1 -1
  2. package/dist/commands/consult/index.js +81 -1
  3. package/dist/commands/consult/index.js.map +1 -1
  4. package/dist/commands/porch/claude.d.ts.map +1 -1
  5. package/dist/commands/porch/claude.js +2 -1
  6. package/dist/commands/porch/claude.js.map +1 -1
  7. package/dist/commands/porch/prompts.d.ts.map +1 -1
  8. package/dist/commands/porch/prompts.js +13 -2
  9. package/dist/commands/porch/prompts.js.map +1 -1
  10. package/dist/commands/porch/protocol.d.ts +3 -1
  11. package/dist/commands/porch/protocol.d.ts.map +1 -1
  12. package/dist/commands/porch/protocol.js +6 -4
  13. package/dist/commands/porch/protocol.js.map +1 -1
  14. package/dist/commands/porch/run.d.ts.map +1 -1
  15. package/dist/commands/porch/run.js +176 -9
  16. package/dist/commands/porch/run.js.map +1 -1
  17. package/dist/commands/porch/signals.d.ts +3 -0
  18. package/dist/commands/porch/signals.d.ts.map +1 -1
  19. package/dist/commands/porch/signals.js +5 -0
  20. package/dist/commands/porch/signals.js.map +1 -1
  21. package/dist/commands/porch/types.d.ts +5 -1
  22. package/dist/commands/porch/types.d.ts.map +1 -1
  23. package/package.json +3 -1
  24. package/skeleton/protocols/bugfix/protocol.json +1 -1
  25. package/skeleton/protocols/spider/prompts/implement.md +99 -47
  26. package/skeleton/protocols/spider/protocol.json +10 -8
  27. package/skeleton/protocols/spider/protocol.md +26 -16
  28. package/skeleton/protocols/tick/protocol.json +1 -1
  29. package/skeleton/roles/builder.md +131 -332
  30. package/skeleton/protocols/spider/prompts/defend.md +0 -215
  31. package/skeleton/protocols/spider/prompts/evaluate.md +0 -241
@@ -4,7 +4,7 @@ You are executing the **IMPLEMENT** phase of the SPIDER protocol.
4
4
 
5
5
  ## Your Goal
6
6
 
7
- Write clean, well-structured code that implements the current plan phase.
7
+ Write clean, well-structured code AND tests that implement the current plan phase.
8
8
 
9
9
  ## Context
10
10
 
@@ -15,14 +15,54 @@ Write clean, well-structured code that implements the current plan phase.
15
15
  - **Spec File**: `codev/specs/{{project_id}}-{{title}}.md`
16
16
  - **Plan File**: `codev/plans/{{project_id}}-{{title}}.md`
17
17
 
18
- ## Consultation Context
18
+ ## What Happens After You Finish
19
19
 
20
- **Implementation does NOT require consultation checkpoints** - that happens after Defend.
20
+ When you signal `PHASE_COMPLETE`, porch will:
21
+ 1. Run 3-way consultation (Gemini, Codex, Claude) on your implementation
22
+ 2. Check that tests exist and pass
23
+ 3. If reviewers request changes, you'll be respawned with their feedback
24
+ 4. Once approved, porch commits and moves to the next plan phase
21
25
 
22
- However, you should be aware:
23
- - Spec and Plan have already been reviewed by GPT-5 Codex and Gemini Pro
24
- - After you complete Implement + Defend, your work will be reviewed
25
- - Implementation must strictly follow the approved spec and plan
26
+ ## Spec Compliance (CRITICAL)
27
+
28
+ **The spec is the source of truth. Code that doesn't match the spec is wrong, even if it "works".**
29
+
30
+ ### Trust Hierarchy
31
+
32
+ ```
33
+ SPEC (source of truth)
34
+
35
+ PLAN (implementation guide derived from spec)
36
+
37
+ EXISTING CODE (NOT TRUSTED - must be validated against spec)
38
+ ```
39
+
40
+ **Never trust existing code over the spec.** Previous implementations may have drifted.
41
+
42
+ ### Pre-Implementation Sanity Check (PISC)
43
+
44
+ **Before writing ANY code:**
45
+
46
+ 1. ✅ "Have I read the spec in the last 30 minutes?"
47
+ 2. ✅ "If the spec has a 'Traps to Avoid' section, have I read it?"
48
+ 3. ✅ "Does my approach match the spec's Technical Implementation section?"
49
+ 4. ✅ "If the spec has code examples, am I following them?"
50
+ 5. ✅ "Does the existing code I'm building on actually match the spec?"
51
+
52
+ **If ANY answer is "no" or "unsure" → STOP and re-read the spec.**
53
+
54
+ ### Avoiding "Fixing Mode"
55
+
56
+ A dangerous pattern: You start looking at symptoms in code, making incremental fixes, copying existing patterns - without going back to the spec. This leads to:
57
+ - Cargo-culting patterns that may be wrong
58
+ - Building on broken foundations
59
+ - Implementing something different from the spec
60
+
61
+ **When you catch yourself "fixing" code:**
62
+ 1. STOP
63
+ 2. Ask: "What does the spec say about this?"
64
+ 3. Re-read the spec's Traps to Avoid section
65
+ 4. Verify existing code matches the spec before building on it
26
66
 
27
67
  ## Prerequisites
28
68
 
@@ -48,7 +88,7 @@ Read the current phase in the plan:
48
88
  - Check that previous phase is committed: `git log --oneline -5`
49
89
  - Ensure build passes before starting: `npm run build` (or equivalent)
50
90
 
51
- ### 3. Implement
91
+ ### 3. Implement the Code
52
92
 
53
93
  Write the code following these principles:
54
94
 
@@ -62,60 +102,72 @@ Write the code following these principles:
62
102
  **Implementation Approach**:
63
103
  - Work on one file at a time
64
104
  - Make small, incremental changes
65
- - Test as you go (manual verification is fine here)
66
105
  - Document complex logic with comments
67
106
 
68
- ### 4. Self-Review
107
+ ### 4. Write Tests
69
108
 
70
- Before signaling completion:
71
- - Read through all changes
72
- - Check for obvious bugs
73
- - Verify code matches the spec requirements
74
- - Ensure no accidental debug code
109
+ **Tests are required.** For each piece of functionality you implement:
75
110
 
76
- ### 5. Build Verification
111
+ - Write unit tests for core logic
112
+ - Write integration tests if the phase involves multiple components
113
+ - Test error cases and edge conditions
114
+ - Ensure tests are deterministic (no flaky tests)
77
115
 
78
- Run build checks using **project-specific commands**:
116
+ **Test file locations** (follow project conventions):
117
+ - `tests/` or `__tests__/` directories
118
+ - `*.test.ts` or `*.spec.ts` naming
119
+
120
+ ### 5. Verify Everything Works
121
+
122
+ Run both build and tests:
79
123
 
80
124
  ```bash
81
- # Check package.json scripts or Makefile for actual commands
82
- # Common patterns:
83
- npm run build # Node.js/TypeScript projects
84
- npm run typecheck # TypeScript type checking
85
- npm run lint # Linting (ESLint, etc.)
86
- cargo build # Rust projects
87
- go build ./... # Go projects
88
- make build # Projects using Makefiles
125
+ npm run build # Must pass
126
+ npm test # Must pass
89
127
  ```
90
128
 
91
- **Important**: Don't assume `npm run build` exists. Check `package.json` or equivalent first.
129
+ **Important**: Don't assume these commands exist. Check `package.json` first.
130
+
131
+ Fix any errors before signaling completion.
132
+
133
+ ### 6. Self-Review
92
134
 
93
- Fix any errors before proceeding.
135
+ Before signaling completion:
136
+ - Read through all code changes
137
+ - Read through all test changes
138
+ - Verify code matches the spec requirements
139
+ - Ensure no accidental debug code
140
+ - Check test coverage is adequate
94
141
 
95
142
  ## Output
96
143
 
144
+ When complete, you should have:
97
145
  - Modified/created source files as specified in the plan phase
146
+ - Tests covering the new functionality
98
147
  - All build checks passing
99
- - Code ready for the Defend (testing) phase
148
+ - All tests passing
100
149
 
101
150
  ## Signals
102
151
 
103
- Emit appropriate signals based on your progress:
152
+ When implementation AND tests are complete and passing:
104
153
 
105
- - After implementation is complete and builds pass:
106
- ```
107
- <signal>PHASE_IMPLEMENTED</signal>
108
- ```
154
+ ```
155
+ <signal>PHASE_COMPLETE</signal>
156
+ ```
157
+
158
+ If you encounter a blocker:
109
159
 
110
- - If you encounter a blocker:
111
- ```
112
- <signal>BLOCKED:reason goes here</signal>
113
- ```
160
+ ```
161
+ <signal>BLOCKED:reason goes here</signal>
162
+ ```
114
163
 
115
- - If you need spec/plan clarification:
116
- ```
117
- <signal>NEEDS_CLARIFICATION:specific question</signal>
118
- ```
164
+ If you need spec/plan clarification:
165
+
166
+ ```
167
+ <signal type=AWAITING_INPUT>
168
+ Your specific questions here
169
+ </signal>
170
+ ```
119
171
 
120
172
  ## Important Notes
121
173
 
@@ -123,21 +175,21 @@ Emit appropriate signals based on your progress:
123
175
  2. **Don't over-engineer** - Simplest solution that works
124
176
  3. **Don't skip error handling** - But don't go overboard either
125
177
  4. **Keep changes focused** - Only touch files in this phase
126
- 5. **Build must pass** - Don't proceed if build fails
178
+ 5. **Build AND tests must pass** - Don't signal complete until both pass
179
+ 6. **Write tests** - Every implementation phase needs tests
127
180
 
128
181
  ## What NOT to Do
129
182
 
130
- - Don't write tests yet (that's Defend phase)
131
183
  - Don't modify files outside this phase's scope
132
184
  - Don't add features not in the spec
133
185
  - Don't leave TODO comments for later (fix now or note as blocker)
134
- - Don't commit yet (that happens after Defend + Evaluate)
135
- - Don't use `git add .` or `git add -A` when you do commit (security risk)
186
+ - Don't skip writing tests
187
+ - Don't use `git add .` or `git add -A` when you commit (security risk)
136
188
 
137
189
  ## Handling Problems
138
190
 
139
191
  **If the plan is unclear**:
140
- Signal `NEEDS_CLARIFICATION` with your specific question.
192
+ Signal `AWAITING_INPUT` with your specific question.
141
193
 
142
194
  **If you discover the spec is wrong**:
143
195
  Signal `BLOCKED` and explain the issue. The Architect may need to update the spec.
@@ -145,5 +197,5 @@ Signal `BLOCKED` and explain the issue. The Architect may need to update the spe
145
197
  **If a dependency is missing**:
146
198
  Signal `BLOCKED` with details about what's missing.
147
199
 
148
- **If build fails and you can't fix it**:
200
+ **If build or tests fail and you can't fix it**:
149
201
  Signal `BLOCKED` with the error message.
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "$schema": "../../protocol-schema.json",
3
3
  "name": "spider",
4
- "version": "2.0.0",
5
- "description": "Specification-driven development with build-verify cycles",
4
+ "alias": "spir",
5
+ "version": "2.1.0",
6
+ "description": "SPIR: Specify → Plan → Implement → Review with build-verify cycles",
6
7
  "phases": [
7
8
  {
8
9
  "id": "specify",
@@ -18,7 +19,7 @@
18
19
  "models": ["gemini", "codex", "claude"],
19
20
  "parallel": true
20
21
  },
21
- "max_iterations": 3,
22
+ "max_iterations": 7,
22
23
  "on_complete": {
23
24
  "commit": true,
24
25
  "push": true
@@ -40,14 +41,15 @@
40
41
  "models": ["gemini", "codex", "claude"],
41
42
  "parallel": true
42
43
  },
43
- "max_iterations": 3,
44
+ "max_iterations": 7,
44
45
  "on_complete": {
45
46
  "commit": true,
46
47
  "push": true
47
48
  },
48
49
  "checks": {
49
50
  "plan_exists": "test -f codev/plans/${PROJECT_ID}-*.md",
50
- "has_phases_json": "grep -q '\"phases\":' codev/plans/${PROJECT_ID}-*.md"
51
+ "has_phases_json": "grep -q '\"phases\":' codev/plans/${PROJECT_ID}-*.md",
52
+ "min_two_phases": "grep -o '\"id\": *\"[^\"]*\"' codev/plans/${PROJECT_ID}-*.md | wc -l | awk '$1 >= 2 {exit 0} {exit 1}'"
51
53
  },
52
54
  "gate": "plan-approval",
53
55
  "next": "implement"
@@ -66,7 +68,7 @@
66
68
  "models": ["gemini", "codex", "claude"],
67
69
  "parallel": true
68
70
  },
69
- "max_iterations": 3,
71
+ "max_iterations": 7,
70
72
  "on_complete": {
71
73
  "commit": true,
72
74
  "push": true
@@ -102,7 +104,7 @@
102
104
  "models": ["gemini", "codex", "claude"],
103
105
  "parallel": true
104
106
  },
105
- "max_iterations": 3,
107
+ "max_iterations": 7,
106
108
  "on_complete": {
107
109
  "commit": true,
108
110
  "push": true
@@ -127,7 +129,7 @@
127
129
  "commit_has_code": "git log -1 --name-only --pretty=format: | grep -qE '\\.(ts|tsx|js|jsx|py|go|rs)$'"
128
130
  },
129
131
  "defaults": {
130
- "max_iterations": 3,
132
+ "max_iterations": 7,
131
133
  "verify": {
132
134
  "models": ["gemini", "codex", "claude"],
133
135
  "parallel": true
@@ -1,4 +1,10 @@
1
- # SPIDER Protocol
1
+ # SPIR Protocol (formerly SPIDER)
2
+
3
+ > **Also known as**: SPIDER (legacy name)
4
+ >
5
+ > **SPIR** = **S**pecify → **P**lan → **I**mplement → **R**eview
6
+ >
7
+ > Each phase has one build-verify cycle with 3-way consultation.
2
8
 
3
9
  > **Quick Reference**: See `codev/resources/workflow-reference.md` for stage diagrams and common commands.
4
10
 
@@ -40,13 +46,21 @@ The user can specify different agents by saying: "use SPIDER with consultation f
40
46
  - **Review**: After review document
41
47
 
42
48
  ## Overview
43
- SPIDER is a structured development protocol that emphasizes specification-driven development with iterative implementation and continuous review. It builds upon the DAPPER methodology with a focus on context-first development and multi-agent collaboration.
49
+ SPIR is a structured development protocol that emphasizes specification-driven development with iterative implementation and continuous review. It builds upon the DAPPER methodology with a focus on context-first development and multi-agent collaboration.
50
+
51
+ **The SPIR Model**:
52
+ - **S - Specify**: Write specification with 3-way review → Gate: `spec-approval`
53
+ - **P - Plan**: Write implementation plan with 3-way review → Gate: `plan-approval`
54
+ - **I - Implement**: Execute each plan phase with build-verify cycle (one cycle per phase)
55
+ - **R - Review**: Final review and PR preparation with 3-way review
56
+
57
+ Each phase follows a build-verify loop: build the artifact, then verify with 3-way consultation (Gemini, Codex, Claude).
44
58
 
45
59
  **Core Principle**: Each feature is tracked through exactly THREE documents - a specification, a plan, and a review with lessons learned - all sharing the same filename and sequential identifier.
46
60
 
47
- ## When to Use SPIDER
61
+ ## When to Use SPIR
48
62
 
49
- ### Use SPIDER for:
63
+ ### Use SPIR for:
50
64
  - New feature development
51
65
  - Architecture changes
52
66
  - Complex refactoring
@@ -54,7 +68,7 @@ SPIDER is a structured development protocol that emphasizes specification-driven
54
68
  - API design and implementation
55
69
  - Performance optimization initiatives
56
70
 
57
- ### Skip SPIDER for:
71
+ ### Skip SPIR for:
58
72
  - Simple bug fixes (< 10 lines)
59
73
  - Documentation updates
60
74
  - Configuration changes
@@ -224,25 +238,21 @@ Each phase should be:
224
238
  **Template**: `templates/plan.md`
225
239
  **Review Required**: Yes - Technical lead approval AFTER consultations
226
240
 
227
- ### (IDE) - Implementation Loop
228
-
229
- Execute for each phase in the plan. This is a strict cycle that must be completed in order.
241
+ ### I - Implement (Per Plan Phase)
230
242
 
231
- **⚠️ MANDATORY**: The I-D-E cycle MUST be completed for EACH PHASE, not just at the end of all phases. Skipping D (Defend) or E (Evaluate) for any phase is a PROTOCOL VIOLATION.
243
+ Execute for each phase in the plan. Each phase follows a build-verify cycle.
232
244
 
233
245
  **CRITICAL PRECONDITION**: Before starting any phase, verify the previous phase was committed to git. No phase can begin without the prior phase's commit.
234
246
 
235
- **Phase Completion Process**:
236
- 1. **Implement** - Build the code for this phase
237
- 2. **Defend** - Write comprehensive tests that guard functionality
238
- 3. **Evaluate** - Assess and discuss with user
247
+ **Build-Verify Cycle Per Phase**:
248
+ 1. **Build** - Implement code and tests for this phase
249
+ 2. **Verify** - 3-way consultation (Gemini, Codex, Claude)
250
+ 3. **Iterate** - Address feedback until verification passes
239
251
  4. **Commit** - Single atomic commit for the phase (MANDATORY before next phase)
240
252
  5. **Proceed** - Move to next phase only after commit
241
253
 
242
254
  **Handling Failures**:
243
- - If **Defend** phase reveals gaps → return to **Implement** to fix
244
- - If **Evaluation** reveals unmet criteria → return to **Implement**
245
- - If user requests changes → return to **Implement**
255
+ - If verification reveals gaps → iterate and fix
246
256
  - If fundamental plan flaws found → mark phase as `blocked` and revise plan
247
257
 
248
258
  **Commit Requirements**:
@@ -2,7 +2,7 @@
2
2
  "$schema": "../../protocol-schema.json",
3
3
  "name": "tick",
4
4
  "version": "1.0.0",
5
- "description": "Amendment workflow for existing SPIDER specifications",
5
+ "description": "Amendment workflow for existing SPIR specifications",
6
6
  "phases": [
7
7
  {
8
8
  "id": "identify",