Skip to content

Commit beac4b6

Browse files
committed
feat: mcp tools and resources v0
1 parent 9e8d677 commit beac4b6

File tree

6 files changed

+9986
-51
lines changed

6 files changed

+9986
-51
lines changed

src/codegen/cli/api/client.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
PR_LOOKUP_ENDPOINT,
1616
RUN_ENDPOINT,
1717
RUN_ON_PR_ENDPOINT,
18+
IMPROVE_ENDPOINT,
1819
)
1920
from codegen.cli.api.schemas import (
2021
AskExpertInput,
@@ -36,12 +37,15 @@
3637
RunCodemodOutput,
3738
RunOnPRInput,
3839
RunOnPRResponse,
40+
ImproveCodemodInput,
41+
ImproveCodemodResponse,
3942
)
4043
from codegen.cli.auth.session import CodegenSession
4144
from codegen.cli.codemod.convert import convert_to_ui
4245
from codegen.cli.env.global_env import global_env
4346
from codegen.cli.errors import InvalidTokenError, ServerError
4447
from codegen.cli.utils.codemods import Codemod
48+
from codegen.cli.utils.constants import ProgrammingLanguage
4549
from codegen.cli.utils.function_finder import DecoratedFunction
4650

4751
InputT = TypeVar("InputT", bound=BaseModel)
@@ -248,3 +252,13 @@ def lookup_pr(self, repo_full_name: str, github_pr_number: int) -> PRSchema:
248252
PRLookupInput(input=PRLookupInput.BasePRLookupInput(repo_full_name=repo_full_name, github_pr_number=github_pr_number)),
249253
PRLookupResponse,
250254
)
255+
256+
257+
def improve_codemod(self, codemod: str, task: str, concerns: list[str], context: dict[str, str], language: ProgrammingLanguage) -> ImproveCodemodResponse:
258+
"""Improve a codemod."""
259+
return self._make_request(
260+
"GET",
261+
IMPROVE_ENDPOINT,
262+
ImproveCodemodInput(input=ImproveCodemodInput.BaseImproveCodemodInput(codemod=codemod, task=task, concerns=concerns, context=context, language=language)),
263+
ImproveCodemodResponse
264+
)

src/codegen/cli/api/endpoints.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@
1010
RUN_ON_PR_ENDPOINT = f"https://{MODAL_PREFIX}--cli-run-on-pull-request.modal.run"
1111
PR_LOOKUP_ENDPOINT = f"https://{MODAL_PREFIX}--cli-pr-lookup.modal.run"
1212
CODEGEN_SYSTEM_PROMPT_URL = "https://gist.githubusercontent.com/jayhack/15681a2ceaccd726f19e6fdb3a44738b/raw/17c08054e3931b3b7fdf424458269c9e607541e8/codegen-system-prompt.txt"
13+
IMPROVE_ENDPOINT = "https://codegen-sh-develop-rpatel--cli-improve.modal.run"

src/codegen/cli/api/schemas.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,3 +234,22 @@ class RunOnPRResponse(BaseModel):
234234
codemod_id: int = Field(..., description="ID of the codemod")
235235
codemod_run_id: int = Field(..., description="ID of the codemod run")
236236
web_url: str = Field(..., description="URL to view the test results")
237+
238+
239+
###########################################################################
240+
# IMPROVE
241+
###########################################################################
242+
243+
class ImproveCodemodInput(BaseModel):
244+
class BaseImproveCodemodInput(BaseModel):
245+
codemod: str = Field(..., description="Source code of the codemod to improve")
246+
task: str = Field(..., description="Task to which the codemod should implement to solve")
247+
concerns: list[str] = Field(..., description="A list of issues that were discovered with the current codemod that need to be considered in the next iteration")
248+
context: dict[str, str] = Field(..., description="Additional context for the codemod this can be a list of files that are related, additional information about the task, etc.")
249+
language: ProgrammingLanguage = Field(..., description="Language of the codemod")
250+
251+
input: BaseImproveCodemodInput = Field(..., description="Input data for improvement")
252+
253+
class ImproveCodemodResponse(BaseModel):
254+
success: bool = Field(..., description="Whether the improvement was successful")
255+
codemod_source: str = Field(..., description="Source code of the improved codemod")

0 commit comments

Comments
 (0)