提供 tinystruct Java 框架开发指导,覆盖路由、测试、持久化与服务端能力。
复制安装指令,让 AI 自动完成配置 · 推荐新手
请帮我安装 askskill 上的 "tinystruct-patterns" 技能: 1. 下载 https://raw.githubusercontent.com/affaan-m/ECC/main/skills/tinystruct-patterns/SKILL.md 2. 保存为 ~/.claude/skills/tinystruct-patterns/SKILL.md 3. 装好后重载技能,告诉我可以用了
请基于 tinystruct 演示如何创建一个 Application 类,并定义两个使用 @Action 映射的路由:GET /health 和 POST /users。请给出完整 Java 示例,并说明 ActionRegistry 需要如何注册。
返回可运行的 tinystruct 应用骨架代码,包含 Application、Action 路由实现与注册说明。
我有一个 tinystruct 的 Action,用于处理用户创建请求。请帮我设计单元测试方案,包含成功、参数缺失、JSON 格式错误三种场景,并给出测试代码示例。
返回针对 tinystruct Action 的测试思路与示例代码,覆盖正常与异常分支。
请用 tinystruct 说明如何基于 AbstractData 定义一个 User 实体,完成保存与查询,并在用户创建后触发事件,再通过 SSE 将结果推送给前端。请给出关键代码结构。
返回结合 AbstractData、事件系统与 SSE 的实现方案和核心代码示例。
Architecture and implementation patterns for building modules with the tinystruct Java framework – a lightweight, high-performance framework that treats CLI and HTTP as equal citizens, requiring no main() method and minimal configuration.
CLI and HTTP are equal citizens. Every method annotated with @Action should ideally be runnable from both a terminal and a web browser without modification. This "dual-mode" capability is the core design philosophy of tinystruct.
Application modules by extending AbstractApplication.@Action.Context.Builder and Builders components.AbstractData POJOs.generate command.URLRequest and HTTPHandler.application.properties.The tinystruct framework treats any method annotated with @Action as a routable endpoint for both terminal and web environments. Applications are created by extending AbstractApplication, which provides core lifecycle hooks like init() and access to the request Context.
Routing is handled by the ActionRegistry, which automatically maps path segments to method arguments and injects dependencies. For data-only services, the native Builder and Builders components should be used for JSON serialization to maintain a zero-dependency footprint. The database layer uses AbstractData POJOs paired with XML mapping files for CRUD operations without external ORM libraries.
public class MyService extends AbstractApplication {
@Override
public void init() {
this.setTemplateRequired(false); // Disable .view lookup for data/API apps
}
@Override public String version() { return "1.0.0"; }
@Action("greet")
public String greet() {
return "Hello from tinystruct!";
}
// Path parameter: GET /?q=greet/James OR bin/dispatcher greet/James
@Action("greet")
public String greet(String name) {
return "Hello, " + name + "!";
}
}
@Action(value = "login", mode = Mode.HTTP_POST)
public String doLogin(Request<?, ?> request) throws ApplicationException {
request.getSession().setAttribute("userId", "42");
return "Logged in";
}
import org.tinystruct.data.component.Builder;
import org.tinystruct.data.component.Builders;
@Action("api/data")
public String getData() throws ApplicationException {
Builders dataList = new Builders();
Builder item = new Builder();
item.put("id", 1);
item.put("name", "James");
dataList.add(item);
Builder response = new Builder();
response.put("status", "success");
response.put("data", dataList);
return response.toString(); // {"status":"success","data":[{"id":1,"name":"James"}]}
}
import org.tinystruct.http.SSEPushManager;
@Action("sse/connect")
public String connect() {
return "{\"type\":\"connect\",\"message\":\"Connected to SSE\"}";
}
// Push to a specific client
String sessionId = getContext().getId();
Builder msg = new Builder();
msg.put("text", "Hello, user!");
SSEPushManager.getInstance().push(sessionId, msg);
// Broadcast to all
// Broadcast to all
SSEPushManager.getInstance().broadcast(msg);
import org.tinystruct.data.FileEntity;
…
帮助用户智能挖掘高价值潜在客户并生成多渠道触达方案
帮助开发者使用 Bun 进行运行、打包、测试与依赖管理,并评估替代 Node 的时机。
为 Quarkus 项目执行发布前验证闭环,涵盖构建、测试、扫描与差异审查。
帮助你检索和更新 Jira 工单,分析需求并高效推进协作流程
在每次编辑代码时自动格式化、检查并智能修复质量问题
帮助开发者掌握地道 Rust 模式、所有权、并发与错误处理实践
帮助开发者构建含生命周期管理、WebSocket与SSE的 HTTP 服务模式
通过四个示例工具演示 MCP 服务的参数设计、结构化输出与错误处理
连接 Tiny ERP 数据,查询与管理商品、库存、订单及应收应付信息。
帮助开发者用 Node/TypeScript 快速构建符合规范的 MCP 服务器与工具能力
提供 FastAPI 项目结构、鉴权、事务分层与测试的最佳实践指导
为多智能体协作提供轻量任务管理,支持任务流转、依赖与评论追踪。