Skip to content

feat: environment file sync, multi-provider install, and CI#94

Merged
fentas merged 20 commits intomainfrom
feat/environments
Feb 12, 2026
Merged

feat: environment file sync, multi-provider install, and CI#94
fentas merged 20 commits intomainfrom
feat/environments

Conversation

@fentas
Copy link
Owner

@fentas fentas commented Feb 12, 2026

This pull request introduces significant improvements to the documentation, developer workflow, and usability of the b project, focusing on enhanced environment file management, streamlined CI configuration, and improved user guidance. The most important changes are summarized below.

Documentation and User Guidance Improvements:

  • Expanded README.md to clarify that b manages both binaries and environment files, with new sections describing features, usage, and configuration for both (binaries and envs). Added badges for coverage and Go reference. [1] [2] [3] [4]
  • Updated the Docusaurus documentation to reflect new capabilities: environment file syncing, cache management, and verification commands. Added new quick reference commands and improved descriptions for install, list, and search subcommands. [1] [2] [3] [4] [5] [6] [7] [8] [9]
  • Added a new b cache documentation page, detailing cache management subcommands and usage examples.

Developer Workflow and CI Enhancements:

  • Updated the GitHub Actions workflow in .github/workflows/test.yml to use the latest versions of actions, improve Go version management, and simplify caching. Now supports the feat/environments branch and uses go-version-file: go.mod for consistency. [1] [2] [3] [4] [5]
  • Added a comprehensive Makefile with targets for build, test, coverage (including JSON report), lint, CI, and clean, streamlining local development and CI integration.

CLI and Usability Improvements:

  • Improved error reporting in cmd/b/main.go by printing errors to stderr before exiting, making CLI failures more visible and user-friendly. [1] [2]

These changes collectively enhance the project's maintainability, user experience, and readiness for broader usage.

Summary

  • Phase 1: Multi-provider binary install — GitHub, GitLab, Gitea, GoInstall, Docker providers with auto-detection
  • Phase 2: Env file sync from git repos — SCP-style syntax, glob matching, bare-clone git cache, lockfile tracking
  • Phase 3: Merge strategies for env updates — replace, client, and three-way merge via git merge-file
  • Phase 4: Cache clean, env conflict warnings, version --remote, upstream config discovery
  • Docs: Updated Docusaurus docs, README badges (coverage, Go reference), CI workflow
  • Tests: Coverage across key packages (lock 88%, state 80%, envmatch 100%, gitcache 47%, provider 40%, cli 27%)
  • CI: Makefile with build, test, coverage (JSON + .out), lint, and ci targets

Closes #76
Closes #67

Test plan

  • make build compiles successfully
  • make test — all tests pass
  • make coverage — generates test/coverage/coverage.out and .json
  • make lint — golangci-lint passes
  • make ci — full CI pipeline passes
  • Manual: b install jq kubectl works with new provider system
  • Manual: b install github.com/org/repo:/path/** env sync works

🤖 Generated with Claude Code

fentas and others added 11 commits February 12, 2026 14:20
Add provider abstraction for fetching binaries from any release source:
- GitHub, GitLab, Gitea/Codeberg releases with OS/arch auto-detection
- Go install (compile from source) and Docker image extraction
- Heuristic asset matching: OS/arch scoring, archive extraction, binary detection

Wire providers into existing CLI:
- `b install github.com/org/repo@version` works for any release
- `b install --add` writes provider refs to b.yaml binaries section
- Presets (pkg/binaries/*.go) remain as overrides for known tools

Add b.lock and b verify:
- JSON lockfile pins binary versions + SHA256 checksums
- `b verify` checks all managed artifacts against lock
- Lock updated automatically after install

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds environment file management: sync files from upstream git repos
using SCP-style syntax (b install ref:/glob dest), config-based sync
via b.yaml envs section, update/verify/list/version support for envs.

Uses git CLI cache layer (shallow bare clones), glob matching on
file trees, SHA256 checksums in b.lock, and path traversal protection.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add --strategy flag to b update with three conflict strategies:
- replace (default): overwrite with upstream, warn about local changes
- client: keep local files when modified, skip upstream changes
- merge: three-way merge via git merge-file with conflict markers

Interactive per-file prompt on TTY when local changes detected with
default (replace) strategy: [r]eplace [k]eep [m]erge [d]iff.
Non-TTY (CI) defaults to replace with warning.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…discovery (Phase 4)

Add b cache clean/path subcommands, env dest conflict detection,
remote commit checking for envs in b version, upstream b.yaml discovery
for bare provider refs, and enhanced b search with provider ref hints.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Update README with env sync, provider refs, merge strategies, cache,
and verify commands. Add env hints to b init output. Include b.lock
in .gitignore template. Update test workflow to use go-version-file
and modern action versions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add comprehensive unit tests for:
- pkg/state: config load/save, YAML marshal/unmarshal, BinaryList, EnvList
- pkg/cli: shared options, verify, cache helpers, init, list, install
  (addToConfig, addEnvToConfig, updateLock), update validate, version
- pkg/env: writeFile, findLockFile, syncMessage variants, strategies
- pkg/gitcache: DefaultCacheRoot, edge cases for RefBase/RefLabel/RefVersion
- pkg/provider: all provider Match/Name, detect helpers (isArchive,
  containsWord, shouldIgnore, MatchAsset), GitHub/GitLab/Gitea/Docker edges

Coverage changes for key packages:
  cli:      10.9% → 27.5%
  provider: 28.4% → 40.7%
  state:    51.9% → 80.7%
  gitcache: 45.8% → 47.5%

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Coverage outputs go to test/coverage/ (both .out and .json).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
v1.57.1 is incompatible with Go 1.26. Also fix gofmt check
to skip vendor/ directory.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR expands b from a binary manager into a combined binary installer + env file sync tool, introducing provider-based installs, git-backed env syncing with merge strategies, lockfile tracking, and CI/docs updates.

Changes:

  • Add multi-provider binary installs (GitHub/GitLab/Gitea/Go install/Docker) with ref auto-detection and asset matching.
  • Add env file syncing from git repos (glob matching, git cache, strategies: replace/client/merge) tracked in b.lock.
  • Add CLI surface for env workflows (b update envs, b verify, b cache) plus docs and CI updates.

Reviewed changes

Copilot reviewed 56 out of 57 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
pkg/state/types.go Adds envs to config state and provider-ref detection for binaries.
pkg/state/types_test.go Tests YAML marshal/unmarshal and config load/save behavior including envs/files map forms.
pkg/provider/provider.go Introduces provider interface, registry, ref parsing, and binary-name derivation.
pkg/provider/provider_test.go Tests provider ref parsing and name derivation.
pkg/provider/detect.go Adds asset matching heuristics (OS/arch aliases, archive detection, ignore rules).
pkg/provider/detect_test.go Adds tests for asset selection and helper functions.
pkg/provider/docker.go Adds Docker/OCI provider install via container runtime extraction.
pkg/provider/gitlab.go Adds GitLab provider via GitLab Releases API.
pkg/provider/gitea.go Adds Gitea/Forgejo provider via instance API.
pkg/provider/github.go Adds GitHub provider (latest via redirects, release assets via API).
pkg/provider/github_test.go Tests GitHub ref matching and owner/repo parsing.
pkg/provider/goinstall.go Adds go:// provider using go install.
pkg/provider/providers_test.go Broad provider matching/detection tests and asset helper edge cases.
pkg/lock/lock.go Introduces b.lock JSON schema with binaries/envs + SHA256 helpers.
pkg/lock/lock_test.go Tests lockfile read/write and upsert/find helpers.
pkg/gitcache/gitcache.go Implements bare-clone cache, ref resolution, merge/diff helpers, and ref parsing helpers.
pkg/gitcache/gitcache_test.go Tests cache helpers plus merge/diff behavior.
pkg/gitcache/gitcache_extra_test.go Adds additional edge-case tests for gitcache helpers.
pkg/envmatch/match.go Implements glob matching, ignore logic, and destination computation for env sync.
pkg/envmatch/match_test.go Tests glob semantics, ignore behavior, and dest computation.
pkg/env/env.go Implements env sync pipeline (resolve commit, fetch cache, match globs, apply strategies, write lock entries).
pkg/env/env_test.go Adds unit tests for env syncing helpers/strategy behavior.
pkg/env/env_extra_test.go Adds extra coverage for env helper behaviors.
pkg/cli/shared.go Adds provider-ref binary resolution and lock directory handling.
pkg/cli/install.go Extends install to support provider refs and SCP-style env sync, plus lock updates.
pkg/cli/install_test.go Tests SCP arg parsing and commit-shortening helper.
pkg/cli/update.go Extends update to handle env syncing, strategies, conflict prompts, and conflict warnings.
pkg/cli/update_test.go Tests strategy validation and env conflict guard behavior.
pkg/cli/list.go Extends list output to include env entries and lock status.
pkg/cli/search.go Adds provider-ref install hints and expanded help text.
pkg/cli/version.go Adds env version display and remote commit checks.
pkg/cli/verify.go Adds b verify to validate installed binaries/env files against b.lock.
pkg/cli/cache.go Adds b cache command to show/clean git cache and report size.
pkg/cli/cache_test.go Tests cache size formatting and directory sizing.
pkg/cli/root.go Registers new verify and cache commands.
pkg/cli/init.go Updates init messaging and ensures b.lock is not ignored by generated .gitignore.
pkg/binary/types.go Adds provider metadata fields for auto-detected binaries.
pkg/binary/download.go Routes downloads through provider system and adds archive extraction heuristics.
cmd/b/main.go Prints errors to stderr on CLI execution failure.
go.mod Updates module Go version and adds direct dependency adjustments.
README.md Updates project description, features, and usage examples (providers/env sync/lock/verify/cache).
Makefile Adds build/test/coverage/lint/ci targets and coverage artifact generation.
.gitignore Ignores generated coverage artifacts.
.github/workflows/test.yml Updates Go setup, Codecov action, branches, and uses go.mod for Go version.
docs/homepage.mdx Updates messaging/examples to include env sync and lockfile.
docs/troubleshooting.mdx Adds git-cache, env sync, merge conflict, and verify troubleshooting guidance.
docs/glossary.mdx Adds terminology for env sync, git cache, lockfile, and strategies.
docs/getting-started.mdx Adds env sync, verify, and update-strategy docs plus config examples.
docs/b/overview.mdx Updates command reference overview to include env-related commands.
docs/b/subcommands/install.mdx Documents provider refs and SCP-style env sync installs.
docs/b/subcommands/update.mdx Documents env updates and merge strategy flag.
docs/b/subcommands/list.mdx Documents env listing behavior.
docs/b/subcommands/search.mdx Documents provider-ref hints.
docs/b/subcommands/version.mdx Documents env status and remote checks.
docs/b/subcommands/verify.mdx Adds docs for new verify command.
docs/b/subcommands/cache.mdx Adds docs for new cache command.

fentas and others added 2 commits February 12, 2026 19:55
Provider refs (github.com/..., go://...) defined in b.yaml were silently
skipped because GetBinary found the config entry before reaching the
provider detection path. Now falls through to provider detection when
resolveBinary fails for non-preset names.

Also adds golangci-lint to b.yaml, .golangci.yml config, and updates
Makefile to build into .bin/.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Make TestMatchAsset/TestMatchAssetNoMatch platform-aware (runtime.GOOS/GOARCH)
- Add os.MkdirAll in EnsureClone to create cache root if missing
- Distinguish exit code 1 (conflicts) from 128+ (signal) in Merge3Way
- Propagate real errors from DiffNoIndex instead of swallowing them
- Replace weak strings.Contains("..") path traversal check with filepath.Rel
- Fix showDiff to use DefaultCacheRoot() and ensure clone/fetch before ShowFile
- Fix misleading "ordered access" comment in EnvList.UnmarshalYAML
- Check file.Close() errors in download.go (downloadAsset, extractFromZipAuto, downloadPreset)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- golangci-lint-action@v6 does not support golangci-lint v2, use @v9 (latest)
- Make TestMatchAsset_PrefersTarGz and TestMatchAsset_PrefersArchive
  platform-aware using runtime.GOOS/GOARCH

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 59 out of 60 changed files in this pull request and generated 8 comments.

fentas and others added 3 commits February 12, 2026 20:23
The callback received the raw relative m.DestPath, which could break
interactive conflict handling (diff/merge) when CWD != project root.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace hardcoded ">=5.0.0" in all WriteLock calls with the actual CLI
version from main.go, threaded through SharedOptions.bVersion.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 59 out of 60 changed files in this pull request and generated 5 comments.

fentas and others added 2 commits February 12, 2026 20:42
Go 1.26 removed the windows/arm (32-bit) port. windows/arm64 remains
supported.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
containsWord now loops through all occurrences of the search term
instead of only checking the first match, which could be embedded
in an alphanumeric token. Also replaced os.Exit(1) in verify with
a returned error so deferred cleanup and cobra hooks run properly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@fentas fentas requested a review from Copilot February 12, 2026 19:56
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 60 out of 61 changed files in this pull request and generated no new comments.

@fentas fentas merged commit 41c6c2d into main Feb 12, 2026
19 checks passed
@fentas fentas deleted the feat/environments branch February 12, 2026 20:00
fentas pushed a commit that referenced this pull request Feb 12, 2026
🤖 I have created a release *beep* *boop*
---


## [4.6.0](v4.5.0...v4.6.0)
(2026-02-12)


### Features

* environment file sync, multi-provider install, and CI
([#94](#94))
([41c6c2d](41c6c2d))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

binary sha custom binaries

2 participants