quilltap 3.1.0-dev.24 → 3.1.0-dev.27

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 +43 -1
  2. package/package.json +1 -1
package/bin/quilltap.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict';
3
3
 
4
- const { fork, exec } = require('child_process');
4
+ const { fork, exec, execSync } = require('child_process');
5
5
  const path = require('path');
6
6
  const fs = require('fs');
7
7
  const { getCacheDir, isCacheValid, ensureStandalone } = require('../lib/download-manager');
@@ -114,6 +114,45 @@ function openBrowser(url) {
114
114
  });
115
115
  }
116
116
 
117
+ // Check if native modules are compiled for the current Node.js version.
118
+ // This handles the case where npx caches the package but the user upgrades
119
+ // Node.js — the cached native modules will have a stale NODE_MODULE_VERSION.
120
+ function ensureNativeModules() {
121
+ const nativeModules = ['better-sqlite3', 'sharp'];
122
+ const needsRebuild = [];
123
+
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
134
+ }
135
+ }
136
+
137
+ if (needsRebuild.length === 0) return;
138
+
139
+ console.log(` Rebuilding native modules for Node.js ${process.version}...`);
140
+
141
+ try {
142
+ execSync(`npm rebuild ${needsRebuild.join(' ')}`, {
143
+ cwd: PACKAGE_DIR,
144
+ stdio: 'inherit',
145
+ });
146
+ console.log(' Done.');
147
+ console.log('');
148
+ } catch (err) {
149
+ console.error('');
150
+ console.error(` Warning: Failed to rebuild native modules: ${err.message}`);
151
+ console.error(' Try running: npm rebuild --prefix ' + PACKAGE_DIR);
152
+ console.error('');
153
+ }
154
+ }
155
+
117
156
  // Main
118
157
  async function main() {
119
158
  const opts = parseArgs(process.argv);
@@ -150,6 +189,9 @@ async function main() {
150
189
  process.exit(1);
151
190
  }
152
191
 
192
+ // Ensure native modules are compiled for the current Node.js version
193
+ ensureNativeModules();
194
+
153
195
  // Set up environment
154
196
  const env = {
155
197
  ...process.env,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quilltap",
3
- "version": "3.1.0-dev.24",
3
+ "version": "3.1.0-dev.27",
4
4
  "description": "Self-hosted AI workspace for writers, worldbuilders, and roleplayers. Run with npx quilltap.",
5
5
  "author": {
6
6
  "name": "Charles Sebold",