Summary
Would you be open to an optional, entirely local estimate of LLM token counts for text-based clipboard cards?
The proposed card metadata would look like:
This would deliberately be a model-agnostic estimate, not an exact tokenizer count. The ≈ marker and settings copy would make that limitation explicit because different model families tokenize the same text differently.
Proposed product decisions
Before implementing, I would like explicit approval on these three points:
- Estimate, not a model-specific tokenizer — a small dependency-free heuristic, clearly marked with
≈.
- Opt-in — disabled by default under a new Cards setting.
- Text-only scope — available for
.text, .richText, and .link cards; omitted from image, color, and file cards.
Proposed setting:
Show estimated LLM token counts
Uses a local, model-agnostic estimate. Actual token counts vary by model.
Privacy and architecture
The first version would preserve Pesty's existing dependency-free and local-first design:
- no API calls, network access, telemetry, or clipboard uploads;
- no third-party packages or bundled tokenizer vocabulary;
- no changes to
ClipItem, JSON persistence, iCloud Drive, CloudKit, or the clipboard capture pipeline;
- lazy computation only for materialized cards;
- estimation outside the main actor, with cancellation;
- bounded in-memory cache by text content;
- 5 MiB maximum input;
- current character metadata shown immediately, with no spinner while the estimate is pending.
A model-specific tokenizer such as o200k_base would remain a separate proposal because it would require decisions about tokenizer choice, data licensing, resources, bundle size, and ongoing vocabulary maintenance.
Validation
If this direction is accepted, the PR would include:
- dependency-free XCTest coverage across prose, code, JSON, URLs, Portuguese, emoji, CJK, Arabic, combining characters, cancellation, and size limits;
- calibration against reference counts generated outside the package;
swift build, swift test, and universal app bundle validation;
- before/after strip screenshots and a screenshot of the new setting;
- performance checks confirming that the first frame and clipboard monitor do not depend on estimation.
If these three product decisions fit the project, I can proceed with the focused implementation.
Summary
Would you be open to an optional, entirely local estimate of LLM token counts for text-based clipboard cards?
The proposed card metadata would look like:
This would deliberately be a model-agnostic estimate, not an exact tokenizer count. The
≈marker and settings copy would make that limitation explicit because different model families tokenize the same text differently.Proposed product decisions
Before implementing, I would like explicit approval on these three points:
≈..text,.richText, and.linkcards; omitted from image, color, and file cards.Proposed setting:
Privacy and architecture
The first version would preserve Pesty's existing dependency-free and local-first design:
ClipItem, JSON persistence, iCloud Drive, CloudKit, or the clipboard capture pipeline;A model-specific tokenizer such as
o200k_basewould remain a separate proposal because it would require decisions about tokenizer choice, data licensing, resources, bundle size, and ongoing vocabulary maintenance.Validation
If this direction is accepted, the PR would include:
swift build,swift test, and universal app bundle validation;If these three product decisions fit the project, I can proceed with the focused implementation.