import { homedir } from "node:os";
import { join } from "node:path";

export function configDir(): string {
  return process.env.OVERDECK_CONFIG_DIR || join(homedir(), ".config", "overdeck");
}

export function stateDir(): string {
  return process.env.OVERDECK_STATE_DIR ?? join(homedir(), ".local", "state", "overdeck");
}

export function configFile(): string {
  return join(configDir(), "config.toml");
}

export function tokenFile(): string {
  return join(configDir(), "token");
}

export function deployDir(): string {
  return process.env.OVERDECK_DEPLOY_DIR ?? join(homedir(), ".local", "share", "overdeck", "deploy");
}

export function incidentAssetsDir(): string {
  return join(deployDir(), "modules", "workstation", "claude", "incidents");
}

/** Authorities deployed with harness/incident assets, never the collector worktree. */
export function adapterRegistryFile(): string {
  return join(deployDir(), "modules", "harness", "presets", "adapters.json");
}

export function incidentDispatchCapabilitiesFile(): string {
  return join(incidentAssetsDir(), "dispatch-capabilities.json");
}

export function incidentTaxonomyFile(): string {
  return join(incidentAssetsDir(), "taxonomy.json");
}

export function journalFile(): string {
  return join(stateDir(), "items.jsonl");
}

export function actionsJournalFile(): string {
  return join(stateDir(), "actions.jsonl");
}

export function incidentStatusDbFile(): string {
  return join(stateDir(), "incident-status.sqlite");
}

export function incidentMutationDbFile(): string {
  return join(stateDir(), "incident-mutations.sqlite");
}

export function reportsDir(): string {
  return process.env.OVERDECK_REPORTS_DIR ?? join(homedir(), ".local", "share", "overdeck", "reports");
}

export function liveSessionReportFile(): string {
  return join(reportsDir(), "2026-08-08-session-report.html");
}
