/** * `workflow convert` — Convert a .sop.md file to a YAML workflow definition. * * Reads the SOP markdown file, parses its structure, and outputs * a corresponding YAML workflow definition. * * @example * workflow convert deploy.sop.md * workflow convert deploy.sop.md --output workflows/deploy.yaml */ import type { CliOptions } from '../utils.js'; import { printJson } from '../utils.js'; // --------------------------------------------------------------------------- // Stub: engine integration (not implemented yet) // --------------------------------------------------------------------------- interface ConvertResult { inputFile: string; outputFile: string; workflowName: string; nodeCount: number; } async function convertSopToYaml( _inputPath: string, _outputPath?: string, ): Promise { throw new Error('not implemented yet: convertSopToYaml'); } // --------------------------------------------------------------------------- // Command handler // --------------------------------------------------------------------------- export async function convertCommand( args: string[], options: CliOptions, ): Promise { if (args.length === 0) { throw new Error('Missing required argument: \n\nUsage: workflow convert [--output ]'); } const inputPath = args[0]!; if (!inputPath.endsWith('.sop.md')) { throw new Error(`Input file must end with .sop.md, got: ${inputPath}`); } const result = await convertSopToYaml(inputPath, options.output); if (options.json) { printJson(result); return; } console.log(`Converted: ${result.inputFile}`); console.log(` Output: ${result.outputFile}`); console.log(` Workflow: ${result.workflowName}`); console.log(` Nodes: ${result.nodeCount}`); }