@autobe/agent
Version:
AI backend server code generator
93 lines (92 loc) • 4.2 kB
TypeScript
import { AutoBeAnalyze } from "@autobe/interface";
/**
* Fixed 6-category SRS document structure template.
*
* Defines the authoritative structure for all analysis documents. LLM is no
* longer responsible for deciding file count, file names, or module/unit
* layout. Instead, it focuses solely on content generation within this fixed
* skeleton.
*
* Hierarchy: Category (file) -> Module (#) -> Unit (##) -> Section (###)
*
* @author Juntak
*/
export type FixedAnalyzeTemplateCategoryId = "00-toc" | "01-actors-and-auth" | "02-domain-model" | "03-functional-requirements" | "04-business-rules" | "05-non-functional";
export interface FixedAnalyzeTemplateFileTemplate {
categoryId: FixedAnalyzeTemplateCategoryId;
/** Currently equals categoryId; reserved for future per-category splits. */
fileId: string;
filename: `${string}.md`;
documentType: string;
description: string;
downstreamPhase: string;
modules: FixedAnalyzeTemplateModuleTemplate[];
/** Regex patterns that must NOT appear in this file's sections. */
forbiddenPatterns: RegExp[];
}
export interface FixedAnalyzeTemplateModuleTemplate {
index: number;
title: string;
purpose: string;
unitStrategy: FixedAnalyzeTemplateUnitStrategy;
}
export type FixedAnalyzeTemplateUnitStrategy = FixedAnalyzeTemplateFixedUnits | FixedAnalyzeTemplatePerEntityUnits | FixedAnalyzeTemplatePerActorUnits | FixedAnalyzeTemplatePerEntityGroupUnits;
export interface FixedAnalyzeTemplateFixedUnits {
type: "fixed";
units: FixedAnalyzeTemplateUnitTemplate[];
}
export interface FixedAnalyzeTemplatePerEntityUnits {
type: "perEntity";
unitTemplate: FixedAnalyzeTemplateUnitTemplate;
}
export interface FixedAnalyzeTemplatePerActorUnits {
type: "perActor";
unitTemplate: FixedAnalyzeTemplateUnitTemplate;
}
export interface FixedAnalyzeTemplatePerEntityGroupUnits {
type: "perEntityGroup";
unitTemplate: FixedAnalyzeTemplateUnitTemplate;
}
export interface FixedAnalyzeTemplateUnitTemplate {
titlePattern: string;
purposePattern: string;
keywords: string[];
}
export type FixedAnalyzeTemplateFeatureId = "real-time" | "external-integration" | "file-storage";
export interface FixedAnalyzeTemplateFeature {
id: FixedAnalyzeTemplateFeatureId;
/** Provider names for external-integration (e.g., ["stripe", "sendgrid"]) */
providers?: string[];
}
export declare const FIXED_ANALYZE_TEMPLATE_CANONICAL_SOURCE: Record<string, FixedAnalyzeTemplateCategoryId>;
export declare const FIXED_ANALYZE_TEMPLATE: FixedAnalyzeTemplateFileTemplate[];
export declare const FIXED_ANALYZE_TEMPLATE_CONDITIONAL_MODULES: Record<FixedAnalyzeTemplateFeatureId, Array<{
targetCategory: FixedAnalyzeTemplateCategoryId;
module: FixedAnalyzeTemplateModuleTemplate;
}>>;
/**
* Expand a module's unit strategy into concrete unit templates based on the
* domain's entities and actors.
*/
export declare const expandFixedAnalyzeTemplateUnits: (module: FixedAnalyzeTemplateModuleTemplate, entities: Array<{
name: string;
}>, actors: Array<{
name: string;
}>) => FixedAnalyzeTemplateUnitTemplate[];
/**
* Build an expanded template by merging base TEMPLATE with conditional modules
* activated by the given features.
*
* Module indices are renumbered sequentially per file after merging.
*/
export declare const buildFixedAnalyzeExpandedTemplate: (features: FixedAnalyzeTemplateFeature[]) => FixedAnalyzeTemplateFileTemplate[];
/**
* Generate AutoBeAnalyze.IFile.Scenario objects from the fixed template,
* optionally expanded with conditional modules based on features. Called after
* LLM returns actors/entities/features in the scenario phase.
*/
export declare const buildFixedAnalyzeScenarioFiles: (_prefix: string, features?: FixedAnalyzeTemplateFeature[]) => AutoBeAnalyze.IFileScenario[];
/** Deterministically generate the Document Map unit content for 00-toc. */
export declare const buildFixedAnalyzeDocumentMapContent: (files: FixedAnalyzeTemplateFileTemplate[]) => string;
/** Deterministically generate the Canonical Source Declaration unit content. */
export declare const buildFixedAnalyzeCanonicalSourceContent: () => string;