Skip to main content

LanguagePlugin

Trait LanguagePlugin 

Source
pub trait LanguagePlugin: Send + Sync {
Show 25 methods // Required methods fn name(&self) -> &str; fn extensions(&self) -> &[&str]; fn key_files(&self) -> &[&str]; fn get_lsp_config(&self) -> LspConfig; fn get_init_action(&self, opts: &InitOptions) -> ProjectAction; fn check_tooling_action(&self, path: &Path) -> ProjectAction; fn init_command(&self, opts: &InitOptions) -> String; fn test_command(&self) -> String; fn run_command(&self) -> String; // Provided methods fn detect(&self, path: &Path) -> bool { ... } fn run_command_for_dir(&self, _path: &Path) -> String { ... } fn syntax_check_command(&self) -> Option<String> { ... } fn build_command(&self) -> Option<String> { ... } fn lint_command(&self) -> Option<String> { ... } fn file_ownership_patterns(&self) -> &[&str] { ... } fn owns_file(&self, path: &str) -> bool { ... } fn host_tool_available(&self) -> bool { ... } fn required_binaries(&self) -> Vec<(&str, &str, &str)> { ... } fn lsp_fallback(&self) -> Option<LspConfig> { ... } fn verifier_profile(&self) -> VerifierProfile { ... } fn legal_support_files(&self) -> &[&str] { ... } fn manifest_mutation_policy( &self, _manifest_path: &str, ) -> ManifestMutationPolicy { ... } fn dependency_command_policy(&self, _command: &str) -> CommandPolicyDecision { ... } fn correction_prompt_fragment(&self) -> Option<&str> { ... } fn test_file_patterns(&self) -> &[&str] { ... }
}
Expand description

A plugin for a specific programming language

PSP-5 expands this trait beyond init/test/run to a full capability-based runtime contract that governs detection, verification, LSP, and ownership.

Required Methods§

Source

fn name(&self) -> &str

Name of the language

Source

fn extensions(&self) -> &[&str]

File extensions this plugin handles

Source

fn key_files(&self) -> &[&str]

Key files that identify this language (e.g., Cargo.toml, pyproject.toml)

Source

fn get_lsp_config(&self) -> LspConfig

Get the LSP configuration for this language

Source

fn get_init_action(&self, opts: &InitOptions) -> ProjectAction

Get the action to initialize a new project (greenfield)

Source

fn check_tooling_action(&self, path: &Path) -> ProjectAction

Check if an existing project needs tooling sync (e.g., uv sync, cargo fetch)

Source

fn init_command(&self, opts: &InitOptions) -> String

Get the command to initialize a new project DEPRECATED: Use get_init_action instead

Source

fn test_command(&self) -> String

Get the command to run tests

Source

fn run_command(&self) -> String

Get the command to run the project (for verification)

Provided Methods§

Source

fn detect(&self, path: &Path) -> bool

Detect if this plugin should handle the given project directory

Source

fn run_command_for_dir(&self, _path: &Path) -> String

Get the command to run the project in a specific directory.

Override this to inspect pyproject.toml, Cargo.toml, etc. and return a more appropriate run command than the generic default.

Source

fn syntax_check_command(&self) -> Option<String>

Get the syntax/type check command (e.g., cargo check, uvx ty check .)

Returns None if the plugin has no syntax check command (uses LSP only).

Source

fn build_command(&self) -> Option<String>

Get the build command (e.g., cargo build, npm run build)

Returns None if the language doesn’t have a separate build step.

Source

fn lint_command(&self) -> Option<String>

Get the lint command (e.g., cargo clippy -- -D warnings)

Used only in VerifierStrictness::Strict mode.

Source

fn file_ownership_patterns(&self) -> &[&str]

File glob patterns this plugin owns (e.g., ["*.rs", "Cargo.toml"])

Used for node ownership matching in multi-language repos.

Source

fn owns_file(&self, path: &str) -> bool

PSP-5 Phase 2: Check if a file path belongs to this plugin’s ownership domain

Uses file_ownership_patterns() for suffix/extension matching.

Source

fn host_tool_available(&self) -> bool

Check if the host has the required build tools available

Returns true if the plugin’s primary toolchain is installed and callable. When false, the runtime enters degraded-validation mode.

Source

fn required_binaries(&self) -> Vec<(&str, &str, &str)>

Required host binaries for this plugin, grouped by role.

Each entry is (binary_name, role_description, install_hint). The orchestrator checks these before init and emits install directions for any that are missing.

Source

fn lsp_fallback(&self) -> Option<LspConfig>

Get fallback LSP config when primary is unavailable

Source

fn verifier_profile(&self) -> VerifierProfile

Build a complete verifier profile by probing each capability.

The default implementation auto-assembles from the existing syntax_check_command(), build_command(), test_command(), lint_command(), and host_tool_available() methods.

Plugins override this method to provide per-sensor probing with distinct fallback commands and independent availability checks.

Source

fn legal_support_files(&self) -> &[&str]

Legal support files that the LLM is allowed to create beyond declared output_files (e.g., Cargo.toml for Rust, __init__.py for Python).

These are files that commonly accompany code generation but are not explicitly listed in the plan. The typed parse pipeline’s Layer E uses this to accept known auxiliary files without flagging them as ownership violations.

Source

fn manifest_mutation_policy( &self, _manifest_path: &str, ) -> ManifestMutationPolicy

Policy for manifest file mutations produced by the LLM.

Returns whether a given manifest path may be modified. Plugins can deny mutations to key files (e.g., root Cargo.toml in a workspace) while allowing leaf-level manifest edits.

Source

fn dependency_command_policy(&self, _command: &str) -> CommandPolicyDecision

Policy for dependency-management commands emitted by the LLM.

Replaces the hardcoded command allowlist in the correction pipeline. Each command string (e.g., "cargo add serde") is checked against this policy before execution.

Source

fn correction_prompt_fragment(&self) -> Option<&str>

Plugin-specific correction prompt fragment.

Injected into correction retry prompts to give the LLM language-specific guidance (e.g., “use cargo add instead of editing Cargo.toml directly”). Returns None if the plugin has no special guidance.

Source

fn test_file_patterns(&self) -> &[&str]

Glob patterns that identify test files for this language.

Used by plan validation to infer that test-type tasks should depend on the code tasks whose output files match these patterns’ sibling sources.

Implementors§