feat: test-generation + issue/PR summary via slash commands (/gen-tests, /summarize)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
53
scripts/ai_summary.py
Normal file
53
scripts/ai_summary.py
Normal file
@@ -0,0 +1,53 @@
|
||||
"""Feature E — KI-Zusammenfassung langer Issue-/PR-Diskussionen.
|
||||
|
||||
Per Slash-Command `/summarize` an einem Issue oder PR (issue_comment). Holt
|
||||
Titel/Body + alle menschlichen Kommentare und fasst Diskussion, Stand und offene
|
||||
Punkte zusammen — als idempotenten Kommentar.
|
||||
"""
|
||||
import sys
|
||||
|
||||
import context
|
||||
import gitea_api
|
||||
import llm
|
||||
|
||||
MARKER = "<!-- ci-ai:summary -->"
|
||||
THREAD_CAP = 24000
|
||||
|
||||
SYSTEM = (
|
||||
"Du fasst Issue-/PR-Diskussionen prägnant auf Deutsch zusammen: worum es geht, "
|
||||
"welche Entscheidungen/Argumente fielen und was offen ist. Keine Erfindungen — "
|
||||
"nur was im Thread steht."
|
||||
)
|
||||
|
||||
PROMPT = """\
|
||||
Fasse die folgende Diskussion zusammen. Genau diese drei Abschnitte (Markdown):
|
||||
|
||||
### Worum geht's
|
||||
### Stand & Entscheidungen
|
||||
### Offene Punkte / nächste Schritte
|
||||
|
||||
--- THREAD ---
|
||||
{thread}
|
||||
"""
|
||||
|
||||
|
||||
def main() -> int:
|
||||
owner, repo = context.repo_slug()
|
||||
iss = context.issue()
|
||||
index = iss["index"] if iss else (context.pull_request() or {}).get("index")
|
||||
if not index:
|
||||
print("[ai_summary] Kein Issue/PR-Kontext. Übersprungen.")
|
||||
return 0
|
||||
ok, why = llm.configured()
|
||||
if not ok:
|
||||
print(f"[ai_summary] KI inaktiv ({why}) — übersprungen, kein Fehler.")
|
||||
return 0
|
||||
thread = gitea_api.get_issue_thread(owner, repo, index)[:THREAD_CAP]
|
||||
answer = llm.complete(SYSTEM, PROMPT.format(thread=thread), max_tokens=1500)
|
||||
gitea_api.upsert_comment(owner, repo, index, MARKER, f"## 📝 KI-Zusammenfassung\n\n{answer}")
|
||||
print("[ai_summary] Kommentar gepostet/aktualisiert.")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Reference in New Issue
Block a user