TokenCap scans all JS/TS source files and maps how they connect to each other.
bash
tokencap graphThis generates TOKENCAP_GRAPH.md containing:
- Changed Files — files with unstaged/staged Git changes
- File Relationships —
source → dependencyimport edges - Important Nodes — files classified by type
- All Scanned Files — grouped by classification
Supported file extensions: .ts, .tsx, .js, .jsx, .mjs, .cjs
Import patterns parsed:
import x from "./file"import { x } from "../file"export { x } from "./file"const x = require("./file")
Node classification:
| Pattern | Type |
|---|---|
/app/, /pages/, page.*, route.*, layout.* | route |
/api/ + route.* | api |
Uppercase name, /components/, /ui/, .tsx | component |
/lib/, /services/, /utils/, /hooks/ | service |
schema.prisma, /models/, /db/, /database/ | database |
next.config.*, vite.config.*, tsconfig.*, package.json | config |
Note: Only local relative imports are followed. External packages (react, lodash, etc.) are ignored.