diff --git a/agent_cost_estimator/cli.py b/agent_cost_estimator/cli.py index 6a4043b..d00582f 100644 --- a/agent_cost_estimator/cli.py +++ b/agent_cost_estimator/cli.py @@ -465,6 +465,7 @@ import sys import subprocess import json import threading +import shutil from pathlib import Path from watchdog.observers import Observer from watchdog.events import FileSystemEventHandler @@ -476,6 +477,19 @@ HOOKS_CONFIG = HOOKS_DIR / "hooks.toml" # Global reference to the vibe-acp process vibe_acp_process = None +def forward_stdin(): + # Forward data from our stdin to vibe-acp's stdin. + # This is crucial for VSCodium to communicate with the real vibe-acp. + # Without this, VSCodium hangs during initialization. + global vibe_acp_process + try: + for line in sys.stdin: + if vibe_acp_process and vibe_acp_process.stdin: + vibe_acp_process.stdin.write(line) + vibe_acp_process.stdin.flush() + except Exception as e: + print(f"stdin forwarder error: {{e}}", file=sys.stderr) + class TurnCompletionHandler(FileSystemEventHandler): def on_created(self, event): self._check_journal(event) @@ -562,7 +576,16 @@ def main(): text=True ) - # Wait for vibe-acp to complete + # Start stdin forwarder thread - CRITICAL for ACP protocol + # Without this, VSCodium cannot communicate with vibe-acp + stdin_thread = threading.Thread( + target=forward_stdin, + name="vibe-acp-stdin-forwarder", + daemon=True + ) + stdin_thread.start() + + # Wait for vibe-acp to complete (or until VSCodium terminates us) vibe_acp_process.wait() sys.exit(vibe_acp_process.returncode) except KeyboardInterrupt: