vault-sync: 2026-09-16 00:00 (jimmy)

This commit is contained in:
jimmy
2026-09-16 00:00:30 -07:00
parent cf3c882c94
commit 00719428b2
194 changed files with 42289 additions and 0 deletions
@@ -0,0 +1,14 @@
contact-lookup
hey-check
hey-feed
hey-imbox
hey-later
hey-seen
hey-thread
hey-trail
tracker-mailbox
tracker-recent
tracker-search
tracker-today
vault-inbox
vault-stats
@@ -0,0 +1,59 @@
#!/usr/bin/env bash
# Search Hey tracker for all emails from a specific person
# Usage: contact-lookup <name or email>
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
VAULT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)"
TRACKER="$VAULT_DIR/Meta/hey-tracker.jsonl"
if [[ ! -f "$TRACKER" ]]; then
echo "Tracker not found at $TRACKER" >&2
exit 1
fi
if [[ -z "${1:-}" ]]; then
echo "Usage: contact-lookup <name or email>" >&2
exit 1
fi
python3 - "$TRACKER" "$1" <<'PYEOF'
import json, sys
tracker_path, query = sys.argv[1], sys.argv[2].lower()
results = []
with open(tracker_path) as f:
for line in f:
try:
e = json.loads(line)
except Exception:
continue
if query in e.get("sender_name", "").lower() or query in e.get("sender_email", "").lower():
results.append(e)
# Dedupe by topic_id, keep latest (skip entries with no topic_id)
seen = {}
for e in results:
tid = e.get("topic_id")
if not tid:
continue
seen[tid] = e
results = sorted(seen.values(), key=lambda x: x.get("active_at", ""), reverse=True)
if not results:
print(f'No emails found from "{query}"')
else:
emails = set(e.get("sender_email", "") for e in results if e.get("sender_email"))
names = set(e.get("sender_name", "") for e in results if e.get("sender_name"))
print(f'Found {len(results)} threads from: {", ".join(names)}')
print(f'Email(s): {", ".join(emails)}')
print()
for e in results[:20]:
date = e.get("active_at", "")[:10]
mb = e.get("mailbox", "")
subj = e.get("subject", "")[:60]
tid = e.get("topic_id", "")
print(f"{date} | {mb:8} | {subj} | {tid}")
if len(results) > 20:
print(f" ... and {len(results) - 20} more")
PYEOF
@@ -0,0 +1,70 @@
#!/usr/bin/env python3
"""Read hey-tracker.jsonl and display recent emails.
Usage:
hey-check # show last 2 days
hey-check 7 # show last 7 days
hey-check --all # show everything
hey-check --search FOI # search subjects and senders
"""
import json, sys
from datetime import datetime, timedelta, timezone
from pathlib import Path
# Derive vault root from script location: Meta/scripts/ -> vault root
SCRIPT_DIR = Path(__file__).parent
VAULT_DIR = SCRIPT_DIR.parent.parent
TRACKER = VAULT_DIR / "Meta" / "hey-tracker.jsonl"
def read_tracker():
if TRACKER.exists() and TRACKER.stat().st_size > 0:
return TRACKER.read_text().strip().split("\n")
return []
def main():
args = sys.argv[1:]
search = None
days = 2
show_all = False
if "--search" in args:
idx = args.index("--search")
search = args[idx + 1].lower() if idx + 1 < len(args) else ""
show_all = True
elif "--all" in args:
show_all = True
elif args and args[0].isdigit():
days = int(args[0])
cutoff = (datetime.now(timezone.utc) - timedelta(days=days)).strftime("%Y-%m-%d")
lines = read_tracker()
if not lines:
print("No tracker data available")
return
entries = []
for line in lines:
try:
entries.append(json.loads(line))
except Exception:
continue
for e in entries:
date = e.get("active_at", "")[:10]
if not show_all and date < cutoff:
continue
sender = e.get("sender_name", "")
subj = e.get("subject", "")
mailbox = e.get("mailbox", "")
tid = e.get("topic_id", "")
if search and search not in subj.lower() and search not in sender.lower() and search not in e.get("sender_email", "").lower():
continue
print(f"{date} | {mailbox:8} | {sender[:30]:30} | {subj[:65]} | {tid}")
if __name__ == "__main__":
main()
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
# List Hey Feed (newsletters, notifications)
# Usage: hey-feed [--json]
set -euo pipefail
if [[ "${1:-}" == "--json" ]]; then
hey box feedbox --json
else
hey box feedbox --json | python3 -c "
import json, sys
data = json.load(sys.stdin)
for p in data.get('data', {}).get('postings', []):
date = p.get('active_at', '')[:10]
sender = p.get('creator', {}).get('name', '')[:30]
subj = p.get('name', '')[:65]
tid = p.get('app_url', '').split('/')[-1]
print(f'{date} | {sender:30} | {subj} | {tid}')
"
fi
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
# List Hey Imbox (screened-in, high priority emails)
# Usage: hey-imbox [--json]
set -euo pipefail
if [[ "${1:-}" == "--json" ]]; then
hey box imbox --json
else
hey box imbox --json | python3 -c "
import json, sys
data = json.load(sys.stdin)
for p in data.get('data', {}).get('postings', []):
date = p.get('active_at', '')[:10]
sender = p.get('creator', {}).get('name', '')[:30]
subj = p.get('name', '')[:65]
tid = p.get('app_url', '').split('/')[-1]
print(f'{date} | {sender:30} | {subj} | {tid}')
"
fi
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
# List Hey Reply Later / Set Aside
# Usage: hey-later [--json]
set -euo pipefail
if [[ "${1:-}" == "--json" ]]; then
hey box laterbox --json
else
hey box laterbox --json | python3 -c "
import json, sys
data = json.load(sys.stdin)
for p in data.get('data', {}).get('postings', []):
date = p.get('active_at', '')[:10]
sender = p.get('creator', {}).get('name', '')[:30]
subj = p.get('name', '')[:65]
tid = p.get('app_url', '').split('/')[-1]
print(f'{date} | {sender:30} | {subj} | {tid}')
"
fi
@@ -0,0 +1,9 @@
#!/usr/bin/env bash
# Mark a Hey posting as seen
# Usage: hey-seen <posting_id>
set -euo pipefail
if [[ -z "${1:-}" ]]; then
echo "Usage: hey-seen <posting_id>" >&2
exit 1
fi
hey seen "$1"
@@ -0,0 +1,9 @@
#!/usr/bin/env bash
# Read a specific Hey thread by ID
# Usage: hey-thread <posting_id>
set -euo pipefail
if [[ -z "${1:-}" ]]; then
echo "Usage: hey-thread <posting_id>" >&2
exit 1
fi
hey threads "$1" --json
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
# List Hey Paper Trail (receipts, confirmations, financial)
# Usage: hey-trail [--json]
set -euo pipefail
if [[ "${1:-}" == "--json" ]]; then
hey box trailbox --json
else
hey box trailbox --json | python3 -c "
import json, sys
data = json.load(sys.stdin)
for p in data.get('data', {}).get('postings', []):
date = p.get('active_at', '')[:10]
sender = p.get('creator', {}).get('name', '')[:30]
subj = p.get('name', '')[:65]
tid = p.get('app_url', '').split('/')[-1]
print(f'{date} | {sender:30} | {subj} | {tid}')
"
fi
@@ -0,0 +1,71 @@
#!/usr/bin/env bash
# Filter Hey tracker by mailbox
# Usage: tracker-mailbox <imbox|feedbox|trailbox> [days] [--json]
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
VAULT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)"
TRACKER="$VAULT_DIR/Meta/hey-tracker.jsonl"
if [[ ! -f "$TRACKER" ]]; then
echo "Tracker not found at $TRACKER" >&2
exit 1
fi
MAILBOX=""
DAYS=7
JSON=false
while [[ $# -gt 0 ]]; do
case "$1" in
--json) JSON=true; shift ;;
[0-9]*)
if ! [[ "$1" =~ ^[0-9]+$ ]]; then
echo "Error: days must be a positive integer" >&2
exit 1
fi
DAYS="$1"; shift ;;
*)
if [[ -z "$MAILBOX" ]]; then
MAILBOX="$1"
fi
shift ;;
esac
done
if [[ -z "$MAILBOX" ]]; then
echo "Usage: tracker-mailbox <imbox|feedbox|trailbox> [days] [--json]" >&2
exit 1
fi
AS_JSON=$([[ "$JSON" == "true" ]] && echo "1" || echo "0")
python3 - "$TRACKER" "$MAILBOX" "$DAYS" "$AS_JSON" <<'PYEOF'
import json, sys
from datetime import datetime, timedelta, timezone
tracker_path, mailbox, days, as_json_flag = sys.argv[1], sys.argv[2], int(sys.argv[3]), sys.argv[4] == "1"
cutoff = (datetime.now(timezone.utc) - timedelta(days=days)).strftime("%Y-%m-%d")
results = []
with open(tracker_path) as f:
for line in f:
try:
e = json.loads(line)
except Exception:
continue
if e.get("mailbox") != mailbox:
continue
if e.get("active_at", "")[:10] < cutoff:
continue
results.append(e)
if as_json_flag:
print(json.dumps(results, indent=2))
else:
for e in results:
date = e.get("active_at", "")[:10]
sender = e.get("sender_name", "")[:30]
subj = e.get("subject", "")[:60]
tid = e.get("topic_id", "")
print(f"{date} | {sender:30} | {subj} | {tid}")
PYEOF
@@ -0,0 +1,69 @@
#!/usr/bin/env bash
# Show recent Hey tracker entries (last N hours, default 24)
# Usage: tracker-recent [hours] [--mailbox imbox] [--json]
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
VAULT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)"
TRACKER="$VAULT_DIR/Meta/hey-tracker.jsonl"
if [[ ! -f "$TRACKER" ]]; then
echo "Tracker not found at $TRACKER" >&2
exit 1
fi
HOURS=24
MAILBOX=""
JSON=false
while [[ $# -gt 0 ]]; do
case "$1" in
--mailbox)
if [[ $# -lt 2 || "$2" == --* ]]; then
echo "Usage: tracker-recent [hours] [--mailbox imbox] [--json]" >&2
exit 1
fi
MAILBOX="$2"; shift 2 ;;
--json) JSON=true; shift ;;
[0-9]*)
if ! [[ "$1" =~ ^[0-9]+$ ]]; then
echo "Error: hours must be a positive integer" >&2
exit 1
fi
HOURS="$1"; shift ;;
*) shift ;;
esac
done
AS_JSON=$([[ "$JSON" == "true" ]] && echo "1" || echo "0")
python3 - "$TRACKER" "$HOURS" "$MAILBOX" "$AS_JSON" <<'PYEOF'
import json, sys
from datetime import datetime, timedelta, timezone
tracker_path, hours, mailbox_filter, as_json_flag = sys.argv[1], int(sys.argv[2]), sys.argv[3], sys.argv[4] == "1"
cutoff = (datetime.now(timezone.utc) - timedelta(hours=hours)).strftime("%Y-%m-%dT%H:%M:%S")
results = []
with open(tracker_path) as f:
for line in f:
try:
e = json.loads(line)
except Exception:
continue
if e.get("active_at", "")[:19] < cutoff:
continue
if mailbox_filter and e.get("mailbox") != mailbox_filter:
continue
results.append(e)
if as_json_flag:
print(json.dumps(results, indent=2))
else:
for e in results:
date = e.get("active_at", "")[:16]
mb = e.get("mailbox", "")
sender = e.get("sender_name", "")[:30]
subj = e.get("subject", "")[:60]
tid = e.get("topic_id", "")
print(f"{date} | {mb:8} | {sender:30} | {subj} | {tid}")
PYEOF
@@ -0,0 +1,72 @@
#!/usr/bin/env bash
# Search Hey tracker by subject, sender name, sender email, or summary
# Usage: tracker-search <query> [--mailbox imbox] [--json]
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
VAULT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)"
TRACKER="$VAULT_DIR/Meta/hey-tracker.jsonl"
if [[ ! -f "$TRACKER" ]]; then
echo "Tracker not found at $TRACKER" >&2
exit 1
fi
QUERY=""
MAILBOX=""
JSON=false
while [[ $# -gt 0 ]]; do
case "$1" in
--mailbox)
if [[ $# -lt 2 || "$2" == --* ]]; then
echo "Usage: tracker-search <query> [--mailbox imbox] [--json]" >&2
exit 1
fi
MAILBOX="$2"; shift 2 ;;
--json) JSON=true; shift ;;
*) QUERY="$1"; shift ;;
esac
done
if [[ -z "$QUERY" ]]; then
echo "Usage: tracker-search <query> [--mailbox imbox] [--json]" >&2
exit 1
fi
AS_JSON=$([[ "$JSON" == "true" ]] && echo "1" || echo "0")
python3 - "$TRACKER" "$QUERY" "$MAILBOX" "$AS_JSON" <<'PYEOF'
import json, sys
tracker_path, query, mailbox_filter, as_json_flag = sys.argv[1], sys.argv[2].lower(), sys.argv[3], sys.argv[4] == "1"
results = []
with open(tracker_path) as f:
for line in f:
try:
e = json.loads(line)
except Exception:
continue
if mailbox_filter and e.get("mailbox") != mailbox_filter:
continue
haystack = " ".join([
e.get("subject", ""),
e.get("sender_name", ""),
e.get("sender_email", ""),
e.get("summary", "")
]).lower()
if query not in haystack:
continue
results.append(e)
if as_json_flag:
print(json.dumps(results, indent=2))
else:
for e in results:
date = e.get("active_at", "")[:10]
mb = e.get("mailbox", "")
sender = e.get("sender_name", "")[:30]
subj = e.get("subject", "")[:60]
tid = e.get("topic_id", "")
print(f"{date} | {mb:8} | {sender:30} | {subj} | {tid}")
PYEOF
@@ -0,0 +1,62 @@
#!/usr/bin/env bash
# Show today's Hey tracker entries
# Usage: tracker-today [--mailbox imbox] [--json]
set -euo pipefail
# Derive vault root from script location: Meta/scripts/ -> vault root
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
VAULT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)"
TRACKER="$VAULT_DIR/Meta/hey-tracker.jsonl"
if [[ ! -f "$TRACKER" ]]; then
echo "Tracker not found at $TRACKER" >&2
exit 1
fi
TODAY=$(date -u +%Y-%m-%d)
MAILBOX=""
JSON=false
while [[ $# -gt 0 ]]; do
case "$1" in
--mailbox)
if [[ $# -lt 2 || "$2" == --* ]]; then
echo "Usage: tracker-today [--mailbox imbox] [--json]" >&2
exit 1
fi
MAILBOX="$2"; shift 2 ;;
--json) JSON=true; shift ;;
*) shift ;;
esac
done
AS_JSON=$([[ "$JSON" == "true" ]] && echo "1" || echo "0")
python3 - "$TRACKER" "$TODAY" "$MAILBOX" "$AS_JSON" <<'PYEOF'
import json, sys
tracker_path, today, mailbox_filter, as_json_flag = sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4] == "1"
results = []
with open(tracker_path) as f:
for line in f:
try:
e = json.loads(line)
except Exception:
continue
if not e.get("active_at", "").startswith(today):
continue
if mailbox_filter and e.get("mailbox") != mailbox_filter:
continue
results.append(e)
if as_json_flag:
print(json.dumps(results, indent=2))
else:
for e in results:
date = e.get("active_at", "")[:16]
mb = e.get("mailbox", "")
sender = e.get("sender_name", "")[:30]
subj = e.get("subject", "")[:60]
tid = e.get("topic_id", "")
print(f"{date} | {mb:8} | {sender:30} | {subj} | {tid}")
PYEOF
@@ -0,0 +1,27 @@
#!/usr/bin/env bash
# List notes currently in the inbox
# Usage: vault-inbox [--count]
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
VAULT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)"
INBOX="$VAULT_DIR/00-Inbox"
if [[ ! -d "$INBOX" ]]; then
if [[ "${1:-}" == "--count" ]]; then
echo "0"
else
echo "No inbox directory found at $INBOX"
fi
exit 0
fi
if [[ "${1:-}" == "--count" ]]; then
find "$INBOX" -name "*.md" -not -path "*/.*" 2>/dev/null | wc -l | tr -d ' '
else
find "$INBOX" -name "*.md" -not -path "*/.*" 2>/dev/null | while read -r f; do
mod=$(stat -f "%Sm" -t "%Y-%m-%d %H:%M" "$f" 2>/dev/null || stat -c "%y" "$f" 2>/dev/null | cut -c1-16 || echo "?")
name=$(basename "$f" .md)
echo " $mod $name"
done | sort -r
fi
@@ -0,0 +1,44 @@
#!/usr/bin/env bash
# Vault statistics: note counts by folder, recent activity
# Usage: vault-stats
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
VAULT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)"
echo "=== Vault Statistics ==="
echo ""
dirs=(
"00-Inbox"
"01-Projects"
"02-Areas"
"03-Resources"
"04-Archive"
"05-People"
"06-Meetings"
"07-Daily"
"MOC"
"Templates"
"Meta"
)
for dir in "${dirs[@]}"; do
if [[ -d "$VAULT_DIR/$dir" ]]; then
count=$(find "$VAULT_DIR/$dir" -name "*.md" -not -path "*/.*" 2>/dev/null | wc -l | tr -d ' ')
printf "%-20s %s notes\n" "$dir/" "$count"
fi
done
echo ""
echo "=== Recent Activity (last 24h) ==="
find "$VAULT_DIR" -name "*.md" -not -path "*/.*" -not -path "*/My-Brain-Is-Full-Crew/*" -mmin -1440 2>/dev/null | while read -r f; do
mod=$(stat -f "%Sm" -t "%Y-%m-%d %H:%M" "$f" 2>/dev/null || stat -c "%y" "$f" 2>/dev/null | cut -c1-16 || echo "?")
rel="${f#$VAULT_DIR/}"
echo " $mod $rel"
done | sort -r | head -20
echo ""
echo "=== Total ==="
total=$(find "$VAULT_DIR" -name "*.md" -not -path "*/.*" -not -path "*/My-Brain-Is-Full-Crew/*" 2>/dev/null | wc -l | tr -d ' ')
echo "$total notes in vault"