Repository navigation
feat(kimi-code): summarize workspace trust with configuration sources - #4056
Conversation
🦋 Changeset detectedLatest commit: 206ce33 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f5af4442e2
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| await Promise.all([ | ||
| program.skills.ready, | ||
| program.agentProfiles.ready, | ||
| program.instructions.ready, | ||
| ]); |
There was a problem hiding this comment.
Do not block the trust prompt on full source discovery
When opening an untrusted workspace whose skill or instruction discovery is slow (for example, a large .kimi-code/skills tree or an unavailable filesystem), awaiting all three readiness promises prevents getWorkspaceTrustInfo() from resolving, so maybeRunWorkspaceTrustPrompt() cannot mount either choice. Previously this RPC only waited for MCP-config loading and the dialog could be shown while these loaders continued; keep this disclosure non-blocking or time-bounded so users can still choose “Don’t trust.”
AGENTS.md reference: AGENTS.md:L98-L100
Useful? React with 👍 / 👎.
| @@ -0,0 +1,5 @@ | |||
| --- | |||
| "@moonshot-ai/kimi-code": patch | |||
There was a problem hiding this comment.
Release the SDK contract alongside the CLI
This changes the public WorkspaceTrustInfo return shape and its getWorkspaceTrustInfo() implementation, but the only changeset bumps @moonshot-ai/kimi-code. Consequently, standalone SDK consumers will continue receiving the previously published SDK and cannot obtain these disclosure fields; add an @moonshot-ai/kimi-code-sdk changeset with the appropriate versioning/compatibility treatment.
AGENTS.md reference: AGENTS.md:L110-L112
Useful? React with 👍 / 👎.
| const localConfig = new FileProjectLocalConfigService(bootstrap, fs); | ||
| const result = await localConfig.readAdditionalDirs(workDir); | ||
| return result.additionalDirs; |
There was a problem hiding this comment.
Avoid claiming every configured directory is external
readAdditionalDirs() accepts and resolves any configured directory without excluding paths inside the project. Therefore, an untrusted repository with [workspace] additional_dir = ["."] will render this as granting access to a directory “outside this project,” even though it grants no new external access. Filter this list to actual external directories or describe it neutrally as additional directories so the trust decision is accurate.
Useful? React with 👍 / 👎.
…rnal additional dirs
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2181e342b2
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| await Promise.race([ | ||
| Promise.all([program.skills.ready, program.agentProfiles.ready, program.instructions.ready]), | ||
| new Promise((resolve) => setTimeout(resolve, INSTRUCTION_DISCOVERY_TIMEOUT_MS)), | ||
| ]); |
There was a problem hiding this comment.
Surface discovery timeouts in the trust prompt
When a project has a skill, agent-profile, or instruction scan that takes longer than two seconds (for example, a large project skill tree), this race returns the still-empty snapshots. The prompt then renders “No project-level config found,” but the same loaders continue and their project sources are applied after the user selects Trust, so the user is asked to approve a misleadingly incomplete disclosure. Preserve the non-blocking startup behavior, but expose that discovery is incomplete rather than treating it as an empty configuration.
AGENTS.md reference: AGENTS.md:L118-L120
Useful? React with 👍 / 👎.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 68b288c823
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if (server.envKeys !== undefined && server.envKeys.length > 0) { | ||
| parts.push(`env keys: ${server.envKeys.map(sanitizeForDisplay).join(', ')}`); | ||
| } | ||
| if (server.headerKeys !== undefined && server.headerKeys.length > 0) { | ||
| parts.push(`header keys: ${server.headerKeys.map(sanitizeForDisplay).join(', ')}`); | ||
| } |
There was a problem hiding this comment.
Cap untrusted MCP key lists before rendering
When an untrusted project declares a MCP server with a very large env or headers map, the schema accepts every key and the SDK preserves them all; this formatter then joins the entire list before wrapping it. The server-count cap does not constrain these fields, so a crafted .mcp.json can generate thousands of prompt rows and make the trust dialog slow or unusable before the user can select “Don't trust.” Truncate these key lists and display a remaining-count suffix.
Useful? React with 👍 / 👎.
| return Object.entries(loaded.servers) | ||
| .filter(([name]) => projectPaths.has(loaded.origins[name] ?? '')) | ||
| .map(([name, config]) => describeWorkspaceMcpServer(name, config, loaded.origins[name] ?? '')) |
There was a problem hiding this comment.
Exclude disabled MCP servers from the trust disclosure
When a project MCP entry sets enabled: false, this origin-only filter still reports it as gated, and the dialog consequently says that trusting will run it automatically. The connection manager instead creates such entries with status disabled and never connects them, so users can be discouraged from trusting a folder by an activation that cannot occur. Filter disabled entries here or surface them as disabled rather than counting them as servers that will run.
Useful? React with 👍 / 👎.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6d80922b82
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const projectPaths = new Set([paths.projectRoot, paths.project]); | ||
| return Object.entries(loaded.servers) | ||
| .filter(([name]) => projectPaths.has(loaded.origins[name] ?? '')) | ||
| .filter(([, config]) => config.enabled !== false) |
There was a problem hiding this comment.
Disclose disabled project MCP overrides
When an enabled user-level MCP server shares a name with a project entry whose enabled is false, this filter removes the project entry from the disclosure and the prompt can even state that no project config exists. Trusting nevertheless reloads the merged configuration with the project layer, and WorkspaceMcpService.apply() passes that disabled config to manager.connect(), which closes the user server and leaves it disabled. Surface this as a disabled override rather than omitting it so affected MCP users can make an informed trust decision.
AGENTS.md reference: AGENTS.md:L118-L120
Useful? React with 👍 / 👎.
| new Promise<boolean>((resolve) => | ||
| setTimeout(() => resolve(false), INSTRUCTION_DISCOVERY_TIMEOUT_MS), | ||
| ), |
There was a problem hiding this comment.
Clear the completed disclosure timeout
When instruction discovery completes before the two-second budget, the Promise.race resolves but this timer is neither cleared nor unref'ed. The pending timer keeps Node's event loop alive, so a standalone SDK caller that queries trust info and immediately closes its harness still takes roughly two additional seconds to exit. Retain the timeout handle and clear it when readiness wins (or unref it).
Useful? React with 👍 / 👎.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9f30a2444f
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const prefix = `${result.projectRoot}/`; | ||
| return result.additionalDirs.filter( | ||
| (dir) => dir !== result.projectRoot && !dir.startsWith(prefix), | ||
| ); |
There was a problem hiding this comment.
Resolve symlinked additional directories before hiding them
When an untrusted repository sets additional_dir = ["linked-dir"] and linked-dir is a symlink to (for example) the user's home directory, this lexical prefix check removes it from the disclosure as if it were inside the project. The filesystem service resolves every configured additional directory with realpath and treats that external target as an allowed root, so trusting grants undisclosed outside-project access and can even render the misleading empty-state prompt. Compare canonical paths before filtering, or disclose symlinked entries whose targets escape the project.
AGENTS.md reference: AGENTS.md:L118-L120
Useful? React with 👍 / 👎.
| const enabledUserNames = new Set( | ||
| Object.entries(userLoad.servers) | ||
| .filter(([, config]) => config.enabled !== false) | ||
| .map(([name]) => name), | ||
| ); |
There was a problem hiding this comment.
Disclose disabled overrides of plugin MCP servers
When an enabled plugin provides a server such as plugin-demo:finance and a project .mcp.json sets that same runtime name to enabled: false, this set only considers user JSON entries, so the disclosure omits the override. WorkspaceMcpConfigService merges file servers after plugin servers, therefore trusting applies the disabled project entry and shuts down the plugin server despite the prompt potentially claiming no project config. Fresh evidence: the plugin manager explicitly emits the plugin-<id>:<server> names that the file layer can override; include enabled plugin-server names in this check.
AGENTS.md reference: AGENTS.md:L118-L120
Useful? React with 👍 / 👎.
| function formatNameList(names: readonly string[]): string { | ||
| const shown = names.slice(0, MAX_NAME_LIST).map(sanitizeForDisplay); | ||
| const suffix = names.length > MAX_NAME_LIST ? `, +${names.length - MAX_NAME_LIST} more` : ''; | ||
| return `${shown.join(', ')}${suffix}`; |
There was a problem hiding this comment.
Limit each untrusted source name before wrapping
A project skill accepts any non-empty frontmatter name, so one crafted multi-megabyte name reaches formatNameList; the count cap only limits the number of names, not their length. At the dialog's minimum wrap width this produces hundreds of thousands of rendered rows before either choice is usable, allowing an untrusted workspace to effectively block the user from selecting “Don't trust.” Truncate each displayed skill/profile name with an omitted-length suffix before joining and wrapping.
Useful? React with 👍 / 👎.
Signed-off-by: 7Sageer <[email protected]>
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
A project .mcp.json can supply an unbounded args array (and arbitrary-length command, cwd, or URL strings), and this serializes the complete value before the rendered text is wrapped. The server-count and key-list caps do not constrain these fields, so a crafted workspace can generate enough rows to make the pre-trust dialog unusable before the user can select “Don't trust.” Truncate each displayed field and cap the number of displayed arguments with an omitted-count suffix.
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| } | ||
| const fs = this.engineAccessor.get(IHostFileSystem); | ||
| const bootstrap = this.engineAccessor.get(IBootstrapService); | ||
| const [mcp, dirs, instructions] = await Promise.all([ |
There was a problem hiding this comment.
Bound all pre-trust disclosure I/O
On a slow or unavailable filesystem, this Promise.all still prevents the trust dialog from mounting because readGatedAdditionalDirs() and the MCP loaders have no deadline, and describeInstructionSources() performs its Git-root probe before its internal two-second race. An untrusted workspace on such a mount therefore cannot select “Don't trust”; apply one outer, non-blocking timeout to the entire disclosure collection. Fresh evidence: the current timeout only starts after the awaited findGitWorkTree() call and does not cover the sibling disclosure promises.
Useful? React with 👍 / 👎.
| } | ||
|
|
||
| function isInsideOrEqualDir(child: string, parent: string): boolean { | ||
| return child === parent || child.startsWith(`${parent}/`); |
There was a problem hiding this comment.
Normalize Windows canonical paths before filtering
On Windows, IHostFileSystem.realpath() returns native backslash paths, so for additional_dir = ["sub"] this check compares C:\repo\sub with the constructed prefix C:\repo/ and classifies an in-project directory as external. The prompt then falsely says trusting grants access outside the project; normalize both canonical paths to one separator convention or use a path-aware relative containment check.
Useful? React with 👍 / 👎.
| .flatMap((entry) => entry.profiles) | ||
| .toSorted(); | ||
| const agentsMdPaths = snapshot.sources.instructionPaths | ||
| .filter((path) => path.startsWith(`${projectRoot}/`)) |
There was a problem hiding this comment.
Include root-level instructions in the disclosure
When Kimi is launched from the filesystem root (or a Windows drive root) outside a Git worktree, projectRoot already ends in /, so this prefix becomes // (for example, C://) and filters out the /AGENTS.md that WorkspaceInstructionsService loads. disclosureComplete remains true and the prompt can claim no project config even though trusting injects that instruction file; normalize the boundary prefix or handle root paths explicitly.
Useful? React with 👍 / 👎.
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep them coming! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
kimi-code/apps/kimi-code/src/tui/components/dialogs/trust-prompt.ts
Lines 252 to 254 in 0b034cb
A project .mcp.json accepts arbitrarily long command, args, cwd, and URL strings, but this formatter only removes control characters and then passes the complete value to wrapTextWithAnsi. For example, an untrusted workspace with a multi-megabyte stdio command produces hundreds of thousands of prompt rows at the minimum width, making the trust dialog unusable before the user can select “Don't trust.” Truncate each displayed target field (with an omitted-length/count suffix) before wrapping.
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6e5c45d1b6
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| await Promise.all([ | ||
| this.skills.ready, | ||
| this.agentProfilesLoader.ready, | ||
| this.instructions.ready, | ||
| ]); |
There was a problem hiding this comment.
Await competing profile loaders before disclosing profiles
When an SDK host uses the new process-level agentFiles option and that explicit file is slower to read than the workspace agent directory, this waits only for the workspace loader and snapshots the registry before the explicit loader registers. A same-named workspace profile is then displayed as becoming available, but the session catalog later selects the higher-priority explicit profile and suppresses the workspace one. Fresh evidence is that explicit profiles are loaded asynchronously from bootstrap.args.agentFiles; wait for the competing loaders or mark this portion of the disclosure incomplete.
Useful? React with 👍 / 👎.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8081d74879
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| function isInsideOrEqualDir(child: string, parent: string): boolean { | ||
| const rel = relative(parent, child); | ||
| return rel === '' || (!rel.startsWith('..') && !isAbsolute(rel)); |
There was a problem hiding this comment.
Treat
..-prefixed child paths as inside the project
When an untrusted project's local.toml configures additional_dir = ["..cache"] and /repo/..cache exists, relative('/repo', '/repo/..cache') is ..cache; this prefix check classifies that in-project directory as escaping. readGatedAdditionalDirs() then tells the user that trusting grants outside-project access even though it grants no new external access. Restrict the parent check to .. itself or a parent-segment prefix such as ../.
Useful? React with 👍 / 👎.
|
@codex review |
|
Codex Review: Didn't find any major issues. 👍 Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
|
@codex review |
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 206ce332c0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| readonly paths: readonly string[]; | ||
| } | ||
|
|
||
| /** Trust state of a workspace directory, plus everything trusting it would activate. */ |
There was a problem hiding this comment.
Gate disclosed workspace inputs on the trust state
For SDK hosts that call createSession() without first calling trustWorkspace(), this contract is inaccurate: session materialization never checks IWorkspaceTrust, while WorkspaceDirsService has already loaded local.toml and the session is seeded directly with those directories, project skills, instructions, and profiles. Such a session therefore receives the disclosed external access and prompt inputs while trusted remains false, so consumers cannot treat the new gatedAdditionalDirs or instruction disclosure as things that trusting actually activates; either enforce the gate in session creation or avoid exposing these inputs as trust-gated.
AGENTS.md reference: AGENTS.md:L110-L112
Useful? React with 👍 / 👎.
Step 11, the tail of the sync: 13 upstream commits over 177 files. The step lands the WaitFor steering rework, the workspace-trust summary, the sticky user messages, and the completion-budget cleanup. Upstream's changes in this step, all absorbed: - interrupt tower wake turns on user input and harden tower operations (MoonshotAI#3998) - cap WaitFor at 90s and let new input end the wait (MoonshotAI#4061) - summarize workspace trust with configuration sources (MoonshotAI#4056) - trust the workspace via KIMI_CODE_TRUST_WORKSPACE (MoonshotAI#4059) - add sticky user messages in fullscreen mode (MoonshotAI#4031) - omit the completion token cap unless explicitly configured (MoonshotAI#4091) - clear inherited cron tasks at the fork record (MoonshotAI#4083) - fold UserPromptSubmit hook output into the prompt message (MoonshotAI#4081) - remove the interruption reminder on undo of its turn (MoonshotAI#4076) - publish permission mode changes on agent.status.updated (MoonshotAI#4057) - stop NotifyUser nudges in hosts without the update panel (MoonshotAI#4054) - add regression and user-impact review to the PR workflow (MoonshotAI#4023) - sync the 2.1.1 changelog into the release notes (MoonshotAI#4018) Fork behaviour that had to survive: - the message-dispatch controller split: upstream's new steering path (the steering set, the queue-wide steer, the settle callback, the transcript rollback on a failed steer) was ported into MessageDispatchController, and KimiTUI keeps delegating to it - the i18n layer: the rewritten trust prompt goes through `t()` with new en/zh entries, and the Code Review Rules section lands in DEVELOP.md (the fork's renamed AGENTS.md) - the fork's node-local → host rename, its sixel graphics work in pi-tui, and its Windows-safe test cleanup stay in place - the fork's tool list: the recorded tools-snapshot hashes keep the fork's own tool set - the fork's path-image ingestion no longer defers the media-free submit path: extractMediaAttachments returns synchronously when the text carries no image file path, so a plain prompt reaches dispatch in the same tick again (upstream's steering tests assert exactly that) Verified: typecheck clean across every package and app; full suite 17879 passed / 0 failed / 81 skipped / 1 todo, plus kimi-inspect's own 115 tests; lint 0 errors.
Requirement or Bug
信任目录之前,用后果摘要说明会激活什么,并给出可自行核查的配置文件或目录。
Bug Reproduction Steps
N/A
Root Cause
N/A
Code Changes
来源聚合限定在 trust disclosure 内,复用加载器已有的结果;不修改其他 service、AgentProfile、指令加载器或状态清单,也不增加来源追踪机制。agent 配置直接提供已有扫描目录作为核查入口,目录以
/结尾,不承诺精确到生效文件或单个 agent 文件的符号链接目标。MCP 和 AGENTS.md 文件、项目外目录的实际位置会解析符号链接;skill 来源优先归并到已有根目录。项目内路径相对当前工作目录显示,项目外保留绝对路径。面板不显示 MCP 命令、参数、env/header/token 详情,也没有独立详情页;完整配置由用户按路径打开查看。
扫描失败在面板显示通用提示,AGENTS.md 直接复用现有加载警告;不为精确标注失败路径新增跨模块字段。project skills 最多等待 1 秒,watcher 初始化失败或超时后继续显示信任入口,并提示用户检查 skill 目录。长内容在同一面板分页,目录和核查路径不会按固定数量截掉。信任存储、工具审批和启动生命周期不变。
Preview
实际组件渲染,80×24 终端(23 个可用行):
Behavior Changes and Affected Users
默认选中信任,↑↓ 选择,Enter/Space 确认,Esc 退出。
验证:
afterPromptStarted=true,重试继续在后台运行。Checklist