lathe-agent 0.1.0__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.
Files changed (74) hide show
  1. lathe/__init__.py +4 -0
  2. lathe/__main__.py +6 -0
  3. lathe/bench/__init__.py +43 -0
  4. lathe/bench/evaluator.py +176 -0
  5. lathe/bench/models.py +69 -0
  6. lathe/bench/report.py +241 -0
  7. lathe/bench/runner.py +185 -0
  8. lathe/bench/tasks/__init__.py +540 -0
  9. lathe/cli.py +868 -0
  10. lathe/config.py +483 -0
  11. lathe/context/__init__.py +45 -0
  12. lathe/context/budget.py +526 -0
  13. lathe/context/index.py +721 -0
  14. lathe/context/repomap.py +599 -0
  15. lathe/llm/__init__.py +21 -0
  16. lathe/llm/base.py +67 -0
  17. lathe/llm/factory.py +88 -0
  18. lathe/llm/hf.py +294 -0
  19. lathe/llm/ollama.py +208 -0
  20. lathe/llm/openai_compat.py +237 -0
  21. lathe/llm/types.py +86 -0
  22. lathe/memory/__init__.py +45 -0
  23. lathe/memory/commands.py +162 -0
  24. lathe/memory/instructions.py +326 -0
  25. lathe/memory/mcp.py +319 -0
  26. lathe/memory/sessions.py +291 -0
  27. lathe/merge/__init__.py +85 -0
  28. lathe/merge/colab.py +123 -0
  29. lathe/merge/compatibility.py +315 -0
  30. lathe/merge/generator.py +175 -0
  31. lathe/merge/gguf.py +362 -0
  32. lathe/merge/hub.py +130 -0
  33. lathe/merge/models.py +109 -0
  34. lathe/merge/resources.py +221 -0
  35. lathe/merge/runner.py +161 -0
  36. lathe/merge/wizard.py +256 -0
  37. lathe/orchestrator/__init__.py +86 -0
  38. lathe/orchestrator/agent.py +533 -0
  39. lathe/orchestrator/dual.py +825 -0
  40. lathe/orchestrator/events.py +182 -0
  41. lathe/orchestrator/review.py +173 -0
  42. lathe/orchestrator/router.py +869 -0
  43. lathe/prompts/__init__.py +34 -0
  44. lathe/prompts/agent.md +62 -0
  45. lathe/prompts/review.md +47 -0
  46. lathe/safety/__init__.py +67 -0
  47. lathe/safety/checkpoints.py +564 -0
  48. lathe/safety/permissions.py +397 -0
  49. lathe/safety/workspace.py +287 -0
  50. lathe/session.py +33 -0
  51. lathe/tools/__init__.py +159 -0
  52. lathe/tools/base.py +207 -0
  53. lathe/tools/edit.py +385 -0
  54. lathe/tools/files.py +514 -0
  55. lathe/tools/git.py +357 -0
  56. lathe/tools/protocol.py +136 -0
  57. lathe/tools/registry.py +103 -0
  58. lathe/tools/search.py +344 -0
  59. lathe/tools/shell.py +164 -0
  60. lathe/tools/tests.py +379 -0
  61. lathe/ui/__init__.py +27 -0
  62. lathe/ui/agent_view.py +308 -0
  63. lathe/ui/banner.py +58 -0
  64. lathe/ui/commands.py +701 -0
  65. lathe/ui/completer.py +113 -0
  66. lathe/ui/diff.py +40 -0
  67. lathe/ui/repl.py +398 -0
  68. lathe/ui/status.py +84 -0
  69. lathe/ui/theme.py +35 -0
  70. lathe_agent-0.1.0.dist-info/METADATA +627 -0
  71. lathe_agent-0.1.0.dist-info/RECORD +74 -0
  72. lathe_agent-0.1.0.dist-info/WHEEL +4 -0
  73. lathe_agent-0.1.0.dist-info/entry_points.txt +2 -0
  74. lathe_agent-0.1.0.dist-info/licenses/LICENSE +19 -0
lathe/__init__.py ADDED
@@ -0,0 +1,4 @@
1
+ """Lathe: Terminal AI coding agent using local and open-source models."""
2
+
3
+ __version__ = "0.1.0"
4
+ __all__ = ["__version__"]
lathe/__main__.py ADDED
@@ -0,0 +1,6 @@
1
+ """Package execution entry point for `python -m lathe`."""
2
+
3
+ from lathe.cli import app
4
+
5
+ if __name__ == "__main__":
6
+ app()
@@ -0,0 +1,43 @@
1
+ """Evaluation harness for assessing model coding correctness and latency on Lathe mini-bench."""
2
+
3
+ from lathe.bench.evaluator import (
4
+ evaluate_c_task,
5
+ evaluate_python_task,
6
+ evaluate_task_solution,
7
+ evaluate_tool_task,
8
+ )
9
+ from lathe.bench.models import (
10
+ BenchmarkSuiteResult,
11
+ BenchTask,
12
+ ModelBenchSummary,
13
+ TaskResult,
14
+ )
15
+ from lathe.bench.report import (
16
+ generate_benchmark_chart,
17
+ render_benchmark_table,
18
+ save_benchmark_json,
19
+ )
20
+ from lathe.bench.runner import (
21
+ run_benchmark_suite,
22
+ run_model_benchmark,
23
+ run_task_evaluation,
24
+ )
25
+ from lathe.bench.tasks import ALL_BENCH_TASKS
26
+
27
+ __all__ = [
28
+ "ALL_BENCH_TASKS",
29
+ "BenchmarkSuiteResult",
30
+ "BenchTask",
31
+ "ModelBenchSummary",
32
+ "TaskResult",
33
+ "evaluate_c_task",
34
+ "evaluate_python_task",
35
+ "evaluate_task_solution",
36
+ "evaluate_tool_task",
37
+ "generate_benchmark_chart",
38
+ "render_benchmark_table",
39
+ "run_benchmark_suite",
40
+ "run_model_benchmark",
41
+ "run_task_evaluation",
42
+ "save_benchmark_json",
43
+ ]
@@ -0,0 +1,176 @@
1
+ """Task output evaluation for Python, C, and tool-calling benchmark tasks."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ import re
7
+ import shutil
8
+ import subprocess
9
+ import sys
10
+ import tempfile
11
+ from pathlib import Path
12
+ from typing import Any
13
+
14
+ from lathe.bench.models import BenchTask
15
+
16
+
17
+ def extract_code_block(text: str, language: str) -> str:
18
+ """Extract code from fenced markdown blocks or return raw text."""
19
+ # Match ```python ... ``` or ```c ... ```
20
+ pattern = rf"```{language}\s*\n(.*?)\n```"
21
+ match = re.search(pattern, text, re.DOTALL | re.IGNORECASE)
22
+ if match:
23
+ return match.group(1).strip()
24
+
25
+ # Match generic ``` ... ```
26
+ generic_match = re.search(r"```\s*\n(.*?)\n```", text, re.DOTALL)
27
+ if generic_match:
28
+ return generic_match.group(1).strip()
29
+
30
+ return text.strip()
31
+
32
+
33
+ def evaluate_python_task(
34
+ generated_code: str,
35
+ test_code: str,
36
+ timeout: float = 5.0,
37
+ ) -> tuple[bool, str | None]:
38
+ """Execute Python code combined with unit tests in an isolated subprocess."""
39
+ clean_code = extract_code_block(generated_code, "python")
40
+ full_script = f"{clean_code}\n\n# --- Test Harness ---\n{test_code}\n"
41
+
42
+ try:
43
+ proc = subprocess.run(
44
+ [sys.executable, "-c", full_script],
45
+ capture_output=True,
46
+ text=True,
47
+ timeout=timeout,
48
+ )
49
+ if proc.returncode == 0:
50
+ return True, None
51
+ err = proc.stderr.strip() or proc.stdout.strip()
52
+ return False, err or "Python test assertion failed."
53
+ except subprocess.TimeoutExpired:
54
+ return False, f"Execution timed out ({timeout}s)."
55
+ except Exception as exc:
56
+ return False, str(exc)
57
+
58
+
59
+ def evaluate_c_task(
60
+ generated_code: str,
61
+ test_code: str,
62
+ timeout: float = 5.0,
63
+ ) -> tuple[bool, str | None]:
64
+ """Compile C solution with test harness using clang/gcc and run binary."""
65
+ compiler = shutil.which("clang") or shutil.which("gcc")
66
+ if not compiler:
67
+ return False, "C compiler (clang or gcc) not found in system PATH."
68
+
69
+ clean_code = extract_code_block(generated_code, "c")
70
+ full_source = f"{clean_code}\n\n{test_code}\n"
71
+
72
+ with tempfile.TemporaryDirectory() as td:
73
+ src_path = Path(td) / "solution.c"
74
+ bin_path = Path(td) / "solution_bin"
75
+ src_path.write_text(full_source, encoding="utf-8")
76
+
77
+ # Compile
78
+ compile_proc = subprocess.run(
79
+ [compiler, "-O2", str(src_path), "-o", str(bin_path)],
80
+ capture_output=True,
81
+ text=True,
82
+ timeout=10.0,
83
+ )
84
+ if compile_proc.returncode != 0:
85
+ return False, f"C compilation error:\n{compile_proc.stderr.strip()}"
86
+
87
+ # Run
88
+ try:
89
+ run_proc = subprocess.run(
90
+ [str(bin_path)],
91
+ capture_output=True,
92
+ text=True,
93
+ timeout=timeout,
94
+ )
95
+ if run_proc.returncode == 0:
96
+ return True, None
97
+ return False, f"C binary exited with code {run_proc.returncode} (assertion failure)."
98
+ except subprocess.TimeoutExpired:
99
+ return False, f"C execution timed out ({timeout}s)."
100
+ except Exception as exc:
101
+ return False, str(exc)
102
+
103
+
104
+ def evaluate_tool_task(
105
+ raw_output: str,
106
+ expected_tool: str | None,
107
+ expected_args: dict[str, Any],
108
+ ) -> tuple[bool, str | None]:
109
+ """Parse tool call block and verify name and required arguments match expectations."""
110
+ # 1. Look for <tool_call>{"name": ..., "arguments": ...}</tool_call>
111
+ tool_call_match = re.search(r"<tool_call>(.*?)</tool_call>", raw_output, re.DOTALL)
112
+ candidate_json = tool_call_match.group(1).strip() if tool_call_match else raw_output.strip()
113
+
114
+ # If code fenced, strip it
115
+ if candidate_json.startswith("```"):
116
+ candidate_json = extract_code_block(candidate_json, "json")
117
+
118
+ try:
119
+ data = json.loads(candidate_json)
120
+ except Exception:
121
+ # Search for first JSON object in string
122
+ brace_start = candidate_json.find("{")
123
+ brace_end = candidate_json.rfind("}")
124
+ if brace_start != -1 and brace_end > brace_start:
125
+ try:
126
+ data = json.loads(candidate_json[brace_start : brace_end + 1])
127
+ except Exception as err:
128
+ return False, f"Invalid JSON in tool call: {err}"
129
+ else:
130
+ return False, "No valid JSON tool call found in output."
131
+
132
+ if not isinstance(data, dict):
133
+ return False, "Parsed tool call is not a JSON object."
134
+
135
+ name = data.get("name")
136
+ if expected_tool and name != expected_tool:
137
+ return False, f"Expected tool '{expected_tool}', got '{name}'."
138
+
139
+ args = data.get("arguments", {})
140
+ if not isinstance(args, dict):
141
+ return False, "'arguments' field is not a dictionary."
142
+
143
+ for k, v in expected_args.items():
144
+ if k not in args:
145
+ return False, f"Missing required argument '{k}' in tool call."
146
+ if str(args[k]).strip() != str(v).strip():
147
+ return False, f"Argument '{k}' mismatch: expected '{v}', got '{args[k]}'."
148
+
149
+ return True, None
150
+
151
+
152
+ def evaluate_task_solution(
153
+ task: BenchTask,
154
+ generated_output: str,
155
+ ) -> tuple[bool, str | None]:
156
+ """Dispatch evaluation to appropriate evaluator based on task language."""
157
+ if task.is_tool_task or task.language == "tool":
158
+ return evaluate_tool_task(
159
+ raw_output=generated_output,
160
+ expected_tool=task.expected_tool,
161
+ expected_args=task.expected_args,
162
+ )
163
+
164
+ if task.language == "python":
165
+ return evaluate_python_task(
166
+ generated_code=generated_output,
167
+ test_code=task.test_code,
168
+ )
169
+
170
+ if task.language == "c":
171
+ return evaluate_c_task(
172
+ generated_code=generated_output,
173
+ test_code=task.test_code,
174
+ )
175
+
176
+ return False, f"Unsupported task language '{task.language}'."
lathe/bench/models.py ADDED
@@ -0,0 +1,69 @@
1
+ """Data models and schemas for Lathe mini-bench evaluation harness."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from dataclasses import asdict, dataclass, field
6
+ from typing import Any
7
+
8
+
9
+ @dataclass
10
+ class BenchTask:
11
+ """A coding task in the benchmark suite."""
12
+
13
+ id: str
14
+ name: str
15
+ language: str # "python", "c", or "tool"
16
+ prompt: str
17
+ entry_point: str
18
+ test_code: str
19
+ is_tool_task: bool = False
20
+ expected_tool: str | None = None
21
+ expected_args: dict[str, Any] = field(default_factory=dict)
22
+
23
+
24
+ @dataclass
25
+ class TaskResult:
26
+ """Outcome of evaluating a model on a single benchmark task."""
27
+
28
+ task_id: str
29
+ model: str
30
+ passed: bool
31
+ latency_s: float
32
+ tokens_generated: int
33
+ tokens_per_sec: float
34
+ tool_call_valid: bool | None = None
35
+ error: str | None = None
36
+ output: str = ""
37
+
38
+
39
+ @dataclass
40
+ class ModelBenchSummary:
41
+ """Aggregated benchmark metrics for a single evaluated model."""
42
+
43
+ model: str
44
+ total_tasks: int
45
+ passed_tasks: int
46
+ pass_rate: float # pass@1 percentage 0.0 - 100.0
47
+ avg_tokens_per_sec: float
48
+ avg_latency_s: float
49
+ tool_success_rate: float # percentage 0.0 - 100.0
50
+ task_results: list[TaskResult] = field(default_factory=list)
51
+
52
+
53
+ @dataclass
54
+ class BenchmarkSuiteResult:
55
+ """Full benchmark suite execution results across all evaluated models."""
56
+
57
+ timestamp: str
58
+ label: str # "Lathe mini-bench"
59
+ models: list[ModelBenchSummary]
60
+ tasks_count: int
61
+
62
+ def to_dict(self) -> dict[str, Any]:
63
+ """Convert entire benchmark result to a serializable dictionary."""
64
+ return {
65
+ "timestamp": self.timestamp,
66
+ "label": self.label,
67
+ "tasks_count": self.tasks_count,
68
+ "models": [asdict(m) for m in self.models],
69
+ }
lathe/bench/report.py ADDED
@@ -0,0 +1,241 @@
1
+ """Benchmarking reports: Rich comparison table, JSON persistence, and PNG bar chart generation."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ import struct
7
+ import zlib
8
+ from pathlib import Path
9
+
10
+ from rich.table import Table
11
+
12
+ from lathe.bench.models import BenchmarkSuiteResult
13
+
14
+
15
+ def render_benchmark_table(suite_result: BenchmarkSuiteResult) -> Table:
16
+ """Render a styled Rich table comparing candidate models on Lathe mini-bench metrics."""
17
+ table = Table(
18
+ title="[bold cyan]Lathe mini-bench[/bold cyan] [dim](Illustrative - Not Official)[/dim]",
19
+ title_style="bold",
20
+ border_style="bright_blue",
21
+ show_header=True,
22
+ header_style="bold white",
23
+ )
24
+ table.add_column("Model Evaluated", style="bold", width=34)
25
+ table.add_column("Pass@1", justify="right", width=12)
26
+ table.add_column("Solved", justify="right", width=12)
27
+ table.add_column("Tokens/sec", justify="right", width=14)
28
+ table.add_column("Avg Latency", justify="right", width=14)
29
+ table.add_column("Tool Success", justify="right", width=14)
30
+
31
+ for m in suite_result.models:
32
+ pass_color = "green" if m.pass_rate >= 70.0 else "yellow" if m.pass_rate >= 40.0 else "red"
33
+ pass_badge = f"[{pass_color}]{m.pass_rate:.1f}%[/{pass_color}]"
34
+ solved_str = f"{m.passed_tasks}/{m.total_tasks}"
35
+ tps_str = f"{m.avg_tokens_per_sec:.1f} t/s"
36
+ lat_str = f"{m.avg_latency_s:.2f}s"
37
+ tool_color = "green" if m.tool_success_rate >= 80.0 else "yellow"
38
+ tool_badge = f"[{tool_color}]{m.tool_success_rate:.1f}%[/{tool_color}]"
39
+
40
+ table.add_row(
41
+ m.model,
42
+ pass_badge,
43
+ solved_str,
44
+ tps_str,
45
+ lat_str,
46
+ tool_badge,
47
+ )
48
+
49
+ return table
50
+
51
+
52
+ def save_benchmark_json(
53
+ suite_result: BenchmarkSuiteResult,
54
+ output_dir: Path | str | None = None,
55
+ ) -> Path:
56
+ """Save benchmark results to bench/results/<date>.json."""
57
+ root = Path(output_dir) if output_dir else Path.cwd() / "bench" / "results"
58
+ root.mkdir(parents=True, exist_ok=True)
59
+ json_path = root / f"{suite_result.timestamp}.json"
60
+ json_path.write_text(json.dumps(suite_result.to_dict(), indent=2), encoding="utf-8")
61
+ return json_path
62
+
63
+
64
+ def _create_pure_python_png(
65
+ models: list[str],
66
+ pass_rates: list[float],
67
+ throughputs: list[float],
68
+ output_path: Path,
69
+ width: int = 800,
70
+ height: int = 400,
71
+ ) -> None:
72
+ """Fallback generator producing a valid PNG bar chart without external libraries."""
73
+ # Create an RGB image buffer filled with dark background (#1e1e2e -> R:30, G:30, B:46)
74
+ bg_r, bg_g, bg_b = 30, 30, 46
75
+ grid_r, grid_g, grid_b = 60, 60, 80
76
+ pass_r, pass_g, pass_b = 52, 211, 153 # emerald green
77
+ tps_r, tps_g, tps_b = 56, 189, 248 # cyan
78
+
79
+ pixels = bytearray([bg_r, bg_g, bg_b] * (width * height))
80
+
81
+ def set_pixel(x: int, y: int, r: int, g: int, b: int) -> None:
82
+ if 0 <= x < width and 0 <= y < height:
83
+ idx = (y * width + x) * 3
84
+ pixels[idx] = r
85
+ pixels[idx + 1] = g
86
+ pixels[idx + 2] = b
87
+
88
+ def draw_rect(x1: int, y1: int, x2: int, y2: int, r: int, g: int, b: int) -> None:
89
+ for py in range(max(0, y1), min(height, y2)):
90
+ for px in range(max(0, x1), min(width, x2)):
91
+ set_pixel(px, py, r, g, b)
92
+
93
+ # Margins and plotting area
94
+ margin_l = 80
95
+ margin_r = 40
96
+ margin_t = 60
97
+ margin_b = 60
98
+ plot_w = width - margin_l - margin_r
99
+ plot_h = height - margin_t - margin_b
100
+
101
+ # Draw grid baseline
102
+ draw_rect(
103
+ margin_l, height - margin_b, width - margin_r, height - margin_b + 2, grid_r, grid_g, grid_b
104
+ )
105
+
106
+ # Draw bars for each model
107
+ num_models = max(1, len(models))
108
+ slot_w = plot_w // num_models
109
+ bar_w = min(40, slot_w // 3)
110
+
111
+ for i in range(num_models):
112
+ center_x = margin_l + i * slot_w + slot_w // 2
113
+ pr = pass_rates[i] if i < len(pass_rates) else 0.0
114
+ tp = throughputs[i] if i < len(throughputs) else 0.0
115
+
116
+ # Bar 1: Pass Rate (0 - 100%)
117
+ bar1_h = int((pr / 100.0) * plot_h)
118
+ b1_x1 = center_x - bar_w - 4
119
+ b1_y1 = height - margin_b - bar1_h
120
+ draw_rect(b1_x1, b1_y1, b1_x1 + bar_w, height - margin_b, pass_r, pass_g, pass_b)
121
+
122
+ # Bar 2: Throughput (scaled to max 100 t/s)
123
+ bar2_h = int((min(100.0, tp) / 100.0) * plot_h)
124
+ b2_x1 = center_x + 4
125
+ b2_y1 = height - margin_b - bar2_h
126
+ draw_rect(b2_x1, b2_y1, b2_x1 + bar_w, height - margin_b, tps_r, tps_g, tps_b)
127
+
128
+ # Encode raw pixels as standard PNG
129
+ raw_lines = bytearray()
130
+ for row in range(height):
131
+ raw_lines.append(0) # Filter byte 0 (None)
132
+ start = row * width * 3
133
+ raw_lines.extend(pixels[start : start + width * 3])
134
+
135
+ compressed_idat = zlib.compress(bytes(raw_lines), 6)
136
+
137
+ def make_chunk(chunk_type: bytes, data: bytes) -> bytes:
138
+ crc = zlib.crc32(chunk_type + data) & 0xFFFFFFFF
139
+ return struct.pack(">I", len(data)) + chunk_type + data + struct.pack(">I", crc)
140
+
141
+ png_data = bytearray(b"\x89PNG\r\n\x1a\n")
142
+ # IHDR chunk: width, height, bit_depth=8, color_type=2 (Truecolor RGB)
143
+ ihdr_data = struct.pack(">IIBBBBB", width, height, 8, 2, 0, 0, 0)
144
+ png_data.extend(make_chunk(b"IHDR", ihdr_data))
145
+ # IDAT chunk
146
+ png_data.extend(make_chunk(b"IDAT", compressed_idat))
147
+ # IEND chunk
148
+ png_data.extend(make_chunk(b"IEND", b""))
149
+
150
+ output_path.parent.mkdir(parents=True, exist_ok=True)
151
+ output_path.write_bytes(bytes(png_data))
152
+
153
+
154
+ def generate_benchmark_chart(
155
+ suite_result: BenchmarkSuiteResult,
156
+ output_path: Path | str | None = None,
157
+ ) -> Path:
158
+ """Generate a clean comparative bar chart PNG saved to assets/bench.png."""
159
+ target_path = Path(output_path) if output_path else Path.cwd() / "assets" / "bench.png"
160
+ target_path.parent.mkdir(parents=True, exist_ok=True)
161
+
162
+ model_names = [m.model.split("/")[-1] for m in suite_result.models]
163
+ pass_rates = [m.pass_rate for m in suite_result.models]
164
+ throughputs = [m.avg_tokens_per_sec for m in suite_result.models]
165
+
166
+ # 1. Try rendering with matplotlib if installed
167
+ try:
168
+ import matplotlib # type: ignore[import-not-found]
169
+
170
+ matplotlib.use("Agg")
171
+ import matplotlib.pyplot as plt # type: ignore[import-not-found]
172
+ import numpy as np
173
+
174
+ x = np.arange(len(model_names))
175
+ bar_width = 0.35
176
+
177
+ fig, ax1 = plt.subplots(figsize=(10, 5), dpi=150)
178
+ fig.patch.set_facecolor("#1e1e2e")
179
+ ax1.set_facecolor("#1e1e2e")
180
+
181
+ # Pass@1 bars
182
+ ax1.bar(
183
+ x - bar_width / 2,
184
+ pass_rates,
185
+ bar_width,
186
+ label="Pass@1 (%)",
187
+ color="#34d399",
188
+ edgecolor="#10b981",
189
+ )
190
+ ax1.set_ylabel("Pass@1 (%)", color="#34d399", fontsize=11, fontweight="bold")
191
+ ax1.tick_params(axis="y", labelcolor="#34d399")
192
+ ax1.set_ylim(0, 100)
193
+
194
+ # Throughput bars on secondary axis
195
+ ax2 = ax1.twinx()
196
+ ax2.bar(
197
+ x + bar_width / 2,
198
+ throughputs,
199
+ bar_width,
200
+ label="Tokens/sec",
201
+ color="#38bdf8",
202
+ edgecolor="#0284c7",
203
+ )
204
+ ax2.set_ylabel("Throughput (tok/sec)", color="#38bdf8", fontsize=11, fontweight="bold")
205
+ ax2.tick_params(axis="y", labelcolor="#38bdf8")
206
+
207
+ ax1.set_xticks(x)
208
+ ax1.set_xticklabels(model_names, color="#f8fafc", fontsize=10, fontweight="bold")
209
+ ax1.tick_params(axis="x", colors="#f8fafc")
210
+
211
+ # Styling
212
+ plt.title(
213
+ "Lathe mini-bench: Pass@1 & Token Throughput (Illustrative Evaluation)",
214
+ color="#f8fafc",
215
+ fontsize=12,
216
+ fontweight="bold",
217
+ pad=15,
218
+ )
219
+ ax1.spines["bottom"].set_color("#64748b")
220
+ ax1.spines["top"].set_visible(False)
221
+ ax1.spines["left"].set_color("#34d399")
222
+ ax1.spines["right"].set_visible(False)
223
+ ax2.spines["right"].set_color("#38bdf8")
224
+ ax2.spines["top"].set_visible(False)
225
+ ax2.spines["left"].set_visible(False)
226
+ ax1.grid(axis="y", linestyle="--", alpha=0.2, color="#94a3b8")
227
+
228
+ plt.tight_layout()
229
+ plt.savefig(str(target_path), facecolor=fig.get_facecolor(), bbox_inches="tight")
230
+ plt.close(fig)
231
+ return target_path
232
+
233
+ except Exception:
234
+ # Fallback to pure-Python PNG generator
235
+ _create_pure_python_png(
236
+ models=model_names,
237
+ pass_rates=pass_rates,
238
+ throughputs=throughputs,
239
+ output_path=target_path,
240
+ )
241
+ return target_path