Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
23 changes: 22 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ Ledger is a macOS desktop app for viewing git branches, worktrees, and pull requ
```
lib/main/main.ts # IPC handlers, app lifecycle
lib/services/ # Git operations as pure functions (branch, commit, stash, etc.)
lib/services/codegraph/ # Code dependency graph parsing (PHP, Ruby, TypeScript)
lib/conveyor/ # Typed IPC with Zod validation (schemas, handlers, APIs)
lib/preload/preload.ts # API exposed to renderer
app/app.tsx # Main React component (large)
app/styles/app.css # All styling (large)
app/types/electron.d.ts # TypeScript types for IPC
app/components/ # UI components (panels, canvas, window)
resources/scripts/ # External parser scripts (PHP, Ruby)
```

## Common Tasks
Expand All @@ -46,7 +48,8 @@ app/components/ # UI components (panels, canvas, window)

Main UI is in `app/app.tsx`. Components are in `app/components/`:
- `panels/editor/` - Editor panels (BranchDetail, PRReview, Staging, etc.)
- `panels/viz/` - Visualization panels (GitGraph)
- `panels/viz/` - Visualization panels (GitGraph, ERD, CodeGraph)
- `panels/viz/codegraph/` - Code dependency graph visualization
- `canvas/` - Canvas layout system
- `window/` - Window chrome (Titlebar, menus)

Expand Down Expand Up @@ -134,6 +137,24 @@ The canonical sources are:
- `lib/services/` - Git operations as pure functions
- `lib/conveyor/schemas/` - IPC channel definitions with Zod validation

## Code Graph (AST Parsing)

Visualizes code dependencies as a force-directed network graph. Supports:

| Language | Parser | Notes |
|----------|--------|-------|
| PHP | `nikic/php-parser` (bundled) | Laravel-optimized (Models/Controllers/Services) |
| Ruby | Regex-based | Rails-optimized (Models/Controllers) |
| TypeScript | `ts-morph` | Full AST with tsconfig resolution |

Key files:
- `lib/services/codegraph/` - Parser service and type definitions
- `resources/scripts/php-ast-parser.php` - PHP parser (bundled with nikic/php-parser)
- `resources/scripts/ruby-ast-parser.rb` - Ruby parser (no gem dependencies)
- `app/components/panels/viz/codegraph/` - React components and D3 renderer

The parsers run zero-touch (no modifications needed to target repo). For Laravel/Rails projects, only key directories are scanned for performance. Nodes with fewer than 2 connections are filtered out.

## Error Handling

- Git errors shown in error banner
Expand Down
16 changes: 16 additions & 0 deletions app/components/canvas/CanvasRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { EditorSlot } from './EditorSlot'
import { PRList, BranchList, WorktreeList, StashList, CommitList, Sidebar, RepoList } from '../panels/list'
import { GitGraph, ContributorChart, TechTreeChart } from '../panels/viz'
import { ERDCanvasPanel } from '../panels/viz/erd'
import { CodeGraphPanel } from '../panels/viz/codegraph'

// ========================================
// Data Interface
Expand Down Expand Up @@ -400,6 +401,7 @@ export function CanvasRenderer({
{ id: 'timeline', label: 'Timeline', icon: '◔' },
{ id: 'tech-tree', label: 'Tech Tree', icon: '⬡' },
{ id: 'erd-canvas', label: 'ERD', icon: '◫' },
{ id: 'codegraph', label: 'Code Graph', icon: '⬡' },
]

return (
Expand Down Expand Up @@ -523,6 +525,20 @@ export function CanvasRenderer({
</div>
)

case 'codegraph':
return (
<div className="viz-panel codegraph-panel">
<VizHeader
panel={column.panel}
label={column.label || 'Code Graph'}
icon={column.icon || '⬡'}
/>
<div className="viz-panel-content codegraph-content">
<CodeGraphPanel repoPath={data.repoPath} />
</div>
</div>
)

default:
return (
<div className="empty-column">
Expand Down
Loading