71 lines
2.0 KiB
Markdown
71 lines
2.0 KiB
Markdown
|
|
# Task ID: 95
|
||
|
|
|
||
|
|
**Title:** Implement mcpctl proxymodel validate Command
|
||
|
|
|
||
|
|
**Status:** cancelled
|
||
|
|
|
||
|
|
**Dependencies:** 78 ✓, 79 ✓
|
||
|
|
|
||
|
|
**Priority:** medium
|
||
|
|
|
||
|
|
**Description:** Add CLI command to validate a proxymodel definition, checking that all stages resolve and config is valid.
|
||
|
|
|
||
|
|
**Details:**
|
||
|
|
|
||
|
|
Create `src/cli/src/commands/proxymodel-validate.ts`:
|
||
|
|
|
||
|
|
```typescript
|
||
|
|
import { Command } from 'commander';
|
||
|
|
import { loadProxyModels } from 'mcplocal/proxymodel/loader';
|
||
|
|
import { getStage, loadCustomStages } from 'mcplocal/proxymodel/stage-registry';
|
||
|
|
|
||
|
|
export function registerProxymodelValidate(program: Command): void {
|
||
|
|
program
|
||
|
|
.command('proxymodel validate <name>')
|
||
|
|
.description('Validate a proxymodel definition')
|
||
|
|
.action(async (name: string) => {
|
||
|
|
await loadCustomStages();
|
||
|
|
const models = await loadProxyModels();
|
||
|
|
const model = models.get(name);
|
||
|
|
|
||
|
|
if (!model) {
|
||
|
|
console.error(`Proxymodel '${name}' not found`);
|
||
|
|
process.exit(1);
|
||
|
|
}
|
||
|
|
|
||
|
|
let valid = true;
|
||
|
|
const errors: string[] = [];
|
||
|
|
|
||
|
|
// Check all stages resolve
|
||
|
|
for (const stageConfig of model.spec.stages) {
|
||
|
|
const stage = getStage(stageConfig.type);
|
||
|
|
if (!stage) {
|
||
|
|
errors.push(`Stage '${stageConfig.type}' not found`);
|
||
|
|
valid = false;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// Check controller is valid
|
||
|
|
const validControllers = ['gate', 'none'];
|
||
|
|
if (model.spec.controller && !validControllers.includes(model.spec.controller)) {
|
||
|
|
errors.push(`Unknown controller '${model.spec.controller}'`);
|
||
|
|
valid = false;
|
||
|
|
}
|
||
|
|
|
||
|
|
if (valid) {
|
||
|
|
console.log(`✓ Proxymodel '${name}' is valid`);
|
||
|
|
} else {
|
||
|
|
console.error(`✗ Proxymodel '${name}' has errors:`);
|
||
|
|
for (const err of errors) {
|
||
|
|
console.error(` - ${err}`);
|
||
|
|
}
|
||
|
|
process.exit(1);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
**Test Strategy:**
|
||
|
|
|
||
|
|
CLI test: valid proxymodel passes, proxymodel with unknown stage fails with clear error, proxymodel with unknown controller fails. Test with both built-in and custom stages.
|