full-stack-coding-assistant-agent 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.
- agents/__init__.py +0 -0
- agents/audit_agent.py +223 -0
- agents/backend_agent.py +179 -0
- agents/base_agent.py +406 -0
- agents/frontend_agent.py +148 -0
- agents/test_agent.py +155 -0
- coordinator/__init__.py +0 -0
- coordinator/coordinator.py +452 -0
- coordinator/dag.py +147 -0
- executor/__init__.py +0 -0
- executor/cb_integration.py +160 -0
- full_stack_coding_assistant_agent/__init__.py +6 -0
- full_stack_coding_assistant_agent/cli.py +10 -0
- full_stack_coding_assistant_agent/main.py +686 -0
- full_stack_coding_assistant_agent-0.1.0.dist-info/METADATA +849 -0
- full_stack_coding_assistant_agent-0.1.0.dist-info/RECORD +31 -0
- full_stack_coding_assistant_agent-0.1.0.dist-info/WHEEL +5 -0
- full_stack_coding_assistant_agent-0.1.0.dist-info/entry_points.txt +2 -0
- full_stack_coding_assistant_agent-0.1.0.dist-info/top_level.txt +7 -0
- model/__init__.py +0 -0
- model/config.py +62 -0
- model/model_router.py +150 -0
- storage/__init__.py +0 -0
- storage/context_db.py +274 -0
- utils/__init__.py +0 -0
- utils/agent_selector.py +243 -0
- utils/config_validator.py +143 -0
- utils/logger.py +95 -0
- utils/output_manager.py +1572 -0
- utils/pdf_reader.py +122 -0
- utils/version.py +188 -0
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"""
|
|
2
|
+
CodeBuddy CLI 集成模块
|
|
3
|
+
通过命令行调用 CodeBuddy CLI 执行代码操作
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import json
|
|
7
|
+
import os
|
|
8
|
+
import subprocess
|
|
9
|
+
import tempfile
|
|
10
|
+
from typing import Dict, List, Optional
|
|
11
|
+
|
|
12
|
+
from model.config import CODEBUDDY_CONFIG
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class CodeBuddyExecutor:
|
|
16
|
+
"""CodeBuddy CLI 执行器(静态方法)"""
|
|
17
|
+
|
|
18
|
+
@staticmethod
|
|
19
|
+
def _run_cli(command: str, args: List[str], timeout: Optional[int] = None) -> Dict:
|
|
20
|
+
"""
|
|
21
|
+
执行 CodeBuddy CLI 命令
|
|
22
|
+
|
|
23
|
+
Args:
|
|
24
|
+
command: CLI 命令(如 apply-edit, run-code)
|
|
25
|
+
args: 命令参数列表
|
|
26
|
+
timeout: 超时时间(秒),None 则使用配置文件中的默认值
|
|
27
|
+
|
|
28
|
+
Returns:
|
|
29
|
+
执行结果字典
|
|
30
|
+
"""
|
|
31
|
+
# 使用配置文件中的 CLI 路径
|
|
32
|
+
cli_path = CODEBUDDY_CONFIG["cli_path"]
|
|
33
|
+
cmd = [cli_path, command] + args
|
|
34
|
+
|
|
35
|
+
# 使用配置文件中的超时时间或传入的参数
|
|
36
|
+
actual_timeout = timeout or CODEBUDDY_CONFIG["timeout"]
|
|
37
|
+
|
|
38
|
+
try:
|
|
39
|
+
result = subprocess.run(
|
|
40
|
+
cmd,
|
|
41
|
+
capture_output=True,
|
|
42
|
+
text=True,
|
|
43
|
+
timeout=actual_timeout,
|
|
44
|
+
)
|
|
45
|
+
return {
|
|
46
|
+
"success": result.returncode == 0,
|
|
47
|
+
"stdout": result.stdout,
|
|
48
|
+
"stderr": result.stderr,
|
|
49
|
+
"returncode": result.returncode,
|
|
50
|
+
}
|
|
51
|
+
except subprocess.TimeoutExpired:
|
|
52
|
+
return {
|
|
53
|
+
"success": False,
|
|
54
|
+
"error": f"命令超时({actual_timeout}秒)",
|
|
55
|
+
}
|
|
56
|
+
except FileNotFoundError:
|
|
57
|
+
return {
|
|
58
|
+
"success": False,
|
|
59
|
+
"error": f"CodeBuddy CLI 未找到: {cli_path}",
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
@staticmethod
|
|
63
|
+
def apply_code_edit(file_path: str, new_code: str) -> Dict:
|
|
64
|
+
"""
|
|
65
|
+
应用代码修改(调用 CodeBuddy CLI)
|
|
66
|
+
|
|
67
|
+
Args:
|
|
68
|
+
file_path: 目标文件路径
|
|
69
|
+
new_code: 新代码内容
|
|
70
|
+
|
|
71
|
+
Returns:
|
|
72
|
+
执行结果
|
|
73
|
+
"""
|
|
74
|
+
# 将代码写入临时文件
|
|
75
|
+
with tempfile.NamedTemporaryFile(mode="w", suffix=".tmp", delete=False) as f:
|
|
76
|
+
f.write(new_code)
|
|
77
|
+
temp_path = f.name
|
|
78
|
+
|
|
79
|
+
result = CodeBuddyExecutor._run_cli(
|
|
80
|
+
"apply-edit",
|
|
81
|
+
["--file", file_path, "--content-file", temp_path],
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
# 清理临时文件
|
|
85
|
+
os.unlink(temp_path)
|
|
86
|
+
|
|
87
|
+
return result
|
|
88
|
+
|
|
89
|
+
@staticmethod
|
|
90
|
+
def run_code(code: str, language: str = "python") -> Dict:
|
|
91
|
+
"""
|
|
92
|
+
在沙箱中运行代码
|
|
93
|
+
|
|
94
|
+
Args:
|
|
95
|
+
code: 代码内容
|
|
96
|
+
language: 编程语言(python/javascript/typescript)
|
|
97
|
+
|
|
98
|
+
Returns:
|
|
99
|
+
执行结果(stdout/stderr)
|
|
100
|
+
"""
|
|
101
|
+
return CodeBuddyExecutor._run_cli(
|
|
102
|
+
"run-code",
|
|
103
|
+
["--language", language, "--code", code],
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
@staticmethod
|
|
107
|
+
def run_tests(test_path: str) -> Dict:
|
|
108
|
+
"""
|
|
109
|
+
运行测试
|
|
110
|
+
|
|
111
|
+
Args:
|
|
112
|
+
test_path: 测试文件路径或目录
|
|
113
|
+
|
|
114
|
+
Returns:
|
|
115
|
+
测试结果
|
|
116
|
+
"""
|
|
117
|
+
return CodeBuddyExecutor._run_cli(
|
|
118
|
+
"run-tests",
|
|
119
|
+
["--path", test_path],
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
@staticmethod
|
|
123
|
+
def review_code(file_path: str) -> Dict:
|
|
124
|
+
"""
|
|
125
|
+
代码审查(调用 CodeBuddy 的 AI 审查能力)
|
|
126
|
+
|
|
127
|
+
Args:
|
|
128
|
+
file_path: 代码文件路径
|
|
129
|
+
|
|
130
|
+
Returns:
|
|
131
|
+
审查结果
|
|
132
|
+
"""
|
|
133
|
+
return CodeBuddyExecutor._run_cli(
|
|
134
|
+
"review",
|
|
135
|
+
["--file", file_path, "--format", "json"],
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
@staticmethod
|
|
139
|
+
def get_suggestions(code: str, cursor_position: int) -> List[Dict]:
|
|
140
|
+
"""
|
|
141
|
+
获取代码补全建议
|
|
142
|
+
|
|
143
|
+
Args:
|
|
144
|
+
code: 当前代码
|
|
145
|
+
cursor_position: 光标位置
|
|
146
|
+
|
|
147
|
+
Returns:
|
|
148
|
+
补全建议列表
|
|
149
|
+
"""
|
|
150
|
+
result = CodeBuddyExecutor._run_cli(
|
|
151
|
+
"suggest",
|
|
152
|
+
["--code", code, "--cursor", str(cursor_position)],
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
if result["success"]:
|
|
156
|
+
try:
|
|
157
|
+
return json.loads(result["stdout"])
|
|
158
|
+
except json.JSONDecodeError:
|
|
159
|
+
return []
|
|
160
|
+
return []
|