fix(conversation-memory): silent first run with graceful CLI wrapper - #475
Conversation
Add cli-graceful.mjs wrapper that checks node_modules before importing better-sqlite3. On first run without dependencies, npm install runs asynchronously in background with silent exit. No more ERR_MODULE_NOT_FOUND errors during SessionStart hook. Changes: - Add src/cli-graceful.mjs - checks deps, runs npm install in background - Build outputs cli-internal.mjs (bundled) + cli.mjs (wrapper copy) - Update ensure-deps.sh to run silently in background - Simplify hooks.json (no longer needs ensure-deps hook) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughThis PR implements graceful dependency handling for the conversation-memory plugin by introducing a CLI wrapper that detects missing node_modules and launches a silent background npm install. The build system now outputs the core CLI as cli-internal.mjs while exposing a graceful wrapper as the entry point, and the hook timeout was reduced. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Fix ERR_MODULE_NOT_FOUND error on first run by adding graceful CLI wrapper that checks for node_modules before importing better-sqlite3. When dependencies are missing, npm install runs asynchronously in background with silent exit.
Problem
The conversation-memory plugin threw a SessionStart:startup hook error on first run because the SessionStart hook directly called cli.mjs, which immediately imported better-sqlite3 before dependencies were installed. The plugin eventually recovered after auto-installing dependencies, but the initial error message was noisy and confusing.
Solution
Add cli-graceful.mjs wrapper that:
Changes
Testing
First run (no deps): Silent exit, background npm install
Second run (with deps): Normal CLI operation
All BATS tests pass
🤖 Generated with Claude Code](https://claude.com/claude-code)
Summary by CodeRabbit
Performance
Chores