An intelligent code analysis tool that uses LLMs to explain and document your codebase. It analyzes function dependencies, builds a call tree, and provides detailed explanations using AI.
bun install
Set your OpenRouter API key as an environment variable:
export OPENROUTER_API_KEY=your_api_key_here
If you want to use the web viewer:
cd ui
bun install
Run the main script with a function name to analyze:
bun run main.ts <functionName>
Example:
bun run main.ts analyzeCode
This will:
To view past analyses in the web UI:
# Step 1: Aggregate history files
bun run aggregate-history.ts
# Step 2: Start the web viewer
cd ui
bun run dev
Then open your browser to http://localhost:5173 to browse all your code analyses.
code_analysis/
āāā main.ts # Main analysis script
āāā utils.ts # Code parsing and analysis functions
āāā llmcalls.ts # LLM API integration
āāā aggregate-history.ts # History aggregation utility
āāā ui/ # Web viewer (Svelte)
ā āāā src/
ā ā āāā routes/
ā ā ā āāā +page.svelte # Main viewer page
ā ā āāā lib/
ā ā āāā components/ # UI components
ā āāā static/
ā ā āāā history/ # JSON history files
ā āāā package.json
ā āāā vite.config.ts
āāā package.json
.ts
, .tsx
, .js
, .jsx
, and .py
filesThe tool uses OpenRouter to access various LLM models. Default models are configured in main.ts
:
const models = ["deepseek/deepseek-chat-v3.1:free", "z-ai/glm-4.5-air:free"];
const temperature = 1.0;
You can modify these to use different models available on OpenRouter.
The web viewer provides:
To build the web viewer for production:
cd ui
bun run build
The built files will be in ui/.svelte-kit/
and can be deployed to any static hosting service.