mirror of
https://github.com/bendtherules/opencode-multi-model.git
synced 2026-08-18 21:52:11 +00:00
refactor: rename launchMultiModel to openMultiModel
This commit is contained in:
+2
-2
@@ -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,
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
export { launchMultiModel } from "./open";
|
||||
export { openMultiModel } from "./open";
|
||||
export { closeMultiModel } from "./close";
|
||||
export * from "./utils";
|
||||
|
||||
+2
-2
@@ -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<MultiModelResult> {
|
||||
export async function openMultiModel(options: MultiModelOptions): Promise<MultiModelResult> {
|
||||
const sessionName = options.sessionName.trim();
|
||||
const safeSessionName = sanitizeName(sessionName);
|
||||
const models = normalizeModels(options.models);
|
||||
|
||||
+2
-2
@@ -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,
|
||||
|
||||
+18
-18
@@ -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],
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user