@longzai-intelligence-bun/cli 0.1.1 → 0.1.2

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 +11 -11
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -30,7 +30,7 @@ if(e&&e.length===3){let n=/^\s*/.exec(t)[0].length+4,a=` `.repeat(n),c=e[2],l=JS
30
30
  t===!0&&Array.prototype.push.apply(g,n);let _=``,{plain:v,errors:y}=Object.entries(e).reduce(({plain:t,errors:n},[r,i])=>{if(g.includes(r)===!1){let a=typeof d[r]==`function`?d[r](i,r,e,{colors:h.colors}):i;f.includes(r)?n[r]=a:t[r]=a}return{plain:t,errors:n}},{plain:{},errors:{}});return m?
31
31
  /* istanbul ignore else */
32
32
  (Object.keys(v).length>0&&(_+=p.greyMessage(r(v))),_+=l,_=_.replace(/\\\\/gi,`\\`)):Object.entries(v).forEach(([e,t])=>{let n=typeof d[e]==`function`?t:r(t,null,2);if(n===void 0)return;n=n.replace(/\\\\/gi,`\\`);let a=i({input:n,ident:u,eol:l}),s=o(e);_+=`${u}${p.property(s)}:${a.startsWith(l)?``:` `}${a}${l}`}),Object.entries(y).forEach(([e,t])=>{let n=typeof d[e]==`function`,i=n?t:r(t,null,2);i!==void 0&&(_+=a({keyName:e,lines:i,eol:l,ident:u,sanitizeStack:!n}))}),_}})),At=/* @__PURE__ */ M(((e,t)=>{t.exports=s;let{LOGGER_KEYS:n}=at(),r=Ct(),i=wt(),a=kt(),o=Dt();function s({log:e,context:t}){let{EOL:s,IDENT:c,errorProps:l,messageKey:u}=t,d=o(e.stack),f=`${c}${i({input:d,ident:c,eol:s})}${s}`;if(l.length>0){let i=n.concat(u,`type`,`stack`),d;d=l[0]===`*`?Object.keys(e).filter(e=>i.includes(e)===!1):l.filter(e=>i.includes(e)===!1);for(let n=0;n<d.length;n+=1){let i=d[n];if(!(i in e))continue;let l=o(i);if(r(e[i])){let n=a({log:e[i],excludeLoggerKeys:!1,context:{...t,IDENT:c+c}});f=`${f}${c}${l}: {${s}${n}${c}}${s}`;continue}let u=o(e[i]);f=`${f}${c}${l}: ${u}${s}`}}return f}})),jt=/* @__PURE__ */ M(((e,t)=>{t.exports=r;let n=mt();function r({log:e,context:t}){let{colorizer:r,customLevels:i,customLevelNames:a,levelKey:o,getLevelLabelData:s}=t,c=t.customPrettifiers?.level,l=n(e,o);if(l===void 0)return;let u=r(l,{customLevels:i,customLevelNames:a});if(c){let[t]=s(l);return c(l,o,e,{label:t,labelColorized:u,colors:r.colors})}return u}})),Mt=/* @__PURE__ */ M(((e,t)=>{t.exports=o;let{LEVELS:n}=at(),r=mt(),i=St(),a=Dt();function o({log:e,context:t}){let{colorizer:o,customLevels:s,levelKey:c,levelLabel:l,messageFormat:u,messageKey:d,useOnlyCustomProps:f}=t;if(u&&typeof u==`string`){let t=i(u,e),d=String(t).replace(/{([^{}]+)}/g,function(t,i){let a;if(i===l&&(a=r(e,c))!==void 0)return(f?s===void 0:s[a]===void 0)?n[a]:s[a];let o=r(e,i);return o===void 0?``:o});return o.message(a(d))}if(u&&typeof u==`function`){let t=u(e,d,l,{colors:o.colors});return o.message(t)}if(d in e&&(typeof e[d]==`string`||typeof e[d]==`number`||typeof e[d]==`boolean`))return o.message(a(e[d]))}})),Nt=/* @__PURE__ */ M(((e,t)=>{t.exports=r;let n=Dt();function r({log:e,context:t}){let{customPrettifiers:r,colorizer:i}=t,a=``;if(e.name||e.pid||e.hostname){if(a+=`(`,e.name&&(a+=r.name?r.name(e.name,`name`,e,{colors:i.colors}):n(e.name)),e.pid){let t=r.pid?r.pid(e.pid,`pid`,e,{colors:i.colors}):n(e.pid);e.name&&e.pid?a+=`/`+t:a+=t}if(e.hostname){let t=r.hostname?r.hostname(e.hostname,`hostname`,e,{colors:i.colors}):n(e.hostname);a+=`${a===`(`?`on`:` on`} ${t}`}a+=`)`}if(e.caller){let t=r.caller?r.caller(e.caller,`caller`,e,{colors:i.colors}):n(e.caller);a+=`${a===``?``:` `}<${t}>`}if(a!==``)return a}})),Pt=/* @__PURE__ */ M(((e,t)=>{t.exports=i;let n=yt(),r=Dt();function i({log:e,context:t}){let{timestampKey:i,translateTime:a}=t,o=t.customPrettifiers?.time,s=null;if(i in e?s=e[i]:`timestamp`in e&&(s=e.timestamp),s===null)return;let c=a?n(s,a):s;return o?o(c):`[${r(c)}]`}})),Ft=/* @__PURE__ */ M(((e,t)=>{t.exports={buildSafeSonicBoom:ut(),createDate:ft(),deleteLogProperty:ht(),filterLog:_t(),formatTime:yt(),getPropertyValue:mt(),handleCustomLevelsNamesOpts:bt(),handleCustomLevelsOpts:xt(),interpretConditionals:St(),isObject:Ct(),isValidDate:dt(),joinLinesWithIndentation:wt(),noop:lt(),parseFactoryOptions:Tt(),prettifyErrorLog:At(),prettifyError:Ot(),prettifyLevel:jt(),prettifyMessage:Mt(),prettifyMetadata:Nt(),prettifyObject:kt(),prettifyTime:Pt(),splitPropertyKey:pt(),stripUnsafeControlChars:Dt(),getLevelLabelData:ot()}})),It=/* @__PURE__ */ M(((e,t)=>{let n=typeof Buffer<`u`,r=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,i=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;function a(e,t,a){a==null&&typeof t==`object`&&t&&(a=t,t=void 0),n&&Buffer.isBuffer(e)&&(e=e.toString()),e&&e.charCodeAt(0)===65279&&(e=e.slice(1));let s=JSON.parse(e,t);if(typeof s!=`object`||!s)return s;let c=a&&a.protoAction||`error`,l=a&&a.constructorAction||`error`;if(c===`ignore`&&l===`ignore`)return s;if(c!==`ignore`&&l!==`ignore`){if(r.test(e)===!1&&i.test(e)===!1)return s}else if(c!==`ignore`&&l===`ignore`){if(r.test(e)===!1)return s}else if(i.test(e)===!1)return s;return o(s,{protoAction:c,constructorAction:l,safe:a&&a.safe})}function o(e,{protoAction:t=`error`,constructorAction:n=`error`,safe:r}={}){let i=[e];for(;i.length;){let e=i;i=[];for(let a of e){if(t!==`ignore`&&Object.prototype.hasOwnProperty.call(a,`__proto__`)){if(r===!0)return null;if(t===`error`)throw SyntaxError(`Object contains forbidden prototype property`);delete a.__proto__}if(n!==`ignore`&&Object.prototype.hasOwnProperty.call(a,`constructor`)&&a.constructor!==null&&typeof a.constructor==`object`&&Object.prototype.hasOwnProperty.call(a.constructor,`prototype`)){if(r===!0)return null;if(n===`error`)throw SyntaxError(`Object contains forbidden prototype property`);delete a.constructor}for(let e in a){let t=a[e];t&&typeof t==`object`&&i.push(t)}}}return e}function s(e,t,n){let{stackTraceLimit:r}=Error;Error.stackTraceLimit=0;try{return a(e,t,n)}finally{Error.stackTraceLimit=r}}function c(e,t){let{stackTraceLimit:n}=Error;Error.stackTraceLimit=0;let r;try{r=a(e,t,{safe:!0})}catch{r=void 0}finally{Error.stackTraceLimit=n}return r}t.exports=s,t.exports.default=s,t.exports.parse=s,t.exports.safeParse=c,t.exports.scan=o})),Lt=/* @__PURE__ */ M(((e,t)=>{t.exports=h;let n=It(),r=Ct(),i=At(),a=jt(),o=Mt(),s=Nt(),c=kt(),l=Pt(),u=_t(),{LEVELS:d,LEVEL_KEY:f,LEVEL_NAMES:p}=at(),m=e=>{try{return{value:n.parse(e,{protoAction:`remove`})}}catch(e){return{err:e}}};function h(e){let t;if(r(e))t=e;else{let n=m(e);if(n.err||!r(n.value))return e+this.EOL;t=n.value}if(this.minimumLevel){let e;e=this.useOnlyCustomProps?this.customLevels:this.customLevelNames[this.minimumLevel]!==void 0;let n;if(n=e?this.customLevelNames[this.minimumLevel]:p[this.minimumLevel],n||=typeof this.minimumLevel==`string`?p[this.minimumLevel]:p[d[this.minimumLevel].toLowerCase()],t[this.levelKey===void 0?f:this.levelKey]<n)return}let n=o({log:t,context:this.context});(this.ignoreKeys||this.includeKeys)&&(t=u({log:t,context:this.context}));let h=a({log:t,context:{...this.context,...this.context.customProperties}}),g=s({log:t,context:this.context}),_=l({log:t,context:this.context}),v=``;if(this.levelFirst&&h&&(v=`${h}`),_&&v===``?v=`${_}`:_&&(v=`${v} ${_}`),!this.levelFirst&&h&&(v=v.length>0?`${v} ${h}`:h),g&&(v=v.length>0?`${v} ${g}:`:g),v.endsWith(`:`)===!1&&v!==``&&(v+=`:`),n!==void 0&&(v=v.length>0?`${v} ${n}`:n),v.length>0&&!this.singleLine&&(v+=this.EOL),t.type===`Error`&&typeof t.stack==`string`){let e=i({log:t,context:this.context});this.singleLine&&(v+=this.EOL),v+=e}else if(this.hideObject===!1){let e=[this.messageKey,this.levelKey,this.timestampKey].map(e=>e.replaceAll(/\\/g,``)).filter(e=>typeof t[e]==`string`||typeof t[e]==`number`||typeof t[e]==`boolean`),n=c({log:t,skipKeys:e,context:this.context});this.singleLine&&!/^\s$/.test(n)&&(v+=` `),v+=n}return v}})),Rt=/* @__PURE__ */ P((/* @__PURE__ */ M(((e,t)=>{let{isColorSupported:n}=Qe(),r=nt(),{Transform:i}=F(`node:stream`),a=it(),o=st(),{ERROR_LIKE_KEYS:s,LEVEL_KEY:c,LEVEL_LABEL:l,MESSAGE_KEY:u,TIMESTAMP_KEY:d}=at(),{buildSafeSonicBoom:f,parseFactoryOptions:p}=Ft(),m=Lt(),h={colorize:n,colorizeObjects:!0,crlf:!1,customColors:null,customLevels:null,customPrettifiers:{},errorLikeObjectKeys:s,errorProps:``,hideObject:!1,ignore:`hostname`,include:void 0,levelFirst:!1,levelKey:c,levelLabel:l,messageFormat:null,messageKey:u,minimumLevel:void 0,singleLine:!1,timestampKey:d,translateTime:!0,useOnlyCustomProps:!0};function g(e){return e===`true`||e!==`false`&&e}function _(e){let t={...e};for(let e of[`colorize`,`colorizeObjects`,`crlf`,`hideObject`,`levelFirst`,`singleLine`,`useOnlyCustomProps`])e in t&&(t[e]=g(t[e]));return`translateTime`in t&&(t.translateTime===`true`||t.translateTime===`false`)&&(t.translateTime=g(t.translateTime)),t}function v(e){let t=_(Object.assign({},h,e)),n=p(t);return m.bind({...n,context:n})}function y(e={}){let t=v(e),n;return a(function(a){a.on(`message`,function n(r){r&&r.code===`PINO_CONFIG`&&(Object.assign(e,{messageKey:r.config.messageKey,errorLikeObjectKeys:Array.from(/* @__PURE__ */ new Set([...e.errorLikeObjectKeys||s,r.config.errorKey])),customLevels:r.config.levels.values}),t=v(e),a.off(`message`,n))});let o=new i({objectMode:!0,autoDestroy:!0,transform(e,n,r){r(null,t(e))}});return n=typeof e.destination==`object`&&typeof e.destination.write==`function`?e.destination:f({dest:e.destination||1,append:e.append,mkdir:e.mkdir,sync:e.sync}),a.on(`unknown`,function(e){n.write(e+`
33
- `)}),r(a,o,n),o},{parse:`lines`,close(e,t){n.on(`close`,()=>{t(e)})}})}t.exports=y,t.exports.build=y,t.exports.PinoPretty=y,t.exports.prettyFactory=v,t.exports.colorizerFactory=o,t.exports.isColorSupported=n,t.exports.default=y})))(),1),zt=class{module;constructor(e=`Noop`){this.module=e}debug(e,t){}info(e,t){}warn(e,t){}error(e,t,n){}withOperation(e){return this}withTrace(e){return this}flush(){return Promise.resolve()}getModule(){return this.module}};function Bt(e=`Noop`){return new zt(e)}Bt(`App`);const Vt={colorize:!0,translateTime:`SYS:HH:MM:ss`,ignore:`pid,hostname,module`,messageFormat:`{msg}`,singleLine:!0};let Ht=!1;function Ut(){return e(import.meta.url).resolve(`pino-pretty`)}function Wt(e){return(0,Rt.default)({...Vt,...e})}function Gt(e){return{target:Ut(),options:{...Vt,...e}}}const Kt={enableTracing:!0,prettyMode:`stream`};function qt(){return Ht}function Jt(){Ht=!0}function Yt(e={}){let t={...Kt,...e},n=process.env.NODE_ENV!==`production`,r=n&&!e.transport&&t.prettyMode===`stream`?Wt(e.prettyOptions):void 0;Ie({minLevel:e.minLevel??(n?`debug`:`info`),enableConsole:!0,autoTracing:t.enableTracing,transport:e.transport??(n&&t.prettyMode===`transport`?Gt(e.prettyOptions):void 0),stream:r}),t.enableTracing&&Ye(Ze())}function Xt(){qt()||(Jt(),Yt())}function Zt(e={}){Jt(),Yt(e)}function Qt(e){Xt();let t=Ge(e),n=Xe();return n?t.withTrace(n):t}Zt();var $t=/* @__PURE__ */ M((e=>{var t=class extends Error{constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},n=class extends t{constructor(e){super(1,`commander.invalidArgument`,e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};e.CommanderError=t,e.InvalidArgumentError=n})),en=/* @__PURE__ */ M((e=>{let{InvalidArgumentError:t}=$t();var n=class{constructor(e,t){switch(this.description=t||``,this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case`<`:this.required=!0,this._name=e.slice(1,-1);break;case`[`:this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e}this._name.endsWith(`...`)&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,n):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function r(e){let t=e.name()+(e.variadic===!0?`...`:``);return e.required?`<`+t+`>`:`[`+t+`]`}e.Argument=n,e.humanReadableArgName=r})),tn=/* @__PURE__ */ M((e=>{let{humanReadableArgName:t}=en();var n=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(e=>!e._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((e,t)=>e.name().localeCompare(t.name())),t}compareOptions(e,t){let n=e=>e.short?e.short.replace(/^-/,``):e.long.replace(/^--/,``);return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(e=>!e.hidden),n=e._getHelpOption();if(n&&!n.hidden){let r=n.short&&e._findOption(n.short),i=n.long&&e._findOption(n.long);!r&&!i?t.push(n):n.long&&!i?t.push(e.createOption(n.long,n.description)):n.short&&!r&&t.push(e.createOption(n.short,n.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let e=n.options.filter(e=>!e.hidden);t.push(...e)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||``}),e.registeredArguments.find(e=>e.description)?e.registeredArguments:[]}subcommandTerm(e){let n=e.registeredArguments.map(e=>t(e)).join(` `);return e._name+(e._aliases[0]?`|`+e._aliases[0]:``)+(e.options.length?` [options]`:``)+(n?` `+n:``)}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(n)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(n)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+`|`+e._aliases[0]);let n=``;for(let t=e.parent;t;t=t.parent)n=t.name()+` `+n;return n+t+` `+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue==`boolean`)&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,t,n){return t.length===0?[]:[n.styleTitle(e),...t,``]}groupItems(e,t,n){let r=/* @__PURE__ */ new Map;return e.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[])}),t.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[]),r.get(t).push(e)}),r}formatHelp(e,t){let n=t.padWidth(e,t),r=t.helpWidth??80;function i(e,r){return t.formatItem(e,n,r,t)}let a=[`${t.styleTitle(`Usage:`)} ${t.styleUsage(t.commandUsage(e))}`,``],o=t.commandDescription(e);o.length>0&&(a=a.concat([t.boxWrap(t.styleCommandDescription(o),r),``]));let s=t.visibleArguments(e).map(e=>i(t.styleArgumentTerm(t.argumentTerm(e)),t.styleArgumentDescription(t.argumentDescription(e))));if(a=a.concat(this.formatItemList(`Arguments:`,s,t)),this.groupItems(e.options,t.visibleOptions(e),e=>e.helpGroupHeading??`Options:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),t.showGlobalOptions){let n=t.visibleGlobalOptions(e).map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(`Global Options:`,n,t))}return this.groupItems(e.commands,t.visibleCommands(e),e=>e.helpGroup()||`Commands:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleSubcommandTerm(t.subcommandTerm(e)),t.styleSubcommandDescription(t.subcommandDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),a.join(`
33
+ `)}),r(a,o,n),o},{parse:`lines`,close(e,t){n.on(`close`,()=>{t(e)})}})}t.exports=y,t.exports.build=y,t.exports.PinoPretty=y,t.exports.prettyFactory=v,t.exports.colorizerFactory=o,t.exports.isColorSupported=n,t.exports.default=y})))(),1),zt=class{module;constructor(e=`Noop`){this.module=e}debug(e,t){}info(e,t){}warn(e,t){}error(e,t,n){}withOperation(e){return this}withTrace(e){return this}flush(){return Promise.resolve()}getModule(){return this.module}};function Bt(e=`Noop`){return new zt(e)}Bt(`App`);const Vt={colorize:!0,translateTime:`SYS:HH:MM:ss`,ignore:`pid,hostname,module`,messageFormat:`{msg}`,singleLine:!0};let Ht=!1;function Ut(){return e(import.meta.url).resolve(`pino-pretty`)}function Wt(e){return(0,Rt.default)({...Vt,...e})}function Gt(e){return{target:Ut(),options:{...Vt,...e}}}const Kt={enableTracing:!0,prettyMode:`stream`,output:`stdout`};function qt(){return Ht}function Jt(){Ht=!0}function Yt(e={}){let t={...Kt,...e},n=process.env.NODE_ENV!==`production`,r=t.output===`stderr`,i=r?{...e.prettyOptions,destination:2}:e.prettyOptions,a=e.transport??(n&&t.prettyMode===`transport`?Gt(i):void 0),o=n&&!e.transport&&t.prettyMode===`stream`?Wt(i):void 0,s=o===void 0&&a===void 0&&r?process.stderr:void 0;Ie({minLevel:e.minLevel??(n?`debug`:`info`),enableConsole:!0,autoTracing:t.enableTracing,transport:a,stream:o??s}),t.enableTracing&&Ye(Ze())}function Xt(){qt()||(Jt(),Yt())}function Zt(e={}){Jt(),Yt(e)}function Qt(e){Xt();let t=Ge(e),n=Xe();return n?t.withTrace(n):t}Zt();var $t=/* @__PURE__ */ M((e=>{var t=class extends Error{constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},n=class extends t{constructor(e){super(1,`commander.invalidArgument`,e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};e.CommanderError=t,e.InvalidArgumentError=n})),en=/* @__PURE__ */ M((e=>{let{InvalidArgumentError:t}=$t();var n=class{constructor(e,t){switch(this.description=t||``,this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case`<`:this.required=!0,this._name=e.slice(1,-1);break;case`[`:this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e}this._name.endsWith(`...`)&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,n):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function r(e){let t=e.name()+(e.variadic===!0?`...`:``);return e.required?`<`+t+`>`:`[`+t+`]`}e.Argument=n,e.humanReadableArgName=r})),tn=/* @__PURE__ */ M((e=>{let{humanReadableArgName:t}=en();var n=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(e=>!e._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((e,t)=>e.name().localeCompare(t.name())),t}compareOptions(e,t){let n=e=>e.short?e.short.replace(/^-/,``):e.long.replace(/^--/,``);return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(e=>!e.hidden),n=e._getHelpOption();if(n&&!n.hidden){let r=n.short&&e._findOption(n.short),i=n.long&&e._findOption(n.long);!r&&!i?t.push(n):n.long&&!i?t.push(e.createOption(n.long,n.description)):n.short&&!r&&t.push(e.createOption(n.short,n.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let e=n.options.filter(e=>!e.hidden);t.push(...e)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||``}),e.registeredArguments.find(e=>e.description)?e.registeredArguments:[]}subcommandTerm(e){let n=e.registeredArguments.map(e=>t(e)).join(` `);return e._name+(e._aliases[0]?`|`+e._aliases[0]:``)+(e.options.length?` [options]`:``)+(n?` `+n:``)}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(n)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(n)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+`|`+e._aliases[0]);let n=``;for(let t=e.parent;t;t=t.parent)n=t.name()+` `+n;return n+t+` `+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue==`boolean`)&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,t,n){return t.length===0?[]:[n.styleTitle(e),...t,``]}groupItems(e,t,n){let r=/* @__PURE__ */ new Map;return e.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[])}),t.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[]),r.get(t).push(e)}),r}formatHelp(e,t){let n=t.padWidth(e,t),r=t.helpWidth??80;function i(e,r){return t.formatItem(e,n,r,t)}let a=[`${t.styleTitle(`Usage:`)} ${t.styleUsage(t.commandUsage(e))}`,``],o=t.commandDescription(e);o.length>0&&(a=a.concat([t.boxWrap(t.styleCommandDescription(o),r),``]));let s=t.visibleArguments(e).map(e=>i(t.styleArgumentTerm(t.argumentTerm(e)),t.styleArgumentDescription(t.argumentDescription(e))));if(a=a.concat(this.formatItemList(`Arguments:`,s,t)),this.groupItems(e.options,t.visibleOptions(e),e=>e.helpGroupHeading??`Options:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),t.showGlobalOptions){let n=t.visibleGlobalOptions(e).map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(`Global Options:`,n,t))}return this.groupItems(e.commands,t.visibleCommands(e),e=>e.helpGroup()||`Commands:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleSubcommandTerm(t.subcommandTerm(e)),t.styleSubcommandDescription(t.subcommandDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),a.join(`
34
34
  `)}displayWidth(e){return r(e).length}styleTitle(e){return e}styleUsage(e){return e.split(` `).map(e=>e===`[options]`?this.styleOptionText(e):e===`[command]`?this.styleSubcommandText(e):e[0]===`[`||e[0]===`<`?this.styleArgumentText(e):this.styleCommandText(e)).join(` `)}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOptionText(e)}styleSubcommandTerm(e){return e.split(` `).map(e=>e===`[options]`?this.styleOptionText(e):e[0]===`[`||e[0]===`<`?this.styleArgumentText(e):this.styleSubcommandText(e)).join(` `)}styleArgumentTerm(e){return this.styleArgumentText(e)}styleOptionText(e){return e}styleArgumentText(e){return e}styleSubcommandText(e){return e}styleCommandText(e){return e}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,t,n,r){let i=` `.repeat(2);if(!n)return i+e;let a=e.padEnd(t+e.length-r.displayWidth(e)),o=(this.helpWidth??80)-t-2-2,s;return s=o<this.minWidthToWrap||r.preformatted(n)?n:r.boxWrap(n,o).replace(/\n/g,`
35
35
  `+` `.repeat(t+2)),i+a+` `.repeat(2)+s.replace(/\n/g,`\n${i}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;let n=e.split(/\r\n|\n/),r=/[\s]*[^\s]+/g,i=[];return n.forEach(e=>{let n=e.match(r);if(n===null){i.push(``);return}let a=[n.shift()],o=this.displayWidth(a[0]);n.forEach(e=>{let n=this.displayWidth(e);if(o+n<=t){a.push(e),o+=n;return}i.push(a.join(``));let r=e.trimStart();a=[r],o=this.displayWidth(r)}),i.push(a.join(``))}),i.join(`
36
36
  `)}};function r(e){return e.replace(/\x1b\[\d*(;\d*)*m/g,``)}e.Help=n,e.stripColor=r})),nn=/* @__PURE__ */ M((e=>{let{InvalidArgumentError:t}=$t();var n=class{constructor(e,t){this.flags=e,this.description=t||``,this.required=e.includes(`<`),this.optional=e.includes(`[`),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let n=a(e);this.short=n.shortFlag,this.long=n.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith(`--no-`)),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return typeof e==`string`&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,n):e},this}name(){return this.long?this.long.replace(/^--/,``):this.short.replace(/^-/,``)}attributeName(){return this.negate?i(this.name().replace(/^no-/,``)):i(this.name())}helpGroup(e){return this.helpGroupHeading=e,this}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},r=class{constructor(e){this.positiveOptions=/* @__PURE__ */ new Map,this.negativeOptions=/* @__PURE__ */ new Map,this.dualOptions=/* @__PURE__ */ new Set,e.forEach(e=>{e.negate?this.negativeOptions.set(e.attributeName(),e):this.positiveOptions.set(e.attributeName(),e)}),this.negativeOptions.forEach((e,t)=>{this.positiveOptions.has(t)&&this.dualOptions.add(t)})}valueFromOption(e,t){let n=t.attributeName();if(!this.dualOptions.has(n))return!0;let r=this.negativeOptions.get(n).presetArg,i=r!==void 0&&r;return t.negate===(i===e)}};function i(e){return e.split(`-`).reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function a(e){let t,n,r=/^-[^-]$/,i=/^--[^-]/,a=e.split(/[ |,]+/).concat(`guard`);if(r.test(a[0])&&(t=a.shift()),i.test(a[0])&&(n=a.shift()),!t&&r.test(a[0])&&(t=a.shift()),!t&&i.test(a[0])&&(t=n,n=a.shift()),a[0].startsWith(`-`)){let t=a[0],n=`option creation failed due to '${t}' in option flags '${e}'`;throw/^-[^-][^-]/.test(t)?Error(`${n}
@@ -205,20 +205,20 @@ ${K.default.gray(Td+Cd.repeat(a+2)+Ed)}
205
205
  `):process.stdout.write(`${r} ${s}
206
206
  `),m(),i()};return{start:v,stop:y,message:(e=``)=>{s=g(e??s)}}},Bd={red:e=>K.default.red(e),green:e=>K.default.green(e),yellow:e=>K.default.yellow(e),blue:e=>K.default.blue(e),cyan:e=>K.default.cyan(e),magenta:e=>K.default.magenta(e),gray:e=>K.default.gray(e),bold:e=>K.default.bold(e),dim:e=>K.default.dim(e)},Vd={async select(e,t){let n=await Fd({message:e,options:t.map(e=>({value:e.value,label:e.label,hint:e.hint}))});return td(n)&&(Ld(`操作已取消`),process.exit(0)),typeof n==`string`?n:String(n)},async textInput(e,t){let n=await Nd({message:e,placeholder:t?.placeholder,defaultValue:t?.defaultValue});return td(n)&&(Ld(`操作已取消`),process.exit(0)),typeof n==`string`?n:String(n)},async confirm(e,t){let n=await Pd({message:e,initialValue:t?.defaultValue??!1});return td(n)&&(Ld(`操作已取消`),process.exit(0)),typeof n==`boolean`?n:!!n},spinner(){let e=zd();return{start(t){e.start(t)},stop(t){e.stop(t)}}},note(e,t){Id(e,t)},log:{info(e){Rd.info(K.default.blue(e))},success(e){Rd.success(K.default.green(e))},warn(e){Rd.warn(K.default.yellow(e))},error(e){Rd.error(K.default.red(e))},step(e){Rd.step(e)}}};function Hd(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 X(...e){process.stdout.write(`${Hd(e)}\n`)}function Z(...e){process.stderr.write(`${Hd(e)}\n`)}const Ud=/* @__PURE__ */ new Set([`build`,`coverage`,`dist`,`node_modules`,`out`]),Wd=/* @__PURE__ */ new Set([`ENAMETOOLONG`,`EACCES`,`EPERM`,`ENOENT`]),Gd=Fl([jl(el()),Nl({packages:jl(el())})]),Kd=e=>typeof e!=`object`||!e||!(`code`in e)?!1:typeof e.code==`string`,qd=e=>{let t=``;for(let n=0;n<e.length;n+=1){let r=e.charAt(n);r===`*`?e[n+1]===`*`?(t+=`.*`,n+=1):t+=`[^/]+`:t+=r.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}return RegExp(`^${t}$`)},Jd=e=>{let t={positives:[],negatives:[]};for(let n of e)n.startsWith(`!`)?t.negatives.push(qd(n.slice(1))):t.positives.push(qd(n));return t},Yd=e=>{let t=Gd.safeParse(e);if(t.success)return Array.isArray(t.data)?t.data:t.data.packages},Xd=(e,t)=>e.positives.some(e=>e.test(t))&&!e.negatives.some(e=>e.test(t)),Zd=(e,t)=>e.negatives.some(e=>e.test(t)),Qd=[`bun.lock`,`bun.lockb`],$d=Nl({name:el().optional(),workspaces:Gd.optional()}),ef=Nl({name:el().optional()}),tf=async e=>{try{let t=ef.safeParse(JSON.parse(await b(e,`utf-8`)));return t.success?t.data.name??null:null}catch{return null}},nf=async e=>{let t={packageDirs:[],lockDirs:[],rootHasLock:!1,scanSkips:[]},n=[{dir:e,depth:0}];for(;n.length>0;){let r=n.shift();if(r===void 0)break;let i;try{i=await x(r.dir,{withFileTypes:!0})}catch(n){if(!Kd(n)||!Wd.has(n.code))throw n;let i=r.depth===0?`.`:r.dir.slice(e.length+1);t.scanSkips.push({path:i,code:n.code});continue}let a=!1,o=!1;for(let e of i)e.isFile()&&Qd.includes(e.name)&&(a=!0),e.isFile()&&e.name===`package.json`&&(o=!0);r.depth===0?t.rootHasLock=a:(a&&t.lockDirs.push(r.dir.slice(e.length+1)),o&&t.packageDirs.push({relPath:r.dir.slice(e.length+1),name:await tf(l(r.dir,`package.json`))}));for(let e of i)e.isDirectory()&&(e.name.startsWith(`.`)||Ud.has(e.name)||r.depth>=5||n.push({dir:l(r.dir,e.name),depth:r.depth+1}))}return t},rf=async e=>{let t;try{t=JSON.parse(await b(l(e,`package.json`),`utf-8`))}catch{throw Error(`根 package.json 不存在或不可解析,请在仓库根执行本命令`)}let n=$d.safeParse(t);if(!n.success)throw Error(`根 package.json 不存在或不可解析,请在仓库根执行本命令`);let r=n.data,i=r.name??null,a=i===null?null:i.includes(`/`)?i.slice(0,i.lastIndexOf(`/`)):`@${i}`,o=Yd(r.workspaces);if(o===void 0)return{rootName:i,scope:a,hasWorkspaces:!1,memberCount:0,violations:[],notices:[],scanSkips:[],ok:!0};let s=Jd(o),c=await nf(e),u=[],d=[],f=new Map(c.packageDirs.map(e=>[e.relPath,e.name])),p=c.packageDirs.map(e=>e.relPath).filter(e=>Xd(s,e));c.rootHasLock||u.push({kind:`missing-root-lock`,path:``,message:`仓库根缺少 bun.lock,声明了 workspaces 的 monorepo 锁文件应只存在于根`});let m=/* @__PURE__ */ new Set;for(let e of c.lockDirs){if(Xd(s,e)){m.add(e),u.push({kind:`stray-member-lock`,path:e,message:`${e} 是 workspaces 成员却持有自己的 bun.lock,属游离锁文件`});continue}let t=f.get(e)??null;t===null?d.push({kind:`orphan-lock`,path:e,message:`${e} 存在锁文件但没有 package.json,请确认目录用途`}):Zd(s,e)?d.push({kind:`excluded-standalone`,path:e,message:`${e} 为负向 glob 显式排除的独立安装根,锁文件属合法形态`}):a!==null&&t.startsWith(`${a}/`)?(m.add(e),u.push({kind:`uncovered-same-scope`,path:e,message:`${e}(${t})与根包同作用域却未被 workspaces 覆盖,已按独立安装根长出游离锁`})):d.push({kind:`foreign-scope-lock`,path:e,message:`${e}(${t})不属于根作用域且持有独立锁文件,若为有意保留请以负向 glob 显式排除`})}for(let e of c.packageDirs)p.includes(e.relPath)||Zd(s,e.relPath)||m.has(e.relPath)||a!==null&&e.name!==null&&e.name.startsWith(`${a}/`)&&u.push({kind:`uncovered-same-scope`,path:e.relPath,message:`${e.relPath}(${e.name})与根包同作用域却未被 workspaces 覆盖,请补 glob 或以负向 glob 显式排除`});return{rootName:i,scope:a,hasWorkspaces:!0,memberCount:p.length,violations:u,notices:d,scanSkips:c.scanSkips,ok:u.length===0}},af=async()=>{let e=process.cwd();X(`正在扫描 ${e} 下的工作区布局...`);try{let t=await rf(e);if(!t.hasWorkspaces){X(`未声明 workspaces,非 bun workspaces monorepo,跳过锁文件校验`);return}if(t.scanSkips.length>0){Z(`\n${t.scanSkips.length} 项目录读取降级告警,结论基于其余可读目录:`);for(let e of t.scanSkips)Z(` ${e.path} 读取失败已跳过该子树,错误码 ${e.code}`)}if(X(`根包 ${t.rootName??`未命名`},workspaces 成员 ${t.memberCount} 个`),t.notices.length>0){X(`\n${t.notices.length} 项提示:`);for(let e of t.notices)X(` ${e.message}`)}if(!t.ok){X(`\n发现 ${t.violations.length} 项违规:`);for(let e of t.violations)X(` ${e.message}`);X(`
207
207
  修复指引: 删除成员目录的游离 bun.lock 后在仓库根执行 bun install;覆盖缺口补 workspaces glob,刻意独立的子项目以负向 glob 显式排除`),process.exit(1)}X(`单一锁文件不变量成立,无游离锁文件与覆盖缺口`)}catch(e){Z(`错误: ${e instanceof Error?e.message:String(e)}`),process.exit(1)}},of=/* @__PURE__ */ new Set([`.bun`]),sf=/* @__PURE__ */ new Set([`ENOENT`,`ENOTDIR`]),cf=Nl({workspaces:Gd.optional()}),lf=async e=>{let t=[],n=[],r=[{dir:e,depth:0}];for(;r.length>0;){let i=r.shift();if(i===void 0)break;let a;try{a=await x(i.dir,{withFileTypes:!0})}catch(t){if(!Kd(t)||!Wd.has(t.code))throw t;n.push({path:i.dir.slice(e.length+1),code:t.code});continue}a.some(e=>e.isFile()&&e.name===`package.json`)&&t.push(i.dir.slice(e.length+1));for(let e of a)e.isDirectory()&&(e.name.startsWith(`.`)||Ud.has(e.name)||i.depth>=5||r.push({dir:l(i.dir,e.name),depth:i.depth+1}))}return{packageDirPaths:t,scanSkips:n}},uf=async(e,t)=>{let n=[],r=[],i=[e];for(;i.length>0;){let e=i.shift();if(e===void 0)break;let a;try{a=await x(e,{withFileTypes:!0})}catch(n){if(!Kd(n)||!Wd.has(n.code))throw n;r.push({path:e.slice(t.length+1),code:n.code});continue}for(let o of a){let a=l(e,o.name);if(!of.has(o.name)){if(o.isSymbolicLink())try{await C(a)}catch(e){if(Kd(e)&&sf.has(e.code)){n.push({path:a.slice(t.length+1),target:await S(a)});continue}r.push({path:a.slice(t.length+1),code:Kd(e)?e.code:`UNKNOWN`})}else o.isDirectory()&&i.push(a)}}}return{dangling:n,scanSkips:r}},df=async e=>{let t;try{t=JSON.parse(await b(l(e,`package.json`),`utf-8`))}catch{throw Error(`根 package.json 不存在或不可解析,请在仓库根执行本命令`)}let n=cf.safeParse(t);if(!n.success)throw Error(`根 package.json 不存在或不可解析,请在仓库根执行本命令`);let r=Yd(n.data.workspaces);if(r===void 0)return{hasWorkspaces:!1,memberCount:0,scannedNodeModulesRoots:0,dangling:[],scanSkips:[],ok:!0};let i=Jd(r),a=await lf(e),o=a.packageDirPaths.filter(e=>Xd(i,e)),s=[],c=[...a.scanSkips],u=0;for(let t of[``,...o]){let n=l(e,t,`node_modules`);try{if(!(await C(n)).isDirectory())continue}catch{continue}u+=1;let r=await uf(n,e);s.push(...r.dangling),c.push(...r.scanSkips)}return{hasWorkspaces:!0,memberCount:o.length,scannedNodeModulesRoots:u,dangling:s,scanSkips:c,ok:s.length===0}},ff=async(e,t)=>{let n={removed:[],kept:[]};for(let r of t){let t=l(e,r.path);try{if(!(await y(t)).isSymbolicLink()){n.kept.push(r.path);continue}await C(t),n.kept.push(r.path)}catch(e){if(!Kd(e)||!sf.has(e.code)){n.kept.push(r.path);continue}await w(t),n.removed.push(r.path)}}return n},pf=async()=>{let e=process.cwd();X(`正在扫描 ${e} 下的安装布局...`);try{let t=await df(e);if(!t.hasWorkspaces){X(`未声明 workspaces,非 bun workspaces monorepo,跳过悬挂链接检测`);return}if(t.scanSkips.length>0){Z(`\n${t.scanSkips.length} 项目录读取降级告警,结论基于其余可读目录:`);for(let e of t.scanSkips)Z(` ${e.path} 读取失败已跳过该子树,错误码 ${e.code}`)}if(X(`workspaces 成员 ${t.memberCount} 个,扫描 ${t.scannedNodeModulesRoots} 个 node_modules 树`),t.dangling.length>0){X(`\n发现 ${t.dangling.length} 根悬挂符号链接:`);for(let e of t.dangling)X(` ${e.path} 指向已不存在的 ${e.target}`);X(`
208
- 修复指引: 执行 lzi-bun-cli node-links fix 回收悬挂死链后重试,有效链接零触碰`),process.exit(Math.min(t.dangling.length,255))}X(`安装布局一致,未发现悬挂符号链接`)}catch(e){Z(`错误: ${e instanceof Error?e.message:String(e)}`),process.exit(1)}},mf=async()=>{let e=process.cwd();X(`正在扫描 ${e} 下的悬挂符号链接...`);try{let t=await df(e);if(!t.hasWorkspaces){X(`未声明 workspaces,非 bun workspaces monorepo,跳过悬挂链接回收`);return}if(t.dangling.length===0){X(`未发现悬挂符号链接,无需回收,共巡查 ${t.scannedNodeModulesRoots} 个 node_modules 树`);return}X(`发现 ${t.dangling.length} 根悬挂符号链接,开始回收:`);for(let e of t.dangling)X(` ${e.path} 指向已不存在的 ${e.target}`);let n=await ff(e,t.dangling);for(let e of n.removed)X(`已回收 ${e}`);for(let e of n.kept)Z(`未能回收 ${e},链接状态已变化,请人工确认`);let r=await df(e);X(`回收完成,清除 ${n.removed.length} 根,剩余悬挂 ${r.dangling.length} 根,有效链接零触碰`),(r.dangling.length>0||n.kept.length>0)&&process.exit(1)}catch(e){Z(`错误: ${e instanceof Error?e.message:String(e)}`),process.exit(1)}};function hf(e,t=`./src/__tests__/bootstrap.ts`){let n=[t,...(e?.test?.preload??[]).filter(e=>e!==t)];return{...e,test:{...e?.test,preload:n}}}const Q=`https://registry.npmjs.org/`,gf=/* @__PURE__ */ new Map([[`longzai-intelligence`,Q],[`longzai-intelligence-agent-tools`,Q],[`longzai-intelligence-audit`,Q],[`longzai-intelligence-auth`,Q],[`longzai-intelligence-builder`,Q],[`longzai-intelligence-bun`,Q],[`longzai-intelligence-cache`,Q],[`longzai-intelligence-cli`,Q],[`longzai-intelligence-config`,Q],[`longzai-intelligence-dependencies`,Q],[`longzai-intelligence-design-system`,Q],[`longzai-intelligence-dev-tools`,Q],[`longzai-intelligence-electron`,Q],[`longzai-intelligence-error`,Q],[`longzai-intelligence-event-bus`,Q],[`longzai-intelligence-logger`,Q],[`longzai-intelligence-okr`,Q],[`longzai-intelligence-oxfmt`,Q],[`longzai-intelligence-oxlint`,Q],[`longzai-intelligence-plugin`,Q],[`longzai-intelligence-shared-config`,Q],[`longzai-intelligence-shared-kernel`,Q],[`longzai-intelligence-scripts`,Q],[`longzai-intelligence-standards`,Q],[`longzai-intelligence-transport`,Q],[`longzai-intelligence-typescript`,Q],[`longzai-intelligence-vscode`,Q],[`longzai-intelligence-zod`,Q],[`longzai-intelligence-prettier`,Q],[`longzai-intelligence-tsdown`,Q],[`longzai-intelligence-vitest`,Q],[`longzai-intelligence-academy`,Q],[`longzai-intelligence-accounting`,Q],[`longzai-intelligence-activity`,Q],[`longzai-intelligence-administration`,Q],[`longzai-intelligence-agent`,Q],[`longzai-intelligence-agent-broadcast`,Q],[`longzai-intelligence-agent-collaboration`,Q],[`longzai-intelligence-agent-endless`,Q],[`longzai-intelligence-agent-migrator`,Q],[`longzai-intelligence-agent-monitor`,Q],[`longzai-intelligence-agent-prompts`,Q],[`longzai-intelligence-agent-relation`,Q],[`longzai-intelligence-agent-session`,Q],[`longzai-intelligence-agent-swarm`,Q],[`longzai-intelligence-agent-tasks`,Q],[`longzai-intelligence-agent-tasks-data`,Q],[`longzai-intelligence-agent-ui`,Q],[`longzai-intelligence-analytics`,Q],[`longzai-intelligence-api`,Q],[`longzai-intelligence-app-gallery`,Q],[`longzai-intelligence-app-store`,Q],[`longzai-intelligence-architecture`,Q],[`longzai-intelligence-architecture-expert`,Q],[`longzai-intelligence-arkts`,Q],[`longzai-intelligence-art`,Q],[`longzai-intelligence-artifact`,Q],[`longzai-intelligence-artifact-registry`,Q],[`longzai-intelligence-arxiv`,Q],[`longzai-intelligence-arxiv-data`,Q],[`longzai-intelligence-arxiv-markdown`,Q],[`longzai-intelligence-atomic`,Q],[`longzai-intelligence-attention`,Q],[`longzai-intelligence-audio`,Q],[`longzai-intelligence-audio-assistant`,Q],[`longzai-intelligence-augmented-reality`,Q],[`longzai-intelligence-auto-research`,Q],[`longzai-intelligence-automate`,Q],[`longzai-intelligence-benchmark`,Q],[`longzai-intelligence-bilibili`,Q],[`longzai-intelligence-bilibili-data`,Q],[`longzai-intelligence-bilibili-markdown`,Q],[`longzai-intelligence-billing`,Q],[`longzai-intelligence-blackboard`,Q],[`longzai-intelligence-blackboard-data`,Q],[`longzai-intelligence-blackboard-markdown`,Q],[`longzai-intelligence-bluetooth`,Q],[`longzai-intelligence-board`,Q],[`longzai-intelligence-bootstrap`,Q],[`longzai-intelligence-bootstrap-registry`,Q],[`longzai-intelligence-bounty-registry`,Q],[`longzai-intelligence-brawl-stars`,Q],[`longzai-intelligence-broker`,Q],[`longzai-intelligence-bt`,Q],[`longzai-intelligence-business-plan`,Q],[`longzai-intelligence-calendar`,Q],[`longzai-intelligence-camera`,Q],[`longzai-intelligence-canvas`,Q],[`longzai-intelligence-capture`,Q],[`longzai-intelligence-change-maker`,Q],[`longzai-intelligence-changelog`,Q],[`longzai-intelligence-changeset`,Q],[`longzai-intelligence-chat`,Q],[`longzai-intelligence-chess`,Q],[`longzai-intelligence-circuit`,Q],[`longzai-intelligence-claude-code`,Q],[`longzai-intelligence-claude-knowledge`,Q],[`longzai-intelligence-clipboard-share`,Q],[`longzai-intelligence-closed-loop`,Q],[`longzai-intelligence-closed-loop-data`,Q],[`longzai-intelligence-closed-loop-markdown`,Q],[`longzai-intelligence-cloud`,Q],[`longzai-intelligence-code`,Q],[`longzai-intelligence-code-agent`,Q],[`longzai-intelligence-code-reviewer`,Q],[`longzai-intelligence-codebase-research`,Q],[`longzai-intelligence-coding-expert`,Q],[`longzai-intelligence-collaboration`,Q],[`longzai-intelligence-collective`,Q],[`longzai-intelligence-commerce`,Q],[`longzai-intelligence-commit`,Q],[`longzai-intelligence-competition-registry`,Q],[`longzai-intelligence-composer`,Q],[`longzai-intelligence-concrete`,Q],[`longzai-intelligence-concrete-industry`,Q],[`longzai-intelligence-config-registry`,Q],[`longzai-intelligence-context`,Q],[`longzai-intelligence-contract`,Q],[`longzai-intelligence-contract-parity`,Q],[`longzai-intelligence-cookery`,Q],[`longzai-intelligence-country`,Q],[`longzai-intelligence-creativity`,Q],[`longzai-intelligence-cross-platform`,Q],[`longzai-intelligence-crossref`,Q],[`longzai-intelligence-crossref-markdown`,Q],[`longzai-intelligence-crypto`,Q],[`longzai-intelligence-customer-service`,Q],[`longzai-intelligence-cut`,Q],[`longzai-intelligence-dag`,Q],[`longzai-intelligence-dashboard`,Q],[`longzai-intelligence-data`,Q],[`longzai-intelligence-data-science`,Q],[`longzai-intelligence-database`,Q],[`longzai-intelligence-decenterlization`,Q],[`longzai-intelligence-decision`,Q],[`longzai-intelligence-deepseek`,Q],[`longzai-intelligence-deepseek-harness`,Q],[`longzai-intelligence-deepseek-harness-knowledge`,Q],[`longzai-intelligence-delta`,Q],[`longzai-intelligence-deploy`,Q],[`longzai-intelligence-design`,Q],[`longzai-intelligence-design-lab`,Q],[`longzai-intelligence-design-registry`,Q],[`longzai-intelligence-design-trending`,Q],[`longzai-intelligence-device`,Q],[`longzai-intelligence-dimensions`,Q],[`longzai-intelligence-discipline`,Q],[`longzai-intelligence-discovery`,Q],[`longzai-intelligence-disk-space`,Q],[`longzai-intelligence-disk-space-data`,Q],[`longzai-intelligence-disk-space-markdown`,Q],[`longzai-intelligence-distill`,Q],[`longzai-intelligence-docs`,Q],[`longzai-intelligence-docs-registry`,Q],[`longzai-intelligence-document`,Q],[`longzai-intelligence-douyin`,Q],[`longzai-intelligence-douyin-data`,Q],[`longzai-intelligence-douyin-markdown`,Q],[`longzai-intelligence-drone`,Q],[`longzai-intelligence-edge`,Q],[`longzai-intelligence-electrobun`,Q],[`longzai-intelligence-elysia`,Q],[`longzai-intelligence-embodied`,Q],[`longzai-intelligence-empowerment`,Q],[`longzai-intelligence-engineering`,Q],[`longzai-intelligence-env`,Q],[`longzai-intelligence-env-registry`,Q],[`longzai-intelligence-equilibrium`,Q],[`longzai-intelligence-eslint`,Q],[`longzai-intelligence-event`,Q],[`longzai-intelligence-event-tracking`,Q],[`longzai-intelligence-evolution`,Q],[`longzai-intelligence-excel`,Q],[`longzai-intelligence-exchange-rate`,Q],[`longzai-intelligence-execution`,Q],[`longzai-intelligence-experience`,Q],[`longzai-intelligence-expert`,Q],[`longzai-intelligence-expert-thinking`,Q],[`longzai-intelligence-fde`,Q],[`longzai-intelligence-feature-flags`,Q],[`longzai-intelligence-features`,Q],[`longzai-intelligence-federation`,Q],[`longzai-intelligence-feed`,Q],[`longzai-intelligence-feishu`,Q],[`longzai-intelligence-fields-medal-knowledge`,Q],[`longzai-intelligence-file-processing`,Q],[`longzai-intelligence-findings`,Q],[`longzai-intelligence-fitness`,Q],[`longzai-intelligence-font`,Q],[`longzai-intelligence-game`,Q],[`longzai-intelligence-game-studio`,Q],[`longzai-intelligence-gantt`,Q],[`longzai-intelligence-gateway`,Q],[`longzai-intelligence-geo`,Q],[`longzai-intelligence-gesture`,Q],[`longzai-intelligence-git`,Q],[`longzai-intelligence-git-commit`,Q],[`longzai-intelligence-git-insight`,Q],[`longzai-intelligence-git-reviewer`,Q],[`longzai-intelligence-git-swarm`,Q],[`longzai-intelligence-git-swarm-registry`,Q],[`longzai-intelligence-gitcode`,Q],[`longzai-intelligence-github-data`,Q],[`longzai-intelligence-github-markdown`,Q],[`longzai-intelligence-github-trending`,Q],[`longzai-intelligence-github-trending-data`,Q],[`longzai-intelligence-github-trending-markdown`,Q],[`longzai-intelligence-globals`,Q],[`longzai-intelligence-growth`,Q],[`longzai-intelligence-growth-registry`,Q],[`longzai-intelligence-handover`,Q],[`longzai-intelligence-hardware`,Q],[`longzai-intelligence-harness`,Q],[`longzai-intelligence-healthcare`,Q],[`longzai-intelligence-history`,Q],[`longzai-intelligence-horizon`,Q],[`longzai-intelligence-human-resource`,Q],[`longzai-intelligence-i18n`,Q],[`longzai-intelligence-idea`,Q],[`longzai-intelligence-identity`,Q],[`longzai-intelligence-ime`,Q],[`longzai-intelligence-impact-maker`,Q],[`longzai-intelligence-inbox`,Q],[`longzai-intelligence-inbox-registry`,Q],[`longzai-intelligence-input-data`,Q],[`longzai-intelligence-input-markdown`,Q],[`longzai-intelligence-insight`,Q],[`longzai-intelligence-intellectual-property`,Q],[`longzai-intelligence-intent`,Q],[`longzai-intelligence-intentionomics`,Q],[`longzai-intelligence-interview`,Q],[`longzai-intelligence-issues`,Q],[`longzai-intelligence-jev`,Q],[`longzai-intelligence-jev-knowledge`,Q],[`longzai-intelligence-jev-system`,Q],[`longzai-intelligence-journal-of-finance-data`,Q],[`longzai-intelligence-journal-of-financial-and-quantitative-analysis-data`,Q],[`longzai-intelligence-journal-of-financial-economics-data`,Q],[`longzai-intelligence-journals`,Q],[`longzai-intelligence-journals-2026-10`,Q],[`longzai-intelligence-journals-markdown`,Q],[`longzai-intelligence-journals-registry`,Q],[`longzai-intelligence-key-management`,Q],[`longzai-intelligence-knowledge`,Q],[`longzai-intelligence-knowledge-graph`,Q],[`longzai-intelligence-knowledge-markdown`,Q],[`longzai-intelligence-kol`,Q],[`longzai-intelligence-kol-data`,Q],[`longzai-intelligence-kol-markdown`,Q],[`longzai-intelligence-kol-registry`,Q],[`longzai-intelligence-language-model`,Q],[`longzai-intelligence-law`,Q],[`longzai-intelligence-law-data`,Q],[`longzai-intelligence-law-markdown`,Q],[`longzai-intelligence-lean`,Q],[`longzai-intelligence-ledger`,Q],[`longzai-intelligence-legal`,Q],[`longzai-intelligence-liquid-glass`,Q],[`longzai-intelligence-living-previewer`,Q],[`longzai-intelligence-loop`,Q],[`longzai-intelligence-machine-learning`,Q],[`longzai-intelligence-mail`,Q],[`longzai-intelligence-mandala`,Q],[`longzai-intelligence-map`,Q],[`longzai-intelligence-markdown`,Q],[`longzai-intelligence-marketing`,Q],[`longzai-intelligence-marketplace`,Q],[`longzai-intelligence-math`,Q],[`longzai-intelligence-mcn`,Q],[`longzai-intelligence-mcp`,Q],[`longzai-intelligence-mechanisms`,Q],[`longzai-intelligence-mechanisms-registry`,Q],[`longzai-intelligence-media`,Q],[`longzai-intelligence-meditation`,Q],[`longzai-intelligence-meeting-notes`,Q],[`longzai-intelligence-memory`,Q],[`longzai-intelligence-mentor`,Q],[`longzai-intelligence-messaging`,Q],[`longzai-intelligence-mindset`,Q],[`longzai-intelligence-minimax-knowldege`,Q],[`longzai-intelligence-mission-control`,Q],[`longzai-intelligence-model-fusion`,Q],[`longzai-intelligence-model-gateway`,Q],[`longzai-intelligence-moment`,Q],[`longzai-intelligence-montage`,Q],[`longzai-intelligence-movie`,Q],[`longzai-intelligence-music-video`,Q],[`longzai-intelligence-music-video-data`,Q],[`longzai-intelligence-narrative-analyzer`,Q],[`longzai-intelligence-nation`,Q],[`longzai-intelligence-nginx`,Q],[`longzai-intelligence-nginx-cli`,Q],[`longzai-intelligence-nobel-prize-knowledge`,Q],[`longzai-intelligence-notification`,Q],[`longzai-intelligence-npm`,Q],[`longzai-intelligence-npm-registry`,Q],[`longzai-intelligence-npm-registry-data`,Q],[`longzai-intelligence-observability`,Q],[`longzai-intelligence-office-industry`,Q],[`longzai-intelligence-okr-data`,Q],[`longzai-intelligence-okr-markdown`,Q],[`longzai-intelligence-older`,Q],[`longzai-intelligence-one`,Q],[`longzai-intelligence-one-digest`,Q],[`longzai-intelligence-one-digest-data`,Q],[`longzai-intelligence-one-digest-markdown`,Q],[`longzai-intelligence-one-digest-registry`,Q],[`longzai-intelligence-one-trae-works`,Q],[`longzai-intelligence-ontology`,Q],[`longzai-intelligence-open-pencil`,Q],[`longzai-intelligence-open-router`,Q],[`longzai-intelligence-open-router-data`,Q],[`longzai-intelligence-open-router-markdown`,Q],[`longzai-intelligence-opencode`,Q],[`longzai-intelligence-opencode-knowledge`,Q],[`longzai-intelligence-opportunity`,Q],[`longzai-intelligence-orchestry`,Q],[`longzai-intelligence-organization`,Q],[`longzai-intelligence-orm`,Q],[`longzai-intelligence-outfit`,Q],[`longzai-intelligence-outsourcing`,Q],[`longzai-intelligence-overseas`,Q],[`longzai-intelligence-pagination`,Q],[`longzai-intelligence-panel`,Q],[`longzai-intelligence-paper-reader`,Q],[`longzai-intelligence-parametric-industry`,Q],[`longzai-intelligence-partner`,Q],[`longzai-intelligence-pay`,Q],[`longzai-intelligence-payment`,Q],[`longzai-intelligence-permission`,Q],[`longzai-intelligence-personal-assistant`,Q],[`longzai-intelligence-philosophy`,Q],[`longzai-intelligence-philosophy-markdown`,Q],[`longzai-intelligence-philosophy-ontology`,Q],[`longzai-intelligence-pi-knowledge`,Q],[`longzai-intelligence-pii`,Q],[`longzai-intelligence-pipeline`,Q],[`longzai-intelligence-pitfalls`,Q],[`longzai-intelligence-plugin-registry`,Q],[`longzai-intelligence-pm2`,Q],[`longzai-intelligence-policy-research`,Q],[`longzai-intelligence-port`,Q],[`longzai-intelligence-portal`,Q],[`longzai-intelligence-previewer`,Q],[`longzai-intelligence-prezi`,Q],[`longzai-intelligence-prisma`,Q],[`longzai-intelligence-process-monitor`,Q],[`longzai-intelligence-product-requirement`,Q],[`longzai-intelligence-product-research`,Q],[`longzai-intelligence-programming-language`,Q],[`longzai-intelligence-project`,Q],[`longzai-intelligence-project-data`,Q],[`longzai-intelligence-project-markdown`,Q],[`longzai-intelligence-project-portfolio`,Q],[`longzai-intelligence-project-registry`,Q],[`longzai-intelligence-promotion`,Q],[`longzai-intelligence-proposals`,Q],[`longzai-intelligence-prospect`,Q],[`longzai-intelligence-psychoanalyst`,Q],[`longzai-intelligence-publication`,Q],[`longzai-intelligence-qcloud`,Q],[`longzai-intelligence-quant`,Q],[`longzai-intelligence-queue`,Q],[`longzai-intelligence-quick-notes`,Q],[`longzai-intelligence-react-devtools`,Q],[`longzai-intelligence-react-native`,Q],[`longzai-intelligence-reader`,Q],[`longzai-intelligence-reading-distinction`,Q],[`longzai-intelligence-reading-shanhaijing`,Q],[`longzai-intelligence-readme`,Q],[`longzai-intelligence-reasoning`,Q],[`longzai-intelligence-records`,Q],[`longzai-intelligence-recruitment`,Q],[`longzai-intelligence-reflections`,Q],[`longzai-intelligence-release`,Q],[`longzai-intelligence-release-markdown`,Q],[`longzai-intelligence-reliability`,Q],[`longzai-intelligence-remote-desktop`,Q],[`longzai-intelligence-remote-machine`,Q],[`longzai-intelligence-remote-machine-registry`,Q],[`longzai-intelligence-remotion`,Q],[`longzai-intelligence-report`,Q],[`longzai-intelligence-repository`,Q],[`longzai-intelligence-repository-handover`,Q],[`longzai-intelligence-research-report`,Q],[`longzai-intelligence-research-report-data`,Q],[`longzai-intelligence-research-report-markdown`,Q],[`longzai-intelligence-research-report-registry`,Q],[`longzai-intelligence-resilience`,Q],[`longzai-intelligence-reverse-engineering`,Q],[`longzai-intelligence-review-of-financial-studies-data`,Q],[`longzai-intelligence-reviewer`,Q],[`longzai-intelligence-risk`,Q],[`longzai-intelligence-roadmap`,Q],[`longzai-intelligence-roadmap-data`,Q],[`longzai-intelligence-roadmap-markdown`,Q],[`longzai-intelligence-router`,Q],[`longzai-intelligence-rss`,Q],[`longzai-intelligence-rss-markdown`,Q],[`longzai-intelligence-runtime`,Q],[`longzai-intelligence-runtime-registry`,Q],[`longzai-intelligence-sales`,Q],[`longzai-intelligence-scanner`,Q],[`longzai-intelligence-schedule-markdown`,Q],[`longzai-intelligence-schedule-registry`,Q],[`longzai-intelligence-scheduler`,Q],[`longzai-intelligence-schema`,Q],[`longzai-intelligence-scope`,Q],[`longzai-intelligence-scrape`,Q],[`longzai-intelligence-screenshots`,Q],[`longzai-intelligence-scripts-registry`,Q],[`longzai-intelligence-search`,Q],[`longzai-intelligence-security`,Q],[`longzai-intelligence-security-bounty-registry`,Q],[`longzai-intelligence-security-inventory`,Q],[`longzai-intelligence-serverless`,Q],[`longzai-intelligence-share`,Q],[`longzai-intelligence-sheet`,Q],[`longzai-intelligence-short-video`,Q],[`longzai-intelligence-skill`,Q],[`longzai-intelligence-slider`,Q],[`longzai-intelligence-smart-transition`,Q],[`longzai-intelligence-sms`,Q],[`longzai-intelligence-software-factory`,Q],[`longzai-intelligence-soul`,Q],[`longzai-intelligence-specs`,Q],[`longzai-intelligence-spline`,Q],[`longzai-intelligence-sports`,Q],[`longzai-intelligence-ssl`,Q],[`longzai-intelligence-startup`,Q],[`longzai-intelligence-state-machine`,Q],[`longzai-intelligence-storage`,Q],[`longzai-intelligence-strategy`,Q],[`longzai-intelligence-strategy-consulting`,Q],[`longzai-intelligence-strategy-consulting-data`,Q],[`longzai-intelligence-strategy-consulting-markdown`,Q],[`longzai-intelligence-supply-chain`,Q],[`longzai-intelligence-support`,Q],[`longzai-intelligence-survey`,Q],[`longzai-intelligence-system`,Q],[`longzai-intelligence-system-data`,Q],[`longzai-intelligence-system-markdown`,Q],[`longzai-intelligence-system-registry`,Q],[`longzai-intelligence-talk`,Q],[`longzai-intelligence-taro`,Q],[`longzai-intelligence-task`,Q],[`longzai-intelligence-task-data`,Q],[`longzai-intelligence-task-markdown`,Q],[`longzai-intelligence-telemetry`,Q],[`longzai-intelligence-templates`,Q],[`longzai-intelligence-tenant`,Q],[`longzai-intelligence-terminal`,Q],[`longzai-intelligence-testing`,Q],[`longzai-intelligence-thinking`,Q],[`longzai-intelligence-token-exchange`,Q],[`longzai-intelligence-token-finance`,Q],[`longzai-intelligence-token-handover`,Q],[`longzai-intelligence-toolchain`,Q],[`longzai-intelligence-topology`,Q],[`longzai-intelligence-tracking-bennett-brassard`,Q],[`longzai-intelligence-tracking-deng-yu`,Q],[`longzai-intelligence-tracking-hong-wang`,Q],[`longzai-intelligence-tracking-jacob-tsimerman`,Q],[`longzai-intelligence-tracking-john-clarke`,Q],[`longzai-intelligence-tracking-john-martinis`,Q],[`longzai-intelligence-tracking-john-pardon`,Q],[`longzai-intelligence-tracking-michel-devoret`,Q],[`longzai-intelligence-tracking-nation`,Q],[`longzai-intelligence-tracking-qbitai`,Q],[`longzai-intelligence-tracking-terrytao`,Q],[`longzai-intelligence-tracking-xiao-lin`,Q],[`longzai-intelligence-tracking-yu-bo`,Q],[`longzai-intelligence-trader`,Q],[`longzai-intelligence-trae`,Q],[`longzai-intelligence-training-data`,Q],[`longzai-intelligence-translator`,Q],[`longzai-intelligence-travel`,Q],[`longzai-intelligence-trending`,Q],[`longzai-intelligence-tsconfig`,Q],[`longzai-intelligence-tsdoc`,Q],[`longzai-intelligence-tsgo`,Q],[`longzai-intelligence-turbo`,Q],[`longzai-intelligence-turing-award-knowledge`,Q],[`longzai-intelligence-twitter`,Q],[`longzai-intelligence-twitter-data`,Q],[`longzai-intelligence-twitter-markdown`,Q],[`longzai-intelligence-typeorm`,Q],[`longzai-intelligence-usecase`,Q],[`longzai-intelligence-user-experience`,Q],[`longzai-intelligence-user-research`,Q],[`longzai-intelligence-userscript`,Q],[`longzai-intelligence-utils`,Q],[`longzai-intelligence-value-chain`,Q],[`longzai-intelligence-vector-search`,Q],[`longzai-intelligence-vendor`,Q],[`longzai-intelligence-venture-capital`,Q],[`longzai-intelligence-version`,Q],[`longzai-intelligence-video-generation`,Q],[`longzai-intelligence-video-player`,Q],[`longzai-intelligence-vite`,Q],[`longzai-intelligence-voice`,Q],[`longzai-intelligence-voice-recorder`,Q],[`longzai-intelligence-vscode-developer`,Q],[`longzai-intelligence-vuln`,Q],[`longzai-intelligence-vuln-data`,Q],[`longzai-intelligence-vuln-markdown`,Q],[`longzai-intelligence-vuln-registry`,Q],[`longzai-intelligence-warehouse`,Q],[`longzai-intelligence-wealth`,Q],[`longzai-intelligence-web3`,Q],[`longzai-intelligence-webhook`,Q],[`longzai-intelligence-websocket`,Q],[`longzai-intelligence-wechat`,Q],[`longzai-intelligence-wechat-miniprogram`,Q],[`longzai-intelligence-wechat-pay`,Q],[`longzai-intelligence-wifi`,Q],[`longzai-intelligence-wiki`,Q],[`longzai-intelligence-word`,Q],[`longzai-intelligence-work`,Q],[`longzai-intelligence-worker`,Q],[`longzai-intelligence-workflow`,Q],[`longzai-intelligence-workflow-data`,Q],[`longzai-intelligence-workflow-markdown`,Q],[`longzai-intelligence-workflow-registry`,Q],[`longzai-intelligence-workspace`,Q],[`longzai-intelligence-writer`,Q],[`longzai-intelligence-xiaohongshu`,Q],[`longzai-intelligence-xiaohongshu-data`,Q],[`longzai-intelligence-xiaohongshu-markdown`,Q],[`longzai-intelligence-youtube`,Q],[`longzai-intelligence-youtube-data`,Q],[`longzai-intelligence-youtube-markdown`,Q],[`longzai-intelligence-zcode`,Q],[`longzai-intelligence-zcode-cleaner`,Q],[`longzai-intelligence-zcode-commit`,Q],[`longzai-intelligence-zcode-knowledge`,Q],[`longzai-intelligence-zcode-remote`,Q],[`longzai-intelligence-zcode-security`,Q],[`longzai-intelligence-zed-delta-knowledge`,Q],[`longzai-intelligence-zhihu`,Q],[`longzai-intelligence-zhihu-data`,Q],[`longzai-intelligence-zhihu-markdown`,Q]]),_f=`LZI_GLOBALS_ROOT`,vf=`lzi-bun-install.config.ts`,yf=/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/;var bf=class extends Error{details;constructor(e,t=`install.extraScopes`){super(`${t} 校验失败:\n${e.map(e=>`- ${e}`).join(`
209
- `)}`),this.name=`InstallScopesError`,this.details=e}};function xf(e){if(typeof e!=`string`)return!1;try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`}catch{return!1}}function Sf(e,t,n,r){let i=e instanceof Map?Object.fromEntries(e):{...e},a=[],o={};for(let[n,i]of Object.entries(t??{})){let t=n.replace(/^@+/,``);t.length===0||!yf.test(t)?a.push(`\`${n}\` 不是合法 scope 名(仅允许字母/数字开头,后接字母/数字与 . _ -,@ 前缀可省略)`):xf(i)?o[t]!==void 0&&o[t]!==i?a.push(`\`${t}\` 在 extraScopes 内重复声明且安装源不一致`):(e instanceof Map?e.has(t):Object.hasOwn(e,t))?a.push(`\`${t}\` 与预定义 scope 冲突(预定义不可覆盖,如需调整请在 ${r} 维护)`):o[t]=i:a.push(`\`${n}\` 的安装源 \`${String(i)}\` 不是合法的 http/https URL`)}let s=/* @__PURE__ */ new Set;for(let e of n??[]){let t=e.replace(/^@+/,``);t.length===0||!yf.test(t)?a.push(`\`${e}\` 不是合法 scope 名(仅允许字母/数字开头,后接字母/数字与 . _ -,@ 前缀可省略)`):o[t]===void 0?s.add(t):a.push(`\`${t}\` 同时出现在 extraScopes 与 privateScopes(追加公网安装源与私有轨声明矛盾)`)}if(a.length>0)throw new bf(a);for(let[e,t]of Object.entries(o))i[e]=t;for(let e of s)delete i[e];return i}function Cf(e,t,n,r){let i=Sf(e,t,n,`globals 仓 lzi-bun-install.config.ts`),a=r?.replace(/^@+/,``),o=new Set((n??[]).map(e=>e.replace(/^@+/,``)));return a!==void 0&&yf.test(a)&&!Object.hasOwn(i,a)&&!o.has(a)&&(i[a]=`https://registry.npmjs.org/`),i}function wf(e){let t=[];if(typeof e!=`object`||!e)throw new bf([`default export 必须是对象({ scopes: { ... } })`],`globals 预设 lzi-bun-install.config.ts`);let n=typeof e==`object`&&e&&`scopes`in e?e.scopes:void 0;if(typeof n!=`object`||!n||Array.isArray(n))throw new bf([`scopes 必须是 scope → registry 的对象映射`],`globals 预设 lzi-bun-install.config.ts`);let r={};for(let[e,i]of Object.entries(n))yf.test(e)?typeof i!=`string`||!xf(i)?t.push(`\`${e}\` 的安装源 \`${String(i)}\` 不是合法的 http/https URL`):r[e]=i:t.push(`\`${e}\` 不是合法 scope 名(仅允许字母/数字开头,后接字母/数字与 . _ -,不含 @ 前缀)`);if(t.length>0)throw new bf(t,`globals 预设 lzi-bun-install.config.ts`);if(Object.keys(r).length===0)throw new bf([`scopes 清单为空(真源不允许空清单)`],`globals 预设 lzi-bun-install.config.ts`);return r}var Tf=class extends Error{configPath;constructor(e,t,n){super(e,n),this.name=`SharedConfigError`,this.configPath=t}},Ef=class extends Tf{searchFrom;constructor(e){super(`未在 ${e} 找到配置文件`,e),this.name=`SharedConfigNotFoundError`,this.searchFrom=e}},Df=class extends Tf{issues;constructor(e,t){super(`配置校验失败,共 ${e.length} 个问题`,t),this.name=`SharedConfigValidationError`,this.issues=e}};function Of(e,t,n,r){let i=e;if(r.schema!==void 0){let e=r.schema.safeParse(i);if(!e.success)throw new Df(e.error.issues,t);i=e.data}return r.transform!==void 0&&(i=r.transform(i,n)),i}function kf(e){return e instanceof Error&&e.message.length>0?`,底层原因为 ${e.name}: ${e.message}`:``}var Af=class extends Tf{cause;constructor(e,t){super(`加载配置文件 ${e} 失败${kf(t)}`,e,{cause:t}),this.name=`SharedConfigLoadError`,this.cause=t}};function jf(e){return typeof e==`object`&&!!e}function Mf(e){return typeof e==`object`&&!!e}async function Nf(e,t={}){let r=d(e);if(!n(r))throw new Ef(r);let i;try{let e=await import(r);i=jf(e)?e.default:void 0}catch(e){throw new Af(r,e)}if(i===void 0)throw new Af(r,TypeError(`配置文件缺少默认导出`));if(!Mf(i))throw new Af(r,TypeError(`配置文件的默认导出必须是对象`));return{config:Of(i,r,c(r),t),configFilePath:r}}function Pf(e=process.cwd()){let t=d(e);for(;;){let e=l(t,`lzi.config.ts`);if(n(e))return e;let r=c(t);if(r===t)return null;t=r}}async function Ff(e={}){let t=e.cwd??process.cwd(),n=Pf(t);if(n===null)throw new Ef(t);let r=d(n,`..`),{config:i}=await Nf(n);return{config:i,configPath:r,configFilePath:n}}function If(e){return typeof e==`object`&&!!e}async function Lf(e){let t;try{t=await x(e)}catch(t){throw new Af(e,t)}let n=t.filter(e=>e.endsWith(`.config.ts`)).sort();if(n.length===0)throw new Af(e,Error(`配置目录内没有 .config.ts 分片文件`));let r={};for(let t of n){let n=await Nf(l(e,t));r={...r,...n.config}}let i=r;if(!If(i))throw new Af(e,Error(`配置目录合并结果不是对象形态`));return i}function Rf(e,t=process.cwd()){let n=Array.isArray(e)?e:[e],r=d(t);for(;;){for(let e of n){let t=l(r,e);if(zf(t))return t}let e=c(r);if(e===r)return null;r=e}}function zf(e){try{return o(e).isDirectory()}catch{return!1}}function Bf(e,t=process.cwd()){let r=Array.isArray(e)?e:[e],i=d(t);for(;;){for(let e of r){let t=l(i,e);if(n(t))return t}let e=c(i);if(e===i)return null;i=e}}function Vf(e){return typeof e==`object`&&!!e}function Hf(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}async function Uf(e={}){let t=e.cwd??d(process.cwd());if(e.explicitPath!==void 0){let t=await Nf(e.explicitPath,{schema:e.schema,transform:e.transform});return{success:!0,config:t.config,source:`explicit`,configFilePath:t.configFilePath}}if(e.standaloneFile!==void 0){let n=Bf(e.standaloneFile,t);if(n!==null){let{config:t}=await Nf(n);return{success:!0,config:Of(t,n,c(n),e),source:`standalone`,configFilePath:n}}}if(e.standaloneDir!==void 0){let n=Rf(e.standaloneDir,t);if(n!==null)return{success:!0,config:Of(await Lf(n),n,n,e),source:`standalone`,configFilePath:n}}if(e.unifiedField!==void 0){let n,r;try{let{config:i,configFilePath:a}=await Ff({cwd:t}),o=i;n=Hf(o)?o[e.unifiedField]:void 0,r=a}catch(e){if(!(e instanceof Ef))throw e}if(r!==void 0&&n!==void 0&&Vf(n))return{success:!0,config:Of(n,r,c(r),e),source:`unified`,configFilePath:r}}return{success:!1,configFilePath:null}}const Wf=[`packages/*`,`apps/*`];function Gf(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Kf(e){if(Array.isArray(e))return e.every(e=>typeof e==`string`)?e:void 0;if(Gf(e)){let t=e.packages;if(Array.isArray(t)&&t.every(e=>typeof e==`string`))return{packages:t}}}function qf(e){let t=d(e,`package.json`);if(!n(t))throw new Ef(e);let r;try{let e=JSON.parse(i(t,`utf8`));r=Gf(e)?Kf(e.workspaces):void 0}catch(e){throw new Af(t,e)}let a=Array.isArray(r)?r:r?.packages;return a&&a.length>0?a:Wf}async function Jf(e,t={}){let r=qf(e),a=/* @__PURE__ */ new Set,o=[];for(let s of r){let r=new Bun.Glob(`${s}/package.json`);for await(let s of r.scan({cwd:e,absolute:!0,onlyFiles:!0})){let e=d(s,`..`);if(a.has(e))continue;let r;try{let e=JSON.parse(i(s,`utf8`));r=typeof e==`object`&&e?e:void 0}catch{continue}r!==void 0&&typeof r.name==`string`&&r.name.length!==0&&(t.configFileName!==void 0&&!n(d(e,t.configFileName))||(a.add(e),o.push({name:r.name,dir:e})))}}return o}var Yf=class extends Error{bunfigPath;reason;constructor(e,t){super(`${e} 校验失败:${t};请运行 bun run bun-config:generate 后重试`),this.name=`BunfigDriftError`,this.bunfigPath=e,this.reason=t}},Xf=class extends Error{bunfigPath;constructor(e){super(`${e} 已存在且非 lzi-bun-cli 生成(缺少 @lzi-bun-cli 自动生成,请勿编辑 标记),如需 lzi-bun-cli 接管,请删除该文件或手动合并后重试`),this.name=`BunfigProtectedError`,this.bunfigPath=e}};function Zf(e){return`"${e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}"`}function Qf(e,t){let n=e.map(e=>Zf(e)),r=`[${n.join(`, `)}]`;return`${t} = `.length+r.length<=100?r:`[\n${n.map(e=>` ${e},`).join(`
210
- `)}\n]`}function $f(e){let t=[`registry = ${Zf(e.registry)}`],n=tp(`linker`,e.linker);n&&t.push(n);let r=tp(`globalStore`,e.globalStore);r&&t.push(r);let i=Object.entries(e.scopes).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>`${Zf(`@${e}`)} = ${Zf(t)}`),a=[`[install]\n${t.join(`
208
+ 修复指引: 执行 lzi-bun-cli node-links fix 回收悬挂死链后重试,有效链接零触碰`),process.exit(Math.min(t.dangling.length,255))}X(`安装布局一致,未发现悬挂符号链接`)}catch(e){Z(`错误: ${e instanceof Error?e.message:String(e)}`),process.exit(1)}},mf=async()=>{let e=process.cwd();X(`正在扫描 ${e} 下的悬挂符号链接...`);try{let t=await df(e);if(!t.hasWorkspaces){X(`未声明 workspaces,非 bun workspaces monorepo,跳过悬挂链接回收`);return}if(t.dangling.length===0){X(`未发现悬挂符号链接,无需回收,共巡查 ${t.scannedNodeModulesRoots} 个 node_modules 树`);return}X(`发现 ${t.dangling.length} 根悬挂符号链接,开始回收:`);for(let e of t.dangling)X(` ${e.path} 指向已不存在的 ${e.target}`);let n=await ff(e,t.dangling);for(let e of n.removed)X(`已回收 ${e}`);for(let e of n.kept)Z(`未能回收 ${e},链接状态已变化,请人工确认`);let r=await df(e);X(`回收完成,清除 ${n.removed.length} 根,剩余悬挂 ${r.dangling.length} 根,有效链接零触碰`),(r.dangling.length>0||n.kept.length>0)&&process.exit(1)}catch(e){Z(`错误: ${e instanceof Error?e.message:String(e)}`),process.exit(1)}};function hf(e,t=`./src/__tests__/helpers/bootstrap.ts`){let n=[t,...(e?.test?.preload??[]).filter(e=>e!==t)];return{...e,test:{...e?.test,preload:n}}}const Q=`https://registry.npmjs.org/`,gf=/* @__PURE__ */ new Map([[`longzai-intelligence`,Q],[`longzai-intelligence-agent-tools`,Q],[`longzai-intelligence-audit`,Q],[`longzai-intelligence-auth`,Q],[`longzai-intelligence-builder`,Q],[`longzai-intelligence-bun`,Q],[`longzai-intelligence-cache`,Q],[`longzai-intelligence-cli`,Q],[`longzai-intelligence-config`,Q],[`longzai-intelligence-dependencies`,Q],[`longzai-intelligence-design-system`,Q],[`longzai-intelligence-dev-tools`,Q],[`longzai-intelligence-electron`,Q],[`longzai-intelligence-error`,Q],[`longzai-intelligence-event-bus`,Q],[`longzai-intelligence-logger`,Q],[`longzai-intelligence-okr`,Q],[`longzai-intelligence-oxfmt`,Q],[`longzai-intelligence-oxlint`,Q],[`longzai-intelligence-plugin`,Q],[`longzai-intelligence-shared-config`,Q],[`longzai-intelligence-shared-kernel`,Q],[`longzai-intelligence-scripts`,Q],[`longzai-intelligence-standards`,Q],[`longzai-intelligence-transport`,Q],[`longzai-intelligence-typescript`,Q],[`longzai-intelligence-vscode`,Q],[`longzai-intelligence-zod`,Q],[`longzai-intelligence-prettier`,Q],[`longzai-intelligence-tsdown`,Q],[`longzai-intelligence-vitest`,Q],[`longzai-intelligence-academy`,Q],[`longzai-intelligence-accounting`,Q],[`longzai-intelligence-activity`,Q],[`longzai-intelligence-administration`,Q],[`longzai-intelligence-agent`,Q],[`longzai-intelligence-agent-broadcast`,Q],[`longzai-intelligence-agent-collaboration`,Q],[`longzai-intelligence-agent-endless`,Q],[`longzai-intelligence-agent-migrator`,Q],[`longzai-intelligence-agent-monitor`,Q],[`longzai-intelligence-agent-prompts`,Q],[`longzai-intelligence-agent-relation`,Q],[`longzai-intelligence-agent-session`,Q],[`longzai-intelligence-agent-swarm`,Q],[`longzai-intelligence-agent-tasks`,Q],[`longzai-intelligence-agent-tasks-data`,Q],[`longzai-intelligence-agent-ui`,Q],[`longzai-intelligence-analytics`,Q],[`longzai-intelligence-api`,Q],[`longzai-intelligence-app-gallery`,Q],[`longzai-intelligence-app-store`,Q],[`longzai-intelligence-architecture`,Q],[`longzai-intelligence-architecture-expert`,Q],[`longzai-intelligence-arkts`,Q],[`longzai-intelligence-art`,Q],[`longzai-intelligence-artifact`,Q],[`longzai-intelligence-artifact-registry`,Q],[`longzai-intelligence-arxiv`,Q],[`longzai-intelligence-arxiv-data`,Q],[`longzai-intelligence-arxiv-markdown`,Q],[`longzai-intelligence-atomic`,Q],[`longzai-intelligence-attention`,Q],[`longzai-intelligence-audio`,Q],[`longzai-intelligence-audio-assistant`,Q],[`longzai-intelligence-augmented-reality`,Q],[`longzai-intelligence-auto-research`,Q],[`longzai-intelligence-automate`,Q],[`longzai-intelligence-benchmark`,Q],[`longzai-intelligence-bilibili`,Q],[`longzai-intelligence-bilibili-data`,Q],[`longzai-intelligence-bilibili-markdown`,Q],[`longzai-intelligence-billing`,Q],[`longzai-intelligence-blackboard`,Q],[`longzai-intelligence-blackboard-data`,Q],[`longzai-intelligence-blackboard-markdown`,Q],[`longzai-intelligence-bluetooth`,Q],[`longzai-intelligence-board`,Q],[`longzai-intelligence-bootstrap`,Q],[`longzai-intelligence-bootstrap-registry`,Q],[`longzai-intelligence-bounty-registry`,Q],[`longzai-intelligence-brawl-stars`,Q],[`longzai-intelligence-broker`,Q],[`longzai-intelligence-bt`,Q],[`longzai-intelligence-business-plan`,Q],[`longzai-intelligence-calendar`,Q],[`longzai-intelligence-camera`,Q],[`longzai-intelligence-canvas`,Q],[`longzai-intelligence-capture`,Q],[`longzai-intelligence-change-maker`,Q],[`longzai-intelligence-changelog`,Q],[`longzai-intelligence-changeset`,Q],[`longzai-intelligence-chat`,Q],[`longzai-intelligence-chess`,Q],[`longzai-intelligence-circuit`,Q],[`longzai-intelligence-claude-code`,Q],[`longzai-intelligence-claude-knowledge`,Q],[`longzai-intelligence-clipboard-share`,Q],[`longzai-intelligence-closed-loop`,Q],[`longzai-intelligence-closed-loop-data`,Q],[`longzai-intelligence-closed-loop-markdown`,Q],[`longzai-intelligence-cloud`,Q],[`longzai-intelligence-code`,Q],[`longzai-intelligence-code-agent`,Q],[`longzai-intelligence-code-reviewer`,Q],[`longzai-intelligence-codebase-research`,Q],[`longzai-intelligence-coding-expert`,Q],[`longzai-intelligence-collaboration`,Q],[`longzai-intelligence-collective`,Q],[`longzai-intelligence-commerce`,Q],[`longzai-intelligence-commit`,Q],[`longzai-intelligence-competition-registry`,Q],[`longzai-intelligence-composer`,Q],[`longzai-intelligence-concrete`,Q],[`longzai-intelligence-concrete-industry`,Q],[`longzai-intelligence-config-registry`,Q],[`longzai-intelligence-context`,Q],[`longzai-intelligence-contract`,Q],[`longzai-intelligence-contract-parity`,Q],[`longzai-intelligence-cookery`,Q],[`longzai-intelligence-country`,Q],[`longzai-intelligence-creativity`,Q],[`longzai-intelligence-cross-platform`,Q],[`longzai-intelligence-crossref`,Q],[`longzai-intelligence-crossref-markdown`,Q],[`longzai-intelligence-crypto`,Q],[`longzai-intelligence-customer-service`,Q],[`longzai-intelligence-cut`,Q],[`longzai-intelligence-dag`,Q],[`longzai-intelligence-dashboard`,Q],[`longzai-intelligence-data`,Q],[`longzai-intelligence-data-science`,Q],[`longzai-intelligence-database`,Q],[`longzai-intelligence-decenterlization`,Q],[`longzai-intelligence-decision`,Q],[`longzai-intelligence-deepseek`,Q],[`longzai-intelligence-deepseek-harness`,Q],[`longzai-intelligence-deepseek-harness-knowledge`,Q],[`longzai-intelligence-delta`,Q],[`longzai-intelligence-deploy`,Q],[`longzai-intelligence-design`,Q],[`longzai-intelligence-design-lab`,Q],[`longzai-intelligence-design-registry`,Q],[`longzai-intelligence-design-trending`,Q],[`longzai-intelligence-device`,Q],[`longzai-intelligence-dimensions`,Q],[`longzai-intelligence-discipline`,Q],[`longzai-intelligence-discovery`,Q],[`longzai-intelligence-disk-space`,Q],[`longzai-intelligence-disk-space-data`,Q],[`longzai-intelligence-disk-space-markdown`,Q],[`longzai-intelligence-distill`,Q],[`longzai-intelligence-docs`,Q],[`longzai-intelligence-docs-registry`,Q],[`longzai-intelligence-document`,Q],[`longzai-intelligence-douyin`,Q],[`longzai-intelligence-douyin-data`,Q],[`longzai-intelligence-douyin-markdown`,Q],[`longzai-intelligence-drone`,Q],[`longzai-intelligence-edge`,Q],[`longzai-intelligence-electrobun`,Q],[`longzai-intelligence-elysia`,Q],[`longzai-intelligence-embodied`,Q],[`longzai-intelligence-empowerment`,Q],[`longzai-intelligence-engineering`,Q],[`longzai-intelligence-env`,Q],[`longzai-intelligence-env-registry`,Q],[`longzai-intelligence-equilibrium`,Q],[`longzai-intelligence-eslint`,Q],[`longzai-intelligence-event`,Q],[`longzai-intelligence-event-tracking`,Q],[`longzai-intelligence-evolution`,Q],[`longzai-intelligence-excel`,Q],[`longzai-intelligence-exchange-rate`,Q],[`longzai-intelligence-execution`,Q],[`longzai-intelligence-experience`,Q],[`longzai-intelligence-expert`,Q],[`longzai-intelligence-expert-thinking`,Q],[`longzai-intelligence-fde`,Q],[`longzai-intelligence-feature-flags`,Q],[`longzai-intelligence-features`,Q],[`longzai-intelligence-federation`,Q],[`longzai-intelligence-feed`,Q],[`longzai-intelligence-feishu`,Q],[`longzai-intelligence-fields-medal-knowledge`,Q],[`longzai-intelligence-file-processing`,Q],[`longzai-intelligence-findings`,Q],[`longzai-intelligence-fitness`,Q],[`longzai-intelligence-font`,Q],[`longzai-intelligence-game`,Q],[`longzai-intelligence-game-studio`,Q],[`longzai-intelligence-gantt`,Q],[`longzai-intelligence-gateway`,Q],[`longzai-intelligence-geo`,Q],[`longzai-intelligence-gesture`,Q],[`longzai-intelligence-git`,Q],[`longzai-intelligence-git-commit`,Q],[`longzai-intelligence-git-insight`,Q],[`longzai-intelligence-git-reviewer`,Q],[`longzai-intelligence-git-swarm`,Q],[`longzai-intelligence-git-swarm-registry`,Q],[`longzai-intelligence-gitcode`,Q],[`longzai-intelligence-github-data`,Q],[`longzai-intelligence-github-markdown`,Q],[`longzai-intelligence-github-trending`,Q],[`longzai-intelligence-github-trending-data`,Q],[`longzai-intelligence-github-trending-markdown`,Q],[`longzai-intelligence-globals`,Q],[`longzai-intelligence-growth`,Q],[`longzai-intelligence-growth-registry`,Q],[`longzai-intelligence-handover`,Q],[`longzai-intelligence-hardware`,Q],[`longzai-intelligence-harness`,Q],[`longzai-intelligence-healthcare`,Q],[`longzai-intelligence-history`,Q],[`longzai-intelligence-horizon`,Q],[`longzai-intelligence-human-resource`,Q],[`longzai-intelligence-i18n`,Q],[`longzai-intelligence-idea`,Q],[`longzai-intelligence-identity`,Q],[`longzai-intelligence-ime`,Q],[`longzai-intelligence-impact-maker`,Q],[`longzai-intelligence-inbox`,Q],[`longzai-intelligence-inbox-registry`,Q],[`longzai-intelligence-input-data`,Q],[`longzai-intelligence-input-markdown`,Q],[`longzai-intelligence-insight`,Q],[`longzai-intelligence-intellectual-property`,Q],[`longzai-intelligence-intent`,Q],[`longzai-intelligence-intentionomics`,Q],[`longzai-intelligence-interview`,Q],[`longzai-intelligence-issues`,Q],[`longzai-intelligence-jev`,Q],[`longzai-intelligence-jev-knowledge`,Q],[`longzai-intelligence-jev-system`,Q],[`longzai-intelligence-journal-of-finance-data`,Q],[`longzai-intelligence-journal-of-financial-and-quantitative-analysis-data`,Q],[`longzai-intelligence-journal-of-financial-economics-data`,Q],[`longzai-intelligence-journals`,Q],[`longzai-intelligence-journals-2026-10`,Q],[`longzai-intelligence-journals-markdown`,Q],[`longzai-intelligence-journals-registry`,Q],[`longzai-intelligence-key-management`,Q],[`longzai-intelligence-knowledge`,Q],[`longzai-intelligence-knowledge-graph`,Q],[`longzai-intelligence-knowledge-markdown`,Q],[`longzai-intelligence-kol`,Q],[`longzai-intelligence-kol-data`,Q],[`longzai-intelligence-kol-markdown`,Q],[`longzai-intelligence-kol-registry`,Q],[`longzai-intelligence-language-model`,Q],[`longzai-intelligence-law`,Q],[`longzai-intelligence-law-data`,Q],[`longzai-intelligence-law-markdown`,Q],[`longzai-intelligence-lean`,Q],[`longzai-intelligence-ledger`,Q],[`longzai-intelligence-legal`,Q],[`longzai-intelligence-liquid-glass`,Q],[`longzai-intelligence-living-previewer`,Q],[`longzai-intelligence-loop`,Q],[`longzai-intelligence-machine-learning`,Q],[`longzai-intelligence-mail`,Q],[`longzai-intelligence-mandala`,Q],[`longzai-intelligence-map`,Q],[`longzai-intelligence-markdown`,Q],[`longzai-intelligence-marketing`,Q],[`longzai-intelligence-marketplace`,Q],[`longzai-intelligence-math`,Q],[`longzai-intelligence-mcn`,Q],[`longzai-intelligence-mcp`,Q],[`longzai-intelligence-mechanisms`,Q],[`longzai-intelligence-mechanisms-registry`,Q],[`longzai-intelligence-media`,Q],[`longzai-intelligence-meditation`,Q],[`longzai-intelligence-meeting-notes`,Q],[`longzai-intelligence-memory`,Q],[`longzai-intelligence-mentor`,Q],[`longzai-intelligence-messaging`,Q],[`longzai-intelligence-mindset`,Q],[`longzai-intelligence-minimax-knowldege`,Q],[`longzai-intelligence-mission-control`,Q],[`longzai-intelligence-model-fusion`,Q],[`longzai-intelligence-model-gateway`,Q],[`longzai-intelligence-moment`,Q],[`longzai-intelligence-montage`,Q],[`longzai-intelligence-movie`,Q],[`longzai-intelligence-music-video`,Q],[`longzai-intelligence-music-video-data`,Q],[`longzai-intelligence-narrative-analyzer`,Q],[`longzai-intelligence-nation`,Q],[`longzai-intelligence-nginx`,Q],[`longzai-intelligence-nginx-cli`,Q],[`longzai-intelligence-nobel-prize-knowledge`,Q],[`longzai-intelligence-notification`,Q],[`longzai-intelligence-npm`,Q],[`longzai-intelligence-npm-registry`,Q],[`longzai-intelligence-npm-registry-data`,Q],[`longzai-intelligence-observability`,Q],[`longzai-intelligence-office-industry`,Q],[`longzai-intelligence-okr-data`,Q],[`longzai-intelligence-okr-markdown`,Q],[`longzai-intelligence-older`,Q],[`longzai-intelligence-one`,Q],[`longzai-intelligence-one-digest`,Q],[`longzai-intelligence-one-digest-data`,Q],[`longzai-intelligence-one-digest-markdown`,Q],[`longzai-intelligence-one-digest-registry`,Q],[`longzai-intelligence-one-trae-works`,Q],[`longzai-intelligence-ontology`,Q],[`longzai-intelligence-open-pencil`,Q],[`longzai-intelligence-open-router`,Q],[`longzai-intelligence-open-router-data`,Q],[`longzai-intelligence-open-router-markdown`,Q],[`longzai-intelligence-opencode`,Q],[`longzai-intelligence-opencode-knowledge`,Q],[`longzai-intelligence-opportunity`,Q],[`longzai-intelligence-orchestry`,Q],[`longzai-intelligence-organization`,Q],[`longzai-intelligence-orm`,Q],[`longzai-intelligence-outfit`,Q],[`longzai-intelligence-outsourcing`,Q],[`longzai-intelligence-overseas`,Q],[`longzai-intelligence-pagination`,Q],[`longzai-intelligence-panel`,Q],[`longzai-intelligence-paper-reader`,Q],[`longzai-intelligence-parametric-industry`,Q],[`longzai-intelligence-partner`,Q],[`longzai-intelligence-pay`,Q],[`longzai-intelligence-payment`,Q],[`longzai-intelligence-permission`,Q],[`longzai-intelligence-personal-assistant`,Q],[`longzai-intelligence-philosophy`,Q],[`longzai-intelligence-philosophy-markdown`,Q],[`longzai-intelligence-philosophy-ontology`,Q],[`longzai-intelligence-pi-knowledge`,Q],[`longzai-intelligence-pii`,Q],[`longzai-intelligence-pipeline`,Q],[`longzai-intelligence-pitfalls`,Q],[`longzai-intelligence-plugin-registry`,Q],[`longzai-intelligence-pm2`,Q],[`longzai-intelligence-policy-research`,Q],[`longzai-intelligence-port`,Q],[`longzai-intelligence-portal`,Q],[`longzai-intelligence-previewer`,Q],[`longzai-intelligence-prezi`,Q],[`longzai-intelligence-prisma`,Q],[`longzai-intelligence-process-monitor`,Q],[`longzai-intelligence-product-requirement`,Q],[`longzai-intelligence-product-research`,Q],[`longzai-intelligence-programming-language`,Q],[`longzai-intelligence-project`,Q],[`longzai-intelligence-project-data`,Q],[`longzai-intelligence-project-markdown`,Q],[`longzai-intelligence-project-portfolio`,Q],[`longzai-intelligence-project-registry`,Q],[`longzai-intelligence-promotion`,Q],[`longzai-intelligence-proposals`,Q],[`longzai-intelligence-prospect`,Q],[`longzai-intelligence-psychoanalyst`,Q],[`longzai-intelligence-publication`,Q],[`longzai-intelligence-qcloud`,Q],[`longzai-intelligence-quant`,Q],[`longzai-intelligence-queue`,Q],[`longzai-intelligence-quick-notes`,Q],[`longzai-intelligence-react-devtools`,Q],[`longzai-intelligence-react-native`,Q],[`longzai-intelligence-reader`,Q],[`longzai-intelligence-reading-distinction`,Q],[`longzai-intelligence-reading-shanhaijing`,Q],[`longzai-intelligence-readme`,Q],[`longzai-intelligence-reasoning`,Q],[`longzai-intelligence-records`,Q],[`longzai-intelligence-recruitment`,Q],[`longzai-intelligence-reflections`,Q],[`longzai-intelligence-release`,Q],[`longzai-intelligence-release-markdown`,Q],[`longzai-intelligence-reliability`,Q],[`longzai-intelligence-remote-desktop`,Q],[`longzai-intelligence-remote-machine`,Q],[`longzai-intelligence-remote-machine-registry`,Q],[`longzai-intelligence-remotion`,Q],[`longzai-intelligence-report`,Q],[`longzai-intelligence-repository`,Q],[`longzai-intelligence-repository-handover`,Q],[`longzai-intelligence-research-report`,Q],[`longzai-intelligence-research-report-data`,Q],[`longzai-intelligence-research-report-markdown`,Q],[`longzai-intelligence-research-report-registry`,Q],[`longzai-intelligence-resilience`,Q],[`longzai-intelligence-reverse-engineering`,Q],[`longzai-intelligence-review-of-financial-studies-data`,Q],[`longzai-intelligence-reviewer`,Q],[`longzai-intelligence-risk`,Q],[`longzai-intelligence-roadmap`,Q],[`longzai-intelligence-roadmap-data`,Q],[`longzai-intelligence-roadmap-markdown`,Q],[`longzai-intelligence-router`,Q],[`longzai-intelligence-rss`,Q],[`longzai-intelligence-rss-markdown`,Q],[`longzai-intelligence-runtime`,Q],[`longzai-intelligence-runtime-registry`,Q],[`longzai-intelligence-sales`,Q],[`longzai-intelligence-scanner`,Q],[`longzai-intelligence-schedule-markdown`,Q],[`longzai-intelligence-schedule-registry`,Q],[`longzai-intelligence-scheduler`,Q],[`longzai-intelligence-schema`,Q],[`longzai-intelligence-scope`,Q],[`longzai-intelligence-scrape`,Q],[`longzai-intelligence-screenshots`,Q],[`longzai-intelligence-scripts-registry`,Q],[`longzai-intelligence-search`,Q],[`longzai-intelligence-security`,Q],[`longzai-intelligence-security-bounty-registry`,Q],[`longzai-intelligence-security-inventory`,Q],[`longzai-intelligence-serverless`,Q],[`longzai-intelligence-share`,Q],[`longzai-intelligence-sheet`,Q],[`longzai-intelligence-short-video`,Q],[`longzai-intelligence-skill`,Q],[`longzai-intelligence-slider`,Q],[`longzai-intelligence-smart-transition`,Q],[`longzai-intelligence-sms`,Q],[`longzai-intelligence-software-factory`,Q],[`longzai-intelligence-soul`,Q],[`longzai-intelligence-specs`,Q],[`longzai-intelligence-spline`,Q],[`longzai-intelligence-sports`,Q],[`longzai-intelligence-ssl`,Q],[`longzai-intelligence-startup`,Q],[`longzai-intelligence-state-machine`,Q],[`longzai-intelligence-storage`,Q],[`longzai-intelligence-strategy`,Q],[`longzai-intelligence-strategy-consulting`,Q],[`longzai-intelligence-strategy-consulting-data`,Q],[`longzai-intelligence-strategy-consulting-markdown`,Q],[`longzai-intelligence-supply-chain`,Q],[`longzai-intelligence-support`,Q],[`longzai-intelligence-survey`,Q],[`longzai-intelligence-system`,Q],[`longzai-intelligence-system-data`,Q],[`longzai-intelligence-system-markdown`,Q],[`longzai-intelligence-system-registry`,Q],[`longzai-intelligence-talk`,Q],[`longzai-intelligence-taro`,Q],[`longzai-intelligence-task`,Q],[`longzai-intelligence-task-data`,Q],[`longzai-intelligence-task-markdown`,Q],[`longzai-intelligence-telemetry`,Q],[`longzai-intelligence-templates`,Q],[`longzai-intelligence-tenant`,Q],[`longzai-intelligence-terminal`,Q],[`longzai-intelligence-testing`,Q],[`longzai-intelligence-thinking`,Q],[`longzai-intelligence-token-exchange`,Q],[`longzai-intelligence-token-finance`,Q],[`longzai-intelligence-token-handover`,Q],[`longzai-intelligence-toolchain`,Q],[`longzai-intelligence-topology`,Q],[`longzai-intelligence-tracking-bennett-brassard`,Q],[`longzai-intelligence-tracking-deng-yu`,Q],[`longzai-intelligence-tracking-hong-wang`,Q],[`longzai-intelligence-tracking-jacob-tsimerman`,Q],[`longzai-intelligence-tracking-john-clarke`,Q],[`longzai-intelligence-tracking-john-martinis`,Q],[`longzai-intelligence-tracking-john-pardon`,Q],[`longzai-intelligence-tracking-michel-devoret`,Q],[`longzai-intelligence-tracking-nation`,Q],[`longzai-intelligence-tracking-qbitai`,Q],[`longzai-intelligence-tracking-terrytao`,Q],[`longzai-intelligence-tracking-xiao-lin`,Q],[`longzai-intelligence-tracking-yu-bo`,Q],[`longzai-intelligence-trader`,Q],[`longzai-intelligence-trae`,Q],[`longzai-intelligence-training-data`,Q],[`longzai-intelligence-translator`,Q],[`longzai-intelligence-travel`,Q],[`longzai-intelligence-trending`,Q],[`longzai-intelligence-tsconfig`,Q],[`longzai-intelligence-tsdoc`,Q],[`longzai-intelligence-tsgo`,Q],[`longzai-intelligence-turbo`,Q],[`longzai-intelligence-turing-award-knowledge`,Q],[`longzai-intelligence-twitter`,Q],[`longzai-intelligence-twitter-data`,Q],[`longzai-intelligence-twitter-markdown`,Q],[`longzai-intelligence-typeorm`,Q],[`longzai-intelligence-usecase`,Q],[`longzai-intelligence-user-experience`,Q],[`longzai-intelligence-user-research`,Q],[`longzai-intelligence-userscript`,Q],[`longzai-intelligence-utils`,Q],[`longzai-intelligence-value-chain`,Q],[`longzai-intelligence-vector-search`,Q],[`longzai-intelligence-vendor`,Q],[`longzai-intelligence-venture-capital`,Q],[`longzai-intelligence-version`,Q],[`longzai-intelligence-video-generation`,Q],[`longzai-intelligence-video-player`,Q],[`longzai-intelligence-vite`,Q],[`longzai-intelligence-voice`,Q],[`longzai-intelligence-voice-recorder`,Q],[`longzai-intelligence-vscode-developer`,Q],[`longzai-intelligence-vuln`,Q],[`longzai-intelligence-vuln-data`,Q],[`longzai-intelligence-vuln-markdown`,Q],[`longzai-intelligence-vuln-registry`,Q],[`longzai-intelligence-warehouse`,Q],[`longzai-intelligence-wealth`,Q],[`longzai-intelligence-web3`,Q],[`longzai-intelligence-webhook`,Q],[`longzai-intelligence-websocket`,Q],[`longzai-intelligence-wechat`,Q],[`longzai-intelligence-wechat-miniprogram`,Q],[`longzai-intelligence-wechat-pay`,Q],[`longzai-intelligence-wifi`,Q],[`longzai-intelligence-wiki`,Q],[`longzai-intelligence-word`,Q],[`longzai-intelligence-work`,Q],[`longzai-intelligence-worker`,Q],[`longzai-intelligence-workflow`,Q],[`longzai-intelligence-workflow-data`,Q],[`longzai-intelligence-workflow-markdown`,Q],[`longzai-intelligence-workflow-registry`,Q],[`longzai-intelligence-workspace`,Q],[`longzai-intelligence-writer`,Q],[`longzai-intelligence-xiaohongshu`,Q],[`longzai-intelligence-xiaohongshu-data`,Q],[`longzai-intelligence-xiaohongshu-markdown`,Q],[`longzai-intelligence-youtube`,Q],[`longzai-intelligence-youtube-data`,Q],[`longzai-intelligence-youtube-markdown`,Q],[`longzai-intelligence-zcode`,Q],[`longzai-intelligence-zcode-cleaner`,Q],[`longzai-intelligence-zcode-commit`,Q],[`longzai-intelligence-zcode-knowledge`,Q],[`longzai-intelligence-zcode-remote`,Q],[`longzai-intelligence-zcode-security`,Q],[`longzai-intelligence-zed-delta-knowledge`,Q],[`longzai-intelligence-zhihu`,Q],[`longzai-intelligence-zhihu-data`,Q],[`longzai-intelligence-zhihu-markdown`,Q]]),_f=`LZI_GLOBALS_ROOT`,vf=/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/;var yf=class extends Error{details;constructor(e,t=`install.extraScopes`){super(`${t} 校验失败:\n${e.map(e=>`- ${e}`).join(`
209
+ `)}`),this.name=`InstallScopesError`,this.details=e}};function bf(e){if(typeof e!=`string`)return!1;try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`}catch{return!1}}function xf(e,t,n,r){let i=e instanceof Map?Object.fromEntries(e):{...e},a=[],o={};for(let[n,i]of Object.entries(t??{})){let t=n.replace(/^@+/,``);t.length===0||!vf.test(t)?a.push(`\`${n}\` 不是合法 scope 名(仅允许字母/数字开头,后接字母/数字与 . _ -,@ 前缀可省略)`):bf(i)?o[t]!==void 0&&o[t]!==i?a.push(`\`${t}\` 在 extraScopes 内重复声明且安装源不一致`):(e instanceof Map?e.has(t):Object.hasOwn(e,t))?a.push(`\`${t}\` 与预定义 scope 冲突(预定义不可覆盖,如需调整请在 ${r} 维护)`):o[t]=i:a.push(`\`${n}\` 的安装源 \`${String(i)}\` 不是合法的 http/https URL`)}let s=/* @__PURE__ */ new Set;for(let e of n??[]){let t=e.replace(/^@+/,``);t.length===0||!vf.test(t)?a.push(`\`${e}\` 不是合法 scope 名(仅允许字母/数字开头,后接字母/数字与 . _ -,@ 前缀可省略)`):o[t]===void 0?s.add(t):a.push(`\`${t}\` 同时出现在 extraScopes 与 privateScopes(追加公网安装源与私有轨声明矛盾)`)}if(a.length>0)throw new yf(a);for(let[e,t]of Object.entries(o))i[e]=t;for(let e of s)delete i[e];return i}function Sf(e,t,n,r){let i=xf(e,t,n,`globals 仓 lzi-bun-install.config.ts`),a=r?.replace(/^@+/,``),o=new Set((n??[]).map(e=>e.replace(/^@+/,``)));return a!==void 0&&vf.test(a)&&!Object.hasOwn(i,a)&&!o.has(a)&&(i[a]=`https://registry.npmjs.org/`),i}function Cf(e){let t=[];if(typeof e!=`object`||!e)throw new yf([`default export 必须是对象({ scopes: { ... } })`],`globals 预设 lzi-bun-install.config.ts`);let n=typeof e==`object`&&e&&`scopes`in e?e.scopes:void 0;if(typeof n!=`object`||!n||Array.isArray(n))throw new yf([`scopes 必须是 scope → registry 的对象映射`],`globals 预设 lzi-bun-install.config.ts`);let r={};for(let[e,i]of Object.entries(n))vf.test(e)?typeof i!=`string`||!bf(i)?t.push(`\`${e}\` 的安装源 \`${String(i)}\` 不是合法的 http/https URL`):r[e]=i:t.push(`\`${e}\` 不是合法 scope 名(仅允许字母/数字开头,后接字母/数字与 . _ -,不含 @ 前缀)`);if(t.length>0)throw new yf(t,`globals 预设 lzi-bun-install.config.ts`);if(Object.keys(r).length===0)throw new yf([`scopes 清单为空(真源不允许空清单)`],`globals 预设 lzi-bun-install.config.ts`);return r}var wf=class extends Error{configPath;constructor(e,t,n){super(e,n),this.name=`SharedConfigError`,this.configPath=t}},Tf=class extends wf{searchFrom;constructor(e){super(`未在 ${e} 找到配置文件`,e),this.name=`SharedConfigNotFoundError`,this.searchFrom=e}},Ef=class extends wf{issues;constructor(e,t){super(`配置校验失败,共 ${e.length} 个问题`,t),this.name=`SharedConfigValidationError`,this.issues=e}};function Df(e,t,n,r){let i=e;if(r.schema!==void 0){let e=r.schema.safeParse(i);if(!e.success)throw new Ef(e.error.issues,t);i=e.data}return r.transform!==void 0&&(i=r.transform(i,n)),i}function Of(e){return e instanceof Error&&e.message.length>0?`,底层原因为 ${e.name}: ${e.message}`:``}var kf=class extends wf{cause;constructor(e,t){super(`加载配置文件 ${e} 失败${Of(t)}`,e,{cause:t}),this.name=`SharedConfigLoadError`,this.cause=t}};function Af(e){return typeof e==`object`&&!!e}function jf(e){return typeof e==`object`&&!!e}async function Mf(e,t={}){let r=d(e);if(!n(r))throw new Tf(r);let i;try{let e=await import(r);i=Af(e)?e.default:void 0}catch(e){throw new kf(r,e)}if(i===void 0)throw new kf(r,TypeError(`配置文件缺少默认导出`));if(!jf(i))throw new kf(r,TypeError(`配置文件的默认导出必须是对象`));return{config:Df(i,r,c(r),t),configFilePath:r}}function Nf(e=process.cwd()){let t=d(e);for(;;){let e=l(t,`lzi.config.ts`);if(n(e))return e;let r=c(t);if(r===t)return null;t=r}}async function Pf(e={}){let t=e.cwd??process.cwd(),n=Nf(t);if(n===null)throw new Tf(t);let r=d(n,`..`),{config:i}=await Mf(n);return{config:i,configPath:r,configFilePath:n}}function Ff(e){return typeof e==`object`&&!!e}async function If(e){let t;try{t=await x(e)}catch(t){throw new kf(e,t)}let n=t.filter(e=>e.endsWith(`.config.ts`)).sort();if(n.length===0)throw new kf(e,Error(`配置目录内没有 .config.ts 分片文件`));let r={};for(let t of n){let n=await Mf(l(e,t));r={...r,...n.config}}let i=r;if(!Ff(i))throw new kf(e,Error(`配置目录合并结果不是对象形态`));return i}function Lf(e,t=process.cwd()){let n=Array.isArray(e)?e:[e],r=d(t);for(;;){for(let e of n){let t=l(r,e);if(Rf(t))return t}let e=c(r);if(e===r)return null;r=e}}function Rf(e){try{return o(e).isDirectory()}catch{return!1}}function zf(e,t=process.cwd()){let r=Array.isArray(e)?e:[e],i=d(t);for(;;){for(let e of r){let t=l(i,e);if(n(t))return t}let e=c(i);if(e===i)return null;i=e}}function Bf(e){return typeof e==`object`&&!!e}function Vf(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}async function Hf(e={}){let t=e.cwd??d(process.cwd());if(e.explicitPath!==void 0){let t=await Mf(e.explicitPath,{schema:e.schema,transform:e.transform});return{success:!0,config:t.config,source:`explicit`,configFilePath:t.configFilePath}}if(e.standaloneFile!==void 0){let n=zf(e.standaloneFile,t);if(n!==null){let{config:t}=await Mf(n);return{success:!0,config:Df(t,n,c(n),e),source:`standalone`,configFilePath:n}}}if(e.standaloneDir!==void 0){let n=Lf(e.standaloneDir,t);if(n!==null)return{success:!0,config:Df(await If(n),n,n,e),source:`standalone`,configFilePath:n}}if(e.unifiedField!==void 0){let n,r;try{let{config:i,configFilePath:a}=await Pf({cwd:t}),o=i;n=Vf(o)?o[e.unifiedField]:void 0,r=a}catch(e){if(!(e instanceof Tf))throw e}if(r!==void 0&&n!==void 0&&Bf(n))return{success:!0,config:Df(n,r,c(r),e),source:`unified`,configFilePath:r}}return{success:!1,configFilePath:null}}const Uf=[`packages/*`,`apps/*`];function Wf(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Gf(e){if(Array.isArray(e))return e.every(e=>typeof e==`string`)?e:void 0;if(Wf(e)){let t=e.packages;if(Array.isArray(t)&&t.every(e=>typeof e==`string`))return{packages:t}}}function Kf(e){let t=d(e,`package.json`);if(!n(t))throw new Tf(e);let r;try{let e=JSON.parse(i(t,`utf8`));r=Wf(e)?Gf(e.workspaces):void 0}catch(e){throw new kf(t,e)}let a=Array.isArray(r)?r:r?.packages;return a&&a.length>0?a:Uf}async function qf(e,t={}){let r=Kf(e),a=/* @__PURE__ */ new Set,o=[];for(let s of r){let r=new Bun.Glob(`${s}/package.json`);for await(let s of r.scan({cwd:e,absolute:!0,onlyFiles:!0})){let e=d(s,`..`);if(a.has(e))continue;let r;try{let e=JSON.parse(i(s,`utf8`));r=typeof e==`object`&&e?e:void 0}catch{continue}r!==void 0&&typeof r.name==`string`&&r.name.length!==0&&(t.configFileName!==void 0&&!n(d(e,t.configFileName))||(a.add(e),o.push({name:r.name,dir:e})))}}return o}var Jf=class extends Error{bunfigPath;reason;constructor(e,t){super(`${e} 校验失败:${t};请运行 bun run bun-config:generate 后重试`),this.name=`BunfigDriftError`,this.bunfigPath=e,this.reason=t}},Yf=class extends Error{bunfigPath;constructor(e){super(`${e} 已存在且非 lzi-bun-cli 生成(缺少 @lzi-bun-cli 自动生成,请勿编辑 标记),如需 lzi-bun-cli 接管,请删除该文件或手动合并后重试`),this.name=`BunfigProtectedError`,this.bunfigPath=e}};function Xf(e){return`"${e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}"`}function Zf(e,t){let n=e.map(e=>Xf(e)),r=`[${n.join(`, `)}]`;return`${t} = `.length+r.length<=100?r:`[\n${n.map(e=>` ${e},`).join(`
210
+ `)}\n]`}function Qf(e){let t=[`registry = ${Xf(e.registry)}`],n=ep(`linker`,e.linker);n&&t.push(n);let r=ep(`globalStore`,e.globalStore);r&&t.push(r);let i=Object.entries(e.scopes).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>`${Xf(`@${e}`)} = ${Xf(t)}`),a=[`[install]\n${t.join(`
211
211
  `)}`];return i.length>0&&a.push(`[install.scopes]\n${i.join(`
212
212
  `)}`),a.join(`
213
213
 
214
- `)}function ep(e,t,n){return{registry:`https://mirrors.cloud.tencent.com/npm/`,scopes:Cf(t,e?.extraScopes,e?.privateScopes,n),linker:e?.linker,globalStore:e?.globalStore}}function tp(e,t){if(t!==void 0){if(typeof t==`boolean`||typeof t==`number`)return`${e} = ${t}`;if(typeof t==`string`)return`${e} = ${Zf(t)}`;if(Array.isArray(t))return t.length===0?void 0:`${e} = ${Qf(t,e)}`}}function np(e){let t=[];e.install&&t.push($f(e.install));let n=e.test,r=[],i=tp(`preload`,n.preload);i&&r.push(i);let a=tp(`coverage`,n.coverage);a&&r.push(a);let o=tp(`coverageSkipTestFiles`,n.coverageSkipTestFiles);o&&r.push(o);let s=tp(`coverageReporter`,n.coverageReporter);s&&r.push(s);let c=tp(`coverageDir`,n.coverageDir);c&&r.push(c);let l=tp(`coveragePathIgnorePatterns`,n.coveragePathIgnorePatterns);l&&r.push(l);let u=tp(`coverageIgnoreSourcemaps`,n.coverageIgnoreSourcemaps);u&&r.push(u);let d=tp(`timeout`,n.timeout);return d&&r.push(d),r.length>0&&t.push(`[test]\n${r.join(`
214
+ `)}function $f(e,t,n){return{registry:`https://mirrors.cloud.tencent.com/npm/`,scopes:Sf(t,e?.extraScopes,e?.privateScopes,n),linker:e?.linker,globalStore:e?.globalStore}}function ep(e,t){if(t!==void 0){if(typeof t==`boolean`||typeof t==`number`)return`${e} = ${t}`;if(typeof t==`string`)return`${e} = ${Xf(t)}`;if(Array.isArray(t))return t.length===0?void 0:`${e} = ${Zf(t,e)}`}}function tp(e){let t=[];e.install&&t.push(Qf(e.install));let n=e.test,r=[],i=ep(`preload`,n.preload);i&&r.push(i);let a=ep(`coverage`,n.coverage);a&&r.push(a);let o=ep(`coverageSkipTestFiles`,n.coverageSkipTestFiles);o&&r.push(o);let s=ep(`coverageReporter`,n.coverageReporter);s&&r.push(s);let c=ep(`coverageDir`,n.coverageDir);c&&r.push(c);let l=ep(`coveragePathIgnorePatterns`,n.coveragePathIgnorePatterns);l&&r.push(l);let u=ep(`coverageIgnoreSourcemaps`,n.coverageIgnoreSourcemaps);u&&r.push(u);let d=ep(`timeout`,n.timeout);return d&&r.push(d),r.length>0&&t.push(`[test]\n${r.join(`
215
215
  `)}`),`# @lzi-bun-cli 自动生成,请勿编辑\n${t.join(`
216
216
 
217
- `)}\n`}function rp(e,t={}){let n=t.isRoot===!0,r=e?.test,i=r?r.coverage!==void 0||r.coverageThreshold!==void 0||r.coveragePathIgnorePatterns!==void 0||r.coverageReporter!==void 0||r.coverageSkipTestFiles!==void 0||r.coverageDir!==void 0||r.preload!==void 0||r.timeout!==void 0:!1;if(!n&&!i)return null;let a={test:r??{}};if(n){if(t.installScopesPreset===void 0)throw Error(`root bunfig 生成需要 globals 仓 install scopes 预设(LZI_GLOBALS_ROOT 定位 longzai-intelligence-globals → lzi-bun-install.config.ts),调用方应先解析并加载`);a.install=ep(t.repoInstall,t.installScopesPreset,t.selfScope)}return{content:np(a),shouldWrite:!0}}const ip=(e,t)=>n(l(t,`src/__tests__/bootstrap.ts`))?hf(e):e;function ap(e){let t=0,n=0,r=0,i=0;for(let a of e.split(`
218
- `)){let e=a.trimEnd();e.startsWith(`LF:`)?t+=Number.parseInt(e.slice(3),10)||0:e.startsWith(`LH:`)?n+=Number.parseInt(e.slice(3),10)||0:e.startsWith(`FNF:`)?r+=Number.parseInt(e.slice(4),10)||0:e.startsWith(`FNH:`)&&(i+=Number.parseInt(e.slice(4),10)||0)}return{linesFound:t,linesHit:n,functionsFound:r,functionsHit:i}}function op(e){return typeof e==`number`?{lines:e,functions:e,statements:e}:{...e}}function sp(e,t){if(!(t<=0))return e/t}function cp(e,t){let n=op(t),r=sp(e.linesHit,e.linesFound),i=sp(e.functionsHit,e.functionsFound),a=[];return n.lines!==void 0&&a.push({dimension:`lines`,actual:r,required:n.lines}),n.functions!==void 0&&a.push({dimension:`functions`,actual:i,required:n.functions}),n.statements!==void 0&&a.push({dimension:`statements`,actual:r,required:n.statements}),{passed:a.every(e=>e.actual===void 0||e.actual>=e.required),results:a}}function lp(e){return`${(e*100).toFixed(2)}%`}function up(e){return e.results.map(e=>{let t=e.actual===void 0?`无数据`:lp(e.actual),n=e.actual===void 0||e.actual>=e.required?`通过`:`未达标`;return`${e.dimension} 覆盖率 ${t},阈值 ${lp(e.required)},${n}`})}var dp=class extends Error{details;constructor(e,t){let n=t.flatMap(e=>e.details.map(t=>`${fp(e.kind)}:${t}`));super(`${e} 的测试配置违反分层规则:\n${n.map(e=>` - ${e}`).join(`
219
- `)}`),this.name=`TypeOnlyViolationError`,this.details=n}};function fp(e){return e===`exempt-runtime`?`包内代码与声明预设不符`:e===`zero-tests-undeclared`?`包内没有测试,也没有声明允许零测试的预设`:`声明的预设与目录分层不符`}const pp=e=>typeof e==`object`&&!!e&&!Array.isArray(e),mp=e=>Array.isArray(e)||typeof e==`object`&&!!e&&`packages`in e,hp=e=>{let t=l(e,`package.json`);if(!n(t))return`missing-package-json`;let r;try{r=JSON.parse(i(t,`utf8`))}catch{return`not-root`}return pp(r)&&mp(r.workspaces)?`root`:`not-root`},gp=e=>hp(e)===`root`,_p=(e,t)=>{let n=l(e,`package.json`);try{let e=JSON.parse(i(n,`utf8`));if(pp(e)){let t=e.name;if(typeof t==`string`&&t!==``)return t}}catch{}return t},vp=e=>{let t=e.indexOf(`/`);if(!(!e.startsWith(`@`)||t<=1))return e.slice(1,t)},yp={server:`server`,web:`web`,desktop:`desktop`,cli:`cli`,mcp:`mcp`,"desktop-host":`desktop-host`,docs:`docs`,mobile:`mobile`,miniprogram:`miniprogram`},bp={core:`package`,shared:`package`,sdk:`package`},xp=[`contract`,`main`,`implementation`,`infrastructure`,`api`,`ui`];function Sp(e){if(e===``)return`root`;let t=e.split(`/`),n=t[0],r=t[1],i=t[2];return n===`domains`?t.length<3||i===void 0?`non-fixed`:xp.find(e=>e===i)??`non-fixed`:n===`apps`?t.length===3&&r===`capabilities`?`capability`:t.length===2&&r!==void 0?yp[r]??`non-fixed`:`non-fixed`:n===`packages`&&t.length===2&&r!==void 0?bp[r]??`non-fixed`:`non-fixed`}const Cp=`.lzi/baselines/lzi-bun.typeonly.json`,wp=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Tp=[`exempt-runtime`,`zero-tests-undeclared`,`preset-layer-mismatch`],Ep=e=>typeof e==`string`&&Tp.some(t=>t===e);function Dp(e){return`${e.path}|${e.kind}`}function Op(e){let t=l(e,Cp);if(!n(t))return/* @__PURE__ */ new Set;try{let e=JSON.parse(i(t,`utf8`));if(!wp(e)||!Array.isArray(e.entries))return/* @__PURE__ */ new Set;let n=/* @__PURE__ */ new Set;for(let t of e.entries)wp(t)&&typeof t.path==`string`&&Ep(t.kind)&&n.add(`${t.path}|${t.kind}`);return n}catch{return/* @__PURE__ */ new Set}}function kp(e,t,n){return e.has(`${t}|${n}`)}function Ap(e,t){let n=[...t].sort((e,t)=>Dp(e)<Dp(t)?-1:+(Dp(e)>Dp(t))),i=l(e,Cp);r(c(i),{recursive:!0}),s(i,`${JSON.stringify({version:1,entries:n},null,2)}\n`,`utf8`)}function jp(e,t){return[...Op(e)].filter(e=>!t.has(e))}function Mp(e){let t=e.indexOf(`|`),n=Tp.find(n=>n===e.slice(t+1));return{path:e.slice(0,t),kind:n??`preset-layer-mismatch`}}const Np=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Pp=e=>Np(e)&&typeof e.type==`string`;function Fp(e){return Pp(e)?e:void 0}function Ip(e){if(Array.isArray(e))return e.every(Pp)?e:void 0}function $(e,t){return Fp(e[t])}function Lp(e){if(e!==void 0&&e.type===`Identifier`)return typeof e.name==`string`?e.name:void 0}function Rp(e){return e.type.endsWith(`Literal`)?e.type!==`TemplateLiteral`||e.expressions!==void 0&&Ip(e.expressions)?.length===0:!1}function zp(e){if(Rp(e)||Bp(e))return!0;if(e.type===`TSAsExpression`||e.type===`TSSatisfiesExpression`){let t=$(e,`expression`);return t!==void 0&&zp(t)}if(e.type===`UnaryExpression`){let t=$(e,`argument`);return t!==void 0&&Rp(t)}if(e.type===`BinaryExpression`){let t=$(e,`left`),n=$(e,`right`);return t!==void 0&&n!==void 0&&Rp(t)&&Rp(n)}return!1}function Bp(e){if(e.type===`ObjectExpression`){let t=Ip(e.properties);return t!==void 0&&t.every(e=>{if(e.type===`Property`){if(e.computed===!0)return!1;let t=$(e,`value`);return t!==void 0&&zp(t)}if(e.type===`SpreadElement`){let t=$(e,`argument`);return t!==void 0&&Bp(t)}return!1})}if(e.type===`ArrayExpression`){let t=e.elements;return Array.isArray(t)?t.every(e=>{if(e==null)return!0;let t=Fp(e);return t!==void 0&&zp(t)}):!1}return!1}function Vp(e){let t=Lp($(e,`superClass`));if(t===void 0||t!==`Error`&&!t.endsWith(`Error`))return!1;let n=$(e,`body`);if(n===void 0)return!1;let r=Ip(n.body);return r!==void 0&&r.every(e=>{if(e.type===`MethodDefinition`)return e.kind===`constructor`;if(e.type===`PropertyDefinition`){let t=$(e,`value`);return t===void 0||zp(t)}return!1})}function Hp(e){let t=$(e,`body`);if(t===void 0)return!1;if(t.type!==`BlockStatement`)return!0;let n=Ip(t.body);if(n===void 0||n.length!==1)return!1;let r=n[0];return r!==void 0&&r.type===`ReturnStatement`}function Up(e){return e?`tsx`:`ts`}function Wp(e,t){let n=$(e,`callee`);if(n===void 0)return!1;if(Lp(n)===`Symbol`)return!0;if(n.type===`MemberExpression`){let e=Lp($(n,`object`));return e!==void 0&&t.zodBindings.has(e)}return!1}function Gp(e,t){if(e.type===`TSAsExpression`||e.type===`TSSatisfiesExpression`){let n=$(e,`expression`);if(n!==void 0)return Gp(n,t)}if(e.type===`TSInstantiationExpression`){let n=$(e,`expression`);if(n!==void 0)return Gp(n,t)}return e.type===`CallExpression`?Wp(e,t)?`declarative`:`runtime`:e.type===`ArrowFunctionExpression`?t.isTsx?`runtime`:Hp(e)?`thin`:`runtime`:e.type===`Identifier`||zp(e)?`declarative`:`runtime`}function Kp(e,t){switch(e.type){case`TSTypeAliasDeclaration`:case`TSInterfaceDeclaration`:case`TSModuleDeclaration`:case`TSDeclareFunction`:return`type`;case`TSEnumDeclaration`:return`declarative`;case`ClassDeclaration`:return Vp(e)?`declarative`:`runtime`;case`FunctionDeclaration`:return t.isTsx?`runtime`:Hp(e)?`thin`:`runtime`;case`VariableDeclaration`:{let n=Ip(e.declarations);if(n===void 0)return`runtime`;let r=`type`;for(let e of n){let n=$(e,`init`),i=n===void 0?`declarative`:Gp(n,t);if(i===`runtime`)return`runtime`;i!==`type`&&(r=i)}return r}default:return`runtime`}}function qp(e,t){let n=/* @__PURE__ */ new Set,r=/* @__PURE__ */ new Set,i=/* @__PURE__ */ new Map;for(let t of e){if(t.type===`ImportDeclaration`){Jp(t,n,r);continue}let e=$(t,`declaration`);t.type===`ExportNamedDeclaration`&&e!==void 0?Yp(i,e):Yp(i,t)}return{zodBindings:n,importBindings:r,localDeclarations:i,isTsx:t}}function Jp(e,t,n){let r=$(e,`source`),i=r!==void 0&&typeof r.value==`string`?r.value:void 0,a=Ip(e.specifiers);if(a!==void 0)for(let e of a){let r=Lp($(e,`local`));r!==void 0&&(n.add(r),i===`zod`&&(e.type===`ImportNamespaceSpecifier`&&t.add(r),e.type===`ImportSpecifier`&&Lp($(e,`imported`))===`z`&&t.add(r)))}}function Yp(e,t){if(t.type===`FunctionDeclaration`||t.type===`ClassDeclaration`){let n=Lp($(t,`id`));n!==void 0&&e.set(n,t)}else if(t.type===`VariableDeclaration`){let n=Ip(t.declarations);if(n===void 0)return;for(let t of n){let n=Lp($(t,`id`));n!==void 0&&e.set(n,t)}}}function Xp(e){if(e.type===`VariableDeclaration`){let t=Ip(e.declarations),n=t===void 0?void 0:t[0];return(n===void 0?void 0:Lp($(n,`id`)))??`anonymous`}return Lp($(e,`id`))??`anonymous`}function Zp(e,t){let n=Lp($(e,`local`));if(n===void 0)return;let r=Lp($(e,`exported`))??n,i=t.localDeclarations.get(n);if(i!==void 0){let e=$(i,`init`);return{name:r,form:e===void 0?Kp(i,t):Gp(e,t)}}if(t.importBindings.has(n))return{name:r,form:`reexport`}}function Qp(e,t){return e.type===`FunctionDeclaration`||e.type===`ClassDeclaration`||e.type===`VariableDeclaration`?Kp(e,t):Gp(e,t)}const $p=/* @__PURE__ */ new Set([`__tests__`,`__mocks__`,`__fixtures__`]),em=[`.test.`,`.spec.`,`.d.ts`];function tm(e){return em.some(t=>e.includes(t))}function nm(e){let t=l(e,`src`);if(!n(t))return[];let r=[],i=(e,t)=>{for(let n of a(e,{withFileTypes:!0})){if($p.has(n.name))continue;let a=t===``?n.name:`${t}/${n.name}`;n.isDirectory()?i(l(e,n.name),a):n.isFile()&&(n.name.endsWith(`.ts`)||n.name.endsWith(`.tsx`))&&r.push(`src/${a}`)}};return i(t,``),r}function rm(e,t){let n=Ip(T(e,{sourceType:`module`,lang:Up(t)}).body)??[],r=qp(n,t),i=/* @__PURE__ */ new Map,a=(e,t)=>{let n=i.get(e);n===void 0?i.set(e,[t]):n.push(t)};for(let e of n)if(e.type===`ExportAllDeclaration`)a(`reexport`,`*`);else if(e.type===`ExportNamedDeclaration`){if($(e,`source`)!==void 0){a(`reexport`,`named-from`);continue}let t=$(e,`declaration`);if(t!==void 0){a(Kp(t,r),Xp(t));continue}let n=Ip(e.specifiers);if(n===void 0)continue;for(let e of n){let t=Zp(e,r);t!==void 0&&a(t.form,t.name)}}else if(e.type===`ExportDefaultDeclaration`){let t=$(e,`declaration`);if(t===void 0){a(`runtime`,`default`);continue}a(Qp(t,r),`default`)}return i}function im(e){let t=nm(e).filter(e=>!tm(e)),n=[],r=!1,a=!1;for(let o of t){let t;try{t=i(l(e,o),`utf8`)}catch{continue}let s;try{s=rm(t,o.endsWith(`.tsx`))}catch{n.push({file:o,name:`parse-error`,reason:`文件解析失败,无法确认内容,按包含运行时逻辑处理`});continue}let c=s.get(`runtime`);if(c!==void 0)for(let e of c)n.push({file:o,name:e,reason:`这个导出包含运行时逻辑`});s.has(`declarative`)&&(r=!0),(s.has(`thin`)||s.has(`reexport`))&&(a=!0)}return n.length>0?{verdict:`runtime`,runtimeExports:n}:r?{verdict:`declarative`,runtimeExports:[]}:a?{verdict:`facade`,runtimeExports:[]}:{verdict:`pure-type`,runtimeExports:[]}}function am(e){let t=e;for(;;){if(hp(t)===`root`)return t;let n=c(t);if(n===t)return e;t=n}}const om=/* @__PURE__ */ new Set([`contract`,`main`,`type-only`]),sm=/* @__PURE__ */ new Set([`contract`,`main`,`docs`,`type-only`,`root`]),cm=[`src/**/*.test.ts`,`src/**/*.test.tsx`,`__tests__/**/*.test.ts`],lm=/* @__PURE__ */ new Set([`root`,`contract`,`main`,`docs`,`domain`,`implementation`,`infrastructure`,`api`,`ui`,`capability`,`mcp`,`desktop-host`,`mobile`,`miniprogram`,`package`,`server`,`web`,`desktop`,`cli`]),um={root:`@longzai-intelligence-bun/presets/root`,contract:`@longzai-intelligence-bun/presets/contract`,main:`@longzai-intelligence-bun/presets/main`,docs:`@longzai-intelligence-bun/presets/docs`,domain:`@longzai-intelligence-bun/presets/domain`,implementation:`@longzai-intelligence-bun/presets/implementation`,infrastructure:`@longzai-intelligence-bun/presets/infrastructure`,api:`@longzai-intelligence-bun/presets/api`,ui:`@longzai-intelligence-bun/presets/ui`,capability:`@longzai-intelligence-bun/presets/capability`,mcp:`@longzai-intelligence-bun/presets/mcp`,"desktop-host":`@longzai-intelligence-bun/presets/desktop-host`,mobile:`@longzai-intelligence-bun/presets/mobile`,miniprogram:`@longzai-intelligence-bun/presets/miniprogram`,package:`@longzai-intelligence-bun/presets/package`,server:`@longzai-intelligence-bun/presets/server`,web:`@longzai-intelligence-bun/presets/web`,desktop:`@longzai-intelligence-bun/presets/desktop`,cli:`@longzai-intelligence-bun/presets/cli`};async function dm(e){let t=e.config?.preset??`custom`,n=e.config?.preset!==void 0,r=Sp(u(e.repoRoot,e.packageDir)),i=[];if(lm.has(t)&&t!==r&&i.push({kind:`preset-layer-mismatch`,details:[pm(t,r)]}),om.has(t)){let n=im(e.packageDir);n.verdict===`runtime`&&i.push({kind:`exempt-runtime`,details:[`该包声明为 ${t},这个预设只允许纯类型与声明式内容,但扫描发现 ${n.runtimeExports.length} 处包含运行时逻辑的导出`,...n.runtimeExports.slice(0,5).map(e=>`${e.file} 的 ${e.name},${e.reason}`)]})}return await hm(e.config,e.packageDir)===0&&!sm.has(t)&&i.push({kind:`zero-tests-undeclared`,details:[fm(t,n,r)]}),i}function fm(e,t,n){return t?e===`custom`?`该包的 lzi-bun.config.ts 未走预设子路径,包内没有任何测试文件。custom 不在允许零测试的预设之列,允许零测试的预设为 contract、main、docs、type-only 与 root。请补充测试,或改用上述预设子路径之一,改用后命令会扫描包内容,确认内容符合该预设的要求`:`该包声明为 ${e},包内没有任何测试文件。${e} 预设要求包内必须有测试,允许零测试的预设为 contract、main、docs、type-only 与 root。请补充测试`:n===`non-fixed`?`lzi-bun.config.ts 已加载,但结果里没有预设标记。常见原因是配置仍用旧具名工厂,或依赖停留在旧版本。本包目录没有固定分层,请改用 @longzai-intelligence-bun/presets/type-only 子路径的 defineConfig 声明,并保证包内只有类型与声明式内容`:`lzi-bun.config.ts 已加载,但结果里没有预设标记。常见原因是配置仍用旧具名工厂,或依赖停留在旧版本。本包的目录分层是 ${n},请改用 ${um[n]} 子路径的 defineConfig 声明配置`}function pm(e,t){return t===`non-fixed`?`本包目录没有固定分层,声明的预设是 ${e}。固定分层预设只能用于对应的目录分层,custom 与 type-only 不受目录分层约束。请改用 @longzai-intelligence-bun/presets/type-only 子路径的 defineConfig 声明,并保证包内只有类型与声明式内容`:`本包的目录分层是 ${t},声明的预设却是 ${e}。固定分层预设必须与目录分层一致,custom 与 type-only 不受目录分层约束。请改用 ${um[t]} 子路径的 defineConfig 声明配置`}async function mm(e){let t=await dm(e);if(t.length===0)return;let n=u(e.repoRoot,e.packageDir),r=Op(e.repoRoot),i=t.filter(e=>!kp(r,n,e.kind));if(i.length!==0){if(e.strict)throw new dp(e.subject,i);for(let t of i)for(let n of t.details)Z(`警告: ${e.subject} ${n}`)}}async function hm(e,t){let n=e?.test?.include??cm;if(n.length===cm.length&&n.every((e,t)=>e===cm[t]))return gm(t);let r=/* @__PURE__ */ new Set;for(let e of n){let n=new Bun.Glob(e);for await(let e of n.scan({cwd:t,onlyFiles:!0}))r.add(e)}return r.size}function gm(e){let t=l(e,`src`);if(!n(t))return 0;let r=0,i=e=>{for(let t of a(e,{withFileTypes:!0}))t.isDirectory()?i(l(e,t.name)):(t.isFile()&&t.name.endsWith(`.test.ts`)||t.isFile()&&t.name.endsWith(`.test.tsx`))&&(r+=1)};return i(t),r}const _m=async(e=process.cwd())=>{let t=await Uf({cwd:e,standaloneFile:`lzi-bun.config.ts`,unifiedField:`bun`});return t.success?t.config:(X(`提示: 未找到配置文件 lzi-bun.config.ts,使用默认配置`),{})};var vm=class extends Error{constructor(e){super(e),this.name=`GlobalsUnresolvedError`}};const ym=e=>`已配置的 globals 定位未能命中(longzai-intelligence-globals),已尝试:\n ${e.join(`
220
- `)}\n请修正 ${_f} / --globals 的路径,或移除该配置以回落包内预设(LZI_SCOPES)`,bm=e=>{try{return o(e).isDirectory()}catch{return!1}},xm=(e={})=>{let t=process.env[_f],n=[...t!==void 0&&t!==``?[{source:`env`,path:d(t)}]:[],...e.explicitPath===void 0?[]:[{source:`explicit`,path:d(e.explicitPath)}]],r=[];for(let e of n)if(r.push(`${e.source}: ${e.path}`),bm(e.path))return{ok:!0,resolution:{globalsRoot:e.path,source:e.source}};return{ok:!1,failure:{attempted:r}}},Sm=RegExp(`^${_f}=.*$`,`m`),Cm=`${_f}=/absolute/path/to/longzai-intelligence-globals`,wm=(e,t)=>{let r=l(e,`.env`),a=`${_f}=${t}`;if(n(r)){let e=i(r,`utf8`);if(Sm.test(e)){let t=e.replace(Sm,a);t!==e&&s(r,t,`utf8`)}else{let t=e.endsWith(`
217
+ `)}\n`}function np(e,t={}){let n=t.isRoot===!0,r=e?.test,i=r?r.coverage!==void 0||r.coverageThreshold!==void 0||r.coveragePathIgnorePatterns!==void 0||r.coverageReporter!==void 0||r.coverageSkipTestFiles!==void 0||r.coverageDir!==void 0||r.preload!==void 0||r.timeout!==void 0:!1;if(!n&&!i)return null;let a={test:r??{}};if(n){if(t.installScopesPreset===void 0)throw Error(`root bunfig 生成需要 globals 仓 install scopes 预设(LZI_GLOBALS_ROOT 定位 longzai-intelligence-globals → lzi-bun-install.config.ts),调用方应先解析并加载`);a.install=$f(t.repoInstall,t.installScopesPreset,t.selfScope)}return{content:tp(a),shouldWrite:!0}}const rp=(e,t)=>n(l(t,`src/__tests__/helpers/bootstrap.ts`))?hf(e):e;function ip(e){let t=0,n=0,r=0,i=0;for(let a of e.split(`
218
+ `)){let e=a.trimEnd();e.startsWith(`LF:`)?t+=Number.parseInt(e.slice(3),10)||0:e.startsWith(`LH:`)?n+=Number.parseInt(e.slice(3),10)||0:e.startsWith(`FNF:`)?r+=Number.parseInt(e.slice(4),10)||0:e.startsWith(`FNH:`)&&(i+=Number.parseInt(e.slice(4),10)||0)}return{linesFound:t,linesHit:n,functionsFound:r,functionsHit:i}}function ap(e){return typeof e==`number`?{lines:e,functions:e,statements:e}:{...e}}function op(e,t){if(!(t<=0))return e/t}function sp(e,t){let n=ap(t),r=op(e.linesHit,e.linesFound),i=op(e.functionsHit,e.functionsFound),a=[];return n.lines!==void 0&&a.push({dimension:`lines`,actual:r,required:n.lines}),n.functions!==void 0&&a.push({dimension:`functions`,actual:i,required:n.functions}),n.statements!==void 0&&a.push({dimension:`statements`,actual:r,required:n.statements}),{passed:a.every(e=>e.actual===void 0||e.actual>=e.required),results:a}}function cp(e){return`${(e*100).toFixed(2)}%`}function lp(e){return e.results.map(e=>{let t=e.actual===void 0?`无数据`:cp(e.actual),n=e.actual===void 0||e.actual>=e.required?`通过`:`未达标`;return`${e.dimension} 覆盖率 ${t},阈值 ${cp(e.required)},${n}`})}var up=class extends Error{details;constructor(e,t){let n=t.flatMap(e=>e.details.map(t=>`${dp(e.kind)}:${t}`));super(`${e} 的测试配置违反分层规则:\n${n.map(e=>` - ${e}`).join(`
219
+ `)}`),this.name=`TypeOnlyViolationError`,this.details=n}};function dp(e){return e===`exempt-runtime`?`包内代码与声明预设不符`:e===`zero-tests-undeclared`?`包内没有测试,也没有声明允许零测试的预设`:`声明的预设与目录分层不符`}const fp=e=>typeof e==`object`&&!!e&&!Array.isArray(e),pp=e=>Array.isArray(e)||typeof e==`object`&&!!e&&`packages`in e,mp=e=>{let t=l(e,`package.json`);if(!n(t))return`missing-package-json`;let r;try{r=JSON.parse(i(t,`utf8`))}catch{return`not-root`}return fp(r)&&pp(r.workspaces)?`root`:`not-root`},hp=e=>mp(e)===`root`,gp=(e,t)=>{let n=l(e,`package.json`);try{let e=JSON.parse(i(n,`utf8`));if(fp(e)){let t=e.name;if(typeof t==`string`&&t!==``)return t}}catch{}return t},_p=e=>{let t=e.indexOf(`/`);if(!(!e.startsWith(`@`)||t<=1))return e.slice(1,t)},vp={server:`server`,web:`web`,desktop:`desktop`,cli:`cli`,mcp:`mcp`,"desktop-host":`desktop-host`,docs:`docs`,mobile:`mobile`,miniprogram:`miniprogram`},yp={core:`package`,shared:`package`,sdk:`package`},bp=[`contract`,`main`,`implementation`,`infrastructure`,`api`,`ui`];function xp(e){if(e===``)return`root`;let t=e.split(`/`),n=t[0],r=t[1],i=t[2];return n===`domains`?t.length<3||i===void 0?`non-fixed`:bp.find(e=>e===i)??`non-fixed`:n===`apps`?t.length===3&&r===`capabilities`?`capability`:t.length===2&&r!==void 0?vp[r]??`non-fixed`:`non-fixed`:n===`packages`&&t.length===2&&r!==void 0?yp[r]??`non-fixed`:`non-fixed`}const Sp=`.lzi/baselines/lzi-bun.typeonly.json`,Cp=e=>typeof e==`object`&&!!e&&!Array.isArray(e),wp=[`exempt-runtime`,`zero-tests-undeclared`,`preset-layer-mismatch`],Tp=e=>typeof e==`string`&&wp.some(t=>t===e);function Ep(e){return`${e.path}|${e.kind}`}function Dp(e){let t=l(e,Sp);if(!n(t))return/* @__PURE__ */ new Set;try{let e=JSON.parse(i(t,`utf8`));if(!Cp(e)||!Array.isArray(e.entries))return/* @__PURE__ */ new Set;let n=/* @__PURE__ */ new Set;for(let t of e.entries)Cp(t)&&typeof t.path==`string`&&Tp(t.kind)&&n.add(`${t.path}|${t.kind}`);return n}catch{return/* @__PURE__ */ new Set}}function Op(e,t,n){return e.has(`${t}|${n}`)}function kp(e,t){let n=[...t].sort((e,t)=>Ep(e)<Ep(t)?-1:+(Ep(e)>Ep(t))),i=l(e,Sp);r(c(i),{recursive:!0}),s(i,`${JSON.stringify({version:1,entries:n},null,2)}\n`,`utf8`)}function Ap(e,t){return[...Dp(e)].filter(e=>!t.has(e))}function jp(e){let t=e.indexOf(`|`),n=wp.find(n=>n===e.slice(t+1));return{path:e.slice(0,t),kind:n??`preset-layer-mismatch`}}const Mp=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Np=e=>Mp(e)&&typeof e.type==`string`;function Pp(e){return Np(e)?e:void 0}function Fp(e){if(Array.isArray(e))return e.every(Np)?e:void 0}function $(e,t){return Pp(e[t])}function Ip(e){if(e!==void 0&&e.type===`Identifier`)return typeof e.name==`string`?e.name:void 0}function Lp(e){return e.type.endsWith(`Literal`)?e.type!==`TemplateLiteral`||e.expressions!==void 0&&Fp(e.expressions)?.length===0:!1}function Rp(e){if(Lp(e)||zp(e))return!0;if(e.type===`TSAsExpression`||e.type===`TSSatisfiesExpression`){let t=$(e,`expression`);return t!==void 0&&Rp(t)}if(e.type===`UnaryExpression`){let t=$(e,`argument`);return t!==void 0&&Lp(t)}if(e.type===`BinaryExpression`){let t=$(e,`left`),n=$(e,`right`);return t!==void 0&&n!==void 0&&Lp(t)&&Lp(n)}return!1}function zp(e){if(e.type===`ObjectExpression`){let t=Fp(e.properties);return t!==void 0&&t.every(e=>{if(e.type===`Property`){if(e.computed===!0)return!1;let t=$(e,`value`);return t!==void 0&&Rp(t)}if(e.type===`SpreadElement`){let t=$(e,`argument`);return t!==void 0&&zp(t)}return!1})}if(e.type===`ArrayExpression`){let t=e.elements;return Array.isArray(t)?t.every(e=>{if(e==null)return!0;let t=Pp(e);return t!==void 0&&Rp(t)}):!1}return!1}function Bp(e){let t=Ip($(e,`superClass`));if(t===void 0||t!==`Error`&&!t.endsWith(`Error`))return!1;let n=$(e,`body`);if(n===void 0)return!1;let r=Fp(n.body);return r!==void 0&&r.every(e=>{if(e.type===`MethodDefinition`)return e.kind===`constructor`;if(e.type===`PropertyDefinition`){let t=$(e,`value`);return t===void 0||Rp(t)}return!1})}function Vp(e){let t=$(e,`body`);if(t===void 0)return!1;if(t.type!==`BlockStatement`)return!0;let n=Fp(t.body);if(n===void 0||n.length!==1)return!1;let r=n[0];return r!==void 0&&r.type===`ReturnStatement`}function Hp(e){return e?`tsx`:`ts`}function Up(e,t){let n=$(e,`callee`);if(n===void 0)return!1;if(Ip(n)===`Symbol`)return!0;if(n.type===`MemberExpression`){let e=Ip($(n,`object`));return e!==void 0&&t.zodBindings.has(e)}return!1}function Wp(e,t){if(e.type===`TSAsExpression`||e.type===`TSSatisfiesExpression`){let n=$(e,`expression`);if(n!==void 0)return Wp(n,t)}if(e.type===`TSInstantiationExpression`){let n=$(e,`expression`);if(n!==void 0)return Wp(n,t)}return e.type===`CallExpression`?Up(e,t)?`declarative`:`runtime`:e.type===`ArrowFunctionExpression`?t.isTsx?`runtime`:Vp(e)?`thin`:`runtime`:e.type===`Identifier`||Rp(e)?`declarative`:`runtime`}function Gp(e,t){switch(e.type){case`TSTypeAliasDeclaration`:case`TSInterfaceDeclaration`:case`TSModuleDeclaration`:case`TSDeclareFunction`:return`type`;case`TSEnumDeclaration`:return`declarative`;case`ClassDeclaration`:return Bp(e)?`declarative`:`runtime`;case`FunctionDeclaration`:return t.isTsx?`runtime`:Vp(e)?`thin`:`runtime`;case`VariableDeclaration`:{let n=Fp(e.declarations);if(n===void 0)return`runtime`;let r=`type`;for(let e of n){let n=$(e,`init`),i=n===void 0?`declarative`:Wp(n,t);if(i===`runtime`)return`runtime`;i!==`type`&&(r=i)}return r}default:return`runtime`}}function Kp(e,t){let n=/* @__PURE__ */ new Set,r=/* @__PURE__ */ new Set,i=/* @__PURE__ */ new Map;for(let t of e){if(t.type===`ImportDeclaration`){qp(t,n,r);continue}let e=$(t,`declaration`);t.type===`ExportNamedDeclaration`&&e!==void 0?Jp(i,e):Jp(i,t)}return{zodBindings:n,importBindings:r,localDeclarations:i,isTsx:t}}function qp(e,t,n){let r=$(e,`source`),i=r!==void 0&&typeof r.value==`string`?r.value:void 0,a=Fp(e.specifiers);if(a!==void 0)for(let e of a){let r=Ip($(e,`local`));r!==void 0&&(n.add(r),i===`zod`&&(e.type===`ImportNamespaceSpecifier`&&t.add(r),e.type===`ImportSpecifier`&&Ip($(e,`imported`))===`z`&&t.add(r)))}}function Jp(e,t){if(t.type===`FunctionDeclaration`||t.type===`ClassDeclaration`){let n=Ip($(t,`id`));n!==void 0&&e.set(n,t)}else if(t.type===`VariableDeclaration`){let n=Fp(t.declarations);if(n===void 0)return;for(let t of n){let n=Ip($(t,`id`));n!==void 0&&e.set(n,t)}}}function Yp(e){if(e.type===`VariableDeclaration`){let t=Fp(e.declarations),n=t===void 0?void 0:t[0];return(n===void 0?void 0:Ip($(n,`id`)))??`anonymous`}return Ip($(e,`id`))??`anonymous`}function Xp(e,t){let n=Ip($(e,`local`));if(n===void 0)return;let r=Ip($(e,`exported`))??n,i=t.localDeclarations.get(n);if(i!==void 0){let e=$(i,`init`);return{name:r,form:e===void 0?Gp(i,t):Wp(e,t)}}if(t.importBindings.has(n))return{name:r,form:`reexport`}}function Zp(e,t){return e.type===`FunctionDeclaration`||e.type===`ClassDeclaration`||e.type===`VariableDeclaration`?Gp(e,t):Wp(e,t)}const Qp=/* @__PURE__ */ new Set([`__tests__`,`__mocks__`,`__fixtures__`]),$p=[`.test.`,`.spec.`,`.d.ts`];function em(e){return $p.some(t=>e.includes(t))}function tm(e){let t=l(e,`src`);if(!n(t))return[];let r=[],i=(e,t)=>{for(let n of a(e,{withFileTypes:!0})){if(Qp.has(n.name))continue;let a=t===``?n.name:`${t}/${n.name}`;n.isDirectory()?i(l(e,n.name),a):n.isFile()&&(n.name.endsWith(`.ts`)||n.name.endsWith(`.tsx`))&&r.push(`src/${a}`)}};return i(t,``),r}function nm(e,t){let n=Fp(T(e,{sourceType:`module`,lang:Hp(t)}).body)??[],r=Kp(n,t),i=/* @__PURE__ */ new Map,a=(e,t)=>{let n=i.get(e);n===void 0?i.set(e,[t]):n.push(t)};for(let e of n)if(e.type===`ExportAllDeclaration`)a(`reexport`,`*`);else if(e.type===`ExportNamedDeclaration`){if($(e,`source`)!==void 0){a(`reexport`,`named-from`);continue}let t=$(e,`declaration`);if(t!==void 0){a(Gp(t,r),Yp(t));continue}let n=Fp(e.specifiers);if(n===void 0)continue;for(let e of n){let t=Xp(e,r);t!==void 0&&a(t.form,t.name)}}else if(e.type===`ExportDefaultDeclaration`){let t=$(e,`declaration`);if(t===void 0){a(`runtime`,`default`);continue}a(Zp(t,r),`default`)}return i}function rm(e){let t=tm(e).filter(e=>!em(e)),n=[],r=!1,a=!1;for(let o of t){let t;try{t=i(l(e,o),`utf8`)}catch{continue}let s;try{s=nm(t,o.endsWith(`.tsx`))}catch{n.push({file:o,name:`parse-error`,reason:`文件解析失败,无法确认内容,按包含运行时逻辑处理`});continue}let c=s.get(`runtime`);if(c!==void 0)for(let e of c)n.push({file:o,name:e,reason:`这个导出包含运行时逻辑`});s.has(`declarative`)&&(r=!0),(s.has(`thin`)||s.has(`reexport`))&&(a=!0)}return n.length>0?{verdict:`runtime`,runtimeExports:n}:r?{verdict:`declarative`,runtimeExports:[]}:a?{verdict:`facade`,runtimeExports:[]}:{verdict:`pure-type`,runtimeExports:[]}}function im(e){let t=e;for(;;){if(mp(t)===`root`)return t;let n=c(t);if(n===t)return e;t=n}}const am=/* @__PURE__ */ new Set([`contract`,`main`,`type-only`]),om=/* @__PURE__ */ new Set([`contract`,`main`,`docs`,`type-only`,`root`]),sm=[`src/**/*.test.ts`,`src/**/*.test.tsx`,`__tests__/**/*.test.ts`],cm=/* @__PURE__ */ new Set([`root`,`contract`,`main`,`docs`,`domain`,`implementation`,`infrastructure`,`api`,`ui`,`capability`,`mcp`,`desktop-host`,`mobile`,`miniprogram`,`package`,`server`,`web`,`desktop`,`cli`]),lm={root:`@longzai-intelligence-bun/presets/root`,contract:`@longzai-intelligence-bun/presets/contract`,main:`@longzai-intelligence-bun/presets/main`,docs:`@longzai-intelligence-bun/presets/docs`,domain:`@longzai-intelligence-bun/presets/domain`,implementation:`@longzai-intelligence-bun/presets/implementation`,infrastructure:`@longzai-intelligence-bun/presets/infrastructure`,api:`@longzai-intelligence-bun/presets/api`,ui:`@longzai-intelligence-bun/presets/ui`,capability:`@longzai-intelligence-bun/presets/capability`,mcp:`@longzai-intelligence-bun/presets/mcp`,"desktop-host":`@longzai-intelligence-bun/presets/desktop-host`,mobile:`@longzai-intelligence-bun/presets/mobile`,miniprogram:`@longzai-intelligence-bun/presets/miniprogram`,package:`@longzai-intelligence-bun/presets/package`,server:`@longzai-intelligence-bun/presets/server`,web:`@longzai-intelligence-bun/presets/web`,desktop:`@longzai-intelligence-bun/presets/desktop`,cli:`@longzai-intelligence-bun/presets/cli`};async function um(e){let t=e.config?.preset??`custom`,n=e.config?.preset!==void 0,r=xp(u(e.repoRoot,e.packageDir)),i=[];if(cm.has(t)&&t!==r&&i.push({kind:`preset-layer-mismatch`,details:[fm(t,r)]}),am.has(t)){let n=rm(e.packageDir);n.verdict===`runtime`&&i.push({kind:`exempt-runtime`,details:[`该包声明为 ${t},这个预设只允许纯类型与声明式内容,但扫描发现 ${n.runtimeExports.length} 处包含运行时逻辑的导出`,...n.runtimeExports.slice(0,5).map(e=>`${e.file} 的 ${e.name},${e.reason}`)]})}return await mm(e.config,e.packageDir)===0&&!om.has(t)&&i.push({kind:`zero-tests-undeclared`,details:[dm(t,n,r)]}),i}function dm(e,t,n){return t?e===`custom`?`该包的 lzi-bun.config.ts 未走预设子路径,包内没有任何测试文件。custom 不在允许零测试的预设之列,允许零测试的预设为 contract、main、docs、type-only 与 root。请补充测试,或改用上述预设子路径之一,改用后命令会扫描包内容,确认内容符合该预设的要求`:`该包声明为 ${e},包内没有任何测试文件。${e} 预设要求包内必须有测试,允许零测试的预设为 contract、main、docs、type-only 与 root。请补充测试`:n===`non-fixed`?`lzi-bun.config.ts 已加载,但结果里没有预设标记。常见原因是配置仍用旧具名工厂,或依赖停留在旧版本。本包目录没有固定分层,请改用 @longzai-intelligence-bun/presets/type-only 子路径的 defineConfig 声明,并保证包内只有类型与声明式内容`:`lzi-bun.config.ts 已加载,但结果里没有预设标记。常见原因是配置仍用旧具名工厂,或依赖停留在旧版本。本包的目录分层是 ${n},请改用 ${lm[n]} 子路径的 defineConfig 声明配置`}function fm(e,t){return t===`non-fixed`?`本包目录没有固定分层,声明的预设是 ${e}。固定分层预设只能用于对应的目录分层,custom 与 type-only 不受目录分层约束。请改用 @longzai-intelligence-bun/presets/type-only 子路径的 defineConfig 声明,并保证包内只有类型与声明式内容`:`本包的目录分层是 ${t},声明的预设却是 ${e}。固定分层预设必须与目录分层一致,custom 与 type-only 不受目录分层约束。请改用 ${lm[t]} 子路径的 defineConfig 声明配置`}async function pm(e){let t=await um(e);if(t.length===0)return;let n=u(e.repoRoot,e.packageDir),r=Dp(e.repoRoot),i=t.filter(e=>!Op(r,n,e.kind));if(i.length!==0){if(e.strict)throw new up(e.subject,i);for(let t of i)for(let n of t.details)Z(`警告: ${e.subject} ${n}`)}}async function mm(e,t){let n=e?.test?.include??sm;if(n.length===sm.length&&n.every((e,t)=>e===sm[t]))return hm(t);let r=/* @__PURE__ */ new Set;for(let e of n){let n=new Bun.Glob(e);for await(let e of n.scan({cwd:t,onlyFiles:!0}))r.add(e)}return r.size}function hm(e){let t=l(e,`src`);if(!n(t))return 0;let r=0,i=e=>{for(let t of a(e,{withFileTypes:!0}))t.isDirectory()?i(l(e,t.name)):(t.isFile()&&t.name.endsWith(`.test.ts`)||t.isFile()&&t.name.endsWith(`.test.tsx`))&&(r+=1)};return i(t),r}const gm=async(e=process.cwd())=>{let t=await Hf({cwd:e,standaloneFile:`lzi-bun.config.ts`,unifiedField:`bun`});return t.success?t.config:(X(`提示: 未找到配置文件 lzi-bun.config.ts,使用默认配置`),{})};var _m=class extends Error{constructor(e){super(e),this.name=`GlobalsUnresolvedError`}};const vm=e=>`已配置的 globals 定位未能命中(longzai-intelligence-globals),已尝试:\n ${e.join(`
220
+ `)}\n请修正 ${_f} / --globals 的路径,或移除该配置以回落包内预设(LZI_SCOPES)`,ym=e=>{try{return o(e).isDirectory()}catch{return!1}},bm=(e={})=>{let t=process.env[_f],n=[...t!==void 0&&t!==``?[{source:`env`,path:d(t)}]:[],...e.explicitPath===void 0?[]:[{source:`explicit`,path:d(e.explicitPath)}]],r=[];for(let e of n)if(r.push(`${e.source}: ${e.path}`),ym(e.path))return{ok:!0,resolution:{globalsRoot:e.path,source:e.source}};return{ok:!1,failure:{attempted:r}}},xm=RegExp(`^${_f}=.*$`,`m`),Sm=`${_f}=/absolute/path/to/longzai-intelligence-globals`,Cm=(e,t)=>{let r=l(e,`.env`),a=`${_f}=${t}`;if(n(r)){let e=i(r,`utf8`);if(xm.test(e)){let t=e.replace(xm,a);t!==e&&s(r,t,`utf8`)}else{let t=e.endsWith(`
221
221
  `)||e.length===0?e:`${e}\n`;s(r,`${t}${a}\n`,`utf8`)}}else s(r,`${a}\n`,`utf8`);let o=l(e,`.env.example`);if(n(o)){let e=i(o,`utf8`);if(!e.includes(`LZI_GLOBALS_ROOT=`)){let t=e.endsWith(`
222
- `)||e.length===0?e:`${e}\n`;s(o,`${t}${Cm}\n`,`utf8`)}}else s(o,`${Cm}\n`,`utf8`)},Tm=async e=>wf((await Nf(l(e,vf))).config),Em=async(e={})=>{let t=xm({explicitPath:e.explicitPath});if(t.ok)return{presetScopes:await Tm(t.resolution.globalsRoot),source:`globals`};if(t.failure.attempted.length===0)return{presetScopes:Object.fromEntries(gf),source:`preset`};throw new vm(ym(t.failure.attempted))},Dm=/* @__PURE__ */ new Set([`extraScopes`,`privateScopes`,`linker`,`globalStore`]);function Om(e){if(typeof e!=`object`||!e||Array.isArray(e))throw Error(`lzi-bun-install.config.ts 默认导出须为对象`);for(let t of Object.keys(e))if(!Dm.has(t))throw Error(`lzi-bun-install.config.ts 含不可声明键 ${t},可声明键为 extraScopes、privateScopes、linker、globalStore`);let t=typeof e==`object`&&e&&`extraScopes`in e?e.extraScopes:void 0,n=typeof e==`object`&&e&&`privateScopes`in e?e.privateScopes:void 0,r=typeof e==`object`&&e&&`linker`in e?e.linker:void 0,i=typeof e==`object`&&e&&`globalStore`in e?e.globalStore:void 0;if(t!==void 0){if(typeof t!=`object`||!t||Array.isArray(t))throw Error(`lzi-bun-install.config.ts 的 extraScopes 须为 scope 到安装源 URL 的对象`);for(let[e,n]of Object.entries(t))if(typeof e!=`string`||typeof n!=`string`)throw Error(`lzi-bun-install.config.ts 的 extraScopes 键值均须为字符串`)}if(n!==void 0&&(!Array.isArray(n)||n.some(e=>typeof e!=`string`)))throw Error(`lzi-bun-install.config.ts 的 privateScopes 须为 scope 字符串数组`);if(r!==void 0&&r!==`isolated`&&r!==`hoisted`)throw Error(`lzi-bun-install.config.ts 的 linker 仅可为 isolated 或 hoisted`);if(i!==void 0&&typeof i!=`boolean`)throw Error(`lzi-bun-install.config.ts 的 globalStore 须为布尔值`);let a={};return t!==void 0&&(a.extraScopes=Object.fromEntries(Object.entries(t).map(([e,t])=>[e,String(t)]))),Array.isArray(n)&&(a.privateScopes=n.map(e=>String(e))),(r===`isolated`||r===`hoisted`)&&(a.linker=r),typeof i==`boolean`&&(a.globalStore=i),a}const km=async e=>{let t=l(e,vf);if(n(t))return Om((await Nf(t)).config)},Am=[`src/**/*.test.ts`,`src/**/*.test.tsx`,`__tests__/**/*.test.ts`];function jm(e){let t=[`bun`,`test`];return e.watch===!0&&t.push(`--watch`),e.coverage===!0&&t.push(`--coverage`),e.extra&&e.extra.length>0&&t.push(...e.extra),t}async function Mm(e,t=process.cwd()){let n=/* @__PURE__ */ new Set;for(let r of e){let e=new Bun.Glob(r);for await(let r of e.scan({cwd:t,onlyFiles:!0}))n.add(r)}return n.size}const Nm=(e,t,n)=>{let r=e.split(`
222
+ `)||e.length===0?e:`${e}\n`;s(o,`${t}${Sm}\n`,`utf8`)}}else s(o,`${Sm}\n`,`utf8`)},wm=async e=>Cf((await Mf(l(e,`lzi-bun-install.config.ts`))).config),Tm=async(e={})=>{let t=bm({explicitPath:e.explicitPath});if(t.ok)return{presetScopes:await wm(t.resolution.globalsRoot),source:`globals`};if(t.failure.attempted.length===0)return{presetScopes:Object.fromEntries(gf),source:`preset`};throw new _m(vm(t.failure.attempted))},Em=/* @__PURE__ */ new Set([`extraScopes`,`privateScopes`,`linker`,`globalStore`]);function Dm(e){if(typeof e!=`object`||!e||Array.isArray(e))throw Error(`lzi-bun.config.ts 的 install 声明须为对象`);for(let t of Object.keys(e))if(!Em.has(t))throw Error(`lzi-bun.config.ts 的 install 声明含不可声明键 ${t},可声明键为 extraScopes、privateScopes、linker、globalStore`);let t=typeof e==`object`&&e&&`extraScopes`in e?e.extraScopes:void 0,n=typeof e==`object`&&e&&`privateScopes`in e?e.privateScopes:void 0,r=typeof e==`object`&&e&&`linker`in e?e.linker:void 0,i=typeof e==`object`&&e&&`globalStore`in e?e.globalStore:void 0;if(t!==void 0){if(typeof t!=`object`||!t||Array.isArray(t))throw Error(`lzi-bun.config.ts 的 install.extraScopes 须为 scope 到安装源 URL 的对象`);for(let[e,n]of Object.entries(t))if(typeof e!=`string`||typeof n!=`string`)throw Error(`lzi-bun.config.ts 的 install.extraScopes 键值均须为字符串`)}if(n!==void 0&&(!Array.isArray(n)||n.some(e=>typeof e!=`string`)))throw Error(`lzi-bun.config.ts 的 install.privateScopes 须为 scope 字符串数组`);if(r!==void 0&&r!==`isolated`&&r!==`hoisted`)throw Error(`lzi-bun.config.ts 的 install.linker 仅可为 isolated 或 hoisted`);if(i!==void 0&&typeof i!=`boolean`)throw Error(`lzi-bun.config.ts 的 install.globalStore 须为布尔值`);let a={};return t!==void 0&&(a.extraScopes=Object.fromEntries(Object.entries(t).map(([e,t])=>[e,String(t)]))),Array.isArray(n)&&(a.privateScopes=n.map(e=>String(e))),(r===`isolated`||r===`hoisted`)&&(a.linker=r),typeof i==`boolean`&&(a.globalStore=i),a}const Om=[`src/**/*.test.ts`,`src/**/*.test.tsx`,`__tests__/**/*.test.ts`];function km(e){let t=[`bun`,`test`];return e.watch===!0&&t.push(`--watch`),e.coverage===!0&&t.push(`--coverage`),e.extra&&e.extra.length>0&&t.push(...e.extra),t}async function Am(e,t=process.cwd()){let n=/* @__PURE__ */ new Set;for(let r of e){let e=new Bun.Glob(r);for await(let r of e.scan({cwd:t,onlyFiles:!0}))n.add(r)}return n.size}const jm=(e,t,n)=>{let r=e.split(`
223
223
  `),i=t.split(`
224
- `),a=0;for(;a<r.length&&a<i.length&&r[a]===i[a];)a++;let o=`第 ${a+1} 行不一致(磁盘 \`${r[a]??`<缺行>`}\` ≠ 预期 \`${i[a]??`<缺行>`}\`)`,s=n===void 0?void 0:`"@${n}" = `;return s!==void 0&&t.includes(s)&&!e.includes(s)?`${o},且本仓 scope @${n} 行在磁盘文件中缺位——bun publish 的 scope 映射优先级会使公网轨发布回退默认镜像源并以 missing authentication 失败(issue 0008)`:o},Pm=async(e,t={})=>{let r=t.dir??process.cwd(),a=l(r,`bunfig.toml`),o=gp(r),c,u;o&&(c=(await Em({explicitPath:t.globalsPath})).presetScopes,u=await km(r));let d=o?vp(_p(r,``)):void 0,f=rp(ip(e,r),{isRoot:o,installScopesPreset:c,selfScope:d,repoInstall:u});if(!f?.shouldWrite){if(t.dryRun&&X(`(无 coverage 配置,不会生成 bunfig.toml)`),t.check===!0&&n(a))throw new Yf(a,`该包无 coverage 配置,生成器判定不应存在 bunfig.toml(多余文件),请删除该文件`);return{status:`skipped`,bunfigPath:a}}if(t.dryRun)return X(`[dry-run] 将写入 ${a}:`),X(f.content),{status:`generated`,bunfigPath:a};if(t.check===!0){if(!n(a))throw new Yf(a,d===void 0?`bunfig.toml 不存在(生成器预期应存在)`:`bunfig.toml 不存在,本仓 scope @${d} 未注入 [install.scopes]——bun publish 的 scope 映射优先级会使公网轨发布回退默认镜像源并以 missing authentication 失败(issue 0008)`);let e=i(a,`utf8`);if(!e.includes(`@lzi-bun-cli 自动生成,请勿编辑`))throw new Yf(a,`bunfig.toml 为手写文件(无生成标记),不受 lzi-bun-cli 管理;如需接管请确认内容后删除该文件重新生成`);if(e!==f.content)throw new Yf(a,Nm(e,f.content,d));return X(`校验通过 ${a}(与生成器预期一致)`),{status:`checked`,bunfigPath:a}}if(n(a)&&!i(a,`utf8`).includes(`@lzi-bun-cli 自动生成,请勿编辑`))throw new Xf(a);return s(a,f.content,`utf8`),X(`已生成 ${a}(lzi-bun-cli 接管覆盖率配置)`),{status:`generated`,bunfigPath:a}},Fm=e=>{let t=e?.test;if(t===void 0)return;let r=t.coverageThreshold;if(r===void 0)return;let a=l(process.cwd(),t.coverageDir??`coverage`,`lcov.info`);if(!n(a)){X(`未找到覆盖率报告 ${a},跳过全局阈值判定`);return}let o=cp(ap(i(a,`utf8`)),r);if(o.passed)for(let e of up(o))X(e);else{Z(`错误: 覆盖率全局汇总低于阈值`);for(let e of up(o))Z(e);process.exit(1)}},Im=async e=>{let t=await _m();await mm({config:t,packageDir:process.cwd(),repoRoot:am(process.cwd()),strict:!1,subject:_p(process.cwd(),process.cwd())});let n=t.test?.passWithNoTests??!0;await Mm(t.test?.include??Am)===0&&(n&&(X(`无测试文件,跳过(type-only / facade 包,passWithNoTests)`),process.exit(0)),Z(`错误: 未找到测试文件,且 test.passWithNoTests 为 false`),Z(`(如该包确为 type-only / facade 包,请在 lzi-dev.config.ts 设置 test.passWithNoTests: true)`),process.exit(1));try{await Pm(t)}catch(e){throw(e instanceof Xf||e instanceof bf||e instanceof vm)&&(Z(`错误: ${e.message}`),process.exit(1)),e}let r=jm(e),i=await Bun.spawn(r,{cwd:process.cwd(),stdout:`inherit`,stderr:`inherit`}).exited;i!==0&&process.exit(i),Fm(t)},Lm=async(e,t,n)=>{let r=await _m();try{await mm({config:r,packageDir:process.cwd(),repoRoot:am(process.cwd()),strict:!0,subject:_p(process.cwd(),process.cwd())}),await Pm(r,{dryRun:e,globalsPath:t,check:n})}catch(e){throw(e instanceof Xf||e instanceof Yf||e instanceof bf||e instanceof vm||e instanceof dp)&&(Z(`错误: ${e.message}`),process.exit(1)),e}},Rm=e=>{let t=hp(e);t===`missing-package-json`&&(Z(`错误: 当前目录 ${e} 无 package.json,--recursive 须在 monorepo root 执行`),process.exit(1)),t!==`root`&&(Z(`错误: ${e} 的 package.json 未声明 workspaces 字段,--recursive 须在 monorepo root 执行`),process.exit(1))},zm=async(e,t,n)=>{let r=process.cwd();Rm(r);let i=await Jf(r,{configFileName:`lzi-bun.config.ts`}),a=[{name:_p(r,r.split(`/`).pop()??`root`),dir:r}];a.push(...i.map(e=>({name:e.name,dir:e.dir})));let o=n===!0?`校验`:e?`预览`:`生成`;X(`发现 ${a.length} 个目标(root 1 + 子包 ${i.length}),开始${o}...`);let s=[];for(let i of a){X(`▶ ${i.name}`);try{let a=await _m(i.dir);await mm({config:a,packageDir:i.dir,repoRoot:r,strict:!0,subject:i.name});let{status:o}=await Pm(a,{dryRun:e,check:n,dir:i.dir,globalsPath:t});s.push({name:i.name,dir:i.dir,status:o})}catch(e){s.push({name:i.name,dir:i.dir,status:`failed`,reason:e instanceof Error?e.message:String(e)})}}let c=s.filter(e=>e.status===`generated`),l=s.filter(e=>e.status===`checked`),u=s.filter(e=>e.status===`skipped`),d=s.filter(e=>e.status===`failed`);if(X(``),X(`汇总:${c.length} 生成 / ${l.length} 一致 / ${u.length} 跳过 / ${d.length} 失败`),d.length>0){Z(``),Z(`失败子包:`);for(let e of d)Z(` - ${e.name}:${e.reason}`);process.exitCode=1}},Bm=async e=>{let t=e.dryRun===!0,n=e.check===!0;if(t&&n&&(Z(`错误: --dry-run 与 --check 互斥(预览与校验是两种只读形态,请二选一)`),process.exit(1)),e.globalsPath!==void 0){let t=xm({explicitPath:e.globalsPath});t.ok||(Z(`错误: ${ym(t.failure.attempted)}`),process.exit(1));let{globalsRoot:n,source:r}=t.resolution;wm(process.cwd(),n),X(`已定位 globals 仓(${r})并固化到 .env:${n}`)}e.recursive===!0?await zm(t,e.globalsPath,n):await Lm(t,e.globalsPath,n)},Vm=/* @__PURE__ */ new Set([`contract`,`main`,`type-only`]);async function Hm(e,t){let n=u(t,e),r=_p(e,n||`root`),i=Sp(n),a=null,o=`custom`,s;try{a=await _m(e),o=a?.preset??`custom`,s=await dm({config:a,packageDir:e,repoRoot:t,strict:!1,subject:r})}catch{o=`load-error`,s=[{kind:`preset-layer-mismatch`,details:[`lzi-bun.config.ts 加载失败,无法确认声明的预设。请检查文件内的导入与语法,常见原因是配置仍用旧具名工厂,或预设子路径版本尚未发布`]}]}let c=Vm.has(o)?im(e).verdict:`not-scanned`;return{name:r,path:n,layer:i,preset:o,verdict:c,tests:await hm(a,e),violations:s}}async function Um(e){let t=process.cwd();e.recursive===!0&&hp(t)!==`root`&&(Z(`错误:--recursive 须在含 workspaces 字段的 workspace 根执行`),process.exit(1));let n=[t];if(e.recursive===!0){let e=await Jf(t,{configFileName:`lzi-bun.config.ts`});n.push(...e.map(e=>e.dir))}let r=Op(t),i=[];for(let e of n)i.push(await Hm(e,t));if(e.json===!0)X(JSON.stringify({rows:i},null,2));else{X(`审计 ${i.length} 个目标`);for(let e of i){let t=e.violations.filter(t=>!kp(r,e.path,t.kind)),n=t.length>0?` 违规 ${t.length} 项`:e.violations.length>0?` 基线内`:` 合规`;X(` ${e.path||`根目录`} 分层 ${e.layer} 预设 ${e.preset} 判定 ${e.verdict} 测试 ${e.tests}${n}`);for(let e of t)for(let t of e.details.slice(0,3))Z(` - ${t}`)}}if(e.initBaseline===!0){let e=/* @__PURE__ */ new Set;for(let t of i)for(let n of t.violations)e.add(`${t.path}|${n.kind}`);Ap(t,[...e].map(Mp)),X(`已落盘基线 ${e.size} 条至 .lzi/baselines/lzi-bun.typeonly.json`)}else if(e.pruneBaseline===!0){let e=/* @__PURE__ */ new Set;for(let t of i)for(let n of t.violations)e.add(`${t.path}|${n.kind}`);let n=jp(t,e);n.length>0?(Ap(t,[...r].filter(e=>!n.includes(e)).map(Mp)),X(`已从基线移除 ${n.length} 条已修复条目`)):X(`基线无已修复条目可移除`)}else if(e.check===!0){let e=i.reduce((e,t)=>e+t.violations.filter(e=>!kp(r,t.path,e.kind)).length,0);e>0&&(Z(`错误:${e} 项违规不在基线内,基线只减不增,请先治理违规再重试`),process.exitCode=1)}}function Wm(e){Gm(e),Ym(e),Jm(e),Km(e),qm(e)}function Gm(e){Su(e,{name:`test`,description:`运行 bun 测试(替代三件套,零测试包默认放行)`,options:[{flags:`--watch`,description:`监听模式(对应 test:watch)`},{flags:`--coverage`,description:`覆盖率(对应 test:coverage)`}],schema:Nl({watch:Tl().optional(),coverage:Tl().optional()}),action:async(e,t)=>{await Im({watch:e.watch===!0,coverage:e.coverage===!0,extra:t})}})}function Km(e){Su(e,{name:`lockfile check`,description:`校验单一 bun.lock 不变量与 workspaces 覆盖缺口`,schema:Nl({}),action:async()=>{await af()}})}function qm(e){Su(e,{name:`node-links check`,description:`检测 node_modules 悬挂符号链接,命中即非零退出`,schema:Nl({}),action:async()=>{await pf()}}),Su(e,{name:`node-links fix`,description:`回收 node_modules 悬挂死链,删除前复验,有效链接零触碰`,schema:Nl({}),action:async()=>{await mf()}})}function Jm(e){Su(e,{name:`typeonly audit`,description:`检查各包的目录分层、预设声明与包内容是否符合规则,并管理违规基线`,options:[{flags:`-r, --recursive`,description:`递归审计 workspace 内全部含 lzi-bun.config.ts 的包`},{flags:`--check`,description:`校验模式,实际违规须为基线子集,否则非零退出`},{flags:`--json`,description:`以 JSON 形态输出审计行`},{flags:`--init-baseline`,description:`落盘当前全量违规为基线祖父条款`},{flags:`--prune-baseline`,description:`移除基线中已修复的条目,只减不增`}],schema:Nl({recursive:Tl().optional(),check:Tl().optional(),json:Tl().optional(),initBaseline:Tl().optional(),pruneBaseline:Tl().optional()}),action:async e=>{await Um({recursive:e.recursive===!0,check:e.check===!0,json:e.json===!0,initBaseline:e.initBaseline===!0,pruneBaseline:e.pruneBaseline===!0})}})}function Ym(e){Su(e,{name:`config generate`,description:`生成 bunfig.toml(不执行测试,支持 --dry-run 预览、--check 校验、-r 批量、--globals 定位)`,options:[{flags:`--dry-run`,description:`仅预览将写入的内容,不写盘`},{flags:`--check`,description:`仅校验磁盘 bunfig.toml 与生成器预期是否一致(漂移即报错退出,不写盘)`},{flags:`-r, --recursive`,description:`递归处理 monorepo 下含 lzi-bun.config.ts 的子包`},{flags:`--globals <path>`,description:`一次性 bootstrap 定位 globals 仓(命中后固化 .env,此后零参数)`}],schema:Nl({dryRun:Tl().optional(),check:Tl().optional(),recursive:Tl().optional(),globals:el().optional()}),action:async e=>{await Bm({dryRun:e.dryRun===!0,check:e.check===!0,recursive:e.recursive===!0,globalsPath:e.globals})}})}const Xm=vu({name:`lzi-bun-cli`,description:`Longzai Intelligence bun 工具集`,interaction:Vd,color:Bd});Wm(Xm);async function Zm(){await Xm.parseAsync(process.argv)}Zm().catch(e=>{process.stderr.write(`错误: ${e instanceof Error?e.message:String(e)}\n`),process.exit(1)});export{};
224
+ `),a=0;for(;a<r.length&&a<i.length&&r[a]===i[a];)a++;let o=`第 ${a+1} 行不一致(磁盘 \`${r[a]??`<缺行>`}\` ≠ 预期 \`${i[a]??`<缺行>`}\`)`,s=n===void 0?void 0:`"@${n}" = `;return s!==void 0&&t.includes(s)&&!e.includes(s)?`${o},且本仓 scope @${n} 行在磁盘文件中缺位——bun publish 的 scope 映射优先级会使公网轨发布回退默认镜像源并以 missing authentication 失败(issue 0008)`:o},Mm=async(e,t={})=>{let r=t.dir??process.cwd(),a=l(r,`bunfig.toml`),o=hp(r),c,u;o&&(c=(await Tm({explicitPath:t.globalsPath})).presetScopes,u=e?.install===void 0?void 0:Dm(e.install));let d=o?_p(gp(r,``)):void 0,f=np(rp(e,r),{isRoot:o,installScopesPreset:c,selfScope:d,repoInstall:u});if(!f?.shouldWrite){if(t.dryRun&&X(`(无 coverage 配置,不会生成 bunfig.toml)`),t.check===!0&&n(a))throw new Jf(a,`该包无 coverage 配置,生成器判定不应存在 bunfig.toml(多余文件),请删除该文件`);return{status:`skipped`,bunfigPath:a}}if(t.dryRun)return X(`[dry-run] 将写入 ${a}:`),X(f.content),{status:`generated`,bunfigPath:a};if(t.check===!0){if(!n(a))throw new Jf(a,d===void 0?`bunfig.toml 不存在(生成器预期应存在)`:`bunfig.toml 不存在,本仓 scope @${d} 未注入 [install.scopes]——bun publish 的 scope 映射优先级会使公网轨发布回退默认镜像源并以 missing authentication 失败(issue 0008)`);let e=i(a,`utf8`);if(!e.includes(`@lzi-bun-cli 自动生成,请勿编辑`))throw new Jf(a,`bunfig.toml 为手写文件(无生成标记),不受 lzi-bun-cli 管理;如需接管请确认内容后删除该文件重新生成`);if(e!==f.content)throw new Jf(a,jm(e,f.content,d));return X(`校验通过 ${a}(与生成器预期一致)`),{status:`checked`,bunfigPath:a}}if(n(a)&&!i(a,`utf8`).includes(`@lzi-bun-cli 自动生成,请勿编辑`))throw new Yf(a);return s(a,f.content,`utf8`),X(`已生成 ${a}(lzi-bun-cli 接管覆盖率配置)`),{status:`generated`,bunfigPath:a}},Nm=e=>{let t=e?.test;if(t===void 0)return;let r=t.coverageThreshold;if(r===void 0)return;let a=l(process.cwd(),t.coverageDir??`coverage`,`lcov.info`);if(!n(a)){X(`未找到覆盖率报告 ${a},跳过全局阈值判定`);return}let o=sp(ip(i(a,`utf8`)),r);if(o.passed)for(let e of lp(o))X(e);else{Z(`错误: 覆盖率全局汇总低于阈值`);for(let e of lp(o))Z(e);process.exit(1)}},Pm=async e=>{let t=await gm();await pm({config:t,packageDir:process.cwd(),repoRoot:im(process.cwd()),strict:!1,subject:gp(process.cwd(),process.cwd())});let n=t.test?.passWithNoTests??!0;await Am(t.test?.include??Om)===0&&(n&&(X(`无测试文件,跳过(type-only / facade 包,passWithNoTests)`),process.exit(0)),Z(`错误: 未找到测试文件,且 test.passWithNoTests 为 false`),Z(`(如该包确为 type-only / facade 包,请在 lzi-dev.config.ts 设置 test.passWithNoTests: true)`),process.exit(1));try{await Mm(t)}catch(e){throw(e instanceof Yf||e instanceof yf||e instanceof _m)&&(Z(`错误: ${e.message}`),process.exit(1)),e}let r=km(e),i=await Bun.spawn(r,{cwd:process.cwd(),stdout:`inherit`,stderr:`inherit`}).exited;i!==0&&process.exit(i),Nm(t)},Fm=async(e,t,n)=>{let r=await gm();try{await pm({config:r,packageDir:process.cwd(),repoRoot:im(process.cwd()),strict:!0,subject:gp(process.cwd(),process.cwd())}),await Mm(r,{dryRun:e,globalsPath:t,check:n})}catch(e){throw(e instanceof Yf||e instanceof Jf||e instanceof yf||e instanceof _m||e instanceof up)&&(Z(`错误: ${e.message}`),process.exit(1)),e}},Im=e=>{let t=mp(e);t===`missing-package-json`&&(Z(`错误: 当前目录 ${e} 无 package.json,--recursive 须在 monorepo root 执行`),process.exit(1)),t!==`root`&&(Z(`错误: ${e} 的 package.json 未声明 workspaces 字段,--recursive 须在 monorepo root 执行`),process.exit(1))},Lm=async(e,t,n)=>{let r=process.cwd();Im(r);let i=await qf(r,{configFileName:`lzi-bun.config.ts`}),a=[{name:gp(r,r.split(`/`).pop()??`root`),dir:r}];a.push(...i.map(e=>({name:e.name,dir:e.dir})));let o=n===!0?`校验`:e?`预览`:`生成`;X(`发现 ${a.length} 个目标(root 1 + 子包 ${i.length}),开始${o}...`);let s=[];for(let i of a){X(`▶ ${i.name}`);try{let a=await gm(i.dir);await pm({config:a,packageDir:i.dir,repoRoot:r,strict:!0,subject:i.name});let{status:o}=await Mm(a,{dryRun:e,check:n,dir:i.dir,globalsPath:t});s.push({name:i.name,dir:i.dir,status:o})}catch(e){s.push({name:i.name,dir:i.dir,status:`failed`,reason:e instanceof Error?e.message:String(e)})}}let c=s.filter(e=>e.status===`generated`),l=s.filter(e=>e.status===`checked`),u=s.filter(e=>e.status===`skipped`),d=s.filter(e=>e.status===`failed`);if(X(``),X(`汇总:${c.length} 生成 / ${l.length} 一致 / ${u.length} 跳过 / ${d.length} 失败`),d.length>0){Z(``),Z(`失败子包:`);for(let e of d)Z(` - ${e.name}:${e.reason}`);process.exitCode=1}},Rm=async e=>{let t=e.dryRun===!0,n=e.check===!0;if(t&&n&&(Z(`错误: --dry-run 与 --check 互斥(预览与校验是两种只读形态,请二选一)`),process.exit(1)),e.globalsPath!==void 0){let t=bm({explicitPath:e.globalsPath});t.ok||(Z(`错误: ${vm(t.failure.attempted)}`),process.exit(1));let{globalsRoot:n,source:r}=t.resolution;Cm(process.cwd(),n),X(`已定位 globals 仓(${r})并固化到 .env:${n}`)}e.recursive===!0?await Lm(t,e.globalsPath,n):await Fm(t,e.globalsPath,n)},zm=/* @__PURE__ */ new Set([`contract`,`main`,`type-only`]);async function Bm(e,t){let n=u(t,e),r=gp(e,n||`root`),i=xp(n),a=null,o=`custom`,s;try{a=await gm(e),o=a?.preset??`custom`,s=await um({config:a,packageDir:e,repoRoot:t,strict:!1,subject:r})}catch{o=`load-error`,s=[{kind:`preset-layer-mismatch`,details:[`lzi-bun.config.ts 加载失败,无法确认声明的预设。请检查文件内的导入与语法,常见原因是配置仍用旧具名工厂,或预设子路径版本尚未发布`]}]}let c=zm.has(o)?rm(e).verdict:`not-scanned`;return{name:r,path:n,layer:i,preset:o,verdict:c,tests:await mm(a,e),violations:s}}async function Vm(e){let t=process.cwd();e.recursive===!0&&mp(t)!==`root`&&(Z(`错误:--recursive 须在含 workspaces 字段的 workspace 根执行`),process.exit(1));let n=[t];if(e.recursive===!0){let e=await qf(t,{configFileName:`lzi-bun.config.ts`});n.push(...e.map(e=>e.dir))}let r=Dp(t),i=[];for(let e of n)i.push(await Bm(e,t));if(e.json===!0)X(JSON.stringify({rows:i},null,2));else{X(`审计 ${i.length} 个目标`);for(let e of i){let t=e.violations.filter(t=>!Op(r,e.path,t.kind)),n=t.length>0?` 违规 ${t.length} 项`:e.violations.length>0?` 基线内`:` 合规`;X(` ${e.path||`根目录`} 分层 ${e.layer} 预设 ${e.preset} 判定 ${e.verdict} 测试 ${e.tests}${n}`);for(let e of t)for(let t of e.details.slice(0,3))Z(` - ${t}`)}}if(e.initBaseline===!0){let e=/* @__PURE__ */ new Set;for(let t of i)for(let n of t.violations)e.add(`${t.path}|${n.kind}`);kp(t,[...e].map(jp)),X(`已落盘基线 ${e.size} 条至 .lzi/baselines/lzi-bun.typeonly.json`)}else if(e.pruneBaseline===!0){let e=/* @__PURE__ */ new Set;for(let t of i)for(let n of t.violations)e.add(`${t.path}|${n.kind}`);let n=Ap(t,e);n.length>0?(kp(t,[...r].filter(e=>!n.includes(e)).map(jp)),X(`已从基线移除 ${n.length} 条已修复条目`)):X(`基线无已修复条目可移除`)}else if(e.check===!0){let e=i.reduce((e,t)=>e+t.violations.filter(e=>!Op(r,t.path,e.kind)).length,0);e>0&&(Z(`错误:${e} 项违规不在基线内,基线只减不增,请先治理违规再重试`),process.exitCode=1)}}function Hm(e){Um(e),qm(e),Km(e),Wm(e),Gm(e)}function Um(e){Su(e,{name:`test`,description:`运行 bun 测试(替代三件套,零测试包默认放行)`,options:[{flags:`--watch`,description:`监听模式(对应 test:watch)`},{flags:`--coverage`,description:`覆盖率(对应 test:coverage)`}],schema:Nl({watch:Tl().optional(),coverage:Tl().optional()}),action:async(e,t)=>{await Pm({watch:e.watch===!0,coverage:e.coverage===!0,extra:t})}})}function Wm(e){Su(e,{name:`lockfile check`,description:`校验单一 bun.lock 不变量与 workspaces 覆盖缺口`,schema:Nl({}),action:async()=>{await af()}})}function Gm(e){Su(e,{name:`node-links check`,description:`检测 node_modules 悬挂符号链接,命中即非零退出`,schema:Nl({}),action:async()=>{await pf()}}),Su(e,{name:`node-links fix`,description:`回收 node_modules 悬挂死链,删除前复验,有效链接零触碰`,schema:Nl({}),action:async()=>{await mf()}})}function Km(e){Su(e,{name:`typeonly audit`,description:`检查各包的目录分层、预设声明与包内容是否符合规则,并管理违规基线`,options:[{flags:`-r, --recursive`,description:`递归审计 workspace 内全部含 lzi-bun.config.ts 的包`},{flags:`--check`,description:`校验模式,实际违规须为基线子集,否则非零退出`},{flags:`--json`,description:`以 JSON 形态输出审计行`},{flags:`--init-baseline`,description:`落盘当前全量违规为基线祖父条款`},{flags:`--prune-baseline`,description:`移除基线中已修复的条目,只减不增`}],schema:Nl({recursive:Tl().optional(),check:Tl().optional(),json:Tl().optional(),initBaseline:Tl().optional(),pruneBaseline:Tl().optional()}),action:async e=>{await Vm({recursive:e.recursive===!0,check:e.check===!0,json:e.json===!0,initBaseline:e.initBaseline===!0,pruneBaseline:e.pruneBaseline===!0})}})}function qm(e){Su(e,{name:`config generate`,description:`生成 bunfig.toml(不执行测试,支持 --dry-run 预览、--check 校验、-r 批量、--globals 定位)`,options:[{flags:`--dry-run`,description:`仅预览将写入的内容,不写盘`},{flags:`--check`,description:`仅校验磁盘 bunfig.toml 与生成器预期是否一致(漂移即报错退出,不写盘)`},{flags:`-r, --recursive`,description:`递归处理 monorepo 下含 lzi-bun.config.ts 的子包`},{flags:`--globals <path>`,description:`一次性 bootstrap 定位 globals 仓(命中后固化 .env,此后零参数)`}],schema:Nl({dryRun:Tl().optional(),check:Tl().optional(),recursive:Tl().optional(),globals:el().optional()}),action:async e=>{await Rm({dryRun:e.dryRun===!0,check:e.check===!0,recursive:e.recursive===!0,globalsPath:e.globals})}})}const Jm=vu({name:`lzi-bun-cli`,description:`Longzai Intelligence bun 工具集`,interaction:Vd,color:Bd});Hm(Jm);async function Ym(){await Jm.parseAsync(process.argv)}Ym().catch(e=>{process.stderr.write(`错误: ${e instanceof Error?e.message:String(e)}\n`),process.exit(1)});export{};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longzai-intelligence-bun/cli",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Longzai Intelligence Bun 工具集 CLI",
5
5
  "keywords": [
6
6
  "bun",
@@ -40,7 +40,7 @@
40
40
  "test:coverage": "bun test --coverage"
41
41
  },
42
42
  "dependencies": {
43
- "@longzai-intelligence-bun/config": "0.1.1",
43
+ "@longzai-intelligence-bun/config": "0.1.2",
44
44
  "@longzai-intelligence-cli/core": "^0.0.10",
45
45
  "@longzai-intelligence-cli/standard": "^0.0.10",
46
46
  "@longzai-intelligence-logger/node": "^0.1.8",