feat: record CLI command telemetry

This commit is contained in:
2026-06-02 15:49:27 +01:00
parent eb30450f34
commit 2fcc822394
6 changed files with 86 additions and 5 deletions
+15 -2
View File
@@ -13,6 +13,7 @@ from .status import project_stage, task_counts, update_project_state, update_age
from .tasks import generate_agent_prompt, get_next_task, update_task_status
from .templates import CONTEXT_FILES, write_file_if_missing
from .guardrails import run_all_guardrails, format_report
from .telemetry import record_event
app = typer.Typer(help="RDB discovery and delivery workflow CLI.")
console = Console()
@@ -35,6 +36,7 @@ def append_run_log(root: Path, event: str, task_id: str = "", notes: str = "") -
def init() -> None:
"""Create the initial markdown project structure."""
root = root_path()
record_event(root, "command", "rdb init")
created: list[str] = []
skipped: list[str] = []
@@ -59,6 +61,7 @@ def init() -> None:
def discover() -> None:
"""Ask the core discovery questions and append answers to the discovery ledger."""
root = root_path()
record_event(root, "command", "rdb discover")
write_file_if_missing(root, "context/discovery-log.md", CONTEXT_FILES["context/discovery-log.md"])
for index, question in enumerate(core_questions(), start=1):
@@ -76,6 +79,7 @@ def discover() -> None:
def ask_more() -> None:
"""Ask for additional details on Low-confidence or follow-up-needed answers."""
root = root_path()
record_event(root, "command", "rdb ask_more")
answers = read_discovery_answers(root)
if not answers:
@@ -119,6 +123,7 @@ def ask_more() -> None:
def status() -> None:
"""Show current project stage and task counts."""
root = root_path()
record_event(root, "command", "rdb status")
console.print(f"[bold]Project stage:[/bold] {project_stage(root)}")
counts = task_counts(root)
@@ -138,7 +143,9 @@ def status() -> None:
@app.command(name="next")
def next_task() -> None:
"""Show the next Todo task."""
task = get_next_task(root_path())
root = root_path()
record_event(root, "command", "rdb next")
task = get_next_task(root)
if not task:
console.print("[yellow]No Todo task found.[/yellow]")
raise typer.Exit(code=0)
@@ -152,6 +159,7 @@ def next_task() -> None:
def start(task_id: str) -> None:
"""Mark a task as In Progress."""
root = root_path()
record_event(root, "command", "rdb start", {"task_id": task_id})
if not update_task_status(root, task_id, "In Progress"):
console.print(f"[red]Task not found:[/red] {task_id}")
raise typer.Exit(code=1)
@@ -165,6 +173,7 @@ def start(task_id: str) -> None:
def complete(task_id: str) -> None:
"""Mark a task as Done and record validation notes."""
root = root_path()
record_event(root, "command", "rdb complete", {"task_id": task_id})
notes = typer.prompt("Validation notes", default="Not tested")
if not update_task_status(root, task_id, "Done"):
console.print(f"[red]Task not found:[/red] {task_id}")
@@ -178,13 +187,16 @@ def complete(task_id: str) -> None:
@app.command()
def handoff() -> None:
"""Print an AI-agent handoff summary."""
console.print(build_handoff(root_path()))
root = root_path()
record_event(root, "command", "rdb handoff")
console.print(build_handoff(root))
@app.command()
def prompt() -> None:
"""Generate a ready-to-paste implementation prompt for the next Todo task."""
root = root_path()
record_event(root, "command", "rdb prompt")
result = generate_agent_prompt(root)
console.print(result)
@@ -193,6 +205,7 @@ def prompt() -> None:
def guardrails() -> None:
"""Review agent runs for signs of non-progress (stalls, repeats, loops)."""
root = root_path()
record_event(root, "command", "rdb guardrails")
results = run_all_guardrails(root)
report = format_report(results)
console.print(report)