@ericsanchezok/meta-synergy 1.1.26 → 1.2.17

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/README.md ADDED
@@ -0,0 +1,47 @@
1
+ # MetaSynergy
2
+
3
+ > ⚠️ **Experimental** — This package is under active development. The API, behavior, and release artifacts may change without notice.
4
+
5
+ MetaSynergy is a lightweight companion CLI that connects to a remote Synergy host — useful when you want to use Synergy as a backend service without running the full local runtime.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ curl -fsSL https://raw.githubusercontent.com/SII-Holos/synergy/main/packages/meta-synergy/install | bash
11
+ ```
12
+
13
+ Install a specific version:
14
+
15
+ ```bash
16
+ curl -fsSL https://raw.githubusercontent.com/SII-Holos/synergy/main/packages/meta-synergy/install | bash -s -- --version 1.1.26
17
+ ```
18
+
19
+ ### Options
20
+
21
+ | Flag | Description |
22
+ | ------------------ | ------------------------------- |
23
+ | `--version <ver>` | Install a specific version |
24
+ | `--binary <path>` | Install from a local binary |
25
+ | `--no-modify-path` | Don't modify shell config files |
26
+
27
+ ### What the installer does
28
+
29
+ 1. Downloads the appropriate binary for your platform (darwin/linux/windows + x64/arm64)
30
+ 2. Places it under `~/.meta-synergy/bin/`
31
+ 3. Adds that directory to your `PATH` (unless `--no-modify-path` is passed)
32
+
33
+ ## Usage
34
+
35
+ ```bash
36
+ meta-synergy
37
+ ```
38
+
39
+ For usage instructions, run:
40
+
41
+ ```bash
42
+ meta-synergy --help
43
+ ```
44
+
45
+ ## Source
46
+
47
+ Built from this monorepo at `packages/meta-synergy/`. Issues and contributions are welcome at [github.com/SII-Holos/synergy](https://github.com/SII-Holos/synergy).
package/install ADDED
@@ -0,0 +1,444 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ APP=meta-synergy
4
+
5
+ MUTED='\033[0;2m'
6
+ RED='\033[0;31m'
7
+ ORANGE='\033[38;5;214m'
8
+ NC='\033[0m' # No Color
9
+
10
+ usage() {
11
+ cat <<EOF
12
+ MetaSynergy Installer
13
+
14
+ Usage: install.sh [options]
15
+
16
+ Options:
17
+ -h, --help Display this help message
18
+ -v, --version <version> Install a specific version (e.g., 1.1.26)
19
+ -b, --binary <path> Install from a local binary instead of downloading
20
+ --no-modify-path Don't modify shell config files (.zshrc, .bashrc, etc.)
21
+
22
+ Examples:
23
+ curl -fsSL https://raw.githubusercontent.com/SII-Holos/synergy/main/packages/meta-synergy/install | bash
24
+ curl -fsSL https://raw.githubusercontent.com/SII-Holos/synergy/main/packages/meta-synergy/install | bash -s -- --version 1.1.26
25
+ ./install --binary /path/to/meta-synergy
26
+ EOF
27
+ }
28
+
29
+ requested_version=${VERSION:-}
30
+ no_modify_path=false
31
+ binary_path=""
32
+
33
+ while [[ $# -gt 0 ]]; do
34
+ case "$1" in
35
+ -h|--help)
36
+ usage
37
+ exit 0
38
+ ;;
39
+ -v|--version)
40
+ if [[ -n "${2:-}" ]]; then
41
+ requested_version="$2"
42
+ shift 2
43
+ else
44
+ echo -e "${RED}Error: --version requires a version argument${NC}"
45
+ exit 1
46
+ fi
47
+ ;;
48
+ -b|--binary)
49
+ if [[ -n "${2:-}" ]]; then
50
+ binary_path="$2"
51
+ shift 2
52
+ else
53
+ echo -e "${RED}Error: --binary requires a path argument${NC}"
54
+ exit 1
55
+ fi
56
+ ;;
57
+ --no-modify-path)
58
+ no_modify_path=true
59
+ shift
60
+ ;;
61
+ *)
62
+ echo -e "${ORANGE}Warning: Unknown option '$1'${NC}" >&2
63
+ shift
64
+ ;;
65
+ esac
66
+ done
67
+
68
+ INSTALL_DIR=$HOME/.meta-synergy/bin
69
+ mkdir -p "$INSTALL_DIR"
70
+
71
+ # If --binary is provided, skip all download/detection logic
72
+ if [ -n "$binary_path" ]; then
73
+ if [ ! -f "$binary_path" ]; then
74
+ echo -e "${RED}Error: Binary not found at ${binary_path}${NC}"
75
+ exit 1
76
+ fi
77
+ specific_version="local"
78
+ else
79
+ raw_os=$(uname -s)
80
+ os=$(echo "$raw_os" | tr '[:upper:]' '[:lower:]')
81
+ case "$raw_os" in
82
+ Darwin*) os="darwin" ;;
83
+ Linux*) os="linux" ;;
84
+ MINGW*|MSYS*|CYGWIN*) os="windows" ;;
85
+ esac
86
+
87
+ arch=$(uname -m)
88
+ if [[ "$arch" == "aarch64" ]]; then
89
+ arch="arm64"
90
+ fi
91
+ if [[ "$arch" == "x86_64" ]]; then
92
+ arch="x64"
93
+ fi
94
+
95
+ if [ "$os" = "darwin" ] && [ "$arch" = "x64" ]; then
96
+ rosetta_flag=$(sysctl -n sysctl.proc_translated 2>/dev/null || echo 0)
97
+ if [ "$rosetta_flag" = "1" ]; then
98
+ arch="arm64"
99
+ fi
100
+ fi
101
+
102
+ combo="$os-$arch"
103
+ case "$combo" in
104
+ linux-x64|linux-arm64|darwin-x64|darwin-arm64|windows-x64|windows-arm64)
105
+ ;;
106
+ *)
107
+ echo -e "${RED}Unsupported OS/Arch: $os/$arch${NC}"
108
+ exit 1
109
+ ;;
110
+ esac
111
+
112
+ archive_ext=".zip"
113
+ if [ "$os" = "linux" ]; then
114
+ archive_ext=".tar.gz"
115
+ fi
116
+
117
+ is_musl=false
118
+ if [ "$os" = "linux" ]; then
119
+ if [ -f /etc/alpine-release ]; then
120
+ is_musl=true
121
+ fi
122
+
123
+ if command -v ldd >/dev/null 2>&1; then
124
+ if ldd --version 2>&1 | grep -qi musl; then
125
+ is_musl=true
126
+ fi
127
+ fi
128
+ fi
129
+
130
+ needs_baseline=false
131
+ if [ "$arch" = "x64" ]; then
132
+ if [ "$os" = "linux" ]; then
133
+ if ! grep -qi avx2 /proc/cpuinfo 2>/dev/null; then
134
+ needs_baseline=true
135
+ fi
136
+ fi
137
+
138
+ if [ "$os" = "darwin" ]; then
139
+ avx2=$(sysctl -n hw.optional.avx2_0 2>/dev/null || echo 0)
140
+ if [ "$avx2" != "1" ]; then
141
+ needs_baseline=true
142
+ fi
143
+ fi
144
+ fi
145
+
146
+ target="$os-$arch"
147
+ if [ "$needs_baseline" = "true" ]; then
148
+ target="$target-baseline"
149
+ fi
150
+ if [ "$is_musl" = "true" ]; then
151
+ target="$target-musl"
152
+ fi
153
+
154
+ filename="$APP-$target$archive_ext"
155
+
156
+ if [ "$os" = "linux" ]; then
157
+ if ! command -v tar >/dev/null 2>&1; then
158
+ echo -e "${RED}Error: 'tar' is required but not installed.${NC}"
159
+ exit 1
160
+ fi
161
+ else
162
+ if ! command -v unzip >/dev/null 2>&1; then
163
+ echo -e "${RED}Error: 'unzip' is required but not installed.${NC}"
164
+ exit 1
165
+ fi
166
+ fi
167
+
168
+ if [ -z "$requested_version" ]; then
169
+ url="https://github.com/SII-Holos/synergy/releases/latest/download/$filename"
170
+ specific_version=$(curl -s https://api.github.com/repos/SII-Holos/synergy/releases/latest | sed -n 's/.*"tag_name": *"v\([^"]*\)".*/\1/p')
171
+
172
+ if [[ $? -ne 0 || -z "$specific_version" ]]; then
173
+ echo -e "${RED}Failed to fetch version information${NC}"
174
+ exit 1
175
+ fi
176
+ else
177
+ # Strip leading 'v' if present
178
+ requested_version="${requested_version#v}"
179
+ url="https://github.com/SII-Holos/synergy/releases/download/v${requested_version}/$filename"
180
+ specific_version=$requested_version
181
+
182
+ # Verify the release exists before downloading
183
+ http_status=$(curl -sI -o /dev/null -w "%{http_code}" "https://github.com/SII-Holos/synergy/releases/tag/v${requested_version}")
184
+ if [ "$http_status" = "404" ]; then
185
+ echo -e "${RED}Error: Release v${requested_version} not found${NC}"
186
+ echo -e "${MUTED}Available releases: https://github.com/SII-Holos/synergy/releases${NC}"
187
+ exit 1
188
+ fi
189
+ fi
190
+ fi
191
+
192
+ print_message() {
193
+ local level=$1
194
+ local message=$2
195
+ local color=""
196
+
197
+ case $level in
198
+ info) color="${NC}" ;;
199
+ warning) color="${NC}" ;;
200
+ error) color="${RED}" ;;
201
+ esac
202
+
203
+ echo -e "${color}${message}${NC}"
204
+ }
205
+
206
+ check_version() {
207
+ if command -v meta-synergy >/dev/null 2>&1; then
208
+ meta_synergy_path=$(which meta-synergy)
209
+
210
+ ## Check the installed version
211
+ installed_version=$(meta-synergy --version 2>/dev/null || echo "")
212
+
213
+ if [[ "$installed_version" != "$specific_version" ]]; then
214
+ print_message info "${MUTED}Installed version: ${NC}$installed_version."
215
+ else
216
+ print_message info "${MUTED}Version ${NC}$specific_version${MUTED} already installed"
217
+ exit 0
218
+ fi
219
+ fi
220
+ }
221
+
222
+ unbuffered_sed() {
223
+ if echo | sed -u -e "" >/dev/null 2>&1; then
224
+ sed -nu "$@"
225
+ elif echo | sed -l -e "" >/dev/null 2>&1; then
226
+ sed -nl "$@"
227
+ else
228
+ local pad="$(printf "\n%512s" "")"
229
+ sed -ne "s/$/\\${pad}/" "$@"
230
+ fi
231
+ }
232
+
233
+ print_progress() {
234
+ local bytes="$1"
235
+ local length="$2"
236
+ [ "$length" -gt 0 ] || return 0
237
+
238
+ local width=50
239
+ local percent=$(( bytes * 100 / length ))
240
+ [ "$percent" -gt 100 ] && percent=100
241
+ local on=$(( percent * width / 100 ))
242
+ local off=$(( width - on ))
243
+
244
+ local filled=$(printf "%*s" "$on" "")
245
+ filled=${filled// /■}
246
+ local empty=$(printf "%*s" "$off" "")
247
+ empty=${empty// /・}
248
+
249
+ printf "\r${ORANGE}%s%s %3d%%${NC}" "$filled" "$empty" "$percent" >&4
250
+ }
251
+
252
+ download_with_progress() {
253
+ local url="$1"
254
+ local output="$2"
255
+
256
+ if [ -t 2 ]; then
257
+ exec 4>&2
258
+ else
259
+ exec 4>/dev/null
260
+ fi
261
+
262
+ local tmp_dir=${TMPDIR:-/tmp}
263
+ local basename="${tmp_dir}/meta-synergy_install_$$"
264
+ local tracefile="${basename}.trace"
265
+
266
+ rm -f "$tracefile"
267
+ mkfifo "$tracefile"
268
+
269
+ # Hide cursor
270
+ printf "\033[?25l" >&4
271
+
272
+ trap "trap - RETURN; rm -f \"$tracefile\"; printf '\033[?25h' >&4; exec 4>&-" RETURN
273
+
274
+ (
275
+ curl --trace-ascii "$tracefile" -s -L -o "$output" "$url"
276
+ ) &
277
+ local curl_pid=$!
278
+
279
+ unbuffered_sed \
280
+ -e 'y/ACDEGHLNORTV/acdeghlnortv/' \
281
+ -e '/^0000: content-length:/p' \
282
+ -e '/^<= recv data/p' \
283
+ "$tracefile" | \
284
+ {
285
+ local length=0
286
+ local bytes=0
287
+
288
+ while IFS=" " read -r -a line; do
289
+ [ "${#line[@]}" -lt 2 ] && continue
290
+ local tag="${line[0]} ${line[1]}"
291
+
292
+ if [ "$tag" = "0000: content-length:" ]; then
293
+ length="${line[2]}"
294
+ length=$(echo "$length" | tr -d '\r')
295
+ bytes=0
296
+ elif [ "$tag" = "<= recv" ]; then
297
+ local size="${line[3]}"
298
+ bytes=$(( bytes + size ))
299
+ if [ "$length" -gt 0 ]; then
300
+ print_progress "$bytes" "$length"
301
+ fi
302
+ fi
303
+ done
304
+ }
305
+
306
+ wait $curl_pid
307
+ local ret=$?
308
+ echo "" >&4
309
+ return $ret
310
+ }
311
+
312
+ download_and_install() {
313
+ print_message info "\n${MUTED}Installing ${NC}meta-synergy ${MUTED}version: ${NC}$specific_version"
314
+ local tmp_dir="${TMPDIR:-/tmp}/meta_synergy_install_$$"
315
+ mkdir -p "$tmp_dir"
316
+
317
+ if [[ "$os" == "windows" ]] || ! [ -t 2 ] || ! download_with_progress "$url" "$tmp_dir/$filename"; then
318
+ # Fallback to standard curl on Windows, non-TTY environments, or if custom progress fails
319
+ curl -# -L -o "$tmp_dir/$filename" "$url"
320
+ fi
321
+
322
+ if [ "$os" = "linux" ]; then
323
+ tar -xzf "$tmp_dir/$filename" -C "$tmp_dir"
324
+ else
325
+ unzip -q "$tmp_dir/$filename" -d "$tmp_dir"
326
+ fi
327
+
328
+ mv "$tmp_dir/bin/meta-synergy" "$INSTALL_DIR/meta-synergy"
329
+ chmod 755 "${INSTALL_DIR}/meta-synergy"
330
+ rm -rf "$tmp_dir"
331
+ }
332
+
333
+ install_from_binary() {
334
+ print_message info "\n${MUTED}Installing ${NC}meta-synergy ${MUTED}from: ${NC}$binary_path"
335
+ cp "$binary_path" "${INSTALL_DIR}/meta-synergy"
336
+ chmod 755 "${INSTALL_DIR}/meta-synergy"
337
+ }
338
+
339
+ if [ -n "$binary_path" ]; then
340
+ install_from_binary
341
+ else
342
+ check_version
343
+ download_and_install
344
+ fi
345
+
346
+
347
+ add_to_path() {
348
+ local config_file=$1
349
+ local command=$2
350
+
351
+ if grep -Fxq "$command" "$config_file"; then
352
+ print_message info "Command already exists in $config_file, skipping write."
353
+ elif [[ -w $config_file ]]; then
354
+ echo -e "\n# meta-synergy" >> "$config_file"
355
+ echo "$command" >> "$config_file"
356
+ print_message info "${MUTED}Successfully added ${NC}meta-synergy ${MUTED}to \$PATH in ${NC}$config_file"
357
+ else
358
+ print_message warning "Manually add the directory to $config_file (or similar):"
359
+ print_message info " $command"
360
+ fi
361
+ }
362
+
363
+ XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-$HOME/.config}
364
+
365
+ current_shell=$(basename "$SHELL")
366
+ case $current_shell in
367
+ fish)
368
+ config_files="$HOME/.config/fish/config.fish"
369
+ ;;
370
+ zsh)
371
+ config_files="$HOME/.zshrc $HOME/.zshenv $XDG_CONFIG_HOME/zsh/.zshrc $XDG_CONFIG_HOME/zsh/.zshenv"
372
+ ;;
373
+ bash)
374
+ config_files="$HOME/.bashrc $HOME/.bash_profile $HOME/.profile $XDG_CONFIG_HOME/bash/.bashrc $XDG_CONFIG_HOME/bash/.bash_profile"
375
+ ;;
376
+ ash)
377
+ config_files="$HOME/.ashrc $HOME/.profile /etc/profile"
378
+ ;;
379
+ sh)
380
+ config_files="$HOME/.ashrc $HOME/.profile /etc/profile"
381
+ ;;
382
+ *)
383
+ # Default case if none of the above matches
384
+ config_files="$HOME/.bashrc $HOME/.bash_profile $XDG_CONFIG_HOME/bash/.bashrc $XDG_CONFIG_HOME/bash/.bash_profile"
385
+ ;;
386
+ esac
387
+
388
+ if [[ "$no_modify_path" != "true" ]]; then
389
+ config_file=""
390
+ for file in $config_files; do
391
+ if [[ -f $file ]]; then
392
+ config_file=$file
393
+ break
394
+ fi
395
+ done
396
+
397
+ if [[ -z $config_file ]]; then
398
+ print_message warning "No config file found for $current_shell. You may need to manually add to PATH:"
399
+ print_message info " export PATH=$INSTALL_DIR:\$PATH"
400
+ elif [[ ":$PATH:" != *":$INSTALL_DIR:"* ]]; then
401
+ case $current_shell in
402
+ fish)
403
+ add_to_path "$config_file" "fish_add_path $INSTALL_DIR"
404
+ ;;
405
+ zsh)
406
+ add_to_path "$config_file" "export PATH=$INSTALL_DIR:\$PATH"
407
+ ;;
408
+ bash)
409
+ add_to_path "$config_file" "export PATH=$INSTALL_DIR:\$PATH"
410
+ ;;
411
+ ash)
412
+ add_to_path "$config_file" "export PATH=$INSTALL_DIR:\$PATH"
413
+ ;;
414
+ sh)
415
+ add_to_path "$config_file" "export PATH=$INSTALL_DIR:\$PATH"
416
+ ;;
417
+ *)
418
+ export PATH=$INSTALL_DIR:$PATH
419
+ print_message warning "Manually add the directory to $config_file (or similar):"
420
+ print_message info " export PATH=$INSTALL_DIR:\$PATH"
421
+ ;;
422
+ esac
423
+ fi
424
+ fi
425
+
426
+ if [ -n "${GITHUB_ACTIONS-}" ] && [ "${GITHUB_ACTIONS}" == "true" ]; then
427
+ echo "$INSTALL_DIR" >> $GITHUB_PATH
428
+ print_message info "Added $INSTALL_DIR to \$GITHUB_PATH"
429
+ fi
430
+
431
+ echo -e ""
432
+ echo -e "${MUTED} ${NC} "
433
+ echo -e "${MUTED}█▀▀ █▀▄ █▀▀ █▀▀▀ █ █${NC}"
434
+ echo -e "${MUTED}▀▀█ █▀▄ █▀▀ █ ▀█ █▄▄█${NC}"
435
+ echo -e "${MUTED}▀▀▀ ▀ ▀ ▀▀▀ ▀▀▀▀ ▄▄█${NC}"
436
+ echo -e ""
437
+ echo -e ""
438
+ echo -e "${MUTED}MetaSynergy is ready! To start:${NC}"
439
+ echo -e ""
440
+ echo -e "meta-synergy ${MUTED}# Run command${NC}"
441
+ echo -e ""
442
+ echo -e "${MUTED}For more information visit ${NC}https://github.com/SII-Holos/synergy"
443
+ echo -e ""
444
+ echo -e ""
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@ericsanchezok/meta-synergy",
4
- "version": "1.1.26",
4
+ "version": "1.2.17",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "bin": {
@@ -22,12 +22,13 @@
22
22
  "build": "tsc -p tsconfig.json"
23
23
  },
24
24
  "dependencies": {
25
- "@ericsanchezok/meta-protocol": "workspace:*",
26
- "zod": "catalog:"
25
+ "@ericsanchezok/meta-protocol": "1.2.17",
26
+ "jsonc-parser": "3.3.1",
27
+ "zod": "4.1.8"
27
28
  },
28
29
  "devDependencies": {
29
- "@tsconfig/node22": "catalog:",
30
- "@types/node": "catalog:",
31
- "typescript": "catalog:"
30
+ "@tsconfig/node22": "22.0.2",
31
+ "@types/node": "22.13.9",
32
+ "typescript": "5.8.2"
32
33
  }
33
34
  }
@@ -0,0 +1,93 @@
1
+ #!/usr/bin/env bun
2
+
3
+ import path from "path"
4
+
5
+ const dir = path.resolve(import.meta.dir, "..")
6
+
7
+ process.chdir(dir)
8
+
9
+ const singleFlag = process.argv.includes("--single")
10
+ const baselineFlag = process.argv.includes("--baseline")
11
+
12
+ const version = process.env.META_SYNERGY_VERSION ?? "0.0.0-dev"
13
+
14
+ const allTargets: {
15
+ os: string
16
+ arch: "arm64" | "x64"
17
+ abi?: "musl"
18
+ avx2?: false
19
+ }[] = [
20
+ // Linux glibc
21
+ { os: "linux", arch: "arm64" },
22
+ { os: "linux", arch: "x64" },
23
+ { os: "linux", arch: "x64", avx2: false },
24
+ // Linux musl
25
+ { os: "linux", arch: "arm64", abi: "musl" },
26
+ { os: "linux", arch: "x64", abi: "musl" },
27
+ { os: "linux", arch: "x64", abi: "musl", avx2: false },
28
+ // macOS
29
+ { os: "darwin", arch: "arm64" },
30
+ { os: "darwin", arch: "x64" },
31
+ { os: "darwin", arch: "x64", avx2: false },
32
+ // Windows
33
+ { os: "win32", arch: "x64" },
34
+ { os: "win32", arch: "x64", avx2: false },
35
+ { os: "win32", arch: "arm64" },
36
+ ]
37
+
38
+ const targets = singleFlag
39
+ ? allTargets.filter((item) => {
40
+ if (item.os !== process.platform || item.arch !== process.arch) return false
41
+ if (item.avx2 === false) return baselineFlag
42
+ return !item.abi
43
+ })
44
+ : allTargets
45
+
46
+ await Bun.write(Bun.stdout, `building ${targets.length} meta-synergy target(s)\n`)
47
+ await Bun.$`rm -rf dist`
48
+
49
+ for (const item of targets) {
50
+ const name = buildName(item)
51
+ const bunTarget = buildBunTarget(item)
52
+ const binaryName = item.os === "win32" ? "meta-synergy.exe" : "meta-synergy"
53
+
54
+ console.log(`building ${name} (${bunTarget})`)
55
+ await Bun.$`mkdir -p dist/${name}/bin`
56
+
57
+ await Bun.build({
58
+ entrypoints: ["./src/cli.ts"],
59
+ compile: {
60
+ target: bunTarget as any,
61
+ outfile: `dist/${name}/bin/${binaryName}`,
62
+ autoloadBunfig: false,
63
+ autoloadDotenv: false,
64
+ },
65
+ define: {
66
+ META_SYNERGY_VERSION: `'${version}'`,
67
+ },
68
+ })
69
+ }
70
+
71
+ function buildName(item: (typeof allTargets)[number]): string {
72
+ return [
73
+ "meta-synergy",
74
+ item.os === "win32" ? "windows" : item.os,
75
+ item.arch,
76
+ item.avx2 === false ? "baseline" : undefined,
77
+ item.abi,
78
+ ]
79
+ .filter(Boolean)
80
+ .join("-")
81
+ }
82
+
83
+ function buildBunTarget(item: (typeof allTargets)[number]): string {
84
+ return [
85
+ "bun",
86
+ item.os === "win32" ? "windows" : item.os,
87
+ item.arch,
88
+ item.avx2 === false ? "baseline" : undefined,
89
+ item.abi,
90
+ ]
91
+ .filter(Boolean)
92
+ .join("-")
93
+ }