feat(parser): Markdown and YAML knowledge extractors#539
Open
otalrapha wants to merge 1 commit into
Open
Conversation
Adds regex-based extractors for two formats that have no bundled tree-sitter grammar (same approach already used for ReScript and SQL CREATE PROCEDURE): - Markdown (.md/.mdx/.qmd): each heading becomes a Section node; heading nesting produces CONTAINS edges; backtick filenames / [[wikilinks]] / [text](x.md) links produce REFERENCES edges. Fenced code blocks are skipped. - YAML (.yaml/.yml): top-level keys become Section nodes and registry-style list entries (id:/name:) become Type nodes, with CONTAINS edges. Pure regex, no PyYAML dependency. Because both reuse the existing NodeInfo/EdgeInfo schema and the shared CONTAINS/REFERENCES edge kinds, documentation and config now live in the SAME graph as code — e.g. a spec.md REFERENCES the source file it describes, and a CRON-123 registry entry is a queryable node. Tests: tests/test_knowledge_extractors.py (4 cases — headings/nesting, code fence skip, references, yaml entries). ruff clean, pytest green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds two regex-based extractors so the graph can index knowledge files that have no bundled tree-sitter grammar:
.md/.mdx/.qmd): headings →Sectionnodes, nesting →CONTAINSedges, links (backtick filenames,[[wikilinks]],[text](x.md)) →REFERENCESedges. Fenced code blocks are skipped..yaml/.yml): top-level keys →Sectionnodes, registry-styleid:/name:list entries →Typenodes, withCONTAINSedges. Pure regex, no PyYAML dependency.Why
Both reuse the existing
NodeInfo/EdgeInfoschema and the sharedCONTAINS/REFERENCESedge kinds, so documentation and config land in the same graph as code: aspec.mdcanREFERENCESthe source file it describes, and aCRON-123registry 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 inEXTENSION_TO_LANGUAGE, dispatch inparse_bytes, dedicated_parse_markdown/_parse_yamlmethods.Tests
tests/test_knowledge_extractors.py— 4 cases (headings/nesting, fenced-code skip, references, yaml entries).ruff checkpasses clean,pytestgreen locally.