Skip to main content

primarysource

A primary source is the text itself: answer from it, and say exactly where it is.

One package, many collections. The core is a sectioned-document model, a ref grammar, token-budgeted paging, a fixed result shape, readers, a full-text index, a CLI and an MCP server. Each collection is a subpackage behind an extra: rfc (the RFC series, moved in from rfclib), nist, usb, itu, zim, cve, and more. PLAN.md has the design and ROADMAP.md the open work.

pip install "primarysource[rfc,mcp]"
primarysource collections
primarysource mcp --collection rfc

Pre-alpha. It ships no document text: you fetch the sources yourself.

What works today

from primarysource.budget import page
from primarysource.model import Document, Section, Unit, span_hash
from primarysource.refs import RefGrammar
from primarysource.render import render

grammar = RefGrammar(r"(?:RFC|BCP|STD)\d+")
ref = grammar.parse("RFC9000§9.6¶2")          # Ref(doc='RFC9000', section='9.6', para=2)

document = Document("demo", "Demo", Unit.SENTENCE, (Section("1", "Scope", ("First.", "Second.")),))
section = document.section("1")
result = page(section.units, start=1, max_tokens=2000)
print(render(" ".join(result.units), {"cite": "Demo §1", "unit": document.unit, "span": span_hash("First.")}))
Module What it does
primarysource.model Document, Section, the declared Unit that ¶n counts, span_hash
primarysource.refs RefGrammar: <doc>§<section>[#anchor][¶n] and <doc>:<first>-<last>, for a library's own document-id pattern
primarysource.budget tokens, page: whole units up to a token budget, always making progress, with next_start
primarysource.render body plus cite:, unit:, span:, next:, relaxed:, warning: footer lines in a fixed order
primarysource.errors LibError(message, hint): an error that names its remedy
primarysource.home resolve_home(app): $<APP>_HOME or the per-user data directory; atomic_write

What it does not do yet

It reads no file format, builds no index, has no command and serves nothing. No library depends on it.

Tests

python -m pytest -q from this directory. All tests use invented text.

Metadata

Release files for primarysource 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for primarysource 0.1.0
File Size Uploaded Provenance Actions
primarysource-0.1.0.tar.gz 1.4 MB With provenance Details for primarysource-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for primarysource 0.1.0
File Interpreter ABI Platform Actions
primarysource-0.1.0-py3-none-any.whl Python 3 none any Details for primarysource-0.1.0-py3-none-any.whl

Total release size: 2.2 MB

Release files / primarysource-0.1.0.tar.gz

Download URL primarysource-0.1.0.tar.gz
Size 1.4 MB
Tags Source
SHA-256 checksum
How to use checksums
ba2da54d020c6229868e6e56dde883fa1f124d0033644e6e69dc13ad29bffc93
BLAKE2b-256 checksum
How to use checksums
2559d4530a92e201bfe49812d6f0e097e4f26f2365a6b9539d6460a5a047767e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.

Transparency log

Release files / primarysource-0.1.0-py3-none-any.whl

Download URL primarysource-0.1.0-py3-none-any.whl
Size 880.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
febf77900ae19e41da372bdea9f2a71207ae65e06f0657a5b6c81290e111bef0
BLAKE2b-256 checksum
How to use checksums
640e9d66fdad09b99859131bd781f8b9f26be1c868e4106d9065e7f3641ff20a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.

Transparency log

Security for primarysource 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for primarysource-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page