Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: check

on:
push:
branches: [main]
pull_request:

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm run check
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 0.2.0 - 2026-11-19

- Aligned with the 2026-11-17 `DESIGN.md` update: `DESIGN.md` owns motion timing tokens; `MOTION.md` binds them with `design` and references them with `timing: "{motion.<token>}"`.
- Resolved design tokens in Motion IR, including the bound `DESIGN.md` hash.
- Added interleaved YAML blocks, `omitted`, and external `@` references with `DESIGN.md` semantics.
- Added `prefer-design-token`, `timing-conflict`, `design-path`, `duplicate-key`, `unknown-omission`, and `redundant-omission` rules; renamed `missing-frontmatter` to `missing-machine-data`.
- Added the design-bound example and a CI workflow. See `docs/releases/v0.2.0.md` for migration.

## 0.1.0 - 2026-07-20

- Established the independent `motion.md` philosophy, scope, terminology, and version policy.
Expand Down
43 changes: 23 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ A format specification for describing motion graphics and frontend animation int

**English** · [简体中文](README.zh-CN.md)

[Specification](docs/spec.md) · [JSON Schema](schemas/motion.schema.json) · [Examples](examples) · [v0.1.0 release](https://github.com/2233admin/motion.md/releases/tag/v0.1.0)
[Specification](docs/spec.md) · [JSON Schema](schemas/motion.schema.json) · [Examples](examples) · [v0.2 release notes](docs/releases/v0.2.0.md)

## The Format

A `MOTION.md` file combines machine-readable motion semantics in YAML front matter with human-readable design intent in Markdown prose.
A `MOTION.md` file combines machine-readable motion semantics in YAML (front matter, or ` ```yaml ` blocks interleaved into the sections they belong to) with human-readable design intent in Markdown prose.

The YAML defines exact states, events, transitions, timelines, curves, interruption rules, accessibility substitutions, and performance budgets. The prose explains why those rules exist, what the motion should communicate, and where restraint matters.

Expand All @@ -19,7 +19,7 @@ The YAML defines exact states, events, transitions, timelines, curves, interrupt

```md
---
version: "0.1"
version: "0.2"
name: Quiet Feedback
posture: minimal
states:
Expand Down Expand Up @@ -83,7 +83,7 @@ This motion direction is authored for the product.

An agent reading this file knows which state owns the result, which event causes the change, how interruption is resolved, what reduced motion preserves, and which performance limits must survive runtime selection.

See the [minimal](examples/minimal/MOTION.md), [expressive](examples/expressive/MOTION.md), [procedural](examples/procedural/MOTION.md), and [reduced-motion](examples/reduced-motion/MOTION.md) examples for complete motion systems.
See the [minimal](examples/minimal/MOTION.md), [expressive](examples/expressive/MOTION.md), [procedural](examples/procedural/MOTION.md), [reduced-motion](examples/reduced-motion/MOTION.md), and [design-bound](examples/design-bound/MOTION.md) examples for complete motion systems. The design-bound example takes its timing from a sibling `DESIGN.md`.

## Getting Started

Expand All @@ -100,7 +100,7 @@ The CLI emits structured findings that coding agents can act on:
{
"findings": [],
"format": "motion.md",
"specVersion": "0.1",
"specVersion": "0.2",
"summary": {
"errors": 0,
"warnings": 0,
Expand All @@ -123,8 +123,8 @@ The full `MOTION.md` specification lives at [`docs/spec.md`](docs/spec.md). What

A `MOTION.md` file has two layers:

1. **YAML front matter** — exact motion semantics, delimited by `---` fences at the top of the file;
2. **Markdown body** — design intent and rationale organized into `##` sections.
1. **YAML** — exact motion semantics, either as front matter delimited by `---` fences or as ` ```yaml ` blocks inside the relevant section (for example `reducedMotion` under `## Reduced Motion`). All blocks merge into one tree; each top-level key may appear once;
2. **Markdown body** — design intent and rationale organized into `##` sections. Prose may point to other files with `` `@path#fragment` ``, resolved from the `MOTION.md` directory.

YAML is normative for exact values and graph relationships. Markdown is normative for intent, priorities, prohibitions, and decision rationale. A conforming consumer reports conflicts instead of silently choosing one layer.

Expand All @@ -135,10 +135,13 @@ YAML is normative for exact values and graph relationships. Markdown is normativ
| `version` | Specification version |
| `name` | Human-readable motion system name |
| `posture` | `static`, `minimal`, `expressive`, or `procedural` |
| `design` | Relative path to a `DESIGN.md` whose `motion` tokens may be referenced |
| `omitted` | Prose sections deliberately left out, with optional reasons |
| `defaults` | Default timing: a `timing` token reference, or duration, delay, and curve |
| `states` | Semantic product states |
| `events` | User, system, data, time, viewport, media, or sensor inputs |
| `curves` | Linear, Bézier, steps, spring, or procedural curves |
| `timelines` | Runtime-neutral drivers, tracks, and keyframes |
| `timelines` | Runtime-neutral drivers, tracks, and keyframes; tracks may use `timing: "{motion.<token>}"` |
| `transitions` | State changes, interruption, and cancellation policy |
| `reducedMotion` | Accessibility strategy and semantic substitutions |
| `performance` | Frame, input, concurrency, and determinism budgets |
Expand All @@ -158,7 +161,7 @@ Markdown sections may be omitted, but those present should follow this order:
6. Performance
7. Provenance

Unknown sections are preserved. Duplicate second-level headings are invalid because they make stable section addressing ambiguous.
Unknown sections are preserved. Duplicate second-level headings are invalid because they make stable section addressing ambiguous. Sections left out on purpose are declared in `omitted`, which suppresses the `missing-section` warning.

## CLI Reference

Expand All @@ -172,21 +175,21 @@ All commands accept file paths; `lint` and `parse` also accept `-` for standard
| `motionmd spec` | Output the Markdown specification |
| `motionmd spec --format json` | Output the JSON Schema |

`lint`, `parse`, and `diff` exit with code `1` when invalid or breaking results are found. CLI misuse and unreadable input exit with code `2`.
`design` and `@` references resolve from each input file's directory (the working directory for standard input). `lint`, `parse`, and `diff` exit with code `1` when invalid or breaking results are found. CLI misuse and unreadable input exit with code `2`.

## Relationship to DESIGN.md

The project shape deliberately aligns with Google Labs' [`design.md`](https://github.com/google-labs-code/design.md):
In November 2026 Google Labs' [`design.md`](https://github.com/google-labs-code/design.md) added a `## Motion & Micro-interaction` section and `motion` tokens (`duration`, `delay`, `timingFunction`). The split between the two files is:

| Shared convention | `DESIGN.md` | `MOTION.md` |
| --- | --- | --- |
| Portable project document | Visual identity | Motion intent and temporal behavior |
| YAML front matter | Exact design tokens | Exact states, events, timelines, and budgets |
| Markdown prose | Visual rationale | Motion rationale, hierarchy, and restraint |
| Machine contract | Schema and linting | Schema, linting, and Motion IR |
| Agent workflow | Read, validate, export | Read, validate, normalize, compare |
| Concern | Owner |
| --- | --- |
| Brand motion tone and timing vocabulary (`state-change`, `surface-enter`, …) | `DESIGN.md` |
| State graph, events, choreography, interruption, reduced motion, budgets | `MOTION.md` |
| Springs, scroll and pointer drivers, procedural curves | `MOTION.md` (no `DESIGN.md` equivalent) |

`MOTION.md` binds with `design: DESIGN.md` and references tokens with `timing: "{motion.surface-enter}"` instead of restating 250ms and a Bézier curve. References resolve to concrete values in Motion IR together with the `DESIGN.md` hash, so a token change shows up in `motionmd diff`. A literal that happens to equal a token gets a `prefer-design-token` hint.

The formats are complementary, not nested. `DESIGN.md` owns visual identity and design-system values. `MOTION.md` owns state change, time, interruption, reduced motion, and performance. Tooling may consume both without either specification redefining the other.
Both formats share the same document conventions: front matter or interleaved YAML blocks, `##` sections, `omitted`, `{…}` token references, and `` `@path#fragment` `` external references. See [`examples/design-bound`](examples/design-bound).

See [`docs/interoperability.md`](docs/interoperability.md) for the consumer boundary.

Expand All @@ -204,7 +207,7 @@ Runtime adapter → evidence and QA

## Status

The `MOTION.md` format is at version `0.1` and remains a draft. The specification, JSON Schema, Motion IR, and CLI are ready for evaluation. Incompatible changes may occur before v1.0.
The `MOTION.md` format is at version `0.2` and remains a draft. The specification, JSON Schema, Motion IR, and CLI are ready for evaluation. Incompatible changes may occur before v1.0.

The repository is open source under the MIT License. The package remains marked `private` only to prevent accidental npm publication while the distribution contract is still evolving.

Expand Down
43 changes: 23 additions & 20 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ A format specification for describing motion graphics and frontend animation int

[English](README.md) · **简体中文**

[规范](docs/spec.md) · [JSON Schema](schemas/motion.schema.json) · [示例](examples) · [v0.1.0 Release](https://github.com/2233admin/motion.md/releases/tag/v0.1.0)
[规范](docs/spec.md) · [JSON Schema](schemas/motion.schema.json) · [示例](examples) · [v0.2 发布说明](docs/releases/v0.2.0.md)

## 文件格式

一个 `MOTION.md` 文件由两部分组成:YAML front matter 中机器可读的动画语义,以及 Markdown 正文中人类与 Agent 可读的运动图形和前端动画意图。
一个 `MOTION.md` 文件由两部分组成:YAML 中机器可读的动画语义(写在 front matter,或穿插在各章节的 ` ```yaml ` 代码块里),以及 Markdown 正文中人类与 Agent 可读的运动图形和前端动画意图。

YAML 定义精确的状态、事件、转换、时间线、曲线、中断规则、无障碍替代方案与性能预算。Markdown 解释这些规则为什么存在、动画需要传达什么,以及应该在哪里保持克制。

Expand All @@ -19,7 +19,7 @@ YAML 定义精确的状态、事件、转换、时间线、曲线、中断规则

```md
---
version: "0.1"
version: "0.2"
name: Quiet Feedback
posture: minimal
states:
Expand Down Expand Up @@ -83,7 +83,7 @@ provenance:

Agent 读取这个文件后,可以知道哪个状态拥有结果、什么事件触发变化、中断如何处理、Reduced Motion 必须保留什么,以及运行时选择不能破坏哪些性能限制。

完整的动画规范可以参考[最小](examples/minimal/MOTION.md)、[表现型](examples/expressive/MOTION.md)、[程序化](examples/procedural/MOTION.md)和 [Reduced Motion](examples/reduced-motion/MOTION.md) 示例。
完整的动画规范可以参考[最小](examples/minimal/MOTION.md)、[表现型](examples/expressive/MOTION.md)、[程序化](examples/procedural/MOTION.md)、[Reduced Motion](examples/reduced-motion/MOTION.md) 和 [DESIGN.md 绑定](examples/design-bound/MOTION.md) 示例。最后一个的时序全部来自同目录的 `DESIGN.md`。

## 快速开始

Expand All @@ -100,7 +100,7 @@ CLI 输出编程 Agent 可以直接处理的结构化 findings:
{
"findings": [],
"format": "motion.md",
"specVersion": "0.1",
"specVersion": "0.2",
"summary": {
"errors": 0,
"warnings": 0,
Expand All @@ -123,8 +123,8 @@ motionmd diff before/MOTION.md after/MOTION.md

一个 `MOTION.md` 文件包含两个层:

1. **YAML front matter** — 文件顶部由 `---` 分隔的精确动画语义;
2. **Markdown 正文** — 由 `##` 章节组织的动画意图与说明。
1. **YAML** — 精确动画语义。可以写在文件顶部 `---` 分隔的 front matter 里,也可以写成穿插在对应章节内的 ` ```yaml ` 代码块(例如把 `reducedMotion` 放在 `## Reduced Motion` 下)。所有块合并成一棵树,同一顶层键只能出现一次;
2. **Markdown 正文** — 由 `##` 章节组织的动画意图与说明。正文可以用 `` `@path#fragment` `` 引用其他文件,从 `MOTION.md` 所在目录解析。

YAML 对精确数值和图关系具有规范性。Markdown 对意图、优先级、禁用规则和决策理由具有规范性。两者冲突时,合规消费者应报告冲突,而不是静默选择其中一层。

Expand All @@ -135,10 +135,13 @@ YAML 对精确数值和图关系具有规范性。Markdown 对意图、优先级
| `version` | 规范版本 |
| `name` | 动画规范的人类可读名称 |
| `posture` | `static`、`minimal`、`expressive` 或 `procedural` |
| `design` | 绑定的 `DESIGN.md` 相对路径,其 `motion` token 可被引用 |
| `omitted` | 有意省略的正文章节,附可选理由 |
| `defaults` | 默认时序:`timing` token 引用,或时长、延迟、曲线 |
| `states` | 产品的语义状态 |
| `events` | 用户、系统、数据、时间、视口、媒体或传感器输入 |
| `curves` | 线性、Bézier、steps、spring 或程序曲线 |
| `timelines` | 运行时无关的驱动、轨道和关键帧 |
| `timelines` | 运行时无关的驱动、轨道和关键帧;轨道可用 `timing: "{motion.<token>}"` 引用 DESIGN.md 时序 |
| `transitions` | 状态变化、中断与取消策略 |
| `reducedMotion` | 无障碍策略与语义替代方案 |
| `performance` | 帧率、输入、并发与确定性预算 |
Expand All @@ -158,7 +161,7 @@ Markdown 章节可以省略;已经出现的章节应遵循以下顺序:
6. Performance
7. Provenance

未知章节会被保留。重复的二级标题无效,因为它们会使稳定的章节寻址产生歧义。
未知章节会被保留。重复的二级标题无效,因为它们会使稳定的章节寻址产生歧义。有意不写的章节在 `omitted` 中声明,即可消除 `missing-section` 警告。

## CLI 参考

Expand All @@ -172,21 +175,21 @@ Markdown 章节可以省略;已经出现的章节应遵循以下顺序:
| `motionmd spec` | 输出 Markdown 规范 |
| `motionmd spec --format json` | 输出 JSON Schema |

`lint`、`parse` 和 `diff` 在发现无效或破坏性结果时以代码 `1` 退出。CLI 用法错误和无法读取的输入以代码 `2` 退出。
`design` 与 `@` 引用从输入文件所在目录解析(标准输入则从当前目录)。`lint`、`parse` 和 `diff` 在发现无效或破坏性结果时以代码 `1` 退出。CLI 用法错误和无法读取的输入以代码 `2` 退出。

## 与 DESIGN.md 的关系

本项目在产品形态上有意与 Google Labs 的 [`design.md`](https://github.com/google-labs-code/design.md) 对齐:
Google Labs 的 [`design.md`](https://github.com/google-labs-code/design.md) 在 2026 年 11 月加入了 `## Motion & Micro-interaction` 章节和 `motion` token(`duration`、`delay`、`timingFunction`)。两份文件的分工因此是:

| 共享约定 | `DESIGN.md` | `MOTION.md` |
| --- | --- | --- |
| 可移植项目文档 | 视觉身份 | 运动图形与前端动画意图、时序行为 |
| YAML front matter | 精确设计 Token | 精确状态、事件、时间线与预算 |
| Markdown 正文 | 视觉设计理由 | 动画意图说明、层级与克制 |
| 机器契约 | Schema 与 lint | Schema、lint 与 Motion IR |
| Agent 工作流 | 读取、校验、导出 | 读取、校验、归一化、比较 |
| 关注点 | 归属 |
| --- | --- |
| 品牌动效基调、时序词汇(`state-change`、`surface-enter` 等 token) | `DESIGN.md` |
| 状态图、事件、编排、打断、降级、性能预算 | `MOTION.md` |
| spring、滚动/指针驱动、程序曲线 | `MOTION.md`(DESIGN.md 无对应) |

`MOTION.md` 通过 `design: DESIGN.md` 绑定,用 `timing: "{motion.surface-enter}"` 引用 token,不再重复写 250ms 和贝塞尔曲线。引用会在 Motion IR 中解析为具体数值,并记录 `DESIGN.md` 的 hash,所以 token 一改,`motionmd diff` 就能看到。轨道上的字面值如果恰好等于某个 token,lint 会给出 `prefer-design-token` 提示。

两个格式互补但不嵌套。`DESIGN.md` 负责视觉身份与设计系统数值;`MOTION.md` 负责状态变化、时间、中断、Reduced Motion 与性能。工具可以同时消费二者,而不需要其中一个规范重新定义另一个。
两种格式共用同一套文档约定:front matter 或穿插 YAML 块、`##` 章节、`omitted`、`{…}` token 引用、`` `@path#fragment` `` 外部引用。完整示例见 [`examples/design-bound`](examples/design-bound)。

消费者边界详见 [`docs/interoperability.md`](docs/interoperability.md)。

Expand All @@ -204,7 +207,7 @@ runtime adapter → evidence and QA

## 当前状态

`MOTION.md` 格式目前为 `0.1` 草案。规范、JSON Schema、Motion IR 与 CLI 已可用于评估;v1.0 之前仍可能发生不兼容变化。
`MOTION.md` 格式目前为 `0.2` 草案。规范、JSON Schema、Motion IR 与 CLI 已可用于评估;v1.0 之前仍可能发生不兼容变化。

仓库使用 MIT License 开源。包暂时保留 `private` 标记,仅用于避免分发契约仍在演进时被误发布到 npm。

Expand Down
21 changes: 17 additions & 4 deletions docs/interoperability.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,22 @@

## DESIGN.md

`DESIGN.md` describes visual identity and design rationale. `MOTION.md` describes behavior in time. A product may use either or both.
Since November 2026, `DESIGN.md` has its own `## Motion & Micro-interaction` section and `motion` tokens (`duration`, `delay`, `timingFunction`). The split is:

`MOTION.md` MAY refer to semantic concepts established by `DESIGN.md` in prose or namespaced extensions. It MUST NOT duplicate color, typography, spacing, component, or other visual-token systems as a competing source of truth. The v0.1 core defines no cross-file reference syntax; consumers own resolution and conflict reporting.
| Concern | Owner |
| --- | --- |
| Brand motion tone ("quick and understated", "nothing loops") | `DESIGN.md` prose |
| Timing vocabulary: purpose-named durations, delays, easing | `DESIGN.md` `motion` tokens |
| Which states change, and on which event | `MOTION.md` |
| Which targets and properties move, and in what order | `MOTION.md` timelines |
| Interruption and cancellation | `MOTION.md` |
| Reduced-motion substitutions and what they preserve | `MOTION.md` |
| Performance budgets and deterministic playback | `MOTION.md` |
| Springs, scroll/pointer drivers, procedural curves | `MOTION.md` (no `DESIGN.md` equivalent) |

`MOTION.md` binds to a `DESIGN.md` with `design` and references its tokens with `timing: "{motion.<token>}"` (spec section 7). It MUST NOT restate token values, and it MUST NOT duplicate color, typography, spacing, component, or other visual tokens. A project with only `DESIGN.md` motion tokens has a vocabulary but no behavior contract; a project with only `MOTION.md` declares its own curves locally.

The two files use the same document conventions so one toolchain can read both: YAML front matter or interleaved ` ```yaml ` blocks, `##` sections, `omitted`, `{…}` token references, and `` `@path#fragment` `` external references resolved from the file's own directory.

## Designer Pipeline

Expand All @@ -22,9 +35,9 @@ The Pipeline MUST consume parsed Motion IR rather than maintaining a divergent p

```json
{
"motionSpec": "0.1",
"motionSpec": "0.2",
"schema": "schemas/motion.schema.json",
"requiredIr": "0.1"
"requiredIr": "0.2"
}
```

Expand Down
Loading
Loading