Skip to content

Commit fe56300

Browse files
committed
Merge branch 'develop' of github.com:codegen-sh/codegen-sdk into eagarwal-cg-10342-codebasereset-should-not-blow-away-ipynb-changes
2 parents 1bb194d + 4e0f0e5 commit fe56300

File tree

14 files changed

+379
-285
lines changed

14 files changed

+379
-285
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ repos:
2020
- id: biome-check
2121
additional_dependencies: ["@biomejs/[email protected]"]
2222
exclude: (src/codemods/eval)|(tests/unit/skills/snapshots)|(tests/unit/codegen/sdk/output)|(tests/integration/verified_codemods)|(docs/samples)
23-
23+
- repo: https://github.com/ComPWA/taplo-pre-commit
24+
rev: v0.9.3
25+
hooks:
26+
- id: taplo-format
2427
- repo: https://github.com/MarcoGorelli/cython-lint
2528
rev: v0.16.6
2629
hooks:

docs/building-with-codegen/codebase-visualization.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ This guide provides a basic overview of graph creation and customization. Like t
2020
width="100%"
2121
height="600px"
2222
scrolling="no"
23-
src={`https://chadcode.sh/embedded/graph?id=ef312926-286d-4c13-8e09-38e1a47882f1&zoom=0.5`}
23+
src={`https://codegen.sh/embedded/graph?id=ef312926-286d-4c13-8e09-38e1a47882f1&zoom=0.5`}
2424
className="rounded-xl "
2525
style={{
2626
backgroundColor: "#15141b",

docs/building-with-codegen/dot-codegen.mdx

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@ The `.codegen` directory contains your project's Codegen configuration, codemods
1111

1212
```bash
1313
.codegen/
14-
├── config.toml # Project configuration
15-
├── codemods/ # Your codemod implementations
16-
├── jupyter/ # Jupyter notebooks for exploration
17-
├── docs/ # API documentation
18-
├── examples/ # Example code
19-
└── prompts/ # AI system prompts
14+
├── .venv/ # Python virtual environment (gitignored)
15+
├── config.toml # Project configuration
16+
├── codemods/ # Your codemod implementations
17+
├── jupyter/ # Jupyter notebooks for exploration
18+
└── codegen-system-prompt.txt # AI system prompt
2019
```
2120

2221
## Initialization
@@ -31,6 +30,20 @@ codegen init [--fetch-docs] [--repo-name NAME] [--organization-name ORG]
3130
The `--fetch-docs` flag downloads API documentation and examples specific to your project's programming language.
3231
</Note>
3332

33+
## Virtual Environment
34+
35+
Codegen maintains its own virtual environment in `.codegen/.venv/` to ensure consistent package versions and isolation from your project's dependencies. This environment is:
36+
37+
- Created using `uv` for fast, reliable package management
38+
- Initialized with Python 3.13
39+
- Automatically managed by Codegen commands
40+
- Used for running codemods and Jupyter notebooks
41+
- Gitignored to avoid committing environment-specific files
42+
43+
The environment is created during `codegen init` and used by commands like `codegen run` and `codegen notebook`.
44+
45+
<Note>To debug codemods, you will need to set the python virtual environment in your IDE to `.codegen/.venv`</Note>
46+
3447
### Configuration
3548

3649
The `config.toml` file stores your project settings:
@@ -49,13 +62,15 @@ Codegen automatically adds appropriate entries to your `.gitignore`:
4962

5063
```gitignore
5164
# Codegen
52-
.codegen/prompts/
65+
.codegen/.venv/
5366
.codegen/docs/
54-
.codegen/examples/
67+
.codegen/jupyter/
68+
.codegen/codegen-system-prompt.txt
5569
```
5670

5771
<Info>
58-
While prompts, docs, and examples are ignored, your codemods in `.codegen/codemods/` are tracked in Git.
72+
- While most directories are ignored, your codemods in `.codegen/codemods/` and `config.toml` are tracked in Git
73+
- The virtual environment and Jupyter notebooks are gitignored to avoid environment-specific issues
5974
</Info>
6075

6176
## Working with Codemods

docs/introduction/overview.mdx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ iconType: "solid"
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

12-
export const intoSnippet = `# Codegen builds a complete graph connecting
12+
export const metaCode = `# Codegen builds a complete graph connecting
1313
# functions, classes, imports and their relationships
1414
from codegen import Codebase
1515
@@ -21,13 +21,23 @@ for function in codebase.functions:
2121
function.remove()
2222
`
2323

24+
export const code = `def foo():
25+
pass
26+
27+
def bar():
28+
foo()
29+
30+
def baz():
31+
pass
32+
`
33+
2434
<iframe
2535
width="100%"
2636
height="300px"
2737
scrolling="no"
2838
src={`https://chadcode.sh/embedded/codemod/?code=${encodeURIComponent(
29-
intoSnippet
30-
)}`}
39+
metaCode
40+
)}&input=${encodeURIComponent(code)}`}
3141
style={{
3242
backgroundColor: "#15141b",
3343
}}

hatch.toml

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ tool = ["uv", "pip"]
1212
[envs.hatch-build.overrides]
1313
matrix.tool.installer = { value = "{matrix:tool}" }
1414
matrix.tool.scripts = [
15-
{ key = "pip", value = "{env:HATCH_UV} pip {args}", if = [
16-
"uv",
17-
] },
15+
{ key = "pip", value = "{env:HATCH_UV} pip {args}", if = [
16+
"uv",
17+
] },
1818
]
1919

2020
[version]
@@ -25,19 +25,19 @@ UV_EXTRA_INDEX_URL = "https://[email protected].
2525

2626
[build.targets.wheel.hooks.cython]
2727
dependencies = [
28-
"hatch-cython @ git+https://github.com/codegen-sh/hatch-cython.git",
29-
"cython>=3.0.11",
30-
"tree-sitter",
31-
"networkx",
28+
"hatch-cython @ git+https://github.com/codegen-sh/hatch-cython.git",
29+
"cython>=3.0.11",
30+
"tree-sitter",
31+
"networkx",
3232
]
3333

3434
[build.targets.wheel.hooks.cython.options]
3535
src = "codegen/sdk"
3636
compile_args = [
37-
"-O3",
38-
{ platforms = [
39-
"darwin",
40-
], arch = "arm64", arg = "-mcpu=apple-m1" },
37+
"-O3",
38+
{ platforms = [
39+
"darwin",
40+
], arch = "arm64", arg = "-mcpu=apple-m1" },
4141
]
4242
cythonize_kwargs = { annotate = true, nthreads = 16, exclude_failures = false, cache = true }
4343
compiled_sdist = true
@@ -57,27 +57,30 @@ c_string_type = "unicode"
5757

5858
[build.targets.wheel.hooks.cython.options.files]
5959
exclude = [
60-
"**/__init__.py",
61-
"**/code_generation",
62-
"**/skills",
63-
"**/codebase/factory",
64-
"**/guides",
65-
"**/testing",
66-
"**/codebase_graph_utils.py",
60+
"**/__init__.py",
61+
"**/code_generation",
62+
"**/skills",
63+
"**/codebase/factory",
64+
"**/guides",
65+
"**/testing",
66+
"**/codebase_graph_utils.py",
6767
]
6868

6969
[build.targets.wheel]
7070
macos-max-compat = false
7171

7272
[build]
73-
packages = [
74-
"src/codegen",
75-
]
76-
77-
[metadata.hooks.vcs]
78-
Homepage = "https://github.com/codegen-sh/codegen-sdk"
79-
source_archive = "https://github.com/codegen-sh/codegen-sdk/archive/{commit_hash}.zip"
73+
packages = ["src/codegen"]
8074

75+
[metadata.hooks.vcs.urls]
76+
Homepage = "https://www.codegen.com/"
77+
Repository = "https://github.com/codegen-sh/codegen-sdk"
78+
download = "https://github.com/codegen-sh/codegen-sdk/archive/{commit_hash}.zip"
79+
Changelog = "https://docs.codegen.com/changelog/changelog"
80+
Releasenotes = "https://github.com/codegen-sh/codegen-sdk/releases"
81+
Issues = "https://github.com/codegen-sh/codegen-sdk/issues"
82+
Documentation = "https://docs.codegen.sh"
83+
Playground = "https://www.codegen.sh/"
8184

8285
[build.targets.wheel.hooks.custom]
8386
enable-by-default = false

0 commit comments

Comments
 (0)