From bfd55e0f9f55c284baa757fa58067e7bb11e8deb Mon Sep 17 00:00:00 2001 From: bendtherules Date: Thu, 19 Mar 2026 19:41:25 +0530 Subject: [PATCH] build: add direct cleanup command --- README.md | 29 ++++++++++++++++------------- src/cli.ts | 1 + src/core/launch.ts | 14 +++++++++++--- src/tools/open.ts | 1 + src/types.ts | 2 ++ 5 files changed, 31 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 1034602..4d1e150 100644 --- a/README.md +++ b/README.md @@ -34,8 +34,8 @@ If you installed it via bun and want to use it as a project tool, import it from ```typescript // .opencode/tools/multi-model.ts -import { openTool, closeTool } from "@username/opencode-multi-model" -export { openTool, closeTool } +import { openTool as open, closeTool as close } from "@username/opencode-multi-model" +export { open, close } ``` If you are developing this package locally and want to test it in a project without publishing, import via relative paths: @@ -44,7 +44,7 @@ If you are developing this package locally and want to test it in a project with // .opencode/tools/multi-model.ts import { openTool } from "../../src/tools/open" import { closeTool } from "../../src/tools/close" -export { openTool, closeTool } +export { openTool as open, closeTool as close } ``` ## Usage @@ -57,10 +57,14 @@ Use multi-model-open tool: sessionName: my-session, models: ["openai/gpt-4o", "anthropic/claude-3-5-sonnet"] ``` -**Close a session:** +**Close a session (using tool):** ``` -Use multi-model-close tool: -sessionName: my-session, cleanupWorktrees: true +call tool multi-model-close with sessionName: my-session +``` + +**Close a session (using manual command):** +```bash +tmux kill-session -t my-session && rm -rf ~/.local/share/opencode/multi-model/my-session && git worktree prune && git branch -D $(git branch --format='%(refname:short)' --list 'opencode/my-session/*') ``` ### CLI Usage @@ -78,16 +82,15 @@ export OPENCODE_MULTI_MODEL_BINARY=kilo opencode-multi-model open my-session -m openai/gpt-4o ``` -**Close a session:** +**Close a session (CLI command):** ```bash -# Just close the tmux session -opencode-multi-model close my-session - # Close and cleanup worktrees -opencode-multi-model close my-session --cleanup-worktrees +opencode-multi-model close my-session +``` -# Force cleanup without confirmation -opencode-multi-model close my-session --cleanup-worktrees --force +**Close a session (manual command):** +```bash +tmux kill-session -t my-session && rm -rf ~/.local/share/opencode/multi-model/my-session && git worktree prune && git branch -D $(git branch --format='%(refname:short)' --list 'opencode/my-session/*') ``` **Help:** diff --git a/src/cli.ts b/src/cli.ts index 6416435..2d141e5 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -25,6 +25,7 @@ program sessionName, models: options.models, binaryName, + mode: "cli", }); if (result.success) { diff --git a/src/core/launch.ts b/src/core/launch.ts index 173303b..0db0e89 100644 --- a/src/core/launch.ts +++ b/src/core/launch.ts @@ -39,6 +39,7 @@ export async function launchMultiModel(options: MultiModelOptions): Promise 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 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