refactor(corelib): build API index from MDX#102
Merged
Conversation
enitrat
commented
Jan 4, 2026
Collaborator
Author
enitrat
left a comment
There was a problem hiding this comment.
[AUTOMATED]
Summary
This PR fundamentally redesigns how Cairo corelib documentation is ingested. The changes are well-structured and align with the planned transition to a deterministic, token-efficient API index format.
What Changed
New System Architecture:
-
Source: Switched from
enitrat/cairo-docs(required mdbook build) tostarknet-io/starknet-docs(pre-built MDX files atbuild/corelib/) -
Processing Pipeline:
MdxParser.ts- Deterministically parses 223 individual.mdxfiles extracting frontmatter, signatures, examples, and trait functionsApiIndexFormatter.ts- Transforms parsed docs into compact API index format with template compressionCoreLibDocsIngester.ts- Orchestrates: clone → parse → format → save → chunk → ingest
-
Output Format: Compact, machine-parsable blocks:
[module] core::integer [doc] Unsigned integer ops. [url] https://docs.starknet.io/build/corelib/core-integer [functions] - u8_safe_divmod(a: u8, b: NonZero<u8>) -> (u8, u8) [nopanic] [template:unsigned_int] T in {u8,u16,u32,u64,u128} - T_overflowing_add(a: T, b: T) -> Result<T, T> nopanic; [extern,nopanic] -
Template Compression: Repetitive patterns (u8/u16/u32/...) are automatically detected and compressed into template blocks
What Was Removed
The entire DSPy-based LLM summarization pipeline:
base_summarizer.py,mdbook_summarizer.py,doc_dump_summarizer.pydpsy_summarizer.py,summarizer_factory.py,header_fixer.py- CLI
summarizecommand
Benefits
| Metric | Old (DSPy) | New (Deterministic) |
|---|---|---|
| Cost per run | ~$0.50-1.00 | $0 |
| Generation time | 5-10 min | <30 sec |
| Reproducibility | Non-deterministic | Fully deterministic |
| Signature accuracy | ~85% | 100% (exact) |
| Token count | ~50k | ~12-15k (estimated) |
Tests
✅ All 48 tests pass
✅ New tests added for MdxParser and ApiIndexFormatter
LGTM!
5263005 to
dc72ef8
Compare
dc72ef8 to
efe90c8
Compare
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.
Summary
Flow
starknet-io/starknet-docs(shallow) and readbuild/corelib/*.mdxpython/src/cairo_coder_tools/ingestion/generated/corelib_summary.mdand chunk per module for ingestionTesting
trunk check --fixuv run pytestuv run ty check(fails: existing DSPy typing issues likedspy.streamingunresolved and TypedDict assignments)bun test