Skip to content

refactor: rename the Workspace concept to Project - #5206

Merged
Grapedge merged 3 commits into
mainfrom
refactor/project-workdir-naming
Nov 25, 2026
Merged

Grapedge merged 3 commits into
mainfrom
refactor/project-workdir-naming

Conversation

@Grapedge

@Grapedge Grapedge commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

Requirement or Bug

这组改动的领域模型是:项目(Project)是会话和信任的归属,有主目录和附加目录;会话属于一个项目,记录自己的工作目录。agent-core-v2 的代码里一直把项目叫作 Workspace,和产品、文档里的「项目」对不上。这个 PR 把代码里的 Workspace 概念改名为 Project。它基于已合入的 #5204,只做机械改名,不改任何行为。

Bug Reproduction Steps

N/A,机械改名。

Root Cause

N/A,不是缺陷修复。

Code Changes

改名由一份映射表驱动的 codemod 完成(映射表不在仓库里,下面的改名清单就是它的内容):按符号改名(TypeScript 编译器的引用改写)、移动文件并改写导入路径、少量文本替换,最后重新生成三份清单。codemod 在改名后的提交上再跑一次没有任何变化。

三个提交:

  1. refactor(agent-core-v2): share the session count update:一个不改行为的小去重。会话索引的镜像和投影各自算一遍项目的会话计数,抽成 sessionIndexModel.ts 里的一个函数;extra agent 加载器的构造参数把 config 挪到目录之后。这两处是 main 上已有的重复片段,改名会改掉片段里的标识符,重复检查就会把它们算成新增,所以先消掉。
  2. refactor: rename the Workspace concept to Project:机械改名。
  3. chore: add a changeset for the Project rename。

改名的规模:

  • 104 个导出名改名,改写了 1,580 处;参数按规则改了 30 个。
  • 106 个文件移动(源码 80 个、测试 26 个):app/workspace/* 移到 app/project/*,workspace/* 移到 project/*,features/skill/workspace/* 移到 features/skill/project/*,导入路径随之改写。
  • scripts/checks/baselines/oxlint-ratchet.json 的键跟着文件路径改名,计数不变。
  • state 清单生成器:SCOPES 每项带上自己的状态服务名,FEATURES_RECEIVER_SCOPE 由它推导,不再另存一份名单;清单头部和分节注释里的接口名改成 IProjectStateService。
  • packages/agent-core-v2/AGENTS.md 里的标识符和一句中文跟着改名。

明确不改的:

  • 落盘和对外的名字:local.toml 的 [workspace] 段、projects.json 的字段、KAP 的 workspace_id 等字段和路由,以及 PersistedWorkspaceFile、LEGACY_WORKSPACES_KEY、WORKSPACE_TRUST_SECTION、TRUST_WORKSPACE_ENV、trustWorkspaceEnvTrusted、WORKSPACE_DIRS_CHANGE_VARIANT、WORKSPACE_ROOT_SKILL_SOURCE_ID 这些名字。
  • 所有字符串:DI 的 id(例如 createDecorator('workspaceService'))、状态键、事件名、错误码、配置键。debug RPC 和 klient 按字符串调用服务,所以这些都不能动。
  • 对象成员名(例如 workspaceId 字段):很多会被序列化或按名字远程调用,类型检查证明不了改名安全,留到之后单独处理。
  • 会话的 workspace context(ISessionWorkspaceContext 等):它管的是会话的工具能访问哪些目录,也就是工作目录加项目的附加目录,和环境的访问根(environmentWorkspaceView 等)是同一个概念,不是项目,所以和访问根一起保留原名。
  • 其他包自己的声明:kap-server、node-sdk、klient 只改导入和类型引用;klient 用 as 保住公开的 Workspace、WorkspaceUpdate 类型名。
  • 意思不同的名字:workspaceRootKey,以及另外 3 个指别的东西的名字。
改名清单(104 个名字)
  • src/_base/utils/paths.ts:canonicalWorkspaceRoot → canonicalProjectRoot
  • src/agent/changeNotifier/changeNotifierService.ts:diffWorkspaceDirs → diffProjectDirs,WorkspaceDirsChanges → ProjectDirsChanges,workspaceDirsChangeText → projectDirsChangeText,WorkspacePrimaryChange → ProjectPrimaryChange
  • src/app/sessionIndex/sessionIndexModel.ts:SessionWorkspaceCounts → SessionProjectCounts
  • src/app/sessionIndex/sessionIndexService.ts:samePrimaryByWorkspace → samePrimaryByProject
  • src/app/sessionIndex/sessionIndexSource.ts:listWorkspaceIds → listProjectIds
  • src/app/telemetry/events.ts:WorkspaceTrustChangedEvent → ProjectTrustChangedEvent,WorkspaceTrustReadFailedEvent → ProjectTrustReadFailedEvent
  • src/app/workspace/errors.ts:WorkspaceErrors → ProjectErrors
  • src/app/workspace/fileWorkspacePersistence.ts:FileWorkspacePersistence → FileProjectPersistence,WORKSPACE_CATALOG_SCOPE → PROJECT_CATALOG_SCOPE
  • src/app/workspace/workspace.ts:IWorkspaceService → IProjectService,Workspace → Project,WorkspaceCreate → ProjectCreate,WorkspaceKind → ProjectKind,WorkspaceUpdate → ProjectUpdate
  • src/app/workspace/workspaceEvents.ts:WorkspaceCreated → ProjectCreated,WorkspaceCreatedPayload → ProjectCreatedPayload,WorkspaceDeleted → ProjectDeleted,WorkspaceDeletedPayload → ProjectDeletedPayload,WorkspaceUpdated → ProjectUpdated,WorkspaceUpdatedPayload → ProjectUpdatedPayload
  • src/app/workspace/workspacePersistence.ts:IWorkspacePersistence → IProjectPersistence,PersistedWorkspaceEntry → PersistedProjectEntry,WorkspaceCatalog → ProjectCatalog,WorkspaceCatalogMutator → ProjectCatalogMutator
  • src/app/workspace/workspaceProtocol.ts:Workspace → Project,WorkspaceCreatedEvent → ProjectCreatedEvent,WorkspaceDeletedEvent → ProjectDeletedEvent,WorkspaceUpdatedEvent → ProjectUpdatedEvent
  • src/app/workspace/workspaceService.ts:WorkspaceService → ProjectService
  • src/app/workspaceAliases/workspaceAliases.ts:IWorkspaceAliases → IProjectAliases
  • src/app/workspaceAliases/workspaceAliasesService.ts:WorkspaceAliasesService → ProjectAliasesService
  • src/app/workspaceSessions/workspaceSessions.ts:IWorkspaceSessions → IProjectSessions
  • src/app/workspaceSessions/workspaceSessionsService.ts:WorkspaceSessionsService → ProjectSessionsService
  • src/features/skill/workspace/rootFileSkillSource.ts:IWorkspaceRootSkillSource → IProjectRootSkillSource,WorkspaceRootSkillSource → ProjectRootSkillSource
  • src/features/skill/workspace/workspaceSkillCatalog.ts:IWorkspaceSkillCatalog → IProjectSkillCatalog
  • src/features/skill/workspace/workspaceSkillCatalogService.ts:workspaceSkillCatalogContributionsKey → projectSkillCatalogContributionsKey,workspaceSkillCatalogMergedKey → projectSkillCatalogMergedKey,WorkspaceSkillCatalogService → ProjectSkillCatalogService
  • src/session/sessionContext/sessionContext.ts:SessionWorkspaceAssociationSnapshot → SessionProjectAssociationSnapshot,snapshotSessionWorkspaceAssociation → snapshotSessionProjectAssociation
  • src/session/workspaceInfo/workspaceInfo.ts:ISessionWorkspaceInfo → ISessionProjectInfo,sessionWorkspaceInfoSeed → sessionProjectInfoSeed
  • src/workspace/sessionLifecycle/internal/addressing.ts:workspacePersistenceScope → projectPersistenceScope
  • src/workspace/state/workspaceState.ts:IWorkspaceStateService → IProjectStateService
  • src/workspace/state/workspaceStateService.ts:WorkspaceStateService → ProjectStateService
  • src/workspace/workspaceAgentProfileLoader/workspaceAgentProfileLoader.ts:IWorkspaceAgentProfileLoader → IProjectAgentProfileLoader
  • src/workspace/workspaceAgentProfileLoader/workspaceAgentProfileLoaderService.ts:WorkspaceAgentProfileLoaderService → ProjectAgentProfileLoaderService
  • src/workspace/workspaceContext/workspaceContext.ts:IWorkspaceContext → IProjectContext,workspaceContextSeed → projectContextSeed,WorkspaceMeta → ProjectMeta,WorkspaceSource → ProjectSource
  • src/workspace/workspaceDirs/workspaceDirs.ts:IWorkspaceDirs → IProjectDirs,WorkspaceAddDirInput → ProjectAddDirInput,WorkspaceAdditionalDirsResult → ProjectAdditionalDirsResult
  • src/workspace/workspaceDirs/workspaceDirsService.ts:samePrimaryByWorkspace → samePrimaryByProject,workspaceDirsEphemeralDirsKey → projectDirsEphemeralDirsKey,workspaceDirsFileDirsKey → projectDirsFileDirsKey,workspaceDirsPrimaryByWorkspaceKey → projectDirsPrimaryByProjectKey,workspaceDirsRegistryDirsKey → projectDirsRegistryDirsKey,WorkspaceDirsService → ProjectDirsService
  • src/workspace/workspaceFs/fs.ts:IWorkspaceFsService → IProjectFsService
  • src/workspace/workspaceFs/fsService.ts:WorkspaceFsService → ProjectFsService
  • src/workspace/workspaceGit/workspaceGit.ts:IWorkspaceGitService → IProjectGitService
  • src/workspace/workspaceGit/workspaceGitService.ts:WorkspaceGitService → ProjectGitService
  • src/workspace/workspaceInstance/workspaceInstance.ts:WorkspaceInstance → ProjectInstance,WorkspaceInstanceLifecycle → ProjectInstanceLifecycle,WorkspaceInstanceSnapshot → ProjectInstanceSnapshot
  • src/workspace/workspaceInstance/workspaceInstanceManager.ts:IWorkspaceInstanceManager → IProjectInstanceManager,WorkspaceInstanceChange → ProjectInstanceChange,WorkspaceInstanceLease → ProjectInstanceLease,WorkspaceInstanceRef → ProjectInstanceRef,WorkspaceInstancesSnapshot → ProjectInstancesSnapshot
  • src/workspace/workspaceInstance/workspaceInstanceManagerService.ts:WorkspaceInstanceManager → ProjectInstanceManager
  • src/workspace/workspaceInstructions/workspaceInstructions.ts:IWorkspaceInstructionsService → IProjectInstructionsService,WorkspaceInstructionsSnapshot → ProjectInstructionsSnapshot
  • src/workspace/workspaceInstructions/workspaceInstructionsService.ts:workspaceInstructionsCurrentKey → projectInstructionsCurrentKey,WorkspaceInstructionsService → ProjectInstructionsService
  • src/workspace/workspaceMcp/workspaceMcp.ts:IWorkspaceMcpService → IProjectMcpService
  • src/workspace/workspaceMcp/workspaceMcpService.ts:WorkspaceMcpService → ProjectMcpService
  • src/workspace/workspaceMcpConfig/workspaceMcpConfig.ts:IWorkspaceMcpConfigService → IProjectMcpConfigService
  • src/workspace/workspaceMcpConfig/workspaceMcpConfigService.ts:WorkspaceMcpConfigService → ProjectMcpConfigService
  • src/workspace/workspaceTrust/configSection.ts:DEFAULT_WORKSPACE_TRUST_CONFIG → DEFAULT_PROJECT_TRUST_CONFIG,WorkspaceTrustConfig → ProjectTrustConfig,WorkspaceTrustConfigSchema → ProjectTrustConfigSchema,workspaceTrustRequired → projectTrustRequired
  • src/workspace/workspaceTrust/trustDisclosure.ts:IWorkspaceTrustDisclosure → IProjectTrustDisclosure
  • src/workspace/workspaceTrust/trustDisclosureService.ts:WorkspaceTrustDisclosureService → ProjectTrustDisclosureService
  • src/workspace/workspaceTrust/trustRecord.ts:deleteWorkspaceTrust → deleteProjectTrust,migrateWorkspaceTrust → migrateProjectTrust,readWorkspaceTrust → readProjectTrust,writeWorkspaceTrust → writeProjectTrust
  • src/workspace/workspaceTrust/workspaceTrust.ts:IWorkspaceTrust → IProjectTrust,WorkspaceTrustChange → ProjectTrustChange
  • src/workspace/workspaceTrust/workspaceTrustService.ts:WorkspaceTrustService → ProjectTrustService,workspaceTrustTrustedKey → projectTrustTrustedKey
  • src/workspace/workspaceTrust/workspaceTrustStore.ts:IWorkspaceTrustEntry → IProjectTrustEntry,IWorkspaceTrustStore → IProjectTrustStore,WorkspaceTrustEntry → ProjectTrustEntry,WorkspaceTrustStore → ProjectTrustStore

Behavior Changes and Affected Users

没有行为变化。packages/kap-server/schema/contract.txt 和 wire-manifest.d.ts 逐字节不变;config-manifest.toml 只有 4 行注释里的源码路径变了,state-manifest.d.ts 只有 15 行里的注释变了(源码路径和 IProjectStateService 等类型名,其中一处是声明行末尾的行内注释),声明本身没有变化。packages/kap-server/docs/kap.md 和 packages/node-sdk/src/index.ts 没有改动。依赖 agent-core-v2 深路径导入的代码(app/workspace/*、workspace/* 等)需要换成新路径,仓库内的调用方都已改好。

验证
  • feat: group implicit projects by git repository #5204 合入后已变基到 main 的 e6b16c44d5,本机通过了完整的 pnpm lint、pnpm run check:duplication origin/main(0 新增克隆)、11 个非 app-* 包与 CLI/测试套件的 tsc --noEmit、桌面端 typecheck,以及 kap-server、acp-server、klient、agent-core-v2(app/project、app/sessionIndex、project)和 node-sdk 共 30 个测试文件、873 条用例。
  • packages/kap-server/schema/contract.txt、openapi.json 和 packages/node-sdk/src/index.ts 无差异。
  • 更早一次变基到 main 的 2679368ca(在 feat: group implicit projects by git repository #5204 上)时,CI 全部通过,Codex 评审未提出问题;更早基底 b5da9bcb1 上在改名前后各跑过一遍全量测试并逐项比对,行为一致。

这是机械改名,共 221 个文件,+1,924/−1,907 行。

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue (external PRs: issue must have a maintainer's /approve).
  • I have added tests that prove my feature works.
  • The behavior-change table above is complete, and every removed behavior or flipped default is named in the changeset and either has an escape hatch or was explicitly approved by a maintainer in this PR.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

@changeset-bot

changeset-bot Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7317d09

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@moonshot-ai/agent-core-v2 Patch
@moonshot-ai/kap-server Patch
@moonshot-ai/klient Patch
@moonshot-ai/kimi-code-sdk Patch

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-25T10:22:05.720621Z 7317d09 Draft marked ready
ℹ️ 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 Nov 21, 2026 •

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

commit: 7317d09

@Grapedge
Grapedge added this pull request to stack #5225 November 22, 2026 15:17
@Grapedge
Grapedge force-pushed the refactor/project-workdir-naming branch from 5bf654a to 603d3c5 Compare November 23, 2026 06:07
@Grapedge
Grapedge force-pushed the refactor/project-workdir-naming branch from 603d3c5 to 7ae95ee Compare November 23, 2026 06:16
@Grapedge
Grapedge force-pushed the refactor/project-workdir-naming branch from 7ae95ee to a8b526a Compare November 23, 2026 06:58
@Grapedge
Grapedge force-pushed the refactor/project-workdir-naming branch from a8b526a to e2b0a03 Compare November 23, 2026 07:46
@Grapedge
Grapedge force-pushed the refactor/project-workdir-naming branch from e2b0a03 to 6ce7e5d Compare November 23, 2026 08:30
@Grapedge
Grapedge force-pushed the refactor/project-workdir-naming branch from 6ce7e5d to 6d4b884 Compare November 23, 2026 09:25
@Grapedge
Grapedge force-pushed the refactor/project-workdir-naming branch from 6d4b884 to 713319a Compare November 23, 2026 09:34
@Grapedge
Grapedge force-pushed the refactor/project-workdir-naming branch from 713319a to 8e856fc Compare November 23, 2026 10:33
@Grapedge
Grapedge force-pushed the refactor/project-workdir-naming branch from 8e856fc to 6aa20cb Compare November 23, 2026 12:50
@Grapedge
Grapedge force-pushed the refactor/project-workdir-naming branch 2 times, most recently from c96903f to 1b433e0 Compare November 24, 2026 21:20
@Grapedge
Grapedge force-pushed the refactor/project-workdir-naming branch 2 times, most recently from 0a6aa0a to 2c9804b Compare November 25, 2026 07:18
@Grapedge

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: 2c9804bf72

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

@Grapedge
Grapedge force-pushed the refactor/project-workdir-naming branch from 2c9804b to b40e87b Compare November 25, 2026 07:58
@Grapedge
Grapedge marked this pull request as draft November 25, 2026 09:15
Base automatically changed from feat/worktree-project-grouping to main November 25, 2026 10:14
The index mirror and the projector computed a workspace's session counts
separately. The extra agent profile loader takes its config after the
directories, so that its parameter list no longer repeats the explicit
loader's. The rename that follows would otherwise make both fragments count
as new duplicates.
agent-core-v2 now names the project the way the domain model does. The
persisted project entity, the per-project layer under src/workspace (now
src/project) and the session's view of its project carry the Project
name.

The change is mechanical. The type checker renames 104 top-level
declarations and the 30 parameters typed with them; 106 files move
(80 source, 26 test) and 443 import specifiers in 129 files follow
them. The other packages change only their imports and type
references, and klient re-exports the renamed types under their old
public names. The state-manifest generator now names each scope's state
service, so the regenerated state and config manifests differ only in
source paths and type names inside comments. The wire manifest and the
KAP contract are byte-identical.

Kept as they are:
- every string: DI ids, state keys, event types, error codes, the
  [workspace] config section and its fields, environment variables,
  storage names, telemetry event names, KAP paths and fields;
- member names such as workspaceId, local variables and test-local
  declarations;
- the session's workspace context and the tools' access roots, which
  hold the directories a session's tools may reach, not the project;
- names tied to persisted or external values: the legacy
  workspaces.json shape and key, the trust config section and
  environment variable, the workspace_dirs_change reminder variant and
  the workspace skill source id;
- workspaceRootKey, a path key shared by project roots, working
  directories and additional directories, and three names whose
  workspace means something else (the Tower checkout, the
  [environments] section, the workspaces.json migration record);
- the scope wording of the state manifest.
@Grapedge
Grapedge force-pushed the refactor/project-workdir-naming branch from b40e87b to 7317d09 Compare November 25, 2026 10:19
@Grapedge
Grapedge marked this pull request as ready for review November 25, 2026 10:19
@Grapedge
Grapedge merged commit c6dec96 into main Nov 25, 2026
30 of 31 checks passed
@Grapedge
Grapedge deleted the refactor/project-workdir-naming branch November 25, 2026 11:20
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Nov 25, 2026
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.
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Nov 25, 2026
…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.
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Nov 26, 2026
Reverse the earlier Workspace-as-fork-term verdict: files and symbols follow
upstream's Project rename, while fork-only features stay. Record the
preservation list and reopen the row for the mechanical port.
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Nov 26, 2026
…oonshotAI#5206)

Apply the file-move layer of the upstream Workspace -> Project rename: 95
modules and their tests move to the project paths (app/project,
project/projectFs, project/projectInstance, project/sessionLifecycle and
the rest), and every alias and relative import follows. The structural
files that upstream deletes and recreates (project.ts, projectEvents.ts,
projectContext, projectInstanceManager, projectTrust/configSection,
projectState, the profile-loader barrel) move with them.

Symbols still carry their Workspace names; the declaration rename is the
next batch. Verified: agent-core-v2 typecheck clean, the moved project
suites 107 pass / 3 skip, check:no-comments OK.
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Nov 26, 2026
…onshotAI#5206)

Apply the declaration half of the upstream rename: the 40 exported
Workspace* symbols and their references become Project*, together with
the engine imports. The upstream preservation list stays untouched: DI
ids, state keys, event/error strings, workspaceId, workspaceRootKey, the
persisted workspace formats and the fork's test-local helpers.

Verified: agent-core-v2 typecheck clean, the project suites 440 pass /
5 skip, check:no-comments OK.
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Nov 26, 2026
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Nov 26, 2026
Rename the remaining engine type references in klient, node-sdk,
kap-server, acp-server, migration-legacy, product and the apps. klient
keeps its public Workspace/WorkspaceUpdate aliases; the preserved strings
(DI ids, KAP fields, config sections, workspaceId/workspaceRootKey) stay.
The bare Workspace/Kind/Create/Update/Instance types become Project*,
the state and config manifests are regenerated, and the engine
AGENTS/DEVELOP wording follows.

Verified: the affected packages typecheck clean; project 440, kap
sessions/workspaces 163, node-sdk list-sessions, acp lifecycle and CLI
print tests pass; check:no-comments OK.
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Nov 26, 2026
Engine and consumer packages now use the upstream Project names while
keeping klient's public aliases and the preserved protocol strings.
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