Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c2affcad42 | |||
| 73291803b6 | |||
| e792fac6c0 | |||
| e71ab9715e | |||
| c31ddd0bb3 |
@@ -111,6 +111,18 @@ python scripts/agent_poller.py --action create-pr \
|
||||
Closes #N"
|
||||
```
|
||||
|
||||
PR 创建后,在 Issue 下评论 PR 链接:
|
||||
|
||||
```bash
|
||||
python scripts/agent_poller.py --action comment --issue N \
|
||||
--body "PR 已创建: <PR_URL>
|
||||
|
||||
变更:
|
||||
- <摘要>
|
||||
|
||||
等待 CI 通过后 merge。"
|
||||
```
|
||||
|
||||
### 5. 等待 CI
|
||||
|
||||
PR 创建后 CI 自动触发。用 agent_poller 监控状态:
|
||||
@@ -166,3 +178,33 @@ QE-Agent 开 Issue (qe-feedback)
|
||||
- **测试**:每次提交前必须确保 `python -m pytest -v` 全量通过
|
||||
- **范围**:不混入与当前 Issue 无关的改动
|
||||
- **PR**:Push 后立即创建 PR,CI 通过后 merge,PR 信息写入 Issue 后关闭
|
||||
|
||||
## agent_poller 命令速查
|
||||
|
||||
| 命令 | 用途 | 阶段 |
|
||||
|------|------|------|
|
||||
| `--action list` | 列出所有待处理 Issue | 1. 轮询 |
|
||||
| `--action get --issue N` | 查看 Issue 详情 | 2. 分析 |
|
||||
| `--action create-pr --issue N --branch X --body "..."` | 创建 PR | 4. 提 PR |
|
||||
| `--action comment --issue N --body "..."` | 评论 Issue(记录 PR 链接等) | 4. 提 PR |
|
||||
| `--action pr-status --pr N` | 查看 PR + CI 状态 | 5. 等 CI |
|
||||
| `--action merge-pr --pr N` | Merge PR(自动检查 CI) | 6. Merge |
|
||||
| `--action close-issue --issue N --body "..."` | 手动关闭 Issue | 6. 关闭 |
|
||||
| `--action lifecycle --issue N` | 查看 Issue 完整生命周期 | 随时 |
|
||||
|
||||
## 闭环完成检查清单
|
||||
|
||||
处理每个 Issue 时,确认以下节点全部完成:
|
||||
|
||||
- [ ] **分析**:`agent_poller.py --action get` 理解 Issue 内容
|
||||
- [ ] **分支**:`git checkout -b dev/issue-N-<slug>`
|
||||
- [ ] **开发**:修改功能代码 + 同步更新 UT
|
||||
- [ ] **测试**:`python -m pytest -v` 全量通过
|
||||
- [ ] **提交**:`git commit -m "fix: <描述> - Closes #N"`
|
||||
- [ ] **推送**:`git push origin dev/issue-N-<slug>`
|
||||
- [ ] **PR**:`agent_poller.py --action create-pr` 创建 PR
|
||||
- [ ] **评论**:`agent_poller.py --action comment` 在 Issue 下记录 PR 链接
|
||||
- [ ] **CI**:`agent_poller.py --action pr-status` 确认 CI 通过
|
||||
- [ ] **合并**:`agent_poller.py --action merge-pr` 合并 PR
|
||||
- [ ] **关闭**:确认 Issue 已自动关闭,否则 `--action close-issue`
|
||||
- [ ] **验证**:`agent_poller.py --action lifecycle` 确认全流程完成
|
||||
|
||||
@@ -33,7 +33,10 @@ def _req(method, path, data=None):
|
||||
req.add_header("Content-Type", "application/json")
|
||||
try:
|
||||
with urllib.request.urlopen(req) as resp:
|
||||
return json.loads(resp.read())
|
||||
raw = resp.read()
|
||||
if not raw:
|
||||
return {} # Gitea merge returns 200 with empty body
|
||||
return json.loads(raw)
|
||||
except urllib.error.HTTPError as e:
|
||||
body = e.read().decode()
|
||||
print(f"API Error {e.code}: {body}", file=sys.stderr)
|
||||
@@ -153,7 +156,11 @@ def merge_pr(pr_num):
|
||||
sys.exit(1)
|
||||
|
||||
result = _req("POST", f"/pulls/{pr_num}/merge", {"Do": "merge"})
|
||||
if result.get("merged"):
|
||||
# Verify merge success by re-checking PR state
|
||||
pr_after = _req("GET", f"/pulls/{pr_num}")
|
||||
if pr_after.get("merged"):
|
||||
print(f"PR #{pr_num} merged successfully")
|
||||
elif result.get("merged"):
|
||||
print(f"PR #{pr_num} merged successfully")
|
||||
else:
|
||||
print(f"Merge result: {result.get('message', 'unknown')}")
|
||||
|
||||
@@ -26,19 +26,20 @@ case "$MODE" in
|
||||
echo ""
|
||||
echo "正在执行单次检查..."
|
||||
claude -p --agent agents/DEV_AGENT.md \
|
||||
"你是 Dev-Agent,检查 Gitea 所有打开的 Issue,跳过纯测试相关的,其他全部领取分析并修复,记得同步更新测试。"
|
||||
"你是 Dev-Agent。检查 Gitea 所有打开的 Issue(--action list),跳过纯测试相关的。对每个负责的 Issue,走完完整闭环:分析 → 分支 → 开发+UT → pytest → commit → push → create-pr → comment Issue → 等 CI → merge-pr → 关闭。"
|
||||
;;
|
||||
2)
|
||||
echo ""
|
||||
echo "启动持续轮询模式 (每 10 分钟)..."
|
||||
echo "按 Ctrl+C 停止"
|
||||
claude -p --agent agents/DEV_AGENT.md \
|
||||
"你是 Dev-Agent,用 loop 模式每 10 分钟检查一次 Gitea 所有打开的 Issue,跳过纯测试相关的,其他全部领取处理。完成后评论进度,push 触发 CI。"
|
||||
"你是 Dev-Agent。用 loop 模式每 10 分钟检查一次 Gitea Issue(--action list)。跳过纯测试相关的。每个 Issue 走完整闭环:分析→开发→push→create-pr→comment→CI→merge-pr→close。每个步骤用 agent_poller.py 对应命令。"
|
||||
;;
|
||||
3)
|
||||
echo ""
|
||||
echo "启动交互模式..."
|
||||
echo "进入后输入: 检查 Gitea Issues 并处理"
|
||||
echo "可用命令速查: agent_poller.py --help"
|
||||
claude --agent agents/DEV_AGENT.md
|
||||
;;
|
||||
*)
|
||||
|
||||
@@ -4,6 +4,7 @@ Reads API keys from a secrets.yaml file, falling back to environment variables.
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import yaml
|
||||
|
||||
@@ -23,11 +24,9 @@ PROMPTS_DIR = os.path.join(BASE_DIR, "prompts")
|
||||
TESTS_DIR = os.path.join(BASE_DIR, "tests")
|
||||
OUTPUT_DIR = IR_OUTPUT # backward compatibility alias
|
||||
|
||||
# Input file (the parsed PRD JSON)
|
||||
_DEFAULT_INPUT = os.path.join(
|
||||
PROJECT_OUTPUT, "车机娱乐系统禁止功能文档_脱敏 v0.9_v2_updated.json",
|
||||
)
|
||||
INPUT_JSON = os.environ.get("IR_INPUT_JSON", _DEFAULT_INPUT)
|
||||
# Input file (the parsed PRD JSON) — must be set via env var or CLI
|
||||
# No hardcoded default to avoid silently processing the wrong document.
|
||||
INPUT_JSON = os.environ.get("IR_INPUT_JSON", None)
|
||||
|
||||
|
||||
def set_input_file(path: str) -> None:
|
||||
@@ -125,8 +124,26 @@ def llm_client():
|
||||
|
||||
|
||||
def load_input_document(path: str | None = None) -> dict:
|
||||
"""Load the parsed PRD JSON document."""
|
||||
"""Load the parsed PRD JSON document.
|
||||
|
||||
Args:
|
||||
path: Explicit file path. If None, reads from IR_INPUT_JSON env var.
|
||||
|
||||
Raises:
|
||||
FileNotFoundError: If no path is configured.
|
||||
SystemExit: If the configured path does not exist.
|
||||
"""
|
||||
path = path or INPUT_JSON
|
||||
if not path:
|
||||
print("错误: 未指定输入文件。请通过以下任一方式指定:", file=sys.stderr)
|
||||
print(" 1. 设置环境变量: IR_INPUT_JSON=<path>", file=sys.stderr)
|
||||
print(" 2. 通过 main.py: python main.py --input <path>", file=sys.stderr)
|
||||
print(" 3. 通过 step 脚本: python step1_semantic_index.py --input <path>", file=sys.stderr)
|
||||
print(" 4. 程序调用: config.set_input_file(<path>)", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
if not os.path.isfile(path):
|
||||
print(f"错误: 输入文件不存在: {path}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
with open(path, "r", encoding="utf-8") as f:
|
||||
return json.load(f)
|
||||
|
||||
|
||||
@@ -19,6 +19,33 @@ def test_set_input_file():
|
||||
config.set_input_file(original)
|
||||
|
||||
|
||||
def test_no_hardcoded_input_file():
|
||||
"""INPUT_JSON should not have a hardcoded default — comes from env or None."""
|
||||
# When IR_INPUT_JSON env is not set, INPUT_JSON should be None
|
||||
env_val = os.environ.pop("IR_INPUT_JSON", None)
|
||||
try:
|
||||
import importlib
|
||||
importlib.reload(config)
|
||||
# After reload without env var, INPUT_JSON should be None
|
||||
assert config.INPUT_JSON is None, \
|
||||
f"INPUT_JSON should be None when env not set, got: {config.INPUT_JSON}"
|
||||
finally:
|
||||
if env_val is not None:
|
||||
os.environ["IR_INPUT_JSON"] = env_val
|
||||
importlib.reload(config)
|
||||
|
||||
|
||||
def test_set_input_file_accepts_none():
|
||||
"""set_input_file(None) should work for resetting."""
|
||||
original = config.INPUT_JSON
|
||||
try:
|
||||
config.set_input_file("/tmp/test.json")
|
||||
config.set_input_file(None)
|
||||
assert config.INPUT_JSON is None
|
||||
finally:
|
||||
config.set_input_file(original)
|
||||
|
||||
|
||||
def test_config_constants_exist():
|
||||
"""Verify all expected path constants are defined."""
|
||||
assert config.BASE_DIR
|
||||
|
||||
Reference in New Issue
Block a user