@longzai-intelligence-bun/cli 0.0.32 → 0.0.33

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 +8 -8
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -189,18 +189,18 @@ ${K.default.gray(fu+uu.repeat(a+2)+pu)}
189
189
  `),m(),i()};return{start:v,stop:y,message:(e=``)=>{s=g(e??s)}}},Du={red:e=>K.default.red(e),green:e=>K.default.green(e),yellow:e=>K.default.yellow(e),blue:e=>K.default.blue(e),cyan:e=>K.default.cyan(e),magenta:e=>K.default.magenta(e),gray:e=>K.default.gray(e),bold:e=>K.default.bold(e),dim:e=>K.default.dim(e)},Ou={async select(e,t){let n=await Su({message:e,options:t.map(e=>({value:e.value,label:e.label,hint:e.hint}))});return Ul(n)&&(wu(`操作已取消`),process.exit(0)),typeof n==`string`?n:String(n)},async textInput(e,t){let n=await bu({message:e,placeholder:t?.placeholder,defaultValue:t?.defaultValue});return Ul(n)&&(wu(`操作已取消`),process.exit(0)),typeof n==`string`?n:String(n)},async confirm(e,t){let n=await xu({message:e,initialValue:t?.defaultValue??!1});return Ul(n)&&(wu(`操作已取消`),process.exit(0)),typeof n==`boolean`?n:!!n},spinner(){let e=Eu();return{start(t){e.start(t)},stop(t){e.stop(t)}}},note(e,t){Cu(e,t)},log:{info(e){Tu.info(K.default.blue(e))},success(e){Tu.success(K.default.green(e))},warn(e){Tu.warn(K.default.yellow(e))},error(e){Tu.error(K.default.red(e))},step(e){Tu.step(e)}}};function ku(e){return e.map(e=>{if(typeof e==`string`)return e;if(e instanceof Error)return e.message;try{return JSON.stringify(e)}catch{return String(e)}}).join(` `)}function Z(...e){process.stdout.write(`${ku(e)}\n`)}function Q(...e){process.stderr.write(`${ku(e)}\n`)}const Au=/* @__PURE__ */ new Set([`build`,`coverage`,`dist`,`node_modules`,`out`]),ju=/* @__PURE__ */ new Set([`ENAMETOOLONG`,`EACCES`,`EPERM`,`ENOENT`]),Mu=Cc([yc(Hs()),xc({packages:yc(Hs())})]),Nu=e=>typeof e!=`object`||!e||!(`code`in e)?!1:typeof e.code==`string`,Pu=e=>{let t=``;for(let n=0;n<e.length;n+=1){let r=e.charAt(n);r===`*`?e[n+1]===`*`?(t+=`.*`,n+=1):t+=`[^/]+`:t+=r.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}return RegExp(`^${t}$`)},Fu=e=>{let t={positives:[],negatives:[]};for(let n of e)n.startsWith(`!`)?t.negatives.push(Pu(n.slice(1))):t.positives.push(Pu(n));return t},Iu=e=>{let t=Mu.safeParse(e);if(t.success)return Array.isArray(t.data)?t.data:t.data.packages},Lu=(e,t)=>e.positives.some(e=>e.test(t))&&!e.negatives.some(e=>e.test(t)),Ru=(e,t)=>e.negatives.some(e=>e.test(t)),zu=[`bun.lock`,`bun.lockb`],Bu=xc({name:Hs().optional(),workspaces:Mu.optional()}),Vu=xc({name:Hs().optional()}),Hu=async e=>{try{let t=Vu.safeParse(JSON.parse(await _(e,`utf-8`)));return t.success?t.data.name??null:null}catch{return null}},Uu=async e=>{let t={packageDirs:[],lockDirs:[],rootHasLock:!1,scanSkips:[]},n=[{dir:e,depth:0}];for(;n.length>0;){let r=n.shift();if(r===void 0)break;let i;try{i=await v(r.dir,{withFileTypes:!0})}catch(n){if(!Nu(n)||!ju.has(n.code))throw n;let i=r.depth===0?`.`:r.dir.slice(e.length+1);t.scanSkips.push({path:i,code:n.code});continue}let a=!1,o=!1;for(let e of i)e.isFile()&&zu.includes(e.name)&&(a=!0),e.isFile()&&e.name===`package.json`&&(o=!0);r.depth===0?t.rootHasLock=a:(a&&t.lockDirs.push(r.dir.slice(e.length+1)),o&&t.packageDirs.push({relPath:r.dir.slice(e.length+1),name:await Hu(s(r.dir,`package.json`))}));for(let e of i)e.isDirectory()&&(e.name.startsWith(`.`)||Au.has(e.name)||r.depth>=5||n.push({dir:s(r.dir,e.name),depth:r.depth+1}))}return t},Wu=async e=>{let t;try{t=JSON.parse(await _(s(e,`package.json`),`utf-8`))}catch{throw Error(`根 package.json 不存在或不可解析,请在仓库根执行本命令`)}let n=Bu.safeParse(t);if(!n.success)throw Error(`根 package.json 不存在或不可解析,请在仓库根执行本命令`);let r=n.data,i=r.name??null,a=i===null?null:i.includes(`/`)?i.slice(0,i.lastIndexOf(`/`)):`@${i}`,o=Iu(r.workspaces);if(o===void 0)return{rootName:i,scope:a,hasWorkspaces:!1,memberCount:0,violations:[],notices:[],scanSkips:[],ok:!0};let c=Fu(o),l=await Uu(e),u=[],d=[],f=new Map(l.packageDirs.map(e=>[e.relPath,e.name])),p=l.packageDirs.map(e=>e.relPath).filter(e=>Lu(c,e));l.rootHasLock||u.push({kind:`missing-root-lock`,path:``,message:`仓库根缺少 bun.lock,声明了 workspaces 的 monorepo 锁文件应只存在于根`});let m=/* @__PURE__ */ new Set;for(let e of l.lockDirs){if(Lu(c,e)){m.add(e),u.push({kind:`stray-member-lock`,path:e,message:`${e} 是 workspaces 成员却持有自己的 bun.lock,属游离锁文件`});continue}let t=f.get(e)??null;t===null?d.push({kind:`orphan-lock`,path:e,message:`${e} 存在锁文件但没有 package.json,请确认目录用途`}):Ru(c,e)?d.push({kind:`excluded-standalone`,path:e,message:`${e} 为负向 glob 显式排除的独立安装根,锁文件属合法形态`}):a!==null&&t.startsWith(`${a}/`)?(m.add(e),u.push({kind:`uncovered-same-scope`,path:e,message:`${e}(${t})与根包同作用域却未被 workspaces 覆盖,已按独立安装根长出游离锁`})):d.push({kind:`foreign-scope-lock`,path:e,message:`${e}(${t})不属于根作用域且持有独立锁文件,若为有意保留请以负向 glob 显式排除`})}for(let e of l.packageDirs)p.includes(e.relPath)||Ru(c,e.relPath)||m.has(e.relPath)||a!==null&&e.name!==null&&e.name.startsWith(`${a}/`)&&u.push({kind:`uncovered-same-scope`,path:e.relPath,message:`${e.relPath}(${e.name})与根包同作用域却未被 workspaces 覆盖,请补 glob 或以负向 glob 显式排除`});return{rootName:i,scope:a,hasWorkspaces:!0,memberCount:p.length,violations:u,notices:d,scanSkips:l.scanSkips,ok:u.length===0}},Gu=async()=>{let e=process.cwd();Z(`正在扫描 ${e} 下的工作区布局...`);try{let t=await Wu(e);if(!t.hasWorkspaces){Z(`未声明 workspaces,非 bun workspaces monorepo,跳过锁文件校验`);return}if(t.scanSkips.length>0){Q(`\n${t.scanSkips.length} 项目录读取降级告警,结论基于其余可读目录:`);for(let e of t.scanSkips)Q(` ${e.path} 读取失败已跳过该子树,错误码 ${e.code}`)}if(Z(`根包 ${t.rootName??`未命名`},workspaces 成员 ${t.memberCount} 个`),t.notices.length>0){Z(`\n${t.notices.length} 项提示:`);for(let e of t.notices)Z(` ${e.message}`)}if(!t.ok){Z(`\n发现 ${t.violations.length} 项违规:`);for(let e of t.violations)Z(` ${e.message}`);Z(`
190
190
  修复指引: 删除成员目录的游离 bun.lock 后在仓库根执行 bun install;覆盖缺口补 workspaces glob,刻意独立的子项目以负向 glob 显式排除`),process.exit(1)}Z(`单一锁文件不变量成立,无游离锁文件与覆盖缺口`)}catch(e){Q(`错误: ${e instanceof Error?e.message:String(e)}`),process.exit(1)}},Ku=/* @__PURE__ */ new Set([`.bun`]),qu=/* @__PURE__ */ new Set([`ENOENT`,`ENOTDIR`]),Ju=xc({workspaces:Mu.optional()}),Yu=async e=>{let t=[],n=[],r=[{dir:e,depth:0}];for(;r.length>0;){let i=r.shift();if(i===void 0)break;let a;try{a=await v(i.dir,{withFileTypes:!0})}catch(t){if(!Nu(t)||!ju.has(t.code))throw t;n.push({path:i.dir.slice(e.length+1),code:t.code});continue}a.some(e=>e.isFile()&&e.name===`package.json`)&&t.push(i.dir.slice(e.length+1));for(let e of a)e.isDirectory()&&(e.name.startsWith(`.`)||Au.has(e.name)||i.depth>=5||r.push({dir:s(i.dir,e.name),depth:i.depth+1}))}return{packageDirPaths:t,scanSkips:n}},Xu=async(e,t)=>{let n=[],r=[],i=[e];for(;i.length>0;){let e=i.shift();if(e===void 0)break;let a;try{a=await v(e,{withFileTypes:!0})}catch(n){if(!Nu(n)||!ju.has(n.code))throw n;r.push({path:e.slice(t.length+1),code:n.code});continue}for(let o of a){let a=s(e,o.name);if(!Ku.has(o.name)){if(o.isSymbolicLink())try{await b(a)}catch(e){if(Nu(e)&&qu.has(e.code)){n.push({path:a.slice(t.length+1),target:await y(a)});continue}r.push({path:a.slice(t.length+1),code:Nu(e)?e.code:`UNKNOWN`})}else o.isDirectory()&&i.push(a)}}}return{dangling:n,scanSkips:r}},Zu=async e=>{let t;try{t=JSON.parse(await _(s(e,`package.json`),`utf-8`))}catch{throw Error(`根 package.json 不存在或不可解析,请在仓库根执行本命令`)}let n=Ju.safeParse(t);if(!n.success)throw Error(`根 package.json 不存在或不可解析,请在仓库根执行本命令`);let r=Iu(n.data.workspaces);if(r===void 0)return{hasWorkspaces:!1,memberCount:0,scannedNodeModulesRoots:0,dangling:[],scanSkips:[],ok:!0};let i=Fu(r),a=await Yu(e),o=a.packageDirPaths.filter(e=>Lu(i,e)),c=[],l=[...a.scanSkips],u=0;for(let t of[``,...o]){let n=s(e,t,`node_modules`);try{if(!(await b(n)).isDirectory())continue}catch{continue}u+=1;let r=await Xu(n,e);c.push(...r.dangling),l.push(...r.scanSkips)}return{hasWorkspaces:!0,memberCount:o.length,scannedNodeModulesRoots:u,dangling:c,scanSkips:l,ok:c.length===0}},Qu=async(e,t)=>{let n={removed:[],kept:[]};for(let r of t){let t=s(e,r.path);try{if(!(await g(t)).isSymbolicLink()){n.kept.push(r.path);continue}await b(t),n.kept.push(r.path)}catch(e){if(!Nu(e)||!qu.has(e.code)){n.kept.push(r.path);continue}await x(t),n.removed.push(r.path)}}return n},$u=async()=>{let e=process.cwd();Z(`正在扫描 ${e} 下的安装布局...`);try{let t=await Zu(e);if(!t.hasWorkspaces){Z(`未声明 workspaces,非 bun workspaces monorepo,跳过悬挂链接检测`);return}if(t.scanSkips.length>0){Q(`\n${t.scanSkips.length} 项目录读取降级告警,结论基于其余可读目录:`);for(let e of t.scanSkips)Q(` ${e.path} 读取失败已跳过该子树,错误码 ${e.code}`)}if(Z(`workspaces 成员 ${t.memberCount} 个,扫描 ${t.scannedNodeModulesRoots} 个 node_modules 树`),t.dangling.length>0){Z(`\n发现 ${t.dangling.length} 根悬挂符号链接:`);for(let e of t.dangling)Z(` ${e.path} 指向已不存在的 ${e.target}`);Z(`
191
191
  修复指引: 执行 lzi-bun-cli node-links fix 回收悬挂死链后重试,有效链接零触碰`),process.exit(Math.min(t.dangling.length,255))}Z(`安装布局一致,未发现悬挂符号链接`)}catch(e){Q(`错误: ${e instanceof Error?e.message:String(e)}`),process.exit(1)}},ed=async()=>{let e=process.cwd();Z(`正在扫描 ${e} 下的悬挂符号链接...`);try{let t=await Zu(e);if(!t.hasWorkspaces){Z(`未声明 workspaces,非 bun workspaces monorepo,跳过悬挂链接回收`);return}if(t.dangling.length===0){Z(`未发现悬挂符号链接,无需回收,共巡查 ${t.scannedNodeModulesRoots} 个 node_modules 树`);return}Z(`发现 ${t.dangling.length} 根悬挂符号链接,开始回收:`);for(let e of t.dangling)Z(` ${e.path} 指向已不存在的 ${e.target}`);let n=await Qu(e,t.dangling);for(let e of n.removed)Z(`已回收 ${e}`);for(let e of n.kept)Q(`未能回收 ${e},链接状态已变化,请人工确认`);let r=await Zu(e);Z(`回收完成,清除 ${n.removed.length} 根,剩余悬挂 ${r.dangling.length} 根,有效链接零触碰`),(r.dangling.length>0||n.kept.length>0)&&process.exit(1)}catch(e){Q(`错误: ${e instanceof Error?e.message:String(e)}`),process.exit(1)}},$=`https://registry.npmjs.org/`,td=/* @__PURE__ */ new Map([[`longzai-intelligence`,$],[`longzai-intelligence-agent-tools`,$],[`longzai-intelligence-audit`,$],[`longzai-intelligence-auth`,$],[`longzai-intelligence-builder`,$],[`longzai-intelligence-bun`,$],[`longzai-intelligence-cache`,$],[`longzai-intelligence-cli`,$],[`longzai-intelligence-config`,$],[`longzai-intelligence-design-system`,$],[`longzai-intelligence-dev-tools`,$],[`longzai-intelligence-electron`,$],[`longzai-intelligence-error`,$],[`longzai-intelligence-event-bus`,$],[`longzai-intelligence-logger`,$],[`longzai-intelligence-okr`,$],[`longzai-intelligence-oxfmt`,$],[`longzai-intelligence-oxlint`,$],[`longzai-intelligence-plugin`,$],[`longzai-intelligence-shared-config`,$],[`longzai-intelligence-shared-kernel`,$],[`longzai-intelligence-scripts`,$],[`longzai-intelligence-standards`,$],[`longzai-intelligence-transport`,$],[`longzai-intelligence-typescript`,$],[`longzai-intelligence-vscode`,$],[`longzai-intelligence-zod`,$],[`longzai-intelligence-prettier`,$],[`longzai-intelligence-tsdown`,$],[`longzai-intelligence-vitest`,$],[`longzai-intelligence-academy`,$],[`longzai-intelligence-accounting`,$],[`longzai-intelligence-activity`,$],[`longzai-intelligence-administration`,$],[`longzai-intelligence-agent`,$],[`longzai-intelligence-agent-collaboration`,$],[`longzai-intelligence-agent-endless`,$],[`longzai-intelligence-agent-migrator`,$],[`longzai-intelligence-agent-prompts`,$],[`longzai-intelligence-agent-relation`,$],[`longzai-intelligence-agent-session`,$],[`longzai-intelligence-agent-swarm`,$],[`longzai-intelligence-agent-ui`,$],[`longzai-intelligence-analytics`,$],[`longzai-intelligence-api`,$],[`longzai-intelligence-app-gallery`,$],[`longzai-intelligence-app-store`,$],[`longzai-intelligence-architecture`,$],[`longzai-intelligence-architecture-expert`,$],[`longzai-intelligence-arkts`,$],[`longzai-intelligence-art`,$],[`longzai-intelligence-artifact`,$],[`longzai-intelligence-artifact-registry`,$],[`longzai-intelligence-arxiv`,$],[`longzai-intelligence-arxiv-data`,$],[`longzai-intelligence-arxiv-markdown`,$],[`longzai-intelligence-atomic`,$],[`longzai-intelligence-attention`,$],[`longzai-intelligence-audio`,$],[`longzai-intelligence-audio-assistant`,$],[`longzai-intelligence-augmented-reality`,$],[`longzai-intelligence-auto-research`,$],[`longzai-intelligence-automate`,$],[`longzai-intelligence-benchmark`,$],[`longzai-intelligence-bilibili`,$],[`longzai-intelligence-bilibili-data`,$],[`longzai-intelligence-bilibili-markdown`,$],[`longzai-intelligence-billing`,$],[`longzai-intelligence-blackboard`,$],[`longzai-intelligence-blackboard-data`,$],[`longzai-intelligence-blackboard-markdown`,$],[`longzai-intelligence-bluetooth`,$],[`longzai-intelligence-board`,$],[`longzai-intelligence-bounty-registry`,$],[`longzai-intelligence-brawl-stars`,$],[`longzai-intelligence-broker`,$],[`longzai-intelligence-business-plan`,$],[`longzai-intelligence-calendar`,$],[`longzai-intelligence-camera`,$],[`longzai-intelligence-canvas`,$],[`longzai-intelligence-capture`,$],[`longzai-intelligence-change-maker`,$],[`longzai-intelligence-changelog`,$],[`longzai-intelligence-changeset`,$],[`longzai-intelligence-chat`,$],[`longzai-intelligence-chess`,$],[`longzai-intelligence-circuit`,$],[`longzai-intelligence-claude-code`,$],[`longzai-intelligence-clipboard-share`,$],[`longzai-intelligence-closed-loop`,$],[`longzai-intelligence-closed-loop-data`,$],[`longzai-intelligence-closed-loop-markdown`,$],[`longzai-intelligence-cloud`,$],[`longzai-intelligence-code`,$],[`longzai-intelligence-code-agent`,$],[`longzai-intelligence-code-reviewer`,$],[`longzai-intelligence-codebase-research`,$],[`longzai-intelligence-coding-expert`,$],[`longzai-intelligence-collaboration`,$],[`longzai-intelligence-collective`,$],[`longzai-intelligence-commerce`,$],[`longzai-intelligence-commit`,$],[`longzai-intelligence-competition-registry`,$],[`longzai-intelligence-composer`,$],[`longzai-intelligence-concrete`,$],[`longzai-intelligence-concrete-industry`,$],[`longzai-intelligence-config-registry`,$],[`longzai-intelligence-context`,$],[`longzai-intelligence-contract`,$],[`longzai-intelligence-contract-parity`,$],[`longzai-intelligence-cookery`,$],[`longzai-intelligence-country`,$],[`longzai-intelligence-creativity`,$],[`longzai-intelligence-cross-platform`,$],[`longzai-intelligence-crossref`,$],[`longzai-intelligence-crossref-markdown`,$],[`longzai-intelligence-crypto`,$],[`longzai-intelligence-customer-service`,$],[`longzai-intelligence-cut`,$],[`longzai-intelligence-dag`,$],[`longzai-intelligence-dashboard`,$],[`longzai-intelligence-data`,$],[`longzai-intelligence-data-science`,$],[`longzai-intelligence-database`,$],[`longzai-intelligence-decenterlization`,$],[`longzai-intelligence-decision`,$],[`longzai-intelligence-deepseek`,$],[`longzai-intelligence-deepseek-harness`,$],[`longzai-intelligence-deepseek-harness-knowledge`,$],[`longzai-intelligence-delta`,$],[`longzai-intelligence-design`,$],[`longzai-intelligence-design-lab`,$],[`longzai-intelligence-device`,$],[`longzai-intelligence-discipline`,$],[`longzai-intelligence-discovery`,$],[`longzai-intelligence-disk-space`,$],[`longzai-intelligence-disk-space-data`,$],[`longzai-intelligence-disk-space-markdown`,$],[`longzai-intelligence-distill`,$],[`longzai-intelligence-docs`,$],[`longzai-intelligence-docs-registry`,$],[`longzai-intelligence-document`,$],[`longzai-intelligence-douyin`,$],[`longzai-intelligence-douyin-data`,$],[`longzai-intelligence-douyin-markdown`,$],[`longzai-intelligence-drone`,$],[`longzai-intelligence-edge`,$],[`longzai-intelligence-electrobun`,$],[`longzai-intelligence-elysia`,$],[`longzai-intelligence-embodied`,$],[`longzai-intelligence-empowerment`,$],[`longzai-intelligence-engineering`,$],[`longzai-intelligence-env`,$],[`longzai-intelligence-env-registry`,$],[`longzai-intelligence-equilibrium`,$],[`longzai-intelligence-eslint`,$],[`longzai-intelligence-event`,$],[`longzai-intelligence-event-tracking`,$],[`longzai-intelligence-evolution`,$],[`longzai-intelligence-excel`,$],[`longzai-intelligence-exchange-rate`,$],[`longzai-intelligence-execution`,$],[`longzai-intelligence-experience`,$],[`longzai-intelligence-expert`,$],[`longzai-intelligence-expert-thinking`,$],[`longzai-intelligence-fde`,$],[`longzai-intelligence-feature-flags`,$],[`longzai-intelligence-features`,$],[`longzai-intelligence-federation`,$],[`longzai-intelligence-feed`,$],[`longzai-intelligence-feishu`,$],[`longzai-intelligence-file-processing`,$],[`longzai-intelligence-fitness`,$],[`longzai-intelligence-font`,$],[`longzai-intelligence-game`,$],[`longzai-intelligence-game-studio`,$],[`longzai-intelligence-gantt`,$],[`longzai-intelligence-gateway`,$],[`longzai-intelligence-geo`,$],[`longzai-intelligence-gesture`,$],[`longzai-intelligence-git`,$],[`longzai-intelligence-git-insight`,$],[`longzai-intelligence-gitcode`,$],[`longzai-intelligence-github-data`,$],[`longzai-intelligence-github-markdown`,$],[`longzai-intelligence-github-trending`,$],[`longzai-intelligence-github-trending-data`,$],[`longzai-intelligence-github-trending-markdown`,$],[`longzai-intelligence-globals`,$],[`longzai-intelligence-growth`,$],[`longzai-intelligence-growth-registry`,$],[`longzai-intelligence-handover`,$],[`longzai-intelligence-hardware`,$],[`longzai-intelligence-harness`,$],[`longzai-intelligence-healthcare`,$],[`longzai-intelligence-history`,$],[`longzai-intelligence-horizon`,$],[`longzai-intelligence-human-resource`,$],[`longzai-intelligence-i18n`,$],[`longzai-intelligence-idea`,$],[`longzai-intelligence-identity`,$],[`longzai-intelligence-ime`,$],[`longzai-intelligence-impact-maker`,$],[`longzai-intelligence-insight`,$],[`longzai-intelligence-intellectual-property`,$],[`longzai-intelligence-intent`,$],[`longzai-intelligence-intentionomics`,$],[`longzai-intelligence-interview`,$],[`longzai-intelligence-issues`,$],[`longzai-intelligence-jev`,$],[`longzai-intelligence-jev-knowledge`,$],[`longzai-intelligence-jev-system`,$],[`longzai-intelligence-journal-of-finance-data`,$],[`longzai-intelligence-journal-of-financial-and-quantitative-analysis-data`,$],[`longzai-intelligence-journal-of-financial-economics-data`,$],[`longzai-intelligence-key-management`,$],[`longzai-intelligence-knowledge`,$],[`longzai-intelligence-knowledge-graph`,$],[`longzai-intelligence-knowledge-markdown`,$],[`longzai-intelligence-kol`,$],[`longzai-intelligence-kol-data`,$],[`longzai-intelligence-kol-markdown`,$],[`longzai-intelligence-kol-registry`,$],[`longzai-intelligence-language-model`,$],[`longzai-intelligence-law`,$],[`longzai-intelligence-law-data`,$],[`longzai-intelligence-law-markdown`,$],[`longzai-intelligence-lean`,$],[`longzai-intelligence-legal`,$],[`longzai-intelligence-liquid-glass`,$],[`longzai-intelligence-living-previewer`,$],[`longzai-intelligence-loop`,$],[`longzai-intelligence-machine-learning`,$],[`longzai-intelligence-mail`,$],[`longzai-intelligence-mandala`,$],[`longzai-intelligence-map`,$],[`longzai-intelligence-markdown`,$],[`longzai-intelligence-marketing`,$],[`longzai-intelligence-marketplace`,$],[`longzai-intelligence-math`,$],[`longzai-intelligence-mcn`,$],[`longzai-intelligence-mcp`,$],[`longzai-intelligence-media`,$],[`longzai-intelligence-meditation`,$],[`longzai-intelligence-memory`,$],[`longzai-intelligence-mentor`,$],[`longzai-intelligence-messaging`,$],[`longzai-intelligence-mindset`,$],[`longzai-intelligence-minimax-knowldege`,$],[`longzai-intelligence-mission-control`,$],[`longzai-intelligence-model-fusion`,$],[`longzai-intelligence-model-gateway`,$],[`longzai-intelligence-moment`,$],[`longzai-intelligence-montage`,$],[`longzai-intelligence-movie`,$],[`longzai-intelligence-music-video`,$],[`longzai-intelligence-music-video-data`,$],[`longzai-intelligence-narrative-analyzer`,$],[`longzai-intelligence-nation`,$],[`longzai-intelligence-nginx`,$],[`longzai-intelligence-notification`,$],[`longzai-intelligence-npm`,$],[`longzai-intelligence-npm-registry`,$],[`longzai-intelligence-npm-registry-data`,$],[`longzai-intelligence-observability`,$],[`longzai-intelligence-office-industry`,$],[`longzai-intelligence-okr-data`,$],[`longzai-intelligence-okr-markdown`,$],[`longzai-intelligence-older`,$],[`longzai-intelligence-one`,$],[`longzai-intelligence-one-digest`,$],[`longzai-intelligence-one-digest-data`,$],[`longzai-intelligence-one-digest-markdown`,$],[`longzai-intelligence-one-digest-registry`,$],[`longzai-intelligence-one-trae-works`,$],[`longzai-intelligence-ontology`,$],[`longzai-intelligence-open-pencil`,$],[`longzai-intelligence-open-router`,$],[`longzai-intelligence-open-router-data`,$],[`longzai-intelligence-open-router-markdown`,$],[`longzai-intelligence-opencode`,$],[`longzai-intelligence-opportunity`,$],[`longzai-intelligence-orchestry`,$],[`longzai-intelligence-organization`,$],[`longzai-intelligence-orm`,$],[`longzai-intelligence-outfit`,$],[`longzai-intelligence-outsourcing`,$],[`longzai-intelligence-overseas`,$],[`longzai-intelligence-pagination`,$],[`longzai-intelligence-panel`,$],[`longzai-intelligence-paper-reader`,$],[`longzai-intelligence-parametric-industry`,$],[`longzai-intelligence-partner`,$],[`longzai-intelligence-pay`,$],[`longzai-intelligence-payment`,$],[`longzai-intelligence-permission`,$],[`longzai-intelligence-personal-assistant`,$],[`longzai-intelligence-pii`,$],[`longzai-intelligence-pipeline`,$],[`longzai-intelligence-policy-research`,$],[`longzai-intelligence-portal`,$],[`longzai-intelligence-previewer`,$],[`longzai-intelligence-prezi`,$],[`longzai-intelligence-prisma`,$],[`longzai-intelligence-product-requirement`,$],[`longzai-intelligence-product-research`,$],[`longzai-intelligence-programming-language`,$],[`longzai-intelligence-project`,$],[`longzai-intelligence-project-data`,$],[`longzai-intelligence-project-markdown`,$],[`longzai-intelligence-project-portfolio`,$],[`longzai-intelligence-project-registry`,$],[`longzai-intelligence-promotion`,$],[`longzai-intelligence-prospect`,$],[`longzai-intelligence-psychoanalyst`,$],[`longzai-intelligence-publication`,$],[`longzai-intelligence-qcloud`,$],[`longzai-intelligence-quant`,$],[`longzai-intelligence-queue`,$],[`longzai-intelligence-react-devtools`,$],[`longzai-intelligence-react-native`,$],[`longzai-intelligence-reading-shanhaijing`,$],[`longzai-intelligence-readme`,$],[`longzai-intelligence-reasoning`,$],[`longzai-intelligence-records`,$],[`longzai-intelligence-recruitment`,$],[`longzai-intelligence-release`,$],[`longzai-intelligence-release-markdown`,$],[`longzai-intelligence-reliability`,$],[`longzai-intelligence-remote-desktop`,$],[`longzai-intelligence-remotion`,$],[`longzai-intelligence-report`,$],[`longzai-intelligence-repository`,$],[`longzai-intelligence-repository-handover`,$],[`longzai-intelligence-resilience`,$],[`longzai-intelligence-reverse-engineering`,$],[`longzai-intelligence-review-of-financial-studies-data`,$],[`longzai-intelligence-reviewer`,$],[`longzai-intelligence-risk`,$],[`longzai-intelligence-roadmap`,$],[`longzai-intelligence-roadmap-data`,$],[`longzai-intelligence-roadmap-markdown`,$],[`longzai-intelligence-router`,$],[`longzai-intelligence-rss`,$],[`longzai-intelligence-rss-markdown`,$],[`longzai-intelligence-runtime`,$],[`longzai-intelligence-sales`,$],[`longzai-intelligence-scanner`,$],[`longzai-intelligence-schedule-markdown`,$],[`longzai-intelligence-schedule-registry`,$],[`longzai-intelligence-scheduler`,$],[`longzai-intelligence-schema`,$],[`longzai-intelligence-scope`,$],[`longzai-intelligence-scrape`,$],[`longzai-intelligence-search`,$],[`longzai-intelligence-security`,$],[`longzai-intelligence-security-bounty-registry`,$],[`longzai-intelligence-security-inventory`,$],[`longzai-intelligence-serverless`,$],[`longzai-intelligence-share`,$],[`longzai-intelligence-short-video`,$],[`longzai-intelligence-skill`,$],[`longzai-intelligence-slider`,$],[`longzai-intelligence-smart-transition`,$],[`longzai-intelligence-sms`,$],[`longzai-intelligence-software-factory`,$],[`longzai-intelligence-soul`,$],[`longzai-intelligence-specs`,$],[`longzai-intelligence-spline`,$],[`longzai-intelligence-sports`,$],[`longzai-intelligence-ssl`,$],[`longzai-intelligence-startup`,$],[`longzai-intelligence-storage`,$],[`longzai-intelligence-strategy`,$],[`longzai-intelligence-strategy-consulting`,$],[`longzai-intelligence-supply-chain`,$],[`longzai-intelligence-support`,$],[`longzai-intelligence-survey`,$],[`longzai-intelligence-talk`,$],[`longzai-intelligence-taro`,$],[`longzai-intelligence-task`,$],[`longzai-intelligence-task-data`,$],[`longzai-intelligence-task-markdown`,$],[`longzai-intelligence-telemetry`,$],[`longzai-intelligence-templates`,$],[`longzai-intelligence-tenant`,$],[`longzai-intelligence-testing`,$],[`longzai-intelligence-thinking`,$],[`longzai-intelligence-token-exchange`,$],[`longzai-intelligence-token-finance`,$],[`longzai-intelligence-token-handover`,$],[`longzai-intelligence-topology`,$],[`longzai-intelligence-tracking-nation`,$],[`longzai-intelligence-tracking-qbitai`,$],[`longzai-intelligence-tracking-terrytao`,$],[`longzai-intelligence-tracking-xiao-lin`,$],[`longzai-intelligence-tracking-yu-bo`,$],[`longzai-intelligence-trader`,$],[`longzai-intelligence-trae`,$],[`longzai-intelligence-training-data`,$],[`longzai-intelligence-translator`,$],[`longzai-intelligence-travel`,$],[`longzai-intelligence-trending`,$],[`longzai-intelligence-tsdoc`,$],[`longzai-intelligence-tsgo`,$],[`longzai-intelligence-twitter`,$],[`longzai-intelligence-twitter-data`,$],[`longzai-intelligence-twitter-markdown`,$],[`longzai-intelligence-typeorm`,$],[`longzai-intelligence-usecase`,$],[`longzai-intelligence-user-experience`,$],[`longzai-intelligence-user-research`,$],[`longzai-intelligence-userscript`,$],[`longzai-intelligence-utils`,$],[`longzai-intelligence-value-chain`,$],[`longzai-intelligence-vector-search`,$],[`longzai-intelligence-vendor`,$],[`longzai-intelligence-venture-capital`,$],[`longzai-intelligence-version`,$],[`longzai-intelligence-video-generation`,$],[`longzai-intelligence-video-player`,$],[`longzai-intelligence-voice`,$],[`longzai-intelligence-voice-recorder`,$],[`longzai-intelligence-vscode-developer`,$],[`longzai-intelligence-vuln`,$],[`longzai-intelligence-vuln-data`,$],[`longzai-intelligence-vuln-markdown`,$],[`longzai-intelligence-vuln-registry`,$],[`longzai-intelligence-warehouse`,$],[`longzai-intelligence-wealth`,$],[`longzai-intelligence-web3`,$],[`longzai-intelligence-webhook`,$],[`longzai-intelligence-websocket`,$],[`longzai-intelligence-wechat`,$],[`longzai-intelligence-wechat-miniprogram`,$],[`longzai-intelligence-wechat-pay`,$],[`longzai-intelligence-wifi`,$],[`longzai-intelligence-wiki`,$],[`longzai-intelligence-word`,$],[`longzai-intelligence-work`,$],[`longzai-intelligence-worker`,$],[`longzai-intelligence-workflow`,$],[`longzai-intelligence-workflow-data`,$],[`longzai-intelligence-workflow-markdown`,$],[`longzai-intelligence-workflow-registry`,$],[`longzai-intelligence-workspace`,$],[`longzai-intelligence-writer`,$],[`longzai-intelligence-xiaohongshu`,$],[`longzai-intelligence-xiaohongshu-data`,$],[`longzai-intelligence-xiaohongshu-markdown`,$],[`longzai-intelligence-youtube`,$],[`longzai-intelligence-youtube-data`,$],[`longzai-intelligence-youtube-markdown`,$],[`longzai-intelligence-zcode`,$],[`longzai-intelligence-zcode-security`,$],[`longzai-intelligence-zed-delta-knowledge`,$],[`longzai-intelligence-zhihu`,$],[`longzai-intelligence-zhihu-data`,$],[`longzai-intelligence-zhihu-markdown`,$]]),nd=`LZI_GLOBALS_ROOT`,rd=/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/;var id=class extends Error{details;constructor(e,t=`install.extraScopes`){super(`${t} 校验失败:\n${e.map(e=>`- ${e}`).join(`
192
- `)}`),this.name=`InstallScopesError`,this.details=e}};function ad(e){if(typeof e!=`string`)return!1;try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`}catch{return!1}}function od(e,t,n,r){let i=e instanceof Map?Object.fromEntries(e):{...e},a=[],o={};for(let[n,i]of Object.entries(t??{})){let t=n.replace(/^@+/,``);t.length===0||!rd.test(t)?a.push(`\`${n}\` 不是合法 scope 名(仅允许字母/数字开头,后接字母/数字与 . _ -,@ 前缀可省略)`):ad(i)?o[t]!==void 0&&o[t]!==i?a.push(`\`${t}\` 在 extraScopes 内重复声明且安装源不一致`):(e instanceof Map?e.has(t):Object.hasOwn(e,t))?a.push(`\`${t}\` 与预定义 scope 冲突(预定义不可覆盖,如需调整请在 ${r} 维护)`):o[t]=i:a.push(`\`${n}\` 的安装源 \`${String(i)}\` 不是合法的 http/https URL`)}let s=/* @__PURE__ */ new Set;for(let e of n??[]){let t=e.replace(/^@+/,``);t.length===0||!rd.test(t)?a.push(`\`${e}\` 不是合法 scope 名(仅允许字母/数字开头,后接字母/数字与 . _ -,@ 前缀可省略)`):o[t]===void 0?s.add(t):a.push(`\`${t}\` 同时出现在 extraScopes 与 privateScopes(追加公网安装源与私有轨声明矛盾)`)}if(a.length>0)throw new id(a);for(let[e,t]of Object.entries(o))i[e]=t;for(let e of s)delete i[e];return i}function sd(e,t,n,r){let i=od(e,t,n,`globals 仓 lzi-bun-install.config.ts`),a=r?.replace(/^@+/,``),o=new Set((n??[]).map(e=>e.replace(/^@+/,``)));return a!==void 0&&rd.test(a)&&!Object.hasOwn(i,a)&&!o.has(a)&&(i[a]=`https://registry.npmjs.org/`),i}function cd(e){let t=[];if(typeof e!=`object`||!e)throw new id([`default export 必须是对象({ scopes: { ... } })`],`globals 预设 lzi-bun-install.config.ts`);let n=typeof e==`object`&&e&&`scopes`in e?e.scopes:void 0;if(typeof n!=`object`||!n||Array.isArray(n))throw new id([`scopes 必须是 scope → registry 的对象映射`],`globals 预设 lzi-bun-install.config.ts`);let r={};for(let[e,i]of Object.entries(n))rd.test(e)?typeof i!=`string`||!ad(i)?t.push(`\`${e}\` 的安装源 \`${String(i)}\` 不是合法的 http/https URL`):r[e]=i:t.push(`\`${e}\` 不是合法 scope 名(仅允许字母/数字开头,后接字母/数字与 . _ -,不含 @ 前缀)`);if(t.length>0)throw new id(t,`globals 预设 lzi-bun-install.config.ts`);if(Object.keys(r).length===0)throw new id([`scopes 清单为空(真源不允许空清单)`],`globals 预设 lzi-bun-install.config.ts`);return r}var ld=class extends Error{configPath;constructor(e,t){super(e),this.name=`SharedConfigError`,this.configPath=t}},ud=class extends ld{searchFrom;constructor(e){super(`未在 ${e} 找到配置文件`,e),this.name=`SharedConfigNotFoundError`,this.searchFrom=e}},dd=class extends ld{issues;constructor(e,t){super(`配置校验失败,共 ${e.length} 个问题`,t),this.name=`SharedConfigValidationError`,this.issues=e}};function fd(e,t,n,r){let i=e;if(r.schema!==void 0){let e=r.schema.safeParse(i);if(!e.success)throw new dd(e.error.issues,t);i=e.data}return r.transform!==void 0&&(i=r.transform(i,n)),i}var pd=class extends ld{cause;constructor(e,t){super(`加载配置文件 ${e} 失败`,e),this.name=`SharedConfigLoadError`,this.cause=t}};function md(e){return typeof e==`object`&&!!e}function hd(e){return typeof e==`object`&&!!e}async function gd(e,t={}){let r=c(e);if(!n(r))throw new ud(r);let i;try{let e=await import(r);i=md(e)?e.default:void 0}catch(e){throw new pd(r,e)}if(i===void 0)throw new pd(r,TypeError(`配置文件缺少默认导出`));if(!hd(i))throw new pd(r,TypeError(`配置文件的默认导出必须是对象`));return{config:fd(i,r,o(r),t),configFilePath:r}}function _d(e=process.cwd()){let t=c(e);for(;;){let e=s(t,`lzi.config.ts`);if(n(e))return e;let r=o(t);if(r===t)return null;t=r}}async function vd(e={}){let t=e.cwd??process.cwd(),n=_d(t);if(n===null)throw new ud(t);let r=c(n,`..`),{config:i}=await gd(n);return{config:i,configPath:r,configFilePath:n}}function yd(e){return typeof e==`object`&&!!e}async function bd(e){let t;try{t=await v(e)}catch(t){throw new pd(e,t)}let n=t.filter(e=>e.endsWith(`.config.ts`)).sort();if(n.length===0)throw new pd(e,Error(`配置目录内没有 .config.ts 分片文件`));let r={};for(let t of n){let n=await gd(s(e,t));r={...r,...n.config}}let i=r;if(!yd(i))throw new pd(e,Error(`配置目录合并结果不是对象形态`));return i}function xd(e,t=process.cwd()){let n=Array.isArray(e)?e:[e],r=c(t);for(;;){for(let e of n){let t=s(r,e);if(Sd(t))return t}let e=o(r);if(e===r)return null;r=e}}function Sd(e){try{return i(e).isDirectory()}catch{return!1}}function Cd(e,t=process.cwd()){let r=Array.isArray(e)?e:[e],i=c(t);for(;;){for(let e of r){let t=s(i,e);if(n(t))return t}let e=o(i);if(e===i)return null;i=e}}function wd(e){return typeof e==`object`&&!!e}function Td(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}async function Ed(e={}){let t=e.cwd??c(process.cwd());if(e.explicitPath!==void 0){let t=await gd(e.explicitPath,{schema:e.schema,transform:e.transform});return{success:!0,config:t.config,source:`explicit`,configFilePath:t.configFilePath}}if(e.standaloneFile!==void 0){let n=Cd(e.standaloneFile,t);if(n!==null){let{config:t}=await gd(n);return{success:!0,config:fd(t,n,o(n),e),source:`standalone`,configFilePath:n}}}if(e.standaloneDir!==void 0){let n=xd(e.standaloneDir,t);if(n!==null)return{success:!0,config:fd(await bd(n),n,n,e),source:`standalone`,configFilePath:n}}if(e.unifiedField!==void 0){let n,r;try{let{config:i,configFilePath:a}=await vd({cwd:t}),o=i;n=Td(o)?o[e.unifiedField]:void 0,r=a}catch{}if(r!==void 0&&n!==void 0&&wd(n))return{success:!0,config:fd(n,r,o(r),e),source:`unified`,configFilePath:r}}return{success:!1,configFilePath:null}}const Dd=[`packages/*`,`apps/*`];function Od(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function kd(e){if(Array.isArray(e))return e.every(e=>typeof e==`string`)?e:void 0;if(Od(e)){let t=e.packages;if(Array.isArray(t)&&t.every(e=>typeof e==`string`))return{packages:t}}}function Ad(e){let t=c(e,`package.json`);if(!n(t))throw new ud(e);let i;try{let e=JSON.parse(r(t,`utf8`));i=Od(e)?kd(e.workspaces):void 0}catch(e){throw new pd(t,e)}let a=Array.isArray(i)?i:i?.packages;return a&&a.length>0?a:Dd}async function jd(e,t={}){let i=Ad(e),a=/* @__PURE__ */ new Set,o=[];for(let s of i){let i=new Bun.Glob(`${s}/package.json`);for await(let s of i.scan({cwd:e,absolute:!0,onlyFiles:!0})){let e=c(s,`..`);if(a.has(e))continue;let i;try{let e=JSON.parse(r(s,`utf8`));i=typeof e==`object`&&e?e:void 0}catch{continue}i!==void 0&&typeof i.name==`string`&&i.name.length!==0&&(t.configFileName!==void 0&&!n(c(e,t.configFileName))||(a.add(e),o.push({name:i.name,dir:e})))}}return o}var Md=class extends Error{bunfigPath;reason;constructor(e,t){super(`${e} 校验失败:${t};请运行 bun run bun-config:generate 后重试`),this.name=`BunfigDriftError`,this.bunfigPath=e,this.reason=t}},Nd=class extends Error{bunfigPath;constructor(e){super(`${e} 已存在且非 lzi-bun-cli 生成(缺少 @lzi-bun-cli 自动生成,请勿编辑 标记),如需 lzi-bun-cli 接管,请删除该文件或手动合并后重试`),this.name=`BunfigProtectedError`,this.bunfigPath=e}};function Pd(e){return`"${e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}"`}function Fd(e,t){let n=e.map(e=>Pd(e)),r=`[${n.join(`, `)}]`;return`${t} = `.length+r.length<=100?r:`[\n${n.map(e=>` ${e},`).join(`
193
- `)}\n]`}function Id(e){let t=[`registry = ${Pd(e.registry)}`],n=Rd(`linker`,e.linker);n&&t.push(n);let r=Rd(`globalStore`,e.globalStore);r&&t.push(r);let i=Object.entries(e.scopes).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>`${Pd(`@${e}`)} = ${Pd(t)}`),a=[`[install]\n${t.join(`
192
+ `)}`),this.name=`InstallScopesError`,this.details=e}};function ad(e){if(typeof e!=`string`)return!1;try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`}catch{return!1}}function od(e,t,n,r){let i=e instanceof Map?Object.fromEntries(e):{...e},a=[],o={};for(let[n,i]of Object.entries(t??{})){let t=n.replace(/^@+/,``);t.length===0||!rd.test(t)?a.push(`\`${n}\` 不是合法 scope 名(仅允许字母/数字开头,后接字母/数字与 . _ -,@ 前缀可省略)`):ad(i)?o[t]!==void 0&&o[t]!==i?a.push(`\`${t}\` 在 extraScopes 内重复声明且安装源不一致`):(e instanceof Map?e.has(t):Object.hasOwn(e,t))?a.push(`\`${t}\` 与预定义 scope 冲突(预定义不可覆盖,如需调整请在 ${r} 维护)`):o[t]=i:a.push(`\`${n}\` 的安装源 \`${String(i)}\` 不是合法的 http/https URL`)}let s=/* @__PURE__ */ new Set;for(let e of n??[]){let t=e.replace(/^@+/,``);t.length===0||!rd.test(t)?a.push(`\`${e}\` 不是合法 scope 名(仅允许字母/数字开头,后接字母/数字与 . _ -,@ 前缀可省略)`):o[t]===void 0?s.add(t):a.push(`\`${t}\` 同时出现在 extraScopes 与 privateScopes(追加公网安装源与私有轨声明矛盾)`)}if(a.length>0)throw new id(a);for(let[e,t]of Object.entries(o))i[e]=t;for(let e of s)delete i[e];return i}function sd(e,t,n,r){let i=od(e,t,n,`globals 仓 lzi-bun-install.config.ts`),a=r?.replace(/^@+/,``),o=new Set((n??[]).map(e=>e.replace(/^@+/,``)));return a!==void 0&&rd.test(a)&&!Object.hasOwn(i,a)&&!o.has(a)&&(i[a]=`https://registry.npmjs.org/`),i}function cd(e){let t=[];if(typeof e!=`object`||!e)throw new id([`default export 必须是对象({ scopes: { ... } })`],`globals 预设 lzi-bun-install.config.ts`);let n=typeof e==`object`&&e&&`scopes`in e?e.scopes:void 0;if(typeof n!=`object`||!n||Array.isArray(n))throw new id([`scopes 必须是 scope → registry 的对象映射`],`globals 预设 lzi-bun-install.config.ts`);let r={};for(let[e,i]of Object.entries(n))rd.test(e)?typeof i!=`string`||!ad(i)?t.push(`\`${e}\` 的安装源 \`${String(i)}\` 不是合法的 http/https URL`):r[e]=i:t.push(`\`${e}\` 不是合法 scope 名(仅允许字母/数字开头,后接字母/数字与 . _ -,不含 @ 前缀)`);if(t.length>0)throw new id(t,`globals 预设 lzi-bun-install.config.ts`);if(Object.keys(r).length===0)throw new id([`scopes 清单为空(真源不允许空清单)`],`globals 预设 lzi-bun-install.config.ts`);return r}var ld=class extends Error{configPath;constructor(e,t,n){super(e,n),this.name=`SharedConfigError`,this.configPath=t}},ud=class extends ld{searchFrom;constructor(e){super(`未在 ${e} 找到配置文件`,e),this.name=`SharedConfigNotFoundError`,this.searchFrom=e}},dd=class extends ld{issues;constructor(e,t){super(`配置校验失败,共 ${e.length} 个问题`,t),this.name=`SharedConfigValidationError`,this.issues=e}};function fd(e,t,n,r){let i=e;if(r.schema!==void 0){let e=r.schema.safeParse(i);if(!e.success)throw new dd(e.error.issues,t);i=e.data}return r.transform!==void 0&&(i=r.transform(i,n)),i}function pd(e){return e instanceof Error&&e.message.length>0?`,底层原因为 ${e.name}: ${e.message}`:``}var md=class extends ld{cause;constructor(e,t){super(`加载配置文件 ${e} 失败${pd(t)}`,e,{cause:t}),this.name=`SharedConfigLoadError`,this.cause=t}};function hd(e){return typeof e==`object`&&!!e}function gd(e){return typeof e==`object`&&!!e}async function _d(e,t={}){let r=c(e);if(!n(r))throw new ud(r);let i;try{let e=await import(r);i=hd(e)?e.default:void 0}catch(e){throw new md(r,e)}if(i===void 0)throw new md(r,TypeError(`配置文件缺少默认导出`));if(!gd(i))throw new md(r,TypeError(`配置文件的默认导出必须是对象`));return{config:fd(i,r,o(r),t),configFilePath:r}}function vd(e=process.cwd()){let t=c(e);for(;;){let e=s(t,`lzi.config.ts`);if(n(e))return e;let r=o(t);if(r===t)return null;t=r}}async function yd(e={}){let t=e.cwd??process.cwd(),n=vd(t);if(n===null)throw new ud(t);let r=c(n,`..`),{config:i}=await _d(n);return{config:i,configPath:r,configFilePath:n}}function bd(e){return typeof e==`object`&&!!e}async function xd(e){let t;try{t=await v(e)}catch(t){throw new md(e,t)}let n=t.filter(e=>e.endsWith(`.config.ts`)).sort();if(n.length===0)throw new md(e,Error(`配置目录内没有 .config.ts 分片文件`));let r={};for(let t of n){let n=await _d(s(e,t));r={...r,...n.config}}let i=r;if(!bd(i))throw new md(e,Error(`配置目录合并结果不是对象形态`));return i}function Sd(e,t=process.cwd()){let n=Array.isArray(e)?e:[e],r=c(t);for(;;){for(let e of n){let t=s(r,e);if(Cd(t))return t}let e=o(r);if(e===r)return null;r=e}}function Cd(e){try{return i(e).isDirectory()}catch{return!1}}function wd(e,t=process.cwd()){let r=Array.isArray(e)?e:[e],i=c(t);for(;;){for(let e of r){let t=s(i,e);if(n(t))return t}let e=o(i);if(e===i)return null;i=e}}function Td(e){return typeof e==`object`&&!!e}function Ed(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}async function Dd(e={}){let t=e.cwd??c(process.cwd());if(e.explicitPath!==void 0){let t=await _d(e.explicitPath,{schema:e.schema,transform:e.transform});return{success:!0,config:t.config,source:`explicit`,configFilePath:t.configFilePath}}if(e.standaloneFile!==void 0){let n=wd(e.standaloneFile,t);if(n!==null){let{config:t}=await _d(n);return{success:!0,config:fd(t,n,o(n),e),source:`standalone`,configFilePath:n}}}if(e.standaloneDir!==void 0){let n=Sd(e.standaloneDir,t);if(n!==null)return{success:!0,config:fd(await xd(n),n,n,e),source:`standalone`,configFilePath:n}}if(e.unifiedField!==void 0){let n,r;try{let{config:i,configFilePath:a}=await yd({cwd:t}),o=i;n=Ed(o)?o[e.unifiedField]:void 0,r=a}catch(e){if(!(e instanceof ud))throw e}if(r!==void 0&&n!==void 0&&Td(n))return{success:!0,config:fd(n,r,o(r),e),source:`unified`,configFilePath:r}}return{success:!1,configFilePath:null}}const Od=[`packages/*`,`apps/*`];function kd(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ad(e){if(Array.isArray(e))return e.every(e=>typeof e==`string`)?e:void 0;if(kd(e)){let t=e.packages;if(Array.isArray(t)&&t.every(e=>typeof e==`string`))return{packages:t}}}function jd(e){let t=c(e,`package.json`);if(!n(t))throw new ud(e);let i;try{let e=JSON.parse(r(t,`utf8`));i=kd(e)?Ad(e.workspaces):void 0}catch(e){throw new md(t,e)}let a=Array.isArray(i)?i:i?.packages;return a&&a.length>0?a:Od}async function Md(e,t={}){let i=jd(e),a=/* @__PURE__ */ new Set,o=[];for(let s of i){let i=new Bun.Glob(`${s}/package.json`);for await(let s of i.scan({cwd:e,absolute:!0,onlyFiles:!0})){let e=c(s,`..`);if(a.has(e))continue;let i;try{let e=JSON.parse(r(s,`utf8`));i=typeof e==`object`&&e?e:void 0}catch{continue}i!==void 0&&typeof i.name==`string`&&i.name.length!==0&&(t.configFileName!==void 0&&!n(c(e,t.configFileName))||(a.add(e),o.push({name:i.name,dir:e})))}}return o}var Nd=class extends Error{bunfigPath;reason;constructor(e,t){super(`${e} 校验失败:${t};请运行 bun run bun-config:generate 后重试`),this.name=`BunfigDriftError`,this.bunfigPath=e,this.reason=t}},Pd=class extends Error{bunfigPath;constructor(e){super(`${e} 已存在且非 lzi-bun-cli 生成(缺少 @lzi-bun-cli 自动生成,请勿编辑 标记),如需 lzi-bun-cli 接管,请删除该文件或手动合并后重试`),this.name=`BunfigProtectedError`,this.bunfigPath=e}};function Fd(e){return`"${e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}"`}function Id(e,t){let n=e.map(e=>Fd(e)),r=`[${n.join(`, `)}]`;return`${t} = `.length+r.length<=100?r:`[\n${n.map(e=>` ${e},`).join(`
193
+ `)}\n]`}function Ld(e){let t=[`registry = ${Fd(e.registry)}`],n=zd(`linker`,e.linker);n&&t.push(n);let r=zd(`globalStore`,e.globalStore);r&&t.push(r);let i=Object.entries(e.scopes).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>`${Fd(`@${e}`)} = ${Fd(t)}`),a=[`[install]\n${t.join(`
194
194
  `)}`];return i.length>0&&a.push(`[install.scopes]\n${i.join(`
195
195
  `)}`),a.join(`
196
196
 
197
- `)}function Ld(e,t,n){return{registry:`https://mirrors.cloud.tencent.com/npm/`,scopes:sd(t,e?.extraScopes,e?.privateScopes,n),linker:e?.linker,globalStore:e?.globalStore}}function Rd(e,t){if(t!==void 0){if(typeof t==`boolean`||typeof t==`number`)return`${e} = ${t}`;if(typeof t==`string`)return`${e} = ${Pd(t)}`;if(Array.isArray(t))return t.length===0?void 0:`${e} = ${Fd(t,e)}`}}function zd(e){let t=[];e.install&&t.push(Id(e.install));let n=e.test,r=[],i=Rd(`preload`,n.preload);i&&r.push(i);let a=Rd(`coverage`,n.coverage);a&&r.push(a);let o=Rd(`coverageSkipTestFiles`,n.coverageSkipTestFiles);o&&r.push(o);let s=Rd(`coverageReporter`,n.coverageReporter);s&&r.push(s);let c=Rd(`coverageDir`,n.coverageDir);c&&r.push(c);let l=Rd(`coveragePathIgnorePatterns`,n.coveragePathIgnorePatterns);l&&r.push(l);let u=Rd(`coverageIgnoreSourcemaps`,n.coverageIgnoreSourcemaps);u&&r.push(u);let d=Rd(`timeout`,n.timeout);return d&&r.push(d),r.length>0&&t.push(`[test]\n${r.join(`
197
+ `)}function Rd(e,t,n){return{registry:`https://mirrors.cloud.tencent.com/npm/`,scopes:sd(t,e?.extraScopes,e?.privateScopes,n),linker:e?.linker,globalStore:e?.globalStore}}function zd(e,t){if(t!==void 0){if(typeof t==`boolean`||typeof t==`number`)return`${e} = ${t}`;if(typeof t==`string`)return`${e} = ${Fd(t)}`;if(Array.isArray(t))return t.length===0?void 0:`${e} = ${Id(t,e)}`}}function Bd(e){let t=[];e.install&&t.push(Ld(e.install));let n=e.test,r=[],i=zd(`preload`,n.preload);i&&r.push(i);let a=zd(`coverage`,n.coverage);a&&r.push(a);let o=zd(`coverageSkipTestFiles`,n.coverageSkipTestFiles);o&&r.push(o);let s=zd(`coverageReporter`,n.coverageReporter);s&&r.push(s);let c=zd(`coverageDir`,n.coverageDir);c&&r.push(c);let l=zd(`coveragePathIgnorePatterns`,n.coveragePathIgnorePatterns);l&&r.push(l);let u=zd(`coverageIgnoreSourcemaps`,n.coverageIgnoreSourcemaps);u&&r.push(u);let d=zd(`timeout`,n.timeout);return d&&r.push(d),r.length>0&&t.push(`[test]\n${r.join(`
198
198
  `)}`),`# @lzi-bun-cli 自动生成,请勿编辑\n${t.join(`
199
199
 
200
- `)}\n`}function Bd(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=Ld(e?.install,t.installScopesPreset,t.selfScope)}return{content:zd(a),shouldWrite:!0}}function Vd(e){let t=0,n=0,r=0,i=0;for(let a of e.split(`
201
- `)){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 Hd(e){return typeof e==`number`?{lines:e,functions:e,statements:e}:{...e}}function Ud(e,t){if(!(t<=0))return e/t}function Wd(e,t){let n=Hd(t),r=Ud(e.linesHit,e.linesFound),i=Ud(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 Gd(e){return`${(e*100).toFixed(2)}%`}function Kd(e){return e.results.map(e=>{let t=e.actual===void 0?`无数据`:Gd(e.actual),n=e.actual===void 0||e.actual>=e.required?`通过`:`未达标`;return`${e.dimension} 覆盖率 ${t},阈值 ${Gd(e.required)},${n}`})}const qd=async(e=process.cwd())=>{let t=await Ed({cwd:e,standaloneFile:`lzi-bun.config.ts`,unifiedField:`bun`});return t.success?t.config:(Z(`提示: 未找到配置文件 lzi-bun.config.ts,使用默认配置`),{})};var Jd=class extends Error{constructor(e){super(e),this.name=`GlobalsUnresolvedError`}};const Yd=e=>`已配置的 globals 定位未能命中(longzai-intelligence-globals),已尝试:\n ${e.join(`
202
- `)}\n请修正 ${nd} / --globals 的路径,或移除该配置以回落包内预设(LZI_SCOPES)`,Xd=e=>{try{return i(e).isDirectory()}catch{return!1}},Zd=(e={})=>{let t=process.env[nd],n=[...t!==void 0&&t!==``?[{source:`env`,path:c(t)}]:[],...e.explicitPath===void 0?[]:[{source:`explicit`,path:c(e.explicitPath)}]],r=[];for(let e of n)if(r.push(`${e.source}: ${e.path}`),Xd(e.path))return{ok:!0,resolution:{globalsRoot:e.path,source:e.source}};return{ok:!1,failure:{attempted:r}}},Qd=RegExp(`^${nd}=.*$`,`m`),$d=`${nd}=/absolute/path/to/longzai-intelligence-globals`,ef=(e,t)=>{let i=s(e,`.env`),o=`${nd}=${t}`;if(n(i)){let e=r(i,`utf8`);if(Qd.test(e)){let t=e.replace(Qd,o);t!==e&&a(i,t,`utf8`)}else{let t=e.endsWith(`
200
+ `)}\n`}function Vd(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=Rd(e?.install,t.installScopesPreset,t.selfScope)}return{content:Bd(a),shouldWrite:!0}}function Hd(e){let t=0,n=0,r=0,i=0;for(let a of e.split(`
201
+ `)){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 Ud(e){return typeof e==`number`?{lines:e,functions:e,statements:e}:{...e}}function Wd(e,t){if(!(t<=0))return e/t}function Gd(e,t){let n=Ud(t),r=Wd(e.linesHit,e.linesFound),i=Wd(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 Kd(e){return`${(e*100).toFixed(2)}%`}function qd(e){return e.results.map(e=>{let t=e.actual===void 0?`无数据`:Kd(e.actual),n=e.actual===void 0||e.actual>=e.required?`通过`:`未达标`;return`${e.dimension} 覆盖率 ${t},阈值 ${Kd(e.required)},${n}`})}const Jd=async(e=process.cwd())=>{let t=await Dd({cwd:e,standaloneFile:`lzi-bun.config.ts`,unifiedField:`bun`});return t.success?t.config:(Z(`提示: 未找到配置文件 lzi-bun.config.ts,使用默认配置`),{})};var Yd=class extends Error{constructor(e){super(e),this.name=`GlobalsUnresolvedError`}};const Xd=e=>`已配置的 globals 定位未能命中(longzai-intelligence-globals),已尝试:\n ${e.join(`
202
+ `)}\n请修正 ${nd} / --globals 的路径,或移除该配置以回落包内预设(LZI_SCOPES)`,Zd=e=>{try{return i(e).isDirectory()}catch{return!1}},Qd=(e={})=>{let t=process.env[nd],n=[...t!==void 0&&t!==``?[{source:`env`,path:c(t)}]:[],...e.explicitPath===void 0?[]:[{source:`explicit`,path:c(e.explicitPath)}]],r=[];for(let e of n)if(r.push(`${e.source}: ${e.path}`),Zd(e.path))return{ok:!0,resolution:{globalsRoot:e.path,source:e.source}};return{ok:!1,failure:{attempted:r}}},$d=RegExp(`^${nd}=.*$`,`m`),ef=`${nd}=/absolute/path/to/longzai-intelligence-globals`,tf=(e,t)=>{let i=s(e,`.env`),o=`${nd}=${t}`;if(n(i)){let e=r(i,`utf8`);if($d.test(e)){let t=e.replace($d,o);t!==e&&a(i,t,`utf8`)}else{let t=e.endsWith(`
203
203
  `)||e.length===0?e:`${e}\n`;a(i,`${t}${o}\n`,`utf8`)}}else a(i,`${o}\n`,`utf8`);let c=s(e,`.env.example`);if(n(c)){let e=r(c,`utf8`);if(!e.includes(`LZI_GLOBALS_ROOT=`)){let t=e.endsWith(`
204
- `)||e.length===0?e:`${e}\n`;a(c,`${t}${$d}\n`,`utf8`)}}else a(c,`${$d}\n`,`utf8`)},tf=async e=>cd((await gd(s(e,`lzi-bun-install.config.ts`))).config),nf=async(e={})=>{let t=Zd({explicitPath:e.explicitPath});if(t.ok)return{presetScopes:await tf(t.resolution.globalsRoot),source:`globals`};if(t.failure.attempted.length===0)return{presetScopes:Object.fromEntries(td),source:`preset`};throw new Jd(Yd(t.failure.attempted))},rf=e=>typeof e==`object`&&!!e&&!Array.isArray(e),af=e=>Array.isArray(e)||typeof e==`object`&&!!e&&`packages`in e,of=e=>{let t=s(e,`package.json`);if(!n(t))return`missing-package-json`;let i;try{i=JSON.parse(r(t,`utf8`))}catch{return`not-root`}return rf(i)&&af(i.workspaces)?`root`:`not-root`},sf=e=>of(e)===`root`,cf=(e,t)=>{let n=s(e,`package.json`);try{let e=JSON.parse(r(n,`utf8`));if(rf(e)){let t=e.name;if(typeof t==`string`&&t!==``)return t}}catch{}return t},lf=e=>{let t=e.indexOf(`/`);if(!(!e.startsWith(`@`)||t<=1))return e.slice(1,t)},uf=[`src/**/*.test.ts`,`src/**/*.test.tsx`,`__tests__/**/*.test.ts`];function df(e){let t=[`bun`,`test`];return e.watch===!0&&t.push(`--watch`),e.coverage===!0&&t.push(`--coverage`),e.extra&&e.extra.length>0&&t.push(...e.extra),t}async function ff(e){let t=/* @__PURE__ */ new Set;for(let n of e){let e=new Bun.Glob(n);for await(let n of e.scan({cwd:process.cwd(),onlyFiles:!0}))t.add(n)}return t.size}const pf=(e,t,n)=>{let r=e.split(`
204
+ `)||e.length===0?e:`${e}\n`;a(c,`${t}${ef}\n`,`utf8`)}}else a(c,`${ef}\n`,`utf8`)},nf=async e=>cd((await _d(s(e,`lzi-bun-install.config.ts`))).config),rf=async(e={})=>{let t=Qd({explicitPath:e.explicitPath});if(t.ok)return{presetScopes:await nf(t.resolution.globalsRoot),source:`globals`};if(t.failure.attempted.length===0)return{presetScopes:Object.fromEntries(td),source:`preset`};throw new Yd(Xd(t.failure.attempted))},af=e=>typeof e==`object`&&!!e&&!Array.isArray(e),of=e=>Array.isArray(e)||typeof e==`object`&&!!e&&`packages`in e,sf=e=>{let t=s(e,`package.json`);if(!n(t))return`missing-package-json`;let i;try{i=JSON.parse(r(t,`utf8`))}catch{return`not-root`}return af(i)&&of(i.workspaces)?`root`:`not-root`},cf=e=>sf(e)===`root`,lf=(e,t)=>{let n=s(e,`package.json`);try{let e=JSON.parse(r(n,`utf8`));if(af(e)){let t=e.name;if(typeof t==`string`&&t!==``)return t}}catch{}return t},uf=e=>{let t=e.indexOf(`/`);if(!(!e.startsWith(`@`)||t<=1))return e.slice(1,t)},df=[`src/**/*.test.ts`,`src/**/*.test.tsx`,`__tests__/**/*.test.ts`];function ff(e){let t=[`bun`,`test`];return e.watch===!0&&t.push(`--watch`),e.coverage===!0&&t.push(`--coverage`),e.extra&&e.extra.length>0&&t.push(...e.extra),t}async function pf(e){let t=/* @__PURE__ */ new Set;for(let n of e){let e=new Bun.Glob(n);for await(let n of e.scan({cwd:process.cwd(),onlyFiles:!0}))t.add(n)}return t.size}const mf=(e,t,n)=>{let r=e.split(`
205
205
  `),i=t.split(`
206
- `),a=0;for(;a<r.length&&a<i.length&&r[a]===i[a];)a++;let o=`第 ${a+1} 行不一致(磁盘 \`${r[a]??`<缺行>`}\` ≠ 预期 \`${i[a]??`<缺行>`}\`)`,s=n===void 0?void 0:`"@${n}" = `;return s!==void 0&&t.includes(s)&&!e.includes(s)?`${o},且本仓 scope @${n} 行在磁盘文件中缺位——bun publish 的 scope 映射优先级会使公网轨发布回退默认镜像源并以 missing authentication 失败(issue 0008)`:o},mf=async(e,t={})=>{let i=t.dir??process.cwd(),o=s(i,`bunfig.toml`),c=sf(i),l;c&&(l=(await nf({explicitPath:t.globalsPath})).presetScopes);let u=c?lf(cf(i,``)):void 0,d=Bd(e,{isRoot:c,installScopesPreset:l,selfScope:u});if(!d?.shouldWrite){if(t.dryRun&&Z(`(无 coverage 配置,不会生成 bunfig.toml)`),t.check===!0&&n(o))throw new Md(o,`该包无 coverage 配置,生成器判定不应存在 bunfig.toml(多余文件),请删除该文件`);return{status:`skipped`,bunfigPath:o}}if(t.dryRun)return Z(`[dry-run] 将写入 ${o}:`),Z(d.content),{status:`generated`,bunfigPath:o};if(t.check===!0){if(!n(o))throw new Md(o,u===void 0?`bunfig.toml 不存在(生成器预期应存在)`:`bunfig.toml 不存在,本仓 scope @${u} 未注入 [install.scopes]——bun publish 的 scope 映射优先级会使公网轨发布回退默认镜像源并以 missing authentication 失败(issue 0008)`);let e=r(o,`utf8`);if(!e.includes(`@lzi-bun-cli 自动生成,请勿编辑`))throw new Md(o,`bunfig.toml 为手写文件(无生成标记),不受 lzi-bun-cli 管理;如需接管请确认内容后删除该文件重新生成`);if(e!==d.content)throw new Md(o,pf(e,d.content,u));return Z(`校验通过 ${o}(与生成器预期一致)`),{status:`checked`,bunfigPath:o}}if(n(o)&&!r(o,`utf8`).includes(`@lzi-bun-cli 自动生成,请勿编辑`))throw new Nd(o);return a(o,d.content,`utf8`),Z(`已生成 ${o}(lzi-bun-cli 接管覆盖率配置)`),{status:`generated`,bunfigPath:o}},hf=e=>{let t=e?.test;if(t===void 0)return;let i=t.coverageThreshold;if(i===void 0)return;let a=s(process.cwd(),t.coverageDir??`coverage`,`lcov.info`);if(!n(a)){Z(`未找到覆盖率报告 ${a},跳过全局阈值判定`);return}let o=Wd(Vd(r(a,`utf8`)),i);if(o.passed)for(let e of Kd(o))Z(e);else{Q(`错误: 覆盖率全局汇总低于阈值`);for(let e of Kd(o))Q(e);process.exit(1)}},gf=async e=>{let t=await qd(),n=t.test?.passWithNoTests??!0;await ff(t.test?.include??uf)===0&&(n&&(Z(`无测试文件,跳过(type-only / facade 包,passWithNoTests)`),process.exit(0)),Q(`错误: 未找到测试文件,且 test.passWithNoTests 为 false`),Q(`(如该包确为 type-only / facade 包,请在 lzi-dev.config.ts 设置 test.passWithNoTests: true)`),process.exit(1));try{await mf(t)}catch(e){throw(e instanceof Nd||e instanceof id||e instanceof Jd)&&(Q(`错误: ${e.message}`),process.exit(1)),e}let r=df(e),i=await Bun.spawn(r,{cwd:process.cwd(),stdout:`inherit`,stderr:`inherit`}).exited;i!==0&&process.exit(i),hf(t)},_f=async(e,t,n)=>{let r=await qd();try{await mf(r,{dryRun:e,globalsPath:t,check:n})}catch(e){throw(e instanceof Nd||e instanceof Md||e instanceof id||e instanceof Jd)&&(Q(`错误: ${e.message}`),process.exit(1)),e}},vf=e=>{let t=of(e);t===`missing-package-json`&&(Q(`错误: 当前目录 ${e} 无 package.json,--recursive 须在 monorepo root 执行`),process.exit(1)),t!==`root`&&(Q(`错误: ${e} 的 package.json 未声明 workspaces 字段,--recursive 须在 monorepo root 执行`),process.exit(1))},yf=async(e,t,n)=>{let r=process.cwd();vf(r);let i=await jd(r,{configFileName:`lzi-bun.config.ts`}),a=[{name:cf(r,r.split(`/`).pop()??`root`),dir:r}];a.push(...i.map(e=>({name:e.name,dir:e.dir})));let o=n===!0?`校验`:e?`预览`:`生成`;Z(`发现 ${a.length} 个目标(root 1 + 子包 ${i.length}),开始${o}...`);let s=[];for(let r of a){Z(`▶ ${r.name}`);try{let i=await qd(r.dir),{status:a}=await mf(i,{dryRun:e,check:n,dir:r.dir,globalsPath:t});s.push({name:r.name,dir:r.dir,status:a})}catch(e){s.push({name:r.name,dir:r.dir,status:`failed`,reason:e instanceof Error?e.message:String(e)})}}let c=s.filter(e=>e.status===`generated`),l=s.filter(e=>e.status===`checked`),u=s.filter(e=>e.status===`skipped`),d=s.filter(e=>e.status===`failed`);if(Z(``),Z(`汇总:${c.length} 生成 / ${l.length} 一致 / ${u.length} 跳过 / ${d.length} 失败`),d.length>0){Q(``),Q(`失败子包:`);for(let e of d)Q(` - ${e.name}:${e.reason}`);process.exitCode=1}},bf=async e=>{let t=e.dryRun===!0,n=e.check===!0;if(t&&n&&(Q(`错误: --dry-run 与 --check 互斥(预览与校验是两种只读形态,请二选一)`),process.exit(1)),e.globalsPath!==void 0){let t=Zd({explicitPath:e.globalsPath});t.ok||(Q(`错误: ${Yd(t.failure.attempted)}`),process.exit(1));let{globalsRoot:n,source:r}=t.resolution;ef(process.cwd(),n),Z(`已定位 globals 仓(${r})并固化到 .env:${n}`)}e.recursive===!0?await yf(t,e.globalsPath,n):await _f(t,e.globalsPath,n)};function xf(e){Sf(e),Tf(e),Cf(e),wf(e)}function Sf(e){ul(e,{name:`test`,description:`运行 bun 测试(替代三件套,零测试包默认放行)`,options:[{flags:`--watch`,description:`监听模式(对应 test:watch)`},{flags:`--coverage`,description:`覆盖率(对应 test:coverage)`}],schema:xc({watch:pc().optional(),coverage:pc().optional()}),action:async(e,t)=>{await gf({watch:e.watch===!0,coverage:e.coverage===!0,extra:t})}})}function Cf(e){ul(e,{name:`lockfile check`,description:`校验单一 bun.lock 不变量与 workspaces 覆盖缺口`,schema:xc({}),action:async()=>{await Gu()}})}function wf(e){ul(e,{name:`node-links check`,description:`检测 node_modules 悬挂符号链接,命中即非零退出`,schema:xc({}),action:async()=>{await $u()}}),ul(e,{name:`node-links fix`,description:`回收 node_modules 悬挂死链,删除前复验,有效链接零触碰`,schema:xc({}),action:async()=>{await ed()}})}function Tf(e){ul(e,{name:`config generate`,description:`生成 bunfig.toml(不执行测试,支持 --dry-run 预览、--check 校验、-r 批量、--globals 定位)`,options:[{flags:`--dry-run`,description:`仅预览将写入的内容,不写盘`},{flags:`--check`,description:`仅校验磁盘 bunfig.toml 与生成器预期是否一致(漂移即报错退出,不写盘)`},{flags:`-r, --recursive`,description:`递归处理 monorepo 下含 lzi-bun.config.ts 的子包`},{flags:`--globals <path>`,description:`一次性 bootstrap 定位 globals 仓(命中后固化 .env,此后零参数)`}],schema:xc({dryRun:pc().optional(),check:pc().optional(),recursive:pc().optional(),globals:Hs().optional()}),action:async e=>{await bf({dryRun:e.dryRun===!0,check:e.check===!0,recursive:e.recursive===!0,globalsPath:e.globals})}})}const Ef=ol({name:`lzi-bun-cli`,description:`Longzai Intelligence bun 工具集`,interaction:Ou,color:Du});xf(Ef);async function Df(){await Ef.parseAsync(process.argv)}Df().catch(e=>{process.stderr.write(`错误: ${e instanceof Error?e.message:String(e)}\n`),process.exit(1)});export{};
206
+ `),a=0;for(;a<r.length&&a<i.length&&r[a]===i[a];)a++;let o=`第 ${a+1} 行不一致(磁盘 \`${r[a]??`<缺行>`}\` ≠ 预期 \`${i[a]??`<缺行>`}\`)`,s=n===void 0?void 0:`"@${n}" = `;return s!==void 0&&t.includes(s)&&!e.includes(s)?`${o},且本仓 scope @${n} 行在磁盘文件中缺位——bun publish 的 scope 映射优先级会使公网轨发布回退默认镜像源并以 missing authentication 失败(issue 0008)`:o},hf=async(e,t={})=>{let i=t.dir??process.cwd(),o=s(i,`bunfig.toml`),c=cf(i),l;c&&(l=(await rf({explicitPath:t.globalsPath})).presetScopes);let u=c?uf(lf(i,``)):void 0,d=Vd(e,{isRoot:c,installScopesPreset:l,selfScope:u});if(!d?.shouldWrite){if(t.dryRun&&Z(`(无 coverage 配置,不会生成 bunfig.toml)`),t.check===!0&&n(o))throw new Nd(o,`该包无 coverage 配置,生成器判定不应存在 bunfig.toml(多余文件),请删除该文件`);return{status:`skipped`,bunfigPath:o}}if(t.dryRun)return Z(`[dry-run] 将写入 ${o}:`),Z(d.content),{status:`generated`,bunfigPath:o};if(t.check===!0){if(!n(o))throw new Nd(o,u===void 0?`bunfig.toml 不存在(生成器预期应存在)`:`bunfig.toml 不存在,本仓 scope @${u} 未注入 [install.scopes]——bun publish 的 scope 映射优先级会使公网轨发布回退默认镜像源并以 missing authentication 失败(issue 0008)`);let e=r(o,`utf8`);if(!e.includes(`@lzi-bun-cli 自动生成,请勿编辑`))throw new Nd(o,`bunfig.toml 为手写文件(无生成标记),不受 lzi-bun-cli 管理;如需接管请确认内容后删除该文件重新生成`);if(e!==d.content)throw new Nd(o,mf(e,d.content,u));return Z(`校验通过 ${o}(与生成器预期一致)`),{status:`checked`,bunfigPath:o}}if(n(o)&&!r(o,`utf8`).includes(`@lzi-bun-cli 自动生成,请勿编辑`))throw new Pd(o);return a(o,d.content,`utf8`),Z(`已生成 ${o}(lzi-bun-cli 接管覆盖率配置)`),{status:`generated`,bunfigPath:o}},gf=e=>{let t=e?.test;if(t===void 0)return;let i=t.coverageThreshold;if(i===void 0)return;let a=s(process.cwd(),t.coverageDir??`coverage`,`lcov.info`);if(!n(a)){Z(`未找到覆盖率报告 ${a},跳过全局阈值判定`);return}let o=Gd(Hd(r(a,`utf8`)),i);if(o.passed)for(let e of qd(o))Z(e);else{Q(`错误: 覆盖率全局汇总低于阈值`);for(let e of qd(o))Q(e);process.exit(1)}},_f=async e=>{let t=await Jd(),n=t.test?.passWithNoTests??!0;await pf(t.test?.include??df)===0&&(n&&(Z(`无测试文件,跳过(type-only / facade 包,passWithNoTests)`),process.exit(0)),Q(`错误: 未找到测试文件,且 test.passWithNoTests 为 false`),Q(`(如该包确为 type-only / facade 包,请在 lzi-dev.config.ts 设置 test.passWithNoTests: true)`),process.exit(1));try{await hf(t)}catch(e){throw(e instanceof Pd||e instanceof id||e instanceof Yd)&&(Q(`错误: ${e.message}`),process.exit(1)),e}let r=ff(e),i=await Bun.spawn(r,{cwd:process.cwd(),stdout:`inherit`,stderr:`inherit`}).exited;i!==0&&process.exit(i),gf(t)},vf=async(e,t,n)=>{let r=await Jd();try{await hf(r,{dryRun:e,globalsPath:t,check:n})}catch(e){throw(e instanceof Pd||e instanceof Nd||e instanceof id||e instanceof Yd)&&(Q(`错误: ${e.message}`),process.exit(1)),e}},yf=e=>{let t=sf(e);t===`missing-package-json`&&(Q(`错误: 当前目录 ${e} 无 package.json,--recursive 须在 monorepo root 执行`),process.exit(1)),t!==`root`&&(Q(`错误: ${e} 的 package.json 未声明 workspaces 字段,--recursive 须在 monorepo root 执行`),process.exit(1))},bf=async(e,t,n)=>{let r=process.cwd();yf(r);let i=await Md(r,{configFileName:`lzi-bun.config.ts`}),a=[{name:lf(r,r.split(`/`).pop()??`root`),dir:r}];a.push(...i.map(e=>({name:e.name,dir:e.dir})));let o=n===!0?`校验`:e?`预览`:`生成`;Z(`发现 ${a.length} 个目标(root 1 + 子包 ${i.length}),开始${o}...`);let s=[];for(let r of a){Z(`▶ ${r.name}`);try{let i=await Jd(r.dir),{status:a}=await hf(i,{dryRun:e,check:n,dir:r.dir,globalsPath:t});s.push({name:r.name,dir:r.dir,status:a})}catch(e){s.push({name:r.name,dir:r.dir,status:`failed`,reason:e instanceof Error?e.message:String(e)})}}let c=s.filter(e=>e.status===`generated`),l=s.filter(e=>e.status===`checked`),u=s.filter(e=>e.status===`skipped`),d=s.filter(e=>e.status===`failed`);if(Z(``),Z(`汇总:${c.length} 生成 / ${l.length} 一致 / ${u.length} 跳过 / ${d.length} 失败`),d.length>0){Q(``),Q(`失败子包:`);for(let e of d)Q(` - ${e.name}:${e.reason}`);process.exitCode=1}},xf=async e=>{let t=e.dryRun===!0,n=e.check===!0;if(t&&n&&(Q(`错误: --dry-run 与 --check 互斥(预览与校验是两种只读形态,请二选一)`),process.exit(1)),e.globalsPath!==void 0){let t=Qd({explicitPath:e.globalsPath});t.ok||(Q(`错误: ${Xd(t.failure.attempted)}`),process.exit(1));let{globalsRoot:n,source:r}=t.resolution;tf(process.cwd(),n),Z(`已定位 globals 仓(${r})并固化到 .env:${n}`)}e.recursive===!0?await bf(t,e.globalsPath,n):await vf(t,e.globalsPath,n)};function Sf(e){Cf(e),Ef(e),wf(e),Tf(e)}function Cf(e){ul(e,{name:`test`,description:`运行 bun 测试(替代三件套,零测试包默认放行)`,options:[{flags:`--watch`,description:`监听模式(对应 test:watch)`},{flags:`--coverage`,description:`覆盖率(对应 test:coverage)`}],schema:xc({watch:pc().optional(),coverage:pc().optional()}),action:async(e,t)=>{await _f({watch:e.watch===!0,coverage:e.coverage===!0,extra:t})}})}function wf(e){ul(e,{name:`lockfile check`,description:`校验单一 bun.lock 不变量与 workspaces 覆盖缺口`,schema:xc({}),action:async()=>{await Gu()}})}function Tf(e){ul(e,{name:`node-links check`,description:`检测 node_modules 悬挂符号链接,命中即非零退出`,schema:xc({}),action:async()=>{await $u()}}),ul(e,{name:`node-links fix`,description:`回收 node_modules 悬挂死链,删除前复验,有效链接零触碰`,schema:xc({}),action:async()=>{await ed()}})}function Ef(e){ul(e,{name:`config generate`,description:`生成 bunfig.toml(不执行测试,支持 --dry-run 预览、--check 校验、-r 批量、--globals 定位)`,options:[{flags:`--dry-run`,description:`仅预览将写入的内容,不写盘`},{flags:`--check`,description:`仅校验磁盘 bunfig.toml 与生成器预期是否一致(漂移即报错退出,不写盘)`},{flags:`-r, --recursive`,description:`递归处理 monorepo 下含 lzi-bun.config.ts 的子包`},{flags:`--globals <path>`,description:`一次性 bootstrap 定位 globals 仓(命中后固化 .env,此后零参数)`}],schema:xc({dryRun:pc().optional(),check:pc().optional(),recursive:pc().optional(),globals:Hs().optional()}),action:async e=>{await xf({dryRun:e.dryRun===!0,check:e.check===!0,recursive:e.recursive===!0,globalsPath:e.globals})}})}const Df=ol({name:`lzi-bun-cli`,description:`Longzai Intelligence bun 工具集`,interaction:Ou,color:Du});Sf(Df);async function Of(){await Df.parseAsync(process.argv)}Of().catch(e=>{process.stderr.write(`错误: ${e instanceof Error?e.message:String(e)}\n`),process.exit(1)});export{};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longzai-intelligence-bun/cli",
3
- "version": "0.0.32",
3
+ "version": "0.0.33",
4
4
  "description": "Longzai Intelligence Bun 工具集 CLI",
5
5
  "keywords": [
6
6
  "bun",
@@ -40,10 +40,10 @@
40
40
  "test:coverage": "bun test --coverage"
41
41
  },
42
42
  "dependencies": {
43
- "@longzai-intelligence-bun/config": "0.0.32",
43
+ "@longzai-intelligence-bun/config": "0.0.33",
44
44
  "@longzai-intelligence-cli/core": "^0.0.10",
45
45
  "@longzai-intelligence-cli/standard": "^0.0.10",
46
- "@longzai-intelligence-shared-config/core": "^0.0.9",
46
+ "@longzai-intelligence-shared-config/core": "^0.0.10",
47
47
  "zod": "^4.4.3"
48
48
  }
49
49
  }