diff --git a/src/cli.ts b/src/cli.ts index 28cd138..d9fb2ac 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -1,6 +1,6 @@ #!/usr/bin/env bun import { Command } from "commander"; -import { launchMultiModel } from "./core/open"; +import { openMultiModel } from "./core/open"; import { closeMultiModel } from "./core/close"; import { getBinaryName } from "./core/utils"; @@ -21,7 +21,7 @@ program try { const binaryName = options.binary || getBinaryName(); - const result = await launchMultiModel({ + const result = await openMultiModel({ sessionName, models: options.models, binaryName, diff --git a/src/core/index.ts b/src/core/index.ts index 510547c..db81d7b 100644 --- a/src/core/index.ts +++ b/src/core/index.ts @@ -1,3 +1,3 @@ -export { launchMultiModel } from "./open"; +export { openMultiModel } from "./open"; export { closeMultiModel } from "./close"; export * from "./utils"; diff --git a/src/core/open.ts b/src/core/open.ts index 0994746..f55f734 100644 --- a/src/core/open.ts +++ b/src/core/open.ts @@ -24,7 +24,7 @@ import { * * @example * ```ts - * const result = await launchMultiModel({ + * const result = await openMultiModel({ * sessionName: "compare", * models: ["openai/gpt-5.2", "anthropic/claude-3-5-sonnet"], * binaryName: "opencode", @@ -34,7 +34,7 @@ import { * } * ``` */ -export async function launchMultiModel(options: MultiModelOptions): Promise { +export async function openMultiModel(options: MultiModelOptions): Promise { const sessionName = options.sessionName.trim(); const safeSessionName = sanitizeName(sessionName); const models = normalizeModels(options.models); diff --git a/src/tools/open.ts b/src/tools/open.ts index 31ffdb3..dd3a88f 100644 --- a/src/tools/open.ts +++ b/src/tools/open.ts @@ -1,5 +1,5 @@ import { tool } from "@opencode-ai/plugin"; -import { launchMultiModel } from "../core/open"; +import { openMultiModel } from "../core/open"; import { getBinaryName } from "../core/utils"; /** @@ -20,7 +20,7 @@ export const openTool = tool({ async execute(args, context) { const binaryName = getBinaryName(); - const result = await launchMultiModel({ + const result = await openMultiModel({ sessionName: args.sessionName, models: args.models, binaryName, diff --git a/tests/multi-model.test.ts b/tests/multi-model.test.ts index 4f82c2e..1f5e9b8 100644 --- a/tests/multi-model.test.ts +++ b/tests/multi-model.test.ts @@ -1,7 +1,7 @@ import { expect, test, mock, spyOn, beforeEach, afterEach, describe } from "bun:test"; import * as fs from "node:fs"; import * as os from "node:os"; -import { launchMultiModel } from "../src/core/open"; +import { openMultiModel } from "../src/core/open"; import { shellQuote, normalizeModels, @@ -79,7 +79,7 @@ describe("multi-model launch", () => { }); test("fails if session name is empty", async () => { - const result = await launchMultiModel({ + const result = await openMultiModel({ sessionName: "", models: ["openai/gpt-5.2"], }); @@ -90,7 +90,7 @@ describe("multi-model launch", () => { }); test("fails if no models are provided", async () => { - const result = await launchMultiModel({ + const result = await openMultiModel({ sessionName: "test-session", models: [], }); @@ -101,7 +101,7 @@ describe("multi-model launch", () => { }); test("fails if duplicate models are provided", async () => { - const result = await launchMultiModel({ + const result = await openMultiModel({ sessionName: "test-session", models: ["openai/gpt-5.2", "openai/gpt-5.2"], }); @@ -114,7 +114,7 @@ describe("multi-model launch", () => { test("fails if not inside a git repository", async () => { mockCommandResponses["git rev-parse --is-inside-work-tree"] = { ok: false, stdout: "", stderr: "not a git repo" }; - const result = await launchMultiModel({ + const result = await openMultiModel({ sessionName: "test-session", models: ["openai/gpt-5.2"], }); @@ -127,7 +127,7 @@ describe("multi-model launch", () => { test("fails if tmux is not installed", async () => { mockCommandResponses["command -v tmux"] = { ok: false, stdout: "", stderr: "" }; - const result = await launchMultiModel({ + const result = await openMultiModel({ sessionName: "test-session", models: ["openai/gpt-5.2"], }); @@ -143,7 +143,7 @@ describe("multi-model launch", () => { test("fails if opencode is not installed", async () => { mockCommandResponses["command -v opencode"] = { ok: false, stdout: "", stderr: "" }; - const result = await launchMultiModel({ + const result = await openMultiModel({ sessionName: "test-session", models: ["openai/gpt-5.2"], }); @@ -158,7 +158,7 @@ describe("multi-model launch", () => { }); test("fails if model name is not in allowlist", async () => { - const result = await launchMultiModel({ + const result = await openMultiModel({ sessionName: "test-session", models: ["invalid/model"], }); @@ -176,7 +176,7 @@ describe("multi-model launch", () => { test("fails if session already exists", async () => { mockCommandResponses["tmux has-session -t test-session"] = { ok: true, stdout: "", stderr: "" }; - const result = await launchMultiModel({ + const result = await openMultiModel({ sessionName: "test-session", models: ["openai/gpt-5.2"], }); @@ -193,7 +193,7 @@ describe("multi-model launch", () => { }); test("successfully plans and executes tmux launch with single model", async () => { - const result = await launchMultiModel({ + const result = await openMultiModel({ sessionName: "test-session", models: ["openai/gpt-5.2"], }); @@ -207,7 +207,7 @@ describe("multi-model launch", () => { test("successfully launches multiple models", async () => { mockCommandResponses["git show-ref --verify --quiet refs/heads/opencode/test-session/claude-3-5-sonnet"] = { ok: false, stdout: "", stderr: "" }; - const result = await launchMultiModel({ + const result = await openMultiModel({ sessionName: "test-session", models: ["openai/gpt-5.2", "anthropic/claude-3-5-sonnet"], }); @@ -222,7 +222,7 @@ describe("multi-model launch", () => { mockCommandResponses["tmux has-session -t test session!"] = { ok: false, stdout: "", stderr: "" }; mockCommandResponses["git show-ref --verify --quiet refs/heads/opencode/test-session/gpt-5-2"] = { ok: false, stdout: "", stderr: "" }; - const result = await launchMultiModel({ + const result = await openMultiModel({ sessionName: "test session!", models: ["openai/gpt-5.2"], }); @@ -237,7 +237,7 @@ describe("multi-model launch", () => { mockCommandResponses["git worktree remove -f /mock/home/.local/share/opencode/multi-model/test-session/gpt-5-2"] = { ok: true, stdout: "", stderr: "" }; mockCommandResponses["git branch -D opencode/test-session/gpt-5-2"] = { ok: true, stdout: "", stderr: "" }; - const result = await launchMultiModel({ + const result = await openMultiModel({ sessionName: "test-session", models: ["openai/gpt-5.2"], }); @@ -263,7 +263,7 @@ describe("multi-model launch", () => { return path.includes("test-session/gpt-5-2"); }); - const result = await launchMultiModel({ + const result = await openMultiModel({ sessionName: "test-session", models: ["openai/gpt-5.2"], }); @@ -282,7 +282,7 @@ describe("multi-model launch", () => { test("fails if git branch exists for first model", async () => { mockCommandResponses["git show-ref --verify --quiet refs/heads/opencode/test-session/gpt-5-2"] = { ok: true, stdout: "", stderr: "" }; - const result = await launchMultiModel({ + const result = await openMultiModel({ sessionName: "test-session", models: ["openai/gpt-5.2"], }); @@ -302,7 +302,7 @@ describe("multi-model launch", () => { test("fails if git worktree add fails for first model", async () => { mockCommandResponses["git worktree add -b opencode/test-session/gpt-5-2 /mock/home/.local/share/opencode/multi-model/test-session/gpt-5-2"] = { ok: false, stdout: "", stderr: "git error" }; - const result = await launchMultiModel({ + const result = await openMultiModel({ sessionName: "test-session", models: ["openai/gpt-5.2"], }); @@ -325,7 +325,7 @@ describe("multi-model launch", () => { mockCommandResponses["git show-ref --verify --quiet refs/heads/opencode/test-session/gpt-5-2"] = { ok: false, stdout: "", stderr: "" }; mockCommandResponses["git show-ref --verify --quiet refs/heads/opencode/test-session/gpt-5-2-2"] = { ok: false, stdout: "", stderr: "" }; - const result = await launchMultiModel({ + const result = await openMultiModel({ sessionName: "test-session", models: ["openai/gpt-5.2", "anthropic/gpt-5.2"], }); @@ -341,7 +341,7 @@ describe("multi-model launch", () => { mockCommandResponses["opencode models"] = { ok: true, stdout: longModel, stderr: "" }; mockCommandResponses[`git show-ref --verify --quiet refs/heads/opencode/test-session/${longModel.slice(0, 24)}`] = { ok: false, stdout: "", stderr: "" }; - const result = await launchMultiModel({ + const result = await openMultiModel({ sessionName: "test-session", models: [longModel], });