wcgw 2.2.0__py3-none-any.whl → 2.2.1__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 wcgw might be problematic. Click here for more details.

@@ -186,7 +186,7 @@ def loop(
186
186
  - Only one of send_text, send_specials, send_ascii should be provided.
187
187
  - This returns within 5 seconds, for heavy programs keep checking status for upto 10 turns before asking user to continue checking again.
188
188
  - Programs don't hang easily, so most likely explanation for no output is usually that the program is still running, and you need to check status again using ["Enter"].
189
-
189
+ - Do not send Ctrl-c before checking for status till 10 minutes or whatever is appropriate for the program to finish.
190
190
  """,
191
191
  ),
192
192
  ToolParam(
@@ -222,6 +222,7 @@ def loop(
222
222
  description="""
223
223
  - Use absolute file path only.
224
224
  - Use SEARCH/REPLACE blocks to edit the file.
225
+ - If the edit fails due to block not matching, please retry with correct block till it matches. Re-read the file to ensure you've all the lines correct.
225
226
  """,
226
227
  ),
227
228
  ]
@@ -106,6 +106,7 @@ async def handle_list_tools() -> list[types.Tool]:
106
106
  - Only one of send_text, send_specials, send_ascii should be provided.
107
107
  - This returns within 3 seconds, for heavy programs keep checking status for upto 10 turns before asking user to continue checking again.
108
108
  - Programs don't hang easily, so most likely explanation for no output is usually that the program is still running, and you need to check status again using ["Enter"].
109
+ - Do not send Ctrl-c before checking for status till 10 minutes or whatever is appropriate for the program to finish.
109
110
  """,
110
111
  ),
111
112
  ToolParam(
@@ -141,6 +142,7 @@ async def handle_list_tools() -> list[types.Tool]:
141
142
  description="""
142
143
  - Use absolute file path only.
143
144
  - Use SEARCH/REPLACE blocks to edit the file.
145
+ - If the edit fails due to block not matching, please retry with correct block till it matches. Re-read the file to ensure you've all the lines correct.
144
146
  """
145
147
  + diffinstructions,
146
148
  ),
wcgw/client/tools.py CHANGED
@@ -537,6 +537,15 @@ def write_file(writefile: WriteIfEmpty, error_on_exist: bool) -> str:
537
537
  else:
538
538
  path_ = writefile.file_path
539
539
 
540
+ error_on_exist = (
541
+ not (
542
+ len(TOOL_CALLS) > 1
543
+ and isinstance(TOOL_CALLS[-2], FileEdit)
544
+ and TOOL_CALLS[-2].file_path == path_
545
+ )
546
+ and error_on_exist
547
+ )
548
+
540
549
  if not BASH_STATE.is_in_docker:
541
550
  if error_on_exist and os.path.exists(path_):
542
551
  file_data = Path(path_).read_text()
@@ -598,7 +607,7 @@ def find_least_edit_distance_substring(
598
607
  content_lines = new_content_lines
599
608
  find_lines = find_str.split("\n")
600
609
  find_lines = [
601
- line.strip() for line in find_lines
610
+ line.strip() for line in find_lines if line.strip()
602
611
  ] # Remove trailing and leading space for calculating edit distance
603
612
  # Slide window and find one with sum of edit distance least
604
613
  min_edit_distance = float("inf")
@@ -640,7 +649,9 @@ def edit_content(content: str, find_lines: str, replace_with_lines: str) -> str:
640
649
  raise Exception(
641
650
  f"""Error: no match found for the provided search block.
642
651
  Requested search block: \n```\n{find_lines}\n```
643
- Possible relevant section in the file:\n---\n```\n{closest_match}\n```\n---\nFile not edited"""
652
+ Possible relevant section in the file:\n---\n```\n{closest_match}\n```\n---\nFile not edited
653
+ \nPlease retry with exact search. Re-read the file if unsure.
654
+ """
644
655
  )
645
656
 
646
657
  content = content.replace(find_lines, replace_with_lines, 1)
@@ -648,6 +659,24 @@ def edit_content(content: str, find_lines: str, replace_with_lines: str) -> str:
648
659
 
649
660
 
650
661
  def do_diff_edit(fedit: FileEdit) -> str:
662
+ try:
663
+ return _do_diff_edit(fedit)
664
+ except Exception as e:
665
+ # Try replacing \"
666
+ try:
667
+ fedit = FileEdit(
668
+ file_path=fedit.file_path,
669
+ file_edit_using_search_replace_blocks=fedit.file_edit_using_search_replace_blocks.replace(
670
+ '\\"', '"'
671
+ ),
672
+ )
673
+ return _do_diff_edit(fedit)
674
+ except Exception:
675
+ pass
676
+ raise e
677
+
678
+
679
+ def _do_diff_edit(fedit: FileEdit) -> str:
651
680
  console.log(f"Editing file: {fedit.file_path}")
652
681
 
653
682
  if not os.path.isabs(fedit.file_path):
@@ -824,70 +853,24 @@ def which_tool_name(name: str) -> Type[TOOLS]:
824
853
  raise ValueError(f"Unknown tool name: {name}")
825
854
 
826
855
 
856
+ TOOL_CALLS: list[TOOLS] = []
857
+
858
+
827
859
  def get_tool_output(
828
- args: dict[object, object]
829
- | Confirmation
830
- | BashCommand
831
- | BashInteraction
832
- | ResetShell
833
- | WriteIfEmpty
834
- | FileEditFindReplace
835
- | FileEdit
836
- | AIAssistant
837
- | DoneFlag
838
- | ReadImage
839
- | Initialize
840
- | ReadFile
841
- | Mouse
842
- | Keyboard
843
- | ScreenShot
844
- | GetScreenInfo,
860
+ args: dict[object, object] | TOOLS,
845
861
  enc: tiktoken.Encoding,
846
862
  limit: float,
847
863
  loop_call: Callable[[str, float], tuple[str, float]],
848
864
  max_tokens: Optional[int],
849
865
  ) -> tuple[list[str | ImageData | DoneFlag], float]:
850
- global IS_IN_DOCKER
866
+ global IS_IN_DOCKER, TOOL_CALLS
851
867
  if isinstance(args, dict):
852
- adapter = TypeAdapter[
853
- Confirmation
854
- | BashCommand
855
- | BashInteraction
856
- | ResetShell
857
- | WriteIfEmpty
858
- | FileEditFindReplace
859
- | FileEdit
860
- | AIAssistant
861
- | DoneFlag
862
- | ReadImage
863
- | ReadFile
864
- | Initialize
865
- | Mouse
866
- | Keyboard
867
- | ScreenShot
868
- | GetScreenInfo,
869
- ](
870
- Confirmation
871
- | BashCommand
872
- | BashInteraction
873
- | ResetShell
874
- | WriteIfEmpty
875
- | FileEditFindReplace
876
- | FileEdit
877
- | AIAssistant
878
- | DoneFlag
879
- | ReadImage
880
- | ReadFile
881
- | Initialize
882
- | Mouse
883
- | Keyboard
884
- | ScreenShot
885
- | GetScreenInfo
886
- )
868
+ adapter = TypeAdapter[TOOLS](TOOLS)
887
869
  arg = adapter.validate_python(args)
888
870
  else:
889
871
  arg = args
890
872
  output: tuple[str | DoneFlag | ImageData, float]
873
+ TOOL_CALLS.append(arg)
891
874
  if isinstance(arg, Confirmation):
892
875
  console.print("Calling ask confirmation tool")
893
876
  output = ask_confirmation(arg), 0.0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: wcgw
3
- Version: 2.2.0
3
+ Version: 2.2.1
4
4
  Summary: Shell and coding agent on claude and chatgpt
5
5
  Project-URL: Homepage, https://github.com/rusiaaman/wcgw
6
6
  Author-email: Aman Rusia <gapypi@arcfu.com>
@@ -2,7 +2,7 @@ wcgw/__init__.py,sha256=9K2QW7QuSLhMTVbKbBYd9UUp-ZyrfBrxcjuD_xk458k,118
2
2
  wcgw/types_.py,sha256=5QM97K3kOJ7vNBgZ1NYmKPqwSe9WfzDImAIvjbRcClo,1772
3
3
  wcgw/client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  wcgw/client/__main__.py,sha256=wcCrL4PjG51r5wVKqJhcoJPTLfHW0wNbD31DrUN0MWI,28
5
- wcgw/client/anthropic_client.py,sha256=Lfby2Tj4NZn5nrUH6d0VGhdHkD8Z_xk-qtG-S7XB0rc,20664
5
+ wcgw/client/anthropic_client.py,sha256=68JNQAdH9Cg5lWTMKX3SvGNbYqPGyGe02VWWUbLaNss,20938
6
6
  wcgw/client/cli.py,sha256=-z0kpDAW3mzfQrQeZfaVJhBCAQY3HXnt9GdgQ8s-u0Y,1003
7
7
  wcgw/client/common.py,sha256=grH-yV_4tnTQZ29xExn4YicGLxEq98z-HkEZwH0ReSg,1410
8
8
  wcgw/client/computer_use.py,sha256=35NKAlMrxwD0TBlMMRnbCwz4g8TBRGOlcy-cmS-yJ_A,15247
@@ -10,13 +10,13 @@ wcgw/client/diff-instructions.txt,sha256=s5AJKG23JsjwRYhFZFQVvwDpF67vElawrmdXwvu
10
10
  wcgw/client/openai_client.py,sha256=xfB96A4qZM7-CUJhyDMqX9rUIzhCw4AtV9ryTKE8SOM,17885
11
11
  wcgw/client/openai_utils.py,sha256=YNwCsA-Wqq7jWrxP0rfQmBTb1dI0s7dWXzQqyTzOZT4,2629
12
12
  wcgw/client/sys_utils.py,sha256=GajPntKhaTUMn6EOmopENWZNR2G_BJyuVbuot0x6veI,1376
13
- wcgw/client/tools.py,sha256=fbMzRXudIBwLQwpINEYYx4nBDc5uyu7pSUF3pZUarug,35931
13
+ wcgw/client/tools.py,sha256=e5ul5ZNjvP7UJ8-gubHiNCYjcBIjAPkbkBckKnwKJp4,35724
14
14
  wcgw/client/mcp_server/Readme.md,sha256=I8N4dHkTUVGNQ63BQkBMBhCCBTgqGOSF_pUR6iOEiUk,2495
15
15
  wcgw/client/mcp_server/__init__.py,sha256=hyPPwO9cabAJsOMWhKyat9yl7OlSmIobaoAZKHu3DMc,381
16
- wcgw/client/mcp_server/server.py,sha256=VPs6Dm2XHoMmsUKDJlyxh-mJQzqzlrtyviEi_LutjLk,10951
16
+ wcgw/client/mcp_server/server.py,sha256=DCclYqC8mRzCti2pztnm8ZkwGeXnzzNlkvi5Yh02D20,11226
17
17
  wcgw/relay/serve.py,sha256=KLYjTvM9CfqdxgFOfHM8LUkFGZ9kKyyJunpNdEIFQUk,8766
18
18
  wcgw/relay/static/privacy.txt,sha256=s9qBdbx2SexCpC_z33sg16TptmAwDEehMCLz4L50JLc,529
19
- wcgw-2.2.0.dist-info/METADATA,sha256=bJcxxDqBnsvcO_NKSkJ95wl9Y-EK7P-V_T6XPwoUI2s,7939
20
- wcgw-2.2.0.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
21
- wcgw-2.2.0.dist-info/entry_points.txt,sha256=eKo1omwbAggWlQ0l7GKoR7uV1-j16nk9tK0BhC2Oz_E,120
22
- wcgw-2.2.0.dist-info/RECORD,,
19
+ wcgw-2.2.1.dist-info/METADATA,sha256=ZI81P-DAaTxkmZmU8tBJ8tYAchOEJ3p0VeRGXpWi3IQ,7939
20
+ wcgw-2.2.1.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
21
+ wcgw-2.2.1.dist-info/entry_points.txt,sha256=eKo1omwbAggWlQ0l7GKoR7uV1-j16nk9tK0BhC2Oz_E,120
22
+ wcgw-2.2.1.dist-info/RECORD,,
File without changes