multiclaw 0.0.0-stage → 0.2.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 PengQi Shi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,327 @@
1
- # Temporary Holding Version
1
+ # multiclaw
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![npm](https://img.shields.io/npm/v/multiclaw)](https://www.npmjs.com/package/multiclaw)
4
+ [![GitHub](https://img.shields.io/badge/GitHub-shipengqi%2Fmulticlaw-blue?logo=github)](https://github.com/shipengqi/multiclaw)
5
+
6
+ [中文](https://github.com/shipengqi/multiclaw/blob/main/README.zh-CN.md)
7
+
8
+ Multi-agent orchestration CLI. Define a pipeline of AI agents, give them a requirement, and watch them run in parallel or in sequence based on the dependency graph you declare.
9
+
10
+ ## Prerequisites
11
+
12
+ At least one AI runtime must be installed:
13
+
14
+ | Runtime | Install |
15
+ |---------|---------|
16
+ | `claude` (default) | `npm install -g @anthropic-ai/claude-code` |
17
+
18
+ > **Future support:** We plan to add support for additional runtimes (Codex, OpenCode, Cursor) in upcoming releases.
19
+
20
+ ## Install
21
+
22
+ ```bash
23
+ npm install -g multiclaw
24
+ ```
25
+
26
+ ## Quick start
27
+
28
+ ```bash
29
+ # 1. Scaffold a config in the current directory
30
+ multiclaw init
31
+
32
+ # 2. Run an orchestration
33
+ multiclaw run "Build a REST API for a todo list" --ui
34
+ ```
35
+
36
+ `--ui` opens a real-time Dashboard in the browser. Omit it to run headless.
37
+
38
+ ## Commands
39
+
40
+ ### `multiclaw init`
41
+
42
+ Interactive scaffold. Creates `multiclaw.config.ts` in the current directory.
43
+
44
+ Prompts:
45
+ - **Project name** — defaults to the current directory name
46
+ - **Preset** — pipeline template (see [Presets](#presets))
47
+ - **Work directory** — where agents read and write files
48
+
49
+ ### `multiclaw run <requirement> [options]`
50
+
51
+ Runs the orchestration defined in your config file.
52
+
53
+ | Option | Description |
54
+ |--------|-------------|
55
+ | `--config <path>` | Path to config file. Auto-discovers `multiclaw.config.ts` if omitted. |
56
+ | `--ui` | Start the Dashboard server and open it in the browser. |
57
+ | `--port <port>` | Dashboard port. Requires `--ui`. Default: `3210`. |
58
+ | `--server-url <url>` | Stream events to a running `multiclaw serve` instance. |
59
+ | `--no-leader` | Skip the leader agent and use the default pipeline directly. |
60
+
61
+ The `<requirement>` string is injected into every agent's prompt as `{{requirement}}`.
62
+
63
+ Each run creates an isolated timestamped subdirectory inside `workDir` (e.g. `workspace/run-2026-10-08T12-00-00`).
64
+
65
+ ### `multiclaw serve [options]`
66
+
67
+ Start a persistent Dashboard server. Useful for CI or when you want a permanent URL to monitor runs.
68
+
69
+ | Option | Description |
70
+ |--------|-------------|
71
+ | `--port <port>` | Port to listen on. Default: `3210`. |
72
+
73
+ Connect a run to it with `multiclaw run "..." --server-url http://localhost:3210`.
74
+
75
+ ## Config file
76
+
77
+ ```typescript
78
+ // multiclaw.config.ts
79
+ import { defineConfig, agents } from "multiclaw"
80
+
81
+ export default defineConfig({
82
+ name: "My Project",
83
+ workDir: "./workspace",
84
+
85
+ // Variables available as {{key}} in every agent's taskPrompt.
86
+ // `requirement` is automatically injected from the CLI argument.
87
+ context: {
88
+ projectName: "My App",
89
+ },
90
+
91
+ // Optional: runs before the main pipeline to decide which agents are needed.
92
+ // The leader reads the requirement and the codebase, then outputs the agent IDs to run.
93
+ leader: agents.leader(),
94
+
95
+ logDir: "./logs", // optional; default: workDir/.multiclaw/logs
96
+ continueOnError: false, // optional; keep running if an agent fails
97
+ maxConcurrency: 4, // optional; max agents running at once
98
+
99
+ dashboard: {
100
+ port: 3210,
101
+ autoOpen: true,
102
+ },
103
+
104
+ agents: [
105
+ {
106
+ id: "architect", // unique identifier, used in dependsOn
107
+ name: "Architect", // display name
108
+ icon: "◆", // optional; shown in terminal and dashboard
109
+ runtime: "claude", // optional; default: "claude"
110
+ model: "opus", // optional; override default model for this agent
111
+ systemPrompt: "You are a software architect.", // optional
112
+ taskPrompt: `Design the system for {{requirement}}.
113
+ Read the brief at {{file:brief.md}} and write architecture.md.`,
114
+ tools: ["Read", "Write"],
115
+ dependsOn: [], // optional; list of agent ids this agent waits for
116
+ timeout: 600_000, // optional; ms, default: 600 000 (10 min)
117
+ retries: 0, // optional; retry count on failure, default: 0
118
+ workDir: "architect", // optional; subdirectory relative to global workDir
119
+ },
120
+ {
121
+ id: "developer",
122
+ name: "Developer",
123
+ model: "sonnet", // override model for this agent
124
+ taskPrompt: "Read architecture.md and implement the code.",
125
+ tools: ["Read", "Write", "Bash"],
126
+ dependsOn: ["architect"],
127
+ },
128
+ ],
129
+ })
130
+ ```
131
+
132
+ ### Top-level config fields
133
+
134
+ | Field | Type | Required | Description |
135
+ |-------|------|----------|-------------|
136
+ | `name` | string | ✓ | Project name, shown in the dashboard. |
137
+ | `workDir` | string | ✓ | Base directory where agents read and write files. |
138
+ | `agents` | AgentDefinition[] | ✓ | The agent pipeline (see Agent fields below). |
139
+ | `leader` | AgentDefinition | | Optional routing agent (see [Leader](#leader)). |
140
+ | `useLeader` | boolean | | Enable or disable the leader agent. Default: `true` when leader is configured. |
141
+ | `context` | Record<string, string> | | Variables available as `{{key}}` in every prompt. `requirement` is injected automatically. |
142
+ | `logDir` | string | | Log output directory. Default: `workDir/.multiclaw/logs`. |
143
+ | `continueOnError` | boolean | | Keep running when an agent fails. Default: `false`. |
144
+ | `maxConcurrency` | number | | Max agents running in parallel. Default: unlimited. |
145
+ | `dashboard.port` | number | | Dashboard port. Default: `3210`. |
146
+ | `dashboard.autoOpen` | boolean | | Open the dashboard in a browser automatically. Default: `true`. |
147
+
148
+ ### Agent fields
149
+
150
+ | Field | Type | Required | Description |
151
+ |-------|------|----------|-------------|
152
+ | `id` | string | ✓ | Unique identifier. Used in `dependsOn`. |
153
+ | `name` | string | ✓ | Display name shown in terminal and dashboard. |
154
+ | `taskPrompt` | string | ✓ | Prompt sent to the AI runtime. Supports template variables. |
155
+ | `systemPrompt` | string | | Optional system prompt prepended to `taskPrompt`. |
156
+ | `icon` | string | | Unicode icon shown next to the agent name. |
157
+ | `runtime` | string | | `claude` (default). Additional runtimes coming soon. |
158
+ | `model` | string | | Override the default model for this agent. E.g. `"opus"`, `"sonnet"`, `"haiku"`. Takes precedence over `models`. |
159
+ | `models` | Record<string, string> | | Map of runtime names to model names. Used when `model` is not set. E.g. `{ claude: "opus", openai: "gpt-4" }`. |
160
+ | `tools` | string[] | | Allowed tools. Default: `["Read", "Write", "Bash"]`. |
161
+ | `dependsOn` | string[] | | Agent ids that must complete before this agent starts. |
162
+ | `timeout` | number | | Per-agent timeout in ms. Default: `600000` (10 min). |
163
+ | `retries` | number | | Number of retry attempts on failure. Default: `0`. |
164
+ | `workDir` | string | | Subdirectory (relative to global `workDir`) for this agent's CWD. |
165
+
166
+ ### Template variables
167
+
168
+ Two syntaxes are supported in `taskPrompt` and `systemPrompt`:
169
+
170
+ | Syntax | Replaced with |
171
+ |--------|--------------|
172
+ | `{{key}}` | The value of `context.key` (or `requirement` from the CLI). |
173
+ | `{{file:path/to/file}}` | The contents of that file, resolved relative to `workDir`. |
174
+ | `{{pipelineAgents}}` | List of all agents running in this pipeline (id: name). Auto-injected; useful for the architect to decompose tasks per agent. |
175
+
176
+ ## Parallelism
177
+
178
+ Agents are grouped into stages by their dependency graph (topological sort). All agents within the same stage run concurrently. `maxConcurrency` caps how many run at once globally.
179
+
180
+ ```
181
+ Stage 1: product-manager
182
+ Stage 2: architect
183
+ Stage 3: backend-developer │ ui-designer ← parallel
184
+ Stage 4: code-reviewer │ devops ← parallel
185
+ ```
186
+
187
+ ## Dashboard
188
+
189
+ The real-time web UI shows:
190
+
191
+ - Stage timeline with agent status (running / done / failed / skipped)
192
+ - Live streaming logs per agent
193
+ - Per-agent duration and retry count
194
+ - Elapsed time while running; total time on completion
195
+
196
+ Start it with `--ui` on `run`, or run `multiclaw serve` for a persistent instance.
197
+
198
+ ## Logs
199
+
200
+ After each run, all generated files are written under `workDir/.multiclaw/runs/run-<timestamp>/` (or `logDir` if set):
201
+
202
+ ```
203
+ workDir/
204
+ └── .multiclaw/
205
+ └── runs/
206
+ └── run-2026-10-08T12-00-00/
207
+ ├── <agent output files> ← files agents write (e.g. architecture.md)
208
+ └── logs/
209
+ ├── <agentId>.log ← raw stdout per agent
210
+ └── report.json ← full orchestration result
211
+ ```
212
+
213
+ | File | Contents |
214
+ |------|----------|
215
+ | `<agentId>.log` | Raw stdout from that agent's process |
216
+ | `report.json` | Full orchestration result (status, duration, output per agent) |
217
+
218
+ The log path is printed to the terminal at the start of every run.
219
+
220
+ ## Presets
221
+
222
+ Presets are pipeline templates you can pick during `multiclaw init`:
223
+
224
+ | Preset | Pipeline | Agents |
225
+ |--------|----------|--------|
226
+ | `simple` | Architect → Arch Design Reviewer → Backend Developer → Code Reviewer | 4 |
227
+ | `backend` | Product Manager → Architect → Arch Design Reviewer → Backend Developer → Tester → Code Reviewer + DevOps | 7 |
228
+ | `fullstack` | Product Manager → Architect → Arch Design Reviewer → Backend Developer + UI Designer → UI Design Reviewer → Frontend Developer → Code Reviewer + DevOps | 9 |
229
+
230
+ ## Leader
231
+
232
+ The `leader` field adds a routing agent that runs **before** the main pipeline. It reads the requirement and inspects the codebase, then decides which agents are actually needed for this task. Agents the leader omits are skipped.
233
+
234
+ ```typescript
235
+ export default defineConfig({
236
+ leader: agents.leader(),
237
+ agents: [
238
+ agents.architect(),
239
+ agents.archDesignReviewer({ dependsOn: ["architect"] }),
240
+ agents.backendDeveloper({ dependsOn: ["arch-design-reviewer"] }),
241
+ agents.codeReviewer({ dependsOn: ["backend-developer"] }),
242
+ ],
243
+ })
244
+ ```
245
+
246
+ For a minor bug fix the leader might decide only `backend-developer` and `code-reviewer` are needed, skipping the design stages. For a greenfield feature it runs the full pipeline.
247
+
248
+ If the leader fails or produces invalid output, multiclaw falls back to running all agents.
249
+
250
+ ### Disabling the leader
251
+
252
+ You can skip the leader and use the default pipeline directly in three ways:
253
+
254
+ 1. **CLI option** (for a single run):
255
+ ```bash
256
+ multiclaw run "your requirement" --no-leader
257
+ ```
258
+
259
+ 2. **Config file** (per-run, via environment variable or config override):
260
+ ```typescript
261
+ export default defineConfig({
262
+ leader: agents.leader(),
263
+ useLeader: false, // disable leader
264
+ agents: [...],
265
+ })
266
+ ```
267
+
268
+ 3. **Remove the leader from config** (always use the default pipeline):
269
+ ```typescript
270
+ export default defineConfig({
271
+ // leader field omitted
272
+ agents: [...],
273
+ })
274
+ ```
275
+
276
+ ## Architect and Task Decomposition
277
+
278
+ When the **architect** agent is in your pipeline, it produces three outputs:
279
+
280
+ 1. **architecture.md** — architecture plan and module breakdown
281
+ 2. **api-spec.md** — complete API specification
282
+ 3. **task-plan.json** — structured task breakdown for all implementation agents in the pipeline
283
+
284
+ The `task-plan.json` file helps coordinate work across parallel agents by explicitly assigning scope to each agent. Each implementation agent (backend-developer, frontend-developer, ui-designer, devops, tester, etc.) reads this file to understand its specific responsibilities and dependencies.
285
+
286
+ **Example task-plan.json:**
287
+ ```json
288
+ {
289
+ "projectName": "My App",
290
+ "requirement": "Build a todo list API with React UI",
291
+ "tasks": [
292
+ {
293
+ "id": "backend-developer",
294
+ "title": "REST API",
295
+ "scope": "Implement all endpoints per api-spec.md",
296
+ "dependsOn": []
297
+ },
298
+ {
299
+ "id": "frontend-developer",
300
+ "title": "React UI",
301
+ "scope": "Build React components following ui-design.md",
302
+ "dependsOn": []
303
+ },
304
+ {
305
+ "id": "devops",
306
+ "title": "Deployment",
307
+ "scope": "Containerize and set up CI/CD",
308
+ "dependsOn": ["backend-developer", "frontend-developer"]
309
+ }
310
+ ]
311
+ }
312
+ ```
313
+
314
+ If the architect is not in your pipeline, dev agents fall back to reading `architecture.md` and `api-spec.md` directly.
315
+
316
+ ## Example
317
+
318
+ See [`examples/dev-team/`](https://github.com/shipengqi/multiclaw/tree/main/examples/dev-team) for a working three-agent pipeline (Architect → Developer → Reviewer).
319
+
320
+ ```bash
321
+ cd examples/dev-team
322
+ pnpm dev
323
+ ```
324
+
325
+ ## License
326
+
327
+ [MIT](https://github.com/shipengqi/multiclaw/blob/main/LICENSE)
package/dist/index.js ADDED
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env node
2
+ import { Command } from "commander";
3
+ import { runCommand } from "./commands/run";
4
+ import { initCommand } from "./commands/init";
5
+ import { serveCommand } from "./commands/serve";
6
+ import { upgradeCommand } from "./commands/upgrade";
7
+ const program = new Command();
8
+ program
9
+ .name("multiclaw")
10
+ .description("Multi-agent orchestration CLI")
11
+ .version("0.1.0");
12
+ program
13
+ .command("init")
14
+ .description("Scaffold a config file (interactive)")
15
+ .action(() => initCommand());
16
+ program
17
+ .command("run <requirement>")
18
+ .description("Run an orchestration")
19
+ .option("--config <path>", "Config file path (default: auto-discover ./multiclaw.config.ts)")
20
+ .option("--ui", "Start Dashboard and open in browser")
21
+ .option("--port <port>", "Dashboard port (requires --ui)", (v) => parseInt(v, 10))
22
+ .option("--server-url <url>", "Connect to a running serve process")
23
+ .option("--no-leader", "Skip the leader agent and use the default pipeline")
24
+ .action((requirement, opts) => runCommand(requirement, opts));
25
+ program
26
+ .command("serve")
27
+ .description("Start a persistent Dashboard server")
28
+ .option("--port <port>", "Port", (v) => parseInt(v, 10))
29
+ .action((opts) => serveCommand(opts));
30
+ program
31
+ .command("upgrade")
32
+ .description("Upgrade multiclaw to the latest version")
33
+ .action(() => upgradeCommand());
34
+ program.parseAsync(process.argv).catch((err) => {
35
+ console.error(`\x1b[31mError: ${err.message ?? err}\x1b[0m`);
36
+ process.exit(1);
37
+ });
38
+ //# sourceMappingURL=index.js.map
package/dist/lib.js ADDED
@@ -0,0 +1,2 @@
1
+ export { defineConfig, agents } from "@multiclawcli/core";
2
+ //# sourceMappingURL=lib.js.map
package/package.json CHANGED
@@ -1,6 +1,43 @@
1
1
  {
2
2
  "name": "multiclaw",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.2.0",
4
+ "type": "module",
5
+ "bin": {
6
+ "multiclaw": "dist/index.js"
7
+ },
8
+ "main": "dist/lib.js",
9
+ "types": "dist/lib.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/lib.d.ts",
13
+ "default": "./dist/lib.js"
14
+ }
15
+ },
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "https://github.com/shipengqi/multiclaw.git",
19
+ "directory": "packages/cli"
20
+ },
21
+ "homepage": "https://github.com/shipengqi/multiclaw#readme",
22
+ "bugs": {
23
+ "url": "https://github.com/shipengqi/multiclaw/issues"
24
+ },
25
+ "dependencies": {
26
+ "@inquirer/prompts": "^8.7.3",
27
+ "@multiclawcli/core": "0.2.0",
28
+ "@multiclawcli/dashboard": "0.2.0",
29
+ "commander": "^12.0.0",
30
+ "open": "^10.0.0",
31
+ "tsx": "^4.7.0",
32
+ "ws": "^8.16.0"
33
+ },
34
+ "devDependencies": {
35
+ "@types/node": "^20.11.0",
36
+ "@types/ws": "^8.5.0",
37
+ "typescript": "^5.4.0"
38
+ },
39
+ "scripts": {
40
+ "build": "tsc",
41
+ "dev": "tsx src/index.ts"
42
+ }
6
43
  }
@@ -0,0 +1,128 @@
1
+ import * as fs from "fs"
2
+ import * as path from "path"
3
+ import { execSync } from "child_process"
4
+ import { select, input } from "@inquirer/prompts"
5
+
6
+ // ─── Agent Block Definitions ──────────────────────────────────────────────────
7
+
8
+ const AGENT_BLOCKS: Record<string, string> = {
9
+ simple: ` agents.architect(),
10
+ agents.archDesignReviewer({ dependsOn: ["architect"] }),
11
+ agents.backendDeveloper({ dependsOn: ["arch-design-reviewer"] }),
12
+ agents.codeReviewer({ dependsOn: ["backend-developer"] }),`,
13
+
14
+ backend: ` agents.productManager(),
15
+ agents.architect({ dependsOn: ["product-manager"] }),
16
+ agents.archDesignReviewer({ dependsOn: ["architect"] }),
17
+ agents.backendDeveloper({ dependsOn: ["arch-design-reviewer"] }),
18
+ agents.tester({ dependsOn: ["backend-developer"] }),
19
+ agents.codeReviewer({ dependsOn: ["tester"] }),
20
+ agents.devops({ dependsOn: ["tester"] }),`,
21
+
22
+ fullstack: ` agents.productManager(),
23
+ agents.architect({ dependsOn: ["product-manager"] }),
24
+ agents.archDesignReviewer({ dependsOn: ["architect"] }),
25
+ agents.backendDeveloper({ dependsOn: ["arch-design-reviewer"] }),
26
+ agents.uiDesigner({ dependsOn: ["arch-design-reviewer"] }),
27
+ agents.uiDesignReviewer({ dependsOn: ["ui-designer"] }),
28
+ agents.frontendDeveloper({ dependsOn: ["ui-design-reviewer"] }),
29
+ agents.codeReviewer({ dependsOn: ["backend-developer", "frontend-developer"] }),
30
+ agents.devops({ dependsOn: ["backend-developer", "frontend-developer"] }),`,
31
+ }
32
+
33
+ const PRESET_DESCRIPTIONS: Record<string, string> = {
34
+ simple: "Architect → Arch Design Reviewer → Backend Developer → Code Reviewer (4 agents)",
35
+ backend: "Product Manager → Architect → Arch Design Reviewer → Backend Developer → Tester → Code Reviewer + DevOps (7 agents)",
36
+ fullstack: "Product Manager → Architect → Arch Design Reviewer → Backend Developer + UI Designer → UI Design Reviewer → Frontend Developer → Code Reviewer + DevOps (9 agents)",
37
+ }
38
+
39
+ const RUNTIME_INSTALL: Record<string, string> = {
40
+ claude: "npm install -g @anthropic-ai/claude-code",
41
+ codex: "npm install -g @openai/codex",
42
+ opencode: "npm install -g opencode",
43
+ cursor: "curl https://cursor.com/install | bash",
44
+ }
45
+
46
+ // ─── Config Generator ─────────────────────────────────────────────────────────
47
+
48
+ function generateConfig(opts: { preset: string; workDir: string; projectName: string }): string {
49
+ return `import { defineConfig, agents } from "multiclaw"
50
+
51
+ export default defineConfig({
52
+ name: "${opts.projectName}",
53
+ workDir: "${opts.workDir}",
54
+ context: {
55
+ projectName: "${opts.projectName}",
56
+ },
57
+ dashboard: { port: 3210, autoOpen: true },
58
+ agents: [
59
+ ${AGENT_BLOCKS[opts.preset]}
60
+ ],
61
+ })
62
+ `
63
+ }
64
+
65
+ // ─── Command ──────────────────────────────────────────────────────────────────
66
+
67
+ export async function initCommand(): Promise<void> {
68
+ const configPath = path.resolve(process.cwd(), "multiclaw.config.ts")
69
+ if (fs.existsSync(configPath)) {
70
+ console.error("\x1b[31mError: multiclaw.config.ts already exists\x1b[0m")
71
+ process.exit(1)
72
+ }
73
+
74
+ const defaultProjectName = path.basename(process.cwd())
75
+
76
+ const projectName = await input({
77
+ message: "Project name:",
78
+ default: defaultProjectName,
79
+ })
80
+
81
+ const preset = await select({
82
+ message: "Select a preset:",
83
+ choices: [
84
+ { value: "simple", name: `simple — ${PRESET_DESCRIPTIONS.simple}` },
85
+ { value: "backend", name: `backend — ${PRESET_DESCRIPTIONS.backend}` },
86
+ { value: "fullstack", name: `fullstack — ${PRESET_DESCRIPTIONS.fullstack}` },
87
+ ],
88
+ })
89
+
90
+ const workDir = await input({
91
+ message: "Work directory (where agents read and write files):",
92
+ default: ".",
93
+ })
94
+
95
+ try {
96
+ fs.writeFileSync(configPath, generateConfig({ preset, workDir, projectName }))
97
+ if (workDir !== ".") {
98
+ fs.mkdirSync(path.resolve(process.cwd(), workDir), { recursive: true })
99
+ }
100
+ } catch (err) {
101
+ console.error(`\x1b[31mError: Failed to create files: ${(err as Error).message}\x1b[0m`)
102
+ process.exit(1)
103
+ }
104
+
105
+ console.log("")
106
+ console.log(`\x1b[32m✓\x1b[0m Created multiclaw.config.ts`)
107
+ console.log(` preset: ${preset} (${PRESET_DESCRIPTIONS[preset]})`)
108
+ console.log(` workDir: ${workDir}`)
109
+ console.log("")
110
+ console.log(`> Run: multiclaw run "describe your requirement" --ui`)
111
+
112
+ checkRuntime()
113
+ }
114
+
115
+ function checkRuntime(): void {
116
+ const runtimes = ["claude", "codex", "opencode"]
117
+ const available = runtimes.filter((r) => {
118
+ try { execSync(`${r} --version`, { stdio: "ignore" }); return true }
119
+ catch { return false }
120
+ })
121
+ if (available.length === 0) {
122
+ console.log("")
123
+ console.log("\x1b[33mWarning: No AI runtime detected. Install at least one:\x1b[0m")
124
+ for (const [name, cmd] of Object.entries(RUNTIME_INSTALL)) {
125
+ console.log(` \x1b[2m${name.padEnd(12)} ${cmd}\x1b[0m`)
126
+ }
127
+ }
128
+ }
@@ -0,0 +1,97 @@
1
+ import * as path from "path"
2
+ import type { Orchestrator } from "@multiclawcli/core"
3
+ import { Orchestrator as OrchestratorImpl, runtimeRegistry } from "@multiclawcli/core"
4
+ import { loadConfig } from "../loader/loadConfig"
5
+ import { ConsoleReporter } from "../reporters/ConsoleReporter"
6
+ import { FileLogWriter } from "../reporters/FileLogWriter"
7
+
8
+ export interface RunOptions {
9
+ config?: string
10
+ ui?: boolean
11
+ serverUrl?: string
12
+ port?: number
13
+ noLeader?: boolean
14
+ }
15
+
16
+ export async function runCommand(requirement: string, options: RunOptions): Promise<void> {
17
+ const config = await loadConfig(options.config, requirement)
18
+
19
+ if (options.noLeader) {
20
+ config.useLeader = false
21
+ }
22
+
23
+ const ts = new Date().toISOString().replace(/[:.]/g, "-").slice(0, 19)
24
+ config.workDir = path.join(config.workDir, ".multiclaw", "runs", `run-${ts}`)
25
+
26
+ const runtimeNames = new Set(config.agents.map((a) => a.runtime ?? "claude"))
27
+ for (const name of runtimeNames) {
28
+ let rt
29
+ try { rt = runtimeRegistry.get(name) } catch {
30
+ console.error(`\x1b[31mError: Unknown runtime "${name}". Supported: claude\x1b[0m`)
31
+ process.exit(1)
32
+ }
33
+ if (!(await rt.checkAvailable())) {
34
+ console.error(`\x1b[31mError: Runtime "${name}" is not available. Make sure the CLI is installed.\x1b[0m`)
35
+ process.exit(1)
36
+ }
37
+ }
38
+
39
+ const orchestrator = new OrchestratorImpl(config)
40
+
41
+ new ConsoleReporter().attach(orchestrator.eventBus)
42
+
43
+ const logDir = config.logDir ?? path.join(config.workDir, "logs")
44
+ new FileLogWriter(logDir).attach(orchestrator.eventBus)
45
+ console.log(`\x1b[2mLogs: ${logDir}\x1b[0m`)
46
+
47
+ if (options.ui && options.serverUrl) {
48
+ console.warn("\x1b[33mWarning: --ui and --server-url cannot be used together. Using --ui.\x1b[0m")
49
+ }
50
+
51
+ if (options.ui) {
52
+ await attachDashboard(orchestrator, config, options)
53
+ } else if (options.serverUrl) {
54
+ await attachRemoteServer(orchestrator, options.serverUrl)
55
+ }
56
+
57
+ const result = await orchestrator.run()
58
+ process.exit(result.success ? 0 : 1)
59
+ }
60
+
61
+ async function attachDashboard(
62
+ orchestrator: Orchestrator,
63
+ config: Awaited<ReturnType<typeof loadConfig>>,
64
+ options: RunOptions
65
+ ): Promise<void> {
66
+ const { DashboardServer } = await import("@multiclawcli/dashboard/server")
67
+ const port = options.port ?? config.dashboard?.port ?? 3210
68
+ const server = new DashboardServer({ port })
69
+ await server.start()
70
+ server.bindEventBus(orchestrator.eventBus)
71
+
72
+ const url = `http://localhost:${port}`
73
+ console.log(`\x1b[36mDashboard: ${url}\x1b[0m`)
74
+
75
+ if (config.dashboard?.autoOpen ?? true) {
76
+ const { default: open } = await import("open")
77
+ await open(url)
78
+ }
79
+ }
80
+
81
+ async function attachRemoteServer(
82
+ orchestrator: Orchestrator,
83
+ serverUrl: string
84
+ ): Promise<void> {
85
+ const { WebSocket } = await import("ws")
86
+ const wsUrl = serverUrl.replace(/^https?/, (p) => p === "https" ? "wss" : "ws")
87
+ const ws = new WebSocket(wsUrl)
88
+ await new Promise<void>((resolve, reject) => {
89
+ const timer = setTimeout(() => reject(new Error(`Connection to serve timed out: ${serverUrl}`)), 5000)
90
+ ws.on("open", () => { clearTimeout(timer); resolve() })
91
+ ws.on("error", (err) => { clearTimeout(timer); reject(err) })
92
+ })
93
+ console.log(`\x1b[36mConnected to Dashboard server: ${serverUrl}\x1b[0m`)
94
+ orchestrator.eventBus.subscribe((e) => {
95
+ if (ws.readyState === ws.OPEN) ws.send(JSON.stringify(e))
96
+ })
97
+ }
@@ -0,0 +1,12 @@
1
+ export interface ServeOptions {
2
+ port?: number
3
+ }
4
+
5
+ export async function serveCommand(options: ServeOptions): Promise<void> {
6
+ const { DashboardServer } = await import("@multiclawcli/dashboard/server")
7
+ const port = options.port ?? 3210
8
+ const server = new DashboardServer({ port, acceptClientEvents: true })
9
+ await server.start()
10
+ console.log(`\x1b[36mDashboard running at: http://localhost:${port}\x1b[0m`)
11
+ console.log(` In another terminal run: multiclaw run "<requirement>" --server-url http://localhost:${port}`)
12
+ }
@@ -0,0 +1,35 @@
1
+ import { execSync } from "child_process"
2
+ import { createRequire } from "module"
3
+
4
+ const require = createRequire(import.meta.url)
5
+
6
+ export async function upgradeCommand(): Promise<void> {
7
+ const { version: currentVersion } = require("../../package.json") as { version: string }
8
+
9
+ console.log(`Current version: v${currentVersion}`)
10
+ console.log("Checking for updates...")
11
+
12
+ let latestVersion: string
13
+ try {
14
+ latestVersion = execSync("npm show multiclaw version", { encoding: "utf8" }).trim()
15
+ } catch {
16
+ console.error("\x1b[31mError: Failed to fetch latest version from npm registry\x1b[0m")
17
+ process.exit(1)
18
+ return
19
+ }
20
+
21
+ if (latestVersion === currentVersion) {
22
+ console.log(`\x1b[32m✓\x1b[0m Already on the latest version (v${currentVersion})`)
23
+ return
24
+ }
25
+
26
+ console.log(`Upgrading multiclaw v${currentVersion} → v${latestVersion}...`)
27
+
28
+ try {
29
+ execSync("npm install -g multiclaw@latest", { stdio: "inherit" })
30
+ console.log(`\x1b[32m✓\x1b[0m Successfully upgraded to v${latestVersion}`)
31
+ } catch {
32
+ console.error("\x1b[31mError: Upgrade failed. Try running manually: npm install -g multiclaw@latest\x1b[0m")
33
+ process.exit(1)
34
+ }
35
+ }
package/src/index.ts ADDED
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env node
2
+ import { Command } from "commander"
3
+ import { runCommand } from "./commands/run"
4
+ import { initCommand } from "./commands/init"
5
+ import { serveCommand } from "./commands/serve"
6
+ import { upgradeCommand } from "./commands/upgrade"
7
+
8
+ const program = new Command()
9
+
10
+ program
11
+ .name("multiclaw")
12
+ .description("Multi-agent orchestration CLI")
13
+ .version("0.1.0")
14
+
15
+ program
16
+ .command("init")
17
+ .description("Scaffold a config file (interactive)")
18
+ .action(() => initCommand())
19
+
20
+ program
21
+ .command("run <requirement>")
22
+ .description("Run an orchestration")
23
+ .option("--config <path>", "Config file path (default: auto-discover ./multiclaw.config.ts)")
24
+ .option("--ui", "Start Dashboard and open in browser")
25
+ .option("--port <port>", "Dashboard port (requires --ui)", (v) => parseInt(v, 10))
26
+ .option("--server-url <url>", "Connect to a running serve process")
27
+ .option("--no-leader", "Skip the leader agent and use the default pipeline")
28
+ .action((requirement, opts) => runCommand(requirement, opts))
29
+
30
+ program
31
+ .command("serve")
32
+ .description("Start a persistent Dashboard server")
33
+ .option("--port <port>", "Port", (v) => parseInt(v, 10))
34
+ .action((opts) => serveCommand(opts))
35
+
36
+ program
37
+ .command("upgrade")
38
+ .description("Upgrade multiclaw to the latest version")
39
+ .action(() => upgradeCommand())
40
+
41
+ program.parseAsync(process.argv).catch((err: unknown) => {
42
+ console.error(`\x1b[31mError: ${(err as Error).message ?? err}\x1b[0m`)
43
+ process.exit(1)
44
+ })
package/src/lib.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { defineConfig, agents } from "@multiclawcli/core"
2
+ export type { MultiClawConfig, AgentDefinition } from "@multiclawcli/core"
@@ -0,0 +1,47 @@
1
+ import * as path from "path"
2
+ import * as fs from "fs"
3
+ import type { MultiClawConfig } from "@multiclawcli/core"
4
+
5
+ const DEFAULT_CONFIG_NAMES = ["multiclaw.config.ts", "multiclaw.config.js"]
6
+
7
+ function findConfig(configPath?: string): string {
8
+ if (configPath) {
9
+ const abs = path.resolve(process.cwd(), configPath)
10
+ if (!fs.existsSync(abs)) throw new Error(`Config file not found: ${abs}`)
11
+ return abs
12
+ }
13
+ for (const name of DEFAULT_CONFIG_NAMES) {
14
+ const abs = path.resolve(process.cwd(), name)
15
+ if (fs.existsSync(abs)) return abs
16
+ }
17
+ throw new Error(`No config file found. Create multiclaw.config.ts in the current directory or use --config to specify a path.`)
18
+ }
19
+
20
+ export async function loadConfig(configPath?: string, requirement?: string): Promise<MultiClawConfig> {
21
+ const absPath = findConfig(configPath)
22
+
23
+ // The compiled CLI cannot natively import .ts files — register tsx ESM hook
24
+ // so dynamic import can handle TypeScript config files.
25
+ const { register } = await import("tsx/esm/api")
26
+ const unregister = register()
27
+ let mod: Record<string, unknown>
28
+ try {
29
+ mod = await import(absPath)
30
+ } finally {
31
+ unregister()
32
+ }
33
+ const config: MultiClawConfig = (mod.default ?? mod.config) as MultiClawConfig
34
+
35
+ if (!config || !Array.isArray(config.agents)) {
36
+ throw new Error(`Invalid config format — expected: export default defineConfig({...})`)
37
+ }
38
+
39
+ const configDir = path.dirname(absPath)
40
+ config.workDir = path.resolve(configDir, config.workDir)
41
+
42
+ if (requirement !== undefined) {
43
+ config.context = { ...config.context, requirement }
44
+ }
45
+
46
+ return config
47
+ }
@@ -0,0 +1,93 @@
1
+ import type { EventBus, MultiClawEvent } from "@multiclawcli/core"
2
+
3
+ // Degraded to plain ASCII when NO_COLOR is set, TERM=dumb, or stdout is not a TTY (pipe/CI).
4
+ const isFancy =
5
+ !process.env.NO_COLOR &&
6
+ process.env.TERM !== "dumb" &&
7
+ process.stdout.isTTY === true
8
+
9
+ const S = isFancy
10
+ ? { ok: "✓", fail: "✗", run: "›", retry: "↻", skip: "⊘", warn: "⚠", bullet: "·" }
11
+ : { ok: "+", fail: "x", run: ">", retry: "~", skip: "-", warn: "!", bullet: "*" }
12
+
13
+ const C = isFancy
14
+ ? {
15
+ reset: "\x1b[0m", bold: "\x1b[1m", dim: "\x1b[2m",
16
+ cyan: "\x1b[36m", green: "\x1b[32m",
17
+ yellow: "\x1b[33m", red: "\x1b[31m", purple: "\x1b[35m",
18
+ }
19
+ : {
20
+ reset: "", bold: "", dim: "",
21
+ cyan: "", green: "",
22
+ yellow: "", red: "", purple: "",
23
+ }
24
+
25
+ export class ConsoleReporter {
26
+ attach(eventBus: EventBus): () => void {
27
+ return eventBus.subscribe((e) => this.handle(e))
28
+ }
29
+
30
+ private handle(e: MultiClawEvent): void {
31
+ switch (e.type) {
32
+ case "orchestration:start": {
33
+ const line = (isFancy ? "═" : "=").repeat(50)
34
+ const edge = isFancy ? ["╔", "║", "╚", "╗", "╝"] : ["+", "|", "+", "+", "+"]
35
+ console.log(`\n${C.bold}${C.purple}${edge[0]}${line}${edge[3]}`)
36
+ console.log(`${edge[1]} ${S.run} ${e.payload.name.padEnd(46)}${edge[1]}`)
37
+ console.log(`${edge[2]}${line}${edge[4]}${C.reset}`)
38
+ console.log(`${C.cyan}${S.bullet} Agents: ${e.payload.totalAgents} Stages: ${e.payload.stages.length}${C.reset}\n`)
39
+ break
40
+ }
41
+ case "stage:start": {
42
+ const dash = (isFancy ? "─" : "-").repeat(16)
43
+ console.log(`${C.cyan}${dash} Stage ${e.payload.stageIndex + 1} ${dash}${C.reset}`)
44
+ break
45
+ }
46
+ case "agent:start": {
47
+ console.log(`${C.purple}${S.run} [${e.payload.agentName}] starting...${C.reset}`)
48
+ break
49
+ }
50
+ case "agent:output": {
51
+ process.stdout.write(` ${e.payload.chunk}`)
52
+ break
53
+ }
54
+ case "agent:complete": {
55
+ const d = (e.payload.duration / 1000).toFixed(1)
56
+ console.log(`${C.green}${S.ok} ${e.payload.agentName} done (${d}s)${C.reset}`)
57
+ break
58
+ }
59
+ case "agent:failed": {
60
+ console.log(`${C.red}${S.fail} ${e.payload.agentName} failed: ${e.payload.error}${C.reset}`)
61
+ break
62
+ }
63
+ case "agent:skipped": {
64
+ console.log(`${C.yellow}${S.skip} ${e.payload.agentName} skipped${C.reset}`)
65
+ break
66
+ }
67
+ case "agent:retrying": {
68
+ console.log(`${C.yellow}${S.retry} ${e.payload.agentName} retry ${e.payload.attempt}/${e.payload.maxAttempts}: ${e.payload.error}${C.reset}`)
69
+ break
70
+ }
71
+ case "orchestration:complete": {
72
+ const { success, totalDuration, agentResults } = e.payload
73
+ const line = (isFancy ? "═" : "=").repeat(50)
74
+ const edge = isFancy ? ["╔", "║", "╚", "╗", "╝"] : ["+", "|", "+", "+", "+"]
75
+ const title = success ? `${S.ok} All done` : `${S.warn} Done (with failures)`
76
+ console.log(`\n${C.bold}${C.purple}${edge[0]}${line}${edge[3]}`)
77
+ console.log(`${edge[1]} ${title.padEnd(48)}${edge[1]}`)
78
+ console.log(`${edge[2]}${line}${edge[4]}${C.reset}`)
79
+ const nameWidth = Math.max(8, ...agentResults.map((r) => r.agentName.length))
80
+ const totalStr = `${(totalDuration / 1000).toFixed(1)}s`
81
+ console.log(` ~ ${"Total".padEnd(nameWidth)} ${totalStr.padStart(7)}`)
82
+ for (const r of agentResults) {
83
+ const icon = r.status === "success" ? S.ok : S.fail
84
+ const color = r.status === "success" ? C.green : C.red
85
+ const dur = `${(r.duration / 1000).toFixed(1)}s`
86
+ console.log(` ${color}${icon}${C.reset} ${r.agentName.padEnd(nameWidth)} ${dur.padStart(7)}`)
87
+ }
88
+ console.log()
89
+ break
90
+ }
91
+ }
92
+ }
93
+ }
@@ -0,0 +1,43 @@
1
+ import * as fs from "fs"
2
+ import * as path from "path"
3
+ import type { EventBus, MultiClawEvent } from "@multiclawcli/core"
4
+
5
+ export class FileLogWriter {
6
+ private streams = new Map<string, fs.WriteStream>()
7
+
8
+ constructor(private logDir: string) {
9
+ fs.mkdirSync(logDir, { recursive: true })
10
+ }
11
+
12
+ attach(eventBus: EventBus): () => void {
13
+ return eventBus.subscribe((e) => this.handle(e))
14
+ }
15
+
16
+ private handle(e: MultiClawEvent): void {
17
+ if (e.type === "agent:output") {
18
+ this.getStream(e.payload.agentId).write(e.payload.chunk)
19
+ }
20
+ if (e.type === "orchestration:complete") {
21
+ fs.writeFileSync(
22
+ path.join(this.logDir, "report.json"),
23
+ JSON.stringify(e.payload, null, 2)
24
+ )
25
+ this.closeAll()
26
+ }
27
+ }
28
+
29
+ private getStream(agentId: string): fs.WriteStream {
30
+ if (!this.streams.has(agentId)) {
31
+ this.streams.set(
32
+ agentId,
33
+ fs.createWriteStream(path.join(this.logDir, `${agentId}.log`))
34
+ )
35
+ }
36
+ return this.streams.get(agentId)!
37
+ }
38
+
39
+ private closeAll(): void {
40
+ for (const s of this.streams.values()) s.end()
41
+ this.streams.clear()
42
+ }
43
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": { "outDir": "dist", "rootDir": "src" },
4
+ "references": [
5
+ { "path": "../core" },
6
+ { "path": "../dashboard/tsconfig.server.json" }
7
+ ],
8
+ "include": ["src"]
9
+ }