@kruschdev/pascal-plugin-mit-assets 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ASSETS.md +298 -0
- package/LICENSE +21 -0
- package/README.md +71 -2
- package/dist/agent-operations.d.ts +8 -0
- package/dist/agent-operations.js +305 -0
- package/dist/agent-tools.d.ts +7 -0
- package/dist/agent-tools.js +128 -0
- package/dist/audit.d.ts +78 -0
- package/dist/bin/pascal-mit-assets.js +5238 -0
- package/dist/bom.d.ts +123 -0
- package/dist/cad/appliance-mep-builders.d.ts +7 -0
- package/dist/cad/furniture-builders.d.ts +9 -0
- package/dist/cad/index.d.ts +48 -0
- package/dist/cad/index.js +23 -0
- package/dist/cad/kitchen-bath-builders.d.ts +9 -0
- package/dist/cad/outdoor-fenestration-builders.d.ts +8 -0
- package/dist/cad/primitives.d.ts +56 -0
- package/dist/cad/props-vehicles-builders.d.ts +8 -0
- package/dist/chunk-2qgndrap.js +5200 -0
- package/dist/chunk-6hzyh6qv.js +346 -0
- package/dist/chunk-f72r2bmp.js +84 -0
- package/dist/chunk-hqgm57dv.js +310 -0
- package/dist/chunk-kgwk6kan.js +150 -0
- package/dist/chunk-raafkn3w.js +286 -0
- package/dist/chunk-vzmjt9dz.js +4380 -0
- package/dist/chunk-xhkwv6t4.js +5080 -0
- package/dist/hdri/index.d.ts +1 -0
- package/dist/hdri/index.js +322 -0
- package/dist/hdri/sky.d.ts +26 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.js +198 -0
- package/dist/manifest.d.ts +46 -0
- package/dist/materials/index.d.ts +10 -0
- package/dist/materials/index.js +1464 -0
- package/dist/materials/ktx2.d.ts +10 -0
- package/dist/materials/noise.d.ts +89 -0
- package/dist/materials/patterns.d.ts +15 -0
- package/dist/nodes/mit-item.d.ts +76 -0
- package/dist/render.d.ts +10 -0
- package/dist/render.js +24 -0
- package/dist/scripts/build-assets.js +17129 -0
- package/dist/sfx/index.d.ts +1 -0
- package/dist/sfx/index.js +1223 -0
- package/dist/sfx/synth.d.ts +25 -0
- package/dist/sku-crosswalk.d.ts +46 -0
- package/dist/ui/chat-card.d.ts +7 -0
- package/dist/ui/host-panel.d.ts +1 -0
- package/dist/ui/inspector-card.d.ts +4 -0
- package/dist/ui/schedule-view.d.ts +1 -0
- package/package.json +135 -4
- package/src/agent-operations.ts +373 -0
- package/src/agent-tools.ts +136 -0
- package/src/audit.ts +356 -0
- package/src/bom.ts +512 -0
- package/src/cad/appliance-mep-builders.ts +1336 -0
- package/src/cad/furniture-builders.ts +1622 -0
- package/src/cad/index.ts +993 -0
- package/src/cad/kitchen-bath-builders.ts +1189 -0
- package/src/cad/outdoor-fenestration-builders.ts +1499 -0
- package/src/cad/primitives.ts +286 -0
- package/src/cad/props-vehicles-builders.ts +1065 -0
- package/src/hdri/index.ts +5 -0
- package/src/hdri/sky.ts +481 -0
- package/src/index.ts +127 -0
- package/src/manifest.ts +5296 -0
- package/src/materials/index.ts +56 -0
- package/src/materials/ktx2.ts +138 -0
- package/src/materials/noise.ts +417 -0
- package/src/materials/patterns.ts +1507 -0
- package/src/nodes/mit-item.ts +163 -0
- package/src/render.ts +25 -0
- package/src/sfx/index.ts +6 -0
- package/src/sfx/synth.ts +1495 -0
- package/src/sku-crosswalk.ts +3868 -0
- package/src/ui/chat-card.tsx +93 -0
- package/src/ui/host-panel.tsx +330 -0
- package/src/ui/inspector-card.tsx +213 -0
- package/src/ui/schedule-view.tsx +188 -0
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure Zod-only Agent Tool Contracts (`@kruschdev/pascal-plugin-mit-assets/agent-tools`).
|
|
3
|
+
* Conforms to Pascal DECISIONS.md E-016: zero Three.js, React, viewer, or editor imports.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { PluginAgentTools } from '@pascal-app/core/agent-tools'
|
|
7
|
+
import { z } from 'zod'
|
|
8
|
+
import { MIT_ITEM_SPECS, MIT_MATERIAL_SPECS, MIT_SFX_SPECS } from './manifest'
|
|
9
|
+
|
|
10
|
+
const ITEM_CATEGORIES = [
|
|
11
|
+
'furniture',
|
|
12
|
+
'appliance',
|
|
13
|
+
'bathroom',
|
|
14
|
+
'kitchen',
|
|
15
|
+
'outdoor',
|
|
16
|
+
'architectural',
|
|
17
|
+
] as const
|
|
18
|
+
|
|
19
|
+
const MATERIAL_CATEGORIES = [
|
|
20
|
+
'concrete',
|
|
21
|
+
'fabric',
|
|
22
|
+
'flooring',
|
|
23
|
+
'leather',
|
|
24
|
+
'metal',
|
|
25
|
+
'roofing',
|
|
26
|
+
'siding',
|
|
27
|
+
'wood',
|
|
28
|
+
] as const
|
|
29
|
+
|
|
30
|
+
const Vec3 = z.tuple([z.number().finite(), z.number().finite(), z.number().finite()])
|
|
31
|
+
|
|
32
|
+
export const mitAssetsAgentTools: PluginAgentTools = {
|
|
33
|
+
pluginId: 'krusch:mit-assets',
|
|
34
|
+
apiVersion: 1,
|
|
35
|
+
version: '0.1.0',
|
|
36
|
+
instructions:
|
|
37
|
+
`100% clean-room MIT asset replacement plugin solving pascalorg/editor#1327: ${MIT_ITEM_SPECS.length} parametric 3D procedural items, ${MIT_MATERIAL_SPECS.length} procedural PBR material packs (.ktx2/.webp), ${MIT_SFX_SPECS.length} synthesized DSP SFX cues, and procedural Radiance RGBE sunset HDRI.`,
|
|
38
|
+
skills: [
|
|
39
|
+
{
|
|
40
|
+
name: 'mit-commercial-asset-migration',
|
|
41
|
+
summary:
|
|
42
|
+
'Audit a Pascal scene for non-MIT Supabase/bundled assets and replace them with 100% MIT procedural nodes or drop-in asset URLs',
|
|
43
|
+
body: [
|
|
44
|
+
'1. Call `mit_audit_scene` to scan the active scene for external Supabase or unattributed bundled asset URLs.',
|
|
45
|
+
'2. Call `mit_search_items` or `mit_list_materials` to inspect the 155 MIT 3D items and 68 MIT PBR material packs.',
|
|
46
|
+
'3. Call `mit_place_item` to insert a clean-room MIT procedural `mit-assets:item` node directly into a level.',
|
|
47
|
+
'4. Call `mit_replace_scene_items` to convert existing Supabase/bundled `item` nodes into clean-room MIT `mit-assets:item` nodes in a single undo step.',
|
|
48
|
+
].join('\n'),
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
tools: [
|
|
52
|
+
{
|
|
53
|
+
name: 'mit_search_items',
|
|
54
|
+
title: `Search ${MIT_ITEM_SPECS.length} clean-room MIT 3D items`,
|
|
55
|
+
description:
|
|
56
|
+
'Search all 155 clean-room MIT procedural 3D item replacements matching Pascal Editor items/ and CATALOG_ITEMS.',
|
|
57
|
+
runsIn: 'operation',
|
|
58
|
+
input: {
|
|
59
|
+
query: z.string().default(''),
|
|
60
|
+
category: z.enum(ITEM_CATEGORIES).optional(),
|
|
61
|
+
limit: z.number().int().min(1).max(200).default(50),
|
|
62
|
+
},
|
|
63
|
+
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true },
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: 'mit_list_materials',
|
|
67
|
+
title: `List ${MIT_MATERIAL_SPECS.length} clean-room MIT PBR material packs`,
|
|
68
|
+
description:
|
|
69
|
+
'List procedural PBR texture packs (albedo, normal, roughness, AO, metallic) replacing apps/editor/public/material/.',
|
|
70
|
+
runsIn: 'operation',
|
|
71
|
+
input: {
|
|
72
|
+
category: z.enum(MATERIAL_CATEGORIES).optional(),
|
|
73
|
+
query: z.string().default(''),
|
|
74
|
+
},
|
|
75
|
+
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true },
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: 'mit_audit_scene',
|
|
79
|
+
title: 'Audit scene for non-MIT / external Supabase assets',
|
|
80
|
+
description:
|
|
81
|
+
'Scan every node in the active Pascal scene to detect external Supabase URLs or bundled unlicensed assets and report 1:1 MIT replacements.',
|
|
82
|
+
runsIn: 'operation',
|
|
83
|
+
input: {
|
|
84
|
+
mitBaseUrl: z.string().default(''),
|
|
85
|
+
},
|
|
86
|
+
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true },
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: 'mit_place_item',
|
|
90
|
+
title: 'Place a clean-room MIT procedural 3D item',
|
|
91
|
+
description:
|
|
92
|
+
'Insert a self-contained clean-room MIT `mit-assets:item` node (zero external GLB fetch required) on a level.',
|
|
93
|
+
runsIn: 'operation',
|
|
94
|
+
input: {
|
|
95
|
+
levelId: z.string().optional(),
|
|
96
|
+
slug: z.string().min(1).default('sofa'),
|
|
97
|
+
name: z.string().optional(),
|
|
98
|
+
position: Vec3.optional(),
|
|
99
|
+
rotation: z.number().finite().default(0),
|
|
100
|
+
widthM: z.number().finite().min(0.04).max(20).optional(),
|
|
101
|
+
heightM: z.number().finite().min(0.01).max(20).optional(),
|
|
102
|
+
depthM: z.number().finite().min(0.02).max(20).optional(),
|
|
103
|
+
accentColor: z.string().regex(/^#[0-9a-fA-F]{6}$/).optional(),
|
|
104
|
+
},
|
|
105
|
+
annotations: { destructiveHint: false, idempotentHint: false },
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
name: 'mit_replace_scene_items',
|
|
109
|
+
title: 'Replace non-MIT item nodes with clean-room MIT nodes',
|
|
110
|
+
description:
|
|
111
|
+
'Convert scene `item` nodes referencing Pascal Supabase or bundled /items/ GLBs into clean-room MIT `mit-assets:item` nodes (preserving position, rotation, dimensions, and parent level).',
|
|
112
|
+
runsIn: 'operation',
|
|
113
|
+
input: {
|
|
114
|
+
dryRun: z.boolean().default(false),
|
|
115
|
+
mitBaseUrl: z.string().default(''),
|
|
116
|
+
},
|
|
117
|
+
annotations: { destructiveHint: true, idempotentHint: true },
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
name: 'mit_schedule_bom',
|
|
121
|
+
title: 'Generate priced Real-SKU CSI BOM & CSV for MIT assets',
|
|
122
|
+
description:
|
|
123
|
+
'Compile placed mit-assets:item nodes (and optional mapped Pascal items + material quantities) into a real-world SKU priced BOM, pascal-bom/1.1 fragment, and formula-safe CSV.',
|
|
124
|
+
runsIn: 'operation',
|
|
125
|
+
input: {
|
|
126
|
+
markupPct: z.number().finite().min(0).max(100).default(0),
|
|
127
|
+
salesTaxPct: z.number().finite().min(0).max(25).default(0),
|
|
128
|
+
includeMappedPascalItems: z.boolean().default(true),
|
|
129
|
+
includeCsv: z.boolean().default(true),
|
|
130
|
+
},
|
|
131
|
+
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true },
|
|
132
|
+
},
|
|
133
|
+
],
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export default mitAssetsAgentTools
|
package/src/audit.ts
ADDED
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure headless MIT Asset Provenance & Commercial Readiness Audit (`src/audit.ts`).
|
|
3
|
+
* Scans any Pascal scene graph to identify non-MIT / external Supabase / unattributed
|
|
4
|
+
* asset URLs and maps them 1:1 to clean-room MIT replacements in `@kruschdev/pascal-plugin-mit-assets`.
|
|
5
|
+
*
|
|
6
|
+
* Strictly pure TypeScript: zero React, Three.js, viewer, editor, or node:* imports.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
MIT_HDRI_SPEC,
|
|
11
|
+
MIT_ITEM_SPECS,
|
|
12
|
+
MIT_MATERIAL_SPECS,
|
|
13
|
+
MIT_SFX_SPECS,
|
|
14
|
+
type MitItemSpec,
|
|
15
|
+
getMitItemSpec,
|
|
16
|
+
} from './manifest'
|
|
17
|
+
|
|
18
|
+
export type MitAuditFindingSeverity = 'info' | 'warning' | 'action-required'
|
|
19
|
+
|
|
20
|
+
export type MitAuditFinding = {
|
|
21
|
+
readonly nodeId: string
|
|
22
|
+
readonly nodeType: string
|
|
23
|
+
readonly severity: MitAuditFindingSeverity
|
|
24
|
+
readonly code:
|
|
25
|
+
| 'EXTERNAL_SUPABASE_ASSET'
|
|
26
|
+
| 'BUNDLED_UNLICENSED_ITEM'
|
|
27
|
+
| 'BUNDLED_UNLICENSED_MATERIAL'
|
|
28
|
+
| 'MIT_PROCEDURAL_NODE'
|
|
29
|
+
| 'UNMAPPED_CUSTOM_URL'
|
|
30
|
+
readonly currentUrl: string
|
|
31
|
+
readonly matchedSlug?: string
|
|
32
|
+
readonly mitReplacementUrl?: string
|
|
33
|
+
readonly message: string
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export type MitSceneAuditSummary = {
|
|
37
|
+
readonly totalNodesScanned: number
|
|
38
|
+
readonly mitCleanCount: number
|
|
39
|
+
readonly replaceableCount: number
|
|
40
|
+
readonly unmappedCount: number
|
|
41
|
+
readonly commercialReady: boolean
|
|
42
|
+
readonly findings: readonly MitAuditFinding[]
|
|
43
|
+
readonly inventory: {
|
|
44
|
+
readonly items: number
|
|
45
|
+
readonly materials: number
|
|
46
|
+
readonly sfx: number
|
|
47
|
+
readonly hdri: number
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export type MitCatalogItemEntry = {
|
|
52
|
+
readonly id: string
|
|
53
|
+
readonly slug: string
|
|
54
|
+
readonly category: string
|
|
55
|
+
readonly name: string
|
|
56
|
+
readonly tags: readonly string[]
|
|
57
|
+
readonly thumbnail: string
|
|
58
|
+
readonly src: string
|
|
59
|
+
readonly floorPlanUrl: string
|
|
60
|
+
readonly dimensions: readonly [number, number, number]
|
|
61
|
+
readonly offset: readonly [number, number, number]
|
|
62
|
+
readonly rotation: readonly [number, number, number]
|
|
63
|
+
readonly scale: readonly [number, number, number]
|
|
64
|
+
readonly attachTo?: 'wall' | 'wall-side' | 'ceiling'
|
|
65
|
+
readonly surface?: { readonly height: number }
|
|
66
|
+
readonly license: 'MIT'
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const SUPABASE_HOST_RE = /supabase\.co\/storage\/v1\/object\/public\/items\/system\/([^/]+)\//i
|
|
70
|
+
const LOCAL_ITEM_PATH_RE = /(?:^|\/)items\/([^/]+)\/model\.glb(?:\?.*)?$/i
|
|
71
|
+
const MATERIAL_PATH_RE = /(?:^|\/)material\/([^/]+\/[^/]+)\//i
|
|
72
|
+
const SIDING_PATH_RE = /(?:^|\/)material\/siding\/(batten|lap)_/i
|
|
73
|
+
|
|
74
|
+
export function normalizeBaseUrl(baseUrl: string): string {
|
|
75
|
+
const trimmed = baseUrl.trim()
|
|
76
|
+
if (!trimmed || trimmed === '/') return ''
|
|
77
|
+
return trimmed.replace(/\/+$/, '')
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function resolveMitItemUrl(slug: string, baseUrl = ''): string {
|
|
81
|
+
const base = normalizeBaseUrl(baseUrl)
|
|
82
|
+
return `${base}/items/${slug}/model.glb`
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function resolveMitThumbnailUrl(slug: string, baseUrl = ''): string {
|
|
86
|
+
const base = normalizeBaseUrl(baseUrl)
|
|
87
|
+
return `${base}/items/${slug}/thumbnail.webp`
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function resolveMitFloorPlanUrl(slug: string, baseUrl = ''): string {
|
|
91
|
+
const base = normalizeBaseUrl(baseUrl)
|
|
92
|
+
return `${base}/items/${slug}/floor-plan.svg`
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Drop-in MIT replacement for `@pascal-app/editor`'s `CATALOG_ITEMS` array.
|
|
97
|
+
* Points every item at self-hosted MIT paths (`${baseUrl}/items/<slug>/...`) instead of Supabase.
|
|
98
|
+
*/
|
|
99
|
+
export function buildMitCatalogItems(
|
|
100
|
+
baseUrl = '',
|
|
101
|
+
includePublicOnly = false,
|
|
102
|
+
): MitCatalogItemEntry[] {
|
|
103
|
+
const list = includePublicOnly
|
|
104
|
+
? MIT_ITEM_SPECS
|
|
105
|
+
: MIT_ITEM_SPECS.filter((s) => s.inCatalogItems)
|
|
106
|
+
|
|
107
|
+
return list.map((spec) => ({
|
|
108
|
+
id: spec.catalogId,
|
|
109
|
+
slug: spec.slug,
|
|
110
|
+
category: spec.category,
|
|
111
|
+
name: spec.name,
|
|
112
|
+
tags: [...spec.tags, 'mit', 'clean-room'],
|
|
113
|
+
thumbnail: resolveMitThumbnailUrl(spec.slug, baseUrl),
|
|
114
|
+
src: resolveMitItemUrl(spec.slug, baseUrl),
|
|
115
|
+
floorPlanUrl: resolveMitFloorPlanUrl(spec.slug, baseUrl),
|
|
116
|
+
dimensions: spec.dimensions,
|
|
117
|
+
offset: [0, 0, 0] as const,
|
|
118
|
+
rotation: [0, 0, 0] as const,
|
|
119
|
+
scale: [1, 1, 1] as const,
|
|
120
|
+
...(spec.attachTo ? { attachTo: spec.attachTo } : {}),
|
|
121
|
+
...(spec.hasSurface && spec.surfaceHeight !== undefined
|
|
122
|
+
? { surface: { height: spec.surfaceHeight } }
|
|
123
|
+
: {}),
|
|
124
|
+
license: 'MIT' as const,
|
|
125
|
+
}))
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export function searchMitItems(
|
|
129
|
+
query = '',
|
|
130
|
+
category?: MitItemSpec['category'],
|
|
131
|
+
limit = 50,
|
|
132
|
+
): MitItemSpec[] {
|
|
133
|
+
const q = query.trim().toLowerCase()
|
|
134
|
+
const out: MitItemSpec[] = []
|
|
135
|
+
for (const spec of MIT_ITEM_SPECS) {
|
|
136
|
+
if (category && spec.category !== category) continue
|
|
137
|
+
if (q) {
|
|
138
|
+
const hay = `${spec.slug} ${spec.catalogId} ${spec.name} ${spec.category} ${spec.tags.join(' ')}`.toLowerCase()
|
|
139
|
+
if (!hay.includes(q)) continue
|
|
140
|
+
}
|
|
141
|
+
out.push(spec)
|
|
142
|
+
if (out.length >= limit) break
|
|
143
|
+
}
|
|
144
|
+
return out
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function extractItemSlugFromUrl(url: string): string | undefined {
|
|
148
|
+
const sup = url.match(SUPABASE_HOST_RE)?.[1]
|
|
149
|
+
if (sup) return sup
|
|
150
|
+
const loc = url.match(LOCAL_ITEM_PATH_RE)?.[1]
|
|
151
|
+
if (loc) return loc
|
|
152
|
+
return undefined
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function extractMaterialPackFromUrl(url: string): string | undefined {
|
|
156
|
+
const siding = url.match(SIDING_PATH_RE)?.[1]
|
|
157
|
+
if (siding) return `siding/${siding}`
|
|
158
|
+
return url.match(MATERIAL_PATH_RE)?.[1]
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const MATERIAL_PACK_SET = new Set(MIT_MATERIAL_SPECS.map((m) => m.id))
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Audits a Pascal scene node map (`Record<string, unknown>`) for non-MIT asset URLs
|
|
165
|
+
* (e.g. Pascal's Supabase item URLs or unattributed `/items/` and `/material/` paths)
|
|
166
|
+
* and computes exact 1:1 clean-room MIT replacement paths.
|
|
167
|
+
*/
|
|
168
|
+
export function auditSceneMitProvenance(
|
|
169
|
+
nodes: Readonly<Record<string, unknown>>,
|
|
170
|
+
mitBaseUrl = '',
|
|
171
|
+
): MitSceneAuditSummary {
|
|
172
|
+
const findings: MitAuditFinding[] = []
|
|
173
|
+
let totalNodesScanned = 0
|
|
174
|
+
let mitCleanCount = 0
|
|
175
|
+
let replaceableCount = 0
|
|
176
|
+
let unmappedCount = 0
|
|
177
|
+
|
|
178
|
+
for (const [nodeId, raw] of Object.entries(nodes)) {
|
|
179
|
+
if (!raw || typeof raw !== 'object') continue
|
|
180
|
+
const node = raw as Record<string, unknown>
|
|
181
|
+
const nodeType = typeof node.type === 'string' ? node.type : 'unknown'
|
|
182
|
+
totalNodesScanned += 1
|
|
183
|
+
|
|
184
|
+
if (nodeType === 'mit-assets:item') {
|
|
185
|
+
mitCleanCount += 1
|
|
186
|
+
findings.push({
|
|
187
|
+
nodeId,
|
|
188
|
+
nodeType,
|
|
189
|
+
severity: 'info',
|
|
190
|
+
code: 'MIT_PROCEDURAL_NODE',
|
|
191
|
+
currentUrl: `procedural://mit-assets/${String(node.slug ?? 'sofa')}`,
|
|
192
|
+
matchedSlug: typeof node.slug === 'string' ? node.slug : undefined,
|
|
193
|
+
message: 'Native clean-room MIT procedural geometry (zero third-party binary assets).',
|
|
194
|
+
})
|
|
195
|
+
continue
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// Check asset.src on Pascal `item` nodes
|
|
199
|
+
const asset = node.asset && typeof node.asset === 'object' ? (node.asset as Record<string, unknown>) : null
|
|
200
|
+
const src = typeof asset?.src === 'string' ? asset.src : typeof node.src === 'string' ? node.src : null
|
|
201
|
+
const normalizedBase = normalizeBaseUrl(mitBaseUrl)
|
|
202
|
+
if (src) {
|
|
203
|
+
const cleanSrc = src.split(/[?#]/, 1)[0] ?? src
|
|
204
|
+
const slug = extractItemSlugFromUrl(cleanSrc)
|
|
205
|
+
const matched = slug ? getMitItemSpec(slug) : undefined
|
|
206
|
+
const isCleanMitUrl =
|
|
207
|
+
Boolean(normalizedBase) &&
|
|
208
|
+
Boolean(matched) &&
|
|
209
|
+
cleanSrc.toLowerCase() === resolveMitItemUrl(matched!.slug, normalizedBase).toLowerCase()
|
|
210
|
+
const procItemMatch = cleanSrc.match(/^procedural:\/\/mit-assets\/([^/]+)$/i)
|
|
211
|
+
const isProceduralMitUrl = Boolean(procItemMatch && getMitItemSpec(procItemMatch[1]!))
|
|
212
|
+
|
|
213
|
+
if (isCleanMitUrl || isProceduralMitUrl) {
|
|
214
|
+
mitCleanCount += 1
|
|
215
|
+
} else if (SUPABASE_HOST_RE.test(cleanSrc)) {
|
|
216
|
+
if (matched) {
|
|
217
|
+
replaceableCount += 1
|
|
218
|
+
findings.push({
|
|
219
|
+
nodeId,
|
|
220
|
+
nodeType,
|
|
221
|
+
severity: 'action-required',
|
|
222
|
+
code: 'EXTERNAL_SUPABASE_ASSET',
|
|
223
|
+
currentUrl: src,
|
|
224
|
+
matchedSlug: matched.slug,
|
|
225
|
+
mitReplacementUrl: normalizedBase
|
|
226
|
+
? resolveMitItemUrl(matched.slug, normalizedBase)
|
|
227
|
+
: `procedural://mit-assets/${matched.slug}`,
|
|
228
|
+
message: `Item references Pascal hosted Supabase GLB (${matched.slug}); replace with clean-room MIT asset or mit-assets:item node.`,
|
|
229
|
+
})
|
|
230
|
+
} else {
|
|
231
|
+
unmappedCount += 1
|
|
232
|
+
findings.push({
|
|
233
|
+
nodeId,
|
|
234
|
+
nodeType,
|
|
235
|
+
severity: 'warning',
|
|
236
|
+
code: 'UNMAPPED_CUSTOM_URL',
|
|
237
|
+
currentUrl: src,
|
|
238
|
+
message: `External Supabase asset URL has no mapped MIT slug: ${src}`,
|
|
239
|
+
})
|
|
240
|
+
}
|
|
241
|
+
} else if (LOCAL_ITEM_PATH_RE.test(cleanSrc) && matched) {
|
|
242
|
+
replaceableCount += 1
|
|
243
|
+
findings.push({
|
|
244
|
+
nodeId,
|
|
245
|
+
nodeType,
|
|
246
|
+
severity: 'warning',
|
|
247
|
+
code: 'BUNDLED_UNLICENSED_ITEM',
|
|
248
|
+
currentUrl: src,
|
|
249
|
+
matchedSlug: matched.slug,
|
|
250
|
+
mitReplacementUrl: normalizedBase
|
|
251
|
+
? resolveMitItemUrl(matched.slug, normalizedBase)
|
|
252
|
+
: `procedural://mit-assets/${matched.slug}`,
|
|
253
|
+
message: `Bundled /items/${matched.slug}/model.glb requires MIT asset pack swap in public/ (issue #1327).`,
|
|
254
|
+
})
|
|
255
|
+
} else {
|
|
256
|
+
unmappedCount += 1
|
|
257
|
+
findings.push({
|
|
258
|
+
nodeId,
|
|
259
|
+
nodeType,
|
|
260
|
+
severity: 'warning',
|
|
261
|
+
code: 'UNMAPPED_CUSTOM_URL',
|
|
262
|
+
currentUrl: src,
|
|
263
|
+
message: `Unattributed or external asset URL has no mapped MIT replacement: ${src}`,
|
|
264
|
+
})
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// Check material texture URLs if present on material/surface nodes (all string map slots)
|
|
269
|
+
const maps =
|
|
270
|
+
node.maps && typeof node.maps === 'object'
|
|
271
|
+
? (node.maps as Record<string, unknown>)
|
|
272
|
+
: node.preset && typeof node.preset === 'object' && (node.preset as Record<string, unknown>).maps
|
|
273
|
+
? ((node.preset as Record<string, unknown>).maps as Record<string, unknown>)
|
|
274
|
+
: null
|
|
275
|
+
if (maps) {
|
|
276
|
+
const seenMapUrls = new Set<string>()
|
|
277
|
+
for (const rawMapUrl of Object.values(maps)) {
|
|
278
|
+
if (typeof rawMapUrl !== 'string' || !rawMapUrl.trim()) continue
|
|
279
|
+
const cleanMapUrl = rawMapUrl.split(/[?#]/, 1)[0] ?? rawMapUrl
|
|
280
|
+
if (seenMapUrls.has(cleanMapUrl)) continue
|
|
281
|
+
seenMapUrls.add(cleanMapUrl)
|
|
282
|
+
|
|
283
|
+
const pack = extractMaterialPackFromUrl(cleanMapUrl)
|
|
284
|
+
if (pack && MATERIAL_PACK_SET.has(pack)) {
|
|
285
|
+
const isProceduralMitMat = cleanMapUrl.toLowerCase().startsWith('procedural://mit-assets/material/')
|
|
286
|
+
if (
|
|
287
|
+
isProceduralMitMat ||
|
|
288
|
+
(normalizedBase &&
|
|
289
|
+
cleanMapUrl.toLowerCase().startsWith(`${normalizedBase.toLowerCase()}/material/`))
|
|
290
|
+
) {
|
|
291
|
+
mitCleanCount += 1
|
|
292
|
+
} else {
|
|
293
|
+
const matIdx = cleanMapUrl.toLowerCase().indexOf('/material/')
|
|
294
|
+
const relPath =
|
|
295
|
+
matIdx >= 0
|
|
296
|
+
? `/material/${cleanMapUrl.slice(matIdx + '/material/'.length)}`
|
|
297
|
+
: cleanMapUrl.startsWith('/')
|
|
298
|
+
? cleanMapUrl
|
|
299
|
+
: `/${cleanMapUrl}`
|
|
300
|
+
replaceableCount += 1
|
|
301
|
+
findings.push({
|
|
302
|
+
nodeId,
|
|
303
|
+
nodeType,
|
|
304
|
+
severity: 'warning',
|
|
305
|
+
code: 'BUNDLED_UNLICENSED_MATERIAL',
|
|
306
|
+
currentUrl: rawMapUrl,
|
|
307
|
+
matchedSlug: pack,
|
|
308
|
+
mitReplacementUrl: normalizedBase
|
|
309
|
+
? `${normalizedBase}${relPath}`
|
|
310
|
+
: `procedural://mit-assets${relPath}`,
|
|
311
|
+
message: `Material pack "${pack}" has a 1:1 clean-room MIT procedural replacement.`,
|
|
312
|
+
})
|
|
313
|
+
}
|
|
314
|
+
} else {
|
|
315
|
+
unmappedCount += 1
|
|
316
|
+
findings.push({
|
|
317
|
+
nodeId,
|
|
318
|
+
nodeType,
|
|
319
|
+
severity: 'warning',
|
|
320
|
+
code: 'UNMAPPED_CUSTOM_URL',
|
|
321
|
+
currentUrl: rawMapUrl,
|
|
322
|
+
message: `Unattributed or external material texture URL has no mapped MIT replacement: ${rawMapUrl}`,
|
|
323
|
+
})
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
return {
|
|
330
|
+
totalNodesScanned,
|
|
331
|
+
mitCleanCount,
|
|
332
|
+
replaceableCount,
|
|
333
|
+
unmappedCount,
|
|
334
|
+
commercialReady: replaceableCount === 0 && unmappedCount === 0,
|
|
335
|
+
findings,
|
|
336
|
+
inventory: {
|
|
337
|
+
items: MIT_ITEM_SPECS.length,
|
|
338
|
+
materials: MIT_MATERIAL_SPECS.length,
|
|
339
|
+
sfx: MIT_SFX_SPECS.length,
|
|
340
|
+
hdri: 1,
|
|
341
|
+
},
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
export function getMitAssetInventorySummary() {
|
|
346
|
+
return {
|
|
347
|
+
license: 'MIT' as const,
|
|
348
|
+
issueReference: 'https://github.com/pascalorg/editor/issues/1327',
|
|
349
|
+
items: MIT_ITEM_SPECS.length,
|
|
350
|
+
catalogItems: MIT_ITEM_SPECS.filter((s) => s.inCatalogItems).length,
|
|
351
|
+
publicItems: MIT_ITEM_SPECS.filter((s) => s.inPublicItems).length,
|
|
352
|
+
materials: MIT_MATERIAL_SPECS.length,
|
|
353
|
+
sfx: MIT_SFX_SPECS.length,
|
|
354
|
+
hdri: MIT_HDRI_SPEC.path,
|
|
355
|
+
}
|
|
356
|
+
}
|