npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@workedbeforepush/opencode-dotnet-format

v0.0.1

Published

OpenCode plugin that automatically formats .NET files using dotnet format

Downloads

126

Readme

@workedbeforepush/opencode-dotnet-format

OpenCode plugin that automatically formats .NET files (C#, F#, VB) using dotnet format whenever OpenCode edits them.

Features

  • Automatically runs dotnet format style --severity info on every edited .NET file
  • Walks up the directory tree to find the nearest solution or project file (.slnx, .sln, .csproj, .fsproj, .vbproj)
  • Scopes formatting to the edited file only using --include, so it runs fast
  • Supports all .NET file types: .cs, .vb, .fs, .fsi, .fsx, .fsscript
  • Gracefully disables itself when dotnet is not available on PATH

Prerequisites

  • OpenCode
  • .NET SDK installed with dotnet on your PATH
  • An .editorconfig in your project for formatting rules (recommended)

Installation

From npm (recommended)

Add the plugin to your OpenCode config file:

Global (~/.config/opencode/opencode.json):

{
  "plugin": ["@workedbeforepush/opencode-dotnet-format"]
}

Project-level (opencode.json):

{
  "plugin": ["@workedbeforepush/opencode-dotnet-format"]
}

OpenCode installs npm plugins automatically at startup.

From local file

Copy src/index.ts to one of the plugin directories:

  • Global: ~/.config/opencode/plugins/dotnet-format.ts
  • Project-level: .opencode/plugins/dotnet-format.ts

Files placed in these directories are loaded automatically at startup.

How it works

file.edited event fires
        |
        v
Is the file extension .cs / .vb / .fs / .fsi / .fsx / .fsscript?
        |
       yes
        |
        v
Walk parent directories for *.slnx / *.sln / *.csproj / *.fsproj / *.vbproj
        |
      found
        |
        v
dotnet format style <project-file> --include <relative-path> --severity info
        |
        v
Log result (success or warning)
  1. OpenCode fires a file.edited event whenever a file is written.
  2. The plugin checks if the file has a .NET extension.
  3. Starting from the file's directory, it walks up the tree looking for the nearest project or solution file in priority order: .slnx > .sln > .csproj > .fsproj > .vbproj.
  4. It runs dotnet format style scoped to that single file using --include.
  5. Formatting rules come from your .editorconfig — the plugin does not impose any rules of its own.

Configuration

This plugin has no configuration options. It uses whatever rules your .editorconfig and analyzer settings define.

To control which style rules apply and at what severity, configure them in your .editorconfig:

[*.cs]
# Enforce var usage
csharp_style_var_for_built_in_types = true:suggestion
csharp_style_var_when_type_is_apparent = true:suggestion

# Namespace declarations
csharp_style_namespace_declarations = file_scoped:warning

# Using directives
dotnet_sort_system_directives_first = true

See the .NET code style rule options documentation for all available settings.

Known issues

  • IDE0060 crash on .NET 10 SDK: The dotnet format style command may crash with System.NotSupportedException due to an analyzer bug in certain .NET 10 SDK versions. The plugin logs a warning and continues — no files are corrupted.

Troubleshooting

Enable debug logging to see plugin output:

opencode --log-level DEBUG

Look for log lines with service opencode-dotnet-format:

opencode-dotnet-format  info  dotnet-format plugin loaded
opencode-dotnet-format  info  Formatting: dotnet format style MyProject.sln --include src/MyFile.cs --severity info

If the plugin does not load:

  • Verify dotnet --version works in your terminal
  • Check that the plugin is listed in your config or placed in the plugins directory
  • Ensure you are running OpenCode v1.4.0 or later

Development

# Install dependencies
bun install

# Type check
bun run typecheck

# Build
bun run build

License

MIT