@longzai-intelligence-bun/cli 0.1.8 → 0.1.9

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 +12 -12
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -203,22 +203,22 @@ ${q.default.gray(_f+hf.repeat(a+2)+vf)}
203
203
  `);let d=0,f=0;p(),a=setInterval(()=>{if(r&&s===c)return;h(),c=s;let n=q.default.magenta(t[d]);if(r)process.stdout.write(`${n} ${s}...`);else if(e===`timer`)process.stdout.write(`${n} ${s} ${_(l)}`);else{let e=`.`.repeat(Math.floor(f)).slice(0,3);process.stdout.write(`${n} ${s}${e}`)}d=d+1<t.length?d+1:0,f=f<t.length?f+.125:0},n)},y=(t=``,n=0)=>{o=!1,clearInterval(a),h();let r=n===0?q.default.green(df):n===1?q.default.red(lf):q.default.red(uf);s=g(t??s),e===`timer`?process.stdout.write(`${r} ${s} ${_(l)}
204
204
  `):process.stdout.write(`${r} ${s}
205
205
  `),m(),i()};return{start:v,stop:y,message:(e=``)=>{s=g(e??s)}}},Mf={red:e=>q.default.red(e),green:e=>q.default.green(e),yellow:e=>q.default.yellow(e),blue:e=>q.default.blue(e),cyan:e=>q.default.cyan(e),magenta:e=>q.default.magenta(e),gray:e=>q.default.gray(e),bold:e=>q.default.bold(e),dim:e=>q.default.dim(e)},Nf={async select(e,t){let n=await Df({message:e,options:t.map(e=>({value:e.value,label:e.label,hint:e.hint}))});return Gd(n)&&(kf(`操作已取消`),process.exit(0)),typeof n==`string`?n:String(n)},async textInput(e,t){let n=await Tf({message:e,placeholder:t?.placeholder,defaultValue:t?.defaultValue});return Gd(n)&&(kf(`操作已取消`),process.exit(0)),typeof n==`string`?n:String(n)},async confirm(e,t){let n=await Ef({message:e,initialValue:t?.defaultValue??!1});return Gd(n)&&(kf(`操作已取消`),process.exit(0)),typeof n==`boolean`?n:!!n},spinner(){let e=jf();return{start(t){e.start(t)},stop(t){e.stop(t)}}},note(e,t){Of(e,t)},log:{info(e){Af.info(q.default.blue(e))},success(e){Af.success(q.default.green(e))},warn(e){Af.warn(q.default.yellow(e))},error(e){Af.error(q.default.red(e))},step(e){Af.step(e)}}};function Pf(e){return e.map(e=>{if(typeof e==`string`)return e;if(e instanceof Error)return e.message;try{return JSON.stringify(e)}catch{return String(e)}}).join(` `)}function X(...e){process.stdout.write(`${Pf(e)}\n`)}function Z(...e){process.stderr.write(`${Pf(e)}\n`)}function Ff(e,t=`./src/__tests__/helpers/bootstrap.ts`){let n=[t,...(e?.test?.preload??[]).filter(e=>e!==t)];return{...e,test:{...e?.test,preload:n}}}const If=[`maximum resident set size`,`peak memory footprint`];function Lf(e){for(let t of e.split(`
206
- `)){let e=t.trim();for(let t of If){let n;if(e.startsWith(t)){let t=e.slice(e.indexOf(`:`)+1).trim();n=Number.parseInt(t,10)}else if(e.endsWith(t))n=Number.parseInt(e,10);else continue;if(Number.isInteger(n)&&n>=0)return n}}}function Rf(e,t){let n=e=>`${Math.round(e/1048576)} MB`;return[`内存峰值 ${n(e)},预算 ${n(t)}`,`超预算即测试用例形态违例,请合并整页挂载用例的只读断言并把断言下放组件级,预算可经环境变量 LZI_TEST_MEMORY_BUDGET_BYTES 临时覆盖`]}const Q=`https://registry.npmjs.org/`,zf=/* @__PURE__ */ new Map([[`longzai-intelligence`,Q],[`longzai-intelligence-agent-tools`,Q],[`longzai-intelligence-audit`,Q],[`longzai-intelligence-auth`,Q],[`longzai-intelligence-builder`,Q],[`longzai-intelligence-bun`,Q],[`longzai-intelligence-cache`,Q],[`longzai-intelligence-cli`,Q],[`longzai-intelligence-config`,Q],[`longzai-intelligence-dependencies`,Q],[`longzai-intelligence-design-system`,Q],[`longzai-intelligence-dev-tools`,Q],[`longzai-intelligence-electron`,Q],[`longzai-intelligence-error`,Q],[`longzai-intelligence-event-bus`,Q],[`longzai-intelligence-lint`,Q],[`longzai-intelligence-logger`,Q],[`longzai-intelligence-okr`,Q],[`longzai-intelligence-oxfmt`,Q],[`longzai-intelligence-oxlint`,Q],[`longzai-intelligence-plugin`,Q],[`longzai-intelligence-shared-config`,Q],[`longzai-intelligence-shared-kernel`,Q],[`longzai-intelligence-scripts`,Q],[`longzai-intelligence-standards`,Q],[`longzai-intelligence-transport`,Q],[`longzai-intelligence-typescript`,Q],[`longzai-intelligence-vscode`,Q],[`longzai-intelligence-zod`,Q],[`longzai-intelligence-prettier`,Q],[`longzai-intelligence-tsdown`,Q],[`longzai-intelligence-vitest`,Q],[`longzai-intelligence-academy`,Q],[`longzai-intelligence-accounting`,Q],[`longzai-intelligence-activity`,Q],[`longzai-intelligence-administration`,Q],[`longzai-intelligence-agent`,Q],[`longzai-intelligence-agent-broadcast`,Q],[`longzai-intelligence-agent-collaboration`,Q],[`longzai-intelligence-agent-endless`,Q],[`longzai-intelligence-agent-migrator`,Q],[`longzai-intelligence-agent-monitor`,Q],[`longzai-intelligence-agent-prompts`,Q],[`longzai-intelligence-agent-relation`,Q],[`longzai-intelligence-agent-session`,Q],[`longzai-intelligence-agent-swarm`,Q],[`longzai-intelligence-agent-tasks`,Q],[`longzai-intelligence-agent-tasks-data`,Q],[`longzai-intelligence-agent-ui`,Q],[`longzai-intelligence-analytics`,Q],[`longzai-intelligence-api`,Q],[`longzai-intelligence-app-gallery`,Q],[`longzai-intelligence-app-store`,Q],[`longzai-intelligence-architecture`,Q],[`longzai-intelligence-architecture-expert`,Q],[`longzai-intelligence-arkts`,Q],[`longzai-intelligence-art`,Q],[`longzai-intelligence-artifact`,Q],[`longzai-intelligence-artifact-registry`,Q],[`longzai-intelligence-arxiv`,Q],[`longzai-intelligence-arxiv-data`,Q],[`longzai-intelligence-arxiv-markdown`,Q],[`longzai-intelligence-atomic`,Q],[`longzai-intelligence-attention`,Q],[`longzai-intelligence-audio`,Q],[`longzai-intelligence-audio-assistant`,Q],[`longzai-intelligence-augmented-reality`,Q],[`longzai-intelligence-auto-research`,Q],[`longzai-intelligence-automate`,Q],[`longzai-intelligence-benchmark`,Q],[`longzai-intelligence-bilibili`,Q],[`longzai-intelligence-bilibili-data`,Q],[`longzai-intelligence-bilibili-markdown`,Q],[`longzai-intelligence-billing`,Q],[`longzai-intelligence-blackboard`,Q],[`longzai-intelligence-blackboard-data`,Q],[`longzai-intelligence-blackboard-markdown`,Q],[`longzai-intelligence-bluetooth`,Q],[`longzai-intelligence-board`,Q],[`longzai-intelligence-bootstrap`,Q],[`longzai-intelligence-bootstrap-registry`,Q],[`longzai-intelligence-bounty-registry`,Q],[`longzai-intelligence-brawl-stars`,Q],[`longzai-intelligence-broker`,Q],[`longzai-intelligence-bt`,Q],[`longzai-intelligence-business-plan`,Q],[`longzai-intelligence-calendar`,Q],[`longzai-intelligence-camera`,Q],[`longzai-intelligence-canvas`,Q],[`longzai-intelligence-capture`,Q],[`longzai-intelligence-change-maker`,Q],[`longzai-intelligence-changelog`,Q],[`longzai-intelligence-changeset`,Q],[`longzai-intelligence-chat`,Q],[`longzai-intelligence-chess`,Q],[`longzai-intelligence-circuit`,Q],[`longzai-intelligence-claude-code`,Q],[`longzai-intelligence-claude-knowledge`,Q],[`longzai-intelligence-clipboard-share`,Q],[`longzai-intelligence-closed-loop`,Q],[`longzai-intelligence-closed-loop-data`,Q],[`longzai-intelligence-closed-loop-markdown`,Q],[`longzai-intelligence-cloud`,Q],[`longzai-intelligence-code`,Q],[`longzai-intelligence-code-agent`,Q],[`longzai-intelligence-code-reviewer`,Q],[`longzai-intelligence-codebase-research`,Q],[`longzai-intelligence-coding-expert`,Q],[`longzai-intelligence-collaboration`,Q],[`longzai-intelligence-collective`,Q],[`longzai-intelligence-commerce`,Q],[`longzai-intelligence-commit`,Q],[`longzai-intelligence-competition-registry`,Q],[`longzai-intelligence-composer`,Q],[`longzai-intelligence-concrete`,Q],[`longzai-intelligence-concrete-industry`,Q],[`longzai-intelligence-config-registry`,Q],[`longzai-intelligence-context`,Q],[`longzai-intelligence-contract`,Q],[`longzai-intelligence-contract-parity`,Q],[`longzai-intelligence-cookery`,Q],[`longzai-intelligence-country`,Q],[`longzai-intelligence-creativity`,Q],[`longzai-intelligence-cross-platform`,Q],[`longzai-intelligence-crossref`,Q],[`longzai-intelligence-crossref-markdown`,Q],[`longzai-intelligence-crypto`,Q],[`longzai-intelligence-customer-service`,Q],[`longzai-intelligence-cut`,Q],[`longzai-intelligence-dag`,Q],[`longzai-intelligence-dashboard`,Q],[`longzai-intelligence-data`,Q],[`longzai-intelligence-data-science`,Q],[`longzai-intelligence-database`,Q],[`longzai-intelligence-decenterlization`,Q],[`longzai-intelligence-decision`,Q],[`longzai-intelligence-deepseek`,Q],[`longzai-intelligence-deepseek-harness`,Q],[`longzai-intelligence-deepseek-harness-knowledge`,Q],[`longzai-intelligence-delta`,Q],[`longzai-intelligence-deploy`,Q],[`longzai-intelligence-design`,Q],[`longzai-intelligence-design-lab`,Q],[`longzai-intelligence-design-registry`,Q],[`longzai-intelligence-design-trending`,Q],[`longzai-intelligence-device`,Q],[`longzai-intelligence-dimensions`,Q],[`longzai-intelligence-discipline`,Q],[`longzai-intelligence-discovery`,Q],[`longzai-intelligence-disk-space`,Q],[`longzai-intelligence-disk-space-data`,Q],[`longzai-intelligence-disk-space-markdown`,Q],[`longzai-intelligence-distill`,Q],[`longzai-intelligence-docs`,Q],[`longzai-intelligence-docs-registry`,Q],[`longzai-intelligence-document`,Q],[`longzai-intelligence-douyin`,Q],[`longzai-intelligence-douyin-data`,Q],[`longzai-intelligence-douyin-markdown`,Q],[`longzai-intelligence-drone`,Q],[`longzai-intelligence-edge`,Q],[`longzai-intelligence-electrobun`,Q],[`longzai-intelligence-elysia`,Q],[`longzai-intelligence-embodied`,Q],[`longzai-intelligence-empowerment`,Q],[`longzai-intelligence-engineering`,Q],[`longzai-intelligence-env`,Q],[`longzai-intelligence-env-registry`,Q],[`longzai-intelligence-equilibrium`,Q],[`longzai-intelligence-eslint`,Q],[`longzai-intelligence-event`,Q],[`longzai-intelligence-event-tracking`,Q],[`longzai-intelligence-evolution`,Q],[`longzai-intelligence-excel`,Q],[`longzai-intelligence-exchange-rate`,Q],[`longzai-intelligence-execution`,Q],[`longzai-intelligence-experience`,Q],[`longzai-intelligence-expert`,Q],[`longzai-intelligence-expert-thinking`,Q],[`longzai-intelligence-fde`,Q],[`longzai-intelligence-feature-flags`,Q],[`longzai-intelligence-features`,Q],[`longzai-intelligence-federation`,Q],[`longzai-intelligence-feed`,Q],[`longzai-intelligence-feishu`,Q],[`longzai-intelligence-fields-medal-knowledge`,Q],[`longzai-intelligence-file-processing`,Q],[`longzai-intelligence-findings`,Q],[`longzai-intelligence-fitness`,Q],[`longzai-intelligence-font`,Q],[`longzai-intelligence-game`,Q],[`longzai-intelligence-game-studio`,Q],[`longzai-intelligence-gantt`,Q],[`longzai-intelligence-gateway`,Q],[`longzai-intelligence-geo`,Q],[`longzai-intelligence-gesture`,Q],[`longzai-intelligence-git`,Q],[`longzai-intelligence-git-commit`,Q],[`longzai-intelligence-git-insight`,Q],[`longzai-intelligence-git-reviewer`,Q],[`longzai-intelligence-git-swarm`,Q],[`longzai-intelligence-git-swarm-registry`,Q],[`longzai-intelligence-gitcode`,Q],[`longzai-intelligence-github-data`,Q],[`longzai-intelligence-github-markdown`,Q],[`longzai-intelligence-github-trending`,Q],[`longzai-intelligence-github-trending-data`,Q],[`longzai-intelligence-github-trending-markdown`,Q],[`longzai-intelligence-globals`,Q],[`longzai-intelligence-growth`,Q],[`longzai-intelligence-growth-registry`,Q],[`longzai-intelligence-handover`,Q],[`longzai-intelligence-hardware`,Q],[`longzai-intelligence-harness`,Q],[`longzai-intelligence-healthcare`,Q],[`longzai-intelligence-history`,Q],[`longzai-intelligence-horizon`,Q],[`longzai-intelligence-human-resource`,Q],[`longzai-intelligence-i18n`,Q],[`longzai-intelligence-idea`,Q],[`longzai-intelligence-identity`,Q],[`longzai-intelligence-ime`,Q],[`longzai-intelligence-impact-maker`,Q],[`longzai-intelligence-inbox`,Q],[`longzai-intelligence-inbox-registry`,Q],[`longzai-intelligence-input-data`,Q],[`longzai-intelligence-input-markdown`,Q],[`longzai-intelligence-insight`,Q],[`longzai-intelligence-intellectual-property`,Q],[`longzai-intelligence-intent`,Q],[`longzai-intelligence-intentionomics`,Q],[`longzai-intelligence-interview`,Q],[`longzai-intelligence-issues`,Q],[`longzai-intelligence-jev`,Q],[`longzai-intelligence-jev-knowledge`,Q],[`longzai-intelligence-jev-system`,Q],[`longzai-intelligence-journal-of-finance-data`,Q],[`longzai-intelligence-journal-of-financial-and-quantitative-analysis-data`,Q],[`longzai-intelligence-journal-of-financial-economics-data`,Q],[`longzai-intelligence-journals`,Q],[`longzai-intelligence-journals-2026-10`,Q],[`longzai-intelligence-journals-markdown`,Q],[`longzai-intelligence-journals-registry`,Q],[`longzai-intelligence-key-management`,Q],[`longzai-intelligence-knowledge`,Q],[`longzai-intelligence-knowledge-graph`,Q],[`longzai-intelligence-knowledge-markdown`,Q],[`longzai-intelligence-kol`,Q],[`longzai-intelligence-kol-data`,Q],[`longzai-intelligence-kol-markdown`,Q],[`longzai-intelligence-kol-registry`,Q],[`longzai-intelligence-language-model`,Q],[`longzai-intelligence-law`,Q],[`longzai-intelligence-law-data`,Q],[`longzai-intelligence-law-markdown`,Q],[`longzai-intelligence-lean`,Q],[`longzai-intelligence-ledger`,Q],[`longzai-intelligence-legal`,Q],[`longzai-intelligence-liquid-glass`,Q],[`longzai-intelligence-living-previewer`,Q],[`longzai-intelligence-loop`,Q],[`longzai-intelligence-machine-learning`,Q],[`longzai-intelligence-mail`,Q],[`longzai-intelligence-mandala`,Q],[`longzai-intelligence-map`,Q],[`longzai-intelligence-markdown`,Q],[`longzai-intelligence-marketing`,Q],[`longzai-intelligence-marketplace`,Q],[`longzai-intelligence-math`,Q],[`longzai-intelligence-mcn`,Q],[`longzai-intelligence-mcp`,Q],[`longzai-intelligence-mechanisms`,Q],[`longzai-intelligence-mechanisms-registry`,Q],[`longzai-intelligence-media`,Q],[`longzai-intelligence-meditation`,Q],[`longzai-intelligence-meeting-notes`,Q],[`longzai-intelligence-memory`,Q],[`longzai-intelligence-mentor`,Q],[`longzai-intelligence-messaging`,Q],[`longzai-intelligence-mindset`,Q],[`longzai-intelligence-minimax-knowldege`,Q],[`longzai-intelligence-mission-control`,Q],[`longzai-intelligence-model-fusion`,Q],[`longzai-intelligence-model-gateway`,Q],[`longzai-intelligence-moment`,Q],[`longzai-intelligence-montage`,Q],[`longzai-intelligence-movie`,Q],[`longzai-intelligence-music-video`,Q],[`longzai-intelligence-music-video-data`,Q],[`longzai-intelligence-narrative-analyzer`,Q],[`longzai-intelligence-nation`,Q],[`longzai-intelligence-nginx`,Q],[`longzai-intelligence-nginx-cli`,Q],[`longzai-intelligence-nobel-prize-knowledge`,Q],[`longzai-intelligence-notification`,Q],[`longzai-intelligence-npm`,Q],[`longzai-intelligence-npm-registry`,Q],[`longzai-intelligence-npm-registry-data`,Q],[`longzai-intelligence-observability`,Q],[`longzai-intelligence-office-industry`,Q],[`longzai-intelligence-okr-data`,Q],[`longzai-intelligence-okr-markdown`,Q],[`longzai-intelligence-older`,Q],[`longzai-intelligence-one`,Q],[`longzai-intelligence-one-digest`,Q],[`longzai-intelligence-one-digest-data`,Q],[`longzai-intelligence-one-digest-markdown`,Q],[`longzai-intelligence-one-digest-registry`,Q],[`longzai-intelligence-one-trae-works`,Q],[`longzai-intelligence-ontology`,Q],[`longzai-intelligence-open-pencil`,Q],[`longzai-intelligence-open-router`,Q],[`longzai-intelligence-open-router-data`,Q],[`longzai-intelligence-open-router-markdown`,Q],[`longzai-intelligence-opencode`,Q],[`longzai-intelligence-opencode-knowledge`,Q],[`longzai-intelligence-opportunity`,Q],[`longzai-intelligence-orchestry`,Q],[`longzai-intelligence-organization`,Q],[`longzai-intelligence-orm`,Q],[`longzai-intelligence-outfit`,Q],[`longzai-intelligence-outsourcing`,Q],[`longzai-intelligence-overseas`,Q],[`longzai-intelligence-pagination`,Q],[`longzai-intelligence-panel`,Q],[`longzai-intelligence-paper-reader`,Q],[`longzai-intelligence-parametric-industry`,Q],[`longzai-intelligence-partner`,Q],[`longzai-intelligence-pay`,Q],[`longzai-intelligence-payment`,Q],[`longzai-intelligence-permission`,Q],[`longzai-intelligence-personal-assistant`,Q],[`longzai-intelligence-philosophy`,Q],[`longzai-intelligence-philosophy-markdown`,Q],[`longzai-intelligence-philosophy-ontology`,Q],[`longzai-intelligence-pi-knowledge`,Q],[`longzai-intelligence-pii`,Q],[`longzai-intelligence-pipeline`,Q],[`longzai-intelligence-pitfalls`,Q],[`longzai-intelligence-plugin-registry`,Q],[`longzai-intelligence-pm2`,Q],[`longzai-intelligence-policy-research`,Q],[`longzai-intelligence-port`,Q],[`longzai-intelligence-portal`,Q],[`longzai-intelligence-previewer`,Q],[`longzai-intelligence-prezi`,Q],[`longzai-intelligence-prisma`,Q],[`longzai-intelligence-process-monitor`,Q],[`longzai-intelligence-product-requirement`,Q],[`longzai-intelligence-product-research`,Q],[`longzai-intelligence-programming-language`,Q],[`longzai-intelligence-project`,Q],[`longzai-intelligence-project-data`,Q],[`longzai-intelligence-project-markdown`,Q],[`longzai-intelligence-project-portfolio`,Q],[`longzai-intelligence-project-registry`,Q],[`longzai-intelligence-promotion`,Q],[`longzai-intelligence-proposals`,Q],[`longzai-intelligence-prospect`,Q],[`longzai-intelligence-psychoanalyst`,Q],[`longzai-intelligence-publication`,Q],[`longzai-intelligence-qcloud`,Q],[`longzai-intelligence-quant`,Q],[`longzai-intelligence-queue`,Q],[`longzai-intelligence-quick-notes`,Q],[`longzai-intelligence-react-devtools`,Q],[`longzai-intelligence-react-native`,Q],[`longzai-intelligence-reader`,Q],[`longzai-intelligence-reading-distinction`,Q],[`longzai-intelligence-reading-shanhaijing`,Q],[`longzai-intelligence-readme`,Q],[`longzai-intelligence-reasoning`,Q],[`longzai-intelligence-records`,Q],[`longzai-intelligence-recruitment`,Q],[`longzai-intelligence-reflections`,Q],[`longzai-intelligence-release`,Q],[`longzai-intelligence-release-markdown`,Q],[`longzai-intelligence-reliability`,Q],[`longzai-intelligence-remote-desktop`,Q],[`longzai-intelligence-remote-machine`,Q],[`longzai-intelligence-remote-machine-registry`,Q],[`longzai-intelligence-remotion`,Q],[`longzai-intelligence-report`,Q],[`longzai-intelligence-repository`,Q],[`longzai-intelligence-repository-handover`,Q],[`longzai-intelligence-research-report`,Q],[`longzai-intelligence-research-report-data`,Q],[`longzai-intelligence-research-report-markdown`,Q],[`longzai-intelligence-research-report-registry`,Q],[`longzai-intelligence-resilience`,Q],[`longzai-intelligence-reverse-engineering`,Q],[`longzai-intelligence-review-of-financial-studies-data`,Q],[`longzai-intelligence-reviewer`,Q],[`longzai-intelligence-risk`,Q],[`longzai-intelligence-roadmap`,Q],[`longzai-intelligence-roadmap-data`,Q],[`longzai-intelligence-roadmap-markdown`,Q],[`longzai-intelligence-router`,Q],[`longzai-intelligence-rss`,Q],[`longzai-intelligence-rss-markdown`,Q],[`longzai-intelligence-runtime`,Q],[`longzai-intelligence-runtime-registry`,Q],[`longzai-intelligence-sales`,Q],[`longzai-intelligence-scanner`,Q],[`longzai-intelligence-schedule-markdown`,Q],[`longzai-intelligence-schedule-registry`,Q],[`longzai-intelligence-scheduler`,Q],[`longzai-intelligence-schema`,Q],[`longzai-intelligence-scope`,Q],[`longzai-intelligence-scrape`,Q],[`longzai-intelligence-screenshots`,Q],[`longzai-intelligence-scripts-registry`,Q],[`longzai-intelligence-search`,Q],[`longzai-intelligence-security`,Q],[`longzai-intelligence-security-bounty-registry`,Q],[`longzai-intelligence-security-inventory`,Q],[`longzai-intelligence-serverless`,Q],[`longzai-intelligence-share`,Q],[`longzai-intelligence-sheet`,Q],[`longzai-intelligence-short-video`,Q],[`longzai-intelligence-skill`,Q],[`longzai-intelligence-slider`,Q],[`longzai-intelligence-smart-transition`,Q],[`longzai-intelligence-sms`,Q],[`longzai-intelligence-software-factory`,Q],[`longzai-intelligence-soul`,Q],[`longzai-intelligence-specs`,Q],[`longzai-intelligence-spline`,Q],[`longzai-intelligence-sports`,Q],[`longzai-intelligence-ssl`,Q],[`longzai-intelligence-startup`,Q],[`longzai-intelligence-state-machine`,Q],[`longzai-intelligence-storage`,Q],[`longzai-intelligence-strategy`,Q],[`longzai-intelligence-strategy-consulting`,Q],[`longzai-intelligence-strategy-consulting-data`,Q],[`longzai-intelligence-strategy-consulting-markdown`,Q],[`longzai-intelligence-supply-chain`,Q],[`longzai-intelligence-support`,Q],[`longzai-intelligence-survey`,Q],[`longzai-intelligence-system`,Q],[`longzai-intelligence-system-data`,Q],[`longzai-intelligence-system-markdown`,Q],[`longzai-intelligence-system-registry`,Q],[`longzai-intelligence-talk`,Q],[`longzai-intelligence-taro`,Q],[`longzai-intelligence-task`,Q],[`longzai-intelligence-task-data`,Q],[`longzai-intelligence-task-markdown`,Q],[`longzai-intelligence-telemetry`,Q],[`longzai-intelligence-templates`,Q],[`longzai-intelligence-tenant`,Q],[`longzai-intelligence-terminal`,Q],[`longzai-intelligence-testing`,Q],[`longzai-intelligence-thinking`,Q],[`longzai-intelligence-token-exchange`,Q],[`longzai-intelligence-token-finance`,Q],[`longzai-intelligence-token-handover`,Q],[`longzai-intelligence-toolchain`,Q],[`longzai-intelligence-topology`,Q],[`longzai-intelligence-tracking-bennett-brassard`,Q],[`longzai-intelligence-tracking-deng-yu`,Q],[`longzai-intelligence-tracking-hong-wang`,Q],[`longzai-intelligence-tracking-jacob-tsimerman`,Q],[`longzai-intelligence-tracking-john-clarke`,Q],[`longzai-intelligence-tracking-john-martinis`,Q],[`longzai-intelligence-tracking-john-pardon`,Q],[`longzai-intelligence-tracking-michel-devoret`,Q],[`longzai-intelligence-tracking-nation`,Q],[`longzai-intelligence-tracking-qbitai`,Q],[`longzai-intelligence-tracking-terrytao`,Q],[`longzai-intelligence-tracking-xiao-lin`,Q],[`longzai-intelligence-tracking-yu-bo`,Q],[`longzai-intelligence-trader`,Q],[`longzai-intelligence-trae`,Q],[`longzai-intelligence-training-data`,Q],[`longzai-intelligence-translator`,Q],[`longzai-intelligence-travel`,Q],[`longzai-intelligence-trending`,Q],[`longzai-intelligence-tsconfig`,Q],[`longzai-intelligence-tsdoc`,Q],[`longzai-intelligence-tsgo`,Q],[`longzai-intelligence-turbo`,Q],[`longzai-intelligence-turing-award-knowledge`,Q],[`longzai-intelligence-twitter`,Q],[`longzai-intelligence-twitter-data`,Q],[`longzai-intelligence-twitter-markdown`,Q],[`longzai-intelligence-typeorm`,Q],[`longzai-intelligence-usecase`,Q],[`longzai-intelligence-user-experience`,Q],[`longzai-intelligence-user-research`,Q],[`longzai-intelligence-userscript`,Q],[`longzai-intelligence-utils`,Q],[`longzai-intelligence-value-chain`,Q],[`longzai-intelligence-vector-search`,Q],[`longzai-intelligence-vendor`,Q],[`longzai-intelligence-venture-capital`,Q],[`longzai-intelligence-version`,Q],[`longzai-intelligence-video-generation`,Q],[`longzai-intelligence-video-player`,Q],[`longzai-intelligence-vite`,Q],[`longzai-intelligence-voice`,Q],[`longzai-intelligence-voice-recorder`,Q],[`longzai-intelligence-vscode-developer`,Q],[`longzai-intelligence-vuln`,Q],[`longzai-intelligence-vuln-data`,Q],[`longzai-intelligence-vuln-markdown`,Q],[`longzai-intelligence-vuln-registry`,Q],[`longzai-intelligence-warehouse`,Q],[`longzai-intelligence-wealth`,Q],[`longzai-intelligence-web3`,Q],[`longzai-intelligence-webhook`,Q],[`longzai-intelligence-websocket`,Q],[`longzai-intelligence-wechat`,Q],[`longzai-intelligence-wechat-miniprogram`,Q],[`longzai-intelligence-wechat-pay`,Q],[`longzai-intelligence-wifi`,Q],[`longzai-intelligence-wiki`,Q],[`longzai-intelligence-word`,Q],[`longzai-intelligence-work`,Q],[`longzai-intelligence-worker`,Q],[`longzai-intelligence-workflow`,Q],[`longzai-intelligence-workflow-data`,Q],[`longzai-intelligence-workflow-markdown`,Q],[`longzai-intelligence-workflow-registry`,Q],[`longzai-intelligence-workspace`,Q],[`longzai-intelligence-writer`,Q],[`longzai-intelligence-xiaohongshu`,Q],[`longzai-intelligence-xiaohongshu-data`,Q],[`longzai-intelligence-xiaohongshu-markdown`,Q],[`longzai-intelligence-youtube`,Q],[`longzai-intelligence-youtube-data`,Q],[`longzai-intelligence-youtube-markdown`,Q],[`longzai-intelligence-zcode`,Q],[`longzai-intelligence-zcode-cleaner`,Q],[`longzai-intelligence-zcode-commit`,Q],[`longzai-intelligence-zcode-knowledge`,Q],[`longzai-intelligence-zcode-remote`,Q],[`longzai-intelligence-zcode-security`,Q],[`longzai-intelligence-zed-delta-knowledge`,Q],[`longzai-intelligence-zhihu`,Q],[`longzai-intelligence-zhihu-data`,Q],[`longzai-intelligence-zhihu-markdown`,Q]]),Bf=`LZI_GLOBALS_ROOT`,Vf=/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/;var Hf=class extends Error{details;constructor(e,t=`install.extraScopes`){super(`${t} 校验失败:\n${e.map(e=>`- ${e}`).join(`
207
- `)}`),this.name=`InstallScopesError`,this.details=e}};function Uf(e){if(typeof e!=`string`)return!1;try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`}catch{return!1}}function Wf(e,t,n,r){let i=e instanceof Map?Object.fromEntries(e):{...e},a=[],o={};for(let[n,i]of Object.entries(t??{})){let t=n.replace(/^@+/,``);t.length===0||!Vf.test(t)?a.push(`\`${n}\` 不是合法 scope 名(仅允许字母/数字开头,后接字母/数字与 . _ -,@ 前缀可省略)`):Uf(i)?o[t]!==void 0&&o[t]!==i?a.push(`\`${t}\` 在 extraScopes 内重复声明且安装源不一致`):(e instanceof Map?e.has(t):Object.hasOwn(e,t))?a.push(`\`${t}\` 与预定义 scope 冲突(预定义不可覆盖,如需调整请在 ${r} 维护)`):o[t]=i:a.push(`\`${n}\` 的安装源 \`${String(i)}\` 不是合法的 http/https URL`)}let s=/* @__PURE__ */ new Set;for(let e of n??[]){let t=e.replace(/^@+/,``);t.length===0||!Vf.test(t)?a.push(`\`${e}\` 不是合法 scope 名(仅允许字母/数字开头,后接字母/数字与 . _ -,@ 前缀可省略)`):o[t]===void 0?s.add(t):a.push(`\`${t}\` 同时出现在 extraScopes 与 privateScopes(追加公网安装源与私有轨声明矛盾)`)}if(a.length>0)throw new Hf(a);for(let[e,t]of Object.entries(o))i[e]=t;for(let e of s)delete i[e];return i}function Gf(e,t,n,r){let i=Wf(e,t,n,`globals 仓 lzi-bun-install.config.ts`),a=r?.replace(/^@+/,``),o=new Set((n??[]).map(e=>e.replace(/^@+/,``)));return a!==void 0&&Vf.test(a)&&!Object.hasOwn(i,a)&&!o.has(a)&&(i[a]=`https://registry.npmjs.org/`),i}function Kf(e){let t=[];if(typeof e!=`object`||!e)throw new Hf([`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 Hf([`scopes 必须是 scope → registry 的对象映射`],`globals 预设 lzi-bun-install.config.ts`);let r={};for(let[e,i]of Object.entries(n))Vf.test(e)?typeof i!=`string`||!Uf(i)?t.push(`\`${e}\` 的安装源 \`${String(i)}\` 不是合法的 http/https URL`):r[e]=i:t.push(`\`${e}\` 不是合法 scope 名(仅允许字母/数字开头,后接字母/数字与 . _ -,不含 @ 前缀)`);if(t.length>0)throw new Hf(t,`globals 预设 lzi-bun-install.config.ts`);if(Object.keys(r).length===0)throw new Hf([`scopes 清单为空(真源不允许空清单)`],`globals 预设 lzi-bun-install.config.ts`);return r}const qf=/* @__PURE__ */ new Set([`web`,`desktop`,`desktop-host`,`mobile`,`miniprogram`,`ui`]);function Jf(e){let t=process.env.LZI_TEST_MEMORY_BUDGET_BYTES;if(t!==void 0){let e=Number.parseInt(t,10);if(Number.isInteger(e)&&e>0)return e}return e!==void 0&&qf.has(e)?1610612736:1073741824}const Yf=e=>{let t=e;for(;;){if(r(d(t,`.git`)))return t;let e=d(t,`..`);if(e===t)return;t=e}},Xf=(e,t)=>{if(t!==void 0&&t.length>0)return{scopeName:t};let n=Yf(e);return n===void 0?{skipped:!0}:{scopeName:l(n)}},Zf=e=>({scopeName:e,registered:zf.has(e)}),Qf=async(e={})=>{let t=Xf(process.cwd(),e.scopeName);if(`skipped`in t){X(`当前目录不在任何 git 项目仓内,跳过登记检查`);return}let n=Zf(t.scopeName);n.registered?X(`当前项目 ${n.scopeName} 已登记于 bun 侧安装源注册表`):(Z(`当前项目 ${n.scopeName} 未登记于 bun 侧安装源注册表`),Z(`修复指引:补登 bun 仓 packages/config 的 scopes.constants.ts 与 globals 仓 lzi-bun-install.config.ts 双写条目,双写后各仓执行 bun-config:generate 生效`),process.exit(1))},$f=/* @__PURE__ */ new Set([`build`,`coverage`,`dist`,`node_modules`,`out`]),ep=/* @__PURE__ */ new Set([`ENAMETOOLONG`,`EACCES`,`EPERM`,`ENOENT`]),tp=Ws([zs(cs()),Hs({packages:zs(cs())})]),np=e=>typeof e!=`object`||!e||!(`code`in e)?!1:typeof e.code==`string`,rp=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}$`)},ip=e=>{let t={positives:[],negatives:[]};for(let n of e)n.startsWith(`!`)?t.negatives.push(rp(n.slice(1))):t.positives.push(rp(n));return t},ap=e=>{let t=tp.safeParse(e);if(t.success)return Array.isArray(t.data)?t.data:t.data.packages},op=(e,t)=>e.positives.some(e=>e.test(t))&&!e.negatives.some(e=>e.test(t)),sp=(e,t)=>e.negatives.some(e=>e.test(t)),cp=[`bun.lock`,`bun.lockb`],lp=Hs({name:cs().optional(),workspaces:tp.optional()}),up=Hs({name:cs().optional()}),dp=async e=>{try{let t=up.safeParse(JSON.parse(await S(e,`utf-8`)));return t.success?t.data.name??null:null}catch{return null}},fp=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 C(r.dir,{withFileTypes:!0})}catch(n){if(!np(n)||!ep.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()&&cp.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 dp(d(r.dir,`package.json`))}));for(let e of i)e.isDirectory()&&(e.name.startsWith(`.`)||$f.has(e.name)||r.depth>=5||n.push({dir:d(r.dir,e.name),depth:r.depth+1}))}return t},pp=async e=>{let t;try{t=JSON.parse(await S(d(e,`package.json`),`utf-8`))}catch{throw Error(`根 package.json 不存在或不可解析,请在仓库根执行本命令`)}let n=lp.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=ap(r.workspaces);if(o===void 0)return{rootName:i,scope:a,hasWorkspaces:!1,memberCount:0,violations:[],notices:[],scanSkips:[],ok:!0};let s=ip(o),c=await fp(e),l=[],u=[],f=new Map(c.packageDirs.map(e=>[e.relPath,e.name])),p=c.packageDirs.map(e=>e.relPath).filter(e=>op(s,e));c.rootHasLock||l.push({kind:`missing-root-lock`,path:``,message:`仓库根缺少 bun.lock,声明了 workspaces 的 monorepo 锁文件应只存在于根`});let m=/* @__PURE__ */ new Set;for(let e of c.lockDirs){if(op(s,e)){m.add(e),l.push({kind:`stray-member-lock`,path:e,message:`${e} 是 workspaces 成员却持有自己的 bun.lock,属游离锁文件`});continue}let t=f.get(e)??null;t===null?u.push({kind:`orphan-lock`,path:e,message:`${e} 存在锁文件但没有 package.json,请确认目录用途`}):sp(s,e)?u.push({kind:`excluded-standalone`,path:e,message:`${e} 为负向 glob 显式排除的独立安装根,锁文件属合法形态`}):a!==null&&t.startsWith(`${a}/`)?(m.add(e),l.push({kind:`uncovered-same-scope`,path:e,message:`${e}(${t})与根包同作用域却未被 workspaces 覆盖,已按独立安装根长出游离锁`})):u.push({kind:`foreign-scope-lock`,path:e,message:`${e}(${t})不属于根作用域且持有独立锁文件,若为有意保留请以负向 glob 显式排除`})}for(let e of c.packageDirs)p.includes(e.relPath)||sp(s,e.relPath)||m.has(e.relPath)||a!==null&&e.name!==null&&e.name.startsWith(`${a}/`)&&l.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:l,notices:u,scanSkips:c.scanSkips,ok:l.length===0}},mp=async()=>{let e=process.cwd();X(`正在扫描 ${e} 下的工作区布局...`);try{let t=await pp(e);if(!t.hasWorkspaces){X(`未声明 workspaces,非 bun workspaces monorepo,跳过锁文件校验`);return}if(t.scanSkips.length>0){Z(`\n${t.scanSkips.length} 项目录读取降级告警,结论基于其余可读目录:`);for(let e of t.scanSkips)Z(` ${e.path} 读取失败已跳过该子树,错误码 ${e.code}`)}if(X(`根包 ${t.rootName??`未命名`},workspaces 成员 ${t.memberCount} 个`),t.notices.length>0){X(`\n${t.notices.length} 项提示:`);for(let e of t.notices)X(` ${e.message}`)}if(!t.ok){X(`\n发现 ${t.violations.length} 项违规:`);for(let e of t.violations)X(` ${e.message}`);X(`
208
- 修复指引: 删除成员目录的游离 bun.lock 后在仓库根执行 bun install;覆盖缺口补 workspaces glob,刻意独立的子项目以负向 glob 显式排除`),process.exit(1)}X(`单一锁文件不变量成立,无游离锁文件与覆盖缺口`)}catch(e){Z(`错误: ${e instanceof Error?e.message:String(e)}`),process.exit(1)}},hp=/* @__PURE__ */ new Set([`.bun`]),gp=/* @__PURE__ */ new Set([`ENOENT`,`ENOTDIR`]),_p=Hs({workspaces:tp.optional()}),vp=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 C(i.dir,{withFileTypes:!0})}catch(t){if(!np(t)||!ep.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(`.`)||$f.has(e.name)||i.depth>=5||r.push({dir:d(i.dir,e.name),depth:i.depth+1}))}return{packageDirPaths:t,scanSkips:n}},yp=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 C(e,{withFileTypes:!0})}catch(n){if(!np(n)||!ep.has(n.code))throw n;r.push({path:e.slice(t.length+1),code:n.code});continue}for(let o of a){let a=d(e,o.name);if(!hp.has(o.name)){if(o.isSymbolicLink())try{await T(a)}catch(e){if(np(e)&&gp.has(e.code)){n.push({path:a.slice(t.length+1),target:await w(a)});continue}r.push({path:a.slice(t.length+1),code:np(e)?e.code:`UNKNOWN`})}else o.isDirectory()&&i.push(a)}}}return{dangling:n,scanSkips:r}},bp=async e=>{let t;try{t=JSON.parse(await S(d(e,`package.json`),`utf-8`))}catch{throw Error(`根 package.json 不存在或不可解析,请在仓库根执行本命令`)}let n=_p.safeParse(t);if(!n.success)throw Error(`根 package.json 不存在或不可解析,请在仓库根执行本命令`);let r=ap(n.data.workspaces);if(r===void 0)return{hasWorkspaces:!1,memberCount:0,scannedNodeModulesRoots:0,dangling:[],scanSkips:[],ok:!0};let i=ip(r),a=await vp(e),o=a.packageDirPaths.filter(e=>op(i,e)),s=[],c=[...a.scanSkips],l=0;for(let t of[``,...o]){let n=d(e,t,`node_modules`);try{if(!(await T(n)).isDirectory())continue}catch{continue}l+=1;let r=await yp(n,e);s.push(...r.dangling),c.push(...r.scanSkips)}return{hasWorkspaces:!0,memberCount:o.length,scannedNodeModulesRoots:l,dangling:s,scanSkips:c,ok:s.length===0}},xp=async(e,t)=>{let n={removed:[],kept:[]};for(let r of t){let t=d(e,r.path);try{if(!(await x(t)).isSymbolicLink()){n.kept.push(r.path);continue}await T(t),n.kept.push(r.path)}catch(e){if(!np(e)||!gp.has(e.code)){n.kept.push(r.path);continue}await E(t),n.removed.push(r.path)}}return n},Sp=async()=>{let e=process.cwd();X(`正在扫描 ${e} 下的安装布局...`);try{let t=await bp(e);if(!t.hasWorkspaces){X(`未声明 workspaces,非 bun workspaces monorepo,跳过悬挂链接检测`);return}if(t.scanSkips.length>0){Z(`\n${t.scanSkips.length} 项目录读取降级告警,结论基于其余可读目录:`);for(let e of t.scanSkips)Z(` ${e.path} 读取失败已跳过该子树,错误码 ${e.code}`)}if(X(`workspaces 成员 ${t.memberCount} 个,扫描 ${t.scannedNodeModulesRoots} 个 node_modules 树`),t.dangling.length>0){X(`\n发现 ${t.dangling.length} 根悬挂符号链接:`);for(let e of t.dangling)X(` ${e.path} 指向已不存在的 ${e.target}`);X(`
209
- 修复指引:执行 bunx @longzai-intelligence-bun/cli node-links fix 回收悬挂死链后重试,有效链接零触碰`),process.exit(Math.min(t.dangling.length,255))}X(`安装布局一致,未发现悬挂符号链接`)}catch(e){Z(`错误: ${e instanceof Error?e.message:String(e)}`),process.exit(1)}},Cp=async()=>{let e=process.cwd();X(`正在扫描 ${e} 下的悬挂符号链接...`);try{let t=await bp(e);if(!t.hasWorkspaces){X(`未声明 workspaces,非 bun workspaces monorepo,跳过悬挂链接回收`);return}if(t.dangling.length===0){X(`未发现悬挂符号链接,无需回收,共巡查 ${t.scannedNodeModulesRoots} 个 node_modules 树`);return}X(`发现 ${t.dangling.length} 根悬挂符号链接,开始回收:`);for(let e of t.dangling)X(` ${e.path} 指向已不存在的 ${e.target}`);let n=await xp(e,t.dangling);for(let e of n.removed)X(`已回收 ${e}`);for(let e of n.kept)Z(`未能回收 ${e},链接状态已变化,请人工确认`);let r=await bp(e);X(`回收完成,清除 ${n.removed.length} 根,剩余悬挂 ${r.dangling.length} 根,有效链接零触碰`),(r.dangling.length>0||n.kept.length>0)&&process.exit(1)}catch(e){Z(`错误: ${e instanceof Error?e.message:String(e)}`),process.exit(1)}};var wp=class extends Error{configPath;constructor(e,t,n){super(e,n),this.name=`SharedConfigError`,this.configPath=t}},Tp=class extends wp{searchFrom;constructor(e){super(`未在 ${e} 找到配置文件`,e),this.name=`SharedConfigNotFoundError`,this.searchFrom=e}},Ep=class extends wp{issues;constructor(e,t){super(`配置校验失败,共 ${e.length} 个问题`,t),this.name=`SharedConfigValidationError`,this.issues=e}};function Dp(e,t,n,r){let i=e;if(r.schema!==void 0){let e=r.schema.safeParse(i);if(!e.success)throw new Ep(e.error.issues,t);i=e.data}return r.transform!==void 0&&(i=r.transform(i,n)),i}function Op(e){return e instanceof Error&&e.message.length>0?`,底层原因为 ${e.name}: ${e.message}`:``}var kp=class extends wp{cause;constructor(e,t){super(`加载配置文件 ${e} 失败${Op(t)}`,e,{cause:t}),this.name=`SharedConfigLoadError`,this.cause=t}};function Ap(e){return typeof e==`object`&&!!e}function jp(e){return typeof e==`object`&&!!e}async function Mp(e,t={}){let n=p(e);if(!r(n))throw new Tp(n);let i;try{let e=await import(n);i=Ap(e)?e.default:void 0}catch(e){throw new kp(n,e)}if(i===void 0)throw new kp(n,TypeError(`配置文件缺少默认导出`));if(!jp(i))throw new kp(n,TypeError(`配置文件的默认导出必须是对象`));return{config:Dp(i,n,u(n),t),configFilePath:n}}function Np(e=process.cwd()){let t=p(e);for(;;){let e=d(t,`lzi.config.ts`);if(r(e))return e;let n=u(t);if(n===t)return null;t=n}}async function Pp(e={}){let t=e.cwd??process.cwd(),n=Np(t);if(n===null)throw new Tp(t);let r=p(n,`..`),{config:i}=await Mp(n);return{config:i,configPath:r,configFilePath:n}}function Fp(e){return typeof e==`object`&&!!e}async function Ip(e){let t;try{t=await C(e)}catch(t){throw new kp(e,t)}let n=t.filter(e=>e.endsWith(`.config.ts`)).sort();if(n.length===0)throw new kp(e,Error(`配置目录内没有 .config.ts 分片文件`));let r={};for(let t of n){let n=await Mp(d(e,t));r={...r,...n.config}}let i=r;if(!Fp(i))throw new kp(e,Error(`配置目录合并结果不是对象形态`));return i}function Lp(e,t=process.cwd()){let n=Array.isArray(e)?e:[e],r=p(t);for(;;){for(let e of n){let t=d(r,e);if(Rp(t))return t}let e=u(r);if(e===r)return null;r=e}}function Rp(e){try{return s(e).isDirectory()}catch{return!1}}function zp(e,t=process.cwd()){let n=Array.isArray(e)?e:[e],i=p(t);for(;;){for(let e of n){let t=d(i,e);if(r(t))return t}let e=u(i);if(e===i)return null;i=e}}function Bp(e){return typeof e==`object`&&!!e}function Vp(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}async function Hp(e={}){let t=e.cwd??p(process.cwd());if(e.explicitPath!==void 0){let t=await Mp(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=zp(e.standaloneFile,t);if(n!==null){let{config:t}=await Mp(n);return{success:!0,config:Dp(t,n,u(n),e),source:`standalone`,configFilePath:n}}}if(e.standaloneDir!==void 0){let n=Lp(e.standaloneDir,t);if(n!==null)return{success:!0,config:Dp(await Ip(n),n,n,e),source:`standalone`,configFilePath:n}}if(e.unifiedField!==void 0){let n,r;try{let{config:i,configFilePath:a}=await Pp({cwd:t}),o=i;n=Vp(o)?o[e.unifiedField]:void 0,r=a}catch(e){if(!(e instanceof Tp))throw e}if(r!==void 0&&n!==void 0&&Bp(n))return{success:!0,config:Dp(n,r,u(r),e),source:`unified`,configFilePath:r}}return{success:!1,configFilePath:null}}const Up=[`packages/*`,`apps/*`];function Wp(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Gp(e){if(Array.isArray(e))return e.every(e=>typeof e==`string`)?e:void 0;if(Wp(e)){let t=e.packages;if(Array.isArray(t)&&t.every(e=>typeof e==`string`))return{packages:t}}}function Kp(e){let t=p(e,`package.json`);if(!r(t))throw new Tp(e);let n;try{let e=JSON.parse(a(t,`utf8`));n=Wp(e)?Gp(e.workspaces):void 0}catch(e){throw new kp(t,e)}let i=Array.isArray(n)?n:n?.packages;return i&&i.length>0?i:Up}async function qp(e,t={}){let n=Kp(e),i=/* @__PURE__ */ new Set,o=[];for(let s of n){let n=new Bun.Glob(`${s}/package.json`);for await(let s of n.scan({cwd:e,absolute:!0,onlyFiles:!0})){let e=p(s,`..`);if(i.has(e))continue;let n;try{let e=JSON.parse(a(s,`utf8`));n=typeof e==`object`&&e?e:void 0}catch{continue}n!==void 0&&typeof n.name==`string`&&n.name.length!==0&&(t.configFileName!==void 0&&!r(p(e,t.configFileName))||(i.add(e),o.push({name:n.name,dir:e})))}}return o}var Jp=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}},Yp=class extends Error{bunfigPath;constructor(e){super(`${e} 已存在且非 lzi-bun 生成(缺少 @lzi-bun 自动生成,请勿编辑 标记),如需 lzi-bun 接管,请删除该文件或手动合并后重试`),this.name=`BunfigProtectedError`,this.bunfigPath=e}};function Xp(e){return`"${e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}"`}function Zp(e,t){let n=e.map(e=>Xp(e)),r=`[${n.join(`, `)}]`;return`${t} = `.length+r.length<=100?r:`[\n${n.map(e=>` ${e},`).join(`
210
- `)}\n]`}function Qp(e){let t=[`registry = ${Xp(e.registry)}`],n=em(`linker`,e.linker);n&&t.push(n);let r=em(`globalStore`,e.globalStore);r&&t.push(r);let i=Object.entries(e.scopes).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>`${Xp(`@${e}`)} = ${Xp(t)}`),a=[`[install]\n${t.join(`
206
+ `)){let e=t.trim();for(let t of If){let n;if(e.startsWith(t)){let t=e.slice(e.indexOf(`:`)+1).trim();n=Number.parseInt(t,10)}else if(e.endsWith(t))n=Number.parseInt(e,10);else continue;if(Number.isInteger(n)&&n>=0)return n}}}function Rf(e,t){let n=e=>`${Math.round(e/1048576)} MB`;return[`内存峰值 ${n(e)},预算 ${n(t)}`,`超预算即测试用例形态违例,请合并整页挂载用例的只读断言并把断言下放组件级,预算可经环境变量 LZI_TEST_MEMORY_BUDGET_BYTES 临时覆盖`]}const Q=`https://registry.npmjs.org/`,zf=/* @__PURE__ */ new Map([[`longzai-intelligence`,Q],[`longzai-intelligence-agent-tools`,Q],[`longzai-intelligence-audit`,Q],[`longzai-intelligence-auth`,Q],[`longzai-intelligence-builder`,Q],[`longzai-intelligence-bun`,Q],[`longzai-intelligence-cache`,Q],[`longzai-intelligence-cli`,Q],[`longzai-intelligence-config`,Q],[`longzai-intelligence-dependencies`,Q],[`longzai-intelligence-design-system`,Q],[`longzai-intelligence-dev-tools`,Q],[`longzai-intelligence-electron`,Q],[`longzai-intelligence-error`,Q],[`longzai-intelligence-event-bus`,Q],[`longzai-intelligence-lint`,Q],[`longzai-intelligence-logger`,Q],[`longzai-intelligence-okr`,Q],[`longzai-intelligence-oxfmt`,Q],[`longzai-intelligence-oxlint`,Q],[`longzai-intelligence-plugin`,Q],[`longzai-intelligence-shared-config`,Q],[`longzai-intelligence-shared-kernel`,Q],[`longzai-intelligence-scripts`,Q],[`longzai-intelligence-standards`,Q],[`longzai-intelligence-transport`,Q],[`longzai-intelligence-typescript`,Q],[`longzai-intelligence-vscode`,Q],[`longzai-intelligence-zod`,Q],[`longzai-intelligence-prettier`,Q],[`longzai-intelligence-tsdown`,Q],[`longzai-intelligence-vitest`,Q],[`longzai-intelligence-academy`,Q],[`longzai-intelligence-accounting`,Q],[`longzai-intelligence-activity`,Q],[`longzai-intelligence-administration`,Q],[`longzai-intelligence-agent`,Q],[`longzai-intelligence-agent-broadcast`,Q],[`longzai-intelligence-agent-collaboration`,Q],[`longzai-intelligence-agent-endless`,Q],[`longzai-intelligence-agent-migrator`,Q],[`longzai-intelligence-agent-monitor`,Q],[`longzai-intelligence-agent-prompts`,Q],[`longzai-intelligence-agent-relation`,Q],[`longzai-intelligence-agent-session`,Q],[`longzai-intelligence-agent-swarm`,Q],[`longzai-intelligence-agent-tasks`,Q],[`longzai-intelligence-agent-tasks-data`,Q],[`longzai-intelligence-agent-ui`,Q],[`longzai-intelligence-analytics`,Q],[`longzai-intelligence-api`,Q],[`longzai-intelligence-app-gallery`,Q],[`longzai-intelligence-app-store`,Q],[`longzai-intelligence-architecture`,Q],[`longzai-intelligence-architecture-expert`,Q],[`longzai-intelligence-arkts`,Q],[`longzai-intelligence-art`,Q],[`longzai-intelligence-artifact`,Q],[`longzai-intelligence-artifact-registry`,Q],[`longzai-intelligence-arxiv`,Q],[`longzai-intelligence-arxiv-data`,Q],[`longzai-intelligence-arxiv-markdown`,Q],[`longzai-intelligence-atomic`,Q],[`longzai-intelligence-attention`,Q],[`longzai-intelligence-audio`,Q],[`longzai-intelligence-audio-assistant`,Q],[`longzai-intelligence-augmented-reality`,Q],[`longzai-intelligence-auto-research`,Q],[`longzai-intelligence-automate`,Q],[`longzai-intelligence-benchmark`,Q],[`longzai-intelligence-bilibili`,Q],[`longzai-intelligence-bilibili-data`,Q],[`longzai-intelligence-bilibili-markdown`,Q],[`longzai-intelligence-billing`,Q],[`longzai-intelligence-blackboard`,Q],[`longzai-intelligence-blackboard-data`,Q],[`longzai-intelligence-blackboard-markdown`,Q],[`longzai-intelligence-bluetooth`,Q],[`longzai-intelligence-board`,Q],[`longzai-intelligence-bootstrap`,Q],[`longzai-intelligence-bootstrap-registry`,Q],[`longzai-intelligence-bounty-registry`,Q],[`longzai-intelligence-brawl-stars`,Q],[`longzai-intelligence-broker`,Q],[`longzai-intelligence-bt`,Q],[`longzai-intelligence-business-plan`,Q],[`longzai-intelligence-calendar`,Q],[`longzai-intelligence-camera`,Q],[`longzai-intelligence-canvas`,Q],[`longzai-intelligence-capture`,Q],[`longzai-intelligence-change-maker`,Q],[`longzai-intelligence-changelog`,Q],[`longzai-intelligence-changeset`,Q],[`longzai-intelligence-chat`,Q],[`longzai-intelligence-chess`,Q],[`longzai-intelligence-circuit`,Q],[`longzai-intelligence-claude-code`,Q],[`longzai-intelligence-claude-knowledge`,Q],[`longzai-intelligence-clipboard-share`,Q],[`longzai-intelligence-closed-loop`,Q],[`longzai-intelligence-closed-loop-data`,Q],[`longzai-intelligence-closed-loop-markdown`,Q],[`longzai-intelligence-cloud`,Q],[`longzai-intelligence-code`,Q],[`longzai-intelligence-code-agent`,Q],[`longzai-intelligence-code-reviewer`,Q],[`longzai-intelligence-codebase-research`,Q],[`longzai-intelligence-coding-expert`,Q],[`longzai-intelligence-collaboration`,Q],[`longzai-intelligence-collective`,Q],[`longzai-intelligence-commerce`,Q],[`longzai-intelligence-commit`,Q],[`longzai-intelligence-competition-registry`,Q],[`longzai-intelligence-composer`,Q],[`longzai-intelligence-concrete`,Q],[`longzai-intelligence-concrete-industry`,Q],[`longzai-intelligence-config-registry`,Q],[`longzai-intelligence-context`,Q],[`longzai-intelligence-contract`,Q],[`longzai-intelligence-contract-parity`,Q],[`longzai-intelligence-cookery`,Q],[`longzai-intelligence-country`,Q],[`longzai-intelligence-creativity`,Q],[`longzai-intelligence-cross-platform`,Q],[`longzai-intelligence-crossref`,Q],[`longzai-intelligence-crossref-markdown`,Q],[`longzai-intelligence-crypto`,Q],[`longzai-intelligence-customer-service`,Q],[`longzai-intelligence-cut`,Q],[`longzai-intelligence-dag`,Q],[`longzai-intelligence-dashboard`,Q],[`longzai-intelligence-data`,Q],[`longzai-intelligence-data-science`,Q],[`longzai-intelligence-database`,Q],[`longzai-intelligence-decenterlization`,Q],[`longzai-intelligence-decision`,Q],[`longzai-intelligence-deepseek`,Q],[`longzai-intelligence-deepseek-harness`,Q],[`longzai-intelligence-deepseek-harness-knowledge`,Q],[`longzai-intelligence-delta`,Q],[`longzai-intelligence-deploy`,Q],[`longzai-intelligence-design`,Q],[`longzai-intelligence-design-lab`,Q],[`longzai-intelligence-design-registry`,Q],[`longzai-intelligence-design-trending`,Q],[`longzai-intelligence-device`,Q],[`longzai-intelligence-dimensions`,Q],[`longzai-intelligence-discipline`,Q],[`longzai-intelligence-discovery`,Q],[`longzai-intelligence-disk-space`,Q],[`longzai-intelligence-disk-space-data`,Q],[`longzai-intelligence-disk-space-markdown`,Q],[`longzai-intelligence-distill`,Q],[`longzai-intelligence-docs`,Q],[`longzai-intelligence-docs-registry`,Q],[`longzai-intelligence-document`,Q],[`longzai-intelligence-douyin`,Q],[`longzai-intelligence-douyin-data`,Q],[`longzai-intelligence-douyin-markdown`,Q],[`longzai-intelligence-drone`,Q],[`longzai-intelligence-edge`,Q],[`longzai-intelligence-electrobun`,Q],[`longzai-intelligence-elysia`,Q],[`longzai-intelligence-embodied`,Q],[`longzai-intelligence-empowerment`,Q],[`longzai-intelligence-engineering`,Q],[`longzai-intelligence-env`,Q],[`longzai-intelligence-env-registry`,Q],[`longzai-intelligence-equilibrium`,Q],[`longzai-intelligence-eslint`,Q],[`longzai-intelligence-event`,Q],[`longzai-intelligence-event-tracking`,Q],[`longzai-intelligence-evolution`,Q],[`longzai-intelligence-excel`,Q],[`longzai-intelligence-exchange-rate`,Q],[`longzai-intelligence-execution`,Q],[`longzai-intelligence-experience`,Q],[`longzai-intelligence-expert`,Q],[`longzai-intelligence-expert-thinking`,Q],[`longzai-intelligence-fde`,Q],[`longzai-intelligence-feature-flags`,Q],[`longzai-intelligence-features`,Q],[`longzai-intelligence-federation`,Q],[`longzai-intelligence-feed`,Q],[`longzai-intelligence-feishu`,Q],[`longzai-intelligence-fields-medal-knowledge`,Q],[`longzai-intelligence-file-processing`,Q],[`longzai-intelligence-findings`,Q],[`longzai-intelligence-fitness`,Q],[`longzai-intelligence-font`,Q],[`longzai-intelligence-game`,Q],[`longzai-intelligence-game-studio`,Q],[`longzai-intelligence-gantt`,Q],[`longzai-intelligence-gateway`,Q],[`longzai-intelligence-geo`,Q],[`longzai-intelligence-gesture`,Q],[`longzai-intelligence-git`,Q],[`longzai-intelligence-git-commit`,Q],[`longzai-intelligence-git-insight`,Q],[`longzai-intelligence-git-reviewer`,Q],[`longzai-intelligence-git-swarm`,Q],[`longzai-intelligence-git-swarm-registry`,Q],[`longzai-intelligence-gitcode`,Q],[`longzai-intelligence-github-data`,Q],[`longzai-intelligence-github-markdown`,Q],[`longzai-intelligence-github-trending`,Q],[`longzai-intelligence-github-trending-data`,Q],[`longzai-intelligence-github-trending-markdown`,Q],[`longzai-intelligence-globals`,Q],[`longzai-intelligence-growth`,Q],[`longzai-intelligence-growth-registry`,Q],[`longzai-intelligence-handover`,Q],[`longzai-intelligence-hardware`,Q],[`longzai-intelligence-harness`,Q],[`longzai-intelligence-healthcare`,Q],[`longzai-intelligence-history`,Q],[`longzai-intelligence-horizon`,Q],[`longzai-intelligence-human-resource`,Q],[`longzai-intelligence-i18n`,Q],[`longzai-intelligence-idea`,Q],[`longzai-intelligence-identity`,Q],[`longzai-intelligence-ime`,Q],[`longzai-intelligence-impact-maker`,Q],[`longzai-intelligence-inbox`,Q],[`longzai-intelligence-inbox-registry`,Q],[`longzai-intelligence-input-data`,Q],[`longzai-intelligence-input-markdown`,Q],[`longzai-intelligence-insight`,Q],[`longzai-intelligence-intellectual-property`,Q],[`longzai-intelligence-intent`,Q],[`longzai-intelligence-intentionomics`,Q],[`longzai-intelligence-interview`,Q],[`longzai-intelligence-issues`,Q],[`longzai-intelligence-jev`,Q],[`longzai-intelligence-jev-knowledge`,Q],[`longzai-intelligence-jev-system`,Q],[`longzai-intelligence-journal-of-finance-data`,Q],[`longzai-intelligence-journal-of-financial-and-quantitative-analysis-data`,Q],[`longzai-intelligence-journal-of-financial-economics-data`,Q],[`longzai-intelligence-journals`,Q],[`longzai-intelligence-journals-2026-10`,Q],[`longzai-intelligence-journals-markdown`,Q],[`longzai-intelligence-journals-registry`,Q],[`longzai-intelligence-key-management`,Q],[`longzai-intelligence-knowledge`,Q],[`longzai-intelligence-knowledge-graph`,Q],[`longzai-intelligence-knowledge-markdown`,Q],[`longzai-intelligence-kol`,Q],[`longzai-intelligence-kol-data`,Q],[`longzai-intelligence-kol-markdown`,Q],[`longzai-intelligence-kol-registry`,Q],[`longzai-intelligence-language-model`,Q],[`longzai-intelligence-law`,Q],[`longzai-intelligence-law-data`,Q],[`longzai-intelligence-law-markdown`,Q],[`longzai-intelligence-lean`,Q],[`longzai-intelligence-ledger`,Q],[`longzai-intelligence-legal`,Q],[`longzai-intelligence-liquid-glass`,Q],[`longzai-intelligence-living-previewer`,Q],[`longzai-intelligence-loop`,Q],[`longzai-intelligence-machine-learning`,Q],[`longzai-intelligence-mail`,Q],[`longzai-intelligence-mandala`,Q],[`longzai-intelligence-map`,Q],[`longzai-intelligence-markdown`,Q],[`longzai-intelligence-marketing`,Q],[`longzai-intelligence-marketplace`,Q],[`longzai-intelligence-math`,Q],[`longzai-intelligence-mcn`,Q],[`longzai-intelligence-mcp`,Q],[`longzai-intelligence-mechanisms`,Q],[`longzai-intelligence-mechanisms-registry`,Q],[`longzai-intelligence-media`,Q],[`longzai-intelligence-meditation`,Q],[`longzai-intelligence-meeting-notes`,Q],[`longzai-intelligence-memory`,Q],[`longzai-intelligence-mentor`,Q],[`longzai-intelligence-messaging`,Q],[`longzai-intelligence-mindset`,Q],[`longzai-intelligence-minimax-knowldege`,Q],[`longzai-intelligence-mission-control`,Q],[`longzai-intelligence-model-fusion`,Q],[`longzai-intelligence-model-gateway`,Q],[`longzai-intelligence-moment`,Q],[`longzai-intelligence-montage`,Q],[`longzai-intelligence-movie`,Q],[`longzai-intelligence-music-video`,Q],[`longzai-intelligence-music-video-data`,Q],[`longzai-intelligence-narrative-analyzer`,Q],[`longzai-intelligence-nation`,Q],[`longzai-intelligence-nginx`,Q],[`longzai-intelligence-nginx-cli`,Q],[`longzai-intelligence-nobel-prize-knowledge`,Q],[`longzai-intelligence-notification`,Q],[`longzai-intelligence-npm`,Q],[`longzai-intelligence-npm-registry`,Q],[`longzai-intelligence-npm-registry-data`,Q],[`longzai-intelligence-observability`,Q],[`longzai-intelligence-office-industry`,Q],[`longzai-intelligence-okr-data`,Q],[`longzai-intelligence-okr-markdown`,Q],[`longzai-intelligence-older`,Q],[`longzai-intelligence-one`,Q],[`longzai-intelligence-one-digest`,Q],[`longzai-intelligence-one-digest-data`,Q],[`longzai-intelligence-one-digest-markdown`,Q],[`longzai-intelligence-one-digest-registry`,Q],[`longzai-intelligence-one-trae-works`,Q],[`longzai-intelligence-ontology`,Q],[`longzai-intelligence-open-pencil`,Q],[`longzai-intelligence-open-router`,Q],[`longzai-intelligence-open-router-data`,Q],[`longzai-intelligence-open-router-markdown`,Q],[`longzai-intelligence-opencode`,Q],[`longzai-intelligence-opencode-knowledge`,Q],[`longzai-intelligence-opportunity`,Q],[`longzai-intelligence-orchestry`,Q],[`longzai-intelligence-organization`,Q],[`longzai-intelligence-orm`,Q],[`longzai-intelligence-outfit`,Q],[`longzai-intelligence-outsourcing`,Q],[`longzai-intelligence-overseas`,Q],[`longzai-intelligence-pagination`,Q],[`longzai-intelligence-panel`,Q],[`longzai-intelligence-paper-reader`,Q],[`longzai-intelligence-parametric-industry`,Q],[`longzai-intelligence-partner`,Q],[`longzai-intelligence-pay`,Q],[`longzai-intelligence-payment`,Q],[`longzai-intelligence-permission`,Q],[`longzai-intelligence-personal-assistant`,Q],[`longzai-intelligence-philosophy`,Q],[`longzai-intelligence-philosophy-markdown`,Q],[`longzai-intelligence-philosophy-ontology`,Q],[`longzai-intelligence-pi-knowledge`,Q],[`longzai-intelligence-pii`,Q],[`longzai-intelligence-pipeline`,Q],[`longzai-intelligence-pitfalls`,Q],[`longzai-intelligence-plugin-registry`,Q],[`longzai-intelligence-pm2`,Q],[`longzai-intelligence-policy-research`,Q],[`longzai-intelligence-port`,Q],[`longzai-intelligence-portal`,Q],[`longzai-intelligence-previewer`,Q],[`longzai-intelligence-prezi`,Q],[`longzai-intelligence-prisma`,Q],[`longzai-intelligence-process-monitor`,Q],[`longzai-intelligence-product-requirement`,Q],[`longzai-intelligence-product-research`,Q],[`longzai-intelligence-programming-language`,Q],[`longzai-intelligence-project`,Q],[`longzai-intelligence-project-data`,Q],[`longzai-intelligence-project-markdown`,Q],[`longzai-intelligence-project-portfolio`,Q],[`longzai-intelligence-project-registry`,Q],[`longzai-intelligence-promotion`,Q],[`longzai-intelligence-proposals`,Q],[`longzai-intelligence-prospect`,Q],[`longzai-intelligence-psychoanalyst`,Q],[`longzai-intelligence-publication`,Q],[`longzai-intelligence-qcloud`,Q],[`longzai-intelligence-quant`,Q],[`longzai-intelligence-queue`,Q],[`longzai-intelligence-quick-notes`,Q],[`longzai-intelligence-react-devtools`,Q],[`longzai-intelligence-react-native`,Q],[`longzai-intelligence-reader`,Q],[`longzai-intelligence-reading-distinction`,Q],[`longzai-intelligence-reading-shanhaijing`,Q],[`longzai-intelligence-readme`,Q],[`longzai-intelligence-reasoning`,Q],[`longzai-intelligence-records`,Q],[`longzai-intelligence-recruitment`,Q],[`longzai-intelligence-reflections`,Q],[`longzai-intelligence-release`,Q],[`longzai-intelligence-release-markdown`,Q],[`longzai-intelligence-reliability`,Q],[`longzai-intelligence-remote-desktop`,Q],[`longzai-intelligence-remote-machine`,Q],[`longzai-intelligence-remote-machine-registry`,Q],[`longzai-intelligence-remotion`,Q],[`longzai-intelligence-report`,Q],[`longzai-intelligence-repository`,Q],[`longzai-intelligence-repository-handover`,Q],[`longzai-intelligence-research-report`,Q],[`longzai-intelligence-research-report-data`,Q],[`longzai-intelligence-research-report-markdown`,Q],[`longzai-intelligence-research-report-registry`,Q],[`longzai-intelligence-resilience`,Q],[`longzai-intelligence-reverse-engineering`,Q],[`longzai-intelligence-review-of-financial-studies-data`,Q],[`longzai-intelligence-reviewer`,Q],[`longzai-intelligence-risk`,Q],[`longzai-intelligence-roadmap`,Q],[`longzai-intelligence-roadmap-data`,Q],[`longzai-intelligence-roadmap-markdown`,Q],[`longzai-intelligence-router`,Q],[`longzai-intelligence-rss`,Q],[`longzai-intelligence-rss-markdown`,Q],[`longzai-intelligence-runtime`,Q],[`longzai-intelligence-runtime-registry`,Q],[`longzai-intelligence-sales`,Q],[`longzai-intelligence-scanner`,Q],[`longzai-intelligence-schedule-markdown`,Q],[`longzai-intelligence-schedule-registry`,Q],[`longzai-intelligence-scheduler`,Q],[`longzai-intelligence-schema`,Q],[`longzai-intelligence-scope`,Q],[`longzai-intelligence-scrape`,Q],[`longzai-intelligence-screenshots`,Q],[`longzai-intelligence-scripts-registry`,Q],[`longzai-intelligence-search`,Q],[`longzai-intelligence-security`,Q],[`longzai-intelligence-security-bounty-registry`,Q],[`longzai-intelligence-security-inventory`,Q],[`longzai-intelligence-serverless`,Q],[`longzai-intelligence-share`,Q],[`longzai-intelligence-sheet`,Q],[`longzai-intelligence-short-video`,Q],[`longzai-intelligence-skill`,Q],[`longzai-intelligence-slider`,Q],[`longzai-intelligence-smart-transition`,Q],[`longzai-intelligence-sms`,Q],[`longzai-intelligence-software-factory`,Q],[`longzai-intelligence-soul`,Q],[`longzai-intelligence-specs`,Q],[`longzai-intelligence-spline`,Q],[`longzai-intelligence-sports`,Q],[`longzai-intelligence-ssl`,Q],[`longzai-intelligence-startup`,Q],[`longzai-intelligence-state-machine`,Q],[`longzai-intelligence-storage`,Q],[`longzai-intelligence-strategy`,Q],[`longzai-intelligence-strategy-consulting`,Q],[`longzai-intelligence-strategy-consulting-data`,Q],[`longzai-intelligence-strategy-consulting-markdown`,Q],[`longzai-intelligence-subtitle`,Q],[`longzai-intelligence-supply-chain`,Q],[`longzai-intelligence-support`,Q],[`longzai-intelligence-survey`,Q],[`longzai-intelligence-system`,Q],[`longzai-intelligence-system-data`,Q],[`longzai-intelligence-system-markdown`,Q],[`longzai-intelligence-system-registry`,Q],[`longzai-intelligence-talk`,Q],[`longzai-intelligence-taro`,Q],[`longzai-intelligence-task`,Q],[`longzai-intelligence-task-data`,Q],[`longzai-intelligence-task-markdown`,Q],[`longzai-intelligence-telemetry`,Q],[`longzai-intelligence-templates`,Q],[`longzai-intelligence-tenant`,Q],[`longzai-intelligence-terminal`,Q],[`longzai-intelligence-testing`,Q],[`longzai-intelligence-thinking`,Q],[`longzai-intelligence-token-exchange`,Q],[`longzai-intelligence-token-finance`,Q],[`longzai-intelligence-token-handover`,Q],[`longzai-intelligence-toolchain`,Q],[`longzai-intelligence-topology`,Q],[`longzai-intelligence-tracking-bennett-brassard`,Q],[`longzai-intelligence-tracking-deng-yu`,Q],[`longzai-intelligence-tracking-hong-wang`,Q],[`longzai-intelligence-tracking-jacob-tsimerman`,Q],[`longzai-intelligence-tracking-john-clarke`,Q],[`longzai-intelligence-tracking-john-martinis`,Q],[`longzai-intelligence-tracking-john-pardon`,Q],[`longzai-intelligence-tracking-michel-devoret`,Q],[`longzai-intelligence-tracking-nation`,Q],[`longzai-intelligence-tracking-qbitai`,Q],[`longzai-intelligence-tracking-terrytao`,Q],[`longzai-intelligence-tracking-xiao-lin`,Q],[`longzai-intelligence-tracking-yu-bo`,Q],[`longzai-intelligence-trader`,Q],[`longzai-intelligence-trae`,Q],[`longzai-intelligence-training-data`,Q],[`longzai-intelligence-translator`,Q],[`longzai-intelligence-travel`,Q],[`longzai-intelligence-trending`,Q],[`longzai-intelligence-tsconfig`,Q],[`longzai-intelligence-tsdoc`,Q],[`longzai-intelligence-tsgo`,Q],[`longzai-intelligence-turbo`,Q],[`longzai-intelligence-turing-award-knowledge`,Q],[`longzai-intelligence-twitter`,Q],[`longzai-intelligence-twitter-data`,Q],[`longzai-intelligence-twitter-markdown`,Q],[`longzai-intelligence-typeorm`,Q],[`longzai-intelligence-usecase`,Q],[`longzai-intelligence-user-experience`,Q],[`longzai-intelligence-user-research`,Q],[`longzai-intelligence-userscript`,Q],[`longzai-intelligence-utils`,Q],[`longzai-intelligence-value-chain`,Q],[`longzai-intelligence-vector-search`,Q],[`longzai-intelligence-vendor`,Q],[`longzai-intelligence-venture-capital`,Q],[`longzai-intelligence-version`,Q],[`longzai-intelligence-video-generation`,Q],[`longzai-intelligence-video-player`,Q],[`longzai-intelligence-vite`,Q],[`longzai-intelligence-voice`,Q],[`longzai-intelligence-voice-recorder`,Q],[`longzai-intelligence-vscode-developer`,Q],[`longzai-intelligence-vuln`,Q],[`longzai-intelligence-vuln-data`,Q],[`longzai-intelligence-vuln-markdown`,Q],[`longzai-intelligence-vuln-registry`,Q],[`longzai-intelligence-warehouse`,Q],[`longzai-intelligence-wealth`,Q],[`longzai-intelligence-web3`,Q],[`longzai-intelligence-webhook`,Q],[`longzai-intelligence-websocket`,Q],[`longzai-intelligence-wechat`,Q],[`longzai-intelligence-wechat-miniprogram`,Q],[`longzai-intelligence-wechat-pay`,Q],[`longzai-intelligence-wifi`,Q],[`longzai-intelligence-wiki`,Q],[`longzai-intelligence-word`,Q],[`longzai-intelligence-work`,Q],[`longzai-intelligence-worker`,Q],[`longzai-intelligence-workflow`,Q],[`longzai-intelligence-workflow-data`,Q],[`longzai-intelligence-workflow-markdown`,Q],[`longzai-intelligence-workflow-registry`,Q],[`longzai-intelligence-workspace`,Q],[`longzai-intelligence-writer`,Q],[`longzai-intelligence-xiaohongshu`,Q],[`longzai-intelligence-xiaohongshu-data`,Q],[`longzai-intelligence-xiaohongshu-markdown`,Q],[`longzai-intelligence-youtube`,Q],[`longzai-intelligence-youtube-data`,Q],[`longzai-intelligence-youtube-markdown`,Q],[`longzai-intelligence-zcode`,Q],[`longzai-intelligence-zcode-cleaner`,Q],[`longzai-intelligence-zcode-commit`,Q],[`longzai-intelligence-zcode-knowledge`,Q],[`longzai-intelligence-zcode-remote`,Q],[`longzai-intelligence-zcode-security`,Q],[`longzai-intelligence-zed-delta-knowledge`,Q],[`longzai-intelligence-zhihu`,Q],[`longzai-intelligence-zhihu-data`,Q],[`longzai-intelligence-zhihu-markdown`,Q]]),Bf=/* @__PURE__ */ `longzai-intelligence-aliyun-private.longzai-intelligence-api-plugin-private.longzai-intelligence-api-private.longzai-intelligence-app-gallery-private.longzai-intelligence-app-store-connect-private.longzai-intelligence-auth-private.longzai-intelligence-bilibili-markdown-private.longzai-intelligence-bilibili-private.longzai-intelligence-codebase-research-private.longzai-intelligence-douyin-markdown-private.longzai-intelligence-electron-private.longzai-intelligence-gantt-private.longzai-intelligence-gateway-private.longzai-intelligence-git-reviewer-private.longzai-intelligence-idea-private.longzai-intelligence-intentionomics-private.longzai-intelligence-interoperation-private.longzai-intelligence-knowledge-private.longzai-intelligence-language-model-private.longzai-intelligence-law-markdown-private.longzai-intelligence-law-private.longzai-intelligence-loop-private.longzai-intelligence-narrative-analyzer-private.longzai-intelligence-okr-private.longzai-intelligence-paper-reader-private.longzai-intelligence-plugin-registry-private.longzai-intelligence-policy-research-private.longzai-intelligence-previewer-private.longzai-intelligence-product-research-private.longzai-intelligence-qcloud-private.longzai-intelligence-release-workflow-private.longzai-intelligence-research-report-markdown-private.longzai-intelligence-research-report-private.longzai-intelligence-roadmap-private.longzai-intelligence-runtime-registry-private.longzai-intelligence-scrape-private.longzai-intelligence-search-private.longzai-intelligence-session-continuity-private.longzai-intelligence-session-roaming-private.longzai-intelligence-strategy-consulting-markdown-private.longzai-intelligence-strategy-consulting-private.longzai-intelligence-terminal-private.longzai-intelligence-twitter-markdown-private.longzai-intelligence-twitter-private.longzai-intelligence-user-research-private.longzai-intelligence-vector-search-private.longzai-intelligence-xiaohongshu-markdown-private.longzai-intelligence-youtube-markdown-private.longzai-intelligence-youtube-private.longzai-intelligence-zhihu-markdown-private.longzai-intelligence-zhihu-private`.split(`.`),Vf=`LZI_GLOBALS_ROOT`,Hf=/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/;var Uf=class extends Error{details;constructor(e,t=`install.extraScopes`){super(`${t} 校验失败:\n${e.map(e=>`- ${e}`).join(`
207
+ `)}`),this.name=`InstallScopesError`,this.details=e}};function Wf(e){if(typeof e!=`string`)return!1;try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`}catch{return!1}}function Gf(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||!Hf.test(t)?a.push(`\`${n}\` 不是合法 scope 名(仅允许字母/数字开头,后接字母/数字与 . _ -,@ 前缀可省略)`):Wf(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||!Hf.test(t)?a.push(`\`${e}\` 不是合法 scope 名(仅允许字母/数字开头,后接字母/数字与 . _ -,@ 前缀可省略)`):o[t]===void 0?s.add(t):a.push(`\`${t}\` 同时出现在 extraScopes 与 privateScopes(追加安装源与排除轨声明矛盾)`)}if(a.length>0)throw new Uf(a);for(let[e,t]of Object.entries(o))i[e]=t;for(let e of s)delete i[e];return i}function Kf(e,t,n,r){let i=Gf(e,t,n,`globals 仓 lzi-bun-install.config.ts`),a=r?.replace(/^@+/,``),o=new Set((n??[]).map(e=>e.replace(/^@+/,``)));return a!==void 0&&!a.endsWith(`-private`)&&Hf.test(a)&&!Object.hasOwn(i,a)&&!o.has(a)&&(i[a]=`https://registry.npmjs.org/`),i}function qf(e){let t=[];if(typeof e!=`object`||!e)throw new Uf([`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 Uf([`scopes 必须是 scope → registry 的对象映射`],`globals 预设 lzi-bun-install.config.ts`);let r={};for(let[e,i]of Object.entries(n))Hf.test(e)?typeof i!=`string`||!Wf(i)?t.push(`\`${e}\` 的安装源 \`${String(i)}\` 不是合法的 http/https URL`):r[e]=i:t.push(`\`${e}\` 不是合法 scope 名(仅允许字母/数字开头,后接字母/数字与 . _ -,不含 @ 前缀)`);if(t.length>0)throw new Uf(t,`globals 预设 lzi-bun-install.config.ts`);if(Object.keys(r).length===0)throw new Uf([`scopes 清单为空(真源不允许空清单)`],`globals 预设 lzi-bun-install.config.ts`);return r}const Jf=/* @__PURE__ */ new Set([`web`,`desktop`,`desktop-host`,`mobile`,`miniprogram`,`ui`]);function Yf(e){let t=process.env.LZI_TEST_MEMORY_BUDGET_BYTES;if(t!==void 0){let e=Number.parseInt(t,10);if(Number.isInteger(e)&&e>0)return e}return e!==void 0&&Jf.has(e)?1610612736:1073741824}const Xf=e=>{let t=e;for(;;){if(r(d(t,`.git`)))return t;let e=d(t,`..`);if(e===t)return;t=e}},Zf=(e,t)=>{if(t!==void 0&&t.length>0)return{scopeName:t};let n=Xf(e);return n===void 0?{skipped:!0}:{scopeName:l(n)}},Qf=e=>({scopeName:e,registered:zf.has(e)}),$f=async(e={})=>{let t=Zf(process.cwd(),e.scopeName);if(`skipped`in t){X(`当前目录不在任何 git 项目仓内,跳过登记检查`);return}let n=Qf(t.scopeName);n.registered?X(`当前项目 ${n.scopeName} 已登记于 bun 侧安装源注册表`):(Z(`当前项目 ${n.scopeName} 未登记于 bun 侧安装源注册表`),Z(`修复指引:补登 bun 仓 packages/config 的 scopes.constants.ts 与 globals 仓 lzi-bun-install.config.ts 双写条目,双写后各仓执行 bun-config:generate 生效`),process.exit(1))},ep=/* @__PURE__ */ new Set([`build`,`coverage`,`dist`,`node_modules`,`out`]),tp=/* @__PURE__ */ new Set([`ENAMETOOLONG`,`EACCES`,`EPERM`,`ENOENT`]),np=Ws([zs(cs()),Hs({packages:zs(cs())})]),rp=e=>typeof e!=`object`||!e||!(`code`in e)?!1:typeof e.code==`string`,ip=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}$`)},ap=e=>{let t={positives:[],negatives:[]};for(let n of e)n.startsWith(`!`)?t.negatives.push(ip(n.slice(1))):t.positives.push(ip(n));return t},op=e=>{let t=np.safeParse(e);if(t.success)return Array.isArray(t.data)?t.data:t.data.packages},sp=(e,t)=>e.positives.some(e=>e.test(t))&&!e.negatives.some(e=>e.test(t)),cp=(e,t)=>e.negatives.some(e=>e.test(t)),lp=[`bun.lock`,`bun.lockb`],up=Hs({name:cs().optional(),workspaces:np.optional()}),dp=Hs({name:cs().optional()}),fp=async e=>{try{let t=dp.safeParse(JSON.parse(await S(e,`utf-8`)));return t.success?t.data.name??null:null}catch{return null}},pp=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 C(r.dir,{withFileTypes:!0})}catch(n){if(!rp(n)||!tp.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()&&lp.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 fp(d(r.dir,`package.json`))}));for(let e of i)e.isDirectory()&&(e.name.startsWith(`.`)||ep.has(e.name)||r.depth>=5||n.push({dir:d(r.dir,e.name),depth:r.depth+1}))}return t},mp=async e=>{let t;try{t=JSON.parse(await S(d(e,`package.json`),`utf-8`))}catch{throw Error(`根 package.json 不存在或不可解析,请在仓库根执行本命令`)}let n=up.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=op(r.workspaces);if(o===void 0)return{rootName:i,scope:a,hasWorkspaces:!1,memberCount:0,violations:[],notices:[],scanSkips:[],ok:!0};let s=ap(o),c=await pp(e),l=[],u=[],f=new Map(c.packageDirs.map(e=>[e.relPath,e.name])),p=c.packageDirs.map(e=>e.relPath).filter(e=>sp(s,e));c.rootHasLock||l.push({kind:`missing-root-lock`,path:``,message:`仓库根缺少 bun.lock,声明了 workspaces 的 monorepo 锁文件应只存在于根`});let m=/* @__PURE__ */ new Set;for(let e of c.lockDirs){if(sp(s,e)){m.add(e),l.push({kind:`stray-member-lock`,path:e,message:`${e} 是 workspaces 成员却持有自己的 bun.lock,属游离锁文件`});continue}let t=f.get(e)??null;t===null?u.push({kind:`orphan-lock`,path:e,message:`${e} 存在锁文件但没有 package.json,请确认目录用途`}):cp(s,e)?u.push({kind:`excluded-standalone`,path:e,message:`${e} 为负向 glob 显式排除的独立安装根,锁文件属合法形态`}):a!==null&&t.startsWith(`${a}/`)?(m.add(e),l.push({kind:`uncovered-same-scope`,path:e,message:`${e}(${t})与根包同作用域却未被 workspaces 覆盖,已按独立安装根长出游离锁`})):u.push({kind:`foreign-scope-lock`,path:e,message:`${e}(${t})不属于根作用域且持有独立锁文件,若为有意保留请以负向 glob 显式排除`})}for(let e of c.packageDirs)p.includes(e.relPath)||cp(s,e.relPath)||m.has(e.relPath)||a!==null&&e.name!==null&&e.name.startsWith(`${a}/`)&&l.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:l,notices:u,scanSkips:c.scanSkips,ok:l.length===0}},hp=async()=>{let e=process.cwd();X(`正在扫描 ${e} 下的工作区布局...`);try{let t=await mp(e);if(!t.hasWorkspaces){X(`未声明 workspaces,非 bun workspaces monorepo,跳过锁文件校验`);return}if(t.scanSkips.length>0){Z(`\n${t.scanSkips.length} 项目录读取降级告警,结论基于其余可读目录:`);for(let e of t.scanSkips)Z(` ${e.path} 读取失败已跳过该子树,错误码 ${e.code}`)}if(X(`根包 ${t.rootName??`未命名`},workspaces 成员 ${t.memberCount} 个`),t.notices.length>0){X(`\n${t.notices.length} 项提示:`);for(let e of t.notices)X(` ${e.message}`)}if(!t.ok){X(`\n发现 ${t.violations.length} 项违规:`);for(let e of t.violations)X(` ${e.message}`);X(`
208
+ 修复指引: 删除成员目录的游离 bun.lock 后在仓库根执行 bun install;覆盖缺口补 workspaces glob,刻意独立的子项目以负向 glob 显式排除`),process.exit(1)}X(`单一锁文件不变量成立,无游离锁文件与覆盖缺口`)}catch(e){Z(`错误: ${e instanceof Error?e.message:String(e)}`),process.exit(1)}},gp=/* @__PURE__ */ new Set([`.bun`]),_p=/* @__PURE__ */ new Set([`ENOENT`,`ENOTDIR`]),vp=Hs({workspaces:np.optional()}),yp=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 C(i.dir,{withFileTypes:!0})}catch(t){if(!rp(t)||!tp.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(`.`)||ep.has(e.name)||i.depth>=5||r.push({dir:d(i.dir,e.name),depth:i.depth+1}))}return{packageDirPaths:t,scanSkips:n}},bp=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 C(e,{withFileTypes:!0})}catch(n){if(!rp(n)||!tp.has(n.code))throw n;r.push({path:e.slice(t.length+1),code:n.code});continue}for(let o of a){let a=d(e,o.name);if(!gp.has(o.name)){if(o.isSymbolicLink())try{await T(a)}catch(e){if(rp(e)&&_p.has(e.code)){n.push({path:a.slice(t.length+1),target:await w(a)});continue}r.push({path:a.slice(t.length+1),code:rp(e)?e.code:`UNKNOWN`})}else o.isDirectory()&&i.push(a)}}}return{dangling:n,scanSkips:r}},xp=async e=>{let t;try{t=JSON.parse(await S(d(e,`package.json`),`utf-8`))}catch{throw Error(`根 package.json 不存在或不可解析,请在仓库根执行本命令`)}let n=vp.safeParse(t);if(!n.success)throw Error(`根 package.json 不存在或不可解析,请在仓库根执行本命令`);let r=op(n.data.workspaces);if(r===void 0)return{hasWorkspaces:!1,memberCount:0,scannedNodeModulesRoots:0,dangling:[],scanSkips:[],ok:!0};let i=ap(r),a=await yp(e),o=a.packageDirPaths.filter(e=>sp(i,e)),s=[],c=[...a.scanSkips],l=0;for(let t of[``,...o]){let n=d(e,t,`node_modules`);try{if(!(await T(n)).isDirectory())continue}catch{continue}l+=1;let r=await bp(n,e);s.push(...r.dangling),c.push(...r.scanSkips)}return{hasWorkspaces:!0,memberCount:o.length,scannedNodeModulesRoots:l,dangling:s,scanSkips:c,ok:s.length===0}},Sp=async(e,t)=>{let n={removed:[],kept:[]};for(let r of t){let t=d(e,r.path);try{if(!(await x(t)).isSymbolicLink()){n.kept.push(r.path);continue}await T(t),n.kept.push(r.path)}catch(e){if(!rp(e)||!_p.has(e.code)){n.kept.push(r.path);continue}await E(t),n.removed.push(r.path)}}return n},Cp=async()=>{let e=process.cwd();X(`正在扫描 ${e} 下的安装布局...`);try{let t=await xp(e);if(!t.hasWorkspaces){X(`未声明 workspaces,非 bun workspaces monorepo,跳过悬挂链接检测`);return}if(t.scanSkips.length>0){Z(`\n${t.scanSkips.length} 项目录读取降级告警,结论基于其余可读目录:`);for(let e of t.scanSkips)Z(` ${e.path} 读取失败已跳过该子树,错误码 ${e.code}`)}if(X(`workspaces 成员 ${t.memberCount} 个,扫描 ${t.scannedNodeModulesRoots} 个 node_modules 树`),t.dangling.length>0){X(`\n发现 ${t.dangling.length} 根悬挂符号链接:`);for(let e of t.dangling)X(` ${e.path} 指向已不存在的 ${e.target}`);X(`
209
+ 修复指引:执行 bunx @longzai-intelligence-bun/cli node-links fix 回收悬挂死链后重试,有效链接零触碰`),process.exit(Math.min(t.dangling.length,255))}X(`安装布局一致,未发现悬挂符号链接`)}catch(e){Z(`错误: ${e instanceof Error?e.message:String(e)}`),process.exit(1)}},wp=async()=>{let e=process.cwd();X(`正在扫描 ${e} 下的悬挂符号链接...`);try{let t=await xp(e);if(!t.hasWorkspaces){X(`未声明 workspaces,非 bun workspaces monorepo,跳过悬挂链接回收`);return}if(t.dangling.length===0){X(`未发现悬挂符号链接,无需回收,共巡查 ${t.scannedNodeModulesRoots} 个 node_modules 树`);return}X(`发现 ${t.dangling.length} 根悬挂符号链接,开始回收:`);for(let e of t.dangling)X(` ${e.path} 指向已不存在的 ${e.target}`);let n=await Sp(e,t.dangling);for(let e of n.removed)X(`已回收 ${e}`);for(let e of n.kept)Z(`未能回收 ${e},链接状态已变化,请人工确认`);let r=await xp(e);X(`回收完成,清除 ${n.removed.length} 根,剩余悬挂 ${r.dangling.length} 根,有效链接零触碰`),(r.dangling.length>0||n.kept.length>0)&&process.exit(1)}catch(e){Z(`错误: ${e instanceof Error?e.message:String(e)}`),process.exit(1)}};var Tp=class extends Error{configPath;constructor(e,t,n){super(e,n),this.name=`SharedConfigError`,this.configPath=t}},Ep=class extends Tp{searchFrom;constructor(e){super(`未在 ${e} 找到配置文件`,e),this.name=`SharedConfigNotFoundError`,this.searchFrom=e}},Dp=class extends Tp{issues;constructor(e,t){super(`配置校验失败,共 ${e.length} 个问题`,t),this.name=`SharedConfigValidationError`,this.issues=e}};function Op(e,t,n,r){let i=e;if(r.schema!==void 0){let e=r.schema.safeParse(i);if(!e.success)throw new Dp(e.error.issues,t);i=e.data}return r.transform!==void 0&&(i=r.transform(i,n)),i}function kp(e){return e instanceof Error&&e.message.length>0?`,底层原因为 ${e.name}: ${e.message}`:``}var Ap=class extends Tp{cause;constructor(e,t){super(`加载配置文件 ${e} 失败${kp(t)}`,e,{cause:t}),this.name=`SharedConfigLoadError`,this.cause=t}};function jp(e){return typeof e==`object`&&!!e}function Mp(e){return typeof e==`object`&&!!e}async function Np(e,t={}){let n=p(e);if(!r(n))throw new Ep(n);let i;try{let e=await import(n);i=jp(e)?e.default:void 0}catch(e){throw new Ap(n,e)}if(i===void 0)throw new Ap(n,TypeError(`配置文件缺少默认导出`));if(!Mp(i))throw new Ap(n,TypeError(`配置文件的默认导出必须是对象`));return{config:Op(i,n,u(n),t),configFilePath:n}}function Pp(e=process.cwd()){let t=p(e);for(;;){let e=d(t,`lzi.config.ts`);if(r(e))return e;let n=u(t);if(n===t)return null;t=n}}async function Fp(e={}){let t=e.cwd??process.cwd(),n=Pp(t);if(n===null)throw new Ep(t);let r=p(n,`..`),{config:i}=await Np(n);return{config:i,configPath:r,configFilePath:n}}function Ip(e){return typeof e==`object`&&!!e}async function Lp(e){let t;try{t=await C(e)}catch(t){throw new Ap(e,t)}let n=t.filter(e=>e.endsWith(`.config.ts`)).sort();if(n.length===0)throw new Ap(e,Error(`配置目录内没有 .config.ts 分片文件`));let r={};for(let t of n){let n=await Np(d(e,t));r={...r,...n.config}}let i=r;if(!Ip(i))throw new Ap(e,Error(`配置目录合并结果不是对象形态`));return i}function Rp(e,t=process.cwd()){let n=Array.isArray(e)?e:[e],r=p(t);for(;;){for(let e of n){let t=d(r,e);if(zp(t))return t}let e=u(r);if(e===r)return null;r=e}}function zp(e){try{return s(e).isDirectory()}catch{return!1}}function Bp(e,t=process.cwd()){let n=Array.isArray(e)?e:[e],i=p(t);for(;;){for(let e of n){let t=d(i,e);if(r(t))return t}let e=u(i);if(e===i)return null;i=e}}function Vp(e){return typeof e==`object`&&!!e}function Hp(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}async function Up(e={}){let t=e.cwd??p(process.cwd());if(e.explicitPath!==void 0){let t=await Np(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=Bp(e.standaloneFile,t);if(n!==null){let{config:t}=await Np(n);return{success:!0,config:Op(t,n,u(n),e),source:`standalone`,configFilePath:n}}}if(e.standaloneDir!==void 0){let n=Rp(e.standaloneDir,t);if(n!==null)return{success:!0,config:Op(await Lp(n),n,n,e),source:`standalone`,configFilePath:n}}if(e.unifiedField!==void 0){let n,r;try{let{config:i,configFilePath:a}=await Fp({cwd:t}),o=i;n=Hp(o)?o[e.unifiedField]:void 0,r=a}catch(e){if(!(e instanceof Ep))throw e}if(r!==void 0&&n!==void 0&&Vp(n))return{success:!0,config:Op(n,r,u(r),e),source:`unified`,configFilePath:r}}return{success:!1,configFilePath:null}}const Wp=[`packages/*`,`apps/*`];function Gp(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Kp(e){if(Array.isArray(e))return e.every(e=>typeof e==`string`)?e:void 0;if(Gp(e)){let t=e.packages;if(Array.isArray(t)&&t.every(e=>typeof e==`string`))return{packages:t}}}function qp(e){let t=p(e,`package.json`);if(!r(t))throw new Ep(e);let n;try{let e=JSON.parse(a(t,`utf8`));n=Gp(e)?Kp(e.workspaces):void 0}catch(e){throw new Ap(t,e)}let i=Array.isArray(n)?n:n?.packages;return i&&i.length>0?i:Wp}async function Jp(e,t={}){let n=qp(e),i=/* @__PURE__ */ new Set,o=[];for(let s of n){let n=new Bun.Glob(`${s}/package.json`);for await(let s of n.scan({cwd:e,absolute:!0,onlyFiles:!0})){let e=p(s,`..`);if(i.has(e))continue;let n;try{let e=JSON.parse(a(s,`utf8`));n=typeof e==`object`&&e?e:void 0}catch{continue}n!==void 0&&typeof n.name==`string`&&n.name.length!==0&&(t.configFileName!==void 0&&!r(p(e,t.configFileName))||(i.add(e),o.push({name:n.name,dir:e})))}}return o}var Yp=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}},Xp=class extends Error{bunfigPath;constructor(e){super(`${e} 已存在且非 lzi-bun 生成(缺少 @lzi-bun 自动生成,请勿编辑 标记),如需 lzi-bun 接管,请删除该文件或手动合并后重试`),this.name=`BunfigProtectedError`,this.bunfigPath=e}};function Zp(e){return`"${e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}"`}function Qp(e,t){let n=e.map(e=>Zp(e)),r=`[${n.join(`, `)}]`;return`${t} = `.length+r.length<=100?r:`[\n${n.map(e=>` ${e},`).join(`
210
+ `)}\n]`}function $p(e){let t=[`registry = ${Zp(e.registry)}`],n=tm(`linker`,e.linker);n&&t.push(n);let r=tm(`globalStore`,e.globalStore);r&&t.push(r);let i=Object.entries(e.scopes).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>`${Zp(`@${e}`)} = ${Zp(t)}`),a=[`[install]\n${t.join(`
211
211
  `)}`];return i.length>0&&a.push(`[install.scopes]\n${i.join(`
212
212
  `)}`),a.join(`
213
213
 
214
- `)}function $p(e,t,n){return{registry:`https://mirrors.cloud.tencent.com/npm/`,scopes:Gf(t,e?.extraScopes,e?.privateScopes,n),linker:e?.linker,globalStore:e?.globalStore}}function em(e,t){if(t!==void 0){if(typeof t==`boolean`||typeof t==`number`)return`${e} = ${t}`;if(typeof t==`string`)return`${e} = ${Xp(t)}`;if(Array.isArray(t))return t.length===0?void 0:`${e} = ${Zp(t,e)}`}}function tm(e){let t=[];e.install&&t.push(Qp(e.install));let n=e.test,r=[],i=em(`preload`,n.preload);i&&r.push(i);let a=em(`coverage`,n.coverage);a&&r.push(a);let o=em(`coverageSkipTestFiles`,n.coverageSkipTestFiles);o&&r.push(o);let s=em(`coverageReporter`,n.coverageReporter);s&&r.push(s);let c=em(`coverageDir`,n.coverageDir);c&&r.push(c);let l=em(`coveragePathIgnorePatterns`,n.coveragePathIgnorePatterns);l&&r.push(l);let u=em(`coverageIgnoreSourcemaps`,n.coverageIgnoreSourcemaps);u&&r.push(u);let d=em(`timeout`,n.timeout);return d&&r.push(d),r.length>0&&t.push(`[test]\n${r.join(`
214
+ `)}function em(e,t,n,r){let i=Kf(t,e?.extraScopes,e?.privateScopes,n);if(r!==void 0){let t=new Set((e?.privateScopes??[]).map(e=>e.replace(/^@+/,``)));for(let e of Bf)!Object.hasOwn(i,e)&&!t.has(e)&&(i[e]=r)}return{registry:`https://mirrors.cloud.tencent.com/npm/`,scopes:i,linker:e?.linker,globalStore:e?.globalStore}}function tm(e,t){if(t!==void 0){if(typeof t==`boolean`||typeof t==`number`)return`${e} = ${t}`;if(typeof t==`string`)return`${e} = ${Zp(t)}`;if(Array.isArray(t))return t.length===0?void 0:`${e} = ${Qp(t,e)}`}}function nm(e){let t=[];e.install&&t.push($p(e.install));let n=e.test,r=[],i=tm(`preload`,n.preload);i&&r.push(i);let a=tm(`coverage`,n.coverage);a&&r.push(a);let o=tm(`coverageSkipTestFiles`,n.coverageSkipTestFiles);o&&r.push(o);let s=tm(`coverageReporter`,n.coverageReporter);s&&r.push(s);let c=tm(`coverageDir`,n.coverageDir);c&&r.push(c);let l=tm(`coveragePathIgnorePatterns`,n.coveragePathIgnorePatterns);l&&r.push(l);let u=tm(`coverageIgnoreSourcemaps`,n.coverageIgnoreSourcemaps);u&&r.push(u);let d=tm(`timeout`,n.timeout);return d&&r.push(d),r.length>0&&t.push(`[test]\n${r.join(`
215
215
  `)}`),`# @lzi-bun 自动生成,请勿编辑\n${t.join(`
216
216
 
217
- `)}\n`}function nm(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=$p(t.repoInstall,t.installScopesPreset,t.selfScope)}return{content:tm(a),shouldWrite:!0}}const rm=(e,t)=>r(d(t,`src/__tests__/helpers/bootstrap.ts`))?Ff(e):e;function im(e){let t=0,n=0,r=0,i=0;for(let a of e.split(`
218
- `)){let e=a.trimEnd();e.startsWith(`LF:`)?t+=Number.parseInt(e.slice(3),10)||0:e.startsWith(`LH:`)?n+=Number.parseInt(e.slice(3),10)||0:e.startsWith(`FNF:`)?r+=Number.parseInt(e.slice(4),10)||0:e.startsWith(`FNH:`)&&(i+=Number.parseInt(e.slice(4),10)||0)}return{linesFound:t,linesHit:n,functionsFound:r,functionsHit:i}}function am(e){return typeof e==`number`?{lines:e,functions:e,statements:e}:{...e}}function om(e,t){if(!(t<=0))return e/t}function sm(e,t){let n=am(t),r=om(e.linesHit,e.linesFound),i=om(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 cm(e){return`${(e*100).toFixed(2)}%`}function lm(e){return e.results.map(e=>{let t=e.actual===void 0?`无数据`:cm(e.actual),n=e.actual===void 0||e.actual>=e.required?`通过`:`未达标`;return`${e.dimension} 覆盖率 ${t},阈值 ${cm(e.required)},${n}`})}const um={server:`server`,web:`web`,desktop:`desktop`,cli:`cli`,mcp:`mcp`,"desktop-host":`desktop-host`,docs:`docs`,mobile:`mobile`,miniprogram:`miniprogram`},dm=[`contract`,`main`,`implementation`,`infrastructure`,`api`,`ui`];function fm(e){if(e===``)return`root`;let t=e.split(`/`),n=t[0],r=t[1],i=t[2];return n===`domains`?t.length<3||i===void 0?`non-fixed`:dm.find(e=>e===i)??`non-fixed`:n===`apps`?t.length===3&&r===`capabilities`?`capability`:t.length===2&&r!==void 0?um[r]??`non-fixed`:`non-fixed`:n===`packages`&&t.length===2&&r!==void 0?`package`:`non-fixed`}var pm=class extends Error{details;constructor(e,t){let n=t.flatMap(e=>e.details.map(t=>`${mm(e.kind)}:${t}`));super(`${e} 的测试配置违反分层规则:\n${n.map(e=>` - ${e}`).join(`
219
- `)}`),this.name=`TypeOnlyViolationError`,this.details=n}};function mm(e){return e===`exempt-runtime`?`包内代码与声明预设不符`:e===`zero-tests-undeclared`?`包内没有测试,也没有声明允许零测试的预设`:`声明的预设与目录分层不符`}const hm=e=>typeof e==`object`&&!!e&&!Array.isArray(e),gm=e=>Array.isArray(e)||typeof e==`object`&&!!e&&`packages`in e,_m=e=>{let t=d(e,`package.json`);if(!r(t))return`missing-package-json`;let n;try{n=JSON.parse(a(t,`utf8`))}catch{return`not-root`}return hm(n)&&gm(n.workspaces)?`root`:`not-root`},vm=e=>_m(e)===`root`,ym=(e,t)=>{let n=d(e,`package.json`);try{let e=JSON.parse(a(n,`utf8`));if(hm(e)){let t=e.name;if(typeof t==`string`&&t!==``)return t}}catch{}return t},bm=e=>{let t=e.indexOf(`/`);if(!(!e.startsWith(`@`)||t<=1))return e.slice(1,t)},xm=`.lzi/baselines/lzi-bun.typeonly.json`,Sm=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Cm=[`exempt-runtime`,`zero-tests-undeclared`,`preset-layer-mismatch`],wm=e=>typeof e==`string`&&Cm.some(t=>t===e);function Tm(e){return`${e.path}|${e.kind}`}function Em(e){let t=d(e,xm);if(!r(t))return/* @__PURE__ */ new Set;try{let e=JSON.parse(a(t,`utf8`));if(!Sm(e)||!Array.isArray(e.entries))return/* @__PURE__ */ new Set;let n=/* @__PURE__ */ new Set;for(let t of e.entries)Sm(t)&&typeof t.path==`string`&&wm(t.kind)&&n.add(`${t.path}|${t.kind}`);return n}catch{return/* @__PURE__ */ new Set}}function Dm(e,t,n){return e.has(`${t}|${n}`)}function Om(e,t){let n=[...t].sort((e,t)=>Tm(e)<Tm(t)?-1:+(Tm(e)>Tm(t))),r=d(e,xm);i(u(r),{recursive:!0}),c(r,`${JSON.stringify({version:1,entries:n},null,2)}\n`,`utf8`)}function km(e,t){return[...Em(e)].filter(e=>!t.has(e))}function Am(e){let t=e.indexOf(`|`),n=Cm.find(n=>n===e.slice(t+1));return{path:e.slice(0,t),kind:n??`preset-layer-mismatch`}}const jm=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Mm=e=>jm(e)&&typeof e.type==`string`;function Nm(e){return Mm(e)?e:void 0}function Pm(e){if(Array.isArray(e))return e.every(Mm)?e:void 0}function $(e,t){return Nm(e[t])}function Fm(e){if(e!==void 0&&e.type===`Identifier`)return typeof e.name==`string`?e.name:void 0}function Im(e){return e.type.endsWith(`Literal`)?e.type!==`TemplateLiteral`||e.expressions!==void 0&&Pm(e.expressions)?.length===0:!1}function Lm(e){if(Im(e)||Rm(e))return!0;if(e.type===`TSAsExpression`||e.type===`TSSatisfiesExpression`){let t=$(e,`expression`);return t!==void 0&&Lm(t)}if(e.type===`UnaryExpression`){let t=$(e,`argument`);return t!==void 0&&Im(t)}if(e.type===`BinaryExpression`){let t=$(e,`left`),n=$(e,`right`);return t!==void 0&&n!==void 0&&Im(t)&&Im(n)}return!1}function Rm(e){if(e.type===`ObjectExpression`){let t=Pm(e.properties);return t!==void 0&&t.every(e=>{if(e.type===`Property`){if(e.computed===!0)return!1;let t=$(e,`value`);return t!==void 0&&Lm(t)}if(e.type===`SpreadElement`){let t=$(e,`argument`);return t!==void 0&&Rm(t)}return!1})}if(e.type===`ArrayExpression`){let t=e.elements;return Array.isArray(t)?t.every(e=>{if(e==null)return!0;let t=Nm(e);return t!==void 0&&Lm(t)}):!1}return!1}function zm(e){let t=Fm($(e,`superClass`));if(t===void 0||t!==`Error`&&!t.endsWith(`Error`))return!1;let n=$(e,`body`);if(n===void 0)return!1;let r=Pm(n.body);return r!==void 0&&r.every(e=>{if(e.type===`MethodDefinition`)return e.kind===`constructor`;if(e.type===`PropertyDefinition`){let t=$(e,`value`);return t===void 0||Lm(t)}return!1})}function Bm(e){let t=$(e,`body`);if(t===void 0)return!1;if(t.type!==`BlockStatement`)return!0;let n=Pm(t.body);if(n===void 0||n.length!==1)return!1;let r=n[0];return r!==void 0&&r.type===`ReturnStatement`}function Vm(e){return e?`tsx`:`ts`}function Hm(e,t){let n=$(e,`callee`);if(n===void 0)return!1;if(Fm(n)===`Symbol`)return!0;if(n.type===`MemberExpression`){let e=Fm($(n,`object`));return e!==void 0&&t.zodBindings.has(e)}return!1}function Um(e,t){if(e.type===`TSAsExpression`||e.type===`TSSatisfiesExpression`){let n=$(e,`expression`);if(n!==void 0)return Um(n,t)}if(e.type===`TSInstantiationExpression`){let n=$(e,`expression`);if(n!==void 0)return Um(n,t)}return e.type===`CallExpression`?Hm(e,t)?`declarative`:`runtime`:e.type===`ArrowFunctionExpression`?t.isTsx?`runtime`:Bm(e)?`thin`:`runtime`:e.type===`Identifier`||Lm(e)?`declarative`:`runtime`}function Wm(e,t){switch(e.type){case`TSTypeAliasDeclaration`:case`TSInterfaceDeclaration`:case`TSModuleDeclaration`:case`TSDeclareFunction`:return`type`;case`TSEnumDeclaration`:return`declarative`;case`ClassDeclaration`:return zm(e)?`declarative`:`runtime`;case`FunctionDeclaration`:return t.isTsx?`runtime`:Bm(e)?`thin`:`runtime`;case`VariableDeclaration`:{let n=Pm(e.declarations);if(n===void 0)return`runtime`;let r=`type`;for(let e of n){let n=$(e,`init`),i=n===void 0?`declarative`:Um(n,t);if(i===`runtime`)return`runtime`;i!==`type`&&(r=i)}return r}default:return`runtime`}}function Gm(e,t){let n=/* @__PURE__ */ new Set,r=/* @__PURE__ */ new Set,i=/* @__PURE__ */ new Map;for(let t of e){if(t.type===`ImportDeclaration`){Km(t,n,r);continue}let e=$(t,`declaration`);t.type===`ExportNamedDeclaration`&&e!==void 0?qm(i,e):qm(i,t)}return{zodBindings:n,importBindings:r,localDeclarations:i,isTsx:t}}function Km(e,t,n){let r=$(e,`source`),i=r!==void 0&&typeof r.value==`string`?r.value:void 0,a=Pm(e.specifiers);if(a!==void 0)for(let e of a){let r=Fm($(e,`local`));r!==void 0&&(n.add(r),i===`zod`&&(e.type===`ImportNamespaceSpecifier`&&t.add(r),e.type===`ImportSpecifier`&&Fm($(e,`imported`))===`z`&&t.add(r)))}}function qm(e,t){if(t.type===`FunctionDeclaration`||t.type===`ClassDeclaration`){let n=Fm($(t,`id`));n!==void 0&&e.set(n,t)}else if(t.type===`VariableDeclaration`){let n=Pm(t.declarations);if(n===void 0)return;for(let t of n){let n=Fm($(t,`id`));n!==void 0&&e.set(n,t)}}}function Jm(e){if(e.type===`VariableDeclaration`){let t=Pm(e.declarations),n=t===void 0?void 0:t[0];return(n===void 0?void 0:Fm($(n,`id`)))??`anonymous`}return Fm($(e,`id`))??`anonymous`}function Ym(e,t){let n=Fm($(e,`local`));if(n===void 0)return;let r=Fm($(e,`exported`))??n,i=t.localDeclarations.get(n);if(i!==void 0){let e=$(i,`init`);return{name:r,form:e===void 0?Wm(i,t):Um(e,t)}}if(t.importBindings.has(n))return{name:r,form:`reexport`}}function Xm(e,t){return e.type===`FunctionDeclaration`||e.type===`ClassDeclaration`||e.type===`VariableDeclaration`?Wm(e,t):Um(e,t)}const Zm=/* @__PURE__ */ new Set([`__tests__`,`__mocks__`,`__fixtures__`]),Qm=[`.test.`,`.spec.`,`.d.ts`];function $m(e){return Qm.some(t=>e.includes(t))}function eh(e){let t=d(e,`src`);if(!r(t))return[];let n=[],i=(e,t)=>{for(let r of o(e,{withFileTypes:!0})){if(Zm.has(r.name))continue;let a=t===``?r.name:`${t}/${r.name}`;r.isDirectory()?i(d(e,r.name),a):r.isFile()&&(r.name.endsWith(`.ts`)||r.name.endsWith(`.tsx`))&&n.push(`src/${a}`)}};return i(t,``),n}function th(e,t){let n=Pm(D(e,{sourceType:`module`,lang:Vm(t)}).body)??[],r=Gm(n,t),i=/* @__PURE__ */ new Map,a=(e,t)=>{let n=i.get(e);n===void 0?i.set(e,[t]):n.push(t)};for(let e of n)if(e.type===`ExportAllDeclaration`)a(`reexport`,`*`);else if(e.type===`ExportNamedDeclaration`){if($(e,`source`)!==void 0){a(`reexport`,`named-from`);continue}let t=$(e,`declaration`);if(t!==void 0){a(Wm(t,r),Jm(t));continue}let n=Pm(e.specifiers);if(n===void 0)continue;for(let e of n){let t=Ym(e,r);t!==void 0&&a(t.form,t.name)}}else if(e.type===`ExportDefaultDeclaration`){let t=$(e,`declaration`);if(t===void 0){a(`runtime`,`default`);continue}a(Xm(t,r),`default`)}return i}function nh(e){let t=eh(e).filter(e=>!$m(e)),n=[],r=!1,i=!1;for(let o of t){let t;try{t=a(d(e,o),`utf8`)}catch{continue}let s;try{s=th(t,o.endsWith(`.tsx`))}catch{n.push({file:o,name:`parse-error`,reason:`文件解析失败,无法确认内容,按包含运行时逻辑处理`});continue}let c=s.get(`runtime`);if(c!==void 0)for(let e of c)n.push({file:o,name:e,reason:`这个导出包含运行时逻辑`});s.has(`declarative`)&&(r=!0),(s.has(`thin`)||s.has(`reexport`))&&(i=!0)}return n.length>0?{verdict:`runtime`,runtimeExports:n}:r?{verdict:`declarative`,runtimeExports:[]}:i?{verdict:`facade`,runtimeExports:[]}:{verdict:`pure-type`,runtimeExports:[]}}function rh(e){let t=e;for(;;){if(_m(t)===`root`)return t;let n=u(t);if(n===t)return e;t=n}}const ih=/* @__PURE__ */ new Set([`contract`,`main`,`type-only`]),ah=/* @__PURE__ */ new Set([`contract`,`main`,`docs`,`type-only`,`root`]),oh=[`src/**/*.test.ts`,`src/**/*.test.tsx`,`__tests__/**/*.test.ts`],sh=/* @__PURE__ */ new Set([`root`,`contract`,`main`,`docs`,`domain`,`implementation`,`infrastructure`,`api`,`ui`,`capability`,`mcp`,`desktop-host`,`mobile`,`miniprogram`,`package`,`server`,`web`,`desktop`,`cli`]),ch={root:`@longzai-intelligence-bun/presets/root`,contract:`@longzai-intelligence-bun/presets/contract`,main:`@longzai-intelligence-bun/presets/main`,docs:`@longzai-intelligence-bun/presets/docs`,domain:`@longzai-intelligence-bun/presets/domain`,implementation:`@longzai-intelligence-bun/presets/implementation`,infrastructure:`@longzai-intelligence-bun/presets/infrastructure`,api:`@longzai-intelligence-bun/presets/api`,ui:`@longzai-intelligence-bun/presets/ui`,capability:`@longzai-intelligence-bun/presets/capability`,mcp:`@longzai-intelligence-bun/presets/mcp`,"desktop-host":`@longzai-intelligence-bun/presets/desktop-host`,mobile:`@longzai-intelligence-bun/presets/mobile`,miniprogram:`@longzai-intelligence-bun/presets/miniprogram`,package:`@longzai-intelligence-bun/presets/package`,server:`@longzai-intelligence-bun/presets/server`,web:`@longzai-intelligence-bun/presets/web`,desktop:`@longzai-intelligence-bun/presets/desktop`,cli:`@longzai-intelligence-bun/presets/cli`};async function lh(e){let t=e.config?.preset??`custom`,n=e.config?.preset!==void 0,r=fm(f(e.repoRoot,e.packageDir)),i=[];if(sh.has(t)&&t!==r&&i.push({kind:`preset-layer-mismatch`,details:[dh(t,r)]}),ih.has(t)){let n=nh(e.packageDir);n.verdict===`runtime`&&i.push({kind:`exempt-runtime`,details:[`该包声明为 ${t},这个预设只允许纯类型与声明式内容,但扫描发现 ${n.runtimeExports.length} 处包含运行时逻辑的导出`,...n.runtimeExports.slice(0,5).map(e=>`${e.file} 的 ${e.name},${e.reason}`)]})}return await ph(e.config,e.packageDir)===0&&!ah.has(t)&&i.push({kind:`zero-tests-undeclared`,details:[uh(t,n,r)]}),i}function uh(e,t,n){return t?e===`custom`?`该包的 lzi-bun.config.ts 未走预设子路径,包内没有任何测试文件。custom 不在允许零测试的预设之列,允许零测试的预设为 contract、main、docs、type-only 与 root。请补充测试,或改用上述预设子路径之一,改用后命令会扫描包内容,确认内容符合该预设的要求`:`该包声明为 ${e},包内没有任何测试文件。${e} 预设要求包内必须有测试,允许零测试的预设为 contract、main、docs、type-only 与 root。请补充测试`:n===`non-fixed`?`lzi-bun.config.ts 已加载,但结果里没有预设标记。常见原因是配置仍用旧具名工厂,或依赖停留在旧版本。本包目录没有固定分层,请改用 @longzai-intelligence-bun/presets/type-only 子路径的 defineConfig 声明,并保证包内只有类型与声明式内容`:`lzi-bun.config.ts 已加载,但结果里没有预设标记。常见原因是配置仍用旧具名工厂,或依赖停留在旧版本。本包的目录分层是 ${n},请改用 ${ch[n]} 子路径的 defineConfig 声明配置`}function dh(e,t){return t===`non-fixed`?`本包目录没有固定分层,声明的预设是 ${e}。固定分层预设只能用于对应的目录分层,custom 与 type-only 不受目录分层约束。请改用 @longzai-intelligence-bun/presets/type-only 子路径的 defineConfig 声明,并保证包内只有类型与声明式内容`:`本包的目录分层是 ${t},声明的预设却是 ${e}。固定分层预设必须与目录分层一致,custom 与 type-only 不受目录分层约束。请改用 ${ch[t]} 子路径的 defineConfig 声明配置`}async function fh(e){let t=await lh(e);if(t.length===0)return;let n=f(e.repoRoot,e.packageDir),r=Em(e.repoRoot),i=t.filter(e=>!Dm(r,n,e.kind));if(i.length!==0){if(e.strict)throw new pm(e.subject,i);for(let t of i)for(let n of t.details)Z(`警告: ${e.subject} ${n}`)}}async function ph(e,t){let n=e?.test?.include??oh;if(n.length===oh.length&&n.every((e,t)=>e===oh[t]))return mh(t);let r=/* @__PURE__ */ new Set;for(let e of n){let n=new Bun.Glob(e);for await(let e of n.scan({cwd:t,onlyFiles:!0}))r.add(e)}return r.size}function mh(e){let t=d(e,`src`);if(!r(t))return 0;let n=0,i=e=>{for(let t of o(e,{withFileTypes:!0}))t.isDirectory()?i(d(e,t.name)):(t.isFile()&&t.name.endsWith(`.test.ts`)||t.isFile()&&t.name.endsWith(`.test.tsx`))&&(n+=1)};return i(t),n}const hh=async(e=process.cwd())=>{let t=await Hp({cwd:e,standaloneFile:`lzi-bun.config.ts`,unifiedField:`bun`});return t.success?t.config:(X(`提示: 未找到配置文件 lzi-bun.config.ts,使用默认配置`),{})};var gh=class extends Error{constructor(e){super(e),this.name=`GlobalsUnresolvedError`}};const _h=e=>`已配置的 globals 定位未能命中(longzai-intelligence-globals),已尝试:\n ${e.join(`
220
- `)}\n请修正 ${Bf} / --globals 的路径,或移除该配置以回落包内预设(LZI_SCOPES)`,vh=e=>{try{return s(e).isDirectory()}catch{return!1}},yh=(e={})=>{let t=process.env[Bf],n=[...t!==void 0&&t!==``?[{source:`env`,path:p(t)}]:[],...e.explicitPath===void 0?[]:[{source:`explicit`,path:p(e.explicitPath)}]],r=[];for(let e of n)if(r.push(`${e.source}: ${e.path}`),vh(e.path))return{ok:!0,resolution:{globalsRoot:e.path,source:e.source}};return{ok:!1,failure:{attempted:r}}},bh=RegExp(`^${Bf}=.*$`,`m`),xh=`${Bf}=/absolute/path/to/longzai-intelligence-globals`,Sh=(e,t)=>{let n=d(e,`.env`),i=`${Bf}=${t}`;if(r(n)){let e=a(n,`utf8`);if(bh.test(e)){let t=e.replace(bh,i);t!==e&&c(n,t,`utf8`)}else{let t=e.endsWith(`
217
+ `)}\n`}function rm(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=em(t.repoInstall,t.installScopesPreset,t.selfScope,process.env.LZI_NPM_REGISTRY_URL)}return{content:nm(a),shouldWrite:!0}}const im=(e,t)=>r(d(t,`src/__tests__/helpers/bootstrap.ts`))?Ff(e):e;function am(e){let t=0,n=0,r=0,i=0;for(let a of e.split(`
218
+ `)){let e=a.trimEnd();e.startsWith(`LF:`)?t+=Number.parseInt(e.slice(3),10)||0:e.startsWith(`LH:`)?n+=Number.parseInt(e.slice(3),10)||0:e.startsWith(`FNF:`)?r+=Number.parseInt(e.slice(4),10)||0:e.startsWith(`FNH:`)&&(i+=Number.parseInt(e.slice(4),10)||0)}return{linesFound:t,linesHit:n,functionsFound:r,functionsHit:i}}function om(e){return typeof e==`number`?{lines:e,functions:e,statements:e}:{...e}}function sm(e,t){if(!(t<=0))return e/t}function cm(e,t){let n=om(t),r=sm(e.linesHit,e.linesFound),i=sm(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 lm(e){return`${(e*100).toFixed(2)}%`}function um(e){return e.results.map(e=>{let t=e.actual===void 0?`无数据`:lm(e.actual),n=e.actual===void 0||e.actual>=e.required?`通过`:`未达标`;return`${e.dimension} 覆盖率 ${t},阈值 ${lm(e.required)},${n}`})}const dm={server:`server`,web:`web`,desktop:`desktop`,cli:`cli`,mcp:`mcp`,"desktop-host":`desktop-host`,docs:`docs`,mobile:`mobile`,miniprogram:`miniprogram`},fm=[`contract`,`main`,`implementation`,`infrastructure`,`api`,`ui`];function pm(e){if(e===``)return`root`;let t=e.split(`/`),n=t[0],r=t[1],i=t[2];return n===`domains`?t.length<3||i===void 0?`non-fixed`:fm.find(e=>e===i)??`non-fixed`:n===`apps`?t.length===3&&r===`capabilities`?`capability`:t.length===2&&r!==void 0?dm[r]??`non-fixed`:`non-fixed`:n===`packages`&&t.length===2&&r!==void 0?`package`:`non-fixed`}var mm=class extends Error{details;constructor(e,t){let n=t.flatMap(e=>e.details.map(t=>`${hm(e.kind)}:${t}`));super(`${e} 的测试配置违反分层规则:\n${n.map(e=>` - ${e}`).join(`
219
+ `)}`),this.name=`TypeOnlyViolationError`,this.details=n}};function hm(e){return e===`exempt-runtime`?`包内代码与声明预设不符`:e===`zero-tests-undeclared`?`包内没有测试,也没有声明允许零测试的预设`:`声明的预设与目录分层不符`}const gm=e=>typeof e==`object`&&!!e&&!Array.isArray(e),_m=e=>Array.isArray(e)||typeof e==`object`&&!!e&&`packages`in e,vm=e=>{let t=d(e,`package.json`);if(!r(t))return`missing-package-json`;let n;try{n=JSON.parse(a(t,`utf8`))}catch{return`not-root`}return gm(n)&&_m(n.workspaces)?`root`:`not-root`},ym=e=>vm(e)===`root`,bm=(e,t)=>{let n=d(e,`package.json`);try{let e=JSON.parse(a(n,`utf8`));if(gm(e)){let t=e.name;if(typeof t==`string`&&t!==``)return t}}catch{}return t},xm=e=>{let t=e.indexOf(`/`);if(!(!e.startsWith(`@`)||t<=1))return e.slice(1,t)},Sm=`.lzi/baselines/lzi-bun.typeonly.json`,Cm=e=>typeof e==`object`&&!!e&&!Array.isArray(e),wm=[`exempt-runtime`,`zero-tests-undeclared`,`preset-layer-mismatch`],Tm=e=>typeof e==`string`&&wm.some(t=>t===e);function Em(e){return`${e.path}|${e.kind}`}function Dm(e){let t=d(e,Sm);if(!r(t))return/* @__PURE__ */ new Set;try{let e=JSON.parse(a(t,`utf8`));if(!Cm(e)||!Array.isArray(e.entries))return/* @__PURE__ */ new Set;let n=/* @__PURE__ */ new Set;for(let t of e.entries)Cm(t)&&typeof t.path==`string`&&Tm(t.kind)&&n.add(`${t.path}|${t.kind}`);return n}catch{return/* @__PURE__ */ new Set}}function Om(e,t,n){return e.has(`${t}|${n}`)}function km(e,t){let n=[...t].sort((e,t)=>Em(e)<Em(t)?-1:+(Em(e)>Em(t))),r=d(e,Sm);i(u(r),{recursive:!0}),c(r,`${JSON.stringify({version:1,entries:n},null,2)}\n`,`utf8`)}function Am(e,t){return[...Dm(e)].filter(e=>!t.has(e))}function jm(e){let t=e.indexOf(`|`),n=wm.find(n=>n===e.slice(t+1));return{path:e.slice(0,t),kind:n??`preset-layer-mismatch`}}const Mm=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Nm=e=>Mm(e)&&typeof e.type==`string`;function Pm(e){return Nm(e)?e:void 0}function Fm(e){if(Array.isArray(e))return e.every(Nm)?e:void 0}function $(e,t){return Pm(e[t])}function Im(e){if(e!==void 0&&e.type===`Identifier`)return typeof e.name==`string`?e.name:void 0}function Lm(e){return e.type.endsWith(`Literal`)?e.type!==`TemplateLiteral`||e.expressions!==void 0&&Fm(e.expressions)?.length===0:!1}function Rm(e){if(Lm(e)||zm(e))return!0;if(e.type===`TSAsExpression`||e.type===`TSSatisfiesExpression`){let t=$(e,`expression`);return t!==void 0&&Rm(t)}if(e.type===`UnaryExpression`){let t=$(e,`argument`);return t!==void 0&&Lm(t)}if(e.type===`BinaryExpression`){let t=$(e,`left`),n=$(e,`right`);return t!==void 0&&n!==void 0&&Lm(t)&&Lm(n)}return!1}function zm(e){if(e.type===`ObjectExpression`){let t=Fm(e.properties);return t!==void 0&&t.every(e=>{if(e.type===`Property`){if(e.computed===!0)return!1;let t=$(e,`value`);return t!==void 0&&Rm(t)}if(e.type===`SpreadElement`){let t=$(e,`argument`);return t!==void 0&&zm(t)}return!1})}if(e.type===`ArrayExpression`){let t=e.elements;return Array.isArray(t)?t.every(e=>{if(e==null)return!0;let t=Pm(e);return t!==void 0&&Rm(t)}):!1}return!1}function Bm(e){let t=Im($(e,`superClass`));if(t===void 0||t!==`Error`&&!t.endsWith(`Error`))return!1;let n=$(e,`body`);if(n===void 0)return!1;let r=Fm(n.body);return r!==void 0&&r.every(e=>{if(e.type===`MethodDefinition`)return e.kind===`constructor`;if(e.type===`PropertyDefinition`){let t=$(e,`value`);return t===void 0||Rm(t)}return!1})}function Vm(e){let t=$(e,`body`);if(t===void 0)return!1;if(t.type!==`BlockStatement`)return!0;let n=Fm(t.body);if(n===void 0||n.length!==1)return!1;let r=n[0];return r!==void 0&&r.type===`ReturnStatement`}function Hm(e){return e?`tsx`:`ts`}function Um(e,t){let n=$(e,`callee`);if(n===void 0)return!1;if(Im(n)===`Symbol`)return!0;if(n.type===`MemberExpression`){let e=Im($(n,`object`));return e!==void 0&&t.zodBindings.has(e)}return!1}function Wm(e,t){if(e.type===`TSAsExpression`||e.type===`TSSatisfiesExpression`){let n=$(e,`expression`);if(n!==void 0)return Wm(n,t)}if(e.type===`TSInstantiationExpression`){let n=$(e,`expression`);if(n!==void 0)return Wm(n,t)}return e.type===`CallExpression`?Um(e,t)?`declarative`:`runtime`:e.type===`ArrowFunctionExpression`?t.isTsx?`runtime`:Vm(e)?`thin`:`runtime`:e.type===`Identifier`||Rm(e)?`declarative`:`runtime`}function Gm(e,t){switch(e.type){case`TSTypeAliasDeclaration`:case`TSInterfaceDeclaration`:case`TSModuleDeclaration`:case`TSDeclareFunction`:return`type`;case`TSEnumDeclaration`:return`declarative`;case`ClassDeclaration`:return Bm(e)?`declarative`:`runtime`;case`FunctionDeclaration`:return t.isTsx?`runtime`:Vm(e)?`thin`:`runtime`;case`VariableDeclaration`:{let n=Fm(e.declarations);if(n===void 0)return`runtime`;let r=`type`;for(let e of n){let n=$(e,`init`),i=n===void 0?`declarative`:Wm(n,t);if(i===`runtime`)return`runtime`;i!==`type`&&(r=i)}return r}default:return`runtime`}}function Km(e,t){let n=/* @__PURE__ */ new Set,r=/* @__PURE__ */ new Set,i=/* @__PURE__ */ new Map;for(let t of e){if(t.type===`ImportDeclaration`){qm(t,n,r);continue}let e=$(t,`declaration`);t.type===`ExportNamedDeclaration`&&e!==void 0?Jm(i,e):Jm(i,t)}return{zodBindings:n,importBindings:r,localDeclarations:i,isTsx:t}}function qm(e,t,n){let r=$(e,`source`),i=r!==void 0&&typeof r.value==`string`?r.value:void 0,a=Fm(e.specifiers);if(a!==void 0)for(let e of a){let r=Im($(e,`local`));r!==void 0&&(n.add(r),i===`zod`&&(e.type===`ImportNamespaceSpecifier`&&t.add(r),e.type===`ImportSpecifier`&&Im($(e,`imported`))===`z`&&t.add(r)))}}function Jm(e,t){if(t.type===`FunctionDeclaration`||t.type===`ClassDeclaration`){let n=Im($(t,`id`));n!==void 0&&e.set(n,t)}else if(t.type===`VariableDeclaration`){let n=Fm(t.declarations);if(n===void 0)return;for(let t of n){let n=Im($(t,`id`));n!==void 0&&e.set(n,t)}}}function Ym(e){if(e.type===`VariableDeclaration`){let t=Fm(e.declarations),n=t===void 0?void 0:t[0];return(n===void 0?void 0:Im($(n,`id`)))??`anonymous`}return Im($(e,`id`))??`anonymous`}function Xm(e,t){let n=Im($(e,`local`));if(n===void 0)return;let r=Im($(e,`exported`))??n,i=t.localDeclarations.get(n);if(i!==void 0){let e=$(i,`init`);return{name:r,form:e===void 0?Gm(i,t):Wm(e,t)}}if(t.importBindings.has(n))return{name:r,form:`reexport`}}function Zm(e,t){return e.type===`FunctionDeclaration`||e.type===`ClassDeclaration`||e.type===`VariableDeclaration`?Gm(e,t):Wm(e,t)}const Qm=/* @__PURE__ */ new Set([`__tests__`,`__mocks__`,`__fixtures__`]),$m=[`.test.`,`.spec.`,`.d.ts`];function eh(e){return $m.some(t=>e.includes(t))}function th(e){let t=d(e,`src`);if(!r(t))return[];let n=[],i=(e,t)=>{for(let r of o(e,{withFileTypes:!0})){if(Qm.has(r.name))continue;let a=t===``?r.name:`${t}/${r.name}`;r.isDirectory()?i(d(e,r.name),a):r.isFile()&&(r.name.endsWith(`.ts`)||r.name.endsWith(`.tsx`))&&n.push(`src/${a}`)}};return i(t,``),n}function nh(e,t){let n=Fm(D(e,{sourceType:`module`,lang:Hm(t)}).body)??[],r=Km(n,t),i=/* @__PURE__ */ new Map,a=(e,t)=>{let n=i.get(e);n===void 0?i.set(e,[t]):n.push(t)};for(let e of n)if(e.type===`ExportAllDeclaration`)a(`reexport`,`*`);else if(e.type===`ExportNamedDeclaration`){if($(e,`source`)!==void 0){a(`reexport`,`named-from`);continue}let t=$(e,`declaration`);if(t!==void 0){a(Gm(t,r),Ym(t));continue}let n=Fm(e.specifiers);if(n===void 0)continue;for(let e of n){let t=Xm(e,r);t!==void 0&&a(t.form,t.name)}}else if(e.type===`ExportDefaultDeclaration`){let t=$(e,`declaration`);if(t===void 0){a(`runtime`,`default`);continue}a(Zm(t,r),`default`)}return i}function rh(e){let t=th(e).filter(e=>!eh(e)),n=[],r=!1,i=!1;for(let o of t){let t;try{t=a(d(e,o),`utf8`)}catch{continue}let s;try{s=nh(t,o.endsWith(`.tsx`))}catch{n.push({file:o,name:`parse-error`,reason:`文件解析失败,无法确认内容,按包含运行时逻辑处理`});continue}let c=s.get(`runtime`);if(c!==void 0)for(let e of c)n.push({file:o,name:e,reason:`这个导出包含运行时逻辑`});s.has(`declarative`)&&(r=!0),(s.has(`thin`)||s.has(`reexport`))&&(i=!0)}return n.length>0?{verdict:`runtime`,runtimeExports:n}:r?{verdict:`declarative`,runtimeExports:[]}:i?{verdict:`facade`,runtimeExports:[]}:{verdict:`pure-type`,runtimeExports:[]}}function ih(e){let t=e;for(;;){if(vm(t)===`root`)return t;let n=u(t);if(n===t)return e;t=n}}const ah=/* @__PURE__ */ new Set([`contract`,`main`,`type-only`]),oh=/* @__PURE__ */ new Set([`contract`,`main`,`docs`,`type-only`,`root`]),sh=[`src/**/*.test.ts`,`src/**/*.test.tsx`,`__tests__/**/*.test.ts`],ch=/* @__PURE__ */ new Set([`root`,`contract`,`main`,`docs`,`domain`,`implementation`,`infrastructure`,`api`,`ui`,`capability`,`mcp`,`desktop-host`,`mobile`,`miniprogram`,`package`,`server`,`web`,`desktop`,`cli`]),lh={root:`@longzai-intelligence-bun/presets/root`,contract:`@longzai-intelligence-bun/presets/contract`,main:`@longzai-intelligence-bun/presets/main`,docs:`@longzai-intelligence-bun/presets/docs`,domain:`@longzai-intelligence-bun/presets/domain`,implementation:`@longzai-intelligence-bun/presets/implementation`,infrastructure:`@longzai-intelligence-bun/presets/infrastructure`,api:`@longzai-intelligence-bun/presets/api`,ui:`@longzai-intelligence-bun/presets/ui`,capability:`@longzai-intelligence-bun/presets/capability`,mcp:`@longzai-intelligence-bun/presets/mcp`,"desktop-host":`@longzai-intelligence-bun/presets/desktop-host`,mobile:`@longzai-intelligence-bun/presets/mobile`,miniprogram:`@longzai-intelligence-bun/presets/miniprogram`,package:`@longzai-intelligence-bun/presets/package`,server:`@longzai-intelligence-bun/presets/server`,web:`@longzai-intelligence-bun/presets/web`,desktop:`@longzai-intelligence-bun/presets/desktop`,cli:`@longzai-intelligence-bun/presets/cli`};async function uh(e){let t=e.config?.preset??`custom`,n=e.config?.preset!==void 0,r=pm(f(e.repoRoot,e.packageDir)),i=[];if(ch.has(t)&&t!==r&&i.push({kind:`preset-layer-mismatch`,details:[fh(t,r)]}),ah.has(t)){let n=rh(e.packageDir);n.verdict===`runtime`&&i.push({kind:`exempt-runtime`,details:[`该包声明为 ${t},这个预设只允许纯类型与声明式内容,但扫描发现 ${n.runtimeExports.length} 处包含运行时逻辑的导出`,...n.runtimeExports.slice(0,5).map(e=>`${e.file} 的 ${e.name},${e.reason}`)]})}return await mh(e.config,e.packageDir)===0&&!oh.has(t)&&i.push({kind:`zero-tests-undeclared`,details:[dh(t,n,r)]}),i}function dh(e,t,n){return t?e===`custom`?`该包的 lzi-bun.config.ts 未走预设子路径,包内没有任何测试文件。custom 不在允许零测试的预设之列,允许零测试的预设为 contract、main、docs、type-only 与 root。请补充测试,或改用上述预设子路径之一,改用后命令会扫描包内容,确认内容符合该预设的要求`:`该包声明为 ${e},包内没有任何测试文件。${e} 预设要求包内必须有测试,允许零测试的预设为 contract、main、docs、type-only 与 root。请补充测试`:n===`non-fixed`?`lzi-bun.config.ts 已加载,但结果里没有预设标记。常见原因是配置仍用旧具名工厂,或依赖停留在旧版本。本包目录没有固定分层,请改用 @longzai-intelligence-bun/presets/type-only 子路径的 defineConfig 声明,并保证包内只有类型与声明式内容`:`lzi-bun.config.ts 已加载,但结果里没有预设标记。常见原因是配置仍用旧具名工厂,或依赖停留在旧版本。本包的目录分层是 ${n},请改用 ${lh[n]} 子路径的 defineConfig 声明配置`}function fh(e,t){return t===`non-fixed`?`本包目录没有固定分层,声明的预设是 ${e}。固定分层预设只能用于对应的目录分层,custom 与 type-only 不受目录分层约束。请改用 @longzai-intelligence-bun/presets/type-only 子路径的 defineConfig 声明,并保证包内只有类型与声明式内容`:`本包的目录分层是 ${t},声明的预设却是 ${e}。固定分层预设必须与目录分层一致,custom 与 type-only 不受目录分层约束。请改用 ${lh[t]} 子路径的 defineConfig 声明配置`}async function ph(e){let t=await uh(e);if(t.length===0)return;let n=f(e.repoRoot,e.packageDir),r=Dm(e.repoRoot),i=t.filter(e=>!Om(r,n,e.kind));if(i.length!==0){if(e.strict)throw new mm(e.subject,i);for(let t of i)for(let n of t.details)Z(`警告: ${e.subject} ${n}`)}}async function mh(e,t){let n=e?.test?.include??sh;if(n.length===sh.length&&n.every((e,t)=>e===sh[t]))return hh(t);let r=/* @__PURE__ */ new Set;for(let e of n){let n=new Bun.Glob(e);for await(let e of n.scan({cwd:t,onlyFiles:!0}))r.add(e)}return r.size}function hh(e){let t=d(e,`src`);if(!r(t))return 0;let n=0,i=e=>{for(let t of o(e,{withFileTypes:!0}))t.isDirectory()?i(d(e,t.name)):(t.isFile()&&t.name.endsWith(`.test.ts`)||t.isFile()&&t.name.endsWith(`.test.tsx`))&&(n+=1)};return i(t),n}const gh=async(e=process.cwd())=>{let t=await Up({cwd:e,standaloneFile:`lzi-bun.config.ts`,unifiedField:`bun`});return t.success?t.config:(X(`提示: 未找到配置文件 lzi-bun.config.ts,使用默认配置`),{})};var _h=class extends Error{constructor(e){super(e),this.name=`GlobalsUnresolvedError`}};const vh=e=>`已配置的 globals 定位未能命中(longzai-intelligence-globals),已尝试:\n ${e.join(`
220
+ `)}\n请修正 ${Vf} / --globals 的路径,或移除该配置以回落包内预设(LZI_SCOPES)`,yh=e=>{try{return s(e).isDirectory()}catch{return!1}},bh=(e={})=>{let t=process.env[Vf],n=[...t!==void 0&&t!==``?[{source:`env`,path:p(t)}]:[],...e.explicitPath===void 0?[]:[{source:`explicit`,path:p(e.explicitPath)}]],r=[];for(let e of n)if(r.push(`${e.source}: ${e.path}`),yh(e.path))return{ok:!0,resolution:{globalsRoot:e.path,source:e.source}};return{ok:!1,failure:{attempted:r}}},xh=RegExp(`^${Vf}=.*$`,`m`),Sh=`${Vf}=/absolute/path/to/longzai-intelligence-globals`,Ch=(e,t)=>{let n=d(e,`.env`),i=`${Vf}=${t}`;if(r(n)){let e=a(n,`utf8`);if(xh.test(e)){let t=e.replace(xh,i);t!==e&&c(n,t,`utf8`)}else{let t=e.endsWith(`
221
221
  `)||e.length===0?e:`${e}\n`;c(n,`${t}${i}\n`,`utf8`)}}else c(n,`${i}\n`,`utf8`);let o=d(e,`.env.example`);if(r(o)){let e=a(o,`utf8`);if(!e.includes(`LZI_GLOBALS_ROOT=`)){let t=e.endsWith(`
222
- `)||e.length===0?e:`${e}\n`;c(o,`${t}${xh}\n`,`utf8`)}}else c(o,`${xh}\n`,`utf8`)},Ch=async e=>Kf((await Mp(d(e,`lzi-bun-install.config.ts`))).config),wh=async(e={})=>{let t=yh({explicitPath:e.explicitPath});if(t.ok)return{presetScopes:await Ch(t.resolution.globalsRoot),source:`globals`};if(t.failure.attempted.length===0)return{presetScopes:Object.fromEntries(zf),source:`preset`};throw new gh(_h(t.failure.attempted))},Th=/* @__PURE__ */ new Set([`extraScopes`,`privateScopes`,`linker`,`globalStore`]);function Eh(e){if(typeof e!=`object`||!e||Array.isArray(e))throw Error(`lzi-bun.config.ts 的 install 声明须为对象`);for(let t of Object.keys(e))if(!Th.has(t))throw Error(`lzi-bun.config.ts 的 install 声明含不可声明键 ${t},可声明键为 extraScopes、privateScopes、linker、globalStore`);let t=typeof e==`object`&&e&&`extraScopes`in e?e.extraScopes:void 0,n=typeof e==`object`&&e&&`privateScopes`in e?e.privateScopes:void 0,r=typeof e==`object`&&e&&`linker`in e?e.linker:void 0,i=typeof e==`object`&&e&&`globalStore`in e?e.globalStore:void 0;if(t!==void 0){if(typeof t!=`object`||!t||Array.isArray(t))throw Error(`lzi-bun.config.ts 的 install.extraScopes 须为 scope 到安装源 URL 的对象`);for(let[e,n]of Object.entries(t))if(typeof e!=`string`||typeof n!=`string`)throw Error(`lzi-bun.config.ts 的 install.extraScopes 键值均须为字符串`)}if(n!==void 0&&(!Array.isArray(n)||n.some(e=>typeof e!=`string`)))throw Error(`lzi-bun.config.ts 的 install.privateScopes 须为 scope 字符串数组`);if(r!==void 0&&r!==`isolated`&&r!==`hoisted`)throw Error(`lzi-bun.config.ts 的 install.linker 仅可为 isolated 或 hoisted`);if(i!==void 0&&typeof i!=`boolean`)throw Error(`lzi-bun.config.ts 的 install.globalStore 须为布尔值`);let a={};return t!==void 0&&(a.extraScopes=Object.fromEntries(Object.entries(t).map(([e,t])=>[e,String(t)]))),Array.isArray(n)&&(a.privateScopes=n.map(e=>String(e))),(r===`isolated`||r===`hoisted`)&&(a.linker=r),typeof i==`boolean`&&(a.globalStore=i),a}const Dh=[`src/**/*.test.ts`,`src/**/*.test.tsx`,`__tests__/**/*.test.ts`];function Oh(e){let t=[`bun`,`test`];return e.watch===!0&&t.push(`--watch`),e.coverage===!0&&t.push(`--coverage`),e.extra&&e.extra.length>0&&t.push(...e.extra),t}function kh(e,n=t()){return e?{enabled:!1,reason:`watch 为长驻会话,跳过内存护栏`}:n===`darwin`?{enabled:!0}:{enabled:!1,reason:`非 darwin 平台无 /usr/bin/time -l,跳过内存护栏`}}function Ah(e,t){return t?[`/usr/bin/time`,`-l`,...e]:[...e]}async function jh(e,t=process.cwd()){let n=/* @__PURE__ */ new Set;for(let r of e){let e=new Bun.Glob(r);for await(let r of e.scan({cwd:t,onlyFiles:!0}))n.add(r)}return n.size}const Mh=(e,t,n)=>{let r=e.split(`
222
+ `)||e.length===0?e:`${e}\n`;c(o,`${t}${Sh}\n`,`utf8`)}}else c(o,`${Sh}\n`,`utf8`)},wh=async e=>qf((await Np(d(e,`lzi-bun-install.config.ts`))).config),Th=async(e={})=>{let t=bh({explicitPath:e.explicitPath});if(t.ok)return{presetScopes:await wh(t.resolution.globalsRoot),source:`globals`};if(t.failure.attempted.length===0)return{presetScopes:Object.fromEntries(zf),source:`preset`};throw new _h(vh(t.failure.attempted))},Eh=/* @__PURE__ */ new Set([`extraScopes`,`privateScopes`,`linker`,`globalStore`]);function Dh(e){if(typeof e!=`object`||!e||Array.isArray(e))throw Error(`lzi-bun.config.ts 的 install 声明须为对象`);for(let t of Object.keys(e))if(!Eh.has(t))throw Error(`lzi-bun.config.ts 的 install 声明含不可声明键 ${t},可声明键为 extraScopes、privateScopes、linker、globalStore`);let t=typeof e==`object`&&e&&`extraScopes`in e?e.extraScopes:void 0,n=typeof e==`object`&&e&&`privateScopes`in e?e.privateScopes:void 0,r=typeof e==`object`&&e&&`linker`in e?e.linker:void 0,i=typeof e==`object`&&e&&`globalStore`in e?e.globalStore:void 0;if(t!==void 0){if(typeof t!=`object`||!t||Array.isArray(t))throw Error(`lzi-bun.config.ts 的 install.extraScopes 须为 scope 到安装源 URL 的对象`);for(let[e,n]of Object.entries(t))if(typeof e!=`string`||typeof n!=`string`)throw Error(`lzi-bun.config.ts 的 install.extraScopes 键值均须为字符串`)}if(n!==void 0&&(!Array.isArray(n)||n.some(e=>typeof e!=`string`)))throw Error(`lzi-bun.config.ts 的 install.privateScopes 须为 scope 字符串数组`);if(r!==void 0&&r!==`isolated`&&r!==`hoisted`)throw Error(`lzi-bun.config.ts 的 install.linker 仅可为 isolated 或 hoisted`);if(i!==void 0&&typeof i!=`boolean`)throw Error(`lzi-bun.config.ts 的 install.globalStore 须为布尔值`);let a={};return t!==void 0&&(a.extraScopes=Object.fromEntries(Object.entries(t).map(([e,t])=>[e,String(t)]))),Array.isArray(n)&&(a.privateScopes=n.map(e=>String(e))),(r===`isolated`||r===`hoisted`)&&(a.linker=r),typeof i==`boolean`&&(a.globalStore=i),a}const Oh=[`src/**/*.test.ts`,`src/**/*.test.tsx`,`__tests__/**/*.test.ts`];function kh(e){let t=[`bun`,`test`];return e.watch===!0&&t.push(`--watch`),e.coverage===!0&&t.push(`--coverage`),e.extra&&e.extra.length>0&&t.push(...e.extra),t}function Ah(e,n=t()){return e?{enabled:!1,reason:`watch 为长驻会话,跳过内存护栏`}:n===`darwin`?{enabled:!0}:{enabled:!1,reason:`非 darwin 平台无 /usr/bin/time -l,跳过内存护栏`}}function jh(e,t){return t?[`/usr/bin/time`,`-l`,...e]:[...e]}async function Mh(e,t=process.cwd()){let n=/* @__PURE__ */ new Set;for(let r of e){let e=new Bun.Glob(r);for await(let r of e.scan({cwd:t,onlyFiles:!0}))n.add(r)}return n.size}const Nh=(e,t,n)=>{let r=e.split(`
223
223
  `),i=t.split(`
224
- `),a=0;for(;a<r.length&&a<i.length&&r[a]===i[a];)a++;let o=`第 ${a+1} 行不一致(磁盘 \`${r[a]??`<缺行>`}\` ≠ 预期 \`${i[a]??`<缺行>`}\`)`,s=n===void 0?void 0:`"@${n}" = `;return s!==void 0&&t.includes(s)&&!e.includes(s)?`${o},且本仓 scope @${n} 行在磁盘文件中缺位——bun publish 的 scope 映射优先级会使公网轨发布回退默认镜像源并以 missing authentication 失败(issue 0008)`:o},Nh=async(e,t={})=>{let n=t.dir??process.cwd(),i=d(n,`bunfig.toml`),o=vm(n),s,l;o&&(s=(await wh({explicitPath:t.globalsPath})).presetScopes,l=e?.install===void 0?void 0:Eh(e.install));let u=o?bm(ym(n,``)):void 0,f=nm(rm(e,n),{isRoot:o,installScopesPreset:s,selfScope:u,repoInstall:l});if(!f?.shouldWrite){if(t.dryRun&&X(`(无 coverage 配置,不会生成 bunfig.toml)`),t.check===!0&&r(i))throw new Jp(i,`该包无 coverage 配置,生成器判定不应存在 bunfig.toml(多余文件),请删除该文件`);return{status:`skipped`,bunfigPath:i}}if(t.dryRun)return X(`[dry-run] 将写入 ${i}:`),X(f.content),{status:`generated`,bunfigPath:i};if(t.check===!0){if(!r(i))throw new Jp(i,u===void 0?`bunfig.toml 不存在(生成器预期应存在)`:`bunfig.toml 不存在,本仓 scope @${u} 未注入 [install.scopes]——bun publish 的 scope 映射优先级会使公网轨发布回退默认镜像源并以 missing authentication 失败(issue 0008)`);let e=a(i,`utf8`);if(!e.includes(`@lzi-bun 自动生成,请勿编辑`))throw new Jp(i,`bunfig.toml 为手写文件(无生成标记),不受 lzi-bun 管理;如需接管请确认内容后删除该文件重新生成`);if(e!==f.content)throw new Jp(i,Mh(e,f.content,u));return X(`校验通过 ${i}(与生成器预期一致)`),{status:`checked`,bunfigPath:i}}if(r(i)&&!a(i,`utf8`).includes(`@lzi-bun 自动生成,请勿编辑`))throw new Yp(i);return c(i,f.content,`utf8`),X(`已生成 ${i}(lzi-bun 接管覆盖率配置)`),{status:`generated`,bunfigPath:i}},Ph=e=>{let t=e?.test;if(t===void 0)return;let n=t.coverageThreshold;if(n===void 0)return;let i=d(process.cwd(),t.coverageDir??`coverage`,`lcov.info`);if(!r(i)){X(`未找到覆盖率报告 ${i},跳过全局阈值判定`);return}let o=sm(im(a(i,`utf8`)),n);if(o.passed)for(let e of lm(o))X(e);else{Z(`错误: 覆盖率全局汇总低于阈值`);for(let e of lm(o))Z(e);process.exit(1)}},Fh=(e,t)=>{let n=Jf(t?.preset),r=Lf(e);if(r===void 0&&(Z(`错误: 内存护栏失效——未能从 time 输出解析峰值常驻内存,fail closed 退出`),process.exit(1)),r>n){Z(`错误: 测试内存峰值超预算`);for(let e of Rf(r,n))Z(e);process.exit(1)}X(Rf(r,n)[0]??`内存峰值受控`)},Ih=async e=>{let t=await hh();await fh({config:t,packageDir:process.cwd(),repoRoot:rh(process.cwd()),strict:!1,subject:ym(process.cwd(),process.cwd())});let n=t.test?.passWithNoTests??!0;await jh(t.test?.include??Dh)===0&&(n&&(X(`无测试文件,跳过(type-only / facade 包,passWithNoTests)`),process.exit(0)),Z(`错误: 未找到测试文件,且 test.passWithNoTests 为 false`),Z(`(如该包确为 type-only / facade 包,请在 lzi-dev.config.ts 设置 test.passWithNoTests: true)`),process.exit(1));try{await Nh(t)}catch(e){throw(e instanceof Yp||e instanceof Hf||e instanceof gh)&&(Z(`错误: ${e.message}`),process.exit(1)),e}let r=Oh(e),i=kh(e.watch===!0);!i.enabled&&i.reason!==void 0&&Z(i.reason);let a=Bun.spawn(Ah(r,i.enabled),{cwd:process.cwd(),stdout:`inherit`,stderr:i.enabled?`pipe`:`inherit`}),o=``;if(i.enabled&&a.stderr!==void 0){let e=new TextDecoder;for await(let t of a.stderr){let n=e.decode(t,{stream:!0});process.stderr.write(n),o+=n}}let s=await a.exited;s!==0&&process.exit(s),i.enabled&&Fh(o,t),Ph(t)},Lh=async(e,t,n)=>{let r=await hh();try{await fh({config:r,packageDir:process.cwd(),repoRoot:rh(process.cwd()),strict:!0,subject:ym(process.cwd(),process.cwd())}),await Nh(r,{dryRun:e,globalsPath:t,check:n})}catch(e){throw(e instanceof Yp||e instanceof Jp||e instanceof Hf||e instanceof gh||e instanceof pm)&&(Z(`错误: ${e.message}`),process.exit(1)),e}},Rh=e=>{let t=_m(e);t===`missing-package-json`&&(Z(`错误: 当前目录 ${e} 无 package.json,--recursive 须在 monorepo root 执行`),process.exit(1)),t!==`root`&&(Z(`错误: ${e} 的 package.json 未声明 workspaces 字段,--recursive 须在 monorepo root 执行`),process.exit(1))},zh=async(e,t,n)=>{let r=process.cwd();Rh(r);let i=await qp(r,{configFileName:`lzi-bun.config.ts`}),a=[{name:ym(r,r.split(`/`).pop()??`root`),dir:r}];a.push(...i.map(e=>({name:e.name,dir:e.dir})));let o=n===!0?`校验`:e?`预览`:`生成`;X(`发现 ${a.length} 个目标(root 1 + 子包 ${i.length}),开始${o}...`);let s=[];for(let i of a){X(`▶ ${i.name}`);try{let a=await hh(i.dir);await fh({config:a,packageDir:i.dir,repoRoot:r,strict:!0,subject:i.name});let{status:o}=await Nh(a,{dryRun:e,check:n,dir:i.dir,globalsPath:t});s.push({name:i.name,dir:i.dir,status:o})}catch(e){s.push({name:i.name,dir:i.dir,status:`failed`,reason:e instanceof Error?e.message:String(e)})}}let c=s.filter(e=>e.status===`generated`),l=s.filter(e=>e.status===`checked`),u=s.filter(e=>e.status===`skipped`),d=s.filter(e=>e.status===`failed`);if(X(``),X(`汇总:${c.length} 生成 / ${l.length} 一致 / ${u.length} 跳过 / ${d.length} 失败`),d.length>0){Z(``),Z(`失败子包:`);for(let e of d)Z(` - ${e.name}:${e.reason}`);process.exitCode=1}},Bh=async e=>{let t=e.dryRun===!0,n=e.check===!0;if(t&&n&&(Z(`错误: --dry-run 与 --check 互斥(预览与校验是两种只读形态,请二选一)`),process.exit(1)),e.globalsPath!==void 0){let t=yh({explicitPath:e.globalsPath});t.ok||(Z(`错误: ${_h(t.failure.attempted)}`),process.exit(1));let{globalsRoot:n,source:r}=t.resolution;Sh(process.cwd(),n),X(`已定位 globals 仓(${r})并固化到 .env:${n}`)}e.recursive===!0?await zh(t,e.globalsPath,n):await Lh(t,e.globalsPath,n)},Vh=/* @__PURE__ */ new Set([`contract`,`main`,`type-only`]);async function Hh(e,t){let n=f(t,e),r=ym(e,n||`root`),i=fm(n),a=null,o=`custom`,s;try{a=await hh(e),o=a?.preset??`custom`,s=await lh({config:a,packageDir:e,repoRoot:t,strict:!1,subject:r})}catch{o=`load-error`,s=[{kind:`preset-layer-mismatch`,details:[`lzi-bun.config.ts 加载失败,无法确认声明的预设。请检查文件内的导入与语法,常见原因是配置仍用旧具名工厂,或预设子路径版本尚未发布`]}]}let c=Vh.has(o)?nh(e).verdict:`not-scanned`;return{name:r,path:n,layer:i,preset:o,verdict:c,tests:await ph(a,e),violations:s}}async function Uh(e){let t=process.cwd();e.recursive===!0&&_m(t)!==`root`&&(Z(`错误:--recursive 须在含 workspaces 字段的 workspace 根执行`),process.exit(1));let n=[t];if(e.recursive===!0){let e=await qp(t,{configFileName:`lzi-bun.config.ts`});n.push(...e.map(e=>e.dir))}let r=Em(t),i=[];for(let e of n)i.push(await Hh(e,t));if(e.json===!0)X(JSON.stringify({rows:i},null,2));else{X(`审计 ${i.length} 个目标`);for(let e of i){let t=e.violations.filter(t=>!Dm(r,e.path,t.kind)),n=t.length>0?` 违规 ${t.length} 项`:e.violations.length>0?` 基线内`:` 合规`;X(` ${e.path||`根目录`} 分层 ${e.layer} 预设 ${e.preset} 判定 ${e.verdict} 测试 ${e.tests}${n}`);for(let e of t)for(let t of e.details.slice(0,3))Z(` - ${t}`)}}if(e.initBaseline===!0){let e=/* @__PURE__ */ new Set;for(let t of i)for(let n of t.violations)e.add(`${t.path}|${n.kind}`);Om(t,[...e].map(Am)),X(`已落盘基线 ${e.size} 条至 .lzi/baselines/lzi-bun.typeonly.json`)}else if(e.pruneBaseline===!0){let e=/* @__PURE__ */ new Set;for(let t of i)for(let n of t.violations)e.add(`${t.path}|${n.kind}`);let n=km(t,e);n.length>0?(Om(t,[...r].filter(e=>!n.includes(e)).map(Am)),X(`已从基线移除 ${n.length} 条已修复条目`)):X(`基线无已修复条目可移除`)}else if(e.check===!0){let e=i.reduce((e,t)=>e+t.violations.filter(e=>!Dm(r,t.path,e.kind)).length,0);e>0&&(Z(`错误:${e} 项违规不在基线内,基线只减不增,请先治理违规再重试`),process.exitCode=1)}}function Wh(e){Gh(e),Yh(e),Jh(e),Kh(e),qh(e),Xh(e)}function Gh(e){fd(e,{name:`test`,description:`运行 bun 测试(替代三件套,零测试包默认放行)`,options:[{flags:`--watch`,description:`监听模式(对应 test:watch)`},{flags:`--coverage`,description:`覆盖率(对应 test:coverage)`}],schema:Hs({watch:Ns().optional(),coverage:Ns().optional()}),action:async(e,t)=>{await Ih({watch:e.watch===!0,coverage:e.coverage===!0,extra:t})}})}function Kh(e){fd(e,{name:`lockfile check`,description:`校验单一 bun.lock 不变量与 workspaces 覆盖缺口`,schema:Hs({}),action:async()=>{await mp()}})}function qh(e){fd(e,{name:`node-links check`,description:`检测 node_modules 悬挂符号链接,命中即非零退出`,schema:Hs({}),action:async()=>{await Sp()}}),fd(e,{name:`node-links fix`,description:`回收 node_modules 悬挂死链,删除前复验,有效链接零触碰`,schema:Hs({}),action:async()=>{await Cp()}})}function Jh(e){fd(e,{name:`typeonly audit`,description:`检查各包的目录分层、预设声明与包内容是否符合规则,并管理违规基线`,options:[{flags:`-r, --recursive`,description:`递归审计 workspace 内全部含 lzi-bun.config.ts 的包`},{flags:`--check`,description:`校验模式,实际违规须为基线子集,否则非零退出`},{flags:`--json`,description:`以 JSON 形态输出审计行`},{flags:`--init-baseline`,description:`落盘当前全量违规为基线祖父条款`},{flags:`--prune-baseline`,description:`移除基线中已修复的条目,只减不增`}],schema:Hs({recursive:Ns().optional(),check:Ns().optional(),json:Ns().optional(),initBaseline:Ns().optional(),pruneBaseline:Ns().optional()}),action:async e=>{await Uh({recursive:e.recursive===!0,check:e.check===!0,json:e.json===!0,initBaseline:e.initBaseline===!0,pruneBaseline:e.pruneBaseline===!0})}})}function Yh(e){fd(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:Hs({dryRun:Ns().optional(),check:Ns().optional(),recursive:Ns().optional(),globals:cs().optional()}),action:async e=>{await Bh({dryRun:e.dryRun===!0,check:e.check===!0,recursive:e.recursive===!0,globalsPath:e.globals})}})}function Xh(e){fd(e,{name:`check`,description:`检查当前项目 npm scope 是否登记于 bun 侧安装源注册表`,options:[{flags:`--scope <name>`,description:`显式指定项目名,缺省自 git 仓根目录名推导`}],schema:Hs({scope:cs().optional()}),action:async e=>{await Qf({scopeName:e.scope})}})}const Zh=cd({name:`lzi-bun`,description:`Longzai Intelligence bun 工具集`,interaction:Nf,color:Mf});Wh(Zh);async function Qh(){await Zh.parseAsync(process.argv)}Qh().catch(e=>{process.stderr.write(`错误: ${e instanceof Error?e.message:String(e)}\n`),process.exit(1)});export{};
224
+ `),a=0;for(;a<r.length&&a<i.length&&r[a]===i[a];)a++;let o=`第 ${a+1} 行不一致(磁盘 \`${r[a]??`<缺行>`}\` ≠ 预期 \`${i[a]??`<缺行>`}\`)`,s=n===void 0?void 0:`"@${n}" = `;return s!==void 0&&t.includes(s)&&!e.includes(s)?`${o},且本仓 scope @${n} 行在磁盘文件中缺位——bun publish 的 scope 映射优先级会使公网轨发布回退默认镜像源并以 missing authentication 失败(issue 0008)`:o},Ph=async(e,t={})=>{let n=t.dir??process.cwd(),i=d(n,`bunfig.toml`),o=ym(n),s,l;o&&(s=(await Th({explicitPath:t.globalsPath})).presetScopes,l=e?.install===void 0?void 0:Dh(e.install));let u=o?xm(bm(n,``)):void 0,f=rm(im(e,n),{isRoot:o,installScopesPreset:s,selfScope:u,repoInstall:l});if(!f?.shouldWrite){if(t.dryRun&&X(`(无 coverage 配置,不会生成 bunfig.toml)`),t.check===!0&&r(i))throw new Yp(i,`该包无 coverage 配置,生成器判定不应存在 bunfig.toml(多余文件),请删除该文件`);return{status:`skipped`,bunfigPath:i}}if(t.dryRun)return X(`[dry-run] 将写入 ${i}:`),X(f.content),{status:`generated`,bunfigPath:i};if(t.check===!0){if(!r(i))throw new Yp(i,u===void 0?`bunfig.toml 不存在(生成器预期应存在)`:`bunfig.toml 不存在,本仓 scope @${u} 未注入 [install.scopes]——bun publish 的 scope 映射优先级会使公网轨发布回退默认镜像源并以 missing authentication 失败(issue 0008)`);let e=a(i,`utf8`);if(!e.includes(`@lzi-bun 自动生成,请勿编辑`))throw new Yp(i,`bunfig.toml 为手写文件(无生成标记),不受 lzi-bun 管理;如需接管请确认内容后删除该文件重新生成`);if(e!==f.content)throw new Yp(i,Nh(e,f.content,u));return X(`校验通过 ${i}(与生成器预期一致)`),{status:`checked`,bunfigPath:i}}if(r(i)&&!a(i,`utf8`).includes(`@lzi-bun 自动生成,请勿编辑`))throw new Xp(i);return c(i,f.content,`utf8`),X(`已生成 ${i}(lzi-bun 接管覆盖率配置)`),{status:`generated`,bunfigPath:i}},Fh=e=>{let t=e?.test;if(t===void 0)return;let n=t.coverageThreshold;if(n===void 0)return;let i=d(process.cwd(),t.coverageDir??`coverage`,`lcov.info`);if(!r(i)){X(`未找到覆盖率报告 ${i},跳过全局阈值判定`);return}let o=cm(am(a(i,`utf8`)),n);if(o.passed)for(let e of um(o))X(e);else{Z(`错误: 覆盖率全局汇总低于阈值`);for(let e of um(o))Z(e);process.exit(1)}},Ih=(e,t)=>{let n=Yf(t?.preset),r=Lf(e);if(r===void 0&&(Z(`错误: 内存护栏失效——未能从 time 输出解析峰值常驻内存,fail closed 退出`),process.exit(1)),r>n){Z(`错误: 测试内存峰值超预算`);for(let e of Rf(r,n))Z(e);process.exit(1)}X(Rf(r,n)[0]??`内存峰值受控`)},Lh=async e=>{let t=await gh();await ph({config:t,packageDir:process.cwd(),repoRoot:ih(process.cwd()),strict:!1,subject:bm(process.cwd(),process.cwd())});let n=t.test?.passWithNoTests??!0;await Mh(t.test?.include??Oh)===0&&(n&&(X(`无测试文件,跳过(type-only / facade 包,passWithNoTests)`),process.exit(0)),Z(`错误: 未找到测试文件,且 test.passWithNoTests 为 false`),Z(`(如该包确为 type-only / facade 包,请在 lzi-dev.config.ts 设置 test.passWithNoTests: true)`),process.exit(1));try{await Ph(t)}catch(e){throw(e instanceof Xp||e instanceof Uf||e instanceof _h)&&(Z(`错误: ${e.message}`),process.exit(1)),e}let r=kh(e),i=Ah(e.watch===!0);!i.enabled&&i.reason!==void 0&&Z(i.reason);let a=Bun.spawn(jh(r,i.enabled),{cwd:process.cwd(),stdout:`inherit`,stderr:i.enabled?`pipe`:`inherit`}),o=``;if(i.enabled&&a.stderr!==void 0){let e=new TextDecoder;for await(let t of a.stderr){let n=e.decode(t,{stream:!0});process.stderr.write(n),o+=n}}let s=await a.exited;s!==0&&process.exit(s),i.enabled&&Ih(o,t),Fh(t)},Rh=async(e,t,n)=>{let r=await gh();try{await ph({config:r,packageDir:process.cwd(),repoRoot:ih(process.cwd()),strict:!0,subject:bm(process.cwd(),process.cwd())}),await Ph(r,{dryRun:e,globalsPath:t,check:n})}catch(e){throw(e instanceof Xp||e instanceof Yp||e instanceof Uf||e instanceof _h||e instanceof mm)&&(Z(`错误: ${e.message}`),process.exit(1)),e}},zh=e=>{let t=vm(e);t===`missing-package-json`&&(Z(`错误: 当前目录 ${e} 无 package.json,--recursive 须在 monorepo root 执行`),process.exit(1)),t!==`root`&&(Z(`错误: ${e} 的 package.json 未声明 workspaces 字段,--recursive 须在 monorepo root 执行`),process.exit(1))},Bh=async(e,t,n)=>{let r=process.cwd();zh(r);let i=await Jp(r,{configFileName:`lzi-bun.config.ts`}),a=[{name:bm(r,r.split(`/`).pop()??`root`),dir:r}];a.push(...i.map(e=>({name:e.name,dir:e.dir})));let o=n===!0?`校验`:e?`预览`:`生成`;X(`发现 ${a.length} 个目标(root 1 + 子包 ${i.length}),开始${o}...`);let s=[];for(let i of a){X(`▶ ${i.name}`);try{let a=await gh(i.dir);await ph({config:a,packageDir:i.dir,repoRoot:r,strict:!0,subject:i.name});let{status:o}=await Ph(a,{dryRun:e,check:n,dir:i.dir,globalsPath:t});s.push({name:i.name,dir:i.dir,status:o})}catch(e){s.push({name:i.name,dir:i.dir,status:`failed`,reason:e instanceof Error?e.message:String(e)})}}let c=s.filter(e=>e.status===`generated`),l=s.filter(e=>e.status===`checked`),u=s.filter(e=>e.status===`skipped`),d=s.filter(e=>e.status===`failed`);if(X(``),X(`汇总:${c.length} 生成 / ${l.length} 一致 / ${u.length} 跳过 / ${d.length} 失败`),d.length>0){Z(``),Z(`失败子包:`);for(let e of d)Z(` - ${e.name}:${e.reason}`);process.exitCode=1}},Vh=async e=>{let t=e.dryRun===!0,n=e.check===!0;if(t&&n&&(Z(`错误: --dry-run 与 --check 互斥(预览与校验是两种只读形态,请二选一)`),process.exit(1)),e.globalsPath!==void 0){let t=bh({explicitPath:e.globalsPath});t.ok||(Z(`错误: ${vh(t.failure.attempted)}`),process.exit(1));let{globalsRoot:n,source:r}=t.resolution;Ch(process.cwd(),n),X(`已定位 globals 仓(${r})并固化到 .env:${n}`)}e.recursive===!0?await Bh(t,e.globalsPath,n):await Rh(t,e.globalsPath,n)},Hh=/* @__PURE__ */ new Set([`contract`,`main`,`type-only`]);async function Uh(e,t){let n=f(t,e),r=bm(e,n||`root`),i=pm(n),a=null,o=`custom`,s;try{a=await gh(e),o=a?.preset??`custom`,s=await uh({config:a,packageDir:e,repoRoot:t,strict:!1,subject:r})}catch{o=`load-error`,s=[{kind:`preset-layer-mismatch`,details:[`lzi-bun.config.ts 加载失败,无法确认声明的预设。请检查文件内的导入与语法,常见原因是配置仍用旧具名工厂,或预设子路径版本尚未发布`]}]}let c=Hh.has(o)?rh(e).verdict:`not-scanned`;return{name:r,path:n,layer:i,preset:o,verdict:c,tests:await mh(a,e),violations:s}}async function Wh(e){let t=process.cwd();e.recursive===!0&&vm(t)!==`root`&&(Z(`错误:--recursive 须在含 workspaces 字段的 workspace 根执行`),process.exit(1));let n=[t];if(e.recursive===!0){let e=await Jp(t,{configFileName:`lzi-bun.config.ts`});n.push(...e.map(e=>e.dir))}let r=Dm(t),i=[];for(let e of n)i.push(await Uh(e,t));if(e.json===!0)X(JSON.stringify({rows:i},null,2));else{X(`审计 ${i.length} 个目标`);for(let e of i){let t=e.violations.filter(t=>!Om(r,e.path,t.kind)),n=t.length>0?` 违规 ${t.length} 项`:e.violations.length>0?` 基线内`:` 合规`;X(` ${e.path||`根目录`} 分层 ${e.layer} 预设 ${e.preset} 判定 ${e.verdict} 测试 ${e.tests}${n}`);for(let e of t)for(let t of e.details.slice(0,3))Z(` - ${t}`)}}if(e.initBaseline===!0){let e=/* @__PURE__ */ new Set;for(let t of i)for(let n of t.violations)e.add(`${t.path}|${n.kind}`);km(t,[...e].map(jm)),X(`已落盘基线 ${e.size} 条至 .lzi/baselines/lzi-bun.typeonly.json`)}else if(e.pruneBaseline===!0){let e=/* @__PURE__ */ new Set;for(let t of i)for(let n of t.violations)e.add(`${t.path}|${n.kind}`);let n=Am(t,e);n.length>0?(km(t,[...r].filter(e=>!n.includes(e)).map(jm)),X(`已从基线移除 ${n.length} 条已修复条目`)):X(`基线无已修复条目可移除`)}else if(e.check===!0){let e=i.reduce((e,t)=>e+t.violations.filter(e=>!Om(r,t.path,e.kind)).length,0);e>0&&(Z(`错误:${e} 项违规不在基线内,基线只减不增,请先治理违规再重试`),process.exitCode=1)}}function Gh(e){Kh(e),Xh(e),Yh(e),qh(e),Jh(e),Zh(e)}function Kh(e){fd(e,{name:`test`,description:`运行 bun 测试(替代三件套,零测试包默认放行)`,options:[{flags:`--watch`,description:`监听模式(对应 test:watch)`},{flags:`--coverage`,description:`覆盖率(对应 test:coverage)`}],schema:Hs({watch:Ns().optional(),coverage:Ns().optional()}),action:async(e,t)=>{await Lh({watch:e.watch===!0,coverage:e.coverage===!0,extra:t})}})}function qh(e){fd(e,{name:`lockfile check`,description:`校验单一 bun.lock 不变量与 workspaces 覆盖缺口`,schema:Hs({}),action:async()=>{await hp()}})}function Jh(e){fd(e,{name:`node-links check`,description:`检测 node_modules 悬挂符号链接,命中即非零退出`,schema:Hs({}),action:async()=>{await Cp()}}),fd(e,{name:`node-links fix`,description:`回收 node_modules 悬挂死链,删除前复验,有效链接零触碰`,schema:Hs({}),action:async()=>{await wp()}})}function Yh(e){fd(e,{name:`typeonly audit`,description:`检查各包的目录分层、预设声明与包内容是否符合规则,并管理违规基线`,options:[{flags:`-r, --recursive`,description:`递归审计 workspace 内全部含 lzi-bun.config.ts 的包`},{flags:`--check`,description:`校验模式,实际违规须为基线子集,否则非零退出`},{flags:`--json`,description:`以 JSON 形态输出审计行`},{flags:`--init-baseline`,description:`落盘当前全量违规为基线祖父条款`},{flags:`--prune-baseline`,description:`移除基线中已修复的条目,只减不增`}],schema:Hs({recursive:Ns().optional(),check:Ns().optional(),json:Ns().optional(),initBaseline:Ns().optional(),pruneBaseline:Ns().optional()}),action:async e=>{await Wh({recursive:e.recursive===!0,check:e.check===!0,json:e.json===!0,initBaseline:e.initBaseline===!0,pruneBaseline:e.pruneBaseline===!0})}})}function Xh(e){fd(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:Hs({dryRun:Ns().optional(),check:Ns().optional(),recursive:Ns().optional(),globals:cs().optional()}),action:async e=>{await Vh({dryRun:e.dryRun===!0,check:e.check===!0,recursive:e.recursive===!0,globalsPath:e.globals})}})}function Zh(e){fd(e,{name:`check`,description:`检查当前项目 npm scope 是否登记于 bun 侧安装源注册表`,options:[{flags:`--scope <name>`,description:`显式指定项目名,缺省自 git 仓根目录名推导`}],schema:Hs({scope:cs().optional()}),action:async e=>{await $f({scopeName:e.scope})}})}const Qh=cd({name:`lzi-bun`,description:`Longzai Intelligence bun 工具集`,interaction:Nf,color:Mf});Gh(Qh);async function $h(){await Qh.parseAsync(process.argv)}$h().catch(e=>{process.stderr.write(`错误: ${e instanceof Error?e.message:String(e)}\n`),process.exit(1)});export{};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longzai-intelligence-bun/cli",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "Longzai Intelligence Bun 工具集 CLI",
5
5
  "keywords": [
6
6
  "bun",
@@ -40,8 +40,8 @@
40
40
  "test:coverage": "lzi-bun test --coverage"
41
41
  },
42
42
  "dependencies": {
43
- "@longzai-intelligence-bun/config": "0.1.8",
44
- "@longzai-intelligence-bun/presets": "0.1.8",
43
+ "@longzai-intelligence-bun/config": "0.1.9",
44
+ "@longzai-intelligence-bun/presets": "0.1.9",
45
45
  "@longzai-intelligence-cli/core": "^0.0.10",
46
46
  "@longzai-intelligence-cli/standard": "^0.0.10",
47
47
  "@longzai-intelligence-logger/node": "^0.1.8",