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,936 @@
1
+ # Agent Integration Guide
2
+
3
+ Learn how to integrate vibe-validate with AI coding assistants like Claude Code, Cursor, Aider, and Continue.
4
+
5
+ ## Table of Contents
6
+
7
+ - [Why Agent Integration?](#why-agent-integration)
8
+ - [Supported Agents](#supported-agents)
9
+ - [Integration Patterns](#integration-patterns)
10
+ - [Claude Code Integration](#claude-code-integration)
11
+ - [Cursor Integration](#cursor-integration)
12
+ - [Aider Integration](#aider-integration)
13
+ - [Continue Integration](#continue-integration)
14
+ - [Custom Agent Integration](#custom-agent-integration)
15
+ - [Best Practices](#best-practices)
16
+
17
+ ## Why Agent Integration?
18
+
19
+ AI coding assistants benefit from structured validation output:
20
+
21
+ **Benefits:**
22
+ - 🤖 **Actionable Prompts** - Ready-to-use error descriptions
23
+ - 📊 **Structured Data** - YAML/JSON format for parsing
24
+ - 🎯 **Focused Context** - Only relevant error information
25
+ - 🔄 **Iterative Fixing** - Fast feedback loop with caching
26
+ - 📝 **File:Line Context** - Jump directly to error locations
27
+
28
+ **Traditional Output (Not Agent-Friendly):**
29
+ ```
30
+ [32m✔[0m Building... (1234ms)
31
+ [31m✖[0m TypeScript compilation failed
32
+ src/index.ts(42,5): error TS2322: Type 'string' is not assignable to type 'number'.
33
+
34
+ 42 count: "five",
35
+ ~~~~~
36
+
37
+ Found 1 error.
38
+ ```
39
+
40
+ **Agent-Friendly Output (Structured):**
41
+ <!-- validation-result:partial -->
42
+ ```yaml
43
+ passed: false
44
+ phases:
45
+ - name: Pre-Qualification
46
+ passed: false
47
+ steps:
48
+ - name: TypeScript
49
+ passed: false
50
+ extraction:
51
+ errors:
52
+ - file: src/index.ts
53
+ line: 42
54
+ column: 5
55
+ message: "error TS2322: Type 'string' is not assignable to type 'number'"
56
+ summary: 1 error found
57
+ totalErrors: 1
58
+ ```
59
+
60
+ > **Note on Command Syntax**: This guide uses `vv` (the short alias) for all commands. You can substitute `vibe-validate` or `npx vibe-validate` if preferred - they work identically. Using `vv` saves typing and tokens, making it especially efficient for AI agents.
61
+
62
+ ## Supported Agents
63
+
64
+ vibe-validate officially supports these AI coding assistants:
65
+
66
+ | Agent | Detection | Output Format | Status |
67
+ |-------|-----------|---------------|--------|
68
+ | **Claude Code** | `CLAUDE_CODE=1` | YAML | ✅ Official |
69
+ | **Cursor** | `CURSOR=1` | YAML | ✅ Official |
70
+ | **Aider** | `AIDER=1` | YAML | ✅ Official |
71
+ | **Continue** | `CONTINUE=1` | YAML | ✅ Official |
72
+ | **CI/CD** | `CI=true` | YAML | ✅ Standard |
73
+ | **Custom** | Manual flag | YAML/JSON | ✅ Supported |
74
+
75
+ ## Integration Patterns
76
+
77
+ ### Pattern 1: Pre-Commit Workflow
78
+
79
+ **Agent ensures code quality before committing:**
80
+
81
+ ```typescript
82
+ // Agent workflow (pseudo-code):
83
+ 1. User: "Commit these changes"
84
+ 2. Agent: Run `vv pre-commit`
85
+ 3. If validation fails:
86
+ - Run `vv state` to get error details
87
+ - Analyze errors and suggest fixes
88
+ - Apply fixes
89
+ - Re-run validation (cached, fast!)
90
+ 4. If validation passes:
91
+ - Commit changes
92
+ ```
93
+
94
+ **Benefits:**
95
+ - ✅ Never commit broken code
96
+ - ✅ Fast feedback loop (caching)
97
+ - ✅ Automated error fixing
98
+
99
+ ### Pattern 2: Error Resolution Loop
100
+
101
+ **Agent iteratively fixes errors:**
102
+
103
+ ```typescript
104
+ // Iterative fixing workflow:
105
+ do {
106
+ result = run `vv validate`
107
+ if (result.passed) break;
108
+
109
+ // Extract errors from failed steps
110
+ errors = result.phases
111
+ .flatMap(phase => phase.steps)
112
+ .filter(step => !step.passed)
113
+ .flatMap(step => step.extraction?.errors || [])
114
+
115
+ fixes = suggest_fixes(errors)
116
+ apply_fixes(fixes)
117
+ } while (max_iterations)
118
+ ```
119
+
120
+ **Benefits:**
121
+ - ✅ Systematic error resolution
122
+ - ✅ Learning from patterns
123
+ - ✅ Comprehensive fixes
124
+
125
+ ### Pattern 3: Development Assistant
126
+
127
+ **Agent monitors validation state during development:**
128
+
129
+ ```typescript
130
+ // Real-time feedback workflow:
131
+ 1. User: "Add login feature"
132
+ 2. Agent: Implement feature
133
+ 3. Agent: Run `vv validate --force`
134
+ 4. Agent: Read validation state
135
+ 5. If errors exist:
136
+ - Fix errors proactively
137
+ - Re-validate
138
+ 6. Report completion to user
139
+ ```
140
+
141
+ **Benefits:**
142
+ - ✅ Proactive error fixing
143
+ - ✅ User never sees errors
144
+ - ✅ Higher code quality
145
+
146
+ ## Claude Code Integration
147
+
148
+ **Claude Code** is Anthropic's official AI coding assistant with terminal integration.
149
+
150
+ ### Setup
151
+
152
+ **1. Configure vibe-validate:**
153
+ <!-- config:example -->
154
+ ```yaml
155
+ # vibe-validate.config.yaml
156
+ # Reference: https://github.com/jdutton/vibe-validate/tree/main/packages/cli/config-templates
157
+ git:
158
+ mainBranch: main
159
+ validation:
160
+ phases:
161
+ - name: Testing
162
+ steps:
163
+ - name: Unit Tests
164
+ command: npm test
165
+ ```
166
+
167
+ **2. Add npm scripts:**
168
+ ```json
169
+ {
170
+ "scripts": {
171
+ "validate": "vibe-validate validate",
172
+ "pre-commit": "vibe-validate pre-commit"
173
+ }
174
+ }
175
+ ```
176
+
177
+ **3. Configure Claude Code project:**
178
+ ```markdown
179
+ <!-- CLAUDE.md (project instructions) -->
180
+ # Validation Workflow
181
+
182
+ **MANDATORY Steps for ANY Code Change:**
183
+ 1. Make your changes
184
+ 2. Run `npm run pre-commit` (MUST pass)
185
+ 3. Only commit if validation passes
186
+
187
+ ## Validation State
188
+
189
+ Validation results cached via git notes (content-based):
190
+ - Check current state: `vv state`
191
+ - Force re-validation: `vv validate --force`
192
+ - View timeline (advanced): `vv history list`
193
+
194
+ ## Error Fixing
195
+
196
+ When validation fails:
197
+ 1. View error details: `vv state`
198
+ 2. Fix the issue
199
+ 3. Re-run validation (fast with caching!)
200
+ ```
201
+
202
+ ### Usage in Claude Code
203
+
204
+ **User request:**
205
+ ```
206
+ User: Fix any validation errors and commit
207
+ ```
208
+
209
+ **Claude Code workflow:**
210
+ ```bash
211
+ # 1. Check validation state
212
+ $ vv state
213
+
214
+ # Output (YAML format):
215
+ # passed: false
216
+ # phases: [...] # See Phase and Step structure below
217
+ #
218
+ ```
219
+
220
+ ### Claude Code Features
221
+
222
+ **Automatic detection:**
223
+ - Claude Code sets `CLAUDE_CODE=1` environment variable
224
+ - vibe-validate automatically uses YAML output
225
+ - No manual configuration needed
226
+
227
+ **State integration:**
228
+ - Claude Code can run `vv state` for validation results
229
+ - Structured YAML data for programmatic parsing
230
+
231
+ **Performance:**
232
+ - Validation caching = fast iteration
233
+ - Claude Code can validate frequently without slowdown
234
+ - Cached validation: < 1s vs. seconds/minutes full validation
235
+
236
+ ---
237
+
238
+ ## Cursor Integration
239
+
240
+ **Cursor** is an AI-powered code editor built on VSCode.
241
+
242
+ ### Setup
243
+
244
+ **1. Configure vibe-validate:**
245
+ <!-- config:example -->
246
+ ```yaml
247
+ # vibe-validate.config.yaml
248
+ # Reference: https://github.com/jdutton/vibe-validate/tree/main/packages/cli/config-templates
249
+ git:
250
+ mainBranch: main
251
+ validation:
252
+ phases:
253
+ - name: Testing
254
+ steps:
255
+ - name: Unit Tests
256
+ command: npm test
257
+ ```
258
+
259
+ **2. Add VSCode tasks:**
260
+ ```json
261
+ // .vscode/tasks.json
262
+ {
263
+ "version": "2.0.0",
264
+ "tasks": [
265
+ {
266
+ "label": "Validate",
267
+ "type": "shell",
268
+ "command": "npm run validate",
269
+ "problemMatcher": [],
270
+ "presentation": {
271
+ "reveal": "always",
272
+ "panel": "new"
273
+ }
274
+ },
275
+ {
276
+ "label": "Pre-Commit",
277
+ "type": "shell",
278
+ "command": "npm run pre-commit",
279
+ "problemMatcher": []
280
+ }
281
+ ]
282
+ }
283
+ ```
284
+
285
+ **3. Add keyboard shortcuts:**
286
+ ```json
287
+ // .vscode/keybindings.json
288
+ [
289
+ {
290
+ "key": "ctrl+shift+v",
291
+ "command": "workbench.action.tasks.runTask",
292
+ "args": "Validate"
293
+ }
294
+ ]
295
+ ```
296
+
297
+ ### Usage in Cursor
298
+
299
+ **Cursor AI chat:**
300
+ ```
301
+ User: Run validation and fix any errors
302
+
303
+ Cursor: Running validation...
304
+ [Runs: vv validate]
305
+
306
+ Cursor: Found 2 TypeScript errors. Fixing...
307
+ [Runs: vv state]
308
+ [Applies fixes]
309
+
310
+ Cursor: Validation now passes. Ready to commit.
311
+ ```
312
+
313
+ ### Cursor Features
314
+
315
+ **Terminal integration:**
316
+ ```bash
317
+ # Set environment variable for Cursor
318
+ export CURSOR=1
319
+
320
+ # Run validation
321
+ npm run validate
322
+ ```
323
+
324
+ **AI chat integration:**
325
+ - Cursor can run shell commands
326
+ - Reads YAML output automatically
327
+ - Suggests fixes based on errors
328
+
329
+ **Editor integration:**
330
+ - Jump to errors with Cmd+Click
331
+ - Inline error display
332
+ - Fix suggestions in editor
333
+
334
+ ---
335
+
336
+ ## Aider Integration
337
+
338
+ **Aider** is a terminal-based AI pair programmer.
339
+
340
+ ### Setup
341
+
342
+ **1. Configure vibe-validate:**
343
+ <!-- config:example -->
344
+ ```yaml
345
+ # vibe-validate.config.yaml
346
+ # Reference: https://github.com/jdutton/vibe-validate/tree/main/packages/cli/config-templates
347
+ git:
348
+ mainBranch: main
349
+ validation:
350
+ phases:
351
+ - name: Testing
352
+ steps:
353
+ - name: Unit Tests
354
+ command: npm test
355
+ ```
356
+
357
+ **2. Create Aider configuration:**
358
+ ```yaml
359
+ # .aider.conf.yml
360
+ edit-format: whole
361
+ auto-commits: false
362
+ dirty-commits: false
363
+
364
+ # Add validation to workflow
365
+ pre-commit-hook: |
366
+ vibe-validate pre-commit
367
+ ```
368
+
369
+ **3. Add shell alias:**
370
+ ```bash
371
+ # ~/.bashrc or ~/.zshrc
372
+ alias validate="AIDER=1 vv validate"
373
+ alias pre-commit="AIDER=1 vv pre-commit"
374
+ ```
375
+
376
+ ### Usage in Aider
377
+
378
+ **Aider session:**
379
+ ```
380
+ You: Run validation and fix errors
381
+
382
+ Aider: Running validation...
383
+ > vv validate
384
+
385
+ Aider: Found TypeScript errors:
386
+ - src/index.ts:42:5 - error TS2322
387
+
388
+ Aider: Fixing src/index.ts...
389
+ [Applies fix]
390
+
391
+ Aider: Re-running validation...
392
+ > vv validate
393
+ ✅ Validation passed
394
+
395
+ You: Great! Commit the changes.
396
+ ```
397
+
398
+ ### Aider Features
399
+
400
+ **Command execution:**
401
+ - Aider runs shell commands directly
402
+ - Reads YAML output from state file
403
+ - Parses errors for fixing
404
+
405
+ **File editing:**
406
+ - Aider edits files based on errors
407
+ - Uses file:line context from extractors
408
+ - Applies fixes systematically
409
+
410
+ **Git integration:**
411
+ - Aider commits changes automatically
412
+ - Pre-commit hook runs validation
413
+ - Prevents bad commits
414
+
415
+ ---
416
+
417
+ ## Continue Integration
418
+
419
+ **Continue** is an open-source AI code assistant for VSCode.
420
+
421
+ ### Setup
422
+
423
+ **1. Configure vibe-validate:**
424
+ <!-- config:example -->
425
+ ```yaml
426
+ # vibe-validate.config.yaml
427
+ # Reference: https://github.com/jdutton/vibe-validate/tree/main/packages/cli/config-templates
428
+ git:
429
+ mainBranch: main
430
+ validation:
431
+ phases:
432
+ - name: Testing
433
+ steps:
434
+ - name: Unit Tests
435
+ command: npm test
436
+ ```
437
+
438
+ **2. Add Continue configuration:**
439
+ ```json
440
+ // .continue/config.json
441
+ {
442
+ "customCommands": [
443
+ {
444
+ "name": "validate",
445
+ "description": "Run vibe-validate validation",
446
+ "prompt": "Run validation and report results:\n\n```\nvibe-validate validate\n```\n\nIf validation fails, run `vibe-validate state` to view errors and fix them."
447
+ },
448
+ {
449
+ "name": "fix-errors",
450
+ "description": "Fix validation errors",
451
+ }
452
+ ]
453
+ }
454
+ ```
455
+
456
+ **3. Add npm scripts:**
457
+ ```json
458
+ {
459
+ "scripts": {
460
+ "validate": "CONTINUE=1 vibe-validate validate",
461
+ "pre-commit": "CONTINUE=1 vibe-validate pre-commit"
462
+ }
463
+ }
464
+ ```
465
+
466
+ ### Usage in Continue
467
+
468
+ **Continue chat:**
469
+ ```
470
+ User: /validate
471
+
472
+ Continue: Running validation...
473
+ [Executes: npm run validate]
474
+
475
+ Continue: Validation failed with 2 errors:
476
+ 1. src/index.ts:42:5 - TypeScript error
477
+ 2. src/auth.ts:128:10 - ESLint warning
478
+
479
+ User: /fix-errors
480
+
481
+ Continue: Reading validation state...
482
+ [Runs: vv state]
483
+
484
+ Continue: Fixing errors...
485
+ [Applies fixes to src/index.ts and src/auth.ts]
486
+
487
+ Continue: Re-validating...
488
+ ✅ All errors fixed! Validation passes.
489
+ ```
490
+
491
+ ### Continue Features
492
+
493
+ **Custom commands:**
494
+ - `/validate` - Run validation
495
+ - `/fix-errors` - Fix validation errors
496
+ - `/pre-commit` - Pre-commit workflow
497
+
498
+ **File context:**
499
+ - Continue understands file:line references
500
+ - Opens files automatically
501
+ - Applies fixes in context
502
+
503
+ **Terminal integration:**
504
+ - Runs npm scripts
505
+ - Reads YAML output
506
+ - Parses error messages
507
+
508
+ ---
509
+
510
+ ## Custom Agent Integration
511
+
512
+ Integrate vibe-validate with your own AI tools or scripts.
513
+
514
+ ### Step 1: Set Environment Variable
515
+
516
+ ```bash
517
+ # Set custom agent detection (optional)
518
+ export MY_AGENT=1
519
+ ```
520
+
521
+ ### Step 2: Run Validation
522
+
523
+ ```bash
524
+ vibe-validate validate
525
+ ```
526
+
527
+ ### Step 3: Read Validation State
528
+
529
+ ```bash
530
+ # View validation state (YAML output)
531
+ vibe-validate state
532
+ ```
533
+
534
+ **State output structure:**
535
+ <!-- validation-result:example -->
536
+ ```yaml
537
+ passed: false
538
+ timestamp: 2025-10-16T15:30:00.000Z
539
+ treeHash: a1b2c3d4e5f6789abc123def456
540
+ summary: "TypeScript type check failed"
541
+ phases:
542
+ - name: "Pre-Qualification"
543
+ passed: false
544
+ durationSecs: 5.2
545
+ steps:
546
+ - name: "TypeScript"
547
+ command: "pnpm typecheck"
548
+ exitCode: 1
549
+ durationSecs: 5.2
550
+ passed: false
551
+ extraction:
552
+ errors:
553
+ - file: src/index.ts
554
+ line: 42
555
+ column: 5
556
+ message: "error TS2322: Type 'string' is not assignable to type 'number'"
557
+ summary: "1 type error"
558
+ totalErrors: 1
559
+ ```
560
+
561
+ **Note**: Validation state is stored in git notes (not files). Always use `vibe-validate state` to query.
562
+
563
+ ### Step 4: Parse and Act
564
+
565
+ **Python example:**
566
+ ```python
567
+ import yaml
568
+ import subprocess
569
+
570
+ # Run validation
571
+ result = subprocess.run(
572
+ ['vibe-validate', 'validate'],
573
+ capture_output=True,
574
+ env={'MY_AGENT': '1'}
575
+ )
576
+
577
+ # Read state via command (YAML output)
578
+ state_output = subprocess.run(
579
+ ['vibe-validate', 'state'],
580
+ capture_output=True,
581
+ text=True
582
+ ).stdout
583
+
584
+ state = yaml.safe_load(state_output)
585
+
586
+ if not state['passed']:
587
+ # Extract errors from failed steps
588
+ failed_steps = [
589
+ step for phase in state['phases']
590
+ for step in phase['steps']
591
+ if not step['passed']
592
+ ]
593
+
594
+ for step in failed_steps:
595
+ print(f"Failed step: {step['name']}")
596
+ if 'extraction' in step and 'errors' in step['extraction']:
597
+ for error in step['extraction']['errors']:
598
+ print(f" {error['file']}:{error['line']} - {error['message']}")
599
+
600
+ # AI agent fixes errors here
601
+ # ...
602
+
603
+ # Re-validate (fast with caching!)
604
+ subprocess.run(['vibe-validate', 'validate'])
605
+ ```
606
+
607
+ **Node.js example:**
608
+ ```typescript
609
+ import { execSync } from 'child_process';
610
+ import yaml from 'yaml';
611
+
612
+ // Run validation
613
+ try {
614
+ execSync('vibe-validate validate', {
615
+ env: { ...process.env, MY_AGENT: '1' },
616
+ });
617
+ } catch (error) {
618
+ // Validation failed
619
+ }
620
+
621
+ // Read state via command (YAML output)
622
+ const stateOutput = execSync('vibe-validate state', { encoding: 'utf-8' });
623
+ const state = yaml.parse(stateOutput);
624
+
625
+ if (!state.passed) {
626
+ // Extract errors from failed steps
627
+ const failedSteps = state.phases
628
+ .flatMap(phase => phase.steps)
629
+ .filter(step => !step.passed);
630
+
631
+ for (const step of failedSteps) {
632
+ console.log(`Failed step: ${step.name}`);
633
+ if (step.extraction?.errors) {
634
+ for (const error of step.extraction.errors) {
635
+ console.log(` ${error.file}:${error.line} - ${error.message}`);
636
+ }
637
+ }
638
+ }
639
+
640
+ // AI agent processes errors
641
+ const allErrors = failedSteps.flatMap(step => step.extraction?.errors || []);
642
+ const fixes = await aiAgent.fixErrors(allErrors);
643
+
644
+ // Apply fixes
645
+ await applyFixes(fixes);
646
+
647
+ // Re-validate (fast with caching!)
648
+ execSync('vibe-validate validate');
649
+ }
650
+ ```
651
+
652
+ ### Step 5: Handle Exit Codes
653
+
654
+ ```bash
655
+ # Check exit code
656
+ vibe-validate validate
657
+ EXIT_CODE=$?
658
+
659
+ if [ $EXIT_CODE -eq 0 ]; then
660
+ echo "Validation passed"
661
+ elif [ $EXIT_CODE -eq 1 ]; then
662
+ echo "Validation failed - fix errors"
663
+ vibe-validate state
664
+ elif [ $EXIT_CODE -eq 2 ]; then
665
+ echo "Configuration error"
666
+ fi
667
+ ```
668
+
669
+ ---
670
+
671
+ ## Best Practices
672
+
673
+
674
+ ### 2. Leverage Caching for Iteration
675
+
676
+ Validation caching enables fast iteration:
677
+
678
+ ```typescript
679
+ // First run: ~90 seconds (full validation)
680
+ await validate();
681
+
682
+ // Fix errors
683
+ await fixErrors();
684
+
685
+ // Second run: ~300ms (cached, only changed files)
686
+ await validate();
687
+ ```
688
+
689
+ **Typical workflow:**
690
+ - 1st run: Full validation (slow)
691
+ - Fix 1-2 errors
692
+ - 2nd run: Cached validation (fast!)
693
+ - Repeat until all errors fixed
694
+
695
+ ### 3. Implement Pre-Commit Workflow
696
+
697
+ Prevent bad commits with pre-commit validation:
698
+
699
+ ```bash
700
+ # .git/hooks/pre-commit
701
+ #!/bin/sh
702
+ vibe-validate pre-commit
703
+
704
+ if [ $? -ne 0 ]; then
705
+ echo "❌ Pre-commit validation failed"
706
+ echo "Fix errors before committing"
707
+ exit 1
708
+ fi
709
+ ```
710
+
711
+ **Agent workflow:**
712
+ ```typescript
713
+ async function commitChanges(message: string) {
714
+ // Run pre-commit validation
715
+ const result = await preCommit();
716
+
717
+ if (!result.passed) {
718
+ // Fix errors automatically
719
+ await fixErrors(result.errors);
720
+
721
+ // Re-validate
722
+ await preCommit();
723
+ }
724
+
725
+ // Commit if validation passes
726
+ await git.commit(message);
727
+ }
728
+ ```
729
+
730
+ ### 4. Use Structured Output
731
+
732
+ Always use YAML or JSON for agent parsing:
733
+
734
+ ```bash
735
+ # Good: Structured output
736
+ vibe-validate validate --yaml
737
+
738
+ # Less good: Human-readable output
739
+ vibe-validate validate --human
740
+ ```
741
+
742
+ **Why structured output:**
743
+ - ✅ Easy to parse programmatically
744
+ - ✅ No ambiguity (no color codes)
745
+ - ✅ Complete error context
746
+ - ✅ Ready-to-use prompts
747
+
748
+ ### 5. Monitor Validation Performance
749
+
750
+ Track validation performance for optimization:
751
+
752
+ ```typescript
753
+ const start = Date.now();
754
+ await validate();
755
+ const duration = Date.now() - start;
756
+
757
+ if (duration > 10000) {
758
+ console.warn('Validation slow - consider optimizing');
759
+ }
760
+ ```
761
+
762
+ **Optimization strategies:**
763
+ - Enable parallel execution
764
+ - Use fail-fast ordering
765
+ - Cache validation state
766
+ - Incremental validation (future)
767
+
768
+ ### 6. Handle Edge Cases
769
+
770
+ **Network failures:**
771
+ ```typescript
772
+ try {
773
+ await validate();
774
+ } catch (error) {
775
+ if (error.code === 'ECONNREFUSED') {
776
+ console.error('Network error - skip validation');
777
+ return { passed: true }; // Allow commit
778
+ }
779
+ throw error;
780
+ }
781
+ ```
782
+
783
+ **Git repository issues:**
784
+ ```typescript
785
+ const state = await validate();
786
+
787
+ if (state.error === 'Not a git repository') {
788
+ console.warn('Git not available - skip tree hash caching');
789
+ // Fall back to timestamp-based caching
790
+ }
791
+ ```
792
+
793
+ ---
794
+
795
+ ## Advanced Integration Patterns
796
+
797
+ ### Pattern: Progressive Error Fixing
798
+
799
+ Fix errors progressively based on priority:
800
+
801
+ ```typescript
802
+ async function fixErrorsProgressively() {
803
+ let iteration = 0;
804
+ const maxIterations = 10;
805
+
806
+ while (iteration < maxIterations) {
807
+ const state = await validate();
808
+
809
+ if (state.passed) {
810
+ console.log(`✅ All errors fixed in ${iteration} iterations`);
811
+ break;
812
+ }
813
+
814
+ // Extract errors from failed steps
815
+ const errors = state.phases
816
+ .flatMap(phase => phase.steps)
817
+ .filter(step => !step.passed)
818
+ .flatMap(step => step.extraction?.errors || []);
819
+
820
+ // Sort by priority (TypeScript errors first)
821
+ const sortedErrors = sortByPriority(errors);
822
+
823
+ // Fix top 3 errors only
824
+ const topErrors = sortedErrors.slice(0, 3);
825
+ await fixErrors(topErrors);
826
+
827
+ iteration++;
828
+ }
829
+ }
830
+ ```
831
+
832
+ ### Pattern: Multi-Agent Collaboration
833
+
834
+ Multiple agents collaborate on fixing errors:
835
+
836
+ ```typescript
837
+ async function multiAgentFix() {
838
+ const state = await validate();
839
+
840
+ if (state.passed) return;
841
+
842
+ // Route errors to specialized agents
843
+ const typescriptErrors = filterByType(state.errors, 'typescript');
844
+ const eslintErrors = filterByType(state.errors, 'eslint');
845
+ const testErrors = filterByType(state.errors, 'test');
846
+
847
+ // Parallel fixing
848
+ await Promise.all([
849
+ typescriptAgent.fix(typescriptErrors),
850
+ eslintAgent.fix(eslintErrors),
851
+ testAgent.fix(testErrors),
852
+ ]);
853
+
854
+ // Re-validate
855
+ await validate();
856
+ }
857
+ ```
858
+
859
+ ### Pattern: Learning from Fixes
860
+
861
+ Track fixes for pattern recognition:
862
+
863
+ ```typescript
864
+ interface FixRecord {
865
+ error: string;
866
+ fix: string;
867
+ timestamp: Date;
868
+ }
869
+
870
+ const fixHistory: FixRecord[] = [];
871
+
872
+ async function learnFromFixes() {
873
+ const state = await validate();
874
+
875
+ if (!state.passed) {
876
+ const fixes = await suggestFixes(state.errors);
877
+
878
+ for (const fix of fixes) {
879
+ // Apply fix
880
+ await applyFix(fix);
881
+
882
+ // Record for learning
883
+ fixHistory.push({
884
+ error: fix.error,
885
+ fix: fix.solution,
886
+ timestamp: new Date(),
887
+ });
888
+ }
889
+ }
890
+
891
+ // Use history for better suggestions
892
+ const patterns = analyzePatterns(fixHistory);
893
+ await updateSuggestionModel(patterns);
894
+ }
895
+ ```
896
+
897
+ ---
898
+
899
+ ## Troubleshooting
900
+
901
+ ### "State file not found"
902
+
903
+ **Solution**: Run validation first to create state file:
904
+ ```bash
905
+ vibe-validate validate
906
+ vibe-validate validate --check
907
+ ```
908
+
909
+ ### "Agent fixes don't work"
910
+
911
+ **Solution**: Check error format in state output:
912
+ ```bash
913
+ vibe-validate state | grep -A 10 "Failed step"
914
+ ```
915
+
916
+ Ensure error extractors are working correctly (see [Error Extractors Guide](./error-extractors-guide.md)).
917
+
918
+ ---
919
+
920
+ ## Related Documentation
921
+
922
+ - [Getting Started Guide](./getting-started.md)
923
+ - [Configuration Reference](./configuration-reference.md)
924
+ - [CLI Reference](./cli-reference.md)
925
+ - [Config Templates Guide](./../config-templates/README.md)
926
+ - [Error Extractors Guide](./error-extractors-guide.md)
927
+
928
+ ---
929
+
930
+ ## See Also
931
+
932
+ - [Claude Code Documentation](https://claude.ai/code)
933
+ - [Cursor Documentation](https://cursor.sh)
934
+ - [Aider Documentation](https://aider.chat)
935
+ - [Continue Documentation](https://continue.dev)
936
+ - [vibe-validate GitHub](https://github.com/yourusername/vibe-validate)