@longzai-intelligence-bun/cli 0.1.2 → 0.1.3

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 +5 -5
  2. package/package.json +3 -2
package/dist/index.js CHANGED
@@ -215,10 +215,10 @@ ${K.default.gray(Td+Cd.repeat(a+2)+Ed)}
215
215
  `)}`),`# @lzi-bun-cli 自动生成,请勿编辑\n${t.join(`
216
216
 
217
217
  `)}\n`}function np(e,t={}){let n=t.isRoot===!0,r=e?.test,i=r?r.coverage!==void 0||r.coverageThreshold!==void 0||r.coveragePathIgnorePatterns!==void 0||r.coverageReporter!==void 0||r.coverageSkipTestFiles!==void 0||r.coverageDir!==void 0||r.preload!==void 0||r.timeout!==void 0:!1;if(!n&&!i)return null;let a={test:r??{}};if(n){if(t.installScopesPreset===void 0)throw Error(`root bunfig 生成需要 globals 仓 install scopes 预设(LZI_GLOBALS_ROOT 定位 longzai-intelligence-globals → lzi-bun-install.config.ts),调用方应先解析并加载`);a.install=$f(t.repoInstall,t.installScopesPreset,t.selfScope)}return{content:tp(a),shouldWrite:!0}}const rp=(e,t)=>n(l(t,`src/__tests__/helpers/bootstrap.ts`))?hf(e):e;function ip(e){let t=0,n=0,r=0,i=0;for(let a of e.split(`
218
- `)){let e=a.trimEnd();e.startsWith(`LF:`)?t+=Number.parseInt(e.slice(3),10)||0:e.startsWith(`LH:`)?n+=Number.parseInt(e.slice(3),10)||0:e.startsWith(`FNF:`)?r+=Number.parseInt(e.slice(4),10)||0:e.startsWith(`FNH:`)&&(i+=Number.parseInt(e.slice(4),10)||0)}return{linesFound:t,linesHit:n,functionsFound:r,functionsHit:i}}function ap(e){return typeof e==`number`?{lines:e,functions:e,statements:e}:{...e}}function op(e,t){if(!(t<=0))return e/t}function sp(e,t){let n=ap(t),r=op(e.linesHit,e.linesFound),i=op(e.functionsHit,e.functionsFound),a=[];return n.lines!==void 0&&a.push({dimension:`lines`,actual:r,required:n.lines}),n.functions!==void 0&&a.push({dimension:`functions`,actual:i,required:n.functions}),n.statements!==void 0&&a.push({dimension:`statements`,actual:r,required:n.statements}),{passed:a.every(e=>e.actual===void 0||e.actual>=e.required),results:a}}function cp(e){return`${(e*100).toFixed(2)}%`}function lp(e){return e.results.map(e=>{let t=e.actual===void 0?`无数据`:cp(e.actual),n=e.actual===void 0||e.actual>=e.required?`通过`:`未达标`;return`${e.dimension} 覆盖率 ${t},阈值 ${cp(e.required)},${n}`})}var up=class extends Error{details;constructor(e,t){let n=t.flatMap(e=>e.details.map(t=>`${dp(e.kind)}:${t}`));super(`${e} 的测试配置违反分层规则:\n${n.map(e=>` - ${e}`).join(`
219
- `)}`),this.name=`TypeOnlyViolationError`,this.details=n}};function dp(e){return e===`exempt-runtime`?`包内代码与声明预设不符`:e===`zero-tests-undeclared`?`包内没有测试,也没有声明允许零测试的预设`:`声明的预设与目录分层不符`}const fp=e=>typeof e==`object`&&!!e&&!Array.isArray(e),pp=e=>Array.isArray(e)||typeof e==`object`&&!!e&&`packages`in e,mp=e=>{let t=l(e,`package.json`);if(!n(t))return`missing-package-json`;let r;try{r=JSON.parse(i(t,`utf8`))}catch{return`not-root`}return fp(r)&&pp(r.workspaces)?`root`:`not-root`},hp=e=>mp(e)===`root`,gp=(e,t)=>{let n=l(e,`package.json`);try{let e=JSON.parse(i(n,`utf8`));if(fp(e)){let t=e.name;if(typeof t==`string`&&t!==``)return t}}catch{}return t},_p=e=>{let t=e.indexOf(`/`);if(!(!e.startsWith(`@`)||t<=1))return e.slice(1,t)},vp={server:`server`,web:`web`,desktop:`desktop`,cli:`cli`,mcp:`mcp`,"desktop-host":`desktop-host`,docs:`docs`,mobile:`mobile`,miniprogram:`miniprogram`},yp={core:`package`,shared:`package`,sdk:`package`},bp=[`contract`,`main`,`implementation`,`infrastructure`,`api`,`ui`];function xp(e){if(e===``)return`root`;let t=e.split(`/`),n=t[0],r=t[1],i=t[2];return n===`domains`?t.length<3||i===void 0?`non-fixed`:bp.find(e=>e===i)??`non-fixed`:n===`apps`?t.length===3&&r===`capabilities`?`capability`:t.length===2&&r!==void 0?vp[r]??`non-fixed`:`non-fixed`:n===`packages`&&t.length===2&&r!==void 0?yp[r]??`non-fixed`:`non-fixed`}const Sp=`.lzi/baselines/lzi-bun.typeonly.json`,Cp=e=>typeof e==`object`&&!!e&&!Array.isArray(e),wp=[`exempt-runtime`,`zero-tests-undeclared`,`preset-layer-mismatch`],Tp=e=>typeof e==`string`&&wp.some(t=>t===e);function Ep(e){return`${e.path}|${e.kind}`}function Dp(e){let t=l(e,Sp);if(!n(t))return/* @__PURE__ */ new Set;try{let e=JSON.parse(i(t,`utf8`));if(!Cp(e)||!Array.isArray(e.entries))return/* @__PURE__ */ new Set;let n=/* @__PURE__ */ new Set;for(let t of e.entries)Cp(t)&&typeof t.path==`string`&&Tp(t.kind)&&n.add(`${t.path}|${t.kind}`);return n}catch{return/* @__PURE__ */ new Set}}function Op(e,t,n){return e.has(`${t}|${n}`)}function kp(e,t){let n=[...t].sort((e,t)=>Ep(e)<Ep(t)?-1:+(Ep(e)>Ep(t))),i=l(e,Sp);r(c(i),{recursive:!0}),s(i,`${JSON.stringify({version:1,entries:n},null,2)}\n`,`utf8`)}function Ap(e,t){return[...Dp(e)].filter(e=>!t.has(e))}function jp(e){let t=e.indexOf(`|`),n=wp.find(n=>n===e.slice(t+1));return{path:e.slice(0,t),kind:n??`preset-layer-mismatch`}}const Mp=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Np=e=>Mp(e)&&typeof e.type==`string`;function Pp(e){return Np(e)?e:void 0}function Fp(e){if(Array.isArray(e))return e.every(Np)?e:void 0}function $(e,t){return Pp(e[t])}function Ip(e){if(e!==void 0&&e.type===`Identifier`)return typeof e.name==`string`?e.name:void 0}function Lp(e){return e.type.endsWith(`Literal`)?e.type!==`TemplateLiteral`||e.expressions!==void 0&&Fp(e.expressions)?.length===0:!1}function Rp(e){if(Lp(e)||zp(e))return!0;if(e.type===`TSAsExpression`||e.type===`TSSatisfiesExpression`){let t=$(e,`expression`);return t!==void 0&&Rp(t)}if(e.type===`UnaryExpression`){let t=$(e,`argument`);return t!==void 0&&Lp(t)}if(e.type===`BinaryExpression`){let t=$(e,`left`),n=$(e,`right`);return t!==void 0&&n!==void 0&&Lp(t)&&Lp(n)}return!1}function zp(e){if(e.type===`ObjectExpression`){let t=Fp(e.properties);return t!==void 0&&t.every(e=>{if(e.type===`Property`){if(e.computed===!0)return!1;let t=$(e,`value`);return t!==void 0&&Rp(t)}if(e.type===`SpreadElement`){let t=$(e,`argument`);return t!==void 0&&zp(t)}return!1})}if(e.type===`ArrayExpression`){let t=e.elements;return Array.isArray(t)?t.every(e=>{if(e==null)return!0;let t=Pp(e);return t!==void 0&&Rp(t)}):!1}return!1}function Bp(e){let t=Ip($(e,`superClass`));if(t===void 0||t!==`Error`&&!t.endsWith(`Error`))return!1;let n=$(e,`body`);if(n===void 0)return!1;let r=Fp(n.body);return r!==void 0&&r.every(e=>{if(e.type===`MethodDefinition`)return e.kind===`constructor`;if(e.type===`PropertyDefinition`){let t=$(e,`value`);return t===void 0||Rp(t)}return!1})}function Vp(e){let t=$(e,`body`);if(t===void 0)return!1;if(t.type!==`BlockStatement`)return!0;let n=Fp(t.body);if(n===void 0||n.length!==1)return!1;let r=n[0];return r!==void 0&&r.type===`ReturnStatement`}function Hp(e){return e?`tsx`:`ts`}function Up(e,t){let n=$(e,`callee`);if(n===void 0)return!1;if(Ip(n)===`Symbol`)return!0;if(n.type===`MemberExpression`){let e=Ip($(n,`object`));return e!==void 0&&t.zodBindings.has(e)}return!1}function Wp(e,t){if(e.type===`TSAsExpression`||e.type===`TSSatisfiesExpression`){let n=$(e,`expression`);if(n!==void 0)return Wp(n,t)}if(e.type===`TSInstantiationExpression`){let n=$(e,`expression`);if(n!==void 0)return Wp(n,t)}return e.type===`CallExpression`?Up(e,t)?`declarative`:`runtime`:e.type===`ArrowFunctionExpression`?t.isTsx?`runtime`:Vp(e)?`thin`:`runtime`:e.type===`Identifier`||Rp(e)?`declarative`:`runtime`}function Gp(e,t){switch(e.type){case`TSTypeAliasDeclaration`:case`TSInterfaceDeclaration`:case`TSModuleDeclaration`:case`TSDeclareFunction`:return`type`;case`TSEnumDeclaration`:return`declarative`;case`ClassDeclaration`:return Bp(e)?`declarative`:`runtime`;case`FunctionDeclaration`:return t.isTsx?`runtime`:Vp(e)?`thin`:`runtime`;case`VariableDeclaration`:{let n=Fp(e.declarations);if(n===void 0)return`runtime`;let r=`type`;for(let e of n){let n=$(e,`init`),i=n===void 0?`declarative`:Wp(n,t);if(i===`runtime`)return`runtime`;i!==`type`&&(r=i)}return r}default:return`runtime`}}function Kp(e,t){let n=/* @__PURE__ */ new Set,r=/* @__PURE__ */ new Set,i=/* @__PURE__ */ new Map;for(let t of e){if(t.type===`ImportDeclaration`){qp(t,n,r);continue}let e=$(t,`declaration`);t.type===`ExportNamedDeclaration`&&e!==void 0?Jp(i,e):Jp(i,t)}return{zodBindings:n,importBindings:r,localDeclarations:i,isTsx:t}}function qp(e,t,n){let r=$(e,`source`),i=r!==void 0&&typeof r.value==`string`?r.value:void 0,a=Fp(e.specifiers);if(a!==void 0)for(let e of a){let r=Ip($(e,`local`));r!==void 0&&(n.add(r),i===`zod`&&(e.type===`ImportNamespaceSpecifier`&&t.add(r),e.type===`ImportSpecifier`&&Ip($(e,`imported`))===`z`&&t.add(r)))}}function Jp(e,t){if(t.type===`FunctionDeclaration`||t.type===`ClassDeclaration`){let n=Ip($(t,`id`));n!==void 0&&e.set(n,t)}else if(t.type===`VariableDeclaration`){let n=Fp(t.declarations);if(n===void 0)return;for(let t of n){let n=Ip($(t,`id`));n!==void 0&&e.set(n,t)}}}function Yp(e){if(e.type===`VariableDeclaration`){let t=Fp(e.declarations),n=t===void 0?void 0:t[0];return(n===void 0?void 0:Ip($(n,`id`)))??`anonymous`}return Ip($(e,`id`))??`anonymous`}function Xp(e,t){let n=Ip($(e,`local`));if(n===void 0)return;let r=Ip($(e,`exported`))??n,i=t.localDeclarations.get(n);if(i!==void 0){let e=$(i,`init`);return{name:r,form:e===void 0?Gp(i,t):Wp(e,t)}}if(t.importBindings.has(n))return{name:r,form:`reexport`}}function Zp(e,t){return e.type===`FunctionDeclaration`||e.type===`ClassDeclaration`||e.type===`VariableDeclaration`?Gp(e,t):Wp(e,t)}const Qp=/* @__PURE__ */ new Set([`__tests__`,`__mocks__`,`__fixtures__`]),$p=[`.test.`,`.spec.`,`.d.ts`];function em(e){return $p.some(t=>e.includes(t))}function tm(e){let t=l(e,`src`);if(!n(t))return[];let r=[],i=(e,t)=>{for(let n of a(e,{withFileTypes:!0})){if(Qp.has(n.name))continue;let a=t===``?n.name:`${t}/${n.name}`;n.isDirectory()?i(l(e,n.name),a):n.isFile()&&(n.name.endsWith(`.ts`)||n.name.endsWith(`.tsx`))&&r.push(`src/${a}`)}};return i(t,``),r}function nm(e,t){let n=Fp(T(e,{sourceType:`module`,lang:Hp(t)}).body)??[],r=Kp(n,t),i=/* @__PURE__ */ new Map,a=(e,t)=>{let n=i.get(e);n===void 0?i.set(e,[t]):n.push(t)};for(let e of n)if(e.type===`ExportAllDeclaration`)a(`reexport`,`*`);else if(e.type===`ExportNamedDeclaration`){if($(e,`source`)!==void 0){a(`reexport`,`named-from`);continue}let t=$(e,`declaration`);if(t!==void 0){a(Gp(t,r),Yp(t));continue}let n=Fp(e.specifiers);if(n===void 0)continue;for(let e of n){let t=Xp(e,r);t!==void 0&&a(t.form,t.name)}}else if(e.type===`ExportDefaultDeclaration`){let t=$(e,`declaration`);if(t===void 0){a(`runtime`,`default`);continue}a(Zp(t,r),`default`)}return i}function rm(e){let t=tm(e).filter(e=>!em(e)),n=[],r=!1,a=!1;for(let o of t){let t;try{t=i(l(e,o),`utf8`)}catch{continue}let s;try{s=nm(t,o.endsWith(`.tsx`))}catch{n.push({file:o,name:`parse-error`,reason:`文件解析失败,无法确认内容,按包含运行时逻辑处理`});continue}let c=s.get(`runtime`);if(c!==void 0)for(let e of c)n.push({file:o,name:e,reason:`这个导出包含运行时逻辑`});s.has(`declarative`)&&(r=!0),(s.has(`thin`)||s.has(`reexport`))&&(a=!0)}return n.length>0?{verdict:`runtime`,runtimeExports:n}:r?{verdict:`declarative`,runtimeExports:[]}:a?{verdict:`facade`,runtimeExports:[]}:{verdict:`pure-type`,runtimeExports:[]}}function im(e){let t=e;for(;;){if(mp(t)===`root`)return t;let n=c(t);if(n===t)return e;t=n}}const am=/* @__PURE__ */ new Set([`contract`,`main`,`type-only`]),om=/* @__PURE__ */ new Set([`contract`,`main`,`docs`,`type-only`,`root`]),sm=[`src/**/*.test.ts`,`src/**/*.test.tsx`,`__tests__/**/*.test.ts`],cm=/* @__PURE__ */ new Set([`root`,`contract`,`main`,`docs`,`domain`,`implementation`,`infrastructure`,`api`,`ui`,`capability`,`mcp`,`desktop-host`,`mobile`,`miniprogram`,`package`,`server`,`web`,`desktop`,`cli`]),lm={root:`@longzai-intelligence-bun/presets/root`,contract:`@longzai-intelligence-bun/presets/contract`,main:`@longzai-intelligence-bun/presets/main`,docs:`@longzai-intelligence-bun/presets/docs`,domain:`@longzai-intelligence-bun/presets/domain`,implementation:`@longzai-intelligence-bun/presets/implementation`,infrastructure:`@longzai-intelligence-bun/presets/infrastructure`,api:`@longzai-intelligence-bun/presets/api`,ui:`@longzai-intelligence-bun/presets/ui`,capability:`@longzai-intelligence-bun/presets/capability`,mcp:`@longzai-intelligence-bun/presets/mcp`,"desktop-host":`@longzai-intelligence-bun/presets/desktop-host`,mobile:`@longzai-intelligence-bun/presets/mobile`,miniprogram:`@longzai-intelligence-bun/presets/miniprogram`,package:`@longzai-intelligence-bun/presets/package`,server:`@longzai-intelligence-bun/presets/server`,web:`@longzai-intelligence-bun/presets/web`,desktop:`@longzai-intelligence-bun/presets/desktop`,cli:`@longzai-intelligence-bun/presets/cli`};async function um(e){let t=e.config?.preset??`custom`,n=e.config?.preset!==void 0,r=xp(u(e.repoRoot,e.packageDir)),i=[];if(cm.has(t)&&t!==r&&i.push({kind:`preset-layer-mismatch`,details:[fm(t,r)]}),am.has(t)){let n=rm(e.packageDir);n.verdict===`runtime`&&i.push({kind:`exempt-runtime`,details:[`该包声明为 ${t},这个预设只允许纯类型与声明式内容,但扫描发现 ${n.runtimeExports.length} 处包含运行时逻辑的导出`,...n.runtimeExports.slice(0,5).map(e=>`${e.file} 的 ${e.name},${e.reason}`)]})}return await mm(e.config,e.packageDir)===0&&!om.has(t)&&i.push({kind:`zero-tests-undeclared`,details:[dm(t,n,r)]}),i}function dm(e,t,n){return t?e===`custom`?`该包的 lzi-bun.config.ts 未走预设子路径,包内没有任何测试文件。custom 不在允许零测试的预设之列,允许零测试的预设为 contract、main、docs、type-only 与 root。请补充测试,或改用上述预设子路径之一,改用后命令会扫描包内容,确认内容符合该预设的要求`:`该包声明为 ${e},包内没有任何测试文件。${e} 预设要求包内必须有测试,允许零测试的预设为 contract、main、docs、type-only 与 root。请补充测试`:n===`non-fixed`?`lzi-bun.config.ts 已加载,但结果里没有预设标记。常见原因是配置仍用旧具名工厂,或依赖停留在旧版本。本包目录没有固定分层,请改用 @longzai-intelligence-bun/presets/type-only 子路径的 defineConfig 声明,并保证包内只有类型与声明式内容`:`lzi-bun.config.ts 已加载,但结果里没有预设标记。常见原因是配置仍用旧具名工厂,或依赖停留在旧版本。本包的目录分层是 ${n},请改用 ${lm[n]} 子路径的 defineConfig 声明配置`}function fm(e,t){return t===`non-fixed`?`本包目录没有固定分层,声明的预设是 ${e}。固定分层预设只能用于对应的目录分层,custom 与 type-only 不受目录分层约束。请改用 @longzai-intelligence-bun/presets/type-only 子路径的 defineConfig 声明,并保证包内只有类型与声明式内容`:`本包的目录分层是 ${t},声明的预设却是 ${e}。固定分层预设必须与目录分层一致,custom 与 type-only 不受目录分层约束。请改用 ${lm[t]} 子路径的 defineConfig 声明配置`}async function pm(e){let t=await um(e);if(t.length===0)return;let n=u(e.repoRoot,e.packageDir),r=Dp(e.repoRoot),i=t.filter(e=>!Op(r,n,e.kind));if(i.length!==0){if(e.strict)throw new up(e.subject,i);for(let t of i)for(let n of t.details)Z(`警告: ${e.subject} ${n}`)}}async function mm(e,t){let n=e?.test?.include??sm;if(n.length===sm.length&&n.every((e,t)=>e===sm[t]))return hm(t);let r=/* @__PURE__ */ new Set;for(let e of n){let n=new Bun.Glob(e);for await(let e of n.scan({cwd:t,onlyFiles:!0}))r.add(e)}return r.size}function hm(e){let t=l(e,`src`);if(!n(t))return 0;let r=0,i=e=>{for(let t of a(e,{withFileTypes:!0}))t.isDirectory()?i(l(e,t.name)):(t.isFile()&&t.name.endsWith(`.test.ts`)||t.isFile()&&t.name.endsWith(`.test.tsx`))&&(r+=1)};return i(t),r}const gm=async(e=process.cwd())=>{let t=await Hf({cwd:e,standaloneFile:`lzi-bun.config.ts`,unifiedField:`bun`});return t.success?t.config:(X(`提示: 未找到配置文件 lzi-bun.config.ts,使用默认配置`),{})};var _m=class extends Error{constructor(e){super(e),this.name=`GlobalsUnresolvedError`}};const vm=e=>`已配置的 globals 定位未能命中(longzai-intelligence-globals),已尝试:\n ${e.join(`
220
- `)}\n请修正 ${_f} / --globals 的路径,或移除该配置以回落包内预设(LZI_SCOPES)`,ym=e=>{try{return o(e).isDirectory()}catch{return!1}},bm=(e={})=>{let t=process.env[_f],n=[...t!==void 0&&t!==``?[{source:`env`,path:d(t)}]:[],...e.explicitPath===void 0?[]:[{source:`explicit`,path:d(e.explicitPath)}]],r=[];for(let e of n)if(r.push(`${e.source}: ${e.path}`),ym(e.path))return{ok:!0,resolution:{globalsRoot:e.path,source:e.source}};return{ok:!1,failure:{attempted:r}}},xm=RegExp(`^${_f}=.*$`,`m`),Sm=`${_f}=/absolute/path/to/longzai-intelligence-globals`,Cm=(e,t)=>{let r=l(e,`.env`),a=`${_f}=${t}`;if(n(r)){let e=i(r,`utf8`);if(xm.test(e)){let t=e.replace(xm,a);t!==e&&s(r,t,`utf8`)}else{let t=e.endsWith(`
218
+ `)){let e=a.trimEnd();e.startsWith(`LF:`)?t+=Number.parseInt(e.slice(3),10)||0:e.startsWith(`LH:`)?n+=Number.parseInt(e.slice(3),10)||0:e.startsWith(`FNF:`)?r+=Number.parseInt(e.slice(4),10)||0:e.startsWith(`FNH:`)&&(i+=Number.parseInt(e.slice(4),10)||0)}return{linesFound:t,linesHit:n,functionsFound:r,functionsHit:i}}function ap(e){return typeof e==`number`?{lines:e,functions:e,statements:e}:{...e}}function op(e,t){if(!(t<=0))return e/t}function sp(e,t){let n=ap(t),r=op(e.linesHit,e.linesFound),i=op(e.functionsHit,e.functionsFound),a=[];return n.lines!==void 0&&a.push({dimension:`lines`,actual:r,required:n.lines}),n.functions!==void 0&&a.push({dimension:`functions`,actual:i,required:n.functions}),n.statements!==void 0&&a.push({dimension:`statements`,actual:r,required:n.statements}),{passed:a.every(e=>e.actual===void 0||e.actual>=e.required),results:a}}function cp(e){return`${(e*100).toFixed(2)}%`}function lp(e){return e.results.map(e=>{let t=e.actual===void 0?`无数据`:cp(e.actual),n=e.actual===void 0||e.actual>=e.required?`通过`:`未达标`;return`${e.dimension} 覆盖率 ${t},阈值 ${cp(e.required)},${n}`})}const up={server:`server`,web:`web`,desktop:`desktop`,cli:`cli`,mcp:`mcp`,"desktop-host":`desktop-host`,docs:`docs`,mobile:`mobile`,miniprogram:`miniprogram`},dp=[`contract`,`main`,`implementation`,`infrastructure`,`api`,`ui`];function fp(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`:dp.find(e=>e===i)??`non-fixed`:n===`apps`?t.length===3&&r===`capabilities`?`capability`:t.length===2&&r!==void 0?up[r]??`non-fixed`:`non-fixed`:n===`packages`&&t.length===2&&r!==void 0?`package`:`non-fixed`}var pp=class extends Error{details;constructor(e,t){let n=t.flatMap(e=>e.details.map(t=>`${mp(e.kind)}:${t}`));super(`${e} 的测试配置违反分层规则:\n${n.map(e=>` - ${e}`).join(`
219
+ `)}`),this.name=`TypeOnlyViolationError`,this.details=n}};function mp(e){return e===`exempt-runtime`?`包内代码与声明预设不符`:e===`zero-tests-undeclared`?`包内没有测试,也没有声明允许零测试的预设`:`声明的预设与目录分层不符`}const hp=e=>typeof e==`object`&&!!e&&!Array.isArray(e),gp=e=>Array.isArray(e)||typeof e==`object`&&!!e&&`packages`in e,_p=e=>{let t=l(e,`package.json`);if(!n(t))return`missing-package-json`;let r;try{r=JSON.parse(i(t,`utf8`))}catch{return`not-root`}return hp(r)&&gp(r.workspaces)?`root`:`not-root`},vp=e=>_p(e)===`root`,yp=(e,t)=>{let n=l(e,`package.json`);try{let e=JSON.parse(i(n,`utf8`));if(hp(e)){let t=e.name;if(typeof t==`string`&&t!==``)return t}}catch{}return t},bp=e=>{let t=e.indexOf(`/`);if(!(!e.startsWith(`@`)||t<=1))return e.slice(1,t)},xp=`.lzi/baselines/lzi-bun.typeonly.json`,Sp=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Cp=[`exempt-runtime`,`zero-tests-undeclared`,`preset-layer-mismatch`],wp=e=>typeof e==`string`&&Cp.some(t=>t===e);function Tp(e){return`${e.path}|${e.kind}`}function Ep(e){let t=l(e,xp);if(!n(t))return/* @__PURE__ */ new Set;try{let e=JSON.parse(i(t,`utf8`));if(!Sp(e)||!Array.isArray(e.entries))return/* @__PURE__ */ new Set;let n=/* @__PURE__ */ new Set;for(let t of e.entries)Sp(t)&&typeof t.path==`string`&&wp(t.kind)&&n.add(`${t.path}|${t.kind}`);return n}catch{return/* @__PURE__ */ new Set}}function Dp(e,t,n){return e.has(`${t}|${n}`)}function Op(e,t){let n=[...t].sort((e,t)=>Tp(e)<Tp(t)?-1:+(Tp(e)>Tp(t))),i=l(e,xp);r(c(i),{recursive:!0}),s(i,`${JSON.stringify({version:1,entries:n},null,2)}\n`,`utf8`)}function kp(e,t){return[...Ep(e)].filter(e=>!t.has(e))}function Ap(e){let t=e.indexOf(`|`),n=Cp.find(n=>n===e.slice(t+1));return{path:e.slice(0,t),kind:n??`preset-layer-mismatch`}}const jp=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Mp=e=>jp(e)&&typeof e.type==`string`;function Np(e){return Mp(e)?e:void 0}function Pp(e){if(Array.isArray(e))return e.every(Mp)?e:void 0}function $(e,t){return Np(e[t])}function Fp(e){if(e!==void 0&&e.type===`Identifier`)return typeof e.name==`string`?e.name:void 0}function Ip(e){return e.type.endsWith(`Literal`)?e.type!==`TemplateLiteral`||e.expressions!==void 0&&Pp(e.expressions)?.length===0:!1}function Lp(e){if(Ip(e)||Rp(e))return!0;if(e.type===`TSAsExpression`||e.type===`TSSatisfiesExpression`){let t=$(e,`expression`);return t!==void 0&&Lp(t)}if(e.type===`UnaryExpression`){let t=$(e,`argument`);return t!==void 0&&Ip(t)}if(e.type===`BinaryExpression`){let t=$(e,`left`),n=$(e,`right`);return t!==void 0&&n!==void 0&&Ip(t)&&Ip(n)}return!1}function Rp(e){if(e.type===`ObjectExpression`){let t=Pp(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&&Lp(t)}if(e.type===`SpreadElement`){let t=$(e,`argument`);return t!==void 0&&Rp(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=Np(e);return t!==void 0&&Lp(t)}):!1}return!1}function zp(e){let t=Fp($(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=Pp(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||Lp(t)}return!1})}function Bp(e){let t=$(e,`body`);if(t===void 0)return!1;if(t.type!==`BlockStatement`)return!0;let n=Pp(t.body);if(n===void 0||n.length!==1)return!1;let r=n[0];return r!==void 0&&r.type===`ReturnStatement`}function Vp(e){return e?`tsx`:`ts`}function Hp(e,t){let n=$(e,`callee`);if(n===void 0)return!1;if(Fp(n)===`Symbol`)return!0;if(n.type===`MemberExpression`){let e=Fp($(n,`object`));return e!==void 0&&t.zodBindings.has(e)}return!1}function Up(e,t){if(e.type===`TSAsExpression`||e.type===`TSSatisfiesExpression`){let n=$(e,`expression`);if(n!==void 0)return Up(n,t)}if(e.type===`TSInstantiationExpression`){let n=$(e,`expression`);if(n!==void 0)return Up(n,t)}return e.type===`CallExpression`?Hp(e,t)?`declarative`:`runtime`:e.type===`ArrowFunctionExpression`?t.isTsx?`runtime`:Bp(e)?`thin`:`runtime`:e.type===`Identifier`||Lp(e)?`declarative`:`runtime`}function Wp(e,t){switch(e.type){case`TSTypeAliasDeclaration`:case`TSInterfaceDeclaration`:case`TSModuleDeclaration`:case`TSDeclareFunction`:return`type`;case`TSEnumDeclaration`:return`declarative`;case`ClassDeclaration`:return zp(e)?`declarative`:`runtime`;case`FunctionDeclaration`:return t.isTsx?`runtime`:Bp(e)?`thin`:`runtime`;case`VariableDeclaration`:{let n=Pp(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`:Up(n,t);if(i===`runtime`)return`runtime`;i!==`type`&&(r=i)}return r}default:return`runtime`}}function Gp(e,t){let n=/* @__PURE__ */ new Set,r=/* @__PURE__ */ new Set,i=/* @__PURE__ */ new Map;for(let t of e){if(t.type===`ImportDeclaration`){Kp(t,n,r);continue}let e=$(t,`declaration`);t.type===`ExportNamedDeclaration`&&e!==void 0?qp(i,e):qp(i,t)}return{zodBindings:n,importBindings:r,localDeclarations:i,isTsx:t}}function Kp(e,t,n){let r=$(e,`source`),i=r!==void 0&&typeof r.value==`string`?r.value:void 0,a=Pp(e.specifiers);if(a!==void 0)for(let e of a){let r=Fp($(e,`local`));r!==void 0&&(n.add(r),i===`zod`&&(e.type===`ImportNamespaceSpecifier`&&t.add(r),e.type===`ImportSpecifier`&&Fp($(e,`imported`))===`z`&&t.add(r)))}}function qp(e,t){if(t.type===`FunctionDeclaration`||t.type===`ClassDeclaration`){let n=Fp($(t,`id`));n!==void 0&&e.set(n,t)}else if(t.type===`VariableDeclaration`){let n=Pp(t.declarations);if(n===void 0)return;for(let t of n){let n=Fp($(t,`id`));n!==void 0&&e.set(n,t)}}}function Jp(e){if(e.type===`VariableDeclaration`){let t=Pp(e.declarations),n=t===void 0?void 0:t[0];return(n===void 0?void 0:Fp($(n,`id`)))??`anonymous`}return Fp($(e,`id`))??`anonymous`}function Yp(e,t){let n=Fp($(e,`local`));if(n===void 0)return;let r=Fp($(e,`exported`))??n,i=t.localDeclarations.get(n);if(i!==void 0){let e=$(i,`init`);return{name:r,form:e===void 0?Wp(i,t):Up(e,t)}}if(t.importBindings.has(n))return{name:r,form:`reexport`}}function Xp(e,t){return e.type===`FunctionDeclaration`||e.type===`ClassDeclaration`||e.type===`VariableDeclaration`?Wp(e,t):Up(e,t)}const Zp=/* @__PURE__ */ new Set([`__tests__`,`__mocks__`,`__fixtures__`]),Qp=[`.test.`,`.spec.`,`.d.ts`];function $p(e){return Qp.some(t=>e.includes(t))}function em(e){let t=l(e,`src`);if(!n(t))return[];let r=[],i=(e,t)=>{for(let n of a(e,{withFileTypes:!0})){if(Zp.has(n.name))continue;let a=t===``?n.name:`${t}/${n.name}`;n.isDirectory()?i(l(e,n.name),a):n.isFile()&&(n.name.endsWith(`.ts`)||n.name.endsWith(`.tsx`))&&r.push(`src/${a}`)}};return i(t,``),r}function tm(e,t){let n=Pp(T(e,{sourceType:`module`,lang:Vp(t)}).body)??[],r=Gp(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(Wp(t,r),Jp(t));continue}let n=Pp(e.specifiers);if(n===void 0)continue;for(let e of n){let t=Yp(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(Xp(t,r),`default`)}return i}function nm(e){let t=em(e).filter(e=>!$p(e)),n=[],r=!1,a=!1;for(let o of t){let t;try{t=i(l(e,o),`utf8`)}catch{continue}let s;try{s=tm(t,o.endsWith(`.tsx`))}catch{n.push({file:o,name:`parse-error`,reason:`文件解析失败,无法确认内容,按包含运行时逻辑处理`});continue}let c=s.get(`runtime`);if(c!==void 0)for(let e of c)n.push({file:o,name:e,reason:`这个导出包含运行时逻辑`});s.has(`declarative`)&&(r=!0),(s.has(`thin`)||s.has(`reexport`))&&(a=!0)}return n.length>0?{verdict:`runtime`,runtimeExports:n}:r?{verdict:`declarative`,runtimeExports:[]}:a?{verdict:`facade`,runtimeExports:[]}:{verdict:`pure-type`,runtimeExports:[]}}function rm(e){let t=e;for(;;){if(_p(t)===`root`)return t;let n=c(t);if(n===t)return e;t=n}}const im=/* @__PURE__ */ new Set([`contract`,`main`,`type-only`]),am=/* @__PURE__ */ new Set([`contract`,`main`,`docs`,`type-only`,`root`]),om=[`src/**/*.test.ts`,`src/**/*.test.tsx`,`__tests__/**/*.test.ts`],sm=/* @__PURE__ */ new Set([`root`,`contract`,`main`,`docs`,`domain`,`implementation`,`infrastructure`,`api`,`ui`,`capability`,`mcp`,`desktop-host`,`mobile`,`miniprogram`,`package`,`server`,`web`,`desktop`,`cli`]),cm={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 lm(e){let t=e.config?.preset??`custom`,n=e.config?.preset!==void 0,r=fp(u(e.repoRoot,e.packageDir)),i=[];if(sm.has(t)&&t!==r&&i.push({kind:`preset-layer-mismatch`,details:[dm(t,r)]}),im.has(t)){let n=nm(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 pm(e.config,e.packageDir)===0&&!am.has(t)&&i.push({kind:`zero-tests-undeclared`,details:[um(t,n,r)]}),i}function um(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},请改用 ${cm[n]} 子路径的 defineConfig 声明配置`}function dm(e,t){return t===`non-fixed`?`本包目录没有固定分层,声明的预设是 ${e}。固定分层预设只能用于对应的目录分层,custom 与 type-only 不受目录分层约束。请改用 @longzai-intelligence-bun/presets/type-only 子路径的 defineConfig 声明,并保证包内只有类型与声明式内容`:`本包的目录分层是 ${t},声明的预设却是 ${e}。固定分层预设必须与目录分层一致,custom 与 type-only 不受目录分层约束。请改用 ${cm[t]} 子路径的 defineConfig 声明配置`}async function fm(e){let t=await lm(e);if(t.length===0)return;let n=u(e.repoRoot,e.packageDir),r=Ep(e.repoRoot),i=t.filter(e=>!Dp(r,n,e.kind));if(i.length!==0){if(e.strict)throw new pp(e.subject,i);for(let t of i)for(let n of t.details)Z(`警告: ${e.subject} ${n}`)}}async function pm(e,t){let n=e?.test?.include??om;if(n.length===om.length&&n.every((e,t)=>e===om[t]))return mm(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 mm(e){let t=l(e,`src`);if(!n(t))return 0;let r=0,i=e=>{for(let t of a(e,{withFileTypes:!0}))t.isDirectory()?i(l(e,t.name)):(t.isFile()&&t.name.endsWith(`.test.ts`)||t.isFile()&&t.name.endsWith(`.test.tsx`))&&(r+=1)};return i(t),r}const hm=async(e=process.cwd())=>{let t=await Hf({cwd:e,standaloneFile:`lzi-bun.config.ts`,unifiedField:`bun`});return t.success?t.config:(X(`提示: 未找到配置文件 lzi-bun.config.ts,使用默认配置`),{})};var gm=class extends Error{constructor(e){super(e),this.name=`GlobalsUnresolvedError`}};const _m=e=>`已配置的 globals 定位未能命中(longzai-intelligence-globals),已尝试:\n ${e.join(`
220
+ `)}\n请修正 ${_f} / --globals 的路径,或移除该配置以回落包内预设(LZI_SCOPES)`,vm=e=>{try{return o(e).isDirectory()}catch{return!1}},ym=(e={})=>{let t=process.env[_f],n=[...t!==void 0&&t!==``?[{source:`env`,path:d(t)}]:[],...e.explicitPath===void 0?[]:[{source:`explicit`,path:d(e.explicitPath)}]],r=[];for(let e of n)if(r.push(`${e.source}: ${e.path}`),vm(e.path))return{ok:!0,resolution:{globalsRoot:e.path,source:e.source}};return{ok:!1,failure:{attempted:r}}},bm=RegExp(`^${_f}=.*$`,`m`),xm=`${_f}=/absolute/path/to/longzai-intelligence-globals`,Sm=(e,t)=>{let r=l(e,`.env`),a=`${_f}=${t}`;if(n(r)){let e=i(r,`utf8`);if(bm.test(e)){let t=e.replace(bm,a);t!==e&&s(r,t,`utf8`)}else{let t=e.endsWith(`
221
221
  `)||e.length===0?e:`${e}\n`;s(r,`${t}${a}\n`,`utf8`)}}else s(r,`${a}\n`,`utf8`);let o=l(e,`.env.example`);if(n(o)){let e=i(o,`utf8`);if(!e.includes(`LZI_GLOBALS_ROOT=`)){let t=e.endsWith(`
222
- `)||e.length===0?e:`${e}\n`;s(o,`${t}${Sm}\n`,`utf8`)}}else s(o,`${Sm}\n`,`utf8`)},wm=async e=>Cf((await Mf(l(e,`lzi-bun-install.config.ts`))).config),Tm=async(e={})=>{let t=bm({explicitPath:e.explicitPath});if(t.ok)return{presetScopes:await wm(t.resolution.globalsRoot),source:`globals`};if(t.failure.attempted.length===0)return{presetScopes:Object.fromEntries(gf),source:`preset`};throw new _m(vm(t.failure.attempted))},Em=/* @__PURE__ */ new Set([`extraScopes`,`privateScopes`,`linker`,`globalStore`]);function Dm(e){if(typeof e!=`object`||!e||Array.isArray(e))throw Error(`lzi-bun.config.ts 的 install 声明须为对象`);for(let t of Object.keys(e))if(!Em.has(t))throw Error(`lzi-bun.config.ts 的 install 声明含不可声明键 ${t},可声明键为 extraScopes、privateScopes、linker、globalStore`);let t=typeof e==`object`&&e&&`extraScopes`in e?e.extraScopes:void 0,n=typeof e==`object`&&e&&`privateScopes`in e?e.privateScopes:void 0,r=typeof e==`object`&&e&&`linker`in e?e.linker:void 0,i=typeof e==`object`&&e&&`globalStore`in e?e.globalStore:void 0;if(t!==void 0){if(typeof t!=`object`||!t||Array.isArray(t))throw Error(`lzi-bun.config.ts 的 install.extraScopes 须为 scope 到安装源 URL 的对象`);for(let[e,n]of Object.entries(t))if(typeof e!=`string`||typeof n!=`string`)throw Error(`lzi-bun.config.ts 的 install.extraScopes 键值均须为字符串`)}if(n!==void 0&&(!Array.isArray(n)||n.some(e=>typeof e!=`string`)))throw Error(`lzi-bun.config.ts 的 install.privateScopes 须为 scope 字符串数组`);if(r!==void 0&&r!==`isolated`&&r!==`hoisted`)throw Error(`lzi-bun.config.ts 的 install.linker 仅可为 isolated 或 hoisted`);if(i!==void 0&&typeof i!=`boolean`)throw Error(`lzi-bun.config.ts 的 install.globalStore 须为布尔值`);let a={};return t!==void 0&&(a.extraScopes=Object.fromEntries(Object.entries(t).map(([e,t])=>[e,String(t)]))),Array.isArray(n)&&(a.privateScopes=n.map(e=>String(e))),(r===`isolated`||r===`hoisted`)&&(a.linker=r),typeof i==`boolean`&&(a.globalStore=i),a}const Om=[`src/**/*.test.ts`,`src/**/*.test.tsx`,`__tests__/**/*.test.ts`];function km(e){let t=[`bun`,`test`];return e.watch===!0&&t.push(`--watch`),e.coverage===!0&&t.push(`--coverage`),e.extra&&e.extra.length>0&&t.push(...e.extra),t}async function Am(e,t=process.cwd()){let n=/* @__PURE__ */ new Set;for(let r of e){let e=new Bun.Glob(r);for await(let r of e.scan({cwd:t,onlyFiles:!0}))n.add(r)}return n.size}const jm=(e,t,n)=>{let r=e.split(`
222
+ `)||e.length===0?e:`${e}\n`;s(o,`${t}${xm}\n`,`utf8`)}}else s(o,`${xm}\n`,`utf8`)},Cm=async e=>Cf((await Mf(l(e,`lzi-bun-install.config.ts`))).config),wm=async(e={})=>{let t=ym({explicitPath:e.explicitPath});if(t.ok)return{presetScopes:await Cm(t.resolution.globalsRoot),source:`globals`};if(t.failure.attempted.length===0)return{presetScopes:Object.fromEntries(gf),source:`preset`};throw new gm(_m(t.failure.attempted))},Tm=/* @__PURE__ */ new Set([`extraScopes`,`privateScopes`,`linker`,`globalStore`]);function Em(e){if(typeof e!=`object`||!e||Array.isArray(e))throw Error(`lzi-bun.config.ts 的 install 声明须为对象`);for(let t of Object.keys(e))if(!Tm.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 Dm=[`src/**/*.test.ts`,`src/**/*.test.tsx`,`__tests__/**/*.test.ts`];function Om(e){let t=[`bun`,`test`];return e.watch===!0&&t.push(`--watch`),e.coverage===!0&&t.push(`--coverage`),e.extra&&e.extra.length>0&&t.push(...e.extra),t}async function km(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 Am=(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},Mm=async(e,t={})=>{let r=t.dir??process.cwd(),a=l(r,`bunfig.toml`),o=hp(r),c,u;o&&(c=(await Tm({explicitPath:t.globalsPath})).presetScopes,u=e?.install===void 0?void 0:Dm(e.install));let d=o?_p(gp(r,``)):void 0,f=np(rp(e,r),{isRoot:o,installScopesPreset:c,selfScope:d,repoInstall:u});if(!f?.shouldWrite){if(t.dryRun&&X(`(无 coverage 配置,不会生成 bunfig.toml)`),t.check===!0&&n(a))throw new Jf(a,`该包无 coverage 配置,生成器判定不应存在 bunfig.toml(多余文件),请删除该文件`);return{status:`skipped`,bunfigPath:a}}if(t.dryRun)return X(`[dry-run] 将写入 ${a}:`),X(f.content),{status:`generated`,bunfigPath:a};if(t.check===!0){if(!n(a))throw new Jf(a,d===void 0?`bunfig.toml 不存在(生成器预期应存在)`:`bunfig.toml 不存在,本仓 scope @${d} 未注入 [install.scopes]——bun publish 的 scope 映射优先级会使公网轨发布回退默认镜像源并以 missing authentication 失败(issue 0008)`);let e=i(a,`utf8`);if(!e.includes(`@lzi-bun-cli 自动生成,请勿编辑`))throw new Jf(a,`bunfig.toml 为手写文件(无生成标记),不受 lzi-bun-cli 管理;如需接管请确认内容后删除该文件重新生成`);if(e!==f.content)throw new Jf(a,jm(e,f.content,d));return X(`校验通过 ${a}(与生成器预期一致)`),{status:`checked`,bunfigPath:a}}if(n(a)&&!i(a,`utf8`).includes(`@lzi-bun-cli 自动生成,请勿编辑`))throw new Yf(a);return s(a,f.content,`utf8`),X(`已生成 ${a}(lzi-bun-cli 接管覆盖率配置)`),{status:`generated`,bunfigPath:a}},Nm=e=>{let t=e?.test;if(t===void 0)return;let r=t.coverageThreshold;if(r===void 0)return;let a=l(process.cwd(),t.coverageDir??`coverage`,`lcov.info`);if(!n(a)){X(`未找到覆盖率报告 ${a},跳过全局阈值判定`);return}let o=sp(ip(i(a,`utf8`)),r);if(o.passed)for(let e of lp(o))X(e);else{Z(`错误: 覆盖率全局汇总低于阈值`);for(let e of lp(o))Z(e);process.exit(1)}},Pm=async e=>{let t=await gm();await pm({config:t,packageDir:process.cwd(),repoRoot:im(process.cwd()),strict:!1,subject:gp(process.cwd(),process.cwd())});let n=t.test?.passWithNoTests??!0;await Am(t.test?.include??Om)===0&&(n&&(X(`无测试文件,跳过(type-only / facade 包,passWithNoTests)`),process.exit(0)),Z(`错误: 未找到测试文件,且 test.passWithNoTests 为 false`),Z(`(如该包确为 type-only / facade 包,请在 lzi-dev.config.ts 设置 test.passWithNoTests: true)`),process.exit(1));try{await Mm(t)}catch(e){throw(e instanceof Yf||e instanceof yf||e instanceof _m)&&(Z(`错误: ${e.message}`),process.exit(1)),e}let r=km(e),i=await Bun.spawn(r,{cwd:process.cwd(),stdout:`inherit`,stderr:`inherit`}).exited;i!==0&&process.exit(i),Nm(t)},Fm=async(e,t,n)=>{let r=await gm();try{await pm({config:r,packageDir:process.cwd(),repoRoot:im(process.cwd()),strict:!0,subject:gp(process.cwd(),process.cwd())}),await Mm(r,{dryRun:e,globalsPath:t,check:n})}catch(e){throw(e instanceof Yf||e instanceof Jf||e instanceof yf||e instanceof _m||e instanceof up)&&(Z(`错误: ${e.message}`),process.exit(1)),e}},Im=e=>{let t=mp(e);t===`missing-package-json`&&(Z(`错误: 当前目录 ${e} 无 package.json,--recursive 须在 monorepo root 执行`),process.exit(1)),t!==`root`&&(Z(`错误: ${e} 的 package.json 未声明 workspaces 字段,--recursive 须在 monorepo root 执行`),process.exit(1))},Lm=async(e,t,n)=>{let r=process.cwd();Im(r);let i=await qf(r,{configFileName:`lzi-bun.config.ts`}),a=[{name:gp(r,r.split(`/`).pop()??`root`),dir:r}];a.push(...i.map(e=>({name:e.name,dir:e.dir})));let o=n===!0?`校验`:e?`预览`:`生成`;X(`发现 ${a.length} 个目标(root 1 + 子包 ${i.length}),开始${o}...`);let s=[];for(let i of a){X(`▶ ${i.name}`);try{let a=await gm(i.dir);await pm({config:a,packageDir:i.dir,repoRoot:r,strict:!0,subject:i.name});let{status:o}=await Mm(a,{dryRun:e,check:n,dir:i.dir,globalsPath:t});s.push({name:i.name,dir:i.dir,status:o})}catch(e){s.push({name:i.name,dir:i.dir,status:`failed`,reason:e instanceof Error?e.message:String(e)})}}let c=s.filter(e=>e.status===`generated`),l=s.filter(e=>e.status===`checked`),u=s.filter(e=>e.status===`skipped`),d=s.filter(e=>e.status===`failed`);if(X(``),X(`汇总:${c.length} 生成 / ${l.length} 一致 / ${u.length} 跳过 / ${d.length} 失败`),d.length>0){Z(``),Z(`失败子包:`);for(let e of d)Z(` - ${e.name}:${e.reason}`);process.exitCode=1}},Rm=async e=>{let t=e.dryRun===!0,n=e.check===!0;if(t&&n&&(Z(`错误: --dry-run 与 --check 互斥(预览与校验是两种只读形态,请二选一)`),process.exit(1)),e.globalsPath!==void 0){let t=bm({explicitPath:e.globalsPath});t.ok||(Z(`错误: ${vm(t.failure.attempted)}`),process.exit(1));let{globalsRoot:n,source:r}=t.resolution;Cm(process.cwd(),n),X(`已定位 globals 仓(${r})并固化到 .env:${n}`)}e.recursive===!0?await Lm(t,e.globalsPath,n):await Fm(t,e.globalsPath,n)},zm=/* @__PURE__ */ new Set([`contract`,`main`,`type-only`]);async function Bm(e,t){let n=u(t,e),r=gp(e,n||`root`),i=xp(n),a=null,o=`custom`,s;try{a=await gm(e),o=a?.preset??`custom`,s=await um({config:a,packageDir:e,repoRoot:t,strict:!1,subject:r})}catch{o=`load-error`,s=[{kind:`preset-layer-mismatch`,details:[`lzi-bun.config.ts 加载失败,无法确认声明的预设。请检查文件内的导入与语法,常见原因是配置仍用旧具名工厂,或预设子路径版本尚未发布`]}]}let c=zm.has(o)?rm(e).verdict:`not-scanned`;return{name:r,path:n,layer:i,preset:o,verdict:c,tests:await mm(a,e),violations:s}}async function Vm(e){let t=process.cwd();e.recursive===!0&&mp(t)!==`root`&&(Z(`错误:--recursive 须在含 workspaces 字段的 workspace 根执行`),process.exit(1));let n=[t];if(e.recursive===!0){let e=await qf(t,{configFileName:`lzi-bun.config.ts`});n.push(...e.map(e=>e.dir))}let r=Dp(t),i=[];for(let e of n)i.push(await Bm(e,t));if(e.json===!0)X(JSON.stringify({rows:i},null,2));else{X(`审计 ${i.length} 个目标`);for(let e of i){let t=e.violations.filter(t=>!Op(r,e.path,t.kind)),n=t.length>0?` 违规 ${t.length} 项`:e.violations.length>0?` 基线内`:` 合规`;X(` ${e.path||`根目录`} 分层 ${e.layer} 预设 ${e.preset} 判定 ${e.verdict} 测试 ${e.tests}${n}`);for(let e of t)for(let t of e.details.slice(0,3))Z(` - ${t}`)}}if(e.initBaseline===!0){let e=/* @__PURE__ */ new Set;for(let t of i)for(let n of t.violations)e.add(`${t.path}|${n.kind}`);kp(t,[...e].map(jp)),X(`已落盘基线 ${e.size} 条至 .lzi/baselines/lzi-bun.typeonly.json`)}else if(e.pruneBaseline===!0){let e=/* @__PURE__ */ new Set;for(let t of i)for(let n of t.violations)e.add(`${t.path}|${n.kind}`);let n=Ap(t,e);n.length>0?(kp(t,[...r].filter(e=>!n.includes(e)).map(jp)),X(`已从基线移除 ${n.length} 条已修复条目`)):X(`基线无已修复条目可移除`)}else if(e.check===!0){let e=i.reduce((e,t)=>e+t.violations.filter(e=>!Op(r,t.path,e.kind)).length,0);e>0&&(Z(`错误:${e} 项违规不在基线内,基线只减不增,请先治理违规再重试`),process.exitCode=1)}}function Hm(e){Um(e),qm(e),Km(e),Wm(e),Gm(e)}function Um(e){Su(e,{name:`test`,description:`运行 bun 测试(替代三件套,零测试包默认放行)`,options:[{flags:`--watch`,description:`监听模式(对应 test:watch)`},{flags:`--coverage`,description:`覆盖率(对应 test:coverage)`}],schema:Nl({watch:Tl().optional(),coverage:Tl().optional()}),action:async(e,t)=>{await Pm({watch:e.watch===!0,coverage:e.coverage===!0,extra:t})}})}function Wm(e){Su(e,{name:`lockfile check`,description:`校验单一 bun.lock 不变量与 workspaces 覆盖缺口`,schema:Nl({}),action:async()=>{await af()}})}function Gm(e){Su(e,{name:`node-links check`,description:`检测 node_modules 悬挂符号链接,命中即非零退出`,schema:Nl({}),action:async()=>{await pf()}}),Su(e,{name:`node-links fix`,description:`回收 node_modules 悬挂死链,删除前复验,有效链接零触碰`,schema:Nl({}),action:async()=>{await mf()}})}function Km(e){Su(e,{name:`typeonly audit`,description:`检查各包的目录分层、预设声明与包内容是否符合规则,并管理违规基线`,options:[{flags:`-r, --recursive`,description:`递归审计 workspace 内全部含 lzi-bun.config.ts 的包`},{flags:`--check`,description:`校验模式,实际违规须为基线子集,否则非零退出`},{flags:`--json`,description:`以 JSON 形态输出审计行`},{flags:`--init-baseline`,description:`落盘当前全量违规为基线祖父条款`},{flags:`--prune-baseline`,description:`移除基线中已修复的条目,只减不增`}],schema:Nl({recursive:Tl().optional(),check:Tl().optional(),json:Tl().optional(),initBaseline:Tl().optional(),pruneBaseline:Tl().optional()}),action:async e=>{await Vm({recursive:e.recursive===!0,check:e.check===!0,json:e.json===!0,initBaseline:e.initBaseline===!0,pruneBaseline:e.pruneBaseline===!0})}})}function qm(e){Su(e,{name:`config generate`,description:`生成 bunfig.toml(不执行测试,支持 --dry-run 预览、--check 校验、-r 批量、--globals 定位)`,options:[{flags:`--dry-run`,description:`仅预览将写入的内容,不写盘`},{flags:`--check`,description:`仅校验磁盘 bunfig.toml 与生成器预期是否一致(漂移即报错退出,不写盘)`},{flags:`-r, --recursive`,description:`递归处理 monorepo 下含 lzi-bun.config.ts 的子包`},{flags:`--globals <path>`,description:`一次性 bootstrap 定位 globals 仓(命中后固化 .env,此后零参数)`}],schema:Nl({dryRun:Tl().optional(),check:Tl().optional(),recursive:Tl().optional(),globals:el().optional()}),action:async e=>{await Rm({dryRun:e.dryRun===!0,check:e.check===!0,recursive:e.recursive===!0,globalsPath:e.globals})}})}const Jm=vu({name:`lzi-bun-cli`,description:`Longzai Intelligence bun 工具集`,interaction:Vd,color:Bd});Hm(Jm);async function Ym(){await Jm.parseAsync(process.argv)}Ym().catch(e=>{process.stderr.write(`错误: ${e instanceof Error?e.message:String(e)}\n`),process.exit(1)});export{};
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},jm=async(e,t={})=>{let r=t.dir??process.cwd(),a=l(r,`bunfig.toml`),o=vp(r),c,u;o&&(c=(await wm({explicitPath:t.globalsPath})).presetScopes,u=e?.install===void 0?void 0:Em(e.install));let d=o?bp(yp(r,``)):void 0,f=np(rp(e,r),{isRoot:o,installScopesPreset:c,selfScope:d,repoInstall:u});if(!f?.shouldWrite){if(t.dryRun&&X(`(无 coverage 配置,不会生成 bunfig.toml)`),t.check===!0&&n(a))throw new Jf(a,`该包无 coverage 配置,生成器判定不应存在 bunfig.toml(多余文件),请删除该文件`);return{status:`skipped`,bunfigPath:a}}if(t.dryRun)return X(`[dry-run] 将写入 ${a}:`),X(f.content),{status:`generated`,bunfigPath:a};if(t.check===!0){if(!n(a))throw new Jf(a,d===void 0?`bunfig.toml 不存在(生成器预期应存在)`:`bunfig.toml 不存在,本仓 scope @${d} 未注入 [install.scopes]——bun publish 的 scope 映射优先级会使公网轨发布回退默认镜像源并以 missing authentication 失败(issue 0008)`);let e=i(a,`utf8`);if(!e.includes(`@lzi-bun-cli 自动生成,请勿编辑`))throw new Jf(a,`bunfig.toml 为手写文件(无生成标记),不受 lzi-bun-cli 管理;如需接管请确认内容后删除该文件重新生成`);if(e!==f.content)throw new Jf(a,Am(e,f.content,d));return X(`校验通过 ${a}(与生成器预期一致)`),{status:`checked`,bunfigPath:a}}if(n(a)&&!i(a,`utf8`).includes(`@lzi-bun-cli 自动生成,请勿编辑`))throw new Yf(a);return s(a,f.content,`utf8`),X(`已生成 ${a}(lzi-bun-cli 接管覆盖率配置)`),{status:`generated`,bunfigPath:a}},Mm=e=>{let t=e?.test;if(t===void 0)return;let r=t.coverageThreshold;if(r===void 0)return;let a=l(process.cwd(),t.coverageDir??`coverage`,`lcov.info`);if(!n(a)){X(`未找到覆盖率报告 ${a},跳过全局阈值判定`);return}let o=sp(ip(i(a,`utf8`)),r);if(o.passed)for(let e of lp(o))X(e);else{Z(`错误: 覆盖率全局汇总低于阈值`);for(let e of lp(o))Z(e);process.exit(1)}},Nm=async e=>{let t=await hm();await fm({config:t,packageDir:process.cwd(),repoRoot:rm(process.cwd()),strict:!1,subject:yp(process.cwd(),process.cwd())});let n=t.test?.passWithNoTests??!0;await km(t.test?.include??Dm)===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 jm(t)}catch(e){throw(e instanceof Yf||e instanceof yf||e instanceof gm)&&(Z(`错误: ${e.message}`),process.exit(1)),e}let r=Om(e),i=await Bun.spawn(r,{cwd:process.cwd(),stdout:`inherit`,stderr:`inherit`}).exited;i!==0&&process.exit(i),Mm(t)},Pm=async(e,t,n)=>{let r=await hm();try{await fm({config:r,packageDir:process.cwd(),repoRoot:rm(process.cwd()),strict:!0,subject:yp(process.cwd(),process.cwd())}),await jm(r,{dryRun:e,globalsPath:t,check:n})}catch(e){throw(e instanceof Yf||e instanceof Jf||e instanceof yf||e instanceof gm||e instanceof pp)&&(Z(`错误: ${e.message}`),process.exit(1)),e}},Fm=e=>{let t=_p(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))},Im=async(e,t,n)=>{let r=process.cwd();Fm(r);let i=await qf(r,{configFileName:`lzi-bun.config.ts`}),a=[{name:yp(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 hm(i.dir);await fm({config:a,packageDir:i.dir,repoRoot:r,strict:!0,subject:i.name});let{status:o}=await jm(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}},Lm=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=ym({explicitPath:e.globalsPath});t.ok||(Z(`错误: ${_m(t.failure.attempted)}`),process.exit(1));let{globalsRoot:n,source:r}=t.resolution;Sm(process.cwd(),n),X(`已定位 globals 仓(${r})并固化到 .env:${n}`)}e.recursive===!0?await Im(t,e.globalsPath,n):await Pm(t,e.globalsPath,n)},Rm=/* @__PURE__ */ new Set([`contract`,`main`,`type-only`]);async function zm(e,t){let n=u(t,e),r=yp(e,n||`root`),i=fp(n),a=null,o=`custom`,s;try{a=await hm(e),o=a?.preset??`custom`,s=await lm({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=Rm.has(o)?nm(e).verdict:`not-scanned`;return{name:r,path:n,layer:i,preset:o,verdict:c,tests:await pm(a,e),violations:s}}async function Bm(e){let t=process.cwd();e.recursive===!0&&_p(t)!==`root`&&(Z(`错误:--recursive 须在含 workspaces 字段的 workspace 根执行`),process.exit(1));let n=[t];if(e.recursive===!0){let e=await qf(t,{configFileName:`lzi-bun.config.ts`});n.push(...e.map(e=>e.dir))}let r=Ep(t),i=[];for(let e of n)i.push(await zm(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=>!Dp(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}`);Op(t,[...e].map(Ap)),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=kp(t,e);n.length>0?(Op(t,[...r].filter(e=>!n.includes(e)).map(Ap)),X(`已从基线移除 ${n.length} 条已修复条目`)):X(`基线无已修复条目可移除`)}else if(e.check===!0){let e=i.reduce((e,t)=>e+t.violations.filter(e=>!Dp(r,t.path,e.kind)).length,0);e>0&&(Z(`错误:${e} 项违规不在基线内,基线只减不增,请先治理违规再重试`),process.exitCode=1)}}function Vm(e){Hm(e),Km(e),Gm(e),Um(e),Wm(e)}function Hm(e){Su(e,{name:`test`,description:`运行 bun 测试(替代三件套,零测试包默认放行)`,options:[{flags:`--watch`,description:`监听模式(对应 test:watch)`},{flags:`--coverage`,description:`覆盖率(对应 test:coverage)`}],schema:Nl({watch:Tl().optional(),coverage:Tl().optional()}),action:async(e,t)=>{await Nm({watch:e.watch===!0,coverage:e.coverage===!0,extra:t})}})}function Um(e){Su(e,{name:`lockfile check`,description:`校验单一 bun.lock 不变量与 workspaces 覆盖缺口`,schema:Nl({}),action:async()=>{await af()}})}function Wm(e){Su(e,{name:`node-links check`,description:`检测 node_modules 悬挂符号链接,命中即非零退出`,schema:Nl({}),action:async()=>{await pf()}}),Su(e,{name:`node-links fix`,description:`回收 node_modules 悬挂死链,删除前复验,有效链接零触碰`,schema:Nl({}),action:async()=>{await mf()}})}function Gm(e){Su(e,{name:`typeonly audit`,description:`检查各包的目录分层、预设声明与包内容是否符合规则,并管理违规基线`,options:[{flags:`-r, --recursive`,description:`递归审计 workspace 内全部含 lzi-bun.config.ts 的包`},{flags:`--check`,description:`校验模式,实际违规须为基线子集,否则非零退出`},{flags:`--json`,description:`以 JSON 形态输出审计行`},{flags:`--init-baseline`,description:`落盘当前全量违规为基线祖父条款`},{flags:`--prune-baseline`,description:`移除基线中已修复的条目,只减不增`}],schema:Nl({recursive:Tl().optional(),check:Tl().optional(),json:Tl().optional(),initBaseline:Tl().optional(),pruneBaseline:Tl().optional()}),action:async e=>{await Bm({recursive:e.recursive===!0,check:e.check===!0,json:e.json===!0,initBaseline:e.initBaseline===!0,pruneBaseline:e.pruneBaseline===!0})}})}function Km(e){Su(e,{name:`config generate`,description:`生成 bunfig.toml(不执行测试,支持 --dry-run 预览、--check 校验、-r 批量、--globals 定位)`,options:[{flags:`--dry-run`,description:`仅预览将写入的内容,不写盘`},{flags:`--check`,description:`仅校验磁盘 bunfig.toml 与生成器预期是否一致(漂移即报错退出,不写盘)`},{flags:`-r, --recursive`,description:`递归处理 monorepo 下含 lzi-bun.config.ts 的子包`},{flags:`--globals <path>`,description:`一次性 bootstrap 定位 globals 仓(命中后固化 .env,此后零参数)`}],schema:Nl({dryRun:Tl().optional(),check:Tl().optional(),recursive:Tl().optional(),globals:el().optional()}),action:async e=>{await Lm({dryRun:e.dryRun===!0,check:e.check===!0,recursive:e.recursive===!0,globalsPath:e.globals})}})}const qm=vu({name:`lzi-bun-cli`,description:`Longzai Intelligence bun 工具集`,interaction:Vd,color:Bd});Vm(qm);async function Jm(){await qm.parseAsync(process.argv)}Jm().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.2",
3
+ "version": "0.1.3",
4
4
  "description": "Longzai Intelligence Bun 工具集 CLI",
5
5
  "keywords": [
6
6
  "bun",
@@ -40,7 +40,8 @@
40
40
  "test:coverage": "bun test --coverage"
41
41
  },
42
42
  "dependencies": {
43
- "@longzai-intelligence-bun/config": "0.1.2",
43
+ "@longzai-intelligence-bun/config": "0.1.3",
44
+ "@longzai-intelligence-bun/presets": "0.1.3",
44
45
  "@longzai-intelligence-cli/core": "^0.0.10",
45
46
  "@longzai-intelligence-cli/standard": "^0.0.10",
46
47
  "@longzai-intelligence-logger/node": "^0.1.8",