feat(database): add file size metadata and range parameters
- Add byte_size and line_count columns to files table - Increment SchemaVersion to 2 (requires re-indexing) - Add DeclarationWithMetadata, FileRange, FileResult types - Add GetDeclarationsWithMetadata method for file metadata lookup - Add GetFileWithRange method for paginated file retrieval - Implement countLines and applyLineRange helpers Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -44,6 +44,30 @@ type File struct {
|
||||
FilePath string
|
||||
Extension string
|
||||
Content string
|
||||
ByteSize int
|
||||
LineCount int
|
||||
}
|
||||
|
||||
// DeclarationWithMetadata includes declaration info plus file metadata.
|
||||
type DeclarationWithMetadata struct {
|
||||
Declaration
|
||||
ByteSize int // File size in bytes, 0 if file not indexed
|
||||
LineCount int // Number of lines, 0 if file not indexed
|
||||
HasFile bool // True if file is indexed
|
||||
}
|
||||
|
||||
// FileRange specifies a range of lines to return from a file.
|
||||
type FileRange struct {
|
||||
Offset int // Line offset (0-based)
|
||||
Limit int // Maximum lines to return (0 = default 250)
|
||||
}
|
||||
|
||||
// FileResult contains a file with range metadata.
|
||||
type FileResult struct {
|
||||
*File
|
||||
TotalLines int // Total lines in the file
|
||||
StartLine int // First line returned (1-based)
|
||||
EndLine int // Last line returned (1-based)
|
||||
}
|
||||
|
||||
// SearchFilters contains optional filters for option search.
|
||||
@@ -80,9 +104,11 @@ type Store interface {
|
||||
CreateDeclaration(ctx context.Context, decl *Declaration) error
|
||||
CreateDeclarationsBatch(ctx context.Context, decls []*Declaration) error
|
||||
GetDeclarations(ctx context.Context, optionID int64) ([]*Declaration, error)
|
||||
GetDeclarationsWithMetadata(ctx context.Context, revisionID, optionID int64) ([]*DeclarationWithMetadata, error)
|
||||
|
||||
// File operations
|
||||
CreateFile(ctx context.Context, file *File) error
|
||||
CreateFilesBatch(ctx context.Context, files []*File) error
|
||||
GetFile(ctx context.Context, revisionID int64, path string) (*File, error)
|
||||
GetFileWithRange(ctx context.Context, revisionID int64, path string, r FileRange) (*FileResult, error)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user