EasyCode Skill
Purpose
This skill turns natural-language requests into deterministic EasyCode-style generation inputs and execution steps.
Use this skill when users ask for:
- - Generating Java code from one or more DB tables
- MyBatisPlus or custom template-group generation
- Reusing previous DB/package/author/template settings
- Auto-mapping
base_package to project output paths
Inputs and Contract
- 1. Normalize the request to
generate_java_code schema in references/function-schema.json. - Require explicit table names.
- Fill missing fields from local state when available.
- If critical DB fields are still missing, ask only for missing items.
- When available, pass
generation_config.table_columns for full field-level rendering parity. - If
table_columns is absent, script attempts JDBC metadata fetch from db_connection.
Workflow
- 1. Parse user intent.
- Load recent state from
.easycode-skill/state.json by running:
-
python3 scripts/easycode_skill.py state --show
- 3. Merge request + state + defaults:
- default
template_group is
Custom-V3.
- default output root is
src/main/java.
- 4. Validate template group against references/template-groups.md.
- Preview output plan:
-
python3 scripts/easycode_skill.py plan --spec '<json>'
- 6. Execute generation:
-
python3 scripts/easycode_skill.py execute --spec '<json>'
- add
--overwrite only when user confirms replacement
- add
--run-project-format to run formatter after generation
- 7. Persist successful config:
-
python3 scripts/easycode_skill.py state --save --spec '<json>'
- 8. Helper commands:
-
python3 scripts/easycode_skill.py check-driver --db-type mysql
-
python3 scripts/easycode_skill.py spec-template --db-type mysql --tables user,order
-
python3 scripts/easycode_skill.py interactive (首次 1~9 步引导,后续仅输入表名)
Generation Rules
- Convert
base_package (for example
com.app.admin) to
src/main/java/com/app/admin.
- Append template-level relative package (for example
entity,
mapper,
service,
controller).
-
MyBatisPlus ->
configs/EasyCodeConfig-mybatispuls.json (fallback project root file)
-
Custom-V2 ->
configs/EasyCodeConfig-V2.json (fallback project root file)
-
Custom-V3 ->
configs/EasyCodeConfig-V3.json (fallback project root file)
- Preferred lookup is
drivers/drivers-paths.json.
- Skill-local jars under
drivers/<db>/ are supported.
- If still missing, pass
db_connection.driver_jar.
- Always show a pre-write file list.
- If file exists, mark as
overwrite_candidate and ask for confirmation before replacing.
Current Renderer Status
- - The script uses a Java Velocity bridge to render template
code with EasyCode global macros (init/define/autoImport/mybatisSupport). - INLINECODE37 writes rendered output (not scaffold), and
plan can include rendered content with --include-content. - If
table_columns is missing, script auto-fetches metadata through JDBC. - When no JDBC driver is found locally, pass
db_connection.driver_jar (and optional db_connection.driver_class) or provide table_columns. - Default JDBC type preferences:
- Number ->
Long
- Time/Date/Timestamp ->
Date
- Override via
generation_config.type_mapping when needed.
- Optional interactive prompt: add
--interactive-type-mapping to
plan/execute when
type_mapping is not specified.
- - Optional project formatter:
- set
generation_config.project_format_command to custom command(s), or
- use
--run-project-format and let script auto-detect
gradlew/mvnw format tasks.
Memory Policy
Persist these keys after successful run:
- -
db_type, url, INLINECODE55 - INLINECODE56 ,
base_package, INLINECODE58 - optional
project_root, INLINECODE60 - interactive mode also persists
pass, driver_jar, driver_class, type_mapping, project_format_command for next-run defaults.
Do not store plaintext password in state. If password must be cached, store encrypted value from host secret manager.
Execution Guidance
- - Prefer deterministic script calls for plan/state actions.
- For actual rendering, use the project’s EasyCode engine implementation when available.
- If engine invocation is unavailable, still provide a complete plan and clearly report blocked execution step.
Response Style
When reporting execution:
- - Show resolved template group
- Show resolved base output directory
- Show generated/updated file count
- Show blocked items (if any) and exact next action
EasyCode 技能
目的
本技能将自然语言请求转化为确定性的 EasyCode 风格生成输入和执行步骤。
当用户提出以下请求时使用本技能:
- - 根据一个或多个数据库表生成 Java 代码
- MyBatisPlus 或自定义模板组生成
- 复用之前的数据库/包名/作者/模板设置
- 自动将 base_package 映射到项目输出路径
输入与约定
- 1. 将请求规范化为 references/function-schema.json 中的 generatejavacode 模式。
- 要求提供明确的表名。
- 当本地状态可用时,填充缺失字段。
- 如果关键数据库字段仍然缺失,仅询问缺失项。
- 当可用时,传递 generationconfig.tablecolumns 以实现完整的字段级渲染一致性。
- 如果缺少 tablecolumns,脚本将尝试从 db_connection 通过 JDBC 元数据获取。
工作流程
- 1. 解析用户意图。
- 通过运行以下命令从 .easycode-skill/state.json 加载最近状态:
- python3 scripts/easycode_skill.py state --show
- 3. 合并请求 + 状态 + 默认值:
- 默认 template_group 为 Custom-V3。
- 默认输出根目录为 src/main/java。
- 4. 根据 references/template-groups.md 验证模板组。
- 预览输出计划:
- python3 scripts/easycode_skill.py plan --spec
- 6. 执行生成:
- python3 scripts/easycode_skill.py execute --spec
- 仅在用户确认替换时添加 --overwrite
- 添加 --run-project-format 以在生成后运行格式化工具
- 7. 持久化成功配置:
- python3 scripts/easycode_skill.py state --save --spec
- 8. 辅助命令:
- python3 scripts/easycode_skill.py check-driver --db-type mysql
- python3 scripts/easycode_skill.py spec-template --db-type mysql --tables user,order
- python3 scripts/easycode_skill.py interactive(首次执行 1~9 步引导,后续仅输入表名)
生成规则
- 将 base_package(例如 com.app.admin)转换为 src/main/java/com/app/admin。
- 追加模板级别的相对包名(例如 entity、mapper、service、controller)。
- MyBatisPlus -> configs/EasyCodeConfig-mybatispuls.json(回退项目根目录文件)
- Custom-V2 -> configs/EasyCodeConfig-V2.json(回退项目根目录文件)
- Custom-V3 -> configs/EasyCodeConfig-V3.json(回退项目根目录文件)
- 首选查找路径为 drivers/drivers-paths.json。
- 支持 drivers// 目录下的技能本地 jar 包。
- 如果仍然缺失,传递 dbconnection.driverjar。
- 始终显示写入前的文件列表。
- 如果文件已存在,标记为 overwrite_candidate 并在替换前请求确认。
当前渲染器状态
- - 脚本使用 Java Velocity 桥接器,通过 EasyCode 全局宏(init/define/autoImport/mybatisSupport)渲染模板 code。
- execute 写入渲染后的输出(而非脚手架),plan 可通过 --include-content 包含渲染内容。
- 如果缺少 tablecolumns,脚本通过 JDBC 自动获取元数据。
- 当本地未找到 JDBC 驱动时,传递 dbconnection.driverjar(以及可选的 dbconnection.driverclass)或提供 tablecolumns。
- 默认 JDBC 类型偏好:
- Number -> Long
- Time/Date/Timestamp -> Date
- 需要时通过 generationconfig.typemapping 覆盖。
- 可选的交互式提示:当未指定 type_mapping 时,在 plan/execute 中添加 --interactive-type-mapping。
- 将 generationconfig.projectformat_command 设置为自定义命令,或
- 使用 --run-project-format 让脚本自动检测 gradlew/mvnw 格式化任务。
记忆策略
成功运行后持久化以下键:
- - dbtype、url、user
- author、basepackage、templategroup
- 可选的 projectroot、outputroot
- 交互模式还会持久化 pass、driverjar、driverclass、typemapping、projectformatcommand 作为下次运行的默认值。
不要在状态中存储明文密码。如果必须缓存密码,请存储来自主机密钥管理器的加密值。
执行指南
- - 对于计划/状态操作,优先使用确定性的脚本调用。
- 对于实际渲染,尽可能使用项目的 EasyCode 引擎实现。
- 如果引擎调用不可用,仍需提供完整的计划并清晰报告被阻塞的执行步骤。
响应风格
报告执行结果时:
- - 显示解析后的模板组
- 显示解析后的基础输出目录
- 显示生成/更新的文件数量
- 显示被阻塞的项目(如有)以及确切的下一步操作