fix: Make VSCodium hook write to stderr to avoid breaking ACP protocol

The Vibe core in vibe-acp (ACP mode) automatically triggers hooks when
VIBE_HOME is set. However, hooks that write to stdout will break the ACP
protocol that vibe-acp uses to communicate with VSCodium.

This fix modifies the VSCodium hook (mistral-vibe-code/post_turn.py) to:
- Write all output to stderr instead of stdout
- VSCodium will still display stderr output in the UI
- This avoids corrupting the ACP communication channel

The simpler approach:
1. Set VIBE_HOME environment variable (via shell wrapper)
2. Let Vibe core auto-trigger hooks
3. Hooks write to stderr (not stdout)

This is simpler and more reliable than the watchdog-based approach.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
user
2026-10-25 18:33:04 +01:00
parent eb8d85214f
commit 901dbca119
@@ -46,7 +46,7 @@ import subprocess
import logging
from pathlib import Path
# Configure logging
# Configure logging to stderr
logging.basicConfig(
level=logging.WARNING,
format='%(levelname)s [post_turn.py] %(message)s',
@@ -54,6 +54,10 @@ logging.basicConfig(
)
LOG = logging.getLogger(__name__)
# IMPORTANT: This hook writes to STDERR instead of STDOUT to avoid
# breaking the ACP protocol that vibe-acp uses to communicate with VSCodium.
# VSCodium will still display stderr output in the UI.
def get_session_dir() -> Path:
"""Resolve the session directory from stdin payload or environment.
@@ -157,26 +161,23 @@ def main():
if result.returncode != 0:
LOG.error(f"agent-cost-estimator failed:\n{result.stderr}")
# Return error message
print(json.dumps({
"system_message": f"-- [cost: error - {result.stderr.strip()}]"
}))
# Write to stderr instead of stdout to avoid breaking ACP protocol
print(f"-- [cost: error - {result.stderr.strip()}]", file=sys.stderr)
return
# Format the output
message = format_cost_output(result.stdout)
print(json.dumps({"system_message": f"-- {message}"}))
# Write to stderr instead of stdout to avoid breaking ACP protocol
print(f"-- {message}", file=sys.stderr)
except subprocess.TimeoutExpired:
LOG.error("agent-cost-estimator timed out after 30 seconds")
print(json.dumps({
"system_message": "-- [cost: timeout]"
}))
# Write to stderr instead of stdout to avoid breaking ACP protocol
print("-- [cost: timeout]", file=sys.stderr)
except Exception as e:
LOG.error(f"Unexpected error: {e}")
print(json.dumps({
"system_message": f"-- [cost: error - {str(e)}]"
}))
# Write to stderr instead of stdout to avoid breaking ACP protocol
print(f"-- [cost: error - {str(e)}]", file=sys.stderr)
if __name__ == "__main__":