@vibe-validate/history 0.14.3 → 0.15.0-rc.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/README.md +5 -5
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/pruner.d.ts +17 -0
- package/dist/pruner.d.ts.map +1 -1
- package/dist/pruner.js +74 -0
- package/dist/pruner.js.map +1 -1
- package/dist/reader.d.ts +4 -4
- package/dist/reader.d.ts.map +1 -1
- package/dist/reader.js +39 -14
- package/dist/reader.js.map +1 -1
- package/dist/run-cache-reader.d.ts +50 -0
- package/dist/run-cache-reader.d.ts.map +1 -0
- package/dist/run-cache-reader.js +136 -0
- package/dist/run-cache-reader.js.map +1 -0
- package/dist/schemas.d.ts +1690 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +130 -0
- package/dist/schemas.js.map +1 -0
- package/dist/truncate.d.ts +9 -4
- package/dist/truncate.d.ts.map +1 -1
- package/dist/truncate.js +12 -35
- package/dist/truncate.js.map +1 -1
- package/dist/types.d.ts +11 -62
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +6 -15
- package/dist/types.js.map +1 -1
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -108,14 +108,14 @@ const config: HistoryConfig = {
|
|
|
108
108
|
enabled: true,
|
|
109
109
|
|
|
110
110
|
gitNotes: {
|
|
111
|
-
ref: 'vibe-validate/
|
|
112
|
-
maxRunsPerTree: 10,
|
|
113
|
-
maxOutputBytes: 10000,
|
|
111
|
+
ref: 'vibe-validate/validate', // Git notes ref namespace (v0.15.0: changed from 'runs')
|
|
112
|
+
maxRunsPerTree: 10, // Keep last 10 runs per tree
|
|
113
|
+
maxOutputBytes: 10000, // 10KB max per step output
|
|
114
114
|
},
|
|
115
115
|
|
|
116
116
|
retention: {
|
|
117
|
-
warnAfterDays:
|
|
118
|
-
warnAfterCount:
|
|
117
|
+
warnAfterDays: 30, // Warn about notes >30 days old (v0.15.0: was 90)
|
|
118
|
+
warnAfterCount: 1000, // Warn when >1000 tree hashes (v0.15.0: was 100, adjusted for run caching)
|
|
119
119
|
},
|
|
120
120
|
};
|
|
121
121
|
```
|
package/dist/index.d.ts
CHANGED
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @packageDocumentation
|
|
5
5
|
*/
|
|
6
|
-
export type { ValidationRun, HistoryNote, RecordResult, StabilityCheck, HistoryConfig, HealthCheckResult, PruneResult, } from './types.js';
|
|
6
|
+
export type { ValidationRun, HistoryNote, RecordResult, StabilityCheck, HistoryConfig, HealthCheckResult, PruneResult, RunCacheNote, } from './types.js';
|
|
7
7
|
export { DEFAULT_HISTORY_CONFIG } from './types.js';
|
|
8
8
|
export { recordValidationHistory, checkWorktreeStability, } from './recorder.js';
|
|
9
9
|
export { readHistoryNote, listHistoryTreeHashes, getAllHistoryNotes, hasHistoryForTree, } from './reader.js';
|
|
10
|
-
export {
|
|
10
|
+
export { listRunCacheEntries, getRunCacheEntry, getAllRunCacheForTree, listRunCacheTreeHashes, getAllRunCacheEntries, type RunCacheEntryMeta, } from './run-cache-reader.js';
|
|
11
|
+
export { pruneHistoryByAge, pruneAllHistory, pruneLegacyNotes, pruneAllRunCache } from './pruner.js';
|
|
11
12
|
export { checkHistoryHealth } from './health-check.js';
|
|
12
13
|
export { truncateValidationOutput } from './truncate.js';
|
|
13
14
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,YAAY,EACV,aAAa,EACb,WAAW,EACX,YAAY,EACZ,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,WAAW,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,YAAY,EACV,aAAa,EACb,WAAW,EACX,YAAY,EACZ,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,WAAW,EACX,YAAY,GACb,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAGpD,OAAO,EACL,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,KAAK,iBAAiB,GACvB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAGrG,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAGvD,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -8,8 +8,10 @@ export { DEFAULT_HISTORY_CONFIG } from './types.js';
|
|
|
8
8
|
export { recordValidationHistory, checkWorktreeStability, } from './recorder.js';
|
|
9
9
|
// Reader
|
|
10
10
|
export { readHistoryNote, listHistoryTreeHashes, getAllHistoryNotes, hasHistoryForTree, } from './reader.js';
|
|
11
|
+
// Run cache reader
|
|
12
|
+
export { listRunCacheEntries, getRunCacheEntry, getAllRunCacheForTree, listRunCacheTreeHashes, getAllRunCacheEntries, } from './run-cache-reader.js';
|
|
11
13
|
// Pruner
|
|
12
|
-
export { pruneHistoryByAge, pruneAllHistory } from './pruner.js';
|
|
14
|
+
export { pruneHistoryByAge, pruneAllHistory, pruneLegacyNotes, pruneAllRunCache } from './pruner.js';
|
|
13
15
|
// Health check
|
|
14
16
|
export { checkHistoryHealth } from './health-check.js';
|
|
15
17
|
// Truncate
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAcH,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAEpD,WAAW;AACX,OAAO,EACL,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,eAAe,CAAC;AAEvB,SAAS;AACT,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,aAAa,CAAC;AAErB,mBAAmB;AACnB,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,GAEtB,MAAM,uBAAuB,CAAC;AAE/B,SAAS;AACT,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAErG,eAAe;AACf,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEvD,WAAW;AACX,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/pruner.d.ts
CHANGED
|
@@ -19,4 +19,21 @@ export declare function pruneHistoryByAge(olderThanDays: number, config?: Histor
|
|
|
19
19
|
* @returns Prune result
|
|
20
20
|
*/
|
|
21
21
|
export declare function pruneAllHistory(config?: HistoryConfig, dryRun?: boolean): Promise<PruneResult>;
|
|
22
|
+
/**
|
|
23
|
+
* Clean up legacy git notes from pre-0.15.0 versions
|
|
24
|
+
*
|
|
25
|
+
* Removes notes from the old `refs/notes/vibe-validate/runs` namespace.
|
|
26
|
+
* Safe to call - only removes if legacy notes exist.
|
|
27
|
+
*
|
|
28
|
+
* @param dryRun - If true, don't actually delete (default: false)
|
|
29
|
+
* @returns Prune result
|
|
30
|
+
*/
|
|
31
|
+
export declare function pruneLegacyNotes(dryRun?: boolean): Promise<PruneResult>;
|
|
32
|
+
/**
|
|
33
|
+
* Prune all run cache entries
|
|
34
|
+
*
|
|
35
|
+
* @param dryRun - If true, don't actually delete (default: false)
|
|
36
|
+
* @returns Prune result
|
|
37
|
+
*/
|
|
38
|
+
export declare function pruneAllRunCache(dryRun?: boolean): Promise<PruneResult>;
|
|
22
39
|
//# sourceMappingURL=pruner.d.ts.map
|
package/dist/pruner.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pruner.d.ts","sourceRoot":"","sources":["../src/pruner.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"pruner.d.ts","sourceRoot":"","sources":["../src/pruner.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAY7D;;;;;;;GAOG;AACH,wBAAsB,iBAAiB,CACrC,aAAa,EAAE,MAAM,EACrB,MAAM,GAAE,aAAkB,EAC1B,MAAM,GAAE,OAAe,GACtB,OAAO,CAAC,WAAW,CAAC,CAsDtB;AAED;;;;;;GAMG;AACH,wBAAsB,eAAe,CACnC,MAAM,GAAE,aAAkB,EAC1B,MAAM,GAAE,OAAe,GACtB,OAAO,CAAC,WAAW,CAAC,CAwCtB;AAED;;;;;;;;GAQG;AACH,wBAAsB,gBAAgB,CAAC,MAAM,GAAE,OAAe,GAAG,OAAO,CAAC,WAAW,CAAC,CAoCpF;AAED;;;;;GAKG;AACH,wBAAsB,gBAAgB,CAAC,MAAM,GAAE,OAAe,GAAG,OAAO,CAAC,WAAW,CAAC,CAgCpF"}
|
package/dist/pruner.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { execSync } from 'node:child_process';
|
|
5
5
|
import { DEFAULT_HISTORY_CONFIG } from './types.js';
|
|
6
6
|
import { getAllHistoryNotes } from './reader.js';
|
|
7
|
+
import { listRunCacheTreeHashes, getAllRunCacheForTree } from './run-cache-reader.js';
|
|
7
8
|
const GIT_TIMEOUT = 30000;
|
|
8
9
|
const GIT_OPTIONS = {
|
|
9
10
|
encoding: 'utf8',
|
|
@@ -104,4 +105,77 @@ export async function pruneAllHistory(config = {}, dryRun = false) {
|
|
|
104
105
|
prunedTreeHashes,
|
|
105
106
|
};
|
|
106
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* Clean up legacy git notes from pre-0.15.0 versions
|
|
110
|
+
*
|
|
111
|
+
* Removes notes from the old `refs/notes/vibe-validate/runs` namespace.
|
|
112
|
+
* Safe to call - only removes if legacy notes exist.
|
|
113
|
+
*
|
|
114
|
+
* @param dryRun - If true, don't actually delete (default: false)
|
|
115
|
+
* @returns Prune result
|
|
116
|
+
*/
|
|
117
|
+
export async function pruneLegacyNotes(dryRun = false) {
|
|
118
|
+
const legacyRef = 'vibe-validate/runs';
|
|
119
|
+
let notesPruned = 0;
|
|
120
|
+
let runsPruned = 0;
|
|
121
|
+
const prunedTreeHashes = [];
|
|
122
|
+
try {
|
|
123
|
+
const allNotes = await getAllHistoryNotes(legacyRef);
|
|
124
|
+
for (const note of allNotes) {
|
|
125
|
+
if (!dryRun) {
|
|
126
|
+
try {
|
|
127
|
+
execSync(`git notes --ref=${legacyRef} remove ${note.treeHash}`, { ...GIT_OPTIONS, stdio: 'ignore' });
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
130
|
+
// Ignore errors
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
notesPruned++;
|
|
134
|
+
runsPruned += note.runs?.length ?? 0;
|
|
135
|
+
prunedTreeHashes.push(note.treeHash);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
// No legacy notes found - that's fine
|
|
140
|
+
}
|
|
141
|
+
return {
|
|
142
|
+
notesPruned,
|
|
143
|
+
runsPruned,
|
|
144
|
+
notesRemaining: 0,
|
|
145
|
+
prunedTreeHashes,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Prune all run cache entries
|
|
150
|
+
*
|
|
151
|
+
* @param dryRun - If true, don't actually delete (default: false)
|
|
152
|
+
* @returns Prune result
|
|
153
|
+
*/
|
|
154
|
+
export async function pruneAllRunCache(dryRun = false) {
|
|
155
|
+
const treeHashes = await listRunCacheTreeHashes();
|
|
156
|
+
let notesPruned = 0;
|
|
157
|
+
const prunedTreeHashes = [];
|
|
158
|
+
for (const treeHash of treeHashes) {
|
|
159
|
+
const entries = await getAllRunCacheForTree(treeHash);
|
|
160
|
+
if (entries.length > 0) {
|
|
161
|
+
if (!dryRun) {
|
|
162
|
+
try {
|
|
163
|
+
// Delete all run cache notes under this tree hash
|
|
164
|
+
execSync(`git for-each-ref --format="%(refname)" refs/notes/vibe-validate/run/${treeHash}/ | xargs -I {} git update-ref -d {}`, { ...GIT_OPTIONS, stdio: 'ignore' });
|
|
165
|
+
}
|
|
166
|
+
catch {
|
|
167
|
+
// Ignore errors
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
notesPruned += entries.length;
|
|
171
|
+
prunedTreeHashes.push(treeHash);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return {
|
|
175
|
+
notesPruned,
|
|
176
|
+
runsPruned: notesPruned, // For run cache, each note is one cached command
|
|
177
|
+
notesRemaining: 0,
|
|
178
|
+
prunedTreeHashes,
|
|
179
|
+
};
|
|
180
|
+
}
|
|
107
181
|
//# sourceMappingURL=pruner.js.map
|
package/dist/pruner.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pruner.js","sourceRoot":"","sources":["../src/pruner.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C,OA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AAW,EAAE,iDAAiD;QAC1E,cAAc,EAAE,CAAC;QACjB,gBAAgB;KACjB,CAAC;AACJ,CAAC"}
|
package/dist/reader.d.ts
CHANGED
|
@@ -6,21 +6,21 @@ import type { HistoryNote } from './types.js';
|
|
|
6
6
|
* Read validation history note for a tree hash
|
|
7
7
|
*
|
|
8
8
|
* @param treeHash - Git tree hash
|
|
9
|
-
* @param notesRef - Git notes ref (default: vibe-validate/
|
|
9
|
+
* @param notesRef - Git notes ref (default: vibe-validate/validate)
|
|
10
10
|
* @returns History note or null if not found
|
|
11
11
|
*/
|
|
12
12
|
export declare function readHistoryNote(treeHash: string, notesRef?: string): Promise<HistoryNote | null>;
|
|
13
13
|
/**
|
|
14
14
|
* List all tree hashes with validation history
|
|
15
15
|
*
|
|
16
|
-
* @param notesRef - Git notes ref (default: vibe-validate/
|
|
16
|
+
* @param notesRef - Git notes ref (default: vibe-validate/validate)
|
|
17
17
|
* @returns Array of tree hashes with notes
|
|
18
18
|
*/
|
|
19
19
|
export declare function listHistoryTreeHashes(notesRef?: string): Promise<string[]>;
|
|
20
20
|
/**
|
|
21
21
|
* Get all validation history notes
|
|
22
22
|
*
|
|
23
|
-
* @param notesRef - Git notes ref (default: vibe-validate/
|
|
23
|
+
* @param notesRef - Git notes ref (default: vibe-validate/validate)
|
|
24
24
|
* @returns Array of all history notes
|
|
25
25
|
*/
|
|
26
26
|
export declare function getAllHistoryNotes(notesRef?: string): Promise<HistoryNote[]>;
|
|
@@ -28,7 +28,7 @@ export declare function getAllHistoryNotes(notesRef?: string): Promise<HistoryNo
|
|
|
28
28
|
* Check if validation history exists for a tree hash
|
|
29
29
|
*
|
|
30
30
|
* @param treeHash - Git tree hash
|
|
31
|
-
* @param notesRef - Git notes ref (default: vibe-validate/
|
|
31
|
+
* @param notesRef - Git notes ref (default: vibe-validate/validate)
|
|
32
32
|
* @returns True if history exists
|
|
33
33
|
*/
|
|
34
34
|
export declare function hasHistoryForTree(treeHash: string, notesRef?: string): Promise<boolean>;
|
package/dist/reader.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reader.d.ts","sourceRoot":"","sources":["../src/reader.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"reader.d.ts","sourceRoot":"","sources":["../src/reader.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAS9C;;;;;;GAMG;AACH,wBAAsB,eAAe,CACnC,QAAQ,EAAE,MAAM,EAChB,QAAQ,GAAE,MAAiC,GAC1C,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CA4C7B;AAED;;;;;GAKG;AACH,wBAAsB,qBAAqB,CACzC,QAAQ,GAAE,MAAiC,GAC1C,OAAO,CAAC,MAAM,EAAE,CAAC,CAuBnB;AAED;;;;;GAKG;AACH,wBAAsB,kBAAkB,CACtC,QAAQ,GAAE,MAAiC,GAC1C,OAAO,CAAC,WAAW,EAAE,CAAC,CAYxB;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,MAAM,EAChB,QAAQ,GAAE,MAAiC,GAC1C,OAAO,CAAC,OAAO,CAAC,CAGlB"}
|
package/dist/reader.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { execSync } from 'node:child_process';
|
|
5
5
|
import { parse as parseYaml } from 'yaml';
|
|
6
|
+
import { safeValidateResult } from '@vibe-validate/core';
|
|
6
7
|
const GIT_TIMEOUT = 30000;
|
|
7
8
|
const GIT_OPTIONS = {
|
|
8
9
|
encoding: 'utf8',
|
|
@@ -13,28 +14,53 @@ const GIT_OPTIONS = {
|
|
|
13
14
|
* Read validation history note for a tree hash
|
|
14
15
|
*
|
|
15
16
|
* @param treeHash - Git tree hash
|
|
16
|
-
* @param notesRef - Git notes ref (default: vibe-validate/
|
|
17
|
+
* @param notesRef - Git notes ref (default: vibe-validate/validate)
|
|
17
18
|
* @returns History note or null if not found
|
|
18
19
|
*/
|
|
19
|
-
export async function readHistoryNote(treeHash, notesRef = 'vibe-validate/
|
|
20
|
+
export async function readHistoryNote(treeHash, notesRef = 'vibe-validate/validate') {
|
|
20
21
|
try {
|
|
21
22
|
const yaml = execSync(`git notes --ref=${notesRef} show ${treeHash}`, GIT_OPTIONS);
|
|
22
|
-
const
|
|
23
|
-
|
|
23
|
+
const parsed = parseYaml(yaml);
|
|
24
|
+
// Validate as HistoryNote structure
|
|
25
|
+
if (!parsed || typeof parsed !== 'object' || !('runs' in parsed) || !Array.isArray(parsed.runs)) {
|
|
26
|
+
console.warn(`Invalid history note structure for ${treeHash} - missing runs array`);
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
// Validate each ValidationResult in runs array using safe validation
|
|
30
|
+
const validatedRuns = [];
|
|
31
|
+
for (const run of parsed.runs) {
|
|
32
|
+
if (!run.result) {
|
|
33
|
+
console.warn(`Run ${run.id} missing result field - skipping`);
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
const validationResult = safeValidateResult(run.result);
|
|
37
|
+
if (!validationResult.success) {
|
|
38
|
+
console.warn(`Invalid ValidationResult in run ${run.id}:`, validationResult.errors);
|
|
39
|
+
console.warn('Skipping corrupted run entry');
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
validatedRuns.push({
|
|
43
|
+
...run,
|
|
44
|
+
result: validationResult.data,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
treeHash: parsed.treeHash ?? treeHash,
|
|
49
|
+
runs: validatedRuns,
|
|
50
|
+
};
|
|
24
51
|
}
|
|
25
|
-
catch
|
|
52
|
+
catch {
|
|
26
53
|
// Note doesn't exist - this is expected for first-time validation
|
|
27
|
-
console.debug(`No history note for ${treeHash}: ${error instanceof Error ? error.message : String(error)}`);
|
|
28
54
|
return null;
|
|
29
55
|
}
|
|
30
56
|
}
|
|
31
57
|
/**
|
|
32
58
|
* List all tree hashes with validation history
|
|
33
59
|
*
|
|
34
|
-
* @param notesRef - Git notes ref (default: vibe-validate/
|
|
60
|
+
* @param notesRef - Git notes ref (default: vibe-validate/validate)
|
|
35
61
|
* @returns Array of tree hashes with notes
|
|
36
62
|
*/
|
|
37
|
-
export async function listHistoryTreeHashes(notesRef = 'vibe-validate/
|
|
63
|
+
export async function listHistoryTreeHashes(notesRef = 'vibe-validate/validate') {
|
|
38
64
|
try {
|
|
39
65
|
const output = execSync(`git notes --ref=${notesRef} list`, GIT_OPTIONS);
|
|
40
66
|
if (!output.trim()) {
|
|
@@ -51,19 +77,18 @@ export async function listHistoryTreeHashes(notesRef = 'vibe-validate/runs') {
|
|
|
51
77
|
.filter(Boolean);
|
|
52
78
|
return treeHashes;
|
|
53
79
|
}
|
|
54
|
-
catch
|
|
80
|
+
catch {
|
|
55
81
|
// No notes exist yet - expected for new repos
|
|
56
|
-
console.debug(`No history notes found: ${error instanceof Error ? error.message : String(error)}`);
|
|
57
82
|
return [];
|
|
58
83
|
}
|
|
59
84
|
}
|
|
60
85
|
/**
|
|
61
86
|
* Get all validation history notes
|
|
62
87
|
*
|
|
63
|
-
* @param notesRef - Git notes ref (default: vibe-validate/
|
|
88
|
+
* @param notesRef - Git notes ref (default: vibe-validate/validate)
|
|
64
89
|
* @returns Array of all history notes
|
|
65
90
|
*/
|
|
66
|
-
export async function getAllHistoryNotes(notesRef = 'vibe-validate/
|
|
91
|
+
export async function getAllHistoryNotes(notesRef = 'vibe-validate/validate') {
|
|
67
92
|
const treeHashes = await listHistoryTreeHashes(notesRef);
|
|
68
93
|
const notes = [];
|
|
69
94
|
for (const treeHash of treeHashes) {
|
|
@@ -78,10 +103,10 @@ export async function getAllHistoryNotes(notesRef = 'vibe-validate/runs') {
|
|
|
78
103
|
* Check if validation history exists for a tree hash
|
|
79
104
|
*
|
|
80
105
|
* @param treeHash - Git tree hash
|
|
81
|
-
* @param notesRef - Git notes ref (default: vibe-validate/
|
|
106
|
+
* @param notesRef - Git notes ref (default: vibe-validate/validate)
|
|
82
107
|
* @returns True if history exists
|
|
83
108
|
*/
|
|
84
|
-
export async function hasHistoryForTree(treeHash, notesRef = 'vibe-validate/
|
|
109
|
+
export async function hasHistoryForTree(treeHash, notesRef = 'vibe-validate/validate') {
|
|
85
110
|
const note = await readHistoryNote(treeHash, notesRef);
|
|
86
111
|
return note !== null;
|
|
87
112
|
}
|
package/dist/reader.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reader.js","sourceRoot":"","sources":["../src/reader.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"reader.js","sourceRoot":"","sources":["../src/reader.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAGzD,MAAM,WAAW,GAAG,KAAK,CAAC;AAC1B,MAAM,WAAW,GAAG;IAClB,QAAQ,EAAE,MAAe;IACzB,OAAO,EAAE,WAAW;IACpB,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAA+B;CAChE,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,QAAgB,EAChB,WAAmB,wBAAwB;IAE3C,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,QAAQ,CACnB,mBAAmB,QAAQ,SAAS,QAAQ,EAAE,EAC9C,WAAW,CACZ,CAAC;QAEF,MAAM,MAAM,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;QAE/B,oCAAoC;QACpC,IAAI,CAA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
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run cache reader - Read run cache entries from git notes
|
|
3
|
+
*
|
|
4
|
+
* Run cache is stored at: refs/notes/vibe-validate/run/{treeHash}/{cacheKey}
|
|
5
|
+
* where cacheKey = encodeURIComponent(workdir ? `${workdir}:${command}` : command)
|
|
6
|
+
*/
|
|
7
|
+
import type { RunCacheNote } from './types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Entry metadata from git notes list
|
|
10
|
+
*/
|
|
11
|
+
export interface RunCacheEntryMeta {
|
|
12
|
+
treeHash: string;
|
|
13
|
+
cacheKey: string;
|
|
14
|
+
refPath: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* List all run cache entries for a tree hash
|
|
18
|
+
*
|
|
19
|
+
* @param treeHash - Git tree hash
|
|
20
|
+
* @returns Array of run cache entry metadata
|
|
21
|
+
*/
|
|
22
|
+
export declare function listRunCacheEntries(treeHash: string): Promise<RunCacheEntryMeta[]>;
|
|
23
|
+
/**
|
|
24
|
+
* Get a specific run cache entry
|
|
25
|
+
*
|
|
26
|
+
* @param treeHash - Git tree hash
|
|
27
|
+
* @param cacheKey - URL-encoded cache key
|
|
28
|
+
* @returns Run cache note or null if not found
|
|
29
|
+
*/
|
|
30
|
+
export declare function getRunCacheEntry(treeHash: string, cacheKey: string): Promise<RunCacheNote | null>;
|
|
31
|
+
/**
|
|
32
|
+
* Get all run cache entries for a tree hash
|
|
33
|
+
*
|
|
34
|
+
* @param treeHash - Git tree hash
|
|
35
|
+
* @returns Array of all run cache notes for this tree hash
|
|
36
|
+
*/
|
|
37
|
+
export declare function getAllRunCacheForTree(treeHash: string): Promise<RunCacheNote[]>;
|
|
38
|
+
/**
|
|
39
|
+
* List all tree hashes that have run cache entries
|
|
40
|
+
*
|
|
41
|
+
* @returns Array of tree hashes with run cache
|
|
42
|
+
*/
|
|
43
|
+
export declare function listRunCacheTreeHashes(): Promise<string[]>;
|
|
44
|
+
/**
|
|
45
|
+
* Get all run cache entries across all tree hashes
|
|
46
|
+
*
|
|
47
|
+
* @returns Array of all run cache notes
|
|
48
|
+
*/
|
|
49
|
+
export declare function getAllRunCacheEntries(): Promise<RunCacheNote[]>;
|
|
50
|
+
//# sourceMappingURL=run-cache-reader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-cache-reader.d.ts","sourceRoot":"","sources":["../src/run-cache-reader.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAS/C;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;GAKG;AACH,wBAAsB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAqCxF;AAED;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAW9B;AAED;;;;;GAKG;AACH,wBAAsB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAYrF;AAED;;;;GAIG;AACH,wBAAsB,sBAAsB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CA8BhE;AAED;;;;GAIG;AACH,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC,CAarE"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run cache reader - Read run cache entries from git notes
|
|
3
|
+
*
|
|
4
|
+
* Run cache is stored at: refs/notes/vibe-validate/run/{treeHash}/{cacheKey}
|
|
5
|
+
* where cacheKey = encodeURIComponent(workdir ? `${workdir}:${command}` : command)
|
|
6
|
+
*/
|
|
7
|
+
import { execSync } from 'node:child_process';
|
|
8
|
+
import { parse as parseYaml } from 'yaml';
|
|
9
|
+
const GIT_TIMEOUT = 30000;
|
|
10
|
+
const GIT_OPTIONS = {
|
|
11
|
+
encoding: 'utf8',
|
|
12
|
+
timeout: GIT_TIMEOUT,
|
|
13
|
+
stdio: ['pipe', 'pipe', 'ignore'],
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* List all run cache entries for a tree hash
|
|
17
|
+
*
|
|
18
|
+
* @param treeHash - Git tree hash
|
|
19
|
+
* @returns Array of run cache entry metadata
|
|
20
|
+
*/
|
|
21
|
+
export async function listRunCacheEntries(treeHash) {
|
|
22
|
+
try {
|
|
23
|
+
// List all notes under refs/notes/vibe-validate/run/{treeHash}/*
|
|
24
|
+
const output = execSync(`git for-each-ref --format="%(refname) %(objectname)" refs/notes/vibe-validate/run/${treeHash}/`, GIT_OPTIONS);
|
|
25
|
+
if (!output.trim()) {
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
28
|
+
// Parse output: "refs/notes/vibe-validate/run/{treeHash}/{cacheKey} {noteObjectName}"
|
|
29
|
+
const entries = output
|
|
30
|
+
.trim()
|
|
31
|
+
.split('\n')
|
|
32
|
+
.map((line) => {
|
|
33
|
+
const [refPath] = line.split(' ');
|
|
34
|
+
// Extract cache key from ref path
|
|
35
|
+
const regex = /refs\/notes\/vibe-validate\/run\/([^/]+)\/(.+)$/;
|
|
36
|
+
const match = regex.exec(refPath);
|
|
37
|
+
if (!match)
|
|
38
|
+
return null;
|
|
39
|
+
const [, treeHashFromRef, cacheKey] = match;
|
|
40
|
+
return {
|
|
41
|
+
treeHash: treeHashFromRef,
|
|
42
|
+
cacheKey,
|
|
43
|
+
refPath,
|
|
44
|
+
};
|
|
45
|
+
})
|
|
46
|
+
.filter(Boolean);
|
|
47
|
+
return entries;
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
// No run cache exists - expected for tree hashes without run cache
|
|
51
|
+
return [];
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Get a specific run cache entry
|
|
56
|
+
*
|
|
57
|
+
* @param treeHash - Git tree hash
|
|
58
|
+
* @param cacheKey - URL-encoded cache key
|
|
59
|
+
* @returns Run cache note or null if not found
|
|
60
|
+
*/
|
|
61
|
+
export async function getRunCacheEntry(treeHash, cacheKey) {
|
|
62
|
+
try {
|
|
63
|
+
const refPath = `vibe-validate/run/${treeHash}/${cacheKey}`;
|
|
64
|
+
const yaml = execSync(`git notes --ref=${refPath} show HEAD`, GIT_OPTIONS);
|
|
65
|
+
const note = parseYaml(yaml);
|
|
66
|
+
return note;
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
// Entry doesn't exist or parse failed
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Get all run cache entries for a tree hash
|
|
75
|
+
*
|
|
76
|
+
* @param treeHash - Git tree hash
|
|
77
|
+
* @returns Array of all run cache notes for this tree hash
|
|
78
|
+
*/
|
|
79
|
+
export async function getAllRunCacheForTree(treeHash) {
|
|
80
|
+
const entries = await listRunCacheEntries(treeHash);
|
|
81
|
+
const notes = [];
|
|
82
|
+
for (const entry of entries) {
|
|
83
|
+
const note = await getRunCacheEntry(entry.treeHash, entry.cacheKey);
|
|
84
|
+
if (note) {
|
|
85
|
+
notes.push(note);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return notes;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* List all tree hashes that have run cache entries
|
|
92
|
+
*
|
|
93
|
+
* @returns Array of tree hashes with run cache
|
|
94
|
+
*/
|
|
95
|
+
export async function listRunCacheTreeHashes() {
|
|
96
|
+
try {
|
|
97
|
+
// List all notes under refs/notes/vibe-validate/run/
|
|
98
|
+
const output = execSync('git for-each-ref --format="%(refname)" refs/notes/vibe-validate/run/', GIT_OPTIONS);
|
|
99
|
+
if (!output.trim()) {
|
|
100
|
+
return [];
|
|
101
|
+
}
|
|
102
|
+
// Parse output and extract unique tree hashes
|
|
103
|
+
const treeHashes = new Set();
|
|
104
|
+
const lines = output.trim().split('\n');
|
|
105
|
+
for (const line of lines) {
|
|
106
|
+
// Extract tree hash from ref path: refs/notes/vibe-validate/run/{treeHash}/...
|
|
107
|
+
const regex = /refs\/notes\/vibe-validate\/run\/([^/]+)/;
|
|
108
|
+
const match = regex.exec(line);
|
|
109
|
+
if (match) {
|
|
110
|
+
treeHashes.add(match[1]);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return Array.from(treeHashes);
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
// No run cache exists - expected for repos without run cache
|
|
117
|
+
return [];
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Get all run cache entries across all tree hashes
|
|
122
|
+
*
|
|
123
|
+
* @returns Array of all run cache notes
|
|
124
|
+
*/
|
|
125
|
+
export async function getAllRunCacheEntries() {
|
|
126
|
+
const treeHashes = await listRunCacheTreeHashes();
|
|
127
|
+
const allNotes = [];
|
|
128
|
+
for (const treeHash of treeHashes) {
|
|
129
|
+
const notes = await getAllRunCacheForTree(treeHash);
|
|
130
|
+
allNotes.push(...notes);
|
|
131
|
+
}
|
|
132
|
+
// Sort by timestamp (newest first)
|
|
133
|
+
allNotes.sort((a, b) => new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime());
|
|
134
|
+
return allNotes;
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=run-cache-reader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-cache-reader.js","sourceRoot":"","sources":["../src/run-cache-reader.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;AA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