Files
Saim Shafiqueandmorluto 2ce4471c9f fix(setup): honor KIRO_HOME for the Kiro user configuration (#15056)
* fix(setup): honor KIRO_HOME for the Kiro user configuration

* fix(setup): fall back when KIRO_HOME is any filesystem root

The ancestor check compared the selected root against home with
path.relative, which returns an absolute path across drives, so a
KIRO_HOME of D:\ or a UNC share root was accepted while Kiro itself
falls back to ~/.kiro. Check the selected path against its own root
separately, and document the override in the client configuration
guide.

* test(setup): clear KIRO_HOME from lifecycle test environments

The client-location scrubber omitted KIRO_HOME, so lifecycle tests
calling supportedClients/detectClients and systemUninstallHost with
the default process.env could resolve a runner-exported KIRO_HOME
outside their temporary home and touch the real Kiro registration.

* fix(setup): resolve Kiro home aliases before selecting a profile

* refactor(setup): use the captured host platform for Kiro path checks

---------

Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
2026-11-29 22:01:03 -05:00

64 lines
1.5 KiB
TypeScript

import { vi } from "vitest";
/** Environment variables that redirect where supported clients keep config. */
const CLIENT_LOCATION_ENVIRONMENT = [
"HOME",
"USERPROFILE",
"HOMEDRIVE",
"HOMEPATH",
"APPDATA",
"CLINE_MCP_SETTINGS_PATH",
"CLINE_DATA_DIR",
"CLINE_DIR",
"CLAUDE_CONFIG_DIR",
"CODEX_HOME",
"DSH_HOME",
"DSH_AGENTS_HOME",
"COPILOT_HOME",
"FACTORY_HOME_OVERRIDE",
"FLATPAK_XDG_CONFIG_HOME",
"GROK_HOME",
"GEMINI_CLI_HOME",
"GEMINI_CLI_TRUST_WORKSPACE",
"GEMINI_RESTRICTED_MODE",
"GEMINI_CLI_TRUSTED_FOLDERS_PATH",
"GEMINI_CLI_SYSTEM_SETTINGS_PATH",
"GEMINI_CLI_SYSTEM_DEFAULTS_PATH",
"HERMES_DATA_DIR_SUFFIX",
"HERMES_HOME",
"FX_HOME",
"GOOSE_ADDITIONAL_CONFIG_FILES",
"GOOSE_PATH_ROOT",
"PROGRAMDATA",
"JUNIE_HOME",
"JUNIE_MCP_DEFAULT_LOCATIONS",
"JUNIE_CONFIG_LOCATION",
"JUNIE_CONFIG_DEFAULT_LOCATIONS",
"KILO_CONFIG",
"KILO_CONFIG_CONTENT",
"KILO_CONFIG_DIR",
"KILO_DISABLE_PROJECT_CONFIG",
"KIMI_CODE_HOME",
"KIRO_HOME",
"MCPORTER_CONFIG",
"LOCALAPPDATA",
"OMP_PROFILE",
"OPENCODE_CONFIG",
"OPENCODE_CONFIG_DIR",
"PI_CODING_AGENT_DIR",
"PI_CONFIG_DIR",
"PI_PROFILE",
"QODER_CONFIG_DIR",
"QWEN_HOME",
"SAND_DATA_ROOT",
"VSCODE_APPDATA",
"VSCODE_CWD",
"VSCODE_PORTABLE",
"XDG_CONFIG_HOME",
] as const;
/** Clear the developer's client locations so tests resolve only their temporary homes. */
export const clearClientLocationEnvironment = (): void => {
for (const name of CLIENT_LOCATION_ENVIRONMENT) vi.stubEnv(name, undefined);
};