Artificial-superintelligence
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -35,6 +35,10 @@ You are an AI-powered terminal assistant. Your role is to interpret user request
|
|
35 |
- git clone: For cloning repositories
|
36 |
- cd: For changing directories
|
37 |
- Python script execution: For running .py files
|
|
|
|
|
|
|
|
|
38 |
|
39 |
2. Provide the exact command to be executed, without any explanation or additional text.
|
40 |
|
@@ -46,7 +50,15 @@ You are an AI-powered terminal assistant. Your role is to interpret user request
|
|
46 |
|
47 |
6. For Python script execution, provide the command to run the script (e.g., '!python script_name.py').
|
48 |
|
49 |
-
7.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
|
51 |
Always respond with ONLY the command to be executed, nothing else.
|
52 |
"""
|
@@ -98,6 +110,25 @@ def execute_code():
|
|
98 |
result = f"Error: Directory not found: {new_dir}"
|
99 |
elif ai_result.startswith("!python "):
|
100 |
result = execute_command(ai_result[1:]) # Remove the leading '!'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
else:
|
102 |
result = f"Unclear AI response: {ai_result}"
|
103 |
|
|
|
35 |
- git clone: For cloning repositories
|
36 |
- cd: For changing directories
|
37 |
- Python script execution: For running .py files
|
38 |
+
- show files: List files in the current directory
|
39 |
+
- hide files: Hide the file explorer
|
40 |
+
- new file: Create a new file
|
41 |
+
- edit file: Open a file for editing
|
42 |
|
43 |
2. Provide the exact command to be executed, without any explanation or additional text.
|
44 |
|
|
|
50 |
|
51 |
6. For Python script execution, provide the command to run the script (e.g., '!python script_name.py').
|
52 |
|
53 |
+
7. For show files, respond with 'show files'.
|
54 |
+
|
55 |
+
8. For hide files, respond with 'hide files'.
|
56 |
+
|
57 |
+
9. For new file requests, respond with 'new file filename.ext', where filename.ext is the name provided by the user or a default name if not specified.
|
58 |
+
|
59 |
+
10. For edit file requests, respond with 'edit filename.ext', where filename.ext is the name of the file to be edited.
|
60 |
+
|
61 |
+
11. If a request is unclear or doesn't match any known command type, respond with "Unclear request. Please provide more details."
|
62 |
|
63 |
Always respond with ONLY the command to be executed, nothing else.
|
64 |
"""
|
|
|
110 |
result = f"Error: Directory not found: {new_dir}"
|
111 |
elif ai_result.startswith("!python "):
|
112 |
result = execute_command(ai_result[1:]) # Remove the leading '!'
|
113 |
+
elif ai_result == "show files":
|
114 |
+
files = os.listdir(current_dir)
|
115 |
+
result = "Files in current directory:\n" + "\n".join(files)
|
116 |
+
elif ai_result == "hide files":
|
117 |
+
result = "Files hidden."
|
118 |
+
elif ai_result.startswith("new file "):
|
119 |
+
filename = ai_result[9:].strip()
|
120 |
+
filepath = os.path.join(current_dir, filename)
|
121 |
+
with open(filepath, 'w') as f:
|
122 |
+
pass # Create an empty file
|
123 |
+
result = f"Created new file: {filename}"
|
124 |
+
elif ai_result.startswith("edit "):
|
125 |
+
filename = ai_result[5:].strip()
|
126 |
+
filepath = os.path.join(current_dir, filename)
|
127 |
+
if os.path.exists(filepath):
|
128 |
+
result = "Enter code:"
|
129 |
+
return jsonify({"result": result, "action": "edit", "filename": filename})
|
130 |
+
else:
|
131 |
+
result = f"Error: File {filename} not found."
|
132 |
else:
|
133 |
result = f"Unclear AI response: {ai_result}"
|
134 |
|