Skip to content

Feature proposal: optional local LLM token estimates on text cards #81

Description

@joaoabdalla

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:

≈1.1k tok · 4.3k chars

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:

  1. Estimate, not a model-specific tokenizer — a small dependency-free heuristic, clearly marked with .
  2. Opt-in — disabled by default under a new Cards setting.
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions