File size: 17,943 Bytes
65888d5 | 1 2 3 4 5 6 7 8 9 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 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 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 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 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 309 310 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 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 | # Stack 2.9 - Tool Reference
**38 Built-in Tools** for file operations, git, code execution, web, memory, and task planning.
---
## π File Operations
### read
**Description:** Read file contents with optional offset and limit.
**Input:**
```json
{
"path": "string (required) - file path to read",
"offset": "integer (optional, default 0) - starting line number",
"limit": "integer (optional, default -1) - max lines to read (-1 = all)"
}
```
**Output:**
```json
{
"success": "boolean",
"content": "string - file contents",
"total_lines": "integer",
"path": "string",
"error": "string (if success=false)"
}
```
**Example:**
```python
read(path: '/home/user/file.py', offset: 0, limit: 100)
```
### write
**Description:** Write content to file (create or overwrite).
**Input:**
```json
{
"path": "string (required) - destination file path",
"content": "string (required) - content to write",
"append": "boolean (optional, default false) - append instead of overwrite"
}
```
**Output:**
```json
{
"success": "boolean",
"path": "string",
"lines_written": "integer"
}
```
**Example:**
```python
write(path: 'output.txt', content: 'Hello World', append: false)
```
### edit
**Description:** Edit file using exact text replacement (first occurrence only).
**Input:**
```json
{
"path": "string (required) - file to edit",
"old_text": "string (required) - text to find and replace",
"new_text": "string (required) - replacement text"
}
```
**Output:**
```json
{
"success": "boolean",
"path": "string",
"edits_made": "integer (usually 1)",
"error": "string (if old_text not found or file missing)"
}
```
**Example:**
```python
edit(path: 'config.py', old_text: 'DEBUG = True', new_text: 'DEBUG = False')
```
### search
**Description:** Recursively search for files matching a glob pattern.
**Input:**
```json
{
"path": "string (required) - base directory to search",
"pattern": "string (required) - glob pattern (e.g., '*.py', '**/*.md')",
"exclude": "array of strings (optional) - exclusion patterns"
}
```
**Output:**
```json
{
"success": "boolean",
"matches": "array of file paths (strings)",
"count": "integer",
"error": "string"
}
```
**Example:**
```python
search(path: '/project', pattern: '**/*.py', exclude: ['node_modules', '.git'])
```
### grep
**Description:** Search for regex pattern in file(s), optionally with context lines.
**Input:**
```json
{
"path": "string (required) - file or directory to search",
"pattern": "string (required) - regex pattern",
"context": "integer (optional, default 0) - number of lines before/after"
}
```
**Output:**
```json
{
"success": "boolean",
"matches": "array of objects with: file, line, content, [context]",
"count": "integer"
}
```
**Example:**
```python
grep(path: '/src', pattern: 'def\\s+\\w+', context: 2)
```
### copy
**Description:** Copy file or directory.
**Input:**
```json
{
"source": "string (required) - source path",
"destination": "string (required) - destination path"
}
```
**Output:**
```json
{
"success": "boolean",
"source": "string",
"destination": "string",
"error": "string"
}
```
**Example:**
```python
copy(source: 'backup/config.yaml', destination: 'config.yaml')
```
### move
**Description:** Move or rename file/directory.
**Input:**
```json
{
"source": "string (required) - current path",
"destination": "string (required) - new path"
}
```
**Output:**
```json
{
"success": "boolean",
"source": "string",
"destination": "string"
}
```
**Example:**
```python
move(source: 'old_name.py', destination: 'new_name.py')
```
### delete
**Description:** Delete file or directory. Requires `force=True` for actual deletion (safety).
**Input:**
```json
{
"path": "string (required) - path to delete",
"force": "boolean (optional, default false) - must be true to actually delete"
}
```
**Output:**
```json
{
"success": "boolean",
"deleted": "string (if force=true)",
"warning": "string (if force=false)",
"error": "string"
}
```
**Example:**
```python
delete(path: 'temp_file.log', force: true)
```
---
## π Git Operations
### git_status
**Description:** Get git status (modified, untracked files).
**Input:**
```json
{
"repo_path": "string (optional, default '.') - git repository path"
}
```
**Output:**
```json
{
"success": "boolean",
"files": "array of file paths (strings)",
"count": "integer",
"repo": "string",
"error": "string"
}
```
**Example:**
```python
git_status(repo_path: '/my/project')
```
### git_commit
**Description:** Create a git commit with optional file staging.
**Input:**
```json
{
"repo_path": "string (optional, default '.')",
"message": "string (required) - commit message",
"files": "array of strings (optional) - specific files to stage (default: all)"
}
```
**Output:**
```json
{
"success": "boolean",
"message": "string",
"output": "string (full git output)",
"error": "string"
}
```
**Example:**
```python
git_commit(repo_path: '.', message: 'Fix bug in parser', files: ['src/parser.py'])
```
### git_push
**Description:** Push commits to remote repository.
**Input:**
```json
{
"repo_path": "string (optional, default '.')",
"remote": "string (optional, default 'origin')",
"branch": "string (optional) - branch name (default: current branch)"
}
```
**Output:**
```json
{
"success": "boolean",
"remote": "string",
"branch": "string",
"output": "string",
"error": "string"
}
```
**Example:**
```python
git_push(repo_path: '.', remote: 'origin', branch: 'main')
```
### git_pull
**Description:** Pull changes from remote repository.
**Input:**
```json
{
"repo_path": "string (optional, default '.')",
"remote": "string (optional, default 'origin')",
"branch": "string (optional)"
}
```
**Output:**
```json
{
"success": "boolean",
"remote": "string",
"branch": "string",
"output": "string",
"error": "string"
}
```
**Example:**
```python
git_pull(repo_path: '.', remote: 'origin')
```
### git_branch
**Description:** List, create, or delete branches.
**Input:**
```json
{
"repo_path": "string (optional, default '.')",
"create": "string (optional) - create new branch with this name",
"delete": "string (optional) - delete branch with this name"
}
```
**Output:**
```json
{
"success": "boolean",
"branches": "array of strings (when listing)",
"count": "integer",
"created": "string (when creating)",
"deleted": "string (when deleting)",
"error": "string"
}
```
**Example:**
```python
git_branch(repo_path: '.', create: 'feature/new-ui')
```
### git_log
**Description:** Get commit history (oneline format).
**Input:**
```json
{
"repo_path": "string (optional, default '.')",
"limit": "integer (optional, default 10) - max commits to return"
}
```
**Output:**
```json
{
"success": "boolean",
"commits": "array of strings (oneline format)",
"count": "integer"
}
```
**Example:**
```python
git_log(repo_path: '.', limit: 20)
```
### git_diff
**Description:** Show git diff (staged or unstaged changes).
**Input:**
```json
{
"repo_path": "string (optional, default '.')",
"file": "string (optional) - limit diff to specific file",
"staged": "boolean (optional, default false) - show staged changes"
}
```
**Output:**
```json
{
"success": "boolean",
"diff": "string - full diff output",
"has_changes": "boolean",
"error": "string"
}
```
**Example:**
```python
git_diff(repo_path: '.', staged: true)
```
---
## π» Code Execution
### run
**Description:** Execute shell command with timeout and working directory.
**Input:**
```json
{
"command": "string (required) - shell command to execute",
"timeout": "integer (optional, default 60) - timeout in seconds",
"cwd": "string (optional) - working directory",
"env": "object (optional) - environment variables to add/override"
}
```
**Output:**
```json
{
"success": "boolean (true if returncode==0)",
"returncode": "integer",
"stdout": "string",
"stderr": "string",
"command": "string"
}
```
**Example:**
```python
run(command: 'npm test', timeout: 120, cwd: '/project')
```
### test
**Description:** Run tests using pytest.
**Input:**
```json
{
"path": "string (optional, default '.') - test directory or file",
"pattern": "string (optional, default 'test*.py') - test file pattern",
"verbose": "boolean (optional, default true) - verbose output"
}
```
**Output:**
```json
{
"success": "boolean (true if tests pass)",
"output": "string (stdout)",
"errors": "string (stderr)",
"returncode": "integer"
}
```
**Example:**
```python
test(path: 'tests/', pattern: 'test_*.py', verbose: true)
```
### lint
**Description:** Lint code using ruff, pylint, or mypy.
**Input:**
```json
{
"path": "string (optional, default '.')",
"linter": "string (optional, default 'ruff') - one of: 'ruff', 'pylint', 'mypy'"
}
```
**Output:**
```json
{
"success": "boolean",
"output": "string",
"errors": "string"
}
```
**Example:**
```python
lint(path: 'src/', linter: 'ruff')
```
### format
**Description:** Format code using ruff or black.
**Input:**
```json
{
"path": "string (optional, default '.')",
"formatter": "string (optional, default 'ruff') - one of: 'ruff', 'black'"
}
```
**Output:**
```json
{
"success": "boolean",
"output": "string",
"errors": "string"
}
```
**Example:**
```python
format(path: '.', formatter: 'black')
```
### typecheck
**Description:** Run mypy type checking.
**Input:**
```json
{
"path": "string (optional, default '.')"
}
```
**Output:**
```json
{
"success": "boolean",
"output": "string",
"errors": "string"
}
```
**Example:**
```python
typecheck(path: 'src/')
```
### server
**Description:** Start a development server (foreground or background).
**Input:**
```json
{
"command": "string (required) - command to start server",
"port": "integer (required) - port number",
"cwd": "string (optional) - working directory",
"background": "boolean (optional, default false) - run in background"
}
```
**Output:**
```json
{
"success": "boolean",
"pid": "integer (if background=true)",
"port": "integer",
"message": "string",
"output": "string (if background=false)"
}
```
**Example:**
```python
server(command: 'python -m http.server 8000', port: 8000, background: true)
```
### install
**Description:** Install dependencies from requirements file.
**Input:**
```json
{
"path": "string (optional, default '.')",
"package_manager": "string (optional, default 'pip') - 'pip', 'poetry', or 'npm'"
}
```
**Output:**
```json
{
"success": "boolean",
"output": "string",
"errors": "string"
}
```
**Example:**
```python
install(path: '.', package_manager: 'pip')
```
---
## π Web
### web_search
**Description:** Search the web (uses brave-search CLI or fallback).
**Input:**
```json
{
"query": "string (required) - search query",
"count": "integer (optional, default 5) - number of results",
"freshness": "string (optional) - time filter (day, week, month, year)",
"language": "string (optional) - language code (e.g., 'en')"
}
```
**Output:**
```json
{
"success": "boolean",
"query": "string",
"results": "array of {title, url, snippet} objects",
"error": "string"
}
```
**Example:**
```python
web_search(query: 'python asyncio tutorial', count: 5)
```
### fetch
**Description:** Fetch and extract text content from URL.
**Input:**
```json
{
"url": "string (required) - URL to fetch",
"max_chars": "integer (optional, default 10000) - max characters to return"
}
```
**Output:**
```json
{
"success": "boolean",
"url": "string",
"content": "string (truncated to max_chars)",
"length": "integer",
"error": "string"
}
```
**Example:**
```python
fetch(url: 'https://example.com', max_chars: 5000)
```
### download
**Description:** Download file from URL to local destination.
**Input:**
```json
{
"url": "string (required) - URL to download",
"destination": "string (required) - local file path"
}
```
**Output:**
```json
{
"success": "boolean",
"url": "string",
"destination": "string",
"size": "integer (bytes)",
"error": "string"
}
```
**Example:**
```python
download(url: 'https://example.com/file.zip', destination: 'downloads/file.zip')
```
### check_url
**Description:** Check if URL is accessible (HTTP status code).
**Input:**
```json
{
"url": "string (required) - URL to check"
}
```
**Output:**
```json
{
"success": "boolean (true for 200, 301, 302)",
"url": "string",
"status_code": "string (e.g., '200')"
}
```
**Example:**
```python
check_url(url: 'https://api.example.com/health')
```
### screenshot
**Description:** Take screenshot of webpage (requires puppeteer).
**Input:**
```json
{
"url": "string (required) - webpage URL",
"destination": "string (optional, default 'screenshot.png') - output file path"
}
```
**Output:**
```json
{
"success": "boolean",
"url": "string",
"destination": "string",
"error": "string"
}
```
**Example:**
```python
screenshot(url: 'https://example.com', destination: 'page.png')
```
---
## π§ Memory
### memory_recall
**Description:** Search memory files (MEMORY.md and memory/*.md) for query.
**Input:**
```json
{
"query": "string (required) - search term",
"max_results": "integer (optional, default 5) - max matching files to return"
}
```
**Output:**
```json
{
"success": "boolean",
"query": "string",
"matches": "array of file paths",
"count": "integer"
}
```
**Example:**
```python
memory_recall(query: 'project Alpha', max_results: 10)
```
### memory_save
**Description:** Save a memory entry to MEMORY.md.
**Input:**
```json
{
"key": "string (required) - entry title/heading",
"value": "string (required) - entry content"
}
```
**Output:**
```json
{
"success": "boolean",
"key": "string",
"saved": "boolean"
}
```
**Example:**
```python
memory_save(key: 'Meeting with Client', value: 'Discussed timeline and requirements')
```
### memory_list
**Description:** List all memory entries (titles only).
**Input:** `{}`
**Output:**
```json
{
"success": "boolean",
"entries": "array of {title, content_preview}",
"count": "integer"
}
```
**Example:**
```python
memory_list()
```
### context_load
**Description:** Load core context files (AGENTS.md, SOUL.md, TOOLS.md).
**Input:** `{}`
**Output:**
```json
{
"success": "boolean",
"context": "object with keys: agents, soul, tools",
"loaded": "array of loaded file names"
}
```
**Example:**
```python
context_load()
```
### project_scan
**Description:** Scan project structure and detect key files.
**Input:**
```json
{
"path": "string (optional, default '.')"
}
```
**Output:**
```json
{
"success": "boolean",
"project": {
"name": "string",
"files": "array",
"dirs": "array",
"has_git": "boolean",
"has_pyproject": "boolean",
"has_package_json": "boolean",
"has_dockerfile": "boolean"
}
}
```
**Example:**
```python
project_scan(path: '/my/project')
```
---
## π Task Planning
### create_task
**Description:** Create a new task with title, description, priority.
**Input:**
```json
{
"title": "string (required)",
"description": "string (optional, default '')",
"priority": "string (optional, default 'medium') - 'low', 'medium', 'high', 'critical'"
}
```
**Output:**
```json
{
"success": "boolean",
"task": {
"id": "string (8-char hash)",
"title": "string",
"description": "string",
"priority": "string",
"status": "pending",
"created": "ISO timestamp"
}
}
```
**Example:**
```python
create_task(title: 'Fix login bug', description: 'Users cannot logout', priority: 'high')
```
### list_tasks
**Description:** List tasks with optional filtering.
**Input:**
```json
{
"status": "string (optional) - filter by status",
"priority": "string (optional) - filter by priority"
}
```
**Output:**
```json
{
"success": "boolean",
"tasks": "array of task objects",
"count": "integer"
}
```
**Example:**
```python
list_tasks(status: 'pending', priority: 'high')
```
### update_task
**Description:** Update task status or fields.
**Input:**
```json
{
"task_id": "string (required) - task identifier",
"status": "string (optional) - new status (pending, in_progress, done, blocked)",
"**kwargs": "any other fields to update"
}
```
**Output:**
```json
{
"success": "boolean",
"task_id": "string",
"updated": "boolean"
}
```
**Example:**
```python
update_task(task_id: 'a1b2c3d4', status: 'in_progress')
```
### delete_task
**Description:** Delete a task by ID.
**Input:**
```json
{
"task_id": "string (required)"
}
```
**Output:**
```json
{
"success": "boolean",
"task_id": "string",
"deleted": "boolean"
}
```
**Example:**
```python
delete_task(task_id: 'a1b2c3d4')
```
### create_plan
**Description:** Create an execution plan with ordered steps.
**Input:**
```json
{
"goal": "string (required)",
"steps": "array of strings (required) - ordered list of steps"
}
```
**Output:**
```json
{
"success": "boolean",
"plan": {
"id": "string (8-char hash)",
"goal": "string",
"steps": "array",
"status": "pending",
"created": "ISO timestamp"
}
}
```
**Example:**
```python
create_plan(goal: 'Deploy to production', steps: ['Build Docker image', 'Push to registry', 'Update k8s config'])
```
### execute_plan
**Description:** Mark a plan as executing (manual step-by-step execution).
**Input:**
```json
{
"plan_id": "string (required)"
}
```
**Output:**
```json
{
"success": "boolean",
"plan_id": "string",
"status": "executing",
"steps": "array of steps to execute"
}
```
**Example:**
```python
execute_plan(plan_id: 'p1l2a3n4')
```
---
## π Notes
- All tools return a dictionary with at least a `success` boolean key.
- On failure, additional keys (`error`, `message`) provide details.
- Paths are relative to current working directory unless absolute.
- Timeouts prevent infinite hangs (default varies per tool).
- For safety, destructive operations (delete) require explicit flags.
---
**Total Tools:** 38 across 6 categories
|