var W=Object.defineProperty;var Q=(g)=>g;function H(g,r){this[g]=Q.bind(null,r)}var Pe=(g,r)=>{for(var h in r)W(g,h,{get:r[h],enumerable:!0,configurable:!0,set:H.bind(r,h)})};var Le=(g,r)=>()=>(g&&(r=g(g=0)),r);import{CodeBlock as P,InstallCommand as J}from"@contractspec/lib.design-system";import G from"@contractspec/lib.ui-link";import{ChevronRight as _}from"lucide-react";import{jsx as i,jsxs as d}from"react/jsx-runtime";function Y(){return d("div",{className:"space-y-8",children:[d("div",{className:"space-y-2",children:[i("h1",{className:"font-bold text-4xl",children:"ContractSpec CLI"}),i("p",{className:"text-lg text-muted-foreground",children:"Command-line interface for creating, building, and validating contract specifications with AI-powered code generation."})]}),d("div",{className:"space-y-6",children:[d("div",{className:"space-y-3",children:[i("h2",{className:"font-bold text-2xl",children:"Installation"}),i(J,{package:"contractspec",dev:!0})]}),d("div",{className:"space-y-3",children:[i("h2",{className:"font-bold text-2xl",children:"Quick Start"}),i(P,{language:"bash",code:`# Initialize project
contractspec onboard
bunx contractspec init

# Create a spec
contractspec create --type operation

# Generate code
contractspec generate

# Validate
contractspec validate`})]}),d("div",{className:"space-y-4",children:[i("h2",{className:"font-bold text-2xl",children:"Commands"}),i("div",{className:"grid gap-4",children:[{name:"onboard",description:"Primary OSS onboarding flow that recommends tracks, examples, and repo-local guides",usage:"contractspec onboard [track...] [--example <key>] [--dry-run] [--json]"},{name:"create",description:"Interactive wizard to create contract specifications",usage:"contractspec create [--type operation] [--ai]"},{name:"build",description:"Generate implementation code from contract specs using AI agents",usage:"contractspec build <spec-file> [--agent-mode claude-code]"},{name:"validate",description:"Validate contract specifications and implementations",usage:"contractspec validate <spec-file> [--check-implementation]"},{name:"list",description:"List all contract specifications in the project",usage:"contractspec list [--type operation] [--json]"},{name:"watch",description:"Watch specs and auto-regenerate on changes",usage:"contractspec watch [--build] [--validate]"},{name:"sync",description:"Sync contracts by building all discovered specs",usage:"contractspec sync [--dry-run]"},{name:"ci",description:"Run all validation checks for CI/CD pipelines",usage:"contractspec ci [--format sarif] [--output results.sarif]"},{name:"deps",description:"Analyze contract dependencies and relationships",usage:"contractspec deps [--circular] [--format dot]"},{name:"diff",description:"Compare contract specifications and show differences",usage:"contractspec diff <spec1> <spec2> [--breaking]"}].map((r)=>d("div",{className:"card-subtle space-y-2 p-4",children:[i("h3",{className:"font-bold font-mono text-violet-400",children:r.name}),i("p",{className:"text-muted-foreground text-sm",children:r.description}),i(P,{language:"bash",code:r.usage,showCopyButton:!1})]},r.name))})]}),d("div",{className:"space-y-3",children:[i("h2",{className:"font-bold text-2xl",children:"AI Agent Modes"}),i("p",{className:"text-muted-foreground",children:"The CLI supports multiple AI agent modes for different use cases:"}),d("div",{className:"grid gap-3 md:grid-cols-2",children:[d("div",{className:"card-subtle p-4",children:[i("h4",{className:"font-bold",children:"simple"}),i("p",{className:"text-muted-foreground text-sm",children:"Direct LLM API calls, fast and straightforward. Best for rapid prototyping."})]}),d("div",{className:"card-subtle p-4",children:[i("h4",{className:"font-bold",children:"claude-code"}),i("p",{className:"text-muted-foreground text-sm",children:"Extended thinking with Claude. Best for production-quality code."})]}),d("div",{className:"card-subtle p-4",children:[i("h4",{className:"font-bold",children:"openai-codex"}),i("p",{className:"text-muted-foreground text-sm",children:"GPT-4o/o1 models. Excellent for algorithms and optimization."})]}),d("div",{className:"card-subtle p-4",children:[i("h4",{className:"font-bold",children:"cursor"}),i("p",{className:"text-muted-foreground text-sm",children:"Leverages Cursor agentic capabilities. Requires Cursor environment."})]})]})]}),d("div",{className:"space-y-3",children:[i("h2",{className:"font-bold text-2xl",children:"CI/CD Integration"}),i("p",{className:"text-muted-foreground",children:"Run all validation checks in CI/CD with machine-readable output:"}),i(P,{language:"yaml",filename:".github/workflows/validate.yml",code:`- name: Validate Contracts
  run: contractspec ci --format sarif --output results.sarif

- name: Upload SARIF
  uses: github/codeql-action/upload-sarif@v3
  with:
    sarif_file: results.sarif`})]}),d("div",{className:"card-subtle space-y-4 p-6",children:[i("h3",{className:"font-bold",children:"Configuration"}),d("p",{className:"text-muted-foreground text-sm",children:["Create a ",i("code",{children:".contractsrc.json"})," file in your project root:"]}),i(P,{language:"json",filename:".contractsrc.json",code:`{
  "aiProvider": "claude",
  "agentMode": "claude-code",
  "outputDir": "./src",
  "conventions": {
    "operations": "interactions/commands|queries",
    "events": "events"
  }
}`})]})]}),d("div",{className:"flex items-center gap-4 pt-4",children:[d(G,{href:"/docs/getting-started/tools/vscode",className:"btn-primary",children:["Next: VS Code Extension ",i(_,{size:16})]}),i(G,{href:"/docs/getting-started/tools",className:"btn-ghost",children:"Back to Tools"})]})]})}import L from"@contractspec/lib.ui-link";import{ChevronRight as $}from"lucide-react";import{jsx as o,jsxs as p}from"react/jsx-runtime";function K(){return p("div",{className:"space-y-8",children:[p("div",{className:"space-y-2",children:[o("h1",{className:"font-bold text-4xl",children:"Compatibility"}),o("p",{className:"text-lg text-muted-foreground",children:"Supported runtimes, frameworks, and agent modes for ContractSpec."})]}),p("div",{className:"space-y-6",children:[p("div",{className:"card-subtle space-y-3 p-6",children:[o("h2",{className:"font-bold text-2xl",children:"Runtimes"}),p("ul",{className:"space-y-2 text-muted-foreground",children:[o("li",{children:"Node.js 20+"}),o("li",{children:"Bun 1.0+"})]})]}),p("div",{className:"card-subtle space-y-3 p-6",children:[o("h2",{className:"font-bold text-2xl",children:"Frameworks"}),p("ul",{className:"space-y-2 text-muted-foreground",children:[o("li",{children:"Next.js 14+ (App Router preferred)"}),o("li",{children:"Bun + Elysia or compatible HTTP servers"})]})]}),p("div",{className:"card-subtle space-y-3 p-6",children:[o("h2",{className:"font-bold text-2xl",children:"Package managers"}),p("ul",{className:"space-y-2 text-muted-foreground",children:[o("li",{children:"bun (recommended)"}),o("li",{children:"npm"}),o("li",{children:"pnpm"})]})]}),p("div",{className:"card-subtle space-y-3 p-6",children:[o("h2",{className:"font-bold text-2xl",children:"AI agent modes"}),p("ul",{className:"space-y-2 text-muted-foreground",children:[o("li",{children:"claude-code"}),o("li",{children:"openai-codex"}),o("li",{children:"cursor"}),o("li",{children:"opencode"}),o("li",{children:"simple (direct LLM)"})]})]}),p("div",{className:"card-subtle space-y-3 p-6",children:[o("h2",{className:"font-bold text-2xl",children:"Datastores"}),o("p",{className:"text-muted-foreground",children:"ContractSpec ships with Prisma-friendly defaults and can integrate with custom adapters for other databases."}),p("ul",{className:"space-y-2 text-muted-foreground",children:[o("li",{children:"PostgreSQL via Prisma"}),o("li",{children:"Custom adapters for other SQL/NoSQL stores"})]})]}),p("div",{className:"card-subtle space-y-3 p-6",children:[o("h2",{className:"font-bold text-2xl",children:"Cross-platform UI architecture"}),p("p",{className:"text-muted-foreground",children:["Need the React and React Native component compatibility story? Read"," ",o(L,{href:"/docs/libraries/cross-platform-ui",className:"text-[color:var(--rust)] underline underline-offset-4",children:"Cross-platform UI"})," ","for the runtime and UI-layer split."]})]})]}),p("div",{className:"flex flex-wrap items-center gap-3 pt-2",children:[o(L,{href:"/docs/getting-started/start-here",className:"btn-ghost",children:"Start here"}),o(L,{href:"/docs/getting-started/troubleshooting",className:"btn-ghost",children:"Troubleshooting"}),p(L,{href:"/docs/getting-started/installation",className:"btn-primary",children:["Next: Installation ",o($,{size:16})]})]})]})}import{CodeBlock as R}from"@contractspec/lib.design-system";import{HStack as X,VStack as S}from"@contractspec/lib.design-system/layout";import{List as Z,ListItem as w}from"@contractspec/lib.design-system/list";import{H1 as x,H2 as E,H3 as j,P as k,Text as v}from"@contractspec/lib.design-system/typography";import O from"@contractspec/lib.ui-link";import{ChevronRight as ee}from"lucide-react";import{jsx as t,jsxs as y}from"react/jsx-runtime";var te=`import { defineDataView } from '@contractspec/lib.contracts-spec/data-views';
import { ListTransactions } from './list-transactions';

export const TransactionHistory = defineDataView({
  meta: {
    key: 'billing.transactionHistory',
    version: '1.0.0',
    entity: 'transaction',
    title: 'Transaction History',
    description: 'Customer payment history',
    domain: 'billing',
    owners: ['team-billing'],
    tags: ['payments'],
    stability: 'stable',
  },
  source: {
    primary: {
      key: ListTransactions.meta.key,
      version: ListTransactions.meta.version,
    },
  },
  view: {
    kind: 'table',
    executionMode: 'client',
    selection: 'multiple',
    columnVisibility: true,
    columnResizing: true,
    columnPinning: true,
    rowExpansion: {
      fields: ['notes', 'renewalDate', 'lastActivityAt'],
    },
    initialState: {
      pageSize: 4,
      hiddenColumns: ['notes'],
      pinnedColumns: {
        left: ['account'],
      },
      sorting: [{ field: 'arr', desc: true }],
    },
    fields: [
      { key: 'account', label: 'Account', dataPath: 'account', sortable: true },
      { key: 'owner', label: 'Owner', dataPath: 'owner', sortable: true },
      { key: 'status', label: 'Status', dataPath: 'status', sortable: true },
      {
        key: 'amount',
        label: 'Amount',
        dataPath: 'amount',
        sortable: true,
        format: { type: 'currency', currency: 'EUR', rounded: true },
      },
      {
        key: 'renewalDate',
        label: 'Renewal',
        dataPath: 'renewalDate',
        format: { type: 'date', dateStyle: 'medium' },
      },
      {
        key: 'processingTime',
        label: 'Processing time',
        dataPath: 'processingMinutes',
        format: { type: 'duration', unit: 'minute', display: 'digital' },
      },
      {
        key: 'notes',
        label: 'Notes',
        dataPath: 'notes',
        visibility: { minDataDepth: 'detailed' },
      },
    ],
    collection: {
      viewModes: {
        defaultMode: 'table',
        allowedModes: ['list', 'grid', 'table'],
      },
      toolbar: {
        search: true,
        viewMode: true,
        filters: true,
        density: true,
        dataDepth: true,
      },
      pagination: {
        pageSize: 25,
        pageSizeOptions: [10, 25, 50],
      },
      density: 'comfortable',
      dataDepth: 'standard',
      personalization: {
        enabled: true,
        persist: {
          viewMode: true,
          density: true,
          dataDepth: true,
          pageSize: true,
        },
      },
    },
    filters: [
      { key: 'status', label: 'Status', field: 'status', type: 'enum' },
      {
        key: 'amount',
        label: 'Amount',
        field: 'amount',
        type: 'currency',
        valueMode: 'range',
      },
      {
        key: 'renewalDate',
        label: 'Renewal',
        field: 'renewalDate',
        type: 'date',
        valueMode: 'range',
      },
    ],
  },
});`;function ae(){return y(S,{className:"space-y-8",children:[y(S,{className:"space-y-4",children:[t(x,{className:"font-bold text-4xl",children:"Display Data with DataViews"}),t(k,{className:"text-lg text-muted-foreground",children:"Define a filterable, sortable transaction history view that works across web and mobile without duplicating UI code."})]}),y(S,{className:"space-y-4",children:[t(E,{className:"font-bold text-2xl",children:"1. Define the underlying query"}),t(k,{className:"text-muted-foreground",children:"First, create a query operation to fetch the data:"}),t(R,{language:"typescript",filename:"lib/specs/billing/list-transactions.ts",code:`import { defineQuery } from '@contractspec/lib.contracts-spec';

export const ListTransactions = defineQuery({
  meta: {
    key: 'billing.listTransactions',
    version: '1.0.0',
    description: 'Fetch customer transaction history',
  },
  io: {
    input: /* pagination + filters */,
    output: /* array of transactions */,
  },
  policy: { auth: 'user' },
});`})]}),y(S,{className:"space-y-4",children:[t(E,{className:"font-bold text-2xl",children:"2. Define the DataView spec"}),t(k,{className:"text-muted-foreground",children:"Wrap your query with presentation metadata:"}),t(R,{language:"typescript",filename:"lib/specs/billing/transaction-history.data-view.ts",code:te}),y(k,{className:"text-muted-foreground text-sm",children:["The live version of this pattern is available in the canonical"," ",t(O,{href:"/docs/examples/data-grid-showcase",className:"text-[color:var(--rust)] underline underline-offset-4",children:t(v,{children:"Data Grid Showcase"})}),"."]})]}),y(S,{className:"space-y-4",children:[t(E,{className:"font-bold text-2xl",children:"3. Render on the frontend"}),t(k,{className:"text-muted-foreground",children:"Use the runtime renderer in your React or React Native app:"}),t(R,{language:"tsx",filename:"app/dashboard/transactions/page.tsx",code:`'use client';

import { DataViewRenderer } from '@contractspec/lib.design-system';
import { TransactionHistory } from '@/lib/specs/billing/transaction-history.data-view';
import { useQuery } from '@tanstack/react-query';

export function TransactionsPage() {
  const { data, isLoading } = useQuery({
    queryKey: ['transactions'],
    queryFn: () => fetch('/api/ops/billing.listTransactions').then(r => r.json()),
  });

  return (
    <div className="container py-8">
      <h1 className="text-3xl font-bold mb-6">Payment History</h1>
      <DataViewRenderer
        spec={TransactionHistory}
        items={data?.items ?? []}
        loading={isLoading}
        defaultViewMode="table"
        defaultDensity="comfortable"
        defaultDataDepth="standard"
        onFilterChange={(filters) => {
          // refetch with new filters
        }}
      />
    </div>
  );
}`})]}),y(S,{className:"space-y-4",children:[t(E,{className:"font-bold text-2xl",children:"4. Add personalization"}),t(k,{className:"text-muted-foreground",children:"When the app has a user profile or behavior insights, resolve DataView preferences before rendering. The renderer receives plain props; personalization stays in the app/runtime boundary."}),t(R,{language:"tsx",filename:"app/dashboard/transactions/PersonalizedTransactions.tsx",code:`'use client';

import { DataViewRenderer } from '@contractspec/lib.design-system';
import { resolveDataViewPreferences } from '@contractspec/lib.personalization/data-view-preferences';
import { createBehaviorTracker } from '@contractspec/lib.personalization';

const tracker = createBehaviorTracker({
  store,
  context: { tenantId: tenant.id, userId: user.id },
});

const resolved = resolveDataViewPreferences({
  spec: TransactionHistory,
  preferences: profile.canonical,
  insights,
  record: savedTransactionViewPreference,
});

<DataViewRenderer
  spec={TransactionHistory}
  items={transactions}
  defaultViewMode={resolved.viewMode}
  defaultDensity={resolved.density}
  defaultDataDepth={resolved.dataDepth}
  pagination={{ page, pageSize: resolved.pageSize ?? 25, total }}
  onViewModeChange={(viewMode) =>
    tracker.trackDataViewInteraction({
      dataViewKey: TransactionHistory.meta.key,
      action: 'view_mode_changed',
      viewMode,
    })
  }
  onDataDepthChange={(dataDepth) =>
    tracker.trackDataViewInteraction({
      dataViewKey: TransactionHistory.meta.key,
      action: 'data_depth_changed',
      dataDepth,
    })
  }
/>;`})]}),y(S,{className:"card-subtle space-y-4 p-6",children:[t(j,{className:"font-bold",children:"Why DataViews?"}),y(Z,{className:"space-y-2 text-muted-foreground text-sm",children:[t(w,{children:t(v,{children:"Same spec renders on web (React) and mobile (React Native)"})}),t(w,{children:t(v,{children:"Filters, sorting, and pagination handled automatically"})}),t(w,{children:t(v,{children:"Column visibility, pinning, resizing, and row expansion stay contract-driven"})}),t(w,{children:t(v,{children:"List, grid, and table modes can share one collection config with toolbar and pagination defaults"})}),t(w,{children:t(v,{children:"Data depth lets summary screens hide detailed fields without forking the spec"})}),t(w,{children:t(v,{children:"Typed format rules for numbers, percent values, currency, dates, times, datetimes, and durations applied consistently"})}),t(w,{children:t(v,{children:"Personalization helpers can seed preferred view mode, density, data depth, and page size from user preferences or behavior insights"})}),t(w,{children:t(v,{children:"Export to CSV/PDF using the same spec"})}),t(w,{children:t(v,{children:"A/B test different layouts without touching the backend"})})]})]}),y(X,{className:"items-center gap-4 pt-4",children:[y(O,{href:"/docs/libraries/data-views",className:"btn-primary",children:[t(v,{children:"DataView API Reference"})," ",t(ee,{size:16})]}),t(O,{href:"/docs/specs/workflows",className:"btn-ghost",children:t(v,{children:"Next: Workflows"})})]})]})}import{CodeBlock as ie,InstallCommand as oe}from"@contractspec/lib.design-system";import B from"@contractspec/lib.ui-link";import{ChevronRight as q,Code2 as ne,Cpu as re,Layers as ce,Terminal as le}from"lucide-react";import{jsx as s,jsxs as N}from"react/jsx-runtime";function Ke(){return N("div",{className:"space-y-8",children:[N("div",{className:"space-y-2",children:[s("h1",{className:"font-bold text-4xl",children:"Developer Tools"}),s("p",{className:"text-lg text-muted-foreground",children:"Use the OSS toolchain to define contracts, validate changes, inspect generated surfaces, and adopt the system incrementally across different environments."})]}),s("div",{className:"grid gap-6 md:grid-cols-2",children:[{name:"CLI",href:"/docs/getting-started/tools/cli",description:"Command-line interface for spec creation, building, validation, and CI/CD integration.",icon:le,status:"available",highlights:["AI-powered code generation","Multiple agent modes","SARIF/JSON output"]},{name:"VS Code Extension",href:"/docs/getting-started/tools/vscode",description:"Real-time validation, scaffolding, and navigation directly in your editor.",icon:ne,status:"available",highlights:["Specs Explorer sidebar","Watch mode","Interactive walkthroughs"]},{name:"ContractSpec Studio",href:"https://www.contractspec.studio",description:"The operating layer on top of OSS ContractSpec for teams that want evidence-backed decisions, workflow automation, and managed delivery loops.",icon:ce,status:"available",highlights:["Evidence-to-decision loop","Compiled spec diffs and task packs","Exports to Linear, Jira, Notion, and GitHub"]},{name:"JetBrains Plugin",href:"#",description:"Full ContractSpec support for IntelliJ, WebStorm, and other JetBrains IDEs.",icon:re,status:"coming-soon",highlights:["Code navigation","Inline validation","Refactoring support"]}].map((r)=>{let h=r.icon,I=r.status==="coming-soon";return N("div",{className:`card-subtle relative space-y-4 p-6 ${I?"opacity-75":""}`,children:[I&&s("span",{className:"absolute -top-2 right-4 rounded-full bg-violet-500/20 px-2 py-0.5 font-medium text-violet-400 text-xs",children:"Coming Soon"}),N("div",{className:"flex items-center gap-3",children:[s("div",{className:"flex h-10 w-10 items-center justify-center rounded-lg bg-violet-500/10",children:s(h,{className:"h-5 w-5 text-violet-400"})}),s("h3",{className:"font-bold text-lg",children:r.name})]}),s("p",{className:"text-muted-foreground text-sm",children:r.description}),s("ul",{className:"space-y-1",children:r.highlights.map((M)=>N("li",{className:"flex items-center gap-2 text-muted-foreground text-sm",children:[s("span",{className:"text-violet-400",children:"-"}),M]},M))}),!I&&N(B,{href:r.href,className:"btn-ghost inline-flex items-center gap-1 text-sm",children:["Learn more ",s(q,{size:14})]})]},r.name)})}),N("div",{className:"card-subtle space-y-4 p-6",children:[s("h3",{className:"font-bold",children:"Quick Install"}),N("div",{className:"space-y-3",children:[N("div",{children:[s("p",{className:"mb-2 font-medium text-muted-foreground text-xs",children:"CLI"}),s(oe,{package:"contractspec",dev:!0})]}),N("div",{children:[s("p",{className:"mb-2 font-medium text-muted-foreground text-xs",children:"VS Code Extension"}),s(ie,{language:"bash",code:"code --install-extension lssm.vscode-contractspec"})]})]})]}),N("div",{className:"flex items-center gap-4 pt-4",children:[N(B,{href:"/docs/getting-started/tools/cli",className:"btn-primary",children:["Get Started with CLI ",s(q,{size:16})]}),s(B,{href:"/docs/getting-started/tools/vscode",className:"btn-ghost",children:"VS Code Extension"})]})]})}import{CodeBlock as A}from"@contractspec/lib.design-system";import de from"@contractspec/lib.ui-link";import{ChevronRight as se}from"lucide-react";import{jsx as n,jsxs as f}from"react/jsx-runtime";function pe(){return f("div",{className:"space-y-8",children:[f("div",{className:"space-y-2",children:[n("h1",{className:"font-bold text-4xl",children:"Your First Operation"}),n("p",{className:"text-lg text-muted-foreground",children:"Build a payment capture operation with policy enforcement in under 10 minutes."})]}),f("div",{className:"space-y-6",children:[f("div",{className:"space-y-3",children:[n("h2",{className:"font-bold text-2xl",children:"What you'll build"}),n("p",{className:"text-muted-foreground",children:"A real-world payment processing operation that validates input, enforces business rules, integrates with Stripe, and audits every transaction. This is production-ready code, not a toy example."})]}),f("div",{className:"space-y-3",children:[n("h2",{className:"font-bold text-2xl",children:"1. Define the operation spec"}),f("p",{className:"text-muted-foreground",children:["Create ",n("code",{children:"lib/specs/billing/capture-payment.ts"}),":"]}),n(A,{language:"typescript",filename:"lib/specs/billing/capture-payment.ts",code:`import { defineCommand } from '@contractspec/lib.contracts-spec';
import { SchemaModel, ScalarTypeEnum } from '@contractspec/lib.schema';

const CapturePaymentInput = new SchemaModel({
  name: 'CapturePaymentInput',
  fields: {
    invoiceId: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
    amount: { type: ScalarTypeEnum.PositiveNumber(), isOptional: false },
    currency: { type: ScalarTypeEnum.String(), isOptional: false },
    paymentMethodId: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
  },
});

const PaymentResult = new SchemaModel({
  name: 'PaymentResult',
  fields: {
    transactionId: { type: ScalarTypeEnum.String(), isOptional: false },
    status: { type: ScalarTypeEnum.String(), isOptional: false },
    receiptUrl: { type: ScalarTypeEnum.String(), isOptional: true },
  },
});

export const CapturePayment = defineCommand({
  meta: {
    key: 'billing.capturePayment',
    version: '1.0.0',
    description: 'Process a payment for an invoice',
    goal: 'Capture funds from customer payment method',
    context: 'Called when customer confirms purchase',
    owners: ['team-billing'],
    tags: ['payments', 'stripe', 'critical'],
    stability: 'stable',
  },
  io: {
    input: CapturePaymentInput,
    output: PaymentResult,
  },
  policy: {
    auth: 'user',
    rules: [
      { resource: 'invoice', action: 'pay', condition: 'owner' },
    ],
  },
});`})]}),f("div",{className:"space-y-3",children:[n("h2",{className:"font-bold text-2xl",children:"2. Implement the handler"}),f("p",{className:"text-muted-foreground",children:["Create ",n("code",{children:"lib/handlers/billing/capture-payment.ts"}),":"]}),n(A,{language:"typescript",filename:"lib/handlers/billing/capture-payment.ts",code:`import { CapturePayment } from '@/lib/specs/billing/capture-payment';
import { stripe } from '@/lib/integrations/stripe';
import { db } from '@/lib/db';

export async function handleCapturePayment(input, ctx) {
  // 1. Verify invoice exists and belongs to user
  const invoice = await db.invoice.findUnique({
    where: { id: input.invoiceId, userId: ctx.userId },
  });

  if (!invoice) throw new Error('Invoice not found');
  if (invoice.status === 'paid') throw new Error('Already paid');

  // 2. Create Stripe payment intent
  const paymentIntent = await stripe.paymentIntents.create({
    amount: Math.round(input.amount * 100),
    currency: input.currency,
    payment_method: input.paymentMethodId,
    confirm: true,
    metadata: { invoiceId: input.invoiceId },
  });

  // 3. Update invoice status
  await db.invoice.update({
    where: { id: input.invoiceId },
    data: {
      status: 'paid',
      paidAt: new Date(),
      transactionId: paymentIntent.id,
    },
  });

  return {
    transactionId: paymentIntent.id,
    status: paymentIntent.status,
    receiptUrl: paymentIntent.charges.data[0]?.receipt_url,
  };
}`})]}),f("div",{className:"space-y-3",children:[n("h2",{className:"font-bold text-2xl",children:"3. Register and serve"}),f("p",{className:"text-muted-foreground",children:["Wire it up in ",n("code",{children:"lib/registry.ts"})," and"," ",n("code",{children:"app/api/ops/[...route]/route.ts"}),":"]}),n(A,{language:"typescript",filename:"lib/registry.ts",code:`import { OperationSpecRegistry, installOp } from '@contractspec/lib.contracts-spec';
import { CapturePayment } from './specs/billing/capture-payment';
import { handleCapturePayment } from './handlers/billing/capture-payment';

export const registry = new OperationSpecRegistry();
installOp(registry, CapturePayment, handleCapturePayment);`}),n(A,{language:"typescript",filename:"app/api/ops/[...route]/route.ts",code:`import { makeNextAppHandler } from '@contractspec/lib.contracts-runtime-server-rest/rest-next-app';
import { registry } from '@/lib/registry';
import { auth } from '@/lib/auth';

const handler = makeNextAppHandler(registry, async (req) => {
  const session = await auth(req);
  return { actor: 'user', userId: session.userId, tenantId: session.tenantId };
});

export { handler as GET, handler as POST };`})]}),f("div",{className:"card-subtle space-y-4 p-6",children:[n("h3",{className:"font-bold",children:"What you just built:"}),f("ul",{className:"space-y-2 text-muted-foreground text-sm",children:[f("li",{children:["Type-safe API endpoint at"," ",n("code",{children:"/api/ops/billing.capturePayment"})]}),n("li",{children:"Automatic input validation (amount must be positive, IDs required)"}),n("li",{children:"Policy enforcement—only invoice owner can pay"}),n("li",{children:"Stripe integration with error handling"}),n("li",{children:"Database transaction with audit trail"}),n("li",{children:"Same spec works with GraphQL, MCP, or webhooks"})]})]}),n("div",{className:"flex items-center gap-4 pt-4",children:f(de,{href:"/docs/getting-started/dataviews",className:"btn-primary",children:["Next: Display Data with DataViews ",n(se,{size:16})]})})]})]})}import{CodeBlock as F,InstallCommand as D}from"@contractspec/lib.design-system";import me from"@contractspec/lib.ui-link";import{ChevronRight as ue}from"lucide-react";import{jsx as c,jsxs as b}from"react/jsx-runtime";function fe(){return b("div",{className:"space-y-8",children:[b("div",{className:"space-y-2",children:[c("h1",{className:"font-bold text-4xl",children:"Installation"}),c("p",{className:"text-lg text-muted-foreground",children:"Add ContractSpec to your existing Next.js or Bun project, or start fresh."})]}),b("div",{className:"space-y-6",children:[b("div",{className:"space-y-3",children:[c("h2",{className:"font-bold text-2xl",children:"Prerequisites"}),b("ul",{className:"space-y-2 text-muted-foreground",children:[c("li",{children:"Node.js 20+ (or Bun 1.0+)"}),c("li",{children:"Existing Next.js app or Bun HTTP server"}),c("li",{children:"PostgreSQL database (for persistence)"})]})]}),b("div",{className:"space-y-3",children:[c("h2",{className:"font-bold text-2xl",children:"Install Core Libraries"}),c("p",{className:"text-muted-foreground",children:"Add the contracts runtime and your choice of adapter:"}),c(D,{package:["@contractspec/lib.contracts-spec","@contractspec/lib.schema"]})]}),b("div",{className:"space-y-3",children:[c("h2",{className:"font-bold text-2xl",children:"For Next.js projects"}),c(D,{package:"@contractspec/lib.contracts-spec"})]}),b("div",{className:"space-y-3",children:[c("h2",{className:"font-bold text-2xl",children:"For database models"}),c(D,{package:["@contractspec/app.cli-database","prisma","@prisma/client"]})]}),b("div",{className:"space-y-3",children:[c("h2",{className:"font-bold text-2xl",children:"Set up your project"}),c("p",{className:"text-muted-foreground",children:"Initialize a new ContractSpec project structure:"}),c(F,{language:"bash",filename:"installation-init",code:`bunx contractspec init
# Follow the interactive prompts to configure your project`})]}),b("div",{className:"space-y-3",children:[c("h2",{className:"font-bold text-2xl",children:"Initialize the database"}),c("p",{className:"text-muted-foreground",children:"If using Prisma, set up your schema and generate the client:"}),c(F,{language:"bash",filename:"installation-prisma",code:`bunx prisma init
# Edit prisma/schema.prisma with your models
bunx prisma generate
bunx prisma migrate dev --name init`})]}),c("div",{className:"flex items-center gap-4 pt-4",children:b(me,{href:"/docs/getting-started/hello-world",className:"btn-primary",children:["Next: First Operation ",c(ue,{size:16})]})})]})]})}import{CodeBlock as z,InstallCommand as ge}from"@contractspec/lib.design-system";import T from"@contractspec/lib.ui-link";import{ChevronRight as he}from"lucide-react";import{jsx as u,jsxs as C}from"react/jsx-runtime";function ve(){return C("div",{className:"space-y-8",children:[C("div",{className:"space-y-2",children:[u("h1",{className:"font-bold text-4xl",children:"Start here"}),u("p",{className:"text-lg text-muted-foreground",children:"A fast onboarding path from install to your first generated contract."})]}),C("div",{className:"space-y-6",children:[C("div",{className:"space-y-3",children:[u("h2",{className:"font-bold text-2xl",children:"Install the CLI"}),u(ge,{package:"contractspec",dev:!0})]}),C("div",{className:"space-y-3",children:[u("h2",{className:"font-bold text-2xl",children:"Generate repo-local guidance"}),u(z,{language:"bash",filename:"start-here-onboard",code:`contractspec onboard
# optional focused track
contractspec onboard knowledge --example knowledge-canon`})]}),C("div",{className:"space-y-3",children:[u("h2",{className:"font-bold text-2xl",children:"Initialize your project"}),u(z,{language:"bash",filename:"start-here-init",code:"bunx contractspec init"})]}),C("div",{className:"space-y-3",children:[u("h2",{className:"font-bold text-2xl",children:"Author your first contract"}),u(z,{language:"bash",filename:"start-here-create",code:"contractspec create --type operation"})]}),C("div",{className:"space-y-3",children:[u("h2",{className:"font-bold text-2xl",children:"Generate implementation"}),u(z,{language:"bash",filename:"start-here-build",code:`contractspec generate
contractspec validate`})]})]}),C("div",{className:"flex flex-wrap items-center gap-3 pt-2",children:[C(T,{href:"/docs/getting-started/hello-world",className:"btn-primary",children:["Next: Hello World ",u(he,{size:16})]}),u(T,{href:"/docs/getting-started/troubleshooting",className:"btn-ghost",children:"Troubleshooting"}),u(T,{href:"/docs/getting-started/compatibility",className:"btn-ghost",children:"Compatibility"})]})]})}import{CodeBlock as Ne}from"@contractspec/lib.design-system";import V from"@contractspec/lib.ui-link";import{ChevronRight as ye}from"lucide-react";import{jsx as l,jsxs as m}from"react/jsx-runtime";function be(){return m("div",{className:"space-y-8",children:[m("div",{className:"space-y-2",children:[l("h1",{className:"font-bold text-4xl",children:"Troubleshooting"}),l("p",{className:"text-lg text-muted-foreground",children:"Common issues and fixes when installing or generating with ContractSpec."})]}),m("div",{className:"space-y-6",children:[m("div",{className:"card-subtle space-y-3 p-6",children:[l("h2",{className:"font-bold text-2xl",children:"Command not found"}),m("ul",{className:"space-y-2 text-muted-foreground",children:[l("li",{children:"Reinstall the CLI and ensure it is in your PATH."}),l("li",{children:"Confirm Node.js 20+ or Bun 1.0+ is installed."})]})]}),m("div",{className:"card-subtle space-y-3 p-6",children:[l("h2",{className:"font-bold text-2xl",children:"Specs not discovered"}),m("ul",{className:"space-y-2 text-muted-foreground",children:[m("li",{children:["Run ",l("code",{children:"contractspec list"})," to see discovered specs."]}),l("li",{children:"Verify your spec path conventions in .contractsrc.json."})]})]}),m("div",{className:"card-subtle space-y-3 p-6",children:[l("h2",{className:"font-bold text-2xl",children:"Build or validate fails"}),m("ul",{className:"space-y-2 text-muted-foreground",children:[m("li",{children:["Run ",l("code",{children:"contractspec validate"})," to surface schema errors."]}),l("li",{children:"Check that generated files were not manually edited."})]})]}),m("div",{className:"space-y-3",children:[l("h2",{className:"font-bold text-2xl",children:"Diagnostics"}),l(Ne,{language:"bash",filename:"troubleshooting-diagnostics",code:`contractspec --version
contractspec list
contractspec validate src/contracts/mySpec.ts`})]}),m("div",{className:"card-subtle space-y-3 p-6",children:[l("h2",{className:"font-bold text-2xl",children:"Still blocked?"}),m("ul",{className:"space-y-2 text-muted-foreground",children:[l("li",{children:"Confirm compatibility requirements for runtime and framework."}),l("li",{children:"Re-run builds on a clean branch to isolate changes."}),l("li",{children:"Use a new spec and minimal adapter to validate setup."})]})]})]}),m("div",{className:"flex flex-wrap items-center gap-3 pt-2",children:[l(V,{href:"/docs/getting-started/start-here",className:"btn-ghost",children:"Start here"}),l(V,{href:"/docs/getting-started/compatibility",className:"btn-ghost",children:"Compatibility"}),m(V,{href:"/docs/getting-started/installation",className:"btn-primary",children:["Next: Installation ",l(ye,{size:16})]})]})]})}import{CodeBlock as Ce}from"@contractspec/lib.design-system";import U from"@contractspec/lib.ui-link";import{ChevronRight as we,ExternalLink as Se}from"lucide-react";import{jsx as e,jsxs as a}from"react/jsx-runtime";function Ct(){let g=[{category:"Core Functionality",items:["Real-time validation with instant feedback on spec errors","Build/Scaffold handlers and components from specs","Interactive spec creation wizard","Watch mode for auto-rebuild on changes","Sync all specs in workspace with one command"]},{category:"Visual Navigation",items:["Specs Explorer sidebar with organized tree view","Dependencies view to visualize spec relationships","Build Results tracking with history","Circular dependency detection"]},{category:"Comparison & Export",items:["Semantic and text diff between specs","Git comparison with baseline branches","OpenAPI 3.1 specification export"]}],r=[{name:"Create New Spec",description:"Interactive wizard to create specs"},{name:"Validate Current Spec",description:"Validate the currently open spec"},{name:"Build/Scaffold from Current Spec",description:"Generate handler/component"},{name:"Toggle Watch Mode",description:"Auto-rebuild on changes"},{name:"Sync All Specs",description:"Build all specs in workspace"},{name:"Analyze Spec Dependencies",description:"Visualize spec dependencies"},{name:"Compare Specs",description:"Semantic or text diff between specs"},{name:"Export to OpenAPI",description:"Generate OpenAPI specification"}];return a("div",{className:"space-y-8",children:[a("div",{className:"space-y-2",children:[e("h1",{className:"font-bold text-4xl",children:"VS Code Extension"}),e("p",{className:"text-lg text-muted-foreground",children:"Spec-first development directly in VS Code. Validate, scaffold, and explore your contract specifications with real-time feedback."})]}),a("div",{className:"flex flex-wrap gap-3",children:[a("a",{href:"https://marketplace.visualstudio.com/items?itemName=lssm.vscode-contractspec",target:"_blank",rel:"noopener noreferrer",className:"btn-primary inline-flex items-center gap-2",children:["Install Extension ",e(Se,{size:16})]}),e("a",{href:"vscode:extension/lssm.vscode-contractspec",className:"btn-ghost inline-flex items-center gap-2",children:"Open in VS Code"})]}),a("div",{className:"space-y-6",children:[a("div",{className:"space-y-3",children:[e("h2",{className:"font-bold text-2xl",children:"Installation"}),a("div",{className:"space-y-2",children:[a("p",{className:"text-muted-foreground text-sm",children:[e("strong",{children:"Option 1:"})," Install from VS Code Marketplace"]}),e(Ce,{language:"bash",code:"code --install-extension lssm.vscode-contractspec"}),a("p",{className:"mt-4 text-muted-foreground text-sm",children:[e("strong",{children:"Option 2:"}),' Search for "ContractSpec" in VS Code Extensions (Ctrl/Cmd+Shift+X)']})]})]}),a("div",{className:"space-y-4",children:[e("h2",{className:"font-bold text-2xl",children:"Features"}),e("div",{className:"grid gap-4 md:grid-cols-3",children:g.map((h)=>a("div",{className:"card-subtle space-y-3 p-4",children:[e("h3",{className:"font-bold text-violet-400",children:h.category}),e("ul",{className:"space-y-2",children:h.items.map((I)=>a("li",{className:"flex items-start gap-2 text-muted-foreground text-sm",children:[e("span",{className:"mt-1 text-violet-400",children:"-"}),e("span",{children:I})]},I))})]},h.category))})]}),a("div",{className:"space-y-4",children:[e("h2",{className:"font-bold text-2xl",children:"Commands"}),a("p",{className:"text-muted-foreground",children:["Access commands via Command Palette (Ctrl/Cmd+Shift+P) with prefix"," ",e("code",{children:"ContractSpec:"})]}),e("div",{className:"grid gap-3 md:grid-cols-2",children:r.map((h)=>e("div",{className:"card-subtle flex items-center gap-3 p-3",children:a("div",{className:"flex-1",children:[e("p",{className:"font-medium font-mono text-sm",children:h.name}),e("p",{className:"text-muted-foreground text-xs",children:h.description})]})},h.name))})]}),a("div",{className:"space-y-3",children:[e("h2",{className:"font-bold text-2xl",children:"Sidebar Views"}),e("p",{className:"text-muted-foreground",children:"The extension adds a ContractSpec activity bar (icon in sidebar) with three views:"}),a("div",{className:"grid gap-4 md:grid-cols-3",children:[a("div",{className:"card-subtle space-y-2 p-4",children:[e("h4",{className:"font-bold",children:"Specs Explorer"}),e("p",{className:"text-muted-foreground text-sm",children:"Browse all specs organized by type. Shows name, version, and stability. Click to open, right-click for actions."})]}),a("div",{className:"card-subtle space-y-2 p-4",children:[e("h4",{className:"font-bold",children:"Dependencies"}),e("p",{className:"text-muted-foreground text-sm",children:"Visualize spec relationships. Detect circular dependencies. Navigate to referenced specs."})]}),a("div",{className:"card-subtle space-y-2 p-4",children:[e("h4",{className:"font-bold",children:"Build Results"}),e("p",{className:"text-muted-foreground text-sm",children:"Track build history (last 20). Success/failure indicators. Click to open generated files."})]})]})]}),a("div",{className:"space-y-3",children:[e("h2",{className:"font-bold text-2xl",children:"Getting Started"}),a("ol",{className:"list-inside list-decimal space-y-2 text-muted-foreground",children:[e("li",{children:"Install the extension from VS Code Marketplace"}),e("li",{children:"Open a workspace with ContractSpec files (or create one)"}),e("li",{children:"Start the walkthrough: Help - Welcome - ContractSpec"}),a("li",{children:["Create your first spec: Click ",e("strong",{children:"+"})," in Specs Explorer or run ",e("code",{children:"ContractSpec: Create New Spec"})]}),e("li",{children:"Build from it: Click the build icon in the editor title bar"})]})]}),a("div",{className:"card-subtle space-y-4 p-6",children:[e("h3",{className:"font-bold",children:"Configuration"}),e("p",{className:"text-muted-foreground text-sm",children:"Configure the extension in VS Code Settings:"}),e("div",{className:"overflow-x-auto",children:a("table",{className:"w-full text-muted-foreground text-sm",children:[e("thead",{children:a("tr",{className:"border-border border-b",children:[e("th",{className:"p-2 text-left font-medium",children:"Setting"}),e("th",{className:"p-2 text-left font-medium",children:"Description"}),e("th",{className:"p-2 text-left font-medium",children:"Default"})]})}),a("tbody",{children:[a("tr",{className:"border-border border-b",children:[e("td",{className:"p-2 font-mono text-xs",children:"validation.onSave"}),e("td",{className:"p-2",children:"Run validation on save"}),e("td",{className:"p-2",children:"true"})]}),a("tr",{className:"border-border border-b",children:[e("td",{className:"p-2 font-mono text-xs",children:"validation.onOpen"}),e("td",{className:"p-2",children:"Run validation on open"}),e("td",{className:"p-2",children:"true"})]}),a("tr",{className:"border-border border-b",children:[e("td",{className:"p-2 font-mono text-xs",children:"api.baseUrl"}),e("td",{className:"p-2",children:"Base URL for ContractSpec API"}),e("td",{className:"p-2",children:"(empty)"})]})]})]})})]})]}),a("div",{className:"flex items-center gap-4 pt-4",children:[e(U,{href:"/docs/getting-started/tools/cli",className:"btn-ghost",children:"Back: CLI"}),a(U,{href:"/docs/specs",className:"btn-primary",children:["Next: Core Concepts ",e(we,{size:16})]})]})]})}import{registerDocBlocks as Ie}from"@contractspec/lib.contracts-spec/docs";var ke=[{id:"docs.getting-started.start-here",title:"Start here",summary:"Fast onboarding path from install to first generated contract.",kind:"usage",visibility:"public",route:"/docs/getting-started/start-here",tags:["getting-started","onboarding"],body:`# Start Here

Get ContractSpec running quickly and generate your first contract-backed code.

## 1. Install the CLI

\`\`\`bash
bun add -D contractspec
bun add @contractspec/lib.contracts-spec @contractspec/lib.schema
\`\`\`

## 2. Initialize your project

\`\`\`bash
bunx contractspec init
\`\`\`

## 3. Create your first contract

\`\`\`bash
contractspec create --type operation
\`\`\`

## 4. Generate implementation

\`\`\`bash
contractspec build src/contracts/mySpec.ts
contractspec validate src/contracts/mySpec.ts
\`\`\`

## Next steps

- Follow the Hello World tutorial for a full walkthrough.
- Install the VS Code extension for inline validation.
- Review compatibility notes before deploying to production.
`},{id:"docs.getting-started.troubleshooting",title:"Troubleshooting",summary:"Resolve common install, spec discovery, and build issues.",kind:"faq",visibility:"public",route:"/docs/getting-started/troubleshooting",tags:["getting-started","troubleshooting"],body:`# Troubleshooting

Common issues and quick fixes when getting started with ContractSpec.

## Command not found

- Reinstall the CLI and ensure it is in your PATH.
- Confirm Node.js 20+ or Bun 1.0+ is installed.

## Specs not discovered

- Run \`contractspec list\` to see discovered specs.
- Verify your spec path conventions in \`.contractsrc.json\`.

## Build or validate fails

- Run \`contractspec validate\` to surface schema errors.
- Check that generated files were not manually edited.

## Diagnostics

\`\`\`bash
contractspec --version
contractspec list
contractspec validate src/contracts/mySpec.ts
\`\`\`

## Still blocked?

- Confirm compatibility requirements (runtime, framework, package manager).
- Re-run \`contractspec build\` with a clean working tree.
`},{id:"docs.getting-started.compatibility",title:"Compatibility",summary:"Supported runtimes, frameworks, package managers, and AI modes.",kind:"reference",visibility:"public",route:"/docs/getting-started/compatibility",tags:["getting-started","compatibility"],body:`# Compatibility

ContractSpec supports modern TypeScript stacks with spec-first workflows.

## Runtimes

- Node.js 20+
- Bun 1.0+

## Frameworks

- Next.js 14+ (App Router preferred)
- Bun + Elysia or other HTTP servers

## Package managers

- bun (recommended)
- npm
- yarn
- pnpm

## AI agent modes

- claude-code
- openai-codex
- cursor
- opencode
- simple (direct LLM)

## Datastores

- PostgreSQL via Prisma
- Bring your own adapter for other databases
`}];Ie(ke);export{Ct as VSCodeExtensionPage,be as TroubleshootingPage,ve as StartHerePage,fe as InstallationPage,pe as HelloWorldPage,Ke as DeveloperToolsPage,ae as DataViewTutorialPage,K as CompatibilityPage,Y as CLIPage};
