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

# 手順書 YAML

> 手順書 YAML フォーマットの構造とフィールド。

## 概要

**手順書**は、ブラウザ自動化のステップを記述した YAML ファイルです。[`generate`](/ja/cli/generate) で生成し、[`execute`](/ja/cli/execute) で実行します。

## 最小例

```yaml theme={null}
title: ダッシュボードにログイン
settings:
  baseUrl: "https://app.example.com"
  defaultTimeout: 10000
  pauseBetweenSteps: 500
  stopOnError: true
metadata:
  startUrl: "https://app.example.com/login"
  goal: "ログインしてダッシュボードを表示する"
  goalAchieved: true
  totalSteps: 3
  generatedAt: "2025-01-15T10:30:00Z"
steps:
  - ordinal: 0
    description: "ログインページに遷移"
    url: "https://app.example.com/login"
    riskLevel: low
    requiresConfirmation: false
    action:
      type: navigate
      url: "https://app.example.com/login"
  - ordinal: 1
    description: "メールアドレスを入力"
    url: "https://app.example.com/login"
    riskLevel: low
    requiresConfirmation: false
    action:
      type: input
      value: "{{email}}"
      selector:
        tagName: input
        inputType: email
        placeholder: "Email address"
  - ordinal: 2
    description: "サインインをクリック"
    url: "https://app.example.com/login"
    riskLevel: medium
    requiresConfirmation: true
    action:
      type: click
      selector:
        tagName: button
        innerText: "Sign In"
variables:
  email:
    source: prompt
    description: "ログイン用メールアドレス"
    required: true
```

## トップレベルフィールド

| フィールド                    | 型       |  必須 | 説明                         |
| ------------------------ | ------- | :-: | -------------------------- |
| `title`                  | string  | Yes | 手順書のタイトル                   |
| `naturalLanguageSummary` | string  |  No | AI 生成のサマリー                 |
| `settings`               | object  | Yes | 実行設定（下記参照）                 |
| `metadata`               | object  | Yes | 生成メタデータ                    |
| `steps`                  | Step\[] | Yes | ステップの順序付きリスト（最低1つ）         |
| `notes`                  | string  |  No | 追加メモ                       |
| `context`                | string  |  No | コンテキスト Markdown            |
| `variables`              | Record  |  No | [変数定義](/ja/yaml/variables) |
| `dataSource`             | object  |  No | バッチ実行用データソースマッピング          |

## `settings`

| フィールド               | 型       | デフォルト   | 説明                 |
| ------------------- | ------- | ------- | ------------------ |
| `baseUrl`           | string  | —       | 対象アプリケーションのベース URL |
| `defaultTimeout`    | integer | `10000` | ステップタイムアウト（ミリ秒）    |
| `pauseBetweenSteps` | integer | `500`   | ステップ間の待機時間（ミリ秒）    |
| `stopOnError`       | boolean | `true`  | 最初のエラーで実行を停止       |

## `metadata`

| フィールド          | 型         |  必須 | 説明               |
| -------------- | --------- | :-: | ---------------- |
| `startUrl`     | string    | Yes | 生成開始時の URL       |
| `goal`         | string    | Yes | ゴールの説明           |
| `goalAchieved` | boolean   | Yes | 生成時にゴールが達成されたか   |
| `totalSteps`   | integer   | Yes | ステップ総数           |
| `generatedAt`  | string    | Yes | ISO 8601 タイムスタンプ |
| `skills`       | string\[] |  No | 有効なスキルプラグイン      |

## `dataSource`

`--data` を使用したバッチ実行で使用します。

| フィールド     | 型                       | 説明                       |
| --------- | ----------------------- | ------------------------ |
| `mapping` | Record\<string, string> | 変数名と CSV/JSON カラム名のマッピング |

```yaml theme={null}
dataSource:
  mapping:
    email: "Email"
    name: "Full Name"
```

## ステップ構造

各ステップは `ParsedStep` オブジェクトです。各サブ構造の詳細は以下を参照してください：

<CardGroup cols={2}>
  <Card title="アクション" icon="play" href="/ja/yaml/actions">
    12種類のアクション型: click, input, select, navigate, scroll, wait, hover, extract, download, export, memory, key
  </Card>

  <Card title="セレクタ" icon="crosshairs" href="/ja/yaml/selectors">
    14のセレクタフィールドと優先順位ベースの解決
  </Card>

  <Card title="変数" icon="brackets-curly" href="/ja/yaml/variables">
    6つの変数ソースと解決優先順位
  </Card>

  <Card title="キャプチャ" icon="camera" href="/ja/yaml/captures">
    ステップからデータを抽出する5つの戦略
  </Card>

  <Card title="ループ・分岐" icon="arrows-split-up-and-left" href="/ja/yaml/loops-and-branches">
    while/forEach ループと条件分岐
  </Card>

  <Card title="メモリ操作" icon="database" href="/ja/yaml/memory-operations">
    ステップ間でデータを蓄積・集計
  </Card>
</CardGroup>

### 共通ステップフィールド

| フィールド                  | 型                                              |  必須 | 説明                           |
| ---------------------- | ---------------------------------------------- | :-: | ---------------------------- |
| `ordinal`              | integer                                        | Yes | ステップ番号（0始まり）                 |
| `description`          | string                                         | Yes | ステップの説明                      |
| `action`               | [Action](/ja/yaml/actions)                     | Yes | 実行するアクション                    |
| `url`                  | string                                         | Yes | ステップ実行時の想定ページ URL            |
| `riskLevel`            | `low` \| `medium` \| `high`                    | Yes | リスク分類                        |
| `requiresConfirmation` | boolean                                        | Yes | 実行前にユーザー承認が必要か               |
| `captures`             | [Capture\[\]](/ja/yaml/captures)               |  No | 実行後にキャプチャする値                 |
| `condition`            | string                                         |  No | テンプレート式 — falsy の場合ステップをスキップ |
| `loop`                 | [Loop](/ja/yaml/loops-and-branches)            |  No | ループ定義                        |
| `steps`                | Step\[]                                        |  No | ネストされたステップ（ループ内で使用）          |
| `branches`             | [Branch](/ja/yaml/loops-and-branches#branches) |  No | 条件分岐                         |
| `memoryOperations`     | [MemoryOp\[\]](/ja/yaml/memory-operations)     |  No | メモリ操作                        |

<Note>
  1つのステップに `loop` と `branches` を同時に設定することはできません。
</Note>
