sync: auto-sync from Mikes-MacBook-Air.local at 2026-07-08 06:49:28

Author: Mike Swanson
Machine: Mikes-MacBook-Air.local
Timestamp: 2026-07-08 06:49:28
This commit is contained in:
2026-07-08 06:49:37 -07:00
parent fc12c596f1
commit 2a1ea6c9f7
10 changed files with 22260 additions and 4 deletions

View File

@@ -0,0 +1,32 @@
#!/usr/bin/env bash
# get-identity.sh — Read identity.json and export user/machine vars for attribution
#
# Source this at the start of any skill that needs attribution (bot alerts, commits,
# logs, RMM operations). Exports $USER_NAME, $USER_SHORT, $MACHINE, $USER_EMAIL.
#
# Usage:
# source .claude/scripts/get-identity.sh
# echo "[RMM] $USER_SHORT deployed to X machines..."
#
# Soft-fails: if identity.json is missing, exports "Unknown" values and returns 1
# (but does NOT exit, so the caller continues). This ensures skills never break on
# missing identity - they just attribute to "Unknown".
IDENTITY_FILE="${CLAUDETOOLS_ROOT:-.}/.claude/identity.json"
if [ ! -f "$IDENTITY_FILE" ]; then
echo "[WARNING] identity.json not found at $IDENTITY_FILE - attribution will be 'Unknown'" >&2
export USER_NAME="Unknown User"
export USER_SHORT="unknown"
export MACHINE="unknown-machine"
export USER_EMAIL="unknown@unknown.com"
return 1
fi
export USER_NAME=$(jq -r '.full_name // .user // "Unknown"' "$IDENTITY_FILE" 2>/dev/null || echo "Unknown")
export USER_SHORT=$(jq -r '.user // "unknown"' "$IDENTITY_FILE" 2>/dev/null || echo "unknown")
export MACHINE=$(jq -r '.machine // "unknown"' "$IDENTITY_FILE" 2>/dev/null || echo "unknown")
export USER_EMAIL=$(jq -r '.email // "unknown@unknown.com"' "$IDENTITY_FILE" 2>/dev/null || echo "unknown@unknown.com")
# Success
return 0

View File

@@ -12,6 +12,11 @@
# bash post-bot-alert.sh "message text" bot # force #bot-alerts
# echo "message text" | bash post-bot-alert.sh
#
# Identity: This script sources get-identity.sh, making $USER_SHORT, $USER_NAME,
# $MACHINE, $USER_EMAIL available. Callers can use these in messages for correct
# attribution (e.g., "[RMM] $USER_SHORT deployed..."). The script itself doesn't
# auto-inject identity - callers must explicitly use the vars when needed.
#
# Token resolution (first hit wins):
# 1. SOPS vault: projects/discord-bot/bot-token.sops.yaml field credentials.bot_token
# 2. projects/discord-bot/.env key DISCORD_TOKEN
@@ -27,6 +32,9 @@ BOT_CHANNEL_ID="624710699771232265" # #bot-alerts — default (Syncro + gene
DEV_CHANNEL_ID="1509998508198068484" # #dev-alerts — private RMM/Dev alerts (Howard + Mike only)
ROOT="${CLAUDETOOLS_ROOT:-$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)}"
# Load identity for attribution (soft-fail if missing)
source "$ROOT/.claude/scripts/get-identity.sh" 2>/dev/null || true
# --- message (arg or stdin) ---
MSG="${1:-}"
if [ -z "$MSG" ] && [ ! -t 0 ]; then MSG="$(cat)"; fi