mirror of
https://github.com/bendtherules/opencode-multi-model.git
synced 2026-08-18 13:42:21 +00:00
72 lines
2.3 KiB
TypeScript
72 lines
2.3 KiB
TypeScript
#!/usr/bin/env bun
|
|
import { Command } from "commander";
|
|
import { openMultiModel } from "./core/open";
|
|
import { closeMultiModel } from "./core/close";
|
|
import { getBinaryName } from "./core/utils";
|
|
|
|
const program = new Command();
|
|
|
|
program
|
|
.name("opencode-multi-model")
|
|
.description("Launch multiple OpenCode models in tmux sessions")
|
|
.version("1.0.0");
|
|
|
|
program
|
|
.command("open")
|
|
.description("Create a new multi-model tmux session")
|
|
.argument("<session-name>", "Name for the tmux session")
|
|
.option("-m, --models <models...>", "Model IDs to launch (space-separated)", [])
|
|
.option("-b, --binary <binary>", "Binary to use (opencode or kilo). Defaults to env var OPENCODE_MULTI_MODEL_BINARY or 'opencode'")
|
|
.action(async (sessionName: string, options: { models: string[]; binary?: string }) => {
|
|
try {
|
|
const binaryName = options.binary || getBinaryName();
|
|
|
|
const result = await openMultiModel({
|
|
sessionName,
|
|
models: options.models,
|
|
binaryName,
|
|
mode: "cli",
|
|
});
|
|
|
|
if (result.success) {
|
|
console.log(result.instructions || `Created session: ${result.sessionName}`);
|
|
} else {
|
|
console.error(`Failed: ${result.error}`);
|
|
process.exit(1);
|
|
}
|
|
} catch (error) {
|
|
console.error(`Error: ${error}`);
|
|
process.exit(1);
|
|
}
|
|
});
|
|
|
|
program
|
|
.command("close")
|
|
.description("Close a multi-model tmux session")
|
|
.argument("<session-name>", "Name of the tmux session to close")
|
|
.option("--keep-worktrees", "Do not remove worktrees and delete branches", false)
|
|
.option("--no-tags", "Create archive tags before deleting branches", false)
|
|
.option("-f, --force", "Skip confirmation prompts", false)
|
|
.action(async (sessionName: string, options: { keepWorktrees: boolean; force: boolean; tags: boolean }) => {
|
|
try {
|
|
const result = await closeMultiModel({
|
|
sessionName,
|
|
cleanupWorktrees: !options.keepWorktrees,
|
|
force: options.force,
|
|
createArchiveTags: options.tags,
|
|
});
|
|
|
|
if (result.success) {
|
|
console.log(result.instructions);
|
|
} else {
|
|
console.error(`Failed: ${result.error}`);
|
|
process.exit(1);
|
|
}
|
|
} catch (error) {
|
|
console.error(`Error: ${error}`);
|
|
process.exit(1);
|
|
}
|
|
});
|
|
|
|
program.parse();
|