| 81 | } |
| 82 | |
| 83 | function schemaToCLIOptions(schema: JsonSchema): CliOption[] { |
| 84 | if (!schema || !schema.properties) { |
| 85 | return []; |
| 86 | } |
| 87 | const required = schema.required || []; |
| 88 | const properties = schema.properties; |
| 89 | return Object.entries(properties).map(([name, prop]) => { |
| 90 | const isRequired = required.includes(name); |
| 91 | const description = prop.description || ''; |
| 92 | if (typeof prop.type !== 'string') { |
| 93 | throw new Error( |
| 94 | `Property ${name} has a complex type not supported by CLI.`, |
| 95 | ); |
| 96 | } |
| 97 | return { |
| 98 | name, |
| 99 | type: prop.type, |
| 100 | description, |
| 101 | required: isRequired, |
| 102 | default: prop.default, |
| 103 | enum: prop.enum, |
| 104 | }; |
| 105 | }); |
| 106 | } |
| 107 | |
| 108 | async function generateCli() { |
| 109 | const tools = await fetchTools(); |