@autobe/agent
Version:
AI backend server code generator
98 lines • 4.3 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.assembleModule = exports.assembleContent = void 0;
// ============================================
// Content Assembly
// ============================================
/** Assemble all sections into final markdown content */
const assembleContent = (moduleEvent, unitEvents, sectionResults) => {
const lines = [];
// Document title and summary
lines.push(`**${moduleEvent.title}**`);
lines.push("");
lines.push(moduleEvent.summary);
lines.push("");
// For each module section
for (let moduleIndex = 0; moduleIndex < moduleEvent.moduleSections.length; moduleIndex++) {
const moduleSection = moduleEvent.moduleSections[moduleIndex];
const unitEvent = unitEvents[moduleIndex];
const sectionEventsForModule = sectionResults[moduleIndex];
// Module header
lines.push(`# ${moduleSection.title}`);
lines.push("");
if (moduleSection.content) {
lines.push(moduleSection.content);
lines.push("");
}
// For each unit section
if (unitEvent) {
for (let unitIndex = 0; unitIndex < unitEvent.unitSections.length; unitIndex++) {
const unitSection = unitEvent.unitSections[unitIndex];
const sectionEvent = sectionEventsForModule === null || sectionEventsForModule === void 0 ? void 0 : sectionEventsForModule[unitIndex];
// Unit section header
lines.push(`## ${unitSection.title}`);
lines.push("");
if (unitSection.content) {
lines.push(unitSection.content);
lines.push("");
}
// For each section section
if (sectionEvent) {
for (const sectionSection of sectionEvent.sectionSections) {
lines.push(`### ${sectionSection.title}`);
lines.push("");
lines.push(sectionSection.content);
lines.push("");
}
}
}
}
}
return lines.join("\n").trim();
};
exports.assembleContent = assembleContent;
/**
* Assemble structured module data from events.
*
* This method builds the hierarchical AutoBeAnalyze.IModule structure from the
* module, unit, and section events, preserving the three-level hierarchy that
* would otherwise be lost when assembling into flat markdown.
*/
const assembleModule = (moduleEvent, unitEvents, sectionResults) => {
var _a;
const firstModuleSection = moduleEvent.moduleSections[0];
if (!firstModuleSection) {
return { title: "", purpose: "", content: "", units: [] };
}
// Collect all units across all module sections into a single module
const allUnits = [];
for (let moduleIndex = 0; moduleIndex < moduleEvent.moduleSections.length; moduleIndex++) {
const unitEvent = unitEvents[moduleIndex];
const sectionEventsForModule = sectionResults[moduleIndex];
if (unitEvent) {
for (let unitIndex = 0; unitIndex < unitEvent.unitSections.length; unitIndex++) {
const unitSection = unitEvent.unitSections[unitIndex];
const sectionEvent = sectionEventsForModule === null || sectionEventsForModule === void 0 ? void 0 : sectionEventsForModule[unitIndex];
const sections = (_a = sectionEvent === null || sectionEvent === void 0 ? void 0 : sectionEvent.sectionSections.map((s) => ({
title: s.title,
content: s.content,
}))) !== null && _a !== void 0 ? _a : [];
allUnits.push({
title: unitSection.title,
purpose: unitSection.purpose,
content: unitSection.content,
keywords: unitSection.keywords,
sections,
});
}
}
}
return {
title: firstModuleSection.title,
purpose: firstModuleSection.purpose,
content: firstModuleSection.content,
units: allUnits,
};
};
exports.assembleModule = assembleModule;
//# sourceMappingURL=AutoBeAnalyzeProgrammer.js.map