/** * ADRFlow Service Layer * * Contains all business logic for ADR operations. * This is the primary interface for working with ADRs. * * @module adrflow/core/service */ import type { ADR, ADRId, ADRStats, CreateADRInput, SearchOptions, SearchResult, TimelineOptions, UpdateADRInput } from './types.js'; import type { ADRStore } from '../storage/store.js'; /** * Service configuration options */ export interface ServiceConfig { /** Default source type for new ADRs */ readonly defaultSourceType?: 'claude_session' | 'cursor_session' | 'manual' | 'imported'; /** Default source ID (e.g., session identifier) */ readonly defaultSourceId?: string; } /** * Result of an ask operation */ export interface AskResult { /** The answer to the question */ readonly answer: string; /** ADRs that were relevant to answering the question */ readonly relevantADRs: readonly ADR[]; /** Confidence level of the answer */ readonly confidence: 'high' | 'medium' | 'low'; } /** * ADR Service * * Provides high-level operations for working with ADRs. * Handles validation, business rules, and coordinates with storage. */ export declare class ADRService { private readonly store; private readonly config; constructor(store: ADRStore, config?: ServiceConfig); /** * Initializes the service * Must be called before any other operations */ initialize(): Promise; /** * Shuts down the service * Should be called when done */ shutdown(): Promise; /** * Creates a new ADR * * @param input - The ADR creation input * @returns The created ADR * @throws ADRError if validation fails or supersedes creates a cycle */ create(input: CreateADRInput): Promise; /** * Gets an ADR by ID * * @param id - The ADR ID * @returns The ADR or undefined if not found */ get(id: ADRId): Promise; /** * Gets an ADR by ID, throwing if not found * * @param id - The ADR ID * @returns The ADR * @throws ADRError if not found */ getRequired(id: ADRId): Promise; /** * Updates an existing ADR * * @param input - The update input * @returns The updated ADR * @throws ADRError if not found or validation fails */ update(input: UpdateADRInput): Promise; /** * Accepts a proposed ADR * * @param id - The ADR ID * @returns The updated ADR * @throws ADRError if not found or already accepted */ accept(id: ADRId): Promise; /** * Deprecates an ADR * * @param id - The ADR ID * @returns The updated ADR * @throws ADRError if not found */ deprecate(id: ADRId): Promise; /** * Creates a new ADR that supersedes an existing one * * @param existingId - The ID of the ADR to supersede * @param input - The new ADR input * @returns The new ADR */ supersede(existingId: ADRId, input: Omit): Promise; /** * Deletes an ADR * * @param id - The ADR ID * @returns true if deleted * @throws ADRError if not found */ delete(id: ADRId): Promise; /** * Lists ADRs with optional filtering * * @param options - Search/filter options * @returns Search result with matching ADRs */ list(options?: SearchOptions): Promise; /** * Searches ADRs by text query * * @param query - The search query * @param options - Search/filter options * @returns Search result with matching ADRs */ search(query: string, options?: SearchOptions): Promise; /** * Gets ADRs in chronological order * * @param options - Timeline options * @returns ADRs in chronological order */ timeline(options?: TimelineOptions): Promise; /** * Answers a question using the ADR knowledge base * * This is a simplified implementation that finds relevant ADRs. * In production, this would integrate with an LLM for natural language answers. * * @param question - The question to answer * @returns The answer with relevant ADRs */ ask(question: string): Promise; /** * Gets statistics about the ADR collection */ getStats(): Promise; /** * Compacts the storage to reclaim space */ compact(): Promise; /** * Gets all ADRs related to a specific file path * * @param filePath - The file path to search for * @returns ADRs that reference the file */ getByFile(filePath: string): Promise; /** * Gets the supersession chain for an ADR * * @param id - The ADR ID * @returns Array of ADRs in the supersession chain */ getSupersessionChain(id: ADRId): Promise; /** * Builds a natural language answer from an ADR */ private buildAnswer; } /** * Creates a new ADR service */ export declare function createService(store: ADRStore, config?: ServiceConfig): ADRService; //# sourceMappingURL=service.d.ts.map