/** * Config Loader * * Loads and merges configuration from multiple sources with the following priority: * 1. Environment variables (highest) * 2. Project config (.specforge.json) * 3. Global config (~/.specforge/config.json) * 4. Default values (lowest) */ import { GlobalConfig, ResolvedConfig } from './types.js'; import type { SpecforgeJsonConfig, ActiveSpecification, MonorepoConfig, AgentTeamsConfig } from './agent-teams.types.js'; /** * AgentTeamsConfig with all defaults applied (all fields required). */ export type ResolvedAgentTeamsConfig = Required> & { validationCommands?: AgentTeamsConfig['validationCommands']; }; /** * Load global configuration from ~/.specforge/config.json * * @returns GlobalConfig object (empty object if file doesn't exist or is invalid) * * @example * ```typescript * const globalConfig = loadGlobalConfig(); * if (globalConfig.apiKey) { * console.log('API key found in global config'); * } * ``` */ export declare function loadGlobalConfig(): GlobalConfig; /** * Load project configuration from .specforge.json * * Searches current directory and parent directories for .specforge.json. * * @returns ProjectConfig object if found, null otherwise * * @example * ```typescript * const projectConfig = loadProjectConfig(); * if (projectConfig?.projectId) { * console.log('Project ID:', projectConfig.projectId); * } * ``` */ export declare function loadProjectConfig(): SpecforgeJsonConfig | null; /** * Resolve final configuration from all sources * * Merges configuration with the following priority (highest to lowest): * 1. Environment variables * 2. Project config (.specforge.json) * 3. Global config (~/.specforge/config.json) * 4. Default values * * @returns ResolvedConfig with all values and source tracking * * @example * ```typescript * const config = resolveConfig(); * console.log('API Key from:', config.sources.apiKey); // 'env' | 'global' | null * console.log('Format:', config.format); // 'json' | 'toon' * ``` */ export declare function resolveConfig(): ResolvedConfig; /** * Check if user is authenticated (has API key configured) * * @returns true if API key is available from any source * * @example * ```typescript * if (!isAuthenticated()) { * console.error('Please run: specforge login'); * process.exit(1); * } * ``` */ export declare function isAuthenticated(): boolean; /** * Get API key if available * * @returns API key string or null if not configured */ export declare function getApiKey(): string | null; /** * Check if running in a project context * * @returns true if a .specforge.json was found */ export declare function hasProjectContext(): boolean; /** * Get current project ID if available * * @returns Project ID or null */ export declare function getProjectId(): string | null; /** * Get current specification ID if available * * @returns Specification ID or null */ export declare function getSpecificationId(): string | null; /** * Get Agent Teams config with defaults merged. * * Always returns a fully-resolved config object — never null. * Partial configs are merged with defaults via spread operator. * * @param config - Parsed project config (or null for all defaults) * @returns Resolved Agent Teams config with all defaults applied */ export declare function getAgentTeamsConfig(config: SpecforgeJsonConfig | null): ResolvedAgentTeamsConfig; /** * Get the active specification from config. * * @param config - Parsed project config * @returns ActiveSpecification if set, null otherwise */ export declare function getActiveSpecification(config: SpecforgeJsonConfig | null): ActiveSpecification | null; /** * Get monorepo config with defaults merged. * * Returns null if the monorepo section is not present at all. * If present (even partially), merges with defaults. * * @param config - Parsed project config * @returns MonorepoConfig with defaults applied, or null if section absent */ export declare function getMonorepoConfig(config: SpecforgeJsonConfig | null): MonorepoConfig | null; //# sourceMappingURL=loader.d.ts.map