eust-w 0bcfbc13dd feat(ide): push IDE work to ide/ branches and merge it through a verified wish
People's changes now reach the target branch the same way the agent's do. The
IDE credential carries a ref prefix and the Git service runs a pre-receive hook
on every push that refuses updates outside it, so the IDE can push only
`ide/` branches; the platform's own integration is unaffected.

- A wish may name a source branch. The run starts from that branch's head, the
  agent builds on it, and verification, repair rounds, merging onto a moved
  target and conflict repair work as before. A missing branch makes the run
  wait (git_storage) until it is pushed.
- Release risk is now computed from the target branch before integration, not
  from where the run started: a migration committed on the source branch would
  otherwise have been missed and could have skipped approval.
- Clones work on `ide/work`; a plain `git push` publishes it.
- The console lists a project's IDE branches with a button to submit a wish
  that merges one, and the new-wish form has a starting-point field; MCP
  `submit_wish` accepts `sourceBranch`. The Git service lists branches under
  a prefix for this (`POST /refs`).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 19:17:14 +08:00
..

IDE 策略扩展(@wishforge/ide-policy)

随 IDE 一起构建的 Theia 1.76 前后端扩展,做三件事:

  1. 扩展白名单(FR-H5):后端替换 Theia 的插件服务与部署器。安装、卸载、启用、停用一律返回 EXTENSIONS_MANAGED_BY_ADMIN;启动时只加载 WF_IDE_MANAGED_PLUGINS_DIR 中、列在 managed-plugins.lock.json(以及 scripts/python-debugger.lock.json)里的扩展,并逐个核对扩展 ID、版本与目录内容摘要。符号链接与特殊文件被拒绝,目录未配置时后端拒绝启动插件部署。前端在用户尝试安装扩展时说明扩展由管理员通过镜像构建统一管理。
  2. 按工作区隔离的协作(FR-H3):替换 @theia/collaboration 的前端贡献,只有当 WF_COLLABORATION_GATEWAY_URL 指向当前已认证工作区的网关协作路由时才注册房间命令与状态栏入口,否则协作保持关闭,不会退回公共 OCT 服务。OCT 令牌按实例保存,不复用其他工作区的令牌。协作连接的地址计算在 ../collaboration/client-factory.cjs 中。
  3. 项目仓库(FR-H2):后端提供 POST /wishforge-internal/git-credential,接收网关投递的仓库令牌(见 gateway/README.md)。
    • 访问控制:要求 Theia 的连接令牌,这个令牌只有网关持有。
    • 校验:请求必须严格符合格式,仓库地址必须与工作区配置一致。provisioner 设置 WISHFORGE_GIT_REMOTE 时只接受这一个仓库;本地共享的 Theia 设置 WISHFORGE_GIT_ORIGIN,接受这个 Git 服务上属于所投递项目的仓库。
    • 令牌存放:写入 WISHFORGE_GIT_CREDENTIAL_DIR 下的 <项目>.gitconfig(权限 0600,内容是 http.<仓库>.extraHeader 与提交身份),克隆通过 include.path 引用它。令牌不进入命令行、仓库文件或 .git/config;Kubernetes 中这个目录是内存卷。
    • 克隆:工作区中还没有该仓库的克隆时,把项目克隆到以项目命名的文件夹。同名文件夹已被占用时在名称后加上项目 ID 的前 8 位,两者都被占用时不克隆,从不覆盖已有文件。之后的投递只刷新令牌,项目改名后仍沿用原来的克隆。
    • 工作分支:克隆后切换到 ide/work(远端已有这个分支时跟踪它,否则从目标分支创建),并设置 push.default=current 与 push.autoSetupRemote=true,这样不带参数的 git push 就会发布这个分支。令牌只能推送 ide/ 开头的分支。
    • 身份覆盖:用户自己设置的 git config user.name / user.email 优先于平台给的身份。

IDE 与 Agent 之间只通过 Git commit 交接,扩展不提供保存屏障、草稿恢复或调试控制租约。

测试

node --test apps/ide/policy/test/*.test.cjs

测试覆盖插件安装接口被拒绝、白名单内容摘要校验与符号链接拒绝,以及用真实 Git 验证仓库的克隆、令牌刷新、提交身份、工作分支的发布与继续、不覆盖已有文件夹和拒绝其他仓库。需要先安装 IDE 依赖(npm run ide:install);npm run test:ide 会一并运行。

边界

Theia 后端与用户终端以同一个系统用户运行,扩展的限制可以被同一工作区中的恶意终端绕过;它约束的是正常使用路径,不是同一工作区内协作者之间的隔离。工作区之间的隔离依赖每个工作区独立的 Kata Pod 与网关。