Documentation
¶
Index ¶
- Constants
- func DetectProjectRoot(cwd string) (string, error)
- func FormatResults(results []SearchResult) string
- func IndexPath(projectRoot, overridePath string) (string, error)
- func PruneIndexes() ([]string, error)
- type FileRow
- type IndexInfo
- type IndexResult
- type QueryType
- type SearchResult
- type StatusInfo
- type Store
- func (s *Store) AllFilePaths() (map[string]int64, error)
- func (s *Store) Begin() (*sql.Tx, error)
- func (s *Store) Close() error
- func (s *Store) DB() *sql.DB
- func (s *Store) DeleteFTS(tx *sql.Tx, id int64) error
- func (s *Store) DeleteFile(tx *sql.Tx, id int64) error
- func (s *Store) FileCount() (int, error)
- func (s *Store) ForceRebuild() error
- func (s *Store) GetFile(path string) (*FileRow, error)
- func (s *Store) InsertFTS(tx *sql.Tx, id int64, path, content string) error
- func (s *Store) Meta(key string) (string, error)
- func (s *Store) Optimize() error
- func (s *Store) ProjectRoot() string
- func (s *Store) UpdateMtime(tx *sql.Tx, id, mtime int64) error
- func (s *Store) UpsertFile(tx *sql.Tx, path, hash string, mtime int64) (int64, error)
Constants ¶
const SchemaVersion = "1"
Variables ¶
This section is empty.
Functions ¶
func DetectProjectRoot ¶
DetectProjectRoot walks upward from cwd looking for a .draft/ directory or a CLAUDE.md file. Returns the first directory containing either marker, or cwd itself if no marker is found.
func FormatResults ¶
func FormatResults(results []SearchResult) string
FormatResults formats search results as markdown with fenced code blocks.
func IndexPath ¶
IndexPath returns the path to the SQLite database for the given project root. If overridePath is non-empty, it is returned directly (supports --db flag).
func PruneIndexes ¶
PruneIndexes scans the cache directory and deletes indexes whose project_root no longer exists on disk.
Types ¶
type IndexInfo ¶
type IndexInfo struct {
ProjectRoot string
FileCount int
SizeBytes int64
LastIndexed string
DBPath string
}
IndexInfo holds summary info about one index database.
func ListIndexes ¶
ListIndexes returns info about all index databases in the cache directory.
type IndexResult ¶
IndexResult reports what happened during an index run.
type QueryType ¶
type QueryType int
QueryType classifies a search query.
func ClassifyQuery ¶
ClassifyQuery determines how to route a query.
type SearchResult ¶
SearchResult represents a single search hit.
type StatusInfo ¶
type StatusInfo struct {
DBPath string
ProjectRoot string
FileCount int
LastIndexed string
SizeBytes int64
}
StatusInfo holds information for the --status flag.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store wraps a SQLite database with dual FTS5 indexes.
func OpenStore ¶
OpenStore opens (or creates) the search index database at dbPath. projectRoot is recorded in index_meta for diagnostics and prune.
func (*Store) AllFilePaths ¶
AllFilePaths returns all indexed file paths.
func (*Store) DeleteFTS ¶
DeleteFTS removes FTS entries for the given file ID from both tables. Reads original content from fts to supply to contentless fts_trigram delete.
func (*Store) DeleteFile ¶
DeleteFile removes a file and its FTS entries. For contentless fts_trigram, we must supply the original content for deletion.
func (*Store) ForceRebuild ¶
ForceRebuild drops all tables and recreates the schema.
func (*Store) ProjectRoot ¶
ProjectRoot returns the project root stored in this store.
func (*Store) UpdateMtime ¶
UpdateMtime updates only the mtime for a file (content unchanged).