Tools¶
pycodeloop.core.tools.filesystem.ReadFileTool
¶
Bases: Tool
Source code in pycodeloop/core/tools/filesystem.py
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 | |
description = "Read a text file's contents, optionally a line range."
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'}}, 'required': ['path']}
class-attribute
instance-attribute
¶
run(path, offset=1, limit=None)
¶
Source code in pycodeloop/core/tools/filesystem.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | |
pycodeloop.core.tools.filesystem.WriteFileTool
¶
Bases: Tool
Source code in pycodeloop/core/tools/filesystem.py
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 | |
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
¶
preview(path, content, **_)
¶
Source code in pycodeloop/core/tools/filesystem.py
68 69 70 71 72 73 74 75 | |
run(path, content)
¶
Source code in pycodeloop/core/tools/filesystem.py
77 78 79 80 81 82 83 84 85 86 | |
pycodeloop.core.tools.filesystem.EditFileTool
¶
Bases: Tool
Source code in pycodeloop/core/tools/filesystem.py
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 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 | |
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
¶
preview(path, old_string, new_string, replace_all=False, **_)
¶
Source code in pycodeloop/core/tools/filesystem.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | |
run(path, old_string, new_string, replace_all=False)
¶
Source code in pycodeloop/core/tools/filesystem.py
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | |
pycodeloop.core.tools.filesystem.DeleteFileTool
¶
Bases: Tool
Source code in pycodeloop/core/tools/filesystem.py
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 | |
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
¶
preview(path, **_)
¶
Source code in pycodeloop/core/tools/filesystem.py
182 183 184 185 186 187 188 189 | |
run(path)
¶
Source code in pycodeloop/core/tools/filesystem.py
191 192 193 194 195 196 197 198 199 | |
pycodeloop.core.tools.filesystem.ListDirTool
¶
Bases: Tool
Source code in pycodeloop/core/tools/filesystem.py
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | |
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/core/tools/filesystem.py
210 211 212 213 214 215 216 217 218 219 220 | |
pycodeloop.core.tools.search.GlobTool
¶
Bases: Tool
Source code in pycodeloop/core/tools/search.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 | |
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/core/tools/search.py
73 74 75 76 77 78 79 80 81 82 83 84 85 | |
pycodeloop.core.tools.search.GrepTool
¶
Bases: Tool
Source code in pycodeloop/core/tools/search.py
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 | |
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/core/tools/search.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | |
pycodeloop.core.tools.bash.BashTool
¶
Bases: Tool
Source code in pycodeloop/core/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 | |
dangerous = True
class-attribute
instance-attribute
¶
description = 'Run a shell command and return its stdout/stderr.'
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/core/tools/bash.py
24 25 | |
run(command, timeout=120)
¶
Source code in pycodeloop/core/tools/bash.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | |
pycodeloop.core.tools.web.WebFetchTool
¶
Bases: Tool
Source code in pycodeloop/core/tools/web.py
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 | |
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/core/tools/web.py
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 | |
pycodeloop.core.tools.http_request.HttpRequestTool
¶
Bases: Tool
Source code in pycodeloop/core/tools/http_request.py
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 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 | |
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/core/tools/http_request.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | |
run(url, method='GET', headers=None, json_body=None, timeout=30)
¶
Source code in pycodeloop/core/tools/http_request.py
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 | |
pycodeloop.core.tools.git.GitStatusTool
¶
Bases: Tool
Source code in pycodeloop/core/tools/git.py
31 32 33 34 35 36 37 | |
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/core/tools/git.py
36 37 | |
pycodeloop.core.tools.git.GitDiffTool
¶
Bases: Tool
Source code in pycodeloop/core/tools/git.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | |
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/core/tools/git.py
51 52 53 54 55 56 57 58 59 60 | |
pycodeloop.core.tools.git.GitLogTool
¶
Bases: Tool
Source code in pycodeloop/core/tools/git.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | |
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/core/tools/git.py
74 75 76 77 78 79 80 | |
pycodeloop.core.tools.git.GitCommitTool
¶
Bases: Tool
Source code in pycodeloop/core/tools/git.py
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 | |
dangerous = True
class-attribute
instance-attribute
¶
description = 'Stage files and create a commit. Pass `paths` to stage specific files, or omit it to stage everything (git add -A).'
class-attribute
instance-attribute
¶
name = 'git_commit'
class-attribute
instance-attribute
¶
parameters = {'type': 'object', 'properties': {'message': {'type': 'string'}, 'paths': {'type': 'array', 'items': {'type': 'string'}}}, 'required': ['message']}
class-attribute
instance-attribute
¶
preview(message, paths=None, **_)
¶
Source code in pycodeloop/core/tools/git.py
99 100 101 102 | |
run(message, paths=None)
¶
Source code in pycodeloop/core/tools/git.py
104 105 106 107 108 109 110 | |
pycodeloop.core.tools.env.EnvTool
¶
Bases: Tool
Source code in pycodeloop/core/tools/env.py
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 | |
description = 'Read environment variables. Pass `name` for one variable, or omit it to list every variable name (values containing SECRET, KEY, TOKEN, PASSWORD, or CREDENTIAL 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/core/tools/env.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 | |
pycodeloop.core.tools.todo.TodoTool
¶
Bases: Tool
Scratchpad checklist for multi-step tasks. State lives on the tool
instance, so it persists for as long as this instance is reused across
turns (the default — Agent builds each tool once per session).
Source code in pycodeloop/core/tools/todo.py
10 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 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 | |
description = "Track a checklist of steps for a multi-step task. Actions: 'add' (needs `text`), 'complete' (needs `item_id`), 'list', 'clear'."
class-attribute
instance-attribute
¶
name = 'todo'
class-attribute
instance-attribute
¶
parameters = {'type': 'object', 'properties': {'action': {'type': 'string', 'enum': sorted(_ACTIONS)}, 'text': {'type': 'string'}, 'item_id': {'type': 'integer'}}, 'required': ['action']}
class-attribute
instance-attribute
¶
__init__()
¶
Source code in pycodeloop/core/tools/todo.py
31 32 33 | |
run(action, text='', item_id=None)
¶
Source code in pycodeloop/core/tools/todo.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 | |