Skip to content

About

Rust development bundle for the Amplifier project

Resources

Code of conduct

Security policy

Stars

4 stars

Watchers

0 watching

Forks

Repository files navigation

amplifier-bundle-rust-dev

Comprehensive Rust development tools for Amplifier.

Provides:

  • LSP integration — rust-analyzer for code intelligence
  • Code quality — cargo fmt, clippy, cargo check integration
  • Auto-checking — hooks that run on file write/edit
  • Stub detection — identifies todo!(), unimplemented!(), // TODO patterns
  • Structure advice — bounded file-length feedback after edits; native Clippy complexity advice during lint
  • Expert agents — rust-dev (quality) + code-intel (LSP navigation)

Security and workspace trust

Rust build scripts, procedural macros, dependencies, Cargo subcommands, and language-server features can execute native code. This bundle therefore uses a restricted default profile:

  • rust-analyzer build scripts, procedural macros, and check-on-save are disabled.
  • rust-analyzer custom requests are disabled.
  • Automatic edit hooks run only non-executing stub and physical file-length checks.
  • rust_check skips Cargo-based checks until the host process sets AMPLIFIER_RUST_ALLOW_WORKSPACE_EXECUTION=true.
  • Cargo commands run only from the canonical configured workspace root and reject paths outside it.
  • Compiler diagnostics are XML-escaped and labeled as untrusted data before they are added to model context.
  • Bundle-owned modules are pinned to this release. External LSP sources continue to follow upstream main; hosts should resolve, validate, and record their exact commits for each installation. Existing running environments keep their resolved code.

Enabling workspace execution is a security decision. Do it only after trusting the repository, its dependencies, build.rs files, procedural macros, Cargo, rust-analyzer, rustfmt, Clippy, and the Rust toolchain. Repository-controlled Cargo metadata cannot enable this setting.

Migration from 0.2.x behavior defaults

Existing consumers that require automatic Cargo checks must set AMPLIFIER_RUST_ALLOW_WORKSPACE_EXECUTION=true in the host process for each trusted workspace and restore the desired format, lint, or types checks. Do not put this value in repository configuration or a repository .env file. For LSP features that require generated code or procedural macros, provide a separate trusted override enabling the relevant rust-analyzer options. Untrusted workspaces remain intentionally limited.

Usage

Cargo execution, configuration, and malformed diagnostic-output failures are reported as errors through the shared checker, tool, and advisory hook. Formatting differences remain warnings; a failed check is not reported as a clean result.

includes:
  - bundle: git+https://github.com/microsoft/amplifier-bundle-rust-dev@v0.4.1

Install the matching shared library in the Amplifier host's Python environment:

python -m pip install "amplifier-bundle-rust-dev @ git+https://github.com/microsoft/amplifier-bundle-rust-dev@v0.4.1"

The tool and hook modules use that shared library and the host's existing amplifier-core as peer dependencies. Including the bundle does not replace this host installation requirement. The Git tag distributes bundle content and Python source; this release does not require publication to a Python package index.

Fast edit feedback

v0.4.1 checks the confirmed output path after successful edits, including resolved bundle mentions, while retaining support for legacy tool events.

The default hook checks the edited .rs file after successful write_file, edit_file, Write, Edit, or MultiEdit events with a file_path or path. It does not interpret apply_patch, scan the workspace, or launch Cargo. Legacy post-tool events without a success field remain supported; explicit failures produce no feedback.

FILE-LENGTH warns above 500 physical lines. This is a prompt to review a file's responsibilities, not a measure of Rust complexity or a requirement to split cohesive code. Warnings do not make the tool fail or block edits.

The combined structure/stub pass reads at most 1 MiB plus one byte once per file. Oversized, unreadable, or invalid UTF-8 files report STRUCTURE-SKIPPED; they are not reported as clean or fully checked for stubs. Default exclusions cover target, .git, vendor, generated, and _generated path components, plus leading comments marked @generated, automatically generated, or generated by. Header recognition is deliberately limited to the first ten lines before code. Excluded sources are quiet in the default hook and carry an informational STRUCTURE-EXCLUDED result when explicitly checked with structure enabled.

Tune the shared policy in Cargo.toml (workspace metadata also works):

[package.metadata.amplifier-rust-dev]
enable_structure_check = true  # false disables the size check
max_file_lines = 500
structure_max_bytes = 1048576
structure_exclude_patterns = ["vendor/**", "generated/**", "_generated/**"]
structure_exclude_generated = true
enable_clippy_advisories = true

Lists replace defaults. The existing exclude_patterns setting applies as well. For deliberate analysis of generated/vendor code, remove the corresponding exclusions and disable generated-header exclusion. An explicit tool call with checks: ["stubs"] preserves the previous full-read stub scanner and its existing exclusion rules. The default combined pass shares its bounded read with stubs. checks: ["structure"] requests only physical size feedback.

Hook configuration can select checks, override shared settings through check_options, disable injection with auto_inject: false, or disable the hook with enabled: false. Its defaults retain 256 recent file states and cap injected context at 4,096 characters after XML escaping (max_cached_files and max_context_chars, minimum 1 and 512 respectively). Repeated identical issues are quiet; changed diagnostics are delivered even when the issue count is equal. Detailed verbosity intentionally repeats issues. Only a fixed-size diagnostic fingerprint and counts are retained per file, not file contents or transcripts.

Native complexity advice

An explicitly selected, host-authorized lint check enables Clippy's cognitive_complexity and too_many_lines warnings in the existing Cargo invocation. No additional compilation, targets, or workspace expansion are added. The default edit hook does not request lint, even in an authorized workspace.

Use native clippy.toml settings to adjust the thresholds (Clippy defaults shown):

cognitive-complexity-threshold = 25
too-many-lines-threshold = 100

Clippy owns the function analysis and its suppression rules. Set enable_clippy_advisories = false to stop this bundle enabling those two lints; project-enabled lints remain in effect. The environment flags AMPLIFIER_RUST_ENABLE_STRUCTURE_CHECK and AMPLIFIER_RUST_ENABLE_CLIPPY_ADVISORIES can override project advisory settings. Explicit hook check_options or requested tool checks take precedence. None of these advisory settings grants permission to execute Cargo.

Individual Behaviors

# LSP only (no quality hooks):
includes:
  - bundle: rust-dev:behaviors/rust-lsp

# Quality tools only:
includes:
  - bundle: rust-dev:behaviors/rust-quality

License

This project is licensed under the MIT License.

Contributing

Note

This project is not currently accepting external contributions, but we're actively working toward opening this up. We value community input and look forward to collaborating in the future. For now, feel free to fork and experiment!

Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit Contributor License Agreements.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.

About

Rust development bundle for the Amplifier project

Resources

Code of conduct

Security policy

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages