@vibe-validate/cli 0.19.5 → 0.19.7

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 (36) hide show
  1. package/README.md +5 -5
  2. package/dist/bin.js +28 -39
  3. package/dist/bin.js.map +1 -1
  4. package/dist/command-registry.d.ts +46 -0
  5. package/dist/command-registry.d.ts.map +1 -0
  6. package/dist/command-registry.js +60 -0
  7. package/dist/command-registry.js.map +1 -0
  8. package/dist/commands/cleanup.d.ts.map +1 -1
  9. package/dist/commands/cleanup.js +13 -5
  10. package/dist/commands/cleanup.js.map +1 -1
  11. package/dist/commands/create-extractor.d.ts +67 -0
  12. package/dist/commands/create-extractor.d.ts.map +1 -1
  13. package/dist/commands/create-extractor.js +129 -56
  14. package/dist/commands/create-extractor.js.map +1 -1
  15. package/dist/commands/pre-commit.d.ts.map +1 -1
  16. package/dist/commands/pre-commit.js +214 -58
  17. package/dist/commands/pre-commit.js.map +1 -1
  18. package/dist/commands/state.d.ts.map +1 -1
  19. package/dist/commands/state.js +8 -4
  20. package/dist/commands/state.js.map +1 -1
  21. package/dist/commands/validate.d.ts.map +1 -1
  22. package/dist/commands/validate.js +22 -8
  23. package/dist/commands/validate.js.map +1 -1
  24. package/dist/schemas/watch-pr-result.schema.d.ts +18 -18
  25. package/dist/schemas/watch-pr-schema.d.ts +4 -4
  26. package/dist/utils/check-validation.d.ts.map +1 -1
  27. package/dist/utils/check-validation.js +12 -5
  28. package/dist/utils/check-validation.js.map +1 -1
  29. package/dist/utils/display-cached-result.d.ts +21 -0
  30. package/dist/utils/display-cached-result.d.ts.map +1 -1
  31. package/dist/utils/display-cached-result.js +33 -2
  32. package/dist/utils/display-cached-result.js.map +1 -1
  33. package/dist/utils/validate-workflow.d.ts.map +1 -1
  34. package/dist/utils/validate-workflow.js +22 -11
  35. package/dist/utils/validate-workflow.js.map +1 -1
  36. package/package.json +9 -8
@@ -5,13 +5,16 @@
5
5
  * Creates a fully-functional plugin directory with tests, samples, and documentation.
6
6
  */
7
7
  import { writeFileSync, existsSync, readFileSync } from 'node:fs';
8
- import { join, dirname } from 'node:path';
8
+ import { join, dirname, relative } from 'node:path';
9
9
  import { fileURLToPath } from 'node:url';
10
- import { mkdirSyncReal, normalizePath } from '@vibe-validate/utils';
10
+ import { mkdirSyncReal, normalizePath, toForwardSlash } from '@vibe-validate/utils';
11
11
  import chalk from 'chalk';
12
12
  import prompts from 'prompts';
13
13
  import { getCommandName } from '../utils/command-name.js';
14
14
  import { detectPackageManager, getInstallCommandUnfrozen } from '../utils/package-manager-commands.js';
15
+ import { outputYamlResult } from '../utils/yaml-output.js';
16
+ /** Subdirectory inside the scaffolded plugin that holds real-world error samples. */
17
+ const SAMPLES_DIR_NAME = 'samples';
15
18
  export function createExtractorCommand(program) {
16
19
  program
17
20
  .command('create-extractor [name]')
@@ -21,38 +24,10 @@ export function createExtractorCommand(program) {
21
24
  .option('--detection-pattern <pattern>', 'Detection keyword or pattern')
22
25
  .option('--priority <number>', 'Detection priority (higher = check first)', '70')
23
26
  .option('-f, --force', 'Overwrite existing plugin directory')
27
+ .option('--dry-run', 'Show which files would be created without writing anything')
24
28
  .action(async (name, options) => {
25
29
  try {
26
- // Normalize cwd to avoid Windows short path issues (e.g., RUNNER~1)
27
- const cwd = normalizePath(process.cwd());
28
- // Interactive prompts for missing information (skip entirely if all options provided)
29
- const context = await gatherContext(name, options);
30
- // Determine output directory
31
- const pluginDir = join(cwd, `vibe-validate-plugin-${context.pluginName}`);
32
- // Check if directory exists
33
- if (existsSync(pluginDir) && !options.force) {
34
- console.error(chalk.red('āŒ Plugin directory already exists:'));
35
- console.error(chalk.gray(` ${pluginDir}`));
36
- console.error(chalk.gray(' Use --force to overwrite'));
37
- process.exit(1);
38
- }
39
- // Create plugin directory
40
- console.log(chalk.blue('šŸ”Ø Creating extractor plugin...'));
41
- createPluginDirectory(pluginDir, context);
42
- console.log(chalk.green('āœ… Extractor plugin created successfully!'));
43
- console.log(chalk.blue(`šŸ“ Created: ${pluginDir}`));
44
- const cmd = getCommandName();
45
- const pm = detectPackageManager(pluginDir);
46
- const installCmd = getInstallCommandUnfrozen(pm);
47
- console.log();
48
- console.log(chalk.yellow('Next steps:'));
49
- console.log(chalk.gray(' 1. cd ' + `vibe-validate-plugin-${context.pluginName}`));
50
- console.log(chalk.gray(` 2. ${installCmd}`));
51
- console.log(chalk.gray(' 3. Add your sample error output to samples/sample-error.txt'));
52
- console.log(chalk.gray(' 4. Implement detect() and extract() functions in index.ts'));
53
- console.log(chalk.gray(` 5. Run tests: ${pm} test`));
54
- console.log(chalk.gray(` 6. Test the plugin: ${cmd} test-extractor .`));
55
- process.exit(0);
30
+ await runCreateExtractor(name, options);
56
31
  }
57
32
  catch (error) {
58
33
  console.error(chalk.red('āŒ Failed to create extractor plugin:'), error);
@@ -60,6 +35,105 @@ export function createExtractorCommand(program) {
60
35
  }
61
36
  });
62
37
  }
38
+ /**
39
+ * Execute the create-extractor logic.
40
+ *
41
+ * Extracted from the Commander `.action()` closure so the directory-exists,
42
+ * dry-run dispatch, and write paths can be exercised by in-process unit tests
43
+ * (V8 coverage only sees code that runs inside the Vitest worker).
44
+ */
45
+ export async function runCreateExtractor(name, options) {
46
+ // Normalize cwd to avoid Windows short path issues (e.g., RUNNER~1)
47
+ const cwd = normalizePath(process.cwd());
48
+ // Interactive prompts for missing information (skip entirely if all options provided)
49
+ const context = await gatherContext(name, options);
50
+ // Determine output directory
51
+ const pluginDir = join(cwd, `vibe-validate-plugin-${context.pluginName}`);
52
+ // Check if directory exists (skipped in dry-run: we never overwrite, so no warning needed)
53
+ if (existsSync(pluginDir) && !options.force && !options.dryRun) {
54
+ console.error(chalk.red('āŒ Plugin directory already exists:'));
55
+ console.error(chalk.gray(` ${pluginDir}`));
56
+ console.error(chalk.gray(' Use --force to overwrite'));
57
+ process.exit(1);
58
+ }
59
+ // Dry-run path: emit YAML preview without touching the filesystem
60
+ if (options.dryRun) {
61
+ await emitDryRunPreview(cwd, pluginDir, context);
62
+ process.exit(0);
63
+ }
64
+ // Create plugin directory
65
+ console.log(chalk.blue('šŸ”Ø Creating extractor plugin...'));
66
+ createPluginDirectory(pluginDir, context);
67
+ console.log(chalk.green('āœ… Extractor plugin created successfully!'));
68
+ console.log(chalk.blue(`šŸ“ Created: ${pluginDir}`));
69
+ const pm = detectPackageManager(pluginDir);
70
+ const installCmd = getInstallCommandUnfrozen(pm);
71
+ console.log();
72
+ console.log(chalk.yellow('Next steps:'));
73
+ console.log(chalk.gray(' 1. cd ' + `vibe-validate-plugin-${context.pluginName}`));
74
+ console.log(chalk.gray(` 2. ${installCmd}`));
75
+ console.log(chalk.gray(' 3. Add your sample error output to samples/sample-error.txt'));
76
+ console.log(chalk.gray(' 4. Implement detect() and extract() functions in index.ts'));
77
+ console.log(chalk.gray(` 5. Run tests: ${pm} test`));
78
+ process.exit(0);
79
+ }
80
+ /**
81
+ * Single source of truth for the files a scaffolded plugin contains.
82
+ *
83
+ * Both the real write path (`createPluginDirectory`) and the dry-run preview
84
+ * (`emitDryRunPreview`) iterate this list, guaranteeing they stay in sync.
85
+ * All generators here are pure (no I/O), so the same list is safe to use for
86
+ * both writing and previewing.
87
+ *
88
+ * Exported for in-process unit testing — subprocess-based command tests
89
+ * don't contribute line hits to V8 coverage instrumentation.
90
+ */
91
+ export function getPluginFileList(context) {
92
+ return [
93
+ { relPath: 'index.ts', content: generateIndexTs(context) },
94
+ { relPath: 'index.test.ts', content: generateIndexTestTs(context) },
95
+ { relPath: 'README.md', content: generateReadme(context) },
96
+ { relPath: 'CLAUDE.md', content: generateClaudeMd(context) },
97
+ { relPath: 'package.json', content: generatePackageJson(context) },
98
+ { relPath: 'tsconfig.json', content: generateTsConfig(context) },
99
+ { relPath: join(SAMPLES_DIR_NAME, 'sample-error.txt'), content: generateSampleError(context) },
100
+ ];
101
+ }
102
+ /**
103
+ * Compute the list of files that would be created and emit a YAML preview to stdout.
104
+ *
105
+ * Calls every template generator (they are pure) and measures `Buffer.byteLength`
106
+ * for each result. Does not call `mkdirSyncReal` or `writeFileSync`.
107
+ *
108
+ * Exported for in-process unit testing (see `getPluginFileList` for rationale).
109
+ */
110
+ export async function emitDryRunPreview(cwd, pluginDir, context) {
111
+ // Format a path relative to cwd with a leading `./` (matches what users see).
112
+ // POSIX-style separators in YAML output for consistency across platforms.
113
+ const toDisplayPath = (absPath) => {
114
+ const posix = toForwardSlash(relative(cwd, absPath));
115
+ return posix.startsWith('.') ? posix : `./${posix}`;
116
+ };
117
+ const samplesDir = join(pluginDir, SAMPLES_DIR_NAME);
118
+ const wouldCreate = getPluginFileList(context).map(({ relPath, content }) => ({
119
+ path: toDisplayPath(join(pluginDir, relPath)),
120
+ bytes: Buffer.byteLength(content, 'utf8'),
121
+ }));
122
+ const totalBytes = wouldCreate.reduce((sum, entry) => sum + entry.bytes, 0);
123
+ const result = {
124
+ dryRun: true,
125
+ pluginName: context.pluginName,
126
+ pluginDir: toDisplayPath(pluginDir),
127
+ wouldCreateDir: [toDisplayPath(pluginDir), toDisplayPath(samplesDir)],
128
+ wouldCreate,
129
+ summary: {
130
+ filesCount: wouldCreate.length,
131
+ dirsCount: 2,
132
+ totalBytes,
133
+ },
134
+ };
135
+ await outputYamlResult(result);
136
+ }
63
137
  /**
64
138
  * Build prompts configuration for missing options
65
139
  */
@@ -94,14 +168,28 @@ function buildPromptsConfig(name, options) {
94
168
  ];
95
169
  }
96
170
  /**
97
- * Gather context from command-line arguments and interactive prompts
171
+ * Gather context from command-line arguments and interactive prompts.
172
+ *
173
+ * Exported so the non-TTY guard can be unit-tested in-process — driving the
174
+ * full Commander action via `parseAsync` is awkward because of how the test
175
+ * harness's `process.exit` mock interacts with command parsing.
98
176
  */
99
- async function gatherContext(name, options) {
177
+ export async function gatherContext(name, options) {
100
178
  // Check if all required options are provided (skip prompts for non-TTY/CI environments)
101
179
  // CRITICAL: The prompts library has issues on Windows CI even when all prompts have type: null.
102
180
  // By skipping the prompts() call entirely when all options are provided, we avoid these issues.
103
181
  const hasAllOptions = name && options.description && options.author && options.detectionPattern;
104
182
  let responses = {};
183
+ // Bail fast when stdin is not a TTY and required info is missing.
184
+ // Without this guard, prompts() returns {} on closed stdin and the
185
+ // existing cancellation path silently exits 0 — confusing in CI / pipes.
186
+ if (!hasAllOptions && !process.stdin.isTTY) {
187
+ const cmd = getCommandName();
188
+ console.error(chalk.red(`error: plugin name is required when running non-interactively\n` +
189
+ ` pass it as a positional argument, plus the required flags:\n` +
190
+ ` ${cmd} create-extractor <name> --description <desc> --author <author> --detection-pattern <pattern>`));
191
+ process.exit(1);
192
+ }
105
193
  // Only run prompts if we're missing required information
106
194
  if (!hasAllOptions) {
107
195
  responses = await prompts(buildPromptsConfig(name, options));
@@ -139,22 +227,12 @@ async function gatherContext(name, options) {
139
227
  function createPluginDirectory(pluginDir, context) {
140
228
  // Create directories (using mkdirSyncReal to handle Windows short paths)
141
229
  const normalizedPluginDir = mkdirSyncReal(pluginDir, { recursive: true });
142
- mkdirSyncReal(join(normalizedPluginDir, 'samples'), { recursive: true });
230
+ mkdirSyncReal(join(normalizedPluginDir, SAMPLES_DIR_NAME), { recursive: true });
143
231
  // Write files (using normalized path to ensure consistency)
144
- writeFileSync(join(normalizedPluginDir, 'index.ts'), generateIndexTs(context), 'utf-8');
145
- writeFileSync(join(normalizedPluginDir, 'index.test.ts'), generateIndexTestTs(context), 'utf-8');
146
- writeFileSync(join(normalizedPluginDir, 'README.md'), generateReadme(context), 'utf-8');
147
- writeFileSync(join(normalizedPluginDir, 'CLAUDE.md'), generateClaudeMd(context), 'utf-8');
148
- writeFileSync(join(normalizedPluginDir, 'package.json'), generatePackageJson(context), 'utf-8');
149
- writeFileSync(join(normalizedPluginDir, 'tsconfig.json'), generateTsConfig(context), 'utf-8');
150
- writeFileSync(join(normalizedPluginDir, 'samples', 'sample-error.txt'), generateSampleError(context), 'utf-8');
151
- console.log(chalk.gray(' āœ“ Created index.ts'));
152
- console.log(chalk.gray(' āœ“ Created index.test.ts'));
153
- console.log(chalk.gray(' āœ“ Created README.md'));
154
- console.log(chalk.gray(' āœ“ Created CLAUDE.md'));
155
- console.log(chalk.gray(' āœ“ Created package.json'));
156
- console.log(chalk.gray(' āœ“ Created tsconfig.json'));
157
- console.log(chalk.gray(' āœ“ Created samples/sample-error.txt'));
232
+ for (const { relPath, content } of getPluginFileList(context)) {
233
+ writeFileSync(join(normalizedPluginDir, relPath), content, 'utf-8');
234
+ console.log(chalk.gray(` āœ“ Created ${relPath}`));
235
+ }
158
236
  }
159
237
  /**
160
238
  * Generate index.ts (main plugin file)
@@ -783,10 +861,7 @@ npm install # or: pnpm install / yarn install / bun install
783
861
  # 6. Run tests
784
862
  npm test
785
863
 
786
- # 7. Test with vibe-validate
787
- vibe-validate test-extractor .
788
-
789
- # 8. Publish (optional)
864
+ # 7. Publish (optional)
790
865
  npm publish
791
866
  \`\`\`
792
867
 
@@ -805,13 +880,11 @@ Generated plugins follow the vibe-validate plugin architecture:
805
880
  2. **Implement detect()** function to identify your tool's output
806
881
  3. **Implement extract()** function to parse errors
807
882
  4. **Run tests** to validate functionality
808
- 5. **Test with vibe-validate** using \`test-extractor\` command
809
- 6. **Publish to npm** (optional) or use locally
883
+ 5. **Publish to npm** (optional) or use locally
810
884
 
811
885
  ## Related Commands
812
886
 
813
887
  - \`vibe-validate fork-extractor <name>\` - Copy built-in extractor for customization
814
- - \`vibe-validate test-extractor <path>\` - Validate plugin functionality and security
815
888
  `);
816
889
  }
817
890
  //# sourceMappingURL=create-extractor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"create-extractor.js","sourceRoot":"","sources":["../../src/commands/create-extractor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAClE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,O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G,CAAC,CAAC;AACf,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,8BAA8B;IAC5C,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+Gb,CAAC,CAAC;AACH,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"pre-commit.d.ts","sourceRoot":"","sources":["../../src/commands/pre-commit.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAYH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAqEzC,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA0NvD;AAED;;GAEG;AACH,wBAAgB,wBAAwB,IAAI,IAAI,CA6L/C"}
1
+ {"version":3,"file":"pre-commit.d.ts","sourceRoot":"","sources":["../../src/commands/pre-commit.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAuBH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA6OzC,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAuNvD;AAED;;GAEG;AACH,wBAAgB,wBAAwB,IAAI,IAAI,CAsN/C"}
@@ -4,8 +4,8 @@
4
4
  * Runs branch sync check + validation before allowing commit.
5
5
  * This is the recommended workflow before committing code.
6
6
  */
7
- import { getRemoteBranch } from '@vibe-validate/config';
8
- import { checkBranchSync, getPartiallyStagedFiles, isCurrentBranchBehindTracking, getGitTreeHash, isMergeInProgress } from '@vibe-validate/git';
7
+ import { getRemoteBranch, getRemoteOrigin, getMainBranch, DEFAULT_SYNC_GUARD_MODE } from '@vibe-validate/config';
8
+ import { checkBranchSync, fetchRemoteRefs, getPartiallyStagedFiles, getTrackingDivergence, getUpstreamRef, getGitTreeHash, isMergeInProgress, isRebaseInProgress, refKey } from '@vibe-validate/git';
9
9
  import { isToolAvailable } from '@vibe-validate/utils';
10
10
  import chalk from 'chalk';
11
11
  import { getCommandName } from '../utils/command-name.js';
@@ -30,6 +30,136 @@ function showWorkProtectionMessage(treeHash, recoveryCommand, programName) {
30
30
  console.error(chalk.gray(` ${recoveryCommand}`));
31
31
  }
32
32
  }
33
+ /**
34
+ * Refresh exactly the refs the active sync guards depend on.
35
+ *
36
+ * Both guards compare local refs against remote-tracking refs, so an answer is
37
+ * only as truthful as the last fetch. `off` must cost nothing, so the rule is a
38
+ * disjunction: fetch when *either* guard is active, and fetch only that guard's
39
+ * ref. Grouping into one call means both-active still costs a single
40
+ * round-trip.
41
+ *
42
+ * @returns Whether each guard's local ref can be trusted. "Fresh" means the ref
43
+ * is safe to judge on: either it was just fetched, or there was
44
+ * nothing to fetch (no upstream, guard disabled) and the local ref is
45
+ * all the truth there is. Only an *attempted and failed* fetch marks a
46
+ * ref stale, so the caller degrades that guard to no opinion.
47
+ */
48
+ function fetchSyncRefs(baseRef, upstreamRef, verbose) {
49
+ const refs = [baseRef, upstreamRef].filter((ref) => ref !== null);
50
+ if (refs.length === 0) {
51
+ return { baseFresh: true, upstreamFresh: true };
52
+ }
53
+ console.log(chalk.blue('šŸ”„ Fetching latest refs from remote...'));
54
+ const outcomes = fetchRemoteRefs(refs);
55
+ if (verbose) {
56
+ for (const [remote, outcome] of Object.entries(outcomes)) {
57
+ if (!outcome.ok) {
58
+ console.warn(chalk.gray(` Fetch from ${remote} failed: ${outcome.error ?? 'unknown error'}`));
59
+ }
60
+ }
61
+ }
62
+ // Per ref, not per remote: a deleted upstream branch aborts the combined
63
+ // fetch, and must not be read as "origin is unreachable" and take the
64
+ // base-branch guard down with it.
65
+ const isFresh = (ref) => ref === null || (outcomes[refKey(ref)]?.ok ?? false);
66
+ return { baseFresh: isFresh(baseRef), upstreamFresh: isFresh(upstreamRef) };
67
+ }
68
+ /**
69
+ * Guard: is the branch behind its own remote tracking branch?
70
+ *
71
+ * This means someone else — or another machine, or another agent — pushed to
72
+ * your branch. `git push` would tell you eventually; this just tells you sooner.
73
+ *
74
+ * @param isFresh - Whether the upstream ref was successfully fetched. When
75
+ * false the local ref is stale, so this guard has no opinion:
76
+ * reporting "up to date" from a stale ref is worse than
77
+ * silence, and blocking on one is worse still.
78
+ * @returns true when the commit must be blocked.
79
+ */
80
+ function reportTrackingDivergence(mode, isFresh, treeHash, programName) {
81
+ console.log(chalk.blue('šŸ” Checking divergence from remote tracking branch...'));
82
+ const divergence = getTrackingDivergence();
83
+ if (divergence === null) {
84
+ console.log(chalk.gray('ā„¹ļø No remote tracking branch (new branch or not pushed yet)'));
85
+ return false;
86
+ }
87
+ // Before any verdict: a stale ref cannot support one. "Up to date" from a ref
88
+ // we failed to refresh is the same reassuring lie as a missed "behind".
89
+ if (!isFresh) {
90
+ console.log(chalk.gray('ā„¹ļø Could not refresh the remote tracking branch - skipping this check'));
91
+ console.log(chalk.gray(' (deleted upstream branch, or offline)'));
92
+ return false;
93
+ }
94
+ if (divergence.behind === 0) {
95
+ if (divergence.ahead === 0) {
96
+ console.log(chalk.green('āœ… Current branch is up to date with remote'));
97
+ }
98
+ else {
99
+ // Purely ahead: local unpushed commits. Normal mid-PR state.
100
+ console.log(chalk.green(`āœ… Local branch is ahead of remote by ${divergence.ahead} commit(s) (unpushed)`));
101
+ }
102
+ return false;
103
+ }
104
+ if (divergence.ahead > 0) {
105
+ // Diverged: history rewritten (typically a rebase). Pass with notice.
106
+ console.log(chalk.blue('ā„¹ļø Local branch has rewritten history vs remote tracking branch.'));
107
+ console.log(chalk.gray(` Ahead by ${divergence.ahead} commit(s), behind by ${divergence.behind} commit(s) (rebased history).`));
108
+ console.log(chalk.gray(' When ready to push: git push --force-with-lease'));
109
+ return false;
110
+ }
111
+ // Purely behind: someone else pushed.
112
+ if (mode === 'block') {
113
+ console.error(chalk.red(`āŒ Current branch is behind its remote tracking branch`));
114
+ console.error(chalk.yellow(` Behind by ${divergence.behind} commit(s)`));
115
+ console.error(chalk.yellow(' Someone else has pushed changes to this branch.'));
116
+ showWorkProtectionMessage(treeHash, 'git pull', programName);
117
+ console.error(chalk.gray('\n Alternative: git pull --rebase'));
118
+ console.error(chalk.gray('\n Skip this check with: hooks.preCommit.trackingBranchSync: off'));
119
+ return true;
120
+ }
121
+ console.warn(chalk.yellow(`āš ļø Current branch is behind its remote tracking branch by ${divergence.behind} commit(s)`));
122
+ console.warn(chalk.gray(' Someone else has pushed changes to this branch. To sync: git pull --rebase'));
123
+ console.warn(chalk.gray(' (warning only - set hooks.preCommit.trackingBranchSync: block to make this a hard stop)'));
124
+ return false;
125
+ }
126
+ /**
127
+ * Guard: is the branch behind the base branch (e.g. origin/main)?
128
+ *
129
+ * @param isFresh - Whether the base ref was successfully fetched; see
130
+ * {@link reportTrackingDivergence}.
131
+ * @returns true when the commit must be blocked.
132
+ */
133
+ async function reportBaseBranchSync(mode, remoteBranch, isFresh, treeHash, programName) {
134
+ console.log(chalk.blue(`šŸ”„ Checking branch sync with ${remoteBranch}...`));
135
+ // The fetch already happened in fetchSyncRefs (one round-trip for both
136
+ // guards), so don't pay for a second one here.
137
+ const syncResult = await checkBranchSync({ remoteBranch, skipFetch: true });
138
+ // Checked before freshness: a repo with no remote is a benign, permanent
139
+ // state, not a failed fetch, and shouldn't be reported as one.
140
+ if (!syncResult.hasRemote) {
141
+ console.log(chalk.gray('ā„¹ļø No remote tracking branch (new branch or no remote)'));
142
+ return false;
143
+ }
144
+ if (!isFresh) {
145
+ console.log(chalk.gray(`ā„¹ļø Could not refresh ${remoteBranch} - skipping this check (offline?)`));
146
+ return false;
147
+ }
148
+ if (syncResult.isUpToDate) {
149
+ console.log(chalk.green(`āœ… Branch is up to date with ${remoteBranch}`));
150
+ return false;
151
+ }
152
+ if (mode === 'block') {
153
+ console.error(chalk.red(`āŒ Branch is behind ${remoteBranch}`));
154
+ console.error(chalk.yellow(` Behind by ${syncResult.behindBy} commit(s)`));
155
+ showWorkProtectionMessage(treeHash, `git merge ${remoteBranch}`, programName);
156
+ return true;
157
+ }
158
+ console.warn(chalk.yellow(`āš ļø Branch is behind ${remoteBranch} by ${syncResult.behindBy} commit(s)`));
159
+ console.warn(chalk.gray(` To sync: git merge ${remoteBranch}`));
160
+ console.warn(chalk.gray(' (warning only - set hooks.preCommit.baseBranchSync: block to make this a hard stop)'));
161
+ return false;
162
+ }
33
163
  /**
34
164
  * Handle the result of a secret scanning tool
35
165
  *
@@ -61,7 +191,7 @@ export function preCommitCommand(program) {
61
191
  const cmd = program
62
192
  .command('pre-commit')
63
193
  .description('Run branch sync check + validation (recommended before commit). Spawned steps run with GIT_* env vars stripped to prevent parent-repo corruption when invoked as a git hook (see docs/skills/vibe-validate/git-hook-safety.md).')
64
- .option('--skip-sync', 'Skip branch sync check')
194
+ .option('--skip-sync', 'Skip the base-branch sync check and its network fetch (same as hooks.preCommit.baseBranchSync: off)')
65
195
  .option('-v, --verbose', 'Show detailed progress and output');
66
196
  // eslint-disable-next-line sonarjs/cognitive-complexity -- Complexity 47 acceptable for pre-commit workflow orchestration (coordinates git sync, config loading, validation, and error handling)
67
197
  cmd.action(async (options) => {
@@ -112,55 +242,56 @@ export function preCommitCommand(program) {
112
242
  process.exit(1);
113
243
  }
114
244
  console.log(chalk.green('āœ… No partially staged files'));
115
- // Step 3: Check if current branch is behind its remote tracking branch
116
- console.log(chalk.blue('šŸ” Checking if current branch is behind remote...'));
117
- const behindTracking = isCurrentBranchBehindTracking();
118
- if (behindTracking !== null && behindTracking > 0) {
119
- console.error(chalk.red(`āŒ Current branch is behind its remote tracking branch`));
120
- console.error(chalk.yellow(` Behind by ${behindTracking} commit(s)`));
121
- console.error(chalk.yellow(' Someone else has pushed changes to this branch.'));
122
- showWorkProtectionMessage(treeHash, 'git pull', programName);
123
- console.error(chalk.gray('\n Alternative: git pull --rebase'));
124
- console.error(chalk.gray('\n Skip this check with: --skip-sync (not recommended)'));
245
+ // Step 4: Verbose mode is ONLY enabled via explicit --verbose flag
246
+ const verbose = options.verbose ?? false;
247
+ // Step 5: Sync guards.
248
+ //
249
+ // Neither guard is a correctness condition, so both default to 'warn':
250
+ // check, say something useful, let the commit through. Blocking here for
251
+ // a non-correctness reason routes people to `git commit --no-verify`,
252
+ // which skips every other guard too. Set 'block' to opt back into a hard
253
+ // stop; hard enforcement otherwise belongs in CI (`vv sync-check`).
254
+ const preCommitConfig = config.hooks?.preCommit;
255
+ const trackingMode = preCommitConfig?.trackingBranchSync ?? DEFAULT_SYNC_GUARD_MODE;
256
+ // --skip-sync predates the config and has always meant the base-branch
257
+ // guard specifically, so it stays scoped to that one.
258
+ const branchMode = options.skipSync
259
+ ? 'off'
260
+ : (preCommitConfig?.baseBranchSync ?? DEFAULT_SYNC_GUARD_MODE);
261
+ const remoteBranch = getRemoteBranch(config.git);
262
+ // The base-branch guard is meaningless while a merge or rebase is
263
+ // mid-flight. During a merge, being behind origin/main is expected - the
264
+ // merge commit resolves it. During a rebase, HEAD is transiently
265
+ // rewinding. Decided here so we don't fetch a ref nothing will read.
266
+ const mergeInProgress = isMergeInProgress();
267
+ const rebaseInProgress = isRebaseInProgress();
268
+ const baseGuardActive = branchMode !== 'off' && !mergeInProgress && !rebaseInProgress;
269
+ // Mid-rebase HEAD is detached, so there is no upstream to compare
270
+ // against - the tracking guard would report "no remote tracking branch",
271
+ // which is false and alarming during every conflict resolution.
272
+ const trackingGuardActive = trackingMode !== 'off' && !rebaseInProgress;
273
+ const upstreamRef = trackingGuardActive ? getUpstreamRef() : null;
274
+ const baseRef = baseGuardActive
275
+ ? { remote: getRemoteOrigin(config.git), branch: getMainBranch(config.git) }
276
+ : null;
277
+ const { baseFresh, upstreamFresh } = fetchSyncRefs(baseRef, upstreamRef, verbose);
278
+ if (trackingGuardActive
279
+ && reportTrackingDivergence(trackingMode, upstreamFresh, treeHash, programName)) {
125
280
  process.exit(1);
126
281
  }
127
- if (behindTracking === null) {
128
- console.log(chalk.gray('ā„¹ļø No remote tracking branch (new branch or not pushed yet)'));
129
- }
130
- else {
131
- console.log(chalk.green('āœ… Current branch is up to date with remote'));
132
- }
133
- // Step 4: Check branch sync (unless skipped or in merge)
134
- if (!options.skipSync) {
135
- // Construct remote branch reference using helper
136
- const remoteBranch = getRemoteBranch(config.git);
137
- // Check if we're in the middle of a merge (MERGE_HEAD exists)
138
- // During a merge, being behind origin/main is expected - the merge commit will resolve it
139
- if (isMergeInProgress()) {
282
+ if (branchMode !== 'off') {
283
+ if (mergeInProgress) {
140
284
  console.log(chalk.blue(`šŸ”„ Merge in progress - skipping branch sync check`));
141
285
  console.log(chalk.gray(` (This merge commit will sync with ${remoteBranch})`));
142
286
  }
143
- else {
144
- console.log(chalk.blue(`šŸ”„ Checking branch sync with ${remoteBranch}...`));
145
- const syncResult = await checkBranchSync({
146
- remoteBranch,
147
- });
148
- if (!syncResult.isUpToDate && syncResult.hasRemote) {
149
- console.error(chalk.red(`āŒ Branch is behind ${remoteBranch}`));
150
- console.error(chalk.yellow(` Behind by ${syncResult.behindBy} commit(s)`));
151
- showWorkProtectionMessage(treeHash, `git merge ${remoteBranch}`, programName);
152
- process.exit(1);
153
- }
154
- if (syncResult.hasRemote) {
155
- console.log(chalk.green(`āœ… Branch is up to date with ${remoteBranch}`));
156
- }
157
- else {
158
- console.log(chalk.gray('ā„¹ļø No remote tracking branch (new branch or no remote)'));
159
- }
287
+ else if (rebaseInProgress) {
288
+ console.log(chalk.blue(`šŸ”„ Rebase in progress - skipping branch sync check`));
289
+ console.log(chalk.gray(` (Sync state will settle once the rebase completes)`));
290
+ }
291
+ else if (await reportBaseBranchSync(branchMode, remoteBranch, baseFresh, treeHash, programName)) {
292
+ process.exit(1);
160
293
  }
161
294
  }
162
- // Step 5: Verbose mode is ONLY enabled via explicit --verbose flag
163
- const verbose = options.verbose ?? false;
164
295
  // Step 6: Run secret scanning if enabled
165
296
  const secretScanning = config.hooks?.preCommit?.secretScanning;
166
297
  if (secretScanning?.enabled) {
@@ -230,7 +361,7 @@ export function preCommitCommand(program) {
230
361
  }
231
362
  }
232
363
  });
233
- // Step 9: Report results
364
+ // Step 8: Report results
234
365
  if (result.passed) {
235
366
  console.log(chalk.green('\nāœ… Pre-commit checks passed!'));
236
367
  console.log(chalk.gray(' Safe to commit.'));
@@ -264,24 +395,47 @@ The \`pre-commit\` command runs a comprehensive pre-commit workflow to ensure yo
264
395
 
265
396
  ## How It Works
266
397
 
267
- 1. Checks for partially staged files (fails if detected)
268
- 2. Checks if current branch is behind its remote tracking branch (fails if detected)
269
- 3. Runs sync-check (fails if branch behind origin/main, skipped during merge)
270
- 4. Runs secret scanning (if enabled in config)
271
- 5. Runs validate (with caching)
272
- 6. Reports git status (warns about unstaged files)
398
+ 1. Checks for partially staged files (**fails** if detected)
399
+ 2. Fetches only the refs the enabled sync guards need (one round-trip; skipped entirely when both are \`off\`)
400
+ 3. Checks if the current branch is behind its remote tracking branch (**warns** by default)
401
+ 4. Checks if the current branch is behind the base branch, e.g. origin/main (**warns** by default; skipped during a merge or rebase)
402
+ 5. Runs secret scanning (if enabled in config)
403
+ 6. Runs validate (with caching)
273
404
 
274
- **Note:** When completing a merge commit (MERGE_HEAD exists), the branch sync check is automatically skipped since the merge commit itself resolves the out-of-sync state.
405
+ **Note:** When completing a merge commit (MERGE_HEAD exists), or partway through a rebase, the base-branch sync check is automatically skipped — the merge commit itself resolves the out-of-sync state, and a mid-rebase HEAD gives a misleading answer.
406
+
407
+ ## Sync Guards
408
+
409
+ The two sync checks are **warnings, not gates**. Being behind a branch does not make the code you are committing wrong, and blocking a commit for a non-correctness reason pushes people to \`git commit --no-verify\` — which skips secret scanning, validation and partial-stage detection too.
410
+
411
+ The partially-staged-files check is different, and stays a hard block: validation runs against the full file while git commits only the staged hunk, so a pass could certify code that isn't what lands.
412
+
413
+ Each guard takes \`warn\` (default), \`block\`, or \`off\`:
414
+
415
+ \`\`\`yaml
416
+ hooks:
417
+ preCommit:
418
+ baseBranchSync: warn # behind the base branch (origin/main)
419
+ trackingBranchSync: warn # behind your own remote branch (someone else pushed)
420
+ \`\`\`
421
+
422
+ - \`warn\` — check, print a notice, allow the commit
423
+ - \`block\` — check and fail the commit (the pre-0.19.7 behaviour)
424
+ - \`off\` — skip the check entirely, **including its network fetch**
425
+
426
+ \`off\` is the only setting that makes \`pre-commit\` skip the fetch. \`warn\` still fetches, because a sync notice computed from a stale ref is worth nothing. If a ref cannot be refreshed — offline, or an upstream branch deleted after its PR merged — the guard that depends on that ref degrades to no opinion and the commit proceeds. Degradation is per guard, not per remote.
427
+
428
+ For hard enforcement, use \`vibe-validate sync-check\` in CI — it still exits 1 when the branch is behind.
275
429
 
276
430
  ## Options
277
431
 
278
- - \`--skip-sync\` - Skip branch sync check (not recommended)
432
+ - \`--skip-sync\` - Skip the base-branch sync check and its network fetch (equivalent to \`baseBranchSync: off\`; does not affect \`trackingBranchSync\`)
279
433
  - \`-v, --verbose\` - Show detailed progress and output
280
434
 
281
435
  ## Exit Codes
282
436
 
283
- - \`0\` - Sync OK and validation passed
284
- - \`1\` - Sync failed OR validation failed
437
+ - \`0\` - Validation passed (and no sync guard set to \`block\` was violated)
438
+ - \`1\` - Validation failed, secrets detected, files partially staged, or a \`block\` sync guard was violated
285
439
 
286
440
  ## Examples
287
441
 
@@ -289,7 +443,7 @@ The \`pre-commit\` command runs a comprehensive pre-commit workflow to ensure yo
289
443
  # Standard pre-commit workflow
290
444
  vibe-validate pre-commit
291
445
 
292
- # Skip sync check (not recommended)
446
+ # Skip the base-branch sync check and its fetch
293
447
  vibe-validate pre-commit --skip-sync
294
448
  \`\`\`
295
449
 
@@ -408,7 +562,9 @@ hooks:
408
562
 
409
563
  ## Error Recovery
410
564
 
411
- ### If sync check fails
565
+ ### If a sync guard blocks the commit
566
+
567
+ Only reachable when a guard is set to \`block\` — with the default \`warn\` you get a notice and the commit proceeds.
412
568
 
413
569
  **Branch is behind origin/main:**
414
570
  \`\`\`bash