vgxness 1.0.3 → 1.0.4

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.
@@ -4,6 +4,15 @@ import { fileURLToPath } from 'node:url';
4
4
  import Database from 'better-sqlite3';
5
5
  const migrationsDirectory = join(dirname(fileURLToPath(import.meta.url)), 'migrations');
6
6
  export const sqliteBusyTimeoutMs = 5000;
7
+ const nativeBindingDiagnosticGuidance = 'Detected a likely better-sqlite3 native binding problem. Ensure npm install scripts are enabled, then rebuild or reinstall dependencies for the active Node.js version (for example: npm rebuild better-sqlite3 --ignore-scripts=false).';
8
+ const nativeBindingFailurePatterns = [
9
+ /better_sqlite3\.node/i,
10
+ /better-sqlite3/i,
11
+ /NODE_MODULE_VERSION/i,
12
+ /ERR_DLOPEN_FAILED/i,
13
+ /Could not locate the bindings file/i,
14
+ /compiled against a different Node\.js version/i,
15
+ ];
7
16
  export class MemoryDatabase {
8
17
  connection;
9
18
  constructor(connection) {
@@ -29,7 +38,7 @@ export class MemoryDatabase {
29
38
  ok: false,
30
39
  error: {
31
40
  code: 'store_unavailable',
32
- message: `Unable to open local memory store at ${options.path}`,
41
+ message: buildMemoryStoreUnavailableMessage(options.path, cause),
33
42
  cause,
34
43
  },
35
44
  };
@@ -89,9 +98,42 @@ export class MemoryDatabase {
89
98
  export function openMemoryDatabase(options) {
90
99
  return MemoryDatabase.open(options);
91
100
  }
101
+ export function buildMemoryStoreUnavailableMessage(path, cause) {
102
+ const message = `Unable to open local memory store at ${path}`;
103
+ if (!isLikelyBetterSqlite3NativeBindingFailure(cause))
104
+ return message;
105
+ return `${message}. ${nativeBindingDiagnosticGuidance}`;
106
+ }
107
+ export function isLikelyBetterSqlite3NativeBindingFailure(cause) {
108
+ const values = collectDiagnosticValues(cause);
109
+ return values.some((value) => nativeBindingFailurePatterns.some((pattern) => pattern.test(value)));
110
+ }
92
111
  function migrationFailure(message, cause) {
93
112
  const error = { code: 'migration_failed', message };
94
113
  if (cause !== undefined)
95
114
  error.cause = cause;
96
115
  return { ok: false, error };
97
116
  }
117
+ function collectDiagnosticValues(value, seen = new Set()) {
118
+ if (value === undefined || value === null)
119
+ return [];
120
+ if (typeof value === 'string')
121
+ return [value];
122
+ if (typeof value === 'number' || typeof value === 'boolean' || typeof value === 'bigint' || typeof value === 'symbol')
123
+ return [String(value)];
124
+ if (typeof value !== 'object')
125
+ return [];
126
+ if (seen.has(value))
127
+ return [];
128
+ seen.add(value);
129
+ const diagnosticValues = [];
130
+ const record = value;
131
+ for (const key of ['code', 'message', 'stack', 'name']) {
132
+ const property = record[key];
133
+ if (property !== undefined)
134
+ diagnosticValues.push(...collectDiagnosticValues(property, seen));
135
+ }
136
+ if (record.cause !== undefined)
137
+ diagnosticValues.push(...collectDiagnosticValues(record.cause, seen));
138
+ return diagnosticValues;
139
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vgxness",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "CLI and MCP control plane for guided AI-agent workflows, SDD, memory, and OpenCode setup.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "repository": {