Skip to content

Commit 3878ed1

Browse files
docs: updated API reference
1 parent 65d6223 commit 3878ed1

File tree

1 file changed

+52
-52
lines changed

1 file changed

+52
-52
lines changed

src/graph_sitter/system-prompt.txt

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
---
2-
title: "Codegen"
2+
title: "Graph-sitter"
33
sidebarTitle: "Overview"
44
icon: "robot"
55
iconType: "solid"
66
---
77

8-
[Codegen](https://github.com/codegen-sh/graph-sitter) is a python library for manipulating codebases.
8+
[Graph-sitter](https://github.com/codegen-sh/graph-sitter) is a python library for manipulating codebases.
99

1010
It provides a scriptable interface to a powerful, multi-lingual language server built on top of [Tree-sitter](https://tree-sitter.github.io/tree-sitter/).
1111

1212
```python
13-
from codegen import Codebase
13+
from graph_sitter import Codebase
1414

1515
# Graph-sitter builds a complete graph connecting
1616
# functions, classes, imports and their relationships
@@ -59,9 +59,9 @@ pipx install graph-sitter
5959
For further & more in depth installation instructions, see the [installation guide](/introduction/installation).
6060
</Note>
6161

62-
## What can I do with Codegen?
62+
## What can I do with Graph-sitter?
6363

64-
Codegen's simple yet powerful APIs enable a range of applications, including:
64+
Graph-sitter's simple yet powerful APIs enable a range of applications, including:
6565

6666
<CardGroup cols={2}>
6767
<Card
@@ -87,7 +87,7 @@ Codegen's simple yet powerful APIs enable a range of applications, including:
8787
</Card>
8888
</CardGroup>
8989

90-
See below for an example call graph visualization generated with Codegen.
90+
See below for an example call graph visualization generated with Graph-sitter.
9191

9292
<Frame caption="Call graph visualization for modal/modal-client/_Client">
9393
<iframe
@@ -118,7 +118,7 @@ import {
118118
icon="graduation-cap"
119119
href="/introduction/getting-started"
120120
>
121-
Follow our step-by-step tutorial to start manipulating code with Codegen.
121+
Follow our step-by-step tutorial to start manipulating code with Graph-sitter.
122122
</Card>
123123
<Card title="Tutorials" icon="diagram-project" href="/tutorials/at-a-glance">
124124
Learn how to use Graph-sitter for common code transformation tasks.
@@ -131,7 +131,7 @@ import {
131131
</Card>
132132
</CardGroup>
133133

134-
## Why Codegen?
134+
## Why Graph-sitter?
135135

136136
Many software engineering tasks - refactors, enforcing patterns, analyzing control flow, etc. - are fundamentally programmatic operations. Yet the tools we use to express these transformations often feel disconnected from how we think about code.
137137

@@ -438,7 +438,7 @@ These flags are helpful for debugging problematic repos, optimizing Codegen’s
438438

439439
```python
440440
from graph_sitter import Codebase
441-
from codegen.configs import CodebaseConfig
441+
from graph_sitter.configs import CodebaseConfig
442442

443443
# Initialize a Codebase with custom configuration
444444
codebase = Codebase(
@@ -520,15 +520,15 @@ We recommend using [uv](https://github.com/astral-sh/uv) for installation. If yo
520520
curl -LsSf https://astral.sh/uv/install.sh | sh
521521
```
522522

523-
## Installing Codegen
523+
## Installing Graph-sitter
524524

525525
```bash
526526
uv tool install graph-sitter --python 3.13
527527
```
528528

529529

530530
<Note>
531-
This makes the `codegen` command available globally in your terminal, while keeping its dependencies isolated.
531+
This makes the `graph-sitter` command available globally in your terminal, while keeping its dependencies isolated.
532532
</Note>
533533

534534
## Quick Start
@@ -581,7 +581,7 @@ Let's walk through a minimal example of using Graph-sitter in a project:
581581
Having issues? Here are some common problems and their solutions:
582582

583583
- **I'm hitting an UV error related to `[[ packages ]]`**: This means you're likely using an outdated version of UV. Try updating to the latest version with: `uv self update`.
584-
- **I'm hitting an error about `No module named 'codegen.sdk.extensions.utils'`**: The compiled cython extensions are out of sync. Update them with `uv sync --reinstall-package codegen`.
584+
- **I'm hitting an error about `No module named 'graph_sitter.sdk.extensions.utils'`**: The compiled cython extensions are out of sync. Update them with `uv sync --reinstall-package graph-sitter`.
585585
- **I'm hitting a `RecursionError: maximum recursion depth exceeded` error while parsing my codebase**: If you are using python 3.12, try upgrading to 3.13. If you are already on 3.13, try upping the recursion limit with `sys.setrecursionlimit(10000)`.
586586

587587
<Note>
@@ -617,7 +617,7 @@ For more help, join our [community Slack](/introduction/community) or check the
617617
icon="hammer"
618618
href="/building-with-graph-sitter/at-a-glance"
619619
>
620-
Learn more about building with Codegen
620+
Learn more about building with Graph-sitter
621621
</Card>
622622

623623
</CardGroup>
@@ -814,7 +814,7 @@ Graph-sitter is designed to be used with AI assistants. This document describes
814814

815815
## System Prompt
816816

817-
Graph-sitter provides a `.txt` file that you can drag-and-drop into any chat assistant. This is roughly 60k tokens and will enable chat assistants like, ChatGPT, Claude 3.5 etc. to build effectively with Codegen.
817+
Graph-sitter provides a `.txt` file that you can drag-and-drop into any chat assistant. This is roughly 60k tokens and will enable chat assistants like, ChatGPT, Claude 3.5 etc. to build effectively with Graph-sitter.
818818

819819
import {
820820
CODEGEN_SYSTEM_PROMPT
@@ -838,8 +838,8 @@ gs create delete-dead-imports . --description "Delete unused imports"
838838

839839
Graph-sitter automatically generates an optimized ["system prompt"](https://news.ycombinator.com/item?id=37880023) that includes:
840840

841-
- An introduction to Codegen
842-
- Codegen API documentation
841+
- An introduction to Graph-sitter
842+
- Graph-sitter API documentation
843843
- Examples of relevant transformations
844844

845845
You can find this generated prompt in the `.codegen/prompts/<codemod-name>-system-prompt.md` file.
@@ -878,13 +878,13 @@ This `.md` file can be used with any AI assistant (Claude, GPT-4, etc.) to get m
878878

879879
## Copilot, Cursor and Windsurf (IDEs)
880880

881-
When using IDE chat assistants, you can leverage Codegen's context by mentioning your codemod in composer mode:
881+
When using IDE chat assistants, you can leverage Graph-sitter's context by mentioning your codemod in composer mode:
882882

883883
```bash
884884
@.codegen/codemods/upgrade-react18 @.codegen/prompts/system-prompt.md
885885
```
886886

887-
This will ensure that the IDE's native chat model is aware of the APIs and common patterns for Codegen.
887+
This will ensure that the IDE's native chat model is aware of the APIs and common patterns for Graph-sitter.
888888

889889
## Devin, OpenHands and Semi-autonomous Code Agents
890890

@@ -1011,7 +1011,7 @@ You can customize the behavior of the graph construction process when initializi
10111011

10121012
```python
10131013
from graph_sitter import Codebase
1014-
from codegen.configs import CodebaseConfig
1014+
from graph_sitter.configs import CodebaseConfig
10151015

10161016
# Initialize a Codebase with custom configuration
10171017
codebase = Codebase(
@@ -1200,7 +1200,7 @@ This experimental flag pushes the graph creation back until the graph is needed.
12001200
**Example Codemod:**
12011201
```python
12021202
from graph_sitter import Codebase
1203-
from codegen.configs import CodebaseConfig
1203+
from graph_sitter.configs import CodebaseConfig
12041204

12051205
# Enable lazy graph parsing
12061206
codebase = Codebase("<repo_path>", config=CodebaseConfig(exp_lazy_graph=True))
@@ -1865,8 +1865,8 @@ You can customize the behavior of your Codebase instance by passing a `CodebaseC
18651865

18661866
```python
18671867
from graph_sitter import Codebase
1868-
from codegen.configs.models.codebase import CodebaseConfig
1869-
from codegen.configs.models.secrets import SecretsConfig
1868+
from graph_sitter.configs.models.codebase import CodebaseConfig
1869+
from graph_sitter.configs.models.secrets import SecretsConfig
18701870

18711871
codebase = Codebase(
18721872
"path/to/repository",
@@ -1893,9 +1893,9 @@ Here's an example:
18931893

18941894
```python
18951895
from graph_sitter import Codebase
1896-
from codegen.git.repo_operator.local_repo_operator import LocalRepoOperator
1897-
from codegen.git.schemas.repo_config import BaseRepoConfig
1898-
from codegen.sdk.codebase.config import ProjectConfig
1896+
from graph_sitter.git.repo_operator.local_repo_operator import LocalRepoOperator
1897+
from graph_sitter.git.schemas.repo_config import BaseRepoConfig
1898+
from graph_sitter.sdk.codebase.config import ProjectConfig
18991899

19001900
codebase = Codebase(
19011901
projects = [
@@ -2178,7 +2178,7 @@ iconType: "solid"
21782178

21792179
# Function Decorator
21802180

2181-
The `function` decorator is used to define codegen functions within your application. It allows you to specify a name for the function that will be ran making it easier to run specific codemods
2181+
The `function` decorator is used to define graph-sitter functions within your application. It allows you to specify a name for the function that will be ran making it easier to run specific codemods
21822182

21832183
## Usage
21842184

@@ -2200,7 +2200,7 @@ In this example, the function `run` is decorated with `@graph_sitter.function` a
22002200

22012201
## Description
22022202

2203-
The `function` decorator is part of the codegen SDK CLI and is used to mark functions that are intended to be ran as part of a code generation process. It ensures that the function is properly registered and can be invoked with the specified name.
2203+
The `function` decorator is part of the graph-sitter SDK CLI and is used to mark functions that are intended to be ran as part of a code generation process. It ensures that the function is properly registered and can be invoked with the specified name.
22042204

22052205

22062206
## CLI Examples
@@ -2534,9 +2534,9 @@ exists = codebase.has_directory("path/to/dir")
25342534
## Differences between SourceFile and File
25352535

25362536
- [File](/api-reference/core/File) - a general purpose class that represents any file in the codebase including non-code files like README.md, .env, .json, image files, etc.
2537-
- [SourceFile](/api-reference/core/SourceFile) - a subclass of [File](/api-reference/core/File) that provides additional functionality for source code files written in languages supported by the [codegen-sdk](/introduction/overview) (Python, TypeScript, JavaScript, React).
2537+
- [SourceFile](/api-reference/core/SourceFile) - a subclass of [File](/api-reference/core/File) that provides additional functionality for source code files written in languages supported by [graph-sitter](/introduction/overview) (Python, TypeScript, JavaScript, React).
25382538

2539-
The majority of intended use cases involve using exclusively [SourceFile](/api-reference/core/SourceFile) objects as these contain code that can be parsed and manipulated by the [codegen-sdk](/introduction/overview). However, there may be cases where it will be necessary to work with non-code files. In these cases, the [File](/api-reference/core/File) class can be used.
2539+
The majority of intended use cases involve using exclusively [SourceFile](/api-reference/core/SourceFile) objects as these contain code that can be parsed and manipulated by [graph-sitter](/introduction/overview). However, there may be cases where it will be necessary to work with non-code files. In these cases, the [File](/api-reference/core/File) class can be used.
25402540

25412541
By default, the `codebase.files` property will only return [SourceFile](/api-reference/core/SourceFile) objects. To include non-code files the `extensions='*'` argument must be used.
25422542

@@ -3278,7 +3278,7 @@ for imp in file.imports:
32783278
imp = file.get_import('math')
32793279

32803280
# Grab and filter from a codebase
3281-
from codegen.sdk import ExternalModule
3281+
from graph_sitter.sdk import ExternalModule
32823282

32833283
external_imports = [i for i in codebase.imports if isinstance(i, ExternalModule)]
32843284
```
@@ -5466,9 +5466,9 @@ Here's how to build a directed graph of function calls using NetworkX:
54665466

54675467
```python
54685468
import networkx as nx
5469-
from codegen.sdk.core.interfaces.callable import FunctionCallDefinition
5470-
from codegen.sdk.core.function import Function
5471-
from codegen.sdk.core.external_module import ExternalModule
5469+
from graph_sitter.sdk.core.interfaces.callable import FunctionCallDefinition
5470+
from graph_sitter.sdk.core.function import Function
5471+
from graph_sitter.sdk.core.external_module import ExternalModule
54725472

54735473
def create_call_graph(start_func, end_func, max_depth=5):
54745474
G = nx.DiGraph()
@@ -7092,7 +7092,7 @@ icon: "calculator"
70927092
iconType: "solid"
70937093
---
70947094

7095-
This tutorial explains how codebase metrics are efficiently calculated using the `codegen` library in the Codebase Analytics Dashboard. The metrics include indices of codebase maintainabilith and complexity.
7095+
This tutorial explains how codebase metrics are efficiently calculated using the `graph-sitter` library in the Codebase Analytics Dashboard. The metrics include indices of codebase maintainabilith and complexity.
70967096

70977097
View the full code and setup instructions in our [codebase-analytics repository](https://github.com/codegen-sh/codebase-analytics).
70987098

@@ -7137,7 +7137,7 @@ Halstead Volume is a software metric which measures the complexity of a codebase
71377137

71387138
**Halstead Volume**: `V = (N1 + N2) * log2(n1 + n2)`
71397139

7140-
This calculation uses codegen's expression types to make this calculation very efficient - these include BinaryExpression, UnaryExpression and ComparisonExpression. The function extracts operators and operands from the codebase object and calculated in `calculate_halstead_volume()` function.
7140+
This calculation uses graph-sitter's expression types to make this calculation very efficient - these include BinaryExpression, UnaryExpression and ComparisonExpression. The function extracts operators and operands from the codebase object and calculated in `calculate_halstead_volume()` function.
71417141

71427142
```python
71437143
def calculate_halstead_volume(operators, operands):
@@ -7157,7 +7157,7 @@ def calculate_halstead_volume(operators, operands):
71577157
```
71587158

71597159
### Depth of Inheritance (DOI)
7160-
Depth of Inheritance measures the length of inheritance chain for each class. It is calculated by counting the length of the superclasses list for each class in the codebase. The implementation is handled through a simple calculation using codegen's class information in the `calculate_doi()` function.
7160+
Depth of Inheritance measures the length of inheritance chain for each class. It is calculated by counting the length of the superclasses list for each class in the codebase. The implementation is handled through a simple calculation using graph-sitter's class information in the `calculate_doi()` function.
71617161

71627162
```python
71637163
def calculate_doi(cls):
@@ -7171,7 +7171,7 @@ Maintainability Index is a software metric which measures how maintainable a cod
71717171

71727172
This formula is then normalized to a scale of 0-100, where 100 is the maximum maintainability.
71737173

7174-
The implementation is handled through the `calculate_maintainability_index()` function. The codegen codebase object is used to efficiently extract the Cyclomatic Complexity and Halstead Volume for each function and class in the codebase, which are then used to calculate the maintainability index.
7174+
The implementation is handled through the `calculate_maintainability_index()` function. The graph-sitter codebase object is used to efficiently extract the Cyclomatic Complexity and Halstead Volume for each function and class in the codebase, which are then used to calculate the maintainability index.
71757175

71767176
```python
71777177
def calculate_maintainability_index(
@@ -7217,7 +7217,7 @@ Comment density is calculated by dividing the lines of code which contain commen
72177217
It measures the proportion of comments in the codebase and is a good indicator of how much code is properly documented. Accordingly, it can show how maintainable and easy to understand the codebase is.
72187218

72197219
## General Codebase Statistics
7220-
The number of files is determined by traversing codegen's FileNode objects in the parsed codebase. The number of functions is calculated by counting FunctionDef nodes across all parsed files. The number of classes is obtained by summing ClassDef nodes throughout the codebase.
7220+
The number of files is determined by traversing graph-sitter's FileNode objects in the parsed codebase. The number of functions is calculated by counting FunctionDef nodes across all parsed files. The number of classes is obtained by summing ClassDef nodes throughout the codebase.
72217221

72227222
```python
72237223
num_files = len(codebase.files(extensions="*"))
@@ -7234,7 +7234,7 @@ The tool is implemented as a FastAPI application wrapped in a Modal deployment.
72347234
1. Send a POST request to `/analyze_repo` with the repository URL
72357235
2. The tool will:
72367236
- Clone the repository
7237-
- Parse the codebase using codegen
7237+
- Parse the codebase using graph-sitter
72387238
- Calculate all metrics
72397239
- Return a comprehensive JSON response with all metrics
72407240

@@ -7279,9 +7279,9 @@ First, let's import the types we need from Codegen:
72797279
```python
72807280
import graph_sitter
72817281
from graph_sitter import Codebase
7282-
from codegen.sdk.core.external_module import ExternalModule
7283-
from codegen.sdk.core.import_resolution import Import
7284-
from codegen.sdk.core.symbol import Symbol
7282+
from graph_sitter.sdk.core.external_module import ExternalModule
7283+
from graph_sitter.sdk.core.import_resolution import Import
7284+
from graph_sitter.sdk.core.symbol import Symbol
72857285
```
72867286

72877287
Here's how we get the full context for each function:
@@ -7451,7 +7451,7 @@ examples = [create_training_example(f) for f in training_data["functions"]]
74517451
---
74527452
title: "Codebase Visualization"
74537453
sidebarTitle: "Visualization"
7454-
description: "This guide will show you how to create codebase visualizations using [codegen](/introduction/overview)."
7454+
description: "This guide will show you how to create codebase visualizations using [graph-sitter](/introduction/overview)."
74557455
icon: "share-nodes"
74567456
iconType: "solid"
74577457
---
@@ -7472,7 +7472,7 @@ iconType: "solid"
74727472

74737473
## Overview
74747474

7475-
To demonstrate the visualization capabilities of the codegen we will generate three different visualizations of PostHog's open source [repository](https://github.com/PostHog/posthog).
7475+
To demonstrate the visualization capabilities of graph-sitter we will generate three different visualizations of PostHog's open source [repository](https://github.com/PostHog/posthog).
74767476
- [Call Trace Visualization](#call-trace-visualization)
74777477
- [Function Dependency Graph](#function-dependency-graph)
74787478
- [Blast Radius Visualization](#blast-radius-visualization)
@@ -11501,7 +11501,7 @@ iconType: "solid"
1150111501

1150211502
# AI Impact Analysis
1150311503

11504-
This tutorial shows how to use Codegen's attribution extension to analyze the impact of AI on your
11504+
This tutorial shows how to use Graph-sitter's attribution extension to analyze the impact of AI on your
1150511505
codebase. You'll learn how to identify which parts of your code were written by AI tools like
1150611506
GitHub Copilot, Devin, or other AI assistants.
1150711507

@@ -11519,7 +11519,7 @@ The attribution extension analyzes git history to:
1151911519

1152011520
## Installation
1152111521

11522-
The attribution extension is included with Codegen. No additional installation is required.
11522+
The attribution extension is included with Graph-sitter. No additional installation is required.
1152311523

1152411524
## Basic Usage
1152511525

@@ -11528,7 +11528,7 @@ The attribution extension is included with Codegen. No additional installation i
1152811528
You can run the AI impact analysis using the graph_sitter.cli:
1152911529

1153011530
```bash
11531-
codegen analyze-ai-impact
11531+
graph-sitter analyze-ai-impact
1153211532
```
1153311533

1153411534
Or from Python code:
@@ -11614,17 +11614,17 @@ from collections import Counter
1161411614

1161511615
from graph_sitter import Codebase
1161611616
from graph_sitter.extensions.attribution.main import add_attribution_to_symbols
11617-
from codegen.git.repo_operator.repo_operator import RepoOperator
11618-
from codegen.git.schemas.repo_config import RepoConfig
11619-
from codegen.sdk.codebase.config import ProjectConfig
11620-
from codegen.shared.enums.programming_language import ProgrammingLanguage
11617+
from graph_sitter.git.repo_operator.repo_operator import RepoOperator
11618+
from graph_sitter.git.schemas.repo_config import RepoConfig
11619+
from graph_sitter.sdk.codebase.config import ProjectConfig
11620+
from graph_sitter.shared.enums.programming_language import ProgrammingLanguage
1162111621

1162211622
def analyze_contributors(codebase):
1162311623
"""Analyze contributors to the codebase and their impact."""
1162411624
print("\n🔍 Contributor Analysis:")
1162511625

1162611626
# Define which authors are considered AI
11627-
ai_authors = ['devin[bot]', 'codegen[bot]', 'github-actions[bot]', 'dependabot[bot]']
11627+
ai_authors = ['devin[bot]', 'graph-sitter[bot]', 'github-actions[bot]', 'dependabot[bot]']
1162811628

1162911629
# Add attribution information to all symbols
1163011630
print("Adding attribution information to symbols...")

0 commit comments

Comments
 (0)