New @boocode/ion package (v0.0.1) for inference optimization network. .codesight/ wiki artifacts for codebase documentation. .omo/ work plans for openspec cleanup and enhanced file panel.
66 lines
1.7 KiB
TypeScript
66 lines
1.7 KiB
TypeScript
/**
|
|
* `workflow validate` — Validate a workflow definition without executing.
|
|
*
|
|
* Loads the workflow, runs schema validation, and reports any errors.
|
|
*
|
|
* @example
|
|
* workflow validate deploy
|
|
* workflow validate deploy --json
|
|
*/
|
|
|
|
import type { CliOptions } from '../utils.js';
|
|
import { printJson } from '../utils.js';
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Stub: engine integration (not implemented yet)
|
|
// ---------------------------------------------------------------------------
|
|
|
|
interface ValidationError {
|
|
path: string;
|
|
message: string;
|
|
}
|
|
|
|
interface ValidateResult {
|
|
valid: boolean;
|
|
errors: ValidationError[];
|
|
workflowName: string;
|
|
}
|
|
|
|
async function validateWorkflow(
|
|
_name: string,
|
|
_cwd?: string,
|
|
): Promise<ValidateResult> {
|
|
throw new Error('not implemented yet: validateWorkflow');
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Command handler
|
|
// ---------------------------------------------------------------------------
|
|
|
|
export async function validateCommand(
|
|
args: string[],
|
|
options: CliOptions,
|
|
): Promise<void> {
|
|
if (args.length === 0) {
|
|
throw new Error('Missing required argument: <name>\n\nUsage: workflow validate <name> [--json]');
|
|
}
|
|
|
|
const workflowName = args[0]!;
|
|
|
|
const result = await validateWorkflow(workflowName, options.cwd);
|
|
|
|
if (options.json) {
|
|
printJson(result);
|
|
return;
|
|
}
|
|
|
|
if (result.valid) {
|
|
console.log(`✓ Workflow "${result.workflowName}" is valid.`);
|
|
} else {
|
|
console.log(`✗ Workflow "${result.workflowName}" has ${result.errors.length} error(s):`);
|
|
console.log('');
|
|
for (const err of result.errors) {
|
|
console.log(` ${err.path}: ${err.message}`);
|
|
}
|
|
}
|
|
} |