auto-coder-web 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- auto_coder_web/__init__.py +0 -0
- auto_coder_web/auto_coder_runner.py +694 -0
- auto_coder_web/file_group.py +69 -0
- auto_coder_web/file_manager.py +114 -0
- auto_coder_web/hello.py +36 -0
- auto_coder_web/json_file_storage.py +44 -0
- auto_coder_web/proxy.py +532 -0
- auto_coder_web/terminal.py +259 -0
- auto_coder_web/version.py +1 -0
- auto_coder_web/web/asset-manifest.json +15 -0
- auto_coder_web/web/favicon.ico +0 -0
- auto_coder_web/web/index.html +1 -0
- auto_coder_web/web/logo192.png +0 -0
- auto_coder_web/web/logo512.png +0 -0
- auto_coder_web/web/manifest.json +25 -0
- auto_coder_web/web/robots.txt +3 -0
- auto_coder_web/web/static/css/main.0441fea8.css +6 -0
- auto_coder_web/web/static/css/main.0441fea8.css.map +1 -0
- auto_coder_web/web/static/js/453.8ab44547.chunk.js +2 -0
- auto_coder_web/web/static/js/453.8ab44547.chunk.js.map +1 -0
- auto_coder_web/web/static/js/main.9cc516f4.js +3 -0
- auto_coder_web/web/static/js/main.9cc516f4.js.LICENSE.txt +119 -0
- auto_coder_web/web/static/js/main.9cc516f4.js.map +1 -0
- auto_coder_web-0.1.0.dist-info/METADATA +34 -0
- auto_coder_web-0.1.0.dist-info/RECORD +28 -0
- auto_coder_web-0.1.0.dist-info/WHEEL +5 -0
- auto_coder_web-0.1.0.dist-info/entry_points.txt +2 -0
- auto_coder_web-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,69 @@
|
|
1
|
+
from fastapi import HTTPException
|
2
|
+
from typing import List, Dict, Optional
|
3
|
+
import os
|
4
|
+
from .auto_coder_runner import AutoCoderRunner
|
5
|
+
|
6
|
+
class FileGroupManager:
|
7
|
+
def __init__(self,auto_coder_runner: AutoCoderRunner):
|
8
|
+
self.runner = auto_coder_runner
|
9
|
+
|
10
|
+
async def create_group(self, name: str, description: str) -> Dict:
|
11
|
+
group = self.runner.add_group(name,description=description)
|
12
|
+
if group is None:
|
13
|
+
raise HTTPException(status_code=400, detail="Group already exists")
|
14
|
+
return {
|
15
|
+
"name": name,
|
16
|
+
"description": description,
|
17
|
+
"files": []
|
18
|
+
}
|
19
|
+
|
20
|
+
async def switch_groups(self, group_names: List[str]) -> Dict:
|
21
|
+
result = self.runner.switch_groups(group_names)
|
22
|
+
if result is None:
|
23
|
+
raise HTTPException(status_code=404, detail="Group not found")
|
24
|
+
return result
|
25
|
+
|
26
|
+
async def delete_group(self, name: str) -> None:
|
27
|
+
result = self.runner.remove_group(name)
|
28
|
+
if result is None:
|
29
|
+
raise HTTPException(status_code=404, detail="Group not found")
|
30
|
+
|
31
|
+
async def add_files_to_group(self, group_name: str, files: List[str]) -> Dict:
|
32
|
+
result = self.runner.add_files_to_group(group_name, files)
|
33
|
+
if result is None:
|
34
|
+
raise HTTPException(status_code=404, detail="Group not found")
|
35
|
+
return {
|
36
|
+
"name": group_name,
|
37
|
+
"files": result.get("files", [])
|
38
|
+
}
|
39
|
+
|
40
|
+
async def remove_files_from_group(self, group_name: str, files: List[str]) -> Dict:
|
41
|
+
result = self.runner.remove_files_from_group(group_name, files)
|
42
|
+
if result is None:
|
43
|
+
raise HTTPException(status_code=404, detail="Group not found")
|
44
|
+
return {
|
45
|
+
"name": group_name,
|
46
|
+
"files": result.get("files", [])
|
47
|
+
}
|
48
|
+
|
49
|
+
async def get_groups(self) -> List[Dict]:
|
50
|
+
groups = self.runner.get_groups()
|
51
|
+
if not groups:
|
52
|
+
return []
|
53
|
+
return [
|
54
|
+
{
|
55
|
+
"name": group_name,
|
56
|
+
"files": self.runner.get_files_in_group(group_name).get("files", []),
|
57
|
+
"description": self.runner.get_group_description(group_name)
|
58
|
+
}
|
59
|
+
for group_name in groups.get("groups", [])
|
60
|
+
]
|
61
|
+
|
62
|
+
async def get_group(self, name: str) -> Optional[Dict]:
|
63
|
+
files = self.runner.get_files_in_group(name)
|
64
|
+
if files is None:
|
65
|
+
return None
|
66
|
+
return {
|
67
|
+
"name": name,
|
68
|
+
"files": files.get("files", [])
|
69
|
+
}
|
@@ -0,0 +1,114 @@
|
|
1
|
+
import os
|
2
|
+
import json
|
3
|
+
from typing import List, Dict, Any, Optional
|
4
|
+
|
5
|
+
|
6
|
+
def get_directory_tree(root_path: str, path: str = None, lazy: bool = False) -> List[Dict[str, Any]]:
|
7
|
+
"""
|
8
|
+
Generate a directory tree structure while ignoring common directories and files
|
9
|
+
that should not be included in version control or IDE specific files.
|
10
|
+
|
11
|
+
Args:
|
12
|
+
root_path: The root directory path to start traversing from
|
13
|
+
path: Optional path relative to root_path to get children for
|
14
|
+
lazy: If True, only return immediate children for directories
|
15
|
+
|
16
|
+
Returns:
|
17
|
+
A list of dictionaries representing the directory tree structure
|
18
|
+
"""
|
19
|
+
# Common directories and files to ignore
|
20
|
+
IGNORE_PATTERNS = {
|
21
|
+
# Version control
|
22
|
+
'.git', '.svn', '.hg',
|
23
|
+
# Dependencies
|
24
|
+
'node_modules', 'venv', '.venv', 'env', '.env',
|
25
|
+
'__pycache__', '.pytest_cache',
|
26
|
+
# Build outputs
|
27
|
+
'dist', 'build', 'target',
|
28
|
+
# IDE specific
|
29
|
+
'.idea', '.vscode', '.vs',
|
30
|
+
# OS specific
|
31
|
+
'.DS_Store', 'Thumbs.db',
|
32
|
+
# Other common patterns
|
33
|
+
'coverage', '.coverage', 'htmlcov',
|
34
|
+
# Hidden directories (start with .)
|
35
|
+
'.*'
|
36
|
+
}
|
37
|
+
|
38
|
+
def should_ignore(name: str) -> bool:
|
39
|
+
"""Check if a file or directory should be ignored"""
|
40
|
+
# Ignore hidden files/directories
|
41
|
+
if name.startswith('.'):
|
42
|
+
return True
|
43
|
+
# Ignore exact matches and pattern matches
|
44
|
+
return name in IGNORE_PATTERNS
|
45
|
+
|
46
|
+
def build_tree(current_path: str) -> List[Dict[str, Any]]:
|
47
|
+
"""Recursively build the directory tree"""
|
48
|
+
items = []
|
49
|
+
try:
|
50
|
+
for name in sorted(os.listdir(current_path)):
|
51
|
+
if should_ignore(name):
|
52
|
+
continue
|
53
|
+
|
54
|
+
full_path = os.path.join(current_path, name)
|
55
|
+
relative_path = os.path.relpath(full_path, root_path)
|
56
|
+
|
57
|
+
if os.path.isdir(full_path):
|
58
|
+
if lazy:
|
59
|
+
# For lazy loading, just check if directory has any visible children
|
60
|
+
has_children = False
|
61
|
+
for child_name in os.listdir(full_path):
|
62
|
+
if not should_ignore(child_name):
|
63
|
+
has_children = True
|
64
|
+
break
|
65
|
+
|
66
|
+
items.append({
|
67
|
+
'title': name,
|
68
|
+
'key': relative_path,
|
69
|
+
'children': [], # Empty children array for lazy loading
|
70
|
+
'isLeaf': False,
|
71
|
+
'hasChildren': has_children
|
72
|
+
})
|
73
|
+
else:
|
74
|
+
children = build_tree(full_path)
|
75
|
+
if children: # Only add non-empty directories
|
76
|
+
items.append({
|
77
|
+
'title': name,
|
78
|
+
'key': relative_path,
|
79
|
+
'children': children,
|
80
|
+
'isLeaf': False,
|
81
|
+
'hasChildren': True
|
82
|
+
})
|
83
|
+
else:
|
84
|
+
items.append({
|
85
|
+
'title': name,
|
86
|
+
'key': relative_path,
|
87
|
+
'isLeaf': True,
|
88
|
+
'hasChildren': False
|
89
|
+
})
|
90
|
+
except PermissionError:
|
91
|
+
# Skip directories we don't have permission to read
|
92
|
+
pass
|
93
|
+
|
94
|
+
return items
|
95
|
+
|
96
|
+
if path:
|
97
|
+
# If path is provided, get children of that specific directory
|
98
|
+
target_path = os.path.join(root_path, path)
|
99
|
+
if os.path.isdir(target_path):
|
100
|
+
return build_tree(target_path)
|
101
|
+
return []
|
102
|
+
|
103
|
+
# If no path provided, build tree from root with lazy loading
|
104
|
+
return build_tree(root_path)
|
105
|
+
|
106
|
+
|
107
|
+
def read_file_content(project_path: str, file_path: str) -> str:
|
108
|
+
"""Read the content of a file"""
|
109
|
+
try:
|
110
|
+
full_path = os.path.join(project_path, file_path)
|
111
|
+
with open(full_path, 'r', encoding='utf-8') as f:
|
112
|
+
return f.read()
|
113
|
+
except (IOError, UnicodeDecodeError):
|
114
|
+
return None
|
auto_coder_web/hello.py
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
def hello():
|
2
|
+
"""
|
3
|
+
A simple hello function
|
4
|
+
|
5
|
+
Returns:
|
6
|
+
str: A greeting message
|
7
|
+
"""
|
8
|
+
return "Hello, Auto-Coder!"
|
9
|
+
def hello():
|
10
|
+
"""
|
11
|
+
A simple hello function
|
12
|
+
|
13
|
+
Returns:
|
14
|
+
str: A greeting message
|
15
|
+
"""
|
16
|
+
return "Hello, Auto-Coder!"
|
17
|
+
def say_hello(name: str = "World") -> str:
|
18
|
+
"""Returns a greeting message.
|
19
|
+
|
20
|
+
Args:
|
21
|
+
name: The name to greet. Defaults to "World".
|
22
|
+
|
23
|
+
Returns:
|
24
|
+
A greeting string
|
25
|
+
"""
|
26
|
+
return f"Hello, {name}!"
|
27
|
+
def say_hello(name: str = "World") -> str:
|
28
|
+
"""Returns a greeting message.
|
29
|
+
|
30
|
+
Args:
|
31
|
+
name: The name to greet. Defaults to "World".
|
32
|
+
|
33
|
+
Returns:
|
34
|
+
A greeting string
|
35
|
+
"""
|
36
|
+
return f"Hello, {name}!"
|
@@ -0,0 +1,44 @@
|
|
1
|
+
import json
|
2
|
+
import os
|
3
|
+
import aiofiles
|
4
|
+
from typing import Dict, List, Optional
|
5
|
+
|
6
|
+
class JsonFileStorage:
|
7
|
+
def __init__(self, storage_dir: Optional[str] = None):
|
8
|
+
self.storage_dir = storage_dir or os.path.expanduser("~/.auto-coder.web")
|
9
|
+
os.makedirs(self.storage_dir, exist_ok=True)
|
10
|
+
|
11
|
+
self.file_groups_path = os.path.join(self.storage_dir, "file_groups.json")
|
12
|
+
self.project_path_file = os.path.join(self.storage_dir, "project_path.json")
|
13
|
+
|
14
|
+
async def save_file_groups(self, groups: Dict[str, Dict]) -> None:
|
15
|
+
"""Save file groups to JSON file"""
|
16
|
+
async with aiofiles.open(self.file_groups_path, 'w') as f:
|
17
|
+
await f.write(json.dumps(groups, indent=2))
|
18
|
+
|
19
|
+
async def load_file_groups(self) -> Dict[str, Dict]:
|
20
|
+
"""Load file groups from JSON file"""
|
21
|
+
try:
|
22
|
+
async with aiofiles.open(self.file_groups_path, 'r') as f:
|
23
|
+
content = await f.read()
|
24
|
+
return json.loads(content)
|
25
|
+
except (FileNotFoundError, json.JSONDecodeError):
|
26
|
+
return {}
|
27
|
+
|
28
|
+
async def save_project_path(self, path: str) -> None:
|
29
|
+
"""Save project path to JSON file"""
|
30
|
+
async with aiofiles.open(self.project_path_file, 'w') as f:
|
31
|
+
await f.write(json.dumps({"project_path": path}, indent=2))
|
32
|
+
|
33
|
+
async def load_project_path(self) -> Optional[str]:
|
34
|
+
"""Load project path from JSON file"""
|
35
|
+
try:
|
36
|
+
async with aiofiles.open(self.project_path_file, 'r') as f:
|
37
|
+
content = await f.read()
|
38
|
+
data = json.loads(content)
|
39
|
+
return data.get("project_path")
|
40
|
+
except (FileNotFoundError, json.JSONDecodeError):
|
41
|
+
return None
|
42
|
+
|
43
|
+
# Global instance
|
44
|
+
storage = JsonFileStorage()
|