blob: c5cddc1360ff410500676d44775dd58bc377141b (
plain)
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
|
"""Self-check for the coding-agent wrapper (no XMPP server needed)."""
from xmpp_cli_bridge.agent import PROMPT
from xmpp_cli_bridge.__main__ import make_handler
# replicates agent.py's I/O shape: startup prompt, then "<turn>(N) > "
AGENT_LIKE = (
"import sys\nsys.stdout.write('> ');sys.stdout.flush()\n"
"for line in sys.stdin:\n"
" sys.stdout.write('turn: ' + line + '(42) > ')\n"
" sys.stdout.flush()\n"
)
def test_prompt_matches_both_forms():
assert PROMPT.search("reply text\n> ")
assert PROMPT.search("reply text\n(78412) > ")
# a reply merely containing '>' is not matched as the prompt
m = PROMPT.search("a > b\n> ")
assert m and m.end() == len("a > b\n> ")
def test_agent_like_roundtrip():
h = make_handler(
["python3", "-c", AGENT_LIKE], {"a@b"}, prompt=PROMPT, max_wait=5
)
# startup prompt drained, token-usage-style prompt stripped
assert h("list files", "a@b") == "turn: list files\n"
assert h("second", "a@b") == "turn: second\n"
|