Files
opencode-multi-model/src/tools/close.ts
T
bendtherules 6b07a7ac2a feat: add required mode flag to cleanup and close
- Made `mode` a mandatory property in `MultiModelOptions`, `CloseSessionOptions`, and `CleanupOptions`.
- Updated function signatures to accept `mode` and removed default empty option objects where appropriate.
- Passed `mode: "cli"` from CLI commands and `mode: "tool"` from tool commands to cleanup, close, and open operations.
- Adjusted internal handling to use the provided `mode` (removed fallback defaults).
- Updated type definitions and added documentation for the new `mode` field.
2026-03-23 13:59:05 +05:30

52 lines
1.6 KiB
TypeScript

import { tool } from "@opencode-ai/plugin";
import { closeMultiModel } from "../core/close";
/**
* OpenCode tool definition for closing multi-model tmux sessions.
*
* Kills the tmux session and optionally removes git worktrees,
* creates archive tags, and deletes associated branches.
*/
export const closeTool = tool({
description: `Close a multi-model tmux session and optionally clean up worktrees and branches.
Arguments:
- \`sessionName\` (string, required): tmux session name to close.
- \`cleanupWorktrees\` (boolean, optional, default: true): Whether to remove worktrees and delete branches.
- \`createArchiveTags\` (boolean, optional, default: true): Whether to create archive tags before deleting branches.`,
args: {
sessionName: tool.schema
.string()
.min(1)
.describe("tmux session name to close"),
cleanupWorktrees: tool.schema
.boolean()
.default(true)
.describe(
"whether to remove worktrees and delete branches (default: true)",
),
createArchiveTags: tool.schema
.boolean()
.default(true)
.describe(
"whether to create archive tags before deleting branches (default: true)",
),
},
async execute(args, _context) {
// In plugin mode, we skip confirmation (force=true) since there's no interactive terminal
const result = await closeMultiModel({
sessionName: args.sessionName,
cleanupWorktrees: args.cleanupWorktrees,
createArchiveTags: args.createArchiveTags,
force: true,
mode: "tool",
});
if (!result.success) {
return result.error!;
}
return result.instructions;
},
});