mirror of
https://github.com/Kaelio/ktx.git
synced 2026-06-13 08:15:14 +02:00
feat(cli): add ktx dev schema to emit ktx.yaml JSON Schema
Annotates the Zod config schema with .describe() text on every field and adds generateKtxProjectConfigJsonSchema() plus a ktx dev schema command that prints (or writes) a draft-07 JSON Schema for editors and LLM agents.
This commit is contained in:
parent
b3be54e3fa
commit
bd4b41f681
4 changed files with 299 additions and 110 deletions
|
|
@ -46,5 +46,23 @@ export function registerDevCommands(program: Command, context: KtxCliCommandCont
|
|||
},
|
||||
);
|
||||
|
||||
dev
|
||||
.command('schema')
|
||||
.description('Print a JSON Schema describing ktx.yaml (for editors and LLM agents)')
|
||||
.option('--output <file>', 'Write the schema to a file instead of stdout')
|
||||
.action(async (options: { output?: string }) => {
|
||||
const { generateKtxProjectConfigJsonSchema } = await import('@ktx/context/project');
|
||||
const json = `${JSON.stringify(generateKtxProjectConfigJsonSchema(), null, 2)}\n`;
|
||||
if (options.output) {
|
||||
const { writeFile } = await import('node:fs/promises');
|
||||
const target = resolve(options.output);
|
||||
await writeFile(target, json, 'utf8');
|
||||
context.io.stdout.write(`Wrote ${target}\n`);
|
||||
} else {
|
||||
context.io.stdout.write(json);
|
||||
}
|
||||
context.setExitCode(0);
|
||||
});
|
||||
|
||||
registerRuntimeCommands(dev, context);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue