opencode-swarm-plugin 0.55.0 → 0.56.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.
@@ -0,0 +1,10 @@
1
+ {
2
+ "mcpServers": {
3
+ "swarm-tools": {
4
+ "command": "bun",
5
+ "args": ["run", "${CLAUDE_PLUGIN_ROOT}/bin/swarm-mcp-server.ts"],
6
+ "cwd": "${CLAUDE_PLUGIN_ROOT}",
7
+ "description": "Swarm multi-agent coordination tools"
8
+ }
9
+ }
10
+ }
@@ -0,0 +1,36 @@
1
+ ---
2
+ name: background-worker
3
+ description: Runs background-only tasks without MCP tool access.
4
+ model: haiku
5
+ skills:
6
+ - swarm-coordination
7
+ - testing-patterns
8
+ tools:
9
+ - Read
10
+ - Write
11
+ - Edit
12
+ - Glob
13
+ - Grep
14
+ - Bash
15
+ ---
16
+
17
+ # Background Worker Agent
18
+
19
+ Background workers are for tasks that **do not require MCP tools** (summaries, doc edits, light refactors).
20
+
21
+ ## Constraints
22
+
23
+ - **No MCP tools** are available in background subagents.
24
+ - Avoid tasks that require live coordination, swarmmail, or hive operations.
25
+ - If MCP tools are needed, request a foreground worker instead.
26
+
27
+ ## Safe Use Cases
28
+
29
+ - Documentation updates
30
+ - Static file edits
31
+ - Copy edits and formatting
32
+ - Notes, summaries, and small refactors
33
+
34
+ ## Usage Guidance
35
+
36
+ If a task needs tool coordination or swarmmail calls, switch to a foreground worker.
@@ -0,0 +1,39 @@
1
+ ---
2
+ name: coordinator
3
+ description: Orchestrates swarm coordination and supervises worker agents.
4
+ model: opus
5
+ skills:
6
+ - swarm-coordination
7
+ - system-design
8
+ - testing-patterns
9
+ - cli-builder
10
+ tools:
11
+ - "*"
12
+ ---
13
+
14
+ # Swarm Coordinator Agent
15
+
16
+ Orchestrates swarm work: decomposes tasks, spawns workers, monitors progress, and reviews results.
17
+
18
+ ## Operating Rules
19
+
20
+ - **Always initialize Swarm Mail first** with `swarmmail_init` before any coordination.
21
+ - **Never reserve files** as the coordinator. Workers reserve their own files.
22
+ - **Decompose with intent** using `swarm_plan_prompt` + `swarm_validate_decomposition`.
23
+ - **Review every worker completion** via `swarm_review` + `swarm_review_feedback`.
24
+ - **Record outcomes** with `swarm_complete` for learning signals.
25
+
26
+ ## Tool Access
27
+
28
+ This agent is configured with `tools: ["*"]` to allow full tool access per user choice.
29
+ If you need to restrict access later, replace the wildcard with a curated list.
30
+
31
+ ## Foreground Requirement
32
+
33
+ MCP tools are **foreground-only**. Keep the coordinator in the foreground if it must call MCP tools.
34
+
35
+ ## Output Expectations
36
+
37
+ - Produce clear decomposition plans and worker prompts.
38
+ - Provide milestone updates, risks, and decisions to the user.
39
+ - Escalate blockers quickly via Swarm Mail.
@@ -0,0 +1,42 @@
1
+ ---
2
+ name: worker
3
+ description: Executes a single subtask with file reservations and progress reporting.
4
+ model: sonnet
5
+ skills:
6
+ - swarm-coordination
7
+ - testing-patterns
8
+ - system-design
9
+ tools:
10
+ - "*"
11
+ ---
12
+
13
+ # Swarm Worker Agent
14
+
15
+ Executes a scoped subtask and reports progress to the coordinator.
16
+
17
+ ## Mandatory Checklist (Condensed)
18
+
19
+ 1. `swarmmail_init` first
20
+ 2. `hivemind_find` before coding
21
+ 3. `skills_use` for relevant skills
22
+ 4. `swarmmail_reserve` assigned files
23
+ 5. Implement changes
24
+ 6. `swarm_progress` at 25/50/75%
25
+ 7. `swarm_checkpoint` before risky ops
26
+ 8. `hivemind_store` learnings
27
+ 9. `swarm_complete` to finish
28
+
29
+ ## Tool Access
30
+
31
+ This agent is configured with `tools: ["*"]` to allow full tool access per user choice.
32
+ If you need to restrict access later, replace the wildcard with a curated list.
33
+
34
+ ## Foreground Requirement
35
+
36
+ MCP tools are **foreground-only**. Keep this worker in the foreground when MCP tools are required.
37
+
38
+ ## Expectations
39
+
40
+ - Follow TDD: red → green → refactor.
41
+ - Respect file reservations and coordinate conflicts via Swarm Mail.
42
+ - Provide clear progress updates and blockers.
@@ -0,0 +1,103 @@
1
+ #!/usr/bin/env bun
2
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
4
+ import { allTools } from "../../dist/index.js";
5
+
6
+ type ToolContext = {
7
+ sessionID: string;
8
+ messageID: string;
9
+ agent: string;
10
+ abort: AbortSignal;
11
+ };
12
+
13
+ type ToolDefinition = {
14
+ description?: string;
15
+ args?: Record<string, unknown>;
16
+ execute: (args: Record<string, unknown>, context: ToolContext) => Promise<unknown> | unknown;
17
+ };
18
+
19
+ /**
20
+ * Build a tool execution context for MCP tool calls.
21
+ */
22
+ function createToolContext(): ToolContext {
23
+ const sessionId =
24
+ process.env.CLAUDE_SESSION_ID ||
25
+ process.env.OPENCODE_SESSION_ID ||
26
+ `mcp-${Date.now()}`;
27
+ const messageId =
28
+ process.env.CLAUDE_MESSAGE_ID ||
29
+ process.env.OPENCODE_MESSAGE_ID ||
30
+ `msg-${Date.now()}`;
31
+ const agent =
32
+ process.env.CLAUDE_AGENT_NAME || process.env.OPENCODE_AGENT || "claude";
33
+
34
+ return {
35
+ sessionID: sessionId,
36
+ messageID: messageId,
37
+ agent,
38
+ abort: new AbortController().signal,
39
+ };
40
+ }
41
+
42
+ /**
43
+ * Normalize tool execution results into text output.
44
+ */
45
+ function formatToolOutput(result: unknown): string {
46
+ if (typeof result === "string") {
47
+ return result;
48
+ }
49
+
50
+ try {
51
+ return JSON.stringify(result, null, 2);
52
+ } catch {
53
+ return String(result);
54
+ }
55
+ }
56
+
57
+ /**
58
+ * Register all swarm tools with the MCP server.
59
+ */
60
+ function registerTools(server: McpServer): void {
61
+ const tools = allTools as Record<string, ToolDefinition>;
62
+
63
+ for (const [toolName, toolDef] of Object.entries(tools)) {
64
+ server.registerTool(
65
+ toolName,
66
+ {
67
+ description: toolDef.description ?? `Swarm tool: ${toolName}`,
68
+ inputSchema: toolDef.args ?? {},
69
+ },
70
+ async (args) => {
71
+ const result = await toolDef.execute(
72
+ (args ?? {}) as Record<string, unknown>,
73
+ createToolContext(),
74
+ );
75
+
76
+ return {
77
+ content: [{ type: "text", text: formatToolOutput(result) }],
78
+ };
79
+ },
80
+ );
81
+ }
82
+ }
83
+
84
+ /**
85
+ * Start the MCP server over stdio for Claude Code auto-launch.
86
+ */
87
+ async function main(): Promise<void> {
88
+ const server = new McpServer({
89
+ name: "swarm-tools",
90
+ version: process.env.SWARM_VERSION || "dev",
91
+ });
92
+
93
+ registerTools(server);
94
+
95
+ const transport = new StdioServerTransport();
96
+ await server.connect(transport);
97
+ console.error("[swarm-mcp] Server started");
98
+ }
99
+
100
+ main().catch((error) => {
101
+ console.error("[swarm-mcp] Server failed", error);
102
+ process.exit(1);
103
+ });
@@ -0,0 +1,17 @@
1
+ ---
2
+ description: Properly end a swarm session - release reservations, sync state, generate continuation prompt
3
+ ---
4
+
5
+ # /swarm:handoff
6
+
7
+ Wrap up a swarm session cleanly.
8
+
9
+ ## Workflow
10
+ 1. Summarize completed work and open blockers.
11
+ 2. `swarmmail_release()` to free reservations (if any).
12
+ 3. Update cells with `hive_update()` or `hive_close()`.
13
+ 4. `hive_sync()` to persist state to git.
14
+ 5. Provide a concise handoff note for the next session.
15
+
16
+ ## Usage
17
+ `/swarm:handoff`
@@ -0,0 +1,19 @@
1
+ ---
2
+ description: Query and manage swarm tasks (cells)
3
+ ---
4
+
5
+ # /swarm:hive
6
+
7
+ Manage Hive cells with the `hive_*` tools (never the deprecated `bd` CLI).
8
+
9
+ ## Common actions
10
+ - List ready work: `hive_ready()`
11
+ - Query by status: `hive_query({ status: "open" })`
12
+ - Create a task: `hive_create({ title, type, priority })`
13
+ - Update status/description: `hive_update(id, { status, description })`
14
+ - Close a cell: `hive_close(id, "Done")`
15
+
16
+ ## Usage
17
+ - `/swarm:hive`
18
+ - `/swarm:hive create "Fix auth bug"`
19
+ - `/swarm:hive close <cell-id> "Done"`
@@ -0,0 +1,15 @@
1
+ ---
2
+ description: Check swarm mail inbox for messages from other agents
3
+ ---
4
+
5
+ # /swarm:inbox
6
+
7
+ Review Swarm Mail without blowing context.
8
+
9
+ ## Workflow
10
+ 1. `swarmmail_inbox()` for headers (max 5).
11
+ 2. `swarmmail_read_message(message_id)` for details.
12
+ 3. `swarmmail_ack(message_id)` when handled.
13
+
14
+ ## Usage
15
+ `/swarm:inbox`
@@ -0,0 +1,15 @@
1
+ ---
2
+ description: Check swarm coordination status - workers, messages, reservations
3
+ ---
4
+
5
+ # /swarm:status
6
+
7
+ Summarize active swarm state.
8
+
9
+ ## Workflow
10
+ 1. `swarm_status({ epic_id, project_key })` for progress and workers.
11
+ 2. `swarmmail_inbox()` to surface new messages.
12
+ 3. `hive_query({ status: "in_progress" })` for active cells.
13
+
14
+ ## Usage
15
+ `/swarm:status`
@@ -0,0 +1,19 @@
1
+ ---
2
+ description: Decompose a task into parallel subtasks and coordinate execution
3
+ ---
4
+
5
+ # /swarm:swarm
6
+
7
+ Use this command to kick off a multi-agent swarm.
8
+
9
+ ## Workflow
10
+ 1. Clarify scope and success criteria if needed.
11
+ 2. `swarmmail_init()` to register the session.
12
+ 3. `swarm_decompose()` → `swarm_validate_decomposition()` for a safe plan.
13
+ 4. `hive_create_epic()` to create the epic + subtasks.
14
+ 5. `swarm_spawn_subtask()` for each subtask (workers reserve files).
15
+ 6. Monitor with `swarm_status()` and `swarmmail_inbox()`.
16
+ 7. Review workers with `swarm_review()` + `swarm_review_feedback()`.
17
+
18
+ ## Usage
19
+ `/swarm:swarm Add OAuth authentication with Google and GitHub`
@@ -0,0 +1,48 @@
1
+ {
2
+ "hooks": {
3
+ "SessionStart": [
4
+ {
5
+ "matcher": "",
6
+ "hooks": [
7
+ {
8
+ "type": "command",
9
+ "command": "swarm claude session-start"
10
+ }
11
+ ]
12
+ }
13
+ ],
14
+ "UserPromptSubmit": [
15
+ {
16
+ "matcher": "",
17
+ "hooks": [
18
+ {
19
+ "type": "command",
20
+ "command": "swarm claude user-prompt"
21
+ }
22
+ ]
23
+ }
24
+ ],
25
+ "PreCompact": [
26
+ {
27
+ "matcher": "",
28
+ "hooks": [
29
+ {
30
+ "type": "command",
31
+ "command": "swarm claude pre-compact"
32
+ }
33
+ ]
34
+ }
35
+ ],
36
+ "SessionEnd": [
37
+ {
38
+ "matcher": "",
39
+ "hooks": [
40
+ {
41
+ "type": "command",
42
+ "command": "swarm claude session-end"
43
+ }
44
+ ]
45
+ }
46
+ ]
47
+ }
48
+ }
@@ -0,0 +1,76 @@
1
+ ---
2
+ name: swarm-coordination
3
+ description: Multi-agent coordination patterns for OpenCode swarm workflows. Use when work benefits from parallelization or coordination.
4
+ tags:
5
+ - swarm
6
+ - multi-agent
7
+ - coordination
8
+ tools:
9
+ - "*"
10
+ related_skills:
11
+ - testing-patterns
12
+ - system-design
13
+ - cli-builder
14
+ ---
15
+
16
+ # Swarm Coordination
17
+
18
+ This skill guides multi-agent coordination for OpenCode swarm workflows.
19
+
20
+ ## When to Use
21
+
22
+ - Tasks touching 3+ files
23
+ - Parallelizable work (frontend/backend/tests)
24
+ - Work requiring specialized agents
25
+ - Time-to-completion matters
26
+
27
+ Avoid swarming for 1–2 file changes or tightly sequential work.
28
+
29
+ ## Tool Access (Wildcard)
30
+
31
+ This skill is configured with `tools: ["*"]` per user choice. If you need curated access later, replace the wildcard with explicit tool lists.
32
+
33
+ ## Foreground vs Background
34
+
35
+ - **Foreground agents** can access MCP tools.
36
+ - **Background agents** do **not** have MCP tools.
37
+ - Use foreground workers for `swarmmail_*`, `swarm_*`, `hive_*`, and MCP calls.
38
+ - Use background workers for doc edits and static work only.
39
+
40
+ ## MCP Lifecycle Mitigation
41
+
42
+ Claude Code auto-launches MCP servers from `mcpServers` configuration. Do **not** require manual `swarm mcp-serve` except for debugging.
43
+
44
+ ## Coordinator Protocol (High-Level)
45
+
46
+ 1. Initialize Swarm Mail (`swarmmail_init`).
47
+ 2. Query past learnings (`hivemind_find`).
48
+ 3. Decompose (`swarm_plan_prompt` + `swarm_validate_decomposition`).
49
+ 4. Spawn workers with explicit file lists.
50
+ 5. Review worker output (`swarm_review` + `swarm_review_feedback`).
51
+ 6. Record outcomes (`swarm_complete`).
52
+
53
+ ## Worker Protocol (High-Level)
54
+
55
+ 1. Initialize Swarm Mail (`swarmmail_init`).
56
+ 2. Reserve files (`swarmmail_reserve`).
57
+ 3. Work within scope and report progress.
58
+ 4. Complete with `swarm_complete`.
59
+
60
+ ## File Reservations
61
+
62
+ Workers must reserve files **before** editing and release via `swarm_complete`.
63
+ Coordinators never reserve files.
64
+
65
+ ## Progress Reporting
66
+
67
+ Use `swarm_progress` at 25%, 50%, and 75% completion to trigger auto-checkpoints.
68
+
69
+ ## Skill Loading Guidance
70
+
71
+ Workers should load skills based on task type:
72
+
73
+ - Tests or fixes → `testing-patterns`
74
+ - Architecture → `system-design`
75
+ - CLI work → `cli-builder`
76
+ - Coordination → `swarm-coordination`