2 Commits

Author SHA1 Message Date
8907963d57 fix(cli): use absolute paths for logos and generate 6 distinct PDFs
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 5s
Build & Deploy / 🧪 QA (push) Failing after 12s
Build & Deploy / 🏗️ Build (push) Failing after 14s
Build & Deploy / 🚀 Deploy (push) Has been skipped
Build & Deploy / 🩺 Health Check (push) Has been skipped
Build & Deploy / 🔔 Notify (push) Successful in 2s
2026-02-27 18:25:15 +01:00
844a5f5412 feat: ai estimation 2026-02-27 15:17:28 +01:00

View File

@@ -18,10 +18,13 @@ try {
if (existsSync(atMintelEnv)) {
dotenvConfig({ path: atMintelEnv });
}
} catch { /* @mintel/concept-engine not resolvable — skip */ }
} catch {
/* @mintel/concept-engine not resolvable — skip */
}
async function main() {
const OPENROUTER_KEY = process.env.OPENROUTER_API_KEY || process.env.OPENROUTER_KEY;
const OPENROUTER_KEY =
process.env.OPENROUTER_API_KEY || process.env.OPENROUTER_KEY;
if (!OPENROUTER_KEY) {
console.error("❌ Error: OPENROUTER_API_KEY not found in environment.");
process.exit(1);
@@ -30,7 +33,9 @@ async function main() {
const args = process.argv.slice(2);
const briefingArg = args[0];
if (!briefingArg) {
console.error("❌ Error: Provide a briefing file or text as the first argument.");
console.error(
"❌ Error: Provide a briefing file or text as the first argument.",
);
process.exit(1);
}
@@ -66,18 +71,25 @@ async function main() {
}
const monorepoRoot = path.resolve(process.cwd(), "../../");
const crawlDir = path.join(path.resolve(monorepoRoot, "../at-mintel"), "data/crawls");
const crawlDir = path.join(
path.resolve(monorepoRoot, "../at-mintel"),
"data/crawls",
);
const outputDir = path.join(monorepoRoot, "out");
const konzeptDir = path.join(outputDir, "konzept");
const schaetzungDir = path.join(outputDir, "schaetzung");
const agbDir = path.join(outputDir, "agb");
const infoDir = path.join(outputDir, "info");
const deckblattDir = path.join(outputDir, "deckblatt");
const abschlussDir = path.join(outputDir, "abschluss");
await fs.mkdir(outputDir, { recursive: true });
await fs.mkdir(konzeptDir, { recursive: true });
await fs.mkdir(schaetzungDir, { recursive: true });
await fs.mkdir(agbDir, { recursive: true });
await fs.mkdir(infoDir, { recursive: true });
await fs.mkdir(deckblattDir, { recursive: true });
await fs.mkdir(abschlussDir, { recursive: true });
const conceptPipeline = new ConceptPipeline({
openrouterKey: OPENROUTER_KEY,
@@ -88,6 +100,15 @@ async function main() {
const engine = new PdfEngine();
const headerIcon = path.join(
monorepoRoot,
"apps/web/src/assets/logo/Icon-Black-Transparent.png",
);
const footerLogo = path.join(
monorepoRoot,
"apps/web/src/assets/logo/Logo-Black-Transparent.png",
);
try {
const conceptResult = await conceptPipeline.run({
briefing,
@@ -100,8 +121,14 @@ async function main() {
const timestamp = new Date().toISOString().replace(/[:.]/g, "-");
console.log("\n📄 Generating Concept PDF...");
const conceptPdfPath = path.join(konzeptDir, `${companyName}_Konzept_${timestamp}.pdf`);
await engine.generateConceptPdf(conceptResult, conceptPdfPath);
const conceptPdfPath = path.join(
konzeptDir,
`${companyName}_Konzept_${timestamp}.pdf`,
);
await engine.generateConceptPdf(conceptResult, conceptPdfPath, {
headerIcon,
footerLogo,
});
console.log(`✅ Created Concept PDF at: ${conceptPdfPath}`);
console.log("\n==================================================");
@@ -121,24 +148,59 @@ async function main() {
if (estimationResult.formState) {
console.log("\n📄 Generating Estimation PDF...");
const estimationPdfPath = path.join(schaetzungDir, `${companyName}_Angebot_${timestamp}.pdf`);
await engine.generateEstimatePdf(estimationResult.formState, estimationPdfPath);
const estimationPdfPath = path.join(
schaetzungDir,
`${companyName}_Angebot_${timestamp}.pdf`,
);
await engine.generateEstimatePdf(
estimationResult.formState,
estimationPdfPath,
{ headerIcon, footerLogo },
);
console.log(`✅ Created Angebot PDF at: ${estimationPdfPath}`);
console.log("\n📄 Generating AGBs PDF...");
const agbPdfPath = path.join(agbDir, `${companyName}_AGBs_${timestamp}.pdf`);
await engine.generateAgbsPdf(agbPdfPath, {});
const agbPdfPath = path.join(
agbDir,
`${companyName}_AGBs_${timestamp}.pdf`,
);
await engine.generateAgbsPdf(agbPdfPath, { headerIcon, footerLogo });
console.log(`✅ Created AGBs PDF at: ${agbPdfPath}`);
console.log("\n📄 Generating Deckblatt PDF...");
const deckblattPdfPath = path.join(
deckblattDir,
`${companyName}_Deckblatt_${timestamp}.pdf`,
);
await engine.generateFrontPagePdf(
estimationResult.formState,
deckblattPdfPath,
{ headerIcon },
);
console.log(`✅ Created Deckblatt PDF at: ${deckblattPdfPath}`);
console.log("\n📄 Generating Abschluss PDF...");
const abschlussPdfPath = path.join(
abschlussDir,
`${companyName}_Abschluss_${timestamp}.pdf`,
);
await engine.generateClosingPdf(abschlussPdfPath, {
headerIcon,
footerLogo,
});
console.log(`✅ Created Abschluss PDF at: ${abschlussPdfPath}`);
} else {
console.log("\n⚠ No formState generated, skipping Estimation PDF.");
}
// Generate Info PDF
console.log("\n📄 Generating Arbeitsweise PDF...");
const infoPdfPath = path.join(infoDir, `${companyName}_Arbeitsweise_${timestamp}.pdf`);
await engine.generateInfoPdf(infoPdfPath, {});
const infoPdfPath = path.join(
infoDir,
`${companyName}_Arbeitsweise_${timestamp}.pdf`,
);
await engine.generateInfoPdf(infoPdfPath, { headerIcon, footerLogo });
console.log(`✅ Created Arbeitsweise PDF at: ${infoPdfPath}`);
} catch (e) {
console.error(`\n❌ Pipeline failed: ${(e as Error).message}`);
process.exit(1);