sources

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2026 License: Apache-2.0 Imports: 23 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package sources provides content acquisition from local files, git repositories, and web pages. Each source type returns []RawDoc; chunking and indexing are applied by the sources orchestrator.

Index

Constants

This section is empty.

Variables

View Source
var DefaultRegistry = &Registry{}

DefaultRegistry is the package-level registry populated by init() functions in each source file (local.go, git.go, etc.).

Functions

This section is empty.

Types

type CredentialConsumer added in v0.2.0

type CredentialConsumer interface {
	SetCredentials(*auth.Store)
}

CredentialConsumer is implemented by sources that authenticate outbound requests. The orchestrator calls SetCredentials after construction when a source implements it, which keeps Factory free of a parameter that only network-backed source kinds need.

type Factory

type Factory func(name string, raw any, projectRoot, baseDir string, global config.PullPolicy) (Source, SourceMeta, error)

Factory creates a Source and its metadata from kind-specific configuration. name is the user-chosen label for the source entry. raw is the kind-specific config struct (e.g. config.LocalSource for "local"). projectRoot is the workspace root; baseDir is the cache directory for fetched remote sources. global is the project-wide PullPolicy fallback.

type GitSource

type GitSource struct {
	// contains filtered or unexported fields
}

GitSource clones a remote git repository to disk.

func (*GitSource) Fetch

func (s *GitSource) Fetch(ctx context.Context) error

Fetch clones the git repository to disk. Credentials come from the environment (SSH keys, git credential helpers, .netrc). If destDir already exists it is removed first to ensure a clean clone.

func (*GitSource) Read

func (s *GitSource) Read(globs []string, prefix string) ([]RawDoc, error)

type HTTPSource

type HTTPSource struct {
	// contains filtered or unexported fields
}

HTTPSource downloads a URL archive (or single file) to disk.

func (*HTTPSource) Fetch

func (s *HTTPSource) Fetch(ctx context.Context) error

Fetch downloads the URL to disk. When extract is nil, archive detection is automatic (Content-Type or .tar.gz/.tgz URL suffix). When extract is non-nil its value is used directly. Optional headers are added to the request alongside .netrc credentials.

func (*HTTPSource) Read

func (s *HTTPSource) Read(globs []string, prefix string) ([]RawDoc, error)

func (*HTTPSource) SetCredentials added in v0.2.0

func (s *HTTPSource) SetCredentials(store *auth.Store)

SetCredentials implements CredentialConsumer.

type LocalSource

type LocalSource struct {
	// contains filtered or unexported fields
}

LocalSource serves files directly from an existing filesystem; Fetch is a no-op.

func (*LocalSource) Fetch

func (s *LocalSource) Fetch(_ context.Context) error

func (*LocalSource) Read

func (s *LocalSource) Read(globs []string, prefix string) ([]RawDoc, error)

type RawDoc

type RawDoc struct {
	// Source identifies the origin (relative path, URL, or repo:path).
	Source string
	// Content is the raw content of the document.
	Content string
}

RawDoc is a fetched document before chunking/indexing. Sources return RawDocs; the orchestrator applies chunking later.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry holds source factories keyed by kind (e.g. "local", "git").

func (*Registry) Lookup

func (r *Registry) Lookup(kind string) (Factory, bool)

Lookup returns the factory registered for kind.

func (*Registry) Register

func (r *Registry) Register(kind string, f Factory)

Register adds (or replaces) the source factory for kind.

type ScrapeOptions

type ScrapeOptions struct {
	MaxPageSize int64 // max bytes per page
	MaxPages    int   // max URLs to fetch (seeds + discovered)
	MaxDepth    int   // max link-following depth; 0 = seed URLs only
}

ScrapeOptions configures limits for URL scraping.

type ScrapeSource

type ScrapeSource struct {
	// contains filtered or unexported fields
}

ScrapeSource crawls web pages and saves them as markdown to disk.

func (*ScrapeSource) Fetch

func (s *ScrapeSource) Fetch(ctx context.Context) error

Fetch scrapes the configured URLs, converts HTML to text, and saves each page as a .md file under destDir. When opts.MaxDepth > 0, discovered links that share the same origin and path prefix as their seed URL are followed. Existing destDir content is cleared first for a clean fetch.

func (*ScrapeSource) Read

func (s *ScrapeSource) Read(globs []string, prefix string) ([]RawDoc, error)

type Source

type Source interface {
	Fetch(ctx context.Context) error
	Read(globs []string, prefix string) ([]RawDoc, error)
}

Source is the interface satisfied by every content source. Fetch acquires remote content to disk (no-op for local sources); Read returns matched documents from the source content.

type SourceMeta

type SourceMeta struct {
	NoIndex    bool     // when true, skip indexing for this source
	ReadGlobs  []string // glob patterns for content files within the source FS
	ReadPrefix string   // prefix prepended to file paths for attribution
}

SourceMeta carries per-source metadata used by the orchestrator to read and index content after Fetch.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL