/ main.py
main.py
 1  import sys
 2  import os
 3  import subprocess
 4  from pathlib import Path
 5  from dotenv import load_dotenv
 6  from aider.coders import Coder
 7  from aider.models import Model
 8  from aider.io import InputOutput
 9  
10  load_dotenv()
11  
12  def run_aider_session(input_file):
13      model = Model("claude-3-5-sonnet-20240620")
14      io = InputOutput(yes=True)
15  
16      with open(input_file, 'r') as f:
17          user_input = f.read()
18  
19      fnames = ["magic_prompt.txt", "project_name.txt", "project_prompt.txt"]
20      coder = Coder.create(main_model=model, fnames=fnames, io=io)
21  
22      # Add magic prompt and user input to the chat
23      coder.run(user_input)
24  
25      # The Aider session will now process the input and generate a project name and initial prompt
26      # It will then run the dreamnode_creator.py script and start a new Aider session in the new project
27  
28  def main():
29      if len(sys.argv) != 2:
30          print("Usage: python auryn.py <input_file_path>")
31          sys.exit(1)
32  
33      input_file = sys.argv[1]
34      magic_prompt_file = "magic_prompt.txt"
35  
36      if not os.path.exists(input_file):
37          print(f"Error: Input file '{input_file}' not found.")
38          sys.exit(1)
39  
40      run_aider_session(input_file)
41  
42      subprocess.run(["python", "dreamnode_creator.py", "project_name.txt", "project_prompt.txt"], check=True)
43  
44      # delete content of text files
45      open("project_name.txt", 'w').close()
46      open("project_prompt.txt", 'w').close()
47  
48  if __name__ == "__main__":
49      main()