Update plugin template to match current TimeTracker plugin system#1
Update plugin template to match current TimeTracker plugin system#1
Conversation
bthos
commented
Feb 8, 2026
- Update Plugin trait to use time-tracker-plugin-sdk
- Change entry_point from plugin_init to _plugin_create
- Add _plugin_destroy FFI export
- Update plugin.toml format to match current implementation
- Add Extension API documentation and examples
- Update README with current Plugin API information
- Update Cargo.toml to use plugin SDK dependency
- Update Plugin trait to use time-tracker-plugin-sdk - Change entry_point from plugin_init to _plugin_create - Add _plugin_destroy FFI export - Update plugin.toml format to match current implementation - Add Extension API documentation and examples - Update README with current Plugin API information - Update Cargo.toml to use plugin SDK dependency Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Pull request overview
Updates the Rust plugin template to match the current TimeTracker plugin system by switching to time-tracker-plugin-sdk, updating the required FFI exports, and refreshing the manifest/docs to reflect the new Extension API and lifecycle.
Changes:
- Replaced the in-template Plugin/API definitions with
time-tracker-plugin-sdkand updated the example plugin implementation accordingly. - Changed the backend entry point to
_plugin_createand added_plugin_destroyfor unloading. - Updated
plugin.toml,Cargo.toml, and README documentation to reflect the current plugin manifest format and Extension API usage.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/plugin.rs | Migrates the example plugin to the SDK Plugin trait and demonstrates schema/command patterns. |
| src/lib.rs | Updates exported FFI symbols to _plugin_create / _plugin_destroy. |
| plugin.toml | Adjusts backend metadata to match the new entry point and naming expectations. |
| README.md | Refreshes template setup instructions and documents the Extension API and new lifecycle. |
| Cargo.toml | Switches dependencies to use the plugin SDK instead of the prior placeholder types. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ModelField, | ||
| ForeignKey, | ||
| SchemaExtension, | ||
| }; | ||
| use serde_json; |
There was a problem hiding this comment.
ModelField, ForeignKey, and the standalone use serde_json; import are currently unused (the ModelField usage is inside a block comment). This will trigger unused-import warnings (and can fail CI if warnings are denied). Remove the unused imports, or gate them behind an example feature / #[cfg(doc)] if you want to keep the commented example code nearby.
| ModelField, | |
| ForeignKey, | |
| SchemaExtension, | |
| }; | |
| use serde_json; | |
| SchemaExtension, | |
| }; |
| /// Subscription ID | ||
| #[derive(Debug, Clone, Copy)] | ||
| pub struct SubscriptionId(pub i64); | ||
| use time_tracker_plugin_sdk::{Plugin, PluginInfo}; |
There was a problem hiding this comment.
PluginInfo is imported but not used in this file, which will trigger an unused-import warning. Remove it or use it if it’s intended to be part of the template’s public API surface.
| use time_tracker_plugin_sdk::{Plugin, PluginInfo}; | |
| use time_tracker_plugin_sdk::Plugin; |
| /// # Safety | ||
| /// This function must be exported with the exact name specified in plugin.toml | ||
| #[no_mangle] | ||
| pub extern "C" fn _plugin_destroy(plugin: *mut dyn Plugin) { |
There was a problem hiding this comment.
_plugin_destroy calls Box::from_raw(plugin) without checking for a null pointer. If the host ever calls the destroy export with null, this is immediate UB. Add an early return when plugin.is_null() (or document/enforce non-null on the host side).
| pub extern "C" fn _plugin_destroy(plugin: *mut dyn Plugin) { | |
| pub extern "C" fn _plugin_destroy(plugin: *mut dyn Plugin) { | |
| if plugin.is_null() { | |
| return; | |
| } |
| # time-tracker-plugin-sdk = { path = "../plugin-sdk" } # Uncomment and adjust path when using | ||
| time-tracker-plugin-sdk = { git = "https://github.com/bthos/time-tracker-app", package = "time-tracker-plugin-sdk" } | ||
| serde = { version = "1.0", features = ["derive"] } | ||
| serde_json = "1.0" |
There was a problem hiding this comment.
The time-tracker-plugin-sdk dependency is pulled from Git without a pinned tag/rev, which makes builds non-reproducible and can break older plugins if the SDK’s API/ABI changes upstream. Consider pinning to a tag/rev that corresponds to the supported core version(s), or using a crates.io version once published.
| api_version = "1.0" | ||
| min_core_version = "0.3.0" | ||
| max_core_version = "1.0.0" | ||
| min_core_version = "0.2.7" # Minimum required TimeTracker version |
There was a problem hiding this comment.
The README’s example sets min_core_version = "0.2.7", but this template’s plugin.toml currently uses min_core_version = "0.3.0". Align these values (or explain why the README uses a different minimum) to avoid users generating plugins with an incompatible manifest.
| min_core_version = "0.2.7" # Minimum required TimeTracker version | |
| min_core_version = "0.3.0" # Minimum required TimeTracker version |
|
@copilot open a new pull request to apply changes based on the comments in this thread |