-
Notifications
You must be signed in to change notification settings - Fork 0
Clean AI system prompt: remove verbose spatial distribution and show complete keyframe details #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -68,42 +68,43 @@ function buildCanvasState(project: Project): string { | |||||
| return 'Empty canvas — no layers yet.'; | ||||||
| } | ||||||
|
|
||||||
| const halfHeight = project.height / 2; | ||||||
|
|
||||||
| // Group layers by rough vertical position | ||||||
| const topLayers = project.layers.filter((l) => l.transform.y < -halfHeight / 3); | ||||||
| const middleLayers = project.layers.filter( | ||||||
| (l) => l.transform.y >= -halfHeight / 3 && l.transform.y <= halfHeight / 3 | ||||||
| ); | ||||||
| const bottomLayers = project.layers.filter((l) => l.transform.y > halfHeight / 3); | ||||||
|
|
||||||
| let spatial = ''; | ||||||
| if (topLayers.length > 0) { | ||||||
| spatial += `TOP: ${topLayers.map((l) => `[${l.name}]`).join(' ')}\n`; | ||||||
| } | ||||||
| if (middleLayers.length > 0) { | ||||||
| spatial += `CENTER: ${middleLayers.map((l) => `[${l.name}]`).join(' ')}\n`; | ||||||
| } | ||||||
| if (bottomLayers.length > 0) { | ||||||
| spatial += `BOTTOM: ${bottomLayers.map((l) => `[${l.name}]`).join(' ')}\n`; | ||||||
| } | ||||||
|
|
||||||
| const layerList = project.layers | ||||||
| .map((layer, index) => { | ||||||
| const animatedProps = [...new Set(layer.keyframes.map((k) => k.property))]; | ||||||
| // Show ALL props | ||||||
| const propsPreview = Object.entries(layer.props) | ||||||
| .slice(0, 3) | ||||||
| .map(([k, v]) => `${k}=${JSON.stringify(v)}`) | ||||||
| .join(', '); | ||||||
|
|
||||||
| // Group keyframes by property and show all details | ||||||
| const keyframesByProp = new Map<string, typeof layer.keyframes>(); | ||||||
| for (const kf of layer.keyframes) { | ||||||
| if (!keyframesByProp.has(kf.property)) { | ||||||
| keyframesByProp.set(kf.property, []); | ||||||
| } | ||||||
| keyframesByProp.get(kf.property)!.push(kf); | ||||||
| } | ||||||
|
|
||||||
| // Build detailed keyframe info | ||||||
| let keyframesDetail = ''; | ||||||
| if (keyframesByProp.size > 0) { | ||||||
| keyframesDetail = '\n keyframes:'; | ||||||
| for (const [prop, kfs] of keyframesByProp) { | ||||||
| const kfList = kfs | ||||||
| .sort((a, b) => a.time - b.time) | ||||||
| .map( | ||||||
| (kf) => | ||||||
| `t=${kf.time}s: ${JSON.stringify(kf.value)}${kf.easing ? ` (${kf.easing})` : ''}` | ||||||
| ) | ||||||
| .join(', '); | ||||||
| keyframesDetail += `\n ${prop}: [${kfList}]`; | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| return `${index}. "${layer.name}" (id: "${layer.id}", type: ${layer.type}) | ||||||
| pos: (${layer.transform.x}, ${layer.transform.y}) | opacity: ${layer.style.opacity} | ||||||
| props: {${propsPreview}${Object.keys(layer.props).length > 3 ? ', ...' : ''}} | ||||||
| animated: [${animatedProps.join(', ') || 'none'}]`; | ||||||
| pos: (${layer.transform.x}, ${layer.transform.y}) | scale: (${layer.transform.scaleX}, ${layer.transform.scaleY}) | rotation: ${layer.transform.rotationZ}° | opacity: ${layer.style.opacity} | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# First, find the file structure to understand the layout
echo "=== Repository structure ==="
git ls-files | grep -E "(base\.ts|system-prompt\.ts)" | head -20
echo ""
echo "=== Check system-prompt.ts around line 104 ==="
wc -l src/lib/ai/system-prompt.ts
head -110 src/lib/ai/system-prompt.ts | tail -20
echo ""
echo "=== Check generateTransformCSS in base.ts ==="
fd base.ts -x cat -n {} \; | grep -A10 -B2 "generateTransformCSS"
echo ""
echo "=== Search for rotationZ definitions ==="
rg -n "rotationZ" --type=ts -g '!node_modules/**' | head -40Repository: epavanello/devmotion Length of output: 2892
Per the schema definition in Suggested fix- pos: (${layer.transform.x}, ${layer.transform.y}) | scale: (${layer.transform.scaleX}, ${layer.transform.scaleY}) | rotation: ${layer.transform.rotationZ}° | opacity: ${layer.style.opacity}
+ pos: (${layer.transform.x}, ${layer.transform.y}) | scale: (${layer.transform.scaleX}, ${layer.transform.scaleY}) | rotation: ${layer.transform.rotationZ}rad | opacity: ${layer.style.opacity}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| props: {${propsPreview || 'none'}}${keyframesDetail || '\n keyframes: none'}`; | ||||||
| }) | ||||||
| .join('\n'); | ||||||
| .join('\n\n'); | ||||||
|
|
||||||
| return `${spatial} | ||||||
| ${project.layers.length} layer(s): | ||||||
| ${layerList}`; | ||||||
| return `${project.layers.length} layer(s):\n${layerList}`; | ||||||
| } | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: epavanello/devmotion
Length of output: 356
🏁 Script executed:
Repository: epavanello/devmotion
Length of output: 227
🏁 Script executed:
Repository: epavanello/devmotion
Length of output: 3046
🏁 Script executed:
Repository: epavanello/devmotion
Length of output: 2178
🏁 Script executed:
Repository: epavanello/devmotion
Length of output: 1267
🏁 Script executed:
Repository: epavanello/devmotion
Length of output: 1385
🏁 Script executed:
Repository: epavanello/devmotion
Length of output: 3835
🏁 Script executed:
Repository: epavanello/devmotion
Length of output: 4984
🏁 Script executed:
Repository: epavanello/devmotion
Length of output: 3316
🏁 Script executed:
Repository: epavanello/devmotion
Length of output: 804
kf.easingdoesn't exist on keyframe objects — easing info will never display.The
Keyframetype (defined insrc/lib/schemas/animation.ts:119-125) has aninterpolationproperty, noteasing. Usingkf.easingon line 96 will always be falsy, silently omitting the interpolation details you intended to include.Additionally, on line 104,
rotationZis displayed with a°symbol, but it's stored in radians throughout the system (seesrc/lib/schemas/base.ts:44andsrc/lib/layers/base.ts:318). This is misleading to the AI.Suggested fixes:
Line 96: Use interpolation instead of easing
Line 104: Fix rotationZ unit
pos: (${layer.transform.x}, ${layer.transform.y}) | scale: (${layer.transform.scaleX}, ${layer.transform.scaleY}) | rotation: ${layer.transform.rotationZ}° | opacity: ${layer.style.opacity} + pos: (${layer.transform.x}, ${layer.transform.y}) | scale: (${layer.transform.scaleX}, ${layer.transform.scaleY}) | rotation: ${layer.transform.rotationZ}rad | opacity: ${layer.style.opacity}📝 Committable suggestion
🤖 Prompt for AI Agents