Repository navigation
feat: read up to 2000 lines per call, exact continuation calls, CLI read --all - #30
Merged
Merged
Conversation
…ead --all - read: an omitted end line still reads 500 lines; an explicit range returns up to 2000 lines and 256 KiB, whichever comes first, then continues at NextStartLine. read_many keeps 500 lines per item and 1000 per batch. - MCP: when more of the requested range remains, the text gives the exact next read call (repo, full commit, canonical path, start_line, end_line within the requested end, explicit plugins); a complete range that ends before the file only says where the file continues. Unread read_many items with a valid range get a retry call. - CLI 0.7.0: `sourcegraph read --all` reads a whole file page by page at one commit with continuous line numbers, checks every page, and stops after 20000 lines (exit 0) with a shell-safe continue command; `--start N` alone reads N..N+199. - Docs, skill and CLI README describe the limits and hints. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
A single read returned at most 500 lines, so reading a whole file meant many calls, and agents had to work out the next call from
NextStartLinethemselves. The command line read 200 lines at a time with no way to read a whole file.Changes
read(MCP andPOST /v1/repo/read) returns up to 2000 lines per call; the 256 KiB byte limit is unchanged and whichever comes first stops the read. An MCPreadwithoutend_linestill reads 500 lines. A larger range is not an error: the first 2000 lines come back withTruncated,HasMoreandNextStartLine.read_manyunchanged: 500 lines per item (now enforced inside the batch reader, independent of the single-read limit) and 1000 lines / 256 KiB / 30 seconds per batch.Next call: read {"repo":"…","revision":"<full SHA>","path":"<canonical path>","start_line":N,"end_line":min(requested end, N+1999)}, including an explicitly passedpluginsvalue. A complete range that ends before the file only says from which line the file continues. Unreadread_manyitems (READ_BUDGET_EXCEEDED,READ_TIMEOUT) with a valid range get aRetry callwith their original range. Tool descriptions and schemas updated.sourcegraph read <repo> <path> --all [--rev] [--start]reads a whole file page by page (2000 lines per request; older servers answer 500) pinned to the first page's commit, with continuous line numbers. It checks every page (start line, advancing, contiguousNextStartLine) and stops after 20000 lines with exit code 0, a shell-safe continue command on stderr (--before repo and path) andHasMore/NextStartLinein--jsonoutput.--start Nwithout--endnow reads lines N..N+199 instead of an invalid N..200 range. Plugin version 0.7.0.docs/interfaces.md, skill, CLI README andweb/plugins/llms.txt.Risks
read_manyare unchanged, so default context use does not grow.Compatibility
No new fields and no breaking change. Older clients keep paging; each page can be longer. The new CLI works against older servers (500-line pages).
Testing
go testforinternal/gitstore,internal/service,internal/mcpserver,internal/httpserver, plus the external plugin tests with a builtcontext-evidenceartifact;bun run check;scripts/audit-public.py;cd cli && bun test(10 tests against a fake server: 500- and 2000-line pages, 20000-line stop, quoting, misbehaving servers,--json).read_manyitem 500 whilereadreturns 2000; hint contents (requested-end clipping, served commit, unusual paths, plugins) and a round trip that feeds the hint back through the MCP handler (symlink alias, quoted and Unicode paths).🤖 Generated with Claude Code