Add Lua plugin scripting#302
Merged
Merged
Conversation
Adds a plugin-facing domain facade (src/core/plugin_api.rs) with serde-serializable snapshots (PlaybackState, TrackInfo, DeviceInfo, PlaylistInfo); rspotify types never cross the plugin boundary. Embeds a Lua 5.4 engine (mlua, vendored) behind the new `scripting` default feature. Loads ~/.config/spotatui/init.lua and plugins/*.lua, exposes a curated spotatui.* API (reads, actions, event hooks for start/quit/track_change/playback_state_change/seek/volume_change/ queue_change). Actions route through the same App methods as keybindings so native-streaming fast paths are honored. Plugin errors are panic-safe, one-strike disabled, and surface as error-priority status messages that normal notifications cannot clobber. Slim CI build stays mlua-free.
spotatui.http_get/http_post spawn requests on the tokio runtime and deliver results back to the engine over a channel drained each tick; callbacks are one-shot, attributed to their plugin, and error-contained. spotatui.json_decode/json_encode wrap serde. API version 2 -> 3.
- Load directory plugins (plugins/<name>/main.lua, fallback init.lua) with the plugin's own folder on package.path for require() - Add 'spotatui plugin' CLI (add/list/remove/update) backed by a git clone and a plugins.lock lockfile; gated behind the scripting feature - Ship example plugins under examples/plugins/ and a PLUGINS.md index - Document install/authoring flow in docs/scripting.md
- spotatui.require_api(n) fails a plugin load with a clear "requires API vN" message when the build is too old, instead of a cryptic nil-call error - Bump scripting API_VERSION 3 -> 4 - Add a Trust and safety section (plugins are unsandboxed) to the docs - Add `spotatui plugin new <name>` to scaffold a working directory plugin - Document the `spotatui-plugin` GitHub topic for discovery
704d077 to
2742898
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds an embedded Lua plugin system (phases 0-5) plus the ecosystem polish needed to ship it.
What plugins can do
track_change,playback_state_change,seek,volume_change,queue_change,start,quit)plugin_commandsmap inconfig.ymlEcosystem
spotatui plugin add/list/remove/updategit-based installer with aplugins.locklockfilespotatui plugin new <name>scaffolds a working directory plugin to start fromplugins/<name>/main.lua) withrequiresupport for sibling modulesspotatui.require_api(n)lets a plugin declare its minimum API version and fail with a clear message instead of a cryptic nil-call error on older buildsPLUGINS.mdindex, fulldocs/scripting.mdreference, and aspotatui-pluginGitHub topic convention for discoverySafety
scriptingfeature; the slim CI build stays mlua-freeAppmethods, never raw IoEventsVerification
cargo clippy/cargo testgreen on bothtelemetry,scripting(343 tests) and slimtelemetry(251 tests)