polyvariant / smithy4s-bsp   0.6.0

GitHub

smithy4s-based interpreter for BSP based on jsonrpclib-smithy4s.

Scala versions: 3.x

smithy4s-bsp

Smithy definitions for the Build Server Protocol (BSP), enabling type-safe BSP client and server implementations in Scala.

Overview

This project converts the official BSP specification into Smithy format, allowing you to generate type-safe Scala code using Smithy4s. The generated code can be used with jsonrpclib's smithy4s integration to build BSP clients and servers.

Published Modules

codegen

Contains the Smithy4s-generated BSP data types and protocol definitions.

sbt:

libraryDependencies += "org.polyvariant.smithy4s-bsp" %% "codegen" % "x.y.z"

Mill:

ivy"org.polyvariant.smithy4s-bsp::codegen:x.y.z"

scala-cli:

//> using dep org.polyvariant.smithy4s-bsp::codegen:x.y.z

This artifact includes:

  • Complete BSP protocol data types generated from Smithy definitions
  • Type-safe representations of all BSP requests, responses, and notifications

bsp4s

The main entrypoint providing codecs and utilities for building BSP clients and servers.

sbt:

libraryDependencies += "org.polyvariant.smithy4s-bsp" %% "bsp4s" % "x.y.z"

Mill:

ivy"org.polyvariant.smithy4s-bsp::bsp4s:x.y.z"

scala-cli:

//> using dep org.polyvariant.smithy4s-bsp::bsp4s:x.y.z

This artifact includes:

  • BSPCodecs - Helper utilities for creating BSP clients and servers with proper encoding/decoding
  • Depends on codegen, so you get all the generated types automatically

protocol

Contains custom Smithy trait definitions used in the BSP specification (not typically needed as a direct dependency).

Usage

To build BSP clients or servers, use the bsp4s artifact. You'll also need:

  1. jsonrpclib for JSON-RPC communication
  2. A transport layer (e.g., fs2-io for stdio communication)

The library provides BSPCodecs.clientStub and BSPCodecs.serverEndpoints helpers that handle BSP-specific encoding requirements, making it easy to create type-safe BSP clients and servers.

Examples

See the example module for a complete working example of a BSP server and a BSP client.

For a real-world usage example, check out SLS (Simple Language Server), a Scala language server that uses this library to communicate with BSP build servers.

BSP Version

This project tracks the official BSP specification. The Smithy definitions are kept up-to-date with the latest BSP protocol version.

Dependencies

This project relies on:

License

Apache 2.0 - See LICENSE for details.

Contributing

Contributions are welcome! The Smithy definitions are transformed from the official BSP specification.

Maintainers