Expand description
SDK for building vagus plugins — standalone vagus-<name> binaries that vagus core
dispatches to (the git/kubectl/gh-extension pattern). See docs/plugin-contract.md.
Using this crate is optional: a plugin in any language can speak the protocol directly. In Rust it saves you from re-implementing the wire format, the env contract, and the vault-write guard.
§Minimal plugin
use vagus_plugin::{Emitter, describe, is_describe};
fn main() -> std::io::Result<()> {
let args: Vec<String> = std::env::args().skip(1).collect();
if is_describe(&args) {
describe("vagus-hello — example plugin");
return Ok(());
}
let mut out = Emitter::from_env();
out.progress(1, Some(1), "working");
out.write_note("30-Resources/hello/note.md", "# hi\n\nfrom a plugin\n")?;
out.result_ok(serde_json::json!({ "notes": 1 }));
Ok(())
}Re-exports§
pub use vagus_plugin_protocol as protocol;
Structs§
Constants§
- DESCRIBE_
SUBCOMMAND - Reserved discovery subcommand:
vagus-<name> __describeprints a one-line summary on stdout forvagus plugins. Used by both core (caller) and the SDK (callee).
Functions§
- config_
dir - This plugin’s own config dir:
~/.config/vagus-<name>/(XDG, even on macOS — to sit alongside vagus core, which deliberately uses XDG paths). Core never reads it. Respects$XDG_CONFIG_HOME. - data_
dir - This plugin’s own state/cache dir:
~/.local/share/vagus-<name>/(XDG) — outside iCloud (G1). Respects$XDG_DATA_HOME. - describe
- Print a one-line description for
vagus pluginsdiscovery. - is_
describe - True when the first arg is the
DESCRIBE_SUBCOMMAND. - protocol_
mode - True when core launched us in NDJSON protocol mode (vs. a direct standalone run).
- vagus_
bin - Path to the
vagusbinary for callbacks (e.g. indexing standalone). Falls back tovaguson PATH. - vault
- Resolved vault root. Prefers
$VAGUS_VAULT(set by core); falls back to the documented~/brainsymlink for standalone runs. ReturnsNoneonly if neither is resolvable.