Skip to content

Commit 57fa810

Browse files
committed
fix: remove local install
1 parent f18f570 commit 57fa810

File tree

20 files changed

+1922
-343
lines changed

20 files changed

+1922
-343
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
2+
3+
from codegen.agents.code_agent import CodeAgent
4+
from codegen.extensions.github.types.events.pull_request import PullRequestLabeledEvent
5+
from codegen.extensions.langchain.tools import GithubCreatePRCommentTool, GithubCreatePRReviewCommentTool, GithubViewPRTool
6+
from codegen.sdk.core.codebase import Codebase
7+
8+
9+
def pr_review_agent(codebase: Codebase, event: PullRequestLabeledEvent) -> None:
10+
review_atention_message = f"CodegenBot is starting to review the PR please wait..."
11+
comment =codebase._op.create_pr_comment(event.number, review_atention_message)
12+
# Define tools first
13+
pr_tools = [
14+
GithubViewPRTool(codebase),
15+
GithubCreatePRCommentTool(codebase),
16+
GithubCreatePRReviewCommentTool(codebase),
17+
]
18+
19+
# Create agent with the defined tools
20+
agent = CodeAgent(codebase=codebase, tools=pr_tools)
21+
22+
# Using a prompt from SWE Bench
23+
prompt = f"""
24+
Hey CodegenBot!
25+
26+
Here's a SWE task for you. Please Review this pull request!
27+
{event.pull_request.url}
28+
Do not terminate until have reviewed the pull request and are satisfied with your review.
29+
30+
Review this Pull request like the señor ingenier you are
31+
be explicit about the changes, produce a short summary, and point out possible improvements where pressent dont be self congratulatory stick to the facts
32+
use the tools at your disposal to create propper pr reviews include code snippets if needed, and suggest improvements if feel its necesary
33+
"""
34+
# Run the agent
35+
result = agent.run(prompt)
36+
comment.delete()

codegen-examples/examples/codegen_app/app.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
########################################################################################################################
1717

1818
# Create the cg_app
19-
cg = CodegenApp(name="codegen-test", repos=["codegen-sh/Kevin-s-Adventure-Game"])
19+
cg = CodegenApp(name="codegen-test", repo="codegen-sh/Kevin-s-Adventure-Game")
2020

2121

2222
@cg.slack.event("app_mention")
@@ -26,7 +26,7 @@ async def handle_mention(event: SlackEvent):
2626

2727
# Codebase
2828
logger.info("[CODEBASE] Initializing codebase")
29-
codebase = cg.get_codebase("codegen-sh/Kevin-s-Adventure-Game")
29+
codebase = cg.get_codebase()
3030

3131
# Code Agent
3232
logger.info("[CODE_AGENT] Initializing code agent")
@@ -43,7 +43,7 @@ async def handle_mention(event: SlackEvent):
4343
def handle_pr(event: PullRequestLabeledEvent):
4444
logger.info("PR labeled")
4545
logger.info(f"PR head sha: {event.pull_request.head.sha}")
46-
codebase = cg.get_codebase("codegen-sh/Kevin-s-Adventure-Game")
46+
codebase = cg.get_codebase()
4747

4848
# =====[ Check out commit ]=====
4949
# Might require fetch?
@@ -62,7 +62,7 @@ def handle_pr(event: PullRequestLabeledEvent):
6262
@cg.linear.event("Issue")
6363
def handle_issue(event: LinearEvent):
6464
logger.info(f"Issue created: {event}")
65-
codebase = cg.get_codebase("codegen-sh/Kevin-s-Adventure-Game")
65+
codebase = cg.get_codebase()
6666
return {"message": "Linear Issue event", "num_files": len(codebase.files), "num_functions": len(codebase.functions)}
6767

6868

@@ -74,7 +74,7 @@ def handle_issue(event: LinearEvent):
7474

7575
# For deploying local package
7676
REPO_URL = "https://github.com/codegen-sh/codegen-sdk.git"
77-
COMMIT_ID = "26dafad2c319968e14b90806d42c6c7aaa627bb0"
77+
COMMIT_ID = "6a0e101718c247c01399c60b7abf301278a41786"
7878

7979
# Create the base image with dependencies
8080
base_image = (
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import logging
2+
from codegen.extensions.github.types.events.pull_request import PullRequestLabeledEvent
3+
from codegen.sdk.core.codebase import Codebase
4+
5+
logging.basicConfig(level=logging.INFO)
6+
logger = logging.getLogger(__name__)
7+
def pr_lint_dev_import_violations(codebase: Codebase, event: PullRequestLabeledEvent):
8+
9+
patch, commit_shas, modified_symbols = codebase.get_modified_symbols_in_pr(event.pull_request.number)
10+
modified_files = set(commit_shas.keys())
11+
12+
DIR_NAME = 'packages/next/src/client/components/react-dev-overlay'
13+
directory = codebase.get_directory(DIR_NAME)
14+
15+
# Initialize a list to store all violations
16+
violations = []
17+
18+
# Check if directory exists before proceeding
19+
if directory is not None and hasattr(directory, 'files'):
20+
for file in directory.files:
21+
for imp in file.inbound_imports:
22+
# Check if the import is from outside the directory and is in the modified files
23+
if imp.file not in directory and imp.file.filepath in modified_files:
24+
# Skip require statements
25+
if 'require' in imp.import_statement:
26+
continue
27+
violation = f'- Violation in `{file.filepath}`: Importing from `{imp.file.filepath}` ([link]({imp.github_url}))'
28+
violations.append(violation)
29+
logger.info(f"Found violation: {violation}")
30+
31+
# Only create a PR comment if violations are found
32+
if violations:
33+
review_attention_message = "## Dev Import Violations Found\n\n"
34+
review_attention_message += "The following files have imports that violate development overlay rules:\n\n"
35+
review_attention_message += "\n".join(violations)
36+
review_attention_message += "\n\nPlease ensure that development imports are not imported in production code."
37+
38+
# Create PR comment with the formatted message
39+
codebase._op.create_pr_comment(event.pull_request.number, review_attention_message)
40+
41+

codegen-examples/examples/codegen_app/modal_app.py

Lines changed: 0 additions & 131 deletions
This file was deleted.

0 commit comments

Comments
 (0)