Skip to content

feat: introduce plugin system with routes/hooks, metadata, tests, and docs#113

Merged
1Lucas1apk merged 24 commits into
PerformanC:v3from
Tapao-NonSen:PRs
Nov 5, 2025
Merged

feat: introduce plugin system with routes/hooks, metadata, tests, and docs#113
1Lucas1apk merged 24 commits into
PerformanC:v3from
Tapao-NonSen:PRs

Conversation

@Tapao-NonSen

@Tapao-NonSen Tapao-NonSen commented Nov 5, 2025

Copy link
Copy Markdown
Contributor

Changes

Added a plugin system to NodeLink. It allows loading and registering plugins (local or NPM) that can define custom HTTP routes, audio sources, lyrics providers, stream interceptors, and pre-play hooks.

Refactored core components (SourcesManager, LyricsManager) to use registration methods that support plugin-based sources. Added new API endpoints for plugin and route information.

Also included new configuration fields for plugins and improved HTTP route resolution to include plugin routes before internal ones.

Why

To make NodeLink modular and extendable without changing internal files.
Developers can now add custom behavior, caching, or third-party integrations through plugins, improving maintainability and flexibility.

Checkmarks

  • Tested new and modified endpoints.
  • Maintained consistent indentation.
  • Still compatible with LavaLink clients.

Additional information

This prepares NodeLink for broader ecosystem use — plugins can now add new sources or logic dynamically, making future extensions and experimentation simpler.

Tapao-NonSen and others added 12 commits November 5, 2025 03:15
- Added PluginManager to manage plugins, including loading local and package plugins.
- Introduced API for plugins to register routes, audio sources, and lyrics sources.
- Implemented stream interceptors and before-play hooks for enhanced audio processing.
- Created example and audio cache plugins to demonstrate plugin capabilities.
- Updated source and lyrics managers to support dynamic plugin registration.
- Enhanced documentation for plugin system and usage examples.
Signed-off-by: Tapao <40026698+Tapao-NonSen@users.noreply.github.com>
Signed-off-by: Tapao <40026698+Tapao-NonSen@users.noreply.github.com>
@Tapao-NonSen Tapao-NonSen marked this pull request as ready for review November 5, 2025 14:51
Copilot AI review requested due to automatic review settings November 5, 2025 14:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a plugin system for NodeLink, enabling developers to extend functionality without modifying core files. Plugins can register HTTP routes, audio/lyrics sources, stream interceptors, and playback hooks.

Key Changes:

  • New PluginManager class to discover, load, and manage plugins from local files and NPM packages
  • Integration of plugin routes into the request handler with proper priority ordering
  • Two example plugins: audio-cache-plugin (disk caching with TTL/size limits) and prebuffer-plugin (stream buffering)

Reviewed Changes

Copilot reviewed 19 out of 20 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/plugins/pluginManager.js Core plugin system: loads plugins, manages routes, interceptors, and before-play hooks
src/plugins/src/audio-cache-plugin.js Caches audio streams to disk with configurable TTL and size limits
src/plugins/src/prebuffer-plugin.js Buffers initial stream bytes before playback for smoother starts
src/plugins/src/example-plugin.js Minimal example demonstrating plugin API usage
src/api/index.js Integrates plugin routes into request handler (static then dynamic)
src/api/info.js Exposes loaded plugin metadata in /v4/info endpoint
src/api/routes.js New endpoint listing all builtin and plugin routes
src/api/plugins.js New endpoint listing loaded plugins and their routes
src/managers/sourceManager.js Refactored to support plugin-registered sources; integrates stream interceptor pipeline
src/managers/lyricsManager.js Added addLyricsSource method for plugin-registered lyrics providers
src/playback/player.js Invokes plugin beforePlay hooks before stream initialization
src/worker.js Initializes PluginManager in worker process
src/index.js Initializes PluginManager in main server process
test/plugins.integration.test.js Integration tests for plugin routes and metadata
docs/plugins.md Comprehensive plugin API documentation with examples
config.default.js Default configuration for audioCache and prebuffer plugins
Comments suppressed due to low confidence (1)

docs/plugins.md:1

  • The documentation states plugins should be under src/plugins/*.js, but the actual code loads from src/plugins/src/*.js (see pluginManager.js line 92). Update documentation to match implementation: src/plugins/src/*.js.
Plugin System

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/plugins/src/audio-cache-plugin.js Outdated
Comment thread src/api/info.js Outdated
Comment thread src/plugins/src/audio-cache-plugin.js Outdated
@Tapao-NonSen Tapao-NonSen requested a review from Copilot November 5, 2025 15:10

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 19 out of 20 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (1)

docs/plugins.md:1

  • The documentation states plugins should be in src/plugins/*.js, but the actual implementation loads from src/plugins/src/*.js as seen in pluginManager.js line 92. This should be corrected to src/plugins/src/*.js to match the implementation.
Plugin System

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/api/info.js Outdated
Comment thread README.md Outdated
Comment thread src/plugins/src/audio-cache-plugin.js
@1Lucas1apk 1Lucas1apk self-requested a review November 5, 2025 17:20
@1Lucas1apk 1Lucas1apk added docs Improvements or additions to documentation enhancement New feature or request labels Nov 5, 2025

@1Lucas1apk 1Lucas1apk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make these changes

Comment thread docs/plugins.md
Comment thread src/plugins/src/audio-cache-plugin.js
Comment thread src/plugins/src/audio-cache-plugin.js Outdated
Comment thread src/plugins/src/prebuffer-plugin.js
Comment thread src/plugins/pluginManager.js
Comment thread src/api/plugins.js Outdated
Comment thread src/api/routes.js
Comment thread docs/plugins.md
@1Lucas1apk 1Lucas1apk merged commit 02a71ce into PerformanC:v3 Nov 5, 2025
1Lucas1apk added a commit that referenced this pull request Nov 6, 2025
…nd docs #113

feat: introduce plugin system with routes/hooks, metadata, tests, and docs

reason: The system is quite unstable, causing problems with NodeLink's functionality. I accepted without reliable testing beforehand; I need you to run tests before adding the system. It was my mistake!
@EvilG-MC EvilG-MC mentioned this pull request Dec 13, 2025
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants