|
| 1 | +# Asset Browser / Import Hub Reengineering Design (asset-browser) |
| 2 | + |
| 3 | +## Purpose |
| 4 | +- Approved asset browsing and non-destructive import planning surface for vectors, palettes, parallax, tilemaps, and sprite workflow assets. |
| 5 | + |
| 6 | +## Current V1 Capability |
| 7 | +- Active in registry-driven tools surface. |
| 8 | +- Runtime entry point: `Asset Browser/index.html`. |
| 9 | +- Runtime implementation file: `tools/Asset Browser/main.js`. |
| 10 | + |
| 11 | +## Current V2 / Workspace Status |
| 12 | +- Legacy/first-class tool present in registry; not fully mapped into Workspace V2 toolState lane. |
| 13 | +- Workspace integration classification: |
| 14 | + - global tool: no |
| 15 | + - toolState-capable tool: no |
| 16 | + - published `tools.*` output candidate: yes |
| 17 | +- Readiness: Needs additional schema/contract alignment |
| 18 | + |
| 19 | +## Expected JSON Schema/Input |
| 20 | +- Schema ref: `tools/schemas/tools/asset-browser.schema.json`. Required root keys: `assets`. Defined root properties: `assets`, `assetBrowserPreset`, `approvedAssets`, `importHubPreset`. |
| 21 | + |
| 22 | +## Valid JSON Load Behavior (Target) |
| 23 | +- Parse incoming tool payload once. |
| 24 | +- Validate against the tool schema/contract before rendering. |
| 25 | +- Render the fully valid state and expose clear contract readout text. |
| 26 | + |
| 27 | +## Invalid JSON Rejection Behavior (Target) |
| 28 | +- Reject before rendering domain state. |
| 29 | +- Show one clear actionable invalid message. |
| 30 | +- Avoid fallback/default injections and avoid mutating inbound payload structure. |
| 31 | + |
| 32 | +## Current Components/Functions |
| 33 | +- Top-level functions: `normalizeSamplePresetPath()`, `buildPresetLoadedStatus()`, `setAssetBrowserLifecycle()`, `ensureFirstVisibleAssetSelection()`, `syncAssetBrowserUxContract()`, `sanitizeText()`, `normalizeSampleId()`, `normalizeToolId()`, `normalizeLocalPath()`, `toTitleCase()`, `humanizeAssetId()`, `normalizeExplicitCatalogPath()`, `findCompanionPresetPath()`, `extractCompanionAssetPayload()`, `mapCompanionPresetToEntries()`, `readActiveProjectManifest()`, `collectCatalogPathCandidates()`, `mapKindToCategory()`, `normalizeCatalogEntries()`, `normalizePresetAssetEntries()`, `extractAssetBrowserCatalogFromPreset()`, `inferAssetKindFromPath()`, `normalizeManifestAssetEntries()`, `normalizeManifestToolAssetEntries()`, `inspectManifestAssetBrowserSource()`, `classifyApprovedAssetState()`, `emitAssetBrowserControlReadiness()`, `buildApprovedAssetStatusText()`, `buildApprovedAssetEmptyStateText()`, `getActiveAssetEmptyStateMessage()`, `getCategoryOrder()`, `extractAssetBrowserPreset()`, `applyAssetBrowserPreset()`, `resolveInitialSelectedAssetId()`, `getAssetTypeFromCategory()`, `applyLaunchContext()`, `getVisibleAssets()`, `getSelectedAsset()`, `getPathExtension()`, `populateCategoryControls()`, `populateDestinationOptions()`, `renderAssetList()`, `inferCategoryFromFileName()`, `normalizeImportName()`, `buildImportPlan()`, `renderImportPlan()`, `downloadImportPlan()`, `useSelectedAssetInActiveTool()`, `syncImportFormFromFile()`, `bindEvents()`, `bootAssetBrowser()`. |
| 34 | + |
| 35 | +## Target Components/Functions |
| 36 | +- Separate explicit JSON contract functions (`import`, `validate`, `load`, `export`) from view-only rendering methods. |
| 37 | +- Keep tool-specific logic inside the tool runtime; avoid Workspace V2 owning tool-specific compare/merge/edit behavior. |
| 38 | +- Keep one visible invalid-state path that blocks render before any partial state draws. |
| 39 | + |
| 40 | +## Tool-Owned JSON Functions |
| 41 | +- Import: `buildPresetLoadedStatus()`, `extractCompanionAssetPayload()`, `readActiveProjectManifest()`, `emitAssetBrowserControlReadiness()`, `normalizeImportName()`, `buildImportPlan()`, `renderImportPlan()`, `downloadImportPlan()`, `syncImportFormFromFile()` |
| 42 | +- Validate: `normalizeSamplePresetPath()`, `sanitizeText()`, `normalizeSampleId()`, `normalizeToolId()`, `normalizeLocalPath()`, `normalizeExplicitCatalogPath()`, `normalizeCatalogEntries()`, `normalizePresetAssetEntries()`, `normalizeManifestAssetEntries()`, `normalizeManifestToolAssetEntries()`, `normalizeImportName()` |
| 43 | +- Edit/process: `applyAssetBrowserPreset()`, `applyLaunchContext()`, `renderAssetList()`, `renderImportPlan()` |
| 44 | +- Export: `downloadImportPlan()` |
| 45 | +- Add/copy to Workspace toolState: Not yet explicit in current tool runtime. |
| 46 | +- Publish to `tools.asset-browser`: Supported as target ownership in design; concrete publish path varies by tool. |
| 47 | +- Compare/merge for own schema: Not currently tool-local; Workspace V2 has cross-toolState compare/merge UI today. |
| 48 | + |
| 49 | +## Workspace Integration Contract |
| 50 | +- Workspace launch path exists via tools index/workspace-manager registry entry points. |
| 51 | +- Explicit Workspace V2 toolState contract is not yet completed for this tool. |
| 52 | + |
| 53 | +## Playwright Expectations |
| 54 | +- Valid payload path should show visible valid-state surface. |
| 55 | +- Invalid payload path should show visible invalid-state surface and hide valid state. |
| 56 | +- Workspace launch handoff should open the tool with hostContext/toolState payload when applicable. |
| 57 | + |
| 58 | +## Manual Test Expectations |
| 59 | +- Launch from `tools/index.html` and confirm baseline UI renders. |
| 60 | +- Launch from Workspace V2 when applicable and confirm payload handoff path. |
| 61 | +- Provide an invalid JSON contract and confirm the tool blocks render with explicit error. |
| 62 | + |
| 63 | +## Known Gaps |
| 64 | +- Tool is not fully in the current Workspace V2 toolState-capable Playwright lane. |
0 commit comments