wcgw 2.8.5__py3-none-any.whl → 2.8.7__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.

@@ -6,6 +6,10 @@ from typing import Callable, DefaultDict, Literal, Optional
6
6
  TOLERANCE_TYPES = Literal["SILENT", "WARNING", "ERROR"]
7
7
 
8
8
 
9
+ class SearchReplaceMatchError(Exception):
10
+ pass
11
+
12
+
9
13
  @dataclass
10
14
  class Tolerance:
11
15
  line_process: Callable[[str], str]
@@ -45,7 +49,7 @@ class FileEditOutput:
45
49
  Got error while processing the following search block:
46
50
  ---
47
51
  ```
48
- {'\n'.join(search_)}
52
+ {"\n".join(search_)}
49
53
  ```
50
54
  ---
51
55
  Error:
@@ -53,7 +57,7 @@ Error:
53
57
  ---
54
58
  """)
55
59
  if len(errors) >= max_errors:
56
- raise Exception("\n".join(errors))
60
+ raise SearchReplaceMatchError("\n".join(errors))
57
61
  if last_idx < span.start:
58
62
  new_lines.extend(self.original_content[last_idx : span.start])
59
63
 
@@ -64,7 +68,7 @@ Error:
64
68
  new_lines.extend(self.original_content[last_idx:])
65
69
 
66
70
  if errors:
67
- raise Exception("\n".join(errors))
71
+ raise SearchReplaceMatchError("\n".join(errors))
68
72
 
69
73
  return new_lines, set(warnings)
70
74
 
@@ -1,32 +1,71 @@
1
1
  import re
2
2
  from typing import Callable
3
3
 
4
- from .diff_edit import FileEditInput, FileEditOutput
4
+ from .diff_edit import FileEditInput, FileEditOutput, SearchReplaceMatchError
5
5
 
6
+ # Global regex patterns
7
+ SEARCH_MARKER = re.compile(r"^<<<<<<+\s*SEARCH\s*$")
8
+ DIVIDER_MARKER = re.compile(r"^======*\s*$")
9
+ REPLACE_MARKER = re.compile(r"^>>>>>>+\s*REPLACE\s*$")
10
+
11
+ class SearchReplaceSyntaxError(Exception):
12
+ def __init__(self, message: str):
13
+ message =f"""Got syntax error while parsing search replace blocks:
14
+ {message}
15
+ ---
16
+
17
+ Make sure blocks are in correct sequence, and the markers are in separate lines:
18
+
19
+ <{'<<<<<< SEARCH'}
20
+ example old
21
+ =======
22
+ example new
23
+ >{'>>>>>> REPLACE'}
24
+
25
+ """
26
+ super().__init__(message)
6
27
 
7
28
  def search_replace_edit(
8
29
  lines: list[str], original_content: str, logger: Callable[[str], object]
9
30
  ) -> tuple[str, str]:
10
31
  if not lines:
11
- raise Exception("Error: No input to search replace edit")
32
+ raise SearchReplaceSyntaxError("Error: No input to search replace edit")
33
+
12
34
  original_lines = original_content.split("\n")
13
35
  n_lines = len(lines)
14
36
  i = 0
15
37
  search_replace_blocks = list[tuple[list[str], list[str]]]()
38
+
16
39
  while i < n_lines:
17
- if re.match(r"^<<<<<<+\s*SEARCH\s*$", lines[i]):
40
+ if SEARCH_MARKER.match(lines[i]):
41
+ line_num = i + 1
18
42
  search_block = []
19
43
  i += 1
20
- while i < n_lines and not re.match(r"^======*\s*$", lines[i]):
44
+
45
+ while i < n_lines and not DIVIDER_MARKER.match(lines[i]):
46
+ if SEARCH_MARKER.match(lines[i]) or REPLACE_MARKER.match(lines[i]):
47
+ raise SearchReplaceSyntaxError(f"Line {i+1}: Found stray marker in SEARCH block: {lines[i]}")
21
48
  search_block.append(lines[i])
22
49
  i += 1
23
- i += 1
50
+
51
+ if i >= n_lines:
52
+ raise SearchReplaceSyntaxError(f"Line {line_num}: Unclosed SEARCH block - missing ======= marker")
53
+
24
54
  if not search_block:
25
- raise Exception("SEARCH block can not be empty")
55
+ raise SearchReplaceSyntaxError(f"Line {line_num}: SEARCH block cannot be empty")
56
+
57
+ i += 1
26
58
  replace_block = []
27
- while i < n_lines and not re.match(r"^>>>>>>+\s*REPLACE\s*$", lines[i]):
59
+
60
+ while i < n_lines and not REPLACE_MARKER.match(lines[i]):
61
+ if SEARCH_MARKER.match(lines[i]) or DIVIDER_MARKER.match(lines[i]):
62
+ raise SearchReplaceSyntaxError(f"Line {i+1}: Found stray marker in REPLACE block: {lines[i]}")
28
63
  replace_block.append(lines[i])
29
64
  i += 1
65
+
66
+ if i >= n_lines:
67
+ raise SearchReplaceSyntaxError(f"Line {line_num}: Unclosed block - missing REPLACE marker")
68
+
30
69
  i += 1
31
70
 
32
71
  for line in search_block:
@@ -38,10 +77,12 @@ def search_replace_edit(
38
77
 
39
78
  search_replace_blocks.append((search_block, replace_block))
40
79
  else:
80
+ if REPLACE_MARKER.match(lines[i]) or DIVIDER_MARKER.match(lines[i]):
81
+ raise SearchReplaceSyntaxError(f"Line {i+1}: Found stray marker outside block: {lines[i]}")
41
82
  i += 1
42
83
 
43
84
  if not search_replace_blocks:
44
- raise Exception(
85
+ raise SearchReplaceSyntaxError(
45
86
  "No valid search replace blocks found, ensure your SEARCH/REPLACE blocks are formatted correctly"
46
87
  )
47
88
 
@@ -80,7 +121,7 @@ def greedy_context_replace(
80
121
  if len(best_matches) > 1:
81
122
  # Duplicate found, try to ground using previous blocks.
82
123
  if current_block_offset == 0:
83
- raise Exception(f"""
124
+ raise SearchReplaceMatchError(f"""
84
125
  The following block matched more than once:
85
126
  ---
86
127
  ```
@@ -318,7 +318,8 @@ async def main(computer_use: bool) -> None:
318
318
  if computer_use:
319
319
  COMPUTER_USE_ON_DOCKER_ENABLED = True
320
320
 
321
- version = importlib.metadata.version("wcgw")
321
+ version = str(importlib.metadata.version("wcgw"))
322
+ tools.console.log("wcgw version: " + version)
322
323
  # Run the server using stdin/stdout streams
323
324
  async with mcp_wcgw.server.stdio.stdio_server() as (read_stream, write_stream):
324
325
  await server.run(
wcgw/client/tools.py CHANGED
@@ -130,8 +130,7 @@ def ask_confirmation(prompt: Confirmation) -> str:
130
130
  return "Yes" if response.lower() == "y" else "No"
131
131
 
132
132
 
133
- PROMPT_CONST = "#@wcgw@#"
134
- PROMPT = PROMPT_CONST
133
+ PROMPT_CONST = "#" + "@wcgw@#"
135
134
 
136
135
 
137
136
  def start_shell(is_restricted_mode: bool, initial_dir: str) -> pexpect.spawn: # type: ignore
@@ -142,36 +141,36 @@ def start_shell(is_restricted_mode: bool, initial_dir: str) -> pexpect.spawn: #
142
141
  try:
143
142
  shell = pexpect.spawn(
144
143
  cmd,
145
- env={**os.environ, **{"PS1": PROMPT}}, # type: ignore[arg-type]
144
+ env={**os.environ, **{"PS1": PROMPT_CONST}}, # type: ignore[arg-type]
146
145
  echo=False,
147
146
  encoding="utf-8",
148
147
  timeout=TIMEOUT,
149
148
  cwd=initial_dir,
150
149
  )
151
150
  shell.sendline(
152
- f"export PROMPT_COMMAND= PS1={PROMPT}"
151
+ f"export PROMPT_COMMAND= PS1={PROMPT_CONST}"
153
152
  ) # Unset prompt command to avoid interfering
154
- shell.expect(PROMPT, timeout=TIMEOUT)
153
+ shell.expect(PROMPT_CONST, timeout=TIMEOUT)
155
154
  except Exception as e:
156
155
  console.print(traceback.format_exc())
157
156
  console.log(f"Error starting shell: {e}. Retrying without rc ...")
158
157
 
159
158
  shell = pexpect.spawn(
160
159
  "/bin/bash --noprofile --norc",
161
- env={**os.environ, **{"PS1": PROMPT}}, # type: ignore[arg-type]
160
+ env={**os.environ, **{"PS1": PROMPT_CONST}}, # type: ignore[arg-type]
162
161
  echo=False,
163
162
  encoding="utf-8",
164
163
  timeout=TIMEOUT,
165
164
  )
166
- shell.sendline(f"export PS1={PROMPT}")
167
- shell.expect(PROMPT, timeout=TIMEOUT)
165
+ shell.sendline(f"export PS1={PROMPT_CONST}")
166
+ shell.expect(PROMPT_CONST, timeout=TIMEOUT)
168
167
 
169
168
  shell.sendline("stty -icanon -echo")
170
- shell.expect(PROMPT, timeout=TIMEOUT)
169
+ shell.expect(PROMPT_CONST, timeout=TIMEOUT)
171
170
  shell.sendline("set +o pipefail")
172
- shell.expect(PROMPT, timeout=TIMEOUT)
171
+ shell.expect(PROMPT_CONST, timeout=TIMEOUT)
173
172
  shell.sendline("export GIT_PAGER=cat PAGER=cat")
174
- shell.expect(PROMPT, timeout=TIMEOUT)
173
+ shell.expect(PROMPT_CONST, timeout=TIMEOUT)
175
174
  return shell
176
175
 
177
176
 
@@ -183,42 +182,6 @@ def _is_int(mystr: str) -> bool:
183
182
  return False
184
183
 
185
184
 
186
- def _ensure_env_and_bg_jobs(shell: pexpect.spawn) -> Optional[int]: # type: ignore
187
- if PROMPT != PROMPT_CONST:
188
- return None
189
- # First reset the prompt in case venv was sourced or other reasons.
190
- shell.sendline(f"export PS1={PROMPT}")
191
- shell.expect(PROMPT, timeout=0.2)
192
- # Reset echo also if it was enabled
193
- shell.sendline("stty -icanon -echo")
194
- shell.expect(PROMPT, timeout=0.2)
195
- shell.sendline("set +o pipefail")
196
- shell.expect(PROMPT, timeout=0.2)
197
- shell.sendline("export GIT_PAGER=cat PAGER=cat")
198
- shell.expect(PROMPT, timeout=0.2)
199
- shell.sendline("jobs | wc -l")
200
- before = ""
201
-
202
- while not _is_int(before): # Consume all previous output
203
- try:
204
- shell.expect(PROMPT, timeout=0.2)
205
- except pexpect.TIMEOUT:
206
- console.print(f"Couldn't get exit code, before: {before}")
207
- raise
208
-
209
- before_val = shell.before
210
- if not isinstance(before_val, str):
211
- before_val = str(before_val)
212
- assert isinstance(before_val, str)
213
- before_lines = render_terminal_output(before_val)
214
- before = "\n".join(before_lines).strip()
215
-
216
- try:
217
- return int(before)
218
- except ValueError:
219
- raise ValueError(f"Malformed output: {before}")
220
-
221
-
222
185
  BASH_CLF_OUTPUT = Literal["repl", "pending"]
223
186
 
224
187
 
@@ -242,7 +205,7 @@ class BashState:
242
205
  )
243
206
  self._mode = mode or Modes.wcgw
244
207
  self._whitelist_for_overwrite: set[str] = whitelist_for_overwrite or set()
245
-
208
+ self._prompt = PROMPT_CONST
246
209
  self._init_shell()
247
210
 
248
211
  @property
@@ -261,7 +224,47 @@ class BashState:
261
224
  def write_if_empty_mode(self) -> WriteIfEmptyMode:
262
225
  return self._write_if_empty_mode
263
226
 
227
+ def ensure_env_and_bg_jobs(self) -> Optional[int]:
228
+ if self._prompt != PROMPT_CONST:
229
+ return None
230
+ shell = self.shell
231
+ # First reset the prompt in case venv was sourced or other reasons.
232
+ shell.sendline(f"export PS1={self._prompt}")
233
+ shell.expect(self._prompt, timeout=0.2)
234
+ # Reset echo also if it was enabled
235
+ shell.sendline("stty -icanon -echo")
236
+ shell.expect(self._prompt, timeout=0.2)
237
+ shell.sendline("set +o pipefail")
238
+ shell.expect(self._prompt, timeout=0.2)
239
+ shell.sendline("export GIT_PAGER=cat PAGER=cat")
240
+ shell.expect(self._prompt, timeout=0.2)
241
+ shell.sendline("jobs | wc -l")
242
+ before = ""
243
+ counts = 0
244
+ while not _is_int(before): # Consume all previous output
245
+ try:
246
+ shell.expect(self._prompt, timeout=0.2)
247
+ except pexpect.TIMEOUT:
248
+ console.print(f"Couldn't get exit code, before: {before}")
249
+ raise
250
+
251
+ before_val = shell.before
252
+ if not isinstance(before_val, str):
253
+ before_val = str(before_val)
254
+ assert isinstance(before_val, str)
255
+ before_lines = render_terminal_output(before_val)
256
+ before = "\n".join(before_lines).strip()
257
+ counts += 1
258
+ if counts > 100:
259
+ raise ValueError("Error in understanding shell output. This shouldn't happen, likely shell is in a bad state, please reset it")
260
+
261
+ try:
262
+ return int(before)
263
+ except ValueError:
264
+ raise ValueError(f"Malformed output: {before}")
265
+
264
266
  def _init_shell(self) -> None:
267
+ self._prompt = PROMPT_CONST
265
268
  self._state: Literal["repl"] | datetime.datetime = "repl"
266
269
  self._is_in_docker: Optional[str] = ""
267
270
  # Ensure self._cwd exists
@@ -270,11 +273,11 @@ class BashState:
270
273
  self._bash_command_mode.bash_mode == "restricted_mode",
271
274
  self._cwd,
272
275
  )
273
-
276
+
274
277
  self._pending_output = ""
275
278
 
276
279
  # Get exit info to ensure shell is ready
277
- _ensure_env_and_bg_jobs(self._shell)
280
+ self.ensure_env_and_bg_jobs()
278
281
 
279
282
  @property
280
283
  def shell(self) -> pexpect.spawn: # type: ignore
@@ -306,9 +309,13 @@ class BashState:
306
309
  def cwd(self) -> str:
307
310
  return self._cwd
308
311
 
312
+ @property
313
+ def prompt(self) -> str:
314
+ return self._prompt
315
+
309
316
  def update_cwd(self) -> str:
310
317
  self.shell.sendline("pwd")
311
- self.shell.expect(PROMPT, timeout=0.2)
318
+ self.shell.expect(self._prompt, timeout=0.2)
312
319
  before_val = self.shell.before
313
320
  if not isinstance(before_val, str):
314
321
  before_val = str(before_val)
@@ -388,6 +395,30 @@ class BashState:
388
395
  def pending_output(self) -> str:
389
396
  return self._pending_output
390
397
 
398
+ def update_repl_prompt(self, command: str) -> bool:
399
+ if re.match(r"^wcgw_update_prompt\(\)$", command.strip()):
400
+ self.shell.sendintr()
401
+ index = self.shell.expect([self._prompt, pexpect.TIMEOUT], timeout=0.2)
402
+ if index == 0:
403
+ return True
404
+ before = self.shell.before or ""
405
+ assert before, "Something went wrong updating repl prompt"
406
+ self._prompt = before.split("\n")[-1].strip()
407
+ # Escape all regex
408
+ self._prompt = re.escape(self._prompt)
409
+ console.print(f"Trying to update prompt to: {self._prompt.encode()!r}")
410
+ index = 0
411
+ counts = 0
412
+ while index == 0:
413
+ # Consume all REPL prompts till now
414
+ index = self.shell.expect([self._prompt, pexpect.TIMEOUT], timeout=0.2)
415
+ counts += 1
416
+ if counts > 100:
417
+ raise ValueError("Error in understanding shell output. This shouldn't happen, likely shell is in a bad state, please reset it")
418
+ console.print(f"Prompt updated to: {self._prompt}")
419
+ return True
420
+ return False
421
+
391
422
 
392
423
  BASH_STATE = BashState(os.getcwd(), None, None, None, None)
393
424
  INITIALIZED = False
@@ -544,28 +575,6 @@ WAITING_INPUT_MESSAGE = """A command is already running. NOTE: You can't run mul
544
575
  """
545
576
 
546
577
 
547
- def update_repl_prompt(command: str) -> bool:
548
- global PROMPT
549
- if re.match(r"^wcgw_update_prompt\(\)$", command.strip()):
550
- BASH_STATE.shell.sendintr()
551
- index = BASH_STATE.shell.expect([PROMPT, pexpect.TIMEOUT], timeout=0.2)
552
- if index == 0:
553
- return True
554
- before = BASH_STATE.shell.before or ""
555
- assert before, "Something went wrong updating repl prompt"
556
- PROMPT = before.split("\n")[-1].strip()
557
- # Escape all regex
558
- PROMPT = re.escape(PROMPT)
559
- console.print(f"Trying to update prompt to: {PROMPT.encode()!r}")
560
- index = 0
561
- while index == 0:
562
- # Consume all REPL prompts till now
563
- index = BASH_STATE.shell.expect([PROMPT, pexpect.TIMEOUT], timeout=0.2)
564
- console.print(f"Prompt updated to: {PROMPT}")
565
- return True
566
- return False
567
-
568
-
569
578
  def get_status() -> str:
570
579
  status = "\n\n---\n\n"
571
580
  if BASH_STATE.state == "pending":
@@ -573,7 +582,7 @@ def get_status() -> str:
573
582
  status += "running for = " + BASH_STATE.get_pending_for() + "\n"
574
583
  status += "cwd = " + BASH_STATE.cwd + "\n"
575
584
  else:
576
- bg_jobs = _ensure_env_and_bg_jobs(BASH_STATE.shell)
585
+ bg_jobs = BASH_STATE.ensure_env_and_bg_jobs()
577
586
  bg_desc = ""
578
587
  if bg_jobs and bg_jobs > 0:
579
588
  bg_desc = f"; {bg_jobs} background jobs running"
@@ -643,7 +652,7 @@ def execute_bash(
643
652
  if isinstance(bash_arg, BashCommand):
644
653
  if BASH_STATE.bash_command_mode.allowed_commands == "none":
645
654
  return "Error: BashCommand not allowed in current mode", 0.0
646
- updated_repl_mode = update_repl_prompt(bash_arg.command)
655
+ updated_repl_mode = BASH_STATE.update_repl_prompt(bash_arg.command)
647
656
  if updated_repl_mode:
648
657
  BASH_STATE.set_repl()
649
658
  response = (
@@ -720,7 +729,7 @@ def execute_bash(
720
729
  0.0,
721
730
  )
722
731
 
723
- updated_repl_mode = update_repl_prompt(bash_arg.send_text)
732
+ updated_repl_mode = BASH_STATE.update_repl_prompt(bash_arg.send_text)
724
733
  if updated_repl_mode:
725
734
  BASH_STATE.set_repl()
726
735
  response = "Prompt updated, you can execute REPL lines using BashCommand now"
@@ -736,11 +745,11 @@ def execute_bash(
736
745
 
737
746
  except KeyboardInterrupt:
738
747
  BASH_STATE.shell.sendintr()
739
- BASH_STATE.shell.expect(PROMPT)
748
+ BASH_STATE.shell.expect(BASH_STATE.prompt)
740
749
  return "---\n\nFailure: user interrupted the execution", 0.0
741
750
 
742
751
  wait = min(timeout_s or TIMEOUT, TIMEOUT_WHILE_OUTPUT)
743
- index = BASH_STATE.shell.expect([PROMPT, pexpect.TIMEOUT], timeout=wait)
752
+ index = BASH_STATE.shell.expect([BASH_STATE.prompt, pexpect.TIMEOUT], timeout=wait)
744
753
  if index == 1:
745
754
  text = BASH_STATE.shell.before or ""
746
755
  incremental_text = _incremental_text(text, BASH_STATE.pending_output)
@@ -754,7 +763,9 @@ def execute_bash(
754
763
  patience -= 1
755
764
  itext = incremental_text
756
765
  while remaining > 0 and patience > 0:
757
- index = BASH_STATE.shell.expect([PROMPT, pexpect.TIMEOUT], timeout=wait)
766
+ index = BASH_STATE.shell.expect(
767
+ [BASH_STATE.prompt, pexpect.TIMEOUT], timeout=wait
768
+ )
758
769
  if index == 0:
759
770
  second_wait_success = True
760
771
  break
@@ -1310,7 +1321,7 @@ def get_tool_output(
1310
1321
  # At this point we should go into the docker env
1311
1322
  res, _ = execute_bash(
1312
1323
  enc,
1313
- BashInteraction(send_text=f"export PS1={PROMPT}"),
1324
+ BashInteraction(send_text=f"export PS1={BASH_STATE.prompt}"),
1314
1325
  None,
1315
1326
  0.2,
1316
1327
  )
@@ -1459,7 +1470,7 @@ def read_files(file_paths: list[str], max_tokens: Optional[int]) -> str:
1459
1470
  if truncated or (max_tokens and max_tokens <= 0):
1460
1471
  not_reading = file_paths[i + 1 :]
1461
1472
  if not_reading:
1462
- message += f'\nNot reading the rest of the files: {", ".join(not_reading)} due to token limit, please call again'
1473
+ message += f"\nNot reading the rest of the files: {', '.join(not_reading)} due to token limit, please call again"
1463
1474
  break
1464
1475
  else:
1465
1476
  message += "```"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: wcgw
3
- Version: 2.8.5
3
+ Version: 2.8.7
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>
@@ -29,10 +29,11 @@ Description-Content-Type: text/markdown
29
29
 
30
30
  # Shell and Coding agent for Claude and Chatgpt
31
31
 
32
+ Empowering chat applications to code, build and run on your local machine.
33
+
32
34
  - Claude - An MCP server on claude desktop for autonomous shell and coding agent. (mac only)
33
35
  - Chatgpt - Allows custom gpt to talk to your shell via a relay server. (linux or mac)
34
36
 
35
-
36
37
  ⚠️ Warning: do not allow BashCommand tool without reviewing the command, it may result in data loss.
37
38
 
38
39
  [![Tests](https://github.com/rusiaaman/wcgw/actions/workflows/python-tests.yml/badge.svg?branch=main)](https://github.com/rusiaaman/wcgw/actions/workflows/python-tests.yml)
@@ -42,13 +43,14 @@ Description-Content-Type: text/markdown
42
43
  [![smithery badge](https://smithery.ai/badge/wcgw)](https://smithery.ai/server/wcgw)
43
44
 
44
45
  ## Updates
45
- - [15 Jan 2025] Modes introduced: architect, code-writer, and all powerful wcgw mode.
46
+
47
+ - [15 Jan 2025] Modes introduced: architect, code-writer, and all powerful wcgw mode.
46
48
 
47
49
  - [8 Jan 2025] Context saving tool for saving relevant file paths along with a description in a single file. Can be used as a task checkpoint or for knowledge transfer.
48
50
 
49
51
  - [29 Dec 2024] Syntax checking on file writing and edits is now stable. Made `initialize` tool call useful; sending smart repo structure to claude if any repo is referenced. Large file handling is also now improved.
50
52
 
51
- - [9 Dec 2024] [Vscode extension to paste context on Claude app](https://marketplace.visualstudio.com/items?itemName=AmanRusia.wcgw)
53
+ - [9 Dec 2024] [Vscode extension to paste context on Claude app](https://marketplace.visualstudio.com/items?itemName=AmanRusia.wcgw)
52
54
 
53
55
  - [01 Dec 2024] Removed author hosted relay server for chatgpt.
54
56
 
@@ -60,19 +62,19 @@ Description-Content-Type: text/markdown
60
62
  - ⚡ **Large file edit**: Supports large file incremental edits to avoid token limit issues. Faster than full file write.
61
63
  - ⚡ **Syntax checking on edits**: Reports feedback to the LLM if its edits have any syntax errors, so that it can redo it.
62
64
  - ⚡ **Interactive Command Handling**: Supports interactive commands using arrow keys, interrupt, and ansi escape sequences.
63
- - ⚡ **File protections**:
64
- - The AI needs to read a file at least once before it's allowed to edit or rewrite it. This avoids accidental overwrites.
65
- - Avoids context filling up while reading very large files. Files get chunked based on token length.
65
+ - ⚡ **File protections**:
66
+ - The AI needs to read a file at least once before it's allowed to edit or rewrite it. This avoids accidental overwrites.
67
+ - Avoids context filling up while reading very large files. Files get chunked based on token length.
66
68
  - On initialisation the provided workspace's directory structure is returned after selecting important files (based on .gitignore as well as a statistical approach)
67
69
  - File edit based on search-replace tries to find correct search block if it has multiple matches based on previous search blocks. Fails otherwise (for correctness).
68
70
  - File edit has spacing tolerant matching, with warning on issues like indentation mismatch. If there's no match, the closest match is returned to the AI to fix its mistakes.
69
71
  - Using Aider-like search and replace, which has better performance than tool call based search and replace.
70
- - ⚡ **Shell optimizations**:
72
+ - ⚡ **Shell optimizations**:
71
73
  - Only one command is allowed to be run at a time, simplifying management and avoiding rogue processes. There's only single shell instance at any point of time.
72
- - Current working directory is always returned after any shell command to prevent AI from getting lost.
74
+ - Current working directory is always returned after any shell command to prevent AI from getting lost.
73
75
  - Command polling exits after a quick timeout to avoid slow feedback. However, status checking has wait tolerance based on fresh output streaming from a command. Both of these approach combined provides a good shell interaction experience.
74
76
  - ⚡ **Saving repo context in a single file**: Task checkpointing using "ContextSave" tool saves detailed context in a single file. Tasks can later be resumed in a new chat asking "Resume `task id`". The saved file can be used to do other kinds of knowledge transfer, such as taking help from another AI.
75
- - ⚡ **Easily switch between various modes**:
77
+ - ⚡ **Easily switch between various modes**:
76
78
  - Ask it to run in 'architect' mode for planning. Inspired by adier's architect mode, work with Claude to come up with a plan first. Leads to better accuracy and prevents premature file editing.
77
79
  - Ask it to run in 'code-writer' mode for code editing and project building. You can provide specific paths with wild card support to prevent other files getting edited.
78
80
  - By default it runs in 'wcgw' mode that has no restrictions and full authorisation.
@@ -150,25 +152,29 @@ over here
150
152
  Then ask claude to execute shell commands, read files, edit files, run your code, etc.
151
153
 
152
154
  #### Task checkpoint or knowledge transfer
155
+
153
156
  - You can do a task checkpoint or a knowledge transfer by attaching "KnowledgeTransfer" prompt using "Attach from MCP" button.
154
157
  - On running "KnowledgeTransfer" prompt, the "ContextSave" tool will be called saving the task description and all file content together in a single file. An id for the task will be generated.
155
158
  - You can in a new chat say "Resume '<task id>'", the AI should then call "Initialize" with the task id and load the context from there.
156
159
  - Or you can directly open the file generated and share it with another AI for help.
157
160
 
158
161
  #### Modes
162
+
159
163
  There are three built-in modes. You may ask Claude to run in one of the modes, like "Use 'architect' mode"
160
- | **Mode** | **Description** | **Allows** | **Denies** | **Invoke prompt** |
164
+ | **Mode** | **Description** | **Allows** | **Denies** | **Invoke prompt** |
161
165
  |-----------------|-----------------------------------------------------------------------------|---------------------------------------------------------|----------------------------------------------|----------------------------------------------------------------------------------------------------|
162
- | **Architect** | Designed for you to work with Claude to investigate and understand your repo. | Read-only commands | FileEdit and Write tool | Run in mode='architect' |
163
- | **Code-writer** | For code writing and development | Specified path globs for editing or writing, specified commands | FileEdit for paths not matching specified glob, Write for paths not matching specified glob | Run in code writer mode, only 'tests/**' allowed, only uv command allowed |
164
- | **wcgw** | Default mode with everything allowed | Everything | Nothing | No prompt, or "Run in wcgw mode" |
166
+ | **Architect** | Designed for you to work with Claude to investigate and understand your repo. | Read-only commands | FileEdit and Write tool | Run in mode='architect' |
167
+ | **Code-writer** | For code writing and development | Specified path globs for editing or writing, specified commands | FileEdit for paths not matching specified glob, Write for paths not matching specified glob | Run in code writer mode, only 'tests/**' allowed, only uv command allowed |
168
+ | **wcgw\*\* | Default mode with everything allowed | Everything | Nothing | No prompt, or "Run in wcgw mode" |
165
169
 
166
170
  Note: in code-writer mode either all commands are allowed or none are allowed for now. If you give a list of allowed commands, Claude is instructed to run only those commands, but no actual check happens. (WIP)
167
171
 
168
- ### [Optional] Vs code extension
172
+ ### [Optional] Vs code extension
173
+
169
174
  https://marketplace.visualstudio.com/items?itemName=AmanRusia.wcgw
170
175
 
171
- Commands:
176
+ Commands:
177
+
172
178
  - Select a text and press `cmd+'` and then enter instructions. This will switch the app to Claude and paste a text containing your instructions, file path, workspace dir, and the selected text.
173
179
 
174
180
  ## Chatgpt Setup
@@ -200,3 +206,36 @@ Then run
200
206
  `uvx --from wcgw@latest wcgw_local --claude`
201
207
 
202
208
  You can now directly write messages or press enter key to open vim for multiline message and text pasting.
209
+
210
+ ## Tools
211
+
212
+ The server provides the following MCP tools:
213
+
214
+ **Shell Operations:**
215
+
216
+ - `Initialize`: Reset shell and set up workspace environment
217
+ - Parameters: `any_workspace_path` (string), `initial_files_to_read` (string[]), `mode_name` ("wcgw"|"architect"|"code_writer"), `task_id_to_resume` (string)
218
+ - `BashCommand`: Execute shell commands with timeout control
219
+ - Parameters: `command` (string), `wait_for_seconds` (int, optional)
220
+ - `BashInteraction`: Send keyboard input to running programs
221
+ - Parameters: `send_text` (string) or `send_specials` (["Enter"|"Key-up"|...]) or `send_ascii` (int[]), `wait_for_seconds` (int, optional)
222
+
223
+ **File Operations:**
224
+
225
+ - `ReadFiles`: Read content from one or more files
226
+ - Parameters: `file_paths` (string[])
227
+ - `WriteIfEmpty`: Create new files or write to empty files
228
+ - Parameters: `file_path` (string), `file_content` (string)
229
+ - `FileEdit`: Edit existing files using search/replace blocks
230
+ - Parameters: `file_path` (string), `file_edit_using_search_replace_blocks` (string)
231
+ - `ReadImage`: Read image files for display/processing
232
+ - Parameters: `file_path` (string)
233
+
234
+ **Project Management:**
235
+
236
+ - `ContextSave`: Save project context and files for Knowledge Transfer or saving task checkpoints to be resumed later
237
+ - Parameters: `id` (string), `project_root_path` (string), `description` (string), `relevant_file_globs` (string[])
238
+ - `ResetShell`: Emergency reset for shell environment
239
+ - Parameters: `should_reset` (boolean)
240
+
241
+ All tools support absolute paths and include built-in protections against common errors. See the [MCP specification](https://modelcontextprotocol.io/) for detailed protocol information.
@@ -7,12 +7,12 @@ wcgw/client/diff-instructions.txt,sha256=tmJ9Fu9XdO_72lYXQQNY9RZyx91bjxrXJf9d_KB
7
7
  wcgw/client/memory.py,sha256=8LdYsOhvCOoC1kfvDr85kNy07WnhPMvE6B2FRM2w85Y,2902
8
8
  wcgw/client/modes.py,sha256=FkDJIgjKrlJEufLq3abWfqV25BdF2pH-HnoHafy9LrA,10484
9
9
  wcgw/client/sys_utils.py,sha256=GajPntKhaTUMn6EOmopENWZNR2G_BJyuVbuot0x6veI,1376
10
- wcgw/client/tools.py,sha256=lQhWn-syIX3zLLDxNNK5GSowbU2NV3G7ytRKmj-LFlc,51248
11
- wcgw/client/file_ops/diff_edit.py,sha256=o0ucArVwn5p6QTDgYsjLfMy4TJXxUG3qcppFBNF3bbQ,16751
12
- wcgw/client/file_ops/search_replace.py,sha256=89ieDC9fTsIKPDx7CJwnwpX32dRdSlMKoBtKVXc7VWI,3971
10
+ wcgw/client/tools.py,sha256=ndIvlJlULCxqRlks9cfDJK8JqMK0Ry85Mt4kZQ0IZhQ,52216
11
+ wcgw/client/file_ops/diff_edit.py,sha256=OlJCpPSE_3T41q9H0yDORm6trjm3w6zh1EkuPTxik2A,16832
12
+ wcgw/client/file_ops/search_replace.py,sha256=Napa7IWaYPGMNdttunKyRDkb90elZE7r23B_o_htRxo,5585
13
13
  wcgw/client/mcp_server/Readme.md,sha256=I8N4dHkTUVGNQ63BQkBMBhCCBTgqGOSF_pUR6iOEiUk,2495
14
14
  wcgw/client/mcp_server/__init__.py,sha256=hyPPwO9cabAJsOMWhKyat9yl7OlSmIobaoAZKHu3DMc,381
15
- wcgw/client/mcp_server/server.py,sha256=CBOS_DSDcBf5VlHQMJJbDL-wnn_DAPDvxX3dO8yodRo,13144
15
+ wcgw/client/mcp_server/server.py,sha256=zMVa2nR2hapQZAtR34POch3VLVEEnJ6SQ8iWYLDxJrU,13199
16
16
  wcgw/client/repo_ops/display_tree.py,sha256=5FD4hfMkM2cIZnXlu7WfJswJLthj0SkuHlkGH6dpWQU,4632
17
17
  wcgw/client/repo_ops/path_prob.py,sha256=SWf0CDn37rtlsYRQ51ufSxay-heaQoVIhr1alB9tZ4M,2144
18
18
  wcgw/client/repo_ops/paths_model.vocab,sha256=M1pXycYDQehMXtpp-qAgU7rtzeBbCOiJo4qcYFY0kqk,315087
@@ -20,6 +20,12 @@ wcgw/client/repo_ops/paths_tokens.model,sha256=jiwwE4ae8ADKuTZISutXuM5Wfyc_FBmN5
20
20
  wcgw/client/repo_ops/repo_context.py,sha256=5NqRxBY0K-SBFXJ0Ybt7llzYOBD8pRkTpruMMJHWxv4,4336
21
21
  wcgw/relay/serve.py,sha256=Z5EwtaCAtKFBSnUw4mPYw0sze3Coc4Fa8gObRRG_bT0,9525
22
22
  wcgw/relay/static/privacy.txt,sha256=s9qBdbx2SexCpC_z33sg16TptmAwDEehMCLz4L50JLc,529
23
+ wcgw_cli/__init__.py,sha256=TNxXsTPgb52OhakIda9wTRh91cqoBqgQRx5TxjzQQFU,21
24
+ wcgw_cli/__main__.py,sha256=wcCrL4PjG51r5wVKqJhcoJPTLfHW0wNbD31DrUN0MWI,28
25
+ wcgw_cli/anthropic_client.py,sha256=lZWEoX_qDOJIjzbG-EKxTjJyvTSw1Y5odtv7YUUIL7k,21054
26
+ wcgw_cli/cli.py,sha256=GEje9ZBIaD5_-HK3zxZCGYaeDF8bfFxImloOR3O66Fw,1019
27
+ wcgw_cli/openai_client.py,sha256=wp4XDf3t3W6XG5LHgr6bFckePyty24BGtsOEjOrIrk0,17955
28
+ wcgw_cli/openai_utils.py,sha256=xGOb3W5ALrIozV7oszfGYztpj0FnXdD7jAxm5lEIVKY,2439
23
29
  mcp_wcgw/__init__.py,sha256=fKCgOdN7cn7gR3YGFaGyV5Goe8A2sEyllLcsRkN0i-g,2601
24
30
  mcp_wcgw/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
25
31
  mcp_wcgw/types.py,sha256=Enq5vqOPaQdObK9OQuafdLuMxb5RsLQ3k_k613fK41k,30556
@@ -42,8 +48,8 @@ mcp_wcgw/shared/memory.py,sha256=dBsOghxHz8-tycdSVo9kSujbsC8xb_tYsGmuJobuZnw,281
42
48
  mcp_wcgw/shared/progress.py,sha256=ymxOsb8XO5Mhlop7fRfdbmvPodANj7oq6O4dD0iUcnw,1048
43
49
  mcp_wcgw/shared/session.py,sha256=e44a0LQOW8gwdLs9_DE9oDsxqW2U8mXG3d5KT95bn5o,10393
44
50
  mcp_wcgw/shared/version.py,sha256=d2LZii-mgsPIxpshjkXnOTUmk98i0DT4ff8VpA_kAvE,111
45
- wcgw-2.8.5.dist-info/METADATA,sha256=N2LJBm7hqi1ZFPiNIVbkzuVqXRuB1XC_2pSSxq0cuE0,11944
46
- wcgw-2.8.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
47
- wcgw-2.8.5.dist-info/entry_points.txt,sha256=vd3tj1_Kzfp55LscJ8-6WFMM5hm9cWTfNGFCrWBnH3Q,124
48
- wcgw-2.8.5.dist-info/licenses/LICENSE,sha256=BvY8xqjOfc3X2qZpGpX3MZEmF-4Dp0LqgKBbT6L_8oI,11142
49
- wcgw-2.8.5.dist-info/RECORD,,
51
+ wcgw-2.8.7.dist-info/METADATA,sha256=xXsXNlWtzj7OgpCgknOCaiiX1qG0KkOc8IbxsLW2k1A,13053
52
+ wcgw-2.8.7.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
53
+ wcgw-2.8.7.dist-info/entry_points.txt,sha256=vd3tj1_Kzfp55LscJ8-6WFMM5hm9cWTfNGFCrWBnH3Q,124
54
+ wcgw-2.8.7.dist-info/licenses/LICENSE,sha256=BvY8xqjOfc3X2qZpGpX3MZEmF-4Dp0LqgKBbT6L_8oI,11142
55
+ wcgw-2.8.7.dist-info/RECORD,,
wcgw_cli/__init__.py ADDED
@@ -0,0 +1 @@
1
+ from .cli import app
wcgw_cli/__main__.py ADDED
@@ -0,0 +1,3 @@
1
+ from .cli import app
2
+
3
+ app()