/** * @traqr/core — Configuration Resolver * * Resolves configuration from a 5-level hierarchy (highest priority wins): * 1. Environment variables (TRAQR_*, GUARDIAN_*) * 2. Slot-level overrides (runtime context) * 3. Project config (.traqr/config.json) * 4. Organization config (~/.traqr/config.json) * 5. Built-in defaults * * Used by the daemon at startup and by CLI commands. */ import type { TraqrConfig, DaemonConfig, GuardianConfig } from './config-schema.js'; /** * Registry entry for a Traqr-initialized project. * Stored in ~/.traqr/config.json under the `projects` map. */ export interface ProjectRegistryEntry { /** Absolute path to the project's main repo */ repoPath: string; /** Absolute path to the project's worktrees directory */ worktreesPath: string; /** Display name, e.g. "My App" */ displayName: string; /** 2-char alias prefix for shell aliases, e.g. "nk" */ aliasPrefix: string; /** ISO timestamp of when the project was registered */ registeredAt: string; } /** * Organization-level config stored at ~/.traqr/config.json. * Shared defaults across all projects for one developer/team. */ export interface OrgConfig { /** Default co-author line for commits */ coAuthor?: string; /** Registry of all Traqr-initialized projects, keyed by project slug */ projects?: Record; /** Slug of the primary project (gets generic z1/c1 aliases) */ primaryProject?: string; /** Max concurrent Claude Code sessions across all projects */ maxConcurrentSlots?: number; /** Default memory settings for new projects */ memory?: Partial>; /** Default issue tracker settings */ issues?: Partial>; /** Default notification settings */ notifications?: Partial>; /** Default daemon configuration */ daemon?: Partial; /** Default guardian configuration */ guardian?: Partial; /** Default root directory for new projects (e.g., ~/Projects) */ projectsRoot?: string; /** Absolute path to the traqr platform repo (e.g., ~/Traqr-Enterprises/traqr) */ traqrRepoPath?: string; /** Absolute path to Traqr template directory (packages/core/templates) */ templatesPath?: string; /** Service connection state recorded during /traqr-setup */ services?: Record; /** * Owner's preferred stack — pre-fills alternative selections in /traqr-init. * Category-based: each maps to a config section. Projects inherit by default, * can override individually. */ preferredStack?: { errorTracking: 'sentry' | 'axiom' | 'none'; analytics: 'posthog'; issueTracking: 'linear' | 'github-issues'; email: 'resend' | 'none'; uptime: 'checkly' | 'betterstack' | 'both' | 'none'; observability: 'axiom' | 'none'; edgeCompute: 'cloudflare' | 'none'; auth: 'firebase' | 'supabase' | 'clerk' | 'custom'; database: 'supabase' | 'firestore' | 'd1'; }; } /** * Fully resolved configuration with daemon and guardian guaranteed present. * This is what the daemon and CLI commands consume. */ export interface ResolvedConfig extends TraqrConfig { daemon: DaemonConfig; guardian: GuardianConfig; /** Resolution metadata — tracks where values came from */ _resolution: { orgConfigPath: string | null; projectConfigPath: string | null; envOverrides: string[]; }; } /** * Deep merge source into target, preserving target defaults for missing keys. * Arrays are replaced (not merged). Null/undefined source values are skipped. */ export declare function deepMerge>(target: T, source: Partial): T; /** * Load organization-level config from ~/.traqr/config.json. * Returns null config if file doesn't exist or can't be parsed. */ export declare function loadOrgConfig(): { config: OrgConfig | null; path: string; }; /** * Write organization-level config to ~/.traqr/config.json. * Creates the ~/.traqr/ directory if it doesn't exist. */ export declare function writeOrgConfig(config: OrgConfig): void; /** * Register a project in the org-level registry (~/.traqr/config.json). * Creates the file and directory if they don't exist. * Upserts: if the project slug already exists, it is updated. */ export declare function registerProject(slug: string, entry: ProjectRegistryEntry): void; /** * Get the org-level project registry. */ export declare function getProjectRegistry(): Record; /** * Load project-level config from .traqr/config.json. * Searches from projectRoot (or cwd) upward. */ export declare function loadProjectConfig(projectRoot?: string): { config: TraqrConfig | null; path: string; }; /** * Apply owner's preferredStack to a project config as defaults. * Only fills in sections that aren't already set by the project. */ export declare function mergePreferredStack(config: TraqrConfig, preferredStack: NonNullable): TraqrConfig; /** * VCS detection result from git remote analysis. */ export interface VcsDetection { provider: 'github' | 'gitlab' | 'codecommit' | 'unknown'; remoteUrl: string; orgRepo: string; hostname: string; selfHosted: boolean; protocol: 'ssh' | 'https' | 'unknown'; ciConfigDetected: string | null; } /** * Auto-detect VCS provider from git remote origin URL. * Handles GitHub, GitLab (cloud + self-hosted), and CodeCommit. * Falls back to GitHub detection for backward compatibility. * * https://github.com/org/repo.git → github, org/repo * git@github.com:org/repo.git → github, org/repo * https://gitlab.com/group/project.git → gitlab, group/project * git@gitlab.example.com:group/project.git → gitlab (self-hosted), group/project * https://git-codecommit.us-east-1... → codecommit */ export declare function detectVcsProvider(projectRoot?: string): VcsDetection; /** * Resolve full configuration from all sources. * * Priority (highest wins): * 1. Environment variables * 2. Slot-level overrides (passed at runtime) * 3. Project config (.traqr/config.json) * 4. Organization config (~/.traqr/config.json) * 5. Built-in defaults */ export declare function resolveConfig(options?: { projectRoot?: string; slotOverrides?: { daemon?: Partial; guardian?: Partial; }; }): ResolvedConfig; /** * Print a human-readable summary of resolved config sources. * Useful for daemon startup logging. */ export declare function printConfigSummary(config: ResolvedConfig): string; /** * Detect if the current project is a monorepo with workspace support. * Checks for package.json with `workspaces` field and an `apps/` directory. */ export declare function detectMonorepo(root?: string): { isMonorepo: boolean; existingApps: string[]; existingPackages: string[]; workspacesGlobs: string[]; }; //# sourceMappingURL=config-resolver.d.ts.map