8
8
9
9
from codegen import Codebase
10
10
from codegen .extensions .linear .linear_client import LinearClient
11
- from codegen .extensions .tools .linear_tools import (
11
+ from codegen .extensions .tools .linear . linear import (
12
12
linear_comment_on_issue_tool ,
13
13
linear_create_issue_tool ,
14
14
linear_get_issue_comments_tool ,
@@ -354,19 +354,24 @@ def _run(self, query: str, k: int = 5, preview_length: int = 200) -> str:
354
354
return json .dumps (result , indent = 2 )
355
355
356
356
357
- class CreatePRInput (BaseModel ):
357
+ ########################################################################################################################
358
+ # GITHUB
359
+ ########################################################################################################################
360
+
361
+
362
+ class GithubCreatePRInput (BaseModel ):
358
363
"""Input for creating a PR"""
359
364
360
365
title : str = Field (..., description = "The title of the PR" )
361
366
body : str = Field (..., description = "The body of the PR" )
362
367
363
368
364
- class CreatePRTool (BaseTool ):
369
+ class GithubCreatePRTool (BaseTool ):
365
370
"""Tool for creating a PR."""
366
371
367
372
name : ClassVar [str ] = "create_pr"
368
373
description : ClassVar [str ] = "Create a PR for the current branch"
369
- args_schema : ClassVar [type [BaseModel ]] = CreatePRInput
374
+ args_schema : ClassVar [type [BaseModel ]] = GithubCreatePRInput
370
375
codebase : Codebase = Field (exclude = True )
371
376
372
377
def __init__ (self , codebase : Codebase ) -> None :
@@ -377,18 +382,18 @@ def _run(self, title: str, body: str) -> str:
377
382
return json .dumps (result , indent = 2 )
378
383
379
384
380
- class GetPRContentsInput (BaseModel ):
385
+ class GithubViewPRInput (BaseModel ):
381
386
"""Input for getting PR contents."""
382
387
383
388
pr_id : int = Field (..., description = "Number of the PR to get the contents for" )
384
389
385
390
386
- class GetPRcontentsTool (BaseTool ):
391
+ class GithubViewPRTool (BaseTool ):
387
392
"""Tool for getting PR data."""
388
393
389
- name : ClassVar [str ] = "get_pr_contents "
390
- description : ClassVar [str ] = "Get the diff and modified symbols of a PR along with the dependencies of the modified symbols "
391
- args_schema : ClassVar [type [BaseModel ]] = GetPRContentsInput
394
+ name : ClassVar [str ] = "view_pr "
395
+ description : ClassVar [str ] = "View the diff and associated context for a pull request "
396
+ args_schema : ClassVar [type [BaseModel ]] = GithubViewPRInput
392
397
codebase : Codebase = Field (exclude = True )
393
398
394
399
def __init__ (self , codebase : Codebase ) -> None :
@@ -399,19 +404,19 @@ def _run(self, pr_id: int) -> str:
399
404
return json .dumps (result , indent = 2 )
400
405
401
406
402
- class CreatePRCommentInput (BaseModel ):
407
+ class GithubCreatePRCommentInput (BaseModel ):
403
408
"""Input for creating a PR comment"""
404
409
405
410
pr_number : int = Field (..., description = "The PR number to comment on" )
406
411
body : str = Field (..., description = "The comment text" )
407
412
408
413
409
- class CreatePRCommentTool (BaseTool ):
414
+ class GithubCreatePRCommentTool (BaseTool ):
410
415
"""Tool for creating a general PR comment."""
411
416
412
417
name : ClassVar [str ] = "create_pr_comment"
413
418
description : ClassVar [str ] = "Create a general comment on a pull request"
414
- args_schema : ClassVar [type [BaseModel ]] = CreatePRCommentInput
419
+ args_schema : ClassVar [type [BaseModel ]] = GithubCreatePRCommentInput
415
420
codebase : Codebase = Field (exclude = True )
416
421
417
422
def __init__ (self , codebase : Codebase ) -> None :
@@ -422,7 +427,7 @@ def _run(self, pr_number: int, body: str) -> str:
422
427
return json .dumps (result , indent = 2 )
423
428
424
429
425
- class CreatePRReviewCommentInput (BaseModel ):
430
+ class GithubCreatePRReviewCommentInput (BaseModel ):
426
431
"""Input for creating an inline PR review comment"""
427
432
428
433
pr_number : int = Field (..., description = "The PR number to comment on" )
@@ -434,12 +439,12 @@ class CreatePRReviewCommentInput(BaseModel):
434
439
start_line : int | None = Field (None , description = "For multi-line comments, the starting line" )
435
440
436
441
437
- class CreatePRReviewCommentTool (BaseTool ):
442
+ class GithubCreatePRReviewCommentTool (BaseTool ):
438
443
"""Tool for creating inline PR review comments."""
439
444
440
445
name : ClassVar [str ] = "create_pr_review_comment"
441
446
description : ClassVar [str ] = "Create an inline review comment on a specific line in a pull request"
442
- args_schema : ClassVar [type [BaseModel ]] = CreatePRReviewCommentInput
447
+ args_schema : ClassVar [type [BaseModel ]] = GithubCreatePRReviewCommentInput
443
448
codebase : Codebase = Field (exclude = True )
444
449
445
450
def __init__ (self , codebase : Codebase ) -> None :
@@ -468,6 +473,11 @@ def _run(
468
473
return json .dumps (result , indent = 2 )
469
474
470
475
476
+ ########################################################################################################################
477
+ # LINEAR
478
+ ########################################################################################################################
479
+
480
+
471
481
class LinearGetIssueInput (BaseModel ):
472
482
"""Input for getting a Linear issue."""
473
483
@@ -597,6 +607,11 @@ def _run(self) -> str:
597
607
return json .dumps (result , indent = 2 )
598
608
599
609
610
+ ########################################################################################################################
611
+ # EXPORT
612
+ ########################################################################################################################
613
+
614
+
600
615
def get_workspace_tools (codebase : Codebase ) -> list ["BaseTool" ]:
601
616
"""Get all workspace tools initialized with a codebase.
602
617
@@ -609,12 +624,9 @@ def get_workspace_tools(codebase: Codebase) -> list["BaseTool"]:
609
624
return [
610
625
CommitTool (codebase ),
611
626
CreateFileTool (codebase ),
612
- CreatePRTool (codebase ),
613
- CreatePRCommentTool (codebase ),
614
- CreatePRReviewCommentTool (codebase ),
615
627
DeleteFileTool (codebase ),
616
628
EditFileTool (codebase ),
617
- GetPRcontentsTool (codebase ),
629
+ GithubViewPRTool (codebase ),
618
630
ListDirectoryTool (codebase ),
619
631
MoveSymbolTool (codebase ),
620
632
RenameFileTool (codebase ),
@@ -623,6 +635,12 @@ def get_workspace_tools(codebase: Codebase) -> list["BaseTool"]:
623
635
SemanticEditTool (codebase ),
624
636
SemanticSearchTool (codebase ),
625
637
ViewFileTool (codebase ),
638
+ # Github
639
+ GithubCreatePRTool (codebase ),
640
+ GithubCreatePRCommentTool (codebase ),
641
+ GithubCreatePRReviewCommentTool (codebase ),
642
+ GithubViewPRTool (codebase ),
643
+ # Linear
626
644
LinearGetIssueTool (codebase ),
627
645
LinearGetIssueCommentsTool (codebase ),
628
646
LinearCommentOnIssueTool (codebase ),
0 commit comments