diff --git a/Discovery/adr_discovery/extractor/formats/frontmatter.py b/Discovery/adr_discovery/extractor/formats/frontmatter.py index a07adaab..fc0592f4 100644 --- a/Discovery/adr_discovery/extractor/formats/frontmatter.py +++ b/Discovery/adr_discovery/extractor/formats/frontmatter.py @@ -153,9 +153,12 @@ def _value(key: str, rest: str, continuation: list[str]): raise Unrepresentable(f"{key}: anchor, alias or tag outside the supported subset") if rest[:1] == "[": + if not is_list: + # Only list keys use the items. `argument-hint: [pr] [priority]` + # is how Claude Code documents hints; it is not one flow list. + return _SKIP text = " ".join([rest, *(_strip_comment(line.strip()) for line in content)]) - items = _flow_items(key, text) - return items if is_list else _SKIP + return _flow_items(key, text) if rest[:1] == "{": if is_list: diff --git a/Discovery/adr_discovery/tests_unit/test_frontmatter_tolerance.py b/Discovery/adr_discovery/tests_unit/test_frontmatter_tolerance.py index 1d0894d3..02117286 100644 --- a/Discovery/adr_discovery/tests_unit/test_frontmatter_tolerance.py +++ b/Discovery/adr_discovery/tests_unit/test_frontmatter_tolerance.py @@ -162,3 +162,25 @@ def test_skipped_keys_become_a_coverage_note_not_an_error(world): assert result.errors == () and len(result.declarations) == 1 probes = [p for p in gate.ledger.freeze().probes if p.name == "frontmatter"] assert len(probes) == 1 and probes[0].status == "ran" and "description" in probes[0].detail + + +def test_bracketed_argument_hint_is_skipped_not_failed(): + # The form Claude Code documents for slash commands. + values, skipped = parse_with_notes(fm("argument-hint: [pr-number] [priority] [assignee]", "model: haiku")) + + assert values == {"model": "haiku"} + assert skipped == ("argument-hint",) + + +def test_a_command_with_a_bracketed_argument_hint_is_a_declaration(world): + from adr_discovery.contracts.records import Candidate + from adr_discovery.extractor import extract + + world.file("/Users/a/.claude/commands/review-pr.md", + fm("argument-hint: [pr-number] [priority]", "allowed-tools: Bash(gh pr view:*)")) + result = extract(world.gate(), Candidate("marker_dir", "/Users/a/.claude/commands", "sweep")) + + assert result.errors == () + assert [(d.name, d.raw["allowed_tools"]) for d in result.declarations] == [ + ("review-pr", ("Bash(gh pr view:*)",)) + ]