
Product
Introducing Repository Access Permissions and Custom Roles
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.
pi-read-map
Advanced tools

This pi extension augments the built-in read tool with structural file maps. When you open a file larger than 2,000 lines or 50 KB, the extension generates a map of every symbol and its line range. You navigate large codebases precisely instead of scanning sequentially.
The problem: pi sees only the first 2,000 lines of a 50,000-line source file. Ask "how does the type checker handle unions?" and the model either hallucinates or burns tokens re-reading until it finds the answer.
The trade-off: pi-read-map spends ~2,000–10,000 tokens upfront to generate a map of the entire file. The extension triggers only for files exceeding the truncation limit (>2,000 lines and >50 KB); smaller files pass through unchanged.
The payoff: The map stays in context. Ask "show me the merge implementation," "compare error handling in these three functions," or "what symbols exist after line 40,000?" without re-reading. The investment pays for itself when you analyze a large file beyond a single summary.
See pi-read-map in action analyzing the TypeScript compiler's 54,000-line type checker:
https://github.com/user-attachments/assets/4408f37b-b669-453f-a588-336a5332ae90
# Global install
pi install https://github.com/Whamp/pi-read-map
# Global install
pi install npm:pi-read-map
# Project-local install
pi install npm:pi-read-map -l
# Clone and install globally
pi install ./path/to/pi-read-map
# Or project-local
pi install ./path/to/pi-read-map -l
Try the extension without installing:
pi -e https://github.com/Whamp/pi-read-map
pi -e npm:pi-read-map
pi -e ./path/to/pi-read-map
Start pi or run /reload. Then read a large file:
read path/to/large-file.ts
Output includes the truncated content followed by:
[Truncated: showing first 2000 lines of 10,247 (50 KB of 412 KB)]
───────────────────────────────────────
File Map: path/to/large-file.ts
10,247 lines │ 412 KB │ TypeScript
───────────────────────────────────────
class ProcessorConfig: [18-32]
class BatchProcessor: [34-890]
constructor(config: ProcessorConfig): [40-65]
async run(items: List<Item>): [67-180]
...
───────────────────────────────────────
Use read(path, offset=LINE, limit=N) for targeted reads.
───────────────────────────────────────
npm run typecheck # Type checking
npm run lint # Linting with oxlint
npm run lint:fix # Auto-fix lint issues
npm run format # Format with oxfmt
npm run format:check # Check formatting
npm run validate # Run all checks
npm run test # Unit tests
npm run test:watch # Watch mode
npm run test:integration # Integration tests
npm run test:e2e # End-to-end tests
npm run bench # Benchmarks
src/
├── index.ts # Extension entry: tool registration, caching, messages
├── mapper.ts # Dispatcher: routes files to language mappers
├── formatter.ts # Budget-aware formatting with detail reduction
├── language-detect.ts # Maps file extensions to languages
├── types.ts # Shared interfaces (FileMap, FileSymbol)
├── enums.ts # SymbolKind, DetailLevel
├── constants.ts # Thresholds (2,000 lines, 50 KB, 20 KB budget)
└── mappers/ # Language-specific parsers
├── typescript.ts # ts-morph for TS/JS
├── python.ts # Python AST via subprocess
├── go.ts # Go AST via subprocess
├── rust.ts # tree-sitter
├── cpp.ts # tree-sitter for C/C++
├── clojure.ts # tree-sitter for Clojure/ClojureScript/EDN
├── c.ts # Regex patterns
├── sql.ts # Regex
├── json.ts # jq subprocess
├── jsonl.ts # Streaming parser
├── yaml.ts # Regex
├── toml.ts # Regex
├── csv.ts # In-process parser
├── markdown.ts # Regex
├── ctags.ts # universal-ctags fallback
└── fallback.ts # Grep-based final fallback
scripts/
├── python_outline.py # Python AST extraction
└── go_outline.go # Go AST extraction (compiles on first use)
tests/
├── unit/ # Mapper and utility tests
├── integration/ # Dispatcher, caching, budget enforcement
├── e2e/ # Real pi sessions via tmux
└── fixtures/ # Sample files per language
The extension intercepts read calls and decides:
ls and throw an EISDIR error that includes inline fallback directory output.Note on design: Maps are inlined as raw text rather than sent as separate custom UI messages. While this sacrifices a dedicated TUI widget, it ensures true parallel tool execution. Custom messages interrupt parallel tool batches, causing skipped reads and forcing slow recovery loops. Inlining guarantees the LLM receives the map immediately in the same turn without breaking concurrency.
npm packages:
ts-morph - TypeScript AST analysistree-sitter - Parser frameworktree-sitter-cpp - C/C++ parsingtree-sitter-rust - Rust parsingtree-sitter-clojure - Clojure parsingSystem tools (optional):
python3 - Python mappergo - Go mapperjq - JSON mapperuniversal-ctags - Language fallbackPeer dependency warnings during install. You may see npm warn ERESOLVE overriding peer dependency messages about tree-sitter-cpp. This is cosmetic — the extension installs and works correctly. The warning occurs because tree-sitter-cpp@0.23.4 on npm declares peerDependencies: { "tree-sitter": "^0.21.1" } while we use tree-sitter@0.22.4 (required by tree-sitter-rust). The fix exists on the tree-sitter-cpp master branch but hasn't been published to npm yet. See tree-sitter/tree-sitter-cpp#349 for tracking.
This project was inspired by and built upon the foundation of codemap by kcosr. Check out the original project for the ideas that made this possible.
MIT
FAQs
Pi extension that adds structural file maps for large files
The npm package pi-read-map receives a total of 275 weekly downloads. As such, pi-read-map popularity was classified as not popular.
We found that pi-read-map demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.

Product
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.

Product
Socket Firewall blocks malicious VS Code and Open VSX extensions before install, protecting developers from compromised editor marketplaces.