funcfinder

module
v1.6.117 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 19, 2026 License: MIT

README ΒΆ

funcfinder

Go Version License Platform

Stop mastering grep. Run one script. Get the full picture.

./build.sh && ./funcfinder --dir . --all --json > map.json

Why?

Without funcfinder With funcfinder
AI reads README, avoids code (too expensive) AI sees full structure, reads only what matters
Hours browsing files: "what depends on what?" map.json + one jq query = instant answer
80% API budget on exploration 99% reduction β€” map once, extract targeted
ctags + LSP + grep + manual work One binary, 15 languages, zero setup
Learn tools, then teach model Drop map.json in context β€” model just works

Time + Money + Understanding + Simplicity = One command.

πŸš€ Production Features
  • πŸ“ Directory Mode ⭐ NEW: --dir ./project scans entire repositories with automatic language detection
  • ⚑ Parallel Processing: --workers 8 for 4-8x speedup on large codebases
  • 🎯 Smart Filtering: Automatic .gitignore support, skip node_modules, vendor, etc.
  • πŸ” Three Analysis Modes:
    • --map (default): Find all functions
    • --struct: Find only classes/structs/types
    • --all: Both functions and types
  • πŸ“Š Output Formats: grep-style, JSON, tree, tree-full, extract bodies
  • 🎨 Multi-language: Single command analyzes mixed Go/Python/C++/Java projects
  • πŸͺŸ Cross-platform: Linux, macOS, Windowsβ€”zero dependencies
πŸ“ˆ Real-World Performance
# Small project (21 files, mixed languages)
funcfinder -dir test_examples --all --map
β†’ 273 functions + 438 types in ~30-45ms

# Medium project (25 Go files)
funcfinder -dir internal --all --json
β†’ 228 functions + 69 classes in ~40ms

# Parallel speedup
--workers 1: 45ms  β†’  --workers 4: 29ms (1.55x faster)

🌐 Core Capabilities

  • πŸ” Single File Analysis: --inp file.go --map for targeted extraction
  • πŸ“ Directory Scanning: --dir ./src --all for entire codebases
  • πŸ—οΈ Type Extraction: --struct finds classes, structs, interfaces, enums
  • πŸ”„ Combined Analysis: --all gets both functions and types in one pass
  • πŸ—ΊοΈ Codebase Mapping: --tree shows hierarchical structure
  • πŸ“ Precise Extraction: --lines 50:100 for specific code ranges
  • πŸ“€ Body Extraction: --extract pulls complete function bodies
  • πŸ“Š JSON Export: --json for programmatic processing
  • ⚑ Performance: 763K lines/sec sanitizer, parallel worker pools
  • 🎯 Zero Dependencies: Single static binary

🌐 Supported Languages (15)

Category Languages
Systems C, C++, Rust, Go, D
JVM Java, Kotlin, Scala
Web JavaScript, TypeScript, PHP
Scripting Python, Ruby
Mobile Swift, C#

πŸ“¦ Installation

go install github.com/ruslano69/funcfinder@latest
Pre-built Binaries

Download from Releases:

# Linux
wget https://github.com/ruslano69/funcfinder/releases/download/v1.6.0/funcfinder-linux-amd64.tar.gz
tar -xzf funcfinder-linux-amd64.tar.gz
sudo mv funcfinder /usr/local/bin/

# macOS
wget https://github.com/ruslano69/funcfinder/releases/download/v1.6.0/funcfinder-darwin-amd64.tar.gz
tar -xzf funcfinder-darwin-amd64.tar.gz
sudo mv funcfinder /usr/local/bin/

# Windows
# Download funcfinder-windows-amd64.zip and add to PATH
From Source
git clone https://github.com/ruslano69/funcfinder.git
cd funcfinder

# Linux/macOS: Build all utilities (funcfinder, stat, deps, complexity)
./build.sh

# Windows (PowerShell): Build all utilities
.\build.ps1

# Or build funcfinder only
go build  # Now works! βœ…

βœ… Fixed: go build now works without errors! Other utilities use build tags and are built via build.sh/build.ps1.

For Windows-specific instructions, see docs/WINDOWS.md.

πŸš€ Quick Start

Directory Mode (⭐ Most Powerful)
# Scan entire project (auto-detects languages)
funcfinder --dir ./myproject --map --tree

# Find all functions + classes in repository
funcfinder --dir ./src --all --json > codebase.json

# Fast parallel scan with 8 workers
funcfinder --dir . --map --workers 8

# Only structs/classes (skip functions)
funcfinder --dir ./models --struct --map

# Output:
# INFO: Scanning directory: ./src (mode=all, workers=8, gitignore=true)
# └── src
# β”œβ”€β”€ main.go
# β”‚   β”œβ”€β”€ def main (line 10)
# β”‚   └── class Server (line 25)
# β”œβ”€β”€ handler.py
# β”‚   β”œβ”€β”€ def process (line 5)
# β”‚   └── class Handler (line 20)
# INFO: Processed 15 files, found 45 functions, 12 classes/types
Single File Mode
Check version
funcfinder --version
# Output: funcfinder version 1.6.0
Map all functions in a file
funcfinder --inp main.go --source go --map
# Output: main: 10-25; Handler: 45-78; helper: 65-72;
Find specific functions
funcfinder --inp api.go --source go --func Handler,Middleware
# Output: Handler: 45-78; Middleware: 80-95;
JSON output for AI
funcfinder --inp api.go --source go --map --json
{
  "Handler": {"start": 45, "end": 78},
  "Middleware": {"start": 80, "end": 95}
}
Extract function body
funcfinder --inp api.go --source go --func Handler --extract
// Handler: 45-78
func Handler(w http.ResponseWriter, r *http.Request) {
    // function body...
}
Find structs/classes/types (NEW in v1.5.0)
# Map all types in a Go file
funcfinder --inp models.go --source go --struct --map
# Output: User: 10-15; fields: ID, Name, Email Address: 20-25; fields: Street, City, Zip

# Find specific types
funcfinder --inp models.go --source go --struct --type User,Address
# Output: User: 10-15; fields: ID, Name, Email Address: 20-25; fields: Street, City, Zip

# JSON output for types
funcfinder --inp models.py --source py --struct --map --json
{
  "filename": "models.py",
  "types": [
    {
      "name": "User",
      "kind": "class",
      "start": 5,
      "end": 12,
      "fields": [
        {"name": "id", "type": "int", "line": 6},
        {"name": "name", "type": "str", "line": 7}
      ]
    }
  ]
}
Combined mode: functions + structs (NEW in v1.5.0)
# Get complete file structure in one call
funcfinder --inp service.go --source go --all --map

# Output:
# === FUNCTIONS ===
# NewService: 30-35; Process: 40-55; Validate: 60-70;
#
# === TYPES ===
# Service: 10-15; fields: db, cache Config: 20-25; fields: Host, Port

# JSON output with both functions and types
funcfinder --inp api.go --source go --all --json
{
  "filename": "api.go",
  "functions": [
    {"name": "NewService", "start": 30, "end": 35},
    {"name": "Process", "start": 40, "end": 55}
  ],
  "types": [
    {
      "name": "Service",
      "kind": "struct",
      "start": 10,
      "end": 15,
      "fields": [
        {"name": "db", "type": "*sql.DB", "line": 11},
        {"name": "cache", "type": "Cache", "line": 12}
      ]
    }
  ]
}

πŸ—οΈ Architecture: Why Not Just Regex?

The Problem with Simple Regex Parsers

Most code parsers use naive regex patterns and fail on edge cases:

// ❌ Simple regex breaks here:
string path = @"C:\Users\Test";  // C# verbatim string
string msg = @"He said ""Hello""";  // Escaped quotes in verbatim

// ❌ Regex truncates this:
query := `SELECT * FROM users // not a comment`  // Go raw string

// ❌ Regex sees 6 quotes, not 1 docstring:
"""This is a Python docstring"""
funcfinder's Solution: Factory + State Machine
Input File β†’ Language Factory β†’ Parser Factory β†’ Enhanced Sanitizer β†’ Pattern Matching
     β”‚              β”‚                  β”‚                    β”‚                  β”‚
  file.go      GoConfig          Finder           State Machine         Find Functions
  file.py    PythonConfig    PythonFinder     (763K lines/sec)         Extract Bodies
  file.cs      CSharpConfig       Finder       Handles verbatim            Output

Key Components:

  1. Language Factory (languages.json)

    • Auto-detects language by extension
    • Loads correct parser config (brace-based vs indent-based)
    • Supports 15+ languages with language-specific features
  2. Enhanced Sanitizer (State Machine, not regex)

    • 7 states: Normal, LineComment, BlockComment, String, RawString, CharLiteral, MultiLineString
    • Correctly handles: C# @"...", Python """, Go `...`, nested comments
    • Performance: 763,000 lines/sec
    • Technical deep-dive
  3. Parser Factory

    • CreateFinder() β†’ Brace-based (Go, Java, C++) or Indent-based (Python)
    • CreateStructFinder() β†’ Type extraction with field parsing
    • Unified API regardless of language
  4. Directory Processor

    • Worker pool for parallel processing
    • .gitignore pattern matching
    • Language detection per file
    • Result aggregation

Result: Handles production code that breaks simple regex parsers.

Proof: Test Results
# C# verbatim strings (broken in most tools)
funcfinder --inp test.cs --source cs --map
βœ… Correctly handles @"C:\Users" and @"He said ""Hello"""

# Python docstrings (often counted as 6 separate strings)
funcfinder --inp test.py --source py --map
βœ… Treats """...""" as single multiline string

# Go raw strings with comment-like content
funcfinder --inp test.go --source go --map
βœ… `SELECT // not comment` parsed correctly

πŸ€– AI Agent Integration

mini-SWE-agent Support

funcfinder provides perfect CLI tools for mini-SWE-agent - a minimalist AI coding agent that uses only bash commands.

Why perfect match:

  • βœ… Pure bash interface (no special tool-calling)
  • βœ… Stateless execution (each command independent)
  • βœ… JSON output everywhere (--json flag)
  • βœ… 99% token reduction vs reading full files

Quick Example:

# Agent workflow: Fix bug in auth/middleware.go

# 1. Get COMPLETE structure - functions + types (50 tokens vs 5000) ⭐ NEW
funcfinder --inp auth/middleware.go --source go --all --json

# 2. Extract buggy function (150 tokens vs 5000)
funcfinder --inp auth/middleware.go --source go --func ValidateToken --extract

# 3. Check related types (understand data structures)
funcfinder --inp auth/middleware.go --source go --struct --type TokenData --extract

# 4. Check complexity
complexity auth/middleware.go -j | jq '.functions[] | select(.name=="ValidateToken")'

# 5. Make targeted fix with 99% token savings! πŸŽ‰

Why --all is perfect for AI agents:

  • βœ… One call = complete context (functions + data structures)
  • βœ… Understand both behavior (functions) and state (types)
  • βœ… Minimal tokens for maximum insight
  • βœ… Perfect for code understanding and refactoring tasks

See: AI Agent Guide | Example Workflows

πŸ’‘ Use Cases

AI-Driven Development

Problem: AI reading 10,000 lines when it needs 250

Solution:

# 1. Get file structure (minimal tokens)
funcfinder --inp large_file.go --source go --map --json

# 2. AI selects needed function from map

# 3. Extract only that function (97.5% token savings!)
funcfinder --inp large_file.go --source go --func ProcessData --extract
Code Navigation
# Find all methods in a C# file
funcfinder --inp Controller.cs --source cs --map --json > functions.json

# Extract specific method for review
funcfinder --inp Controller.cs --source cs --func CreateUser --extract
JavaScript/TypeScript Support
# Find all functions in a JavaScript file
funcfinder --inp app.js --source js --map --json

# Extract async function from TypeScript
funcfinder --inp api.ts --source ts --func fetchUser --extract

# Find generator functions
funcfinder --inp generators.js --source js --func simpleGenerator --extract

# Extract arrow functions
funcfinder --inp utils.js --source js --func arrowFunc,asyncArrow --extract

# Find React component methods
funcfinder --inp Component.jsx --source js --func render,componentDidMount
Python Support with Decorators
# Map all functions in Python file
funcfinder --inp api.py --source py --map

# Extract function with decorators
funcfinder --inp api.py --source py --func cached_function --extract

# JSON output includes decorators
funcfinder --inp api.py --source py --func get_user --json
{
  "get_user": {
    "decorators": [
      "@require_auth",
      "@validate_input"
    ],
    "end": 42,
    "start": 35
  }
}

# Find async functions and generators
funcfinder --inp utils.py --source py --func async_generator,fibonacci --extract
Struct/Type Finding (NEW in v1.5.0)
# Find all types in a Go file
funcfinder --inp models.go --source go --struct --map
# Output: User: 10-20; fields: ID, Name, Email Config: 25-30; fields: Host, Port

# Find specific structs/classes
funcfinder --inp models.py --source py --struct --type User,Product --extract

# Get complete file structure (functions + types)
funcfinder --inp service.go --source go --all --json
{
  "functions": [{"name": "NewService", "start": 35, "end": 45}],
  "types": [
    {
      "name": "Service",
      "kind": "struct",
      "fields": [{"name": "db", "type": "*sql.DB", "line": 12}]
    }
  ]
}

# Find C++ classes and structs
funcfinder --inp widget.cpp --source cpp --struct --map

# Find Java classes and interfaces
funcfinder --inp api.java --source java --struct --map

# Find Python classes with fields
funcfinder --inp models.py --source py --struct --tree
# Output:
# class User (10-25)
#   β”œβ”€β”€ field id: int (line 11)
#   β”œβ”€β”€ field name: str (line 12)
#   └── field email: str (line 13)

Why struct finding is useful:

  • πŸ—οΈ Understand data structures before modifying code
  • πŸ” Find type definitions across large codebases
  • πŸ“Š JSON output for AI-powered refactoring
  • πŸ”„ Combined with functions for complete context
Tree Visualization for Classes
# Display class hierarchy in tree format
funcfinder --inp Calculator.java --source java --tree

# Output:
# class Calculator (1-20)
# β”œβ”€β”€ method add (5-7)
# β”œβ”€β”€ method subtract (9-11)
# └── method multiply (13-15)
# class Helper (22-30)
# β”œβ”€β”€ method assist (23-25)
# └── method process (27-29)

# Tree with full signatures
funcfinder --inp api.ts --source ts --tree-full

# Visualize Python classes (with decorators!)
funcfinder --inp models.py --source py --tree
Line Range Filtering (v1.4.0+)
# Standalone mode: Fast file slicing (works on ANY file, no --source needed)
funcfinder --inp app.log --lines 1000:1100
# Output: Lines 1000-1100 with line numbers

# JSON output for line ranges
funcfinder --inp config.yaml --lines :50 --json

# Filter mode: Narrow function search to specific lines
funcfinder --inp large_file.go --source go --map --lines 500:1000
# Only shows functions within lines 500-1000

# Find function in specific area (much faster for large files)
funcfinder --inp server.js --source js --func handleAPI --lines 100:500 --extract

# Tree view of limited scope
funcfinder --inp Calculator.java --source java --tree --lines 1:100

# Windows-compatible sed alternative (10-50x faster than PowerShell)
funcfinder --inp server.log --lines 5000:   # From line 5000 to EOF
funcfinder --inp debug.txt --lines :1000    # First 1000 lines
funcfinder --inp trace.log --lines 500      # Single line 500

Why --lines is useful:

  • πŸͺŸ Cross-platform: Works on Windows without sed
  • ⚑ Performance: 10-50x faster than PowerShell alternatives
  • 🎯 Precision: Combine with --map/--func/--tree to narrow search scope
  • πŸ“ Any file: Standalone mode works on logs, configs, any text file
Integration with Other Tools
# Combine with grep/mgrep for comprehensive analysis
mgrep "authentication" api.go
funcfinder --inp api.go --source go --func AuthHandler --extract

# Get function start line in scripts
START=$(funcfinder --inp api.go --source go --func Handler --json | jq '.Handler.start')

πŸ”„ Usage Scenarios

Git Hooks Integration: "Commit Once, Search Instantly Forever"

Automatically update your code map on every commit. Set up once β€” instant search forever.

1. Create post-commit hook:

# .git/hooks/post-commit
#!/bin/bash
funcfinder --dir . --all --json > .codemap.json 2>/dev/null
git add .codemap.json 2>/dev/null
chmod +x .git/hooks/post-commit

2. Add project configuration (optional):

# .funcfinder.config
EXCLUDE_DIRS="node_modules,vendor,.git,dist,build"
WORKERS=8
OUTPUT_FORMAT="json"

3. Result:

Approach Search Time Context
grep -r "func" ~2-5 sec Text only
funcfinder + hooks instant Structure + boundaries + types

Benefits:

  • πŸ“ Code map always up-to-date
  • ⚑ Instant search via .codemap.json
  • πŸ” AI agents get structure without parsing
  • πŸ’Ύ Minimal overhead (JSON ~50KB for medium project)

Using the map:

# Find functions in auth module
jq '.files[] | select(.path | contains("auth")) | .functions[]' .codemap.json

# List all classes with paths
jq '.files[] | .path as $p | .types[] | "\($p):\(.name)"' .codemap.json

# Project statistics
jq '{files: (.files | length), functions: [.files[].functions[]] | length}' .codemap.json

πŸ“– Usage

funcfinder --inp <file> [--source <lang>] [OPTIONS]

Required:
  --inp <file>       Source file to analyze
  --source <lang>    Language: go/c/cpp/cs/java/d/js/ts/py/rust/swift/kotlin/php/ruby/scala
                     (optional when using --lines alone)

Work modes (choose one):
  (default)          Find functions (default behavior)
  --struct           Find structs/classes/types instead of functions ⭐ NEW
  --all              Find both functions and structs ⭐ NEW

Search modes (choose one):
  --func <names>     Find specific functions (comma-separated)
  --type <names>     Find specific types (comma-separated, requires --struct) ⭐ NEW
  --map              Map all functions/types in file
  --tree             Display in tree format (shows class hierarchy)
  --tree-full        Display in tree format with signatures

Filtering:
  --lines <range>    Extract/filter by line range (standalone or with --source)
                     Formats: 100:150, :50, 100:, 100

Output formats:
  (default)          grep-style: name: n1-n2;
  --json             JSON format
  --extract          Extract function/type bodies

Options:
  --raw              Don't ignore raw strings in brace counting
  --version          Print version and exit
Examples of flag combinations:
# Functions (default mode)
funcfinder --inp file.go --source go --map                    # Map all functions
funcfinder --inp file.go --source go --func Handler          # Find specific function

# Structs mode
funcfinder --inp file.go --source go --struct --map          # Map all types
funcfinder --inp file.go --source go --struct --type User    # Find specific type

# Combined mode (--all requires --map, --tree, or --json)
funcfinder --inp file.go --source go --all --map             # Map functions + types
funcfinder --inp file.go --source go --all --json            # JSON with both
funcfinder --inp file.go --source go --all --extract         # Extract both

# Invalid combinations (will error)
funcfinder --inp file.go --source go --struct --all          # Mutually exclusive
funcfinder --inp file.go --source go --func foo --struct     # Can't mix modes
funcfinder --inp file.go --source go --type User             # Need --struct or --all

🎯 Token Reduction Examples

Example 1: Large Codebase Analysis

Traditional approach:

  • AI reads entire codebase: 100,000 lines = 150,000 tokens
  • Cost: $0.45 (at $0.003/1K tokens)
  • Time: Multiple AI requests, ~5-10 seconds

With funcfinder:

# 1. Get structure (280,000 lines/sec)
funcfinder --inp . --source go --map --json
  • Analysis time: 0.36 seconds for 100K lines
  • Tokens sent to AI: ~500 tokens (JSON structure)
  • Cost: $0.0015
  • Token savings: 99.67% | Cost savings: 300x | Time: faster than 1 AI request!
Example 2: Targeted Function Extraction

Traditional approach:

  • AI reads entire file: 5,000 lines = 7,500 tokens

With funcfinder:

# 1. Map functions
funcfinder --inp api.go --source go --map --json

# 2. AI selects function from structure (50 tokens)

# 3. Extract only that function
funcfinder --inp api.go --source go --func ProcessData --extract
  • Tokens used: 50 (structure) + 375 (function body) = 425 tokens
  • Token savings: 94%

πŸ—οΈ Architecture

funcfinder/
β”œβ”€β”€ cmd/                        # CLI entry points
β”‚   β”œβ”€β”€ funcfinder/main.go      # Main tool
β”‚   β”œβ”€β”€ stat/main.go            # Call counter
β”‚   β”œβ”€β”€ deps/main.go            # Dependency analyzer
β”‚   └── complexity/main.go      # Complexity analyzer
β”œβ”€β”€ internal/                   # Core logic
β”‚   β”œβ”€β”€ config.go               # Language configuration
β”‚   β”œβ”€β”€ languages.json          # 15 language patterns (embedded)
β”‚   β”œβ”€β”€ finder.go               # Function boundary detection
β”‚   β”œβ”€β”€ structfinder.go         # Class/struct detection
β”‚   β”œβ”€β”€ enhanced_sanitizer.go   # State-machine parser
β”‚   β”œβ”€β”€ dirprocessor.go         # Directory scanning
β”‚   β”œβ”€β”€ python_finder.go        # Python-specific logic
β”‚   β”œβ”€β”€ formatter.go            # Output formatting
β”‚   └── tree.go                 # Tree visualization
β”œβ”€β”€ examples/
β”‚   └── analyze.sh              # Full project analysis
β”œβ”€β”€ docs/                       # Documentation
└── test_examples/              # Test files (15 languages)

πŸ”§ Configuration

Language patterns are defined in languages.json (embedded in binary):

{
  "go": {
    "func_pattern": "^\\s*func\\s+(\\([^)]*\\)\\s+)?(\\w+)\\s*\\(",
    "line_comment": "//",
    "block_comment_start": "/*",
    "block_comment_end": "*/",
    "string_chars": ["\""],
    "raw_string_chars": ["`"],
    "escape_char": "\\"
  }
}

πŸ§ͺ Testing

Tested on:

  • Go standard library (fmt/print.go)
  • Production C# code (TELB project)
  • Real-world codebases with complex nesting
# Run tests
go test ./...

# Test on sample file
funcfinder --inp config.go --source go --map

πŸ› οΈ Additional Utilities

funcfinder ships with additional utilities for comprehensive code analysis. All utilities share a unified architecture with common configuration and error handling modules.

Quick Start
# Build all utilities
./build.sh

# Full project analysis in one command
./examples/analyze.sh

# AI agent workflow
funcfinder --inp api.go --source go --map  # Code structure
stat api.go -l go -n 10                    # Hotspots
deps . -l go -j                            # Dependency graph
complexity api.go -l go                    # Cognitive complexity
Utilities
Utility Purpose Languages Output
funcfinder Code structure (functions, classes, boundaries) 15 grep/JSON/extract
stat Function call analysis + file metrics 15 text
deps Module dependency analysis (stdlib/external/internal) 15 text/JSON
complexity Cognitive complexity analyzer (nesting depth) 15 colored text
🧠 complexity - Cognitive Complexity Analyzer

Philosophy: Deep nesting (not branch count) is the real complexity.

# Analyze single file
complexity main.go -l go

# Analyze directory
complexity . -l go

# JSON output for automation
complexity api.py -l py --json

# Top N most complex functions
complexity . -l go -n 10

Complexity Levels:

  • βœ… SIMPLE (depth ≀ 2) - Flat code, easy to understand
  • ⚠️ MODERATE (depth = 3) - One nesting level
  • πŸ”Ά HIGH (depth β‰₯ 4) - Two+ nesting levels
  • πŸ”΄ CRITICAL (depth β‰₯ 6) - Needs refactoring

Formula: NDC = 2^(maxDepth - 1)

πŸ“Š Full Analysis with analyze.sh
./examples/analyze.sh

Report includes:

  • πŸ“ˆ File statistics (lines, size, code/comments/blank ratio)
  • πŸ” Function inventory
  • πŸ”₯ Call hotspots (top functions by frequency)
  • πŸ“¦ Dependency graph (stdlib vs external vs internal)
  • 🧠 Complexity distribution (SIMPLE/MODERATE/HIGH/CRITICAL)
πŸ—οΈ Unified Architecture (v1.4.0)

All utilities share common modules (DRY principle):

funcfinder/
β”œβ”€β”€ internal/
β”‚   β”œβ”€β”€ config.go          # Unified language configuration
β”‚   β”œβ”€β”€ errors.go          # Standard error handling
β”‚   └── languages.json     # Single source of patterns (embedded)
β”œβ”€β”€ cmd/
β”‚   β”œβ”€β”€ funcfinder/        # Main CLI
β”‚   β”œβ”€β”€ stat/              # Call counter + metrics
β”‚   β”œβ”€β”€ deps/              # Dependency analyzer
β”‚   └── complexity/        # Complexity analyzer
└── examples/
    └── analyze.sh         # Full project analysis

Architecture Benefits:

  • βœ… Zero duplication - single config for all utilities
  • βœ… Consistency - same error messages everywhere
  • βœ… Easy extension - add language = update JSON
  • βœ… Zero dependencies - all utilities are static binaries

Common Use Cases:

  • πŸ“Š Initial analysis of unfamiliar code
  • πŸ” Finding optimization bottlenecks
  • πŸ”„ Refactoring and duplication detection
  • πŸ“ˆ Code review and PR analysis
  • πŸ€– AI agent navigation with minimal tokens
  • 🧠 Complexity assessment before refactoring

🀝 Contributing

Contributions welcome! Please follow these guidelines:

How to contribute:

  • Fork the repository and create a feature branch
  • Write tests for new functionality
  • Follow existing code style and conventions
  • Submit PR with clear description

Areas for contribution:

  • Additional language support
  • Improved regex patterns
  • Performance optimizations
  • Test coverage

πŸ“Š Performance

Verified Benchmarks

Parsing throughput: 280,000 lines/sec (3.6 ΞΌs per line)

# Real-world performance (verified with benchmark tool)
100,000 lines β†’ 0.36 seconds
280,000 lines β†’ 1.00 second

# This means funcfinder analyzes 100K lines FASTER than a single AI API request! (~500ms)
⚑ The X-Ray and Microscope for AI

What makes funcfinder unique:

  • πŸ”¬ X-ray vision: Scan entire codebase structure in milliseconds
  • πŸ” Microscope precision: Extract exact functions with zero noise
  • πŸš€ Faster than AI requests: 100K lines in 360ms vs AI request ~500ms
  • πŸ’° 99.67% token savings: 150,000 tokens β†’ 500 tokens for structure

Why this matters for AI workflows:

Traditional approach (without funcfinder):
β”œβ”€β”€ Read entire file: 150,000 tokens @ $0.003/1K = $0.45
β”œβ”€β”€ Wait for AI processing: ~500-1000ms
└── Get answer with full file context

With funcfinder:
β”œβ”€β”€ Get file structure: 0.36 seconds for 100K lines
β”œβ”€β”€ Send structure to AI: 500 tokens @ $0.003/1K = $0.0015
β”œβ”€β”€ AI selects function: instant
└── Extract function: <1ms
   Total: 0.36s + minimal cost (300x cheaper!)
Technical Details
  • Complexity: O(n) linear with respect to file size
  • Memory: Minimal (streaming line-by-line processing)
  • Binary size: 3MB (static, no external dependencies)
  • Platform: Cross-platform (Linux, macOS, Windows)

πŸ—ΊοΈ Roadmap

v1.1.0 βœ…
  • JavaScript/TypeScript support
  • --version flag
  • Arrow function support for JS/TS
  • Generator function support
v1.2.0 βœ…
  • Python support with decorator detection
  • Async/await function support
  • Improved function detection across all languages
v1.3.0 βœ…
  • Tree visualization (--tree and --tree-full)
  • Class hierarchy detection
  • Method-class association for all OOP languages
  • Rust support (structs, traits, enums, impl blocks)
  • Swift support (classes, structs, protocols, enums)
  • Kotlin, PHP, Ruby, Scala support ⭐ NEW
  • 15 languages total (added without Go code changes!)
v1.4.0 βœ…
  • --lines flag for line range filtering
  • Cross-platform file slicing (sed alternative)
  • Standalone and filter modes
  • stat utility - function call counter + file metrics (15 languages)
  • deps utility - dependency analyzer (15 languages)
  • complexity utility ⭐ NEW - cognitive complexity analyzer (15 languages)
  • Unified architecture - shared config.go and errors.go (DRY principle)
  • analyze.sh - comprehensive project analysis script
  • Complete code analysis toolkit with zero dependencies
v1.5.0 (Current) βœ…
  • --struct flag - Find structs/classes/types/interfaces ⭐ NEW
  • --type flag - Find specific types by name ⭐ NEW
  • --all flag - Combined mode (functions + structs) ⭐ NEW
  • EnhancedSanitizer - Multiline strings, char literals, nested comments
  • Struct pattern support for all 15 languages
  • Field extraction - Extract type fields with names and types
  • Combined JSON output - Functions and types in single response
  • Nested function support - Python, JS, TS, Go, Ruby, Scala
  • Complete code structure analysis (behavior + state)
v1.6.0
  • Configuration file support (.funcfinderrc)
  • Custom patterns via CLI
  • Improved C# regex patterns
  • Function type filters (public/private)
  • Cyclomatic complexity (as alternative to nesting depth)
  • HTML reports for analyze.sh
v2.0.0
  • Tree-sitter integration for precise parsing
  • 30+ language support
  • API server mode
  • IDE integrations

πŸ“š Documentation

πŸ“„ License

MIT License - see LICENSE file for details.

πŸ™ Acknowledgments

Built for AI-driven development workflows. Inspired by the need to minimize token usage in large codebases.

πŸ“ž Support


funcfinder - Navigate code efficiently, save tokens intelligently πŸš€

Directories ΒΆ

Path Synopsis
cmd
benchmark command
complexity command
complexity.go - Nesting Depth Complexity Analyzer Analyzes code complexity based on NESTING DEPTH, not decision point count Philosophy: Deep nesting is harder to understand than flat code with many branches
complexity.go - Nesting Depth Complexity Analyzer Analyzes code complexity based on NESTING DEPTH, not decision point count Philosophy: Deep nesting is harder to understand than flat code with many branches
deps command
deps.go - Module dependency analyzer Uses shared configuration for multiple languages
deps.go - Module dependency analyzer Uses shared configuration for multiple languages
findstruct command
funcfinder command
stat command
stat.go - Unified function call counter for multiple languages Counts function calls in source files using shared configuration
stat.go - Unified function call counter for multiple languages Counts function calls in source files using shared configuration
config.go - Unified language configuration Loads and manages language patterns for funcfinder, stat, deps, complexity, and findstruct
config.go - Unified language configuration Loads and manages language patterns for funcfinder, stat, deps, complexity, and findstruct
test_structs_go.go - Test file for Go struct detection
test_structs_go.go - Test file for Go struct detection

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL