feat: environment file sync, multi-provider install, and CI#94
Merged
Conversation
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>
Contributor
There was a problem hiding this comment.
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 updateenvs,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. |
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>
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>
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
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces significant improvements to the documentation, developer workflow, and usability of the
bproject, 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:
README.mdto clarify thatbmanages both binaries and environment files, with new sections describing features, usage, and configuration for both (binariesandenvs). Added badges for coverage and Go reference. [1] [2] [3] [4]install,list, andsearchsubcommands. [1] [2] [3] [4] [5] [6] [7] [8] [9]b cachedocumentation page, detailing cache management subcommands and usage examples.Developer Workflow and CI Enhancements:
.github/workflows/test.ymlto use the latest versions of actions, improve Go version management, and simplify caching. Now supports thefeat/environmentsbranch and usesgo-version-file: go.modfor consistency. [1] [2] [3] [4] [5]Makefilewith targets for build, test, coverage (including JSON report), lint, CI, and clean, streamlining local development and CI integration.CLI and Usability Improvements:
cmd/b/main.goby 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
git merge-fileversion --remote, upstream config discoveryCloses #76
Closes #67
Test plan
make buildcompiles successfullymake test— all tests passmake coverage— generatestest/coverage/coverage.outand.jsonmake lint— golangci-lint passesmake ci— full CI pipeline passesb install jq kubectlworks with new provider systemb install github.com/org/repo:/path/**env sync works🤖 Generated with Claude Code