### Example Skill Recommendation Response Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/find-skills/SKILL.md This is an example of how to present a found skill to the user, including its purpose, installation count, source, and installation command. ```bash I found a skill that might help! The "react-best-practices" skill provides React and Next.js performance optimization guidelines from Vercel Engineering. (185K installs) To install it: npx skills add vercel-labs/agent-skills@react-best-practices Learn more: https://skills.sh/vercel-labs/agent-skills/react-best-practices ``` -------------------------------- ### H-SPI Plugin Development Example Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/solon-development-skill/references/core_concepts.md Demonstrates the lifecycle methods `start()` and `stop()` for an H-SPI plugin. Resources added in `start()` must be unregistered in `stop()` to ensure proper isolation and cleanup. ```java public class Plugin1Impl implements Plugin { AppContext context; StaticRepository staticRepository; @Override public void start(AppContext context) { this.context = context; // Add own config file context.cfg().loadAdd("demo1011.plugin1.yml"); // Scan own beans context.beanScan(Plugin1Impl.class); // Add own static file repository (register classloader) staticRepository = new ClassPathStaticRepository(context.getClassLoader(), "plugin1_static"); StaticMappings.add("/html/", staticRepository); } @Override public void stop() throws Throwable { // Remove HTTP handlers (use prefix for easy removal) Solon.app().router().remove("/user"); // Remove scheduled jobs (use a solution that supports manual removal) JobManager.getInstance().jobRemove("job1"); // Remove event subscriptions context.beanForeach(bw -> { if (bw.raw() instanceof EventListener) { EventBus.unsubscribe(bw.raw()); } }); // Remove static file repository StaticMappings.remove(staticRepository); } } ``` -------------------------------- ### Install SolonCode on Windows Source: https://github.com/opensolon/soloncode/blob/main/README.md Use PowerShell to download and execute the installation script for Windows systems. ```powershell irm https://solon.noear.org/soloncode/setup.ps1 | iex ``` -------------------------------- ### Install CLI Backend Source: https://github.com/opensolon/soloncode/blob/main/soloncode-desktop/README.md Installs the SolonCode CLI backend to the user's home directory. ```bash # In the root directory of the project cd soloncode-cli mvn clean package -DskipTests # Install to ~/.soloncode/bin/ cd release # Windows powershell -File install.ps1 # Linux/macOS bash install.sh ``` -------------------------------- ### Build Desktop Installer (Linux) Source: https://github.com/opensolon/soloncode/blob/main/soloncode-desktop/README.md Builds the Linux installer package for SolonCode Desktop, including prerequisite installations. ```bash # Prerequisite dependencies sudo apt install libwebkit2gtk-4.1-dev build-essential curl wget file libxdo-dev libssl-dev libayatana-appindicator3-dev librsvg2-dev # Build CLI JAR + Install cd soloncode-cli mvn clean package -DskipTests cd release && bash install.sh && cd .. # Build desktop installer cd ../soloncode-desktop pnpm install pnpm tauri build ``` -------------------------------- ### Solon Full Configuration Example Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/spring-to-solon-skill/references/config_system_migration.md An example of a comprehensive `app.yml` file in Solon, demonstrating equivalent configurations for server, datasource, Redis, logging, and custom application settings. ```yaml # 服务配置(Solon 的 server 配置结构不同于 Spring) server: port: 8080 contextPath: /api # 注意:不是 servlet.context-path # Solon 激活环境 solon: env: dev # 数据源配置(使用 Solon 的数据源约定) datasource: # 默认数据源 url: jdbc:mysql://localhost:3306/mydb username: root password: 123456 driverClassName: com.mysql.cj.jdbc.Driver maxPoolSize: 20 minIdle: 5 # Redis 配置(使用 Solon 的 Redis 约定) redis: host: localhost port: 6379 password: "" database: 0 # 日志级别 solon.logging: level: root: INFO com.example: DEBUG # 自定义业务配置(保持不变) app: name: demo-app version: 1.0.0 features: - feature-a - feature-b security: jwt-secret: my-secret-key token-expiration: 3600 ``` -------------------------------- ### Startup Parameter Examples Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/solon-development-skill/references/api_annotations.md Demonstrates equivalent ways to set the solon.env startup parameter. ```bash java -Dsolon.env=dev -jar demo.jar ``` ```bash java -jar demo.jar --solon.env=dev ``` ```bash java -jar demo.jar --env=dev ``` -------------------------------- ### PiAgent Example Configuration and Call Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/solon-development-skill/references/ai_development.md Configures the harness with the PiAgent's tools (`TOOL_PI`) and a default model, then makes a prompt call to the engine. This example demonstrates setting up and using a specific agent configuration. ```java HarnessProperties harnessProps = new HarnessProperties(".tmp/"); harnessProps.addTools(ToolPermission.TOOL_PI); //微形命令行工具 harnessProps.addModel(null); //设定大模型配置 HarnessEngine engine = HarnessEngine.of(harnessProps) .sessionProvider(sessionProvider) .build(); engine.prompt("网络调查 ai mcp 协议,生成一个 mcp.md 报告").call(); ``` -------------------------------- ### Install a Skill Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/find-skills/SKILL.md Use this command to install a specific skill. Skills can be installed from GitHub or other sources. ```bash npx skills add ``` -------------------------------- ### Build Desktop Installer (macOS) Source: https://github.com/opensolon/soloncode/blob/main/soloncode-desktop/README.md Builds the macOS installer package for SolonCode Desktop, including prerequisite installations. ```bash # Prerequisite dependencies brew install node rust npm install -g pnpm # Build CLI JAR + Install cd soloncode-cli mvn clean package -DskipTests cd release && bash install.sh && cd .. # Build desktop installer cd ../soloncode-desktop pnpm install pnpm tauri build ``` -------------------------------- ### Build Desktop Installer (Windows) Source: https://github.com/opensolon/soloncode/blob/main/soloncode-desktop/README.md Builds the Windows installer package for SolonCode Desktop using Tauri CLI. ```bash cd soloncode-desktop npm run tauri:build ``` -------------------------------- ### Nami Client Using Solon Annotations - Further Simplification Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/solon-development-skill/references/remoting.md Further simplifies Nami client interface definitions by relying on default HTTP methods (GET for no parameters, POST for parameters) and inferred paths. This example demonstrates GET and POST requests with various parameter types. ```java @NamiClient public interface HelloService { String hello(String name, @Header("H1") String h1, @Cookie("C1") String c1); @Consumes(MimeType.APPLICATION_JSON_VALUE) String test01(List ids); String test02(UploadedFile file); @Post // 如果是 GET 请求,这个注解可以去掉 String test03(); @Mapping("/test04/{name}") String test04(String name); @Mapping("/test05/?type={type}") String test05(int type, @Body Order order); } ``` -------------------------------- ### Install Frontend Dependencies Source: https://github.com/opensolon/soloncode/blob/main/soloncode-desktop/README.md Installs the necessary dependencies for the SolonCode Desktop frontend using pnpm. ```bash cd soloncode-desktop npm install ``` -------------------------------- ### Example Search Queries for Finding Skills Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/find-skills/SKILL.md These examples demonstrate how to use the `npx skills find` command with specific keywords to locate relevant skills for user requests. ```bash npx skills find react performance ``` ```bash npx skills find pr review ``` ```bash npx skills find changelog ``` -------------------------------- ### Install SolonCode on Mac/Linux Source: https://github.com/opensolon/soloncode/blob/main/README.md Use curl to download and execute the installation script for macOS and Linux systems. ```bash curl -fsSL https://solon.noear.org/soloncode/setup.sh | bash ``` -------------------------------- ### Application Configuration Example (YAML) Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/solon-development-skill/references/modules_reference.md Example of application configuration in YAML format for a database connection. This typically resides in an application.yml file. ```yaml # application.yml db1: jdbcUrl: jdbc:mysql://localhost:3306/demo username: root password: 123456 driverClassName: com.mysql.cj.jdbc.Driver ``` -------------------------------- ### Start Development Mode Source: https://github.com/opensolon/soloncode/blob/main/soloncode-desktop/README.md Launches the frontend and Tauri window with hot-reloading enabled for development. ```bash # Start frontend + Tauri window (hot update) npm run tauri:dev ``` -------------------------------- ### Install a Skill with Global and Auto-Confirm Flags Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/find-skills/SKILL.md Use this command to install a skill globally for the user and skip confirmation prompts. The `-g` flag installs user-level, and `-y` skips confirmation. ```bash npx skills add -g -y ``` -------------------------------- ### Spring Boot Full Configuration Example Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/spring-to-solon-skill/references/config_system_migration.md An example of a comprehensive `application.yml` file in Spring Boot, including server, datasource, Redis, logging, and custom application settings. ```yaml # 服务配置 server: port: 8080 servlet: context-path: /api # Spring 激活环境 spring: profiles: active: dev # 数据源配置 datasource: url: jdbc:mysql://localhost:3306/mydb username: root password: 123456 driver-class-name: com.mysql.cj.jdbc.Driver hikari: maximum-pool-size: 20 minimum-idle: 5 # Redis 配置 redis: host: localhost port: 6379 password: "" database: 0 # 日志级别 logging: level: root: INFO com.example: DEBUG # 自定义业务配置 app: name: demo-app version: 1.0.0 features: - feature-a - feature-b security: jwt-secret: my-secret-key token-expiration: 3600 ``` -------------------------------- ### Solon Plugin Implementation Example Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/solon-development-skill/references/core_concepts.md Provides an example of a custom Solon plugin implementation. Plugins should follow the convention `XxxSolonPlugin` and are typically placed in the `integration` package. ```java public class DemoSolonPlugin implements Plugin { @Override public void start(AppContext context) { context.beanInterceptorAdd(AuthLogined.class, new LoginedInterceptor()); } } ``` -------------------------------- ### SimpleAgent Hello World Example Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/solon-development-skill/references/ai_development.md Demonstrates a 'SimpleAgent' for basic instruction response. It includes a ChatModel configuration and a custom TimeTool. ```java ChatModel chatModel = ChatModel.of("https://api.moark.com/v1/chat/completions") .apiKey("***") .model("Qwen3-32B") .build(); SimpleAgent robot = SimpleAgent.of(chatModel) .defaultToolAdd(new TimeTool()) .build(); String answer = robot.prompt("现在几点了?") .call() .getContent(); public static class TimeTool { @ToolMapping(description = "获取当前系统时间") public String getTime() { return LocalDateTime.now().toString(); } } ``` -------------------------------- ### DataSource Configuration Example (HikariCP) Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/solon-development-skill/references/modules_reference.md Example of configuring a DataSource using HikariCP. This configuration is typically placed in a Java class annotated with @Configuration. ```java import org.noear.solon.annotation.Configuration; import org.noear.solon.annotation.Bean; import org.noear.solon.annotation.Inject; import javax.sql.DataSource; import com.zaxxer.hikari.HikariDataSource; // DataSource 配置(HikariCP 示例) @Configuration public class DataSourceConfig { @Bean(name = "db1", typed = true) public DataSource db1(@Inject("${db1}") HikariDataSource ds) { return ds; } } ``` -------------------------------- ### Workflow Executor Configuration Example (Java) Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/solon-development-skill/references/flow_orchestration.md Provides an example of configuring a WorkflowExecutor as a Spring Bean. Use for dependency injection in Solon applications. ```java @Configuration public class WorkflowConfig { @Bean public WorkflowExecutor workflowOf(FlowEngine engine) { return WorkflowExecutor.of(engine, new NotBlockStateController(), new InMemoryStateRepository()); } } ``` -------------------------------- ### Snapshot Output Format Example Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/agent-browser/references/snapshot-refs.md Illustrates the hierarchical structure and @ref assignments generated by the snapshot command. ```text Page: Example Site - Home URL: https://example.com @e1 [header] @e2 [nav] @e3 [a] "Home" @e4 [a] "Products" @e5 [a] "About" @e6 [button] "Sign In" @e7 [main] @e8 [h1] "Welcome" @e9 [form] @e10 [input type="email"] placeholder="Email" @e11 [input type="password"] placeholder="Password" @e12 [button type="submit"] "Log In" @e13 [footer] @e14 [a] "Privacy Policy" ``` -------------------------------- ### Run SolonCode Web Interface Source: https://github.com/opensolon/soloncode/blob/main/README.md Start the SolonCode web interface by running 'soloncode web 0'. Access the interactive web UI via the provided URL. ```bash demo@MacBook-Pro ~ % soloncode web 0 SolonCode v2026.6.5 PID-73617 Model:deepseek-v4-flash /path/demo 2026-05-20 09:35 Web interface: http://localhost:50488/ ``` -------------------------------- ### Basic Browser Interaction Workflow Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/agent-browser/SKILL.md Demonstrates the core workflow of opening a URL, taking a snapshot to get element references, interacting with elements using those references, and re-snapshotting. ```bash agent-browser open https://example.com/form agent-browser snapshot -i # Output: @e1 [input type="email"], @e2 [input type="password"], @e3 [button] "Submit" agent-browser fill @e1 "user@example.com" agent-browser fill @e2 "password123" agent-browser click @e3 agent-browser wait --load networkidle agent-browser snapshot -i # Check result ``` -------------------------------- ### Basic Video Recording Workflow Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/agent-browser/references/video-recording.md Start recording, perform browser actions, and then stop to save the video. This is the fundamental sequence for capturing automation. ```bash # Start recording agent-browser record start ./demo.webm # Perform actions agent-browser open https://example.com agent-browser snapshot -i agent-browser click @e1 agent-browser fill @e2 "test input" # Stop and save agent-browser record stop ``` -------------------------------- ### State File Contents Example Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/agent-browser/references/session-management.md An example of the JSON structure for a saved session state file, including cookies, local storage, session storage, and origins. ```json { "cookies": [...], "localStorage": {...}, "sessionStorage": {...}, "origins": [...] } ``` -------------------------------- ### Basic Profiling Workflow Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/agent-browser/references/profiling.md Start profiling, perform actions, and then stop and save the trace to a file. This is a fundamental workflow for capturing performance data. ```bash # Start profiling agent-browser profiler start # Perform actions agent-browser navigate https://example.com agent-browser click "#button" agent-browser wait 1000 # Stop and save agent-browser profiler stop ./trace.json ``` -------------------------------- ### Profiler Command Usage Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/agent-browser/references/profiling.md Demonstrates starting the profiler with default categories and with custom categories, as well as stopping and saving the trace. Ensure you specify a valid file path for saving. ```bash # Start profiling with default categories agent-browser profiler start # Start with custom trace categories agent-browser profiler start --categories "devtools.timeline,v8.execute,blink.user_timing" # Stop profiling and save to file agent-browser profiler stop ./trace.json ``` -------------------------------- ### Generating Documentation with Video Recording Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/agent-browser/references/video-recording.md Create video documentation of user workflows. This script records a login process, including pauses for clarity, to generate a visual guide. ```bash #!/bin/bash # Record workflow for documentation agent-browser record start ./docs/how-to-login.webm agent-browser open https://app.example.com/login agent-browser wait 1000 # Pause for visibility agent-browser snapshot -i agent-browser fill @e1 "demo@example.com" agent-browser wait 500 agent-browser fill @e2 "password" agent-browser wait 500 agent-browser click @e3 agent-browser wait --load networkidle agent-browser wait 1000 # Show result agent-browser record stop ``` -------------------------------- ### Workflow Executor Usage Example (Java) Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/solon-development-skill/references/flow_orchestration.md Shows how to build and use a WorkflowExecutor for business scenarios like approvals and task assignments. Requires 'solon-flow-workflow' dependency. ```java // 构建工作流执行器 WorkflowExecutor workflow = WorkflowExecutor.of(engine, new NotBlockStateController(), new InMemoryStateRepository()); // 查询任务 Task task = workflow.findTask("c1", FlowContext.of("inst-1")); // 认领任务(权限匹配 + 状态激活) Task task = workflow.claimTask("c1", FlowContext.of("inst-1")); ``` -------------------------------- ### Mock Web Server Test Example Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/solon-development-skill/references/testing.md Uses MockWebServer to set up a mock HTTP server and test client interactions. Requires HttpTester for making requests. ```java import okhttp3.mockwebserver.MockResponse; import okhttp3.mockwebserver.MockWebServer; import org.junit.Rule; import org.junit.Test; import java.io.IOException; public class MockWebTest extends HttpTester { public static final String EXPECTED = "{\"status\": \"ok\"}"; @Rule public MockWebServer server = new MockWebServer(); @Test public void testSimple() throws IOException { server.enqueue(new MockResponse().setBody(EXPECTED)); String rst = http(server.getPort()).get(); assert rst != null; assert EXPECTED.equals(rst); } } ``` -------------------------------- ### Full Test Dependency Configuration: Solon Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/spring-to-solon-skill/references/test_basics_migration.md Example of configuring Solon test dependencies in pom.xml, including optional AssertJ. ```xml org.noear solon-test test org.assertj assertj-core test ``` -------------------------------- ### Mockito Mocking Example Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/solon-development-skill/references/testing.md Demonstrates using Mockito, which is built into solon-test, for creating mock objects and defining their behavior. ```java import static org.mockito.Mockito.*; import static org.junit.jupiter.api.Assertions.*; public class MockTest { @Test void testStub() { List l = mock(ArrayList.class); when(l.get(0)).thenReturn(10); when(l.get(1)).thenReturn(20); assertEquals(l.get(0), 10); assertEquals(l.get(1), 20); assertNull(l.get(4)); } @Test void testMatchers() { List l = mock(ArrayList.class); when(l.get(anyInt())).thenReturn(100); assertEquals(l.get(999), 100); } } ``` -------------------------------- ### Parallel Gateway Example (YAML) Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/solon-development-skill/references/flow_orchestration.md Defines a parallel gateway (all choices) in a flow layout. Use when multiple paths should be executed concurrently without conditions. ```yaml id: demo1 layout: - type: start - { type: parallel, link: [n1, n2] } - { type: activity, task: "@Task1", id: n1, link: g_end } - { type: activity, task: "@Task2", id: n2, link: g_end } - { type: parallel, id: g_end } - type: end ``` -------------------------------- ### Loop Gateway Example (YAML) Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/solon-development-skill/references/flow_orchestration.md Defines a loop gateway for iterating over a collection. Use for repeating a section of the flow. ```yaml id: demo1 layout: - type: start - { type: loop, meta: { "$for": "id", "$in": "idList" } } - { type: activity, task: "@Job" } - type: loop - type: end ``` -------------------------------- ### Solon Filter Example Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/spring-to-solon-skill/references/web_filter_interceptor_migration.md Shows the Solon equivalent of the Spring authentication filter, using Solon's Context and Filter interface. ```java import org.noear.solon.core.handle.Context; import org.noear.solon.core.handle.Filter; import org.noear.solon.core.handle.FilterChain; @Component public class AuthFilter implements Filter { @Override public void doFilter(Context ctx, FilterChain chain) throws Throwable { String token = ctx.header("Authorization"); if (token == null || token.isEmpty()) { ctx.status(401); ctx.contentType("application/json"); ctx.output("{"code":401,"message":"未授权"}"); return; // 不调用 chain.doFilter(),终止请求链 } chain.doFilter(ctx); } } ``` -------------------------------- ### Full Mockito Example with Manual Injection in Solon Test Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/spring-to-solon-skill/references/test_basics_migration.md Sets up mocks for UserService and OrderRepository in @BeforeEach, injects them into the Solon context, and tests OrderService's createOrder method. ```java @SolonTest(App.class) class OrderServiceTest { @Inject private OrderService orderService; @BeforeEach void setUp() { UserService mockUserService = mock(UserService.class); OrderRepository mockOrderRepo = mock(OrderRepository.class); when(mockUserService.getUser(1L)).thenReturn(new User(1L, "张三")); Solon.context().wrapAndPut(UserService.class, mockUserService); Solon.context().wrapAndPut(OrderRepository.class, mockOrderRepo); } @Test void testCreateOrder() { Order order = orderService.createOrder(1L, BigDecimal.valueOf(99.9)); assertNotNull(order); OrderRepository repo = Solon.context().getBean(OrderRepository.class); verify(repo, times(1)).save(any(Order.class)); } } ``` -------------------------------- ### Spring HandlerInterceptor Example Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/spring-to-solon-skill/references/web_filter_interceptor_migration.md Illustrates a Spring Boot logging interceptor that logs request start time and duration. ```java import org.springframework.web.servlet.HandlerInterceptor; import org.springframework.web.servlet.ModelAndView; @Component public class LogInterceptor implements HandlerInterceptor { @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { long startTime = System.currentTimeMillis(); request.setAttribute("startTime", startTime); System.out.println("请求开始: " + request.getRequestURI()); return true; } @Override public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) { System.out.println("请求处理完成"); } @Override public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) { long startTime = (long) request.getAttribute("startTime"); long duration = System.currentTimeMillis() - startTime; System.out.println("请求耗时: " + duration + "ms"); } } // 注册拦截器 @Configuration public class WebConfig implements WebMvcConfigurer { @Autowired private LogInterceptor logInterceptor; @Override public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(logInterceptor) .addPathPatterns("/api/**") .excludePathPatterns("/api/public/**"); } } ``` -------------------------------- ### Solon Cloud Discovery Service Instance Retrieval Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/spring-to-solon-skill/references/cloud_discovery_config_migration.md Example of retrieving service instances using Solon Cloud's CloudClient for discovery. ```java @Component public class OrderService { public List getUserInstances() { return CloudClient.discovery().findInstances("user-service"); } } ``` -------------------------------- ### Inclusive Gateway Example (YAML) Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/solon-development-skill/references/flow_orchestration.md Defines an inclusive gateway (multiple choices) in a flow layout. Use when multiple paths can be taken concurrently based on conditions. ```yaml id: demo1 layout: - type: start - { type: inclusive, link: [{ nextId: n1, when: "b>1" }, { nextId: n2, when: "a>1" }] } - { type: activity, task: "@Task1", id: n1, link: g_end } - { type: activity, task: "@Task2", id: n2, link: g_end } - { type: inclusive, id: g_end } - type: end ``` -------------------------------- ### Solon Cloud Dependency Management with BOM Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/spring-to-solon-skill/references/cloud_discovery_config_migration.md Example of using a Bill of Materials (BOM) to manage Solon Cloud plugin versions, ensuring compatibility and consistency. ```xml org.noear solon-parent 3.10.0 pom import ``` -------------------------------- ### Solon RouterInterceptor Example Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/spring-to-solon-skill/references/web_filter_interceptor_migration.md Shows the Solon equivalent of the Spring logging interceptor, using a single doIntercept method for pre and post-processing. ```java import org.noear.solon.core.handle.Context; import org.noear.solon.core.handle.Handler; import org.noear.solon.core.handle.RouterInterceptor; @Component public class LogRouterInterceptor implements RouterInterceptor { @Override public void doIntercept(Context ctx, Handler mainHandler, RouterInterceptorChain chain) throws Throwable { // 请求处理前(等价于 preHandle) long startTime = System.currentTimeMillis(); ctx.attrSet("startTime", startTime); System.out.println("请求开始: " + ctx.path()); // 执行后续拦截器和目标 handler chain.doIntercept(ctx, mainHandler); // 请求处理完成后(等价于 afterCompletion) long duration = System.currentTimeMillis() - startTime; System.out.println("请求耗时: " + duration + "ms"); } } ``` -------------------------------- ### Basic Interface Declaration with @NamiClient Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/solon-development-skill/references/remoting.md Declares an interface for a remote service using @NamiClient, specifying the base URL. This example shows basic POST and GET operations for saving and reading complex models. ```java @NamiClient(url = "http://localhost:8080/ComplexModelService/") public interface IComplexModelService { // POST http://localhost:8080/ComplexModelService/save void save(@NamiBody ComplexModel model); // POST http://localhost:8080/ComplexModelService/read ComplexModel read(Integer modelId); } ``` -------------------------------- ### WebSocket Chat Implementation Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/solon-development-skill/references/common_patterns.md Implement a WebSocket endpoint for a chat room. This example shows how to handle connection opening and message reception. ```java @ServerEndpoint("/ws/chat/{roomId}") public class WebSocketChat extends SimpleWebSocketListener { @Override public void onOpen(WebSocket socket) { String roomId = socket.param("roomId"); System.out.println("用户加入房间: " + roomId); } @Override public void onMessage(WebSocket socket, String text) throws IOException { socket.send("[Echo] " + text); } } ``` -------------------------------- ### Update All Installed Skills Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/find-skills/SKILL.md Use this command to update all of your installed skills to their latest versions. ```bash npx skills update ``` -------------------------------- ### Initialize Solon AI Development Environment Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/solon-development-skill/references/ai_development.md This snippet shows how to initialize the HarnessEngine, configure tools, add chat models, set system prompts, and provide a custom agent session provider. It demonstrates setting up the core components for AI development. ```java import org.noear.solon.ai.agent.AgentSession; import org.noear.solon.ai.agent.AgentSessionProvider; import org.noear.solon.ai.agent.react.ReActAgent; import org.noear.solon.ai.agent.session.InMemoryAgentSession; import org.noear.solon.ai.chat.ChatConfig; import org.noear.solon.ai.harness.HarnessEngine; import org.noear.solon.ai.harness.HarnessProperties; import org.noear.solon.ai.harness.agent.AgentDefinition; import org.noear.solon.ai.harness.permission.ToolPermission; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; public class DemoApp { public static void main(String[] arg) throws Throwable { //--- 1. 初始化 HarnessProperties harnessProps = new HarnessProperties(".tmp/"); harnessProps.addTools(ToolPermission.TOOL_WEBSEARCH); //设定工具权限 harnessProps.addModel(new ChatConfig()); //添加大模型配置(可多个,用时可切换) harnessProps.setSystemPrompt("xxx"); //添加主代理系统提示词 AgentSessionProvider sessionProvider = new AgentSessionProvider() { private Map sessionMap = new ConcurrentHashMap<>(); @Override public AgentSession getSession(String instanceId) { return sessionMap.computeIfAbsent(instanceId, k -> InMemoryAgentSession.of(k)); } }; HarnessEngine engine = HarnessEngine.of(harnessProps) .sessionProvider(sessionProvider) .build(); //--- 用主代理执行 case1(engine, "hello"); //--- 动态创建子代理执行(可以动态创建不同的工具权限) case2(engine, "hello"); } private static void case1(HarnessEngine engine, String prompt) throws Throwable { AgentSession session = engine.getSession("default"); //--- 用主代理模式 engine.prompt(prompt) .session(session) //没有,则为临时会话 .options(o -> { //按需,动态指定工作区(没有,则为默认工作区) o.toolContextPut(HarnessEngine.ATTR_CWD, "xxx"); }) .call(); } private static void case2(HarnessEngine engine, String prompt) throws Throwable { AgentSession session = engine.getSession("default"); //动态定义智能体 AgentDefinition definition = new AgentDefinition(); definition.setSystemPrompt("xxx"); //系统提示词 definition.getMetadata().addTools(ToolPermission.TOOL_BASH); //工具权限 ReActAgent subagent = engine.createSubagent(definition).build(); subagent.prompt(prompt) .session(session) //没有,则为临时会话 .options(o -> { //按需,动态指定工作区(没有,则为默认工作区) o.toolContextPut(HarnessEngine.ATTR_CWD, "xxx"); }) .call(); } } ``` -------------------------------- ### RPC Server Implementation Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/solon-development-skill/references/remoting.md Implement the RPC service on the server. Ensure the service class is annotated with @Mapping and @Remoting. The server application needs to start Solon. ```java public class ServerApp { public static void main(String[] args) { Solon.start(ServerApp.class, args); } } @Mapping("/rpc/v1/user") // 必须有 @Mapping @Remoting public class UserServiceImpl implements UserService { @Inject UserMapper userMapper; @Override public void add(User user) { userMapper.add(user); } @Override public User getById(long userId) { return userMapper.getById(userId); } } ``` -------------------------------- ### Solon E-SPI: Programmatic Custom Loading Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/solon-development-skill/references/core_concepts.md Example of using Solon's E-SPI (External SPI) to programmatically load external JAR packages and configuration files during application startup. ```java @SolonMain public class Application { public static void main(String[] args) throws Exception { Solon.start(Application.class, args, app -> { // Load jar package app.classLoader().addJar(new File("/demo.jar")); // Load properties file app.cfg().loadAdd(new File("/demo.yml")); }); } } ``` -------------------------------- ### HTTP Method Mapping - GET Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/solon-development-skill/references/api_annotations.md Limits a mapping to handle only GET requests. Used in conjunction with @Mapping. ```java @Get @Mapping("/users") public List getUsers() { // ... } ``` -------------------------------- ### Annotation-based Transaction Example Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/solon-development-skill/references/modules_reference.md Example of using the @Tran annotation for declarative transaction management. The default propagation mechanism is REQUIRED. ```java import org.noear.solon.annotation.Service; import org.noear.solon.annotation.Inject; import org.noear.solon.data.annotation.Tran; @Service public class OrderService { @Inject private UserService userService; @Tran // 声明式事务(传播机制默认 REQUIRED) public void createOrder(Order order) { userService.updateUser(order.getUser()); // ... 其他业务操作 } } ``` -------------------------------- ### Database Schema Initialization Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/spring-to-solon-skill/references/test_advanced_migration.md SQL script for creating the 'users' table, compatible with both Spring Boot and Solon. ```sql CREATE TABLE IF NOT EXISTS users ( id BIGINT PRIMARY KEY AUTO_INCREMENT, name VARCHAR(100), email VARCHAR(100) ); ``` -------------------------------- ### JUnit 4 Solon Test Example Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/solon-development-skill/references/testing.md Example of a JUnit 4 test using SolonJUnit4ClassRunner and @SolonTest, extending HttpTester for HTTP interface testing. ```java @RunWith(SolonJUnit4ClassRunner.class) @SolonTest(TestApp.class) public class DemoTest extends HttpTester { @Inject UserService userService; @Test // org.junit.Test public void hello() { assert userService.hello("world").equals("hello world"); } } ``` -------------------------------- ### Initialize a New Skill Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/skill-creator/SKILL.md Use this command to generate a new skill template directory. It sets up the basic structure including a SKILL.md template, and example resource directories like scripts/, references/, and assets/. ```bash scripts/init_skill.py --path ``` -------------------------------- ### Batch Interface Test Example Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/solon-development-skill/references/testing.md An example of a batch interface test where multiple API calls are made and their responses are asserted. This snippet tests the '/api/config.set' endpoint. ```java @Slf4j @SolonTest(App.class) public class Api_config extends HttpTester { @Test public void config_set() throws Exception { String json = path("/api/config.set") .data("tag", "demo") .data("key", "test") .data("value", "test").post(); ONode node = ONode.load(json); assert node.get("code").getInt() == 200; } } ``` -------------------------------- ### Nami Client Using Solon Annotations - Simplified Mapping Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/solon-development-skill/references/remoting.md Shows a simplified approach to defining Nami client interfaces with Solon annotations, where path segments and parameter names can be inferred. This example uses default POST for methods with parameters. ```java @NamiClient public interface HelloService { @Post String hello(String name, @Header("H1") String h1, @Cookie("C1") String c1); @Consumes(MimeType.APPLICATION_JSON_VALUE) @Post String test01(List ids); @Mapping("/test05/?type={type}") @Post String test05(int type, @Body Order order); } ``` -------------------------------- ### Solon Configuration Metadata JSON Example Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/solon-development-skill/references/core_concepts.md This JSON file defines available configuration properties and provides value suggestions for them. It includes properties like server port and cache driver type, along with hints for the cache driver. ```json { "properties": [ { "name": "server.port", "type": "java.lang.Integer", "defaultValue": "8080", "description": "服务端口" }, { "name": "cache.driverType", "type": "java.lang.String", "defaultValue": "local", "description": "缓存驱动类型" }, { "name": "beetlsql.inters", "type": "java.lang.String[]", "description": "数据管理插件列表" } ], "hints": [ { "name": "cache.driverType", "values": [ { "value": "local", "description": "本地缓存" }, { "value": "redis", "description": "Redis缓存" }, { "value": "memcached", "description": "Memcached缓存" } ] } ] } ``` -------------------------------- ### Chrome Trace Event Format Example Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/agent-browser/references/profiling.md An example of the JSON output format generated by the profiler, which adheres to the Chrome Trace Event format. This structure is used by various profiling tools. ```json { "traceEvents": [ { "cat": "devtools.timeline", "name": "RunTask", "ph": "X", "ts": 12345, "dur": 100, ... }, ... ], "metadata": { "clock-domain": "LINUX_CLOCK_MONOTONIC" } } ``` -------------------------------- ### SqlUtils Usage Example Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/solon-development-skill/references/modules_reference.md Example demonstrating the usage of SqlUtils for database operations, including updating, finding by ID, and querying lists of users. SqlUtils provides lightweight JDBC encapsulation with chained queries and automatic Bean mapping. ```java import org.noear.solon.annotation.Component; import org.noear.solon.annotation.Inject; import javax.sql.DataSource; import java.util.List; import org.noear.solon.data.sql.SqlUtils; @Component public class UserService { @Inject private DataSource dataSource; // 推荐复用 SqlUtils 实例 private SqlUtils sqlUtils() { return new SqlUtils(dataSource); } public void updateUser(User user) { sqlUtils().update("UPDATE users SET name=? WHERE id=?", user.name, user.id); } public User getUser(long id) { return sqlUtils().findById(id, User.class, "users"); } public List listUsers() { return sqlUtils().queryRowList("SELECT * FROM users").toBeanList(User.class); } } ``` -------------------------------- ### Check for Skill Updates Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/find-skills/SKILL.md Use this command to check if any of your installed skills have available updates. ```bash npx skills check ``` -------------------------------- ### Spring Interceptors Configuration Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/spring-to-solon-skill/references/web_filter_interceptor_migration.md Example of configuring multiple interceptors in Spring's WebMvcConfigurer. ```java @Configuration public class WebConfig implements WebMvcConfigurer { @Override public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(new AuthInterceptor()) // 第 1 个 .addPathPatterns("/api/**"); registry.addInterceptor(new LogInterceptor()) // 第 2 个 .addPathPatterns("/api/**"); } } ``` -------------------------------- ### Database Data Initialization Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/spring-to-solon-skill/references/test_advanced_migration.md SQL script for inserting initial data into the 'users' table, usable in both Spring Boot and Solon test environments. ```sql INSERT INTO users (name, email) VALUES ('张三', 'zhangsan@example.com'); INSERT INTO users (name, email) VALUES ('李四', 'lisi@example.com'); ``` -------------------------------- ### YAML Configuration with Variable References Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/solon-development-skill/references/core_concepts.md Demonstrates how to reference other configuration variables using `${...}` syntax in YAML files. Default values can be provided using a colon. ```yaml solon.app.name: "demo" demo.name: "${solon.app.name}" demo.title: "${solon.app.title:}" # default empty demo.description: "${solon.app.name}/${solon.app.title:}" ``` -------------------------------- ### Common Ref Patterns Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/agent-browser/references/snapshot-refs.md Provides examples of common HTML elements and their corresponding ref notations. ```text @e1 [button] "Submit" # Button with text @e2 [input type="email"] # Email input @e3 [input type="password"] # Password input @e4 [a href="/page"] "Link Text" # Anchor link @e5 [select] # Dropdown @e6 [textarea] placeholder="Message" # Text area @e7 [div class="modal"] # Container (when relevant) @e8 [img alt="Logo"] # Image @e9 [checkbox] checked # Checked checkbox @e10 [radio] selected # Selected radio ``` -------------------------------- ### Lifecycle Bean Interface Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/solon-development-skill/references/api_annotations.md Interface for components that require explicit start and stop lifecycle management. ```java class MyLifecycleBean implements LifecycleBean { @Override public void start() { System.out.println("LifecycleBean started"); } @Override public void stop() { System.out.println("LifecycleBean stopped"); } } ``` -------------------------------- ### Spring @CrossOrigin Annotation Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/spring-to-solon-skill/references/web_filter_interceptor_migration.md Example of configuring CORS for a specific controller using the @CrossOrigin annotation in Spring. ```java @RestController @RequestMapping("/api") @CrossOrigin(origins = "http://localhost:3000", methods = {RequestMethod.GET, RequestMethod.POST}, maxAge = 3600) public class ApiController { } ``` -------------------------------- ### Spring Servlet Filter Example Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/spring-to-solon-skill/references/web_filter_interceptor_migration.md Demonstrates a Spring Boot authentication filter that checks for an Authorization header. ```java import org.springframework.web.filter.OncePerRequestFilter; import javax.servlet.*; import javax.servlet.http.*; @Component public class AuthFilter extends OncePerRequestFilter { @Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { String token = request.getHeader("Authorization"); if (token == null || token.isEmpty()) { response.setStatus(401); response.setContentType("application/json;charset=UTF-8"); response.getWriter().write("{"code":401,"message":"未授权"}"); return; } filterChain.doFilter(request, response); } } ``` -------------------------------- ### Nami Client Using Solon Annotations - Basic Mapping Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/solon-development-skill/references/remoting.md Illustrates using Solon annotations like @Post, @Mapping, @Header, and @Cookie to define a Nami client interface. This example maps a POST request to 'hello' with custom headers and cookies. ```java @NamiClient public interface HelloService { @Post @Mapping("hello") String hello(String name, @Header("H1") String h1, @Cookie("C1") String c1); @Consumes(MimeType.APPLICATION_JSON_VALUE) @Mapping("/test01") @Post String test01(@Param("ids") List ids); @Mapping("/test02") @Post String test02(@Param("file") UploadedFile file); @Mapping("/test04/{name}") @Get String test04(@Path("name") String name); } ``` -------------------------------- ### Spring Boot Application Class Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/spring-to-solon-skill/references/ioc_aop_migration.md Example of a typical Spring Boot application class using @SpringBootApplication. ```java package com.example.demo; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; // @SpringBootApplication 包含:@SpringBootConfiguration + @EnableAutoConfiguration + @ComponentScan @SpringBootApplication public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } } ``` -------------------------------- ### Basic Login Flow with agent-browser Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/agent-browser/references/authentication.md Automates a basic login process by opening a URL, waiting for network idle, filling credentials into identified form elements, and submitting the form. Verifies login success by checking the resulting URL. ```bash # Navigate to login page agent-browser open https://app.example.com/login agent-browser wait --load networkidle # Get form elements agent-browser snapshot -i # Output: @e1 [input type="email"], @e2 [input type="password"], @e3 [button] "Sign In" # Fill credentials agent-browser fill @e1 "user@example.com" agent-browser fill @e2 "password123" # Submit agent-browser click @e3 agent-browser wait --load networkidle # Verify login succeeded agent-browser get url # Should be dashboard, not login ``` -------------------------------- ### Spring Global CORS Configuration Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/spring-to-solon-skill/references/web_filter_interceptor_migration.md Example of configuring CORS globally for multiple mappings in Spring using WebMvcConfigurer. ```java @Configuration public class CorsConfig implements WebMvcConfigurer { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/api/**") .allowedOrigins("http://localhost:3000") .allowedMethods("GET", "POST", "PUT", "DELETE") .allowedHeaders("*") .allowCredentials(true) .maxAge(3600); } } ``` -------------------------------- ### Correct Ref Interaction Workflow Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/agent-browser/references/snapshot-refs.md Illustrates the correct sequence of opening a page, taking a snapshot, and then interacting with elements using refs. ```bash # CORRECT agent-browser open https://example.com agent-browser snapshot -i # Get refs first agent-browser click @e1 # Use ref # WRONG agent-browser open https://example.com agent-browser click @e1 # Ref doesn't exist yet! ``` -------------------------------- ### Switch Main Model Runtime Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/solon-development-skill/references/ai_development.md Demonstrates how to switch the main model used by the engine, which automatically rebuilds the main agent. It also shows how to retrieve a specific model by name or the main model if the name is null. ```java // 切换主模型(自动重建主代理) engine.switchMainModel("model-name"); // 按名取模型,空则返回主模型 ChatModel model = engine.getModelOrMain("model-name"); ``` -------------------------------- ### Declarative HttpClient Interface Declaration Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/solon-development-skill/references/remoting.md Example of declaring an interface for a declarative HTTP client using Nami annotations. ```APIDOC ## Nami Declarative HttpClient Nami provides a declarative experience for building HTTP clients. ### Interface Declaration and Usage ```java @NamiClient(url = "http://localhost:8080/ComplexModelService/") public interface IComplexModelService { // POST http://localhost:8080/ComplexModelService/save void save(@NamiBody ComplexModel model); // POST http://localhost:8080/ComplexModelService/read ComplexModel read(Integer modelId); } ``` ### Adjusting Request Method and Path ```java @NamiClient(url = "http://localhost:8080/ComplexModelService/", headers = "TOKEN=xxx") public interface IComplexModelService { // PUT http://localhost:8080/ComplexModelService/save @NamiMapping("PUT") void save(@NamiBody ComplexModel model); // GET http://localhost:8080/ComplexModelService/api/1.0.1?modelId=xxx @NamiMapping("GET api/1.0.1") ComplexModel read(Integer modelId); } ``` ### Injecting the Client ```java @Controller public class Demo { // If no configuration is provided during injection, the annotation configuration from the interface is used. @NamiClient IComplexModelService complexModelService; @Mapping public void test(ComplexModel model) { complexModelService.save(model); } } ``` ``` -------------------------------- ### Solon Cloud Configuration Value Injection (Recommended) Source: https://github.com/opensolon/soloncode/blob/main/soloncode-cli/release/skills/spring-to-solon-skill/references/cloud_discovery_config_migration.md Demonstrates the recommended way in Solon Cloud to inject configuration values, which are automatically updated upon changes. ```java // 方式1:自动注入(推荐) @RestController public class ConfigController { @Inject("${dynamic.value}") private String dynamicValue; // 配置变更时自动更新 } ```