Files
magic-factorio/tasks/recipe-editor-plan.md

3.1 KiB

Implementation Plan: Planner Recipe Workbench

Overview

Build a local, planner-facing recipe workbench whose JSON book becomes the shared authority for item, machine, and recipe balance. It must make the dependency tree understandable, allow safe edits without touching code, report broken references and loops immediately, and save recoverable revisions back into the project.

Architecture decisions

  • data/recipe-book.json is the editable authority; the browser interface does not hide a second copy.
  • The editor is dependency-free HTML/CSS/JavaScript so the planner can launch it with one Windows shortcut.
  • A localhost-only helper saves to the fixed data path and creates a timestamped backup before replacement.
  • Import/export remains available when the helper is not running.
  • The graph is generated from item-to-recipe and recipe-to-item references; positions are presentation state, not balance data.
  • All mutations pass through one command history so undo/redo, validation, autosave draft, and dirty-state reporting stay consistent.

Task list

Phase 1: Authority data

  • Define the recipe-book schema
  • Seed a complete first-warp recipe path and representative postgame exchanges
  • Add structural and balance validation rules

Checkpoint: Data

  • Every recipe input/output references an existing item
  • Every recipe machine, biome, stage, and unlock technology is known
  • First-warp production has a traceable upstream route

Phase 2: Planner interface

  • Add searchable item/recipe/machine navigation
  • Add focus and full-tree graph views with pan, zoom, and selection
  • Add editable inspector forms and repeatable input/output rows
  • Add route summaries and issue navigation

Checkpoint: Editing

  • Changing an amount updates the tree and balance summary immediately
  • Adding or deleting a reference cannot fail silently
  • Undo/redo restores complete book states

Phase 3: Persistence and handoff

  • Add one-click Windows launcher and local save endpoint
  • Create backups on every direct save
  • Add JSON import/export and draft recovery
  • Document the planner workflow

Checkpoint: Complete

  • Browser interaction and visual layout verified at desktop and narrow widths
  • Direct save followed by reload returns identical data
  • Automated tests cover schema, references, cycles, and critical first-warp ingredients

Risks and mitigations

Risk Impact Mitigation
Large global graph becomes unreadable High Default to selected-node neighborhood; keep full tree as an explicit mode
Planner accidentally breaks runtime IDs High Warn before ID rename, update references automatically, and validate before save
Browser storage is mistaken for a real save High Persistent dirty indicator; direct save or exported file is the only committed state
Random recipes cannot fit ordinary amount fields High Outputs support amount, min/max, chance, and weight in one schema
Tool data diverges from the game High Runtime integration must consume the same JSON or generated resources from it