@codified/cli 0.5.5 → 0.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +3 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1009,7 +1009,7 @@ Make sure the Codify server was started with bootstrap support enabled.`);let s=
1009
1009
  `))}),e.tool("codify_status",["Show the health and stats of the context graph.","","Displays: total nodes/edges, breakdown by type and layer, average freshness,","gap count, and graph age. Useful for understanding the state of the graph","and whether it needs attention (stale data, too many gaps, etc.)."].join(`
1010
1010
  `),{},async()=>r?st(()=>r(),i=>{let s=["## Codify Graph Status","","| Metric | Value |","|--------|-------|",`| Total nodes | **${i.totalNodes}** |`,`| Total edges | **${i.totalEdges}** |`,`| Avg freshness | **${(i.avgFreshness*100).toFixed(0)}%** |`,`| Open gaps | **${i.gapCount}** |`];if(i.totalNodes===0)s.push("","The graph is empty. Run `codify_bootstrap` to populate it from your project's git history.");else{s.push("","### Nodes by type","");for(let[a,c]of Object.entries(i.nodesByType).sort((u,l)=>l[1]-u[1]))s.push(`- ${a}: ${c}`);s.push("","### Nodes by layer","");for(let[a,c]of Object.entries(i.nodesByLayer))s.push(`- ${a}: ${c}`);i.newestNode&&s.push("",`Newest: ${i.newestNode}`),i.oldestNode&&s.push(`Oldest: ${i.oldestNode}`)}return s.join(`
1011
1011
  `)}):st(async()=>{let i=await n.search("",{limit:1}),s=await n.getGaps({limit:100});return{allNodes:i,gaps:s}},({allNodes:i,gaps:s})=>["## Codify Graph Status","",`Gaps detected: **${s.length}**`,"","For detailed stats, the graph stats service needs to be configured.","Use `codify_search` or `codify_get_context` to explore the graph."].join(`
1012
- `)))}var PF=v(()=>{"use strict";Gs();xi()});import{McpServer as CZ,ResourceTemplate as kZ}from"@modelcontextprotocol/sdk/server/mcp.js";function wg(t,e){let n,o,r,i,s,a,c;"graphService"in t?(n=t.graphService,o=t.contextRouter,r=t.bootstrapFn,i=t.graphStatsFn,s=t.collectionPlannerFn,a=t.gapQueueFn,c=t.contextPushController):(n=t,o=e);let u=new CZ({name:"codify",version:"0.5.5"},{capabilities:{tools:{},resources:{}},instructions:["Codify is a living context graph that captures your organization's decisions, features, customer signals, and code artifacts.","","USE THESE TOOLS PROACTIVELY:","- When a developer asks 'why was this built this way?' \u2192 codify_explain","- When working on a feature/file \u2192 codify_get_context to surface relevant decisions and signals","- When making a decision \u2192 codify_add_context to record it","- When something seems uncertain \u2192 codify_get_gaps to see what's missing","- When a gap needs evidence \u2192 codify_collect to mine the graph for relevant nodes","- When you need a deep briefing on an area \u2192 codify_get_context_package for a comprehensive package","- Before making a decision \u2192 codify_decision_context to assemble prior decisions, evidence, contradictions, and gaps","- On first setup \u2192 codify_bootstrap to populate the graph from git history","","The graph gets smarter over time. Every interaction adds context."].join(`
1012
+ `)))}var PF=v(()=>{"use strict";Gs();xi()});import{McpServer as CZ,ResourceTemplate as kZ}from"@modelcontextprotocol/sdk/server/mcp.js";function wg(t,e){let n,o,r,i,s,a,c;"graphService"in t?(n=t.graphService,o=t.contextRouter,r=t.bootstrapFn,i=t.graphStatsFn,s=t.collectionPlannerFn,a=t.gapQueueFn,c=t.contextPushController):(n=t,o=e);let u=new CZ({name:"codify",version:"0.5.6"},{capabilities:{tools:{},resources:{}},instructions:["Codify is a living context graph that captures your organization's decisions, features, customer signals, and code artifacts.","","USE THESE TOOLS PROACTIVELY:","- When a developer asks 'why was this built this way?' \u2192 codify_explain","- When working on a feature/file \u2192 codify_get_context to surface relevant decisions and signals","- When making a decision \u2192 codify_add_context to record it","- When something seems uncertain \u2192 codify_get_gaps to see what's missing","- When a gap needs evidence \u2192 codify_collect to mine the graph for relevant nodes","- When you need a deep briefing on an area \u2192 codify_get_context_package for a comprehensive package","- Before making a decision \u2192 codify_decision_context to assemble prior decisions, evidence, contradictions, and gaps","- On first setup \u2192 codify_bootstrap to populate the graph from git history","","The graph gets smarter over time. Every interaction adds context."].join(`
1013
1013
  `)}),l={server:u,graphService:n,contextRouter:o,bootstrapFn:r,graphStatsFn:i,collectionPlannerFn:s,gapQueueFn:a,contextPushController:c};return SF(l),$F(l),NF(l),OF(l),kF(l),DF(l),u.resource("graph-schema","codify://schema",{description:"The Codify context graph schema \u2014 node types, edge types, and their relationships",mimeType:"text/markdown"},async()=>({contents:[{uri:"codify://schema",mimeType:"text/markdown",text:["# Codify Graph Schema","","## Node Types","- **Decision**: Technical or product decisions with status, rationale, and stakeholders","- **Feature**: Product features with lifecycle status (planned \u2192 active \u2192 sunset)","- **Metric**: Quantifiable measurements with current values and targets","- **CustomerSignal**: Feedback, complaints, requests from customers","- **CodeArtifact**: Files, functions, classes, modules in the codebase","- **Discussion**: Meetings, Slack threads, PR reviews where context was shared","- **Gap**: Missing data, stale info, or contradictions that need resolution","- **Study**: User research studies with findings and methodology","- **Person**: Team members and stakeholders","","## Edge Types","### Causal","- caused_by, informed_by, evidence_for, derived_from, triggered","### Conflict","- contradicts, supersedes","### Structural","- related_to, addresses, depends_on, implements, owned_by, measured_by,"," discussed_in, blocked_by, mentions, corroborates, refines, competed_by","### Temporal","- preceded_by","","## Context Layers","- **ephemeral**: Raw signals, unprocessed (auto-expires)","- **hot**: Recently ingested, awaiting validation (TTL-based)","- **draft**: Validated but not yet promoted (gating required)","- **permanent**: Fully validated, core knowledge","","## Freshness Model","Each node has a freshness score (0.0-1.0) computed from:","- 50% Recency: exponential decay with per-type half-lives","- 30% Corroboration: how many independent sources confirm this","- 20% Source reliability: how trustworthy the original source is"].join(`
1014
1014
  `)}]})),u.resource("quickstart","codify://quickstart",{description:"Quick start guide for using Codify",mimeType:"text/markdown"},async()=>({contents:[{uri:"codify://quickstart",mimeType:"text/markdown",text:["# Codify Quick Start","","## 1. Bootstrap your project","Run `codify_bootstrap` to populate the graph from your git history.","","## 2. Explore context",'Use `codify_get_context` with any topic: "authentication", "pricing", "checkout".',"","## 3. Record decisions",'Use `codify_add_context` when you make a decision: "We chose PostgreSQL because..."',"","## 4. Check for gaps","Use `codify_get_gaps` to see what context is missing or stale.","","## 5. Ask questions",'Use `codify_explain` to ask "Why was this built this way?" about any part of the codebase.',"","The graph grows smarter over time as you use it."].join(`
1015
1015
  `)}]})),u.resource("context-topic",new kZ("codify://context/{topic}",{list:void 0}),{description:"Context package for a specific topic \u2014 returns related nodes, gaps, and relationships synthesized into a summary",mimeType:"application/json"},async(d,p)=>{let f=p.topic??"",m=Array.isArray(f)?f[0]:f,h=await n.search(m,{limit:10}),w=new Map;for(let T of h)w.set(T.id,T);for(let T of h)try{let b=await n.traverse(T.id,{direction:"both",maxDepth:2,limit:30});for(let g of b)w.has(g.id)||w.set(g.id,g)}catch{}let E=Array.from(w.values()),x=await n.getGaps({limit:10}),y=m.toLowerCase().split(/\s+/).filter(T=>T.length>1),$=y.length>0?x.filter(T=>{let g=T.properties??{},_=T.metadata??{},R=JSON.stringify({...g,..._}).toLowerCase();return y.some(C=>R.includes(C))}):x,S={};for(let T of E)S[T.type]=(S[T.type]??0)+1;let N={topic:m,nodeCount:E.length,nodesByType:S,gapCount:$.length,nodes:E.slice(0,20).map(T=>{let _={...T.properties??{},...T.metadata??{}};return{id:T.id,type:T.type,title:_.title??_.name??T.id,freshness:T.freshness,confidence:T.confidence,layer:T.layer}}),gaps:$.map(T=>{let g=T.properties??{},_=T.metadata??{};return{id:T.id,description:g.description??_.description??"No description",severity:g.severity??_.severity??"medium",status:g.status??_.status??"detected"}}),ttl:300};return{contents:[{uri:`codify://context/${encodeURIComponent(m)}`,mimeType:"application/json",text:JSON.stringify(N,null,2)}]}}),u.resource("gaps-active","codify://gaps/active",{description:"Current active gap summary \u2014 total count, top 5 by priority, any clusters",mimeType:"application/json"},async()=>{let d=null,p=null;a?d=await a({limit:50}):p=await n.getGaps({limit:50,sortBy:"severity"});let f=d??[],m=p??[],h=d?f.map($=>$.gap):m,w=h.length,E=d?f.slice(0,5).map($=>{let S=sn($.gap);return{id:$.gap.id,description:S.description??"No description",severity:S.severity??"medium",gapType:S.gapType??"unknown",priority:$.priority}}):m.slice(0,5).map($=>{let S=sn($);return{id:$.id,description:S.description??"No description",severity:S.severity??"medium",gapType:S.gapType??"unknown",priority:null}}),x=new Map;for(let $ of h){let N=sn($).clusterId;N&&x.set(N,(x.get(N)??0)+1)}let y={totalCount:w,top5:E,clusters:Array.from(x.entries()).map(([$,S])=>({clusterId:$,gapCount:S})),ttl:300};return{contents:[{uri:"codify://gaps/active",mimeType:"application/json",text:JSON.stringify(y,null,2)}]}}),u}var l0=v(()=>{"use strict";xi();xF();IF();RF();CF();AF();PF()});var Tg,Bs,d0=v(()=>{"use strict";Tg={engineering:["CodeArtifact","Decision","Feature","Discussion","Gap"],product:["Feature","CustomerSignal","Metric","Decision","Gap","Study"],design:["Feature","CustomerSignal","Discussion","Study"],sales:["CustomerSignal","Feature","Metric","Decision"],support:["CustomerSignal","Feature","CodeArtifact"],marketing:["Feature","Metric","CustomerSignal","Study"],leadership:["Decision","Metric","Feature","Gap","Study"]},Bs=class{constructor(e){this.graph=e}async getContext(e){let{topic:n,role:o,maxNodes:r=20}=e,i={limit:r*2,minFreshness:.1};return o&&Tg[o]&&(i.nodeTypes=Tg[o]),{nodes:(await this.graph.search(n,i)).map(c=>({node:c,relevanceScore:this.computeRelevanceScore(c,o)})).sort((c,u)=>u.relevanceScore-c.relevanceScore).slice(0,r),query:e}}async getDecisionTrail(e){let n=["caused_by","informed_by","evidence_for","derived_from","triggered"];return this.graph.traverse(e,{edgeTypes:n,direction:"outgoing",maxDepth:10,limit:50})}computeRelevanceScore(e,n){let o=e.freshness*.4,r=e.confidence*.3,i=.5;if(n&&Tg[n]){let s=Tg[n],a=s.indexOf(e.type);a>=0?i=1-a*(.8/s.length):i=.1}return o+r+i*.3}}});var p0,LF=v(()=>{p0=(t,e,n)=>(o,r)=>{let i=-1;return s(0);async function s(a){if(a<=i)throw new Error("next() called multiple times");i=a;let c,u=!1,l;if(t[a]?(l=t[a][0][0],o.req.routeIndex=a):l=a===t.length&&r||void 0,l)try{c=await l(o,()=>s(a+1))}catch(d){if(d instanceof Error&&e)o.error=d,c=await e(d,o),u=!0;else throw d}else o.finalized===!1&&n&&(c=await n(o));return c&&(o.finalized===!1||u)&&(o.res=c),o}}});var jF=v(()=>{});var FF,MF=v(()=>{FF=Symbol()});async function AZ(t,e){let n=await t.formData();return n?DZ(n,e):{}}function DZ(t,e){let n=Object.create(null);return t.forEach((o,r)=>{e.all||r.endsWith("[]")?PZ(n,r,o):n[r]=o}),e.dot&&Object.entries(n).forEach(([o,r])=>{o.includes(".")&&(LZ(n,o,r),delete n[o])}),n}var UF,PZ,LZ,GF=v(()=>{f0();UF=async(t,e=Object.create(null))=>{let{all:n=!1,dot:o=!1}=e,i=(t instanceof Sg?t.raw.headers:t.headers).get("Content-Type");return i?.startsWith("multipart/form-data")||i?.startsWith("application/x-www-form-urlencoded")?AZ(t,{all:n,dot:o}):{}};PZ=(t,e,n)=>{t[e]!==void 0?Array.isArray(t[e])?t[e].push(n):t[e]=[t[e],n]:e.endsWith("[]")?t[e]=[n]:t[e]=n},LZ=(t,e,n)=>{let o=t,r=e.split(".");r.forEach((i,s)=>{s===r.length-1?o[i]=n:((!o[i]||typeof o[i]!="object"||Array.isArray(o[i])||o[i]instanceof File)&&(o[i]=Object.create(null)),o=o[i])})}});var h0,BF,jZ,FZ,xg,qF,$g,MZ,g0,zF,qs,Ig,m0,VF,HF,WF,y0,du=v(()=>{h0=t=>{let e=t.split("/");return e[0]===""&&e.shift(),e},BF=t=>{let{groups:e,path:n}=jZ(t),o=h0(n);return FZ(o,e)},jZ=t=>{let e=[];return t=t.replace(/\{[^}]+\}/g,(n,o)=>{let r=`@${o}`;return e.push([r,n]),r}),{groups:e,path:t}},FZ=(t,e)=>{for(let n=e.length-1;n>=0;n--){let[o]=e[n];for(let r=t.length-1;r>=0;r--)if(t[r].includes(o)){t[r]=t[r].replace(o,e[n][1]);break}}return t},xg={},qF=(t,e)=>{if(t==="*")return"*";let n=t.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);if(n){let o=`${t}#${e}`;return xg[o]||(n[2]?xg[o]=e&&e[0]!==":"&&e[0]!=="*"?[o,n[1],new RegExp(`^${n[2]}(?=/${e})`)]:[t,n[1],new RegExp(`^${n[2]}$`)]:xg[o]=[t,n[1],!0]),xg[o]}return null},$g=(t,e)=>{try{return e(t)}catch{return t.replace(/(?:%[0-9A-Fa-f]{2})+/g,n=>{try{return e(n)}catch{return n}})}},MZ=t=>$g(t,decodeURI),g0=t=>{let e=t.url,n=e.indexOf("/",e.indexOf(":")+4),o=n;for(;o<e.length;o++){let r=e.charCodeAt(o);if(r===37){let i=e.indexOf("?",o),s=e.indexOf("#",o),a=i===-1?s===-1?void 0:s:s===-1?i:Math.min(i,s),c=e.slice(n,a);return MZ(c.includes("%25")?c.replace(/%25/g,"%2525"):c)}else if(r===63||r===35)break}return e.slice(n,o)},zF=t=>{let e=g0(t);return e.length>1&&e.at(-1)==="/"?e.slice(0,-1):e},qs=(t,e,...n)=>(n.length&&(e=qs(e,...n)),`${t?.[0]==="/"?"":"/"}${t}${e==="/"?"":`${t?.at(-1)==="/"?"":"/"}${e?.[0]==="/"?e.slice(1):e}`}`),Ig=t=>{if(t.charCodeAt(t.length-1)!==63||!t.includes(":"))return null;let e=t.split("/"),n=[],o="";return e.forEach(r=>{if(r!==""&&!/\:/.test(r))o+="/"+r;else if(/\:/.test(r))if(/\?/.test(r)){n.length===0&&o===""?n.push("/"):n.push(o);let i=r.replace("?","");o+="/"+i,n.push(o)}else o+="/"+r}),n.filter((r,i,s)=>s.indexOf(r)===i)},m0=t=>/[%+]/.test(t)?(t.indexOf("+")!==-1&&(t=t.replace(/\+/g," ")),t.indexOf("%")!==-1?$g(t,y0):t):t,VF=(t,e,n)=>{let o;if(!n&&e&&!/[%+]/.test(e)){let s=t.indexOf("?",8);if(s===-1)return;for(t.startsWith(e,s+1)||(s=t.indexOf(`&${e}`,s+1));s!==-1;){let a=t.charCodeAt(s+e.length+1);if(a===61){let c=s+e.length+2,u=t.indexOf("&",c);return m0(t.slice(c,u===-1?void 0:u))}else if(a==38||isNaN(a))return"";s=t.indexOf(`&${e}`,s+1)}if(o=/[%+]/.test(t),!o)return}let r={};o??=/[%+]/.test(t);let i=t.indexOf("?",8);for(;i!==-1;){let s=t.indexOf("&",i+1),a=t.indexOf("=",i);a>s&&s!==-1&&(a=-1);let c=t.slice(i+1,a===-1?s===-1?void 0:s:a);if(o&&(c=m0(c)),i=s,c==="")continue;let u;a===-1?u="":(u=t.slice(a+1,s===-1?void 0:s),o&&(u=m0(u))),n?(r[c]&&Array.isArray(r[c])||(r[c]=[]),r[c].push(u)):r[c]??=u}return e?r[e]:r},HF=VF,WF=(t,e)=>VF(t,e,!0),y0=decodeURIComponent});var KF,Sg,f0=v(()=>{jF();MF();GF();du();KF=t=>$g(t,y0),Sg=class{raw;#t;#e;routeIndex=0;path;bodyCache={};constructor(t,e="/",n=[[]]){this.raw=t,this.path=e,this.#e=n,this.#t={}}param(t){return t?this.#o(t):this.#n()}#o(t){let e=this.#e[0][this.routeIndex][1][t],n=this.#i(e);return n&&/\%/.test(n)?KF(n):n}#n(){let t={},e=Object.keys(this.#e[0][this.routeIndex][1]);for(let n of e){let o=this.#i(this.#e[0][this.routeIndex][1][n]);o!==void 0&&(t[n]=/\%/.test(o)?KF(o):o)}return t}#i(t){return this.#e[1]?this.#e[1][t]:t}query(t){return HF(this.url,t)}queries(t){return WF(this.url,t)}header(t){if(t)return this.raw.headers.get(t)??void 0;let e={};return this.raw.headers.forEach((n,o)=>{e[o]=n}),e}async parseBody(t){return this.bodyCache.parsedBody??=await UF(this,t)}#s=t=>{let{bodyCache:e,raw:n}=this,o=e[t];if(o)return o;let r=Object.keys(e)[0];return r?e[r].then(i=>(r==="json"&&(i=JSON.stringify(i)),new Response(i)[t]())):e[t]=n[t]()};json(){return this.#s("text").then(t=>JSON.parse(t))}text(){return this.#s("text")}arrayBuffer(){return this.#s("arrayBuffer")}blob(){return this.#s("blob")}formData(){return this.#s("formData")}addValidatedData(t,e){this.#t[t]=e}valid(t){return this.#t[t]}get url(){return this.raw.url}get method(){return this.raw.method}get[FF](){return this.#e}get matchedRoutes(){return this.#e[0].map(([[,t]])=>t)}get routePath(){return this.#e[0].map(([[,t]])=>t)[this.routeIndex].path}}});var QF,UZ,b0,YF=v(()=>{QF={Stringify:1,BeforeStream:2,Stream:3},UZ=(t,e)=>{let n=new String(t);return n.isEscaped=!0,n.callbacks=e,n},b0=async(t,e,n,o,r)=>{typeof t=="object"&&!(t instanceof String)&&(t instanceof Promise||(t=t.toString()),t instanceof Promise&&(t=await t));let i=t.callbacks;if(!i?.length)return Promise.resolve(t);r?r[0]+=t:r=[t];let s=Promise.all(i.map(a=>a({phase:e,buffer:r,context:o}))).then(a=>Promise.all(a.filter(Boolean).map(c=>b0(c,e,!1,o,r))).then(()=>r[0]));return n?UZ(await s,i):s}});var GZ,v0,Ld,JF,ZF=v(()=>{f0();YF();GZ="text/plain; charset=UTF-8",v0=(t,e)=>({"Content-Type":t,...e}),Ld=(t,e)=>new Response(t,e),JF=class{#t;#e;env={};#o;finalized=!1;error;#n;#i;#s;#c;#b;#u;#a;#r;#y;constructor(t,e){this.#t=t,e&&(this.#i=e.executionCtx,this.env=e.env,this.#u=e.notFoundHandler,this.#y=e.path,this.#r=e.matchResult)}get req(){return this.#e??=new Sg(this.#t,this.#y,this.#r),this.#e}get event(){if(this.#i&&"respondWith"in this.#i)return this.#i;throw Error("This context has no FetchEvent")}get executionCtx(){if(this.#i)return this.#i;throw Error("This context has no ExecutionContext")}get res(){return this.#s||=Ld(null,{headers:this.#a??=new Headers})}set res(t){if(this.#s&&t){t=Ld(t.body,t);for(let[e,n]of this.#s.headers.entries())if(e!=="content-type")if(e==="set-cookie"){let o=this.#s.headers.getSetCookie();t.headers.delete("set-cookie");for(let r of o)t.headers.append("set-cookie",r)}else t.headers.set(e,n)}this.#s=t,this.finalized=!0}render=(...t)=>(this.#b??=e=>this.html(e),this.#b(...t));setLayout=t=>this.#c=t;getLayout=()=>this.#c;setRenderer=t=>{this.#b=t};header=(t,e,n)=>{this.finalized&&(this.#s=Ld(this.#s.body,this.#s));let o=this.#s?this.#s.headers:this.#a??=new Headers;e===void 0?o.delete(t):n?.append?o.append(t,e):o.set(t,e)};status=t=>{this.#n=t};set=(t,e)=>{this.#o??=new Map,this.#o.set(t,e)};get=t=>this.#o?this.#o.get(t):void 0;get var(){return this.#o?Object.fromEntries(this.#o):{}}#p(t,e,n){let o=this.#s?new Headers(this.#s.headers):this.#a??new Headers;if(typeof e=="object"&&"headers"in e){let i=e.headers instanceof Headers?e.headers:new Headers(e.headers);for(let[s,a]of i)s.toLowerCase()==="set-cookie"?o.append(s,a):o.set(s,a)}if(n)for(let[i,s]of Object.entries(n))if(typeof s=="string")o.set(i,s);else{o.delete(i);for(let a of s)o.append(i,a)}let r=typeof e=="number"?e:e?.status??this.#n;return Ld(t,{status:r,headers:o})}newResponse=(...t)=>this.#p(...t);body=(t,e,n)=>this.#p(t,e,n);text=(t,e,n)=>!this.#a&&!this.#n&&!e&&!n&&!this.finalized?new Response(t):this.#p(t,e,v0(GZ,n));json=(t,e,n)=>this.#p(JSON.stringify(t),e,v0("application/json",n));html=(t,e,n)=>{let o=r=>this.#p(r,e,v0("text/html; charset=UTF-8",n));return typeof t=="object"?b0(t,QF.Stringify,!1,{}).then(o):o(t)};redirect=(t,e)=>{let n=String(t);return this.header("Location",/[^\x00-\xFF]/.test(n)?encodeURI(n):n),this.newResponse(null,e??302)};notFound=()=>(this.#u??=()=>Ld(),this.#u(this))}});var St,XF,eM,Ng,Rg,zs=v(()=>{St="ALL",XF="all",eM=["get","post","put","delete","options","patch"],Ng="Can not add a route since the matcher is already built.",Rg=class extends Error{}});var tM,nM=v(()=>{tM="__COMPOSED_HANDLER"});var BZ,rM,oM,sM=v(()=>{LF();ZF();zs();nM();du();BZ=t=>t.text("404 Not Found",404),rM=(t,e)=>{if("getResponse"in t){let n=t.getResponse();return e.newResponse(n.body,n)}return console.error(t),e.text("Internal Server Error",500)},oM=class iM{get;post;put;delete;options;patch;all;on;use;router;getPath;_basePath="/";#t="/";routes=[];constructor(e={}){[...eM,XF].forEach(i=>{this[i]=(s,...a)=>(typeof s=="string"?this.#t=s:this.#n(i,this.#t,s),a.forEach(c=>{this.#n(i,this.#t,c)}),this)}),this.on=(i,s,...a)=>{for(let c of[s].flat()){this.#t=c;for(let u of[i].flat())a.map(l=>{this.#n(u.toUpperCase(),this.#t,l)})}return this},this.use=(i,...s)=>(typeof i=="string"?this.#t=i:(this.#t="*",s.unshift(i)),s.forEach(a=>{this.#n(St,this.#t,a)}),this);let{strict:o,...r}=e;Object.assign(this,r),this.getPath=o??!0?e.getPath??g0:zF}#e(){let e=new iM({router:this.router,getPath:this.getPath});return e.errorHandler=this.errorHandler,e.#o=this.#o,e.routes=this.routes,e}#o=BZ;errorHandler=rM;route(e,n){let o=this.basePath(e);return n.routes.map(r=>{let i;n.errorHandler===rM?i=r.handler:(i=async(s,a)=>(await p0([],n.errorHandler)(s,()=>r.handler(s,a))).res,i[tM]=r.handler),o.#n(r.method,r.path,i)}),this}basePath(e){let n=this.#e();return n._basePath=qs(this._basePath,e),n}onError=e=>(this.errorHandler=e,this);notFound=e=>(this.#o=e,this);mount(e,n,o){let r,i;o&&(typeof o=="function"?i=o:(i=o.optionHandler,o.replaceRequest===!1?r=c=>c:r=o.replaceRequest));let s=i?c=>{let u=i(c);return Array.isArray(u)?u:[u]}:c=>{let u;try{u=c.executionCtx}catch{}return[c.env,u]};r||=(()=>{let c=qs(this._basePath,e),u=c==="/"?0:c.length;return l=>{let d=new URL(l.url);return d.pathname=d.pathname.slice(u)||"/",new Request(d,l)}})();let a=async(c,u)=>{let l=await n(r(c.req.raw),...s(c));if(l)return l;await u()};return this.#n(St,qs(e,"*"),a),this}#n(e,n,o){e=e.toUpperCase(),n=qs(this._basePath,n);let r={basePath:this._basePath,path:n,method:e,handler:o};this.router.add(e,n,[o,r]),this.routes.push(r)}#i(e,n){if(e instanceof Error)return this.errorHandler(e,n);throw e}#s(e,n,o,r){if(r==="HEAD")return(async()=>new Response(null,await this.#s(e,n,o,"GET")))();let i=this.getPath(e,{env:o}),s=this.router.match(r,i),a=new JF(e,{path:i,matchResult:s,env:o,executionCtx:n,notFoundHandler:this.#o});if(s[0].length===1){let u;try{u=s[0][0][0][0](a,async()=>{a.res=await this.#o(a)})}catch(l){return this.#i(l,a)}return u instanceof Promise?u.then(l=>l||(a.finalized?a.res:this.#o(a))).catch(l=>this.#i(l,a)):u??this.#o(a)}let c=p0(s[0],this.errorHandler,this.#o);return(async()=>{try{let u=await c(a);if(!u.finalized)throw new Error("Context is not finalized. Did you forget to return a Response object or `await next()`?");return u.res}catch(u){return this.#i(u,a)}})()}fetch=(e,...n)=>this.#s(e,n[1],n[0],e.method);request=(e,n,o,r)=>e instanceof Request?this.fetch(n?new Request(e,n):e,o,r):(e=e.toString(),this.fetch(new Request(/^https?:\/\//.test(e)?e:`http://localhost${qs("/",e)}`,n),o,r));fire=()=>{addEventListener("fetch",e=>{e.respondWith(this.#s(e.request,e,void 0,e.request.method))})}}});function _0(t,e){let n=this.buildAllMatchers(),o=((r,i)=>{let s=n[r]||n[St],a=s[2][i];if(a)return a;let c=i.match(s[0]);if(!c)return[[],Og];let u=c.indexOf("",1);return[s[1][u],c]});return this.match=o,o(t,e)}var Og,E0=v(()=>{zs();Og=[]});function zZ(t,e){return t.length===1?e.length===1?t<e?-1:1:-1:e.length===1||t===jd||t===Fd?1:e===jd||e===Fd?-1:t===Cg?1:e===Cg?-1:t.length===e.length?t<e?-1:1:e.length-t.length}var Cg,jd,Fd,Vs,qZ,aM,T0=v(()=>{Cg="[^/]+",jd=".*",Fd="(?:|/.*)",Vs=Symbol(),qZ=new Set(".\\+*[^]$()");aM=class w0{#t;#e;#o=Object.create(null);insert(e,n,o,r,i){if(e.length===0){if(this.#t!==void 0)throw Vs;if(i)return;this.#t=n;return}let[s,...a]=e,c=s==="*"?a.length===0?["","",jd]:["","",Cg]:s==="/*"?["","",Fd]:s.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/),u;if(c){let l=c[1],d=c[2]||Cg;if(l&&c[2]&&(d===".*"||(d=d.replace(/^\((?!\?:)(?=[^)]+\)$)/,"(?:"),/\((?!\?:)/.test(d))))throw Vs;if(u=this.#o[d],!u){if(Object.keys(this.#o).some(p=>p!==jd&&p!==Fd))throw Vs;if(i)return;u=this.#o[d]=new w0,l!==""&&(u.#e=r.varIndex++)}!i&&l!==""&&o.push([l,u.#e])}else if(u=this.#o[s],!u){if(Object.keys(this.#o).some(l=>l.length>1&&l!==jd&&l!==Fd))throw Vs;if(i)return;u=this.#o[s]=new w0}u.insert(a,n,o,r,i)}buildRegExpStr(){let n=Object.keys(this.#o).sort(zZ).map(o=>{let r=this.#o[o];return(typeof r.#e=="number"?`(${o})@${r.#e}`:qZ.has(o)?`\\${o}`:o)+r.buildRegExpStr()});return typeof this.#t=="number"&&n.unshift(`#${this.#t}`),n.length===0?"":n.length===1?n[0]:"(?:"+n.join("|")+")"}}});var cM,uM=v(()=>{T0();cM=class{#t={varIndex:0};#e=new aM;insert(t,e,n){let o=[],r=[];for(let s=0;;){let a=!1;if(t=t.replace(/\{[^}]+\}/g,c=>{let u=`@\\${s}`;return r[s]=[u,c],s++,a=!0,u}),!a)break}let i=t.match(/(?::[^\/]+)|(?:\/\*$)|./g)||[];for(let s=r.length-1;s>=0;s--){let[a]=r[s];for(let c=i.length-1;c>=0;c--)if(i[c].indexOf(a)!==-1){i[c]=i[c].replace(a,r[s][1]);break}}return this.#e.insert(i,e,o,this.#t,n),o}buildRegExp(){let t=this.#e.buildRegExpStr();if(t==="")return[/^$/,[],[]];let e=0,n=[],o=[];return t=t.replace(/#(\d+)|@(\d+)|\.\*\$/g,(r,i,s)=>i!==void 0?(n[++e]=Number(i),"$()"):(s!==void 0&&(o[Number(s)]=++e),"")),[new RegExp(`^${t}`),n,o]}}});function dM(t){return lM[t]??=new RegExp(t==="*"?"":`^${t.replace(/\/\*$|([.\\+*[^\]$()])/g,(e,n)=>n?`\\${n}`:"(?:|/.*)")}$`)}function HZ(){lM=Object.create(null)}function WZ(t){let e=new cM,n=[];if(t.length===0)return VZ;let o=t.map(u=>[!/\*|\/:/.test(u[0]),...u]).sort(([u,l],[d,p])=>u?1:d?-1:l.length-p.length),r=Object.create(null);for(let u=0,l=-1,d=o.length;u<d;u++){let[p,f,m]=o[u];p?r[f]=[m.map(([w])=>[w,Object.create(null)]),Og]:l++;let h;try{h=e.insert(f,l,p)}catch(w){throw w===Vs?new Rg(f):w}p||(n[l]=m.map(([w,E])=>{let x=Object.create(null);for(E-=1;E>=0;E--){let[y,$]=h[E];x[y]=$}return[w,x]}))}let[i,s,a]=e.buildRegExp();for(let u=0,l=n.length;u<l;u++)for(let d=0,p=n[u].length;d<p;d++){let f=n[u][d]?.[1];if(!f)continue;let m=Object.keys(f);for(let h=0,w=m.length;h<w;h++)f[m[h]]=a[f[m[h]]]}let c=[];for(let u in s)c[u]=n[s[u]];return[i,c,r]}function pu(t,e){if(t){for(let n of Object.keys(t).sort((o,r)=>r.length-o.length))if(dM(n).test(e))return[...t[n]]}}var VZ,lM,kg,S0=v(()=>{zs();du();E0();T0();uM();VZ=[/^$/,[],Object.create(null)],lM=Object.create(null);kg=class{name="RegExpRouter";#t;#e;constructor(){this.#t={[St]:Object.create(null)},this.#e={[St]:Object.create(null)}}add(t,e,n){let o=this.#t,r=this.#e;if(!o||!r)throw new Error(Ng);o[t]||[o,r].forEach(a=>{a[t]=Object.create(null),Object.keys(a[St]).forEach(c=>{a[t][c]=[...a[St][c]]})}),e==="/*"&&(e="*");let i=(e.match(/\/:/g)||[]).length;if(/\*$/.test(e)){let a=dM(e);t===St?Object.keys(o).forEach(c=>{o[c][e]||=pu(o[c],e)||pu(o[St],e)||[]}):o[t][e]||=pu(o[t],e)||pu(o[St],e)||[],Object.keys(o).forEach(c=>{(t===St||t===c)&&Object.keys(o[c]).forEach(u=>{a.test(u)&&o[c][u].push([n,i])})}),Object.keys(r).forEach(c=>{(t===St||t===c)&&Object.keys(r[c]).forEach(u=>a.test(u)&&r[c][u].push([n,i]))});return}let s=Ig(e)||[e];for(let a=0,c=s.length;a<c;a++){let u=s[a];Object.keys(r).forEach(l=>{(t===St||t===l)&&(r[l][u]||=[...pu(o[l],u)||pu(o[St],u)||[]],r[l][u].push([n,i-c+a+1]))})}}match=_0;buildAllMatchers(){let t=Object.create(null);return Object.keys(this.#e).concat(Object.keys(this.#t)).forEach(e=>{t[e]||=this.#o(e)}),this.#t=this.#e=void 0,HZ(),t}#o(t){let e=[],n=t===St;return[this.#t,this.#e].forEach(o=>{let r=o[t]?Object.keys(o[t]).map(i=>[i,o[t][i]]):[];r.length!==0?(n||=!0,e.push(...r)):t!==St&&e.push(...Object.keys(o[St]).map(i=>[i,o[St][i]]))}),n?WZ(e):null}}});var pM=v(()=>{zs();E0();S0()});var fM=v(()=>{S0();pM()});var x0,mM=v(()=>{zs();x0=class{name="SmartRouter";#t=[];#e=[];constructor(t){this.#t=t.routers}add(t,e,n){if(!this.#e)throw new Error(Ng);this.#e.push([t,e,n])}match(t,e){if(!this.#e)throw new Error("Fatal error");let n=this.#t,o=this.#e,r=n.length,i=0,s;for(;i<r;i++){let a=n[i];try{for(let c=0,u=o.length;c<u;c++)a.add(...o[c]);s=a.match(t,e)}catch(c){if(c instanceof Rg)continue;throw c}this.match=a.match.bind(a),this.#t=[a],this.#e=void 0;break}if(i===r)throw new Error("Fatal error");return this.name=`SmartRouter + ${this.activeRouter.name}`,s}get activeRouter(){if(this.#e||this.#t.length!==1)throw new Error("No active router has been determined yet.");return this.#t[0]}}});var hM=v(()=>{mM()});var Md,KZ,gM,bM=v(()=>{zs();du();Md=Object.create(null),KZ=t=>{for(let e in t)return!0;return!1},gM=class yM{#t;#e;#o;#n=0;#i=Md;constructor(e,n,o){if(this.#e=o||Object.create(null),this.#t=[],e&&n){let r=Object.create(null);r[e]={handler:n,possibleKeys:[],score:0},this.#t=[r]}this.#o=[]}insert(e,n,o){this.#n=++this.#n;let r=this,i=BF(n),s=[];for(let a=0,c=i.length;a<c;a++){let u=i[a],l=i[a+1],d=qF(u,l),p=Array.isArray(d)?d[0]:u;if(p in r.#e){r=r.#e[p],d&&s.push(d[1]);continue}r.#e[p]=new yM,d&&(r.#o.push(d),s.push(d[1])),r=r.#e[p]}return r.#t.push({[e]:{handler:o,possibleKeys:s.filter((a,c,u)=>u.indexOf(a)===c),score:this.#n}}),r}#s(e,n,o,r,i){for(let s=0,a=n.#t.length;s<a;s++){let c=n.#t[s],u=c[o]||c[St],l={};if(u!==void 0&&(u.params=Object.create(null),e.push(u),r!==Md||i&&i!==Md))for(let d=0,p=u.possibleKeys.length;d<p;d++){let f=u.possibleKeys[d],m=l[u.score];u.params[f]=i?.[f]&&!m?i[f]:r[f]??i?.[f],l[u.score]=!0}}}search(e,n){let o=[];this.#i=Md;let i=[this],s=h0(n),a=[],c=s.length,u=null;for(let l=0;l<c;l++){let d=s[l],p=l===c-1,f=[];for(let h=0,w=i.length;h<w;h++){let E=i[h],x=E.#e[d];x&&(x.#i=E.#i,p?(x.#e["*"]&&this.#s(o,x.#e["*"],e,E.#i),this.#s(o,x,e,E.#i)):f.push(x));for(let y=0,$=E.#o.length;y<$;y++){let S=E.#o[y],N=E.#i===Md?{}:{...E.#i};if(S==="*"){let R=E.#e["*"];R&&(this.#s(o,R,e,E.#i),R.#i=N,f.push(R));continue}let[T,b,g]=S;if(!d&&!(g instanceof RegExp))continue;let _=E.#e[T];if(g instanceof RegExp){if(u===null){u=new Array(c);let A=n[0]==="/"?1:0;for(let j=0;j<c;j++)u[j]=A,A+=s[j].length+1}let R=n.substring(u[l]),C=g.exec(R);if(C){if(N[b]=C[0],this.#s(o,_,e,E.#i,N),KZ(_.#e)){_.#i=N;let A=C[0].match(/\//)?.length??0;(a[A]||=[]).push(_)}continue}}(g===!0||g.test(d))&&(N[b]=d,p?(this.#s(o,_,e,N,E.#i),_.#e["*"]&&this.#s(o,_.#e["*"],e,N,E.#i)):(_.#i=N,f.push(_)))}}let m=a.shift();i=m?f.concat(m):f}return o.length>1&&o.sort((l,d)=>l.score-d.score),[o.map(({handler:l,params:d})=>[l,d])]}}});var $0,vM=v(()=>{du();bM();$0=class{name="TrieRouter";#t;constructor(){this.#t=new gM}add(t,e,n){let o=Ig(e);if(o){for(let r=0,i=o.length;r<i;r++)this.#t.insert(t,o[r],n);return}this.#t.insert(t,e,n)}match(t,e){return this.#t.search(t,e)}}});var _M=v(()=>{vM()});var fu,EM=v(()=>{sM();fM();hM();_M();fu=class extends oM{constructor(t={}){super(t),this.router=t.router??new x0({routers:[new kg,new $0]})}}});var wM={};Tt(wM,{Hono:()=>fu});var Ag=v(()=>{EM()});var SM={};Tt(SM,{createGitHubWebhookHandler:()=>I0});import{createHmac as QZ,timingSafeEqual as YZ}from"node:crypto";function XZ(t,e,n){if(!e)return!1;let o="sha256="+QZ("sha256",n).update(t).digest("hex"),r=Buffer.from(e),i=Buffer.from(o);return r.length!==i.length?!1:YZ(r,i)}function I0(t){let e=new fu,n=new Ti;return e.post("/webhooks/github",async o=>{let r=process.env.GITHUB_WEBHOOK_SECRET,i=await o.req.text();if(r){let d=o.req.header("x-hub-signature-256");if(!XZ(i,d,r))return console.log("[webhook:github] Signature verification failed"),o.json({error:"Invalid signature"},401)}let s=o.req.header("x-github-event"),a=o.req.header("x-github-delivery")??"unknown";if(!s)return o.json({error:"Missing x-github-event header"},400);if(!JZ.has(s))return console.log(`[webhook:github] Ignoring unsupported event: ${s} (delivery: ${a})`),o.json({ok:!0,ignored:!0,event:s});let c;try{c=JSON.parse(i)}catch{return o.json({error:"Invalid JSON body"},400)}if(s==="pull_request"){let d=c.action;if(!d||!ZZ.has(d))return console.log(`[webhook:github] Ignoring pull_request action: ${d} (delivery: ${a})`),o.json({ok:!0,ignored:!0,event:s,action:d})}let u=n.handleWebhook(c);if(u.length===0)return console.log(`[webhook:github] No artifacts extracted from ${s} event (delivery: ${a})`),o.json({ok:!0,artifacts:0});let l=c.repository?.full_name??"unknown";if(console.log(`[webhook:github] ${s} from ${l}: ${u.length} artifact(s) (delivery: ${a})`),t?.eventBus)try{let d=t.eventBus.connection.getConnection(),f=new TextEncoder().encode(JSON.stringify({source:"github-webhook",deliveryId:a,eventType:s,repo:l,artifacts:u,receivedAt:new Date().toISOString()}));d.publish(TM,f),console.log(`[webhook:github] Published ${u.length} artifact(s) to ${TM}`)}catch(d){console.error("[webhook:github] Failed to publish to NATS:",d)}else{console.log("[webhook:github] No event bus configured \u2014 artifacts logged but not published");for(let d of u)console.log(` [webhook:github] Artifact: ${d.artifactType} ${d.externalId}`)}return o.json({ok:!0,event:s,deliveryId:a,artifacts:u.length})}),e}var JZ,ZZ,TM,N0=v(()=>{"use strict";Ag();pr();JZ=new Set(["push","pull_request"]),ZZ=new Set(["opened","closed","reopened","synchronize"]),TM="ingest.webhook.artifacts"});var PM={};Tt(PM,{RequestError:()=>Li,createAdaptorServer:()=>DM,getRequestListener:()=>AM,serve:()=>yX});import{createServer as eX}from"http";import{Http2ServerRequest as tX}from"http2";import{Http2ServerRequest as R0}from"http2";import{Readable as xM}from"stream";import fX from"crypto";async function lX(t){return Promise.race([t,Promise.resolve().then(()=>Promise.resolve(void 0))])}function RM(t,e,n){let o=a=>{t.cancel(a).catch(()=>{})};return e.on("close",o),e.on("error",o),(n??t.read()).then(s,r),t.closed.finally(()=>{e.off("close",o),e.off("error",o)});function r(a){a&&e.destroy(a)}function i(){t.read().then(s,r)}function s({done:a,value:c}){try{if(a)e.end();else if(!e.write(c))e.once("drain",i);else return t.read().then(s,r)}catch(u){r(u)}}}function dX(t,e){if(t.locked)throw new TypeError("ReadableStream is locked.");return e.destroyed?void 0:RM(t.getReader(),e)}var Li,nX,rX,Ud,oX,IM,iX,gu,sX,Dg,Pg,aX,hu,cX,Lg,uX,$M,mu,Hs,k0,Gd,O0,pX,A0,mX,OM,C0,CM,kM,hX,gX,AM,DM,yX,LM=v(()=>{Li=class extends Error{constructor(t,e){super(t,e),this.name="RequestError"}},nX=t=>t instanceof Li?t:new Li(t.message,{cause:t}),rX=global.Request,Ud=class extends rX{constructor(t,e){typeof t=="object"&&gu in t&&(t=t[gu]()),typeof e?.body?.getReader<"u"&&(e.duplex??="half"),super(t,e)}},oX=t=>{let e=[],n=t.rawHeaders;for(let o=0;o<n.length;o+=2){let{[o]:r,[o+1]:i}=n;r.charCodeAt(0)!==58&&e.push([r,i])}return new Headers(e)},IM=Symbol("wrapBodyStream"),iX=(t,e,n,o,r)=>{let i={method:t,headers:n,signal:r.signal};if(t==="TRACE"){i.method="GET";let s=new Ud(e,i);return Object.defineProperty(s,"method",{get(){return"TRACE"}}),s}if(!(t==="GET"||t==="HEAD"))if("rawBody"in o&&o.rawBody instanceof Buffer)i.body=new ReadableStream({start(s){s.enqueue(o.rawBody),s.close()}});else if(o[IM]){let s;i.body=new ReadableStream({async pull(a){try{s||=xM.toWeb(o).getReader();let{done:c,value:u}=await s.read();c?a.close():a.enqueue(u)}catch(c){a.error(c)}}})}else i.body=xM.toWeb(o);return new Ud(e,i)},gu=Symbol("getRequestCache"),sX=Symbol("requestCache"),Dg=Symbol("incomingKey"),Pg=Symbol("urlKey"),aX=Symbol("headersKey"),hu=Symbol("abortControllerKey"),cX=Symbol("getAbortController"),Lg={get method(){return this[Dg].method||"GET"},get url(){return this[Pg]},get headers(){return this[aX]||=oX(this[Dg])},[cX](){return this[gu](),this[hu]},[gu](){return this[hu]||=new AbortController,this[sX]||=iX(this.method,this[Pg],this.headers,this[Dg],this[hu])}};["body","bodyUsed","cache","credentials","destination","integrity","mode","redirect","referrer","referrerPolicy","signal","keepalive"].forEach(t=>{Object.defineProperty(Lg,t,{get(){return this[gu]()[t]}})});["arrayBuffer","blob","clone","formData","json","text"].forEach(t=>{Object.defineProperty(Lg,t,{value:function(){return this[gu]()[t]()}})});Object.setPrototypeOf(Lg,Ud.prototype);uX=(t,e)=>{let n=Object.create(Lg);n[Dg]=t;let o=t.url||"";if(o[0]!=="/"&&(o.startsWith("http://")||o.startsWith("https://"))){if(t instanceof R0)throw new Li("Absolute URL for :path is not allowed in HTTP/2");try{let a=new URL(o);n[Pg]=a.href}catch(a){throw new Li("Invalid absolute URL",{cause:a})}return n}let r=(t instanceof R0?t.authority:t.headers.host)||e;if(!r)throw new Li("Missing host header");let i;if(t instanceof R0){if(i=t.scheme,!(i==="http"||i==="https"))throw new Li("Unsupported scheme")}else i=t.socket&&t.socket.encrypted?"https":"http";let s=new URL(`${i}://${r}${o}`);if(s.hostname.length!==r.length&&s.hostname!==r.replace(/:\d+$/,""))throw new Li("Invalid host header");return n[Pg]=s.href,n},$M=Symbol("responseCache"),mu=Symbol("getResponseCache"),Hs=Symbol("cache"),k0=global.Response,Gd=class NM{#t;#e;[mu](){return delete this[Hs],this[$M]||=new k0(this.#t,this.#e)}constructor(e,n){let o;if(this.#t=e,n instanceof NM){let r=n[$M];if(r){this.#e=r,this[mu]();return}else this.#e=n.#e,o=new Headers(n.#e.headers)}else this.#e=n;(typeof e=="string"||typeof e?.getReader<"u"||e instanceof Blob||e instanceof Uint8Array)&&(this[Hs]=[n?.status||200,e,o||n?.headers])}get headers(){let e=this[Hs];return e?(e[2]instanceof Headers||(e[2]=new Headers(e[2]||{"content-type":"text/plain; charset=UTF-8"})),e[2]):this[mu]().headers}get status(){return this[Hs]?.[0]??this[mu]().status}get ok(){let e=this.status;return e>=200&&e<300}};["body","bodyUsed","redirected","statusText","trailers","type","url"].forEach(t=>{Object.defineProperty(Gd.prototype,t,{get(){return this[mu]()[t]}})});["arrayBuffer","blob","clone","formData","json","text"].forEach(t=>{Object.defineProperty(Gd.prototype,t,{value:function(){return this[mu]()[t]()}})});Object.setPrototypeOf(Gd,k0);Object.setPrototypeOf(Gd.prototype,k0.prototype);O0=t=>{let e={};t instanceof Headers||(t=new Headers(t??void 0));let n=[];for(let[o,r]of t)o==="set-cookie"?n.push(r):e[o]=r;return n.length>0&&(e["set-cookie"]=n),e["content-type"]??="text/plain; charset=UTF-8",e},pX="x-hono-already-sent";typeof global.crypto>"u"&&(global.crypto=fX);A0=Symbol("outgoingEnded"),mX=()=>new Response(null,{status:400}),OM=t=>new Response(null,{status:t instanceof Error&&(t.name==="TimeoutError"||t.constructor.name==="TimeoutError")?504:500}),C0=(t,e)=>{let n=t instanceof Error?t:new Error("unknown error",{cause:t});n.code==="ERR_STREAM_PREMATURE_CLOSE"?console.info("The user aborted a request."):(console.error(t),e.headersSent||e.writeHead(500,{"Content-Type":"text/plain"}),e.end(`Error: ${n.message}`),e.destroy(n))},CM=t=>{"flushHeaders"in t&&t.writable&&t.flushHeaders()},kM=async(t,e)=>{let[n,o,r]=t[Hs],i=!1;if(!r)r={"content-type":"text/plain; charset=UTF-8"};else if(r instanceof Headers)i=r.has("content-length"),r=O0(r);else if(Array.isArray(r)){let s=new Headers(r);i=s.has("content-length"),r=O0(s)}else for(let s in r)if(s.length===14&&s.toLowerCase()==="content-length"){i=!0;break}i||(typeof o=="string"?r["Content-Length"]=Buffer.byteLength(o):o instanceof Uint8Array?r["Content-Length"]=o.byteLength:o instanceof Blob&&(r["Content-Length"]=o.size)),e.writeHead(n,r),typeof o=="string"||o instanceof Uint8Array?e.end(o):o instanceof Blob?e.end(new Uint8Array(await o.arrayBuffer())):(CM(e),await dX(o,e)?.catch(s=>C0(s,e))),e[A0]?.()},hX=t=>typeof t.then=="function",gX=async(t,e,n={})=>{if(hX(t))if(n.errorHandler)try{t=await t}catch(r){let i=await n.errorHandler(r);if(!i)return;t=i}else t=await t.catch(OM);if(Hs in t)return kM(t,e);let o=O0(t.headers);if(t.body){let r=t.body.getReader(),i=[],s=!1,a;if(o["transfer-encoding"]!=="chunked"){let c=2;for(let u=0;u<c;u++){a||=r.read();let l=await lX(a).catch(d=>{console.error(d),s=!0});if(!l){if(u===1){await new Promise(d=>setTimeout(d)),c=3;continue}break}if(a=void 0,l.value&&i.push(l.value),l.done){s=!0;break}}s&&!("content-length"in o)&&(o["content-length"]=i.reduce((u,l)=>u+l.length,0))}e.writeHead(t.status,o),i.forEach(c=>{e.write(c)}),s?e.end():(i.length===0&&CM(e),await RM(r,e,a))}else o[pX]||(e.writeHead(t.status,o),e.end());e[A0]?.()},AM=(t,e={})=>{let n=e.autoCleanupIncoming??!0;return e.overrideGlobalObjects!==!1&&global.Request!==Ud&&(Object.defineProperty(global,"Request",{value:Ud}),Object.defineProperty(global,"Response",{value:Gd})),async(o,r)=>{let i,s;try{s=uX(o,e.hostname);let a=!n||o.method==="GET"||o.method==="HEAD";if(a||(o[IM]=!0,o.on("end",()=>{a=!0}),o instanceof tX&&(r[A0]=()=>{a||setTimeout(()=>{a||setTimeout(()=>{o.destroy(),r.destroy()})})})),r.on("close",()=>{s[hu]&&(o.errored?s[hu].abort(o.errored.toString()):r.writableFinished||s[hu].abort("Client connection prematurely closed.")),a||setTimeout(()=>{a||setTimeout(()=>{o.destroy()})})}),i=t(s,{incoming:o,outgoing:r}),Hs in i)return kM(i,r)}catch(a){if(i)return C0(a,r);if(e.errorHandler){if(i=await e.errorHandler(s?a:nX(a)),!i)return}else s?i=OM(a):i=mX()}try{return await gX(i,r,e)}catch(a){return C0(a,r)}}},DM=t=>{let e=t.fetch,n=AM(e,{hostname:t.hostname,overrideGlobalObjects:t.overrideGlobalObjects,autoCleanupIncoming:t.autoCleanupIncoming});return(t.createServer||eX)(t.serverOptions||{},n)},yX=(t,e)=>{let n=DM(t);return n.listen(t?.port??3e3,t.hostname,()=>{let o=n.address();e&&e(o)}),n}});var ji,jM,FM,MM,UM,Bd,jg,Fg,bX,vX,_X,EX,Mg,D0=v(()=>{ji={red:"\x1B[31m",yellow:"\x1B[33m",magenta:"\x1B[35m",cyan:"\x1B[36m",reset:"\x1B[0m"},jM=ji.yellow+"WARN"+ji.reset,FM=ji.cyan+"INFO"+ji.reset,MM=ji.red+"ERR"+ji.reset,UM=ji.magenta+"DEBUG"+ji.reset,Bd={debug:0,info:1,warn:2,error:3,silent:4},jg=()=>{},Fg=t=>(...e)=>console.log(t,...e),bX=console.debug?(...t)=>console.debug(UM,...t):Fg(UM),vX=console.info?(...t)=>console.info(FM,...t):Fg(FM),_X=console.warn?(...t)=>console.warn(jM,...t):Fg(jM),EX=console.error?(...t)=>console.error(MM,...t):Fg(MM),Mg=(t=globalThis.process?.env.DEBUG==="1"?"debug":"info")=>{let e=Bd[t];return{debug:e>Bd.debug?jg:bX,info:e>Bd.info?jg:vX,warn:e>Bd.warn?jg:_X,error:e>Bd.error?jg:EX}}});function Ye(t){return t?.then!=null}function wX(t){let e=t;return e&&e.then&&e.catch&&e.finally}function oe(t,e,n,o){let r=Ue().then(t).then(e,n);return o&&(r=r.finally(o)),zd(r)}function Ue(t){return t&&wX(t)?t:Ye(t)?{then:(e,n)=>Ue(t.then(e,n)),catch:e=>Ue(t.then(n=>n,e)),finally:e=>Ue(e?xX(t,e):t),[Symbol.toStringTag]:"Promise"}:{then(e){if(e)try{return Ue(e(t))}catch(n){return yo(n)}return this},catch(){return this},finally(e){if(e)try{return Ue(e()).then(()=>t,()=>t)}catch(n){return yo(n)}return this},[Symbol.toStringTag]:"Promise",__fakePromiseValue:t,[Ug]:"resolved"}}function qd(){if(Promise.withResolvers)return Promise.withResolvers();let t,e;return{promise:new Promise(function(r,i){t=r,e=i}),get resolve(){return t},get reject(){return e}}}function Ut(t,e,n){if(t?.length===0)return;let o=t[Symbol.iterator](),r=0;function i(){let{done:s,value:a}=o.next();if(s)return;let c=!1;function u(){c=!0}return oe(function(){return e(a,u,r++)},function(d){if(d&&n?.push(d),!c)return i()})}return i()}function yo(t){return{then(e,n){if(n)try{return Ue(n(t))}catch(o){return yo(o)}return this},catch(e){if(e)try{return Ue(e(t))}catch(n){return yo(n)}return this},finally(e){if(e)try{e()}catch(n){return yo(n)}return this},__fakeRejectError:t,[Symbol.toStringTag]:"Promise",[Ug]:"rejected"}}function Wo(t,e,n,o){Symbol.asyncIterator in t&&(t=t[Symbol.asyncIterator]());let r,i,s;if(o){let u;s=l=>(u||=oe(o,()=>l,()=>l),u)}typeof t.return=="function"&&(r=t.return,i=u=>{let l=()=>{throw u};return r.call(t).then(l,l)});function a(u){return u.done?s?s(u):u:oe(()=>u.value,l=>oe(()=>e(l),GM,i))}let c;if(n){let u,l=n;c=d=>(u||=oe(()=>d,p=>oe(()=>l(p),GM,i)),u)}return{next(){return t.next().then(a,c)},return(){let u=r?r.call(t).then(a,c):Ue({value:void 0,done:!0});return s?u.then(s):u},throw(u){return typeof t.throw=="function"?t.throw(u).then(a,c):i?i(u):yo(u)},[Symbol.asyncIterator](){return this}}}function GM(t){return{value:t,done:!1}}function TX(t){return t?.[Ug]==="resolved"}function SX(t){return t?.[Ug]==="rejected"}function xX(t,e){return"finally"in t?t.finally(e):t.then(n=>{let o=e();return Ye(o)?o.then(()=>n):n},n=>{let o=e();if(Ye(o))return o.then(()=>{throw n});throw n})}function zd(t){if(TX(t))return t.__fakePromiseValue;if(SX(t))throw t.__fakeRejectError;return t}var Ug,dt=v(()=>{Ug=Symbol.for("@whatwg-node/promise-helpers/FakePromise")});var BM,qM=v(()=>{BM='<!doctype html><html lang=en><head><meta charset=utf-8><title>__TITLE__</title><link rel=icon href=https://raw.githubusercontent.com/graphql-hive/graphql-yoga/refs/heads/main/website/src/app/favicon.ico><link crossorigin rel=stylesheet href=https://unpkg.com/@graphql-yoga/graphiql@4.4.4/dist/graphiql.css></head><body id=body class=no-focus-outline><noscript>You need to enable JavaScript to run this app.</noscript><div id=root>Loading __TITLE__...</div><script>function prepareBlob(r){const o=new Blob([r],{type:"application/javascript"});return URL.createObjectURL(o)}const workers={},workerUrls={editorWorkerService:"https://unpkg.com/@graphql-yoga/graphiql@4.4.4/dist/monacoeditorwork/editor.worker.bundle.js",json:"https://unpkg.com/@graphql-yoga/graphiql@4.4.4/dist/monacoeditorwork/json.worker.bundle.js",graphql:"https://unpkg.com/@graphql-yoga/graphiql@4.4.4/dist/monacoeditorwork/graphql.worker..bundle.js"};function prepareWorkers(){return Promise.all(Object.entries(workerUrls).map(async([r,o])=>{const e=await fetch(o),t=await e.text();workers[r]=prepareBlob(t)}))}self.MonacoEnvironment={globalAPI:!1,getWorkerUrl:function(r,o){return workers[o]}}</script><script src=https://unpkg.com/@graphql-yoga/graphiql@4.4.4/dist/yoga-graphiql.umd.js></script><script>prepareWorkers().finally(()=>{YogaGraphiQL.renderYogaGraphiQL(root,__OPTS__)})</script></body></html>'});function $X({headers:t,method:e}){return e==="GET"&&!!t?.get("accept")?.includes("text/html")}function zM(t){let e=t.logger??console,n;typeof t?.options=="function"?n=t?.options:typeof t?.options=="object"?n=()=>t?.options:t?.options===!1?n=()=>!1:n=()=>({});let o=t?.render??IX,r,i=({URLPattern:s})=>(r||=new s({pathname:t.graphqlEndpoint}),r);return{onRequest({request:s,serverContext:a,fetchAPI:c,endResponse:u,url:l}){if($X(s)&&(s.url.endsWith(t.graphqlEndpoint)||s.url.endsWith(`${t.graphqlEndpoint}/`)||l.pathname===t.graphqlEndpoint||l.pathname===`${t.graphqlEndpoint}/`||i(c).test(l)))return e.debug("Rendering GraphiQL"),oe(()=>n(s,a),d=>{if(d)return oe(()=>o({...d===!0?{}:d}),p=>{let f=new c.Response(p,{headers:{"Content-Type":"text/html"},status:200});u(f)})})}}}var IX,VM=v(()=>{dt();qM();IX=t=>BM.replace("__TITLE__",t?.title||"Yoga GraphiQL").replace("__OPTS__",JSON.stringify(t??{}))});function P0(t){return t?.[Symbol.toStringTag]==="GraphQLSchema"}var HM,WM=v(()=>{dt();HM=t=>{if(t==null)return{};if(P0(t))return{onPluginInit({setSchema:e}){e(t)}};if("then"in t){let e;return{onRequestParse(){return{onRequestParseDone(){if(!e)return oe(()=>t,n=>{e=n})}}},onEnveloped({setSchema:n}){if(e==null)throw new Error("You provide a promise of a schema but it hasn't been resolved yet. Make sure you use this plugin with GraphQL Yoga.");if(!P0(e))throw new Error("The resolved schema is not a valid GraphQLSchema instance.");n(e)}}}if(typeof t=="function"){let e=new WeakMap;return{onRequestParse({request:n,serverContext:o}){return{onRequestParseDone(){return oe(()=>t({...o,request:n}),r=>{if(!P0(r))throw new Error("The factory function did not return a valid GraphQLSchema.");e.set(n,r)})}}},onEnveloped({setSchema:n,context:o}){if(o?.request==null)throw new Error("Request object is not available in the context. Make sure you use this plugin with GraphQL Yoga.");let r=e.get(o.request);if(r==null)throw new Error("No schema found for this request. Make sure you use this plugin with GraphQL Yoga.");n(r)}}}throw new Error("Invalid schema definition provided, expected a schema, promise or function.")}});var KM=P(yu=>{"use strict";Object.defineProperty(yu,"__esModule",{value:!0});yu.versionInfo=yu.version=void 0;var NX="16.13.1";yu.version=NX;var RX=Object.freeze({major:16,minor:13,patch:1,preReleaseTag:null});yu.versionInfo=RX});var xn=P(L0=>{"use strict";Object.defineProperty(L0,"__esModule",{value:!0});L0.devAssert=OX;function OX(t,e){if(!!!t)throw new Error(e)}});var Gg=P(j0=>{"use strict";Object.defineProperty(j0,"__esModule",{value:!0});j0.isPromise=CX;function CX(t){return typeof t?.then=="function"}});var bo=P(F0=>{"use strict";Object.defineProperty(F0,"__esModule",{value:!0});F0.isObjectLike=kX;function kX(t){return typeof t=="object"&&t!==null}});var dn=P(M0=>{"use strict";Object.defineProperty(M0,"__esModule",{value:!0});M0.invariant=AX;function AX(t,e){if(!!!t)throw new Error(e??"Unexpected invariant triggered.")}});var Bg=P(U0=>{"use strict";Object.defineProperty(U0,"__esModule",{value:!0});U0.getLocation=LX;var DX=dn(),PX=/\r\n|[\n\r]/g;function LX(t,e){let n=0,o=1;for(let r of t.body.matchAll(PX)){if(typeof r.index=="number"||(0,DX.invariant)(!1),r.index>=e)break;n=r.index+r[0].length,o+=1}return{line:o,column:e+1-n}}});var G0=P(qg=>{"use strict";Object.defineProperty(qg,"__esModule",{value:!0});qg.printLocation=FX;qg.printSourceLocation=YM;var jX=Bg();function FX(t){return YM(t.source,(0,jX.getLocation)(t.source,t.start))}function YM(t,e){let n=t.locationOffset.column-1,o="".padStart(n)+t.body,r=e.line-1,i=t.locationOffset.line-1,s=e.line+i,a=e.line===1?n:0,c=e.column+a,u=`${t.name}:${s}:${c}
@@ -1334,7 +1334,7 @@ builder.objectType('MyObject', {
1334
1334
  `),k_(o);try{await A_(o)}catch(w){console.error(" \u2717 Failed to start Docker services:",w.message),process.exit(1)}console.log(" \u2713 PostgreSQL on :5432"),console.log(" \u2713 NATS on :4222"),console.log(" \u2713 Redis on :6379"),console.log(" Waiting for PostgreSQL to accept connections..."),await D_(o)||(console.error(` \u2717 PostgreSQL did not become ready within 120s
1335
1335
  `),process.exit(1)),console.log(" \u2713 PostgreSQL is ready")}console.log(`
1336
1336
  [4/6] Database migrations`);try{let h=Nl(),w=await Rl(s,h),E=w.applied.length+w.skipped.length;w.applied.length>0?console.log(` \u2713 Schema applied (${w.applied.length} migration${w.applied.length>1?"s":""} applied, ${w.skipped.length} already up-to-date)`):console.log(` \u2713 Schema up-to-date (${E} migration${E>1?"s":""})`)}catch(h){console.error(" \u2717 Migration failed:",h.message),process.exit(1)}console.log(`
1337
- [5/6] Project config`);let c=RY(e),u;try{let{getPool:h,closePool:w}=await Promise.resolve().then(()=>(te(),Ce)),E=h(),x=await E.query("SELECT id FROM projects WHERE name = $1",[c]);x.rows.length>0?(u=x.rows[0].id,console.log(` \u2713 Using existing project '${c}' (${u})`)):(u=(await E.query("INSERT INTO projects (name) VALUES ($1) RETURNING id",[c])).rows[0].id,console.log(` \u2713 Created project '${c}' (${u})`)),await w()}catch(h){console.warn(" ! Could not create project in database:",h.message),console.warn(" ! Using default project. Run 'codify project create <name>' later.")}NY(n,{recursive:!0});let l=Wa(n,"config.json"),d={version:"0.5.5",database:s,nats:a,projectRoot:e,createdAt:new Date().toISOString()};u&&(d.projectId=u,d.projectName=c),mm(l,JSON.stringify(d,null,2)+`
1337
+ [5/6] Project config`);let c=RY(e),u;try{let{getPool:h,closePool:w}=await Promise.resolve().then(()=>(te(),Ce)),E=h(),x=await E.query("SELECT id FROM projects WHERE name = $1",[c]);x.rows.length>0?(u=x.rows[0].id,console.log(` \u2713 Using existing project '${c}' (${u})`)):(u=(await E.query("INSERT INTO projects (name) VALUES ($1) RETURNING id",[c])).rows[0].id,console.log(` \u2713 Created project '${c}' (${u})`)),await w()}catch(h){console.warn(" ! Could not create project in database:",h.message),console.warn(" ! Using default project. Run 'codify project create <name>' later.")}NY(n,{recursive:!0});let l=Wa(n,"config.json"),d={version:"0.5.6",database:s,nats:a,projectRoot:e,createdAt:new Date().toISOString()};u&&(d.projectId=u,d.projectName=c),mm(l,JSON.stringify(d,null,2)+`
1338
1338
  `,"utf-8"),console.log(" \u2713 .codify/config.json created");let p=Wa(e,".gitignore");if(ND(p)){let h=RD(p,"utf-8");h.includes(".codify")||(mm(p,h.trimEnd()+`
1339
1339
  .codify/
1340
1340
  `,"utf-8"),console.log(" \u2713 .codify/ added to .gitignore"))}else mm(p,`.codify/
@@ -2608,7 +2608,7 @@ builder.objectType('MyObject', {
2608
2608
  ERROR: Cannot connect to Codify services.`),console.error(` Run 'codify init' to start the infrastructure.
2609
2609
  `)):console.error(`
2610
2610
  ERROR: ${n}
2611
- `),process.exit(1)}});process.on("unhandledRejection",(t,e)=>{console.error("[codify] Unhandled rejection:",t)});process.on("uncaughtException",t=>{console.error("[codify] Uncaught exception:",t),process.exit(1)});var We=new se;We.name("codify").description("Codify \u2014 Living Context Graph for AI-Native Teams").version("0.5.5").option("-v, --verbose","Enable debug-level logging").option("-q, --quiet","Suppress info-level logging").hook("preAction",(t,e)=>{let n=We.opts();n.verbose&&(process.env.CODIFY_VERBOSE="1"),n.quiet&&(process.env.CODIFY_QUIET="1")}).addHelpText("after",`
2611
+ `),process.exit(1)}});process.on("unhandledRejection",(t,e)=>{console.error("[codify] Unhandled rejection:",t)});process.on("uncaughtException",t=>{console.error("[codify] Uncaught exception:",t),process.exit(1)});var We=new se;We.name("codify").description("Codify \u2014 Living Context Graph for AI-Native Teams").version("0.5.6").option("-v, --verbose","Enable debug-level logging").option("-q, --quiet","Suppress info-level logging").hook("preAction",(t,e)=>{let n=We.opts();n.verbose&&(process.env.CODIFY_VERBOSE="1"),n.quiet&&(process.env.CODIFY_QUIET="1")}).addHelpText("after",`
2612
2612
  Getting Started:
2613
2613
  codify up Set up and start in one command (init+bootstrap+start)
2614
2614
  codify init Set up infrastructure and configure project
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codified/cli",
3
- "version": "0.5.5",
3
+ "version": "0.5.6",
4
4
  "type": "module",
5
5
  "description": "Codify — Living Context Graph for AI-Native Teams",
6
6
  "repository": {