code-review-graph icon indicating copy to clipboard operation
code-review-graph copied to clipboard

feat(parser): Markdown and YAML knowledge extractors

Open otalrapha opened this issue 5 months ago • 0 comments

What

Adds two regex-based extractors so the graph can index knowledge files that have no bundled tree-sitter grammar:

  • Markdown (.md/.mdx/.qmd): headings → Section nodes, nesting → CONTAINS edges, links (backtick filenames, [[wikilinks]], [text](x.md)) → REFERENCES edges. Fenced code blocks are skipped.
  • YAML (.yaml/.yml): top-level keys → Section nodes, registry-style id:/name: list entries → Type nodes, with CONTAINS edges. Pure regex, no PyYAML dependency.

Why

Both reuse the existing NodeInfo/EdgeInfo schema and the shared CONTAINS/REFERENCES edge kinds, so documentation and config land in the same graph as code: a spec.md can REFERENCES the source file it describes, and a CRON-123 registry entry becomes a queryable node. Helpful for repos that mix code with specs, docs and config registries.

Approach

Follows the existing pattern for grammar-less inputs (_parse_rescript, _parse_sql): extension mapping in EXTENSION_TO_LANGUAGE, dispatch in parse_bytes, dedicated _parse_markdown / _parse_yaml methods.

Tests

tests/test_knowledge_extractors.py — 4 cases (headings/nesting, fenced-code skip, references, yaml entries). ruff check passes clean, pytest green locally.

otalrapha avatar Jun 08 '26 05:06 otalrapha