syntaxmatrix 2.3.5__py3-none-any.whl → 2.5.5.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
File without changes
@@ -0,0 +1,24 @@
1
+ # syntaxmatrix/agent_tools.py
2
+ from dataclasses import dataclass
3
+ from typing import Callable, Optional, Dict, Any, List, Literal
4
+
5
+ Phase = Literal["sanitize_early", "domain_patches", "syntax_fixes", "final_repair"]
6
+
7
+ @dataclass
8
+ class CodeTool:
9
+ name: str
10
+ phase: Phase
11
+ fn: Callable[[str, Dict[str, Any]], str]
12
+ when: Optional[Callable[[str, Dict[str, Any]], bool]] = None
13
+ priority: int = 100 # lower runs earlier within the phase
14
+
15
+ class ToolRunner:
16
+ def __init__(self, tools: List[CodeTool]):
17
+ # stable order: phase → priority → name
18
+ self.tools = sorted(tools, key=lambda t: (t.phase, t.priority, t.name))
19
+
20
+ def run(self, code: str, ctx: Dict[str, Any]) -> str:
21
+ for t in self.tools:
22
+ if t.when is None or t.when(code, ctx):
23
+ code = t.fn(code, ctx)
24
+ return code