Repository navigation
feat: group implicit projects by git repository - #5204
Conversation
🦋 Changeset detectedLatest commit: 301742a The changes in this PR will be included in the next version bump. This PR includes changesets to release 11 packages
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 Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 270d2cbca9
ℹ️ 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".
e9e75f5 to
c4ba5f3
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c4ba5f347f
ℹ️ 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".
c4ba5f3 to
5726a5d
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5726a5d870
ℹ️ 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".
5726a5d to
1a526f1
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1a526f15a8
ℹ️ 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".
1a526f1 to
35a522d
Compare
b4b12c3 to
395aa7a
Compare
395aa7a to
2395d32
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2395d32c21
ℹ️ 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".
2395d32 to
8de5b76
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8de5b7638d
ℹ️ 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".
8de5b76 to
26c6604
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 26c66047fc
ℹ️ 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".
…irectory A session created with only workspace_root, or one of its aliases, joins the implicit workspace of its repository, and workspace_id with a workspace_root elsewhere in the root's repository starts the session there. Sessions report the directory they run in, changing the primary directory of an implicit workspace returns 40941, and file requests by path no longer register a workspace.
… them Skills, additional directories, file suggestions, MCP servers and trust info for a directory now come from the view a new session in that directory would use, and listing the sessions of a directory returns those of its implicit project that run there. Imported and migrated sessions are placed by the same rule as new ones.
…irectories Starting in a linked worktree or subdirectory of a trusted repository no longer asks for trust again, and the prompt names the project and its primary directory. kimi -c and the session lists use the sessions that ran in the current directory, and resuming a session whose directory was deleted says so.
Sessions are grouped with their project by id only, and the file tree, diff picker, terminals, Open In, session info and @ suggestions open at the directory a session runs in. Archived sessions in Settings are grouped by project as well. The primary directory of a CLI project can no longer be changed, and a removed project shows up again once the server lists it.
…ectory as missing for MCP When a component of a session's working directory has been replaced by a file, realpath fails with ENOTDIR. The MCP fallback treated only ENOENT as a missing directory, so such a session was served by the main checkout's set and started its servers, while main gives it no project servers.
…s file tree loads When a session's directory changed while the listing of its old directory was still in flight, the refresh was skipped because the path was marked as loading, and the old response then filled the tree. The file panel showed the former directory's files until a manual refresh.
…the project's file-history list A session created with an explicit local environment directory equal to the project's primary directory got its own retention list, so one directory could keep file history for twice the usual number of sessions. Such sessions now share the project's list again, as they do on main.
Archived sessions are grouped and filtered by project, labelled with the project name. A new project is named after the last segment of its directory, so two projects such as /a/app and /b/app showed the same label in both the filter and the group headings. Each project now also shows its path, as the project picker does.
…y that no longer exists A session whose working directory had been removed got a set of MCP servers of its own, and loading its config searched upward from the missing path for a git root. When the path sat under another repository, that repository's .mcp.json was read and its servers started under the session project's trust. Such a set now never counts as trusted, so it reads the user's config only, and it is cached apart from the checkout sets so that a directory that comes back is served by the checkout rules.
Update the TUI driver in tests/e2e to match the renamed 'Trust this project?' prompt, and remove the paused legacy apps/kimi-code/test/e2e/tui additions blocked by legacy-e2e.mjs on main (the behaviors remain covered by node-sdk, kimi-tui-startup, and tests/e2e/scenarios/workspace).
aa513a5 to
301742a
Compare
MoonshotAI#5204 needs the layered project port, MoonshotAI#5206 is the Workspace -> Project rename, and MoonshotAI#5292 imports the projectSessions paths both create. Keep them in dependency order rather than applying 189/320-file patches wholesale.
…equivalent Register the deliberate naming deviation in PLAYBOOK and close the rename row as equivalent. MoonshotAI#5204/MoonshotAI#5292 are adapted to workspace semantics instead of importing upstream's project paths.
…5204) Bring in the core of the implicit-project grouping: GitWorkTree's marker and checkout location detection, the five workdir-slug helpers the decision needs, decideImplicitProject, projectDirAt and unlessProjectGone. The implicitProject suite passes 20; projectDirAt's filesystem/symlink suite is deferred until it is adapted to this host backend. The primitives are not wired into project sessions yet; the service and KAP/session integration follow.
…hotAI#5204) Port the post-rename feature onto the project layer: implicit projects are grouped by their git repository, project sessions gain listForWorkdir, ProjectDirsService follows the upstream primary/member/worktree rules, and trust is carried through the primary directory with the ProjectTrust view. The session-index parser keeps projectRoot so removed projects can be revived from the directory their sessions recorded. Includes the upstream changesets and the reset edge handling and tests. Verified: agent-core-v2 typecheck clean; project, projectDirs, projectSessions and implicitProject suites 169 pass / 5 skip; check:no-comments OK.
The fake service now carries resolveImplicit, peekImplicit, reviveImplicit, projectDirAt and acceptsWorkDir, so the root typecheck stays green after the project-grouping interface grew.
…hotAI#5204) An absolute fs ref no longer calls createOrTouch: it looks up an existing implicit project by directory or builds a read-only pick, and a missing or non-directory path returns undefined. This keeps browsing from minting project records and follows the upstream grouping rule.
…sessions (MoonshotAI#5204) Session creation and profile cwd moves now call resolveImplicit instead of createOrTouch, so a session started inside a repository joins its grouped main-checkout project and a session keeps its own working directory. The auto-registration path is gone from the KAP session surface.
…onshotAI#5204) The workspaces facade now resolves the implicit project for a directory through the engine's grouping rule; the contract, facade and round-trip tests follow. Root and klient typechecks are clean, facade 33 pass.
…hotAI#5204) Port the remaining client half of upstream e6b16c4 on top of the landed core/KAP/klient work: desktop panel roots and archived-project grouping, app-core panelRoots, app-client activePanelRoots and unseen-project listing, app-components FilesPanel session roots, CLI launch-path resolution for skill dirs, TUI session-directory resume hints, SDK resolveSessionPlacement and WorkspaceTrustInfo.projectRoot, and project-scoped imported sessions. Fork adaptations: - the localized trust prompt keeps the fork's workspace wording and the standalone session-directory hint; upstream's session-aware project trust and its trust-prompt rewrite are not adopted; - upstream vitest test files are adapted to the fork's bun:test suites, and the UI test for MoonshotAI#5351's confirmDiscard stays with that row; - migration-legacy keeps its own session-index entry writer while writing the new project-scoped session layout, and imported sessions keep the localized default title; - the message-flow temp-dir cleanup retries on Windows EBUSY. Verified: apps/kimi-code and node-sdk typecheck clean; node-sdk sdk-rpc-client-v2 100 pass / 11 skip; session-import 13, add-dir 9, run-shell 23, TUI startup 89, message-flow 489 pass / 1 skip, run-v2-print 27; migration-legacy import/resume 9; desktop renderer 50; app-client workspaces-store 90, files-store 60, session-info 13; app-components FilesPanel 7; app-core panelRoots 7. Pre-existing: app-client workspace-state 212 pass / 13 fail and session-list-store 35 pass / 2 fail (Bun lacks vi.resetModules).
Requirement or Bug
CLI 会为启动
kimi的每个目录自动建一个隐式项目(桌面端里手动建的叫手动项目)。用户用git worktree add给同一个仓库另开一个工作文件夹,在里面运行kimi时会遇到三个问题。已经信任过的仓库又问一次信任。桌面端侧边栏里同一个仓库出现好几个项目。桌面端还能改隐式项目的主目录,改完以后在终端里打开原来的目录,kimi却在改过的目录里运行。这个 PR 让隐式项目按 git 仓库归组。worktree 和子目录里新开的会话归到仓库的项目,沿用它的信任,同时留在自己启动的目录里工作。隐式项目的主目录改为只读。
Bug Reproduction Steps
~/app里运行kimi,选择信任。git worktree add ../app-fix,再cd ../app-fix && kimi,又弹出信任提示。app和app-fix两个项目。app-fix项目的主目录改成别的目录,回到终端cd ../app-fix && kimi,初始工作目录是改过的目录,不是app-fix。Root Cause
隐式项目的 id 是启动目录的哈希。CLI 从不看目录属于哪个仓库,所以每个 worktree、每个子目录都成了独立的项目,各自要信任。会话也不记自己的工作目录,而是跟着项目主目录走,所以桌面端一改主目录,CLI 的会话也跟着挪走。这是根本修复。项目归属改由一个解析器按仓库决定,会话在主目录以外启动时记下自己的目录。
Code Changes
核心思路。 所有创建隐式项目的入口都走同一个解析器,包括 TUI、
kimi -p、SDK、只传workspace_root的 KAP 请求、ACP 和会话导入。启动目录自己已经有带会话的隐式项目,就继续用它,老数据原样保留。否则从磁盘认出目录所在仓库的主检出(仓库最初所在、放着.git目录的文件夹),复用或创建它的项目。不在仓库里,就和以前一样按目录建项目。会话在主目录以外启动时,把起始目录记进 state.json 里已有的environmentCwd。项目受信任,当且仅当它的主目录有信任记录。flowchart TD D[启动目录 D] --> R1{D 自己的隐式项目里有会话} R1 -- 有 --> P1[用 D 自己的项目] R1 -- 没有 --> L{认出 D 所在仓库的主检出 M} L -- 是,且 M 不是 home 或其上级 --> P2[复用或创建 M 的项目] L -- 否 --> P3[复用或创建 D 自己的项目]第一条规则保住已经有会话的老项目,不迁移任何数据,只有新目录才归组。认主检出只读磁盘上的
.git文件,不调用 git。worktree 的指针文件要和 git 写下的反向指针对得上才归组,伪造的或读不懂的.git让目录自成项目。内容跟谁走。 会随分支变的内容跟工作目录,不会变的跟项目。
~/app-fix里的会话~/app项目的~/app-fix的~/app-fix的配置,服务在~/app-fix启动项目级 MCP 每个检出一套,配置从项目主目录在这个检出里的对应位置读。子目录自己的
.kimi-code/mcp.json不再读。信任现在覆盖整个仓库,而node_modules或解压进来的目录里也可能带着这个文件,不能不经确认就运行里面的命令。隐式项目的主目录只读。 改它会把 CLI 的会话带到别处。核心报
workspace.primary_immutable,KAP 返回新错误码40941,桌面端不再显示「设为主目录」。手动项目不受影响。KAP。
POST /sessions同时给workspace_id和workspace_root时,隐式和手动项目用同一条规则。workspace_root和主目录在同一个 git 仓库里就放行,否则必须等于主目录,和以前一样返回40001。附加目录不算。会话在哪个目录启动就在哪里运行,不在主目录的会话在响应的environment_cwd里报告这个目录。会话里的 agent 按kap.md再开会话时,要带上自己的environment_id和environment_cwd,否则新会话会跑到主目录。桌面端。 侧边栏只按项目 id 分组会话。选中会话时,文件树、diff、终端、Open In、会话信息和
@补全以会话的工作目录为根,草稿页用项目主目录。「已归档」页按项目分组。关键决策
.git、gitdir、commondir、core.bare、core.worktreegit rev-parse、git worktree listGIT_*环境变量;能识破伪造的core.worktreekimi -c续哪个会话旧路径和新位置
acquire({ cwd })、createOrTouchIWorkspaceService.resolveImplicit,只读查询用peekImplicitforRootsforProject只看主目录,改主目录时把记录带过去workspaceIdsFor-r的listSessions({ sessionId, workDir })POST /sessions的目录校验workspace_id时必须等于主目录@补全阅读指南
packages/agent-core-v2/src/app/git/workTree.ts讲各种.git布局怎么认。packages/agent-core-v2/src/app/workspace/implicitProject.ts是三条规则的纯函数。packages/agent-core-v2/src/app/workspace/workspaceService.ts实现resolveImplicit、主目录只读和复活已删除的项目。packages/agent-core-v2/src/app/workspace/projectWorkDir.ts判断一个目录能不能在项目里当工作目录,以及它在哪个检出里对应主目录。packages/agent-core-v2/src/session/workspaceContext/workspaceRoots.ts决定什么时候记会话的工作目录。packages/agent-core-v2/src/program/programWorkdirs.ts和programMcpSets.ts给每个工作目录一个视图、每个检出一套 MCP。packages/kap-server/src/routes/sessions.ts是 KAP 的放置规则。packages/node-sdk/src/sdk-rpc-client-v2.ts决定目录查询用哪个视图、怎么列目录的会话。packages/app-core/src/lib/panelRoots.ts决定桌面端面板的根。信任、权限规则和 MCP 注册表的改动,是改成读项目主目录或会话所在的检出。CLI 改的是数据来源和文案。这些可以略读。
Behavior Changes and Affected Users
kimi -p、VS Code、ACP、只传workspace_root的 KAP 请求、会话导入)--add-dir目录的记录才受信任的项目;早先改过主目录的手动项目Trust this folder?,显示启动目录Trust this project?,显示项目主目录Could not inspect project settings.kimi -p未信任警告(所有用户)this folder is not trusted,让用户选不存在的Trust this folderthis project is not trusted,选项名改成真实存在的Trust and continue;不再列出enabled: false的服务kimi -c、kimi -p -c、会话选择器、kimi session list、kimi fork、kimi export的默认会话kimi session list --json的脚本kimi session list --all、kimi -r <id>kimi -r <id>cd,目录已删时说明;信任按会话所属的项目问/add-dir选「记住」写到仓库项目/add-dir自己的工作目录并选「记住」@候选也会出现environment_cwd把会话钉在登记目录、又要访问主目录的 KAP 客户端--add-dir或/add-dir加上主目录/add-dir.kimi-code/mcp.json(先问信任).kimi-code/mcp.json的用户mcp-config、import-from-cc-codex的提示词(逐句见下)<cwd>/.kimi-code/mcp.json<project root>/.kimi-code/mcp.json;<cwd>在子目录时先向用户说明40941,桌面端不显示入口POST /sessions只传workspace_root或它的别名workspace_root推算项目 id 的 KAP 客户端workspace_idPOST /sessions同时给workspace_id和workspace_rootworkspace_root必须等于主目录40001environment_cwdenvironment_cwd,值是它运行的目录suggestFiles、项目级 MCP、信任信息)listSessions({ workDir })listSessions()列全部cwdcd到不存在的目录kimi -rstderr 的脚本.kimi-code/local.toml写坏kimi export的 manifestworkspaceDir是项目主目录@补全kimi appkimi app的用户相对的
--agent-file仍按启动目录解析,相对的--skills-dir、extra_skill_dirs、extra_agent_dirs仍按工作目录所在检出的根解析,和改动前一样。内置技能的提示词改动(
packages/agent-core-v2/src/features/skill/catalog/builtin/),逐句列出:mcp-config.md,Project-root 一条<project root>/.mcp.json, where project root is found by walking up from<cwd>to the nearest.git.or is <cwd> when there is none,和读取逻辑一致mcp-config.md,Project-local 一条<cwd>/.kimi-code/mcp.json. Use for Kimi-specific overrides in the current working directory.<project root>/.kimi-code/mcp.json. Use for Kimi-specific overrides; Kimi does not read this file from subdirectories. When<cwd>is not the project root, say in the announcement before the write that Kimi loads this file for sessions anywhere in this git checkout, while a project opened directly at<cwd>(for example one created for this folder in the desktop app) reads<cwd>/.kimi-code/mcp.jsoninstead.import-from-cc-codex.md,目标位置清单<cwd>/.kimi-code/mcp.json, because Kimi reads the current working directory's Kimi-specific MCP file, not every project-root.kimi-code/mcp.jsonfrom subdirectories.<project root>/.kimi-code/mcp.json, because Kimi reads the Kimi-specific MCP file at the project root, not.kimi-code/mcp.jsonfiles in its subdirectories.import-from-cc-codex.md,disabledMcpjsonServers的建议"enabled": falsein<cwd>/.kimi-code/mcp.json<project root>/.kimi-code/mcp.json,其余不变import-from-cc-codex.md,选目标作用域<cwd>/.kimi-code/mcp.json). If<cwd>is not the project root, call this out in the preview so the user understands when Kimi will load it.<project root>/.kimi-code/mcp.json). If<cwd>is not the project root, say in the preview that Kimi loads it for sessions anywhere in this git checkout, while a project opened directly at<cwd>… reads<cwd>/.kimi-code/mcp.jsoninstead.这些句子只发给激活了这两个内置技能的会话,也就是用户运行
/mcp-config或导入技能,或者模型自己调用它们的时候。原句让模型把项目级 Kimi MCP 写进当前目录。这个 PR 之后,子目录里的这个文件不再被读,照原句写会静默失效。新句改成写到检出根,也就是 Kimi 实际读取的位置。只有桌面端为子目录建的项目还读子目录里的文件,模型分不清这种情况,所以要求它写入前向用户说明。契约。 改动的契约文件是
packages/kap-server/docs/kap.md、packages/kap-server/schema/contract.txt、packages/node-sdk/src/index.ts和apps/kimi-code/src/cli/。contract.txt只多了POST /workspaces/{id}/primary返回40941的形状,HOST_API_LEVEL不变。kap.md写了新的放置规则和40941。SDK 只做加法,新增sameDir、resolveSessionPlacement、信任信息里的projectRoot和信任查询的sessionId;listSessions({ workDir })的语义变化见上表。使用方是本仓库的桌面端和 Web 端、会话里按kap.md调 KAP 的 agent、VS Code 扩展(经 SDK)、Zed 等 ACP 客户端和 SDK 用户。旧版本写的数据都能继续读。projects.json 的schema_version仍是 2,没有新字段。会话索引每行只多一个可选的projectRoot,旧版本读索引时忽略它。老会话没有environmentCwd,按跟随主目录处理。上表多数行没有开关形式的逃生口,行为在设计阶段定下,请维护者在这个 PR 里确认。
已知限制。
git worktree move之后,kimi -c按会话记下的目录找,找不到搬走前的会话。受影响模块与测试覆盖
packages/agent-core-v2/test/app/git/gitService.test.ts,覆盖各种.git布局、伪造的指针、裸仓库、config.worktree、CRLF 和 Windows 写法,布局夹具在checkoutLayouts.ts。implicitProject.test.ts。两个进程同时解析只产生一个项目、清空 projects.json 后重建、删掉老项目后归组、复活已删除的项目、主目录只读、改主目录后带走信任,在workspaceService.test.ts。projectWorkDir.test.ts。workspaceRoots.test.ts、program.test.ts、workspaceDirsService.test.ts、workspaceSessionsService.test.ts。programMcpSets.test.ts和mcpRegistry.test.ts,真实的kimi -p在apps/kimi-code/test/cli/print-mcp.test.ts。workspaceTrust.test.ts,SDK 里另有「已信任的目录被仓库的 local.toml 列出,项目照样问信任」和「读不出要披露的内容时仍给出准确的主目录」两条。fileHistory.test.ts,KAP 的 fork 和删除也各有用例。sessions.test.ts覆盖只传workspace_root归组、同仓库规则、范围外40001、符号链接、fork、environment_cwd的报告和目录删除后仍能打开。workspaces.test.ts覆盖40941,fs.test.ts覆盖按路径读文件不登记项目,skills.test.ts覆盖登记成附加目录的 worktree 用自己的技能。tests/scenarios/cold-recovery.test.ts。sdk-rpc-client-v2.test.ts、list-sessions.test.ts、acp-server/test/lifecycle.test.ts。kimi-tui-startup.test.ts、v2-run-print.test.ts、import-sessions.test.ts和tests/e2e/scenarios/workspace/(tests/e2e/surfaces/tui.ts已同步更新为等待Trust this project?)。packages/app-core/test/panelRoots.test.ts、packages/app-client/test/workspaces-store.test.ts、files-store.test.ts、session-list-store.test.ts、apps/desktop/tests/renderer/sessionPanelRoots.test.ts和已归档页的组件测试。改动过的已有测试。 旧断言固定的是这次有意改掉的几种行为,包括隐式项目吸收手动项目的目录、目录集里任一目录有记录就信任、读子目录的
.kimi-code/mcp.json、-c和-r和listSessions的目录视图,以及会话一律跟随主目录。删掉了四条原有单测:两条是桌面端panelAdapters里和sessionPanelRoots重复的用例,一条是filesPanel.test.ts里只断言替身的用例,还有一条是 print 模式的「跟随项目的会话从当前项目根恢复」(由索引测试projects the current primary without changing explicit environment cwd or historical metadata覆盖)。KAP 的固定端口用例由「只有 worktree 会话时只启动一个进程」的断言覆盖。另因 main 在 #5385 冻结了已停跑的apps/kimi-code/test/e2e/tui/,移除了本 PR 此前在该目录新增的project-trust.test.ts与working-directory.test.ts;对应行为继续由packages/node-sdk/test/sdk-rpc-client-v2.test.ts、apps/kimi-code/test/tui/kimi-tui-startup.test.ts与tests/e2e/scenarios/workspace/覆盖(仅少了一组停跑目录内的独立 PTY worktree 信任串联用例,原本在 CI 中也不运行)。验证
f85f504b8f后,本机(macOS)通过了完整的pnpm lint、受影响包与桌面端类型检查(agent-core-v2、kap-server、node-sdk、kimi-code、acp-server、tests/e2e、apps/desktop)、tests/e2e/scenarios/workspace/的 2 条 TUI 信任场景,以及与 main 重叠模块的 Vitest 用例(apiSurface、openapi、sessions、acp-server/lifecycle、sessionPanelRoots、session-header-menu-context、panelRoots、kimi-tui-startup、trust-prompt、workspaceDirsService与sdk-rpc-client-v2信任分组)。2679368ca后,完整 CI 在aa513a5c50上全部通过(跳过项为 main 上暂停的 L0 受保护测试门禁 ci: temporarily pause previous e2e gates #5309、关闭的 Windows 任务和按标签触发的变异测试),本机也通过了pnpm run check:duplication、agent-core-v2/kap-server/app-core/klient 全套(11,225 条)与 CLI/桌面端渲染层测试(6,466 条;个别超时或需本机zstd的用例在 main 上同样失败或单跑通过)。programMcpSets.ts两行,经 KAP 跑了目录被删、上级被换成文件、上级没有权限三种情况,结果和 main 一致。files.ts,挂载真实的文件面板验证。environment_cwd的会话会单独占一份文件历史保留列表,同一目录最多保留 60 个会话。改回和项目共用一份,经 KAP 各建 31 个会话验证,保留数和 main 一样是 30。.mcp.json,并按本项目的信任启动它的服务。现在这类会话只读用户级配置。经 KAP 复现并验证,删掉另一个仓库下的工作目录再恢复会话,那个仓库的命令不再执行。kap.md的一句话和 changeset。48cdb62be之后、这些评审修复之前,整条栈上 TUI、ACP、桌面端、Web 四套跨端用例各 65 条全部通过。桌面端 E2E 87 条通过,失败的 1 条terminal-panel.spec.ts在 main 上同样失败。real-llm-smoke要连真实模型,没有跑。worktree 会话里的内置浏览器没有验证。Windows 路径由单元测试覆盖,没有在 Windows 和真实 SSH 主机上实测。Checklist
/approve).gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.