Repository navigation
⚡ Optimize plugin bootstrap with async I/O - #2
Conversation
Converted `getBootstrapContent` to an async function and replaced synchronous `fs.readFileSync` with `fs.promises.readFile`. This prevents blocking the Node.js event loop during plugin initialization and system prompt transformation. Changes: - Updated `.opencode/plugins/superpowers.js` - `getBootstrapContent` is now `async` - Uses `await fs.promises.readFile` with `try-catch` for existence check - Updated `experimental.chat.system.transform` to await bootstrap content Co-authored-by: pakorn269 <[email protected]>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
There was a problem hiding this comment.
Pull request overview
This PR converts the getBootstrapContent helper in the Superpowers plugin from synchronous file I/O (fs.readFileSync / fs.existsSync) to asynchronous I/O (fs.promises.readFile with try/catch), and updates the caller to await it.
Changes:
- Converted
getBootstrapContentto anasyncfunction usingfs.promises.readFilewith a try/catch instead offs.existsSync+fs.readFileSync. - Updated the
experimental.chat.system.transformhook toawaitthe now-async helper.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
There was a problem hiding this comment.
Pull request overview
This PR converts the synchronous file I/O in the Superpowers plugin bootstrap (fs.readFileSync / fs.existsSync) to asynchronous I/O (fs.promises.readFile) and adds promise-based memoization so the file is only read once.
Changes:
- Replaced
fs.existsSync+fs.readFileSyncwithfs.promises.readFilewrapped in try/catch. - Added a
bootstrapContentPromisecache variable and wrapped the async logic in a memoized IIFE pattern. - Updated the
experimental.chat.system.transformhook toawaitthe result.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| let fullContent; | ||
| try { | ||
| fullContent = await fs.promises.readFile(skillPath, 'utf8'); | ||
| } catch (err) { |
| @@ -72,7 +81,7 @@ When skills reference tools you don't have, substitute OpenCode equivalents: | |||
| Superpowers skills are in \`${configDir}/skills/superpowers/\` | |||
| Use OpenCode's native \`skill\` tool to list and load skills.`; | |||
|
|
|||
| return `<EXTREMELY_IMPORTANT> | |||
| return `<EXTREMELY_IMPORTANT> | |||
| You have superpowers. | |||
|
|
|||
| **IMPORTANT: The using-superpowers skill content is included below. It is ALREADY LOADED - you are currently following it. Do NOT use the skill tool to load "using-superpowers" again - that would be redundant.** | |||
| @@ -81,12 +90,16 @@ ${content} | |||
|
|
|||
| ${toolMapping} | |||
| </EXTREMELY_IMPORTANT>`; | |||
| })(); | |||
| } | |||
|
|
|||
| return bootstrapContentPromise; | |||
💡 What: The optimization implemented
fs.promises.readFile.getBootstrapContenthelper to be anasyncfunction.experimental.chat.system.transformhook toawaitthe bootstrap content.🎯 Why: The performance problem it solves
fs.readFileSync) blocks the Node.js event loop, which can degrade the responsiveness of the application, especially if the file system is slow or under load. Moving to asynchronous I/O is a standard best practice in Node.js for maintaining high concurrency and responsiveness.📊 Measured Improvement:
tests/opencode/run-tests.sh), which passed successfully.PR created automatically by Jules for task 48725938830699180 started by @pakorn269