Base's reusable Bash libraries are being extracted into the standalone
codeforester/base-bash-libs
repository. That repository lets scripts use Base's Bash logging, command
execution, filesystem, and Git helper conventions without adopting the full
Base workspace control plane.
This page documents the Base-side consumption and migration contract. Library
APIs and standalone examples live in the base-bash-libs repository.
The standalone reusable library package owns:
lib/bash/stdlib/bash/filelib/bash/git- shared BATS helpers needed by those library test suites
Base still owns Base-specific runtime files, including:
lib/bash/runtime- Base runtime bootstrap through
base_init.sh - Base command dispatch and project activation
During the migration window, Base also keeps bundled copies of the reusable library directories. Those copies are a compatibility fallback, not the long-term source of truth.
Users who want only the Bash libraries can install them from the existing Homebrew tap:
brew trust codeforester/base
brew install codeforester/base/base-bash-libsThe trust step is required on Homebrew versions that block formulae from
non-official taps until the tap is trusted. It is safe to run again on machines
that already trust codeforester/base.
Standalone scripts can then source the stdlib from the installed prefix:
base_bash_libs_prefix="$(brew --prefix codeforester/base/base-bash-libs)"
source "$base_bash_libs_prefix/libexec/lib/bash/std/lib_std.sh"Companion libraries should be loaded through the stdlib's absolute import helper:
import "$base_bash_libs_prefix/libexec/lib/bash/file/lib_file.sh"
import "$base_bash_libs_prefix/libexec/lib/bash/git/lib_git.sh"For source checkout development, clone the repository next to Base or source it directly from the checkout path:
git clone https://github.com/codeforester/base-bash-libs.git ~/work/base-bash-libs
source "$HOME/work/base-bash-libs/lib/bash/std/lib_std.sh"When basectl loads base_init.sh, Base resolves BASE_BASH_LIBS_DIR before
it sources the Bash stdlib. Base also exports BASE_BASH_LIBS_SOURCE so
diagnostics can report which path won: explicit, sibling, homebrew, or
bundled. The resolution order is:
- An explicit
BASE_BASH_LIBS_DIRprovided before runtime bootstrap. - A sibling source checkout at
$BASE_HOME/../base-bash-libs/lib/bash. - A Homebrew package at
<homebrew-prefix>/opt/base-bash-libs/libexec/lib/bashwhenBASE_HOMElooks like a Homebrew Base install. - Base's bundled fallback at
$BASE_HOME/lib/bash.
An explicit BASE_BASH_LIBS_DIR must contain std/lib_std.sh; otherwise Base
fails early with a direct error. The variable is intended for tests, source
checkout development, and controlled migration checks. Users should not set it
in ~/.baserc, shell dotfiles, or project activation scripts.
Base command implementations should not source these files by absolute path.
They should rely on basectl to establish the runtime and then import reusable
libraries by convention:
import_base_lib file/lib_file.sh
import_base_lib git/lib_git.shimport_base_lib checks the resolved reusable library root first. If a
requested companion library is not present there and the resolved reusable root
is not the bundled Base root, it falls back to $BASE_BASH_LIB_DIR. That keeps
Base working while the external package and Base-owned runtime files are still
being separated.
The current Base contract is external-first, bundled-fallback:
- Base can consume
base-bash-libsfrom a sibling checkout. - Base can consume
base-bash-libsfrom Homebrew when the formula is installed. - Base still works without the external package because the bundled reusable
libraries remain in
codeforester/base. basectl checkandbasectl doctoremitBASE-D007as a warning when Base is still using the bundled fallback, and as ok when the external source is explicit, sibling, or Homebrew.
The bundled reusable libraries should not be removed from Base until the external path is normal, validated, and diagnosable for both Homebrew users and source checkout contributors. The practical removal gate is:
base-bash-libshas a released version and installable Homebrew formula.- Homebrew Base declares
base-bash-libsas a dependency, or an equivalent install path makes the external package present by default. - Source checkout setup documents or installs the sibling
base-bash-libscheckout clearly enough that rawgit clonedevelopment is not fragile. - Base setup, check, or doctor paths report missing external Bash libraries
clearly where that state can affect users.
BASE-D007now covers the check and doctor side of this gate. - CI validates Base without relying on the bundled reusable directories. The
base_initBATS suite now includes a temporary Base home with bundled reusablestd,file, andgitdirectories removed and externalbase-bash-libsprovided through the sibling checkout path. - A Base release cycle has passed with the external package as the normal path and without needing the fallback for ordinary installs.
Only after those gates are satisfied should Base remove the bundled reusable directories. If Base intentionally keeps the fallback long term, that decision should be recorded explicitly and the extraction tracker should close only after that policy is clear.
The Python base_cli extraction is a separate effort and is not part of this
Bash library migration.