ktx/packages/cli/test/context
Andrey Avtomonov 2877b85adc
fix(cli): isolate ktx-owned project repositories (#283)
* fix(cli): isolate ktx project git repos

* fix(cli): remove inert auto commit config

* test(cli): drop stale auto commit fixtures

* docs: document isolated ktx project repos

* test(cli): keep stale config grep clean

* fix(cli): guide setup away from foreign repos at the project dir

ktx owns the git repo rooted at the project dir and refuses to adopt one it
did not create (the Finding 3 isolation invariant). But setup steered users
straight into that failure: the interactive menu offers "Current directory"
first, and `--no-input --yes --project-dir <repo-root>` created directly in
place — both then threw a generic "Failed to initialize git repository:"
wrapper from deep in GitService.initialize().

Extract the ownership rule into a shared `classifyKtxRepoOwnership(dir)` used by
both GitService.initialize() (the invariant) and the setup wizard (pre-flight
guidance), so the decision derives from one rule. Setup now detects a foreign
repo before constructing GitService and: interactively re-prompts (the user
picks the existing `ktx-project` subfolder), or non-interactively returns a
clean missing-input with the actionable message. The typed foreign-repo error
is also surfaced verbatim instead of being buried under the generic wrapper.

Empty/non-repo current directories still work — only foreign repos are blocked.

* fix(cli): keep classifyKtxRepoOwnership total for non-directory paths

The setup ownership guard runs before the existing not-a-directory check, so
pointing a custom/--project-dir path at a file made classifyKtxRepoOwnership
lstat `<file>/.git`, hit ENOTDIR, and throw — crashing the setup step instead
of returning the friendly "path exists and is not a directory" result.

A path that is a file (or missing) holds no git repo for ktx to avoid, so treat
ENOTDIR like ENOENT and return 'unowned'. The downstream existingFolderState
check still rejects a non-directory with its friendly message, and the
classifier no longer throws raw errno for any caller.
2026-06-10 14:12:25 +02:00
..
connections fix: read semantic sources safely (#284) 2026-06-10 14:06:13 +02:00
core fix(cli): isolate ktx-owned project repositories (#283) 2026-06-10 14:12:25 +02:00
daemon test: split cli tests from source tree (#216) 2026-05-26 08:49:05 +02:00
index-sync fix: read semantic sources safely (#284) 2026-06-10 14:06:13 +02:00
ingest fix(cli): isolate ktx-owned project repositories (#283) 2026-06-10 14:12:25 +02:00
llm fix(ingest): drive work-unit progress from tool calls, not turn counts (#269) 2026-06-08 15:30:35 +02:00
mcp fix: read semantic sources safely (#284) 2026-06-10 14:06:13 +02:00
memory fix: read semantic sources safely (#284) 2026-06-10 14:06:13 +02:00
project fix(cli): isolate ktx-owned project repositories (#283) 2026-06-10 14:12:25 +02:00
prompts test: split cli tests from source tree (#216) 2026-05-26 08:49:05 +02:00
scan test: split cli tests from source tree (#216) 2026-05-26 08:49:05 +02:00
search fix: read semantic sources safely (#284) 2026-06-10 14:06:13 +02:00
skills test: split cli tests from source tree (#216) 2026-05-26 08:49:05 +02:00
sl fix: read semantic sources safely (#284) 2026-06-10 14:06:13 +02:00
sql-analysis fix: read semantic sources safely (#284) 2026-06-10 14:06:13 +02:00
test test: split cli tests from source tree (#216) 2026-05-26 08:49:05 +02:00
tools test: split cli tests from source tree (#216) 2026-05-26 08:49:05 +02:00
wiki feat(cli): shell completion for commands, flags, and entity names (#244) 2026-05-31 23:44:33 +02:00