All checks were successful
Monorepo Pipeline / ⚡ Prioritize Release (push) Successful in 3s
Monorepo Pipeline / 🧹 Lint (push) Successful in 1m19s
Monorepo Pipeline / 🧪 Test (push) Successful in 1m5s
Monorepo Pipeline / 🏗️ Build (push) Successful in 1m26s
Monorepo Pipeline / 🚀 Release (push) Has been skipped
Monorepo Pipeline / 🐳 Build Image Processor (push) Has been skipped
Monorepo Pipeline / 🐳 Build Directus (Base) (push) Has been skipped
Monorepo Pipeline / 🐳 Build Gatekeeper (Product) (push) Has been skipped
Monorepo Pipeline / 🐳 Build Build-Base (push) Has been skipped
Monorepo Pipeline / 🐳 Build Production Runtime (push) Has been skipped
82 lines
2.6 KiB
JavaScript
82 lines
2.6 KiB
JavaScript
#!/usr/bin/env node
|
|
// ============================================================================
|
|
// @mintel/estimation-engine — CLI Entry Point
|
|
// ============================================================================
|
|
|
|
import { Command } from "commander";
|
|
import * as path from "node:path";
|
|
import * as fs from "node:fs/promises";
|
|
import { existsSync } from "node:fs";
|
|
import { config as dotenvConfig } from "dotenv";
|
|
import { EstimationPipeline } from "./pipeline.js";
|
|
import type { ProjectConcept } from "@mintel/concept-engine";
|
|
|
|
// Load .env from monorepo root
|
|
dotenvConfig({ path: path.resolve(process.cwd(), "../../.env") });
|
|
dotenvConfig({ path: path.resolve(process.cwd(), ".env") });
|
|
|
|
const program = new Command();
|
|
|
|
program
|
|
.name("estimate")
|
|
.description("AI-powered project estimation engine")
|
|
.version("1.0.0");
|
|
|
|
program
|
|
.command("run")
|
|
.description("Run the financial estimation pipeline from a concept file")
|
|
.argument("<concept-file>", "Path to the ProjectConcept JSON file")
|
|
.option("--budget <budget>", "Budget constraint (e.g. '15.000 €')")
|
|
.option("--output <dir>", "Output directory", "../../out/estimations")
|
|
.action(async (conceptFile: string, options: any) => {
|
|
const openrouterKey =
|
|
process.env.OPENROUTER_API_KEY || process.env.OPENROUTER_KEY;
|
|
if (!openrouterKey) {
|
|
console.error("❌ OPENROUTER_API_KEY not found in environment.");
|
|
process.exit(1);
|
|
}
|
|
|
|
const filePath = path.resolve(process.cwd(), conceptFile);
|
|
if (!existsSync(filePath)) {
|
|
console.error(`❌ Concept file not found: ${filePath}`);
|
|
process.exit(1);
|
|
}
|
|
|
|
console.log(`📄 Loading concept from: ${filePath}`);
|
|
const rawConcept = await fs.readFile(filePath, "utf8");
|
|
const concept = JSON.parse(rawConcept) as ProjectConcept;
|
|
|
|
const pipeline = new EstimationPipeline(
|
|
{
|
|
openrouterKey,
|
|
outputDir: path.resolve(process.cwd(), options.output),
|
|
crawlDir: "", // No longer needed here
|
|
},
|
|
{
|
|
onStepStart: (_id, _name) => {},
|
|
onStepComplete: (_id, _result) => {},
|
|
},
|
|
);
|
|
|
|
try {
|
|
const result = await pipeline.run({
|
|
concept,
|
|
budget: options.budget,
|
|
});
|
|
|
|
console.log("\n✨ Estimation complete!");
|
|
|
|
if (result.validationResult && !result.validationResult.passed) {
|
|
console.log(
|
|
`\n⚠️ ${result.validationResult.errors.length} validation issues found.`,
|
|
);
|
|
console.log(" Review the output JSON and re-run problematic steps.");
|
|
}
|
|
} catch (err) {
|
|
console.error(`\n❌ Pipeline failed: ${(err as Error).message}`);
|
|
process.exit(1);
|
|
}
|
|
});
|
|
|
|
program.parse();
|