Skip to content

Conversation

@prosdev
Copy link
Collaborator

@prosdev prosdev commented Nov 27, 2025

Summary

Enhances the dev_map tool to provide richer, more useful codebase overviews for AI assistants.

Changes

1. Signatures in Exports

  • Export display now shows function/method signatures instead of just names
  • Signatures truncated to 60 chars for readability
  • Falls back to name if no signature available

2. Hot Paths (Most Referenced Files)

  • New section showing files with most incoming references
  • Computed from callers and callees metadata
  • Helps AI identify central/important code quickly
  • Configurable via includeHotPaths and maxHotPaths options

3. Smart Depth (Adaptive Expansion)

  • Information density heuristic for tree pruning
  • Expands directories with high component counts
  • Collapses sparse directories to save tokens
  • Always shows first 2 levels for basic structure
  • Configurable via smartDepth and smartDepthThreshold options

Example Output

# Codebase Map

## Hot Paths (most referenced)
1. `packages/core/src/indexer/index.ts` (RepositoryIndexer) - 47 refs
2. `packages/core/src/vector/store.ts` (LanceDBVectorStore) - 32 refs
3. `packages/mcp-server/src/server/mcp-server.ts` (MCPServer) - 28 refs

## Directory Structure

└── packages/ (195 components)
    ├── core/ (45 components)
    │   └── exports: function search(query, opts): Promise<Result[]>, class RepositoryIndexer...
    ├── mcp-server/ (28 components)
    │   └── exports: class MCPServer, function createAdapter(config): Adapter...

New Options

Option Type Default Description
includeHotPaths boolean true Show hot paths section
maxHotPaths number 5 Max hot paths to display
smartDepth boolean false Use adaptive depth
smartDepthThreshold number 10 Min components to expand

Testing

  • 3 new tests for signatures
  • 5 new tests for hot paths
  • 3 new tests for smart depth
  • All 1370 tests passing

- Add signature field to ExportInfo type
- Extract signatures from indexed document metadata
- Display signatures in formatted output (truncated to 60 chars)
- Fall back to name if no signature available

Provides richer context for AI assistants to understand APIs.
Compute and display files with most incoming references:
- Count callers from indexed metadata
- Count callees pointing to files
- Sort by reference count, limit to maxHotPaths
- Display in formatted output with ref counts

Hot paths help AI assistants identify central/important code.
Implement information density heuristic for tree pruning:
- Expand directories with componentCount >= threshold
- Always show first 2 levels for basic structure
- Collapse sparse directories to save tokens
- Configurable via smartDepth and smartDepthThreshold options

Improves token efficiency by focusing on interesting code areas.
@prosdev prosdev merged commit 54917bb into main Nov 27, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant