Skip to content

The Repository Interface

The kit.Repository object is the backbone of the library. It serves as your primary interface for accessing, analyzing, and understanding codebases, regardless of their language or location (local path or remote Git URL).

What Can You Do with a Repository?

Once you instantiate a Repository object pointing to your target codebase:

from kit import Repository
# Point to a local project
my_repo = Repository("/path/to/local/project")
# Or point to a remote GitHub repo
# github_repo = Repository("https://github.com/owner/repo-name")
# Or analyze a specific version
# versioned_repo = Repository("https://github.com/owner/repo-name", ref="v1.2.3")

You can perform various code intelligence tasks:

Explore Structure

  • Get the file tree with .get_file_tree()

Read Content

  • Access file content with .get_file_content()

Understand Code

  • Extract functions, classes, and symbols with .extract_symbols()

Access Git Metadata

  • Get commit SHA, branch, and remote URL with .current_sha, .current_branch, .remote_url

Search & Navigate

  • Find text patterns with .search_text()
  • Find semantically similar code with .search_semantic()

Analyze Dependencies

  • Find where symbols are used with .find_symbol_usages()

Prepare for LLMs

  • Chunk code by lines with .chunk_file_by_lines()
  • Chunk code by symbols with .chunk_file_by_symbols()
  • Get context around lines with .extract_context_around_line()

Integrate with AI

  • Get configured summarizers with .get_summarizer()
  • Get vector searchers with .get_vector_searcher()

Export Data

  • Save to JSON with .write_index(), .write_symbols(), etc.
Class/ToolDescription
SummarizerGenerate summaries of code using LLMs
VectorSearcherQuery vector index of code for semantic search
DocstringIndexerBuild vector index of LLM-generated summaries
SummarySearcherQuery that index