mirror of
https://github.com/Kaelio/ktx.git
synced 2026-07-25 12:01:03 +02:00
* fix(cli): double the height of the setup banner t crossbar
* fix(cli): unify setup multi-select hints and make Tab the select key
The six interactive multi-select surfaces in `ktx setup` documented three
different hint voices, one had no hint at all, and they named two different
select keys (Space vs Tab). Tab is the only key that can toggle selection
without colliding with type-to-search input, so make it the single documented
select key everywhere and compose every hint from one shared fragment
vocabulary in prompt-navigation.ts.
- Register `updateSettings({ aliases: { tab: 'space' } })` so Tab toggles flat
multiselects; the alias applies only to non-text prompts, leaving typed
search input (schema/Notion) untouched.
- Add the missing hint to the agent-targets prompt and drop the stray
"Space to select … Esc …" info line plus the now-dead writeSetupInfo helper.
- Replace the schema-scope ad-hoc hint with the searchable-multiselect voice
and standardize "filter" -> "search" vocabulary.
- Delete DEFAULT_TREE_PICKER_HELP_TEXT and the unused TreePickerChrome.helpText
seam; render the shared tree hint instead.
* refactor(cli): show LLM check progress for every setup backend
Rename runLlmHealthCheckWithProgress to validateModelWithProgress and
wrap the Claude subscription and Codex auth probes in the same spinner
progress as the Anthropic API and Vertex backends, so each backend shows
consistent "Checking <provider> LLM" output during setup.
* feat(cli): add ktx-orange progress spinners to setup steps
Add a shared runWithCliSpinner helper and a TTY-aware createCliSpinner:
an animated clack spinner in a terminal, and a static stderr-only spinner
before raw-mode pickers (the table tree picker and demo tour), where the
animated spinner's stdin grab would otherwise corrupt the next prompt.
Wrap the slow setup waits in progress spinners: managed runtime install,
embedding daemon start + first-run model download, embeddings health
check, the connection-test gate, and source validation / dbt clone /
Metabase discovery. Recolor every spinner frame from clack's magenta to
the ktx mascot orange (#FF8A4C) via the static helper and clack's
styleFrame option.
120 lines
3.5 KiB
TypeScript
120 lines
3.5 KiB
TypeScript
/** @internal */
|
|
export const MULTISELECT_NAVIGATION_FRAGMENTS = {
|
|
move: 'Up/Down to move',
|
|
expand: 'Right/Left to expand or collapse',
|
|
select: 'Tab to select or unselect',
|
|
search: 'Type to search',
|
|
confirm: 'Enter to confirm',
|
|
back: 'Escape to go back',
|
|
backSearchableTree: 'Escape to clear search or go back',
|
|
exit: 'Ctrl+C to exit',
|
|
} as const;
|
|
|
|
function composeNavigationHint(fragments: readonly string[]): string {
|
|
return `${fragments.join(', ')}.`;
|
|
}
|
|
|
|
const fragment = MULTISELECT_NAVIGATION_FRAGMENTS;
|
|
|
|
/** @internal */
|
|
export const FLAT_MULTISELECT_NAVIGATION_HINT = composeNavigationHint([
|
|
fragment.move,
|
|
fragment.select,
|
|
fragment.confirm,
|
|
fragment.back,
|
|
fragment.exit,
|
|
]);
|
|
|
|
/** @internal */
|
|
export const SEARCHABLE_MULTISELECT_NAVIGATION_HINT = composeNavigationHint([
|
|
fragment.move,
|
|
fragment.select,
|
|
fragment.search,
|
|
fragment.confirm,
|
|
fragment.back,
|
|
fragment.exit,
|
|
]);
|
|
|
|
export const TREE_PICKER_NAVIGATION_HINT = composeNavigationHint([
|
|
fragment.move,
|
|
fragment.expand,
|
|
fragment.select,
|
|
fragment.search,
|
|
fragment.confirm,
|
|
fragment.backSearchableTree,
|
|
fragment.exit,
|
|
]);
|
|
|
|
const TEXT_INPUT_NAVIGATION_HINT = 'Press Escape to go back.';
|
|
|
|
function removeTrailingBlankLines(message: string): string {
|
|
return message.replace(/\n+$/, '');
|
|
}
|
|
|
|
function prefixContinuationLines(message: string): string {
|
|
const lines = message.split('\n');
|
|
if (lines.length <= 1) return message;
|
|
const [title, ...body] = lines;
|
|
let trailingEmptyCount = 0;
|
|
while (trailingEmptyCount < body.length && body[body.length - 1 - trailingEmptyCount] === '') {
|
|
trailingEmptyCount++;
|
|
}
|
|
const contentBody = trailingEmptyCount > 0 ? body.slice(0, -trailingEmptyCount) : body;
|
|
const trailingBody = trailingEmptyCount > 0 ? body.slice(-trailingEmptyCount) : [];
|
|
return [
|
|
title,
|
|
...contentBody.map((line) => {
|
|
const stripped = line.replace(/^│\s*/, '');
|
|
return stripped === '' ? '│' : `│ ${stripped}`;
|
|
}),
|
|
...trailingBody,
|
|
].join('\n');
|
|
}
|
|
|
|
function withTextInputBodySpacing(message: string): string {
|
|
const normalized = removeTrailingBlankLines(message);
|
|
if (!normalized.includes('\n')) {
|
|
return normalized;
|
|
}
|
|
const [title, ...bodyLines] = normalized.split('\n');
|
|
if (bodyLines[0] === '') {
|
|
return normalized;
|
|
}
|
|
return `${title}\n\n${bodyLines.join('\n')}`;
|
|
}
|
|
|
|
/** @internal */
|
|
export function withMenuOptionSpacing(message: string): string {
|
|
if (!message.includes('\n') || message.endsWith('\n')) {
|
|
return message;
|
|
}
|
|
return `${message}\n`;
|
|
}
|
|
|
|
export function withMenuOptionsSpacing<T extends { message: string }>(options: T): T {
|
|
return { ...options, message: withMenuOptionSpacing(options.message) };
|
|
}
|
|
|
|
export function withMultiselectNavigation(message: string): string {
|
|
if (message.includes(FLAT_MULTISELECT_NAVIGATION_HINT)) {
|
|
return message;
|
|
}
|
|
return `${message}\n${FLAT_MULTISELECT_NAVIGATION_HINT}`;
|
|
}
|
|
|
|
export function withSearchableMultiselectNavigation(message: string): string {
|
|
if (message.includes(SEARCHABLE_MULTISELECT_NAVIGATION_HINT)) {
|
|
return message;
|
|
}
|
|
return `${message}\n${SEARCHABLE_MULTISELECT_NAVIGATION_HINT}`;
|
|
}
|
|
|
|
export function withTextInputNavigation(message: string): string {
|
|
const messageWithoutHint = removeTrailingBlankLines(message)
|
|
.split('\n')
|
|
.filter((line) => !line.includes(TEXT_INPUT_NAVIGATION_HINT))
|
|
.map((line) => line.replace(/^│\s*/, ''))
|
|
.join('\n');
|
|
const full = `${withTextInputBodySpacing(messageWithoutHint)}\n${TEXT_INPUT_NAVIGATION_HINT}`;
|
|
return `${prefixContinuationLines(full)}\n│`;
|
|
}
|