auto-coder-web 0.1.55__py3-none-any.whl → 0.1.56__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/proxy.py +2 -1
- auto_coder_web/routers/commit_router.py +16 -38
- auto_coder_web/routers/upload_router.py +53 -0
- auto_coder_web/version.py +1 -1
- auto_coder_web/web/assets/{cssMode-C7Ffvbun.js → cssMode-B9D1QDVI.js} +1 -1
- auto_coder_web/web/assets/{freemarker2-C3Y6D2nF.js → freemarker2-Dicv7qV3.js} +1 -1
- auto_coder_web/web/assets/{handlebars-3udXWLRO.js → handlebars-ANEWa5nN.js} +1 -1
- auto_coder_web/web/assets/{html-C_5YHrtq.js → html-CjLTxV7p.js} +1 -1
- auto_coder_web/web/assets/{htmlMode-OsOJ7Pmh.js → htmlMode-CPF-fncb.js} +1 -1
- auto_coder_web/web/assets/{index-D1XBUj0Z.js → index-B6lJ3lzm.js} +257 -257
- auto_coder_web/web/assets/{javascript-CTPXDi4L.js → javascript-De95hsfT.js} +1 -1
- auto_coder_web/web/assets/{jsonMode-bGTtAsru.js → jsonMode-CiUFt_wa.js} +1 -1
- auto_coder_web/web/assets/{liquid-DUSKiz9O.js → liquid-5eKYrWZN.js} +1 -1
- auto_coder_web/web/assets/{mdx-B7LHQoZi.js → mdx-Bq8_lQjD.js} +1 -1
- auto_coder_web/web/assets/{python-Bw8iUNJc.js → python-DnVtHbtp.js} +1 -1
- auto_coder_web/web/assets/{razor-BvxiGwj6.js → razor-DONQM8ne.js} +1 -1
- auto_coder_web/web/assets/{tsMode-CLB9pI4V.js → tsMode-TPLnL9z4.js} +1 -1
- auto_coder_web/web/assets/{typescript-Cp3zBmo-.js → typescript-D_z80ey2.js} +1 -1
- auto_coder_web/web/assets/{xml-Dz8SFDwn.js → xml-BoVQ-ITO.js} +1 -1
- auto_coder_web/web/assets/{yaml-C_ezErvC.js → yaml-fqI-KrvZ.js} +1 -1
- auto_coder_web/web/index.html +1 -1
- {auto_coder_web-0.1.55.dist-info → auto_coder_web-0.1.56.dist-info}/METADATA +1 -1
- {auto_coder_web-0.1.55.dist-info → auto_coder_web-0.1.56.dist-info}/RECORD +26 -25
- {auto_coder_web-0.1.55.dist-info → auto_coder_web-0.1.56.dist-info}/WHEEL +0 -0
- {auto_coder_web-0.1.55.dist-info → auto_coder_web-0.1.56.dist-info}/entry_points.txt +0 -0
- {auto_coder_web-0.1.55.dist-info → auto_coder_web-0.1.56.dist-info}/top_level.txt +0 -0
auto_coder_web/proxy.py
CHANGED
@@ -19,7 +19,7 @@ import sys
|
|
19
19
|
from auto_coder_web.terminal import terminal_manager
|
20
20
|
from autocoder.common import AutoCoderArgs
|
21
21
|
from auto_coder_web.auto_coder_runner_wrapper import AutoCoderRunnerWrapper
|
22
|
-
from auto_coder_web.routers import todo_router, settings_router, auto_router, commit_router, chat_router, coding_router,index_router,config_router
|
22
|
+
from auto_coder_web.routers import todo_router, settings_router, auto_router, commit_router, chat_router, coding_router,index_router,config_router,upload_router
|
23
23
|
from auto_coder_web.expert_routers import history_router
|
24
24
|
from auto_coder_web.common_router import completions_router, file_router, auto_coder_conf_router, chat_list_router, file_group_router, model_router, compiler_router
|
25
25
|
from rich.console import Console
|
@@ -98,6 +98,7 @@ class ProxyServer:
|
|
98
98
|
self.app.include_router(compiler_router.router)
|
99
99
|
self.app.include_router(index_router.router)
|
100
100
|
self.app.include_router(config_router.router)
|
101
|
+
self.app.include_router(upload_router.router)
|
101
102
|
|
102
103
|
@self.app.on_event("shutdown")
|
103
104
|
async def shutdown_event():
|
@@ -426,20 +426,16 @@ async def get_current_changes(
|
|
426
426
|
logger.info(f"使用事件文件模式获取提交, event_file_id={event_file_id}")
|
427
427
|
try:
|
428
428
|
# 获取事件文件路径
|
429
|
-
event_file_path = get_event_file_path(event_file_id, project_path)
|
430
|
-
logger.info(f"事件文件路径: {event_file_path}")
|
429
|
+
event_file_path = get_event_file_path(event_file_id, project_path)
|
431
430
|
|
432
431
|
# 获取事件管理器
|
433
|
-
event_manager = get_event_manager(event_file_path)
|
434
|
-
logger.info(f"成功获取事件管理器")
|
432
|
+
event_manager = get_event_manager(event_file_path)
|
435
433
|
|
436
434
|
# 获取所有事件
|
437
|
-
all_events = event_manager.event_store.get_events()
|
438
|
-
logger.info(f"获取事件总数: {len(all_events)}")
|
435
|
+
all_events = event_manager.event_store.get_events()
|
439
436
|
|
440
437
|
# 创建ActionYmlFileManager实例
|
441
|
-
action_manager = ActionYmlFileManager(project_path)
|
442
|
-
logger.info(f"成功创建ActionYmlFileManager实例")
|
438
|
+
action_manager = ActionYmlFileManager(project_path)
|
443
439
|
|
444
440
|
action_files = set()
|
445
441
|
final_action_files = []
|
@@ -447,37 +443,28 @@ async def get_current_changes(
|
|
447
443
|
# 记录事件中包含action_file字段的事件数量
|
448
444
|
action_file_count = 0
|
449
445
|
|
450
|
-
for i, event in enumerate(all_events):
|
451
|
-
logger.debug(f"处理事件 {i+1}/{len(all_events)}, 事件类型: {event.event_type}")
|
446
|
+
for i, event in enumerate(all_events):
|
452
447
|
# 检查元数据中是否有action_file字段
|
453
448
|
if 'action_file' in event.metadata and event.metadata['action_file']:
|
454
449
|
action_file_count += 1
|
455
|
-
action_file = event.metadata['action_file']
|
456
|
-
logger.debug(f"事件 {i+1} 包含action_file: {action_file}")
|
450
|
+
action_file = event.metadata['action_file']
|
457
451
|
|
458
|
-
if action_file in action_files:
|
459
|
-
logger.debug(f"跳过重复的action_file: {action_file}")
|
452
|
+
if action_file in action_files:
|
460
453
|
continue
|
461
454
|
|
462
455
|
action_files.add(action_file)
|
463
456
|
# 从action文件获取提交ID
|
464
457
|
# action_file 这里的值是 类似这样的 actions/000000000104_chat_action.yml
|
465
458
|
if action_file.startswith("actions"):
|
466
|
-
action_file = action_file[len("actions/"):]
|
467
|
-
logger.debug(f"处理后的action_file: {action_file}")
|
459
|
+
action_file = action_file[len("actions/"):]
|
468
460
|
|
469
461
|
final_action_files.append(action_file)
|
470
|
-
|
471
|
-
logger.info(f"从 {len(all_events)} 个事件中提取到 {action_file_count} 个包含action_file的事件")
|
472
|
-
logger.info(f"去重后得到 {len(action_files)} 个唯一action_file")
|
473
|
-
logger.info(f"最终处理的action_files: {final_action_files}")
|
462
|
+
|
474
463
|
|
475
464
|
commits = []
|
476
|
-
for i, action_file in enumerate(final_action_files):
|
477
|
-
logger.info(f"处理action文件 {i+1}/{len(final_action_files)}: {action_file}")
|
465
|
+
for i, action_file in enumerate(final_action_files):
|
478
466
|
commit_ids = action_manager.get_all_commit_id_from_file(action_file)
|
479
|
-
|
480
|
-
logger.info(f"从action文件 {action_file} 获取到的提交ID列表: {commit_ids}")
|
467
|
+
|
481
468
|
|
482
469
|
if not commit_ids:
|
483
470
|
logger.warning(f"无法从action文件 {action_file} 获取提交ID")
|
@@ -492,8 +479,7 @@ async def get_current_changes(
|
|
492
479
|
for cid in commit_ids:
|
493
480
|
try:
|
494
481
|
commit = repo.commit(cid)
|
495
|
-
message = commit.message.strip()
|
496
|
-
logger.info(f"检查提交 {cid[:7]} 是否为revert提交,消息: {message[:50]}...")
|
482
|
+
message = commit.message.strip()
|
497
483
|
|
498
484
|
if message.startswith("<revert>"):
|
499
485
|
logger.info(f"找到revert提交: {cid}")
|
@@ -503,20 +489,16 @@ async def get_current_changes(
|
|
503
489
|
logger.warning(f"检查提交 {cid} 时出错: {str(e)}")
|
504
490
|
|
505
491
|
# 如果找到revert提交,只处理这个提交
|
506
|
-
if revert_commit_id:
|
507
|
-
logger.info(f"将只处理revert提交: {revert_commit_id}")
|
492
|
+
if revert_commit_id:
|
508
493
|
commit_ids = [revert_commit_id]
|
509
494
|
|
510
495
|
# 处理所有提交ID(或者只处理revert提交)
|
511
496
|
for commit_id in commit_ids:
|
512
497
|
# 验证提交ID是否存在于仓库中
|
513
|
-
try:
|
514
|
-
logger.info(f"获取提交详情: {commit_id}")
|
498
|
+
try:
|
515
499
|
commit = repo.commit(commit_id)
|
516
500
|
# 获取提交统计信息
|
517
|
-
stats = commit.stats.total
|
518
|
-
logger.info(f"提交统计信息: 插入={stats['insertions']}, 删除={stats['deletions']}, 文件变更={stats['files']}")
|
519
|
-
|
501
|
+
stats = commit.stats.total
|
520
502
|
# 构建提交信息
|
521
503
|
commit_info = {
|
522
504
|
"hash": commit.hexsha,
|
@@ -532,18 +514,14 @@ async def get_current_changes(
|
|
532
514
|
}
|
533
515
|
}
|
534
516
|
commits.append(commit_info)
|
535
|
-
logger.info(f"成功添加提交信息到结果列表,当前结果数: {len(commits)}")
|
536
517
|
except Exception as e:
|
537
518
|
logger.warning(f"无法获取提交 {commit_id} 的详情: {str(e)}")
|
538
519
|
|
539
|
-
logger.info(f"处理完所有action文件,共找到 {len(commits)} 个提交")
|
540
520
|
|
541
521
|
# 按提交时间戳排序(降序 - 最新的在前面)
|
542
522
|
if commits:
|
543
523
|
commits.sort(key=lambda x: x['timestamp'], reverse=True)
|
544
|
-
|
545
|
-
|
546
|
-
logger.info(f"返回结果: {len(commits)} 个提交")
|
524
|
+
|
547
525
|
return {"commits": commits, "total": len(commits)}
|
548
526
|
|
549
527
|
except Exception as e:
|
@@ -0,0 +1,53 @@
|
|
1
|
+
import os
|
2
|
+
import hashlib
|
3
|
+
import time
|
4
|
+
from fastapi import APIRouter, UploadFile, File, HTTPException, Request
|
5
|
+
from fastapi.responses import JSONResponse
|
6
|
+
from pathlib import Path
|
7
|
+
from typing import Optional
|
8
|
+
|
9
|
+
router = APIRouter()
|
10
|
+
|
11
|
+
async def get_project_path(request: Request) -> str:
|
12
|
+
"""从FastAPI请求上下文中获取项目路径"""
|
13
|
+
return request.app.state.project_path
|
14
|
+
|
15
|
+
async def get_upload_path(project_path: str) -> Path:
|
16
|
+
"""获取上传目录路径"""
|
17
|
+
upload_path = Path(project_path) / ".auto-coder" / "auto-coder.web" / "uploads"
|
18
|
+
upload_path.mkdir(parents=True, exist_ok=True)
|
19
|
+
return upload_path
|
20
|
+
|
21
|
+
def generate_filename(file: UploadFile) -> str:
|
22
|
+
"""生成唯一的文件名: md5(原始文件名) + 时间戳"""
|
23
|
+
filename_hash = hashlib.md5(file.filename.encode()).hexdigest()
|
24
|
+
timestamp = int(time.time())
|
25
|
+
ext = os.path.splitext(file.filename)[1]
|
26
|
+
return f"{filename_hash}_{timestamp}{ext}"
|
27
|
+
|
28
|
+
@router.post("/api/upload/image")
|
29
|
+
async def upload_image(
|
30
|
+
request: Request,
|
31
|
+
file: UploadFile = File(...)
|
32
|
+
):
|
33
|
+
"""上传图片文件"""
|
34
|
+
if not file.content_type.startswith('image/'):
|
35
|
+
raise HTTPException(status_code=400, detail="Only image files are allowed")
|
36
|
+
|
37
|
+
project_path = await get_project_path(request)
|
38
|
+
upload_path = await get_upload_path(project_path)
|
39
|
+
|
40
|
+
filename = generate_filename(file)
|
41
|
+
file_path = upload_path / filename
|
42
|
+
|
43
|
+
try:
|
44
|
+
contents = await file.read()
|
45
|
+
with open(file_path, 'wb') as f:
|
46
|
+
f.write(contents)
|
47
|
+
except Exception as e:
|
48
|
+
raise HTTPException(status_code=500, detail=f"Error uploading file: {str(e)}")
|
49
|
+
|
50
|
+
return JSONResponse({
|
51
|
+
"success": True,
|
52
|
+
"path": os.path.join(".",".auto-coder", "auto-coder.web", "uploads", filename)
|
53
|
+
})
|
auto_coder_web/version.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = "0.1.
|
1
|
+
__version__ = "0.1.56"
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import{m as et}from"./index-
|
1
|
+
import{m as et}from"./index-B6lJ3lzm.js";/*!-----------------------------------------------------------------------------
|
2
2
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
3
3
|
* Version: 0.52.2(404545bded1df6ffa41ea0af4e8ddb219018c6c1)
|
4
4
|
* Released under the MIT license
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import{m as f}from"./index-
|
1
|
+
import{m as f}from"./index-B6lJ3lzm.js";/*!-----------------------------------------------------------------------------
|
2
2
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
3
3
|
* Version: 0.52.2(404545bded1df6ffa41ea0af4e8ddb219018c6c1)
|
4
4
|
* Released under the MIT license
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import{m as l}from"./index-
|
1
|
+
import{m as l}from"./index-B6lJ3lzm.js";/*!-----------------------------------------------------------------------------
|
2
2
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
3
3
|
* Version: 0.52.2(404545bded1df6ffa41ea0af4e8ddb219018c6c1)
|
4
4
|
* Released under the MIT license
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import{m as s}from"./index-
|
1
|
+
import{m as s}from"./index-B6lJ3lzm.js";/*!-----------------------------------------------------------------------------
|
2
2
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
3
3
|
* Version: 0.52.2(404545bded1df6ffa41ea0af4e8ddb219018c6c1)
|
4
4
|
* Released under the MIT license
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import{m as lt}from"./index-
|
1
|
+
import{m as lt}from"./index-B6lJ3lzm.js";/*!-----------------------------------------------------------------------------
|
2
2
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
3
3
|
* Version: 0.52.2(404545bded1df6ffa41ea0af4e8ddb219018c6c1)
|
4
4
|
* Released under the MIT license
|