monomind 1.16.11 → 1.17.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.
Files changed (148) hide show
  1. package/.claude/agents/engineering/engineering-security-engineer.md +1 -1
  2. package/.claude/agents/github/code-review-swarm.md +19 -19
  3. package/.claude/agents/github/github-modes.md +4 -4
  4. package/.claude/agents/github/multi-repo-swarm.md +24 -24
  5. package/.claude/agents/github/project-board-sync.md +28 -28
  6. package/.claude/agents/github/swarm-issue.md +26 -26
  7. package/.claude/agents/github/swarm-pr.md +18 -18
  8. package/.claude/agents/github/workflow-automation.md +27 -27
  9. package/.claude/agents/reengineer-squad/git-manager.md +2 -2
  10. package/.claude/commands/mastermind/_repeat.md +4 -0
  11. package/.claude/commands/mastermind/master.md +61 -4
  12. package/.claude/commands/mastermind/references/antigravity-tools.md +60 -0
  13. package/.claude/commands/mastermind/references/claude-code-tools.md +50 -0
  14. package/.claude/commands/mastermind/references/codex-tools.md +64 -0
  15. package/.claude/commands/mastermind/references/copilot-tools.md +49 -0
  16. package/.claude/commands/mastermind/references/gemini-tools.md +63 -0
  17. package/.claude/commands/mastermind/references/pi-tools.md +28 -0
  18. package/.claude/helpers/mastermind-activate.cjs +53 -0
  19. package/.claude/scheduled_tasks.lock +1 -1
  20. package/.claude/settings.json +4 -0
  21. package/.claude/skills/mastermind/_repeat.md +2 -0
  22. package/.claude/skills/mastermind/runorg.md +14 -0
  23. package/.claude/skills/mastermind/techport.md +5 -5
  24. package/README.md +1 -1
  25. package/package.json +6 -5
  26. package/packages/@monomind/cli/.claude/agents/engineering/engineering-security-engineer.md +1 -1
  27. package/packages/@monomind/cli/.claude/agents/github/code-review-swarm.md +19 -19
  28. package/packages/@monomind/cli/.claude/agents/github/github-modes.md +4 -4
  29. package/packages/@monomind/cli/.claude/agents/github/multi-repo-swarm.md +24 -24
  30. package/packages/@monomind/cli/.claude/agents/github/project-board-sync.md +28 -28
  31. package/packages/@monomind/cli/.claude/agents/github/swarm-issue.md +26 -26
  32. package/packages/@monomind/cli/.claude/agents/github/swarm-pr.md +18 -18
  33. package/packages/@monomind/cli/.claude/agents/github/workflow-automation.md +27 -27
  34. package/packages/@monomind/cli/.claude/agents/reengineer-squad/git-manager.md +2 -2
  35. package/packages/@monomind/cli/.claude/commands/mastermind/_repeat.md +4 -0
  36. package/packages/@monomind/cli/.claude/commands/mastermind/master.md +61 -4
  37. package/packages/@monomind/cli/.claude/commands/mastermind/references/antigravity-tools.md +60 -0
  38. package/packages/@monomind/cli/.claude/commands/mastermind/references/claude-code-tools.md +50 -0
  39. package/packages/@monomind/cli/.claude/commands/mastermind/references/codex-tools.md +64 -0
  40. package/packages/@monomind/cli/.claude/commands/mastermind/references/copilot-tools.md +49 -0
  41. package/packages/@monomind/cli/.claude/commands/mastermind/references/gemini-tools.md +63 -0
  42. package/packages/@monomind/cli/.claude/commands/mastermind/references/pi-tools.md +28 -0
  43. package/packages/@monomind/cli/.claude/helpers/mastermind-activate.cjs +53 -0
  44. package/packages/@monomind/cli/.claude/skills/mastermind/_repeat.md +2 -0
  45. package/packages/@monomind/cli/.claude/skills/mastermind/runorg.md +14 -0
  46. package/packages/@monomind/cli/.claude/skills/mastermind/techport.md +5 -5
  47. package/packages/@monomind/cli/README.md +1 -1
  48. package/packages/@monomind/cli/dist/src/__tests__/browse-analyzer.test.js +42 -59
  49. package/packages/@monomind/cli/dist/src/browser/dashboard/server.js +18 -0
  50. package/packages/@monomind/cli/dist/src/commands/agent-lifecycle.d.ts +17 -0
  51. package/packages/@monomind/cli/dist/src/commands/agent-lifecycle.js +320 -0
  52. package/packages/@monomind/cli/dist/src/commands/agent-ops.d.ts +9 -0
  53. package/packages/@monomind/cli/dist/src/commands/agent-ops.js +329 -0
  54. package/packages/@monomind/cli/dist/src/commands/agent.js +5 -907
  55. package/packages/@monomind/cli/dist/src/commands/analyze-ast.d.ts +26 -0
  56. package/packages/@monomind/cli/dist/src/commands/analyze-ast.js +284 -0
  57. package/packages/@monomind/cli/dist/src/commands/analyze-boundaries.d.ts +14 -0
  58. package/packages/@monomind/cli/dist/src/commands/analyze-boundaries.js +295 -0
  59. package/packages/@monomind/cli/dist/src/commands/analyze-diff.d.ts +8 -0
  60. package/packages/@monomind/cli/dist/src/commands/analyze-diff.js +395 -0
  61. package/packages/@monomind/cli/dist/src/commands/analyze-graph.d.ts +14 -0
  62. package/packages/@monomind/cli/dist/src/commands/analyze-graph.js +304 -0
  63. package/packages/@monomind/cli/dist/src/commands/analyze-imports.d.ts +11 -0
  64. package/packages/@monomind/cli/dist/src/commands/analyze-imports.js +287 -0
  65. package/packages/@monomind/cli/dist/src/commands/analyze-symbols.d.ts +14 -0
  66. package/packages/@monomind/cli/dist/src/commands/analyze-symbols.js +302 -0
  67. package/packages/@monomind/cli/dist/src/commands/analyze.d.ts +38 -0
  68. package/packages/@monomind/cli/dist/src/commands/analyze.js +12 -1827
  69. package/packages/@monomind/cli/dist/src/commands/doctor-env-checks.d.ts +26 -0
  70. package/packages/@monomind/cli/dist/src/commands/doctor-env-checks.js +189 -0
  71. package/packages/@monomind/cli/dist/src/commands/doctor-project-checks.d.ts +19 -0
  72. package/packages/@monomind/cli/dist/src/commands/doctor-project-checks.js +388 -0
  73. package/packages/@monomind/cli/dist/src/commands/doctor.js +51 -942
  74. package/packages/@monomind/cli/dist/src/commands/hive-mind-comms.d.ts +11 -0
  75. package/packages/@monomind/cli/dist/src/commands/hive-mind-comms.js +242 -0
  76. package/packages/@monomind/cli/dist/src/commands/hive-mind-helpers.d.ts +35 -0
  77. package/packages/@monomind/cli/dist/src/commands/hive-mind-helpers.js +203 -0
  78. package/packages/@monomind/cli/dist/src/commands/hive-mind-ops.d.ts +8 -0
  79. package/packages/@monomind/cli/dist/src/commands/hive-mind-ops.js +233 -0
  80. package/packages/@monomind/cli/dist/src/commands/hive-mind-spawn.d.ts +12 -0
  81. package/packages/@monomind/cli/dist/src/commands/hive-mind-spawn.js +274 -0
  82. package/packages/@monomind/cli/dist/src/commands/hive-mind.js +10 -1129
  83. package/packages/@monomind/cli/dist/src/commands/hooks-coverage-commands.d.ts +4 -4
  84. package/packages/@monomind/cli/dist/src/commands/hooks-coverage-commands.js +19 -819
  85. package/packages/@monomind/cli/dist/src/commands/hooks-coverage-gaps.d.ts +7 -0
  86. package/packages/@monomind/cli/dist/src/commands/hooks-coverage-gaps.js +334 -0
  87. package/packages/@monomind/cli/dist/src/commands/hooks-coverage-routing.d.ts +7 -0
  88. package/packages/@monomind/cli/dist/src/commands/hooks-coverage-routing.js +399 -0
  89. package/packages/@monomind/cli/dist/src/commands/index.js +0 -2
  90. package/packages/@monomind/cli/dist/src/commands/init-subcommands.d.ts +8 -0
  91. package/packages/@monomind/cli/dist/src/commands/init-subcommands.js +156 -0
  92. package/packages/@monomind/cli/dist/src/commands/init-upgrade.d.ts +6 -0
  93. package/packages/@monomind/cli/dist/src/commands/init-upgrade.js +203 -0
  94. package/packages/@monomind/cli/dist/src/commands/init-wizard.d.ts +6 -0
  95. package/packages/@monomind/cli/dist/src/commands/init-wizard.js +246 -0
  96. package/packages/@monomind/cli/dist/src/commands/init.js +6 -623
  97. package/packages/@monomind/cli/dist/src/commands/memory-admin.d.ts +10 -0
  98. package/packages/@monomind/cli/dist/src/commands/memory-admin.js +433 -0
  99. package/packages/@monomind/cli/dist/src/commands/memory-crud.d.ts +9 -0
  100. package/packages/@monomind/cli/dist/src/commands/memory-crud.js +342 -0
  101. package/packages/@monomind/cli/dist/src/commands/memory-list.d.ts +10 -0
  102. package/packages/@monomind/cli/dist/src/commands/memory-list.js +321 -0
  103. package/packages/@monomind/cli/dist/src/commands/memory-transfer.d.ts +9 -0
  104. package/packages/@monomind/cli/dist/src/commands/memory-transfer.js +372 -0
  105. package/packages/@monomind/cli/dist/src/commands/memory.d.ts +6 -0
  106. package/packages/@monomind/cli/dist/src/commands/memory.js +10 -1441
  107. package/packages/@monomind/cli/dist/src/commands/neural-core.d.ts +8 -0
  108. package/packages/@monomind/cli/dist/src/commands/neural-core.js +274 -0
  109. package/packages/@monomind/cli/dist/src/commands/neural-optimize.d.ts +7 -0
  110. package/packages/@monomind/cli/dist/src/commands/neural-optimize.js +332 -0
  111. package/packages/@monomind/cli/dist/src/commands/neural-registry.d.ts +7 -0
  112. package/packages/@monomind/cli/dist/src/commands/neural-registry.js +290 -0
  113. package/packages/@monomind/cli/dist/src/commands/neural.js +3 -974
  114. package/packages/@monomind/cli/dist/src/commands/platforms.js +327 -7
  115. package/packages/@monomind/cli/dist/src/commands/security-cve.d.ts +6 -0
  116. package/packages/@monomind/cli/dist/src/commands/security-cve.js +310 -0
  117. package/packages/@monomind/cli/dist/src/commands/security-misc.d.ts +9 -0
  118. package/packages/@monomind/cli/dist/src/commands/security-misc.js +293 -0
  119. package/packages/@monomind/cli/dist/src/commands/security-scan.d.ts +18 -0
  120. package/packages/@monomind/cli/dist/src/commands/security-scan.js +328 -0
  121. package/packages/@monomind/cli/dist/src/commands/security.js +3 -958
  122. package/packages/@monomind/cli/dist/src/commands/session.js +1 -1
  123. package/packages/@monomind/cli/dist/src/commands/swarm.js +23 -17
  124. package/packages/@monomind/cli/dist/src/init/executor.js +0 -24
  125. package/packages/@monomind/cli/dist/src/init/statusline-generator.js +0 -45
  126. package/packages/@monomind/cli/dist/src/init/types.d.ts +0 -2
  127. package/packages/@monomind/cli/dist/src/init/types.js +0 -2
  128. package/packages/@monomind/cli/dist/src/mcp-tools/swarm-tools.js +77 -0
  129. package/packages/@monomind/cli/dist/src/parser.js +11 -6
  130. package/packages/@monomind/cli/dist/src/routing/llm-caller.js +1 -2
  131. package/packages/@monomind/cli/dist/src/ui/dashboard.html +82 -75
  132. package/packages/@monomind/cli/dist/src/ui/server.mjs +41 -4
  133. package/packages/@monomind/cli/package.json +3 -4
  134. package/packages/@monomind/cli/scripts/understand-analyze.mjs +1 -1
  135. package/packages/@monomind/guidance/README.md +0 -1
  136. package/packages/@monomind/guidance/package.json +2 -14
  137. package/scripts/verify-appliance.sh +16 -20
  138. package/.claude-plugin/README.md +0 -704
  139. package/.claude-plugin/docs/INSTALLATION.md +0 -258
  140. package/.claude-plugin/docs/PLUGIN_SUMMARY.md +0 -358
  141. package/.claude-plugin/docs/QUICKSTART.md +0 -357
  142. package/.claude-plugin/docs/STRUCTURE.md +0 -122
  143. package/.claude-plugin/hooks/hooks.json +0 -74
  144. package/.claude-plugin/marketplace.json +0 -98
  145. package/.claude-plugin/plugin.json +0 -70
  146. package/.claude-plugin/scripts/install.sh +0 -234
  147. package/.claude-plugin/scripts/uninstall.sh +0 -36
  148. package/.claude-plugin/scripts/verify.sh +0 -102
@@ -1,85 +1,68 @@
1
1
  import { describe, it, expect, vi, beforeEach } from 'vitest';
2
- // Shared mock instance so tests can override `create` per-test
3
- const mockCreate = vi.fn().mockResolvedValue({
4
- content: [{
5
- type: 'text',
6
- text: JSON.stringify({
7
- id: 'linkedin:comment_post',
8
- platform: 'linkedin',
9
- name: 'Comment on Post',
10
- params: ['post_url', 'text'],
11
- steps: [
12
- { type: 'navigate', url: '{{params.post_url}}' },
13
- { type: 'find', selectors: ['.comment-box'], as: 'box' },
14
- { type: 'click', target: '{{box}}' },
15
- { type: 'type', target: '{{box}}', text: '{{params.text}}', humanDelay: true },
16
- { type: 'wait', condition: 'network_idle', timeout: 3000 },
17
- ],
18
- }),
19
- }],
2
+ import { EventEmitter } from 'events';
3
+ // Mock child_process.spawn so tests don't invoke the real claude CLI
4
+ vi.mock('child_process', async (importOriginal) => {
5
+ const actual = await importOriginal();
6
+ return { ...actual, spawn: vi.fn() };
20
7
  });
21
- // Mock Anthropic SDK before importing analyzer
22
- vi.mock('@anthropic-ai/sdk', () => {
23
- const MockAnthropic = vi.fn(function () {
24
- this.messages = { create: mockCreate };
8
+ async function makeSpawnMock(stdout, exitCode = 0) {
9
+ const { spawn } = vi.mocked(await import('child_process'));
10
+ spawn.mockImplementationOnce(() => {
11
+ const proc = new EventEmitter();
12
+ proc.stdout = new EventEmitter();
13
+ proc.stderr = new EventEmitter();
14
+ proc.kill = vi.fn();
15
+ setTimeout(() => {
16
+ proc.stdout.emit('data', Buffer.from(stdout));
17
+ proc.emit('close', exitCode);
18
+ }, 0);
19
+ return proc;
25
20
  });
26
- return { default: MockAnthropic };
27
- });
21
+ }
22
+ const VALID_ACTION_DEF = {
23
+ id: 'linkedin:comment_post',
24
+ platform: 'linkedin',
25
+ name: 'Comment on Post',
26
+ params: ['post_url', 'text'],
27
+ steps: [
28
+ { type: 'navigate', url: '{{params.post_url}}' },
29
+ { type: 'find', selectors: ['.comment-box'], as: 'box' },
30
+ { type: 'click', target: '{{box}}' },
31
+ { type: 'type', target: '{{box}}', text: '{{params.text}}', humanDelay: true },
32
+ { type: 'wait', condition: 'network_idle', timeout: 3000 },
33
+ ],
34
+ };
28
35
  function mockPage(url = 'https://linkedin.com/feed', title = 'LinkedIn') {
29
36
  return {
30
37
  url: vi.fn().mockResolvedValue(url),
31
38
  evaluate: vi.fn().mockImplementation((expr) => {
32
39
  if (expr === 'document.title')
33
40
  return Promise.resolve(title);
34
- return Promise.resolve('[]'); // empty elements for DOM capture
41
+ return Promise.resolve('[]');
35
42
  }),
36
43
  };
37
44
  }
38
45
  describe('analyzePageForAction', () => {
39
46
  let analyzePageForAction;
40
47
  beforeEach(async () => {
41
- mockCreate.mockResolvedValue({
42
- content: [{
43
- type: 'text',
44
- text: JSON.stringify({
45
- id: 'linkedin:comment_post',
46
- platform: 'linkedin',
47
- name: 'Comment on Post',
48
- params: ['post_url', 'text'],
49
- steps: [
50
- { type: 'navigate', url: '{{params.post_url}}' },
51
- { type: 'find', selectors: ['.comment-box'], as: 'box' },
52
- { type: 'click', target: '{{box}}' },
53
- { type: 'type', target: '{{box}}', text: '{{params.text}}', humanDelay: true },
54
- { type: 'wait', condition: 'network_idle', timeout: 3000 },
55
- ],
56
- }),
57
- }],
58
- });
48
+ vi.resetModules();
59
49
  const mod = await import('@monoes/monobrowse');
60
50
  analyzePageForAction = mod.analyzePageForAction;
61
- });
62
- it('returns a valid ActionDef from mocked Claude response', async () => {
63
- const page = mockPage();
64
- // Pass a dummy key via options (Anthropic SDK is mocked no real call is made)
65
- const result = await analyzePageForAction(page, 'comment on a LinkedIn post', { apiKey: 'sk-test' });
51
+ }, 20000); // monolean: re-importing the workspace package can exceed the 10s default under full-suite parallel load
52
+ it('returns a valid ActionDef from mocked claude --print response', async () => {
53
+ await makeSpawnMock(JSON.stringify(VALID_ACTION_DEF));
54
+ const result = await analyzePageForAction(mockPage(), 'comment on a LinkedIn post');
66
55
  expect(result.id).toBe('linkedin:comment_post');
67
56
  expect(result.steps).toHaveLength(5);
68
57
  expect(result.params).toContain('text');
69
58
  });
70
- it('throws on invalid JSON from Claude', async () => {
71
- mockCreate.mockResolvedValueOnce({
72
- content: [{ type: 'text', text: 'not json at all' }],
73
- });
74
- const page = mockPage();
75
- await expect(analyzePageForAction(page, 'test', { apiKey: 'sk-test' })).rejects.toThrow('invalid JSON');
59
+ it('throws on invalid JSON from claude', async () => {
60
+ await makeSpawnMock('not json at all');
61
+ await expect(analyzePageForAction(mockPage(), 'test')).rejects.toThrow('invalid JSON');
76
62
  });
77
63
  it('throws when ActionDef is missing id', async () => {
78
- mockCreate.mockResolvedValueOnce({
79
- content: [{ type: 'text', text: JSON.stringify({ steps: [] }) }],
80
- });
81
- const page = mockPage();
82
- await expect(analyzePageForAction(page, 'test', { apiKey: 'sk-test' })).rejects.toThrow('invalid ActionDef');
64
+ await makeSpawnMock(JSON.stringify({ steps: [] }));
65
+ await expect(analyzePageForAction(mockPage(), 'test')).rejects.toThrow('invalid ActionDef');
83
66
  });
84
67
  });
85
68
  //# sourceMappingURL=browse-analyzer.test.js.map
@@ -30,6 +30,24 @@ export function getDashboardServer(port = DEFAULT_PORT) {
30
30
  res.end(JSON.stringify(recentRuns));
31
31
  return;
32
32
  }
33
+ if (req.method === 'POST' && req.url === '/api/mastermind/event') {
34
+ const chunks = [];
35
+ req.on('data', (chunk) => chunks.push(chunk));
36
+ req.on('end', () => {
37
+ try {
38
+ const body = Buffer.concat(chunks).toString('utf8');
39
+ JSON.parse(body); // validate before broadcast
40
+ for (const client of clients) {
41
+ if (client.readyState === client.OPEN)
42
+ client.send(body);
43
+ }
44
+ }
45
+ catch { }
46
+ res.writeHead(200, { 'Content-Type': 'application/json' });
47
+ res.end('{"ok":true}');
48
+ });
49
+ return;
50
+ }
33
51
  res.writeHead(404);
34
52
  res.end();
35
53
  });
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Agent lifecycle commands — spawn, list, status, stop
3
+ */
4
+ import type { Command } from '../types.js';
5
+ export declare function updateSwarmActivityMetrics(agentCountDelta: number): void;
6
+ export declare const AGENT_TYPES: {
7
+ value: string;
8
+ label: string;
9
+ hint: string;
10
+ }[];
11
+ export declare function getAgentCapabilities(type: string): string[];
12
+ export declare function formatStatus(status: unknown): string;
13
+ export declare const spawnCommand: Command;
14
+ export declare const listCommand: Command;
15
+ export declare const statusCommand: Command;
16
+ export declare const stopCommand: Command;
17
+ //# sourceMappingURL=agent-lifecycle.d.ts.map
@@ -0,0 +1,320 @@
1
+ /**
2
+ * Agent lifecycle commands — spawn, list, status, stop
3
+ */
4
+ import { output } from '../output.js';
5
+ import { select, confirm, input } from '../prompt.js';
6
+ import { callMCPTool, MCPClientError } from '../mcp-client.js';
7
+ import * as fs from 'fs';
8
+ import * as path from 'path';
9
+ // ─── Shared utilities ────────────────────────────────────────────────────────
10
+ export function updateSwarmActivityMetrics(agentCountDelta) {
11
+ try {
12
+ const metricsDir = path.join(process.cwd(), '.monomind', 'metrics');
13
+ const activityPath = path.join(metricsDir, 'swarm-activity.json');
14
+ let data = {
15
+ timestamp: new Date().toISOString(),
16
+ swarm: { active: false, agent_count: 0, coordination_active: false },
17
+ };
18
+ if (fs.existsSync(activityPath) && fs.statSync(activityPath).size <= 10 * 1024 * 1024) {
19
+ data = JSON.parse(fs.readFileSync(activityPath, 'utf-8'));
20
+ }
21
+ else {
22
+ fs.mkdirSync(metricsDir, { recursive: true });
23
+ }
24
+ const swarm = data.swarm ?? {};
25
+ const currentCount = Math.max(0, swarm.agent_count || 0);
26
+ const newCount = Math.max(0, currentCount + agentCountDelta);
27
+ swarm.agent_count = newCount;
28
+ swarm.active = newCount > 0;
29
+ swarm.coordination_active = newCount > 0;
30
+ data.swarm = swarm;
31
+ data.timestamp = new Date().toISOString();
32
+ const tmpPath = activityPath + '.tmp';
33
+ fs.writeFileSync(tmpPath, JSON.stringify(data, null, 2));
34
+ fs.renameSync(tmpPath, activityPath);
35
+ }
36
+ catch {
37
+ // Non-critical — don't fail the command if metrics update fails
38
+ }
39
+ }
40
+ export const AGENT_TYPES = [
41
+ { value: 'coder', label: 'Coder', hint: 'Code development with neural patterns' },
42
+ { value: 'researcher', label: 'Researcher', hint: 'Research with web access and data analysis' },
43
+ { value: 'tester', label: 'Tester', hint: 'Comprehensive testing with automation' },
44
+ { value: 'reviewer', label: 'Reviewer', hint: 'Code review with security and quality checks' },
45
+ { value: 'architect', label: 'Architect', hint: 'System design with enterprise patterns' },
46
+ { value: 'coordinator', label: 'Coordinator', hint: 'Multi-agent orchestration and workflow' },
47
+ { value: 'analyst', label: 'Analyst', hint: 'Performance analysis and optimization' },
48
+ { value: 'optimizer', label: 'Optimizer', hint: 'Performance optimization and bottleneck analysis' },
49
+ { value: 'security-architect', label: 'Security Architect', hint: 'Security architecture and threat modeling' },
50
+ { value: 'security-auditor', label: 'Security Auditor', hint: 'CVE remediation and security testing' },
51
+ { value: 'memory-specialist', label: 'Memory Specialist', hint: 'LanceDB ANN search (150x-12,500x faster)' },
52
+ { value: 'swarm-specialist', label: 'Swarm Specialist', hint: 'Unified coordination engine' },
53
+ { value: 'performance-engineer', label: 'Performance Engineer', hint: '2.49x-7.47x optimization targets' },
54
+ { value: 'core-architect', label: 'Core Architect', hint: 'Domain-driven design restructure' },
55
+ { value: 'test-architect', label: 'Test Architect', hint: 'TDD London School methodology' },
56
+ ];
57
+ export function getAgentCapabilities(type) {
58
+ const capabilities = {
59
+ coder: ['code-generation', 'refactoring', 'debugging', 'testing'],
60
+ researcher: ['web-search', 'data-analysis', 'summarization', 'citation'],
61
+ tester: ['unit-testing', 'integration-testing', 'coverage-analysis', 'automation'],
62
+ reviewer: ['code-review', 'security-audit', 'quality-check', 'documentation'],
63
+ architect: ['system-design', 'pattern-analysis', 'scalability', 'documentation'],
64
+ coordinator: ['task-orchestration', 'agent-management', 'workflow-control'],
65
+ 'security-architect': ['threat-modeling', 'security-patterns', 'compliance', 'audit'],
66
+ 'memory-specialist': ['vector-search', 'lancedb', 'caching', 'optimization'],
67
+ 'performance-engineer': ['benchmarking', 'profiling', 'optimization', 'monitoring'],
68
+ };
69
+ return capabilities[type] || ['general'];
70
+ }
71
+ export function formatStatus(status) {
72
+ const s = String(status);
73
+ switch (s) {
74
+ case 'active': return output.success(s);
75
+ case 'idle': return output.warning(s);
76
+ case 'inactive':
77
+ case 'stopped': return output.dim(s);
78
+ case 'error': return output.error(s);
79
+ default: return s;
80
+ }
81
+ }
82
+ // ─── spawn subcommand ────────────────────────────────────────────────────────
83
+ export const spawnCommand = {
84
+ name: 'spawn',
85
+ description: 'Spawn a new agent',
86
+ options: [
87
+ { name: 'type', short: 't', description: 'Agent type to spawn', type: 'string', choices: AGENT_TYPES.map(a => a.value) },
88
+ { name: 'name', short: 'n', description: 'Agent name/identifier', type: 'string' },
89
+ { name: 'provider', short: 'p', description: 'Provider to use (anthropic, openrouter, ollama)', type: 'string', default: 'anthropic' },
90
+ { name: 'model', short: 'm', description: 'Model to use', type: 'string' },
91
+ { name: 'task', description: 'Initial task for the agent', type: 'string' },
92
+ { name: 'timeout', description: 'Agent timeout in seconds', type: 'number', default: 300 },
93
+ { name: 'auto-tools', description: 'Enable automatic tool usage', type: 'boolean', default: true },
94
+ ],
95
+ examples: [
96
+ { command: 'monomind agent spawn --type coder --name bot-1', description: 'Spawn a coder agent' },
97
+ { command: 'monomind agent spawn -t researcher --task "Research React 19"', description: 'Spawn researcher with task' },
98
+ ],
99
+ action: async (ctx) => {
100
+ let agentType = ctx.flags.type?.slice(0, 64) ?? '';
101
+ let agentName = ctx.flags.name?.slice(0, 128) ?? '';
102
+ if (!agentType && ctx.interactive) {
103
+ agentType = await select({ message: 'Select agent type:', options: AGENT_TYPES });
104
+ }
105
+ const taskDescription = ctx.flags.task?.slice(0, 2048);
106
+ if (!agentType && taskDescription) {
107
+ try {
108
+ const { createConfiguredRouteLayer } = await import('../routing/route-layer-factory.js');
109
+ const layer = await createConfiguredRouteLayer();
110
+ const routeResult = await layer.route(taskDescription);
111
+ agentType = routeResult.agentSlug;
112
+ process.stderr.write(`[route] ${routeResult.method}: "${agentType}" (confidence: ${(routeResult.confidence * 100).toFixed(1)}%)\n`);
113
+ }
114
+ catch {
115
+ // RouteLayer unavailable — fall through to error below
116
+ }
117
+ }
118
+ if (!agentType) {
119
+ output.printError('Agent type is required. Use --type or -t flag, or provide --task for auto-routing.');
120
+ return { success: false, exitCode: 1 };
121
+ }
122
+ if (!agentName)
123
+ agentName = `${agentType}-${Date.now().toString(36)}`;
124
+ output.printInfo(`Spawning ${agentType} agent: ${output.highlight(agentName)}`);
125
+ try {
126
+ const result = await callMCPTool('agent_spawn', {
127
+ agentType, id: agentName,
128
+ config: {
129
+ provider: ctx.flags.provider || 'anthropic',
130
+ model: ctx.flags.model,
131
+ task: ctx.flags.task,
132
+ timeout: ctx.flags.timeout,
133
+ autoTools: ctx.flags['auto-tools'],
134
+ },
135
+ priority: 'normal',
136
+ metadata: { name: agentName, capabilities: getAgentCapabilities(agentType) },
137
+ });
138
+ output.writeln();
139
+ output.printTable({
140
+ columns: [
141
+ { key: 'property', header: 'Property', width: 15 },
142
+ { key: 'value', header: 'Value', width: 40 },
143
+ ],
144
+ data: [
145
+ { property: 'ID', value: result.agentId },
146
+ { property: 'Type', value: result.agentType },
147
+ { property: 'Name', value: agentName },
148
+ { property: 'Status', value: result.status },
149
+ { property: 'Created', value: result.createdAt },
150
+ { property: 'Capabilities', value: getAgentCapabilities(agentType).join(', ') },
151
+ ],
152
+ });
153
+ output.writeln();
154
+ output.printSuccess(`Agent ${agentName} spawned successfully`);
155
+ updateSwarmActivityMetrics(1);
156
+ if (ctx.flags.format === 'json')
157
+ output.printJson(result);
158
+ return { success: true, data: result };
159
+ }
160
+ catch (error) {
161
+ output.printError(error instanceof MCPClientError ? `Failed to spawn agent: ${error.message}` : `Unexpected error: ${String(error)}`);
162
+ return { success: false, exitCode: 1 };
163
+ }
164
+ },
165
+ };
166
+ // ─── list subcommand ─────────────────────────────────────────────────────────
167
+ export const listCommand = {
168
+ name: 'list',
169
+ aliases: ['ls'],
170
+ description: 'List all active agents',
171
+ options: [
172
+ { name: 'all', short: 'a', description: 'Include inactive agents', type: 'boolean', default: false },
173
+ { name: 'type', short: 't', description: 'Filter by agent type', type: 'string' },
174
+ { name: 'status', short: 's', description: 'Filter by status', type: 'string' },
175
+ ],
176
+ action: async (ctx) => {
177
+ try {
178
+ const result = await callMCPTool('agent_list', {
179
+ status: ctx.flags.all ? 'all' : ctx.flags.status || undefined,
180
+ agentType: ctx.flags.type || undefined,
181
+ limit: 100,
182
+ });
183
+ if (ctx.flags.format === 'json') {
184
+ output.printJson(result);
185
+ return { success: true, data: result };
186
+ }
187
+ output.writeln();
188
+ output.writeln(output.bold('Active Agents'));
189
+ output.writeln();
190
+ if (result.agents.length === 0) {
191
+ output.printInfo('No agents found matching criteria');
192
+ return { success: true, data: result };
193
+ }
194
+ const displayAgents = result.agents.map(agent => ({
195
+ id: agent.id,
196
+ type: agent.agentType,
197
+ status: agent.status,
198
+ created: new Date(agent.createdAt).toLocaleTimeString(),
199
+ lastActivity: agent.lastActivityAt ? new Date(agent.lastActivityAt).toLocaleTimeString() : 'N/A',
200
+ }));
201
+ output.printTable({
202
+ columns: [
203
+ { key: 'id', header: 'ID', width: 20 },
204
+ { key: 'type', header: 'Type', width: 15 },
205
+ { key: 'status', header: 'Status', width: 12, format: formatStatus },
206
+ { key: 'created', header: 'Created', width: 12 },
207
+ { key: 'lastActivity', header: 'Last Activity', width: 12 },
208
+ ],
209
+ data: displayAgents,
210
+ });
211
+ output.writeln();
212
+ output.printInfo(`Total: ${result.total} agents`);
213
+ return { success: true, data: result };
214
+ }
215
+ catch (error) {
216
+ output.printError(error instanceof MCPClientError ? `Failed to list agents: ${error.message}` : `Unexpected error: ${String(error)}`);
217
+ return { success: false, exitCode: 1 };
218
+ }
219
+ },
220
+ };
221
+ // ─── status subcommand ───────────────────────────────────────────────────────
222
+ export const statusCommand = {
223
+ name: 'status',
224
+ description: 'Show detailed status of an agent',
225
+ options: [{ name: 'id', description: 'Agent ID', type: 'string' }],
226
+ action: async (ctx) => {
227
+ let agentId = ctx.args[0] || ctx.flags.id;
228
+ if (!agentId && ctx.interactive) {
229
+ agentId = await input({ message: 'Enter agent ID:', validate: (v) => v.length > 0 || 'Agent ID is required' });
230
+ }
231
+ if (!agentId) {
232
+ output.printError('Agent ID is required');
233
+ return { success: false, exitCode: 1 };
234
+ }
235
+ try {
236
+ const status = await callMCPTool('agent_status', { agentId, includeMetrics: true, includeHistory: false });
237
+ if (ctx.flags.format === 'json') {
238
+ output.printJson(status);
239
+ return { success: true, data: status };
240
+ }
241
+ output.writeln();
242
+ output.printBox([
243
+ `Type: ${status.agentType}`,
244
+ `Status: ${formatStatus(status.status)}`,
245
+ `Created: ${new Date(status.createdAt).toLocaleString()}`,
246
+ `Last Activity: ${status.lastActivityAt ? new Date(status.lastActivityAt).toLocaleString() : 'N/A'}`,
247
+ ].join('\n'), `Agent: ${status.id}`);
248
+ if (status.metrics) {
249
+ output.writeln();
250
+ output.writeln(output.bold('Metrics'));
251
+ const avgExecTime = status.metrics.averageExecutionTime ?? 0;
252
+ const uptime = status.metrics.uptime ?? 0;
253
+ output.printTable({
254
+ columns: [
255
+ { key: 'metric', header: 'Metric', width: 25 },
256
+ { key: 'value', header: 'Value', width: 15, align: 'right' },
257
+ ],
258
+ data: [
259
+ { metric: 'Tasks Completed', value: status.metrics.tasksCompleted ?? 0 },
260
+ { metric: 'Tasks In Progress', value: status.metrics.tasksInProgress ?? 0 },
261
+ { metric: 'Tasks Failed', value: status.metrics.tasksFailed ?? 0 },
262
+ { metric: 'Avg Execution Time', value: `${avgExecTime.toFixed(2)}ms` },
263
+ { metric: 'Uptime', value: `${(uptime / 1000 / 60).toFixed(1)}m` },
264
+ ],
265
+ });
266
+ }
267
+ return { success: true, data: status };
268
+ }
269
+ catch (error) {
270
+ output.printError(error instanceof MCPClientError ? `Failed to get agent status: ${error.message}` : `Unexpected error: ${String(error)}`);
271
+ return { success: false, exitCode: 1 };
272
+ }
273
+ },
274
+ };
275
+ // ─── stop subcommand ─────────────────────────────────────────────────────────
276
+ export const stopCommand = {
277
+ name: 'stop',
278
+ aliases: ['kill'],
279
+ description: 'Stop a running agent',
280
+ options: [
281
+ { name: 'force', short: 'f', description: 'Force stop without graceful shutdown', type: 'boolean', default: false },
282
+ { name: 'timeout', description: 'Graceful shutdown timeout in seconds', type: 'number', default: 30 },
283
+ ],
284
+ action: async (ctx) => {
285
+ const agentId = ctx.args[0];
286
+ if (!agentId) {
287
+ output.printError('Agent ID is required');
288
+ return { success: false, exitCode: 1 };
289
+ }
290
+ const force = ctx.flags.force;
291
+ if (!force && ctx.interactive) {
292
+ const confirmed = await confirm({ message: `Are you sure you want to stop agent ${agentId}?`, default: false });
293
+ if (!confirmed) {
294
+ output.printInfo('Operation cancelled');
295
+ return { success: true };
296
+ }
297
+ }
298
+ output.printInfo(`Stopping agent ${agentId}...`);
299
+ try {
300
+ const result = await callMCPTool('agent_terminate', {
301
+ agentId, graceful: !force, reason: 'Stopped by user via CLI',
302
+ });
303
+ if (!force) {
304
+ output.writeln(output.dim(' Completing current task...'));
305
+ output.writeln(output.dim(' Saving state...'));
306
+ output.writeln(output.dim(' Releasing resources...'));
307
+ }
308
+ output.printSuccess(`Agent ${agentId} stopped successfully`);
309
+ updateSwarmActivityMetrics(-1);
310
+ if (ctx.flags.format === 'json')
311
+ output.printJson(result);
312
+ return { success: true, data: result };
313
+ }
314
+ catch (error) {
315
+ output.printError(error instanceof MCPClientError ? `Failed to stop agent: ${error.message}` : `Unexpected error: ${String(error)}`);
316
+ return { success: false, exitCode: 1 };
317
+ }
318
+ },
319
+ };
320
+ //# sourceMappingURL=agent-lifecycle.js.map
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Agent operational commands — metrics, pool, health, logs
3
+ */
4
+ import type { Command } from '../types.js';
5
+ export declare const metricsCommand: Command;
6
+ export declare const poolCommand: Command;
7
+ export declare const healthCommand: Command;
8
+ export declare const logsCommand: Command;
9
+ //# sourceMappingURL=agent-ops.d.ts.map