@boshu2/vibe-check 2.2.1 → 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.
- package/.agents/plans/2025-12-28-ai-safety-integration-plan.md +326 -0
- package/.agents/plans/2025-12-29-complexity-driver-plan.md +225 -0
- package/.agents/plans/2025-12-29-complexity-drivers-plan.md +253 -0
- package/.agents/research/2025-12-28-ai-platform-security-integration.md +295 -0
- package/.agents/research/2025-12-29-complexity-driver-architecture.md +392 -0
- package/.agents/research/2025-12-29-complexity-drivers.md +227 -0
- package/.beads/README.md +81 -0
- package/.beads/config.yaml +62 -0
- package/.beads/interactions.jsonl +0 -0
- package/.beads/issues.jsonl +21 -0
- package/.beads/metadata.json +4 -0
- package/.gitattributes +3 -0
- package/AGENTS.md +40 -0
- package/CHANGELOG.md +69 -0
- package/CLAUDE.md +75 -0
- package/README.md +71 -0
- package/dist/ai-safety/contract-drift.d.ts +14 -0
- package/dist/ai-safety/contract-drift.d.ts.map +1 -0
- package/dist/ai-safety/contract-drift.js +230 -0
- package/dist/ai-safety/contract-drift.js.map +1 -0
- package/dist/ai-safety/index.d.ts +43 -0
- package/dist/ai-safety/index.d.ts.map +1 -0
- package/dist/ai-safety/index.js +177 -0
- package/dist/ai-safety/index.js.map +1 -0
- package/dist/ai-safety/scope-violation.d.ts +18 -0
- package/dist/ai-safety/scope-violation.d.ts.map +1 -0
- package/dist/ai-safety/scope-violation.js +150 -0
- package/dist/ai-safety/scope-violation.js.map +1 -0
- package/dist/ai-safety/secret-leakage.d.ts +18 -0
- package/dist/ai-safety/secret-leakage.d.ts.map +1 -0
- package/dist/ai-safety/secret-leakage.js +188 -0
- package/dist/ai-safety/secret-leakage.js.map +1 -0
- package/dist/ai-safety/token-spiral.d.ts +17 -0
- package/dist/ai-safety/token-spiral.d.ts.map +1 -0
- package/dist/ai-safety/token-spiral.js +183 -0
- package/dist/ai-safety/token-spiral.js.map +1 -0
- package/dist/ai-safety/types.d.ts +122 -0
- package/dist/ai-safety/types.d.ts.map +1 -0
- package/dist/ai-safety/types.js +32 -0
- package/dist/ai-safety/types.js.map +1 -0
- package/dist/analyzers/complexity.d.ts +92 -0
- package/dist/analyzers/complexity.d.ts.map +1 -0
- package/dist/analyzers/complexity.js +79 -0
- package/dist/analyzers/complexity.js.map +1 -0
- package/dist/analyzers/modularity.d.ts +3 -1
- package/dist/analyzers/modularity.d.ts.map +1 -1
- package/dist/analyzers/modularity.js +32 -6
- package/dist/analyzers/modularity.js.map +1 -1
- package/dist/cli.js +2 -1
- package/dist/cli.js.map +1 -1
- package/dist/commands/driver.d.ts +18 -0
- package/dist/commands/driver.d.ts.map +1 -0
- package/dist/commands/driver.js +58 -0
- package/dist/commands/driver.js.map +1 -0
- package/dist/commands/index.d.ts +1 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +1 -0
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/modularity.d.ts +2 -0
- package/dist/commands/modularity.d.ts.map +1 -1
- package/dist/commands/modularity.js +86 -7
- package/dist/commands/modularity.js.map +1 -1
- package/dist/commands/session.d.ts +9 -0
- package/dist/commands/session.d.ts.map +1 -1
- package/dist/commands/session.js +42 -0
- package/dist/commands/session.js.map +1 -1
- package/dist/commands/watch.d.ts.map +1 -1
- package/dist/commands/watch.js +59 -0
- package/dist/commands/watch.js.map +1 -1
- package/drivers/README.md +327 -0
- package/drivers/go.sh +131 -0
- package/drivers/java.sh +137 -0
- package/drivers/javascript.sh +134 -0
- package/drivers/php.sh +132 -0
- package/drivers/python.sh +90 -0
- package/drivers/rust.sh +132 -0
- package/package.json +4 -1
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
---
|
|
2
|
+
date: 2025-12-28
|
|
3
|
+
type: Plan
|
|
4
|
+
topic: "AI Safety Detection Module for vibe-check"
|
|
5
|
+
research: ".agents/research/2025-12-28-ai-platform-security-integration.md"
|
|
6
|
+
tags: [plan, ai-safety, llm-validation, security, vibe-check]
|
|
7
|
+
status: READY_FOR_APPROVAL
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Plan: AI Safety Detection Module
|
|
11
|
+
|
|
12
|
+
**Created:** 2025-12-28
|
|
13
|
+
**Research:** `.agents/research/2025-12-28-ai-platform-security-integration.md`
|
|
14
|
+
**Vibe Level:** L3 (Multiple files, following existing patterns)
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Overview
|
|
19
|
+
|
|
20
|
+
Add a new `src/ai-safety/` module to vibe-check that detects LLM-specific antipatterns in commit history: **secret leakage**, **scope violations**, **contract drift**, and **token spirals**. This extends the existing inner-loop failure detection with patterns ported from ai-platform's production security stack.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Approach
|
|
25
|
+
|
|
26
|
+
Port security validation patterns from `ai-platform/tests/agents/test_agent_security.py` and adapt them for git-based analysis. Follow the existing `src/inner-loop/` module structure exactly.
|
|
27
|
+
|
|
28
|
+
**Why this approach:**
|
|
29
|
+
1. **Proven patterns:** ai-platform patterns are battle-tested for classified environments
|
|
30
|
+
2. **Non-breaking:** Extends existing architecture without replacing anything
|
|
31
|
+
3. **Familiar structure:** Same module organization as inner-loop
|
|
32
|
+
4. **Zero new dependencies:** Pure TypeScript, uses existing git analysis
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Features
|
|
37
|
+
|
|
38
|
+
### Feature 1: AI Safety Types and Orchestrator
|
|
39
|
+
|
|
40
|
+
**Priority:** P0 (Foundation - must come first)
|
|
41
|
+
**Type:** feature
|
|
42
|
+
**Depends On:** None
|
|
43
|
+
|
|
44
|
+
**Acceptance Criteria:**
|
|
45
|
+
- [ ] `src/ai-safety/types.ts` defines all interfaces
|
|
46
|
+
- [ ] `src/ai-safety/index.ts` exports orchestrator function
|
|
47
|
+
- [ ] `AISafetyAnalysis` interface matches inner-loop pattern
|
|
48
|
+
- [ ] Config supports enable/disable per detector
|
|
49
|
+
- [ ] Compiles without errors
|
|
50
|
+
|
|
51
|
+
**Files Affected:**
|
|
52
|
+
- `src/ai-safety/types.ts` - New file: Type definitions
|
|
53
|
+
- `src/ai-safety/index.ts` - New file: Orchestrator + exports
|
|
54
|
+
|
|
55
|
+
**Test Strategy:** `npm run build` passes, types are importable
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
### Feature 2: Secret Leakage Detector
|
|
60
|
+
|
|
61
|
+
**Priority:** P1 (Highest value, immediate utility)
|
|
62
|
+
**Type:** feature
|
|
63
|
+
**Depends On:** Feature 1
|
|
64
|
+
|
|
65
|
+
**Acceptance Criteria:**
|
|
66
|
+
- [ ] Detects OpenAI keys (`sk-[a-zA-Z0-9]{48}`)
|
|
67
|
+
- [ ] Detects GitHub PATs (`ghp_[a-zA-Z0-9]{36}`)
|
|
68
|
+
- [ ] Detects GitLab PATs (`glpat-[a-zA-Z0-9]{20}`)
|
|
69
|
+
- [ ] Detects AWS keys (`AKIA[0-9A-Z]{16}`)
|
|
70
|
+
- [ ] Detects Slack tokens (`xox[baprs]-*`)
|
|
71
|
+
- [ ] Detects generic patterns (password=, secret=)
|
|
72
|
+
- [ ] Reports file, line context, and pattern matched
|
|
73
|
+
- [ ] Critical severity by default
|
|
74
|
+
|
|
75
|
+
**Files Affected:**
|
|
76
|
+
- `src/ai-safety/secret-leakage.ts` - New file: Secret detection logic
|
|
77
|
+
- `src/ai-safety/index.ts` - Wire into orchestrator
|
|
78
|
+
|
|
79
|
+
**Test Strategy:**
|
|
80
|
+
1. Create test with fake secrets in commit diffs
|
|
81
|
+
2. Verify detection of each pattern
|
|
82
|
+
3. Verify no false positives on similar-looking strings
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
### Feature 3: Scope Violation Detector
|
|
87
|
+
|
|
88
|
+
**Priority:** P2 (High value, needs config)
|
|
89
|
+
**Type:** feature
|
|
90
|
+
**Depends On:** Feature 1
|
|
91
|
+
|
|
92
|
+
**Acceptance Criteria:**
|
|
93
|
+
- [ ] Detects commits touching files outside declared scope
|
|
94
|
+
- [ ] Scope defined via config file (`.vibe-check/scope.yaml`) or CLI
|
|
95
|
+
- [ ] Supports glob patterns for scope definition
|
|
96
|
+
- [ ] Reports which files violated scope
|
|
97
|
+
- [ ] Warning severity by default
|
|
98
|
+
|
|
99
|
+
**Files Affected:**
|
|
100
|
+
- `src/ai-safety/scope-violation.ts` - New file: Scope check logic
|
|
101
|
+
- `src/ai-safety/index.ts` - Wire into orchestrator
|
|
102
|
+
- `src/types.ts` - Add AISafetyConfig to main types
|
|
103
|
+
|
|
104
|
+
**Test Strategy:**
|
|
105
|
+
1. Define scope as `src/feature/**`
|
|
106
|
+
2. Create commit touching `src/other/file.ts`
|
|
107
|
+
3. Verify scope violation detected
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
### Feature 4: Contract Drift Detector
|
|
112
|
+
|
|
113
|
+
**Priority:** P2 (Medium value, pattern analysis)
|
|
114
|
+
**Type:** feature
|
|
115
|
+
**Depends On:** Feature 1
|
|
116
|
+
|
|
117
|
+
**Acceptance Criteria:**
|
|
118
|
+
- [ ] Tracks commit message format compliance over time
|
|
119
|
+
- [ ] Detects degradation from conventional commits format
|
|
120
|
+
- [ ] Tracks entropy (message quality declining)
|
|
121
|
+
- [ ] Reports drift percentage and trend direction
|
|
122
|
+
- [ ] Warning severity when >30% drift from baseline
|
|
123
|
+
|
|
124
|
+
**Files Affected:**
|
|
125
|
+
- `src/ai-safety/contract-drift.ts` - New file: Format drift logic
|
|
126
|
+
- `src/ai-safety/index.ts` - Wire into orchestrator
|
|
127
|
+
|
|
128
|
+
**Test Strategy:**
|
|
129
|
+
1. Provide commits with good format then degrading format
|
|
130
|
+
2. Verify drift percentage calculated
|
|
131
|
+
3. Verify warning triggered at threshold
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
### Feature 5: Token Spiral Estimator
|
|
136
|
+
|
|
137
|
+
**Priority:** P3 (Lower value, estimation-based)
|
|
138
|
+
**Type:** feature
|
|
139
|
+
**Depends On:** Feature 1
|
|
140
|
+
|
|
141
|
+
**Acceptance Criteria:**
|
|
142
|
+
- [ ] Estimates token usage from commit size
|
|
143
|
+
- [ ] Uses heuristic: ~4 chars per token
|
|
144
|
+
- [ ] Tracks cumulative session tokens
|
|
145
|
+
- [ ] Detects explosion patterns (>2x baseline)
|
|
146
|
+
- [ ] Info severity (advisory, not critical)
|
|
147
|
+
|
|
148
|
+
**Files Affected:**
|
|
149
|
+
- `src/ai-safety/token-spiral.ts` - New file: Token estimation logic
|
|
150
|
+
- `src/ai-safety/index.ts` - Wire into orchestrator
|
|
151
|
+
|
|
152
|
+
**Test Strategy:**
|
|
153
|
+
1. Provide small commits then huge commit
|
|
154
|
+
2. Verify explosion detected
|
|
155
|
+
3. Verify reasonable token estimates
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
### Feature 6: Integration with Session End
|
|
160
|
+
|
|
161
|
+
**Priority:** P1 (Makes feature visible to users)
|
|
162
|
+
**Type:** feature
|
|
163
|
+
**Depends On:** Features 1-2 (minimum)
|
|
164
|
+
|
|
165
|
+
**Acceptance Criteria:**
|
|
166
|
+
- [ ] `session end` JSON output includes `ai_safety` section
|
|
167
|
+
- [ ] Terminal output shows AI safety warnings
|
|
168
|
+
- [ ] Critical findings show in red
|
|
169
|
+
- [ ] Recommendations generated for each finding
|
|
170
|
+
|
|
171
|
+
**Files Affected:**
|
|
172
|
+
- `src/commands/session.ts` - Add AI safety analysis call
|
|
173
|
+
- `src/output/terminal.ts` - Format AI safety for terminal
|
|
174
|
+
- `src/output/json.ts` - Format AI safety for JSON
|
|
175
|
+
|
|
176
|
+
**Test Strategy:** `vibe-check session end --format json` includes ai_safety section
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
### Feature 7: Integration with Watch Command
|
|
181
|
+
|
|
182
|
+
**Priority:** P2 (Real-time value)
|
|
183
|
+
**Type:** feature
|
|
184
|
+
**Depends On:** Feature 2 (secret detection)
|
|
185
|
+
|
|
186
|
+
**Acceptance Criteria:**
|
|
187
|
+
- [ ] Watch mode alerts on secret detection immediately
|
|
188
|
+
- [ ] Uses red/bold for critical findings
|
|
189
|
+
- [ ] Shows file and pattern matched
|
|
190
|
+
- [ ] Rate-limited (don't spam alerts)
|
|
191
|
+
|
|
192
|
+
**Files Affected:**
|
|
193
|
+
- `src/commands/watch.ts` - Add secret detection to watch loop
|
|
194
|
+
|
|
195
|
+
**Test Strategy:** Run watch, commit file with fake secret, see immediate alert
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
### Feature 8: Tests and Documentation
|
|
200
|
+
|
|
201
|
+
**Priority:** P2 (Quality assurance)
|
|
202
|
+
**Type:** task
|
|
203
|
+
**Depends On:** Features 1-5
|
|
204
|
+
|
|
205
|
+
**Acceptance Criteria:**
|
|
206
|
+
- [ ] Unit tests for each detector
|
|
207
|
+
- [ ] Integration test for orchestrator
|
|
208
|
+
- [ ] CLAUDE.md updated with ai-safety commands
|
|
209
|
+
- [ ] README.md mentions AI safety features
|
|
210
|
+
|
|
211
|
+
**Files Affected:**
|
|
212
|
+
- `tests/ai-safety.test.ts` - New file: Test suite
|
|
213
|
+
- `CLAUDE.md` - Update documentation
|
|
214
|
+
- `README.md` - Feature description
|
|
215
|
+
|
|
216
|
+
**Test Strategy:** `npm test` passes with >80% coverage on new module
|
|
217
|
+
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
## Implementation Order
|
|
221
|
+
|
|
222
|
+
| Step | Feature | Depends On | Validation |
|
|
223
|
+
|------|---------|------------|------------|
|
|
224
|
+
| 1 | Types and Orchestrator | - | `npm run build` passes |
|
|
225
|
+
| 2 | Secret Leakage | Step 1 | Test with fake secrets |
|
|
226
|
+
| 3 | Session Integration | Steps 1-2 | `session end` shows findings |
|
|
227
|
+
| 4 | Scope Violation | Step 1 | Test with scope config |
|
|
228
|
+
| 5 | Contract Drift | Step 1 | Test with degrading commits |
|
|
229
|
+
| 6 | Token Spiral | Step 1 | Test with varying sizes |
|
|
230
|
+
| 7 | Watch Integration | Step 2 | Real-time alert test |
|
|
231
|
+
| 8 | Tests & Docs | Steps 1-6 | `npm test` passes |
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
## Beads Issues to Create
|
|
236
|
+
|
|
237
|
+
After approval, these issues will be created:
|
|
238
|
+
|
|
239
|
+
| ID | Title | Type | Priority | Depends On |
|
|
240
|
+
|----|-------|------|----------|------------|
|
|
241
|
+
| TBD | Epic: AI Safety Detection Module | epic | P1 | - |
|
|
242
|
+
| TBD | AI Safety types and orchestrator | feature | P0 | Epic |
|
|
243
|
+
| TBD | Secret leakage detector | feature | P1 | Types |
|
|
244
|
+
| TBD | Session end AI safety integration | feature | P1 | Secret detector |
|
|
245
|
+
| TBD | Scope violation detector | feature | P2 | Types |
|
|
246
|
+
| TBD | Contract drift detector | feature | P2 | Types |
|
|
247
|
+
| TBD | Token spiral estimator | feature | P3 | Types |
|
|
248
|
+
| TBD | Watch command AI safety integration | feature | P2 | Secret detector |
|
|
249
|
+
| TBD | Tests and documentation | task | P2 | All features |
|
|
250
|
+
|
|
251
|
+
---
|
|
252
|
+
|
|
253
|
+
## File Structure After Implementation
|
|
254
|
+
|
|
255
|
+
```
|
|
256
|
+
src/ai-safety/
|
|
257
|
+
├── index.ts # Orchestrator: analyzeAISafety()
|
|
258
|
+
├── types.ts # Interfaces: AISafetyAnalysis, configs
|
|
259
|
+
├── secret-leakage.ts # Regex-based secret detection
|
|
260
|
+
├── scope-violation.ts # Glob-based scope checking
|
|
261
|
+
├── contract-drift.ts # Commit format degradation
|
|
262
|
+
└── token-spiral.ts # Token usage estimation
|
|
263
|
+
|
|
264
|
+
tests/ai-safety.test.ts # Full test suite
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
---
|
|
268
|
+
|
|
269
|
+
## Key Interfaces (Preview)
|
|
270
|
+
|
|
271
|
+
```typescript
|
|
272
|
+
// src/ai-safety/types.ts
|
|
273
|
+
export interface AISafetyAnalysis {
|
|
274
|
+
secretLeakage: SecretLeakageResult;
|
|
275
|
+
scopeViolations: ScopeViolationResult;
|
|
276
|
+
contractDrift: ContractDriftResult;
|
|
277
|
+
tokenSpiral: TokenSpiralResult;
|
|
278
|
+
summary: {
|
|
279
|
+
totalIssues: number;
|
|
280
|
+
criticalIssues: number;
|
|
281
|
+
warningIssues: number;
|
|
282
|
+
overallHealth: 'healthy' | 'warning' | 'critical';
|
|
283
|
+
};
|
|
284
|
+
recommendations: string[];
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
export interface SecretLeakageResult {
|
|
288
|
+
detected: boolean;
|
|
289
|
+
findings: SecretFinding[];
|
|
290
|
+
message: string;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
export interface SecretFinding {
|
|
294
|
+
commitHash: string;
|
|
295
|
+
file: string;
|
|
296
|
+
pattern: string;
|
|
297
|
+
lineContext: string;
|
|
298
|
+
severity: 'critical' | 'warning';
|
|
299
|
+
}
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
---
|
|
303
|
+
|
|
304
|
+
## Rollback Procedure
|
|
305
|
+
|
|
306
|
+
If something goes wrong:
|
|
307
|
+
|
|
308
|
+
1. **Module not loading:** Revert `src/ai-safety/` directory
|
|
309
|
+
2. **Session command broken:** Revert `src/commands/session.ts` changes
|
|
310
|
+
3. **Watch command broken:** Revert `src/commands/watch.ts` changes
|
|
311
|
+
4. **Build fails:** Check `src/ai-safety/index.ts` exports
|
|
312
|
+
|
|
313
|
+
All changes are additive - existing functionality is not modified, only extended.
|
|
314
|
+
|
|
315
|
+
---
|
|
316
|
+
|
|
317
|
+
## Next Steps
|
|
318
|
+
|
|
319
|
+
1. **Review and approve this plan**
|
|
320
|
+
2. **Create beads issues** (commands below)
|
|
321
|
+
3. **`bd ready`** to see unblocked issues
|
|
322
|
+
4. **`/implement`** to execute first issue
|
|
323
|
+
|
|
324
|
+
---
|
|
325
|
+
|
|
326
|
+
**Output:** .agents/plans/2025-12-28-ai-safety-integration-plan.md
|
|
@@ -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
|