feat: 源文件夹支持标记为可写,允许一次会话改多个仓库
- Dominant language
- TypeScript
- Stars
- 2.7k
- Forks
- 401
- Avg merge
- 21h 48m
- Merged PRs (30d)
- 776
Description
### 使用场景 / Use case
一个业务项目由多个 repo 组成(主服务 + SDK + 共享 proto/schema + 前端)。改一个接口经常要同时动两三个仓:服务端改实现、SDK 改契约、前端改调用。
期望在「创建项目 → 源文件夹」里加进这些仓之后,能在同一个任务里把它们都改掉,而不是每个仓单独开一个任务、来回切上下文。
### 当前问题 / Current limitation
源文件夹列表里只有标记「主要」的那个可写,其余一律只读。而且两个 vendor 的行为还不一致:
- Codex 侧是硬锁。`packages/maker-core/src/agents/codex/index.ts:465` 定义了 `cindy-readonly-references` permission profile,`:3200-3216` 把 `:workspace_roots` 显式设成 `'read'`,只有 `opts.workingDir` 给 `'write'`。副仓写入被 sandbox 直接挡掉。
- Claude 侧是软策略。`packages/maker-core/src/agents/shared/auto-review.ts:99-108` 把可写根截成 `workspaceRoots.slice(0, 1)`,区外写返回 `'prompt'` 升级人工确认,批准后仍可写。
同一份项目配置换个 vendor 行为就变,用户没有任何提示。
更关键的是,Codex 底层本来就支持可写多根:`codex --add-dir ` 的官方描述是 "Additional directories that should be **writable** alongside the primary workspace"。Cindy 是在上层主动把这个能力降级了,代码注释里只写了「额外目录是只读引用上下文」这个断言,没有说明为什么。
### 期望方案 / Proposed solution
给每个源文件夹加一个「可写」开关,默认关(保持现有行为和向下兼容)。
- 创建/编辑项目弹窗里,每行文件夹右侧加 checkbox 或「只读 / 可写」切换。
- Codex:在 `readonlyReferencesConfig` 的 filesystem map 里给被标记的路径写 `'write'`,与 `codexExtraWritableRoots` 同一条路子。
- Claude:`auto-review.ts` 的 `writableRoots` 不再固定 `slice(0, 1)`,改成按标记过滤。
- 聊天输入框的「引用目录(只读)」菜单(`apps/desktop/src/renderer/components/new-chat/ExtraDirsButton.tsx:517`)同步支持,标题文案随之调整。
- 会话里 agent 需要知道哪些根可写,避免它在只读仓里反复试探。
需要一并考虑的:多仓可写之后 git 操作的归属判断(agent 容易在错的仓 commit),以及 auto-review 的红线是否要按仓分别配置。
### 已考虑的替代方案 / Alternatives considered
1. 建一个父目录把所有 repo 放进去,用父目录当主要文件夹。可行但 grep/索引范围变大,agent 分不清当前该在哪个仓提交,而且要求用户改磁盘布局。
2. 每个仓单开一个任务。上下文割裂,跨仓改接口时两边容易对不齐。
3. 改成 monorepo 或 submodule。改造成本远超收益,且不是所有项目都能合。
4. 保持只读,只在需要写时手动把副仓切成「主要」。每次切换要重开任务,摩擦跟方案 2 一样。
Contributor guide
Research direction
Start with the Codex permission handling at packages/maker-core/src/agents/codex/index.ts:465 and :3200-3216, then inspect packages/maker-core/src/agents/shared/auto-review.ts:99-108. Trace how source-folder settings reach the desktop UI, including apps/desktop/src/renderer/components/new-chat/ExtraDirsButton.tsx:517. Done means selected roots are writable consistently for Codex and Claude, read-only roots remain protected, and the UI and agent guidance reflect each root’s setting.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- electron, typescript
- Domain
- desktop, developer-experience, devtools
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100