monomind 2.2.0 → 2.3.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 (90) hide show
  1. package/package.json +2 -2
  2. package/packages/@monomind/cli/.claude/commands/mastermind/createorg.md +24 -16
  3. package/packages/@monomind/cli/.claude/commands/mastermind/master.md +23 -7
  4. package/packages/@monomind/cli/.claude/commands/mastermind/runorg.md +3 -1
  5. package/packages/@monomind/cli/.claude/commands/mastermind/stoporg.md +6 -3
  6. package/packages/@monomind/cli/.claude/skills/mastermind-skills/code-quality-reviewer-prompt.md +3 -3
  7. package/packages/@monomind/cli/.claude/skills/mastermind-skills/createorg.md +19 -24
  8. package/packages/@monomind/cli/.claude/skills/mastermind-skills/debug.md +49 -4
  9. package/packages/@monomind/cli/.claude/skills/mastermind-skills/design.md +11 -10
  10. package/packages/@monomind/cli/.claude/skills/mastermind-skills/final-reviewer-prompt.md +144 -0
  11. package/packages/@monomind/cli/.claude/skills/mastermind-skills/implementer-prompt.md +9 -4
  12. package/packages/@monomind/cli/.claude/skills/mastermind-skills/org-settings.md +20 -2
  13. package/packages/@monomind/cli/.claude/skills/mastermind-skills/orgs.md +40 -19
  14. package/packages/@monomind/cli/.claude/skills/mastermind-skills/orgstatus.md +90 -41
  15. package/packages/@monomind/cli/.claude/skills/mastermind-skills/plan.md +19 -0
  16. package/packages/@monomind/cli/.claude/skills/mastermind-skills/skill-builder.md +171 -0
  17. package/packages/@monomind/cli/.claude/skills/mastermind-skills/spec-reviewer-prompt.md +19 -2
  18. package/packages/@monomind/cli/.claude/skills/mastermind-skills/stoporg.md +7 -5
  19. package/packages/@monomind/cli/.claude/skills/mastermind-skills/taskdev.md +83 -15
  20. package/packages/@monomind/cli/.claude/skills/mastermind-skills/tdd.md +30 -0
  21. package/packages/@monomind/cli/dist/src/autopilot-state.js +6 -4
  22. package/packages/@monomind/cli/dist/src/browser/dashboard/server.js +4 -1
  23. package/packages/@monomind/cli/dist/src/capabilities/manager.js +3 -1
  24. package/packages/@monomind/cli/dist/src/commands/agent-lifecycle.js +26 -0
  25. package/packages/@monomind/cli/dist/src/commands/agent-ops.js +28 -46
  26. package/packages/@monomind/cli/dist/src/commands/cleanup.d.ts +18 -0
  27. package/packages/@monomind/cli/dist/src/commands/cleanup.js +120 -0
  28. package/packages/@monomind/cli/dist/src/commands/doctor-project-checks.js +13 -4
  29. package/packages/@monomind/cli/dist/src/commands/hooks-routing-commands.js +34 -18
  30. package/packages/@monomind/cli/dist/src/commands/hooks-workers.js +8 -2
  31. package/packages/@monomind/cli/dist/src/commands/hooks.js +1 -1
  32. package/packages/@monomind/cli/dist/src/commands/mcp.js +4 -1
  33. package/packages/@monomind/cli/dist/src/commands/memory-admin.js +7 -1
  34. package/packages/@monomind/cli/dist/src/commands/org-observe.d.ts +18 -0
  35. package/packages/@monomind/cli/dist/src/commands/org-observe.js +295 -0
  36. package/packages/@monomind/cli/dist/src/commands/org.d.ts +9 -1
  37. package/packages/@monomind/cli/dist/src/commands/org.js +191 -9
  38. package/packages/@monomind/cli/dist/src/commands/performance.js +4 -1
  39. package/packages/@monomind/cli/dist/src/commands/platforms.js +4 -1
  40. package/packages/@monomind/cli/dist/src/commands/security-scan.js +8 -2
  41. package/packages/@monomind/cli/dist/src/commands/start.js +4 -1
  42. package/packages/@monomind/cli/dist/src/commands/swarm.js +3 -2
  43. package/packages/@monomind/cli/dist/src/index.js +13 -3
  44. package/packages/@monomind/cli/dist/src/init/executor.js +19 -5
  45. package/packages/@monomind/cli/dist/src/knowledge/document-pipeline.js +3 -2
  46. package/packages/@monomind/cli/dist/src/mcp-tools/agent-tools.d.ts +1 -0
  47. package/packages/@monomind/cli/dist/src/mcp-tools/agent-tools.js +63 -20
  48. package/packages/@monomind/cli/dist/src/mcp-tools/claims-tools.js +3 -1
  49. package/packages/@monomind/cli/dist/src/mcp-tools/config-tools.js +3 -2
  50. package/packages/@monomind/cli/dist/src/mcp-tools/daa-tools.js +3 -2
  51. package/packages/@monomind/cli/dist/src/mcp-tools/embeddings-tools.js +6 -2
  52. package/packages/@monomind/cli/dist/src/mcp-tools/github-tools.js +35 -10
  53. package/packages/@monomind/cli/dist/src/mcp-tools/hive-mind-tools.js +24 -7
  54. package/packages/@monomind/cli/dist/src/mcp-tools/hooks-embedding.js +13 -3
  55. package/packages/@monomind/cli/dist/src/mcp-tools/hooks-intelligence.js +9 -3
  56. package/packages/@monomind/cli/dist/src/mcp-tools/hooks-routing.d.ts +1 -0
  57. package/packages/@monomind/cli/dist/src/mcp-tools/hooks-routing.js +112 -10
  58. package/packages/@monomind/cli/dist/src/mcp-tools/hooks-tools.js +2 -1
  59. package/packages/@monomind/cli/dist/src/mcp-tools/monograph-tools.js +8 -2
  60. package/packages/@monomind/cli/dist/src/mcp-tools/performance-tools.js +3 -2
  61. package/packages/@monomind/cli/dist/src/mcp-tools/session-tools.js +15 -5
  62. package/packages/@monomind/cli/dist/src/mcp-tools/swarm-tools.js +4 -1
  63. package/packages/@monomind/cli/dist/src/mcp-tools/system-tools.js +6 -4
  64. package/packages/@monomind/cli/dist/src/mcp-tools/task-tools.d.ts +20 -0
  65. package/packages/@monomind/cli/dist/src/mcp-tools/task-tools.js +38 -16
  66. package/packages/@monomind/cli/dist/src/mcp-tools/terminal-tools.d.ts +2 -0
  67. package/packages/@monomind/cli/dist/src/mcp-tools/terminal-tools.js +41 -24
  68. package/packages/@monomind/cli/dist/src/memory/ewc-consolidation.js +6 -2
  69. package/packages/@monomind/cli/dist/src/memory/intelligence.js +32 -10
  70. package/packages/@monomind/cli/dist/src/memory/memory-bridge.js +16 -4
  71. package/packages/@monomind/cli/dist/src/memory/memory-crud.js +26 -2
  72. package/packages/@monomind/cli/dist/src/memory/memory-initializer.js +3 -2
  73. package/packages/@monomind/cli/dist/src/memory/memory-migrations.js +2 -0
  74. package/packages/@monomind/cli/dist/src/monovector/command-outcomes.js +4 -1
  75. package/packages/@monomind/cli/dist/src/orgrt/bus.js +4 -1
  76. package/packages/@monomind/cli/dist/src/orgrt/daemon.js +74 -19
  77. package/packages/@monomind/cli/dist/src/orgrt/inbox.js +3 -1
  78. package/packages/@monomind/cli/dist/src/orgrt/reporting.d.ts +40 -0
  79. package/packages/@monomind/cli/dist/src/orgrt/reporting.js +127 -0
  80. package/packages/@monomind/cli/dist/src/orgrt/session.d.ts +2 -0
  81. package/packages/@monomind/cli/dist/src/orgrt/session.js +10 -2
  82. package/packages/@monomind/cli/dist/src/orgrt/templates.d.ts +16 -0
  83. package/packages/@monomind/cli/dist/src/orgrt/templates.js +57 -0
  84. package/packages/@monomind/cli/dist/src/services/config-file-manager.js +10 -1
  85. package/packages/@monomind/cli/dist/src/transfer/storage/gcs.js +6 -2
  86. package/packages/@monomind/cli/dist/src/ui/orgs.html +32 -0
  87. package/packages/@monomind/cli/dist/src/ui/server.mjs +25 -0
  88. package/packages/@monomind/cli/dist/src/update/executor.js +3 -1
  89. package/packages/@monomind/cli/dist/src/update/rate-limiter.js +3 -1
  90. package/packages/@monomind/cli/package.json +2 -2
@@ -42,34 +42,51 @@ fi
42
42
 
43
43
  ## Step 2 — Render Org Table
44
44
 
45
- For each org file (skip state/approvals files), extract and display:
45
+ For each org file (skip state/approvals files), extract and display. v2 orgs
46
+ (Org Runtime v2, the default since 2026-07) carry `schedule` ("30m"/"2h") in the
47
+ config and their live state in `.monomind/orgs/<name>/runtime.json`; only legacy
48
+ v1 orgs have a `.loop` block.
46
49
 
47
50
  ```bash
48
51
  echo ""
49
- printf "%-28s %-10s %-12s %-22s %-22s\n" "ORG" "STATUS" "SCHEDULE" "LAST RUN" "NEXT RUN"
50
- printf "%-28s %-10s %-12s %-22s %-22s\n" "---" "------" "--------" "--------" "--------"
52
+ printf "%-28s %-14s %-12s %-22s\n" "ORG" "STATUS" "SCHEDULE" "LAST RUN"
53
+ printf "%-28s %-14s %-12s %-22s\n" "---" "------" "--------" "--------"
51
54
 
52
55
  for f in $orgFiles; do
53
- name=$(jq -r '.name // "(unnamed)"' "$f" 2>/dev/null)
56
+ name=$(basename "$f" .json)
54
57
  goal=$(jq -r '.goal // ""' "$f" 2>/dev/null | cut -c1-55)
55
- status=$(jq -r '.status // "—"' "$f" 2>/dev/null)
56
- interval=$(jq -r 'if .loop.poll_interval_minutes then "\(.loop.poll_interval_minutes)m" else "manual" end' "$f" 2>/dev/null)
57
- last_run=$(jq -r '.loop.last_run // "—"' "$f" 2>/dev/null | sed 's/T/ /;s/Z//')
58
- next_run=$(jq -r '.loop.next_run // "—"' "$f" 2>/dev/null | sed 's/T/ /;s/Z//')
59
-
60
- # Status indicator — distinguish non-scheduled (manual) from scheduled loop states
61
- if [ "$interval" = "manual" ]; then
62
- indicator="■ persistent"
63
- else
58
+ schedule=$(jq -r '.schedule // empty' "$f" 2>/dev/null)
59
+ loop_interval=$(jq -r '.loop.poll_interval_minutes // empty' "$f" 2>/dev/null)
60
+
61
+ if [ -n "$loop_interval" ]; then
62
+ # legacy v1 scheduled org — state lives in the config's status field
63
+ interval="${loop_interval}m (v1)"
64
+ status=$(jq -r '.status // ""' "$f" 2>/dev/null)
64
65
  case "$status" in
65
66
  active) indicator="● active" ;;
66
- stopped) indicator="○ stopped" ;;
67
67
  paused) indicator="⏸ paused" ;;
68
- *) indicator=" unknown" ;;
68
+ *) indicator=" stopped" ;;
69
69
  esac
70
+ last_run=$(jq -r '.loop.last_run // "—"' "$f" 2>/dev/null | sed 's/T/ /;s/Z//')
71
+ else
72
+ # v2 org — live state is in runtime.json (crashed = running record, dead pid)
73
+ interval="${schedule:-manual}"
74
+ rt=".monomind/orgs/${name}/runtime.json"
75
+ rt_status=$(jq -r '.status // "never run"' "$rt" 2>/dev/null || echo "never run")
76
+ rt_pid=$(jq -r '.pid // 0' "$rt" 2>/dev/null || echo 0)
77
+ if [ "$rt_status" = "running" ] && [ "$rt_pid" -gt 0 ] && ! kill -0 "$rt_pid" 2>/dev/null; then
78
+ indicator="✗ crashed"
79
+ elif [ "$rt_status" = "running" ]; then
80
+ indicator="● running"
81
+ elif [ "$rt_status" = "never run" ]; then
82
+ indicator="· never run"
83
+ else
84
+ indicator="○ ${rt_status}"
85
+ fi
86
+ last_run=$(jq -r '.updated // "—"' "$rt" 2>/dev/null | sed 's/T/ /;s/\..*Z//' || echo "—")
70
87
  fi
71
-
72
- printf "%-28s %-10s %-12s %-22s %-22s\n" "$name" "$indicator" "$interval" "$last_run" "$next_run"
88
+
89
+ printf "%-28s %-14s %-12s %-22s\n" "$name" "$indicator" "$interval" "$last_run"
73
90
  echo " └ $goal"
74
91
  echo ""
75
92
  done
@@ -82,10 +99,14 @@ done
82
99
  ```
83
100
  COMMANDS
84
101
  ────────
102
+ monomind org run <name> Run an org once in the foreground
103
+ monomind org serve Host all scheduled orgs as a daemon
104
+ monomind org stop <name> Stop a running org
105
+ monomind org status [name] Runtime state (detects crashes)
106
+ monomind org validate [name] Check config against the runtime schema
85
107
  /mastermind:orgstatus --org <name> Detailed status, last runs, activity
86
- /mastermind:runorg --org <name> Start (or restart) a scheduled org
87
- /mastermind:stoporg --org <name> Stop a running scheduled org
88
108
  /mastermind:createorg <goal> Create a new org
109
+ /mastermind:runorg --org <name> (legacy v1 orgs only — deprecated)
89
110
  ```
90
111
 
91
112
  ---
@@ -39,20 +39,37 @@ orgFile=".monomind/orgs/${org_name}.json"
39
39
 
40
40
  ## Step 2 — Extract Fields
41
41
 
42
+ An org is **v2** (Org Runtime v2 — the default since 2026-07) when it has no
43
+ `.loop` block; its schedule is the top-level `schedule` field and its live state
44
+ is `.monomind/orgs/<name>/runtime.json`. Only legacy v1 orgs have `.loop`,
45
+ `topology`, `board_id`, or `agent_type` on roles.
46
+
42
47
  ```bash
43
48
  name=$(jq -r '.name // "(unnamed)"' "$orgFile")
44
49
  goal=$(jq -r '.goal // "(no goal set)"' "$orgFile")
45
50
  status=$(jq -r '.status // "no-schedule"' "$orgFile")
46
- topology=$(jq -r '.topology // "hierarchical"' "$orgFile")
47
51
  role_count=$(jq '.roles | length' "$orgFile")
48
52
  created_at=$(jq -r '.created_at // "-"' "$orgFile")
49
53
 
50
- # Loop fields (scheduled orgs only)
54
+ # v1 loop fields (legacy scheduled orgs only)
51
55
  has_schedule=$(jq -r 'if .loop.poll_interval_minutes then "yes" else "no" end' "$orgFile")
52
56
  poll_interval=$(jq -r '.loop.poll_interval_minutes // ""' "$orgFile")
53
57
  last_run=$(jq -r '.loop.last_run // "never"' "$orgFile")
54
58
  next_run=$(jq -r '.loop.next_run // "not scheduled"' "$orgFile")
55
59
  run_prompt_file=$(jq -r '.loop.run_prompt_file // ""' "$orgFile")
60
+
61
+ # v2 fields
62
+ is_v2=$([ "$has_schedule" = "no" ] && echo yes || echo no)
63
+ v2_schedule=$(jq -r '.schedule // empty' "$orgFile")
64
+ budget=$(jq -r '.run_config.budget_tokens // 1000000' "$orgFile")
65
+ rtFile=".monomind/orgs/${org_name}/runtime.json"
66
+ rt_status=$(jq -r '.status // "never run"' "$rtFile" 2>/dev/null || echo "never run")
67
+ rt_run=$(jq -r '.run // ""' "$rtFile" 2>/dev/null || echo "")
68
+ rt_pid=$(jq -r '.pid // 0' "$rtFile" 2>/dev/null || echo 0)
69
+ rt_updated=$(jq -r '.updated // "-"' "$rtFile" 2>/dev/null || echo "-")
70
+ if [ "$rt_status" = "running" ] && [ "$rt_pid" -gt 0 ] && ! kill -0 "$rt_pid" 2>/dev/null; then
71
+ rt_status="crashed (stale runtime.json, pid ${rt_pid} gone)"
72
+ fi
56
73
  ```
57
74
 
58
75
  ---
@@ -65,9 +82,19 @@ echo "ORG: $name"
65
82
  echo "════════════════════════════════════════════════"
66
83
  echo " Goal: $goal"
67
84
  echo " Created: $created_at"
68
- echo " Topology: $topology | Roles: $role_count"
85
+ echo " Roles: $role_count"
69
86
  echo ""
70
87
 
88
+ if [ "$is_v2" = "yes" ]; then
89
+ echo "RUNTIME (Org Runtime v2)"
90
+ echo "────────────────────────"
91
+ echo " Status: $rt_status${rt_run:+ (run $rt_run)}"
92
+ echo " Updated: $rt_updated"
93
+ echo " Schedule: ${v2_schedule:-manual — run with: monomind org run $name}"
94
+ echo " Budget: $budget tokens (split across roles)"
95
+ echo ""
96
+ fi
97
+
71
98
  if [ "$has_schedule" = "yes" ]; then
72
99
  echo "SCHEDULED LOOP"
73
100
  echo "──────────────"
@@ -88,22 +115,28 @@ fi
88
115
 
89
116
  echo "ROLES"
90
117
  echo "─────"
91
- jq -r '(.roles // [])[] | " • [\(.id)] \(.title) → \(.agent_type) (\(.reports_to // "top"))"' "$orgFile"
118
+ jq -r '(.roles // [])[] | " • [\(.id)] \(.title // .id) → \(.agent_type // .type // "specialist") (reports to: \(.reports_to // "top"))"' "$orgFile"
92
119
  echo ""
93
120
 
94
121
  echo "HEALTH"
95
122
  echo "──────"
96
123
 
97
- # Board / column IDs
98
- board_id=$(jq -r '.board_id // ""' "$orgFile")
99
- todo_col=$(jq -r '.todo_col_id // ""' "$orgFile")
100
- doing_col=$(jq -r '.doing_col_id // ""' "$orgFile")
101
- done_col=$(jq -r '.done_col_id // ""' "$orgFile")
102
-
103
- if [ -n "$board_id" ] && [ -n "$todo_col" ] && [ -n "$doing_col" ] && [ -n "$done_col" ]; then
104
- echo " Board: ✓ task board configured (${board_id})"
124
+ if [ "$is_v2" = "yes" ]; then
125
+ # v2 health = does the config still start? (schema + structural invariants)
126
+ npx -y monomind@latest org validate "$name" >/dev/null 2>&1 \
127
+ && echo " Config: ✓ valid (monomind org validate)" \
128
+ || echo " Config: ✗ INVALID run: monomind org validate $name"
105
129
  else
106
- echo " Board: task board IDs missing — re-run /mastermind:createorg --name ${name} to rebuild"
130
+ # v1 health: board / column IDs
131
+ board_id=$(jq -r '.board_id // ""' "$orgFile")
132
+ todo_col=$(jq -r '.todo_col_id // ""' "$orgFile")
133
+ doing_col=$(jq -r '.doing_col_id // ""' "$orgFile")
134
+ done_col=$(jq -r '.done_col_id // ""' "$orgFile")
135
+ if [ -n "$board_id" ] && [ -n "$todo_col" ] && [ -n "$doing_col" ] && [ -n "$done_col" ]; then
136
+ echo " Board: ✓ task board configured (${board_id})"
137
+ else
138
+ echo " Board: ✗ task board IDs missing — re-run /mastermind:createorg --name ${name} to rebuild"
139
+ fi
107
140
  fi
108
141
 
109
142
  # Pending approvals
@@ -117,9 +150,9 @@ else
117
150
  echo " Approvals: ✓ no approvals file"
118
151
  fi
119
152
 
120
- # Stop file (pending stop signal)
121
- stopFile=".monomind/orgs/.stops/${org_name}.stop"
122
- [ -f "$stopFile" ] && echo " Stop file: ⚠ PRESENT a stop signal is queued for this org"
153
+ # Stop file (pending stop signal) — v2 daemons poll <org>/stop; v1 used .stops/
154
+ [ -f ".monomind/orgs/${org_name}/stop" ] && echo " Stop file: ⚠ PRESENT (v2) — daemon will exit within 2s of seeing it"
155
+ [ -f ".monomind/orgs/.stops/${org_name}.stop" ] && echo " Stop file: ⚠ PRESENT (v1 legacy path)"
123
156
 
124
157
  # Loop prompt file (scheduled orgs)
125
158
  if [ "$has_schedule" = "yes" ]; then
@@ -137,17 +170,30 @@ echo ""
137
170
  ## Step 4 — Show Recent Activity (if available)
138
171
 
139
172
  ```bash
140
- activityFile=".monomind/orgs/${org_name}-activity.jsonl"
141
- if [ -f "$activityFile" ]; then
142
- echo "RECENT ACTIVITY (last 5)"
143
- echo "────────────────────────"
144
- tail -5 "$activityFile" | while IFS= read -r line; do
145
- ts=$(echo "$line" | jq -r '.ts // ""')
146
- type=$(echo "$line" | jq -r '.type // ""')
147
- pending=$(echo "$line" | jq -r '.pending // ""')
148
- echo " $ts $type ${pending:+pending=$pending}"
149
- done
150
- echo ""
173
+ if [ "$is_v2" = "yes" ]; then
174
+ # v2: the durable record is bus.jsonl inside the most recent run directory
175
+ latest_bus=$(ls -t .monomind/orgs/"${org_name}"/run-*/bus.jsonl 2>/dev/null | head -1)
176
+ if [ -n "$latest_bus" ]; then
177
+ echo "RECENT ACTIVITY (last 5 bus events — $(dirname "$latest_bus" | xargs basename))"
178
+ echo "────────────────────────"
179
+ tail -5 "$latest_bus" | while IFS= read -r line; do
180
+ echo "$line" | jq -r '" \(.ts // "" | if type=="number" then (./1000 | todate) else . end) \(.type // "") \(.from // "")\(if .to then " → " + .to else "" end) \(.msg // .tool // "" | tostring | .[0:60])"' 2>/dev/null
181
+ done
182
+ echo ""
183
+ fi
184
+ else
185
+ activityFile=".monomind/orgs/${org_name}-activity.jsonl"
186
+ if [ -f "$activityFile" ]; then
187
+ echo "RECENT ACTIVITY (last 5)"
188
+ echo "────────────────────────"
189
+ tail -5 "$activityFile" | while IFS= read -r line; do
190
+ ts=$(echo "$line" | jq -r '.ts // ""')
191
+ type=$(echo "$line" | jq -r '.type // ""')
192
+ pending=$(echo "$line" | jq -r '.pending // ""')
193
+ echo " $ts $type ${pending:+pending=$pending}"
194
+ done
195
+ echo ""
196
+ fi
151
197
  fi
152
198
  ```
153
199
 
@@ -156,25 +202,28 @@ fi
156
202
  ## Step 5 — Show Lifecycle Commands
157
203
 
158
204
  ```bash
159
- if [ "$has_schedule" = "yes" ]; then
160
- echo "ACTIONS"
161
- echo "───────"
205
+ echo "ACTIONS"
206
+ echo "───────"
207
+ if [ "$is_v2" = "yes" ]; then
208
+ case "$rt_status" in
209
+ running*) echo " Stop: monomind org stop $name" ;;
210
+ crashed*) echo " Close out: monomind org mark-complete $name" ;;
211
+ *) echo " Run: monomind org run $name${v2_schedule:+ (or host on schedule: monomind org serve)}" ;;
212
+ esac
213
+ echo " Logs: monomind org logs $name --follow"
214
+ echo " Report: monomind org report $name (add --all for run history)"
215
+ echo " Validate: monomind org validate $name"
216
+ echo " Settings: /mastermind:org-settings --org $name"
217
+ elif [ "$has_schedule" = "yes" ]; then
162
218
  case "$status" in
163
- active|paused)
164
- echo " Stop loop: /mastermind:stoporg --org $name"
165
- ;;
166
- stopped)
167
- echo " Start loop: /mastermind:runorg --org $name"
168
- ;;
219
+ active|paused) echo " Stop loop: /mastermind:stoporg --org $name" ;;
220
+ stopped) echo " Start loop: /mastermind:runorg --org $name (legacy v1)" ;;
169
221
  esac
170
222
  echo " Edit prompt: \$EDITOR $run_prompt_file"
171
- echo " All orgs: /mastermind:orgs"
172
223
  else
173
- echo "ACTIONS"
174
- echo "───────"
175
- echo " Run org: /mastermind:runorg --org $name"
176
- echo " All orgs: /mastermind:orgs"
224
+ echo " Run org: /mastermind:runorg --org $name (legacy v1)"
177
225
  fi
226
+ echo " All orgs: /mastermind:orgs"
178
227
  echo ""
179
228
  ```
180
229
 
@@ -49,6 +49,12 @@ This structure informs the task decomposition. Each task should produce self-con
49
49
 
50
50
  ---
51
51
 
52
+ ## Task Right-Sizing
53
+
54
+ A task is the smallest unit that carries its own test cycle and is worth a fresh reviewer's gate. When drawing task boundaries: fold setup, configuration, scaffolding, and documentation steps into the task whose deliverable needs them; split only where a reviewer could meaningfully reject one task while approving its neighbor. Each task ends with an independently testable deliverable.
55
+
56
+ ---
57
+
52
58
  ## Bite-Sized Task Granularity
53
59
 
54
60
  **Each step is one action (2-5 minutes):**
@@ -75,6 +81,13 @@ This structure informs the task decomposition. Each task should produce self-con
75
81
 
76
82
  **Tech Stack:** [Key technologies/libraries]
77
83
 
84
+ ## Global Constraints
85
+
86
+ [The spec's project-wide requirements — version floors, dependency limits,
87
+ naming and copy rules, platform requirements — one line each, with exact
88
+ values copied verbatim from the spec. Every task's requirements implicitly
89
+ include this section.]
90
+
78
91
  ---
79
92
  ```
80
93
 
@@ -90,6 +103,12 @@ This structure informs the task decomposition. Each task should produce self-con
90
103
  - Modify: `exact/path/to/existing.py:123-145`
91
104
  - Test: `tests/exact/path/to/test.py`
92
105
 
106
+ **Interfaces:**
107
+ - Consumes: [what this task uses from earlier tasks — exact signatures]
108
+ - Produces: [what later tasks rely on — exact function names, parameter
109
+ and return types. A task's implementer sees only their own task; this
110
+ block is how they learn the names and types neighboring tasks use.]
111
+
93
112
  - [ ] **Step 1: Write the failing test**
94
113
 
95
114
  ```python
@@ -161,6 +161,12 @@ description: Use when implementation is complete and you need to decide how to i
161
161
  description: Use when receiving code review feedback before implementing suggestions
162
162
  ```
163
163
 
164
+ ### Descriptive Naming
165
+
166
+ **Use active voice, verb-first:**
167
+ - ✅ `creating-skills` not `skill-creation`
168
+ - ✅ `condition-based-waiting` not `async-test-helpers`
169
+
164
170
  ### Keyword Coverage
165
171
 
166
172
  Use words Claude would search for:
@@ -190,6 +196,33 @@ Use words Claude would search for:
190
196
  See mastermind/worktree.md
191
197
  ```
192
198
 
199
+ **Why no @ links:** `@` syntax force-loads files immediately, consuming context before it's needed. Name the skill; let the reader invoke it.
200
+
201
+ ## Flowchart Usage
202
+
203
+ **Use flowcharts ONLY for:**
204
+ - Non-obvious decision points
205
+ - Process loops where you might stop too early
206
+ - "When to use A vs B" decisions
207
+
208
+ **Never use flowcharts for:**
209
+ - Reference material → tables, lists
210
+ - Code examples → markdown blocks
211
+ - Linear instructions → numbered lists
212
+ - Labels without semantic meaning (step1, helper2)
213
+
214
+ ## Code Examples
215
+
216
+ **One excellent example beats many mediocre ones.** Choose the most relevant language for the domain.
217
+
218
+ **Good example:** complete and runnable, well-commented explaining WHY, from a real scenario, ready to adapt.
219
+
220
+ **Don't:** implement in 5+ languages, create fill-in-the-blank templates, write contrived examples.
221
+
222
+ ## File Organization
223
+
224
+ Mastermind skills are single files in a flat namespace. Keep everything inline. If a skill genuinely needs heavy reference material (500+ lines of API docs), condense it to what agents actually retrieve — a skill nobody can afford to load teaches nothing. Reusable prompt templates (like taskdev's implementer/reviewer prompts) live as sibling `*-prompt.md` files in the skills directory.
225
+
193
226
  ## The Iron Law (Same as TDD)
194
227
 
195
228
  ```
@@ -205,8 +238,83 @@ Edit skill without testing? Same violation.
205
238
  - Not for "simple additions"
206
239
  - Not for "just adding a section"
207
240
  - Not for "documentation updates"
241
+ - Don't keep untested changes as "reference"
242
+ - Don't "adapt" while running tests
208
243
  - Delete means delete
209
244
 
245
+ ## Testing All Skill Types
246
+
247
+ Different skill types need different test approaches:
248
+
249
+ ### Discipline-Enforcing Skills (rules/requirements)
250
+
251
+ **Examples:** tdd, verify, design-before-code gates
252
+
253
+ **Test with:** academic questions (do they understand the rules?), pressure scenarios (do they comply under stress?), multiple pressures combined (time + sunk cost + exhaustion). Identify rationalizations and add explicit counters.
254
+
255
+ **Success criteria:** agent follows the rule under maximum pressure.
256
+
257
+ ### Technique Skills (how-to guides)
258
+
259
+ **Test with:** application scenarios (can they apply it correctly?), variation scenarios (edge cases?), missing-information tests (do the instructions have gaps?).
260
+
261
+ **Success criteria:** agent successfully applies the technique to a new scenario.
262
+
263
+ ### Pattern Skills (mental models)
264
+
265
+ **Test with:** recognition scenarios (do they see when it applies?), application scenarios, counter-examples (do they know when NOT to apply?).
266
+
267
+ **Success criteria:** agent correctly identifies when/how to apply the pattern.
268
+
269
+ ### Reference Skills (documentation/APIs)
270
+
271
+ **Test with:** retrieval scenarios (can they find the right information?), application scenarios (can they use it correctly?), gap testing (are common use cases covered?).
272
+
273
+ **Success criteria:** agent finds and correctly applies the reference information.
274
+
275
+ ## Match the Form to the Failure
276
+
277
+ Before writing guidance, classify the baseline failure. The form that bulletproofs one failure type measurably backfires on another.
278
+
279
+ | Baseline failure | Right form | Wrong form |
280
+ |---|---|---|
281
+ | Skips/violates a rule under pressure (knows better, does it anyway) | Prohibition + rationalization table + red flags (see Bulletproofing below) | Soft guidance ("prefer...", "consider...") |
282
+ | Complies, but output has the wrong shape (bloated prompt, buried verdict, restated spec) | Positive recipe or contract: state what the output IS — its parts, in order | Prohibition list ("don't restate", "never narrate") |
283
+ | Omits a required element from something they already produce | Structural: REQUIRED field or slot in the template they fill in | Prose reminders near the template |
284
+ | Behavior should depend on a condition | Conditional keyed to an observable predicate ("if the brief exists, reference it") | Unconditional rule + exemption clauses |
285
+
286
+ **Why prohibitions backfire on shaping problems:** under a competing incentive, agents negotiate with "don't X". A recipe leaves nothing to negotiate: the output matches the stated shape or it doesn't.
287
+
288
+ **Rules for whichever form you pick:**
289
+ - **No nuance clauses.** "Don't X unless it matters" reopens the negotiation. Express a real exception as its own conditional on an observable predicate.
290
+ - **Exemption clauses don't scope.** "This limit doesn't apply to code blocks" still suppresses code blocks. If part of the output must be exempt, restructure so the rule can't reach it.
291
+
292
+ ## Bulletproofing Skills Against Rationalization
293
+
294
+ Skills that enforce discipline (like TDD) need to resist rationalization. Agents are smart and will find loopholes when under pressure.
295
+
296
+ **Scope:** this toolkit is for discipline failures — an agent that knows the rule and skips it under pressure. For wrong-shaped output or omitted elements, prohibition-based bulletproofing backfires; use the forms in Match the Form to the Failure instead.
297
+
298
+ ### Close Every Loophole Explicitly
299
+
300
+ Don't just state the rule — forbid specific workarounds. "Write code before test? Delete it." becomes: "Delete it. Start over. No exceptions: don't keep it as 'reference', don't 'adapt' it while writing tests, don't look at it. Delete means delete."
301
+
302
+ ### Address "Spirit vs Letter" Arguments
303
+
304
+ Add the foundational principle early: **"Violating the letter of the rules is violating the spirit of the rules."** This cuts off the entire class of "I'm following the spirit" rationalizations.
305
+
306
+ ### Build Rationalization Table
307
+
308
+ Capture rationalizations from baseline testing. Every excuse agents make goes in the table as `| Excuse | Reality |` rows.
309
+
310
+ ### Create Red Flags List
311
+
312
+ Make it easy for agents to self-check when rationalizing: a short list of the exact thoughts that mean STOP, ending with what to do instead.
313
+
314
+ ### Update the Description for Violation Symptoms
315
+
316
+ Add to the description the symptoms of when you're ABOUT to violate the rule (e.g. "use when implementing any feature or bugfix, **before writing implementation code**").
317
+
210
318
  ## RED-GREEN-REFACTOR for Skills
211
319
 
212
320
  ### RED: Write Failing Test (Baseline)
@@ -226,6 +334,18 @@ Run same scenarios WITH skill. Agent should now comply.
226
334
 
227
335
  Agent found new rationalization? Add explicit counter. Re-test until bulletproof.
228
336
 
337
+ ### Micro-Test Wording Before Full Scenarios
338
+
339
+ Full pressure-scenario runs are the final gate, but they are slow and expensive per iteration. Verify the wording itself first with micro-tests:
340
+
341
+ 1. **One fresh-context sample per call** — a single-shot subagent whose instructions embed the guidance in the realistic context it will live in (the full skill, not the guidance in isolation), given a task that tempts the failure.
342
+ 2. **Always include a no-guidance control.** If the control doesn't exhibit the failure, there is nothing to fix — stop, don't author the guidance.
343
+ 3. **5+ reps per variant.** Single samples lie.
344
+ 4. **Manually read every flagged match.** Template echoes and quoted counter-examples masquerade as hits; automated counts alone overstate both failure and success.
345
+ 5. **Variance is a metric.** When guidance lands, reps converge on the same shape. Five different interpretations across five reps means the wording isn't binding — tighten the form before adding words.
346
+
347
+ Micro-tests verify wording; they do not replace pressure scenarios for discipline skills.
348
+
229
349
  ## Common Rationalizations for Skipping Testing
230
350
 
231
351
  | Excuse | Reality |
@@ -235,6 +355,40 @@ Agent found new rationalization? Add explicit counter. Re-test until bulletproof
235
355
  | "Testing is overkill" | Untested skills have issues. Always. |
236
356
  | "I'll test if problems emerge" | Test BEFORE deploying. |
237
357
  | "I'm confident it's good" | Overconfidence guarantees issues. Test anyway. |
358
+ | "Academic review is enough" | Reading ≠ using. Test application scenarios. |
359
+ | "Too tedious to test" | Testing is less tedious than debugging a bad skill in production. |
360
+ | "No time to test" | Deploying an untested skill wastes more time fixing it later. |
361
+
362
+ **All of these mean: Test before deploying. No exceptions.**
363
+
364
+ ## Anti-Patterns
365
+
366
+ ### ❌ Narrative Example
367
+ "In session 2025-10-03, we found empty projectDir caused..."
368
+ **Why bad:** Too specific, not reusable
369
+
370
+ ### ❌ Multi-Language Dilution
371
+ example-js.js, example-py.py, example-go.go
372
+ **Why bad:** Mediocre quality, maintenance burden
373
+
374
+ ### ❌ Code in Flowcharts
375
+ Flowchart nodes containing code statements
376
+ **Why bad:** Can't copy-paste, hard to read
377
+
378
+ ### ❌ Generic Labels
379
+ helper1, helper2, step3, pattern4
380
+ **Why bad:** Labels should have semantic meaning
381
+
382
+ ## STOP: Before Moving to Next Skill
383
+
384
+ **After writing ANY skill, you MUST STOP and complete the deployment process.**
385
+
386
+ **Do NOT:**
387
+ - Create multiple skills in batch without testing each
388
+ - Move to the next skill before the current one is verified
389
+ - Skip testing because "batching is more efficient"
390
+
391
+ **The deployment checklist below is MANDATORY for EACH skill.** Deploying untested skills = deploying untested code.
238
392
 
239
393
  ## Skill Creation Checklist
240
394
 
@@ -251,6 +405,9 @@ Agent found new rationalization? Add explicit counter. Re-test until bulletproof
251
405
  - [ ] Keywords throughout for search
252
406
  - [ ] Clear overview with core principle
253
407
  - [ ] Address specific baseline failures from RED phase
408
+ - [ ] Guidance form matches the failure type (see Match the Form to the Failure)
409
+ - [ ] For behavior-shaping guidance: wording micro-tested against a no-guidance control (5+ reps, every flagged match read manually) — N/A for pure reference skills
410
+ - [ ] One excellent example (not multi-language)
254
411
  - [ ] Run scenarios WITH skill — verify agents now comply
255
412
 
256
413
  **REFACTOR Phase:**
@@ -264,6 +421,20 @@ Agent found new rationalization? Add explicit counter. Re-test until bulletproof
264
421
  - [ ] Skill file at `.claude/skills/mastermind/<name>.md`
265
422
  - [ ] Command file at `.claude/commands/mastermind/<name>.md`
266
423
  - [ ] Commit both files to git
424
+ - [ ] Mirror both files into `packages/@monomind/cli/.claude/` (the npm-shipped copy)
425
+
426
+ ## Discovery Workflow
427
+
428
+ How future agents find your skill:
429
+
430
+ 1. **Encounters problem** ("tests are flaky")
431
+ 2. **Searches skills** (greps descriptions, browses the namespace)
432
+ 3. **Finds the skill** (description matches)
433
+ 4. **Scans overview** (is this relevant?)
434
+ 5. **Reads patterns** (quick reference table)
435
+ 6. **Loads example** (only when implementing)
436
+
437
+ **Optimize for this flow** — put searchable terms early and often.
267
438
 
268
439
  ## The Bottom Line
269
440
 
@@ -14,11 +14,28 @@ Task tool (general-purpose):
14
14
 
15
15
  ## What Was Requested
16
16
 
17
- [FULL TEXT of task requirements paste from plan]
17
+ Read this file first — it is the task's requirements, with the exact
18
+ values that bind the implementation:
19
+
20
+ [TASK_BRIEF_PATH — e.g. .monomind/taskdev/task-N-brief.md]
21
+
22
+ ## Global Constraints
23
+
24
+ [Copied verbatim from the plan's Global Constraints section — exact
25
+ values, formats, and cross-component relationships that bind this task]
18
26
 
19
27
  ## What Implementer Claims They Built
20
28
 
21
- [From implementer's report]
29
+ Read the implementer's report file:
30
+
31
+ [REPORT_FILE_PATH — e.g. .monomind/taskdev/task-N-report.md]
32
+
33
+ ## Diff to Review
34
+
35
+ Read this file — it contains the commit list, stat summary, and full
36
+ diff for the task:
37
+
38
+ [DIFF_FILE_PATH — e.g. .monomind/taskdev/task-N-review.diff]
22
39
 
23
40
  ## CRITICAL: Do Not Trust the Report
24
41
 
@@ -42,16 +42,18 @@ current_status=$(jq -r '.status // "no-schedule"' "$orgFile")
42
42
  has_schedule=$(jq -r 'if .loop.poll_interval_minutes then "yes" else "no" end' "$orgFile")
43
43
  ```
44
44
 
45
- If `has_schedule == "no"`:
45
+ If `has_schedule == "no"` — this is a **v2 org** (Org Runtime v2 has `schedule`,
46
+ never `.loop`). Its daemon polls `.monomind/orgs/<name>/stop` every 2s, which is
47
+ exactly what `monomind org stop` writes — use the CLI, not the v1 `.stops/` path:
48
+
46
49
  ```bash
47
50
  REPO_ROOT=$(git rev-parse --show-toplevel 2>/dev/null || pwd)
48
51
  CTRL_URL=$(jq -r '.url // "http://localhost:4242"' "$REPO_ROOT/.monomind/control.json" 2>/dev/null || echo "http://localhost:4242")
49
- # Write stop file so any running boss agent detects it at next loop iteration
50
- mkdir -p ".monomind/orgs/.stops"
51
- touch ".monomind/orgs/.stops/${org_name}.stop"
52
+ npx -y monomind@latest org stop "${org_name}" \
53
+ || { mkdir -p ".monomind/orgs/${org_name}"; date -u +%Y-%m-%dT%H:%M:%SZ > ".monomind/orgs/${org_name}/stop"; }
52
54
  # Also POST to the control server in case a dashboard-started instance is running
53
55
  curl -s -X POST "${CTRL_URL}/api/orgs/${org_name}/stop" >/dev/null 2>&1 || true
54
- echo "Stop signal sent to org '${org_name}' (non-scheduled). The boss agent will exit at the next loop checkpoint."
56
+ echo "Stop requested for org '${org_name}' (v2 daemon exits within 2s)."
55
57
  ```
56
58
  - Exit.
57
59