Docs›Reference›Code graph

Code graph

A local graph of the functions, classes and constants in your repo. It maps identifiers on your machine and does not rename them.

Why a graph

Scanning a file tells you what is in that file. The graph is what Pretense knows about the repository: which functions, classes and constants exist, and where. init builds it once so the later commands work from a picture of the whole tree.

It is a record of your names, not a rename of them. The rename happens in the proxy, on fenced code in each request: names in your code are swapped before the provider sees them and restored in the response. See How it works.

Building it

pretense init walks the repository, records every function, class and constant it finds, and writes them to .pretense/fingerprint.json.

bash
pretense init
terminal
✓ Scanned 214 files
✓ Indexed 863 functions
✓ Indexed 114 classes
✓ Indexed 0 constants
✓ Created pretense.yaml
✓ Wrote .pretense/fingerprint.json
✓ Added .pretense/ to .gitignore

The last line matters: the graph is added to your .gitignore, so it is not committed alongside the code it describes. Run pretense init again after a refactor that renames a lot of things.

pretense status reports what the graph currently holds, next to your configuration and the state of the proxy.

terminal
✓ Fingerprint: 214 files, 977 identifiers
  Last scanned: 0 minutes ago

Languages

Identifiers are extracted from TypeScript, JavaScript, Python, Go, Java, Kotlin, Ruby and Rust.

A file in any other language is still scanned for secrets. It just contributes no identifiers to the graph. The file types scan skips are listed in the CLI reference.

Next steps

  • How it worksWhat the proxy swaps on the way out, and what it restores on the way back
  • CLI referenceWhat init and status accept, and what they return
  • ConfigurationThe pretense.yaml that init writes beside the graph