@@ -11,7 +11,7 @@ import {HorizontalDivider} from '/snippets/HorizontalDivider.mdx';
11
11
import {GithubLinkNote } from ' /snippets/GithubLinkNote.mdx' ;
12
12
import {Attribute } from ' /snippets/Attribute.mdx' ;
13
13
14
- <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L112-L1328 " />
14
+ <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L113-L1458 " />
15
15
16
16
17
17
## Attributes
@@ -89,7 +89,7 @@ import {Attribute} from '/snippets/Attribute.mdx';
89
89
<HorizontalDivider />
90
90
### <span className = " text-primary" >ai</span >
91
91
Generates a response from the AI based on the provided prompt, target, and context.
92
- <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L1114-L1192 " />
92
+ <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L1115-L1193 " />
93
93
94
94
<ParameterWrapper >
95
95
<Parameter
@@ -124,7 +124,7 @@ Generates a response from the AI based on the provided prompt, target, and conte
124
124
125
125
### <span className = " text-primary" >checkout</span >
126
126
Checks out a git branch or commit and syncs the codebase graph to the new state.
127
- <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L816-L849 " />
127
+ <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L817-L850 " />
128
128
129
129
<ParameterWrapper >
130
130
<Parameter
@@ -159,7 +159,7 @@ Checks out a git branch or commit and syncs the codebase graph to the new state.
159
159
160
160
### <span className = " text-primary" >commit</span >
161
161
Commits all staged changes to the codebase graph and synchronizes the graph with the filesystem if specified.
162
- <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L754-L766 " />
162
+ <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L755-L767 " />
163
163
164
164
<ParameterWrapper >
165
165
<Parameter
@@ -176,7 +176,7 @@ Commits all staged changes to the codebase graph and synchronizes the graph with
176
176
177
177
### <span className = " text-primary" >create_directory</span >
178
178
Creates a directory at the specified path.
179
- <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L480-L491 " />
179
+ <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L481-L492 " />
180
180
181
181
<ParameterWrapper >
182
182
<Parameter
@@ -205,7 +205,7 @@ Creates a directory at the specified path.
205
205
206
206
### <span className = " text-primary" >create_file</span >
207
207
Creates a new file in the codebase with specified content.
208
- <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L442-L478 " />
208
+ <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L443-L479 " />
209
209
210
210
<ParameterWrapper >
211
211
<Parameter
@@ -234,7 +234,7 @@ Creates a new file in the codebase with specified content.
234
234
235
235
### <span className = " text-primary" >create_pr</span >
236
236
Creates a pull request from the current branch to the repository's default branch.
237
- <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L914-L941 " />
237
+ <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L915-L942 " />
238
238
239
239
<ParameterWrapper >
240
240
<Parameter
@@ -257,31 +257,31 @@ Creates a pull request from the current branch to the repository's default branc
257
257
258
258
### <span className = " text-primary" >create_pr_comment</span >
259
259
Create a comment on a pull request
260
- <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L1309-L1311 " />
260
+ <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L1439-L1441 " />
261
261
262
262
263
263
<Return return_type = { <code className = " text-sm bg-gray-100 px-2 py-0.5 rounded" >None</code > } description = " " />
264
264
265
265
266
266
### <span className = " text-primary" >create_pr_review_comment</span >
267
267
Create a review comment on a pull request.
268
- <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L1313-L1328 " />
268
+ <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L1443-L1458 " />
269
269
270
270
271
271
<Return return_type = { <code className = " text-sm bg-gray-100 px-2 py-0.5 rounded" >None</code > } description = " " />
272
272
273
273
274
274
### <span className = " text-primary" >files</span >
275
275
A list property that returns all files in the codebase.
276
- <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L260-L291 " />
276
+ <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L261-L292 " />
277
277
278
278
279
279
<Return return_type = { <><span >list[</span > <a href = " /api-reference/core/SourceFile" style = { {fontWeight: " inherit" , fontSize: " inherit" } } >SourceFile</a > <span >] | list[</span > <a href = " /api-reference/core/File" style = { {fontWeight: " inherit" , fontSize: " inherit" } } >File</a > <span >]</span ></> } description = " A sorted list of source files in the codebase." />
280
280
281
281
282
282
### <span className = " text-primary" >find_by_span</span >
283
283
Finds editable objects that overlap with the given source code span.
284
- <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L1202-L1217 " />
284
+ <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L1203-L1218 " />
285
285
286
286
<ParameterWrapper >
287
287
<Parameter
@@ -296,9 +296,17 @@ Finds editable objects that overlap with the given source code span.
296
296
<Return return_type = { <><span >list[</span > <a href = " /api-reference/core/Editable" style = { {fontWeight: " inherit" , fontSize: " inherit" } } >Editable</a > <span >]</span ></> } description = " A list of Editable objects that overlap with the given span." />
297
297
298
298
299
+ ### <span className = " text-primary" >from_files</span >
300
+ Creates a Codebase instance from multiple files.
301
+ <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L1349-L1429" />
302
+
303
+
304
+ <Return return_type = { <><a href = " /api-reference/core/Codebase" style = { {fontWeight: " inherit" , fontSize: " inherit" } } >Codebase</a ></> } description = " A Codebase instance initialized with the provided files" />
305
+
306
+
299
307
### <span className = " text-primary" >from_repo</span >
300
308
Fetches a codebase from GitHub and returns a Codebase instance.
301
- <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L1240-L1299 " />
309
+ <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L1241-L1300 " />
302
310
303
311
<ParameterWrapper >
304
312
<Parameter
@@ -349,9 +357,17 @@ Fetches a codebase from GitHub and returns a Codebase instance.
349
357
<Return return_type = { <><a href = " /api-reference/core/Codebase" style = { {fontWeight: " inherit" , fontSize: " inherit" } } >Codebase</a ></> } description = " A Codebase instance initialized with the cloned repository" />
350
358
351
359
360
+ ### <span className = " text-primary" >from_string</span >
361
+ Creates a Codebase instance from a string of code.
362
+ <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L1303-L1346" />
363
+
364
+
365
+ <Return return_type = { <><a href = " /api-reference/core/Codebase" style = { {fontWeight: " inherit" , fontSize: " inherit" } } >Codebase</a ></> } description = " A Codebase instance initialized with the provided code Example: >>> # Python code >>> code = " def add(a, b): return a + b" >>> codebase = Codebase.from_string(code, language=" python" ) >>> # TypeScript code >>> code = " function add(a: number, b: number): number { return a + b; }" >>> codebase = Codebase.from_string(code, language=" typescript" )" />
366
+
367
+
352
368
### <span className = " text-primary" >get_class</span >
353
369
Returns a class that matches the given name.
354
- <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L638-L660 " />
370
+ <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L639-L661 " />
355
371
356
372
<ParameterWrapper >
357
373
<Parameter
@@ -374,7 +390,7 @@ Returns a class that matches the given name.
374
390
375
391
### <span className = " text-primary" >get_directory</span >
376
392
Returns Directory by ` dir_path ` , or full path to the directory from codebase root.
377
- <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L560-L580 " />
393
+ <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L561-L581 " />
378
394
379
395
<ParameterWrapper >
380
396
<Parameter
@@ -397,7 +413,7 @@ Returns Directory by `dir_path`, or full path to the directory from codebase roo
397
413
398
414
### <span className = " text-primary" >get_file</span >
399
415
Retrieves a file from the codebase by its filepath.
400
- <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L509-L545 " />
416
+ <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L510-L546 " />
401
417
402
418
<ParameterWrapper >
403
419
<Parameter
@@ -426,7 +442,7 @@ Retrieves a file from the codebase by its filepath.
426
442
427
443
### <span className = " text-primary" >get_function</span >
428
444
Retrieves a function from the codebase by its name.
429
- <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L662-L689 " />
445
+ <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L663-L690 " />
430
446
431
447
<ParameterWrapper >
432
448
<Parameter
@@ -449,15 +465,15 @@ Retrieves a function from the codebase by its name.
449
465
450
466
### <span className = " text-primary" >get_modified_symbols_in_pr</span >
451
467
Get all modified symbols in a pull request
452
- <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L1301-L1307 " />
468
+ <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L1431-L1437 " />
453
469
454
470
455
471
<Return return_type = { <code className = " text-sm bg-gray-100 px-2 py-0.5 rounded" >tuple[str, dict[str, str], list[str]]</code > } description = " " />
456
472
457
473
458
474
### <span className = " text-primary" >get_relative_path</span >
459
475
Calculates a relative path from one file to another, removing the extension from the target file.
460
- <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L699-L730 " />
476
+ <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L700-L731 " />
461
477
462
478
<ParameterWrapper >
463
479
<Parameter
@@ -480,7 +496,7 @@ Calculates a relative path from one file to another, removing the extension from
480
496
481
497
### <span className = " text-primary" >get_symbol</span >
482
498
Returns a Symbol by name from the codebase.
483
- <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L595-L620 " />
499
+ <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L596-L621 " />
484
500
485
501
<ParameterWrapper >
486
502
<Parameter
@@ -503,7 +519,7 @@ Returns a Symbol by name from the codebase.
503
519
504
520
### <span className = " text-primary" >get_symbols</span >
505
521
Retrieves all symbols in the codebase that match the given symbol name.
506
- <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L622-L636 " />
522
+ <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L623-L637 " />
507
523
508
524
<ParameterWrapper >
509
525
<Parameter
@@ -520,7 +536,7 @@ Retrieves all symbols in the codebase that match the given symbol name.
520
536
521
537
### <span className = " text-primary" >git_commit</span >
522
538
Stages + commits all changes to the codebase and git.
523
- <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L736-L752 " />
539
+ <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L737-L753 " />
524
540
525
541
<ParameterWrapper >
526
542
<Parameter
@@ -543,7 +559,7 @@ Stages + commits all changes to the codebase and git.
543
559
544
560
### <span className = " text-primary" >has_directory</span >
545
561
Returns a boolean indicating if a directory exists in the codebase.
546
- <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L547-L558 " />
562
+ <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L548-L559 " />
547
563
548
564
<ParameterWrapper >
549
565
<Parameter
@@ -560,7 +576,7 @@ Returns a boolean indicating if a directory exists in the codebase.
560
576
561
577
### <span className = " text-primary" >has_file</span >
562
578
Determines if a file exists in the codebase.
563
- <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L493-L503 " />
579
+ <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L494-L504 " />
564
580
565
581
<ParameterWrapper >
566
582
<Parameter
@@ -583,7 +599,7 @@ Determines if a file exists in the codebase.
583
599
584
600
### <span className = " text-primary" >has_symbol</span >
585
601
Returns whether a symbol exists in the codebase.
586
- <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L582-L593 " />
602
+ <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L583-L594 " />
587
603
588
604
<ParameterWrapper >
589
605
<Parameter
@@ -600,23 +616,23 @@ Returns whether a symbol exists in the codebase.
600
616
601
617
### <span className = " text-primary" >reset</span >
602
618
Resets the codebase by
603
- <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L797-L814 " />
619
+ <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L798-L815 " />
604
620
605
621
606
622
<Return return_type = { <code className = " text-sm bg-gray-100 px-2 py-0.5 rounded" >None</code > } description = " " />
607
623
608
624
609
625
### <span className = " text-primary" >set_ai_key</span >
610
626
Sets the OpenAI key for the current Codebase instance.
611
- <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L1194-L1200 " />
627
+ <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L1195-L1201 " />
612
628
613
629
614
630
<Return return_type = { <code className = " text-sm bg-gray-100 px-2 py-0.5 rounded" >None</code > } description = " " />
615
631
616
632
617
633
### <span className = " text-primary" >set_session_options</span >
618
634
Sets the session options for the current codebase.
619
- <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L1219-L1237 " />
635
+ <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L1220-L1238 " />
620
636
621
637
<ParameterWrapper >
622
638
<Parameter
@@ -645,7 +661,7 @@ Sets the session options for the current codebase.
645
661
646
662
### <span className = " text-primary" >should_fix</span >
647
663
Returns True if the flag should be fixed based on the current mode and active group.
648
- <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L995-L1009 " />
664
+ <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L996-L1010 " />
649
665
650
666
<ParameterWrapper >
651
667
<Parameter
@@ -662,7 +678,7 @@ Returns True if the flag should be fixed based on the current mode and active gr
662
678
663
679
### <span className = " text-primary" >visualize</span >
664
680
Visualizes a NetworkX graph or Plotly figure.
665
- <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L947-L960 " />
681
+ <GithubLinkNote link = " https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py#L948-L961 " />
666
682
667
683
<ParameterWrapper >
668
684
<Parameter
0 commit comments