Skip to content

feat: multi-root workspace registry and source-folder management - #4336

Merged
liruifengv merged 33 commits into
mainfrom
feat/multi-root-workspace
Oct 28, 2026
Merged

liruifengv merged 33 commits into
mainfrom
feat/multi-root-workspace

Conversation

@liruifengv

@liruifengv liruifengv commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

需求或 Bug

为 desktop/web 的多源文件夹项目提供 core 基础:projects.json 注册表、wd_/wm_ 身份与会话归属、源目录运行时、全根文件系统能力,以及 REST/WS 和 MCP 所需的目录解析。

Bug 复现步骤

N/A

根本原因

N/A

代码变更

projects.json(schema_version = 2)
  projects[id] = root / name / kind / additional_dirs / created_at / last_opened_at
  deleted_project_ids / idempotency_keys / migration
  从 workspaces.json 一次性迁移并保留备份;旧文件和 sessions 不搬家
  跨进程 update(mutator) + 实际写锁;原子替换后仍持续监听
  瞬时迁移失败清除 rejected promise,后续请求可以重试
  新格式严格校验 additional_dirs 类型和 kind;legacy 迁移保留容错

身份与会话归属
  wd_<slug>_<hash12>:隐式目录,保留 alias 折叠和规范化查找
  wm_<uuid>:显式项目;同 root 可共存,重试由 idempotency_key 去重
  显式 workspace_id 创建会话 → 对应桶;仅 cwd → hash 桶
  sessions/<workspaceId>/<sessionId>;隐式重建不吸入 wm_ 桶
  删除仅处理自身 alias 链,不连带同 root 的其他项目

目录运行时与 MCP
  managed:注册表为唯一目录来源;implicit:注册表 + 主目录 local.toml + ephemeral
  注册表更新实时推送目录集,compaction / clear 后仍保留新增目录提醒
  折叠隐式 alias 重载时包含当前精确条目,add-dir 持久化后立即可见
  MCP findContaining 使用 program.dirs 的实时 root + additionalDirs,并保留最长根匹配

文件系统
  list / search / suggest / grep(rg 与 Node)覆盖全部源目录
  主根返回相对路径,附加根返回绝对路径;重叠根在累计前去重
  缺失附加根可跳过;附加根的绝对请求保留请求锚点
  保留 main 的符号链接目录遍历、预算与外部链接开关

REST / WS / SDK / 文档
  POST /workspaces:创建 wm_,支持 additional_dirs 与 idempotency_key
  PATCH /workspaces/{id}:名称和 additional_dirs 整体替换
  POST /workspaces/{id}/primary:原子交换 root 与附加目录(UI 当前禁用换主)
  GET /workspaces/project-config-dirs:只读导入;损坏 TOML / 失效目录返回错误而非空数组
  移除旧 POST /workspaces/{id}/add-dir;Klient update 支持 additionalDirs
  中英文文档同步:server-api、config-files、data-locations(wd_ / wm_ 会话桶)

行为变化与影响范围

行为 原行为 新行为 旧行为使用方与当前边界
已存在 root 的 POST /workspaces 按 root 返回已有条目 每次创建新的 wm_,同 root 可共存;重试使用 idempotency_key desktop/web 快速添加与项目弹窗;不再保留旧 root 幂等(D08)
同 root 的 wd_ 与 wm_ 去重为一个条目 两种身份可同时存在 desktop/web 侧栏、会话分组和删除均按 ID 隔离
TUI/SDK 按 workDir 查会话 仅 hash 桶及 alias hash/alias ∪ 目录集成员桶 TUI/CLI/VS Code 可看到匹配目录的项目会话;REST/desktop 仍按桶严格过滤
/workspaces/{id}/primary 无此接口 原子换主,ID 与桶不变 当前 UI 禁止换主;活跃 runtime、隐式 ID、冷会话恢复问题留到 D01/D02/D16
TUI /add-dir 选择记住 写入项目 .kimi-code/local.toml 写入 projects.json;隐式仍读取旧配置 旧版本或其他 KIMI_CODE_HOME 不共享新注册表(D04);二期互操作
旧 POST /workspaces/{id}/add-dir 可添加并支持 persist: false 接口移除,改用 workspace PATCH 当前客户端与服务端同步演进,不增加兼容 shim(D09)
项目 local.toml 合并 所有会话均合并 仅 implicit 合并;managed 需显式导入 新建/编辑弹窗提供只读导入;managed 不会自动继承旧配置
workspaces.json 持续读写 一次性迁移到 projects.json,保留备份 不做持续同步;回退期间的变更不自动调和(D17)
schema-v2 数据 非法字段可能被静默忽略或强制转换 非字符串目录项、非数组目录字段、缺失/非法 kind 均报损坏 legacy 迁移仍保持容错,不重建或清空原文件
绝对附加目录的 fs 操作 可能被判为越界或错误映射到主根 目录集内允许;结果保留源根身份 集外路径仍为 fs.path_escapes;附加根失效不再阻断其他根的 suggest
search / grep 主目录搜索 全源目录搜索,重叠根去重 会话创建前的 search/suggest 留到 D06;跨仓库 Git status/diff 留到 D07
MCP stdio probe cwd 仅按实例主目录判断归属 按实时目录集判断,新增根可匹配、移除根不再匹配 使用 program.dirs,不读取构造时 metadata 快照
配置导入失败 返回成功空数组,无法区分无配置 请求失败,客户端展示导入失败 中英文 API 文档同步更新
瞬时迁移失败 rejected promise 导致进程内后续请求持续失败 清除缓存并允许下一次请求重试 增加快照冲突后第二次加载成功的回归测试

受影响模块:agent-core-v2 的注册表、目录服务、文件系统、运行时与 MCP;kap-server 的 workspace/session/fs 路由和 WS;klient、node-sdk 的契约与目录视图;中英文配置和 API 文档。

测试覆盖:

  • workspaceService.test.ts:68 条通过(迁移、严格校验、幂等、alias、失败重试等)。
  • fsService.test.ts:96 条通过(全根搜索/grep/suggest、缺失根、重叠根、符号链接与附加根锚点)。
  • workspaceDirsService.test.ts:13 条通过(实时目录、隐式 alias、managed/implicit 差异)。
  • workspaceInstanceManager.test.ts:11 条通过(MCP 实时目录与最长根匹配)。
  • kap-server:1426 条通过,1 条跳过。
  • agent-core-v2 与 kap-server 构建通过;pnpm lint 0 errors;中英文 VitePress 文档构建通过。
  • 非本 PR 引入的既有验证限制:全量 agent-core-v2 套件中的 subagent 超时用例已在基线复现;独立 typecheck 仍有基线 undici 版本冲突。未将这些失败描述为本 PR 回归。

与 main 已合并,merge commit 为 730cca00a,冲突已解决;多根目录与 main 的符号链接目录支持均保留。

暂缓项与边界

17 项均有明确决策,完整评论链接见 未修项台账:

  • 换主:D01、D02、D16;删除/恢复:D03、D15;local.toml 互操作:D04、D05。
  • 文件与 Git:D06(会话前 search/suggest)、D07(跨仓库 Git 合并语义)。
  • 明确不做:D08(旧 root 幂等)、D09(旧 add-dir REST)。
  • 边界情况:D10(删除后的幂等重试)、D11(目录失效后的幂等重试)、D12(__proto__ 幂等键)、D13(相对 root 输入)。
  • 待产品决策:D14(同 root 项目按路径打开的目标选择)。
  • 迁移:D17(回退后的 legacy 调和;当前一次性迁移、无持续同步)。

Checklist

  • 我已阅读并遵循 CONTRIBUTING 与 AGENTS.md。
  • 需求来自内部 RFC,无公开 issue。
  • 我已添加证明功能可用的测试及回归覆盖。
  • 行为变化表已覆盖旧 root 幂等、旧 add-dir REST、旧 local.toml、迁移和文件系统语义;对应的兼容边界与暂缓项均已列明。
  • 已运行 gen-changesets skill,或本 PR 无需 changeset。(按本 PR 既定发布口径,桌面端功能说明由 code-app 承担,core 不另列 CLI changeset。)
  • 已运行 gen-docs skill,或本 PR 无需文档更新。(server-api.md、config-files.md、data-locations.md 已做中英文同步更新。)

…tion

workspaces.json v2 adds optional additional_dirs (plus create-time
idempotency keys) on top of v1 entries with zero migration, and the
writer now preserves unknown fields so mixed-version round-trips only
drop what they do not know.

Workspace ids split into two namespaces: wd_ hash identities stay the
implicit channel (TUI/CLI/VSCode via createOrTouch, idempotent and
alias-folding as before), while explicit registry creates mint wm_
uuid identities that may share a root with a hash entry. Alias
resolution and list dedupe only fold wd_ spellings, delete tombstones
only the id's own wd_ alias chain, and wm_-bucket session lines no
longer feed implicit registry rebuild.

Session attribution follows the channel: SDK workspaceIdsFor is
locked to the workDir hash bucket so directory views are unchanged,
while POST /sessions with an explicit workspace_id lands in that
bucket directly. WorkspaceDirsService gains a registry source,
injecting the registry dir set minus cwd into every workspace scope
alongside local.toml and ephemeral dirs.
POST /workspaces now mints a fresh wm_ uuid per call (single-root
included; same-path duplicates stay unmerged) and accepts
additional_dirs plus a client idempotency_key for retry-safe creation.
PATCH /workspaces/{id} learns additional_dirs with whole-list replace
semantics so edit clients submit name and dirs in one transaction; dir
validation reuses the add-dir chain (absolutize, stat, dedupe,
not-the-root) with 40001/40409/40410. The wire shape gains
additional_dirs (default []) and workspace_id params accept wm_ ids,
keeping REST and WS event.workspace.* payloads aligned.
Copilot AI balanced review requested due to automatic review settings October 22, 2026 09:11
@changeset-bot

changeset-bot Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 716d752

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-28T05:27:00.400449Z 716d752 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@pkg-pr-new

pkg-pr-new Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@716d752
npx https://pkg.pr.new/@moonshot-ai/kimi-code@716d752

commit: 716d752

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 45f60a4381

ℹ️ 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".

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved workspace isolation, update forwarding, and session lifecycle regressions affect access boundaries and existing functionality.

6 open issues
What changed in this PR

Adds the server-side foundation for multi-root workspaces, separating explicit desktop/web workspaces from implicit directory-based workspaces used by CLI and SDK clients.

Changes:

  • Introduces registry v2, explicit workspace IDs, retry deduplication, and channel-specific session attribution.
  • Adds source-folder management through REST, WebSocket payloads, and live engine updates.
  • Expands tests and updates English and Chinese API documentation.
File Description
packages/​node-sdk/​src/​sdk-rpc-client-v2.ts Changes implicit session-bucket lookup.
packages/​klient/​test/​facade.test.ts Updates workspace response fixtures.
packages/​klient/​src/​contract/​global/​workspaces.ts Adds source folders to workspace responses.
packages/​kap-server/​test/​workspaces.test.ts Tests explicit IDs, attribution, and folder management.
packages/​kap-server/​test/​workspaceLayout.test.ts Expects registry format v2.
packages/​kap-server/​src/​transport/​ws/​v1/​sessionEventBroadcaster.ts Includes source folders in lifecycle payloads.
packages/​kap-server/​src/​routes/​workspaces.ts Implements explicit creation and folder updates.
packages/​kap-server/​src/​routes/​sessions.ts Preserves explicit session-bucket selection.
packages/​kap-server/​src/​protocol/​workspace.ts Extends workspace IDs and request schemas.
packages/​agent-core-v2/​test/​workspace/​workspaceInstance/​workspaceInstanceManager.test.ts Updates manager fixtures and dependencies.
packages/​agent-core-v2/​test/​workspace/​workspaceDirs/​workspaceDirsService.test.ts Tests registry-folder merging and live updates.
packages/​agent-core-v2/​test/​app/​workspaceAliases/​workspaceAliasesService.test.ts Tests separation of explicit and implicit aliases.
packages/​agent-core-v2/​test/​app/​workspace/​workspaceService.test.ts Covers registry creation, persistence, and deletion.
packages/​agent-core-v2/​test/​app/​sessionExport/​sessionExport.test.ts Updates workspace service stubs.
packages/​agent-core-v2/​src/​workspace/​workspaceInstance/​workspaceInstanceManagerService.ts Passes registry dependencies to programs.
packages/​agent-core-v2/​src/​workspace/​workspaceDirs/​workspaceDirsService.ts Merges registry folders into active workspace directories.
packages/​agent-core-v2/​src/​program/​programDependencies.ts Declares registry dependencies.
packages/​agent-core-v2/​src/​program/​program.ts Supplies registry dependencies to directory services.
packages/​agent-core-v2/​src/​app/​workspaceAliases/​workspaceAliasesService.ts Separates alias namespaces and supports index-only lookup.
packages/​agent-core-v2/​src/​app/​workspace/​workspaceService.ts Implements explicit creation, touching, and folder replacement.
packages/​agent-core-v2/​src/​app/​workspace/​workspacePersistence.ts Extends persisted registry types.
packages/​agent-core-v2/​src/​app/​workspace/​workspaceAlias.ts Limits folding and rebuilds to implicit workspaces.
packages/​agent-core-v2/​src/​app/​workspace/​workspace.ts Extends workspace service interfaces.
packages/​agent-core-v2/​src/​app/​workspace/​fileWorkspacePersistence.ts Persists registry v2 and preserves unknown fields.
packages/​agent-core-v2/​src/​_base/​utils/​workdir-slug.ts Adds implicit workspace-ID detection.
docs/​zh/​reference/​server-api.md Documents the workspace API changes in Chinese.
docs/​en/​reference/​server-api.md Documents the workspace API changes in English.

Review effort: Balanced

…oots

resolveWithin no longer rejects absolute paths outright: any path
inside the workspace dir set (cwd plus the merged additional dirs)
passes the same containment and symlink guards as cwd-relative input,
while paths outside the set still fail with fs.path_escapes. fs:list
keys absolute-path responses relative to the requested root ('.' for
the top, request-root-relative for children) and resolves gitignore
rules against that root, so clients can switch the file-tree base
between a workspace's source folders without key-space drift.
Relative-path behavior is byte-identical.
…rkspace dir

Request-anchored keying broke deep browsing: listing a subdirectory of
an additional root re-anchored entry keys at that subdirectory, so the
client tree's key space shifted per request. Keys are now anchored at
the workspace dir (workdir or merged additional dir, longest match)
that contains the requested path, so a source folder has one stable
key space ('docs', 'docs/note.md') no matter which subpath is listed.
The longest-match comparison also no longer ties out additional roots
whose path length equals the workdir's.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2cc2ce5192

ℹ️ 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".

workspaceIdsFor now unions the directory's own hash bucket (plus
spelling aliases) with every registered workspace whose dir set
(root + additionalDirs) contains the directory, whether the directory
is the workspace's primary or a member root. TUI /sessions, startup
restore, kimi session/fork/export, and the VS Code folder session
list all inherit the widened view. REST and desktop listing stay
bucket-strict.
IWorkspaceService.setPrimary swaps root with an additional dir
atomically — the workspace id, session bucket, and all sessions are
untouched — and POST /workspaces/{id}/primary exposes it with
in-set/existence validation (40001/40409/40410). After a swap the
workspace instance is closed so the next materialization runs on the
new primary (local.toml follows the primary per the dir-merge rules);
registry-driven dirs keep flowing to live scopes through the
persistence change event.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 10cbac24ca

ℹ️ 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".

local.toml's workspace.additional_dir is now a legacy compatibility
input: it keeps being read and honored, is imported into the registry
once when a workspace is created or first edited (POST
/workspaces/{id}/import-project-config, and automatically on POST
/workspaces), and is cleared from the file after a successful import
while other keys are kept. TUI /add-dir 'remember' now writes the
registry entry directly (wm_ scope to the wm_ entry, hash scope to the
hash entry, registering on demand) instead of appending local.toml,
and the redundant POST /workspaces/{id}/add-dir endpoint is removed —
source-folder management lives on the workspace resource itself.
@github-actions

Copy link
Copy Markdown
Contributor

❌ Nix build failed

    kimi-code>    ╭─[ ../../packages/kap-server/src/routes/workspaces.ts:8:3 ]
    kimi-code>    │
    kimi-code>  8 │   IWorkspaceTrustStore,
    kimi-code>    │   ──────────┬─────────
    kimi-code>    │             ╰─────────── Missing export
    kimi-code>    │
    kimi-code>    │ Note: If you meant to import a type rather than a value, make sure to add the `type` modifier (e.g. `import { type Foo } from '@moonshot-ai/agent-core-v2'`).
    kimi-code> ───╯
    kimi-code> 
    kimi-code>     at aggregateBindingErrorsIntoJsError (file:///build/source/node_modules/.pnpm/[email protected]/node_modules/rolldown/dist/shared/error-D0SD8_tL.mjs:49:18)
    kimi-code>     at unwrapBindingResult (file:///build/source/node_modules/.pnpm/[email protected]/node_modules/rolldown/dist/shared/error-D0SD8_tL.mjs:19:128)
    kimi-code>     at #build (file:///build/source/node_modules/.pnpm/[email protected]/node_modules/rolldown/dist/shared/rolldown-CMhwwZPA.mjs:145:34)
    kimi-code>     at async build (file:///build/source/node_modules/.pnpm/[email protected]/node_modules/rolldown/dist/index.mjs:46:22)
    kimi-code>     at async Promise.all (index 0)
    kimi-code>     at async buildSingle (file:///build/source/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@vue+language-core_e075af6d78a5ff7f9606ba22fe4639f1/node_modules/tsdown/dist/build-KEepWO_k.mjs:823:19)
    kimi-code>     at async Promise.all (index 0)
    kimi-code>     at async buildWithConfigs (file:///build/source/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@vue+language-core_e075af6d78a5ff7f9606ba22fe4639f1/node_modules/tsdown/dist/build-KEepWO_k.mjs:770:18)
    kimi-code>     at async build$1 (file:///build/source/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@vue+language-core_e075af6d78a5ff7f9606ba22fe4639f1/node_modules/tsdown/dist/build-KEepWO_k.mjs:725:9)
    kimi-code>     at async CAC.<anonymous> (file:///build/source/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@vue+language-core_e075af6d78a5ff7f9606ba22fe4639f1/node_modules/tsdown/dist/run.mjs:21:2)
    kimi-code> Command failed: /nix/store/chsxa1iw7s3m51v4kj43yd1nw26xvi21-nodejs-24.15.0/bin/node /build/source/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@vue+language-core_e075af6d78a5ff7f9606ba22fe4639f1/node_modules/tsdown/dist/run.mjs --config tsdown.native.config.ts
    kimi-code> 
    kimi-code>  ERROR  Error: Build failed with 1 error:
    kimi-code> 
    kimi-code> [MISSING_EXPORT] "IWorkspaceTrustStore" is not exported by "../../packages/agent-core-v2/src/index.ts".
    kimi-code>    ╭─[ ../../packages/kap-server/src/routes/workspaces.ts:8:3 ]
    kimi-code>    │
    kimi-code>  8 │   IWorkspaceTrustStore,
    kimi-code>    │   ──────────┬─────────
    kimi-code>    │             ╰─────────── Missing export
    kimi-code>    │
    kimi-code>    │ Note: If you meant to import a type rather than a value, make sure to add the `type` modifier (e.g. `import { type Foo } from '@moonshot-ai/agent-core-v2'`).
    kimi-code> ───╯
    kimi-code> 
    kimi-code>     at aggregateBindingErrorsIntoJsError (file:///build/source/node_modules/.pnpm/[email protected]/node_modules/rolldown/dist/shared/error-D0SD8_tL.mjs:49:18)
    kimi-code>     at unwrapBindingResult (file:///build/source/node_modules/.pnpm/[email protected]/node_modules/rolldown/dist/shared/error-D0SD8_tL.mjs:19:128)
    kimi-code>     at #build (file:///build/source/node_modules/.pnpm/[email protected]/node_modules/rolldown/dist/shared/rolldown-CMhwwZPA.mjs:145:34)
    kimi-code>     at async build (file:///build/source/node_modules/.pnpm/[email protected]/node_modules/rolldown/dist/index.mjs:46:22)
    kimi-code>     at async Promise.all (index 0)
    kimi-code>     at async buildSingle (file:///build/source/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@vue+language-core_e075af6d78a5ff7f9606ba22fe4639f1/node_modules/tsdown/dist/build-KEepWO_k.mjs:823:19)
    kimi-code>     at async Promise.all (index 0)
    kimi-code>     at async buildWithConfigs (file:///build/source/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@vue+language-core_e075af6d78a5ff7f9606ba22fe4639f1/node_modules/tsdown/dist/build-KEepWO_k.mjs:770:18)
    kimi-code>     at async build$1 (file:///build/source/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@vue+language-core_e075af6d78a5ff7f9606ba22fe4639f1/node_modules/tsdown/dist/build-KEepWO_k.mjs:725:9)
    kimi-code>     at async CAC.<anonymous> (file:///build/source/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@vue+language-core_e075af6d78a5ff7f9606ba22fe4639f1/node_modules/tsdown/dist/run.mjs:21:2)
    kimi-code> 
    kimi-code> 
    kimi-code> /build/source/apps/kimi-code:
    kimi-code>  ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL  @moonshot-ai/[email protected] build:native:sea: `node scripts/native/build.mjs --profile=local`
    kimi-code> Exit status 1
    error: Cannot build '/nix/store/r52czgg0wcfarmgjhmi4ak0vq4b7hfql-kimi-code-2.3.0.drv'.
           Reason: builder failed with exit code 1.
           Output paths:
             /nix/store/1df7b05zj85zxhd7gcsqb07yfxm0gpwf-kimi-code-2.3.0
           Last 25 log lines:
           > [MISSING_EXPORT] "IWorkspaceTrustStore" is not exported by "../../packages/agent-core-v2/src/index.ts".
           >    ╭─[ ../../packages/kap-server/src/routes/workspaces.ts:8:3 ]
           >    │
           >  8 │   IWorkspaceTrustStore,
           >    │   ──────────┬─────────
           >    │             ╰─────────── Missing export
           >    │
           >    │ Note: If you meant to import a type rather than a value, make sure to add the `type` modifier (e.g. `import { type Foo } from '@moonshot-ai/agent-core-v2'`).
           > ───╯
           >
           >     at aggregateBindingErrorsIntoJsError (file:///build/source/node_modules/.pnpm/[email protected]/node_modules/rolldown/dist/shared/error-D0SD8_tL.mjs:49:18)
           >     at unwrapBindingResult (file:///build/source/node_modules/.pnpm/[email protected]/node_modules/rolldown/dist/shared/error-D0SD8_tL.mjs:19:128)
           >     at #build (file:///build/source/node_modules/.pnpm/[email protected]/node_modules/rolldown/dist/shared/rolldown-CMhwwZPA.mjs:145:34)
           >     at async build (file:///build/source/node_modules/.pnpm/[email protected]/node_modules/rolldown/dist/index.mjs:46:22)
           >     at async Promise.all (index 0)
           >     at async buildSingle (file:///build/source/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@vue+language-core_e075af6d78a5ff7f9606ba22fe4639f1/node_modules/tsdown/dist/build-KEepWO_k.mjs:823:19)
           >     at async Promise.all (index 0)
           >     at async buildWithConfigs (file:///build/source/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@vue+language-core_e075af6d78a5ff7f9606ba22fe4639f1/node_modules/tsdown/dist/build-KEepWO_k.mjs:770:18)
           >     at async build$1 (file:///build/source/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@vue+language-core_e075af6d78a5ff7f9606ba22fe4639f1/node_modules/tsdown/dist/build-KEepWO_k.mjs:725:9)
           >     at async CAC.<anonymous> (file:///build/source/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@vue+language-core_e075af6d78a5ff7f9606ba22fe4639f1/node_modules/tsdown/dist/run.mjs:21:2)
           >
           >
           > /build/source/apps/kimi-code:
           >  ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL  @moonshot-ai/[email protected] build:native:sea: `node scripts/native/build.mjs --profile=local`
           > Exit status 1
           For full logs, run:
             nix log /nix/store/r52czgg0wcfarmgjhmi4ak0vq4b7hfql-kimi-code-2.3.0.drv

…ce routes

The previous commit accidentally swept an in-progress trust-store
refactor (IWorkspaceTrustStore import, resolveTrust via the store, and
its no-materialization test) into the add-dir removal — those files
are not part of this branch. This restores the two contaminated files
to their intended contents: the import-project-config endpoint and its
tests, the add-dir endpoint and its tests removed, nothing else.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8a9bb83bfc

ℹ️ 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".

Comment thread packages/node-sdk/src/types.ts Resolved
… constructor

A swept-in worktree change raised the filler count for a constructor
parameter that does not exist on this branch, which misaligned the
unit-host factory argument and failed the whole file on CI.
…dirs endpoint

local.toml becomes a purely read-only legacy input: nothing in core
writes it anymore. Workspace creation no longer merges the primary's
additional_dir, and the import-project-config endpoint (unreleased) is
removed together with the registry-side importProjectConfig method and
the clear-after-import write path.

Migration is driven explicitly by clients through the new
GET /workspaces/project-config-dirs endpoint, which resolves a
project's local.toml additional_dir without mutating the registry or
the file, so a create/edit form can union the result and persist
through the normal save path.
…aces

Workspaces now carry a persisted kind: managed for explicitly created
entries (wm_ ids) and implicit for directory-anchored ones (wd_ ids,
including everything that predates the field). The kind rides through
WorkspaceMeta into the workspace DI scope, so WorkspaceDirsService
gates on a stored fact rather than the id string format.

Managed workspaces treat the registry as the single source of truth:
their sessions no longer merge or watch the project's local.toml.
Implicit workspaces keep the legacy merge untouched, so TUI/CLI
sessions anchored by cwd see no behavior change. The kind is exposed
on the kap-server workspace wire and mirrored in the klient contract.
@liruifengv
liruifengv marked this pull request as draft October 22, 2026 13:40

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 27b2113d8b

ℹ️ 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".

Migrate the registry to projects.json without rewriting the legacy file. Serialize cross-process updates and preserve unrelated records and extension fields.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2cababb5b4

ℹ️ 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".

Comment thread docs/en/reference/server-api.md Resolved
@liruifengv

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b917d41e33

ℹ️ 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".

@liruifengv

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 638f0e770d

ℹ️ 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".

@liruifengv

Copy link
Copy Markdown
Collaborator Author

@codex review

1 similar comment
@liruifengv

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 39112c240f

ℹ️ 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".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 730cca00a1

ℹ️ 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".

@liruifengv
liruifengv merged commit 093e8f4 into main Oct 28, 2026
16 checks passed
@liruifengv
liruifengv deleted the feat/multi-root-workspace branch October 28, 2026 07:28
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Nov 4, 2026
…t land yet

Both need multi-root workspace registration (MoonshotAI#4336): the REST create and
update schemas carry only `root` and `name`, so there is no
`additional_dirs` field to pass through or to de-duplicate. MoonshotAI#4511's fs
half is already in place — resolveWorkspaceFs forwards
ws.additionalDirs — so it stays in_progress with that note rather than
being closed or signed off.
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Nov 4, 2026
First slice of upstream MoonshotAI/kimi-code 093e8f4 (MoonshotAI#4336).

The registry only had `createOrTouch`, which derives an id from the root
path and cannot carry a name or source folders from the caller. Managed
creation arrives alongside it:

- `create({ root, name?, additionalDirs?, idempotencyKey? })` mints a
  `wm_` id, keeps the kind `managed`, and records the idempotency key in
  the catalog so a retried request returns the same workspace, including
  across a restart.
- `touch(id)` bumps `lastOpenedAt` after re-checking the root still
  exists, and `setPrimary(id, path)` swaps a registered source folder
  into the root, moving the old root into the folder list.
- `additionalDirs` are validated and de-duplicated by root key, and a
  directory equal to the root itself is dropped.

Fork adaptations: the catalog keeps the fork's `deletedIds` shape and
gains an optional `idempotencyKeys` map persisted next to it;
`createOrTouch` is untouched, so the fork's hash-id path and its
`fs.path_not_found` mapping stay exactly as they were.

Not in this slice: `readProjectConfigDirs` needs the project local
config, which lives in the node-fs backend scope and is not injectable
into an app-scoped service here.

Verified: agent-core-v2 typecheck clean, the workspace service suite is
34 pass / 1 skip / 0 fail including three new cases for create, retry
dedupe, touch and setPrimary, and check:no-comments is green.
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Nov 4, 2026
Second slice of upstream MoonshotAI/kimi-code 093e8f4 (MoonshotAI#4336).

`POST /workspaces` now accepts `additional_dirs` and `idempotency_key`
and routes to the new managed creation when either is present, while a
bare `root`/`name` keeps the existing create-or-touch behaviour. The
workspace wire object carries `kind` and `additional_dirs`, and ids may
now be either the existing `wd_<slug>_<hash12>` form or the new
`wm_<uuid>`.

The new route case pins the whole path: a managed id, `kind: managed`,
the source folder echoed back, and a retried request returning the same
workspace.

Verified: kap-server typecheck clean, the workspaces suite is 24 pass /
1 fail, where that failure (legacy split-bucket session counts) fails
identically before this change, and check:no-comments is green.
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Nov 4, 2026
…MoonshotAI#4513

MoonshotAI#4336 is in_progress: d07cc07 adds managed creation with retry-safe
ids and 0390f64 puts source folders on the REST and wire surfaces.
MoonshotAI#4513 lands on top of that in 718a3ae and is closed against a route
probe.

MoonshotAI#4511 keeps its fs-side forwarding, but its route-level cross-folder
search test is still missing, so it stays in_progress with a manual
probe rather than borrowing the workspace-creation case as evidence.
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Nov 4, 2026
Port of the search half of upstream MoonshotAI/kimi-code 093e8f4
(MoonshotAI#4336).

`fs:search` walked only the work directory, so a file living in a
registered source folder was invisible to the tool the model uses to
find files. The fuzzy branch now walks each root with its own gitignore
matcher and reports a non-primary root's hits as root-specific paths,
matching what `fs:suggest` has always done.

Fork adaptations: the empty-query branch still lists the work directory
only. Listing a second root means handing `list` an absolute path, which
this fork's `resolveWithin` refuses by design; giving it a per-root
anchor is the remaining part of the multi-root filesystem work and is
not smuggled in here.

The added case searches a workspace with one source folder and fails
when the walk is narrowed back to the work directory.
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Nov 4, 2026
Port of the list half of upstream MoonshotAI/kimi-code 093e8f4
(MoonshotAI#4336).

`fs:search` with an empty query could only see the work directory,
because listing a second root means handing `list` an absolute path and
this fork refuses absolutes outright. Absolute paths now anchor at the
nearest registered root — the same validation the git status work
already uses — and entries come back relative to that root.

`list` and the ignored-ancestor probe both take the resolved base
instead of reaching for the work directory, and each root keeps its own
gitignore matcher.

The added case lists a source folder by absolute path, then a directory
inside it, and asserts entries stay relative to the registered root.

Path confinement is unchanged: absolut es are accepted only when they
resolve inside a registered root, the existing escape and symlink cases
still pass, and `resolveWithin` keeps rejecting absolutes for every
other caller.
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Nov 4, 2026
Port of the registry half of upstream MoonshotAI/kimi-code 093e8f4
(MoonshotAI#4336).

Source folders registered through `POST /workspaces` reached the
catalog but never the session: `WorkspaceDirsService` built its list
from local.toml and session-scoped additions only, so the filesystem and
search layers kept seeing one root no matter what the registry held.

`ProgramDependencies` now carries the workspace service,
`WorkspaceDirsService` takes it, and `additionalDirs` is the union of
the project-local config, the registry and the session-scoped entries.
The registry is read on ready and re-read after each `addDir`, matching
every workspace whose root set contains this session's working
directory and skipping the directory that is already the root.

Adaptation: this fork's `WorkspaceMeta` has no `kind`, so the upstream
managed/implicit split collapses to "the current workspace first, then
every other registered one" — the same filter result for the only case
that matters, a session looking up its own source folders.

The added case registers a workspace with one source folder and asserts
it reaches `additionalDirs`.
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Nov 4, 2026
Registry source folders now reach the session (ca6eec1), so the REST
surface added in 0390f64 is finally wired end to end. Three pieces
remain for the row: per-root change notifications, which need
`ISessionWorkspaceInfo.primaryByWorkspace` that this fork's interface
does not carry; `readProjectConfigDirs`, which has no consumer here; and
upstream's route-level tests.
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Nov 4, 2026
Port of the notification half of upstream MoonshotAI/kimi-code
093e8f4 (MoonshotAI#4336).

A session's directory set can change while it runs — a source folder is
added, or a folder becomes the primary root — but nothing told the agent,
so it kept working against a stale picture. `ISessionWorkspaceInfo` now
carries `primaryByWorkspace` next to `additionalDirs`, `IWorkspaceDirs`
gains `reload()`, and the change notifier diffs both against the beliefs
it last recorded and reminds once per change with the added and removed
directories.

Details that mirror upstream: the first observation only records a
baseline, a primary move is reported as a move rather than as an add plus
a remove, and the belief pair survives `ContextClear` and
`ContextApplyCompaction` while the rest of the snapshot resets.

Fork adaptations: the notifier reaches the info service through the
agent scope, so every harness stub that built `ISessionWorkspaceInfo` or
`IAgentChangeNotifierService` by hand needed the new members; the test
dispatcher stub also has to carry the two new belief fields, or the
snapshot never lands and the second change looks like the first.

Both cases fail when the reminder call is removed.
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Nov 4, 2026
d07cc07 managed creation with retry-safe ids, 0390f64 the REST and
wire surface, 14ba59e+a14144db88 cross-folder search and per-root
anchoring, ca6eec1 registry folders reaching the session,
d96993d the source-folder change reminder, 0cff84f the
workspace-scoped list route and upstream's four route tests.

One piece is deliberately not ported and the evidence says so:
readProjectConfigDirs. Upstream's only consumer is a REST route this
fork does not expose, and no code here calls it, so adding the service
method and the endpoint would be a speculative surface.

Ledger: closed 37 -> 38, remaining 61.
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Nov 11, 2026
Upstream MoonshotAI#4689 also clarifies the /workspaces/{id}/primary semantics, but that endpoint section belongs to the unported REST slice of upstream MoonshotAI#4336. The fork has no POST /workspaces/{id}/primary route, so the paragraph is not added rather than left dangling; the untrust wording matches the fork's WorkspaceTrustGroup.untrust, which revokes every root in the dir set.
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Nov 15, 2026
The web bundle aligned to upstream f082f04 calls endpoints this fork
never carried. Port the missing halves of two upstream changes.

MoonshotAI#4525: engine PluginMarketplaceService and PluginPackageCache,
PluginManager.inspect, per-record skills, PluginService.previewPlugin and
install-by-marketplaceId, plus GET /plugins/{id}, POST /plugins/preview,
the install request union and the full marketplace wire shape.

MoonshotAI#4336: IWorkspaceService.readProjectConfigDirs, POST
/workspaces/{id}/primary, GET /workspaces/project-config-dirs,
additional_dirs normalization on create/update and the upstream
dedupeByRoot split.

Free 40934 for plugin.catalog_changed by renumbering the prompt-optimizer
codes, and update the API surface snapshot, plugin and workspace tests,
the orphan-export baseline and the ledger rows.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants