65 lines
1.9 KiB
Python
65 lines
1.9 KiB
Python
"""Tool for logging bugs and improvement requests that need Claude Code to fix."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import logging
|
|
from datetime import UTC, datetime
|
|
from pathlib import Path
|
|
|
|
from . import tool
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
|
@tool(
|
|
"report_issue",
|
|
"Log a bug or improvement that needs Claude Code to fix. "
|
|
"Creates a structured entry in memory/improvement_requests.md.",
|
|
category="system",
|
|
)
|
|
def report_issue(
|
|
title: str,
|
|
description: str,
|
|
affected_files: str = "",
|
|
suggested_fix: str = "",
|
|
ctx: dict | None = None,
|
|
) -> str:
|
|
"""Append a structured improvement request and index it in memory."""
|
|
now = datetime.now(UTC)
|
|
timestamp = now.strftime("%Y-%m-%d %H:%M UTC")
|
|
|
|
entry_lines = [
|
|
f"\n## {title}",
|
|
f"**Reported:** {timestamp} ",
|
|
f"**Status:** pending\n",
|
|
description,
|
|
]
|
|
|
|
if affected_files:
|
|
entry_lines.append(f"\n**Affected files:** {affected_files}")
|
|
|
|
if suggested_fix:
|
|
entry_lines.append(f"\n**Suggested Claude Code prompt:**\n> {suggested_fix}")
|
|
|
|
entry_lines.append("\n---")
|
|
entry = "\n".join(entry_lines)
|
|
|
|
# Write to the improvement requests file
|
|
requests_path = Path("memory/improvement_requests.md")
|
|
requests_path.parent.mkdir(parents=True, exist_ok=True)
|
|
|
|
if requests_path.exists():
|
|
content = requests_path.read_text(encoding="utf-8")
|
|
else:
|
|
content = "# Improvement Requests\n\nItems here need Claude Code (with codebase access) to fix.\n"
|
|
|
|
content += entry + "\n"
|
|
requests_path.write_text(content, encoding="utf-8")
|
|
|
|
# Also index into semantic memory for searchability
|
|
if ctx and ctx.get("memory"):
|
|
ctx["memory"].log_daily(f"Reported issue: {title} — {description}")
|
|
|
|
log.info("Logged improvement request: %s", title)
|
|
return f"Logged improvement request: **{title}**. Bryan will see it on the next heartbeat."
|