UNPKG

@autobe/agent

Version:

AI backend server code generator

75 lines (74 loc) 2.58 kB
import { AutoBeAnalyze, AutoBeAnalyzeWriteSectionEvent } from "@autobe/interface"; /** * A single canonical error code entry extracted from a YAML spec block in * 04-business-rules. */ export interface IErrorCodeRegistryEntry { /** Error code, e.g. "TODO_NOT_FOUND" */ code: string; /** HTTP status code, e.g. 404 */ http: number; /** Condition description */ condition: string; } /** * A reference to an error code found via backtick pattern in non-canonical * files. */ export interface IErrorCodeReference { code: string; fileIndex: number; sectionTitle: string; } /** Result of comparing canonical error code definitions to backtick references. */ export interface IErrorCodeValidationResult { /** All canonical error codes from 04-business-rules YAML blocks */ canonical: IErrorCodeRegistryEntry[]; /** All backtick error code references in other files */ references: IErrorCodeReference[]; /** References that don't match any canonical definition */ undefinedReferences: IErrorCodeReference[]; /** YAML parse errors */ parseErrors: Array<{ fileIndex: number; sectionTitle: string; error: string; }>; } export interface IErrorCodeConflict { /** Normalized condition key */ conditionKey: string; /** Different error codes for the same condition */ codes: Array<{ errorCode: string; httpStatus: number; files: string[]; }>; } /** * Validate error code references across files using YAML canonical definitions. * * 1. Extracts canonical error codes from 04-business-rules YAML blocks * 2. Extracts backtick `ERROR_CODE` references from 03-functional-requirements * 3. Reports undefined references */ export declare const validateErrorCodes: (props: { files: Array<{ file: AutoBeAnalyze.IFileScenario; sectionEvents: AutoBeAnalyzeWriteSectionEvent[][]; }>; }) => IErrorCodeValidationResult; /** * Detect error code conflicts across files. * * Now operates on YAML-extracted data. A conflict occurs when the same error * code appears with different HTTP statuses across YAML blocks. */ export declare const detectErrorCodeConflicts: (props: { files: Array<{ file: AutoBeAnalyze.IFileScenario; sectionEvents: AutoBeAnalyzeWriteSectionEvent[][]; }>; }) => IErrorCodeConflict[]; /** Build a map from filename → list of error code conflict feedback strings. */ export declare const buildFileErrorCodeConflictMap: (conflicts: IErrorCodeConflict[]) => Map<string, string[]>;