Simplify Windows fix: use idempotent npm install instead of custom installer

Co-authored-by: thedotmack <683968+thedotmack@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-10-23 21:50:35 +00:00
parent 8d5bfec90e
commit e50c6142bb
9 changed files with 18 additions and 199 deletions
+8 -13
View File
@@ -26,7 +26,7 @@ This creates a continuous memory system where Claude can learn from past session
Claude-mem integrates with Claude Code through 5 lifecycle hooks:
1. **SessionStart Hook** (`context-hook`)
- Auto-installs dependencies on first run (cross-platform Node.js installer)
- Ensures dependencies are installed (runs fast idempotent npm install)
- Injects context from previous sessions
- Auto-starts PM2 worker service
- Retrieves last 10 session summaries with three-tier verbosity (v4.2.0)
@@ -201,16 +201,12 @@ npm run build && git commit -a -m "Build and update" && git push && cd ~/.claude
```
1) Compiles TypeScript and outputs hook executables to `plugin/scripts/`
2) Generates `ensure-dependencies.js` - cross-platform installer script
3) Creates `package.json` in `plugin/scripts/` with runtime dependencies
4) Does all the things needed to update and test since plugin-based installs are out of the .claude/ folder
2) Does all the things needed to update and test since plugin-based installs are out of the .claude/ folder
**Build Outputs**:
- Hook executables: `*-hook.js` (ESM format)
- Worker service: `worker-service.cjs` (CJS format)
- Search server: `search-server.js` (ESM format)
- Dependency installer: `ensure-dependencies.js` (ESM format)
- Runtime manifest: `package.json` (includes `better-sqlite3` dependency)
## Version History
@@ -219,15 +215,14 @@ npm run build && git commit -a -m "Build and update" && git push && cd ~/.claude
**Fixes**:
- Fixed Windows PowerShell compatibility issue with SessionStart hook
- Replaced bash-specific installation command with cross-platform Node.js installer
- Added `ensure-dependencies.js` script for automatic dependency installation
- Build process now generates `package.json` with runtime dependencies in `plugin/scripts/`
- Replaced bash-specific test command `[` with cross-platform npm install command
- Hook now runs `npm install` with quiet flags (fast and idempotent when dependencies exist)
**Technical Details**:
- Created `src/bin/ensure-dependencies.ts` for cross-platform dependency management
- Updated `plugin/hooks/hooks.json` to use Node.js command chain instead of shell syntax
- Dependencies (`better-sqlite3`) are now installed automatically on first run across all platforms
- Added `.gitignore` rule for `plugin/scripts/package-lock.json`
- Updated `plugin/hooks/hooks.json` SessionStart command to use standard shell syntax
- Changed from: `[ ! -d ... ] && cd ... && npm install && node ... || node ...`
- Changed to: `cd ... && npm install --prefer-offline --no-audit --no-fund --loglevel=error && node ...`
- Dependencies are installed in marketplace folder (parent of CLAUDE_PLUGIN_ROOT) where root package.json exists
### v4.2.0
**Breaking Changes**: None (minor version)