import { tool } from "@opencode-ai/plugin"; import { cleanupMultiModel } from "../core/cleanup"; /** * OpenCode tool definition for cleaning up archive tags. * * Deletes archive tags (format: archive/*) from local and remote repositories. * Used to clean up recovery tags created by the close command. */ export const cleanupTool = tool({ description: `Delete all archive tags from the local repository and, optionally, from a remote. Arguments: -\`remote\` (string, optional): Specify a remote name to which deletions should be pushed. If omitted, the first available remote is used. - \`noRemote\` (boolean, optional): When true, only delete local tags and do not push deletions to any remote.`, args: { remote: tool.schema .string() .optional() .describe( "Remote handling: string=specific remote, undefined=first available remote", ), noRemote: tool.schema .boolean() .default(false) .describe("Only delete local tags, don't push to remote.") .optional(), }, async execute(args, _context) { // In plugin mode, we skip confirmation (force=true) const result = await cleanupMultiModel({ force: true, remote: args.noRemote ? false : args.remote, mode: "tool", }); if (!result.success) { return result.error!; } return ( result.instructions ?? `Deleted ${result.localTagsDeleted} local tags.` ); }, });