monomind 2.0.3 → 2.1.3

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 (113) hide show
  1. package/README.md +74 -92
  2. package/package.json +11 -7
  3. package/packages/@monomind/cli/.claude/helpers/control-start.cjs +13 -20
  4. package/packages/@monomind/cli/.claude/helpers/event-logger.cjs +109 -6
  5. package/packages/@monomind/cli/.claude/helpers/graphify-freshen.cjs +19 -17
  6. package/packages/@monomind/cli/.claude/helpers/handlers/agent-start-handler.cjs +60 -28
  7. package/packages/@monomind/cli/.claude/helpers/handlers/capture-handler.cjs +99 -28
  8. package/packages/@monomind/cli/.claude/helpers/handlers/edit-handler.cjs +27 -9
  9. package/packages/@monomind/cli/.claude/helpers/handlers/gates-handler.cjs +18 -9
  10. package/packages/@monomind/cli/.claude/helpers/handlers/loops-status-handler.cjs +1 -1
  11. package/packages/@monomind/cli/.claude/helpers/handlers/route-handler.cjs +33 -4
  12. package/packages/@monomind/cli/.claude/helpers/handlers/session-handler.cjs +75 -45
  13. package/packages/@monomind/cli/.claude/helpers/handlers/session-restore-handler.cjs +0 -12
  14. package/packages/@monomind/cli/.claude/helpers/handlers/task-handler.cjs +53 -22
  15. package/packages/@monomind/cli/.claude/helpers/hook-handler.cjs +75 -4
  16. package/packages/@monomind/cli/.claude/helpers/intelligence.cjs +94 -15
  17. package/packages/@monomind/cli/.claude/helpers/session.cjs +6 -1
  18. package/packages/@monomind/cli/.claude/helpers/statusline.cjs +10 -10
  19. package/packages/@monomind/cli/.claude/helpers/token-tracker.cjs +3 -3
  20. package/packages/@monomind/cli/.claude/helpers/utils/agent-registrations.cjs +41 -0
  21. package/packages/@monomind/cli/.claude/helpers/utils/fs-helpers.cjs +183 -0
  22. package/packages/@monomind/cli/.claude/helpers/utils/micro-agents.cjs +10 -6
  23. package/packages/@monomind/cli/.claude/helpers/utils/monograph.cjs +73 -2
  24. package/packages/@monomind/cli/.claude/helpers/utils/telemetry.cjs +35 -19
  25. package/packages/@monomind/cli/README.md +74 -92
  26. package/packages/@monomind/cli/bin/cli.js +10 -1
  27. package/packages/@monomind/cli/dist/src/browser/workflow/store.d.ts +2 -2
  28. package/packages/@monomind/cli/dist/src/commands/agent-ops.js +9 -15
  29. package/packages/@monomind/cli/dist/src/commands/browse.d.ts +1 -1
  30. package/packages/@monomind/cli/dist/src/commands/cleanup.js +20 -4
  31. package/packages/@monomind/cli/dist/src/commands/completions.js +66 -261
  32. package/packages/@monomind/cli/dist/src/commands/doctor-env-checks.js +5 -0
  33. package/packages/@monomind/cli/dist/src/commands/doctor.js +7 -2
  34. package/packages/@monomind/cli/dist/src/commands/hooks-workers.js +7 -0
  35. package/packages/@monomind/cli/dist/src/commands/index.js +3 -0
  36. package/packages/@monomind/cli/dist/src/commands/mcp.js +11 -6
  37. package/packages/@monomind/cli/dist/src/commands/memory-admin.js +12 -6
  38. package/packages/@monomind/cli/dist/src/commands/memory-transfer.js +6 -13
  39. package/packages/@monomind/cli/dist/src/commands/monograph.js +3 -3
  40. package/packages/@monomind/cli/dist/src/commands/org.d.ts +3 -1
  41. package/packages/@monomind/cli/dist/src/commands/org.js +321 -127
  42. package/packages/@monomind/cli/dist/src/commands/platforms.d.ts +1 -1
  43. package/packages/@monomind/cli/dist/src/commands/start.js +142 -37
  44. package/packages/@monomind/cli/dist/src/commands/tokens.js +21 -3
  45. package/packages/@monomind/cli/dist/src/config-adapter.js +37 -17
  46. package/packages/@monomind/cli/dist/src/index.js +64 -28
  47. package/packages/@monomind/cli/dist/src/init/claudemd-generator.js +44 -11
  48. package/packages/@monomind/cli/dist/src/init/executor.js +93 -55
  49. package/packages/@monomind/cli/dist/src/mcp-client.d.ts +8 -3
  50. package/packages/@monomind/cli/dist/src/mcp-client.js +37 -3
  51. package/packages/@monomind/cli/dist/src/mcp-server.js +8 -2
  52. package/packages/@monomind/cli/dist/src/mcp-tools/agent-tools.d.ts +20 -0
  53. package/packages/@monomind/cli/dist/src/mcp-tools/agent-tools.js +10 -5
  54. package/packages/@monomind/cli/dist/src/mcp-tools/auto-install.d.ts +8 -8
  55. package/packages/@monomind/cli/dist/src/mcp-tools/coherence/types.d.ts +31 -31
  56. package/packages/@monomind/cli/dist/src/mcp-tools/github-tools.js +30 -8
  57. package/packages/@monomind/cli/dist/src/mcp-tools/graphify-tools.js +11 -2
  58. package/packages/@monomind/cli/dist/src/mcp-tools/hive-mind-tools.js +56 -35
  59. package/packages/@monomind/cli/dist/src/mcp-tools/knowledge-tools.js +9 -1
  60. package/packages/@monomind/cli/dist/src/mcp-tools/monograph-compat.js +56 -14
  61. package/packages/@monomind/cli/dist/src/mcp-tools/monograph-tools.js +88 -41
  62. package/packages/@monomind/cli/dist/src/mcp-tools/quality/coverage-analysis/prioritize-gaps.d.ts +36 -36
  63. package/packages/@monomind/cli/dist/src/mcp-tools/quality/security-compliance/detect-secrets.d.ts +4 -4
  64. package/packages/@monomind/cli/dist/src/mcp-tools/swarm-tools.js +6 -4
  65. package/packages/@monomind/cli/dist/src/mcp-tools/system-tools.js +4 -4
  66. package/packages/@monomind/cli/dist/src/mcp-tools/types.d.ts +20 -0
  67. package/packages/@monomind/cli/dist/src/mcp-tools/types.js +36 -1
  68. package/packages/@monomind/cli/dist/src/memory/ewc-consolidation.d.ts +12 -0
  69. package/packages/@monomind/cli/dist/src/memory/hnsw-operations.d.ts +13 -1
  70. package/packages/@monomind/cli/dist/src/memory/hnsw-operations.js +66 -14
  71. package/packages/@monomind/cli/dist/src/memory/intelligence.js +99 -3
  72. package/packages/@monomind/cli/dist/src/memory/memory-bridge.d.ts +7 -0
  73. package/packages/@monomind/cli/dist/src/memory/memory-bridge.js +20 -0
  74. package/packages/@monomind/cli/dist/src/memory/sona-optimizer.d.ts +12 -0
  75. package/packages/@monomind/cli/dist/src/orgrt/broker.d.ts +26 -0
  76. package/packages/@monomind/cli/dist/src/orgrt/broker.js +73 -0
  77. package/packages/@monomind/cli/dist/src/orgrt/bus.d.ts +5 -1
  78. package/packages/@monomind/cli/dist/src/orgrt/bus.js +5 -1
  79. package/packages/@monomind/cli/dist/src/orgrt/daemon.d.ts +46 -0
  80. package/packages/@monomind/cli/dist/src/orgrt/daemon.js +201 -18
  81. package/packages/@monomind/cli/dist/src/orgrt/forwarder.d.ts +10 -5
  82. package/packages/@monomind/cli/dist/src/orgrt/forwarder.js +138 -8
  83. package/packages/@monomind/cli/dist/src/orgrt/inbox.d.ts +11 -0
  84. package/packages/@monomind/cli/dist/src/orgrt/inbox.js +56 -0
  85. package/packages/@monomind/cli/dist/src/orgrt/policy.d.ts +5 -1
  86. package/packages/@monomind/cli/dist/src/orgrt/policy.js +58 -5
  87. package/packages/@monomind/cli/dist/src/orgrt/provider.js +1 -0
  88. package/packages/@monomind/cli/dist/src/orgrt/scheduler.d.ts +13 -0
  89. package/packages/@monomind/cli/dist/src/orgrt/scheduler.js +48 -0
  90. package/packages/@monomind/cli/dist/src/orgrt/server.d.ts +9 -0
  91. package/packages/@monomind/cli/dist/src/orgrt/server.js +39 -0
  92. package/packages/@monomind/cli/dist/src/orgrt/session.d.ts +10 -1
  93. package/packages/@monomind/cli/dist/src/orgrt/session.js +24 -1
  94. package/packages/@monomind/cli/dist/src/orgrt/test-loop.d.ts +12 -0
  95. package/packages/@monomind/cli/dist/src/orgrt/test-loop.js +108 -0
  96. package/packages/@monomind/cli/dist/src/orgrt/types.d.ts +52 -52
  97. package/packages/@monomind/cli/dist/src/output.d.ts +29 -29
  98. package/packages/@monomind/cli/dist/src/output.js +22 -7
  99. package/packages/@monomind/cli/dist/src/parser.d.ts +32 -0
  100. package/packages/@monomind/cli/dist/src/parser.js +130 -5
  101. package/packages/@monomind/cli/dist/src/routing/embed-worker.js +13 -1
  102. package/packages/@monomind/cli/dist/src/routing/route-layer-factory.js +31 -0
  103. package/packages/@monomind/cli/dist/src/services/config-file-manager.d.ts +21 -0
  104. package/packages/@monomind/cli/dist/src/services/config-file-manager.js +60 -7
  105. package/packages/@monomind/cli/dist/src/services/crash-reporter.js +2 -1
  106. package/packages/@monomind/cli/dist/src/types.d.ts +2 -2
  107. package/packages/@monomind/cli/dist/src/ui/dashboard.html +243 -49
  108. package/packages/@monomind/cli/dist/src/ui/orgs-files.js +192 -0
  109. package/packages/@monomind/cli/dist/src/ui/orgs.html +79 -11
  110. package/packages/@monomind/cli/dist/src/ui/server.mjs +346 -139
  111. package/packages/@monomind/cli/dist/src/utils/input-guards.d.ts +9 -0
  112. package/packages/@monomind/cli/dist/src/utils/input-guards.js +39 -5
  113. package/packages/@monomind/cli/package.json +15 -15
@@ -5,8 +5,8 @@
5
5
  <h1 align="center">Monomind</h1>
6
6
 
7
7
  <p align="center">
8
- <strong>Hire an AI team. Set a goal. Walk away.</strong><br/>
9
- Autonomous Claude Code orchestration with persistent memory, self-coordinating agent orgs, and a codebase knowledge graph.
8
+ <strong>An open-source MCP server that extends Claude Code with a codebase knowledge graph, persistent memory, and multi-agent coordination.</strong><br/>
9
+ MIT licensed &middot; Fully local &middot; No data leaves your machine
10
10
  </p>
11
11
 
12
12
  <p align="center">
@@ -30,126 +30,105 @@
30
30
 
31
31
  ## What is Monomind?
32
32
 
33
- Claude Code is already powerful. Monomind makes it **run itself**.
33
+ Monomind is an **open-source CLI and MCP server** that plugs into Claude Code via the standard [Model Context Protocol](https://modelcontextprotocol.io/). It adds capabilities that Claude Code doesn't ship with out of the box:
34
34
 
35
- Install once. Wire it into Claude Code. Then instead of prompting Claude to do individual tasks, you tell Monomind what outcome you want and it assembles a team, coordinates the work, and delivers.
35
+ - **Codebase knowledge graph** tree-sitter parses your code into a SQLite-backed graph of files, functions, classes, and their relationships. Query imports, callers, and blast radius before making changes.
36
+ - **Persistent memory** — a JSON pattern store with episodic recall that survives across sessions. Agents and orgs share context without re-prompting.
37
+ - **Multi-agent coordination** — in-session, spawn ad-hoc agent teams via Claude Code's Task tool; for persistent background work, `monomind org run` starts a real SDK-backed daemon with policy-gated role agents and a live dashboard.
38
+ - **Reusable slash commands** — 30+ development workflows (build, review, debug, TDD, architecture) available as `/mastermind:*` commands inside Claude Code.
36
39
 
37
40
  ```bash
38
- # Assemble an AI content team and let it run
39
- /mastermind:createorg content-team "publish 3 SEO-optimized posts per week"
40
- /mastermind:runorg --org content-team
41
-
42
- # Or run the autonomous code improvement loop
43
- /mastermind:autodev --tillend --focus security
41
+ npm install -g monomind # MIT licensed, 0 external API calls
42
+ cd your-project && monomind init
43
+ claude mcp add monomind npx monomind mcp start
44
44
  ```
45
45
 
46
- That's it. Come back later.
46
+ ### Trust & Security
47
+
48
+ | Concern | Answer |
49
+ |---|---|
50
+ | **License** | [MIT](LICENSE) — use it however you want |
51
+ | **Data privacy** | Everything runs locally. No telemetry, no phone-home, no external API calls from Monomind itself. Your code stays on your machine. |
52
+ | **Dependencies** | Standard npm packages (tree-sitter, sql.js, zod). No native binaries. No post-install scripts that download code. |
53
+ | **Permissions** | Registers as an MCP server — Claude Code controls what tools are available and prompts you before executing anything sensitive. |
54
+ | **Source** | Fully open. Read every line at [github.com/monoes/monomind](https://github.com/monoes/monomind). |
55
+ | **Maintenance** | Active development, regular releases on npm. |
47
56
 
48
57
  ---
49
58
 
50
59
  ## 🏢 Autonomous Organizations
51
60
 
52
- > **This is the headline feature.** Build a persistent AI organization — roles, hierarchy, shared task board and start it as a background daemon that runs without you.
61
+ > **This is the headline feature.** `monomind org run` starts a persistent, SDK-backed daemon that runs an autonomous agent organization — roles, hierarchy, policy-gated tool access, a live dashboard until you stop it.
53
62
 
54
63
  ### The idea
55
64
 
56
- Every business function needs a team. Monomind lets you design that team in one command, then run it forever. The org persists across sessions. It checkpoints, recovers from failures, and coordinates its agents through a shared task board all automatically.
65
+ Every business function needs a team. Define the org once as a JSON file — goal, roles, who reports to whom, per-role tool/file/budget policy — then run it as a real background daemon backed by the Claude Agent SDK. It persists across sessions, serves a live WebSocket dashboard, and can discover and message other Monomind orgs running on the same machine.
57
66
 
58
67
  ```mermaid
59
68
  flowchart TD
60
69
  U(["You"])
61
- CO["/mastermind:createorg\nDefine goal + roles"]
62
- RO["/mastermind:runorg\nStart daemon"]
63
- BOSS["Boss Agent\ncoordinator"]
64
- W["Writer\nContent Creator"]
70
+ DEF["org.json\nGoal + roles + policy"]
71
+ RUN["monomind org run\nStart SDK daemon"]
72
+ BOSS["Boss Agent\nAgent SDK session"]
73
+ W["Writer"]
65
74
  S["SEO Specialist"]
66
75
  R["Reviewer"]
67
- M["Growth Marketer"]
68
- BOARD[("Shared\nTask Board")]
69
- MEM[("Persistent\nMemory")]
76
+ DASH[("Live Dashboard\n:4243")]
77
+ XORG[("Other orgs\ncross-process")]
70
78
 
71
- U --> CO --> RO --> BOSS
79
+ U --> DEF --> RUN --> BOSS
72
80
  BOSS -->|spawns| W
73
81
  BOSS -->|spawns| S
74
82
  BOSS -->|spawns| R
75
- BOSS -->|spawns| M
76
- BOSS <-->|claims + reports| BOARD
77
- W <-->|stores output| MEM
78
- S <-->|reads context| MEM
83
+ RUN <-->|serves| DASH
84
+ RUN <-.->|--cross-process| XORG
79
85
 
80
86
  style BOSS fill:#00D2AA22,stroke:#00D2AA
81
- style BOARD fill:#F59E0B22,stroke:#F59E0B
82
- style MEM fill:#8B5CF622,stroke:#8B5CF6
83
- ```
84
-
85
- ### Two commands to a running org
86
-
87
- **Step 1 — Design it:**
88
-
87
+ style DASH fill:#F59E0B22,stroke:#F59E0B
88
+ style XORG fill:#8B5CF622,stroke:#8B5CF6
89
89
  ```
90
- / mastermind:createorg content-team
91
- "Build and publish 3 blog posts per week on AI dev tools"
92
-
93
- Deriving roles from goal...
94
-
95
- ╔ ORG: content-team
96
- ║ TOPOLOGY: star (5 roles)
97
90
 
98
- boss → coordinator
99
- writer → Content Creator
100
- reviewer → reviewer
101
- marketer → Growth Hacker
102
- seo → SEO Specialist
91
+ ### Run one
103
92
 
104
- Type "go" to save, or describe changes.
105
- go
93
+ ```bash
94
+ # .monomind/orgs/<name>.json defines the org: goal, roles, policy.
95
+ # See .monomind/orgs/sample-team.json in a fresh `monomind init` for a working example.
106
96
 
107
- Saved .monomind/orgs/content-team.json
108
- → Run: /mastermind:runorg --org content-team
109
- ```
97
+ monomind org run content-team --task "Build and publish 3 blog posts per week"
110
98
 
111
- **Step 2 Start it:**
99
+ # Live dashboard: http://localhost:4243
100
+ # ✓ Boss agent (Claude Agent SDK session) spawns, reads the org goal,
101
+ # assigns work to role agents, coordinates until the task completes
102
+ # or you stop it.
112
103
 
113
- ```bash
114
- /mastermind:runorg --org content-team
115
-
116
- # Boss agent spawns in background
117
- # Coordinates all roles via shared task board
118
- # Checkpoints every 30 minutes
119
- # Loops until you stop it
104
+ monomind org status content-team # runtime state
105
+ monomind org stop content-team # request a graceful stop
106
+ monomind org list # every org + status
120
107
  ```
121
108
 
122
109
  ### What runs under the hood
123
110
 
124
111
  | What | How |
125
112
  |---|---|
126
- | **Boss agent** | Coordinator type, no supervisor owns the goal |
127
- | **Role agents** | Spawned on demand, specialized by task type |
128
- | **Task board** | Todo Doing Done, shared across all agents |
129
- | **Memory** | All output stored in an org-scoped memory namespace |
130
- | **Checkpoint** | State saved every 30 min survives crashes and restarts |
131
- | **Governance** | `auto` (free), `board` (approve sensitive), `strict` (approve all external actions) |
132
-
133
- ### Topology is auto-derived
134
-
135
- ```mermaid
136
- graph LR
137
- A["1-3 roles"] -->|mesh| B["All-to-all\ndirect comms"]
138
- C["4-6 roles"] -->|star| D["Boss to workers\nfan-out"]
139
- E["7+ roles"] -->|hierarchical| F["Boss to leads to workers\nmiddle management"]
140
- ```
113
+ | **OrgDaemon** | Hosts one or more orgs in a single process; real Claude Agent SDK sessions per role, not simulated |
114
+ | **PolicyEngine** | Per-role gates on tool access, file read/write scope, web access, token budget — enforced, with a full audit trail |
115
+ | **Live dashboard** | WebSocket-served at `:4243` by default (`--port` to change, `--serve=false` to disable) |
116
+ | **Cross-process comms** | `--cross-process` (default on) lets orgs on different `monomind` processes/projects discover and message each other |
117
+ | **Scheduling** | `monomind org serve` hosts orgs whose definition has a `schedule` field, running them on interval |
141
118
 
142
119
  ### Org management commands
143
120
 
144
121
  ```bash
145
- /mastermind:createorg <name> "<goal>" # design org from a goal
146
- /mastermind:runorg --org <name> # start as background daemon
147
- /mastermind:orgs # list all orgs + status
148
- /mastermind:orgstatus --org <name> # detailed status for one org
149
- /mastermind:stoporg --org <name> # stop a running org
150
- /mastermind:approve # review pending approval requests
122
+ monomind org run <name> [--task "..."] [--port N] [--cross-process] # start a daemon
123
+ monomind org stop <name> # request a running org to stop
124
+ monomind org status [name] # runtime state for one or all orgs
125
+ monomind org list # list every org + status
126
+ monomind org serve [--port N] # host-only mode, runs scheduled orgs
127
+ monomind org delete <name> # remove an org
151
128
  ```
152
129
 
130
+ > **Note:** the older `/mastermind:createorg` + `/mastermind:runorg` prompt-orchestrated flow is deprecated — it has no delivery guarantees or ground-truth event stream. It still runs for orgs not yet migrated, but new orgs should use `monomind org run` directly against a hand-authored `.monomind/orgs/<name>.json`.
131
+
153
132
  ---
154
133
 
155
134
  ## ⚡ The Autonomous Build Loop
@@ -206,11 +185,11 @@ claude mcp add monomind npx monomind mcp start
206
185
  monomind doctor --fix
207
186
  ```
208
187
 
209
- Open Claude Code. You now have 80+ slash commands available:
188
+ Open Claude Code. You now have 60+ slash commands available:
210
189
 
211
190
  ```bash
212
191
  /mastermind:autodev --tillend # start autonomous code loop
213
- /mastermind:createorg my-team # create your first AI org
192
+ monomind org run my-team # run your first AI org (see .monomind/orgs/sample-team.json)
214
193
  /mastermind:help # show all commands
215
194
  ```
216
195
 
@@ -262,7 +241,7 @@ Before touching any file, Monomind queries **Monograph** — a SQLite-backed kno
262
241
 
263
242
  ## 🎣 Hooks & Workers
264
243
 
265
- Monomind wires 22 hook events into Claude Code. Every edit, task, command, and session fires hooks that log patterns, route agents, and train the intelligence system.
244
+ Monomind wires 29 hook subcommands into Claude Code across edit, task, command, and session lifecycle events logging patterns, routing agents, and feeding the intelligence system.
266
245
 
267
246
  ```mermaid
268
247
  flowchart LR
@@ -296,7 +275,7 @@ const result = await fence.detect(userInput);
296
275
 
297
276
  ---
298
277
 
299
- ## 📋 80+ Slash Commands
278
+ ## 📋 60+ Slash Commands
300
279
 
301
280
  Everything runs from inside Claude Code via slash commands. Here's the highlight reel:
302
281
 
@@ -315,9 +294,9 @@ Everything runs from inside Claude Code via slash commands. Here's the highlight
315
294
  ### Organizations
316
295
  | Command | What it does |
317
296
  |---|---|
318
- | `/mastermind:createorg` | Design an autonomous agent org |
319
- | `/mastermind:runorg` | Start it as a background daemon |
320
- | `/mastermind:orgs` | List all orgs + status |
297
+ | `monomind org run <name>` | Start an org as a real SDK-backed daemon |
298
+ | `monomind org status` / `list` | Runtime state for one or all orgs |
299
+ | `monomind org stop <name>` | Request a graceful stop |
321
300
  | `/mastermind:approve` | Action pending approval requests |
322
301
 
323
302
  ### Business Domains
@@ -329,7 +308,7 @@ Everything runs from inside Claude Code via slash commands. Here's the highlight
329
308
  | `/mastermind:finance` | Budgets, invoicing, modeling |
330
309
  | `/mastermind:ops` | Operations and workflow automation |
331
310
 
332
- **[→ Full reference (80+ commands)](https://monoes.github.io/monomind/#slash)**
311
+ **[→ Full reference (60+ commands)](https://monoes.github.io/monomind/#slash)**
333
312
 
334
313
  ---
335
314
 
@@ -351,24 +330,27 @@ graph TD
351
330
  CC["Claude Code"]
352
331
  MCP["MCP Server\nmonomind mcp start"]
353
332
  D["Background Workers\n(@monomind/hooks, in-process)"]
333
+ ORG["OrgDaemon\nmonomind org run\nreal SDK sessions"]
354
334
 
355
- CC <-->|"MCP tools: monograph, memory, swarm"| MCP
335
+ CC <-->|"MCP tools: monograph, memory"| MCP
356
336
  MCP <--> D
357
337
 
358
338
  D --> ADB[("Memory store\npatterns + episodes")]
359
339
  D --> MG[("Monograph\ncode graph")]
360
- D --> HK["Hooks\n22 event types"]
361
- D --> SW["Swarm\n4 topologies\n3 consensus strategies"]
340
+ D --> HK["Hooks\n29 subcommands"]
362
341
 
363
- CC -->|"Task tool - spawns agents"| AG["Agent Swarm\narchitect, coder\ntester, reviewer\nsecurity, perf"]
342
+ CC -->|"Task tool - spawns agents"| AG["In-session agents\narchitect, coder\ntester, reviewer\nsecurity, perf"]
364
343
  AG <-->|reads and writes| ADB
344
+ ORG -->|"spawns, policy-gated"| RA["Role agents"]
345
+ ORG <-->|reads and writes| ADB
365
346
 
366
347
  style CC fill:#00D2AA22,stroke:#00D2AA
367
348
  style AG fill:#8B5CF622,stroke:#8B5CF6
368
349
  style ADB fill:#F59E0B22,stroke:#F59E0B
350
+ style ORG fill:#F59E0B22,stroke:#F59E0B
369
351
  ```
370
352
 
371
- **Claude Code handles all execution.** MCP tools only coordinate. Your data never leaves your machine.
353
+ **Claude Code's Task tool drives in-session multi-agent work; `monomind org run` drives persistent background orgs.** Your data never leaves your machine.
372
354
 
373
355
  ---
374
356
 
@@ -241,8 +241,17 @@ if (isMCPMode) {
241
241
 
242
242
  const { CLI } = await import('../dist/src/index.js');
243
243
  const cli = new CLI();
244
+ // A detached daemon child (`start --daemon --foreground-worker-internal`,
245
+ // see src/commands/start.ts) intentionally keeps a ref'd setInterval alive
246
+ // after its action resolves — that's what holds the process open as a real
247
+ // daemon. Unconditionally calling process.exit() here would kill it the
248
+ // instant the action's promise resolves, defeating the whole point.
249
+ const isDaemonChild = cliArgs.includes('--foreground-worker-internal');
244
250
  cli.run().then(() => {
245
- process.exit(process.exitCode ?? 0);
251
+ if (!isDaemonChild) {
252
+ process.exit(process.exitCode ?? 0);
253
+ }
254
+ // Daemon child: let the event loop stay alive on its own ref'd interval.
246
255
  }).catch((error) => {
247
256
  console.error('Fatal error:', safeMsg(error && error.message));
248
257
  process.exit(1);
@@ -1,7 +1,7 @@
1
1
  import type { WorkflowDef, RunRecord } from './types.js';
2
2
  export declare class WorkflowStoreError extends Error {
3
- readonly cause?: unknown | undefined;
4
- constructor(message: string, cause?: unknown | undefined);
3
+ readonly cause?: unknown;
4
+ constructor(message: string, cause?: unknown);
5
5
  }
6
6
  export declare function readWorkflow(filePath: string): Promise<WorkflowDef>;
7
7
  export declare function writeRunRecord(record: RunRecord): Promise<void>;
@@ -8,11 +8,7 @@ import { formatStatus } from './agent-lifecycle.js';
8
8
  export const metricsCommand = {
9
9
  name: 'metrics',
10
10
  description: 'Show agent performance metrics',
11
- options: [
12
- { name: 'period', short: 'p', description: 'Time period (1h, 24h, 7d, 30d)', type: 'string', default: '24h' },
13
- ],
14
11
  action: async (ctx) => {
15
- const period = ctx.flags.period;
16
12
  const { existsSync, readFileSync, readdirSync, statSync } = await import('fs');
17
13
  const { join } = await import('path');
18
14
  let totalAgents = 0;
@@ -61,13 +57,12 @@ export const metricsCommand = {
61
57
  catch { /* ignore */ }
62
58
  }
63
59
  let vectorCount = 0;
64
- const dbPath = join(swarmDir, 'memory.db');
65
- if (existsSync(dbPath)) {
66
- try {
67
- vectorCount = Math.floor(statSync(dbPath).size / 2048);
68
- }
69
- catch { /* ignore */ }
60
+ try {
61
+ const { bridgeGetBackendStats } = await import('../memory/memory-bridge.js');
62
+ const backendStats = await bridgeGetBackendStats();
63
+ vectorCount = backendStats?.totalEntries ?? 0;
70
64
  }
65
+ catch { /* backend unavailable */ }
71
66
  const byType = Object.entries(typeCounts).map(([type, data]) => ({
72
67
  type, count: data.count, tasks: data.tasks,
73
68
  successRate: data.tasks > 0 ? `${Math.round((data.success / data.tasks) * 100)}%` : 'N/A',
@@ -76,20 +71,19 @@ export const metricsCommand = {
76
71
  ? `${Math.round(Object.values(typeCounts).reduce((a, d) => a + d.success, 0) / tasksCompleted * 100)}%`
77
72
  : 'N/A';
78
73
  const metrics = {
79
- period,
80
74
  summary: {
81
75
  totalAgents, activeAgents, tasksCompleted, avgSuccessRate, vectorCount,
82
76
  note: totalAgents === 0 ? 'No agents spawned yet. Use: agent spawn -t coder' : undefined,
83
77
  },
84
78
  byType,
85
- performance: { memoryVectors: `${vectorCount} vectors`, searchBackend: vectorCount > 0 ? 'HNSW-indexed' : 'none' },
79
+ performance: { memoryEntries: `${vectorCount} entries`, searchBackend: vectorCount > 0 ? 'LanceDB' : 'none' },
86
80
  };
87
81
  if (ctx.flags.format === 'json') {
88
82
  output.printJson(metrics);
89
83
  return { success: true, data: metrics };
90
84
  }
91
85
  output.writeln();
92
- output.writeln(output.bold(`Agent Metrics (${period})`));
86
+ output.writeln(output.bold('Agent Metrics'));
93
87
  output.writeln();
94
88
  output.printTable({
95
89
  columns: [
@@ -101,7 +95,7 @@ export const metricsCommand = {
101
95
  { metric: 'Active Agents', value: metrics.summary.activeAgents },
102
96
  { metric: 'Tasks Completed', value: metrics.summary.tasksCompleted },
103
97
  { metric: 'Success Rate', value: metrics.summary.avgSuccessRate },
104
- { metric: 'Memory Vectors', value: metrics.summary.vectorCount },
98
+ { metric: 'Memory Entries', value: metrics.summary.vectorCount },
105
99
  ],
106
100
  });
107
101
  output.writeln();
@@ -122,7 +116,7 @@ export const metricsCommand = {
122
116
  output.writeln();
123
117
  output.writeln(output.bold('Memory'));
124
118
  output.printList([
125
- `Vectors: ${output.success(metrics.performance.memoryVectors)}`,
119
+ `Entries: ${output.success(metrics.performance.memoryEntries)}`,
126
120
  `Backend: ${output.success(metrics.performance.searchBackend)}`,
127
121
  ]);
128
122
  return { success: true, data: metrics };
@@ -1,5 +1,4 @@
1
1
  declare const browseCommand: {
2
- subcommands: import("../types.js").Command[];
3
2
  name: string;
4
3
  description: string;
5
4
  aliases?: string[];
@@ -7,6 +6,7 @@ declare const browseCommand: {
7
6
  examples?: import("@monoes/monobrowse/cli/types").CommandExample[];
8
7
  action?: import("@monoes/monobrowse/cli/types").CommandAction;
9
8
  hidden?: boolean;
9
+ subcommands: import("../types.js").Command[];
10
10
  };
11
11
  export default browseCommand;
12
12
  //# sourceMappingURL=browse.d.ts.map
@@ -5,8 +5,8 @@
5
5
  * github.com/monoes/monomind
6
6
  */
7
7
  import { output } from '../output.js';
8
- import { existsSync, lstatSync, rmSync, readdirSync } from 'fs';
9
- import { join } from 'path';
8
+ import { existsSync, lstatSync, rmSync, readdirSync, readFileSync, writeFileSync, mkdirSync } from 'fs';
9
+ import { join, dirname } from 'path';
10
10
  /**
11
11
  * Artifact directories and files that monomind/monomind may create
12
12
  */
@@ -190,13 +190,29 @@ export const cleanupCommand = {
190
190
  // Actually delete
191
191
  try {
192
192
  const fullPath = join(cwd, item.path);
193
- if (item.type === 'dir') {
193
+ // Special-case: `.claude/` is scanned and removed as a single unit,
194
+ // but KEEP_CONFIG_PATHS promises `.claude/settings.json` survives
195
+ // --keep-config. Back the file up, wipe the directory, then
196
+ // restore just that one file — the rest of `.claude/` is still
197
+ // removed as normal.
198
+ const settingsPath = join(cwd, '.claude', 'settings.json');
199
+ const isClaudeDirWithPreservedSettings = item.type === 'dir' && item.path === '.claude' && keepConfig && existsSync(settingsPath);
200
+ if (isClaudeDirWithPreservedSettings) {
201
+ const settingsBackup = readFileSync(settingsPath);
194
202
  rmSync(fullPath, { recursive: true, force: true });
203
+ mkdirSync(dirname(settingsPath), { recursive: true });
204
+ writeFileSync(settingsPath, settingsBackup);
205
+ output.writeln(output.success(` [removed] ${typeLabel} ${item.path} (${sizeStr}) - ${item.description}`));
206
+ output.writeln(output.dim(` [kept] file .claude/settings.json - preserved (--keep-config)`));
207
+ }
208
+ else if (item.type === 'dir') {
209
+ rmSync(fullPath, { recursive: true, force: true });
210
+ output.writeln(output.success(` [removed] ${typeLabel} ${item.path} (${sizeStr}) - ${item.description}`));
195
211
  }
196
212
  else {
197
213
  rmSync(fullPath, { force: true });
214
+ output.writeln(output.success(` [removed] ${typeLabel} ${item.path} (${sizeStr}) - ${item.description}`));
198
215
  }
199
- output.writeln(output.success(` [removed] ${typeLabel} ${item.path} (${sizeStr}) - ${item.description}`));
200
216
  removedCount++;
201
217
  removedSize += item.size;
202
218
  }