monomind 1.9.3 → 1.9.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.
@@ -52,8 +52,29 @@ if (!entryPoint) {
52
52
  process.exit(0);
53
53
  }
54
54
 
55
+ // Skip if another build is already in progress (avoids SQLite BUSY on concurrent init + session-start)
56
+ const lockPath = path.join(graphDir, 'build.lock');
57
+ const now = Date.now();
58
+ try {
59
+ const stat = fs.statSync(lockPath);
60
+ // Stale lock older than 5 minutes — remove it and proceed
61
+ if (now - stat.mtimeMs < 5 * 60 * 1000) {
62
+ console.log('[graph] build already in progress — skipping');
63
+ process.exit(0);
64
+ }
65
+ fs.unlinkSync(lockPath);
66
+ } catch { /* lock does not exist — proceed */ }
67
+
68
+ // Write lock file; the build process removes it on completion
69
+ try { fs.writeFileSync(lockPath, String(process.pid)); } catch { /* non-fatal */ }
70
+
55
71
  // Spawn a detached node process to run buildAsync from @monoes/monograph (ESM)
56
- const script = `import { buildAsync } from ${JSON.stringify('file://' + entryPoint)}; await buildAsync(${JSON.stringify(projectDir)});`;
72
+ const script = `
73
+ import { buildAsync } from ${JSON.stringify('file://' + entryPoint)};
74
+ import { unlinkSync } from 'fs';
75
+ try { await buildAsync(${JSON.stringify(projectDir)}); } finally {
76
+ try { unlinkSync(${JSON.stringify(lockPath)}); } catch {}
77
+ }`;
57
78
  const child = spawn(process.execPath, ['--input-type=module', '--eval', script], {
58
79
  detached: true,
59
80
  stdio: ['ignore', logFd, logFd],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "monomind",
3
- "version": "1.9.3",
3
+ "version": "1.9.4",
4
4
  "description": "Monomind - Enterprise AI agent orchestration for Claude Code. Deploy 60+ specialized agents in coordinated swarms with self-learning, fault-tolerant consensus, vector memory, and MCP integration",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -89,18 +89,14 @@ const initAction = async (ctx) => {
89
89
  return { success: false, exitCode: 1 };
90
90
  }
91
91
  spinner.succeed('Monomind initialized successfully!');
92
- // Trigger background monograph build + continuous watch
92
+ // Trigger background monograph watch (includes initial build on start).
93
+ // Only one spawn — avoids SQLite BUSY from concurrent build + watch + session-start hook.
93
94
  try {
94
95
  const { spawn } = await import('child_process');
95
- for (const args of [
96
- ['monograph', 'build', '--code-only'],
97
- ['monograph', 'watch'],
98
- ]) {
99
- const proc = spawn(process.execPath, [process.argv[1], ...args], {
100
- detached: true, stdio: 'ignore', cwd: ctx.cwd, env: process.env,
101
- });
102
- proc.unref();
103
- }
96
+ const proc = spawn(process.execPath, [process.argv[1], 'monograph', 'watch'], {
97
+ detached: true, stdio: 'ignore', cwd: ctx.cwd, env: process.env,
98
+ });
99
+ proc.unref();
104
100
  output.printInfo('◈ Building knowledge graph in background… (watch mode active)');
105
101
  }
106
102
  catch {
@@ -350,25 +350,16 @@ export async function executeInit(options) {
350
350
  return result;
351
351
  }
352
352
  /**
353
- * Initialize the Monograph knowledge graph (native TypeScript, no Python required).
354
- * Fire-and-forget build init does not wait for it to complete.
353
+ * Initialize the Monograph knowledge graph output directory.
354
+ * The actual build is kicked off by init.ts after executeInit returns,
355
+ * as a detached child process — keeping it out-of-process avoids SQLite
356
+ * lock contention with any concurrently-running session-start hooks.
355
357
  */
356
358
  async function initKnowledgeGraph(targetDir, result) {
357
359
  const { mkdirSync } = await import('fs');
358
360
  const outputDir = path.join(targetDir, '.monomind', 'graph');
359
361
  mkdirSync(outputDir, { recursive: true });
360
- try {
361
- const { buildAsync } = await import('@monoes/monograph');
362
- buildAsync(targetDir, { codeOnly: false })
363
- .then(() => { })
364
- .catch((err) => {
365
- console.warn('[monograph] Background build failed:', err);
366
- });
367
- result.created.files.push('.monomind/monograph.db (knowledge graph building in background)');
368
- }
369
- catch (err) {
370
- result.skipped.push('knowledge graph: monograph package unavailable');
371
- }
362
+ result.created.files.push('.monomind/graph/ (knowledge graph directory, build starts after init)');
372
363
  }
373
364
  /**
374
365
  * Start the monomind daemon with background workers.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monoes/monomindcli",
3
- "version": "1.9.3",
3
+ "version": "1.9.4",
4
4
  "type": "module",
5
5
  "description": "Monomind CLI - Enterprise AI agent orchestration with 60+ specialized agents, swarm coordination, MCP server, self-learning hooks, and vector memory for Claude Code",
6
6
  "main": "dist/src/index.js",