# `CMDC.Backend.Results.FileData`
[🔗](https://github.com/tuplehq/cmdc/blob/v0.4.0/lib/cmdc/backend/results.ex#L30)

文件数据 typed map（对标 deepagents `FileData` TypedDict）。

## 格式版本

- **v1**（legacy）：`content` 为 `[binary]`（按 `\n` 分割的行列表），无 `encoding` 字段
- **v2**（current）：`content` 为 `binary`，加 `encoding` 字段（`"utf-8"` 或 `"base64"`）

Backend 接受两种格式作为输入，输出推荐 v2。

# `t`

```elixir
@type t() :: %{
  :content =&gt; String.t() | [String.t()],
  optional(:encoding) =&gt; String.t(),
  optional(:created_at) =&gt; String.t(),
  optional(:modified_at) =&gt; String.t()
}
```

# `new`

```elixir
@spec new(
  String.t(),
  keyword()
) :: t()
```

构建 v2 格式文件数据。

# `to_legacy`

```elixir
@spec to_legacy(t()) :: %{content: [String.t()]}
```

返回 v1（legacy）格式（lines list）。

# `to_string`

```elixir
@spec to_string(t()) :: String.t()
```

字符串内容（处理 v1/v2 两种格式）。

# `to_v2`

```elixir
@spec to_v2(t()) :: t()
```

从 v1 (lines) 转 v2 (string)；幂等。

---

*Consult [api-reference.md](api-reference.md) for complete listing*
