Modul-Split: Fachlogik nach domain/, OS-Code nach platform/, Tauri-Verdrahtung in app.rs/commands.rs
- lib.rs nur noch Prozessrollen-Dispatch + Panic-Tracer - KWin-Script als KDE-Pendant zur GNOME-Extension (Popup ans Zeiger- Rechteck), wird von deb/rpm mit ausgeliefert - SNI-Tray auf ksni (pure Rust), appindicator-Depends entfallen
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
//! Wurzelpfade der App und Home-Kontraktion/-Expansion.
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
/// Dateiname der Projekt-Registry unter ~/.config/ai-control.
|
||||
const PROJECTS_FILE: &str = "projects.json";
|
||||
|
||||
/// Wurzelpfade; in Tests mit temporärem home instanziierbar.
|
||||
pub(crate) struct Paths {
|
||||
pub(crate) home: PathBuf,
|
||||
}
|
||||
|
||||
impl Paths {
|
||||
pub(crate) fn real() -> Self {
|
||||
Paths { home: crate::platform::home_dir() }
|
||||
}
|
||||
|
||||
/// Default-Root: Alt-Layout (Discovery ohne Registry) und Ablageort neuer
|
||||
/// Projekte ohne gewählten Zielordner.
|
||||
pub(crate) fn projects_dir(&self) -> PathBuf {
|
||||
self.home.join("claude-projects")
|
||||
}
|
||||
|
||||
pub(crate) fn config_dir(&self) -> PathBuf {
|
||||
self.home.join(".config").join("ai-control")
|
||||
}
|
||||
|
||||
pub(crate) fn projects_file(&self) -> PathBuf {
|
||||
self.config_dir().join(PROJECTS_FILE)
|
||||
}
|
||||
|
||||
pub(crate) fn pools_dir(&self) -> PathBuf {
|
||||
self.config_dir().join("pools")
|
||||
}
|
||||
|
||||
/// Gemeinsames Icons-Verzeichnis aller Projekte — synct mit der App-Config,
|
||||
/// unabhängig von Pool-Zuordnung und Quell-Repos.
|
||||
pub(crate) fn icons_dir(&self) -> PathBuf {
|
||||
self.config_dir().join("icons")
|
||||
}
|
||||
|
||||
pub(crate) fn pool_dir(&self, pool: &str) -> PathBuf {
|
||||
self.pools_dir().join(pool)
|
||||
}
|
||||
|
||||
/// Panel-Dateien pro Projekt: der Skill schreibt seinen Entwurf hier hinein,
|
||||
/// der Terminal-Prozess beobachtet die Datei und zeigt sie im Panel.
|
||||
fn panels_dir(&self) -> PathBuf {
|
||||
self.config_dir().join("panels")
|
||||
}
|
||||
}
|
||||
|
||||
/// Panel-Datei eines Projekts (Kanal Skill -> Panel). Der Pfad landet als
|
||||
/// AI_CONTROL_PANEL in der PTY-Umgebung.
|
||||
pub(crate) fn panel_file(project: &str) -> PathBuf {
|
||||
Paths::real().panels_dir().join(format!("{project}.md"))
|
||||
}
|
||||
|
||||
/// "~" bzw. "~/x" relativ zum Home auflösen; alles andere unverändert.
|
||||
pub(crate) fn expand_home(paths: &Paths, p: &str) -> PathBuf {
|
||||
if p == "~" {
|
||||
return paths.home.clone();
|
||||
}
|
||||
match p.strip_prefix("~/") {
|
||||
Some(rest) => paths.home.join(rest),
|
||||
None => PathBuf::from(p),
|
||||
}
|
||||
}
|
||||
|
||||
/// Pfad unterhalb von Home als "~/…" schreiben — Registry-Einträge im
|
||||
/// Home-Bereich bleiben damit maschinenübergreifend stabil.
|
||||
pub(crate) fn contract_home(paths: &Paths, p: &std::path::Path) -> String {
|
||||
match p.strip_prefix(&paths.home) {
|
||||
Ok(rest) => format!("~/{}", rest.display()),
|
||||
Err(_) => p.display().to_string(),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user