Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /Consiliency_treesitter-chunker /.claude /hooks /utils /summarizer.py
| #!/usr/bin/env -S uv run --script | |
| # /// script | |
| # requires = { python = ">=3.8" } | |
| # dependencies = [ | |
| # "anthropic", | |
| # "python-dotenv", | |
| # ] | |
| # /// | |
| import json | |
| from typing import Any | |
| from .llm.anth import prompt_llm | |
| def generate_event_summary(event_data: dict[str, Any]) -> str | None: | |
| """ | |
| Generate a concise one - sentence summary of a hook event for engineers. | |
| Args: | |
| event_data: The hook event data containing event_type, payload, etc. | |
| Returns: | |
| str: A one - sentence summary, or None if generation fails | |
| """ | |
| event_type = event_data.get("hook_event_type", "Unknown") | |
| payload = event_data.get("payload", {}) | |
| # Convert payload to string representation | |
| payload_str = json.dumps(payload, indent=2) | |
| if len(payload_str) > 1000: | |
| payload_str = payload_str[:1000] + "..." | |
| prompt = f"""Generate a one - sentence summary of this Claude Code hook event payload for an engineer monitoring the system. | |
| Event Type: {event_type} | |
| Payload: | |
| {payload_str} | |
| Requirements: | |
| - ONE sentence only (no period at the end) | |
| - Focus on the key action or information in the payload | |
| - Be specific and technical | |
| - Keep under 15 words | |
| - Use present tense | |
| - No quotes or formatting | |
| - Return ONLY the summary text | |
| Examples: | |
| - Reads configuration file from project root | |
| - Executes npm install to update dependencies | |
| - Searches web for React documentation | |
| - Edits database schema to add user table | |
| - Agent responds with implementation plan | |
| Generate the summary based on the payload:""" | |
| summary = prompt_llm(prompt) | |
| # Clean up the response | |
| if summary: | |
| summary = summary.strip().strip('"').strip("'").strip(".") | |
| # Take only the first line if multiple | |
| summary = summary.split("\n")[0].strip() | |
| # Ensure it's not too long | |
| if len(summary) > 100: | |
| summary = summary[:97] + "..." | |
| return summary | |
Xet Storage Details
- Size:
- 1.9 kB
- Xet hash:
- 23fa860c3f5e42dac595554a1976c5322070c06915ca30c34057a12e0127d551
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.