mirror of
https://github.com/myronblair/jarvis
synced 2026-07-27 16:22:55 -05:00
Adopt live production state as git baseline
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
// Proactive suggestions endpoint — returns time-based command suggestions
|
||||
require_once __DIR__ . '/../config.php';
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$hour = (int)date('G');
|
||||
$dow = (int)date('w'); // 0=Sun, 6=Sat
|
||||
|
||||
// Find intents used 3+ times at this hour and day-of-week
|
||||
$rows = JarvisDB::query(
|
||||
"SELECT intent_name, hit_count FROM usage_patterns
|
||||
WHERE hour=? AND dow=? AND hit_count >= 3
|
||||
ORDER BY hit_count DESC LIMIT 3",
|
||||
[$hour, $dow]
|
||||
) ?? [];
|
||||
|
||||
// Map intents to friendly suggestion prompts
|
||||
$intentPrompts = [
|
||||
'network_scan' => 'Run a network scan?',
|
||||
'jellyfin_now_playing' => 'Check what\'s playing on Jellyfin?',
|
||||
'jellyfin_library' => 'Check the Jellyfin library?',
|
||||
'ha_scene' => 'Activate a home scene?',
|
||||
'planner:briefing' => 'Get your daily briefing?',
|
||||
'vm_suggestions' => 'Check VM resource usage?',
|
||||
'jellyfin_pause' => 'Pause Jellyfin?',
|
||||
'focus_mode' => 'Switch to focus mode?',
|
||||
'show_panels' => 'Show all panels?',
|
||||
];
|
||||
|
||||
$suggestions = [];
|
||||
foreach ($rows as $r) {
|
||||
$intent = $r['intent_name'];
|
||||
if (isset($intentPrompts[$intent])) {
|
||||
$suggestions[] = [
|
||||
'intent' => $intent,
|
||||
'prompt' => $intentPrompts[$intent],
|
||||
'hit_count' => (int)$r['hit_count'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode(['suggestions' => $suggestions, 'hour' => $hour, 'dow' => $dow]);
|
||||
Reference in New Issue
Block a user