Fix Kaimon detection on Windows: _kaimon_dir() now matches kaimon_config_dir() #1

Merged
mthelm85 merged 1 commit from fix-kaimon-dir-windows into main 2026-07-15 18:35:34 -07:00
mthelm85 commented 2026-07-15 09:45:36 -07:00 (Migrated from github.com)

Fix Kaimon detection on Windows: _kaimon_dir() now matches kaimon_config_dir()

Problem

On Windows, KaimonSlate never detects an installed Kaimon, so the slate app's first-run registration prompt never appears and KaimonSlate.register_extension() silently returns false.

The cause is a platform mismatch between the two packages. Kaimon resolves its config dir per-platform (kaimon_config_dir()):

dir = if Sys.iswindows()
    joinpath(get(ENV, "APPDATA", joinpath(homedir(), "AppData", "Roaming")), "Kaimon")
else
    joinpath(get(ENV, "XDG_CONFIG_HOME", joinpath(homedir(), ".config")), "kaimon")
end

…but KaimonSlate's _kaimon_dir() only implements the non-Windows branch:

_kaimon_dir() = joinpath(get(ENV, "XDG_CONFIG_HOME", joinpath(homedir(), ".config")), "kaimon")

Since extension detection is simply "Kaimon's config dir exists", a Windows user with a fully working Kaimon (config in %APPDATA%\Kaimon) looks like "Kaimon not installed" to KaimonSlate. Slate then falls back to owning its own hub — no slate.* tools, no agent.

Fix

_kaimon_dir() now mirrors Kaimon's resolution order, with one deliberate difference: an explicit XDG_CONFIG_HOME takes precedence on every platform. This preserves isolated-config launches and the test suite's isolation strategy (test_app.jl sandboxes both config surfaces via XDG_CONFIG_HOME), which would otherwise write into the real %APPDATA%\Kaimon when run on Windows.

function _kaimon_dir()
    xdg = get(ENV, "XDG_CONFIG_HOME", "")
    isempty(xdg) || return joinpath(xdg, "kaimon")
    Sys.iswindows() &&
        return joinpath(get(ENV, "APPDATA", joinpath(homedir(), "AppData", "Roaming")), "Kaimon")
    return joinpath(homedir(), ".config", "kaimon")
end

Also updates the register_extension docstring, which hard-coded ~/.config/kaimon/extensions.json.

Testing

  • Added a _kaimon_dir platform resolution testset to test/test_app.jl covering the XDG_CONFIG_HOME override and the per-platform defaults (asserts the %APPDATA%\Kaimon path on Windows, ~/.config/kaimon elsewhere).
  • Reproduced on Windows / Julia 1.12 with a working Kaimon install: register_extension(force=true) returns false, no extensions.json is written, and the slate app never shows the registration prompt.
# Fix Kaimon detection on Windows: `_kaimon_dir()` now matches `kaimon_config_dir()` ## Problem On Windows, KaimonSlate never detects an installed Kaimon, so the `slate` app's first-run registration prompt never appears and `KaimonSlate.register_extension()` silently returns `false`. The cause is a platform mismatch between the two packages. Kaimon resolves its config dir per-platform ([`kaimon_config_dir()`](https://github.com/kahliburke/Kaimon.jl/blob/main/src/Kaimon.jl#L87)): ```julia dir = if Sys.iswindows() joinpath(get(ENV, "APPDATA", joinpath(homedir(), "AppData", "Roaming")), "Kaimon") else joinpath(get(ENV, "XDG_CONFIG_HOME", joinpath(homedir(), ".config")), "kaimon") end ``` …but KaimonSlate's `_kaimon_dir()` only implements the non-Windows branch: ```julia _kaimon_dir() = joinpath(get(ENV, "XDG_CONFIG_HOME", joinpath(homedir(), ".config")), "kaimon") ``` Since extension detection is simply "Kaimon's config dir exists", a Windows user with a fully working Kaimon (config in `%APPDATA%\Kaimon`) looks like "Kaimon not installed" to KaimonSlate. Slate then falls back to owning its own hub — no `slate.*` tools, no agent. ## Fix `_kaimon_dir()` now mirrors Kaimon's resolution order, with one deliberate difference: an explicit `XDG_CONFIG_HOME` takes precedence **on every platform**. This preserves isolated-config launches and the test suite's isolation strategy (`test_app.jl` sandboxes both config surfaces via `XDG_CONFIG_HOME`), which would otherwise write into the real `%APPDATA%\Kaimon` when run on Windows. ```julia function _kaimon_dir() xdg = get(ENV, "XDG_CONFIG_HOME", "") isempty(xdg) || return joinpath(xdg, "kaimon") Sys.iswindows() && return joinpath(get(ENV, "APPDATA", joinpath(homedir(), "AppData", "Roaming")), "Kaimon") return joinpath(homedir(), ".config", "kaimon") end ``` Also updates the `register_extension` docstring, which hard-coded `~/.config/kaimon/extensions.json`. ## Testing - Added a `_kaimon_dir platform resolution` testset to `test/test_app.jl` covering the `XDG_CONFIG_HOME` override and the per-platform defaults (asserts the `%APPDATA%\Kaimon` path on Windows, `~/.config/kaimon` elsewhere). - Reproduced on Windows / Julia 1.12 with a working Kaimon install: `register_extension(force=true)` returns `false`, no `extensions.json` is written, and the `slate` app never shows the registration prompt.
Sign in to join this conversation.
No description provided.