@cluesmith/codev 2.0.12 → 2.0.13

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.
@@ -0,0 +1,215 @@
1
+ # IMPLEMENT Phase Prompt
2
+
3
+ You are executing the **IMPLEMENT** phase of the SPIR protocol.
4
+
5
+ ## Your Goal
6
+
7
+ Write clean, well-structured code AND tests that implement the current plan phase.
8
+
9
+ ## Context
10
+
11
+ - **Project ID**: {{project_id}}
12
+ - **Project Title**: {{title}}
13
+ - **Current State**: {{current_state}}
14
+ - **Plan Phase**: {{plan_phase_id}} - {{plan_phase_title}}
15
+
16
+ ## ⚠️ SCOPE RESTRICTION — READ THIS FIRST
17
+
18
+ **You are implementing ONLY the current plan phase: {{plan_phase_id}} ({{plan_phase_title}}).**
19
+
20
+ - **DO NOT** implement other phases. Other phases will be handled in subsequent porch iterations.
21
+ - **DO NOT** read the full plan file and implement everything you see.
22
+ - The plan phase details are included below under "Current Plan Phase Details". That is your ONLY scope.
23
+ - If you need to reference the spec for requirements, read `codev/specs/{{project_id}}-*.md` but ONLY implement what the current phase requires.
24
+
25
+ ## What Happens After You Finish
26
+
27
+ When you signal `PHASE_COMPLETE`, porch will:
28
+ 1. Run 3-way consultation (Gemini, Codex, Claude) on your implementation
29
+ 2. Check that tests exist and pass
30
+ 3. If reviewers request changes, you'll be respawned with their feedback
31
+ 4. Once approved, porch commits and moves to the next plan phase
32
+
33
+ ## Spec Compliance (CRITICAL)
34
+
35
+ **The spec is the source of truth. Code that doesn't match the spec is wrong, even if it "works".**
36
+
37
+ ### Trust Hierarchy
38
+
39
+ ```
40
+ SPEC (source of truth)
41
+
42
+ PLAN (implementation guide derived from spec)
43
+
44
+ EXISTING CODE (NOT TRUSTED - must be validated against spec)
45
+ ```
46
+
47
+ **Never trust existing code over the spec.** Previous implementations may have drifted.
48
+
49
+ ### Pre-Implementation Sanity Check (PISC)
50
+
51
+ **Before writing ANY code:**
52
+
53
+ 1. ✅ "Have I read the spec in the last 30 minutes?"
54
+ 2. ✅ "If the spec has a 'Traps to Avoid' section, have I read it?"
55
+ 3. ✅ "Does my approach match the spec's Technical Implementation section?"
56
+ 4. ✅ "If the spec has code examples, am I following them?"
57
+ 5. ✅ "Does the existing code I'm building on actually match the spec?"
58
+
59
+ **If ANY answer is "no" or "unsure" → STOP and re-read the spec.**
60
+
61
+ ### Avoiding "Fixing Mode"
62
+
63
+ 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:
64
+ - Cargo-culting patterns that may be wrong
65
+ - Building on broken foundations
66
+ - Implementing something different from the spec
67
+
68
+ **When you catch yourself "fixing" code:**
69
+ 1. STOP
70
+ 2. Ask: "What does the spec say about this?"
71
+ 3. Re-read the spec's Traps to Avoid section
72
+ 4. Verify existing code matches the spec before building on it
73
+
74
+ ## Prerequisites
75
+
76
+ Before implementing, verify:
77
+ 1. Previous phase (if any) is committed to git
78
+ 2. You've read the plan phase you're implementing
79
+ 3. You understand the success criteria for this phase
80
+ 4. Dependencies from earlier phases are available
81
+
82
+ ## Process
83
+
84
+ ### 1. Review the Plan Phase
85
+
86
+ Read the current phase in the plan:
87
+ - What is the objective?
88
+ - What files need to be created/modified?
89
+ - What are the success criteria?
90
+ - What dependencies exist?
91
+
92
+ ### 2. Set Up
93
+
94
+ - Verify you're on the correct branch
95
+ - Check that previous phase is committed: `git log --oneline -5`
96
+ - Ensure build passes before starting: `npm run build` (or equivalent)
97
+
98
+ ### 3. Implement the Code
99
+
100
+ Write the code following these principles:
101
+
102
+ **Code Quality Standards**:
103
+ - Self-documenting code (clear names, obvious structure)
104
+ - No commented-out code
105
+ - No debug prints in final code
106
+ - Explicit error handling
107
+ - Follow project style guide
108
+
109
+ **Implementation Approach**:
110
+ - Work on one file at a time
111
+ - Make small, incremental changes
112
+ - Document complex logic with comments
113
+
114
+ ### 4. Write Tests
115
+
116
+ **Tests are required.** For each piece of functionality you implement:
117
+
118
+ - Write unit tests for core logic
119
+ - Write integration tests if the phase involves multiple components
120
+ - Test error cases and edge conditions
121
+ - Ensure tests are deterministic (no flaky tests)
122
+
123
+ **Test file locations** (follow project conventions):
124
+ - `tests/` or `__tests__/` directories
125
+ - `*.test.ts` or `*.spec.ts` naming
126
+
127
+ ### 5. Verify Everything Works
128
+
129
+ Run both build and tests:
130
+
131
+ ```bash
132
+ npm run build # Must pass
133
+ npm test # Must pass
134
+ ```
135
+
136
+ **Important**: Don't assume these commands exist. Check `package.json` first.
137
+
138
+ Fix any errors before signaling completion.
139
+
140
+ ### 6. Self-Review
141
+
142
+ Before signaling completion:
143
+ - Read through all code changes
144
+ - Read through all test changes
145
+ - Verify code matches the spec requirements
146
+ - Ensure no accidental debug code
147
+ - Check test coverage is adequate
148
+
149
+ ## Output
150
+
151
+ When complete, you should have:
152
+ - Modified/created source files as specified in the plan phase
153
+ - Tests covering the new functionality
154
+ - All build checks passing
155
+ - All tests passing
156
+
157
+ ## Signals
158
+
159
+ When implementation AND tests are complete and passing:
160
+
161
+ ```
162
+ <signal>PHASE_COMPLETE</signal>
163
+ ```
164
+
165
+ If you encounter a blocker:
166
+
167
+ ```
168
+ <signal>BLOCKED:reason goes here</signal>
169
+ ```
170
+
171
+ If you need spec/plan clarification:
172
+
173
+ ```
174
+ <signal type=AWAITING_INPUT>
175
+ Your specific questions here
176
+ </signal>
177
+ ```
178
+
179
+ ## Important Notes
180
+
181
+ 1. **Follow the plan** - Implement what's specified, not more
182
+ 2. **Don't over-engineer** - Simplest solution that works
183
+ 3. **Don't skip error handling** - But don't go overboard either
184
+ 4. **Keep changes focused** - Only touch files in this phase
185
+ 5. **Build AND tests must pass** - Don't signal complete until both pass
186
+ 6. **Write tests** - Every implementation phase needs tests
187
+
188
+ ## What NOT to Do
189
+
190
+ - Don't modify files outside this phase's scope
191
+ - Don't add features not in the spec
192
+ - Don't leave TODO comments for later (fix now or note as blocker)
193
+ - Don't skip writing tests
194
+ - Don't use `git add .` or `git add -A` when you commit (security risk)
195
+
196
+ ## Handling Problems
197
+
198
+ **If the plan is unclear**:
199
+ Signal `AWAITING_INPUT` with your specific question.
200
+
201
+ **If you discover the spec is wrong**:
202
+ Signal `BLOCKED` and explain the issue. The Architect may need to update the spec.
203
+
204
+ **If a dependency is missing**:
205
+ Signal `BLOCKED` with details about what's missing.
206
+
207
+ **If build or tests fail and you can't fix it**:
208
+ Signal `BLOCKED` with the error message.
209
+
210
+ **If you encounter pre-existing flaky tests** (tests that fail intermittently but are unrelated to your changes):
211
+ 1. **DO NOT** edit `status.yaml` to bypass checks
212
+ 2. **DO NOT** skip porch checks or use workarounds to avoid the failure
213
+ 3. **DO** mark the flaky test as skipped with a clear annotation (e.g., `it.skip('...') // FLAKY: intermittent timeout, skipped pending investigation`)
214
+ 4. **DO** document each skipped flaky test in your review under a `## Flaky Tests` section so the team can follow up
215
+ 5. Commit the skip and continue with your work
@@ -0,0 +1,150 @@
1
+ # PLAN Phase Prompt
2
+
3
+ You are executing the **PLAN** phase of the SPIR protocol.
4
+
5
+ ## Your Goal
6
+
7
+ Transform the approved specification into an executable implementation plan with clear phases.
8
+
9
+ ## Context
10
+
11
+ - **Project ID**: {{project_id}}
12
+ - **Project Title**: {{title}}
13
+ - **Current State**: {{current_state}}
14
+ - **Spec File**: `codev/specs/{{artifact_name}}.md`
15
+ - **Plan File**: `codev/plans/{{artifact_name}}.md`
16
+
17
+ ## Prerequisites
18
+
19
+ Before planning, verify:
20
+ 1. The specification exists and has been approved
21
+ 2. You've read and understood the entire spec
22
+ 3. Success criteria are clear and measurable
23
+
24
+ ## Process
25
+
26
+ ### 1. Analyze the Specification
27
+
28
+ Read the spec thoroughly. Identify:
29
+ - All functional requirements
30
+ - Non-functional requirements
31
+ - Dependencies and constraints
32
+ - Success criteria to validate against
33
+
34
+ ### 2. Identify Implementation Phases
35
+
36
+ Break the work into logical phases. Each phase should be:
37
+ - **Self-contained** - A complete unit of functionality
38
+ - **Independently testable** - Can be verified on its own
39
+ - **Valuable** - Delivers observable progress
40
+ - **Committable** - Can be a single atomic commit
41
+
42
+ Good phase examples:
43
+ - "Database Schema" - Creates all tables/migrations
44
+ - "Core API Endpoints" - Implements main REST routes
45
+ - "Authentication Flow" - Handles login/logout/session
46
+
47
+ Bad phase examples:
48
+ - "Setup" - Too vague
49
+ - "Part 1" - Not descriptive
50
+ - "Everything" - Not broken down
51
+
52
+ ### 3. Define Each Phase
53
+
54
+ For each phase, document:
55
+ - **Objective** - Single clear goal
56
+ - **Files to modify/create** - Specific paths
57
+ - **Dependencies** - Which phases must complete first
58
+ - **Success criteria** - How to know it's done
59
+ - **Test approach** - What tests will verify it
60
+
61
+ ### 4. Order Phases by Dependencies
62
+
63
+ Arrange phases so dependencies are satisfied:
64
+ ```
65
+ Phase 1: Database Schema (no dependencies)
66
+ Phase 2: Data Models (depends on Phase 1)
67
+ Phase 3: API Endpoints (depends on Phase 2)
68
+ Phase 4: Frontend Integration (depends on Phase 3)
69
+ ```
70
+
71
+ ### 5. Finalize
72
+
73
+ After completing the plan draft, signal completion. Porch will run 3-way consultation (Gemini, Codex, Claude) automatically via the verify step. If reviewers request changes, you'll be respawned with their feedback.
74
+
75
+ ## Output
76
+
77
+ Create the plan file at `codev/plans/{{artifact_name}}.md`.
78
+
79
+ Use the plan template from `codev/protocols/spir/templates/plan.md` if available.
80
+
81
+ ### Plan Structure
82
+
83
+ ```markdown
84
+ # Implementation Plan: {{title}}
85
+
86
+ ## Overview
87
+ Brief summary of what will be implemented.
88
+
89
+ ## Phases
90
+
91
+ ### Phase 1: [Name]
92
+ - **Objective**: [Single clear goal]
93
+ - **Files**: [List of files to create/modify]
94
+ - **Dependencies**: None
95
+ - **Success Criteria**: [How to verify completion]
96
+ - **Tests**: [What tests will be written]
97
+
98
+ ### Phase 2: [Name]
99
+ - **Objective**: [Single clear goal]
100
+ - **Files**: [List of files]
101
+ - **Dependencies**: Phase 1
102
+ - **Success Criteria**: [Verification method]
103
+ - **Tests**: [Test approach]
104
+
105
+ [Continue for all phases...]
106
+
107
+ ## Risk Assessment
108
+ - [Risk 1]: [Mitigation]
109
+ - [Risk 2]: [Mitigation]
110
+
111
+ ```
112
+
113
+ ## Signals
114
+
115
+ Emit appropriate signals based on your progress:
116
+
117
+ - After completing the plan draft:
118
+ ```
119
+ <signal>PLAN_DRAFTED</signal>
120
+ ```
121
+
122
+ ## Commit Cadence
123
+
124
+ Make commits at these milestones:
125
+ 1. `[Spec {{project_id}}] Initial implementation plan`
126
+ 2. `[Spec {{project_id}}] Plan with multi-agent review`
127
+ 3. `[Spec {{project_id}}] Plan with user feedback`
128
+ 4. `[Spec {{project_id}}] Final approved plan`
129
+
130
+ **CRITICAL**: Never use `git add .` or `git add -A`. Always stage specific files:
131
+ ```bash
132
+ git add codev/plans/{{artifact_name}}.md
133
+ ```
134
+
135
+ ## Important Notes
136
+
137
+ 1. **No time estimates** - Don't include hours/days/weeks
138
+ 3. **Be specific about files** - Exact paths, not "the config file"
139
+ 4. **Keep phases small** - 1-3 files per phase is ideal
140
+ 5. **Document dependencies clearly** - Prevents blocked work
141
+
142
+ ## What NOT to Do
143
+
144
+ - Don't run `consult` commands yourself (porch handles consultations)
145
+ - Don't write code (that's for Implement phase)
146
+ - Don't estimate time (meaningless in AI development)
147
+ - Don't create phases that can't be independently tested
148
+ - Don't skip dependency analysis
149
+ - Don't make phases too large (if >5 files, split it)
150
+ - Don't use `git add .` or `git add -A` (security risk)
@@ -0,0 +1,259 @@
1
+ # REVIEW Phase Prompt
2
+
3
+ You are executing the **REVIEW** phase of the SPIR protocol.
4
+
5
+ ## Your Goal
6
+
7
+ Perform a comprehensive review, document lessons learned, and prepare for PR submission.
8
+
9
+ ## Context
10
+
11
+ - **Project ID**: {{project_id}}
12
+ - **Project Title**: {{title}}
13
+ - **Current State**: {{current_state}}
14
+ - **Spec File**: `codev/specs/{{artifact_name}}.md`
15
+ - **Plan File**: `codev/plans/{{artifact_name}}.md`
16
+ - **Review File**: `codev/reviews/{{artifact_name}}.md`
17
+
18
+ ## Prerequisites
19
+
20
+ Before review, verify:
21
+ 1. All implementation phases are committed
22
+ 2. All tests are passing
23
+ 3. Build is passing
24
+ 4. Spec compliance verified for all phases
25
+
26
+ Verify commits: `git log --oneline | grep "[Spec {{project_id}}]"`
27
+
28
+ ## Process
29
+
30
+ ### 1. Comprehensive Review
31
+
32
+ Review the entire implementation:
33
+
34
+ **Code Quality**:
35
+ - Is the code readable and maintainable?
36
+ - Are there any code smells?
37
+ - Is error handling consistent?
38
+ - Are there any security concerns?
39
+
40
+ **Architecture**:
41
+ - Does the implementation fit well with existing code?
42
+ - Are there any architectural concerns?
43
+ - Is the design scalable if needed?
44
+
45
+ **Documentation**:
46
+ - Is code adequately commented where needed?
47
+ - Are public APIs documented?
48
+ - Is README updated if needed?
49
+
50
+ ### 2. Spec Comparison
51
+
52
+ Compare final implementation to original specification:
53
+
54
+ - What was delivered vs what was specified?
55
+ - Any deviations? Document why.
56
+ - All success criteria met?
57
+
58
+ ### 3. Create Review Document
59
+
60
+ Create `codev/reviews/{{artifact_name}}.md`:
61
+
62
+ ```markdown
63
+ # Review: {{title}}
64
+
65
+ ## Summary
66
+ Brief description of what was implemented.
67
+
68
+ ## Spec Compliance
69
+ - [x] Requirement 1: Implemented as specified
70
+ - [x] Requirement 2: Implemented with deviation (see below)
71
+ - [x] Requirement 3: Implemented as specified
72
+
73
+ ## Deviations from Plan
74
+ - **Phase X**: [What changed and why]
75
+
76
+ ## Lessons Learned
77
+
78
+ ### What Went Well
79
+ - [Positive observation 1]
80
+ - [Positive observation 2]
81
+
82
+ ### Challenges Encountered
83
+ - [Challenge 1]: [How it was resolved]
84
+ - [Challenge 2]: [How it was resolved]
85
+
86
+ ### What Would Be Done Differently
87
+ - [Insight 1]
88
+ - [Insight 2]
89
+
90
+ ### Methodology Improvements
91
+ - [Suggested improvement to SPIR protocol]
92
+ - [Suggested improvement to tooling]
93
+
94
+ ## Technical Debt
95
+ - [Any shortcuts taken that should be addressed later]
96
+
97
+ ## Consultation Feedback
98
+
99
+ [See instructions below]
100
+
101
+ ## Flaky Tests
102
+ - [Any pre-existing tests that were skipped as flaky during this project]
103
+ - [Include test name, file path, and observed failure mode]
104
+ - [If none: "No flaky tests encountered"]
105
+
106
+ ## Follow-up Items
107
+ - [Any items identified for future work]
108
+ ```
109
+
110
+ ### 3b. Include Consultation Feedback
111
+
112
+ **IMPORTANT**: The review document MUST include a `## Consultation Feedback` section that summarizes all consultation concerns raised during every phase of the project and how the builder responded.
113
+
114
+ Read the consultation output files from the project directory (`codev/projects/{project-id}-*/`). For each phase that had consultation, create a subsection organized by phase, round, and model:
115
+
116
+ ```markdown
117
+ ## Consultation Feedback
118
+
119
+ ### Specify Phase (Round 1)
120
+
121
+ #### Gemini
122
+ - **Concern**: [Summary of the concern]
123
+ - **Addressed**: [What was changed to resolve it]
124
+
125
+ #### Codex
126
+ - **Concern**: [Summary]
127
+ - **Rebutted**: [Why the current approach is correct]
128
+
129
+ #### Claude
130
+ - No concerns raised (APPROVE)
131
+
132
+ ### Plan Phase (Round 1)
133
+ ...
134
+ ```
135
+
136
+ **Response types** — each concern gets exactly one:
137
+ - **Addressed**: Builder made a change to resolve the concern
138
+ - **Rebutted**: Builder explains why the concern doesn't apply
139
+ - **N/A**: Concern is out of scope, already handled elsewhere, or moot
140
+
141
+ **Edge cases**:
142
+ - If all reviewers approved with no concerns: "No concerns raised — all consultations approved"
143
+ - For COMMENT verdicts: include their feedback (non-blocking but useful context)
144
+ - For CONSULT_ERROR (model failure): note "Consultation failed for [model]"
145
+ - If a phase had multiple rounds, give each round its own subsection
146
+
147
+ ### 4. Update Architecture and Lessons Learned Documentation
148
+
149
+ **MANDATORY**: The review document MUST include `## Architecture Updates` and `## Lessons Learned Updates` sections. Porch will block advancement if these are missing.
150
+
151
+ **Architecture Updates** (`codev/resources/arch.md`):
152
+ 1. Read the current `codev/resources/arch.md`
153
+ 2. Determine if this project introduced architectural changes worth documenting (new subsystems, data flows, design decisions, invariants, file locations)
154
+ 3. If yes: make the updates to arch.md and describe what you changed in the `## Architecture Updates` section of the review
155
+ 4. If no: write "No architecture updates needed" in the section with a brief explanation (e.g., "This was a template-only change with no new subsystems or data flows")
156
+
157
+ **Lessons Learned Updates** (`codev/resources/lessons-learned.md`):
158
+ 1. Read the current `codev/resources/lessons-learned.md`
159
+ 2. Determine if this project produced generalizable lessons (patterns, anti-patterns, debugging insights, process improvements)
160
+ 3. If yes: add entries to lessons-learned.md and describe what you added in the `## Lessons Learned Updates` section of the review
161
+ 4. If no: write "No lessons learned updates needed" in the section with a brief explanation (e.g., "Straightforward implementation with no novel insights beyond existing entries")
162
+
163
+ ### 4b. Update Other Documentation
164
+
165
+ If needed, also update:
166
+ - README.md (new features, changed behavior)
167
+ - API documentation
168
+
169
+ ### 5. Final Verification
170
+
171
+ Before PR:
172
+ - [ ] All tests pass (use project-specific test command)
173
+ - [ ] Build passes (use project-specific build command)
174
+ - [ ] Lint passes (if configured)
175
+ - [ ] No uncommitted changes: `git status`
176
+ - [ ] Review document complete
177
+
178
+ ### 6. Create Pull Request
179
+
180
+ **IMPORTANT: Create the PR BEFORE signaling completion.** The PR must exist so that
181
+ porch consultation reviews the actual PR, and the architect can review a real PR
182
+ when the pr gate fires.
183
+
184
+ ```bash
185
+ gh pr create --title "[Spec {{project_id}}] {{title}}" --body "$(cat <<'EOF'
186
+ ## Summary
187
+ [Brief description of the implementation]
188
+
189
+ ## Changes
190
+ - [Change 1]
191
+ - [Change 2]
192
+
193
+ ## Testing
194
+ - All unit tests passing
195
+ - Integration tests added for [X]
196
+ - Manual testing completed for [Y]
197
+
198
+ ## Spec
199
+ Link: codev/specs/{{artifact_name}}.md
200
+
201
+ ## Review
202
+ Link: codev/reviews/{{artifact_name}}.md
203
+ EOF
204
+ )"
205
+ ```
206
+
207
+ ### 7. Signal Completion
208
+
209
+ After the PR is created, signal completion. Porch will run 3-way consultation
210
+ (Gemini, Codex, Claude) automatically via the verify step. If reviewers request
211
+ changes, you'll be respawned with their feedback.
212
+
213
+ ## Output
214
+
215
+ - Review document at `codev/reviews/{{artifact_name}}.md`
216
+ - Updated documentation (if needed)
217
+ - Pull request created and ready for review
218
+
219
+ ## Signals
220
+
221
+ - After review document is complete:
222
+ ```
223
+ <signal>REVIEW_COMPLETE</signal>
224
+ ```
225
+
226
+ - After PR is created — signal completion so porch runs consultation:
227
+ ```
228
+ <signal>PR_READY</signal>
229
+ ```
230
+
231
+ ## Important Notes
232
+
233
+ 1. **Be honest in lessons learned** - Future you will thank present you
234
+ 3. **Document deviations** - They're not failures, they're learnings
235
+ 4. **Update methodology** - If you found a better way, document it
236
+ 5. **Don't skip the checklist** - It catches last-minute issues
237
+ 6. **Clean PR description** - Makes review easier
238
+
239
+ ## What NOT to Do
240
+
241
+ - Don't run `consult` commands yourself (porch handles consultations)
242
+ - Don't skip lessons learned ("nothing to report")
243
+ - Don't merge your own PR (Architect handles integration)
244
+ - Don't leave uncommitted changes
245
+ - Don't forget to update documentation
246
+ - Don't rush this phase - it's valuable for learning
247
+ - Don't use `git add .` or `git add -A` (security risk)
248
+
249
+ ## Review Prompts for Reflection
250
+
251
+ Ask yourself:
252
+ - What surprised me during implementation?
253
+ - Where did I spend the most time? Was it avoidable?
254
+ - What would have helped me go faster?
255
+ - Did the spec adequately describe what was needed?
256
+ - Did the plan phases make sense in hindsight?
257
+ - What tests caught issues? What tests were unnecessary?
258
+
259
+ Capture these reflections in the lessons learned section.