@longzai-intelligence-dependencies/cli 0.0.7 → 0.0.8

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 +7 -6
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -160,7 +160,7 @@ function ic(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...V(n)})}//
160
160
  function ac(e,t){let n=/* @__PURE__ */ oc(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(hr(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,`input`in r||(r.input=t.value),r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(hr(r))}},e(t.value,t)),t);return n}// @__NO_SIDE_EFFECTS__
161
161
  function oc(e,t){let n=new Vi({check:`custom`,...V(t)});return n._zod.check=e,n}function sc(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&Dn(e,t,n[t]);return e}function cc(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??rs,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:/* @__PURE__ */ new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,intersections:[],deferred:[],external:e?.external??void 0}}function lc(e,t,n,r,i){let a=typeof t.unrepresentable==`function`?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a===`any`)return!1;if(a===void 0||a===`throw`)throw Error(i);return Object.assign(n,a),!0}function uc(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,uc(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&sc(o.schema,c),t.io===`input`&&bc(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function dc(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function fc(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=/* @__PURE__ */ new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${dc(a)}`}}let i=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:`#`};let a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+dc(a)}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
162
162
 
163
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0])a(n);else{if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}(e.metadataRegistry.get(n[0])?.id||r.cycle||r.count>1&&e.reused===`ref`)&&a(n)}}e.external&&(e.sharedDefsExtractedFor=e.external)}function pc(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;pc(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}const mc=/* @__PURE__ */ new Set([`type`,`properties`,`required`,`additionalProperties`]),hc=[`oneOf`,`anyOf`];function gc(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function _c(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!mc.has(e))return null;t.push(n)}let n={},r=/* @__PURE__ */ new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??gc(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}Dn(n,r,e.length===1?e[0]:_c(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=gc(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function vc(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of mc)if(t in e)return;let n=t.filter(e=>hc.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=_c(t);else{let e=n[0],i=hc.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>_c([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,sc(e,r))}function yc(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):sc(i,s),sc(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())pc(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=/* @__PURE__ */ new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])vc(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}sc(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,Dn(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:Sc(t,`input`,e.processors),output:Sc(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function bc(e,t){let n=t??{seen:/* @__PURE__ */ new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return bc(r.element,n);if(r.type===`set`)return bc(r.valueType,n);if(r.type===`lazy`)return bc(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`||r.type===`catch`)return bc(r.innerType,n);if(r.type===`intersection`)return bc(r.left,n)||bc(r.right,n);if(r.type===`record`||r.type===`map`)return bc(r.keyType,n)||bc(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:bc(r.in,n)||bc(r.out,n);if(r.type===`object`){for(let e in r.shape)if(bc(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(bc(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(bc(e,n))return!0;return!!(r.rest&&bc(r.rest,n))}return!1}const xc=(e,t={})=>n=>{let r=cc({...n,processors:t});return uc(e,r),fc(r,e),yc(r,e)},Sc=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=cc({...i??{},target:a,io:t,processors:n});return uc(e,o),fc(o,e),yc(o,e)},Cc=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},wc=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},Tc=(e,t)=>{Cc(e,`minimum`,t),wc(e,`maximum`,t)},Ec=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},Dc=(e,t)=>{e.patterns??=/* @__PURE__ */ new Set,e.patterns.add(t)},Oc=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},kc=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},Ac=(e,t)=>Cc(e,`minimum`,t.minimum),jc=(e,t)=>wc(e,`maximum`,t.maximum),Mc=e=>(t,n)=>{kc(t,n.format);let[r,i]=e[n.format];Cc(t,`minimum`,r),wc(t,`maximum`,i)},Nc={greater_than:(e,t)=>Cc(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>wc(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>Ec(e,t.value),number_format:Mc(qn),bigint_format:Mc(Jn),min_length:Ac,max_length:jc,length_equals:(e,t)=>Tc(e,t.length),min_size:Ac,max_size:jc,size_equals:(e,t)=>Tc(e,t.size),string_format:(e,t)=>{kc(e,t.format),t.pattern&&Dc(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>Oc(e,t.mime)};function Pc(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)Nc[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&Cc(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&Cc(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&wc(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&wc(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&Ec(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&Oc(t,i.mime);for(let e of i.patterns??[])Dc(t,e);return t}const Fc={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Ic=/* @__PURE__ */ new Map([[Ua,Ti],[Ga,Ei]]),Lc=e=>Ic.get(e)??e,Rc=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=Pc(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Fc[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(Lc);e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},zc=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=Pc(e);i.type=u?`integer`:`number`;let d=typeof l==`number`&&l>=(a??-1/0),f=typeof c==`number`&&c<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o==`number`&&(i.maximum=o),s){let n=/* @__PURE__ */ new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):lc(e,t,i,r,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...o]=n;a!==void 0&&(i.multipleOf=a),o.length&&(i.allOf=[...i.allOf??[],...o.map(e=>({multipleOf:e}))])}},Bc=(e,t,n,r)=>{n.type=`boolean`},Vc=(e,t,n,r)=>{n.not={}},Hc=(e,t,n,r)=>{let i=e._zod.def,a=yn(i.entries);a.length===0?n.not={}:(a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a)},Uc=(e,t,n,r)=>{lc(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},Wc=(e,t,n,r)=>{lc(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},Gc=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=Pc(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=uc(a.element,t,{...r,path:[...r.path,`items`]})};function Kc(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?Kc(t.out):t.type===`catch`?Kc(t.innerType):e._zod.optin}const qc=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&lc(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)Dn(i.properties,e,uc(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?Kc(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=uc(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Jc=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>uc(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Yc=(e,t,n,r)=>{let i=e._zod.def,a=uc(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=uc(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)};function Xc(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let r=e.get(t)?.def;if(!r)return t;let i=Xc(e,r,n);return i===r?t:i}for(let r of[`anyOf`,`oneOf`]){let i=t[r];if(!Array.isArray(i))continue;let a=i.map(t=>Xc(e,t,n));a.some((e,t)=>e!==i[t])&&(t={...t,[r]:a})}let r=Array.isArray(t.type)?t.type:[t.type],i=!r.includes(`string`)&&r.some(e=>e===`number`||e===`integer`),a=t.enum??(t.const===void 0?void 0:[t.const]);if(!i&&!a?.some(e=>typeof e==`number`))return t;let{minimum:o,maximum:s,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:d,id:f,...p}=t;return p.enum?p.enum=p.enum.map(e=>typeof e==`number`?String(e):e):typeof p.const==`number`&&(p.const=String(p.const)),i&&(p.type=`string`,a||(p.pattern=(r.includes(`number`)?Li:Ii).source)),p}const Zc=/* @__PURE__ */ new WeakMap;function Qc(e){let t=/* @__PURE__ */ new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let n=/* @__PURE__ */ new Map;for(let r of Zc.get(e)??[]){let i=e.seen.get(r),a=(i?.def??i?.schema)?.propertyNames;if(!a||a===!0||n.has(a))continue;let o=Xc(t,a,/* @__PURE__ */ new Set);o!==a&&n.set(a,o)}if(n.size)for(let t of e.seen.values())for(let e of[t.schema,t.def]){let t=e&&n.get(e.propertyNames);t&&(e.propertyNames=t)}}const $c=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=Pc(o).patterns;if(a.mode===`loose`&&s&&s.size>0){let e=uc(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)Dn(i.patternProperties,Lc(t).source,e)}else{if(t.target===`draft-07`||t.target===`draft-2020-12`){i.propertyNames=uc(a.keyType,t,{...r,path:[...r.path,`propertyNames`]});let n=Zc.get(t);n||(n=[],Zc.set(t,n),t.deferred.push(()=>Qc(t))),n.push(e)}i.additionalProperties=uc(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]})}let c=o._zod.values,l=t.io===`input`&&Kc(a.valueType)!==void 0;if(c&&!a.partial&&!l){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e.map(String))}},el=(e,t,n,r)=>{let i=e._zod.def,a=uc(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},tl=(e,t,n,r)=>{let i=e._zod.def;uc(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},nl=Symbol();function rl(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(lc(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),nl):JSON.parse(o)}const il=(e,t,n,r)=>{let i=e._zod.def;uc(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=rl(i.defaultValue,e,t,n,r);o!==nl&&(n.default=o)},al=(e,t,n,r)=>{let i=e._zod.def;uc(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=rl(i.defaultValue,e,t,n,r);o!==nl&&(n._prefault=o)},ol=(e,t,n,r)=>{let i=e._zod.def;uc(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{lc(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},sl=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;uc(o,t,r);let s=t.seen.get(e);s.ref=o},cl=(e,t,n,r)=>{let i=e._zod.def;uc(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},ll=(e,t,n,r)=>{let i=e._zod.def;uc(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},ul=/* @__PURE__ */ new WeakSet([Object.prototype,Error.prototype]);function dl(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}const fl=/*@__PURE__*/ U(`ZodError`,(e,t)=>{Br.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);ul.has(n)||(ul.add(n),dl(n,`format`,e=>t=>Ur(e,t)),dl(n,`flatten`,e=>t=>Hr(e,t)),dl(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,xn,2)}),dl(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,xn,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),pl=/* @__PURE__ */ Gr(fl),ml=/* @__PURE__ */ Kr(fl),hl=/* @__PURE__ */ qr(fl),gl=/* @__PURE__ */ Yr(fl),_l=/* @__PURE__ */ ti(fl),vl=/* @__PURE__ */ ni(fl),yl=/* @__PURE__ */ ri(fl),bl=/* @__PURE__ */ ii(fl),xl=/* @__PURE__ */ ai(fl),Sl=/* @__PURE__ */ oi(fl),Cl=/* @__PURE__ */ si(fl),wl=/* @__PURE__ */ ci(fl);function Tl(){Nr.localeError||Pr($o())}function El(){Nr.memoizer||Pr({memoizer:Xo()})}const Dl=/*@__PURE__*/ U(`ZodType`,(e,t)=>(Tl(),sa.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(Pn(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return Wn(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Wu(e,t))},superRefine(e,t){return this.check(Gu(e,t))},overwrite(e){return this.check(/* @__PURE__ */ Zs(e))},optional(){return Eu(this)},exactOptional(){return Ou(this)},nullable(){return Au(this)},nullish(){return Eu(Au(this))},nonoptional(e){return Iu(this,e)},array(){return du(this)},or(e){return gu([this,e])},and(e){return vu(this,e)},transform(e){return Bu(this,wu(e))},default(e){return Mu(this,e)},prefault(e){return Pu(this,e)},catch(e){return Ru(this,e)},pipe(e){return Bu(this,e)},readonly(){return Hu(this)},describe(e){let t=this.clone();return rs.add(t,{description:e}),t},meta(...e){if(e.length===0)return rs.get(this);let t=this.clone();return rs.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return vr(this,`~standard`,{...ua(this),jsonSchema:{input:Sc(this,`input`),output:Sc(this,`output`)}})},set"~standard"(e){_r(this,`~standard`,e)},parse:function e(t,n){return pl(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await ml(this,t,n,{callee:e})},safeParse(e,t){return hl(this,e,t)},async safeParseAsync(e,t){return gl(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){_r(this,`spa`,e)},validate(e,t){return Qr(this,e,t)},validateAsync(e,t){return ei(this,e,t)},encode:function e(t,n){return _l(this,t,n,{callee:e})},decode:function e(t,n){return vl(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await yl(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await bl(this,t,n,{callee:e})},safeEncode(e,t){return xl(this,e,t)},safeDecode(e,t){return Sl(this,e,t)},async safeEncodeAsync(e,t){return Cl(this,e,t)},async safeDecodeAsync(e,t){return wl(this,e,t)},toJSONSchema(e){return xc(this,{})(e)},get description(){return rs.get(this)?.description},get _def(){return this._zod.def}}),Ol=/*@__PURE__*/ U(`_ZodString`,(e,t)=>{da.init(e,t),Dl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Rc(e,t,n,r)},/*@__PURE__*/ yr({format:e=>Pc(e).format??null,minLength:e=>Pc(e).minimum??null,maxLength:e=>Pc(e).maximum??null},{regex(...e){return this.check(/* @__PURE__ */ Gs(...e))},includes(...e){return this.check(/* @__PURE__ */ Js(...e))},startsWith(...e){return this.check(/* @__PURE__ */ Ys(...e))},endsWith(...e){return this.check(/* @__PURE__ */ Xs(...e))},min(...e){return this.check(/* @__PURE__ */ Us(...e))},max(...e){return this.check(/* @__PURE__ */ Hs(...e))},length(...e){return this.check(/* @__PURE__ */ Ws(...e))},nonempty(...e){return this.check(/* @__PURE__ */ Us(1,...e))},lowercase(e){return this.check(/* @__PURE__ */ Ks(e))},uppercase(e){return this.check(/* @__PURE__ */ qs(e))},trim(){return this.check(/* @__PURE__ */ $s())},normalize(...e){return this.check(/* @__PURE__ */ Qs(...e))},toLowerCase(){return this.check(/* @__PURE__ */ ec())},toUpperCase(){return this.check(/* @__PURE__ */ tc())},slugify(){return this.check(/* @__PURE__ */ nc())}})),kl=/*@__PURE__*/ U(`ZodString`,(e,t)=>{da.init(e,t),Ol.init(e,t)},{email(e){return this.check(/* @__PURE__ */ os(Il,e))},url(e){return this.check(/* @__PURE__ */ fs(zl,e))},jwt(e){return this.check(/* @__PURE__ */ Ds(eu,e))},emoji(e){return this.check(/* @__PURE__ */ ps(Bl,e))},guid(e){return this.check(/* @__PURE__ */ ss(Ll,e))},uuid(e){return this.check(/* @__PURE__ */ cs(Rl,e))},uuidv4(e){return this.check(/* @__PURE__ */ ls(Rl,e))},uuidv6(e){return this.check(/* @__PURE__ */ us(Rl,e))},uuidv7(e){return this.check(/* @__PURE__ */ ds(Rl,e))},nanoid(e){return this.check(/* @__PURE__ */ ms(Vl,e))},cuid(e){return this.check(/* @__PURE__ */ hs(Hl,e))},cuid2(e){return this.check(/* @__PURE__ */ gs(Ul,e))},ulid(e){return this.check(/* @__PURE__ */ _s(Wl,e))},base64(e){return this.check(/* @__PURE__ */ ws(Zl,e))},base64url(e){return this.check(/* @__PURE__ */ Ts(Ql,e))},xid(e){return this.check(/* @__PURE__ */ vs(Gl,e))},ksuid(e){return this.check(/* @__PURE__ */ ys(Kl,e))},ipv4(e){return this.check(/* @__PURE__ */ bs(ql,e))},ipv6(e){return this.check(/* @__PURE__ */ xs(Jl,e))},cidrv4(e){return this.check(/* @__PURE__ */ Ss(Yl,e))},cidrv6(e){return this.check(/* @__PURE__ */ Cs(Xl,e))},e164(e){return this.check(/* @__PURE__ */ Es($l,e))},datetime(e){return this.check(/* @__PURE__ */ Os(Ml,e))},date(e){return this.check(/* @__PURE__ */ ks(Nl,e))},time(e){return this.check(/* @__PURE__ */ As(Pl,e))},duration(e){return this.check(/* @__PURE__ */ js(Fl,e))}});function Al(e){return/* @__PURE__ */ as(kl,e)}const jl=/*@__PURE__*/ U(`ZodStringFormat`,(e,t)=>{fa.init(e,t),Ol.init(e,t)}),Ml=/*@__PURE__*/ U(`ZodISODateTime`,(e,t)=>{ja.init(e,t),jl.init(e,t)}),Nl=/*@__PURE__*/ U(`ZodISODate`,(e,t)=>{Ma.init(e,t),jl.init(e,t)}),Pl=/*@__PURE__*/ U(`ZodISOTime`,(e,t)=>{Na.init(e,t),jl.init(e,t)}),Fl=/*@__PURE__*/ U(`ZodISODuration`,(e,t)=>{Pa.init(e,t),jl.init(e,t)}),Il=/*@__PURE__*/ U(`ZodEmail`,(e,t)=>{ha.init(e,t),jl.init(e,t)}),Ll=/*@__PURE__*/ U(`ZodGUID`,(e,t)=>{pa.init(e,t),jl.init(e,t)}),Rl=/*@__PURE__*/ U(`ZodUUID`,(e,t)=>{ma.init(e,t),jl.init(e,t)}),zl=/*@__PURE__*/ U(`ZodURL`,(e,t)=>{Ca.init(e,t),jl.init(e,t)}),Bl=/*@__PURE__*/ U(`ZodEmoji`,(e,t)=>{wa.init(e,t),jl.init(e,t)}),Vl=/*@__PURE__*/ U(`ZodNanoID`,(e,t)=>{Ta.init(e,t),jl.init(e,t)}),Hl=/*@__PURE__*/ U(`ZodCUID`,(e,t)=>{Ea.init(e,t),jl.init(e,t)}),Ul=/*@__PURE__*/ U(`ZodCUID2`,(e,t)=>{Da.init(e,t),jl.init(e,t)}),Wl=/*@__PURE__*/ U(`ZodULID`,(e,t)=>{Oa.init(e,t),jl.init(e,t)}),Gl=/*@__PURE__*/ U(`ZodXID`,(e,t)=>{ka.init(e,t),jl.init(e,t)}),Kl=/*@__PURE__*/ U(`ZodKSUID`,(e,t)=>{Aa.init(e,t),jl.init(e,t)}),ql=/*@__PURE__*/ U(`ZodIPv4`,(e,t)=>{Fa.init(e,t),jl.init(e,t)}),Jl=/*@__PURE__*/ U(`ZodIPv6`,(e,t)=>{Ra.init(e,t),jl.init(e,t)}),Yl=/*@__PURE__*/ U(`ZodCIDRv4`,(e,t)=>{za.init(e,t),jl.init(e,t)}),Xl=/*@__PURE__*/ U(`ZodCIDRv6`,(e,t)=>{Va.init(e,t),jl.init(e,t)}),Zl=/*@__PURE__*/ U(`ZodBase64`,(e,t)=>{Wa.init(e,t),jl.init(e,t)}),Ql=/*@__PURE__*/ U(`ZodBase64URL`,(e,t)=>{qa.init(e,t),jl.init(e,t)}),$l=/*@__PURE__*/ U(`ZodE164`,(e,t)=>{Ja.init(e,t),jl.init(e,t)}),eu=/*@__PURE__*/ U(`ZodJWT`,(e,t)=>{Xa.init(e,t),jl.init(e,t)}),tu=/*@__PURE__*/ U(`ZodNumber`,(e,t)=>{Za.init(e,t),Dl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zc(e,t,n,r),e.isFinite=!0},/*@__PURE__*/ yr({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=Pc(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=Pc(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=Pc(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>Pc(e).format??null},{gt(e,t){return this.check(/* @__PURE__ */ zs(e,t))},gte(e,t){return this.check(/* @__PURE__ */ Bs(e,t))},min(e,t){return this.check(/* @__PURE__ */ Bs(e,t))},lt(e,t){return this.check(/* @__PURE__ */ Ls(e,t))},lte(e,t){return this.check(/* @__PURE__ */ Rs(e,t))},max(e,t){return this.check(/* @__PURE__ */ Rs(e,t))},int(e){return this.check(ru(e))},safe(e){return this.check(ru(e))},positive(e){return this.check(/* @__PURE__ */ zs(0,e))},nonnegative(e){return this.check(/* @__PURE__ */ Bs(0,e))},negative(e){return this.check(/* @__PURE__ */ Ls(0,e))},nonpositive(e){return this.check(/* @__PURE__ */ Rs(0,e))},multipleOf(e,t){return this.check(/* @__PURE__ */ Vs(e,t))},step(e,t){return this.check(/* @__PURE__ */ Vs(e,t))},finite(){return this}})),nu=/*@__PURE__*/ U(`ZodNumberFormat`,(e,t)=>{Qa.init(e,t),tu.init(e,t)});function ru(e){return/* @__PURE__ */ Ns(nu,e)}const iu=/*@__PURE__*/ U(`ZodBoolean`,(e,t)=>{$a.init(e,t),Dl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Bc(e,t,n,r)});function au(e){return/* @__PURE__ */ Ps(iu,e)}const ou=/*@__PURE__*/ U(`ZodUnknown`,(e,t)=>{eo.init(e,t),Dl.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function su(){return/* @__PURE__ */ Fs(ou)}const cu=/*@__PURE__*/ U(`ZodNever`,(e,t)=>{to.init(e,t),Dl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vc(e,t,n,r)});function lu(e){return/* @__PURE__ */ Is(cu,e)}const uu=/*@__PURE__*/ U(`ZodArray`,(e,t)=>{El(),ao.init(e,t),Dl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Gc(e,t,n,r),e.element=t.element},{min(e,t){return this.check(/* @__PURE__ */ Us(e,t))},nonempty(e){return this.check(/* @__PURE__ */ Us(1,e))},max(e,t){return this.check(/* @__PURE__ */ Hs(e,t))},length(e,t){return this.check(/* @__PURE__ */ Ws(e,t))},unwrap(){return this.element}});function du(e,t){return/* @__PURE__ */ rc(uu,e,t)}const fu=/*@__PURE__*/ U(`ZodObject`,(e,t)=>{El(),fo.init(e,t),Dl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qc(e,t,n,r),Tr(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return Su(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(Pn(this._zod.def,{catchall:e}))},passthrough(){return this.clone(Pn(this._zod.def,{catchall:su()}))},loose(){return this.clone(Pn(this._zod.def,{catchall:su()}))},strict(){return this.clone(Pn(this._zod.def,{catchall:lu()}))},strip(){return this.clone(Pn(this._zod.def,{catchall:void 0}))},extend(e){return Qn(this,e)},safeExtend(e){return er(this,e)},merge(e){return tr(this,e)},pick(e){return Yn(this,e)},omit(e){return Zn(this,e)},partial(...e){return nr(Tu,this,e[0])},exactPartial(...e){return nr(Du,this,e[0],`exactPartial`)},required(...e){return rr(Fu,this,e[0])}});function pu(e,t){let n={type:`object`,shape:e??{},...V(t)};return new fu(n)}function mu(e,t){return new fu({type:`object`,shape:e,catchall:su(),...V(t)})}const hu=/*@__PURE__*/ U(`ZodUnion`,(e,t)=>{mo.init(e,t),Dl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Jc(e,t,n,r),e.options=t.options});function gu(e,t){return new hu({type:`union`,options:e,...V(t)})}const _u=/*@__PURE__*/ U(`ZodIntersection`,(e,t)=>{ho.init(e,t),Dl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yc(e,t,n,r)});function vu(e,t){return new _u({type:`intersection`,left:e,right:t})}const yu=/*@__PURE__*/ U(`ZodRecord`,(e,t)=>{El(),vo.init(e,t),Dl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$c(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function bu(e,t,n){return!t||!t._zod?new yu({type:`record`,keyType:Al(),valueType:e,...V(t)}):new yu({type:`record`,keyType:e,valueType:t,...V(n)})}const xu=/*@__PURE__*/ U(`ZodEnum`,(e,t)=>{yo.init(e,t),Dl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Hc(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new xu({...t,checks:[],...V(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new xu({...t,checks:[],...V(r),entries:i})}});function Su(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new xu({type:`enum`,entries:n,...V(t)})}const Cu=/*@__PURE__*/ U(`ZodTransform`,(e,t)=>{El(),bo.init(e,t),Dl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Wc(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Mr(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(hr(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(hr(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function wu(e){return new Cu({type:`transform`,transform:e})}const Tu=/*@__PURE__*/ U(`ZodOptional`,(e,t)=>{So.init(e,t),Dl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ll(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Eu(e){return new Tu({type:`optional`,innerType:e})}const Du=/*@__PURE__*/ U(`ZodExactOptional`,(e,t)=>{Co.init(e,t),Dl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ll(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ou(e){return new Du({type:`optional`,innerType:e})}const ku=/*@__PURE__*/ U(`ZodNullable`,(e,t)=>{wo.init(e,t),Dl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>el(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Au(e){return new ku({type:`nullable`,innerType:e})}const ju=/*@__PURE__*/ U(`ZodDefault`,(e,t)=>{To.init(e,t),Dl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>il(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Mu(e,t){return new ju({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Vn(t)}})}const Nu=/*@__PURE__*/ U(`ZodPrefault`,(e,t)=>{Do.init(e,t),Dl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>al(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Pu(e,t){return new Nu({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Vn(t)}})}const Fu=/*@__PURE__*/ U(`ZodNonOptional`,(e,t)=>{Oo.init(e,t),Dl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>tl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Iu(e,t){return new Fu({type:`nonoptional`,innerType:e,...V(t)})}const Lu=/*@__PURE__*/ U(`ZodCatch`,(e,t)=>{jo.init(e,t),Dl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ol(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Ru(e,t){return new Lu({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:Er(t)})}const zu=/*@__PURE__*/ U(`ZodPipe`,(e,t)=>{Mo.init(e,t),Dl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>sl(e,t,n,r),e.in=t.in,e.out=t.out});function Bu(e,t){return new zu({type:`pipe`,in:e,out:t})}const Vu=/*@__PURE__*/ U(`ZodReadonly`,(e,t)=>{Po.init(e,t),Dl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Hu(e){return new Vu({type:`readonly`,innerType:e})}const Uu=/*@__PURE__*/ U(`ZodCustom`,(e,t)=>{Io.init(e,t),Dl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Uc(e,t,n,r)});function Wu(e,t={}){return/* @__PURE__ */ ic(Uu,e,t)}function Gu(e,t){return/* @__PURE__ */ ac(e,t)}function Ku(e){return/* @__PURE__ */ Ms(tu,e)}let qu;function Ju(){return qu??=en(`@longzai-intelligence-cli/core/provider`),qu}const Yu={red:e=>e,green:e=>e,yellow:e=>e,blue:e=>e,cyan:e=>e,magenta:e=>e,gray:e=>e,bold:e=>e,dim:e=>e};let Xu={select:async(e,t)=>t[0]?.value??``,textInput:async(e,t)=>t?.defaultValue??``,confirm:async(e,t)=>t?.defaultValue??!1,spinner:()=>({start:e=>Ju().info(e),stop:e=>Ju().info(e)}),note:(e,t)=>{t?Ju().info(`${t}: ${e}`):Ju().info(e)},log:{info:e=>Ju().info(e),success:e=>Ju().info(e),warn:e=>Ju().warn(e),error:e=>Ju().error(e),step:e=>Ju().info(e)}},Zu=Yu;function Qu(e){Xu=e}function $u(e){Zu=e}function ed(){return Xu}function td(){return Zu}const nd=()=>`0.0.7`;function rd(e){let t=e.version??nd();e.interaction&&Qu(e.interaction),e.color&&$u(e.color);let n=new hn;return n.name(e.name).version(t,`-v, --version`,`输出 ${e.name} 的版本号`),e.description&&n.description(e.description),n}let id;function ad(){return id??=en(`@longzai-intelligence-cli/core/define-command`),id}function od(e,t){let n=e.commands.find(e=>e.name()===t);return n===void 0?e.command(t):n}function sd(e,t){if(t.length===1){let n=t[0];if(n===void 0)throw Error(`defineCommand: segments 为空,无法解析命令名`);return e.command(n)}let[n,...r]=t;if(n===void 0)throw Error(`defineCommand: segments 首段为空,无法解析父命令名`);let i=r.pop();if(i===void 0)throw Error(`defineCommand: segments 末段为空,无法解析子命令名`);let a=od(e,n);for(let e of r)a=od(a,e);return a.command(i)}function cd(e,t){let n=sd(e,t.name.split(` `).filter(e=>e.length>0));t.description&&n.description(t.description);for(let e of t.arguments??[])e.description?n.argument(e.signature,e.description):n.argument(e.signature);for(let e of t.options??[])e.defaultValue===void 0?n.option(e.flags,e.description??``):n.option(e.flags,e.description??``,e.defaultValue);n.action(async(...e)=>{let n=e[e.length-1];if(!(n instanceof hn))return;let r=n.opts(),i=n.args,a=t.schema.safeParse(r);if(!a.success){let e=a.error.issues.map(e=>e.message).join(`, `);ad().error(td().red(`参数校验失败: ${e}`)),ed().log.error(`参数校验失败: ${e}`),process.exit(1)}await t.action(a.data,i)})}var ld=/* @__PURE__ */ w(import.meta.url);function ud(e){let t=y(e);return t.length>1&&t[t.length-1]===C&&(t=t.substring(0,t.length-1)),t}const dd=/[\\/]/g;function fd(e,t){return e.replace(dd,t)}const pd=/^[a-z]:[\\/]$/i;function md(e){return e===`/`||pd.test(e)}function hd(e,t){let{resolvePaths:n,normalizePath:r,pathSeparator:i}=t,a=process.platform===`win32`&&e.includes(`/`)||e.startsWith(`.`);return n&&(e=S(e)),(r||a)&&(e=ud(e)),e===`.`?``:fd(e[e.length-1]===i?e:e+i,i)}function gd(e,t){return t+e}function _d(e,t){return function(n,r){return r.startsWith(e)?r.slice(e.length)+n:fd(x(e,r),t.pathSeparator)+t.pathSeparator+n}}function vd(e){return e}function yd(e,t,n){return t+e+n}function bd(e,t){let{relativePaths:n,includeBasePath:r}=t;return n&&e?_d(e,t):r?gd:vd}function xd(e){return function(t,n){n.push(t.substring(e.length)||`.`)}}function Sd(e){return function(t,n,r){let i=t.substring(e.length)||`.`;r.every(e=>e(i,!0))&&n.push(i)}}const Cd=(e,t)=>{t.push(e||`.`)},wd=(e,t,n)=>{let r=e||`.`;n.every(e=>e(r,!0))&&t.push(r)},Td=()=>{};function Ed(e,t){let{includeDirs:n,filters:r,relativePaths:i}=t;return n?i?r&&r.length?Sd(e):xd(e):r&&r.length?wd:Cd:Td}const Dd=(e,t,n,r)=>{r.every(t=>t(e,!1))&&n.files++},Od=(e,t,n,r)=>{r.every(t=>t(e,!1))&&t.push(e)},kd=(e,t,n,r)=>{n.files++},Ad=(e,t)=>{t.push(e)},jd=()=>{};function Md(e){let{excludeFiles:t,filters:n,onlyCounts:r}=e;return t?jd:n&&n.length?r?Dd:Od:r?kd:Ad}const Nd=e=>e,Pd=()=>[``].slice(0,0);function Fd(e){return e.group?Pd:Nd}const Id=(e,t,n)=>{e.push({directory:t,files:n,dir:t})},Ld=()=>{};function Rd(e){return e.group?Id:Ld}const zd=function(e,t,n){let{queue:r,fs:i,options:{suppressErrors:a}}=t;r.enqueue(),i.realpath(e,(o,s)=>{if(o)return r.dequeue(a?null:o,t);i.stat(s,(i,o)=>{if(i)return r.dequeue(a?null:i,t);if(o.isDirectory()&&Hd(e,s,t))return r.dequeue(null,t);n(o,s),r.dequeue(null,t)})})},Bd=function(e,t,n){let{queue:r,fs:i,options:{suppressErrors:a}}=t;r.enqueue();try{let r=i.realpathSync(e),a=i.statSync(r);if(a.isDirectory()&&Hd(e,r,t))return;n(a,r)}catch(e){if(!a)throw e}};function Vd(e,t){return!e.resolveSymlinks||e.excludeSymlinks?null:t?Bd:zd}function Hd(e,t,n){if(n.options.useRealPaths)return Ud(t,n);let r=_(e),i=1;for(;r!==n.root&&i<2;){let e=n.symlinks.get(r);e&&(e===t||e.startsWith(t)||t.startsWith(e))?i++:r=_(r)}return n.symlinks.set(e,t),i>1}function Ud(e,t){return t.visited.includes(e+t.options.pathSeparator)}const Wd=e=>e.counts,Gd=e=>e.groups,Kd=e=>e.paths,qd=e=>e.paths.slice(0,e.options.maxFiles),Jd=(e,t,n)=>(Qd(t,n,e.counts,e.options.suppressErrors),null),Yd=(e,t,n)=>(Qd(t,n,e.paths,e.options.suppressErrors),null),Xd=(e,t,n)=>(Qd(t,n,e.paths.slice(0,e.options.maxFiles),e.options.suppressErrors),null),Zd=(e,t,n)=>(Qd(t,n,e.groups,e.options.suppressErrors),null);function Qd(e,t,n,r){t(e&&!r?e:null,n)}function $d(e,t){let{onlyCounts:n,group:r,maxFiles:i}=e;return n?t?Wd:Jd:r?t?Gd:Zd:i?t?qd:Xd:t?Kd:Yd}const ef={withFileTypes:!0},tf=(e,t,n,r,i)=>{if(e.queue.enqueue(),r<0)return e.queue.dequeue(null,e);let{fs:a}=e;e.visited.push(t),e.counts.directories++,a.readdir(t||`.`,ef,(t,a=[])=>{i(a,n,r),e.queue.dequeue(e.options.suppressErrors?null:t,e)})},nf=(e,t,n,r,i)=>{let{fs:a}=e;if(r<0)return;e.visited.push(t),e.counts.directories++;let o=[];try{o=a.readdirSync(t||`.`,ef)}catch(t){if(!e.options.suppressErrors)throw t}i(o,n,r)};function rf(e){return e?nf:tf}var af=class{count=0;constructor(e){this.onQueueEmpty=e}enqueue(){return this.count++,this.count}dequeue(e,t){this.onQueueEmpty&&(--this.count<=0||e)&&(this.onQueueEmpty(e,t),e&&(t.controller.abort(),this.onQueueEmpty=void 0))}},of=class{_files=0;_directories=0;set files(e){this._files=e}get files(){return this._files}set directories(e){this._directories=e}get directories(){return this._directories}
163
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0])a(n);else{if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}(e.metadataRegistry.get(n[0])?.id||r.cycle||r.count>1&&e.reused===`ref`)&&a(n)}}e.external&&(e.sharedDefsExtractedFor=e.external)}function pc(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;pc(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}const mc=/* @__PURE__ */ new Set([`type`,`properties`,`required`,`additionalProperties`]),hc=[`oneOf`,`anyOf`];function gc(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function _c(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!mc.has(e))return null;t.push(n)}let n={},r=/* @__PURE__ */ new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??gc(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}Dn(n,r,e.length===1?e[0]:_c(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=gc(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function vc(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of mc)if(t in e)return;let n=t.filter(e=>hc.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=_c(t);else{let e=n[0],i=hc.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>_c([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,sc(e,r))}function yc(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):sc(i,s),sc(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())pc(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=/* @__PURE__ */ new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])vc(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}sc(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,Dn(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:Sc(t,`input`,e.processors),output:Sc(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function bc(e,t){let n=t??{seen:/* @__PURE__ */ new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return bc(r.element,n);if(r.type===`set`)return bc(r.valueType,n);if(r.type===`lazy`)return bc(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`||r.type===`catch`)return bc(r.innerType,n);if(r.type===`intersection`)return bc(r.left,n)||bc(r.right,n);if(r.type===`record`||r.type===`map`)return bc(r.keyType,n)||bc(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:bc(r.in,n)||bc(r.out,n);if(r.type===`object`){for(let e in r.shape)if(bc(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(bc(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(bc(e,n))return!0;return!!(r.rest&&bc(r.rest,n))}return!1}const xc=(e,t={})=>n=>{let r=cc({...n,processors:t});return uc(e,r),fc(r,e),yc(r,e)},Sc=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=cc({...i??{},target:a,io:t,processors:n});return uc(e,o),fc(o,e),yc(o,e)},Cc=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},wc=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},Tc=(e,t)=>{Cc(e,`minimum`,t),wc(e,`maximum`,t)},Ec=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},Dc=(e,t)=>{e.patterns??=/* @__PURE__ */ new Set,e.patterns.add(t)},Oc=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},kc=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},Ac=(e,t)=>Cc(e,`minimum`,t.minimum),jc=(e,t)=>wc(e,`maximum`,t.maximum),Mc=e=>(t,n)=>{kc(t,n.format);let[r,i]=e[n.format];Cc(t,`minimum`,r),wc(t,`maximum`,i)},Nc={greater_than:(e,t)=>Cc(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>wc(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>Ec(e,t.value),number_format:Mc(qn),bigint_format:Mc(Jn),min_length:Ac,max_length:jc,length_equals:(e,t)=>Tc(e,t.length),min_size:Ac,max_size:jc,size_equals:(e,t)=>Tc(e,t.size),string_format:(e,t)=>{kc(e,t.format),t.pattern&&Dc(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>Oc(e,t.mime)};function Pc(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)Nc[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&Cc(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&Cc(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&wc(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&wc(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&Ec(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&Oc(t,i.mime);for(let e of i.patterns??[])Dc(t,e);return t}const Fc={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Ic=/* @__PURE__ */ new Map([[Ua,Ti],[Ga,Ei]]),Lc=e=>Ic.get(e)??e,Rc=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=Pc(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Fc[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(Lc);e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},zc=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=Pc(e);i.type=u?`integer`:`number`;let d=typeof l==`number`&&l>=(a??-1/0),f=typeof c==`number`&&c<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o==`number`&&(i.maximum=o),s){let n=/* @__PURE__ */ new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):lc(e,t,i,r,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...o]=n;a!==void 0&&(i.multipleOf=a),o.length&&(i.allOf=[...i.allOf??[],...o.map(e=>({multipleOf:e}))])}},Bc=(e,t,n,r)=>{n.type=`boolean`},Vc=(e,t,n,r)=>{n.not={}},Hc=(e,t,n,r)=>{let i=e._zod.def,a=yn(i.entries);a.length===0?n.not={}:(a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a)},Uc=(e,t,n,r)=>{lc(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},Wc=(e,t,n,r)=>{lc(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},Gc=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=Pc(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=uc(a.element,t,{...r,path:[...r.path,`items`]})};function Kc(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?Kc(t.out):t.type===`catch`?Kc(t.innerType):e._zod.optin}const qc=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&lc(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)Dn(i.properties,e,uc(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?Kc(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=uc(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Jc=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>uc(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Yc=(e,t,n,r)=>{let i=e._zod.def,a=uc(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=uc(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)};function Xc(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let r=e.get(t)?.def;if(!r)return t;let i=Xc(e,r,n);return i===r?t:i}for(let r of[`anyOf`,`oneOf`]){let i=t[r];if(!Array.isArray(i))continue;let a=i.map(t=>Xc(e,t,n));a.some((e,t)=>e!==i[t])&&(t={...t,[r]:a})}let r=Array.isArray(t.type)?t.type:[t.type],i=!r.includes(`string`)&&r.some(e=>e===`number`||e===`integer`),a=t.enum??(t.const===void 0?void 0:[t.const]);if(!i&&!a?.some(e=>typeof e==`number`))return t;let{minimum:o,maximum:s,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:d,id:f,...p}=t;return p.enum?p.enum=p.enum.map(e=>typeof e==`number`?String(e):e):typeof p.const==`number`&&(p.const=String(p.const)),i&&(p.type=`string`,a||(p.pattern=(r.includes(`number`)?Li:Ii).source)),p}const Zc=/* @__PURE__ */ new WeakMap;function Qc(e){let t=/* @__PURE__ */ new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let n=/* @__PURE__ */ new Map;for(let r of Zc.get(e)??[]){let i=e.seen.get(r),a=(i?.def??i?.schema)?.propertyNames;if(!a||a===!0||n.has(a))continue;let o=Xc(t,a,/* @__PURE__ */ new Set);o!==a&&n.set(a,o)}if(n.size)for(let t of e.seen.values())for(let e of[t.schema,t.def]){let t=e&&n.get(e.propertyNames);t&&(e.propertyNames=t)}}const $c=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=Pc(o).patterns;if(a.mode===`loose`&&s&&s.size>0){let e=uc(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)Dn(i.patternProperties,Lc(t).source,e)}else{if(t.target===`draft-07`||t.target===`draft-2020-12`){i.propertyNames=uc(a.keyType,t,{...r,path:[...r.path,`propertyNames`]});let n=Zc.get(t);n||(n=[],Zc.set(t,n),t.deferred.push(()=>Qc(t))),n.push(e)}i.additionalProperties=uc(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]})}let c=o._zod.values,l=t.io===`input`&&Kc(a.valueType)!==void 0;if(c&&!a.partial&&!l){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e.map(String))}},el=(e,t,n,r)=>{let i=e._zod.def,a=uc(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},tl=(e,t,n,r)=>{let i=e._zod.def;uc(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},nl=Symbol();function rl(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(lc(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),nl):JSON.parse(o)}const il=(e,t,n,r)=>{let i=e._zod.def;uc(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=rl(i.defaultValue,e,t,n,r);o!==nl&&(n.default=o)},al=(e,t,n,r)=>{let i=e._zod.def;uc(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=rl(i.defaultValue,e,t,n,r);o!==nl&&(n._prefault=o)},ol=(e,t,n,r)=>{let i=e._zod.def;uc(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{lc(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},sl=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;uc(o,t,r);let s=t.seen.get(e);s.ref=o},cl=(e,t,n,r)=>{let i=e._zod.def;uc(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},ll=(e,t,n,r)=>{let i=e._zod.def;uc(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},ul=/* @__PURE__ */ new WeakSet([Object.prototype,Error.prototype]);function dl(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}const fl=/*@__PURE__*/ U(`ZodError`,(e,t)=>{Br.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);ul.has(n)||(ul.add(n),dl(n,`format`,e=>t=>Ur(e,t)),dl(n,`flatten`,e=>t=>Hr(e,t)),dl(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,xn,2)}),dl(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,xn,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),pl=/* @__PURE__ */ Gr(fl),ml=/* @__PURE__ */ Kr(fl),hl=/* @__PURE__ */ qr(fl),gl=/* @__PURE__ */ Yr(fl),_l=/* @__PURE__ */ ti(fl),vl=/* @__PURE__ */ ni(fl),yl=/* @__PURE__ */ ri(fl),bl=/* @__PURE__ */ ii(fl),xl=/* @__PURE__ */ ai(fl),Sl=/* @__PURE__ */ oi(fl),Cl=/* @__PURE__ */ si(fl),wl=/* @__PURE__ */ ci(fl);function Tl(){Nr.localeError||Pr($o())}function El(){Nr.memoizer||Pr({memoizer:Xo()})}const Dl=/*@__PURE__*/ U(`ZodType`,(e,t)=>(Tl(),sa.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(Pn(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return Wn(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Wu(e,t))},superRefine(e,t){return this.check(Gu(e,t))},overwrite(e){return this.check(/* @__PURE__ */ Zs(e))},optional(){return Eu(this)},exactOptional(){return Ou(this)},nullable(){return Au(this)},nullish(){return Eu(Au(this))},nonoptional(e){return Iu(this,e)},array(){return du(this)},or(e){return gu([this,e])},and(e){return vu(this,e)},transform(e){return Bu(this,wu(e))},default(e){return Mu(this,e)},prefault(e){return Pu(this,e)},catch(e){return Ru(this,e)},pipe(e){return Bu(this,e)},readonly(){return Hu(this)},describe(e){let t=this.clone();return rs.add(t,{description:e}),t},meta(...e){if(e.length===0)return rs.get(this);let t=this.clone();return rs.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return vr(this,`~standard`,{...ua(this),jsonSchema:{input:Sc(this,`input`),output:Sc(this,`output`)}})},set"~standard"(e){_r(this,`~standard`,e)},parse:function e(t,n){return pl(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await ml(this,t,n,{callee:e})},safeParse(e,t){return hl(this,e,t)},async safeParseAsync(e,t){return gl(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){_r(this,`spa`,e)},validate(e,t){return Qr(this,e,t)},validateAsync(e,t){return ei(this,e,t)},encode:function e(t,n){return _l(this,t,n,{callee:e})},decode:function e(t,n){return vl(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await yl(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await bl(this,t,n,{callee:e})},safeEncode(e,t){return xl(this,e,t)},safeDecode(e,t){return Sl(this,e,t)},async safeEncodeAsync(e,t){return Cl(this,e,t)},async safeDecodeAsync(e,t){return wl(this,e,t)},toJSONSchema(e){return xc(this,{})(e)},get description(){return rs.get(this)?.description},get _def(){return this._zod.def}}),Ol=/*@__PURE__*/ U(`_ZodString`,(e,t)=>{da.init(e,t),Dl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Rc(e,t,n,r)},/*@__PURE__*/ yr({format:e=>Pc(e).format??null,minLength:e=>Pc(e).minimum??null,maxLength:e=>Pc(e).maximum??null},{regex(...e){return this.check(/* @__PURE__ */ Gs(...e))},includes(...e){return this.check(/* @__PURE__ */ Js(...e))},startsWith(...e){return this.check(/* @__PURE__ */ Ys(...e))},endsWith(...e){return this.check(/* @__PURE__ */ Xs(...e))},min(...e){return this.check(/* @__PURE__ */ Us(...e))},max(...e){return this.check(/* @__PURE__ */ Hs(...e))},length(...e){return this.check(/* @__PURE__ */ Ws(...e))},nonempty(...e){return this.check(/* @__PURE__ */ Us(1,...e))},lowercase(e){return this.check(/* @__PURE__ */ Ks(e))},uppercase(e){return this.check(/* @__PURE__ */ qs(e))},trim(){return this.check(/* @__PURE__ */ $s())},normalize(...e){return this.check(/* @__PURE__ */ Qs(...e))},toLowerCase(){return this.check(/* @__PURE__ */ ec())},toUpperCase(){return this.check(/* @__PURE__ */ tc())},slugify(){return this.check(/* @__PURE__ */ nc())}})),kl=/*@__PURE__*/ U(`ZodString`,(e,t)=>{da.init(e,t),Ol.init(e,t)},{email(e){return this.check(/* @__PURE__ */ os(Il,e))},url(e){return this.check(/* @__PURE__ */ fs(zl,e))},jwt(e){return this.check(/* @__PURE__ */ Ds(eu,e))},emoji(e){return this.check(/* @__PURE__ */ ps(Bl,e))},guid(e){return this.check(/* @__PURE__ */ ss(Ll,e))},uuid(e){return this.check(/* @__PURE__ */ cs(Rl,e))},uuidv4(e){return this.check(/* @__PURE__ */ ls(Rl,e))},uuidv6(e){return this.check(/* @__PURE__ */ us(Rl,e))},uuidv7(e){return this.check(/* @__PURE__ */ ds(Rl,e))},nanoid(e){return this.check(/* @__PURE__ */ ms(Vl,e))},cuid(e){return this.check(/* @__PURE__ */ hs(Hl,e))},cuid2(e){return this.check(/* @__PURE__ */ gs(Ul,e))},ulid(e){return this.check(/* @__PURE__ */ _s(Wl,e))},base64(e){return this.check(/* @__PURE__ */ ws(Zl,e))},base64url(e){return this.check(/* @__PURE__ */ Ts(Ql,e))},xid(e){return this.check(/* @__PURE__ */ vs(Gl,e))},ksuid(e){return this.check(/* @__PURE__ */ ys(Kl,e))},ipv4(e){return this.check(/* @__PURE__ */ bs(ql,e))},ipv6(e){return this.check(/* @__PURE__ */ xs(Jl,e))},cidrv4(e){return this.check(/* @__PURE__ */ Ss(Yl,e))},cidrv6(e){return this.check(/* @__PURE__ */ Cs(Xl,e))},e164(e){return this.check(/* @__PURE__ */ Es($l,e))},datetime(e){return this.check(/* @__PURE__ */ Os(Ml,e))},date(e){return this.check(/* @__PURE__ */ ks(Nl,e))},time(e){return this.check(/* @__PURE__ */ As(Pl,e))},duration(e){return this.check(/* @__PURE__ */ js(Fl,e))}});function Al(e){return/* @__PURE__ */ as(kl,e)}const jl=/*@__PURE__*/ U(`ZodStringFormat`,(e,t)=>{fa.init(e,t),Ol.init(e,t)}),Ml=/*@__PURE__*/ U(`ZodISODateTime`,(e,t)=>{ja.init(e,t),jl.init(e,t)}),Nl=/*@__PURE__*/ U(`ZodISODate`,(e,t)=>{Ma.init(e,t),jl.init(e,t)}),Pl=/*@__PURE__*/ U(`ZodISOTime`,(e,t)=>{Na.init(e,t),jl.init(e,t)}),Fl=/*@__PURE__*/ U(`ZodISODuration`,(e,t)=>{Pa.init(e,t),jl.init(e,t)}),Il=/*@__PURE__*/ U(`ZodEmail`,(e,t)=>{ha.init(e,t),jl.init(e,t)}),Ll=/*@__PURE__*/ U(`ZodGUID`,(e,t)=>{pa.init(e,t),jl.init(e,t)}),Rl=/*@__PURE__*/ U(`ZodUUID`,(e,t)=>{ma.init(e,t),jl.init(e,t)}),zl=/*@__PURE__*/ U(`ZodURL`,(e,t)=>{Ca.init(e,t),jl.init(e,t)}),Bl=/*@__PURE__*/ U(`ZodEmoji`,(e,t)=>{wa.init(e,t),jl.init(e,t)}),Vl=/*@__PURE__*/ U(`ZodNanoID`,(e,t)=>{Ta.init(e,t),jl.init(e,t)}),Hl=/*@__PURE__*/ U(`ZodCUID`,(e,t)=>{Ea.init(e,t),jl.init(e,t)}),Ul=/*@__PURE__*/ U(`ZodCUID2`,(e,t)=>{Da.init(e,t),jl.init(e,t)}),Wl=/*@__PURE__*/ U(`ZodULID`,(e,t)=>{Oa.init(e,t),jl.init(e,t)}),Gl=/*@__PURE__*/ U(`ZodXID`,(e,t)=>{ka.init(e,t),jl.init(e,t)}),Kl=/*@__PURE__*/ U(`ZodKSUID`,(e,t)=>{Aa.init(e,t),jl.init(e,t)}),ql=/*@__PURE__*/ U(`ZodIPv4`,(e,t)=>{Fa.init(e,t),jl.init(e,t)}),Jl=/*@__PURE__*/ U(`ZodIPv6`,(e,t)=>{Ra.init(e,t),jl.init(e,t)}),Yl=/*@__PURE__*/ U(`ZodCIDRv4`,(e,t)=>{za.init(e,t),jl.init(e,t)}),Xl=/*@__PURE__*/ U(`ZodCIDRv6`,(e,t)=>{Va.init(e,t),jl.init(e,t)}),Zl=/*@__PURE__*/ U(`ZodBase64`,(e,t)=>{Wa.init(e,t),jl.init(e,t)}),Ql=/*@__PURE__*/ U(`ZodBase64URL`,(e,t)=>{qa.init(e,t),jl.init(e,t)}),$l=/*@__PURE__*/ U(`ZodE164`,(e,t)=>{Ja.init(e,t),jl.init(e,t)}),eu=/*@__PURE__*/ U(`ZodJWT`,(e,t)=>{Xa.init(e,t),jl.init(e,t)}),tu=/*@__PURE__*/ U(`ZodNumber`,(e,t)=>{Za.init(e,t),Dl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zc(e,t,n,r),e.isFinite=!0},/*@__PURE__*/ yr({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=Pc(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=Pc(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=Pc(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>Pc(e).format??null},{gt(e,t){return this.check(/* @__PURE__ */ zs(e,t))},gte(e,t){return this.check(/* @__PURE__ */ Bs(e,t))},min(e,t){return this.check(/* @__PURE__ */ Bs(e,t))},lt(e,t){return this.check(/* @__PURE__ */ Ls(e,t))},lte(e,t){return this.check(/* @__PURE__ */ Rs(e,t))},max(e,t){return this.check(/* @__PURE__ */ Rs(e,t))},int(e){return this.check(ru(e))},safe(e){return this.check(ru(e))},positive(e){return this.check(/* @__PURE__ */ zs(0,e))},nonnegative(e){return this.check(/* @__PURE__ */ Bs(0,e))},negative(e){return this.check(/* @__PURE__ */ Ls(0,e))},nonpositive(e){return this.check(/* @__PURE__ */ Rs(0,e))},multipleOf(e,t){return this.check(/* @__PURE__ */ Vs(e,t))},step(e,t){return this.check(/* @__PURE__ */ Vs(e,t))},finite(){return this}})),nu=/*@__PURE__*/ U(`ZodNumberFormat`,(e,t)=>{Qa.init(e,t),tu.init(e,t)});function ru(e){return/* @__PURE__ */ Ns(nu,e)}const iu=/*@__PURE__*/ U(`ZodBoolean`,(e,t)=>{$a.init(e,t),Dl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Bc(e,t,n,r)});function au(e){return/* @__PURE__ */ Ps(iu,e)}const ou=/*@__PURE__*/ U(`ZodUnknown`,(e,t)=>{eo.init(e,t),Dl.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function su(){return/* @__PURE__ */ Fs(ou)}const cu=/*@__PURE__*/ U(`ZodNever`,(e,t)=>{to.init(e,t),Dl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vc(e,t,n,r)});function lu(e){return/* @__PURE__ */ Is(cu,e)}const uu=/*@__PURE__*/ U(`ZodArray`,(e,t)=>{El(),ao.init(e,t),Dl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Gc(e,t,n,r),e.element=t.element},{min(e,t){return this.check(/* @__PURE__ */ Us(e,t))},nonempty(e){return this.check(/* @__PURE__ */ Us(1,e))},max(e,t){return this.check(/* @__PURE__ */ Hs(e,t))},length(e,t){return this.check(/* @__PURE__ */ Ws(e,t))},unwrap(){return this.element}});function du(e,t){return/* @__PURE__ */ rc(uu,e,t)}const fu=/*@__PURE__*/ U(`ZodObject`,(e,t)=>{El(),fo.init(e,t),Dl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qc(e,t,n,r),Tr(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return Su(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(Pn(this._zod.def,{catchall:e}))},passthrough(){return this.clone(Pn(this._zod.def,{catchall:su()}))},loose(){return this.clone(Pn(this._zod.def,{catchall:su()}))},strict(){return this.clone(Pn(this._zod.def,{catchall:lu()}))},strip(){return this.clone(Pn(this._zod.def,{catchall:void 0}))},extend(e){return Qn(this,e)},safeExtend(e){return er(this,e)},merge(e){return tr(this,e)},pick(e){return Yn(this,e)},omit(e){return Zn(this,e)},partial(...e){return nr(Tu,this,e[0])},exactPartial(...e){return nr(Du,this,e[0],`exactPartial`)},required(...e){return rr(Fu,this,e[0])}});function pu(e,t){let n={type:`object`,shape:e??{},...V(t)};return new fu(n)}function mu(e,t){return new fu({type:`object`,shape:e,catchall:su(),...V(t)})}const hu=/*@__PURE__*/ U(`ZodUnion`,(e,t)=>{mo.init(e,t),Dl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Jc(e,t,n,r),e.options=t.options});function gu(e,t){return new hu({type:`union`,options:e,...V(t)})}const _u=/*@__PURE__*/ U(`ZodIntersection`,(e,t)=>{ho.init(e,t),Dl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yc(e,t,n,r)});function vu(e,t){return new _u({type:`intersection`,left:e,right:t})}const yu=/*@__PURE__*/ U(`ZodRecord`,(e,t)=>{El(),vo.init(e,t),Dl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$c(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function bu(e,t,n){return!t||!t._zod?new yu({type:`record`,keyType:Al(),valueType:e,...V(t)}):new yu({type:`record`,keyType:e,valueType:t,...V(n)})}const xu=/*@__PURE__*/ U(`ZodEnum`,(e,t)=>{yo.init(e,t),Dl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Hc(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new xu({...t,checks:[],...V(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new xu({...t,checks:[],...V(r),entries:i})}});function Su(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new xu({type:`enum`,entries:n,...V(t)})}const Cu=/*@__PURE__*/ U(`ZodTransform`,(e,t)=>{El(),bo.init(e,t),Dl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Wc(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Mr(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(hr(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(hr(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function wu(e){return new Cu({type:`transform`,transform:e})}const Tu=/*@__PURE__*/ U(`ZodOptional`,(e,t)=>{So.init(e,t),Dl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ll(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Eu(e){return new Tu({type:`optional`,innerType:e})}const Du=/*@__PURE__*/ U(`ZodExactOptional`,(e,t)=>{Co.init(e,t),Dl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ll(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ou(e){return new Du({type:`optional`,innerType:e})}const ku=/*@__PURE__*/ U(`ZodNullable`,(e,t)=>{wo.init(e,t),Dl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>el(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Au(e){return new ku({type:`nullable`,innerType:e})}const ju=/*@__PURE__*/ U(`ZodDefault`,(e,t)=>{To.init(e,t),Dl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>il(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Mu(e,t){return new ju({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Vn(t)}})}const Nu=/*@__PURE__*/ U(`ZodPrefault`,(e,t)=>{Do.init(e,t),Dl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>al(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Pu(e,t){return new Nu({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Vn(t)}})}const Fu=/*@__PURE__*/ U(`ZodNonOptional`,(e,t)=>{Oo.init(e,t),Dl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>tl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Iu(e,t){return new Fu({type:`nonoptional`,innerType:e,...V(t)})}const Lu=/*@__PURE__*/ U(`ZodCatch`,(e,t)=>{jo.init(e,t),Dl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ol(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Ru(e,t){return new Lu({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:Er(t)})}const zu=/*@__PURE__*/ U(`ZodPipe`,(e,t)=>{Mo.init(e,t),Dl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>sl(e,t,n,r),e.in=t.in,e.out=t.out});function Bu(e,t){return new zu({type:`pipe`,in:e,out:t})}const Vu=/*@__PURE__*/ U(`ZodReadonly`,(e,t)=>{Po.init(e,t),Dl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cl(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Hu(e){return new Vu({type:`readonly`,innerType:e})}const Uu=/*@__PURE__*/ U(`ZodCustom`,(e,t)=>{Io.init(e,t),Dl.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Uc(e,t,n,r)});function Wu(e,t={}){return/* @__PURE__ */ ic(Uu,e,t)}function Gu(e,t){return/* @__PURE__ */ ac(e,t)}function Ku(e){return/* @__PURE__ */ Ms(tu,e)}let qu;function Ju(){return qu??=en(`@longzai-intelligence-cli/core/provider`),qu}const Yu={red:e=>e,green:e=>e,yellow:e=>e,blue:e=>e,cyan:e=>e,magenta:e=>e,gray:e=>e,bold:e=>e,dim:e=>e};let Xu={select:async(e,t)=>t[0]?.value??``,textInput:async(e,t)=>t?.defaultValue??``,confirm:async(e,t)=>t?.defaultValue??!1,spinner:()=>({start:e=>Ju().info(e),stop:e=>Ju().info(e)}),note:(e,t)=>{t?Ju().info(`${t}: ${e}`):Ju().info(e)},log:{info:e=>Ju().info(e),success:e=>Ju().info(e),warn:e=>Ju().warn(e),error:e=>Ju().error(e),step:e=>Ju().info(e)}},Zu=Yu;function Qu(e){Xu=e}function $u(e){Zu=e}function ed(){return Xu}function td(){return Zu}const nd=()=>`0.0.8`;function rd(e){let t=e.version??nd();e.interaction&&Qu(e.interaction),e.color&&$u(e.color);let n=new hn;return n.name(e.name).version(t,`-v, --version`,`输出 ${e.name} 的版本号`),e.description&&n.description(e.description),n}let id;function ad(){return id??=en(`@longzai-intelligence-cli/core/define-command`),id}function od(e,t){let n=e.commands.find(e=>e.name()===t);return n===void 0?e.command(t):n}function sd(e,t){if(t.length===1){let n=t[0];if(n===void 0)throw Error(`defineCommand: segments 为空,无法解析命令名`);return e.command(n)}let[n,...r]=t;if(n===void 0)throw Error(`defineCommand: segments 首段为空,无法解析父命令名`);let i=r.pop();if(i===void 0)throw Error(`defineCommand: segments 末段为空,无法解析子命令名`);let a=od(e,n);for(let e of r)a=od(a,e);return a.command(i)}function cd(e,t){let n=sd(e,t.name.split(` `).filter(e=>e.length>0));t.description&&n.description(t.description);for(let e of t.arguments??[])e.description?n.argument(e.signature,e.description):n.argument(e.signature);for(let e of t.options??[])e.defaultValue===void 0?n.option(e.flags,e.description??``):n.option(e.flags,e.description??``,e.defaultValue);n.action(async(...e)=>{let n=e[e.length-1];if(!(n instanceof hn))return;let r=n.opts(),i=n.args,a=t.schema.safeParse(r);if(!a.success){let e=a.error.issues.map(e=>e.message).join(`, `);ad().error(td().red(`参数校验失败: ${e}`)),ed().log.error(`参数校验失败: ${e}`),process.exit(1)}await t.action(a.data,i)})}var ld=/* @__PURE__ */ w(import.meta.url);function ud(e){let t=y(e);return t.length>1&&t[t.length-1]===C&&(t=t.substring(0,t.length-1)),t}const dd=/[\\/]/g;function fd(e,t){return e.replace(dd,t)}const pd=/^[a-z]:[\\/]$/i;function md(e){return e===`/`||pd.test(e)}function hd(e,t){let{resolvePaths:n,normalizePath:r,pathSeparator:i}=t,a=process.platform===`win32`&&e.includes(`/`)||e.startsWith(`.`);return n&&(e=S(e)),(r||a)&&(e=ud(e)),e===`.`?``:fd(e[e.length-1]===i?e:e+i,i)}function gd(e,t){return t+e}function _d(e,t){return function(n,r){return r.startsWith(e)?r.slice(e.length)+n:fd(x(e,r),t.pathSeparator)+t.pathSeparator+n}}function vd(e){return e}function yd(e,t,n){return t+e+n}function bd(e,t){let{relativePaths:n,includeBasePath:r}=t;return n&&e?_d(e,t):r?gd:vd}function xd(e){return function(t,n){n.push(t.substring(e.length)||`.`)}}function Sd(e){return function(t,n,r){let i=t.substring(e.length)||`.`;r.every(e=>e(i,!0))&&n.push(i)}}const Cd=(e,t)=>{t.push(e||`.`)},wd=(e,t,n)=>{let r=e||`.`;n.every(e=>e(r,!0))&&t.push(r)},Td=()=>{};function Ed(e,t){let{includeDirs:n,filters:r,relativePaths:i}=t;return n?i?r&&r.length?Sd(e):xd(e):r&&r.length?wd:Cd:Td}const Dd=(e,t,n,r)=>{r.every(t=>t(e,!1))&&n.files++},Od=(e,t,n,r)=>{r.every(t=>t(e,!1))&&t.push(e)},kd=(e,t,n,r)=>{n.files++},Ad=(e,t)=>{t.push(e)},jd=()=>{};function Md(e){let{excludeFiles:t,filters:n,onlyCounts:r}=e;return t?jd:n&&n.length?r?Dd:Od:r?kd:Ad}const Nd=e=>e,Pd=()=>[``].slice(0,0);function Fd(e){return e.group?Pd:Nd}const Id=(e,t,n)=>{e.push({directory:t,files:n,dir:t})},Ld=()=>{};function Rd(e){return e.group?Id:Ld}const zd=function(e,t,n){let{queue:r,fs:i,options:{suppressErrors:a}}=t;r.enqueue(),i.realpath(e,(o,s)=>{if(o)return r.dequeue(a?null:o,t);i.stat(s,(i,o)=>{if(i)return r.dequeue(a?null:i,t);if(o.isDirectory()&&Hd(e,s,t))return r.dequeue(null,t);n(o,s),r.dequeue(null,t)})})},Bd=function(e,t,n){let{queue:r,fs:i,options:{suppressErrors:a}}=t;r.enqueue();try{let r=i.realpathSync(e),a=i.statSync(r);if(a.isDirectory()&&Hd(e,r,t))return;n(a,r)}catch(e){if(!a)throw e}};function Vd(e,t){return!e.resolveSymlinks||e.excludeSymlinks?null:t?Bd:zd}function Hd(e,t,n){if(n.options.useRealPaths)return Ud(t,n);let r=_(e),i=1;for(;r!==n.root&&i<2;){let e=n.symlinks.get(r);e&&(e===t||e.startsWith(t)||t.startsWith(e))?i++:r=_(r)}return n.symlinks.set(e,t),i>1}function Ud(e,t){return t.visited.includes(e+t.options.pathSeparator)}const Wd=e=>e.counts,Gd=e=>e.groups,Kd=e=>e.paths,qd=e=>e.paths.slice(0,e.options.maxFiles),Jd=(e,t,n)=>(Qd(t,n,e.counts,e.options.suppressErrors),null),Yd=(e,t,n)=>(Qd(t,n,e.paths,e.options.suppressErrors),null),Xd=(e,t,n)=>(Qd(t,n,e.paths.slice(0,e.options.maxFiles),e.options.suppressErrors),null),Zd=(e,t,n)=>(Qd(t,n,e.groups,e.options.suppressErrors),null);function Qd(e,t,n,r){t(e&&!r?e:null,n)}function $d(e,t){let{onlyCounts:n,group:r,maxFiles:i}=e;return n?t?Wd:Jd:r?t?Gd:Zd:i?t?qd:Xd:t?Kd:Yd}const ef={withFileTypes:!0},tf=(e,t,n,r,i)=>{if(e.queue.enqueue(),r<0)return e.queue.dequeue(null,e);let{fs:a}=e;e.visited.push(t),e.counts.directories++,a.readdir(t||`.`,ef,(t,a=[])=>{i(a,n,r),e.queue.dequeue(e.options.suppressErrors?null:t,e)})},nf=(e,t,n,r,i)=>{let{fs:a}=e;if(r<0)return;e.visited.push(t),e.counts.directories++;let o=[];try{o=a.readdirSync(t||`.`,ef)}catch(t){if(!e.options.suppressErrors)throw t}i(o,n,r)};function rf(e){return e?nf:tf}var af=class{count=0;constructor(e){this.onQueueEmpty=e}enqueue(){return this.count++,this.count}dequeue(e,t){this.onQueueEmpty&&(--this.count<=0||e)&&(this.onQueueEmpty(e,t),e&&(t.controller.abort(),this.onQueueEmpty=void 0))}},of=class{_files=0;_directories=0;set files(e){this._files=e}get files(){return this._files}set directories(e){this._directories=e}get directories(){return this._directories}
164
164
  /* c8 ignore next 3 */
165
165
  get dirs(){return this._directories}},sf=class{aborted=!1;abort(){this.aborted=!0}},cf=class{root;isSynchronous;state;joinPath;pushDirectory;pushFile;getArray;groupFiles;resolveSymlink;walkDirectory;callbackInvoker;constructor(e,t,n){this.isSynchronous=!n,this.callbackInvoker=$d(t,this.isSynchronous),this.root=hd(e,t),this.state={root:md(this.root)?this.root:this.root.slice(0,-1),paths:[``].slice(0,0),groups:[],counts:new of,options:t,queue:new af((e,t)=>this.callbackInvoker(t,e,n)),symlinks:/* @__PURE__ */ new Map,visited:[``].slice(0,0),controller:new sf,fs:t.fs||l},this.joinPath=bd(this.root,t),this.pushDirectory=Ed(this.root,t),this.pushFile=Md(t),this.getArray=Fd(t),this.groupFiles=Rd(t),this.resolveSymlink=Vd(t,this.isSynchronous),this.walkDirectory=rf(this.isSynchronous)}start(){return this.pushDirectory(this.root,this.state.paths,this.state.options.filters),this.walkDirectory(this.state,this.root,this.root,this.state.options.maxDepth,this.walk),this.isSynchronous?this.callbackInvoker(this.state,null):null}walk=(e,t,n)=>{let{paths:r,options:{filters:i,resolveSymlinks:a,excludeSymlinks:o,exclude:s,maxFiles:c,signal:l,useRealPaths:u,pathSeparator:d},controller:f}=this.state;if(f.aborted||l&&l.aborted||c&&r.length>c)return;let p=this.getArray(this.state.paths);for(let c=0;c<e.length;++c){let l=e[c];if(l.isFile()||l.isSymbolicLink()&&!a&&!o){let e=this.joinPath(l.name,t);this.pushFile(e,p,this.state.counts,i)}else if(l.isDirectory()){let e=yd(l.name,t,this.state.options.pathSeparator);if(s&&s(l.name,e))continue;this.pushDirectory(e,r,i),this.walkDirectory(this.state,e,e,n-1,this.walk)}else if(this.resolveSymlink&&l.isSymbolicLink()){let e=gd(l.name,t);this.resolveSymlink(e,this.state,(t,r)=>{if(t.isDirectory()){if(r=hd(r,this.state.options),s&&s(l.name,u?r:e+d))return;this.walkDirectory(this.state,r,u?r:e+d,n-1,this.walk)}else{r=u?r:e;let t=g(r),n=hd(_(r),this.state.options);r=this.joinPath(t,n),this.pushFile(r,p,this.state.counts,i)}})}}this.groupFiles(this.state.groups,t,p)}};function lf(e,t){return new Promise((n,r)=>{uf(e,t,(e,t)=>{if(e)return r(e);n(t)})})}function uf(e,t,n){new cf(e,t,n).start()}function df(e,t){return new cf(e,t).start()}var ff=class{constructor(e,t){this.root=e,this.options=t}withPromise(){return lf(this.root,this.options)}withCallback(e){uf(this.root,this.options,e)}sync(){return df(this.root,this.options)}};let pf=null;
166
166
  /* c8 ignore next 6 */
@@ -319,9 +319,10 @@ default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.l
319
319
  n?this.stack.push(n):(yield*this.pop(),yield*this.step())}else{let t=this.peek(2);if(t.type===`block-map`&&(this.type===`map-value-ind`&&t.indent===e.indent||this.type===`newline`&&!t.items[t.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type===`map-value-ind`&&t.type!==`flow-collection`){let n=l(c(t));d(e);let r=e.end.splice(1,e.end.length);r.push(this.sourceToken);let i={type:`block-map`,offset:e.offset,indent:e.indent,items:[{start:n,key:e,sep:r}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=i}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let e=this.source.indexOf(`
320
320
  `)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
321
321
  `,e)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return this.flowScalar(this.type);case`block-scalar-header`:return{type:`block-scalar`,offset:this.offset,indent:this.indent,props:[this.sourceToken],source:``};case`flow-map-start`:case`flow-seq-start`:return{type:`flow-collection`,offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case`seq-item-ind`:return{type:`block-seq`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case`explicit-key-ind`:{this.onKeyLine=!0;let t=l(c(e));return t.push(this.sourceToken),{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case`map-value-ind`:{this.onKeyLine=!0;let t=l(c(e));return{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!==`comment`||this.indent<=t?!1:e.every(e=>e.type===`newline`||e.type===`space`)}*documentEnd(e){this.type!==`doc-mode`&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case`comma`:case`doc-start`:case`doc-end`:case`flow-seq-end`:case`flow-map-end`:case`map-value-ind`:yield*this.pop(),yield*this.step();break;case`newline`:this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop())}}}})),qy=/* @__PURE__ */ n((e=>{var t=zy(),n=Sy(),r=Cy(),i=qv(),a=Q(),o=Gy(),s=Ky();function c(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new o.LineCounter||null,prettyErrors:t}}function l(e,n={}){let{lineCounter:i,prettyErrors:a}=c(n),o=new s.Parser(i?.addNewLine),l=new t.Composer(n),u=Array.from(l.compose(o.parse(e)));if(a&&i)for(let t of u)t.errors.forEach(r.prettifyError(e,i)),t.warnings.forEach(r.prettifyError(e,i));return u.length>0?u:Object.assign([],{empty:!0},l.streamInfo())}function u(e,n={}){let{lineCounter:i,prettyErrors:a}=c(n),o=new s.Parser(i?.addNewLine),l=new t.Composer(n),u=null;for(let t of l.compose(o.parse(e),!0,e.length))if(!u)u=t;else if(u.options.logLevel!==`silent`){u.errors.push(new r.YAMLParseError(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return a&&i&&(u.errors.forEach(r.prettifyError(e,i)),u.warnings.forEach(r.prettifyError(e,i))),u}function d(e,t,n){let r;typeof t==`function`?r=t:n===void 0&&t&&typeof t==`object`&&(n=t);let a=u(e,n);if(!a)return null;if(a.warnings.forEach(e=>i.warn(a.options.logLevel,e)),a.errors.length>0){if(a.options.logLevel!==`silent`)throw a.errors[0];a.errors=[]}return a.toJS(Object.assign({reviver:r},n))}function f(e,t,r){let i=null;if(typeof t==`function`||Array.isArray(t)?i=t:r===void 0&&t&&(r=t),typeof r==`string`&&(r=r.length),typeof r==`number`){let e=Math.round(r);r=e<1?void 0:e>8?{indent:8}:{indent:e}}if(e===void 0){let{keepUndefined:e}=r??t??{};if(!e)return}return a.isDocument(e)&&!i?e.toString(r):new n.Document(e,i,r).toString(r)}e.parse=d,e.parseAllDocuments=l,e.parseDocument=u,e.stringify=f})),Jy=(/* @__PURE__ */ n((e=>{var t=zy(),n=Sy(),r=by(),i=Cy(),a=Rv(),o=Q(),s=Xv(),c=zv(),l=Qv(),u=ey();Uy();var d=Wy(),f=Gy(),p=Ky(),m=qy(),h=Mv();e.Composer=t.Composer,e.Document=n.Document,e.Schema=r.Schema,e.YAMLError=i.YAMLError,e.YAMLParseError=i.YAMLParseError,e.YAMLWarning=i.YAMLWarning,e.Alias=a.Alias,e.isAlias=o.isAlias,e.isCollection=o.isCollection,e.isDocument=o.isDocument,e.isMap=o.isMap,e.isNode=o.isNode,e.isPair=o.isPair,e.isScalar=o.isScalar,e.isSeq=o.isSeq,e.Pair=s.Pair,e.Scalar=c.Scalar,e.YAMLMap=l.YAMLMap,e.YAMLSeq=u.YAMLSeq,e.Lexer=d.Lexer,e.LineCounter=f.LineCounter,e.Parser=p.Parser,e.parse=m.parse,e.parseAllDocuments=m.parseAllDocuments,e.parseDocument=m.parseDocument,e.stringify=m.stringify,e.visit=h.visit,e.visitAsync=h.visitAsync})))();function Yy(e){let t=(0,Jy.parseDocument)(e),n=!1;function r(r){e=r,t=(0,Jy.parseDocument)(e),n=!1}function i(e,r){let i=e.length===1?t.contents:t.getIn(e.slice(0,-1));i||(i=t.createNode({}),t.setIn(e.slice(0,-1),i));let a=e[e.length-1],o=i.items.find(e=>typeof e.key==`string`?e.key===a:e.key.value===a),s=i.items.map(e=>typeof e.key==`string`?e.key:String(e.key.value));if(!o){let e=0;for(;e<s.length&&!(s[e].localeCompare(a)>0);e++);o=new Jy.Pair(a,r),i.items.splice(e,0,o),n=!0}else if((0,Jy.isAlias)(o.value)){let e=Xy(t,o.value);e&&e.value!==r&&(e.value=r,n=!0)}else!o.value||typeof o.value==`string`?o.value!==r&&(o.value=r,n=!0):o.value.value!==r&&(o.value.value=r,n=!0)}function a(e,n,r){let i=t.toJSON()||{},a=e==="default"?i.catalog?.[n]:i.catalogs?.[e]?.[n];if(a===r)return{conflicts:!1,newCatalogName:e,existingSpecifier:a};if(a){let t=Zy(r);return{conflicts:!0,existingSpecifier:a,newCatalogName:e==="default"?`conflicts_${n}_${t}`:`conflicts_${e}_${t}`}}return{conflicts:!1,newCatalogName:e}}function o(e,t,n){let{newCatalogName:r}=a(e,t,n);s(r,t,n)}function s(e,n,r){let a=t.toJSON()?.catalogs?.default!==void 0;i(e==="default"&&!a?[`catalog`,n]:[`catalogs`,e,n],r)}function c(e){let n=[],r=t.toJSON()||{};if(r.catalogs)for(let t of Object.keys(r.catalogs))r.catalogs[t]?.[e]&&n.push(t);return r.catalog&&r.catalog[e]&&n.push(`default`),n}return{getDocument(){return t},setContent:r,hasChanged:()=>n,toJSON:()=>t.toJSON(),toString:n=>{let r=e.split(`'`).length>=e.split(`"`).length;return t.toString({singleQuote:r,...n})},setPath:i,setPackage:s,setPackageNoConflicts:o,getPackageCatalogs:c,hasSpecifierConflicts:a}}function Xy(e,t){let n;return(0,Jy.visit)(e,{Scalar:(e,r,i)=>{r.anchor===t.source&&typeof r.value==`string`&&(n=r)}}),n}function Zy(e){return e.replace(/\^/g,`h`).replace(/~/g,`t`).replace(/\./g,`_`).replace(/</g,`l`).replace(/>/g,`g`).replace(/=/g,`e`).replace(/\*/g,`s`).replace(/@/g,`a`).replace(/\|/g,`p`).replace(/&/g,`n`).replace(/-/g,`m`).replace(/\+/g,`u`).replace(/\s/g,`_`)}function Qy(e){return e??=[],Array.isArray(e)?e:[e]}function $y(e){return typeof e==`object`&&!!e&&`json`in e&&typeof e.json==`function`}function eb(e){if($y(e))return e.json();throw TypeError(`response does not implement json()`)}const tb=3e4,nb=`version-upgrade@npm node/${F.version}`,rb=Object.assign((e,t)=>{let n=new Headers(t?.headers);return n.set(`user-agent`,nb),C_(e,{...t,headers:n})},{preconnect:()=>{}});async function ib(e,t,n,r){let i;for(let a=0;a<=r;a++)try{return await Promise.race([e(),new Promise((e,i)=>setTimeout(()=>i(/* @__PURE__ */ Error(`Timeout requesting "${t}" (attempt ${a+1}/${r+1})`)),n))])}catch(e){if(i=e instanceof Error?e:Error(String(e)),a<r){let e=Math.min(1e3*2**a,1e4);await new Promise(t=>setTimeout(t,e))}}throw i??Error(`Unexpected state: all retries exhausted for "${t}" but no error captured`)}async function ab(e,t=!1,n,r=tb,i=3){let a=await ib(()=>pg(e,{cwd:n,force:t,fetch:rb,metadata:!0,throw:!1}),e,r,i);if(!cb(a))throw Error(`Invalid package metadata received for "${e}"`);let o=a;if(`error`in o)throw Error(`Failed to fetch package "${e}": ${o.error}`);return sb(o)}async function ob(e,t=tb,n=3){let r=await ib(()=>rb(new URL(`${e}/meta.json`,`https://jsr.io/`),{headers:{accept:`application/json`}}).then(e=>eb(e)),e,t,n);if(!lb(r))throw Error(`Invalid JSR package metadata received for "${e}"`);let i=r;return{versions:Object.keys(i.versions),tags:{latest:i.latest}}}function sb(e){let t=Object.keys(e.versionsMeta),n=Object.fromEntries(Object.entries(e.versionsMeta).flatMap(([e,t])=>t.deprecated==null?[]:[[e,t.deprecated]])),r=Object.fromEntries(Object.entries(e.versionsMeta).map(([e,t])=>[e,t.engines?.node]).filter(([,e])=>e)),i=Object.fromEntries(Object.entries(e.versionsMeta).map(([e,t])=>[e,t.provenance]).filter(([,e])=>e)),a=Object.fromEntries(Object.entries(e.versionsMeta).map(([e,t])=>[e,t.integrity]).filter(([,e])=>e));return{tags:e.distTags,versions:t,time:{...Object.fromEntries(Object.entries(e.versionsMeta).filter(([,e])=>e.time).map(([e,t])=>[e,t.time])),created:e.timeCreated,modified:e.timeModified},nodeSemver:r,provenance:i,deprecated:Object.keys(n).length>0?n:void 0,integrity:a}}function cb(e){return typeof e==`object`&&!!e&&`versionsMeta`in e&&`distTags`in e}function lb(e){return typeof e==`object`&&!!e&&`scope`in e&&`name`in e&&`latest`in e&&`versions`in e}let ub=null;const db=()=>(ub===null&&(ub=en(`packages/version-upgrade/src/io/cache`)),ub),fb=(0,Ep.default)(`version-upgrade:cache`);let pb={},mb=!1;const hb=Sp(s.tmpdir(),`version-upgrade`),gb=Sp(hb,`cache.json`),_b=18e5;function vb(){return Date.now()}function yb(e){return vb()-e}async function bb(){T(gb)&&yb(E(gb).mtimeMs)<_b?(fb(`cache loaded from ${gb}`),pb=JSON.parse(await D.readFile(gb,`utf-8`))):fb(`no cache found`)}async function xb(){if(mb)try{await D.mkdir(hb,{recursive:!0}),await D.writeFile(gb,JSON.stringify(pb),`utf-8`),fb(`cache saved to ${gb}`)}catch(e){db().error(`Failed to save cache`,e instanceof Error?e:Error(String(e)))}}async function Sb(e,t=`npm`,n,r,i){let a,o=`${t}:${e}`;if(pb[o]){if(yb(pb[o].cacheTime)<_b)return fb(`cache hit for ${o}`),pb[o].data;delete pb[o]}try{let a=t===`jsr`?await ob(e,r,i):await ab(e,!1,n,r,i);if(a)return pb[o]={data:a,cacheTime:vb()},mb=!0,a}catch(e){a=e}return{tags:{},versions:[],error:a instanceof Error&&a.message||String(a),deprecated:{}}}const Cb=[`**/node_modules/**`,`**/dist/**`,`**/public/**`,`**/fixture/**`,`**/fixtures/**`];function wb(e,t=[]){if(!e)return{};let n={};for(let[r,i]of Object.entries(e))if(typeof i==`object`&&i){let e={};for(let[t,n]of Object.entries(i))e[t]=n;n={...n,...wb(e,[...t,r])}}else typeof i==`string`&&(n[r]={version:i,parents:t});return n}function Tb(e,t){let n=t.split(`.`).reduce((e,t)=>{if(typeof e==`object`&&e){let n={};for(let[t,r]of Object.entries(e))n[t]=r;return n[t]}},e);if(typeof n==`object`&&n){let e={};for(let[t,r]of Object.entries(n))e[t]=r;return wb(e)}return{}}function Eb(e){if(typeof e==`object`&&e&&!Array.isArray(e)){let t={};for(let[n,r]of Object.entries(e))t[n]=r;return t}return{}}function Db(e,t,n){let r=t.split(`.`),i=r.pop();if(i===void 0)return;let a=e;for(let e of r){(typeof a[e]!=`object`||a[e]===null)&&(a[e]={});let t=Eb(a[e]);a[e]=t,a=t}a[i]=n}function Ob(e,t,n){return Object.entries(Tb(e,t)||{}).map(([e,{version:r,parents:i}])=>kb({name:e,version:r,type:t,shouldUpdate:n,parents:i}))}function kb({name:e,version:t,type:n,shouldUpdate:r,parents:i,hexHash:a}){let o={name:e,currentVersion:t,parents:i,source:n,update:r(e)};return a&&(o.hexHash=a),o}function Ab(e,t){let n={};return e.filter(e=>e.source===t).sort((e,t)=>(e.aliasName||e.name).localeCompare(t.aliasName||t.name)).forEach(e=>{let t=e.update?e.targetVersion:e.currentVersion,r=n;if(e.parents&&e.parents.length>0){let t=n;for(let n of e.parents){(typeof t[n]!=`object`||t[n]===null)&&(t[n]={});let e=Eb(t[n]);t[n]=e,t=e}r=t}if(e.aliasName===void 0)r[e.name]=t;else{let n=e.protocol?`${e.protocol}:`:``;r[e.aliasName]=`${n}${e.protocol===`jsr`?t:jb(e,t)}`}}),n}function jb(e,t){let n=t?`@${t}`:``;return`${e.name}${n}`}async function Mb(e,t,n,r){let i=Sp(t.cwd??``,e),a=r??JSON.parse(await R(i,`utf-8`)),o=[];function s(t,r){let o=Object.entries(r).map(([e,t])=>kb({name:e,version:t,type:`bun-workspace`,shouldUpdate:n}));return{name:t,private:!0,version:``,type:`bun-workspace`,relative:e,filepath:i,raw:a,deps:o,resolved:[]}}let c=a?.workspaces;if(c&&typeof c==`object`){let e=Fb(c);if(e.catalog&&typeof e.catalog==`object`&&o.push(s(`bun-catalog:default`,Ib(e.catalog))),e.catalogs&&typeof e.catalogs==`object`){let t=Lb(e.catalogs);for(let e of Object.keys(t)){let n=t[e];n&&o.push(s(`bun-catalog:${e}`,n))}}}return o}async function Nb(e,t){let n=Ab(e.resolved,`bun-workspace`);if(Object.keys(n).length&&e.name.startsWith(`bun-catalog:`)){let t=e.name.replace(`bun-catalog:`,``),r=Fb(e.raw.workspaces??{});if(e.raw.workspaces=r,t==="default")r.catalog={...Ib(r.catalog??{}),...Ib(n)};else{let e=Lb(r.catalogs??{});r.catalogs=e,e[t]||(e[t]={}),e[t]={...e[t],...Ib(n)}}await Pb(e.filepath,e.raw)}}async function Pb(e,t){let n;try{n=M_(await R(e,`utf-8`)).indent}catch{}let r=JSON.stringify(t,null,n||` `);await ae(e,`${r}\n`,`utf-8`)}function Fb(e){if(typeof e==`object`&&e&&!Array.isArray(e)){let t={};for(let[n,r]of Object.entries(e))t[n]=r;return t}return{}}function Ib(e){if(typeof e==`object`&&e&&!Array.isArray(e)){let t={};for(let[n,r]of Object.entries(e))typeof r==`string`&&(t[n]=r);return t}return{}}function Lb(e){if(typeof e==`object`&&e&&!Array.isArray(e)){let t={};for(let[n,r]of Object.entries(e))if(typeof r==`object`&&r&&!Array.isArray(r)){let e={};for(let[t,n]of Object.entries(r))typeof n==`string`&&(e[t]=n);t[n]=e}return t}return{}}let Rb=null;const zb=()=>(Rb===null&&(Rb=en(`packages/version-upgrade/src/addons/vscode`)),Rb);function Bb(e,t){if(typeof e==`object`&&e){for(let[n,r]of Object.entries(e))if(n===t&&typeof r==`string`)return r}}function Vb(e){if(e==null)return!1;let t=e.engines;return Bb(t,`vscode`)!==void 0}function Hb(e){for(let t of[`dependencies`,`devDependencies`,`peerDependencies`]){let n=Bb(e[t],`@types/vscode`);if(n!==void 0)return n}return``}const Ub=[{beforeWrite(e){if(!Vb(e.raw)||e.raw==null)return;let t=e.raw,n=Hb(t);if(!n||n.includes(`:`))return;let r=t.engines,i=Bb(r,`vscode`);if(!i)return;let a=Av(i),o=Av(n);if(a&&o&&$_(o,a)){zb().info(`[taze addon] Updated VS Code engine field to ${n}`);let e=/[>^<:~]/.test(n)?n:`^${n}`;if(typeof r==`object`&&r){let n={};for(let[t,i]of Object.entries(r))n[t]=t===`vscode`?e:i;t.engines=n}}}}];function Wb(e){return re.from(e.slice(7),`base64`).toString(`hex`)}function Gb(e){return typeof e==`object`&&!!e&&`version`in e&&typeof e.version==`string`}const Kb=[`dependencies`,`devDependencies`,`peerDependencies`,`optionalDependencies`,`packageManager`,`pnpm.overrides`,`resolutions`,`overrides`];function qb(e,t){return t.depFields?.[e]===!1?!1:e!==`peerDependencies`||!!t.peer}async function Jb(e,t,n,r){let i=Sp(t.cwd??``,e),a=r??await px(i),o=[];for(let e of Kb)if(qb(e,t)){if(e===`packageManager`){let e=a.packageManager;if(typeof e==`string`){let t=e.indexOf(`@`),r=t>0?e.slice(0,t):``,i=t>0?e.slice(t+1):``,a=i.indexOf(`+`),s=a>=0?i.slice(0,a):i,c=a>=0?i.slice(a+1):``,l=c.indexOf(`.`),u=l>=0?c.slice(l+1):void 0;o.push(kb({name:r,version:`^${s}`,type:`packageManager`,shouldUpdate:n,hexHash:u}))}}else o.push(...Ob(a,e,n))}let s=typeof a.name==`string`?a.name:``,c=typeof a.version==`string`?a.version:``;return[{name:s,private:!!a.private,version:c,type:`package.json`,relative:e,filepath:i,raw:a,deps:o,resolved:[]}]}async function Yb(e,t){let n=!1;for(let r of Kb)if(qb(r,t)){if(r===`packageManager`){let t=Object.entries(Ab(e.resolved,`packageManager`))[0];if(t){e.raw||={};let[r,i]=t,a=typeof i==`string`?i.replace(`^`,``):String(i),o=`${r}@${a}`,s=e.resolved.find(e=>e.source===`packageManager`&&e.name===r);if(s?.hexHash){let e=s.pkgData?.integrity?.[a];if(e){let t=Wb(e);o=`${o}+sha512.${t}`}}e.raw.packageManager=o,n=!0}}else{let t=Tb(e.raw,r),i=Ab(e.resolved,r),a={};for(let[e,n]of Object.entries(t||{}))Gb(n)&&(a[e]=n.version);for(let[e,t]of Object.entries(i||{}))a[e]=t;Object.keys(a).length>0&&(Db(e.raw,r,a),n=!0)}}if(n){for(let n of t.addons||Ub)await n.beforeWrite?.(e,t);await mx(e.filepath,e.raw||{})}}const Xb=[`dependencies`,`devDependencies`,`peerDependencies`,`optionalDependencies`,`packageManager`,`pnpm.overrides`,`resolutions`,`overrides`];function Zb(e,t){return e===`peerDependencies`?!!t.peer:t.depFields?.[e]!==!1}async function Qb(e){let t=await L.readFile(e,`utf-8`);if(!t)return new Jy.Document({});let n=(0,Jy.parseDocument)(t,{merge:!0}),r=n.toJS();if(n.errors.length||typeof r!=`object`||Array.isArray(r))throw TypeError(`Invalid package.yaml structure in ${e}`);return n}async function $b(e,t){let{amount:n,type:r}=await L.readFile(e,`utf-8`).then(M_).catch(()=>({amount:2,type:`space`})),i=(0,Jy.stringify)(t,{indent:(r===`tab`?2:n)??2,aliasDuplicateObjects:!1,lineWidth:0}).replace(/^(\s*)"(@[^":]+)":/gm,`$1'$2':`);await L.writeFile(e,i,`utf-8`)}async function ex(e,t,n){let r=Sp(t.cwd??``,e),i=await Qb(r),a=[];for(let e of Xb)if(Zb(e,t)){if(e===`packageManager`){let t=i.get(e);if(typeof t==`string`){let e=t.split(`@`),r=e[0]??``,i=(e[1]??``).split(`+`)[0];a.push(kb({name:r,version:`^${i??``}`,type:`packageManager`,shouldUpdate:n}))}}else{let t={},r=i.toJS();if(typeof r==`object`&&r&&!Array.isArray(r))for(let[e,n]of Object.entries(r))t[e]=n;a.push(...Ob(t,e,n))}}let o=i.get(`name`),s=i.get(`version`);return[{name:typeof o==`string`?o:``,private:!!i.get(`private`),version:typeof s==`string`?s:``,type:`package.yaml`,relative:e,filepath:r,get raw(){return i.toJS()},deps:a,yamlDocument:i,resolved:[]}]}async function tx(e,t){let n=!1;if(e.type!==`package.yaml`)throw Error(`Package type is not supported`);let r=e.yamlDocument||new Jy.Document(e.raw);for(let i of Xb)if(Zb(i,t)){if(i===`packageManager`){let t=Object.entries(Ab(e.resolved,`packageManager`))[0];if(t){let[e,i]=t,a=typeof i==`string`?i.replace(`^`,``):``;r.set(`packageManager`,`${e}@${a}`),n=!0}}else{let t=Tb(nx(r),i);t&&Object.keys(t).length>0&&(Object.entries(Ab(e.resolved,i)).forEach(([e,t])=>r.setIn([...i.split(`.`),e],t)),n=!0)}}if(n){for(let n of t.addons||Ub)await n.beforeWrite?.(e,t);await $b(e.filepath,r)}}function nx(e){let t=e.toJS();if(typeof t==`object`&&t&&!Array.isArray(t)){let e={};for(let[n,r]of Object.entries(t))e[n]=r;return e}return{}}async function rx(e,t,n){let r=Sp(t.cwd??``,e),i=Yy(await R(r,`utf-8`)),a=i.getDocument().toJSON(),o=[];function s(t,o){let s=Object.entries(o).map(([e,t])=>kb({name:e,version:t,type:`pnpm-workspace`,shouldUpdate:n}));return{name:t,private:!0,version:``,type:`pnpm-workspace.yaml`,relative:e,filepath:r,raw:a,context:i,deps:s,resolved:[]}}if(a?.catalog&&o.push(s(`pnpm-catalog:default`,a.catalog)),a?.catalogs)for(let e of Object.keys(a.catalogs))o.push(s(`pnpm-catalog:${e}`,a.catalogs[e]));return a?.overrides&&o.push(s(`pnpm-workspace:overrides`,a.overrides)),o}async function ix(e,t){let n=Ab(e.resolved,`pnpm-workspace`);if(Object.keys(n).length){if(e.name.startsWith(`pnpm-catalog:`)){let t=e.name.replace(`pnpm-catalog:`,``);for(let[r,i]of Object.entries(n))typeof i==`string`&&e.context.setPackage(t,r,i)}else{let t=e.name.replace(`pnpm-workspace:`,``).split(/\./g);for(let[r,i]of Object.entries(n))e.context.setPath([...t,r],i)}e.context.hasChanged()&&await ax(e,e.context)}}function ax(e,t){return ae(e.filepath,t.toString(),`utf8`)}async function ox(e,t,n){let r=Sp(t.cwd??``,e),i=Yy(await R(r,`utf-8`)),a=i.getDocument().toJSON(),o=[];function s(t,o){let s=Object.entries(o).map(([e,t])=>kb({name:e,version:t,type:`yarn-workspace`,shouldUpdate:n}));return{name:t,private:!0,version:``,type:`.yarnrc.yml`,relative:e,filepath:r,raw:a,context:i,deps:s,resolved:[]}}if(a?.catalog&&o.push(s(`yarn-catalog:default`,a.catalog)),a?.catalogs)for(let e of Object.keys(a.catalogs))o.push(s(`yarn-catalog:${e}`,a.catalogs[e]));return o}async function sx(e,t){let n=Ab(e.resolved,`yarn-workspace`);if(Object.keys(n).length){if(e.name.startsWith(`yarn-catalog:`)){let t=e.name.replace(`yarn-catalog:`,``);for(let[r,i]of Object.entries(n))typeof i==`string`&&e.context.setPackage(t,r,i)}else{let t=e.name.replace(`yarn-workspace:`,``).split(/\./g);for(let[r,i]of Object.entries(n))e.context.setPath([...t,r],i)}e.context.hasChanged()&&await cx(e,e.context)}}function cx(e,t){return ae(e.filepath,t.toString(),`utf8`)}function lx(e){return e.replace(/[.+?^${}()|[\]\\]/g,`\\$&`)}function ux(e){if(e.startsWith(`/`)){let t=e.lastIndexOf(`/`),n=e.substring(1,t),r=e.substring(t+1,e.length);return new RegExp(n,r)}return RegExp(`^${lx(e).replace(/\*+/g,`.*?`)}$`)}function dx(e,t=!0){if(!e||e.length===0)return()=>t;let n=Qy(e).flatMap(e=>e.split(`,`)).map(ux);return e=>{for(let t of n)if(t.test(e))return!0;return!1}}function fx(e,t){let n=dx(e,!0),r=dx(t,!1);return e=>!r(e)&&n(e)}async function px(e){return JSON.parse(await D.readFile(e,`utf-8`))}async function mx(e,t){let n=M_(await D.readFile(e,`utf-8`)).indent||` `;await D.writeFile(e,`${JSON.stringify(t,null,n)}\n`,`utf-8`)}async function hx(e,t){switch(e.type){case`package.json`:return Yb(e,t);case`package.yaml`:return tx(e,t);case`pnpm-workspace.yaml`:return ix(e,t);case`bun-workspace`:return Nb(e,t);case`.yarnrc.yml`:return sx(e,t);default:throw Error(`Unsupported package type: ${e.type}`)}}async function gx(e,t,n){if(e.endsWith(`pnpm-workspace.yaml`))return rx(e,t,n);if(e.endsWith(`.yarnrc.yml`))return ox(e,t,n);if(e.endsWith(`package.yaml`))return ex(e,t,n);if(e.endsWith(`package.json`)){let r=Sp(t.cwd??``,e);try{let i=await px(r),a=i?.workspaces;if(a&&typeof a==`object`&&(`catalog`in a||`catalogs`in a)){let r=Sp(t.cwd||F.cwd());if(T(bp(r,`bun.lockb`))||T(bp(r,`bun.lock`))){let r=await Mb(e,t,n,i),a=await Jb(e,t,n,i);return[...r,...a]}}return Jb(e,t,n,i)}catch{}}return Jb(e,t,n)}async function _x(e){let t=[],n=Sp(e.cwd||F.cwd()),r=fx(e.include,e.exclude);if(e.recursive){let n=await Yf(`**/package.yaml`,{ignore:Cb.concat(e.ignorePaths||[]),cwd:e.cwd,onlyFiles:!0,dot:!1,expandDirectories:!1}),r=await Yf(`**/package.json`,{ignore:Cb.concat(e.ignorePaths||[]),cwd:e.cwd,onlyFiles:!0,dot:!1,expandDirectories:!1}),i=/* @__PURE__ */ new Set;for(let e of n){t.push(e);let n=Tp(e);i.add(n)}for(let e of r){let n=Tp(e);i.has(n)||t.push(e)}}else t=await Yf(`package.{yaml,json}`,{cwd:n});return t=t.sort((e,t)=>e.localeCompare(t)),e.ignoreOtherWorkspaces&&(t=(await Promise.all(t.map(async e=>{if(!e.includes(`/`))return[e];let t=bp(n,e),r=F_(`.git`,{cwd:t,last:n});if(r&&Tp(r)!==n)return[];let i=F_(`pnpm-workspace.yaml`,{cwd:t,last:n});if(i&&Tp(i)!==n)return[];let a=F_(`.yarnrc.yml`,{cwd:t,last:n});if(a&&Tp(a)!==n)return[];let o=F_(`bun.lockb`,{cwd:t,last:n})||F_(`bun.lock`,{cwd:t,last:n});return o&&Tp(o)!==n?[]:[e]}))).flat()),T(bp(n,`pnpm-workspace.yaml`))&&t.unshift(`pnpm-workspace.yaml`),T(bp(n,`.yarnrc.yml`))&&t.unshift(`.yarnrc.yml`),(await Promise.all(t.map(t=>gx(t,e,r)))).flat()}const vx={error:-1,major:0,minor:1,patch:2,"":3};function yx(e){return e.sort((e,t)=>vx[e.diff||``]-vx[t.diff||``])}function bx(e,t){if(t.packageMode){for(let n of Object.keys(t.packageMode))if(ux(n).test(e))return t.packageMode[n]}}function xx(e,t){let n=[];for(let r of Qy(t.maturityPeriodExclude).flatMap(e=>e.split(`,`))){let t=r.trim();if(!t)continue;let i=t.startsWith(`/`)?-1:t.lastIndexOf(`@`);if(!ux(i>0?t.slice(0,i):t).test(e))continue;if(i<=0)return!0;let a=t.slice(i+1).split(`||`).map(e=>e.trim()).filter(Boolean);n.push(...a)}return n}function Sx(e,t){for(let n of t)if(kv(e,n,{includePrerelease:!0}))return!0;return!1}const Cx=new P;function wx(e){return e.match(/(@[^/]+\/)?([^/]+)/g)||[]}function Tx(e){return e.match(/[^>]+/g)||[]}function Ex(e){return/^(?:https?:|git\+|github:)/.test(e)}function Dx(e){return/^(?:link|file|workspace|catalog):/.test(e)}function Ox(e){return/^(?:npm|jsr):/.test(e)}function kx(e){return e===`npm`?`npm`:e===`jsr`?`jsr`:`npm`}function Ax(e){let t=e.indexOf(`:`),n=kx(e.slice(0,t)),r=e.slice(t+1);if(n===`npm`){let e=r.lastIndexOf(`@`);return e>0?{protocol:n,name:r.substring(0,e),version:r.substring(e+1)}:{protocol:n,name:r,version:``}}return{protocol:n,name:``,version:r}}function jx(e){let t=[`>=`,`<=`,`>`,`<`,`~`,`^`],n=e.trim();if(n===`*`||n===``)return`*`;if(n[0]===`~`||n[0]===`^`)return n[0];for(let e of t)if(n.startsWith(e))return e;if(n.includes(`x`)){let e=n.split(`.`);if(e[0]===`x`)return`*`;if(e[1]===`x`)return`^`;if(e[2]===`x`)return`~`}return n.length>0&&n.charCodeAt(0)>=48&&n.charCodeAt(0)<=57?``:null}function Mx(e,t){if(!jv(e))return null;if(t==="default")return e;let n=Av(e);return n?{major:`>=`,minor:`^`,patch:`~`}[t]+n:null}function Nx(e,t){return e==null||t==null?null:t===`*`?`*`:t+e}function Px(e,t){return Nx(t,jx(e))}function Fx(e,t,n,r){let i=null;if(n===`latest`){let t=r.latest;i=t!=null&&e.includes(t)?t:e.at(-1)??null}else if(n===`newest`)i=e.at(-1)??null;else if(n===`next`){let t=r.next;i=t!=null&&e.includes(t)?t:e.at(-1)??null}else if(n===`stable`){let n=Mx(t,`default`);if(!n)return;e.filter(e=>!e.includes(`-`)).forEach(e=>{kv(e,n)&&(!i||$_(e,i))&&(i=e)})}else if(n==="default"&&(t===`*`||t.trim()===``))return;else{let a=Mx(t,n);if(!a)throw Error(`invalid_range`);let o=r.latest??null;o&&!kv(o,a)&&(o=null),e.forEach(e=>{kv(e,a)&&(!o||nv(e,o))&&(!i||$_(e,i))&&(i=e)})}if(i)return i}function Ix(e,t){return e.filter(e=>!t[e])}function Lx(e,t,n){if(!t||n<=0)return e;let r=/* @__PURE__ */ new Date((/* @__PURE__ */ new Date()).getTime()-n*24*60*60*1e3);return e.filter(e=>{let n=t[e];return!n||new Date(n)<r})}function Rx(e,t,n){let{tags:r}=e.pkgData,i=zx(e,n);if(i.length!==0)return e.filteredVersions=i,Fx(i,e.currentVersion,t,r)}function zx(e,t){let{versions:n,deprecated:r,time:i}=e.pkgData,a=n;r&&Object.keys(r).length>0&&(a=Ix(a,r));let o=xx(e.name,t);if(t.maturityPeriod&&t.maturityPeriod>0&&o!==!0){let e=a;if(a=Lx(e,i,t.maturityPeriod),o.length>0){let t=new Set(a);a=e.filter(e=>t.has(e)||Sx(e,o))}}return a}function Bx(e,t,n){let r=Rx(e,`latest`,n);return r&&$_(r,t)?r:void 0}function Vx(e,t,n=!0,r=!1){let i=/^\d+/.test(e.currentVersion);if(i&&!r)e.targetVersion=e.currentVersion,e.targetVersionTime=e.currentVersionTime,e.diff=null,e.update=!1;else{if(e.targetVersion=Px(e.currentVersion,t)||e.currentVersion,e.targetVersionTime=e.pkgData.time?.[t],e.currentProvenance=e.pkgData.provenance?.[e.currentVersion],e.targetProvenance=e.pkgData.provenance?.[e.targetVersion],e.provenanceDowngraded=!(!e.currentProvenance||e.targetProvenance)||e.currentProvenance===`trustedPublisher`&&e.targetProvenance===!0,i&&Q_(e.currentVersion,e.targetVersion)){let{versions:t,time:n={},tags:r}=e.pkgData,i=Fx(e.filteredVersions??t,e.currentVersion,`minor`,r);i&&(e.targetVersion=i,e.targetVersionTime=n[e.targetVersion])}try{let t=Av(e.currentVersion),n=Av(e.targetVersion);if(!t||!n)throw Error(`invalid_version`);e.currentVersionTime=e.pkgData.time?.[t.toString()],e.diff=Hx(t,n),e.update=e.diff!==null&&tv(t,n)}catch(t){if(!n)throw t;e.targetVersion=e.currentVersion,e.diff=`error`,e.update=!1}}}function Hx(e,t){if(Q_(e,t))return null;let n=kv(t,`~${e}`,{includePrerelease:!0}),r=kv(t,`^${e}`,{includePrerelease:!0}),i=kv(t,`>=${e}`,{includePrerelease:!0});return n?r?`patch`:`major`:r?`minor`:i?`major`:`error`}function Ux(e,t){return{...e,diff:null,targetVersion:e.currentVersion,update:!1,provenanceDowngraded:!1,pkgData:{tags:{},versions:[]},...t}}function Wx(e){return e!=null&&e!==`ignore`?e:`default`}async function Gx(e,t,n=()=>!0){let r={...e,diff:null,targetVersion:e.currentVersion,update:e.update,provenanceDowngraded:!1,pkgData:{tags:{},versions:[]}},i=bx(r.name,t),a=t.mode,o=i?i===a?a:a==="default"?i:`ignore`:a;if(Dx(e.currentVersion)||Ex(e.currentVersion)||!e.update||!await Promise.resolve(n(e))||o===`ignore`)return Ux(e);if(Ox(e.currentVersion)){let{name:t,version:n,protocol:i}=Ax(e.currentVersion);if(r.name=t||r.name,r.currentVersion=n,r.aliasName=e.name,r.protocol=i,!n)return Ux(e,{name:r.name,currentVersion:n,aliasName:e.name,protocol:i})}let s=r.name;r.source===`resolutions`?s=wx(r.name).pop()??r.name:r.source===`pnpm.overrides`&&(s=Tx(r.name).pop()??r.name);let c=await Sb(s,r.protocol,t.cwd,t.timeout,t.retries),{error:l,deprecated:u}=c;r.pkgData=c;let d=null,f;if(l==null)try{if(u&&typeof u==`object`&&r.currentVersion&&u[r.currentVersion])return Ux(e,{name:r.name,currentVersion:r.currentVersion,aliasName:r.aliasName,protocol:r.protocol});if(f=Rx(r,Wx(o),t),!f)return Ux(e,{name:r.name,currentVersion:r.currentVersion,aliasName:r.aliasName,protocol:r.protocol,pkgData:c})}catch(e){d=e instanceof Error?e.message:String(e)}else d=l;f?Vx(r,f,void 0,t.includeLocked):r.targetVersion=r.currentVersion,r.targetVersion===r.currentVersion&&(r.diff=null,r.update=!1);try{let e=Av(f||r.targetVersion||``);e&&(r.latestVersionAvailable=Bx(r,e,t));let{nodecompat:n=!0}=t;if(n){let t=F.version,{nodeSemver:n}=r.pkgData;if(n&&e?.version&&e?.version in n){let i=n[e.version];r.nodeCompatibleVersion={compatible:i!=null&&kv(t,i),semver:i??``}}}}catch{}return d&&(r.diff=`error`,r.update=!1,r.resolveError=d),r}async function Kx(e,t,n=()=>!0,r=()=>{}){let i=e.length,a=0,{concurrency:o=10}=t,s=Cx.getStore()||cp(o);return Promise.all(e.map(e=>s.add(async()=>{let o=await Gx(e,t,n);return a+=1,r(e.name,a,i),o})))}async function qx(e,t,n,r){let i=await Kx(e.deps,t,n,(t,n,i)=>r?.(e.name,t,n,i));return yx(i),e.resolved=i,e}async function Jx(e,t={}){e.force||await bb();let n=await _x(e);t.afterPackagesLoaded?.(n);let r=n.filter(e=>e.private).map(e=>e.name).filter(e=>e),i=e=>!r.includes(e.name),a=0,o=(e,n,r,i)=>{a++,t.onDependencyResolved?.(e,n,a,i)},s=cp(e.concurrency||10);return await Cx.run(s,()=>Promise.all(n.map(async n=>{t.beforePackageStart?.(n),await Yx(n,e,i,{...t,onDependencyResolved:o}),t.afterPackageEnd?.(n)}))),t.afterPackagesEnd?.(n),await xb(),{packages:n}}async function Yx(e,t,n=()=>!0,r={}){await qx(e,t,n,r.onDependencyResolved);let{resolved:i}=e,a=i.filter(e=>e.update);return t.write&&a.length&&await Promise.resolve(r.beforePackageWrite?.(e))!==!1&&(await hx(e,t),r.afterPackageWrite?.(e)),e}const Xx={RED:`\x1B[0;31m`,GREEN:`\x1B[0;32m`,YELLOW:`\x1B[1;33m`,BLUE:`\x1B[0;34m`,RESET:`\x1B[0m`};function Zx(e){return e.map(e=>{if(typeof e==`string`)return e;if(e instanceof Error)return e.message;try{return JSON.stringify(e)}catch{return String(e)}}).join(` `)}function $(...e){process.stdout.write(`${Zx(e)}\n`)}function Qx(...e){process.stderr.write(`${Zx(e)}\n`)}const $x=async()=>{let e=await op();return e?(e.source===`legacy-dev-tools`&&$(`提示: 经 lzi-dev.config.ts 共享读取依赖工具配置,建议补建 lzi-dependencies.config.ts`),e.config):($(`提示: 未找到配置文件 lzi-dependencies.config.ts,使用默认配置`),{})},eS=[`**/node_modules/**`,`**/oh_modules/**`,`**/target/**`,`**/dist/**`,`**/build/**`,`**/.turbo/**`],tS=e=>!e||e.length===0?eS:[...eS,...e],nS=pu({name:Al().optional(),workspaces:su().optional(),devDependencies:bu(Al(),Al()).optional()}),rS=async()=>{let e=process.cwd();$(`正在扫描 ${e} 下的 package.json 文件...`);let t=null;try{let n=nS.safeParse(await Bun.file(`${e}/package.json`).json());t=n.success?n.data:null}catch{t=null}t===null&&($(`未找到可解析的 workspace 根 package.json,请在仓库根目录执行本命令`),process.exit(1));let n=await $x(),r=tS(n.hoisting?.ignorePaths),i=new Set(n.hoisting?.allowlist??[]),a=t.devDependencies??{},o=await Yf(`**/package.json`,{cwd:e,ignore:r,onlyFiles:!0,dot:!1}),s=0,c=[];for(let t of o){if(t===`package.json`)continue;let n=null;try{let r=nS.safeParse(await Bun.file(`${e}/${t}`).json());n=r.success?r.data:null}catch{n=null}if(n===null||n.workspaces!==void 0)continue;let r=n.devDependencies??{};if(Object.keys(r).length!==0){s+=1;for(let[o,s]of Object.entries(r)){let r=a[o];r===void 0||i.has(o)||c.push({packageName:n.name??t,relPath:te(e,`${e}/${t}`),dependency:o,subRange:s,rootRange:r,drifted:s!==r})}}}if($(`找到 ${s} 个子包,根声明开发依赖 ${Object.keys(a).length} 项`),c.length===0)$(`所有子包均未重复声明根已有的开发依赖`);else{$(`
322
- 以下子包重复声明根已有的开发依赖:`);for(let e of c){let t=e.drifted?` 版本漂移`:``;$(` ${e.packageName} ${e.relPath}`),$(` ${e.dependency} 子声明 ${e.subRange} 根声明 ${e.rootRange}${t}`)}$(`共 ${c.length} 处重复声明,处置口径见 ADR 0036`),process.exit(1)}},iS=`@longzai-intelligence`,aS=async()=>{let e=process.env.npm_config_registry;process.env.npm_config_registry=`https://registry.npmjs.org/`;let t;try{t=await oS(void 0)}finally{e===void 0?delete process.env.npm_config_registry:process.env.npm_config_registry=e}let n=sS(t);$(`
323
- --- 检查结果 ---`);let r=0;if(r+=cS(t,new Set(n),!1),n.length>0){$(`\n回退基线:${n.length} 个内部包在 npm 无记录,按本机 registry 配置复查`);let e=await oS(n);r+=cS(e,new Set(n),!0)}r===0?$(`全部 Longzai Intelligence 包依赖均为最新版`):(Qx(`\n共 ${r} 个内部包依赖非最新版,修复指引: 在仓根执行 lzi-dependencies upgrade --write 或 bun run version:upgrade`),process.exit(Math.min(r,255)))},oS=async e=>{let t=(await $x()).upgrade??{},{packages:n}=await Jx({cwd:process.cwd(),mode:`latest`,write:!1,recursive:t.recursive??!0,timeout:t.timeout??3e4,retries:t.retries??3,exclude:t.exclude??[],include:e===void 0?t.include??[]:[...e],depFields:t.depFields,ignorePaths:t.ignorePaths??[],concurrency:t.concurrency??10,force:!1,all:!1,install:!1,update:!1,interactive:!1,group:!0,includeLocked:!1,timediff:!0,nodecompat:!0,loglevel:`silent`,silent:!0,failOnOutdated:!1},{afterPackagesLoaded:e=>{$(`扫描到 ${e.length} 个包,正在校验 Longzai Intelligence 依赖新鲜度...`)}});return n},sS=e=>{let t=/* @__PURE__ */ new Set;for(let n of e)for(let e of n.resolved)e.name.startsWith(iS)&&e.resolveError!=null&&t.add(e.name);return[...t]},cS=(e,t,n)=>{let r=0;for(let i of e){let e=i.resolved.filter(e=>!e.update||!e.name.startsWith(iS)?!1:n?t.has(e.name):!t.has(e.name));if(e.length!==0){r+=e.length,$(`\n${i.name||i.relative}:`);for(let t of e){let e=t.diff??``,r=n?`,回退基线`:``;$(` ${t.name}: ${t.currentVersion} -> ${t.targetVersion} ${e}${r}`)}}}return r},lS=`lzi-architecture.yaml`,uS=e=>Array.isArray(e)&&e.every(e=>typeof e==`string`),dS=e=>{if(typeof e!=`object`||!e||Array.isArray(e))return{};let t={};return`root`in e&&typeof e.root==`string`&&(t.root=e.root),`exclude`in e&&uS(e.exclude)&&(t.exclude=e.exclude),t},fS=async e=>{try{let t=await Bun.file(e).text();return dS(Bun.YAML.parse(t))}catch(t){Qx(`错误: 加载配置文件失败: ${e}`,t instanceof Error?t.message:String(t)),process.exit(1)}},pS=e=>typeof e!=`object`||!e||Array.isArray(e)?{}:`exclude`in e&&uS(e.exclude)?{exclude:e.exclude}:{},mS=e=>typeof e==`object`&&e&&`default`in e?e.default:void 0,hS=async e=>{if(e){let t=N(process.cwd(),e);T(t)||(Qx(`错误: 配置文件不存在: ${t}`),process.exit(1));let n=await fS(t);return{rootDir:N(j(t),n.root??`../`),exclude:n.exclude??[],source:`explicit`}}let t=process.env.LZI_GLOBALS_ROOT;if(t!==void 0&&t!==``){let e=M(N(t),`lzi-architecture.config.ts`);if(T(e))try{let n=pS(mS(await import(e)));return{rootDir:j(N(t)),exclude:n.exclude??[],source:`globals`}}catch(t){Qx(`错误: 加载 globals 聚合配置失败: ${e}`,t instanceof Error?t.message:String(t)),process.exit(1)}}let n=process.cwd();for(;n!==`/`;){let e=M(n,lS);if(T(e)){let t=await fS(e);return{rootDir:N(j(e),t.root??`../`),exclude:t.exclude??[],source:`yaml-upward`}}n=j(n)}return null},gS=(e,t)=>{let n;try{n=k(e)}catch{Qx(`错误: 无法读取聚合根目录: ${e}`),process.exit(1)}let r=new Set(t);return n.filter(e=>!(e.startsWith(`.`)||e===`node_modules`||r.has(e))).map(t=>{let n=M(e,t),r=M(n,`package.json`);try{if(A(n).isDirectory()&&T(r))return{name:t,dir:n}}catch{}return null}).filter(e=>e!==null)},_S=(e,t)=>Bun.spawnSync([`git`,`diff`,`--quiet`,`HEAD`,`--`,t],{cwd:e,stdout:`pipe`,stderr:`pipe`}).exitCode===0,vS=e=>{let t=e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);return RegExp(`("${t}/[^"]+":\\s*")[^"]*(")`,`g`)},yS=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),bS=e=>/^[~^]?\d/.test(e),xS=(e,t)=>`${/^[~^]/.exec(e)?.[0]??``}${t}`,SS=e=>{let t=Bun.spawnSync([`git`,`ls-files`,`--`,`*/package.json`],{cwd:e,stdout:`pipe`,stderr:`pipe`});return t.exitCode===0?[`package.json`,...(t.stdout?.toString()??``).trim().split(`
324
- `).map(e=>e.trim()).filter(e=>e.length>0).filter(t=>T(M(e,t)))]:[`package.json`]},CS=(e,t,n)=>Bun.spawnSync([`git`,`commit`,...t,`-m`,n],{cwd:e,stdout:`pipe`,stderr:`pipe`}).exitCode===0,wS=async(e,t,n)=>{let r=await Bun.file(e).text(),i=[],a=[],o=[],s;for(t.lastIndex=0;(s=t.exec(r))!==null;){let e=s[0],t=s[1]??``,r=s[2]??``,i=/^"([^"]+)"/.exec(t)?.[1]??``,a=e.slice(t.length,e.length-r.length),c=n(i,a);a!==c&&bS(a)&&o.push({name:i,oldVersion:a,targetVersion:c,prefix:t,suffix:r})}if(o.length===0)return{matchedPackages:i,changes:a};let c=r;for(let e of o){let t=RegExp(`("${yS(e.name)}":\\s*")[^"]*(")`);c=c.replace(t,`$1${e.targetVersion}$2`),i.push(e.name),a.push({name:e.name,from:e.oldVersion,to:e.targetVersion})}return await Bun.write(e,c),{matchedPackages:i,changes:a}},TS=async(e,t,n)=>{let r=await Bun.file(e).text(),i=[],a=[];t.lastIndex=0;let o;for(;(o=t.exec(r))!==null;){let e=o[0],t=o[1]??``,r=o[2]??``,s=/^"([^"]+)"/.exec(t)?.[1]??``,c=e.slice(t.length,e.length-r.length),l=n(s,c);c!==l&&bS(c)&&(i.push(s),a.push({name:s,from:c,to:l}))}return{matchedPackages:i,changes:a}},ES=async(e,t,n,r,i)=>{let{name:a,dir:o}=e,s=SS(o),c=[],l=[],u=[],d=[];for(let e of s){let r=M(o,e),a=await TS(r,t,n);if(a.matchedPackages.length!==0){if(!_S(o,e))u.push(e);else{if(i)c.push(...a.matchedPackages),l.push(...a.changes);else{let e=await wS(r,t,n);c.push(...e.matchedPackages),l.push(...e.changes)}d.push(e)}}}return d.length===0?u.length>0?{name:a,dir:o,matchedPackages:c,changes:l,skippedFiles:u,status:`skipped-dirty`,reason:`package.json 已有未提交改动:${u.join(`,`)}`}:{name:a,dir:o,matchedPackages:c,changes:l,status:`skipped-nochange`,reason:`无匹配 scope 或已是目标版本`}:i||CS(o,d,r)?{name:a,dir:o,matchedPackages:c,changes:l,skippedFiles:u,status:`success`}:{name:a,dir:o,matchedPackages:c,changes:l,skippedFiles:u,status:`failed`,reason:`git commit 失败,文件已修改,需人工介入`}},DS=async(e,t)=>{let n=/* @__PURE__ */ new Set;for(let r of e){let e=SS(r.dir);for(let i of e){let e=M(r.dir,i),a=await Bun.file(e).text();t.lastIndex=0;let o;for(;(o=t.exec(a))!==null;){let e=o[1]??``,t=/^"([^"]+)"/.exec(e)?.[1];t&&n.add(t)}}}return[...n]},OS=async(e,t)=>{let n=/* @__PURE__ */ new Map,r=[],i=0,a=async e=>{let t=await Sb(e),i=t.tags?.latest;if(i===void 0){let n=t.error instanceof Error?t.error.message:t.error??`未找到 dist-tags.latest`;r.push({name:e,reason:n})}else n.set(e,i)},o=async()=>{for(;i<e.length;){let t=e[i];i++,t!==void 0&&await a(t)}},s=Array.from({length:Math.min(t,e.length)},()=>o());if(await Promise.all(s),r.length>0){Qx(`${Xx.RED}错误: 部分包查询 npm latest 失败,已中止(0 文件改动、0 提交)${Xx.RESET}`);for(let e of r)Qx(` ${e.name}: ${e.reason}`);process.exit(1)}return n},kS=async e=>{let{scope:t,version:n,message:r,dryRun:i}=e,a=e.concurrency??10,o=await hS(e.config);o||(Qx(`错误: 未找到产品群配置文件 ${lS}`),Qx(`提示: 请在 architecture 项目创建该配置文件(参考 lzi-architecture.sample.yaml)`),Qx(`提示: 或使用 --config <path> 显式指定`),Qx(`提示: 或在 .env 设置 LZI_GLOBALS_ROOT 定位 globals 仓 TS 配置(ADR 0081)`),process.exit(1));let s=o.rootDir;T(s)||(Qx(`错误: 聚合根目录不存在: ${s}`),process.exit(1));let c=o.exclude,l=n===void 0,u=l?`latest(各自 npm 最新)`:n,d=r??(l?`chore: bump ${t} deps to latest`:`chore: bump ${t} deps to ${n.replace(/^[~^]/,``)}`),f=vS(t);$(`${Xx.BLUE}═══ version upgrade-across ═══${Xx.RESET}`),$(`聚合配置来源: ${o.source}(--config 显式 / env globals / cwd 上溯 yaml)`),$(`聚合根: ${s}`),$(`升级范围: ${t} 下的所有包 -> ${u}`),$(`并发数: ${a}`),c.length>0&&$(`排除项目: ${c.join(`, `)}`),i&&$(`${Xx.YELLOW}[dry-run] 预览模式,不写文件、不提交${Xx.RESET}`),$(``);let p=gS(s,c);$(`发现 ${p.length} 个子项目,并发处理(并发 ${a})...`),$(``);let m;if(l){let e=await DS(p,f);if(e.length===0){$(`${Xx.YELLOW}未匹配到任何 ${t} 下的包,结束${Xx.RESET}`);return}$(`匹配到 ${e.length} 个 ${t} 下的包,查询 npm latest...`);let n=await OS(e,a);m=(e,t)=>xS(t,n.get(e)??``)}else{let e=n??``;m=()=>e}let h=[],g=0,_=p.length;await(async(e,t)=>{let n=0,r=async()=>{for(;n<e.length;){let t=e[n];if(n++,t===void 0)break;let r=await ES(t,f,m,d,i);h.push(r),g++;let a=r.status===`success`?`${Xx.GREEN}✓${Xx.RESET}`:r.status===`failed`?`${Xx.RED}✗${Xx.RESET}`:`·`;$(` [${g}/${_}] ${a} ${t.name}`)}},a=Array.from({length:Math.min(t,e.length)},()=>r());await Promise.all(a)})(p,a),$(``),AS(h,i)},AS=(e,t)=>{let n=e.filter(e=>e.status===`success`),r=e.filter(e=>e.status===`skipped-dirty`),i=e.filter(e=>e.status===`skipped-nochange`),a=e.filter(e=>e.status===`failed`);$(`${Xx.BLUE}═══ 处理结果 ═══${Xx.RESET}`);let o=t?`将提交`:`已提交`;$(`${Xx.GREEN}✓ ${o}: ${n.length}${Xx.RESET}`);for(let e of n){let t=e.changes.map(e=>`${e.name.split(`/`).pop()}: ${e.from} → ${e.to}`).join(`, `);$(` ${e.name}`),$(` ${t}`),e.skippedFiles!==void 0&&e.skippedFiles.length>0&&$(` ⚠ 脏文件跳过:${e.skippedFiles.join(`,`)}`)}if(r.length>0){$(``),$(`${Xx.YELLOW}⚠ 跳过(文件已改动): ${r.length}${Xx.RESET}`);for(let e of r)$(` ${e.name}: ${e.reason}`)}if(i.length>0&&($(``),$(`跳过(无匹配/已是目标版本): ${i.length}`)),a.length>0){$(``),$(`${Xx.RED}✗ 失败(需人工介入): ${a.length}${Xx.RESET}`);for(let e of a)$(` ${e.name}: ${e.reason}`),$(` ${e.changes.map(e=>`${e.name.split(`/`).pop()}: ${e.from} → ${e.to}`).join(`, `)}`)}$(``),$(`${Xx.BLUE}汇总: ${n.length} ${o} / ${r.length} 跳过(dirty) / ${i.length} 跳过(无变更) / ${a.length} 失败${Xx.RESET}`),!t&&n.length>0&&($(``),$(`下一步:推送到远程`),$(` bun push-all`)),a.length>0&&(process.exitCode=1)},jS=Su([`default`,`major`,`minor`,`patch`,`latest`,`newest`]).default(`default`),MS=async e=>{let t=(await $x()).upgrade??{},n=e.mode||t.mode||`default`,r=jS.safeParse(n),i=r.success?r.data:`default`,a=[...e.scope?[`${e.scope}/*`]:[],...t.include??[]],{packages:o}=await Jx({cwd:process.cwd(),mode:i,write:!e.dryRun&&e.write,recursive:t.recursive??!0,timeout:t.timeout??3e4,retries:t.retries??3,exclude:t.exclude??[],include:a,depFields:t.depFields,ignorePaths:t.ignorePaths??[],concurrency:t.concurrency??10,force:!1,all:!1,install:!1,update:!1,interactive:!1,group:!0,includeLocked:!1,timediff:!0,nodecompat:!0,loglevel:`info`,silent:!1,failOnOutdated:!1},{afterPackagesLoaded:e=>{$(`扫描到 ${e.length} 个包,正在检查依赖更新...`)},beforePackageStart:e=>{$(`正在检查 ${e.name||e.relative}...`)},afterPackageEnd:e=>{let t=e.resolved.filter(e=>e.update).length;$(t>0?` ✓ ${e.name||e.relative}: 发现 ${t} 个可更新依赖`:` ✓ ${e.name||e.relative}: 所有依赖已是最新`)},afterPackageWrite:e=>{$(` 📝 已写入 ${e.name||e.relative}`)}}),s=0;$(`
325
- --- 检查结果 ---`);for(let e of o){let t=e.resolved.filter(e=>e.update);if(t.length>0){s+=t.length,$(`\n${e.name||e.relative}:`);for(let e of t){let t=e.diff??``;$(` ${e.name}: ${e.currentVersion} -> ${e.targetVersion} (${t})`)}}}s===0?$(`所有依赖已是最新版本`):($(`\n共发现 ${s} 个可更新依赖`),e.write?$(`已写入 package.json`):$(`使用 --write 参数写入 package.json`))};function NS(e){cd(e,{name:`upgrade`,description:`检查依赖版本更新`,arguments:[{signature:`[mode]`,description:`升级模式(major/minor/patch/latest/newest)`},{signature:`[scope]`,description:`可选。仅升级指定 scope 下的依赖(如 @longzai-intelligence-oxlint),内部展开为 include @scope/*`}],options:[{flags:`--write`,description:`将更新写入 package.json`},{flags:`--dry-run`,description:`仅预览`}],schema:mu({write:au().optional(),dryRun:au().optional()}),action:async(e,t)=>{let n=t[0],r=t[1];await MS({mode:n,write:e.write===!0,dryRun:e.dryRun===!0,scope:r})}}),cd(e,{name:`upgrade-across`,description:`跨产品群批量升级依赖(读 lzi-architecture.yaml)`,options:[{flags:`--scope <scope>`,description:`依赖 scope(必填,如 @longzai-intelligence-builder)`},{flags:`--target <version>`,description:`目标版本号(可选,如 ^0.0.8。省略时自动取每个匹配包的 npm latest)`},{flags:`-m, --message <message>`,description:`自定义提交信息`},{flags:`--config <path>`,description:`配置文件路径(显式指定,覆盖自动查找)`},{flags:`--concurrency <n>`,description:`并发数(默认 10)`},{flags:`--dry-run`,description:`仅预览(不写文件、不提交)`}],schema:mu({scope:Al().optional(),target:Al().optional(),message:Al().optional(),config:Al().optional(),concurrency:Ku().int().positive().optional(),dryRun:au().optional()}),action:async e=>{e.scope||(process.stderr.write(`错误: upgrade-across 需要指定 --scope <@scope>
322
+ 以下子包重复声明根已有的开发依赖:`);for(let e of c){let t=e.drifted?` 版本漂移`:``;$(` ${e.packageName} ${e.relPath}`),$(` ${e.dependency} 子声明 ${e.subRange} 根声明 ${e.rootRange}${t}`)}$(`共 ${c.length} 处重复声明,处置口径见 ADR 0036`),process.exit(1)}},iS=pu({name:Al().optional(),overrides:bu(Al(),su()).optional(),pnpm:pu({overrides:bu(Al(),su()).optional()}).optional(),resolutions:bu(Al(),su()).optional()}),aS=e=>typeof e==`string`?e:`嵌套对象`,oS=async()=>{let e=process.cwd();$(`正在扫描 ${e} 下的 package.json 文件...`);let t=null;try{let n=iS.safeParse(await Bun.file(`${e}/package.json`).json());t=n.success?n.data:null}catch{t=null}t===null&&($(`未找到可解析的仓库根 package.json,请在仓库根目录执行本命令`),process.exit(1));let n=await $x(),r=tS(n.overrides?.ignorePaths),i=new Set(n.overrides?.allowlist??[]),a=await Yf(`**/package.json`,{cwd:e,ignore:r,onlyFiles:!0,dot:!1}),o=0,s=[];for(let t of a){let n=null;try{let r=iS.safeParse(await Bun.file(`${e}/${t}`).json());n=r.success?r.data:null}catch{n=null}if(n===null)continue;o+=1;let r=[[`overrides`,n.overrides??{}],[`pnpm.overrides`,n.pnpm?.overrides??{}],[`resolutions`,n.resolutions??{}]];for(let[a,o]of r)for(let[r,c]of Object.entries(o))i.has(r)||s.push({packageName:n.name??t,relPath:te(e,`${e}/${t}`),field:a,entry:r,value:aS(c)})}if($(`扫描到 ${o} 个清单,登记豁免条目 ${i.size} 项`),s.length===0)$(`全部清单均未声明未豁免的 overrides 族强制版本字段`);else{$(`
323
+ 以下清单声明了未豁免的 overrides 族强制版本字段:`);for(let e of s)$(` ${e.packageName} ${e.relPath}`),$(` ${e.field} ${e.entry} ${e.value}`);$(`共 ${s.length} 处强制版本条目,处置口径见 ADR 0153,豁免须经特别申请登记于 lzi-dependencies.config.ts 的 overrides.allowlist`),process.exit(1)}},sS=`@longzai-intelligence`,cS=async()=>{let e=process.env.npm_config_registry;process.env.npm_config_registry=`https://registry.npmjs.org/`;let t;try{t=await lS(void 0)}finally{e===void 0?delete process.env.npm_config_registry:process.env.npm_config_registry=e}let n=uS(t);$(`
324
+ --- 检查结果 ---`);let r=0;if(r+=dS(t,new Set(n),!1),n.length>0){$(`\n回退基线:${n.length} 个内部包在 npm 无记录,按本机 registry 配置复查`);let e=await lS(n);r+=dS(e,new Set(n),!0)}r===0?$(`全部 Longzai Intelligence 包依赖均为最新版`):(Qx(`\n共 ${r} 个内部包依赖非最新版,修复指引: 在仓根执行 lzi-dependencies upgrade --write 或 bun run version:upgrade`),process.exit(Math.min(r,255)))},lS=async e=>{let t=(await $x()).upgrade??{},{packages:n}=await Jx({cwd:process.cwd(),mode:`latest`,write:!1,recursive:t.recursive??!0,timeout:t.timeout??3e4,retries:t.retries??3,exclude:t.exclude??[],include:e===void 0?t.include??[]:[...e],depFields:t.depFields,ignorePaths:t.ignorePaths??[],concurrency:t.concurrency??10,force:!1,all:!1,install:!1,update:!1,interactive:!1,group:!0,includeLocked:!1,timediff:!0,nodecompat:!0,loglevel:`silent`,silent:!0,failOnOutdated:!1},{afterPackagesLoaded:e=>{$(`扫描到 ${e.length} 个包,正在校验 Longzai Intelligence 依赖新鲜度...`)}});return n},uS=e=>{let t=/* @__PURE__ */ new Set;for(let n of e)for(let e of n.resolved)e.name.startsWith(sS)&&e.resolveError!=null&&t.add(e.name);return[...t]},dS=(e,t,n)=>{let r=0;for(let i of e){let e=i.resolved.filter(e=>!e.update||!e.name.startsWith(sS)?!1:n?t.has(e.name):!t.has(e.name));if(e.length!==0){r+=e.length,$(`\n${i.name||i.relative}:`);for(let t of e){let e=t.diff??``,r=n?`,回退基线`:``;$(` ${t.name}: ${t.currentVersion} -> ${t.targetVersion} ${e}${r}`)}}}return r},fS=`lzi-architecture.yaml`,pS=e=>Array.isArray(e)&&e.every(e=>typeof e==`string`),mS=e=>{if(typeof e!=`object`||!e||Array.isArray(e))return{};let t={};return`root`in e&&typeof e.root==`string`&&(t.root=e.root),`exclude`in e&&pS(e.exclude)&&(t.exclude=e.exclude),t},hS=async e=>{try{let t=await Bun.file(e).text();return mS(Bun.YAML.parse(t))}catch(t){Qx(`错误: 加载配置文件失败: ${e}`,t instanceof Error?t.message:String(t)),process.exit(1)}},gS=e=>typeof e!=`object`||!e||Array.isArray(e)?{}:`exclude`in e&&pS(e.exclude)?{exclude:e.exclude}:{},_S=e=>typeof e==`object`&&e&&`default`in e?e.default:void 0,vS=async e=>{if(e){let t=N(process.cwd(),e);T(t)||(Qx(`错误: 配置文件不存在: ${t}`),process.exit(1));let n=await hS(t);return{rootDir:N(j(t),n.root??`../`),exclude:n.exclude??[],source:`explicit`}}let t=process.env.LZI_GLOBALS_ROOT;if(t!==void 0&&t!==``){let e=M(N(t),`lzi-architecture.config.ts`);if(T(e))try{let n=gS(_S(await import(e)));return{rootDir:j(N(t)),exclude:n.exclude??[],source:`globals`}}catch(t){Qx(`错误: 加载 globals 聚合配置失败: ${e}`,t instanceof Error?t.message:String(t)),process.exit(1)}}let n=process.cwd();for(;n!==`/`;){let e=M(n,fS);if(T(e)){let t=await hS(e);return{rootDir:N(j(e),t.root??`../`),exclude:t.exclude??[],source:`yaml-upward`}}n=j(n)}return null},yS=(e,t)=>{let n;try{n=k(e)}catch{Qx(`错误: 无法读取聚合根目录: ${e}`),process.exit(1)}let r=new Set(t);return n.filter(e=>!(e.startsWith(`.`)||e===`node_modules`||r.has(e))).map(t=>{let n=M(e,t),r=M(n,`package.json`);try{if(A(n).isDirectory()&&T(r))return{name:t,dir:n}}catch{}return null}).filter(e=>e!==null)},bS=(e,t)=>Bun.spawnSync([`git`,`diff`,`--quiet`,`HEAD`,`--`,t],{cwd:e,stdout:`pipe`,stderr:`pipe`}).exitCode===0,xS=e=>{let t=e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);return RegExp(`("${t}/[^"]+":\\s*")[^"]*(")`,`g`)},SS=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),CS=e=>/^[~^]?\d/.test(e),wS=(e,t)=>`${/^[~^]/.exec(e)?.[0]??``}${t}`,TS=e=>{let t=Bun.spawnSync([`git`,`ls-files`,`--`,`*/package.json`],{cwd:e,stdout:`pipe`,stderr:`pipe`});return t.exitCode===0?[`package.json`,...(t.stdout?.toString()??``).trim().split(`
325
+ `).map(e=>e.trim()).filter(e=>e.length>0).filter(t=>T(M(e,t)))]:[`package.json`]},ES=(e,t,n)=>Bun.spawnSync([`git`,`commit`,...t,`-m`,n],{cwd:e,stdout:`pipe`,stderr:`pipe`}).exitCode===0,DS=async(e,t,n)=>{let r=await Bun.file(e).text(),i=[],a=[],o=[],s;for(t.lastIndex=0;(s=t.exec(r))!==null;){let e=s[0],t=s[1]??``,r=s[2]??``,i=/^"([^"]+)"/.exec(t)?.[1]??``,a=e.slice(t.length,e.length-r.length),c=n(i,a);a!==c&&CS(a)&&o.push({name:i,oldVersion:a,targetVersion:c,prefix:t,suffix:r})}if(o.length===0)return{matchedPackages:i,changes:a};let c=r;for(let e of o){let t=RegExp(`("${SS(e.name)}":\\s*")[^"]*(")`);c=c.replace(t,`$1${e.targetVersion}$2`),i.push(e.name),a.push({name:e.name,from:e.oldVersion,to:e.targetVersion})}return await Bun.write(e,c),{matchedPackages:i,changes:a}},OS=async(e,t,n)=>{let r=await Bun.file(e).text(),i=[],a=[];t.lastIndex=0;let o;for(;(o=t.exec(r))!==null;){let e=o[0],t=o[1]??``,r=o[2]??``,s=/^"([^"]+)"/.exec(t)?.[1]??``,c=e.slice(t.length,e.length-r.length),l=n(s,c);c!==l&&CS(c)&&(i.push(s),a.push({name:s,from:c,to:l}))}return{matchedPackages:i,changes:a}},kS=async(e,t,n,r,i)=>{let{name:a,dir:o}=e,s=TS(o),c=[],l=[],u=[],d=[];for(let e of s){let r=M(o,e),a=await OS(r,t,n);if(a.matchedPackages.length!==0){if(!bS(o,e))u.push(e);else{if(i)c.push(...a.matchedPackages),l.push(...a.changes);else{let e=await DS(r,t,n);c.push(...e.matchedPackages),l.push(...e.changes)}d.push(e)}}}return d.length===0?u.length>0?{name:a,dir:o,matchedPackages:c,changes:l,skippedFiles:u,status:`skipped-dirty`,reason:`package.json 已有未提交改动:${u.join(`,`)}`}:{name:a,dir:o,matchedPackages:c,changes:l,status:`skipped-nochange`,reason:`无匹配 scope 或已是目标版本`}:i||ES(o,d,r)?{name:a,dir:o,matchedPackages:c,changes:l,skippedFiles:u,status:`success`}:{name:a,dir:o,matchedPackages:c,changes:l,skippedFiles:u,status:`failed`,reason:`git commit 失败,文件已修改,需人工介入`}},AS=async(e,t)=>{let n=/* @__PURE__ */ new Set;for(let r of e){let e=TS(r.dir);for(let i of e){let e=M(r.dir,i),a=await Bun.file(e).text();t.lastIndex=0;let o;for(;(o=t.exec(a))!==null;){let e=o[1]??``,t=/^"([^"]+)"/.exec(e)?.[1];t&&n.add(t)}}}return[...n]},jS=async(e,t)=>{let n=/* @__PURE__ */ new Map,r=[],i=0,a=async e=>{let t=await Sb(e),i=t.tags?.latest;if(i===void 0){let n=t.error instanceof Error?t.error.message:t.error??`未找到 dist-tags.latest`;r.push({name:e,reason:n})}else n.set(e,i)},o=async()=>{for(;i<e.length;){let t=e[i];i++,t!==void 0&&await a(t)}},s=Array.from({length:Math.min(t,e.length)},()=>o());if(await Promise.all(s),r.length>0){Qx(`${Xx.RED}错误: 部分包查询 npm latest 失败,已中止(0 文件改动、0 提交)${Xx.RESET}`);for(let e of r)Qx(` ${e.name}: ${e.reason}`);process.exit(1)}return n},MS=async e=>{let{scope:t,version:n,message:r,dryRun:i}=e,a=e.concurrency??10,o=await vS(e.config);o||(Qx(`错误: 未找到产品群配置文件 ${fS}`),Qx(`提示: 请在 architecture 项目创建该配置文件(参考 lzi-architecture.sample.yaml)`),Qx(`提示: 或使用 --config <path> 显式指定`),Qx(`提示: 或在 .env 设置 LZI_GLOBALS_ROOT 定位 globals 仓 TS 配置(ADR 0081)`),process.exit(1));let s=o.rootDir;T(s)||(Qx(`错误: 聚合根目录不存在: ${s}`),process.exit(1));let c=o.exclude,l=n===void 0,u=l?`latest(各自 npm 最新)`:n,d=r??(l?`chore: bump ${t} deps to latest`:`chore: bump ${t} deps to ${n.replace(/^[~^]/,``)}`),f=xS(t);$(`${Xx.BLUE}═══ version upgrade-across ═══${Xx.RESET}`),$(`聚合配置来源: ${o.source}(--config 显式 / env globals / cwd 上溯 yaml)`),$(`聚合根: ${s}`),$(`升级范围: ${t} 下的所有包 -> ${u}`),$(`并发数: ${a}`),c.length>0&&$(`排除项目: ${c.join(`, `)}`),i&&$(`${Xx.YELLOW}[dry-run] 预览模式,不写文件、不提交${Xx.RESET}`),$(``);let p=yS(s,c);$(`发现 ${p.length} 个子项目,并发处理(并发 ${a})...`),$(``);let m;if(l){let e=await AS(p,f);if(e.length===0){$(`${Xx.YELLOW}未匹配到任何 ${t} 下的包,结束${Xx.RESET}`);return}$(`匹配到 ${e.length} 个 ${t} 下的包,查询 npm latest...`);let n=await jS(e,a);m=(e,t)=>wS(t,n.get(e)??``)}else{let e=n??``;m=()=>e}let h=[],g=0,_=p.length;await(async(e,t)=>{let n=0,r=async()=>{for(;n<e.length;){let t=e[n];if(n++,t===void 0)break;let r=await kS(t,f,m,d,i);h.push(r),g++;let a=r.status===`success`?`${Xx.GREEN}✓${Xx.RESET}`:r.status===`failed`?`${Xx.RED}✗${Xx.RESET}`:`·`;$(` [${g}/${_}] ${a} ${t.name}`)}},a=Array.from({length:Math.min(t,e.length)},()=>r());await Promise.all(a)})(p,a),$(``),NS(h,i)},NS=(e,t)=>{let n=e.filter(e=>e.status===`success`),r=e.filter(e=>e.status===`skipped-dirty`),i=e.filter(e=>e.status===`skipped-nochange`),a=e.filter(e=>e.status===`failed`);$(`${Xx.BLUE}═══ 处理结果 ═══${Xx.RESET}`);let o=t?`将提交`:`已提交`;$(`${Xx.GREEN}✓ ${o}: ${n.length}${Xx.RESET}`);for(let e of n){let t=e.changes.map(e=>`${e.name.split(`/`).pop()}: ${e.from} → ${e.to}`).join(`, `);$(` ${e.name}`),$(` ${t}`),e.skippedFiles!==void 0&&e.skippedFiles.length>0&&$(` ⚠ 脏文件跳过:${e.skippedFiles.join(`,`)}`)}if(r.length>0){$(``),$(`${Xx.YELLOW}⚠ 跳过(文件已改动): ${r.length}${Xx.RESET}`);for(let e of r)$(` ${e.name}: ${e.reason}`)}if(i.length>0&&($(``),$(`跳过(无匹配/已是目标版本): ${i.length}`)),a.length>0){$(``),$(`${Xx.RED}✗ 失败(需人工介入): ${a.length}${Xx.RESET}`);for(let e of a)$(` ${e.name}: ${e.reason}`),$(` ${e.changes.map(e=>`${e.name.split(`/`).pop()}: ${e.from} → ${e.to}`).join(`, `)}`)}$(``),$(`${Xx.BLUE}汇总: ${n.length} ${o} / ${r.length} 跳过(dirty) / ${i.length} 跳过(无变更) / ${a.length} 失败${Xx.RESET}`),!t&&n.length>0&&($(``),$(`下一步:推送到远程`),$(` bun push-all`)),a.length>0&&(process.exitCode=1)},PS=Su([`default`,`major`,`minor`,`patch`,`latest`,`newest`]).default(`default`),FS=async e=>{let t=(await $x()).upgrade??{},n=e.mode||t.mode||`default`,r=PS.safeParse(n),i=r.success?r.data:`default`,a=[...e.scope?[`${e.scope}/*`]:[],...t.include??[]],{packages:o}=await Jx({cwd:process.cwd(),mode:i,write:!e.dryRun&&e.write,recursive:t.recursive??!0,timeout:t.timeout??3e4,retries:t.retries??3,exclude:t.exclude??[],include:a,depFields:t.depFields,ignorePaths:t.ignorePaths??[],concurrency:t.concurrency??10,force:!1,all:!1,install:!1,update:!1,interactive:!1,group:!0,includeLocked:!1,timediff:!0,nodecompat:!0,loglevel:`info`,silent:!1,failOnOutdated:!1},{afterPackagesLoaded:e=>{$(`扫描到 ${e.length} 个包,正在检查依赖更新...`)},beforePackageStart:e=>{$(`正在检查 ${e.name||e.relative}...`)},afterPackageEnd:e=>{let t=e.resolved.filter(e=>e.update).length;$(t>0?` ✓ ${e.name||e.relative}: 发现 ${t} 个可更新依赖`:` ✓ ${e.name||e.relative}: 所有依赖已是最新`)},afterPackageWrite:e=>{$(` 📝 已写入 ${e.name||e.relative}`)}}),s=0;$(`
326
+ --- 检查结果 ---`);for(let e of o){let t=e.resolved.filter(e=>e.update);if(t.length>0){s+=t.length,$(`\n${e.name||e.relative}:`);for(let e of t){let t=e.diff??``;$(` ${e.name}: ${e.currentVersion} -> ${e.targetVersion} (${t})`)}}}s===0?$(`所有依赖已是最新版本`):($(`\n共发现 ${s} 个可更新依赖`),e.write?$(`已写入 package.json`):$(`使用 --write 参数写入 package.json`))};function IS(e){cd(e,{name:`upgrade`,description:`检查依赖版本更新`,arguments:[{signature:`[mode]`,description:`升级模式(major/minor/patch/latest/newest)`},{signature:`[scope]`,description:`可选。仅升级指定 scope 下的依赖(如 @longzai-intelligence-oxlint),内部展开为 include @scope/*`}],options:[{flags:`--write`,description:`将更新写入 package.json`},{flags:`--dry-run`,description:`仅预览`}],schema:mu({write:au().optional(),dryRun:au().optional()}),action:async(e,t)=>{let n=t[0],r=t[1];await FS({mode:n,write:e.write===!0,dryRun:e.dryRun===!0,scope:r})}}),cd(e,{name:`upgrade-across`,description:`跨产品群批量升级依赖(读 lzi-architecture.yaml)`,options:[{flags:`--scope <scope>`,description:`依赖 scope(必填,如 @longzai-intelligence-builder)`},{flags:`--target <version>`,description:`目标版本号(可选,如 ^0.0.8。省略时自动取每个匹配包的 npm latest)`},{flags:`-m, --message <message>`,description:`自定义提交信息`},{flags:`--config <path>`,description:`配置文件路径(显式指定,覆盖自动查找)`},{flags:`--concurrency <n>`,description:`并发数(默认 10)`},{flags:`--dry-run`,description:`仅预览(不写文件、不提交)`}],schema:mu({scope:Al().optional(),target:Al().optional(),message:Al().optional(),config:Al().optional(),concurrency:Ku().int().positive().optional(),dryRun:au().optional()}),action:async e=>{e.scope||(process.stderr.write(`错误: upgrade-across 需要指定 --scope <@scope>
326
327
  `),process.stderr.write(`示例: --scope @longzai-intelligence-builder
327
- `),process.exit(1)),await kS({scope:e.scope,version:e.target,message:e.message,config:e.config,concurrency:e.concurrency,dryRun:e.dryRun===!0})}}),cd(e,{name:`check`,description:`校验全部 Longzai Intelligence 包依赖是否为 registry 最新版`,schema:mu({}),action:async()=>{await aS()}})}function PS(e){cd(e,{name:`hoisting check`,description:`检查子包开发依赖是否重复声明 workspace 根已有依赖`,schema:mu({}),action:async()=>{await rS()}})}$t({transport:{target:`pino/file`,options:{destination:2}}});function FS(){let e=rd({name:`lzi-dependencies`,description:`Longzai Intelligence 依赖版本管理工具`,version:`0.0.7`});return NS(e),PS(e),e}async function IS(){await FS().parseAsync(process.argv)}import.meta.main===!0&&await IS();export{FS as buildProgram};
328
+ `),process.exit(1)),await MS({scope:e.scope,version:e.target,message:e.message,config:e.config,concurrency:e.concurrency,dryRun:e.dryRun===!0})}}),cd(e,{name:`check`,description:`校验全部 Longzai Intelligence 包依赖是否为 registry 最新版`,schema:mu({}),action:async()=>{await cS()}})}function LS(e){cd(e,{name:`hoisting check`,description:`检查子包开发依赖是否重复声明 workspace 根已有依赖`,schema:mu({}),action:async()=>{await rS()}})}function RS(e){cd(e,{name:`overrides check`,description:`检查 package.json 是否声明未豁免的强制版本字段`,schema:mu({}),action:async()=>{await oS()}})}$t({transport:{target:`pino/file`,options:{destination:2}}});function zS(){let e=rd({name:`lzi-dependencies`,description:`Longzai Intelligence 依赖版本管理工具`,version:`0.0.8`});return IS(e),LS(e),RS(e),e}async function BS(){await zS().parseAsync(process.argv)}import.meta.main===!0&&await BS();export{zS as buildProgram};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longzai-intelligence-dependencies/cli",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "description": "Longzai Intelligence 依赖版本管理 CLI(bin lzi-dependencies)",
5
5
  "keywords": [
6
6
  "cli",
@@ -39,7 +39,7 @@
39
39
  },
40
40
  "dependencies": {
41
41
  "@longzai-intelligence-cli/core": "^0.0.12",
42
- "@longzai-intelligence-dependencies/core": "0.0.7",
42
+ "@longzai-intelligence-dependencies/core": "0.0.8",
43
43
  "@longzai-intelligence-logger/node": "^0.1.5"
44
44
  }
45
45
  }