Repository navigation
fix: use .kilo instead of .kilocode for config directories - #6881
Conversation
Only rename project-level .kilocode/ to .kilo/. The global ~/.kilocode directory must stay because legacy CLI instances and legacy-migration.ts in kilo-gateway still read from it.
Code Review SummaryStatus: 1 Issues Found | Recommendation: Address before merge Overview
Fix these issues in Kilo Cloud Issue Details (click to expand)WARNING
Other Observations (not in diff)No additional issues found outside the diff. Files Reviewed (26 files)
|
- Fix comment referencing ~/.kilo when globalDir() returns ~/.kilocode - Revert to specific .kilo/ git exclude entries instead of blanket .kilo/ to avoid hiding user-authored rules/workflows/config from git status
- readMetadata() falls back to .kilocode/ inside worktrees since the per-worktree metadata dirs aren't renamed by the top-level migration - Rewrite stale .kilocode/ paths in agent-manager.json on load
…Manager Move migration call to the top of activate() so it runs for all users on every extension startup, before kilo serve is spawned or any code reads from the .kilo directory.
After renaming the directory, git's internal .git/worktrees/*/gitdir files still reference the old .kilocode path. This causes git to lose track of worktrees, leading to crashes. Both the CLI and extension migration now rewrite these gitdir files after a successful rename.
|
We probably want to postpone this after GA, closing |
Replace the one-time directory rename migration with a dual-read strategy: - CLI config (rules, workflows, skills, MCP, project-id): read from both .kilo/ and .kilocode/ directories, with .kilo taking precedence - Agent Manager data (worktrees, state, setup scripts): migrate from .kilocode/ to .kilo/ at startup since the extension exclusively owns these - Config discovery (paths.ts, config.ts): include .kilocode in directory and agent/command pattern matching Key decisions: - .kilo/ is the new canonical write location for all new data - .kilocode/ is read as a legacy fallback (no data loss for existing users) - No directory rename: both dirs can coexist safely - Agent Manager migration is item-level (moves individual files), not a full directory rename, so it handles both-dirs-exist gracefully - Windows path rewrite in WorktreeStateManager handles both / and \ separators - Workflow/MCP load order: .kilocode first, .kilo second (last wins) - Rules dedup via seen-set with .kilo checked first (first wins) - Delete migrate-kilo-dir.ts (no longer needed)
When the project root is itself a worktree, .git is a file pointing at the shared git dir, not a directory. Follow the gitdir pointer to find the actual .git/worktrees/ location.
Always repair stale git worktree refs when .kilo worktrees already exist so partially migrated repos recover on startup. Also dual-read global skills, rules, and workflows from both legacy and new home directories.
markijbema
left a comment
There was a problem hiding this comment.
Few comments,otherwise good to go
| for (const [id, wt] of Object.entries(data.worktrees ?? {})) { | ||
| this.worktrees.set(id, { id, ...wt }) | ||
| // Rewrite stale .kilocode/ paths (handles both Unix / and Windows \ separators) | ||
| const fixed = wt.path?.replace(/[/\\]\.kilocode[/\\]/g, `${path.sep}.kilo${path.sep}`) ?? wt.path |
There was a problem hiding this comment.
WARNING: Relative legacy worktree paths are left stale
This replacement only matches .kilocode when it has a leading slash or backslash. A persisted relative entry like .kilocode/worktrees/foo will survive unchanged, and validate() later resolves it against root, so the migrated state still points at the old location and the worktree gets dropped as missing.
| const skillsDir = path.join(dir, "skills") | ||
| if (await Filesystem.isDir(skillsDir)) { | ||
| directories.push(dir) // Return parent (.kilocode/), not skills/ | ||
| for (const target of [".kilocode", ".kilo"] as const) { |
There was a problem hiding this comment.
SUGGESTION: This makes .kilo skills load twice
Skill.state() already scans project .kilo directories through Config.directories(). Returning .kilo from this helper means the same skills/**/SKILL.md files are parsed a second time, which produces false duplicate skill name warnings and an extra disk walk for every project that already uses .kilo/skills.
| allServers.push({ name, server }) // Later entries win in deduplication | ||
| for (const dir of [".kilocode", ".kilo"]) { | ||
| const projectSettingsPath = path.join(options.projectDir, dir, "mcp.json") | ||
| const projectSettings = await readMcpSettings(projectSettingsPath) |
There was a problem hiding this comment.
WARNING: Malformed legacy MCP config blocks .kilo fallback
If .kilocode/mcp.json contains invalid JSON, readMcpSettings() throws here and aborts the entire loop before .kilo/mcp.json is read. In mixed-state repos, that means a stale broken legacy file makes the new-path MCP config disappear completely instead of falling back to the valid .kilo copy. Catch parse errors per directory and continue to the next location.
readMcpSettings() called JSON.parse() without try/catch. In migrate(),
if .kilocode/mcp.json existed but contained malformed JSON, the uncaught
exception propagated out of the dual-read loop, preventing .kilo/mcp.json
from ever being read. The outer loadMcpConfig() catch returned {} instead
of the valid config — silently losing MCP server configuration.
Wrap the file read + parse in try/catch, log a warning, and return null
so the loop continues to the next config directory.
Regression tests added for both readMcpSettings (unit) and migrate
(integration) to prove the bug and verify the fix.
Refs: Kilo-Org#6881
…#7012) readMcpSettings() called JSON.parse() without try/catch. In migrate(), if .kilocode/mcp.json existed but contained malformed JSON, the uncaught exception propagated out of the dual-read loop, preventing .kilo/mcp.json from ever being read. The outer loadMcpConfig() catch returned {} instead of the valid config — silently losing MCP server configuration. Wrap the file read + parse in try/catch, log a warning, and return null so the loop continues to the next config directory. Regression tests added for both readMcpSettings (unit) and migrate (integration) to prove the bug and verify the fix. Refs: #6881 Co-authored-by: marius-kiloclaw <[email protected]>
…6881) * fix: use .kilo instead of .kilocode for config directories * fix: keep global ~/.kilocode untouched for legacy CLI compat Only rename project-level .kilocode/ to .kilo/. The global ~/.kilocode directory must stay because legacy CLI instances and legacy-migration.ts in kilo-gateway still read from it. * test: update VS Code extension tests to use .kilo directory paths * fix: correct paths.ts comment and use specific git exclude entries - Fix comment referencing ~/.kilo when globalDir() returns ~/.kilocode - Revert to specific .kilo/ git exclude entries instead of blanket .kilo/ to avoid hiding user-authored rules/workflows/config from git status * fix: handle legacy per-worktree metadata and stale paths in state - readMetadata() falls back to .kilocode/ inside worktrees since the per-worktree metadata dirs aren't renamed by the top-level migration - Rewrite stale .kilocode/ paths in agent-manager.json on load * fix: run .kilocode migration at extension activation, not just Agent Manager Move migration call to the top of activate() so it runs for all users on every extension startup, before kilo serve is spawned or any code reads from the .kilo directory. * fix: update git worktree refs after .kilocode → .kilo rename After renaming the directory, git's internal .git/worktrees/*/gitdir files still reference the old .kilocode path. This causes git to lose track of worktrees, leading to crashes. Both the CLI and extension migration now rewrite these gitdir files after a successful rename. * fix: read from both .kilo and .kilocode, write to .kilo Replace the one-time directory rename migration with a dual-read strategy: - CLI config (rules, workflows, skills, MCP, project-id): read from both .kilo/ and .kilocode/ directories, with .kilo taking precedence - Agent Manager data (worktrees, state, setup scripts): migrate from .kilocode/ to .kilo/ at startup since the extension exclusively owns these - Config discovery (paths.ts, config.ts): include .kilocode in directory and agent/command pattern matching Key decisions: - .kilo/ is the new canonical write location for all new data - .kilocode/ is read as a legacy fallback (no data loss for existing users) - No directory rename: both dirs can coexist safely - Agent Manager migration is item-level (moves individual files), not a full directory rename, so it handles both-dirs-exist gracefully - Windows path rewrite in WorktreeStateManager handles both / and \ separators - Workflow/MCP load order: .kilocode first, .kilo second (last wins) - Rules dedup via seen-set with .kilo checked first (first wins) - Delete migrate-kilo-dir.ts (no longer needed) * fix: resolve .git file when fixing worktree refs during migration When the project root is itself a worktree, .git is a file pointing at the shared git dir, not a directory. Follow the gitdir pointer to find the actual .git/worktrees/ location. * fix: recover partial .kilo migrations and global dirs Always repair stale git worktree refs when .kilo worktrees already exist so partially migrated repos recover on startup. Also dual-read global skills, rules, and workflows from both legacy and new home directories. * fix: keep .kilo ahead of legacy config dirs * fix: narrow legacy agent manager excludes * chore: link migration cleanup follow-up
…Kilo-Org#7012) readMcpSettings() called JSON.parse() without try/catch. In migrate(), if .kilocode/mcp.json existed but contained malformed JSON, the uncaught exception propagated out of the dual-read loop, preventing .kilo/mcp.json from ever being read. The outer loadMcpConfig() catch returned {} instead of the valid config — silently losing MCP server configuration. Wrap the file read + parse in try/catch, log a warning, and return null so the loop continues to the next config directory. Regression tests added for both readMcpSettings (unit) and migrate (integration) to prove the bug and verify the fix. Refs: Kilo-Org#6881
…6881) * fix: use .kilo instead of .kilocode for config directories * fix: keep global ~/.kilocode untouched for legacy CLI compat Only rename project-level .kilocode/ to .kilo/. The global ~/.kilocode directory must stay because legacy CLI instances and legacy-migration.ts in kilo-gateway still read from it. * test: update VS Code extension tests to use .kilo directory paths * fix: correct paths.ts comment and use specific git exclude entries - Fix comment referencing ~/.kilo when globalDir() returns ~/.kilocode - Revert to specific .kilo/ git exclude entries instead of blanket .kilo/ to avoid hiding user-authored rules/workflows/config from git status * fix: handle legacy per-worktree metadata and stale paths in state - readMetadata() falls back to .kilocode/ inside worktrees since the per-worktree metadata dirs aren't renamed by the top-level migration - Rewrite stale .kilocode/ paths in agent-manager.json on load * fix: run .kilocode migration at extension activation, not just Agent Manager Move migration call to the top of activate() so it runs for all users on every extension startup, before kilo serve is spawned or any code reads from the .kilo directory. * fix: update git worktree refs after .kilocode → .kilo rename After renaming the directory, git's internal .git/worktrees/*/gitdir files still reference the old .kilocode path. This causes git to lose track of worktrees, leading to crashes. Both the CLI and extension migration now rewrite these gitdir files after a successful rename. * fix: read from both .kilo and .kilocode, write to .kilo Replace the one-time directory rename migration with a dual-read strategy: - CLI config (rules, workflows, skills, MCP, project-id): read from both .kilo/ and .kilocode/ directories, with .kilo taking precedence - Agent Manager data (worktrees, state, setup scripts): migrate from .kilocode/ to .kilo/ at startup since the extension exclusively owns these - Config discovery (paths.ts, config.ts): include .kilocode in directory and agent/command pattern matching Key decisions: - .kilo/ is the new canonical write location for all new data - .kilocode/ is read as a legacy fallback (no data loss for existing users) - No directory rename: both dirs can coexist safely - Agent Manager migration is item-level (moves individual files), not a full directory rename, so it handles both-dirs-exist gracefully - Windows path rewrite in WorktreeStateManager handles both / and \ separators - Workflow/MCP load order: .kilocode first, .kilo second (last wins) - Rules dedup via seen-set with .kilo checked first (first wins) - Delete migrate-kilo-dir.ts (no longer needed) * fix: resolve .git file when fixing worktree refs during migration When the project root is itself a worktree, .git is a file pointing at the shared git dir, not a directory. Follow the gitdir pointer to find the actual .git/worktrees/ location. * fix: recover partial .kilo migrations and global dirs Always repair stale git worktree refs when .kilo worktrees already exist so partially migrated repos recover on startup. Also dual-read global skills, rules, and workflows from both legacy and new home directories. * fix: keep .kilo ahead of legacy config dirs * fix: narrow legacy agent manager excludes * chore: link migration cleanup follow-up
…Kilo-Org#7012) readMcpSettings() called JSON.parse() without try/catch. In migrate(), if .kilocode/mcp.json existed but contained malformed JSON, the uncaught exception propagated out of the dual-read loop, preventing .kilo/mcp.json from ever being read. The outer loadMcpConfig() catch returned {} instead of the valid config — silently losing MCP server configuration. Wrap the file read + parse in try/catch, log a warning, and return null so the loop continues to the next config directory. Regression tests added for both readMcpSettings (unit) and migrate (integration) to prove the bug and verify the fix. Refs: Kilo-Org#6881 Co-authored-by: marius-kiloclaw <[email protected]>
Summary
Closes #6874
Updates
.kilocodedirectory handling to.kiloacross the CLI and VS Code extension using two strategies depending on ownership.Strategy 1: Agent Manager data -> migrate at startup
Files exclusively owned by Agent Manager (
agent-manager.json,worktrees/,setup-script*) are moved from.kilocode/to.kilo/at startup viamigrateAgentManagerData()inpackages/kilo-vscode/src/agent-manager/constants.ts.WorktreeStateManager.load()andWorktreeManager.ensureMigrated().kilo/(no overwrite).git/worktrees/{name}/gitdir) whenever.kilo/worktrees/exists, so partially migrated repos recover too.gitdirectory) and worktree roots (.gitfile).kilocode/paths inagent-manager.jsonworktree entries (Unix and Windows separators).kilo/onlyreadMetadata) still checks both.kilo/and.kilocode/since those internal dirs are not movedStrategy 2: CLI config data -> dual-read
Multiple CLI consumers read config data, so there is no single safe migration point. Instead, each component reads from both
.kilo/and.kilocode/, with.kilo/taking precedence.paths.ts(skills).kilo/and.kilocode/project-id.ts.kilo/config.jsonfirst, fall back to.kilocode/config.jsonmcp-migrator.ts.kilocode/mcp.jsonthen.kilo/mcp.json(later wins)rules-migrator.ts.kilo/winsworkflows-migrator.ts.kilocode/first and.kilo/second (later wins)config/paths.ts.kilo,.kilocode,.opencodedirectoriesconfig/config.ts.kilocode/dirs tooNew writes go to
.kilo/. Existing.kilocode/content continues to work without manual migration.What didn't change (separate concerns)
.kilocodeignore,.kilocoderules,.kilocodemodes(standalone dotfiles, not directories)kilocode.kilo-code(VS Code extension publisher ID)kilocodeToken,kilocodeOrganizationId(API property names)legacy-migration.tsin kilo-gateway (explicit legacy auth migration)