You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/graph_sitter/system-prompt.txt
+52-52Lines changed: 52 additions & 52 deletions
Original file line number
Diff line number
Diff line change
@@ -1,16 +1,16 @@
1
1
---
2
-
title: "Codegen"
2
+
title: "Graph-sitter"
3
3
sidebarTitle: "Overview"
4
4
icon: "robot"
5
5
iconType: "solid"
6
6
---
7
7
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.
9
9
10
10
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/).
11
11
12
12
```python
13
-
from codegen import Codebase
13
+
from graph_sitter import Codebase
14
14
15
15
# Graph-sitter builds a complete graph connecting
16
16
# functions, classes, imports and their relationships
@@ -59,9 +59,9 @@ pipx install graph-sitter
59
59
For further & more in depth installation instructions, see the [installation guide](/introduction/installation).
60
60
</Note>
61
61
62
-
## What can I do with Codegen?
62
+
## What can I do with Graph-sitter?
63
63
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:
65
65
66
66
<CardGroup cols={2}>
67
67
<Card
@@ -87,7 +87,7 @@ Codegen's simple yet powerful APIs enable a range of applications, including:
87
87
</Card>
88
88
</CardGroup>
89
89
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.
91
91
92
92
<Frame caption="Call graph visualization for modal/modal-client/_Client">
93
93
<iframe
@@ -118,7 +118,7 @@ import {
118
118
icon="graduation-cap"
119
119
href="/introduction/getting-started"
120
120
>
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.
Learn how to use Graph-sitter for common code transformation tasks.
@@ -131,7 +131,7 @@ import {
131
131
</Card>
132
132
</CardGroup>
133
133
134
-
## Why Codegen?
134
+
## Why Graph-sitter?
135
135
136
136
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.
137
137
@@ -438,7 +438,7 @@ These flags are helpful for debugging problematic repos, optimizing Codegen’s
438
438
439
439
```python
440
440
from graph_sitter import Codebase
441
-
from codegen.configs import CodebaseConfig
441
+
from graph_sitter.configs import CodebaseConfig
442
442
443
443
# Initialize a Codebase with custom configuration
444
444
codebase = Codebase(
@@ -520,15 +520,15 @@ We recommend using [uv](https://github.com/astral-sh/uv) for installation. If yo
520
520
curl -LsSf https://astral.sh/uv/install.sh | sh
521
521
```
522
522
523
-
## Installing Codegen
523
+
## Installing Graph-sitter
524
524
525
525
```bash
526
526
uv tool install graph-sitter --python 3.13
527
527
```
528
528
529
529
530
530
<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.
532
532
</Note>
533
533
534
534
## Quick Start
@@ -581,7 +581,7 @@ Let's walk through a minimal example of using Graph-sitter in a project:
581
581
Having issues? Here are some common problems and their solutions:
582
582
583
583
- **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`.
585
585
- **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)`.
586
586
587
587
<Note>
@@ -617,7 +617,7 @@ For more help, join our [community Slack](/introduction/community) or check the
617
617
icon="hammer"
618
618
href="/building-with-graph-sitter/at-a-glance"
619
619
>
620
-
Learn more about building with Codegen
620
+
Learn more about building with Graph-sitter
621
621
</Card>
622
622
623
623
</CardGroup>
@@ -814,7 +814,7 @@ Graph-sitter is designed to be used with AI assistants. This document describes
814
814
815
815
## System Prompt
816
816
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.
@@ -1865,8 +1865,8 @@ You can customize the behavior of your Codebase instance by passing a `CodebaseC
1865
1865
1866
1866
```python
1867
1867
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
1870
1870
1871
1871
codebase = Codebase(
1872
1872
"path/to/repository",
@@ -1893,9 +1893,9 @@ Here's an example:
1893
1893
1894
1894
```python
1895
1895
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
1899
1899
1900
1900
codebase = Codebase(
1901
1901
projects = [
@@ -2178,7 +2178,7 @@ iconType: "solid"
2178
2178
2179
2179
# Function Decorator
2180
2180
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
2182
2182
2183
2183
## Usage
2184
2184
@@ -2200,7 +2200,7 @@ In this example, the function `run` is decorated with `@graph_sitter.function` a
2200
2200
2201
2201
## Description
2202
2202
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.
- [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).
2538
2538
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.
2540
2540
2541
2541
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.
2542
2542
@@ -3278,7 +3278,7 @@ for imp in file.imports:
3278
3278
imp = file.get_import('math')
3279
3279
3280
3280
# Grab and filter from a codebase
3281
-
from codegen.sdk import ExternalModule
3281
+
from graph_sitter.sdk import ExternalModule
3282
3282
3283
3283
external_imports = [i for i in codebase.imports if isinstance(i, ExternalModule)]
3284
3284
```
@@ -5466,9 +5466,9 @@ Here's how to build a directed graph of function calls using NetworkX:
5466
5466
5467
5467
```python
5468
5468
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
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.
7096
7096
7097
7097
View the full code and setup instructions in our [codebase-analytics repository](https://github.com/codegen-sh/codebase-analytics).
7098
7098
@@ -7137,7 +7137,7 @@ Halstead Volume is a software metric which measures the complexity of a codebase
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.
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.
7161
7161
7162
7162
```python
7163
7163
def calculate_doi(cls):
@@ -7171,7 +7171,7 @@ Maintainability Index is a software metric which measures how maintainable a cod
7171
7171
7172
7172
This formula is then normalized to a scale of 0-100, where 100 is the maximum maintainability.
7173
7173
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.
7175
7175
7176
7176
```python
7177
7177
def calculate_maintainability_index(
@@ -7217,7 +7217,7 @@ Comment density is calculated by dividing the lines of code which contain commen
7217
7217
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.
7218
7218
7219
7219
## 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.
7221
7221
7222
7222
```python
7223
7223
num_files = len(codebase.files(extensions="*"))
@@ -7234,7 +7234,7 @@ The tool is implemented as a FastAPI application wrapped in a Modal deployment.
7234
7234
1. Send a POST request to `/analyze_repo` with the repository URL
7235
7235
2. The tool will:
7236
7236
- Clone the repository
7237
-
- Parse the codebase using codegen
7237
+
- Parse the codebase using graph-sitter
7238
7238
- Calculate all metrics
7239
7239
- Return a comprehensive JSON response with all metrics
7240
7240
@@ -7279,9 +7279,9 @@ First, let's import the types we need from Codegen:
7279
7279
```python
7280
7280
import graph_sitter
7281
7281
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
7285
7285
```
7286
7286
7287
7287
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"]]
7451
7451
---
7452
7452
title: "Codebase Visualization"
7453
7453
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)."
7455
7455
icon: "share-nodes"
7456
7456
iconType: "solid"
7457
7457
---
@@ -7472,7 +7472,7 @@ iconType: "solid"
7472
7472
7473
7473
## Overview
7474
7474
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).
0 commit comments