jarvis-ai-assistant 0.1.72__tar.gz → 0.1.74__tar.gz
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 jarvis-ai-assistant might be problematic. Click here for more details.
- {jarvis_ai_assistant-0.1.72/src/jarvis_ai_assistant.egg-info → jarvis_ai_assistant-0.1.74}/PKG-INFO +1 -1
- {jarvis_ai_assistant-0.1.72 → jarvis_ai_assistant-0.1.74}/pyproject.toml +1 -1
- {jarvis_ai_assistant-0.1.72 → jarvis_ai_assistant-0.1.74}/setup.py +1 -1
- {jarvis_ai_assistant-0.1.72 → jarvis_ai_assistant-0.1.74}/src/jarvis/__init__.py +1 -1
- {jarvis_ai_assistant-0.1.72 → jarvis_ai_assistant-0.1.74}/src/jarvis/agent.py +1 -0
- {jarvis_ai_assistant-0.1.72 → jarvis_ai_assistant-0.1.74}/src/jarvis/jarvis_codebase/main.py +149 -33
- {jarvis_ai_assistant-0.1.72 → jarvis_ai_assistant-0.1.74}/src/jarvis/jarvis_coder/main.py +79 -10
- {jarvis_ai_assistant-0.1.72 → jarvis_ai_assistant-0.1.74}/src/jarvis/tools/codebase_qa.py +4 -0
- {jarvis_ai_assistant-0.1.72 → jarvis_ai_assistant-0.1.74/src/jarvis_ai_assistant.egg-info}/PKG-INFO +1 -1
- {jarvis_ai_assistant-0.1.72 → jarvis_ai_assistant-0.1.74}/LICENSE +0 -0
- {jarvis_ai_assistant-0.1.72 → jarvis_ai_assistant-0.1.74}/MANIFEST.in +0 -0
- {jarvis_ai_assistant-0.1.72 → jarvis_ai_assistant-0.1.74}/README.md +0 -0
- {jarvis_ai_assistant-0.1.72 → jarvis_ai_assistant-0.1.74}/setup.cfg +0 -0
- {jarvis_ai_assistant-0.1.72 → jarvis_ai_assistant-0.1.74}/src/jarvis/jarvis_codebase/__init__.py +0 -0
- {jarvis_ai_assistant-0.1.72 → jarvis_ai_assistant-0.1.74}/src/jarvis/jarvis_coder/__init__.py +0 -0
- {jarvis_ai_assistant-0.1.72 → jarvis_ai_assistant-0.1.74}/src/jarvis/main.py +0 -0
- {jarvis_ai_assistant-0.1.72 → jarvis_ai_assistant-0.1.74}/src/jarvis/models/__init__.py +0 -0
- {jarvis_ai_assistant-0.1.72 → jarvis_ai_assistant-0.1.74}/src/jarvis/models/ai8.py +0 -0
- {jarvis_ai_assistant-0.1.72 → jarvis_ai_assistant-0.1.74}/src/jarvis/models/base.py +0 -0
- {jarvis_ai_assistant-0.1.72 → jarvis_ai_assistant-0.1.74}/src/jarvis/models/kimi.py +0 -0
- {jarvis_ai_assistant-0.1.72 → jarvis_ai_assistant-0.1.74}/src/jarvis/models/openai.py +0 -0
- {jarvis_ai_assistant-0.1.72 → jarvis_ai_assistant-0.1.74}/src/jarvis/models/oyi.py +0 -0
- {jarvis_ai_assistant-0.1.72 → jarvis_ai_assistant-0.1.74}/src/jarvis/models/registry.py +0 -0
- {jarvis_ai_assistant-0.1.72 → jarvis_ai_assistant-0.1.74}/src/jarvis/tools/__init__.py +0 -0
- {jarvis_ai_assistant-0.1.72 → jarvis_ai_assistant-0.1.74}/src/jarvis/tools/base.py +0 -0
- {jarvis_ai_assistant-0.1.72 → jarvis_ai_assistant-0.1.74}/src/jarvis/tools/coder.py +0 -0
- {jarvis_ai_assistant-0.1.72 → jarvis_ai_assistant-0.1.74}/src/jarvis/tools/file_ops.py +0 -0
- {jarvis_ai_assistant-0.1.72 → jarvis_ai_assistant-0.1.74}/src/jarvis/tools/generator.py +0 -0
- {jarvis_ai_assistant-0.1.72 → jarvis_ai_assistant-0.1.74}/src/jarvis/tools/methodology.py +0 -0
- {jarvis_ai_assistant-0.1.72 → jarvis_ai_assistant-0.1.74}/src/jarvis/tools/registry.py +0 -0
- {jarvis_ai_assistant-0.1.72 → jarvis_ai_assistant-0.1.74}/src/jarvis/tools/search.py +0 -0
- {jarvis_ai_assistant-0.1.72 → jarvis_ai_assistant-0.1.74}/src/jarvis/tools/shell.py +0 -0
- {jarvis_ai_assistant-0.1.72 → jarvis_ai_assistant-0.1.74}/src/jarvis/tools/sub_agent.py +0 -0
- {jarvis_ai_assistant-0.1.72 → jarvis_ai_assistant-0.1.74}/src/jarvis/tools/webpage.py +0 -0
- {jarvis_ai_assistant-0.1.72 → jarvis_ai_assistant-0.1.74}/src/jarvis/utils.py +0 -0
- {jarvis_ai_assistant-0.1.72 → jarvis_ai_assistant-0.1.74}/src/jarvis_ai_assistant.egg-info/SOURCES.txt +0 -0
- {jarvis_ai_assistant-0.1.72 → jarvis_ai_assistant-0.1.74}/src/jarvis_ai_assistant.egg-info/dependency_links.txt +0 -0
- {jarvis_ai_assistant-0.1.72 → jarvis_ai_assistant-0.1.74}/src/jarvis_ai_assistant.egg-info/entry_points.txt +0 -0
- {jarvis_ai_assistant-0.1.72 → jarvis_ai_assistant-0.1.74}/src/jarvis_ai_assistant.egg-info/requires.txt +0 -0
- {jarvis_ai_assistant-0.1.72 → jarvis_ai_assistant-0.1.74}/src/jarvis_ai_assistant.egg-info/top_level.txt +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "jarvis-ai-assistant"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.74"
|
|
8
8
|
description = "Jarvis: An AI assistant that uses tools to interact with the system"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
authors = [{ name = "Your Name", email = "your.email@example.com" }]
|
|
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
|
|
|
2
2
|
|
|
3
3
|
setup(
|
|
4
4
|
name="jarvis-ai-assistant",
|
|
5
|
-
version="0.1.
|
|
5
|
+
version="0.1.74",
|
|
6
6
|
author="skyfire",
|
|
7
7
|
author_email="skyfireitdiy@hotmail.com",
|
|
8
8
|
description="An AI assistant that uses various tools to interact with the system",
|
{jarvis_ai_assistant-0.1.72 → jarvis_ai_assistant-0.1.74}/src/jarvis/jarvis_codebase/main.py
RENAMED
|
@@ -310,27 +310,103 @@ class CodeBase:
|
|
|
310
310
|
self.build_index()
|
|
311
311
|
self.save_cache()
|
|
312
312
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
313
|
+
|
|
314
|
+
def generate_codebase(self, force: bool = False):
|
|
315
|
+
"""生成代码库索引
|
|
316
|
+
Args:
|
|
317
|
+
force: 是否强制重建索引,不询问用户
|
|
318
|
+
"""
|
|
319
|
+
# 更新 git 文件列表
|
|
320
|
+
self.git_file_list = self.get_git_file_list()
|
|
321
|
+
|
|
322
|
+
# 检查文件变化
|
|
323
|
+
changes_detected = False
|
|
324
|
+
new_files = []
|
|
325
|
+
modified_files = []
|
|
326
|
+
deleted_files = []
|
|
317
327
|
|
|
318
|
-
#
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
+
# 检查删除的文件
|
|
329
|
+
files_to_delete = []
|
|
330
|
+
for file_path in list(self.vector_cache.keys()):
|
|
331
|
+
if file_path not in self.git_file_list:
|
|
332
|
+
deleted_files.append(file_path)
|
|
333
|
+
files_to_delete.append(file_path)
|
|
334
|
+
changes_detected = True
|
|
335
|
+
|
|
336
|
+
# 检查新增和修改的文件
|
|
337
|
+
for file_path in self.git_file_list:
|
|
338
|
+
if not os.path.exists(file_path) or not self.is_text_file(file_path):
|
|
339
|
+
continue
|
|
340
|
+
|
|
341
|
+
try:
|
|
342
|
+
current_md5 = hashlib.md5(open(file_path, "rb").read()).hexdigest()
|
|
343
|
+
|
|
344
|
+
if file_path not in self.vector_cache:
|
|
345
|
+
new_files.append(file_path)
|
|
346
|
+
changes_detected = True
|
|
347
|
+
elif self.vector_cache[file_path].get("md5") != current_md5:
|
|
348
|
+
modified_files.append(file_path)
|
|
349
|
+
changes_detected = True
|
|
350
|
+
except Exception as e:
|
|
351
|
+
PrettyOutput.print(f"检查文件失败 {file_path}: {str(e)}",
|
|
352
|
+
output_type=OutputType.ERROR)
|
|
353
|
+
continue
|
|
354
|
+
|
|
355
|
+
# 如果检测到变化,显示变化并询问用户
|
|
356
|
+
if changes_detected:
|
|
357
|
+
PrettyOutput.print("\n检测到以下变化:", output_type=OutputType.WARNING)
|
|
358
|
+
if new_files:
|
|
359
|
+
PrettyOutput.print("\n新增文件:", output_type=OutputType.INFO)
|
|
360
|
+
for f in new_files:
|
|
361
|
+
PrettyOutput.print(f" {f}", output_type=OutputType.INFO)
|
|
362
|
+
if modified_files:
|
|
363
|
+
PrettyOutput.print("\n修改的文件:", output_type=OutputType.INFO)
|
|
364
|
+
for f in modified_files:
|
|
365
|
+
PrettyOutput.print(f" {f}", output_type=OutputType.INFO)
|
|
366
|
+
if deleted_files:
|
|
367
|
+
PrettyOutput.print("\n删除的文件:", output_type=OutputType.INFO)
|
|
368
|
+
for f in deleted_files:
|
|
369
|
+
PrettyOutput.print(f" {f}", output_type=OutputType.INFO)
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
# 如果force为True,直接继续
|
|
373
|
+
if not force:
|
|
374
|
+
# 询问用户是否继续
|
|
375
|
+
while True:
|
|
376
|
+
response = input("\n是否重建索引?[y/N] ").lower().strip()
|
|
377
|
+
if response in ['y', 'yes']:
|
|
378
|
+
break
|
|
379
|
+
elif response in ['', 'n', 'no']:
|
|
380
|
+
PrettyOutput.print("取消重建索引", output_type=OutputType.INFO)
|
|
381
|
+
return
|
|
382
|
+
else:
|
|
383
|
+
PrettyOutput.print("请输入 y 或 n", output_type=OutputType.WARNING)
|
|
384
|
+
|
|
385
|
+
# 清理已删除的文件
|
|
386
|
+
for file_path in files_to_delete:
|
|
387
|
+
del self.vector_cache[file_path]
|
|
388
|
+
if files_to_delete:
|
|
389
|
+
PrettyOutput.print(f"清理了 {len(files_to_delete)} 个文件的缓存",
|
|
390
|
+
output_type=OutputType.INFO)
|
|
391
|
+
|
|
392
|
+
# 处理新文件和修改的文件
|
|
393
|
+
processed_files = []
|
|
394
|
+
files_to_process = new_files + modified_files
|
|
395
|
+
|
|
396
|
+
# 使用线程池处理文件
|
|
397
|
+
with ThreadPoolExecutor(max_workers=self.thread_count) as executor:
|
|
398
|
+
futures = [executor.submit(self.process_file, file) for file in files_to_process]
|
|
399
|
+
for future in concurrent.futures.as_completed(futures):
|
|
400
|
+
result = future.result()
|
|
401
|
+
if result:
|
|
402
|
+
processed_files.append(result)
|
|
403
|
+
PrettyOutput.print(f"索引文件: {result}", output_type=OutputType.INFO)
|
|
404
|
+
|
|
328
405
|
PrettyOutput.print("重新生成向量数据库", output_type=OutputType.INFO)
|
|
329
406
|
self.gen_vector_db_from_cache()
|
|
407
|
+
PrettyOutput.print(f"成功为 {len(processed_files)} 个文件生成索引", output_type=OutputType.INFO)
|
|
330
408
|
else:
|
|
331
|
-
PrettyOutput.print("
|
|
332
|
-
|
|
333
|
-
PrettyOutput.print(f"成功为 {len(processed_files)} 个文件生成索引", output_type=OutputType.INFO)
|
|
409
|
+
PrettyOutput.print("没有检测到文件变更,无需重建索引", output_type=OutputType.INFO)
|
|
334
410
|
|
|
335
411
|
def rerank_results(self, query: str, initial_results: List[Tuple[str, float, str]]) -> List[Tuple[str, float, str]]:
|
|
336
412
|
"""使用大模型对搜索结果重新排序"""
|
|
@@ -377,10 +453,12 @@ class CodeBase:
|
|
|
377
453
|
try:
|
|
378
454
|
file_path, score_str = line.split(':', 1)
|
|
379
455
|
file_path = file_path.strip()
|
|
380
|
-
score = float(score_str.strip())
|
|
381
|
-
#
|
|
382
|
-
|
|
383
|
-
|
|
456
|
+
score = float(score_str.strip()) / 100.0 # 转换为0-1范围
|
|
457
|
+
# 只保留相关度大于等于0.7的结果
|
|
458
|
+
if score >= 0.7:
|
|
459
|
+
# 找到对应的原始描述
|
|
460
|
+
desc = next((desc for p, _, desc in initial_results if p == file_path), "")
|
|
461
|
+
scored_results.append((file_path, score, desc))
|
|
384
462
|
except:
|
|
385
463
|
continue
|
|
386
464
|
|
|
@@ -413,8 +491,6 @@ class CodeBase:
|
|
|
413
491
|
PrettyOutput.print(f"查询: {query}", output_type=OutputType.INFO)
|
|
414
492
|
|
|
415
493
|
# 为每个查询获取相似文件
|
|
416
|
-
all_results = {} # 文件路径 -> (总分数, 出现次数, 描述)
|
|
417
|
-
|
|
418
494
|
q_vector = self.get_embedding(query)
|
|
419
495
|
q_vector = q_vector.reshape(1, -1)
|
|
420
496
|
|
|
@@ -429,12 +505,18 @@ class CodeBase:
|
|
|
429
505
|
continue
|
|
430
506
|
|
|
431
507
|
similarity = 1.0 / (1.0 + float(distance))
|
|
432
|
-
|
|
433
|
-
|
|
508
|
+
# 只保留相似度大于等于0.5的结果
|
|
509
|
+
if similarity >= 0.5:
|
|
510
|
+
PrettyOutput.print(f" {self.file_paths[i]} : 距离 {distance:.3f}, 相似度 {similarity:.3f}",
|
|
511
|
+
output_type=OutputType.INFO)
|
|
434
512
|
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
513
|
+
file_path = self.file_paths[i]
|
|
514
|
+
data = self.vector_cache[file_path]
|
|
515
|
+
initial_results.append((file_path, similarity, data["description"]))
|
|
516
|
+
|
|
517
|
+
if not initial_results:
|
|
518
|
+
PrettyOutput.print("没有找到相似度大于0.5的文件", output_type=OutputType.WARNING)
|
|
519
|
+
return []
|
|
438
520
|
|
|
439
521
|
# 使用大模型重新排序
|
|
440
522
|
PrettyOutput.print("使用大模型重新排序...", output_type=OutputType.INFO)
|
|
@@ -482,22 +564,56 @@ class CodeBase:
|
|
|
482
564
|
finally:
|
|
483
565
|
model.delete_chat()
|
|
484
566
|
|
|
567
|
+
def is_index_generated(self) -> bool:
|
|
568
|
+
"""检查索引是否已经生成"""
|
|
569
|
+
# 检查缓存文件是否存在
|
|
570
|
+
if not os.path.exists(self.cache_path):
|
|
571
|
+
return False
|
|
572
|
+
|
|
573
|
+
# 检查缓存是否有效
|
|
574
|
+
try:
|
|
575
|
+
with open(self.cache_path, 'rb') as f:
|
|
576
|
+
cache_data = pickle.load(f)
|
|
577
|
+
if not cache_data.get("vectors") or not cache_data.get("file_paths"):
|
|
578
|
+
return False
|
|
579
|
+
except Exception:
|
|
580
|
+
return False
|
|
581
|
+
|
|
582
|
+
# 检查索引是否已构建
|
|
583
|
+
if not hasattr(self, 'index') or self.index is None:
|
|
584
|
+
return False
|
|
585
|
+
|
|
586
|
+
# 检查向量缓存和文件路径列表是否非空
|
|
587
|
+
if not self.vector_cache or not self.file_paths:
|
|
588
|
+
return False
|
|
589
|
+
|
|
590
|
+
return True
|
|
591
|
+
|
|
592
|
+
|
|
485
593
|
|
|
486
594
|
def main():
|
|
487
595
|
parser = argparse.ArgumentParser(description='Codebase management and search tool')
|
|
488
596
|
parser.add_argument('--search', type=str, help='Search query to find similar code files')
|
|
489
597
|
parser.add_argument('--top-k', type=int, default=20, help='Number of results to return (default: 20)')
|
|
490
598
|
parser.add_argument('--ask', type=str, help='Ask a question about the codebase')
|
|
599
|
+
parser.add_argument('--generate', action='store_true', help='Generate codebase index')
|
|
491
600
|
args = parser.parse_args()
|
|
492
601
|
|
|
493
602
|
current_dir = find_git_root()
|
|
494
603
|
codebase = CodeBase(current_dir)
|
|
495
604
|
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
PrettyOutput.print("
|
|
499
|
-
|
|
500
|
-
|
|
605
|
+
# 如果没有生成索引,且不是生成命令,提示用户先生成索引
|
|
606
|
+
if not codebase.is_index_generated() and not args.generate:
|
|
607
|
+
PrettyOutput.print("索引尚未生成,请先运行 --generate 生成索引", output_type=OutputType.WARNING)
|
|
608
|
+
return
|
|
609
|
+
|
|
610
|
+
|
|
611
|
+
if args.generate:
|
|
612
|
+
try:
|
|
613
|
+
codebase.generate_codebase(force=True)
|
|
614
|
+
PrettyOutput.print("\nCodebase generation completed", output_type=OutputType.SUCCESS)
|
|
615
|
+
except Exception as e:
|
|
616
|
+
PrettyOutput.print(f"Error during codebase generation: {str(e)}", output_type=OutputType.ERROR)
|
|
501
617
|
|
|
502
618
|
if args.search:
|
|
503
619
|
results = codebase.search_similar(args.search, args.top_k)
|
|
@@ -278,12 +278,12 @@ class JarvisCoder:
|
|
|
278
278
|
|
|
279
279
|
return True, ""
|
|
280
280
|
|
|
281
|
-
def _save_edit_record(self,
|
|
281
|
+
def _save_edit_record(self, commit_message: str, git_diff: str) -> None:
|
|
282
282
|
"""保存代码修改记录
|
|
283
283
|
|
|
284
284
|
Args:
|
|
285
|
-
|
|
286
|
-
|
|
285
|
+
commit_message: 提交信息
|
|
286
|
+
git_diff: git diff --cached的输出
|
|
287
287
|
"""
|
|
288
288
|
|
|
289
289
|
# 获取下一个序号
|
|
@@ -296,8 +296,8 @@ class JarvisCoder:
|
|
|
296
296
|
# 创建记录文件
|
|
297
297
|
record = {
|
|
298
298
|
"timestamp": time.strftime("%Y-%m-%d %H:%M:%S"),
|
|
299
|
-
"
|
|
300
|
-
"
|
|
299
|
+
"commit_message": commit_message,
|
|
300
|
+
"git_diff": git_diff
|
|
301
301
|
}
|
|
302
302
|
|
|
303
303
|
record_path = os.path.join(self.record_dir, f"{next_num:04d}.yaml")
|
|
@@ -308,14 +308,21 @@ class JarvisCoder:
|
|
|
308
308
|
|
|
309
309
|
|
|
310
310
|
|
|
311
|
+
|
|
311
312
|
def _prepare_execution(self) -> None:
|
|
312
313
|
"""准备执行环境"""
|
|
313
314
|
self.main_model = self._new_model()
|
|
314
315
|
self._codebase.generate_codebase()
|
|
315
316
|
|
|
317
|
+
|
|
316
318
|
def _load_related_files(self, feature: str) -> List[Dict]:
|
|
317
319
|
"""加载相关文件内容"""
|
|
318
320
|
ret = []
|
|
321
|
+
# 确保索引数据库已生成
|
|
322
|
+
if not self._codebase.is_index_generated():
|
|
323
|
+
PrettyOutput.print("检测到索引数据库未生成,正在生成...", OutputType.WARNING)
|
|
324
|
+
self._codebase.generate_codebase()
|
|
325
|
+
|
|
319
326
|
related_files = self._codebase.search_similar(feature)
|
|
320
327
|
for file, score, _ in related_files:
|
|
321
328
|
PrettyOutput.print(f"相关文件: {file} 相关度: {score:.3f}", OutputType.SUCCESS)
|
|
@@ -339,7 +346,7 @@ class JarvisCoder:
|
|
|
339
346
|
if success:
|
|
340
347
|
user_confirm = input("是否确认修改?(y/n)")
|
|
341
348
|
if user_confirm.lower() == "y":
|
|
342
|
-
self._finalize_changes(feature
|
|
349
|
+
self._finalize_changes(feature)
|
|
343
350
|
return {
|
|
344
351
|
"success": True,
|
|
345
352
|
"stdout": f"已完成功能开发{feature}",
|
|
@@ -369,12 +376,74 @@ class JarvisCoder:
|
|
|
369
376
|
"""
|
|
370
377
|
patches = self._remake_patch(retry_prompt)
|
|
371
378
|
|
|
372
|
-
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
def _generate_commit_message(self, git_diff: str, feature: str) -> str:
|
|
383
|
+
"""根据git diff和功能描述生成commit信息
|
|
384
|
+
|
|
385
|
+
Args:
|
|
386
|
+
git_diff: git diff --cached的输出
|
|
387
|
+
feature: 用户的功能描述
|
|
388
|
+
|
|
389
|
+
Returns:
|
|
390
|
+
str: 生成的commit信息
|
|
391
|
+
"""
|
|
392
|
+
|
|
393
|
+
# 生成提示词
|
|
394
|
+
prompt = f"""你是一个经验丰富的程序员,请根据以下代码变更和功能描述生成简洁明了的commit信息:
|
|
395
|
+
|
|
396
|
+
功能描述:
|
|
397
|
+
{feature}
|
|
398
|
+
|
|
399
|
+
代码变更:
|
|
400
|
+
"""
|
|
401
|
+
# 添加git diff内容
|
|
402
|
+
prompt += f"Git Diff:\n{git_diff}\n\n"
|
|
403
|
+
|
|
404
|
+
prompt += """
|
|
405
|
+
请遵循以下规则:
|
|
406
|
+
1. 使用英文编写
|
|
407
|
+
2. 采用常规的commit message格式:<type>(<scope>): <subject>
|
|
408
|
+
3. 保持简洁,不超过50个字符
|
|
409
|
+
4. 准确描述代码变更的主要内容
|
|
410
|
+
5. 优先考虑功能描述和git diff中的变更内容
|
|
411
|
+
"""
|
|
412
|
+
|
|
413
|
+
# 使用normal模型生成commit信息
|
|
414
|
+
model = PlatformRegistry().get_global_platform_registry().create_platform(self.platform)
|
|
415
|
+
model.set_model_name(self.model)
|
|
416
|
+
model.set_suppress_output(True)
|
|
417
|
+
success, response = self._call_model_with_retry(model, prompt)
|
|
418
|
+
if not success:
|
|
419
|
+
return "Update code changes"
|
|
420
|
+
|
|
421
|
+
# 清理响应内容
|
|
422
|
+
return response.strip().split("\n")[0]
|
|
423
|
+
|
|
424
|
+
def _finalize_changes(self, feature: str) -> None:
|
|
373
425
|
"""完成修改并提交"""
|
|
374
426
|
PrettyOutput.print("修改确认成功,提交修改", OutputType.INFO)
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
427
|
+
|
|
428
|
+
# 只添加已经在 git 控制下的修改文件
|
|
429
|
+
os.system("git add -u")
|
|
430
|
+
|
|
431
|
+
# 然后获取 git diff
|
|
432
|
+
git_diff = os.popen("git diff --cached").read()
|
|
433
|
+
|
|
434
|
+
# 自动生成commit信息,传入feature
|
|
435
|
+
commit_message = self._generate_commit_message(git_diff, feature)
|
|
436
|
+
|
|
437
|
+
# 显示并确认commit信息
|
|
438
|
+
PrettyOutput.print(f"自动生成的commit信息: {commit_message}", OutputType.INFO)
|
|
439
|
+
user_confirm = input("是否使用该commit信息?(y/n) [y]: ") or "y"
|
|
440
|
+
|
|
441
|
+
if user_confirm.lower() != "y":
|
|
442
|
+
commit_message = input("请输入新的commit信息: ")
|
|
443
|
+
|
|
444
|
+
# 不需要再次 git add,因为已经添加过了
|
|
445
|
+
os.system(f"git commit -m '{commit_message}'")
|
|
446
|
+
self._save_edit_record(commit_message, git_diff)
|
|
378
447
|
|
|
379
448
|
def _revert_changes(self) -> None:
|
|
380
449
|
"""回退所有修改"""
|
|
@@ -45,8 +45,12 @@ class CodebaseQATool:
|
|
|
45
45
|
"stderr": "错误:当前目录不在Git仓库中",
|
|
46
46
|
"error": "NotInGitRepository"
|
|
47
47
|
}
|
|
48
|
+
|
|
48
49
|
os.chdir(root_dir)
|
|
49
50
|
codebase = CodeBase(root_dir)
|
|
51
|
+
# 生成索引
|
|
52
|
+
|
|
53
|
+
codebase.generate_codebase(force=True)
|
|
50
54
|
# 执行问答
|
|
51
55
|
response = codebase.ask_codebase(question, top_k)
|
|
52
56
|
os.chdir(current_dir)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{jarvis_ai_assistant-0.1.72 → jarvis_ai_assistant-0.1.74}/src/jarvis/jarvis_codebase/__init__.py
RENAMED
|
File without changes
|
{jarvis_ai_assistant-0.1.72 → jarvis_ai_assistant-0.1.74}/src/jarvis/jarvis_coder/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|