Marty Plugin Protocol
The official SDK for creating Marty workspace plugins as dynamic libraries. This crate provides everything you need to build plugins that automatically discover and manage projects within monorepos.
๐ Quick Start
1. Create a New Plugin
# Cargo.toml
[]
= "marty-plugin-myframework"
= "0.1.0"
= "2021"
[]
= ["cdylib"] # Required for dynamic library
[]
= "0.2"
= "1.0"
2. Implement Your Plugin
use ;
use ;
use Path;
// Define your plugin
;
// Define project detection logic
;
// Connect plugin to workspace provider
// Export for dynamic loading
export_plugin!;
3. Build and Install
# Build the plugin
# Install to Marty's plugin directory
๐ง Core Concepts
Plugin Discovery Process
- Scanning: Marty walks the workspace using your
include_path_globs()patterns - Filtering: Files matching
exclude_path_globs()are skipped - Detection:
on_file_found()is called for each matching file - Project Creation: Valid projects become
InferredProjectinstances
Workspace Dependencies โ ๏ธ
Critical: workspace_dependencies represents dependencies between projects within the same workspace, NOT external packages.
// โ
CORRECT: Internal workspace projects
vec!
// โ INCORRECT: External packages
vec!
This is used for:
- Build ordering: Dependencies built first
- Change impact: Which projects are affected by changes
- Task orchestration: Proper execution order across projects
๐ Examples by Language
Rust (Cargo.toml)
[]
= { = "../shared-utils" } # โ
Include "shared-utils"
= "1.0" # โ External - ignore
JavaScript/TypeScript (package.json)
Python (pyproject.toml)
[]
= { = "../shared-lib" } # โ
Include "shared-lib"
= "^2.25.0" # โ External - ignore
๐ Plugin Architecture
Core Traits
MartyPlugin: Main plugin interface with metadata and configurationWorkspaceProvider: Project discovery and analysis logic
Key Data Structures
InferredProject: Represents a discovered projectWorkspace: Context passed to plugins (root path, existing projects)Project: Explicit projects with marty.yml files
Dynamic Library Interface
The export_plugin! macro generates C ABI functions for cross-language compatibility:
plugin_name()- Plugin display nameplugin_key()- Unique identifierplugin_on_file_found()- Project detectionplugin_cleanup_string()- Memory management
๐งช Testing Your Plugin
๐ Performance Tips
- Specific patterns: Use precise glob patterns to minimize file system operations
- Fast rejection: Check filenames before reading file contents
- Efficient parsing: Use streaming parsers for large files
- Smart exclusions: Add common build directories to
exclude_path_globs()
๐ ๏ธ Migration from WASM
If you're migrating from WASM plugins:
Build Changes
# OLD: WASM target
# [lib]
# crate-type = ["cdylib"]
# [dependencies]
# serde = { version = "1.0", default-features = false }
# NEW: Dynamic library
[]
= ["cdylib"]
[]
= "1.0" # Full crate ecosystem available!
Code Changes
// OLD: Manual WASM exports
// #[no_mangle]
// pub extern "C" fn _start() { /* ... */ }
// NEW: Simple macro
export_plugin!;
Benefits
- โ Faster execution - Native vs WASM interpretation
- โ Better debugging - Standard debugging tools work
- โ Full ecosystem - Any Rust crate can be used
- โ Simpler deployment - Standard shared libraries
๐ Documentation
- API Documentation - Complete API reference
- Plugin Guide - Detailed examples
- Marty Documentation - Main project docs
๐ Troubleshooting
Common Issues
Plugin not detected:
- Ensure
crate-type = ["cdylib"]in Cargo.toml - Check plugin is in
~/.marty/plugins/directory - Verify
export_plugin!(YourPlugin)is called
Projects not discovered:
- Check
include_path_globs()patterns match your files - Verify
on_file_found()returnsSome(InferredProject)for valid projects - Test patterns don't conflict with excludes
Build errors:
- Plugin struct must have
pub const fn new() -> Self - Must implement
MartyPlugintrait - Import
export_pluginfrommarty_plugin_protocol::dylib
๐ค Contributing
Contributions are welcome! Please see the main repository for contributing guidelines.
๐ License
Licensed under either of Apache License, Version 2.0 or MIT License at your option.
Built by the Marty team ๐ GitHub | Documentation