Tools¶
pycodeloop.tools.filesystem.ReadFileTool
¶
Bases: Tool
Source code in pycodeloop/tools/filesystem.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 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 126 127 128 | |
description = "Read a text file's contents, optionally a line range. If you already read the exact same path and range in this session and it hasn't changed on disk since, this returns a short notice instead of repeating the content, to save tokens — pass force=true to get the full content again (e.g. if it scrolled out of your context after compaction)."
class-attribute
instance-attribute
¶
name = 'read_file'
class-attribute
instance-attribute
¶
parameters = {'type': 'object', 'properties': {'path': {'type': 'string', 'description': 'File path to read'}, 'offset': {'type': 'integer', 'description': '1-indexed start line'}, 'limit': {'type': 'integer', 'description': 'Max lines to read'}, 'force': {'type': 'boolean', 'description': 'Show full content even if unchanged since your last read.', 'default': False}}, 'required': ['path']}
class-attribute
instance-attribute
¶
__init__(access_log=None)
¶
Source code in pycodeloop/tools/filesystem.py
71 72 | |
run(path, offset=1, limit=None, force=False)
¶
Source code in pycodeloop/tools/filesystem.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 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 126 127 128 | |
pycodeloop.tools.filesystem.WriteFileTool
¶
Bases: Tool
Source code in pycodeloop/tools/filesystem.py
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 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 | |
dangerous = True
class-attribute
instance-attribute
¶
description = 'Write content to a file, creating or overwriting it.'
class-attribute
instance-attribute
¶
name = 'write_file'
class-attribute
instance-attribute
¶
parameters = {'type': 'object', 'properties': {'path': {'type': 'string'}, 'content': {'type': 'string'}}, 'required': ['path', 'content']}
class-attribute
instance-attribute
¶
__init__(access_log=None)
¶
Source code in pycodeloop/tools/filesystem.py
144 145 | |
preview(path, content, **_)
¶
Source code in pycodeloop/tools/filesystem.py
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | |
run(path, content)
¶
Source code in pycodeloop/tools/filesystem.py
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 | |
pycodeloop.tools.filesystem.EditFileTool
¶
Bases: Tool
Source code in pycodeloop/tools/filesystem.py
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 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 | |
dangerous = True
class-attribute
instance-attribute
¶
description = 'Replace an exact substring in a file with a new one.'
class-attribute
instance-attribute
¶
name = 'edit_file'
class-attribute
instance-attribute
¶
parameters = {'type': 'object', 'properties': {'path': {'type': 'string'}, 'old_string': {'type': 'string'}, 'new_string': {'type': 'string'}, 'replace_all': {'type': 'boolean', 'default': False}}, 'required': ['path', 'old_string', 'new_string']}
class-attribute
instance-attribute
¶
__init__(access_log=None)
¶
Source code in pycodeloop/tools/filesystem.py
215 216 | |
preview(path, old_string, new_string, replace_all=False, **_)
¶
Source code in pycodeloop/tools/filesystem.py
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 | |
run(path, old_string, new_string, replace_all=False)
¶
Source code in pycodeloop/tools/filesystem.py
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 | |
pycodeloop.tools.filesystem.DeleteFileTool
¶
Bases: Tool
Source code in pycodeloop/tools/filesystem.py
311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 | |
dangerous = True
class-attribute
instance-attribute
¶
description = 'Delete a file.'
class-attribute
instance-attribute
¶
name = 'delete_file'
class-attribute
instance-attribute
¶
parameters = {'type': 'object', 'properties': {'path': {'type': 'string'}}, 'required': ['path']}
class-attribute
instance-attribute
¶
__init__(access_log=None)
¶
Source code in pycodeloop/tools/filesystem.py
321 322 | |
preview(path, **_)
¶
Source code in pycodeloop/tools/filesystem.py
324 325 326 327 328 329 330 331 332 333 334 | |
run(path)
¶
Source code in pycodeloop/tools/filesystem.py
336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 | |
pycodeloop.tools.filesystem.ListDirTool
¶
Bases: Tool
Source code in pycodeloop/tools/filesystem.py
354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 | |
description = 'List files and directories at a given path.'
class-attribute
instance-attribute
¶
name = 'list_dir'
class-attribute
instance-attribute
¶
parameters = {'type': 'object', 'properties': {'path': {'type': 'string', 'default': '.'}}}
class-attribute
instance-attribute
¶
run(path='.')
¶
Source code in pycodeloop/tools/filesystem.py
362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 | |
pycodeloop.tools.search.GlobTool
¶
Bases: Tool
Source code in pycodeloop/tools/search.py
81 82 83 84 85 86 87 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 | |
description = "Find files by glob pattern (e.g. '**/*.py')."
class-attribute
instance-attribute
¶
name = 'glob'
class-attribute
instance-attribute
¶
parameters = {'type': 'object', 'properties': {'pattern': {'type': 'string'}, 'path': {'type': 'string', 'default': '.'}, 'max_results': {'type': 'integer', 'default': 100}}, 'required': ['pattern']}
class-attribute
instance-attribute
¶
run(pattern, path='.', max_results=100)
¶
Source code in pycodeloop/tools/search.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | |
pycodeloop.tools.search.GrepTool
¶
Bases: Tool
Source code in pycodeloop/tools/search.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | |
description = 'Search for a regex pattern across files under a path.'
class-attribute
instance-attribute
¶
name = 'grep'
class-attribute
instance-attribute
¶
parameters = {'type': 'object', 'properties': {'pattern': {'type': 'string'}, 'path': {'type': 'string', 'default': '.'}, 'max_results': {'type': 'integer', 'default': 100}}, 'required': ['pattern']}
class-attribute
instance-attribute
¶
run(pattern, path='.', max_results=100)
¶
Source code in pycodeloop/tools/search.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | |
pycodeloop.tools.bash.BashTool
¶
Bases: Tool
Source code in pycodeloop/tools/bash.py
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 | |
dangerous = True
class-attribute
instance-attribute
¶
description = 'Run a shell command and return its stdout/stderr. Not limited to the workspace root — unlike read_file/write_file/grep/etc, this runs an arbitrary command with full filesystem access, so use it for paths outside the project only when the user actually asked for that.'
class-attribute
instance-attribute
¶
name = 'bash'
class-attribute
instance-attribute
¶
parameters = {'type': 'object', 'properties': {'command': {'type': 'string'}, 'timeout': {'type': 'integer', 'default': 120}}, 'required': ['command']}
class-attribute
instance-attribute
¶
preview(command, **_)
¶
Source code in pycodeloop/tools/bash.py
30 31 | |
run(command, timeout=120)
¶
Source code in pycodeloop/tools/bash.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | |
pycodeloop.tools.web.WebFetchTool
¶
Bases: Tool
Source code in pycodeloop/tools/web.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | |
description = 'Fetch a URL and return its content as plain text.'
class-attribute
instance-attribute
¶
name = 'web_fetch'
class-attribute
instance-attribute
¶
parameters = {'type': 'object', 'properties': {'url': {'type': 'string'}, 'timeout': {'type': 'number', 'default': 30}}, 'required': ['url']}
class-attribute
instance-attribute
¶
run(url, timeout=30)
¶
Source code in pycodeloop/tools/web.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | |
pycodeloop.tools.http_request.HttpRequestTool
¶
Bases: Tool
Source code in pycodeloop/tools/http_request.py
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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 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 | |
dangerous = True
class-attribute
instance-attribute
¶
description = "Call a JSON HTTP API — any method, headers, and body. Use web_fetch instead for reading a webpage's text."
class-attribute
instance-attribute
¶
name = 'http_request'
class-attribute
instance-attribute
¶
parameters = {'type': 'object', 'properties': {'url': {'type': 'string'}, 'method': {'type': 'string', 'default': 'GET'}, 'headers': {'type': 'object'}, 'json_body': {'type': 'object', 'description': 'Sent as the JSON request body.'}, 'timeout': {'type': 'number', 'default': 30}}, 'required': ['url']}
class-attribute
instance-attribute
¶
preview(url, method='GET', headers=None, json_body=None, **_)
¶
Source code in pycodeloop/tools/http_request.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | |
run(url, method='GET', headers=None, json_body=None, timeout=30)
¶
Source code in pycodeloop/tools/http_request.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 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 | |
pycodeloop.tools.git.GitStatusTool
¶
Bases: Tool
Source code in pycodeloop/tools/git.py
34 35 36 37 38 39 40 | |
description = 'Show the working tree status (git status --porcelain).'
class-attribute
instance-attribute
¶
name = 'git_status'
class-attribute
instance-attribute
¶
parameters = {'type': 'object', 'properties': {}}
class-attribute
instance-attribute
¶
run()
¶
Source code in pycodeloop/tools/git.py
39 40 | |
pycodeloop.tools.git.GitDiffTool
¶
Bases: Tool
Source code in pycodeloop/tools/git.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | |
description = 'Show unstaged (or staged) changes as a unified diff.'
class-attribute
instance-attribute
¶
name = 'git_diff'
class-attribute
instance-attribute
¶
parameters = {'type': 'object', 'properties': {'path': {'type': 'string'}, 'staged': {'type': 'boolean', 'default': False}}}
class-attribute
instance-attribute
¶
run(path='', staged=False)
¶
Source code in pycodeloop/tools/git.py
54 55 56 57 58 59 60 61 62 63 | |
pycodeloop.tools.git.GitLogTool
¶
Bases: Tool
Source code in pycodeloop/tools/git.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | |
description = 'Show recent commit history, one line per commit.'
class-attribute
instance-attribute
¶
name = 'git_log'
class-attribute
instance-attribute
¶
parameters = {'type': 'object', 'properties': {'max_count': {'type': 'integer', 'default': 20}, 'path': {'type': 'string'}}}
class-attribute
instance-attribute
¶
run(max_count=20, path='')
¶
Source code in pycodeloop/tools/git.py
77 78 79 80 81 82 83 | |
pycodeloop.tools.git.GitCommitTool
¶
Bases: Tool
Source code in pycodeloop/tools/git.py
86 87 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 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | |
dangerous = True
class-attribute
instance-attribute
¶
description = 'Stage specific files and create a commit. `paths` is required — list every file to stage by name. Never stages the whole tree (no git add -A/-u).'
class-attribute
instance-attribute
¶
name = 'git_commit'
class-attribute
instance-attribute
¶
parameters = {'type': 'object', 'properties': {'message': {'type': 'string'}, 'paths': {'type': 'array', 'items': {'type': 'string'}, 'description': 'Files to stage (required; no catch-all).'}}, 'required': ['message', 'paths']}
class-attribute
instance-attribute
¶
preview(message, paths=None, **_)
¶
Source code in pycodeloop/tools/git.py
107 108 109 110 111 112 113 114 115 116 | |
run(message, paths=None)
¶
Source code in pycodeloop/tools/git.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | |
pycodeloop.tools.env.EnvTool
¶
Bases: Tool
Source code in pycodeloop/tools/env.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
description = 'Read environment variables. Pass `name` for one variable, or omit it to list every variable name (values whose name looks sensitive — SECRET, KEY, TOKEN, PASS/PASSWORD, AUTH, COOKIE, SESSION, CREDENTIAL, … — or a scheme://user:pass@ credential in the value, are masked).'
class-attribute
instance-attribute
¶
name = 'env'
class-attribute
instance-attribute
¶
parameters = {'type': 'object', 'properties': {'name': {'type': 'string'}}}
class-attribute
instance-attribute
¶
run(name='')
¶
Source code in pycodeloop/tools/env.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
pycodeloop.tools.sql.SqlSchemaTool
¶
Bases: Tool
Source code in pycodeloop/tools/sql.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 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 | |
dangerous = True
class-attribute
instance-attribute
¶
description = "List tables in a database, or the columns of one table. Pass a SQLAlchemy connection `url` (e.g. 'sqlite:///path/to.db', 'postgresql://user:pass@host/db', 'mysql+pymysql://user:pass@host/db'). Use before sql_query to see what's there."
class-attribute
instance-attribute
¶
name = 'sql_schema'
class-attribute
instance-attribute
¶
parameters = {'type': 'object', 'properties': {'url': {'type': 'string'}, 'table': {'type': 'string', 'description': "Omit to list every table instead of one table's columns."}}, 'required': ['url']}
class-attribute
instance-attribute
¶
preview(url, table='', **_)
¶
Source code in pycodeloop/tools/sql.py
139 140 141 | |
run(url, table='')
¶
Source code in pycodeloop/tools/sql.py
143 144 145 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 | |
pycodeloop.tools.sql.SqlQueryTool
¶
Bases: Tool
Source code in pycodeloop/tools/sql.py
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 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | |
dangerous = True
class-attribute
instance-attribute
¶
description = "Run a single read-only SQL statement (SELECT, WITH, EXPLAIN, safe PRAGMA, SHOW, or DESCRIBE — no INSERT/UPDATE/DELETE/DDL, no multiple statements) against a database and return the results as a tab-separated table. Pass a SQLAlchemy connection `url`. Use sql_schema first if you don't know the tables/columns yet."
class-attribute
instance-attribute
¶
name = 'sql_query'
class-attribute
instance-attribute
¶
parameters = {'type': 'object', 'properties': {'url': {'type': 'string'}, 'query': {'type': 'string'}, 'max_rows': {'type': 'integer', 'default': 200}}, 'required': ['url', 'query']}
class-attribute
instance-attribute
¶
preview(url, query='', **_)
¶
Source code in pycodeloop/tools/sql.py
204 205 | |
run(url, query, max_rows=200)
¶
Source code in pycodeloop/tools/sql.py
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 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | |