// @bun
import{definePrompt as D,defineResourceTemplate as B,PromptRegistry as F,ResourceRegistry as H}from"@contractspec/lib.contracts-spec";import k from"zod";var I=["@contractspec"],x=["contracts","mcp"];function L(w){let q=new H;return q.register(B({meta:{uriTemplate:"contracts://list",title:"Contract specs list",description:"JSON list of all contract specs in the workspace.",mimeType:"application/json",tags:x},input:k.object({}),resolve:async()=>{let j=await w.listSpecs();return{uri:"contracts://list",mimeType:"application/json",data:JSON.stringify(j,null,2)}}})),q.register(B({meta:{uriTemplate:"contracts://spec/{path}",title:"Contract spec content",description:"Read a single contract spec file by path.",mimeType:"text/plain",tags:x},input:k.object({path:k.string()}),resolve:async({path:j})=>{let C=await w.getSpec(j);if(!C)return{uri:`contracts://spec/${encodeURIComponent(j)}`,mimeType:"text/plain",data:`Spec not found: ${j}`};return{uri:`contracts://spec/${encodeURIComponent(j)}`,mimeType:"text/plain",data:C.content}}})),q.register(B({meta:{uriTemplate:"contracts://registry/manifest",title:"Remote registry manifest",description:"Contract registry manifest from the remote server.",mimeType:"application/json",tags:x},input:k.object({}),resolve:async()=>{let j=await w.fetchRegistryManifest();return{uri:"contracts://registry/manifest",mimeType:"application/json",data:JSON.stringify(j,null,2)}}})),q.register(B({meta:{uriTemplate:"adoption://catalog",title:"ContractSpec adoption catalog",description:"Bundled ContractSpec adoption catalog used by Connect and MCP.",mimeType:"application/json",tags:x},input:k.object({}),resolve:async()=>{let j=await w.searchAdoptionCatalog({query:"contractspec"});return{uri:"adoption://catalog",mimeType:"application/json",data:JSON.stringify(j,null,2)}}})),q.register(B({meta:{uriTemplate:"adoption://policy/{family}",title:"ContractSpec adoption policy",description:"Family-aware adoption recommendation and verdict policy.",mimeType:"application/json",tags:x},input:k.object({family:k.string()}),resolve:async({family:j})=>{let C=await w.resolveAdoption({family:j,query:j});return{uri:`adoption://policy/${encodeURIComponent(j)}`,mimeType:"application/json",data:JSON.stringify(C,null,2)}}})),q}function M(){let w=new F;return w.register(D({meta:{key:"contracts.editor",version:"1.0.0",title:"Contract editing guide",description:"Guide AI agents through reading, editing, and validating contracts.",tags:x,stability:"beta",owners:I},args:[{name:"goal",description:"What the agent wants to achieve with the contract.",required:!1,schema:k.string().optional()}],input:k.object({goal:k.string().optional()}),render:async({goal:q})=>[{type:"text",text:["Contract editing workflow:","1. Use contracts.list to discover specs","2. Use contracts.get to read a spec","3. Edit content and call contracts.update","4. Run contracts.validate to verify changes","5. Run contracts.build to regenerate artifacts","6. Use adoption.resolve to prefer existing workspace or ContractSpec surfaces before inventing new ones",q?`Agent goal: ${q}`:""].filter(Boolean).join(`
`)},{type:"resource",uri:"contracts://list",title:"Available contracts"}]})),w}export{L as buildContractsResources,M as buildContractsPrompts};
