packages/cli/SKILL.md
@hile/cli 的强约束生成规范。适用于 boot 编排、启动流程、容器事件日志与退出阶段管理。
npx skillsauth add cevio/hile hile-cliInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
本文档面向代码生成器与维护者,强调“可执行约束”,而非入门说明。
hile.auto_load_packages 只允许模块名,禁止文件路径。src/services/ 下 *.boot.* 与 *.service.* 同属 service 模块(均 defineService);.boot = CLI 自启动,.service = loadService 依赖加载。*.boot.ts / *.boot.js 必须位于 src/services/(如 src/services/index.boot.ts),禁止放在 src/ 根目录。*.service.ts / *.service.js(依赖加载的 service 模块)必须同放在 src/services/。export default 合法 Hile 服务(defineService / register 结果)。auto_load_packages → 扫描 boot。HILE_RUNTIME_DIR → src(dev) → dist。container.on 并输出关键生命周期日志。registerExitHook(offEvent) 注册退出钩子;实现内对 @hile/core 的全局 container 调用 await container.shutdown(),仅在其完成后(含 TTY 下对 process.stdin.unref() 的收尾)在 finally 中执行 offEvent() 与 exit();shutdown 未完成时进程挂起不退出(受 forceExitTimeout 上限保护)。最小事件集:
service:initservice:readyservice:errorservice:shutdown:startservice:shutdown:doneservice:shutdown:errorcontainer:shutdown:startcontainer:shutdown:donecontainer:error要求:
[hile],目标与状态自然拼接durationMs),如 ready (12ms)// ✗ 不要在 CLI 内自建另一套生命周期/依赖管理
// ✓ 复用 @hile/core 的 onEvent、shutdown、resolve 语义
// ✗
export default function main() {}
// ✓
export default defineService('http', async (shutdown) => {
// ...
})
// ✗ 只订阅不释放
const off = container.on(listener)
// ✓ 退出时在 registerExitHook 的 finally 中调用 off()
// ✗ 直接 exit 不关闭容器
exitHook(exit => exit())
// ✓ 使用 registerExitHook(offEvent),内部 await container.shutdown() 再 exit
no services to load 并退出--dev 与非 dev 的 NODE_ENV 行为一致--env-file 加载顺序可预测exit() 仅在 container.shutdown() 完成后调用;shutdown 未完成时进程挂起(见 exitHook 单测)process.stdin 调用 unref(),避免 stdin 拖住进程退出devops
@hile/model: defineModel/loadModel 定义和消费模型;services 依赖注入;pipeline 中间件链;每次 loadModel 重新执行 main
development
Code generation and contribution rules for @hile/micro-dynamic-configs. Use when editing this package or when the user asks about dynamic config patterns or API.
development
Code generation and contribution rules for @hile/cache. Use when editing this package or when the user asks about @hile/cache API, types, patterns, or features.
development
Code generation and contribution rules for @hile/micro. Use when editing this package or when the user asks about @hile/micro API, types, patterns, or features.