Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Kratos HelperNew to Visual Studio Code? Get it now.
Kratos Helper

Kratos Helper

dengdai68

|
17 installs
| (0) | Free
Quickly find Kratos: Find BladeMaster HTTP API definitions using tree-sitter.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

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

  1. Press Cmd+Shift+P (macOS) or Ctrl+Shift+P (Windows/Linux)
  2. Search for "Kratos: Find BladeMaster HTTP API"
  3. Start typing to filter routes (e.g., /api/users, /v1/orders)

Route Discovery Demo

Method 2: Right-Click Context Menu

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

Context Menu Demo

Finding Interface Implementations

The extension automatically detects Go interfaces and provides convenient CodeLens for finding implementations:

CodeLens Integration:

  1. Open any Go file containing interface definitions
  2. Look for CodeLens indicators above interface methods: 🔍 Find implementations
  3. Click to see all implementations of that interface method across your codebase

Command Palette:

  1. Press Cmd+Shift+P (macOS) or Ctrl+Shift+P (Windows/Linux)
  2. Search for "Go: Find Interface Implementations"
  3. 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:

  1. Right-click any .proto file
  2. Navigate to Kratos → Choose your action:
    • Kratos: Generate PB Files (gRPC server/client code)
    • Kratos: Generate BM Files (BladeMaster HTTP server)

From Editor:

  1. Open a .proto file
  2. Right-click in editor
  3. 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

  1. Auto-Detection: Checks Kratos installation and version before execution
  2. Progress Tracking: Real-time progress indicators with detailed status messages
  3. Error Handling: Comprehensive error reporting with actionable guidance
  4. 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:

  1. Open VS Code
  2. Press Ctrl+Shift+X (Extensions view)
  3. Search "Kratos Helper" or "api-finder"
  4. Click Install

Via Command Line:

code --install-extension dengdai68.api-finder

Manual Installation:

  1. Download .vsix file from releases
  2. 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

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft