9dd8b180ac
Changed all hook entry points to use dynamic imports after bootstrap runs. This ensures that better-sqlite3 is installed before Node.js attempts to resolve the import.
Changes:
- Modified src/bin/hooks/*.ts to call ensureDependencies() before dynamic import
- Moved from static `import { hook } from '...'` to `const { hook } = await import('...')`
- This delays module resolution until after npm install completes
- Bumped version to 4.0.6
The previous approach failed because static imports are resolved at module link time, before any runtime code (including ensureDependencies) executes.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
25 lines
700 B
TypeScript
25 lines
700 B
TypeScript
|
|
/**
|
|
* New Hook Entry Point - UserPromptSubmit
|
|
* Standalone executable for plugin hooks
|
|
*/
|
|
|
|
// Bootstrap: Ensure dependencies are installed before importing modules
|
|
import { ensureDependencies } from '../../shared/bootstrap.js';
|
|
import { stdin } from 'process';
|
|
|
|
// Run bootstrap synchronously BEFORE any dynamic imports
|
|
ensureDependencies();
|
|
|
|
// Dynamic import AFTER bootstrap ensures dependencies are installed
|
|
const { newHook } = await import('../../hooks/new.js');
|
|
|
|
// Read input from stdin
|
|
let input = '';
|
|
stdin.on('data', (chunk) => input += chunk);
|
|
stdin.on('end', async () => {
|
|
const parsed = input.trim() ? JSON.parse(input) : undefined;
|
|
await newHook(parsed);
|
|
process.exit(0);
|
|
});
|