feat: add read_discovery_answers, append_followup_answer, and ask-more command

- Add read_discovery_answers() to parse discovery-log.md rows into dicts
  with low_confidence and needs_followup boolean flags.
- Add append_followup_answer() to append follow-up rows linked to original Q-A IDs.
- Add 'ask-more' CLI command that detects Low-confidence and Follow-up-needed
  answers, prompts for additional details, and records them in the log.
- Add 6 tests: read_discovery_answers round-trip, empty-log handling,
  low-confidence detection, follow-up flag detection, and append_followup.
This commit is contained in:
2026-06-02 09:57:02 +01:00
parent 07ee27b03e
commit 39728667a7
3 changed files with 202 additions and 1 deletions
+44 -1
View File
@@ -7,7 +7,7 @@ import typer
from rich.console import Console
from rich.table import Table
from .discovery import append_discovery_answer, core_questions
from .discovery import append_discovery_answer, append_followup_answer, core_questions, read_discovery_answers
from .handoff import build_handoff
from .status import project_stage, task_counts
from .tasks import generate_agent_prompt, get_next_task, update_task_status
@@ -71,6 +71,49 @@ def discover() -> None:
console.print("[bold green]Discovery complete.[/bold green]")
@app.command()
def ask_more() -> None:
"""Ask for additional details on Low-confidence or follow-up-needed answers."""
root = root_path()
answers = read_discovery_answers(root)
if not answers:
console.print("[yellow]No discovery answers found. Run `discover` first.[/yellow]")
raise typer.Exit(code=0)
low_conf = [a for a in answers if a["low_confidence"]]
follow_ups = [a for a in answers if a["needs_followup"]]
flagged: dict[str, list[str]] = {} # question_id -> list of reasons
for a in low_conf:
flagged.setdefault(a["id"], []).append("Low confidence")
for a in follow_ups:
flagged.setdefault(a["id"], []).append("Follow-up needed")
if not flagged:
console.print("[green]No Low-confidence or Follow-up-needed answers found.[/green]")
raise typer.Exit(code=0)
count = 0
for qid, reasons in sorted(flagged.items()):
original = next(a for a in answers if a["id"] == qid)
console.print(f"\n[yellow]Question:[/yellow] {original['question']}")
console.print(f"[dim]Reasons: {', '.join(reasons)}[/dim]")
fu_question = typer.prompt(
f"Follow-up for {qid}",
default=f"Additional detail on: {original['question'][:40]}",
)
fu_answer = typer.prompt("New answer")
fu_confidence = typer.prompt("Confidence?", default="Medium")
append_followup_answer(root, qid, fu_question, fu_answer, fu_confidence)
count += 1
console.print(f"[green]Recorded follow-up for {qid}.[/green]")
console.print(f"\n[bold green]Ask-more complete: recorded {count} follow-up(s).[/bold green]")
@app.command()
def status() -> None:
"""Show current project stage and task counts."""