Skip to content

Conversation

kcrommett
Copy link

@kcrommett kcrommett commented Oct 12, 2025

Summary

  • Refactor File.Content to a discriminated union for type-safe text vs binary
    handling
  • Add MIME detection and include it in binary responses; update SDK types and do
    cs

Changes

  • Replace File.Content with a discriminated union keyed by type:
    • text: { type: "text", content, diff?, patch? }
    • binary: { type: "binary", content /* base64 */, mimeType }
  • Add getMimeType(path) with common extension map and application/octet-strea m fallback
  • Add isBinaryFile(path, file) using extension heuristics plus a null-byte sca
    n of the first up to 512 bytes
  • Update read(path):
    • Return binary with base64 content and mimeType for detected binaries
    • Return text content; when tracked in git, compute diff and full patch
      (tries unstaged, then staged)
  • Update SDK generated types to expose FileContent as a discriminated union
  • Update SDK docs with usage examples for binary (data URL) vs text content

Benefits

  • Strong compile-time guarantees when handling text vs binary content across ser
    ver and SDK
  • Explicit mimeType metadata enables correct client-side rendering and process
    ing
  • Clear API: diff/patch only on text variant; binary is base64 with metadata
  • Simpler client logic using content.type discriminator

@kcrommett kcrommett marked this pull request as ready for review October 12, 2025 05:14
@rekram1-node rekram1-node self-requested a review October 12, 2025 05:30
@rekram1-node
Copy link
Collaborator

@kmk142789 please stop reviewing prs, the review doesnt do anything since you arent a maintainer and it can lead to confusion with those trying to contribute

@rekram1-node
Copy link
Collaborator

@kcrommett ill peep this today thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants