auto-coder 0.1.331__py3-none-any.whl → 0.1.333__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.
Potentially problematic release.
This version of auto-coder might be problematic. Click here for more details.
- {auto_coder-0.1.331.dist-info → auto_coder-0.1.333.dist-info}/METADATA +1 -1
- {auto_coder-0.1.331.dist-info → auto_coder-0.1.333.dist-info}/RECORD +28 -26
- autocoder/agent/agentic_filter.py +929 -0
- autocoder/auto_coder.py +5 -23
- autocoder/auto_coder_runner.py +2 -0
- autocoder/commands/auto_command.py +1 -1
- autocoder/commands/tools.py +68 -3
- autocoder/common/__init__.py +2 -0
- autocoder/common/auto_coder_lang.py +9 -1
- autocoder/common/code_modification_ranker.py +6 -2
- autocoder/common/conf_utils.py +36 -0
- autocoder/common/stream_out_type.py +4 -2
- autocoder/common/types.py +2 -2
- autocoder/common/v2/code_auto_merge_editblock.py +1 -1
- autocoder/common/v2/code_diff_manager.py +73 -6
- autocoder/common/v2/code_editblock_manager.py +480 -163
- autocoder/compilers/provided_compiler.py +39 -0
- autocoder/helper/project_creator.py +282 -100
- autocoder/index/entry.py +35 -10
- autocoder/linters/reactjs_linter.py +55 -61
- autocoder/linters/shadow_linter.py +4 -0
- autocoder/shadows/shadow_manager.py +1 -1
- autocoder/utils/project_structure.py +2 -2
- autocoder/version.py +1 -1
- {auto_coder-0.1.331.dist-info → auto_coder-0.1.333.dist-info}/LICENSE +0 -0
- {auto_coder-0.1.331.dist-info → auto_coder-0.1.333.dist-info}/WHEEL +0 -0
- {auto_coder-0.1.331.dist-info → auto_coder-0.1.333.dist-info}/entry_points.txt +0 -0
- {auto_coder-0.1.331.dist-info → auto_coder-0.1.333.dist-info}/top_level.txt +0 -0
|
@@ -11,6 +11,7 @@ from typing import Dict, List, Any, Optional, Union
|
|
|
11
11
|
import time
|
|
12
12
|
from pathlib import Path
|
|
13
13
|
|
|
14
|
+
from autocoder.common import AutoCoderArgs
|
|
14
15
|
from autocoder.compilers.base_compiler import BaseCompiler
|
|
15
16
|
from autocoder.compilers.models import (
|
|
16
17
|
CompilationError,
|
|
@@ -19,6 +20,7 @@ from autocoder.compilers.models import (
|
|
|
19
20
|
CompilationErrorPosition,
|
|
20
21
|
CompilationErrorSeverity
|
|
21
22
|
)
|
|
23
|
+
from autocoder.utils.project_structure import EnhancedFileAnalyzer
|
|
22
24
|
|
|
23
25
|
|
|
24
26
|
class ProvidedCompiler(BaseCompiler):
|
|
@@ -233,6 +235,33 @@ class ProvidedCompiler(BaseCompiler):
|
|
|
233
235
|
'file_path': file_path,
|
|
234
236
|
'language': 'unknown'
|
|
235
237
|
}
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
def get_all_extensions(self, directory: str = ".") -> str:
|
|
241
|
+
"""获取指定目录下所有文件的后缀名,多个按逗号分隔,并且带."""
|
|
242
|
+
args = AutoCoderArgs(
|
|
243
|
+
source_dir=directory,
|
|
244
|
+
# 其他必要参数设置为默认值
|
|
245
|
+
target_file="",
|
|
246
|
+
git_url="",
|
|
247
|
+
project_type="",
|
|
248
|
+
conversation_prune_safe_zone_tokens=0
|
|
249
|
+
)
|
|
250
|
+
|
|
251
|
+
analyzer = EnhancedFileAnalyzer(
|
|
252
|
+
args=args,
|
|
253
|
+
llm=None, # 如果只是获取后缀名,可以不需要LLM
|
|
254
|
+
config=None # 使用默认配置
|
|
255
|
+
)
|
|
256
|
+
|
|
257
|
+
# 获取分析结果
|
|
258
|
+
analysis_result = analyzer.analyze_extensions()
|
|
259
|
+
|
|
260
|
+
# 合并 code 和 config 的后缀名
|
|
261
|
+
all_extensions = set(analysis_result["code"] + analysis_result["config"])
|
|
262
|
+
|
|
263
|
+
# 转换为逗号分隔的字符串
|
|
264
|
+
return ",".join(sorted(all_extensions))
|
|
236
265
|
|
|
237
266
|
def compile_project(self, project_path: str,target_compiler_name:Optional[str] = None) -> ProjectCompilationResult:
|
|
238
267
|
"""
|
|
@@ -257,6 +286,16 @@ class ProvidedCompiler(BaseCompiler):
|
|
|
257
286
|
return result
|
|
258
287
|
|
|
259
288
|
target_compiler_config = None
|
|
289
|
+
if not target_compiler_name:
|
|
290
|
+
for compiler_config in self.config.get('compilers', []):
|
|
291
|
+
working_dir = os.path.join(project_path,compiler_config.get('working_dir', '.'))
|
|
292
|
+
print(working_dir)
|
|
293
|
+
all_extensions = self.get_all_extensions(working_dir)
|
|
294
|
+
triggers = compiler_config.get("triggers",[])
|
|
295
|
+
if any(trigger in all_extensions for trigger in triggers):
|
|
296
|
+
target_compiler_config = compiler_config
|
|
297
|
+
break
|
|
298
|
+
|
|
260
299
|
if target_compiler_name:
|
|
261
300
|
for compiler_config in self.config.get('compilers', []):
|
|
262
301
|
if compiler_config.get("name","") == target_compiler_name:
|
|
@@ -130,34 +130,40 @@ if __name__ == "__main__":
|
|
|
130
130
|
|
|
131
131
|
class ReactJSFileCreator(FileCreator):
|
|
132
132
|
"""
|
|
133
|
-
React TypeScript 计算器项目文件创建器
|
|
133
|
+
Vite + React TypeScript 计算器项目文件创建器
|
|
134
134
|
"""
|
|
135
135
|
|
|
136
136
|
def create_files(self, project_dir: str) -> None:
|
|
137
|
-
"""创建 React TypeScript 项目文件"""
|
|
137
|
+
"""创建 Vite + React TypeScript 项目文件"""
|
|
138
138
|
# 创建 package.json
|
|
139
139
|
self._create_package_json(project_dir)
|
|
140
140
|
# 创建 index.html
|
|
141
141
|
self._create_index_html(project_dir)
|
|
142
|
+
# 创建 vite.config.ts
|
|
143
|
+
self._create_vite_config(project_dir)
|
|
142
144
|
# 创建 src 目录
|
|
143
145
|
src_dir = os.path.join(project_dir, "src")
|
|
144
146
|
os.makedirs(src_dir, exist_ok=True)
|
|
145
147
|
# 创建 App.tsx 和 Calculator.tsx 组件
|
|
146
148
|
self._create_app_tsx(src_dir)
|
|
147
149
|
self._create_calculator_component(src_dir)
|
|
148
|
-
self.
|
|
149
|
-
# 创建 tsconfig.json
|
|
150
|
+
self._create_main_tsx(src_dir)
|
|
151
|
+
# 创建 tsconfig.json 和 tsconfig.node.json
|
|
150
152
|
self._create_tsconfig_json(project_dir)
|
|
153
|
+
self._create_tsconfig_node_json(project_dir)
|
|
154
|
+
# 创建 .gitignore
|
|
155
|
+
self._create_gitignore(project_dir)
|
|
151
156
|
|
|
152
157
|
def get_file_paths(self, project_dir: str) -> List[str]:
|
|
153
|
-
"""获取 React TypeScript 项目的主要文件路径"""
|
|
158
|
+
"""获取 Vite + React TypeScript 项目的主要文件路径"""
|
|
154
159
|
abs_project_dir = os.path.abspath(project_dir)
|
|
155
160
|
return [
|
|
156
161
|
os.path.join(abs_project_dir, "package.json"),
|
|
162
|
+
os.path.join(abs_project_dir, "vite.config.ts"),
|
|
157
163
|
os.path.join(abs_project_dir, "tsconfig.json"),
|
|
158
164
|
os.path.join(abs_project_dir, "src", "App.tsx"),
|
|
159
165
|
os.path.join(abs_project_dir, "src", "Calculator.tsx"),
|
|
160
|
-
os.path.join(abs_project_dir, "src", "
|
|
166
|
+
os.path.join(abs_project_dir, "src", "main.tsx")
|
|
161
167
|
]
|
|
162
168
|
|
|
163
169
|
@property
|
|
@@ -167,20 +173,17 @@ class ReactJSFileCreator(FileCreator):
|
|
|
167
173
|
|
|
168
174
|
def _create_index_html(self, project_dir: str) -> None:
|
|
169
175
|
"""创建 index.html 文件"""
|
|
170
|
-
index_html_path = os.path.join(project_dir, "
|
|
171
|
-
os.makedirs(os.path.dirname(index_html_path), exist_ok=True)
|
|
176
|
+
index_html_path = os.path.join(project_dir, "index.html")
|
|
172
177
|
index_html_content = """<!DOCTYPE html>
|
|
173
178
|
<html lang="en">
|
|
174
179
|
<head>
|
|
175
|
-
<meta charset="
|
|
176
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
177
|
-
<
|
|
178
|
-
<meta name="description" content="React Calculator App" />
|
|
179
|
-
<title>React Calculator</title>
|
|
180
|
+
<meta charset="UTF-8" />
|
|
181
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
182
|
+
<title>Vite + React Calculator</title>
|
|
180
183
|
</head>
|
|
181
184
|
<body>
|
|
182
|
-
<noscript>You need to enable JavaScript to run this app.</noscript>
|
|
183
185
|
<div id="root"></div>
|
|
186
|
+
<script type="module" src="/src/main.tsx"></script>
|
|
184
187
|
</body>
|
|
185
188
|
</html>"""
|
|
186
189
|
with open(index_html_path, "w", encoding="utf-8") as f:
|
|
@@ -191,133 +194,213 @@ class ReactJSFileCreator(FileCreator):
|
|
|
191
194
|
package_path = os.path.join(project_dir, "package.json")
|
|
192
195
|
package_content = """{
|
|
193
196
|
"name": "calculator-app",
|
|
194
|
-
"version": "0.1.0",
|
|
195
197
|
"private": true,
|
|
196
|
-
"
|
|
197
|
-
|
|
198
|
-
"react-dom": "^18.2.0",
|
|
199
|
-
"react-scripts": "5.0.1",
|
|
200
|
-
"@types/node": "^16.18.0",
|
|
201
|
-
"@types/react": "^18.2.0",
|
|
202
|
-
"@types/react-dom": "^18.2.0",
|
|
203
|
-
"typescript": "^4.9.5"
|
|
204
|
-
},
|
|
198
|
+
"version": "0.1.0",
|
|
199
|
+
"type": "module",
|
|
205
200
|
"scripts": {
|
|
206
|
-
"
|
|
207
|
-
"build": "
|
|
208
|
-
"
|
|
209
|
-
"
|
|
201
|
+
"dev": "vite",
|
|
202
|
+
"build": "tsc && vite build",
|
|
203
|
+
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
|
204
|
+
"preview": "vite preview"
|
|
210
205
|
},
|
|
211
|
-
"
|
|
212
|
-
"
|
|
213
|
-
|
|
214
|
-
"react-app/jest"
|
|
215
|
-
]
|
|
206
|
+
"dependencies": {
|
|
207
|
+
"react": "^18.2.0",
|
|
208
|
+
"react-dom": "^18.2.0"
|
|
216
209
|
},
|
|
217
|
-
"
|
|
218
|
-
"
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
"
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
210
|
+
"devDependencies": {
|
|
211
|
+
"@types/react": "^18.2.15",
|
|
212
|
+
"@types/react-dom": "^18.2.7",
|
|
213
|
+
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
|
214
|
+
"@typescript-eslint/parser": "^6.0.0",
|
|
215
|
+
"@vitejs/plugin-react": "^4.0.3",
|
|
216
|
+
"eslint": "^8.45.0",
|
|
217
|
+
"eslint-plugin-react-hooks": "^4.6.0",
|
|
218
|
+
"eslint-plugin-react-refresh": "^0.4.3",
|
|
219
|
+
"typescript": "^5.0.2",
|
|
220
|
+
"vite": "^4.4.5"
|
|
228
221
|
}
|
|
229
222
|
}"""
|
|
230
223
|
with open(package_path, "w", encoding="utf-8") as f:
|
|
231
224
|
f.write(package_content)
|
|
232
225
|
|
|
226
|
+
def _create_vite_config(self, project_dir: str) -> None:
|
|
227
|
+
"""创建 vite.config.ts 文件"""
|
|
228
|
+
vite_config_path = os.path.join(project_dir, "vite.config.ts")
|
|
229
|
+
vite_config_content = """import { defineConfig } from 'vite'
|
|
230
|
+
import react from '@vitejs/plugin-react'
|
|
231
|
+
|
|
232
|
+
// https://vitejs.dev/config/
|
|
233
|
+
export default defineConfig({
|
|
234
|
+
plugins: [react()],
|
|
235
|
+
})
|
|
236
|
+
"""
|
|
237
|
+
with open(vite_config_path, "w", encoding="utf-8") as f:
|
|
238
|
+
f.write(vite_config_content)
|
|
239
|
+
|
|
233
240
|
def _create_tsconfig_json(self, project_dir: str) -> None:
|
|
234
241
|
"""创建 tsconfig.json 文件"""
|
|
235
242
|
tsconfig_path = os.path.join(project_dir, "tsconfig.json")
|
|
236
243
|
tsconfig_content = """{
|
|
237
244
|
"compilerOptions": {
|
|
238
|
-
"target": "
|
|
239
|
-
"
|
|
240
|
-
"
|
|
245
|
+
"target": "ES2020",
|
|
246
|
+
"useDefineForClassFields": true,
|
|
247
|
+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
|
248
|
+
"module": "ESNext",
|
|
241
249
|
"skipLibCheck": true,
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
"
|
|
245
|
-
"
|
|
246
|
-
"noFallthroughCasesInSwitch": true,
|
|
247
|
-
"module": "esnext",
|
|
248
|
-
"moduleResolution": "node",
|
|
250
|
+
|
|
251
|
+
/* Bundler mode */
|
|
252
|
+
"moduleResolution": "bundler",
|
|
253
|
+
"allowImportingTsExtensions": true,
|
|
249
254
|
"resolveJsonModule": true,
|
|
250
255
|
"isolatedModules": true,
|
|
251
256
|
"noEmit": true,
|
|
252
|
-
"jsx": "react-jsx"
|
|
257
|
+
"jsx": "react-jsx",
|
|
258
|
+
|
|
259
|
+
/* Linting */
|
|
260
|
+
"strict": true,
|
|
261
|
+
"noUnusedLocals": true,
|
|
262
|
+
"noUnusedParameters": true,
|
|
263
|
+
"noFallthroughCasesInSwitch": true
|
|
253
264
|
},
|
|
254
|
-
"include": ["src"]
|
|
265
|
+
"include": ["src"],
|
|
266
|
+
"references": [{ "path": "./tsconfig.node.json" }]
|
|
255
267
|
}"""
|
|
256
268
|
with open(tsconfig_path, "w", encoding="utf-8") as f:
|
|
257
269
|
f.write(tsconfig_content)
|
|
258
270
|
|
|
271
|
+
def _create_tsconfig_node_json(self, project_dir: str) -> None:
|
|
272
|
+
"""创建 tsconfig.node.json 文件"""
|
|
273
|
+
tsconfig_node_path = os.path.join(project_dir, "tsconfig.node.json")
|
|
274
|
+
tsconfig_node_content = """{
|
|
275
|
+
"compilerOptions": {
|
|
276
|
+
"composite": true,
|
|
277
|
+
"skipLibCheck": true,
|
|
278
|
+
"module": "ESNext",
|
|
279
|
+
"moduleResolution": "bundler",
|
|
280
|
+
"allowSyntheticDefaultImports": true
|
|
281
|
+
},
|
|
282
|
+
"include": ["vite.config.ts"]
|
|
283
|
+
}"""
|
|
284
|
+
with open(tsconfig_node_path, "w", encoding="utf-8") as f:
|
|
285
|
+
f.write(tsconfig_node_content)
|
|
286
|
+
|
|
287
|
+
def _create_gitignore(self, project_dir: str) -> None:
|
|
288
|
+
"""创建 .gitignore 文件"""
|
|
289
|
+
gitignore_path = os.path.join(project_dir, ".gitignore")
|
|
290
|
+
gitignore_content = """# Logs
|
|
291
|
+
logs
|
|
292
|
+
*.log
|
|
293
|
+
npm-debug.log*
|
|
294
|
+
yarn-debug.log*
|
|
295
|
+
yarn-error.log*
|
|
296
|
+
pnpm-debug.log*
|
|
297
|
+
lerna-debug.log*
|
|
298
|
+
|
|
299
|
+
node_modules
|
|
300
|
+
dist
|
|
301
|
+
dist-ssr
|
|
302
|
+
*.local
|
|
303
|
+
|
|
304
|
+
# Editor directories and files
|
|
305
|
+
.vscode/*
|
|
306
|
+
!.vscode/extensions.json
|
|
307
|
+
.idea
|
|
308
|
+
.DS_Store
|
|
309
|
+
*.suo
|
|
310
|
+
*.ntvs*
|
|
311
|
+
*.njsproj
|
|
312
|
+
*.sln
|
|
313
|
+
*.sw?
|
|
314
|
+
"""
|
|
315
|
+
with open(gitignore_path, "w", encoding="utf-8") as f:
|
|
316
|
+
f.write(gitignore_content)
|
|
317
|
+
|
|
259
318
|
def _create_app_tsx(self, src_dir: str) -> None:
|
|
260
319
|
"""创建 App.tsx 文件"""
|
|
261
320
|
app_path = os.path.join(src_dir, "App.tsx")
|
|
262
|
-
app_content = """import
|
|
263
|
-
import Calculator from './Calculator'
|
|
321
|
+
app_content = """import { useState } from 'react'
|
|
322
|
+
import Calculator from './Calculator'
|
|
323
|
+
import './App.css'
|
|
264
324
|
|
|
265
|
-
|
|
325
|
+
function App() {
|
|
266
326
|
return (
|
|
267
327
|
<div className="App">
|
|
268
328
|
<header className="App-header">
|
|
269
|
-
<h1>React Calculator</h1>
|
|
329
|
+
<h1>Vite + React Calculator</h1>
|
|
270
330
|
</header>
|
|
271
331
|
<main>
|
|
272
332
|
<Calculator />
|
|
273
333
|
</main>
|
|
274
334
|
</div>
|
|
275
|
-
)
|
|
276
|
-
}
|
|
335
|
+
)
|
|
336
|
+
}
|
|
277
337
|
|
|
278
|
-
export default App
|
|
338
|
+
export default App
|
|
339
|
+
"""
|
|
279
340
|
with open(app_path, "w", encoding="utf-8") as f:
|
|
280
341
|
f.write(app_content)
|
|
342
|
+
|
|
343
|
+
# 创建 App.css 文件
|
|
344
|
+
app_css_path = os.path.join(src_dir, "App.css")
|
|
345
|
+
app_css_content = """.App {
|
|
346
|
+
max-width: 1280px;
|
|
347
|
+
margin: 0 auto;
|
|
348
|
+
padding: 2rem;
|
|
349
|
+
text-align: center;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
.App-header {
|
|
353
|
+
margin-bottom: 2rem;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
.App-header h1 {
|
|
357
|
+
font-size: 2.5em;
|
|
358
|
+
line-height: 1.1;
|
|
359
|
+
}
|
|
360
|
+
"""
|
|
361
|
+
with open(app_css_path, "w", encoding="utf-8") as f:
|
|
362
|
+
f.write(app_css_content)
|
|
281
363
|
|
|
282
364
|
def _create_calculator_component(self, src_dir: str) -> None:
|
|
283
365
|
"""创建 Calculator.tsx 组件"""
|
|
284
366
|
calculator_path = os.path.join(src_dir, "Calculator.tsx")
|
|
285
|
-
calculator_content = """import
|
|
367
|
+
calculator_content = """import { useState } from 'react'
|
|
368
|
+
import './Calculator.css'
|
|
286
369
|
|
|
287
370
|
interface CalculatorProps {}
|
|
288
371
|
|
|
289
372
|
const Calculator: React.FC<CalculatorProps> = () => {
|
|
290
|
-
const [display, setDisplay] = useState<string>('0')
|
|
291
|
-
const [equation, setEquation] = useState<string>('')
|
|
373
|
+
const [display, setDisplay] = useState<string>('0')
|
|
374
|
+
const [equation, setEquation] = useState<string>('')
|
|
292
375
|
|
|
293
376
|
const handleNumber = (num: string) => {
|
|
294
377
|
if (display === '0') {
|
|
295
|
-
setDisplay(num)
|
|
378
|
+
setDisplay(num)
|
|
296
379
|
} else {
|
|
297
|
-
setDisplay(display + num)
|
|
380
|
+
setDisplay(display + num)
|
|
298
381
|
}
|
|
299
|
-
}
|
|
382
|
+
}
|
|
300
383
|
|
|
301
384
|
const handleOperator = (operator: string) => {
|
|
302
|
-
setEquation(display + ' ' + operator + ' ')
|
|
303
|
-
setDisplay('0')
|
|
304
|
-
}
|
|
385
|
+
setEquation(display + ' ' + operator + ' ')
|
|
386
|
+
setDisplay('0')
|
|
387
|
+
}
|
|
305
388
|
|
|
306
389
|
const handleEqual = () => {
|
|
307
390
|
try {
|
|
308
|
-
const result = eval(equation + display)
|
|
309
|
-
setDisplay(result.toString())
|
|
310
|
-
setEquation('')
|
|
391
|
+
const result = eval(equation + display)
|
|
392
|
+
setDisplay(result.toString())
|
|
393
|
+
setEquation('')
|
|
311
394
|
} catch (error) {
|
|
312
|
-
setDisplay('Error')
|
|
313
|
-
setEquation('')
|
|
395
|
+
setDisplay('Error')
|
|
396
|
+
setEquation('')
|
|
314
397
|
}
|
|
315
|
-
}
|
|
398
|
+
}
|
|
316
399
|
|
|
317
400
|
const handleClear = () => {
|
|
318
|
-
setDisplay('0')
|
|
319
|
-
setEquation('')
|
|
320
|
-
}
|
|
401
|
+
setDisplay('0')
|
|
402
|
+
setEquation('')
|
|
403
|
+
}
|
|
321
404
|
|
|
322
405
|
return (
|
|
323
406
|
<div className="calculator">
|
|
@@ -345,31 +428,130 @@ const Calculator: React.FC<CalculatorProps> = () => {
|
|
|
345
428
|
<button onClick={() => handleNumber('.')}>.</button>
|
|
346
429
|
</div>
|
|
347
430
|
</div>
|
|
348
|
-
)
|
|
349
|
-
}
|
|
431
|
+
)
|
|
432
|
+
}
|
|
350
433
|
|
|
351
|
-
export default Calculator
|
|
434
|
+
export default Calculator
|
|
435
|
+
"""
|
|
352
436
|
with open(calculator_path, "w", encoding="utf-8") as f:
|
|
353
437
|
f.write(calculator_content)
|
|
438
|
+
|
|
439
|
+
# 创建 Calculator.css 文件
|
|
440
|
+
calculator_css_path = os.path.join(src_dir, "Calculator.css")
|
|
441
|
+
calculator_css_content = """.calculator {
|
|
442
|
+
width: 300px;
|
|
443
|
+
margin: 0 auto;
|
|
444
|
+
border: 1px solid #ccc;
|
|
445
|
+
border-radius: 5px;
|
|
446
|
+
padding: 10px;
|
|
447
|
+
background-color: #f7f7f7;
|
|
448
|
+
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
.display {
|
|
452
|
+
background-color: #fff;
|
|
453
|
+
border: 1px solid #ddd;
|
|
454
|
+
border-radius: 3px;
|
|
455
|
+
margin-bottom: 10px;
|
|
456
|
+
padding: 10px;
|
|
457
|
+
text-align: right;
|
|
458
|
+
min-height: 60px;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
.equation {
|
|
462
|
+
color: #777;
|
|
463
|
+
font-size: 14px;
|
|
464
|
+
min-height: 20px;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
.current {
|
|
468
|
+
font-size: 24px;
|
|
469
|
+
font-weight: bold;
|
|
470
|
+
margin-top: 5px;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
.buttons {
|
|
474
|
+
display: grid;
|
|
475
|
+
grid-template-columns: repeat(4, 1fr);
|
|
476
|
+
gap: 5px;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
button {
|
|
480
|
+
background-color: #e0e0e0;
|
|
481
|
+
border: 1px solid #ccc;
|
|
482
|
+
border-radius: 3px;
|
|
483
|
+
font-size: 18px;
|
|
484
|
+
padding: 10px;
|
|
485
|
+
cursor: pointer;
|
|
486
|
+
transition: background-color 0.2s;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
button:hover {
|
|
490
|
+
background-color: #d0d0d0;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
button:active {
|
|
494
|
+
background-color: #c0c0c0;
|
|
495
|
+
}
|
|
496
|
+
"""
|
|
497
|
+
with open(calculator_css_path, "w", encoding="utf-8") as f:
|
|
498
|
+
f.write(calculator_css_content)
|
|
354
499
|
|
|
355
|
-
def
|
|
356
|
-
"""创建
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
import ReactDOM from 'react-dom/client'
|
|
360
|
-
import App from './App'
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
);
|
|
365
|
-
|
|
366
|
-
root.render(
|
|
500
|
+
def _create_main_tsx(self, src_dir: str) -> None:
|
|
501
|
+
"""创建 main.tsx 文件"""
|
|
502
|
+
main_path = os.path.join(src_dir, "main.tsx")
|
|
503
|
+
main_content = """import React from 'react'
|
|
504
|
+
import ReactDOM from 'react-dom/client'
|
|
505
|
+
import App from './App'
|
|
506
|
+
import './index.css'
|
|
507
|
+
|
|
508
|
+
ReactDOM.createRoot(document.getElementById('root')!).render(
|
|
367
509
|
<React.StrictMode>
|
|
368
510
|
<App />
|
|
369
|
-
</React.StrictMode
|
|
370
|
-
)
|
|
371
|
-
|
|
372
|
-
|
|
511
|
+
</React.StrictMode>,
|
|
512
|
+
)
|
|
513
|
+
"""
|
|
514
|
+
with open(main_path, "w", encoding="utf-8") as f:
|
|
515
|
+
f.write(main_content)
|
|
516
|
+
|
|
517
|
+
# 创建 index.css 文件
|
|
518
|
+
index_css_path = os.path.join(src_dir, "index.css")
|
|
519
|
+
index_css_content = """:root {
|
|
520
|
+
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
|
|
521
|
+
line-height: 1.5;
|
|
522
|
+
font-weight: 400;
|
|
523
|
+
|
|
524
|
+
color-scheme: light dark;
|
|
525
|
+
color: rgba(255, 255, 255, 0.87);
|
|
526
|
+
background-color: #242424;
|
|
527
|
+
|
|
528
|
+
font-synthesis: none;
|
|
529
|
+
text-rendering: optimizeLegibility;
|
|
530
|
+
-webkit-font-smoothing: antialiased;
|
|
531
|
+
-moz-osx-font-smoothing: grayscale;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
@media (prefers-color-scheme: light) {
|
|
535
|
+
:root {
|
|
536
|
+
color: #213547;
|
|
537
|
+
background-color: #ffffff;
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
body {
|
|
542
|
+
margin: 0;
|
|
543
|
+
display: flex;
|
|
544
|
+
place-items: center;
|
|
545
|
+
min-width: 320px;
|
|
546
|
+
min-height: 100vh;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
* {
|
|
550
|
+
box-sizing: border-box;
|
|
551
|
+
}
|
|
552
|
+
"""
|
|
553
|
+
with open(index_css_path, "w", encoding="utf-8") as f:
|
|
554
|
+
f.write(index_css_content)
|
|
373
555
|
|
|
374
556
|
|
|
375
557
|
class FileCreatorFactory:
|
autocoder/index/entry.py
CHANGED
|
@@ -30,6 +30,7 @@ from autocoder.common.action_yml_file_manager import ActionYmlFileManager
|
|
|
30
30
|
|
|
31
31
|
from autocoder.events.event_manager_singleton import get_event_manager
|
|
32
32
|
from autocoder.events import event_content as EventContentCreator
|
|
33
|
+
from autocoder.agent.agentic_filter import AgenticFilter
|
|
33
34
|
|
|
34
35
|
|
|
35
36
|
def build_index_and_filter_files(
|
|
@@ -94,22 +95,46 @@ def build_index_and_filter_files(
|
|
|
94
95
|
phase_end = time.monotonic()
|
|
95
96
|
stats["timings"]["build_index"] = phase_end - phase_start
|
|
96
97
|
|
|
97
|
-
|
|
98
98
|
if not args.skip_filter_index and args.index_filter_model:
|
|
99
|
+
|
|
99
100
|
model_name = getattr(
|
|
100
101
|
index_manager.index_filter_llm, 'default_model_name', None)
|
|
101
102
|
if not model_name:
|
|
102
103
|
model_name = "unknown(without default model name)"
|
|
103
|
-
printer.print_in_terminal(
|
|
104
|
-
"quick_filter_start", style="blue", model_name=model_name)
|
|
105
|
-
quick_filter = QuickFilter(index_manager, stats, sources)
|
|
106
|
-
quick_filter_result = quick_filter.filter(
|
|
107
|
-
index_manager.read_index(), args.query)
|
|
108
104
|
|
|
109
|
-
|
|
105
|
+
if args.enable_agentic_filter:
|
|
106
|
+
from autocoder.agent.agentic_filter import AgenticFilterRequest, AgenticFilter, CommandConfig, MemoryConfig
|
|
107
|
+
from autocoder.common.conf_utils import load_memory
|
|
108
|
+
|
|
109
|
+
_memory = load_memory(args)
|
|
110
|
+
|
|
111
|
+
def save_memory_func():
|
|
112
|
+
pass
|
|
113
|
+
|
|
114
|
+
tuner = AgenticFilter(index_manager.index_filter_llm,
|
|
115
|
+
args=args,
|
|
116
|
+
conversation_history=[],
|
|
117
|
+
memory_config=MemoryConfig(
|
|
118
|
+
memory=_memory, save_memory_func=save_memory_func),
|
|
119
|
+
command_config=None)
|
|
120
|
+
response = tuner.analyze(
|
|
121
|
+
AgenticFilterRequest(user_input=args.query))
|
|
122
|
+
if response:
|
|
123
|
+
for file in response.files:
|
|
124
|
+
final_files[file.path] = TargetFile(
|
|
125
|
+
file_path=file.path, reason="Agentic Filter")
|
|
126
|
+
else:
|
|
127
|
+
printer.print_in_terminal(
|
|
128
|
+
"quick_filter_start", style="blue", model_name=model_name)
|
|
129
|
+
|
|
130
|
+
quick_filter = QuickFilter(index_manager, stats, sources)
|
|
131
|
+
quick_filter_result = quick_filter.filter(
|
|
132
|
+
index_manager.read_index(), args.query)
|
|
133
|
+
|
|
134
|
+
final_files.update(quick_filter_result.files)
|
|
110
135
|
|
|
111
|
-
|
|
112
|
-
|
|
136
|
+
if quick_filter_result.file_positions:
|
|
137
|
+
file_positions.update(quick_filter_result.file_positions)
|
|
113
138
|
|
|
114
139
|
if not args.skip_filter_index and not args.index_filter_model:
|
|
115
140
|
model_name = getattr(index_manager.llm, 'default_model_name', None)
|
|
@@ -352,7 +377,7 @@ def build_index_and_filter_files(
|
|
|
352
377
|
).to_dict()
|
|
353
378
|
),
|
|
354
379
|
metadata=EventMetadata(
|
|
355
|
-
action_file=args.file
|
|
380
|
+
action_file=args.file
|
|
356
381
|
).to_dict()
|
|
357
382
|
)
|
|
358
383
|
|