repolaunch 1.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- repolaunch-1.4.0/LICENSE +21 -0
- repolaunch-1.4.0/PKG-INFO +111 -0
- repolaunch-1.4.0/README.md +84 -0
- repolaunch-1.4.0/launch/__init__.py +8 -0
- repolaunch-1.4.0/launch/agent/__init__.py +0 -0
- repolaunch-1.4.0/launch/agent/action_parser.py +29 -0
- repolaunch-1.4.0/launch/agent/locate.py +136 -0
- repolaunch-1.4.0/launch/agent/organize/__init__.py +0 -0
- repolaunch-1.4.0/launch/agent/organize/parselog.py +341 -0
- repolaunch-1.4.0/launch/agent/organize/rebuild.py +352 -0
- repolaunch-1.4.0/launch/agent/organize/save.py +152 -0
- repolaunch-1.4.0/launch/agent/organize/testall.py +502 -0
- repolaunch-1.4.0/launch/agent/organize/testone.py +283 -0
- repolaunch-1.4.0/launch/agent/prompt.py +43 -0
- repolaunch-1.4.0/launch/agent/setup/__init__.py +0 -0
- repolaunch-1.4.0/launch/agent/setup/base_image.py +88 -0
- repolaunch-1.4.0/launch/agent/setup/save.py +115 -0
- repolaunch-1.4.0/launch/agent/setup/setup.py +326 -0
- repolaunch-1.4.0/launch/agent/setup/verify.py +219 -0
- repolaunch-1.4.0/launch/agent/state.py +209 -0
- repolaunch-1.4.0/launch/api.py +66 -0
- repolaunch-1.4.0/launch/core/entry.py +97 -0
- repolaunch-1.4.0/launch/core/platforms/__init__.py +0 -0
- repolaunch-1.4.0/launch/core/platforms/android.py +146 -0
- repolaunch-1.4.0/launch/core/platforms/base.py +324 -0
- repolaunch-1.4.0/launch/core/platforms/linux.py +358 -0
- repolaunch-1.4.0/launch/core/platforms/windows.py +310 -0
- repolaunch-1.4.0/launch/core/runtime.py +84 -0
- repolaunch-1.4.0/launch/core/workflow.py +154 -0
- repolaunch-1.4.0/launch/run.py +376 -0
- repolaunch-1.4.0/launch/scripts/__init__.py +0 -0
- repolaunch-1.4.0/launch/scripts/adjacent_commit_run.py +522 -0
- repolaunch-1.4.0/launch/scripts/clear_failed_instance.py +34 -0
- repolaunch-1.4.0/launch/scripts/clear_image.py +26 -0
- repolaunch-1.4.0/launch/scripts/collect.py +66 -0
- repolaunch-1.4.0/launch/scripts/gen_dockerfile.py +228 -0
- repolaunch-1.4.0/launch/scripts/parser.py +52 -0
- repolaunch-1.4.0/launch/scripts/upload_docker.py +94 -0
- repolaunch-1.4.0/launch/utilities/__init__.py +0 -0
- repolaunch-1.4.0/launch/utilities/config.py +85 -0
- repolaunch-1.4.0/launch/utilities/dockerfiles/windows_server_c_cpp/ltsc2025_cmake_ninja_vsbuildtools_cl_msbuild/Dockerfile +15 -0
- repolaunch-1.4.0/launch/utilities/dockerfiles/windows_server_c_cpp/ltsc_2019_cmake_ninja_only/Dockerfile +27 -0
- repolaunch-1.4.0/launch/utilities/dockerfiles/windows_server_c_cpp/ltsc_2022_cmake_ninja_only/Dockerfile +27 -0
- repolaunch-1.4.0/launch/utilities/dockerfiles/windows_server_c_cpp/ltsc_2025_vsbuildtools/Dockerfile +28 -0
- repolaunch-1.4.0/launch/utilities/dockerfiles/windows_server_nvm/Dockerfile +19 -0
- repolaunch-1.4.0/launch/utilities/dockerfiles/windows_server_rust/170/Dockerfile +23 -0
- repolaunch-1.4.0/launch/utilities/dockerfiles/windows_server_rust/175/Dockerfile +23 -0
- repolaunch-1.4.0/launch/utilities/dockerfiles/windows_server_rust/180/Dockerfile +23 -0
- repolaunch-1.4.0/launch/utilities/dockerfiles/windows_server_rust/185/Dockerfile +23 -0
- repolaunch-1.4.0/launch/utilities/dockerfiles/windows_server_rust/190/Dockerfile +23 -0
- repolaunch-1.4.0/launch/utilities/get_repo_structure.py +85 -0
- repolaunch-1.4.0/launch/utilities/language_handlers.py +669 -0
- repolaunch-1.4.0/launch/utilities/llm.py +247 -0
- repolaunch-1.4.0/launch/utilities/logger.py +74 -0
- repolaunch-1.4.0/launch/utilities/timemachine.py +270 -0
- repolaunch-1.4.0/launch/utilities/tools/str_replace_editor.py +289 -0
- repolaunch-1.4.0/launch/utilities/workspace.py +221 -0
- repolaunch-1.4.0/pyproject.toml +48 -0
- repolaunch-1.4.0/repolaunch.egg-info/PKG-INFO +111 -0
- repolaunch-1.4.0/repolaunch.egg-info/SOURCES.txt +63 -0
- repolaunch-1.4.0/repolaunch.egg-info/dependency_links.txt +1 -0
- repolaunch-1.4.0/repolaunch.egg-info/entry_points.txt +2 -0
- repolaunch-1.4.0/repolaunch.egg-info/requires.txt +19 -0
- repolaunch-1.4.0/repolaunch.egg-info/top_level.txt +1 -0
- repolaunch-1.4.0/setup.cfg +4 -0
repolaunch-1.4.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Microsoft Corporation.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: repolaunch
|
|
3
|
+
Version: 1.4.0
|
|
4
|
+
Summary: RepoLaunch
|
|
5
|
+
Requires-Python: >=3.12
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Requires-Dist: beautifulsoup4>=4.13.4
|
|
9
|
+
Requires-Dist: docker>=7.1.0
|
|
10
|
+
Requires-Dist: fire>=0.7.0
|
|
11
|
+
Requires-Dist: gitpython>=3.1.44
|
|
12
|
+
Requires-Dist: langchain==0.3.26
|
|
13
|
+
Requires-Dist: langchain-community==0.3.27
|
|
14
|
+
Requires-Dist: langchain-core==0.3.68
|
|
15
|
+
Requires-Dist: litellm
|
|
16
|
+
Requires-Dist: langgraph==0.5.2
|
|
17
|
+
Requires-Dist: pydantic==2.11.7
|
|
18
|
+
Requires-Dist: requests>=2.32.4
|
|
19
|
+
Requires-Dist: rich>=14.0.0
|
|
20
|
+
Requires-Dist: tenacity>=9.1.2
|
|
21
|
+
Requires-Dist: tornado>=6.5.1
|
|
22
|
+
Requires-Dist: typing-extensions>=4.14.1
|
|
23
|
+
Requires-Dist: pygithub
|
|
24
|
+
Provides-Extra: test
|
|
25
|
+
Requires-Dist: pytest>=8.0; extra == "test"
|
|
26
|
+
Dynamic: license-file
|
|
27
|
+
|
|
28
|
+
<h1 align="center"> 🚀 RepoLaunch Agent </h1>
|
|
29
|
+
|
|
30
|
+
<p align="center">
|
|
31
|
+
<a href="https://arxiv.org/abs/2603.05026"><img alt="paper" src="https://img.shields.io/badge/ArXiv-%23B31B1B?style=for-the-badge&logo=arXiv"></a>
|
|
32
|
+
<a href="https://repolaunch.github.io/"><img alt="Website" src="https://img.shields.io/badge/%20-WEBPAGE-D2B46F?style=for-the-badge&logo=readthedocs&logoColor=white&labelColor=343A40"></a>
|
|
33
|
+
<a href="./LICENSE"><img alt="License" src="https://img.shields.io/github/license/SWE-bench/SWE-bench?style=for-the-badge"></a>
|
|
34
|
+
</p>
|
|
35
|
+
|
|
36
|
+
<p align="center">
|
|
37
|
+
<em>Turning Any Codebase into Testable Sandbox Environment</em>
|
|
38
|
+
</p>
|
|
39
|
+
|
|
40
|
+
RepoLaunch is the **first** agentic SWE tool for repository build and test management across programming languages and operating systems. Given a code repository, RepoLaunch can:
|
|
41
|
+
- Install all dependencies and build the repository, delivered as a docker image, with docker image layer info collected for Dockerfile reconstruction;
|
|
42
|
+
- Organize the command to rebuild the repository inside a container after repo modifications;
|
|
43
|
+
- Organize command to test the repository, write a parser to parse test output into structured testcase-status mapping, and optionally find per-testcase running command.
|
|
44
|
+
|
|
45
|
+
RepoLaunch now supports:
|
|
46
|
+
- All mainstram languages : C, C++, C#, Python, Java, Node.js (JS & TS), Go, Rust.
|
|
47
|
+
- Building on linux images, android images, windows images.
|
|
48
|
+
|
|
49
|
+
## Notifications
|
|
50
|
+
|
|
51
|
+
**[20/Aug/2026]** Proposed the memory-aware solution to reuse existing successful results of RepoLaunch to build&test the different commits of the same repo. See [Development.md](docs/Development.md#reuse-repolaunch-results-for-different-commits-of-the-same-repo). This solution is especially useful to create multiple task instances from different issues of the same repo. Experiments on building executable envs for 856 GitHub issues from 93 repos show >= 98% success, with 82% savings on LM API cost and 78% savings on Docker image storage space.
|
|
52
|
+
|
|
53
|
+
**[28/Mar/2026]**
|
|
54
|
+
|
|
55
|
+
RepoLaunch now uses LiteLLM to:
|
|
56
|
+
- ensure compatibility with all mainstream LLM providers
|
|
57
|
+
- enable local LLM deployment for agentic training (RFT, RL) based on launch results
|
|
58
|
+
|
|
59
|
+
RepoLaunch now still uses traditional Thought-Action format for agent actions, because
|
|
60
|
+
- We find that many smaller open-source LMs cannot handle tool call field well.
|
|
61
|
+
- Thought Action in pure text content field ensures best compatibility and feasibility for smaller open-source LMs.
|
|
62
|
+
|
|
63
|
+
**[01/Mar/2026]** Thanks [GLM-5 Foundation Model](https://arxiv.org/pdf/2602.15763) for using RepoLaunch to create executable environment for agentic RL!
|
|
64
|
+
|
|
65
|
+
## Launch your Repository
|
|
66
|
+
|
|
67
|
+
To run RepoLaunch agent to launch your repository, please refer to [Development.md](./docs/Development.md).
|
|
68
|
+
|
|
69
|
+
Trajectory & result demos of RepoLaunch agent: [RepoLaunch-Trajectory-Archive](https://github.com/SWE-bench-Live/RepoLaunch-trajectory-archive).
|
|
70
|
+
|
|
71
|
+
The basic workflow of RepoLaunch agent is as follows:
|
|
72
|
+
|
|
73
|
+

|
|
74
|
+
|
|
75
|
+
## Contributing
|
|
76
|
+
|
|
77
|
+
### Contributing to RepoLaunch Source Codes
|
|
78
|
+
|
|
79
|
+
Please refer to [CONTRIBUTING.md::Contributing to RepoLaunch Source Codes](./CONTRIBUTING.md#contributing-to-repolaunch-source-codes).
|
|
80
|
+
|
|
81
|
+
### Use RepoLaunch to Create New Software Engineering Benchmarks
|
|
82
|
+
|
|
83
|
+
So far the major contribution of RepoLaunch is to build execution environment for [SWE-bench-Live](https://github.com/microsoft/SWE-bench-Live), where the creation of SWE-tasks is based purely on scraping GitHub issues and PRs. Now SWE-bench-Live datasets have been used for benchmarking of LLMs and coding agents, and agentic training (SFT/RL) of code LMs.
|
|
84
|
+
|
|
85
|
+
We encourage new research projects to design new kinds of SWE-tasks for LLM benchmarking and training, with task creation automated by RepoLaunch.
|
|
86
|
+
|
|
87
|
+

|
|
88
|
+
|
|
89
|
+
### Improve Agentic Repository Build and Management Task based on RepoLaunch
|
|
90
|
+
|
|
91
|
+
Please refer to [CONTRIBUTING.md::Future Directions to Study](./CONTRIBUTING.md#future-directions-to-study).
|
|
92
|
+
|
|
93
|
+
## Citations
|
|
94
|
+
|
|
95
|
+
```bibtex
|
|
96
|
+
@article{li2026repolaunch,
|
|
97
|
+
title={RepoLaunch: Automating Build and Management of Code Repositories across Languages and Platforms},
|
|
98
|
+
author={Kenan Li and Rongzhi Li and Linghao Zhang and Qirui Jin and Liao Zhu and Xiaosong Huang and Geng Zhang and Yikai Zhang and Shilin He and Chengxing Xie and Xin Zhang and Zijian Jin and Bowen Li and Chaoyun Zhang and Yu Kang and Yufan Huang and Elsie Nallipogu and Saravan Rajmohan and Qingwei Lin and Dongmei Zhang},
|
|
99
|
+
journal={arXiv preprint arXiv:2603.05026},
|
|
100
|
+
year={2026}
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Trademarks
|
|
105
|
+
|
|
106
|
+
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft
|
|
107
|
+
trademarks or logos is subject to and must follow
|
|
108
|
+
[Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/legal/intellectualproperty/trademarks/usage/general).
|
|
109
|
+
Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
|
|
110
|
+
Any use of third-party trademarks or logos are subject to those third-party's policies.
|
|
111
|
+
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
<h1 align="center"> 🚀 RepoLaunch Agent </h1>
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<a href="https://arxiv.org/abs/2603.05026"><img alt="paper" src="https://img.shields.io/badge/ArXiv-%23B31B1B?style=for-the-badge&logo=arXiv"></a>
|
|
5
|
+
<a href="https://repolaunch.github.io/"><img alt="Website" src="https://img.shields.io/badge/%20-WEBPAGE-D2B46F?style=for-the-badge&logo=readthedocs&logoColor=white&labelColor=343A40"></a>
|
|
6
|
+
<a href="./LICENSE"><img alt="License" src="https://img.shields.io/github/license/SWE-bench/SWE-bench?style=for-the-badge"></a>
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
<em>Turning Any Codebase into Testable Sandbox Environment</em>
|
|
11
|
+
</p>
|
|
12
|
+
|
|
13
|
+
RepoLaunch is the **first** agentic SWE tool for repository build and test management across programming languages and operating systems. Given a code repository, RepoLaunch can:
|
|
14
|
+
- Install all dependencies and build the repository, delivered as a docker image, with docker image layer info collected for Dockerfile reconstruction;
|
|
15
|
+
- Organize the command to rebuild the repository inside a container after repo modifications;
|
|
16
|
+
- Organize command to test the repository, write a parser to parse test output into structured testcase-status mapping, and optionally find per-testcase running command.
|
|
17
|
+
|
|
18
|
+
RepoLaunch now supports:
|
|
19
|
+
- All mainstram languages : C, C++, C#, Python, Java, Node.js (JS & TS), Go, Rust.
|
|
20
|
+
- Building on linux images, android images, windows images.
|
|
21
|
+
|
|
22
|
+
## Notifications
|
|
23
|
+
|
|
24
|
+
**[20/Aug/2026]** Proposed the memory-aware solution to reuse existing successful results of RepoLaunch to build&test the different commits of the same repo. See [Development.md](docs/Development.md#reuse-repolaunch-results-for-different-commits-of-the-same-repo). This solution is especially useful to create multiple task instances from different issues of the same repo. Experiments on building executable envs for 856 GitHub issues from 93 repos show >= 98% success, with 82% savings on LM API cost and 78% savings on Docker image storage space.
|
|
25
|
+
|
|
26
|
+
**[28/Mar/2026]**
|
|
27
|
+
|
|
28
|
+
RepoLaunch now uses LiteLLM to:
|
|
29
|
+
- ensure compatibility with all mainstream LLM providers
|
|
30
|
+
- enable local LLM deployment for agentic training (RFT, RL) based on launch results
|
|
31
|
+
|
|
32
|
+
RepoLaunch now still uses traditional Thought-Action format for agent actions, because
|
|
33
|
+
- We find that many smaller open-source LMs cannot handle tool call field well.
|
|
34
|
+
- Thought Action in pure text content field ensures best compatibility and feasibility for smaller open-source LMs.
|
|
35
|
+
|
|
36
|
+
**[01/Mar/2026]** Thanks [GLM-5 Foundation Model](https://arxiv.org/pdf/2602.15763) for using RepoLaunch to create executable environment for agentic RL!
|
|
37
|
+
|
|
38
|
+
## Launch your Repository
|
|
39
|
+
|
|
40
|
+
To run RepoLaunch agent to launch your repository, please refer to [Development.md](./docs/Development.md).
|
|
41
|
+
|
|
42
|
+
Trajectory & result demos of RepoLaunch agent: [RepoLaunch-Trajectory-Archive](https://github.com/SWE-bench-Live/RepoLaunch-trajectory-archive).
|
|
43
|
+
|
|
44
|
+
The basic workflow of RepoLaunch agent is as follows:
|
|
45
|
+
|
|
46
|
+

|
|
47
|
+
|
|
48
|
+
## Contributing
|
|
49
|
+
|
|
50
|
+
### Contributing to RepoLaunch Source Codes
|
|
51
|
+
|
|
52
|
+
Please refer to [CONTRIBUTING.md::Contributing to RepoLaunch Source Codes](./CONTRIBUTING.md#contributing-to-repolaunch-source-codes).
|
|
53
|
+
|
|
54
|
+
### Use RepoLaunch to Create New Software Engineering Benchmarks
|
|
55
|
+
|
|
56
|
+
So far the major contribution of RepoLaunch is to build execution environment for [SWE-bench-Live](https://github.com/microsoft/SWE-bench-Live), where the creation of SWE-tasks is based purely on scraping GitHub issues and PRs. Now SWE-bench-Live datasets have been used for benchmarking of LLMs and coding agents, and agentic training (SFT/RL) of code LMs.
|
|
57
|
+
|
|
58
|
+
We encourage new research projects to design new kinds of SWE-tasks for LLM benchmarking and training, with task creation automated by RepoLaunch.
|
|
59
|
+
|
|
60
|
+

|
|
61
|
+
|
|
62
|
+
### Improve Agentic Repository Build and Management Task based on RepoLaunch
|
|
63
|
+
|
|
64
|
+
Please refer to [CONTRIBUTING.md::Future Directions to Study](./CONTRIBUTING.md#future-directions-to-study).
|
|
65
|
+
|
|
66
|
+
## Citations
|
|
67
|
+
|
|
68
|
+
```bibtex
|
|
69
|
+
@article{li2026repolaunch,
|
|
70
|
+
title={RepoLaunch: Automating Build and Management of Code Repositories across Languages and Platforms},
|
|
71
|
+
author={Kenan Li and Rongzhi Li and Linghao Zhang and Qirui Jin and Liao Zhu and Xiaosong Huang and Geng Zhang and Yikai Zhang and Shilin He and Chengxing Xie and Xin Zhang and Zijian Jin and Bowen Li and Chaoyun Zhang and Yu Kang and Yufan Huang and Elsie Nallipogu and Saravan Rajmohan and Qingwei Lin and Dongmei Zhang},
|
|
72
|
+
journal={arXiv preprint arXiv:2603.05026},
|
|
73
|
+
year={2026}
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Trademarks
|
|
78
|
+
|
|
79
|
+
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft
|
|
80
|
+
trademarks or logos is subject to and must follow
|
|
81
|
+
[Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/legal/intellectualproperty/trademarks/usage/general).
|
|
82
|
+
Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
|
|
83
|
+
Any use of third-party trademarks or logos are subject to those third-party's policies.
|
|
84
|
+
|
|
File without changes
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Common action parsing utilities for agent interactions.
|
|
3
|
+
"""
|
|
4
|
+
import re
|
|
5
|
+
from typing import Optional, Any
|
|
6
|
+
from abc import ABC, abstractmethod
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class ActionParser(ABC):
|
|
10
|
+
"""Base class for parsing LLM responses into structured actions."""
|
|
11
|
+
|
|
12
|
+
@abstractmethod
|
|
13
|
+
def parse(self, response: str) -> Optional[Any]:
|
|
14
|
+
"""Parse response string into action object."""
|
|
15
|
+
pass
|
|
16
|
+
|
|
17
|
+
@staticmethod
|
|
18
|
+
def extract_tag_content(response: str, tag: str) -> Optional[str]:
|
|
19
|
+
"""Extract content between XML-style tags."""
|
|
20
|
+
pattern = f"<{tag}>(.*?)</{tag}>"
|
|
21
|
+
match = re.search(pattern, response, re.DOTALL)
|
|
22
|
+
return match.group(1) if match else None
|
|
23
|
+
|
|
24
|
+
@staticmethod
|
|
25
|
+
def clean_response(response: str) -> str:
|
|
26
|
+
"""Remove reasoning tags from response if present."""
|
|
27
|
+
if "<think>" in response:
|
|
28
|
+
return response.split("</think>")[1]
|
|
29
|
+
return response
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Repository analysis agent for locating environment setup documentation.
|
|
3
|
+
"""
|
|
4
|
+
import os
|
|
5
|
+
|
|
6
|
+
from langchain.schema import HumanMessage
|
|
7
|
+
|
|
8
|
+
from launch.agent.state import AgentState, auto_catch
|
|
9
|
+
from launch.utilities.get_repo_structure import view_repo_structure
|
|
10
|
+
from launch.utilities.llm import form_llm_cost_log, update_accumulative_cost
|
|
11
|
+
|
|
12
|
+
prompt = """Given this repository structure:
|
|
13
|
+
------ BEGIN REPOSITORY STRUCTURE ------
|
|
14
|
+
{structure}
|
|
15
|
+
------ END REPOSITORY STRUCTURE ------
|
|
16
|
+
|
|
17
|
+
List the most relevant files for setting up a development environment, including:
|
|
18
|
+
0. CI/CD configuration files
|
|
19
|
+
1. README files
|
|
20
|
+
2. Documentation
|
|
21
|
+
3. Installation guides
|
|
22
|
+
4. Development setup guides
|
|
23
|
+
|
|
24
|
+
Only list files that are critical for understanding project dependencies and setup requirements.
|
|
25
|
+
Format each file with its relative path (relative to project root) to be wrapped with tag <file> </file>, one per line."""
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
determine_prompt = """Given a file of the repository, determine if it is relevant for setting up a development environment for the repository or providing information about how to set up dev env (how to setup, install, test, etc.). This determines whether the file's content is fed to the LLM and helps it set up the environment.
|
|
29
|
+
|
|
30
|
+
### File:
|
|
31
|
+
{file}
|
|
32
|
+
|
|
33
|
+
### Reply with the following format:
|
|
34
|
+
|
|
35
|
+
<rel>Yes</rel>
|
|
36
|
+
|
|
37
|
+
or
|
|
38
|
+
|
|
39
|
+
<rel>No</rel>
|
|
40
|
+
|
|
41
|
+
Choose either Yes or No, Yes means this file IS relevant for setting up a dev env for the repository.
|
|
42
|
+
"""
|
|
43
|
+
|
|
44
|
+
THRESHOLD = 128 * 1000 * 2
|
|
45
|
+
|
|
46
|
+
@auto_catch
|
|
47
|
+
def locate_related_file(state: AgentState) -> dict:
|
|
48
|
+
"""
|
|
49
|
+
Analyze repository structure to identify files relevant for environment setup.
|
|
50
|
+
|
|
51
|
+
Uses LLM to scan repository structure and determine which files contain
|
|
52
|
+
information about dependencies, installation, and development setup.
|
|
53
|
+
|
|
54
|
+
Args:
|
|
55
|
+
state (AgentState): Current agent state with repo structure
|
|
56
|
+
|
|
57
|
+
Returns:
|
|
58
|
+
AgentState: Updated state with documentation content and related files
|
|
59
|
+
"""
|
|
60
|
+
llm = state["llm"]
|
|
61
|
+
cost = state["cost"]
|
|
62
|
+
logger = state["logger"]
|
|
63
|
+
repo_structure = state["repo_structure"]
|
|
64
|
+
|
|
65
|
+
locate_prompt = HumanMessage(
|
|
66
|
+
content=prompt.format(structure=repo_structure)
|
|
67
|
+
)
|
|
68
|
+
if len(locate_prompt.content) > THRESHOLD:
|
|
69
|
+
repo_structure = view_repo_structure(state["repo_root"], 2)
|
|
70
|
+
locate_prompt = HumanMessage(
|
|
71
|
+
content=prompt.format(structure=repo_structure)
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
response = llm.invoke([locate_prompt])
|
|
75
|
+
update_accumulative_cost(cost["preparation"], response)
|
|
76
|
+
potential_files = [
|
|
77
|
+
line.split("<file>")[1].split("</file>")[0].strip()
|
|
78
|
+
for line in response.content.split("\n")
|
|
79
|
+
if line.strip() and "<file>" in line
|
|
80
|
+
]
|
|
81
|
+
potential_files = [
|
|
82
|
+
file
|
|
83
|
+
for file in potential_files
|
|
84
|
+
if os.path.exists(os.path.join(state["repo_root"], file))
|
|
85
|
+
]
|
|
86
|
+
potential_files = list(set(potential_files))
|
|
87
|
+
|
|
88
|
+
logger.info(f"Potential files: {potential_files} {form_llm_cost_log(response)}")
|
|
89
|
+
logger.info("Start determine relevance of these files...")
|
|
90
|
+
related_files = []
|
|
91
|
+
|
|
92
|
+
docs = "------ BEGIN RELATED FILES ------\n"
|
|
93
|
+
for file in potential_files:
|
|
94
|
+
path = os.path.join(state["repo_root"], file)
|
|
95
|
+
if not os.path.exists(path):
|
|
96
|
+
continue
|
|
97
|
+
if os.path.isdir(path):
|
|
98
|
+
continue
|
|
99
|
+
try:
|
|
100
|
+
with open(path, "r", encoding="utf-8", errors="ignore") as f:
|
|
101
|
+
content = f.read(THRESHOLD)
|
|
102
|
+
except Exception as e:
|
|
103
|
+
logger.info(f"Error reading file {file}: {e}")
|
|
104
|
+
continue
|
|
105
|
+
|
|
106
|
+
file_info = f"""------ START FILE {file} ------
|
|
107
|
+
{content}
|
|
108
|
+
------ END FILE {file} ------"""
|
|
109
|
+
determine_input = HumanMessage(content=determine_prompt.format(file=file_info))
|
|
110
|
+
|
|
111
|
+
response = llm.invoke([determine_input])
|
|
112
|
+
update_accumulative_cost(cost["preparation"], response)
|
|
113
|
+
logger.info(f"File: {file} - {response.content} {form_llm_cost_log(response)}")
|
|
114
|
+
if "<rel>Yes</rel>" in response.content:
|
|
115
|
+
docs += f"File: {file}\n```\n"
|
|
116
|
+
docs += content + "\n"
|
|
117
|
+
docs += "```\n"
|
|
118
|
+
related_files.append(file)
|
|
119
|
+
docs += "------ END RELATED FILES ------\n"
|
|
120
|
+
|
|
121
|
+
logger.info(f"Located related files: {related_files}")
|
|
122
|
+
|
|
123
|
+
return {
|
|
124
|
+
"messages": [locate_prompt, response],
|
|
125
|
+
"docs": docs,
|
|
126
|
+
# We do not require the full repo structure later
|
|
127
|
+
"repo_structure": repo_structure,
|
|
128
|
+
"cost": cost,
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
if __name__ == "__main__":
|
|
133
|
+
from launch.agent.state import AgentState
|
|
134
|
+
|
|
135
|
+
state = AgentState()
|
|
136
|
+
locate_related_file(state)
|
|
File without changes
|