@longzai-intelligence-dependencies/cli 0.0.16 → 0.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +3 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -159,7 +159,7 @@ Expecting one of '${n.join(`', '`)}'`);return this._lifeCycleHooks[e]?this._life
159
159
  - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
160
160
  - ${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 a=!1,s=[`.js`,`.ts`,`.tsx`,`.mjs`,`.cjs`];function c(e,t){let n=r.resolve(e,t);if(i.existsSync(n))return n;if(s.includes(r.extname(t)))return;let a=s.find(e=>i.existsSync(`${n}${e}`));if(a)return`${n}${a}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let u=e._executableFile||`${this._name}-${e._name}`,d=this._executableDir||``;if(this._scriptPath){let e;try{e=i.realpathSync(this._scriptPath)}catch{e=this._scriptPath}d=r.resolve(r.dirname(e),d)}if(d){let t=c(d,u);if(!t&&!e._executableFile&&this._scriptPath){let n=r.basename(this._scriptPath,r.extname(this._scriptPath));n!==this._name&&(t=c(d,`${n}-${e._name}`))}u=t||u}a=s.includes(r.extname(u));let f;o.platform===`win32`?(this._checkForMissingExecutable(u,d,e._name),t.unshift(u),t=g(o.execArgv).concat(t),f=n.spawn(o.execPath,t,{stdio:`inherit`})):a?(t.unshift(u),t=g(o.execArgv).concat(t),f=n.spawn(o.argv[0],t,{stdio:`inherit`})):f=n.spawn(u,t,{stdio:`inherit`}),f.killed||[`SIGUSR1`,`SIGUSR2`,`SIGTERM`,`SIGINT`,`SIGHUP`].forEach(e=>{o.on(e,()=>{f.killed===!1&&f.exitCode===null&&f.kill(e)})});let p=this._exitCallback;f.on(`close`,e=>{e??=1,p?p(new l(e,`commander.executeSubCommandAsync`,`(close)`)):o.exit(e)}),f.on(`error`,t=>{if(t.code===`ENOENT`)this._checkForMissingExecutable(u,d,e._name);else if(t.code===`EACCES`)throw Error(`'${u}' not executable`);if(!p)o.exit(1);else{let e=new l(1,`commander.executeSubCommandAsync`,`(error)`);e.nestedError=t,p(e)}}),this.runningCommand=f}_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+)(e[+-]?\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(`
161
161
  `),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 o.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()}`,o.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new p(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=m(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=`error: too many arguments${this.parent?` for '${this.name()}'`:``}. Expected ${t} argument${n} but got ${e.length}.`;this.error(r,{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=m(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=>c(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=r.basename(e,r.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(o.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.
162
- 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 g(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)?)$/))===null?(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))===null?(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\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 _(){if(o.env.NO_COLOR||o.env.FORCE_COLOR===`0`||o.env.FORCE_COLOR===`false`)return!1;if(o.env.FORCE_COLOR||o.env.CLICOLOR_FORCE!==void 0)return!0}e.Command=h,e.useColor=_}));const{program:xd,createCommand:Sd,createArgument:Cd,createOption:wd,CommanderError:Td,InvalidArgumentError:Ed,InvalidOptionArgumentError:Dd,Command:Od,Argument:kd,Option:Ad,Help:jd}=(/* @__PURE__ */ t((/* @__PURE__ */ n((e=>{let{Argument:t}=gd(),{Command:n}=bd(),{CommanderError:r,InvalidArgumentError:i}=hd(),{Help:a}=_d(),{Option:o}=vd();e.program=new n,e.createCommand=e=>new n(e),e.createOption=(e,t)=>new o(e,t),e.createArgument=(e,n)=>new t(e,n),e.Command=n,e.Option=o,e.Argument=t,e.Help=a,e.CommanderError=r,e.InvalidArgumentError=i,e.InvalidOptionArgumentError=i})))(),1)).default;let Md;function Nd(){return Md??=md(`@longzai-intelligence-cli/core/provider`),Md}const Pd={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 Fd={select:async(e,t)=>t[0]?.value??``,textInput:async(e,t)=>t?.defaultValue??``,confirm:async(e,t)=>t?.defaultValue??!1,spinner:()=>({start:e=>Nd().info(e),stop:e=>Nd().info(e)}),note:(e,t)=>{t?Nd().info(`${t}: ${e}`):Nd().info(e)},log:{info:e=>Nd().info(e),success:e=>Nd().info(e),warn:e=>Nd().warn(e),error:e=>Nd().error(e),step:e=>Nd().info(e)}},Id=Pd;function Ld(e){Fd=e}function Rd(e){Id=e}function zd(){return Fd}function Bd(){return Id}const Vd=()=>`0.0.16`;function Hd(e){let t=e.version??Vd();e.interaction&&Ld(e.interaction),e.color&&Rd(e.color);let n=new Od;return n.name(e.name).version(t,`-v, --version`,`输出 ${e.name} 的版本号`),e.description&&n.description(e.description),n}let Ud;function Wd(){return Ud??=md(`@longzai-intelligence-cli/core/define-command`),Ud}function Gd(e,t){let n=e.commands.find(e=>e.name()===t);return n===void 0?e.command(t):n}function Kd(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=Gd(e,n);for(let e of r)a=Gd(a,e);return a.command(i)}function qd(e,t){let n=Kd(e,t.name.split(` `).filter(e=>e.length>0));t.description&&n.description(t.description);for(let e of t.arguments??[])e.description?n.argument(e.signature,e.description):n.argument(e.signature);for(let e of t.options??[])e.defaultValue===void 0?n.option(e.flags,e.description??``):n.option(e.flags,e.description??``,e.defaultValue);n.action(async(...e)=>{let n=e[e.length-1];if(!(n instanceof Od))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(`, `);Wd().error(Bd().red(`参数校验失败: ${e}`)),zd().log.error(`参数校验失败: ${e}`),process.exit(1)}await t.action(a.data,i)})}var Jd=/* @__PURE__ */ T(import.meta.url);function Yd(e){let t=b(e);return t.length>1&&t[t.length-1]===w&&(t=t.substring(0,t.length-1)),t}const Xd=/[\\/]/g;function Zd(e,t){return e.replace(Xd,t)}const Qd=/^[a-z]:[\\/]$/i;function $d(e){return e===`/`||Qd.test(e)}function ef(e,t){let{resolvePaths:n,normalizePath:r,pathSeparator:i}=t,a=process.platform===`win32`&&e.includes(`/`)||e.startsWith(`.`);return n&&(e=C(e)),(r||a)&&(e=Yd(e)),e===`.`?``:Zd(e[e.length-1]===i?e:e+i,i)}function tf(e,t){return t+e}function nf(e,t){return function(n,r){return r.startsWith(e)?r.slice(e.length)+n:Zd(S(e,r),t.pathSeparator)+t.pathSeparator+n}}function rf(e){return e}function af(e,t,n){return t+e+n}function of(e,t){let{relativePaths:n,includeBasePath:r}=t;return n&&e?nf(e,t):r?tf:rf}function sf(e){return function(t,n){n.push(t.substring(e.length)||`.`)}}function cf(e){return function(t,n,r){let i=t.substring(e.length)||`.`;r.every(e=>e(i,!0))&&n.push(i)}}const lf=(e,t)=>{t.push(e||`.`)},uf=(e,t,n)=>{let r=e||`.`;n.every(e=>e(r,!0))&&t.push(r)},df=()=>{};function ff(e,t){let{includeDirs:n,filters:r,relativePaths:i}=t;return n?i?r&&r.length?cf(e):sf(e):r&&r.length?uf:lf:df}const pf=(e,t,n,r)=>{r.every(t=>t(e,!1))&&n.files++},mf=(e,t,n,r)=>{r.every(t=>t(e,!1))&&t.push(e)},hf=(e,t,n,r)=>{n.files++},gf=(e,t)=>{t.push(e)},_f=()=>{};function vf(e){let{excludeFiles:t,filters:n,onlyCounts:r}=e;return t?_f:n&&n.length?r?pf:mf:r?hf:gf}const yf=e=>e,bf=()=>[``].slice(0,0);function xf(e){return e.group?bf:yf}const Sf=(e,t,n)=>{e.push({directory:t,files:n,dir:t})},Cf=()=>{};function wf(e){return e.group?Sf:Cf}const Tf=function(e,t,n){let{queue:r,fs:i,options:{suppressErrors:a}}=t;r.enqueue(),i.realpath(e,(o,s)=>{if(o)return r.dequeue(a?null:o,t);i.stat(s,(i,o)=>{if(i)return r.dequeue(a?null:i,t);if(o.isDirectory()&&Of(e,s,t))return r.dequeue(null,t);n(o,s),r.dequeue(null,t)})})},Ef=function(e,t,n){let{queue:r,fs:i,options:{suppressErrors:a}}=t;r.enqueue();try{let r=i.realpathSync(e),a=i.statSync(r);if(a.isDirectory()&&Of(e,r,t))return;n(a,r)}catch(e){if(!a)throw e}};function Df(e,t){return!e.resolveSymlinks||e.excludeSymlinks?null:t?Ef:Tf}function Of(e,t,n){if(n.options.useRealPaths)return kf(t,n);let r=v(e),i=1;for(;r!==n.root&&i<2;){let e=n.symlinks.get(r);e&&(e===t||e.startsWith(t)||t.startsWith(e))?i++:r=v(r)}return n.symlinks.set(e,t),i>1}function kf(e,t){return t.visited.includes(e+t.options.pathSeparator)}const Af=e=>e.counts,jf=e=>e.groups,Mf=e=>e.paths,Nf=e=>e.paths.slice(0,e.options.maxFiles),Pf=(e,t,n)=>(Rf(t,n,e.counts,e.options.suppressErrors),null),Ff=(e,t,n)=>(Rf(t,n,e.paths,e.options.suppressErrors),null),If=(e,t,n)=>(Rf(t,n,e.paths.slice(0,e.options.maxFiles),e.options.suppressErrors),null),Lf=(e,t,n)=>(Rf(t,n,e.groups,e.options.suppressErrors),null);function Rf(e,t,n,r){t(e&&!r?e:null,n)}function zf(e,t){let{onlyCounts:n,group:r,maxFiles:i}=e;return n?t?Af:Pf:r?t?jf:Lf:i?t?Nf:If:t?Mf:Ff}const Bf={withFileTypes:!0},Vf=(e,t,n,r,i)=>{if(e.queue.enqueue(),r<0)return e.queue.dequeue(null,e);let{fs:a}=e;e.visited.push(t),e.counts.directories++,a.readdir(t||`.`,Bf,(t,a=[])=>{i(a,n,r),e.queue.dequeue(e.options.suppressErrors?null:t,e)})},Hf=(e,t,n,r,i)=>{let{fs:a}=e;if(r<0)return;e.visited.push(t),e.counts.directories++;let o=[];try{o=a.readdirSync(t||`.`,Bf)}catch(t){if(!e.options.suppressErrors)throw t}i(o,n,r)};function Uf(e){return e?Hf:Vf}var Wf=class{count=0;constructor(e){this.onQueueEmpty=e}enqueue(){return this.count++,this.count}dequeue(e,t){this.onQueueEmpty&&(--this.count<=0||e)&&(this.onQueueEmpty(e,t),e&&(t.controller.abort(),this.onQueueEmpty=void 0))}},Gf=class{_files=0;_directories=0;set files(e){this._files=e}get files(){return this._files}set directories(e){this._directories=e}get directories(){return this._directories}
162
+ 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 g(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)?)$/))===null?(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))===null?(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\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 _(){if(o.env.NO_COLOR||o.env.FORCE_COLOR===`0`||o.env.FORCE_COLOR===`false`)return!1;if(o.env.FORCE_COLOR||o.env.CLICOLOR_FORCE!==void 0)return!0}e.Command=h,e.useColor=_}));const{program:xd,createCommand:Sd,createArgument:Cd,createOption:wd,CommanderError:Td,InvalidArgumentError:Ed,InvalidOptionArgumentError:Dd,Command:Od,Argument:kd,Option:Ad,Help:jd}=(/* @__PURE__ */ t((/* @__PURE__ */ n((e=>{let{Argument:t}=gd(),{Command:n}=bd(),{CommanderError:r,InvalidArgumentError:i}=hd(),{Help:a}=_d(),{Option:o}=vd();e.program=new n,e.createCommand=e=>new n(e),e.createOption=(e,t)=>new o(e,t),e.createArgument=(e,n)=>new t(e,n),e.Command=n,e.Option=o,e.Argument=t,e.Help=a,e.CommanderError=r,e.InvalidArgumentError=i,e.InvalidOptionArgumentError=i})))(),1)).default;let Md;function Nd(){return Md??=md(`@longzai-intelligence-cli/core/provider`),Md}const Pd={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 Fd={select:async(e,t)=>t[0]?.value??``,textInput:async(e,t)=>t?.defaultValue??``,confirm:async(e,t)=>t?.defaultValue??!1,spinner:()=>({start:e=>Nd().info(e),stop:e=>Nd().info(e)}),note:(e,t)=>{t?Nd().info(`${t}: ${e}`):Nd().info(e)},log:{info:e=>Nd().info(e),success:e=>Nd().info(e),warn:e=>Nd().warn(e),error:e=>Nd().error(e),step:e=>Nd().info(e)}},Id=Pd;function Ld(e){Fd=e}function Rd(e){Id=e}function zd(){return Fd}function Bd(){return Id}const Vd=()=>`0.0.17`;function Hd(e){let t=e.version??Vd();e.interaction&&Ld(e.interaction),e.color&&Rd(e.color);let n=new Od;return n.name(e.name).version(t,`-v, --version`,`输出 ${e.name} 的版本号`),e.description&&n.description(e.description),n}let Ud;function Wd(){return Ud??=md(`@longzai-intelligence-cli/core/define-command`),Ud}function Gd(e,t){let n=e.commands.find(e=>e.name()===t);return n===void 0?e.command(t):n}function Kd(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=Gd(e,n);for(let e of r)a=Gd(a,e);return a.command(i)}function qd(e,t){let n=Kd(e,t.name.split(` `).filter(e=>e.length>0));t.description&&n.description(t.description);for(let e of t.arguments??[])e.description?n.argument(e.signature,e.description):n.argument(e.signature);for(let e of t.options??[])e.defaultValue===void 0?n.option(e.flags,e.description??``):n.option(e.flags,e.description??``,e.defaultValue);n.action(async(...e)=>{let n=e[e.length-1];if(!(n instanceof Od))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(`, `);Wd().error(Bd().red(`参数校验失败: ${e}`)),zd().log.error(`参数校验失败: ${e}`),process.exit(1)}await t.action(a.data,i)})}var Jd=/* @__PURE__ */ T(import.meta.url);function Yd(e){let t=b(e);return t.length>1&&t[t.length-1]===w&&(t=t.substring(0,t.length-1)),t}const Xd=/[\\/]/g;function Zd(e,t){return e.replace(Xd,t)}const Qd=/^[a-z]:[\\/]$/i;function $d(e){return e===`/`||Qd.test(e)}function ef(e,t){let{resolvePaths:n,normalizePath:r,pathSeparator:i}=t,a=process.platform===`win32`&&e.includes(`/`)||e.startsWith(`.`);return n&&(e=C(e)),(r||a)&&(e=Yd(e)),e===`.`?``:Zd(e[e.length-1]===i?e:e+i,i)}function tf(e,t){return t+e}function nf(e,t){return function(n,r){return r.startsWith(e)?r.slice(e.length)+n:Zd(S(e,r),t.pathSeparator)+t.pathSeparator+n}}function rf(e){return e}function af(e,t,n){return t+e+n}function of(e,t){let{relativePaths:n,includeBasePath:r}=t;return n&&e?nf(e,t):r?tf:rf}function sf(e){return function(t,n){n.push(t.substring(e.length)||`.`)}}function cf(e){return function(t,n,r){let i=t.substring(e.length)||`.`;r.every(e=>e(i,!0))&&n.push(i)}}const lf=(e,t)=>{t.push(e||`.`)},uf=(e,t,n)=>{let r=e||`.`;n.every(e=>e(r,!0))&&t.push(r)},df=()=>{};function ff(e,t){let{includeDirs:n,filters:r,relativePaths:i}=t;return n?i?r&&r.length?cf(e):sf(e):r&&r.length?uf:lf:df}const pf=(e,t,n,r)=>{r.every(t=>t(e,!1))&&n.files++},mf=(e,t,n,r)=>{r.every(t=>t(e,!1))&&t.push(e)},hf=(e,t,n,r)=>{n.files++},gf=(e,t)=>{t.push(e)},_f=()=>{};function vf(e){let{excludeFiles:t,filters:n,onlyCounts:r}=e;return t?_f:n&&n.length?r?pf:mf:r?hf:gf}const yf=e=>e,bf=()=>[``].slice(0,0);function xf(e){return e.group?bf:yf}const Sf=(e,t,n)=>{e.push({directory:t,files:n,dir:t})},Cf=()=>{};function wf(e){return e.group?Sf:Cf}const Tf=function(e,t,n){let{queue:r,fs:i,options:{suppressErrors:a}}=t;r.enqueue(),i.realpath(e,(o,s)=>{if(o)return r.dequeue(a?null:o,t);i.stat(s,(i,o)=>{if(i)return r.dequeue(a?null:i,t);if(o.isDirectory()&&Of(e,s,t))return r.dequeue(null,t);n(o,s),r.dequeue(null,t)})})},Ef=function(e,t,n){let{queue:r,fs:i,options:{suppressErrors:a}}=t;r.enqueue();try{let r=i.realpathSync(e),a=i.statSync(r);if(a.isDirectory()&&Of(e,r,t))return;n(a,r)}catch(e){if(!a)throw e}};function Df(e,t){return!e.resolveSymlinks||e.excludeSymlinks?null:t?Ef:Tf}function Of(e,t,n){if(n.options.useRealPaths)return kf(t,n);let r=v(e),i=1;for(;r!==n.root&&i<2;){let e=n.symlinks.get(r);e&&(e===t||e.startsWith(t)||t.startsWith(e))?i++:r=v(r)}return n.symlinks.set(e,t),i>1}function kf(e,t){return t.visited.includes(e+t.options.pathSeparator)}const Af=e=>e.counts,jf=e=>e.groups,Mf=e=>e.paths,Nf=e=>e.paths.slice(0,e.options.maxFiles),Pf=(e,t,n)=>(Rf(t,n,e.counts,e.options.suppressErrors),null),Ff=(e,t,n)=>(Rf(t,n,e.paths,e.options.suppressErrors),null),If=(e,t,n)=>(Rf(t,n,e.paths.slice(0,e.options.maxFiles),e.options.suppressErrors),null),Lf=(e,t,n)=>(Rf(t,n,e.groups,e.options.suppressErrors),null);function Rf(e,t,n,r){t(e&&!r?e:null,n)}function zf(e,t){let{onlyCounts:n,group:r,maxFiles:i}=e;return n?t?Af:Pf:r?t?jf:Lf:i?t?Nf:If:t?Mf:Ff}const Bf={withFileTypes:!0},Vf=(e,t,n,r,i)=>{if(e.queue.enqueue(),r<0)return e.queue.dequeue(null,e);let{fs:a}=e;e.visited.push(t),e.counts.directories++,a.readdir(t||`.`,Bf,(t,a=[])=>{i(a,n,r),e.queue.dequeue(e.options.suppressErrors?null:t,e)})},Hf=(e,t,n,r,i)=>{let{fs:a}=e;if(r<0)return;e.visited.push(t),e.counts.directories++;let o=[];try{o=a.readdirSync(t||`.`,Bf)}catch(t){if(!e.options.suppressErrors)throw t}i(o,n,r)};function Uf(e){return e?Hf:Vf}var Wf=class{count=0;constructor(e){this.onQueueEmpty=e}enqueue(){return this.count++,this.count}dequeue(e,t){this.onQueueEmpty&&(--this.count<=0||e)&&(this.onQueueEmpty(e,t),e&&(t.controller.abort(),this.onQueueEmpty=void 0))}},Gf=class{_files=0;_directories=0;set files(e){this._files=e}get files(){return this._files}set directories(e){this._directories=e}get directories(){return this._directories}
163
163
  /* c8 ignore next 3 */
164
164
  get dirs(){return this._directories}},Kf=class{aborted=!1;abort(){this.aborted=!0}},qf=class{root;isSynchronous;state;joinPath;pushDirectory;pushFile;getArray;groupFiles;resolveSymlink;walkDirectory;callbackInvoker;constructor(e,t,n){this.isSynchronous=!n,this.callbackInvoker=zf(t,this.isSynchronous),this.root=ef(e,t),this.state={root:$d(this.root)?this.root:this.root.slice(0,-1),paths:[``].slice(0,0),groups:[],counts:new Gf,options:t,queue:new Wf((e,t)=>this.callbackInvoker(t,e,n)),symlinks:/* @__PURE__ */ new Map,visited:[``].slice(0,0),controller:new Kf,fs:t.fs||u},this.joinPath=of(this.root,t),this.pushDirectory=ff(this.root,t),this.pushFile=vf(t),this.getArray=xf(t),this.groupFiles=wf(t),this.resolveSymlink=Df(t,this.isSynchronous),this.walkDirectory=Uf(this.isSynchronous)}start(){return this.pushDirectory(this.root,this.state.paths,this.state.options.filters),this.walkDirectory(this.state,this.root,this.root,this.state.options.maxDepth,this.walk),this.isSynchronous?this.callbackInvoker(this.state,null):null}walk=(e,t,n)=>{let{paths:r,options:{filters:i,resolveSymlinks:a,excludeSymlinks:o,exclude:s,maxFiles:c,signal:l,useRealPaths:u,pathSeparator:d},controller:f}=this.state;if(f.aborted||l&&l.aborted||c&&r.length>c)return;let p=this.getArray(this.state.paths);for(let c=0;c<e.length;++c){let l=e[c];if(l.isFile()||l.isSymbolicLink()&&!a&&!o){let e=this.joinPath(l.name,t);this.pushFile(e,p,this.state.counts,i)}else if(l.isDirectory()){let e=af(l.name,t,this.state.options.pathSeparator);if(s&&s(l.name,e))continue;this.pushDirectory(e,r,i),this.walkDirectory(this.state,e,e,n-1,this.walk)}else if(this.resolveSymlink&&l.isSymbolicLink()){let e=tf(l.name,t);this.resolveSymlink(e,this.state,(t,r)=>{if(t.isDirectory()){if(r=ef(r,this.state.options),s&&s(l.name,u?r:e+d))return;this.walkDirectory(this.state,r,u?r:e+d,n-1,this.walk)}else{r=u?r:e;let t=_(r),n=ef(v(r),this.state.options);r=this.joinPath(t,n),this.pushFile(r,p,this.state.counts,i)}})}}this.groupFiles(this.state.groups,t,p)}};function Jf(e,t){return new Promise((n,r)=>{Yf(e,t,(e,t)=>{if(e)return r(e);n(t)})})}function Yf(e,t,n){new qf(e,t,n).start()}function Xf(e,t){return new qf(e,t).start()}var Zf=class{constructor(e,t){this.root=e,this.options=t}withPromise(){return Jf(this.root,this.options)}withCallback(e){Yf(this.root,this.options,e)}sync(){return Xf(this.root,this.options)}};let Qf=null;
165
165
  /* c8 ignore next 6 */
@@ -322,7 +322,7 @@ n?this.stack.push(n):(yield*this.pop(),yield*this.step())}else{let t=this.peek(2
322
322
  --- 领域目录形态 ---`);let n=j(e,`domains`);if(!E(n))return $(`未发现 domains 目录,本段跳过`),0;let r=0,i=0;for(let e of A(n,{withFileTypes:!0})){if(!e.isDirectory())continue;r+=1;let a=A(j(n,e.name),{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>e.name);for(let n of a){if(TC.includes(n))continue;let r=`${e.name}/${n}`;t.has(r)||(i+=1,$(` ${e.name} ${r}`))}}return $(`扫描到 ${r} 个领域目录`),i===0?($(`全部领域目录层名合规`),0):($(`共 ${i} 处领域目录层名不合规`),i)},jC=[`electron`,`electron-vite`,`@longzai-intelligence-electron/*`],MC=`@longzai-intelligence-electron/cli`,NC=[`lzi-electron`,`electron-vite`],PC=[`electron-vite`],FC=(e,t)=>{if(t.endsWith(`/*`)){let n=t.slice(0,-1);return e.startsWith(n)}return e===t},IC=(e,t)=>{let n=[];for(let[r,i]of Object.entries(e)){if(t.has(r))continue;let e=jC.find(e=>FC(r,e));e!==void 0&&n.push({dependency:r,rootRange:i,pattern:e})}return n},LC=(e,t)=>{let n=[];for(let[r,i]of Object.entries(t??{}))for(let t of NC)i.includes(t)&&n.push({relPath:e,detail:`脚本 ${r} 含 ${t}`});return n},RC=e=>{let t=e??{};return PC.some(e=>t[e]!==void 0)},zC=e=>(e??{})[MC]!==void 0,BC=vc({name:U().optional(),workspaces:fc().optional(),scripts:Oc(U(),U()).optional(),devDependencies:Oc(U(),U()).optional()}),VC=async()=>{let e=process.cwd();$(`正在扫描 ${e} 下的 package.json 文件...`);let t=null;try{let n=BC.safeParse(await Bun.file(`${e}/package.json`).json());t=n.success?n.data:null}catch{t=null}t===null&&($(`未找到可解析的 workspace 根 package.json,请在仓库根目录执行本命令`),process.exit(1));let n=await bC(),r=SC(n.hoisting?.ignorePaths),i=new Set(n.hoisting?.allowlist??[]),a=new Set(n.hoisting?.rootAllowlist??[]),o=t.devDependencies??{},s=await Pp(`**/package.json`,{cwd:e,ignore:r,onlyFiles:!0,dot:!1}),c=0,l=[],u=[...LC(`package.json`,t.scripts),...RC(t.devDependencies)?[{relPath:`package.json`,detail:`开发依赖 electron-vite`}]:[]],d=zC(t.devDependencies);for(let t of s){if(t===`package.json`)continue;let n=null;try{let r=BC.safeParse(await Bun.file(`${e}/${t}`).json());n=r.success?r.data:null}catch{n=null}if(n===null||n.workspaces!==void 0)continue;let r=n.devDependencies??{};if(u.push(...LC(t,n.scripts)),RC(r)&&u.push({relPath:t,detail:`开发依赖 electron-vite`}),zC(r)&&(d=!0),Object.keys(r).length!==0){c+=1;for(let[a,s]of Object.entries(r)){let r=o[a];r===void 0||i.has(a)||l.push({packageName:n.name??t,relPath:re(e,`${e}/${t}`),dependency:a,subRange:s,rootRange:r,drifted:s!==r})}}}$(`找到 ${c} 个子包,根声明开发依赖 ${Object.keys(o).length} 项`);let f=l.length;if(f===0)$(`所有子包均未重复声明根已有的开发依赖`);else{$(`
323
323
  以下子包重复声明根已有的开发依赖:`);for(let e of l){let t=e.drifted?` 版本漂移`:``;$(` ${e.packageName} ${e.relPath}`),$(` ${e.dependency} 子声明 ${e.subRange} 根声明 ${e.rootRange}${t}`)}$(`共 ${f} 处重复声明,处置口径见 ADR 0036`)}let p=IC(o,a);if(p.length>0){$(`
324
324
  以下 workspace 根声明了技术栈专属依赖,判定口径 ADR 0036 第 3 节:`);for(let e of p)$(` ${e.dependency} 根声明 ${e.rootRange} 命中禁入模式 ${e.pattern}`);$(`共 ${p.length} 处根禁入声明,处置口径:迁移至栈子包 devDependencies 或径直移除`)}let m=u.length>0&&!d;if(m){$(`\n仓内存在 electron 构建面痕迹但全仓未声明 ${MC}:`);for(let e of u)$(` ${e.relPath} ${e.detail}`);$(`处置口径:在栈子包 devDependencies 声明 ${MC}`)}f+p.length+ +!!m!==0&&($(`\n归位汇总: 重复声明 ${f} 处,根禁入 ${p.length} 处,栈引擎缺失 ${+!!m} 项`),process.exit(1))},HC=vc({name:U().optional(),overrides:Oc(U(),fc()).optional(),pnpm:vc({overrides:Oc(U(),fc()).optional()}).optional(),resolutions:Oc(U(),fc()).optional()}),UC=e=>typeof e==`string`?e:`嵌套对象`,WC=async()=>{let e=process.cwd();$(`正在扫描 ${e} 下的 package.json 文件...`);let t=null;try{let n=HC.safeParse(await Bun.file(`${e}/package.json`).json());t=n.success?n.data:null}catch{t=null}t===null&&($(`未找到可解析的仓库根 package.json,请在仓库根目录执行本命令`),process.exit(1));let n=await bC(),r=SC(n.overrides?.ignorePaths),i=new Set(n.overrides?.allowlist??[]),a=await Pp(`**/package.json`,{cwd:e,ignore:r,onlyFiles:!0,dot:!1}),o=0,s=[];for(let t of a){let n=null;try{let r=HC.safeParse(await Bun.file(`${e}/${t}`).json());n=r.success?r.data:null}catch{n=null}if(n===null)continue;o+=1;let r=[[`overrides`,n.overrides??{}],[`pnpm.overrides`,n.pnpm?.overrides??{}],[`resolutions`,n.resolutions??{}]];for(let[a,o]of r)for(let[r,c]of Object.entries(o))i.has(r)||s.push({packageName:n.name??t,relPath:re(e,`${e}/${t}`),field:a,entry:r,value:UC(c)})}if($(`扫描到 ${o} 个清单,登记豁免条目 ${i.size} 项`),s.length===0)$(`全部清单均未声明未豁免的 overrides 族强制版本字段`);else{$(`
325
- 以下清单声明了未豁免的 overrides 族强制版本字段:`);for(let e of s)$(` ${e.packageName} ${e.relPath}`),$(` ${e.field} ${e.entry} ${e.value}`);$(`共 ${s.length} 处强制版本条目,处置口径见 ADR 0153,豁免须经特别申请登记于 lzi-dependencies.config.ts 的 overrides.allowlist`),process.exit(1)}},GC=(e,t)=>{let n=e.filter(e=>e.relativePath.startsWith(`apps/`));if(n.length===0)return{inScope:!1,violations:[]};let r=[];for(let e of n){let n=e.name??e.relativePath;if(t.has(n))continue;let i=Object.keys(e.exports??{}).filter(e=>e!==`.`);i.length!==0&&r.push({packageName:n,relPath:e.relativePath,extraExits:i})}return{inScope:!0,violations:r}},KC=/* @__PURE__ */ new Set(/* @__PURE__ */ `@longzai-intelligence-agent-tools/cli.@longzai-intelligence-agent-tools/config.@longzai-intelligence-api/cli.@longzai-intelligence-api/config.@longzai-intelligence-api/core.@longzai-intelligence-builder/cli.@longzai-intelligence-builder/config.@longzai-intelligence-builder/core.@longzai-intelligence-builder/dual.@longzai-intelligence-builder/esm.@longzai-intelligence-builder/utils.@longzai-intelligence-bun/cli.@longzai-intelligence-bun/config.@longzai-intelligence-bun/presets.@longzai-intelligence-changelog/cli.@longzai-intelligence-changelog/config.@longzai-intelligence-decision/cli.@longzai-intelligence-decision/config.@longzai-intelligence-debts/cli.@longzai-intelligence-debts/config.@longzai-intelligence-dependencies/cli.@longzai-intelligence-dependencies/config.@longzai-intelligence-dev-tools/cli.@longzai-intelligence-dev-tools/config.@longzai-intelligence-dev-tools/vite-plugin.@longzai-intelligence-env/cli.@longzai-intelligence-env/config.@longzai-intelligence-env/core.@longzai-intelligence-features/cli.@longzai-intelligence-features/config.@longzai-intelligence-features/ledger.@longzai-intelligence-globals/cli.@longzai-intelligence-git/cli.@longzai-intelligence-git/config.@longzai-intelligence-issues/cli.@longzai-intelligence-issues/config.@longzai-intelligence-ledger/cli.@longzai-intelligence-ledger/config.@longzai-intelligence-ledger/core.@longzai-intelligence-markdown/cli.@longzai-intelligence-markdown/config.@longzai-intelligence-oxfmt/config.@longzai-intelligence-oxlint/architecture-core-plugin.@longzai-intelligence-oxlint/architecture-domain-plugin.@longzai-intelligence-oxlint/architecture-electron-plugin.@longzai-intelligence-oxlint/architecture-library-plugin.@longzai-intelligence-oxlint/architecture-plugin.@longzai-intelligence-oxlint/cli.@longzai-intelligence-oxlint/code-style-plugin.@longzai-intelligence-oxlint/composer-plugin.@longzai-intelligence-oxlint/core.@longzai-intelligence-oxlint/design-rules-plugin.@longzai-intelligence-oxlint/elysia-route-plugin.@longzai-intelligence-oxlint/eslint-config-plugin.@longzai-intelligence-oxlint/file-naming-plugin.@longzai-intelligence-oxlint/lzi-builder-config-plugin.@longzai-intelligence-oxlint/lzi-config-plugin.@longzai-intelligence-oxlint/nestjs-route-plugin.@longzai-intelligence-oxlint/oxlint-config.@longzai-intelligence-oxlint/package-json-plugin.@longzai-intelligence-oxlint/perfectionist-plugin.@longzai-intelligence-oxlint/presets.@longzai-intelligence-oxlint/react-plugin.@longzai-intelligence-oxlint/schema-type-separation-plugin.@longzai-intelligence-oxlint/stylistic-plugin.@longzai-intelligence-oxlint/testing.@longzai-intelligence-oxlint/tsconfig-plugin.@longzai-intelligence-oxlint/tsdoc-plugin.@longzai-intelligence-oxlint/tsdown-config-plugin.@longzai-intelligence-oxlint/tsup-config-plugin.@longzai-intelligence-oxlint/typeorm-plugin.@longzai-intelligence-oxlint/typescript-eslint-plugin.@longzai-intelligence-oxlint/utils.@longzai-intelligence-oxlint/vitest-config-plugin.@longzai-intelligence-oxlint/zod-plugin.@longzai-intelligence-release/cli.@longzai-intelligence-release/config.@longzai-intelligence-screenshots/cli.@longzai-intelligence-screenshots/config.@longzai-intelligence-screenshots/ledger.@longzai-intelligence-shared-config/core.@longzai-intelligence-standards/cli.@longzai-intelligence-standards/config.@longzai-intelligence-taro/cli.@longzai-intelligence-tsconfig/cli.@longzai-intelligence-tsconfig/config.@longzai-intelligence-tsconfig/core.@longzai-intelligence-tsgo/cli.@longzai-intelligence-typescript/bun-config.@longzai-intelligence-version/cli.@longzai-intelligence-version/config.@longzai-intelligence-vitest/config.@longzai-intelligence-vscode/cli.@longzai-intelligence-vscode/config.@longzai-intelligence-changeset/core.@longzai-intelligence-cli/cli.@longzai-intelligence-cli/core.@longzai-intelligence-cli/standard.@longzai-intelligence-config/cli.@longzai-intelligence-config/core.@longzai-intelligence-config/registry.@longzai-intelligence-deploy/cli.@longzai-intelligence-deploy/config.@longzai-intelligence-dimensions/cli.@longzai-intelligence-dimensions/config.@longzai-intelligence-dimensions/core.@longzai-intelligence-docs/cli.@longzai-intelligence-docs/compile-plugin.@longzai-intelligence-docs/config.@longzai-intelligence-docs/core.@longzai-intelligence-docs/eslint-plugin-markdown-links.@longzai-intelligence-docs/numbering-plugin.@longzai-intelligence-findings/cli.@longzai-intelligence-findings/config.@longzai-intelligence-findings/ledger.@longzai-intelligence-git-commit/cli.@longzai-intelligence-git-commit/config.@longzai-intelligence-git-swarm/cli.@longzai-intelligence-git-swarm/config.@longzai-intelligence-lint/cli.@longzai-intelligence-mechanisms/cli.@longzai-intelligence-mechanisms/config.@longzai-intelligence-mechanisms/core.@longzai-intelligence-npm-registry/cli.@longzai-intelligence-npm-registry/config.@longzai-intelligence-pitfalls/cli.@longzai-intelligence-pitfalls/config.@longzai-intelligence-pitfalls/ledger.@longzai-intelligence-port/cli.@longzai-intelligence-port/core.@longzai-intelligence-port/registry.@longzai-intelligence-prettier/config.@longzai-intelligence-prettier/markdown-plugin.@longzai-intelligence-project-registry/core.@longzai-intelligence-readme/cli.@longzai-intelligence-readme/config.@longzai-intelligence-readme/core.@longzai-intelligence-records/cli.@longzai-intelligence-records/config.@longzai-intelligence-records/ledger.@longzai-intelligence-reflections/cli.@longzai-intelligence-reflections/config.@longzai-intelligence-reflections/ledger.@longzai-intelligence-remote-machine/config.@longzai-intelligence-runtime-registry/cli.@longzai-intelligence-runtime/cli.@longzai-intelligence-runtime/config.@longzai-intelligence-scripts/cli.@longzai-intelligence-scripts/config.@longzai-intelligence-scripts/core.@longzai-intelligence-specs/cli.@longzai-intelligence-specs/config.@longzai-intelligence-specs/ledger.@longzai-intelligence-testing/cli.@longzai-intelligence-testing/config.@longzai-intelligence-testing/registry.@longzai-intelligence-toolchain/cli.@longzai-intelligence-toolchain/config.@longzai-intelligence-tsdoc/cli.@longzai-intelligence-tsdoc/config.@longzai-intelligence-vite/cli.@longzai-intelligence-wifi/cli.@longzai-intelligence-wifi/config.@longzai-intelligence-growth/cli.@longzai-intelligence-growth/config.@longzai-intelligence-growth/core.@longzai-intelligence-inbox/cli.@longzai-intelligence-inbox/config.@longzai-intelligence-inbox/core.@longzai-intelligence-kol/cli.@longzai-intelligence-kol/config.@longzai-intelligence-kol/core.@longzai-intelligence-one-digest/cli.@longzai-intelligence-one-digest/config.@longzai-intelligence-one-digest/core.@longzai-intelligence-closed-loop-markdown/cli.@longzai-intelligence-closed-loop-markdown/config.@longzai-intelligence-code-report/config.@longzai-intelligence-competition-registry/registry.@longzai-intelligence-crossref-markdown/cli.@longzai-intelligence-crossref-markdown/config.@longzai-intelligence-disk-space-markdown/config.@longzai-intelligence-github-trending-markdown/cli.@longzai-intelligence-github-trending-markdown/config.@longzai-intelligence-input-markdown/cli.@longzai-intelligence-input-markdown/config.@longzai-intelligence-journals-markdown/cli.@longzai-intelligence-journals-markdown/config.@longzai-intelligence-journals/config.@longzai-intelligence-knowledge-markdown/cli.@longzai-intelligence-knowledge-markdown/config.@longzai-intelligence-kol-markdown/cli.@longzai-intelligence-kol-markdown/config.@longzai-intelligence-music-video/config.@longzai-intelligence-nation/config.@longzai-intelligence-okr-markdown/config.@longzai-intelligence-open-router-markdown/cli.@longzai-intelligence-open-router-markdown/config.@longzai-intelligence-paper-report/cli.@longzai-intelligence-paper-report/config.@longzai-intelligence-philosophy-markdown/config.@longzai-intelligence-project-markdown/config.@longzai-intelligence-roadmap-markdown/config.@longzai-intelligence-rss-markdown/cli.@longzai-intelligence-rss-markdown/config.@longzai-intelligence-schedule-markdown/config.@longzai-intelligence-task-markdown/config.@longzai-intelligence-workflow-markdown/config.@longzai-intelligence-bilibili-markdown-private/cli.@longzai-intelligence-bilibili-markdown-private/config.@longzai-intelligence-douyin-markdown-private/cli.@longzai-intelligence-douyin-markdown-private/config.@longzai-intelligence-law-markdown-private/cli.@longzai-intelligence-law-markdown-private/config.@longzai-intelligence-release-workflow-private/publish-repository-plugin.@longzai-intelligence-release-workflow-private/workflow-repository-plugin.@longzai-intelligence-research-report-markdown-private/cli.@longzai-intelligence-research-report-markdown-private/config.@longzai-intelligence-research-report-private/core.@longzai-intelligence-runtime-registry-private/data.@longzai-intelligence-strategy-consulting-markdown-private/cli.@longzai-intelligence-strategy-consulting-markdown-private/config.@longzai-intelligence-twitter-markdown-private/cli.@longzai-intelligence-twitter-markdown-private/config.@longzai-intelligence-xiaohongshu-markdown-private/cli.@longzai-intelligence-xiaohongshu-markdown-private/config.@longzai-intelligence-youtube-markdown-private/cli.@longzai-intelligence-youtube-markdown-private/config.@longzai-intelligence-youtube-private/config.@longzai-intelligence-zhihu-markdown-private/config`.split(`.`)),qC=[`dependencies`,`devDependencies`],JC=(e,t)=>{if(e.workspaces===void 0)return{inScope:!1,violations:[]};let n=[];for(let r of qC){let i=e[r]??{};for(let[e]of Object.entries(i))e.startsWith(`@longzai-intelligence-`)&&!t.has(e)&&(KC.has(e)||n.push({dependency:e,field:r}))}return{inScope:!0,violations:n}},YC=[`dependencies`,`devDependencies`],XC=e=>e.startsWith(`@longzai-intelligence`)&&e.includes(`/`),ZC=e=>e.slice(0,e.lastIndexOf(`/`)),QC=(e,t)=>{let n=[];for(let r of e){let e=/* @__PURE__ */ new Map;for(let n of YC){let i=r[n]??{};for(let[r,a]of Object.entries(i)){if(!XC(r)||a.startsWith(`workspace:`))continue;let i=ZC(r);if(t.has(i))continue;let o=e.get(i)??[];o.push({dependency:r,field:n,specifier:a}),e.set(i,o)}}for(let[t,i]of e)new Set(i.map(e=>e.specifier)).size<=1||n.push({manifest:r.relativePath,scope:t,members:i})}return n},$C=[`dependencies`,`devDependencies`],ew=e=>typeof e==`string`&&e.length>0,tw=e=>{if(typeof e!=`object`||!e)return;let t=Reflect.get(e,`packages`);return Array.isArray(t)?t:void 0},nw=e=>{if(Array.isArray(e))return e.filter(ew);let t=tw(e);return t===void 0?null:t.filter(ew)},rw=(e,t)=>{let n=[];for(let r of e)for(let e of $C){let i=r[e]??{};for(let[a,o]of Object.entries(i))t.has(a)&&!o.startsWith(`workspace:`)&&n.push({manifest:r.relativePath,dependency:a,field:e,currentVersion:o})}return n},iw=`@longzai-intelligence`,aw=vc({workspaces:fc().optional(),dependencies:Oc(U(),U()).optional(),devDependencies:Oc(U(),U()).optional()}),ow=vc({name:U().optional(),dependencies:Oc(U(),U()).optional(),devDependencies:Oc(U(),U()).optional()}),sw=vc({name:U().optional(),exports:Oc(U(),fc()).optional()}),cw=vc({dependencies:Oc(U(),U()).optional(),devDependencies:Oc(U(),U()).optional()}),lw=async()=>{let e=await uw(),t=await fw(),n=await pw(),r=await hw(),i=process.env.npm_config_registry;process.env.npm_config_registry=`https://registry.npmjs.org/`;let a;try{a=await vw(void 0)}finally{i===void 0?delete process.env.npm_config_registry:process.env.npm_config_registry=i}let o=yw(a);$(`
325
+ 以下清单声明了未豁免的 overrides 族强制版本字段:`);for(let e of s)$(` ${e.packageName} ${e.relPath}`),$(` ${e.field} ${e.entry} ${e.value}`);$(`共 ${s.length} 处强制版本条目,处置口径见 ADR 0153,豁免须经特别申请登记于 lzi-dependencies.config.ts 的 overrides.allowlist`),process.exit(1)}},GC=(e,t)=>{let n=e.filter(e=>e.relativePath.startsWith(`apps/`));if(n.length===0)return{inScope:!1,violations:[]};let r=[];for(let e of n){let n=e.name??e.relativePath;if(t.has(n))continue;let i=Object.keys(e.exports??{}).filter(e=>e!==`.`);i.length!==0&&r.push({packageName:n,relPath:e.relativePath,extraExits:i})}return{inScope:!0,violations:r}},KC=/* @__PURE__ */ new Set(/* @__PURE__ */ `@longzai-intelligence-agent-tools/cli.@longzai-intelligence-agent-tools/config.@longzai-intelligence-api/cli.@longzai-intelligence-api/config.@longzai-intelligence-api/core.@longzai-intelligence-builder/cli.@longzai-intelligence-builder/config.@longzai-intelligence-builder/core.@longzai-intelligence-builder/dual.@longzai-intelligence-builder/esm.@longzai-intelligence-builder/utils.@longzai-intelligence-bun/cli.@longzai-intelligence-bun/config.@longzai-intelligence-bun/presets.@longzai-intelligence-changelog/cli.@longzai-intelligence-changelog/config.@longzai-intelligence-decision/cli.@longzai-intelligence-decision/config.@longzai-intelligence-debts/cli.@longzai-intelligence-debts/config.@longzai-intelligence-dependencies/cli.@longzai-intelligence-dependencies/config.@longzai-intelligence-dev-tools/cli.@longzai-intelligence-dev-tools/config.@longzai-intelligence-dev-tools/vite-plugin.@longzai-intelligence-env/cli.@longzai-intelligence-env/config.@longzai-intelligence-env/core.@longzai-intelligence-features/cli.@longzai-intelligence-features/config.@longzai-intelligence-features/ledger.@longzai-intelligence-globals/cli.@longzai-intelligence-git/cli.@longzai-intelligence-git/config.@longzai-intelligence-issues/cli.@longzai-intelligence-issues/config.@longzai-intelligence-ledger/cli.@longzai-intelligence-ledger/config.@longzai-intelligence-ledger/core.@longzai-intelligence-markdown/cli.@longzai-intelligence-markdown/config.@longzai-intelligence-oxfmt/config.@longzai-intelligence-oxlint/architecture-core-plugin.@longzai-intelligence-oxlint/architecture-domain-plugin.@longzai-intelligence-oxlint/architecture-electron-plugin.@longzai-intelligence-oxlint/architecture-library-plugin.@longzai-intelligence-oxlint/architecture-plugin.@longzai-intelligence-oxlint/cli.@longzai-intelligence-oxlint/code-style-plugin.@longzai-intelligence-oxlint/composer-plugin.@longzai-intelligence-oxlint/core.@longzai-intelligence-oxlint/design-rules-plugin.@longzai-intelligence-oxlint/elysia-route-plugin.@longzai-intelligence-oxlint/eslint-config-plugin.@longzai-intelligence-oxlint/file-naming-plugin.@longzai-intelligence-oxlint/lzi-builder-config-plugin.@longzai-intelligence-oxlint/lzi-config-plugin.@longzai-intelligence-oxlint/nestjs-route-plugin.@longzai-intelligence-oxlint/oxlint-config.@longzai-intelligence-oxlint/package-json-plugin.@longzai-intelligence-oxlint/perfectionist-plugin.@longzai-intelligence-oxlint/presets.@longzai-intelligence-oxlint/react-plugin.@longzai-intelligence-oxlint/schema-type-separation-plugin.@longzai-intelligence-oxlint/stylistic-plugin.@longzai-intelligence-oxlint/testing.@longzai-intelligence-oxlint/tsconfig-plugin.@longzai-intelligence-oxlint/tsdoc-plugin.@longzai-intelligence-oxlint/tsdown-config-plugin.@longzai-intelligence-oxlint/tsup-config-plugin.@longzai-intelligence-oxlint/typeorm-plugin.@longzai-intelligence-oxlint/typescript-eslint-plugin.@longzai-intelligence-oxlint/utils.@longzai-intelligence-oxlint/vitest-config-plugin.@longzai-intelligence-oxlint/zod-plugin.@longzai-intelligence-release/cli.@longzai-intelligence-release/config.@longzai-intelligence-screenshots/cli.@longzai-intelligence-screenshots/config.@longzai-intelligence-screenshots/ledger.@longzai-intelligence-shared-config/core.@longzai-intelligence-standards/cli.@longzai-intelligence-standards/config.@longzai-intelligence-taro/cli.@longzai-intelligence-tsconfig/cli.@longzai-intelligence-tsconfig/config.@longzai-intelligence-tsconfig/core.@longzai-intelligence-tsgo/cli.@longzai-intelligence-typescript/bun-config.@longzai-intelligence-version/cli.@longzai-intelligence-version/config.@longzai-intelligence-vitest/config.@longzai-intelligence-vscode/cli.@longzai-intelligence-vscode/config.@longzai-intelligence-assignments/cli.@longzai-intelligence-assignments/config.@longzai-intelligence-changeset/core.@longzai-intelligence-cli/cli.@longzai-intelligence-cli/core.@longzai-intelligence-cli/standard.@longzai-intelligence-config/cli.@longzai-intelligence-config/core.@longzai-intelligence-config/registry.@longzai-intelligence-deploy/cli.@longzai-intelligence-deploy/config.@longzai-intelligence-dimensions/cli.@longzai-intelligence-dimensions/config.@longzai-intelligence-dimensions/core.@longzai-intelligence-docs/cli.@longzai-intelligence-docs/compile-plugin.@longzai-intelligence-docs/config.@longzai-intelligence-docs/core.@longzai-intelligence-docs/eslint-plugin-markdown-links.@longzai-intelligence-docs/numbering-plugin.@longzai-intelligence-findings/cli.@longzai-intelligence-findings/config.@longzai-intelligence-findings/ledger.@longzai-intelligence-git-commit/cli.@longzai-intelligence-git-commit/config.@longzai-intelligence-git-swarm/cli.@longzai-intelligence-git-swarm/config.@longzai-intelligence-lint/cli.@longzai-intelligence-mechanisms/cli.@longzai-intelligence-mechanisms/config.@longzai-intelligence-mechanisms/core.@longzai-intelligence-npm-registry/cli.@longzai-intelligence-npm-registry/config.@longzai-intelligence-pitfalls/cli.@longzai-intelligence-pitfalls/config.@longzai-intelligence-pitfalls/ledger.@longzai-intelligence-port/cli.@longzai-intelligence-port/core.@longzai-intelligence-port/registry.@longzai-intelligence-prettier/config.@longzai-intelligence-prettier/markdown-plugin.@longzai-intelligence-project-registry/core.@longzai-intelligence-readme/cli.@longzai-intelligence-readme/config.@longzai-intelligence-readme/core.@longzai-intelligence-records/cli.@longzai-intelligence-records/config.@longzai-intelligence-records/ledger.@longzai-intelligence-reflections/cli.@longzai-intelligence-reflections/config.@longzai-intelligence-reflections/ledger.@longzai-intelligence-remote-machine/config.@longzai-intelligence-runtime-registry/cli.@longzai-intelligence-runtime/cli.@longzai-intelligence-runtime/config.@longzai-intelligence-scripts/cli.@longzai-intelligence-scripts/config.@longzai-intelligence-scripts/core.@longzai-intelligence-specs/cli.@longzai-intelligence-specs/config.@longzai-intelligence-specs/ledger.@longzai-intelligence-stories/cli.@longzai-intelligence-stories/config.@longzai-intelligence-testing/cli.@longzai-intelligence-testing/config.@longzai-intelligence-testing/registry.@longzai-intelligence-toolchain/cli.@longzai-intelligence-toolchain/config.@longzai-intelligence-tsdoc/cli.@longzai-intelligence-tsdoc/config.@longzai-intelligence-vite/cli.@longzai-intelligence-wifi/cli.@longzai-intelligence-wifi/config.@longzai-intelligence-growth/cli.@longzai-intelligence-growth/config.@longzai-intelligence-growth/core.@longzai-intelligence-inbox/cli.@longzai-intelligence-inbox/config.@longzai-intelligence-inbox/core.@longzai-intelligence-kol/cli.@longzai-intelligence-kol/config.@longzai-intelligence-kol/core.@longzai-intelligence-one-digest/cli.@longzai-intelligence-one-digest/config.@longzai-intelligence-one-digest/core.@longzai-intelligence-closed-loop-markdown/cli.@longzai-intelligence-closed-loop-markdown/config.@longzai-intelligence-code-report/config.@longzai-intelligence-competition-registry/registry.@longzai-intelligence-crossref-markdown/cli.@longzai-intelligence-crossref-markdown/config.@longzai-intelligence-disk-space-markdown/config.@longzai-intelligence-github-trending-markdown/cli.@longzai-intelligence-github-trending-markdown/config.@longzai-intelligence-input-markdown/cli.@longzai-intelligence-input-markdown/config.@longzai-intelligence-journals-markdown/cli.@longzai-intelligence-journals-markdown/config.@longzai-intelligence-journals/config.@longzai-intelligence-knowledge-markdown/cli.@longzai-intelligence-knowledge-markdown/config.@longzai-intelligence-kol-markdown/cli.@longzai-intelligence-kol-markdown/config.@longzai-intelligence-music-video/config.@longzai-intelligence-nation/config.@longzai-intelligence-okr-markdown/config.@longzai-intelligence-open-router-markdown/cli.@longzai-intelligence-open-router-markdown/config.@longzai-intelligence-paper-report/cli.@longzai-intelligence-paper-report/config.@longzai-intelligence-philosophy-markdown/config.@longzai-intelligence-project-markdown/config.@longzai-intelligence-roadmap-markdown/config.@longzai-intelligence-rss-markdown/cli.@longzai-intelligence-rss-markdown/config.@longzai-intelligence-schedule-markdown/config.@longzai-intelligence-task-markdown/config.@longzai-intelligence-workflow-markdown/config.@longzai-intelligence-bilibili-markdown-private/cli.@longzai-intelligence-bilibili-markdown-private/config.@longzai-intelligence-douyin-markdown-private/cli.@longzai-intelligence-douyin-markdown-private/config.@longzai-intelligence-law-markdown-private/cli.@longzai-intelligence-law-markdown-private/config.@longzai-intelligence-release-workflow-private/publish-repository-plugin.@longzai-intelligence-release-workflow-private/workflow-repository-plugin.@longzai-intelligence-research-report-markdown-private/cli.@longzai-intelligence-research-report-markdown-private/config.@longzai-intelligence-research-report-private/core.@longzai-intelligence-runtime-registry-private/data.@longzai-intelligence-strategy-consulting-markdown-private/cli.@longzai-intelligence-strategy-consulting-markdown-private/config.@longzai-intelligence-twitter-markdown-private/cli.@longzai-intelligence-twitter-markdown-private/config.@longzai-intelligence-xiaohongshu-markdown-private/cli.@longzai-intelligence-xiaohongshu-markdown-private/config.@longzai-intelligence-youtube-markdown-private/cli.@longzai-intelligence-youtube-markdown-private/config.@longzai-intelligence-youtube-private/config.@longzai-intelligence-zhihu-markdown-private/config`.split(`.`)),qC=[`dependencies`,`devDependencies`],JC=(e,t)=>{if(e.workspaces===void 0)return{inScope:!1,violations:[]};let n=[];for(let r of qC){let i=e[r]??{};for(let[e]of Object.entries(i))e.startsWith(`@longzai-intelligence-`)&&!t.has(e)&&(KC.has(e)||n.push({dependency:e,field:r}))}return{inScope:!0,violations:n}},YC=[`dependencies`,`devDependencies`],XC=e=>e.startsWith(`@longzai-intelligence`)&&e.includes(`/`),ZC=e=>e.slice(0,e.lastIndexOf(`/`)),QC=(e,t)=>{let n=[];for(let r of e){let e=/* @__PURE__ */ new Map;for(let n of YC){let i=r[n]??{};for(let[r,a]of Object.entries(i)){if(!XC(r)||a.startsWith(`workspace:`))continue;let i=ZC(r);if(t.has(i))continue;let o=e.get(i)??[];o.push({dependency:r,field:n,specifier:a}),e.set(i,o)}}for(let[t,i]of e)new Set(i.map(e=>e.specifier)).size<=1||n.push({manifest:r.relativePath,scope:t,members:i})}return n},$C=[`dependencies`,`devDependencies`],ew=e=>typeof e==`string`&&e.length>0,tw=e=>{if(typeof e!=`object`||!e)return;let t=Reflect.get(e,`packages`);return Array.isArray(t)?t:void 0},nw=e=>{if(Array.isArray(e))return e.filter(ew);let t=tw(e);return t===void 0?null:t.filter(ew)},rw=(e,t)=>{let n=[];for(let r of e)for(let e of $C){let i=r[e]??{};for(let[a,o]of Object.entries(i))t.has(a)&&!o.startsWith(`workspace:`)&&n.push({manifest:r.relativePath,dependency:a,field:e,currentVersion:o})}return n},iw=`@longzai-intelligence`,aw=vc({workspaces:fc().optional(),dependencies:Oc(U(),U()).optional(),devDependencies:Oc(U(),U()).optional()}),ow=vc({name:U().optional(),dependencies:Oc(U(),U()).optional(),devDependencies:Oc(U(),U()).optional()}),sw=vc({name:U().optional(),exports:Oc(U(),fc()).optional()}),cw=vc({dependencies:Oc(U(),U()).optional(),devDependencies:Oc(U(),U()).optional()}),lw=async()=>{let e=await uw(),t=await fw(),n=await pw(),r=await hw(),i=process.env.npm_config_registry;process.env.npm_config_registry=`https://registry.npmjs.org/`;let a;try{a=await vw(void 0)}finally{i===void 0?delete process.env.npm_config_registry:process.env.npm_config_registry=i}let o=yw(a);$(`
326
326
  --- 检查结果 ---`);let s=0;if(s+=bw(a,new Set(o),!1),o.length>0){$(`\n回退基线:${o.length} 个内部包在 npm 无记录,按本机 registry 配置复查`);let e=await vw(o);s+=bw(e,new Set(o),!0)}s===0?$(`全部 Longzai Intelligence 包依赖均为最新版`):yC(`\n共 ${s} 个内部包依赖非最新版,修复指引: 在仓根执行 lzi-dependencies upgrade --write 或 bun run version:upgrade`);let c=e+t+n+r+s;c!==0&&process.exit(Math.min(c,255))},uw=async()=>{let e=null;try{let t=aw.safeParse(await Bun.file(`${process.cwd()}/package.json`).json());e=t.success?t.data:null}catch{e=null}if(e===null)return 0;let t=JC(e,await dw());if(!t.inScope)return 0;if($(`
327
327
  --- 根清单依赖准入 ---`),t.violations.length===0)return $(`工作区根清单未发现业务依赖`),0;for(let e of t.violations)$(` ${e.dependency} ${e.field}`);return $(`共 ${t.violations.length} 处业务依赖出现在工作区根清单,业务依赖应下沉到实际使用的子包,处置口径见 ADR 0182`),t.violations.length},dw=async()=>{let e=await bC();return new Set(e.rootManifest?.allowlist??[])},fw=async()=>{let e=null;try{let t=aw.safeParse(await Bun.file(`${process.cwd()}/package.json`).json());e=t.success?t.data:null}catch{e=null}if(e===null)return 0;let t=nw(e.workspaces);if(t===null||t.length===0)return 0;let n=await _w(t,ow),r=new Set(n.map(e=>e.name).filter(e=>typeof e==`string`));if(r.size===0)return 0;$(`
328
328
  --- 自仓引用协议 ---`);let i={relativePath:`package.json`,dependencies:e.dependencies,devDependencies:e.devDependencies},a=rw([i,...n],r);if(a.length===0)return $(`全部自仓引用均使用 workspace 协议`),0;for(let e of a)$(` ${e.manifest} ${e.dependency} ${e.field} ${e.currentVersion}`);return $(`共 ${a.length} 处自仓引用未使用 workspace 协议,修复指引:将引用值恢复为 workspace:* 后执行 bun install`),a.length},pw=async()=>{let e=null;try{let t=aw.safeParse(await Bun.file(`${process.cwd()}/package.json`).json());e=t.success?t.data:null}catch{e=null}if(e===null)return 0;let t=nw(e.workspaces);if(t===null||t.length===0)return 0;let n=await _w(t,sw),r=GC(n,await mw());if(!r.inScope)return 0;if($(`
@@ -331,4 +331,4 @@ n?this.stack.push(n):(yield*this.pop(),yield*this.step())}else{let t=this.peek(2
331
331
  `).map(e=>e.trim()).filter(e=>e.length>0).filter(t=>E(j(e,t)))]:[`package.json`]},Aw=(e,t,n)=>Bun.spawnSync([`git`,`commit`,...t,`-m`,n],{cwd:e,stdout:`pipe`,stderr:`pipe`}).exitCode===0,jw=async(e,t,n)=>{let r=await Bun.file(e).text(),i=[],a=[],o=[],s;for(t.lastIndex=0;(s=t.exec(r))!==null;){let e=s[0],t=s[1]??``,r=s[2]??``,i=/^"([^"]+)"/.exec(t)?.[1]??``,a=e.slice(t.length,e.length-r.length),c=n(i,a);a!==c&&Dw(a)&&o.push({name:i,oldVersion:a,targetVersion:c,prefix:t,suffix:r})}if(o.length===0)return{matchedPackages:i,changes:a};let c=r;for(let e of o){let t=RegExp(`("${Ew(e.name)}":\\s*")[^"]*(")`);c=c.replace(t,`$1${e.targetVersion}$2`),i.push(e.name),a.push({name:e.name,from:e.oldVersion,to:e.targetVersion})}return await Bun.write(e,c),{matchedPackages:i,changes:a}},Mw=async(e,t,n)=>{let r=await Bun.file(e).text(),i=[],a=[];t.lastIndex=0;let o;for(;(o=t.exec(r))!==null;){let e=o[0],t=o[1]??``,r=o[2]??``,s=/^"([^"]+)"/.exec(t)?.[1]??``,c=e.slice(t.length,e.length-r.length),l=n(s,c);c!==l&&Dw(c)&&(i.push(s),a.push({name:s,from:c,to:l}))}return{matchedPackages:i,changes:a}},Nw=async(e,t,n,r,i)=>{let{name:a,dir:o}=e,s=kw(o),c=[],l=[],u=[],d=[];for(let e of s){let r=j(o,e),a=await Mw(r,t,n);if(a.matchedPackages.length!==0){if(!ww(o,e))u.push(e);else{if(i)c.push(...a.matchedPackages),l.push(...a.changes);else{let e=await jw(r,t,n);c.push(...e.matchedPackages),l.push(...e.changes)}d.push(e)}}}return d.length===0?u.length>0?{name:a,dir:o,matchedPackages:c,changes:l,skippedFiles:u,status:`skipped-dirty`,reason:`package.json 已有未提交改动:${u.join(`,`)}`}:{name:a,dir:o,matchedPackages:c,changes:l,status:`skipped-nochange`,reason:`无匹配 scope 或已是目标版本`}:i||Aw(o,d,r)?{name:a,dir:o,matchedPackages:c,changes:l,skippedFiles:u,status:`success`}:{name:a,dir:o,matchedPackages:c,changes:l,skippedFiles:u,status:`failed`,reason:`git commit 失败,文件已修改,需人工介入`}},Pw=async(e,t)=>{let n=/* @__PURE__ */ new Set;for(let r of e){let e=kw(r.dir);for(let i of e){let e=j(r.dir,i),a=await Bun.file(e).text();t.lastIndex=0;let o;for(;(o=t.exec(a))!==null;){let e=o[1]??``,t=/^"([^"]+)"/.exec(e)?.[1];t&&n.add(t)}}}return[...n]},Fw=async(e,t)=>{let n=/* @__PURE__ */ new Map,r=[],i=0,a=async e=>{let t=await sx(e),i=t.tags?.latest;if(i===void 0){let n=t.error instanceof Error?t.error.message:t.error??`未找到 dist-tags.latest`;r.push({name:e,reason:n})}else n.set(e,i)},o=async()=>{for(;i<e.length;){let t=e[i];i++,t!==void 0&&await a(t)}},s=Array.from({length:Math.min(t,e.length)},()=>o());if(await Promise.all(s),r.length>0){yC(`${_C.RED}错误: 部分包查询 npm latest 失败,已中止(0 文件改动、0 提交)${_C.RESET}`);for(let e of r)yC(` ${e.name}: ${e.reason}`);process.exit(1)}return n},Iw=async e=>{let{scope:t,version:n,message:r,dryRun:i}=e,a=e.concurrency??10,o=await Cw({projectScope:e.projectScope}),s=n===void 0,c=s?`latest(各自 npm 最新)`:n,l=r??(s?`chore: 升级 ${t} 版本至最新`:`chore: 升级 ${t} 版本至 ${n.replace(/^[~^]/,``)}`),u=Tw(t);$(`${_C.BLUE}═══ version upgrade-across ═══${_C.RESET}`),$(`项目获取来源: ${o.source===`structure`?`结构锚点(cwd 上溯聚合根)`:`显式圈定(--project-scope)`}`),$(`registry: ${o.registryRoot}`),$(`项目范围: ${o.scopeId}`),$(`升级范围: ${t} 下的所有包 -> ${c}`),$(`并发数: ${a}`),i&&$(`${_C.YELLOW}[dry-run] 预览模式,不写文件、不提交${_C.RESET}`),$(``);let d=o.projects;$(`发现 ${d.length} 个子项目,并发处理(并发 ${a})...`),$(``);let f;if(s){let e=await Pw(d,u);if(e.length===0){$(`${_C.YELLOW}未匹配到任何 ${t} 下的包,结束${_C.RESET}`);return}$(`匹配到 ${e.length} 个 ${t} 下的包,查询 npm latest...`);let n=await Fw(e,a);f=(e,t)=>Ow(t,n.get(e)??``)}else{let e=n??``;f=()=>e}let p=[],m=0,h=d.length;await(async(e,t)=>{let n=0,r=async()=>{for(;n<e.length;){let t=e[n];if(n++,t===void 0)break;let r=await Nw(t,u,f,l,i);p.push(r),m++;let a=r.status===`success`?`${_C.GREEN}✓${_C.RESET}`:r.status===`failed`?`${_C.RED}✗${_C.RESET}`:`·`;$(` [${m}/${h}] ${a} ${t.name}`)}},a=Array.from({length:Math.min(t,e.length)},()=>r());await Promise.all(a)})(d,a),$(``),Lw(p,i)},Lw=(e,t)=>{let n=e.filter(e=>e.status===`success`),r=e.filter(e=>e.status===`skipped-dirty`),i=e.filter(e=>e.status===`skipped-nochange`),a=e.filter(e=>e.status===`failed`);$(`${_C.BLUE}═══ 处理结果 ═══${_C.RESET}`);let o=t?`将提交`:`已提交`;$(`${_C.GREEN}✓ ${o}: ${n.length}${_C.RESET}`);for(let e of n){let t=e.changes.map(e=>`${e.name.split(`/`).pop()}: ${e.from} → ${e.to}`).join(`, `);$(` ${e.name}`),$(` ${t}`),e.skippedFiles!==void 0&&e.skippedFiles.length>0&&$(` ⚠ 脏文件跳过:${e.skippedFiles.join(`,`)}`)}if(r.length>0){$(``),$(`${_C.YELLOW}⚠ 跳过(文件已改动): ${r.length}${_C.RESET}`);for(let e of r)$(` ${e.name}: ${e.reason}`)}if(i.length>0&&($(``),$(`跳过(无匹配/已是目标版本): ${i.length}`)),a.length>0){$(``),$(`${_C.RED}✗ 失败(需人工介入): ${a.length}${_C.RESET}`);for(let e of a)$(` ${e.name}: ${e.reason}`),$(` ${e.changes.map(e=>`${e.name.split(`/`).pop()}: ${e.from} → ${e.to}`).join(`, `)}`)}$(``),$(`${_C.BLUE}汇总: ${n.length} ${o} / ${r.length} 跳过(dirty) / ${i.length} 跳过(无变更) / ${a.length} 失败${_C.RESET}`),!t&&n.length>0&&($(``),$(`下一步:推送到远程`),$(` bun push-all`)),a.length>0&&(process.exitCode=1)},Rw=e=>[`${e}/*`,`${e}-*/*`],zw=Ac([`default`,`major`,`minor`,`patch`,`latest`,`newest`]).default(`default`),Bw=async e=>{let t=(await bC()).upgrade??{},n=e.mode||t.mode||`default`,r=zw.safeParse(n),i=r.success?r.data:`default`,a=[...e.scope?Rw(e.scope):[],...t.include??[]],{packages:o}=await NS({cwd:process.cwd(),mode:i,write:!e.dryRun&&e.write,recursive:t.recursive??!0,timeout:t.timeout??3e4,retries:t.retries??3,exclude:t.exclude??[],include:a,depFields:t.depFields,ignorePaths:t.ignorePaths??[],concurrency:t.concurrency??10,force:!1,all:!1,install:!1,update:!1,interactive:!1,group:!0,includeLocked:e.locked===!0,timediff:!0,nodecompat:!0,loglevel:`info`,silent:!1,failOnOutdated:!1},{afterPackagesLoaded:e=>{$(`扫描到 ${e.length} 个包,正在检查依赖更新...`)},beforePackageStart:e=>{$(`正在检查 ${e.name||e.relative}...`)},afterPackageEnd:e=>{let t=e.resolved.filter(e=>e.update).length;$(t>0?` ✓ ${e.name||e.relative}: 发现 ${t} 个可更新依赖`:` ✓ ${e.name||e.relative}: 所有依赖已是最新`)},afterPackageWrite:e=>{$(` 📝 已写入 ${e.name||e.relative}`)}}),s=0;$(`
332
332
  --- 检查结果 ---`);for(let e of o){let t=e.resolved.filter(e=>e.update);if(t.length>0){s+=t.length,$(`\n${e.name||e.relative}:`);for(let e of t){let t=e.diff??``;$(` ${e.name}: ${e.currentVersion} -> ${e.targetVersion} (${t})`)}}}s===0?$(`所有依赖已是最新版本`):($(`\n共发现 ${s} 个可更新依赖`),e.write?$(`已写入 package.json`):$(`使用 --write 参数写入 package.json`))};function Vw(e){qd(e,{name:`upgrade`,description:`检查依赖版本更新`,arguments:[{signature:`[mode]`,description:`升级模式(major/minor/patch/latest/newest)`},{signature:`[scope]`,description:`可选。仅升级指定 scope 族的依赖(如 @longzai-intelligence-oxlint 或族根 @longzai-intelligence),内部展开为 include @scope/* 与 @scope-*/*`}],options:[{flags:`--write`,description:`将更新写入 package.json`},{flags:`--dry-run`,description:`仅预览`},{flags:`--locked`,description:`包含精确锁定版本的依赖(默认跳过以数字开头的精确 pin)`}],schema:bc({write:uc().optional(),dryRun:uc().optional(),locked:uc().optional()}),action:async(e,t)=>{let n=t[0],r=t[1];await Bw({mode:n,write:e.write===!0,dryRun:e.dryRun===!0,locked:e.locked,scope:r})}}),qd(e,{name:`upgrade-across`,description:`跨产品群批量升级依赖(项目清单经 project-registry 声明域获取)`,options:[{flags:`--scope <scope>`,description:`依赖 scope(必填,如 @longzai-intelligence-builder)`},{flags:`--target <version>`,description:`目标版本号(可选,如 ^0.0.8。省略时自动取每个匹配包的 npm latest)`},{flags:`-m, --message <message>`,description:`自定义提交信息`},{flags:`--project-scope <id>`,description:`显式圈定项目范围(缺省自动取当前 edition 范围)`},{flags:`--concurrency <n>`,description:`并发数(默认 10)`},{flags:`--dry-run`,description:`仅预览(不写文件、不提交)`}],schema:bc({scope:U().optional(),target:U().optional(),message:U().optional(),config:U().optional(),concurrency:ol().int().positive().optional(),projectScope:U().optional(),dryRun:uc().optional()}),action:async e=>{e.scope||(process.stderr.write(`错误: upgrade-across 需要指定 --scope <@scope>
333
333
  `),process.stderr.write(`示例: --scope @longzai-intelligence-builder
334
- `),process.exit(1)),await Iw({scope:e.scope,version:e.target,message:e.message,projectScope:e.projectScope,concurrency:e.concurrency,dryRun:e.dryRun===!0})}}),qd(e,{name:`check`,description:`依赖声明聚合检查,覆盖根清单准入、自仓引用协议、应用包出口形态、同 scope 版本锁步与依赖新鲜度`,schema:bc({}),action:async()=>{await lw()}})}function Hw(e){qd(e,{name:`hoisting check`,description:`归位三段检查:子包重复声明根依赖、根声明技术栈专属依赖与构建面痕迹引擎声明完备`,schema:bc({}),action:async()=>{await VC()}})}function Uw(e){qd(e,{name:`overrides check`,description:`检查 package.json 是否声明未豁免的强制版本字段`,schema:bc({}),action:async()=>{await WC()}})}function Ww(e){qd(e,{name:`boundary check`,description:`检查 packages 层包是否依赖 domains 层领域契约包并校验领域目录层名合规`,schema:bc({}),action:async()=>{await OC()}})}function Gw(){let e=Hd({name:`lzi-dependencies`,description:`Longzai Intelligence 依赖版本管理工具`,version:`0.0.16`});return Vw(e),Hw(e),Uw(e),Ww(e),e}async function Kw(){await Gw().parseAsync(process.argv)}import.meta.main===!0&&await Kw();export{Gw as buildProgram};
334
+ `),process.exit(1)),await Iw({scope:e.scope,version:e.target,message:e.message,projectScope:e.projectScope,concurrency:e.concurrency,dryRun:e.dryRun===!0})}}),qd(e,{name:`check`,description:`依赖声明聚合检查,覆盖根清单准入、自仓引用协议、应用包出口形态、同 scope 版本锁步与依赖新鲜度`,schema:bc({}),action:async()=>{await lw()}})}function Hw(e){qd(e,{name:`hoisting check`,description:`归位三段检查:子包重复声明根依赖、根声明技术栈专属依赖与构建面痕迹引擎声明完备`,schema:bc({}),action:async()=>{await VC()}})}function Uw(e){qd(e,{name:`overrides check`,description:`检查 package.json 是否声明未豁免的强制版本字段`,schema:bc({}),action:async()=>{await WC()}})}function Ww(e){qd(e,{name:`boundary check`,description:`检查 packages 层包是否依赖 domains 层领域契约包并校验领域目录层名合规`,schema:bc({}),action:async()=>{await OC()}})}function Gw(){let e=Hd({name:`lzi-dependencies`,description:`Longzai Intelligence 依赖版本管理工具`,version:`0.0.17`});return Vw(e),Hw(e),Uw(e),Ww(e),e}async function Kw(){await Gw().parseAsync(process.argv)}import.meta.main===!0&&await Kw();export{Gw as buildProgram};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longzai-intelligence-dependencies/cli",
3
- "version": "0.0.16",
3
+ "version": "0.0.17",
4
4
  "description": "Longzai Intelligence 依赖版本管理 CLI(bin lzi-dependencies)",
5
5
  "keywords": [
6
6
  "cli",