Documentation
¶
Overview ¶
Package docparse extracts plain text from uploaded context documents. Markdown/plain text/CSV pass through verbatim; .docx and .xlsx are unzipped and their XML text extracted; .pdf text is extracted with a pure-Go PDF reader after a bounded pre-validation pass. Images are detected but not text-extractable (they are handled by the vision path, not here).
Index ¶
Constants ¶
const MaxExtractedBytes = 2 << 20
MaxExtractedBytes caps the extracted text per document (mirrors the 2 MiB upload cap, §48 input budget). Extraction is deterministic and bounded.
Variables ¶
This section is empty.
Functions ¶
func ExtractText ¶
ExtractText returns the plain-text body of a document. Unsupported formats (including images, which need the vision path) return an error so the daemon rejects them rather than ingesting binary garbage.
func ImageMediaType ¶
ImageMediaType returns the MIME type for a recognized image (by magic bytes) or "" when data is not a JPEG/PNG/GIF/WebP. Used as the media-type allowlist for vision requests instead of content-sniffing.
func InferKind ¶
InferKind guesses the semantic context-doc kind (prd/design/tech/market/ other) from a filename, used when the uploader does not specify one. It is the single canonical mapping shared by the CLI and the daemon.
func Sniff ¶
Sniff returns the concrete file format: "pdf", "docx", "xlsx", "image", "text", or "unsupported". Magic bytes win over the extension; unknown binary input is classified "unsupported" so it is never ingested as garbage text. Images are classified by MAGIC BYTES ONLY — an extension-only match is NOT treated as an image, so a text file renamed to .png/.jpg still flows through the text path (credential-swept + redacted) instead of bypassing it.
Types ¶
This section is empty.