View Source on Github
Attributes
classes
List of all Classes in the codebase.
console
current_commit
Returns the current Git commit that is checked out in the repository.
default_branch
The default branch of this repository.
directories
List all directories in the codebase.
external_modules
Returns a list of all external modules in the codebase.
functions
List of all Functions in the codebase.
global_vars
List of all GlobalVars in the codebase.
imports
Returns a list of all Import nodes in the codebase.
interfaces
Retrieves all interfaces in the codebase.
language
The programming language of the repository.
name
The name of the repository.
repo_path
symbols
List of all top-level Symbols (Classes, Functions, etc.) in the codebase. Excludes Class
types
List of all Types in the codebase (Typescript only).
viz
Methods
ai
Generates a response from the AI based on the provided prompt, target, and context.View Source on Github
Parameters
prompt
required
target
default:None
context
default:None
model
default:"gpt-4o"
Returns
The generated response from the AI.
checkout
Checks out a git branch or commit and syncs the codebase graph to the new state.View Source on Github
Parameters
commit
default:None
branch
default:None
create_if_missing
default:False
remote
default:False
Returns
The result of the checkout operation.
commit
Commits all staged changes to the codebase graph and synchronizes the graph with the filesystem if specified.View Source on Github
Parameters
sync_graph
default:True
Returns
create_directory
Creates a directory at the specified path.View Source on Github
Parameters
dir_path
required
exist_ok
default:False
parents
default:False
Returns
create_file
Creates a new file in the codebase with specified content.View Source on Github
Parameters
filepath
required
content
default:""
sync
default:True
Returns
The newly created file object.
files
A list property that returns all files in the codebase.View Source on Github
Returns
A sorted list of source files in the codebase.
find_by_span
Finds editable objects that overlap with the given source code span.View Source on Github
Parameters
span
required
Returns
A list of Editable objects that overlap with the given span.
from_repo
Fetches a codebase from GitHub and returns a Codebase instance.View Source on Github
Parameters
repo_name
required
tmp_dir
default:None
commit
default:None
shallow
default:True
Returns
A Codebase instance initialized with the cloned repository
get_class
Returns a class that matches the given name.View Source on Github
Parameters
class_name
required
optional
default:False
Returns
The class with the given name, or None if optional=True and class not found.
get_directory
Returns Directory bydir_path, or full path to the directory from codebase root.
View Source on Github
Parameters
dir_path
required
optional
default:False
Returns
The Directory object if found, None if optional=True and directory not found.
get_file
Retrieves a file from the codebase by its filepath.View Source on Github
Parameters
filepath
required
optional
default:False
ignore_case
default:False
Returns
The source file if found, None if optional=True and file not found.
get_function
Retrieves a function from the codebase by its name.View Source on Github
Parameters
function_name
required
optional
default:False
Returns
The matching function if found. If optional=True and no match is found, returns None.
get_relative_path
Calculates a relative path from one file to another, removing the extension from the target file.View Source on Github
Parameters
from_file
required
to_file
required
Returns
The relative path from `from_file` to `to_file` (with the extension removed from `to_file`).
get_symbol
Returns a Symbol by name from the codebase.View Source on Github
Parameters
symbol_name
required
optional
default:False
Returns
The matched Symbol if found, None if not found and optional=True.
get_symbols
Retrieves all symbols in the codebase that match the given symbol name.View Source on Github
Parameters
symbol_name
required
Returns
A list of Symbol objects that match the given name, sorted alphabetically.
git_commit
Commits all staged changes to the codebase and git.View Source on Github
Parameters
message
required
verify
default:False
Returns
The commit object if changes were committed, None otherwise.
has_directory
Returns a boolean indicating if a directory exists in the codebase.View Source on Github
Parameters
dir_path
required
Returns
True if the directory exists in the codebase, False otherwise.
has_file
Determines if a file exists in the codebase.View Source on Github
Parameters
filepath
required
ignore_case
default:False
Returns
True if the file exists in the codebase, False otherwise.
has_symbol
Returns whether a symbol exists in the codebase.View Source on Github
Parameters
symbol_name
required
Returns
True if a symbol with the given name exists in the codebase, False otherwise.
reset
Resets the codebase byView Source on Github
Returns
set_ai_key
Sets the OpenAI key for the current Codebase instance.View Source on Github
Returns
set_session_options
Sets the Session options for the current codebase.View Source on Github
Returns
should_fix
Returns True if the flag should be fixed based on the current mode and active group.View Source on Github
Parameters
flag
required
Returns
True if the flag should be fixed, False if it should be ignored. Returns False in find mode. Returns True if no active group is set. Returns True if the flag's hash exists in the active group hashes.
visualize
Visualizes a NetworkX graph or Plotly figure.View Source on Github
Parameters
G
required
root
default:None