mirror of
https://github.com/Kaelio/ktx.git
synced 2026-06-25 08:48:08 +02:00
* refactor(context): validate ktx.yaml with Zod and surface issues in status
- Replace hand-rolled ktx.yaml parsing with a strict Zod schema and
derive KtxProjectConfig types from it.
- Add validateKtxProjectConfig returning structured KtxConfigIssue[]
with migration hints for deprecated keys (ingest.llm,
scan.enrichment.backend, etc.).
- Wire ktx status/doctor to run validation, render schema issues in
plain and JSON output, and add a Config row to project status.
- Update the orbit example to camelCase scan.relationships keys to
match the schema.
* fix(context): tolerate legacy setup.completed_steps and optional driver
- Accept and drop the legacy setup.completed_steps field so existing
ktx.yaml files migrated from older versions still load.
- Make connections.<id>.driver optional in the schema; runtime code
already produces a clear "no driver" error at use time.
* feat(cli): add ktx status --validate to run only ktx.yaml schema validation
- New --validate flag dispatches a focused runKtxDoctor 'validate' branch
that reads ktx.yaml, runs validateKtxProjectConfig, and skips LLM,
connection, embedding, and query-history checks.
- Plain output prints a single Config row; JSON output emits
{ok: true} on success or the existing invalid_config / missing_project
shapes on failure.
74 lines
2.6 KiB
TypeScript
74 lines
2.6 KiB
TypeScript
import type { Command } from '@commander-js/extra-typings';
|
|
import type { KtxCliCommandContext } from '../cli-program.js';
|
|
import { resolveCommandProjectDir, resolveCommandProjectDirOverride } from '../cli-program.js';
|
|
import { findNearestKtxProjectDir } from '../project-resolver.js';
|
|
|
|
function outputMode(options: { json?: boolean }): 'plain' | 'json' {
|
|
return options.json === true ? 'json' : 'plain';
|
|
}
|
|
|
|
function inputMode(options: { input?: boolean }): { inputMode?: 'disabled' } {
|
|
return options.input === false ? { inputMode: 'disabled' } : {};
|
|
}
|
|
|
|
export function registerStatusCommands(program: Command, context: KtxCliCommandContext): void {
|
|
program
|
|
.command('status')
|
|
.description('Check current KTX setup and project readiness')
|
|
.option('--json', 'Print JSON output', false)
|
|
.option('-v, --verbose', 'Show every check, including passing ones', false)
|
|
.option('--validate', 'Only validate the ktx.yaml schema; skip readiness checks', false)
|
|
.option('--no-input', 'Disable interactive terminal input')
|
|
.action(
|
|
async (
|
|
options: { json?: boolean; verbose?: boolean; validate?: boolean; input?: boolean },
|
|
command,
|
|
) => {
|
|
const runner = context.deps.doctor ?? (await import('../doctor.js')).runKtxDoctor;
|
|
const explicitOrEnvProjectDir = resolveCommandProjectDirOverride(command);
|
|
const nearestProjectDir = explicitOrEnvProjectDir ? undefined : findNearestKtxProjectDir(process.cwd());
|
|
|
|
if (options.validate === true) {
|
|
context.setExitCode(
|
|
await runner(
|
|
{
|
|
command: 'validate',
|
|
projectDir: resolveCommandProjectDir(command),
|
|
outputMode: outputMode(options),
|
|
...inputMode(options),
|
|
},
|
|
context.io,
|
|
),
|
|
);
|
|
return;
|
|
}
|
|
|
|
if (!explicitOrEnvProjectDir && !nearestProjectDir) {
|
|
context.setExitCode(
|
|
await runner(
|
|
{
|
|
command: 'setup',
|
|
outputMode: outputMode(options),
|
|
verbose: options.verbose === true,
|
|
...inputMode(options),
|
|
},
|
|
context.io,
|
|
),
|
|
);
|
|
return;
|
|
}
|
|
context.setExitCode(
|
|
await runner(
|
|
{
|
|
command: 'project',
|
|
projectDir: resolveCommandProjectDir(command),
|
|
outputMode: outputMode(options),
|
|
verbose: options.verbose === true,
|
|
...inputMode(options),
|
|
},
|
|
context.io,
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|