claude-multi-session 2.5.0 → 2.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/setup.js +150 -18
- package/package.json +1 -1
package/bin/setup.js
CHANGED
|
@@ -43,6 +43,10 @@ const CLAUDE_MD_END_MARKER = '<!-- claude-multi-session:end -->';
|
|
|
43
43
|
|
|
44
44
|
// This teaches the main Claude session how to orchestrate team workers.
|
|
45
45
|
// Wrapped in markers so we can find and remove it later.
|
|
46
|
+
//
|
|
47
|
+
// IMPORTANT: This content MUST stay in sync with docs/ORCHESTRATOR-CLAUDE.md.
|
|
48
|
+
// When updating rules or adding features, update BOTH files.
|
|
49
|
+
// Failure to sync caused all test runs 1-6 to use stale orchestrator rules.
|
|
46
50
|
const STRATEGY_CONTENT = `
|
|
47
51
|
${CLAUDE_MD_START_MARKER}
|
|
48
52
|
|
|
@@ -52,11 +56,39 @@ You have access to a Multi-Session MCP server (\`mcp__multi-session__*\` tools)
|
|
|
52
56
|
|
|
53
57
|
IMPORTANT: When the user asks you to build something complex (more than 2 related tasks), use the multi-session system to parallelize the work instead of doing everything yourself.
|
|
54
58
|
|
|
59
|
+
## Step 0: Verify Your Tools
|
|
60
|
+
|
|
61
|
+
Before starting ANY orchestration work, call \`server_version()\` to verify you're running the latest MCP tools. If the response shows a version mismatch, tell the user to restart Claude Code before proceeding — stale tools cause phantom failures.
|
|
62
|
+
|
|
63
|
+
## How to Orchestrate
|
|
64
|
+
|
|
65
|
+
### Rule 0: Define shared conventions BEFORE spawning workers
|
|
66
|
+
Before spawning workers, fill in the CONVENTION CHECKLIST. Either publish as an artifact (\`shared-conventions\`) or embed in every worker's prompt.
|
|
67
|
+
|
|
68
|
+
=== CONVENTION CHECKLIST (define every item before spawning) ===
|
|
69
|
+
- [ ] Response format: e.g., \`{ data: <result> }\`
|
|
70
|
+
- [ ] Error format: e.g., \`{ error: <message> }\`
|
|
71
|
+
- [ ] Status codes: create=201, read=200, update=200, delete=200, notFound=404, badRequest=400, conflict=409
|
|
72
|
+
- [ ] Naming: e.g., snake_case for DB columns, camelCase for JS variables
|
|
73
|
+
- [ ] File paths: relative only, never absolute
|
|
74
|
+
- [ ] Enum/status values: list EXACT strings (e.g., "pending", "in_progress", "completed" — NOT "Pending" or "InProgress")
|
|
75
|
+
- [ ] Boolean handling: true/false vs 1/0 — pick one, specify it
|
|
76
|
+
- [ ] Date format: ISO 8601 strings, Unix timestamps, or other — specify which
|
|
77
|
+
- [ ] Audit/log action names: exact strings (e.g., "created" vs "create" vs "CREATE")
|
|
78
|
+
- [ ] Shared column names: list exact DB column names for tables multiple workers reference
|
|
79
|
+
|
|
80
|
+
Missing even ONE item causes convention mismatches that the orchestrator then has to fix manually — which violates Rule 6.
|
|
81
|
+
|
|
82
|
+
NEVER assume workers will independently agree on conventions — they won't.
|
|
83
|
+
|
|
55
84
|
### Rule 1: You are the ORCHESTRATOR — not the implementer
|
|
56
85
|
- Plan the work, spawn workers, monitor progress
|
|
57
86
|
- Do NOT implement code yourself when you can delegate
|
|
87
|
+
- Do NOT create project foundation files (package.json, db.js, app.js, server.js) yourself — spawn a setup worker for Phase 0
|
|
58
88
|
- Do NOT read full outputs from workers — check artifacts and contract status instead
|
|
59
89
|
|
|
90
|
+
**Phase 0: Foundation Setup** — If the project needs shared infrastructure (database, app skeleton, package.json), spawn a \`setup\` worker FIRST. Wait for its \`project-foundation\` artifact before spawning other workers. Do NOT create these files yourself.
|
|
91
|
+
|
|
60
92
|
### Rule 2: Use team_spawn for multi-session work
|
|
61
93
|
IMPORTANT: Spawn ALL independent workers in a SINGLE message with multiple tool calls. This makes them run in parallel.
|
|
62
94
|
|
|
@@ -64,10 +96,36 @@ IMPORTANT: Spawn ALL independent workers in a SINGLE message with multiple tool
|
|
|
64
96
|
- Workers have team_ask, team_send_message, team_broadcast tools
|
|
65
97
|
- They can publish and read artifacts directly
|
|
66
98
|
- You should NOT relay messages between them
|
|
99
|
+
- If workers need each other's output, tell them to use team_ask
|
|
100
|
+
- Note: team_ask is a **fallback** for unexpected ambiguity. In well-orchestrated projects where you provide all context upfront, team_ask may never be called — this is the ideal case.
|
|
101
|
+
|
|
102
|
+
### Rule 4: Post-Phase Verification (MANDATORY)
|
|
103
|
+
After ALL workers in a phase complete, BEFORE spawning the next phase, STOP and fill in this checklist:
|
|
104
|
+
|
|
105
|
+
=== PHASE GATE CHECKPOINT (fill in before EVERY team_spawn after Phase 0) ===
|
|
106
|
+
|
|
107
|
+
Phase completing: ___ → Phase starting: ___
|
|
108
|
+
|
|
109
|
+
1. \`artifact_list()\`
|
|
110
|
+
Expected artifacts: [___]
|
|
111
|
+
All present? YES / NO
|
|
112
|
+
|
|
113
|
+
2. \`artifact_get({ artifactId: "___", reader: "orchestrator" })\`
|
|
114
|
+
Content valid and complete? YES / NO
|
|
115
|
+
|
|
116
|
+
3. \`team_roster()\`
|
|
117
|
+
All previous-phase workers idle? YES / NO
|
|
118
|
+
|
|
119
|
+
4. \`artifact_readers({ artifactId: "___" })\`
|
|
120
|
+
All expected consumers listed? YES / NO
|
|
121
|
+
|
|
122
|
+
PROCEED ONLY IF all answers are YES.
|
|
123
|
+
If any is NO → diagnose and fix before continuing.
|
|
124
|
+
|
|
125
|
+
Count your phases upfront. If you have N phases, fill in this checkpoint exactly N-1 times (between every adjacent pair of phases). Skipping verification for later phases is the #1 cause of test failures.
|
|
67
126
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
Only intervene when a session is BLOCKED or FAILED.
|
|
127
|
+
Only intervene in workers when a session is BLOCKED or FAILED.
|
|
128
|
+
Do NOT verify worker output by reading files directly — check artifacts instead.
|
|
71
129
|
|
|
72
130
|
### Rule 5: Always tell workers to publish artifacts
|
|
73
131
|
Every worker prompt should include instructions to:
|
|
@@ -76,16 +134,54 @@ Every worker prompt should include instructions to:
|
|
|
76
134
|
3. Publish output as artifacts (\`artifact_publish\`)
|
|
77
135
|
4. Broadcast completion (\`team_broadcast\`)
|
|
78
136
|
5. Update status to idle when done (\`team_update_status\`)
|
|
137
|
+
6. Follow shared conventions defined in Rule 0 (include them in the prompt or reference the conventions artifact)
|
|
138
|
+
|
|
139
|
+
### Rule 6: Don't fix worker code yourself (pragmatic exception for trivial fixes)
|
|
140
|
+
|
|
141
|
+
=== FIX PROTOCOL (when you must fix worker code directly) ===
|
|
142
|
+
STOP. Before editing any file a worker created, answer these questions:
|
|
143
|
+
|
|
144
|
+
1. Is this fix ≤ 3 lines?
|
|
145
|
+
NO → \`send_message\` to worker or spawn fix-worker. Do NOT fix yourself.
|
|
146
|
+
YES → continue to step 2.
|
|
147
|
+
|
|
148
|
+
2. Is the worker done (idle status in \`team_roster\`)?
|
|
149
|
+
NO → \`send_message\` to worker. Do NOT fix yourself.
|
|
150
|
+
YES → continue to step 3.
|
|
151
|
+
|
|
152
|
+
3. Make the fix.
|
|
153
|
+
|
|
154
|
+
4. Broadcast: \`team_broadcast({ from: "orchestrator", content: "Fixed [file]:[lines] — [description of change]" })\`
|
|
155
|
+
|
|
156
|
+
5. Re-publish: If the fix changes data in a published artifact, call \`artifact_publish\` to update it.
|
|
157
|
+
|
|
158
|
+
NEVER skip steps 4-5. Unannounced fixes cause downstream workers to use stale assumptions.
|
|
159
|
+
|
|
160
|
+
If the failure is due to convention mismatch (wrong response format, etc.), that's YOUR fault — update the conventions and notify the affected workers.
|
|
161
|
+
|
|
162
|
+
### Rule 7: Verify artifacts between phases (Phase Gates)
|
|
163
|
+
Use the PHASE GATE CHECKPOINT from Rule 4 between every pair of phases. This is the same checklist — Rule 7 reinforces that it applies to EVERY phase transition, not just the first one.
|
|
164
|
+
|
|
165
|
+
After all workers finish, verify they consumed shared artifacts:
|
|
166
|
+
\`\`\`
|
|
167
|
+
mcp__multi-session__artifact_readers({ artifactId: "shared-conventions" })
|
|
168
|
+
\`\`\`
|
|
169
|
+
This shows which workers actually read the conventions. If a worker is missing, they may have ignored the shared contract.
|
|
170
|
+
|
|
171
|
+
NEVER trust a worker's self-reported completion — verify the artifact exists yourself.
|
|
172
|
+
|
|
173
|
+
## Quick Reference
|
|
79
174
|
|
|
80
|
-
### Quick Reference
|
|
81
175
|
| You want to... | Use this tool |
|
|
82
176
|
|----------------|---------------|
|
|
83
|
-
|
|
|
84
|
-
|
|
|
85
|
-
|
|
|
177
|
+
| Verify tools before starting | \`server_version\` |
|
|
178
|
+
| Build a multi-person project | \`team_spawn\` (multiple in parallel) |
|
|
179
|
+
| Run a single isolated task | \`delegate_task\` |
|
|
180
|
+
| Check who's working on what | \`team_roster\` |
|
|
86
181
|
| See published outputs | \`artifact_list\` |
|
|
87
|
-
|
|
|
88
|
-
| Send correction to worker | \`send_message\` to that session |
|
|
182
|
+
| See task completion status | \`contract_list\` |
|
|
183
|
+
| Send a correction to a worker | \`send_message\` to that session |
|
|
184
|
+
| Check who read an artifact | \`artifact_readers\` |
|
|
89
185
|
|
|
90
186
|
### When NOT to Delegate
|
|
91
187
|
- Simple tasks (< 5 min, < 3 files) — do it yourself
|
|
@@ -305,8 +401,27 @@ function addGuide(scope) {
|
|
|
305
401
|
existing = fs.readFileSync(claudeMdPath, 'utf-8');
|
|
306
402
|
}
|
|
307
403
|
|
|
308
|
-
// Check if our section already exists
|
|
404
|
+
// Check if our section already exists
|
|
309
405
|
if (existing.includes(CLAUDE_MD_START_MARKER)) {
|
|
406
|
+
// Extract current content between markers and compare with latest
|
|
407
|
+
const startIdx = existing.indexOf(CLAUDE_MD_START_MARKER);
|
|
408
|
+
const endIdx = existing.indexOf(CLAUDE_MD_END_MARKER);
|
|
409
|
+
if (startIdx !== -1 && endIdx !== -1) {
|
|
410
|
+
const currentContent = existing.slice(startIdx, endIdx + CLAUDE_MD_END_MARKER.length).trim();
|
|
411
|
+
const newContent = STRATEGY_CONTENT.trim();
|
|
412
|
+
if (currentContent === newContent) {
|
|
413
|
+
result.skipped = true;
|
|
414
|
+
return result;
|
|
415
|
+
}
|
|
416
|
+
// Content is stale — replace our section, preserve user's other content
|
|
417
|
+
const before = existing.slice(0, startIdx).trimEnd();
|
|
418
|
+
const after = existing.slice(endIdx + CLAUDE_MD_END_MARKER.length).trimStart();
|
|
419
|
+
const updated = (before ? before + '\n\n' : '') + newContent + (after ? '\n\n' + after : '\n');
|
|
420
|
+
fs.writeFileSync(claudeMdPath, updated, 'utf-8');
|
|
421
|
+
result.updated = true;
|
|
422
|
+
return result;
|
|
423
|
+
}
|
|
424
|
+
// Malformed markers — skip to be safe
|
|
310
425
|
result.skipped = true;
|
|
311
426
|
return result;
|
|
312
427
|
}
|
|
@@ -410,10 +525,15 @@ function runPostinstallHint() {
|
|
|
410
525
|
write(' Run "cms-setup" to configure orchestrator guide.');
|
|
411
526
|
write('');
|
|
412
527
|
} else {
|
|
413
|
-
// Already registered —
|
|
528
|
+
// Already registered — check if CLAUDE.md guide needs updating
|
|
414
529
|
write('');
|
|
415
|
-
|
|
416
|
-
|
|
530
|
+
const guideResult = addGuide('global');
|
|
531
|
+
if (guideResult.updated) {
|
|
532
|
+
write(' claude-multi-session: Orchestrator guide updated in ~/.claude/CLAUDE.md');
|
|
533
|
+
write(' Restart Claude Code to use the latest rules.');
|
|
534
|
+
} else {
|
|
535
|
+
write(' claude-multi-session: Already configured and up to date.');
|
|
536
|
+
}
|
|
417
537
|
write('');
|
|
418
538
|
}
|
|
419
539
|
} catch {
|
|
@@ -563,9 +683,19 @@ async function runInteractiveSetup(flags) {
|
|
|
563
683
|
if (wantGuide === null) {
|
|
564
684
|
// Tell the user what will happen before they confirm
|
|
565
685
|
if (guideAlreadyInjected) {
|
|
566
|
-
//
|
|
567
|
-
|
|
568
|
-
|
|
686
|
+
// Check if content is stale
|
|
687
|
+
const currentFile = fs.readFileSync(guideTargetPath, 'utf-8');
|
|
688
|
+
const startIdx = currentFile.indexOf(CLAUDE_MD_START_MARKER);
|
|
689
|
+
const endIdx = currentFile.indexOf(CLAUDE_MD_END_MARKER);
|
|
690
|
+
const currentContent = currentFile.slice(startIdx, endIdx + CLAUDE_MD_END_MARKER.length).trim();
|
|
691
|
+
const isStale = currentContent !== STRATEGY_CONTENT.trim();
|
|
692
|
+
if (isStale) {
|
|
693
|
+
clack.log.warn(`Orchestrator guide in ${guideDisplayPath} is outdated.`);
|
|
694
|
+
wantGuide = true; // Auto-update — addGuide handles the replacement
|
|
695
|
+
} else {
|
|
696
|
+
clack.log.info(`Orchestrator guide in ${guideDisplayPath} is up to date.`);
|
|
697
|
+
wantGuide = false;
|
|
698
|
+
}
|
|
569
699
|
} else if (guideFileExists) {
|
|
570
700
|
// File exists — reassure user their content is safe
|
|
571
701
|
clack.log.info(`Found existing ${guideDisplayPath} — your content will be preserved.`);
|
|
@@ -599,8 +729,10 @@ async function runInteractiveSetup(flags) {
|
|
|
599
729
|
if (wantGuide) {
|
|
600
730
|
const guideResult = addGuide(scope);
|
|
601
731
|
|
|
602
|
-
if (guideResult.
|
|
603
|
-
clack.log.
|
|
732
|
+
if (guideResult.updated) {
|
|
733
|
+
clack.log.success(`Updated orchestrator guide in ${guideDisplayPath} (new rules synced)`);
|
|
734
|
+
} else if (guideResult.skipped) {
|
|
735
|
+
clack.log.info('Orchestrator guide already up to date — skipped.');
|
|
604
736
|
} else if (guideResult.created) {
|
|
605
737
|
clack.log.success(`Created ${guideDisplayPath} with orchestrator guide`);
|
|
606
738
|
} else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-multi-session",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.1",
|
|
4
4
|
"description": "Multi-session orchestrator for Claude Code CLI — spawn, control, pause, resume, and send multiple inputs to Claude Code sessions programmatically",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"bin": {
|