hanzo-mcp 0.7.7__py3-none-any.whl → 0.8.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of hanzo-mcp might be problematic. Click here for more details.
- hanzo_mcp/__init__.py +6 -0
- hanzo_mcp/__main__.py +1 -1
- hanzo_mcp/analytics/__init__.py +2 -2
- hanzo_mcp/analytics/posthog_analytics.py +76 -82
- hanzo_mcp/cli.py +31 -36
- hanzo_mcp/cli_enhanced.py +94 -72
- hanzo_mcp/cli_plugin.py +27 -17
- hanzo_mcp/config/__init__.py +2 -2
- hanzo_mcp/config/settings.py +112 -88
- hanzo_mcp/config/tool_config.py +32 -34
- hanzo_mcp/dev_server.py +66 -67
- hanzo_mcp/prompts/__init__.py +94 -12
- hanzo_mcp/prompts/enhanced_prompts.py +809 -0
- hanzo_mcp/prompts/example_custom_prompt.py +6 -5
- hanzo_mcp/prompts/project_todo_reminder.py +0 -1
- hanzo_mcp/prompts/tool_explorer.py +10 -7
- hanzo_mcp/server.py +17 -21
- hanzo_mcp/server_enhanced.py +15 -22
- hanzo_mcp/tools/__init__.py +56 -28
- hanzo_mcp/tools/agent/__init__.py +16 -19
- hanzo_mcp/tools/agent/agent.py +82 -65
- hanzo_mcp/tools/agent/agent_tool.py +152 -122
- hanzo_mcp/tools/agent/agent_tool_v1_deprecated.py +66 -62
- hanzo_mcp/tools/agent/clarification_protocol.py +55 -50
- hanzo_mcp/tools/agent/clarification_tool.py +11 -10
- hanzo_mcp/tools/agent/claude_cli_tool.py +21 -20
- hanzo_mcp/tools/agent/claude_desktop_auth.py +130 -144
- hanzo_mcp/tools/agent/cli_agent_base.py +59 -53
- hanzo_mcp/tools/agent/code_auth.py +102 -107
- hanzo_mcp/tools/agent/code_auth_tool.py +28 -27
- hanzo_mcp/tools/agent/codex_cli_tool.py +20 -19
- hanzo_mcp/tools/agent/critic_tool.py +86 -73
- hanzo_mcp/tools/agent/gemini_cli_tool.py +21 -20
- hanzo_mcp/tools/agent/grok_cli_tool.py +21 -20
- hanzo_mcp/tools/agent/iching_tool.py +404 -139
- hanzo_mcp/tools/agent/network_tool.py +89 -73
- hanzo_mcp/tools/agent/prompt.py +2 -1
- hanzo_mcp/tools/agent/review_tool.py +101 -98
- hanzo_mcp/tools/agent/swarm_alias.py +87 -0
- hanzo_mcp/tools/agent/swarm_tool.py +246 -161
- hanzo_mcp/tools/agent/swarm_tool_v1_deprecated.py +134 -92
- hanzo_mcp/tools/agent/tool_adapter.py +21 -11
- hanzo_mcp/tools/common/__init__.py +1 -1
- hanzo_mcp/tools/common/base.py +3 -5
- hanzo_mcp/tools/common/batch_tool.py +46 -39
- hanzo_mcp/tools/common/config_tool.py +120 -84
- hanzo_mcp/tools/common/context.py +1 -5
- hanzo_mcp/tools/common/context_fix.py +5 -3
- hanzo_mcp/tools/common/critic_tool.py +4 -8
- hanzo_mcp/tools/common/decorators.py +58 -56
- hanzo_mcp/tools/common/enhanced_base.py +29 -32
- hanzo_mcp/tools/common/fastmcp_pagination.py +91 -94
- hanzo_mcp/tools/common/forgiving_edit.py +91 -87
- hanzo_mcp/tools/common/mode.py +15 -17
- hanzo_mcp/tools/common/mode_loader.py +27 -24
- hanzo_mcp/tools/common/paginated_base.py +61 -53
- hanzo_mcp/tools/common/paginated_response.py +72 -79
- hanzo_mcp/tools/common/pagination.py +50 -53
- hanzo_mcp/tools/common/permissions.py +4 -4
- hanzo_mcp/tools/common/personality.py +186 -138
- hanzo_mcp/tools/common/plugin_loader.py +54 -54
- hanzo_mcp/tools/common/stats.py +65 -47
- hanzo_mcp/tools/common/test_helpers.py +31 -0
- hanzo_mcp/tools/common/thinking_tool.py +4 -8
- hanzo_mcp/tools/common/tool_disable.py +17 -12
- hanzo_mcp/tools/common/tool_enable.py +13 -14
- hanzo_mcp/tools/common/tool_list.py +36 -28
- hanzo_mcp/tools/common/truncate.py +23 -23
- hanzo_mcp/tools/config/__init__.py +4 -4
- hanzo_mcp/tools/config/config_tool.py +42 -29
- hanzo_mcp/tools/config/index_config.py +37 -34
- hanzo_mcp/tools/config/mode_tool.py +175 -55
- hanzo_mcp/tools/database/__init__.py +15 -12
- hanzo_mcp/tools/database/database_manager.py +77 -75
- hanzo_mcp/tools/database/graph.py +137 -91
- hanzo_mcp/tools/database/graph_add.py +30 -18
- hanzo_mcp/tools/database/graph_query.py +178 -102
- hanzo_mcp/tools/database/graph_remove.py +33 -28
- hanzo_mcp/tools/database/graph_search.py +97 -75
- hanzo_mcp/tools/database/graph_stats.py +91 -59
- hanzo_mcp/tools/database/sql.py +107 -79
- hanzo_mcp/tools/database/sql_query.py +30 -24
- hanzo_mcp/tools/database/sql_search.py +29 -25
- hanzo_mcp/tools/database/sql_stats.py +47 -35
- hanzo_mcp/tools/editor/neovim_command.py +25 -28
- hanzo_mcp/tools/editor/neovim_edit.py +21 -23
- hanzo_mcp/tools/editor/neovim_session.py +60 -54
- hanzo_mcp/tools/filesystem/__init__.py +31 -30
- hanzo_mcp/tools/filesystem/ast_multi_edit.py +329 -249
- hanzo_mcp/tools/filesystem/ast_tool.py +4 -4
- hanzo_mcp/tools/filesystem/base.py +1 -1
- hanzo_mcp/tools/filesystem/batch_search.py +316 -224
- hanzo_mcp/tools/filesystem/content_replace.py +4 -4
- hanzo_mcp/tools/filesystem/diff.py +71 -59
- hanzo_mcp/tools/filesystem/directory_tree.py +7 -7
- hanzo_mcp/tools/filesystem/directory_tree_paginated.py +49 -37
- hanzo_mcp/tools/filesystem/edit.py +4 -4
- hanzo_mcp/tools/filesystem/find.py +173 -80
- hanzo_mcp/tools/filesystem/find_files.py +73 -52
- hanzo_mcp/tools/filesystem/git_search.py +157 -104
- hanzo_mcp/tools/filesystem/grep.py +8 -8
- hanzo_mcp/tools/filesystem/multi_edit.py +4 -8
- hanzo_mcp/tools/filesystem/read.py +12 -10
- hanzo_mcp/tools/filesystem/rules_tool.py +59 -43
- hanzo_mcp/tools/filesystem/search_tool.py +263 -207
- hanzo_mcp/tools/filesystem/symbols_tool.py +94 -54
- hanzo_mcp/tools/filesystem/tree.py +35 -33
- hanzo_mcp/tools/filesystem/unix_aliases.py +13 -18
- hanzo_mcp/tools/filesystem/watch.py +37 -36
- hanzo_mcp/tools/filesystem/write.py +4 -8
- hanzo_mcp/tools/jupyter/__init__.py +4 -4
- hanzo_mcp/tools/jupyter/base.py +4 -5
- hanzo_mcp/tools/jupyter/jupyter.py +67 -47
- hanzo_mcp/tools/jupyter/notebook_edit.py +4 -4
- hanzo_mcp/tools/jupyter/notebook_read.py +4 -7
- hanzo_mcp/tools/llm/__init__.py +5 -7
- hanzo_mcp/tools/llm/consensus_tool.py +72 -52
- hanzo_mcp/tools/llm/llm_manage.py +101 -60
- hanzo_mcp/tools/llm/llm_tool.py +226 -166
- hanzo_mcp/tools/llm/provider_tools.py +25 -26
- hanzo_mcp/tools/lsp/__init__.py +1 -1
- hanzo_mcp/tools/lsp/lsp_tool.py +228 -143
- hanzo_mcp/tools/mcp/__init__.py +2 -3
- hanzo_mcp/tools/mcp/mcp_add.py +27 -25
- hanzo_mcp/tools/mcp/mcp_remove.py +7 -8
- hanzo_mcp/tools/mcp/mcp_stats.py +23 -22
- hanzo_mcp/tools/mcp/mcp_tool.py +129 -98
- hanzo_mcp/tools/memory/__init__.py +39 -21
- hanzo_mcp/tools/memory/knowledge_tools.py +124 -99
- hanzo_mcp/tools/memory/memory_tools.py +90 -108
- hanzo_mcp/tools/search/__init__.py +7 -2
- hanzo_mcp/tools/search/find_tool.py +297 -212
- hanzo_mcp/tools/search/unified_search.py +366 -314
- hanzo_mcp/tools/shell/__init__.py +8 -7
- hanzo_mcp/tools/shell/auto_background.py +56 -49
- hanzo_mcp/tools/shell/base.py +1 -1
- hanzo_mcp/tools/shell/base_process.py +75 -75
- hanzo_mcp/tools/shell/bash_session.py +2 -2
- hanzo_mcp/tools/shell/bash_session_executor.py +4 -4
- hanzo_mcp/tools/shell/bash_tool.py +24 -31
- hanzo_mcp/tools/shell/command_executor.py +12 -12
- hanzo_mcp/tools/shell/logs.py +43 -33
- hanzo_mcp/tools/shell/npx.py +13 -13
- hanzo_mcp/tools/shell/npx_background.py +24 -21
- hanzo_mcp/tools/shell/npx_tool.py +18 -22
- hanzo_mcp/tools/shell/open.py +19 -21
- hanzo_mcp/tools/shell/pkill.py +31 -26
- hanzo_mcp/tools/shell/process_tool.py +32 -32
- hanzo_mcp/tools/shell/processes.py +57 -58
- hanzo_mcp/tools/shell/run_background.py +24 -25
- hanzo_mcp/tools/shell/run_command.py +5 -5
- hanzo_mcp/tools/shell/run_command_windows.py +5 -5
- hanzo_mcp/tools/shell/session_storage.py +3 -3
- hanzo_mcp/tools/shell/streaming_command.py +141 -126
- hanzo_mcp/tools/shell/uvx.py +24 -25
- hanzo_mcp/tools/shell/uvx_background.py +35 -33
- hanzo_mcp/tools/shell/uvx_tool.py +18 -22
- hanzo_mcp/tools/todo/__init__.py +6 -2
- hanzo_mcp/tools/todo/todo.py +50 -37
- hanzo_mcp/tools/todo/todo_read.py +5 -8
- hanzo_mcp/tools/todo/todo_write.py +5 -7
- hanzo_mcp/tools/vector/__init__.py +40 -28
- hanzo_mcp/tools/vector/ast_analyzer.py +176 -143
- hanzo_mcp/tools/vector/git_ingester.py +170 -179
- hanzo_mcp/tools/vector/index_tool.py +96 -44
- hanzo_mcp/tools/vector/infinity_store.py +283 -228
- hanzo_mcp/tools/vector/mock_infinity.py +39 -40
- hanzo_mcp/tools/vector/project_manager.py +88 -78
- hanzo_mcp/tools/vector/vector.py +59 -42
- hanzo_mcp/tools/vector/vector_index.py +30 -27
- hanzo_mcp/tools/vector/vector_search.py +64 -45
- hanzo_mcp/types.py +6 -4
- {hanzo_mcp-0.7.7.dist-info → hanzo_mcp-0.8.0.dist-info}/METADATA +1 -1
- hanzo_mcp-0.8.0.dist-info/RECORD +185 -0
- hanzo_mcp-0.7.7.dist-info/RECORD +0 -182
- {hanzo_mcp-0.7.7.dist-info → hanzo_mcp-0.8.0.dist-info}/WHEEL +0 -0
- {hanzo_mcp-0.7.7.dist-info → hanzo_mcp-0.8.0.dist-info}/entry_points.txt +0 -0
- {hanzo_mcp-0.7.7.dist-info → hanzo_mcp-0.8.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,809 @@
|
|
|
1
|
+
"""Enhanced prompts for better discoverability and usability."""
|
|
2
|
+
|
|
3
|
+
QUICK_START_PROMPT = """# Hanzo MCP Quick Start Guide
|
|
4
|
+
|
|
5
|
+
## Common Workflows
|
|
6
|
+
|
|
7
|
+
### 1. Explore a New Codebase
|
|
8
|
+
```python
|
|
9
|
+
# Get project overview
|
|
10
|
+
directory_tree(path=".", depth=3)
|
|
11
|
+
|
|
12
|
+
# Find main entry points
|
|
13
|
+
find(pattern="main.*|index.*", path=".")
|
|
14
|
+
|
|
15
|
+
# Search for key patterns
|
|
16
|
+
search(pattern="TODO|FIXME|BUG", path=".")
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### 2. Multi-Agent Code Analysis
|
|
20
|
+
```python
|
|
21
|
+
# Run parallel analysis with different agents
|
|
22
|
+
batch(
|
|
23
|
+
description="Comprehensive code analysis",
|
|
24
|
+
invocations=[
|
|
25
|
+
{"tool_name": "agent", "input": {"prompt": "Analyze security vulnerabilities"}},
|
|
26
|
+
{"tool_name": "agent", "input": {"prompt": "Find performance bottlenecks"}},
|
|
27
|
+
{"tool_name": "agent", "input": {"prompt": "Review code quality and suggest improvements"}}
|
|
28
|
+
]
|
|
29
|
+
)
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### 3. Refactor Code Across Files
|
|
33
|
+
```python
|
|
34
|
+
# Find all occurrences
|
|
35
|
+
search(pattern="oldFunction", path="./src")
|
|
36
|
+
|
|
37
|
+
# Review with critic
|
|
38
|
+
critic(analysis="Review the usage of oldFunction and suggest refactoring approach")
|
|
39
|
+
|
|
40
|
+
# Make changes
|
|
41
|
+
content_replace(
|
|
42
|
+
pattern="oldFunction",
|
|
43
|
+
replacement="newFunction",
|
|
44
|
+
path="./src"
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
# Run tests
|
|
48
|
+
bash("npm test")
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### 4. Track Complex Tasks
|
|
52
|
+
```python
|
|
53
|
+
# Create todo list
|
|
54
|
+
todo_write(todos=[
|
|
55
|
+
{"content": "Analyze current implementation", "status": "pending"},
|
|
56
|
+
{"content": "Design new architecture", "status": "pending"},
|
|
57
|
+
{"content": "Implement changes", "status": "pending"},
|
|
58
|
+
{"content": "Write tests", "status": "pending"},
|
|
59
|
+
{"content": "Update documentation", "status": "pending"}
|
|
60
|
+
])
|
|
61
|
+
|
|
62
|
+
# Update as you work
|
|
63
|
+
todo(action="update", id="task-1", status="completed")
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Tips
|
|
67
|
+
- Use `batch()` for parallel operations
|
|
68
|
+
- Use `think()` for complex reasoning
|
|
69
|
+
- Use `critic()` for code review
|
|
70
|
+
- Use pagination for large result sets"""
|
|
71
|
+
|
|
72
|
+
PAGINATION_GUIDE_PROMPT = """# Pagination Guide
|
|
73
|
+
|
|
74
|
+
## How Pagination Works
|
|
75
|
+
|
|
76
|
+
Most tools support pagination to handle large result sets efficiently.
|
|
77
|
+
|
|
78
|
+
### Basic Pagination Parameters
|
|
79
|
+
- `page`: Page number (starts at 1)
|
|
80
|
+
- `page_size`: Results per page (default: 50-100)
|
|
81
|
+
- `max_results`: Total maximum results
|
|
82
|
+
|
|
83
|
+
### Examples
|
|
84
|
+
|
|
85
|
+
#### Find Tool with Pagination
|
|
86
|
+
```python
|
|
87
|
+
# Get first page of Python files
|
|
88
|
+
find(pattern="*.py", path="/project", page=1, page_size=10)
|
|
89
|
+
|
|
90
|
+
# Response includes:
|
|
91
|
+
{
|
|
92
|
+
"results": [...],
|
|
93
|
+
"pagination": {
|
|
94
|
+
"page": 1,
|
|
95
|
+
"page_size": 10,
|
|
96
|
+
"total_results": 150,
|
|
97
|
+
"total_pages": 15,
|
|
98
|
+
"has_next": true,
|
|
99
|
+
"has_prev": false
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
# Get next page
|
|
104
|
+
find(pattern="*.py", path="/project", page=2, page_size=10)
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
#### Search with Limits
|
|
108
|
+
```python
|
|
109
|
+
# Limit total results
|
|
110
|
+
search(pattern="TODO", path="/project", max_results=20)
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Batch Processing Pages
|
|
114
|
+
```python
|
|
115
|
+
# Process multiple pages in parallel
|
|
116
|
+
batch(
|
|
117
|
+
description="Get all Python files",
|
|
118
|
+
invocations=[
|
|
119
|
+
{"tool_name": "find", "input": {"pattern": "*.py", "page": 1, "page_size": 50}},
|
|
120
|
+
{"tool_name": "find", "input": {"pattern": "*.py", "page": 2, "page_size": 50}},
|
|
121
|
+
{"tool_name": "find", "input": {"pattern": "*.py", "page": 3, "page_size": 50}}
|
|
122
|
+
]
|
|
123
|
+
)
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Best Practices
|
|
127
|
+
1. Start with smaller page sizes for testing
|
|
128
|
+
2. Use `max_results` to limit total processing
|
|
129
|
+
3. Check `has_next` before requesting next page
|
|
130
|
+
4. Use batch for parallel page fetching"""
|
|
131
|
+
|
|
132
|
+
MEMORY_VECTOR_HELP_PROMPT = """# Memory & Vector Tools Guide
|
|
133
|
+
|
|
134
|
+
## Semantic Search and Memory
|
|
135
|
+
|
|
136
|
+
### Vector Search
|
|
137
|
+
Search using semantic similarity rather than exact text matching.
|
|
138
|
+
|
|
139
|
+
```python
|
|
140
|
+
# Enable vector search in unified search
|
|
141
|
+
search(
|
|
142
|
+
pattern="how to handle user authentication",
|
|
143
|
+
path="/project",
|
|
144
|
+
enable_vector=true
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
# Index project for vector search
|
|
148
|
+
vector_index(path="/project", recursive=true)
|
|
149
|
+
|
|
150
|
+
# Pure vector search
|
|
151
|
+
vector_search(
|
|
152
|
+
query="error handling patterns",
|
|
153
|
+
path="/project",
|
|
154
|
+
top_k=10
|
|
155
|
+
)
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Memory Tools
|
|
159
|
+
Store and retrieve context across sessions.
|
|
160
|
+
|
|
161
|
+
```python
|
|
162
|
+
# Store knowledge
|
|
163
|
+
memory_add(
|
|
164
|
+
key="project_architecture",
|
|
165
|
+
content="The project uses a microservices architecture with..."
|
|
166
|
+
)
|
|
167
|
+
|
|
168
|
+
# Retrieve knowledge
|
|
169
|
+
memory_get(key="project_architecture")
|
|
170
|
+
|
|
171
|
+
# Search memory
|
|
172
|
+
memory_search(query="architecture decisions")
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## Use Cases
|
|
176
|
+
1. **Semantic Code Search**: Find conceptually similar code
|
|
177
|
+
2. **Knowledge Base**: Store project understanding
|
|
178
|
+
3. **Context Preservation**: Maintain context across sessions
|
|
179
|
+
4. **Pattern Discovery**: Find similar implementations
|
|
180
|
+
|
|
181
|
+
## Tips
|
|
182
|
+
- Index large projects once, search many times
|
|
183
|
+
- Combine vector search with traditional search
|
|
184
|
+
- Use memory for important discoveries
|
|
185
|
+
- Vector search works best with natural language queries"""
|
|
186
|
+
|
|
187
|
+
DATABASE_TOOLS_HELP_PROMPT = """# Database Tools Guide
|
|
188
|
+
|
|
189
|
+
## SQL Database Operations
|
|
190
|
+
|
|
191
|
+
### Query Execution
|
|
192
|
+
```python
|
|
193
|
+
# Execute SQL query
|
|
194
|
+
sql_query(
|
|
195
|
+
query="SELECT * FROM users WHERE created_at > '2024-01-01'",
|
|
196
|
+
database="myapp.db"
|
|
197
|
+
)
|
|
198
|
+
|
|
199
|
+
# Search across tables
|
|
200
|
+
sql_search(
|
|
201
|
+
pattern="john@example.com",
|
|
202
|
+
database="myapp.db"
|
|
203
|
+
)
|
|
204
|
+
|
|
205
|
+
# Get database statistics
|
|
206
|
+
sql_stats(database="myapp.db")
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
## Graph Database Operations
|
|
210
|
+
|
|
211
|
+
### Managing Graph Data
|
|
212
|
+
```python
|
|
213
|
+
# Add nodes and edges
|
|
214
|
+
graph_add(
|
|
215
|
+
node_type="User",
|
|
216
|
+
node_id="user_123",
|
|
217
|
+
properties={"name": "John", "email": "john@example.com"}
|
|
218
|
+
)
|
|
219
|
+
|
|
220
|
+
graph_add(
|
|
221
|
+
edge_type="FOLLOWS",
|
|
222
|
+
from_node="user_123",
|
|
223
|
+
to_node="user_456"
|
|
224
|
+
)
|
|
225
|
+
|
|
226
|
+
# Query graph
|
|
227
|
+
graph_query(
|
|
228
|
+
query="MATCH (u:User)-[:FOLLOWS]->(f:User) RETURN u, f",
|
|
229
|
+
database="social.graph"
|
|
230
|
+
)
|
|
231
|
+
|
|
232
|
+
# Search graph
|
|
233
|
+
graph_search(
|
|
234
|
+
pattern="John",
|
|
235
|
+
node_type="User"
|
|
236
|
+
)
|
|
237
|
+
|
|
238
|
+
# Graph statistics
|
|
239
|
+
graph_stats(database="social.graph")
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
## Best Practices
|
|
243
|
+
1. Always sanitize inputs to prevent injection
|
|
244
|
+
2. Use transactions for multiple operations
|
|
245
|
+
3. Index frequently queried fields
|
|
246
|
+
4. Monitor query performance with stats tools"""
|
|
247
|
+
|
|
248
|
+
LSP_TOOLS_HELP_PROMPT = """# Language Server Protocol (LSP) Tools Guide
|
|
249
|
+
|
|
250
|
+
## Code Intelligence Features
|
|
251
|
+
|
|
252
|
+
### Basic Operations
|
|
253
|
+
```python
|
|
254
|
+
# Go to definition
|
|
255
|
+
lsp(
|
|
256
|
+
action="definition",
|
|
257
|
+
file="/src/main.py",
|
|
258
|
+
line=42,
|
|
259
|
+
character=15
|
|
260
|
+
)
|
|
261
|
+
|
|
262
|
+
# Find all references
|
|
263
|
+
lsp(
|
|
264
|
+
action="references",
|
|
265
|
+
file="/src/main.py",
|
|
266
|
+
line=42,
|
|
267
|
+
character=15
|
|
268
|
+
)
|
|
269
|
+
|
|
270
|
+
# Get hover information
|
|
271
|
+
lsp(
|
|
272
|
+
action="hover",
|
|
273
|
+
file="/src/main.py",
|
|
274
|
+
line=42,
|
|
275
|
+
character=15
|
|
276
|
+
)
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
### Refactoring
|
|
280
|
+
```python
|
|
281
|
+
# Rename symbol across codebase
|
|
282
|
+
lsp(
|
|
283
|
+
action="rename",
|
|
284
|
+
file="/src/main.py",
|
|
285
|
+
line=42,
|
|
286
|
+
character=15,
|
|
287
|
+
new_name="newFunctionName"
|
|
288
|
+
)
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
### Diagnostics
|
|
292
|
+
```python
|
|
293
|
+
# Get errors and warnings
|
|
294
|
+
lsp(
|
|
295
|
+
action="diagnostics",
|
|
296
|
+
file="/src/main.py"
|
|
297
|
+
)
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
### Code Completion
|
|
301
|
+
```python
|
|
302
|
+
# Get completions at position
|
|
303
|
+
lsp(
|
|
304
|
+
action="completion",
|
|
305
|
+
file="/src/main.py",
|
|
306
|
+
line=42,
|
|
307
|
+
character=15
|
|
308
|
+
)
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
## Supported Languages
|
|
312
|
+
- Python (pylsp)
|
|
313
|
+
- TypeScript/JavaScript (typescript-language-server)
|
|
314
|
+
- Go (gopls)
|
|
315
|
+
- Rust (rust-analyzer)
|
|
316
|
+
- Java (jdtls)
|
|
317
|
+
- C/C++ (clangd)
|
|
318
|
+
|
|
319
|
+
## Tips
|
|
320
|
+
- LSP servers are installed automatically
|
|
321
|
+
- Use for accurate refactoring
|
|
322
|
+
- Combine with search tools for comprehensive analysis"""
|
|
323
|
+
|
|
324
|
+
CONFIGURATION_GUIDE_PROMPT = """# Configuration Guide
|
|
325
|
+
|
|
326
|
+
## Tool Configuration
|
|
327
|
+
|
|
328
|
+
### View Current Configuration
|
|
329
|
+
```python
|
|
330
|
+
# List all enabled tools
|
|
331
|
+
tool_list()
|
|
332
|
+
|
|
333
|
+
# Check specific tool status
|
|
334
|
+
stats()
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
### Enable/Disable Tools
|
|
338
|
+
```python
|
|
339
|
+
# Enable a tool
|
|
340
|
+
tool_enable(name="lsp")
|
|
341
|
+
|
|
342
|
+
# Disable a tool
|
|
343
|
+
tool_disable(name="sql_query")
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
## Configuration Presets
|
|
347
|
+
|
|
348
|
+
### Available Presets
|
|
349
|
+
|
|
350
|
+
1. **minimal** - Essential tools only
|
|
351
|
+
- Basic file operations
|
|
352
|
+
- Simple commands
|
|
353
|
+
|
|
354
|
+
2. **standard** - Common development tools
|
|
355
|
+
- File operations
|
|
356
|
+
- Search tools
|
|
357
|
+
- Process management
|
|
358
|
+
|
|
359
|
+
3. **development** - Full development suite
|
|
360
|
+
- All standard tools
|
|
361
|
+
- Agent tools
|
|
362
|
+
- Package managers
|
|
363
|
+
- LSP support
|
|
364
|
+
|
|
365
|
+
4. **full** - Everything enabled
|
|
366
|
+
- All tools available
|
|
367
|
+
- Maximum capabilities
|
|
368
|
+
|
|
369
|
+
5. **ai_research** - AI/ML focused
|
|
370
|
+
- Agent orchestration
|
|
371
|
+
- Vector search
|
|
372
|
+
- Memory tools
|
|
373
|
+
|
|
374
|
+
### Switching Presets
|
|
375
|
+
Configure in your launch command:
|
|
376
|
+
```bash
|
|
377
|
+
# Use development preset
|
|
378
|
+
hanzo-mcp --preset development
|
|
379
|
+
|
|
380
|
+
# Or set in config file
|
|
381
|
+
~/.config/hanzo/mcp-settings.json
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
## Environment Variables
|
|
385
|
+
```bash
|
|
386
|
+
# Agent configuration
|
|
387
|
+
export HANZO_AGENT_MODEL="openai/gpt-4"
|
|
388
|
+
export HANZO_API_KEY="your-key"
|
|
389
|
+
|
|
390
|
+
# Tool settings
|
|
391
|
+
export HANZO_COMMAND_TIMEOUT=300
|
|
392
|
+
export HANZO_ENABLE_AGENT_TOOL=true
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
## Project-Specific Config
|
|
396
|
+
Create `.hanzo/config.json` in your project:
|
|
397
|
+
```json
|
|
398
|
+
{
|
|
399
|
+
"enabled_tools": ["lsp", "vector_search"],
|
|
400
|
+
"disabled_tools": ["sql_query"],
|
|
401
|
+
"agent": {
|
|
402
|
+
"model": "claude-3-sonnet",
|
|
403
|
+
"max_iterations": 15
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
```"""
|
|
407
|
+
|
|
408
|
+
NETWORK_AGENT_GUIDE_PROMPT = """# Network Agent Orchestration Guide
|
|
409
|
+
|
|
410
|
+
## Distributed AI Processing
|
|
411
|
+
|
|
412
|
+
The `network` tool (also accessible as `swarm` for compatibility) enables distributed AI workloads across multiple agents.
|
|
413
|
+
|
|
414
|
+
### Basic Multi-Agent Setup
|
|
415
|
+
```python
|
|
416
|
+
# Launch parallel agents
|
|
417
|
+
network(
|
|
418
|
+
task="Analyze this codebase for security, performance, and quality",
|
|
419
|
+
agents=["security_expert", "performance_analyst", "code_reviewer"],
|
|
420
|
+
mode="parallel"
|
|
421
|
+
)
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
### Execution Modes
|
|
425
|
+
|
|
426
|
+
#### 1. Local Mode (Privacy-First)
|
|
427
|
+
```python
|
|
428
|
+
network(
|
|
429
|
+
task="Process sensitive data",
|
|
430
|
+
mode="local", # Uses only local compute
|
|
431
|
+
agents=["data_processor", "analyzer"]
|
|
432
|
+
)
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
#### 2. Distributed Mode
|
|
436
|
+
```python
|
|
437
|
+
network(
|
|
438
|
+
task="Large-scale analysis",
|
|
439
|
+
mode="distributed", # Uses network resources
|
|
440
|
+
agents=["agent1", "agent2", "agent3"]
|
|
441
|
+
)
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
#### 3. Hybrid Mode (Default)
|
|
445
|
+
```python
|
|
446
|
+
network(
|
|
447
|
+
task="General processing",
|
|
448
|
+
mode="hybrid", # Local first, cloud fallback
|
|
449
|
+
agents=["primary", "secondary"]
|
|
450
|
+
)
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
### Routing Strategies
|
|
454
|
+
|
|
455
|
+
#### Sequential Processing
|
|
456
|
+
```python
|
|
457
|
+
network(
|
|
458
|
+
task="Multi-step workflow",
|
|
459
|
+
agents=["preprocessor", "analyzer", "reporter"],
|
|
460
|
+
routing="sequential" # Each agent processes in order
|
|
461
|
+
)
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
#### Parallel Processing
|
|
465
|
+
```python
|
|
466
|
+
network(
|
|
467
|
+
task="Independent analyses",
|
|
468
|
+
agents=["test_runner", "linter", "security_scan"],
|
|
469
|
+
routing="parallel" # All agents work simultaneously
|
|
470
|
+
)
|
|
471
|
+
```
|
|
472
|
+
|
|
473
|
+
#### Consensus Decision
|
|
474
|
+
```python
|
|
475
|
+
network(
|
|
476
|
+
task="Critical decision",
|
|
477
|
+
agents=["expert1", "expert2", "expert3"],
|
|
478
|
+
routing="consensus" # Agents must agree
|
|
479
|
+
)
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
### Claude CLI Integration
|
|
483
|
+
```python
|
|
484
|
+
# Run multiple Claude instances in parallel
|
|
485
|
+
batch(
|
|
486
|
+
description="Parallel Claude analysis",
|
|
487
|
+
invocations=[
|
|
488
|
+
{"tool_name": "claude_cli", "input": {"prompt": "Review architecture"}},
|
|
489
|
+
{"tool_name": "claude_cli", "input": {"prompt": "Analyze performance"}},
|
|
490
|
+
{"tool_name": "claude_cli", "input": {"prompt": "Check security"}}
|
|
491
|
+
]
|
|
492
|
+
)
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
## Advanced Features
|
|
496
|
+
- **MCP Connections**: Agents communicate via MCP protocol
|
|
497
|
+
- **State Sharing**: Agents share context and memory
|
|
498
|
+
- **Tool Sharing**: Agents can use each other's tools
|
|
499
|
+
- **Recursive Calling**: Agents can spawn sub-agents
|
|
500
|
+
|
|
501
|
+
## Best Practices
|
|
502
|
+
1. Use local mode for sensitive data
|
|
503
|
+
2. Use parallel routing for independent tasks
|
|
504
|
+
3. Use consensus for critical decisions
|
|
505
|
+
4. Monitor agent resource usage"""
|
|
506
|
+
|
|
507
|
+
PERFORMANCE_TIPS_PROMPT = """# Performance Optimization Guide
|
|
508
|
+
|
|
509
|
+
## Speed Optimization
|
|
510
|
+
|
|
511
|
+
### 1. Use Batch for Parallel Operations
|
|
512
|
+
```python
|
|
513
|
+
# SLOW - Sequential execution
|
|
514
|
+
result1 = read(file="/file1.py")
|
|
515
|
+
result2 = read(file="/file2.py")
|
|
516
|
+
result3 = read(file="/file3.py")
|
|
517
|
+
|
|
518
|
+
# FAST - Parallel execution
|
|
519
|
+
batch(
|
|
520
|
+
description="Read multiple files",
|
|
521
|
+
invocations=[
|
|
522
|
+
{"tool_name": "read", "input": {"file_path": "/file1.py"}},
|
|
523
|
+
{"tool_name": "read", "input": {"file_path": "/file2.py"}},
|
|
524
|
+
{"tool_name": "read", "input": {"file_path": "/file3.py"}}
|
|
525
|
+
]
|
|
526
|
+
)
|
|
527
|
+
```
|
|
528
|
+
|
|
529
|
+
### 2. Use Unified Search
|
|
530
|
+
```python
|
|
531
|
+
# Combines multiple search methods efficiently
|
|
532
|
+
search(
|
|
533
|
+
pattern="important_function",
|
|
534
|
+
path="/project",
|
|
535
|
+
max_results=20
|
|
536
|
+
)
|
|
537
|
+
```
|
|
538
|
+
|
|
539
|
+
### 3. Limit Result Sets
|
|
540
|
+
```python
|
|
541
|
+
# Use pagination
|
|
542
|
+
find(pattern="*.py", page=1, page_size=50)
|
|
543
|
+
|
|
544
|
+
# Set max results
|
|
545
|
+
grep(pattern="TODO", max_results=100)
|
|
546
|
+
```
|
|
547
|
+
|
|
548
|
+
### 4. Use Appropriate Tools
|
|
549
|
+
```python
|
|
550
|
+
# For code structure - use AST search
|
|
551
|
+
grep_ast(pattern="class.*Service", path="/src")
|
|
552
|
+
|
|
553
|
+
# For exact text - use grep
|
|
554
|
+
grep(pattern="ERROR:", path="/logs")
|
|
555
|
+
|
|
556
|
+
# For concepts - use vector search
|
|
557
|
+
vector_search(query="authentication flow", path="/src")
|
|
558
|
+
```
|
|
559
|
+
|
|
560
|
+
## Memory Optimization
|
|
561
|
+
|
|
562
|
+
### 1. Process Large Files in Chunks
|
|
563
|
+
```python
|
|
564
|
+
# Read with offset and limit
|
|
565
|
+
read(file="/large_file.log", offset=1000, limit=100)
|
|
566
|
+
```
|
|
567
|
+
|
|
568
|
+
### 2. Use Streaming for Long Operations
|
|
569
|
+
```python
|
|
570
|
+
# Background long-running processes
|
|
571
|
+
bash("npm run dev", background=true)
|
|
572
|
+
|
|
573
|
+
# Check status separately
|
|
574
|
+
process(action="list")
|
|
575
|
+
```
|
|
576
|
+
|
|
577
|
+
## Network Optimization
|
|
578
|
+
|
|
579
|
+
### 1. Local-First Processing
|
|
580
|
+
```python
|
|
581
|
+
# Use local compute when possible
|
|
582
|
+
network(task="analyze", mode="local")
|
|
583
|
+
```
|
|
584
|
+
|
|
585
|
+
### 2. Cache Results
|
|
586
|
+
```python
|
|
587
|
+
# Index once, search many times
|
|
588
|
+
vector_index(path="/project")
|
|
589
|
+
# Now searches are fast
|
|
590
|
+
vector_search(query="pattern", use_cache=true)
|
|
591
|
+
```
|
|
592
|
+
|
|
593
|
+
## Tips
|
|
594
|
+
- Profile before optimizing
|
|
595
|
+
- Use batch for I/O operations
|
|
596
|
+
- Limit data transferred
|
|
597
|
+
- Use appropriate search methods
|
|
598
|
+
- Cache expensive operations"""
|
|
599
|
+
|
|
600
|
+
SECURITY_BEST_PRACTICES_PROMPT = """# Security Best Practices
|
|
601
|
+
|
|
602
|
+
## Safe Tool Usage
|
|
603
|
+
|
|
604
|
+
### 1. Path Validation
|
|
605
|
+
```python
|
|
606
|
+
# Always use absolute paths from known locations
|
|
607
|
+
read(file="/home/user/project/file.py") # Good
|
|
608
|
+
read(file="../../../etc/passwd") # Blocked
|
|
609
|
+
|
|
610
|
+
# Tools validate paths against allowed directories
|
|
611
|
+
```
|
|
612
|
+
|
|
613
|
+
### 2. Command Injection Prevention
|
|
614
|
+
```python
|
|
615
|
+
# Use parameterized commands
|
|
616
|
+
bash(f"grep {pattern} file.txt") # Risky if pattern is user input
|
|
617
|
+
|
|
618
|
+
# Better: Use dedicated tools
|
|
619
|
+
grep(pattern=user_input, path="file.txt") # Safe
|
|
620
|
+
```
|
|
621
|
+
|
|
622
|
+
### 3. Sensitive Data Handling
|
|
623
|
+
```python
|
|
624
|
+
# Never log sensitive data
|
|
625
|
+
think("Processing user data [REDACTED]")
|
|
626
|
+
|
|
627
|
+
# Use local mode for sensitive operations
|
|
628
|
+
network(
|
|
629
|
+
task="Process PII data",
|
|
630
|
+
mode="local", # Stays on device
|
|
631
|
+
require_local=true
|
|
632
|
+
)
|
|
633
|
+
```
|
|
634
|
+
|
|
635
|
+
## Permission Management
|
|
636
|
+
|
|
637
|
+
### 1. Tool Permissions
|
|
638
|
+
- Read operations are generally safe
|
|
639
|
+
- Write operations require confirmation
|
|
640
|
+
- System commands are restricted
|
|
641
|
+
|
|
642
|
+
### 2. Agent Permissions
|
|
643
|
+
```python
|
|
644
|
+
# Agents inherit permission restrictions
|
|
645
|
+
agent(
|
|
646
|
+
prompt="Analyze code",
|
|
647
|
+
permissions=["read", "search"] # Limited permissions
|
|
648
|
+
)
|
|
649
|
+
```
|
|
650
|
+
|
|
651
|
+
## Data Protection
|
|
652
|
+
|
|
653
|
+
### 1. Local Processing
|
|
654
|
+
```python
|
|
655
|
+
# Keep data local
|
|
656
|
+
network(mode="local", task="Process confidential data")
|
|
657
|
+
```
|
|
658
|
+
|
|
659
|
+
### 2. Secure Communication
|
|
660
|
+
- All MCP connections use secure channels
|
|
661
|
+
- Agent communications are encrypted
|
|
662
|
+
- No data persisted without permission
|
|
663
|
+
|
|
664
|
+
## Best Practices
|
|
665
|
+
1. Validate all inputs
|
|
666
|
+
2. Use least privilege principle
|
|
667
|
+
3. Keep sensitive data local
|
|
668
|
+
4. Audit tool usage
|
|
669
|
+
5. Review agent outputs
|
|
670
|
+
6. Don't execute untrusted code
|
|
671
|
+
7. Use sandboxed environments for testing"""
|
|
672
|
+
|
|
673
|
+
TROUBLESHOOTING_GUIDE_PROMPT = """# Troubleshooting Guide
|
|
674
|
+
|
|
675
|
+
## Common Issues and Solutions
|
|
676
|
+
|
|
677
|
+
### 1. Tool Not Found
|
|
678
|
+
```
|
|
679
|
+
Error: Tool 'X' not found
|
|
680
|
+
```
|
|
681
|
+
**Solution:**
|
|
682
|
+
```python
|
|
683
|
+
# Check if tool is enabled
|
|
684
|
+
tool_list()
|
|
685
|
+
|
|
686
|
+
# Enable if needed
|
|
687
|
+
tool_enable(name="tool_name")
|
|
688
|
+
```
|
|
689
|
+
|
|
690
|
+
### 2. Permission Denied
|
|
691
|
+
```
|
|
692
|
+
Error: Permission denied for path X
|
|
693
|
+
```
|
|
694
|
+
**Solution:**
|
|
695
|
+
- Ensure path is in allowed directories
|
|
696
|
+
- Launch with: `hanzo-mcp --allow-path /your/path`
|
|
697
|
+
|
|
698
|
+
### 3. Timeout Errors
|
|
699
|
+
```
|
|
700
|
+
Error: Command timed out
|
|
701
|
+
```
|
|
702
|
+
**Solution:**
|
|
703
|
+
```python
|
|
704
|
+
# Increase timeout
|
|
705
|
+
bash("long_command", timeout=300)
|
|
706
|
+
|
|
707
|
+
# Or run in background
|
|
708
|
+
bash("long_command", background=true)
|
|
709
|
+
```
|
|
710
|
+
|
|
711
|
+
### 4. Memory Issues
|
|
712
|
+
```
|
|
713
|
+
Error: Result too large
|
|
714
|
+
```
|
|
715
|
+
**Solution:**
|
|
716
|
+
```python
|
|
717
|
+
# Use pagination
|
|
718
|
+
find(pattern="*", page=1, page_size=50)
|
|
719
|
+
|
|
720
|
+
# Limit results
|
|
721
|
+
grep(pattern="text", max_results=100)
|
|
722
|
+
|
|
723
|
+
# Read in chunks
|
|
724
|
+
read(file="/large.txt", offset=0, limit=1000)
|
|
725
|
+
```
|
|
726
|
+
|
|
727
|
+
### 5. Agent Failures
|
|
728
|
+
```
|
|
729
|
+
Error: Agent failed to complete task
|
|
730
|
+
```
|
|
731
|
+
**Solution:**
|
|
732
|
+
```python
|
|
733
|
+
# Increase iterations
|
|
734
|
+
agent(
|
|
735
|
+
prompt="task",
|
|
736
|
+
max_iterations=20,
|
|
737
|
+
max_tool_uses=50
|
|
738
|
+
)
|
|
739
|
+
|
|
740
|
+
# Use simpler prompts
|
|
741
|
+
# Break complex tasks into steps
|
|
742
|
+
```
|
|
743
|
+
|
|
744
|
+
### 6. Network Issues
|
|
745
|
+
```
|
|
746
|
+
Error: Cannot connect to cluster
|
|
747
|
+
```
|
|
748
|
+
**Solution:**
|
|
749
|
+
```python
|
|
750
|
+
# Use local mode
|
|
751
|
+
network(mode="local", task="...")
|
|
752
|
+
|
|
753
|
+
# Check cluster status
|
|
754
|
+
mcp_stats()
|
|
755
|
+
```
|
|
756
|
+
|
|
757
|
+
## Debugging Tips
|
|
758
|
+
|
|
759
|
+
### 1. Enable Verbose Output
|
|
760
|
+
```python
|
|
761
|
+
# Get detailed information
|
|
762
|
+
stats()
|
|
763
|
+
|
|
764
|
+
# Check process status
|
|
765
|
+
process(action="list")
|
|
766
|
+
|
|
767
|
+
# View logs
|
|
768
|
+
process(action="logs", id="process_id")
|
|
769
|
+
```
|
|
770
|
+
|
|
771
|
+
### 2. Test Incrementally
|
|
772
|
+
```python
|
|
773
|
+
# Start simple
|
|
774
|
+
read(file="/test.txt")
|
|
775
|
+
|
|
776
|
+
# Then expand
|
|
777
|
+
batch(invocations=[...])
|
|
778
|
+
```
|
|
779
|
+
|
|
780
|
+
### 3. Check Documentation
|
|
781
|
+
```python
|
|
782
|
+
# View help for specific category
|
|
783
|
+
"/hanzo:Filesystem tools help"
|
|
784
|
+
"/hanzo:Agent tools help"
|
|
785
|
+
|
|
786
|
+
# Explore all tools
|
|
787
|
+
"/hanzo:Explore all tools"
|
|
788
|
+
```
|
|
789
|
+
|
|
790
|
+
## Getting Help
|
|
791
|
+
1. Check error messages carefully
|
|
792
|
+
2. Use `think()` to reason about issues
|
|
793
|
+
3. Consult category-specific help
|
|
794
|
+
4. Try simpler alternatives
|
|
795
|
+
5. Report persistent issues"""
|
|
796
|
+
|
|
797
|
+
# Export all prompts
|
|
798
|
+
__all__ = [
|
|
799
|
+
"QUICK_START_PROMPT",
|
|
800
|
+
"PAGINATION_GUIDE_PROMPT",
|
|
801
|
+
"MEMORY_VECTOR_HELP_PROMPT",
|
|
802
|
+
"DATABASE_TOOLS_HELP_PROMPT",
|
|
803
|
+
"LSP_TOOLS_HELP_PROMPT",
|
|
804
|
+
"CONFIGURATION_GUIDE_PROMPT",
|
|
805
|
+
"NETWORK_AGENT_GUIDE_PROMPT",
|
|
806
|
+
"PERFORMANCE_TIPS_PROMPT",
|
|
807
|
+
"SECURITY_BEST_PRACTICES_PROMPT",
|
|
808
|
+
"TROUBLESHOOTING_GUIDE_PROMPT",
|
|
809
|
+
]
|