Communitygithub.com

MacroCLI 命令列工具

將圖形化使用者介面工作流程轉換為可參數化的 CLI 巨集,讓 AI 代理透過穩定的命令列介面呼叫,無需直接操作 GUI。

MacroCLI 命令列工具 是什麼?

MacroCLI 是一款為 AI 代理(如 Claude Code、Cursor、Codex 等)設計的命令列工具,能將複雜的 GUI 工作流程轉換成可參數化的 CLI 巨集。代理無需直接操作 GUI,而是透過此 CLI 呼叫巨集,由運行時自動選擇最佳後端(原生外掛/API、檔案轉換、語意 UI 控制或預編譯 GUI 巨集重播)來執行。此工具支援 Python 3.10+,提供完整的參數驗證、乾執行(dry-run)、JSON 輸出與錯誤處理機制,適用於需要自動化多步驟 GUI 操作的開發與測試場景。透過 YAML 定義巨集,可設定前置條件、步驟、後置條件與危險等級,確保執行安全且可逆。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/HKUDS/CLI-Anything/tree/main/skills/cli-anything-macrocli

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

MacroCLI 命令列工具 是做什麼的?

用途

MacroCLI 可將有價值的 GUI 工作流程轉換為可參數化的 CLI 巨集。AI 代理從不直接操作 GUI,而是透過此穩定 CLI 呼叫巨集,由運行時將執行路由至最佳可用後端(原生外掛/API、檔案轉換、語意 UI 控制,或預編譯 GUI 巨集重播)。

安裝

cd macrocli/agent-harness
pip install -e .

系統需求: Python 3.10+、PyYAML、click、prompt-toolkit。

快速入門(供代理使用)

# 1. 查看可用的巨集
cli-anything-macrocli macro list --json

# 2. 檢視巨集的參數
cli-anything-macrocli macro info export_file --json

# 3. 執行乾執行,檢查參數但不產生副作用
cli-anything-macrocli --dry-run macro run export_file \
    --param output=/tmp/test.txt --json

# 4. 執行巨集
cli-anything-macrocli macro run export_file \
    --param output=/tmp/result.txt --json

# 5. 查看可用的後端
cli-anything-macrocli backends --json

指令參考

全域旗標

旗標說明
--json將機器可讀的 JSON 輸出至 stdout
--dry-run模擬所有步驟,跳過副作用
--session-id <id>繼續或建立一個具名工作階段

macro 指令群組

指令說明
macro list列出所有可用的巨集
macro info <name>顯示巨集的結構(參數、步驟、條件)
macro run <name> --param k=v執行巨集
macro dry-run <name> --param k=v模擬執行,不產生副作用
macro validate [name]結構驗證
macro define <name>建立新的巨集 YAML 骨架

session 指令群組

指令說明
session status顯示工作階段統計
session history顯示最近的執行歷史
session save將工作階段持久化至磁碟
session list列出所有已儲存的工作階段

backends

cli-anything-macrocli backends --json
# 顯示:native_api, file_transform, semantic_ui, gui_macro, recovery
# 以及每個後端在目前環境中是否可用。

巨集參數

使用 --param key=value 傳遞參數。可重複使用多次:

cli-anything-macrocli macro run transform_json \
    --param file=/path/to/data.json \
    --param key=settings.theme \
    --param value=dark \
    --json

輸出格式(--json)

所有指令在設定 --json 時都會輸出 JSON:

{
  "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
  }
}

失敗時("success": false),請讀取 "error" 欄位以了解原因。失敗時退出碼為 1。

執行後端

根據巨集的步驟定義自動選擇後端:

後端觸發條件使用案例
native_apibackend: native_api子行程 / shell 指令
file_transformbackend: file_transformXML、JSON、純文字檔案編輯
semantic_uibackend: semantic_ui無障礙輔助 / 鍵盤快速鍵
gui_macrobackend: gui_macro預編譯的座標重播
recoverybackend: recovery重試 / 備用協調

撰寫巨集

巨集是位於 cli_anything/macrocli/macro_definitions/ 目錄下的 YAML 檔案。可使用以下指令建立骨架:

cli-anything-macrocli macro define my_macro --output \
    cli_anything/macrocli/macro_definitions/examples/my_macro.yaml

最小結構範例:

name: my_macro
version: "1.0"
description: 此巨集的用途。

parameters:
  output:
    type: string
    required: true
    description: 寫入結果的位置。
    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  # 或: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

代理使用規則

  1. 一律使用 --json 以獲得程式化的輸出。
  2. 使用 --dry-run 驗證參數,然後再執行會產生副作用的巨集。
  3. 檢查 success 欄位——不要僅根據退出碼判斷成功。
  4. 當 success 為 false 時讀取 error 欄位——它會說明失敗原因。
  5. 使用 macro info <name> 探索參數,然後再呼叫 macro run。
  6. 為所有檔案參數使用絕對路徑。

工作流程範例

# 步驟 1:有什麼可用的?
cli-anything-macrocli macro list --json

# 步驟 2:transform_json 需要哪些參數?
cli-anything-macrocli macro info transform_json --json

# 步驟 3:安全測試
cli-anything-macrocli --dry-run macro run transform_json \
    --param file=/tmp/config.json \
    --param key=theme \
    --param value=dark --json

# 步驟 4:實際執行
cli-anything-macrocli macro run transform_json \
    --param file=/tmp/config.json \
    --param key=theme \
    --param value=dark --json

版本

1.0.0

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

cli-anything-adguardhome

>-

cli-anything-anygen

>-

cli-anything-audacity

>-

cli-anything-blender

>-

cli-anything-browser

Browser automation CLI using DOMShell MCP server. Maps Chrome

cli-anything-calibre

>-

cli-anything-ccswitch

CLI interface for CC Switch — manage AI coding tool configurations from the terminal

cli-anything-chromadb

>-

cli-anything-cloudanalyzer

Command-line interface for CloudAnalyzer — Agent-friendly harness for CloudAnalyzer, a QA platform for mapping, localization, and perception outputs. Supports 27 commands across 8 groups: point cloud evaluation, trajectory evaluation, ground segmentation QA, config-driven quality gates, baseline evolution, processing, visualization, and interactive REPL.

cli-anything-cloudcompare

Command-line interface for CloudCompare — Agent-friendly harness for CloudCompare, the open-source 3D point cloud and mesh processing software. Supports 41 commands across 9 groups: project management, session control, point cloud operations (subsample, filter, segment, analyze), mesh operations, distance computation (C2C, C2M), transformations (ICP, matrix), export (LAS/LAZ/PLY/PCD/OBJ/STL/E57), and interactive REPL.

cli-anything-comfyui

>-

cli-anything-dify-workflow

Wrapper for the Dify workflow DSL CLI. Create, inspect, validate, edit, and export Dify workflow files through a CLI-Anything harness.

cli-anything-drawio

>-

cli-anything-eez-studio

Use EEZ Studio from the command line: inspect and modify native .eez-project files, edit LVGL screens/widgets, manage SCPI commands, and invoke the real EEZ Studio backend for LVGL builds.

cli-anything-eth2-quickstart

>-

cli-anything-exa

>-

cli-anything-firefly-iii

Firefly III CLI - Personal finance management via CLI-Anything

cli-anything-freecad

Complete CLI harness for FreeCAD parametric 3D CAD modeler (258 commands). Covers ALL workbenches: Part (29 primitives + boolean + mirror + loft + sweep), Sketcher (26 cmds: geometry + constraints + editing), PartDesign (38 cmds: pad/pocket/groove/fillet/chamfer/patterns/hole/datum), Assembly (11 cmds), Mesh (16 cmds), TechDraw (15 cmds: views + dimensions + PDF/SVG), Draft (33 cmds: 2D shapes + arrays + transforms), FEM (12 cmds), CAM/CNC (10 cmds), Surface (6 cmds), Spreadsheet (7 cmds), Import (13 formats), Export (17 formats), Measure (12 cmds), Materials (21 presets). Headless FreeCAD export to STEP/IGES/STL/OBJ/DXF/PDF/glTF/3MF.

cli-anything-gimp

>-

cli-anything-godot

>-

相關技能