MoonshotAI / MoonshotAI/kimi-code

Workspace trust is not inherited by subdirectories, forcing a trust prompt for every dynamic worktree

Open
#2,976 0 comments 0 reactions 0 assignees View on GitHub

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:

  1. Trusting a directory implicitly trusts its subdirectories, matching the behavior of comparable tools (VS Code Workspace Trust, Claude Code, Codex), or
  2. 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:

  1. Start Kimi Code interactively in a directory and choose Trust this folder.
  2. Create a subdirectory, e.g. mkdir -p /home/user/.treehouse/test/workspace.
  3. Launch kimi interactively in that subdirectory.
  4. 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.toml or tui.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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.