ocx 2.0.9 → 2.0.10

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 +6 -6
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -52,7 +52,7 @@ var KW=Object.create;var{getPrototypeOf:WW,defineProperty:F7,getOwnPropertyNames
52
52
 
53
53
  `)}M.write("payload.value = newResult;"),M.write("return payload;");let c=M.compile();return(T,x)=>c(Z,T,x)},X,H=V9,G=!c2.jitless,W=G&&E7.value,z=$.catchall,B;Q._zod.parse=(Z,M)=>{B??(B=q.value);let V=Z.value;if(!H(V))return Z.issues.push({expected:"object",code:"invalid_type",input:V,inst:Q}),Z;if(G&&W&&M?.async===!1&&M.jitless!==!0){if(!X)X=J($.shape);if(Z=X(Z,M),!z)return Z;return M$([],V,Z,M,B,Q)}return Y(Z,M)}});V$=j("$ZodUnion",(Q,$)=>{T1.init(Q,$),U1(Q._zod,"optin",()=>$.options.some((J)=>J._zod.optin==="optional")?"optional":void 0),U1(Q._zod,"optout",()=>$.options.some((J)=>J._zod.optout==="optional")?"optional":void 0),U1(Q._zod,"values",()=>{if($.options.every((J)=>J._zod.values))return new Set($.options.flatMap((J)=>Array.from(J._zod.values)));return}),U1(Q._zod,"pattern",()=>{if($.options.every((J)=>J._zod.pattern)){let J=$.options.map((X)=>X._zod.pattern);return new RegExp(`^(${J.map((X)=>q2(X.source)).join("|")})$`)}return});let Y=$.options.length===1,q=$.options[0]._zod.run;Q._zod.parse=(J,X)=>{if(Y)return q(J,X);let H=!1,G=[];for(let K of $.options){let W=K._zod.run({value:J.value,issues:[]},X);if(W instanceof Promise)G.push(W),H=!0;else{if(W.issues.length===0)return W;G.push(W)}}if(!H)return EQ(G,J,Q,X);return Promise.all(G).then((K)=>{return EQ(K,J,Q,X)})}}),A$=j("$ZodIntersection",(Q,$)=>{T1.init(Q,$),Q._zod.parse=(Y,q)=>{let J=Y.value,X=$.left._zod.run({value:J,issues:[]},q),H=$.right._zod.run({value:J,issues:[]},q);if(X instanceof Promise||H instanceof Promise)return Promise.all([X,H]).then(([K,W])=>{return kQ(Y,K,W)});return kQ(Y,X,H)}});L$=j("$ZodRecord",(Q,$)=>{T1.init(Q,$),Q._zod.parse=(Y,q)=>{let J=Y.value;if(!w8(J))return Y.issues.push({expected:"record",code:"invalid_type",input:J,inst:Q}),Y;let X=[],H=$.keyType._zod.values;if(H){Y.value={};let G=new Set;for(let W of H)if(typeof W==="string"||typeof W==="number"||typeof W==="symbol"){G.add(typeof W==="number"?W.toString():W);let z=$.valueType._zod.run({value:J[W],issues:[]},q);if(z instanceof Promise)X.push(z.then((B)=>{if(B.issues.length)Y.issues.push(...X8(W,B.issues));Y.value[W]=B.value}));else{if(z.issues.length)Y.issues.push(...X8(W,z.issues));Y.value[W]=z.value}}let K;for(let W in J)if(!G.has(W))K=K??[],K.push(W);if(K&&K.length>0)Y.issues.push({code:"unrecognized_keys",input:J,inst:Q,keys:K})}else{Y.value={};for(let G of Reflect.ownKeys(J)){if(G==="__proto__")continue;let K=$.keyType._zod.run({value:G,issues:[]},q);if(K instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof G==="string"&&r2.test(G)&&K.issues.length){let B=$.keyType._zod.run({value:Number(G),issues:[]},q);if(B instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(B.issues.length===0)K=B}if(K.issues.length){if($.mode==="loose")Y.value[G]=J[G];else Y.issues.push({code:"invalid_key",origin:"record",issues:K.issues.map((B)=>C0(B,q,I0())),input:G,path:[G],inst:Q});continue}let z=$.valueType._zod.run({value:J[G],issues:[]},q);if(z instanceof Promise)X.push(z.then((B)=>{if(B.issues.length)Y.issues.push(...X8(G,B.issues));Y.value[K.value]=B.value}));else{if(z.issues.length)Y.issues.push(...X8(G,z.issues));Y.value[K.value]=z.value}}}if(X.length)return Promise.all(X).then(()=>Y);return Y}}),F$=j("$ZodEnum",(Q,$)=>{T1.init(Q,$);let Y=Q2($.entries),q=new Set(Y);Q._zod.values=q,Q._zod.pattern=new RegExp(`^(${Y.filter((J)=>k7.has(typeof J)).map((J)=>typeof J==="string"?J8(J):J.toString()).join("|")})$`),Q._zod.parse=(J,X)=>{let H=J.value;if(q.has(H))return J;return J.issues.push({code:"invalid_value",values:Y,input:H,inst:Q}),J}}),j$=j("$ZodLiteral",(Q,$)=>{if(T1.init(Q,$),$.values.length===0)throw Error("Cannot create literal schema with no valid values");let Y=new Set($.values);Q._zod.values=Y,Q._zod.pattern=new RegExp(`^(${$.values.map((q)=>typeof q==="string"?J8(q):q?J8(q.toString()):String(q)).join("|")})$`),Q._zod.parse=(q,J)=>{let X=q.value;if(Y.has(X))return q;return q.issues.push({code:"invalid_value",values:$.values,input:X,inst:Q}),q}}),w$=j("$ZodTransform",(Q,$)=>{T1.init(Q,$),Q._zod.parse=(Y,q)=>{if(q.direction==="backward")throw new t9(Q.constructor.name);let J=$.transform(Y.value,Y);if(q.async)return(J instanceof Promise?J:Promise.resolve(J)).then((H)=>{return Y.value=H,Y});if(J instanceof Promise)throw new Y8;return Y.value=J,Y}});i7=j("$ZodOptional",(Q,$)=>{T1.init(Q,$),Q._zod.optin="optional",Q._zod.optout="optional",U1(Q._zod,"values",()=>{return $.innerType._zod.values?new Set([...$.innerType._zod.values,void 0]):void 0}),U1(Q._zod,"pattern",()=>{let Y=$.innerType._zod.pattern;return Y?new RegExp(`^(${q2(Y.source)})?$`):void 0}),Q._zod.parse=(Y,q)=>{if($.innerType._zod.optin==="optional"){let J=$.innerType._zod.run(Y,q);if(J instanceof Promise)return J.then((X)=>vQ(X,Y.value));return vQ(J,Y.value)}if(Y.value===void 0)return Y;return $.innerType._zod.run(Y,q)}}),D$=j("$ZodExactOptional",(Q,$)=>{i7.init(Q,$),U1(Q._zod,"values",()=>$.innerType._zod.values),U1(Q._zod,"pattern",()=>$.innerType._zod.pattern),Q._zod.parse=(Y,q)=>{return $.innerType._zod.run(Y,q)}}),O$=j("$ZodNullable",(Q,$)=>{T1.init(Q,$),U1(Q._zod,"optin",()=>$.innerType._zod.optin),U1(Q._zod,"optout",()=>$.innerType._zod.optout),U1(Q._zod,"pattern",()=>{let Y=$.innerType._zod.pattern;return Y?new RegExp(`^(${q2(Y.source)}|null)$`):void 0}),U1(Q._zod,"values",()=>{return $.innerType._zod.values?new Set([...$.innerType._zod.values,null]):void 0}),Q._zod.parse=(Y,q)=>{if(Y.value===null)return Y;return $.innerType._zod.run(Y,q)}}),I$=j("$ZodDefault",(Q,$)=>{T1.init(Q,$),Q._zod.optin="optional",U1(Q._zod,"values",()=>$.innerType._zod.values),Q._zod.parse=(Y,q)=>{if(q.direction==="backward")return $.innerType._zod.run(Y,q);if(Y.value===void 0)return Y.value=$.defaultValue,Y;let J=$.innerType._zod.run(Y,q);if(J instanceof Promise)return J.then((X)=>PQ(X,$));return PQ(J,$)}});N$=j("$ZodPrefault",(Q,$)=>{T1.init(Q,$),Q._zod.optin="optional",U1(Q._zod,"values",()=>$.innerType._zod.values),Q._zod.parse=(Y,q)=>{if(q.direction==="backward")return $.innerType._zod.run(Y,q);if(Y.value===void 0)Y.value=$.defaultValue;return $.innerType._zod.run(Y,q)}}),T$=j("$ZodNonOptional",(Q,$)=>{T1.init(Q,$),U1(Q._zod,"values",()=>{let Y=$.innerType._zod.values;return Y?new Set([...Y].filter((q)=>q!==void 0)):void 0}),Q._zod.parse=(Y,q)=>{let J=$.innerType._zod.run(Y,q);if(J instanceof Promise)return J.then((X)=>xQ(X,Q));return xQ(J,Q)}});b$=j("$ZodCatch",(Q,$)=>{T1.init(Q,$),U1(Q._zod,"optin",()=>$.innerType._zod.optin),U1(Q._zod,"optout",()=>$.innerType._zod.optout),U1(Q._zod,"values",()=>$.innerType._zod.values),Q._zod.parse=(Y,q)=>{if(q.direction==="backward")return $.innerType._zod.run(Y,q);let J=$.innerType._zod.run(Y,q);if(J instanceof Promise)return J.then((X)=>{if(Y.value=X.value,X.issues.length)Y.value=$.catchValue({...Y,error:{issues:X.issues.map((H)=>C0(H,q,I0()))},input:Y.value}),Y.issues=[];return Y});if(Y.value=J.value,J.issues.length)Y.value=$.catchValue({...Y,error:{issues:J.issues.map((X)=>C0(X,q,I0()))},input:Y.value}),Y.issues=[];return Y}}),R$=j("$ZodPipe",(Q,$)=>{T1.init(Q,$),U1(Q._zod,"values",()=>$.in._zod.values),U1(Q._zod,"optin",()=>$.in._zod.optin),U1(Q._zod,"optout",()=>$.out._zod.optout),U1(Q._zod,"propValues",()=>$.in._zod.propValues),Q._zod.parse=(Y,q)=>{if(q.direction==="backward"){let X=$.out._zod.run(Y,q);if(X instanceof Promise)return X.then((H)=>Q3(H,$.in,q));return Q3(X,$.in,q)}let J=$.in._zod.run(Y,q);if(J instanceof Promise)return J.then((X)=>Q3(X,$.out,q));return Q3(J,$.out,q)}});S$=j("$ZodReadonly",(Q,$)=>{T1.init(Q,$),U1(Q._zod,"propValues",()=>$.innerType._zod.propValues),U1(Q._zod,"values",()=>$.innerType._zod.values),U1(Q._zod,"optin",()=>$.innerType?._zod?.optin),U1(Q._zod,"optout",()=>$.innerType?._zod?.optout),Q._zod.parse=(Y,q)=>{if(q.direction==="backward")return $.innerType._zod.run(Y,q);let J=$.innerType._zod.run(Y,q);if(J instanceof Promise)return J.then(CQ);return CQ(J)}});E$=j("$ZodCustom",(Q,$)=>{s1.init(Q,$),T1.init(Q,$),Q._zod.parse=(Y,q)=>{return Y},Q._zod.check=(Y)=>{let q=Y.value,J=$.fn(q);if(J instanceof Promise)return J.then((X)=>yQ(X,Y,q,Q));yQ(J,Y,q,Q);return}})});function n7(){return{localeError:sW()}}var sW=()=>{let Q={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function $(J){return Q[J]??null}let Y={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},q={nan:"NaN"};return(J)=>{switch(J.code){case"invalid_type":{let X=q[J.expected]??J.expected,H=x7(J.input),G=q[H]??H;return`Invalid input: expected ${X}, received ${G}`}case"invalid_value":if(J.values.length===1)return`Invalid input: expected ${i2(J.values[0])}`;return`Invalid option: expected one of ${d2(J.values,"|")}`;case"too_big":{let X=J.inclusive?"<=":"<",H=$(J.origin);if(H)return`Too big: expected ${J.origin??"value"} to have ${X}${J.maximum.toString()} ${H.unit??"elements"}`;return`Too big: expected ${J.origin??"value"} to be ${X}${J.maximum.toString()}`}case"too_small":{let X=J.inclusive?">=":">",H=$(J.origin);if(H)return`Too small: expected ${J.origin} to have ${X}${J.minimum.toString()} ${H.unit}`;return`Too small: expected ${J.origin} to be ${X}${J.minimum.toString()}`}case"invalid_format":{let X=J;if(X.format==="starts_with")return`Invalid string: must start with "${X.prefix}"`;if(X.format==="ends_with")return`Invalid string: must end with "${X.suffix}"`;if(X.format==="includes")return`Invalid string: must include "${X.includes}"`;if(X.format==="regex")return`Invalid string: must match pattern ${X.pattern}`;return`Invalid ${Y[X.format]??J.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${J.divisor}`;case"unrecognized_keys":return`Unrecognized key${J.keys.length>1?"s":""}: ${d2(J.keys,", ")}`;case"invalid_key":return`Invalid key in ${J.origin}`;case"invalid_union":return"Invalid input";case"invalid_element":return`Invalid value in ${J.origin}`;default:return"Invalid input"}}};var v$=A(()=>{y0()});var o7=()=>{};class C${constructor(){this._map=new WeakMap,this._idmap=new Map}add(Q,...$){let Y=$[0];if(this._map.set(Q,Y),Y&&typeof Y==="object"&&"id"in Y)this._idmap.set(Y.id,Q);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(Q){let $=this._map.get(Q);if($&&typeof $==="object"&&"id"in $)this._idmap.delete($.id);return this._map.delete(Q),this}get(Q){let $=Q._zod.parent;if($){let Y={...this.get($)??{}};delete Y.id;let q={...Y,...this._map.get(Q)};return Object.keys(q).length?q:void 0}return this._map.get(Q)}has(Q){return this._map.has(Q)}}function rW(){return new C$}var x$,kF,vF,f8;var s7=A(()=>{kF=Symbol("ZodOutput"),vF=Symbol("ZodInput");(x$=globalThis).__zod_globalRegistry??(x$.__zod_globalRegistry=rW());f8=globalThis.__zod_globalRegistry});function y$(Q,$){return new Q({type:"string",...d($)})}function h$(Q,$){return new Q({type:"string",format:"email",check:"string_format",abort:!1,...d($)})}function r7(Q,$){return new Q({type:"string",format:"guid",check:"string_format",abort:!1,...d($)})}function f$(Q,$){return new Q({type:"string",format:"uuid",check:"string_format",abort:!1,...d($)})}function u$(Q,$){return new Q({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...d($)})}function m$(Q,$){return new Q({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...d($)})}function g$(Q,$){return new Q({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...d($)})}function c$(Q,$){return new Q({type:"string",format:"url",check:"string_format",abort:!1,...d($)})}function d$(Q,$){return new Q({type:"string",format:"emoji",check:"string_format",abort:!1,...d($)})}function p$(Q,$){return new Q({type:"string",format:"nanoid",check:"string_format",abort:!1,...d($)})}function l$(Q,$){return new Q({type:"string",format:"cuid",check:"string_format",abort:!1,...d($)})}function i$(Q,$){return new Q({type:"string",format:"cuid2",check:"string_format",abort:!1,...d($)})}function n$(Q,$){return new Q({type:"string",format:"ulid",check:"string_format",abort:!1,...d($)})}function o$(Q,$){return new Q({type:"string",format:"xid",check:"string_format",abort:!1,...d($)})}function s$(Q,$){return new Q({type:"string",format:"ksuid",check:"string_format",abort:!1,...d($)})}function r$(Q,$){return new Q({type:"string",format:"ipv4",check:"string_format",abort:!1,...d($)})}function a$(Q,$){return new Q({type:"string",format:"ipv6",check:"string_format",abort:!1,...d($)})}function t$(Q,$){return new Q({type:"string",format:"cidrv4",check:"string_format",abort:!1,...d($)})}function e$(Q,$){return new Q({type:"string",format:"cidrv6",check:"string_format",abort:!1,...d($)})}function QY(Q,$){return new Q({type:"string",format:"base64",check:"string_format",abort:!1,...d($)})}function $Y(Q,$){return new Q({type:"string",format:"base64url",check:"string_format",abort:!1,...d($)})}function YY(Q,$){return new Q({type:"string",format:"e164",check:"string_format",abort:!1,...d($)})}function qY(Q,$){return new Q({type:"string",format:"jwt",check:"string_format",abort:!1,...d($)})}function JY(Q,$){return new Q({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...d($)})}function XY(Q,$){return new Q({type:"string",format:"date",check:"string_format",...d($)})}function HY(Q,$){return new Q({type:"string",format:"time",check:"string_format",precision:null,...d($)})}function GY(Q,$){return new Q({type:"string",format:"duration",check:"string_format",...d($)})}function KY(Q,$){return new Q({type:"number",checks:[],...d($)})}function WY(Q,$){return new Q({type:"number",check:"number_format",abort:!1,format:"safeint",...d($)})}function zY(Q,$){return new Q({type:"boolean",...d($)})}function BY(Q){return new Q({type:"any"})}function _Y(Q){return new Q({type:"unknown"})}function ZY(Q,$){return new Q({type:"never",...d($)})}function q3(Q,$){return new m7({check:"less_than",...d($),value:Q,inclusive:!1})}function K2(Q,$){return new m7({check:"less_than",...d($),value:Q,inclusive:!0})}function J3(Q,$){return new g7({check:"greater_than",...d($),value:Q,inclusive:!1})}function W2(Q,$){return new g7({check:"greater_than",...d($),value:Q,inclusive:!0})}function X3(Q,$){return new UQ({check:"multiple_of",...d($),value:Q})}function H3(Q,$){return new AQ({check:"max_length",...d($),maximum:Q})}function F9(Q,$){return new LQ({check:"min_length",...d($),minimum:Q})}function G3(Q,$){return new FQ({check:"length_equals",...d($),length:Q})}function a7(Q,$){return new jQ({check:"string_format",format:"regex",...d($),pattern:Q})}function t7(Q){return new wQ({check:"string_format",format:"lowercase",...d(Q)})}function e7(Q){return new DQ({check:"string_format",format:"uppercase",...d(Q)})}function Q4(Q,$){return new OQ({check:"string_format",format:"includes",...d($),includes:Q})}function $4(Q,$){return new IQ({check:"string_format",format:"starts_with",...d($),prefix:Q})}function Y4(Q,$){return new NQ({check:"string_format",format:"ends_with",...d($),suffix:Q})}function O8(Q){return new TQ({check:"overwrite",tx:Q})}function q4(Q){return O8(($)=>$.normalize(Q))}function J4(){return O8((Q)=>Q.trim())}function X4(){return O8((Q)=>Q.toLowerCase())}function H4(){return O8((Q)=>Q.toUpperCase())}function G4(){return O8((Q)=>S7(Q))}function MY(Q,$,Y){return new Q({type:"array",element:$,...d(Y)})}function UY(Q,$,Y){return new Q({type:"custom",check:"custom",fn:$,...d(Y)})}function VY(Q){let $=aW((Y)=>{return Y.addIssue=(q)=>{if(typeof q==="string")Y.issues.push(L9(q,Y.value,$._zod.def));else{let J=q;if(J.fatal)J.continue=!1;J.code??(J.code="custom"),J.input??(J.input=Y.value),J.inst??(J.inst=$),J.continue??(J.continue=!$._zod.def.abort),Y.issues.push(L9(J))}},Q(Y.value,Y)});return $}function aW(Q,$){let Y=new s1({check:"custom",...d($)});return Y._zod.check=Q,Y}var AY=A(()=>{e2();y0()});function K4(Q){let $=Q?.target??"draft-2020-12";if($==="draft-4")$="draft-04";if($==="draft-7")$="draft-07";return{processors:Q.processors??{},metadataRegistry:Q?.metadata??f8,target:$,unrepresentable:Q?.unrepresentable??"throw",override:Q?.override??(()=>{}),io:Q?.io??"output",counter:0,seen:new Map,cycles:Q?.cycles??"ref",reused:Q?.reused??"inline",external:Q?.external??void 0}}function m1(Q,$,Y={path:[],schemaPath:[]}){var q;let J=Q._zod.def,X=$.seen.get(Q);if(X){if(X.count++,Y.schemaPath.includes(Q))X.cycle=Y.path;return X.schema}let H={schema:{},count:1,cycle:void 0,path:Y.path};$.seen.set(Q,H);let G=Q._zod.toJSONSchema?.();if(G)H.schema=G;else{let z={...Y,schemaPath:[...Y.schemaPath,Q],path:Y.path};if(Q._zod.processJSONSchema)Q._zod.processJSONSchema($,H.schema,z);else{let Z=H.schema,M=$.processors[J.type];if(!M)throw Error(`[toJSONSchema]: Non-representable type encountered: ${J.type}`);M(Q,$,Z,z)}let B=Q._zod.parent;if(B){if(!H.ref)H.ref=B;m1(B,$,z),$.seen.get(B).isParent=!0}}let K=$.metadataRegistry.get(Q);if(K)Object.assign(H.schema,K);if($.io==="input"&&Y0(Q))delete H.schema.examples,delete H.schema.default;if($.io==="input"&&H.schema._prefault)(q=H.schema).default??(q.default=H.schema._prefault);return delete H.schema._prefault,$.seen.get(Q).schema}function W4(Q,$){let Y=Q.seen.get($);if(!Y)throw Error("Unprocessed schema. This is a bug in Zod.");let q=new Map;for(let H of Q.seen.entries()){let G=Q.metadataRegistry.get(H[0])?.id;if(G){let K=q.get(G);if(K&&K!==H[0])throw Error(`Duplicate schema id "${G}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);q.set(G,H[0])}}let J=(H)=>{let G=Q.target==="draft-2020-12"?"$defs":"definitions";if(Q.external){let B=Q.external.registry.get(H[0])?.id,Z=Q.external.uri??((V)=>V);if(B)return{ref:Z(B)};let M=H[1].defId??H[1].schema.id??`schema${Q.counter++}`;return H[1].defId=M,{defId:M,ref:`${Z("__shared")}#/${G}/${M}`}}if(H[1]===Y)return{ref:"#"};let W=`${"#"}/${G}/`,z=H[1].schema.id??`__schema${Q.counter++}`;return{defId:z,ref:W+z}},X=(H)=>{if(H[1].schema.$ref)return;let G=H[1],{ref:K,defId:W}=J(H);if(G.def={...G.schema},W)G.defId=W;let z=G.schema;for(let B in z)delete z[B];z.$ref=K};if(Q.cycles==="throw")for(let H of Q.seen.entries()){let G=H[1];if(G.cycle)throw Error(`Cycle detected: #/${G.cycle?.join("/")}/<root>
54
54
 
55
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let H of Q.seen.entries()){let G=H[1];if($===H[0]){X(H);continue}if(Q.external){let W=Q.external.registry.get(H[0])?.id;if($!==H[0]&&W){X(H);continue}}if(Q.metadataRegistry.get(H[0])?.id){X(H);continue}if(G.cycle){X(H);continue}if(G.count>1){if(Q.reused==="ref"){X(H);continue}}}}function z4(Q,$){let Y=Q.seen.get($);if(!Y)throw Error("Unprocessed schema. This is a bug in Zod.");let q=(H)=>{let G=Q.seen.get(H);if(G.ref===null)return;let K=G.def??G.schema,W={...K},z=G.ref;if(G.ref=null,z){q(z);let Z=Q.seen.get(z),M=Z.schema;if(M.$ref&&(Q.target==="draft-07"||Q.target==="draft-04"||Q.target==="openapi-3.0"))K.allOf=K.allOf??[],K.allOf.push(M);else Object.assign(K,M);if(Object.assign(K,W),H._zod.parent===z)for(let U in K){if(U==="$ref"||U==="allOf")continue;if(!(U in W))delete K[U]}if(M.$ref&&Z.def)for(let U in K){if(U==="$ref"||U==="allOf")continue;if(U in Z.def&&JSON.stringify(K[U])===JSON.stringify(Z.def[U]))delete K[U]}}let B=H._zod.parent;if(B&&B!==z){q(B);let Z=Q.seen.get(B);if(Z?.schema.$ref){if(K.$ref=Z.schema.$ref,Z.def)for(let M in K){if(M==="$ref"||M==="allOf")continue;if(M in Z.def&&JSON.stringify(K[M])===JSON.stringify(Z.def[M]))delete K[M]}}}Q.override({zodSchema:H,jsonSchema:K,path:G.path??[]})};for(let H of[...Q.seen.entries()].reverse())q(H[0]);let J={};if(Q.target==="draft-2020-12")J.$schema="https://json-schema.org/draft/2020-12/schema";else if(Q.target==="draft-07")J.$schema="http://json-schema.org/draft-07/schema#";else if(Q.target==="draft-04")J.$schema="http://json-schema.org/draft-04/schema#";else if(Q.target==="openapi-3.0");if(Q.external?.uri){let H=Q.external.registry.get($)?.id;if(!H)throw Error("Schema is missing an `id` property");J.$id=Q.external.uri(H)}Object.assign(J,Y.def??Y.schema);let X=Q.external?.defs??{};for(let H of Q.seen.entries()){let G=H[1];if(G.def&&G.defId)X[G.defId]=G.def}if(Q.external);else if(Object.keys(X).length>0)if(Q.target==="draft-2020-12")J.$defs=X;else J.definitions=X;try{let H=JSON.parse(JSON.stringify(J));return Object.defineProperty(H,"~standard",{value:{...$["~standard"],jsonSchema:{input:z2($,"input",Q.processors),output:z2($,"output",Q.processors)}},enumerable:!1,writable:!1}),H}catch(H){throw Error("Error converting schema to JSON.")}}function Y0(Q,$){let Y=$??{seen:new Set};if(Y.seen.has(Q))return!1;Y.seen.add(Q);let q=Q._zod.def;if(q.type==="transform")return!0;if(q.type==="array")return Y0(q.element,Y);if(q.type==="set")return Y0(q.valueType,Y);if(q.type==="lazy")return Y0(q.getter(),Y);if(q.type==="promise"||q.type==="optional"||q.type==="nonoptional"||q.type==="nullable"||q.type==="readonly"||q.type==="default"||q.type==="prefault")return Y0(q.innerType,Y);if(q.type==="intersection")return Y0(q.left,Y)||Y0(q.right,Y);if(q.type==="record"||q.type==="map")return Y0(q.keyType,Y)||Y0(q.valueType,Y);if(q.type==="pipe")return Y0(q.in,Y)||Y0(q.out,Y);if(q.type==="object"){for(let J in q.shape)if(Y0(q.shape[J],Y))return!0;return!1}if(q.type==="union"){for(let J of q.options)if(Y0(J,Y))return!0;return!1}if(q.type==="tuple"){for(let J of q.items)if(Y0(J,Y))return!0;if(q.rest&&Y0(q.rest,Y))return!0;return!1}return!1}var LY=(Q,$={})=>(Y)=>{let q=K4({...Y,processors:$});return m1(Q,q),W4(q,Q),z4(q,Q)},z2=(Q,$,Y={})=>(q)=>{let{libraryOptions:J,target:X}=q??{},H=K4({...J??{},target:X,io:$,processors:Y});return m1(Q,H),W4(H,Q),z4(H,Q)};var K3=A(()=>{s7()});var tW,FY=(Q,$,Y,q)=>{let J=Y;J.type="string";let{minimum:X,maximum:H,format:G,patterns:K,contentEncoding:W}=Q._zod.bag;if(typeof X==="number")J.minLength=X;if(typeof H==="number")J.maxLength=H;if(G){if(J.format=tW[G]??G,J.format==="")delete J.format;if(G==="time")delete J.format}if(W)J.contentEncoding=W;if(K&&K.size>0){let z=[...K];if(z.length===1)J.pattern=z[0].source;else if(z.length>1)J.allOf=[...z.map((B)=>({...$.target==="draft-07"||$.target==="draft-04"||$.target==="openapi-3.0"?{type:"string"}:{},pattern:B.source}))]}},jY=(Q,$,Y,q)=>{let J=Y,{minimum:X,maximum:H,format:G,multipleOf:K,exclusiveMaximum:W,exclusiveMinimum:z}=Q._zod.bag;if(typeof G==="string"&&G.includes("int"))J.type="integer";else J.type="number";if(typeof z==="number")if($.target==="draft-04"||$.target==="openapi-3.0")J.minimum=z,J.exclusiveMinimum=!0;else J.exclusiveMinimum=z;if(typeof X==="number"){if(J.minimum=X,typeof z==="number"&&$.target!=="draft-04")if(z>=X)delete J.minimum;else delete J.exclusiveMinimum}if(typeof W==="number")if($.target==="draft-04"||$.target==="openapi-3.0")J.maximum=W,J.exclusiveMaximum=!0;else J.exclusiveMaximum=W;if(typeof H==="number"){if(J.maximum=H,typeof W==="number"&&$.target!=="draft-04")if(W<=H)delete J.maximum;else delete J.exclusiveMaximum}if(typeof K==="number")J.multipleOf=K},wY=(Q,$,Y,q)=>{Y.type="boolean"},DY=(Q,$,Y,q)=>{Y.not={}},OY=(Q,$,Y,q)=>{},IY=(Q,$,Y,q)=>{},NY=(Q,$,Y,q)=>{let J=Q._zod.def,X=Q2(J.entries);if(X.every((H)=>typeof H==="number"))Y.type="number";if(X.every((H)=>typeof H==="string"))Y.type="string";Y.enum=X},TY=(Q,$,Y,q)=>{let J=Q._zod.def,X=[];for(let H of J.values)if(H===void 0){if($.unrepresentable==="throw")throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof H==="bigint")if($.unrepresentable==="throw")throw Error("BigInt literals cannot be represented in JSON Schema");else X.push(Number(H));else X.push(H);if(X.length===0);else if(X.length===1){let H=X[0];if(Y.type=H===null?"null":typeof H,$.target==="draft-04"||$.target==="openapi-3.0")Y.enum=[H];else Y.const=H}else{if(X.every((H)=>typeof H==="number"))Y.type="number";if(X.every((H)=>typeof H==="string"))Y.type="string";if(X.every((H)=>typeof H==="boolean"))Y.type="boolean";if(X.every((H)=>H===null))Y.type="null";Y.enum=X}},bY=(Q,$,Y,q)=>{if($.unrepresentable==="throw")throw Error("Custom types cannot be represented in JSON Schema")},RY=(Q,$,Y,q)=>{if($.unrepresentable==="throw")throw Error("Transforms cannot be represented in JSON Schema")},SY=(Q,$,Y,q)=>{let J=Y,X=Q._zod.def,{minimum:H,maximum:G}=Q._zod.bag;if(typeof H==="number")J.minItems=H;if(typeof G==="number")J.maxItems=G;J.type="array",J.items=m1(X.element,$,{...q,path:[...q.path,"items"]})},EY=(Q,$,Y,q)=>{let J=Y,X=Q._zod.def;J.type="object",J.properties={};let H=X.shape;for(let W in H)J.properties[W]=m1(H[W],$,{...q,path:[...q.path,"properties",W]});let G=new Set(Object.keys(H)),K=new Set([...G].filter((W)=>{let z=X.shape[W]._zod;if($.io==="input")return z.optin===void 0;else return z.optout===void 0}));if(K.size>0)J.required=Array.from(K);if(X.catchall?._zod.def.type==="never")J.additionalProperties=!1;else if(!X.catchall){if($.io==="output")J.additionalProperties=!1}else if(X.catchall)J.additionalProperties=m1(X.catchall,$,{...q,path:[...q.path,"additionalProperties"]})},kY=(Q,$,Y,q)=>{let J=Q._zod.def,X=J.inclusive===!1,H=J.options.map((G,K)=>m1(G,$,{...q,path:[...q.path,X?"oneOf":"anyOf",K]}));if(X)Y.oneOf=H;else Y.anyOf=H},vY=(Q,$,Y,q)=>{let J=Q._zod.def,X=m1(J.left,$,{...q,path:[...q.path,"allOf",0]}),H=m1(J.right,$,{...q,path:[...q.path,"allOf",1]}),G=(W)=>("allOf"in W)&&Object.keys(W).length===1,K=[...G(X)?X.allOf:[X],...G(H)?H.allOf:[H]];Y.allOf=K},PY=(Q,$,Y,q)=>{let J=Y,X=Q._zod.def;J.type="object";let H=X.keyType,K=H._zod.bag?.patterns;if(X.mode==="loose"&&K&&K.size>0){let z=m1(X.valueType,$,{...q,path:[...q.path,"patternProperties","*"]});J.patternProperties={};for(let B of K)J.patternProperties[B.source]=z}else{if($.target==="draft-07"||$.target==="draft-2020-12")J.propertyNames=m1(X.keyType,$,{...q,path:[...q.path,"propertyNames"]});J.additionalProperties=m1(X.valueType,$,{...q,path:[...q.path,"additionalProperties"]})}let W=H._zod.values;if(W){let z=[...W].filter((B)=>typeof B==="string"||typeof B==="number");if(z.length>0)J.required=z}},xY=(Q,$,Y,q)=>{let J=Q._zod.def,X=m1(J.innerType,$,q),H=$.seen.get(Q);if($.target==="openapi-3.0")H.ref=J.innerType,Y.nullable=!0;else Y.anyOf=[X,{type:"null"}]},CY=(Q,$,Y,q)=>{let J=Q._zod.def;m1(J.innerType,$,q);let X=$.seen.get(Q);X.ref=J.innerType},yY=(Q,$,Y,q)=>{let J=Q._zod.def;m1(J.innerType,$,q);let X=$.seen.get(Q);X.ref=J.innerType,Y.default=JSON.parse(JSON.stringify(J.defaultValue))},hY=(Q,$,Y,q)=>{let J=Q._zod.def;m1(J.innerType,$,q);let X=$.seen.get(Q);if(X.ref=J.innerType,$.io==="input")Y._prefault=JSON.parse(JSON.stringify(J.defaultValue))},fY=(Q,$,Y,q)=>{let J=Q._zod.def;m1(J.innerType,$,q);let X=$.seen.get(Q);X.ref=J.innerType;let H;try{H=J.catchValue(void 0)}catch{throw Error("Dynamic catch values are not supported in JSON Schema")}Y.default=H},uY=(Q,$,Y,q)=>{let J=Q._zod.def,X=$.io==="input"?J.in._zod.def.type==="transform"?J.out:J.in:J.out;m1(X,$,q);let H=$.seen.get(Q);H.ref=X},mY=(Q,$,Y,q)=>{let J=Q._zod.def;m1(J.innerType,$,q);let X=$.seen.get(Q);X.ref=J.innerType,Y.readOnly=!0},B4=(Q,$,Y,q)=>{let J=Q._zod.def;m1(J.innerType,$,q);let X=$.seen.get(Q);X.ref=J.innerType};var gY=A(()=>{K3();y0();tW={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""}});var cY=()=>{};var o0=A(()=>{y0();t2();o7();cY();U9();h7();y7();k$();e2();d7();s7();AY();K3()});var _4=A(()=>{o0()});function dY(Q){return JY(Xz,Q)}function pY(Q){return XY(Hz,Q)}function lY(Q){return HY(Gz,Q)}function iY(Q){return GY(Kz,Q)}var Xz,Hz,Gz,Kz;var Z4=A(()=>{o0();M4();Xz=j("ZodISODateTime",(Q,$)=>{oQ.init(Q,$),S1.init(Q,$)});Hz=j("ZodISODate",(Q,$)=>{sQ.init(Q,$),S1.init(Q,$)});Gz=j("ZodISOTime",(Q,$)=>{rQ.init(Q,$),S1.init(Q,$)});Kz=j("ZodISODuration",(Q,$)=>{aQ.init(Q,$),S1.init(Q,$)})});var oY=(Q,$)=>{n2.init(Q,$),Q.name="ZodError",Object.defineProperties(Q,{format:{value:(Y)=>k5(Q,Y)},flatten:{value:(Y)=>E5(Q,Y)},addIssue:{value:(Y)=>{Q.issues.push(Y),Q.message=JSON.stringify(Q.issues,A9,2)}},addIssues:{value:(Y)=>{Q.issues.push(...Y),Q.message=JSON.stringify(Q.issues,A9,2)}},isEmpty:{get(){return Q.issues.length===0}}})},U4,U0;var V4=A(()=>{o0();o0();y0();U4=j("ZodError",oY),U0=j("ZodError",oY,{Parent:Error})});var sY,rY,aY,tY,eY,Qq,$q,Yq,qq,Jq,Xq,Hq;var A4=A(()=>{o0();V4();sY=o2(U0),rY=s2(U0),aY=X2(U0),tY=H2(U0),eY=x5(U0),Qq=C5(U0),$q=y5(U0),Yq=h5(U0),qq=f5(U0),Jq=u5(U0),Xq=m5(U0),Hq=g5(U0)});function F(Q){return y$(Bz,Q)}function j9(Q){return KY(Zq,Q)}function Kq(Q){return WY(Sz,Q)}function i1(Q){return zY(Ez,Q)}function Mq(){return BY(kz)}function I8(){return _Y(vz)}function xz(Q){return ZY(Pz,Q)}function R1(Q,$){return MY(Cz,Q,$)}function Q1(Q,$){let Y={type:"object",shape:Q??{},...z1.normalizeParams($)};return new yz(Y)}function V0(Q,$){return new hz({type:"union",options:Q,...z1.normalizeParams($)})}function uz(Q,$){return new fz({type:"intersection",left:Q,right:$})}function q1(Q,$,Y){return new mz({type:"record",keyType:Q,valueType:$,...z1.normalizeParams(Y)})}function t1(Q,$){let Y=Array.isArray(Q)?Object.fromEntries(Q.map((q)=>[q,q])):Q;return new L4({type:"enum",entries:Y,...z1.normalizeParams($)})}function F4(Q,$){return new gz({type:"literal",values:Array.isArray(Q)?Q:[Q],...z1.normalizeParams($)})}function dz(Q){return new cz({type:"transform",transform:Q})}function Wq(Q){return new Uq({type:"optional",innerType:Q})}function lz(Q){return new pz({type:"optional",innerType:Q})}function zq(Q){return new iz({type:"nullable",innerType:Q})}function oz(Q,$){return new nz({type:"default",innerType:Q,get defaultValue(){return typeof $==="function"?$():z1.shallowClone($)}})}function rz(Q,$){return new sz({type:"prefault",innerType:Q,get defaultValue(){return typeof $==="function"?$():z1.shallowClone($)}})}function az(Q,$){return new Vq({type:"nonoptional",innerType:Q,...z1.normalizeParams($)})}function ez(Q,$){return new tz({type:"catch",innerType:Q,catchValue:typeof $==="function"?$:()=>$})}function Bq(Q,$){return new QB({type:"pipe",in:Q,out:$})}function YB(Q){return new $B({type:"readonly",innerType:Q})}function JB(Q,$={}){return UY(qB,Q,$)}function XB(Q){return VY(Q)}var E1,_q,Bz,S1,_z,Gq,W3,Zz,Mz,Uz,Vz,Az,Lz,Fz,jz,wz,Dz,Oz,Iz,Nz,Tz,bz,Rz,Zq,Sz,Ez,kz,vz,Pz,Cz,yz,hz,fz,mz,L4,gz,cz,Uq,pz,iz,nz,sz,Vq,tz,QB,$B,qB;var M4=A(()=>{o0();o0();gY();K3();_4();Z4();A4();E1=j("ZodType",(Q,$)=>{return T1.init(Q,$),Object.assign(Q["~standard"],{jsonSchema:{input:z2(Q,"input"),output:z2(Q,"output")}}),Q.toJSONSchema=LY(Q,{}),Q.def=$,Q.type=$.type,Object.defineProperty(Q,"_def",{value:$}),Q.check=(...Y)=>{return Q.clone(z1.mergeDefs($,{checks:[...$.checks??[],...Y.map((q)=>typeof q==="function"?{_zod:{check:q,def:{check:"custom"},onattach:[]}}:q)]}),{parent:!0})},Q.with=Q.check,Q.clone=(Y,q)=>x0(Q,Y,q),Q.brand=()=>Q,Q.register=(Y,q)=>{return Y.add(Q,q),Q},Q.parse=(Y,q)=>sY(Q,Y,q,{callee:Q.parse}),Q.safeParse=(Y,q)=>aY(Q,Y,q),Q.parseAsync=async(Y,q)=>rY(Q,Y,q,{callee:Q.parseAsync}),Q.safeParseAsync=async(Y,q)=>tY(Q,Y,q),Q.spa=Q.safeParseAsync,Q.encode=(Y,q)=>eY(Q,Y,q),Q.decode=(Y,q)=>Qq(Q,Y,q),Q.encodeAsync=async(Y,q)=>$q(Q,Y,q),Q.decodeAsync=async(Y,q)=>Yq(Q,Y,q),Q.safeEncode=(Y,q)=>qq(Q,Y,q),Q.safeDecode=(Y,q)=>Jq(Q,Y,q),Q.safeEncodeAsync=async(Y,q)=>Xq(Q,Y,q),Q.safeDecodeAsync=async(Y,q)=>Hq(Q,Y,q),Q.refine=(Y,q)=>Q.check(JB(Y,q)),Q.superRefine=(Y)=>Q.check(XB(Y)),Q.overwrite=(Y)=>Q.check(O8(Y)),Q.optional=()=>Wq(Q),Q.exactOptional=()=>lz(Q),Q.nullable=()=>zq(Q),Q.nullish=()=>Wq(zq(Q)),Q.nonoptional=(Y)=>az(Q,Y),Q.array=()=>R1(Q),Q.or=(Y)=>V0([Q,Y]),Q.and=(Y)=>uz(Q,Y),Q.transform=(Y)=>Bq(Q,dz(Y)),Q.default=(Y)=>oz(Q,Y),Q.prefault=(Y)=>rz(Q,Y),Q.catch=(Y)=>ez(Q,Y),Q.pipe=(Y)=>Bq(Q,Y),Q.readonly=()=>YB(Q),Q.describe=(Y)=>{let q=Q.clone();return f8.add(q,{description:Y}),q},Object.defineProperty(Q,"description",{get(){return f8.get(Q)?.description},configurable:!0}),Q.meta=(...Y)=>{if(Y.length===0)return f8.get(Q);let q=Q.clone();return f8.add(q,Y[0]),q},Q.isOptional=()=>Q.safeParse(void 0).success,Q.isNullable=()=>Q.safeParse(null).success,Q.apply=(Y)=>Y(Q),Q}),_q=j("_ZodString",(Q,$)=>{Y3.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(q,J,X)=>FY(Q,q,J,X);let Y=Q._zod.bag;Q.format=Y.format??null,Q.minLength=Y.minimum??null,Q.maxLength=Y.maximum??null,Q.regex=(...q)=>Q.check(a7(...q)),Q.includes=(...q)=>Q.check(Q4(...q)),Q.startsWith=(...q)=>Q.check($4(...q)),Q.endsWith=(...q)=>Q.check(Y4(...q)),Q.min=(...q)=>Q.check(F9(...q)),Q.max=(...q)=>Q.check(H3(...q)),Q.length=(...q)=>Q.check(G3(...q)),Q.nonempty=(...q)=>Q.check(F9(1,...q)),Q.lowercase=(q)=>Q.check(t7(q)),Q.uppercase=(q)=>Q.check(e7(q)),Q.trim=()=>Q.check(J4()),Q.normalize=(...q)=>Q.check(q4(...q)),Q.toLowerCase=()=>Q.check(X4()),Q.toUpperCase=()=>Q.check(H4()),Q.slugify=()=>Q.check(G4())}),Bz=j("ZodString",(Q,$)=>{Y3.init(Q,$),_q.init(Q,$),Q.email=(Y)=>Q.check(h$(_z,Y)),Q.url=(Y)=>Q.check(c$(Zz,Y)),Q.jwt=(Y)=>Q.check(qY(Rz,Y)),Q.emoji=(Y)=>Q.check(d$(Mz,Y)),Q.guid=(Y)=>Q.check(r7(Gq,Y)),Q.uuid=(Y)=>Q.check(f$(W3,Y)),Q.uuidv4=(Y)=>Q.check(u$(W3,Y)),Q.uuidv6=(Y)=>Q.check(m$(W3,Y)),Q.uuidv7=(Y)=>Q.check(g$(W3,Y)),Q.nanoid=(Y)=>Q.check(p$(Uz,Y)),Q.guid=(Y)=>Q.check(r7(Gq,Y)),Q.cuid=(Y)=>Q.check(l$(Vz,Y)),Q.cuid2=(Y)=>Q.check(i$(Az,Y)),Q.ulid=(Y)=>Q.check(n$(Lz,Y)),Q.base64=(Y)=>Q.check(QY(Nz,Y)),Q.base64url=(Y)=>Q.check($Y(Tz,Y)),Q.xid=(Y)=>Q.check(o$(Fz,Y)),Q.ksuid=(Y)=>Q.check(s$(jz,Y)),Q.ipv4=(Y)=>Q.check(r$(wz,Y)),Q.ipv6=(Y)=>Q.check(a$(Dz,Y)),Q.cidrv4=(Y)=>Q.check(t$(Oz,Y)),Q.cidrv6=(Y)=>Q.check(e$(Iz,Y)),Q.e164=(Y)=>Q.check(YY(bz,Y)),Q.datetime=(Y)=>Q.check(dY(Y)),Q.date=(Y)=>Q.check(pY(Y)),Q.time=(Y)=>Q.check(lY(Y)),Q.duration=(Y)=>Q.check(iY(Y))});S1=j("ZodStringFormat",(Q,$)=>{b1.init(Q,$),_q.init(Q,$)}),_z=j("ZodEmail",(Q,$)=>{uQ.init(Q,$),S1.init(Q,$)}),Gq=j("ZodGUID",(Q,$)=>{hQ.init(Q,$),S1.init(Q,$)}),W3=j("ZodUUID",(Q,$)=>{fQ.init(Q,$),S1.init(Q,$)}),Zz=j("ZodURL",(Q,$)=>{mQ.init(Q,$),S1.init(Q,$)}),Mz=j("ZodEmoji",(Q,$)=>{gQ.init(Q,$),S1.init(Q,$)}),Uz=j("ZodNanoID",(Q,$)=>{cQ.init(Q,$),S1.init(Q,$)}),Vz=j("ZodCUID",(Q,$)=>{dQ.init(Q,$),S1.init(Q,$)}),Az=j("ZodCUID2",(Q,$)=>{pQ.init(Q,$),S1.init(Q,$)}),Lz=j("ZodULID",(Q,$)=>{lQ.init(Q,$),S1.init(Q,$)}),Fz=j("ZodXID",(Q,$)=>{iQ.init(Q,$),S1.init(Q,$)}),jz=j("ZodKSUID",(Q,$)=>{nQ.init(Q,$),S1.init(Q,$)}),wz=j("ZodIPv4",(Q,$)=>{tQ.init(Q,$),S1.init(Q,$)}),Dz=j("ZodIPv6",(Q,$)=>{eQ.init(Q,$),S1.init(Q,$)}),Oz=j("ZodCIDRv4",(Q,$)=>{Q$.init(Q,$),S1.init(Q,$)}),Iz=j("ZodCIDRv6",(Q,$)=>{$$.init(Q,$),S1.init(Q,$)}),Nz=j("ZodBase64",(Q,$)=>{q$.init(Q,$),S1.init(Q,$)}),Tz=j("ZodBase64URL",(Q,$)=>{J$.init(Q,$),S1.init(Q,$)}),bz=j("ZodE164",(Q,$)=>{X$.init(Q,$),S1.init(Q,$)}),Rz=j("ZodJWT",(Q,$)=>{H$.init(Q,$),S1.init(Q,$)}),Zq=j("ZodNumber",(Q,$)=>{l7.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(q,J,X)=>jY(Q,q,J,X),Q.gt=(q,J)=>Q.check(J3(q,J)),Q.gte=(q,J)=>Q.check(W2(q,J)),Q.min=(q,J)=>Q.check(W2(q,J)),Q.lt=(q,J)=>Q.check(q3(q,J)),Q.lte=(q,J)=>Q.check(K2(q,J)),Q.max=(q,J)=>Q.check(K2(q,J)),Q.int=(q)=>Q.check(Kq(q)),Q.safe=(q)=>Q.check(Kq(q)),Q.positive=(q)=>Q.check(J3(0,q)),Q.nonnegative=(q)=>Q.check(W2(0,q)),Q.negative=(q)=>Q.check(q3(0,q)),Q.nonpositive=(q)=>Q.check(K2(0,q)),Q.multipleOf=(q,J)=>Q.check(X3(q,J)),Q.step=(q,J)=>Q.check(X3(q,J)),Q.finite=()=>Q;let Y=Q._zod.bag;Q.minValue=Math.max(Y.minimum??Number.NEGATIVE_INFINITY,Y.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,Q.maxValue=Math.min(Y.maximum??Number.POSITIVE_INFINITY,Y.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,Q.isInt=(Y.format??"").includes("int")||Number.isSafeInteger(Y.multipleOf??0.5),Q.isFinite=!0,Q.format=Y.format??null});Sz=j("ZodNumberFormat",(Q,$)=>{G$.init(Q,$),Zq.init(Q,$)});Ez=j("ZodBoolean",(Q,$)=>{K$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>wY(Q,Y,q,J)});kz=j("ZodAny",(Q,$)=>{W$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>OY(Q,Y,q,J)});vz=j("ZodUnknown",(Q,$)=>{z$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>IY(Q,Y,q,J)});Pz=j("ZodNever",(Q,$)=>{B$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>DY(Q,Y,q,J)});Cz=j("ZodArray",(Q,$)=>{_$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>SY(Q,Y,q,J),Q.element=$.element,Q.min=(Y,q)=>Q.check(F9(Y,q)),Q.nonempty=(Y)=>Q.check(F9(1,Y)),Q.max=(Y,q)=>Q.check(H3(Y,q)),Q.length=(Y,q)=>Q.check(G3(Y,q)),Q.unwrap=()=>Q.element});yz=j("ZodObject",(Q,$)=>{U$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>EY(Q,Y,q,J),z1.defineLazy(Q,"shape",()=>{return $.shape}),Q.keyof=()=>t1(Object.keys(Q._zod.def.shape)),Q.catchall=(Y)=>Q.clone({...Q._zod.def,catchall:Y}),Q.passthrough=()=>Q.clone({...Q._zod.def,catchall:I8()}),Q.loose=()=>Q.clone({...Q._zod.def,catchall:I8()}),Q.strict=()=>Q.clone({...Q._zod.def,catchall:xz()}),Q.strip=()=>Q.clone({...Q._zod.def,catchall:void 0}),Q.extend=(Y)=>{return z1.extend(Q,Y)},Q.safeExtend=(Y)=>{return z1.safeExtend(Q,Y)},Q.merge=(Y)=>z1.merge(Q,Y),Q.pick=(Y)=>z1.pick(Q,Y),Q.omit=(Y)=>z1.omit(Q,Y),Q.partial=(...Y)=>z1.partial(Uq,Q,Y[0]),Q.required=(...Y)=>z1.required(Vq,Q,Y[0])});hz=j("ZodUnion",(Q,$)=>{V$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>kY(Q,Y,q,J),Q.options=$.options});fz=j("ZodIntersection",(Q,$)=>{A$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>vY(Q,Y,q,J)});mz=j("ZodRecord",(Q,$)=>{L$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>PY(Q,Y,q,J),Q.keyType=$.keyType,Q.valueType=$.valueType});L4=j("ZodEnum",(Q,$)=>{F$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(q,J,X)=>NY(Q,q,J,X),Q.enum=$.entries,Q.options=Object.values($.entries);let Y=new Set(Object.keys($.entries));Q.extract=(q,J)=>{let X={};for(let H of q)if(Y.has(H))X[H]=$.entries[H];else throw Error(`Key ${H} not found in enum`);return new L4({...$,checks:[],...z1.normalizeParams(J),entries:X})},Q.exclude=(q,J)=>{let X={...$.entries};for(let H of q)if(Y.has(H))delete X[H];else throw Error(`Key ${H} not found in enum`);return new L4({...$,checks:[],...z1.normalizeParams(J),entries:X})}});gz=j("ZodLiteral",(Q,$)=>{j$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>TY(Q,Y,q,J),Q.values=new Set($.values),Object.defineProperty(Q,"value",{get(){if($.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return $.values[0]}})});cz=j("ZodTransform",(Q,$)=>{w$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>RY(Q,Y,q,J),Q._zod.parse=(Y,q)=>{if(q.direction==="backward")throw new t9(Q.constructor.name);Y.addIssue=(X)=>{if(typeof X==="string")Y.issues.push(z1.issue(X,Y.value,$));else{let H=X;if(H.fatal)H.continue=!1;H.code??(H.code="custom"),H.input??(H.input=Y.value),H.inst??(H.inst=Q),Y.issues.push(z1.issue(H))}};let J=$.transform(Y.value,Y);if(J instanceof Promise)return J.then((X)=>{return Y.value=X,Y});return Y.value=J,Y}});Uq=j("ZodOptional",(Q,$)=>{i7.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>B4(Q,Y,q,J),Q.unwrap=()=>Q._zod.def.innerType});pz=j("ZodExactOptional",(Q,$)=>{D$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>B4(Q,Y,q,J),Q.unwrap=()=>Q._zod.def.innerType});iz=j("ZodNullable",(Q,$)=>{O$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>xY(Q,Y,q,J),Q.unwrap=()=>Q._zod.def.innerType});nz=j("ZodDefault",(Q,$)=>{I$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>yY(Q,Y,q,J),Q.unwrap=()=>Q._zod.def.innerType,Q.removeDefault=Q.unwrap});sz=j("ZodPrefault",(Q,$)=>{N$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>hY(Q,Y,q,J),Q.unwrap=()=>Q._zod.def.innerType});Vq=j("ZodNonOptional",(Q,$)=>{T$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>CY(Q,Y,q,J),Q.unwrap=()=>Q._zod.def.innerType});tz=j("ZodCatch",(Q,$)=>{b$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>fY(Q,Y,q,J),Q.unwrap=()=>Q._zod.def.innerType,Q.removeCatch=Q.unwrap});QB=j("ZodPipe",(Q,$)=>{R$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>uY(Q,Y,q,J),Q.in=$.in,Q.out=$.out});$B=j("ZodReadonly",(Q,$)=>{S$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>mY(Q,Y,q,J),Q.unwrap=()=>Q._zod.def.innerType});qB=j("ZodCustom",(Q,$)=>{E$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>bY(Q,Y,q,J)})});var Aq;var Lq=A(()=>{(function(Q){})(Aq||(Aq={}))});var Fq=()=>{};var jq=A(()=>{o0();o0();v$();o7();Z4();Fq();M4();_4();V4();A4();Lq();I0(n7())});var H8=A(()=>{jq()});var Dq;var wq=A(()=>{Dq={name:"ocx",version:"2.0.9",description:"OCX CLI - OpenCode extension manager with portable, isolated profiles. Your setup, anywhere.",author:"kdcokenny",license:"MIT",type:"module",main:"./dist/index.js",bin:{ocx:"./dist/index.js"},files:["dist/index.js"],publishConfig:{access:"public"},repository:{type:"git",url:"https://github.com/kdcokenny/ocx.git"},homepage:"https://github.com/kdcokenny/ocx#readme",bugs:{url:"https://github.com/kdcokenny/ocx/issues"},keywords:["opencode","cli","extensions","agents","plugins","mcp","shadcn","registry"],engines:{bun:">=1.2.0"},scripts:{build:"bun run scripts/build.ts","build:binary":"bun run scripts/build-binary.ts","build:binary:all":"bun run scripts/build-binary.ts --all","build:binary:windows":"bun run scripts/build-binary.ts --target=windows-x64 && bun run scripts/build-binary.ts --target=windows-x64-baseline","release:tag":"bun run scripts/release-tag.ts",check:"bun check:biome && bun check:types","check:biome":"biome check .","check:types":"tsc --noEmit",dev:"bun run src/index.ts",prepublishOnly:"bun run build",test:"bun test","test:binary-smoke":"OCX_DIST_TESTS=1 bun test tests/binary-smoke.test.ts"},dependencies:{commander:"^14.0.3",fuzzysort:"^3.1.0","jsonc-parser":"3.3.1",kleur:"^4.1.5",ora:"^9.3.0",remeda:"^2.33.7",zod:"^4.3.6"},devDependencies:{"@types/bun":"^1.3.11"}}});function KB(Q){return`https://${_2}/schemas/v${Q}/registry.json`}var _2="ocx.kdco.dev",Oq="kdcokenny/ocx",j4,w4,h0=2,f0,Iq;var z3=A(()=>{wq();j4=`https://${_2}/schemas/ocx.json`,w4=`https://${_2}/schemas/registry.json`;f0=KB(h0),Iq=Dq.version});var G1,B1,_1,I1,h,L,u8,n1,m8,x1,u0,C1,N8,w9,m0,D9,D4;var t=A(()=>{G1={SUCCESS:0,GENERAL:1,NOT_FOUND:66,NETWORK:69,CONFIG:78,INTEGRITY:65,CONFLICT:6};B1=class B1 extends Error{code;exitCode;constructor(Q,$,Y=G1.GENERAL){super(Q);this.code=$;this.exitCode=Y;this.name="OCXError"}};_1=class _1 extends B1{constructor(Q){super(Q,"NOT_FOUND",G1.NOT_FOUND);this.name="NotFoundError"}};I1=class I1 extends B1{url;status;statusText;phase;qualifiedName;registryContext;registryName;constructor(Q,$){super(Q,"NETWORK_ERROR",G1.NETWORK);this.name="NetworkError",this.url=$?.url,this.status=$?.status,this.statusText=$?.statusText,this.phase=$?.phase,this.qualifiedName=$?.qualifiedName,this.registryContext=$?.registryContext,this.registryName=$?.registryName}};h=class h extends B1{constructor(Q){super(Q,"CONFIG_ERROR",G1.CONFIG);this.name="ConfigError"}};L=class L extends B1{constructor(Q){super(Q,"VALIDATION_ERROR",G1.GENERAL);this.name="ValidationError"}};u8=class u8 extends B1{details;constructor(Q){super("Registry validation failed","VALIDATION_FAILED",G1.CONFIG);this.details=Q;this.name="ValidationFailedError"}};n1=class n1 extends B1{constructor(Q){super(Q,"CONFLICT",G1.CONFLICT);this.name="ConflictError"}};m8=class m8 extends B1{component;expected;found;constructor(Q,$,Y){let q=`Integrity verification failed for "${Q}"
55
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let H of Q.seen.entries()){let G=H[1];if($===H[0]){X(H);continue}if(Q.external){let W=Q.external.registry.get(H[0])?.id;if($!==H[0]&&W){X(H);continue}}if(Q.metadataRegistry.get(H[0])?.id){X(H);continue}if(G.cycle){X(H);continue}if(G.count>1){if(Q.reused==="ref"){X(H);continue}}}}function z4(Q,$){let Y=Q.seen.get($);if(!Y)throw Error("Unprocessed schema. This is a bug in Zod.");let q=(H)=>{let G=Q.seen.get(H);if(G.ref===null)return;let K=G.def??G.schema,W={...K},z=G.ref;if(G.ref=null,z){q(z);let Z=Q.seen.get(z),M=Z.schema;if(M.$ref&&(Q.target==="draft-07"||Q.target==="draft-04"||Q.target==="openapi-3.0"))K.allOf=K.allOf??[],K.allOf.push(M);else Object.assign(K,M);if(Object.assign(K,W),H._zod.parent===z)for(let U in K){if(U==="$ref"||U==="allOf")continue;if(!(U in W))delete K[U]}if(M.$ref&&Z.def)for(let U in K){if(U==="$ref"||U==="allOf")continue;if(U in Z.def&&JSON.stringify(K[U])===JSON.stringify(Z.def[U]))delete K[U]}}let B=H._zod.parent;if(B&&B!==z){q(B);let Z=Q.seen.get(B);if(Z?.schema.$ref){if(K.$ref=Z.schema.$ref,Z.def)for(let M in K){if(M==="$ref"||M==="allOf")continue;if(M in Z.def&&JSON.stringify(K[M])===JSON.stringify(Z.def[M]))delete K[M]}}}Q.override({zodSchema:H,jsonSchema:K,path:G.path??[]})};for(let H of[...Q.seen.entries()].reverse())q(H[0]);let J={};if(Q.target==="draft-2020-12")J.$schema="https://json-schema.org/draft/2020-12/schema";else if(Q.target==="draft-07")J.$schema="http://json-schema.org/draft-07/schema#";else if(Q.target==="draft-04")J.$schema="http://json-schema.org/draft-04/schema#";else if(Q.target==="openapi-3.0");if(Q.external?.uri){let H=Q.external.registry.get($)?.id;if(!H)throw Error("Schema is missing an `id` property");J.$id=Q.external.uri(H)}Object.assign(J,Y.def??Y.schema);let X=Q.external?.defs??{};for(let H of Q.seen.entries()){let G=H[1];if(G.def&&G.defId)X[G.defId]=G.def}if(Q.external);else if(Object.keys(X).length>0)if(Q.target==="draft-2020-12")J.$defs=X;else J.definitions=X;try{let H=JSON.parse(JSON.stringify(J));return Object.defineProperty(H,"~standard",{value:{...$["~standard"],jsonSchema:{input:z2($,"input",Q.processors),output:z2($,"output",Q.processors)}},enumerable:!1,writable:!1}),H}catch(H){throw Error("Error converting schema to JSON.")}}function Y0(Q,$){let Y=$??{seen:new Set};if(Y.seen.has(Q))return!1;Y.seen.add(Q);let q=Q._zod.def;if(q.type==="transform")return!0;if(q.type==="array")return Y0(q.element,Y);if(q.type==="set")return Y0(q.valueType,Y);if(q.type==="lazy")return Y0(q.getter(),Y);if(q.type==="promise"||q.type==="optional"||q.type==="nonoptional"||q.type==="nullable"||q.type==="readonly"||q.type==="default"||q.type==="prefault")return Y0(q.innerType,Y);if(q.type==="intersection")return Y0(q.left,Y)||Y0(q.right,Y);if(q.type==="record"||q.type==="map")return Y0(q.keyType,Y)||Y0(q.valueType,Y);if(q.type==="pipe")return Y0(q.in,Y)||Y0(q.out,Y);if(q.type==="object"){for(let J in q.shape)if(Y0(q.shape[J],Y))return!0;return!1}if(q.type==="union"){for(let J of q.options)if(Y0(J,Y))return!0;return!1}if(q.type==="tuple"){for(let J of q.items)if(Y0(J,Y))return!0;if(q.rest&&Y0(q.rest,Y))return!0;return!1}return!1}var LY=(Q,$={})=>(Y)=>{let q=K4({...Y,processors:$});return m1(Q,q),W4(q,Q),z4(q,Q)},z2=(Q,$,Y={})=>(q)=>{let{libraryOptions:J,target:X}=q??{},H=K4({...J??{},target:X,io:$,processors:Y});return m1(Q,H),W4(H,Q),z4(H,Q)};var K3=A(()=>{s7()});var tW,FY=(Q,$,Y,q)=>{let J=Y;J.type="string";let{minimum:X,maximum:H,format:G,patterns:K,contentEncoding:W}=Q._zod.bag;if(typeof X==="number")J.minLength=X;if(typeof H==="number")J.maxLength=H;if(G){if(J.format=tW[G]??G,J.format==="")delete J.format;if(G==="time")delete J.format}if(W)J.contentEncoding=W;if(K&&K.size>0){let z=[...K];if(z.length===1)J.pattern=z[0].source;else if(z.length>1)J.allOf=[...z.map((B)=>({...$.target==="draft-07"||$.target==="draft-04"||$.target==="openapi-3.0"?{type:"string"}:{},pattern:B.source}))]}},jY=(Q,$,Y,q)=>{let J=Y,{minimum:X,maximum:H,format:G,multipleOf:K,exclusiveMaximum:W,exclusiveMinimum:z}=Q._zod.bag;if(typeof G==="string"&&G.includes("int"))J.type="integer";else J.type="number";if(typeof z==="number")if($.target==="draft-04"||$.target==="openapi-3.0")J.minimum=z,J.exclusiveMinimum=!0;else J.exclusiveMinimum=z;if(typeof X==="number"){if(J.minimum=X,typeof z==="number"&&$.target!=="draft-04")if(z>=X)delete J.minimum;else delete J.exclusiveMinimum}if(typeof W==="number")if($.target==="draft-04"||$.target==="openapi-3.0")J.maximum=W,J.exclusiveMaximum=!0;else J.exclusiveMaximum=W;if(typeof H==="number"){if(J.maximum=H,typeof W==="number"&&$.target!=="draft-04")if(W<=H)delete J.maximum;else delete J.exclusiveMaximum}if(typeof K==="number")J.multipleOf=K},wY=(Q,$,Y,q)=>{Y.type="boolean"},DY=(Q,$,Y,q)=>{Y.not={}},OY=(Q,$,Y,q)=>{},IY=(Q,$,Y,q)=>{},NY=(Q,$,Y,q)=>{let J=Q._zod.def,X=Q2(J.entries);if(X.every((H)=>typeof H==="number"))Y.type="number";if(X.every((H)=>typeof H==="string"))Y.type="string";Y.enum=X},TY=(Q,$,Y,q)=>{let J=Q._zod.def,X=[];for(let H of J.values)if(H===void 0){if($.unrepresentable==="throw")throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof H==="bigint")if($.unrepresentable==="throw")throw Error("BigInt literals cannot be represented in JSON Schema");else X.push(Number(H));else X.push(H);if(X.length===0);else if(X.length===1){let H=X[0];if(Y.type=H===null?"null":typeof H,$.target==="draft-04"||$.target==="openapi-3.0")Y.enum=[H];else Y.const=H}else{if(X.every((H)=>typeof H==="number"))Y.type="number";if(X.every((H)=>typeof H==="string"))Y.type="string";if(X.every((H)=>typeof H==="boolean"))Y.type="boolean";if(X.every((H)=>H===null))Y.type="null";Y.enum=X}},bY=(Q,$,Y,q)=>{if($.unrepresentable==="throw")throw Error("Custom types cannot be represented in JSON Schema")},RY=(Q,$,Y,q)=>{if($.unrepresentable==="throw")throw Error("Transforms cannot be represented in JSON Schema")},SY=(Q,$,Y,q)=>{let J=Y,X=Q._zod.def,{minimum:H,maximum:G}=Q._zod.bag;if(typeof H==="number")J.minItems=H;if(typeof G==="number")J.maxItems=G;J.type="array",J.items=m1(X.element,$,{...q,path:[...q.path,"items"]})},EY=(Q,$,Y,q)=>{let J=Y,X=Q._zod.def;J.type="object",J.properties={};let H=X.shape;for(let W in H)J.properties[W]=m1(H[W],$,{...q,path:[...q.path,"properties",W]});let G=new Set(Object.keys(H)),K=new Set([...G].filter((W)=>{let z=X.shape[W]._zod;if($.io==="input")return z.optin===void 0;else return z.optout===void 0}));if(K.size>0)J.required=Array.from(K);if(X.catchall?._zod.def.type==="never")J.additionalProperties=!1;else if(!X.catchall){if($.io==="output")J.additionalProperties=!1}else if(X.catchall)J.additionalProperties=m1(X.catchall,$,{...q,path:[...q.path,"additionalProperties"]})},kY=(Q,$,Y,q)=>{let J=Q._zod.def,X=J.inclusive===!1,H=J.options.map((G,K)=>m1(G,$,{...q,path:[...q.path,X?"oneOf":"anyOf",K]}));if(X)Y.oneOf=H;else Y.anyOf=H},vY=(Q,$,Y,q)=>{let J=Q._zod.def,X=m1(J.left,$,{...q,path:[...q.path,"allOf",0]}),H=m1(J.right,$,{...q,path:[...q.path,"allOf",1]}),G=(W)=>("allOf"in W)&&Object.keys(W).length===1,K=[...G(X)?X.allOf:[X],...G(H)?H.allOf:[H]];Y.allOf=K},PY=(Q,$,Y,q)=>{let J=Y,X=Q._zod.def;J.type="object";let H=X.keyType,K=H._zod.bag?.patterns;if(X.mode==="loose"&&K&&K.size>0){let z=m1(X.valueType,$,{...q,path:[...q.path,"patternProperties","*"]});J.patternProperties={};for(let B of K)J.patternProperties[B.source]=z}else{if($.target==="draft-07"||$.target==="draft-2020-12")J.propertyNames=m1(X.keyType,$,{...q,path:[...q.path,"propertyNames"]});J.additionalProperties=m1(X.valueType,$,{...q,path:[...q.path,"additionalProperties"]})}let W=H._zod.values;if(W){let z=[...W].filter((B)=>typeof B==="string"||typeof B==="number");if(z.length>0)J.required=z}},xY=(Q,$,Y,q)=>{let J=Q._zod.def,X=m1(J.innerType,$,q),H=$.seen.get(Q);if($.target==="openapi-3.0")H.ref=J.innerType,Y.nullable=!0;else Y.anyOf=[X,{type:"null"}]},CY=(Q,$,Y,q)=>{let J=Q._zod.def;m1(J.innerType,$,q);let X=$.seen.get(Q);X.ref=J.innerType},yY=(Q,$,Y,q)=>{let J=Q._zod.def;m1(J.innerType,$,q);let X=$.seen.get(Q);X.ref=J.innerType,Y.default=JSON.parse(JSON.stringify(J.defaultValue))},hY=(Q,$,Y,q)=>{let J=Q._zod.def;m1(J.innerType,$,q);let X=$.seen.get(Q);if(X.ref=J.innerType,$.io==="input")Y._prefault=JSON.parse(JSON.stringify(J.defaultValue))},fY=(Q,$,Y,q)=>{let J=Q._zod.def;m1(J.innerType,$,q);let X=$.seen.get(Q);X.ref=J.innerType;let H;try{H=J.catchValue(void 0)}catch{throw Error("Dynamic catch values are not supported in JSON Schema")}Y.default=H},uY=(Q,$,Y,q)=>{let J=Q._zod.def,X=$.io==="input"?J.in._zod.def.type==="transform"?J.out:J.in:J.out;m1(X,$,q);let H=$.seen.get(Q);H.ref=X},mY=(Q,$,Y,q)=>{let J=Q._zod.def;m1(J.innerType,$,q);let X=$.seen.get(Q);X.ref=J.innerType,Y.readOnly=!0},B4=(Q,$,Y,q)=>{let J=Q._zod.def;m1(J.innerType,$,q);let X=$.seen.get(Q);X.ref=J.innerType};var gY=A(()=>{K3();y0();tW={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""}});var cY=()=>{};var o0=A(()=>{y0();t2();o7();cY();U9();h7();y7();k$();e2();d7();s7();AY();K3()});var _4=A(()=>{o0()});function dY(Q){return JY(Xz,Q)}function pY(Q){return XY(Hz,Q)}function lY(Q){return HY(Gz,Q)}function iY(Q){return GY(Kz,Q)}var Xz,Hz,Gz,Kz;var Z4=A(()=>{o0();M4();Xz=j("ZodISODateTime",(Q,$)=>{oQ.init(Q,$),S1.init(Q,$)});Hz=j("ZodISODate",(Q,$)=>{sQ.init(Q,$),S1.init(Q,$)});Gz=j("ZodISOTime",(Q,$)=>{rQ.init(Q,$),S1.init(Q,$)});Kz=j("ZodISODuration",(Q,$)=>{aQ.init(Q,$),S1.init(Q,$)})});var oY=(Q,$)=>{n2.init(Q,$),Q.name="ZodError",Object.defineProperties(Q,{format:{value:(Y)=>k5(Q,Y)},flatten:{value:(Y)=>E5(Q,Y)},addIssue:{value:(Y)=>{Q.issues.push(Y),Q.message=JSON.stringify(Q.issues,A9,2)}},addIssues:{value:(Y)=>{Q.issues.push(...Y),Q.message=JSON.stringify(Q.issues,A9,2)}},isEmpty:{get(){return Q.issues.length===0}}})},U4,U0;var V4=A(()=>{o0();o0();y0();U4=j("ZodError",oY),U0=j("ZodError",oY,{Parent:Error})});var sY,rY,aY,tY,eY,Qq,$q,Yq,qq,Jq,Xq,Hq;var A4=A(()=>{o0();V4();sY=o2(U0),rY=s2(U0),aY=X2(U0),tY=H2(U0),eY=x5(U0),Qq=C5(U0),$q=y5(U0),Yq=h5(U0),qq=f5(U0),Jq=u5(U0),Xq=m5(U0),Hq=g5(U0)});function F(Q){return y$(Bz,Q)}function j9(Q){return KY(Zq,Q)}function Kq(Q){return WY(Sz,Q)}function i1(Q){return zY(Ez,Q)}function Mq(){return BY(kz)}function I8(){return _Y(vz)}function xz(Q){return ZY(Pz,Q)}function R1(Q,$){return MY(Cz,Q,$)}function Q1(Q,$){let Y={type:"object",shape:Q??{},...z1.normalizeParams($)};return new yz(Y)}function V0(Q,$){return new hz({type:"union",options:Q,...z1.normalizeParams($)})}function uz(Q,$){return new fz({type:"intersection",left:Q,right:$})}function q1(Q,$,Y){return new mz({type:"record",keyType:Q,valueType:$,...z1.normalizeParams(Y)})}function t1(Q,$){let Y=Array.isArray(Q)?Object.fromEntries(Q.map((q)=>[q,q])):Q;return new L4({type:"enum",entries:Y,...z1.normalizeParams($)})}function F4(Q,$){return new gz({type:"literal",values:Array.isArray(Q)?Q:[Q],...z1.normalizeParams($)})}function dz(Q){return new cz({type:"transform",transform:Q})}function Wq(Q){return new Uq({type:"optional",innerType:Q})}function lz(Q){return new pz({type:"optional",innerType:Q})}function zq(Q){return new iz({type:"nullable",innerType:Q})}function oz(Q,$){return new nz({type:"default",innerType:Q,get defaultValue(){return typeof $==="function"?$():z1.shallowClone($)}})}function rz(Q,$){return new sz({type:"prefault",innerType:Q,get defaultValue(){return typeof $==="function"?$():z1.shallowClone($)}})}function az(Q,$){return new Vq({type:"nonoptional",innerType:Q,...z1.normalizeParams($)})}function ez(Q,$){return new tz({type:"catch",innerType:Q,catchValue:typeof $==="function"?$:()=>$})}function Bq(Q,$){return new QB({type:"pipe",in:Q,out:$})}function YB(Q){return new $B({type:"readonly",innerType:Q})}function JB(Q,$={}){return UY(qB,Q,$)}function XB(Q){return VY(Q)}var E1,_q,Bz,S1,_z,Gq,W3,Zz,Mz,Uz,Vz,Az,Lz,Fz,jz,wz,Dz,Oz,Iz,Nz,Tz,bz,Rz,Zq,Sz,Ez,kz,vz,Pz,Cz,yz,hz,fz,mz,L4,gz,cz,Uq,pz,iz,nz,sz,Vq,tz,QB,$B,qB;var M4=A(()=>{o0();o0();gY();K3();_4();Z4();A4();E1=j("ZodType",(Q,$)=>{return T1.init(Q,$),Object.assign(Q["~standard"],{jsonSchema:{input:z2(Q,"input"),output:z2(Q,"output")}}),Q.toJSONSchema=LY(Q,{}),Q.def=$,Q.type=$.type,Object.defineProperty(Q,"_def",{value:$}),Q.check=(...Y)=>{return Q.clone(z1.mergeDefs($,{checks:[...$.checks??[],...Y.map((q)=>typeof q==="function"?{_zod:{check:q,def:{check:"custom"},onattach:[]}}:q)]}),{parent:!0})},Q.with=Q.check,Q.clone=(Y,q)=>x0(Q,Y,q),Q.brand=()=>Q,Q.register=(Y,q)=>{return Y.add(Q,q),Q},Q.parse=(Y,q)=>sY(Q,Y,q,{callee:Q.parse}),Q.safeParse=(Y,q)=>aY(Q,Y,q),Q.parseAsync=async(Y,q)=>rY(Q,Y,q,{callee:Q.parseAsync}),Q.safeParseAsync=async(Y,q)=>tY(Q,Y,q),Q.spa=Q.safeParseAsync,Q.encode=(Y,q)=>eY(Q,Y,q),Q.decode=(Y,q)=>Qq(Q,Y,q),Q.encodeAsync=async(Y,q)=>$q(Q,Y,q),Q.decodeAsync=async(Y,q)=>Yq(Q,Y,q),Q.safeEncode=(Y,q)=>qq(Q,Y,q),Q.safeDecode=(Y,q)=>Jq(Q,Y,q),Q.safeEncodeAsync=async(Y,q)=>Xq(Q,Y,q),Q.safeDecodeAsync=async(Y,q)=>Hq(Q,Y,q),Q.refine=(Y,q)=>Q.check(JB(Y,q)),Q.superRefine=(Y)=>Q.check(XB(Y)),Q.overwrite=(Y)=>Q.check(O8(Y)),Q.optional=()=>Wq(Q),Q.exactOptional=()=>lz(Q),Q.nullable=()=>zq(Q),Q.nullish=()=>Wq(zq(Q)),Q.nonoptional=(Y)=>az(Q,Y),Q.array=()=>R1(Q),Q.or=(Y)=>V0([Q,Y]),Q.and=(Y)=>uz(Q,Y),Q.transform=(Y)=>Bq(Q,dz(Y)),Q.default=(Y)=>oz(Q,Y),Q.prefault=(Y)=>rz(Q,Y),Q.catch=(Y)=>ez(Q,Y),Q.pipe=(Y)=>Bq(Q,Y),Q.readonly=()=>YB(Q),Q.describe=(Y)=>{let q=Q.clone();return f8.add(q,{description:Y}),q},Object.defineProperty(Q,"description",{get(){return f8.get(Q)?.description},configurable:!0}),Q.meta=(...Y)=>{if(Y.length===0)return f8.get(Q);let q=Q.clone();return f8.add(q,Y[0]),q},Q.isOptional=()=>Q.safeParse(void 0).success,Q.isNullable=()=>Q.safeParse(null).success,Q.apply=(Y)=>Y(Q),Q}),_q=j("_ZodString",(Q,$)=>{Y3.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(q,J,X)=>FY(Q,q,J,X);let Y=Q._zod.bag;Q.format=Y.format??null,Q.minLength=Y.minimum??null,Q.maxLength=Y.maximum??null,Q.regex=(...q)=>Q.check(a7(...q)),Q.includes=(...q)=>Q.check(Q4(...q)),Q.startsWith=(...q)=>Q.check($4(...q)),Q.endsWith=(...q)=>Q.check(Y4(...q)),Q.min=(...q)=>Q.check(F9(...q)),Q.max=(...q)=>Q.check(H3(...q)),Q.length=(...q)=>Q.check(G3(...q)),Q.nonempty=(...q)=>Q.check(F9(1,...q)),Q.lowercase=(q)=>Q.check(t7(q)),Q.uppercase=(q)=>Q.check(e7(q)),Q.trim=()=>Q.check(J4()),Q.normalize=(...q)=>Q.check(q4(...q)),Q.toLowerCase=()=>Q.check(X4()),Q.toUpperCase=()=>Q.check(H4()),Q.slugify=()=>Q.check(G4())}),Bz=j("ZodString",(Q,$)=>{Y3.init(Q,$),_q.init(Q,$),Q.email=(Y)=>Q.check(h$(_z,Y)),Q.url=(Y)=>Q.check(c$(Zz,Y)),Q.jwt=(Y)=>Q.check(qY(Rz,Y)),Q.emoji=(Y)=>Q.check(d$(Mz,Y)),Q.guid=(Y)=>Q.check(r7(Gq,Y)),Q.uuid=(Y)=>Q.check(f$(W3,Y)),Q.uuidv4=(Y)=>Q.check(u$(W3,Y)),Q.uuidv6=(Y)=>Q.check(m$(W3,Y)),Q.uuidv7=(Y)=>Q.check(g$(W3,Y)),Q.nanoid=(Y)=>Q.check(p$(Uz,Y)),Q.guid=(Y)=>Q.check(r7(Gq,Y)),Q.cuid=(Y)=>Q.check(l$(Vz,Y)),Q.cuid2=(Y)=>Q.check(i$(Az,Y)),Q.ulid=(Y)=>Q.check(n$(Lz,Y)),Q.base64=(Y)=>Q.check(QY(Nz,Y)),Q.base64url=(Y)=>Q.check($Y(Tz,Y)),Q.xid=(Y)=>Q.check(o$(Fz,Y)),Q.ksuid=(Y)=>Q.check(s$(jz,Y)),Q.ipv4=(Y)=>Q.check(r$(wz,Y)),Q.ipv6=(Y)=>Q.check(a$(Dz,Y)),Q.cidrv4=(Y)=>Q.check(t$(Oz,Y)),Q.cidrv6=(Y)=>Q.check(e$(Iz,Y)),Q.e164=(Y)=>Q.check(YY(bz,Y)),Q.datetime=(Y)=>Q.check(dY(Y)),Q.date=(Y)=>Q.check(pY(Y)),Q.time=(Y)=>Q.check(lY(Y)),Q.duration=(Y)=>Q.check(iY(Y))});S1=j("ZodStringFormat",(Q,$)=>{b1.init(Q,$),_q.init(Q,$)}),_z=j("ZodEmail",(Q,$)=>{uQ.init(Q,$),S1.init(Q,$)}),Gq=j("ZodGUID",(Q,$)=>{hQ.init(Q,$),S1.init(Q,$)}),W3=j("ZodUUID",(Q,$)=>{fQ.init(Q,$),S1.init(Q,$)}),Zz=j("ZodURL",(Q,$)=>{mQ.init(Q,$),S1.init(Q,$)}),Mz=j("ZodEmoji",(Q,$)=>{gQ.init(Q,$),S1.init(Q,$)}),Uz=j("ZodNanoID",(Q,$)=>{cQ.init(Q,$),S1.init(Q,$)}),Vz=j("ZodCUID",(Q,$)=>{dQ.init(Q,$),S1.init(Q,$)}),Az=j("ZodCUID2",(Q,$)=>{pQ.init(Q,$),S1.init(Q,$)}),Lz=j("ZodULID",(Q,$)=>{lQ.init(Q,$),S1.init(Q,$)}),Fz=j("ZodXID",(Q,$)=>{iQ.init(Q,$),S1.init(Q,$)}),jz=j("ZodKSUID",(Q,$)=>{nQ.init(Q,$),S1.init(Q,$)}),wz=j("ZodIPv4",(Q,$)=>{tQ.init(Q,$),S1.init(Q,$)}),Dz=j("ZodIPv6",(Q,$)=>{eQ.init(Q,$),S1.init(Q,$)}),Oz=j("ZodCIDRv4",(Q,$)=>{Q$.init(Q,$),S1.init(Q,$)}),Iz=j("ZodCIDRv6",(Q,$)=>{$$.init(Q,$),S1.init(Q,$)}),Nz=j("ZodBase64",(Q,$)=>{q$.init(Q,$),S1.init(Q,$)}),Tz=j("ZodBase64URL",(Q,$)=>{J$.init(Q,$),S1.init(Q,$)}),bz=j("ZodE164",(Q,$)=>{X$.init(Q,$),S1.init(Q,$)}),Rz=j("ZodJWT",(Q,$)=>{H$.init(Q,$),S1.init(Q,$)}),Zq=j("ZodNumber",(Q,$)=>{l7.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(q,J,X)=>jY(Q,q,J,X),Q.gt=(q,J)=>Q.check(J3(q,J)),Q.gte=(q,J)=>Q.check(W2(q,J)),Q.min=(q,J)=>Q.check(W2(q,J)),Q.lt=(q,J)=>Q.check(q3(q,J)),Q.lte=(q,J)=>Q.check(K2(q,J)),Q.max=(q,J)=>Q.check(K2(q,J)),Q.int=(q)=>Q.check(Kq(q)),Q.safe=(q)=>Q.check(Kq(q)),Q.positive=(q)=>Q.check(J3(0,q)),Q.nonnegative=(q)=>Q.check(W2(0,q)),Q.negative=(q)=>Q.check(q3(0,q)),Q.nonpositive=(q)=>Q.check(K2(0,q)),Q.multipleOf=(q,J)=>Q.check(X3(q,J)),Q.step=(q,J)=>Q.check(X3(q,J)),Q.finite=()=>Q;let Y=Q._zod.bag;Q.minValue=Math.max(Y.minimum??Number.NEGATIVE_INFINITY,Y.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,Q.maxValue=Math.min(Y.maximum??Number.POSITIVE_INFINITY,Y.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,Q.isInt=(Y.format??"").includes("int")||Number.isSafeInteger(Y.multipleOf??0.5),Q.isFinite=!0,Q.format=Y.format??null});Sz=j("ZodNumberFormat",(Q,$)=>{G$.init(Q,$),Zq.init(Q,$)});Ez=j("ZodBoolean",(Q,$)=>{K$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>wY(Q,Y,q,J)});kz=j("ZodAny",(Q,$)=>{W$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>OY(Q,Y,q,J)});vz=j("ZodUnknown",(Q,$)=>{z$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>IY(Q,Y,q,J)});Pz=j("ZodNever",(Q,$)=>{B$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>DY(Q,Y,q,J)});Cz=j("ZodArray",(Q,$)=>{_$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>SY(Q,Y,q,J),Q.element=$.element,Q.min=(Y,q)=>Q.check(F9(Y,q)),Q.nonempty=(Y)=>Q.check(F9(1,Y)),Q.max=(Y,q)=>Q.check(H3(Y,q)),Q.length=(Y,q)=>Q.check(G3(Y,q)),Q.unwrap=()=>Q.element});yz=j("ZodObject",(Q,$)=>{U$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>EY(Q,Y,q,J),z1.defineLazy(Q,"shape",()=>{return $.shape}),Q.keyof=()=>t1(Object.keys(Q._zod.def.shape)),Q.catchall=(Y)=>Q.clone({...Q._zod.def,catchall:Y}),Q.passthrough=()=>Q.clone({...Q._zod.def,catchall:I8()}),Q.loose=()=>Q.clone({...Q._zod.def,catchall:I8()}),Q.strict=()=>Q.clone({...Q._zod.def,catchall:xz()}),Q.strip=()=>Q.clone({...Q._zod.def,catchall:void 0}),Q.extend=(Y)=>{return z1.extend(Q,Y)},Q.safeExtend=(Y)=>{return z1.safeExtend(Q,Y)},Q.merge=(Y)=>z1.merge(Q,Y),Q.pick=(Y)=>z1.pick(Q,Y),Q.omit=(Y)=>z1.omit(Q,Y),Q.partial=(...Y)=>z1.partial(Uq,Q,Y[0]),Q.required=(...Y)=>z1.required(Vq,Q,Y[0])});hz=j("ZodUnion",(Q,$)=>{V$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>kY(Q,Y,q,J),Q.options=$.options});fz=j("ZodIntersection",(Q,$)=>{A$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>vY(Q,Y,q,J)});mz=j("ZodRecord",(Q,$)=>{L$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>PY(Q,Y,q,J),Q.keyType=$.keyType,Q.valueType=$.valueType});L4=j("ZodEnum",(Q,$)=>{F$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(q,J,X)=>NY(Q,q,J,X),Q.enum=$.entries,Q.options=Object.values($.entries);let Y=new Set(Object.keys($.entries));Q.extract=(q,J)=>{let X={};for(let H of q)if(Y.has(H))X[H]=$.entries[H];else throw Error(`Key ${H} not found in enum`);return new L4({...$,checks:[],...z1.normalizeParams(J),entries:X})},Q.exclude=(q,J)=>{let X={...$.entries};for(let H of q)if(Y.has(H))delete X[H];else throw Error(`Key ${H} not found in enum`);return new L4({...$,checks:[],...z1.normalizeParams(J),entries:X})}});gz=j("ZodLiteral",(Q,$)=>{j$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>TY(Q,Y,q,J),Q.values=new Set($.values),Object.defineProperty(Q,"value",{get(){if($.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return $.values[0]}})});cz=j("ZodTransform",(Q,$)=>{w$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>RY(Q,Y,q,J),Q._zod.parse=(Y,q)=>{if(q.direction==="backward")throw new t9(Q.constructor.name);Y.addIssue=(X)=>{if(typeof X==="string")Y.issues.push(z1.issue(X,Y.value,$));else{let H=X;if(H.fatal)H.continue=!1;H.code??(H.code="custom"),H.input??(H.input=Y.value),H.inst??(H.inst=Q),Y.issues.push(z1.issue(H))}};let J=$.transform(Y.value,Y);if(J instanceof Promise)return J.then((X)=>{return Y.value=X,Y});return Y.value=J,Y}});Uq=j("ZodOptional",(Q,$)=>{i7.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>B4(Q,Y,q,J),Q.unwrap=()=>Q._zod.def.innerType});pz=j("ZodExactOptional",(Q,$)=>{D$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>B4(Q,Y,q,J),Q.unwrap=()=>Q._zod.def.innerType});iz=j("ZodNullable",(Q,$)=>{O$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>xY(Q,Y,q,J),Q.unwrap=()=>Q._zod.def.innerType});nz=j("ZodDefault",(Q,$)=>{I$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>yY(Q,Y,q,J),Q.unwrap=()=>Q._zod.def.innerType,Q.removeDefault=Q.unwrap});sz=j("ZodPrefault",(Q,$)=>{N$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>hY(Q,Y,q,J),Q.unwrap=()=>Q._zod.def.innerType});Vq=j("ZodNonOptional",(Q,$)=>{T$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>CY(Q,Y,q,J),Q.unwrap=()=>Q._zod.def.innerType});tz=j("ZodCatch",(Q,$)=>{b$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>fY(Q,Y,q,J),Q.unwrap=()=>Q._zod.def.innerType,Q.removeCatch=Q.unwrap});QB=j("ZodPipe",(Q,$)=>{R$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>uY(Q,Y,q,J),Q.in=$.in,Q.out=$.out});$B=j("ZodReadonly",(Q,$)=>{S$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>mY(Q,Y,q,J),Q.unwrap=()=>Q._zod.def.innerType});qB=j("ZodCustom",(Q,$)=>{E$.init(Q,$),E1.init(Q,$),Q._zod.processJSONSchema=(Y,q,J)=>bY(Q,Y,q,J)})});var Aq;var Lq=A(()=>{(function(Q){})(Aq||(Aq={}))});var Fq=()=>{};var jq=A(()=>{o0();o0();v$();o7();Z4();Fq();M4();_4();V4();A4();Lq();I0(n7())});var H8=A(()=>{jq()});var Dq;var wq=A(()=>{Dq={name:"ocx",version:"2.0.10",description:"OCX CLI - OpenCode extension manager with portable, isolated profiles. Your setup, anywhere.",author:"kdcokenny",license:"MIT",type:"module",main:"./dist/index.js",bin:{ocx:"./dist/index.js"},files:["dist/index.js"],publishConfig:{access:"public"},repository:{type:"git",url:"https://github.com/kdcokenny/ocx.git"},homepage:"https://github.com/kdcokenny/ocx#readme",bugs:{url:"https://github.com/kdcokenny/ocx/issues"},keywords:["opencode","cli","extensions","agents","plugins","mcp","shadcn","registry"],engines:{bun:">=1.2.0"},scripts:{build:"bun run scripts/build.ts","build:binary":"bun run scripts/build-binary.ts","build:binary:all":"bun run scripts/build-binary.ts --all","build:binary:windows":"bun run scripts/build-binary.ts --target=windows-x64 && bun run scripts/build-binary.ts --target=windows-x64-baseline","release:tag":"bun run scripts/release-tag.ts",check:"bun check:biome && bun check:types","check:biome":"biome check .","check:types":"tsc --noEmit",dev:"bun run src/index.ts",prepublishOnly:"bun run build",test:"bun test","test:binary-smoke":"OCX_DIST_TESTS=1 bun test tests/binary-smoke.test.ts"},dependencies:{commander:"^14.0.3",fuzzysort:"^3.1.0","jsonc-parser":"3.3.1",kleur:"^4.1.5",ora:"^9.3.0",remeda:"^2.33.7",zod:"^4.3.6"},devDependencies:{"@types/bun":"^1.3.11"}}});function KB(Q){return`https://${_2}/schemas/v${Q}/registry.json`}var _2="ocx.kdco.dev",Oq="kdcokenny/ocx",j4,w4,h0=2,f0,Iq;var z3=A(()=>{wq();j4=`https://${_2}/schemas/ocx.json`,w4=`https://${_2}/schemas/registry.json`;f0=KB(h0),Iq=Dq.version});var G1,B1,_1,I1,h,L,u8,n1,m8,x1,u0,C1,N8,w9,m0,D9,D4;var t=A(()=>{G1={SUCCESS:0,GENERAL:1,NOT_FOUND:66,NETWORK:69,CONFIG:78,INTEGRITY:65,CONFLICT:6};B1=class B1 extends Error{code;exitCode;constructor(Q,$,Y=G1.GENERAL){super(Q);this.code=$;this.exitCode=Y;this.name="OCXError"}};_1=class _1 extends B1{constructor(Q){super(Q,"NOT_FOUND",G1.NOT_FOUND);this.name="NotFoundError"}};I1=class I1 extends B1{url;status;statusText;phase;qualifiedName;registryContext;registryName;constructor(Q,$){super(Q,"NETWORK_ERROR",G1.NETWORK);this.name="NetworkError",this.url=$?.url,this.status=$?.status,this.statusText=$?.statusText,this.phase=$?.phase,this.qualifiedName=$?.qualifiedName,this.registryContext=$?.registryContext,this.registryName=$?.registryName}};h=class h extends B1{constructor(Q){super(Q,"CONFIG_ERROR",G1.CONFIG);this.name="ConfigError"}};L=class L extends B1{constructor(Q){super(Q,"VALIDATION_ERROR",G1.GENERAL);this.name="ValidationError"}};u8=class u8 extends B1{details;constructor(Q){super("Registry validation failed","VALIDATION_FAILED",G1.CONFIG);this.details=Q;this.name="ValidationFailedError"}};n1=class n1 extends B1{constructor(Q){super(Q,"CONFLICT",G1.CONFLICT);this.name="ConflictError"}};m8=class m8 extends B1{component;expected;found;constructor(Q,$,Y){let q=`Integrity verification failed for "${Q}"
56
56
  Expected: ${$}
57
57
  Found: ${Y}
58
58
 
@@ -165,10 +165,10 @@ To reset, delete the config and run init again:
165
165
 
166
166
  <!-- Add your custom instructions for this profile here -->
167
167
  <!-- These will be included when running \`ocx opencode -p default\` -->
168
- `,{mode:384}),Y.push("profileAgents");if($?.succeed("Initialized global profiles"),Q.json)console.log(JSON.stringify({success:!0,files:{globalConfig:J,profileOcx:G,profileOpencode:K,profileAgents:W},created:Y,existed:q}));else if(!Q.quiet)if(Y.length>0){for(let z of Y){if(z==="globalConfig")_.info(`Created global config: ${J}`);if(z==="profileOcx")_.info(`Created profile config: ${G}`);if(z==="profileOpencode")_.info(`Created profile opencode config: ${K}`);if(z==="profileAgents")_.info(`Created profile instructions: ${W}`)}_.info(""),_.info("Next steps:"),_.info(" 1. Edit your profile config: ocx config edit -p default"),_.info(" 2. Add registries: ocx registry add <url> --name <name> --global"),_.info(" 3. Launch OpenCode: ocx opencode"),_.info(" 4. Create more profiles: ocx profile add <name> --global")}else _.info("Global profiles already initialized (all files exist)")}catch(Y){throw $?.fail("Failed to initialize"),Y}}async function vU(Q,$){let Y=Q,q=$.namespace??"my-registry",J=$.author??"Your Name";if(!/^[a-z0-9]+(-[a-z0-9]+)*$/.test(q))throw new L("Invalid namespace format: must start with letter/number, use hyphens only between segments (e.g., 'my-registry')");if((await aH(Y).catch(()=>[])).some((K)=>!K.startsWith(".")))throw new n1("Directory is not empty. Remove existing files or choose a different directory.");let G=$.quiet?null:M1({text:"Scaffolding registry..."});G?.start();try{if(G)G.text=$.local?"Copying template...":"Fetching template...";if($.local)await c9(Y,{recursive:!0}),await QG($.local,Y);else{let K=$.canary?"main":PU();await CU(Y,K,$.verbose)}if(G)G.text="Configuring project...";if(await hU(Y,{namespace:q,author:J}),G?.succeed(`Created registry: ${q}`),$.json)console.log(JSON.stringify({success:!0,namespace:q,path:Y}));else if(!$.quiet)_.info(""),_.info("Next steps:"),_.info(" 1. bun install"),_.info(" 2. Edit registry.jsonc with your components"),_.info(" 3. bun run build"),_.info(""),_.info("Deploy to:"),_.info(" Cloudflare: bunx wrangler deploy"),_.info(" Vercel: vercel"),_.info(" Netlify: netlify deploy")}catch(K){throw G?.fail("Failed to scaffold registry"),K}}async function QG(Q,$){await NU(Q,$,{recursive:!0})}function PU(){return"v2.0.9"}function xU(Q){let $=Q==="main"?"heads/main":`tags/${Q}`;return`https://github.com/${RU}/archive/refs/${$}.tar.gz`}async function CU(Q,$,Y){let q=xU($);if(Y)_.info(`Fetching ${q}`);let J=await fetch(q);if(!J.ok||!J.body)throw new I1(`Failed to fetch template from ${q}: ${J.statusText}`);let X=s3(Q,".ocx-temp");await c9(X,{recursive:!0});try{let H=s3(X,"template.tar.gz"),G=await J.arrayBuffer();await y6(H,Buffer.from(G));let K=Bun.spawn(["tar","-xzf",H,"-C",X],{stdout:"ignore",stderr:"pipe"});if(await K.exited!==0){let M=await new Response(K.stderr).text();throw Error(`Failed to extract template: ${M}`)}let B=(await aH(X)).find((M)=>M.startsWith("ocx-"));if(!B)throw Error("Failed to find extracted template directory");let Z=s3(X,B,SU);await QG(Z,Q)}finally{await bU(X,{recursive:!0,force:!0})}}function yU(Q){return Q.split(/[-_\s]+/).map(($)=>$.charAt(0).toUpperCase()+$.slice(1).toLowerCase()).join(" ")}async function hU(Q,$){let Y=["registry.jsonc","package.json","wrangler.jsonc","README.md","AGENTS.md"];for(let q of Y){let J=s3(Q,q);if(!J9(J))continue;let X=await TU(J).then((H)=>H.toString());if(X=X.replace(/my-registry/g,$.namespace),X=X.replace(/My Registry/g,yU($.namespace)),X=X.replace(/Your Name/g,$.author),q==="registry.jsonc")if(/"\$schema"\s*:/.test(X))X=X.replace(/("\$schema"\s*:\s*")[^"]*(")/,`$1${f0}$2`);else X=X.replace(/{/,`{
168
+ `,{mode:384}),Y.push("profileAgents");if($?.succeed("Initialized global profiles"),Q.json)console.log(JSON.stringify({success:!0,files:{globalConfig:J,profileOcx:G,profileOpencode:K,profileAgents:W},created:Y,existed:q}));else if(!Q.quiet)if(Y.length>0){for(let z of Y){if(z==="globalConfig")_.info(`Created global config: ${J}`);if(z==="profileOcx")_.info(`Created profile config: ${G}`);if(z==="profileOpencode")_.info(`Created profile opencode config: ${K}`);if(z==="profileAgents")_.info(`Created profile instructions: ${W}`)}_.info(""),_.info("Next steps:"),_.info(" 1. Edit your profile config: ocx config edit -p default"),_.info(" 2. Add registries: ocx registry add <url> --name <name> --global"),_.info(" 3. Launch OpenCode: ocx opencode"),_.info(" 4. Create more profiles: ocx profile add <name> --global")}else _.info("Global profiles already initialized (all files exist)")}catch(Y){throw $?.fail("Failed to initialize"),Y}}async function vU(Q,$){let Y=Q,q=$.namespace??"my-registry",J=$.author??"Your Name";if(!/^[a-z0-9]+(-[a-z0-9]+)*$/.test(q))throw new L("Invalid namespace format: must start with letter/number, use hyphens only between segments (e.g., 'my-registry')");if((await aH(Y).catch(()=>[])).some((K)=>!K.startsWith(".")))throw new n1("Directory is not empty. Remove existing files or choose a different directory.");let G=$.quiet?null:M1({text:"Scaffolding registry..."});G?.start();try{if(G)G.text=$.local?"Copying template...":"Fetching template...";if($.local)await c9(Y,{recursive:!0}),await QG($.local,Y);else{let K=$.canary?"main":PU();await CU(Y,K,$.verbose)}if(G)G.text="Configuring project...";if(await hU(Y,{namespace:q,author:J}),G?.succeed(`Created registry: ${q}`),$.json)console.log(JSON.stringify({success:!0,namespace:q,path:Y}));else if(!$.quiet)_.info(""),_.info("Next steps:"),_.info(" 1. bun install"),_.info(" 2. Edit registry.jsonc with your components"),_.info(" 3. bun run build"),_.info(""),_.info("Deploy to:"),_.info(" Cloudflare: bunx wrangler deploy"),_.info(" Vercel: vercel"),_.info(" Netlify: netlify deploy")}catch(K){throw G?.fail("Failed to scaffold registry"),K}}async function QG(Q,$){await NU(Q,$,{recursive:!0})}function PU(){return"v2.0.10"}function xU(Q){let $=Q==="main"?"heads/main":`tags/${Q}`;return`https://github.com/${RU}/archive/refs/${$}.tar.gz`}async function CU(Q,$,Y){let q=xU($);if(Y)_.info(`Fetching ${q}`);let J=await fetch(q);if(!J.ok||!J.body)throw new I1(`Failed to fetch template from ${q}: ${J.statusText}`);let X=s3(Q,".ocx-temp");await c9(X,{recursive:!0});try{let H=s3(X,"template.tar.gz"),G=await J.arrayBuffer();await y6(H,Buffer.from(G));let K=Bun.spawn(["tar","-xzf",H,"-C",X],{stdout:"ignore",stderr:"pipe"});if(await K.exited!==0){let M=await new Response(K.stderr).text();throw Error(`Failed to extract template: ${M}`)}let B=(await aH(X)).find((M)=>M.startsWith("ocx-"));if(!B)throw Error("Failed to find extracted template directory");let Z=s3(X,B,SU);await QG(Z,Q)}finally{await bU(X,{recursive:!0,force:!0})}}function yU(Q){return Q.split(/[-_\s]+/).map(($)=>$.charAt(0).toUpperCase()+$.slice(1).toLowerCase()).join(" ")}async function hU(Q,$){let Y=["registry.jsonc","package.json","wrangler.jsonc","README.md","AGENTS.md"];for(let q of Y){let J=s3(Q,q);if(!J9(J))continue;let X=await TU(J).then((H)=>H.toString());if(X=X.replace(/my-registry/g,$.namespace),X=X.replace(/My Registry/g,yU($.namespace)),X=X.replace(/Your Name/g,$.author),q==="registry.jsonc")if(/"\$schema"\s*:/.test(X))X=X.replace(/("\$schema"\s*:\s*")[^"]*(")/,`$1${f0}$2`);else X=X.replace(/{/,`{
169
169
  "$schema": "${f0}",`);await y6(J,X)}}var RU="kdcokenny/ocx",SU="examples/registry-starter";var $G=A(()=>{z3();j3();t0();W0();q0();$6();t();y1();c1();k0();l0()});function fU(Q,$,Y){let q=Q.indexOf("/");if(q===-1)throw Error(`Invalid legacy key: "${Q}". Expected format: alias/component`);let J=Q.slice(0,q),X=Q.slice(q+1);if(!J||!X)throw Error(`Invalid legacy key: "${Q}". Both alias and component are required.`);let H=A2(Y,J,X,$.version),G={registryUrl:Y,registryName:J,name:X,revision:$.version,hash:$.hash,files:$.files.map((K)=>({path:K,hash:""})),installedAt:$.installedAt,...$.updatedAt&&{updatedAt:$.updatedAt},owner:{type:"user"}};return[H,G]}function r3(Q,$,Y){let q={},J=[],X=Object.keys(Q.installed).sort();for(let G of X){let K=Q.installed[G];if(!K)continue;let W=$.registries[K.registry];if(!W)throw new h(`Registry "${K.registry}" referenced in lock key "${G}" is not configured in ocx.jsonc. Add it before migrating.`);let[z,B]=fU(G,K,W.url);q[z]=B,J.push({legacyKey:G,canonicalId:z,name:B.name,registryName:B.registryName})}return{receipt:{version:1,...Y&&{root:Y},installed:q},components:J}}function YG(Q){let $=Q.registries;if(!$||typeof $!=="object"||Array.isArray($))return[];let Y=[],q=$;for(let J of Object.keys(q).sort()){let X=q[J];if(!X||typeof X!=="object"||Array.isArray(X))continue;let H=X;for(let G of uU)if(G in H)Y.push({registry:J,field:G,action:"remove_deprecated"})}return Y}var uU;var qG=A(()=>{q0();t();uU=["version"]});import{existsSync as h6,readdirSync as mU,readFileSync as GG,statSync as gU}from"fs";import{rename as a3,writeFile as cU}from"fs/promises";import{join as JG}from"path";function KG(Q){Q.command("migrate").description("Migrate legacy ocx.lock to receipt format (.ocx/receipt.jsonc)").option("--global","Migrate global config scope (includes profiles)").option("--apply","Apply migration (default is dry-run preview)").option("--json","Output as JSON").option("-q, --quiet","Suppress output").option("--cwd <path>","Working directory").action(async($)=>{try{await pU($)}catch(Y){s(Y,{json:$.json})}})}async function pU(Q){if(Q.global){await lU(Q);return}await qV(Q,"local",GV(Q),!1)}async function lU(Q){let $=Q.cwd??j0(),Y=iU($);if(!Q.apply){let H=[],G=new Set;for(let{label:z,path:B}of Y){let Z=S8(B),M=T9(B,{isFlattened:!0});if(Z.exists&&M.exists)G.add(z);try{let V=await nU(B,!0,{emitWarnings:!Q.json&&!Q.quiet});H.push({...V,target:z})}catch(V){let U=HG(z,V);if(H.push(U),!Q.json&&!Q.quiet)_.error(`[global:${z}] Preview failed: ${U.error}`)}}let K=XG(H,"global",!1),W=sU(K);if(Q.json){if(d9(K,!1),W)process.exit(1);return}if(!Q.quiet)JV(H,K,G);if(W)process.exit(1);return}let q=[],J=!1;for(let{label:H,path:G}of Y)try{let K=await oU(G,!0);q.push({...K,target:H})}catch(K){J=!0;let W=HG(H,K);if(q.push(W),!Q.json&&!Q.quiet)_.error(`[global:${H}] Migration failed: ${W.error}`)}let X=XG(q,"global",!0);if(Q.json){if(d9(X,!0),J)process.exit(1);return}if(!Q.quiet)XV(q,J);if(J)process.exit(1)}function iU(Q){let $=[];$.push({label:"root",path:Q});let Y=JG(Q,"profiles");if(h6(Y)&&gU(Y).isDirectory()){let J=mU(Y,{withFileTypes:!0}).filter((X)=>X.isDirectory()&&!X.name.startsWith(".")).map((X)=>X.name).sort();for(let X of J)$.push({label:`profile:${X}`,path:JG(Y,X)})}return $}async function nU(Q,$,Y){let q=Y?.emitWarnings??!0,J=f6(Q),X=S8(Q),H=T9(Q,{isFlattened:$}),G=X.exists&&H.exists;if(X.exists&&J.length===0&&!G)return{status:"already_v2",count:0,components:[],configActions:[]};if(!H.exists&&!X.exists&&J.length===0)return{status:"nothing_to_migrate",count:0,components:[],configActions:[]};let K=[];if(H.exists&&!X.exists)try{let W=await L2(Q,{isFlattened:$}),z=await b0(Q,{emitParseDiagnostics:q});if(W&&z)K=r3(W,z,Q).components}catch{if(q)_.warn(`[preview] Could not parse lock/config at "${Q}"; component count may be incomplete.`)}return{status:"preview",count:K.length,components:K,configActions:J}}async function oU(Q,$){let Y=f6(Q),q=S8(Q),J=T9(Q,{isFlattened:$}),X=q.exists&&J.exists;if(q.exists&&Y.length===0&&!X)return{status:"already_v2",count:0,components:[],configActions:[]};if(!J.exists&&!q.exists&&Y.length===0)return{status:"nothing_to_migrate",count:0,components:[],configActions:[]};let H=null;if(J.exists&&!q.exists){let z=await L2(Q,{isFlattened:$});if(!z)throw new L("Failed to parse ocx.lock. The lock file exists but could not be read or contains invalid data.");let B=await b0(Q);if(!B)throw new h("No ocx.jsonc found. The config is required to resolve registry URLs during migration.");let{receipt:Z,components:M}=r3(z,B,Q);H={newReceipt:Z,components:M}}let G=H?.components??[],K=G.length;if(H){await T0(Q,H.newReceipt);let z=t3(J.path);await a3(J.path,z)}if(X){let z=t3(J.path);await a3(J.path,z)}if(Y.length>0)await WG(Q,Y);return{status:H!==null||X||Y.length>0?"migrated":"already_v2",count:K,components:G,configActions:Y}}function XG(Q,$,Y){let q=Q.some((z)=>z.status==="error"),J=Q.some((z)=>z.status==="migrated"||z.status==="preview"),X=Q.every((z)=>z.status==="already_v2"||z.status==="nothing_to_migrate"),H=Q.reduce((z,B)=>z+B.count,0),G=Q.flatMap((z)=>z.components),K=Q.flatMap((z)=>z.configActions),W;if(q)W=Y?"partial_failure":"preview_with_errors";else if(X)W=Q.every((B)=>B.status==="nothing_to_migrate")?"nothing_to_migrate":"already_v2";else if(Y)W=J?"migrated":"already_v2";else W=J?"preview":"already_v2";return{success:!q,status:W,scope:$,count:H,components:G,configActions:K,targets:Q}}function sU(Q){return Q.status==="preview_with_errors"}function d9(Q,$){let Y=rU(Q,$);console.log(JSON.stringify(Y,null,2))}function rU(Q,$){let Y=aU(Q),q=Y.flatMap((J)=>J.blockers??[]);return{...Q,lifecycle_status:QV(Q.status,$),schema_version:dU,blockers:q,targets:Y}}function aU(Q){return(Q.targets&&Q.targets.length>0?Q.targets:[tU(Q)]).map((Y)=>eU(Y))}function tU(Q){return{target:Q.scope,status:Q.status,count:Q.count,components:Q.components,configActions:Q.configActions,blockers:Q.blockers??[]}}function eU(Q){let $=Q.blockers??(Q.status==="error"?[{code:"MIGRATE_BLOCKER",message:Q.error??"Migration blocked",path:Q.target}]:[]);return{...Q,scope:Q.scope??Q.target,result:Q.result??Q.status,blockers:$}}function QV(Q,$){if($)return Q==="partial_failure"?"apply_failed":"apply_ok";return Q==="preview_with_errors"?"preview_blocked":"preview_ok"}function HG(Q,$){let Y=$V($,Q);return{target:Q,status:"error",count:0,components:[],configActions:[],error:Y.message,blockers:[Y]}}function $V(Q,$){let Y=Q instanceof Error?Q.message:String(Q);return{code:YV(Q,Y),message:Y,path:$}}function YV(Q,$){if(typeof Q==="object"&&Q!==null&&"code"in Q){let q=Q.code;if(typeof q==="string"&&q.length>0)return q}let Y=$.toLowerCase();if(Y.includes("ocx.jsonc")||Y.includes("registry"))return"CONFIG_ERROR";if(Y.includes("parse")||Y.includes("invalid"))return"VALIDATION_ERROR";return"MIGRATE_BLOCKER"}async function qV(Q,$,Y,q){let J=f6(Y),X=S8(Y),H=T9(Y,{isFlattened:q}),G=X.exists&&H.exists;if(X.exists&&J.length===0&&!G){let M={success:!0,status:"already_v2",scope:$,count:0,components:[],configActions:[]};if(Q.json){d9(M,Boolean(Q.apply));return}if(!Q.quiet)_.success(`[${$}] Already migrated to receipt format (.ocx/receipt.jsonc).`);return}if(!H.exists&&!X.exists&&J.length===0){let M={success:!0,status:"nothing_to_migrate",scope:$,count:0,components:[],configActions:[]};if(Q.json){d9(M,Boolean(Q.apply));return}if(!Q.quiet)_.info(`[${$}] Nothing to migrate. No legacy ocx.lock found.`);return}let K=null;if(H.exists&&!X.exists){let M=await L2(Y,{isFlattened:q});if(!M)throw new L("Failed to parse ocx.lock. The lock file exists but could not be read or contains invalid data.");let V=await b0(Y);if(!V)throw new h("No ocx.jsonc found. The config is required to resolve registry URLs during migration.");let{receipt:U,components:R}=r3(M,V,Y);K={newReceipt:U,components:R}}let W=K?.components??[],z=W.length;if(!Q.apply){let M={success:!0,status:"preview",scope:$,count:z,components:W,configActions:J};if(Q.json){d9(M,!1);return}if(!Q.quiet){if(z>0){_.info(`[${$}] Migration preview: ${z} component(s) would be migrated.`),_.break();for(let V of W)_.info(` ${V.legacyKey} \u2192 ${V.canonicalId}`);_.break()}if(G)_.info(`[${$}] Legacy ocx.lock would be backed up and removed (receipt already exists).`),_.break();if(J.length>0){_.info(`[${$}] Config normalization: ${J.length} deprecated field(s) would be removed.`);for(let V of J)_.info(` registries.${V.registry}.${V.field} \u2192 remove`);_.break()}if(z===0&&J.length===0&&!G)_.info(`[${$}] Nothing to migrate.`);else _.info("No changes made. Run with --apply to perform migration.")}return}if(K){await T0(Y,K.newReceipt);let M=t3(H.path);if(await a3(H.path,M),!Q.json&&!Q.quiet){_.success(`[${$}] Migrated ${z} component(s) to receipt format (.ocx/receipt.jsonc).`),_.break();for(let V of W)_.success(` \u2713 ${V.legacyKey} \u2192 ${V.canonicalId}`);_.break(),_.info(`Legacy lock backed up to: ${M}`)}}if(G){let M=t3(H.path);if(await a3(H.path,M),!Q.json&&!Q.quiet)_.success(`[${$}] Removed stale legacy lock (receipt already exists).`),_.info(`Legacy lock backed up to: ${M}`)}if(J.length>0){if(await WG(Y,J),!Q.json&&!Q.quiet){if(K)_.break();_.success(`[${$}] Normalized ${J.length} deprecated config field(s).`);for(let M of J)_.success(` \u2713 registries.${M.registry}.${M.field} removed`)}}let Z={success:!0,status:K!==null||G||J.length>0?"migrated":"already_v2",scope:$,count:z,components:W,configActions:J};if(Q.json){d9(Z,!0);return}if(!K&&J.length>0&&!Q.quiet)_.break(),_.success(`[${$}] Config normalization complete.`)}function JV(Q,$,Y){if($.status==="nothing_to_migrate"){_.info("[global] Nothing to migrate across all targets.");return}if($.status==="already_v2"){_.success("[global] All targets already migrated.");return}_.info(`[global] Migration preview across ${Q.length} target(s):`),_.break();for(let q of Q){let J=Y.has(q.target),X=HV(q,J);_.info(` ${q.target}: ${X}`)}if(_.break(),$.status==="preview_with_errors")_.warn("[global] Preview completed with errors on some targets. See above for details."),_.info("No changes made. Run with --apply to perform migration.");else _.info("No changes made. Run with --apply to perform migration.")}function XV(Q,$){_.break();let Y=Q.filter((X)=>X.status==="migrated"),q=Q.filter((X)=>X.status==="already_v2"||X.status==="nothing_to_migrate"),J=Q.filter((X)=>X.status==="error");if(Y.length>0){_.success(`[global] Migrated ${Y.length} target(s):`);for(let X of Y)_.success(` \u2713 ${X.target}`)}if(q.length>0)_.info(`[global] ${q.length} target(s) already up to date.`);if(J.length>0){_.error(`[global] ${J.length} target(s) failed:`);for(let X of J)_.error(` \u2717 ${X.target}: ${X.error}`)}if($)_.break(),_.error("[global] Migration completed with errors. See above for details.")}function HV(Q,$){if(Q.status==="error")return"error";if(Q.status==="already_v2")return"already migrated";if(Q.status==="nothing_to_migrate")return"nothing to migrate";let Y=[];if(Q.count>0)Y.push(`${Q.count} component(s) to migrate`);if(Q.configActions.length>0)Y.push(`${Q.configActions.length} config field(s) to normalize`);if($)Y.push("legacy lock cleanup pending");if(Y.length===0)return"nothing to migrate";return Y.join(", ")}function GV(Q){if(Q.global)return Q.cwd??j0();return Q.cwd??process.cwd()}function t3(Q){let $=`${Q}.bak`;if(!h6($))return $;for(let Y=1;Y<=100;Y++){let q=`${$}.${Y}`;if(!h6(q))return q}return`${$}.${Date.now()}`}function f6(Q){let $=E8(Q);if(!$.exists)return[];try{let Y=GG($.path,"utf-8"),q=O1(Y,[],{allowTrailingComma:!0});if(!q||typeof q!=="object"||Array.isArray(q))return[];return YG(q)}catch{return[]}}async function WG(Q,$){if($.length===0)return;let Y=E8(Q);if(!Y.exists)return;let q=GG(Y.path,"utf-8");for(let J of $){let X=Z9(q,["registries",J.registry,J.field],void 0,KV);q=M9(q,X)}await cU(Y.path,q)}var dU=1,KV;var zG=A(()=>{O0();q0();t();y1();c1();k8();qG();KV={formattingOptions:{tabSize:2,insertSpaces:!0,eol:`
170
170
  `}}});import{basename as WV,resolve as dR}from"path";function e3(){let{GIT_DIR:Q,GIT_WORK_TREE:$,...Y}=process.env;return Y}async function zV(Q){let $=Bun.spawn(["git","symbolic-ref","--short","HEAD"],{cwd:Q,env:e3(),stdout:"pipe",stderr:"pipe"});if(await $.exited===0){let K=(await new Response($.stdout).text()).trim();if(K)return K}let q=Bun.spawn(["git","describe","--tags","--exact-match","HEAD"],{cwd:Q,env:e3(),stdout:"pipe",stderr:"pipe"});if(await q.exited===0){let K=(await new Response(q.stdout).text()).trim();if(K)return K}let X=Bun.spawn(["git","rev-parse","--short","HEAD"],{cwd:Q,env:e3(),stdout:"pipe",stderr:"pipe"});if(await X.exited===0){let K=(await new Response(X.stdout).text()).trim();if(K)return K}return null}async function BV(Q){let $=Bun.spawn(["git","rev-parse","--show-toplevel"],{cwd:Q,env:e3(),stdout:"pipe",stderr:"pipe"});if(await $.exited!==0)return null;let J=(await new Response($.stdout).text()).trim();if(!J)return null;return WV(J)}async function BG(Q){let[$,Y]=await Promise.all([BV(Q),zV(Q)]);return{repoName:$,branch:Y}}var _G=()=>{};import _V from"path";function ZV(Q){return Q<=31||Q>=127&&Q<=159}function MG(){return Boolean(process.env.TMUX)}function MV(Q){if(!MG())return;Bun.spawnSync(["tmux","rename-window",Q]),Bun.spawnSync(["tmux","set-window-option","automatic-rename","off"])}function UV(Q){if(!u6())return;let $=VV(Q);if(!$)return;process.stdout.write(`\x1B]0;${$}\x07`)}function VV(Q){let $="";for(let Y of Q){let q=Y.codePointAt(0);if(q===void 0)continue;$+=ZV(q)?" ":Y}return $.trim()}function u6(){return l8}function UG(Q){MV(Q),UV(Q)}function VG(){if(Q7||!l8)return;process.stdout.write("\x1B[22;2t"),Q7=!0}function m6(){if(!Q7)return;if(MG())Bun.spawnSync(["tmux","set-window-option","automatic-rename","on"]);if(l8)process.stdout.write("\x1B[23;2t");Q7=!1}function AG(Q,$,Y){let q=Y.repoName??_V.basename(Q);if(!Y.branch)return`ocx[${$}]:${q}`;let J=Y.branch.length>ZG?`${Y.branch.slice(0,ZG-3)}...`:Y.branch;return`ocx[${$}]:${q}/${J}`}var ZG=20,Q7=!1;var LG=A(()=>{F2()});import{randomUUID as AV}from"crypto";import{copyFile as LV,cp as FV,lstat as C8,mkdir as jV,mkdtemp as wV,readdir as wG,readFile as DV,realpath as l9,rename as OV,rm as IV,unlink as NV}from"fs/promises";import{tmpdir as TV}from"os";import{basename as bV,dirname as d6,isAbsolute as DG,join as U8,relative as p6}from"path";var{Glob:g6}=globalThis.Bun;function p(Q,$){return new h(`ocx oc ${Q} error: ${$}`)}function P1(Q){if(Q instanceof Error)return Q.message;return String(Q)}function kV(Q){if(Q.length===0)return"Unknown parse error";let $=Q[0];if(!$)return"Unknown parse error";return`${n0($.error)} at offset ${$.offset}`}function Y7(Q){return Q.replaceAll("\\","/")}function c6(Q){return Q.startsWith("./")?Q.slice(2):Q}function l6(Q,$){let Y=p6(Q,$);if(Y.length===0)return!0;return!Y.startsWith("..")&&!DG(Y)}function vV(Q){if(Q.isFile())return"file";if(Q.isDirectory())return"directory";if(Q.isSymbolicLink())return"symlink";return"other"}function x2(Q){return{entryType:vV(Q),device:String(Q.dev),inode:String(Q.ino),mode:String(Q.mode),size:String(Q.size),mtimeMs:String(Q.mtimeMs)}}function PV(Q,$){return Q.entryType===$.entryType&&Q.device===$.device&&Q.inode===$.inode&&Q.mode===$.mode}function xV(Q,$){return Q.size===$.size&&Q.mtimeMs===$.mtimeMs}async function p9(Q){let $;try{$=await C8(Q.absolutePath)}catch{throw p("validate",`Overlay path changed during ${Q.phase}: ${Q.overlayRelativePath}. ${x8}`)}if(Q.mustRemainDirectory&&!$.isDirectory())throw p("validate",`Overlay path changed during ${Q.phase}: ${Q.overlayRelativePath}. ${x8}`);if(Q.mustRemainFile&&!$.isFile())throw p("validate",`Overlay path changed during ${Q.phase}: ${Q.overlayRelativePath}. ${x8}`);let Y=x2($),q=PV(Q.expectedSnapshot,Y),X=!(Q.compareContent??!0)?!0:xV(Q.expectedSnapshot,Y);if(!q||!X)throw p("validate",`Overlay path changed during ${Q.phase}: ${Q.overlayRelativePath}. ${x8}`)}async function $7(Q,$,Y){let J=Y7(p6(Q,$)).split("/").filter((H)=>H.length>0),X=Q;for(let H of J){X=U8(X,H);let G;try{G=await C8(X)}catch(K){if(K.code==="ENOENT")return;throw p("validate",`Failed to inspect overlay destination path (${Y}): ${P1(K)}`)}if(G.isSymbolicLink())throw p("validate",`Overlay destination path contains existing symlink (${Y})`)}}function FG(Q,$,Y){for(let q of Y)try{new g6(c6(q))}catch{throw p("validate",`Invalid project overlay policy at ${Q}: ${$} contains invalid glob pattern "${q}"`)}}async function yV(Q){if(!Q)return{include:[],exclude:[]};let $=U8(Q,d0),Y=await hV(Q,$);if(!Y)return{include:[],exclude:[]};let q;try{q=await DV(Y,"utf8")}catch(W){throw p("read",`Failed to read project overlay policy at ${$}: ${P1(W)}`)}let J=[],X=O1(q,J,{allowTrailingComma:!0});if(J.length>0)throw p("parse",`Failed to parse project overlay policy at ${$}: ${kV(J)}`);if(!X||typeof X!=="object"||Array.isArray(X))throw p("validate",`Invalid project overlay policy at ${$}: root must be an object`);let H=CV.safeParse(X);if(!H.success){let W=H.error.issues[0],z=W?.path.length?W.path.join("."):"root",B=W?.message??"Invalid project overlay policy";throw p("validate",`Invalid project overlay policy at ${$}: ${z} ${B}`)}let G=H.data.include??[],K=H.data.exclude??[];return FG($,"include",G),FG($,"exclude",K),{include:G,exclude:K}}async function hV(Q,$){let Y;try{Y=await C8($)}catch(X){let H=X.code;if(H==="ENOENT"||H==="ENOTDIR")return null;throw p("read",`Failed to inspect project overlay policy at ${$}: ${P1(X)}`)}if(!Y.isSymbolicLink())return $;let q;try{q=await l9(Q)}catch(X){throw p("validate",`Unable to resolve project config directory ${Q}: ${P1(X)}`)}let J;try{J=await l9($)}catch(X){let H=X.code;if(H==="ENOENT"||H==="ENOTDIR")throw p("validate",`Broken symlink in project overlay policy: ${$}`);throw p("read",`Failed to inspect project overlay policy symlink at ${$}: ${P1(X)}`)}if(!l6(q,J))throw p("validate",`Symlink escapes project overlay policy scope: ${$}`);return J}function fV(Q,$){for(let Y of $.include)if(new g6(c6(Y)).match(Q))return!0;for(let Y of $.exclude)if(new g6(c6(Y)).match(Q))return!1;return!0}function uV(Q,$){return Q.filter((Y)=>fV(Y.overlayRelativePath,$)).map((Y)=>({sourcePath:Y.sourcePath,destinationRelativePath:Y.overlayRelativePath,sourceSnapshot:Y.sourceSnapshot}))}async function OG(Q,$,Y){let q;try{q=await l9($)}catch(J){let X=J.code;if(X==="ENOENT"||X==="ENOTDIR")throw p("validate",`Broken symlink in project overlay scope: ${Y}`);throw p("read",`Failed to inspect symlink at ${Y}: ${P1(J)}`)}if(!l6(Q,q))throw p("validate",`Symlink escapes project overlay scope: ${Y}`);throw p("validate",`Symlink entries are not supported in project overlay scope: ${Y}`)}async function IG(Q,$,Y,q,J){let X;try{X=await C8($)}catch(G){throw p("read",`Failed to inspect project overlay path ${Y}: ${P1(G)}`)}if(X.isSymbolicLink())await OG(Q,$,Y);let H=x2(X);if(X.isDirectory()){await J.beforeDirectoryRead?.({absolutePath:$,overlayRelativePath:Y});let G;try{G=await wG($)}catch(K){throw p("read",`Failed to read project overlay directory ${Y}: ${P1(K)}`)}G.sort((K,W)=>K.localeCompare(W));for(let K of G){let W=U8($,K),z=Y7(U8(Y,K));await IG(Q,W,z,q,J)}await p9({absolutePath:$,overlayRelativePath:Y,expectedSnapshot:H,phase:"overlay discovery",mustRemainDirectory:!0});return}if(!X.isFile())return;q.push({sourcePath:$,overlayRelativePath:Y7(Y),sourceSnapshot:H})}async function mV(Q,$={}){let Y;try{Y=await l9(Q)}catch(H){throw p("validate",`Unable to resolve project config directory ${Q}: ${P1(H)}`)}let q;try{q=await C8(Q)}catch(H){throw p("validate",`Unable to inspect project overlay root ${Q}: ${P1(H)}`)}if(!q.isDirectory())throw p("validate",`Project overlay root changed before discovery: ${Q}. ${x8}`);let J=x2(q),X=[];for(let H of RV){let G=U8(Q,H);await $.beforeScopeInspect?.({scope:H,scopeAbsolutePath:G,projectConfigDir:Q}),await p9({absolutePath:Q,overlayRelativePath:".opencode",expectedSnapshot:J,phase:"overlay discovery",mustRemainDirectory:!0});let K;try{K=await C8(G)}catch(W){let z=W.code;if(z==="ENOENT"||z==="ENOTDIR")continue;throw p("read",`Failed to inspect project overlay scope ${H}: ${P1(W)}`)}if(K.isSymbolicLink())await OG(Y,G,H);await IG(Y,G,H,X,$)}return X.sort((H,G)=>H.overlayRelativePath.localeCompare(G.overlayRelativePath)),X}function gV(Q){let $=d6(Q),Y=bV(Q),q=`${process.pid}-${AV()}`;return U8($,`.${Y}.ocx-tmp-${q}`)}async function cV(Q,$){let Y=gV($);try{await LV(Q,Y),await OV(Y,$)}catch(q){try{await NV(Y)}catch{}throw q}}async function dV(Q,$,Y={}){let q=Y.publishAtomically??cV,J;try{J=await C8($)}catch(H){throw p("validate",`Unable to inspect merged overlay root ${$}: ${P1(H)}`)}if(!J.isDirectory())throw p("validate",`Merged overlay root is not a directory: ${$}`);let X=x2(J);for(let H of Q){if(await Y.beforeSourceVerification?.(H),H.sourceSnapshot)await p9({absolutePath:H.sourcePath,overlayRelativePath:H.destinationRelativePath,expectedSnapshot:H.sourceSnapshot,phase:"overlay source verification",mustRemainFile:!0});await p9({absolutePath:$,overlayRelativePath:".merged",expectedSnapshot:X,phase:"overlay destination verification",mustRemainDirectory:!0,compareContent:!1});let G;try{G=A0($,H.destinationRelativePath)}catch(B){throw p("validate",`Overlay destination path is invalid (${H.destinationRelativePath}): ${P1(B)}`)}await $7($,G,H.destinationRelativePath);let K=d6(G);await Y.beforeDestinationParentCreate?.({operation:H,destinationPath:G,destinationParentPath:K}),await $7($,G,H.destinationRelativePath);try{await jV(K,{recursive:!0})}catch(B){throw p("copy",`Failed to copy overlay file ${H.destinationRelativePath}: ${P1(B)}`)}await $7($,G,H.destinationRelativePath);let W;try{W=await C8(K)}catch(B){throw p("validate",`Failed to inspect overlay destination parent (${H.destinationRelativePath}): ${P1(B)}`)}if(!W.isDirectory())throw p("validate",`Overlay destination parent changed before publish (${H.destinationRelativePath}). ${x8}`);let z=x2(W);await Y.beforeDestinationPublish?.({operation:H,destinationPath:G,destinationParentPath:K}),await p9({absolutePath:$,overlayRelativePath:".merged",expectedSnapshot:X,phase:"overlay destination publish",mustRemainDirectory:!0,compareContent:!1}),await p9({absolutePath:K,overlayRelativePath:H.destinationRelativePath,expectedSnapshot:z,phase:"overlay destination publish",mustRemainDirectory:!0,compareContent:!1}),await $7($,G,H.destinationRelativePath);try{await q(H.sourcePath,G)}catch(B){if(B instanceof h)throw B;throw p("copy",`Failed to copy overlay file ${H.destinationRelativePath}: ${P1(B)}`)}}}async function pV(Q,$){let Y;try{Y=await wG(Q)}catch(q){throw p("copy",`Failed to read profile directory ${Q}: ${P1(q)}`)}for(let q of Y){let J=U8(Q,q),X=U8($,q);try{await FV(J,X,{recursive:!0,force:!0,errorOnExist:!1})}catch(H){throw p("copy",`Failed to copy profile base file ${q}: ${P1(H)}`)}}}async function jG(Q){try{await IV(Q,{recursive:!0,force:!0})}catch($){throw p("cleanup",`Failed to remove temporary merged config directory ${Q}: ${P1($)}`)}}function lV(Q,$){let Y=Y7(p6(Q,$));if(!Y||Y===".")throw p("validate",`Overlay source path failed relative parsing: ${$}`);if(Y===".."||Y.startsWith("../")||DG(Y))throw p("validate",`Overlay source path escapes project overlay scope: ${$}`);return Y}function iV(Q,$){let Y=$.map((q)=>{if(!q.sourceSnapshot)throw p("validate",`Overlay source snapshot missing for ${q.destinationRelativePath}. ${x8}`);return{sourceRelativePath:lV(Q,q.sourcePath),destinationRelativePath:q.destinationRelativePath,sourceSnapshot:q.sourceSnapshot}});return{version:EV,projectConfigDir:Q,operations:Y}}function nV(){return null}async function oV(Q){let $=Q.manifest.operations.map((Y)=>({sourcePath:A0(Q.manifest.projectConfigDir,Y.sourceRelativePath),destinationRelativePath:Y.destinationRelativePath,sourceSnapshot:Y.sourceSnapshot}));await dV($,Q.mergedConfigDir,Q.copySeams)}async function sV(Q){if(Q.manifest.operations.length===0)return"best-effort-js";let $=Q.nativeHelper??nV();if($)return await $.applyManifest(Q.manifest,Q.mergedConfigDir),"native-fd";if(Q.hardeningMode==="native-fd-required")throw p("validate",`Native fd helper required for overlay merge, but none is available in this Bun/Node runtime. ${x8}`);return await oV({manifest:Q.manifest,mergedConfigDir:Q.mergedConfigDir,copySeams:Q.copySeams}),"best-effort-js"}async function rV(Q){let $=d6(Q),Y;try{Y=await l9($)}catch(J){throw p("validate",`Unable to resolve project directory ${$}: ${P1(J)}`)}let q;try{q=await l9(Q)}catch(J){throw p("validate",`Unable to resolve project config directory ${Q}: ${P1(J)}`)}if(!l6(Y,q))throw p("validate",`Project .opencode root resolves outside project directory: ${Q}`);return q}function aV(Q){if(Q instanceof h)return Q;return p("copy",`Failed to prepare temporary merged config directory: ${P1(Q)}`)}async function NG(Q){let $=M8(Q.projectDir),Y=Q.hardeningMode??"best-effort-js",q=null;try{q=await wV(U8(TV(),SV)),await pV(Q.profileDir,q);let J="best-effort-js";if($){let H=await rV($),G=await yV(H),K=await mV(H,Q.seams?.collection),W=uV(K,G),z=iV(H,W);J=await sV({manifest:z,mergedConfigDir:q,hardeningMode:Y,copySeams:Q.seams?.copy,nativeHelper:Q.seams?.nativeHelper})}let X=q;return{path:X,cleanup:()=>jG(X),hardeningLevel:J}}catch(J){let X=aV(J);if(q)try{await jG(q)}catch(H){X.message=`${X.message}
171
- Cleanup warning: ${P1(H)}`}throw X}}var RV,SV="ocx-oc-merged-",EV=1,x8="Full TOCTOU/symlink-swap hardening requires an fd-based native helper transaction.",CV;var TG=A(()=>{O0();H8();W0();t();g8();RV=["agent","agents","skill","skills"];CV=Q1({include:R1(F()).optional(),exclude:R1(F()).optional()}).passthrough()});import*as _0 from"path";function q7(Q){return typeof Q==="object"&&Q!==null&&!Array.isArray(Q)}function QA(Q){if(Q.length===0)return"Unknown parse error";let $=Q[0];if(!$)return"Unknown parse error";return`${n0($.error)} at offset ${$.offset}`}function J7(Q){if(Q.length===0)return"$";let $="";for(let Y of Q){if(typeof Y==="number"){$+=`[${Y}]`;continue}$=$.length===0?Y:`${$}.${Y}`}return $}function C2(Q,$,Y,q){if(Q===void 0)return;if(q7(Q)){for(let[J,X]of Object.entries(Q))C2(X,$,[...Y,J],q);return}if(Array.isArray(Q)){for(let[J,X]of Q.entries())C2(X,$,[...Y,J],q);return}q.set(J7(Y),$)}function $A(Q,$,Y,q){let J=Array.from(new Set([...Q,...$])),X=new Map;for(let H of Q)if(!X.has(H))X.set(H,"profile");for(let H of $)if(!X.has(H))X.set(H,"local");for(let[H,G]of J.entries())q.set(J7([...Y,H]),X.get(G)??"local")}function YA(Q,$,Y,q){let J=[...Q,...$],X=n4(J),H=new Map;for(let G=J.length-1;G>=0;G--){let K=J[G];if(!K)continue;let W=D2(K);if(!H.has(W))H.set(W,G<Q.length?"profile":"local")}for(let[G,K]of X.entries()){let W=D2(K);q.set(J7([...Y,G]),H.get(W)??"local")}}function bG(Q,$){return Q.length===1&&Q[0]===$}function RG(Q){let{profileValue:$,localValue:Y,pathSegments:q,origins:J}=Q;if(Y===void 0){C2($,"profile",q,J);return}if($===void 0){C2(Y,"local",q,J);return}if(q7($)&&q7(Y)){let X=new Set([...Object.keys($),...Object.keys(Y)]);for(let H of X)RG({profileValue:$[H],localValue:Y[H],pathSegments:[...q,H],origins:J});return}if(Array.isArray($)&&Array.isArray(Y)){if(bG(q,"instructions")){if($.every((X)=>typeof X==="string")&&Y.every((X)=>typeof X==="string")){$A($,Y,q,J);return}}if(bG(q,"plugin")){if($.every((X)=>typeof X==="string")&&Y.every((X)=>typeof X==="string")){YA($,Y,q,J);return}}}C2(Y,"local",q,J)}function qA(Q){let $=new Map;return RG({profileValue:Q.profileConfig,localValue:Q.localConfig,pathSegments:[],origins:$}),$}function JA(Q){if(!Q.startsWith("{file:"))return null;if(!Q.endsWith("}"))return null;let $=Q.slice(6,-1);return $.length>0?$:null}function XA(Q){return/^[A-Za-z]:[\\/]/.test(Q)}function HA(Q){if(Q.startsWith("~"))return!1;if(_0.isAbsolute(Q))return!1;if(XA(Q))return!1;return!0}function GA(Q){let $=JA(Q.value);if(!$)return Q.value;let Y=J7(Q.pathSegments);if(Q.origins.get(Y)!=="profile")return Q.value;if(!HA($))return Q.value;return`{file:${_0.resolve(Q.profileDir,$)}}`}function i6(Q){let{value:$,pathSegments:Y,origins:q,profileDir:J}=Q;if(typeof $==="string")return GA({value:$,pathSegments:Y,origins:q,profileDir:J});if(Array.isArray($))return $.map((X,H)=>i6({value:X,pathSegments:[...Y,H],origins:q,profileDir:J}));if(q7($)){let X={};for(let[H,G]of Object.entries($))X[H]=i6({value:G,pathSegments:[...Y,H],origins:q,profileDir:J});return X}return $}async function KA(Q){let $=M8(Q);if(!$)return{};let Y=_0.join($,w2),q=Bun.file(Y);if(!await q.exists())return{};let J;try{J=await q.text()}catch(G){let K=G instanceof Error?G.message:"Unknown read error";throw new h(`Failed to read local OpenCode config at ${Y}: ${K}`)}let X=[],H=O1(J,X,{allowTrailingComma:!0});if(X.length>0){let G=QA(X);throw new h(`Invalid JSONC in local OpenCode config at ${Y}: ${G}`)}if(!H||typeof H!=="object"||Array.isArray(H))throw new h(`Invalid local OpenCode config at ${Y}: root must be an object`);return H}async function WA(Q){let $=await KA(Q.projectDir),Y=qA({profileConfig:Q.profileConfig,localConfig:$});return i6({value:Q.mergedConfig,pathSegments:[],origins:Y,profileDir:Q.profileDir})}function zA(Q){let $=new Set,Y=[];for(let q=Q.length-1;q>=0;q--){let J=Q[q];if(!$.has(J))$.add(J),Y.unshift(J)}return Y}function BA(Q){return Q.configBin??Q.envBin??"opencode"}function SG(Q){return Q.includes("/")||Q.includes("\\")}function _A(Q){let{configuredBin:$,cwd:Y}=Q,q=Q.resolveExecutable??((X)=>Bun.which(X));if(!$.trim())throw Error("OpenCode launcher is empty and cannot be resolved to a stable path");if(SG($))return _0.isAbsolute($)?$:_0.resolve(Y,$);let J=q($);if(!J)throw Error(`OpenCode launcher "${$}" is not available in PATH and cannot be used as OPENCODE_BIN`);return _0.isAbsolute(J)?J:_0.resolve(Y,J)}function ZA(Q){let $=Q.resolveExecutable??((W)=>Bun.which(W)),Y=Q.argv??process.argv,q=Q.execPath??process.execPath,J=Q.isCompiledBinary??(typeof Bun<"u"&&typeof Bun.main==="string"&&Bun.main.startsWith("/$bunfs/")),X=Q.inheritedOcxBin?.trim(),H=J?q:Y[1],G=X&&X.length>0?X:H;if(!G?.trim())throw Error("OCX executable path is empty and cannot be resolved from the current process");if(SG(G))return _0.isAbsolute(G)?G:_0.resolve(Q.cwd,G);let K=$(G);if(!K)throw Error(`OCX executable "${G}" is not available in PATH and cannot be persisted as OCX_BIN`);return _0.isAbsolute(K)?K:_0.resolve(Q.cwd,K)}function MA(Q){let $=Boolean(Q.profileName),{OPENCODE_DISABLE_PROJECT_CONFIG:Y,OPENCODE_BIN:q,OCX_CONTEXT:J,OCX_BIN:X,OCX_PROFILE:H,OCX_TITLE_CONTEXT:G,...K}=Q.baseEnv;return{...K,...Q.opencodeBin!==void 0&&{OPENCODE_BIN:Q.opencodeBin},...$&&{OPENCODE_DISABLE_PROJECT_CONFIG:"true"},OPENCODE_CONFIG_DIR:Q.configDir??($?f1(Q.profileName):j0()),...Q.configContent&&{OPENCODE_CONFIG_CONTENT:Q.configContent},...$&&{OCX_CONTEXT:"1"},...$&&Q.ocxBin&&{OCX_BIN:Q.ocxBin},...Q.profileName&&{OCX_PROFILE:Q.profileName},...Q.titleContext&&{OCX_TITLE_CONTEXT:JSON.stringify(Q.titleContext)}}}function EG(Q){let $=Q.command("oc").alias("opencode").description("Launch OpenCode with resolved configuration").option("-p, --profile <name>","Use specific profile").option("--no-rename","Disable terminal/tmux window renaming").allowUnknownOption().allowExcessArguments(!0);B0($),$.action(async(Y,q)=>{try{await VA(q.args,Y)}catch(J){s(J)}})}function UA(){let Q=null,$=null,Y=null,q=!1,J=()=>{if(!$)return;clearTimeout($),$=null},X=()=>{if(!Q)return;if(q)return;q=!0,Q.kill("SIGKILL")},H=()=>{if($)return;$=setTimeout(()=>{X()},tV)},G=(K)=>{if(Y??=eV[K],!Q)return;if($||q){X();return}Q.kill(K),H()};return{attachChild(K){Q=K},clearGraceTimer:J,getRememberedSignalExitCode(){return Y},handleSigint(){G("SIGINT")},handleSigterm(){G("SIGTERM")}}}async function VA(Q,$){let Y=process.cwd(),q=await e0.create(Y,{profile:$.profile}),J=q.resolve(),X=q.getProfile();if(J.profileName)_.info(`Using profile: ${J.profileName}`);let H=X?.ocx,G=$.rename!==!1&&H?.renameWindow!==!1;if(J.profileName){let I=Z8(J.profileName);if(!await Bun.file(I).exists())_.warn(`No opencode.jsonc found at ${I}. Create one to customize OpenCode settings.`)}let K=J.opencode;if(J.profileName)K=await WA({mergedConfig:J.opencode,profileConfig:X?.opencode??{},projectDir:Y,profileDir:f1(J.profileName)});let W=Array.isArray(K.instructions)?K.instructions:[],z=[...J.instructions,...W],B=zA(z),Z=B.length>0||Object.keys(K).length>0?{...K,instructions:B.length>0?B:void 0}:void 0,M=null,V=null,U=null,R=null,N=UA(),c=()=>N.handleSigint(),T=()=>N.handleSigterm(),x=()=>{if(G)m6()};try{if(process.on("SIGINT",c),process.on("SIGTERM",T),process.on("exit",x),N.getRememberedSignalExitCode()!==null){R=N.getRememberedSignalExitCode();return}if(J.profileName)V=await NG({projectDir:Y,profileDir:f1(J.profileName)});if(N.getRememberedSignalExitCode()!==null){R=N.getRememberedSignalExitCode();return}let I=G?await BG(Y):{repoName:null,branch:null};if(N.getRememberedSignalExitCode()!==null){R=N.getRememberedSignalExitCode();return}let w=AG(Y,J.profileName??"default",I),i={mayWriteOscTitle:G&&u6(),baseTitle:w};if(G)VG(),UG(w);if(N.getRememberedSignalExitCode()!==null){R=N.getRememberedSignalExitCode();return}let l=BA({configBin:H?.bin,envBin:process.env.OPENCODE_BIN}),r=Boolean(J.profileName),J1=r?_A({configuredBin:l,cwd:Y}):l,S=r?ZA({cwd:Y,inheritedOcxBin:process.env.OCX_BIN}):void 0,g=Z?JSON.stringify(Z):void 0;try{M=Bun.spawn({cmd:[J1,...Q],cwd:Y,env:MA({baseEnv:process.env,profileName:J.profileName??void 0,ocxBin:S,opencodeBin:J1,configDir:V?.path,configContent:g,titleContext:i}),stdin:"inherit",stdout:"inherit",stderr:"inherit"})}catch(E){throw p("spawn",`Failed to launch OpenCode binary "${l}": ${E instanceof Error?E.message:String(E)}`)}N.attachChild(M),R=await M.exited}catch(I){U=I instanceof Error?I:p("spawn",`OpenCode process failed: ${String(I)}`)}finally{if(N.clearGraceTimer(),process.off("SIGINT",c),process.off("SIGTERM",T),process.off("exit",x),G)m6();if(V)try{await V.cleanup()}catch(I){if(U!==null||N.getRememberedSignalExitCode()!==null||R!==null&&R!==0)_.warn(`Cleanup warning: ${I instanceof Error?I.message:String(I)}`);else U=I instanceof Error?I:p("cleanup",`Failed to remove temporary merged config directory: ${String(I)}`)}}if(U)throw U;let O=N.getRememberedSignalExitCode();if(O!==null)process.exit(O);if(R!==null)process.exit(R)}var tV=2500,eV;var kG=A(()=>{O0();O2();W0();I3();t();_G();y1();c1();k8();k0();LG();TG();eV={SIGINT:130,SIGTERM:143}});import{existsSync as i9}from"fs";import{mkdir as n6,mkdtemp as AA,rename as LA,rm as vG,writeFile as FA}from"fs/promises";import{dirname as PG,join as X7,relative as jA}from"path";function xG(Q,$,Y){let q=Y instanceof Error?Y.message:String(Y);return`${Q} "${$}" (${q})`}function fG(Q,$){let[Y,q]=$.split("/");if(!Y||!q)return;return`${g1(Q)}/components/${q}.json`}function CG(Q){if(!Q)return null;let[$,Y,...q]=Q.split("/");if(!$||!Y||q.length>0)return null;return{registryName:$,componentName:Y}}function wA(Q,$){if(!Q)return{};let Y;try{let H=new URL(Q),G=H.pathname.match(/(?:^|\/)components\/([^/]+)\.json$/);if(G?.[1])Y=decodeURIComponent(G[1]);else{let K=H.pathname.match(/(?:^|\/)components\/([^/]+)\/.+$/);if(K?.[1])Y=decodeURIComponent(K[1])}}catch{}let q=g1(Q),J,X=-1;for(let[H,G]of Object.entries($)){let K=g1(G.url);if(!(q===K||q.startsWith(`${K}/`))||K.length<=X)continue;J=H,X=K.length}return{registryName:J,componentName:Y}}function DA(Q){let $=Q.depRefs[0]??`${Q.namespace}/${Q.component}`,Y={...Q.profileRegistries,...Q.profileRegistries[Q.namespace]?{}:{[Q.namespace]:{url:Q.registryUrl}}},q=Q.error.registryName,J=Q.error.qualifiedName,X=CG(J);if(!q&&X)q=X.registryName;let H=X?.componentName,G=J&&!X&&!J.includes("/")?J:void 0,K=wA(Q.error.url,Y);if(!q&&K.registryName)q=K.registryName;let W=H??G??K.componentName;if((!J||!X)&&q&&W)J=`${q}/${W}`;if(!J)J=$;if(!q)q=CG(J)?.registryName??Q.namespace;let z=Y[q]?.url||(q===Q.namespace?Q.registryUrl:void 0);return{registryName:q,qualifiedName:J,fallbackUrl:Q.error.url||(z?fG(z,J):void 0)}}function yG(Q,$){let Y=Q.phase??$.fallbackPhase,q=Q.url??$.fallbackUrl,J=[`phase: ${Y}`,`qualifiedName: ${$.qualifiedName}`,`registryContext: ${$.registryContext}`,`registryName: ${$.registryName}`,...q?[`url: ${q}`]:[]];return new I1(`${Q.message} (${J.join(", ")})`,{url:q,status:Q.status,statusText:Q.statusText,phase:Y,qualifiedName:$.qualifiedName,registryContext:$.registryContext,registryName:$.registryName})}function hG(Q,$){if(!Q.startsWith(".opencode/"))throw new L(`Invalid embedded target "${Q}": expected .opencode/ prefix for embedded profile files.`);let Y=Q.slice(10);if(!Y)throw new L(`Invalid embedded target "${Q}": missing path after .opencode/ prefix.`);let q;try{q=A0($,Y)}catch(X){if(X instanceof e1)throw new L(`Invalid embedded target "${Q}": ${X.message}`);throw X}let J=jA($,q).replace(/\\/g,"/");if(J==="."||J==="")throw new L(`Invalid embedded target "${Q}": target must resolve to a file path.`);return J}async function o6(Q){let{namespace:$,component:Y,profileName:q,registryUrl:J,quiet:X}=Q;if(!a0.safeParse(q).success)throw new L(`Invalid profile name: "${q}". Profile names must start with a letter and contain only alphanumeric characters, dots, underscores, or hyphens.`);let G;if($)G=$;else throw new L(`Registry name is required for URL-based profile installs.
171
+ Cleanup warning: ${P1(H)}`}throw X}}var RV,SV="ocx-oc-merged-",EV=1,x8="Full TOCTOU/symlink-swap hardening requires an fd-based native helper transaction.",CV;var TG=A(()=>{O0();H8();W0();t();g8();RV=["agent","agents","command","commands","skill","skills","tool","tools"];CV=Q1({include:R1(F()).optional(),exclude:R1(F()).optional()}).passthrough()});import*as _0 from"path";function q7(Q){return typeof Q==="object"&&Q!==null&&!Array.isArray(Q)}function QA(Q){if(Q.length===0)return"Unknown parse error";let $=Q[0];if(!$)return"Unknown parse error";return`${n0($.error)} at offset ${$.offset}`}function J7(Q){if(Q.length===0)return"$";let $="";for(let Y of Q){if(typeof Y==="number"){$+=`[${Y}]`;continue}$=$.length===0?Y:`${$}.${Y}`}return $}function C2(Q,$,Y,q){if(Q===void 0)return;if(q7(Q)){for(let[J,X]of Object.entries(Q))C2(X,$,[...Y,J],q);return}if(Array.isArray(Q)){for(let[J,X]of Q.entries())C2(X,$,[...Y,J],q);return}q.set(J7(Y),$)}function $A(Q,$,Y,q){let J=Array.from(new Set([...Q,...$])),X=new Map;for(let H of Q)if(!X.has(H))X.set(H,"profile");for(let H of $)if(!X.has(H))X.set(H,"local");for(let[H,G]of J.entries())q.set(J7([...Y,H]),X.get(G)??"local")}function YA(Q,$,Y,q){let J=[...Q,...$],X=n4(J),H=new Map;for(let G=J.length-1;G>=0;G--){let K=J[G];if(!K)continue;let W=D2(K);if(!H.has(W))H.set(W,G<Q.length?"profile":"local")}for(let[G,K]of X.entries()){let W=D2(K);q.set(J7([...Y,G]),H.get(W)??"local")}}function bG(Q,$){return Q.length===1&&Q[0]===$}function RG(Q){let{profileValue:$,localValue:Y,pathSegments:q,origins:J}=Q;if(Y===void 0){C2($,"profile",q,J);return}if($===void 0){C2(Y,"local",q,J);return}if(q7($)&&q7(Y)){let X=new Set([...Object.keys($),...Object.keys(Y)]);for(let H of X)RG({profileValue:$[H],localValue:Y[H],pathSegments:[...q,H],origins:J});return}if(Array.isArray($)&&Array.isArray(Y)){if(bG(q,"instructions")){if($.every((X)=>typeof X==="string")&&Y.every((X)=>typeof X==="string")){$A($,Y,q,J);return}}if(bG(q,"plugin")){if($.every((X)=>typeof X==="string")&&Y.every((X)=>typeof X==="string")){YA($,Y,q,J);return}}}C2(Y,"local",q,J)}function qA(Q){let $=new Map;return RG({profileValue:Q.profileConfig,localValue:Q.localConfig,pathSegments:[],origins:$}),$}function JA(Q){if(!Q.startsWith("{file:"))return null;if(!Q.endsWith("}"))return null;let $=Q.slice(6,-1);return $.length>0?$:null}function XA(Q){return/^[A-Za-z]:[\\/]/.test(Q)}function HA(Q){if(Q.startsWith("~"))return!1;if(_0.isAbsolute(Q))return!1;if(XA(Q))return!1;return!0}function GA(Q){let $=JA(Q.value);if(!$)return Q.value;let Y=J7(Q.pathSegments);if(Q.origins.get(Y)!=="profile")return Q.value;if(!HA($))return Q.value;return`{file:${_0.resolve(Q.profileDir,$)}}`}function i6(Q){let{value:$,pathSegments:Y,origins:q,profileDir:J}=Q;if(typeof $==="string")return GA({value:$,pathSegments:Y,origins:q,profileDir:J});if(Array.isArray($))return $.map((X,H)=>i6({value:X,pathSegments:[...Y,H],origins:q,profileDir:J}));if(q7($)){let X={};for(let[H,G]of Object.entries($))X[H]=i6({value:G,pathSegments:[...Y,H],origins:q,profileDir:J});return X}return $}async function KA(Q){let $=M8(Q);if(!$)return{};let Y=_0.join($,w2),q=Bun.file(Y);if(!await q.exists())return{};let J;try{J=await q.text()}catch(G){let K=G instanceof Error?G.message:"Unknown read error";throw new h(`Failed to read local OpenCode config at ${Y}: ${K}`)}let X=[],H=O1(J,X,{allowTrailingComma:!0});if(X.length>0){let G=QA(X);throw new h(`Invalid JSONC in local OpenCode config at ${Y}: ${G}`)}if(!H||typeof H!=="object"||Array.isArray(H))throw new h(`Invalid local OpenCode config at ${Y}: root must be an object`);return H}async function WA(Q){let $=await KA(Q.projectDir),Y=qA({profileConfig:Q.profileConfig,localConfig:$});return i6({value:Q.mergedConfig,pathSegments:[],origins:Y,profileDir:Q.profileDir})}function zA(Q){let $=new Set,Y=[];for(let q=Q.length-1;q>=0;q--){let J=Q[q];if(!$.has(J))$.add(J),Y.unshift(J)}return Y}function BA(Q){return Q.configBin??Q.envBin??"opencode"}function SG(Q){return Q.includes("/")||Q.includes("\\")}function _A(Q){let{configuredBin:$,cwd:Y}=Q,q=Q.resolveExecutable??((X)=>Bun.which(X));if(!$.trim())throw Error("OpenCode launcher is empty and cannot be resolved to a stable path");if(SG($))return _0.isAbsolute($)?$:_0.resolve(Y,$);let J=q($);if(!J)throw Error(`OpenCode launcher "${$}" is not available in PATH and cannot be used as OPENCODE_BIN`);return _0.isAbsolute(J)?J:_0.resolve(Y,J)}function ZA(Q){let $=Q.resolveExecutable??((W)=>Bun.which(W)),Y=Q.argv??process.argv,q=Q.execPath??process.execPath,J=Q.isCompiledBinary??(typeof Bun<"u"&&typeof Bun.main==="string"&&Bun.main.startsWith("/$bunfs/")),X=Q.inheritedOcxBin?.trim(),H=J?q:Y[1],G=X&&X.length>0?X:H;if(!G?.trim())throw Error("OCX executable path is empty and cannot be resolved from the current process");if(SG(G))return _0.isAbsolute(G)?G:_0.resolve(Q.cwd,G);let K=$(G);if(!K)throw Error(`OCX executable "${G}" is not available in PATH and cannot be persisted as OCX_BIN`);return _0.isAbsolute(K)?K:_0.resolve(Q.cwd,K)}function MA(Q){let $=Boolean(Q.profileName),{OPENCODE_DISABLE_PROJECT_CONFIG:Y,OPENCODE_BIN:q,OCX_CONTEXT:J,OCX_BIN:X,OCX_PROFILE:H,OCX_TITLE_CONTEXT:G,...K}=Q.baseEnv;return{...K,...Q.opencodeBin!==void 0&&{OPENCODE_BIN:Q.opencodeBin},...$&&{OPENCODE_DISABLE_PROJECT_CONFIG:"true"},OPENCODE_CONFIG_DIR:Q.configDir??($?f1(Q.profileName):j0()),...Q.configContent&&{OPENCODE_CONFIG_CONTENT:Q.configContent},...$&&{OCX_CONTEXT:"1"},...$&&Q.ocxBin&&{OCX_BIN:Q.ocxBin},...Q.profileName&&{OCX_PROFILE:Q.profileName},...Q.titleContext&&{OCX_TITLE_CONTEXT:JSON.stringify(Q.titleContext)}}}function EG(Q){let $=Q.command("oc").alias("opencode").description("Launch OpenCode with resolved configuration").option("-p, --profile <name>","Use specific profile").option("--no-rename","Disable terminal/tmux window renaming").allowUnknownOption().allowExcessArguments(!0);B0($),$.action(async(Y,q)=>{try{await VA(q.args,Y)}catch(J){s(J)}})}function UA(){let Q=null,$=null,Y=null,q=!1,J=()=>{if(!$)return;clearTimeout($),$=null},X=()=>{if(!Q)return;if(q)return;q=!0,Q.kill("SIGKILL")},H=()=>{if($)return;$=setTimeout(()=>{X()},tV)},G=(K)=>{if(Y??=eV[K],!Q)return;if($||q){X();return}Q.kill(K),H()};return{attachChild(K){Q=K},clearGraceTimer:J,getRememberedSignalExitCode(){return Y},handleSigint(){G("SIGINT")},handleSigterm(){G("SIGTERM")}}}async function VA(Q,$){let Y=process.cwd(),q=await e0.create(Y,{profile:$.profile}),J=q.resolve(),X=q.getProfile();if(J.profileName)_.info(`Using profile: ${J.profileName}`);let H=X?.ocx,G=$.rename!==!1&&H?.renameWindow!==!1;if(J.profileName){let I=Z8(J.profileName);if(!await Bun.file(I).exists())_.warn(`No opencode.jsonc found at ${I}. Create one to customize OpenCode settings.`)}let K=J.opencode;if(J.profileName)K=await WA({mergedConfig:J.opencode,profileConfig:X?.opencode??{},projectDir:Y,profileDir:f1(J.profileName)});let W=Array.isArray(K.instructions)?K.instructions:[],z=[...J.instructions,...W],B=zA(z),Z=B.length>0||Object.keys(K).length>0?{...K,instructions:B.length>0?B:void 0}:void 0,M=null,V=null,U=null,R=null,N=UA(),c=()=>N.handleSigint(),T=()=>N.handleSigterm(),x=()=>{if(G)m6()};try{if(process.on("SIGINT",c),process.on("SIGTERM",T),process.on("exit",x),N.getRememberedSignalExitCode()!==null){R=N.getRememberedSignalExitCode();return}if(J.profileName)V=await NG({projectDir:Y,profileDir:f1(J.profileName)});if(N.getRememberedSignalExitCode()!==null){R=N.getRememberedSignalExitCode();return}let I=G?await BG(Y):{repoName:null,branch:null};if(N.getRememberedSignalExitCode()!==null){R=N.getRememberedSignalExitCode();return}let w=AG(Y,J.profileName??"default",I),i={mayWriteOscTitle:G&&u6(),baseTitle:w};if(G)VG(),UG(w);if(N.getRememberedSignalExitCode()!==null){R=N.getRememberedSignalExitCode();return}let l=BA({configBin:H?.bin,envBin:process.env.OPENCODE_BIN}),r=Boolean(J.profileName),J1=r?_A({configuredBin:l,cwd:Y}):l,S=r?ZA({cwd:Y,inheritedOcxBin:process.env.OCX_BIN}):void 0,g=Z?JSON.stringify(Z):void 0;try{M=Bun.spawn({cmd:[J1,...Q],cwd:Y,env:MA({baseEnv:process.env,profileName:J.profileName??void 0,ocxBin:S,opencodeBin:J1,configDir:V?.path,configContent:g,titleContext:i}),stdin:"inherit",stdout:"inherit",stderr:"inherit"})}catch(E){throw p("spawn",`Failed to launch OpenCode binary "${l}": ${E instanceof Error?E.message:String(E)}`)}N.attachChild(M),R=await M.exited}catch(I){U=I instanceof Error?I:p("spawn",`OpenCode process failed: ${String(I)}`)}finally{if(N.clearGraceTimer(),process.off("SIGINT",c),process.off("SIGTERM",T),process.off("exit",x),G)m6();if(V)try{await V.cleanup()}catch(I){if(U!==null||N.getRememberedSignalExitCode()!==null||R!==null&&R!==0)_.warn(`Cleanup warning: ${I instanceof Error?I.message:String(I)}`);else U=I instanceof Error?I:p("cleanup",`Failed to remove temporary merged config directory: ${String(I)}`)}}if(U)throw U;let O=N.getRememberedSignalExitCode();if(O!==null)process.exit(O);if(R!==null)process.exit(R)}var tV=2500,eV;var kG=A(()=>{O0();O2();W0();I3();t();_G();y1();c1();k8();k0();LG();TG();eV={SIGINT:130,SIGTERM:143}});import{existsSync as i9}from"fs";import{mkdir as n6,mkdtemp as AA,rename as LA,rm as vG,writeFile as FA}from"fs/promises";import{dirname as PG,join as X7,relative as jA}from"path";function xG(Q,$,Y){let q=Y instanceof Error?Y.message:String(Y);return`${Q} "${$}" (${q})`}function fG(Q,$){let[Y,q]=$.split("/");if(!Y||!q)return;return`${g1(Q)}/components/${q}.json`}function CG(Q){if(!Q)return null;let[$,Y,...q]=Q.split("/");if(!$||!Y||q.length>0)return null;return{registryName:$,componentName:Y}}function wA(Q,$){if(!Q)return{};let Y;try{let H=new URL(Q),G=H.pathname.match(/(?:^|\/)components\/([^/]+)\.json$/);if(G?.[1])Y=decodeURIComponent(G[1]);else{let K=H.pathname.match(/(?:^|\/)components\/([^/]+)\/.+$/);if(K?.[1])Y=decodeURIComponent(K[1])}}catch{}let q=g1(Q),J,X=-1;for(let[H,G]of Object.entries($)){let K=g1(G.url);if(!(q===K||q.startsWith(`${K}/`))||K.length<=X)continue;J=H,X=K.length}return{registryName:J,componentName:Y}}function DA(Q){let $=Q.depRefs[0]??`${Q.namespace}/${Q.component}`,Y={...Q.profileRegistries,...Q.profileRegistries[Q.namespace]?{}:{[Q.namespace]:{url:Q.registryUrl}}},q=Q.error.registryName,J=Q.error.qualifiedName,X=CG(J);if(!q&&X)q=X.registryName;let H=X?.componentName,G=J&&!X&&!J.includes("/")?J:void 0,K=wA(Q.error.url,Y);if(!q&&K.registryName)q=K.registryName;let W=H??G??K.componentName;if((!J||!X)&&q&&W)J=`${q}/${W}`;if(!J)J=$;if(!q)q=CG(J)?.registryName??Q.namespace;let z=Y[q]?.url||(q===Q.namespace?Q.registryUrl:void 0);return{registryName:q,qualifiedName:J,fallbackUrl:Q.error.url||(z?fG(z,J):void 0)}}function yG(Q,$){let Y=Q.phase??$.fallbackPhase,q=Q.url??$.fallbackUrl,J=[`phase: ${Y}`,`qualifiedName: ${$.qualifiedName}`,`registryContext: ${$.registryContext}`,`registryName: ${$.registryName}`,...q?[`url: ${q}`]:[]];return new I1(`${Q.message} (${J.join(", ")})`,{url:q,status:Q.status,statusText:Q.statusText,phase:Y,qualifiedName:$.qualifiedName,registryContext:$.registryContext,registryName:$.registryName})}function hG(Q,$){if(!Q.startsWith(".opencode/"))throw new L(`Invalid embedded target "${Q}": expected .opencode/ prefix for embedded profile files.`);let Y=Q.slice(10);if(!Y)throw new L(`Invalid embedded target "${Q}": missing path after .opencode/ prefix.`);let q;try{q=A0($,Y)}catch(X){if(X instanceof e1)throw new L(`Invalid embedded target "${Q}": ${X.message}`);throw X}let J=jA($,q).replace(/\\/g,"/");if(J==="."||J==="")throw new L(`Invalid embedded target "${Q}": target must resolve to a file path.`);return J}async function o6(Q){let{namespace:$,component:Y,profileName:q,registryUrl:J,quiet:X}=Q;if(!a0.safeParse(q).success)throw new L(`Invalid profile name: "${q}". Profile names must start with a letter and contain only alphanumeric characters, dots, underscores, or hyphens.`);let G;if($)G=$;else throw new L(`Registry name is required for URL-based profile installs.
172
172
 
173
173
  Use a qualified component reference (e.g., 'my-registry/${Y}') or specify --name to provide a registry alias.`);let K=f1(q),W=`${G}/${Y}`;if(i9(K))throw new n1(`Profile "${q}" already exists. Remove it first with 'ocx profile rm ${q} --global'.`);let B=X?null:M1({text:`Fetching ${W}...`});B?.start();let Z;try{Z=await N2(J,Y)}catch(O){if(B?.fail(`Failed to fetch ${W}`),O instanceof I1)throw yG(O,{registryContext:"source",registryName:G,qualifiedName:W,fallbackPhase:"packument-fetch",fallbackUrl:fG(J,W)});if(O instanceof _1)throw new _1(`Profile component "${W}" not found in registry.
174
174
 
@@ -250,7 +250,7 @@ ${M.integrity.missing.map((N)=>` - ${N}`).join(`
250
250
  `)}`:"",R=[V,U].filter(Boolean).join(`
251
251
  `);throw new L(`Component '${M.canonicalId}' has been modified. Use --force to remove anyway.
252
252
  ${R}`)}}for(let{canonicalId:M,files:V}of W){for(let U of V){let R=lA(q.cwd,Z,U);if(!R){if($.verbose)_.info(` \u2298 Skipped ${U.path} (not found)`);continue}if(await dA(R,{force:!0}),$.verbose)_.info(` \u2713 Removed ${U.path}`)}delete J.installed[M],G.push(M)}if(await T0(q.cwd,J),H?.succeed(`Removed ${G.length} component(s)`),$.json)console.log(JSON.stringify({success:!0,removed:G,notFound:K},null,2));else if(!$.quiet){_.info("");for(let M of G){let V=R8(M);_.success(`\u2713 Removed ${V.registryName}/${V.name}@${V.revision}`)}_.info(""),_.success(`Done! Removed ${G.length} component(s).`)}}catch(M){throw H?.fail("Failed to remove components"),M}}var XK=A(()=>{k9();q0();r6();e8();t();y1();c1();g8();y9();k0();l0()});var GK=L8((HK,G7)=>{((Q,$)=>{if(typeof define==="function"&&define.amd)define([],$);else if(typeof G7==="object"&&G7.exports)G7.exports=$();else Q.fuzzysort=$()})(HK,(Q)=>{var $=(b,D)=>{if(!b||!D)return $1;var v=M(b);if(!C(D))D=Z(D);var f=v.bitflags;if((f&D._bitflags)!==f)return $1;return U(v,D)},Y=(b,D,v)=>{if(!b)return v?.all?V(D,v):D1;var f=M(b),u=f.bitflags,y=f.containsSpace,k=z(v?.threshold||0),n=v?.limit||e,m=0,K1=0,X1=D.length;function G0(y8){if(m<n)W9.add(y8),++m;else if(++K1,y8._score>W9.peek()._score)W9.replaceTop(y8)}if(v?.key){var r1=v.key;for(var W1=0;W1<X1;++W1){var $0=D[W1],V1=E($0,r1);if(!V1)continue;if(!C(V1))V1=Z(V1);if((u&V1._bitflags)!==u)continue;var j1=U(f,V1);if(j1===$1)continue;if(j1._score<k)continue;j1.obj=$0,G0(j1)}}else if(v?.keys){var V8=v.keys,D0=V8.length;Q:for(var W1=0;W1<X1;++W1){var $0=D[W1];{var a1=0;for(var H1=0;H1<D0;++H1){var r1=V8[H1],V1=E($0,r1);if(!V1){S[H1]=H0;continue}if(!C(V1))V1=Z(V1);S[H1]=V1,a1|=V1._bitflags}if((u&a1)!==u)continue}if(y)for(let A1=0;A1<f.spaceSearches.length;A1++)r[A1]=o;for(var H1=0;H1<D0;++H1){if(V1=S[H1],V1===H0){g[H1]=H0;continue}if(g[H1]=U(f,V1,!1,y),g[H1]===$1){g[H1]=H0;continue}if(y)for(let w1=0;w1<f.spaceSearches.length;w1++){if(J1[w1]>-1000){if(r[w1]>o){var o1=(r[w1]+J1[w1])/4;if(o1>r[w1])r[w1]=o1}}if(J1[w1]>r[w1])r[w1]=J1[w1]}}if(y){for(let A1=0;A1<f.spaceSearches.length;A1++)if(r[A1]===o)continue Q}else{var Y1=!1;for(let A1=0;A1<D0;A1++)if(g[A1]._score!==o){Y1=!0;break}if(!Y1)continue}var Z0=new G(D0);for(let A1=0;A1<D0;A1++)Z0[A1]=g[A1];if(y){var p1=0;for(let A1=0;A1<f.spaceSearches.length;A1++)p1+=r[A1]}else{var p1=o;for(let w1=0;w1<D0;w1++){var j1=Z0[w1];if(j1._score>-1000){if(p1>o){var o1=(p1+j1._score)/4;if(o1>p1)p1=o1}}if(j1._score>p1)p1=j1._score}}if(Z0.obj=$0,Z0._score=p1,v?.scoreFn){if(p1=v.scoreFn(Z0),!p1)continue;p1=z(p1),Z0._score=p1}if(p1<k)continue;G0(Z0)}}else for(var W1=0;W1<X1;++W1){var V1=D[W1];if(!V1)continue;if(!C(V1))V1=Z(V1);if((u&V1._bitflags)!==u)continue;var j1=U(f,V1);if(j1===$1)continue;if(j1._score<k)continue;G0(j1)}if(m===0)return D1;var A8=Array(m);for(var W1=m-1;W1>=0;--W1)A8[W1]=W9.poll();return A8.total=m+K1,A8},q=(b,D="<b>",v="</b>")=>{var f=typeof D==="function"?D:void 0,u=b.target,y=u.length,k=b.indexes,n="",m=0,K1=0,X1=!1,G0=[];for(var r1=0;r1<y;++r1){var W1=u[r1];if(k[K1]===r1){if(++K1,!X1)if(X1=!0,f)G0.push(n),n="";else n+=D;if(K1===k.length){if(f)n+=W1,G0.push(f(n,m++)),n="",G0.push(u.substr(r1+1));else n+=W1+v+u.substr(r1+1);break}}else if(X1)if(X1=!1,f)G0.push(f(n,m++)),n="";else n+=v;n+=W1}return f?G0:n},J=(b)=>{if(typeof b==="number")b=""+b;else if(typeof b!=="string")b="";var D=c(b);return K(b,{_targetLower:D._lower,_targetLowerCodes:D.lowerCodes,_bitflags:D.bitflags})},X=()=>{O.clear(),I.clear()};class H{get["indexes"](){return this._indexes.slice(0,this._indexes.len).sort((b,D)=>b-D)}set["indexes"](b){return this._indexes=b}["highlight"](b,D){return q(this,b,D)}get["score"](){return W(this._score)}set["score"](b){this._score=z(b)}}class G extends Array{get["score"](){return W(this._score)}set["score"](b){this._score=z(b)}}var K=(b,D)=>{let v=new H;return v.target=b,v.obj=D.obj??$1,v._score=D._score??o,v._indexes=D._indexes??[],v._targetLower=D._targetLower??"",v._targetLowerCodes=D._targetLowerCodes??$1,v._nextBeginningIndexes=D._nextBeginningIndexes??$1,v._bitflags=D._bitflags??0,v},W=(b)=>{if(b===o)return 0;if(b>1)return b;return Math.E**(((-b+1)**0.04307-1)*-2)},z=(b)=>{if(b===0)return o;if(b>1)return b;return 1-Math.pow(Math.log(b)/-2+1,23.218017181332716)},B=(b)=>{if(typeof b==="number")b=""+b;else if(typeof b!=="string")b="";b=b.trim();var D=c(b),v=[];if(D.containsSpace){var f=b.split(/\s+/);f=[...new Set(f)];for(var u=0;u<f.length;u++){if(f[u]==="")continue;var y=c(f[u]);v.push({lowerCodes:y.lowerCodes,_lower:f[u].toLowerCase(),containsSpace:!1})}}return{lowerCodes:D.lowerCodes,_lower:D._lower,containsSpace:D.containsSpace,bitflags:D.bitflags,spaceSearches:v}},Z=(b)=>{if(b.length>999)return J(b);var D=O.get(b);if(D!==void 0)return D;return D=J(b),O.set(b,D),D},M=(b)=>{if(b.length>999)return B(b);var D=I.get(b);if(D!==void 0)return D;return D=B(b),I.set(b,D),D},V=(b,D)=>{var v=[];v.total=b.length;var f=D?.limit||e;if(D?.key)for(var u=0;u<b.length;u++){var y=b[u],k=E(y,D.key);if(k==$1)continue;if(!C(k))k=Z(k);var n=K(k.target,{_score:k._score,obj:y});if(v.push(n),v.length>=f)return v}else if(D?.keys)for(var u=0;u<b.length;u++){var y=b[u],m=new G(D.keys.length);for(var K1=D.keys.length-1;K1>=0;--K1){var k=E(y,D.keys[K1]);if(!k){m[K1]=H0;continue}if(!C(k))k=Z(k);k._score=o,k._indexes.len=0,m[K1]=k}if(m.obj=y,m._score=o,v.push(m),v.length>=f)return v}else for(var u=0;u<b.length;u++){var k=b[u];if(k==$1)continue;if(!C(k))k=Z(k);if(k._score=o,k._indexes.len=0,v.push(k),v.length>=f)return v}return v},U=(b,D,v=!1,f=!1)=>{if(v===!1&&b.containsSpace)return R(b,D,f);var{_lower:u,lowerCodes:y}=b,k=y[0],n=D._targetLowerCodes,m=y.length,K1=n.length,W1=0,X1=0,G0=0;for(;;){var r1=k===n[X1];if(r1){if(w[G0++]=X1,++W1,W1===m)break;k=y[W1]}if(++X1,X1>=K1)return $1}var W1=0,$0=!1,V1=0,j1=D._nextBeginningIndexes;if(j1===$1)j1=D._nextBeginningIndexes=x(D.target);X1=w[0]===0?0:j1[w[0]-1];var V8=0;if(X1!==K1)for(;;)if(X1>=K1){if(W1<=0)break;if(++V8,V8>200)break;--W1;var D0=i[--V1];X1=j1[D0]}else{var r1=y[W1]===n[X1];if(r1){if(i[V1++]=X1,++W1,W1===m){$0=!0;break}++X1}else X1=j1[X1]}var a1=m<=1?-1:D._targetLower.indexOf(u,w[0]),H1=!!~a1,o1=!H1?!1:a1===0||D._nextBeginningIndexes[a1-1]===a1;if(H1&&!o1)for(var Y1=0;Y1<j1.length;Y1=j1[Y1]){if(Y1<=a1)continue;for(var Z0=0;Z0<m;Z0++)if(y[Z0]!==D._targetLowerCodes[Y1+Z0])break;if(Z0===m){a1=Y1,o1=!0;break}}var p1=(A1)=>{var w1=0,z5=0;for(var $8=1;$8<m;++$8)if(A1[$8]-A1[$8-1]!==1)w1-=A1[$8],++z5;var GW=A1[m-1]-A1[0]-(m-1);if(w1-=(12+GW)*z5,A1[0]!==0)w1-=A1[0]*A1[0]*0.2;if(!$0)w1*=1000;else{var L7=1;for(var $8=j1[0];$8<K1;$8=j1[$8])++L7;if(L7>24)w1*=(L7-24)*10}if(w1-=(K1-m)/2,H1)w1/=1+m*m*1;if(o1)w1/=1+m*m*1;return w1-=(K1-m)/2,w1};if(!$0){if(H1)for(var Y1=0;Y1<m;++Y1)w[Y1]=a1+Y1;var A8=w,y8=p1(A8)}else if(o1){for(var Y1=0;Y1<m;++Y1)w[Y1]=a1+Y1;var A8=w,y8=p1(w)}else var A8=i,y8=p1(i);D._score=y8;for(var Y1=0;Y1<m;++Y1)D._indexes[Y1]=A8[Y1];D._indexes.len=m;let f2=new H;return f2.target=D.target,f2._score=D._score,f2._indexes=D._indexes,f2},R=(b,D,v)=>{var f=new Set,u=0,y=$1,k=0,n=b.spaceSearches,m=n.length,K1=0,X1=()=>{for(let o1=K1-1;o1>=0;o1--)D._nextBeginningIndexes[l[o1*2+0]]=l[o1*2+1]},G0=!1;for(var H1=0;H1<m;++H1){J1[H1]=o;var r1=n[H1];if(y=U(r1,D),v){if(y===$1)continue;G0=!0}else if(y===$1)return X1(),$1;var W1=H1===m-1;if(!W1){var $0=y._indexes,V1=!0;for(let Y1=0;Y1<$0.len-1;Y1++)if($0[Y1+1]-$0[Y1]!==1){V1=!1;break}if(V1){var j1=$0[$0.len-1]+1,V8=D._nextBeginningIndexes[j1-1];for(let Y1=j1-1;Y1>=0;Y1--){if(V8!==D._nextBeginningIndexes[Y1])break;D._nextBeginningIndexes[Y1]=j1,l[K1*2+0]=Y1,l[K1*2+1]=V8,K1++}}}if(u+=y._score/m,J1[H1]=y._score/m,y._indexes[0]<k)u-=(k-y._indexes[0])*2;k=y._indexes[0];for(var D0=0;D0<y._indexes.len;++D0)f.add(y._indexes[D0])}if(v&&!G0)return $1;X1();var a1=U(b,D,!0);if(a1!==$1&&a1._score>u){if(v)for(var H1=0;H1<m;++H1)J1[H1]=a1._score/m;return a1}if(v)y=D;y._score=u;var H1=0;for(let o1 of f)y._indexes[H1++]=o1;return y._indexes.len=H1,y},N=(b)=>b.replace(/\p{Script=Latin}+/gu,(D)=>D.normalize("NFD")).replace(/[\u0300-\u036f]/g,""),c=(b)=>{b=N(b);var D=b.length,v=b.toLowerCase(),f=[],u=0,y=!1;for(var k=0;k<D;++k){var n=f[k]=v.charCodeAt(k);if(n===32){y=!0;continue}var m=n>=97&&n<=122?n-97:n>=48&&n<=57?26:n<=127?30:31;u|=1<<m}return{lowerCodes:f,bitflags:u,containsSpace:y,_lower:v}},T=(b)=>{var D=b.length,v=[],f=0,u=!1,y=!1;for(var k=0;k<D;++k){var n=b.charCodeAt(k),m=n>=65&&n<=90,K1=m||n>=97&&n<=122||n>=48&&n<=57,X1=m&&!u||!y||!K1;if(u=m,y=K1,X1)v[f++]=k}return v},x=(b)=>{b=N(b);var D=b.length,v=T(b),f=[],u=v[0],y=0;for(var k=0;k<D;++k)if(u>k)f[k]=u;else u=v[++y],f[k]=u===void 0?D:u;return f},O=new Map,I=new Map,w=[],i=[],l=[],r=[],J1=[],S=[],g=[],E=(b,D)=>{var v=b[D];if(v!==void 0)return v;if(typeof D==="function")return D(b);var f=D;if(!Array.isArray(D))f=D.split(".");var u=f.length,y=-1;while(b&&++y<u)b=b[f[y]];return b},C=(b)=>{return typeof b==="object"&&typeof b._bitflags==="number"},e=1/0,o=-e,D1=[];D1.total=0;var $1=null,H0=J(""),A7=(b)=>{var D=[],v=0,f={},u=(y)=>{for(var k=0,n=D[k],m=1;m<v;){var K1=m+1;k=m,K1<v&&D[K1]._score<D[m]._score&&(k=K1),D[k-1>>1]=D[k],m=1+(k<<1)}for(var X1=k-1>>1;k>0&&n._score<D[X1]._score;X1=(k=X1)-1>>1)D[k]=D[X1];D[k]=n};return f.add=(y)=>{var k=v;D[v++]=y;for(var n=k-1>>1;k>0&&y._score<D[n]._score;n=(k=n)-1>>1)D[k]=D[n];D[k]=y},f.poll=(y)=>{if(v!==0){var k=D[0];return D[0]=D[--v],u(),k}},f.peek=(y)=>{if(v!==0)return D[0]},f.replaceTop=(y)=>{D[0]=y,u()},f},W9=A7();return{single:$,go:Y,prepare:J,cleanup:X}})});var WK={};F8(WK,{runSearchCore:()=>KK,runSearchCommandAction:()=>oA});async function oA(Q,$){if($.installed){let q=await L0($.cwd);if(!q||Object.keys(q.installed).length===0){if($.json)F1({success:!0,data:{components:[]}});else _.info("No components installed.");return}let J=Object.entries(q.installed).map(([X,H])=>({name:`${H.registryName}/${H.name}`,registry:H.registryUrl,version:H.revision,installedAt:void 0}));if($.json)F1({success:!0,data:{components:J}});else{_.info(`Installed components (${J.length}):`);for(let X of J)console.log(` ${P.cyan(X.name)} ${P.dim(`v${X.version}`)} from ${X.registry}`)}return}let Y;if($.profile){let q=await e0.create($.cwd,{profile:$.profile});Y={cwd:q.getCwd(),getRegistries:()=>q.getRegistries(),getComponentPath:()=>q.getComponentPath()}}else Y=await R0.requireInitialized($.cwd);await KK(Q,$,Y)}async function KK(Q,$,Y){let q=Y.getRegistries();if($.verbose)_.info(`Searching in ${Object.keys(q).length} registries...`);let J=[],X=M1({text:"Searching registries...",quiet:$.quiet||$.verbose});if(!$.json&&!$.verbose)X.start();for(let[G,K]of Object.entries(q))try{if($.verbose)_.info(`Fetching index from ${G} (${K.url})...`);let W=await P8(K.url);if($.verbose)_.info(`Found ${W.components.length} components in ${G}`);for(let z of W.components)J.push({name:`${G}/${z.name}`,description:z.description,type:z.type,registry:G})}catch(W){if($.verbose)_.warn(`Failed to fetch registry ${G}: ${W instanceof Error?W.message:String(W)}`)}if(!$.json&&!$.verbose)X.stop();let H=J;if(Q)H=a6.default.go(Q,J,{keys:["name","description"],limit:$.limit}).map((K)=>K.obj);else H=H.slice(0,$.limit);if($.json){F1({success:!0,data:{components:H}});return}if(H.length===0){_.info("No components found.");return}_.info(`Found ${H.length} components:`);for(let G of H)console.log(` ${P.cyan(G.name)} ${P.dim(`(${G.type})`)} - ${G.description}`)}var a6;var zK=A(()=>{W8();k9();O2();t8();k4();c1();l0();a6=B5(GK(),1)});function sA(Q){let $=parseInt(Q,10);if(Number.isNaN($)||$<=0)throw new LJ("Must be a positive integer");return $}function BK(Q){let $=Q.command("search").alias("list").description("Search for components across registries or list installed").argument("[query]","Search query").option("--installed","List installed components only",!1).option("-p, --profile <name>","Use specific profile").addOption(new B8("--limit <n>","Limit results").default(20).argParser(sA));Q0($),B0($),$.action(async(Y,q)=>{try{let{runSearchCommandAction:J}=await Promise.resolve().then(() => (zK(),WK));await J(Y,q)}catch(J){s(J,{json:q.json})}})}var _K=A(()=>{L3();y1();k0()});function ZK(Q){let $=["curl","npm","yarn","pnpm","bun"],Y=$.find((q)=>q===Q);if(!Y)throw new x1(`Invalid install method: "${Q}"
253
- Valid methods: ${$.join(", ")}`);return Y}function n9(){if(rA())return"curl";let Q=process.argv[1]??"";if(aA(Q))return"unknown";if(tA(Q))return"yarn";if(eA(Q))return"pnpm";if(QL(Q))return"bun";if($L(Q))return"npm";let $=process.env.npm_config_user_agent??"";if($.includes("yarn"))return"yarn";if($.includes("pnpm"))return"pnpm";if($.includes("bun"))return"bun";if($.includes("npm"))return"npm";return"unknown"}function K7(){if(typeof Bun<"u"&&Bun.main.startsWith("/$bunfs/"))return process.execPath;return process.argv[1]??process.execPath}var rA=()=>Bun.main.startsWith("/$bunfs/"),aA=(Q)=>Q.includes("/_npx/")||Q.includes("/.cache/bunx/")||Q.includes("/.pnpm/_temp/"),tA=(Q)=>Q.includes("/.yarn/global")||Q.includes("/.config/yarn/global"),eA=(Q)=>Q.includes("/.pnpm/")||Q.includes("/pnpm/global"),QL=(Q)=>Q.includes("/.bun/bin")||Q.includes("/.bun/install/global"),$L=(Q)=>Q.includes("/.npm/")||Q.includes("/node_modules/");var W7=A(()=>{t()});import{existsSync as e6,lstatSync as VK,readdirSync as YL,realpathSync as MK,rmSync as qL,unlinkSync as AK}from"fs";import{homedir as LK}from"os";import i0 from"path";function t6(Q,$=0){F1({success:!0,data:Q}),process.exit($)}function X9(Q,$,Y,q){let J={success:!1,error:{code:Q,message:$,...q&&{details:q}},exitCode:Y,meta:{timestamp:new Date().toISOString()}};F1(J),process.exit(Y)}function Q5(Q){return Q instanceof Error&&"code"in Q}function y2(Q){let $=LK();if(!$)return Q;if(Q===$)return"~";if(Q.startsWith($+i0.sep))return`~${Q.slice($.length)}`;return Q}function B7(Q,$){let Y=i0.normalize(Q),q=i0.normalize($),J=i0.relative(Y,q);if(J.startsWith("..")||i0.isAbsolute(J))return null;return J}function JL(Q,$){return B7(Q,$)!==null}function XL(Q,$){if(!e6($))return{contained:!0};try{let Y=MK(Q),q=MK($);return{contained:B7(Y,q)!==null}}catch(Y){if(Q5(Y)&&(Y.code==="EACCES"||Y.code==="EPERM"))return{contained:!1,error:"permission"};return{contained:!1,error:"io"}}}function FK(Q){try{let $=VK(Q);if($.isSymbolicLink())return{valid:!1,reason:"symlink"};if(!$.isDirectory())return{valid:!1,reason:"not-directory"};return{valid:!0}}catch($){if(Q5($)){if($.code==="ENOENT")return{valid:!1,reason:"not-found"};if($.code==="EACCES"||$.code==="EPERM")return{valid:!1,reason:"permission"}}return{valid:!1,reason:"permission"}}}function h2(Q){if(!e6(Q))return"missing";try{let $=VK(Q);if($.isSymbolicLink())return"symlink";if($.isDirectory())return"directory";return"file"}catch{return"missing"}}function HL(Q){if(!e6(Q))return!0;try{return YL(Q).length===0}catch{return!1}}function UK(Q){if(Q.kind==="missing")return"safe";if(Q.kind==="symlink")return JL(Q.rootPath,Q.absolutePath)?"safe":"forbidden";let $=XL(Q.rootPath,Q.absolutePath);if($.error)return"error";return $.contained?"safe":"forbidden"}function H9(Q){return Q==="npm"||Q==="pnpm"||Q==="bun"||Q==="yarn"}function _7(Q){switch(Q){case"npm":return"npm uninstall -g ocx";case"pnpm":return"pnpm remove -g ocx";case"bun":return"bun remove -g ocx";case"yarn":return"yarn global remove ocx";default:return"npm uninstall -g ocx"}}function $5(){let Q=process.env.XDG_CONFIG_HOME||i0.join(LK(),".config");return i0.join(Q,"opencode")}function jK(){let Q=$5(),$=[],Y=_8(),q=B7(Q,Y);if(q){let G=h2(Y);$.push({rootPath:Q,relativePath:q,absolutePath:Y,displayPath:y2(Y),kind:G,deleteIfEmpty:!1,safetyStatus:UK({rootPath:Q,absolutePath:Y,kind:G})})}let J=P9(),X=B7(Q,J);if(X){let G=h2(J);$.push({rootPath:Q,relativePath:X,absolutePath:J,displayPath:y2(J),kind:G,deleteIfEmpty:!1,safetyStatus:UK({rootPath:Q,absolutePath:J,kind:G})})}let H=h2(Q);return $.push({rootPath:Q,relativePath:".",absolutePath:Q,displayPath:y2(Q),kind:H,deleteIfEmpty:!0,safetyStatus:H==="missing"?"safe":"safe"}),$}function wK(){let Q=n9();if(H9(Q))return null;if(Q==="curl"){let $=K7(),Y=h2($);return{rootPath:i0.dirname($),relativePath:i0.basename($),absolutePath:$,displayPath:y2($),kind:Y,deleteIfEmpty:!1,safetyStatus:Y==="missing"?"safe":"safe"}}return null}function GL(Q){if(Q.kind==="missing")return{target:Q,success:!0,skipped:!0,reason:"not found"};if(Q.safetyStatus==="forbidden")return{target:Q,success:!1,skipped:!0,reason:"containment violation",error:Error("Target escapes containment boundary")};if(Q.deleteIfEmpty&&Q.kind==="directory"){if(!HL(Q.absolutePath))return{target:Q,success:!0,skipped:!0,reason:"not empty"}}try{if(Q.kind==="directory")qL(Q.absolutePath,{recursive:!0,force:!0});else AK(Q.absolutePath);return{target:Q,success:!0,skipped:!1}}catch($){let Y=$ instanceof Error?$:Error(String($)),q=Q5($)&&($.code==="EACCES"||$.code==="EPERM")?"permission denied":void 0;return{target:Q,success:!1,skipped:!1,reason:q,error:Y}}}function DK(Q){return Q.map(GL)}function OK(Q,$={}){let Y={rootPath:i0.dirname(Q),relativePath:i0.basename(Q),absolutePath:Q,displayPath:y2(Q),kind:h2(Q),deleteIfEmpty:!1,safetyStatus:"safe"};if(Y.kind==="missing")return{target:Y,success:!0,skipped:!0,reason:"not found"};if(process.platform==="win32"){if(!$.suppressOutput)_.info(`To complete uninstall, manually delete: ${Y.displayPath}`);return{target:Y,success:!0,skipped:!0}}try{return AK(Q),{target:Y,success:!0,skipped:!1}}catch(q){let J=q instanceof Error?q:Error(String(q));return{target:Y,success:!1,skipped:!1,reason:"permission denied",error:J}}}function KL(Q,$,Y){let{dryRunResult:q,hints:J}=IK(Q,$,Y);w0(q,{hints:J})}function IK(Q,$,Y){let q=Q.filter((G)=>G.kind!=="missing"),J=[];for(let G of q)J.push({action:"delete",target:G.displayPath,details:{kind:G.kind,...G.deleteIfEmpty&&{deleteIfEmpty:!0}}});if($&&$.kind!=="missing")J.push({action:"delete",target:$.displayPath,details:{kind:"binary"}});let X=[];if(H9(Y))X.push(`Binary is managed by ${Y}. Run: ${_7(Y)}`);return{dryRunResult:{dryRun:!0,command:"self uninstall",wouldPerform:J,validation:{passed:!0},summary:J.length>0?`Would remove ${J.length} item(s)`:"Nothing to remove"},hints:X}}function WL(Q,$){if(Q.filter((q)=>q.kind!=="missing").length>0||$&&$.kind!=="missing")_.info("Removing OCX files...")}function zL(Q,$,Y){_.break();for(let q of Q){if(q.skipped){if(q.reason==="not found")continue;if(q.reason==="not empty"){_.info(`Kept ${F0.path(q.target.displayPath)} (not empty)`);continue}if(q.reason==="permission denied"){_.warn(`Skipped ${F0.path(q.target.displayPath)} (permission denied)`);continue}if(q.reason==="containment violation"){_.warn(`Skipped ${F0.path(q.target.displayPath)} (containment violation)`);continue}}if(q.success)_.success(`Removed ${F0.path(q.target.displayPath)}`);else _.error(`Failed to remove ${q.target.displayPath}: ${q.error?.message}`)}if($){if($.skipped&&$.reason==="not found");else if($.success&&!$.skipped)_.success(`Removed binary ${F0.path($.target.displayPath)}`);else if(!$.success)_.error(`Failed to remove binary ${$.target.displayPath}: ${$.error?.message}`)}if(H9(Y))_.break(),_.info(`Binary is managed by ${Y}. To complete uninstall, run:`),_.log(` ${F0.command(_7(Y))}`)}function BL(){_.info("Nothing to remove. OCX is not installed globally.")}function z7(Q){return{path:Q.target.displayPath,kind:Q.target.kind,success:Q.success,skipped:Q.skipped,...Q.reason&&{reason:Q.reason},...Q.error&&{error:Q.error.message}}}async function _L(Q){let $=$5(),Y=FK($);if(!Y.valid)switch(Y.reason){case"not-found":break;case"symlink":return X9("VALIDATION_ERROR","Safety error: Global config root is a symlink. Aborting.",d1.SAFETY_ERROR);case"not-directory":return X9("VALIDATION_ERROR","Safety error: Global config root is not a directory. Aborting.",d1.SAFETY_ERROR);case"permission":return X9("PERMISSION_ERROR","Error: Cannot access global config root (permission denied).",d1.ERROR)}let q=jK(),J=q.filter((N)=>N.safetyStatus==="forbidden");if(J.length>0)return X9("VALIDATION_ERROR","Safety error: Target escapes containment boundary.",d1.SAFETY_ERROR,{targets:J.map((N)=>N.displayPath)});let X=q.filter((N)=>N.safetyStatus==="error");if(X.length>0)return X9("PERMISSION_ERROR","Error: Cannot verify containment for targets (permission/IO error).",d1.ERROR,{targets:X.map((N)=>N.displayPath)});let H=n9(),G=wK(),K=q.filter((N)=>N.kind!=="missing"),W=Boolean(G&&G.kind!=="missing"),z=H9(H);if(K.length===0&&!W&&!z)return t6({message:"Nothing to remove. OCX is not installed globally.",removed:[],skipped:[]},d1.SUCCESS);if(Q.dryRun){let{dryRunResult:N,hints:c}=IK(q,G,H);return t6({...N,...c.length>0&&{hints:c}},d1.SUCCESS)}let B=DK(q),Z=null;if(G)Z=OK(G.absolutePath,{suppressOutput:!0});let M=B.some((N)=>!N.success&&!N.skipped),V=Boolean(Z&&!Z.success&&!Z.skipped);if(M||V)return X9("PERMISSION_ERROR","Failed to remove one or more uninstall targets.",d1.ERROR,{configResults:B.map(z7),...Z&&{binaryResult:z7(Z)}});if(H9(H))return X9("UPDATE_ERROR",`Binary is managed by ${H}. Run: ${_7(H)}`,d1.ERROR,{installMethod:H,command:_7(H),configResults:B.map(z7),...Z&&{binaryResult:z7(Z)}});let U=B.filter((N)=>N.success&&!N.skipped).map((N)=>N.target.displayPath),R=B.filter((N)=>N.skipped).map((N)=>({path:N.target.displayPath,reason:N.reason??"skipped"}));if(Z){if(Z.success&&!Z.skipped)U.push(Z.target.displayPath);else if(Z.skipped)R.push({path:Z.target.displayPath,reason:Z.reason??"skipped"})}return t6({removed:U,skipped:R,installMethod:H},d1.SUCCESS)}async function ZL(Q){if(Q.json){await _L(Q);return}let $=$5(),Y=FK($);if(!Y.valid)switch(Y.reason){case"not-found":break;case"symlink":_.error("Safety error: Global config root is a symlink. Aborting."),process.exit(d1.SAFETY_ERROR);break;case"not-directory":_.error("Safety error: Global config root is not a directory. Aborting."),process.exit(d1.SAFETY_ERROR);break;case"permission":_.error("Error: Cannot access global config root (permission denied)."),process.exit(d1.ERROR);break}let q=jK(),J=q.filter((U)=>U.safetyStatus==="forbidden");if(J.length>0){_.error("Safety error: Target escapes containment boundary:");for(let U of J)_.error(` ${U.displayPath}`);process.exit(d1.SAFETY_ERROR)}let X=q.filter((U)=>U.safetyStatus==="error");if(X.length>0){_.error("Error: Cannot verify containment for targets (permission/IO error):");for(let U of X)_.error(` ${U.displayPath}`);process.exit(d1.ERROR)}let H=n9(),G=wK(),K=q.filter((U)=>U.kind!=="missing"),W=G&&G.kind!=="missing",z=H9(H);if(K.length===0&&!W&&!z)BL(),process.exit(d1.SUCCESS);if(Q.dryRun)KL(q,G,H),process.exit(d1.SUCCESS);WL(q,G);let B=DK(q),Z=null;if(G)Z=OK(G.absolutePath);zL(B,Z,H);let M=B.some((U)=>!U.success&&!U.skipped),V=Z&&!Z.success&&!Z.skipped;if(M||V)process.exit(d1.ERROR);if(H9(H))process.exit(d1.ERROR);process.exit(d1.SUCCESS)}function NK(Q){Q.command("uninstall").description("Remove OCX global configuration and binary").option("--dry-run","Preview what would be removed").option("--json","Output as JSON").action(async($)=>{try{await ZL($)}catch(Y){s(Y,{json:$.json})}})}var d1;var TK=A(()=>{W0();W7();e8();y1();c1();d1={SUCCESS:0,ERROR:1,SAFETY_ERROR:2}});class bK{version="2.0.9"}var RK;var SK=A(()=>{RK=new bK});var kK={};F8(kK,{checkForUpdate:()=>q5,EXPLICIT_UPDATE_TIMEOUT_MS:()=>Y5});function EK(Q){let[$=""]=Q.split("-"),Y=$.split("."),q=parseInt(Y[0]??"",10),J=parseInt(Y[1]??"",10),X=parseInt(Y[2]??"",10);if(Number.isNaN(q)||Number.isNaN(J)||Number.isNaN(X))return null;return{major:q,minor:J,patch:X}}function VL(Q,$){let Y=EK(Q),q=EK($);if(!Y||!q)return null;if(Y.major!==q.major)return Y.major-q.major;if(Y.minor!==q.minor)return Y.minor-q.minor;return Y.patch-q.patch}async function q5(Q,$=ML){let q=(Q??RK).version||"0.0.0-dev";if(q==="0.0.0-dev")return{ok:!1,reason:"dev-version"};try{let X=(await v3(UL,void 0,AbortSignal.timeout($))).version,H=VL(X,q);if(H===null)return{ok:!1,reason:"invalid-response"};return{ok:!0,current:q,latest:X,updateAvailable:H>0}}catch(J){if(J instanceof Error){if(J.name==="AbortError"||J.name==="TimeoutError")return{ok:!1,reason:"timeout"};if(J instanceof I1||J.name==="NetworkError")return{ok:!1,reason:"network-error"}}return{ok:!1,reason:"invalid-response"}}}var ML=200,Y5=1e4,UL="ocx";var J5=A(()=>{t();X6();SK()});import{chmodSync as AL,existsSync as G9,renameSync as X5,unlinkSync as Z7}from"fs";function jL(){let Q=process.env.OCX_DOWNLOAD_URL;if(Q)return Q.replace(/\/+$/,"");return FL}function H5(Q){let $=`${process.arch}-${process.platform}`,Y=vK[$];if(!Y){let J=Object.keys(vK).join(", ");throw new x1(`Unsupported platform: ${$}
253
+ Valid methods: ${$.join(", ")}`);return Y}function n9(){if(rA())return"curl";let Q=process.argv[1]??"";if(aA(Q))return"unknown";if(tA(Q))return"yarn";if(eA(Q))return"pnpm";if(QL(Q))return"bun";if($L(Q))return"npm";let $=process.env.npm_config_user_agent??"";if($.includes("yarn"))return"yarn";if($.includes("pnpm"))return"pnpm";if($.includes("bun"))return"bun";if($.includes("npm"))return"npm";return"unknown"}function K7(){if(typeof Bun<"u"&&Bun.main.startsWith("/$bunfs/"))return process.execPath;return process.argv[1]??process.execPath}var rA=()=>Bun.main.startsWith("/$bunfs/"),aA=(Q)=>Q.includes("/_npx/")||Q.includes("/.cache/bunx/")||Q.includes("/.pnpm/_temp/"),tA=(Q)=>Q.includes("/.yarn/global")||Q.includes("/.config/yarn/global"),eA=(Q)=>Q.includes("/.pnpm/")||Q.includes("/pnpm/global"),QL=(Q)=>Q.includes("/.bun/bin")||Q.includes("/.bun/install/global"),$L=(Q)=>Q.includes("/.npm/")||Q.includes("/node_modules/");var W7=A(()=>{t()});import{existsSync as e6,lstatSync as VK,readdirSync as YL,realpathSync as MK,rmSync as qL,unlinkSync as AK}from"fs";import{homedir as LK}from"os";import i0 from"path";function t6(Q,$=0){F1({success:!0,data:Q}),process.exit($)}function X9(Q,$,Y,q){let J={success:!1,error:{code:Q,message:$,...q&&{details:q}},exitCode:Y,meta:{timestamp:new Date().toISOString()}};F1(J),process.exit(Y)}function Q5(Q){return Q instanceof Error&&"code"in Q}function y2(Q){let $=LK();if(!$)return Q;if(Q===$)return"~";if(Q.startsWith($+i0.sep))return`~${Q.slice($.length)}`;return Q}function B7(Q,$){let Y=i0.normalize(Q),q=i0.normalize($),J=i0.relative(Y,q);if(J.startsWith("..")||i0.isAbsolute(J))return null;return J}function JL(Q,$){return B7(Q,$)!==null}function XL(Q,$){if(!e6($))return{contained:!0};try{let Y=MK(Q),q=MK($);return{contained:B7(Y,q)!==null}}catch(Y){if(Q5(Y)&&(Y.code==="EACCES"||Y.code==="EPERM"))return{contained:!1,error:"permission"};return{contained:!1,error:"io"}}}function FK(Q){try{let $=VK(Q);if($.isSymbolicLink())return{valid:!1,reason:"symlink"};if(!$.isDirectory())return{valid:!1,reason:"not-directory"};return{valid:!0}}catch($){if(Q5($)){if($.code==="ENOENT")return{valid:!1,reason:"not-found"};if($.code==="EACCES"||$.code==="EPERM")return{valid:!1,reason:"permission"}}return{valid:!1,reason:"permission"}}}function h2(Q){if(!e6(Q))return"missing";try{let $=VK(Q);if($.isSymbolicLink())return"symlink";if($.isDirectory())return"directory";return"file"}catch{return"missing"}}function HL(Q){if(!e6(Q))return!0;try{return YL(Q).length===0}catch{return!1}}function UK(Q){if(Q.kind==="missing")return"safe";if(Q.kind==="symlink")return JL(Q.rootPath,Q.absolutePath)?"safe":"forbidden";let $=XL(Q.rootPath,Q.absolutePath);if($.error)return"error";return $.contained?"safe":"forbidden"}function H9(Q){return Q==="npm"||Q==="pnpm"||Q==="bun"||Q==="yarn"}function _7(Q){switch(Q){case"npm":return"npm uninstall -g ocx";case"pnpm":return"pnpm remove -g ocx";case"bun":return"bun remove -g ocx";case"yarn":return"yarn global remove ocx";default:return"npm uninstall -g ocx"}}function $5(){let Q=process.env.XDG_CONFIG_HOME||i0.join(LK(),".config");return i0.join(Q,"opencode")}function jK(){let Q=$5(),$=[],Y=_8(),q=B7(Q,Y);if(q){let G=h2(Y);$.push({rootPath:Q,relativePath:q,absolutePath:Y,displayPath:y2(Y),kind:G,deleteIfEmpty:!1,safetyStatus:UK({rootPath:Q,absolutePath:Y,kind:G})})}let J=P9(),X=B7(Q,J);if(X){let G=h2(J);$.push({rootPath:Q,relativePath:X,absolutePath:J,displayPath:y2(J),kind:G,deleteIfEmpty:!1,safetyStatus:UK({rootPath:Q,absolutePath:J,kind:G})})}let H=h2(Q);return $.push({rootPath:Q,relativePath:".",absolutePath:Q,displayPath:y2(Q),kind:H,deleteIfEmpty:!0,safetyStatus:H==="missing"?"safe":"safe"}),$}function wK(){let Q=n9();if(H9(Q))return null;if(Q==="curl"){let $=K7(),Y=h2($);return{rootPath:i0.dirname($),relativePath:i0.basename($),absolutePath:$,displayPath:y2($),kind:Y,deleteIfEmpty:!1,safetyStatus:Y==="missing"?"safe":"safe"}}return null}function GL(Q){if(Q.kind==="missing")return{target:Q,success:!0,skipped:!0,reason:"not found"};if(Q.safetyStatus==="forbidden")return{target:Q,success:!1,skipped:!0,reason:"containment violation",error:Error("Target escapes containment boundary")};if(Q.deleteIfEmpty&&Q.kind==="directory"){if(!HL(Q.absolutePath))return{target:Q,success:!0,skipped:!0,reason:"not empty"}}try{if(Q.kind==="directory")qL(Q.absolutePath,{recursive:!0,force:!0});else AK(Q.absolutePath);return{target:Q,success:!0,skipped:!1}}catch($){let Y=$ instanceof Error?$:Error(String($)),q=Q5($)&&($.code==="EACCES"||$.code==="EPERM")?"permission denied":void 0;return{target:Q,success:!1,skipped:!1,reason:q,error:Y}}}function DK(Q){return Q.map(GL)}function OK(Q,$={}){let Y={rootPath:i0.dirname(Q),relativePath:i0.basename(Q),absolutePath:Q,displayPath:y2(Q),kind:h2(Q),deleteIfEmpty:!1,safetyStatus:"safe"};if(Y.kind==="missing")return{target:Y,success:!0,skipped:!0,reason:"not found"};if(process.platform==="win32"){if(!$.suppressOutput)_.info(`To complete uninstall, manually delete: ${Y.displayPath}`);return{target:Y,success:!0,skipped:!0}}try{return AK(Q),{target:Y,success:!0,skipped:!1}}catch(q){let J=q instanceof Error?q:Error(String(q));return{target:Y,success:!1,skipped:!1,reason:"permission denied",error:J}}}function KL(Q,$,Y){let{dryRunResult:q,hints:J}=IK(Q,$,Y);w0(q,{hints:J})}function IK(Q,$,Y){let q=Q.filter((G)=>G.kind!=="missing"),J=[];for(let G of q)J.push({action:"delete",target:G.displayPath,details:{kind:G.kind,...G.deleteIfEmpty&&{deleteIfEmpty:!0}}});if($&&$.kind!=="missing")J.push({action:"delete",target:$.displayPath,details:{kind:"binary"}});let X=[];if(H9(Y))X.push(`Binary is managed by ${Y}. Run: ${_7(Y)}`);return{dryRunResult:{dryRun:!0,command:"self uninstall",wouldPerform:J,validation:{passed:!0},summary:J.length>0?`Would remove ${J.length} item(s)`:"Nothing to remove"},hints:X}}function WL(Q,$){if(Q.filter((q)=>q.kind!=="missing").length>0||$&&$.kind!=="missing")_.info("Removing OCX files...")}function zL(Q,$,Y){_.break();for(let q of Q){if(q.skipped){if(q.reason==="not found")continue;if(q.reason==="not empty"){_.info(`Kept ${F0.path(q.target.displayPath)} (not empty)`);continue}if(q.reason==="permission denied"){_.warn(`Skipped ${F0.path(q.target.displayPath)} (permission denied)`);continue}if(q.reason==="containment violation"){_.warn(`Skipped ${F0.path(q.target.displayPath)} (containment violation)`);continue}}if(q.success)_.success(`Removed ${F0.path(q.target.displayPath)}`);else _.error(`Failed to remove ${q.target.displayPath}: ${q.error?.message}`)}if($){if($.skipped&&$.reason==="not found");else if($.success&&!$.skipped)_.success(`Removed binary ${F0.path($.target.displayPath)}`);else if(!$.success)_.error(`Failed to remove binary ${$.target.displayPath}: ${$.error?.message}`)}if(H9(Y))_.break(),_.info(`Binary is managed by ${Y}. To complete uninstall, run:`),_.log(` ${F0.command(_7(Y))}`)}function BL(){_.info("Nothing to remove. OCX is not installed globally.")}function z7(Q){return{path:Q.target.displayPath,kind:Q.target.kind,success:Q.success,skipped:Q.skipped,...Q.reason&&{reason:Q.reason},...Q.error&&{error:Q.error.message}}}async function _L(Q){let $=$5(),Y=FK($);if(!Y.valid)switch(Y.reason){case"not-found":break;case"symlink":return X9("VALIDATION_ERROR","Safety error: Global config root is a symlink. Aborting.",d1.SAFETY_ERROR);case"not-directory":return X9("VALIDATION_ERROR","Safety error: Global config root is not a directory. Aborting.",d1.SAFETY_ERROR);case"permission":return X9("PERMISSION_ERROR","Error: Cannot access global config root (permission denied).",d1.ERROR)}let q=jK(),J=q.filter((N)=>N.safetyStatus==="forbidden");if(J.length>0)return X9("VALIDATION_ERROR","Safety error: Target escapes containment boundary.",d1.SAFETY_ERROR,{targets:J.map((N)=>N.displayPath)});let X=q.filter((N)=>N.safetyStatus==="error");if(X.length>0)return X9("PERMISSION_ERROR","Error: Cannot verify containment for targets (permission/IO error).",d1.ERROR,{targets:X.map((N)=>N.displayPath)});let H=n9(),G=wK(),K=q.filter((N)=>N.kind!=="missing"),W=Boolean(G&&G.kind!=="missing"),z=H9(H);if(K.length===0&&!W&&!z)return t6({message:"Nothing to remove. OCX is not installed globally.",removed:[],skipped:[]},d1.SUCCESS);if(Q.dryRun){let{dryRunResult:N,hints:c}=IK(q,G,H);return t6({...N,...c.length>0&&{hints:c}},d1.SUCCESS)}let B=DK(q),Z=null;if(G)Z=OK(G.absolutePath,{suppressOutput:!0});let M=B.some((N)=>!N.success&&!N.skipped),V=Boolean(Z&&!Z.success&&!Z.skipped);if(M||V)return X9("PERMISSION_ERROR","Failed to remove one or more uninstall targets.",d1.ERROR,{configResults:B.map(z7),...Z&&{binaryResult:z7(Z)}});if(H9(H))return X9("UPDATE_ERROR",`Binary is managed by ${H}. Run: ${_7(H)}`,d1.ERROR,{installMethod:H,command:_7(H),configResults:B.map(z7),...Z&&{binaryResult:z7(Z)}});let U=B.filter((N)=>N.success&&!N.skipped).map((N)=>N.target.displayPath),R=B.filter((N)=>N.skipped).map((N)=>({path:N.target.displayPath,reason:N.reason??"skipped"}));if(Z){if(Z.success&&!Z.skipped)U.push(Z.target.displayPath);else if(Z.skipped)R.push({path:Z.target.displayPath,reason:Z.reason??"skipped"})}return t6({removed:U,skipped:R,installMethod:H},d1.SUCCESS)}async function ZL(Q){if(Q.json){await _L(Q);return}let $=$5(),Y=FK($);if(!Y.valid)switch(Y.reason){case"not-found":break;case"symlink":_.error("Safety error: Global config root is a symlink. Aborting."),process.exit(d1.SAFETY_ERROR);break;case"not-directory":_.error("Safety error: Global config root is not a directory. Aborting."),process.exit(d1.SAFETY_ERROR);break;case"permission":_.error("Error: Cannot access global config root (permission denied)."),process.exit(d1.ERROR);break}let q=jK(),J=q.filter((U)=>U.safetyStatus==="forbidden");if(J.length>0){_.error("Safety error: Target escapes containment boundary:");for(let U of J)_.error(` ${U.displayPath}`);process.exit(d1.SAFETY_ERROR)}let X=q.filter((U)=>U.safetyStatus==="error");if(X.length>0){_.error("Error: Cannot verify containment for targets (permission/IO error):");for(let U of X)_.error(` ${U.displayPath}`);process.exit(d1.ERROR)}let H=n9(),G=wK(),K=q.filter((U)=>U.kind!=="missing"),W=G&&G.kind!=="missing",z=H9(H);if(K.length===0&&!W&&!z)BL(),process.exit(d1.SUCCESS);if(Q.dryRun)KL(q,G,H),process.exit(d1.SUCCESS);WL(q,G);let B=DK(q),Z=null;if(G)Z=OK(G.absolutePath);zL(B,Z,H);let M=B.some((U)=>!U.success&&!U.skipped),V=Z&&!Z.success&&!Z.skipped;if(M||V)process.exit(d1.ERROR);if(H9(H))process.exit(d1.ERROR);process.exit(d1.SUCCESS)}function NK(Q){Q.command("uninstall").description("Remove OCX global configuration and binary").option("--dry-run","Preview what would be removed").option("--json","Output as JSON").action(async($)=>{try{await ZL($)}catch(Y){s(Y,{json:$.json})}})}var d1;var TK=A(()=>{W0();W7();e8();y1();c1();d1={SUCCESS:0,ERROR:1,SAFETY_ERROR:2}});class bK{version="2.0.10"}var RK;var SK=A(()=>{RK=new bK});var kK={};F8(kK,{checkForUpdate:()=>q5,EXPLICIT_UPDATE_TIMEOUT_MS:()=>Y5});function EK(Q){let[$=""]=Q.split("-"),Y=$.split("."),q=parseInt(Y[0]??"",10),J=parseInt(Y[1]??"",10),X=parseInt(Y[2]??"",10);if(Number.isNaN(q)||Number.isNaN(J)||Number.isNaN(X))return null;return{major:q,minor:J,patch:X}}function VL(Q,$){let Y=EK(Q),q=EK($);if(!Y||!q)return null;if(Y.major!==q.major)return Y.major-q.major;if(Y.minor!==q.minor)return Y.minor-q.minor;return Y.patch-q.patch}async function q5(Q,$=ML){let q=(Q??RK).version||"0.0.0-dev";if(q==="0.0.0-dev")return{ok:!1,reason:"dev-version"};try{let X=(await v3(UL,void 0,AbortSignal.timeout($))).version,H=VL(X,q);if(H===null)return{ok:!1,reason:"invalid-response"};return{ok:!0,current:q,latest:X,updateAvailable:H>0}}catch(J){if(J instanceof Error){if(J.name==="AbortError"||J.name==="TimeoutError")return{ok:!1,reason:"timeout"};if(J instanceof I1||J.name==="NetworkError")return{ok:!1,reason:"network-error"}}return{ok:!1,reason:"invalid-response"}}}var ML=200,Y5=1e4,UL="ocx";var J5=A(()=>{t();X6();SK()});import{chmodSync as AL,existsSync as G9,renameSync as X5,unlinkSync as Z7}from"fs";function jL(){let Q=process.env.OCX_DOWNLOAD_URL;if(Q)return Q.replace(/\/+$/,"");return FL}function H5(Q){let $=`${process.arch}-${process.platform}`,Y=vK[$];if(!Y){let J=Object.keys(vK).join(", ");throw new x1(`Unsupported platform: ${$}
254
254
  Supported platforms: ${J}`)}return`${jL()}/v${Q}/${Y}`}async function wL(Q,$,Y={}){let q=Y.quiet?null:M1({text:"Downloading update..."});q?.start();let J;try{J=await fetch(Q,{redirect:"follow"})}catch(W){throw q?.fail("Download failed"),new x1(`Network error: ${W instanceof Error?W.message:String(W)}`)}if(!J.ok)throw q?.fail("Download failed"),new x1(`Failed to download: HTTP ${J.status} ${J.statusText}`);if(!J.body)throw q?.fail("Download failed"),new x1("Download failed: Empty response body");let X=J.body.getReader(),H=Bun.file($).writer(),G=Number(J.headers.get("content-length")||0),K=0;try{while(!0){let{done:W,value:z}=await X.read();if(W)break;if(await H.write(z),K+=z.length,G>0&&q){let B=Math.round(K/G*100);q.text=`Downloading... ${B}%`}}await H.end(),q?.succeed("Download complete")}catch(W){throw q?.fail("Download failed"),await H.end(),new x1(`Download interrupted: ${W instanceof Error?W.message:String(W)}`)}}async function PK(Q,$={}){let Y=K7(),q=`${Y}.new.${Date.now()}`,J=H5(Q);await wL(J,q,$);try{AL(q,493)}catch(X){if(G9(q))Z7(q);throw new x1(`Failed to set permissions: ${X instanceof Error?X.message:String(X)}`)}return{tempPath:q,execPath:Y}}function xK(Q,$){let Y=`${$}.backup`;try{if(G9($))X5($,Y);if(X5(Q,$),G9(Y))Z7(Y)}catch(q){if(G9(Y)&&!G9($))try{X5(Y,$)}catch{}if(G9(Q))try{Z7(Q)}catch{}throw new x1(`Update failed: ${q instanceof Error?q.message:String(q)}`)}}function CK(Q){if(G9(Q))try{Z7(Q)}catch{}}var LL="kdcokenny/ocx",FL,vK;var yK=A(()=>{t();l0();W7();FL=`https://github.com/${LL}/releases/download`,vK={"arm64-darwin":"ocx-darwin-arm64","x64-darwin":"ocx-darwin-x64","arm64-linux":"ocx-linux-arm64","x64-linux":"ocx-linux-x64","x64-win32":"ocx-windows-x64.exe"}});var hK={};F8(hK,{notifyUpdated:()=>M7,notifyUpdate:()=>DL,notifyUpToDate:()=>G5});function DL(Q,$){if(!process.stdout.isTTY)return;console.error(`${P.cyan("info")}: update available - ${P.green($)} (current: ${P.dim(Q)})`),console.error(` run ${P.cyan("`ocx self update`")} to upgrade`)}function G5(Q){console.error(`${P.cyan("info")}: ocx unchanged - ${P.dim(Q)}`)}function M7(Q,$){console.error(` ${P.green("ocx updated")} - ${$} (from ${Q})`)}var K5=A(()=>{W8()});import{createHash as OL}from"crypto";function NL(Q){let $=new Map;for(let Y of Q.split(`
255
255
  `)){let q=Y.match(/^([a-fA-F0-9]{64})\s+\*?(.+)$/);if(q?.[1]&&q[2])$.set(q[2].trim(),q[1].toLowerCase())}return $}function TL(Q){return OL("sha256").update(Q).digest("hex")}async function fK(Q){let $=`https://github.com/${IL}/releases/download/v${Q}/SHA256SUMS.txt`,Y=await fetch($);if(!Y.ok)throw new x1(`Failed to fetch checksums: ${Y.status}`);let q=await Y.text();return NL(q)}async function uK(Q,$,Y){let J=await Bun.file(Q).arrayBuffer(),X=TL(Buffer.from(J));if(X!==$)throw new m8(Y,$,X)}var IL="kdcokenny/ocx";var mK=A(()=>{t()});var gK={};F8(gK,{runSelfUpdateCommand:()=>SL});async function SL(Q){let $=Q.method?ZK(Q.method):n9(),Y=Q.json===!0,q=await q5(void 0,Y5);if(!q.ok)throw new x1(RL[q.reason]);let{current:J,latest:X,updateAvailable:H}=q;if(!H&&!Q.force){if(Y)F1({success:!0,data:{current:J,latest:X,method:$,updated:!1}});else G5(J);return}let G=X;switch($){case"curl":{await EL(J,G,Y);break}case"npm":case"pnpm":case"bun":case"yarn":case"unknown":{await kL($,J,G,Y);break}}if(Y)F1({success:!0,data:{current:J,latest:G,method:$,updated:!0}})}async function EL(Q,$,Y){let J=H5($).split("/").pop();if(!J)throw new x1("Failed to determine binary filename from download URL");let H=(await fK($)).get(J);if(!H)throw new x1(`Security error: No checksum found for ${J}. Update aborted.`);let{tempPath:G,execPath:K}=await PK($,{quiet:Y});try{await uK(G,H,J)}catch(W){throw CK(G),W}if(xK(G,K),!Y)M7(Q,$)}async function U7(Q){let $=Bun.spawn(Q,{stdout:"pipe",stderr:"pipe"});if(await $.exited!==0){let q=await new Response($.stderr).text();throw new x1(`Package manager command failed: ${q.trim()}`)}}async function kL(Q,$,Y,q){if(!bL.test(Y))throw new x1(`Invalid version format: ${Y}`);let J=q?null:M1({text:`Updating via ${Q}...`});J?.start();try{switch(Q){case"npm":{await U7(["npm","install","-g",`ocx@${Y}`]);break}case"yarn":{await U7(["yarn","global","add",`ocx@${Y}`]);break}case"pnpm":{await U7(["pnpm","install","-g",`ocx@${Y}`]);break}case"bun":{await U7(["bun","install","-g",`ocx@${Y}`]);break}case"unknown":throw new x1(`Could not detect install method. Update manually with one of:
256
256
  npm install -g ocx@latest
@@ -269,6 +269,6 @@ Use '${Q.slice(0,-1)}' to update to the latest version.`);return{component:Q}}fu
269
269
  `)+`
270
270
 
271
271
  Please use a fully qualified name (alias/component).`);throw new L(`Component '${H}' must include a registry alias (e.g., 'kdco/${H}').`)}let{namespace:G,component:K}=g0(H),W=q.filter((B)=>{let Z=R8(B);return Z.registryName===G&&Z.name===K});if(W.length===0)throw new _1(`Component '${H}' is not installed.
272
- Run '${W5(H,Y)}' to install it first.`);let z=W[0];if(!z)throw Error("Unexpected: matchingIds has length but first element is undefined");J.push({component:z})}return J}function dL(Q,$){let Y=Q.filter((X)=>X.status==="would-update"),J={dryRun:!0,command:"update",wouldPerform:Y.map((X)=>({action:"update",target:X.qualifiedName,details:{from:X.oldVersion,to:X.newVersion}})),validation:{passed:!0},summary:Y.length>0?`Would update ${Y.length} component(s)`:"All components are up to date"};w0(J,{json:$.json,quiet:$.quiet})}var rK=A(()=>{k9();t8();q0();c0();e8();t();y1();c1();k8();P3();y9();k0();l0()});import{resolve as pL}from"path";function lL(Q,$){if($==="not_found")return new _1(Q);if($==="parse_error")return new B1(Q,"CONFIG_ERROR",G1.CONFIG);return new B1(Q,"CONFIG_ERROR",G1.CONFIG)}function iL(Q,$){let Y=P2(Q,{schemaErrors:$==="schema"?Q.length:0}),q={valid:!1,errors:Q,summary:{valid:!1,totalErrors:Y.totalErrors,schemaErrors:Y.schemaErrors,sourceFileErrors:Y.sourceFileErrors,circularDependencyErrors:Y.circularDependencyErrors,duplicateTargetErrors:Y.duplicateTargetErrors,otherErrors:Y.otherErrors}};return new u8(q)}function nL(Q){for(let $ of Q)console.log(P.red(` ${$}`))}function aK(Q){Q.command("validate").description("Validate a registry source (for registry authors)").argument("[path]","Registry source directory",".").option("--cwd <path>","Working directory",process.cwd()).option("--json","Output as JSON",!1).option("-q, --quiet","Suppress output",!1).option("--no-duplicate-targets","Skip duplicate target validation").action(async($,Y)=>{try{let q=pL(Y.cwd,$),J=await o3(q,{skipDuplicateTargets:Y.duplicateTargets===!1});if(!J.success){let[X="Registry validation failed"]=J.errors;if(J.failureType==="load"){let G=lL(X,J.loadErrorKind);if(!Y.json&&Y.quiet){let K=G instanceof B1?G.exitCode:G1.GENERAL;process.exit(K)}throw G}let H=iL(J.errors,J.failureType==="schema"?"schema":"rules");if(Y.json)throw H;if(!Y.quiet)_.error(H.message),nL(J.errors);process.exit(H.exitCode)}if(!Y.quiet&&!Y.json)_.success("\u2713 Registry source is valid");if(Y.json)F1({success:!0,data:{valid:!0,errors:[],summary:P2([])}})}catch(q){if(!Y.json&&Y.quiet){let J=q instanceof B1?q.exitCode:G1.GENERAL;process.exit(J)}s(q,{json:Y.json})}})}var tK=A(()=>{W8();P6();t();y1();c1()});function eK(Q){let $=Q.command("verify").description("Verify integrity of installed components").argument("[components...]","Components to verify (optional, verifies all if omitted)");Q0($),B0($),$.action(async(Y,q)=>{try{await oL(Y,q)}catch(J){s(J,{json:q.json})}})}async function oL(Q,$){let Y=$.cwd??process.cwd(),q=await R0.requireInitialized(Y),J=await L0(q.cwd);if(!J||Object.keys(J.installed).length===0){if($.json)console.log(JSON.stringify({success:!0,verified:[],errors:[]},null,2));else if(!$.quiet)_.info("No components installed.");return}let X;if(Q.length>0)X=H7(Q,J);else X=Object.keys(J.installed);let H=$.quiet||$.json?null:M1({text:"Verifying components..."});H?.start();let G=[],K=!1;for(let W of X){let z=J.installed[W];if(!z){if(Q.length>0)_.warn(`Component '${W}' not found in receipt.`);continue}let B=await T2(q.cwd,z);if(!B.intact)K=!0;G.push({canonicalId:W,intact:B.intact,modified:B.modified,missing:B.missing})}if(H?.succeed(`Verified ${G.length} component(s)`),$.json){if(console.log(JSON.stringify({success:!K,verified:G.filter((W)=>W.intact),errors:G.filter((W)=>!W.intact)},null,2)),K)process.exit(G1.CONFLICT);return}if(!$.quiet){_.info("");for(let W of G)if(W.intact){if($.verbose)_.success(`\u2713 ${W.canonicalId} - all files intact`)}else{_.error(`\u2717 ${W.canonicalId} - integrity check failed`);for(let z of W.modified)_.error(` Modified: ${z}`);for(let z of W.missing)_.error(` Missing: ${z}`)}}if(K){if(!$.quiet)_.info(""),_.warn("Some files have been modified or are missing. Review local changes with git, then run 'ocx update <alias/component>' or 'ocx update --all' to restore.");throw new n1("File integrity check failed for one or more components.")}if(!$.quiet)_.info(""),_.success("All components verified successfully.")}var QW=A(()=>{k9();q0();r6();t();y1();c1();y9();k0();l0()});function sL(){if(process.env.OCX_SELF_UPDATE==="off")return!1;if(QJ(process.env.OCX_NO_UPDATE_CHECK,!1))return!1;if(process.env.CI)return!1;if(!process.stdout.isTTY)return!1;return!0}function $W(Q){Q.hook("postAction",async($,Y)=>{if(Y.name()==="update"&&Y.parent?.name()==="self")return;let q=Y.opts();if(q.json||q.quiet)return;if(!sL())return;try{let[{checkForUpdate:J},{notifyUpdate:X}]=await Promise.all([Promise.resolve().then(() => (J5(),kK)),Promise.resolve().then(() => (K5(),hK))]),H=await J();if(H.ok&&H.updateAvailable)X(H.current,H.latest)}catch{}})}var YW=A(()=>{F2()});async function qW(Q=process.argv){let $=new FJ().name("ocx").description("OpenCode Extensions - Install agents, skills, plugins, and commands").version(rL);if(eH($),yH($),sK($),BK($),QK($),cH($),aK($),lK($),eK($),JK($),KG($),rG($),sH($),EG($),$W($),Q.length<=2){process.stdout.write($.helpInformation());return}await $.parseAsync(Q)}var rL="2.0.9";var JW=A(()=>{L3();v6();dH();rH();$G();zG();kG();aG();$K();XK();_K();iK();rK();tK();QW();YW()});var XW={};F8(XW,{runCliEntryPoint:()=>aL});async function aL(Q=process.argv){try{await qW(Q)}catch($){s($)}}var HW=A(()=>{y1();JW()});_3();k4();if(import.meta.main)tL();async function tL(){let{runCliEntryPoint:Q}=await Promise.resolve().then(() => (HW(),XW));await Q()}export{p8 as registrySchema,M2 as packumentSchema,M3 as ocxLockSchema,b8 as ocxConfigSchema,c8 as componentManifestSchema,U2 as buildRegistry};
272
+ Run '${W5(H,Y)}' to install it first.`);let z=W[0];if(!z)throw Error("Unexpected: matchingIds has length but first element is undefined");J.push({component:z})}return J}function dL(Q,$){let Y=Q.filter((X)=>X.status==="would-update"),J={dryRun:!0,command:"update",wouldPerform:Y.map((X)=>({action:"update",target:X.qualifiedName,details:{from:X.oldVersion,to:X.newVersion}})),validation:{passed:!0},summary:Y.length>0?`Would update ${Y.length} component(s)`:"All components are up to date"};w0(J,{json:$.json,quiet:$.quiet})}var rK=A(()=>{k9();t8();q0();c0();e8();t();y1();c1();k8();P3();y9();k0();l0()});import{resolve as pL}from"path";function lL(Q,$){if($==="not_found")return new _1(Q);if($==="parse_error")return new B1(Q,"CONFIG_ERROR",G1.CONFIG);return new B1(Q,"CONFIG_ERROR",G1.CONFIG)}function iL(Q,$){let Y=P2(Q,{schemaErrors:$==="schema"?Q.length:0}),q={valid:!1,errors:Q,summary:{valid:!1,totalErrors:Y.totalErrors,schemaErrors:Y.schemaErrors,sourceFileErrors:Y.sourceFileErrors,circularDependencyErrors:Y.circularDependencyErrors,duplicateTargetErrors:Y.duplicateTargetErrors,otherErrors:Y.otherErrors}};return new u8(q)}function nL(Q){for(let $ of Q)console.log(P.red(` ${$}`))}function aK(Q){Q.command("validate").description("Validate a registry source (for registry authors)").argument("[path]","Registry source directory",".").option("--cwd <path>","Working directory",process.cwd()).option("--json","Output as JSON",!1).option("-q, --quiet","Suppress output",!1).option("--no-duplicate-targets","Skip duplicate target validation").action(async($,Y)=>{try{let q=pL(Y.cwd,$),J=await o3(q,{skipDuplicateTargets:Y.duplicateTargets===!1});if(!J.success){let[X="Registry validation failed"]=J.errors;if(J.failureType==="load"){let G=lL(X,J.loadErrorKind);if(!Y.json&&Y.quiet){let K=G instanceof B1?G.exitCode:G1.GENERAL;process.exit(K)}throw G}let H=iL(J.errors,J.failureType==="schema"?"schema":"rules");if(Y.json)throw H;if(!Y.quiet)_.error(H.message),nL(J.errors);process.exit(H.exitCode)}if(!Y.quiet&&!Y.json)_.success("\u2713 Registry source is valid");if(Y.json)F1({success:!0,data:{valid:!0,errors:[],summary:P2([])}})}catch(q){if(!Y.json&&Y.quiet){let J=q instanceof B1?q.exitCode:G1.GENERAL;process.exit(J)}s(q,{json:Y.json})}})}var tK=A(()=>{W8();P6();t();y1();c1()});function eK(Q){let $=Q.command("verify").description("Verify integrity of installed components").argument("[components...]","Components to verify (optional, verifies all if omitted)");Q0($),B0($),$.action(async(Y,q)=>{try{await oL(Y,q)}catch(J){s(J,{json:q.json})}})}async function oL(Q,$){let Y=$.cwd??process.cwd(),q=await R0.requireInitialized(Y),J=await L0(q.cwd);if(!J||Object.keys(J.installed).length===0){if($.json)console.log(JSON.stringify({success:!0,verified:[],errors:[]},null,2));else if(!$.quiet)_.info("No components installed.");return}let X;if(Q.length>0)X=H7(Q,J);else X=Object.keys(J.installed);let H=$.quiet||$.json?null:M1({text:"Verifying components..."});H?.start();let G=[],K=!1;for(let W of X){let z=J.installed[W];if(!z){if(Q.length>0)_.warn(`Component '${W}' not found in receipt.`);continue}let B=await T2(q.cwd,z);if(!B.intact)K=!0;G.push({canonicalId:W,intact:B.intact,modified:B.modified,missing:B.missing})}if(H?.succeed(`Verified ${G.length} component(s)`),$.json){if(console.log(JSON.stringify({success:!K,verified:G.filter((W)=>W.intact),errors:G.filter((W)=>!W.intact)},null,2)),K)process.exit(G1.CONFLICT);return}if(!$.quiet){_.info("");for(let W of G)if(W.intact){if($.verbose)_.success(`\u2713 ${W.canonicalId} - all files intact`)}else{_.error(`\u2717 ${W.canonicalId} - integrity check failed`);for(let z of W.modified)_.error(` Modified: ${z}`);for(let z of W.missing)_.error(` Missing: ${z}`)}}if(K){if(!$.quiet)_.info(""),_.warn("Some files have been modified or are missing. Review local changes with git, then run 'ocx update <alias/component>' or 'ocx update --all' to restore.");throw new n1("File integrity check failed for one or more components.")}if(!$.quiet)_.info(""),_.success("All components verified successfully.")}var QW=A(()=>{k9();q0();r6();t();y1();c1();y9();k0();l0()});function sL(){if(process.env.OCX_SELF_UPDATE==="off")return!1;if(QJ(process.env.OCX_NO_UPDATE_CHECK,!1))return!1;if(process.env.CI)return!1;if(!process.stdout.isTTY)return!1;return!0}function $W(Q){Q.hook("postAction",async($,Y)=>{if(Y.name()==="update"&&Y.parent?.name()==="self")return;let q=Y.opts();if(q.json||q.quiet)return;if(!sL())return;try{let[{checkForUpdate:J},{notifyUpdate:X}]=await Promise.all([Promise.resolve().then(() => (J5(),kK)),Promise.resolve().then(() => (K5(),hK))]),H=await J();if(H.ok&&H.updateAvailable)X(H.current,H.latest)}catch{}})}var YW=A(()=>{F2()});async function qW(Q=process.argv){let $=new FJ().name("ocx").description("OpenCode Extensions - Install agents, skills, plugins, and commands").version(rL);if(eH($),yH($),sK($),BK($),QK($),cH($),aK($),lK($),eK($),JK($),KG($),rG($),sH($),EG($),$W($),Q.length<=2){process.stdout.write($.helpInformation());return}await $.parseAsync(Q)}var rL="2.0.10";var JW=A(()=>{L3();v6();dH();rH();$G();zG();kG();aG();$K();XK();_K();iK();rK();tK();QW();YW()});var XW={};F8(XW,{runCliEntryPoint:()=>aL});async function aL(Q=process.argv){try{await qW(Q)}catch($){s($)}}var HW=A(()=>{y1();JW()});_3();k4();if(import.meta.main)tL();async function tL(){let{runCliEntryPoint:Q}=await Promise.resolve().then(() => (HW(),XW));await Q()}export{p8 as registrySchema,M2 as packumentSchema,M3 as ocxLockSchema,b8 as ocxConfigSchema,c8 as componentManifestSchema,U2 as buildRegistry};
273
273
 
274
- //# debugId=E31E2A787F91DAF064756E2164756E21
274
+ //# debugId=CE8F092191E4B2F164756E2164756E21
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ocx",
3
- "version": "2.0.9",
3
+ "version": "2.0.10",
4
4
  "description": "OCX CLI - OpenCode extension manager with portable, isolated profiles. Your setup, anywhere.",
5
5
  "author": "kdcokenny",
6
6
  "license": "MIT",