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, }); if (!result.success) { return result.error!; } return result.instructions; }, });