MoonshotAI / MoonshotAI/kimi-code
Workspace trust is not inherited by subdirectories, forcing a trust prompt for every dynamic worktree
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 7.5k
- Forks
- 1.2k
- Avg merge
- 11h 53m
- Merged PRs (30d)
- 350
Description
When a parent directory is already trusted, launching Kimi Code interactively in any subfolder still shows the "Trust this folder?" prompt. This makes it impossible to use dynamically created worktrees (e.g., test/build sandboxes, git worktree farms, or CI-style per-run directories) without manually trusting each one.
Expected behavior:
One of the following:
- Trusting a directory implicitly trusts its subdirectories, matching the behavior of comparable tools (VS Code Workspace Trust, Claude Code, Codex), or
- There is a supported config or setting to declare trusted root paths or glob patterns (e.g.,
/home/user/.treehouse/**).
Actual behavior:
Each exact working directory needs its own marker file under ~/.kimi-code/workspace-trust/. Trusting /home/user/.treehouse does not prevent the prompt when launching in /home/user/.treehouse/project-123/workspace.
Steps to reproduce:
- Start Kimi Code interactively in a directory and choose Trust this folder.
- Create a subdirectory, e.g.
mkdir -p /home/user/.treehouse/test/workspace. - Launch
kimiinteractively in that subdirectory. - The "Trust this folder?" prompt appears again.
Impact:
Any workflow that spins up Kimi Code agents in temporary or dynamically-named subfolders of a trusted root is blocked unless the launcher manually writes a trust marker file for every path before starting the TUI.
Root cause (from source):
WorkspaceTrustService stores and checks trust only for the exact workspace.cwd:
// packages/agent-core-v2/src/workspace/workspaceTrust/workspaceTrustService.ts
this.root = workspace.cwd;
this.storeKey = encodeWorkDirKey(workspace.cwd);
// ...
this.trusted = (await this.docs.get(TRUST_SCOPE, this.storeKey)) !== undefined;
The startup gate in apps/kimi-code/src/tui/kimi-tui.ts checks getWorkspaceTrustInfo(workDir) for the exact path and shows the prompt if it is not trusted. There is no parent-directory traversal or pattern list.
Suggested fix:
Either:
- Walk up the directory tree when checking trust and treat the workspace as trusted if any parent is trusted, or
- Add a configuration option (e.g., in
config.tomlortui.toml) to declare trusted root paths or glob patterns such as/home/user/.treehouse/**.
Either approach preserves the security intent while fixing the dynamic-worktree case.
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 with packages/agent-core-v2/src/workspace/workspaceTrust/workspaceTrustService.ts and apps/kimi-code/src/tui/kimi-tui.ts, following how the exact workspace.cwd and storeKey are checked. Decide which supported approach fits the security intent: parent-directory trust or configured trusted roots/patterns. Done means a trusted root prevents prompts for its subdirectories, or the supported configuration does so for matching dynamic worktrees.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- cli, security
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100