@kruschdev/pascal-plugin-furnishings 0.0.0-stage → 0.2.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.
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Auto-derived Pascal Inspector Parametrics for all 4 `furnishings:*` node kinds.
3
+ */
4
+
5
+ import type { ParametricDescriptor } from '@pascal-app/core'
6
+ import {
7
+ BUDGET_TIERS,
8
+ ELECTRONICS_CHANNEL_ROLES,
9
+ ELECTRONICS_FINISHES,
10
+ ELECTRONICS_MOUNT_STYLES,
11
+ FABRIC_FINISHES,
12
+ METAL_FINISHES,
13
+ PLANT_MATURITIES,
14
+ PLANT_PLACEMENTS,
15
+ PLANT_SEASONS,
16
+ POT_STYLES,
17
+ SCREEN_STATES,
18
+ STYLE_PRESETS,
19
+ WOOD_FINISHES,
20
+ } from '../furnishings/types'
21
+ import type { FurnishingsAssemblyNode } from './assembly'
22
+ import type { FurnishingsElectronicsNode } from './electronics'
23
+ import type { FurnishingsItemNode } from './item'
24
+ import type { FurnishingsPlantNode } from './plant'
25
+
26
+ const USDA_HARDINESS_ZONES = [
27
+ '3a', '3b', '4a', '4b', '5a', '5b', '6a', '6b',
28
+ '7a', '7b', '8a', '8b', '9a', '9b', '10a', '10b', '11a', '11b',
29
+ ] as const
30
+
31
+ export const furnishingsAssemblyParametrics: ParametricDescriptor<FurnishingsAssemblyNode> = {
32
+ groups: [
33
+ {
34
+ label: 'FF&E & Landscape Settings',
35
+ fields: [
36
+ { key: 'stylePreset', kind: 'enum', label: 'Style Preset', options: [...STYLE_PRESETS] },
37
+ { key: 'budgetTier', kind: 'enum', label: 'Budget Tier', options: [...BUDGET_TIERS] },
38
+ { key: 'season', kind: 'enum', label: 'Botanical Season', options: [...PLANT_SEASONS] },
39
+ { key: 'includeExteriorLandscaping', kind: 'boolean', label: 'Exterior Landscaping' },
40
+ { key: 'includeElectronics', kind: 'boolean', label: 'TVs, Audio & PCs' },
41
+ { key: 'includeHouseplants', kind: 'boolean', label: 'Indoor Houseplants' },
42
+ { key: 'includeRugsAndDecor', kind: 'boolean', label: 'Rugs, Lamps & Decor' },
43
+ { key: 'hardinessZone', kind: 'enum', label: 'USDA Hardiness Zone', options: [...USDA_HARDINESS_ZONES] },
44
+ ],
45
+ },
46
+ ],
47
+ }
48
+
49
+ export const furnishingsItemParametrics: ParametricDescriptor<FurnishingsItemNode> = {
50
+ groups: [
51
+ {
52
+ label: 'Furniture Dimensions & Finishes',
53
+ fields: [
54
+ { key: 'woodFinish', kind: 'enum', label: 'Wood Finish', options: [...WOOD_FINISHES] },
55
+ { key: 'fabricFinish', kind: 'enum', label: 'Fabric / Upholstery', options: [...FABRIC_FINISHES] },
56
+ { key: 'metalFinish', kind: 'enum', label: 'Metal Finish', options: [...METAL_FINISHES] },
57
+ { key: 'widthM', kind: 'number', label: 'Width (m)', min: 0.15, max: 10, step: 0.05 },
58
+ { key: 'depthM', kind: 'number', label: 'Depth (m)', min: 0.03, max: 10, step: 0.05 },
59
+ { key: 'heightM', kind: 'number', label: 'Height (m)', min: 0.01, max: 6, step: 0.05 },
60
+ { key: 'quantity', kind: 'number', label: 'Quantity', min: 1, max: 200, step: 1 },
61
+ { key: 'unitPriceOverrideUsd', kind: 'number', label: 'Unit Price Override ($)', min: 0, step: 10 },
62
+ ],
63
+ },
64
+ ],
65
+ }
66
+
67
+ export const furnishingsElectronicsParametrics: ParametricDescriptor<FurnishingsElectronicsNode> = {
68
+ groups: [
69
+ {
70
+ label: 'Electronics, AV & Power',
71
+ fields: [
72
+ { key: 'screenDiagonalIn', kind: 'number', label: 'Screen Size (in)', min: 13, max: 150, step: 1 },
73
+ { key: 'mountStyle', kind: 'enum', label: 'Mount Style', options: [...ELECTRONICS_MOUNT_STYLES] },
74
+ { key: 'finish', kind: 'enum', label: 'Chassis Finish', options: [...ELECTRONICS_FINISHES] },
75
+ { key: 'channelRole', kind: 'enum', label: 'AV / Channel Role', options: [...ELECTRONICS_CHANNEL_ROLES] },
76
+ { key: 'screenState', kind: 'enum', label: 'Display Mode', options: [...SCREEN_STATES] },
77
+ { key: 'wattageW', kind: 'number', label: 'Power Draw (W)', min: 0, max: 4000, step: 5 },
78
+ { key: 'quantity', kind: 'number', label: 'Quantity', min: 1, max: 100, step: 1 },
79
+ { key: 'unitPriceOverrideUsd', kind: 'number', label: 'Unit Price Override ($)', min: 0, step: 10 },
80
+ ],
81
+ },
82
+ ],
83
+ }
84
+
85
+ export const furnishingsPlantParametrics: ParametricDescriptor<FurnishingsPlantNode> = {
86
+ groups: [
87
+ {
88
+ label: 'Botanical Species & Growth',
89
+ fields: [
90
+ { key: 'maturity', kind: 'enum', label: 'Growth Maturity', options: [...PLANT_MATURITIES] },
91
+ { key: 'season', kind: 'enum', label: 'Season', options: [...PLANT_SEASONS] },
92
+ { key: 'placement', kind: 'enum', label: 'Placement', options: [...PLANT_PLACEMENTS] },
93
+ { key: 'potStyle', kind: 'enum', label: 'Planter / Pot Style', options: [...POT_STYLES] },
94
+ { key: 'heightM', kind: 'number', label: 'Height (m)', min: 0.2, max: 25, step: 0.1 },
95
+ { key: 'canopyRadiusM', kind: 'number', label: 'Canopy Radius (m)', min: 0.12, max: 12, step: 0.1 },
96
+ { key: 'seed', kind: 'number', label: 'Growth Seed', min: 1, max: 999999, step: 1 },
97
+ { key: 'quantity', kind: 'number', label: 'Quantity', min: 1, max: 200, step: 1 },
98
+ { key: 'unitPriceOverrideUsd', kind: 'number', label: 'Unit Price Override ($)', min: 0, step: 10 },
99
+ ],
100
+ },
101
+ ],
102
+ }
@@ -0,0 +1,197 @@
1
+ /**
2
+ * `furnishings:plant` — Trees, Bushes, Hedges, Shrubs, Grasses & Potted Indoor Houseplants Node.
3
+ * Render-safe module: zero `@pascal-app/editor` or `react` imports.
4
+ */
5
+
6
+ import {
7
+ BaseNode,
8
+ type FloorplanGeometry,
9
+ type GeometryContext,
10
+ type NodeDefinition,
11
+ type NodePort,
12
+ nodeType,
13
+ objectId,
14
+ } from '@pascal-app/core'
15
+ import { Group } from 'three'
16
+ import { z } from 'zod'
17
+ import { buildPlantCad } from '../cad/plants-geometry'
18
+ import { isSafeAssetBaseUrl } from '../furnishings/catalog'
19
+ import {
20
+ DOMAIN_COLORS,
21
+ PLANT_MATURITIES,
22
+ PLANT_MATURITY_SCALE,
23
+ PLANT_PLACEMENTS,
24
+ PLANT_SEASONS,
25
+ POT_STYLES,
26
+ } from '../furnishings/types'
27
+ import { attachProceduralWithOptionalGlb } from './glb-hydration'
28
+
29
+ export const FurnishingsPlantNode = BaseNode.extend({
30
+ id: objectId('frnplt'),
31
+ type: nodeType('furnishings:plant'),
32
+ plantKind: z.string().min(2).default('tree-oak-deciduous'),
33
+ position: z.tuple([z.number().finite(), z.number().finite(), z.number().finite()]).default([0, 0, 0]),
34
+ rotation: z.number().finite().default(0),
35
+ zoneName: z.string().default('Yard'),
36
+ placement: z.enum(PLANT_PLACEMENTS).default('in-ground'),
37
+ species: z.string().default('Quercus rubra (Northern Red Oak)'),
38
+ maturity: z.enum(PLANT_MATURITIES).default('mature'),
39
+ season: z.enum(PLANT_SEASONS).default('summer'),
40
+ potStyle: z.enum(POT_STYLES).default('none'),
41
+ heightM: z.number().finite().min(0.2).max(25).default(6.4),
42
+ canopyRadiusM: z.number().finite().min(0.12).max(12).default(2.4),
43
+ seed: z.number().int().min(1).max(999999).default(42),
44
+ quantity: z.number().int().min(1).max(200).default(1),
45
+ unitPriceOverrideUsd: z.number().finite().min(0).optional(),
46
+ customSku: z.string().optional(),
47
+ customBrand: z.string().optional(),
48
+ customGlbUrl: z
49
+ .string()
50
+ .refine((v) => v.trim() === '' || isSafeAssetBaseUrl(v), 'Unsafe customGlbUrl')
51
+ .optional(),
52
+ notes: z.string().default(''),
53
+ })
54
+
55
+ export type FurnishingsPlantNode = z.infer<typeof FurnishingsPlantNode>
56
+
57
+ export function getFurnishingsPlantPorts(node: FurnishingsPlantNode): NodePort[] {
58
+ const [x, y, zPos] = node.position
59
+ return [
60
+ { id: 'root-base', position: [x, y, zPos], direction: [0, 1, 0], diameter: 0.1 },
61
+ ]
62
+ }
63
+
64
+ export function buildFurnishingsPlantGeometry(
65
+ node: FurnishingsPlantNode,
66
+ _ctx?: GeometryContext,
67
+ ): Group {
68
+ const root = new Group()
69
+ root.name = `furnishings-plant:${node.plantKind}`
70
+ const cad = buildPlantCad({
71
+ kind: node.plantKind,
72
+ heightM: node.heightM,
73
+ canopyRadiusM: node.canopyRadiusM,
74
+ maturity: node.maturity,
75
+ season: node.season,
76
+ potStyle: node.potStyle,
77
+ seed: node.seed,
78
+ })
79
+ attachProceduralWithOptionalGlb({
80
+ root,
81
+ proceduralGroup: cad,
82
+ customGlbUrl: node.customGlbUrl,
83
+ tag: `${node.plantKind}:${node.id}`,
84
+ })
85
+ return root
86
+ }
87
+
88
+ /**
89
+ * Architectural landscape 2D floorplan symbol: scalloped botanical canopy outline + center trunk cross.
90
+ */
91
+ export function buildFurnishingsPlantFloorplan(
92
+ node: FurnishingsPlantNode,
93
+ _ctx?: GeometryContext,
94
+ ): FloorplanGeometry {
95
+ const stroke = DOMAIN_COLORS['trees-plants']
96
+ const cx = node.position[0]
97
+ const cz = node.position[2]
98
+ const scale = PLANT_MATURITY_SCALE[node.maturity] ?? 1.0
99
+ const r = Math.max(0.16, node.canopyRadiusM * scale)
100
+
101
+ if (node.plantKind === 'bush-hedge-row' || node.plantKind === 'plant-succulent-trough') {
102
+ const cos = Math.cos(node.rotation)
103
+ const sin = Math.sin(node.rotation)
104
+ const hw = r
105
+ const hd = Math.min(0.45, r * 0.42)
106
+ const pts: [number, number][] = (
107
+ [
108
+ [-hw, -hd],
109
+ [hw, -hd],
110
+ [hw, hd],
111
+ [-hw, hd],
112
+ ] as const
113
+ ).map(([lx, lz]) => [cx + lx * cos + lz * sin, cz - lx * sin + lz * cos])
114
+ return {
115
+ kind: 'group',
116
+ children: [{ kind: 'polygon', points: pts, stroke, strokeWidth: 0.03, fill: `${stroke}33` }],
117
+ }
118
+ }
119
+
120
+ // Scalloped organic architectural canopy ring
121
+ const pts: [number, number][] = []
122
+ const segs = 24
123
+ for (let i = 0; i < segs; i++) {
124
+ const a = (i / segs) * Math.PI * 2
125
+ const ripple = i % 2 === 0 ? 1.0 : 0.88
126
+ pts.push([cx + Math.cos(a) * r * ripple, cz + Math.sin(a) * r * ripple])
127
+ }
128
+ const tick = Math.min(0.18, r * 0.25)
129
+
130
+ return {
131
+ kind: 'group',
132
+ children: [
133
+ { kind: 'polygon', points: pts, stroke, strokeWidth: 0.03, fill: `${stroke}29` },
134
+ { kind: 'line', x1: cx - tick, y1: cz, x2: cx + tick, y2: cz, stroke, strokeWidth: 0.02 },
135
+ { kind: 'line', x1: cx, y1: cz - tick, x2: cx, y2: cz + tick, stroke, strokeWidth: 0.02 },
136
+ ],
137
+ }
138
+ }
139
+
140
+ export const furnishingsPlantRenderDefinition: NodeDefinition<typeof FurnishingsPlantNode> = {
141
+ kind: 'furnishings:plant',
142
+ schemaVersion: 1,
143
+ schema: FurnishingsPlantNode,
144
+ category: 'furnish',
145
+ defaults: () => ({
146
+ object: 'node',
147
+ parentId: null,
148
+ visible: true,
149
+ metadata: {},
150
+ name: 'Mature Red Oak Shade Tree',
151
+ plantKind: 'tree-oak-deciduous',
152
+ position: [0, 0, 0],
153
+ rotation: 0,
154
+ zoneName: 'Yard',
155
+ placement: 'in-ground',
156
+ species: 'Quercus rubra (Northern Red Oak)',
157
+ maturity: 'mature',
158
+ season: 'summer',
159
+ potStyle: 'none',
160
+ heightM: 6.4,
161
+ canopyRadiusM: 2.4,
162
+ seed: 42,
163
+ quantity: 1,
164
+ notes: '',
165
+ }),
166
+ capabilities: {
167
+ selectable: { hitVolume: 'bbox' },
168
+ movable: { axes: ['x', 'y', 'z'], gridSnap: true },
169
+ rotatable: { axes: ['y'], snapAngles: [Math.PI / 6] },
170
+ duplicable: true,
171
+ deletable: true,
172
+ snappable: {},
173
+ },
174
+ geometry: buildFurnishingsPlantGeometry,
175
+ geometryKey: (n) =>
176
+ JSON.stringify([
177
+ n.plantKind,
178
+ n.heightM,
179
+ n.canopyRadiusM,
180
+ n.maturity,
181
+ n.season,
182
+ n.potStyle,
183
+ n.seed,
184
+ n.customGlbUrl ?? '',
185
+ ]),
186
+ ports: getFurnishingsPlantPorts,
187
+ floorplan: buildFurnishingsPlantFloorplan,
188
+ presentation: {
189
+ label: 'Tree, Bush or Houseplant',
190
+ description: 'Procedural deciduous/evergreen trees, palms, boxwood bushes, privacy hedges, hydrangeas, grasses & potted houseplants.',
191
+ icon: { kind: 'iconify', name: 'lucide:trees' },
192
+ paletteSection: 'furnish',
193
+ },
194
+ mcp: {
195
+ description: 'Botanical landscape tree, bush, hedge, shrub, grass, or potted indoor houseplant with seasonal foliage.',
196
+ },
197
+ }
package/src/render.ts ADDED
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Read-only viewer entry (`@kruschdev/pascal-plugin-furnishings/render`).
3
+ * Strictly editor-free: zero `@pascal-app/editor` or `next` imports (verified by `bun run check:render`).
4
+ */
5
+
6
+ import type { AnyNodeDefinition, Plugin } from '@pascal-app/core'
7
+ import { furnishingsAssemblyRenderDefinition } from './nodes/assembly'
8
+ import { furnishingsElectronicsRenderDefinition } from './nodes/electronics'
9
+ import { furnishingsItemRenderDefinition } from './nodes/item'
10
+ import { furnishingsPlantRenderDefinition } from './nodes/plant'
11
+
12
+ export const FURNISHINGS_PLUGIN_ID = 'krusch:furnishings' as const
13
+ export const FURNISHINGS_SCHEDULE_VIEW_ID = 'krusch:furnishings:schedule' as const
14
+
15
+ export const furnishingsRenderPlugin: Plugin = {
16
+ id: FURNISHINGS_PLUGIN_ID,
17
+ apiVersion: 1,
18
+ nodes: [
19
+ furnishingsAssemblyRenderDefinition as unknown as AnyNodeDefinition,
20
+ furnishingsItemRenderDefinition as unknown as AnyNodeDefinition,
21
+ furnishingsElectronicsRenderDefinition as unknown as AnyNodeDefinition,
22
+ furnishingsPlantRenderDefinition as unknown as AnyNodeDefinition,
23
+ ],
24
+ }
25
+
26
+ export default furnishingsRenderPlugin
27
+ export { clearFurnishingsGlbCache } from './nodes/glb-hydration'
28
+ export {
29
+ FurnishingsAssemblyNode,
30
+ furnishingsAssemblyRenderDefinition,
31
+ buildFurnishingsAssemblyGeometry,
32
+ buildFurnishingsAssemblyFloorplan,
33
+ getFurnishingsAssemblyPorts,
34
+ } from './nodes/assembly'
35
+ export {
36
+ FurnishingsItemNode,
37
+ furnishingsItemRenderDefinition,
38
+ buildFurnishingsItemGeometry,
39
+ buildFurnishingsItemFloorplan,
40
+ getFurnishingsItemPorts,
41
+ } from './nodes/item'
42
+ export {
43
+ FurnishingsElectronicsNode,
44
+ furnishingsElectronicsRenderDefinition,
45
+ buildFurnishingsElectronicsGeometry,
46
+ buildFurnishingsElectronicsFloorplan,
47
+ getFurnishingsElectronicsPorts,
48
+ } from './nodes/electronics'
49
+ export {
50
+ FurnishingsPlantNode,
51
+ furnishingsPlantRenderDefinition,
52
+ buildFurnishingsPlantGeometry,
53
+ buildFurnishingsPlantFloorplan,
54
+ getFurnishingsPlantPorts,
55
+ } from './nodes/plant'
@@ -0,0 +1,119 @@
1
+ 'use client'
2
+
3
+ /**
4
+ * Persisted ChatToolCard for `krusch:furnishings` (`PluginChatExtension`).
5
+ */
6
+
7
+ import type { ChatToolCardProps } from '@pascal-app/editor'
8
+
9
+ function fmtUsd(val: unknown): string {
10
+ const n = typeof val === 'number' && Number.isFinite(val) ? val : 0
11
+ return `$${n.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`
12
+ }
13
+
14
+ function safeStr(val: unknown): string | null {
15
+ return typeof val === 'string' && val.length > 0 ? val : null
16
+ }
17
+
18
+ function safeCount(val: unknown, fallback = 0): number {
19
+ return typeof val === 'number' && Number.isFinite(val) ? val : fallback
20
+ }
21
+
22
+ function safeArrLen(val: unknown): number {
23
+ return Array.isArray(val) ? val.length : 0
24
+ }
25
+
26
+ export default function FurnishingsChatCard({ toolName, output, state }: ChatToolCardProps) {
27
+ const safeToolName = typeof toolName === 'string' && toolName.length > 0 ? toolName : 'furnishings'
28
+ const safeState = typeof state === 'string' ? state : ''
29
+ const outputText = safeStr(output?.text)
30
+ const raw = output?.data
31
+ const data = raw && typeof raw === 'object' && !Array.isArray(raw) ? (raw as Record<string, unknown>) : undefined
32
+ const summary = safeStr(data?.summary)
33
+ const name = safeStr(data?.name)
34
+ const species = safeStr(data?.species)
35
+ const bom =
36
+ data?.bom && typeof data.bom === 'object' && !Array.isArray(data.bom)
37
+ ? (data.bom as Record<string, unknown>)
38
+ : undefined
39
+ const audit =
40
+ data?.audit && typeof data.audit === 'object' && !Array.isArray(data.audit)
41
+ ? (data.audit as Record<string, unknown>)
42
+ : typeof data?.errorCount === 'number' && Number.isFinite(data.errorCount)
43
+ ? data
44
+ : undefined
45
+ const renderPrompt =
46
+ data?.renderPrompt && typeof data.renderPrompt === 'object' && !Array.isArray(data.renderPrompt)
47
+ ? (data.renderPrompt as Record<string, unknown>)
48
+ : undefined
49
+ const diversity =
50
+ typeof data?.minDifferingAxes === 'number' &&
51
+ Number.isFinite(data.minDifferingAxes) &&
52
+ Array.isArray(data?.nearDuplicates)
53
+ ? data
54
+ : undefined
55
+ const renderPromptConflictCount = renderPrompt ? safeArrLen(renderPrompt.sceneConflicts) : 0
56
+ const diversityNearDupCount = diversity ? safeArrLen(diversity.nearDuplicates) : 0
57
+
58
+ return (
59
+ <div
60
+ style={{
61
+ padding: 10,
62
+ borderRadius: 8,
63
+ border: '1px solid rgba(34,197,94,0.35)',
64
+ background: 'rgba(15,23,42,0.45)',
65
+ fontSize: 12,
66
+ display: 'flex',
67
+ flexDirection: 'column',
68
+ gap: 4,
69
+ }}
70
+ >
71
+ <div style={{ display: 'flex', justifyContent: 'space-between', fontWeight: 600 }}>
72
+ <span>{safeToolName}</span>
73
+ <span style={{ fontSize: 11, opacity: 0.72 }}>{safeState}</span>
74
+ </div>
75
+ {outputText && <div style={{ opacity: 0.85 }}>{outputText}</div>}
76
+ {summary && <div>{summary}</div>}
77
+ {name && <div style={{ fontWeight: 600 }}>{name}</div>}
78
+ {species && <div style={{ fontStyle: 'italic', opacity: 0.82 }}>{species}</div>}
79
+ {audit && (
80
+ <div>
81
+ Audit: <strong>{safeCount(audit.errorCount, 0)}</strong> error(s),{' '}
82
+ <strong>{safeCount(audit.warningCount, 0)}</strong> warning(s)
83
+ </div>
84
+ )}
85
+ {bom && (
86
+ <div>
87
+ CSI BOM: <strong>{safeCount(bom.itemCount, 0)}</strong> units ·{' '}
88
+ <strong style={{ color: '#4ade80' }}>{fmtUsd(bom.grandTotalUsd)}</strong>
89
+ </div>
90
+ )}
91
+ {renderPrompt && (
92
+ <div>
93
+ Spatial Prompt ({safeStr(renderPrompt.roomName) ?? 'Room'} · {safeStr(renderPrompt.viewId) ?? 'view'}):{' '}
94
+ <strong>{safeArrLen(renderPrompt.solidWallIds)}</strong> solid wall(s),{' '}
95
+ <strong>{safeArrLen(renderPrompt.visibleWindowWalls)}</strong> window wall(s)
96
+ {renderPrompt.isTightRoom === true ? ' · Tight-Room Scale Lock' : ''}
97
+ {renderPromptConflictCount > 0 && (
98
+ <span style={{ color: '#f87171' }}>
99
+ {' '}
100
+ · {renderPromptConflictCount} conflict(s)
101
+ </span>
102
+ )}
103
+ </div>
104
+ )}
105
+ {diversity && (
106
+ <div>
107
+ Axes Diversity ({safeCount(diversity.candidateCount, 0)} options, min{' '}
108
+ {safeCount(diversity.minDifferingAxes, 4)} differing):{' '}
109
+ <strong style={{ color: diversity.valid === true ? '#4ade80' : '#f87171' }}>
110
+ {diversity.valid === true ? 'PASSED' : 'FAILED'}
111
+ </strong>
112
+ {diversityNearDupCount > 0 && (
113
+ <span> · {diversityNearDupCount} near-duplicate pair(s)</span>
114
+ )}
115
+ </div>
116
+ )}
117
+ </div>
118
+ )
119
+ }