Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.zhouxuanting.opencode.health-monitor</string>

<key>ProgramArguments</key>
<array>
<string>/Users/zhouxuanting/opencode-context-infrastructure/.local_runtime/scripts/run-scheduled-job</string>
<string>health_monitor</string>
</array>

<key>WorkingDirectory</key>
<string>/Users/zhouxuanting/opencode-context-infrastructure</string>

<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>8</integer>
<key>Minute</key>
<integer>1</integer>
</dict>

<key>StandardOutPath</key>
<string>/Users/zhouxuanting/opencode-context-infrastructure/.local_runtime/logs/jobs/health_monitor.log</string>

<key>StandardErrorPath</key>
<string>/Users/zhouxuanting/opencode-context-infrastructure/.local_runtime/logs/jobs/health_monitor.err.log</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.zhouxuanting.opencode.health-receiver</string>

<key>ProgramArguments</key>
<array>
<string>/Users/zhouxuanting/opencode-context-infrastructure/.venv/bin/python3</string>
<string>/Users/zhouxuanting/opencode-context-infrastructure/tools/health_data_receiver.py</string>
<string>--port</string>
<string>9876</string>
</array>

<key>WorkingDirectory</key>
<string>/Users/zhouxuanting/opencode-context-infrastructure</string>

<key>KeepAlive</key>
<true/>

<key>StandardOutPath</key>
<string>/Users/zhouxuanting/opencode-context-infrastructure/.local_runtime/logs/services/health_receiver.log</string>

<key>StandardErrorPath</key>
<string>/Users/zhouxuanting/opencode-context-infrastructure/.local_runtime/logs/services/health_receiver.err.log</string>
</dict>
</plist>
88 changes: 88 additions & 0 deletions .local_runtime/scripts/run-scheduled-job
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#!/bin/bash
set -euo pipefail
export PATH="$HOME/.opencode/bin:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:${PATH:-}"

ROOT="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd -P)"
RUNTIME_ROOT="$ROOT/.local_runtime"
ENV_FILE="$ROOT/.env"
PYTHON_BIN="$ROOT/.venv/bin/python3"
JOB="${1:-}"
shift || true

load_env() {
if [[ -f "$ENV_FILE" ]]; then
set -a
source "$ENV_FILE"
set +a
fi
}

require_env() {
local missing=()
for name in "$@"; do
if [[ -z "${!name:-}" ]]; then
missing+=("$name")
fi
done
if [[ ${#missing[@]} -gt 0 ]]; then
echo "SKIP: missing env vars: ${missing[*]}"
exit 0
fi
}

[[ -n "$JOB" ]] || { echo "Usage: $(basename "$0") <job_name>" >&2; exit 1; }
cd "$ROOT"
mkdir -p "$RUNTIME_ROOT/logs/jobs"
load_env

[[ -x "$PYTHON_BIN" ]] || { echo "Missing virtualenv python: $PYTHON_BIN" >&2; exit 1; }

case "$JOB" in
observer)
require_env OPENCODE_BASE_URL OPENCODE_USERNAME OPENCODE_PASSWORD
exec "$PYTHON_BIN" "$ROOT/periodic_jobs/ai_heartbeat/src/v0/observer.py" "$@"
;;
reflector)
require_env OPENCODE_BASE_URL OPENCODE_USERNAME OPENCODE_PASSWORD
exec "$PYTHON_BIN" "$ROOT/periodic_jobs/ai_heartbeat/src/v0/reflector.py" "$@"
;;
crontab_monitor)
require_env OPENCODE_BASE_URL OPENCODE_USERNAME OPENCODE_PASSWORD GMAIL_USERNAME GMAIL_APP_PASSWORD
exec "$PYTHON_BIN" "$ROOT/periodic_jobs/ai_heartbeat/src/v0/jobs/crontab_monitor.py" "$@"
;;
ai_news_daily)
require_env OPENCODE_BASE_URL OPENCODE_USERNAME OPENCODE_PASSWORD GMAIL_USERNAME GMAIL_APP_PASSWORD TAVILY_API_KEY
exec "$PYTHON_BIN" "$ROOT/periodic_jobs/ai_heartbeat/src/v0/jobs/ai_news_survey.py" --mode daily "$@"
;;
ai_news_weekly)
require_env OPENCODE_BASE_URL OPENCODE_USERNAME OPENCODE_PASSWORD GMAIL_USERNAME GMAIL_APP_PASSWORD TAVILY_API_KEY
exec "$PYTHON_BIN" "$ROOT/periodic_jobs/ai_heartbeat/src/v0/jobs/ai_news_survey.py" --mode weekly "$@"
;;
builders_digest)
# follow-builders skill: prepare feed JSON → OpenCode remix → deliver
NODE_BIN="/usr/local/bin/node"
SKILL_DIR="$HOME/.claude/skills/follow-builders/scripts"
[[ -x "$NODE_BIN" ]] || { echo "Missing node: $NODE_BIN" >&2; exit 1; }
[[ -d "$SKILL_DIR" ]] || { echo "Missing skill dir: $SKILL_DIR" >&2; exit 1; }
require_env OPENCODE_BASE_URL OPENCODE_USERNAME OPENCODE_PASSWORD
exec "$PYTHON_BIN" "$ROOT/periodic_jobs/ai_heartbeat/src/v0/jobs/builders_digest.py" --node-bin "$NODE_BIN" --skill-dir "${SKILL_DIR%/scripts}" "$@"
;;
action_advisor)
require_env OPENCODE_BASE_URL OPENCODE_USERNAME OPENCODE_PASSWORD GMAIL_USERNAME GMAIL_APP_PASSWORD
exec "$PYTHON_BIN" "$ROOT/periodic_jobs/ai_heartbeat/src/v0/jobs/action_advisor.py" "$@"
;;
life_record_digest)
exec "$PYTHON_BIN" "$ROOT/periodic_jobs/ai_heartbeat/src/v0/jobs/life_record_digest.py" "$@"
;;
github_trending)
require_env OPENCODE_BASE_URL OPENCODE_USERNAME OPENCODE_PASSWORD
exec "$PYTHON_BIN" "$ROOT/periodic_jobs/ai_heartbeat/src/v0/jobs/github_trending.py" "$@"
;;
health_monitor)
exec "$PYTHON_BIN" "$ROOT/periodic_jobs/ai_heartbeat/src/v0/jobs/health_monitor.py" "$@"
;;
*)
echo "Unknown job: $JOB" >&2
exit 1
;;
esac
Empty file added contexts/health/daily/.gitkeep
Empty file.
16 changes: 16 additions & 0 deletions contexts/health/daily/2026-04-07.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Health Summary 2026-04-07
## Sleep
- Total: 7h00m (23:15 - 06:15)
- Deep: 85min | REM: 110min | Light: 195min | Awake: 30min
## Heart
- Resting HR: 52 bpm
- HRV: 45 ms
- Range: 48-155 bpm

## Activity
- Steps: 8,234
- Active energy: 520 kcal | Exercise: 35 min | Stand: 10 hours

## Blood Oxygen
- Avg: 97% | Min: 94%

Empty file added contexts/health/data/.gitkeep
Empty file.
29 changes: 29 additions & 0 deletions contexts/health/data/2026-04-07.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"date": "2026-04-07",
"sleep": {
"total_minutes": 420,
"deep_minutes": 85,
"rem_minutes": 110,
"light_minutes": 195,
"awake_minutes": 30,
"bedtime": "23:15",
"wakeup": "06:15"
},
"heart": {
"resting_hr": 52,
"hrv_avg": 45,
"hrv_during_sleep": 52,
"hr_min": 48,
"hr_max": 155
},
"activity": {
"steps": 8234,
"active_energy_kcal": 520,
"exercise_minutes": 35,
"stand_hours": 10
},
"blood_oxygen": {
"avg": 97,
"min": 94
}
}
Empty file added contexts/health/weekly/.gitkeep
Empty file.
Loading