Impl: tool-npm-package

This commit is contained in:
2026-03-19 19:12:50 +05:30
parent f1b09bf7de
commit ca753cd1ca
17 changed files with 1914 additions and 499 deletions
+41
View File
@@ -0,0 +1,41 @@
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 cleanup worktrees and 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)"),
},
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,
force: true,
});
if (!result.success) {
return result.error!;
}
let details = "";
if (result.cleanupPerformed) {
details += ` Removed ${result.worktreesRemoved?.length || 0} worktrees.`;
if (result.tagsCreated && result.tagsCreated.length > 0) {
details += ` Created backup tags: ${result.tagsCreated.join(", ")}.`;
}
if (result.warnings && result.warnings.length > 0) {
details += ` Warnings: ${result.warnings.join("; ")}.`;
}
}
return `Session "${result.sessionName}" has been closed.${details}`;
},
});