mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-09-20 00:11:37 +00:00
- 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>
36 lines
1.1 KiB
TypeScript
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);
|
|
}
|
|
}
|