77from pydantic import BaseModel , Field
88
99from codegen import Codebase
10+ from codegen .extensions .linear .linear_client import LinearClient
11+ from codegen .extensions .tools .linear_tools import (
12+ linear_comment_on_issue_tool ,
13+ linear_get_issue_comments_tool ,
14+ linear_get_issue_tool ,
15+ )
1016
1117from ..tools import (
1218 commit ,
@@ -184,7 +190,10 @@ class RevealSymbolInput(BaseModel):
184190
185191 symbol_name : str = Field (..., description = "Name of the symbol to analyze" )
186192 degree : int = Field (default = 1 , description = "How many degrees of separation to traverse" )
187- max_tokens : Optional [int ] = Field (default = None , description = "Optional maximum number of tokens for all source code combined" )
193+ max_tokens : Optional [int ] = Field (
194+ default = None ,
195+ description = "Optional maximum number of tokens for all source code combined" ,
196+ )
188197 collect_dependencies : bool = Field (default = True , description = "Whether to collect dependencies" )
189198 collect_usages : bool = Field (default = True , description = "Whether to collect usages" )
190199
@@ -281,7 +290,10 @@ class MoveSymbolInput(BaseModel):
281290 source_file : str = Field (..., description = "Path to the file containing the symbol" )
282291 symbol_name : str = Field (..., description = "Name of the symbol to move" )
283292 target_file : str = Field (..., description = "Path to the destination file" )
284- strategy : Literal ["update_all_imports" , "add_back_edge" ] = Field (default = "update_all_imports" , description = "Strategy for handling imports: 'update_all_imports' (default) or 'add_back_edge'" )
293+ strategy : Literal ["update_all_imports" , "add_back_edge" ] = Field (
294+ default = "update_all_imports" ,
295+ description = "Strategy for handling imports: 'update_all_imports' (default) or 'add_back_edge'" ,
296+ )
285297 include_dependencies : bool = Field (default = True , description = "Whether to move dependencies along with the symbol" )
286298
287299
@@ -453,6 +465,73 @@ def _run(
453465 return json .dumps (result , indent = 2 )
454466
455467
468+ class LinearGetIssueInput (BaseModel ):
469+ """Input for getting a Linear issue."""
470+
471+ issue_id : str = Field (..., description = "ID of the Linear issue to retrieve" )
472+
473+
474+ class LinearGetIssueTool (BaseTool ):
475+ """Tool for getting Linear issue details."""
476+
477+ name : ClassVar [str ] = "linear_get_issue"
478+ description : ClassVar [str ] = "Get details of a Linear issue by its ID"
479+ args_schema : ClassVar [type [BaseModel ]] = LinearGetIssueInput
480+ client : LinearClient = Field (exclude = True )
481+
482+ def __init__ (self , client : LinearClient ) -> None :
483+ super ().__init__ (client = client )
484+
485+ def _run (self , issue_id : str ) -> str :
486+ result = linear_get_issue_tool (self .client , issue_id )
487+ return json .dumps (result , indent = 2 )
488+
489+
490+ class LinearGetIssueCommentsInput (BaseModel ):
491+ """Input for getting Linear issue comments."""
492+
493+ issue_id : str = Field (..., description = "ID of the Linear issue to get comments for" )
494+
495+
496+ class LinearGetIssueCommentsTool (BaseTool ):
497+ """Tool for getting Linear issue comments."""
498+
499+ name : ClassVar [str ] = "linear_get_issue_comments"
500+ description : ClassVar [str ] = "Get all comments on a Linear issue"
501+ args_schema : ClassVar [type [BaseModel ]] = LinearGetIssueCommentsInput
502+ client : LinearClient = Field (exclude = True )
503+
504+ def __init__ (self , client : LinearClient ) -> None :
505+ super ().__init__ (client = client )
506+
507+ def _run (self , issue_id : str ) -> str :
508+ result = linear_get_issue_comments_tool (self .client , issue_id )
509+ return json .dumps (result , indent = 2 )
510+
511+
512+ class LinearCommentOnIssueInput (BaseModel ):
513+ """Input for commenting on a Linear issue."""
514+
515+ issue_id : str = Field (..., description = "ID of the Linear issue to comment on" )
516+ body : str = Field (..., description = "The comment text" )
517+
518+
519+ class LinearCommentOnIssueTool (BaseTool ):
520+ """Tool for commenting on Linear issues."""
521+
522+ name : ClassVar [str ] = "linear_comment_on_issue"
523+ description : ClassVar [str ] = "Add a comment to a Linear issue"
524+ args_schema : ClassVar [type [BaseModel ]] = LinearCommentOnIssueInput
525+ client : LinearClient = Field (exclude = True )
526+
527+ def __init__ (self , client : LinearClient ) -> None :
528+ super ().__init__ (client = client )
529+
530+ def _run (self , issue_id : str , body : str ) -> str :
531+ result = linear_comment_on_issue_tool (self .client , issue_id , body )
532+ return json .dumps (result , indent = 2 )
533+
534+
456535def get_workspace_tools (codebase : Codebase ) -> list ["BaseTool" ]:
457536 """Get all workspace tools initialized with a codebase.
458537
@@ -479,4 +558,7 @@ def get_workspace_tools(codebase: Codebase) -> list["BaseTool"]:
479558 SemanticEditTool (codebase ),
480559 SemanticSearchTool (codebase ),
481560 ViewFileTool (codebase ),
561+ LinearGetIssueTool (codebase ),
562+ LinearGetIssueCommentsTool (codebase ),
563+ LinearCommentOnIssueTool (codebase ),
482564 ]
0 commit comments