@longzai-intelligence-bun/cli 0.1.14 → 0.1.15

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 +2 -2
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -152,7 +152,7 @@ Expecting one of '${n.join(`', '`)}'`);return this._lifeCycleHooks[e]?this._life
152
152
  - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
153
153
  - ${t?`searched for local subcommand relative to directory '${t}'`:`no directory for search for local subcommand, use .executableDir() to supply a custom directory`}`;throw Error(r)}_executeSubCommand(e,t){t=t.slice();let n=[`.js`,`.ts`,`.tsx`,`.mjs`,`.cjs`];function r(e,t){let r=f.resolve(e,t);if(a.existsSync(r))return r;if(n.includes(f.extname(t)))return;let i=n.find(e=>a.existsSync(`${r}${e}`));if(i)return`${r}${i}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let i=e._executableFile||`${this._name}-${e._name}`,o=this._executableDir||``;if(this._scriptPath){let e;try{e=a.realpathSync(this._scriptPath)}catch{e=this._scriptPath}o=f.resolve(f.dirname(e),o)}if(o){let t=r(o,i);if(!t&&!e._executableFile&&this._scriptPath){let n=f.basename(this._scriptPath,f.extname(this._scriptPath));n!==this._name&&(t=r(o,`${n}-${e._name}`))}i=t||i}let s=n.includes(f.extname(i)),c;b.platform===`win32`?(this._checkForMissingExecutable(i,o,e._name),t.unshift(i),t=ed(b.execArgv).concat(t),c=y.spawn(b.execPath,t,{stdio:`inherit`})):s?(t.unshift(i),t=ed(b.execArgv).concat(t),c=y.spawn(b.argv[0],t,{stdio:`inherit`})):c=y.spawn(i,t,{stdio:`inherit`}),c.killed||[`SIGUSR1`,`SIGUSR2`,`SIGTERM`,`SIGINT`,`SIGHUP`].forEach(e=>{b.on(e,()=>{c.killed===!1&&c.exitCode===null&&c.kill(e)})});let l=this._exitCallback;c.on(`close`,e=>{e??=1,l?l(new Hu(e,`commander.executeSubCommandAsync`,`(close)`)):b.exit(e)}),c.on(`error`,t=>{if(t.code===`ENOENT`)this._checkForMissingExecutable(i,o,e._name);else if(t.code===`EACCES`)throw Error(`'${i}' not executable`);if(!l)b.exit(1);else{let e=new Hu(1,`commander.executeSubCommandAsync`,`(error)`);e.nestedError=t,l(e)}}),this.runningCommand=c}_dispatchSubcommand(e,t,n){let r=this._findCommand(e);r||this.help({error:!0}),r._prepareForParse();let i;return i=this._chainOrCallSubCommandHook(i,r,`preSubcommand`),i=this._chainOrCall(i,()=>{if(r._executableHandler)this._executeSubCommand(r,t.concat(n));else return r._parseCommand(t,n)}),i}_dispatchHelpCommand(e){e||this.help();let t=this._findCommand(e);return t&&!t._executableHandler&&t.help(),this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??`--help`])}_checkNumberOfArguments(){this.registeredArguments.forEach((e,t)=>{e.required&&this.args[t]==null&&this.missingArgument(e.name())}),this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic||this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let e=(e,t,n)=>{let r=t;if(t!==null&&e.parseArg){let i=`error: command-argument value '${t}' is invalid for argument '${e.name()}'.`;r=this._callParseArg(e,t,n,i)}return r};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((n,r)=>{let i=n.defaultValue;n.variadic?r<this.args.length?(i=this.args.slice(r),n.parseArg&&(i=i.reduce((t,r)=>e(n,r,t),n.defaultValue))):i===void 0&&(i=[]):r<this.args.length&&(i=this.args[r],n.parseArg&&(i=e(n,i,n.defaultValue))),t[r]=i}),this.processedArgs=t}_chainOrCall(e,t){return e?.then&&typeof e.then==`function`?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let n=e,r=[];return this._getCommandAndAncestors().reverse().filter(e=>e._lifeCycleHooks[t]!==void 0).forEach(e=>{e._lifeCycleHooks[t].forEach(t=>{r.push({hookedCommand:e,callback:t})})}),t===`postAction`&&r.reverse(),r.forEach(e=>{n=this._chainOrCall(n,()=>e.callback(e.hookedCommand,this))}),n}_chainOrCallSubCommandHook(e,t,n){let r=e;return this._lifeCycleHooks[n]!==void 0&&this._lifeCycleHooks[n].forEach(e=>{r=this._chainOrCall(r,()=>e(this,t))}),r}_parseCommand(e,t){let n=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(n.operands),t=n.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(t),this._dispatchSubcommand(this._defaultCommandName,e,t);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(n.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let r=()=>{n.unknown.length>0&&this.unknownOption(n.unknown[0])},i=`command:${this.name()}`;if(this._actionHandler){r(),this._processArguments();let n;return n=this._chainOrCallHooks(n,`preAction`),n=this._chainOrCall(n,()=>this._actionHandler(this.processedArgs)),this.parent&&(n=this._chainOrCall(n,()=>{this.parent.emit(i,e,t)})),n=this._chainOrCallHooks(n,`postAction`),n}if(this.parent?.listenerCount(i))r(),this._processArguments(),this.parent.emit(i,e,t);else if(e.length){if(this._findCommand(`*`))return this._dispatchSubcommand(`*`,e,t);this.listenerCount(`command:*`)?this.emit(`command:*`,e,t):this.commands.length?this.unknownCommand():(r(),this._processArguments())}else this.commands.length?(r(),this.help({error:!0})):(r(),this._processArguments())}_findCommand(e){if(e)return this.commands.find(t=>t._name===e||t._aliases.includes(e))}_findOption(e){return this.options.find(t=>t.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(e=>{e.options.forEach(t=>{t.mandatory&&e.getOptionValue(t.attributeName())===void 0&&e.missingMandatoryOptionValue(t)})})}_checkForConflictingLocalOptions(){let e=this.options.filter(e=>{let t=e.attributeName();return this.getOptionValue(t)!==void 0&&this.getOptionValueSource(t)!=="default"});e.filter(e=>e.conflictsWith.length>0).forEach(t=>{let n=e.find(e=>t.conflictsWith.includes(e.attributeName()));n&&this._conflictingOption(t,n)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],n=[],r=t;function i(e){return e.length>1&&e[0]===`-`}let a=e=>/^-(\d+|\d*\.\d+)([eE][+-]?\d+)?$/.test(e)?!this._getCommandAndAncestors().some(e=>e.options.map(e=>e.short).some(e=>/^-\d$/.test(e))):!1,o=null,s=null,c=0;for(;c<e.length||s;){let l=s??e[c++];if(s=null,l===`--`){r===n&&r.push(l),r.push(...e.slice(c));break}if(o&&(!i(l)||a(l)))this.emit(`option:${o.name()}`,l);else{if(o=null,i(l)){let t=this._findOption(l);if(t){if(t.required){let n=e[c++];n===void 0&&this.optionMissingArgument(t),this.emit(`option:${t.name()}`,n)}else if(t.optional){let n=null;c<e.length&&(!i(e[c])||a(e[c]))&&(n=e[c++]),this.emit(`option:${t.name()}`,n)}else this.emit(`option:${t.name()}`);o=t.variadic?t:null;continue}}if(l.length>2&&l[0]===`-`&&l[1]!==`-`){let e=this._findOption(`-${l[1]}`);if(e){e.required||e.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${e.name()}`,l.slice(2)):(this.emit(`option:${e.name()}`),s=`-${l.slice(2)}`);continue}}if(/^--[^=]+=/.test(l)){let e=l.indexOf(`=`),t=this._findOption(l.slice(0,e));if(t&&(t.required||t.optional)){this.emit(`option:${t.name()}`,l.slice(e+1));continue}}if(r===t&&i(l)&&!(this.commands.length===0&&a(l))&&(r=n),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&n.length===0){if(this._findCommand(l)){t.push(l),n.push(...e.slice(c));break}if(this._getHelpCommand()&&l===this._getHelpCommand().name()){t.push(l,...e.slice(c));break}if(this._defaultCommandName){n.push(l,...e.slice(c));break}}if(this._passThroughOptions){r.push(l,...e.slice(c));break}r.push(l)}}return{operands:t,unknown:n}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let n=0;n<t;n++){let t=this.options[n].attributeName();e[t]=t===this._versionOptionName?this._version:this[t]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}\n`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError==`string`?this._outputConfiguration.writeErr(`${this._showHelpAfterError}\n`):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
154
154
  `),this.outputHelp({error:!0}));let n=t||{},r=n.exitCode||1,i=n.code||`commander.error`;this._exit(r,i,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in b.env){let t=e.attributeName();(this.getOptionValue(t)===void 0||[`default`,`config`,`env`].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,b.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new Ju(this.options),t=e=>this.getOptionValue(e)!==void 0&&![`default`,`implied`].includes(this.getOptionValueSource(e));this.options.filter(n=>n.implied!==void 0&&t(n.attributeName())&&e.valueFromOption(this.getOptionValue(n.attributeName()),n)).forEach(e=>{Object.keys(e.implied).filter(e=>!t(e)).forEach(t=>{this.setOptionValueWithSource(t,e.implied[t],`implied`)})})}missingArgument(e){let t=`error: missing required argument '${e}'`;this.error(t,{code:`commander.missingArgument`})}optionMissingArgument(e){let t=`error: option '${e.flags}' argument missing`;this.error(t,{code:`commander.optionMissingArgument`})}missingMandatoryOptionValue(e){let t=`error: required option '${e.flags}' not specified`;this.error(t,{code:`commander.missingMandatoryOptionValue`})}_conflictingOption(e,t){let n=e=>{let t=e.attributeName(),n=this.getOptionValue(t),r=this.options.find(e=>e.negate&&t===e.attributeName()),i=this.options.find(e=>!e.negate&&t===e.attributeName());return r&&(r.presetArg===void 0&&n===!1||r.presetArg!==void 0&&n===r.presetArg)?r:i||e},r=e=>{let t=n(e),r=t.attributeName();return this.getOptionValueSource(r)===`env`?`environment variable '${t.envVar}'`:`option '${t.flags}'`},i=`error: ${r(e)} cannot be used with ${r(t)}`;this.error(i,{code:`commander.conflictingOption`})}unknownOption(e){if(this._allowUnknownOption)return;let t=``;if(e.startsWith(`--`)&&this._showSuggestionAfterError){let n=[],r=this;do{let e=r.createHelp().visibleOptions(r).filter(e=>e.long).map(e=>e.long);n=n.concat(e),r=r.parent}while(r&&!r._enablePositionalOptions);t=Qu(e,n)}let n=`error: unknown option '${e}'${t}`;this.error(n,{code:`commander.unknownOption`})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,n=t===1?``:`s`,r=e.length,i=`error: too many arguments${this.parent?` for '${this.name()}'`:``}. Expected ${t} argument${n} but got ${r}: ${e.join(`, `)}.`;this.error(i,{code:`commander.excessArguments`})}unknownCommand(){let e=this.args[0],t=``;if(this._showSuggestionAfterError){let n=[];this.createHelp().visibleCommands(this).forEach(e=>{n.push(e.name()),e.alias()&&n.push(e.alias())}),t=Qu(e,n)}let n=`error: unknown command '${e}'${t}`;this.error(n,{code:`commander.unknownCommand`})}version(e,t,n){if(e===void 0)return this._version;this._version=e,t||=`-V, --version`,n||=`output the version number`;let r=this.createOption(t,n);return this._versionOptionName=r.attributeName(),this._registerOption(r),this.on(`option:`+r.name(),()=>{this._outputConfiguration.writeOut(`${e}\n`),this._exit(0,`commander.version`,e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw Error(`Command alias can't be the same as its name`);let n=this.parent?._findCommand(e);if(n){let t=[n.name()].concat(n.aliases()).join(`|`);throw Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${t}'`)}return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(e=>this.alias(e)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let e=this.registeredArguments.map(e=>Gu(e));return[].concat(this.options.length||this._helpOption!==null?`[options]`:[],this.commands.length?`[command]`:[],this.registeredArguments.length?e:[]).join(` `)}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}helpGroup(e){return e===void 0?this._helpGroupHeading??``:(this._helpGroupHeading=e,this)}commandsGroup(e){return e===void 0?this._defaultCommandGroup??``:(this._defaultCommandGroup=e,this)}optionsGroup(e){return e===void 0?this._defaultOptionGroup??``:(this._defaultOptionGroup=e,this)}_initOptionGroup(e){this._defaultOptionGroup&&!e.helpGroupHeading&&e.helpGroup(this._defaultOptionGroup)}_initCommandGroup(e){this._defaultCommandGroup&&!e.helpGroup()&&e.helpGroup(this._defaultCommandGroup)}nameFromFilename(e){return this._name=f.basename(e,f.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let t=this.createHelp(),n=this._getOutputContext(e);t.prepareContext({error:n.error,helpWidth:n.helpWidth,outputHasColors:n.hasColors});let r=t.formatHelp(this,t);return n.hasColors?r:this._outputConfiguration.stripColor(r)}_getOutputContext(e){e||={};let t=!!e.error,n,r,i;return t?(n=e=>this._outputConfiguration.writeErr(e),r=this._outputConfiguration.getErrHasColors(),i=this._outputConfiguration.getErrHelpWidth()):(n=e=>this._outputConfiguration.writeOut(e),r=this._outputConfiguration.getOutHasColors(),i=this._outputConfiguration.getOutHelpWidth()),{error:t,write:e=>(r||(e=this._outputConfiguration.stripColor(e)),n(e)),hasColors:r,helpWidth:i}}outputHelp(e){let t;typeof e==`function`&&(t=e,e=void 0);let n=this._getOutputContext(e),r={error:n.error,write:n.write,command:this};this._getCommandAndAncestors().reverse().forEach(e=>e.emit(`beforeAllHelp`,r)),this.emit(`beforeHelp`,r);let i=this.helpInformation({error:n.error});if(t&&(i=t(i),typeof i!=`string`&&!Buffer.isBuffer(i)))throw Error(`outputHelp callback must return a string or a Buffer`);n.write(i),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit(`afterHelp`,r),this._getCommandAndAncestors().forEach(e=>e.emit(`afterAllHelp`,r))}helpOption(e,t){return typeof e==`boolean`?(e?(this._helpOption===null&&(this._helpOption=void 0),this._defaultOptionGroup&&this._initOptionGroup(this._getHelpOption())):this._helpOption=null,this):(this._helpOption=this.createOption(e??`-h, --help`,t??`display help for command`),(e||t)&&this._initOptionGroup(this._helpOption),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this._initOptionGroup(e),this}help(e){this.outputHelp(e);let t=Number(b.exitCode??0);t===0&&e&&typeof e!=`function`&&e.error&&(t=1),this._exit(t,`commander.help`,`(outputHelp)`)}addHelpText(e,t){let n=[`beforeAll`,`before`,`after`,`afterAll`];if(!n.includes(e))throw Error(`Unexpected value for position to addHelpText.
155
- Expecting one of '${n.join(`', '`)}'`);let r=`${e}Help`;return this.on(r,e=>{let n;n=typeof t==`function`?t({error:e.error,command:e.command}):t,n&&e.write(`${n}\n`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(e=>t.is(e))&&(this.outputHelp(),this._exit(0,`commander.helpDisplayed`,`(outputHelp)`))}};function ed(e){return e.map(e=>{if(!e.startsWith(`--inspect`))return e;let t,n=`127.0.0.1`,r=`9229`,i;return(i=e.match(/^(--inspect(-brk|-wait)?)$/))===null?(i=e.match(/^(--inspect(-brk|-port|-wait)?)=(\[[^\]]+\]|[^:]+)$/))===null?(i=e.match(/^(--inspect(-brk|-port|-wait)?)=(\[[^\]]+\]|[^:]+):(\d+)$/))!==null&&(t=i[1],n=i[3],r=i[4]):(t=i[1],/^\d+$/.test(i[3])?r=i[3]:n=i[3]):t=i[1],t&&r!==`0`?`${t}=${n}:${parseInt(r)+1}`:e})}function td(){if(b.env.NO_COLOR||b.env.FORCE_COLOR===`0`||b.env.FORCE_COLOR===`false`)return!1;if(b.env.FORCE_COLOR||b.env.CLICOLOR_FORCE!==void 0)return!0}new $u;let nd;function rd(){return nd??=Vu(`@longzai-intelligence-cli/core/provider`),nd}const id={red:e=>e,green:e=>e,yellow:e=>e,blue:e=>e,cyan:e=>e,magenta:e=>e,gray:e=>e,bold:e=>e,dim:e=>e};let ad={select:async(e,t)=>t[0]?.value??``,textInput:async(e,t)=>t?.defaultValue??``,confirm:async(e,t)=>t?.defaultValue??!1,spinner:()=>({start:e=>rd().info(e),stop:e=>rd().info(e)}),note:(e,t)=>{t?rd().info(`${t}: ${e}`):rd().info(e)},log:{info:e=>rd().info(e),success:e=>rd().info(e),warn:e=>rd().warn(e),error:e=>rd().error(e),step:e=>rd().info(e)}},od=id;function sd(e){ad=e}function cd(e){od=e}function ld(){return ad}function ud(){return od}const dd=()=>`0.1.14`;function fd(e){let t=e.version??dd();e.interaction&&sd(e.interaction),e.color&&cd(e.color);let n=new $u;return n.name(e.name).version(t,`-v, --version`,`输出 ${e.name} 的版本号`),e.description&&n.description(e.description),n}let pd;function md(){return pd??=Vu(`@longzai-intelligence-cli/core/define-command`),pd}function hd(e,t){let n=e.commands.find(e=>e.name()===t);return n===void 0?e.command(t):n}function gd(e,t){if(t.length===1){let n=t[0];if(n===void 0)throw Error(`defineCommand: segments 为空,无法解析命令名`);return e.command(n)}let[n,...r]=t;if(n===void 0)throw Error(`defineCommand: segments 首段为空,无法解析父命令名`);let i=r.pop();if(i===void 0)throw Error(`defineCommand: segments 末段为空,无法解析子命令名`);let a=hd(e,n);for(let e of r)a=hd(a,e);return a.command(i)}function _d(e){return typeof e==`object`&&!!e&&`opts`in e&&typeof e.opts==`function`&&`args`in e&&Array.isArray(e.args)}function vd(e,t){let n=gd(e,t.name.split(` `).filter(e=>e.length>0));t.description&&n.description(t.description);for(let e of t.arguments??[])e.description?n.argument(e.signature,e.description):n.argument(e.signature);for(let e of t.options??[])e.defaultValue===void 0?n.option(e.flags,e.description??``):n.option(e.flags,e.description??``,e.defaultValue);n.action(async(...e)=>{let n=e[e.length-1];if(!_d(n))return;let r=n.opts(),i=n.args,a=t.schema.safeParse(r);if(!a.success){let e=a.error.issues.map(e=>e.message).join(`, `);md().error(ud().red(`参数校验失败: ${e}`)),ld().log.error(`参数校验失败: ${e}`),process.exit(1)}await t.action(a.data,i)})}const yd=(()=>{let e=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return t=>{let n=0;for(e.lastIndex=0;e.test(t);)n+=1;return t.length-n}})(),bd=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,xd=e=>e===8987||e===9001||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e>=131072&&e<=196605||e>=196608&&e<=262141,Sd=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,Cd=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,wd=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/uy,Td=/\t{1,1000}/y,Ed=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy,Dd=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,Od=/\p{M}+/gu,kd={limit:1/0,ellipsis:``},Ad=(e,t={},n={})=>{let r=t.limit??1/0,i=t.ellipsis??``,a=t?.ellipsisWidth??(i?Ad(i,kd,n).width:0),o=n.controlWidth??0,s=n.tabWidth??8,c=n.emojiWidth??2,l=n.regularWidth??1,u=n.wideWidth??2,d=[[Dd,l],[Sd,0],[Cd,o],[Td,s],[Ed,c],[wd,u]],f=0,p=0,m=e.length,h=0,g=!1,_=m,v=Math.max(0,r-a),y=0,b=0,x=0,S=0;outer:for(;;){if(b>y||p>=m&&p>f){let t=e.slice(y,b)||e.slice(f,p);h=0;for(let e of t.replaceAll(Od,``)){let t=e.codePointAt(0)||0;if(S=bd(t)?2:xd(t)?u:l,x+S>v&&(_=Math.min(_,Math.max(y,f)+h)),x+S>r){g=!0;break outer}h+=e.length,x+=S}y=b=0}if(p>=m)break outer;for(let t=0,n=d.length;t<n;t++){let[n,i]=d[t];if(n.lastIndex=p,n.test(e)){if(h=n===wd?yd(e.slice(p,n.lastIndex)):n===Ed?1:n.lastIndex-p,S=h*i,x+S>v&&(_=Math.min(_,p+Math.floor((v-x)/i))),x+S>r){g=!0;break outer}x+=S,y=f,b=p,p=f=n.lastIndex;continue outer}}p+=1}return{width:g?v:x,index:g?_:m,truncated:g,ellipsed:g&&r>=a}},jd={limit:1/0,ellipsis:``,ellipsisWidth:0},Md=(e,t={})=>Ad(e,jd,t).width,Nd=`]8;;`,Pd=RegExp(`(?:\\[(?<code>\\d+)m|\\${Nd}(?<uri>.*))`,`y`),Fd=e=>{if(e>=30&&e<=37||e>=90&&e<=97)return 39;if(e>=40&&e<=47||e>=100&&e<=107)return 49;if(e===1||e===2)return 22;if(e===3)return 23;if(e===4)return 24;if(e===7)return 27;if(e===8)return 28;if(e===9)return 29;if(e===0)return 0},Id=e=>`[${e}m`,Ld=e=>`${Nd}${e}`,Rd=(e,t,n)=>{let r=t[Symbol.iterator](),i=!1,a=!1,o=e.at(-1),s=o===void 0?0:Md(o),c=r.next(),l=r.next(),u=0;for(;!c.done;){let o=c.value,d=Md(o);s+d<=n?e[e.length-1]+=o:(e.push(o),s=0),(o===`\x1B`||o===`›`)&&(i=!0,a=t.startsWith(Nd,u+1)),i?a?o===`\x07`&&(i=!1,a=!1):o===`m`&&(i=!1):(s+=d,s===n&&!l.done&&(e.push(``),s=0)),c=l,l=r.next(),u+=o.length}o=e.at(-1),!s&&o!==void 0&&o.length&&e.length>1&&(e[e.length-2]+=e.pop())},zd=e=>{let t=e.split(` `),n=t.length;for(;n&&!Md(t[n-1]);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},Bd=(e,t,n={})=>{if(n.trim!==!1&&e.trim()===``)return``;let r=``,i,a,o=e.split(` `),s=[``],c=0;for(let e=0;e<o.length;e++){let r=o[e];if(n.trim!==!1){let e=s.at(-1)??``,t=e.trimStart();e.length!==t.length&&(s[s.length-1]=t,c=Md(t))}e!==0&&(c>=t&&(n.wordWrap===!1||n.trim===!1)&&(s.push(``),c=0),(c||n.trim===!1)&&(s[s.length-1]+=` `,c++));let i=Md(r);if(n.hard&&i>t){let e=t-c,n=1+Math.floor((i-e-1)/t);Math.floor((i-1)/t)<n&&s.push(``),Rd(s,r,t),c=Md(s.at(-1)??``)}else{if(c+i>t&&c&&i){if(n.wordWrap===!1&&c<t){Rd(s,r,t),c=Md(s.at(-1)??``);continue}s.push(``),c=0}c+i>t&&n.wordWrap===!1?(Rd(s,r,t),c=Md(s.at(-1)??``)):(s[s.length-1]+=r,c+=i)}}n.trim!==!1&&(s=s.map(e=>zd(e)));let l=s.join(`
155
+ Expecting one of '${n.join(`', '`)}'`);let r=`${e}Help`;return this.on(r,e=>{let n;n=typeof t==`function`?t({error:e.error,command:e.command}):t,n&&e.write(`${n}\n`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(e=>t.is(e))&&(this.outputHelp(),this._exit(0,`commander.helpDisplayed`,`(outputHelp)`))}};function ed(e){return e.map(e=>{if(!e.startsWith(`--inspect`))return e;let t,n=`127.0.0.1`,r=`9229`,i;return(i=e.match(/^(--inspect(-brk|-wait)?)$/))===null?(i=e.match(/^(--inspect(-brk|-port|-wait)?)=(\[[^\]]+\]|[^:]+)$/))===null?(i=e.match(/^(--inspect(-brk|-port|-wait)?)=(\[[^\]]+\]|[^:]+):(\d+)$/))!==null&&(t=i[1],n=i[3],r=i[4]):(t=i[1],/^\d+$/.test(i[3])?r=i[3]:n=i[3]):t=i[1],t&&r!==`0`?`${t}=${n}:${parseInt(r)+1}`:e})}function td(){if(b.env.NO_COLOR||b.env.FORCE_COLOR===`0`||b.env.FORCE_COLOR===`false`)return!1;if(b.env.FORCE_COLOR||b.env.CLICOLOR_FORCE!==void 0)return!0}new $u;let nd;function rd(){return nd??=Vu(`@longzai-intelligence-cli/core/provider`),nd}const id={red:e=>e,green:e=>e,yellow:e=>e,blue:e=>e,cyan:e=>e,magenta:e=>e,gray:e=>e,bold:e=>e,dim:e=>e};let ad={select:async(e,t)=>t[0]?.value??``,textInput:async(e,t)=>t?.defaultValue??``,confirm:async(e,t)=>t?.defaultValue??!1,spinner:()=>({start:e=>rd().info(e),stop:e=>rd().info(e)}),note:(e,t)=>{t?rd().info(`${t}: ${e}`):rd().info(e)},log:{info:e=>rd().info(e),success:e=>rd().info(e),warn:e=>rd().warn(e),error:e=>rd().error(e),step:e=>rd().info(e)}},od=id;function sd(e){ad=e}function cd(e){od=e}function ld(){return ad}function ud(){return od}const dd=()=>`0.1.15`;function fd(e){let t=e.version??dd();e.interaction&&sd(e.interaction),e.color&&cd(e.color);let n=new $u;return n.name(e.name).version(t,`-v, --version`,`输出 ${e.name} 的版本号`),e.description&&n.description(e.description),n}let pd;function md(){return pd??=Vu(`@longzai-intelligence-cli/core/define-command`),pd}function hd(e,t){let n=e.commands.find(e=>e.name()===t);return n===void 0?e.command(t):n}function gd(e,t){if(t.length===1){let n=t[0];if(n===void 0)throw Error(`defineCommand: segments 为空,无法解析命令名`);return e.command(n)}let[n,...r]=t;if(n===void 0)throw Error(`defineCommand: segments 首段为空,无法解析父命令名`);let i=r.pop();if(i===void 0)throw Error(`defineCommand: segments 末段为空,无法解析子命令名`);let a=hd(e,n);for(let e of r)a=hd(a,e);return a.command(i)}function _d(e){return typeof e==`object`&&!!e&&`opts`in e&&typeof e.opts==`function`&&`args`in e&&Array.isArray(e.args)}function vd(e,t){let n=gd(e,t.name.split(` `).filter(e=>e.length>0));t.description&&n.description(t.description);for(let e of t.arguments??[])e.description?n.argument(e.signature,e.description):n.argument(e.signature);for(let e of t.options??[])e.defaultValue===void 0?n.option(e.flags,e.description??``):n.option(e.flags,e.description??``,e.defaultValue);n.action(async(...e)=>{let n=e[e.length-1];if(!_d(n))return;let r=n.opts(),i=n.args,a=t.schema.safeParse(r);if(!a.success){let e=a.error.issues.map(e=>e.message).join(`, `);md().error(ud().red(`参数校验失败: ${e}`)),ld().log.error(`参数校验失败: ${e}`),process.exit(1)}await t.action(a.data,i)})}const yd=(()=>{let e=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return t=>{let n=0;for(e.lastIndex=0;e.test(t);)n+=1;return t.length-n}})(),bd=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,xd=e=>e===8987||e===9001||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e>=131072&&e<=196605||e>=196608&&e<=262141,Sd=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,Cd=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,wd=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/uy,Td=/\t{1,1000}/y,Ed=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy,Dd=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,Od=/\p{M}+/gu,kd={limit:1/0,ellipsis:``},Ad=(e,t={},n={})=>{let r=t.limit??1/0,i=t.ellipsis??``,a=t?.ellipsisWidth??(i?Ad(i,kd,n).width:0),o=n.controlWidth??0,s=n.tabWidth??8,c=n.emojiWidth??2,l=n.regularWidth??1,u=n.wideWidth??2,d=[[Dd,l],[Sd,0],[Cd,o],[Td,s],[Ed,c],[wd,u]],f=0,p=0,m=e.length,h=0,g=!1,_=m,v=Math.max(0,r-a),y=0,b=0,x=0,S=0;outer:for(;;){if(b>y||p>=m&&p>f){let t=e.slice(y,b)||e.slice(f,p);h=0;for(let e of t.replaceAll(Od,``)){let t=e.codePointAt(0)||0;if(S=bd(t)?2:xd(t)?u:l,x+S>v&&(_=Math.min(_,Math.max(y,f)+h)),x+S>r){g=!0;break outer}h+=e.length,x+=S}y=b=0}if(p>=m)break outer;for(let t=0,n=d.length;t<n;t++){let[n,i]=d[t];if(n.lastIndex=p,n.test(e)){if(h=n===wd?yd(e.slice(p,n.lastIndex)):n===Ed?1:n.lastIndex-p,S=h*i,x+S>v&&(_=Math.min(_,p+Math.floor((v-x)/i))),x+S>r){g=!0;break outer}x+=S,y=f,b=p,p=f=n.lastIndex;continue outer}}p+=1}return{width:g?v:x,index:g?_:m,truncated:g,ellipsed:g&&r>=a}},jd={limit:1/0,ellipsis:``,ellipsisWidth:0},Md=(e,t={})=>Ad(e,jd,t).width,Nd=`]8;;`,Pd=RegExp(`(?:\\[(?<code>\\d+)m|\\${Nd}(?<uri>.*))`,`y`),Fd=e=>{if(e>=30&&e<=37||e>=90&&e<=97)return 39;if(e>=40&&e<=47||e>=100&&e<=107)return 49;if(e===1||e===2)return 22;if(e===3)return 23;if(e===4)return 24;if(e===7)return 27;if(e===8)return 28;if(e===9)return 29;if(e===0)return 0},Id=e=>`[${e}m`,Ld=e=>`${Nd}${e}`,Rd=(e,t,n)=>{let r=t[Symbol.iterator](),i=!1,a=!1,o=e.at(-1),s=o===void 0?0:Md(o),c=r.next(),l=r.next(),u=0;for(;!c.done;){let o=c.value,d=Md(o);s+d<=n?e[e.length-1]+=o:(e.push(o),s=0),(o===`\x1B`||o===`›`)&&(i=!0,a=t.startsWith(Nd,u+1)),i?a?o===`\x07`&&(i=!1,a=!1):o===`m`&&(i=!1):(s+=d,s===n&&!l.done&&(e.push(``),s=0)),c=l,l=r.next(),u+=o.length}o=e.at(-1),!s&&o!==void 0&&o.length&&e.length>1&&(e[e.length-2]+=e.pop())},zd=e=>{let t=e.split(` `),n=t.length;for(;n&&!Md(t[n-1]);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},Bd=(e,t,n={})=>{if(n.trim!==!1&&e.trim()===``)return``;let r=``,i,a,o=e.split(` `),s=[``],c=0;for(let e=0;e<o.length;e++){let r=o[e];if(n.trim!==!1){let e=s.at(-1)??``,t=e.trimStart();e.length!==t.length&&(s[s.length-1]=t,c=Md(t))}e!==0&&(c>=t&&(n.wordWrap===!1||n.trim===!1)&&(s.push(``),c=0),(c||n.trim===!1)&&(s[s.length-1]+=` `,c++));let i=Md(r);if(n.hard&&i>t){let e=t-c,n=1+Math.floor((i-e-1)/t);Math.floor((i-1)/t)<n&&s.push(``),Rd(s,r,t),c=Md(s.at(-1)??``)}else{if(c+i>t&&c&&i){if(n.wordWrap===!1&&c<t){Rd(s,r,t),c=Md(s.at(-1)??``);continue}s.push(``),c=0}c+i>t&&n.wordWrap===!1?(Rd(s,r,t),c=Md(s.at(-1)??``)):(s[s.length-1]+=r,c+=i)}}n.trim!==!1&&(s=s.map(e=>zd(e)));let l=s.join(`
156
156
  `),u=!1;for(let e=0;e<l.length;e++){let t=l[e];if(r+=t,u)u=!1;else if(u=t>=`\ud800`&&t<=`\udbff`,u)continue;if(t===`\x1B`||t===`›`){Pd.lastIndex=e+1;let t=Pd.exec(l)?.groups;if(t?.code!==void 0){let e=Number.parseFloat(t.code);i=e===39?void 0:e}else t?.uri!==void 0&&(a=t.uri.length===0?void 0:t.uri)}if(l[e+1]===`
157
157
  `){a&&(r+=Ld(``));let e=i?Fd(i):void 0;i&&e&&(r+=Id(e))}else t===`
158
158
  `&&(i&&Fd(i)&&(r+=Id(i)),a&&(r+=Ld(a)))}return r},Vd=/\r?\n/;function Hd(e,t,n){return String(e).normalize().split(Vd).map(e=>Bd(e,t,n)).join(`
@@ -240,7 +240,7 @@ ${t?r(`cyan`,gf):``}
240
240
 
241
241
  `)}\n`}function rh(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=eh(t.repoInstall,t.installScopesPreset,t.selfScope,process.env.LZI_NPM_REGISTRY_URL)}return{content:nh(a),shouldWrite:!0}}const ih=(e,t)=>o(h(t,`src/__tests__/helpers/bootstrap.ts`))?Yf(e):e;function ah(e){let t=0,n=0,r=0,i=0;for(let a of e.split(`
242
242
  `)){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 oh(e){return typeof e==`number`?{lines:e,functions:e,statements:e}:{...e}}function sh(e,t){if(!(t<=0))return e/t}function ch(e,t){let n=oh(t),r=sh(e.linesHit,e.linesFound),i=sh(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 lh(e){return`${(e*100).toFixed(2)}%`}function uh(e){return e.results.map(e=>{let t=e.actual===void 0?`无数据`:lh(e.actual),n=e.actual===void 0||e.actual>=e.required?`通过`:`未达标`;return`${e.dimension} 覆盖率 ${t},阈值 ${lh(e.required)},${n}`})}function dh(e){let t=lp(Fm(e.rootDir)),n=h(e.rootDir,np),r=o(n)?c(n,`utf8`):void 0,i=r===void 0?[]:Am(r),{missing:a,unconsumed:s}=up(t,i),l=new Set((e.declared??[]).map(e=>ap(e))),u=new Set(i.map(e=>ap(e))),f=[...u].filter(e=>!l.has(e)),p=[...l].filter(e=>!u.has(e));if(f.length>0||p.length>0){let e=[`警告:${np} 的 install.privateScopes 加载态与文件态不一致,按文件态执法`];f.length>0&&e.push(`加载态缺见 ${f.map(e=>`@${e}`).join(`、`)}`),p.length>0&&e.push(`加载态多出 ${p.map(e=>`@${e}`).join(`、`)}`),J(e.join(`,`))}for(let e of s)J(`提示:${np} 的 install.privateScopes 条目 @${e} 未被工作区任何包消费,保留为预声明`);if(a.length===0)return{effectivePrivateScopes:i.length>0?[...i]:void 0,missing:a,unconsumed:s,rewritten:!1};if(e.mode===`check`)throw new Ym(n,a);if(r===void 0)throw new Xm(n,`${np} 不存在`,a);let m=Jm(r,a.map(e=>e.scope));if(!m.ok)throw new Xm(n,m.reason,a);let g=[...i,...a.map(e=>`@${e.scope}`)],_=`${n} 的 install.privateScopes 缺失声明 ${a.length} 条:${Lm(a)}`;return e.mode===`dry-run`?(J(`[dry-run] 将自动补齐 ${_}`),J(`[dry-run] 将写入 ${n}:`),J(m.content),{effectivePrivateScopes:g,missing:a,unconsumed:s,rewritten:!1}):(d(n,m.content,`utf8`),J(`已自动补齐 ${_}`),{effectivePrivateScopes:g,missing:a,unconsumed:s,rewritten:!0})}const fh={server:`server`,web:`web`,desktop:`desktop`,cli:`cli`,mcp:`mcp`,"desktop-host":`desktop-host`,docs:`docs`,mobile:`mobile`,miniprogram:`miniprogram`},ph=[`contract`,`main`,`implementation`,`infrastructure`,`api`,`ui`];function mh(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`:ph.find(e=>e===i)??`non-fixed`:n===`apps`?t.length===3&&r===`capabilities`?`capability`:t.length===2&&r!==void 0?fh[r]??`non-fixed`:`non-fixed`:n===`packages`&&t.length===2&&r!==void 0?`package`:`non-fixed`}var hh=class extends Error{details;constructor(e,t){let n=t.flatMap(e=>e.details.map(t=>`${gh(e.kind)}:${t}`));super(`${e} 的测试配置违反分层规则:\n${n.map(e=>` - ${e}`).join(`
243
- `)}`),this.name=`TypeOnlyViolationError`,this.details=n}};function gh(e){return e===`exempt-runtime`?`包内代码与声明预设不符`:e===`zero-tests-undeclared`?`包内没有测试,也没有声明允许零测试的预设`:`声明的预设与目录分层不符`}const _h=e=>typeof e==`object`&&!!e&&!Array.isArray(e),vh=e=>Array.isArray(e)||typeof e==`object`&&!!e&&`packages`in e,yh=e=>{let t=h(e,`package.json`);if(!o(t))return`missing-package-json`;let n;try{n=JSON.parse(c(t,`utf8`))}catch{return`not-root`}return _h(n)&&vh(n.workspaces)?`root`:`not-root`},bh=e=>yh(e)===`root`,xh=(e,t)=>{let n=h(e,`package.json`);try{let e=JSON.parse(c(n,`utf8`));if(_h(e)){let t=e.name;if(typeof t==`string`&&t!==``)return t}}catch{}return t},Sh=e=>{let t=e.indexOf(`/`);if(!(!e.startsWith(`@`)||t<=1))return e.slice(1,t)},Ch=`.lzi/baselines/lzi-bun.typeonly.json`,wh=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Th=[`exempt-runtime`,`zero-tests-undeclared`,`preset-layer-mismatch`],Eh=e=>typeof e==`string`&&Th.some(t=>t===e);function Dh(e){return`${e.path}|${e.kind}`}function Oh(e){let t=h(e,Ch);if(!o(t))return/* @__PURE__ */ new Set;try{let e=JSON.parse(c(t,`utf8`));if(!wh(e)||!Array.isArray(e.entries))return/* @__PURE__ */ new Set;let n=/* @__PURE__ */ new Set;for(let t of e.entries)wh(t)&&typeof t.path==`string`&&Eh(t.kind)&&n.add(`${t.path}|${t.kind}`);return n}catch{return/* @__PURE__ */ new Set}}function kh(e,t,n){return e.has(`${t}|${n}`)}function Ah(e,t){let n=[...t].sort((e,t)=>Dh(e)<Dh(t)?-1:+(Dh(e)>Dh(t))),r=h(e,Ch);s(m(r),{recursive:!0}),d(r,`${JSON.stringify({version:1,entries:n},null,2)}\n`,`utf8`)}function jh(e,t){return[...Oh(e)].filter(e=>!t.has(e))}function Mh(e){let t=e.indexOf(`|`),n=Th.find(n=>n===e.slice(t+1));return{path:e.slice(0,t),kind:n??`preset-layer-mismatch`}}function Nh(e,t){let n=Q(e,`callee`);if(n===void 0)return!1;if(Sm(n)===`Symbol`)return!0;if(n.type===`MemberExpression`){let e=Sm(Q(n,`object`));return e!==void 0&&t.zodBindings.has(e)}return!1}function Ph(e,t){if(e.type===`TSAsExpression`||e.type===`TSSatisfiesExpression`){let n=Q(e,`expression`);if(n!==void 0)return Ph(n,t)}if(e.type===`TSInstantiationExpression`){let n=Q(e,`expression`);if(n!==void 0)return Ph(n,t)}return e.type===`CallExpression`?Nh(e,t)?`declarative`:`runtime`:e.type===`ArrowFunctionExpression`?t.isTsx?`runtime`:Om(e)?`thin`:`runtime`:e.type===`Identifier`||Tm(e)?`declarative`:`runtime`}function Fh(e,t){switch(e.type){case`TSTypeAliasDeclaration`:case`TSInterfaceDeclaration`:case`TSModuleDeclaration`:case`TSDeclareFunction`:return`type`;case`TSEnumDeclaration`:return`declarative`;case`ClassDeclaration`:return Dm(e)?`declarative`:`runtime`;case`FunctionDeclaration`:return t.isTsx?`runtime`:Om(e)?`thin`:`runtime`;case`VariableDeclaration`:{let n=Z(e.declarations);if(n===void 0)return`runtime`;let r=`type`;for(let e of n){let n=Q(e,`init`),i=n===void 0?`declarative`:Ph(n,t);if(i===`runtime`)return`runtime`;i!==`type`&&(r=i)}return r}default:return`runtime`}}function Ih(e,t){let n=/* @__PURE__ */ new Set,r=/* @__PURE__ */ new Set,i=/* @__PURE__ */ new Map;for(let t of e){if(t.type===`ImportDeclaration`){Lh(t,n,r);continue}let e=Q(t,`declaration`);t.type===`ExportNamedDeclaration`&&e!==void 0?Rh(i,e):Rh(i,t)}return{zodBindings:n,importBindings:r,localDeclarations:i,isTsx:t}}function Lh(e,t,n){let r=Q(e,`source`),i=r!==void 0&&typeof r.value==`string`?r.value:void 0,a=Z(e.specifiers);if(a!==void 0)for(let e of a){let r=Sm(Q(e,`local`));r!==void 0&&(n.add(r),i===`zod`&&(e.type===`ImportNamespaceSpecifier`&&t.add(r),e.type===`ImportSpecifier`&&Sm(Q(e,`imported`))===`z`&&t.add(r)))}}function Rh(e,t){if(t.type===`FunctionDeclaration`||t.type===`ClassDeclaration`){let n=Sm(Q(t,`id`));n!==void 0&&e.set(n,t)}else if(t.type===`VariableDeclaration`){let n=Z(t.declarations);if(n===void 0)return;for(let t of n){let n=Sm(Q(t,`id`));n!==void 0&&e.set(n,t)}}}function zh(e){if(e.type===`VariableDeclaration`){let t=Z(e.declarations),n=t===void 0?void 0:t[0];return(n===void 0?void 0:Sm(Q(n,`id`)))??`anonymous`}return Sm(Q(e,`id`))??`anonymous`}function Bh(e,t){let n=Sm(Q(e,`local`));if(n===void 0)return;let r=Sm(Q(e,`exported`))??n,i=t.localDeclarations.get(n);if(i!==void 0){let e=Q(i,`init`);return{name:r,form:e===void 0?Fh(i,t):Ph(e,t)}}if(t.importBindings.has(n))return{name:r,form:`reexport`}}function Vh(e,t){return e.type===`FunctionDeclaration`||e.type===`ClassDeclaration`||e.type===`VariableDeclaration`?Fh(e,t):Ph(e,t)}const Hh=/* @__PURE__ */ new Set([`__tests__`,`__mocks__`,`__fixtures__`]),Uh=[`.test.`,`.spec.`,`.d.ts`];function Wh(e){return Uh.some(t=>e.includes(t))}function Gh(e){let t=h(e,`src`);if(!o(t))return[];let n=[],r=(e,t)=>{for(let i of l(e,{withFileTypes:!0})){if(Hh.has(i.name))continue;let a=t===``?i.name:`${t}/${i.name}`;i.isDirectory()?r(h(e,i.name),a):i.isFile()&&(i.name.endsWith(`.ts`)||i.name.endsWith(`.tsx`))&&n.push(`src/${a}`)}};return r(t,``),n}function Kh(e,t){let n=Z(ee(e,{sourceType:`module`,lang:km(t)}).body)??[],r=Ih(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(Q(e,`source`)!==void 0){a(`reexport`,`named-from`);continue}let t=Q(e,`declaration`);if(t!==void 0){a(Fh(t,r),zh(t));continue}let n=Z(e.specifiers);if(n===void 0)continue;for(let e of n){let t=Bh(e,r);t!==void 0&&a(t.form,t.name)}}else if(e.type===`ExportDefaultDeclaration`){let t=Q(e,`declaration`);if(t===void 0){a(`runtime`,`default`);continue}a(Vh(t,r),`default`)}return i}function qh(e){let t=Gh(e).filter(e=>!Wh(e)),n=[],r=!1,i=!1;for(let a of t){let t;try{t=c(h(e,a),`utf8`)}catch{continue}let o;try{o=Kh(t,a.endsWith(`.tsx`))}catch{n.push({file:a,name:`parse-error`,reason:`文件解析失败,无法确认内容,按包含运行时逻辑处理`});continue}let s=o.get(`runtime`);if(s!==void 0)for(let e of s)n.push({file:a,name:e,reason:`这个导出包含运行时逻辑`});o.has(`declarative`)&&(r=!0),(o.has(`thin`)||o.has(`reexport`))&&(i=!0)}return n.length>0?{verdict:`runtime`,runtimeExports:n}:r?{verdict:`declarative`,runtimeExports:[]}:i?{verdict:`facade`,runtimeExports:[]}:{verdict:`pure-type`,runtimeExports:[]}}function Jh(e){let t=e;for(;;){if(yh(t)===`root`)return t;let n=m(t);if(n===t)return e;t=n}}const Yh=/* @__PURE__ */ new Set([`contract`,`main`,`type-only`]),Xh=/* @__PURE__ */ new Set([`contract`,`main`,`docs`,`type-only`,`root`]),Zh=[`src/**/*.test.ts`,`src/**/*.test.tsx`,`__tests__/**/*.test.ts`],Qh=/* @__PURE__ */ new Set([`root`,`contract`,`main`,`docs`,`domain`,`implementation`,`infrastructure`,`api`,`ui`,`capability`,`mcp`,`desktop-host`,`mobile`,`miniprogram`,`package`,`server`,`web`,`desktop`,`cli`]),$h={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 eg(e){let t=e.config?.preset??`custom`,n=e.config?.preset!==void 0,r=mh(g(e.repoRoot,e.packageDir)),i=[];if(Qh.has(t)&&t!==r&&i.push({kind:`preset-layer-mismatch`,details:[ng(t,r)]}),Yh.has(t)){let n=qh(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 ig(e.config,e.packageDir)===0&&!Xh.has(t)&&i.push({kind:`zero-tests-undeclared`,details:[tg(t,n,r)]}),i}function tg(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},请改用 ${$h[n]} 子路径的 defineConfig 声明配置`}function ng(e,t){return t===`non-fixed`?`本包目录没有固定分层,声明的预设是 ${e}。固定分层预设只能用于对应的目录分层。已知合法错配请以基线豁免登记在案可溯,纯类型与声明式内容包请改用 @longzai-intelligence-bun/presets/type-only 子路径的 defineConfig 声明,其余单元请移除预设声明并按 custom 形态履行测试义务`:`本包的目录分层是 ${t},声明的预设却是 ${e}。固定分层预设必须与目录分层一致,custom 与 type-only 不受目录分层约束。请改用 ${$h[t]} 子路径的 defineConfig 声明配置`}async function rg(e){let t=await eg(e);if(t.length===0)return;let n=g(e.repoRoot,e.packageDir),r=Oh(e.repoRoot),i=t.filter(e=>!kh(r,n,e.kind));if(i.length!==0){if(e.strict)throw new hh(e.subject,i);for(let t of i)for(let n of t.details)Y(`警告: ${e.subject} ${n}`)}}async function ig(e,t){let n=e?.test?.include??Zh;if(n.length===Zh.length&&n.every((e,t)=>e===Zh[t]))return ag(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 ag(e){let t=h(e,`src`);if(!o(t))return 0;let n=0,r=e=>{for(let t of l(e,{withFileTypes:!0}))t.isDirectory()?r(h(e,t.name)):(t.isFile()&&t.name.endsWith(`.test.ts`)||t.isFile()&&t.name.endsWith(`.test.tsx`))&&(n+=1)};return r(t),n}const og=async(e=process.cwd())=>{let t=await dm({cwd:e,standaloneFile:`lzi-bun.config.ts`,unifiedField:`bun`});return t.success?t.config:(J(`提示: 未找到配置文件 lzi-bun.config.ts,使用默认配置`),{})};var sg=class extends Error{constructor(e){super(e),this.name=`GlobalsUnresolvedError`}};const cg=e=>`已配置的 globals 定位未能命中(longzai-intelligence-globals),已尝试:\n ${e.join(`
243
+ `)}`),this.name=`TypeOnlyViolationError`,this.details=n}};function gh(e){return e===`exempt-runtime`?`包内代码与声明预设不符`:e===`zero-tests-undeclared`?`包内没有测试,也没有声明允许零测试的预设`:`声明的预设与目录分层不符`}const _h=e=>typeof e==`object`&&!!e&&!Array.isArray(e),vh=e=>Array.isArray(e)||typeof e==`object`&&!!e&&`packages`in e,yh=e=>{let t=h(e,`package.json`);if(!o(t))return`missing-package-json`;let n;try{n=JSON.parse(c(t,`utf8`))}catch{return`not-root`}return _h(n)&&vh(n.workspaces)?`root`:`not-root`},bh=e=>yh(e)===`root`,xh=(e,t)=>{let n=h(e,`package.json`);try{let e=JSON.parse(c(n,`utf8`));if(_h(e)){let t=e.name;if(typeof t==`string`&&t!==``)return t}}catch{}return t},Sh=e=>{let t=e.indexOf(`/`);if(!(!e.startsWith(`@`)||t<=1))return e.slice(1,t)},Ch=`.lzi/baselines/lzi-bun.typeonly.json`,wh=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Th=[`exempt-runtime`,`zero-tests-undeclared`,`preset-layer-mismatch`],Eh=e=>typeof e==`string`&&Th.some(t=>t===e);function Dh(e){return`${e.path}|${e.kind}`}function Oh(e){let t=h(e,Ch);if(!o(t))return/* @__PURE__ */ new Set;try{let e=JSON.parse(c(t,`utf8`));if(!wh(e)||!Array.isArray(e.entries))return/* @__PURE__ */ new Set;let n=/* @__PURE__ */ new Set;for(let t of e.entries)wh(t)&&typeof t.path==`string`&&Eh(t.kind)&&n.add(`${t.path}|${t.kind}`);return n}catch{return/* @__PURE__ */ new Set}}function kh(e,t,n){return e.has(`${t}|${n}`)}function Ah(e,t){let n=[...t].sort((e,t)=>Dh(e)<Dh(t)?-1:+(Dh(e)>Dh(t))),r=h(e,Ch);s(m(r),{recursive:!0}),d(r,`${JSON.stringify({version:1,entries:n},null,2)}\n`,`utf8`)}function jh(e,t){return[...Oh(e)].filter(e=>!t.has(e))}function Mh(e){let t=e.indexOf(`|`),n=Th.find(n=>n===e.slice(t+1));return{path:e.slice(0,t),kind:n??`preset-layer-mismatch`}}function Nh(e,t){let n=Q(e,`callee`);if(n===void 0)return!1;if(Sm(n)===`Symbol`)return!0;if(n.type===`MemberExpression`){let e=Sm(Q(n,`object`));return e!==void 0&&t.zodBindings.has(e)}return!1}function Ph(e,t){if(e.type===`TSAsExpression`||e.type===`TSSatisfiesExpression`){let n=Q(e,`expression`);if(n!==void 0)return Ph(n,t)}if(e.type===`TSInstantiationExpression`){let n=Q(e,`expression`);if(n!==void 0)return Ph(n,t)}return e.type===`CallExpression`?Nh(e,t)?`declarative`:`runtime`:e.type===`ArrowFunctionExpression`?t.isTsx?`runtime`:Om(e)?`thin`:`runtime`:e.type===`Identifier`||Tm(e)?`declarative`:`runtime`}function Fh(e,t){switch(e.type){case`TSTypeAliasDeclaration`:case`TSInterfaceDeclaration`:case`TSModuleDeclaration`:case`TSDeclareFunction`:return`type`;case`TSEnumDeclaration`:return`declarative`;case`ClassDeclaration`:return Dm(e)?`declarative`:`runtime`;case`FunctionDeclaration`:return t.isTsx?`runtime`:Om(e)?`thin`:`runtime`;case`VariableDeclaration`:{let n=Z(e.declarations);if(n===void 0)return`runtime`;let r=`type`;for(let e of n){let n=Q(e,`init`),i=n===void 0?`declarative`:Ph(n,t);if(i===`runtime`)return`runtime`;i!==`type`&&(r=i)}return r}default:return`runtime`}}function Ih(e,t){let n=/* @__PURE__ */ new Set,r=/* @__PURE__ */ new Set,i=/* @__PURE__ */ new Map;for(let t of e){if(t.type===`ImportDeclaration`){Lh(t,n,r);continue}let e=Q(t,`declaration`);t.type===`ExportNamedDeclaration`&&e!==void 0?Rh(i,e):Rh(i,t)}return{zodBindings:n,importBindings:r,localDeclarations:i,isTsx:t}}function Lh(e,t,n){let r=Q(e,`source`),i=r!==void 0&&typeof r.value==`string`?r.value:void 0,a=Z(e.specifiers);if(a!==void 0)for(let e of a){let r=Sm(Q(e,`local`));r!==void 0&&(n.add(r),i===`zod`&&(e.type===`ImportNamespaceSpecifier`&&t.add(r),e.type===`ImportSpecifier`&&Sm(Q(e,`imported`))===`z`&&t.add(r)))}}function Rh(e,t){if(t.type===`FunctionDeclaration`||t.type===`ClassDeclaration`){let n=Sm(Q(t,`id`));n!==void 0&&e.set(n,t)}else if(t.type===`VariableDeclaration`){let n=Z(t.declarations);if(n===void 0)return;for(let t of n){let n=Sm(Q(t,`id`));n!==void 0&&e.set(n,t)}}}function zh(e){if(e.type===`VariableDeclaration`){let t=Z(e.declarations),n=t===void 0?void 0:t[0];return(n===void 0?void 0:Sm(Q(n,`id`)))??`anonymous`}return Sm(Q(e,`id`))??`anonymous`}function Bh(e,t){let n=Sm(Q(e,`local`));if(n===void 0)return;let r=Sm(Q(e,`exported`))??n,i=t.localDeclarations.get(n);if(i!==void 0){let e=Q(i,`init`);return{name:r,form:e===void 0?Fh(i,t):Ph(e,t)}}if(t.importBindings.has(n))return{name:r,form:`reexport`}}function Vh(e,t){return e.type===`FunctionDeclaration`||e.type===`ClassDeclaration`||e.type===`VariableDeclaration`?Fh(e,t):Ph(e,t)}const Hh=/* @__PURE__ */ new Set([`__tests__`,`__mocks__`,`__fixtures__`]),Uh=[`.test.`,`.spec.`,`.d.ts`];function Wh(e){return Uh.some(t=>e.includes(t))}function Gh(e){let t=h(e,`src`);if(!o(t))return[];let n=[],r=(e,t)=>{for(let i of l(e,{withFileTypes:!0})){if(Hh.has(i.name))continue;let a=t===``?i.name:`${t}/${i.name}`;i.isDirectory()?r(h(e,i.name),a):i.isFile()&&(i.name.endsWith(`.ts`)||i.name.endsWith(`.tsx`))&&n.push(`src/${a}`)}};return r(t,``),n}function Kh(e,t){let n=Z(ee(e,{sourceType:`module`,lang:km(t)}).body)??[],r=Ih(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(Q(e,`source`)!==void 0){a(`reexport`,`named-from`);continue}let t=Q(e,`declaration`);if(t!==void 0){a(Fh(t,r),zh(t));continue}let n=Z(e.specifiers);if(n===void 0)continue;for(let e of n){let t=Bh(e,r);t!==void 0&&a(t.form,t.name)}}else if(e.type===`ExportDefaultDeclaration`){let t=Q(e,`declaration`);if(t===void 0){a(`runtime`,`default`);continue}a(Vh(t,r),`default`)}return i}function qh(e){let t=Gh(e).filter(e=>!Wh(e)),n=[],r=!1,i=!1;for(let a of t){let t;try{t=c(h(e,a),`utf8`)}catch{continue}let o;try{o=Kh(t,a.endsWith(`.tsx`))}catch{n.push({file:a,name:`parse-error`,reason:`文件解析失败,无法确认内容,按包含运行时逻辑处理`});continue}let s=o.get(`runtime`);if(s!==void 0)for(let e of s)n.push({file:a,name:e,reason:`这个导出包含运行时逻辑`});o.has(`declarative`)&&(r=!0),(o.has(`thin`)||o.has(`reexport`))&&(i=!0)}return n.length>0?{verdict:`runtime`,runtimeExports:n}:r?{verdict:`declarative`,runtimeExports:[]}:i?{verdict:`facade`,runtimeExports:[]}:{verdict:`pure-type`,runtimeExports:[]}}function Jh(e){let t=e;for(;;){if(yh(t)===`root`)return t;let n=m(t);if(n===t)return e;t=n}}const Yh=/* @__PURE__ */ new Set([`contract`,`main`,`type-only`]),Xh=/* @__PURE__ */ new Set([`contract`,`main`,`docs`,`fumadocs`,`type-only`,`root`]),Zh=[`src/**/*.test.ts`,`src/**/*.test.tsx`,`__tests__/**/*.test.ts`],Qh=/* @__PURE__ */ new Set([`root`,`contract`,`main`,`docs`,`domain`,`implementation`,`infrastructure`,`api`,`ui`,`capability`,`mcp`,`desktop-host`,`mobile`,`miniprogram`,`package`,`server`,`web`,`desktop`,`cli`]),$h={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 eg(e){let t=e.config?.preset??`custom`,n=e.config?.preset!==void 0,r=mh(g(e.repoRoot,e.packageDir)),i=[];if(Qh.has(t)&&t!==r&&i.push({kind:`preset-layer-mismatch`,details:[ng(t,r)]}),Yh.has(t)){let n=qh(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 ig(e.config,e.packageDir)===0&&!Xh.has(t)&&i.push({kind:`zero-tests-undeclared`,details:[tg(t,n,r)]}),i}function tg(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},请改用 ${$h[n]} 子路径的 defineConfig 声明配置`}function ng(e,t){return t===`non-fixed`?`本包目录没有固定分层,声明的预设是 ${e}。固定分层预设只能用于对应的目录分层。已知合法错配请以基线豁免登记在案可溯,纯类型与声明式内容包请改用 @longzai-intelligence-bun/presets/type-only 子路径的 defineConfig 声明,其余单元请移除预设声明并按 custom 形态履行测试义务`:`本包的目录分层是 ${t},声明的预设却是 ${e}。固定分层预设必须与目录分层一致,custom 与 type-only 不受目录分层约束。请改用 ${$h[t]} 子路径的 defineConfig 声明配置`}async function rg(e){let t=await eg(e);if(t.length===0)return;let n=g(e.repoRoot,e.packageDir),r=Oh(e.repoRoot),i=t.filter(e=>!kh(r,n,e.kind));if(i.length!==0){if(e.strict)throw new hh(e.subject,i);for(let t of i)for(let n of t.details)Y(`警告: ${e.subject} ${n}`)}}async function ig(e,t){let n=e?.test?.include??Zh;if(n.length===Zh.length&&n.every((e,t)=>e===Zh[t]))return ag(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 ag(e){let t=h(e,`src`);if(!o(t))return 0;let n=0,r=e=>{for(let t of l(e,{withFileTypes:!0}))t.isDirectory()?r(h(e,t.name)):(t.isFile()&&t.name.endsWith(`.test.ts`)||t.isFile()&&t.name.endsWith(`.test.tsx`))&&(n+=1)};return r(t),n}const og=async(e=process.cwd())=>{let t=await dm({cwd:e,standaloneFile:`lzi-bun.config.ts`,unifiedField:`bun`});return t.success?t.config:(J(`提示: 未找到配置文件 lzi-bun.config.ts,使用默认配置`),{})};var sg=class extends Error{constructor(e){super(e),this.name=`GlobalsUnresolvedError`}};const cg=e=>`已配置的 globals 定位未能命中(longzai-intelligence-globals),已尝试:\n ${e.join(`
244
244
  `)}\n请修正 ${tp} / --globals 的路径,或移除该配置以回落包内预设(LZI_SCOPES)`,lg=e=>{try{return u(e).isDirectory()}catch{return!1}},ug=(e={})=>{let t=process.env[tp],n=[...t!==void 0&&t!==``?[{source:`env`,path:_(t)}]:[],...e.explicitPath===void 0?[]:[{source:`explicit`,path:_(e.explicitPath)}]],r=[];for(let e of n)if(r.push(`${e.source}: ${e.path}`),lg(e.path))return{ok:!0,resolution:{globalsRoot:e.path,source:e.source}};return{ok:!1,failure:{attempted:r}}},dg=RegExp(`^${tp}=.*$`,`m`),fg=`${tp}=/absolute/path/to/longzai-intelligence-globals`,pg=(e,t)=>{let n=h(e,`.env`),r=`${tp}=${t}`;if(o(n)){let e=c(n,`utf8`);if(dg.test(e)){let t=e.replace(dg,r);t!==e&&d(n,t,`utf8`)}else{let t=e.endsWith(`
245
245
  `)||e.length===0?e:`${e}\n`;d(n,`${t}${r}\n`,`utf8`)}}else d(n,`${r}\n`,`utf8`);let i=h(e,`.env.example`);if(o(i)){let e=c(i,`utf8`);if(!e.includes(`LZI_GLOBALS_ROOT=`)){let t=e.endsWith(`
246
246
  `)||e.length===0?e:`${e}\n`;d(i,`${t}${fg}\n`,`utf8`)}}else d(i,`${fg}\n`,`utf8`)},mg=async e=>hp((await tm(h(e,`lzi-bun-install.config.ts`))).config),hg=async(e={})=>{let t=ug({explicitPath:e.explicitPath});if(t.ok)return{presetScopes:await mg(t.resolution.globalsRoot),source:`globals`};if(t.failure.attempted.length===0)return{presetScopes:Object.fromEntries($f),source:`preset`};throw new sg(cg(t.failure.attempted))},gg=/* @__PURE__ */ new Set([`extraScopes`,`privateScopes`,`linker`,`globalStore`]);function _g(e){if(typeof e!=`object`||!e||Array.isArray(e))throw Error(`lzi-bun.config.ts 的 install 声明须为对象`);for(let t of Object.keys(e))if(!gg.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 vg=[`src/**/*.test.ts`,`src/**/*.test.tsx`,`__tests__/**/*.test.ts`];function yg(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}function bg(e,n=t()){return e?{enabled:!1,reason:`watch 为长驻会话,跳过内存护栏`}:n===`darwin`?{enabled:!0}:{enabled:!1,reason:`非 darwin 平台无 /usr/bin/time -l,跳过内存护栏`}}function xg(e,t){return t?[`/usr/bin/time`,`-l`,...e]:[...e]}async function Sg(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 Cg=(e,t,n)=>{let r=e.split(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longzai-intelligence-bun/cli",
3
- "version": "0.1.14",
3
+ "version": "0.1.15",
4
4
  "description": "Longzai Intelligence Bun 工具集 CLI",
5
5
  "keywords": [
6
6
  "bun",
@@ -38,8 +38,8 @@
38
38
  "clean": "lzi-dev-tools clean"
39
39
  },
40
40
  "dependencies": {
41
- "@longzai-intelligence-bun/config": "0.1.14",
42
- "@longzai-intelligence-bun/presets": "0.1.14",
41
+ "@longzai-intelligence-bun/config": "0.1.15",
42
+ "@longzai-intelligence-bun/presets": "0.1.15",
43
43
  "@longzai-intelligence-cli/core": "^0.0.18",
44
44
  "@longzai-intelligence-cli/standard": "^0.0.18",
45
45
  "@longzai-intelligence-error/utils": "^0.2.0",