Skip to content

Commit

Permalink
feat: Updates to plan+edit cycle
Browse files Browse the repository at this point in the history
  • Loading branch information
kgilpin committed Aug 16, 2024
1 parent b39f08a commit 03050bd
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 14 deletions.
34 changes: 22 additions & 12 deletions navie/mode/edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ def main():
print("Error: Issue description is required in non-interactive mode")
sys.exit(1)

problem_statement = interactions.collect_problem_statement()
problem_statement = interactions.collect_problem_statement()

if not problem_statement.strip():
print("Problem statement is empty. Exiting.")
sys.exit(1)
Expand All @@ -194,8 +195,9 @@ def main():
pass

try:
changed = True
while changed:
replan_required = True
while replan_required:
replan_required = False
user_interface.display_message("Planning...")
plan = edit.plan()

Expand All @@ -206,16 +208,24 @@ def main():
for file in edit.files_to_edit:
user_interface.display_message(f" {file}", color="white")

changed = False
if interactive:
interactions.enter_to_continue()

updated_problem_statement = interactions.prompt_user_for_adjustments(
edit.problem_statement
)
if updated_problem_statement != edit.problem_statement:
edit.problem_statement = updated_problem_statement
changed = True
if interactions.prompt_for_edit():
updated_problem_statement = (
interactions.prompt_user_for_adjustments(edit.problem_statement)
)
if updated_problem_statement != edit.problem_statement:
edit.problem_statement = updated_problem_statement
replan_required = True

updated_files = interactions.prompt_user_for_adjustments(
"\n".join(edit.files_to_edit)
)
if updated_files != "\n".join(edit.files_to_edit):
edit.files_to_edit = [
file.strip()
for file in updated_files.split("\n")
if file.strip()
]

user_interface.display_message("Generating code...")

Expand Down
14 changes: 12 additions & 2 deletions navie/mode/interactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,22 @@ def enter_to_continue(self):
)
if confirmation.lower() == "q":
raise QuitException()
return True

def collect_problem_statement(self) -> str:
return self.user_interface.open_editor_and_read()

def prompt_user_for_adjustments(self, problem_statement: str) -> str:
return self.user_interface.open_editor_and_read(problem_statement)
def prompt_user_for_adjustments(self, content: str) -> str:
return self.user_interface.open_editor_and_read(content)

def prompt_for_edit(self):
confirmation = self.user_interface.get_input(
"Press enter to continue, or (e) to edit the requirements or file list: "
)
if confirmation.lower() == "q":
raise QuitException()

return confirmation.lower() == "e"

def confirm_diff(self, file: str, diff_output: str) -> bool:
self.user_interface.display_message(f"Diff for file {file}:")
Expand Down

0 comments on commit 03050bd

Please sign in to comment.