cli-anything-openclaw
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseOpenClaw Macro System CLI
OpenClaw Macro System CLI
What It Is
是什么
The OpenClaw Macro System converts valuable GUI workflows into parameterized,
CLI-callable macros. Agents never touch the GUI directly — they call macros
through this stable CLI, and the runtime routes execution to the best available
backend (native plugin/API, file transformation, semantic UI control, or
precompiled GUI macro replay).
OpenClaw Macro System可将有价值的GUI工作流转换为可参数化、可通过CLI调用的宏。Agent绝不会直接操作GUI——它们通过这个稳定的CLI调用宏,运行时会将执行路由到最佳可用后端(原生插件/API、文件转换、语义UI控制或预编译的GUI宏重放)。
Installation
安装
bash
cd openclaw-skill/agent-harness
pip install -e .Requirements: Python 3.10+, PyYAML, click, prompt-toolkit.
bash
cd openclaw-skill/agent-harness
pip install -e .要求: Python 3.10+、PyYAML、click、prompt-toolkit。
Quick Start (for agents)
快速入门(面向Agent)
bash
undefinedbash
undefined1. See what macros are available
1. 查看可用的宏
cli-anything-openclaw macro list --json
cli-anything-openclaw macro list --json
2. Inspect a macro's parameters
2. 查看宏的参数
cli-anything-openclaw macro info export_file --json
cli-anything-openclaw macro info export_file --json
3. Dry-run to check params without side effects
3. 空运行以检查参数,无副作用
cli-anything-openclaw --dry-run macro run export_file
--param output=/tmp/test.txt --json
--param output=/tmp/test.txt --json
cli-anything-openclaw --dry-run macro run export_file
--param output=/tmp/test.txt --json
--param output=/tmp/test.txt --json
4. Execute a macro
4. 执行宏
cli-anything-openclaw macro run export_file
--param output=/tmp/result.txt --json
--param output=/tmp/result.txt --json
cli-anything-openclaw macro run export_file
--param output=/tmp/result.txt --json
--param output=/tmp/result.txt --json
5. See what backends are available
5. 查看可用的后端
cli-anything-openclaw backends --json
undefinedcli-anything-openclaw backends --json
undefinedCommand Reference
命令参考
Global Flags
全局标志
| Flag | Description |
|---|---|
| Machine-readable JSON output on stdout |
| Simulate all steps, skip side effects |
| Resume or create a named session |
| 标志 | 描述 |
|---|---|
| 在标准输出打印机器可读的JSON格式内容 |
| 模拟所有步骤,跳过副作用操作 |
| 恢复或创建一个命名会话 |
macro
group
macromacro
命令组
macro| Command | Description |
|---|---|
| List all available macros |
| Show macro schema (parameters, steps, conditions) |
| Execute a macro |
| Simulate without side effects |
| Structural validation |
| Scaffold a new macro YAML |
| 命令 | 描述 |
|---|---|
| 列出所有可用的宏 |
| 显示宏的Schema(参数、步骤、条件) |
| 执行宏 |
| 模拟执行,无副作用 |
| 结构验证 |
| 生成新宏的YAML模板 |
session
group
sessionsession
命令组
session| Command | Description |
|---|---|
| Show session statistics |
| Show recent run history |
| Persist session to disk |
| List all saved sessions |
| 命令 | 描述 |
|---|---|
| 显示会话统计信息 |
| 显示最近的运行历史 |
| 将会话持久化到磁盘 |
| 列出所有已保存的会话 |
backends
backendsbackends
backendsbash
cli-anything-openclaw backends --jsonbash
cli-anything-openclaw backends --jsonShows: native_api, file_transform, semantic_ui, gui_macro, recovery
显示:native_api、file_transform、semantic_ui、gui_macro、recovery
and whether each is available in the current environment.
以及每个后端在当前环境中是否可用。
undefinedundefinedMacro Parameters
宏参数
Pass parameters with . Repeat for multiple:
--param key=valuebash
cli-anything-openclaw macro run transform_json \
--param file=/path/to/data.json \
--param key=settings.theme \
--param value=dark \
--json使用传递参数,多个参数可重复使用:
--param key=valuebash
cli-anything-openclaw macro run transform_json \
--param file=/path/to/data.json \
--param key=settings.theme \
--param value=dark \
--jsonOutput Format (--json)
输出格式(--json)
All commands output JSON when is set:
--jsonjson
{
"success": true,
"macro_name": "export_file",
"output": {
"exported_file": "/tmp/result.txt"
},
"error": "",
"telemetry": {
"duration_ms": 312,
"steps_total": 2,
"steps_run": 2,
"backends_used": ["native_api"],
"dry_run": false
}
}On failure (), read the field for the reason.
Exit code is 1 on failure.
"success": false"error"当设置时,所有命令都会输出JSON格式内容:
--jsonjson
{
"success": true,
"macro_name": "export_file",
"output": {
"exported_file": "/tmp/result.txt"
},
"error": "",
"telemetry": {
"duration_ms": 312,
"steps_total": 2,
"steps_run": 2,
"backends_used": ["native_api"],
"dry_run": false
}
}失败时(),请查看字段了解原因。失败时退出码为1。
"success": false"error"Execution Backends
执行后端
Backends are selected automatically based on the macro step definition:
| Backend | Triggered by | Use case |
|---|---|---|
| | Subprocess / shell command |
| | XML, JSON, text file editing |
| | Accessibility / keyboard shortcuts |
| | Precompiled coordinate replay |
| | Retry / fallback orchestration |
后端会根据宏步骤定义自动选择:
| 后端 | 触发条件 | 使用场景 |
|---|---|---|
| | 子进程/Shell命令 |
| | XML、JSON、文本文件编辑 |
| | 无障碍访问/键盘快捷键 |
| | 预编译坐标重放 |
| | 重试/降级编排 |
Writing Macros
编写宏
Macros are YAML files in .
Scaffold one with:
cli_anything/openclaw/macro_definitions/bash
cli-anything-openclaw macro define my_macro --output \
cli_anything/openclaw/macro_definitions/examples/my_macro.yamlMinimal schema:
yaml
name: my_macro
version: "1.0"
description: What this macro does.
parameters:
output:
type: string
required: true
description: Where to write results.
example: /tmp/result.txt
preconditions:
- file_exists: /path/to/input
steps:
- id: step1
backend: native_api
action: run_command
params:
command: [my-app, --export, "${output}"]
timeout_ms: 30000
on_failure: fail # or: skip, continue
postconditions:
- file_exists: ${output}
- file_size_gt: [${output}, 100]
outputs:
- name: result_file
path: ${output}
agent_hints:
danger_level: safe # safe | moderate | dangerous
side_effects: [creates_file]
reversible: true宏是存储在目录下的YAML文件。使用以下命令生成模板:
cli_anything/openclaw/macro_definitions/bash
cli-anything-openclaw macro define my_macro --output \
cli_anything/openclaw/macro_definitions/examples/my_macro.yaml最小化Schema:
yaml
name: my_macro
version: "1.0"
description: What this macro does.
parameters:
output:
type: string
required: true
description: Where to write results.
example: /tmp/result.txt
preconditions:
- file_exists: /path/to/input
steps:
- id: step1
backend: native_api
action: run_command
params:
command: [my-app, --export, "${output}"]
timeout_ms: 30000
on_failure: fail # or: skip, continue
postconditions:
- file_exists: ${output}
- file_size_gt: [${output}, 100]
outputs:
- name: result_file
path: ${output}
agent_hints:
danger_level: safe # safe | moderate | dangerous
side_effects: [creates_file]
reversible: trueAgent Usage Rules
Agent使用规则
- Always use for programmatic output.
--json - Use to validate params before executing side-effectful macros.
--dry-run - Check field — do not assume success from exit code alone.
success - Read field when
erroris false — it explains what failed.success - Use to discover params before calling
macro info <name>.macro run - Use absolute paths for all file parameters.
- 始终使用以获取程序化输出。
--json - 执行有副作用的宏前,使用验证参数。
--dry-run - 检查字段——不要仅通过退出码判断执行成功。
success - 当为false时,查看
success字段——它会解释失败原因。error - 调用前,使用
macro run了解参数信息。macro info <name> - 所有文件参数请使用绝对路径。
Example Workflow
示例工作流
bash
undefinedbash
undefinedStep 1: What's available?
步骤1:查看可用的宏
cli-anything-openclaw macro list --json
cli-anything-openclaw macro list --json
Step 2: What params does transform_json need?
步骤2:查看transform_json需要哪些参数
cli-anything-openclaw macro info transform_json --json
cli-anything-openclaw macro info transform_json --json
Step 3: Test safely
步骤3:安全测试
cli-anything-openclaw --dry-run macro run transform_json
--param file=/tmp/config.json
--param key=theme
--param value=dark --json
--param file=/tmp/config.json
--param key=theme
--param value=dark --json
cli-anything-openclaw --dry-run macro run transform_json
--param file=/tmp/config.json
--param key=theme
--param value=dark --json
--param file=/tmp/config.json
--param key=theme
--param value=dark --json
Step 4: Execute for real
步骤4:实际执行
cli-anything-openclaw macro run transform_json
--param file=/tmp/config.json
--param key=theme
--param value=dark --json
--param file=/tmp/config.json
--param key=theme
--param value=dark --json
undefinedcli-anything-openclaw macro run transform_json
--param file=/tmp/config.json
--param key=theme
--param value=dark --json
--param file=/tmp/config.json
--param key=theme
--param value=dark --json
undefinedVersion
版本
1.0.0
1.0.0