Files
opencode-multi-model/src/tools/cleanup.ts
T
bendtherules 46d81b4162 feat(tools): enhance CLI tool descriptions and add remote handling option
- Updated `cleanupTool` description to include detailed usage and arguments.
- Added optional `noRemote` flag to `cleanupTool` for local‑only tag deletion.
- Adjusted remote handling logic to respect the new `noRemote` flag.
- Expanded `closeTool` description with clear argument documentation.
- Expanded `openTool` description with detailed argument documentation.
2026-03-23 10:24:49 +05:30

50 lines
1.5 KiB
TypeScript

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
.union([
tool.schema
.string()
.describe(
"Remote name to push deletions to. Error if doesn't exist.",
)
])
.optional()
.describe(
"Remote handling: string=specific remote, undefined=first available remote",
),
noRemote: tool.schema
.literal(true)
.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,
});
if (!result.success) {
return result.error!;
}
return (
result.instructions ?? `Deleted ${result.localTagsDeleted} local tags.`
);
},
});