@tomsun28/happy-code
v0.1.4
Published
A simplified AI-powered CLI tool for intelligent code operations
Downloads
11
Maintainers
Readme
Happy Code CLI
A powerful AI-driven command-line tool designed for developers, providing intelligent code operations, file management, task planning, and development assistance through natural language interaction and rich toolsets to dramatically improve development efficiency.
🚀 Features
Core Tools
- File Operations: Read, write, and edit files with intelligent parsing
- Pattern Search: File pattern matching with glob support
- Content Search: Grep-based content search across files
- Shell Integration: Execute bash commands with sync/async support
- Task Management: Structured todo tracking with status and priority
- Natural Language: Interactive chat interface for seamless workflow
Advanced Capabilities
- MCP Protocol: Integration with third-party MCP servers and tools
- ReAct Planning: Intelligent task planning and execution scheduling
- Multi-Resource: Support for files, URLs, and various resource types
- Background Tasks: Asynchronous command execution support
- Context Management: Automatic context window tracking and intelligent compression
📦 Installation
# Install dependencies
pnpm install
# Build the project
pnpm run build
# Install globally
pnpm run install:global🛠️ Usage Modes
One-Shot Mode
Execute single commands with immediate results:
# Basic message
happy m "who are you"
happy message "who are you"
happy msg "who are you"
# With linked resources
happy m "read the content of the file" -l ./path/to/your/file.txt
happy m "read the content of the file" -l https://example.com/file.txt
# Multiple resources (parallel processing)
happy m "read the content of the files" -l ./path/to/your/file.txt https://example.com/file.txt
happy m "analyze these files" -l https://example.com/file.txt -l ./path/to/your/file.txtInteractive Mode
Enter continuous conversation mode:
# Start interactive mode
happy
# Start with initial message
happy "who are you"🔧 Command Reference
Non-Interactive Mode Commands
Message Commands
happy m <message> # Send message
happy message <message> # Send message (full form)
happy msg <message> # Send message (short form)MCP Server Management
# Add MCP server
happy mcp add <name> <command-to-run>
happy mcp add -s user zai-mcp-server --env Z_AI_API_KEY=your_key -- npx -y "@z_ai/mcp-server"
happy mcp add --transport http sentry https://mcp.sentry.dev/mcp --header Authorization=650ff76850634cbfa
happy mcp add --transport sse asana https://mcp.asana.com/sse --header Authorization=650ff76850634cbfa
# List servers
happy mcp list
# Remove server
happy mcp remove <name>
# Get server info
happy mcp info <name>⚙️ Configuration
Configure via ~/.happy-code/config.yaml:
apiKeys:
zhipu: your_api_key_here
defaults:
encoding: utf8
maxFileSizeMB: 10
searchResultsLimit: 100
shellTimeoutMs: 120000
enableBackgroundTasks: true
aiProvider: zhipu
aiModel: glm-4.6
maxTokens: 131072
temperature: 0.95
# Context Window Management
contextWindow: 204800 # Maximum context size in tokens
autoCompress: true # Enable automatic compression
compressionThreshold: 0.8 # Trigger at 80% usage
environment: development
logLevel: info
mcpServers:
zai-mcp:
command: npx
args:
- -y
- "@z_ai/mcp-server"
env:
Z_AI_API_KEY: your_api_key_here
autoConnect: trueContext Window Management
Happy Code automatically manages context window usage to prevent overflow:
- Token Tracking: Real-time monitoring of prompt and completion tokens
- Aggressive Compression: Compresses ALL history (except system prompts) when threshold reached
- Intelligent Summaries: Uses AI to create concise summaries of entire conversation history
- High Compression Ratio: Typically achieves 85-95% token reduction
- Configurable: Adjust context window size and compression threshold
Configuration Options:
contextWindow: Maximum context size in tokens (default: 204,800)autoCompress: Enable/disable automatic compression (default: true)compressionThreshold: Trigger compression at this usage percentage (default: 0.8)
View Token Usage:
# In interactive mode
/status🛠️ Development
pnpm run dev # Development mode
pnpm run build # Build for production
pnpm test # Run tests
pnpm run lint # Lint code📄 License
MIT License
