Documentation
¶
Overview ¶
Package sources defines interfaces and implementations for document sources.
Index ¶
- Constants
- func NormalizeWebURL(raw string) string
- func ParseDocuments(ctx context.Context, source Source, file FileInfo) ([]*storage.Document, error)
- type BrowserOptions
- type BrowserSource
- func (b *BrowserSource) IsDocumentInScope(file FileInfo, doc *storage.Document) bool
- func (b *BrowserSource) MatchesPath(path string) bool
- func (b *BrowserSource) Name() storage.Source
- func (b *BrowserSource) Parse(ctx context.Context, file FileInfo) (*storage.Document, error)
- func (b *BrowserSource) ParseDocuments(ctx context.Context, file FileInfo) ([]*storage.Document, error)
- func (b *BrowserSource) ReconciliationScope(file FileInfo) string
- func (b *BrowserSource) Scan(ctx context.Context) (<-chan FileInfo, <-chan error)
- func (b *BrowserSource) SetOptions(options BrowserOptions)
- type ClipboardSource
- type CodeSource
- type DOCXSource
- type EPUBSource
- func (e *EPUBSource) IsDocumentInScope(file FileInfo, doc *storage.Document) bool
- func (e *EPUBSource) MatchesPath(filePath string) bool
- func (e *EPUBSource) Name() storage.Source
- func (e *EPUBSource) Parse(ctx context.Context, file FileInfo) (*storage.Document, error)
- func (e *EPUBSource) ParseDocuments(ctx context.Context, file FileInfo) ([]*storage.Document, error)
- func (e *EPUBSource) ReconciliationScope(file FileInfo) string
- func (e *EPUBSource) Scan(ctx context.Context) (<-chan FileInfo, <-chan error)
- type EmailAttachmentOptions
- type EmailSource
- func (e *EmailSource) IsDocumentInScope(file FileInfo, doc *storage.Document) bool
- func (e *EmailSource) MatchesPath(path string) bool
- func (e *EmailSource) Name() storage.Source
- func (e *EmailSource) Parse(ctx context.Context, file FileInfo) (*storage.Document, error)
- func (e *EmailSource) ParseDocuments(ctx context.Context, file FileInfo) ([]*storage.Document, error)
- func (e *EmailSource) ReconciliationScope(file FileInfo) string
- func (e *EmailSource) Scan(ctx context.Context) (<-chan FileInfo, <-chan error)
- func (e *EmailSource) SetAttachmentOptions(options EmailAttachmentOptions)
- func (e *EmailSource) SetIgnore(patterns []string)
- func (e *EmailSource) SetMaskSensitivePreview(enabled bool)
- type FileInfo
- type HTMLSource
- type MarkdownSource
- type MultiDocumentSource
- type OrgSource
- func (o *OrgSource) IsDocumentInScope(file FileInfo, doc *storage.Document) bool
- func (o *OrgSource) MatchesPath(path string) bool
- func (o *OrgSource) Name() storage.Source
- func (o *OrgSource) Parse(ctx context.Context, file FileInfo) (*storage.Document, error)
- func (o *OrgSource) ParseDocuments(ctx context.Context, file FileInfo) ([]*storage.Document, error)
- func (o *OrgSource) ReconciliationScope(file FileInfo) string
- func (o *OrgSource) Scan(ctx context.Context) (<-chan FileInfo, <-chan error)
- type PDFOCROptions
- type PDFSource
- func (p *PDFSource) MatchesPath(path string) bool
- func (p *PDFSource) Name() storage.Source
- func (p *PDFSource) Parse(ctx context.Context, file FileInfo) (*storage.Document, error)
- func (p *PDFSource) Scan(ctx context.Context) (<-chan FileInfo, <-chan error)
- func (p *PDFSource) SetOCROptions(options PDFOCROptions)
- type ParsedMarkdown
- type ReaderPage
- type ReconciledMultiDocumentSource
- type ScanConfig
- type Scanner
- type Source
Constants ¶
const IngestionScopeMetadata = "mindcli_ingestion_scope"
IngestionScopeMetadata is attached to documents owned by a reconciled multi-document artifact. It lets the indexer remove records that disappear from a later parse without treating their virtual paths as local files.
Variables ¶
This section is empty.
Functions ¶
func NormalizeWebURL ¶
NormalizeWebURL returns the stable HTTP(S) identity shared by browser indexing and deliberate URL captures.
Types ¶
type BrowserOptions ¶
type BrowserOptions struct {
IncludeContent bool
AllowedDomains []string
DeniedDomains []string
MaxResponseBytes int64
RequestTimeout time.Duration
FetchConcurrency int
MaxPages int
RetentionDays int
}
BrowserOptions bounds browser history retention and optional reader-mode page fetching. IncludeContent is false by default.
func DefaultBrowserOptions ¶
func DefaultBrowserOptions() BrowserOptions
DefaultBrowserOptions returns privacy-preserving, bounded browser defaults.
type BrowserSource ¶
type BrowserSource struct {
// contains filtered or unexported fields
}
BrowserSource indexes browser history and bookmarks.
func NewBrowserSource ¶
func NewBrowserSource(browsers []string) *BrowserSource
NewBrowserSource creates a new browser history source.
func (*BrowserSource) IsDocumentInScope ¶
func (b *BrowserSource) IsDocumentInScope(file FileInfo, doc *storage.Document) bool
IsDocumentInScope reports whether doc belongs to the scanned browser profile. The fallback recognizes aggregate documents created by older MindCLI versions so the first new index pass removes them.
func (*BrowserSource) MatchesPath ¶
func (b *BrowserSource) MatchesPath(path string) bool
MatchesPath reports whether this source is configured to handle the path.
func (*BrowserSource) Name ¶
func (b *BrowserSource) Name() storage.Source
Name returns the source name.
func (*BrowserSource) Parse ¶
Parse reads browser history and returns a document with all entries. Deprecated: browser indexing uses ParseDocuments so each page is searchable independently. Parse remains as a compatibility shim for Source callers.
func (*BrowserSource) ParseDocuments ¶
func (b *BrowserSource) ParseDocuments(ctx context.Context, file FileInfo) ([]*storage.Document, error)
ParseDocuments returns one independently searchable document per normalized URL in the browser profile.
func (*BrowserSource) ReconciliationScope ¶
func (b *BrowserSource) ReconciliationScope(file FileInfo) string
ReconciliationScope identifies all virtual documents owned by one browser profile, regardless of whether History or Bookmarks was the scanned path.
func (*BrowserSource) Scan ¶
func (b *BrowserSource) Scan(ctx context.Context) (<-chan FileInfo, <-chan error)
Scan finds browser profile data and returns one artifact per browser profile. Chrome history and bookmarks are coalesced so a URL that appears in both is emitted as one document.
func (*BrowserSource) SetOptions ¶
func (b *BrowserSource) SetOptions(options BrowserOptions)
SetOptions configures retention and page fetching for a browser source.
type ClipboardSource ¶
type ClipboardSource struct {
// contains filtered or unexported fields
}
ClipboardSource indexes clipboard history. It polls the system clipboard and stores unique text entries.
func NewClipboardSource ¶
func NewClipboardSource(db *storage.DB, retentionDays int, skipPasswords bool) *ClipboardSource
NewClipboardSource creates a new clipboard source.
func (*ClipboardSource) MatchesPath ¶
func (c *ClipboardSource) MatchesPath(path string) bool
MatchesPath reports whether this source is configured to handle the path.
func (*ClipboardSource) Name ¶
func (c *ClipboardSource) Name() storage.Source
Name returns the source name.
type CodeSource ¶
type CodeSource struct {
// contains filtered or unexported fields
}
CodeSource indexes bounded, recognized UTF-8 source files from configured repository roots without following symbolic links.
func NewCodeSource ¶
func NewCodeSource(paths, ignore []string, maxFileBytes int64, maxFiles int) *CodeSource
func (*CodeSource) MatchesPath ¶
func (c *CodeSource) MatchesPath(path string) bool
func (*CodeSource) Name ¶
func (c *CodeSource) Name() storage.Source
type DOCXSource ¶
type DOCXSource struct {
// contains filtered or unexported fields
}
DOCXSource indexes bounded Office Open XML word-processing documents.
func NewDOCXSource ¶
func NewDOCXSource(paths, ignore []string, maxFileBytes, maxDecompressedBytes int64) *DOCXSource
func (*DOCXSource) MatchesPath ¶
func (d *DOCXSource) MatchesPath(path string) bool
func (*DOCXSource) Name ¶
func (d *DOCXSource) Name() storage.Source
type EPUBSource ¶
type EPUBSource struct {
// contains filtered or unexported fields
}
EPUBSource indexes each spine item in an EPUB as an independent document.
func NewEPUBSource ¶
func NewEPUBSource(paths, ignore []string, maxFileBytes, maxDecompressedBytes int64) *EPUBSource
func (*EPUBSource) IsDocumentInScope ¶
func (e *EPUBSource) IsDocumentInScope(file FileInfo, doc *storage.Document) bool
func (*EPUBSource) MatchesPath ¶
func (e *EPUBSource) MatchesPath(filePath string) bool
func (*EPUBSource) Name ¶
func (e *EPUBSource) Name() storage.Source
func (*EPUBSource) ParseDocuments ¶
func (*EPUBSource) ReconciliationScope ¶
func (e *EPUBSource) ReconciliationScope(file FileInfo) string
type EmailAttachmentOptions ¶
type EmailAttachmentOptions struct {
Enabled bool
MaxAttachmentBytes int64
MaxDecompressedBytes int64
MaxArchiveDepth int
}
EmailAttachmentOptions bounds the optional local extraction of textual attachments. ArchiveDepth 1 permits one DOCX/EPUB container; zero disables archive-backed attachment formats.
func DefaultEmailAttachmentOptions ¶
func DefaultEmailAttachmentOptions() EmailAttachmentOptions
type EmailSource ¶
type EmailSource struct {
// contains filtered or unexported fields
}
EmailSource indexes email archives (mbox, maildir, emlx).
func NewEmailSource ¶
func NewEmailSource(paths, formats []string) *EmailSource
NewEmailSource creates a new email source.
func (*EmailSource) IsDocumentInScope ¶
func (e *EmailSource) IsDocumentInScope(file FileInfo, doc *storage.Document) bool
func (*EmailSource) MatchesPath ¶
func (e *EmailSource) MatchesPath(path string) bool
MatchesPath reports whether this source is configured to handle the path.
func (*EmailSource) Name ¶
func (e *EmailSource) Name() storage.Source
Name returns the source name.
func (*EmailSource) Parse ¶
Parse reads an email file and returns the parsed document. For mbox files, the first message is used as the document.
func (*EmailSource) ParseDocuments ¶
func (e *EmailSource) ParseDocuments(ctx context.Context, file FileInfo) ([]*storage.Document, error)
ParseDocuments returns the email body plus independently searchable textual attachments when extraction is explicitly enabled.
func (*EmailSource) ReconciliationScope ¶
func (e *EmailSource) ReconciliationScope(file FileInfo) string
func (*EmailSource) Scan ¶
func (e *EmailSource) Scan(ctx context.Context) (<-chan FileInfo, <-chan error)
Scan walks configured paths and returns email files to index.
func (*EmailSource) SetAttachmentOptions ¶
func (e *EmailSource) SetAttachmentOptions(options EmailAttachmentOptions)
SetAttachmentOptions enables and bounds attachment extraction.
func (*EmailSource) SetIgnore ¶
func (e *EmailSource) SetIgnore(patterns []string)
SetIgnore configures path exclusion patterns.
func (*EmailSource) SetMaskSensitivePreview ¶
func (e *EmailSource) SetMaskSensitivePreview(enabled bool)
SetMaskSensitivePreview controls redaction in preview/metadata fields.
type HTMLSource ¶
type HTMLSource struct {
// contains filtered or unexported fields
}
HTMLSource indexes HTML pages, MIME web archives, and Safari webarchives.
func NewHTMLSource ¶
func NewHTMLSource(paths, ignore []string, maxFileBytes, maxDecompressedBytes int64) *HTMLSource
NewHTMLSource creates a bounded local HTML source.
func (*HTMLSource) MatchesPath ¶
func (h *HTMLSource) MatchesPath(path string) bool
func (*HTMLSource) Name ¶
func (h *HTMLSource) Name() storage.Source
type MarkdownSource ¶
type MarkdownSource struct {
// contains filtered or unexported fields
}
MarkdownSource indexes markdown files.
func NewMarkdownSource ¶
func NewMarkdownSource(paths, extensions, ignore []string) *MarkdownSource
NewMarkdownSource creates a new markdown source.
func (*MarkdownSource) MatchesPath ¶
func (m *MarkdownSource) MatchesPath(path string) bool
MatchesPath reports whether this source is configured to handle the path.
func (*MarkdownSource) Name ¶
func (m *MarkdownSource) Name() storage.Source
Name returns the source name.
type MultiDocumentSource ¶
type MultiDocumentSource interface {
Source
// ParseDocuments reads a scanned artifact and returns its documents. Every
// document must have a stable ID so it can be updated independently.
ParseDocuments(ctx context.Context, file FileInfo) ([]*storage.Document, error)
}
MultiDocumentSource is implemented by sources where one scanned artifact can contain multiple independently searchable documents. Parse remains part of Source so ordinary file-backed sources keep their simple one-file/one-document contract; the indexer prefers ParseDocuments when this interface is present.
type OrgSource ¶
type OrgSource struct {
// contains filtered or unexported fields
}
OrgSource indexes top-level Org-mode sections independently.
func NewOrgSource ¶
func (*OrgSource) IsDocumentInScope ¶
func (*OrgSource) MatchesPath ¶
func (*OrgSource) ParseDocuments ¶
func (*OrgSource) ReconciliationScope ¶
type PDFOCROptions ¶
type PDFOCROptions struct {
Enabled bool
Command string
Renderer string
Languages []string
MaxPages int
Timeout time.Duration
MinTextChars int
RenderDPI int
MaxRenderedMB int64
}
PDFOCROptions configures the optional local OCR fallback. OCR is only used when ordinary PDF extraction yields fewer than MinTextChars visible chars.
func DefaultPDFOCROptions ¶
func DefaultPDFOCROptions() PDFOCROptions
type PDFSource ¶
type PDFSource struct {
// contains filtered or unexported fields
}
PDFSource indexes PDF files.
func NewPDFSource ¶
NewPDFSource creates a new PDF source.
func (*PDFSource) MatchesPath ¶
MatchesPath reports whether this source is configured to handle the path.
func (*PDFSource) SetOCROptions ¶
func (p *PDFSource) SetOCROptions(options PDFOCROptions)
SetOCROptions enables or tunes the local OCR fallback.
type ParsedMarkdown ¶
type ParsedMarkdown struct {
Title string
Body string
Frontmatter map[string]string
Headings []string
Tags []string
Links []string
}
ParsedMarkdown contains parsed markdown content.
type ReaderPage ¶
ReaderPage is bounded textual content extracted from one public web URL.
func FetchReaderPage ¶
func FetchReaderPage(ctx context.Context, rawURL string, options BrowserOptions) (ReaderPage, error)
FetchReaderPage reuses the browser source's cookie-free HTTP client, domain policy, redirect checks, content-type restrictions, and response bounds for deliberate URL capture.
type ReconciledMultiDocumentSource ¶
type ReconciledMultiDocumentSource interface {
MultiDocumentSource
ReconciliationScope(file FileInfo) string
IsDocumentInScope(file FileInfo, doc *storage.Document) bool
}
ReconciledMultiDocumentSource describes a multi-document source whose returned set is authoritative for a scope. The indexer removes documents in that scope when their stable IDs are absent from the latest successful parse.
type ScanConfig ¶
ScanConfig configures the file scanner.
type Scanner ¶
type Scanner struct {
// contains filtered or unexported fields
}
Scanner walks directories and returns matching files.
func NewScanner ¶
func NewScanner(config ScanConfig) *Scanner
NewScanner creates a new file scanner.
func (*Scanner) MatchesPath ¶
MatchesPath reports whether a path is included by this scanner's config.
type Source ¶
type Source interface {
// Name returns the source name (e.g., "markdown", "pdf").
Name() storage.Source
// Scan walks the configured paths and returns files to index.
Scan(ctx context.Context) (<-chan FileInfo, <-chan error)
// MatchesPath reports whether this source is configured to handle the given path.
MatchesPath(path string) bool
// Parse reads a file and returns the parsed document.
Parse(ctx context.Context, file FileInfo) (*storage.Document, error)
}
Source represents a document source that can be indexed.