fix: Git Workflow 多 Session 并发隔离改造 - Closes #124
CI / test (pull_request) Successful in 22s

核心变更:
- _common.sh: setup_worktree 改为 session-unique detached worktree (origin/main)
- 所有 Agent 文档移除 git checkout main / git pull origin main
- Feature branch 统一从 origin/main 创建: git fetch origin && git checkout -b <branch> origin/main
- CLAUDE.md: 新增工作区隔离章节, primary worktree 定义为只读参考区
- 新增 start_generic.sh: Generic session worktree 隔离启动器

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-06-08 16:11:32 +08:00
parent 9629eb6ae0
commit e4f0b77ca8
9 changed files with 80 additions and 66 deletions
+8 -7
View File
@@ -67,16 +67,17 @@ export GITEA_USER=pzhang_dev_agent_01 # Dev-Agent 账号
- `C:\Users\peterz\projects\document_analyzer\docs\PROJECT_CHARTER.md`
- `C:\Users\peterz\projects\document_analyzer\docs\GLOBAL_STATE.md`
2. 确认环境变量已设置(GITEA_USER + ~/.gitea/config.yaml
3. `/loop 10m` 开启 10 分钟间隔的自动轮询
4. 轮询内容(多轮递进):
3. 确认当前在独立的 git worktree 中(启动脚本已自动切到 `~/.gitea/worktrees/<user>/<timestamp>/`),不与其他 agent 共享工作目录。工作区始终基于 origin/main,请勿 checkout main 分支
4. `/loop 10m` 开启 10 分钟间隔的自动轮询
5. 轮询内容(多轮递进):
a. `--action list --labels product-code` — 先捡带 `product-code` 标签的 Issue
b. `--action list` 无过滤,筛选 title 带 `[product]` 前缀的无标签 Issue
c. `--action blocked-check` — 检查 blocked Issue,若阻塞已解除则自动移除 blocked 标签
d. 都无则分析无标签、无标识的 Issue,判断是否在 Dev 域内
5. 有 Issue → 走完整闭环处理(分析 → 开发 → push → PR → CI → merge → 自行验证 → 关闭)
6. 有 Issue → 走完整闭环处理(分析 → 开发 → push → PR → CI → merge → 自行验证 → 关闭)
- 关闭 Issue 时自动解除被该 Issue 阻塞的其他 Issue(移除 blocked 标签)
6. 无 Issue → 报告 "main healthy,无待处理 Issue",等待下次轮询
7. 同时保持对话开放,随时响应用户指令
7. 无 Issue → 报告 "main healthy,无待处理 Issue",等待下次轮询
8. 同时保持对话开放,随时响应用户指令
## 上下文管理
Context window 有限。当 session 持续较长时间时:
@@ -117,8 +118,8 @@ python scripts/agent_poller.py --action get --issue N
### 3. 开发 / 修复
```
1. git pull origin main
2. git checkout -b dev/issue-N-<slug>
1. git fetch origin
2. git checkout -b dev/issue-N-<slug> origin/main
3. 修改代码 + 更新 UT
4. python -m pytest -v
5. git commit -m "fix: <描述> - Closes #N"