Agent Skills › espressif/esp-claw › lua_package_authoring

lua_package_authoring

GitHub

用于为运行时 Skill 或启动器 App 编写、更新和验证捆绑的 Lua 脚本,确保模块引用正确、路径安全及资源合规。

components/common/lua_module_builder/skills/lua_package_authoring/SKILL.md espressif/esp-claw

触发场景

需要创建或更新嵌入在 Skill 或 App 中的 Lua 脚本 编写符合设备固件限制的 Lua 模块逻辑

安装

npx skills add espressif/esp-claw --skill lua_package_authoring -g -y
更多选项

非标准路径

npx skills add https://github.com/espressif/esp-claw/tree/master/components/common/lua_module_builder/skills/lua_package_authoring -g -y

不安装直接使用

npx skills use espressif/esp-claw@lua_package_authoring

指定 Agent (Claude Code)

npx skills add espressif/esp-claw --skill lua_package_authoring -a claude-code -g -y

安装 repo 全部 skill

npx skills add espressif/esp-claw --all -g -y

预览 repo 内 skill

npx skills add espressif/esp-claw --list

SKILL.md

Frontmatter
{
    "name": "lua_package_authoring",
    "metadata": {
        "cap_groups": [
            "cap_files",
            "cap_lua"
        ]
    },
    "description": "Author or update Lua scripts bundled in an explicitly requested runtime Skill or launcher App; use with the owning creator, not for running existing packages or adding native firmware capabilities."
}

Lua Package Authoring

Use this skill when skill_creator or app_creator needs new or updated bundled Lua scripts. The owning creator controls the package directory, manifest or Skill definition, update scope, removal, and publication. This skill must not call publish_skill, remove_skill, publish_app, or remove_app.

Lua can only compose modules and capabilities already compiled into the device. If the requested behavior needs a missing driver, native capability, Kconfig option, or firmware component, return that limitation to the owning creator instead of fabricating an API.

Authoring Flow

  1. Use the package kind, id, and absolute target directory resolved by the owning creator.
  2. Activate builtin_lua_modules and read the documentation for every module the implementation will import.
  3. Read a nearby bundled test only when it provides a relevant API or resource-lifecycle example.
  4. Write the smallest complete set of scripts. A package may own one or more scripts; do not force unrelated actions into one file.
  5. Read the completed files back and verify imports, documented APIs, arguments, package-local paths, cleanup, and expected output.
  6. Return control to the owning creator for package verification and publication.

Do not infer undocumented functions from module names or test code from a different module.

Package Paths

For a runtime Skill:

  • Store scripts under <SKILLS_ROOT>/<skill_id>/scripts/.
  • Reference them from SKILL.md with {CUR_SKILL_DIR}/scripts/<file>.lua.
  • Do not reference files owned by an App or another Skill.
  • Document synchronous or asynchronous tool execution as described below.

For a launcher App:

  • Store scripts under <APPS_ROOT>/<app_id>/scripts/.
  • Keep the launcher.json entry package-relative, such as scripts/main.lua.
  • The runtime prepends the running script directory to package.path, so package-local Lua modules beside the entry script can be loaded with require("module_name").
  • Derive asset paths from the running script path, for example with debug.getinfo(1, "S").source, and then resolve the App directory. Do not hard-code /system, /fatfs, or an SD mount point.
  • Do not reference files owned by a Skill or another App.

For writable user data, use storage.get_root_dir() with storage.join_path(...). Reject unsafe user-controlled path fragments, addresses, GPIOs, sizes, and other resource identifiers before use. Reuse stable filenames during updates instead of creating numbered variants.

Arguments And Results

  • Runtime exposes the package arguments as the global args object.
  • Use arg_schema when typed defaults or validation materially improve correctness.
  • Keep output concise and predictable enough for the caller or launcher log to interpret.
  • At a critical failure point, print a short contextual error and return or raise the actual error.
  • Do not hide partial failure or report success before the operation completes.

Resource Safety

  • Acquire hardware, files, sockets, screens, and other resources as late as practical and release every acquired resource.
  • Add protected execution and cleanup only when resources must be released on failure; do not add empty cleanup scaffolding.
  • Never busy-wait. Use the documented delay module for timed loops.
  • Keep async log volume bounded and make cancellation leave owned hardware in a safe state.

Runtime Skill Execution

Use lua_run_script for bounded Skill work whose result is needed in the current turn. Its input contains the absolute bundled .lua path, an optional object args, and an optional positive timeout_ms; omitting the timeout uses the 60000 ms default. Do not pass zero.

Use lua_run_script_async for loops, monitors, animations, games, display holds, or Skill work that must outlive the current tool call. Give long-running jobs a stable name. Use exclusive for singleton hardware such as display or audio. Use replace:true only when the user explicitly wants to replace a conflicting job.

  • An omitted or zero async timeout_ms runs until cancelled.
  • At most four async Lua jobs run concurrently.
  • Active jobs with the same name or non-empty exclusive group conflict.
  • log_bytes defaults to 4096 and accepts 1024–16384. Increase it only for useful bounded progress logs.

Document only the execution details that affect each Skill script: path, arguments, execution mode, non-default job policy, success result, and meaningful failure output. Use lua_get_async_job for a status snapshot and lua_tail_async_job with the previous log_next_seq for incremental logs.

Launcher App Execution

The launcher executes an App entry asynchronously with the manifest args. The App creator owns the launcher contract; do not add lua_run_script instructions to the App package. Do not start a long-lived App merely to validate its package.

Verification And Failure Handling

Do not execute a script merely as a syntax check when it could mutate files, contact a network service, operate hardware, or take over the display. Run it only when validation is safe and within the user's request.

Report script errors accurately. Retry only when the failure is understood, the retry is safe, and the corrected input still matches the user's request. Do not silently change user-provided arguments, replace a running job, or execute another script as a fallback.

版本历史

  • 36b377f 当前 2026-11-02 21:37

同 Skill 集合

components/claw_capabilities/cap_app_mgr/skills/app_creator/SKILL.md
components/claw_capabilities/cap_http_request/skills/cap_http_request/SKILL.md
components/claw_capabilities/cap_im_platform/skills/cap_im_platform/SKILL.md
components/claw_capabilities/cap_router_mgr/skills/cap_router_mgr/SKILL.md
components/claw_capabilities/cap_scheduler/skills/cap_scheduler/SKILL.md
components/claw_capabilities/cap_skill_mgr/skills/skills_lab_downloader/SKILL.md
components/claw_capabilities/cap_skill_mgr/skills/skills_lab_search/SKILL.md
components/claw_capabilities/cap_web_search/skills/cap_web_search/SKILL.md
components/claw_modules/claw_memory/skills/memory_ops/SKILL.md
components/claw_modules/claw_memory/skills/profile_memory_ops/SKILL.md
components/common/skill_builder/skills/skill_creator/SKILL.md
components/common/skill_builder/skills/skills_lab_downloader/SKILL.md
components/common/skill_builder/skills/skills_lab_search/SKILL.md
components/lua_modules/lua_driver_touch/skills/read_touch/SKILL.md
components/lua_modules/lua_module_ble_hid/skills/ble_hid/SKILL.md
components/lua_modules/lua_module_ble/skills/ble/SKILL.md
components/lua_modules/lua_module_camera/skills/take_picture/SKILL.md
components/lua_modules/lua_module_display/skills/bdf_font_converter/SKILL.md
components/lua_modules/lua_module_http_server/skills/http_server_lua_demo/SKILL.md
components/claw_capabilities/cap_llm_inspect/skills/cap_llm_inspect_image/SKILL.md

元信息

文件数
0
版本
36b377f
Hash
f7559930
收录时间
2026-11-02 21:37

首页 - Wiki
Copyright © 2011-2026 iteam. Current version is 2.156.0. UTC+08:00, 2026-11-06 22:21
浙ICP备14020137号-1