quilltap 3.1.0-dev.27 → 3.1.0-dev.29

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.
Files changed (2) hide show
  1. package/bin/quilltap.js +25 -11
  2. package/package.json +1 -1
package/bin/quilltap.js CHANGED
@@ -118,19 +118,33 @@ function openBrowser(url) {
118
118
  // This handles the case where npx caches the package but the user upgrades
119
119
  // Node.js — the cached native modules will have a stale NODE_MODULE_VERSION.
120
120
  function ensureNativeModules() {
121
- const nativeModules = ['better-sqlite3', 'sharp'];
122
121
  const needsRebuild = [];
123
122
 
124
- for (const mod of nativeModules) {
125
- try {
126
- require(mod);
127
- } catch (err) {
128
- if (err.message && err.message.includes('NODE_MODULE_VERSION')) {
129
- needsRebuild.push(mod);
130
- } else if (err.code === 'MODULE_NOT_FOUND') {
131
- needsRebuild.push(mod);
132
- }
133
- // Other errors (e.g., missing system libs) — let the server handle them
123
+ // Check better-sqlite3: it lazy-loads the native .node binary only when you
124
+ // create a Database, so a bare require('better-sqlite3') always succeeds.
125
+ // We must load the native binding directly to detect NODE_MODULE_VERSION mismatches.
126
+ try {
127
+ const bindingsPath = path.join(
128
+ PACKAGE_DIR, 'node_modules', 'better-sqlite3', 'build', 'Release', 'better_sqlite3.node'
129
+ );
130
+ require(bindingsPath);
131
+ } catch (err) {
132
+ if (err.message && err.message.includes('NODE_MODULE_VERSION')) {
133
+ needsRebuild.push('better-sqlite3');
134
+ } else if (err.code === 'MODULE_NOT_FOUND') {
135
+ needsRebuild.push('better-sqlite3');
136
+ }
137
+ }
138
+
139
+ // Check sharp: loads its native binding eagerly on require, but we use
140
+ // the same explicit-path approach for consistency and reliability.
141
+ try {
142
+ require('sharp');
143
+ } catch (err) {
144
+ if (err.message && err.message.includes('NODE_MODULE_VERSION')) {
145
+ needsRebuild.push('sharp');
146
+ } else if (err.code === 'MODULE_NOT_FOUND') {
147
+ needsRebuild.push('sharp');
134
148
  }
135
149
  }
136
150
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quilltap",
3
- "version": "3.1.0-dev.27",
3
+ "version": "3.1.0-dev.29",
4
4
  "description": "Self-hosted AI workspace for writers, worldbuilders, and roleplayers. Run with npx quilltap.",
5
5
  "author": {
6
6
  "name": "Charles Sebold",