Skip to content

feat(flow-schema): add flow version diff#34

Merged
wavekat-eason merged 1 commit into
mainfrom
feat/flow-version-diff
Jul 20, 2026
Merged

feat(flow-schema): add flow version diff#34
wavekat-eason merged 1 commit into
mainfrom
feat/flow-version-diff

Conversation

@wavekat-eason

Copy link
Copy Markdown
Contributor

What

Adds diffFlows(before, after) to @wavekat/flow-schema — a structural, authoring-only diff between two flows answering "what changed since the last publish?". TS-only, like mutate.ts (the engine never diffs, so no Rust twin).

Motivating consumer: the platform flow editor wants to highlight which nodes have unpublished changes and show, per node, what's different. Today the only signal is the server's byte-compare draftDirty boolean, which carries no per-node info and false-positives on formatting/stamp churn.

Shape

diffFlows(before, after) -> FlowDiff {
  nodes: Record<id, { status: 'added'|'removed'|'modified'|'unchanged', kind, changes }>
  added / removed / modified: string[]     // sorted
  entryChanged, entryBefore, entryAfter
  changed: boolean
}

Each modified node carries FieldChange[] with dot-paths — top-level fields (prompt, timeout_secs), per-exit (exits.no_answer), per-menu-option (options.1), and a synthetic entry when the start marker moves. Raw before/after values only; labels/colours stay with consumers.

Design

  • Structural, not textual — compares decoded Flow objects, so comment/key-order churn and the flow-level stamps publish rewrites (version, id, name, ui) never register.
  • Entry move shows on both nodes — old and new start node each get an entry change, so a UI highlights exactly what visually moved.
  • Object keys compared order-insensitively; arrays (schedule ranges, exceptions) order-sensitively.

Tests

test/diff.test.ts — 11 cases: added / removed / modified, exit rewire, menu option relabel, prompt change, entry move, structural-equality (comment + key reorder), stamp-ignore, added optional field. Full package suite: 99/99 green; typecheck + build clean, so prepublishOnly passes.

Release

Ships as @wavekat/flow-schema 0.0.8 via release-please on merge. The platform then bumps its dep and wires the presentation layer.

🤖 Generated with Claude Code

Add diffFlows(before, after): a structural, authoring-only diff between
two flows for "what changed since the last publish?". Compares decoded
Flow objects, so comment/key-order churn and the flow-level stamps
publish rewrites (version, id, name, ui) never register — only added,
removed, and edited nodes, and a moved entry.

Each modified node carries field-level changes with dot-paths: top-level
fields, per-exit (exits.no_answer), per-menu-option (options.1), and a
synthetic entry pseudo-field when the start marker moves. Raw before/after
values only; presentation (labels, colours) stays with consumers.

TS-only, like mutate.ts — the engine never diffs, so no Rust twin.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@wavekat-eason
wavekat-eason merged commit 218802e into main Jul 20, 2026
3 checks passed
@wavekat-eason
wavekat-eason deleted the feat/flow-version-diff branch July 20, 2026 10:34
@github-actions github-actions Bot mentioned this pull request Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant