modelshelf 0.1.0

A shared local LLM model registry: discover, deduplicate, download, and update models across desktop apps.
Documentation
//! Jan keeps plain GGUF files under its data folder's `models` directory.
//! The location moved across versions, so several candidates are probed.

use std::path::{Path, PathBuf};

use super::{FoundFile, ScanEnv, Scanner};
use crate::registry::Ecosystem;

pub(crate) struct JanScanner;

impl Scanner for JanScanner {
    fn ecosystem(&self) -> Ecosystem {
        Ecosystem::Jan
    }

    fn detect_root(&self, env: &ScanEnv) -> Option<PathBuf> {
        if let Some(root) = env.root_override(self.ecosystem()) {
            return root.is_dir().then(|| root.to_path_buf());
        }
        let home = env.home()?;
        [
            home.join("jan").join("models"),
            home.join(".local")
                .join("share")
                .join("Jan")
                .join("data")
                .join("models"),
            home.join("Library")
                .join("Application Support")
                .join("Jan")
                .join("data")
                .join("models"),
        ]
        .into_iter()
        .find(|c| c.is_dir())
    }

    fn scan(&self, root: &Path) -> Vec<FoundFile> {
        super::walk_gguf(root, Ecosystem::Jan)
    }
}