-> JSON array of active resources * php api/cli/resources.php touch [...] -> stamp last_used_at */ require __DIR__ . '/../vendor/autoload.php'; require __DIR__ . '/../config.php'; $cmd = $argv[1] ?? ''; if ($cmd === 'list') { $type = $argv[2] ?? ''; if ($type === '') { fwrite(STDERR, "usage: resources.php list \n"); exit(1); } $rows = \Db::select( "SELECT resource_id, name, url, kind, notes, priority FROM mde_resources WHERE agent_type = ? AND active = 1 ORDER BY priority DESC, resource_id ASC", [$type] ); echo json_encode($rows, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); exit; } if ($cmd === 'touch') { $ids = array_slice($argv, 2); foreach ($ids as $id) { \Db::execute("UPDATE mde_resources SET last_used_at = NOW() WHERE resource_id = ?", [(int) $id]); } echo json_encode(['ok' => true, 'touched' => count($ids)]); exit; } fwrite(STDERR, "usage: resources.php list | touch \n"); exit(1);