GitNexus/gitnexus/src/cli/augment.ts
abhigyanpatwari 58972af084 Fix Claude Code hooks: correct settings path, matcher format, and hook script
- Hook config goes in ~/.claude/settings.json (not hooks.json)
- Matcher uses string format ("Grep|Glob|Bash") per new Claude Code schema
- Rename gitnexus-hook.js → gitnexus-hook.cjs for CommonJS compatibility
- Fix setup.ts: correct hook filename and timeout (8000ms instead of 10ms)
- Bump to v1.1.9 and publish to npm

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 13:05:36 +05:30

36 lines
1.1 KiB
TypeScript

/**
* Augment CLI Command
*
* Fast-path command for platform hooks.
* Shells out from Claude Code PreToolUse / Cursor beforeShellExecution hooks.
*
* Usage: gitnexus augment <pattern>
* Returns enriched text to stdout.
*
* Performance: Must cold-start fast (<500ms).
* Skips unnecessary initialization (no web server, no full DB warmup).
*/
import { augment } from '../core/augmentation/engine.js';
export async function augmentCommand(pattern: string): Promise<void> {
if (!pattern || pattern.length < 3) {
process.exit(0);
}
try {
const result = await augment(pattern, process.cwd());
if (result) {
// IMPORTANT: Write to stderr, NOT stdout.
// KuzuDB's native module captures stdout fd at OS level during init,
// which makes stdout permanently broken in subprocess contexts.
// stderr is never captured, so it works reliably everywhere.
// The hook reads from the subprocess's stderr.
process.stderr.write(result + '\n');
}
} catch {
// Graceful failure — never break the calling hook
process.exit(0);
}
}