Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Discovery/adr_discovery/extractor/formats/frontmatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
22 changes: 22 additions & 0 deletions Discovery/adr_discovery/tests_unit/test_frontmatter_tolerance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:*)",))
]