var s=Object.defineProperty;var c=(t)=>t;function l(t,r){this[t]=c.bind(null,r)}var d=(t,r)=>{for(var i in r)s(t,i,{get:r[i],enumerable:!0,configurable:!0,set:l.bind(r,i)})};var g=(t,r)=>()=>(t&&(r=t(t=0)),r);import{CodeBlock as a,InstallCommand as p}from"@contractspec/lib.design-system";import n from"@contractspec/lib.ui-link";import{ChevronRight as m}from"lucide-react";import{jsx as e,jsxs as o}from"react/jsx-runtime";function f(){return o("div",{className:"space-y-8",children:[o("div",{className:"space-y-4",children:[e("h1",{className:"font-bold text-4xl",children:"@contractspec/lib.evolution"}),e("p",{className:"text-lg text-muted-foreground",children:"Analyze production telemetry, surface anomalies, and turn them into AI-reviewed spec proposals that can be approved, rolled out, or reverted."})]}),o("div",{className:"space-y-4",children:[e("h2",{className:"font-bold text-2xl",children:"Installation"}),e(p,{package:"@contractspec/lib.evolution"})]}),o("div",{className:"space-y-3",children:[e("h2",{className:"font-bold text-2xl",children:"From telemetry to intent"}),e(a,{language:"typescript",code:`import { SpecAnalyzer } from '@contractspec/lib.evolution/analyzer';
import { EvolutionPipeline } from '@contractspec/lib.observability';

const analyzer = new SpecAnalyzer();
const pipeline = new EvolutionPipeline({
  onIntent: (intent) => console.log('[intent]', intent),
});

// feed telemetry samples from tracing middleware
pipeline.ingest({
  operation: { name: 'billing.createInvoice', version: 4 },
  durationMs: 612,
  success: false,
  timestamp: new Date(),
  errorCode: 'VALIDATION_FAILED',
});`})]}),o("div",{className:"space-y-3",children:[e("h2",{className:"font-bold text-2xl",children:"Generate & approve suggestions"}),e(a,{language:"typescript",code:`import {
  SpecGenerator,
  SpecSuggestionOrchestrator,
  InMemorySpecSuggestionRepository,
} from '@contractspec/lib.evolution';

const generator = new SpecGenerator();
const repository = new InMemorySpecSuggestionRepository();
const orchestrator = new SpecSuggestionOrchestrator({ repository });

const suggestion = generator.generateFromIntent(intentPattern, {
  summary: 'Add PO number requirement for acme.corp',
});

await orchestrator.submit(suggestion, sessionState);`})]}),o("div",{className:"space-y-3",children:[e("h2",{className:"font-bold text-2xl",children:"Write approved specs back to git"}),e(a,{language:"typescript",code:`import { FileSystemSuggestionWriter } from '@contractspec/lib.evolution/approval';

const writer = new FileSystemSuggestionWriter({
  outputDir:
    'packages/libs/contracts-spec/src/generated',
});

await writer.write({
  ...suggestion,
  status: 'approved',
  approvals: { reviewer: 'ops@contractspec', decidedAt: new Date() },
});`})]}),e("div",{className:"grid gap-4 md:grid-cols-2",children:[{title:"Approvals by default",description:"Every suggestion flows through @contractspec/lib.ai-agent's ApprovalWorkflow. Tune auto-approval thresholds per environment."},{title:"Pluggable storage",description:"Use the Prisma repository in production, in-memory for tests, or stream serialized suggestions into your own queue."}].map((t)=>o("div",{className:"card-subtle space-y-2 p-4",children:[e("h3",{className:"font-semibold text-lg",children:t.title}),e("p",{className:"text-muted-foreground text-sm",children:t.description})]},t.title))}),o("div",{className:"flex items-center gap-4 pt-4",children:[e(n,{href:"/docs/libraries",className:"btn-ghost",children:"Back to Libraries"}),o(n,{href:"/docs/libraries/observability",className:"btn-primary",children:["Next: Observability ",e(m,{size:16})]})]})]})}export{f as LibrariesEvolutionPage};
