67 lines
1.9 KiB
Markdown
67 lines
1.9 KiB
Markdown
|
|
# Task ID: 94
|
||
|
|
|
||
|
|
**Title:** Implement mcpctl create proxymodel Command
|
||
|
|
|
||
|
|
**Status:** cancelled
|
||
|
|
|
||
|
|
**Dependencies:** 78 ✓
|
||
|
|
|
||
|
|
**Priority:** medium
|
||
|
|
|
||
|
|
**Description:** Add CLI command to scaffold a new proxymodel YAML file with specified stages.
|
||
|
|
|
||
|
|
**Details:**
|
||
|
|
|
||
|
|
Create `src/cli/src/commands/create-proxymodel.ts`:
|
||
|
|
|
||
|
|
```typescript
|
||
|
|
import { Command } from 'commander';
|
||
|
|
import { mkdir, writeFile, access } from 'fs/promises';
|
||
|
|
import { join } from 'path';
|
||
|
|
import { stringify as yamlStringify } from 'yaml';
|
||
|
|
|
||
|
|
const PROXYMODELS_DIR = join(process.env.HOME ?? '', '.mcpctl', 'proxymodels');
|
||
|
|
|
||
|
|
export function registerCreateProxymodel(program: Command): void {
|
||
|
|
program
|
||
|
|
.command('create proxymodel <name>')
|
||
|
|
.description('Create a new proxymodel')
|
||
|
|
.option('--stages <stages>', 'Comma-separated list of stage names', 'passthrough')
|
||
|
|
.option('--controller <controller>', 'Session controller (gate or none)', 'gate')
|
||
|
|
.action(async (name: string, opts) => {
|
||
|
|
await mkdir(PROXYMODELS_DIR, { recursive: true });
|
||
|
|
|
||
|
|
const filePath = join(PROXYMODELS_DIR, `${name}.yaml`);
|
||
|
|
|
||
|
|
try {
|
||
|
|
await access(filePath);
|
||
|
|
console.error(`Proxymodel '${name}' already exists at ${filePath}`);
|
||
|
|
process.exit(1);
|
||
|
|
} catch {
|
||
|
|
// File doesn't exist, good
|
||
|
|
}
|
||
|
|
|
||
|
|
const stages = opts.stages.split(',').map((s: string) => ({ type: s.trim() }));
|
||
|
|
|
||
|
|
const model = {
|
||
|
|
kind: 'ProxyModel',
|
||
|
|
metadata: { name },
|
||
|
|
spec: {
|
||
|
|
controller: opts.controller,
|
||
|
|
stages,
|
||
|
|
appliesTo: ['prompts', 'toolResults'],
|
||
|
|
cacheable: true,
|
||
|
|
},
|
||
|
|
};
|
||
|
|
|
||
|
|
await writeFile(filePath, yamlStringify(model));
|
||
|
|
|
||
|
|
console.log(`Created ${filePath}`);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
**Test Strategy:**
|
||
|
|
|
||
|
|
CLI test: `mcpctl create proxymodel my-pipeline --stages summarize,compress` creates valid YAML. Test default values. Verify generated YAML validates against schema.
|