ruben de la fuente
feat: initial deployment to HuggingFace Spaces
0e13326
import { BenchmarkData, MetricsInput, TeamContext } from './types'
export function buildSystemPrompt(benchmarks: BenchmarkData): string {
return `You are a DevOps performance advisor with deep knowledge of engineering delivery research.
## Benchmark reference
${JSON.stringify(benchmarks, null, 2)}
## Your task
Given a team's metrics and context, produce a JSON interpretation report.
Be specific, not generic. Explain the reasoning behind each insight.
Reference benchmark bands explicitly (e.g. "your lead time is in the Medium band").
Keep improvement actions practical and sequenced by impact.
## Output format
Return ONLY valid JSON matching this exact schema:
{
"deliveryProfile": "2-3 sentence description of the team's overall delivery profile",
"benchmarkAlignment": [
{
"metric": "Deployment Frequency",
"yourValue": "human-readable value",
"typicalRange": "the benchmark range for their band",
"band": "elite|high|medium|low"
}
],
"likelyBottlenecks": ["specific bottleneck description"],
"improvements": [
{
"priority": 1,
"action": "specific action",
"rationale": "why this action, linked to their metrics"
}
],
"leadershipSummary": {
"deliverySpeed": "strong|moderate|weak",
"reliability": "strong|moderate|weak",
"focusArea": "one sentence focus area for leadership"
}
}
Include benchmarkAlignment entries for: Deployment Frequency, Lead Time, Change Failure Rate, MTTR.
Provide 3-5 improvements, ordered by priority (1 = highest).
Do not include any text outside the JSON object.`
}
export function formatMetricsMessage(metrics: MetricsInput, context: TeamContext): string {
const freqLabels: Record<MetricsInput['deploymentFrequency'], string> = {
multiple_per_day: 'Multiple times per day',
daily: 'Once per day',
weekly: 'Once per week',
monthly: 'Once per month',
less_than_monthly: 'Less than once per month',
}
return `## Team Metrics
- Deployment Frequency: ${freqLabels[metrics.deploymentFrequency]}
- Lead Time for Changes: ${metrics.leadTimeDays} days
- Change Failure Rate: ${metrics.changeFailureRate}%
- Mean Time to Restore: ${metrics.mttrHours} hours
- Pipeline Duration: ${metrics.pipelineDurationMinutes} minutes
- PR Review Time: ${metrics.prReviewTimeHours} hours
- Team Size: ${metrics.engineerCount} engineers
- Service Count: ${metrics.serviceCount} services
## Team Context
- Architecture: ${context.architecture}
- Release Strategy: ${context.releaseStrategy}
- Compliance Constraints: ${context.hasComplianceConstraints ? 'Yes' : 'No'}`
}