Compare commits

..

8 Commits

Author SHA1 Message Date
f8d011447e chore(owlry): bump version to 1.0.8 2026-04-06 02:39:19 +02:00
9163b1ea6c chore(owlry-rune): bump version to 1.1.4 2026-04-06 02:38:47 +02:00
6586f5d6c2 fix(plugins): close remaining gaps in new plugin format support
- Fix cmd_runtimes() help text: init.lua/init.rn → main.lua/main.rn
- Add .lua extension validation to owlry-lua manifest (mirrors Rune)
- Replace eprintln! with log::warn!/log::debug! in owlry-lua loader
- Add log = "0.4" dependency to owlry-lua
- Add tests: [[providers]] deserialization in owlry-core manifest,
  manifest provider fallback in owlry-lua and owlry-rune loaders,
  non-runtime plugin filtering in both runtimes
2026-04-06 02:38:42 +02:00
a6e94deb3c fix(runtime): prevent dlclose() to avoid SIGSEGV on runtime teardown
Wrap LoadedRuntime._library in ManuallyDrop so dlclose() is never called.
dlclose() unmaps the library code; thread-local destructors inside liblua.so
then SIGSEGV when they try to run against the unmapped addresses.

Also filter out non-.lua plugins in the Lua runtime's discover_plugins()
so liblua.so does not attempt to load Rune plugins.
2026-04-06 02:26:12 +02:00
de74cac67d chore(owlry-lua): bump version to 1.1.3 2026-04-06 02:22:08 +02:00
2f396306fd chore(owlry-core): bump version to 1.3.4 2026-04-06 02:22:07 +02:00
133d5264ea feat(plugins): update plugin format to new entry_point + [[providers]] style
- owlry-core/manifest: add entry_point alias for entry field, add ProviderSpec
  struct for [[providers]] array, change default entry to main.lua
- owlry-lua/manifest: add ProviderDecl struct and providers: Vec<ProviderDecl>
  for [[providers]] support
- owlry-lua/loader: fall back to manifest [[providers]] when script has no API
  registrations; fall back to global refresh() for manifest-declared providers
- owlry-lua/api: expose call_global_refresh() that calls the top-level Lua
  refresh() function directly
- owlry/plugin_commands: update create templates to emit new format:
  entry_point instead of entry, [[providers]] instead of [provides],
  main.rn/main.lua instead of init.rn/init.lua, Rune uses Item::new() builder
  pattern, Lua uses standalone refresh() function
- cmd_validate: accept [[providers]] declarations as a valid provides source
2026-04-06 02:22:03 +02:00
a16c3a0523 fix(just): skip meta packages without PKGBUILD in aur-publish-all 2026-04-06 02:11:32 +02:00
14 changed files with 423 additions and 114 deletions

9
Cargo.lock generated
View File

@@ -2348,7 +2348,7 @@ dependencies = [
[[package]] [[package]]
name = "owlry" name = "owlry"
version = "1.0.7" version = "1.0.8"
dependencies = [ dependencies = [
"chrono", "chrono",
"clap", "clap",
@@ -2369,7 +2369,7 @@ dependencies = [
[[package]] [[package]]
name = "owlry-core" name = "owlry-core"
version = "1.3.3" version = "1.3.4"
dependencies = [ dependencies = [
"chrono", "chrono",
"ctrlc", "ctrlc",
@@ -2397,11 +2397,12 @@ dependencies = [
[[package]] [[package]]
name = "owlry-lua" name = "owlry-lua"
version = "1.1.2" version = "1.1.3"
dependencies = [ dependencies = [
"abi_stable", "abi_stable",
"chrono", "chrono",
"dirs", "dirs",
"log",
"meval", "meval",
"mlua", "mlua",
"owlry-plugin-api", "owlry-plugin-api",
@@ -2423,7 +2424,7 @@ dependencies = [
[[package]] [[package]]
name = "owlry-rune" name = "owlry-rune"
version = "1.1.3" version = "1.1.4"
dependencies = [ dependencies = [
"chrono", "chrono",
"dirs", "dirs",

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "owlry-core" name = "owlry-core"
version = "1.3.3" version = "1.3.4"
edition.workspace = true edition.workspace = true
rust-version.workspace = true rust-version.workspace = true
license.workspace = true license.workspace = true

View File

@@ -10,6 +10,10 @@ use super::error::{PluginError, PluginResult};
#[derive(Debug, Clone, Serialize, Deserialize)] #[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PluginManifest { pub struct PluginManifest {
pub plugin: PluginInfo, pub plugin: PluginInfo,
/// Provider declarations from [[providers]] sections (new-style)
#[serde(default)]
pub providers: Vec<ProviderSpec>,
/// Legacy provides block (old-style)
#[serde(default)] #[serde(default)]
pub provides: PluginProvides, pub provides: PluginProvides,
#[serde(default)] #[serde(default)]
@@ -43,7 +47,7 @@ pub struct PluginInfo {
#[serde(default = "default_owlry_version")] #[serde(default = "default_owlry_version")]
pub owlry_version: String, pub owlry_version: String,
/// Entry point file (relative to plugin directory) /// Entry point file (relative to plugin directory)
#[serde(default = "default_entry")] #[serde(default = "default_entry", alias = "entry_point")]
pub entry: String, pub entry: String,
} }
@@ -52,7 +56,27 @@ fn default_owlry_version() -> String {
} }
fn default_entry() -> String { fn default_entry() -> String {
"init.lua".to_string() "main.lua".to_string()
}
/// A provider declared in a [[providers]] section
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ProviderSpec {
pub id: String,
pub name: String,
#[serde(default)]
pub prefix: Option<String>,
#[serde(default)]
pub icon: Option<String>,
/// "static" (default) or "dynamic"
#[serde(default = "default_provider_type", rename = "type")]
pub provider_type: String,
#[serde(default)]
pub type_id: Option<String>,
}
fn default_provider_type() -> String {
"static".to_string()
} }
/// What the plugin provides /// What the plugin provides
@@ -278,7 +302,7 @@ version = "1.0.0"
assert_eq!(manifest.plugin.id, "test-plugin"); assert_eq!(manifest.plugin.id, "test-plugin");
assert_eq!(manifest.plugin.name, "Test Plugin"); assert_eq!(manifest.plugin.name, "Test Plugin");
assert_eq!(manifest.plugin.version, "1.0.0"); assert_eq!(manifest.plugin.version, "1.0.0");
assert_eq!(manifest.plugin.entry, "init.lua"); assert_eq!(manifest.plugin.entry, "main.lua");
} }
#[test] #[test]
@@ -317,6 +341,70 @@ api_url = "https://api.example.com"
assert_eq!(manifest.permissions.run_commands, vec!["myapp"]); assert_eq!(manifest.permissions.run_commands, vec!["myapp"]);
} }
#[test]
fn test_parse_new_format_with_providers_array() {
let toml_str = r#"
[plugin]
id = "my-plugin"
name = "My Plugin"
version = "0.1.0"
description = "Test"
entry_point = "main.rn"
[[providers]]
id = "my-plugin"
name = "My Plugin"
type = "static"
type_id = "myplugin"
icon = "system-run"
prefix = ":mp"
"#;
let manifest: PluginManifest = toml::from_str(toml_str).unwrap();
assert_eq!(manifest.plugin.entry, "main.rn");
assert_eq!(manifest.providers.len(), 1);
let p = &manifest.providers[0];
assert_eq!(p.id, "my-plugin");
assert_eq!(p.name, "My Plugin");
assert_eq!(p.provider_type, "static");
assert_eq!(p.type_id.as_deref(), Some("myplugin"));
assert_eq!(p.icon.as_deref(), Some("system-run"));
assert_eq!(p.prefix.as_deref(), Some(":mp"));
}
#[test]
fn test_parse_new_format_entry_point_alias() {
let toml_str = r#"
[plugin]
id = "test"
name = "Test"
version = "1.0.0"
entry_point = "main.lua"
"#;
let manifest: PluginManifest = toml::from_str(toml_str).unwrap();
assert_eq!(manifest.plugin.entry, "main.lua");
}
#[test]
fn test_provider_spec_defaults() {
let toml_str = r#"
[plugin]
id = "test"
name = "Test"
version = "1.0.0"
[[providers]]
id = "test"
name = "Test"
"#;
let manifest: PluginManifest = toml::from_str(toml_str).unwrap();
assert_eq!(manifest.providers.len(), 1);
let p = &manifest.providers[0];
assert_eq!(p.provider_type, "static"); // default
assert!(p.prefix.is_none());
assert!(p.icon.is_none());
assert!(p.type_id.is_none());
}
#[test] #[test]
fn test_version_compatibility() { fn test_version_compatibility() {
let toml_str = r#" let toml_str = r#"

View File

@@ -10,6 +10,7 @@
//! Note: This module is infrastructure for the runtime architecture. Full integration //! Note: This module is infrastructure for the runtime architecture. Full integration
//! is pending Phase 5 (AUR Packaging) when runtime packages will be available. //! is pending Phase 5 (AUR Packaging) when runtime packages will be available.
use std::mem::ManuallyDrop;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::sync::Arc; use std::sync::Arc;
@@ -69,8 +70,11 @@ pub struct ScriptRuntimeVTable {
pub struct LoadedRuntime { pub struct LoadedRuntime {
/// Runtime name (for logging) /// Runtime name (for logging)
name: &'static str, name: &'static str,
/// Keep library alive /// Keep library alive — wrapped in ManuallyDrop so we never call dlclose().
_library: Arc<Library>, /// dlclose() unmaps the library code; any thread-local destructors inside the
/// library then SIGSEGV when they try to run against the unmapped addresses.
/// Runtime libraries live for the process lifetime, so leaking the handle is safe.
_library: ManuallyDrop<Arc<Library>>,
/// Runtime vtable /// Runtime vtable
vtable: &'static ScriptRuntimeVTable, vtable: &'static ScriptRuntimeVTable,
/// Runtime handle (state) /// Runtime handle (state)
@@ -138,7 +142,7 @@ impl LoadedRuntime {
Ok(Self { Ok(Self {
name, name,
_library: library, _library: ManuallyDrop::new(library),
vtable, vtable,
handle, handle,
providers, providers,
@@ -166,6 +170,8 @@ impl LoadedRuntime {
impl Drop for LoadedRuntime { impl Drop for LoadedRuntime {
fn drop(&mut self) { fn drop(&mut self) {
(self.vtable.drop)(self.handle); (self.vtable.drop)(self.handle);
// Do NOT drop _library: ManuallyDrop ensures dlclose() is never called.
// See field comment for rationale.
} }
} }

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "owlry-lua" name = "owlry-lua"
version = "1.1.2" version = "1.1.3"
edition.workspace = true edition.workspace = true
rust-version.workspace = true rust-version.workspace = true
license.workspace = true license.workspace = true
@@ -30,6 +30,9 @@ serde_json = "1.0"
# Version compatibility # Version compatibility
semver = "1" semver = "1"
# Logging
log = "0.4"
# HTTP client for plugins # HTTP client for plugins
reqwest = { version = "0.13", default-features = false, features = ["native-tls", "blocking", "json"] } reqwest = { version = "0.13", default-features = false, features = ["native-tls", "blocking", "json"] }

View File

@@ -50,3 +50,8 @@ pub fn call_refresh(lua: &Lua, provider_name: &str) -> LuaResult<Vec<PluginItem>
pub fn call_query(lua: &Lua, provider_name: &str, query: &str) -> LuaResult<Vec<PluginItem>> { pub fn call_query(lua: &Lua, provider_name: &str, query: &str) -> LuaResult<Vec<PluginItem>> {
provider::call_query(lua, provider_name, query) provider::call_query(lua, provider_name, query)
} }
/// Call the global `refresh()` function (for manifest-declared providers)
pub fn call_global_refresh(lua: &Lua) -> LuaResult<Vec<PluginItem>> {
provider::call_global_refresh(lua)
}

View File

@@ -76,6 +76,15 @@ fn register_provider(lua: &Lua, config: Table) -> LuaResult<()> {
Ok(()) Ok(())
} }
/// Call the top-level `refresh()` global function (for manifest-declared providers)
pub fn call_global_refresh(lua: &Lua) -> LuaResult<Vec<PluginItem>> {
let globals = lua.globals();
match globals.get::<Function>("refresh") {
Ok(refresh_fn) => parse_items_result(refresh_fn.call(())?),
Err(_) => Ok(Vec::new()),
}
}
/// Get all registered providers /// Get all registered providers
pub fn get_registrations(lua: &Lua) -> LuaResult<Vec<ProviderRegistration>> { pub fn get_registrations(lua: &Lua) -> LuaResult<Vec<ProviderRegistration>> {
// Suppress unused warning // Suppress unused warning

View File

@@ -96,8 +96,28 @@ impl LoadedPlugin {
.as_ref() .as_ref()
.ok_or_else(|| "Plugin not initialized".to_string())?; .ok_or_else(|| "Plugin not initialized".to_string())?;
api::get_provider_registrations(lua) let mut regs = api::get_provider_registrations(lua)
.map_err(|e| format!("Failed to get registrations: {}", e)) .map_err(|e| format!("Failed to get registrations: {}", e))?;
// Fall back to manifest [[providers]] declarations when the script
// doesn't call owlry.provider.register() (new-style plugins)
if regs.is_empty() {
for decl in &self.manifest.providers {
regs.push(ProviderRegistration {
name: decl.id.clone(),
display_name: decl.name.clone(),
type_id: decl.type_id.clone().unwrap_or_else(|| decl.id.clone()),
default_icon: decl
.icon
.clone()
.unwrap_or_else(|| "application-x-addon".to_string()),
prefix: decl.prefix.clone(),
is_dynamic: decl.provider_type == "dynamic",
});
}
}
Ok(regs)
} }
/// Call a provider's refresh function /// Call a provider's refresh function
@@ -107,7 +127,17 @@ impl LoadedPlugin {
.as_ref() .as_ref()
.ok_or_else(|| "Plugin not initialized".to_string())?; .ok_or_else(|| "Plugin not initialized".to_string())?;
api::call_refresh(lua, provider_name).map_err(|e| format!("Refresh failed: {}", e)) let items = api::call_refresh(lua, provider_name)
.map_err(|e| format!("Refresh failed: {}", e))?;
// If the API path returned nothing, try calling the global refresh()
// function directly (new-style plugins with manifest [[providers]])
if items.is_empty() {
return api::call_global_refresh(lua)
.map_err(|e| format!("Refresh failed: {}", e));
}
Ok(items)
} }
/// Call a provider's query function /// Call a provider's query function
@@ -156,9 +186,18 @@ pub fn discover_plugins(
match PluginManifest::load(&manifest_path) { match PluginManifest::load(&manifest_path) {
Ok(manifest) => { Ok(manifest) => {
// Skip plugins whose entry point is not a Lua file
if !manifest.plugin.entry.ends_with(".lua") {
log::debug!(
"owlry-lua: Skipping non-Lua plugin at {} (entry: {})",
path.display(),
manifest.plugin.entry
);
continue;
}
let id = manifest.plugin.id.clone(); let id = manifest.plugin.id.clone();
if plugins.contains_key(&id) { if plugins.contains_key(&id) {
eprintln!( log::warn!(
"owlry-lua: Duplicate plugin ID '{}', skipping {}", "owlry-lua: Duplicate plugin ID '{}', skipping {}",
id, id,
path.display() path.display()
@@ -168,7 +207,7 @@ pub fn discover_plugins(
plugins.insert(id, (manifest, path)); plugins.insert(id, (manifest, path));
} }
Err(e) => { Err(e) => {
eprintln!( log::warn!(
"owlry-lua: Failed to load plugin at {}: {}", "owlry-lua: Failed to load plugin at {}: {}",
path.display(), path.display(),
e e
@@ -229,4 +268,79 @@ version = "1.0.0"
let plugins = discover_plugins(Path::new("/nonexistent/path")).unwrap(); let plugins = discover_plugins(Path::new("/nonexistent/path")).unwrap();
assert!(plugins.is_empty()); assert!(plugins.is_empty());
} }
#[test]
fn test_discover_skips_non_lua_plugins() {
let temp = TempDir::new().unwrap();
let plugins_dir = temp.path();
// Rune plugin — should be skipped by the Lua runtime
let rune_dir = plugins_dir.join("rune-plugin");
fs::create_dir_all(&rune_dir).unwrap();
fs::write(
rune_dir.join("plugin.toml"),
r#"
[plugin]
id = "rune-plugin"
name = "Rune Plugin"
version = "1.0.0"
entry_point = "main.rn"
[[providers]]
id = "rune-plugin"
name = "Rune Plugin"
"#,
)
.unwrap();
fs::write(rune_dir.join("main.rn"), "pub fn refresh() { [] }").unwrap();
// Lua plugin — should be discovered
create_test_plugin(plugins_dir, "lua-plugin");
let plugins = discover_plugins(plugins_dir).unwrap();
assert_eq!(plugins.len(), 1);
assert!(plugins.contains_key("lua-plugin"));
assert!(!plugins.contains_key("rune-plugin"));
}
#[test]
fn test_manifest_provider_fallback() {
let temp = TempDir::new().unwrap();
let plugin_dir = temp.path().join("test-plugin");
fs::create_dir_all(&plugin_dir).unwrap();
fs::write(
plugin_dir.join("plugin.toml"),
r#"
[plugin]
id = "test-plugin"
name = "Test Plugin"
version = "1.0.0"
entry_point = "main.lua"
[[providers]]
id = "test-plugin"
name = "Test Plugin"
type = "static"
type_id = "testplugin"
icon = "system-run"
prefix = ":tp"
"#,
)
.unwrap();
// Script that does NOT call owlry.provider.register()
fs::write(plugin_dir.join("main.lua"), "function refresh() return {} end").unwrap();
let manifest =
crate::manifest::PluginManifest::load(&plugin_dir.join("plugin.toml")).unwrap();
let mut plugin = LoadedPlugin::new(manifest, plugin_dir);
plugin.initialize().unwrap();
let regs = plugin.get_provider_registrations().unwrap();
assert_eq!(regs.len(), 1, "should fall back to [[providers]] declaration");
assert_eq!(regs[0].name, "test-plugin");
assert_eq!(regs[0].type_id, "testplugin");
assert_eq!(regs[0].prefix.as_deref(), Some(":tp"));
assert!(!regs[0].is_dynamic);
}
} }

View File

@@ -8,6 +8,10 @@ use std::path::Path;
#[derive(Debug, Clone, Serialize, Deserialize)] #[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PluginManifest { pub struct PluginManifest {
pub plugin: PluginInfo, pub plugin: PluginInfo,
/// Provider declarations from [[providers]] sections (new-style)
#[serde(default)]
pub providers: Vec<ProviderDecl>,
/// Legacy provides block (old-style)
#[serde(default)] #[serde(default)]
pub provides: PluginProvides, pub provides: PluginProvides,
#[serde(default)] #[serde(default)]
@@ -16,6 +20,26 @@ pub struct PluginManifest {
pub settings: HashMap<String, toml::Value>, pub settings: HashMap<String, toml::Value>,
} }
/// A provider declared in a [[providers]] section
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ProviderDecl {
pub id: String,
pub name: String,
#[serde(default)]
pub prefix: Option<String>,
#[serde(default)]
pub icon: Option<String>,
/// "static" (default) or "dynamic"
#[serde(default = "default_provider_type", rename = "type")]
pub provider_type: String,
#[serde(default)]
pub type_id: Option<String>,
}
fn default_provider_type() -> String {
"static".to_string()
}
/// Core plugin information /// Core plugin information
#[derive(Debug, Clone, Serialize, Deserialize)] #[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PluginInfo { pub struct PluginInfo {
@@ -127,6 +151,11 @@ impl PluginManifest {
)); ));
} }
// Lua plugins must have a .lua entry point
if !self.plugin.entry.ends_with(".lua") {
return Err("Entry point must be a .lua file for Lua plugins".to_string());
}
Ok(()) Ok(())
} }

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "owlry-rune" name = "owlry-rune"
version = "1.1.3" version = "1.1.4"
edition = "2024" edition = "2024"
rust-version = "1.90" rust-version = "1.90"
description = "Rune scripting runtime for owlry plugins" description = "Rune scripting runtime for owlry plugins"

View File

@@ -203,6 +203,7 @@ pub fn discover_rune_plugins(plugins_dir: &Path) -> Result<HashMap<String, Loade
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use std::fs;
use tempfile::TempDir; use tempfile::TempDir;
#[test] #[test]
@@ -211,4 +212,81 @@ mod tests {
let plugins = discover_rune_plugins(temp.path()).unwrap(); let plugins = discover_rune_plugins(temp.path()).unwrap();
assert!(plugins.is_empty()); assert!(plugins.is_empty());
} }
#[test]
fn test_discover_skips_non_rune_plugins() {
let temp = TempDir::new().unwrap();
let plugins_dir = temp.path();
// Lua plugin — should be skipped by the Rune runtime
let lua_dir = plugins_dir.join("lua-plugin");
fs::create_dir_all(&lua_dir).unwrap();
fs::write(
lua_dir.join("plugin.toml"),
r#"
[plugin]
id = "lua-plugin"
name = "Lua Plugin"
version = "1.0.0"
entry_point = "main.lua"
[[providers]]
id = "lua-plugin"
name = "Lua Plugin"
"#,
)
.unwrap();
fs::write(lua_dir.join("main.lua"), "function refresh() return {} end").unwrap();
let plugins = discover_rune_plugins(plugins_dir).unwrap();
assert!(plugins.is_empty(), "Lua plugin should be skipped by Rune runtime");
}
#[test]
fn test_manifest_provider_fallback() {
let temp = TempDir::new().unwrap();
let plugin_dir = temp.path().join("test-plugin");
fs::create_dir_all(&plugin_dir).unwrap();
fs::write(
plugin_dir.join("plugin.toml"),
r#"
[plugin]
id = "test-plugin"
name = "Test Plugin"
version = "1.0.0"
entry_point = "main.rn"
[[providers]]
id = "test-plugin"
name = "Test Plugin"
type = "static"
type_id = "testplugin"
icon = "system-run"
prefix = ":tp"
"#,
)
.unwrap();
// Script that exports refresh() but doesn't call register_provider()
fs::write(
plugin_dir.join("main.rn"),
r#"use owlry::Item;
pub fn refresh() {
[]
}
"#,
)
.unwrap();
let manifest =
crate::manifest::PluginManifest::load(&plugin_dir.join("plugin.toml")).unwrap();
let plugin = LoadedPlugin::new(manifest, plugin_dir).unwrap();
let regs = plugin.provider_registrations();
assert_eq!(regs.len(), 1, "should fall back to [[providers]] declaration");
assert_eq!(regs[0].name, "test-plugin");
assert_eq!(regs[0].type_id, "testplugin");
assert_eq!(regs[0].prefix.as_deref(), Some(":tp"));
assert!(regs[0].is_static);
}
} }

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "owlry" name = "owlry"
version = "1.0.7" version = "1.0.8"
edition = "2024" edition = "2024"
rust-version = "1.90" rust-version = "1.90"
description = "A lightweight, owl-themed application launcher for Wayland" description = "A lightweight, owl-themed application launcher for Wayland"

View File

@@ -366,6 +366,14 @@ fn cmd_info_installed(name: &str, json_output: bool) -> CommandResult {
"runtime": runtime.to_string(), "runtime": runtime.to_string(),
"runtime_available": runtime_available, "runtime_available": runtime_available,
"path": plugin_path.display().to_string(), "path": plugin_path.display().to_string(),
"providers": manifest.providers.iter().map(|p| serde_json::json!({
"id": p.id,
"name": p.name,
"type": p.provider_type,
"type_id": p.type_id,
"prefix": p.prefix,
"icon": p.icon,
})).collect::<Vec<_>>(),
"provides": { "provides": {
"providers": manifest.provides.providers, "providers": manifest.provides.providers,
"actions": manifest.provides.actions, "actions": manifest.provides.actions,
@@ -406,9 +414,13 @@ fn cmd_info_installed(name: &str, json_output: bool) -> CommandResult {
); );
println!("Path: {}", plugin_path.display()); println!("Path: {}", plugin_path.display());
println!(); println!();
println!("Provides:"); println!("Providers:");
for p in &manifest.providers {
let prefix = p.prefix.as_deref().map(|s| format!(" ({})", s)).unwrap_or_default();
println!(" {} [{}]{}", p.name, p.provider_type, prefix);
}
if !manifest.provides.providers.is_empty() { if !manifest.provides.providers.is_empty() {
println!(" Providers: {}", manifest.provides.providers.join(", ")); println!(" {}", manifest.provides.providers.join(", "));
} }
if manifest.provides.actions { if manifest.provides.actions {
println!(" Actions: yes"); println!(" Actions: yes");
@@ -754,10 +766,16 @@ fn cmd_create(
let desc = description.unwrap_or("A custom owlry plugin"); let desc = description.unwrap_or("A custom owlry plugin");
let (entry_file, entry_ext) = match runtime { let (entry_file, entry_ext) = match runtime {
PluginRuntime::Lua => ("init.lua", "lua"), PluginRuntime::Lua => ("main.lua", "lua"),
PluginRuntime::Rune => ("init.rn", "rn"), PluginRuntime::Rune => ("main.rn", "rn"),
}; };
// Derive a short type_id from the plugin name (strip common prefixes)
let type_id = name
.strip_prefix("owlry-")
.unwrap_or(name)
.replace('-', "_");
// Create plugin.toml // Create plugin.toml
let manifest = format!( let manifest = format!(
r#"[plugin] r#"[plugin]
@@ -765,25 +783,21 @@ id = "{name}"
name = "{display}" name = "{display}"
version = "0.1.0" version = "0.1.0"
description = "{desc}" description = "{desc}"
author = "" entry_point = "{entry_file}"
owlry_version = ">=0.3.0"
entry = "{entry_file}"
[provides] [[providers]]
providers = ["{name}"] id = "{name}"
actions = false name = "{display}"
themes = [] type = "static"
hooks = false type_id = "{type_id}"
icon = "application-x-addon"
[permissions] # prefix = ":{type_id}"
network = false
filesystem = []
run_commands = []
"#, "#,
name = name, name = name,
display = display, display = display,
desc = desc, desc = desc,
entry_file = entry_file, entry_file = entry_file,
type_id = type_id,
); );
fs::write(plugin_dir.join("plugin.toml"), manifest) fs::write(plugin_dir.join("plugin.toml"), manifest)
@@ -792,91 +806,51 @@ run_commands = []
// Create entry point template based on runtime // Create entry point template based on runtime
match runtime { match runtime {
PluginRuntime::Lua => { PluginRuntime::Lua => {
let init_lua = format!( let main_lua = format!(
r#"-- {display} Plugin for Owlry r#"-- {display} Plugin for Owlry
-- {desc} -- {desc}
-- Register the provider function refresh()
owlry.provider.register({{ return {{
name = "{name}", {{
display_name = "{display}", id = "{name}:example",
type_id = "{name}", name = "Example Item",
default_icon = "application-x-executable", description = "This is an example item from {display}",
icon = "dialog-information",
refresh = function() command = "echo 'Hello from {name}!'",
-- Return a list of items tags = {{}},
return {{ }},
{{ }}
id = "{name}:example", end
name = "Example Item",
description = "This is an example item from {display}",
icon = "dialog-information",
command = "echo 'Hello from {name}!'",
terminal = false,
tags = {{}}
}}
}}
end
}})
owlry.log.info("{display} plugin loaded")
"#, "#,
name = name, name = name,
display = display, display = display,
desc = desc, desc = desc,
); );
fs::write(plugin_dir.join(entry_file), init_lua) fs::write(plugin_dir.join(entry_file), main_lua)
.map_err(|e| format!("Failed to write {}: {}", entry_file, e))?; .map_err(|e| format!("Failed to write {}: {}", entry_file, e))?;
} }
PluginRuntime::Rune => { PluginRuntime::Rune => {
// Note: Rune uses #{{ for object literals, so we build manually let main_rn = format!(
let init_rn = format!( r#"use owlry::Item;
r#"//! {display} Plugin for Owlry
//! {desc}
/// Plugin item structure pub fn refresh() {{
struct Item {{{{ let items = [];
id: String,
name: String,
description: String,
icon: String,
command: String,
terminal: bool,
tags: Vec<String>,
}}}}
/// Provider registration items.push(
pub fn register(owlry) {{{{ Item::new("{name}:example", "Example Item", "echo 'Hello from {name}!'")
owlry.provider.register(#{{{{ .description("This is an example item from {display}")
name: "{name}", .icon("dialog-information")
display_name: "{display}", .keywords(["example"]),
type_id: "{name}", );
default_icon: "application-x-executable",
refresh: || {{{{ items
// Return a list of items }}
[
Item {{{{
id: "{name}:example",
name: "Example Item",
description: "This is an example item from {display}",
icon: "dialog-information",
command: "echo 'Hello from {name}!'",
terminal: false,
tags: [],
}}}},
]
}}}},
}}}});
owlry.log.info("{display} plugin loaded");
}}}}
"#, "#,
name = name, name = name,
display = display, display = display,
desc = desc,
); );
fs::write(plugin_dir.join(entry_file), init_rn) fs::write(plugin_dir.join(entry_file), main_rn)
.map_err(|e| format!("Failed to write {}: {}", entry_file, e))?; .map_err(|e| format!("Failed to write {}: {}", entry_file, e))?;
} }
} }
@@ -955,13 +929,14 @@ fn cmd_validate(path: Option<&str>) -> CommandResult {
)); ));
} }
// Check for empty provides // Check for empty provides (accept either [[providers]] or [provides])
if manifest.provides.providers.is_empty() let has_providers = !manifest.providers.is_empty()
&& !manifest.provides.actions || !manifest.provides.providers.is_empty()
&& manifest.provides.themes.is_empty() || manifest.provides.actions
&& !manifest.provides.hooks || !manifest.provides.themes.is_empty()
{ || manifest.provides.hooks;
warnings.push("Plugin does not provide any features".to_string()); if !has_providers {
warnings.push("Plugin does not declare any providers".to_string());
} }
println!(" Plugin ID: {}", manifest.plugin.id); println!(" Plugin ID: {}", manifest.plugin.id);
@@ -1013,11 +988,11 @@ fn cmd_runtimes() -> CommandResult {
if lua_available { if lua_available {
println!(" ✓ Lua - Installed"); println!(" ✓ Lua - Installed");
println!(" Package: owlry-lua"); println!(" Package: owlry-lua");
println!(" Entry point: init.lua"); println!(" Entry point: main.lua");
} else { } else {
println!(" ✗ Lua - Not installed"); println!(" ✗ Lua - Not installed");
println!(" Install: yay -S owlry-lua"); println!(" Install: yay -S owlry-lua");
println!(" Entry point: init.lua"); println!(" Entry point: main.lua");
} }
println!(); println!();
@@ -1026,11 +1001,11 @@ fn cmd_runtimes() -> CommandResult {
if rune_available { if rune_available {
println!(" ✓ Rune - Installed"); println!(" ✓ Rune - Installed");
println!(" Package: owlry-rune"); println!(" Package: owlry-rune");
println!(" Entry point: init.rn"); println!(" Entry point: main.rn");
} else { } else {
println!(" ✗ Rune - Not installed"); println!(" ✗ Rune - Not installed");
println!(" Install: yay -S owlry-rune"); println!(" Install: yay -S owlry-rune");
println!(" Entry point: init.rn"); println!(" Entry point: main.rn");
} }
println!(); println!();

View File

@@ -252,6 +252,7 @@ aur-publish-all:
for dir in aur/*/; do for dir in aur/*/; do
pkg=$(basename "$dir") pkg=$(basename "$dir")
[ -d "$dir/.git" ] || continue [ -d "$dir/.git" ] || continue
[ -f "$dir/PKGBUILD" ] || continue
echo "=== $pkg ===" echo "=== $pkg ==="
just aur-publish-pkg "$pkg" just aur-publish-pkg "$pkg"
echo "" echo ""