跳到正文
所有工具

recipe_save

技能与流程 · macOS · Windows

效果: 写入. 状态: 受限可用.

“受限可用”表示工具可能取决于版本、平台、权限、账户或配置,并不表示它在所有安装中都已启用。

macOS

用途

将一个可重复使用的 SKILL——即命名配方(一组按顺序排列、带参数的 LMCP 工具调用)——保存到这台 Mac,以便用户随时用 recipe_run 重新运行。用户保存它,是为了把自己重复进行的多步 LMCP 工作流(晨间简报、收件箱分流、每周报告、数据拉取)变成一个可重复使用的命令。已保存的技能可以通过 recipe_export 与他人共享。清单必须包含 name 和非空的 steps 数组。步骤无法自行确认:步骤参数中的 `confirm` 在保存时会被移除(confirm_removed_steps 说明有多少个步骤带有它),运行时也会被忽略,因此其工具要求确认的步骤只会返回预览而不会执行。名称已是某个配方时,会被拒绝并返回 recipe_exists,且不写入任何内容;传入 overwrite: true 可替换它。返回 {name}。

必填输入

输入名称会严格保持工具要求的形式。下方可展开的架构中保留英文规范技术定义。

权限与确认

架构未声明明确的确认参数。这并不代表可以未经许可操作;请检查效果并取得授权。

英文规范技术架构 — macOS
{
  "properties": {
    "manifest": {
      "description": "The recipe manifest. Shape: {\"name\": string (required), \"description\": string, \"params\": [{\"name\": string, \"type\": \"string\"|\"int\"|\"bool\", \"default\": any}], \"steps\": [ ... ] (required, non-empty), \"outputs\": [{\"kind\": string}]}. A step is EITHER a tool call {\"tool\": <tool_name>, \"args\": {...}} OR a pause {\"wait\": {\"seconds\": N}} (also {\"wait\": N}). A tool-call step may add \"optional\": true (a boolean; default false): if it fails, recipe_run records {ok:false, error} for it, lists it in skipped_optional and carries on with the next step, instead of stopping — use it for a source the user may not have (an app, a permission). Any arg string may interpolate a declared param with ${name} (e.g. \"limit\": \"${count}\"); an arg that is exactly \"${name}\" keeps the param's type. Steps run in order; a later step can consume an EARLIER step's output with \"${steps[N].result.KEY}\" (0-based; supports .key and [i], e.g. \"account\": \"${steps[0].result.accounts[0].name}\"). A step cannot confirm itself: do not put `confirm` in a step's args (it is removed when saving and ignored when running). recipe_run asks for one confirmation when the recipe has state-changing steps; a step whose tool asks for its own confirmation then answers with its preview and is not executed. A step that names a note should give note_name (the note's title): a note_id only names the note on the Mac that issued it, so a step that gives both is saved with note_name alone.",
      "type": "object"
    },
    "overwrite": {
      "description": "Must be true to replace a recipe that already has this name. Without it, a taken name is refused with recipe_exists and the existing recipe is left as it was.",
      "type": "boolean"
    }
  },
  "required": [
    "manifest"
  ],
  "type": "object"
}

文档示例

recipe_save 的文档示例。请勿执行此示例。所示参数属于虚构数据集;在实际调用前,请解析真实标识符并获得授权。

{
  "manifest": {
    "description": "Read the local date and time.",
    "name": "Demo morning brief",
    "steps": [
      {
        "args": {},
        "tool": "get_datetime"
      }
    ]
  }
}

Windows

用途

将一个可重复使用的 SKILL——即命名配方(一组按顺序排列、带参数的 LMCP 工具调用)——保存到这台设备,以便用户随时用 recipe_run 重新运行。用户保存它,是为了把自己重复进行的多步 LMCP 工作流(晨间简报、收件箱分流、每周报告、数据拉取)变成一个可重复使用的命令。清单必须包含 name 和非空的 steps 数组。步骤可以添加 "optional": true(布尔值;默认 false):如果它失败,recipe_run 会为其记录 {ok:false, error},将其列入 skipped_optional,并继续执行下一步而不是停止——适用于用户可能没有的来源(某个应用、某个权限)。参数字符串可以用 ${name} 插入已声明的参数;恰好为 "${name}" 的参数会保留该参数的类型。后续步骤可以用 "${steps[N].result.KEY}" 使用前面某步的输出(从 0 开始;支持 .key 和 [i])。步骤无法自行确认:步骤参数中的 confirm 会被移除,因此其工具要求确认的步骤(发送、删除、替换文件、运行命令)会返回其预览。名称已是某个配方时,会被拒绝并返回 recipe_exists,且不写入任何内容;传入 overwrite: true 可替换它。返回 {name, step_count}。

必填输入

输入名称会严格保持工具要求的形式。下方可展开的架构中保留英文规范技术定义。

权限与确认

架构未声明明确的确认参数。这并不代表可以未经许可操作;请检查效果并取得授权。

英文规范技术架构 — Windows
{
  "properties": {
    "manifest": {
      "description": "The recipe manifest. Shape: {\"name\": string (required), \"description\": string, \"schema_version\": int, \"params\": [{\"name\": string, \"type\": string, \"default\": any}], \"steps\": [{\"tool\": string, \"args\": object, \"optional\": bool}] (required, non-empty)}.",
      "type": "object"
    },
    "overwrite": {
      "description": "Must be true to replace a recipe that already has this name. Without it, a taken name is refused with recipe_exists and the existing recipe is left as it was.",
      "type": "boolean"
    }
  },
  "required": [
    "manifest"
  ],
  "type": "object"
}

文档示例

recipe_save 的文档示例。请勿执行此示例。所示参数属于虚构数据集;在实际调用前,请解析真实标识符并获得授权。

{
  "manifest": {
    "description": "Read the local date and time.",
    "name": "Demo morning brief",
    "steps": [
      {
        "args": {},
        "tool": "get_datetime"
      }
    ]
  }
}