Skip to content

fix(windows): normalize global config path construction#7834

Open
sainzs wants to merge 1 commit intoKilo-Org:mainfrom
sainzs:fix/windows-xdg-config-paths
Open

fix(windows): normalize global config path construction#7834
sainzs wants to merge 1 commit intoKilo-Org:mainfrom
sainzs:fix/windows-xdg-config-paths

Conversation

@sainzs
Copy link
Copy Markdown

@sainzs sainzs commented Mar 27, 2026

Context

Fixes #7789.

Windows users reported global config paths missing the separator before .config, for example C:\Users\user1.config\kilo\.... The repo also had home-pattern expansion in permissions implemented with string concatenation, which can produce incorrect mixed-separator paths on Windows.

Implementation

Added a small pure path helper in packages/opencode/src/global/paths.ts and used it to:

  • build global Kilo paths explicitly instead of relying on eager xdg-basedir values in packages/opencode/src/global/index.ts
  • expand ~/... and $HOME/... paths with path.join(...) in packages/opencode/src/permission/next.ts
  • normalize VS Code marketplace global config roots in packages/kilo-vscode/src/services/marketplace/paths.ts

Also added Windows-path tests using path.win32 so the behavior is validated without requiring a Windows runner.

Screenshots

before after
Windows config path could collapse the separator before .config Windows path helpers produce C:\Users\user1\.config\kilo in tests

How to Test

  1. Run bun test --cwd packages/opencode test/global/paths.test.ts.
  2. Confirm the test asserts C:\Users\user1\.config\kilo.
  3. Confirm ~/agent/rules.md and $HOME/agent/rules.md expand with Windows separators under path.win32.

Get in Touch

Discord: add your handle here if you want maintainer follow-up there.

@sainzs
Copy link
Copy Markdown
Author

sainzs commented Mar 27, 2026

Verification completed locally:

  • bun test --cwd packages/opencode test/global/paths.test.ts
  • bunx prettier --check packages/opencode/src/global/index.ts packages/opencode/src/global/paths.ts packages/opencode/src/permission/next.ts packages/opencode/test/global/paths.test.ts packages/kilo-vscode/src/services/marketplace/paths.ts

Notes:

  • Repo-wide bun turbo typecheck is not a clean signal on the fork-base branch because the fork is behind upstream main; the hook fails on missing upstream alias modules unrelated to this fix.
  • The actual fix was authored and verified against local origin/main, then pushed via the fork base only because the current GitHub token cannot update workflow-bearing refs on the fork without additional workflow scope.

import { Log } from "@/util/log"
import { Wildcard } from "@/util/wildcard"
import os from "os"
import { drainCovered } from "@/kilocode/permission/drain" // kilocode_change
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CRITICAL: New imports target files that do not exist

Both @/kilocode/permission/drain and @/kilocode/permission/config-paths are imported here, but there is no packages/opencode/src/kilocode/permission/ directory in this branch. permission/next.ts will fail module resolution as soon as it is typechecked.

s.approved.push(...newRules)

if (newRules.length > 0) {
await Config.updateGlobal({ permission: toConfig(newRules) }, { dispose: false })
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CRITICAL: Config.updateGlobal is called with the wrong arity

packages/opencode/src/config/config.ts:1481 defines updateGlobal(config: Info) with no overload, so this new second { dispose: false } argument produces TS2554. The identical call a few lines lower has the same problem.


export function expandHomePattern(pattern: string, home = resolveHome(), pathmod: PathModule = path) {
if (pattern === "~" || pattern === "$HOME") return home
if (pattern.startsWith("~/")) return pathmod.join(home, pattern.slice(2))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: Windows-style home patterns stop matching here

This helper only expands ~/... and $HOME/.... A Windows config written with backslashes (~\agent\rules.md or $HOME\agent\rules.md) now falls through unchanged, so the permission rule will never match the real path on Windows.

return path.join(xdg, "kilo")
}

export class MarketplacePaths {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: This fix is not wired into the extension

MarketplacePaths is only defined in this new file and is not imported anywhere under packages/kilo-vscode/src. As written, the extension never uses the normalized global config root added here, so the Windows marketplace-path bug remains unchanged.

@kilo-code-bot
Copy link
Copy Markdown
Contributor

kilo-code-bot bot commented Mar 27, 2026

Code Review Summary

Status: 2 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 2
SUGGESTION 0

Fix these issues in Kilo Cloud

Issue Details (click to expand)

WARNING

File Line Issue
packages/opencode/src/global/paths.ts 62 expandHomePattern() still ignores Windows backslash forms like ~\... and $HOME\..., so those rules never expand to real paths.
Other Observations (not in diff)

Resolved since last review:

  • packages/opencode/src/permission/next.ts:11 now imports files that exist in the current branch.
  • packages/opencode/src/permission/next.ts:255 is now valid because Config.updateGlobal() accepts the options argument in the current branch.
  • packages/kilo-vscode/src/services/marketplace/paths.ts:15 is now wired into the extension in the current branch.

Issues found outside the current PR diff that cannot receive inline comments:

File Line Issue
packages/opencode/src/kilocode/permission/config-paths.ts 53 Nested AGENTS.md paths are not treated as protected config targets, so edits to files like packages/opencode/AGENTS.md bypass the new config-edit safeguard.
Files Reviewed (6 files)
  • packages/kilo-vscode/src/services/marketplace/paths.ts - 0 issues
  • packages/opencode/src/global/index.ts - 0 issues
  • packages/opencode/src/global/paths.ts - 1 issue
  • packages/opencode/src/permission/next.ts - 0 issues
  • packages/opencode/test/global/paths.test.ts - 0 issues
  • packages/opencode/src/kilocode/permission/config-paths.ts - 1 issue

Reviewed by gpt-5.4-20260305 · 1,686,119 tokens

@sainzs sainzs force-pushed the fix/windows-xdg-config-paths branch from 8b4421a to a50a990 Compare March 27, 2026 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant