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

65 lines
3.1 KiB
Markdown

# 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
- [x] Define the recipe-book schema
- [x] Seed a complete first-warp recipe path and representative postgame exchanges
- [x] Add structural and balance validation rules
### Checkpoint: Data
- [x] Every recipe input/output references an existing item
- [x] Every recipe machine, biome, stage, and unlock technology is known
- [x] First-warp production has a traceable upstream route
### Phase 2: Planner interface
- [x] Add searchable item/recipe/machine navigation
- [x] Add focus and full-tree graph views with pan, zoom, and selection
- [x] Add editable inspector forms and repeatable input/output rows
- [x] Add route summaries and issue navigation
### Checkpoint: Editing
- [x] Changing an amount updates the tree and balance summary immediately
- [x] Adding or deleting a reference cannot fail silently
- [x] Undo/redo restores complete book states
### Phase 3: Persistence and handoff
- [x] Add one-click Windows launcher and local save endpoint
- [x] Create backups on every direct save
- [x] Add JSON import/export and draft recovery
- [x] Document the planner workflow
### Checkpoint: Complete
- [x] Browser interaction and visual layout verified at desktop and narrow widths
- [x] Direct save followed by reload returns identical data
- [x] 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 |