chore: agent 配置文件纳入版本管理 + docs/ 项目章程与全局状态 - Closes #37
CI / test (pull_request) Successful in 11s
CI / test (pull_request) Successful in 11s
- agents/DEV_AGENT.md: 新增启动读取 docs、Session 收尾流程、自行验证关闭 Issue - agents/QE_AGENT.md: 新增启动读取 docs、Session 收尾流程 - docs/PROJECT_CHARTER.md: 项目章程(背景、愿景、目标、约束) - docs/GLOBAL_STATE.md: 项目全局状态(架构、已知问题、变更日志) - scripts/: 启动脚本重构,引入 _common.sh Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
#!/usr/bin/env bash
|
||||
# _common.sh — shared functions for dev-agent / qe-agent startup scripts
|
||||
# Source this file from start_dev_agent.sh or start_qe_agent.sh
|
||||
|
||||
set -eu
|
||||
|
||||
# ── Resolve paths ──────────────────────────────────────────────────────────────
|
||||
_COMMON_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PROJECT_DIR="${PROJECT_DIR:-$(cd "$_COMMON_DIR/.." && pwd)}"
|
||||
|
||||
# ── Load local secrets (not tracked by git) ────────────────────────────────────
|
||||
if [ -f "$_COMMON_DIR/.env" ]; then
|
||||
source "$_COMMON_DIR/.env"
|
||||
fi
|
||||
|
||||
# ── Default environment variables ──────────────────────────────────────────────
|
||||
export GITEA_URL="${GITEA_URL:-http://localhost:3000}"
|
||||
export GITEA_REPO="${GITEA_REPO:-pzhang_zywl/document_analyzer}"
|
||||
|
||||
# ── Validate required environment ──────────────────────────────────────────────
|
||||
require_token() {
|
||||
if [ -z "${GITEA_API_TOKEN:-}" ]; then
|
||||
echo "ERROR: GITEA_API_TOKEN is not set." >&2
|
||||
echo "Set it in scripts/.env or export it:" >&2
|
||||
echo " export GITEA_API_TOKEN=your-token" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# ── Print banner ───────────────────────────────────────────────────────────────
|
||||
banner() {
|
||||
local role="${1:-Agent}"
|
||||
echo "============================================"
|
||||
echo " ${role}-Agent 启动器"
|
||||
echo "============================================"
|
||||
echo ""
|
||||
}
|
||||
|
||||
# ── Launch agent in selected mode ──────────────────────────────────────────────
|
||||
# Usage: launch_agent <agent-file> <agent-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.
|
||||
#
|
||||
# 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.
|
||||
launch_agent() {
|
||||
local agent_file="$1"
|
||||
local agent_name="$2"
|
||||
local single_shot_task="$3"
|
||||
local polling_instruction="${4:-}"
|
||||
|
||||
echo "模式选择:"
|
||||
echo " [1] 单次任务 — 检查 Issue 并处理,完成后自动退出 (automode)"
|
||||
echo " [2] 互动轮询 — 进入 Claude Code 界面,每 10 分钟自动轮询"
|
||||
echo ""
|
||||
read -r -p "请输入 (1/2): " mode
|
||||
echo ""
|
||||
|
||||
case "$mode" in
|
||||
1)
|
||||
echo "执行单次检查 (automode)..."
|
||||
echo ""
|
||||
cd "$PROJECT_DIR"
|
||||
claude -p \
|
||||
--agent "$agent_file" \
|
||||
--dangerously-skip-permissions \
|
||||
"你是 ${agent_name}。${single_shot_task}"
|
||||
;;
|
||||
2)
|
||||
echo "启动互动轮询模式..."
|
||||
echo "${agent_name} 进入 Claude Code 界面后将自动开始轮询"
|
||||
echo "你可以随时输入指令与 Agent 互动,按 Ctrl+C 停止"
|
||||
echo ""
|
||||
cd "$PROJECT_DIR"
|
||||
claude --agent "$agent_file" \
|
||||
"你是 ${agent_name}。${polling_instruction}"
|
||||
;;
|
||||
*)
|
||||
echo "无效选择,请输入 1 或 2。"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
Reference in New Issue
Block a user