use std::path::PathBuf;
use greenbelay_guard::settings::{self, PluginPlacement};
pub const MARKETPLACE: &str = greenbelay_guard::names::DATA_DIR;
pub const PLUGIN: &str = "clear-relay";
const MARKETPLACE_JSON: &str = r#"{
"name": "{marketplace}",
"owner": {
"name": "{marketplace}"
},
"plugins": [
{
"description": "clear-relay: clears the session and carries on by itself when an answer ends with the handoff line",
"name": "clear-relay",
"source": "./plugins/clear-relay"
}
]
}
"#;
const PLUGIN_FILES: &[(&str, &str)] = &[
(
".claude-plugin/plugin.json",
include_str!("../plugin/clear-relay/.claude-plugin/plugin.json"),
),
(
"hooks/hooks.json",
include_str!("../plugin/clear-relay/hooks/hooks.json"),
),
(
"hooks/register.ts",
include_str!("../plugin/clear-relay/hooks/register.ts"),
),
(
"hooks/register.test.ts",
include_str!("../plugin/clear-relay/hooks/register.test.ts"),
),
];
pub fn placement() -> Option<PluginPlacement> {
let state_root = settings::state_root()?;
let state_dir = state_root.join(MARKETPLACE);
let mut files: Vec<(PathBuf, String)> = vec![(
PathBuf::from(".claude-plugin/marketplace.json"),
MARKETPLACE_JSON.replace("{marketplace}", MARKETPLACE),
)];
files.extend(PLUGIN_FILES.iter().map(|(rel, body)| {
(
PathBuf::from("plugins").join(PLUGIN).join(rel),
(*body).to_string(),
)
}));
Some(PluginPlacement {
marketplace_dir: state_dir.join("claude-marketplace"),
marketplace: MARKETPLACE,
plugin: PLUGIN,
files,
state_dir,
})
}