Repository navigation
Expand file tree
/
Copy pathsimulate.py
More file actions
80 lines (73 loc) · 2.1 KB
/
Copy pathsimulate.py
File metadata and controls
80 lines (73 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/env python3
"""
CodeCast Automated Match Simulator (Pure Python)
Simulates a live 6-ball cricket over with realistic pauses,
triggering live reactions on the Native CodeCast Dynamic Island.
Usage: python simulate.py
"""
import time
import json
import urllib.request
MATCH_SCRIPT = [
{
"event": "task_start",
"prompt": "Fix JWT token expiry and refactor auth controller",
"delay": 1.0
},
{
"tool_name": "FileEdit",
"file_path": "src/controllers/auth.py",
"delay": 3.5
},
{
"tool_name": "pytest",
"command": "pytest tests/test_auth.py",
"error": "AssertionError: expected 401 to equal 200",
"exit_code": 1,
"delay": 4.5
},
{
"event": "permission_request",
"tool_name": "AskUser",
"command": "Allow write access to production database config?",
"delay": 4.0
},
{
"tool_name": "Replace",
"file_path": "src/controllers/auth.py",
"delay": 3.5
},
{
"tool_name": "pytest",
"command": "pytest -v",
"exit_code": 0,
"delay": 4.5
},
{
"event": "task_complete",
"prompt": "Successfully resolved auth bug and verified all 16 tests!",
"delay": 3.0
}
]
def send_event(data):
url = "http://127.0.0.1:3001/api/event"
try:
req = urllib.request.Request(
url,
data=json.dumps(data).encode("utf-8"),
headers={"Content-Type": "application/json"}
)
with urllib.request.urlopen(req, timeout=1.0) as resp:
print(f" [Sent Event] -> {data.get('tool_name') or data.get('event')}")
except Exception as e:
print(f" [Error] Could not connect to http://127.0.0.1:3001. Is CodeCast running? ({e})")
def main():
print("=" * 60)
print("🏏 CodeCast — Starting Match Replay Simulation...")
print("=" * 60)
for i, step in enumerate(MATCH_SCRIPT):
time.sleep(step.get("delay", 2.0))
send_event(step)
print("\n🏆 Match Simulation Complete!")
if __name__ == "__main__":
main()