fix: 将 agent 定义移至 .claude/agents/ 实现 session 自动加载 - Closes #108
CI / test (pull_request) Successful in 25s

1. 创建 .claude/agents/dev-agent.md / qe-agent.md — agent 定义文件
2. _common.sh: launch_agent 改为接收绝对路径的 agent 定义文件
3. start_dev_agent.sh / start_qe_agent.sh: 传递 .claude/agents/ 下的文件路径

Claude Code 启动时通过 --agent .claude/agents/<name>.md 自动加载
frontmatter + body 作为系统指令。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-06-08 11:33:05 +08:00
parent d8ba0f36c9
commit 77831d5a68
5 changed files with 509 additions and 15 deletions
+17 -13
View File
@@ -73,23 +73,27 @@ banner() {
}
# ── Launch agent in selected mode ──────────────────────────────────────────────
# Usage: launch_agent <agent-file> <agent-name> <single-shot-task> <polling-instruction>
# Usage: launch_agent <agent-name> <agent-file> <display-name> <single-shot-task> <polling-instruction>
#
# agent-name is the persona name (e.g. "Dev-Agent", "QE-Agent"). It is used to
# prefix prompts so the model adopts the correct identity.
# agent-name is the agent config name (e.g. "dev-agent", "qe-agent") used with
# --agent flag. The agent file lives in .claude/agents/<agent-name>.md (with
# frontmatter + body loaded as system prompt at session start).
#
# display-name is the persona name (e.g. "Dev-Agent", "QE-Agent") used to prefix
# prompts so the model adopts the correct identity.
#
# Mode 1 (single-shot): claude -p, runs once and exits.
# --dangerously-skip-permissions avoids blocking in non-interactive mode.
# The project .claude/settings.json already sets permissionMode: bypass.
#
# Mode 2 (interactive polling): claude --agent, opens Claude Code TUI.
# The agent file defines startup behavior (e.g. /loop 10m) and the
# user can observe or interact at any time.
# The agent config is loaded from .claude/agents/<agent-name>.md,
# its body becomes the system prompt.
launch_agent() {
local agent_file="$1"
local agent_name="$2"
local single_shot_task="$3"
local polling_instruction="${4:-}"
local agent_name="$1"
local agent_file="$2"
local display_name="$3"
local single_shot_task="$4"
local polling_instruction="${5:-}"
echo "模式选择:"
echo " [1] 单次任务 — 检查 Issue 并处理,完成后自动退出 (automode)"
@@ -106,16 +110,16 @@ launch_agent() {
claude -p \
--agent "$agent_file" \
--dangerously-skip-permissions \
"你是 ${agent_name}${single_shot_task}"
"你是 ${display_name}${single_shot_task}"
;;
2)
echo "启动互动轮询模式..."
echo "${agent_name} 进入 Claude Code 界面后将自动开始轮询"
echo "${display_name} 进入 Claude Code 界面后将自动开始轮询"
echo "你可以随时输入指令与 Agent 互动,按 Ctrl+C 停止"
echo ""
cd "$PROJECT_DIR"
claude --agent "$agent_file" \
"你是 ${agent_name}${polling_instruction}"
"你是 ${display_name}${polling_instruction}"
;;
*)
echo "无效选择,请输入 1 或 2。"
+3 -1
View File
@@ -24,8 +24,10 @@ trap 'cleanup_worktree "$GITEA_USER"' EXIT
banner "Dev"
require_token
AGENT_CONF="$_MAIN_REPO_DIR/.claude/agents/dev-agent.md"
launch_agent \
"agents/DEV_AGENT.md" \
"dev-agent" \
"$AGENT_CONF" \
"Dev-Agent" \
"执行一次 Issue 巡检(单次任务,不要用 /loop):
1. python scripts/agent_poller.py --action list 列出所有打开的 Issue
+3 -1
View File
@@ -24,8 +24,10 @@ trap 'cleanup_worktree "$GITEA_USER"' EXIT
banner "QE"
require_token
AGENT_CONF="$_MAIN_REPO_DIR/.claude/agents/qe-agent.md"
launch_agent \
"agents/QE_AGENT.md" \
"qe-agent" \
"$AGENT_CONF" \
"QE-Agent" \
"执行一次 Issue 巡检(单次任务,不要用 /loop):
1. python scripts/agent_poller.py --action list --labels test-code 检查 test-code Issue