// @bun
var s=Object.defineProperty;var i=(c)=>c;function l(c,n){this[c]=i.bind(null,n)}var m=(c,n)=>{for(var o in n)s(c,o,{get:n[o],enumerable:!0,configurable:!0,set:l.bind(n,o)})};var u=(c,n)=>()=>(c&&(n=c(c=0)),n);import{CodeBlock as a}from"@contractspec/lib.design-system";import r from"@contractspec/lib.ui-link";import{ChevronRight as d}from"lucide-react";import{jsx as e,jsxs as t}from"react/jsx-runtime";var p=[".contractspec/connect/context-pack.json",".contractspec/connect/plan-packet.json",".contractspec/connect/patch-verdict.json",".contractspec/connect/audit.ndjson",".contractspec/connect/decisions/<decisionId>/",".contractspec/adoption/catalog.json",".contractspec/adoption/overrides.json"];function y(){return t("div",{className:"space-y-8",children:[t("div",{className:"space-y-3",children:[e("h1",{className:"font-bold text-4xl",children:"Use Connect in a repo"}),e("p",{className:"text-lg text-muted-foreground",children:"Put coding-agent edits and shell commands behind task-scoped context, plan compilation, verification, and local review evidence without introducing a second control plane."})]}),t("div",{className:"card-subtle space-y-4 p-6",children:[e("h2",{className:"font-bold text-2xl",children:"What you'll build"}),t("ul",{className:"space-y-2 text-muted-foreground text-sm",children:[e("li",{children:"A workspace-level Connect config in `.contractsrc.json`."}),e("li",{children:"A reuse-first adoption check before new implementation work."}),e("li",{children:"A context and plan flow for one task."}),e("li",{children:"Verified file and shell mutations with local review/replay evidence."})]})]}),t("div",{className:"space-y-6",children:[t("div",{className:"space-y-3",children:[e("h2",{className:"font-bold text-2xl",children:"1) Enable Connect"}),e("p",{className:"text-muted-foreground text-sm",children:"Start by making the safety policy explicit. Protected paths, generated paths, review thresholds, and command rules live in the workspace config, not in editor-specific hooks."}),e(a,{language:"json",filename:".contractsrc.json",code:`{
  "connect": {
    "enabled": true,
    "storage": {
      "root": ".contractspec/connect",
      "contextPack": ".contractspec/connect/context-pack.json",
      "planPacket": ".contractspec/connect/plan-packet.json",
      "patchVerdict": ".contractspec/connect/patch-verdict.json",
      "auditFile": ".contractspec/connect/audit.ndjson",
      "reviewPacketsDir": ".contractspec/connect/review-packets"
    },
    "policy": {
      "protectedPaths": ["packages/libs/contracts-spec/**"],
      "generatedPaths": ["generated/**"],
      "smokeChecks": ["bun run typecheck"],
      "reviewThresholds": {
        "protectedPathWrite": "require_review",
        "breakingChange": "require_review",
        "destructiveCommand": "deny"
      }
    },
    "commands": {
      "allow": ["bun run typecheck"],
      "review": ["git push"],
      "deny": ["git reset --hard", "git push --force", "rm -rf"]
    },
    "adoption": {
      "enabled": true,
      "catalog": {
        "indexPath": ".contractspec/adoption/catalog.json",
        "overrideManifestPath": ".contractspec/adoption/overrides.json"
      },
      "workspaceScan": {
        "include": ["packages/**", "docs/**"],
        "exclude": ["generated/**", "dist/**"]
      },
      "families": {
        "contracts": true,
        "runtime": true,
        "sharedLibs": true
      },
      "thresholds": {
        "workspaceReuse": "permit",
        "contractspecReuse": "permit",
        "ambiguous": "require_review",
        "newImplementation": "require_review"
      }
    }
  }
}`}),e("p",{className:"text-muted-foreground text-sm",children:"Expected output: Connect has enough policy to classify writes, commands, drift, and review thresholds deterministically."})]}),t("div",{className:"space-y-3",children:[e("h2",{className:"font-bold text-2xl",children:"2) Initialize storage"}),e(a,{language:"bash",filename:"connect-init",code:"contractspec connect init --scope workspace"}),e("p",{className:"text-muted-foreground text-sm",children:"Expected output: `.contractsrc.json` is updated if needed and `.contractspec/connect/` is created."})]}),t("div",{className:"space-y-3",children:[e("h2",{className:"font-bold text-2xl",children:"3) Mirror the adoption catalog and resolve reuse first"}),e("p",{className:"text-muted-foreground text-sm",children:"Connect adoption is the reuse-first layer for authoring. Mirror the local catalog, then resolve the best existing surface for the family you are about to touch before you scaffold or invent anything new."}),e(a,{language:"bash",filename:"connect-adoption",code:`contractspec connect adoption sync --json

printf '{"goal":"Prefer an existing release helper before adding a new one"}' | \\
  contractspec connect adoption resolve --family sharedLibs --stdin --json`}),e("p",{className:"text-muted-foreground text-sm",children:"Expected output: a mirrored local adoption catalog plus a reuse recommendation that can point to an existing workspace package or a ContractSpec surface before the task reaches file mutation."})]}),t("div",{className:"space-y-3",children:[e("h2",{className:"font-bold text-2xl",children:"4) Project context and compile a plan"}),e("p",{className:"text-muted-foreground text-sm",children:"Use the task id as the thread that connects context, plan, verdict, and replay artifacts."}),e(a,{language:"bash",filename:"connect-plan",code:`contractspec connect context \\
  --task docs-connect \\
  --paths packages/libs/contracts-spec/src/control-plane/contracts.ts \\
  --json

printf '{"objective":"Document the control-plane contract surface","commands":["bun run typecheck"]}' | \\
  contractspec connect plan --task docs-connect --stdin --json`}),e("p",{className:"text-muted-foreground text-sm",children:"Expected output: a `ContextPack` and `PlanPacket` that point back to `controlPlane.intent.submit`, `controlPlane.plan.compile`, and `controlPlane.plan.verify`."})]}),t("div",{className:"space-y-3",children:[e("h2",{className:"font-bold text-2xl",children:"5) Verify file and shell mutations"}),e(a,{language:"bash",filename:"connect-verify",code:`printf '{"operation":"edit","path":"packages/libs/contracts-spec/src/control-plane/contracts.ts"}' | \\
  contractspec connect verify --task docs-connect --tool acp.fs.access --stdin --json

printf 'bun run typecheck' | \\
  contractspec connect verify --task docs-connect --tool acp.terminal.exec --stdin --json`}),e("p",{className:"text-muted-foreground text-sm",children:"Expected output: a `PatchVerdict` with `permit`, `rewrite`, `require_review`, or `deny`, plus a runtime-linked control-plane state when that linkage is available."})]}),t("div",{className:"card-subtle space-y-3 p-6",children:[e("h3",{className:"font-semibold text-lg",children:"Artifacts to inspect"}),e("ul",{className:"space-y-2 text-muted-foreground text-sm",children:p.map((c)=>e("li",{children:e("code",{children:c})},c))})]}),t("div",{className:"space-y-3",children:[e("h2",{className:"font-bold text-2xl",children:"6) Review, replay, and optional Studio sync"}),e(a,{language:"bash",filename:"connect-review-replay",code:`contractspec connect review list --json
contractspec connect replay <decisionId> --json
contractspec connect eval <decisionId> --registry ./harness-registry.ts --scenario connect.safe-refactor --json

# Optional when Studio review-bridge mode is enabled
contractspec connect review sync --decision <decisionId> --json`}),e("p",{className:"text-muted-foreground text-sm",children:"Local review packets remain authoritative. Studio sync is an operator convenience layer, not a requirement for baseline OSS safety."})]})]}),t("div",{className:"flex items-center gap-4 pt-4",children:[t(r,{href:"/docs/specs/connect",className:"btn-primary",children:["Back to Connect spec ",e(d,{size:16})]}),e(r,{href:"/docs/architecture/control-plane",className:"btn-ghost",children:"Control-plane runtime"})]})]})}export{y as GuideConnectInRepoPage};
