Histos
Histos is a build tool for Scala. You describe the project in a Scala program,
histos.scala. Histos compiles that program into a graph of modules, then does the work:
compile, test, run, publish. The work is a ZIO effect, so a command can be interrupted and
a resource it opened gets closed.
You can ask from a terminal, from an editor, or from an agent. They share one graph and one result. A compile runs when the code it depends on changed. A skip that hides a real change is a failure, even when the command came back quickly.
Three clients, one graph
You can ask Histos from three places, and they share one answer.
From a terminal, you type histos. That command runs on the JVM. When you have linked
histos-client, the commands that do the heavy work (compile, test, run, clean,
fmt, and complete) go through that native binary instead, and it talks to the same JVM
server.
From an editor, Metals imports the build. Metals speaks BSP, the build server protocol.
Histos answers as histos bsp.
From an agent, the client speaks MCP, the Model Context Protocol, on standard input.
histos mcp is that server. The tools are the same operations you type.
All three reach one JVM server, and that server works on one project graph. There are not three copies of the build.
If you already build with sbt, Mill, or Bazel, Why Histos is the difference in purpose: a program that returns one graph, a skip that is a claim about the bytes, and a cache you place and pin yourself.
val BspVersion: String = "2.2.0" /** Names passed to `tool`. `tools/list` must equal this set. */
val toolNames: Set[ToolName] = Names.allA typed build
The build file is histos.scala. It is an ordinary Scala program: object build extends HistosBuild,
and graph returns the project. A module, a Scala version, a dependency, and a path are
typed values, not strings you hope are well formed. If you write a version or a dependency
the compiler does not accept, histos.scala fails to compile, and Histos does not start
the build.
def graph: Either[BuildError, ProjectGraph]def from(raw: String): Either[ScalaVersionError, ScalaVersion] =
if raw.isEmpty then Left(ScalaVersionError.Empty)
else if Full.matches(raw) then Right(trusted(raw))
else Left(ScalaVersionError.NotFull(raw))A skip you can trust
Compile and package are expensive, so Histos stores their outputs by the bytes that went in. A later compile is skipped only when those bytes say nothing relevant changed.
Two checks matter. The API digest is the public signature of a module: the names and types other modules compile against. A comment or a change inside a method body does not move that signature, so a downstream module is not rebuilt. The product digest is the class files themselves, with line-number tables and the TASTY attribute removed, so a formatting change does not look like a new binary. A skip that hides a real change is a failure, even when the command returned quickly.
def of(analysis: sbt.internal.inc.Analysis): Sha256 =
digest(
analysis.apis.allInternalClasses.toList.sorted.map: name =>
s"$name ${analysis.apis.internalAPI(name).apiHash()}"
)/** Line-number tables and the `TASTY` attribute are not part of a product. `TASTY` is a hash of positions and comments.
* A jar entry's timestamp is not part of a product either. The only path removed is `checkout`, and only where that
* absolute root sits on a path boundary. Every other string stays as written.
*/
object ProductDigest:
val fileName: String = "product.sha256"
def normalize(bytes: Array[Byte], checkout: Path): Either[ClassBytesError, Array[Byte]] =…
Install
You install Histos once, with the script published on the release. It becomes
~/.histos/bin/histos and does not edit your shell startup files. You add that directory
to PATH yourself.
curl -fsSL https://github.com/early-effect/histos/releases/download/dist/shim | sh
export PATH="$HOME/.histos/bin:$PATH"
The Install page walks through what that script does, how a project pins a version, and when the optional native client is worth linking.