vibe-validate 0.17.1-rc.3 → 0.17.2
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/package.json +3 -4
- package/skill/SKILL.md +79 -364
- package/skill/resources/agent-integration-guide.md +936 -0
- package/skill/resources/caching-internals.md +366 -0
- package/skill/resources/cli-reference.md +10 -0
- package/skill/resources/configure-project.md +1 -1
- package/skill/resources/run-capability.md +2 -2
- package/skill/resources/work-recovery.md +233 -0
- package/skill/resources/workflows.md +504 -0
- package/scripts/uninstall-skill.js +0 -41
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
# Caching Internals: Performance & How It Works
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
vibe-validate achieves **dramatic speedup** through git-aware caching using content-based hashing. This document explains how the caching system works internally and how to leverage it for maximum performance.
|
|
6
|
+
|
|
7
|
+
## Core Concept: Git Tree Hashing
|
|
8
|
+
|
|
9
|
+
### What is a tree hash?
|
|
10
|
+
|
|
11
|
+
A **tree hash** is git's way of creating a deterministic fingerprint of your working directory:
|
|
12
|
+
- Content-based (same files = same hash)
|
|
13
|
+
- No timestamps (purely about file contents)
|
|
14
|
+
- Includes untracked files (not just committed code)
|
|
15
|
+
- Deterministic (same state always produces same hash)
|
|
16
|
+
|
|
17
|
+
### How vibe-validate uses tree hashes
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# Behind the scenes on every validation:
|
|
21
|
+
git add --intent-to-add . # Stage untracked files
|
|
22
|
+
git write-tree # Generate tree hash
|
|
23
|
+
# Returns: abc123def456... (40-character SHA-1)
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
This tree hash becomes the **cache key** for validation results.
|
|
27
|
+
|
|
28
|
+
## Performance Numbers
|
|
29
|
+
|
|
30
|
+
Real-world measurements from vibe-validate development:
|
|
31
|
+
|
|
32
|
+
| Scenario | Time | Speedup |
|
|
33
|
+
|----------|------|---------|
|
|
34
|
+
| **Cache miss** (first run) | ~90 seconds | 1x (baseline) |
|
|
35
|
+
| **Cache hit** (no changes) | < 1 second | **Dramatically faster** |
|
|
36
|
+
| **Partial cache** (1 file changed) | ~5-10 seconds | Faster re-validation |
|
|
37
|
+
|
|
38
|
+
## Cache Key: What Invalidates Cache?
|
|
39
|
+
|
|
40
|
+
### Cache invalidates when:
|
|
41
|
+
- ✅ Any file content changes
|
|
42
|
+
- ✅ New files added (even untracked)
|
|
43
|
+
- ✅ Files deleted
|
|
44
|
+
- ✅ File renamed
|
|
45
|
+
- ✅ Working tree modifications
|
|
46
|
+
|
|
47
|
+
### Cache persists when:
|
|
48
|
+
- ✅ Switching branches (if same code state)
|
|
49
|
+
- ✅ Git operations (commits, merges) that result in same tree
|
|
50
|
+
- ✅ Time passing (content-based, not time-based)
|
|
51
|
+
- ✅ .gitignore changes (ignored files not in tree hash)
|
|
52
|
+
|
|
53
|
+
## How Caching Works: Step by Step
|
|
54
|
+
|
|
55
|
+
### First Run (Cache Miss)
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
$ vv validate
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
1. **Calculate tree hash**: `git write-tree` → `abc123`
|
|
62
|
+
2. **Check cache**: Look for `refs/notes/vibe-validate/validation/abc123`
|
|
63
|
+
3. **Cache miss**: No notes found
|
|
64
|
+
4. **Execute validation**: Run all phases (90 seconds)
|
|
65
|
+
5. **Store result**: Save to `refs/notes/vibe-validate/validation/abc123`
|
|
66
|
+
|
|
67
|
+
### Second Run (Cache Hit)
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
$ vv validate
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
1. **Calculate tree hash**: `git write-tree` → `abc123` (same!)
|
|
74
|
+
2. **Check cache**: Look for `refs/notes/vibe-validate/validation/abc123`
|
|
75
|
+
3. **Cache hit!**: Found notes with previous result
|
|
76
|
+
4. **Return cached result**: No execution needed (288ms)
|
|
77
|
+
|
|
78
|
+
### After Code Change (Partial Cache)
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
# Edit one file
|
|
82
|
+
$ vv validate
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
1. **Calculate tree hash**: `git write-tree` → `def456` (different!)
|
|
86
|
+
2. **Check cache**: Look for `refs/notes/vibe-validate/validation/def456`
|
|
87
|
+
3. **Cache miss**: No notes found for new tree hash
|
|
88
|
+
4. **Execute validation**: Run all phases again
|
|
89
|
+
5. **Store result**: Save to `refs/notes/vibe-validate/validation/def456`
|
|
90
|
+
|
|
91
|
+
## Cache Storage: Git Notes
|
|
92
|
+
|
|
93
|
+
vibe-validate uses **git notes** for cache storage:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
# View validation cache
|
|
97
|
+
git notes --ref=refs/notes/vibe-validate/validation list
|
|
98
|
+
|
|
99
|
+
# View specific cached result
|
|
100
|
+
git notes --ref=refs/notes/vibe-validate/validation show <tree-hash>
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Why git notes?
|
|
104
|
+
|
|
105
|
+
- ✅ Built into git (no external dependencies)
|
|
106
|
+
- ✅ Survives branch switches
|
|
107
|
+
- ✅ Works across clones (can be pushed/pulled)
|
|
108
|
+
- ✅ Content-addressable (perfect for caching)
|
|
109
|
+
- ✅ Garbage collected automatically by git
|
|
110
|
+
|
|
111
|
+
## Run Command Caching (v0.15.0+)
|
|
112
|
+
|
|
113
|
+
The `vv run` command has its own cache layer:
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
# First run - cache miss
|
|
117
|
+
vv run "npm test" # Executes (~30s)
|
|
118
|
+
|
|
119
|
+
# Repeat run - cache hit
|
|
120
|
+
vv run "npm test" # Instant (<200ms)
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Cache key for run command
|
|
124
|
+
|
|
125
|
+
Tree hash + command string:
|
|
126
|
+
```
|
|
127
|
+
cache_key = hash(tree_hash + "npm test")
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Stored in: `refs/notes/vibe-validate/run/<tree-hash>/<command-hash>`
|
|
131
|
+
|
|
132
|
+
## Leveraging Caching for Speed
|
|
133
|
+
|
|
134
|
+
### Pattern 1: Incremental Fixes
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
# First run: Full validation (~90s)
|
|
138
|
+
vv validate
|
|
139
|
+
|
|
140
|
+
# Fix 1-2 errors in one file
|
|
141
|
+
# Second run: New tree hash, re-validate
|
|
142
|
+
vv validate # (~90s again, but working toward green)
|
|
143
|
+
|
|
144
|
+
# Fix is correct, no more changes
|
|
145
|
+
# Third run: Cache hit!
|
|
146
|
+
vv validate # (288ms - instant!)
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Pattern 2: Fast Feedback Loop
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
# Use `run` for tight feedback during development
|
|
153
|
+
vv run "npm test -- src/feature.test.ts" # First run (~5s)
|
|
154
|
+
|
|
155
|
+
# Make change
|
|
156
|
+
vv run "npm test -- src/feature.test.ts" # Re-runs (~5s)
|
|
157
|
+
|
|
158
|
+
# No changes, verify still passes
|
|
159
|
+
vv run "npm test -- src/feature.test.ts" # Cache hit! (200ms)
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Pattern 3: Branch Switching
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
# On feature branch
|
|
166
|
+
vv validate # Cache result for feature code
|
|
167
|
+
|
|
168
|
+
# Switch to main
|
|
169
|
+
git checkout main
|
|
170
|
+
vv validate # Cache result for main code
|
|
171
|
+
|
|
172
|
+
# Switch back to feature
|
|
173
|
+
git checkout feature
|
|
174
|
+
vv validate # Cache hit! (same tree hash as before)
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Cache Control
|
|
178
|
+
|
|
179
|
+
### Check cache without running
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
# Check if validation is cached
|
|
183
|
+
vv validate --check
|
|
184
|
+
# Exit 0: cached (green)
|
|
185
|
+
# Exit 1: not cached (need to run)
|
|
186
|
+
|
|
187
|
+
# Check if run command is cached
|
|
188
|
+
vv run --check "npm test"
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### Force cache refresh
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
# Force re-validation (ignore cache)
|
|
195
|
+
vv validate --force
|
|
196
|
+
|
|
197
|
+
# Force re-run (ignore cache)
|
|
198
|
+
vv run --force "npm test"
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### View cache state
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
# Show current validation state
|
|
205
|
+
vv state
|
|
206
|
+
|
|
207
|
+
# List all cached validations
|
|
208
|
+
vv history list
|
|
209
|
+
|
|
210
|
+
# List cached run commands
|
|
211
|
+
vv history list --run
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### Prune old cache
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
# Clear all validation history
|
|
218
|
+
vv history prune --all
|
|
219
|
+
|
|
220
|
+
# Clear only run cache
|
|
221
|
+
vv history prune --run --all
|
|
222
|
+
|
|
223
|
+
# Clear run cache for specific tree hash
|
|
224
|
+
vv history prune --run --tree <tree-hash>
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
## Cache Misses: Common Causes
|
|
228
|
+
|
|
229
|
+
### 1. Timestamp-based files
|
|
230
|
+
|
|
231
|
+
**Problem**: Build artifacts with timestamps always change tree hash
|
|
232
|
+
|
|
233
|
+
```bash
|
|
234
|
+
# dist/bundle.js includes timestamp
|
|
235
|
+
# Tree hash changes every build even if source unchanged
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
**Solution**: Add to .gitignore
|
|
239
|
+
```bash
|
|
240
|
+
echo "dist/" >> .gitignore
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
### 2. Lock file changes
|
|
244
|
+
|
|
245
|
+
**Problem**: `package-lock.json` or `pnpm-lock.yaml` updates cause cache invalidation
|
|
246
|
+
|
|
247
|
+
**Solution**: This is intentional! Dependencies changed = new validation needed.
|
|
248
|
+
|
|
249
|
+
### 3. Untracked generated files
|
|
250
|
+
|
|
251
|
+
**Problem**: Test coverage files, .tsbuildinfo, etc.
|
|
252
|
+
|
|
253
|
+
**Solution**: Add to .gitignore
|
|
254
|
+
```bash
|
|
255
|
+
.tsbuildinfo
|
|
256
|
+
coverage/
|
|
257
|
+
.vitest/
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
## Debugging Cache Issues
|
|
261
|
+
|
|
262
|
+
### Validation always runs (never cached)
|
|
263
|
+
|
|
264
|
+
```bash
|
|
265
|
+
# Check if in git repository
|
|
266
|
+
git status
|
|
267
|
+
|
|
268
|
+
# Check current tree hash
|
|
269
|
+
git write-tree
|
|
270
|
+
|
|
271
|
+
# Check if validation cached for current tree
|
|
272
|
+
vv validate --check
|
|
273
|
+
echo $? # 0 = cached, 1 = not cached
|
|
274
|
+
|
|
275
|
+
# See what's changing
|
|
276
|
+
git status --short
|
|
277
|
+
git diff
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
### Cache seems stale
|
|
281
|
+
|
|
282
|
+
```bash
|
|
283
|
+
# Check current tree hash
|
|
284
|
+
current=$(git write-tree)
|
|
285
|
+
|
|
286
|
+
# Check cached tree hash
|
|
287
|
+
vv state | grep treeHash
|
|
288
|
+
|
|
289
|
+
# Compare
|
|
290
|
+
if [ "$current" != "$cached" ]; then
|
|
291
|
+
echo "Tree changed - cache correctly invalidated"
|
|
292
|
+
fi
|
|
293
|
+
|
|
294
|
+
# Force refresh if needed
|
|
295
|
+
vv validate --force
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
### Performance slower than expected
|
|
299
|
+
|
|
300
|
+
```bash
|
|
301
|
+
# Run with timing
|
|
302
|
+
time vv validate
|
|
303
|
+
|
|
304
|
+
# If > 1 second on cache hit:
|
|
305
|
+
# 1. Check git objects size: du -sh .git/objects
|
|
306
|
+
# 2. Run git gc: git gc --aggressive
|
|
307
|
+
# 3. Check disk I/O: iostat
|
|
308
|
+
|
|
309
|
+
# If still slow, check:
|
|
310
|
+
vv doctor
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
## Advanced: Cache Implementation Details
|
|
314
|
+
|
|
315
|
+
### Tree hash calculation
|
|
316
|
+
|
|
317
|
+
```typescript
|
|
318
|
+
// Simplified implementation
|
|
319
|
+
function getTreeHash(): string {
|
|
320
|
+
// Stage untracked files (intent-to-add, doesn't change index)
|
|
321
|
+
execSync('git add --intent-to-add .');
|
|
322
|
+
|
|
323
|
+
// Generate tree hash from current index
|
|
324
|
+
const treeHash = execSync('git write-tree').toString().trim();
|
|
325
|
+
|
|
326
|
+
// Unstage (cleanup)
|
|
327
|
+
execSync('git reset');
|
|
328
|
+
|
|
329
|
+
return treeHash;
|
|
330
|
+
}
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
### Cache lookup
|
|
334
|
+
|
|
335
|
+
```typescript
|
|
336
|
+
function getCachedValidation(treeHash: string): ValidationResult | null {
|
|
337
|
+
const notesRef = `refs/notes/vibe-validate/validation`;
|
|
338
|
+
|
|
339
|
+
try {
|
|
340
|
+
const cached = execSync(
|
|
341
|
+
`git notes --ref=${notesRef} show ${treeHash}`
|
|
342
|
+
).toString();
|
|
343
|
+
|
|
344
|
+
return JSON.parse(cached);
|
|
345
|
+
} catch {
|
|
346
|
+
return null; // Cache miss
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
### Cache storage
|
|
352
|
+
|
|
353
|
+
```typescript
|
|
354
|
+
function cacheValidation(treeHash: string, result: ValidationResult): void {
|
|
355
|
+
const notesRef = `refs/notes/vibe-validate/validation`;
|
|
356
|
+
const data = JSON.stringify(result);
|
|
357
|
+
|
|
358
|
+
execSync(`git notes --ref=${notesRef} add -f -m '${data}' ${treeHash}`);
|
|
359
|
+
}
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
## See Also
|
|
363
|
+
|
|
364
|
+
- [Run Capability Guide](run-capability.md) - Deep dive on `vv run` caching
|
|
365
|
+
- [CLI Reference](cli-reference.md) - Cache control flags
|
|
366
|
+
- [Troubleshooting Guide](troubleshooting.md) - Cache issues
|
|
@@ -185,6 +185,16 @@ vibe-validate state --verbose # Show full error output
|
|
|
185
185
|
|
|
186
186
|
---
|
|
187
187
|
|
|
188
|
+
### `snapshot`
|
|
189
|
+
|
|
190
|
+
Show current worktree snapshot and recovery instructions
|
|
191
|
+
|
|
192
|
+
**Options:**
|
|
193
|
+
|
|
194
|
+
- `-v, --verbose` - Show detailed snapshot information
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
188
198
|
### `sync-check`
|
|
189
199
|
|
|
190
200
|
Check if branch is behind remote main branch
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
Configure your project to use vibe-validate for comprehensive validation with:
|
|
6
6
|
- **Pre-commit validation** guardrails (prevent broken code from being committed)
|
|
7
|
-
- **Git-aware caching** (
|
|
7
|
+
- **Git-aware caching** (dramatic speedup)
|
|
8
8
|
- **Team-wide consistency** (shared validation configuration)
|
|
9
9
|
- **CI/CD integration** (same validation locally and in CI)
|
|
10
10
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
## Overview
|
|
4
4
|
|
|
5
5
|
The `vv run` capability provides **immediate benefits without any project configuration**. Just wrap any command to get:
|
|
6
|
-
- **
|
|
6
|
+
- **Dramatic speedup** via git tree hash caching
|
|
7
7
|
- **95% token reduction** via smart error extraction
|
|
8
8
|
- **Zero configuration** required
|
|
9
9
|
|
|
@@ -42,7 +42,7 @@ vv run ./gradlew build
|
|
|
42
42
|
vv run npm test
|
|
43
43
|
|
|
44
44
|
# Second run (no code changes): uses cache
|
|
45
|
-
vv run npm test # Instant! (
|
|
45
|
+
vv run npm test # Instant! (dramatically faster)
|
|
46
46
|
|
|
47
47
|
# After code change: re-runs automatically
|
|
48
48
|
vv run npm test # Executes again
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
# Work Recovery & Protection
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
vibe-validate automatically creates **recoverable snapshots** of your work during validation. Every time you run `vv validate`, `vv pre-commit`, or `vv run`, a git tree hash is created that captures your complete working directory state - including untracked files.
|
|
6
|
+
|
|
7
|
+
## What Gets Protected
|
|
8
|
+
|
|
9
|
+
Automatic snapshots include:
|
|
10
|
+
- ✅ **Staged changes** (in git index)
|
|
11
|
+
- ✅ **Unstaged modifications** (tracked files)
|
|
12
|
+
- ✅ **Untracked files** (new files, not in .gitignore)
|
|
13
|
+
|
|
14
|
+
Not protected (by design):
|
|
15
|
+
- ❌ Files in .gitignore (secrets, build artifacts)
|
|
16
|
+
|
|
17
|
+
## When Snapshots Are Created
|
|
18
|
+
|
|
19
|
+
Automatic snapshots happen during:
|
|
20
|
+
- `vv validate` - Full validation pipeline
|
|
21
|
+
- `vv pre-commit` - Pre-commit workflow
|
|
22
|
+
- `vv run <command>` - Individual command execution (v0.15.0+)
|
|
23
|
+
|
|
24
|
+
Each creates a tree hash in git objects that captures complete working directory state at that moment.
|
|
25
|
+
|
|
26
|
+
## View Validation Snapshots
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
# List all validation points (timestamped tree hashes)
|
|
30
|
+
vv history list
|
|
31
|
+
|
|
32
|
+
# Show details of specific validation
|
|
33
|
+
vv history show <tree-hash>
|
|
34
|
+
|
|
35
|
+
# YAML output for programmatic access
|
|
36
|
+
vv history list --yaml
|
|
37
|
+
|
|
38
|
+
# Limit to recent validations
|
|
39
|
+
vv history list --limit 10
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Recover Lost Work
|
|
43
|
+
|
|
44
|
+
### Scenario: Accidentally deleted files or ran `git restore .`
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
# Step 1: Find recent validation point
|
|
48
|
+
vv history list --limit 5
|
|
49
|
+
|
|
50
|
+
# Step 2: View file content from that validation
|
|
51
|
+
git cat-file -p <tree-hash>:path/to/file.ts
|
|
52
|
+
|
|
53
|
+
# Step 3: Recover the file
|
|
54
|
+
git cat-file -p <tree-hash>:path/to/file.ts > path/to/file.ts
|
|
55
|
+
|
|
56
|
+
# Or recover entire directory
|
|
57
|
+
git checkout <tree-hash> -- src/
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Important Notes
|
|
61
|
+
|
|
62
|
+
- Tree hashes are permanent in git objects database
|
|
63
|
+
- Even if you delete branches, tree hashes remain
|
|
64
|
+
- Use `vv history list` to find the right snapshot
|
|
65
|
+
- Recovery works even days/weeks later
|
|
66
|
+
|
|
67
|
+
## Compare Code States
|
|
68
|
+
|
|
69
|
+
### See what changed between two validation points
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
# Compare two tree hashes
|
|
73
|
+
git diff <old-tree-hash> <new-tree-hash>
|
|
74
|
+
|
|
75
|
+
# Compare specific file between validations
|
|
76
|
+
git diff <old-tree-hash>:<file> <new-tree-hash>:<file>
|
|
77
|
+
|
|
78
|
+
# Show what files changed
|
|
79
|
+
git diff --name-status <old-tree-hash> <new-tree-hash>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## View Files in Snapshot
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
# List all files in a tree hash
|
|
86
|
+
git ls-tree -r <tree-hash>
|
|
87
|
+
|
|
88
|
+
# List specific directory
|
|
89
|
+
git ls-tree -r <tree-hash> src/
|
|
90
|
+
|
|
91
|
+
# View specific file
|
|
92
|
+
git cat-file -p <tree-hash>:src/feature.ts
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Common Recovery Patterns
|
|
96
|
+
|
|
97
|
+
### Pattern 1: Undo Recent Changes
|
|
98
|
+
|
|
99
|
+
**Use case**: Made changes that broke everything, want to go back to last working state
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
# List recent validations
|
|
103
|
+
vv history list --limit 10
|
|
104
|
+
|
|
105
|
+
# Pick validation from before bad changes
|
|
106
|
+
# Recover all affected files
|
|
107
|
+
git checkout <good-tree-hash> -- src/
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Pattern 2: Cherry-pick Deleted File
|
|
111
|
+
|
|
112
|
+
**Use case**: Accidentally deleted a file, need just that one file back
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
# Find validation when file existed
|
|
116
|
+
vv history list
|
|
117
|
+
|
|
118
|
+
# Look for validation timestamp before deletion
|
|
119
|
+
# Recover just that file
|
|
120
|
+
git cat-file -p <tree-hash>:path/to/deleted.ts > path/to/deleted.ts
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Pattern 3: Compare Before/After Refactoring
|
|
124
|
+
|
|
125
|
+
**Use case**: Did major refactoring, want to see all changes or partially revert
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
# Before refactoring validation: abc123
|
|
129
|
+
# After refactoring validation: def456
|
|
130
|
+
|
|
131
|
+
# See all changes
|
|
132
|
+
git diff abc123 def456
|
|
133
|
+
|
|
134
|
+
# See just filenames that changed
|
|
135
|
+
git diff --name-status abc123 def456
|
|
136
|
+
|
|
137
|
+
# If refactoring went wrong, revert specific files
|
|
138
|
+
git checkout abc123 -- src/refactored-file.ts
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Pattern 4: Recover After Branch Switch
|
|
142
|
+
|
|
143
|
+
**Use case**: Switched branches and lost uncommitted work
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
# Find validation from before branch switch
|
|
147
|
+
vv history list --limit 20
|
|
148
|
+
|
|
149
|
+
# Look for validation on old branch
|
|
150
|
+
# Recover entire working directory state
|
|
151
|
+
git checkout <tree-hash> -- .
|
|
152
|
+
|
|
153
|
+
# Or just specific directory
|
|
154
|
+
git checkout <tree-hash> -- src/
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Troubleshooting Recovery
|
|
158
|
+
|
|
159
|
+
### "I can't find my validation"
|
|
160
|
+
|
|
161
|
+
**Check:**
|
|
162
|
+
1. Did you run `vv validate`, `vv pre-commit`, or `vv run` before losing the work?
|
|
163
|
+
2. Look further back: `vv history list --limit 50`
|
|
164
|
+
3. Check if in different git repository
|
|
165
|
+
|
|
166
|
+
**If validation wasn't run**: Work might not be recoverable via vibe-validate. Try:
|
|
167
|
+
- `git reflog` - Shows git history including deleted commits
|
|
168
|
+
- File recovery tools (OS-level)
|
|
169
|
+
- IDE local history (VS Code, IntelliJ, etc.)
|
|
170
|
+
|
|
171
|
+
### "Tree hash doesn't exist"
|
|
172
|
+
|
|
173
|
+
**Error**: `fatal: Not a valid object name`
|
|
174
|
+
|
|
175
|
+
**Solutions:**
|
|
176
|
+
1. Verify tree hash is correct (copy-paste from `vv history list`)
|
|
177
|
+
2. Check if in correct git repository
|
|
178
|
+
3. Try `git fsck --full` to verify git objects database
|
|
179
|
+
|
|
180
|
+
### "How long are snapshots kept?"
|
|
181
|
+
|
|
182
|
+
**Answer**: Indefinitely in git objects database until you run `git gc` (garbage collection).
|
|
183
|
+
|
|
184
|
+
**To manually prune old snapshots**:
|
|
185
|
+
```bash
|
|
186
|
+
# Clear all validation history (CAREFUL!)
|
|
187
|
+
vv history prune --all
|
|
188
|
+
|
|
189
|
+
# Clear only run cache
|
|
190
|
+
vv history prune --run --all
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
## Best Practices
|
|
194
|
+
|
|
195
|
+
1. **Run validation frequently** - More snapshots = more recovery points
|
|
196
|
+
2. **Check history before panic** - `vv history list` shows what's recoverable
|
|
197
|
+
3. **Recover incrementally** - Cherry-pick files rather than recovering everything
|
|
198
|
+
4. **Test recovery on scratch branch** - Don't overwrite current work
|
|
199
|
+
5. **Keep validation habit** - Treat validation as "save point" in your workflow
|
|
200
|
+
|
|
201
|
+
## Advanced: Direct Git Object Access
|
|
202
|
+
|
|
203
|
+
### Understanding tree hashes
|
|
204
|
+
|
|
205
|
+
Tree hashes are git's way of storing directory snapshots. They're content-addressable - same content always produces same hash.
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
# View tree structure
|
|
209
|
+
git cat-file -p <tree-hash>
|
|
210
|
+
|
|
211
|
+
# Output shows:
|
|
212
|
+
# 100644 blob abc123 README.md
|
|
213
|
+
# 040000 tree def456 src
|
|
214
|
+
# (permissions) (type) (hash) (name)
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### Recovering from bare tree hash
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
# Create temporary index from tree
|
|
221
|
+
GIT_INDEX_FILE=.git/index.tmp git read-tree <tree-hash>
|
|
222
|
+
|
|
223
|
+
# Checkout files from temporary index
|
|
224
|
+
GIT_INDEX_FILE=.git/index.tmp git checkout-index -a -f
|
|
225
|
+
|
|
226
|
+
# Clean up
|
|
227
|
+
rm .git/index.tmp
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
## See Also
|
|
231
|
+
|
|
232
|
+
- [CLI Reference](cli-reference.md) - `history` command options
|
|
233
|
+
- [Troubleshooting Guide](troubleshooting.md) - General recovery issues
|