monomind 1.17.0 → 1.17.2

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.
Files changed (94) hide show
  1. package/.claude/agents/engineering/engineering-security-engineer.md +1 -1
  2. package/.claude/commands/mastermind/_repeat.md +4 -0
  3. package/.claude/commands/mastermind/master.md +52 -1
  4. package/.claude/scheduled_tasks.lock +1 -1
  5. package/.claude/skills/mastermind/_repeat.md +2 -0
  6. package/package.json +1 -1
  7. package/packages/@monomind/cli/.claude/agents/engineering/engineering-security-engineer.md +1 -1
  8. package/packages/@monomind/cli/.claude/commands/mastermind/_repeat.md +4 -0
  9. package/packages/@monomind/cli/.claude/commands/mastermind/master.md +52 -1
  10. package/packages/@monomind/cli/.claude/skills/mastermind/_repeat.md +2 -0
  11. package/packages/@monomind/cli/dist/src/__tests__/browse-analyzer.test.js +42 -59
  12. package/packages/@monomind/cli/dist/src/agents/registry-builder.d.ts +8 -0
  13. package/packages/@monomind/cli/dist/src/agents/registry-builder.js +22 -0
  14. package/packages/@monomind/cli/dist/src/browser/dashboard/server.js +18 -0
  15. package/packages/@monomind/cli/dist/src/browser/dashboard/ui.html +37 -125
  16. package/packages/@monomind/cli/dist/src/commands/agent-lifecycle.d.ts +17 -0
  17. package/packages/@monomind/cli/dist/src/commands/agent-lifecycle.js +320 -0
  18. package/packages/@monomind/cli/dist/src/commands/agent-ops.d.ts +9 -0
  19. package/packages/@monomind/cli/dist/src/commands/agent-ops.js +329 -0
  20. package/packages/@monomind/cli/dist/src/commands/agent.js +5 -907
  21. package/packages/@monomind/cli/dist/src/commands/analyze-ast.d.ts +26 -0
  22. package/packages/@monomind/cli/dist/src/commands/analyze-ast.js +284 -0
  23. package/packages/@monomind/cli/dist/src/commands/analyze-boundaries.d.ts +14 -0
  24. package/packages/@monomind/cli/dist/src/commands/analyze-boundaries.js +295 -0
  25. package/packages/@monomind/cli/dist/src/commands/analyze-diff.d.ts +8 -0
  26. package/packages/@monomind/cli/dist/src/commands/analyze-diff.js +395 -0
  27. package/packages/@monomind/cli/dist/src/commands/analyze-graph.d.ts +14 -0
  28. package/packages/@monomind/cli/dist/src/commands/analyze-graph.js +304 -0
  29. package/packages/@monomind/cli/dist/src/commands/analyze-imports.d.ts +11 -0
  30. package/packages/@monomind/cli/dist/src/commands/analyze-imports.js +287 -0
  31. package/packages/@monomind/cli/dist/src/commands/analyze-symbols.d.ts +14 -0
  32. package/packages/@monomind/cli/dist/src/commands/analyze-symbols.js +302 -0
  33. package/packages/@monomind/cli/dist/src/commands/analyze.d.ts +38 -0
  34. package/packages/@monomind/cli/dist/src/commands/analyze.js +12 -1827
  35. package/packages/@monomind/cli/dist/src/commands/doctor-env-checks.d.ts +26 -0
  36. package/packages/@monomind/cli/dist/src/commands/doctor-env-checks.js +189 -0
  37. package/packages/@monomind/cli/dist/src/commands/doctor-project-checks.d.ts +20 -0
  38. package/packages/@monomind/cli/dist/src/commands/doctor-project-checks.js +432 -0
  39. package/packages/@monomind/cli/dist/src/commands/doctor.js +54 -943
  40. package/packages/@monomind/cli/dist/src/commands/hive-mind-comms.d.ts +11 -0
  41. package/packages/@monomind/cli/dist/src/commands/hive-mind-comms.js +242 -0
  42. package/packages/@monomind/cli/dist/src/commands/hive-mind-helpers.d.ts +35 -0
  43. package/packages/@monomind/cli/dist/src/commands/hive-mind-helpers.js +203 -0
  44. package/packages/@monomind/cli/dist/src/commands/hive-mind-ops.d.ts +8 -0
  45. package/packages/@monomind/cli/dist/src/commands/hive-mind-ops.js +233 -0
  46. package/packages/@monomind/cli/dist/src/commands/hive-mind-spawn.d.ts +12 -0
  47. package/packages/@monomind/cli/dist/src/commands/hive-mind-spawn.js +274 -0
  48. package/packages/@monomind/cli/dist/src/commands/hive-mind.js +10 -1129
  49. package/packages/@monomind/cli/dist/src/commands/hooks-coverage-commands.d.ts +4 -4
  50. package/packages/@monomind/cli/dist/src/commands/hooks-coverage-commands.js +19 -819
  51. package/packages/@monomind/cli/dist/src/commands/hooks-coverage-gaps.d.ts +7 -0
  52. package/packages/@monomind/cli/dist/src/commands/hooks-coverage-gaps.js +334 -0
  53. package/packages/@monomind/cli/dist/src/commands/hooks-coverage-routing.d.ts +7 -0
  54. package/packages/@monomind/cli/dist/src/commands/hooks-coverage-routing.js +399 -0
  55. package/packages/@monomind/cli/dist/src/commands/init-subcommands.d.ts +8 -0
  56. package/packages/@monomind/cli/dist/src/commands/init-subcommands.js +156 -0
  57. package/packages/@monomind/cli/dist/src/commands/init-upgrade.d.ts +6 -0
  58. package/packages/@monomind/cli/dist/src/commands/init-upgrade.js +203 -0
  59. package/packages/@monomind/cli/dist/src/commands/init-wizard.d.ts +6 -0
  60. package/packages/@monomind/cli/dist/src/commands/init-wizard.js +246 -0
  61. package/packages/@monomind/cli/dist/src/commands/init.js +6 -623
  62. package/packages/@monomind/cli/dist/src/commands/memory-admin.d.ts +10 -0
  63. package/packages/@monomind/cli/dist/src/commands/memory-admin.js +433 -0
  64. package/packages/@monomind/cli/dist/src/commands/memory-crud.d.ts +9 -0
  65. package/packages/@monomind/cli/dist/src/commands/memory-crud.js +342 -0
  66. package/packages/@monomind/cli/dist/src/commands/memory-list.d.ts +10 -0
  67. package/packages/@monomind/cli/dist/src/commands/memory-list.js +321 -0
  68. package/packages/@monomind/cli/dist/src/commands/memory-transfer.d.ts +9 -0
  69. package/packages/@monomind/cli/dist/src/commands/memory-transfer.js +372 -0
  70. package/packages/@monomind/cli/dist/src/commands/memory.d.ts +6 -0
  71. package/packages/@monomind/cli/dist/src/commands/memory.js +10 -1441
  72. package/packages/@monomind/cli/dist/src/commands/neural-core.d.ts +8 -0
  73. package/packages/@monomind/cli/dist/src/commands/neural-core.js +274 -0
  74. package/packages/@monomind/cli/dist/src/commands/neural-optimize.d.ts +7 -0
  75. package/packages/@monomind/cli/dist/src/commands/neural-optimize.js +332 -0
  76. package/packages/@monomind/cli/dist/src/commands/neural-registry.d.ts +7 -0
  77. package/packages/@monomind/cli/dist/src/commands/neural-registry.js +290 -0
  78. package/packages/@monomind/cli/dist/src/commands/neural.js +3 -974
  79. package/packages/@monomind/cli/dist/src/commands/platforms.js +327 -7
  80. package/packages/@monomind/cli/dist/src/commands/security-cve.d.ts +6 -0
  81. package/packages/@monomind/cli/dist/src/commands/security-cve.js +310 -0
  82. package/packages/@monomind/cli/dist/src/commands/security-misc.d.ts +9 -0
  83. package/packages/@monomind/cli/dist/src/commands/security-misc.js +293 -0
  84. package/packages/@monomind/cli/dist/src/commands/security-scan.d.ts +18 -0
  85. package/packages/@monomind/cli/dist/src/commands/security-scan.js +328 -0
  86. package/packages/@monomind/cli/dist/src/commands/security.js +3 -958
  87. package/packages/@monomind/cli/dist/src/commands/session.js +1 -1
  88. package/packages/@monomind/cli/dist/src/commands/swarm.js +23 -17
  89. package/packages/@monomind/cli/dist/src/index.js +8 -37
  90. package/packages/@monomind/cli/dist/src/mcp-tools/swarm-tools.js +77 -0
  91. package/packages/@monomind/cli/dist/src/parser.js +11 -6
  92. package/packages/@monomind/cli/dist/src/routing/llm-caller.js +1 -2
  93. package/packages/@monomind/cli/package.json +2 -3
  94. package/packages/@monomind/cli/scripts/understand-analyze.mjs +1 -1
@@ -0,0 +1,203 @@
1
+ /**
2
+ * Init upgrade subcommand — update helpers without losing user data
3
+ */
4
+ import { output } from '../output.js';
5
+ import * as fs from 'fs';
6
+ import * as path from 'path';
7
+ import { executeUpgrade, executeUpgradeWithMissing, findMonomindProjects, } from '../init/index.js';
8
+ export const upgradeCommand = {
9
+ name: 'upgrade',
10
+ description: 'Update statusline and helpers while preserving existing data',
11
+ options: [
12
+ {
13
+ name: 'verbose',
14
+ short: 'v',
15
+ description: 'Show detailed output',
16
+ type: 'boolean',
17
+ default: false,
18
+ },
19
+ {
20
+ name: 'add-missing',
21
+ short: 'a',
22
+ description: 'Add any new skills, agents, and commands that are missing',
23
+ type: 'boolean',
24
+ default: false,
25
+ },
26
+ {
27
+ name: 'settings',
28
+ short: 's',
29
+ description: 'Merge new settings (Agent Teams, hooks) into existing settings.json',
30
+ type: 'boolean',
31
+ default: false,
32
+ },
33
+ {
34
+ name: 'all',
35
+ description: 'Upgrade all known monomind projects on this machine (scans ~/Desktop, ~/projects, etc.)',
36
+ type: 'boolean',
37
+ default: false,
38
+ },
39
+ ],
40
+ action: async (ctx) => {
41
+ const addMissing = (ctx.flags['add-missing'] || ctx.flags.addMissing);
42
+ const upgradeSettings = (ctx.flags.settings);
43
+ const upgradeAll = (ctx.flags.all);
44
+ if (upgradeAll) {
45
+ output.writeln();
46
+ output.writeln(output.bold('Upgrading all monomind projects'));
47
+ output.writeln(output.dim('Scanning ~/Desktop, ~/projects, ~/code… (this may take a moment)'));
48
+ output.writeln();
49
+ const projects = findMonomindProjects();
50
+ if (projects.length === 0) {
51
+ output.printInfo('No monomind projects found. Install monomind in a project first: npx monomind init');
52
+ return { success: true, exitCode: 0 };
53
+ }
54
+ output.printInfo(`Found ${projects.length} project(s). Upgrading…`);
55
+ output.writeln();
56
+ let succeeded = 0;
57
+ let failed = 0;
58
+ // Try to read control URL for dashboard progress events (best-effort)
59
+ let controlUrl = 'http://localhost:4242';
60
+ try {
61
+ const ctrlPath = path.join(process.cwd(), '.monomind', 'control.json');
62
+ if (fs.existsSync(ctrlPath) && fs.statSync(ctrlPath).size <= 4096) {
63
+ const ctrlCfg = JSON.parse(fs.readFileSync(ctrlPath, 'utf-8'));
64
+ // Only allow localhost/127.0.0.1 URLs to prevent SSRF via attacker-controlled control.json
65
+ if (typeof ctrlCfg.url === 'string' && /^https?:\/\/(localhost|127\.0\.0\.1)(:\d+)?(\/|$)/.test(ctrlCfg.url)) {
66
+ controlUrl = ctrlCfg.url;
67
+ }
68
+ }
69
+ }
70
+ catch { }
71
+ const emitUpgradeProgress = async (projDir, status, current, total) => {
72
+ try {
73
+ const { default: http } = await import('http');
74
+ const payload = JSON.stringify({ type: 'upgrade:progress', project: projDir, status, current, total, ts: Date.now() });
75
+ const url = new URL(controlUrl + '/api/mastermind/event');
76
+ const req = http.request({ hostname: url.hostname, port: parseInt(url.port || '4242'), path: url.pathname, method: 'POST', headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(payload) } });
77
+ req.write(payload);
78
+ req.end();
79
+ req.on('error', () => { });
80
+ }
81
+ catch { }
82
+ };
83
+ for (const projDir of projects) {
84
+ const projIdx = projects.indexOf(projDir) + 1;
85
+ const spinner = output.createSpinner({ text: `[${projIdx}/${projects.length}] ${projDir}` });
86
+ spinner.start();
87
+ try {
88
+ const res = addMissing
89
+ ? await executeUpgradeWithMissing(projDir, upgradeSettings)
90
+ : await executeUpgrade(projDir, upgradeSettings);
91
+ if (res.success) {
92
+ spinner.succeed(projDir + ' (' + res.updated.length + ' updated)');
93
+ succeeded++;
94
+ emitUpgradeProgress(projDir, 'success', projIdx, projects.length);
95
+ }
96
+ else {
97
+ spinner.fail(projDir + ' — ' + (res.errors[0] || 'unknown error'));
98
+ failed++;
99
+ emitUpgradeProgress(projDir, 'failed', projIdx, projects.length);
100
+ }
101
+ }
102
+ catch (e) {
103
+ spinner.fail(projDir + ' — ' + (e instanceof Error ? e.message : String(e)));
104
+ failed++;
105
+ emitUpgradeProgress(projDir, 'failed', projIdx, projects.length);
106
+ }
107
+ }
108
+ output.writeln();
109
+ output.printInfo(`Done: ${succeeded} upgraded, ${failed} failed out of ${projects.length} projects.`);
110
+ return { success: failed === 0, exitCode: failed > 0 ? 1 : 0 };
111
+ }
112
+ output.writeln();
113
+ output.writeln(output.bold('Upgrading MonoMind'));
114
+ if (addMissing && upgradeSettings) {
115
+ output.writeln(output.dim('Updates helpers, settings, and adds any missing skills/agents/commands'));
116
+ }
117
+ else if (addMissing) {
118
+ output.writeln(output.dim('Updates helpers and adds any missing skills/agents/commands'));
119
+ }
120
+ else if (upgradeSettings) {
121
+ output.writeln(output.dim('Updates helpers and merges new settings (Agent Teams, hooks)'));
122
+ }
123
+ else {
124
+ output.writeln(output.dim('Updates helpers while preserving your existing data'));
125
+ }
126
+ output.writeln();
127
+ const spinnerText = upgradeSettings
128
+ ? 'Upgrading helpers and settings...'
129
+ : (addMissing ? 'Upgrading and adding missing assets...' : 'Upgrading...');
130
+ const spinner = output.createSpinner({ text: spinnerText });
131
+ spinner.start();
132
+ try {
133
+ const result = addMissing
134
+ ? await executeUpgradeWithMissing(ctx.cwd, upgradeSettings)
135
+ : await executeUpgrade(ctx.cwd, upgradeSettings);
136
+ if (!result.success) {
137
+ spinner.fail('Upgrade failed');
138
+ for (const error of result.errors) {
139
+ output.printError(error);
140
+ }
141
+ return { success: false, exitCode: 1 };
142
+ }
143
+ spinner.succeed('Upgrade complete!');
144
+ output.writeln();
145
+ if (result.updated.length > 0) {
146
+ output.printBox(result.updated.map(f => `✓ ${f}`).join('\n'), 'Updated (latest version)');
147
+ output.writeln();
148
+ }
149
+ if (result.created.length > 0) {
150
+ output.printBox(result.created.map(f => `+ ${f}`).join('\n'), 'Created (new files)');
151
+ output.writeln();
152
+ }
153
+ if (result.preserved.length > 0 && ctx.flags.verbose) {
154
+ output.printBox(result.preserved.map(f => `• ${f}`).join('\n'), 'Preserved (existing data kept)');
155
+ output.writeln();
156
+ }
157
+ else if (result.preserved.length > 0) {
158
+ output.printInfo(`Preserved ${result.preserved.length} existing data files`);
159
+ output.writeln();
160
+ }
161
+ if (result.addedSkills && result.addedSkills.length > 0) {
162
+ output.printBox(result.addedSkills.map(s => `+ ${s}`).join('\n'), `Added Skills (${result.addedSkills.length} new)`);
163
+ output.writeln();
164
+ }
165
+ if (result.addedAgents && result.addedAgents.length > 0) {
166
+ output.printBox(result.addedAgents.map(a => `+ ${a}`).join('\n'), `Added Agents (${result.addedAgents.length} new)`);
167
+ output.writeln();
168
+ }
169
+ if (result.addedCommands && result.addedCommands.length > 0) {
170
+ output.printBox(result.addedCommands.map(c => `+ ${c}`).join('\n'), `Added Commands (${result.addedCommands.length} new)`);
171
+ output.writeln();
172
+ }
173
+ if (result.settingsUpdated && result.settingsUpdated.length > 0) {
174
+ output.printBox(result.settingsUpdated.map(s => `+ ${s}`).join('\n'), 'Settings Updated');
175
+ output.writeln();
176
+ }
177
+ output.printSuccess('Your statusline helper has been updated to the latest version');
178
+ output.printInfo('Existing metrics and learning data were preserved');
179
+ if (upgradeSettings && result.settingsUpdated && result.settingsUpdated.length > 0) {
180
+ output.printSuccess('Settings.json updated with new Agent Teams configuration');
181
+ }
182
+ if (addMissing) {
183
+ const totalAdded = (result.addedSkills?.length || 0) + (result.addedAgents?.length || 0) + (result.addedCommands?.length || 0);
184
+ if (totalAdded > 0) {
185
+ output.printSuccess(`Added ${totalAdded} missing assets to your project`);
186
+ }
187
+ else {
188
+ output.printInfo('All skills, agents, and commands are already up to date');
189
+ }
190
+ }
191
+ if (ctx.flags.format === 'json') {
192
+ output.printJson(result);
193
+ }
194
+ return { success: true, data: result };
195
+ }
196
+ catch (error) {
197
+ spinner.fail('Upgrade failed');
198
+ output.printError(`Failed to upgrade: ${error instanceof Error ? error.message : String(error)}`);
199
+ return { success: false, exitCode: 1 };
200
+ }
201
+ },
202
+ };
203
+ //# sourceMappingURL=init-upgrade.js.map
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Init wizard subcommand — interactive setup
3
+ */
4
+ import type { Command } from '../types.js';
5
+ export declare const wizardCommand: Command;
6
+ //# sourceMappingURL=init-wizard.d.ts.map
@@ -0,0 +1,246 @@
1
+ /**
2
+ * Init wizard subcommand — interactive setup
3
+ */
4
+ import { output } from '../output.js';
5
+ import { confirm, select, multiSelect, input } from '../prompt.js';
6
+ import { executeInit, DEFAULT_INIT_OPTIONS, MINIMAL_INIT_OPTIONS, FULL_INIT_OPTIONS, } from '../init/index.js';
7
+ export const wizardCommand = {
8
+ name: 'wizard',
9
+ description: 'Interactive setup wizard for comprehensive configuration',
10
+ action: async (ctx) => {
11
+ output.writeln();
12
+ output.writeln(output.bold('Monomind Setup Wizard'));
13
+ output.writeln(output.dim('Answer questions to configure your project'));
14
+ output.writeln();
15
+ try {
16
+ const options = { ...DEFAULT_INIT_OPTIONS, targetDir: ctx.cwd };
17
+ const preset = await select({
18
+ message: 'Select configuration preset:',
19
+ options: [
20
+ { value: 'default', label: 'Default', hint: 'Recommended settings for most projects' },
21
+ { value: 'minimal', label: 'Minimal', hint: 'Core features only' },
22
+ { value: 'full', label: 'Full', hint: 'All features enabled' },
23
+ { value: 'custom', label: 'Custom', hint: 'Choose each component' },
24
+ ],
25
+ });
26
+ if (preset === 'minimal') {
27
+ Object.assign(options, MINIMAL_INIT_OPTIONS);
28
+ options.targetDir = ctx.cwd;
29
+ }
30
+ else if (preset === 'full') {
31
+ Object.assign(options, FULL_INIT_OPTIONS);
32
+ options.targetDir = ctx.cwd;
33
+ }
34
+ else if (preset === 'custom') {
35
+ const components = await multiSelect({
36
+ message: 'Select components to initialize:',
37
+ options: [
38
+ { value: 'claudeMd', label: 'CLAUDE.md', hint: 'Swarm guidance and project configuration', selected: true },
39
+ { value: 'settings', label: 'settings.json', hint: 'Claude Code hooks configuration', selected: true },
40
+ { value: 'skills', label: 'Skills', hint: 'Claude Code skills in .claude/skills/', selected: true },
41
+ { value: 'commands', label: 'Commands', hint: 'Claude Code commands in .claude/commands/', selected: true },
42
+ { value: 'agents', label: 'Agents', hint: 'Agent definitions in .claude/agents/', selected: true },
43
+ { value: 'helpers', label: 'Helpers', hint: 'Utility scripts in .claude/helpers/', selected: true },
44
+ { value: 'statusline', label: 'Statusline', hint: 'Shell statusline integration', selected: false },
45
+ { value: 'mcp', label: 'MCP', hint: '.mcp.json for MCP server configuration', selected: true },
46
+ { value: 'runtime', label: 'Runtime', hint: '.monomind/ directory for v1 runtime', selected: true },
47
+ ],
48
+ });
49
+ options.components.claudeMd = components.includes('claudeMd');
50
+ options.components.settings = components.includes('settings');
51
+ options.components.skills = components.includes('skills');
52
+ options.components.commands = components.includes('commands');
53
+ options.components.agents = components.includes('agents');
54
+ options.components.helpers = components.includes('helpers');
55
+ options.components.statusline = components.includes('statusline');
56
+ options.components.mcp = components.includes('mcp');
57
+ options.components.runtime = components.includes('runtime');
58
+ if (options.components.skills) {
59
+ const skillSets = await multiSelect({
60
+ message: 'Select skill sets:',
61
+ options: [
62
+ { value: 'core', label: 'Core', hint: 'Swarm, memory, SPARC skills', selected: true },
63
+ { value: 'memory', label: 'Memory (LanceDB)', hint: 'Vector database skills', selected: true },
64
+ { value: 'github', label: 'GitHub', hint: 'GitHub integration skills', selected: true },
65
+ ],
66
+ });
67
+ options.skills.core = skillSets.includes('core');
68
+ options.skills.memory = skillSets.includes('memory');
69
+ options.skills.github = skillSets.includes('github');
70
+ }
71
+ if (options.components.settings) {
72
+ const hooks = await multiSelect({
73
+ message: 'Select hooks to enable:',
74
+ options: [
75
+ { value: 'preToolUse', label: 'PreToolUse', hint: 'Before tool execution', selected: true },
76
+ { value: 'postToolUse', label: 'PostToolUse', hint: 'After tool execution', selected: true },
77
+ { value: 'userPromptSubmit', label: 'UserPromptSubmit', hint: 'Task routing', selected: true },
78
+ { value: 'sessionStart', label: 'SessionStart', hint: 'Session initialization', selected: true },
79
+ { value: 'stop', label: 'Stop', hint: 'Task completion evaluation', selected: true },
80
+ { value: 'notification', label: 'Notification', hint: 'Swarm notifications', selected: true },
81
+ { value: 'permissionRequest', label: 'PermissionRequest', hint: 'Auto-allow monomind tools', selected: true },
82
+ ],
83
+ });
84
+ options.hooks.preToolUse = hooks.includes('preToolUse');
85
+ options.hooks.postToolUse = hooks.includes('postToolUse');
86
+ options.hooks.userPromptSubmit = hooks.includes('userPromptSubmit');
87
+ options.hooks.sessionStart = hooks.includes('sessionStart');
88
+ options.hooks.stop = hooks.includes('stop');
89
+ options.hooks.notification = hooks.includes('notification');
90
+ }
91
+ }
92
+ const topology = await select({
93
+ message: 'Select swarm topology:',
94
+ options: [
95
+ { value: 'hierarchical-mesh', label: 'Hierarchical Mesh', hint: 'Best for complex projects (recommended)' },
96
+ { value: 'mesh', label: 'Mesh', hint: 'Peer-to-peer coordination' },
97
+ { value: 'hierarchical', label: 'Hierarchical', hint: 'Tree-based coordination' },
98
+ { value: 'adaptive', label: 'Adaptive', hint: 'Dynamic topology switching' },
99
+ ],
100
+ });
101
+ options.runtime.topology = topology;
102
+ const maxAgents = await input({
103
+ message: 'Maximum concurrent agents:',
104
+ default: String(options.runtime.maxAgents),
105
+ validate: (v) => {
106
+ const n = parseInt(v);
107
+ return (!isNaN(n) && n > 0 && n <= 50) || 'Enter a number between 1 and 50';
108
+ },
109
+ });
110
+ options.runtime.maxAgents = parseInt(maxAgents);
111
+ const memoryBackend = await select({
112
+ message: 'Select memory backend:',
113
+ options: [
114
+ { value: 'hybrid', label: 'Hybrid', hint: 'SQLite + LanceDB (recommended)' },
115
+ { value: 'lancedb', label: 'LanceDB', hint: '150x faster vector search' },
116
+ { value: 'sqlite', label: 'SQLite', hint: 'Standard SQL storage' },
117
+ { value: 'memory', label: 'In-Memory', hint: 'Fast but non-persistent' },
118
+ ],
119
+ });
120
+ options.runtime.memoryBackend = memoryBackend;
121
+ if (memoryBackend === 'lancedb' || memoryBackend === 'hybrid') {
122
+ const enableHNSW = await confirm({
123
+ message: 'Enable HNSW indexing for faster vector search?',
124
+ default: true,
125
+ });
126
+ options.runtime.enableHNSW = enableHNSW;
127
+ }
128
+ const enableNeural = await confirm({
129
+ message: 'Enable neural pattern learning?',
130
+ default: options.runtime.enableNeural,
131
+ });
132
+ options.runtime.enableNeural = enableNeural;
133
+ if (memoryBackend === 'lancedb' || memoryBackend === 'hybrid') {
134
+ const enableSelfLearning = await confirm({
135
+ message: 'Enable self-learning memory? (LearningBridge + Knowledge Graph + Agent Scopes)',
136
+ default: true,
137
+ });
138
+ options.runtime.enableLearningBridge = enableSelfLearning && enableNeural;
139
+ options.runtime.enableMemoryGraph = enableSelfLearning;
140
+ options.runtime.enableAgentScopes = enableSelfLearning;
141
+ }
142
+ else {
143
+ options.runtime.enableLearningBridge = false;
144
+ options.runtime.enableMemoryGraph = false;
145
+ options.runtime.enableAgentScopes = false;
146
+ }
147
+ const enableEmbeddings = await confirm({
148
+ message: 'Enable ONNX embedding system with hyperbolic support?',
149
+ default: true,
150
+ });
151
+ let embeddingModel = 'Xenova/all-MiniLM-L6-v2';
152
+ if (enableEmbeddings) {
153
+ embeddingModel = await select({
154
+ message: 'Select embedding model:',
155
+ options: [
156
+ { value: 'Xenova/all-MiniLM-L6-v2', label: 'MiniLM L6 (384d)', hint: 'Fast, good quality (recommended)' },
157
+ { value: 'Xenova/all-mpnet-base-v2', label: 'MPNet Base (768d)', hint: 'Higher quality, more memory' },
158
+ ],
159
+ });
160
+ }
161
+ output.writeln();
162
+ const spinner = output.createSpinner({ text: 'Initializing...' });
163
+ spinner.start();
164
+ const result = await executeInit(options);
165
+ if (!result.success) {
166
+ spinner.fail('Initialization failed');
167
+ for (const error of result.errors) {
168
+ output.printError(error);
169
+ }
170
+ return { success: false, exitCode: 1 };
171
+ }
172
+ spinner.succeed('Setup complete!');
173
+ let embeddingsInitialized = false;
174
+ if (enableEmbeddings) {
175
+ output.writeln();
176
+ output.printInfo('Initializing ONNX embedding subsystem...');
177
+ const ALLOWED_MODELS = /^[\w\-./]+$/;
178
+ if (!ALLOWED_MODELS.test(embeddingModel)) {
179
+ output.writeln(output.error('Invalid model identifier. Only alphanumeric characters, hyphens, dots, and slashes are allowed.'));
180
+ return { success: false, exitCode: 1 };
181
+ }
182
+ const { execFileSync } = await import('child_process');
183
+ try {
184
+ execFileSync(process.platform === 'win32' ? 'npx.cmd' : 'npx', ['@monomind/cli@latest', 'embeddings', 'init', '--model', embeddingModel, '--no-download', '--force'], {
185
+ stdio: 'pipe',
186
+ cwd: ctx.cwd,
187
+ timeout: 30000
188
+ });
189
+ output.writeln(output.success(' ✓ Embeddings configured'));
190
+ embeddingsInitialized = true;
191
+ }
192
+ catch {
193
+ output.writeln(output.dim(' Embeddings will be configured on first use'));
194
+ }
195
+ }
196
+ const enableGates = await confirm({
197
+ message: 'Enable enforcement gates? (blocks destructive commands + secrets in writes)',
198
+ default: true,
199
+ });
200
+ let gatesEnabled = false;
201
+ if (enableGates) {
202
+ try {
203
+ const { execFileSync } = await import('child_process');
204
+ execFileSync(process.platform === 'win32' ? 'npx.cmd' : 'npx', ['@monomind/cli@latest', 'guidance', 'setup', '--project-dir', ctx.cwd], { stdio: 'pipe', cwd: ctx.cwd, timeout: 10000 });
205
+ gatesEnabled = true;
206
+ output.writeln(output.success(' ✓ Enforcement gates wired'));
207
+ }
208
+ catch {
209
+ output.writeln(output.dim(' Gates setup skipped (run `monomind guidance setup` manually)'));
210
+ }
211
+ }
212
+ output.writeln();
213
+ output.printTable({
214
+ columns: [
215
+ { key: 'setting', header: 'Setting', width: 20 },
216
+ { key: 'value', header: 'Value', width: 40 },
217
+ ],
218
+ data: [
219
+ { setting: 'Preset', value: preset },
220
+ { setting: 'Topology', value: options.runtime.topology },
221
+ { setting: 'Max Agents', value: String(options.runtime.maxAgents) },
222
+ { setting: 'Memory Backend', value: options.runtime.memoryBackend },
223
+ { setting: 'HNSW Indexing', value: options.runtime.enableHNSW ? 'Enabled' : 'Disabled' },
224
+ { setting: 'Neural Learning', value: options.runtime.enableNeural ? 'Enabled' : 'Disabled' },
225
+ { setting: 'Self-Learning', value: options.runtime.enableLearningBridge ? 'LearningBridge + Graph + Scopes' : 'Disabled' },
226
+ { setting: 'Embeddings', value: enableEmbeddings ? `${embeddingModel} (hyperbolic)` : 'Disabled' },
227
+ { setting: 'Skills', value: `${result.summary.skillsCount} installed` },
228
+ { setting: 'Commands', value: `${result.summary.commandsCount} installed` },
229
+ { setting: 'Agents', value: `${result.summary.agentsCount} installed` },
230
+ { setting: 'Hooks', value: `${result.summary.hooksEnabled} enabled` },
231
+ { setting: 'Enforcement Gates', value: gatesEnabled ? 'Enabled' : 'Disabled' },
232
+ ],
233
+ });
234
+ void embeddingsInitialized;
235
+ return { success: true, data: result };
236
+ }
237
+ catch (error) {
238
+ if (error instanceof Error && error.message === 'User cancelled') {
239
+ output.printInfo('Setup cancelled');
240
+ return { success: true };
241
+ }
242
+ throw error;
243
+ }
244
+ },
245
+ };
246
+ //# sourceMappingURL=init-wizard.js.map