Commit 3d4449b
committed
feat: enhance REPL functionality with improved plot capture and download utilities
1. support_tools.py -- Replaced the standalone _captured_plots
list, _capture_matplotlib_plots(), and
_apply_matplotlib_patches() (~90 lines) with a single
module-level _global_plot_capture = PlotCapture() instance.
The backward-compat functions
get_captured_plots()/clear_captured_plots() now delegate to
it. No more duplicated capture logic between the class and the
old module-level functions.
2. execution.py -- Extracted _run_script_in_tempfile() shared
helper. run_r_code and run_bash_script had identical
temp-file-write → subprocess → cleanup boilerplate. Also
consolidated _LANGUAGE_MARKERS dict as single source of truth
for both detect_code_language() and strip_code_markers().
3. download.py -- Extracted _download_file() to replace the
inline download_with_progress() closure that was duplicated
inside check_and_download_s3_files, and the near-identical
download code in download_and_unzip. Also improved temp file
cleanup with finally blocks.
4. formatting.py -- Replaced 20-line manual word-wrapping with
textwrap.fill(). Removed a stray print(message) debug
statement.
5. tool_bridge.py -- Replaced per-key loop with
namespace.update(). Removed the dead
builtins._BaseAgent_custom_functions hack (no callers).
6. __init__.py -- Stopped re-exporting private helpers
_parse_docstring/_type_to_string. Tests import them directly
from schema.py, so no breakage.
One minor behavioral change (non-breaking):
run_bash_script no longer passes shell=True to subprocess.run.
Since the script has a #!/bin/bash shebang and is chmod 755,
direct execution is actually more correct. The old env/cwd
explicit args were also redundant since subprocess.run
inherits them from the parent process.1 parent 1bb0112 commit 3d4449b
6 files changed
Lines changed: 161 additions & 298 deletions
File tree
- BaseAgent
- tools
- utils
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
| 3 | + | |
2 | 4 | | |
3 | 5 | | |
4 | 6 | | |
5 | 7 | | |
6 | 8 | | |
7 | 9 | | |
8 | 10 | | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | 11 | | |
13 | 12 | | |
14 | 13 | | |
| |||
101 | 100 | | |
102 | 101 | | |
103 | 102 | | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
104 | 108 | | |
105 | 109 | | |
106 | 110 | | |
| |||
128 | 132 | | |
129 | 133 | | |
130 | 134 | | |
131 | | - | |
| 135 | + | |
132 | 136 | | |
133 | 137 | | |
134 | 138 | | |
| |||
143 | 147 | | |
144 | 148 | | |
145 | 149 | | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | 150 | | |
233 | | - | |
234 | | - | |
| 151 | + | |
235 | 152 | | |
236 | 153 | | |
237 | 154 | | |
238 | 155 | | |
239 | | - | |
240 | | - | |
| 156 | + | |
241 | 157 | | |
242 | 158 | | |
243 | 159 | | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
| 160 | + | |
| 161 | + | |
249 | 162 | | |
250 | 163 | | |
251 | 164 | | |
| |||
258 | 171 | | |
259 | 172 | | |
260 | 173 | | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | 174 | | |
265 | 175 | | |
266 | 176 | | |
267 | 177 | | |
268 | 178 | | |
269 | 179 | | |
270 | | - | |
271 | 180 | | |
272 | | - | |
273 | | - | |
274 | 181 | | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
| 182 | + | |
280 | 183 | | |
281 | | - | |
| 184 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
13 | 11 | | |
14 | 12 | | |
15 | 13 | | |
| |||
37 | 35 | | |
38 | 36 | | |
39 | 37 | | |
40 | | - | |
41 | | - | |
42 | 38 | | |
43 | 39 | | |
44 | 40 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 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 | + | |
12 | 50 | | |
13 | 51 | | |
14 | 52 | | |
| |||
36 | 74 | | |
37 | 75 | | |
38 | 76 | | |
| 77 | + | |
39 | 78 | | |
40 | 79 | | |
41 | 80 | | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
59 | 87 | | |
60 | 88 | | |
61 | 89 | | |
62 | | - | |
63 | 90 | | |
64 | 91 | | |
65 | 92 | | |
66 | 93 | | |
67 | 94 | | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
68 | 101 | | |
69 | 102 | | |
70 | 103 | | |
| |||
81 | 114 | | |
82 | 115 | | |
83 | 116 | | |
84 | | - | |
85 | 117 | | |
86 | 118 | | |
87 | 119 | | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | 120 | | |
126 | 121 | | |
127 | 122 | | |
128 | 123 | | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
129 | 128 | | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
| 129 | + | |
134 | 130 | | |
135 | 131 | | |
136 | 132 | | |
| |||
140 | 136 | | |
141 | 137 | | |
142 | 138 | | |
143 | | - | |
144 | | - | |
145 | 139 | | |
146 | 140 | | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
| |||
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
161 | | - | |
| 161 | + | |
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
| |||
0 commit comments