@vibe-validate/cli 0.11.0 → 0.12.0
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 +14 -4
- package/dist/bin.js +88 -13
- package/dist/bin.js.map +1 -1
- package/dist/commands/cleanup.d.ts +4 -0
- package/dist/commands/cleanup.d.ts.map +1 -1
- package/dist/commands/cleanup.js +94 -2
- package/dist/commands/cleanup.js.map +1 -1
- package/dist/commands/config.d.ts +4 -0
- package/dist/commands/config.d.ts.map +1 -1
- package/dist/commands/config.js +83 -0
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/doctor.d.ts +4 -0
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +306 -28
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/generate-workflow.d.ts +4 -0
- package/dist/commands/generate-workflow.d.ts.map +1 -1
- package/dist/commands/generate-workflow.js +157 -48
- package/dist/commands/generate-workflow.js.map +1 -1
- package/dist/commands/history.d.ts +13 -0
- package/dist/commands/history.d.ts.map +1 -0
- package/dist/commands/history.js +415 -0
- package/dist/commands/history.js.map +1 -0
- package/dist/commands/init.d.ts +4 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +181 -0
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/pre-commit.d.ts +4 -0
- package/dist/commands/pre-commit.d.ts.map +1 -1
- package/dist/commands/pre-commit.js +158 -7
- package/dist/commands/pre-commit.js.map +1 -1
- package/dist/commands/state.d.ts +5 -1
- package/dist/commands/state.d.ts.map +1 -1
- package/dist/commands/state.js +192 -18
- package/dist/commands/state.js.map +1 -1
- package/dist/commands/sync-check.d.ts +4 -0
- package/dist/commands/sync-check.d.ts.map +1 -1
- package/dist/commands/sync-check.js +98 -2
- package/dist/commands/sync-check.js.map +1 -1
- package/dist/commands/validate.d.ts +5 -1
- package/dist/commands/validate.d.ts.map +1 -1
- package/dist/commands/validate.js +184 -28
- package/dist/commands/validate.js.map +1 -1
- package/dist/commands/watch-pr.d.ts +4 -0
- package/dist/commands/watch-pr.d.ts.map +1 -1
- package/dist/commands/watch-pr.js +175 -14
- package/dist/commands/watch-pr.js.map +1 -1
- package/dist/schemas/watch-pr-schema.d.ts +40 -40
- package/dist/schemas/watch-pr-schema.js +1 -1
- package/dist/schemas/watch-pr-schema.js.map +1 -1
- package/dist/services/ci-provider.d.ts +13 -8
- package/dist/services/ci-provider.d.ts.map +1 -1
- package/dist/services/ci-providers/github-actions.d.ts +5 -4
- package/dist/services/ci-providers/github-actions.d.ts.map +1 -1
- package/dist/services/ci-providers/github-actions.js +36 -27
- package/dist/services/ci-providers/github-actions.js.map +1 -1
- package/dist/utils/check-validation.d.ts +7 -4
- package/dist/utils/check-validation.d.ts.map +1 -1
- package/dist/utils/check-validation.js +129 -48
- package/dist/utils/check-validation.js.map +1 -1
- package/dist/utils/run-validation-with-cache.d.ts +48 -0
- package/dist/utils/run-validation-with-cache.d.ts.map +1 -0
- package/dist/utils/run-validation-with-cache.js +123 -0
- package/dist/utils/run-validation-with-cache.js.map +1 -0
- package/dist/utils/runner-adapter.d.ts +1 -0
- package/dist/utils/runner-adapter.d.ts.map +1 -1
- package/dist/utils/runner-adapter.js +25 -17
- package/dist/utils/runner-adapter.js.map +1 -1
- package/dist/utils/setup-checks/gitignore-check.d.ts +10 -15
- package/dist/utils/setup-checks/gitignore-check.d.ts.map +1 -1
- package/dist/utils/setup-checks/gitignore-check.js +20 -137
- package/dist/utils/setup-checks/gitignore-check.js.map +1 -1
- package/dist/utils/validate-workflow.d.ts +28 -0
- package/dist/utils/validate-workflow.d.ts.map +1 -0
- package/dist/utils/validate-workflow.js +247 -0
- package/dist/utils/validate-workflow.js.map +1 -0
- package/dist/utils/validation-cache.d.ts +30 -0
- package/dist/utils/validation-cache.d.ts.map +1 -0
- package/dist/utils/validation-cache.js +57 -0
- package/dist/utils/validation-cache.js.map +1 -0
- package/package.json +16 -14
- package/watch-pr-result.schema.json +1 -1
- package/LICENSE +0 -21
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pre-commit.d.ts","sourceRoot":"","sources":["../../src/commands/pre-commit.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AASzC,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"pre-commit.d.ts","sourceRoot":"","sources":["../../src/commands/pre-commit.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AASzC,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA8IvD;AAED;;GAEG;AACH,wBAAgB,wBAAwB,IAAI,IAAI,CA4F/C"}
|
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
* Runs branch sync check + validation before allowing commit.
|
|
5
5
|
* This is the recommended workflow before committing code.
|
|
6
6
|
*/
|
|
7
|
-
import { runValidation } from '@vibe-validate/core';
|
|
8
7
|
import { checkBranchSync } from '@vibe-validate/git';
|
|
9
8
|
import { getRemoteBranch } from '@vibe-validate/config';
|
|
10
9
|
import { loadConfig } from '../utils/config-loader.js';
|
|
11
|
-
import { createRunnerConfig } from '../utils/runner-adapter.js';
|
|
12
10
|
import { detectContext } from '../utils/context-detector.js';
|
|
11
|
+
import { runValidateWorkflow } from '../utils/validate-workflow.js';
|
|
12
|
+
import { execSync } from 'child_process';
|
|
13
13
|
import chalk from 'chalk';
|
|
14
14
|
export function preCommitCommand(program) {
|
|
15
15
|
program
|
|
@@ -52,15 +52,70 @@ export function preCommitCommand(program) {
|
|
|
52
52
|
const context = detectContext();
|
|
53
53
|
// Step 4: Verbose mode is ONLY enabled via explicit --verbose flag
|
|
54
54
|
const verbose = options.verbose ?? false;
|
|
55
|
-
// Step 5: Run
|
|
55
|
+
// Step 5: Run secret scanning if enabled
|
|
56
|
+
const secretScanning = config.hooks?.preCommit?.secretScanning;
|
|
57
|
+
if (secretScanning?.enabled && secretScanning?.scanCommand) {
|
|
58
|
+
console.log(chalk.blue('\n🔒 Running secret scanning...'));
|
|
59
|
+
try {
|
|
60
|
+
const result = execSync(secretScanning.scanCommand, {
|
|
61
|
+
encoding: 'utf8',
|
|
62
|
+
stdio: 'pipe',
|
|
63
|
+
});
|
|
64
|
+
// Show scan output if verbose
|
|
65
|
+
if (verbose && result) {
|
|
66
|
+
console.log(chalk.gray(result));
|
|
67
|
+
}
|
|
68
|
+
console.log(chalk.green('✅ No secrets detected'));
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
// Secret scanning failed (either tool missing or secrets found)
|
|
72
|
+
if (error && typeof error === 'object' && 'code' in error && error.code === 'ENOENT') {
|
|
73
|
+
// Tool not found
|
|
74
|
+
const toolName = secretScanning.scanCommand.split(' ')[0];
|
|
75
|
+
console.error(chalk.red('\n❌ Secret scanning tool not found'));
|
|
76
|
+
console.error(chalk.yellow(` Command: ${chalk.white(secretScanning.scanCommand)}`));
|
|
77
|
+
console.error(chalk.yellow(` Tool '${toolName}' is not installed or not in PATH`));
|
|
78
|
+
console.error(chalk.blue('\n💡 Fix options:'));
|
|
79
|
+
console.error(chalk.gray(' 1. Install the tool (e.g., brew install gitleaks)'));
|
|
80
|
+
console.error(chalk.gray(' 2. Disable scanning: set hooks.preCommit.secretScanning.enabled=false'));
|
|
81
|
+
process.exit(1);
|
|
82
|
+
}
|
|
83
|
+
else if (error && typeof error === 'object' && 'stderr' in error && 'stdout' in error) {
|
|
84
|
+
// Tool ran but found secrets
|
|
85
|
+
const stderr = 'stderr' in error && error.stderr ? String(error.stderr) : '';
|
|
86
|
+
const stdout = 'stdout' in error && error.stdout ? String(error.stdout) : '';
|
|
87
|
+
console.error(chalk.red('\n❌ Secret scanning detected potential secrets in staged files\n'));
|
|
88
|
+
// Show scan output
|
|
89
|
+
if (stdout) {
|
|
90
|
+
console.error(stdout);
|
|
91
|
+
}
|
|
92
|
+
if (stderr) {
|
|
93
|
+
console.error(stderr);
|
|
94
|
+
}
|
|
95
|
+
console.error(chalk.blue('\n💡 Fix options:'));
|
|
96
|
+
console.error(chalk.gray(' 1. Remove secrets from staged files'));
|
|
97
|
+
console.error(chalk.gray(' 2. Use .gitleaksignore to mark false positives (if using gitleaks)'));
|
|
98
|
+
console.error(chalk.gray(' 3. Disable scanning: set hooks.preCommit.secretScanning.enabled=false'));
|
|
99
|
+
process.exit(1);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
// Unknown error
|
|
103
|
+
console.error(chalk.red('\n❌ Secret scanning failed with unknown error'));
|
|
104
|
+
console.error(chalk.gray(String(error)));
|
|
105
|
+
process.exit(1);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
// Step 6: Run validation with caching
|
|
56
110
|
console.log(chalk.blue('\n🔄 Running validation...'));
|
|
57
|
-
const
|
|
111
|
+
const result = await runValidateWorkflow(config, {
|
|
58
112
|
force: false, // Respect cache by default
|
|
59
113
|
verbose,
|
|
114
|
+
yaml: false, // Pre-commit uses human-readable output
|
|
115
|
+
check: false,
|
|
60
116
|
context,
|
|
61
117
|
});
|
|
62
|
-
|
|
63
|
-
// Step 6: Report results
|
|
118
|
+
// Step 7: Report results
|
|
64
119
|
if (result.passed) {
|
|
65
120
|
console.log(chalk.green('\n✅ Pre-commit checks passed!'));
|
|
66
121
|
console.log(chalk.gray(' Safe to commit.'));
|
|
@@ -70,7 +125,7 @@ export function preCommitCommand(program) {
|
|
|
70
125
|
console.error(chalk.red('\n❌ Pre-commit checks failed'));
|
|
71
126
|
console.error(chalk.yellow(' Fix errors before committing.'));
|
|
72
127
|
// Show agent-friendly error details
|
|
73
|
-
console.error(chalk.blue('\n📋 Error details:'), chalk.white(
|
|
128
|
+
console.error(chalk.blue('\n📋 Error details:'), chalk.white('vibe-validate state'));
|
|
74
129
|
if (result.rerunCommand) {
|
|
75
130
|
console.error(chalk.blue('🔄 To retry:'), chalk.white(result.rerunCommand));
|
|
76
131
|
}
|
|
@@ -86,4 +141,100 @@ export function preCommitCommand(program) {
|
|
|
86
141
|
}
|
|
87
142
|
});
|
|
88
143
|
}
|
|
144
|
+
/**
|
|
145
|
+
* Show verbose help with detailed documentation
|
|
146
|
+
*/
|
|
147
|
+
export function showPreCommitVerboseHelp() {
|
|
148
|
+
console.log(`# pre-commit Command Reference
|
|
149
|
+
|
|
150
|
+
> Run branch sync check + validation (recommended before commit)
|
|
151
|
+
|
|
152
|
+
## Overview
|
|
153
|
+
|
|
154
|
+
The \`pre-commit\` command runs a comprehensive pre-commit workflow to ensure your code is synced with the remote main branch and passes all validation checks before allowing a commit. This prevents pushing broken code or creating merge conflicts.
|
|
155
|
+
|
|
156
|
+
## How It Works
|
|
157
|
+
|
|
158
|
+
1. Runs sync-check (fails if branch behind origin/main)
|
|
159
|
+
2. Runs validate (with caching)
|
|
160
|
+
3. Reports git status (warns about unstaged files)
|
|
161
|
+
|
|
162
|
+
## Options
|
|
163
|
+
|
|
164
|
+
- \`--skip-sync\` - Skip branch sync check (not recommended)
|
|
165
|
+
- \`-v, --verbose\` - Show detailed progress and output
|
|
166
|
+
|
|
167
|
+
## Exit Codes
|
|
168
|
+
|
|
169
|
+
- \`0\` - Sync OK and validation passed
|
|
170
|
+
- \`1\` - Sync failed OR validation failed
|
|
171
|
+
|
|
172
|
+
## Examples
|
|
173
|
+
|
|
174
|
+
\`\`\`bash
|
|
175
|
+
# Standard pre-commit workflow
|
|
176
|
+
vibe-validate pre-commit
|
|
177
|
+
|
|
178
|
+
# Skip sync check (not recommended)
|
|
179
|
+
vibe-validate pre-commit --skip-sync
|
|
180
|
+
\`\`\`
|
|
181
|
+
|
|
182
|
+
## Common Workflows
|
|
183
|
+
|
|
184
|
+
### Typical usage before committing
|
|
185
|
+
|
|
186
|
+
\`\`\`bash
|
|
187
|
+
# Make changes
|
|
188
|
+
git add .
|
|
189
|
+
|
|
190
|
+
# Run pre-commit checks
|
|
191
|
+
vibe-validate pre-commit
|
|
192
|
+
|
|
193
|
+
# If passed, commit
|
|
194
|
+
git commit -m "Your message"
|
|
195
|
+
\`\`\`
|
|
196
|
+
|
|
197
|
+
### Integrate with Husky
|
|
198
|
+
|
|
199
|
+
\`\`\`bash
|
|
200
|
+
# Setup pre-commit hook
|
|
201
|
+
npx husky init
|
|
202
|
+
echo "npx vibe-validate pre-commit" > .husky/pre-commit
|
|
203
|
+
|
|
204
|
+
# Now runs automatically before every commit
|
|
205
|
+
git commit -m "Your message"
|
|
206
|
+
\`\`\`
|
|
207
|
+
|
|
208
|
+
## Error Recovery
|
|
209
|
+
|
|
210
|
+
### If sync check fails
|
|
211
|
+
|
|
212
|
+
**Branch is behind origin/main:**
|
|
213
|
+
\`\`\`bash
|
|
214
|
+
# Fetch latest changes
|
|
215
|
+
git fetch origin
|
|
216
|
+
|
|
217
|
+
# Merge origin/main
|
|
218
|
+
git merge origin/main
|
|
219
|
+
|
|
220
|
+
# Resolve conflicts if any
|
|
221
|
+
|
|
222
|
+
# Retry pre-commit
|
|
223
|
+
vibe-validate pre-commit
|
|
224
|
+
\`\`\`
|
|
225
|
+
|
|
226
|
+
### If validation fails
|
|
227
|
+
|
|
228
|
+
**Fix errors shown in output:**
|
|
229
|
+
\`\`\`bash
|
|
230
|
+
# View detailed error info
|
|
231
|
+
vibe-validate state
|
|
232
|
+
|
|
233
|
+
# Fix the errors
|
|
234
|
+
|
|
235
|
+
# Retry pre-commit
|
|
236
|
+
vibe-validate pre-commit
|
|
237
|
+
\`\`\`
|
|
238
|
+
`);
|
|
239
|
+
}
|
|
89
240
|
//# sourceMappingURL=pre-commit.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pre-commit.js","sourceRoot":"","sources":["../../src/commands/pre-commit.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"pre-commit.js","sourceRo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KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC;gBAC9E,CAAC;gBACD,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC;oBACvB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC;gBAC5E,CAAC;gBAED,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAClB,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,wCAAwC,CAAC,EAAE,KAAK,CAAC,CAAC;YAC1E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,wBAAwB;IACtC,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0Fb,CAAC,CAAC;AACH,CAAC"}
|
package/dist/commands/state.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* State Command
|
|
3
3
|
*
|
|
4
|
-
* Display current validation state from cache
|
|
4
|
+
* Display current validation state from git notes cache.
|
|
5
5
|
*/
|
|
6
6
|
import type { Command } from 'commander';
|
|
7
7
|
export declare function stateCommand(program: Command): void;
|
|
8
|
+
/**
|
|
9
|
+
* Show verbose help with detailed documentation
|
|
10
|
+
*/
|
|
11
|
+
export declare function showStateVerboseHelp(): void;
|
|
8
12
|
//# sourceMappingURL=state.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/commands/state.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/commands/state.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOzC,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA4FnD;AAgED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,IAAI,CAyH3C"}
|
package/dist/commands/state.js
CHANGED
|
@@ -1,46 +1,89 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* State Command
|
|
3
3
|
*
|
|
4
|
-
* Display current validation state from cache
|
|
4
|
+
* Display current validation state from git notes cache.
|
|
5
5
|
*/
|
|
6
|
-
import { readFileSync, existsSync } from 'fs';
|
|
7
|
-
import { join } from 'path';
|
|
8
6
|
import chalk from 'chalk';
|
|
9
|
-
import {
|
|
7
|
+
import { stringify as stringifyYaml } from 'yaml';
|
|
8
|
+
import { getGitTreeHash } from '@vibe-validate/git';
|
|
9
|
+
import { readHistoryNote, hasHistoryForTree } from '@vibe-validate/history';
|
|
10
10
|
export function stateCommand(program) {
|
|
11
11
|
program
|
|
12
12
|
.command('state')
|
|
13
|
-
.description('Show current validation state')
|
|
13
|
+
.description('Show current validation state from git notes')
|
|
14
14
|
.option('-v, --verbose', 'Show full error output without truncation')
|
|
15
|
-
.option('--file <path>', 'State file path', '.vibe-validate-state.yaml')
|
|
16
15
|
.action(async (options) => {
|
|
17
16
|
try {
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
// Check if
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
// Get current tree hash
|
|
18
|
+
const treeHash = await getGitTreeHash();
|
|
19
|
+
// Check if history exists for current tree
|
|
20
|
+
const hasHistory = await hasHistoryForTree(treeHash);
|
|
21
|
+
if (!hasHistory) {
|
|
22
|
+
// Always show tree hash, even when no history exists (helpful for debugging)
|
|
23
|
+
const noStateOutput = {
|
|
24
|
+
exists: false,
|
|
25
|
+
treeHash: treeHash,
|
|
26
|
+
};
|
|
27
|
+
console.log(stringifyYaml(noStateOutput));
|
|
23
28
|
if (options.verbose) {
|
|
24
|
-
console.log(chalk.gray('
|
|
29
|
+
console.log(chalk.gray('ℹ️ No validation state found for current worktree'));
|
|
25
30
|
console.log(chalk.gray(' Run: vibe-validate validate'));
|
|
26
31
|
}
|
|
27
32
|
process.exit(0);
|
|
28
33
|
}
|
|
29
|
-
// Read
|
|
30
|
-
const
|
|
31
|
-
|
|
34
|
+
// Read history note
|
|
35
|
+
const historyNote = await readHistoryNote(treeHash);
|
|
36
|
+
if (!historyNote || historyNote.runs.length === 0) {
|
|
37
|
+
// Always show tree hash, even when no runs exist
|
|
38
|
+
const noStateOutput = {
|
|
39
|
+
exists: false,
|
|
40
|
+
treeHash: treeHash,
|
|
41
|
+
};
|
|
42
|
+
console.log(stringifyYaml(noStateOutput));
|
|
43
|
+
if (options.verbose) {
|
|
44
|
+
console.log(chalk.gray('ℹ️ No validation runs found for current worktree'));
|
|
45
|
+
}
|
|
46
|
+
process.exit(0);
|
|
47
|
+
}
|
|
48
|
+
// Get most recent run
|
|
49
|
+
const mostRecentRun = historyNote.runs[historyNote.runs.length - 1];
|
|
50
|
+
const result = mostRecentRun.result;
|
|
51
|
+
// Convert to state format (compatible with old format)
|
|
52
|
+
const state = {
|
|
53
|
+
passed: result.passed,
|
|
54
|
+
timestamp: result.timestamp,
|
|
55
|
+
treeHash: result.treeHash,
|
|
56
|
+
failedStep: result.failedStep,
|
|
57
|
+
failedStepOutput: result.failedStepOutput,
|
|
58
|
+
phases: result.phases,
|
|
59
|
+
rerunCommand: result.rerunCommand,
|
|
60
|
+
};
|
|
32
61
|
// Output YAML format (always)
|
|
62
|
+
const yamlContent = stringifyYaml(state);
|
|
33
63
|
if (options.verbose) {
|
|
34
64
|
// Verbose mode: show full output with colors and explanations
|
|
35
|
-
displayVerboseState(state,
|
|
65
|
+
displayVerboseState(state, yamlContent, mostRecentRun.branch);
|
|
36
66
|
}
|
|
37
67
|
else {
|
|
38
68
|
// Minimal mode: just the YAML content
|
|
39
|
-
console.log(
|
|
69
|
+
console.log(yamlContent);
|
|
40
70
|
}
|
|
41
71
|
process.exit(0);
|
|
42
72
|
}
|
|
43
73
|
catch (error) {
|
|
74
|
+
if (error instanceof Error && error.message.includes('not a git repository')) {
|
|
75
|
+
// Not in git repo - show structured output
|
|
76
|
+
const noGitOutput = {
|
|
77
|
+
exists: false,
|
|
78
|
+
error: 'Not in git repository',
|
|
79
|
+
};
|
|
80
|
+
console.log(stringifyYaml(noGitOutput));
|
|
81
|
+
if (options.verbose) {
|
|
82
|
+
console.log(chalk.gray('ℹ️ Not in a git repository'));
|
|
83
|
+
console.log(chalk.gray(' Validation history requires git'));
|
|
84
|
+
}
|
|
85
|
+
process.exit(0);
|
|
86
|
+
}
|
|
44
87
|
console.error(chalk.red('❌ Failed to read validation state:'), error);
|
|
45
88
|
process.exit(1);
|
|
46
89
|
}
|
|
@@ -49,7 +92,7 @@ export function stateCommand(program) {
|
|
|
49
92
|
/**
|
|
50
93
|
* Display validation state in verbose format with colors and explanations
|
|
51
94
|
*/
|
|
52
|
-
function displayVerboseState(state, yamlContent) {
|
|
95
|
+
function displayVerboseState(state, yamlContent, branch) {
|
|
53
96
|
// First show the raw YAML
|
|
54
97
|
console.log(yamlContent);
|
|
55
98
|
// Then add colored summary and explanations
|
|
@@ -68,6 +111,8 @@ function displayVerboseState(state, yamlContent) {
|
|
|
68
111
|
console.log(chalk.gray(`⏰ Last Run: ${timestamp.toLocaleString()}`));
|
|
69
112
|
// Tree hash
|
|
70
113
|
console.log(chalk.gray(`🌳 Git Tree Hash: ${state.treeHash.substring(0, 12)}...`));
|
|
114
|
+
// Branch
|
|
115
|
+
console.log(chalk.gray(`🌿 Branch: ${branch}`));
|
|
71
116
|
// Failed step details (if any)
|
|
72
117
|
if (!state.passed && state.failedStep) {
|
|
73
118
|
console.log(chalk.red(`\n❌ Failed Step: ${state.failedStep}`));
|
|
@@ -83,9 +128,138 @@ function displayVerboseState(state, yamlContent) {
|
|
|
83
128
|
console.log(chalk.gray(' 1. Fix the failed step'));
|
|
84
129
|
console.log(chalk.gray(' 2. Re-run: vibe-validate validate'));
|
|
85
130
|
console.log(chalk.gray(' 3. Or force re-validation: vibe-validate validate --force'));
|
|
131
|
+
// Suggest reporting extractor issues
|
|
132
|
+
console.log(chalk.gray('\n💡 Error output unclear or missing details?'));
|
|
133
|
+
console.log(chalk.gray(' Help improve extraction: https://github.com/jdutton/vibe-validate/issues/new?template=extractor-improvement.yml'));
|
|
86
134
|
}
|
|
87
135
|
else {
|
|
88
136
|
console.log(chalk.green('\n✅ Validation passed! Safe to commit.'));
|
|
89
137
|
}
|
|
138
|
+
console.log(chalk.gray('\n💡 Tip: View full history with: vibe-validate history list'));
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Show verbose help with detailed documentation
|
|
142
|
+
*/
|
|
143
|
+
export function showStateVerboseHelp() {
|
|
144
|
+
console.log(`# state Command Reference
|
|
145
|
+
|
|
146
|
+
> View current validation state
|
|
147
|
+
|
|
148
|
+
## Overview
|
|
149
|
+
|
|
150
|
+
The \`state\` command shows the current validation status without re-running validation. It reads the cached validation result from git notes.
|
|
151
|
+
|
|
152
|
+
## How It Works
|
|
153
|
+
|
|
154
|
+
1. **Reads validation state** from git notes (if exists)
|
|
155
|
+
2. **Shows pass/fail status**
|
|
156
|
+
3. **Shows git tree hash** (cache key)
|
|
157
|
+
4. **Shows timestamp** of last validation
|
|
158
|
+
5. **Shows error summary** (if failed)
|
|
159
|
+
|
|
160
|
+
## Options
|
|
161
|
+
|
|
162
|
+
- \`-v, --verbose\` - Show full error output and details
|
|
163
|
+
- \`-y, --yaml\` - Output as YAML (machine-readable)
|
|
164
|
+
|
|
165
|
+
## Exit Codes
|
|
166
|
+
|
|
167
|
+
- \`0\` - State file found and read successfully
|
|
168
|
+
- \`1\` - State file not found or invalid
|
|
169
|
+
|
|
170
|
+
## Examples
|
|
171
|
+
|
|
172
|
+
\`\`\`bash
|
|
173
|
+
# Check current state
|
|
174
|
+
vibe-validate state
|
|
175
|
+
|
|
176
|
+
# See full error details
|
|
177
|
+
vibe-validate state --verbose
|
|
178
|
+
|
|
179
|
+
# Machine-readable output
|
|
180
|
+
vibe-validate state --yaml
|
|
181
|
+
\`\`\`
|
|
182
|
+
|
|
183
|
+
## Output Formats
|
|
184
|
+
|
|
185
|
+
### Standard Output
|
|
186
|
+
\`\`\`
|
|
187
|
+
✅ Validation Status: PASSED
|
|
188
|
+
📅 Last validated: 2025-10-23T14:30:00Z
|
|
189
|
+
🔑 Tree hash: 2b62c71a3f
|
|
190
|
+
⏱️ Duration: 62.4s
|
|
191
|
+
\`\`\`
|
|
192
|
+
|
|
193
|
+
### Verbose Output
|
|
194
|
+
Includes:
|
|
195
|
+
- Full error messages
|
|
196
|
+
- Stack traces (if available)
|
|
197
|
+
- Failed step details
|
|
198
|
+
- Recommendations for fixing
|
|
199
|
+
|
|
200
|
+
### YAML Output
|
|
201
|
+
\`\`\`yaml
|
|
202
|
+
exists: true
|
|
203
|
+
passed: true
|
|
204
|
+
timestamp: 2025-10-23T14:30:00Z
|
|
205
|
+
treeHash: 2b62c71a3f...
|
|
206
|
+
duration: 62.4
|
|
207
|
+
\`\`\`
|
|
208
|
+
|
|
209
|
+
## When to Use
|
|
210
|
+
|
|
211
|
+
**Use \`state\` when you want to:**
|
|
212
|
+
- Check validation status without re-running
|
|
213
|
+
- Debug why validation failed
|
|
214
|
+
- See what tree hash is cached
|
|
215
|
+
- Verify validation result before committing
|
|
216
|
+
- Get machine-readable validation status
|
|
217
|
+
|
|
218
|
+
**Don't use \`state\` when:**
|
|
219
|
+
- You want to force fresh validation (use \`validate --force\`)
|
|
220
|
+
- You want to run validation if cache is stale (use \`validate\`)
|
|
221
|
+
|
|
222
|
+
## Integration with Other Commands
|
|
223
|
+
|
|
224
|
+
- \`vibe-validate validate\` - Run validation (creates state)
|
|
225
|
+
- \`vibe-validate validate --check\` - Same as \`state\` but with different exit codes
|
|
226
|
+
- \`vibe-validate history list\` - View validation history timeline
|
|
227
|
+
- \`vibe-validate history show <hash>\` - View state for specific tree hash
|
|
228
|
+
|
|
229
|
+
## Common Workflows
|
|
230
|
+
|
|
231
|
+
### Debug validation failure
|
|
232
|
+
\`\`\`bash
|
|
233
|
+
# 1. Run validation
|
|
234
|
+
vibe-validate validate
|
|
235
|
+
|
|
236
|
+
# 2. If fails, see details
|
|
237
|
+
vibe-validate state --verbose
|
|
238
|
+
|
|
239
|
+
# 3. Fix errors
|
|
240
|
+
|
|
241
|
+
# 4. Re-run
|
|
242
|
+
vibe-validate validate
|
|
243
|
+
\`\`\`
|
|
244
|
+
|
|
245
|
+
### AI agent workflow
|
|
246
|
+
\`\`\`bash
|
|
247
|
+
# Run validation
|
|
248
|
+
vibe-validate validate --yaml > /dev/null 2>&1
|
|
249
|
+
|
|
250
|
+
# Get structured result
|
|
251
|
+
vibe-validate state --yaml
|
|
252
|
+
\`\`\`
|
|
253
|
+
|
|
254
|
+
### Pre-commit check
|
|
255
|
+
\`\`\`bash
|
|
256
|
+
# Check if validation already passed
|
|
257
|
+
if vibe-validate state --yaml | grep -q "passed: true"; then
|
|
258
|
+
echo "Validation already passed, skipping"
|
|
259
|
+
else
|
|
260
|
+
vibe-validate validate
|
|
261
|
+
fi
|
|
262
|
+
\`\`\`
|
|
263
|
+
`);
|
|
90
264
|
}
|
|
91
265
|
//# sourceMappingURL=state.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.js","sourceRoot":"","sources":["../../src/commands/state.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,
|
|
1
|
+
{"version":3,"file":"state.js","sourceRoot":"","sources":["../../src/commands/state.ts"],"names":[],"mappings":"AAAA;;;;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C,aAAa;IACb,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;QAClB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC;QAC3C,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC,CAAC;QACpD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,qCAAqC,CAAC,CAAC,CAAC;QAC/D,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,6DAA6D,CAAC,CAAC,CAAC;QAEvF,qCAAqC;QACrC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,+CAA+C,CAAC,CAAC,CAAC;QACzE,OAAO,CAAC,GAAG,CACT,KAAK,CAAC,IAAI,CACR,oHAAoH,CACrH,CACF,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,wCAAwC,CAAC,CAAC,CAAC;IACrE,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,8DAA8D,CAAC,CAAC,CAAC;AAC1F,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB;IAClC,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuHb,CAAC,CAAC;AACH,CAAC"}
|
|
@@ -5,4 +5,8 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type { Command } from 'commander';
|
|
7
7
|
export declare function syncCheckCommand(program: Command): void;
|
|
8
|
+
/**
|
|
9
|
+
* Show verbose help with detailed documentation
|
|
10
|
+
*/
|
|
11
|
+
export declare function showSyncCheckVerboseHelp(): void;
|
|
8
12
|
//# sourceMappingURL=sync-check.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-check.d.ts","sourceRoot":"","sources":["../../src/commands/sync-check.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOzC,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"sync-check.d.ts","sourceRoot":"","sources":["../../src/commands/sync-check.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOzC,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA+DvD;AAmCD;;GAEG;AACH,wBAAgB,wBAAwB,IAAI,IAAI,CA6E/C"}
|
|
@@ -32,9 +32,24 @@ export function syncCheckCommand(program) {
|
|
|
32
32
|
const result = await checkBranchSync({
|
|
33
33
|
remoteBranch,
|
|
34
34
|
});
|
|
35
|
-
// Output based on
|
|
35
|
+
// Output based on yaml flag
|
|
36
36
|
if (options.yaml) {
|
|
37
|
-
|
|
37
|
+
// YAML mode: Output structured result to stdout
|
|
38
|
+
// Small delay to ensure stderr is flushed
|
|
39
|
+
await new Promise(resolve => setTimeout(resolve, 10));
|
|
40
|
+
// RFC 4627 separator
|
|
41
|
+
process.stdout.write('---\n');
|
|
42
|
+
// Write pure YAML
|
|
43
|
+
process.stdout.write(stringifyYaml(result));
|
|
44
|
+
// CRITICAL: Wait for stdout to flush before exiting
|
|
45
|
+
await new Promise(resolve => {
|
|
46
|
+
if (process.stdout.write('')) {
|
|
47
|
+
resolve();
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
process.stdout.once('drain', resolve);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
38
53
|
}
|
|
39
54
|
else {
|
|
40
55
|
// Human-friendly format
|
|
@@ -80,4 +95,85 @@ function displayHumanSyncCheck(result, mainBranch) {
|
|
|
80
95
|
}
|
|
81
96
|
console.log(chalk.gray('─'.repeat(50)));
|
|
82
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* Show verbose help with detailed documentation
|
|
100
|
+
*/
|
|
101
|
+
export function showSyncCheckVerboseHelp() {
|
|
102
|
+
console.log(`# sync-check Command Reference
|
|
103
|
+
|
|
104
|
+
> Check if branch is behind remote main branch
|
|
105
|
+
|
|
106
|
+
## Overview
|
|
107
|
+
|
|
108
|
+
The \`sync-check\` command verifies that your current branch is up to date with the remote main branch (usually origin/main). It compares local and remote commit histories without making any changes to your repository.
|
|
109
|
+
|
|
110
|
+
## How It Works
|
|
111
|
+
|
|
112
|
+
1. Checks if current branch has a remote tracking branch
|
|
113
|
+
2. Compares local and remote commit histories
|
|
114
|
+
3. Reports sync status (up to date, behind, or no remote)
|
|
115
|
+
|
|
116
|
+
## Options
|
|
117
|
+
|
|
118
|
+
- \`--main-branch <branch>\` - Main branch name (overrides config, default: main)
|
|
119
|
+
- \`--remote-origin <remote>\` - Remote origin name (overrides config, default: origin)
|
|
120
|
+
- \`--yaml\` - Output YAML only (no human-friendly display)
|
|
121
|
+
|
|
122
|
+
## Exit Codes
|
|
123
|
+
|
|
124
|
+
- \`0\` - Up to date or no remote tracking
|
|
125
|
+
- \`1\` - Branch is behind (needs merge)
|
|
126
|
+
- \`2\` - Git command failed
|
|
127
|
+
|
|
128
|
+
## Examples
|
|
129
|
+
|
|
130
|
+
\`\`\`bash
|
|
131
|
+
# Check sync with default main branch
|
|
132
|
+
vibe-validate sync-check
|
|
133
|
+
|
|
134
|
+
# Check sync with custom main branch
|
|
135
|
+
vibe-validate sync-check --main-branch develop
|
|
136
|
+
|
|
137
|
+
# YAML output only
|
|
138
|
+
vibe-validate sync-check --yaml
|
|
139
|
+
\`\`\`
|
|
140
|
+
|
|
141
|
+
## Common Workflows
|
|
142
|
+
|
|
143
|
+
### Before starting work
|
|
144
|
+
|
|
145
|
+
\`\`\`bash
|
|
146
|
+
# Check if your branch is behind
|
|
147
|
+
vibe-validate sync-check
|
|
148
|
+
|
|
149
|
+
# If behind, merge latest
|
|
150
|
+
git merge origin/main
|
|
151
|
+
\`\`\`
|
|
152
|
+
|
|
153
|
+
### In CI/CD pipeline
|
|
154
|
+
|
|
155
|
+
\`\`\`bash
|
|
156
|
+
# Check sync as YAML for parsing
|
|
157
|
+
vibe-validate sync-check --yaml
|
|
158
|
+
\`\`\`
|
|
159
|
+
|
|
160
|
+
## Error Recovery
|
|
161
|
+
|
|
162
|
+
### If branch is behind (exit 1)
|
|
163
|
+
|
|
164
|
+
**Merge the remote branch:**
|
|
165
|
+
\`\`\`bash
|
|
166
|
+
# Fetch latest changes
|
|
167
|
+
git fetch origin
|
|
168
|
+
|
|
169
|
+
# Merge origin/main (or git rebase origin/main)
|
|
170
|
+
git merge origin/main
|
|
171
|
+
|
|
172
|
+
# Resolve conflicts if any
|
|
173
|
+
|
|
174
|
+
# Retry sync check
|
|
175
|
+
vibe-validate sync-check
|
|
176
|
+
\`\`\`
|
|
177
|
+
`);
|
|
178
|
+
}
|
|
83
179
|
//# sourceMappingURL=sync-check.js.map
|