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
- License 许可
- MIT
- 最近更新
- 2026-10-13
- Stars
- ★ 48
- Forks
- 3
01 前言 Front Matter
- name
- create-adaptater
- description
- 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
03 SKILL.md 正文
Create an Adaptater
Define, register, and verify an adaptater — a JS data-transformation step that workflows run between actions and agents (normalize CLI args, reshape the shared context, prepare prompt for agent steps).
Workflow
- Ensure a registered features directory (first time only) — edit the conf file to add your
features/root path, then runlm conf. Adaptaters are discovered from theadaptaters/subdirectory of each registered path (same mechanism as agents/actions/workflows). - Write the adaptater file — create
<name>.jsinfeatures/adaptaters/; the filename without extension becomes the adaptater name..jsis the only supported extension. The file must be an ESM module exporting an asyncaction(args, options)function (see Format). - Register — run
lm update. Feature discovery upserts the adaptater into theadaptatertable. No ToolSpec is created: unlike actions, adaptaters have no# tooldocblock and cannot be called directly by agents. - (Optional) Wire it into a workflow — add
- adaptater: <name>tosteps:in a workflow YAML (typically step 1, or between two steps whose data formats don't match), then runlm updateagain. - Verify:
lm updateoutput shows+ [adaptater] <name> <path>for the new file.- Run the workflow:
lm <workflow> [args...] --debug— each step prints as it runs; if the adaptater is the final step, its result is printed to stdout.
Format
ESM module exporting an async action(args, options) function:
// features/adaptaters/prequery.js
async function action(params, options) {
const prompt = Array.isArray(params) ? params.join(" ") : params.prompt;
return { prompt };
}
export { action };
args(first param): string array when the adaptater is step 1 of a workflow (raw CLI args; piped/clipboard/file input may be appended to the array), or the tool arguments object when the workflow is called as an agent tool; for later steps it is the whole accumulated context object. Handle both shapes.options: run flags —debug,verbose,isToolCallwhen called through an agent tool call.- Return value: an object has its keys merged into the shared workflow context (existing context keys win); a string/array lands in
context.args.
Example
Goal: a workflow that takes CLI args and feeds them as prompt to an agent.
# features/workflows/q.yml
steps:
- adaptater: prequery # ["list", "planets"] -> { prompt: "list planets" }
- agent: infer # picks up prompt from context
// features/adaptaters/prequery.js
async function action(params, options) {
const prompt = Array.isArray(params) ? params.join(" ") : params.prompt;
return { prompt };
}
export { action };
lm q list the planets of the solar system ≡ lm infer "list the planets of the solar system".
Gotchas
- Only
.jsfiles are discovered —.py/.ymlinadaptaters/are silently ignored (unlike actions, which support .yml/.js/.py). - The module must export exactly
action— the executor dynamically imports the file and calls the exportedaction; a different export name fails only at run time with a wrapped "executing js action: ..." error, not at registration. - No
# tooldocblock, no ToolSpec — adaptaters cannot be called directly by agents; they exist only as workflow steps. Do not copy the action docblock pattern from the create-action skill. - No CLI alias —
lm <adaptater-name>does not work (aliases are created only for agents/actions/workflows); verify through a workflow step or programmatically. - Context keys cannot be overwritten — object results merge as
{ ...result, ...context }, so returned keys that already exist in the context are dropped; choose distinct key names (promptto feed an agent step). - Step 1 sees raw CLI args as an array, not an object — normalize in the adaptater (e.g.
params.join(" ")); later steps see the accumulated context object. - Fail loudly — throw on bad input, or return
{ error: ... }; the executor throws a returned error and wraps thrown exceptions asadaptater <name>: <e>. - Every change requires
lm update— new/edited adaptaters or workflow step lists are not picked up until re-registration.
References (load when needed)
- Adaptater executor (dynamic import,
actioncall, error wrapping):agent-smith/packages/core/src/adaptaters/cmd.ts - Workflow step dispatch + context merge (how an adaptater result flows to the next step):
agent-smith/packages/core/src/workflows/cmd.ts - Feature discovery (
adaptaters/dir scan,.jsonly,adaptatertable, no CLI alias):agent-smith/docsite/public/doc/libraries/core/3.feature-discovery.md - User-facing doc with the prequery example:
agent-smith/docsite/public/doc/terminal_client/7.workflows.md
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-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
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