idea-debug-tools-dev-guidelines
1
总安装量
1
周安装量
#53056
全站排名
安装命令
npx skills add https://github.com/ayuayue/skills --skill idea-debug-tools-dev-guidelines
Agent 安装分布
kilo
1
amp
1
opencode
1
kimi-cli
1
codex
1
github-copilot
1
Skill 文档
Debug Tools Development Guidelines
Project Overview
Debug Tools is a multi-module Java project with an IntelliJ IDEA plugin that provides advanced debugging capabilities including hot-deploy, hot-reload, method invocation, SQL monitoring, and remote debugging.
Key Capabilities
- Hot Deploy: Skip build/deploy cycle – changes take effect without manual triggers
- Hot Reload: Code changes apply instantly without restarting (supports classes, proxies, Spring, Solon, MyBatis)
- Method Invocation: Directly invoke any Java method without API layers
- Remote Debugging: Trigger remote methods with hot-deploy support
- SQL Monitoring: Print SQL statements and execution time without code changes
- HTTP URL Search: Navigate from URL to method definition
- xxl-job Support: Execute client methods with context passing
- Groovy Execution: Run Groovy scripts for debugging
Module Structure
Maven Modules (root: pom.xml)
debug-tools/
âââ debug-tools-attach # Attachment agent
âââ debug-tools-common # Shared utilities, DTOs, protocols
âââ debug-tools-test # Test modules and examples
âââ debug-tools-base # Base functionality
âââ debug-tools-server # Server-side components
âââ debug-tools-client # Client-side components (Netty-based)
âââ debug-tools-boot # Bootstrap and initialization
âââ debug-tools-core # Core debugging functionality
âââ debug-tools-hotswap # Hot swap agent with plugin system
âââ debug-tools-vm # VM-related utilities
âââ debug-tools-sql # SQL monitoring
âââ debug-tools-extension # Extensions (Spring, Solon)
IDEA Plugin Module (Gradle: debug-tools-idea/)
debug-tools-idea/
âââ src/main/java/io/github/future0923/debug/tools/idea/
â âââ action/ # IDEA actions (menus, shortcuts)
â âââ client/socket/ # TCP client for server communication
â âââ listener/data/ # Data event listeners
â âââ context/ # Context helpers (class/method data)
â âââ camel/ # Naming convention converters
âââ build.gradle.kts # Gradle build configuration
Package Structure Standards
Common Module (debug-tools-common)
io.github.future0923.debug.tools.common/
âââ codec/ # Netty encoding/decoding
âââ dto/ # Data Transfer Objects
â âââ RunDTO.java
â âââ RunContentDTO.java
â âââ RunResultDTO.java
â âââ TraceMethodDTO.java
âââ enums/ # Enumerations
â âââ PrintResultType.java
â âââ ResultClassType.java
â âââ ResultVarClassType.java
â âââ RunContentType.java
âââ exception/ # Custom exceptions
â âââ DebugToolsException.java
â âââ DebugToolsRuntimeException.java
â âââ ArgsParseException.java
â âââ CallTargetException.java
âââ handler/ # Netty packet handlers
âââ protocal/ # Protocol definitions
â âââ packet/ # Packet base and types
â â âââ Packet.java
â â âââ EntityPacket.java
â â âââ request/ # Request packets
â â âââ response/ # Response packets
â âââ http/ # HTTP protocol objects
â âââ serializer/ # Serialization implementations
âââ utils/ # Utility classes
âââ DebugToolsJsonUtils.java
âââ DebugToolsTypeUtils.java
âââ DebugToolsLambdaUtils.java
âââ DebugToolsDateUtils.java
âââ JdkUnsafeUtils.java
Hot Swap Module (debug-tools-hotswap)
io.github.future0923.debug.tools.hotswap.core/
âââ HotswapAgent.java # Main agent entry point
âââ annotation/ # Plugin annotation system
â âââ Plugin.java
â âââ Init.java
â âââ OnClassFileEvent.java
â âââ OnClassLoadEvent.java
â âââ OnResourceFileEvent.java
â âââ handler/ # Annotation processors
âââ command/ # Command system
â âââ Command.java
â âââ MergeableCommand.java
â âââ Scheduler.java
â âââ impl/ # Implementations
âââ config/ # Configuration
â âââ PluginManager.java
â âââ PluginConfiguration.java
â âââ PluginRegistry.java
âââ plugin/ # Built-in plugins
â âââ hotswapper/ # Hot swap implementation
â âââ watchResources/ # Resource watching
â âââ gson/jackson/spring/ # Framework-specific plugins
âââ util/ # Utilities
â âââ JavassistUtil.java # Bytecode manipulation
â âââ ReflectionHelper.java
â âââ HotswapTransformer.java
â âââ AnnotationHelper.java
â âââ IOUtils.java
â âââ classloader/ # ClassLoader utilities
â âââ scanner/ # Class scanning
âââ watch/ # File watching
âââ Watcher.java
âââ WatcherFactory.java
âââ nio/ # NIO2 implementation
Code Style and Conventions
Import Statements
- Follow standard Java import conventions
- Group imports logically: standard library, third-party, project imports
- Use spotless-maven-plugin for automatic formatting
Naming Conventions
- Classes: PascalCase (e.g.,
RunTargetMethodRequestPacket) - Methods: camelCase (e.g.,
dispatchPacket) - Constants: UPPER_SNAKE_CASE (e.g.,
PORT) - Packages: lowercase with dots (e.g.,
io.github.future0923.debug.tools.common)
Exception Handling
- Create domain-specific exceptions extending
DebugToolsExceptionorDebugToolsRuntimeException - Provide descriptive error messages
- Include relevant context in exception data
Logging
- Use SLF4J for logging
- Configure logging levels appropriately
- For hotswap operations, see
LogConfigurationHelper
Lombok Usage
- Lombok is used throughout the project (version 1.18.38)
- Common annotations:
@Data,@Slf4j,@Builder,@AllArgsConstructor,@NoArgsConstructor
Protocol and Packet Design
Packet Structure
All packets extend Packet:
public abstract class Packet {
// Common packet fields
protected Command command;
protected int sequenceId;
// ...
}
Request/Response Pattern
- Request packets:
XxxRequestPacket(inprotocal/packet/request/) - Response packets:
XxxResponsePacket(inprotocal/packet/response/) - Use command enum in
Commandfor packet type identification
Serialization
- Default serializer:
BinaryNettySerializer - Implement
NettySerializerfor custom serialization - Register serializers in
SerializerAlgorithm
Netty Communication
Client-Side (debug-tools-client / debug-tools-idea)
- Client dispatcher:
ClientNettyPacketDispatcher(Netty) orClientPacketDispatcher(Socket) - Handlers are registered in
ClientDispatchHandler
Common Codecs
- Encoder:
PacketNettyEncoder - Decoder:
PacketNettyDecoder - Frame decoder:
PacketFrameDecoder
Server-Side (debug-tools-server)
- Handlers implement
NettyPacketHandler
Hot Swap Plugin System
Plugin Development
Hot swap uses a plugin architecture. To create a new plugin:
- Create plugin class with
@Pluginannotation - Use
@Initfor initialization - Use event annotations:
@OnClassFileEvent– Class file changes@OnClassLoadEvent– Class loading events@OnResourceFileEvent– Resource file changes
Example plugin structure:
@Plugin(name = "MyPlugin", version = "1.0.0")
public class MyPlugin {
@Init
public void init(PluginConfiguration config) {
// Initialization logic
}
@OnClassFileEvent
public void onClassChange(ClassFileEvent event) {
// Handle class changes
}
}
Bytecode Manipulation
- Use
JavassistUtilfor bytecode operations - ClassFileTransformer implementations:
HaClassFileTransformer - See existing plugins for patterns:
IDEA Plugin Development
Action Structure
All IDEA actions extend base classes:
AbstractTraceMethodAction– For method tracing- Actions are registered in
plugin.xml(referenced in build.gradle.kts)
Client Communication
- TCP client:
DebugToolsTcpClient - Config:
ClientConfig - State tracking:
ClientConnectState
Context Helpers
ClassDataContext– Class informationMethodDataContext– Method information
Build and Development
Maven Build
# Build entire project
mvn clean install
# Build specific module
cd debug-tools-common
mvn clean install
# Skip tests
mvn clean install -DskipTests
Gradle Build (IDEA Plugin)
cd debug-tools-idea
./gradlew buildPlugin
# For Windows
gradlew.bat buildPlugin
Code Formatting
- spotless-maven-plugin runs automatically on
validatephase - Manually format:
mvn spotless:apply
License Formatting
- license-maven-plugin runs automatically on
validatephase - See HEADER file for license template
Testing
Test Modules
debug-tools-test/contains test applications:debug-tools-test-simple– Simple test casedebug-tools-test-spring-boot-mybatis– Spring Boot + MyBatis example
Running Tests
# Run all tests
mvn test
# Run tests with hotswap agent (JDK < 21)
mvn test -P surefire-java-lt21
Test Configuration
Hotswap tests require special JVM arguments (see surefire-java-lt21 profile in pom.xml):
-XX:+AllowEnhancedClassRedefinition
-XX:HotswapAgent=external
--add-opens java.base/java.lang=ALL-UNNAMED
--add-opens java.base/jdk.internal.loader=ALL-UNNAMED
# ... more opens
Dependencies
Key Versions
- Java: 8+ (supports 8, 11, 17, 21, 25)
- Spring Boot: 2.7.4
- Groovy: 4.0.22
- Javassist: 3.30.2-GA
- Lombok: 1.18.38
- Hutool: 5.8.29
- Arthas: 3.7.2
Shadow/Relocated Packages
- Shaded package prefix:
io.github.future0923.debug.tools.dependencies - Use maven-shade-plugin to relocate third-party dependencies
Framework Integration
Spring Plugin
Location: debug-tools-hotswap/debug-tools-hotswap-plugin/debug-tools-hotswap-spring-plugin
- Supports Spring Boot 2.7.4
- Provides Spring context-aware hot reload
Solon Plugin
Location: debug-tools-extension/debug-tools-extension-solon
- Supports Solon 3.3.1
- Provides Solon framework integration
Jackson/Gson Plugins
Development Workflow
- Code Changes: Make modifications in appropriate modules
- Build: Run
mvn clean installfor Maven modules - Plugin Build: Run
./gradlew buildPluginin debug-tools-idea - Test: Use test applications in debug-tools-test
- IDEA Plugin: Install plugin jar from
debug-tools-idea/build/distributions/
Important Files to Reference
- Main POM:
pom.xml - Hotswap Agent:
HotswapAgent.java - Client Config:
ClientConfig.java - Bootstrap:
DebugToolsBootstrap.java - IDEA Plugin Build:
build.gradle.kts
Important Notes
- DO NOT execute mvn or other build commands during development
- DO NOT write test code
- Prompt users to manually build and verify changes