codegraph-timeline is an MVP CLI that scans a Git repository across its first-parent commit history and writes simple import-graph metrics to JSON.
It currently uses regular expressions for TypeScript, JavaScript, and Python import statements. Tree-sitter, richer code graphs, Web UI, and animation are intentionally out of scope for this first version.
The Web UI lets you scrub through commit snapshots and inspect the dependency graph over time.
Video: docs/demo.mp4
npm install
npm run buildRun the built CLI directly from this repository:
node dist/src/cli.js scan <repoPath>On Windows PowerShell, for example:
node .\dist\src\cli.js scan C:\Repos\instruction-file-selectorIf you want to use codegraph-timeline as a command name, link the package first:
npm linkThen run:
codegraph-timeline scan <repoPath>During a scan, the CLI:
- Reads commits with
git rev-list --first-parent --reverse HEAD. - Adds each selected commit to a temporary Git worktree.
- Scans TypeScript, JavaScript, and Python files.
- Resolves local
importstatements intofile -> imported fileedges. - Writes timeline snapshots to
data/timeline.json. - Writes module graph snapshots to
data/snapshots/<commit>.json.
Example:
codegraph-timeline scan C:\path\to\repo --limit 10Options:
--limit <count> Limit scanned commits, starting from the oldest first-parent commit.
--target-dir <dir> Analyze a directory inside each worktree instead of the repository root.
--output <path> Write JSON to a custom path. Defaults to data/timeline.json.If PowerShell says The term 'codegraph-timeline' is not recognized, the package has not been linked or installed globally yet. Either use the direct node dist/src/cli.js ... form, or run npm link from this repository.
If Node says Cannot find module '...\dist\src\cli.js', build the TypeScript sources first:
npm run buildLocal execution with options:
node dist/src/cli.js scan <repoPath> --limit 10After scanning a repository, start the local Web UI:
node dist/src/cli.js serveOn Windows PowerShell:
node .\dist\src\cli.js serveThen open the URL printed by the command, usually:
http://127.0.0.1:4173
The UI reads:
data/timeline.json
data/snapshots/*.json
Use the commit slider to switch snapshots. Use the Play/Stop button to step through commits automatically.
Serve options:
--data-dir <dir> Directory containing timeline.json and snapshots/. Defaults to data.
--host <host> Host to bind. Defaults to 127.0.0.1.
--port <port> Port to bind. Defaults to 4173.The graph view uses Cytoscape.js. To keep the MVP responsive, it displays at most 100 nodes from the selected snapshot and hides edges connected to omitted nodes.
data/timeline.json contains an array of snapshots:
[
{
"commit": "abc123...",
"commitDate": "2026-06-04T12:00:00+09:00",
"nodeCount": 12,
"edgeCount": 18,
"maxInDegree": 4,
"maxOutDegree": 3,
"changedFiles": ["src/index.ts"]
}
]Each commit also gets a module graph snapshot in data/snapshots/<commit>.json:
{
"commit": "abc123...",
"date": "2026-06-04T12:00:00+09:00",
"nodes": [
{ "id": "src/index.ts", "label": "index.ts" }
],
"edges": [
{ "source": "src/index.ts", "target": "src/app.ts", "type": "import" }
]
}MIT
npm testThe test command builds TypeScript and runs Node's built-in test runner.
