配置拉取代码生成
生成配置拉取代码模板。用于在 Android 项目中接入配置中心、白名单、单独接口或推拉结合的配置。 触发条件:用户想要创建配置拉取功能,需要生成对应的 Kotlin/Java 代码模板。
MIT-0 · Free to use, modify, and redistribute. No attribution required.
⭐ 0 · 29 · 0 current installs · 0 all-time installs
MIT-0
Security Scan
OpenClaw
Benign
high confidencePurpose & Capability
Name/description (generate Android Kotlin/Java templates for config pull) matches the contents: templates for config center, whitelist, single API, and push-pull integration are provided, and the instructions focus on generating code and plugin hooks for modules. Required capabilities (none) are proportional to the task.
Instruction Scope
SKILL.md instructs the agent to interactively collect configuration details from the user and to generate code files in the workspace at specified module paths. It does not instruct reading system files, env vars, or external endpoints. Note: generated templates include use of project-side symbols (e.g., SecurityKey.clientId / clientSecret) and placeholders for API URLs/push keys; the skill itself does not read or exfiltrate those values, but the generated code will reference them at runtime in the target project and may include arbitrary API endpoints supplied by the user.
Install Mechanism
No install spec and no code files that execute on the host — instruction-only skill. This is low-risk from installation standpoint.
Credentials
The skill declares no required environment variables, binaries, or credentials. Templates reference project-level secrets (SecurityKey.clientId/Secret) as part of generated code, but the skill does not request access to those secrets.
Persistence & Privilege
always:false and no attempt to modify other skills or system config. The skill requires writing generated files into the agent workspace (explicitly mandated). Writing to the workspace is expected for a code generator but is a privileged action — users should confirm generated changes before committing them.
Assessment
This skill is coherent for generating Android config-pull code templates and does not ask for credentials or install anything. Before running: 1) Be prepared that the skill will write files into your agent workspace — review and approve generated files before committing. 2) Pay attention to any API URLs, push keys, or SecurityKey references you supply; the generated code will include them and they may cause the app to contact external services at runtime. 3) Run the generator in a development branch or sandbox and inspect outputs for hard-coded secrets or unexpected endpoints. If you need the generator to avoid writing files automatically, ask it to only show the code instead of writing to workspace.Like a lobster shell, security has layers — review code before you run it.
Current versionv1.0.2
Download ziplatest
License
MIT-0
Free to use, modify, and redistribute. No attribution required.
SKILL.md
配置拉取代码生成
根据用户提供的配置信息,生成对应的代码模板。
交互流程
第一步:询问配置作用
向用户确认:这个配置的作用是什么? 例如:ANR 监控配置、服务费配置、活动配置等。
第二步:确认接入方式
让用户选择接入方式:
-
配置中心 - 需要提供:
- 配置中心组件 Key(如
com.youzan.retailHD.anr) - 字段 Key(如
config) - 模板 Value(JSON 字符串,可选)
- 配置中心组件 Key(如
-
白名单 - 需要提供:
- 白名单 Key(如
anr_feature)
- 白名单 Key(如
-
单独接口 - 需要提供:
- 接口 URL(如
youzan.retail.trade.misc.shopsetting.query/1.0.0)
- 接口 URL(如
-
推拉结合 - 需要提供:
- 推送 Key
- 拉取接口 URL
第三步:确认所属模块
让用户选择配置所属模块:
- 商品模块(module_goods)
- 营销模块(module_marketing)
- 其他模块
代码生成规则
通用规则
- 代码优先使用 Kotlin 编写
- 数据模型如果跟网络相关需要添加
@Keep注解 - 生成代码后,必须写入到 workspace 对应文件,并展示给用户看
白名单接入
生成 WhiteListManager(如果已存在则复用):
object WhiteListManager {
fun is{Feature}Enabled() {
WhiteListTask.isInWhiteList("{key}").subscribe({ result ->
// TODO 待实现
}, { error ->
// TODO 待实现
})
}
}
生成 Plugin 钩子(方法名必须与注解名一致!)
在对应模块的 PluginModule 中添加三个方法:
// 文件位置:/modules/module_xxx/src/common/java/com/youzan/retail/xxx/PluginModule.kt
@ShopSwitched
fun onShopSwitched() {
WhiteListManager.is{Feature}Enabled()
}
@AppStart
fun onAppStart() {
WhiteListManager.is{Feature}Enabled()
}
@ConfigFetch
fun onConfigFetch() {
WhiteListManager.is{Feature}Enabled()
}
配置中心
根据模块 + 作用,在对应模块的 common 下创建 XXXConfigManager 类:
- 路径:
/modules/module_xxx/src/common/java/com/youzan/retail/xxx/ CONFIG_KEY_CONFIG_VERSION固定为1.0.0- 如果提供了模板 JSON,需要生成对应的配置类(使用
@Keep注解)
同时生成 Plugin 钩子(方法名必须与注解名一致!):
@ShopSwitched
fun onShopSwitched() {
{Name}ConfigManager.init()
}
@AppStart
fun onAppStart() {
{Name}ConfigManager.init()
}
@ConfigFetch
fun onConfigFetch() {
{Name}ConfigManager.init()
}
单独接口
在对应模块的 common 下创建:
XXXConfigManager- 业务逻辑XXXTask- Task 层XXXService- Service 接口(包含 @POST 注解和 URL)
同时生成 Plugin 钩子(方法名必须与注解名一致!):
@ShopSwitched
fun onShopSwitched() {
{Name}ConfigManager.query{Name}Config()
}
@AppStart
fun onAppStart() {
{Name}ConfigManager.query{Name}Config()
}
@ConfigFetch
fun onConfigFetch() {
{Name}ConfigManager.query{Name}Config()
}
推拉结合
在对应模块的 common 下创建 XXXRefreshUtils 类,内部实现 IConfigDataNotification 接口注册推送通知。
同时生成 Plugin 钩子(方法名必须与注解名一致!):
@ShopSwitched
fun onShopSwitched() {
{Name}RefreshUtils.register{Name}Notification()
{Name}ConfigManager.query{Name}Config()
}
@AppStart
fun onAppStart() {
{Name}RefreshUtils.register{Name}Notification()
{Name}ConfigManager.query{Name}Config()
}
@ConfigFetch
fun onConfigFetch() {
{Name}ConfigManager.query{Name}Config()
}
Plugin 钩子说明
配置拉取的调用时机通过 Plugin 实现。不同模块的 Plugin 位置:
- 商品模块:
modules/module_goods/src/common/java/com/youzan/retail/goods/PluginModule.kt - 营销模块:
modules/module_marketing/src/common/java/com/youzan/retail/marketing/PluginModule.kt
可用的注解:
@ShopSwitched- 店铺切换时调用@AppStart- 应用启动时调用@ConfigFetch- 配置同步时调用
重要规则:
- 每次生成配置时,必须同时生成这三个 Plugin 钩子方法!
- 方法名必须与注解名一致:
@ShopSwitched→onShopSwitched(),@AppStart→onAppStart(),@ConfigFetch→onConfigFetch() - 生成代码后,必须写入到 workspace 对应文件
Files
5 totalSelect a file
Select a file to preview.
Comments
Loading comments…
