// tools/create-spec/adapters/prior-decisions-hint.ts — SPEC-615
// Best-effort adapter: searches logged decisions for keyword overlap with the
// new spec and returns formatted prior-decision links (AC1/AC2/AC4).
import { getDecisions } from '../../../storage/decision-store.js';
import { searchPriorDecisions } from '../../../engine/prior-decisions/index.js';
/**
 * Find prior decisions relevant to the new spec (AC1/AC2).
 *
 * Returns an empty array when:
 * - No decisions have been logged (AC4 — omit when empty)
 * - Any storage or search error occurs (best-effort, never blocks)
 *
 * @param projectId   - hashed project identifier
 * @param description - spec description + title (combined query text)
 * @param tags        - spec tags appended to the query for richer overlap
 */
export async function runPriorDecisionsHint(projectId, description, tags) {
    try {
        const decisions = await getDecisions(projectId);
        if (decisions.length === 0) {
            return [];
        }
        const query = tags.length > 0 ? `${description} ${tags.join(' ')}` : description;
        return searchPriorDecisions(query, decisions);
    }
    catch {
        return [];
    }
}
//# sourceMappingURL=prior-decisions-hint.js.map