mindlore 0.7.5 → 0.7.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mindlore",
3
- "version": "0.7.5",
3
+ "version": "0.7.6",
4
4
  "description": "AI-native knowledge system for Claude Code",
5
5
  "type": "commonjs",
6
6
  "bin": {
@@ -80,6 +80,8 @@
80
80
  "skills/",
81
81
  "templates/",
82
82
  "SCHEMA.md",
83
- "plugin.json"
83
+ "plugin.json",
84
+ "mcp-server.cjs",
85
+ "start.cjs"
84
86
  ]
85
87
  }
package/plugin.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "manifestVersion": 2,
3
3
  "name": "mindlore",
4
4
  "description": "AI-native knowledge system for Claude Code. Persistent, searchable, evolving knowledge base with FTS5 and Knowledge Graph.",
5
- "version": "0.7.5",
5
+ "version": "0.7.6",
6
6
  "skills": [
7
7
  {
8
8
  "name": "mindlore-ingest",
package/start.cjs ADDED
@@ -0,0 +1,141 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Mindlore MCP Server bootstrap (context-mode pattern).
4
+ *
5
+ * CC plugin marketplace install pipeline does NOT run `npm install` —
6
+ * it just extracts the tarball. Native deps (better-sqlite3, sqlite-vec)
7
+ * need install-time platform binaries that bundledDependencies cannot
8
+ * ship cross-platform (sqlite-vec uses optionalDependencies pattern with
9
+ * per-platform packages, better-sqlite3 v12 ships no prebuilds/ dir).
10
+ *
11
+ * Strategy: this wrapper runs BEFORE mcp-server.cjs. It detects missing
12
+ * or wrong-platform native binaries and self-heals via `npm install` in
13
+ * the plugin cache dir. First boot is 5-30s (one-time), subsequent boots
14
+ * are <100ms (existsSync fast path).
15
+ *
16
+ * Why a separate wrapper instead of inlining in mcp-server.cjs:
17
+ * 1. mcp-server.cjs is an esbuild bundle — adding logic before the
18
+ * require('better-sqlite3') happens at the top of the bundle is hard
19
+ * 2. Single source of truth — hooks can also import ensure-deps later
20
+ * 3. Easier to swap out if CC plugin spec adds postinstall hooks
21
+ *
22
+ * See: feedback_cc_plugin_self_contained.md, feedback_multi_platform_binary.md
23
+ */
24
+
25
+ 'use strict';
26
+
27
+ const fs = require('node:fs');
28
+ const path = require('node:path');
29
+ const { execSync, spawn } = require('node:child_process');
30
+
31
+ const __dirname_ = __dirname;
32
+ const NPM = process.platform === 'win32' ? 'npm.cmd' : 'npm';
33
+
34
+ // Native dep manifest — package + expected binary location after install
35
+ const NATIVE_DEPS = [
36
+ {
37
+ pkg: 'better-sqlite3',
38
+ binary: ['build', 'Release', 'better_sqlite3.node'],
39
+ },
40
+ // sqlite-vec uses optionalDependencies for per-platform packages
41
+ // (sqlite-vec-{linux,darwin,win32}-{x64,arm64}). npm picks the right one
42
+ // at install time. We just check the wrapper package presence — the
43
+ // platform-specific binary is auto-selected by sqlite-vec loader.
44
+ {
45
+ pkg: 'sqlite-vec',
46
+ binary: null, // loader handles platform selection
47
+ },
48
+ ];
49
+
50
+ const RUNTIME_DEPS = [
51
+ '@modelcontextprotocol/sdk',
52
+ 'zod',
53
+ ];
54
+
55
+ function log(msg) {
56
+ // stderr — stdout is reserved for MCP JSON-RPC
57
+ process.stderr.write(`[mindlore-bootstrap] ${msg}\n`);
58
+ }
59
+
60
+ function depPresent({ pkg, binary }) {
61
+ const pkgDir = path.join(__dirname_, 'node_modules', pkg);
62
+ if (!fs.existsSync(pkgDir)) return false;
63
+ if (binary && !fs.existsSync(path.join(pkgDir, ...binary))) return false;
64
+ return true;
65
+ }
66
+
67
+ function probeBetterSqlite3() {
68
+ // Child process probe — in-process require() caches dlopen, can't detect
69
+ // on-disk binary swaps (ABI mismatch or wrong-platform binary).
70
+ try {
71
+ execSync(
72
+ `node -e "new (require('better-sqlite3'))(':memory:').close()"`,
73
+ { cwd: __dirname_, stdio: 'pipe', timeout: 10000 }
74
+ );
75
+ return true;
76
+ } catch {
77
+ return false;
78
+ }
79
+ }
80
+
81
+ function installMissing(packages) {
82
+ if (packages.length === 0) return true;
83
+ log(`installing missing packages: ${packages.join(', ')}`);
84
+ log('(first boot only — subsequent boots <100ms)');
85
+ try {
86
+ execSync(
87
+ `${NPM} install ${packages.join(' ')} --no-package-lock --no-save --silent`,
88
+ { cwd: __dirname_, stdio: 'pipe', timeout: 180000, shell: true }
89
+ );
90
+ log('install complete');
91
+ return true;
92
+ } catch (err) {
93
+ log(`install failed: ${err && err.message ? err.message : String(err)}`);
94
+ log('MCP server may not function — check network + write permissions in plugin cache dir');
95
+ return false;
96
+ }
97
+ }
98
+
99
+ function rebuildBetterSqlite3() {
100
+ log('rebuilding better-sqlite3 for current platform/ABI');
101
+ try {
102
+ execSync(`${NPM} rebuild better-sqlite3 --silent`, {
103
+ cwd: __dirname_, stdio: 'pipe', timeout: 120000, shell: true,
104
+ });
105
+ return true;
106
+ } catch (err) {
107
+ log(`rebuild failed: ${err && err.message ? err.message : String(err)}`);
108
+ return false;
109
+ }
110
+ }
111
+
112
+ function ensureDeps() {
113
+ // Fast path: everything present
114
+ const allDeps = [...NATIVE_DEPS, ...RUNTIME_DEPS.map((pkg) => ({ pkg, binary: null }))];
115
+ const missing = allDeps.filter((d) => !depPresent(d));
116
+
117
+ if (missing.length > 0) {
118
+ const installed = installMissing(missing.map((d) => d.pkg));
119
+ if (!installed) return false;
120
+ }
121
+
122
+ // ABI probe — even if binary file exists, it may be wrong platform
123
+ // (someone copied tarball cross-platform, or `prebuild-install` cached wrong arch).
124
+ if (!probeBetterSqlite3()) {
125
+ log('better-sqlite3 binary present but fails probe (likely ABI mismatch or wrong platform)');
126
+ rebuildBetterSqlite3();
127
+ // Re-probe after rebuild
128
+ if (!probeBetterSqlite3()) {
129
+ log('rebuild did not fix the probe — MCP boot may fail');
130
+ // Don't exit — let downstream require() surface the actual error
131
+ }
132
+ }
133
+
134
+ return true;
135
+ }
136
+
137
+ // Run ensure layer
138
+ ensureDeps();
139
+
140
+ // Boot the actual MCP server
141
+ require('./mcp-server.cjs');
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.7.5",
2
+ "version": "0.7.6",
3
3
  "models": {
4
4
  "ingest": "haiku",
5
5
  "evolve": "sonnet",