MoonshotAI / MoonshotAI/kimi-code
Re-root session working directory when entering a git worktree
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 7.5k
- Forks
- 1.2k
- Avg merge
- 11h 53m
- Merged PRs (30d)
- 350
Description
Problem
When a session started in the main checkout creates a git worktree and implements changes there, the session's working directory stays pinned to the original project root. The displayed path still shows the main checkout, and every tool call (file edits, builds, tests, git commands) must explicitly target the worktree path via absolute paths or cwd overrides.
This is workable, but error-prone:
- It's easy to accidentally build/test/edit against the main checkout instead of the worktree.
- The UI gives no hint about which tree the session is currently aligned to.
- Subagents and background tasks inherit the session root, so worktree work always requires manual path plumbing.
Claude Code solves this with a worktree mechanism (EnterWorktree): entering or creating a worktree migrates the session cwd, so the displayed path and all subsequent tool calls follow the worktree.
Proposal
Add a first-class way to re-root a session into a worktree, for example:
- A
/worktreecommand (create or enter) that switches the session cwd and the displayed path to the worktree root, or - Auto-detection: when the agent creates/enters a worktree for implementation, offer to re-root the session.
Subagents and background tasks spawned after re-rooting should default to the worktree cwd.
Environment
- Kimi Code CLI on Windows (Git Bash shell)
- Repository using a
.worktrees/directory for feature worktrees
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing how the Kimi Code CLI stores and displays the session working directory, then inspect how worktrees, tool calls, subagents, and background tasks receive their cwd. Define whether /worktree or auto-detection is the intended entry point, and verify that re-rooting updates the displayed path and subsequent task defaults without affecting the main checkout.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- cli, developer-experience
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100