File size: 18,820 Bytes
5f0fbdd | 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 | # Stack 2.9 - Complete Tools Reference
Stack 2.9 provides **38 built-in tools** for file operations, git, code execution, web requests, memory, and task management. This document provides the complete reference with actual parameter names, types, and usage examples.
---
## Tool Calling Format
Tools are called using a JSON-based function calling format. The agent automatically selects tools based on user intent, but you can also call them directly via the agent API.
### Example Tool Call
```json
{
"tool": "read",
"params": {
"path": "/path/to/file.py"
},
"id": "call_123"
}
```
### Return Format
All tools return a JSON-serializable dict:
```json
{
"success": true|false,
"result": <tool-specific result data>,
"error": <error message if failed>
}
```
---
## Complete Tool Catalog
### 1. File Operations
#### `read`
Read file contents with optional pagination.
- **Parameters:**
- `path` (string, required) - Path to the file
- `offset` (integer, optional, default: 0) - Line number to start from (0-indexed)
- `limit` (integer, optional, default: -1) - Maximum lines to read (-1 = all)
- **Returns:** `{success, content, total_lines, path}`
**Example:**
```json
{
"tool": "read",
"params": {"path": "stack_cli/cli.py", "limit": 50}
}
```
#### `write`
Write content to a file (overwrites by default).
- **Parameters:**
- `path` (string, required) - Destination file path
- `content` (string, required) - Content to write
- `append` (boolean, optional, default: false) - Append instead of overwrite
- **Returns:** `{success, path, lines_written}`
**Example:**
```json
{
"tool": "write",
"params": {
"path": "output.txt",
"content": "Hello, World!",
"append": false
}
}
```
#### `edit`
Replace exact text in a file (single occurrence).
- **Parameters:**
- `path` (string, required) - File to edit
- `old_text` (string, required) - Text to find and replace
- `new_text` (string, required) - Replacement text
- **Returns:** `{success, path, edits_made}`
**Example:**
```json
{
"tool": "edit",
"params": {
"path": "config.yaml",
"old_text": "debug: false",
"new_text": "debug: true"
}
}
```
#### `search`
Recursively search for files matching a glob pattern.
- **Parameters:**
- `path` (string, required) - Directory to search in
- `pattern` (string, required) - Glob pattern (e.g., `"*.py"`, `"**/*.md"`)
- `exclude` (array of strings, optional) - Paths to exclude
- **Returns:** `{success, matches, count}`
**Example:**
```json
{
"tool": "search",
"params": {
"path": ".",
"pattern": "**/*.py",
"exclude": ["__pycache__", "node_modules"]
}
}
```
#### `grep`
Search for regex pattern across files with optional context.
- **Parameters:**
- `path` (string, required) - File or directory to search
- `pattern` (string, required) - Regular expression pattern
- `context` (integer, optional, default: 0) - Lines of context before/after
- **Returns:** `{success, matches, count}` where each match has `{file, line, content, context?}`
**Example:**
```json
{
"tool": "grep",
"params": {
"path": "stack_cli",
"pattern": "def tool_",
"context": 2
}
}
```
#### `copy`
Copy file or directory (recursive for directories).
- **Parameters:**
- `source` (string, required) - Source path
- `destination` (string, required) - Destination path
- **Returns:** `{success, source, destination}`
**Example:**
```json
{
"tool": "copy",
"params": {
"source": "config.example.yaml",
"destination": "config.yaml"
}
}
```
#### `move`
Move or rename file/directory.
- **Parameters:**
- `source` (string, required) - Current path
- `destination` (string, required) - New path
- **Returns:** `{success, source, destination}`
**Example:**
```json
{
"tool": "move",
"params": {
"source": "old_name.py",
"destination": "new_name.py"
}
}
```
#### `delete`
Delete file or directory (requires force=True for safety).
- **Parameters:**
- `path` (string, required) - Path to delete
- `force` (boolean, optional, default: false) - Actually delete when true
- **Returns:** `{success, deleted/would_delete, warning?}`
**Example:**
```json
{
"tool": "delete",
"params": {
"path": "obsolete_file.txt",
"force": true
}
}
```
---
### 2. Git Operations
#### `git_status`
Get git repository status (porcelain format).
- **Parameters:**
- `repo_path` (string, optional, default: ".") - Repository root
- **Returns:** `{success, files, count, repo}`
**Example:**
```json
{
"tool": "git_status",
"params": {"repo_path": "."}
}
```
#### `git_commit`
Stage changes and create a commit.
- **Parameters:**
- `repo_path` (string, optional, default: ".") - Repository root
- `message` (string, required) - Commit message
- `files` (array of strings, optional) - Specific files to stage (stages all if omitted)
- **Returns:** `{success, message, output}`
**Example:**
```json
{
"tool": "git_commit",
"params": {
"repo_path": ".",
"message": "feat: add new tool documentation",
"files": ["TOOLS.md", "docs/tools.md"]
}
}
```
#### `git_push`
Push commits to remote repository.
- **Parameters:**
- `repo_path` (string, optional, default: ".") - Repository root
- `remote` (string, optional, default: "origin") - Remote name
- `branch` (string, optional) - Branch name (pushes current branch if omitted)
- **Returns:** `{success, remote, branch, output}`
**Example:**
```json
{
"tool": "git_push",
"params": {
"repo_path": ".",
"remote": "origin",
"branch": "main"
}
}
```
#### `git_pull`
Pull changes from remote.
- **Parameters:**
- `repo_path` (string, optional, default: ".") - Repository root
- `remote` (string, optional, default: "origin") - Remote name
- `branch` (string, optional) - Branch name (pulls current branch if omitted)
- **Returns:** `{success, remote, branch, output}`
**Example:**
```json
{
"tool": "git_pull",
"params": {
"repo_path": ".",
"remote": "origin"
}
}
```
#### `git_branch`
List, create, or delete branches.
- **Parameters (mutually exclusive):**
- `repo_path` (string, optional, default: ".")
- `create` (string, optional) - Create and checkout new branch
- `delete` (string, optional) - Delete branch
- **Returns:** `{success, branches?, count?, created?, deleted?}`
**Examples:**
```json
// List branches
{"tool": "git_branch", "params": {"repo_path": "."}}
// Create branch
{"tool": "git_branch", "params": {"create": "feature/new-docs"}}
// Delete branch
{"tool": "git_branch", "params": {"delete": "old-branch"}}
```
#### `git_log`
View commit history.
- **Parameters:**
- `repo_path` (string, optional, default: ".")
- `limit` (integer, optional, default: 10) - Maximum commits
- **Returns:** `{success, commits, count}`
**Example:**
```json
{
"tool": "git_log",
"params": {"repo_path": ".", "limit": 20}
}
```
#### `git_diff`
Show changes between commits or working tree.
- **Parameters:**
- `repo_path` (string, optional, default: ".")
- `file` (string, optional) - Specific file to diff
- `staged` (boolean, optional, default: false) - Show staged changes
- **Returns:** `{success, diff, has_changes}`
**Example:**
```json
{
"tool": "git_diff",
"params": {
"repo_path": ".",
"staged": true
}
}
```
---
### 3. Code Execution
#### `run`
Execute shell command with timeout.
- **Parameters:**
- `command` (string, required) - Shell command to run
- `timeout` (integer, optional, default: 60) - Seconds before timeout
- `cwd` (string, optional) - Working directory
- `env` (object, optional) - Environment variables to merge
- **Returns:** `{success, returncode, stdout, stderr, command}`
**Example:**
```json
{
"tool": "run",
"params": {
"command": "python -m pytest tests/ -v",
"timeout": 300,
"cwd": "."
}
}
```
#### `test`
Run tests using pytest.
- **Parameters:**
- `path` (string, optional, default: ".") - Test directory or file
- `pattern` (string, optional, default: "test*.py") - Test file pattern
- `verbose` (boolean, optional, default: true) - Verbose output
- **Returns:** `{success, output, errors, returncode}`
**Example:**
```json
{
"tool": "test",
"params": {
"path": "tests/",
"pattern": "test_*.py",
"verbose": true
}
}
```
#### `lint`
Lint code with specified linter (ruff, pylint, mypy).
- **Parameters:**
- `path` (string, optional, default: ".")
- `linter` (string, optional, default: "ruff") - "ruff", "pylint", or "mypy"
- **Returns:** `{success, output, errors}`
**Example:**
```json
{
"tool": "lint",
"params": {
"path": "stack_cli/",
"linter": "ruff"
}
}
```
#### `format`
Format code with specified formatter.
- **Parameters:**
- `path` (string, optional, default: ".")
- `formatter` (string, optional, default: "ruff") - "ruff" or "black"
- **Returns:** `{success, output, errors}`
**Example:**
```json
{
"tool": "format",
"params": {
"path": ".",
"formatter": "black"
}
}
```
#### `typecheck`
Run type checking with mypy.
- **Parameters:**
- `path` (string, optional, default: ".")
- **Returns:** `{success, output, errors}`
**Example:**
```json
{
"tool": "typecheck",
"params": {"path": "stack_cli"}
}
```
#### `server`
Start a development server (optionally in background).
- **Parameters:**
- `command` (string, required) - Command to start server
- `port` (integer, required) - Port number (for reference)
- `cwd` (string, optional) - Working directory
- `background` (boolean, optional, default: false) - Run in background
- **Returns:** `{success, pid?, port, message}` or `{success, output}`
**Example:**
```json
{
"tool": "server",
"params": {
"command": "python -m http.server 8000",
"port": 8000,
"background": true
}
}
```
#### `install`
Install dependencies from requirements file.
- **Parameters:**
- `path` (string, optional, default: ".") - Project directory
- `package_manager` (string, optional, default: "pip") - "pip", "poetry", or "npm"
- **Returns:** `{success, output, errors}`
**Example:**
```json
{
"tool": "install",
"params": {
"path": ".",
"package_manager": "pip"
}
}
```
---
### 4. Web & Search
#### `web_search`
Search the web using Brave Search.
- **Parameters:**
- `query` (string, required) - Search query
- `count` (integer, optional, default: 5) - Number of results (1-10)
- `freshness` (string, optional) - Filter by time: "day", "week", "month", "year"
- `language` (string, optional) - ISO 639-1 language code (e.g., "en", "fr")
- **Returns:** `{success, query, results, count}`
**Example:**
```json
{
"tool": "web_search",
"params": {
"query": "Stack 2.9 AI coding assistant",
"count": 10,
"freshness": "month"
}
}
```
#### `fetch`
Download and extract content from a URL.
- **Parameters:**
- `url` (string, required) - URL to fetch
- `max_chars` (integer, optional, default: 10000) - Maximum content length
- **Returns:** `{success, url, content, length}`
**Example:**
```json
{
"tool": "fetch",
"params": {
"url": "https://example.com/README.md",
"max_chars": 5000
}
}
```
#### `download`
Download file from URL to local path.
- **Parameters:**
- `url` (string, required) - Source URL
- `destination` (string, required) - Local file path
- **Returns:** `{success, url, destination, size}`
**Example:**
```json
{
"tool": "download",
"params": {
"url": "https://example.com/dataset.csv",
"destination": "data/dataset.csv"
}
}
```
#### `check_url`
Check if URL is accessible (HTTP HEAD request).
- **Parameters:**
- `url` (string, required) - URL to check
- **Returns:** `{success, url, status_code}`
**Example:**
```json
{
"tool": "check_url",
"params": {"url": "https://github.com"}
}
```
#### `screenshot`
Take screenshot of a webpage (requires puppeteer).
- **Parameters:**
- `url` (string, required) - Webpage URL
- `destination` (string, optional, default: "screenshot.png") - Output path
- **Returns:** `{success, url, destination}`
**Example:**
```json
{
"tool": "screenshot",
"params": {
"url": "https://stack-2-9.example.com",
"destination": "website.png"
}
}
```
---
### 5. Memory & Knowledge
#### `memory_recall`
Search memory files for relevant entries.
- **Parameters:**
- `query` (string, required) - Search query
- `max_results` (integer, optional, default: 5) - Maximum matches
- **Returns:** `{success, query, matches, count}`
**Example:**
```json
{
"tool": "memory_recall",
"params": {
"query": "deployment requirements",
"max_results": 10
}
}
```
#### `memory_save`
Store a memory entry in MEMORY.md.
- **Parameters:**
- `key` (string, required) - Entry title/heading
- `value` (string, required) - Content to save
- **Returns:** `{success, key, saved}`
**Example:**
```json
{
"tool": "memory_save",
"params": {
"key": "GPU Requirements",
"value": "Minimum: 8GB VRAM, Recommended: 24GB VRAM"
}
}
```
#### `memory_list`
List all memory entries with preview.
- **Parameters:** None
- **Returns:** `{success, entries, count}` where each entry has `{title, content}`
**Example:**
```json
{
"tool": "memory_list",
"params": {}
}
```
#### `context_load`
Load workspace context files (AGENTS.md, SOUL.md, TOOLS.md).
- **Parameters:**
- `projects` (array of strings, optional) - Project names to load
- **Returns:** `{success, context, loaded}`
**Example:**
```json
{
"tool": "context_load",
"params": {}
}
```
#### `project_scan`
Scan project structure and detect tech stack.
- **Parameters:**
- `path` (string, optional, default: ".")
- **Returns:** `{success, project}` with `{name, files, dirs, has_git, has_pyproject, has_package_json, has_dockerfile}`
**Example:**
```json
{
"tool": "project_scan",
"params": {"path": "."}
}
```
---
### 6. Task & Planning
#### `create_task`
Create a new task.
- **Parameters:**
- `title` (string, required) - Task title
- `description` (string, optional, default: "") - Detailed description
- `priority` (string, optional, default: "medium") - "low", "medium", or "high"
- **Returns:** `{success, task}` with `{id, title, description, priority, status, created}`
**Example:**
```json
{
"tool": "create_task",
"params": {
"title": "Write comprehensive tool documentation",
"description": "Create TOOLS.md with all 38 tools documented",
"priority": "high"
}
}
```
#### `list_tasks`
List tasks with optional filtering.
- **Parameters:**
- `status` (string, optional) - Filter by "pending", "done", or "all"
- `priority` (string, optional) - Filter by "low", "medium", "high"
- **Returns:** `{success, tasks, count}`
**Example:**
```json
{
"tool": "list_tasks",
"params": {
"status": "pending",
"priority": "high"
}
}
```
#### `update_task`
Update task status or fields.
- **Parameters:**
- `task_id` (string, required) - Task identifier
- `status` (string, optional) - New status
- Additional fields: `title`, `description`, `priority`
- **Returns:** `{success, task_id, updated}`
**Example:**
```json
{
"tool": "update_task",
"params": {
"task_id": "a1b2c3d4",
"status": "done"
}
}
```
#### `delete_task`
Delete a task by ID.
- **Parameters:**
- `task_id` (string, required) - Task to delete
- **Returns:** `{success, task_id, deleted}`
**Example:**
```json
{
"tool": "delete_task",
"params": {"task_id": "a1b2c3d4"}
}
```
#### `create_plan`
Create an execution plan with steps.
- **Parameters:**
- `goal` (string, required) - Plan objective
- `steps` (array of strings, required) - Ordered steps
- **Returns:** `{success, plan}` with `{id, goal, steps, status, created}`
**Example:**
```json
{
"tool": "create_plan",
"params": {
"goal": "Deploy to RunPod",
"steps": [
"Prepare Docker image",
"Upload to registry",
"Launch pod with template",
"Verify deployment"
]
}
}
```
#### `execute_plan`
Mark a plan as in-progress (execution tracking).
- **Parameters:**
- `plan_id` (string, required) - Plan identifier
- **Returns:** `{success, plan_id, status, steps}`
**Example:**
```json
{
"tool": "execute_plan",
"params": {"plan_id": "p123abc"}
}
```
---
## Tool Count Clarification
**Actual tool count: 38** (not 37). The following categories:
- File Operations: 8 tools
- Git Operations: 7 tools
- Code Execution: 7 tools
- Web & Search: 5 tools
- Memory & Knowledge: 5 tools
- Task & Planning: 6 tools
- **Total: 38 tools**
---
## Extension Mechanism
To add a new tool, edit `stack_cli/tools.py`:
```python
def tool_my_feature(param1: str, param2: int = 42) -> Dict[str, Any]:
"""Brief description for LLM."""
try:
# Implementation
result = do_something(param1, param2)
return {
"success": True,
"result": result
}
except Exception as e:
return {"success": False, "error": str(e)}
# Register in TOOLS dict
TOOLS["my_feature"] = tool_my_feature
```
The tool will be automatically available. Update this document when adding tools.
---
## Schema Generation
For programmatic access, use:
```python
from stack_cli.tools import get_tool_schemas, get_tool
# Get all tool schemas (for LLM function calling)
schemas = get_tool_schemas()
# Get a specific tool function
read_fn = get_tool("read")
result = read_fn(path="file.txt")
```
**Note:** The `get_tool_schemas()` function currently provides a limited subset. For full production use, extend it to include all 38 tools with proper JSON Schema parameters derived from function signatures.
---
## Best Practices
1. **Always check `success`** in the return value before using results
2. **Use pagination** for large files: `read(path, offset=0, limit=1000)`
3. **Handle errors gracefully** - tools return `error` field when `success=false`
4. **Be cautious with destructive operations**: `delete` requires `force=true`
5. **Set appropriate timeouts** for long-running commands (`run` tool)
6. **Use `git_status` before `git_commit`** to verify what will be committed
7. **Remember context limits** - tool results count against token limits
---
## Quick Reference Table
| Category | Tools | Count |
|----------|-------|-------|
| File Operations | read, write, edit, search, grep, copy, move, delete | 8 |
| Git | git_status, git_commit, git_push, git_pull, git_branch, git_log, git_diff | 7 |
| Execution | run, test, lint, format, typecheck, server, install | 7 |
| Web | web_search, fetch, download, check_url, screenshot | 5 |
| Memory | memory_recall, memory_save, memory_list, context_load, project_scan | 5 |
| Planning | create_task, list_tasks, update_task, delete_task, create_plan, execute_plan | 6 |
| **Total** | | **38** |
---
*Last updated: 2026-04-02*
*Stack 2.9 - Pattern Memory AI*
|