@cluesmith/codev 1.1.1 → 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.
@@ -6,19 +6,19 @@ MAINTAIN is a periodic maintenance protocol for keeping codebases healthy. Unlik
6
6
 
7
7
  **Core Principle**: Regular maintenance prevents technical debt accumulation.
8
8
 
9
+ **Key Documents**: MAINTAIN is responsible for keeping these living documents accurate and consistent:
10
+ - `codev/resources/arch.md` - Architecture documentation (how the system works)
11
+ - `codev/resources/lessons-learned.md` - Extracted wisdom from reviews
12
+
13
+ Any builder can update these files during development, but MAINTAIN ensures they stay consistent with the actual codebase.
14
+
9
15
  ## When to Use MAINTAIN
10
16
 
11
- ### Triggers
17
+ - When the user/architect requests it
12
18
  - Before a release (clean slate for shipping)
13
19
  - Quarterly maintenance window
14
20
  - After completing a major feature
15
21
  - When the codebase feels "crusty"
16
- - Before major refactoring efforts
17
-
18
- ### Skip MAINTAIN for
19
- - Active development branches with pending PRs
20
- - Emergency production issues
21
- - When tests are failing (fix tests first)
22
22
 
23
23
  ## Execution Model
24
24
 
@@ -39,9 +39,30 @@ Architect reviews → Builder merges
39
39
  ## Prerequisites
40
40
 
41
41
  Before starting MAINTAIN:
42
- - [ ] Git working directory is clean
43
- - [ ] All tests are passing
44
- - [ ] No pending merges or PRs in flight
42
+ 1. Check `codev/maintain/` for last maintenance run
43
+ 2. Note the base commit from that run
44
+ 3. Focus on changes since that commit: `git log --oneline <base-commit>..HEAD`
45
+
46
+ ---
47
+
48
+ ## Maintenance Files
49
+
50
+ Each maintenance run creates a numbered file in `codev/maintain/`:
51
+
52
+ ```
53
+ codev/maintain/
54
+ ├── 0001.md
55
+ ├── 0002.md
56
+ └── ...
57
+ ```
58
+
59
+ **Template**: `codev/protocols/maintain/templates/maintenance-run.md`
60
+
61
+ The file records:
62
+ - Base commit (starting point)
63
+ - Tasks completed
64
+ - Findings and deferred items
65
+ - Summary
45
66
 
46
67
  ---
47
68
 
@@ -56,12 +77,14 @@ Before starting MAINTAIN:
56
77
  | Clean unused flags | Yes | No | Remove feature flags that are always on/off |
57
78
  | Fix flaky tests | No | Yes | Investigate and fix intermittently failing tests |
58
79
  | Update outdated dependencies | Yes | Yes | Bump dependencies with breaking change review |
80
+ | Identify duplicate code | Yes | Yes | Find repeated patterns that should be utility functions |
59
81
 
60
82
  **Tools**:
61
83
  ```bash
62
84
  # TypeScript/JavaScript
63
85
  npx ts-prune # Find unused exports
64
86
  npx depcheck # Find unused dependencies
87
+ npx jscpd . # Find copy-paste code (optional)
65
88
 
66
89
  # Python
67
90
  ruff check --select F401 # Find unused imports
@@ -74,6 +97,7 @@ ruff check --select F401 # Find unused imports
74
97
  | Update arch.md | Yes | No | Sync architecture doc with actual codebase |
75
98
  | Generate lessons-learned.md | Yes | Yes | Extract wisdom from review documents |
76
99
  | Sync CLAUDE.md ↔ AGENTS.md | Yes | No | Ensure both files match |
100
+ | Prune documentation | Yes | Yes | Remove obsolete info, keep CLAUDE.md/README.md under 400 lines |
77
101
  | Check spec/plan/review consistency | Yes | Yes | Find specs without reviews, plans that don't match code |
78
102
  | Remove stale doc references | Yes | No | Delete references to deleted code/files |
79
103
 
@@ -84,6 +108,12 @@ ruff check --select F401 # Find unused imports
84
108
  | Update projectlist.md status | Yes | No | Update project statuses |
85
109
  | Archive terminal projects | Yes | No | Move completed/abandoned to terminal section |
86
110
 
111
+ ### Framework Tasks
112
+
113
+ | Task | Parallelizable | Human Review? | Description |
114
+ |------|----------------|---------------|-------------|
115
+ | Run codev update | No | Yes | Update codev framework to latest version |
116
+
87
117
  ---
88
118
 
89
119
  ## Task Details
@@ -92,16 +122,149 @@ ruff check --select F401 # Find unused imports
92
122
 
93
123
  Scan the actual codebase and update `codev/resources/arch.md`:
94
124
 
125
+ **Discovery phase**:
126
+ 1. `git log --oneline <base-commit>..HEAD` - what changed since last maintenance
127
+ 2. `ls -R` key directories to find new files/modules
128
+ 3. `grep` for new exports, classes, key functions
129
+ 4. Review new/modified specs: `git diff <base-commit>..HEAD --name-only -- codev/specs/`
130
+ 5. Review new/modified plans: `git diff <base-commit>..HEAD --name-only -- codev/plans/`
131
+
132
+ **Update arch.md**:
95
133
  1. Verify directory structure matches documented structure
96
- 2. Update component descriptions
134
+ 2. Update component descriptions for changed modules
97
135
  3. Add new utilities/helpers discovered
98
136
  4. Remove references to deleted code
99
- 5. Update technology stack if changed
137
+ 5. Update technology stack if dependencies changed
138
+ 6. Document new integration points or APIs
139
+ 7. Capture architectural decisions from new specs/plans
140
+
141
+ **Primary sources** (specs/plans):
142
+ - Architectural decisions from specs
143
+ - Component relationships from plans
144
+ - Design rationale and tradeoffs
145
+
146
+ **Secondary sources** (code):
147
+ - File locations and their purpose
148
+ - Key functions/classes and what they do
149
+ - Data flow and dependencies
150
+ - Configuration options
151
+ - CLI commands and flags
152
+
153
+ **What NOT to include**:
154
+ - Implementation details that change frequently
155
+ - Line numbers (they go stale)
156
+ - Full API documentation (use JSDoc/docstrings for that)
157
+
158
+ **Primary Purpose**: arch.md should enable a developer (or AI agent) to rapidly understand the entire system - not just file locations, but **how things actually work**.
159
+
160
+ **Recommended Document Structure**:
161
+ ```markdown
162
+ # Project Architecture
163
+
164
+ ## Overview
165
+ [High-level description: what the system does, core design philosophy, 2-3 sentences]
166
+
167
+ ## Quick Start for Developers
168
+ [The fastest path to understanding: "To understand X, read Y first"]
169
+
170
+ ## Technology Stack
171
+ [Technologies, frameworks, key dependencies with versions]
172
+
173
+ ## Directory Structure
174
+ [Complete directory tree with explanations for each major directory]
175
+
176
+ ## Major Components
177
+
178
+ ### [Component Name] (e.g., Agent Farm)
179
+ - **Purpose**: What problem it solves
180
+ - **Location**: path/to/component
181
+ - **How It Works**:
182
+ - Step-by-step explanation of the mechanism
183
+ - Key technologies used (e.g., "uses tmux for terminal multiplexing")
184
+ - Runtime behavior (e.g., "spawns a tmux session per builder")
185
+ - State management (e.g., "state stored in SQLite at .agent-farm/state.db")
186
+ - **Key Files**:
187
+ - `file.ts` - does X
188
+ - `other.ts` - handles Y
189
+ - **Configuration**: How to customize behavior
190
+ - **Common Operations**: Examples of typical usage
191
+
192
+ [Repeat for each major component - be thorough about HOW, not just WHAT]
193
+
194
+ ## Utility Functions & Helpers
195
+ ### [Utility Category]
196
+ - **File**: path/to/utility.ts
197
+ - **Functions**: `functionName()` - Description and use case
198
+ - **When to Use**: Guidance on appropriate usage
199
+
200
+ ## Data Flow
201
+ [How data moves through the system, with concrete examples]
202
+
203
+ ## Key Design Decisions
204
+ [Important architectural choices and their rationale - the WHY]
205
+
206
+ ## Integration Points
207
+ [External services, APIs, databases, and how they connect]
208
+
209
+ ## Development Patterns
210
+ [Common patterns used throughout the codebase]
211
+ ```
212
+
213
+ **Critical: The "How It Works" Requirement**
214
+
215
+ For each major component, arch.md MUST explain the implementation mechanism, not just the purpose. Examples of good vs bad:
216
+
217
+ | Bad (just WHAT) | Good (includes HOW) |
218
+ |-----------------|---------------------|
219
+ | "Agent Farm manages builders" | "Agent Farm spawns builders in isolated git worktrees. Each builder runs in a tmux session (named `builder-{id}`). The dashboard uses ttyd to expose terminals via HTTP on ports 4201-4299. State is persisted in SQLite." |
220
+ | "Consult tool queries AI models" | "Consult shells out to external CLIs (gemini-cli, codex, claude). It writes the consultant role to a temp file, sets environment variables, and streams stdout/stderr back to the user." |
221
+
222
+ This level of detail enables rapid onboarding and debugging.
223
+
224
+ **Content Quality Standards**:
225
+ - **Be Specific**: Include exact file paths, actual function names, concrete examples
226
+ - **Maintain Accuracy**: Cross-reference specs/plans with actual implementation; flag discrepancies
227
+ - **Optimize for Quick Understanding**: Use clear hierarchy, highlight commonly used components
228
+ - **Stay Current**: Reflect actual state, not aspirational; remove deprecated components
229
+
230
+ **Special Attention Areas**:
231
+
232
+ 1. **Utility Functions** (critical for productivity):
233
+ - Document every utility function with exact location
234
+ - Explain what each does and when to use it
235
+ - Include parameter types and return types
236
+
237
+ 2. **Directory Structure** (often first thing referenced):
238
+ - Keep directory tree up-to-date and complete
239
+ - Explain purpose of each major directory
240
+ - Highlight where specific types of files should be placed
241
+
242
+ 3. **Integration Points** (critical for understanding system boundaries):
243
+ - Document all external dependencies and APIs
244
+ - Explain how different parts connect
245
+ - Note special configuration requirements
246
+
247
+ **Quality Assurance Before Finalizing**:
248
+ - [ ] All file paths are correct and current
249
+ - [ ] All documented functions actually exist
250
+ - [ ] Directory structure matches reality
251
+ - [ ] Architectural decisions are accurately represented
252
+ - [ ] Document is internally consistent
253
+
254
+ **Constraints**:
255
+ - Never invent structure - only document what exists or is in specs/plans
256
+ - Never make architectural decisions - document them, don't make them
257
+ - Always verify documentation against actual implementation
100
258
 
101
259
  ### Generate lessons-learned.md
102
260
 
103
261
  Extract actionable wisdom from review documents into `codev/resources/lessons-learned.md`:
104
262
 
263
+ **Discovery phase**:
264
+ 1. Find new/modified reviews: `git diff <base-commit>..HEAD --name-only -- codev/reviews/`
265
+ 2. Read each new/modified review file
266
+
267
+ **Extract from reviews**:
105
268
  1. Read all files in `codev/reviews/`
106
269
  2. Extract lessons that are:
107
270
  - Actionable (not just "we learned X")
@@ -136,6 +299,67 @@ Ensure both instruction files contain the same content:
136
299
  3. Update the stale one to match
137
300
  4. Both should be identical (per AGENTS.md standard)
138
301
 
302
+ ### Prune Documentation
303
+
304
+ **CRITICAL: Documentation pruning requires JUSTIFICATION for every deletion.**
305
+
306
+ Size targets (~400 lines for CLAUDE.md/README.md) are **guidelines, not mandates**. Never sacrifice clarity or important content just to hit a line count.
307
+
308
+ **Before deleting ANY content, document:**
309
+ 1. **What** is being removed (quote or summarize)
310
+ 2. **Why** it's being removed:
311
+ - `OBSOLETE` - References deleted code/features
312
+ - `DUPLICATIVE` - Same info exists elsewhere (cite location)
313
+ - `MOVED` - Relocated to another file (cite new location)
314
+ - `VERBOSE` - Can be condensed without losing meaning
315
+ 3. **Decision** - Delete, move, or keep with note
316
+
317
+ **Create a deletion log in your maintenance file:**
318
+ ```markdown
319
+ ## Documentation Changes
320
+
321
+ ### arch.md
322
+ | Section | Action | Reason |
323
+ |---------|--------|--------|
324
+ | "Old API docs" | DELETED | OBSOLETE - API removed in v1.2 |
325
+ | "Installation" | MOVED | To INSTALL.md for brevity |
326
+ | "Architecture patterns" | KEPT | Still relevant, referenced by builders |
327
+ ```
328
+
329
+ **Files to review**:
330
+ - `codev/resources/arch.md` - remove references to deleted code/modules
331
+ - `codev/resources/lessons-learned.md` - remove outdated lessons
332
+ - `CLAUDE.md` / `AGENTS.md` - target ~400 lines (guideline, not hard limit)
333
+ - `README.md` - target ~400 lines (guideline, not hard limit)
334
+
335
+ **Conservative approach**:
336
+ - When in doubt, KEEP the content
337
+ - If unsure, ASK the architect before deleting
338
+ - Prefer MOVING over DELETING
339
+ - Never delete "development patterns" or "best practices" sections without explicit approval
340
+
341
+ **What to extract (move, don't delete)**:
342
+ - Detailed command references → `codev/docs/commands/`
343
+ - Protocol details → `codev/protocols/*/protocol.md`
344
+ - Tool configuration → `codev/resources/`
345
+
346
+ **What to ALWAYS keep in CLAUDE.md**:
347
+ - Git prohibitions and safety rules
348
+ - Critical workflow instructions
349
+ - Protocol selection guidance
350
+ - Consultation requirements
351
+ - Links to detailed docs
352
+
353
+ **Good candidates for deletion from CLAUDE.md**:
354
+ - Content duplicated elsewhere (e.g., in protocol files, role files, docs/)
355
+ - **When removing duplicated content**: Replace with a pointer to the canonical location
356
+ ```markdown
357
+ ## Consult Tool
358
+
359
+ See `codev/docs/commands/consult.md` for full documentation.
360
+ ```
361
+ - This keeps CLAUDE.md as an index/guide rather than duplicating detailed docs
362
+
139
363
  ### Remove Dead Code
140
364
 
141
365
  Use static analysis to find and remove unused code:
@@ -159,6 +383,16 @@ Review and update outdated dependencies:
159
383
  3. Update and test
160
384
  4. Document any migration steps
161
385
 
386
+ ### Run codev update
387
+
388
+ Update the codev framework to the latest version:
389
+
390
+ ```bash
391
+ codev update
392
+ ```
393
+
394
+ This updates protocols, templates, and agents while preserving your specs, plans, and reviews.
395
+
162
396
  ---
163
397
 
164
398
  ## Validation
@@ -175,6 +409,33 @@ If validation fails, investigate and fix before creating PR.
175
409
 
176
410
  ---
177
411
 
412
+ ## 3-Way Review (Before PR)
413
+
414
+ After completing all tasks and validation, run a 3-way consultation review:
415
+
416
+ ```bash
417
+ # Run all three in parallel
418
+ consult --model gemini --type impl-review pr <branch-name> &
419
+ consult --model codex --type impl-review pr <branch-name> &
420
+ consult --model claude --type impl-review pr <branch-name> &
421
+ wait
422
+ ```
423
+
424
+ **Focus areas for maintenance review:**
425
+ - Are deletions justified and documented?
426
+ - Is arch.md accurate and complete?
427
+ - Are lessons-learned.md entries actionable?
428
+ - Any regressions or side effects?
429
+
430
+ **Verdicts:**
431
+ - All APPROVE → Create PR
432
+ - Any REQUEST_CHANGES → Address feedback, re-run review
433
+ - Conflicting opinions → Use judgment, document decision
434
+
435
+ Only create the PR after the 3-way review passes.
436
+
437
+ ---
438
+
178
439
  ## Rollback Strategy
179
440
 
180
441
  ### For code changes
@@ -210,7 +471,7 @@ MAINTAIN is an **operational protocol**, not a feature development protocol:
210
471
  | Spec | No |
211
472
  | Plan | No |
212
473
  | Review | No |
213
- | Consultation | No (human review of PR is sufficient) |
474
+ | 3-Way Consultation | **Yes** (before creating PR) |
214
475
 
215
476
  **Exception**: If MAINTAIN reveals need for architectural changes, those should follow SPIDER.
216
477
 
@@ -218,18 +479,24 @@ MAINTAIN is an **operational protocol**, not a feature development protocol:
218
479
 
219
480
  ## Best Practices
220
481
 
221
- 1. **Don't be aggressive**: When in doubt, keep the code
222
- 2. **Check git blame**: Understand why code exists before deleting
482
+ 1. **Don't be aggressive**: When in doubt, KEEP the content. It's easier to delete later than to recover lost knowledge.
483
+ 2. **Check git blame**: Understand why code/docs exist before removing
223
484
  3. **Run full test suite**: Not just affected tests
224
485
  4. **Group related changes**: One commit per logical change
225
- 5. **Document decisions**: Note why things were kept or removed
486
+ 5. **Document EVERY deletion**: Include what, why, and where (if moved)
487
+ 6. **Ask when unsure**: Consult architect before removing "important-looking" content
488
+ 7. **Prefer moving over deleting**: Extract to another file rather than removing entirely
489
+ 8. **Size targets are guidelines**: Never sacrifice clarity to hit a line count
226
490
 
227
491
  ---
228
492
 
229
493
  ## Anti-Patterns
230
494
 
231
- 1. **Deleting everything the audit finds**: Review each item
232
- 2. **Skipping validation**: "It looked dead" is not validation
233
- 3. **Using `rm` instead of `git rm`**: Lose history
234
- 4. **Maintaining during active development**: Wait for PRs to merge
235
- 5. **Ignoring false positives**: Fix audit logic if it's wrong
495
+ 1. **Aggressive rewriting without explanation**: "I condensed it" is not a reason
496
+ 2. **Deleting without documenting why**: Every deletion needs justification in the maintenance file
497
+ 3. **Hitting line count targets at all costs**: 400 lines is a guideline, not a mandate
498
+ 4. **Removing "patterns" or "best practices" sections**: These are high-value content
499
+ 5. **Deleting everything the audit finds**: Review each item individually
500
+ 6. **Skipping validation**: "It looked dead/obsolete" is not validation
501
+ 7. **Using `rm` instead of `git rm`**: Lose history
502
+ 8. **Making changes the architect can't review**: Big deletions need clear explanations
@@ -0,0 +1,64 @@
1
+ # Maintenance Run NNNN
2
+
3
+ ## Metadata
4
+ - **Date**: YYYY-MM-DD
5
+ - **Base Commit**: (commit hash at start)
6
+ - **PR**: #NNN
7
+ - **Scope**: full | code-only | docs-only
8
+
9
+ ## Changes Since Last Run
10
+
11
+ <!-- Auto-generated summary of commits since last maintenance -->
12
+
13
+ ```
14
+ git log --oneline <last-maint-commit>..HEAD
15
+ ```
16
+
17
+ ## Tasks Completed
18
+
19
+ ### Code Hygiene
20
+ - [ ] Dead code removal
21
+ - [ ] Unused dependencies
22
+ - [ ] Dependency updates
23
+ - [ ] Test maintenance
24
+
25
+ ### Documentation
26
+ - [ ] arch.md sync
27
+ - [ ] lessons-learned.md generation
28
+ - [ ] CLAUDE.md / AGENTS.md sync
29
+ - [ ] Documentation pruning (obsolete content, size limits)
30
+
31
+ ### Framework
32
+ - [ ] codev update
33
+ - [ ] projectlist.md status updates
34
+
35
+ ## Findings
36
+
37
+ <!-- Notable discoveries during maintenance -->
38
+
39
+ ## Documentation Changes
40
+
41
+ <!-- REQUIRED: Log all documentation deletions/moves with justification -->
42
+
43
+ ### arch.md
44
+ | Section | Action | Reason |
45
+ |---------|--------|--------|
46
+ | (example) | KEPT/MOVED/DELETED | (justification) |
47
+
48
+ ### CLAUDE.md
49
+ | Section | Action | Reason |
50
+ |---------|--------|--------|
51
+ | (example) | KEPT/MOVED/DELETED | (justification) |
52
+
53
+ ### README.md
54
+ | Section | Action | Reason |
55
+ |---------|--------|--------|
56
+ | (example) | KEPT/MOVED/DELETED | (justification) |
57
+
58
+ ## Deferred
59
+
60
+ <!-- Items discovered but deferred to next run, with reason -->
61
+
62
+ ## Summary
63
+
64
+ <!-- Brief summary of what was accomplished -->
@@ -490,8 +490,8 @@ Execute for each phase in the plan. This is a strict cycle that must be complete
490
490
  - Enhance documentation
491
491
 
492
492
  3. **Update Architecture Documentation**
493
- - Use architecture-documenter agent to update `codev/resources/arch.md`
494
- - Document new modules, utilities, or architectural changes
493
+ - Update `codev/resources/arch.md` with new modules, utilities, or architectural changes
494
+ - Follow guidance in MAINTAIN protocol's "Update arch.md" task for structure and standards
495
495
  - Ensure arch.md reflects current codebase state
496
496
 
497
497
  4. **Revision Requirements** (MANDATORY)
@@ -111,6 +111,19 @@ af send architect "Question about the spec..."
111
111
  af open src/path/to/file.ts
112
112
  ```
113
113
 
114
+ ### Protocol Import
115
+
116
+ ```bash
117
+ # Import protocol improvements from another project
118
+ codev import /path/to/other-project
119
+
120
+ # Import from GitHub
121
+ codev import github:cluesmith/ansari-project
122
+
123
+ # Preview without running Claude
124
+ codev import github:owner/repo --dry-run
125
+ ```
126
+
114
127
  ### Consultation Commands
115
128
 
116
129
  ```bash