auto-coder 0.1.264__py3-none-any.whl → 0.1.265__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.

Files changed (50) hide show
  1. {auto_coder-0.1.264.dist-info → auto_coder-0.1.265.dist-info}/METADATA +1 -1
  2. {auto_coder-0.1.264.dist-info → auto_coder-0.1.265.dist-info}/RECORD +50 -48
  3. autocoder/agent/planner.py +4 -4
  4. autocoder/auto_coder.py +26 -21
  5. autocoder/auto_coder_server.py +7 -7
  6. autocoder/chat_auto_coder.py +150 -49
  7. autocoder/commands/auto_command.py +81 -4
  8. autocoder/commands/tools.py +48 -50
  9. autocoder/common/__init__.py +0 -1
  10. autocoder/common/auto_coder_lang.py +37 -3
  11. autocoder/common/code_auto_generate.py +3 -3
  12. autocoder/common/code_auto_generate_diff.py +3 -6
  13. autocoder/common/code_auto_generate_editblock.py +3 -3
  14. autocoder/common/code_auto_generate_strict_diff.py +3 -3
  15. autocoder/common/code_auto_merge_diff.py +2 -2
  16. autocoder/common/code_auto_merge_editblock.py +1 -1
  17. autocoder/common/code_auto_merge_strict_diff.py +3 -3
  18. autocoder/common/command_completer.py +3 -0
  19. autocoder/common/command_generator.py +24 -8
  20. autocoder/common/command_templates.py +2 -2
  21. autocoder/common/conf_import_export.py +105 -0
  22. autocoder/common/conf_validator.py +1 -1
  23. autocoder/common/files.py +41 -2
  24. autocoder/common/image_to_page.py +11 -11
  25. autocoder/common/index_import_export.py +38 -18
  26. autocoder/common/mcp_hub.py +3 -3
  27. autocoder/common/mcp_server.py +2 -2
  28. autocoder/common/shells.py +254 -13
  29. autocoder/common/stats_panel.py +126 -0
  30. autocoder/dispacher/actions/action.py +6 -18
  31. autocoder/dispacher/actions/copilot.py +2 -2
  32. autocoder/dispacher/actions/plugins/action_regex_project.py +1 -3
  33. autocoder/dispacher/actions/plugins/action_translate.py +1 -1
  34. autocoder/index/index.py +5 -5
  35. autocoder/models.py +2 -2
  36. autocoder/pyproject/__init__.py +5 -5
  37. autocoder/rag/cache/byzer_storage_cache.py +4 -4
  38. autocoder/rag/cache/file_monitor_cache.py +2 -2
  39. autocoder/rag/cache/simple_cache.py +4 -4
  40. autocoder/rag/long_context_rag.py +2 -2
  41. autocoder/regexproject/__init__.py +3 -2
  42. autocoder/suffixproject/__init__.py +3 -2
  43. autocoder/tsproject/__init__.py +3 -2
  44. autocoder/utils/conversation_store.py +1 -1
  45. autocoder/utils/operate_config_api.py +3 -3
  46. autocoder/version.py +1 -1
  47. {auto_coder-0.1.264.dist-info → auto_coder-0.1.265.dist-info}/LICENSE +0 -0
  48. {auto_coder-0.1.264.dist-info → auto_coder-0.1.265.dist-info}/WHEEL +0 -0
  49. {auto_coder-0.1.264.dist-info → auto_coder-0.1.265.dist-info}/entry_points.txt +0 -0
  50. {auto_coder-0.1.264.dist-info → auto_coder-0.1.265.dist-info}/top_level.txt +0 -0
@@ -134,6 +134,7 @@ commands = [
134
134
  "/index/export",
135
135
  "/index/import",
136
136
  "/exclude_dirs",
137
+ "/exclude_files",
137
138
  "/help",
138
139
  "/shell",
139
140
  "/voice_input",
@@ -145,6 +146,8 @@ commands = [
145
146
  "/mcp",
146
147
  "/models",
147
148
  "/auto",
149
+ "/conf/export",
150
+ "/conf/import",
148
151
  ]
149
152
 
150
153
 
@@ -604,7 +607,7 @@ def get_symbol_list() -> List[SymbolItem]:
604
607
  index_file = os.path.join(".auto-coder", "index.json")
605
608
 
606
609
  if os.path.exists(index_file):
607
- with open(index_file, "r") as file:
610
+ with open(index_file, "r",encoding="utf-8") as file:
608
611
  index_data = json.load(file)
609
612
  else:
610
613
  index_data = {}
@@ -641,7 +644,7 @@ def get_symbol_list() -> List[SymbolItem]:
641
644
 
642
645
 
643
646
  def save_memory():
644
- with open(os.path.join(base_persist_dir, "memory.json"), "w") as f:
647
+ with open(os.path.join(base_persist_dir, "memory.json"), "w",encoding="utf-8") as f:
645
648
  json.dump(memory, f, indent=2, ensure_ascii=False)
646
649
  load_memory()
647
650
 
@@ -650,7 +653,7 @@ def load_memory():
650
653
  global memory
651
654
  memory_path = os.path.join(base_persist_dir, "memory.json")
652
655
  if os.path.exists(memory_path):
653
- with open(memory_path, "r") as f:
656
+ with open(memory_path, "r", encoding="utf-8") as f:
654
657
  memory = json.load(f)
655
658
  completer.update_current_files(memory["current_files"]["files"])
656
659
 
@@ -1093,7 +1096,7 @@ def ask(query: str):
1093
1096
 
1094
1097
  execute_file = os.path.join("actions", f"{uuid.uuid4()}.yml")
1095
1098
 
1096
- with open(os.path.join(execute_file), "w") as f:
1099
+ with open(os.path.join(execute_file), "w",encoding="utf-8") as f:
1097
1100
  f.write(yaml_content)
1098
1101
 
1099
1102
  def execute_ask():
@@ -1141,7 +1144,7 @@ def get_llm_friendly_package_docs(
1141
1144
  if return_paths:
1142
1145
  docs.append(file_path)
1143
1146
  else:
1144
- with open(file_path, "r") as f:
1147
+ with open(file_path, "r",encoding="utf-8") as f:
1145
1148
  docs.append(f.read())
1146
1149
 
1147
1150
  return docs
@@ -1151,7 +1154,7 @@ def convert_yaml_to_config(yaml_file: str):
1151
1154
  from autocoder.auto_coder import AutoCoderArgs, load_include_files, Template
1152
1155
 
1153
1156
  args = AutoCoderArgs()
1154
- with open(yaml_file, "r") as f:
1157
+ with open(yaml_file, "r",encoding="utf-8") as f:
1155
1158
  config = yaml.safe_load(f)
1156
1159
  config = load_include_files(config, yaml_file)
1157
1160
  for key, value in config.items():
@@ -1241,7 +1244,7 @@ def mcp(query: str):
1241
1244
 
1242
1245
  temp_yaml = os.path.join("actions", f"{uuid.uuid4()}.yml")
1243
1246
  try:
1244
- with open(temp_yaml, "w") as f:
1247
+ with open(temp_yaml, "w",encoding="utf-8") as f:
1245
1248
  f.write(convert_yaml_config_to_str(yaml_config=yaml_config))
1246
1249
  args = convert_yaml_to_config(temp_yaml)
1247
1250
  finally:
@@ -1310,7 +1313,7 @@ def code_next(query: str):
1310
1313
 
1311
1314
  temp_yaml = os.path.join("actions", f"{uuid.uuid4()}.yml")
1312
1315
  try:
1313
- with open(temp_yaml, "w") as f:
1316
+ with open(temp_yaml, "w",encoding="utf-8") as f:
1314
1317
  f.write(convert_yaml_config_to_str(yaml_config=yaml_config))
1315
1318
  args = convert_yaml_to_config(temp_yaml)
1316
1319
  finally:
@@ -1417,7 +1420,7 @@ def commit(query: str):
1417
1420
  # 临时保存yaml文件,然后读取yaml文件,转换为args
1418
1421
  temp_yaml = os.path.join("actions", f"{uuid.uuid4()}.yml")
1419
1422
  try:
1420
- with open(temp_yaml, "w") as f:
1423
+ with open(temp_yaml, "w",encoding="utf-8") as f:
1421
1424
  f.write(convert_yaml_config_to_str(
1422
1425
  yaml_config=yaml_config))
1423
1426
  args = convert_yaml_to_config(temp_yaml)
@@ -1444,7 +1447,7 @@ def commit(query: str):
1444
1447
 
1445
1448
  yaml_config["query"] = commit_message
1446
1449
  yaml_content = convert_yaml_config_to_str(yaml_config=yaml_config)
1447
- with open(os.path.join(execute_file), "w") as f:
1450
+ with open(os.path.join(execute_file), "w",encoding="utf-8") as f:
1448
1451
  f.write(yaml_content)
1449
1452
 
1450
1453
  file_content = open(execute_file).read()
@@ -1504,6 +1507,7 @@ def coding(query: str):
1504
1507
  "silence": conf.get("silence", "true") == "true",
1505
1508
  "include_project_structure": conf.get("include_project_structure", "true")
1506
1509
  == "true",
1510
+ "exclude_files": conf.get("exclude_files", []),
1507
1511
  }
1508
1512
 
1509
1513
  yaml_config["context"] = ""
@@ -1559,7 +1563,7 @@ def coding(query: str):
1559
1563
  error_message()
1560
1564
  return
1561
1565
 
1562
- with open(memory_file, "r") as f:
1566
+ with open(memory_file, "r",encoding="utf-8") as f:
1563
1567
  chat_history = json.load(f)
1564
1568
 
1565
1569
  if not chat_history["ask_conversation"]:
@@ -1583,7 +1587,7 @@ def coding(query: str):
1583
1587
  md5 = hashlib.md5(yaml_content.encode("utf-8")).hexdigest()
1584
1588
 
1585
1589
  execute_file = os.path.join("actions", latest_yaml_file)
1586
- with open(os.path.join(execute_file), "w") as f:
1590
+ with open(os.path.join(execute_file), "w",encoding="utf-8") as f:
1587
1591
  f.write(yaml_content)
1588
1592
 
1589
1593
  def execute_chat():
@@ -1632,6 +1636,7 @@ def chat(query: str):
1632
1636
  "skip_build_index": conf.get("skip_build_index", "true") == "true",
1633
1637
  "skip_confirm": conf.get("skip_confirm", "true") == "true",
1634
1638
  "silence": conf.get("silence", "true") == "true",
1639
+ "exclude_files": conf.get("exclude_files", []),
1635
1640
  }
1636
1641
 
1637
1642
  current_files = memory["current_files"]["files"] + get_llm_friendly_package_docs(
@@ -1698,7 +1703,7 @@ def chat(query: str):
1698
1703
 
1699
1704
  execute_file = os.path.join("actions", f"{uuid.uuid4()}.yml")
1700
1705
 
1701
- with open(os.path.join(execute_file), "w") as f:
1706
+ with open(os.path.join(execute_file), "w",encoding="utf-8") as f:
1702
1707
  f.write(yaml_content)
1703
1708
 
1704
1709
  def execute_ask():
@@ -1722,7 +1727,7 @@ def summon(query: str):
1722
1727
  for file in current_files:
1723
1728
  if os.path.exists(file):
1724
1729
  try:
1725
- with open(file, "r") as f:
1730
+ with open(file, "r",encoding="utf-8") as f:
1726
1731
  content = f.read()
1727
1732
  s = f"##File: {file}\n{content}\n\n"
1728
1733
  file_contents.append(s)
@@ -1758,7 +1763,7 @@ def summon(query: str):
1758
1763
 
1759
1764
  execute_file = os.path.join("actions", f"{uuid.uuid4()}.yml")
1760
1765
 
1761
- with open(os.path.join(execute_file), "w") as f:
1766
+ with open(os.path.join(execute_file), "w",encoding="utf-8") as f:
1762
1767
  f.write(yaml_content)
1763
1768
 
1764
1769
  def execute_summon():
@@ -1805,7 +1810,7 @@ def design(query: str):
1805
1810
 
1806
1811
  execute_file = os.path.join("actions", f"{uuid.uuid4()}.yml")
1807
1812
 
1808
- with open(os.path.join(execute_file), "w") as f:
1813
+ with open(os.path.join(execute_file), "w",encoding="utf-8") as f:
1809
1814
  f.write(yaml_content)
1810
1815
 
1811
1816
  def execute_design():
@@ -1834,7 +1839,7 @@ def voice_input():
1834
1839
 
1835
1840
  execute_file = os.path.join("actions", f"{uuid.uuid4()}.yml")
1836
1841
 
1837
- with open(os.path.join(execute_file), "w") as f:
1842
+ with open(os.path.join(execute_file), "w",encoding="utf-8") as f:
1838
1843
  f.write(yaml_content)
1839
1844
 
1840
1845
  def execute_voice2text_command():
@@ -1842,7 +1847,7 @@ def voice_input():
1842
1847
 
1843
1848
  try:
1844
1849
  execute_voice2text_command()
1845
- with open(os.path.join(".auto-coder", "exchange.txt"), "r") as f:
1850
+ with open(os.path.join(".auto-coder", "exchange.txt"), "r",encoding="utf-8") as f:
1846
1851
  return f.read()
1847
1852
  finally:
1848
1853
  os.remove(execute_file)
@@ -1864,12 +1869,12 @@ def generate_shell_command(input_text):
1864
1869
 
1865
1870
  execute_file = os.path.join("actions", f"{uuid.uuid4()}.yml")
1866
1871
 
1867
- with open(os.path.join(execute_file), "w") as f:
1872
+ with open(os.path.join(execute_file), "w",encoding="utf-8") as f:
1868
1873
  f.write(yaml_content)
1869
1874
 
1870
1875
  try:
1871
1876
  auto_coder_main(["agent", "generate_command", "--file", execute_file])
1872
- with open(os.path.join(".auto-coder", "exchange.txt"), "r") as f:
1877
+ with open(os.path.join(".auto-coder", "exchange.txt"), "r",encoding="utf-8") as f:
1873
1878
  shell_script = f.read()
1874
1879
  result_manager = ResultManager()
1875
1880
  result_manager.add_result(content=shell_script,meta={
@@ -2265,18 +2270,61 @@ def manage_models(query: str):
2265
2270
 
2266
2271
  def exclude_dirs(dir_names: List[str]):
2267
2272
  new_dirs = dir_names
2268
- existing_dirs = memory.get("exclude_dirs", [])
2273
+ existing_dirs = memory.get("exclude_dirs", [])
2269
2274
  dirs_to_add = [d for d in new_dirs if d not in existing_dirs]
2275
+
2270
2276
  if dirs_to_add:
2271
2277
  existing_dirs.extend(dirs_to_add)
2272
2278
  if "exclude_dirs" not in memory:
2273
2279
  memory["exclude_dirs"] = existing_dirs
2274
2280
  print(f"Added exclude dirs: {dirs_to_add}")
2281
+ exclude_files([f"regex://.*/{d}/*." for d in dirs_to_add])
2275
2282
  else:
2276
2283
  print("All specified dirs are already in the exclude list.")
2277
2284
  save_memory()
2278
2285
  completer.refresh_files()
2279
2286
 
2287
+ def exclude_files(file_patterns: List[str]):
2288
+ result_manager = ResultManager()
2289
+ printer = Printer()
2290
+ new_file_patterns = file_patterns
2291
+ existing_file_patterns = memory.get("exclude_files", [])
2292
+ file_patterns_to_add = [f for f in new_file_patterns if f not in existing_file_patterns]
2293
+
2294
+ for file_pattern in file_patterns_to_add:
2295
+ if not file_pattern.startswith("regex://"):
2296
+ result_manager.add_result(content=printer.get_message_from_key_with_format("invalid_file_pattern", file_pattern=file_pattern),meta={
2297
+ "action": "exclude_files",
2298
+ "input": {
2299
+ "query": file_pattern
2300
+ }
2301
+ })
2302
+ raise ValueError(printer.get_message_from_key_with_format("invalid_file_pattern", file_pattern=file_pattern))
2303
+
2304
+ if file_patterns_to_add:
2305
+ existing_file_patterns.extend(file_patterns_to_add)
2306
+ if "exclude_files" not in memory:
2307
+ memory["exclude_files"] = existing_file_patterns
2308
+
2309
+ result_manager.add_result(content=f"Added exclude files: {file_patterns_to_add}",meta={
2310
+ "action": "exclude_files",
2311
+ "input": {
2312
+ "query": file_patterns_to_add
2313
+ }
2314
+ })
2315
+ save_memory()
2316
+ print(f"Added exclude files: {file_patterns_to_add}")
2317
+ else:
2318
+ result_manager.add_result(content=f"All specified files are already in the exclude list.",meta={
2319
+ "action": "exclude_files",
2320
+ "input": {
2321
+ "query": file_patterns_to_add
2322
+ }
2323
+ })
2324
+ print("All specified files are already in the exclude list.")
2325
+
2326
+
2327
+
2280
2328
  @run_in_raw_thread()
2281
2329
  def index_build():
2282
2330
  conf = memory.get("conf", {})
@@ -2292,7 +2340,7 @@ def index_build():
2292
2340
  yaml_content = convert_yaml_config_to_str(yaml_config=yaml_config)
2293
2341
  yaml_file = os.path.join("actions", f"{uuid.uuid4()}.yml")
2294
2342
 
2295
- with open(yaml_file, "w") as f:
2343
+ with open(yaml_file, "w",encoding="utf-8") as f:
2296
2344
  f.write(yaml_content)
2297
2345
  try:
2298
2346
  with redirect_stdout() as output:
@@ -2322,7 +2370,7 @@ def get_final_config()->AutoCoderArgs:
2322
2370
 
2323
2371
  temp_yaml = os.path.join("actions", f"{uuid.uuid4()}.yml")
2324
2372
  try:
2325
- with open(temp_yaml, "w") as f:
2373
+ with open(temp_yaml, "w",encoding="utf-8") as f:
2326
2374
  f.write(convert_yaml_config_to_str(yaml_config=yaml_config))
2327
2375
  args = convert_yaml_to_config(temp_yaml)
2328
2376
  finally:
@@ -2339,26 +2387,26 @@ def help(query: str):
2339
2387
  auto_config_tuner.tune(AutoConfigRequest(query=query))
2340
2388
 
2341
2389
  @run_in_raw_thread()
2342
- def index_export(export_path: str):
2390
+ def index_export(path: str):
2343
2391
  from autocoder.common.index_import_export import export_index
2344
2392
  from autocoder.common.printer import Printer
2345
2393
  printer = Printer()
2346
2394
  project_root = os.getcwd()
2347
- if export_index(project_root, export_path):
2348
- printer.print_in_terminal("index_export_success", path=export_path)
2395
+ if export_index(project_root, path):
2396
+ printer.print_in_terminal("index_export_success", path=path)
2349
2397
  else:
2350
- printer.print_in_terminal("index_export_fail", path=export_path)
2398
+ printer.print_in_terminal("index_export_fail", path=path)
2351
2399
 
2352
2400
  @run_in_raw_thread()
2353
- def index_import(import_path: str):
2401
+ def index_import(path: str):
2354
2402
  from autocoder.common.index_import_export import import_index
2355
2403
  from autocoder.common.printer import Printer
2356
2404
  printer = Printer()
2357
2405
  project_root = os.getcwd()
2358
- if import_index(project_root, import_path):
2359
- printer.print_in_terminal("index_import_success", path=import_path)
2406
+ if import_index(project_root, path):
2407
+ printer.print_in_terminal("index_import_success", path=path)
2360
2408
  else:
2361
- printer.print_in_terminal("index_import_fail", path=import_path)
2409
+ printer.print_in_terminal("index_import_fail", path=path)
2362
2410
 
2363
2411
  @run_in_raw_thread()
2364
2412
  def index_query(query: str):
@@ -2377,7 +2425,7 @@ def index_query(query: str):
2377
2425
  yaml_content = convert_yaml_config_to_str(yaml_config=yaml_config)
2378
2426
  yaml_file = os.path.join("actions", f"{uuid.uuid4()}.yml")
2379
2427
 
2380
- with open(yaml_file, "w") as f:
2428
+ with open(yaml_file, "w",encoding="utf-8") as f:
2381
2429
  f.write(yaml_content)
2382
2430
  try:
2383
2431
  with redirect_stdout() as output:
@@ -2409,10 +2457,30 @@ def list_files():
2409
2457
  )
2410
2458
  )
2411
2459
 
2412
- @run_in_raw_thread()
2413
- def execute_shell_command(command: str):
2414
- from autocoder.common.shells import execute_shell_command as shell_exec
2415
- shell_exec(command)
2460
+
2461
+ def gen_and_exec_shell_command(query: str):
2462
+ from rich.prompt import Confirm
2463
+ from autocoder.common.printer import Printer
2464
+ from rich.console import Console
2465
+
2466
+ printer = Printer()
2467
+ console = Console()
2468
+ # Generate the shell script
2469
+ shell_script = generate_shell_command(query)
2470
+
2471
+ # Ask for confirmation using rich
2472
+ if Confirm.ask(
2473
+ printer.get_message_from_key("confirm_execute_shell_script"),
2474
+ default=False
2475
+ ):
2476
+ execute_shell_command(shell_script)
2477
+ else:
2478
+ console.print(
2479
+ Panel(
2480
+ printer.get_message_from_key("shell_script_not_executed"),
2481
+ border_style="yellow"
2482
+ )
2483
+ )
2416
2484
 
2417
2485
 
2418
2486
  def lib_command(args: List[str]):
@@ -2542,6 +2610,20 @@ def lib_command(args: List[str]):
2542
2610
  else:
2543
2611
  console.print(f"Unknown subcommand: {subcommand}")
2544
2612
 
2613
+
2614
+ def execute_shell_command(command: str):
2615
+ from autocoder.common.shells import execute_shell_command as shell_exec
2616
+ shell_exec(command)
2617
+
2618
+
2619
+ def conf_export(path: str):
2620
+ from autocoder.common.conf_import_export import export_conf
2621
+ export_conf(os.getcwd(), path)
2622
+
2623
+ def conf_import(path: str):
2624
+ from autocoder.common.conf_import_export import import_conf
2625
+ import_conf(os.getcwd(), path)
2626
+
2545
2627
  @run_in_raw_thread()
2546
2628
  def auto_command(params,query: str):
2547
2629
  """处理/auto指令"""
@@ -2568,6 +2650,7 @@ def auto_command(params,query: str):
2568
2650
  commit=commit,
2569
2651
  help=help,
2570
2652
  exclude_dirs=exclude_dirs,
2653
+ exclude_files=exclude_files,
2571
2654
  ask=ask,
2572
2655
  chat=chat,
2573
2656
  coding=coding,
@@ -2579,7 +2662,11 @@ def auto_command(params,query: str):
2579
2662
  index_build=index_build,
2580
2663
  index_query=index_query,
2581
2664
  execute_shell_command=execute_shell_command,
2582
- generate_shell_command=generate_shell_command
2665
+ generate_shell_command=generate_shell_command,
2666
+ conf_export=conf_export,
2667
+ conf_import=conf_import,
2668
+ index_export=index_export,
2669
+ index_import=index_import
2583
2670
  ))
2584
2671
 
2585
2672
  # 生成建议
@@ -2780,17 +2867,11 @@ def main():
2780
2867
 
2781
2868
  elif user_input.startswith("/index/export"):
2782
2869
  export_path = user_input[len("/index/export"):].strip()
2783
- if not export_path:
2784
- print("Please specify the export path")
2785
- else:
2786
- index_export(export_path)
2870
+ index_export(export_path)
2787
2871
 
2788
2872
  elif user_input.startswith("/index/import"):
2789
- import_path = user_input[len("/index/import"):].strip()
2790
- if not import_path:
2791
- print("Please specify the import path")
2792
- else:
2793
- index_import(import_path)
2873
+ import_path = user_input[len("/index/import"):].strip()
2874
+ index_import(import_path)
2794
2875
 
2795
2876
  elif user_input.startswith("/list_files"):
2796
2877
  list_files()
@@ -2808,7 +2889,17 @@ def main():
2808
2889
  print(memory["mode"])
2809
2890
  else:
2810
2891
  memory["mode"] = conf
2811
-
2892
+
2893
+ elif user_input.startswith("/conf/export"):
2894
+ from autocoder.common.conf_import_export import export_conf
2895
+ export_path = user_input[len("/conf/export"):].strip()
2896
+ export_conf(os.getcwd(), export_path)
2897
+
2898
+ elif user_input.startswith("/conf/import"):
2899
+ from autocoder.common.conf_import_export import import_conf
2900
+ import_path = user_input[len("/conf/import"):].strip()
2901
+ import_conf(os.getcwd(), import_path)
2902
+
2812
2903
  elif user_input.startswith("/conf"):
2813
2904
  conf = user_input[len("/conf"):].strip()
2814
2905
  if not conf:
@@ -2831,6 +2922,12 @@ def main():
2831
2922
  dir_names = user_input[len(
2832
2923
  "/exclude_dirs"):].strip().split(",")
2833
2924
  exclude_dirs(dir_names)
2925
+
2926
+ elif user_input.startswith("/exclude_files"):
2927
+ file_patterns = user_input[len(
2928
+ "/exclude_files"):].strip().split(",")
2929
+ exclude_files(file_patterns)
2930
+
2834
2931
  elif user_input.startswith("/ask"):
2835
2932
  query = user_input[len("/ask"):].strip()
2836
2933
  if not query:
@@ -2893,12 +2990,16 @@ def main():
2893
2990
  # elif user_input.startswith("/shell"):
2894
2991
  else:
2895
2992
  command = user_input
2896
- if user_input.startswith("/shell"):
2993
+ if user_input.startswith("/shell"):
2897
2994
  command = user_input[len("/shell"):].strip()
2898
2995
  if not command:
2899
2996
  print("Please enter a shell command to execute.")
2900
2997
  else:
2901
- execute_shell_command(command)
2998
+ if command.startswith("/chat"):
2999
+ command = command[len("/chat"):].strip()
3000
+ gen_and_exec_shell_command(command)
3001
+ else:
3002
+ execute_shell_command(command)
2902
3003
 
2903
3004
  except KeyboardInterrupt:
2904
3005
  continue
@@ -138,6 +138,11 @@ class CommandConfig(BaseModel):
138
138
  lib: SkipValidation[Callable]
139
139
  execute_shell_command: SkipValidation[Callable]
140
140
  generate_shell_command: SkipValidation[Callable]
141
+ conf_export: SkipValidation[Callable]
142
+ conf_import: SkipValidation[Callable]
143
+ index_export: SkipValidation[Callable]
144
+ index_import: SkipValidation[Callable]
145
+ exclude_files: SkipValidation[Callable]
141
146
 
142
147
 
143
148
 
@@ -298,6 +303,7 @@ class CommandAutoTuner:
298
303
  try:
299
304
  response = to_model(content, AutoCommandResponse)
300
305
  if response.suggestions:
306
+ print(response)
301
307
  command = response.suggestions[0].command
302
308
  parameters = response.suggestions[0].parameters
303
309
  if parameters:
@@ -306,9 +312,9 @@ class CommandAutoTuner:
306
312
  params_str = ""
307
313
  return f"{command}({params_str})"
308
314
  else:
309
- return printer.get_message_from_key("satisfied_prompt", style="green")
310
- except Exception as e:
311
- logger.error(f"Error extracting command response: {e}")
315
+ return printer.get_message_from_key("satisfied_prompt")
316
+ except Exception as e:
317
+ logger.error(f"Error extracting command response: {str(e)}")
312
318
  return content
313
319
 
314
320
  model_name = ",".join(llms_utils.get_llm_names(self.llm))
@@ -1111,7 +1117,72 @@ class CommandAutoTuner:
1111
1117
  </usage>
1112
1118
  </command>
1113
1119
 
1114
- </commands>
1120
+ <command>
1121
+ <name>conf_export</name>
1122
+ <description>配置管理命令,用于管理和控制配置。</description>
1123
+ <usage>
1124
+ 该命令导出当前软件的配置,并保存到指定路径。
1125
+
1126
+ 使用例子:
1127
+ conf_export(path="导出路径,通常是.json文件")
1128
+
1129
+ </usage>
1130
+ </command>
1131
+
1132
+ <command>
1133
+ <name>conf_import</name>
1134
+ <description>配置管理命令,用于管理和控制配置。</description>
1135
+ <usage>
1136
+ 该命令导入指定路径的配置文件到当前软件。
1137
+
1138
+ 使用例子:
1139
+ conf_import(path="导入路径,通常是.json文件")
1140
+
1141
+ </usage>
1142
+ </command>
1143
+
1144
+ <command>
1145
+ <name>index_export</name>
1146
+ <description>索引管理命令,用于管理和控制索引。</description>
1147
+ <usage>
1148
+ 该命令导出当前软件的索引,并保存到指定路径。
1149
+
1150
+ 使用例子:
1151
+ index_export(path="导出路径,通常是.json文件")
1152
+
1153
+ </usage>
1154
+ </command>
1155
+
1156
+ <command>
1157
+ <name>index_import</name>
1158
+ <description>索引管理命令,用于管理和控制索引。</description>
1159
+ <usage>
1160
+ 该命令导入指定路径的索引文件到当前软件。
1161
+
1162
+ 使用例子:
1163
+ index_import(path="导入路径,通常最后是.json文件")
1164
+
1165
+ </usage>
1166
+ </command>
1167
+
1168
+ <command>
1169
+ <name>exclude_files</name>
1170
+ <description>排除指定文件。</description>
1171
+ <usage>
1172
+ 该命令接受一个参数 file_patterns, 为要排除的文件模式字符串列表。
1173
+
1174
+ 使用例子,比如你想要排除 package-lock.json 文件,你可以这样调用:
1175
+
1176
+ exclude_files(file_patterns=["regex://.*/package-lock\.json"])
1177
+
1178
+ 注意:
1179
+ - 文件模式字符串必须以 regex:// 开头
1180
+ - regex:// 后面部分是标准的正则表达式
1181
+ </usage>
1182
+ </command>
1183
+ </commands>
1184
+
1185
+
1115
1186
  '''
1116
1187
 
1117
1188
  def execute_auto_command(self, command: str, parameters: Dict[str, Any]) -> None:
@@ -1135,6 +1206,11 @@ class CommandAutoTuner:
1135
1206
  "models": self.command_config.models,
1136
1207
  "execute_shell_command": self.command_config.execute_shell_command,
1137
1208
  "generate_shell_command": self.command_config.generate_shell_command,
1209
+ "conf_export": self.command_config.conf_export,
1210
+ "conf_import": self.command_config.conf_import,
1211
+ "index_export": self.command_config.index_export,
1212
+ "index_import": self.command_config.index_import,
1213
+ "exclude_files": self.command_config.exclude_files,
1138
1214
 
1139
1215
  "run_python": self.tools.run_python_code,
1140
1216
  "get_related_files_by_symbols": self.tools.get_related_files_by_symbols,
@@ -1146,6 +1222,7 @@ class CommandAutoTuner:
1146
1222
  "get_project_related_files": self.tools.get_project_related_files,
1147
1223
  "ask_user":self.tools.ask_user,
1148
1224
  "read_file_with_keyword_ranges": self.tools.read_file_with_keyword_ranges,
1225
+
1149
1226
 
1150
1227
 
1151
1228
  }