提供 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;
…
帮助开发者落实 Django 安全最佳实践,构建更安全的认证、授权与部署方案。
扫描多项技能并提炼通用规则,自动追加、修订或新建规则文件。
提供面向生产后端的 MySQL 与 MariaDB 设计、查询与运维模式建议。
帮助你判断解析结构化文本时何时用正则、何时引入大模型兜底。
用于 Laravel 项目的环境检查、测试、安全扫描与发布验收
提供地道 Kotlin 模式与最佳实践,帮助构建健壮高效且易维护的应用。
连接 Tiny ERP,统一查询和处理商品、库存、订单与应收应付数据
帮助用户进行 JSON 的生成、校验、格式化与结构化处理。
通过四个示例工具演示 MCP 服务的参数设计、结构化输出与错误处理
帮助开发者用 Node/TypeScript 快速构建符合规范的 MCP 服务器与工具能力
提供 FastAPI 项目结构、鉴权、事务分层与测试的最佳实践指导
帮助开发者系统学习 Spring AI 与 MCP,构建智能体与大模型应用项目。