Files
opencode-multi-model/src/tools/cleanup.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

46 lines
1.4 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
.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.`
);
},
});