Skip to content

Commit 79ee33d

Browse files
authored
Merge pull request #1 from augmentcode/add_ci_and_pre-commit_hooks
Add ci and pre commit hooks
2 parents 091b6e6 + d2a9f70 commit 79ee33d

34 files changed

+705
-412
lines changed

.github/workflows/ci.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: CI - pre-commit & run tests
2+
3+
on:
4+
pull_request:
5+
branches: [ main ]
6+
7+
jobs:
8+
lint-and-test:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v3
14+
15+
- name: Set up Python
16+
uses: actions/setup-python@v4
17+
with:
18+
python-version: '3.11.7' # or your preferred version
19+
20+
- name: Install dependencies
21+
run: |
22+
./setup.sh
23+
24+
- name: Run pre-commit
25+
run: uv run pre-commit run --all-files
26+
27+
- name: Run pytest
28+
run: uv run pytest

.pre-commit-config.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.5.0 # Use the latest stable version
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-yaml
8+
- id: check-symlinks
9+
- id: check-added-large-files
10+
- id: check-case-conflict
11+
- id: check-json
12+
13+
- repo: https://github.com/astral-sh/ruff-pre-commit
14+
# Ruff version.
15+
rev: v0.11.2
16+
hooks:
17+
# Run the linter.
18+
- id: ruff
19+
args: [ --fix ]
20+
# Run the formatter.
21+
- id: ruff-format
22+
# manual stages to auto-correct
23+
- id: ruff
24+
args: [ --fix ]
25+
stages: [manual]
26+
- id: ruff-format
27+
stages: [manual]
28+
29+
- repo: https://github.com/Yelp/detect-secrets
30+
rev: v1.5.0
31+
hooks:
32+
- id: detect-secrets
33+
args: ['--baseline', '.secrets.baseline', 'audit']
34+
35+
- repo: local
36+
hooks:
37+
- id: pyright
38+
name: pyright
39+
entry: pyright
40+
language: system
41+
types: [python]
42+
args: [--stats, -p, pyrightconfig.ci.json]

.secrets.baseline

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
{
2+
"version": "1.5.0",
3+
"plugins_used": [
4+
{
5+
"name": "ArtifactoryDetector"
6+
},
7+
{
8+
"name": "AWSKeyDetector"
9+
},
10+
{
11+
"name": "AzureStorageKeyDetector"
12+
},
13+
{
14+
"name": "Base64HighEntropyString",
15+
"limit": 4.5
16+
},
17+
{
18+
"name": "BasicAuthDetector"
19+
},
20+
{
21+
"name": "CloudantDetector"
22+
},
23+
{
24+
"name": "DiscordBotTokenDetector"
25+
},
26+
{
27+
"name": "GitHubTokenDetector"
28+
},
29+
{
30+
"name": "GitLabTokenDetector"
31+
},
32+
{
33+
"name": "HexHighEntropyString",
34+
"limit": 3.0
35+
},
36+
{
37+
"name": "IbmCloudIamDetector"
38+
},
39+
{
40+
"name": "IbmCosHmacDetector"
41+
},
42+
{
43+
"name": "IPPublicDetector"
44+
},
45+
{
46+
"name": "JwtTokenDetector"
47+
},
48+
{
49+
"name": "KeywordDetector",
50+
"keyword_exclude": ""
51+
},
52+
{
53+
"name": "MailchimpDetector"
54+
},
55+
{
56+
"name": "NpmDetector"
57+
},
58+
{
59+
"name": "OpenAIDetector"
60+
},
61+
{
62+
"name": "PrivateKeyDetector"
63+
},
64+
{
65+
"name": "PypiTokenDetector"
66+
},
67+
{
68+
"name": "SendGridDetector"
69+
},
70+
{
71+
"name": "SlackDetector"
72+
},
73+
{
74+
"name": "SoftlayerDetector"
75+
},
76+
{
77+
"name": "SquareOAuthDetector"
78+
},
79+
{
80+
"name": "StripeDetector"
81+
},
82+
{
83+
"name": "TelegramBotTokenDetector"
84+
},
85+
{
86+
"name": "TwilioKeyDetector"
87+
}
88+
],
89+
"filters_used": [
90+
{
91+
"path": "detect_secrets.filters.allowlist.is_line_allowlisted"
92+
},
93+
{
94+
"path": "detect_secrets.filters.common.is_ignored_due_to_verification_policies",
95+
"min_level": 2
96+
},
97+
{
98+
"path": "detect_secrets.filters.heuristic.is_indirect_reference"
99+
},
100+
{
101+
"path": "detect_secrets.filters.heuristic.is_likely_id_string"
102+
},
103+
{
104+
"path": "detect_secrets.filters.heuristic.is_lock_file"
105+
},
106+
{
107+
"path": "detect_secrets.filters.heuristic.is_not_alphanumeric_string"
108+
},
109+
{
110+
"path": "detect_secrets.filters.heuristic.is_potential_uuid"
111+
},
112+
{
113+
"path": "detect_secrets.filters.heuristic.is_prefixed_with_dollar_sign"
114+
},
115+
{
116+
"path": "detect_secrets.filters.heuristic.is_sequential_string"
117+
},
118+
{
119+
"path": "detect_secrets.filters.heuristic.is_swagger_file"
120+
},
121+
{
122+
"path": "detect_secrets.filters.heuristic.is_templated_secret"
123+
}
124+
],
125+
"results": {
126+
"setup.sh": [
127+
{
128+
"type": "Hex High Entropy String",
129+
"filename": "setup.sh",
130+
"hashed_secret": "7431e16af96558909e41438950a6ffe7ee811465",
131+
"is_verified": false,
132+
"line_number": 31
133+
}
134+
]
135+
},
136+
"generated_at": "2025-03-31T20:57:53Z"
137+
}

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ licensed under the MIT License. The original code has been modified.
3030
Original copyright:
3131
© 2024 Anthropic, PBC
3232

33-
Original license: https://github.com/modelcontextprotocol/servers/blob/main/LICENSE
33+
Original license: https://github.com/modelcontextprotocol/servers/blob/main/LICENSE

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ You can increase `--num-examples` and `--num-candidate-solutions` to run on more
120120

121121
### Running on more examples.
122122

123-
There are 500 examples total in SWE-bench Verified. Note that this can take awhile, so there are a few levels of parallelism this repository supports.
123+
There are 500 examples total in SWE-bench Verified. Note that this can take awhile, so there are a few levels of parallelism this repository supports.
124124
- Firstly, we suggest running 8 processes. This is the `--num-processes` flag. Beyond this, Docker hits issues.
125125
- Secondly, we support a notion of breaking up the dataset into shards. This is the `--shard-ct` and `--shard-id` flags. This makes it relatively easy to split up the work across multiple machines, which circumnvents the issues with scaling Docker byeond 8 processes.
126126

@@ -166,7 +166,7 @@ python majority_vote_ensembler.py example_ensembler_data.jsonl --output_path exa
166166

167167
#### Input Format
168168

169-
The input JSONL file should contain a list of problem objects, each with the following structure:
169+
The input JSONL file should contain a list of problem objects, each with the following structure. The `diffs` are the candidate solutions generated by the agent. The `eval_outcomes` are the results of running the eval harness on each candidate solution, where the index corresponds to the index in the `diffs` array.
170170

171171
```json
172172
{

cli.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
from rich.panel import Panel
1717
from prompt_toolkit import prompt
1818
from prompt_toolkit.history import InMemoryHistory
19-
from termcolor import colored
2019

2120
from tools.agent import Agent
2221
from utils.workspace_manager import WorkspaceManager
@@ -26,6 +25,7 @@
2625
MAX_OUTPUT_TOKENS_PER_TURN = 32768
2726
MAX_TURNS = 200
2827

28+
2929
def main():
3030
"""Main entry point for the CLI."""
3131
# Parse command-line arguments
@@ -84,7 +84,7 @@ def main():
8484
if not args.minimize_stdout_logs:
8585
logger_for_agent_logs.addHandler(logging.StreamHandler())
8686
else:
87-
logger_for_agent_logs.propagate = False
87+
logger_for_agent_logs.propagate = False
8888

8989
# Check if ANTHROPIC_API_KEY is set
9090
if "ANTHROPIC_API_KEY" not in os.environ:
@@ -108,7 +108,9 @@ def main():
108108
)
109109
)
110110
else:
111-
logger_for_agent_logs.info("Agent CLI started. Waiting for user input. Press Ctrl+C to exit. Type 'exit' or 'quit' to end the session.")
111+
logger_for_agent_logs.info(
112+
"Agent CLI started. Waiting for user input. Press Ctrl+C to exit. Type 'exit' or 'quit' to end the session."
113+
)
112114

113115
# Initialize LLM client
114116
client = get_client(
@@ -119,7 +121,9 @@ def main():
119121

120122
# Initialize workspace manager
121123
workspace_path = Path(args.workspace).resolve()
122-
workspace_manager = WorkspaceManager(root=workspace_path, container_workspace=args.use_container_workspace)
124+
workspace_manager = WorkspaceManager(
125+
root=workspace_path, container_workspace=args.use_container_workspace
126+
)
123127

124128
# Initialize agent
125129
agent = Agent(
@@ -135,8 +139,12 @@ def main():
135139

136140
if args.problem_statement is not None:
137141
instruction = INSTRUCTION_PROMPT.format(
138-
location=workspace_path if args.use_container_workspace is None else args.use_container_workspace,
139-
pr_description=args.problem_statement
142+
location=(
143+
workspace_path
144+
if args.use_container_workspace is None
145+
else args.use_container_workspace
146+
),
147+
pr_description=args.problem_statement,
140148
)
141149
else:
142150
instruction = None
@@ -157,7 +165,9 @@ def main():
157165
break
158166
else:
159167
user_input = instruction
160-
logger_for_agent_logs.info(f"User instruction:\n{user_input}\n-------------")
168+
logger_for_agent_logs.info(
169+
f"User instruction:\n{user_input}\n-------------"
170+
)
161171

162172
# Run the agent with the user input
163173
logger_for_agent_logs.info("\nAgent is thinking...")
@@ -167,7 +177,7 @@ def main():
167177
except Exception as e:
168178
logger_for_agent_logs.info(f"Error: {str(e)}")
169179

170-
logger_for_agent_logs.info("\n" + '-' * 40 + "\n")
180+
logger_for_agent_logs.info("\n" + "-" * 40 + "\n")
171181

172182
if instruction is not None:
173183
break
@@ -179,4 +189,4 @@ def main():
179189

180190

181191
if __name__ == "__main__":
182-
main()
192+
main()

example_ensembler_results.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@
2323
"selected_diff": "@@ -45,3 +45,12 @@ def is_palindrome(text):\n cleaned_text = ''.join(c.lower() for c in text if c.isalnum())\n return cleaned_text == cleaned_text[::-1]\n \n+def is_valid_email(email):\n+ \"\"\"\n+ Check if a string is a valid email address.\n+ \"\"\"\n+ import re\n+ \n+ # Simple regex pattern for email validation\n+ pattern = r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$'\n+ return bool(re.match(pattern, email))\n",
2424
"is_eval_success": true
2525
}
26-
]
26+
]

0 commit comments

Comments
 (0)