Skip to content

Add comment_type: markdown for agent and skill definition files #94

Description

@HartmannNico

Motivation

AI agent and skill definition files (.claude/agents/*.md, .github/prompts/*.md, Copilot instruction files) are increasingly the primary implementation artefacts of agentic systems. They sit at the same layer as Rust or Python source files in a requirements → architecture → design → implementation traceability chain — but sphinx-codelinks currently has no comment_type that covers Markdown.

Without Markdown support, any design node whose implementation is a Markdown agent file cannot close its downstream implementation coverage in the graph. This blocks the traceability spine at precisely the point where AI-native projects need it most.

Proposed solution

Add comment_type: markdown backed by tree-sitter-markdown, using block-level HTML comments as the marker carrier:

<!-- @needs My agent realization, prd_unit_imp__thalam__agent_realization, prd_unit_imp, [prd_unit_des__thalam__agent_realization] -->

HTML comments are:

  • Invisible in all Markdown renderers (GitHub, VS Code, Sphinx/MyST)
  • Valid CommonMark — no extension required
  • Git-diffable and grep-able in plain text

Implementation shape (3 files, ~24 lines)

tree-sitter-markdown maps standalone <!-- … --> blocks to html_block nodes. The tree-sitter query is simply (html_block) @comment.

source_discover/config.py

"markdown": ["md", "markdown"],     # COMMENT_FILETYPE
markdown = "markdown"               # CommentType enum

analyse/utils.py

MARKDOWN_QUERY = """(html_block) @comment"""

elif comment_type == CommentType.markdown:
    import tree_sitter_markdown
    parsed_language = Language(tree_sitter_markdown.language())
    query = Query(parsed_language, MARKDOWN_QUERY)

No SCOPE_NODE_TYPES entry needed — Markdown has no function/class scopes; oneline-only mode (get_oneline_needs=True, get_need_id_refs=False) never invokes scope association.

pyproject.toml

"tree-sitter-markdown>=0.5.1",

One caller-side note

Because html_block node text includes the full <!-- … --> delimiters, callers must set end_sequence: " -->" (not the default "\n") in their oneline_comment_style config. This is the only difference from all other comment_type entries and should be documented in the README example.

Precedent

Analogous to the bash comment_type (PR #92). PR #82 (TypeScript) is the structural template for this PR shape.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions