Skip to main content
CLI Reference

travsr graph

Print a text representation of the graph around a file or symbol.

Synopsis

travsr graph <file-or-symbol> [flags]

Flags

FlagDefaultDescription
--depth <n>, -d3Maximum traversal depth from the seed node (ignored with --all)
--direction <dir>, -Ddepsdeps (what this imports or defines) | callers (who depends on it) | both
--format <fmt>, -ftreetree (ASCII) | dot (Graphviz, pipe to dot -Tsvg) | json
--path <hint>(none)Path hint to resolve an ambiguous symbol: a filename, relative path, directory, or fragment (e.g. ppr.rs, crates/travsr-retrieval)
--edges <mode>semanticsemantic prefers call and override edges, falling back to structural when there are none. all follows every edge kind (ignored with --all)
--include-noise(none)Include third-party and anonymous-local nodes in the output, which are filtered out by default
--budget <n>4096Cap output at roughly this many tokens, 0 for unlimited. Truncation keeps the closest nodes and reports how many were cut
--all(none)Dump the entire indexed graph (ignores --depth, --direction, and --edges)

Examples

# Tree view of a file's neighbourhood
$ travsr graph src/auth/jwt.ts

src/auth/jwt.ts
├─ imports
│ ├─ src/config/env.ts
│ └─ node_modules/jsonwebtoken
├─ callers
│ ├─ src/middleware/auth.ts → verify()
│ ├─ src/routes/login.ts → sign()
│ └─ src/services/SessionService.ts → refresh()
└─ callees
├─ jsonwebtoken.sign()
└─ jsonwebtoken.verify()

# DOT format for Graphviz
$ travsr graph src/auth/jwt.ts --format dot | dot -Tsvg > jwt-graph.svg

# Callers only, depth 3
$ travsr graph UserService.find --direction callers --depth 3

# Full graph as JSON
$ travsr graph --all --format json > graph.json

DOT output example

digraph {
"src/auth/jwt.ts" -> "src/config/env.ts" [label="imports"]
"src/middleware/auth.ts" -> "src/auth/jwt.ts" [label="calls:verify"]
"src/routes/login.ts" -> "src/auth/jwt.ts" [label="calls:sign"]
}

Feed DOT output to Graphviz (dot, neato, fdp) for visual graph exploration.