monomind 1.14.5 → 1.14.6

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.
@@ -73,7 +73,7 @@ curl -s -X POST "${CTRL_URL}/api/mastermind/event" \
73
73
  -d "$(jq -cn \
74
74
  --arg session "$session_id" \
75
75
  --arg org "$org_name" \
76
- --arg proj "$(pwd)" \
76
+ --arg proj "$REPO_ROOT" \
77
77
  '{type:"session:start",session:$session,domain:"ops",prompt:("Approve requests for org: "+$org),mode:"confirm",project:$proj,ts:(now*1000|floor)}')" || true
78
78
  ```
79
79
 
@@ -108,7 +108,7 @@ curl -s -X POST "${CTRL_URL}/api/mastermind/event" \
108
108
  --arg session "$session_id" \
109
109
  --arg prompt "$prompt" \
110
110
  --arg mode "$mode" \
111
- --arg proj "$(pwd)" \
111
+ --arg proj "$REPO_ROOT" \
112
112
  '{type:"session:start",session:$session,domain:"ops",prompt:$prompt,mode:$mode,project:$proj,ts:(now*1000|floor)}')" || true
113
113
  ```
114
114
 
@@ -316,7 +316,7 @@ jq -n --arg sid "$SESSION_ID" --arg proj "$project_name" --arg prompt "$resolved
316
316
  CTRL_URL=$(jq -r '.url // "http://localhost:4242"' "$REPO_ROOT/.monomind/control.json" 2>/dev/null || echo "http://localhost:4242")
317
317
  curl -s -o /dev/null -X POST "${CTRL_URL}/api/mastermind/event" \
318
318
  -H "Content-Type: application/json" \
319
- -d "$(jq -cn --arg sid "$SESSION_ID" --arg prompt "$resolved_prompt" --arg mode "$mode" --arg proj "$(pwd)" \
319
+ -d "$(jq -cn --arg sid "$SESSION_ID" --arg prompt "$resolved_prompt" --arg mode "$mode" --arg proj "$REPO_ROOT" \
320
320
  '{type:"session:start",session:$sid,prompt:$prompt,mode:$mode,project:$proj,ts:(now*1000|floor)}')" || true
321
321
  ```
322
322
 
@@ -44,7 +44,26 @@ No orgs yet? Run `/mastermind:createorg` to define one.
44
44
 
45
45
  ---
46
46
 
47
- Parse `$ARGUMENTS` for:
47
+ **STEP 0 — Extract loop-control flags (do this FIRST, before any other parsing)**
48
+
49
+ Scan `$ARGUMENTS` for these flags and store their values. Remove them from the argument string before Step 1:
50
+
51
+ | Flag | Variable | Default |
52
+ |---|---|---|
53
+ | `--rep <N>` | `current_rep = N` | absent |
54
+ | `--loop <id>` | `LOOP_ID = id` | absent |
55
+ | `--tillend` | `tillend_mode = true` | false |
56
+ | `--maxruns <N>` | `tillend_maxruns = N` | 50 |
57
+ | `--wait <N>` | `wait_seconds = N` | 60 |
58
+ | `--repeat <N>` | `repeat_count = N` | 0 |
59
+
60
+ ⚠️ **CRITICAL — CONTINUATION RUNS DO NOT SKIP WORK.** When `--rep N` is present, this is a scheduled continuation triggered by ScheduleWakeup. The org's FULL work cycle MUST still execute every time: session variables → session:start event → Skill("mastermind:runorg") → session:complete event. NEVER short-circuit or skip the org work because `--rep` is present. The `--rep` / `--loop` flags are only consumed by `Skill("mastermind:_repeat")` at the end.
61
+
62
+ ---
63
+
64
+ **STEP 1 — Parse org-specific flags**
65
+
66
+ From the remaining `$ARGUMENTS` (after loop flags removed in Step 0):
48
67
  - `--org <name>` → org_name = <name>
49
68
  - `--task <task>` → task_override = <task> (if omitted, task_override = null — the skill uses org's stored goal)
50
69
  - Remaining text = additional context passed to the boss agent
@@ -68,11 +87,15 @@ If the file does not exist, stop and suggest running `/mastermind:createorg --na
68
87
 
69
88
  Load brain context for the `ops` domain (follow _protocol.md Brain Load Procedure, namespace: `ops`).
70
89
 
71
- Generate a session ID as a real shell variable:
90
+ Resolve session ID and project root:
72
91
  ```bash
73
92
  REPO_ROOT=$(git rev-parse --show-toplevel 2>/dev/null || pwd)
74
- session_id="mm-$(date -u +%Y%m%dT%H%M%S)"
75
93
  CTRL_URL=$(jq -r '.url // "http://localhost:4242"' "$REPO_ROOT/.monomind/control.json" 2>/dev/null || echo "http://localhost:4242")
94
+ # Reuse the loop's original sessionId for continuation runs (keeps all reps under one session)
95
+ if [ -n "${LOOP_ID:-}" ] && [ -f ".monomind/loops/${LOOP_ID}.json" ]; then
96
+ session_id=$(jq -r '.sessionId // empty' ".monomind/loops/${LOOP_ID}.json" 2>/dev/null)
97
+ fi
98
+ session_id="${session_id:-mm-$(date -u +%Y%m%dT%H%M%S)}"
76
99
  ```
77
100
 
78
101
  Emit `session:start` to dashboard:
@@ -82,7 +105,7 @@ curl -s -X POST "${CTRL_URL}/api/mastermind/event" \
82
105
  -d "$(jq -cn \
83
106
  --arg session "$session_id" \
84
107
  --arg org "$org_name" \
85
- --arg proj "$(pwd)" \
108
+ --arg proj "$REPO_ROOT" \
86
109
  '{type:"session:start",session:$session,domain:"ops",prompt:("Running org: "+$org),mode:"auto",project:$proj,ts:(now*1000|floor)}')" || true
87
110
  ```
88
111
 
@@ -93,7 +116,7 @@ curl -s -X POST "${CTRL_URL}/api/mastermind/event" \
93
116
  -d "$(jq -cn \
94
117
  --arg session "$session_id" \
95
118
  --arg org "$org_name" \
96
- --arg proj "$(pwd)" \
119
+ --arg proj "$REPO_ROOT" \
97
120
  '{type:"domain:dispatch",session:$session,domain:"ops",cmd:("Starting org "+$org+" as persistent daemon"),project:$proj,ts:(now*1000|floor)}')" || true
98
121
  ```
99
122
 
@@ -106,7 +129,7 @@ curl -s -X POST "${CTRL_URL}/api/mastermind/event" \
106
129
  -d "$(jq -cn \
107
130
  --arg session "$session_id" \
108
131
  --arg status "<status>" \
109
- --arg proj "$(pwd)" \
132
+ --arg proj "$REPO_ROOT" \
110
133
  '{type:"session:complete",session:$session,domain:"ops",status:$status,domains:["ops"],project:$proj,ts:(now*1000|floor)}')" || true
111
134
  ```
112
135
 
@@ -40,7 +40,7 @@ fi
40
40
  ```
41
41
  Return `status: blocked` with message: "Org '<org_name>' not found. Run /mastermind:createorg to define it."
42
42
 
43
- Validate the config has at minimum: `name`, `goal`, `roles` (non-empty array), `communication`.
43
+ Validate the config has at minimum: `name`, `goal`, `roles` (non-empty array). The `communication` field is optional; fall back to `edges` if absent (both have the same schema: `from`, `to`, `type`).
44
44
 
45
45
  ---
46
46
 
@@ -351,7 +351,7 @@ YOUR TEAM (direct reports):
351
351
  ${directReports.map(r => `• ${r.title} (subagent_type="${r.agent_type}") — ${r.responsibilities.join(', ')}`).join('\n')}
352
352
 
353
353
  FULL COMMUNICATION TOPOLOGY:
354
- ${orgConfig.communication.map(e => `${e.from} → ${e.to} (${e.type})`).join('\n')}
354
+ ${(orgConfig.communication || orgConfig.edges || []).map(e => `${e.from} → ${e.to} (${e.type})`).join('\n')}
355
355
 
356
356
  SHARED INFRASTRUCTURE:
357
357
  - Task board (monotask): board_id=<board_id>
@@ -501,16 +501,27 @@ OPERATING LOOP:
501
501
  # On start — announce you are working:
502
502
  curl -s -X POST "${CTRL_URL}/api/mastermind/event" -H "Content-Type: application/json" \
503
503
  -d "$(jq -cn --arg s "${sessionId}" --arg o "${orgName}" --arg rid "${runId}" \
504
- --arg from "<role_id>" --arg msg "Starting: <card title>" --arg p "$REPO_ROOT" \
505
- '{type:"org:comms",session:$s,org:$o,runId:$rid,from:$from,to:"boss",msg:$msg,project:$p,ts:(now*1000|floor)}')" || true
504
+ --arg from "<role_id>" --arg msg "Starting: <card title>" \
505
+ '{type:"org:comms",session:$s,org:$o,runId:$rid,from:$from,to:"boss",msg:$msg,ts:(now*1000|floor)}')" || true
506
506
  # On completion — report back:
507
507
  curl -s -X POST "${CTRL_URL}/api/mastermind/event" -H "Content-Type: application/json" \
508
508
  -d "$(jq -cn --arg s "${sessionId}" --arg o "${orgName}" --arg rid "${runId}" \
509
- --arg from "<role_id>" --arg msg "Completed: <one-sentence summary of output>" --arg p "$REPO_ROOT" \
510
- '{type:"org:comms",session:$s,org:$o,runId:$rid,from:$from,to:"boss",msg:$msg,project:$p,ts:(now*1000|floor)}')" || true
509
+ --arg from "<role_id>" --arg msg "Completed: <one-sentence summary of output>" \
510
+ '{type:"org:comms",session:$s,org:$o,runId:$rid,from:$from,to:"boss",msg:$msg,ts:(now*1000|floor)}')" || true
511
+ # TOKEN TRACKING — estimate and persist token usage to state.json for the Budgets dashboard:
512
+ # Count approximate output tokens from your work (1 word ≈ 1.3 tokens):
513
+ _tok_out=$(echo -n "<paste a representative sample of your final output here>" | wc -w)
514
+ _tok_out=$(( _tok_out * 13 / 10 ))
515
+ _tok_in=8000 # fixed estimate for task context
516
+ stateFile="$REPO_ROOT/.monomind/orgs/${orgName}-state.json"
517
+ [ -f "$stateFile" ] && jq --arg id "<role_id>" --argjson in $_tok_in --argjson out $_tok_out \
518
+ '.agents[$id].tokens_in = ((.agents[$id].tokens_in // 0) + $in) | .agents[$id].tokens_out = ((.agents[$id].tokens_out // 0) + $out)' \
519
+ "$stateFile" > "${stateFile}.tmp" && mv "${stateFile}.tmp" "$stateFile" || true
511
520
 
512
521
  Fill in the literal values for orgName="${orgName}", runId="${runId}", sessionId="${sessionId}" — embed them
513
522
  directly in the prompt string so the specialist doesn't need to resolve them.
523
+ For token tracking: set _tok_out to the actual word count of your output text (use wc -w on your
524
+ output), and replace <role_id> with the literal role id string.
514
525
 
515
526
  5. Collect completed results from memory (search "${memNs}:report:")
516
527
 
@@ -526,8 +537,7 @@ OPERATING LOOP:
526
537
  jq -cn --arg runId "${runId}" --arg org "${orgName}" --argjson pend "${pending_count:-0}" \
527
538
  '{type:"run:cycle:complete",runId:$runId,org:$org,pending:$pend,ts:(now*1000|floor)}' >> "${runFile}" || true
528
539
  activityFile=".monomind/orgs/${orgName}-activity.jsonl"
529
- jq -cn --arg org "${orgName}" --arg runId "${runId}" --argjson pend "${pending_count:-0}" \
530
- '{type:"run:cycle:complete",org:$org,runId:$runId,ts:(now*1000|floor),pending:$pend}' >> "$activityFile" 2>/dev/null || true
540
+ echo "{\"type\":\"run:cycle:complete\",\"org\":\"${orgName}\",\"runId\":\"${runId}\",\"ts\":\"$(date -u +%Y-%m-%dT%H:%M:%SZ)\",\"pending\":${pending_count:-0}}" >> "$activityFile" 2>/dev/null || true
531
541
 
532
542
  8. REQUIRED — emit org:checkpoint with a one-sentence progress summary (include runId):
533
543
  curl -s -X POST "${CTRL_URL}/api/mastermind/event" -H "Content-Type: application/json" \
@@ -551,24 +561,26 @@ START NOW: resolve CTRL_URL, check for stop signal, assess the board, create ini
551
561
 
552
562
  ## Step 5 — Emit Boss Online Event
553
563
 
554
- Emit `org:agent:online` for the boss role (team member events are emitted by the boss itself):
564
+ Emit `org:agent:online` for the boss role (team member events are emitted by the boss itself).
565
+
566
+ **IMPORTANT**: Shell variables do NOT persist across separate Bash tool calls. Read the `ORG_VARS:` line printed in Step 2+3 and substitute each literal value directly into the curl command before running it. Do NOT use `$variableName` syntax — replace each placeholder with its literal string from `ORG_VARS:`.
555
567
 
556
568
  ```bash
557
- curl -s -X POST "${CTRL_URL}/api/mastermind/event" \
569
+ # Replace <CTRL_URL>, <sessionId>, <orgName>, <runId>, <bossRole_id>, <bossRole_title>, <bossRole_agent_type>, <REPO_ROOT>
570
+ # with the LITERAL values from the ORG_VARS: line printed in Step 2+3.
571
+ curl -s -X POST "<CTRL_URL>/api/mastermind/event" \
558
572
  -H "Content-Type: application/json" \
559
573
  -d "$(jq -cn \
560
- --arg session "$sessionId" \
561
- --arg org "$orgName" \
562
- --arg runId "$runId" \
563
- --arg role "$bossRole_id" \
564
- --arg title "$bossRole_title" \
565
- --arg agent_type "$bossRole_agent_type" \
566
- --arg proj "$REPO_ROOT" \
574
+ --arg session "<sessionId>" \
575
+ --arg org "<orgName>" \
576
+ --arg runId "<runId>" \
577
+ --arg role "<bossRole_id>" \
578
+ --arg title "<bossRole_title>" \
579
+ --arg agent_type "<bossRole_agent_type>" \
580
+ --arg proj "<REPO_ROOT>" \
567
581
  '{type:"org:agent:online",session:$session,org:$org,runId:$runId,role:$role,title:$title,agent_type:$agent_type,project:$proj,ts:(now*1000|floor)}')" || true
568
582
  ```
569
583
 
570
- (Use the scalar string variables `$bossRole_id`, `$bossRole_title`, `$bossRole_agent_type` derived by extracting fields from `bossRole` before constructing the curl call. `CTRL_URL`, `MONO_DIR`, and `runId` were resolved in Step 3 — reuse those variables.)
571
-
572
584
  ---
573
585
 
574
586
  ## Step 6 — Report to User
@@ -108,7 +108,7 @@ curl -s -X POST "${CTRL_URL}/api/mastermind/event" \
108
108
 
109
109
  Current status: stopped
110
110
  The loop will exit at its next scheduled wakeup without rescheduling.
111
- Loop fully dead within: ≤<poll_interval_minutes> minutes
111
+ Loop fully dead within: ≤$(jq -r '.loop.poll_interval_minutes // "?"' "$orgFile") minutes
112
112
 
113
113
  To restart: /mastermind:runorg --org <org_name>
114
114
  Status: /mastermind:orgstatus --org <org_name>
package/README.md CHANGED
@@ -139,16 +139,6 @@ graph LR
139
139
  E["7+ roles"] -->|hierarchical| F["Boss to leads to workers\nmiddle management"]
140
140
  ```
141
141
 
142
- ### Pre-built org types
143
-
144
- | Org | Goal | Roles |
145
- |---|---|---|
146
- | `content-team` | 3 posts/week on AI tools | Director · Writer · Reviewer · SEO · Growth |
147
- | `dev-squad` | Features from design spec | Lead · Architect · Developer · QA |
148
- | `research-lab` | Weekly competitive intelligence | Director · Researcher · Analyst · Writer |
149
- | `sales-engine` | ICP research + outreach sequences | Director · Outbound · Email · Researcher |
150
- | `ops-squad` | 24/7 monitoring + incident response | SRE · Security · Perf · Incident Cmdr |
151
-
152
142
  ### Org management commands
153
143
 
154
144
  ```bash
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "monomind",
3
- "version": "1.14.5",
3
+ "version": "1.14.6",
4
4
  "description": "Monomind - Enterprise AI agent orchestration for Claude Code. Deploy 60+ specialized agents in coordinated swarms with self-learning, fault-tolerant consensus, vector memory, and MCP integration",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -139,16 +139,6 @@ graph LR
139
139
  E["7+ roles"] -->|hierarchical| F["Boss to leads to workers\nmiddle management"]
140
140
  ```
141
141
 
142
- ### Pre-built org types
143
-
144
- | Org | Goal | Roles |
145
- |---|---|---|
146
- | `content-team` | 3 posts/week on AI tools | Director · Writer · Reviewer · SEO · Growth |
147
- | `dev-squad` | Features from design spec | Lead · Architect · Developer · QA |
148
- | `research-lab` | Weekly competitive intelligence | Director · Researcher · Analyst · Writer |
149
- | `sales-engine` | ICP research + outreach sequences | Director · Outbound · Email · Researcher |
150
- | `ops-squad` | 24/7 monitoring + incident response | SRE · Security · Perf · Incident Cmdr |
151
-
152
142
  ### Org management commands
153
143
 
154
144
  ```bash
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monoes/monomindcli",
3
- "version": "1.14.5",
3
+ "version": "1.14.6",
4
4
  "type": "module",
5
5
  "description": "Monomind CLI - Enterprise AI agent orchestration with 60+ specialized agents, swarm coordination, MCP server, self-learning hooks, and vector memory for Claude Code",
6
6
  "main": "dist/src/index.js",