@boshu2/vibe-check 2.3.0 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/.agents/plans/2025-12-29-complexity-driver-plan.md +225 -0
  2. package/.agents/plans/2025-12-29-complexity-drivers-plan.md +253 -0
  3. package/.agents/research/2025-12-29-complexity-driver-architecture.md +392 -0
  4. package/.agents/research/2025-12-29-complexity-drivers.md +227 -0
  5. package/.beads/issues.jsonl +12 -0
  6. package/CHANGELOG.md +27 -0
  7. package/README.md +71 -0
  8. package/dist/analyzers/complexity.d.ts +92 -0
  9. package/dist/analyzers/complexity.d.ts.map +1 -0
  10. package/dist/analyzers/complexity.js +79 -0
  11. package/dist/analyzers/complexity.js.map +1 -0
  12. package/dist/analyzers/modularity.d.ts +3 -1
  13. package/dist/analyzers/modularity.d.ts.map +1 -1
  14. package/dist/analyzers/modularity.js +32 -6
  15. package/dist/analyzers/modularity.js.map +1 -1
  16. package/dist/cli.js +2 -1
  17. package/dist/cli.js.map +1 -1
  18. package/dist/commands/driver.d.ts +18 -0
  19. package/dist/commands/driver.d.ts.map +1 -0
  20. package/dist/commands/driver.js +58 -0
  21. package/dist/commands/driver.js.map +1 -0
  22. package/dist/commands/index.d.ts +1 -0
  23. package/dist/commands/index.d.ts.map +1 -1
  24. package/dist/commands/index.js +1 -0
  25. package/dist/commands/index.js.map +1 -1
  26. package/dist/commands/modularity.d.ts +2 -0
  27. package/dist/commands/modularity.d.ts.map +1 -1
  28. package/dist/commands/modularity.js +86 -7
  29. package/dist/commands/modularity.js.map +1 -1
  30. package/drivers/README.md +327 -0
  31. package/drivers/go.sh +131 -0
  32. package/drivers/java.sh +137 -0
  33. package/drivers/javascript.sh +134 -0
  34. package/drivers/php.sh +132 -0
  35. package/drivers/python.sh +90 -0
  36. package/drivers/rust.sh +132 -0
  37. package/package.json +1 -1
@@ -0,0 +1,225 @@
1
+ ---
2
+ date: 2025-12-29
3
+ type: Plan
4
+ topic: "Add Complexity Driver Architecture"
5
+ research: ".agents/research/2025-12-29-complexity-driver-architecture.md"
6
+ tags: [plan, architecture, complexity]
7
+ status: READY_FOR_IMPLEMENTATION
8
+ ---
9
+
10
+ # Plan: Complexity Driver Architecture
11
+
12
+ **Created:** 2025-12-29
13
+ **Research:** [Complexity Driver Architecture Research](.agents/research/2025-12-29-complexity-driver-architecture.md)
14
+
15
+ ---
16
+
17
+ ## Overview
18
+
19
+ Add a "driver" system that allows language-specific complexity tools (radon, gocyclo, complexity-report) to feed metrics into vibe-check's modularity analyzer. vibe-check remains language-agnostic; drivers normalize tool output to a standard schema.
20
+
21
+ ---
22
+
23
+ ## Features
24
+
25
+ ### Feature 1: Define Complexity Schema and Loader
26
+
27
+ **Priority:** P1
28
+ **Type:** feature
29
+
30
+ **Description:** Create TypeScript types for the standard complexity schema and a loader function.
31
+
32
+ **Files to Create:**
33
+ - `src/analyzers/complexity.ts`
34
+
35
+ **Implementation:**
36
+ ```typescript
37
+ // Types
38
+ export interface ComplexityReport { ... }
39
+ export interface FunctionComplexity { ... }
40
+
41
+ // Loader
42
+ export function loadComplexityData(rootDir: string): ComplexityReport | null
43
+
44
+ // Helper
45
+ export function getFileComplexity(data: ComplexityReport, file: string)
46
+ ```
47
+
48
+ **Acceptance Criteria:**
49
+ - [ ] Types exported and documented
50
+ - [ ] Loader returns null if file doesn't exist
51
+ - [ ] Loader handles malformed JSON gracefully
52
+ - [ ] Helper returns null for unknown files
53
+
54
+ ---
55
+
56
+ ### Feature 2: Integrate Complexity into Modularity Scoring
57
+
58
+ **Priority:** P1
59
+ **Type:** feature
60
+ **Depends On:** Feature 1
61
+
62
+ **Description:** Modify `analyzeModularity()` to optionally accept complexity data and incorporate it into scoring.
63
+
64
+ **Files to Modify:**
65
+ - `src/analyzers/modularity.ts`
66
+
67
+ **Changes:**
68
+ 1. Add optional `complexityData` parameter to `analyzeModularity()`
69
+ 2. Pass to `calculateScore()`
70
+ 3. Add scoring logic:
71
+ - Grade A/B: +2 bonus
72
+ - Grade C: -1, flag `moderate-complexity`
73
+ - Grade D/E: -2, flag `high-complexity`
74
+ - Grade F: -4, flag `extreme-complexity`
75
+ 4. Add new flags to `ModularityFlag` type
76
+
77
+ **Acceptance Criteria:**
78
+ - [ ] Backwards compatible (works without complexity data)
79
+ - [ ] Flags appear in output when complexity issues detected
80
+ - [ ] Score adjustments match spec
81
+
82
+ ---
83
+
84
+ ### Feature 3: Create Python Driver
85
+
86
+ **Priority:** P1
87
+ **Type:** feature
88
+
89
+ **Description:** Shell script that wraps `radon` and outputs standard schema JSON.
90
+
91
+ **Files to Create:**
92
+ - `drivers/python.sh`
93
+
94
+ **Implementation:**
95
+ - Check radon installed
96
+ - Run `radon cc <dir> -j`
97
+ - Transform with `jq` to standard schema
98
+ - Output to stdout
99
+
100
+ **Acceptance Criteria:**
101
+ - [ ] Exits 0 on success
102
+ - [ ] Exits 1 with error JSON if radon not installed
103
+ - [ ] Output validates against schema
104
+ - [ ] Handles empty directories gracefully
105
+
106
+ ---
107
+
108
+ ### Feature 4: Create JavaScript/TypeScript Driver
109
+
110
+ **Priority:** P2
111
+ **Type:** feature
112
+
113
+ **Description:** Shell script that wraps `complexity-report` for JS/TS analysis.
114
+
115
+ **Files to Create:**
116
+ - `drivers/javascript.sh`
117
+
118
+ **Acceptance Criteria:**
119
+ - [ ] Works with complexity-report npm package
120
+ - [ ] Output validates against schema
121
+ - [ ] Handles mixed .js/.ts codebases
122
+
123
+ ---
124
+
125
+ ### Feature 5: Add CLI Integration
126
+
127
+ **Priority:** P2
128
+ **Type:** feature
129
+ **Depends On:** Features 1-3
130
+
131
+ **Description:** Add CLI flags to run drivers and consume their output.
132
+
133
+ **Files to Modify:**
134
+ - `src/cli.ts`
135
+ - `src/commands/analyze.ts`
136
+
137
+ **New CLI Options:**
138
+ ```bash
139
+ # Run driver before analysis
140
+ vibe-check --with-complexity python
141
+
142
+ # Use existing complexity file
143
+ vibe-check --complexity-file .vibe-check/complexity.json
144
+
145
+ # Driver subcommand
146
+ vibe-check driver python ./src
147
+ ```
148
+
149
+ **Acceptance Criteria:**
150
+ - [ ] `--with-complexity` runs driver, saves to `.vibe-check/complexity.json`
151
+ - [ ] `--complexity-file` uses existing file
152
+ - [ ] `driver` subcommand outputs to stdout
153
+ - [ ] Help text updated
154
+
155
+ ---
156
+
157
+ ### Feature 6: Documentation
158
+
159
+ **Priority:** P2
160
+ **Type:** docs
161
+ **Depends On:** Features 1-5
162
+
163
+ **Description:** Document the driver architecture in README and create driver authoring guide.
164
+
165
+ **Files to Modify/Create:**
166
+ - `README.md` - Add "Complexity Analysis" section
167
+ - `docs/drivers.md` - Driver authoring guide
168
+
169
+ **Acceptance Criteria:**
170
+ - [ ] README shows basic usage
171
+ - [ ] Driver guide explains schema and contract
172
+ - [ ] Examples for Python and JS
173
+
174
+ ---
175
+
176
+ ## Implementation Order
177
+
178
+ | Step | Feature | Validation |
179
+ |------|---------|------------|
180
+ | 1 | Schema + Loader | Unit tests pass |
181
+ | 2 | Modularity Integration | `npm test` passes |
182
+ | 3 | Python Driver | Manual test with radon |
183
+ | 4 | CLI Integration | `vibe-check --with-complexity python` works |
184
+ | 5 | JS Driver | Manual test with complexity-report |
185
+ | 6 | Documentation | README updated |
186
+
187
+ ---
188
+
189
+ ## Beads Issues
190
+
191
+ | ID | Title | Priority |
192
+ |----|-------|----------|
193
+ | TBD | Add complexity schema and loader | P1 |
194
+ | TBD | Integrate complexity into modularity scoring | P1 |
195
+ | TBD | Create Python driver (radon wrapper) | P1 |
196
+ | TBD | Add CLI complexity flags | P2 |
197
+ | TBD | Create JavaScript driver | P2 |
198
+ | TBD | Document driver architecture | P2 |
199
+
200
+ ---
201
+
202
+ ## Test Strategy
203
+
204
+ **Unit Tests:**
205
+ - `tests/analyzers/complexity.test.ts` - Schema validation, loader edge cases
206
+ - `tests/analyzers/modularity.test.ts` - Scoring with/without complexity data
207
+
208
+ **Integration Tests:**
209
+ - Run Python driver on known codebase, verify output
210
+ - Run full vibe-check with complexity, verify report includes grades
211
+
212
+ **Manual Testing:**
213
+ - Test on ai-platform repo (known sync.py has F-grade functions)
214
+
215
+ ---
216
+
217
+ ## Next Steps
218
+
219
+ 1. `bd create` to create beads issues
220
+ 2. `/implement` to start with Feature 1
221
+ 3. Build incrementally, test each feature
222
+
223
+ ---
224
+
225
+ **Output:** .agents/plans/2025-12-29-complexity-driver-plan.md
@@ -0,0 +1,253 @@
1
+ ---
2
+ date: 2025-12-29
3
+ type: Plan
4
+ topic: "Add complexity drivers for Rust, PHP, and Java"
5
+ research: ".agents/research/2025-12-29-complexity-drivers.md"
6
+ tags: [plan, drivers, complexity, rust, php, java]
7
+ status: COMPLETED
8
+ ---
9
+
10
+ # Plan: Additional Complexity Drivers
11
+
12
+ **Created:** 2025-12-29
13
+ **Research:** .agents/research/2025-12-29-complexity-drivers.md
14
+ **Vibe Level:** L4 (high confidence - following established driver pattern)
15
+
16
+ ---
17
+
18
+ ## Overview
19
+
20
+ Add complexity drivers for **Rust**, **PHP**, and **Java** to expand vibe-check's language coverage. These are the highest-value additions based on language popularity (TIOBE/Stack Overflow 2025) and tool quality. All three have tools with JSON output, making implementation straightforward.
21
+
22
+ ---
23
+
24
+ ## Approach
25
+
26
+ Follow existing driver pattern established by `python.sh`, `javascript.sh`, and `go.sh`:
27
+
28
+ 1. Shell script wrapper around language-specific tool
29
+ 2. Transform tool output to `ComplexityReport` JSON schema
30
+ 3. Update CLI error messages to include new driver
31
+ 4. Update documentation
32
+
33
+ **Why this approach:**
34
+ - Proven pattern (3 working drivers)
35
+ - Language-agnostic kernel stays clean
36
+ - Shell scripts are portable and don't add npm dependencies
37
+
38
+ ---
39
+
40
+ ## Features
41
+
42
+ ### Feature 1: Rust Driver
43
+
44
+ **Priority:** P1
45
+ **Type:** feature
46
+ **Depends On:** None
47
+
48
+ **Acceptance Criteria:**
49
+ - [ ] `drivers/rust.sh` created wrapping `rust-code-analysis-cli`
50
+ - [ ] Outputs valid `ComplexityReport` JSON
51
+ - [ ] Handles missing tool with helpful error message
52
+ - [ ] Handles empty directories gracefully
53
+ - [ ] CLI updated to list `rust` as available driver
54
+ - [ ] Documentation updated (drivers/README.md, README.md)
55
+
56
+ **Files Affected:**
57
+ - `drivers/rust.sh` - New driver script
58
+ - `drivers/README.md` - Add Rust section
59
+ - `README.md` - Add Rust to Available Drivers list
60
+ - `src/commands/driver.ts` - Update available drivers message
61
+ - `src/commands/modularity.ts` - Update available drivers message
62
+
63
+ **Test Strategy:**
64
+ 1. Create test Rust file with known complexity
65
+ 2. Run `./drivers/rust.sh /path/to/test`
66
+ 3. Verify JSON output matches schema
67
+ 4. Run `vibe-check driver rust /path/to/test`
68
+ 5. Run `vibe-check modularity --with-complexity rust`
69
+
70
+ **Tool Details:**
71
+ ```bash
72
+ # Install
73
+ cargo install rust-code-analysis-cli
74
+
75
+ # Usage (native JSON)
76
+ rust-code-analysis-cli -m -O json -p /path/to/src
77
+ ```
78
+
79
+ ---
80
+
81
+ ### Feature 2: PHP Driver
82
+
83
+ **Priority:** P2
84
+ **Type:** feature
85
+ **Depends On:** None (can be done in parallel with Rust)
86
+
87
+ **Acceptance Criteria:**
88
+ - [ ] `drivers/php.sh` created wrapping `phpmd`
89
+ - [ ] Outputs valid `ComplexityReport` JSON
90
+ - [ ] Handles missing tool with helpful error message
91
+ - [ ] Handles empty directories gracefully
92
+ - [ ] CLI updated to list `php` as available driver
93
+ - [ ] Documentation updated
94
+
95
+ **Files Affected:**
96
+ - `drivers/php.sh` - New driver script
97
+ - `drivers/README.md` - Add PHP section
98
+ - `README.md` - Add PHP to Available Drivers list
99
+ - `src/commands/driver.ts` - Update available drivers message
100
+ - `src/commands/modularity.ts` - Update available drivers message
101
+
102
+ **Test Strategy:**
103
+ 1. Create test PHP file with known complexity
104
+ 2. Run `./drivers/php.sh /path/to/test`
105
+ 3. Verify JSON output matches schema
106
+ 4. Run `vibe-check driver php /path/to/test`
107
+
108
+ **Tool Details:**
109
+ ```bash
110
+ # Install
111
+ composer global require phpmd/phpmd
112
+
113
+ # Usage (native JSON)
114
+ phpmd /path/to/src json codesize
115
+ ```
116
+
117
+ ---
118
+
119
+ ### Feature 3: Java Driver
120
+
121
+ **Priority:** P2
122
+ **Type:** feature
123
+ **Depends On:** None (can be done in parallel)
124
+
125
+ **Acceptance Criteria:**
126
+ - [ ] `drivers/java.sh` created wrapping PMD
127
+ - [ ] Outputs valid `ComplexityReport` JSON
128
+ - [ ] Handles missing tool with helpful error message
129
+ - [ ] Handles empty directories gracefully
130
+ - [ ] CLI updated to list `java` as available driver
131
+ - [ ] Documentation updated
132
+
133
+ **Files Affected:**
134
+ - `drivers/java.sh` - New driver script
135
+ - `drivers/README.md` - Add Java section
136
+ - `README.md` - Add Java to Available Drivers list
137
+ - `src/commands/driver.ts` - Update available drivers message
138
+ - `src/commands/modularity.ts` - Update available drivers message
139
+
140
+ **Test Strategy:**
141
+ 1. Create test Java file with known complexity
142
+ 2. Run `./drivers/java.sh /path/to/test`
143
+ 3. Verify JSON output matches schema
144
+ 4. Run `vibe-check driver java /path/to/test`
145
+
146
+ **Tool Details:**
147
+ ```bash
148
+ # Install (download PMD)
149
+ # https://pmd.github.io/
150
+
151
+ # Usage (JSON via flag)
152
+ pmd check -d /path/to/src -R category/java/design.xml -f json
153
+ ```
154
+
155
+ **Note:** PMD requires JRE. Document this clearly.
156
+
157
+ ---
158
+
159
+ ## Implementation Order
160
+
161
+ | Step | Feature | Depends On | Validation |
162
+ |------|---------|------------|------------|
163
+ | 1 | Rust Driver | - | `vibe-check driver rust ./test` produces valid JSON |
164
+ | 2 | PHP Driver | - | `vibe-check driver php ./test` produces valid JSON |
165
+ | 3 | Java Driver | - | `vibe-check driver java ./test` produces valid JSON |
166
+
167
+ **Note:** All three can be implemented in parallel - no dependencies between them.
168
+
169
+ ---
170
+
171
+ ## Beads Issues to Create
172
+
173
+ After approval, these issues will be created:
174
+
175
+ | ID | Title | Type | Priority | Depends On |
176
+ |----|-------|------|----------|------------|
177
+ | TBD | Epic: Additional Complexity Drivers | epic | P1 | - |
178
+ | TBD | Create Rust complexity driver | feature | P1 | Epic |
179
+ | TBD | Create PHP complexity driver | feature | P2 | Epic |
180
+ | TBD | Create Java complexity driver | feature | P2 | Epic |
181
+
182
+ ---
183
+
184
+ ## Output Format Reference
185
+
186
+ All drivers must output JSON matching this schema:
187
+
188
+ ```typescript
189
+ {
190
+ tool: string; // "rust-code-analysis", "phpmd", "pmd"
191
+ language: string; // "rust", "php", "java"
192
+ generatedAt: string; // ISO timestamp
193
+ files: {
194
+ [filepath: string]: {
195
+ functions: Array<{
196
+ name: string;
197
+ complexity: number;
198
+ grade: 'A' | 'B' | 'C' | 'D' | 'E' | 'F';
199
+ line: number;
200
+ endLine?: number;
201
+ }>;
202
+ avgComplexity: number;
203
+ maxComplexity: number;
204
+ grade: 'A' | 'B' | 'C' | 'D' | 'E' | 'F';
205
+ };
206
+ };
207
+ summary: {
208
+ totalFiles: number;
209
+ totalFunctions: number;
210
+ avgComplexity: number;
211
+ gradeDistribution: Record<'A'|'B'|'C'|'D'|'E'|'F', number>;
212
+ };
213
+ }
214
+ ```
215
+
216
+ **Grade Thresholds:**
217
+ - A: 1-5 (simple)
218
+ - B: 6-10 (acceptable)
219
+ - C: 11-20 (consider refactoring)
220
+ - D: 21-30 (refactor)
221
+ - E: 31-40 (high risk)
222
+ - F: 41+ (unmaintainable)
223
+
224
+ ---
225
+
226
+ ## Rollback Procedure
227
+
228
+ Each driver is independent. To rollback:
229
+ 1. `git revert <commit>` for the specific driver
230
+ 2. Remove the `drivers/<lang>.sh` file
231
+ 3. Update CLI error messages to remove language
232
+
233
+ ---
234
+
235
+ ## Not In Scope
236
+
237
+ - Ruby driver (P3 - requires text parsing)
238
+ - C# driver (P3 - requires XML parsing)
239
+ - Automated tool installation
240
+ - Windows-specific handling
241
+
242
+ ---
243
+
244
+ ## Next Steps
245
+
246
+ 1. Review and approve this plan
247
+ 2. Run beads issue creation (below)
248
+ 3. `bd ready` to see unblocked issues
249
+ 4. `/implement` to execute
250
+
251
+ ---
252
+
253
+ **Output:** .agents/plans/2025-12-29-complexity-drivers-plan.md