multiclaw 0.3.1 → 0.3.2
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/dist/index.js +1 -1
- package/dist/lib.d.ts +1 -0
- package/package.json +7 -3
- package/src/commands/init.ts +0 -128
- package/src/commands/run.ts +0 -97
- package/src/commands/serve.ts +0 -12
- package/src/commands/upgrade.ts +0 -35
- package/src/index.ts +0 -51
- package/src/lib.ts +0 -2
- package/src/loader/loadConfig.ts +0 -47
- package/src/reporters/ConsoleReporter.ts +0 -93
- package/src/reporters/FileLogWriter.ts +0 -43
- package/tsconfig.json +0 -9
- package/tsup.config.ts +0 -18
package/dist/index.js
CHANGED
|
@@ -381,7 +381,7 @@ import { execSync as execSync2 } from "child_process";
|
|
|
381
381
|
import { createRequire } from "module";
|
|
382
382
|
var require2 = createRequire(import.meta.url);
|
|
383
383
|
async function upgradeCommand() {
|
|
384
|
-
const { version: currentVersion } = require2("
|
|
384
|
+
const { version: currentVersion } = require2("../package.json");
|
|
385
385
|
console.log(`Current version: v${currentVersion}`);
|
|
386
386
|
console.log("Checking for updates...");
|
|
387
387
|
let latestVersion;
|
package/dist/lib.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AgentDefinition, MultiClawConfig, agents, defineConfig } from '@multiclawcli/core';
|
package/package.json
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "multiclaw",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"multiclaw": "dist/index.js"
|
|
7
7
|
},
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"package.json"
|
|
11
|
+
],
|
|
8
12
|
"main": "dist/lib.js",
|
|
9
13
|
"types": "dist/lib.d.ts",
|
|
10
14
|
"exports": {
|
|
@@ -24,8 +28,8 @@
|
|
|
24
28
|
},
|
|
25
29
|
"dependencies": {
|
|
26
30
|
"@inquirer/prompts": "^8.7.3",
|
|
27
|
-
"@multiclawcli/core": "0.3.
|
|
28
|
-
"@multiclawcli/dashboard": "0.3.
|
|
31
|
+
"@multiclawcli/core": "0.3.2",
|
|
32
|
+
"@multiclawcli/dashboard": "0.3.2",
|
|
29
33
|
"commander": "^12.0.0",
|
|
30
34
|
"open": "^10.0.0",
|
|
31
35
|
"tsx": "^4.7.0",
|
package/src/commands/init.ts
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
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
|
-
}
|
package/src/commands/run.ts
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
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
|
-
}
|
package/src/commands/serve.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
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
|
-
}
|
package/src/commands/upgrade.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { Command } from "commander"
|
|
3
|
-
import { readFileSync } from "fs"
|
|
4
|
-
import { dirname, join } from "path"
|
|
5
|
-
import { fileURLToPath } from "url"
|
|
6
|
-
import { runCommand } from "./commands/run"
|
|
7
|
-
import { initCommand } from "./commands/init"
|
|
8
|
-
import { serveCommand } from "./commands/serve"
|
|
9
|
-
import { upgradeCommand } from "./commands/upgrade"
|
|
10
|
-
|
|
11
|
-
const __filename = fileURLToPath(import.meta.url)
|
|
12
|
-
const __dirname = dirname(__filename)
|
|
13
|
-
const pkg = JSON.parse(readFileSync(join(__dirname, "../package.json"), "utf-8"))
|
|
14
|
-
|
|
15
|
-
const program = new Command()
|
|
16
|
-
|
|
17
|
-
program
|
|
18
|
-
.name("multiclaw")
|
|
19
|
-
.description("Multi-agent orchestration CLI")
|
|
20
|
-
.version(pkg.version, "-v, --version", "Display version number")
|
|
21
|
-
|
|
22
|
-
program
|
|
23
|
-
.command("init")
|
|
24
|
-
.description("Scaffold a config file (interactive)")
|
|
25
|
-
.action(() => initCommand())
|
|
26
|
-
|
|
27
|
-
program
|
|
28
|
-
.command("run <requirement>")
|
|
29
|
-
.description("Run an orchestration")
|
|
30
|
-
.option("--config <path>", "Config file path (default: auto-discover ./multiclaw.config.ts)")
|
|
31
|
-
.option("--ui", "Start Dashboard and open in browser")
|
|
32
|
-
.option("--port <port>", "Dashboard port (requires --ui)", (v) => parseInt(v, 10))
|
|
33
|
-
.option("--server-url <url>", "Connect to a running serve process")
|
|
34
|
-
.option("--no-leader", "Skip the leader agent and use the default pipeline")
|
|
35
|
-
.action((requirement, opts) => runCommand(requirement, opts))
|
|
36
|
-
|
|
37
|
-
program
|
|
38
|
-
.command("serve")
|
|
39
|
-
.description("Start a persistent Dashboard server")
|
|
40
|
-
.option("--port <port>", "Port", (v) => parseInt(v, 10))
|
|
41
|
-
.action((opts) => serveCommand(opts))
|
|
42
|
-
|
|
43
|
-
program
|
|
44
|
-
.command("upgrade")
|
|
45
|
-
.description("Upgrade multiclaw to the latest version")
|
|
46
|
-
.action(() => upgradeCommand())
|
|
47
|
-
|
|
48
|
-
program.parseAsync(process.argv).catch((err: unknown) => {
|
|
49
|
-
console.error(`\x1b[31mError: ${(err as Error).message ?? err}\x1b[0m`)
|
|
50
|
-
process.exit(1)
|
|
51
|
-
})
|
package/src/lib.ts
DELETED
package/src/loader/loadConfig.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,93 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
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
DELETED
package/tsup.config.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from "tsup"
|
|
2
|
-
|
|
3
|
-
export default defineConfig([
|
|
4
|
-
{
|
|
5
|
-
entry: { index: "src/index.ts" },
|
|
6
|
-
format: ["esm"],
|
|
7
|
-
outDir: "dist",
|
|
8
|
-
clean: true,
|
|
9
|
-
shims: true,
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
entry: { lib: "src/lib.ts" },
|
|
13
|
-
format: ["esm"],
|
|
14
|
-
outDir: "dist",
|
|
15
|
-
dts: true,
|
|
16
|
-
shims: true,
|
|
17
|
-
},
|
|
18
|
-
])
|