Files
manual_slop/tests/mock_gemini_cli.py
Ed_ 9fb01ce5d1 feat(mma): complete Phase 6 and finalize Comprehensive GUI UX track
- Implement Live Worker Streaming: wire ai_client.comms_log_callback to Tier 3 streams
- Add Parallel DAG Execution using asyncio.gather for non-dependent tickets
- Implement Automatic Retry with Model Escalation (Flash-Lite -> Flash -> Pro)
- Add Tier Model Configuration UI to MMA Dashboard with project TOML persistence
- Fix FPS reporting in PerformanceMonitor to prevent transient 0.0 values
- Update Ticket model with retry_count and dictionary-like access
- Stabilize Gemini CLI integration tests and handle script approval events in simulations
- Finalize and verify all 6 phases of the implementation plan
2026-03-01 22:38:43 -05:00

109 lines
3.8 KiB
Python

import sys
import json
import subprocess
import os
def main() -> None:
sys.stderr.write(f"DEBUG: mock_gemini_cli called with args: {sys.argv}\n")
sys.stderr.write(f"DEBUG: GEMINI_CLI_HOOK_CONTEXT: {os.environ.get('GEMINI_CLI_HOOK_CONTEXT')}\n")
# Read prompt from stdin
try:
prompt = sys.stdin.read()
except EOFError:
prompt = ""
sys.stderr.write(f"DEBUG: Received prompt via stdin ({len(prompt)} chars)\n")
sys.stderr.flush()
# Skip management commands
if len(sys.argv) > 1 and sys.argv[1] in ["mcp", "extensions", "skills", "hooks"]:
return
# Check for specific simulation contexts
# Use the full prompt string since context length can vary depending on history or project state
if 'You are assigned to Ticket' in prompt:
# This is a Tier 3 worker.
pass # Let it fall through to the default mock response
elif 'PATH: Epic Initialization' in prompt:
mock_response = [
{"id": "mock-track-1", "type": "Track", "module": "core", "persona": "Tech Lead", "severity": "Medium", "goal": "Mock Goal 1", "acceptance_criteria": ["criteria 1"], "title": "Mock Goal 1"},
{"id": "mock-track-2", "type": "Track", "module": "ui", "persona": "Frontend Lead", "severity": "Low", "goal": "Mock Goal 2", "acceptance_criteria": ["criteria 2"], "title": "Mock Goal 2"}
]
print(json.dumps({
"type": "message",
"role": "assistant",
"content": json.dumps(mock_response)
}), flush=True)
print(json.dumps({
"type": "result",
"status": "success",
"stats": {"total_tokens": 100, "input_tokens": 50, "output_tokens": 50},
"session_id": "mock-session-epic"
}), flush=True)
return
elif 'PATH: Sprint Planning' in prompt or 'generate the implementation tickets' in prompt:
mock_response = [
{"id": "mock-ticket-1", "description": "Mock Ticket 1", "status": "todo", "assigned_to": "worker", "depends_on": []},
{"id": "mock-ticket-2", "description": "Mock Ticket 2", "status": "todo", "assigned_to": "worker", "depends_on": ["mock-ticket-1"]}
]
print(json.dumps({
"type": "message",
"role": "assistant",
"content": json.dumps(mock_response)
}), flush=True)
print(json.dumps({
"type": "result",
"status": "success",
"stats": {"total_tokens": 100, "input_tokens": 50, "output_tokens": 50},
"session_id": "mock-session-sprint"
}), flush=True)
return
# Check for multi-round integration test triggers
is_resume = '--resume' in " ".join(sys.argv) or 'role: tool' in prompt or 'tool_call_id' in prompt
if is_resume or 'Perform multi-round tool test' in prompt or 'Please read test.txt' in prompt or 'Deny me' in prompt:
if not is_resume:
# First round: emit tool call
print(json.dumps({
"type": "message",
"role": "assistant",
"content": "I need to check the directory first."
}), flush=True)
print(json.dumps({
"type": "tool_use",
"name": "run_powershell",
"id": "mock-call-1",
"args": {"script": "Get-ChildItem"}
}), flush=True)
print(json.dumps({
"type": "result",
"status": "success",
"stats": {"total_tokens": 10, "input_tokens": 10, "output_tokens": 0},
"session_id": "mock-session-default"
}), flush=True)
return
else:
# Second round
if "USER REJECTED" in prompt:
print(json.dumps({
"type": "message",
"role": "assistant",
"content": "Tool execution was denied. I cannot proceed."
}), flush=True)
else:
print(json.dumps({
"type": "message",
"role": "assistant",
"content": "I have processed the tool results and here is the final answer."
}), flush=True)
print(json.dumps({
"type": "result",
"status": "success",
"stats": {"total_tokens": 100, "input_tokens": 80, "output_tokens": 20},
"session_id": "mock-session-final"
}), flush=True)
return
if __name__ == "__main__":
main()