Skip to content

feat(markdown): add CommentType.markdown backed by tree-sitter-markdown - #95

Open
HartmannNico wants to merge 2 commits into
useblocks:mainfrom
HartmannNico:feat/markdown-support-pr
Open

feat(markdown): add CommentType.markdown backed by tree-sitter-markdown#95
HartmannNico wants to merge 2 commits into
useblocks:mainfrom
HartmannNico:feat/markdown-support-pr

Conversation

@HartmannNico

Copy link
Copy Markdown

Closes #94

Summary

Adds comment_type: markdown backed by tree-sitter-markdown, enabling <!-- @needs … --> HTML-comment markers in Markdown files to be ingested as traceability nodes by sphinx-codelinks.

Primary use case: AI agent and skill definition files (.claude/agents/*.md, .github/prompts/*.md) that are the actual implementation artefacts of agentic systems and need to participate in a requirements → architecture → design → implementation traceability chain.

Changes (3 files, ~24 lines)

source_discover/config.py

  • Added "markdown": ["md", "markdown"] to COMMENT_FILETYPE
  • Added markdown = "markdown" to CommentType enum

analyse/utils.py

  • Added MARKDOWN_QUERY = """(html_block) @comment""" — tree-sitter-markdown maps standalone <!-- … --> blocks to html_block nodes
  • Added elif comment_type == CommentType.markdown: branch in init_tree_sitter() importing tree_sitter_markdown
  • No SCOPE_NODE_TYPES entry: Markdown has no function/class scopes; oneline-only mode never invokes scope association

pyproject.toml

  • Added tree-sitter-markdown>=0.5.1

Caller note

Because html_block node text includes the full <!-- … --> delimiters, callers must configure end_sequence: " -->" (not the default "\n") in their oneline_comment_style. This is the only behavioural difference from all other comment_type entries.

Example conf:

"my_agents": {
    "source_discover": {"src_dir": ".claude/agents", "comment_type": "markdown"},
    "analyse": {
        "get_oneline_needs": True,
        "get_need_id_refs": False,
        "oneline_comment_style": {
            "needs_fields": [...],
            "start_sequence": "<!-- @needs ",
            "end_sequence": " -->",
        },
    },
}

Relation to other PRs

Analogous to PR #92 (bash). PR #82 (TypeScript) was the structural template.
This PR is independent of PR #92 — it is based directly on main and does not require bash support to be merged first.

Loading
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.

Add comment_type: markdown for agent and skill definition files

3 participants