fastcode-cli

module
v0.0.0-...-2843bd2 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: MIT

README ΒΆ

⚑ FastCode-CLI

A Go-native Codebase Intelligence Engine

Inspired by HKUDS/FastCode β€” Rewritten in Go for speed, portability, and single-binary deployment.

TiαΊΏng Việt

Features β€’ Quick Start β€’ Architecture β€’ Roadmap β€’ Credits


🎯 What is FastCode-CLI?

FastCode-CLI is a high-performance, token-efficient code understanding engine written in Go. It parses, indexes, and navigates large codebases using AST analysis, hybrid search (semantic + BM25), and multi-layer graph modeling β€” all from a single compiled binary.

It is designed for:

  • AI Agent workflows β€” Provide structured, budget-aware code context to LLMs without overwhelming context windows.
  • Developer tooling β€” Quickly understand unfamiliar codebases, trace dependencies, and locate code.
  • MCP Server integration β€” Plug directly into Cursor, Claude Code, Windsurf, or any MCP-compatible client.

✨ Features

πŸ—οΈ Semantic-Structural Code Representation
  • AST Parsing via go-tree-sitter β€” Multi-level indexing across files, classes, functions, and documentation for 8+ languages (Go, Python, JavaScript, TypeScript, Java, Rust, C/C++, C#).
  • Hybrid Index β€” Combines dense vector embeddings with Bleve BM25 keyword search for precise and robust code retrieval.
  • Multi-Layer Graph Modeling β€” Three interconnected relationship graphs (Call Graph, Dependency Graph, Inheritance Graph) for structural navigation.
🧭 Lightning-Fast Navigation
  • Two-Stage Smart Search β€” First finds potentially relevant code, then ranks the best matches for your specific query.
  • Code Skimming β€” Reads only function signatures, class definitions, and type hints instead of full files, saving massive amounts of tokens.
  • Graph Traversal β€” Traces code connections up to N hops away, following imports, calls, and inheritance chains.
πŸ’° Cost-Efficient Context Management
  • Budget-Aware Decision Making β€” Weighs confidence, query complexity, codebase size, and token cost before processing.
  • Value-First Selection β€” Prioritizes high-impact, low-cost information first, like picking the ripest fruit at the best price.
πŸš€ Go Advantages
  • Single Binary β€” No Python, no pip, no venv, no Docker. Just one fast binary.
  • Goroutine Concurrency β€” Parallel AST parsing and HTTP embedding calls turn a 20s Python index into a 2s Go index.
  • Tiny Memory Footprint β€” No PyTorch, no FAISS pickle blobs. Just lean Go + Bleve.

πŸš€ Quick Start

Install from Source
git clone https://github.com/duyhunghd6/fastcode-cli.git
cd fastcode-cli
go build -o fastcode ./cmd/fastcode

# Configure your LLM endpoint
export OPENAI_API_KEY="your-key"
export MODEL="gpt-4o"
export BASE_URL="https://api.openai.com/v1"
Usage
# Index a local repository
fastcode index /path/to/your/repo

# Query the indexed codebase
fastcode query "How does the authentication flow work?"

# Multi-repo query
fastcode query --repos /path/repo1,/path/repo2 "Where is the payment logic?"

# Start as MCP server (for Cursor / Claude Code)
fastcode serve-mcp --port 8080

πŸ— Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                  fastcode-cli                    β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  cmd/       β”‚  internal/    β”‚  pkg/             β”‚
β”‚  fastcode   β”‚  parser       β”‚  treesitter       β”‚
β”‚  (Cobra)    β”‚  graph        β”‚                   β”‚
β”‚             β”‚  index        β”‚                   β”‚
β”‚             β”‚  agent        β”‚                   β”‚
β”‚             β”‚  llm          β”‚                   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        β”‚              β”‚               β”‚
   CLI/MCP      AST + Graph      Tree-sitter
   Interface    Engine           Go Bindings
        β”‚              β”‚               β”‚
        β–Ό              β–Ό               β–Ό
   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚ LLM API β”‚  β”‚ Bleve BM25β”‚  β”‚ Vector Storeβ”‚
   β”‚ (OpenAI β”‚  β”‚ (Keyword  β”‚  β”‚ (Embeddings)β”‚
   β”‚ /Ollama)β”‚  β”‚  Search)  β”‚  β”‚             β”‚
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
Package Layout
Package Description
cmd/fastcode CLI entry point (Cobra), subcommands: index, query, serve-mcp
internal/parser Tree-sitter AST parsing, code unit extraction (functions, classes, imports)
internal/graph Call Graph, Dependency Graph, Inheritance Graph construction & traversal
internal/index Hybrid indexing engine (vector embeddings + BM25 via Bleve)
internal/agent Iterative retrieval agent with budget-aware context gathering
internal/llm LLM client abstraction (OpenAI-compatible API)
pkg/treesitter Tree-sitter Go bindings and language grammar helpers
reference/ Original Python FastCode source code for reference during porting
docs/ Research documents, analysis, and porting plans

πŸ—Ί Roadmap

Phase 1: Core Engine (In Progress)
  • Tree-sitter AST parsing for Go, Python, JS/TS, Java, Rust
  • Code unit extraction (functions, classes, imports, types)
  • Call Graph and Dependency Graph construction
Phase 2: Indexing
  • LLM-based embedding generation (via OpenAI / Ollama API)
  • Bleve BM25 text indexing for keyword search
  • Hybrid retrieval (vector + BM25 fusion)
Phase 3: Retrieval Agent
  • Budget-aware iterative agent (port from Python IterativeAgent)
  • Code skimming and smart file browsing
  • Multi-repo query support
Phase 4: Integration
  • CLI commands: index, query, summary
  • MCP Server mode (serve-mcp)
  • REST API server mode

πŸ™ Credits

This project is a Go rewrite inspired by FastCode by the HKUDS Lab at The University of Hong Kong. The original Python implementation introduced the groundbreaking three-phase framework for token-efficient code understanding.

We gratefully acknowledge the original authors and their research contributions.


πŸ“„ License

This project is licensed under the MIT License.


Built with ❀️ in Go

Part of the Gmind ecosystem β€” Memory Management for Agentic Coding

Directories ΒΆ

Path Synopsis
cmd
ast-compare command
dumpelems command
dumpfiles command
fastcode command
internal
llm
pkg

Jump to

Keyboard shortcuts

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