@vibe-validate/cli 0.15.0-rc.1 → 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.
Files changed (2) hide show
  1. package/bin/vv +131 -0
  2. package/package.json +7 -7
package/bin/vv ADDED
@@ -0,0 +1,131 @@
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();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibe-validate/cli",
3
- "version": "0.15.0-rc.1",
3
+ "version": "0.15.0-rc.2",
4
4
  "description": "Command-line interface for vibe-validate validation framework",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -62,11 +62,11 @@
62
62
  "yaml": "^2.6.1",
63
63
  "zod": "^3.24.1",
64
64
  "zod-to-json-schema": "^3.24.6",
65
- "@vibe-validate/core": "0.15.0-rc.1",
66
- "@vibe-validate/git": "0.15.0-rc.1",
67
- "@vibe-validate/extractors": "0.15.0-rc.1",
68
- "@vibe-validate/config": "0.15.0-rc.1",
69
- "@vibe-validate/history": "0.15.0-rc.1"
65
+ "@vibe-validate/core": "0.15.0-rc.2",
66
+ "@vibe-validate/extractors": "0.15.0-rc.2",
67
+ "@vibe-validate/git": "0.15.0-rc.2",
68
+ "@vibe-validate/history": "0.15.0-rc.2",
69
+ "@vibe-validate/config": "0.15.0-rc.2"
70
70
  },
71
71
  "devDependencies": {
72
72
  "@types/node": "^20.14.8",
@@ -74,7 +74,7 @@
74
74
  "vitest": "^2.0.5"
75
75
  },
76
76
  "scripts": {
77
- "build": "tsc && cp bin/vibe-validate dist/vibe-validate && node dist/scripts/generate-watch-pr-schema.js && node dist/scripts/generate-run-result-schema.js",
77
+ "build": "tsc && cp bin/vibe-validate dist/vibe-validate && rm -f bin/vv && cp bin/vibe-validate bin/vv && node dist/scripts/generate-watch-pr-schema.js && node dist/scripts/generate-run-result-schema.js",
78
78
  "test": "vitest run",
79
79
  "test:watch": "vitest",
80
80
  "test:coverage": "vitest run --coverage",