#!/bin/sh # Semantic vault search via the local Miyo CLI; prints Miyo's JSON to stdout. # Resolves the miyo binary so the agent never has to deal with PATH. die() { printf '%s\n' "$1" >&2 exit "${2:-2}" } QUERY="$*" [ -n "$QUERY" ] || die "Usage: sh miyo-search.sh " 1 # Absolute install path first (Obsidian shells often miss Miyo's bin on PATH). if [ -x "$HOME/.miyo/bin/miyo" ]; then MIYO="$HOME/.miyo/bin/miyo" elif command -v miyo >/dev/null 2>&1; then MIYO=miyo else die "Miyo CLI not found (no ~/.miyo/bin/miyo and 'miyo' not on PATH). The Miyo desktop app is not installed — tell the user to install Miyo, then retry. Do not retry in a loop." 3 fi OUT=$("$MIYO" search "$QUERY" -n 10 --json 2>&1) || die "Miyo search failed — the Miyo app may not be running. Tell the user to open Miyo, then continue without vault search if they can't. Details: $OUT" 1 printf '%s\n' "$OUT"