312 lines
8.4 KiB
Bash
Executable File
312 lines
8.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
usage() {
|
|
cat <<'USAGE'
|
|
Usage:
|
|
bin/agent-prompts.sh --task TASK_ID [options]
|
|
|
|
Options:
|
|
--task TASK_ID Required. Task identifier (e.g. AUTH-LOGIN-REVIEW-001)
|
|
--role ROLE planner|executor|executor-rerun|reviewer-guards|reviewer-acceptance|finalizer|all
|
|
Default: all
|
|
--goal TEXT Planner goal text
|
|
--scope-in TEXT Planner scope-in text
|
|
--scope-out TEXT Planner scope-out text
|
|
--guards CSV Planner required guards (e.g. GR-CORE-005,GR-SEC-001)
|
|
--gates CSV Planner required gates (e.g. QG-001,QG-002,QG-003,QG-006)
|
|
--run-dir PATH Override run directory (default: agent-system/runs/<TASK_ID>)
|
|
--short Emit 3-line one-pager prompt variants
|
|
-h, --help Show help
|
|
|
|
Examples:
|
|
bin/agent-prompts.sh --task AUTH-LOGIN-REVIEW-001
|
|
bin/agent-prompts.sh --task AUTH-LOGIN-REVIEW-001 --role planner --goal "Auth/Login review"
|
|
bin/agent-prompts.sh --task TASK-42 --short
|
|
USAGE
|
|
}
|
|
|
|
task_id=""
|
|
role="all"
|
|
goal="<KURZES_ZIEL>"
|
|
scope_in="<DATEIEN/BEREICHE>"
|
|
scope_out="<AUSSERHALB_SCOPE>"
|
|
guards="<GR-...>"
|
|
gates="<QG-...>"
|
|
short_mode=0
|
|
|
|
while [[ $# -gt 0 ]]; do
|
|
case "$1" in
|
|
--task)
|
|
[[ $# -ge 2 ]] || { echo "[ERROR] --task requires a value" >&2; exit 2; }
|
|
task_id="$2"
|
|
shift 2
|
|
;;
|
|
--role)
|
|
[[ $# -ge 2 ]] || { echo "[ERROR] --role requires a value" >&2; exit 2; }
|
|
role="$2"
|
|
shift 2
|
|
;;
|
|
--goal)
|
|
[[ $# -ge 2 ]] || { echo "[ERROR] --goal requires a value" >&2; exit 2; }
|
|
goal="$2"
|
|
shift 2
|
|
;;
|
|
--scope-in)
|
|
[[ $# -ge 2 ]] || { echo "[ERROR] --scope-in requires a value" >&2; exit 2; }
|
|
scope_in="$2"
|
|
shift 2
|
|
;;
|
|
--scope-out)
|
|
[[ $# -ge 2 ]] || { echo "[ERROR] --scope-out requires a value" >&2; exit 2; }
|
|
scope_out="$2"
|
|
shift 2
|
|
;;
|
|
--guards)
|
|
[[ $# -ge 2 ]] || { echo "[ERROR] --guards requires a value" >&2; exit 2; }
|
|
guards="$2"
|
|
shift 2
|
|
;;
|
|
--gates)
|
|
[[ $# -ge 2 ]] || { echo "[ERROR] --gates requires a value" >&2; exit 2; }
|
|
gates="$2"
|
|
shift 2
|
|
;;
|
|
--run-dir)
|
|
[[ $# -ge 2 ]] || { echo "[ERROR] --run-dir requires a value" >&2; exit 2; }
|
|
run_dir="$2"
|
|
shift 2
|
|
;;
|
|
--short)
|
|
short_mode=1
|
|
shift
|
|
;;
|
|
-h|--help)
|
|
usage
|
|
exit 0
|
|
;;
|
|
*)
|
|
echo "[ERROR] Unknown option: $1" >&2
|
|
usage
|
|
exit 2
|
|
;;
|
|
esac
|
|
done
|
|
|
|
if [[ -z "$task_id" ]]; then
|
|
echo "[ERROR] --task is required" >&2
|
|
usage
|
|
exit 2
|
|
fi
|
|
|
|
if [[ "${run_dir:-}" == "" ]]; then
|
|
run_dir="agent-system/runs/${task_id}"
|
|
fi
|
|
|
|
is_valid_role() {
|
|
case "$1" in
|
|
planner|executor|executor-rerun|reviewer-guards|reviewer-acceptance|finalizer|all)
|
|
return 0
|
|
;;
|
|
*)
|
|
return 1
|
|
;;
|
|
esac
|
|
}
|
|
|
|
if ! is_valid_role "$role"; then
|
|
echo "[ERROR] Invalid --role: $role" >&2
|
|
usage
|
|
exit 2
|
|
fi
|
|
|
|
print_divider() {
|
|
echo
|
|
echo "============================================================"
|
|
echo "$1"
|
|
echo "============================================================"
|
|
}
|
|
|
|
print_short_prompts() {
|
|
cat <<EOF
|
|
Planner (3 Zeilen)
|
|
Du bist Planner im agent-system; liefere nur valid JSON nach planner.schema.json.
|
|
Task ${task_id}; Ziel ${goal}; Scope in/out + Pflicht-Guards ${guards} + Pflicht-Gates ${gates}.
|
|
Erzeuge SC-IDs, Schritte, Tests, Acceptance-Checks, Risiken -> ${run_dir}/plan.json.
|
|
|
|
Executor (3 Zeilen)
|
|
Du bist Executor im agent-system; liefere nur valid JSON nach executor.schema.json.
|
|
Input: ${run_dir}/plan.json; implementiere nur im Scope, keine Drift.
|
|
Führe relevante Gates aus (pass nur Exit 0), sonst blocked+open_items -> ${run_dir}/execution-report.json.
|
|
|
|
Executor Re-Run (3 Zeilen)
|
|
Du bist Executor Re-Run; liefere nur valid JSON nach executor.schema.json.
|
|
Input: plan.json + execution-report.json + review-guards.json; behebe alle Findings.
|
|
Gates neu ausführen, Report synchronisieren -> ${run_dir}/execution-report.json.
|
|
|
|
Reviewer-Guards (3 Zeilen)
|
|
Du bist Reviewer-Guards; liefere nur valid JSON nach reviewer-guards.schema.json.
|
|
Prüfe execution-report gegen alle required_guard_ids + required_quality_gate_ids aus plan.json.
|
|
Findings nur mit rule_ref, severity, file -> ${run_dir}/review-guards.json.
|
|
|
|
Reviewer-Acceptance (3 Zeilen)
|
|
Du bist Reviewer-Acceptance; liefere nur valid JSON nach reviewer-acceptance.schema.json.
|
|
Prüfe jedes SC-* aus plan.json gegen execution-report mit klarer Evidence.
|
|
Bei fail missing_or_wrong füllen -> ${run_dir}/review-acceptance.json.
|
|
|
|
Finalizer (3 Zeilen)
|
|
Du bist Finalizer; liefere nur valid JSON nach finalizer.schema.json.
|
|
Input: execution-report.json + review-guards.json + review-acceptance.json.
|
|
Nur commit/merge bei guard=pass, acceptance=pass, ci=pass; sonst hold+hold_reason -> ${run_dir}/finalize.json.
|
|
EOF
|
|
}
|
|
|
|
print_planner() {
|
|
cat <<EOF
|
|
Du bist Planner im agent-system.
|
|
Lies die Planner-Baseline + Guard/Gate-Kataloge und gib ausschließlich valid JSON nach agent-system/contracts/planner.schema.json aus.
|
|
|
|
Task: ${task_id}
|
|
Ziel: ${goal}
|
|
Scope in: ${scope_in}
|
|
Scope out: ${scope_out}
|
|
Pflicht-Guards: ${guards}
|
|
Pflicht-Gates: ${gates}
|
|
|
|
Erstelle: klare SC-IDs, konkrete Schritte, Tests, Acceptance-Checks, Risiken mit Mitigation.
|
|
Output-Datei: ${run_dir}/plan.json
|
|
EOF
|
|
}
|
|
|
|
print_executor() {
|
|
cat <<EOF
|
|
Du bist Executor im agent-system.
|
|
Lies die Executor-Baseline und gib ausschließlich valid JSON nach agent-system/contracts/executor.schema.json aus.
|
|
|
|
Task: ${task_id}
|
|
Input: ${run_dir}/plan.json
|
|
|
|
Regeln:
|
|
- Nur Plan-Scope umsetzen, keine Scope-Drift.
|
|
- Guard-Evidence und Gate-Results vollständig.
|
|
- Gates nach echtem Exit-Code reporten (pass nur bei Exit 0).
|
|
- Bei Blockern: status="blocked" + genaue open_items.
|
|
|
|
Output-Datei: ${run_dir}/execution-report.json
|
|
EOF
|
|
}
|
|
|
|
print_executor_rerun() {
|
|
cat <<EOF
|
|
Du bist Executor im agent-system.
|
|
Gib ausschließlich valid JSON nach agent-system/contracts/executor.schema.json aus.
|
|
|
|
Task: ${task_id}
|
|
Input:
|
|
- ${run_dir}/plan.json
|
|
- ${run_dir}/execution-report.json
|
|
- ${run_dir}/review-guards.json
|
|
|
|
Behebe alle offenen Findings und synchronisiere den Report.
|
|
Pflicht: Gates erneut ausführen und konsistent reporten (echter Exit-Code).
|
|
Wenn alles grün: status="done". Sonst status="blocked" + exakte Blocker.
|
|
|
|
Output-Datei: ${run_dir}/execution-report.json
|
|
EOF
|
|
}
|
|
|
|
print_reviewer_guards() {
|
|
cat <<EOF
|
|
Du bist Reviewer-Guards im agent-system.
|
|
Prüfe execution-report gegen Guardrails/Security und gib ausschließlich valid JSON nach agent-system/contracts/reviewer-guards.schema.json aus.
|
|
|
|
Task: ${task_id}
|
|
Input:
|
|
- ${run_dir}/plan.json
|
|
- ${run_dir}/execution-report.json
|
|
|
|
Prüfe mindestens:
|
|
- alle required_guard_ids aus plan.json
|
|
- alle required_quality_gate_ids aus plan.json
|
|
|
|
Jedes Finding braucht: rule_ref (GR-/QG-ID), severity, file.
|
|
Output-Datei: ${run_dir}/review-guards.json
|
|
EOF
|
|
}
|
|
|
|
print_reviewer_acceptance() {
|
|
cat <<EOF
|
|
Du bist Reviewer-Acceptance im agent-system.
|
|
Gib ausschließlich valid JSON nach agent-system/contracts/reviewer-acceptance.schema.json aus.
|
|
|
|
Task: ${task_id}
|
|
Input:
|
|
- ${run_dir}/plan.json
|
|
- ${run_dir}/execution-report.json
|
|
|
|
Bewerte jedes SC-* aus plan.json einzeln mit Evidence.
|
|
Bei fail: missing_or_wrong explizit befüllen.
|
|
|
|
Output-Datei: ${run_dir}/review-acceptance.json
|
|
EOF
|
|
}
|
|
|
|
print_finalizer() {
|
|
cat <<EOF
|
|
Du bist Finalizer im agent-system.
|
|
Gib ausschließlich valid JSON nach agent-system/contracts/finalizer.schema.json aus.
|
|
|
|
Task: ${task_id}
|
|
Input:
|
|
- ${run_dir}/execution-report.json
|
|
- ${run_dir}/review-guards.json
|
|
- ${run_dir}/review-acceptance.json
|
|
|
|
Regel:
|
|
- commit/merge nur wenn guard_review=pass, acceptance_review=pass, ci_status=pass
|
|
- sonst final_action="hold" mit klarer hold_reason
|
|
|
|
Output-Datei: ${run_dir}/finalize.json
|
|
EOF
|
|
}
|
|
|
|
if [[ $short_mode -eq 1 ]]; then
|
|
print_short_prompts
|
|
exit 0
|
|
fi
|
|
|
|
case "$role" in
|
|
planner)
|
|
print_planner
|
|
;;
|
|
executor)
|
|
print_executor
|
|
;;
|
|
executor-rerun)
|
|
print_executor_rerun
|
|
;;
|
|
reviewer-guards)
|
|
print_reviewer_guards
|
|
;;
|
|
reviewer-acceptance)
|
|
print_reviewer_acceptance
|
|
;;
|
|
finalizer)
|
|
print_finalizer
|
|
;;
|
|
all)
|
|
print_divider "Planner"
|
|
print_planner
|
|
print_divider "Executor"
|
|
print_executor
|
|
print_divider "Executor Re-Run"
|
|
print_executor_rerun
|
|
print_divider "Reviewer-Guards"
|
|
print_reviewer_guards
|
|
print_divider "Reviewer-Acceptance"
|
|
print_reviewer_acceptance
|
|
print_divider "Finalizer"
|
|
print_finalizer
|
|
;;
|
|
esac
|