Skip to content

Commit 7b11fb6

Browse files
author
DavidQ
committed
Updates to documentation
1 parent 4d4a3df commit 7b11fb6

2 files changed

Lines changed: 72 additions & 1 deletion

File tree

docs/dev/roadmaps/MASTER_ROADMAP_SAMPLES2TOOLS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
- [ ] Validate end-to-end parity for the slice (sample load + tool preload + visible content match).
7878

7979
### Phase 1 - Foundation + One Vertical Slice
80-
- [.] Add shared adapter guidance document for sample-to-tool loading.
80+
- [x] Add shared adapter guidance document for sample-to-tool loading.
8181
- [x] Implement one full reference flow:
8282
- sample page loads `sample-xxxx.json`
8383
- same file is passed to tool launch
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Samples2Tools Adapter Guidance
2+
3+
## Purpose
4+
- Define one shared launch and hydration pattern so a sample preset can load into tools without per-tool URL conventions.
5+
- Keep the source of truth in sample JSON files (`samples/phase-xx/xxxx/*.json`), not duplicated tool-only payloads.
6+
7+
## Shared Launch Contract
8+
- Query params:
9+
- `sampleId=<id>`
10+
- `samplePresetPath=/samples/phase-xx/xxxx/<tool-or-sample-name>.json`
11+
- Rules:
12+
- Reject empty/invalid paths.
13+
- Normalize path separators to `/`.
14+
- Reject traversal (`..`) in preset paths.
15+
- Allow only sample-local/known-safe relative forms.
16+
17+
## Canonical Preset Shape
18+
- Required:
19+
- `sampleId`
20+
- `phase`
21+
- `title`
22+
- `description`
23+
- `toolHints`
24+
- `payload`
25+
- Optional:
26+
- `runtime`
27+
- `toolState`
28+
- `provenance`
29+
30+
## Adapter Pattern (Per Tool)
31+
- Steps:
32+
1. Read `samplePresetPath` and `sampleId` from `window.location.search`.
33+
2. Fetch preset JSON with `{ cache: "no-store" }`.
34+
3. Extract tool-relevant block from `payload` (or fallback to direct tool document shape when intentionally supported).
35+
4. Validate/minimally sanitize into tool schema.
36+
5. Apply to tool state.
37+
6. Emit user status text: `Loaded preset from sample <id>.` (or path fallback).
38+
39+
## Reference Implementations
40+
- Parallax Scene Studio:
41+
- `extractParallaxDocumentFromSamplePreset(...)`
42+
- `tryLoadPresetFromQuery(...)`
43+
- File: `tools/Parallax Scene Studio/main.js`
44+
45+
- Tilemap Studio:
46+
- `extractTileMapDocumentFromSamplePreset(...)`
47+
- `tryLoadPresetFromQuery(...)`
48+
- File: `tools/Tilemap Studio/main.js`
49+
50+
- Vector Asset Studio:
51+
- `extractVectorAssetPresetFromSamplePreset(...)`
52+
- `tryLoadPresetFromQuery(...)`
53+
- File: `tools/Vector Asset Studio/main.js`
54+
55+
## Data Rules
56+
- Do not use `imageDataUrl` in persisted sample/tool/workspace JSON.
57+
- Persist path/file references only (for example `imageName`, `imageSource`, SVG path fields).
58+
- Keep sample assets local to the sample folder whenever practical.
59+
60+
## Validation Checklist
61+
- Sample page consumes the same JSON it passes to tools.
62+
- Tool load succeeds from `samplePresetPath` without manual edits.
63+
- Tool shows loaded source status with sample id/path.
64+
- Direct launch (without preset params) still works.
65+
- No coupling to Phase 20 preset lanes.
66+
67+
## Current Verified Vertical Slice
68+
- Sample `1208`:
69+
- shared preset file exists
70+
- roundtrip links pass `sampleId` + `samplePresetPath`
71+
- Parallax, Tilemap, and Vector Asset Studio implement query preload adapters

0 commit comments

Comments
 (0)