Files
zeekayandHanzo Dev d3110e47ea Major refactor: Unified tools, palette system, dev mode, and shell improvements (v0.6.0)
🎨 **Tool Palette System**
- Created palette system for organizing development tools by ecosystem
- Pre-defined palettes: Python (Guido), Ruby (Matz), JavaScript, Go, Rust, DevOps, Full Stack, Minimal
- `palette` tool to list, activate, and manage tool sets
- Environment variables applied from active palette
- Keeps MCP interface clean while supporting specialized workflows

🔧 **Unified Process Tools with OO Design**
- Refactored all process execution to use clean base class hierarchy
- `BaseProcessTool`, `BaseBinaryTool`, `BaseScriptTool` for consistent interface
- Unified `bash`, `npx`, `uvx` tools with action-based approach (run/background)
- `process` tool for managing background processes
- All tools use same execution pipeline internally

🐚 **Smart Shell Detection**
- Shell tool now detects user's preferred shell from $SHELL environment
- Automatically uses zsh if .zshrc exists (perfect for your setup\!)
- Falls back to bash if no special configuration found
- All zsh aliases, functions, and configurations now available in MCP

🚀 **Development Mode with Hot Reload**
- Added `--dev` flag to hanzo-mcp CLI for development mode
- File watching with automatic reload detection using watchdog
- `hanzo-mcp-dev` command for dedicated dev server
- Watches Python files and config changes
- Debounced reloading to prevent spam

🛠️ **New Tools Added**
- `open`: Opens files/URLs in default application (platform-aware)
- `watch`: Monitors files/directories for changes with pattern matching
- `diff`: Compares files with unified/context diff formats
- `config`: Git-style configuration management

📚 **Documentation & Infrastructure**
- Comprehensive Sphinx documentation with black theme
- Automated deployment to mcp.hanzo.ai via Cloudflare Pages
- GitHub Actions workflow for docs deployment
- 25+ documentation pages organized by category

⚙️ **Configuration Improvements**
- Tool enable/disable system with palette override
- Per-project vs global indexing configuration
- Environment variable management through palettes
- Clean separation of concerns in tool registration

This release provides a much cleaner, more extensible architecture while
maintaining backward compatibility. The palette system makes it easy to
switch between development environments, and the unified process tools
eliminate code duplication while providing consistent behavior.

Co-authored-by: Hanzo Dev <[email protected]>
2025-06-26 17:59:24 -04:00

118 lines
3.9 KiB
Python

import os
from mcp.server import FastMCP
from hanzo_mcp.prompts.compact_conversation import COMPACT_CONVERSATION_PROMPT
from hanzo_mcp.prompts.create_release import CREATE_RELEASE_PROMPT
from hanzo_mcp.prompts.project_system import PROJECT_SYSTEM_PROMPT
from hanzo_mcp.prompts.project_todo_reminder import (
PROJECT_TODO_EMPTY_REMINDER,
get_project_todo_reminder,
)
from hanzo_mcp.prompts.utils import (
get_directory_structure,
get_git_info,
get_os_info,
)
CONTINUE_FROM_LAST_SESSION_PROMPT = """<system-reminder>
This is a reminder that your todo list is currently empty. DO NOT mention this to the user explicitly because they are already aware. If you are working on tasks that would benefit from a todo list please use the TodoWrite tool to create one. If not, please feel free to ignore. Again do not mention this message to the user.
</system-reminder>
"""
def create_project_system_prompt(project_path: str):
"""Factory function to create a project system prompt function."""
def project_system_prompt() -> str:
"""
Summarize the conversation so far for a specific project.
"""
working_directory = project_path
is_git_repo = os.path.isdir(os.path.join(working_directory, ".git"))
platform, _, os_version = get_os_info()
# Get directory structure
directory_structure = get_directory_structure(
working_directory, max_depth=3, include_filtered=False
)
# Get git information
git_info = get_git_info(working_directory)
current_branch = git_info.get("current_branch", "")
main_branch = git_info.get("main_branch", "")
git_status = git_info.get("git_status", "")
recent_commits = git_info.get("recent_commits", "")
return PROJECT_SYSTEM_PROMPT.format(
working_directory=working_directory,
is_git_repo=is_git_repo,
platform=platform,
os_version=os_version,
directory_structure=directory_structure,
current_branch=current_branch,
main_branch=main_branch,
git_status=git_status,
recent_commits=recent_commits,
)
return project_system_prompt
def register_all_prompts(
mcp_server: FastMCP, projects: list[str] | None = None
) -> None:
@mcp_server.prompt(name="Compact current conversation")
def compact() -> str:
"""
Summarize the conversation so far.
"""
return COMPACT_CONVERSATION_PROMPT
@mcp_server.prompt(name="Create a new release")
def create_release() -> str:
"""
Create a new release for my project.
"""
return CREATE_RELEASE_PROMPT
@mcp_server.prompt(name="Continue todo by session id")
def continue_todo_by_session_id(session_id: str) -> str:
"""
Continue from the last todo list for the current session.
"""
return get_project_todo_reminder(session_id)
@mcp_server.prompt(name="Continue latest todo")
def continue_latest_todo() -> str:
"""
Continue from the last todo list for the current session.
"""
return get_project_todo_reminder()
@mcp_server.prompt(name="System prompt")
def manual_project_system_prompt(project_path: str) -> str:
"""
Detailed system prompt include env,git etc information about the specified project.
"""
return create_project_system_prompt(project_path)()
if projects is None:
return
for project in projects:
# Register the prompt with the factory function
mcp_server.prompt(
name=f"System prompt for {os.path.basename(project)}",
description=f"Detailed system prompt include env,git etc information about {project}",
)(create_project_system_prompt(project))
return
__all__ = [
"register_all_prompts",
"get_project_todo_reminder",
"PROJECT_TODO_EMPTY_REMINDER",
]