feature/file-metadata-and-range #3

Merged
torjus merged 4 commits from feature/file-metadata-and-range into master 2026-02-04 00:37:06 +00:00
Owner

Summary

Add file size metadata and range parameters for better handling of large files.

Changes

File Metadata in Declarations

  • get_option now shows file size info: nginx/default.nix:123 (4521 bytes, 156 lines)
  • Helps clients assess file size before fetching

Range Parameters for get_file

  • New offset (0-based line) and limit (default: 250) parameters
  • Shows header when truncated: Showing lines 1-250 of 1523 total
  • Prevents dumping massive files in full

Database

  • Schema version bumped to 2 (requires re-indexing)
  • New columns: byte_size, line_count in files table

Notes

  • Security reviewed: no new attack vectors
  • All parameters validated and bounded
  • Backwards compatible (new params are optional)
## Summary Add file size metadata and range parameters for better handling of large files. ### Changes **File Metadata in Declarations** - `get_option` now shows file size info: `nginx/default.nix:123 (4521 bytes, 156 lines)` - Helps clients assess file size before fetching **Range Parameters for `get_file`** - New `offset` (0-based line) and `limit` (default: 250) parameters - Shows header when truncated: `Showing lines 1-250 of 1523 total` - Prevents dumping massive files in full ### Database - Schema version bumped to 2 (requires re-indexing) - New columns: `byte_size`, `line_count` in files table ### Notes - Security reviewed: no new attack vectors - All parameters validated and bounded - Backwards compatible (new params are optional)
torjus added 4 commits 2026-02-04 00:35:07 +00:00
- 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>
- Add offset and limit parameters to get_file tool schema
- Default limit is 250 lines, offset is 0
- Show "Showing lines X-Y of Z total" header when range is applied
- Update handleGetOption to use GetDeclarationsWithMetadata
- Display file size metadata (bytes, lines) in declarations output

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- testFileRange: test GetFileWithRange with various offset/limit values
- testDeclarationsWithMetadata: test file metadata in declarations
- Verify byte_size and line_count are computed correctly
- Test edge cases: offset beyond EOF, non-indexed files

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
torjus merged commit df9a2f30a9 into master 2026-02-04 00:37:06 +00:00
torjus deleted branch feature/file-metadata-and-range 2026-02-04 00:37:06 +00:00
This repo is archived. You cannot comment on pull requests.
No Reviewers
No Label
1 Participants
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: torjus/labmcp#3