feat(cli): migrate all setup steps to use local state for completion tracking

Update every setup step to write completed_steps to .ktx/setup/state.json
instead of ktx.yaml, stripping legacy entries from config on write.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Luca Martial 2026-05-12 16:26:23 -07:00
parent f70271152b
commit dbfee6b453
14 changed files with 105 additions and 61 deletions

View file

@ -5,6 +5,7 @@ import {
initKtxProject,
type KtxProjectConnectionConfig,
parseKtxProjectConfig,
readKtxSetupState,
serializeKtxProjectConfig,
} from '@ktx/context/project';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
@ -136,7 +137,8 @@ describe('setup sources step', () => {
projectDir,
});
expect((await readConfig()).setup?.completed_steps).toContain('sources');
expect((await readConfig()).setup?.completed_steps).toEqual(undefined);
expect((await readKtxSetupState(projectDir)).completed_steps).toContain('sources');
expect(io.stdout()).toContain('Context source setup skipped.');
});
@ -169,7 +171,8 @@ describe('setup sources step', () => {
source_dir: '/repo/dbt',
project_name: 'analytics',
});
expect(config.setup?.completed_steps).toContain('sources');
expect(config.setup?.completed_steps).toEqual([]);
expect((await readKtxSetupState(projectDir)).completed_steps).toContain('sources');
expect(runInitialIngest).toHaveBeenCalledWith(projectDir, 'analytics_dbt', io.io, { inputMode: 'disabled' });
});