$ show asdf-vm/asdf
asdf is a command-line application that manages multiple runtime versions (Node.js, Python, Ruby, etc.) per project using a plugin architecture. The Go binary dispatches commands like install, set, current, exec, and reshim; it reads `.tool-versions` files searched from the current directory upward, resolves versions via environment variables, plugin callbacks, and legacy version files, then invokes plugin-provided Bash scripts for listing, downloading, and installing tools. It generates shim executables that proxy to `asdf exec` at runtime, and supports shell completions, hooks, and extension commands. Architecturally, asdf is a modular single-binary Go application with internal packages for plugins, versions, shims, resolution, configuration, Git operations, execution, and plugin index lookups. Key external runtime dependencies are bash (plugin callbacks and hooks), git (plugin repository cloning/updating), and the asdf-plugins index. The codebase reflects a rewrite from Bash to Go (v0.16+), preserving the plugin extension model while introducing typed errors, interfaces, and more maintainable package boundaries. Some legacy BATS integration tests and in-progress cleanup comments remain, but the core implementation is clean and well-organized.
The LLM identified 5 files worth highlighting for reuse:
A robust parser and writer for `.tool-versions` files that preserves comments and ordering while supporting version types (`version`, `ref`, `path`, `system`, `latest`). This is isolated, self-contained, and easily reusable in any tool that needs to read or modify per-project version pin files.
A low-level wrapper around `bash -c` that provides a `Command`/`CommandExpression` abstraction, environment map merging, and slice/map conversion utilities. It cleanly encapsulates process execution and environment manipulation, making it a reusable building block for any Go application that needs to run shell commands with controlled environments.
Defines a `Repoer` interface with a real Git-backed implementation for cloning, updating, and inspecting plugin repositories. The interface decouples callers from Git mechanics, enabling unit tests with mocks and making the pattern reusable for any project that manages external Git dependencies.
Generates shim scripts that proxy to `asdf exec`, parses shim metadata from comments, resolves executable paths across versions, and guards against reserved shim names. The encoding/parsing approach with backward-compatible metadata is a well-crafted pattern for generating and reading generated artifacts.
A standalone, regex-based Bash style linter with automatic fix mode and self-tests for its rules. It is not coupled to asdf internals and could be extracted verbatim into any project that wants reproducible shell script style checking.