Kratos Helper - VS Code Extension
A powerful VS Code extension for Kratos framework development, providing intelligent HTTP API route discovery and protobuf code generation capabilities.
✨ Features
- 🔍 Smart API Route Discovery: Automatically scans and indexes HTTP routes from Go
blademaster
code using advanced tree-sitter parsing
- 🚀 BladeMaster Integration: Full support for
blademaster.Engine
and blademaster.RouterGroup
patterns
- 🎯 Intelligent Navigation: Quick search and jump-to-definition for API routes with fuzzy matching
- 🔧 Interface Implementation Finder: Quick discovery and navigation to Go interface method implementations with CodeLens integration
- ⚡ Performance Optimized: Intelligent caching system with automatic file change detection
- 📦 Protobuf Code Generation: Integrated Kratos protobuf code generation with organized submenu
- 🔧 Auto Environment Detection: Built-in Kratos installation verification and version checking
- 🏗️ Zero Dependencies: No external tools required for route discovery (uses embedded tree-sitter WASM)
🚀 Quick Start
Finding HTTP API Routes
Method 1: Command Palette
- Press
Cmd+Shift+P
(macOS) or Ctrl+Shift+P
(Windows/Linux)
- Search for "Kratos: Find BladeMaster HTTP API"
- Start typing to filter routes (e.g.,
/api/users
, /v1/orders
)

Method 2: Right-Click Context Menu
- Open any Go file (
.go
) in the editor
- Right-click anywhere in the editor
- Select "Kratos: Find BladeMaster HTTP API"

Finding Interface Implementations
The extension automatically detects Go interfaces and provides convenient CodeLens for finding implementations:
CodeLens Integration:
- Open any Go file containing interface definitions
- Look for CodeLens indicators above interface methods:
🔍 Find implementations
- Click to see all implementations of that interface method across your codebase
Command Palette:
- Press
Cmd+Shift+P
(macOS) or Ctrl+Shift+P
(Windows/Linux)
- Search for "Go: Find Interface Implementations"
- Select the interface method to explore its implementations
Key Benefits:
- Instant Discovery: Quickly find all types that implement an interface
- Visual Indicators: CodeLens shows implementation count at a glance
- Smart Navigation: Jump directly to implementation files and specific methods
- Real-time Updates: Automatically refreshes when code changes
Protobuf Code Generation
The extension provides a convenient Kratos submenu for all protobuf operations:
From File Explorer:
- Right-click any
.proto
file
- Navigate to Kratos → Choose your action:
- Kratos: Generate PB Files (gRPC server/client code)
- Kratos: Generate BM Files (BladeMaster HTTP server)
From Editor:
- Open a
.proto
file
- Right-click in editor
- Navigate to Kratos → Choose your action
Generated Code Types
Command |
Kratos Command |
Generated Files |
Generate PB Files |
kratos proto grpc |
gRPC server stubs, client code, message types |
Generate BM Files |
kratos proto bm |
BladeMaster HTTP handlers, routing, middleware |
📋 Requirements
For API Route Discovery
- ✅ No dependencies required - Works out of the box
For Protobuf Generation
- 📦 Kratos CLI must be installed and available in PATH
Installing Kratos:
# Method 1: Go Install (Recommended)
go install github.com/go-kratos/kratos/cmd/kratos/v2@latest
# Method 2: Download Binary
# Visit: https://github.com/go-kratos/kratos/releases
Verify Installation:
kratos -v
# Expected output: kratos version v2.x.x
🔧 How It Works
Intelligent Route Discovery
- Tree-sitter Parsing: Uses embedded WASM-based Go parser for accurate AST analysis
- Smart Pattern Detection: Recognizes
blademaster.Engine
and RouterGroup
usage patterns
- Path Resolution: Automatically resolves nested route groups and base paths
- Incremental Updates: Real-time cache updates when files change
- Priority Processing: Processes
http.go
files first for faster discovery
Interface Implementation Analysis
- AST-based Detection: Uses Go's abstract syntax tree to identify interface definitions
- Workspace Scanning: Automatically scans all Go files in workspace for implementations
- Method Signature Matching: Precisely matches method names, parameters, and return types
- CodeLens Integration: Provides inline implementation counts and quick navigation
- Real-time Monitoring: Updates implementation list when files are modified or added
Advanced Protobuf Workflow
- Auto-Detection: Checks Kratos installation and version before execution
- Progress Tracking: Real-time progress indicators with detailed status messages
- Error Handling: Comprehensive error reporting with actionable guidance
- Smart Execution: Runs commands in appropriate workspace directory context
Supported Route Patterns
// Basic routes
engine.GET("/users", handler)
engine.POST("/api/v1/orders", handler)
// Route groups
v1 := engine.Group("/api/v1")
v1.GET("/users", handler)
v1.POST("/orders", handler)
// Nested groups
api := engine.Group("/api")
v1 := api.Group("/v1")
v1.GET("/health", handler)
// Special methods
engine.Any("/webhook", handler)
engine.Ping("/ping")
📚 Available Commands
Command |
Scope |
Description |
Kratos: Find BladeMaster HTTP API |
Go files |
Search and navigate to HTTP route definitions |
Go: Find Interface Implementations |
Go interfaces |
Find all implementations of an interface method |
Kratos: Generate PB Files |
.proto files |
Generate gRPC protobuf code via submenu |
Kratos: Generate BM Files |
.proto files |
Generate BladeMaster HTTP code via submenu |
📦 Installation
Via VS Code Marketplace:
- Open VS Code
- Press
Ctrl+Shift+X
(Extensions view)
- Search "Kratos Helper" or "api-finder"
- Click Install
Via Command Line:
code --install-extension dengdai68.api-finder
Manual Installation:
- Download
.vsix
file from releases
- Run:
code --install-extension kratos-helper-x.x.x.vsix
🏗️ Technical Architecture
- Parser: Embedded
web-tree-sitter
with Go grammar (no external dependencies)
- Cache: Persistent JSON-based route cache with automatic invalidation
- File Watching: Real-time Go file monitoring for incremental updates
- Command Execution: Async process execution with timeout and error handling
- UI Integration: Native VS Code QuickPick with fuzzy search and priority sorting
🤝 Contributing
Issues and pull requests are welcome! Please visit our GitHub repository.
📄 License
This project is licensed under the MIT License.
Made with ❤️ for the Kratos community