2026-05-10 23:12:26 +02:00
|
|
|
import type { Command } from '@commander-js/extra-typings';
|
2026-05-10 23:51:24 +02:00
|
|
|
import type { KtxCliCommandContext } from '../cli-program.js';
|
2026-05-12 23:51:46 +02:00
|
|
|
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' } : {};
|
|
|
|
|
}
|
2026-05-10 23:12:26 +02:00
|
|
|
|
2026-05-10 23:51:24 +02:00
|
|
|
export function registerStatusCommands(program: Command, context: KtxCliCommandContext): void {
|
2026-05-10 23:12:26 +02:00
|
|
|
program
|
|
|
|
|
.command('status')
|
2026-05-12 23:51:46 +02:00
|
|
|
.description('Check current KTX setup and project readiness')
|
2026-05-10 23:12:26 +02:00
|
|
|
.option('--json', 'Print JSON output', false)
|
feat(cli): redesign ktx status output UX (#80)
* feat(cli): redesign ktx status output with grouped checks and color
Replace flat PASS/FAIL/WARN text output with a grouped, symbol-based
layout (Environment, Project, Semantic search, Query history). Passing
groups collapse to a single summary line; failing groups expand to show
individual checks with fix hints. Adds --verbose flag to show all checks
including passing ones, color support for TTY terminals, a dedicated
setup-mode report that guides users toward `ktx setup`, and timing info.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* refactor(cli): extract project checks and historic SQL doctor into status-project
Move project-level doctor checks, semantic search embedding checks, and
historic SQL doctor logic from doctor.ts into a dedicated status-project.ts
module. Removes historic-sql-doctor.ts and its test file, consolidating
everything into the new module with its own tests.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-13 18:47:58 -04:00
|
|
|
.option('-v, --verbose', 'Show every check, including passing ones', false)
|
2026-05-14 15:36:35 +02:00
|
|
|
.option('--validate', 'Only validate the ktx.yaml schema; skip readiness checks', false)
|
2026-05-21 14:07:48 +02:00
|
|
|
.option('--fast', 'Skip checks that require external communication (DB probes, auth probes)', false)
|
2026-05-12 23:51:46 +02:00
|
|
|
.option('--no-input', 'Disable interactive terminal input')
|
2026-05-14 15:36:35 +02:00
|
|
|
.action(
|
|
|
|
|
async (
|
2026-05-21 14:07:48 +02:00
|
|
|
options: { json?: boolean; verbose?: boolean; validate?: boolean; fast?: boolean; input?: boolean },
|
2026-05-14 15:36:35 +02:00
|
|
|
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;
|
|
|
|
|
}
|
2026-05-12 23:51:46 +02:00
|
|
|
context.setExitCode(
|
|
|
|
|
await runner(
|
|
|
|
|
{
|
2026-05-14 15:36:35 +02:00
|
|
|
command: 'project',
|
|
|
|
|
projectDir: resolveCommandProjectDir(command),
|
2026-05-12 23:51:46 +02:00
|
|
|
outputMode: outputMode(options),
|
feat(cli): redesign ktx status output UX (#80)
* feat(cli): redesign ktx status output with grouped checks and color
Replace flat PASS/FAIL/WARN text output with a grouped, symbol-based
layout (Environment, Project, Semantic search, Query history). Passing
groups collapse to a single summary line; failing groups expand to show
individual checks with fix hints. Adds --verbose flag to show all checks
including passing ones, color support for TTY terminals, a dedicated
setup-mode report that guides users toward `ktx setup`, and timing info.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* refactor(cli): extract project checks and historic SQL doctor into status-project
Move project-level doctor checks, semantic search embedding checks, and
historic SQL doctor logic from doctor.ts into a dedicated status-project.ts
module. Removes historic-sql-doctor.ts and its test file, consolidating
everything into the new module with its own tests.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-13 18:47:58 -04:00
|
|
|
verbose: options.verbose === true,
|
2026-05-21 14:07:48 +02:00
|
|
|
fast: options.fast === true,
|
2026-05-12 23:51:46 +02:00
|
|
|
...inputMode(options),
|
|
|
|
|
},
|
|
|
|
|
context.io,
|
|
|
|
|
),
|
|
|
|
|
);
|
2026-05-14 15:36:35 +02:00
|
|
|
},
|
|
|
|
|
);
|
2026-05-10 23:12:26 +02:00
|
|
|
}
|