Read a source file at an exact commit or package version
code_readReads one file of a public GitHub repository or npm package straight from the origin, at an exact identity: a branch or tag is resolved to its commit sha first, and an npm tarball must match the registry's sha512. Returns the requested lines with the commit (or version and integrity), the path, the git blob id of the whole file and a source URL, so the lines can be re-read and checked. Pages by line: give start_line/end_line; next_start_line names the next page. A file that is not UTF-8 text (a NUL byte in its first 8000 bytes, or invalid UTF-8) is never shown as text: the answer is binary:true with its reason, size and blob id. Read-only; nothing is indexed or stored. Every answer, an error included, carries a pauhu-library-receipt/2 in structuredContent.receipt and as a trailing "receipt: {...}" text line; library_verify checks a receipt.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ref | No | Branch, tag or 40-hex commit sha (default HEAD). It is resolved to a commit sha first; the read is at that sha. | |
| path | Yes | File path inside the repository or package, e.g. lib/index.js | |
| repo | No | GitHub repository as owner/name, e.g. nodejs/node. Give this or package. | |
| package | No | npm package name, e.g. source-map-js or @scope/name. Give this or repo. | |
| version | No | npm version or dist-tag (default latest); the tarball is checked against the registry's sha512 integrity. | |
| end_line | No | Last line, inclusive (default start_line + 1999) | |
| start_line | No | First line, 1-based (default 1) |