Skip to content

Update plugin template to match current TimeTracker plugin system#1

Merged
bthos merged 1 commit intomainfrom
update-plugin-template
Feb 8, 2026
Merged

Update plugin template to match current TimeTracker plugin system#1
bthos merged 1 commit intomainfrom
update-plugin-template

Conversation

@bthos
Copy link
Collaborator

@bthos 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>
Copilot AI review requested due to automatic review settings February 8, 2026 00:54
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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-sdk and updated the example plugin implementation accordingly.
  • Changed the backend entry point to _plugin_create and added _plugin_destroy for 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.

Comment on lines +12 to +16
ModelField,
ForeignKey,
SchemaExtension,
};
use serde_json;
Copy link

Copilot AI Feb 8, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
ModelField,
ForeignKey,
SchemaExtension,
};
use serde_json;
SchemaExtension,
};

Copilot uses AI. Check for mistakes.
/// Subscription ID
#[derive(Debug, Clone, Copy)]
pub struct SubscriptionId(pub i64);
use time_tracker_plugin_sdk::{Plugin, PluginInfo};
Copy link

Copilot AI Feb 8, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
use time_tracker_plugin_sdk::{Plugin, PluginInfo};
use time_tracker_plugin_sdk::Plugin;

Copilot uses AI. Check for mistakes.
/// # 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) {
Copy link

Copilot AI Feb 8, 2026

Choose a reason for hiding this comment

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

_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).

Suggested change
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;
}

Copilot uses AI. Check for mistakes.
Comment on lines +18 to 21
# 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"
Copy link

Copilot AI Feb 8, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
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
Copy link

Copilot AI Feb 8, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
min_core_version = "0.2.7" # Minimum required TimeTracker version
min_core_version = "0.3.0" # Minimum required TimeTracker version

Copilot uses AI. Check for mistakes.
@bthos
Copy link
Collaborator Author

bthos commented Feb 8, 2026

@copilot open a new pull request to apply changes based on the comments in this thread

Copy link

Copilot AI commented Feb 8, 2026

@bthos I've opened a new pull request, #2, to work on those changes. Once the pull request is ready, I'll request review from you.

@bthos bthos merged commit b5ddfc8 into main Feb 8, 2026
12 checks passed
@bthos bthos deleted the update-plugin-template branch February 8, 2026 01:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments