create-action
use when asked to create, define, or modify an action in Agent Smith - writes the .js/.py/.yml file in features/actions/, adds the
- License 许可
- MIT
- 最近更新
- 2026-10-13
- Stars
- ★ 48
- Forks
- 3
01 前言 Front Matter
- name
- create-action
- description
- use when asked to create, define, or modify an action in Agent Smith - writes the .js/.py/.yml file in features/actions/, adds the
03 SKILL.md 正文
Create an Action
Define, register, and verify an action — a unit of work (JS/Python code or a wrapped shell command) that workflows and agents can call.
Workflow
- Ensure a registered features directory (first time only) — edit the conf file to add your
features/root path, then runlm conf. Actions are discovered from theactions/subdirectory of each registered path (same mechanism as agents/workflows). - Write the action file — create
<name>.jsinfeatures/actions/(default), or.pyfor a Python script /.ymlto wrap a shell command. The filename without extension becomes the action name. - Expose it as an agent tool — add a
# tooldocblock at the very top of the file (see Tool docblock). Without it the action still runs from workflows, but agents cannot call it. - Register — run
lm update. Discovery upserts the action into theactiontable; with a docblock it also upserts a ToolSpec into thetooltable. - (Optional) Give it to an agent — add the action name to the agent's
toolsList, then runlm updateagain. - Verify:
lm updateoutput lists- actions: <name>(and- tools: <name>when exposed).- Run it through a one-step workflow (
steps: [- action: <name>]) withlm <workflow> [args...], or call it from an agent that has it in itstoolsList.
Formats
JavaScript (.js) — default
ESM module exporting an async action(args, options) function. The docblock (first comment in the file) declares the tool interface:
/*
# tool
name: traffic
description: Get the current road traffic conditions
arguments:
city:
description: The city or location, e.g. San Francisco, CA
required: true
*/
async function action(args, options) {
const city = Array.isArray(args) ? args[0] : args.city;
return { traffic: "normal", city };
}
export { action }
argsshape depends on the caller: string array (CLI / first workflow step), tool arguments object with the docblock's keys (agent tool call), or the workflow context object (later steps) — handle both.optionscarries run flags:debug,verbose,isToolCallwhen called by an agent.- Return a string or object; in workflows an object's keys are merged into the shared context.
- To run shell commands from JS use
utils.execute(cmd, args)—import { utils } from "@agent-smith/core"(seegit_diff.jsexample).
YAML (.yml) — wrap a system command
# features/actions/ocr.yml
tool:
name: ocr
description: Run OCR on an image file
arguments:
path:
description: Path to the image file
required: true
cmd: /home/me/app/.venv/bin/python
args:
- "/home/me/app/ocr.py"
cmdplus optional staticargs(all strings); runtime args are appended after them, positionally.- Result is the trimmed stdout string of the command.
Python (.py)
Plain script run with python3; arguments arrive in sys.argv[1:]:
"""
# tool
name: weather
description: Get the current weather
arguments:
city:
description: The city or location, e.g. San Francisco, CA
required: true
"""
import sys
print(f'{{"temp": 18, "city": "{sys.argv[1]}"}}')
Result is the printed stdout as a string.
Tool docblock
The docblock is what makes an action callable by agents; it defines the ToolSpec (name, description, arguments) that other agents see.
- JS: file must start with
/*on line 1 and# toolon line 2; content up to the closing*/is parsed as YAML. - Python: same, but the opening marker is a triple-quote docstring (
"""on line 1). - YAML: a top-level
tool:section instead of a comment. - Fields:
name(overridden by the filename — keep it for documentation),description,arguments(map of arg name →{ description, required }).
Gotchas
- The docblock must be the first bytes of the file — the parser checks the file starts with
/*\n# tool(JS) or"""\n# tool(Python). An import, shebang, or comment before it silently disables tool registration: the action still works from workflows, but agents get "tool <name> not found for agent ...". - Docblock content is parsed as YAML — write
key: valueand nested maps, not JS/JSON object syntax. - The docblock
nameis overridden by the filename — renaming the file renames the tool and breaks every agenttoolsListreferencing it. - Python actions return raw stdout string — printing JSON does not make it structured; if a later workflow step needs keys, use a JS action or an adaptater that parses the output.
- YAML action args are all strings, appended after static
args:— design the wrapped command to accept them positionally; only trimmed stdout becomes the result (stderr is lost). - JS actions must export exactly
action(async function) as ESM — the module is dynamically imported and called at run time; a different export name fails only when the action runs, not at registration. - Every change requires
lm update— new files, edited docblocks, or newtoolsListreferences are not picked up until re-registration. - Do not verify with
lm <action-name>— actions are not standalone CLI commands in the current CLI; run them through a workflow step or an agent tool call.
References (load when needed)
- Action executor (extension dispatch, args handling per format):
agent-smith/packages/core/src/actions/cmd.ts - Tool docblock parser (
# toolmarkers, YAML parsing, name override):agent-smith/packages/core/src/tools.ts - Feature discovery (scans
actions/for .yml/.js/.py, table registration):agent-smith/docsite/public/doc/libraries/core/3.feature-discovery.md - User-facing action doc:
agent-smith/docsite/public/doc/terminal_client/6.actions.md - Real examples:
agent-smith/examples/features/actions/traffic.js,agent-smith/examples/features/actions/weather.py,agent-smith-plugins/code/git/dist/actions/git_diff.js
04 同仓库更多 Skills
create-workflow
use when asked to create, define, or modify a workflow in Agent Smith - writes the .yml file in features/workflows/, chains actions/agents/adaptaters/commands, registers it with lm update so it runs as `lm <name>` and can be exposed as an agent tool
create-agent
use when asked to create, define, or modify an agent in YAML for Agent Smith, optionally exposes it as a subagent tool
create-adaptater
use when asked to create, define, or modify an adaptater (adapter) in Agent Smith - writes the .js file in features/adaptaters/, registers it with lm update so workflows can use it as a data transformation step between actions and agents
update-doc-map
read this only when instructed to update the documentation map
document-agent-smith-package
use when asked to create or update package documentation in the docsite