From 089ae83942f280bd2247339dae558285ff3434e7 Mon Sep 17 00:00:00 2001 From: nmccready Date: Mon, 18 May 2026 23:59:14 -0400 Subject: [PATCH] feat(remove-bash): drop bash fallback, fail loudly on unsupported triples (#19) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Delete src/sh/sync-agents.sh — bash implementation removed - bin/sync-agents.js: remove fallback branch; unsupported triples now exit 1 with a clear message pointing to go install / brew / GitHub Releases - package.json: drop lint (shellcheck), test:sh, concurrently devDep; test script delegates to make test; files array no longer includes src/**/* - Makefile test target: remove SYNC_AGENTS_BIN=bin/sync-agents prefix - test/sync-agents.bats: resolve Go binary by default (bin/sync-agents) instead of the bash script; SYNC_AGENTS_BIN override kept for CI flexibility Closes #19 Co-Authored-By: Claude Sonnet 4.6 --- Makefile | 2 +- bin/sync-agents.js | 30 +- package.json | 8 +- src/sh/sync-agents.sh | 1596 ----------------------------------------- test/sync-agents.bats | 9 +- 5 files changed, 24 insertions(+), 1621 deletions(-) delete mode 100755 src/sh/sync-agents.sh diff --git a/Makefile b/Makefile index adef377..762963e 100644 --- a/Makefile +++ b/Makefile @@ -42,7 +42,7 @@ build-all: @for p in $(PLATFORMS); do $(MAKE) build-platform PLATFORM=$$p; done test: build - SYNC_AGENTS_BIN=bin/sync-agents npx bats test/sync-agents.bats + npx bats test/sync-agents.bats test-go: test diff --git a/bin/sync-agents.js b/bin/sync-agents.js index 7f4812f..6cb90aa 100755 --- a/bin/sync-agents.js +++ b/bin/sync-agents.js @@ -1,8 +1,7 @@ #!/usr/bin/env node -// Launcher: prefer the Go binary shipped via the matching platform package -// (@brickhouse-tech/sync-agents--); fall back to the bash script -// at src/sh/sync-agents.sh so the package never bricks on an unsupported -// triple. +// Launcher: resolve the Go binary shipped via the matching platform package +// (@brickhouse-tech/sync-agents--). Exits with a clear error on +// unsupported triples rather than silently falling back to a bash script. const { spawnSync } = require("node:child_process"); const path = require("node:path"); @@ -17,22 +16,25 @@ function resolveGoBinary() { const candidate = path.join(path.dirname(pkgJson), "bin", exe); if (fs.existsSync(candidate)) return candidate; } catch { - // platform package not installed (npm skipped it via os/cpu mismatch - // or it failed as an optionalDependency); fall through to bash. + // platform package not installed or not available for this triple. } return null; } -function fallbackShellScript() { - return path.join(__dirname, "..", "src", "sh", "sync-agents.sh"); -} +const target = resolveGoBinary(); -const target = resolveGoBinary() ?? fallbackShellScript(); -const isShell = target.endsWith(".sh"); +if (!target) { + console.error( + `sync-agents: no pre-built binary for ${process.platform}/${process.arch}.\n` + + `Install via one of the supported channels:\n` + + ` go install github.com/brickhouse-tech/sync-agents@latest\n` + + ` brew install brickhouse-tech/tap/sync-agents\n` + + ` https://github.com/brickhouse-tech/sync-agents/releases` + ); + process.exit(1); +} -const result = spawnSync(isShell ? "bash" : target, isShell ? [target, ...process.argv.slice(2)] : process.argv.slice(2), { - stdio: "inherit", -}); +const result = spawnSync(target, process.argv.slice(2), { stdio: "inherit" }); if (result.error) { console.error(`sync-agents: failed to exec ${target}: ${result.error.message}`); diff --git a/package.json b/package.json index 831a7f1..b046cf4 100644 --- a/package.json +++ b/package.json @@ -23,8 +23,7 @@ "sync-agents": "bin/sync-agents.js" }, "files": [ - "bin/sync-agents.js", - "src/**/*" + "bin/sync-agents.js" ], "optionalDependencies": { "@brickhouse-tech/sync-agents-darwin-arm64": "0.2.5", @@ -38,9 +37,7 @@ "picomatch": ">=4.0.4" }, "scripts": { - "lint": "shellcheck src/sh/*.sh", - "test": "npx concurrently --names \"sh,go\" -c \"cyan,magenta\" \"npm run test:sh\" \"npm run test:go\"", - "test:sh": "npx bats test/", + "test": "make test", "test:go": "make test", "prepare": "make install", "prepack": "node scripts/sync-optional-deps.js", @@ -50,7 +47,6 @@ "@commitlint/cli": "^21", "@commitlint/config-conventional": "^21", "commitlint": "21", - "concurrently": "^9.2.1", "sort-package-json": ">=3" } } diff --git a/src/sh/sync-agents.sh b/src/sh/sync-agents.sh deleted file mode 100755 index fac93f0..0000000 --- a/src/sh/sync-agents.sh +++ /dev/null @@ -1,1596 +0,0 @@ -#!/usr/bin/env bash -# ---------------------------------------------------------------------------- -# DEPRECATED — bash implementation of sync-agents. -# -# The Go binary shipped via per-platform npm packages is the supported -# implementation. This shell script remains only as: -# - the fallback path in bin/sync-agents.js for unsupported triples -# - the standalone curl install in README (also deprecated) -# Scheduled for removal in a future major after platform-package install -# data shows the fallback is unused. Bug fixes go into go/, not here. -# ---------------------------------------------------------------------------- -set -euo pipefail - -AGENTS_DIR=".agents" -AGENTS_MD="AGENTS.md" - -# Resolve the real script directory, following symlinks. -# Needed for `npm i -g` installs where the executable is a symlink in PATH -# (e.g. /usr/local/bin/sync-agents -> .../node_modules/.../src/sh/sync-agents.sh). -# BSD readlink (macOS default) lacks -f, so we walk the chain ourselves. -resolve_script_dir() { - local path="${BASH_SOURCE[0]}" - while [[ -L "$path" ]]; do - local dir - dir="$(cd -P "$(dirname "$path")" && pwd)" - path="$(readlink "$path")" - [[ "$path" != /* ]] && path="$dir/$path" - done - cd -P "$(dirname "$path")" && pwd -} -SCRIPT_DIR="$(resolve_script_dir)" -PACKAGE_JSON="${SCRIPT_DIR}/../../package.json" -TEMPLATES_DIR="${SCRIPT_DIR}/../md" - -# Pull version from package.json via node (we're an npm package, node is present). -# Force CommonJS so this works regardless of the caller's ESM/CJS context -# (e.g. NODE_OPTIONS=--input-type=module). Path is passed via argv to avoid -# shell-quoting issues. Requires Node 20+. -if [[ -f "$PACKAGE_JSON" ]] && command -v node >/dev/null 2>&1; then - VERSION="$(node --input-type=commonjs -e 'process.stdout.write(require(process.argv[1]).version)' "$PACKAGE_JSON" 2>/dev/null || echo unknown)" -else - VERSION="unknown" -fi - -# Agent target directories -TARGETS=("claude" "windsurf" "cursor" "copilot") - -# Colors (disabled if not a terminal) -if [[ -t 1 ]]; then - BOLD='\033[1m' - GREEN='\033[0;32m' - YELLOW='\033[0;33m' - RED='\033[0;31m' - CYAN='\033[0;36m' - RESET='\033[0m' -else - BOLD='' GREEN='' YELLOW='' RED='' CYAN='' RESET='' -fi - -info() { echo -e "${GREEN}[info]${RESET} $*"; } -warn() { echo -e "${YELLOW}[warn]${RESET} $*"; } -error() { echo -e "${RED}[error]${RESET} $*" >&2; } - -# Resolve target directory path (copilot uses .github/copilot/ instead of .copilot/) -resolve_target_dir() { - local target="$1" - local root="$2" - if [[ "$target" == "copilot" ]]; then - echo "$root/.github/copilot" - else - echo "$root/.$target" - fi -} - -# Resolve relative path from target dir back to .agents/ (accounts for depth) -resolve_agents_rel() { - local target="$1" - if [[ "$target" == "copilot" ]]; then - echo "../../$AGENTS_DIR" - else - echo "../$AGENTS_DIR" - fi -} - -usage() { - cat < [options] - -${BOLD}COMMANDS${RESET} - init Initialize .agents/ directory structure and AGENTS.md - sync Sync .agents/ to agent directories via symlinks - status Show current sync status - add Add a new rule, skill, or workflow from template - index Regenerate AGENTS.md index from .agents/ contents - clean Remove all synced symlinks (does not remove .agents/) - watch Watch .agents/ for changes and auto-regenerate index - import Import a rule/skill/workflow from a URL - hook Install a pre-commit git hook for auto-sync - fix [type] Migrate legacy dirs + repair broken symlinks - type: skills, rules, workflows, or all - --no-clobber: skip items that already exist in .agents/ - inherit