(command: str)
| 29 | return key |
| 30 | |
| 31 | def print_response(command: str): |
| 32 | print(f"{BLUE}Command found:\n=====================") |
| 33 | print(f"{GREEN}{command}{RESET}") |
| 34 | print(f"{BLUE}====================={RESET}") |
| 35 | print(f"{BLUE}What do you want to do with this command?{RESET}") |
| 36 | print(f"{BLUE}[c] Copy [e] Execute [a] Abort{RESET}") |
| 37 | print(f"{BLUE}Press key: ", end="", flush=True) |
| 38 | |
| 39 | choice = get_keypress().lower() |
| 40 | print(f"{RESET}") |
| 41 | |
| 42 | if choice == "e": |
| 43 | print(f"{BLUE}Executing command: {command}{RESET}") |
| 44 | result = subprocess.run(command, shell=True, capture_output=True, text=True) |
| 45 | print(f"{GREEN}Command output: {result.stdout}{RESET}") |
| 46 | if result.stderr: |
| 47 | print(f"{RED}Error: {result.stderr}{RESET}") |
| 48 | elif choice == "c": |
| 49 | import pyperclip # ⏱ lazy import |
| 50 | pyperclip.copy(command) |
| 51 | print(f"{GREEN}Command copied to clipboard!{RESET}") |
| 52 | elif choice == "a": |
| 53 | print(f"{BLUE}Aborted.{RESET}") |
| 54 | else: |
| 55 | print(f"{RED}Unknown choice. Nothing happened.{RESET}") |
| 56 | |
| 57 | def one_shot_mode(prompt: str): |
| 58 | from open_codex.agent_builder import AgentBuilder |
no test coverage detected