refactor: rename launchMultiModel to openMultiModel

This commit is contained in:
2026-03-20 13:38:46 +05:30
parent 962c9a474f
commit 8a087275b3
5 changed files with 25 additions and 25 deletions
+2 -2
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env bun #!/usr/bin/env bun
import { Command } from "commander"; import { Command } from "commander";
import { launchMultiModel } from "./core/open"; import { openMultiModel } from "./core/open";
import { closeMultiModel } from "./core/close"; import { closeMultiModel } from "./core/close";
import { getBinaryName } from "./core/utils"; import { getBinaryName } from "./core/utils";
@@ -21,7 +21,7 @@ program
try { try {
const binaryName = options.binary || getBinaryName(); const binaryName = options.binary || getBinaryName();
const result = await launchMultiModel({ const result = await openMultiModel({
sessionName, sessionName,
models: options.models, models: options.models,
binaryName, binaryName,
+1 -1
View File
@@ -1,3 +1,3 @@
export { launchMultiModel } from "./open"; export { openMultiModel } from "./open";
export { closeMultiModel } from "./close"; export { closeMultiModel } from "./close";
export * from "./utils"; export * from "./utils";
+2 -2
View File
@@ -24,7 +24,7 @@ import {
* *
* @example * @example
* ```ts * ```ts
* const result = await launchMultiModel({ * const result = await openMultiModel({
* sessionName: "compare", * sessionName: "compare",
* models: ["openai/gpt-5.2", "anthropic/claude-3-5-sonnet"], * models: ["openai/gpt-5.2", "anthropic/claude-3-5-sonnet"],
* binaryName: "opencode", * binaryName: "opencode",
@@ -34,7 +34,7 @@ import {
* } * }
* ``` * ```
*/ */
export async function launchMultiModel(options: MultiModelOptions): Promise<MultiModelResult> { export async function openMultiModel(options: MultiModelOptions): Promise<MultiModelResult> {
const sessionName = options.sessionName.trim(); const sessionName = options.sessionName.trim();
const safeSessionName = sanitizeName(sessionName); const safeSessionName = sanitizeName(sessionName);
const models = normalizeModels(options.models); const models = normalizeModels(options.models);
+2 -2
View File
@@ -1,5 +1,5 @@
import { tool } from "@opencode-ai/plugin"; import { tool } from "@opencode-ai/plugin";
import { launchMultiModel } from "../core/open"; import { openMultiModel } from "../core/open";
import { getBinaryName } from "../core/utils"; import { getBinaryName } from "../core/utils";
/** /**
@@ -20,7 +20,7 @@ export const openTool = tool({
async execute(args, context) { async execute(args, context) {
const binaryName = getBinaryName(); const binaryName = getBinaryName();
const result = await launchMultiModel({ const result = await openMultiModel({
sessionName: args.sessionName, sessionName: args.sessionName,
models: args.models, models: args.models,
binaryName, binaryName,
+18 -18
View File
@@ -1,7 +1,7 @@
import { expect, test, mock, spyOn, beforeEach, afterEach, describe } from "bun:test"; import { expect, test, mock, spyOn, beforeEach, afterEach, describe } from "bun:test";
import * as fs from "node:fs"; import * as fs from "node:fs";
import * as os from "node:os"; import * as os from "node:os";
import { launchMultiModel } from "../src/core/open"; import { openMultiModel } from "../src/core/open";
import { import {
shellQuote, shellQuote,
normalizeModels, normalizeModels,
@@ -79,7 +79,7 @@ describe("multi-model launch", () => {
}); });
test("fails if session name is empty", async () => { test("fails if session name is empty", async () => {
const result = await launchMultiModel({ const result = await openMultiModel({
sessionName: "", sessionName: "",
models: ["openai/gpt-5.2"], models: ["openai/gpt-5.2"],
}); });
@@ -90,7 +90,7 @@ describe("multi-model launch", () => {
}); });
test("fails if no models are provided", async () => { test("fails if no models are provided", async () => {
const result = await launchMultiModel({ const result = await openMultiModel({
sessionName: "test-session", sessionName: "test-session",
models: [], models: [],
}); });
@@ -101,7 +101,7 @@ describe("multi-model launch", () => {
}); });
test("fails if duplicate models are provided", async () => { test("fails if duplicate models are provided", async () => {
const result = await launchMultiModel({ const result = await openMultiModel({
sessionName: "test-session", sessionName: "test-session",
models: ["openai/gpt-5.2", "openai/gpt-5.2"], 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 () => { 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" }; 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", sessionName: "test-session",
models: ["openai/gpt-5.2"], models: ["openai/gpt-5.2"],
}); });
@@ -127,7 +127,7 @@ describe("multi-model launch", () => {
test("fails if tmux is not installed", async () => { test("fails if tmux is not installed", async () => {
mockCommandResponses["command -v tmux"] = { ok: false, stdout: "", stderr: "" }; mockCommandResponses["command -v tmux"] = { ok: false, stdout: "", stderr: "" };
const result = await launchMultiModel({ const result = await openMultiModel({
sessionName: "test-session", sessionName: "test-session",
models: ["openai/gpt-5.2"], models: ["openai/gpt-5.2"],
}); });
@@ -143,7 +143,7 @@ describe("multi-model launch", () => {
test("fails if opencode is not installed", async () => { test("fails if opencode is not installed", async () => {
mockCommandResponses["command -v opencode"] = { ok: false, stdout: "", stderr: "" }; mockCommandResponses["command -v opencode"] = { ok: false, stdout: "", stderr: "" };
const result = await launchMultiModel({ const result = await openMultiModel({
sessionName: "test-session", sessionName: "test-session",
models: ["openai/gpt-5.2"], models: ["openai/gpt-5.2"],
}); });
@@ -158,7 +158,7 @@ describe("multi-model launch", () => {
}); });
test("fails if model name is not in allowlist", async () => { test("fails if model name is not in allowlist", async () => {
const result = await launchMultiModel({ const result = await openMultiModel({
sessionName: "test-session", sessionName: "test-session",
models: ["invalid/model"], models: ["invalid/model"],
}); });
@@ -176,7 +176,7 @@ describe("multi-model launch", () => {
test("fails if session already exists", async () => { test("fails if session already exists", async () => {
mockCommandResponses["tmux has-session -t test-session"] = { ok: true, stdout: "", stderr: "" }; mockCommandResponses["tmux has-session -t test-session"] = { ok: true, stdout: "", stderr: "" };
const result = await launchMultiModel({ const result = await openMultiModel({
sessionName: "test-session", sessionName: "test-session",
models: ["openai/gpt-5.2"], models: ["openai/gpt-5.2"],
}); });
@@ -193,7 +193,7 @@ describe("multi-model launch", () => {
}); });
test("successfully plans and executes tmux launch with single model", async () => { test("successfully plans and executes tmux launch with single model", async () => {
const result = await launchMultiModel({ const result = await openMultiModel({
sessionName: "test-session", sessionName: "test-session",
models: ["openai/gpt-5.2"], models: ["openai/gpt-5.2"],
}); });
@@ -207,7 +207,7 @@ describe("multi-model launch", () => {
test("successfully launches multiple models", async () => { 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: "" }; 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", sessionName: "test-session",
models: ["openai/gpt-5.2", "anthropic/claude-3-5-sonnet"], 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["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: "" }; 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!", sessionName: "test session!",
models: ["openai/gpt-5.2"], 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 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: "" }; 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", sessionName: "test-session",
models: ["openai/gpt-5.2"], models: ["openai/gpt-5.2"],
}); });
@@ -263,7 +263,7 @@ describe("multi-model launch", () => {
return path.includes("test-session/gpt-5-2"); return path.includes("test-session/gpt-5-2");
}); });
const result = await launchMultiModel({ const result = await openMultiModel({
sessionName: "test-session", sessionName: "test-session",
models: ["openai/gpt-5.2"], models: ["openai/gpt-5.2"],
}); });
@@ -282,7 +282,7 @@ describe("multi-model launch", () => {
test("fails if git branch exists for first model", async () => { 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: "" }; 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", sessionName: "test-session",
models: ["openai/gpt-5.2"], models: ["openai/gpt-5.2"],
}); });
@@ -302,7 +302,7 @@ describe("multi-model launch", () => {
test("fails if git worktree add fails for first model", async () => { 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" }; 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", sessionName: "test-session",
models: ["openai/gpt-5.2"], 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"] = { ok: false, stdout: "", stderr: "" };
mockCommandResponses["git show-ref --verify --quiet refs/heads/opencode/test-session/gpt-5-2-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", sessionName: "test-session",
models: ["openai/gpt-5.2", "anthropic/gpt-5.2"], 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["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: "" }; 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", sessionName: "test-session",
models: [longModel], models: [longModel],
}); });