monomind 1.9.2 → 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.
- package/.claude/helpers/graphify-freshen.cjs +22 -1
- package/package.json +1 -1
- package/packages/@monomind/cli/dist/src/commands/init.js +6 -10
- package/packages/@monomind/cli/dist/src/init/executor.js +5 -14
- package/packages/@monomind/cli/dist/src/init/settings-generator.js +34 -16
- package/packages/@monomind/cli/package.json +1 -1
|
@@ -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 = `
|
|
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
|
+
"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
|
|
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
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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
|
|
354
|
-
*
|
|
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
|
-
|
|
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.
|
|
@@ -10,7 +10,7 @@ export function generateSettings(options) {
|
|
|
10
10
|
const settings = {};
|
|
11
11
|
// Add hooks if enabled
|
|
12
12
|
if (options.components.settings) {
|
|
13
|
-
settings.hooks = generateHooksConfig(options.hooks);
|
|
13
|
+
settings.hooks = generateHooksConfig(options.hooks, options.components.graphify);
|
|
14
14
|
}
|
|
15
15
|
// Add statusLine configuration if enabled
|
|
16
16
|
if (options.statusline.enabled) {
|
|
@@ -174,6 +174,15 @@ function hookHandlerCmd(subcommand) {
|
|
|
174
174
|
function autoMemoryCmd(subcommand) {
|
|
175
175
|
return hookCmd('.claude/helpers/auto-memory-hook.mjs', subcommand);
|
|
176
176
|
}
|
|
177
|
+
/** Shorthand for standalone CJS helper scripts (no subcommand) */
|
|
178
|
+
function standaloneHelperCmd(script) {
|
|
179
|
+
if (IS_WINDOWS) {
|
|
180
|
+
return `cmd /c node %CLAUDE_PROJECT_DIR%/.claude/helpers/${script}`;
|
|
181
|
+
}
|
|
182
|
+
// eslint-disable-next-line no-template-curly-in-string
|
|
183
|
+
const dir = '${CLAUDE_PROJECT_DIR:-.}';
|
|
184
|
+
return `sh -c 'exec node "${dir}/.claude/helpers/${script}"'`;
|
|
185
|
+
}
|
|
177
186
|
/**
|
|
178
187
|
* Generate statusLine configuration for Claude Code
|
|
179
188
|
* Uses local helper script for cross-platform compatibility (no npx cold-start)
|
|
@@ -197,7 +206,7 @@ function generateStatusLineConfig(_options) {
|
|
|
197
206
|
* All hooks invoke scripts directly via `node <script> <subcommand>`,
|
|
198
207
|
* working identically on Windows, macOS, and Linux.
|
|
199
208
|
*/
|
|
200
|
-
function generateHooksConfig(config) {
|
|
209
|
+
function generateHooksConfig(config, graphify = true) {
|
|
201
210
|
const hooks = {};
|
|
202
211
|
// Node.js scripts handle errors internally via try/catch.
|
|
203
212
|
// No shell-level error suppression needed (2>/dev/null || true breaks Windows).
|
|
@@ -265,24 +274,33 @@ function generateHooksConfig(config) {
|
|
|
265
274
|
},
|
|
266
275
|
];
|
|
267
276
|
}
|
|
268
|
-
// SessionStart — restore session state + import auto memory
|
|
277
|
+
// SessionStart — restore session state + import auto memory + build knowledge graph
|
|
269
278
|
if (config.sessionStart) {
|
|
270
|
-
|
|
279
|
+
const sessionStartHooks = [
|
|
271
280
|
{
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
command: autoMemoryCmd('import'),
|
|
281
|
-
timeout: 8000,
|
|
282
|
-
},
|
|
283
|
-
],
|
|
281
|
+
type: 'command',
|
|
282
|
+
command: hookHandlerCmd('session-restore'),
|
|
283
|
+
timeout: 15000,
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
type: 'command',
|
|
287
|
+
command: autoMemoryCmd('import'),
|
|
288
|
+
timeout: 8000,
|
|
284
289
|
},
|
|
285
290
|
];
|
|
291
|
+
if (graphify) {
|
|
292
|
+
sessionStartHooks.push({
|
|
293
|
+
type: 'command',
|
|
294
|
+
command: standaloneHelperCmd('graphify-freshen.cjs'),
|
|
295
|
+
timeout: 5000,
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
sessionStartHooks.push({
|
|
299
|
+
type: 'command',
|
|
300
|
+
command: standaloneHelperCmd('control-start.cjs'),
|
|
301
|
+
timeout: 5000,
|
|
302
|
+
});
|
|
303
|
+
hooks.SessionStart = [{ hooks: sessionStartHooks }];
|
|
286
304
|
}
|
|
287
305
|
// SessionEnd — persist session state
|
|
288
306
|
if (config.sessionStart) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@monoes/monomindcli",
|
|
3
|
-
"version": "1.9.
|
|
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",
|