Plugins

Want AI to make you a plugin?

Start a chat with this prompt and describe what the plugin should do. The assistant checks it's possible, writes both files and tells you where they go.

Show prompt
You're going to help me make a plugin for Opal Music, a desktop Apple Music player. The full reference is at https://opalmusic.app/docs/plugins.md; read it if you can browse. The essentials are below.

How we'll work:
1. Start by asking me what the plugin should do, unless I've already said.
2. Check the idea against the API and limits below. If part of it isn't possible (controlling playback, reading lyrics or the library, drawing UI beyond settings and buttons, plain http, local files, background timers), say so plainly and suggest the closest thing that works. If it calls a web service, tell me what account or API key I'll need. Agree on the idea with me before writing code.
3. Write two complete files: manifest.json and main.js. No placeholders except settings the user fills in.
4. Tell me how to install it: in Opal, open Settings, Plugins, press "Open folder", make a new folder inside the one that opens (for example "my-plugin"; not "discord" or "lastfm"), save both files in it, press "Reload", then turn the plugin on. After editing, press "Reload" again.
5. Offer to refine it.

The API (version 1):
- manifest.json has only these fields: {"api": 1, "name": "...", "description": "...", "author": "...", "entry": "main.js", "permissions": {"http": ["api.example.com"], "discord": true}, "settings": [{"key": "...", "label": "...", "description": "...", "type": "toggle" | "text" | "password", "default": false | ""}], "actions": [{"id": "...", "label": "..."}]}. permissions, settings and actions are optional; unknown fields are an error. Ask only for the permissions needed.
- main.js is plain JavaScript (QuickJS) run once when the plugin is turned on. No DOM, Node.js, fetch, timers or modules; promises settle before the next event. Register handlers with opal.on(event, handler).
- Events: "track" (track or null when the song changes), "playback" ({playing, position, duration} in seconds, on play, pause, seek or song change), "tick" (same data, about once a second while playing), "settings" (the new settings), "action" ({id} when a button is pressed), "stop" (null; turned off, reloaded or quitting, clean up here). Right after the script runs, the plugin receives the current track and playback.
- A track: {id, catalogId, title, artist, album, artwork (600x600 image URL), duration, explicit, url (music.apple.com link)}; artwork, catalogId and url can be null.
- opal: on(event, handler); settings (current values by key); status(text) sets the line on the plugin's card ("" clears); log(...) and console.log write to Opal's log; http({url, method = "GET", headers, body}) is synchronous, HTTPS only, hosts must be in permissions.http, no redirects, 15 s timeout, 4 MiB limit, returns {status, headers, body, json()} and throws on network errors but not error statuses; discord.setActivity(appId, activity) and discord.clearActivity(appId) need permissions.discord and throw if Discord isn't running (activity is Discord's activity object: type 2 is Listening, details, state, timestamps, assets with large_image as a URL, up to two buttons); openUrl(url) opens http(s) URLs in the browser; storage.get(key) / storage.set(key, value) persist JSON across restarts (undefined deletes, 256 KiB total); md5(text) returns hex.
- Limits: 1 second of CPU per event (waiting on http doesn't count), 32 MiB of memory, 512 KiB script. An error in a handler is reported and the plugin keeps running.

Good practice: wrap network calls in try/catch and show problems with opal.status, keep secrets in password settings, and clean up in "stop".

This page as Markdown. Index for AI tools: llms.txt.