mirror of
https://github.com/bendtherules/opencode-multi-model.git
synced 2026-08-18 13:42:21 +00:00
feat: add option to disable archive tags
This commit is contained in:
+3
-1
@@ -45,13 +45,15 @@ program
|
||||
.description("Close a multi-model tmux session")
|
||||
.argument("<session-name>", "Name of the tmux session to close")
|
||||
.option("-c, --cleanup-worktrees", "Remove worktrees and delete branches", true)
|
||||
.option("-t, --add-tags", "Create archive tags before deleting branches", true)
|
||||
.option("-f, --force", "Skip confirmation prompts", false)
|
||||
.action(async (sessionName: string, options: { cleanupWorktrees: boolean; force: boolean }) => {
|
||||
.action(async (sessionName: string, options: { cleanupWorktrees: boolean; force: boolean; addTags: boolean }) => {
|
||||
try {
|
||||
const result = await closeMultiModel({
|
||||
sessionName,
|
||||
cleanupWorktrees: options.cleanupWorktrees,
|
||||
force: options.force,
|
||||
createArchiveTags: options.addTags,
|
||||
});
|
||||
|
||||
if (result.success) {
|
||||
|
||||
+12
-10
@@ -96,17 +96,19 @@ export async function closeMultiModel(options: CloseSessionOptions): Promise<Clo
|
||||
await runCommand(["git", "worktree", "remove", "-f", worktree.path]);
|
||||
worktreesRemoved.push(worktree.path);
|
||||
|
||||
// Create an archive tag before deleting the branch for safe recovery
|
||||
const timestamp = new Date().toISOString().replace(/[:.]/g, "-");
|
||||
const archiveTag = `archive/${worktree.branch}-${timestamp}`;
|
||||
const tagResult = await runCommand(["git", "tag", archiveTag, worktree.branch]);
|
||||
// Optionally create an archive tag before deleting the branch for safe recovery
|
||||
if (options.createArchiveTags !== false) {
|
||||
const timestamp = new Date().toISOString().replace(/[:.]/g, "-");
|
||||
const archiveTag = `archive/${worktree.branch}-${timestamp}`;
|
||||
const tagResult = await runCommand(["git", "tag", archiveTag, worktree.branch]);
|
||||
|
||||
if (tagResult.ok) {
|
||||
tagsCreated.push(archiveTag);
|
||||
} else {
|
||||
const warningMsg = chalk.red(`Warning: Failed to create tag ${archiveTag} for branch ${worktree.branch}.`);
|
||||
instructionsArr.push(warningMsg);
|
||||
}
|
||||
if (tagResult.ok) {
|
||||
tagsCreated.push(archiveTag);
|
||||
} else {
|
||||
const warningMsg = chalk.red(`Warning: Failed to create tag ${archiveTag} for branch ${worktree.branch}.`);
|
||||
instructionsArr.push(warningMsg);
|
||||
}
|
||||
}
|
||||
|
||||
await runCommand(["git", "branch", "-D", worktree.branch]);
|
||||
branchesDeleted.push(worktree.branch);
|
||||
|
||||
@@ -12,12 +12,14 @@ export const closeTool = tool({
|
||||
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,
|
||||
});
|
||||
|
||||
|
||||
@@ -32,6 +32,8 @@ export interface MultiModelResult {
|
||||
* Options for closing a multi-model tmux session.
|
||||
*/
|
||||
export interface CloseSessionOptions {
|
||||
/** Whether to create archive tags before deleting branches. */
|
||||
createArchiveTags?: boolean;
|
||||
/** Name of the tmux session to close. */
|
||||
sessionName: string;
|
||||
/** Whether to remove worktrees and delete branches. */
|
||||
|
||||
Reference in New Issue
Block a user