vgxness 1.1.0 → 1.1.1

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/README.md CHANGED
@@ -58,7 +58,7 @@ npm run probe:bun
58
58
  npm run probe:bun -- --yes # mutates dependencies only after explicit consent
59
59
  ```
60
60
 
61
- Runtime SQLite readiness is proven with `bun:sqlite`. `bun run verify:bun-sqlite` copies the source migrations into a temporary directory, applies them against a temporary database, checks foreign keys, busy timeout, FTS/search, transaction rollback, integrity, and cleanup. `bun run verify:node-sqlite` remains optional Node native-binding tooling coverage only.
61
+ Runtime SQLite readiness is proven only with `bun:sqlite`. `bun run verify:bun-sqlite` copies the source migrations into a temporary directory, applies them against a temporary database, checks foreign keys, busy timeout, FTS/search, transaction rollback, integrity, and cleanup. Node.js remains development/build/test tooling, but real local SQLite storage is supported through the Bun runtime path.
62
62
 
63
63
  #### Bun package evidence
64
64
 
@@ -66,7 +66,7 @@ async function runRealMcpSmoke(options) {
66
66
  const client = new Client({ name: 'vgxness-doctor', version: '0.1.0' }, { capabilities: {} });
67
67
  const invocation = resolveDoctorCliInvocation(options.databasePath);
68
68
  const transport = new StdioClientTransport({
69
- command: process.execPath,
69
+ command: invocation.command,
70
70
  args: invocation.args,
71
71
  cwd: options.cwd,
72
72
  stderr: 'pipe',
@@ -173,11 +173,17 @@ function parseMcpToolResult(result) {
173
173
  return { ok: false, error: { code: 'validation_failed', message: 'MCP response did not contain text JSON' } };
174
174
  return JSON.parse(text);
175
175
  }
176
- export function resolveDoctorCliInvocation(databasePath, moduleUrl = import.meta.url) {
176
+ export function resolveDoctorCliInvocation(databasePath, moduleUrl = import.meta.url, options = {}) {
177
+ const runtime = options.runtime ?? currentRuntime();
177
178
  const builtCliPath = fileURLToPath(new URL('../cli/index.js', moduleUrl));
178
179
  if (existsSync(builtCliPath))
179
- return { args: [builtCliPath, 'mcp', 'start', '--db', databasePath] };
180
- return { args: ['--import', import.meta.resolve('tsx'), cliSourcePath(moduleUrl), 'mcp', 'start', '--db', databasePath] };
180
+ return { command: process.execPath, args: [builtCliPath, 'mcp', 'start', '--db', databasePath] };
181
+ if (runtime === 'bun')
182
+ return { command: process.execPath, args: [cliSourcePath(moduleUrl), 'mcp', 'start', '--db', databasePath] };
183
+ return { command: process.execPath, args: ['--import', import.meta.resolve('tsx'), cliSourcePath(moduleUrl), 'mcp', 'start', '--db', databasePath] };
184
+ }
185
+ function currentRuntime() {
186
+ return typeof globalThis.Bun === 'undefined' ? 'node' : 'bun';
181
187
  }
182
188
  function cliSourcePath(moduleUrl) {
183
189
  return fileURLToPath(new URL('../cli/index.ts', moduleUrl));
@@ -1,17 +1,10 @@
1
1
  import { existsSync, readdirSync, readFileSync } from 'node:fs';
2
+ import { createRequire } from 'node:module';
2
3
  import { dirname, join } from 'node:path';
3
4
  import { fileURLToPath } from 'node:url';
4
5
  const migrationsDirectory = join(dirname(fileURLToPath(import.meta.url)), 'migrations');
5
6
  export const sqliteBusyTimeoutMs = 5000;
6
- 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).';
7
- const nativeBindingFailurePatterns = [
8
- /better_sqlite3\.node/i,
9
- /better-sqlite3/i,
10
- /NODE_MODULE_VERSION/i,
11
- /ERR_DLOPEN_FAILED/i,
12
- /Could not locate the bindings file/i,
13
- /compiled against a different Node\.js version/i,
14
- ];
7
+ const bunRequiredGuidance = 'Real local SQLite storage requires Bun. Use the installed Bun-backed vgxness/vgx runtime, or run Bun storage verification with bun run verify:bun-sqlite.';
15
8
  export class MemoryDatabase {
16
9
  connection;
17
10
  constructor(connection) {
@@ -99,39 +92,37 @@ export function openMemoryDatabase(options) {
99
92
  }
100
93
  export function buildMemoryStoreUnavailableMessage(path, cause) {
101
94
  const message = `Unable to open local memory store at ${path}`;
102
- if (!isLikelyBetterSqlite3NativeBindingFailure(cause))
95
+ if (!isUnsupportedSqliteRuntimeError(cause))
103
96
  return message;
104
- return `${message}. ${nativeBindingDiagnosticGuidance}`;
97
+ return `${message}. ${bunRequiredGuidance}`;
105
98
  }
106
- export function isLikelyBetterSqlite3NativeBindingFailure(cause) {
107
- const values = collectDiagnosticValues(cause);
108
- return values.some((value) => nativeBindingFailurePatterns.some((pattern) => pattern.test(value)));
109
- }
110
- const sqliteDriver = await resolveSqliteDriver();
111
99
  function openSqliteConnection(options) {
112
- return sqliteDriver(options);
100
+ return resolveSqliteDriver()(options);
113
101
  }
114
- async function resolveSqliteDriver() {
102
+ function resolveSqliteDriver() {
115
103
  if (isBunRuntime())
116
104
  return resolveBunSqliteDriver();
117
- return resolveBetterSqlite3Driver();
105
+ throw createUnsupportedSqliteRuntimeError();
118
106
  }
119
107
  function isBunRuntime() {
120
108
  return typeof globalThis.Bun !== 'undefined';
121
109
  }
122
- async function resolveBetterSqlite3Driver() {
123
- const module = await import('better-sqlite3');
124
- const BetterSqlite3Database = module.default;
125
- return (options) => new BetterSqlite3Database(options.path, { readonly: options.readonly ?? false });
126
- }
127
- async function resolveBunSqliteDriver() {
128
- const bunSqliteSpecifier = 'bun:sqlite';
129
- const module = (await import(bunSqliteSpecifier));
110
+ function resolveBunSqliteDriver() {
111
+ const require = createRequire(import.meta.url);
112
+ const module = require('bun:sqlite');
130
113
  const BunDatabase = module.Database;
131
114
  if (typeof BunDatabase !== 'function')
132
115
  throw new Error('bun:sqlite Database constructor is unavailable');
133
116
  return (options) => createBunSqliteConnection(new BunDatabase(options.path, { readonly: options.readonly ?? false, strict: true }));
134
117
  }
118
+ function createUnsupportedSqliteRuntimeError() {
119
+ const error = new Error(bunRequiredGuidance);
120
+ error.name = 'UnsupportedSqliteRuntimeError';
121
+ return error;
122
+ }
123
+ function isUnsupportedSqliteRuntimeError(cause) {
124
+ return cause instanceof Error && cause.name === 'UnsupportedSqliteRuntimeError';
125
+ }
135
126
  function createBunSqliteConnection(database) {
136
127
  const record = database;
137
128
  return {
@@ -139,7 +130,7 @@ function createBunSqliteConnection(database) {
139
130
  const prepare = record.prepare;
140
131
  if (typeof prepare !== 'function')
141
132
  throw new Error('bun:sqlite prepare() is unavailable');
142
- return prepare.call(database, sql);
133
+ return createBunSqliteStatement(prepare.call(database, sql));
143
134
  },
144
135
  exec(sql) {
145
136
  const exec = record.exec;
@@ -174,6 +165,30 @@ function createBunSqliteConnection(database) {
174
165
  },
175
166
  };
176
167
  }
168
+ function createBunSqliteStatement(statement) {
169
+ const record = statement;
170
+ return {
171
+ get(...params) {
172
+ const get = record.get;
173
+ if (typeof get !== 'function')
174
+ throw new Error('bun:sqlite statement.get() is unavailable');
175
+ const row = get.call(statement, ...params);
176
+ return row === null ? undefined : row;
177
+ },
178
+ all(...params) {
179
+ const all = record.all;
180
+ if (typeof all !== 'function')
181
+ throw new Error('bun:sqlite statement.all() is unavailable');
182
+ return all.call(statement, ...params);
183
+ },
184
+ run(...params) {
185
+ const run = record.run;
186
+ if (typeof run !== 'function')
187
+ throw new Error('bun:sqlite statement.run() is unavailable');
188
+ return run.call(statement, ...params);
189
+ },
190
+ };
191
+ }
177
192
  function runBunPragma(database, statement) {
178
193
  const normalizedStatement = statement.trim();
179
194
  if (isPragmaSetter(normalizedStatement)) {
@@ -211,26 +226,3 @@ function migrationFailure(message, cause) {
211
226
  error.cause = cause;
212
227
  return { ok: false, error };
213
228
  }
214
- function collectDiagnosticValues(value, seen = new Set()) {
215
- if (value === undefined || value === null)
216
- return [];
217
- if (typeof value === 'string')
218
- return [value];
219
- if (typeof value === 'number' || typeof value === 'boolean' || typeof value === 'bigint' || typeof value === 'symbol')
220
- return [String(value)];
221
- if (typeof value !== 'object')
222
- return [];
223
- if (seen.has(value))
224
- return [];
225
- seen.add(value);
226
- const diagnosticValues = [];
227
- const record = value;
228
- for (const key of ['code', 'message', 'stack', 'name']) {
229
- const property = record[key];
230
- if (property !== undefined)
231
- diagnosticValues.push(...collectDiagnosticValues(property, seen));
232
- }
233
- if (record.cause !== undefined)
234
- diagnosticValues.push(...collectDiagnosticValues(record.cause, seen));
235
- return diagnosticValues;
236
- }
package/docs/cli.md CHANGED
@@ -77,12 +77,13 @@ bun install --frozen-lockfile
77
77
  bun run check:bun-lock
78
78
  bun run verify:typecheck
79
79
  bun run verify:test
80
+ bun run verify:test:bun-storage
80
81
  bun run verify:bun-sqlite
81
82
  bun run verify:package
82
83
  bun run package:bun:evidence -- --require-pass
83
84
  ```
84
85
 
85
- `bun run verify:bun-sqlite` is the SQLite runtime release gate. It uses `bun:sqlite` against a temporary database, copies/applies the source migrations, and checks foreign keys, busy timeout, FTS/search, transaction rollback, integrity, and cleanup. `bun run verify:node-sqlite` is optional Node native-binding tooling coverage only.
86
+ `bun run verify:bun-sqlite` is the SQLite runtime release gate. It uses `bun:sqlite` against a temporary database, copies/applies the source migrations, and checks foreign keys, busy timeout, FTS/search, transaction rollback, integrity, and cleanup. `bun run verify:test:bun-storage` covers storage-backed tests under Bun. Node.js remains development/build/test tooling, but real local SQLite storage is supported through the Bun runtime path.
86
87
 
87
88
  Keep lockfile changes intentional: when `package.json` dependency specifiers change, refresh and review the root `bun.lock` diff. The read-only drift check does not run `bun install` and does not mutate `node_modules`:
88
89
 
@@ -43,13 +43,12 @@ Esa capa no reemplaza a OpenCode, Claude Code o futuros adapters. Los coordina.
43
43
 
44
44
  ## Como esta construido
45
45
 
46
- El proyecto esta escrito en TypeScript y corre sobre Node.js 22 o superior.
46
+ El proyecto esta escrito en TypeScript. Node.js 22 o superior sigue siendo tooling de desarrollo/build/tests; la persistencia local real en SQLite corre por el runtime Bun soportado.
47
47
 
48
48
  Dependencias principales:
49
49
 
50
50
  | Dependencia | Uso |
51
51
  |---|---|
52
- | `better-sqlite3` | Persistencia local en SQLite. |
53
52
  | `@modelcontextprotocol/sdk` | Servidor MCP por stdio. |
54
53
  | `zod` | Validacion de schemas de entrada. |
55
54
  | `tsx` | Ejecucion TypeScript en desarrollo. |
@@ -135,9 +134,9 @@ Archivo clave:
135
134
  src/memory/sqlite/database.ts
136
135
  ```
137
136
 
138
- Al abrir la base, el sistema:
137
+ Al abrir la base con el runtime Bun, el sistema:
139
138
 
140
- 1. Crea una conexion con `better-sqlite3`.
139
+ 1. Crea una conexion SQLite usando `bun:sqlite`.
141
140
  2. Activa `foreign_keys`.
142
141
  3. Configura `busy_timeout`.
143
142
  4. Aplica migraciones SQL si la base no esta en modo readonly.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vgxness",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
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": {
@@ -22,12 +22,12 @@
22
22
  "scripts": {
23
23
  "cli": "tsx src/cli/index.ts",
24
24
  "build": "tsc -p tsconfig.build.json && node scripts/copy-migrations.mjs",
25
- "verify": "bun run verify:typecheck && bun run verify:test && bun run verify:bun-sqlite && bun run verify:package",
25
+ "verify": "bun run verify:typecheck && bun run verify:test && bun run verify:test:bun-storage && bun run verify:bun-sqlite && bun run verify:package",
26
26
  "verify:typecheck": "tsc --noEmit",
27
- "verify:test": "node --import tsx --test \"test/**/*.test.ts\"",
27
+ "verify:test": "node scripts/run-node-tests.mjs",
28
+ "verify:test:bun-storage": "node scripts/run-bun-storage-tests.mjs",
28
29
  "verify:package": "bun run package:bun:evidence",
29
30
  "verify:bun-sqlite": "bun scripts/probe-bun-sqlite.mjs",
30
- "verify:node-sqlite": "node scripts/probe-native-sqlite.mjs",
31
31
  "ci:bun": "bun run check:bun-lock && bun run verify",
32
32
  "check:bun-lock": "node scripts/check-bun-lock.mjs",
33
33
  "check:vgxcode:bun-lock": "node scripts/check-bun-lock.mjs --package-json packages/vgxcode/package.json --bun-lock packages/vgxcode/bun.lock",
@@ -36,7 +36,7 @@
36
36
  "probe:bun-runtime": "node scripts/probe-bun-runtime-cli-mcp.mjs",
37
37
  "verify:bun-runtime": "node scripts/probe-bun-runtime-cli-mcp.mjs --require-pass",
38
38
  "package:bun:evidence": "node scripts/probe-bun-package-evidence.mjs",
39
- "test": "node --import tsx --test \"test/**/*.test.ts\"",
39
+ "test": "node scripts/run-node-tests.mjs",
40
40
  "typecheck": "tsc --noEmit"
41
41
  },
42
42
  "bin": {
@@ -58,10 +58,8 @@
58
58
  "zod": "^4.4.3"
59
59
  },
60
60
  "devDependencies": {
61
- "@types/better-sqlite3": "^7.6.13",
62
61
  "@types/node": "^22.15.18",
63
62
  "@types/react": "^19.2.15",
64
- "better-sqlite3": "^12.10.0",
65
63
  "tsx": "^4.19.4",
66
64
  "typescript": "^5.8.3"
67
65
  },