62 lines
1.7 KiB
Markdown
62 lines
1.7 KiB
Markdown
|
|
# Task ID: 101
|
||
|
|
|
||
|
|
**Title:** Implement mcpctl cache clear Command
|
||
|
|
|
||
|
|
**Status:** done
|
||
|
|
|
||
|
|
**Dependencies:** 98 ✓
|
||
|
|
|
||
|
|
**Priority:** low
|
||
|
|
|
||
|
|
**Description:** Add CLI command to clear the proxymodel cache, optionally filtered by project.
|
||
|
|
|
||
|
|
**Details:**
|
||
|
|
|
||
|
|
Create `src/cli/src/commands/cache-clear.ts`:
|
||
|
|
|
||
|
|
```typescript
|
||
|
|
import { Command } from 'commander';
|
||
|
|
import { readdir, unlink, rmdir } from 'fs/promises';
|
||
|
|
import { join } from 'path';
|
||
|
|
|
||
|
|
const CACHE_DIR = join(process.env.HOME ?? '', '.mcpctl', 'cache', 'proxymodel');
|
||
|
|
|
||
|
|
export function registerCacheClear(program: Command): void {
|
||
|
|
program
|
||
|
|
.command('cache clear')
|
||
|
|
.description('Clear the proxymodel cache')
|
||
|
|
.option('--project <name>', 'Clear only cache for a specific project')
|
||
|
|
.option('--force', 'Skip confirmation', false)
|
||
|
|
.action(async (opts) => {
|
||
|
|
try {
|
||
|
|
const files = await readdir(CACHE_DIR);
|
||
|
|
const toDelete = opts.project
|
||
|
|
? files.filter(f => f.includes(opts.project))
|
||
|
|
: files;
|
||
|
|
|
||
|
|
if (toDelete.length === 0) {
|
||
|
|
console.log('No cache entries to clear');
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
if (!opts.force) {
|
||
|
|
console.log(`This will delete ${toDelete.length} cache entries.`);
|
||
|
|
// Add confirmation prompt
|
||
|
|
}
|
||
|
|
|
||
|
|
for (const file of toDelete) {
|
||
|
|
await unlink(join(CACHE_DIR, file));
|
||
|
|
}
|
||
|
|
|
||
|
|
console.log(`Cleared ${toDelete.length} cache entries`);
|
||
|
|
} catch {
|
||
|
|
console.log('Cache directory does not exist');
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
**Test Strategy:**
|
||
|
|
|
||
|
|
CLI test: clears all entries without --project, clears filtered entries with --project, confirmation required without --force, --force skips confirmation.
|