Script Buddy AI is an advanced scripting assistant for the Composition Script Editor. It helps you understand, improve, debug, and expand your JavaScript through targeted AI analysis and generation.
Note
Paid subscriptions have direct execution access via the Run AI button while free users can use Script Buddy AI via prompt copy-pasting for external AI use.
Script Buddy's AI is trained on the Composition Script documentation, Composition structure, and Control Node structure, enabling it to provide highly specific and context-aware answers. For these reasons, it is important to be precise and use Composer and Singular language when prompting Script Buddy (such as "Control Node ID", "Widget", etc).
Script Buddy offers several modes like Explain, Review, Fix, Extend, Refactor, Document, and Ask Docs. The following goes into detail of each available mode:
Prompt Modes
Script Buddy offers several modes that determine how your selected JavaScript is analyzed, improved, or transformed.
Explains what your JavaScript does in clear, easy-to-understand language. This mode helps you grasp the behavior, logic, and intent behind the JavaScript.
When to use it
- When reading unfamiliar JavaScript
- When learning how a piece of logic works
- When reviewing JavaScript written by someone else
Optional prompt
You can add specific questions, such as “Why is this function recursive?” or “What does this loop achieve?”
Reviews your JavaScript for potential issues, such as logic errors, risky patterns, and areas that may cause bugs.
When to use it
- Before deploying new script
- When auditing someone else’s work
- When looking for hidden or subtle issues
Optional prompt
You can specify concerns like “Check for security issues” or “Focus on performance.”
Attempts to repair issues in your JavaScript and returns a corrected version. The system works to preserve your intended behavior while resolving bugs.
If the script editor displays a runtime error, it will be automatically included in the AI prompt so the system knows exactly what to fix. If an error occurs, open Script Buddy AI, select 'Fix', and click 'Run AI'.
When to use it
- When you know something is broken
- When script errors are hard to track down
- When you want a clean, working version quickly
Optional prompt
If you know the specific problem, you can describe it. (e.g., “The table widget doesn’t show any data and I see the error ‘invalid format’ in the browser console.”)
Adds new features or enhancements while keeping all existing functionality intact.
When to use it
- When you want to add capabilities to your script
- When extending an existing module or component
- When evolving a prototype into a more complete version
Required prompt
Describe the functionality you want to add, such as “Hide the header text rectangle when the Header text control node is empty"
Improves the internal structure of your JavaScript without changing its function. This can involve reorganizing logic, simplifying complex script, improving naming, or modernizing syntax.
When to use it
- When the JavaScript works but is difficult to read
- When preparing JavaScript for long-term maintenance
- When multiple developers will use or extend the module
Optional prompt
You may include preferences such as “Use modern ES6 patterns” or “Reduce nesting levels where possible.”
Generates helpful inline comments that describe the JavaScript's function and purpose. This mode focuses on documentation and does not alter the logic or structure of the script.
When to use it
- When preparing JavaScript for handoff
- When maintaining or updating legacy JavaScript
- When your script works but lacks explanation
Optional prompt
You can specify a preferred documentation style (e.g., JSDoc, detailed comments, brief summaries).
Provides answers based on official documentation or API reference materials. Instead of analyzing your JavaScript, this mode helps you understand the intended use of specific functions, methods, or libraries.
When to use it
- When unsure how a function or API works
- When comparing different approaches for the same task
- When documentation is unclear, incomplete, or hard to find
Required prompt
Enter your question, such as “How do I control the timer via the Singular API?”
Script Scope
When sending composition scripts to the AI, you have two options:
- All: Sends all composition scripts (all Subcomposition scripts, the Global script and the Root script).
- Active: Sends only the current opened script in the editor.
Note that if the Mode is set to "Extend," the "All" button is disabled. This is because "Extend" is designed to add functionality to a single, specific script.
Executing Prompts
Run AI (for paid users)
The Run AI button executes the prompt by sending it to the AI backend for execution. Note that response time for execution is dependent on the AI backend's current load.
Note
The "Run AI" button is exclusively available to users with paid Singular subscriptions. Users with a Free subscription can still utilize the AI functionality indirectly via the "Copy to clipboard" button. More here.
When the AI generates script, you’ll see a “Copy” button to copy it to your clipboard. If the AI output is meant to fully replace an existing script file, a “Replace” button will appear. Clicking it will open the script editor and overwrite the file with the AI-generated script. You can undo this in the script editor with Control-Z.
When satisfied, make sure to save the replaced Script in the upper left corner of the script editor.
Copy Prompt to Clipboard
Users with a Free subscription can still utilize the AI functionality indirectly. They can use the "Copy to clipboard" button, located next to "Run AI," to copy the complete AI prompt (your prompt paired with necessary Singular Composition Script information).
This prompt can then be pasted into any external AI system like Chat GPT. While results must be manually copied and pasted back, this workaround allows Free users to access the intended functionality.
Additional Benefits of Copy and Pasting Externally
Dialogue / Conversation Mode
Script Buddy AI doesn't natively offer conversation mode. Utilizing external AI like Chat GPT allows you to build up prompts to determine script solutions.
Training Script Buddy
External prompting via the Copy to Clipboard button allows you to help train external AI systems on Singular Composition Scripting, thus improving AI's effectiveness in Singular.
Diff View
Script Buddy Diff View is a modal comparison tool within Script Buddy AI that lets you review AI-generated code changes before applying them. It compares your current script with the suggested version so you can understand and control updates.
Note
Diff view is not necessary when using Script Buddy AI. It is helpful and recommended for larger or riskier edits where review between AI generated code and the existing code within the Script Editor is important.
Using Diff View
Click Diff on the generated code block
Note
If no differences exist, a “No changes” badge is shown.
Reading the Diff View
- Green rows: Added code
- Red rows: Removed code
- Highlighted characters: Specific changes within a line
- Collapsed sections: Long unchanged areas are hidden for readability
Applying Changes
- Apply: Replaces your current script with the AI-suggested version after review
Tips and Considerations
Effective Prompting
- Use Singular language - “Widget”, “Group” “Control Node” etc
Sample Prompt:
If the control ID "XXX" is false, set the widget "YYY" SizeY to 100.0
If the control ID "XXX" is true, set the widget "YYY" SizeY to 50.0
Important
- Be mindful of your Composition element anchor points.
- If the Script is using .getDomElement() - ensure that Widget/Group doesn't have an animation on it - as this could cause conflict in the animation timeline and will effect your final play out.
Comments
0 comments