Gather every Claude Code format loop-claude reads into claude_code.py, verified on 2.1.284

This commit is contained in:
2026-09-28 20:17:39 +02:00
parent b7538bd21d
commit 80629fc6d9
9 changed files with 158 additions and 114 deletions
+8 -8
View File
@@ -7,7 +7,7 @@ import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent))
from loop_claude import file_writes, judge, main, premises, transcript
from loop_claude import claude_code, file_writes, judge, main, premises, transcript
from loop_claude.outcome import Stop
CWD = pathlib.Path("/c")
@@ -58,17 +58,17 @@ class HumanTurns(unittest.TestCase):
class Said(unittest.TestCase):
def test_renders_text_and_tool_calls_and_nothing_else(self):
self.assertEqual(transcript.said({"type": "text", "text": "hi"}), "hi")
self.assertEqual(transcript.said({"type": "text", "text": " \n"}), "")
self.assertEqual(transcript.said({"type": "tool_use", "name": "Bash", "input": {"command": "x" * 500}}, 20), '[tool Bash] {"command": "xxxxxxx')
self.assertEqual(transcript.said("not a part"), "")
self.assertEqual(claude_code.said({"type": "text", "text": "hi"}), "hi")
self.assertEqual(claude_code.said({"type": "text", "text": " \n"}), "")
self.assertEqual(claude_code.said({"type": "tool_use", "name": "Bash", "input": {"command": "x" * 500}}, 20), '[tool Bash] {"command": "xxxxxxx')
self.assertEqual(claude_code.said("not a part"), "")
class Parse(unittest.TestCase):
def test_yields_only_json_objects(self):
self.assertEqual(transcript.parse('{"type": "user"}'), {"type": "user"})
self.assertIsNone(transcript.parse("not json"))
self.assertIsNone(transcript.parse("[1, 2]"))
self.assertEqual(claude_code.parse('{"type": "user"}'), {"type": "user"})
self.assertIsNone(claude_code.parse("not json"))
self.assertIsNone(claude_code.parse("[1, 2]"))
class Grounded(unittest.TestCase):