Files
MuyueWorkspace/internal/skills/builtins.go
Augustin f0ccd265da
Some checks failed
CI / build (macos-latest) (push) Has been cancelled
CI / build (windows-latest) (push) Has been cancelled
CI / lint (push) Has been cancelled
CI / build (ubuntu-latest) (push) Has been cancelled
feat: initial release of muyue - AI-powered dev environment assistant
Complete implementation of muyue v0.1.0, a single-binary Go tool that
transforms the development environment with AI-powered orchestration.

Core features:
- TUI with 5 tabs (Dashboard/Chat/Workflow/Agents/Config) using Charm stack
- AI chat via MiniMax M2.7 with async message handling
- Structured Plan→Execute workflow engine (gather→plan→review→execute)
- System scanner detecting 14 tools + 8 runtimes across Linux/macOS/Windows
- Auto-installer for Crush, Claude Code, BMAD, Starship, runtimes
- Background update daemon with hourly checks
- LSP auto-config for 16 language servers
- MCP auto-config for 12 servers (deployed to Crush + Claude Code)
- Skills system with 5 built-ins + AI-powered generation
- Crush/Claude Code proxy for unified control
- HTML preview server for visual outputs
- First-time setup wizard with interactive profiling
- Cross-platform: Linux (primary), macOS, Windows, WSL

CI/CD:
- GitHub Actions CI: build + test + lint on Linux/macOS/Windows
- Release workflow: cross-compile 6 binaries with checksums on tag push

💘 Generated with Crush

Assisted-by: GLM-5.1 via Crush <crush@charm.land>
2026-04-19 22:29:20 +02:00

299 lines
8.6 KiB
Go

package skills
import (
"os"
"path/filepath"
"time"
)
var builtinSkills = []Skill{
{
Name: "env-setup",
Description: "Set up a complete development environment for any language. Detects missing tools, installs them, and configures the project.",
Author: "muyue",
Version: "1.0.0",
Target: "both",
Tags: []string{"setup", "environment", "install"},
Content: `# Environment Setup
Use this skill when setting up a new development environment or project.
## Steps
1. Detect the project type by checking for config files:
- ` + "`go.mod`" + ` → Go
- ` + "`package.json`" + ` → Node.js
- ` + "`requirements.txt` / `pyproject.toml` / `setup.py`" + ` → Python
- ` + "`Cargo.toml`" + ` → Rust
- ` + "`pom.xml` / `build.gradle`" + ` → Java
2. Check if required tools are installed:
- Language runtime (go, node, python, etc.)
- Package manager (npm, pip, cargo, etc.)
- Linter/formatter
- Test runner
3. If tools are missing, install them using the system package manager:
- Linux: apt/dnf/pacman
- macOS: brew
- Windows: winget/scoop
4. Install project dependencies:
- ` + "`go mod download`" + ` for Go
- ` + "`npm install`" + ` / ` + "`pnpm install`" + ` for Node.js
- ` + "`pip install -r requirements.txt`" + ` / ` + "`uv sync`" + ` for Python
- ` + "`cargo build`" + ` for Rust
5. Configure git hooks if ` + "`pre-commit`" + ` config exists.
6. Verify the setup by running tests or build.
## Error Handling
- If a tool cannot be installed automatically, provide the manual install command.
- If dependency installation fails, check for version conflicts and suggest fixes.
- Always check for lock files first to ensure reproducible installs.`,
},
{
Name: "git-workflow",
Description: "Manage git branches, commits, and pull requests following best practices. Handles branching strategy, conventional commits, and PR creation.",
Author: "muyue",
Version: "1.0.0",
Target: "both",
Tags: []string{"git", "workflow", "branching", "commits"},
Content: `# Git Workflow
Use this skill when the user needs to create branches, make commits, or manage pull requests.
## Branch Naming Convention
- ` + "`feature/<ticket>-<description>`" + ` for new features
- ` + "`fix/<ticket>-<description>`" + ` for bug fixes
- ` + "`refactor/<description>`" + ` for refactoring
- ` + "`docs/<description>`" + ` for documentation
## Commit Messages
Follow Conventional Commits:
- ` + "`feat: add user authentication`" + `
- ` + "`fix: resolve null pointer in login`" + `
- ` + "`refactor: extract validation logic`" + `
- ` + "`docs: update API documentation`" + `
- ` + "`test: add integration tests for auth`" + `
- ` + "`chore: update dependencies`" + `
## Workflow
1. Before starting, pull latest changes: ` + "`git pull --rebase origin main`" + `
2. Create branch: ` + "`git checkout -b feature/my-feature`" + `
3. Make changes and commit frequently with meaningful messages
4. Before pushing, rebase: ` + "`git rebase origin/main`" + `
5. Push: ` + "`git push -u origin feature/my-feature`" + `
6. Create PR with description following template
## PR Description Template
` + "```" + `
## Summary
<1-3 bullet points>
## Changes
- <list of key changes>
## Test Plan
- [ ] <checklist>
` + "```" + `
## Error Handling
- If rebase has conflicts, help resolve them file by file
- If push is rejected, pull with rebase first
- Never force push to main/master`,
},
{
Name: "api-design",
Description: "Design and implement REST or GraphQL APIs following best practices. Includes endpoint design, error handling, and documentation.",
Author: "muyue",
Version: "1.0.0",
Target: "both",
Tags: []string{"api", "rest", "graphql", "design"},
Content: `# API Design
Use this skill when designing or implementing an API.
## REST API Design Rules
1. Use nouns for resources, not verbs: ` + "`/users`" + ` not ` + "`/getUsers`" + `
2. Use plural nouns: ` + "`/users`" + ` not ` + "`/user`" + `
3. Use proper HTTP methods:
- GET for reading
- POST for creating
- PUT/PATCH for updating
- DELETE for removing
4. Use query parameters for filtering: ` + "`/users?role=admin&active=true`" + `
5. Use pagination: ` + "`/users?page=1&limit=20`" + `
6. Return proper status codes:
- 200: Success
- 201: Created
- 204: No Content (successful delete)
- 400: Bad Request
- 401: Unauthorized
- 403: Forbidden
- 404: Not Found
- 422: Validation Error
- 500: Internal Server Error
## Error Response Format
` + "```" + `json
{
"error": {
"code": "VALIDATION_ERROR",
"message": "Human readable message",
"details": [
{"field": "email", "message": "Invalid email format"}
]
}
}
` + "```" + `
## Implementation Steps
1. Define the API spec (endpoints, request/response schemas)
2. Implement data models
3. Add validation middleware
4. Implement handlers
5. Add error handling
6. Write tests
7. Generate documentation (OpenAPI/Swagger)`,
},
{
Name: "debug-assist",
Description: "Systematic debugging assistant. Helps identify, isolate, and fix bugs using a structured approach.",
Author: "muyue",
Version: "1.0.0",
Target: "both",
Tags: []string{"debug", "troubleshooting", "bugs"},
Content: `# Debug Assist
Use this skill when the user reports a bug or asks for help debugging.
## Debugging Process
1. **Reproduce** — Understand the exact steps to reproduce
2. **Isolate** — Narrow down the scope:
- Is it frontend or backend?
- Does it happen consistently or intermittently?
- Does it happen in all environments or just one?
3. **Hypothesize** — Form a hypothesis about the root cause
4. **Verify** — Add logging or breakpoints to confirm
5. **Fix** — Make the minimal change to fix the issue
6. **Test** — Verify the fix works and doesn't break other things
7. **Prevent** — Add a test to prevent regression
## Common Patterns
- **Null/Nil errors**: Check for missing initialization or unexpected nil values
- **Type errors**: Check API contracts and type assertions
- **Race conditions**: Look for shared mutable state without synchronization
- **Memory leaks**: Check for unclosed resources (connections, files, channels)
- **Off-by-one**: Check loop bounds and array indexing
- **State issues**: Check if state is properly reset between operations
## Debugging Commands
- Check logs: Look for error messages and stack traces
- Check recent changes: ` + "`git diff HEAD~5`" + ` to see what changed
- Check dependencies: Verify versions match expected
- Check environment: Compare config between working and broken environments`,
},
{
Name: "code-review",
Description: "Perform a thorough code review. Checks for bugs, security issues, performance problems, and style consistency.",
Author: "muyue",
Version: "1.0.0",
Target: "both",
Tags: []string{"review", "quality", "security"},
Content: `# Code Review
Use this skill when reviewing code changes or pull requests.
## Review Checklist
### Correctness
- Does the code do what it's supposed to?
- Are edge cases handled?
- Are there off-by-one errors?
- Are error paths handled?
### Security
- Is user input sanitized?
- Are there SQL injection risks?
- Are secrets hardcoded?
- Are authentication/authorization checks in place?
- Is sensitive data logged?
### Performance
- Are there N+1 queries?
- Are there unnecessary loops or computations?
- Is caching used where appropriate?
- Are large allocations avoided?
### Readability
- Are names descriptive?
- Is the code self-documenting?
- Are complex parts commented?
- Is the code modular?
### Testing
- Are there unit tests?
- Are edge cases tested?
- Are error paths tested?
- Are tests independent and deterministic?
## Review Format
1. Summary of changes
2. Issues found (critical → minor)
3. Suggestions for improvement
4. Positive observations
## Severity Levels
- **Critical**: Security vulnerabilities, data loss risks, crashes
- **Major**: Bugs, performance issues, missing error handling
- **Minor**: Style issues, naming, minor refactoring opportunities
- **Suggestion**: Alternative approaches, improvements`,
},
}
func InstallBuiltinSkills() error {
dir, err := SkillsDir()
if err != nil {
return err
}
for _, s := range builtinSkills {
skillDir := filepath.Join(dir, s.Name)
skillPath := filepath.Join(skillDir, "SKILL.md")
if _, err := os.Stat(skillPath); err == nil {
continue
}
s.CreatedAt = time.Now()
s.UpdatedAt = time.Now()
if err := os.MkdirAll(skillDir, 0755); err != nil {
return err
}
content := renderSkill(&s)
if err := os.WriteFile(skillPath, []byte(content), 0644); err != nil {
return err
}
}
return nil
}