feat(cli): add ktx dev schema to emit ktx.yaml JSON Schema (#93)

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:
Andrey Avtomonov 2026-05-14 16:21:29 +02:00 committed by GitHub
parent c7c5f63a66
commit 2bca308863
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 299 additions and 110 deletions

View file

@ -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);
}