Complete read-parity file views#149
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a unified, transport-neutral “live file view” surface that reads current on-disk bytes with bounded line pagination, exact totalLines, continuation via page.nextOffset, and optional opt-in graph context and sensitive-content handling. It wires the same response contract through the agent library API, a new codegraph file CLI command, MCP get_file, and exact-path explore responses, with accompanying tests and documentation.
Changes:
- Added
src/agent/fileView.tsimplementing bounded line/byte paging, full-stream UTF-8/NUL validation, sensitive redaction/metadata summaries, and optional graph context. - Exposed the file-view contract via CLI (
codegraph file, plus explore flag pass-through), MCP schema/tooling, and public exports (src/index.ts,src/agent.ts). - Added extensive test coverage and updated canonical docs + bundled skill guidance for the new contract and safety model.
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/mcp-server.test.ts | Adds MCP get_file schema checks plus pagination, redaction, and graph-context behavior tests. |
| tests/file-view.test.ts | New end-to-end suite for file view paging, root confinement, binary/UTF-8 validation, redaction, and key-material handling. |
| tests/cli-command-modules.test.ts | Verifies codegraph file JSON/pretty output, bounds rejection, graph context, and sensitive handling via dispatcher. |
| tests/agent-explore.test.ts | Validates explore includes fileView for exact-path queries and updates follow-up command expectations. |
| src/util/confinedFile.ts | Introduces reusable realpath-based confinement helpers and nearest-existing-path resolution. |
| src/mcp/tools.ts | Aligns MCP get_file input schema to file-view constants and adds allowSensitive. |
| src/mcp/server.ts | Routes get_file to the shared agent file-view implementation; updates bounds and request schema. |
| src/mcp/security.ts | Removes duplicated confinement/read helpers and reuses findNearestExistingPath. |
| src/index.ts | Exports the new file-view API (functions, constants, and types) from the root package. |
| src/cli/options.ts | Registers file command schema and adds --offset / --max-bytes value options. |
| src/cli/help.ts | Adds file command help text and extends explore help to document new explicit flags. |
| src/cli/file.ts | Implements codegraph file command (JSON default, --pretty formatting, bounds checks). |
| src/cli/explore.ts | Passes --include-graph-context / --allow-sensitive through to agent explore. |
| src/cli.ts | Adds CLI routing for the new file command. |
| src/agent/fileView.ts | Core implementation: bounded paging, exact totalLines, sensitive redaction/metadata, optional graph context. |
| src/agent/explore.ts | Adds exact-path resolution to include fileView in explore responses and updates follow-ups/pretty output. |
| src/agent.ts | Re-exports file-view surface from the agent subpath facade. |
| docs/plans/2026-07-03-07-read-parity-file-view.md | Updates the plan to reflect the implemented multi-surface contract and safety rules. |
| docs/mcp.md | Documents MCP get_file contract, bounds/defaults, redaction behavior, and exact-path explore fileView. |
| docs/library-api.md | Documents the library file-view API, request/response fields, and explore fileView behavior. |
| docs/cli.md | Adds CLI reference and examples for codegraph file and file-view semantics. |
| docs/agent-workflows.md | Adds workflow guidance for live file reads vs packets and how to opt into graph context/sensitive reads. |
| codegraph-skill/codegraph/SKILL.md | Updates bundled skill guidance to include live file views and new safety/flag semantics. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Summary
totalLines, continuation offsets, and optional bounded graph contextcodegraph file, exact-pathexplore, and MCPget_file, with aligned JSON/pretty output, help, canonical docs, and bundled skill guidance--rootSafety and correctness
Verification
npm run checkreview-and-correctreview/fix verification through a final full review