vibe-validate 0.17.1-rc.3 → 0.17.1

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,504 @@
1
+ # Workflows & Decision Trees
2
+
3
+ ## Overview
4
+
5
+ This guide provides decision trees and workflow patterns for common vibe-validate scenarios. Use these when you're unsure about command sequencing or which workflow to follow.
6
+
7
+ ## Decision Tree: When User Requests a Commit
8
+
9
+ ```
10
+ User: "Commit these changes"
11
+
12
+ Run: npx vibe-validate pre-commit
13
+
14
+ ├─ Pass (exitCode 0)
15
+ │ ↓
16
+ │ Proceed with commit
17
+ │ ↓
18
+ │ git add -A && git commit -m "..."
19
+
20
+ └─ Fail (exitCode 1)
21
+
22
+ Query: npx vibe-validate state
23
+
24
+ Analyze failedStepOutput
25
+
26
+ Show user:
27
+ - Which step failed
28
+ - File/line errors
29
+ - Suggested fix
30
+
31
+ User fixes errors
32
+
33
+ Re-run: npx vibe-validate pre-commit (fast with cache!)
34
+
35
+ Repeat until pass
36
+ ```
37
+
38
+ ### Example Flow
39
+
40
+ ```bash
41
+ # User requests commit
42
+ User: "Commit my changes"
43
+
44
+ # Step 1: Pre-commit validation
45
+ $ vv pre-commit
46
+ ✗ Failed: TypeScript (2 errors)
47
+
48
+ # Step 2: Query state (don't re-run!)
49
+ $ vv state
50
+ passed: false
51
+ failedStep: TypeScript
52
+ errors:
53
+ - file: src/feature.ts
54
+ line: 42
55
+ message: Type 'string' is not assignable to type 'number'
56
+
57
+ # Step 3: Fix and iterate
58
+ # (Fix the error)
59
+ $ vv pre-commit # Fast re-run with cache
60
+ ✓ All validations passed
61
+
62
+ # Step 4: Proceed with commit
63
+ $ git add -A && git commit -m "feat: add feature"
64
+ ```
65
+
66
+ ## Decision Tree: When User Requests Running Tests
67
+
68
+ ```
69
+ User: "Run the tests in path/to/test.ts"
70
+
71
+ Run: npx vibe-validate run "npx vitest path/to/test.ts"
72
+
73
+ Parse YAML output
74
+
75
+ ├─ exitCode: 0
76
+ │ ↓
77
+ │ Report success to user
78
+ │ Show summary (X tests passed)
79
+
80
+ └─ exitCode: 1
81
+
82
+ Show errors[] from YAML
83
+
84
+ Provide file:line context
85
+
86
+ User fixes or asks for help
87
+
88
+ Re-run (wrapped with vv run)
89
+
90
+ Repeat until pass
91
+ ```
92
+
93
+ ### Example Flow
94
+
95
+ ```bash
96
+ # User requests test run
97
+ User: "Run the feature tests"
98
+
99
+ # Step 1: Wrap with vv run
100
+ $ vv run "npm test -- feature.test.ts"
101
+
102
+ # Step 2: Parse output
103
+ exitCode: 1
104
+ errors:
105
+ - file: tests/feature.test.ts
106
+ line: 25
107
+ message: "Expected 5 to equal 6"
108
+ summary: "1 test failure"
109
+
110
+ # Step 3: Show user
111
+ "Test failed at tests/feature.test.ts:25
112
+ Expected 5 to equal 6"
113
+
114
+ # User fixes
115
+ # Step 4: Re-run
116
+ $ vv run "npm test -- feature.test.ts"
117
+ exitCode: 0
118
+ summary: "All tests passed"
119
+ ```
120
+
121
+ ## Decision Tree: When Validation Behaves Unexpectedly
122
+
123
+ ```
124
+ Issue: Validation slow/flaky/failing unexpectedly
125
+
126
+ Run: npx vibe-validate doctor
127
+
128
+ ├─ Issues found
129
+ │ ↓
130
+ │ Follow guidance to fix:
131
+ │ - Node.js version
132
+ │ - Git repository
133
+ │ - Config validity
134
+ │ - Deprecated files
135
+ │ - Hook installation
136
+ │ ↓
137
+ │ Re-run: vv doctor
138
+ │ ↓
139
+ │ Verify fixed
140
+
141
+ └─ No issues found
142
+
143
+ Check cache behavior:
144
+ vv validate --check
145
+
146
+ ├─ Exit 0: Cached (working correctly)
147
+ └─ Exit 1: Not cached
148
+
149
+ Force refresh: vv validate --force
150
+
151
+ Check if passes
152
+ ```
153
+
154
+ ## Decision Tree: When User Lost Work
155
+
156
+ ```
157
+ User: "I accidentally deleted my files"
158
+
159
+ Query: Did you run vv validate, pre-commit, or run recently?
160
+
161
+ ├─ YES
162
+ │ ↓
163
+ │ Run: vv history list --limit 10
164
+ │ ↓
165
+ │ Find recent validation before deletion
166
+ │ ↓
167
+ │ Run: git checkout <tree-hash> -- <path>
168
+ │ ↓
169
+ │ Files recovered!
170
+
171
+ └─ NO
172
+
173
+ Try: git reflog
174
+
175
+ Try: IDE local history
176
+
177
+ Try: OS file recovery tools
178
+
179
+ Educate: Use vv validate frequently for snapshots
180
+ ```
181
+
182
+ **See**: [Work Recovery Guide](work-recovery.md) for detailed recovery patterns
183
+
184
+ ## Workflow Pattern: Pre-Commit Validation
185
+
186
+ ### Standard Flow
187
+
188
+ ```bash
189
+ # 1. Make changes
190
+ git status # See what changed
191
+
192
+ # 2. Run pre-commit validation
193
+ vv pre-commit
194
+
195
+ # 3a. If pass: Commit
196
+ git add -A
197
+ git commit -m "feat: implement feature"
198
+
199
+ # 3b. If fail: Fix and iterate
200
+ vv state # See what failed (instant, no re-run)
201
+ # Fix errors
202
+ vv pre-commit # Fast with cache
203
+ ```
204
+
205
+ ### With Branch Sync Issues
206
+
207
+ ```bash
208
+ # Pre-commit fails: "branch behind origin/main"
209
+ vv pre-commit
210
+ ✗ Branch sync: Behind 3 commits
211
+
212
+ # Fix: Merge or rebase
213
+ git fetch origin
214
+ git merge origin/main # or git rebase origin/main
215
+
216
+ # Re-validate
217
+ vv pre-commit
218
+ ✓ All validations passed
219
+ ```
220
+
221
+ ## Workflow Pattern: Context-Optimized Testing
222
+
223
+ ### Development Loop
224
+
225
+ ```bash
226
+ # 1. Make change to feature code
227
+ # 2. Run tests with extraction
228
+ vv run "npm test -- feature.test.ts"
229
+
230
+ # 3. If fail: See extracted errors
231
+ exitCode: 1
232
+ errors: [...]
233
+
234
+ # 4. Fix and iterate (fast with cache)
235
+ vv run "npm test -- feature.test.ts"
236
+ ```
237
+
238
+ ### Multi-Package Testing
239
+
240
+ ```bash
241
+ # Test specific package
242
+ vv run "pnpm --filter @myapp/core test"
243
+
244
+ # Test all packages
245
+ vv run "pnpm -r test"
246
+
247
+ # Cache works across runs
248
+ vv run "pnpm -r test" # Instant if no changes!
249
+ ```
250
+
251
+ ## Workflow Pattern: Full Validation Pipeline
252
+
253
+ ### Standard Flow
254
+
255
+ ```bash
256
+ # Run all validation phases
257
+ vv validate
258
+
259
+ # If pass: Ready to push
260
+ git push origin feature
261
+
262
+ # If fail: Query state (don't re-run!)
263
+ vv state
264
+
265
+ # Fix errors incrementally
266
+ # Re-validate (fast with cache)
267
+ vv validate
268
+ ```
269
+
270
+ ### With Force Refresh
271
+
272
+ ```bash
273
+ # Suspect stale cache
274
+ vv validate --force
275
+
276
+ # Or just check cache state
277
+ vv validate --check
278
+ if [ $? -eq 0 ]; then
279
+ echo "Cached (validation passed)"
280
+ else
281
+ echo "Not cached (need to run)"
282
+ fi
283
+ ```
284
+
285
+ ## Workflow Pattern: PR Validation Monitoring
286
+
287
+ ### Watch CI Status
288
+
289
+ ```bash
290
+ # Auto-detect PR from branch
291
+ vv watch-pr
292
+
293
+ # Specific PR number
294
+ vv watch-pr 123
295
+
296
+ # YAML output for parsing
297
+ vv watch-pr --yaml
298
+ ```
299
+
300
+ ### On CI Failure
301
+
302
+ ```bash
303
+ # Get detailed state from CI
304
+ vv watch-pr 123
305
+
306
+ # Output shows:
307
+ # - Which validation step failed
308
+ # - Extracted errors from CI logs
309
+ # - Recovery commands
310
+
311
+ # Fix locally
312
+ vv validate --force
313
+
314
+ # Push fix
315
+ git push
316
+ ```
317
+
318
+ ## Workflow Pattern: Initial Project Setup
319
+
320
+ ### New Project Onboarding
321
+
322
+ ```bash
323
+ # 1. Install
324
+ npm install -D vibe-validate
325
+
326
+ # 2. Initialize with template
327
+ vv init --template typescript-library
328
+
329
+ # 3. Run diagnostics
330
+ vv doctor
331
+
332
+ # 4. Fix any issues shown by doctor
333
+
334
+ # 5. Test validation
335
+ vv validate
336
+
337
+ # 6. Commit config
338
+ git add vibe-validate.config.yaml
339
+ git commit -m "chore: add vibe-validate"
340
+ ```
341
+
342
+ ### Existing Project Adoption
343
+
344
+ ```bash
345
+ # 1. Install
346
+ npm install -D vibe-validate
347
+
348
+ # 2. Initialize (pick closest template)
349
+ vv init
350
+
351
+ # 3. Customize config for your setup
352
+ # Edit vibe-validate.config.yaml
353
+
354
+ # 4. Test on clean state
355
+ vv validate
356
+
357
+ # 5. Fix any issues
358
+ vv state # See what failed
359
+
360
+ # 6. Iterate until green
361
+ vv validate
362
+
363
+ # 7. Commit
364
+ git add vibe-validate.config.yaml
365
+ git commit -m "chore: add vibe-validate"
366
+ ```
367
+
368
+ ## Command Sequencing Rules
369
+
370
+ ### Always This Order
371
+
372
+ ```bash
373
+ # CORRECT: Query state before re-running
374
+ vv validate # (fails)
375
+ vv state # Check what failed
376
+ # fix errors
377
+ vv validate # Re-run
378
+
379
+ # WRONG: Re-run immediately
380
+ vv validate # (fails)
381
+ vv validate # Wastes time, doesn't show errors efficiently
382
+ ```
383
+
384
+ ### Never Skip Pre-Commit
385
+
386
+ ```bash
387
+ # CORRECT: Validate before commit
388
+ vv pre-commit
389
+ git add -A && git commit -m "..."
390
+
391
+ # WRONG: Skip validation
392
+ git add -A && git commit -m "..." # Might break CI!
393
+ ```
394
+
395
+ ### Use run for Ad-Hoc Commands
396
+
397
+ ```bash
398
+ # CORRECT: Wrap for extraction
399
+ vv run "npm test"
400
+
401
+ # WRONG: Run raw (verbose output)
402
+ npm test # Wastes context window
403
+ ```
404
+
405
+ ## Edge Cases
406
+
407
+ ### Cache Invalidation After .gitignore Change
408
+
409
+ ```bash
410
+ # Add build artifacts to .gitignore
411
+ echo "dist/" >> .gitignore
412
+
413
+ # Cache persists! (ignored files not in tree hash)
414
+ vv validate # Still cached
415
+
416
+ # Tree hash unchanged, validation result still valid
417
+ ```
418
+
419
+ ### Branch Switch with Same Code
420
+
421
+ ```bash
422
+ # On feature-a
423
+ vv validate # Cache result
424
+
425
+ # Create feature-b from same commit
426
+ git checkout -b feature-b
427
+
428
+ # No changes yet
429
+ vv validate # Cache hit! (same tree hash)
430
+ ```
431
+
432
+ ### Validation After Stash
433
+
434
+ ```bash
435
+ # Stash changes
436
+ git stash
437
+
438
+ # Tree hash changes (clean tree)
439
+ vv validate # Re-validates clean state
440
+
441
+ # Pop stash
442
+ git stash pop
443
+
444
+ # Tree hash changes (dirty tree)
445
+ vv validate # Re-validates with changes
446
+ ```
447
+
448
+ ## Troubleshooting Workflows
449
+
450
+ ### "Validation always runs (never cached)"
451
+
452
+ ```bash
453
+ # Diagnosis workflow
454
+ git status # Any uncommitted changes?
455
+ git write-tree # Current tree hash
456
+ vv state | grep treeHash # Cached tree hash
457
+ # If different: Something is changing
458
+
459
+ # Common causes:
460
+ ls -la | grep -E "coverage|dist|.tsbuildinfo"
461
+ # Add these to .gitignore
462
+
463
+ # Force refresh
464
+ vv validate --force
465
+ ```
466
+
467
+ ### "Errors not being extracted"
468
+
469
+ ```bash
470
+ # Diagnosis workflow
471
+ vv run "your-command"
472
+ # Look for: metadata.detection.extractor
473
+
474
+ # If "generic":
475
+ # Need custom extractor
476
+ # See: resources/extending-extraction.md
477
+
478
+ # If specific extractor but no errors:
479
+ # Extractor may need tuning
480
+ # File issue with example output
481
+ ```
482
+
483
+ ### "Pre-commit always fails on branch sync"
484
+
485
+ ```bash
486
+ # Diagnosis workflow
487
+ git fetch origin
488
+ git branch -vv # Check tracking
489
+ git log origin/main..HEAD # Commits ahead
490
+ git log HEAD..origin/main # Commits behind
491
+
492
+ # If behind:
493
+ git merge origin/main # or rebase
494
+
495
+ # If tracking broken:
496
+ git branch --set-upstream-to=origin/main
497
+ ```
498
+
499
+ ## See Also
500
+
501
+ - [CLI Reference](cli-reference.md) - All command options
502
+ - [Work Recovery Guide](work-recovery.md) - Recovery workflows
503
+ - [Troubleshooting Guide](troubleshooting.md) - Diagnostic workflows
504
+ - [Run Capability Guide](run-capability.md) - `vv run` workflow details
@@ -1,41 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Uninstall vibe-validate skill from ~/.claude/skills/vibe-validate
4
- *
5
- * This script runs before `npm uninstall -g vibe-validate` to clean up the skill.
6
- */
7
-
8
- import { existsSync, rmSync } from 'node:fs';
9
- import { join } from 'node:path';
10
- import { homedir } from 'node:os';
11
-
12
- // Target location
13
- const CLAUDE_SKILLS_DIR = join(homedir(), '.claude', 'skills', 'vibe-validate');
14
-
15
- /**
16
- * Uninstall skill
17
- */
18
- function uninstallSkill() {
19
- // Only uninstall for global installations
20
- // Check if we're in node_modules (global or local)
21
- const isGlobalInstall = process.cwd().includes('/lib/node_modules/');
22
-
23
- if (!isGlobalInstall) {
24
- // Local project installation - skip skill uninstall
25
- return;
26
- }
27
-
28
- try {
29
- if (existsSync(CLAUDE_SKILLS_DIR)) {
30
- console.log('🗑️ Removing vibe-validate skill from Claude Code...');
31
- rmSync(CLAUDE_SKILLS_DIR, { recursive: true, force: true });
32
- console.log(`✅ Skill removed from ${CLAUDE_SKILLS_DIR}`);
33
- }
34
- } catch (error) {
35
- console.error('⚠️ Failed to remove skill:', error.message);
36
- console.error(` You can manually remove: ${CLAUDE_SKILLS_DIR}`);
37
- }
38
- }
39
-
40
- // Run uninstallation
41
- uninstallSkill();