feat: add cleanup command to readme

Introduce a new `cleanup` command that discovers and deletes archive tags, with options for force, remote handling, and local-only operations. Updated README with usage examples, added help entry, and expanded documentation to describe the command and its steps. Added corresponding implementation files (`cleanup.ts`) in both core and tools directories.
This commit is contained in:
2026-03-23 11:32:42 +05:30
parent 4f15a8f8d2
commit 233e211eb8
+54 -2
View File
@@ -62,6 +62,11 @@ sessionName: my-session, models: ["openai/gpt-5.2", "anthropic/claude-3-5-sonnet
call tool multi-model-close with sessionName: my-session call tool multi-model-close with sessionName: my-session
``` ```
**Cleanup archive tags (using tool):**
```
call tool multi-model-cleanup
```
**Close a session (using manual command):** **Close a session (using manual command):**
```bash ```bash
tmux kill-session -t my-session && rm -rf ~/.local/share/opencode/multi-model/my-session && git worktree prune && git branch -D $(git branch --format='%(refname:short)' --list 'opencode/my-session/*') tmux kill-session -t my-session && rm -rf ~/.local/share/opencode/multi-model/my-session && git worktree prune && git branch -D $(git branch --format='%(refname:short)' --list 'opencode/my-session/*')
@@ -88,6 +93,21 @@ opencode-multi-model open my-session -m openai/gpt-5.2
opencode-multi-model close my-session opencode-multi-model close my-session
``` ```
**Cleanup archive tags (CLI command):**
```bash
# Delete all archive tags from local and remote repositories
opencode-multi-model cleanup
# Delete all archive tags without confirmation prompts
opencode-multi-model cleanup --force
# Delete only local archive tags, skip remote deletion
opencode-multi-model cleanup --no-remote
# Delete archive tags and push deletions to a specific remote
opencode-multi-model cleanup --remote origin
```
**Close a session (manual command):** **Close a session (manual command):**
```bash ```bash
tmux kill-session -t my-session && rm -rf ~/.local/share/opencode/multi-model/my-session && git worktree prune && git branch -D $(git branch --format='%(refname:short)' --list 'opencode/my-session/*') tmux kill-session -t my-session && rm -rf ~/.local/share/opencode/multi-model/my-session && git worktree prune && git branch -D $(git branch --format='%(refname:short)' --list 'opencode/my-session/*')
@@ -98,6 +118,7 @@ tmux kill-session -t my-session && rm -rf ~/.local/share/opencode/multi-model/my
opencode-multi-model --help opencode-multi-model --help
opencode-multi-model open --help opencode-multi-model open --help
opencode-multi-model close --help opencode-multi-model close --help
opencode-multi-model cleanup --help
``` ```
## Configuration ## Configuration
@@ -151,6 +172,21 @@ opencode-multi-model close <session-name> [options]
| `--no-tags` | Do not create archive tags before deleting branches | | `--no-tags` | Do not create archive tags before deleting branches |
| `-f, --force` | Skip confirmation prompts | | `-f, --force` | Skip confirmation prompts |
### `cleanup` - Delete all archive tags from local and remote repositories
Archive tags have the format: `archive/<branch-name>-<timestamp>`. These are created by the close command to preserve branch state before deletion.
```bash
opencode-multi-model cleanup [options]
```
**Options:**
| Option | Description |
|--------|-------------|
| `-f, --force` | Skip confirmation prompts |
| `-r, --remote <remote>` | Remote name to push deletions to (default: first remote from git remote -v) |
| `--no-remote` | Only delete local tags, skip remote |
### Global Options ### Global Options
| Option | Description | | Option | Description |
@@ -191,6 +227,20 @@ The `close` command performs the following steps:
4. **Directory cleanup**: Removes the base session directory 4. **Directory cleanup**: Removes the base session directory
### `cleanup` command
The `cleanup` command performs the following steps:
1. **Archive tag discovery**: Finds all git tags matching the pattern `archive/*`
2. **Local tag deletion**: Deletes all archive tags from the local repository
3. **Remote tag deletion** (unless `--no-remote`):
- Determines which remote to use (user-specified, first available, or skip)
- Pushes tag deletions to the remote repository
4. **Summary**: Reports the number of tags deleted locally and remotely
## Requirements ## Requirements
- tmux - tmux
@@ -230,11 +280,13 @@ bun dist/cli.js close test-session
│ ├── core/ │ ├── core/
│ │ ├── index.ts # Core exports │ │ ├── index.ts # Core exports
│ │ ├── open.ts # Launch session logic │ │ ├── open.ts # Launch session logic
│ │ ├── close.ts # Close session logic │ │ ├── close.ts # Close session logic
│ │ ├── cleanup.ts # Cleanup archive tags logic
│ │ └── utils.ts # Helper functions │ │ └── utils.ts # Helper functions
│ └── tools/ │ └── tools/
│ ├── open.ts # Open tool definition │ ├── open.ts # Open tool definition
── close.ts # Close tool definition ── close.ts # Close tool definition
│ └── cleanup.ts # Cleanup tool definition
├── tests/ ├── tests/
│ └── multi-model.test.ts # Tests │ └── multi-model.test.ts # Tests
├── package.json ├── package.json