Skip to content

fix: address code review feedback from PRs #4 and #5 - #7

Merged
samkujovich merged 5 commits into
mainfrom
fix/post-merge-tweaks
Feb 15, 2026
Merged

samkujovich merged 5 commits into
mainfrom
fix/post-merge-tweaks

Conversation

@samkujovich

Copy link
Copy Markdown
Owner

Summary

Post-merge fixes addressing code review feedback from PR #4 (Ambiguity Feedback Loop) and PR #5 (Formatters).

HIGH Priority

  • Robust JSON extraction: Replace fragile regex with brace-balanced parser (_extract_balanced_braces)
  • Unique ambiguity IDs: Add index suffix to prevent collisions (REQ-001:vague:0, REQ-001:vague:1)

MEDIUM Priority

  • Case-insensitive commands: CLARIFY 1 "text" works, preserves text case
  • Module-level imports: Move import copy to top of file
  • Formatters wired in: Agent shows formatted tables after analysis/tickets
  • Proper pluralization: _pluralize() helper for "1 epic" vs "2 epics"
  • Return type fix: run_agent_turn correctly typed as tuple[str, list[TResponseInputItem]]
  • Backslash edge case: Only escape inside JSON strings, not surrounding prose

LOW Priority

  • Code deduplication: Generic _extract_json_with_key() replaces duplicate extraction
  • Dead code removal: Single-quote check in _is_tickets_response
  • Prose preserved: Show assistant's response before formatted tables, not instead of
  • Title truncation: _truncate() adds ellipsis for long titles
  • Pipe escaping: _escape_pipe() for markdown table safety
  • Test helpers: _flag() and _req() reduce line lengths to <99 chars

Test Plan

  • 282 tests passing (up from 281)
  • Lint clean (ruff check)
  • New tests: backslash in prose, unbalanced braces, unique IDs, dismiss command

HIGH:
- Replace fragile JSON regex with brace-balanced parser
- Fix ambiguity ID collision by adding index (REQ-001:category:0)

MEDIUM:
- Fix case-sensitive clarify regex (CLARIFY now works)
- Move inline copy import to module top
- Fix singular/plural grammar ("1 Ambiguity" vs "2 Ambiguities")

LOW:
- Add dismiss command tests
- Document accept/dismiss limitation in docstring

6 new tests (280 total).
MEDIUM:
- Wire formatters into agent.py (analysis + tickets display)
- Fix (s)/(ies) pluralization with _pluralize() helper

LOW:
- Add ellipsis for truncated titles (_truncate helper)
- Fix inconsistent size defaults (use None, not "M")
- Add pipe escaping in table cells (_escape_pipe helper)

Updated tests for new output format.
- Extract generic _extract_json_with_key to eliminate duplication between
  extract_requirements_from_output and _extract_tickets_from_output
- Remove dead code: single-quote check in _is_tickets_response (LLM
  always outputs double quotes for JSON)
- Always show assistant's prose response first, then append formatted
  tables below - previously formatted output replaced prose entirely

Addresses LOW priority code review feedback.
MEDIUM fixes:
- run_agent_turn: Fix return type from str to tuple[str, list[TResponseInputItem]]
  (pre-existing bug - function returns tuple but annotation said str)
- _extract_balanced_braces: Only apply backslash escaping inside JSON strings,
  not in surrounding prose where backslashes could appear

LOW fix:
- test_agent.py: Add _flag() and _req() helpers to reduce line lengths
  from 100-130+ chars to under 99 (project standard)
- All 17 long lines now comply with 99-char limit

Added test: test_extract_with_backslash_in_prose - verifies backslash
in prose (e.g., Windows paths) doesn't break JSON extraction.
@samkujovich
samkujovich merged commit 08c2cf7 into main Feb 15, 2026
2 checks passed
@samkujovich
samkujovich deleted the fix/post-merge-tweaks branch February 15, 2026 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant