@vibe-validate/cli 0.15.0-rc.2 → 0.15.0-rc.5
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/dist/bin/vibe-validate +123 -0
- package/dist/bin/vibe-validate.d.ts +14 -0
- package/dist/bin/vibe-validate.d.ts.map +1 -0
- package/dist/bin/vibe-validate.js +123 -0
- package/dist/bin/vibe-validate.js.map +1 -0
- package/dist/bin/vv +123 -0
- package/dist/commands/history.d.ts.map +1 -1
- package/dist/commands/history.js +52 -6
- package/dist/commands/history.js.map +1 -1
- package/dist/commands/run.d.ts.map +1 -1
- package/dist/commands/run.js +4 -3
- package/dist/commands/run.js.map +1 -1
- package/dist/commands/state.d.ts.map +1 -1
- package/dist/commands/state.js +136 -79
- package/dist/commands/state.js.map +1 -1
- package/dist/schemas/watch-pr-schema.d.ts +6 -6
- package/package.json +9 -10
- package/bin/vibe-validate +0 -131
- package/bin/vv +0 -131
- package/dist/utils/run-validation-with-cache.d.ts +0 -48
- package/dist/utils/run-validation-with-cache.d.ts.map +0 -1
- package/dist/utils/run-validation-with-cache.js +0 -123
- package/dist/utils/run-validation-with-cache.js.map +0 -1
- package/dist/utils/validation-cache.d.ts +0 -30
- package/dist/utils/validation-cache.d.ts.map +0 -1
- package/dist/utils/validation-cache.js +0 -57
- package/dist/utils/validation-cache.js.map +0 -1
- package/dist/vibe-validate +0 -131
package/bin/vv
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* Smart vibe-validate wrapper with context-aware execution
|
|
4
|
-
*
|
|
5
|
-
* Automatically detects execution context and delegates to appropriate binary:
|
|
6
|
-
* - Developer mode: Inside vibe-validate repo → packages/cli/dist/bin.js (unpackaged dev build)
|
|
7
|
-
* - Local install: Project has vibe-validate → node_modules version (packaged)
|
|
8
|
-
* - Global install: Fallback → globally installed version (packaged)
|
|
9
|
-
*
|
|
10
|
-
* Works in both git and non-git directories. Non-git directories don't get
|
|
11
|
-
* caching but still get error extraction.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
import { existsSync } from 'fs';
|
|
15
|
-
import { dirname, join } from 'path';
|
|
16
|
-
import { spawnSync } from 'child_process';
|
|
17
|
-
import { fileURLToPath } from 'url';
|
|
18
|
-
|
|
19
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
20
|
-
const __dirname = dirname(__filename);
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Find project root by walking up to .git directory
|
|
24
|
-
* Falls back to startDir if no git repo found
|
|
25
|
-
*/
|
|
26
|
-
function findProjectRoot(startDir) {
|
|
27
|
-
let current = startDir;
|
|
28
|
-
|
|
29
|
-
while (true) {
|
|
30
|
-
const gitDir = join(current, '.git');
|
|
31
|
-
if (existsSync(gitDir)) {
|
|
32
|
-
return current; // Found git repo
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const parent = dirname(current);
|
|
36
|
-
if (parent === current) {
|
|
37
|
-
// Reached filesystem root, no git found
|
|
38
|
-
return startDir;
|
|
39
|
-
}
|
|
40
|
-
current = parent;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Check if we're in vibe-validate repo (developer mode)
|
|
46
|
-
* Simple detection: both dist/vibe-validate and dist/bin.js must exist
|
|
47
|
-
*/
|
|
48
|
-
function getDevModeBinary(projectRoot) {
|
|
49
|
-
const wrapperPath = join(projectRoot, 'packages/cli/dist/vibe-validate');
|
|
50
|
-
const binPath = join(projectRoot, 'packages/cli/dist/bin.js');
|
|
51
|
-
|
|
52
|
-
// Both files must exist to confirm we're in vibe-validate repo
|
|
53
|
-
if (existsSync(wrapperPath) && existsSync(binPath)) {
|
|
54
|
-
return binPath;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return null;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Find local vibe-validate installation in node_modules
|
|
62
|
-
* Walks up directory tree from project root
|
|
63
|
-
*/
|
|
64
|
-
function findLocalInstall(projectRoot) {
|
|
65
|
-
let current = projectRoot;
|
|
66
|
-
|
|
67
|
-
while (true) {
|
|
68
|
-
const localBin = join(current, 'node_modules/@vibe-validate/cli/dist/bin.js');
|
|
69
|
-
if (existsSync(localBin)) {
|
|
70
|
-
return localBin;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const parent = dirname(current);
|
|
74
|
-
if (parent === current) {
|
|
75
|
-
// Reached filesystem root
|
|
76
|
-
break;
|
|
77
|
-
}
|
|
78
|
-
current = parent;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return null;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Main entry point - detects context and executes appropriate binary
|
|
86
|
-
*/
|
|
87
|
-
function main() {
|
|
88
|
-
const cwd = process.cwd();
|
|
89
|
-
const args = process.argv.slice(2);
|
|
90
|
-
|
|
91
|
-
// Find project root (where .git is, or cwd if no git)
|
|
92
|
-
const projectRoot = findProjectRoot(cwd);
|
|
93
|
-
|
|
94
|
-
let binPath;
|
|
95
|
-
let context;
|
|
96
|
-
|
|
97
|
-
// Priority 1: Check for developer mode (inside vibe-validate repo)
|
|
98
|
-
const devBin = getDevModeBinary(projectRoot);
|
|
99
|
-
if (devBin) {
|
|
100
|
-
binPath = devBin;
|
|
101
|
-
context = 'dev';
|
|
102
|
-
}
|
|
103
|
-
// Priority 2: Check for local install (node_modules)
|
|
104
|
-
else {
|
|
105
|
-
const localBin = findLocalInstall(projectRoot);
|
|
106
|
-
if (localBin) {
|
|
107
|
-
binPath = localBin;
|
|
108
|
-
context = 'local';
|
|
109
|
-
}
|
|
110
|
-
// Priority 3: Use global install (this script's location)
|
|
111
|
-
else {
|
|
112
|
-
binPath = join(__dirname, '../dist/bin.js');
|
|
113
|
-
context = 'global';
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// Execute the binary with all arguments
|
|
118
|
-
const result = spawnSync(process.execPath, [binPath, ...args], {
|
|
119
|
-
stdio: 'inherit',
|
|
120
|
-
env: {
|
|
121
|
-
...process.env,
|
|
122
|
-
VV_CONTEXT: context, // Pass context for debugging (optional)
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
// Exit with same code as child process
|
|
127
|
-
process.exit(result.status ?? 1);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
// Run main function
|
|
131
|
-
main();
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Run Validation with Caching
|
|
3
|
-
*
|
|
4
|
-
* Shared workflow for running validation with git tree hash caching.
|
|
5
|
-
* Used by both validate and pre-commit commands to ensure consistent behavior.
|
|
6
|
-
*/
|
|
7
|
-
import type { ValidationResult, ValidationConfig } from '@vibe-validate/core';
|
|
8
|
-
export interface ValidationWorkflowOptions {
|
|
9
|
-
/** Runner configuration for validation */
|
|
10
|
-
runnerConfig: ValidationConfig;
|
|
11
|
-
/** Force validation even if cached */
|
|
12
|
-
force?: boolean;
|
|
13
|
-
/** Show verbose output */
|
|
14
|
-
verbose?: boolean;
|
|
15
|
-
/** Callback for displaying cache hit information */
|
|
16
|
-
onCacheHit?: (info: {
|
|
17
|
-
treeHash: string;
|
|
18
|
-
timestamp: string;
|
|
19
|
-
duration: number;
|
|
20
|
-
branch: string;
|
|
21
|
-
result: ValidationResult;
|
|
22
|
-
}) => void;
|
|
23
|
-
}
|
|
24
|
-
export interface ValidationWorkflowResult {
|
|
25
|
-
/** Validation result */
|
|
26
|
-
result: ValidationResult;
|
|
27
|
-
/** Whether result was from cache */
|
|
28
|
-
fromCache: boolean;
|
|
29
|
-
/** Git tree hash (if in git repo) */
|
|
30
|
-
treeHash: string | null;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Run validation with full git tree hash caching workflow.
|
|
34
|
-
*
|
|
35
|
-
* This is the complete workflow used by both validate and pre-commit commands:
|
|
36
|
-
* 1. Get git tree hash
|
|
37
|
-
* 2. Check cache (git notes)
|
|
38
|
-
* 3. If cache hit: return cached result
|
|
39
|
-
* 4. If cache miss: run validation
|
|
40
|
-
* 5. Record result to git notes
|
|
41
|
-
* 6. Check worktree stability
|
|
42
|
-
* 7. Run health checks
|
|
43
|
-
*
|
|
44
|
-
* @param options - Validation workflow options
|
|
45
|
-
* @returns Validation workflow result
|
|
46
|
-
*/
|
|
47
|
-
export declare function runValidationWithCache(options: ValidationWorkflowOptions): Promise<ValidationWorkflowResult>;
|
|
48
|
-
//# sourceMappingURL=run-validation-with-cache.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"run-validation-with-cache.d.ts","sourceRoot":"","sources":["../../src/utils/run-validation-with-cache.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAUH,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAG9E,MAAM,WAAW,yBAAyB;IACxC,0CAA0C;IAC1C,YAAY,EAAE,gBAAgB,CAAC;IAE/B,sCAAsC;IACtC,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB,0BAA0B;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,oDAAoD;IACpD,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE;QAClB,QAAQ,EAAE,MAAM,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,gBAAgB,CAAC;KAC1B,KAAK,IAAI,CAAC;CACZ;AAED,MAAM,WAAW,wBAAwB;IACvC,wBAAwB;IACxB,MAAM,EAAE,gBAAgB,CAAC;IAEzB,oCAAoC;IACpC,SAAS,EAAE,OAAO,CAAC;IAEnB,qCAAqC;IACrC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,wBAAwB,CAAC,CAqGnC"}
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Run Validation with Caching
|
|
3
|
-
*
|
|
4
|
-
* Shared workflow for running validation with git tree hash caching.
|
|
5
|
-
* Used by both validate and pre-commit commands to ensure consistent behavior.
|
|
6
|
-
*/
|
|
7
|
-
import { runValidation } from '@vibe-validate/core';
|
|
8
|
-
import { getGitTreeHash } from '@vibe-validate/git';
|
|
9
|
-
import { recordValidationHistory, checkWorktreeStability, checkHistoryHealth, readHistoryNote, } from '@vibe-validate/history';
|
|
10
|
-
import chalk from 'chalk';
|
|
11
|
-
/**
|
|
12
|
-
* Run validation with full git tree hash caching workflow.
|
|
13
|
-
*
|
|
14
|
-
* This is the complete workflow used by both validate and pre-commit commands:
|
|
15
|
-
* 1. Get git tree hash
|
|
16
|
-
* 2. Check cache (git notes)
|
|
17
|
-
* 3. If cache hit: return cached result
|
|
18
|
-
* 4. If cache miss: run validation
|
|
19
|
-
* 5. Record result to git notes
|
|
20
|
-
* 6. Check worktree stability
|
|
21
|
-
* 7. Run health checks
|
|
22
|
-
*
|
|
23
|
-
* @param options - Validation workflow options
|
|
24
|
-
* @returns Validation workflow result
|
|
25
|
-
*/
|
|
26
|
-
export async function runValidationWithCache(options) {
|
|
27
|
-
const { runnerConfig, force = false, verbose = false, onCacheHit } = options;
|
|
28
|
-
// Get tree hash BEFORE validation (for caching and stability check)
|
|
29
|
-
let treeHashBefore = null;
|
|
30
|
-
try {
|
|
31
|
-
treeHashBefore = await getGitTreeHash();
|
|
32
|
-
}
|
|
33
|
-
catch (_error) {
|
|
34
|
-
// Not in git repo or git command failed - continue without history
|
|
35
|
-
if (verbose) {
|
|
36
|
-
console.warn(chalk.yellow('⚠️ Could not get git tree hash - history recording disabled'));
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
// Check cache: if validation already passed for this tree hash, skip re-running
|
|
40
|
-
if (treeHashBefore && !force) {
|
|
41
|
-
try {
|
|
42
|
-
const historyNote = await readHistoryNote(treeHashBefore);
|
|
43
|
-
if (historyNote && historyNote.runs.length > 0) {
|
|
44
|
-
// Find most recent passing run
|
|
45
|
-
const passingRun = [...historyNote.runs]
|
|
46
|
-
.reverse()
|
|
47
|
-
.find(run => run.passed);
|
|
48
|
-
if (passingRun && passingRun.result) {
|
|
49
|
-
// Cache hit! Call callback if provided
|
|
50
|
-
if (onCacheHit) {
|
|
51
|
-
onCacheHit({
|
|
52
|
-
treeHash: treeHashBefore,
|
|
53
|
-
timestamp: passingRun.timestamp,
|
|
54
|
-
duration: passingRun.duration,
|
|
55
|
-
branch: passingRun.branch,
|
|
56
|
-
result: passingRun.result,
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
return {
|
|
60
|
-
result: passingRun.result,
|
|
61
|
-
fromCache: true,
|
|
62
|
-
treeHash: treeHashBefore,
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
catch (_error) {
|
|
68
|
-
// Cache check failed - proceed with validation
|
|
69
|
-
// This is expected for first-time validation
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
// Cache miss - run validation
|
|
73
|
-
const result = await runValidation(runnerConfig);
|
|
74
|
-
// Record validation history (if in git repo and stability check passes)
|
|
75
|
-
if (treeHashBefore) {
|
|
76
|
-
try {
|
|
77
|
-
// Check if worktree changed during validation
|
|
78
|
-
const stability = await checkWorktreeStability(treeHashBefore);
|
|
79
|
-
if (!stability.stable) {
|
|
80
|
-
console.warn(chalk.yellow('\n⚠️ Worktree changed during validation'));
|
|
81
|
-
console.warn(chalk.yellow(` Before: ${stability.treeHashBefore.slice(0, 12)}...`));
|
|
82
|
-
console.warn(chalk.yellow(` After: ${stability.treeHashAfter.slice(0, 12)}...`));
|
|
83
|
-
console.warn(chalk.yellow(' Results valid but history not recorded (unstable state)'));
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
// Record to git notes
|
|
87
|
-
const recordResult = await recordValidationHistory(treeHashBefore, result);
|
|
88
|
-
if (recordResult.recorded) {
|
|
89
|
-
if (verbose) {
|
|
90
|
-
console.log(chalk.gray(`\n📝 History recorded (tree: ${treeHashBefore.slice(0, 12)})`));
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
else if (verbose) {
|
|
94
|
-
console.warn(chalk.yellow(`⚠️ History recording failed: ${recordResult.reason}`));
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
catch (error) {
|
|
99
|
-
// Silent failure - don't block validation
|
|
100
|
-
if (verbose) {
|
|
101
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
102
|
-
console.warn(chalk.yellow(`⚠️ History recording error: ${errorMessage}`));
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
// Proactive health check (non-blocking)
|
|
107
|
-
try {
|
|
108
|
-
const health = await checkHistoryHealth();
|
|
109
|
-
if (health.shouldWarn) {
|
|
110
|
-
console.log('');
|
|
111
|
-
console.log(chalk.blue(health.warningMessage));
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
catch {
|
|
115
|
-
// Silent failure - don't block validation
|
|
116
|
-
}
|
|
117
|
-
return {
|
|
118
|
-
result,
|
|
119
|
-
fromCache: false,
|
|
120
|
-
treeHash: treeHashBefore,
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
//# sourceMappingURL=run-validation-with-cache.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"run-validation-with-cache.js","sourceRoot":"","sources":["../../src/utils/run-validation-with-cache.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EACL,uB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Used by both validate and pre-commit commands to avoid redundant validation.
|
|
6
|
-
*/
|
|
7
|
-
import type { ValidationResult } from '@vibe-validate/core';
|
|
8
|
-
export interface CacheCheckResult {
|
|
9
|
-
/** Whether a cached passing result was found */
|
|
10
|
-
cacheHit: boolean;
|
|
11
|
-
/** The git tree hash that was checked */
|
|
12
|
-
treeHash: string | null;
|
|
13
|
-
/** The cached validation result (if cache hit) */
|
|
14
|
-
cachedResult?: ValidationResult;
|
|
15
|
-
/** Metadata about the cached run */
|
|
16
|
-
cachedRun?: {
|
|
17
|
-
timestamp: string;
|
|
18
|
-
duration: number;
|
|
19
|
-
branch: string;
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Check if validation has already passed for the current working tree.
|
|
24
|
-
* Returns cache hit info including the cached result if found.
|
|
25
|
-
*
|
|
26
|
-
* @param force - If true, bypass cache and force re-validation
|
|
27
|
-
* @returns Cache check result with tree hash and optional cached result
|
|
28
|
-
*/
|
|
29
|
-
export declare function checkValidationCache(force?: boolean): Promise<CacheCheckResult>;
|
|
30
|
-
//# sourceMappingURL=validation-cache.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validation-cache.d.ts","sourceRoot":"","sources":["../../src/utils/validation-cache.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,MAAM,WAAW,gBAAgB;IAC/B,gDAAgD;IAChD,QAAQ,EAAE,OAAO,CAAC;IAElB,yCAAyC;IACzC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IAExB,kDAAkD;IAClD,YAAY,CAAC,EAAE,gBAAgB,CAAC;IAEhC,oCAAoC;IACpC,SAAS,CAAC,EAAE;QACV,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH;AAED;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CAAC,KAAK,UAAQ,GAAG,OAAO,CAAC,gBAAgB,CAAC,CA2CnF"}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Validation Cache Utility
|
|
3
|
-
*
|
|
4
|
-
* Provides git tree hash-based caching for validation results.
|
|
5
|
-
* Used by both validate and pre-commit commands to avoid redundant validation.
|
|
6
|
-
*/
|
|
7
|
-
import { getGitTreeHash } from '@vibe-validate/git';
|
|
8
|
-
import { readHistoryNote } from '@vibe-validate/history';
|
|
9
|
-
/**
|
|
10
|
-
* Check if validation has already passed for the current working tree.
|
|
11
|
-
* Returns cache hit info including the cached result if found.
|
|
12
|
-
*
|
|
13
|
-
* @param force - If true, bypass cache and force re-validation
|
|
14
|
-
* @returns Cache check result with tree hash and optional cached result
|
|
15
|
-
*/
|
|
16
|
-
export async function checkValidationCache(force = false) {
|
|
17
|
-
// Get tree hash for current working directory
|
|
18
|
-
let treeHash = null;
|
|
19
|
-
try {
|
|
20
|
-
treeHash = await getGitTreeHash();
|
|
21
|
-
}
|
|
22
|
-
catch (_error) {
|
|
23
|
-
// Not in git repo or git command failed
|
|
24
|
-
return { cacheHit: false, treeHash: null };
|
|
25
|
-
}
|
|
26
|
-
// If force flag set, skip cache check
|
|
27
|
-
if (force) {
|
|
28
|
-
return { cacheHit: false, treeHash };
|
|
29
|
-
}
|
|
30
|
-
// Check git notes for cached validation result
|
|
31
|
-
try {
|
|
32
|
-
const historyNote = await readHistoryNote(treeHash);
|
|
33
|
-
if (historyNote && historyNote.runs.length > 0) {
|
|
34
|
-
// Find most recent passing run
|
|
35
|
-
const passingRun = [...historyNote.runs]
|
|
36
|
-
.reverse()
|
|
37
|
-
.find(run => run.passed);
|
|
38
|
-
if (passingRun && passingRun.result) {
|
|
39
|
-
return {
|
|
40
|
-
cacheHit: true,
|
|
41
|
-
treeHash,
|
|
42
|
-
cachedResult: passingRun.result,
|
|
43
|
-
cachedRun: {
|
|
44
|
-
timestamp: passingRun.timestamp,
|
|
45
|
-
duration: passingRun.duration,
|
|
46
|
-
branch: passingRun.branch,
|
|
47
|
-
},
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
catch (_error) {
|
|
53
|
-
// Cache read failed - proceed without cache
|
|
54
|
-
}
|
|
55
|
-
return { cacheHit: false, treeHash };
|
|
56
|
-
}
|
|
57
|
-
//# sourceMappingURL=validation-cache.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validation-cache.js","sourceRoot":"","sources":["../../src/utils/validation-cache.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAqBzD;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,KAAK,GAAG,KAAK;IACtD,8CAA8C;IAC9C,IAAI,QAAQ,GAAkB,IAAI,CAAC;IACnC,IAAI,CAAC;QACH,QAAQ,GAAG,MAAM,cAAc,EAAE,CAAC;IACpC,CAAC;IAAC,OAAO,MAAM,EAAE,CAAC;QAChB,wCAAwC;QACxC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC7C,CAAC;IAED,sCAAsC;IACtC,IAAI,KAAK,EAAE,CAAC;QACV,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;IACvC,CAAC;IAED,+CAA+C;IAC/C,IAAI,CAAC;QACH,MAAM,WAAW,GAAG,MAAM,eAAe,CAAC,QAAQ,CAAC,CAAC;QAEpD,IAAI,WAAW,IAAI,WAAW,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC/C,+BAA+B;YAC/B,MAAM,UAAU,GAAG,CAAC,GAAG,WAAW,CAAC,IAAI,CAAC;iBACrC,OAAO,EAAE;iBACT,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YAE3B,IAAI,UAAU,IAAI,UAAU,CAAC,MAAM,EAAE,CAAC;gBACpC,OAAO;oBACL,QAAQ,EAAE,IAAI;oBACd,QAAQ;oBACR,YAAY,EAAE,UAAU,CAAC,MAAM;oBAC/B,SAAS,EAAE;wBACT,SAAS,EAAE,UAAU,CAAC,SAAS;wBAC/B,QAAQ,EAAE,UAAU,CAAC,QAAQ;wBAC7B,MAAM,EAAE,UAAU,CAAC,MAAM;qBAC1B;iBACF,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;IAAC,OAAO,MAAM,EAAE,CAAC;QAChB,4CAA4C;IAC9C,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;AACvC,CAAC"}
|
package/dist/vibe-validate
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* Smart vibe-validate wrapper with context-aware execution
|
|
4
|
-
*
|
|
5
|
-
* Automatically detects execution context and delegates to appropriate binary:
|
|
6
|
-
* - Developer mode: Inside vibe-validate repo → packages/cli/dist/bin.js (unpackaged dev build)
|
|
7
|
-
* - Local install: Project has vibe-validate → node_modules version (packaged)
|
|
8
|
-
* - Global install: Fallback → globally installed version (packaged)
|
|
9
|
-
*
|
|
10
|
-
* Works in both git and non-git directories. Non-git directories don't get
|
|
11
|
-
* caching but still get error extraction.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
import { existsSync } from 'fs';
|
|
15
|
-
import { dirname, join } from 'path';
|
|
16
|
-
import { spawnSync } from 'child_process';
|
|
17
|
-
import { fileURLToPath } from 'url';
|
|
18
|
-
|
|
19
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
20
|
-
const __dirname = dirname(__filename);
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Find project root by walking up to .git directory
|
|
24
|
-
* Falls back to startDir if no git repo found
|
|
25
|
-
*/
|
|
26
|
-
function findProjectRoot(startDir) {
|
|
27
|
-
let current = startDir;
|
|
28
|
-
|
|
29
|
-
while (true) {
|
|
30
|
-
const gitDir = join(current, '.git');
|
|
31
|
-
if (existsSync(gitDir)) {
|
|
32
|
-
return current; // Found git repo
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const parent = dirname(current);
|
|
36
|
-
if (parent === current) {
|
|
37
|
-
// Reached filesystem root, no git found
|
|
38
|
-
return startDir;
|
|
39
|
-
}
|
|
40
|
-
current = parent;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Check if we're in vibe-validate repo (developer mode)
|
|
46
|
-
* Simple detection: both dist/vibe-validate and dist/bin.js must exist
|
|
47
|
-
*/
|
|
48
|
-
function getDevModeBinary(projectRoot) {
|
|
49
|
-
const wrapperPath = join(projectRoot, 'packages/cli/dist/vibe-validate');
|
|
50
|
-
const binPath = join(projectRoot, 'packages/cli/dist/bin.js');
|
|
51
|
-
|
|
52
|
-
// Both files must exist to confirm we're in vibe-validate repo
|
|
53
|
-
if (existsSync(wrapperPath) && existsSync(binPath)) {
|
|
54
|
-
return binPath;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return null;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Find local vibe-validate installation in node_modules
|
|
62
|
-
* Walks up directory tree from project root
|
|
63
|
-
*/
|
|
64
|
-
function findLocalInstall(projectRoot) {
|
|
65
|
-
let current = projectRoot;
|
|
66
|
-
|
|
67
|
-
while (true) {
|
|
68
|
-
const localBin = join(current, 'node_modules/@vibe-validate/cli/dist/bin.js');
|
|
69
|
-
if (existsSync(localBin)) {
|
|
70
|
-
return localBin;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const parent = dirname(current);
|
|
74
|
-
if (parent === current) {
|
|
75
|
-
// Reached filesystem root
|
|
76
|
-
break;
|
|
77
|
-
}
|
|
78
|
-
current = parent;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return null;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Main entry point - detects context and executes appropriate binary
|
|
86
|
-
*/
|
|
87
|
-
function main() {
|
|
88
|
-
const cwd = process.cwd();
|
|
89
|
-
const args = process.argv.slice(2);
|
|
90
|
-
|
|
91
|
-
// Find project root (where .git is, or cwd if no git)
|
|
92
|
-
const projectRoot = findProjectRoot(cwd);
|
|
93
|
-
|
|
94
|
-
let binPath;
|
|
95
|
-
let context;
|
|
96
|
-
|
|
97
|
-
// Priority 1: Check for developer mode (inside vibe-validate repo)
|
|
98
|
-
const devBin = getDevModeBinary(projectRoot);
|
|
99
|
-
if (devBin) {
|
|
100
|
-
binPath = devBin;
|
|
101
|
-
context = 'dev';
|
|
102
|
-
}
|
|
103
|
-
// Priority 2: Check for local install (node_modules)
|
|
104
|
-
else {
|
|
105
|
-
const localBin = findLocalInstall(projectRoot);
|
|
106
|
-
if (localBin) {
|
|
107
|
-
binPath = localBin;
|
|
108
|
-
context = 'local';
|
|
109
|
-
}
|
|
110
|
-
// Priority 3: Use global install (this script's location)
|
|
111
|
-
else {
|
|
112
|
-
binPath = join(__dirname, '../dist/bin.js');
|
|
113
|
-
context = 'global';
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// Execute the binary with all arguments
|
|
118
|
-
const result = spawnSync(process.execPath, [binPath, ...args], {
|
|
119
|
-
stdio: 'inherit',
|
|
120
|
-
env: {
|
|
121
|
-
...process.env,
|
|
122
|
-
VV_CONTEXT: context, // Pass context for debugging (optional)
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
// Exit with same code as child process
|
|
127
|
-
process.exit(result.status ?? 1);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
// Run main function
|
|
131
|
-
main();
|