monomind 1.10.45 → 1.10.47

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "monomind",
3
- "version": "1.10.45",
3
+ "version": "1.10.47",
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",
@@ -34,7 +34,8 @@ const initAction = async (ctx) => {
34
34
  if (initialized.monomind)
35
35
  output.printInfo(' Found: .monomind/config.yaml');
36
36
  output.printInfo('Use --force to reinitialize');
37
- if (ctx.interactive) {
37
+ const yes = ctx.flags.yes || process.env.CI === 'true';
38
+ if (ctx.interactive && !yes) {
38
39
  const proceed = await confirm({
39
40
  message: 'Do you want to reinitialize? This will overwrite existing configuration.',
40
41
  default: false,
@@ -43,8 +44,8 @@ const initAction = async (ctx) => {
43
44
  return { success: true, message: 'Initialization cancelled' };
44
45
  }
45
46
  }
46
- else {
47
- return { success: false, exitCode: 1, message: 'Already initialized' };
47
+ else if (!yes) {
48
+ return { success: false, exitCode: 1, message: 'Already initialized. Use --force or --yes to reinitialize.' };
48
49
  }
49
50
  }
50
51
  output.writeln();
@@ -849,6 +850,13 @@ export const initCommand = {
849
850
  type: 'boolean',
850
851
  default: false,
851
852
  },
853
+ {
854
+ name: 'yes',
855
+ short: 'y',
856
+ description: 'Skip confirmation prompts (also honoured via CI=true env var)',
857
+ type: 'boolean',
858
+ default: false,
859
+ },
852
860
  {
853
861
  name: 'minimal',
854
862
  short: 'm',
@@ -640,12 +640,14 @@ export async function executeUpgrade(targetDir, upgradeSettings = false) {
640
640
  fs.mkdirSync(fullPath, { recursive: true });
641
641
  }
642
642
  }
643
- // 0. ALWAYS update critical helpers (force overwrite)
643
+ // 0. ALWAYS update critical helpers + subdirectories (force overwrite)
644
644
  const sourceHelpersForUpgrade = findSourceHelpersDir();
645
645
  if (sourceHelpersForUpgrade) {
646
+ const destHelpersDir = path.join(targetDir, '.claude', 'helpers');
647
+ // Copy top-level critical files atomically
646
648
  const criticalHelpers = ['auto-memory-hook.mjs', 'hook-handler.cjs', 'intelligence.cjs'];
647
649
  for (const helperName of criticalHelpers) {
648
- const targetPath = path.join(targetDir, '.claude', 'helpers', helperName);
650
+ const targetPath = path.join(destHelpersDir, helperName);
649
651
  const sourcePath = path.join(sourceHelpersForUpgrade, helperName);
650
652
  if (fs.existsSync(sourcePath)) {
651
653
  if (fs.existsSync(targetPath)) {
@@ -654,18 +656,24 @@ export async function executeUpgrade(targetDir, upgradeSettings = false) {
654
656
  else {
655
657
  result.created.push(`.claude/helpers/${helperName}`);
656
658
  }
657
- // Atomic copy-via-rename: a SIGINT/crash during copy would leave a
658
- // half-written hook-handler.cjs which Claude Code executes on every
659
- // hook event — partial JS could disable security checks silently.
660
- {
661
- const tmp = targetPath + '.tmp';
662
- fs.copyFileSync(sourcePath, tmp);
663
- try {
664
- fs.chmodSync(tmp, 0o755);
665
- }
666
- catch { }
667
- fs.renameSync(tmp, targetPath);
659
+ // Atomic copy-via-rename so a partial write can't leave a broken hook
660
+ const tmp = targetPath + '.tmp';
661
+ fs.copyFileSync(sourcePath, tmp);
662
+ try {
663
+ fs.chmodSync(tmp, 0o755);
668
664
  }
665
+ catch { }
666
+ fs.renameSync(tmp, targetPath);
667
+ }
668
+ }
669
+ // Always recursively sync subdirectories (utils/, handlers/) — required by hook-handler.cjs.
670
+ // Uses recursive copy so any future nested subdirs are also covered.
671
+ for (const subdir of ['utils', 'handlers']) {
672
+ const srcSubdir = path.join(sourceHelpersForUpgrade, subdir);
673
+ const destSubdir = path.join(destHelpersDir, subdir);
674
+ if (fs.existsSync(srcSubdir)) {
675
+ copyDirRecursive(srcSubdir, destSubdir);
676
+ result.updated.push(`.claude/helpers/${subdir}/`);
669
677
  }
670
678
  }
671
679
  }
@@ -1210,12 +1218,19 @@ async function copyAgents(targetDir, options, result) {
1210
1218
  }
1211
1219
  /**
1212
1220
  * Find source helpers directory.
1213
- * Validates that the directory contains hook-handler.cjs to avoid
1214
- * returning the target directory or an incomplete source.
1221
+ * Validates that the directory contains hook-handler.cjs AND its required
1222
+ * subdirectory files (utils/telemetry.cjs etc.) to avoid accepting a partial
1223
+ * or corrupted source that would reproduce the missing-utils/ bug class.
1215
1224
  */
1216
1225
  function findSourceHelpersDir(sourceBaseDir) {
1217
1226
  const possiblePaths = [];
1218
- const SENTINEL_FILE = 'hook-handler.cjs'; // Must exist in valid source
1227
+ // All sentinel files must exist — hook-handler.cjs requires these at startup
1228
+ const SENTINEL_FILES = [
1229
+ 'hook-handler.cjs',
1230
+ path.join('utils', 'telemetry.cjs'),
1231
+ path.join('utils', 'monograph.cjs'),
1232
+ path.join('utils', 'micro-agents.cjs'),
1233
+ ];
1219
1234
  // If explicit source base directory is provided, check it first
1220
1235
  if (sourceBaseDir) {
1221
1236
  possiblePaths.push(path.join(sourceBaseDir, '.claude', 'helpers'));
@@ -1251,9 +1266,9 @@ function findSourceHelpersDir(sourceBaseDir) {
1251
1266
  path.join(process.cwd(), '..', '..', '.claude', 'helpers'),
1252
1267
  ];
1253
1268
  possiblePaths.push(...cwdBased);
1254
- // Return first path that exists AND contains the sentinel file
1269
+ // Return first path that exists AND contains ALL sentinel files
1255
1270
  for (const p of possiblePaths) {
1256
- if (fs.existsSync(p) && fs.existsSync(path.join(p, SENTINEL_FILE))) {
1271
+ if (fs.existsSync(p) && SENTINEL_FILES.every(f => fs.existsSync(path.join(p, f)))) {
1257
1272
  return p;
1258
1273
  }
1259
1274
  }
@@ -1266,29 +1281,34 @@ async function writeHelpers(targetDir, options, result) {
1266
1281
  const helpersDir = path.join(targetDir, '.claude', 'helpers');
1267
1282
  // Find source helpers directory (works for npm package and local dev)
1268
1283
  const sourceHelpersDir = findSourceHelpersDir(options.sourceBaseDir);
1269
- // Try to copy existing helpers from source first
1284
+ // Try to copy existing helpers from source first (recursive — includes utils/ and handlers/)
1270
1285
  if (sourceHelpersDir && fs.existsSync(sourceHelpersDir)) {
1271
- const helperFiles = fs.readdirSync(sourceHelpersDir);
1272
1286
  let copiedCount = 0;
1273
- for (const file of helperFiles) {
1274
- const sourcePath = path.join(sourceHelpersDir, file);
1275
- const destPath = path.join(helpersDir, file);
1276
- // Skip directories and only copy files
1277
- if (!fs.statSync(sourcePath).isFile())
1278
- continue;
1279
- if (!fs.existsSync(destPath) || options.force) {
1280
- fs.copyFileSync(sourcePath, destPath);
1281
- // Make shell scripts and mjs files executable
1282
- if (file.endsWith('.sh') || file.endsWith('.mjs')) {
1283
- fs.chmodSync(destPath, '755');
1287
+ const copyRecursive = (srcDir, destDir, relBase) => {
1288
+ fs.mkdirSync(destDir, { recursive: true });
1289
+ for (const entry of fs.readdirSync(srcDir, { withFileTypes: true })) {
1290
+ const srcPath = path.join(srcDir, entry.name);
1291
+ const destPath = path.join(destDir, entry.name);
1292
+ const relPath = relBase ? `${relBase}/${entry.name}` : entry.name;
1293
+ if (entry.isDirectory()) {
1294
+ copyRecursive(srcPath, destPath, relPath);
1295
+ }
1296
+ else {
1297
+ if (!fs.existsSync(destPath) || options.force) {
1298
+ fs.copyFileSync(srcPath, destPath);
1299
+ if (entry.name.endsWith('.sh') || entry.name.endsWith('.mjs')) {
1300
+ fs.chmodSync(destPath, '755');
1301
+ }
1302
+ result.created.files.push(`.claude/helpers/${relPath}`);
1303
+ copiedCount++;
1304
+ }
1305
+ else {
1306
+ result.skipped.push(`.claude/helpers/${relPath}`);
1307
+ }
1284
1308
  }
1285
- result.created.files.push(`.claude/helpers/${file}`);
1286
- copiedCount++;
1287
- }
1288
- else {
1289
- result.skipped.push(`.claude/helpers/${file}`);
1290
1309
  }
1291
- }
1310
+ };
1311
+ copyRecursive(sourceHelpersDir, helpersDir, '');
1292
1312
  if (copiedCount > 0) {
1293
1313
  return; // Skip generating if we copied from source
1294
1314
  }
@@ -1297,9 +1317,9 @@ async function writeHelpers(targetDir, options, result) {
1297
1317
  const helpers = {
1298
1318
  'pre-commit': generatePreCommitHook(),
1299
1319
  'post-commit': generatePostCommitHook(),
1300
- 'session.js': generateSessionManager(),
1301
- 'router.js': generateAgentRouter(),
1302
- 'memory.js': generateMemoryHelper(),
1320
+ 'session.cjs': generateSessionManager(),
1321
+ 'router.cjs': generateAgentRouter(),
1322
+ 'memory.cjs': generateMemoryHelper(),
1303
1323
  'hook-handler.cjs': generateHookHandler(),
1304
1324
  'intelligence.cjs': generateIntelligenceStub(),
1305
1325
  'auto-memory-hook.mjs': generateAutoMemoryHook(),
@@ -401,9 +401,9 @@ export function generateHookHandler() {
401
401
  ' return null;',
402
402
  '}',
403
403
  '',
404
- "const router = safeRequire(path.join(helpersDir, 'router.js'));",
405
- "const session = safeRequire(path.join(helpersDir, 'session.js'));",
406
- "const memory = safeRequire(path.join(helpersDir, 'memory.js'));",
404
+ "const router = safeRequire(path.join(helpersDir, 'router.cjs'));",
405
+ "const session = safeRequire(path.join(helpersDir, 'session.cjs'));",
406
+ "const memory = safeRequire(path.join(helpersDir, 'memory.cjs'));",
407
407
  "const intelligence = safeRequire(path.join(helpersDir, 'intelligence.cjs'));",
408
408
  '',
409
409
  'const [,, command, ...args] = process.argv;',
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monoes/monomindcli",
3
- "version": "1.10.45",
3
+ "version": "1.10.47",
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",