@brickhouse-tech/sync-agents 0.1.12 → 0.1.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brickhouse-tech/sync-agents",
3
- "version": "0.1.12",
3
+ "version": "0.1.14",
4
4
  "description": "Simple scripts to DRY up common agent interactions across multiple LLM providers.",
5
5
  "keywords": [
6
6
  "agents",
@@ -3,17 +3,31 @@ set -euo pipefail
3
3
 
4
4
  AGENTS_DIR=".agents"
5
5
  AGENTS_MD="AGENTS.md"
6
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6
+
7
+ # Resolve the real script directory, following symlinks.
8
+ # Needed for `npm i -g` installs where the executable is a symlink in PATH
9
+ # (e.g. /usr/local/bin/sync-agents -> .../node_modules/.../src/sh/sync-agents.sh).
10
+ # BSD readlink (macOS default) lacks -f, so we walk the chain ourselves.
11
+ resolve_script_dir() {
12
+ local path="${BASH_SOURCE[0]}"
13
+ while [[ -L "$path" ]]; do
14
+ local dir
15
+ dir="$(cd -P "$(dirname "$path")" && pwd)"
16
+ path="$(readlink "$path")"
17
+ [[ "$path" != /* ]] && path="$dir/$path"
18
+ done
19
+ cd -P "$(dirname "$path")" && pwd
20
+ }
21
+ SCRIPT_DIR="$(resolve_script_dir)"
7
22
  PACKAGE_JSON="${SCRIPT_DIR}/../../package.json"
8
23
  TEMPLATES_DIR="${SCRIPT_DIR}/../md"
9
24
 
10
- # Pull version from package.json
11
- # Try relative path first (works in repo / npm local install),
12
- # then resolve via node for global installs where the symlink target differs.
13
- if [[ -f "$PACKAGE_JSON" ]]; then
14
- VERSION="$(sed -n 's/.*"version": *"\([^"]*\)".*/\1/p' "$PACKAGE_JSON" | head -1)"
15
- elif command -v node >/dev/null 2>&1; then
16
- VERSION="$(node -p "require('@brickhouse-tech/sync-agents/package.json').version" 2>/dev/null || echo "unknown")"
25
+ # Pull version from package.json via node (we're an npm package, node is present).
26
+ # Force CommonJS so this works regardless of the caller's ESM/CJS context
27
+ # (e.g. NODE_OPTIONS=--input-type=module). Path is passed via argv to avoid
28
+ # shell-quoting issues. Requires Node 20+.
29
+ if [[ -f "$PACKAGE_JSON" ]] && command -v node >/dev/null 2>&1; then
30
+ VERSION="$(node --input-type=commonjs -e 'process.stdout.write(require(process.argv[1]).version)' "$PACKAGE_JSON" 2>/dev/null || echo unknown)"
17
31
  else
18
32
  VERSION="unknown"
19
33
  fi