fix(cli): remove legacy ingest and wiki commands

This commit is contained in:
Andrey Avtomonov 2026-05-13 22:42:07 +02:00
parent 011d694ed3
commit 75e04cfa56
41 changed files with 328 additions and 851 deletions

View file

@ -228,7 +228,7 @@ export async function localPullConfigForAdapter(
): Promise<unknown> {
if (adapter.source === 'metabase') {
throw new Error(
'Metabase scheduled pulls fan out by mapping. Call runLocalMetabaseIngest() or use `ktx ingest run --adapter metabase --connection-id <metabase-source-id>` from the CLI.',
'Metabase scheduled pulls fan out by mapping. Call runLocalMetabaseIngest() or use `ktx ingest <metabase-source-id>` from the CLI.',
);
}
const connection = project.config.connections[connectionId];

View file

@ -56,7 +56,7 @@ describe('createLocalBundleIngestRuntime', () => {
}),
).toThrow(
[
'ktx ingest run requires llm.provider.backend: anthropic, vertex, or gateway, or an injected agentRunner.',
'ktx ingest requires llm.provider.backend: anthropic, vertex, or gateway, or an injected agentRunner.',
`Configure an Anthropic provider, then rerun ingest:`,
` ktx setup --project-dir ${project.projectDir} --anthropic-api-key-env ANTHROPIC_API_KEY --anthropic-model claude-sonnet-4-6 --no-input`,
].join('\n'),

View file

@ -571,7 +571,7 @@ function nextLocalJobId(): string {
function localIngestLlmProviderGuardMessage(projectDir: string): string {
return [
'ktx ingest run requires llm.provider.backend: anthropic, vertex, or gateway, or an injected agentRunner.',
'ktx ingest requires llm.provider.backend: anthropic, vertex, or gateway, or an injected agentRunner.',
'Configure an Anthropic provider, then rerun ingest:',
` ktx setup --project-dir ${projectDir} --anthropic-api-key-env ANTHROPIC_API_KEY --anthropic-model claude-sonnet-4-6 --no-input`,
].join('\n');

View file

@ -10,7 +10,7 @@ connections:
${connectionId}:
driver: postgres
`),
).toThrow(`"${connectionId}" is reserved for ktx ingest ${connectionId}`);
).toThrow(`"${connectionId}" is reserved for the KTX ingest command namespace`);
});
it('builds the default standalone project config', () => {

View file

@ -113,10 +113,10 @@ function isRecord(value: unknown): value is Record<string, unknown> {
}
const RESERVED_INGEST_CONNECTION_IDS = new Map([
['status', 'ktx ingest status'],
['replay', 'ktx ingest replay'],
['run', 'ktx ingest run'],
['watch', 'ktx ingest watch'],
['status', 'the KTX ingest command namespace'],
['replay', 'the KTX ingest command namespace'],
['run', 'the KTX ingest command namespace'],
['watch', 'the KTX ingest command namespace'],
]);
export function reservedKtxIngestConnectionIdMessage(connectionId: string): string | null {

View file

@ -120,6 +120,22 @@ async function writeLiveDatabaseConfig(projectDir: string): Promise<void> {
);
}
async function writeDatabaseConfigWithoutIngestAdapters(projectDir: string): Promise<void> {
await writeFile(
join(projectDir, 'ktx.yaml'),
[
'project: warehouse',
'connections:',
' warehouse:',
' driver: postgres',
' url: env:DATABASE_URL',
' readonly: true',
'',
].join('\n'),
'utf-8',
);
}
function fetchOnlyAdapter(options: { extractedAt?: () => string } = {}): SourceAdapter {
return {
source: 'live-database',
@ -244,6 +260,27 @@ describe('local scan', () => {
});
});
it('runs a structural database scan when live-database is not listed in ktx.yaml', async () => {
await writeDatabaseConfigWithoutIngestAdapters(project.projectDir);
project = await loadKtxProject({ projectDir: project.projectDir });
const result = await runLocalScan({
project,
adapters: [fetchOnlyAdapter()],
connectionId: 'warehouse',
jobId: 'scan-run-without-public-adapter',
now: () => new Date('2026-04-29T09:10:00.000Z'),
});
expect(result.report).toMatchObject({
connectionId: 'warehouse',
runId: 'scan-run-without-public-adapter',
artifactPaths: {
reportPath: 'raw-sources/warehouse/live-database/2026-04-29-091000-scan-run-without-public-adapter/scan-report.json',
},
});
});
it('reuses scan report and raw-source paths when the same local scan run id is retried', async () => {
const first = await runLocalScan({
project,

View file

@ -342,6 +342,22 @@ function createFilteredConnector(connector: KtxScanConnector, enabledTables: Set
};
}
function withInternalLiveDatabaseAdapter(project: KtxLocalProject): KtxLocalProject {
if (project.config.ingest.adapters.includes(LIVE_DATABASE_ADAPTER)) {
return project;
}
return {
...project,
config: {
...project.config,
ingest: {
...project.config.ingest,
adapters: [...project.config.ingest.adapters, LIVE_DATABASE_ADAPTER],
},
},
};
}
export async function runLocalScan(options: RunLocalScanOptions): Promise<LocalScanRunResult> {
const mode = options.mode ?? 'structural';
assertSupportedMode(mode);
@ -367,7 +383,7 @@ export async function runLocalScan(options: RunLocalScanOptions): Promise<LocalS
await options.progress?.update(0.15, 'Inspecting database schema');
const record = await runLocalStageOnlyIngest({
project: options.project,
project: withInternalLiveDatabaseAdapter(options.project),
adapters,
adapter: LIVE_DATABASE_ADAPTER,
connectionId: options.connectionId,