mirror of
https://github.com/bendtherules/opencode-multi-model.git
synced 2026-08-18 21:52:11 +00:00
build: add direct cleanup command
This commit is contained in:
@@ -25,6 +25,7 @@ program
|
||||
sessionName,
|
||||
models: options.models,
|
||||
binaryName,
|
||||
mode: "cli",
|
||||
});
|
||||
|
||||
if (result.success) {
|
||||
|
||||
+11
-3
@@ -39,6 +39,7 @@ export async function launchMultiModel(options: MultiModelOptions): Promise<Mult
|
||||
const safeSessionName = sanitizeName(sessionName);
|
||||
const models = normalizeModels(options.models);
|
||||
const binaryName = options.binaryName || "opencode";
|
||||
const mode = options.mode || "cli";
|
||||
|
||||
if (!sessionName) {
|
||||
return { success: false, sessionName: "", error: "Error: `sessionName` must not be empty." };
|
||||
@@ -189,6 +190,10 @@ export async function launchMultiModel(options: MultiModelOptions): Promise<Mult
|
||||
const windowNames = windowPlans.map((p) => p.windowName);
|
||||
const attachCommand = `tmux attach -t ${sessionName}`;
|
||||
const cleanupCommand = `tmux kill-session -t ${sessionName} && rm -rf ~/.local/share/opencode/multi-model/${safeSessionName} && git worktree prune && git branch -D $(git branch --format='%(refname:short)' --list 'opencode/${safeSessionName}/*')`;
|
||||
const primaryCleanup =
|
||||
mode === "tool"
|
||||
? `call tool multi-model-close with sessionName: ${sessionName}`
|
||||
: `opencode-multi-model close ${sessionName}`;
|
||||
|
||||
if (failedModels.length > 0) {
|
||||
return {
|
||||
@@ -200,7 +205,9 @@ export async function launchMultiModel(options: MultiModelOptions): Promise<Mult
|
||||
`Succeeded: ${succeededModels.length > 0 ? succeededModels.join(", ") : "none"}.`,
|
||||
`Failed: ${failedModels.join(", ")}.`,
|
||||
`Attach with \`${attachCommand}\` to inspect the session.`,
|
||||
`Cleanup with \n\`${cleanupCommand}\`\nwhen done.`,
|
||||
`Cleanup when done using either:`,
|
||||
`1. ${primaryCleanup}`,
|
||||
`2. Or run manually: \`${cleanupCommand}\``,
|
||||
].join("\n"),
|
||||
};
|
||||
}
|
||||
@@ -211,8 +218,9 @@ export async function launchMultiModel(options: MultiModelOptions): Promise<Mult
|
||||
windows: windowNames,
|
||||
instructions: [
|
||||
`Use \`${attachCommand}\` to join session.`,
|
||||
`When finished, clean up worktrees with:`,
|
||||
`\`${cleanupCommand}\``,
|
||||
`When finished, clean up using either:`,
|
||||
`1. ${primaryCleanup}`,
|
||||
`2. Or run manually: \`${cleanupCommand}\``,
|
||||
].join("\n"),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ export const openTool = tool({
|
||||
sessionName: args.sessionName,
|
||||
models: args.models,
|
||||
binaryName,
|
||||
mode: "tool",
|
||||
});
|
||||
|
||||
context.metadata({
|
||||
|
||||
@@ -8,6 +8,8 @@ export interface MultiModelOptions {
|
||||
models: string[];
|
||||
/** Binary name to use ('opencode' or 'kilo'). Defaults to 'opencode'. */
|
||||
binaryName?: string;
|
||||
/** Caller context: 'cli' shows shell commands, 'tool' shows tool instructions. */
|
||||
mode?: "cli" | "tool";
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user