@monoes/monomindcli 1.9.17 → 1.10.0

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 (118) hide show
  1. package/.claude/commands/mastermind/_repeat.md +182 -39
  2. package/.claude/commands/mastermind/architect.md +17 -11
  3. package/.claude/commands/mastermind/brain.md +4 -0
  4. package/.claude/commands/mastermind/build.md +4 -0
  5. package/.claude/commands/mastermind/content.md +4 -0
  6. package/.claude/commands/mastermind/createorg.md +5 -3
  7. package/.claude/commands/mastermind/finance.md +4 -0
  8. package/.claude/commands/mastermind/idea.md +4 -0
  9. package/.claude/commands/mastermind/marketing.md +4 -0
  10. package/.claude/commands/mastermind/master.md +63 -37
  11. package/.claude/commands/mastermind/ops.md +4 -0
  12. package/.claude/commands/mastermind/release.md +4 -0
  13. package/.claude/commands/mastermind/research.md +4 -0
  14. package/.claude/commands/mastermind/review.md +4 -0
  15. package/.claude/commands/mastermind/runorg.md +5 -3
  16. package/.claude/commands/mastermind/sales.md +4 -0
  17. package/.claude/commands/mastermind/techport.md +9 -0
  18. package/.claude/commands/monomind/do.md +5 -1
  19. package/.claude/commands/monomind/idea.md +5 -1
  20. package/.claude/commands/monomind/improve.md +5 -1
  21. package/.claude/commands/monomind/repeat.md +85 -29
  22. package/.claude/commands/monomind/review.md +6 -2
  23. package/.claude/commands/monomind/understand.md +10 -8
  24. package/.claude/helpers/extras-registry.json +235 -235
  25. package/.claude/helpers/graphify-freshen.cjs +13 -1
  26. package/.claude/helpers/hook-handler.cjs +1 -1
  27. package/.claude/helpers/router.cjs +4 -1
  28. package/.claude/skills/mastermind/_protocol.md +28 -21
  29. package/.claude/skills/mastermind/access.md +236 -0
  30. package/.claude/skills/mastermind/activity.md +191 -0
  31. package/.claude/skills/mastermind/adapter-manager.md +259 -0
  32. package/.claude/skills/mastermind/adapters.md +204 -0
  33. package/.claude/skills/mastermind/agent-detail.md +242 -0
  34. package/.claude/skills/mastermind/agents.md +178 -0
  35. package/.claude/skills/mastermind/approval-detail.md +259 -0
  36. package/.claude/skills/mastermind/approve.md +181 -0
  37. package/.claude/skills/mastermind/architect.md +24 -8
  38. package/.claude/skills/mastermind/backup.md +197 -0
  39. package/.claude/skills/mastermind/bootstrap.md +190 -0
  40. package/.claude/skills/mastermind/budgets.md +237 -0
  41. package/.claude/skills/mastermind/companies.md +256 -0
  42. package/.claude/skills/mastermind/costs.md +151 -0
  43. package/.claude/skills/mastermind/createorg.md +23 -5
  44. package/.claude/skills/mastermind/diagnose.md +249 -0
  45. package/.claude/skills/mastermind/env.md +198 -0
  46. package/.claude/skills/mastermind/environments.md +250 -0
  47. package/.claude/skills/mastermind/export.md +324 -0
  48. package/.claude/skills/mastermind/goal-detail.md +255 -0
  49. package/.claude/skills/mastermind/goals.md +149 -0
  50. package/.claude/skills/mastermind/heartbeat.md +164 -0
  51. package/.claude/skills/mastermind/idea.md +250 -122
  52. package/.claude/skills/mastermind/import.md +281 -0
  53. package/.claude/skills/mastermind/inbox.md +214 -0
  54. package/.claude/skills/mastermind/instance-settings.md +315 -0
  55. package/.claude/skills/mastermind/instance.md +231 -0
  56. package/.claude/skills/mastermind/invite-landing.md +227 -0
  57. package/.claude/skills/mastermind/invites.md +254 -0
  58. package/.claude/skills/mastermind/issue-detail.md +291 -0
  59. package/.claude/skills/mastermind/issues.md +235 -0
  60. package/.claude/skills/mastermind/join-queue.md +170 -0
  61. package/.claude/skills/mastermind/liveness.md +392 -0
  62. package/.claude/skills/mastermind/memory.md +321 -0
  63. package/.claude/skills/mastermind/my-issues.md +146 -0
  64. package/.claude/skills/mastermind/new-agent.md +241 -0
  65. package/.claude/skills/mastermind/org-chart.md +207 -0
  66. package/.claude/skills/mastermind/org-settings.md +217 -0
  67. package/.claude/skills/mastermind/plan-to-tasks.md +136 -0
  68. package/.claude/skills/mastermind/plugin-manager.md +241 -0
  69. package/.claude/skills/mastermind/plugin-settings.md +273 -0
  70. package/.claude/skills/mastermind/plugins.md +190 -0
  71. package/.claude/skills/mastermind/profile.md +187 -0
  72. package/.claude/skills/mastermind/project-detail.md +249 -0
  73. package/.claude/skills/mastermind/project-workspace.md +244 -0
  74. package/.claude/skills/mastermind/projects.md +164 -0
  75. package/.claude/skills/mastermind/routine-detail.md +253 -0
  76. package/.claude/skills/mastermind/routines.md +202 -0
  77. package/.claude/skills/mastermind/runorg.md +74 -9
  78. package/.claude/skills/mastermind/search.md +186 -0
  79. package/.claude/skills/mastermind/secrets.md +199 -0
  80. package/.claude/skills/mastermind/skills.md +156 -0
  81. package/.claude/skills/mastermind/tasks.md +149 -0
  82. package/.claude/skills/mastermind/techport.md +5 -5
  83. package/.claude/skills/mastermind/threads.md +259 -0
  84. package/.claude/skills/mastermind/tree-control.md +250 -0
  85. package/.claude/skills/mastermind/wiki.md +314 -0
  86. package/.claude/skills/mastermind/workspace-detail.md +317 -0
  87. package/.claude/skills/mastermind/workspaces.md +261 -0
  88. package/.claude/skills/mastermind/worktree.md +187 -0
  89. package/dist/src/init/executor.js +8 -8
  90. package/dist/src/init/executor.js.map +1 -1
  91. package/dist/src/init/statusline-generator.d.ts.map +1 -1
  92. package/dist/src/init/statusline-generator.js +12 -0
  93. package/dist/src/init/statusline-generator.js.map +1 -1
  94. package/dist/src/ui/.monomind/data/ranked-context.json +1 -1
  95. package/dist/src/ui/.monomind/loops/mastermind-review-1778664132789.json +16 -0
  96. package/dist/src/ui/.monomind/sessions/current.json +5 -5
  97. package/dist/src/ui/.monomind/sessions/session-1776778451399.json +15 -0
  98. package/dist/src/ui/dashboard.html +3030 -181
  99. package/dist/src/ui/data/mastermind-events.jsonl +8 -0
  100. package/dist/src/ui/data/mastermind-sessions.json +1 -0
  101. package/dist/src/ui/server.mjs +738 -0
  102. package/dist/tsconfig.tsbuildinfo +1 -1
  103. package/package.json +1 -1
  104. package/.claude/skills/.monomind/data/ranked-context.json +0 -5
  105. package/.claude/skills/.monomind/sessions/current.json +0 -13
  106. package/.claude/skills/.monomind/sessions/session-1777829336455.json +0 -15
  107. package/.claude/skills/.monomind/sessions/session-1777831614725.json +0 -15
  108. package/.claude/skills/.monomind/sessions/session-1777832095857.json +0 -15
  109. package/.claude/skills/.monomind/sessions/session-1777839814183.json +0 -15
  110. package/.claude/skills/.monomind/sessions/session-1777841847131.json +0 -15
  111. package/.claude/skills/.monomind/sessions/session-1777843309463.json +0 -15
  112. package/.claude/skills/.monomind/sessions/session-1777880867159.json +0 -15
  113. package/.claude/skills/.monomind/sessions/session-1777881884593.json +0 -15
  114. package/.claude/skills/.monomind/sessions/session-1777884090471.json +0 -15
  115. package/.claude/skills/.monomind/sessions/session-1777884808221.json +0 -15
  116. package/.claude/skills/.monomind/sessions/session-1777885672155.json +0 -15
  117. package/.claude/skills/.monomind/sessions/session-1777886852818.json +0 -15
  118. package/.claude/skills/.monomind/sessions/session-1777896532690.json +0 -15
@@ -0,0 +1,259 @@
1
+ ---
2
+ name: mastermind-adapter-manager
3
+ description: Mastermind adapter-manager — global instance-level adapter catalog. Lists all built-in and npm-installed adapters, enables/disables them in menus, reinstalls from npm to pick up updates, adds custom HTTP adapters, and removes custom ones. Complements mastermind:adapters (per-org) with the global registry. Mirrors AdapterManager.tsx.
4
+ type: domain-skill
5
+ default_mode: confirm
6
+ ---
7
+
8
+ # Mastermind Adapter Manager
9
+
10
+ This skill is invoked by `mastermind:adapter-manager` or directly via `/mastermind:adapter-manager`.
11
+
12
+ ---
13
+
14
+ ## Inputs
15
+
16
+ - `brain_context`: BRAIN CONTEXT block (injected by command, or loaded below if standalone)
17
+ - `action`: list | enable | disable | reinstall | add-http | remove | check-update
18
+ - `adapter_type`: adapter type slug (required for enable/disable/reinstall/remove)
19
+ - `http_url`: base URL for the HTTP adapter endpoint (for add-http)
20
+ - `http_name`: display name for the HTTP adapter (for add-http)
21
+ - `http_label`: short label (for add-http; default: http_name)
22
+ - `caller`: command | master
23
+
24
+ ---
25
+
26
+ ## Adapter Registry Fields
27
+
28
+ ```json
29
+ {
30
+ "type": "adapter-slug",
31
+ "label": "Display Name",
32
+ "source": "built-in | npm | http",
33
+ "packageName": "@paperclipai/adapter-name",
34
+ "version": "1.2.0",
35
+ "modelsCount": 3,
36
+ "disabled": false,
37
+ "isBuiltIn": true,
38
+ "installedAt": "2026-01-01T00:00:00Z"
39
+ }
40
+ ```
41
+
42
+ ---
43
+
44
+ ## Built-in Adapter Types
45
+
46
+ | Type | Label | Notes |
47
+ |------|-------|-------|
48
+ | `claude-local` | Claude (local CLI) | Default |
49
+ | `gemini-local` | Gemini (local) | |
50
+ | `codex-local` | Codex (OpenAI Codex CLI) | |
51
+ | `cursor` | Cursor IDE | |
52
+ | `opencode-local` | OpenCode | |
53
+ | `hermes-local` | Hermes (Ollama) | |
54
+ | `http` | Custom HTTP | Configurable endpoint |
55
+ | `acpx` | ACPX Protocol | |
56
+
57
+ ---
58
+
59
+ ## Step 0 — Brain Load (standalone only)
60
+
61
+ If `caller` is not "command", load brain context following _protocol.md Brain Load Procedure with namespace: `ops`.
62
+
63
+ ---
64
+
65
+ ## Step 1 — Load Global Adapter Registry
66
+
67
+ ```bash
68
+ adapterFile=".monomind/adapters/registry.json"
69
+ mkdir -p ".monomind/adapters"
70
+ if [ ! -f "$adapterFile" ]; then
71
+ cat > "$adapterFile" <<'EOF'
72
+ {
73
+ "adapters": [
74
+ {"type":"claude-local","label":"Claude (local CLI)","source":"built-in","isBuiltIn":true,"disabled":false,"modelsCount":3},
75
+ {"type":"gemini-local","label":"Gemini (local)","source":"built-in","isBuiltIn":true,"disabled":false,"modelsCount":2},
76
+ {"type":"codex-local","label":"Codex (OpenAI)","source":"built-in","isBuiltIn":true,"disabled":false,"modelsCount":3},
77
+ {"type":"cursor","label":"Cursor IDE","source":"built-in","isBuiltIn":true,"disabled":false,"modelsCount":1},
78
+ {"type":"opencode-local","label":"OpenCode","source":"built-in","isBuiltIn":true,"disabled":false,"modelsCount":1},
79
+ {"type":"hermes-local","label":"Hermes (Ollama)","source":"built-in","isBuiltIn":true,"disabled":false,"modelsCount":1},
80
+ {"type":"http","label":"Custom HTTP","source":"built-in","isBuiltIn":true,"disabled":true,"modelsCount":0},
81
+ {"type":"acpx","label":"ACPX Protocol","source":"built-in","isBuiltIn":true,"disabled":true,"modelsCount":0}
82
+ ]
83
+ }
84
+ EOF
85
+ fi
86
+ ```
87
+
88
+ ---
89
+
90
+ ## Step 2 — Execute Action
91
+
92
+ ### list (default)
93
+
94
+ ```bash
95
+ echo "GLOBAL ADAPTER REGISTRY"
96
+ echo "────────────────────────────────────────────────────────"
97
+ printf "%-20s %-22s %-10s %-8s %-8s %s\n" "TYPE" "LABEL" "SOURCE" "MODELS" "STATUS" "VERSION"
98
+ echo "────────────────────────────────────────────────────────"
99
+
100
+ jq -r '.adapters[] |
101
+ [.type, (.label // .type), (.source // "built-in"),
102
+ ((.modelsCount // 0) | tostring),
103
+ (if .disabled then "disabled" else "enabled" end),
104
+ (.version // "-")] | @tsv' \
105
+ "$adapterFile" | while IFS=$'\t' read -r type label src models status ver; do
106
+ printf "%-20s %-22s %-10s %-8s %-8s %s\n" "$type" "$label" "$src" "$models" "$status" "$ver"
107
+ done
108
+
109
+ total=$(jq '.adapters | length' "$adapterFile")
110
+ enabled=$(jq '[.adapters[] | select(.disabled == false or .disabled == null)] | length' "$adapterFile")
111
+ echo ""
112
+ echo " Total: $total | Enabled: $enabled | Disabled: $((total - enabled))"
113
+ echo ""
114
+ echo " To add a custom HTTP adapter: --action add-http --http-url http://localhost:8080 --http-name 'My Model'"
115
+ ```
116
+
117
+ ### enable
118
+
119
+ ```bash
120
+ [ -z "$adapter_type" ] && { echo "ERROR: --adapter-type required."; exit 1; }
121
+
122
+ exists=$(jq -r --arg t "$adapter_type" '[.adapters[] | select(.type == $t)] | length' "$adapterFile")
123
+ [ "$exists" -eq 0 ] && { echo "ERROR: Adapter '$adapter_type' not found. Use --action list to see available adapters."; exit 1; }
124
+
125
+ tmp="${adapterFile}.tmp"
126
+ jq --arg t "$adapter_type" \
127
+ '.adapters = [.adapters[] | if .type == $t then .disabled = false else . end]' \
128
+ "$adapterFile" > "$tmp" && mv "$tmp" "$adapterFile"
129
+
130
+ echo "Adapter '$adapter_type' ENABLED — will appear in agent model menus."
131
+ ```
132
+
133
+ ### disable
134
+
135
+ ```bash
136
+ [ -z "$adapter_type" ] && { echo "ERROR: --adapter-type required."; exit 1; }
137
+
138
+ isBuiltIn=$(jq -r --arg t "$adapter_type" '.adapters[] | select(.type == $t) | .isBuiltIn // false' "$adapterFile")
139
+
140
+ tmp="${adapterFile}.tmp"
141
+ jq --arg t "$adapter_type" \
142
+ '.adapters = [.adapters[] | if .type == $t then .disabled = true else . end]' \
143
+ "$adapterFile" > "$tmp" && mv "$tmp" "$adapterFile"
144
+
145
+ echo "Adapter '$adapter_type' DISABLED — hidden from model menus."
146
+ [ "$isBuiltIn" = "true" ] && echo " NOTE: Built-in adapter disabled but not removed. Re-enable with --action enable."
147
+ ```
148
+
149
+ ### reinstall
150
+
151
+ ```bash
152
+ [ -z "$adapter_type" ] && { echo "ERROR: --adapter-type required."; exit 1; }
153
+
154
+ pkg=$(jq -r --arg t "$adapter_type" '.adapters[] | select(.type == $t) | .packageName // ""' "$adapterFile")
155
+ [ -z "$pkg" ] && { echo "ERROR: Adapter '$adapter_type' has no packageName — cannot reinstall. Only npm-installed adapters support reinstall."; exit 1; }
156
+
157
+ echo "REINSTALL — $adapter_type from $pkg"
158
+ echo "────────────────────────────────────────────────────────"
159
+ echo " Running: npm install $pkg"
160
+
161
+ if npm install "$pkg" 2>&1 | tail -5; then
162
+ newVer=$(node -e "try{console.log(require('$pkg/package.json').version)}catch(e){console.log('unknown')}" 2>/dev/null)
163
+ ts=$(date -u +%Y-%m-%dT%H:%M:%SZ)
164
+ tmp="${adapterFile}.tmp"
165
+ jq --arg t "$adapter_type" --arg v "$newVer" --arg ts "$ts" \
166
+ '.adapters = [.adapters[] | if .type == $t then .version = $v | .reinstalledAt = $ts else . end]' \
167
+ "$adapterFile" > "$tmp" && mv "$tmp" "$adapterFile"
168
+ echo " Reinstalled: $adapter_type @ $newVer"
169
+ else
170
+ echo " ERROR: npm install failed. Check your network and package name."
171
+ fi
172
+ ```
173
+
174
+ ### add-http
175
+
176
+ ```bash
177
+ [ -z "$http_url" ] && { echo "ERROR: --http-url required (e.g. http://localhost:8080)."; exit 1; }
178
+ [ -z "$http_name" ] && { echo "ERROR: --http-name required (display name for this adapter)."; exit 1; }
179
+
180
+ # Validate URL
181
+ echo "$http_url" | grep -qE '^https?://' || { echo "ERROR: --http-url must start with http:// or https://"; exit 1; }
182
+
183
+ # Generate slug from name
184
+ slug=$(echo "${http_name}" | tr '[:upper:]' '[:lower:]' | tr -cs 'a-z0-9' '-' | sed 's/^-//;s/-$//')
185
+ slug="http-${slug}"
186
+
187
+ # Check for duplicate
188
+ dup=$(jq -r --arg t "$slug" '[.adapters[] | select(.type == $t)] | length' "$adapterFile")
189
+ [ "$dup" -gt 0 ] && { echo "ERROR: Adapter slug '$slug' already exists. Remove first: --action remove --adapter-type $slug"; exit 1; }
190
+
191
+ ts=$(date -u +%Y-%m-%dT%H:%M:%SZ)
192
+ tmp="${adapterFile}.tmp"
193
+ jq --arg type "$slug" \
194
+ --arg label "${http_label:-$http_name}" \
195
+ --arg url "$http_url" \
196
+ --arg ts "$ts" \
197
+ '.adapters += [{"type":$type,"label":$label,"source":"http","isBuiltIn":false,"disabled":false,"modelsCount":0,"httpUrl":$url,"installedAt":$ts}]' \
198
+ "$adapterFile" > "$tmp" && mv "$tmp" "$adapterFile"
199
+
200
+ echo "HTTP adapter added: $slug"
201
+ echo " Label: ${http_label:-$http_name}"
202
+ echo " URL: $http_url"
203
+ echo " Slug: $slug"
204
+ echo " Status: enabled"
205
+ ```
206
+
207
+ ### remove
208
+
209
+ ```bash
210
+ [ -z "$adapter_type" ] && { echo "ERROR: --adapter-type required."; exit 1; }
211
+
212
+ isBuiltIn=$(jq -r --arg t "$adapter_type" '.adapters[] | select(.type == $t) | .isBuiltIn // false' "$adapterFile")
213
+ [ "$isBuiltIn" = "true" ] && { echo "ERROR: Cannot remove built-in adapter '$adapter_type'. Use --action disable instead."; exit 1; }
214
+
215
+ tmp="${adapterFile}.tmp"
216
+ jq --arg t "$adapter_type" \
217
+ '.adapters = [.adapters[] | select(.type != $t)]' \
218
+ "$adapterFile" > "$tmp" && mv "$tmp" "$adapterFile"
219
+
220
+ echo "Adapter '$adapter_type' removed from registry."
221
+ ```
222
+
223
+ ### check-update
224
+
225
+ ```bash
226
+ echo "CHECKING FOR ADAPTER UPDATES"
227
+ echo "────────────────────────────────────────────────────────"
228
+
229
+ jq -r '.adapters[] | select(.packageName != null and .packageName != "") |
230
+ [.type, .packageName, (.version // "unknown")] | @tsv' \
231
+ "$adapterFile" | while IFS=$'\t' read -r type pkg ver; do
232
+ latest=$(curl -sf "https://registry.npmjs.org/${pkg}/latest" 2>/dev/null | jq -r '.version // "?"' 2>/dev/null || echo "?")
233
+ if [ "$latest" != "?" ] && [ "$latest" != "$ver" ]; then
234
+ echo " [$type] $ver → $latest (update available: npm install $pkg)"
235
+ else
236
+ echo " [$type] $ver (up to date)"
237
+ fi
238
+ done
239
+
240
+ npmCount=$(jq '[.adapters[] | select(.packageName != null)] | length' "$adapterFile")
241
+ [ "$npmCount" -eq 0 ] && echo " No npm-installed adapters to check."
242
+ ```
243
+
244
+ ---
245
+
246
+ ## Step 3 — Return Output
247
+
248
+ ```yaml
249
+ domain: ops
250
+ status: complete
251
+ action: <action>
252
+ adapter_type: <type>
253
+ ```
254
+
255
+ ---
256
+
257
+ ## Step 4 — Brain Write (standalone only)
258
+
259
+ If `caller` is not "command", follow _protocol.md Brain Write Procedure for domain `ops`.
@@ -0,0 +1,204 @@
1
+ ---
2
+ name: mastermind-adapters
3
+ description: Mastermind adapters — install, enable, disable, reload, and remove LLM adapter plugins per org. Supports claude-local, gemini-local, codex-local, cursor, hermes, http, and custom adapters.
4
+ type: domain-skill
5
+ default_mode: confirm
6
+ ---
7
+
8
+ # Mastermind Adapters
9
+
10
+ This skill is invoked by `mastermind:adapters` or directly via `/mastermind:adapters`.
11
+
12
+ ---
13
+
14
+ ## Inputs
15
+
16
+ - `brain_context`: BRAIN CONTEXT block (injected by command, or loaded below if standalone)
17
+ - `org_name`: org to manage adapters for (required)
18
+ - `action`: list | enable | disable | install | remove | reload | set-default
19
+ - `adapter_type`: adapter slug (e.g. `claude-local`, `gemini-local`, `http`) — required for most actions
20
+ - `package_name`: npm package name or local path (required for `install`)
21
+ - `caller`: command | master
22
+
23
+ ---
24
+
25
+ ## Step 0 — Brain Load (standalone only)
26
+
27
+ If `caller` is not "command", load brain context following _protocol.md Brain Load Procedure with namespace: `ops`.
28
+
29
+ ---
30
+
31
+ ## Built-in Adapter Registry
32
+
33
+ | Type | Label | Source | Notes |
34
+ |------|-------|--------|-------|
35
+ | `claude-local` | Claude (local CLI) | built-in | Uses `claude` CLI |
36
+ | `claude-opus-4-7` | Claude Opus 4.7 | built-in | High capability |
37
+ | `claude-sonnet-4-6` | Claude Sonnet 4.6 | built-in | Balanced (default) |
38
+ | `claude-haiku-4-5` | Claude Haiku 4.5 | built-in | Fast, low cost |
39
+ | `gemini-local` | Gemini (local) | built-in | Uses `gemini` CLI |
40
+ | `codex-local` | Codex (local) | built-in | Uses `codex` CLI |
41
+ | `cursor` | Cursor | built-in | Uses Cursor agent |
42
+ | `hermes-local` | Hermes (local) | built-in | Local Hermes LLM |
43
+ | `http` | HTTP Adapter | built-in | Generic HTTP endpoint |
44
+ | `acpx-local` | ACPX (local) | built-in | ACPX protocol |
45
+
46
+ ---
47
+
48
+ ## Step 1 — Load Adapter Registry
49
+
50
+ ```bash
51
+ orgFile=".monomind/orgs/${org_name}.json"
52
+ [ ! -f "$orgFile" ] && { echo "ERROR: Org '${org_name}' not found."; exit 1; }
53
+
54
+ adaptersFile=".monomind/orgs/${org_name}-adapters.json"
55
+ if [ ! -f "$adaptersFile" ]; then
56
+ # Bootstrap from org config adapter_config if present
57
+ defaultModel=$(jq -r '.run_config.ceo_adapter // "claude-sonnet-4-6"' "$orgFile")
58
+ cat > "$adaptersFile" <<EOF
59
+ {
60
+ "org": "${org_name}",
61
+ "default_adapter": "${defaultModel}",
62
+ "adapters": [
63
+ {"type":"claude-local","label":"Claude (local CLI)","source":"built-in","disabled":false,"modelsCount":3},
64
+ {"type":"gemini-local","label":"Gemini (local)","source":"built-in","disabled":false,"modelsCount":1},
65
+ {"type":"http","label":"HTTP Adapter","source":"built-in","disabled":true,"modelsCount":0}
66
+ ]
67
+ }
68
+ EOF
69
+ fi
70
+ ```
71
+
72
+ ---
73
+
74
+ ## Step 2 — Execute Action
75
+
76
+ ### list (default)
77
+
78
+ ```bash
79
+ echo "ADAPTERS — org: $org_name"
80
+ echo "──────────────────────────────────────────────────────"
81
+ printf "%-22s %-28s %-10s %-8s %s\n" "TYPE" "LABEL" "SOURCE" "MODELS" "STATUS"
82
+ echo "──────────────────────────────────────────────────────"
83
+
84
+ defaultAdap=$(jq -r '.default_adapter // "claude-sonnet-4-6"' "$adaptersFile")
85
+
86
+ jq -r --arg def "$defaultAdap" '
87
+ .adapters[] |
88
+ [.type, (.label // .type), (.source // "built-in"), (.modelsCount // 0 | tostring),
89
+ (if .disabled then "DISABLED" else "ACTIVE" end),
90
+ (if .type == $def then " ← default" else "" end)]
91
+ | @tsv
92
+ ' "$adaptersFile" | while IFS=$'\t' read -r type label source models status def; do
93
+ printf "%-22s %-28s %-10s %-8s %s%s\n" "$type" "$label" "$source" "$models" "$status" "$def"
94
+ done
95
+
96
+ echo ""
97
+ echo "Default adapter: $defaultAdap"
98
+ echo "External adapters: $(jq '[.adapters[] | select(.source == "external")] | length' "$adaptersFile")"
99
+ ```
100
+
101
+ ### enable / disable
102
+
103
+ ```bash
104
+ action_status=$([ "$action" = "enable" ] && echo "false" || echo "true")
105
+ tmp="${adaptersFile}.tmp"
106
+ jq --arg type "$adapter_type" --argjson dis "$action_status" \
107
+ '.adapters = [.adapters[] | if .type == $type then .disabled = $dis else . end]' \
108
+ "$adaptersFile" > "$tmp" && mv "$tmp" "$adaptersFile"
109
+
110
+ # If re-enabling, also check org config adapter_config for matching roles
111
+ echo "Adapter '$adapter_type' → $([ "$action" = "enable" ] && echo 'ACTIVE' || echo 'DISABLED')"
112
+ ```
113
+
114
+ ### install
115
+
116
+ Add an external adapter (npm package or local path):
117
+
118
+ ```bash
119
+ [ -z "$package_name" ] && { echo "ERROR: --package-name required."; exit 1; }
120
+ [ -z "$adapter_type" ] && adapter_type=$(echo "$package_name" | sed 's/[@/].*$//' | tr '-' '_')
121
+
122
+ isLocal=false
123
+ [[ "$package_name" == /* || "$package_name" == "./"* ]] && isLocal=true
124
+
125
+ tmp="${adaptersFile}.tmp"
126
+ jq --arg type "$adapter_type" \
127
+ --arg pkg "$package_name" \
128
+ --argjson local "$isLocal" \
129
+ '.adapters = [.adapters[] | select(.type != $type)] +
130
+ [{"type":$type,"label":$pkg,"source":"external","packageName":$pkg,"isLocalPath":$local,
131
+ "disabled":false,"modelsCount":0,"installedAt":(now|todate)}]' \
132
+ "$adaptersFile" > "$tmp" && mv "$tmp" "$adaptersFile"
133
+ echo "Installed: $package_name as adapter type '$adapter_type'"
134
+ echo "NOTE: Restart the org run to activate the new adapter."
135
+ ```
136
+
137
+ Emit `org:adapter:installed` event:
138
+
139
+ ```bash
140
+ REPO_ROOT=$(git rev-parse --show-toplevel 2>/dev/null || pwd)
141
+ CTRL_URL=$(jq -r '.url // "http://localhost:4242"' "$REPO_ROOT/.monomind/control.json" 2>/dev/null || echo "http://localhost:4242")
142
+ curl -s -X POST "${CTRL_URL}/api/mastermind/event" \
143
+ -H "Content-Type: application/json" \
144
+ -d "$(jq -cn --arg org "$org_name" --arg type "$adapter_type" --arg pkg "$package_name" \
145
+ '{type:"org:adapter:installed",org:$org,adapter:$type,package:$pkg,ts:(now*1000|floor)}')" || true
146
+ ```
147
+
148
+ ### remove
149
+
150
+ ```bash
151
+ [ -z "$adapter_type" ] && { echo "ERROR: --adapter-type required."; exit 1; }
152
+
153
+ # Verify it's external
154
+ src=$(jq -r --arg t "$adapter_type" '.adapters[] | select(.type == $t) | .source' "$adaptersFile" 2>/dev/null)
155
+ [ "$src" = "built-in" ] && { echo "ERROR: Cannot remove built-in adapters. Use 'disable' instead."; exit 1; }
156
+ [ -z "$src" ] && { echo "ERROR: Adapter '$adapter_type' not found."; exit 1; }
157
+
158
+ tmp="${adaptersFile}.tmp"
159
+ jq --arg type "$adapter_type" '.adapters = [.adapters[] | select(.type != $type)]' \
160
+ "$adaptersFile" > "$tmp" && mv "$tmp" "$adaptersFile"
161
+ echo "Removed adapter: $adapter_type"
162
+ ```
163
+
164
+ ### set-default
165
+
166
+ ```bash
167
+ [ -z "$adapter_type" ] && { echo "ERROR: --adapter-type required."; exit 1; }
168
+ tmp="${adaptersFile}.tmp"
169
+ jq --arg type "$adapter_type" '.default_adapter = $type' "$adaptersFile" > "$tmp" && mv "$tmp" "$adaptersFile"
170
+ # Sync to org run_config as well
171
+ orgTmp="${orgFile}.tmp"
172
+ jq --arg model "$adapter_type" '.run_config.ceo_adapter = $model' "$orgFile" > "$orgTmp" && mv "$orgTmp" "$orgFile"
173
+ echo "Default adapter set to: $adapter_type"
174
+ ```
175
+
176
+ ### reload
177
+
178
+ Force a reload hint (marks adapter as needing restart):
179
+
180
+ ```bash
181
+ tmp="${adaptersFile}.tmp"
182
+ jq --arg type "$adapter_type" --arg ts "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
183
+ '.adapters = [.adapters[] | if .type == $type then .last_reload = $ts else . end]' \
184
+ "$adaptersFile" > "$tmp" && mv "$tmp" "$adaptersFile"
185
+ echo "Marked adapter '$adapter_type' for reload. Restart the org run to apply."
186
+ ```
187
+
188
+ ---
189
+
190
+ ## Step 3 — Return Output
191
+
192
+ ```yaml
193
+ domain: ops
194
+ status: complete
195
+ action: <action>
196
+ org: <org_name>
197
+ adapter_type: <adapter_type if applicable>
198
+ ```
199
+
200
+ ---
201
+
202
+ ## Step 4 — Brain Write (standalone only)
203
+
204
+ If `caller` is not "command", follow _protocol.md Brain Write Procedure for domain `ops`.