Skip to content

Commit 1248eb2

Browse files
rushilpatel0github-actions[bot]
authored andcommitted
Automated pre-commit update
1 parent 69311d9 commit 1248eb2

File tree

6 files changed

+34
-23
lines changed

6 files changed

+34
-23
lines changed

src/codegen/cli/api/client.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
DOCS_ENDPOINT,
1212
EXPERT_ENDPOINT,
1313
IDENTIFY_ENDPOINT,
14+
IMPROVE_ENDPOINT,
1415
LOOKUP_ENDPOINT,
1516
PR_LOOKUP_ENDPOINT,
1617
RUN_ENDPOINT,
1718
RUN_ON_PR_ENDPOINT,
18-
IMPROVE_ENDPOINT,
1919
)
2020
from codegen.cli.api.schemas import (
2121
AskExpertInput,
@@ -28,6 +28,8 @@
2828
DocsInput,
2929
DocsResponse,
3030
IdentifyResponse,
31+
ImproveCodemodInput,
32+
ImproveCodemodResponse,
3133
LookupInput,
3234
LookupOutput,
3335
PRLookupInput,
@@ -37,8 +39,6 @@
3739
RunCodemodOutput,
3840
RunOnPRInput,
3941
RunOnPRResponse,
40-
ImproveCodemodInput,
41-
ImproveCodemodResponse,
4242
)
4343
from codegen.cli.auth.session import CodegenSession
4444
from codegen.cli.codemod.convert import convert_to_ui
@@ -253,12 +253,11 @@ def lookup_pr(self, repo_full_name: str, github_pr_number: int) -> PRSchema:
253253
PRLookupResponse,
254254
)
255255

256-
257256
def improve_codemod(self, codemod: str, task: str, concerns: list[str], context: dict[str, str], language: ProgrammingLanguage) -> ImproveCodemodResponse:
258257
"""Improve a codemod."""
259258
return self._make_request(
260259
"GET",
261260
IMPROVE_ENDPOINT,
262261
ImproveCodemodInput(input=ImproveCodemodInput.BaseImproveCodemodInput(codemod=codemod, task=task, concerns=concerns, context=context, language=language)),
263-
ImproveCodemodResponse
264-
)
262+
ImproveCodemodResponse,
263+
)

src/codegen/cli/api/endpoints.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +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 = f"https://{MODAL_PREFIX}--cli-improve.modal.run"
13+
IMPROVE_ENDPOINT = f"https://{MODAL_PREFIX}--cli-improve.modal.run"

src/codegen/cli/api/schemas.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ class RunOnPRResponse(BaseModel):
240240
# IMPROVE
241241
###########################################################################
242242

243+
243244
class ImproveCodemodInput(BaseModel):
244245
class BaseImproveCodemodInput(BaseModel):
245246
codemod: str = Field(..., description="Source code of the codemod to improve")
@@ -250,6 +251,7 @@ class BaseImproveCodemodInput(BaseModel):
250251

251252
input: BaseImproveCodemodInput = Field(..., description="Input data for improvement")
252253

254+
253255
class ImproveCodemodResponse(BaseModel):
254256
success: bool = Field(..., description="Whether the improvement was successful")
255257
codemod_source: str = Field(..., description="Source code of the improved codemod")

src/codegen/cli/mcp/README.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ A MCP server implementation that provides tools and resources for using and work
88

99
## Usage
1010

11-
Most AI Agents that support MCP will have some way to configure the server startup.
11+
Most AI Agents that support MCP will have some way to configure the server startup.
12+
1213
### Cline
14+
1315
Add this to your `cline_mcp_settings.json` file to get started:
16+
1417
```
1518
{
1619
"mcpServers": {
@@ -35,8 +38,3 @@ Name: codegen-mcp
3538
Type: Command
3639
Command: uv --directory <path to codegen installation>/codegen-sdk/src/codegen/cli/mcp run server.py
3740
```
38-
39-
40-
41-
42-

src/codegen/cli/mcp/resources/system_prompt.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2389,7 +2389,7 @@ def validate_data(data: dict) -> bool:
23892389
results = function.find_string_literals(["error"], fuzzy_match=True)
23902390
23912391
# Search with regex
2392-
matches = function.search(r"data\['[^']*'\]") # Find dict access
2392+
matches = function.search(r"data\\['[^']*'\\]") # Find dict access
23932393
matches = function.search("TODO:", include_comments=True)
23942394
23952395
# Find specific patterns
@@ -6327,9 +6327,9 @@ def migrate_api_v1_to_v2(codebase):
63276327
4. **Document Changes**:
63286328
```python
63296329
# Add clear deprecation messages
6330-
old_api.add_decorator(\'\'\@deprecated(
6330+
old_api.add_decorator(\'\'\\@deprecated(
63316331
"Use new_api() instead. Migration guide: docs/migrations/v2.md"
6332-
)\'\'\)
6332+
)\'\'\\)
63336333
```
63346334
63356335
<Note>
@@ -9909,4 +9909,4 @@ def list_users(request: Request):
99099909
- [Codegen API Reference](/api-reference)
99109910
- [Moving Symbols Guide](/building-with-codegen/moving-symbols)
99119911
- [Dependencies and Usages](/building-with-codegen/dependencies-and-usages)
9912-
'''
9912+
'''

src/codegen/cli/mcp/server.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
from typing import Annotated, Any
2-
from codegen.cli.mcp.resources.system_setup_instructions import SETUP_INSTRUCTIONS
3-
from mcp.server.fastmcp import FastMCP, Context
2+
3+
from mcp.server.fastmcp import Context, FastMCP
4+
45
from codegen.cli.api.client import RestAPI
56
from codegen.cli.mcp.resources.system_prompt import SYSTEM_PROMPT
7+
from codegen.cli.mcp.resources.system_setup_instructions import SETUP_INSTRUCTIONS
68
from codegen.cli.utils.constants import ProgrammingLanguage
9+
710
# Initialize FastMCP server
811

912
mcp = FastMCP("codegen-mcp", instructions="MCP server for the Codegen SDK. Use the tools and resources to setup codegen in your environment and to create and improve your Codegen Codemods.")
1013

1114
# ----- RESOURCES -----
1215

16+
1317
@mcp.resource("system://agent_prompt", description="Provides all the information the agent needs to know about Codegen SDK", mime_type="text/plain")
1418
def get_docs() -> str:
1519
"""Get the sdk doc url."""
@@ -31,25 +35,33 @@ def get_service_config() -> dict[str, Any]:
3135
"description": "The MCP server for assisting with creating/writing/improving codegen codemods.",
3236
}
3337

38+
3439
# ----- TOOLS -----
3540

41+
3642
@mcp.tool()
37-
def generate_codemod(title: Annotated[str, "The title of the codemod (hyphenated)"], task: Annotated[str, "The task to which the codemod should implement to solve"], codebase_path: Annotated[str, "The absolute path to the codebase directory"], ctx: Context) -> str:
43+
def generate_codemod(
44+
title: Annotated[str, "The title of the codemod (hyphenated)"],
45+
task: Annotated[str, "The task to which the codemod should implement to solve"],
46+
codebase_path: Annotated[str, "The absolute path to the codebase directory"],
47+
ctx: Context,
48+
) -> str:
3849
"""Generate a codemod for the given task and codebase."""
3950
return f'''
4051
Use the codegen cli to generate a codemod. If you need to intall the cli the command to do so is `uv tool install codegen`. Once installed, run the following command to generate the codemod:
41-
52+
4253
codegen create {title} -d "{task}"
4354
'''
4455

56+
4557
@mcp.tool()
4658
def improve_codemod(
4759
codemod_source: Annotated[str, "The source code of the codemod to improve"],
4860
task: Annotated[str, "The task to which the codemod should implement to solve"],
4961
concerns: Annotated[list[str], "A list of issues that were discovered with the current codemod that need to be considered in the next iteration"],
5062
context: Annotated[dict[str, Any], "Additional context for the codemod this can be a list of files that are related, additional information about the task, etc."],
5163
language: Annotated[ProgrammingLanguage, "The language of the codebase, i.e ALL CAPS PYTHON or TYPESCRIPT "],
52-
ctx: Context
64+
ctx: Context,
5365
) -> str:
5466
"""Improve the codemod."""
5567
try:
@@ -63,4 +75,4 @@ def improve_codemod(
6375
if __name__ == "__main__":
6476
# Initialize and run the server
6577
print("Starting codegen server...")
66-
mcp.run(transport='stdio')
78+
mcp.run(transport="stdio")

0 commit comments

Comments
 (0)