Skip to content

feat: add find_text, on-screen OCR with Windows.Media.Ocr (#117) - #145

Merged
TMHSDigital merged 1 commit into
mainfrom
feat/find-text-117
Oct 24, 2026
Merged

TMHSDigital merged 1 commit into
mainfrom
feat/find-text-117

Conversation

@TMHSDigital

Copy link
Copy Markdown
Owner

Closes #117.

What

New tool find_text { target | input, timestamp, query, regex, redact, returnImage, exactTitle }.

  • Source: a live screenshot of target, or a frame of an image/video input.
  • OCR: Windows.Media.Ocr through WinRT from Windows PowerShell 5.1 (AsTask reflection to await). Paths travel base64-encoded (no quoting), and every pass runs in one PowerShell process (~1 s per call).
  • Returns text, lines (each with a bounding box, capped at 300), and with a query: matches boxed around the words they span plus the image inline with matches outlined. redact: true adds padded, clamped redactRegions for redact_region.
  • A missing OCR language gives an actionable hint (Settings > Language > Optical character recognition). Non-Windows gets a clear error.

What testing turned up

  • Windows OCR silently drops ALL_CAPS words joined by underscores. OPENAI_API_KEY=sk-proj-… vanished entirely at 1×, 2×, and 3× on 18 px text (so did API_KEY=abc), while ghp_… and token: sk-… were fine. Binarizing, inverting, and padding didn't help; 4× did. So recognition merges a 2× and a 4× pass (de-duplicating overlapping lines, keeping the longer reading), capped at the engine's 10,000 px limit.
  • At 4× the engine reads _ as - and I as l, so plain queries match through a normalization (-/_/space, l/I/1/|, O/0). OPENAI_API_KEY matches the misread OPENAI-APl-KEY. Regex queries match the raw text.

End to end (through the server)

Find regex: "sk-|ghp_" on a video frame → 2 matches + redactRegions → redact_region → re-run find_text → 0 matches, non-secret lines still readable. This loop is in the live harness too.

Tests

  • Unit (ocr.test.ts, 10): pass parsing and de-scaling, PowerShell's single-object quirk, language-missing hint, pass merging, normalization, plain/phrase/repeated/regex matching with word boxes, redaction padding and clamping, scale capping.
  • Live harness (Windows): the find → redact → re-check loop with real OCR. 13/13.
  • Full suite 273.

The threat model in the README now points to find_text as an aid for finding secrets, and is explicit that OCR is best-effort. Version 0.19.0; README (30 tools), Pages, mcp-tools.json, CHANGELOG.

🤖 Generated with Claude Code

Reads text from the screen or an image/video frame with Windows' built-in
OCR, returning lines and query matches with bounding boxes, and with
redact: true, padded rectangles ready for redact_region. Two upscaled
passes are merged because the engine drops ALL_CAPS_UNDERSCORE words at
normal sizes, and plain queries tolerate its usual misreads.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Oct 24, 2026
@TMHSDigital
TMHSDigital merged commit 3c479d0 into main Oct 24, 2026
8 checks passed
@TMHSDigital
TMHSDigital deleted the feat/find-text-117 branch October 24, 2026 21:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

find_text: on-screen OCR with Windows.Media.Ocr, plus redaction suggestions

1 participant