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

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: auto-coder
3
- Version: 0.1.277
3
+ Version: 0.1.278
4
4
  Summary: AutoCoder: AutoCoder
5
5
  Author: allwefantasy
6
6
  Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
@@ -12,7 +12,7 @@ autocoder/chat_auto_coder_lang.py,sha256=ShOQVOnMA-WlT-fB9OrOer-xQkbcWxJGl-WMPuZ
12
12
  autocoder/command_args.py,sha256=9aYJ-AmPxP1sQh6ciw04FWHjSn31f2W9afXFwo8wgx4,30441
13
13
  autocoder/lang.py,sha256=U6AjVV8Rs1uLyjFCZ8sT6WWuNUxMBqkXXIOs4S120uk,14511
14
14
  autocoder/models.py,sha256=PlG1tKHSHwB57cKLOl5gTl5yTzFUDzCgeHPJU3N9F6Q,9106
15
- autocoder/version.py,sha256=aQmPFbK421hxX_q_qH6lzGAzBJ-yTN3E_wgJvqVGg9k,23
15
+ autocoder/version.py,sha256=Q3OPt1PiXvKx5xTUCPxUFZP2zsuajLbxdpiOEm_K2L4,23
16
16
  autocoder/agent/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
17
  autocoder/agent/auto_demand_organizer.py,sha256=NWSAEsEk94vT3lGjfo25kKLMwYdPcpy9e-i21txPasQ,6942
18
18
  autocoder/agent/auto_filegroup.py,sha256=CW7bqp0FW1GIEMnl-blyAc2UGT7O9Mom0q66ITz1ckM,6635
@@ -26,7 +26,7 @@ autocoder/agent/planner.py,sha256=SZTSZHxHzDmuWZo3K5fs79RwvJLWurg-nbJRRNbX65o,91
26
26
  autocoder/agent/project_reader.py,sha256=tWLaPoLw1gI6kO_NzivQj28KbobU2ceOLuppHMbfGl8,18234
27
27
  autocoder/chat/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
28
28
  autocoder/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
29
- autocoder/commands/auto_command.py,sha256=Qv5hObiIioIOAVkucFB2na6aLUuxSIgLVO9PfnXwyIo,52496
29
+ autocoder/commands/auto_command.py,sha256=3ZQvG_JX2oWxTv_xiXQDQwMfTAVK-Tynqo6mC9fXb60,52671
30
30
  autocoder/commands/tools.py,sha256=lanjoBGR6H8HDJSY3KrM6ibrtHZbgKX6mKJHSSE66dg,20493
31
31
  autocoder/common/JupyterClient.py,sha256=O-wi6pXeAEYhAY24kDa0BINrLYvKS6rKyWe98pDClS0,2816
32
32
  autocoder/common/ShellClient.py,sha256=fM1q8t_XMSbLBl2zkCNC2J9xuyKN3eXzGm6hHhqL2WY,2286
@@ -75,7 +75,7 @@ autocoder/common/result_manager.py,sha256=nBcFRj5reBC7vp13M91f4B8iPW8B8OehayHlUd
75
75
  autocoder/common/screenshots.py,sha256=_gA-z1HxGjPShBrtgkdideq58MG6rqFB2qMUJKjrycs,3769
76
76
  autocoder/common/search.py,sha256=245iPFgWhMldoUK3CqCP89ltaxZiNPK73evoG6Fp1h8,16518
77
77
  autocoder/common/search_replace.py,sha256=GphFkc57Hb673CAwmbiocqTbw8vrV7TrZxtOhD0332g,22147
78
- autocoder/common/shells.py,sha256=-5j45qb1SVmkZaORqDZ5EM2zJ16b5QGM1wHDfBfGejk,18944
78
+ autocoder/common/shells.py,sha256=elminFpNosnV0hsEUcsugDxlGO8NfH96uah-8bkaBvA,19929
79
79
  autocoder/common/stats_panel.py,sha256=wGl9O45pjVVDxhNumLv4_NfLYSlUP_18Tw4hcJSjw50,4596
80
80
  autocoder/common/sys_prompt.py,sha256=JlexfjZt554faqbgkCmzOJqYUzDHfbnxly5ugFfHfEE,26403
81
81
  autocoder/common/text.py,sha256=KGRQq314GHBmY4MWG8ossRoQi1_DTotvhxchpn78c-k,1003
@@ -165,9 +165,9 @@ autocoder/utils/types.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
165
165
  autocoder/utils/auto_coder_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
166
166
  autocoder/utils/auto_coder_utils/chat_stream_out.py,sha256=lkJ_A-sYU36JMzjFWkk3pR6uos8oZHYt9GPsPe_CPAo,11766
167
167
  autocoder/utils/chat_auto_coder_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
168
- auto_coder-0.1.277.dist-info/LICENSE,sha256=HrhfyXIkWY2tGFK11kg7vPCqhgh5DcxleloqdhrpyMY,11558
169
- auto_coder-0.1.277.dist-info/METADATA,sha256=m2MjOLFknaEjczW5V_NfTL4jj7bikJe0jbn_tuYRfdQ,2643
170
- auto_coder-0.1.277.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
171
- auto_coder-0.1.277.dist-info/entry_points.txt,sha256=0nzHtHH4pNcM7xq4EBA2toS28Qelrvcbrr59GqD_0Ak,350
172
- auto_coder-0.1.277.dist-info/top_level.txt,sha256=Jqc0_uJSw2GwoFQAa9iJxYns-2mWla-9ok_Y3Gcznjk,10
173
- auto_coder-0.1.277.dist-info/RECORD,,
168
+ auto_coder-0.1.278.dist-info/LICENSE,sha256=HrhfyXIkWY2tGFK11kg7vPCqhgh5DcxleloqdhrpyMY,11558
169
+ auto_coder-0.1.278.dist-info/METADATA,sha256=W8ANCnQ9mFraLjuXIUaggoO_jH5Yx-bmm4FNxHLfOvo,2643
170
+ auto_coder-0.1.278.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
171
+ auto_coder-0.1.278.dist-info/entry_points.txt,sha256=0nzHtHH4pNcM7xq4EBA2toS28Qelrvcbrr59GqD_0Ak,350
172
+ auto_coder-0.1.278.dist-info/top_level.txt,sha256=Jqc0_uJSw2GwoFQAa9iJxYns-2mWla-9ok_Y3Gcznjk,10
173
+ auto_coder-0.1.278.dist-info/RECORD,,
@@ -23,6 +23,7 @@ from autocoder.rag.token_counter import count_tokens
23
23
  from autocoder.common.global_cancel import global_cancel
24
24
  from autocoder.common.auto_configure import config_readme
25
25
  from autocoder.utils.auto_project_type import ProjectTypeAnalyzer
26
+ from rich.text import Text
26
27
 
27
28
  class CommandMessage(BaseModel):
28
29
  role: str
@@ -435,8 +436,10 @@ class CommandAutoTuner:
435
436
  "command_execution_result",
436
437
  action=action
437
438
  )
439
+ # 转义内容,避免Rich将内容中的[]解释为markup语法
440
+ text_content = Text(truncated_content)
438
441
  console.print(Panel(
439
- truncated_content,
442
+ text_content,
440
443
  title=title,
441
444
  border_style="blue",
442
445
  padding=(1, 2)
@@ -11,6 +11,9 @@ from rich.panel import Panel
11
11
  from rich.text import Text
12
12
  from rich.live import Live
13
13
  import getpass
14
+ from rich.markup import escape
15
+ import threading
16
+ import queue
14
17
 
15
18
  from autocoder.common.result_manager import ResultManager
16
19
 
@@ -356,7 +359,7 @@ def _win_code_page_to_encoding(code_page: str) -> str:
356
359
 
357
360
  def execute_shell_command(command: str):
358
361
  """
359
- Execute a shell command with cross-platform encoding support.
362
+ Execute a shell command with cross-platform encoding support and streaming output.
360
363
 
361
364
  Args:
362
365
  command (str): The shell command to execute
@@ -446,81 +449,95 @@ set PYTHONIOENCODING=utf-8
446
449
  encoding='utf-8', # 直接指定 UTF-8 编码
447
450
  errors='replace', # 处理无法解码的字符
448
451
  env=env, # 传递修改后的环境变量
449
- startupinfo=startupinfo
452
+ startupinfo=startupinfo,
453
+ bufsize=1, # Line buffering for immediate flushing
454
+ universal_newlines=True # Use text mode to handle platform line endings
450
455
  )
451
456
 
452
457
  # Safe decoding helper (for binary output)
453
- def safe_decode(byte_stream, encoding):
454
- if isinstance(byte_stream, str):
455
- return byte_stream.strip()
458
+ def safe_decode(text, encoding):
459
+ if isinstance(text, str):
460
+ return text.strip()
456
461
  try:
457
- # 首先尝试 UTF-8
458
- return byte_stream.decode('utf-8').strip()
462
+ # Try UTF-8 first
463
+ return text.decode('utf-8').strip()
459
464
  except UnicodeDecodeError:
460
465
  try:
461
- # 如果失败,尝试 GBK
462
- return byte_stream.decode('gbk').strip()
466
+ # If that fails, try GBK
467
+ return text.decode('gbk').strip()
463
468
  except UnicodeDecodeError:
464
- # 最后使用替换模式
465
- return byte_stream.decode(encoding, errors='replace').strip()
469
+ # Finally use replacement mode
470
+ return text.decode(encoding, errors='replace').strip()
466
471
 
467
472
  output = []
468
- with Live(console=console, refresh_per_second=4) as live:
469
- while True:
470
- # Read output streams
471
- output_bytes = process.stdout.readline()
472
- error_bytes = process.stderr.readline()
473
-
474
- # Handle standard output
475
- if output_bytes:
476
- output_line = safe_decode(output_bytes, encoding)
477
- output.append(output_line)
478
- live.update(
479
- Panel(
480
- Text("\n".join(output[-20:])),
481
- title="Shell Output",
482
- border_style="green",
483
- )
484
- )
485
-
486
- # Handle error output
487
- if error_bytes:
488
- error_line = safe_decode(error_bytes, encoding)
489
- output.append(f"ERROR: {error_line}")
490
- live.update(
491
- Panel(
492
- Text("\n".join(output[-20:])),
493
- title="Shell Output",
494
- border_style="red",
495
- )
496
- )
497
-
498
- # Check if process has ended
499
- if process.poll() is not None:
473
+ # Use direct printing for streaming output, not a Live object
474
+ console.print(f"[bold blue]Running command:[/bold blue] {command}")
475
+ console.print("[bold blue]Output streaming:[/bold blue]")
476
+
477
+ output_queue = queue.Queue()
478
+
479
+ def read_stream(stream, stream_name):
480
+ """Read data from stream and put in queue"""
481
+ for line in stream:
482
+ line = line.rstrip() if isinstance(line, str) else safe_decode(line, encoding)
483
+ prefix = "[ERROR] " if stream_name == "stderr" else ""
484
+ output_queue.put((stream_name, f"{prefix}{line}"))
485
+ output_queue.put((stream_name, None)) # Mark stream end
486
+
487
+ # Create threads to read stdout and stderr
488
+ stdout_thread = threading.Thread(target=read_stream, args=(process.stdout, "stdout"))
489
+ stderr_thread = threading.Thread(target=read_stream, args=(process.stderr, "stderr"))
490
+ stdout_thread.daemon = True
491
+ stderr_thread.daemon = True
492
+ stdout_thread.start()
493
+ stderr_thread.start()
494
+
495
+ # Track number of active streams
496
+ active_streams = 2
497
+
498
+ # Process output from queue
499
+ while active_streams > 0:
500
+ try:
501
+ stream_name, line = output_queue.get(timeout=0.1)
502
+ if line is None:
503
+ active_streams -= 1
504
+ continue
505
+
506
+ output.append(line)
507
+ # Print each line directly for true streaming output
508
+ if stream_name == "stderr":
509
+ console.print(f"[red]{line}[/red]")
510
+ else:
511
+ console.print(line)
512
+
513
+ except queue.Empty:
514
+ # Check if process is still running
515
+ if process.poll() is not None and active_streams == 2:
516
+ # If process ended but threads are still running, may have no output
500
517
  break
501
-
502
- # Get remaining output
503
- remaining_out, remaining_err = process.communicate()
504
- if remaining_out:
505
- output.append(safe_decode(remaining_out, encoding))
506
- if remaining_err:
507
- output.append(f"ERROR: {safe_decode(remaining_err, encoding)}")
518
+ continue
519
+
520
+ # Wait for threads to finish
521
+ stdout_thread.join()
522
+ stderr_thread.join()
508
523
 
509
- result_manager.add_result(content="\n".join(output),meta={
524
+ # Wait for process to end and get return code
525
+ return_code = process.wait()
526
+
527
+ # Compile results
528
+ result_content = "\n".join(output)
529
+ result_manager.add_result(content=result_content, meta={
510
530
  "action": "execute_shell_command",
511
531
  "input": {
512
532
  "command": command
513
- }
533
+ },
534
+ "return_code": return_code
514
535
  })
515
- # Show final output
516
- console.print(
517
- Panel(
518
- Text("\n".join(output)),
519
- title="Final Output",
520
- border_style="blue",
521
- subtitle=f"Encoding: {encoding} | OS: {sys.platform}"
522
- )
523
- )
536
+
537
+ # Show command completion info
538
+ completion_message = f"Command completed with return code: {return_code}"
539
+ style = "green" if return_code == 0 else "red"
540
+ console.print(f"[bold {style}]{escape(completion_message)}[/bold {style}]")
524
541
 
525
542
  except FileNotFoundError:
526
543
  result_manager.add_result(content=f"[bold red]Command not found:[/bold red] [yellow]{command}[/yellow]",meta={
autocoder/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.1.277"
1
+ __version__ = "0.1.278"