@sparkleideas/teammate-plugin 1.0.0-alpha.11
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/README.md +713 -0
- package/package.json +101 -0
package/README.md
ADDED
|
@@ -0,0 +1,713 @@
|
|
|
1
|
+
# @claude-flow/teammate-plugin
|
|
2
|
+
|
|
3
|
+
Native **TeammateTool** integration plugin for Claude Flow. Bridges Claude Code v2.1.19+ multi-agent orchestration capabilities with Claude Flow's swarm system.
|
|
4
|
+
|
|
5
|
+
[](https://badge.fury.io/js/%40claude-flow%2Fteammate-plugin)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
## Requirements
|
|
9
|
+
|
|
10
|
+
| Requirement | Minimum Version | Recommended |
|
|
11
|
+
|-------------|-----------------|-------------|
|
|
12
|
+
| **Claude Code** | **>= 2.1.19** | Latest |
|
|
13
|
+
| Node.js | >= 18.0.0 | >= 20.0.0 |
|
|
14
|
+
| npm | >= 9.0.0 | >= 10.0.0 |
|
|
15
|
+
|
|
16
|
+
> **IMPORTANT:** This plugin requires Claude Code version **2.1.19 or higher**. The TeammateTool functionality was introduced in this version and is not available in earlier releases.
|
|
17
|
+
|
|
18
|
+
### Version Check
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
# Check your Claude Code version
|
|
22
|
+
claude --version
|
|
23
|
+
|
|
24
|
+
# Should output: 2.1.19 or higher
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
If your version is below 2.1.19, update Claude Code:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
claude update
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Installation
|
|
34
|
+
|
|
35
|
+
### Via Claude Code CLI (Recommended)
|
|
36
|
+
|
|
37
|
+
Install directly using Claude Code's plugin system:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
# Install from npm registry
|
|
41
|
+
claude plugins install @claude-flow/teammate-plugin
|
|
42
|
+
|
|
43
|
+
# Or install from Claude Flow plugin registry (IPFS-backed)
|
|
44
|
+
claude plugins install teammate-plugin --registry claude-flow
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Via npm
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
npm install @claude-flow/teammate-plugin
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Or with pnpm:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
pnpm add @claude-flow/teammate-plugin
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Via Claude Flow CLI
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
# Install via claude-flow plugin manager
|
|
63
|
+
npx @claude-flow/cli@latest plugins install --name @claude-flow/teammate-plugin
|
|
64
|
+
|
|
65
|
+
# Or add to your claude-flow.config.json
|
|
66
|
+
npx @claude-flow/cli@latest config set plugins.teammate-plugin.enabled true
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Verify Installation
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
# Check plugin is loaded
|
|
73
|
+
claude plugins list
|
|
74
|
+
|
|
75
|
+
# Or via claude-flow
|
|
76
|
+
npx @claude-flow/cli@latest plugins list
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Quick Start
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
import { createTeammateBridge } from '@claude-flow/teammate-plugin';
|
|
83
|
+
|
|
84
|
+
// Initialize the bridge
|
|
85
|
+
const bridge = await createTeammateBridge();
|
|
86
|
+
|
|
87
|
+
// Check compatibility
|
|
88
|
+
const version = bridge.getVersionInfo();
|
|
89
|
+
console.log(`Claude Code: ${version.claudeCode}`);
|
|
90
|
+
console.log(`Compatible: ${version.compatible}`);
|
|
91
|
+
|
|
92
|
+
if (!version.compatible) {
|
|
93
|
+
console.error('Please upgrade Claude Code to >= 2.1.19');
|
|
94
|
+
process.exit(1);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Create a team
|
|
98
|
+
const team = await bridge.spawnTeam({
|
|
99
|
+
name: 'my-dev-team',
|
|
100
|
+
topology: 'hierarchical',
|
|
101
|
+
maxTeammates: 6,
|
|
102
|
+
planModeRequired: true,
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
// Spawn teammates (returns AgentInput for Claude Code Task tool)
|
|
106
|
+
const coder = await bridge.spawnTeammate({
|
|
107
|
+
name: 'coder-1',
|
|
108
|
+
role: 'coder',
|
|
109
|
+
prompt: 'Implement the authentication feature using JWT',
|
|
110
|
+
teamName: 'my-dev-team',
|
|
111
|
+
model: 'sonnet',
|
|
112
|
+
allowedTools: ['Edit', 'Write', 'Read', 'Bash'],
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
// The agentInput can be passed to Claude Code's Task tool
|
|
116
|
+
const agentInput = bridge.buildAgentInput({
|
|
117
|
+
name: 'tester-1',
|
|
118
|
+
role: 'tester',
|
|
119
|
+
prompt: 'Write tests for the authentication feature',
|
|
120
|
+
teamName: 'my-dev-team',
|
|
121
|
+
model: 'haiku',
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
console.log('Pass this to Task tool:', agentInput);
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Features
|
|
128
|
+
|
|
129
|
+
### Core Features (from TeammateTool)
|
|
130
|
+
|
|
131
|
+
| Feature | Description | TeammateTool Operation |
|
|
132
|
+
|---------|-------------|------------------------|
|
|
133
|
+
| Team Management | Create, discover, load teams | `spawnTeam`, `discoverTeams` |
|
|
134
|
+
| Teammate Spawning | Spawn agents with native support | `AgentInput` schema |
|
|
135
|
+
| Join/Leave Workflow | Request-approve-reject pattern | `requestJoin`, `approveJoin`, `rejectJoin` |
|
|
136
|
+
| Messaging | Direct and broadcast messages | `write`, `broadcast` |
|
|
137
|
+
| Plan Approval | Submit, vote, execute plans | `approvePlan`, `rejectPlan` |
|
|
138
|
+
| Swarm Launch | Launch multi-agent execution | `launchSwarm`, `teammateCount` |
|
|
139
|
+
| Shutdown | Graceful teammate termination | `requestShutdown`, `approveShutdown` |
|
|
140
|
+
|
|
141
|
+
### Extended Features (Plugin Additions)
|
|
142
|
+
|
|
143
|
+
| Feature | Description |
|
|
144
|
+
|---------|-------------|
|
|
145
|
+
| Delegation | Delegate authority between teammates |
|
|
146
|
+
| Team Context | Shared variables, permissions, environment |
|
|
147
|
+
| Permission Updates | Dynamic permission changes mid-execution |
|
|
148
|
+
| Session Memory | Persist teammate context across sessions |
|
|
149
|
+
| Remote Sync | Push team to Claude.ai (experimental) |
|
|
150
|
+
| Transcript Sharing | Share message history between teammates |
|
|
151
|
+
| Teleport | Resume teams across terminal instances |
|
|
152
|
+
| Plan Control | Pause, resume, modify plans mid-execution |
|
|
153
|
+
|
|
154
|
+
## API Reference
|
|
155
|
+
|
|
156
|
+
### TeammateBridge
|
|
157
|
+
|
|
158
|
+
The main class for interacting with TeammateTool.
|
|
159
|
+
|
|
160
|
+
#### Initialization
|
|
161
|
+
|
|
162
|
+
```typescript
|
|
163
|
+
import { createTeammateBridge, TeammateBridge } from '@claude-flow/teammate-plugin';
|
|
164
|
+
|
|
165
|
+
// Factory function (recommended)
|
|
166
|
+
const bridge = await createTeammateBridge({
|
|
167
|
+
fallbackToMCP: true, // Fallback to MCP if TeammateTool unavailable
|
|
168
|
+
memory: {
|
|
169
|
+
autoPersist: true,
|
|
170
|
+
persistIntervalMs: 60000,
|
|
171
|
+
},
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
// Or direct instantiation
|
|
175
|
+
const bridge = new TeammateBridge(config);
|
|
176
|
+
await bridge.initialize();
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
#### Team Management
|
|
180
|
+
|
|
181
|
+
```typescript
|
|
182
|
+
// Create team
|
|
183
|
+
const team = await bridge.spawnTeam({
|
|
184
|
+
name: 'my-team',
|
|
185
|
+
topology: 'hierarchical', // 'flat' | 'hierarchical' | 'mesh'
|
|
186
|
+
maxTeammates: 8,
|
|
187
|
+
planModeRequired: true,
|
|
188
|
+
autoApproveJoin: true,
|
|
189
|
+
delegationEnabled: true,
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
// Discover existing teams
|
|
193
|
+
const teams = await bridge.discoverTeams();
|
|
194
|
+
// ['team-1', 'team-2', ...]
|
|
195
|
+
|
|
196
|
+
// Load existing team
|
|
197
|
+
const existingTeam = await bridge.loadTeam('team-1');
|
|
198
|
+
|
|
199
|
+
// Get team state
|
|
200
|
+
const state = bridge.getTeamState('my-team');
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
#### Teammate Spawning
|
|
204
|
+
|
|
205
|
+
```typescript
|
|
206
|
+
// Spawn teammate
|
|
207
|
+
const teammate = await bridge.spawnTeammate({
|
|
208
|
+
name: 'coder-1',
|
|
209
|
+
role: 'coder',
|
|
210
|
+
prompt: 'Implement feature X',
|
|
211
|
+
teamName: 'my-team',
|
|
212
|
+
model: 'sonnet', // 'sonnet' | 'opus' | 'haiku'
|
|
213
|
+
allowedTools: ['Edit', 'Write', 'Read'],
|
|
214
|
+
mode: 'default', // 'default' | 'plan' | 'delegate' | etc.
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
// Build AgentInput for Task tool
|
|
218
|
+
const agentInput = bridge.buildAgentInput({
|
|
219
|
+
name: 'reviewer-1',
|
|
220
|
+
role: 'reviewer',
|
|
221
|
+
prompt: 'Review code changes',
|
|
222
|
+
teamName: 'my-team',
|
|
223
|
+
});
|
|
224
|
+
// Pass agentInput to Claude Code's Task tool
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
#### Messaging
|
|
228
|
+
|
|
229
|
+
```typescript
|
|
230
|
+
// Send direct message
|
|
231
|
+
const message = await bridge.sendMessage(
|
|
232
|
+
'my-team',
|
|
233
|
+
'sender-id',
|
|
234
|
+
'recipient-id',
|
|
235
|
+
{
|
|
236
|
+
type: 'task',
|
|
237
|
+
payload: { action: 'implement', target: 'auth' },
|
|
238
|
+
priority: 'high',
|
|
239
|
+
}
|
|
240
|
+
);
|
|
241
|
+
|
|
242
|
+
// Broadcast to all teammates
|
|
243
|
+
await bridge.broadcast('my-team', 'coordinator-id', {
|
|
244
|
+
type: 'status',
|
|
245
|
+
payload: { phase: 'implementation' },
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
// Read mailbox
|
|
249
|
+
const messages = await bridge.readMailbox('my-team', 'teammate-id');
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
#### Plan Approval
|
|
253
|
+
|
|
254
|
+
```typescript
|
|
255
|
+
// Submit plan
|
|
256
|
+
const plan = await bridge.submitPlan('my-team', {
|
|
257
|
+
description: 'Implement authentication feature',
|
|
258
|
+
proposedBy: 'coordinator-id',
|
|
259
|
+
steps: [
|
|
260
|
+
{ order: 1, action: 'Create user model', tools: ['Edit'], assignee: 'coder-1' },
|
|
261
|
+
{ order: 2, action: 'Add JWT middleware', tools: ['Edit'], assignee: 'coder-1' },
|
|
262
|
+
{ order: 3, action: 'Write unit tests', tools: ['Edit'], assignee: 'tester-1' },
|
|
263
|
+
],
|
|
264
|
+
requiredApprovals: 2,
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
// Approve plan
|
|
268
|
+
await bridge.approvePlan('my-team', plan.id, 'reviewer-id');
|
|
269
|
+
|
|
270
|
+
// Launch swarm (after approval)
|
|
271
|
+
const exitPlanInput = await bridge.launchSwarm('my-team', plan.id, 3);
|
|
272
|
+
// Pass exitPlanInput to ExitPlanMode tool
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
#### Delegation
|
|
276
|
+
|
|
277
|
+
```typescript
|
|
278
|
+
// Delegate authority
|
|
279
|
+
const delegation = await bridge.delegateToTeammate(
|
|
280
|
+
'my-team',
|
|
281
|
+
'lead-id',
|
|
282
|
+
'dev-id',
|
|
283
|
+
['approve_plan', 'spawn_teammate']
|
|
284
|
+
);
|
|
285
|
+
|
|
286
|
+
// Revoke delegation
|
|
287
|
+
await bridge.revokeDelegation('my-team', 'lead-id', 'dev-id');
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
#### Team Context
|
|
291
|
+
|
|
292
|
+
```typescript
|
|
293
|
+
// Update context
|
|
294
|
+
await bridge.updateTeamContext('my-team', {
|
|
295
|
+
sharedVariables: {
|
|
296
|
+
apiEndpoint: 'https://api.example.com',
|
|
297
|
+
version: '1.0.0',
|
|
298
|
+
},
|
|
299
|
+
inheritedPermissions: ['read', 'write'],
|
|
300
|
+
environmentVariables: {
|
|
301
|
+
NODE_ENV: 'development',
|
|
302
|
+
},
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
// Get context
|
|
306
|
+
const context = bridge.getTeamContext('my-team');
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
#### Session Memory
|
|
310
|
+
|
|
311
|
+
```typescript
|
|
312
|
+
// Save teammate memory
|
|
313
|
+
await bridge.saveTeammateMemory('my-team', 'teammate-id');
|
|
314
|
+
|
|
315
|
+
// Load teammate memory
|
|
316
|
+
const memory = await bridge.loadTeammateMemory('my-team', 'teammate-id');
|
|
317
|
+
|
|
318
|
+
// Share transcript
|
|
319
|
+
await bridge.shareTranscript('my-team', 'from-id', 'to-id', {
|
|
320
|
+
start: 0,
|
|
321
|
+
end: 10,
|
|
322
|
+
});
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
#### Teleport
|
|
326
|
+
|
|
327
|
+
```typescript
|
|
328
|
+
// Check if teleport is possible
|
|
329
|
+
const { canTeleport, blockers } = await bridge.canTeleport('my-team', {
|
|
330
|
+
workingDirectory: '/path/to/new/dir',
|
|
331
|
+
gitBranch: 'feature/auth',
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
// Teleport team
|
|
335
|
+
if (canTeleport) {
|
|
336
|
+
const result = await bridge.teleportTeam('my-team', {
|
|
337
|
+
workingDirectory: '/path/to/new/dir',
|
|
338
|
+
gitBranch: 'feature/auth',
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
### MCP Tools
|
|
344
|
+
|
|
345
|
+
The plugin provides 16 MCP tools for use with Claude Code's MCP server:
|
|
346
|
+
|
|
347
|
+
```typescript
|
|
348
|
+
import { TEAMMATE_MCP_TOOLS, handleMCPTool } from '@claude-flow/teammate-plugin';
|
|
349
|
+
|
|
350
|
+
// List all tools
|
|
351
|
+
console.log(TEAMMATE_MCP_TOOLS.map(t => t.name));
|
|
352
|
+
// [
|
|
353
|
+
// 'teammate_spawn_team',
|
|
354
|
+
// 'teammate_discover_teams',
|
|
355
|
+
// 'teammate_spawn',
|
|
356
|
+
// 'teammate_send_message',
|
|
357
|
+
// 'teammate_broadcast',
|
|
358
|
+
// 'teammate_submit_plan',
|
|
359
|
+
// 'teammate_approve_plan',
|
|
360
|
+
// 'teammate_launch_swarm',
|
|
361
|
+
// 'teammate_delegate',
|
|
362
|
+
// 'teammate_update_context',
|
|
363
|
+
// 'teammate_save_memory',
|
|
364
|
+
// 'teammate_share_transcript',
|
|
365
|
+
// 'teammate_push_remote',
|
|
366
|
+
// 'teammate_teleport',
|
|
367
|
+
// 'teammate_get_status',
|
|
368
|
+
// 'teammate_cleanup',
|
|
369
|
+
// ]
|
|
370
|
+
|
|
371
|
+
// Handle tool call
|
|
372
|
+
const result = await handleMCPTool(bridge, 'teammate_spawn_team', {
|
|
373
|
+
name: 'my-team',
|
|
374
|
+
topology: 'hierarchical',
|
|
375
|
+
});
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
## Events
|
|
379
|
+
|
|
380
|
+
The bridge emits events for all operations:
|
|
381
|
+
|
|
382
|
+
```typescript
|
|
383
|
+
bridge.on('team:spawned', ({ team, config }) => {
|
|
384
|
+
console.log(`Team ${team} created`);
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
bridge.on('teammate:spawned', ({ teammate, agentInput }) => {
|
|
388
|
+
console.log(`Teammate ${teammate.name} spawned`);
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
bridge.on('plan:approved', ({ team, plan }) => {
|
|
392
|
+
console.log(`Plan ${plan.id} approved`);
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
bridge.on('delegate:granted', ({ team, from, to, permissions }) => {
|
|
396
|
+
console.log(`${from} delegated to ${to}: ${permissions.join(', ')}`);
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
bridge.on('teleport:completed', ({ team, result }) => {
|
|
400
|
+
console.log(`Team ${team} teleported successfully`);
|
|
401
|
+
});
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
## Error Handling
|
|
405
|
+
|
|
406
|
+
```typescript
|
|
407
|
+
import { TeammateError, TeammateErrorCode } from '@claude-flow/teammate-plugin';
|
|
408
|
+
|
|
409
|
+
try {
|
|
410
|
+
await bridge.launchSwarm('my-team', 'plan-id');
|
|
411
|
+
} catch (error) {
|
|
412
|
+
if (error instanceof TeammateError) {
|
|
413
|
+
switch (error.code) {
|
|
414
|
+
case TeammateErrorCode.PLAN_NOT_APPROVED:
|
|
415
|
+
console.log('Plan needs approval first');
|
|
416
|
+
break;
|
|
417
|
+
case TeammateErrorCode.TEAM_NOT_FOUND:
|
|
418
|
+
console.log(`Team not found: ${error.teamName}`);
|
|
419
|
+
break;
|
|
420
|
+
case TeammateErrorCode.VERSION_INCOMPATIBLE:
|
|
421
|
+
console.log('Claude Code version too old');
|
|
422
|
+
break;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
## Configuration
|
|
429
|
+
|
|
430
|
+
```typescript
|
|
431
|
+
import { createTeammateBridge, DEFAULT_PLUGIN_CONFIG } from '@claude-flow/teammate-plugin';
|
|
432
|
+
|
|
433
|
+
const bridge = await createTeammateBridge({
|
|
434
|
+
autoInitialize: true,
|
|
435
|
+
fallbackToMCP: true,
|
|
436
|
+
|
|
437
|
+
recovery: {
|
|
438
|
+
maxRetries: 3,
|
|
439
|
+
retryDelayMs: 1000,
|
|
440
|
+
exponentialBackoff: true,
|
|
441
|
+
fallbackToMCP: true,
|
|
442
|
+
autoCleanupOnError: true,
|
|
443
|
+
},
|
|
444
|
+
|
|
445
|
+
delegation: {
|
|
446
|
+
maxDepth: 3,
|
|
447
|
+
autoExpireMs: 3600000, // 1 hour
|
|
448
|
+
requireApproval: false,
|
|
449
|
+
},
|
|
450
|
+
|
|
451
|
+
remoteSync: {
|
|
452
|
+
enabled: false,
|
|
453
|
+
autoSync: false,
|
|
454
|
+
syncInterval: 30000,
|
|
455
|
+
preserveOnDisconnect: true,
|
|
456
|
+
},
|
|
457
|
+
|
|
458
|
+
teleport: {
|
|
459
|
+
autoResume: true,
|
|
460
|
+
gitAware: true,
|
|
461
|
+
preserveMailbox: true,
|
|
462
|
+
preserveMemory: true,
|
|
463
|
+
},
|
|
464
|
+
|
|
465
|
+
memory: {
|
|
466
|
+
autoPersist: true,
|
|
467
|
+
persistIntervalMs: 60000,
|
|
468
|
+
maxSizeMb: 100,
|
|
469
|
+
},
|
|
470
|
+
|
|
471
|
+
mailbox: {
|
|
472
|
+
pollingIntervalMs: 1000,
|
|
473
|
+
maxMessages: 1000,
|
|
474
|
+
retentionMs: 3600000,
|
|
475
|
+
},
|
|
476
|
+
});
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
## Integration with Claude Flow
|
|
480
|
+
|
|
481
|
+
```typescript
|
|
482
|
+
import { createTeammateBridge } from '@claude-flow/teammate-plugin';
|
|
483
|
+
import { UnifiedSwarmCoordinator } from '@claude-flow/swarm';
|
|
484
|
+
|
|
485
|
+
// Create bridge
|
|
486
|
+
const bridge = await createTeammateBridge();
|
|
487
|
+
|
|
488
|
+
// Map Claude Flow topology to team config
|
|
489
|
+
const teamConfig = {
|
|
490
|
+
name: 'cf-team',
|
|
491
|
+
topology: 'hierarchical', // Maps to Claude Flow's hierarchical
|
|
492
|
+
maxTeammates: 8,
|
|
493
|
+
planModeRequired: true,
|
|
494
|
+
};
|
|
495
|
+
|
|
496
|
+
// Create team
|
|
497
|
+
const team = await bridge.spawnTeam(teamConfig);
|
|
498
|
+
|
|
499
|
+
// Map Claude Flow agent types to teammate configs
|
|
500
|
+
const agentMapping = {
|
|
501
|
+
'coder': { role: 'coder', tools: ['Edit', 'Write', 'Read', 'Bash'] },
|
|
502
|
+
'tester': { role: 'tester', tools: ['Read', 'Bash', 'Glob'] },
|
|
503
|
+
'reviewer': { role: 'reviewer', tools: ['Read', 'Grep', 'Glob'] },
|
|
504
|
+
'architect': { role: 'architect', tools: ['Read', 'Glob', 'Grep'] },
|
|
505
|
+
};
|
|
506
|
+
|
|
507
|
+
// Spawn teammates with Claude Flow agent types
|
|
508
|
+
for (const [type, config] of Object.entries(agentMapping)) {
|
|
509
|
+
await bridge.spawnTeammate({
|
|
510
|
+
name: `${type}-1`,
|
|
511
|
+
role: config.role,
|
|
512
|
+
prompt: `You are a ${type}...`,
|
|
513
|
+
teamName: 'cf-team',
|
|
514
|
+
allowedTools: config.tools,
|
|
515
|
+
});
|
|
516
|
+
}
|
|
517
|
+
```
|
|
518
|
+
|
|
519
|
+
## File Structure
|
|
520
|
+
|
|
521
|
+
Teams are stored in `~/.claude/teams/`:
|
|
522
|
+
|
|
523
|
+
```
|
|
524
|
+
~/.claude/teams/
|
|
525
|
+
├── my-team/
|
|
526
|
+
│ ├── config.json # Team configuration
|
|
527
|
+
│ ├── state.json # Team state (teammates, plans)
|
|
528
|
+
│ ├── remote.json # Remote session info (if synced)
|
|
529
|
+
│ ├── mailbox/
|
|
530
|
+
│ │ ├── teammate-1.json
|
|
531
|
+
│ │ └── teammate-2.json
|
|
532
|
+
│ └── memory/
|
|
533
|
+
│ ├── teammate-1.json
|
|
534
|
+
│ └── teammate-2.json
|
|
535
|
+
└── other-team/
|
|
536
|
+
└── ...
|
|
537
|
+
```
|
|
538
|
+
|
|
539
|
+
## Environment Variables
|
|
540
|
+
|
|
541
|
+
The plugin uses these Claude Code environment variables:
|
|
542
|
+
|
|
543
|
+
```bash
|
|
544
|
+
CLAUDE_CODE_TEAM_NAME # Current team context
|
|
545
|
+
CLAUDE_CODE_PLAN_MODE_REQUIRED # Require plan approval
|
|
546
|
+
CLAUDE_CODE_TMUX_SESSION # tmux session name
|
|
547
|
+
CLAUDE_CODE_TMUX_PREFIX # tmux prefix key
|
|
548
|
+
CLAUDE_CODE_TEAMMATE_COMMAND # Custom spawn command
|
|
549
|
+
```
|
|
550
|
+
|
|
551
|
+
## Troubleshooting
|
|
552
|
+
|
|
553
|
+
### Plugin reports TeammateTool not available
|
|
554
|
+
|
|
555
|
+
```typescript
|
|
556
|
+
const version = bridge.getVersionInfo();
|
|
557
|
+
if (!version.compatible) {
|
|
558
|
+
console.log(`Claude Code version: ${version.claudeCode}`);
|
|
559
|
+
console.log(`Required: >= 2.1.19`);
|
|
560
|
+
console.log('Run: claude update');
|
|
561
|
+
}
|
|
562
|
+
```
|
|
563
|
+
|
|
564
|
+
### Mailbox messages not received
|
|
565
|
+
|
|
566
|
+
Check that mailbox polling is running:
|
|
567
|
+
|
|
568
|
+
```typescript
|
|
569
|
+
// Mailbox is polled automatically, but you can read manually
|
|
570
|
+
const messages = await bridge.readMailbox('my-team', 'teammate-id');
|
|
571
|
+
```
|
|
572
|
+
|
|
573
|
+
### Plan approval stuck
|
|
574
|
+
|
|
575
|
+
Ensure enough teammates have voted:
|
|
576
|
+
|
|
577
|
+
```typescript
|
|
578
|
+
const team = bridge.getTeamState('my-team');
|
|
579
|
+
const plan = team.activePlans.find(p => p.id === planId);
|
|
580
|
+
|
|
581
|
+
console.log(`Approvals: ${plan.approvals.length}/${plan.requiredApprovals}`);
|
|
582
|
+
console.log(`Rejections: ${plan.rejections.length}`);
|
|
583
|
+
```
|
|
584
|
+
|
|
585
|
+
## Testing the Plugin
|
|
586
|
+
|
|
587
|
+
### Run Unit Tests
|
|
588
|
+
|
|
589
|
+
```bash
|
|
590
|
+
cd v3/plugins/teammate-plugin
|
|
591
|
+
|
|
592
|
+
# Install dependencies
|
|
593
|
+
npm install
|
|
594
|
+
|
|
595
|
+
# Run tests
|
|
596
|
+
npm test
|
|
597
|
+
|
|
598
|
+
# Run tests with coverage
|
|
599
|
+
npm run test:coverage
|
|
600
|
+
```
|
|
601
|
+
|
|
602
|
+
### Verify Plugin Functionality
|
|
603
|
+
|
|
604
|
+
```typescript
|
|
605
|
+
import { createTeammateBridge, TEAMMATE_MCP_TOOLS } from '@claude-flow/teammate-plugin';
|
|
606
|
+
|
|
607
|
+
async function verifyPlugin() {
|
|
608
|
+
console.log('=== Plugin Verification ===\n');
|
|
609
|
+
|
|
610
|
+
// 1. Check MCP tools are exported
|
|
611
|
+
console.log(`✓ MCP Tools available: ${TEAMMATE_MCP_TOOLS.length}`);
|
|
612
|
+
|
|
613
|
+
// 2. Initialize bridge
|
|
614
|
+
const bridge = await createTeammateBridge();
|
|
615
|
+
console.log('✓ Bridge initialized');
|
|
616
|
+
|
|
617
|
+
// 3. Check version compatibility
|
|
618
|
+
const version = bridge.getVersionInfo();
|
|
619
|
+
console.log(`✓ Claude Code version: ${version.claudeCode || 'not detected'}`);
|
|
620
|
+
console.log(`✓ Plugin version: ${version.plugin}`);
|
|
621
|
+
console.log(`✓ Compatible: ${version.compatible}`);
|
|
622
|
+
|
|
623
|
+
// 4. Test team creation (if compatible)
|
|
624
|
+
if (version.compatible) {
|
|
625
|
+
const team = await bridge.spawnTeam({ name: 'test-team' });
|
|
626
|
+
console.log(`✓ Team created: ${team.name}`);
|
|
627
|
+
|
|
628
|
+
// Cleanup
|
|
629
|
+
await bridge.cleanup('test-team');
|
|
630
|
+
console.log('✓ Cleanup successful');
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
console.log('\n=== All checks passed! ===');
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
verifyPlugin().catch(console.error);
|
|
637
|
+
```
|
|
638
|
+
|
|
639
|
+
### Verify via CLI
|
|
640
|
+
|
|
641
|
+
```bash
|
|
642
|
+
# Check plugin is registered
|
|
643
|
+
npx @claude-flow/cli@latest plugins list | grep teammate
|
|
644
|
+
|
|
645
|
+
# Check plugin info
|
|
646
|
+
npx @claude-flow/cli@latest plugins info teammate-plugin
|
|
647
|
+
|
|
648
|
+
# Test MCP tools
|
|
649
|
+
npx @claude-flow/cli@latest mcp tools | grep teammate
|
|
650
|
+
```
|
|
651
|
+
|
|
652
|
+
## Plugin Registry (IPFS)
|
|
653
|
+
|
|
654
|
+
This plugin is published to the Claude Flow Plugin Registry on IPFS for decentralized distribution.
|
|
655
|
+
|
|
656
|
+
### Registry Entry
|
|
657
|
+
|
|
658
|
+
```json
|
|
659
|
+
{
|
|
660
|
+
"name": "teammate-plugin",
|
|
661
|
+
"package": "@claude-flow/teammate-plugin",
|
|
662
|
+
"version": "1.0.0-alpha.1",
|
|
663
|
+
"description": "Native TeammateTool integration for Claude Code v2.1.19+",
|
|
664
|
+
"author": "Claude Flow Team",
|
|
665
|
+
"license": "MIT",
|
|
666
|
+
"repository": "https://github.com/ruvnet/claude-flow",
|
|
667
|
+
"keywords": ["claude-code", "teammate", "multi-agent", "swarm"],
|
|
668
|
+
"requirements": {
|
|
669
|
+
"claudeCode": ">=2.1.19",
|
|
670
|
+
"node": ">=18.0.0"
|
|
671
|
+
},
|
|
672
|
+
"mcpTools": 21,
|
|
673
|
+
"features": [
|
|
674
|
+
"team-management",
|
|
675
|
+
"teammate-spawning",
|
|
676
|
+
"messaging",
|
|
677
|
+
"plan-approval",
|
|
678
|
+
"delegation",
|
|
679
|
+
"remote-sync",
|
|
680
|
+
"bmssp-optimization"
|
|
681
|
+
]
|
|
682
|
+
}
|
|
683
|
+
```
|
|
684
|
+
|
|
685
|
+
### Install from Registry
|
|
686
|
+
|
|
687
|
+
```bash
|
|
688
|
+
# Install from IPFS-backed registry
|
|
689
|
+
npx @claude-flow/cli@latest plugins install teammate-plugin --registry ipfs
|
|
690
|
+
|
|
691
|
+
# Or specify registry CID directly
|
|
692
|
+
npx @claude-flow/cli@latest plugins install teammate-plugin --cid <registry-cid>
|
|
693
|
+
```
|
|
694
|
+
|
|
695
|
+
### Verify Registry Integrity
|
|
696
|
+
|
|
697
|
+
```bash
|
|
698
|
+
# Check plugin hash matches registry
|
|
699
|
+
npx @claude-flow/cli@latest plugins verify teammate-plugin
|
|
700
|
+
|
|
701
|
+
# View registry metadata
|
|
702
|
+
npx @claude-flow/cli@latest plugins registry info
|
|
703
|
+
```
|
|
704
|
+
|
|
705
|
+
## License
|
|
706
|
+
|
|
707
|
+
MIT
|
|
708
|
+
|
|
709
|
+
## Related
|
|
710
|
+
|
|
711
|
+
- [Claude Flow](https://github.com/ruvnet/claude-flow) - Multi-agent orchestration framework
|
|
712
|
+
- [Claude Code](https://github.com/anthropics/claude-code) - Anthropic's CLI for Claude
|
|
713
|
+
- [ADR-027](../implementation/adrs/ADR-027-teammate-tool-integration.md) - Architecture decision record
|
package/package.json
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sparkleideas/teammate-plugin",
|
|
3
|
+
"version": "1.0.0-alpha.11",
|
|
4
|
+
"description": "Native TeammateTool integration plugin for Claude Flow - bridges Claude Code v2.1.19+ multi-agent capabilities",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
},
|
|
13
|
+
"./bridge": {
|
|
14
|
+
"import": "./dist/teammate-bridge.js",
|
|
15
|
+
"types": "./dist/teammate-bridge.d.ts"
|
|
16
|
+
},
|
|
17
|
+
"./mcp": {
|
|
18
|
+
"import": "./dist/mcp-tools.js",
|
|
19
|
+
"types": "./dist/mcp-tools.d.ts"
|
|
20
|
+
},
|
|
21
|
+
"./topology": {
|
|
22
|
+
"import": "./dist/topology-optimizer.js",
|
|
23
|
+
"types": "./dist/topology-optimizer.d.ts"
|
|
24
|
+
},
|
|
25
|
+
"./semantic": {
|
|
26
|
+
"import": "./dist/semantic-router.js",
|
|
27
|
+
"types": "./dist/semantic-router.d.ts"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist",
|
|
32
|
+
"README.md"
|
|
33
|
+
],
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "tsc",
|
|
36
|
+
"test": "vitest run",
|
|
37
|
+
"test:watch": "vitest",
|
|
38
|
+
"test:coverage": "vitest run --coverage",
|
|
39
|
+
"lint": "eslint src --ext .ts",
|
|
40
|
+
"clean": "rm -rf dist",
|
|
41
|
+
"prepublishOnly": "npm run clean && npm run build && npm run test"
|
|
42
|
+
},
|
|
43
|
+
"keywords": [
|
|
44
|
+
"claude",
|
|
45
|
+
"claude-code",
|
|
46
|
+
"claude-flow",
|
|
47
|
+
"teammate",
|
|
48
|
+
"multi-agent",
|
|
49
|
+
"swarm",
|
|
50
|
+
"orchestration",
|
|
51
|
+
"mcp"
|
|
52
|
+
],
|
|
53
|
+
"author": "rUv <ruv@ruv.net>",
|
|
54
|
+
"license": "MIT",
|
|
55
|
+
"repository": {
|
|
56
|
+
"type": "git",
|
|
57
|
+
"url": "https://github.com/ruvnet/claude-flow.git",
|
|
58
|
+
"directory": "v3/plugins/teammate-plugin"
|
|
59
|
+
},
|
|
60
|
+
"bugs": {
|
|
61
|
+
"url": "https://github.com/ruvnet/claude-flow/issues"
|
|
62
|
+
},
|
|
63
|
+
"homepage": "https://github.com/ruvnet/claude-flow#readme",
|
|
64
|
+
"engines": {
|
|
65
|
+
"node": ">=18.0.0"
|
|
66
|
+
},
|
|
67
|
+
"peerDependencies": {
|
|
68
|
+
"@anthropic-ai/claude-code": ">=2.1.19"
|
|
69
|
+
},
|
|
70
|
+
"peerDependenciesMeta": {
|
|
71
|
+
"@anthropic-ai/claude-code": {
|
|
72
|
+
"optional": true
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
"dependencies": {
|
|
76
|
+
"eventemitter3": "^5.0.1",
|
|
77
|
+
"@ruvnet/bmssp": "^1.0.0"
|
|
78
|
+
},
|
|
79
|
+
"devDependencies": {
|
|
80
|
+
"@types/node": "^20.10.0",
|
|
81
|
+
"typescript": "^5.3.0",
|
|
82
|
+
"vitest": "^1.0.0",
|
|
83
|
+
"@vitest/coverage-v8": "^1.0.0",
|
|
84
|
+
"eslint": "^8.55.0",
|
|
85
|
+
"@typescript-eslint/eslint-plugin": "^6.13.0",
|
|
86
|
+
"@typescript-eslint/parser": "^6.13.0"
|
|
87
|
+
},
|
|
88
|
+
"claude-code": {
|
|
89
|
+
"minimumVersion": "2.1.19",
|
|
90
|
+
"requiredFeatures": [
|
|
91
|
+
"TeammateTool",
|
|
92
|
+
"team_name",
|
|
93
|
+
"launchSwarm"
|
|
94
|
+
],
|
|
95
|
+
"optionalFeatures": [
|
|
96
|
+
"pushToRemote",
|
|
97
|
+
"delegate_mode",
|
|
98
|
+
"teleport"
|
|
99
|
+
]
|
|
100
|
+
}
|
|
101
|
+
}
|