-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support existing projects #976
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
from uuid import uuid4 | ||
|
||
from core.agents.base import BaseAgent | ||
from core.agents.convo import AgentConvo | ||
from core.agents.response import AgentResponse, ResponseType | ||
from core.db.models import Complexity | ||
from core.llm.parser import JSONParser | ||
from core.log import get_logger | ||
from core.templates.example_project import EXAMPLE_PROJECT_DESCRIPTION | ||
|
||
log = get_logger(__name__) | ||
|
||
MAX_PROJECT_LINES = 10000 | ||
|
||
|
||
class Importer(BaseAgent): | ||
agent_type = "importer" | ||
display_name = "Project Analyist" | ||
|
||
async def run(self) -> AgentResponse: | ||
if self.prev_response and self.prev_response.type == ResponseType.IMPORT_PROJECT: | ||
# Called by SpecWriter to start the import process | ||
await self.start_import_process() | ||
return AgentResponse.describe_files(self) | ||
|
||
await self.analyze_project() | ||
return AgentResponse.done(self) | ||
|
||
async def start_import_process(self): | ||
# TODO: Send a signal to the UI to copy the project files to workspace | ||
project_root = self.state_manager.get_full_project_root() | ||
await self.ui.import_project(project_root) | ||
await self.send_message( | ||
f"This is experimental feature and is currently limited to projects with size up to {MAX_PROJECT_LINES} lines of code." | ||
) | ||
|
||
await self.ask_question( | ||
f"Please copy your project files to {project_root} and press Continue", | ||
allow_empty=False, | ||
buttons={ | ||
"continue": "Continue", | ||
}, | ||
buttons_only=True, | ||
default="continue", | ||
) | ||
|
||
imported_files, _ = await self.state_manager.import_files() | ||
imported_lines = sum(len(f.content.content.splitlines()) for f in imported_files) | ||
if imported_lines > MAX_PROJECT_LINES: | ||
await self.send_message( | ||
"WARNING: Your project ({imported_lines} LOC) is larger than supported and may cause issues in Pythagora." | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If i understand this correctly we don't really block users from loading bigger projects, we just show the warning. I think warning is not enough and we should check LOC before importing files and then fail importing if it is bigger project |
||
) | ||
await self.state_manager.commit() | ||
|
||
async def analyze_project(self): | ||
llm = self.get_llm() | ||
|
||
self.send_message("Inspecting most important project files ...") | ||
|
||
convo = AgentConvo(self).template("get_entrypoints") | ||
llm_response = await llm(convo, parser=JSONParser()) | ||
relevant_files = [f for f in self.current_state.files if f.path in llm_response] | ||
|
||
self.send_message("Analyzing project ...") | ||
|
||
convo = AgentConvo(self).template( | ||
"analyze_project", relevant_files=relevant_files, example_spec=EXAMPLE_PROJECT_DESCRIPTION | ||
) | ||
llm_response = await llm(convo) | ||
|
||
spec = self.current_state.specification.clone() | ||
spec.description = llm_response | ||
self.next_state.specification = spec | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we maybe also get architecture, sys dependencies and package dependencies? |
||
self.next_state.epics = [ | ||
{ | ||
"id": uuid4().hex, | ||
"name": "Import project", | ||
"description": "Import an existing project into Pythagora", | ||
"tasks": [], | ||
"completed": True, | ||
"test_instructions": None, | ||
"source": "app", | ||
"summary": None, | ||
"complexity": Complexity.HARD if len(self.current_state.files) > 5 else Complexity.SIMPLE, | ||
} | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
"node_modules", | ||
"package-lock.json", | ||
"venv", | ||
".venv", | ||
"dist", | ||
"build", | ||
"target", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
You're given an existing project you need to analyze and continue developing. To do this, you'll need to determine the project architecture, technologies used (platform, libraries, etc) and reverse-engineer the technical and functional spec. | ||
|
||
Here is the list of all the files in the project: | ||
|
||
{% for file in state.files %} | ||
* `{{ file.path }}` - {{ file.meta.get("description")}} | ||
{% endfor %} | ||
|
||
Here's the full content of interesting files that may help you to determine the specification: | ||
|
||
{% for file in state.files %} | ||
**`{{ file.path }}`**: | ||
``` | ||
{{ file.content.content }} | ||
``` | ||
|
||
{% endfor %} | ||
|
||
Based on this information, please provide detailed specification for the project. Here is an example specification format: | ||
|
||
---START_OF_EXAMPLE_SPEC--- | ||
{{ example_spec }} | ||
---END_OF_EXAMPLE_SPEC--- | ||
|
||
**IMPORTANT**: In the specification, you must include the following sections: | ||
* **Project Description**: A detailed description of what the project is about. | ||
* **Features**: A list of features that the project has implemented. Each feature should be described in detail. | ||
* **Technical Specification**: Detailed description of how the project works, including any important technical details. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
You're given an existing project you need to analyze and continue developing. To do this, you'll need to determine the project architecture, technologies used (platform, libraries, etc) and reverse-engineer the technical and functional spec. | ||
|
||
As a first step, you have to identify which of the listed files to examine so you can determine this. After you identify the files, you'll be given full access to their contents so you can determine the project information. | ||
|
||
Here is the list of all the files in the project: | ||
|
||
{% for file in state.files %} | ||
* `{{ file.path }}` - {{ file.meta.get("description")}} | ||
{% endfor %} | ||
|
||
Based on this information, list the files (full path, as shown in the list) you would examine to determine the project architecture, technologies and specification. Output the list in JSON format like in the following example: | ||
|
||
```json | ||
{ | ||
"files": [ | ||
"README.md", | ||
"pyproject.toml", | ||
"settings/settings.py" | ||
] | ||
} | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should have
Back
button also