Skip to content

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

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

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.

Add support for Markdown HTML-comment traceability markers:

Changes:
- source_discover/config.py: add 'markdown' to COMMENT_FILETYPE (.md/.markdown)
  and CommentType.markdown enum value
- analyse/utils.py: add MARKDOWN_QUERY '(html_block) @comment', wire
  tree_sitter_markdown in init_tree_sitter(); no SCOPE_NODE_TYPES entry
  (markdown has no function/class scopes; oneline-only mode)
- pyproject.toml: add tree-sitter-markdown>=0.5.1 dependency

Note: callers must set end_sequence=' -->' (not the default newline) because
the html_block node text includes the full '<!-- ... -->' delimiters.

Closes #NNN. Template: PR-82 (TypeScript).
@ubmarco

ubmarco commented Jul 22, 2026

Copy link
Copy Markdown
Member

Nice, I will check this out. We are building the features in codelinks in sync with ubCode, so bear with me a little while I do that :)

@ubmarco

ubmarco commented Jul 22, 2026

Copy link
Copy Markdown
Member

I approved the CI, it fails.

…attern

- Fix test_source_discover + test_src_trace: add 'markdown' to expected
  comment_type validation error message list
- Add FE_MARKDOWN feature need to docs/source/components/features.rst
  (fixes docs build warnings for IMPL_MD_1/IMPL_MD_3/IMPL_LANG_1)
- Add default_oneliner_markdown fixture to tests/data/extraction/oneline.yaml
  with end_sequence: " -->" config
- Generate snapshot for the markdown extraction fixture
- Add init_markdown_tree_sitter fixture + test_extract_comments_markdown
  + test_init_tree_sitter_markdown to tests/test_analyse_utils.py
- Add 'markdown' entry to LANG_MAP in tests/test_extraction_fixtures.py
- Update docs: configuration.rst (supported values + table row),
  analyse.rst (language support list), change_log.rst (Unreleased entry)
@HartmannNico

Copy link
Copy Markdown
Author

pushed tests and doc as well. used pr #92 bash as template.

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

2 participants