v0.3.0
v0.3.0
This is a cleanup release that hardens the build, makes TextDoc source-referenced and
Markdown-block-aware, and removes the mandatory tiktoken (network) dependency. It
contains several intentional breaking changes for a cleaner API.
Breaking changes
- Token counting is now a dependency-free estimate. The
tiktokendependency is
removed (along withrequests/urllib3at install time), so chopdiff no longer
downloads a tokenizer or needs network access to size or summarize a document.TextUnit.tiktokensis renamed toTextUnit.tokensand now returns a heuristic
estimate (chopdiff.util.token_estimate.estimate_tokens, ~3.8 characters/token,
a blend of current OpenAI/Anthropic/Google rules of thumb).chopdiff.util.tiktoken_utilsandtiktoken_lenare removed. Migrate
from chopdiff.util.tiktoken_utils import tiktoken_lento
from chopdiff.util.token_estimate import estimate_tokens.size_summary()reports the estimate as~N tok.- Exact, provider-keyed token counts (tiktoken/OpenAI, and network-based counters
for other providers) are planned as opt-in extras in a future release.
- Character offsets are now an
Offsetsrecord.Paragraph.char_offsetand
Sentence.char_offset(plain ints) are replaced by anOffsets(doc_offset, block_offset)record on both:doc_offsetis the absolute offset in the document;block_offsetis relative to
the enclosing block (the document for a paragraph, the paragraph for a sentence).TextDoc.char_offset_in_doc(index)is removed; use
doc.get_sent(index).offsets.doc_offset.- Offsets are now exact references into the unmodified input text (the document is no
longer stripped during parsing).
- Paragraph splitting recognizes all blank lines. Paragraphs split on two or more
newlines, including blank lines that contain only whitespace; runs of blank lines
collapse into a single break. Previously only a literal\n\nsplit. - Removed the unused
chopdiffconsole-script entry point. chopdiff is a library
with no CLI; the entry point pointed at a non-existentmain.
New features
- Markdown block-type classification.
BlockType(heading, paragraph, list, table,
code, blockquote, html, footnote) andParagraph.block_type, classified by parsing
each block with flowmark's Markdown (marko) parser.TextDoc.iter_blocks(include=, exclude=)andTextDoc.filtered(include=, exclude=)iterate or sub-select blocks by
type (e.g. process only paragraphs and list items, skipping headings and tables), and
aggregate counts such as sentences/words across paragraph blocks. - Exact source references. Paragraph and sentence
Offsetsround-trip into the
original text;TextDocdocuments a clear contract for offsets and in-place editing.
Infrastructure
- Supply-chain hardening: a 14-day dependency cool-off (
exclude-newer), a committed
lockfile, frozenuv sync --lockedinstalls in CI, and apip-auditgate. See
SUPPLY-CHAIN-SECURITY.md. - Upgraded to the simple-modern-uv template v0.2.26 (Python 3.14 in the CI matrix, uv
0.11.12, basedpyright 1.39.3, docs underdocs/). - The release workflow now installs from the committed lockfile (
--locked) for
reproducible release builds.