-
Notifications
You must be signed in to change notification settings - Fork 7.8k
feat: add question-render fenced markers and Claude transformer #2186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,117 @@ | ||||||||||
| """Question block transformer for Claude Code integration.""" | ||||||||||
|
|
||||||||||
| from __future__ import annotations | ||||||||||
|
Comment on lines
+1
to
+3
|
||||||||||
|
|
||||||||||
| import json | ||||||||||
| import re | ||||||||||
|
|
||||||||||
| _FENCE_RE = re.compile( | ||||||||||
| r"<!-- speckit:question-render:begin -->\s*\n(.*?)\n\s*<!-- speckit:question-render:end -->", | ||||||||||
| re.DOTALL, | ||||||||||
|
Rohan-1920 marked this conversation as resolved.
|
||||||||||
| ) | ||||||||||
| _SEPARATOR_RE = re.compile(r"^\|[-| :]+\|$") | ||||||||||
|
|
||||||||||
| # Markers that promote an option to the top of the list. | ||||||||||
| _RECOMMENDED_RE = re.compile(r"\bRecommended\b\s*[\u2014\-]", re.IGNORECASE) | ||||||||||
|
|
||||||||||
|
|
||||||||||
| def _parse_table_rows(block: str) -> list[list[str]]: | ||||||||||
| """Return data rows from a Markdown table, skipping header and separator.""" | ||||||||||
| rows: list[list[str]] = [] | ||||||||||
| header_seen = False | ||||||||||
| separator_seen = False | ||||||||||
|
|
||||||||||
| for line in block.splitlines(): | ||||||||||
| stripped = line.strip() | ||||||||||
| if not stripped.startswith("|"): | ||||||||||
| continue | ||||||||||
| if not header_seen: | ||||||||||
| header_seen = True | ||||||||||
| continue | ||||||||||
| if not separator_seen: | ||||||||||
| if _SEPARATOR_RE.match(stripped): | ||||||||||
| separator_seen = True | ||||||||||
| continue | ||||||||||
| cells = [c.strip() for c in stripped.split("|")[1:-1]] | ||||||||||
| if cells: | ||||||||||
| rows.append(cells) | ||||||||||
|
|
||||||||||
| return rows | ||||||||||
|
|
||||||||||
|
|
||||||||||
| def parse_clarify(block: str) -> list[dict]: | ||||||||||
| """Parse clarify.md schema: | Option | Description |.""" | ||||||||||
| options: list[dict] = [] | ||||||||||
| recommended: dict | None = None | ||||||||||
| seen_labels: set[str] = set() | ||||||||||
|
|
||||||||||
| for cells in _parse_table_rows(block): | ||||||||||
| if len(cells) < 2: | ||||||||||
| continue | ||||||||||
| label = cells[0] | ||||||||||
| description = cells[1] | ||||||||||
| if label in seen_labels: | ||||||||||
| continue | ||||||||||
| seen_labels.add(label) | ||||||||||
| entry = {"label": label, "description": description} | ||||||||||
| if _RECOMMENDED_RE.search(description): | ||||||||||
| if recommended is None: | ||||||||||
| recommended = entry | ||||||||||
|
||||||||||
| recommended = entry | |
| recommended = entry | |
| else: | |
| options.append(entry) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ARGUMENT_HINTSis imported but not used in this module anymore (hint resolution moved intoskill_postprocess.apply_claude_skill_postprocess). Consider dropping the unused import to keep the module tidy.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot apply changes based on this feedback