feat(identity): sync.sh and syncro.md read from identity.json

Phase 2 migration complete:

sync.sh:
- Read Python command from identity.json first (.python.command)
- Fall back to auto-detection for legacy machines
- Eliminates per-session detection overhead

syncro.md:
- Read Ollama endpoint from identity.json (.ollama.endpoint // .ollama.fallback)
- Read Python command from identity.json (.python.command)
- Both sections have legacy fallbacks with detection
- Eliminates 2-second curl probe on every write operation
- Updated day-of-week verification code example
- Updated Ollama draft call section

Impact: All scripts now read machine-specific config from identity.json
(populated by migrate-identity.sh). Faster, explicit, offline-safe.
This commit is contained in:
2026-05-26 20:12:25 -07:00
parent ba92c0bc84
commit 2c12bd2d04
2 changed files with 52 additions and 19 deletions

View File

@@ -58,7 +58,9 @@ Create, update, close, comment on, and bill tickets in Syncro PSA.
**Appointment dates — always verify day-of-week before the preview.** Day-of-week math is easy to get wrong. Before including any appointment date in a preview, run a live check and display the full day name alongside the date (e.g. "Saturday 2026-05-23", never just "2026-05-23"). The user confirms the day name at the preview step — if the name is wrong, the date is wrong. Incident: #32312 booked Sunday May 24 instead of Saturday May 23 (2026-05-21). Reported by Winter.
```bash
py -c "import datetime; d = datetime.date(YYYY, M, D); print(d.strftime('%A %Y-%m-%d'))"
# Read Python command from identity.json (Phase 2 migration), fallback to 'py' if unavailable
PYTHON=$(jq -r '.python.command // "py"' "$IDENTITY_PATH" 2>/dev/null || echo "py")
$PYTHON -c "import datetime; d = datetime.date(YYYY, M, D); print(d.strftime('%A %Y-%m-%d'))"
```
**After every write operation, post a summary + link to #bot-alerts.** Every ticket created, updated, closed, or commented, every billing run, and every customer created posts a one-line alert to the team's live feed in Discord. This runs AFTER the write succeeds (never before — no alert for an action that didn't happen) and applies regardless of who runs the skill or where (workstation or the Discord bot). Read-only commands (list / view / search) post nothing. Full format, link mapping, and helper call are in "Post to #bot-alerts" below.
@@ -135,15 +137,24 @@ esac
Ollama handles prose drafting for write operations. Claude reviews the output against the hard rules below, then presents a preview. User confirms. Claude executes.
**Availability check** — run once at the start of any write operation, reuse `$OLLAMA` for the rest of the session:
**Availability check** — read endpoint from identity.json (no probing), reuse `$OLLAMA` for the rest of the session:
```bash
if curl -s -m 2 http://localhost:11434/api/tags >/dev/null 2>&1; then
OLLAMA="http://localhost:11434"
elif curl -s -m 3 http://100.92.127.64:11434/api/tags >/dev/null 2>&1; then
OLLAMA="http://100.92.127.64:11434"
else
OLLAMA="" # fallback: Claude drafts directly
# Read Ollama endpoint from identity.json (Phase 2 migration: no curl probe)
OLLAMA=""
if [ -f "$IDENTITY_PATH" ] && command -v jq >/dev/null 2>&1; then
OLLAMA=$(jq -r '.ollama.endpoint // .ollama.fallback // empty' "$IDENTITY_PATH" 2>/dev/null)
fi
# Fallback: probe if identity.json doesn't have ollama config yet (legacy machines)
if [ -z "$OLLAMA" ]; then
if curl -s -m 2 http://localhost:11434/api/tags >/dev/null 2>&1; then
OLLAMA="http://localhost:11434"
elif curl -s -m 3 http://100.101.122.4:11434/api/tags >/dev/null 2>&1; then
OLLAMA="http://100.101.122.4:11434"
else
OLLAMA="" # Claude drafts directly
fi
fi
```
@@ -160,8 +171,22 @@ cat > "$PROMPT_FILE" <<'ENDPROMPT'
<prompt content here>
ENDPROMPT
# Read Python command from identity.json (Phase 2 migration)
PYTHON=$(jq -r '.python.command // empty' "$IDENTITY_PATH" 2>/dev/null)
if [ -z "$PYTHON" ]; then
# Fallback: auto-detect (legacy machines)
for candidate in py python3 python; do
if command -v "$candidate" >/dev/null 2>&1; then
if "$candidate" -c "import sys; sys.exit(0)" >/dev/null 2>&1; then
PYTHON="$candidate"
break
fi
fi
done
fi
if [ -n "$OLLAMA" ]; then
DRAFT=$(PROMPT_FILE="$PROMPT_FILE" py -c "
DRAFT=$(PROMPT_FILE="$PROMPT_FILE" $PYTHON -c "
import os, urllib.request, json, sys
prompt = open(os.environ['PROMPT_FILE']).read()
body = json.dumps({

View File

@@ -116,18 +116,26 @@ cd "$REPO_ROOT"
echo -e "${GREEN}[OK]${NC} Working directory: $(pwd)"
# Detect Python interpreter — verify it actually runs (Windows Store stub passes command -v but fails to execute)
# Detect Python interpreter — read from identity.json first, fall back to detection
PYTHON=""
for candidate in py python3 python; do
if command -v "$candidate" >/dev/null 2>&1; then
if "$candidate" -c "import sys; sys.exit(0)" >/dev/null 2>&1; then
PYTHON="$candidate"
break
fi
fi
done
if [ -f ".claude/identity.json" ] && command -v jq >/dev/null 2>&1; then
PYTHON=$(jq -r '.python.command // empty' ".claude/identity.json" 2>/dev/null)
fi
# Fallback: auto-detect if not in identity.json
if [ -z "$PYTHON" ]; then
echo -e "${RED}[ERROR]${NC} No Python interpreter found (tried: py, python3, python)"
for candidate in py python3 python; do
if command -v "$candidate" >/dev/null 2>&1; then
if "$candidate" -c "import sys; sys.exit(0)" >/dev/null 2>&1; then
PYTHON="$candidate"
break
fi
fi
done
fi
if [ -z "$PYTHON" ]; then
echo -e "${RED}[ERROR]${NC} No Python interpreter found. Run .claude/scripts/migrate-identity.sh to populate identity.json."
exit 1
fi