91e1f1ec9a
Übernimmt den unproponierten Entwurf aus /tmp/orch-pc-pfad-cache (Users Orchestrator-Läufe 09.07. früh) mit einem konstruktiven Fix: der Entwurf rief pc_shell als Shell-Befehl auf — das ist aber ein Agent-Tool, kein Binary, der Fallback konnte nie funktionieren (der untracked .py-Rest war ein angefangener Reparaturversuch via MCP-stdio, unnötig kompliziert). Neues Design: pc_path_lookup.sh = reiner YAML-Cache (lookup/merken/liste, exit 3 = Miss); die PC-Suche bei Cache-Miss macht der Agent selbst mit seinem pc_shell-TOOL und merkt den Fund. SKILL.md im Hausstandard, deploy.sh installiert Skill + Skript. Getestet auf der Box: merken/lookup-Roundtrip inkl. Umlaut- Normalisierung (Ä→ae, dabei tr-Umlaut-Falle gefixt), Miss=exit 3, bash -n grün. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
72 lines
2.2 KiB
Bash
72 lines
2.2 KiB
Bash
#!/usr/bin/env bash
|
|
# pc_path_lookup.sh — YAML-Cache für Windows-PC-Pfade (~/.hermes/pc-paths.yaml).
|
|
#
|
|
# REINER Cache, bewusst OHNE PC-Suche: `pc_shell` ist ein Agent-Tool, kein Binary —
|
|
# der ursprüngliche Entwurf rief es als Shell-Befehl auf und konnte nie funktionieren.
|
|
# Die Suche bei Cache-Miss macht der AGENT selbst (pc_shell-Tool) und legt den Fund
|
|
# danach hier per `merken` ab. Siehe deploy/skills/pc-pfad-cache/SKILL.md.
|
|
#
|
|
# Aufrufe:
|
|
# pc_path_lookup.sh lookup <key> → Pfad auf stdout (exit 0) | exit 3 = Cache-Miss
|
|
# pc_path_lookup.sh merken <key> <pfad> → Eintrag anlegen/aktualisieren
|
|
# pc_path_lookup.sh liste → alle Einträge (key<TAB>pfad)
|
|
set -euo pipefail
|
|
|
|
MODUS="${1:?FEHLT: lookup|merken|liste}"
|
|
YAML_FILE="$HOME/.hermes/pc-paths.yaml"
|
|
PY="$HOME/.hermes/hermes-agent/venv/bin/python"
|
|
[ -x "$PY" ] || PY=python3
|
|
|
|
normalize() {
|
|
# Umlaute ZUERST ausschreiben (beide Fälle — tr lowercased kein Ä/Ö/Ü), dann klein,
|
|
# Leerzeichen → Bindestrich
|
|
printf '%s' "$1" \
|
|
| sed 's/Ä/ae/g; s/Ö/oe/g; s/Ü/ue/g; s/ä/ae/g; s/ö/oe/g; s/ü/ue/g; s/ß/ss/g' \
|
|
| tr '[:upper:]' '[:lower:]' | sed 's/ /-/g'
|
|
}
|
|
|
|
case "$MODUS" in
|
|
lookup)
|
|
KEY=$(normalize "${2:?FEHLT: key}")
|
|
"$PY" - "$YAML_FILE" "$KEY" <<'PYEOF'
|
|
import sys, yaml
|
|
try:
|
|
data = yaml.safe_load(open(sys.argv[1])) or {}
|
|
except FileNotFoundError:
|
|
data = {}
|
|
apps = data.get("apps") or {}
|
|
if sys.argv[2] in apps:
|
|
print(apps[sys.argv[2]])
|
|
else:
|
|
sys.exit(3)
|
|
PYEOF
|
|
;;
|
|
merken)
|
|
KEY=$(normalize "${2:?FEHLT: key}")
|
|
PFAD="${3:?FEHLT: pfad}"
|
|
"$PY" - "$YAML_FILE" "$KEY" "$PFAD" <<'PYEOF'
|
|
import sys, yaml
|
|
try:
|
|
data = yaml.safe_load(open(sys.argv[1])) or {}
|
|
except FileNotFoundError:
|
|
data = {}
|
|
data.setdefault("apps", {})[sys.argv[2]] = sys.argv[3]
|
|
yaml.safe_dump(data, open(sys.argv[1], "w"), allow_unicode=True, default_flow_style=False)
|
|
print(f"gemerkt: {sys.argv[2]} -> {sys.argv[3]}")
|
|
PYEOF
|
|
;;
|
|
liste)
|
|
"$PY" - "$YAML_FILE" <<'PYEOF'
|
|
import sys, yaml
|
|
try:
|
|
data = yaml.safe_load(open(sys.argv[1])) or {}
|
|
except FileNotFoundError:
|
|
data = {}
|
|
for k, v in sorted((data.get("apps") or {}).items()):
|
|
print(f"{k}\t{v}")
|
|
PYEOF
|
|
;;
|
|
*)
|
|
echo "FEHLT: lookup|merken|liste" >&2; exit 2 ;;
|
|
esac
|