diff --git a/pyproject.toml b/pyproject.toml index cc3d716..9afc2fc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] authors = [{ name = "Aman Rusia", email = "gapypi@arcfu.com" }] name = "wcgw" -version = "2.8.8" +version = "2.8.9" description = "Shell and coding agent on claude and chatgpt" readme = "README.md" requires-python = ">=3.11, <3.13" diff --git a/src/wcgw/client/tools.py b/src/wcgw/client/tools.py index f3c03ef..0241fc2 100644 --- a/src/wcgw/client/tools.py +++ b/src/wcgw/client/tools.py @@ -146,6 +146,7 @@ def start_shell(is_restricted_mode: bool, initial_dir: str) -> pexpect.spawn: # encoding="utf-8", timeout=TIMEOUT, cwd=initial_dir, + codec_errors="backslashreplace", ) shell.sendline( f"export PROMPT_COMMAND= PS1={PROMPT_CONST}" @@ -161,6 +162,7 @@ def start_shell(is_restricted_mode: bool, initial_dir: str) -> pexpect.spawn: # echo=False, encoding="utf-8", timeout=TIMEOUT, + codec_errors="backslashreplace", ) shell.sendline(f"export PS1={PROMPT_CONST}") shell.expect(PROMPT_CONST, timeout=TIMEOUT) @@ -256,7 +258,9 @@ def ensure_env_and_bg_jobs(self) -> Optional[int]: before = "\n".join(before_lines).strip() counts += 1 if counts > 100: - raise ValueError("Error in understanding shell output. This shouldn't happen, likely shell is in a bad state, please reset it") + raise ValueError( + "Error in understanding shell output. This shouldn't happen, likely shell is in a bad state, please reset it" + ) try: return int(before) @@ -273,7 +277,7 @@ def _init_shell(self) -> None: self._bash_command_mode.bash_mode == "restricted_mode", self._cwd, ) - + self._pending_output = "" # Get exit info to ensure shell is ready @@ -414,7 +418,9 @@ def update_repl_prompt(self, command: str) -> bool: index = self.shell.expect([self._prompt, pexpect.TIMEOUT], timeout=0.2) counts += 1 if counts > 100: - raise ValueError("Error in understanding shell output. This shouldn't happen, likely shell is in a bad state, please reset it") + raise ValueError( + "Error in understanding shell output. This shouldn't happen, likely shell is in a bad state, please reset it" + ) console.print(f"Prompt updated to: {self._prompt}") return True return False