Skip to content

Commit 0efddc9

Browse files
committed
fix(doctor,hooks): resolve better-sqlite3 via require.resolve to follow npm hoisting (v4.2.6)
The v4.2.5 native-binding probe regressed every fresh `npm install @pcircle/memesh` install: it pre-checked `<packageRoot>/node_modules/better-sqlite3` literally, but npm hoists dependencies to the consumer's top-level node_modules. So when memesh is installed as a dependency the directory at the literal path doesn't exist even though `require('better-sqlite3')` works correctly via Node's normal resolution. Found this by verifying the v4.2.5 release with a clean-room install: $ mkdir /tmp/verify && cd /tmp/verify $ npm install @pcircle/memesh@4.2.5 $ ./node_modules/.bin/memesh doctor Overall: FAIL [FAIL] Native SQLite binding ← false negative on a working install The fix in both surfaces (doctor.ts and _shared.js) is to drop the existence-precheck and call `require.resolve('better-sqlite3', { paths: [pkgRoot] })`. Node's resolver walks the same path the runtime uses (current dir → parent → ancestor's node_modules) and returns the resolved module path, which we walk back to the package root. A MODULE_NOT_FOUND error from the probe surfaces as a clean "run `npm install`" hint; a `bindings file` error still surfaces as the rebuild hint from v4.2.5. The hook self-heal also retargets `npm rebuild`'s cwd to the project that owns the hoisted node_modules tree (walking up until a non-node_modules package.json appears). Running rebuild from memesh's own pkgRoot would no-op when the binary is hoisted elsewhere. Validation: - Local clean-room install: smoke test confirms 4.2.6 doctor PASSes on a hoisted install - npm test --run: 1036/1038 (same 2 pre-existing failures as v4.2.5) - memesh doctor: Overall: PASS_WITH_CONCERNS, native-binding PASS - npm run lint: clean Version bumped 4.2.5 -> 4.2.6 across all 7 anchor files. The CodeQL config and TOCTOU fix from v4.2.5 carry forward unchanged.
1 parent fda4f90 commit 0efddc9

13 files changed

Lines changed: 80 additions & 43 deletions

File tree

.claude-plugin/marketplace.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"name": "memesh",
99
"source": "./",
1010
"description": "MeMesh — Local memory for Claude Code and MCP coding agents. One SQLite file, zero cloud required.",
11-
"version": "4.2.5",
11+
"version": "4.2.6",
1212
"author": {
1313
"name": "PCIRCLE AI"
1414
},

.claude-plugin/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"author": {
55
"name": "PCIRCLE AI"
66
},
7-
"version": "4.2.5",
7+
"version": "4.2.6",
88
"homepage": "https://pcircle.ai/memesh-llm-memory",
99
"repository": "https://github.com/PCIRCLE-AI/memesh-llm-memory",
1010
"license": "MIT",

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
All notable changes to MeMesh are documented here.
44

5+
## [4.2.6] — 2026-05-13
6+
7+
### Fixed
8+
- **`memesh doctor` and hook self-heal now follow npm hoisting** (`src/core/doctor.ts`, `scripts/hooks/_shared.js`) — the v4.2.5 native-binding check pre-checked `<packageRoot>/node_modules/better-sqlite3` literally, but when memesh is installed as a dependency npm hoists `better-sqlite3` to the consumer's top-level `node_modules/`. Result: every fresh `npm install @pcircle/memesh` saw a FAIL on the native-binding check even though the binding worked correctly. Both surfaces now resolve via `require.resolve('better-sqlite3', { paths: [pkgRoot] })`, which follows Node's normal resolution algorithm and finds hoisted packages. The hook's `npm rebuild` self-heal also targets the correct project root now (the package that owns the hoisted `node_modules`), not memesh's own pkgRoot.
9+
- Doctor test `reports FAIL when node_modules/better-sqlite3 is entirely missing` updated to `reports FAIL with npm install hint when better-sqlite3 is not resolvable` — exercises the MODULE_NOT_FOUND probe response now that the existence-check branch is gone.
10+
511
## [4.2.5] — 2026-05-13
612

713
### Added

dist/core/doctor.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/core/doctor.js

Lines changed: 6 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/core/doctor.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/skills-manifest.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"schema": "memesh.skills-manifest/v1",
3-
"generated_at": "2026-05-13T05:09:42.706Z",
3+
"generated_at": "2026-05-13T05:46:34.185Z",
44
"entries": [
55
{
66
"path": ".claude-plugin/plugin.json",
7-
"sha256": "c42ed9693fcd5e37af60769b6f0dabc9061e416be2148b4a87ee38242c0f4645",
7+
"sha256": "34a93efe40e01daa689670b91ce9937c9cf018b6cf60de15bab89534625d215f",
88
"bytes": 441
99
},
1010
{
@@ -19,8 +19,8 @@
1919
},
2020
{
2121
"path": "scripts/hooks/_shared.js",
22-
"sha256": "247f6cac1ff3615b121f7419b9824cab8cb2e8a835d06ae6dcdca39aba92706f",
23-
"bytes": 32902
22+
"sha256": "392c1ea45952197d1c65ce92c5e5d80623b635322fb3f446a0b58a055abbac25",
23+
"bytes": 33970
2424
},
2525
{
2626
"path": "scripts/hooks/post-commit.js",

docs/ARCHITECTURE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# MeMesh Plugin Architecture
22

3-
**Version**: 4.2.5
3+
**Version**: 4.2.6
44

55
---
66

docs/api/API_REFERENCE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# MeMesh Plugin -- API Reference
22

33
**Protocol**: Model Context Protocol (MCP) over stdio
4-
**Version**: 4.2.5
4+
**Version**: 4.2.6
55
**Compatibility**: Works with Claude Code plugins, Claude Managed Agents (via MCP connector), and any MCP-compatible client.
66

77
---

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pcircle/memesh",
3-
"version": "4.2.5",
3+
"version": "4.2.6",
44
"description": "MeMesh — Local memory for Claude Code and MCP coding agents. One SQLite file, zero cloud required.",
55
"main": "dist/index.js",
66
"type": "module",

0 commit comments

Comments
 (0)