Repository navigation
Releases
Releases · ptmorris05/ecfr-md
ecfr-md 0.2.0
On PyPI: uv tool install ecfr-md or pip install ecfr-md, with the extras web, tui, mcp, docx, pdf and all.
Added
ecfr-md browse [CITATION] [--date DATE]: a full-screen terminal browser
(thetuiextra, Textual). The outline of the whole CFR beside the text,
with a breadcrumb and the date of the text. Everything works with the
arrow keys, Enter and Esc, shown in the footer: in the text,↑/↓
paragraphs,←/→cross-references, Enter follows one or opens an
entry of contents, Esc goes back (from the first place, up a level; it
never quits); in the outline,↑/↓move,→/←open and close
branches or go in and out, Enter reads;tabmoves between the two; in
dialogs,↓/↑go from the box to the list and back, Enter chooses,
Esc closes. Letter keys are shortcuts:ggo to any citation
(completed from the outline),/search,[/]previous and next
section,j/kparagraphs,uup,b/fback and forward,dtext
as of a date,hchanges with a redline of each,eexport in every
format,ycopy the paragraph's citation,othe outline,?keys.
The mouse works too. Theallextra includestui.- An MCP server for AI agents:
ecfr-md mcp(stdio, or streamable HTTP
with--http), andecfr_md.mcp.server(ecfr)for apps that serve it
themselves. Needs the newmcpextra (FastMCP 4.2), whichallnow
includes. Read-only tools with output schemas and Markdown results:
list_titles,outline(token estimates per entry),read(the text
that fits a token budget, with a cursor to continue, full pinpoint
paragraph labels, paragraph ids and what's around it),search,
changes,history,compare(located redline with the amendments
between the dates),references,cited_by,resolve_citation,
verify_quote,defineandsettings;exportwrites only under
--export-dir, andconfigureexists only with
--allow-config-changes. Resourcescfr:{address},cfr:titlesand
ecfr-md:settings, with subscriptions that notify when the eCFR changes
the text; citation completions; prompts for summarizing obligations,
what changed, comparing provisions and finding a term; progress and
cancellation for large fetches. ecfr_md.define()/ECFR.define(term, citation)and
ecfr-md define TERM CITATION: the definition of a term that governs a
place in the CFR, found in the place's text and the definitions sections
that apply to it (Definition,Definitions).ecfr_md.verify_quote()/ECFR.verify_quote(citation, text)and
ecfr-md verify CITATION --quote TEXT: whether a quotation is word for
word at a pinpoint, else where it is or the nearest text (QuoteCheck).ecfr_md.passages: text cut to a token budget at paragraph boundaries
with a cursor (passage,Passage), and the paragraph at any offset
(TextIndex).--jsononget(the same as--format json),syncand
cache clear, so every command can print JSON.- An agent skill,
skills/ecfr-md/SKILL.md, that teaches the command
line, and an AI agents guide with setup for Claude Code and other MCP
clients. - Not-found errors suggest near misses: "did you mean 164.502?".
ecfr-md serve: a web navigator for the CFR, run on this computer
(webextra: Starlette, uvicorn, Jinja2). Paths mirror ecfr.gov
(/current/...,/on/DATE/...,/compare/LATER/to/EARLIER/...), and
/go?cite=resolves any citation. Pages for titles, divisions (contents
with section counts and sizes), text, history, comparisons (an inline
word-level redline), search, export in every format (downloaded, or saved
to--save-dir) and settings (everySettingsfield, applied at once and
optionally written to the config file). A command palette (⌘K) for
citations, headings, known names, words, dates and actions; hover
previews of cross-references and "open beside"; defined terms underlined
with their definitions; paragraph and range deep links; copy with
citation (OFR or Bluebook); a versions timeline; outline, focus, text size,
density, light and dark;j/k/[/]/ukeys. Text streams with a
progress hairline, neighbouring pages are prerendered, a service worker
keeps read pages offline, and there is a print stylesheet. Every page is
also.mdand.json, with/llms.txtand/openapi.json. It answers
only local host names unless--hostopens it, and refuses cross-site
requests that change anything.ecfr_md.web.create_app()is the ASGI app.ECFR.definitions(citation): every defined term that governs a place,
nearest first, as the web navigator underlines them.ecfr_md.compare.aligned(): both texts block by block, unchanged blocks
included, for a whole-text redline;Difference.kindis"unchanged"
for those.- The HTML writer is a class,
render.html_writer.Writer, with a method
per kind of block to override; inline<ins>and<del>are kept as
insertions and deletions. - The
allextra includesweb. - MIT license. Releases are published on GitHub from version tags, with the
wheel and source distribution attached and build provenance attested. - A documentation site with an API reference, built from the README,
changelog and docstrings. - Navigation: nodes from a client have
nextandprevious(the
neighbouring section or appendix, across parts, chapters and titles),
up(the parent, or the division above the text fetched) andoutline
(their entry in the outline of the whole CFR). Outline entries have
next,previous,up,siblingsandread(date=), which fetches the
text. Nodes fromload()raiseECFRErrorfor these. ecfr_md.outline()/ECFR.outline()with no citation: the whole CFR,
one entry per title, each title's structure loaded when first opened.- Cross-references:
Node.references,find_references(text, context)
andReference(start,end,text,target,citation,url,
kind). Sections, lists and ranges of them, paragraphs "of this section"
or "of § X", parts, subparts and appendices relative to the text, other
titles, and citations of the U.S. Code, the Federal Register and public
laws, which link to uscode.house.gov, federalregister.gov and
congress.gov (templatesUSC_URL,FR_URL,PUBLIC_LAW_URL). ecfr_md.cited_by()/ECFR.cited_by()andecfr-md cited-by: sections
that may cite a section or part, found by search (approximate).ecfr-md references CITATION: a section's cross-references and what
they refer to.- Linked Markdown:
links=onsave(),Node.save()and--links/
--no-linksonget;to_markdown(links=True). Trees link their
cross-references to each other's files by default, and to the eCFR for
anything outside the tree. Front matter recordslinks. Node.anchor: the eCFR's id for a paragraph (p-164.502(a)(1)),
section (164.502), subpart, part or appendix.ecfr-md outlineof a section or appendix ends with the previous and
next ones.- Offline reading: when the eCFR can't be reached, the newest cached title
list and text are used, with anECFRWarningthat they may be out of
date. ecfr-md titles,ecfr_md.titles()andECFR.titles(): every title with
the latest date of its text (TitleInfo). A bareecfr-md outlinelists
them too.ecfr-md compare CITATION --since DATE [--until DATE],ECFR.compare()
andecfr_md.compare(): what changed between two dates, paragraph by
paragraph and word by word (Comparison,Difference).changesends
with the compare command for the latest change.search --in CITATION(within=in Python, and on every search
endpoint) limits a search to a title or any part of it. Unquoted words
form one query.get_many(..., errors="return")keeps going past citations that fail.- In a terminal,
getindents paragraphs, shows the section and parent
paragraphs above a paragraph, pages long text (--no-pager), shows
footnote marks as superscripts, and ends with the citation, date and
eCFR link. get -o -prints to stdout;get --from -reads stdin;--fromlines
may have# comments, quotes and lists.cache info --json.- Export formats besides Markdown: plain text, HTML, JSON, EPUB, Word and PDF.
Node.export(path, format=None)andsave(..., format=)on nodes,ECFR
andecfr_mdpick the format from the file's suffix (hipaa.pdf) unless
format=names one;ecfr-md get -o hipaa.pdfand--formatlikewise,
andget --format json|text|htmlprints. HTML pages are standalone, light
and dark, print well, and anchor paragraphs with the eCFR's ids
(#p-164.502(a)(1)). JSON is the node tree with each node's own text and
provenance. Word documents use Word's heading styles; PDFs have a bookmark
per heading, a running head and page numbers. Withtree=True(--tree,
and--all), text and HTML get a file per section and an index page per
level, and the others a file per part, written as the text is read. - Extras
docx(python-docx),pdf(Typst, which needs no system libraries)
andall. Without one, saving raisesMissingDependencyError, which says
what to install. - Addresses: one short, shell-safe name for every place in the CFR, e.g.
45/164.502/a/1,45/part-164/subpart-E,12/part-1026/supplement-I,
26/1.401.k-1(26 CFR 1.401(k)-1),45/164.501/1~2(the second of two
(1)s),45/164.502@2020-01-01; lists (45/164.502,164.504) and ranges of
paragraphs (45/164.502/b..d). Address:Address.parsereads addresses, citations (now also Bluebook
forms, spaced164.502 a 1and dotted164.502.a.1markers), eCFR, LII and
GovInfo links, GovInfo granule ids, USLM identifiers,cfr:URIs and the
names of saved files, old and new.str(),.citation()("ofr"or
"bluebook"),.url(),.uri(),.file_name();Address.parse_manyfor
lists.- Everything that takes a citat...
ecfr-md 0.2.0rc1
Install from GitHub; ecfr-md is not on PyPI.
Added
ecfr-md browse [CITATION] [--date DATE]: a full-screen terminal browser
(thetuiextra, Textual). The outline of the whole CFR beside the text,
with a breadcrumb and the date of the text. Keys:ggo to any citation
(completed from the outline),/search,[/]previous and next
section,j/kparagraphs,tabandenter(or a click) to follow
cross-references,uup,b/fback and forward,dtext as of a
date,hchanges with a redline of each,eexport in every format,y
copy the paragraph's citation,othe outline,?keys. Theall
extra includestui.- An MCP server for AI agents:
ecfr-md mcp(stdio, or streamable HTTP
with--http), andecfr_md.mcp.server(ecfr)for apps that serve it
themselves. Needs the newmcpextra (FastMCP 4.2), whichallnow
includes. Read-only tools with output schemas and Markdown results:
list_titles,outline(token estimates per entry),read(the text
that fits a token budget, with a cursor to continue, full pinpoint
paragraph labels, paragraph ids and what's around it),search,
changes,history,compare(located redline with the amendments
between the dates),references,cited_by,resolve_citation,
verify_quote,defineandsettings;exportwrites only under
--export-dir, andconfigureexists only with
--allow-config-changes. Resourcescfr:{address},cfr:titlesand
ecfr-md:settings, with subscriptions that notify when the eCFR changes
the text; citation completions; prompts for summarizing obligations,
what changed, comparing provisions and finding a term; progress and
cancellation for large fetches. ecfr_md.define()/ECFR.define(term, citation)and
ecfr-md define TERM CITATION: the definition of a term that governs a
place in the CFR, found in the place's text and the definitions sections
that apply to it (Definition,Definitions).ecfr_md.verify_quote()/ECFR.verify_quote(citation, text)and
ecfr-md verify CITATION --quote TEXT: whether a quotation is word for
word at a pinpoint, else where it is or the nearest text (QuoteCheck).ecfr_md.passages: text cut to a token budget at paragraph boundaries
with a cursor (passage,Passage), and the paragraph at any offset
(TextIndex).--jsononget(the same as--format json),syncand
cache clear, so every command can print JSON.- An agent skill,
skills/ecfr-md/SKILL.md, that teaches the command
line, and an AI agents guide with setup for Claude Code and other MCP
clients. - Not-found errors suggest near misses: "did you mean 164.502?".
ecfr-md serve: a web navigator for the CFR, run on this computer
(webextra: Starlette, uvicorn, Jinja2). Paths mirror ecfr.gov
(/current/...,/on/DATE/...,/compare/LATER/to/EARLIER/...), and
/go?cite=resolves any citation. Pages for titles, divisions (contents
with section counts and sizes), text, history, comparisons (an inline
word-level redline), search, export in every format (downloaded, or saved
to--save-dir) and settings (everySettingsfield, applied at once and
optionally written to the config file). A command palette (⌘K) for
citations, headings, known names, words, dates and actions; hover
previews of cross-references and "open beside"; defined terms underlined
with their definitions; paragraph and range deep links; copy with
citation (OFR or Bluebook); a versions timeline; outline, focus, text size,
density, light and dark;j/k/[/]/ukeys. Text streams with a
progress hairline, neighbouring pages are prerendered, a service worker
keeps read pages offline, and there is a print stylesheet. Every page is
also.mdand.json, with/llms.txtand/openapi.json. It answers
only local host names unless--hostopens it, and refuses cross-site
requests that change anything.ecfr_md.web.create_app()is the ASGI app.ECFR.definitions(citation): every defined term that governs a place,
nearest first, as the web navigator underlines them.ecfr_md.compare.aligned(): both texts block by block, unchanged blocks
included, for a whole-text redline;Difference.kindis"unchanged"
for those.- The HTML writer is a class,
render.html_writer.Writer, with a method
per kind of block to override; inline<ins>and<del>are kept as
insertions and deletions. - The
allextra includesweb. - MIT license. Releases are published on GitHub from version tags, with the
wheel and source distribution attached and build provenance attested. - A documentation site with an API reference, built from the README,
changelog and docstrings. - Navigation: nodes from a client have
nextandprevious(the
neighbouring section or appendix, across parts, chapters and titles),
up(the parent, or the division above the text fetched) andoutline
(their entry in the outline of the whole CFR). Outline entries have
next,previous,up,siblingsandread(date=), which fetches the
text. Nodes fromload()raiseECFRErrorfor these. ecfr_md.outline()/ECFR.outline()with no citation: the whole CFR,
one entry per title, each title's structure loaded when first opened.- Cross-references:
Node.references,find_references(text, context)
andReference(start,end,text,target,citation,url,
kind). Sections, lists and ranges of them, paragraphs "of this section"
or "of § X", parts, subparts and appendices relative to the text, other
titles, and citations of the U.S. Code, the Federal Register and public
laws, which link to uscode.house.gov, federalregister.gov and
congress.gov (templatesUSC_URL,FR_URL,PUBLIC_LAW_URL). ecfr_md.cited_by()/ECFR.cited_by()andecfr-md cited-by: sections
that may cite a section or part, found by search (approximate).ecfr-md references CITATION: a section's cross-references and what
they refer to.- Linked Markdown:
links=onsave(),Node.save()and--links/
--no-linksonget;to_markdown(links=True). Trees link their
cross-references to each other's files by default, and to the eCFR for
anything outside the tree. Front matter recordslinks. Node.anchor: the eCFR's id for a paragraph (p-164.502(a)(1)),
section (164.502), subpart, part or appendix.ecfr-md outlineof a section or appendix ends with the previous and
next ones.- Offline reading: when the eCFR can't be reached, the newest cached title
list and text are used, with anECFRWarningthat they may be out of
date. ecfr-md titles,ecfr_md.titles()andECFR.titles(): every title with
the latest date of its text (TitleInfo). A bareecfr-md outlinelists
them too.ecfr-md compare CITATION --since DATE [--until DATE],ECFR.compare()
andecfr_md.compare(): what changed between two dates, paragraph by
paragraph and word by word (Comparison,Difference).changesends
with the compare command for the latest change.search --in CITATION(within=in Python, and on every search
endpoint) limits a search to a title or any part of it. Unquoted words
form one query.get_many(..., errors="return")keeps going past citations that fail.- In a terminal,
getindents paragraphs, shows the section and parent
paragraphs above a paragraph, pages long text (--no-pager), shows
footnote marks as superscripts, and ends with the citation, date and
eCFR link. get -o -prints to stdout;get --from -reads stdin;--fromlines
may have# comments, quotes and lists.cache info --json.- Export formats besides Markdown: plain text, HTML, JSON, EPUB, Word and PDF.
Node.export(path, format=None)andsave(..., format=)on nodes,ECFR
andecfr_mdpick the format from the file's suffix (hipaa.pdf) unless
format=names one;ecfr-md get -o hipaa.pdfand--formatlikewise,
andget --format json|text|htmlprints. HTML pages are standalone, light
and dark, print well, and anchor paragraphs with the eCFR's ids
(#p-164.502(a)(1)). JSON is the node tree with each node's own text and
provenance. Word documents use Word's heading styles; PDFs have a bookmark
per heading, a running head and page numbers. Withtree=True(--tree,
and--all), text and HTML get a file per section and an index page per
level, and the others a file per part, written as the text is read. - Extras
docx(python-docx),pdf(Typst, which needs no system libraries)
andall. Without one, saving raisesMissingDependencyError, which says
what to install. - Addresses: one short, shell-safe name for every place in the CFR, e.g.
45/164.502/a/1,45/part-164/subpart-E,12/part-1026/supplement-I,
26/1.401.k-1(26 CFR 1.401(k)-1),45/164.501/1~2(the second of two
(1)s),45/164.502@2020-01-01; lists (45/164.502,164.504) and ranges of
paragraphs (45/164.502/b..d). Address:Address.parsereads addresses, citations (now also Bluebook
forms, spaced164.502 a 1and dotted164.502.a.1markers), eCFR, LII and
GovInfo links, GovInfo granule ids, USLM identifiers,cfr:URIs and the
names of saved files, old and new.str(),.citation()("ofr"or
"bluebook"),.url(),.uri(),.file_name();Address.parse_manyfor
lists.- Everything that takes a citation takes any of those:
get,save,
outline,changes,get_many,search(within=),get --fromand the
CLI's citation words. - A trailing year, as in a Bluebook citation (
45 C.F.R. § 164.502 (2018)),
means that year's annual edition of the title (January 1 for titles 1–16,
April 1 for 17–27, July 1 for 28–41, October 1 for 42–50), instead of being
an error. A date in an address (@2020-01-01) is used likewise. Node.address,Node.uri(cfr:45/164.502@2024-01-01),Node.cite(style=, year=); `...