use serde::Serialize;
pub const DEFAULT_SHOW_DATA_DIR_DEPTH: usize = 4;
pub const DEFAULT_HISTORY_LIMIT: usize = 50;
pub const DEFAULT_FILTER_RUNS: usize = 20;
#[derive(Debug, Clone, Serialize)]
pub struct DeploymentDisplayEntry {
pub pack: String,
pub handler: String,
pub kind: String,
pub source: String,
pub datastore: String,
}
#[derive(Debug, Clone, Serialize)]
pub struct TreeLine {
pub prefix: String,
pub name: String,
pub annotation: String,
}
#[derive(Debug, Clone, Serialize)]
#[serde(tag = "kind", rename_all = "kebab-case")]
pub enum ProbeResult {
Summary {
data_dir: String,
available: Vec<ProbeSubcommandInfo>,
},
DeploymentMap {
data_dir: String,
map_path: String,
entries: Vec<DeploymentDisplayEntry>,
},
ShowDataDir {
data_dir: String,
lines: Vec<TreeLine>,
total_nodes: usize,
total_size: u64,
},
ShellInit(ShellInitView),
ShellInitAggregate(ShellInitAggregateView),
ShellInitHistory(ShellInitHistoryView),
ShellInitFilter(ShellInitFilterView),
ShellInitErrors(ShellInitErrorsView),
App(AppProbeView),
}
#[derive(Debug, Clone, Serialize)]
pub struct AppProbeView {
pub pack: String,
pub macos: bool,
pub entries: Vec<AppProbeEntry>,
pub suggested_adoptions: Vec<String>,
}
#[derive(Debug, Clone, Serialize)]
pub struct AppProbeEntry {
pub folder: String,
pub target_path: String,
pub target_exists: bool,
pub source_rule: String,
pub cask: Option<String>,
pub app_bundle: Option<String>,
pub bundle_id: Option<String>,
}
#[derive(Debug, Clone, Serialize)]
pub struct ShellInitAggregateView {
pub runs: usize,
pub requested_runs: usize,
pub profiling_enabled: bool,
pub profiles_dir: String,
pub rows: Vec<ShellInitAggregateRow>,
pub stale: bool,
pub latest_profile_when: String,
pub last_up_when: String,
}
#[derive(Debug, Clone, Serialize)]
pub struct ShellInitAggregateRow {
pub pack: String,
pub handler: String,
pub target: String,
pub p50_label: String,
pub p95_label: String,
pub max_label: String,
pub p50_us: u64,
pub p95_us: u64,
pub max_us: u64,
pub seen_label: String,
pub runs_seen: usize,
pub runs_total: usize,
}
#[derive(Debug, Clone, Serialize)]
pub struct ShellInitHistoryView {
pub profiling_enabled: bool,
pub profiles_dir: String,
pub rows: Vec<ShellInitHistoryRow>,
pub stale: bool,
pub latest_profile_when: String,
pub last_up_when: String,
}
#[derive(Debug, Clone, Serialize)]
pub struct ShellInitHistoryRow {
pub filename: String,
pub unix_ts: u64,
pub when: String,
pub shell: String,
pub total_label: String,
pub user_total_label: String,
pub total_us: u64,
pub user_total_us: u64,
pub failed_entries: usize,
pub entry_count: usize,
}
#[derive(Debug, Clone, Serialize)]
pub struct ShellInitView {
pub filename: String,
pub shell: String,
pub profiling_enabled: bool,
pub has_profile: bool,
pub groups: Vec<ShellInitGroup>,
pub user_total_us: u64,
pub framing_us: u64,
pub total_us: u64,
pub profiles_dir: String,
pub stale: bool,
pub profile_when: String,
pub last_up_when: String,
}
#[derive(Debug, Clone, Serialize)]
pub struct ShellInitRow {
pub target: String,
pub duration_us: u64,
pub duration_label: String,
pub exit_status: i32,
pub status_class: &'static str,
}
#[derive(Debug, Clone, Serialize)]
pub struct ShellInitGroup {
pub pack: String,
pub handler: String,
pub rows: Vec<ShellInitRow>,
pub group_total_us: u64,
pub group_total_label: String,
}
#[derive(Debug, Clone, Serialize)]
pub struct ShellInitFilterView {
pub profiling_enabled: bool,
pub profiles_dir: String,
pub filter: String,
pub filter_pack: String,
pub filter_filename: Option<String>,
pub runs_examined: usize,
pub targets: Vec<ShellInitFilterTarget>,
pub stale: bool,
pub latest_profile_when: String,
pub last_up_when: String,
}
#[derive(Debug, Clone, Serialize)]
pub struct ShellInitFilterTarget {
pub target: String,
pub display_target: String,
pub pack: String,
pub handler: String,
pub runs: Vec<ShellInitFilterRun>,
pub failure_count: usize,
}
#[derive(Debug, Clone, Serialize)]
pub struct ShellInitErrorsView {
pub profiling_enabled: bool,
pub profiles_dir: String,
pub runs_examined: usize,
pub targets: Vec<ShellInitFilterTarget>,
pub stale: bool,
pub latest_profile_when: String,
pub last_up_when: String,
}
#[derive(Debug, Clone, Serialize)]
pub struct ShellInitFilterRun {
pub when: String,
pub duration_label: String,
pub duration_us: u64,
pub exit_status: i32,
pub status_class: &'static str,
pub stderr_lines: Vec<String>,
pub profile_filename: String,
}
#[derive(Debug, Clone, Serialize)]
pub struct ProbeSubcommandInfo {
pub name: &'static str,
pub description: &'static str,
}
pub const PROBE_SUBCOMMANDS: &[ProbeSubcommandInfo] = &[
ProbeSubcommandInfo {
name: "deployment-map",
description: "Source↔deployed map — what dodot linked where.",
},
ProbeSubcommandInfo {
name: "shell-init",
description: "Per-source timings for the most recent shell startup.",
},
ProbeSubcommandInfo {
name: "show-data-dir",
description: "Tree of dodot's data directory, with sizes.",
},
];