> ## Documentation Index
> Fetch the complete documentation index at: https://starforge.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# sf recipe

> 方法锁（recipe.lock.json）状态与升级

锁机制原理见 [Recipe 与版本管理](/zh-Hans/concepts/recipes)。

## sf recipe status

```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
sf recipe status <EXP>       # 单实验：锁与当前 catalog 的字段级差异
sf recipe status --all       # 扫描 experiments / smoke 全部
sf recipe status <EXP> --server   # 再与 Console 发布的 catalog 握手对照
```

输出逐字段 diff：recipe 版本、digest、框架版本、runtime\_id、SDK 兼容范围。有 diff 不代表坏——代表升级后行为可能变化，需要显式确认。

## sf recipe upgrade

```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
sf recipe upgrade <EXP>                             # 升级锁（不改框架版本）
sf recipe upgrade <EXP> --framework-version 0.9.0   # 同时切框架版本
sf recipe upgrade --all                             # 先全量校验，再统一写入
sf recipe upgrade <EXP> --dry-run                   # 只显示 diff，不写文件
```

| 选项                        | 说明                       |
| ------------------------- | ------------------------ |
| `--all`                   | 全仓库实验统一升级（先校验后写入）        |
| `--dry-run`               | 只看 diff                  |
| `--framework-version`     | 升级同时切换框架版本               |
| `--accept-runtime-change` | 升级涉及 runtime（镜像）变化时的显式确认 |

<Tip>
  升级会改写 `recipe.lock.json`——记得 commit，否则下次提交又会因工作区脏被拦。提交场景可以直接 `sf submit --upgrade-recipe` 一步完成。
</Tip>

## `sf recipe`

Manage recipe locks

```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
sf recipe <subcommand>
```

| 命令                  | 说明                                     |
| ------------------- | -------------------------------------- |
| `sf recipe ls`      | List every available method            |
| `sf recipe status`  | Show an experiment's lock drift        |
| `sf recipe sync`    | Sync published methods to this machine |
| `sf recipe upgrade` | Upgrade an experiment lock             |

### `sf recipe ls`

List every available method

```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
sf recipe ls [options]
```

| 选项         | 说明                               |
| ---------- | -------------------------------- |
| `--source` | Only one source: builtin \| user |

### `sf recipe status`

Show an experiment's lock drift

```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
sf recipe status [EXP] [options]
```

| 参数    | 说明                                                  |
| ----- | --------------------------------------------------- |
| `EXP` | Experiment name or path; omitting it requires --all |

| 选项         | 说明                                           |
| ---------- | -------------------------------------------- |
| `--all`    | Scan experiments/ and smoke/                 |
| `--server` | Also cross-check against the Console catalog |

### `sf recipe sync`

Sync published methods to this machine

```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
sf recipe sync [options]
```

| 选项         | 说明                                                                                       |
| ---------- | ---------------------------------------------------------------------------------------- |
| `--server` | Console address (defaults to the one you logged into)                                    |
| `--prune`  | Whether to drop methods that exist locally but not on the platform (or were unpublished) |

### `sf recipe upgrade`

Upgrade an experiment lock

```bash theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
sf recipe upgrade [EXP] [options]
```

| 参数    | 说明                                                     |
| ----- | ------------------------------------------------------ |
| `EXP` | Experiment name or path; mutually exclusive with --all |

| 选项                        | 说明                                                                                           |
| ------------------------- | -------------------------------------------------------------------------------------------- |
| `--all`                   | Validate everything first, then write in one go                                              |
| `--dry-run`               | Only show the diff, write nothing                                                            |
| `--framework-version`     | Also move to this exact framework version                                                    |
| `--accept-runtime-change` | When the locked framework version is gone from the catalog, fall back to the current default |
