Skip to content

Commit a1666d0

Browse files
Merge branch 'develop' into jmeza-cg-9949-run-generate-docs-generation-only-in-ci
2 parents 087bd18 + cac53b0 commit a1666d0

File tree

7 files changed

+328
-24
lines changed

7 files changed

+328
-24
lines changed
Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,38 @@
1-
name: Unit Tests
1+
name: Tests
22

33
on:
44
push:
55
branches:
66
- "develop"
7-
pull_request:
7+
pull_request_target:
88
types: [ opened, synchronize, reopened, labeled ]
99
branches:
1010
- "develop"
1111
workflow_dispatch:
1212

1313
jobs:
14+
access-check:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions-cool/check-user-permission@v2
18+
with:
19+
require: write
20+
username: ${{ github.triggering_actor }}
21+
error-if-missing: true
22+
1423
unit-tests:
24+
needs: access-check
1525
runs-on: ubuntu-latest-8
26+
environment: testing
1627
steps:
1728
- uses: actions/checkout@v4
1829
with:
1930
fetch-depth: 0
31+
ref: ${{ github.event.pull_request.head.sha }}
32+
2033
- name: Setup environment
2134
uses: ./.github/actions/setup-environment
35+
2236
- name: Run ATS and Tests
2337
uses: ./.github/actions/run-ats
2438
timeout-minutes: 15
@@ -30,9 +44,11 @@ jobs:
3044
codecov_flags: unit-tests
3145

3246
codemod-tests:
47+
needs: access-check
3348
# TODO: re-enable when this check is a develop required check
3449
if: false
3550
runs-on: ubuntu-latest-32
51+
environment: testing
3652
strategy:
3753
matrix:
3854
sync_graph: [ true, false ]
@@ -48,10 +64,15 @@ jobs:
4864
name: "Codemod tests ${{matrix.size}}: Sync Graph=${{matrix.sync_graph}}"
4965
steps:
5066
- uses: actions/checkout@v4
67+
with:
68+
ref: ${{ github.event.pull_request.head.sha }}
69+
5170
- name: Setup environment
5271
uses: ./.github/actions/setup-environment
72+
5373
- name: Cache oss-repos
5474
uses: ./.github/actions/setup-oss-repos
75+
5576
- name: Run ATS and Tests
5677
uses: ./.github/actions/run-ats
5778
timeout-minutes: 15
@@ -66,11 +87,15 @@ jobs:
6687
GITHUB_WORKSPACE: $GITHUB_WORKSPACE
6788

6889
parse-tests:
69-
runs-on: ubuntu-latest-32
90+
needs: access-check
7091
if: contains(github.event.pull_request.labels.*.name, 'parse-tests') || github.event_name == 'push' || github.event_name == 'workflow_dispatch'
71-
environment: parse-tests
92+
runs-on: ubuntu-latest-32
93+
environment: testing
7294
steps:
7395
- uses: actions/checkout@v4
96+
with:
97+
ref: ${{ github.event.pull_request.head.sha }}
98+
7499
- name: Setup environment
75100
uses: ./.github/actions/setup-environment
76101

@@ -91,10 +116,12 @@ jobs:
91116
-n auto \
92117
-o junit_suite_name="${{github.job}}" \
93118
tests/integration/codemod/test_parse.py
119+
94120
- uses: ./.github/actions/report
95121
with:
96122
flag: no-flag
97123
codecov_token: ${{ secrets.CODECOV_TOKEN }}
124+
98125
- name: Notify parse tests failure
99126
uses: slackapi/slack-github-action@v2.0.0
100127
if: failure() && github.event_name == 'push' && false
@@ -132,11 +159,17 @@ jobs:
132159
}
133160
134161
integration-tests:
162+
needs: access-check
135163
runs-on: ubuntu-latest-16
164+
environment: testing
136165
steps:
137166
- uses: actions/checkout@v4
167+
with:
168+
ref: ${{ github.event.pull_request.head.sha }}
169+
138170
- name: Setup environment
139171
uses: ./.github/actions/setup-environment
172+
140173
- name: Test with pytest
141174
timeout-minutes: 5
142175
env:
@@ -147,6 +180,7 @@ jobs:
147180
-n auto \
148181
-o junit_suite_name="${{github.job}}" \
149182
tests/integration/codegen
183+
150184
- uses: ./.github/actions/report
151185
with:
152186
flag: integration-tests

src/codegen/configs/models/codebase.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ def __init__(self, prefix: str = "CODEBASE", *args, **kwargs) -> None:
1515
full_range_index: bool = False
1616
ignore_process_errors: bool = True
1717
disable_graph: bool = False
18+
disable_file_parse: bool = False
1819
generics: bool = True
1920
import_resolution_overrides: dict[str, str] = Field(default_factory=lambda: {})
2021
ts_dependency_manager: bool = False

src/codegen/extensions/langchain/agent.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
from .tools import (
1414
CreateFileTool,
1515
DeleteFileTool,
16-
EditFileTool,
1716
ListDirectoryTool,
1817
MoveSymbolTool,
18+
RelaceEditTool,
1919
RenameFileTool,
2020
ReplacementEditTool,
2121
RevealSymbolTool,
2222
SearchTool,
23-
SemanticEditTool,
23+
# SemanticEditTool,
2424
ViewFileTool,
2525
)
2626

@@ -62,14 +62,15 @@ def create_codebase_agent(
6262
ViewFileTool(codebase),
6363
ListDirectoryTool(codebase),
6464
SearchTool(codebase),
65-
EditFileTool(codebase),
65+
# EditFileTool(codebase),
6666
CreateFileTool(codebase),
6767
DeleteFileTool(codebase),
6868
RenameFileTool(codebase),
6969
MoveSymbolTool(codebase),
7070
RevealSymbolTool(codebase),
71-
SemanticEditTool(codebase),
71+
# SemanticEditTool(codebase),
7272
ReplacementEditTool(codebase),
73+
RelaceEditTool(codebase),
7374
# SemanticSearchTool(codebase),
7475
# =====[ Github Integration ]=====
7576
# Enable Github integration

src/codegen/extensions/langchain/tools.py

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
linear_search_issues_tool,
1717
)
1818
from codegen.extensions.tools.link_annotation import add_links_to_message
19+
from codegen.extensions.tools.relace_edit import relace_edit
1920
from codegen.extensions.tools.replacement_edit import replacement_edit
2021
from codegen.extensions.tools.reveal_symbol import reveal_symbol
2122
from codegen.extensions.tools.search import search
@@ -37,6 +38,7 @@
3738
view_file,
3839
view_pr,
3940
)
41+
from ..tools.relace_edit_prompts import RELACE_EDIT_PROMPT
4042
from ..tools.semantic_edit_prompts import FILE_EDIT_PROMPT
4143

4244

@@ -729,9 +731,10 @@ def get_workspace_tools(codebase: Codebase) -> list["BaseTool"]:
729731
RevealSymbolTool(codebase),
730732
RunBashCommandTool(), # Note: This tool doesn't need the codebase
731733
SearchTool(codebase),
732-
SemanticEditTool(codebase),
734+
# SemanticEditTool(codebase),
733735
SemanticSearchTool(codebase),
734736
ViewFileTool(codebase),
737+
RelaceEditTool(codebase),
735738
# Github
736739
GithubCreatePRTool(codebase),
737740
GithubCreatePRCommentTool(codebase),
@@ -788,3 +791,47 @@ def _run(
788791
count=count,
789792
)
790793
return result.render()
794+
795+
796+
# Brief description for the Relace Edit tool
797+
_RELACE_EDIT_BRIEF = """Tool for file editing using the Relace Instant Apply API.
798+
This high-speed code generation engine optimizes for real-time performance at 2000 tokens/second.
799+
800+
Provide an edit snippet that describes the changes you want to make, with helpful comments to indicate unchanged sections, like so:
801+
```
802+
// ... keep existing imports ...
803+
804+
// Add new function
805+
function calculateDiscount(price, discountPercent) {
806+
return price * (discountPercent / 100);
807+
}
808+
809+
// ... keep existing code ...
810+
```
811+
812+
The API will merge your edit snippet with the existing code to produce the final result.
813+
The API key will be automatically retrieved from the RELACE_API environment variable.
814+
"""
815+
816+
817+
class RelaceEditInput(BaseModel):
818+
"""Input for Relace editing."""
819+
820+
filepath: str = Field(..., description="Path of the file relative to workspace root")
821+
edit_snippet: str = Field(..., description=RELACE_EDIT_PROMPT)
822+
823+
824+
class RelaceEditTool(BaseTool):
825+
"""Tool for editing files using the Relace Instant Apply API."""
826+
827+
name: ClassVar[str] = "relace_edit"
828+
description: ClassVar[str] = _RELACE_EDIT_BRIEF
829+
args_schema: ClassVar[type[BaseModel]] = RelaceEditInput
830+
codebase: Codebase = Field(exclude=True)
831+
832+
def __init__(self, codebase: Codebase) -> None:
833+
super().__init__(codebase=codebase)
834+
835+
def _run(self, filepath: str, edit_snippet: str) -> str:
836+
result = relace_edit(self.codebase, filepath, edit_snippet)
837+
return result.render()

0 commit comments

Comments
 (0)