@longzai-intelligence/eslint-plugin-architecture 0.0.1 → 0.0.2

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.
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`@longzai-intelligence/eslint-utils`),l=require(`node:path`);l=s(l);let u=require(`node:fs`);u=s(u);let d=require(`@typescript-eslint/utils`);const f={types:0,utils:1,"shared-kernel":2,contract:3,engine:4,platform:5,infrastructure:6,implementation:6},ee=[{pattern:/\/domains\/[^/]+\/implementation\//,layer:`implementation`},{pattern:/\/domains\/[^/]+\/contract\//,layer:`contract`},{pattern:/\/domains\/shared-kernel\//,layer:`shared-kernel`},{pattern:/\/infrastructure\//,layer:`infrastructure`},{pattern:/\/packages\/utils\//,layer:`utils`},{pattern:/\/packages\/errors\//,layer:`utils`},{pattern:/\/packages\/zod-utils\//,layer:`utils`},{pattern:/\/packages\/testing-utils\//,layer:`utils`},{pattern:/\/packages\/engine\/[^/]+\//,layer:`engine`},{pattern:/\/packages\/design-system\/primitives\//,layer:`utils`},{pattern:/\/packages\/design-system\/composites\//,layer:`implementation`},{pattern:/\/packages\/design-system\/utils\//,layer:`utils`},{pattern:/\/packages\/electron\//,layer:`implementation`},{pattern:/\/packages\/typeorm-adapter\//,layer:`implementation`},{pattern:/\/packages\/typeorm-utils\//,layer:`utils`},{pattern:/\/packages\/http-client\//,layer:`utils`},{pattern:/\/packages\/pagination\//,layer:`utils`},{pattern:/\/packages\/turbo-output-parser\//,layer:`utils`},{pattern:/\/packages\/host-contracts\//,layer:`contract`},{pattern:/\/packages\/event-bus\/contract\//,layer:`contract`},{pattern:/\/packages\/event-bus\/implementation\//,layer:`implementation`},{pattern:/\/packages\/payment\/core\//,layer:`contract`},{pattern:/\/packages\/payment\/adapters\//,layer:`implementation`},{pattern:/\/packages\/payment\/presets\//,layer:`implementation`},{pattern:/\/packages\/logger\/core\//,layer:`contract`},{pattern:/\/packages\/logger\/adapters\//,layer:`implementation`},{pattern:/\/packages\/logger\/presets\//,layer:`implementation`},{pattern:/\/packages\/react-devtools\/core\//,layer:`contract`},{pattern:/\/packages\/react-devtools\/adapters\//,layer:`implementation`},{pattern:/\/packages\/react-devtools\/ui\//,layer:`implementation`},{pattern:/\/packages\/react-devtools\/presets\//,layer:`implementation`},{pattern:/\/packages\/feed-parser\/protocol\//,layer:`contract`},{pattern:/\/packages\/feed-parser\/[^/]+\//,layer:`implementation`}],te=[{pattern:/\/src\/domain\//,layer:`contract`},{pattern:/\/src\/engine\//,layer:`engine`},{pattern:/\/src\/platform\//,layer:`platform`},{pattern:/\/src\/infrastructure\//,layer:`infrastructure`},{pattern:/\/src\/shared\//,layer:`shared-kernel`}],ne=[{pattern:/\/src\/domain\//,layer:`contract`},{pattern:/\/src\/engine\//,layer:`engine`},{pattern:/\/src\/platform\//,layer:`platform`},{pattern:/\/src\/infrastructure\//,layer:`infrastructure`},{pattern:/\/src\/shared\//,layer:`shared-kernel`}],p=new WeakMap;function re(e){let t=e.replace(/\\/g,`/`);for(let{pattern:e,layer:n}of ee)if(e.test(t))return{layer:n,priority:f[n]};return t.includes(`/apps/`)?ae(t):t.includes(`/packages/`)?oe(t):null}function ie(e,t){let n=p.get(t);if(n||(n=new Map,p.set(t,n)),n.has(e))return n.get(e);let r=re(e);return n.set(e,r),r}function ae(e){for(let{pattern:t,layer:n}of te)if(t.test(e))return{layer:n,priority:f[n]};return null}function oe(e){for(let{pattern:t,layer:n}of ne)if(t.test(e))return{layer:n,priority:f[n]};return null}const se=[{suffix:`-contract`,layer:`contract`},{suffix:`-implementation`,layer:`implementation`},{suffix:`-engine`,layer:`engine`},{suffix:`-runtime`,layer:`engine`}],ce={"@longzai-intelligence/shared-kernel":`shared-kernel`,"@longzai-intelligence/utils":`utils`,"@longzai-intelligence/error-utils":`utils`,"@longzai-intelligence/zod-utils":`utils`,"@longzai-intelligence/testing-utils":`utils`,"@longzai-intelligence/host-contracts":`contract`,"@longzai-intelligence/typeorm-adapter":`implementation`,"@longzai-intelligence/typeorm-utils":`utils`,"@longzai-intelligence/http-client":`utils`,"@longzai-intelligence/pagination":`utils`,"@longzai-intelligence/turbo-output-parser":`utils`,"@longzai-intelligence/electron":`implementation`},m=`@longzai-intelligence/`;function le(e){if(!e.startsWith(m))return null;let t=e.split(`/`)[1];if(!t)return null;let n=ce[`${m}${t}`];if(n)return{layer:n,priority:f[n]};for(let{suffix:e,layer:n}of se)if(t.endsWith(e))return{layer:n,priority:f[n]};return null}const ue={types:`类型层 (Types)`,utils:`工具层 (Utils)`,"shared-kernel":`共享内核层 (Shared Kernel)`,contract:`契约层 (Contract)`,engine:`引擎层 (Engine)`,platform:`平台层 (Platform)`,infrastructure:`基础设施层 (Infrastructure)`,implementation:`实现层 (Implementation)`};function de(e){return ue[e]}function fe(e,t){return f[e]>=f[t]}const pe={meta:{type:`problem`,docs:{description:`强制执行 Clean Architecture 的依赖方向规则`},messages:{invalidDependency:`依赖方向违规: {{currentLayer}} ({{currentLayerName}}) 不能导入 {{importLayer}} ({{importLayerName}})。依赖应该从外层指向内层,请检查导入语句。`},schema:[]},create(e){let t=e.filename,n=ie(t,e);return n?{ImportDeclaration(t){let r=t.source.value;if(typeof r!=`string`)return;let i=le(r);i&&(fe(n.layer,i.layer)||e.report({node:t,messageId:`invalidDependency`,data:{currentLayer:n.layer,currentLayerName:de(n.layer),importLayer:i.layer,importLayerName:de(i.layer)}}))}}:{}}},me=new Set(`Agent.Page.PageContent.Workspace.WorkspaceMember.User.Session.Task.Repository.Folder.SyncMetadata.SyncError.SyncErrorCode.SyncResult.SyncStatus.SyncConflictData.EntityChange.OfflineOperation.DirtyEntity.PullResult.PushResult.ApiResponse.P2PNode.ConnectionState.NetworkStatus.IMAgent.IMContact.IMConversation.IMMessage.IMGroup.IMGroupSettings`.split(`.`));function he(e){return e.replace(/\\/g,`/`).includes(`/apps/`)}function h(e){return me.has(e)}const g={meta:{type:`problem`,docs:{description:`禁止在 apps 层定义核心领域类型`},messages:{noCoreTypesInApps:`禁止在 apps 层定义核心领域类型 "{{typeName}}"。请在 packages/types 或 packages/domain 中定义此类型。`},schema:[]},create(e){let t=e.filename;return he(t)?{TSInterfaceDeclaration(t){if(!(0,c.hasIdWithName)(t))return;let n=t.id.name;h(n)&&e.report({node:t,messageId:`noCoreTypesInApps`,data:{typeName:n}})},TSTypeAliasDeclaration(t){if(!(0,c.hasIdWithName)(t))return;let n=t.id.name;h(n)&&e.report({node:t,messageId:`noCoreTypesInApps`,data:{typeName:n}})},ClassDeclaration(t){if(!(0,c.hasIdWithName)(t))return;let n=t.id.name;h(n)&&e.report({node:t,messageId:`noCoreTypesInApps`,data:{typeName:n}})}}:{}}},_={node:[`fs`,`path`,`os`,`crypto`,`child_process`,`cluster`,`dgram`,`dns`,`http`,`https`,`net`,`readline`,`stream`,`tls`,`tty`,`udp`,`url`,`util`,`v8`,`vm`,`worker_threads`,`zlib`],browser:[`window`,`document`,`navigator`,`localStorage`,`sessionStorage`,`fetch`,`XMLHttpRequest`,`WebSocket`,`Worker`,`IndexedDB`,`Blob`,`File`,`FileReader`,`URL`,`URLSearchParams`,`History`,`Location`,`Screen`,`AudioContext`,`Canvas`,`Notification`,`Performance`,`ServiceWorker`],electron:[`ipcRenderer`,`ipcMain`,`app`,`BrowserWindow`,`dialog`,`Menu`,`Tray`,`nativeImage`,`shell`,`clipboard`]},ge=new Set(_.node),_e=new Set(_.browser),ve=new Set(_.electron),ye=[/\/domains\/shared-kernel\//,/\/domains\/page-domain\//,/\/domains\/repository-domain\//,/\/domains\/agent-domain\//,/\/domains\/collab-domain\//,/\/domains\/identity-domain\//,/\/domains\/workflow-domain\//,/\/domains\/chat-domain\//,/\/domains\/workspace-domain\//];function be(e){let t=e.replace(/\\/g,`/`);return ye.some(e=>e.test(t))}function xe(e){if(e.startsWith(`node:`)||ge.has(e))return`node`;for(let t of _.node)if(e.startsWith(`${t}/`))return`node`;return null}function v(e){return _e.has(e)}function y(e){return ve.has(e)}function Se(e){return typeof e==`object`&&!!e&&`object`in e&&e.object!==null&&typeof e.object==`object`&&`type`in e.object&&`name`in e.object}function Ce(e){return typeof e==`object`&&!!e&&`name`in e&&typeof e.name==`string`}function we(e,t){if(!(0,c.isImportDeclaration)(e))return;let n=e.source.value;if(typeof n==`string`&&xe(n)){let r=n.replace(/^node:/,``);t.report({node:e,messageId:`nodeImport`,data:{moduleName:r}})}}function Te(e,t){if(Se(e)&&e.object.type===`Identifier`){let n=e.object.name;v(n)&&t.report({node:e,messageId:`browserAPI`,data:{apiName:n}}),y(n)&&t.report({node:e,messageId:`electronAPI`,data:{apiName:n}})}}function Ee(e,t){if(!Ce(e))return;let n=e.name;(v(n)||y(n))&&e.parent&&e.parent.type!==`MemberExpression`&&t.report({node:e,messageId:`globalAPI`,data:{globalName:n}})}const b={meta:{type:`problem`,docs:{description:`禁止在业务域层直接使用平台特定 API`},messages:{nodeImport:`平台代码泄漏: 业务域层禁止直接导入 Node.js 模块 '{{moduleName}}'。请通过 packages/platform 层的接口间接访问。`,browserAPI:`平台代码泄漏: 业务域层禁止直接使用浏览器 API '{{apiName}}'。请通过 packages/platform 层的接口间接访问。`,electronAPI:`平台代码泄漏: 业务域层禁止直接使用 Electron API '{{apiName}}'。请通过 packages/platform 层的接口间接访问。`,globalAPI:`平台代码泄漏: 业务域层禁止直接访问全局对象 '{{globalName}}'。请通过 packages/platform 层的接口间接访问。`},schema:[]},create(e){let t=e.filename;return be(t)?{ImportDeclaration(t){we(t,e)},MemberExpression(t){Te(t,e)},Identifier(t){Ee(t,e)}}:{}}},De=[/\/packages\/platform\//,/\/packages\/ui\//,/\/packages\/ui-kit\//,/\/packages\/engine\//,/\/packages\/utils\//,/\/packages\/types\//],Oe=[`Page`,`Repository`,`Agent`,`Workflow`,`Workspace`,`User`,`Auth`,`Session`,`Message`,`Conversation`,`Sync`,`Favorite`,`Folder`,`Team`,`Execution`,`Task`,`Step`,`Trigger`],ke=[/^validate/,/^calculate/,/^compute/,/^determine/,/^check/,/^can/,/^should/,/^isAllowed/,/^isPermitted/,/^hasPermission/,/^applyRule/,/^enforce/,/^execute/];function Ae(e){let t=e.replace(/\\/g,`/`);return De.some(e=>e.test(t))}function x(e){let t=e.charAt(0).toUpperCase()+e.slice(1);return Oe.some(e=>t.includes(e))}function je(e){return ke.some(t=>t.test(e))}function Me(e){return typeof e==`object`&&!!e&&`key`in e&&e.key!==null&&typeof e.key==`object`&&`type`in e.key&&e.key.type===`Identifier`&&`name`in e.key&&typeof e.key.name==`string`}function Ne(e){return typeof e==`object`&&!!e&&`id`in e&&e.id!==null&&typeof e.id==`object`&&`type`in e.id&&e.id.type===`Identifier`&&`name`in e.id&&typeof e.id.name==`string`&&`type`in e&&typeof e.type==`string`}function Pe(e,t){(0,c.hasIdWithName)(e)&&x(e.id.name)&&t.report({node:e,messageId:`businessClass`,data:{className:e.id.name}})}function Fe(e,t){Me(e)&&je(e.key.name)&&t.report({node:e,messageId:`businessMethod`,data:{methodName:e.key.name}})}function Ie(e,t){(0,c.hasIdWithName)(e)&&x(e.id.name)&&t.report({node:e,messageId:`businessInterface`,data:{interfaceName:e.id.name}})}function Le(e,t){Ne(e)&&x(e.id.name)&&t.report({node:e,messageId:`businessType`,data:{typeName:e.id.name}})}const Re={meta:{type:`suggestion`,docs:{description:`检测技术层中可能存在的业务逻辑`},messages:{businessClass:`业务逻辑泄漏嫌疑: 技术层发现业务相关类 '{{className}}'。业务逻辑应该放在 domains/ 层。`,businessMethod:`业务逻辑泄漏嫌疑: 技术层发现业务规则方法 '{{methodName}}'。业务规则应该放在 domains/ 层。`,businessInterface:`业务逻辑泄漏嫌疑: 技术层发现业务相关接口 '{{interfaceName}}'。业务接口应该放在 domains/ 层。`,businessType:`业务逻辑泄漏嫌疑: 技术层发现业务相关类型 '{{typeName}}'。业务类型应该放在 domains/ 层。`},schema:[]},create(e){let t=e.filename;return Ae(t)?{ClassDeclaration(t){Pe(t,e)},MethodDefinition(t){Fe(t,e)},TSInterfaceDeclaration(t){Ie(t,e)},TSTypeAliasDeclaration(t){Le(t,e)}}:{}}};function ze(e){return e.startsWith(`create`)||e.startsWith(`make`)||e.startsWith(`build`)}function Be(e){return/domains\/[^/]+\/(implementation|contract)\/src\/index\.ts$/.test(e)?`main`:/domains\/[^/]+\/(implementation|contract)\/src\/(domain|application|infrastructure)\/index\.ts$/.test(e)?`layer`:/domains\/[^/]+\/(implementation|contract)\/src\/(domain|application|infrastructure)\/\w+\/index\.ts$/.test(e)?`submodule`:`none`}function Ve(e){return e.includes(`/infrastructure/`)}const He=[],Ue=[{pattern:/^(?!create)[A-Za-z]+Repository(Drizzle|Memory|Sqlite|Mysql)$/,messageId:`forbiddenRepositoryExport`,message:`禁止导出具体仓储实现类`},{pattern:/^(?!create)[A-Za-z]*Table$/,messageId:`forbiddenTableExport`,message:`禁止导出数据库表定义`},{pattern:/[A-Za-z]+OrmEntity$/,messageId:`forbiddenOrmEntityExportFromMain`,message:`禁止从主入口导出 ORM 实体,应从 ./typeorm 入口导出`},{pattern:/[A-Z_]+_ORM_ENTITIES$/,messageId:`forbiddenEntitiesExportFromMain`,message:`禁止从主入口导出实体集合,应从 ./typeorm 入口导出`},{pattern:/[A-Za-z]+OrmMapper$/,messageId:`forbiddenOrmMapperExportFromMain`,message:`禁止从主入口导出 ORM Mapper,这是基础设施层实现细节`}],We=/^(?!create)[A-Za-z]*Schema$/,Ge=new WeakMap;function Ke(e,t,n){if(!n)return qe(e,t);let r=Ge.get(n);if(r||(r=new Map,Ge.set(n,r)),r.has(t))return r.get(t);let i=qe(e,t);return r.set(t,i),i}function qe(e,t){let n=[],r=/export\s*\*\s*from/.test(e),i=e.matchAll(/export\s+type\s+\{([^}]+)\}/g);for(let e of i){let t=e[1];if(t){let e=t.split(`,`).map(e=>{let t=e.trim().split(` as `);return t[0]?t[0].trim():``}).filter(e=>e);n.push(...e)}}let a=e.matchAll(/export\s+(?!type)\{([^}]+)\}/g);for(let e of a){let t=e[1];if(t){let e=t.split(`,`).map(e=>{let t=e.trim().split(` as `);return t[0]?t[0].trim():``}).filter(e=>e);n.push(...e)}}let o=e.matchAll(/export\s+(class|function|const|let|interface|type)\s+(\w+)/g);for(let e of o){let t=e[2];t&&n.push(t)}let s=[],c=Ve(t);if(Be(t)===`submodule`)return{usesExportStar:r,exports:n,forbiddenIssues:s};for(let e of n)if(!ze(e)){for(let{pattern:t,messageId:n}of He)t.test(e)&&s.push({messageId:n,exportName:e});for(let{pattern:t,messageId:n}of Ue)t.test(e)&&s.push({messageId:n,exportName:e});c&&We.test(e)&&s.push({messageId:`forbiddenSchemaExport`,exportName:e})}return{usesExportStar:r,exports:n,forbiddenIssues:s}}const Je={meta:{type:`problem`,docs:{description:`Domain 包导出规范:禁止 export *、禁止导出具体实现类、禁止导出数据库表和 Schema`,recommended:!0},schema:[],messages:{forbiddenExportStar:`禁止使用 export *,应使用显式导出(export { ... } 或 export type { ... })`,forbiddenRepositoryExport:`禁止导出具体仓储实现类 {{exportName}},应使用工厂函数 createXxxRepository`,forbiddenTableExport:`禁止导出数据库表定义 {{exportName}}`,forbiddenSchemaExport:`禁止导出 Schema 定义 {{exportName}}`,forbiddenOrmEntityExportFromMain:`禁止从主入口导出 ORM 实体 {{exportName}},应从 ./typeorm 入口导出`,forbiddenEntitiesExportFromMain:`禁止从主入口导出实体集合 {{exportName}},应从 ./typeorm 入口导出`,forbiddenOrmMapperExportFromMain:`禁止从主入口导出 ORM Mapper {{exportName}},这是基础设施层实现细节`}},create(e){let t=e.filename;if(Be(t)===`none`)return{};let n=e.sourceCode.text,{usesExportStar:r,forbiddenIssues:i}=Ke(n,t,e);return{Program(t){r&&e.report({node:t,messageId:`forbiddenExportStar`});for(let n of i)e.report({node:t,messageId:n.messageId,data:{exportName:n.exportName}})}}}},Ye=/@longzai-intelligence\/[^/]+\/typeorm/,Xe=/@longzai-intelligence\/[^/]+\/infrastructure\//,Ze=[/data-source\.ts$/,/data-source\.config\.ts$/,/data-source\.[a-z-]+\.ts$/,/database\.module\.ts$/,/database\.ts$/,/database\.config\.ts$/,/database\.service\.ts$/];function Qe(e){return Ze.some(t=>t.test(e))}const $e={meta:{type:`problem`,docs:{description:`Domain TypeORM 导入规范:非 DataSource 场景禁止导入 /typeorm 入口,禁止 infrastructure/* deep import`,recommended:!0},schema:[],messages:{forbiddenTypeormImport:`非 DataSource 场景禁止从 /typeorm 入口导入 ORM 实体,该入口仅供 DataSource/迁移基础设施使用`,forbiddenInfrastructureImport:`禁止 infrastructure/* deep import,应使用受控入口(主入口或 ./typeorm)`}},create(e){let t=e.filename,n=Qe(t);return{ImportDeclaration(t){if(!t.source)return;let r=t.source.value;typeof r==`string`&&(Ye.test(r)&&(n||e.report({node:t,messageId:`forbiddenTypeormImport`})),Xe.test(r)&&e.report({node:t,messageId:`forbiddenInfrastructureImport`}))}}}};function et(e){if(typeof e!=`object`||!e)return!1;let t=e;return`name`in t&&typeof t.name==`string`&&`isSpecialFile`in t&&typeof t.isSpecialFile==`function`&&`getNamingRules`in t&&typeof t.getNamingRules==`function`&&`shouldSkipTypeSuffix`in t&&typeof t.shouldSkipTypeSuffix==`function`}const tt=[{pattern:/\.service\.drizzle\.ts$/,case:`kebab-case`,description:`Drizzle Service 文件应使用 xxx.service.drizzle.ts 格式(kebab-case)`},{pattern:/\.service\.memory\.ts$/,case:`kebab-case`,description:`Memory Service 文件应使用 xxx.service.memory.ts 格式(kebab-case)`},{pattern:/\.service\.ts$/,case:`kebab-case`,description:`服务文件应使用 xxx.service.ts 格式(kebab-case)`},{pattern:/\.controller\.ts$/,case:`kebab-case`,description:`控制器文件应使用 xxx.controller.ts 格式(kebab-case)`},{pattern:/\.module\.ts$/,case:`kebab-case`,description:`模块文件应使用 xxx.module.ts 格式(kebab-case)`},{pattern:/\.repository\.drizzle\.ts$/,case:`kebab-case`,description:`Drizzle Repository 文件应使用 xxx.repository.drizzle.ts 格式(kebab-case)`},{pattern:/\.repository\.memory\.ts$/,case:`kebab-case`,description:`Memory Repository 文件应使用 xxx.repository.memory.ts 格式(kebab-case)`},{pattern:/\.repository\.interface\.ts$/,case:`kebab-case`,description:`Repository 接口文件应使用 xxx.repository.interface.ts 格式(kebab-case)`},{pattern:/\.repository\.types\.ts$/,case:`kebab-case`,description:`Repository 类型文件应使用 xxx.repository.types.ts 格式(kebab-case)`},{pattern:/\.repository\.ts$/,case:`kebab-case`,description:`Repository 文件应使用 xxx.repository.ts 格式(kebab-case)`},{pattern:/\.entity\.types\.ts$/,case:`kebab-case`,description:`Entity 类型文件应使用 xxx.entity.types.ts 格式(kebab-case)`},{pattern:/\.entity\.interface\.ts$/,case:`kebab-case`,description:`Entity 接口文件应使用 xxx.entity.interface.ts 格式(kebab-case)`},{pattern:/\.entity\.ts$/,case:`kebab-case`,description:`Entity 文件应使用 xxx.entity.ts 格式(kebab-case)`},{pattern:/\.dto\.ts$/,case:`kebab-case`,description:`DTO 文件应使用 xxx.dto.ts 格式(kebab-case)`},{pattern:/\.port\.interface\.ts$/,case:`kebab-case`,description:`Port 接口文件应使用 xxx.port.interface.ts 格式(kebab-case)`},{pattern:/\.interface\.ts$/,case:`kebab-case`,description:`接口文件应使用 xxx.interface.ts 格式(kebab-case)`},{pattern:/\.types\.ts$/,case:`kebab-case`,description:`类型文件应使用 xxx.types.ts 格式(kebab-case)`},{pattern:/\.schema\.ts$/,case:`kebab-case`,description:`Schema 文件应使用 xxx.schema.ts 格式(kebab-case)`},{pattern:/\.port\.ts$/,case:`kebab-case`,description:`Port 文件应使用 xxx.port.ts 格式(kebab-case)`},{pattern:/\.port\.adapter\.ts$/,case:`kebab-case`,description:`Port Adapter 文件应使用 xxx.port.adapter.ts 格式(kebab-case)`},{pattern:/\.adapter\.ts$/,case:`kebab-case`,description:`Adapter 文件应使用 xxx.adapter.ts 格式(kebab-case)`},{pattern:/\.events\.ts$/,case:`kebab-case`,description:`Events 文件应使用 xxx.events.ts 格式(kebab-case)`},{pattern:/\.mapper\.ts$/,case:`kebab-case`,description:`Mapper 文件应使用 xxx.mapper.ts 格式(kebab-case)`},{pattern:/\.ipc\.ts$/,case:`kebab-case`,description:`IPC 文件应使用 xxx.ipc.ts 格式(kebab-case)`},{pattern:/\.config\.ts$/,case:`kebab-case`,description:`配置文件应使用 xxx.config.ts 格式(kebab-case)`},{pattern:/\.errors\.ts$/,case:`kebab-case`,description:`错误文件应使用 xxx.errors.ts 格式(kebab-case)`},{pattern:/\.utils\.ts$/,case:`kebab-case`,description:`工具函数文件应使用 xxx.utils.ts 格式(kebab-case)`},{pattern:/\.constants\.ts$/,case:`kebab-case`,description:`常量文件应使用 xxx.constants.ts 格式(kebab-case)`},{pattern:/\.atom\.ts$/,case:`kebab-case`,description:`Atom 文件应使用 xxx.atom.ts 格式(kebab-case)`},{pattern:/\.vo\.ts$/,case:`kebab-case`,description:`值对象文件应使用 xxx.vo.ts 格式(kebab-case)`},{pattern:/\.usecase\.ts$/,case:`kebab-case`,description:`UseCase 文件应使用 xxx.usecase.ts 格式(kebab-case)`},{pattern:/\.styles\.css$/,case:`kebab-case`,description:`样式文件应使用 xxx.styles.css 格式(kebab-case)`},{pattern:/\.extension\.tsx?$/,case:`kebab-case`,description:`扩展文件应使用 xxx.extension.ts(x) 格式(kebab-case)`}],nt=[{pattern:/^use[A-Z][a-zA-Z]*\.spec\.tsx?$/,case:`camelCase`,description:`Hook 测试文件应使用 camelCase 并以 use 前缀开头(如 useChat.spec.ts)`},{pattern:/^use[A-Z][a-zA-Z]*\.test\.tsx?$/,case:`camelCase`,description:`Hook 测试文件应使用 camelCase 并以 use 前缀开头(如 useChat.test.ts)`},{pattern:/^use[A-Z][a-zA-Z]*\.types\.ts$/,case:`camelCase`,description:`Hook 类型文件应使用 camelCase 并以 use 前缀开头(如 useChat.types.ts)`},{pattern:/\.spec\.ts$/,case:`kebab-case-test`,description:`测试文件应使用 xxx.spec.ts 格式(kebab-case)`},{pattern:/\.test\.ts$/,case:`kebab-case-test`,description:`测试文件应使用 xxx.test.ts 格式(kebab-case)`},{pattern:/\.spec\.tsx$/,case:`kebab-case-test`,description:`测试文件应使用 xxx.spec.tsx 格式(kebab-case)`},{pattern:/\.test\.tsx$/,case:`kebab-case-test`,description:`测试文件应使用 xxx.test.tsx 格式(kebab-case)`},{pattern:/^use[A-Z][a-zA-Z]*\.tsx?$/,case:`camelCase`,description:`Hook 文件应使用 camelCase 并以 use 前缀开头(如 useChat.ts)`}],S={pattern:/^[A-Z][a-zA-Z]*\.tsx$/,case:`PascalCase`,description:`React 组件文件应使用 PascalCase(如 ChatPage.tsx)`};[...nt,...tt];const rt=[`index.ts`,`index.tsx`,`main.ts`,`main.tsx`,`App.tsx`,`types.ts`,`errors.ts`,`constants.ts`,`persistence.ts`,`typeorm.ts`],it=[`impl`,`functions`,`methods`,`handlers`,`classes`];function at(e){let t=e.replace(/\.tsx?$/,``);return[/s$/,/es$/,/ies$/].some(e=>e.test(t))}function ot(e){return/^v\d+(-[a-z0-9-]+)?\.ts$/.test(e)}function st(e){let t=e.replace(/\.tsx?$/,``);for(let e of it){if(t.endsWith(`.${e}`))return e;let n=t.split(`.`);if(n.length>=2&&n[n.length-1]===e)return e}return null}function ct(e){if(!e.endsWith(`.tsx`))return!1;let t=e.replace(`.tsx`,``);return/^[A-Z][a-zA-Z0-9]*$/.test(t)}function lt(e){if(!e.endsWith(`.ts`)&&!e.endsWith(`.tsx`))return!1;let t=e.replace(/\.tsx?$/,``);return/^use[A-Z][a-zA-Z0-9]*$/.test(t)}function ut(e){for(let t of[`.test.ts`,`.test.tsx`,`.spec.ts`,`.spec.tsx`])if(e.endsWith(t)){let n=t.endsWith(`.tsx`)?`.tsx`:`.ts`;return e.replace(t,n)}return e}const C={name:`base`,isSpecialFile(e){return!!(rt.includes(e)||e.endsWith(`.d.ts`)||ot(e))},getNamingRules(){return[...nt,...tt,S]},shouldSkipTypeSuffix(e){let t=ut(e);return!!(rt.includes(t)||t.endsWith(`.d.ts`)||ot(t)||ct(t)||lt(t)||!st(t)&&at(t))}},w=[`page.tsx`,`page.ts`,`layout.tsx`,`layout.ts`,`loading.tsx`,`loading.ts`,`error.tsx`,`error.ts`,`not-found.tsx`,`not-found.ts`,`template.tsx`,`template.ts`,`default.tsx`,`default.ts`,`global-error.tsx`,`global-error.ts`,`middleware.ts`,`route.ts`],dt={name:`nextjs`,isSpecialFile(e){return w.includes(e)},getNamingRules(){return[]},shouldSkipTypeSuffix(e){return w.includes(e)}},ft=[/^\[.+\]\.tsx?$/,/^_layout\.tsx?$/,/^\(.+\)\.tsx?$/],pt=[`_layout.tsx`,`_layout.ts`,`_sitemap.tsx`,`_sitemap.ts`],mt={name:`expo-router`,isSpecialFile(e){return pt.includes(e)?!0:ft.some(t=>t.test(e))},getNamingRules(){return[]},shouldSkipTypeSuffix(e){return this.isSpecialFile(e)}},ht=new Map;function T(e){ht.set(e.name,e)}T(C),T(dt),T(mt);function E(e){return/^[A-Z][a-zA-Z0-9]*$/.test(e)}function gt(e){return/^[a-z][a-zA-Z0-9]*$/.test(e)}function D(e){return/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/.test(e)}function _t(e){return e.split(`.`).every(e=>D(e)&&e.length>0)}function vt(e){return e.split(`.`).every(e=>D(e)&&e.length>0)}function yt(e,t){if(e.endsWith(`.types`)&&t===`kebab-case`)return _t(e);switch(t){case`PascalCase`:return E(e);case`camelCase`:return gt(e);case`kebab-case`:return D(e);case`kebab-case-test`:return vt(e);default:return!1}}const O=new WeakMap;function k(e,t){if(!t)try{return u.default.existsSync(e)}catch{return!1}let n=O.get(t);if(n||(n=new Map,O.set(t,n)),n.has(e))return n.get(e);let r;try{r=u.default.existsSync(e)}catch{r=!1}return n.set(e,r),r}function bt(e,t,n,r){let i=t.substring(6),a=l.default.dirname(i);return k(l.default.join(e,`pages`,a===`.`?``:a,n),r)}function xt(e,t,n,r){let i=t.substring(11),a=l.default.dirname(i);return k(l.default.join(e,`components`,a===`.`?``:a,n),r)}function St(e,t,n,r){let i=t.substring(14),a=l.default.dirname(i);return k(l.default.join(e,`ui`,`components`,a===`.`?``:a,n),r)}function Ct(e,t,n,r){let i=t.substring(6),a=l.default.dirname(i);return k(l.default.join(e,`react`,a===`.`?``:a,n),r)}function wt(e,t,n){let r=e.indexOf(`/__tests__/`),i=e.substring(0,r),a=e.substring(r+11);return a.startsWith(`pages/`)?bt(i,a,t,n):a.startsWith(`components/`)?xt(i,a,t,n):a.startsWith(`ui/components/`)?St(i,a,t,n):a.startsWith(`react/`)?Ct(i,a,t,n):k(l.default.join(i,t),n)}function Tt(e,t,n){let r=e.replace(/\\/g,`/`),i=r.includes(`/__tests__/`),a=r.includes(`/components/`);if(!a&&!i||!(t.endsWith(`.test.tsx`)||t.endsWith(`.spec.tsx`)||t.endsWith(`.test.ts`)||t.endsWith(`.spec.ts`)))return!1;let o=t.replace(/\.(test|spec)\.(tsx|ts)$/,`.tsx`);return i?wt(r,o,n):a?k(l.default.join(l.default.dirname(e),o),n):!1}const A=new WeakMap;function Et(e,t){if(!t)try{return u.default.existsSync(e)}catch{return!1}let n=A.get(t);if(n||(n=new Map,A.set(t,n)),n.has(e))return n.get(e);let r;try{r=u.default.existsSync(e)}catch{r=!1}return n.set(e,r),r}function Dt(e,t,n){if(!e.replace(/\\/g,`/`).includes(`/components/`)||!t.endsWith(`.types.ts`))return!1;let r=t.replace(`.types.ts`,`.tsx`);return Et(l.default.join(l.default.dirname(e),r),n)}function Ot(e,t){if(t===S)return e.replace(/\.tsx$/,``);let n=t.pattern.source;return n.startsWith(`^`)&&n.endsWith(`$`)?n.includes(`\\.test\\.`)||n.includes(`\\.spec\\.`)?e.replace(/\.(test|spec)\.(tsx?|jsx?)$/,``):n.includes(`\\.types\\.`)?e.replace(/\.types\.ts$/,``):e.replace(/\.[^.]+$/,``):e.replace(t.pattern,``)}const j={meta:{type:`problem`,docs:{description:`强制执行文件命名规范`},messages:{invalidFileName:`文件命名违规: {{fileName}}。{{description}}`},schema:[]},create(e){let t=e.filename,n=l.default.basename(t),r=et(e.settings?.platformNamingStrategy)?e.settings.platformNamingStrategy:C;if(r.isSpecialFile(n,t)||Dt(t,n,e)&&E(n.replace(`.types.ts`,``))||Tt(t,n,e)&&E(n.replace(/\.(test|spec)\.(tsx|ts)$/,``)))return{};let i=r.getNamingRules().find(e=>e.pattern.test(n));if(!i&&n.endsWith(`.tsx`)&&(i=S),!i)return{};let a=Ot(n,i);return yt(n.endsWith(`.types.ts`)&&i.case===`kebab-case`?n.replace(/\.ts$/,``):a,i.case)||e.report({loc:{start:{line:1,column:0},end:{line:1,column:n.length}},messageId:`invalidFileName`,data:{fileName:n,description:i.description}}),{}}};function kt(e){return e.endsWith(`.types.ts`)?!0:/^[a-z][a-z0-9-]*\.[a-z][a-z0-9-]*\.tsx?$/.test(e)||/^[a-z][a-z0-9-]*\.[a-z][a-z0-9-]*\.[a-z][a-z0-9-]*\.tsx?$/.test(e)}function At(e){let t=e.replace(/\.tsx?$/,``);for(let e of it){if(t.endsWith(`.${e}`))return e;let n=t.split(`.`);if(n.length>=2&&n[n.length-1]===e)return e}return null}function jt(e){let t=[],n=e.replace(/\.tsx?$/,``);return(n.includes(`service`)||n.includes(`Service`))&&t.push(`.service.ts`),(n.includes(`controller`)||n.includes(`Controller`))&&t.push(`.controller.ts`),(n.includes(`utils`)||n.includes(`helper`)||n.includes(`Helper`))&&t.push(`.utils.ts`),(n.includes(`constant`)||n.includes(`Constant`))&&t.push(`.constants.ts`),(n.includes(`config`)||n.includes(`Config`))&&t.push(`.config.ts`),(n.includes(`atom`)||n.includes(`state`)||n.includes(`State`))&&t.push(`.atom.ts`),t.length===0&&t.push(`.utils.ts`,`.config.ts`,`.constants.ts`),t}function Mt(e){for(let t of[`.test.ts`,`.test.tsx`,`.spec.ts`,`.spec.tsx`])if(e.endsWith(t)){let n=t.endsWith(`.tsx`)?`.tsx`:`.ts`;return e.replace(t,n)}return e}const M={meta:{type:`problem`,docs:{description:`强制执行文件类型后缀规范,确保文件名明确表达其用途`},messages:{missingTypeSuffix:`文件 "{{fileName}}" 缺少类型后缀。除特殊文件外,所有文件应使用 xxx.yyy.ts 格式明确表达用途。建议: {{suggestions}}`,forbiddenSuffix:`文件 "{{fileName}}" 使用了禁止的后缀 ".{{suffix}}"。该后缀语义过于泛化,无法表达文件用途。请使用更具体的后缀,如 ".utils"、".helpers"、".service" 等。`},schema:[]},create(e){let t=e.filename,n=l.default.basename(t);if((et(e.settings?.platformNamingStrategy)?e.settings.platformNamingStrategy:C).shouldSkipTypeSuffix(n))return{};let r=Mt(n),i=At(r);if(i)return e.report({loc:{start:{line:1,column:0},end:{line:1,column:n.length}},messageId:`forbiddenSuffix`,data:{fileName:n,suffix:i}}),{};if(kt(r))return{};let a=jt(r);return e.report({loc:{start:{line:1,column:0},end:{line:1,column:n.length}},messageId:`missingTypeSuffix`,data:{fileName:n,suggestions:a.join(`, `)}}),{}}},Nt=[/\/src\/renderer\//];function Pt(e){let t=e.replace(/\\/g,`/`);return Nt.some(e=>e.test(t))}function Ft(e){if(!e.startsWith(`@longzai-intelligence/`))return!1;let t=e.split(`/`);if(t.length<2)return!1;let n=t[1];return n?n.endsWith(`-implementation`):!1}const N={meta:{type:`problem`,docs:{description:`禁止在 Electron renderer 进程中导入 Implementation 包`},messages:{implementationInRenderer:`禁止在 renderer 进程中导入 Implementation 包 "{{packageName}}"。Implementation 包包含 Node.js 特定代码,请在 main 进程中使用,或使用 Contract 包代替。`},schema:[]},create(e){let t=e.filename;return Pt(t)?{ImportDeclaration(t){let n=t.source.value;typeof n==`string`&&Ft(n)&&e.report({node:t,messageId:`implementationInRenderer`,data:{packageName:n}})}}:{}}};function It(e){return typeof e==`object`&&!!e&&`alias`in e&&typeof e.alias==`string`&&`pathPattern`in e&&typeof e.pathPattern==`string`}function Lt(e){return Array.isArray(e)&&e.every(It)}const P=[{alias:`@main`,pathPattern:`src/main`},{alias:`@preload`,pathPattern:`src/preload`},{alias:`@renderer`,pathPattern:`src/renderer/src`},{alias:`@shared`,pathPattern:`src/shared`}];function F(e,t){let n=e.replace(/\\/g,`/`);for(let e of t){let t=e.pathPattern.replace(/\\/g,`/`);if(n.includes(`/${t}/`)||n.endsWith(`/${t}`)||n.includes(`/${t}\\`))return e.alias}return null}function Rt(e,t,n){if(!t.startsWith(`.`))return null;let r=e.replace(/\\/g,`/`),i=r.lastIndexOf(`/`),a=i>0?r.substring(0,i):``;return F(l.default.resolve(a,t).replace(/\\/g,`/`),n)}function zt(e){return e.startsWith(`./`)||e.startsWith(`../`)}const I={meta:{type:`problem`,docs:{description:`禁止使用相对路径穿越不同包范围,强制使用别名导入`},messages:{noCrossPackageRelativeImport:`禁止使用相对路径跨包导入。当前文件位于 "{{currentPackage}}" 包,目标位于 "{{targetPackage}}" 包。请使用别名导入:{{targetPackage}}/...`},schema:[{type:`object`,properties:{packageBoundaries:{type:`array`,items:{type:`object`,properties:{alias:{type:`string`},pathPattern:{type:`string`}},required:[`alias`,`pathPattern`]}}},additionalProperties:!1}]},create(e){let t=e.filename,n=e.options[0],r=n&&typeof n==`object`?n:{},i=`packageBoundaries`in r&&Array.isArray(r.packageBoundaries)?r.packageBoundaries:P,a=Lt(i)?i:P,o=F(t,a);return o?{ImportDeclaration(n){let r=n.source.value;if(typeof r!=`string`||!zt(r))return;let i=Rt(t,r,a);i&&o!==i&&e.report({node:n,messageId:`noCrossPackageRelativeImport`,data:{currentPackage:o,targetPackage:i}})}}:{}}},L=[/\.test\.ts$/,/\.test\.tsx$/,/\.spec\.ts$/,/\.spec\.tsx$/],R=[`/node_modules/`,`/dist/`,`/out/`,`/.bun/`],Bt=[{segment:`/templates/`,type:`templates`},{segment:`/domains/`,type:`domains`},{segment:`/packages/`,type:`packages`},{segment:`/infrastructure/`,type:`infrastructure`}],Vt=[{segment:`/src/main/`,process:`main`},{segment:`/src/renderer/`,process:`renderer`},{segment:`/src/preload/`,process:`preload`},{segment:`/src/shared/`,process:`shared`}];function z(e){return e.replace(/\\/g,`/`)}function Ht(e){return L.some(t=>t.test(e))}function Ut(e){let t=z(e);return R.some(e=>t.includes(e))}function B(e){return e.isElectron&&e.electronProcess?`src/${e.electronProcess}/__tests__`:`src/__tests__`}function Wt(e,t){let n=z(e);return t.srcRoot?n.startsWith(`${t.srcRoot}/__tests__/`):!0}function Gt(e,t){let n=z(e),r=l.default.basename(e);if(!t.srcRoot)return`src/__tests__/${r}`;let i=n.indexOf(`/src/`);if(i===-1)return`${t.srcRoot}/__tests__/${r}`;let a=n.slice(i+5).split(`/`);if(a.length>1&&a.pop(),t.isElectron&&t.electronProcess){let e=a.indexOf(t.electronProcess);e!==-1&&a.splice(e,1)}let o=a.indexOf(`__tests__`);o!==-1&&a.splice(o,1);let s=a.join(`/`),c=B(t);return s?`${c}/${s}/${r}`:`${c}/${r}`}function Kt(e,t){let n=e.indexOf(t),r=e.slice(n+t.length).split(`/`),i=r.findIndex(e=>e===`src`);if(i!==-1)return e.slice(0,n+t.length)+r.slice(0,i+1).join(`/`);let a=t===`/domains/`&&r.length>=2?`${r[0]}/${r[1]}`:r[0];return a?e.slice(0,n+t.length+a.length)+`/src`:e.slice(0,n+t.length)+`src`}function qt(e){for(let t of Vt)if(e.includes(t.segment))return{electronProcess:t.process,srcRoot:e.slice(0,e.indexOf(t.segment))+t.segment.slice(0,-1)};return{srcRoot:``}}function Jt(e){return e.includes(`-desktop`)||e===`desktop`}function Yt(e){let t=z(e);for(let e of Bt)if(t.includes(e.segment))return{type:e.type,isElectron:!1,srcRoot:Kt(t,e.segment)};if(t.includes(`/database/`)){let e=t.indexOf(`/database/`);return{type:`database`,isElectron:!1,srcRoot:t.slice(0,e+10)+`src`}}if(!t.includes(`/apps/`))return{type:`unknown`,isElectron:!1,srcRoot:``};let n=t.indexOf(`/apps/`),r=t.slice(n+6).split(`/`)[0];if(!r)return{type:`unknown`,isElectron:!1,srcRoot:``};let i=t.slice(0,n+6+r.length)+`/src`;if(!Jt(r))return{type:`apps`,isElectron:!1,srcRoot:i};let a=qt(t);return{type:`apps`,isElectron:!0,electronProcess:a.electronProcess,srcRoot:a.srcRoot||i}}const V={meta:{type:`problem`,docs:{description:`强制测试文件放置在 src/__tests__ 目录下`},messages:{invalidTestFileLocation:`测试文件 "{{fileName}}" 必须放置在 {{expectedDir}} 目录下。当前路径: "{{currentPath}}"。建议路径: "{{suggestedPath}}"`},schema:[]},create(e){let t=e.filename,n=l.default.basename(t);if(!Ht(n)||Ut(t)||n.endsWith(`.d.ts`))return{};let r=Yt(t);if(r.type===`unknown`||Wt(t,r))return{};let i=B(r),a=Gt(t,r);return e.report({loc:{start:{line:1,column:0},end:{line:1,column:n.length}},messageId:`invalidTestFileLocation`,data:{fileName:n,expectedDir:i,currentPath:t,suggestedPath:a}}),{}}},Xt=[`**/vitest.setup.ts`,`**/jest.setup.ts`,`**/fixtures/**`,`**/helpers/**`,`**/mocks/**`,`**/__mocks__/**`,`**/*.d.ts`],Zt=[/\.test\.ts$/,/\.test\.tsx$/,/\.spec\.ts$/,/\.spec\.tsx$/];function Qt(e){return Zt.some(t=>t.test(e))}function $t(e,t){let n=t.replace(/[.+^${}()|[\]\\]/g,`\\$&`).replace(/\*\*/g,`{{DOUBLE_STAR}}`).replace(/\*/g,`[^/]*`).replace(/{{DOUBLE_STAR}}/g,`.*`);return RegExp(`^${n}$`).test(e)}function en(e,t){return t.some(t=>$t(e,t))}function tn(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function nn(e){if(typeof e!=`object`||!e)return!1;if(!(`allowPatterns`in e))return!0;let t=e.allowPatterns;return Array.isArray(t)&&tn(t)}const rn={meta:{type:`problem`,docs:{description:`禁止在 __tests__ 目录下放置非测试文件`},messages:{nonTestFileInTestsDirectory:`文件 "{{fileName}}" 位于 __tests__ 目录下但不是测试文件。测试目录应仅包含测试文件(*.test.ts, *.spec.ts)。如果是辅助文件,请移动到 src/test-helpers/ 或 src/testing/ 目录。`},schema:[{type:`object`,properties:{allowPatterns:{type:`array`,items:{type:`string`},description:`允许在 __tests__ 目录下的非测试文件 glob 模式`}},additionalProperties:!1}]},create(e){let t=[...Xt],n=e.options[0];nn(n)&&n.allowPatterns&&(t=[...Xt,...n.allowPatterns]);let r=e.filename,i=z(r),a=l.default.basename(r);return{Program(){i.includes(`/__tests__/`)&&(Qt(a)||en(i,t)||e.report({loc:{start:{line:1,column:0},end:{line:1,column:a.length}},messageId:`nonTestFileInTestsDirectory`,data:{fileName:a}}))}}}},an=[/\.test\.ts$/,/\.test\.tsx$/,/\.spec\.ts$/,/\.spec\.tsx$/],H=[`.ts`,`.tsx`],on=new Set([`node_modules`,`dist`,`out`,`.bun`,`.turbo`,`.cache`,`generated`]),sn=new WeakMap;function cn(e){return e.replace(/\\/g,`/`)}function ln(e,t){let n;try{n=u.default.readdirSync(e,{withFileTypes:!0})}catch{return}for(let r of n){let n=l.default.join(e,r.name);if(r.isDirectory()){if(on.has(r.name))continue;ln(n,t)}else r.isFile()&&t(n)}}function U(e){return L.some(t=>t.test(e))}function un(e){let t=cn(e);return R.some(e=>t.includes(e))}function dn(e){for(let t of an)if(t.test(e))return e.replace(t,``);return e}function fn(e){let t=cn(e),n=t.indexOf(`/__tests__/`);return n===-1?l.default.dirname(e):t.substring(0,n)}function pn(e,t){for(let n of H){let r=l.default.join(t,e+n);if(u.default.existsSync(r))return r}return null}function mn(e,t){let n=sn.get(e);if(n||(n=new Map,sn.set(e,n)),n.has(t))return n.get(t);let r=[];return ln(t,e=>r.push(e)),n.set(t,r),r}function hn(e,t,n,r){let i=l.default.dirname(t),a=[i,l.default.dirname(i)];for(let t of a){let n=pn(e,t);if(n)return n}let o=[n,i];for(let t of o){if(!u.default.existsSync(t))continue;let n=mn(r,t);for(let t of n){let n=l.default.basename(t);if(!U(n)){for(let r of H)if(n===e+r)return t}}}return null}function gn(e,t){let n=l.default.basename(e),r=dn(n),i=fn(e);if(hn(r,e,i,t))return{isMatch:!0,suggestion:null};let a=bn(i,e,t)[0];if(a){let e=l.default.basename(a,l.default.extname(a)),t=l.default.extname(n),r=n.includes(`.spec.`)?`.spec`:`.test`,i=t.replace(r,``);return{isMatch:!1,suggestion:e+r+i}}return{isMatch:!1,suggestion:null}}function _n(e){return U(e)||e===`index.ts`||e===`index.tsx`||e.endsWith(`.d.ts`)?!1:H.some(t=>e.endsWith(t))}function vn(e,t,n){if(u.default.existsSync(e))try{let r=u.default.readdirSync(e,{withFileTypes:!0});for(let i of r){if(!i.isFile())continue;let r=i.name;if(!_n(r))continue;let a=l.default.join(e,r);n.has(a)||(t.push(a),n.add(a))}}catch{}}function yn(e,t,n,r){if(!u.default.existsSync(e))return;let i=mn(t,e);for(let e of i)_n(l.default.basename(e))&&(r.has(e)||(n.push(e),r.add(e)))}function bn(e,t,n){let r=l.default.dirname(t),i=l.default.dirname(r),a=[],o=new Set,s=[r,i];for(let e of s)vn(e,a,o);if(a.length===0){let t=[e,r];for(let e of t)yn(e,n,a,o)}return a}const xn={meta:{type:`problem`,docs:{description:`确保测试文件名与被测试的源文件名保持一致`},messages:{testFileNotMatchSource:`测试文件 "{{testFileName}}" 未找到匹配的源文件。测试文件名应与源文件名保持一致。{{suggestion}}`},schema:[]},create(e){let t=e.filename,n=l.default.basename(t);if(!U(n)||un(t)||n.endsWith(`.d.ts`))return{};let r=gn(t,e);if(!r.isMatch){let t=r.suggestion?`建议重命名为 "${r.suggestion}"`:`请确保测试文件名与源文件名匹配(如 user.service.ts -> user.service.test.ts)`;e.report({loc:{start:{line:1,column:0},end:{line:1,column:n.length}},messageId:`testFileNotMatchSource`,data:{testFileName:n,suggestion:t}})}return{}}};function Sn(e){if(!e||typeof e!=`object`)return!1;let t=e;if(!(`type`in t)||t.type!==d.AST_NODE_TYPES.MemberExpression||!(`object`in t)||!t.object||!(`property`in t)||!t.property)return!1;let n=t.object,r=t.property;return!n||typeof n!=`object`||!r||typeof r!=`object`?!1:`type`in n&&n.type===d.AST_NODE_TYPES.Identifier&&`name`in n&&n.name===`window`&&`type`in r&&r.type===d.AST_NODE_TYPES.Identifier&&`name`in r&&r.name===`electron`}const Cn={meta:{type:`problem`,docs:{description:`禁止在 Preload 中直接暴露 @electron-toolkit/preload 的 electronAPI`},messages:{noElectronApiImport:`禁止导入 @electron-toolkit/preload 的 electronAPI。`,noExposeElectronApi:`禁止执行 contextBridge.exposeInMainWorld("electron", electronAPI)。`,noWindowElectronApi:`禁止执行 window.electron = electronAPI。`},schema:[]},create(e){return{ImportDeclaration(t){if(t.source.value===`@electron-toolkit/preload`)for(let n of t.specifiers)n.type===`ImportSpecifier`&&n.imported.type===`Identifier`&&n.imported.name===`electronAPI`&&e.report({node:n,messageId:`noElectronApiImport`})},CallExpression(t){if(t.callee.type!==`MemberExpression`||t.callee.property.type!==`Identifier`||t.callee.property.name!==`exposeInMainWorld`||t.arguments.length<2)return;let[n,r]=t.arguments;n?.type===`Literal`&&n.value===`electron`&&r?.type===`Identifier`&&r.name===`electronAPI`&&e.report({node:t,messageId:`noExposeElectronApi`})},AssignmentExpression(t){t.left.type===`MemberExpression`&&Sn(t.left)&&t.right.type===`Identifier`&&t.right.name===`electronAPI`&&e.report({node:t,messageId:`noWindowElectronApi`})}}}};function wn(e){let t=e.replace(/\\/g,`/`);return t.includes(`/src/preload/`)&&!t.includes(`/__tests__/`)}function W(e){return typeof e==`object`&&!!e}function Tn(e){if(!W(e))return null;let t=e.key;return W(t)?typeof t.name==`string`?t.name:typeof t.value==`string`?t.value:null:null}function En(e){return!W(e)||!Array.isArray(e.properties)?!1:e.properties.some(e=>{if(!W(e)||e.type!==`Property`)return!1;let t=Tn(e);return t===`on`||t===`send`||t===`invoke`})}const Dn={meta:{type:`problem`,docs:{description:`禁止在 Preload 暴露通用 ipc 桥接对象`},messages:{noIpcBridge:`禁止暴露通用 ipc 桥接对象(on/send/invoke)。请使用领域 API。`},schema:[]},create(e){return wn(e.filename)?{Property(t){Tn(t)===`ipc`&&W(t.value)&&t.value.type===`ObjectExpression`&&En(t.value)&&e.report({node:t,messageId:`noIpcBridge`})}}:{}}};function On(e){let t=e.replace(/\\/g,`/`);return t.includes(`/src/preload/`)&&!t.includes(`/__tests__/`)&&!t.includes(`/src/preload/utils/`)}const kn={meta:{type:`problem`,docs:{description:`禁止在 Preload 业务代码中直接调用 ipcRenderer`},messages:{noDirectCall:`禁止直接调用 ipcRenderer。请通过 createTypedAPI 或 invoke 封装。`},schema:[]},create(e){return On(e.filename)?{CallExpression(t){t.callee.type===`MemberExpression`&&t.callee.object.type===`Identifier`&&t.callee.object.name===`ipcRenderer`&&e.report({node:t,messageId:`noDirectCall`})}}:{}}};function G(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`Identifier`&&`name`in e&&typeof e.name==`string`}function An(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`Property`&&`value`in e&&e.value!==null&&typeof e.value==`object`&&G(e.value)}function jn(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`RestElement`&&`argument`in e&&e.argument!==null&&typeof e.argument==`object`&&G(e.argument)}function Mn(e){let t=[];if(!e||typeof e!=`object`)return t;if(G(e)&&t.push(e.name),`type`in e&&e.type===`ObjectPattern`&&`properties`in e&&Array.isArray(e.properties))for(let n of e.properties)!n||typeof n!=`object`||(An(n)?t.push(n.value.name):jn(n)&&t.push(n.argument.name));if(`type`in e&&e.type===`ArrayPattern`&&`elements`in e&&Array.isArray(e.elements))for(let n of e.elements)G(n)&&t.push(n.name);return t}function Nn(e){return`declaration`in e}function Pn(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`VariableDeclaration`&&`kind`in e&&`declarations`in e&&Array.isArray(e.declarations)}function Fn(e){if(typeof e!=`object`||!e||!(`range`in e))return!1;let t=e.range;return Array.isArray(t)&&t.length===2}function In(e,t,n){return r=>{let i=t.declaration;if(!i||!Fn(i)||!e.getTokenBefore(i))return null;let a=e.getText(i),o=n.join(`, `),s=e.getText(t).match(/^(\s*)/),c=s?s[1]:``,l=`${a}`,u=`${c}export { ${o} };`;return r.replaceText(t,`${l}\n${u}`)}}const Ln={meta:{type:`suggestion`,docs:{description:`将 export const/let/var 拆分为独立的声明和导出语句,以便 JSDoc 正确插入`,recommended:!0},fixable:`code`,schema:[],messages:{preferSplitExport:"应将 `export {{kind}} {{names}}` 拆分为独立的声明和导出语句,以便 JSDoc 正确插入注释"}},create(e){let t=e.sourceCode;return{ExportNamedDeclaration(n){if(!Nn(n)||!n.declaration||!Pn(n.declaration))return;let r=n.declaration;if(r.kind!==`const`&&r.kind!==`let`&&r.kind!==`var`)return;let i=r.declarations;if(i.length===0)return;let a=[];i.forEach(e=>{a.push(...Mn(e.id))}),a.length!==0&&e.report({node:n,messageId:`preferSplitExport`,data:{kind:r.kind,names:a.join(`, `)},fix:In(t,n,a)})}}}};function Rn(e){return typeof e==`object`&&!!e&&`name`in e&&typeof e.name==`string`&&(!(`severity`in e)||e.severity===`error`||e.severity===`warn`||e.severity===void 0)&&(!(`description`in e)||typeof e.description==`string`||e.description===void 0)}function zn(e){return Array.isArray(e)&&e.every(Rn)}function Bn(e){if(typeof e!=`object`||!e)return!1;if(!(`directories`in e))return!0;let t=e.directories;return Array.isArray(t)&&zn(t)}const Vn=[{name:`apps`,severity:`error`,description:`应用层目录`},{name:`domains`,severity:`error`,description:`领域层目录`},{name:`packages`,severity:`error`,description:`技术层目录`},{name:`infrastructure`,severity:`warn`,description:`基础设施层目录`},{name:`templates`,severity:`warn`,description:`模板层目录`},{name:`docs`,severity:`warn`,description:`文档层目录`}];function Hn(e,t){return(0,u.existsSync)((0,l.join)(e,t,`README.md`))}function Un(e){return e.cwd}const Wn=new WeakMap;function Gn(e){let t=Wn.get(e);return t||(t=new Set,Wn.set(e,t)),t}const Kn={meta:{type:`problem`,docs:{description:`检查分层目录是否包含 README.md 文件`},messages:{missingReadmeError:`分层目录 "{{directory}}" ({{description}}) 缺少 README.md 文件。分层目录必须包含 README.md 文件,阐明该层职责。`,missingReadmeWarn:`分层目录 "{{directory}}" ({{description}}) 建议添加 README.md 文件,阐明该层职责。`},schema:[{type:`object`,properties:{directories:{type:`array`,items:{type:`object`,properties:{name:{type:`string`},severity:{type:`string`,enum:[`error`,`warn`]},description:{type:`string`}},required:[`name`]}}},additionalProperties:!1}]},create(e){let t=Un(e),n=Gn(e),r=Vn,i=e.options[0];return Bn(i)&&i.directories&&(r=i.directories),{Program(i){if(!n.has(t)){n.add(t);for(let n of r){let r=n.name;if((0,u.existsSync)((0,l.join)(t,r))&&!Hn(t,r)){let t=(n.severity||`error`)===`error`?`missingReadmeError`:`missingReadmeWarn`;e.report({node:i,messageId:t,data:{directory:r,description:n.description||r}})}}}}}}},qn=[{suffix:`.service.drizzle.ts`,classSuffix:`Service`,isInterface:!1,isPrefix:!1},{suffix:`.service.memory.ts`,classSuffix:`Service`,isInterface:!1,isPrefix:!1},{suffix:`.service.ts`,classSuffix:`Service`,isInterface:!1,isPrefix:!1},{suffix:`.controller.ts`,classSuffix:`Controller`,isInterface:!1,isPrefix:!1},{suffix:`.module.ts`,classSuffix:`Module`,isInterface:!1,isPrefix:!1},{suffix:`.repository.drizzle.ts`,classSuffix:`Repository`,isInterface:!1,isPrefix:!1},{suffix:`.repository.memory.ts`,classSuffix:`Repository`,isInterface:!1,isPrefix:!1},{suffix:`.repository.interface.ts`,classSuffix:`Repository`,isInterface:!0,isPrefix:!0},{suffix:`.repository.ts`,classSuffix:`Repository`,isInterface:!1,isPrefix:!1},{suffix:`.entity.ts`,classSuffix:`Entity`,isInterface:!1,isPrefix:!1},{suffix:`.orm-entity.ts`,classSuffix:`OrmEntity`,isInterface:!1,isPrefix:!1},{suffix:`.dto.ts`,classSuffix:`DTO`,isInterface:!1,isPrefix:!1},{suffix:`.port.interface.ts`,classSuffix:`Port`,isInterface:!0,isPrefix:!0},{suffix:`.interface.ts`,classSuffix:``,isInterface:!0,isPrefix:!0},{suffix:`.port.ts`,classSuffix:`Port`,isInterface:!0,isPrefix:!1},{suffix:`.port.adapter.ts`,classSuffix:`PortAdapter`,isInterface:!1,isPrefix:!1},{suffix:`.adapter.ts`,classSuffix:`Adapter`,isInterface:!1,isPrefix:!1},{suffix:`.events.ts`,classSuffix:`Event`,isInterface:!1,isPrefix:!1},{suffix:`.mapper.ts`,classSuffix:`Mapper`,isInterface:!1,isPrefix:!1},{suffix:`.vo.ts`,classSuffix:`VO`,isInterface:!1,isPrefix:!1},{suffix:`.usecase.ts`,classSuffix:`UseCase`,isInterface:!1,isPrefix:!1},{suffix:`.errors.ts`,classSuffix:`Error`,isInterface:!1,isPrefix:!1}];function Jn(e){for(let t of qn)if(e.endsWith(t.suffix))return t;return null}function Yn(e,t){if(t.isPrefix&&t.isInterface){if(t.classSuffix){let n=t.classSuffix;return e.startsWith(`I`)&&e.endsWith(n)&&e.length>1+n.length}return e.startsWith(`I`)&&e.length>1}return t.isPrefix?e.startsWith(`I`)&&e.length>1:e.endsWith(t.classSuffix)&&e.length>t.classSuffix.length}function Xn(e){return e.isPrefix&&e.isInterface?e.classSuffix?`I${e.classSuffix}(如 IUser${e.classSuffix})`:`I 前缀(如 IUser)`:e.isPrefix?`I 前缀(如 IUser)`:`${e.classSuffix} 后缀`}function Zn(e,t,n,r){if(!(0,c.hasIdWithName)(e))return;let i=e.id.name;n.isInterface||Yn(i,n)||t.report({node:e,messageId:`invalidClassName`,data:{className:i,fileName:r,expectedFormat:Xn(n)}})}function Qn(e,t,n,r){if(!n.isInterface||!(0,c.hasIdWithName)(e))return;let i=e.id.name;Yn(i,n)||t.report({node:e,messageId:`invalidInterfaceName`,data:{interfaceName:i,fileName:r,expectedFormat:Xn(n)}})}function $n(e){let t=e.filename,n=l.default.basename(t);if(n.endsWith(`.test.ts`)||n.endsWith(`.spec.ts`))return{};let r=Jn(n);return r?{ClassDeclaration(t){Zn(t,e,r,n)},TSInterfaceDeclaration(t){Qn(t,e,r,n)}}:{}}const er={meta:{type:`problem`,docs:{description:`强制执行类名与文件类型后缀的一致性`},messages:{invalidClassName:`类名 "{{className}}" 不符合命名规范。文件 "{{fileName}}" 中的类应使用 {{expectedFormat}}`,invalidInterfaceName:`接口名 "{{interfaceName}}" 不符合命名规范。文件 "{{fileName}}" 中的接口应使用 {{expectedFormat}}`},schema:[]},create:$n},tr=[`types.ts`,`types.d.ts`],nr=[`.port.interface.ts`,`.repository.interface.ts`,`.types.ts`,`.types.d.ts`,`.events.ts`];function rr(e,t){return(0,c.hasIPrefix)(e)?!1:t.endsWith(`.dto.ts`)?(0,c.isValidDtoNameUpperCase)(e):!0}function ir(e){return e.endsWith(`.dto.ts`)?`DTO 后缀(如 UserDTO),禁止 I 前缀`:`PascalCase(如 User、UserRepository),禁止 I 前缀`}function ar(e){if(tr.includes(e))return!0;for(let t of nr)if(e.endsWith(t))return!0;return!1}function or(e){return e.endsWith(`.port.ts`)?e.replace(`.port.ts`,`.port.interface.ts`):e.endsWith(`.repository.ts`)?e.replace(`.repository.ts`,`.repository.interface.ts`):e.replace(`.ts`,`.interface.ts`)}function sr(e,t){return t.endsWith(`Dto`)?(0,c.createDtoSuffixFixer)(e,t,!0):null}function cr(e,t,n,r){if(rr(n,r))return;if((0,c.hasIPrefix)(n)){e.report({node:t,messageId:`invalidIPrefix`,data:{interfaceName:n,suggestedName:n.substring(1)},fix:(0,c.createRemoveIPrefixFixer)(t,n)});return}let i=sr(t,n);i?e.report({node:t,messageId:`invalidDtoSuffix`,data:{interfaceName:n},fix:i}):e.report({node:t,messageId:`invalidInterfaceName`,data:{interfaceName:n,expectedFormat:ir(r)}})}function lr(e,t,n,r,i){i||r.endsWith(`.dto.ts`)||e.report({node:t,messageId:`invalidFileName`,data:{fileName:r,interfaceName:n,expectedFileName:or(r)}})}function ur(e,t,n,r){if(!(0,c.hasIdWithNameAndRange)(t))return;let i=t.id.name;cr(e,t,i,n),lr(e,t,i,n,r)}function dr(e){let t=e.filename,n=l.default.basename(t);if(n.endsWith(`.test.ts`)||n.endsWith(`.spec.ts`)||ar(n))return{};let r=n.endsWith(`.interface.ts`);return{TSInterfaceDeclaration(t){ur(e,t,n,r)}}}const fr={meta:{type:`problem`,docs:{description:`强制执行接口命名规范(禁止 I 前缀,使用 PascalCase)和文件命名规范(xxx.interface.ts)`},messages:{invalidIPrefix:`接口名 "{{interfaceName}}" 使用了 I 前缀。现代 TypeScript 不推荐使用匈牙利命名法,建议使用 "{{suggestedName}}"`,invalidInterfaceName:`接口名 "{{interfaceName}}" 不符合命名规范。接口名应使用 {{expectedFormat}}`,invalidDtoSuffix:`接口名 "{{interfaceName}}" 后缀应使用 DTO(全大写)而非 Dto(驼峰式)`,invalidFileName:`包含接口 "{{interfaceName}}" 的文件 "{{fileName}}" 应命名为 "{{expectedFileName}}"`},schema:[],fixable:`code`},create:dr},pr=[`.types.ts`,`.types.d.ts`];function mr(e){return pr.some(t=>e.endsWith(t))}function hr(e){let t=e.filename,n=l.default.basename(t);return n.endsWith(`.test.ts`)||n.endsWith(`.spec.ts`)||!mr(n)?{}:{TSInterfaceDeclaration(t){if(!(0,c.hasIdWithNameAndRange)(t))return;let n=t.id.name;(0,c.hasIPrefix)(n)&&e.report({node:t,messageId:`invalidIPrefix`,data:{interfaceName:n,suggestedName:n.substring(1)},fix:(0,c.createRemoveIPrefixFixer)(t,n)})}}}const gr={meta:{type:`problem`,docs:{description:`强制执行 types 文件中的接口命名规范(禁止 I 前缀)`},messages:{invalidIPrefix:`类型文件中的接口名 "{{interfaceName}}" 使用了 I 前缀。现代 TypeScript 不推荐使用匈牙利命名法,建议使用 "{{suggestedName}}"`},schema:[],fixable:`code`},create:hr};function _r(e){return e.endsWith(`.dto.ts`)}function vr(e){return e.endsWith(`DTO`)}function yr(e){let t=e.filename,n=l.default.basename(t);return n.endsWith(`.test.ts`)||n.endsWith(`.spec.ts`)||!_r(n)?{}:{TSInterfaceDeclaration(t){if(!(0,c.hasIdWithNameAndRange)(t))return;let n=t.id.name;vr(n)?e.report({node:t,messageId:`invalidDtoSuffix`,data:{interfaceName:n},fix:(0,c.createDtoSuffixFixer)(t,n,!1)}):(0,c.isValidDtoNameCamelCase)(n)||e.report({node:t,messageId:`missingDtoSuffix`,data:{interfaceName:n}})}}}const br={meta:{type:`problem`,docs:{description:`强制执行 DTO 文件中的接口命名规范(Dto 后缀,驼峰式)`},messages:{invalidDtoSuffix:`接口名 "{{interfaceName}}" 后缀应使用 Dto(驼峰式)而非 DTO(全大写)`,missingDtoSuffix:`DTO 文件中的接口名 "{{interfaceName}}" 应以 Dto 结尾(如 UserResponseDto)`},schema:[],fixable:`code`},create:yr},K=`@longzai-intelligence/config/tsup`,xr=`definePackageConfig`,Sr=[`defineConfig`];function Cr(e){return{ImportDeclaration(t){if(!(0,c.isImportDeclaration)(t))return;let n=t.source.value;for(let r of t.specifiers){if(!(0,c.isImportSpecifier)(r))continue;let i=r.imported.name;if(Sr.includes(i)){if(n===`tsup`){e.report({node:t,messageId:`forbiddenTsupImport`,data:{importedName:i,correctExportName:xr,configPackage:K}});continue}n===K&&e.report({node:t,messageId:`forbiddenConfigImport`,data:{importedName:i,correctExportName:xr,configPackage:K}})}}}}}const wr={meta:{type:`problem`,docs:{description:`强制执行 tsup.config.ts 文件中的配置导入规范,必须使用 definePackageConfig`},messages:{forbiddenTsupImport:`禁止从 tsup 包导入 {{importedName}}。应使用 {{correctExportName}} 从 {{configPackage}} 导入`,forbiddenConfigImport:`禁止从 {{configPackage}} 导入 {{importedName}}。应使用 {{correctExportName}}`},schema:[]},create:Cr},q=`@longzai-intelligence/tsdown-config`,Tr=[`defineDomainImplementationConfig`,`defineDomainContractConfig`,`defineSharedKernelConfig`,`defineReactComponentsConfig`,`defineConfigPackageConfig`,`definePackageConfig`],Er=[`defineConfig`];function Dr(e){return{ImportDeclaration(t){if(!(0,c.isImportDeclaration)(t))return;let n=t.source.value;for(let r of t.specifiers){if(!(0,c.isImportSpecifier)(r))continue;let i=r.imported.name;if(Er.includes(i)){if(n===`tsdown`){e.report({node:t,messageId:`forbiddenTsdownImport`,data:{importedName:i,presetNames:Tr.join(`、`),configPackage:q}});continue}n===q&&e.report({node:t,messageId:`forbiddenConfigImport`,data:{importedName:i,presetNames:Tr.join(`、`),configPackage:q}})}}}}}const Or={meta:{type:`problem`,docs:{description:`强制执行 tsdown.config.ts 文件中的配置导入规范,必须使用预设函数`},messages:{forbiddenTsdownImport:`禁止从 tsdown 包导入 {{importedName}}。应使用预设函数({{presetNames}})从 {{configPackage}} 导入`,forbiddenConfigImport:`禁止从 {{configPackage}} 导入 {{importedName}}。应使用预设函数({{presetNames}})`},schema:[]},create:Dr},J=[`@longzai-intelligence/config/vitest`,`@longzai-intelligence/vitest-config`],Y=[`createBaseVitestConfig`,`createDomainVitestConfig`,`createDomainUIVitestConfig`,`createPackageVitestConfig`,`createTypeOnlyVitestConfig`,`createDesktopVitestConfig`,`createWebVitestConfig`,`defineVitestConfig`,`defineDomainVitestConfig`,`defineDomainUIVitestConfig`,`definePackageVitestConfig`,`defineTypeOnlyVitestConfig`,`defineDesktopVitestConfig`,`defineWebVitestConfig`],kr=[`defineConfig`],Ar=[`infrastructure/configs/vitest/vitest.config.ts`];function jr(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`ExportDefaultDeclaration`&&`declaration`in e&&e.declaration!==null&&typeof e.declaration==`object`}function Mr(e){return e.endsWith(`vitest.config.ts`)}function Nr(e,t,n){if(!(0,c.isImportDeclaration)(e))return;let r=e.source.value;for(let t of e.specifiers){if(!(0,c.isImportSpecifier)(t))continue;let i=t.imported.name;if(r===`vitest`&&kr.includes(i)){n.hasForbiddenImport=!0,n.forbiddenImportNode=e,n.forbiddenImportName=i;continue}J.includes(r)&&Y.includes(i)&&(n.hasValidImport=!0)}}function Pr(e,t){return!t.hasForbiddenImport||!t.forbiddenImportNode?!1:(e.report({node:t.forbiddenImportNode,messageId:`forbiddenVitestImport`,data:{importedName:t.forbiddenImportName,configPackages:J.join(` 或 `),allowedExports:Y.join(`, `)}}),!0)}function Fr(e,t,n){if(!(0,c.isCallExpressionNode)(e))return!1;let r=e.callee.name;return typeof r==`string`&&!Y.includes(r)&&!n.hasValidImport?(t.report({node:e,messageId:`invalidConfigFunction`,data:{configPackages:J.join(` 或 `),allowedExports:Y.join(`, `)}}),!0):!1}function Ir(e,t,n){return(0,c.isObjectExpressionNode)(e)?n.hasValidImport?!1:(t.report({node:e,messageId:`invalidConfigObject`,data:{configPackages:J.join(` 或 `),allowedExports:Y.join(`, `)}}),!0):!1}function Lr(e,t,n){if(!jr(e))return;n.hasExportDefault=!0;let r=e.declaration;Pr(t,n)||Fr(r,t,n)||Ir(r,t,n)}function Rr(e,t){if(!t.hasExportDefault){let t=e.sourceCode.ast;e.report({node:t,messageId:`missingConfigImport`,data:{configPackages:J.join(` 或 `),allowedExports:Y.join(`, `)}})}}function zr(e){let t=e.filename;if(!Mr(t)||(0,c.isInExcludedPath)(t,Ar))return{};let n={hasValidImport:!1,hasForbiddenImport:!1,hasExportDefault:!1,forbiddenImportNode:null,forbiddenImportName:``};return{ImportDeclaration(t){Nr(t,e,n)},ExportDefaultDeclaration(t){Lr(t,e,n)},"Program:exit"(){Rr(e,n)}}}const Br={meta:{type:`problem`,docs:{description:`强制执行 vitest.config.ts 文件中的配置导入规范,必须使用共享配置函数`},messages:{forbiddenVitestImport:`禁止从 vitest 包导入 {{importedName}}。应使用共享配置函数({{allowedExports}})从 {{configPackages}} 导入`,invalidConfigFunction:`必须使用共享配置函数({{allowedExports}})从 {{configPackages}} 导入`,missingConfigImport:`vitest.config.ts 必须使用共享配置函数({{allowedExports}})从 {{configPackages}} 导入`},schema:[]},create:zr},X=`@longzai-intelligence/config/eslint`,Z=[`createBaseConfig`,`createLibraryConfig`,`createDomainConfig`,`createReactConfig`,`createElectronConfig`,`createNextConfig`,`createArchitectureConfig`,`createServerConfig`,`createNestConfig`,`createHonoConfig`],Vr=[`baseConfig`,`libraryConfig`,`domainConfig`,`reactConfig`,`electronConfig`,`nextConfig`,`architectureConfig`,`serverConfig`,`nestConfig`,`honoConfig`,`base`,`library`,`domain`,`react`,`electron`,`next`,`architecture`,`server`,`nest`,`hono`];function Hr(e,t){e.report({node:t,messageId:`forbiddenDefaultImport`,data:{configPackage:X,allowedFunctions:Z.join(`、`)}})}function Ur(e,t){e.report({node:t,messageId:`forbiddenNamespaceImport`,data:{configPackage:X,allowedFunctions:Z.join(`、`)}})}function Wr(e,t,n){e.report({node:t,messageId:`forbiddenConfigImport`,data:{importedName:n,allowedFunctions:Z.join(`、`)}})}function Gr(e,t){e.report({node:t,messageId:`missingCreateFunction`,data:{configPackage:X,allowedFunctions:Z.join(`、`)}})}function Kr(e,t){if(!(0,c.isImportDeclaration)(t)||t.source.value!==X)return;let n=[],r=[],i=!1;for(let a of t.specifiers)if((0,c.isImportSpecifier)(a)){if((0,c.isDefaultImport)(a)){Hr(e,t),i=!0;continue}if(a.type===`ImportNamespaceSpecifier`){Ur(e,t),i=!0;continue}Vr.includes(a.imported.name)?r.push(a):Z.includes(a.imported.name)&&n.push(a)}if(!i){for(let n of r)Wr(e,t,n.imported.name);r.length===0&&n.length===0&&(t.specifiers.some(e=>(0,c.isImportSpecifier)(e)&&e.type===`ImportSpecifier`&&!Z.includes(e.imported.name)&&!Vr.includes(e.imported.name))||Gr(e,t))}}function qr(e){return{ImportDeclaration(t){Kr(e,t)}}}const Jr={meta:{type:`problem`,docs:{description:`强制执行 eslint.config.ts 文件中的配置导入规范,必须使用 createXxxConfig 函数`},messages:{forbiddenDefaultImport:`禁止从 {{configPackage}} 使用默认导入。应使用具名导入 {{allowedFunctions}} 等配置创建函数`,forbiddenNamespaceImport:`禁止从 {{configPackage}} 使用命名空间导入。应使用具名导入 {{allowedFunctions}} 等配置创建函数`,forbiddenConfigImport:`禁止从配置包导入 {{importedName}}。应使用 {{allowedFunctions}} 等配置创建函数`,missingCreateFunction:`必须从 {{configPackage}} 导入至少一个配置创建函数(如 {{allowedFunctions}})`},schema:[]},create:qr},Yr=[`./tsconfig/app.json`,`./tsconfig/node.json`,`./tsconfig/test.json`],Xr=[`app.json`,`node.json`,`test.json`,`build.json`];function Zr(e){return typeof e==`object`&&!!e&&`path`in e&&typeof e.path==`string`}function Qr(e){return Array.isArray(e)&&e.every(Zr)}function $r(e){return!(typeof e!=`object`||!e)}function ei(e){try{let t=(0,u.readFileSync)(e,`utf-8`);return JSON.parse(t)}catch{return null}}function ti(e){let t=e.map(e=>e.path);return Yr.filter(e=>!t.includes(e))}function ni(e){return e.map(e=>e.path).filter(e=>!Yr.includes(e))}const ri=new WeakMap;function ii(e,t){let n=ri.get(e);if(n||(n=new Map,ri.set(e,n)),n.has(t))return n.get(t);let r=(0,u.existsSync)(t),i={hasDir:r,missingFiles:r?ai(t):[]};return n.set(t,i),i}function ai(e){return Xr.filter(t=>!(0,u.existsSync)((0,l.join)(e,t)))}function oi(e,t,n){if(!n.references||!Qr(n.references)){e.report({node:t,messageId:`missingReferences`});return}let r=ti(n.references);r.length>0&&e.report({node:t,messageId:`missingRequiredReference`,data:{missingPath:r[0]}});let i=ni(n.references);for(let n of i)e.report({node:t,messageId:`extraReference`,data:{extraPath:n}})}function si(e,t,n){return n.files===void 0?!0:Array.isArray(n.files)?n.files.length===0?!0:(e.report({node:t,messageId:`filesMustBeEmpty`}),!1):(e.report({node:t,messageId:`filesMustBeArray`}),!1)}const ci={meta:{type:`problem`,docs:{description:`检查 tsconfig.json 是否正确使用 references 配置`},messages:{missingReferences:`tsconfig.json 必须使用 references 配置,采用目录收拢多配置模式。请添加 references 字段,包含 app.json、node.json、test.json 三个配置。`,missingRequiredReference:`tsconfig.json 的 references 缺少必需的配置: "{{missingPath}}"。references 必须包含 ./tsconfig/app.json、./tsconfig/node.json、./tsconfig/test.json。`,filesMustBeEmpty:`tsconfig.json 使用 references 时,files 必须为空数组 "[]"。请将 files 设置为空数组或移除 files 字段。`,filesMustBeArray:`tsconfig.json 使用 references 时,files 必须为数组类型。请将 files 设置为空数组 "[]"。`,missingTsconfigDirectory:`缺少 tsconfig/ 目录。请创建 tsconfig/ 目录并添加 app.json、node.json、test.json、build.json 配置文件。`,missingConfigFile:`tsconfig/ 目录缺少必需的配置文件: {{missingFiles}}。必需的配置文件包括: app.json、node.json、test.json、build.json。`,extraReference:`tsconfig.json 的 references 包含非必需的配置: "{{extraPath}}"。references 应仅包含 ./tsconfig/app.json、./tsconfig/node.json、./tsconfig/test.json。`},schema:[]},create(e){let t=e.filename;if(!t.endsWith(`tsconfig.json`)||t.includes(`tsconfig/`))return{};let n=(0,l.join)((0,l.dirname)(t),`tsconfig`);return{Program(r){let i=ei(t);if(!$r(i))return;let a=ii(e,n);if(!a.hasDir){e.report({node:r,messageId:`missingTsconfigDirectory`});return}if(a.missingFiles.length>0){e.report({node:r,messageId:`missingConfigFile`,data:{missingFiles:a.missingFiles.join(`, `)}});return}si(e,r,i)&&oi(e,r,i)}}}};function li(e){let t=e.replace(/\\/g,`/`);return t.includes(`/src/preload/`)&&!t.includes(`/__tests__/`)}const ui={meta:{type:`problem`,docs:{description:`禁止使用字符串字面量作为 IPC 通道名`},messages:{noStringLiteral:`禁止使用字符串字面量作为 IPC 通道名。请使用通道常量。`},schema:[]},create(e){return li(e.filename)?{CallExpression(t){if(t.callee.type!==`Identifier`||t.callee.name!==`invoke`||t.arguments.length===0)return;let n=t.arguments[0];n&&n.type===`Literal`&&typeof n.value==`string`&&e.report({node:n,messageId:`noStringLiteral`})},ObjectExpression(t){if(t.parent?.type===`CallExpression`&&t.parent.callee.type===`Identifier`&&t.parent.callee.name===`createTypedAPI`)for(let n of t.properties)n.type===`Property`&&n.value.type===`Literal`&&typeof n.value.value==`string`&&e.report({node:n.value,messageId:`noStringLiteral`})}}:{}}};function di(e){let t=e.replace(/\\/g,`/`);return t.endsWith(`/src/preload/index.ts`)&&!t.includes(`/__tests__/`)}function fi(e){let t=e.parent;for(;t;){if(t.type===`CallExpression`&&t.callee.type===`Identifier`&&t.callee.name===`exposeSafeAPI`)return!0;t=t.parent}return!1}const pi={meta:{type:`problem`,docs:{description:`要求使用 exposeSafeAPI 进行 API 暴露`},messages:{requireExposeSafeApi:`请使用 exposeSafeAPI 进行 API 暴露,而非直接调用 contextBridge.exposeInMainWorld。`},schema:[]},create(e){return di(e.filename)?{CallExpression(t){t.callee.type===`MemberExpression`&&t.callee.object.type===`Identifier`&&t.callee.object.name===`contextBridge`&&t.callee.property.type===`Identifier`&&t.callee.property.name===`exposeInMainWorld`&&(fi(t)||e.report({node:t,messageId:`requireExposeSafeApi`}))}}:{}}};function mi(e){let t=e.replace(/\\/g,`/`);return t.includes(`/src/preload/utils/`)&&!t.includes(`/__tests__/`)}function hi(e){return e.startsWith(`createTyped`)}const gi={meta:{type:`problem`,docs:{description:`禁止自定义 IPC 工具函数`},messages:{noCustomIPC:`禁止自定义 IPC 工具函数。请使用 @longzai-intelligence/electron/preload 提供的标准函数。`},schema:[]},create(e){return mi(e.filename)?{FunctionDeclaration(t){t.id&&hi(t.id.name)&&e.report({node:t,messageId:`noCustomIPC`})},VariableDeclaration(t){for(let n of t.declarations){if(n.id.type!==`Identifier`||!hi(n.id.name))continue;let r=n.init;r&&(r.type===`FunctionExpression`||r.type===`ArrowFunctionExpression`)&&e.report({node:t,messageId:`noCustomIPC`})}}}:{}}},_i=new Set([`unwrap`,`unwrapIPCResult`]);function vi(e){let t=e.replace(/\\/g,`/`);return t.includes(`/src/renderer/`)&&!t.includes(`/__tests__/`)&&!t.endsWith(`.test.ts`)&&!t.endsWith(`.spec.ts`)}function yi(e){if(e.type!==`CallExpression`)return!1;let{callee:t}=e;if(t.type!==`MemberExpression`)return!1;let{object:n}=t;return n.type===`MemberExpression`?n.object.type===`Identifier`&&n.object.name===`window`:!1}function bi(e){let t=e.parent;for(;t;){if(t.type===`CallExpression`&&t.callee.type===`Identifier`&&_i.has(t.callee.name))return!0;if(t.type===`CallExpression`)break;t=t.parent}return!1}const xi={meta:{type:`problem`,docs:{description:`渲染层调用 IPC API 时必须使用 unwrap 解包结果`},messages:{requireUnwrap:`渲染层调用 IPC API 时必须使用 unwrap 或 unwrapIPCResult 解包结果。`},schema:[]},create(e){return vi(e.filename)?{CallExpression(t){yi(t)&&(bi(t)||e.report({node:t,messageId:`requireUnwrap`}))}}:{}}};function Si(e){return e.endsWith(`Class`)}function Ci(e,t){if(typeof t!=`object`||!t||!(`imported`in t)||!(`local`in t)||t.local===null||typeof t.local!=`object`||!(`name`in t.local)||typeof t.local.name!=`string`||!(`range`in t.local)||!Array.isArray(t.local.range))return;let n=t.local.name,r=t.imported!==null&&typeof t.imported==`object`&&`name`in t.imported&&typeof t.imported.name==`string`?t.imported.name:n;n!==r&&Si(n)&&e.report({node:t,messageId:`noClassSuffixAlias`,data:{aliasName:n,importedName:r}})}function wi(e){return{ImportSpecifier(t){Ci(e,t)}}}const Q={meta:{type:`problem`,docs:{description:`禁止在 import 别名中使用 "Class" 后缀`},messages:{noClassSuffixAlias:`导入别名 "{{aliasName}}" 使用了 "Class" 后缀,这是不允许的命名方式。请使用更具描述性的名称,或直接使用原始名称 "{{importedName}}"`},schema:[]},create:wi},Ti=/domains\/[^/]+\/implementation\/src\/index\.ts$/,Ei=[/\.\/typeorm/,/\.\/typeorm'/,/\.\/typeorm"/];function Di(e){return Ei.some(t=>t.test(e))}const Oi={meta:{type:`problem`,docs:{description:`Implementation 包导出控制:禁止从主入口重新导出 typeorm.ts 的内容,typeorm.ts 仅供 DataSource/迁移基础设施使用`,recommended:!0},schema:[],messages:{forbiddenTypeormReExport:`禁止从主入口重新导出 typeorm.ts 的内容。typeorm.ts 是专门的持久化入口,仅供 DataSource/迁移基础设施使用,业务代码应通过主入口导入领域服务`}},create(e){let t=e.filename;return Ti.test(t)?{ExportNamedDeclaration(t){if(!t.source)return;let n=t.source.value;typeof n==`string`&&Di(n)&&e.report({node:t,messageId:`forbiddenTypeormReExport`})},ExportAllDeclaration(t){if(!t.source)return;let n=t.source.value;typeof n==`string`&&Di(n)&&e.report({node:t,messageId:`forbiddenTypeormReExport`})}}:{}}},ki={type:`suggestion`,docs:{description:`强制 domain entities 导出命名符合 {DOMAIN}_ORM_ENTITIES 规范`,recommended:!0},fixable:void 0,schema:[],messages:{invalidNaming:`entities 导出命名 "{{name}}" 不符合规范,应使用 "{{expected}}" 格式`,genericNaming:`entities 导出命名 "{{name}}" 是通用名称,应使用具体的 domain 名称 "{{expected}}"`,missingOrm:`entities 导出命名 "{{name}}" 缺少 "_ORM" 前缀,应使用 "{{expected}}"`,typoDetected:`entities 导出命名 "{{name}}" 可能存在拼写错误,应使用 "{{expected}}"`}},Ai=new Set([`DOMAIN_ENTITIES`,`ALL_ENTITIES`,`ENTITIES`]);function ji(e){let t=e.match(/\/domains\/([^/]+)\/implementation\/src\/typeorm\.ts$/);return!t||!t[1]?null:t[1].split(`-`).map(e=>e.toUpperCase()).join(`_`)}function Mi(e,t){return e.endsWith(`_ORM_ENTITIES`)?!1:e.endsWith(`_ENTITIES`)?e.replace(`_ENTITIES`,``)===t.replace(`_ORM_ENTITIES`,``):!1}function Ni(e){return Ai.has(e)}function Pi(e,t){let n=e.length,r=t.length,i=[];for(let a=0;a<=n;a++){i[a]=[];for(let n=0;n<=r;n++)a===0?i[a][n]=n:n===0?i[a][n]=a:e[a-1]===t[n-1]?i[a][n]=i[a-1][n-1]:i[a][n]=Math.min(i[a-1][n-1],i[a][n-1],i[a-1][n])+1}return i[n][r]}function Fi(e,t){let n=e.replace(`_ORM_ENTITIES`,``).replace(`_ENTITIES`,``),r=t.replace(`_ORM_ENTITIES`,``);return n===r?!1:n.toLowerCase()===r.toLowerCase()?!0:Pi(n,r)<=2}function Ii(e,t,n,r){Mi(n,r)?e.report({node:t,messageId:`missingOrm`,data:{name:n,expected:r}}):Ni(n)?e.report({node:t,messageId:`genericNaming`,data:{name:n,expected:r}}):Fi(n,r)?e.report({node:t,messageId:`typoDetected`,data:{name:n,expected:r}}):e.report({node:t,messageId:`invalidNaming`,data:{name:n,expected:r}})}function Li(e,t,n,r){if(typeof n!=`object`||!n||!(`id`in n)||n.id===null||typeof n.id!=`object`||!(`type`in n.id)||n.id.type!==`Identifier`||!(`name`in n.id)||typeof n.id.name!=`string`)return;let i=n.id.name;!i.endsWith(`_ENTITIES`)&&!i.endsWith(`_ORM_ENTITIES`)||i!==r&&Ii(e,t,i,r)}function Ri(e,t,n,r){if(typeof n!=`object`||!n||!(`exported`in n)||n.exported===null||typeof n.exported!=`object`||!(`type`in n.exported)||n.exported.type!==`Identifier`||!(`name`in n.exported)||typeof n.exported.name!=`string`)return;let i=n.exported.name;!i.endsWith(`_ENTITIES`)&&!i.endsWith(`_ORM_ENTITIES`)||i!==r&&Ii(e,t,i,r)}function zi(e,t){function n(n){if(typeof n==`object`&&n&&`declaration`in n&&n.declaration!==null&&typeof n.declaration==`object`&&`type`in n.declaration&&n.declaration.type===`VariableDeclaration`&&`declarations`in n.declaration&&Array.isArray(n.declaration.declarations))for(let r of n.declaration.declarations)Li(e,n,r,t);if(typeof n==`object`&&n&&`specifiers`in n&&Array.isArray(n.specifiers))for(let r of n.specifiers)Ri(e,n,r,t)}return n}function Bi(e){let t=e.filename;if(!t.endsWith(`typeorm.ts`))return{};let n=ji(t);return n?{ExportNamedDeclaration:zi(e,`${n}_ORM_ENTITIES`)}:{}}const Vi={meta:ki,create:Bi};function Hi(e){return e.replace(/\\/g,`/`).includes(`/apps/`)}function Ui(e){return e.endsWith(`-implementation`)}function Wi(e){return e.endsWith(`Entity`)}function Gi(e){return e.endsWith(`UseCase`)}function Ki(e){return[/PortAdapter$/,/_TOKEN$/,/^create\w+Repository$/,/^create\w+Adapter$/].some(t=>t.test(e))}const qi={noEntityImport:`禁止在 apps 层导入 Entity 类 "{{importName}}"。请使用 contract 包的 Port 接口进行操作。`,noUseCaseImport:`禁止在 apps 层导入 UseCase 类 "{{importName}}"。请使用 contract 包的 Port 接口进行操作。`,noImplementationImport:`禁止在 apps 层从 implementation 包导入 "{{importName}}"。请使用 contract 包的 Port 接口。`};function Ji(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`ImportSpecifier`}function Yi(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`Identifier`&&`name`in e&&typeof e.name==`string`}function Xi(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`Literal`&&`value`in e&&typeof e.value==`string`}function Zi(e){if(!(`imported`in e)||e.imported===null||typeof e.imported!=`object`)return null;let t=e.imported;return Yi(t)?t.name:Xi(t)?t.value:null}function Qi(e,t,n){Wi(n)?e.report({node:t,messageId:`noEntityImport`,data:{importName:n}}):Gi(n)?e.report({node:t,messageId:`noUseCaseImport`,data:{importName:n}}):Ki(n)||e.report({node:t,messageId:`noImplementationImport`,data:{importName:n}})}function $i(e,t,n){if(!Ji(t))return;let r=Zi(t);r&&Qi(e,t,r)}const ea={meta:{type:`problem`,docs:{description:`禁止在 apps 层导入 implementation 包的 Entity 和 UseCase`},messages:qi,schema:[]},create(e){let t=e.filename;return Hi(t)?{ImportDeclaration(t){if(!(`source`in t)||t.source===null||typeof t.source!=`object`||!(`type`in t.source)||t.source.type!==`Literal`||!(`value`in t.source)||typeof t.source.value!=`string`)return;let n=t.source.value;if(Ui(n)&&!(!(`specifiers`in t)||!Array.isArray(t.specifiers)))for(let r of t.specifiers)Ji(r)&&$i(e,r,n)}}:{}}};function ta(e){let t=e.replace(/\\/g,`/`);return t.includes(`/domains/`)&&t.includes(`/implementation/src/index.ts`)}function na(e){return e.endsWith(`Entity`)}function ra(e){return e.endsWith(`Repository`)&&!e.startsWith(`I`)}function ia(e){return e.endsWith(`OrmEntity`)}function aa(e){return e.endsWith(`_ORM_ENTITIES`)}function oa(e){return e.endsWith(`OrmMapper`)}function sa(e){return e.endsWith(`Schema`)}function ca(e){return`exportKind`in e&&typeof e.exportKind==`string`?e.exportKind===`value`:!0}function la(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`ExportSpecifier`}function ua(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`Identifier`&&`name`in e&&typeof e.name==`string`}function da(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`Literal`&&`value`in e&&typeof e.value==`string`}function fa(e){if(typeof e!=`object`||!e||!(`exported`in e)||e.exported===null||typeof e.exported!=`object`)return null;let t=e.exported;return ua(t)?t.name:da(t)?t.value:null}function $(e,t,n,r){e.report({node:t,messageId:n,data:{exportName:r}})}function pa(e,t,n){return na(n)&&ca(t)?($(e,t,`noEntityValueExport`,n),!0):!1}function ma(e,t,n){return ra(n)?($(e,t,`noRepositoryTypeExport`,n),!0):!1}function ha(e,t,n){return ia(n)?($(e,t,`noOrmEntityExport`,n),!0):aa(n)?($(e,t,`noOrmEntitiesExport`,n),!0):oa(n)?($(e,t,`noOrmMapperExport`,n),!0):!1}function ga(e,t,n){sa(n)&&$(e,t,`noSchemaExport`,n)}function _a(e,t,n){pa(e,t,n)||ma(e,t,n)||ha(e,t,n)||ga(e,t,n)}function va(e,t){if(!(!(`source`in t)||t.source===null||typeof t.source!=`object`||!(`type`in t.source)||t.source.type!==`Literal`||!(`value`in t.source)||typeof t.source.value!=`string`)&&!(!(`specifiers`in t)||!Array.isArray(t.specifiers)))for(let n of t.specifiers){if(!la(n))continue;let t=fa(n);t&&_a(e,n,t)}}const ya={meta:{type:`problem`,docs:{description:`检查 Domain Implementation 包的导出是否符合规范`},messages:{noEntityValueExport:'禁止从主入口值导出 Entity 类 "{{exportName}}"。请改为类型导出:`export type { {{exportName}} }` 或移除导出。',noRepositoryTypeExport:`禁止导出 Repository 类型 "{{exportName}}"。Repository 是内部实现,不应暴露给外部。请移除此导出。`,noOrmEntityExport:`禁止从主入口导出 ORM 实体 "{{exportName}}"。请创建 src/typeorm.ts 入口文件,从该入口导出 ORM 实体。`,noOrmEntitiesExport:`禁止从主入口导出 ORM 实体集合 "{{exportName}}"。请创建 src/typeorm.ts 入口文件,从该入口导出。`,noOrmMapperExport:`禁止导出 ORM Mapper "{{exportName}}"。ORM Mapper 是基础设施实现细节,不应暴露给外部。请移除此导出。`,noSchemaExport:`禁止导出 Schema 定义 "{{exportName}}"。Schema 是实现细节,应完全保留在 Domain 内部。请仅导出从 Schema 推断的类型。`},schema:[]},create(e){let t=e.filename;return ta(t)?{ExportNamedDeclaration(t){va(e,t)}}:{}}},ba=`@longzai-intelligence/architecture-core`,xa={meta:{name:ba,version:`1.0.0`},rules:{"dependency-direction":pe,"no-core-types-in-apps":g,"business-leak":Re,"file-naming":j,"require-type-suffix":M,"no-cross-package-relative-import":I,"prefer-split-export-const":Ln,"require-class-suffix":er,"require-interface-naming":fr,"require-type-naming":gr,"require-dto-naming":br,"no-class-suffix-alias":Q,"implementation-export-control":Oi,"no-implementation-import-in-apps":ea,"domain-export-compliance":ya}},Sa=`@longzai-intelligence/architecture-domain`,Ca={meta:{name:Sa,version:`1.0.0`},rules:{"domain-export":Je,"domain-typeorm-import":$e,"layer-readme-required":Kn,"require-domain-entities-naming":Vi}},wa=`@longzai-intelligence/architecture-electron`,Ta={meta:{name:wa,version:`1.0.0`},rules:{"platform-leak":b,"no-implementation-in-renderer":N,"no-unsafe-electron-api-exposure":Cn,"no-generic-ipc-bridge-exposure":Dn,"no-direct-ipcrenderer-in-preload":kn,"tsconfig-references":ci,"require-typed-ipc-channel":ui,"require-expose-safe-api":pi,"no-custom-ipc-utility":gi,"require-unwrap-ipc-result":xi}},Ea=`@longzai-intelligence/architecture-library`,Da={meta:{name:Ea,version:`1.0.0`},rules:{"test-file-placement":V,"no-non-test-files-in-tests-directory":rn,"test-file-matches-source":xn,"require-tsup-config-import":wr,"require-tsdown-config-import":Or,"require-vitest-config-import":Br,"require-eslint-config-import":Jr}},Oa=`@longzai-intelligence/architecture`,ka={meta:{name:Oa,version:`1.0.0`},rules:{"dependency-direction":pe,"no-core-types-in-apps":g,"platform-leak":b,"business-leak":Re,"domain-export":Je,"domain-typeorm-import":$e,"file-naming":j,"require-type-suffix":M,"no-implementation-in-renderer":N,"no-cross-package-relative-import":I,"test-file-placement":V,"no-non-test-files-in-tests-directory":rn,"test-file-matches-source":xn,"no-unsafe-electron-api-exposure":Cn,"no-generic-ipc-bridge-exposure":Dn,"no-direct-ipcrenderer-in-preload":kn,"prefer-split-export-const":Ln,"layer-readme-required":Kn,"require-class-suffix":er,"require-interface-naming":fr,"require-type-naming":gr,"require-dto-naming":br,"require-tsup-config-import":wr,"require-tsdown-config-import":Or,"require-vitest-config-import":Br,"require-eslint-config-import":Jr,"tsconfig-references":ci,"require-typed-ipc-channel":ui,"require-expose-safe-api":pi,"no-custom-ipc-utility":gi,"require-unwrap-ipc-result":xi,"no-class-suffix-alias":Q,"implementation-export-control":Oi,"require-domain-entities-naming":Vi,"no-implementation-import-in-apps":ea}};exports.CORE_PLUGIN_NAME=ba,exports.DOMAIN_PLUGIN_NAME=Sa,exports.ELECTRON_PLUGIN_NAME=wa,exports.LIBRARY_PLUGIN_NAME=Ea,exports.PLUGIN_NAME=Oa,exports.architectureCorePlugin=xa,exports.architectureDomainPlugin=Ca,exports.architectureElectronPlugin=Ta,exports.architectureLibraryPlugin=Da,exports.architecturePlugin=ka;
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`@longzai-intelligence/eslint-utils`),l=require(`node:path`);l=s(l);let u=require(`node:fs`);u=s(u);let d=require(`@typescript-eslint/utils`);const f={types:0,utils:1,"shared-kernel":2,contract:3,engine:4,platform:5,infrastructure:6,implementation:6},ee={"@longzai-intelligence/shared-kernel":`shared-kernel`,"@longzai-intelligence/utils":`utils`,"@longzai-intelligence/error-utils":`utils`,"@longzai-intelligence/zod-utils":`utils`,"@longzai-intelligence/testing-utils":`utils`,"@longzai-intelligence/host-contracts":`contract`,"@longzai-intelligence/typeorm-adapter":`implementation`,"@longzai-intelligence/typeorm-utils":`utils`,"@longzai-intelligence/http-client":`utils`,"@longzai-intelligence/pagination":`utils`,"@longzai-intelligence/turbo-output-parser":`utils`,"@longzai-intelligence/electron":`implementation`},te=[{suffix:`-contract`,layer:`contract`},{suffix:`-implementation`,layer:`implementation`},{suffix:`-engine`,layer:`engine`},{suffix:`-runtime`,layer:`engine`}],p={pathPatterns:[{pattern:/\/domains\/[^/]+\/implementation\//,layer:`implementation`},{pattern:/\/domains\/[^/]+\/contract\//,layer:`contract`},{pattern:/\/domains\/shared-kernel\//,layer:`shared-kernel`},{pattern:/\/infrastructure\//,layer:`infrastructure`},{pattern:/\/packages\/utils\//,layer:`utils`},{pattern:/\/packages\/errors\//,layer:`utils`},{pattern:/\/packages\/zod-utils\//,layer:`utils`},{pattern:/\/packages\/testing-utils\//,layer:`utils`},{pattern:/\/packages\/engine\/[^/]+\//,layer:`engine`},{pattern:/\/packages\/design-system\/primitives\//,layer:`utils`},{pattern:/\/packages\/design-system\/composites\//,layer:`implementation`},{pattern:/\/packages\/design-system\/utils\//,layer:`utils`},{pattern:/\/packages\/electron\//,layer:`implementation`},{pattern:/\/packages\/typeorm-adapter\//,layer:`implementation`},{pattern:/\/packages\/typeorm-utils\//,layer:`utils`},{pattern:/\/packages\/http-client\//,layer:`utils`},{pattern:/\/packages\/pagination\//,layer:`utils`},{pattern:/\/packages\/turbo-output-parser\//,layer:`utils`},{pattern:/\/packages\/host-contracts\//,layer:`contract`},{pattern:/\/packages\/event-bus\/contract\//,layer:`contract`},{pattern:/\/packages\/event-bus\/implementation\//,layer:`implementation`},{pattern:/\/packages\/payment\/core\//,layer:`contract`},{pattern:/\/packages\/payment\/adapters\//,layer:`implementation`},{pattern:/\/packages\/payment\/presets\//,layer:`implementation`},{pattern:/\/packages\/logger\/core\//,layer:`contract`},{pattern:/\/packages\/logger\/adapters\//,layer:`implementation`},{pattern:/\/packages\/logger\/presets\//,layer:`implementation`},{pattern:/\/packages\/react-devtools\/core\//,layer:`contract`},{pattern:/\/packages\/react-devtools\/adapters\//,layer:`implementation`},{pattern:/\/packages\/react-devtools\/ui\//,layer:`implementation`},{pattern:/\/packages\/react-devtools\/presets\//,layer:`implementation`},{pattern:/\/packages\/feed-parser\/protocol\//,layer:`contract`},{pattern:/\/packages\/feed-parser\/[^/]+\//,layer:`implementation`}],packagePrefix:`@longzai-intelligence/`,specialPackageMappings:ee,packageSuffixMappings:te},ne=[{pattern:/\/src\/domain\//,layer:`contract`},{pattern:/\/src\/engine\//,layer:`engine`},{pattern:/\/src\/platform\//,layer:`platform`},{pattern:/\/src\/infrastructure\//,layer:`infrastructure`},{pattern:/\/src\/shared\//,layer:`shared-kernel`}],re=[{pattern:/\/src\/domain\//,layer:`contract`},{pattern:/\/src\/engine\//,layer:`engine`},{pattern:/\/src\/platform\//,layer:`platform`},{pattern:/\/src\/infrastructure\//,layer:`infrastructure`},{pattern:/\/src\/shared\//,layer:`shared-kernel`}],m=new WeakMap;function ie(e,t){let n=e.replace(/\\/g,`/`),r=t??p.pathPatterns;if(r){for(let{pattern:e,layer:t}of r)if(e.test(n))return{layer:t,priority:f[t]}}return n.includes(`/apps/`)?oe(n):n.includes(`/packages/`)?se(n):null}function ae(e,t,n){let r=m.get(t);if(r||(r=new Map,m.set(t,r)),r.has(e))return r.get(e);let i=ie(e,n);return r.set(e,i),i}function oe(e){for(let{pattern:t,layer:n}of ne)if(t.test(e))return{layer:n,priority:f[n]};return null}function se(e){for(let{pattern:t,layer:n}of re)if(t.test(e))return{layer:n,priority:f[n]};return null}function ce(e,t){let n=t?.packagePrefix??`@longzai-intelligence/`;if(!e.startsWith(n))return null;let r=e.split(`/`)[1];if(!r)return null;let i=`${n}${r}`,a=(t?.specialPackageMappings??ee)[i];if(a)return{layer:a,priority:f[a]};let o=t?.packageSuffixMappings??te;for(let{suffix:e,layer:t}of o)if(r.endsWith(e))return{layer:t,priority:f[t]};return null}const le={types:`类型层 (Types)`,utils:`工具层 (Utils)`,"shared-kernel":`共享内核层 (Shared Kernel)`,contract:`契约层 (Contract)`,engine:`引擎层 (Engine)`,platform:`平台层 (Platform)`,infrastructure:`基础设施层 (Infrastructure)`,implementation:`实现层 (Implementation)`};function ue(e){return le[e]}function de(e,t){return f[e]>=f[t]}const fe=new Set([`types`,`utils`,`shared-kernel`,`contract`,`engine`,`platform`,`infrastructure`,`implementation`]);function h(e){return fe.has(e)}function pe(e){return e?e.reduce((e,{pattern:t,layer:n})=>(h(n)&&e.push({pattern:me(t),layer:n}),e),[]):[]}function me(e){let t=e.match(/^\/(.+)\/([gimsuvy]*)$/);if(t&&t[1]){let e=t[1],n=t[2]??``;return new RegExp(e,n)}return new RegExp(e)}function he(e){if(!e)return;let t={};for(let[n,r]of Object.entries(e))h(r)&&(t[n]=r);return Object.keys(t).length>0?t:void 0}function ge(e){if(!e||e.length===0)return;let t=[];for(let{suffix:n,layer:r}of e)h(r)&&t.push({suffix:n,layer:r});return t.length>0?t:void 0}function _e(e){let t={};return e.pathPatterns&&(t.pathPatterns=pe(e.pathPatterns)),e.packagePrefix&&(t.packagePrefix=e.packagePrefix),e.specialPackageMappings&&(t.specialPackageMappings=he(e.specialPackageMappings)),e.packageSuffixMappings&&(t.packageSuffixMappings=ge(e.packageSuffixMappings)),t}const ve={meta:{type:`problem`,docs:{description:`强制执行 Clean Architecture 的依赖方向规则`},messages:{invalidDependency:`依赖方向违规: {{currentLayer}} ({{currentLayerName}}) 不能导入 {{importLayer}} ({{importLayerName}})。依赖应该从外层指向内层,请检查导入语句。`},schema:[{type:`object`,properties:{pathPatterns:{type:`array`,items:{type:`object`,properties:{pattern:{type:`string`},layer:{type:`string`}},required:[`pattern`,`layer`],additionalProperties:!1}},packagePrefix:{type:`string`},specialPackageMappings:{type:`object`,additionalProperties:{type:`string`}},packageSuffixMappings:{type:`array`,items:{type:`object`,properties:{suffix:{type:`string`},layer:{type:`string`}},required:[`suffix`,`layer`],additionalProperties:!1}}},additionalProperties:!1}]},create(e){let t=_e(e.options?.[0]||{}),n={pathPatterns:t.pathPatterns??p.pathPatterns,packagePrefix:t.packagePrefix??p.packagePrefix,specialPackageMappings:t.specialPackageMappings??p.specialPackageMappings,packageSuffixMappings:t.packageSuffixMappings??p.packageSuffixMappings},r=e.filename,i=ae(r,e,n.pathPatterns);return i?{ImportDeclaration(t){let r=t.source.value;if(typeof r!=`string`)return;let a=ce(r,n);a&&(de(i.layer,a.layer)||e.report({node:t,messageId:`invalidDependency`,data:{currentLayer:i.layer,currentLayerName:ue(i.layer),importLayer:a.layer,importLayerName:ue(a.layer)}}))}}:{}}},ye=new Set(`Agent.Page.PageContent.Workspace.WorkspaceMember.User.Session.Task.Repository.Folder.SyncMetadata.SyncError.SyncErrorCode.SyncResult.SyncStatus.SyncConflictData.EntityChange.OfflineOperation.DirtyEntity.PullResult.PushResult.ApiResponse.P2PNode.ConnectionState.NetworkStatus.IMAgent.IMContact.IMConversation.IMMessage.IMGroup.IMGroupSettings`.split(`.`));function be(e){return e.replace(/\\/g,`/`).includes(`/apps/`)}function g(e){return ye.has(e)}const _={meta:{type:`problem`,docs:{description:`禁止在 apps 层定义核心领域类型`},messages:{noCoreTypesInApps:`禁止在 apps 层定义核心领域类型 "{{typeName}}"。请在 packages/types 或 packages/domain 中定义此类型。`},schema:[]},create(e){let t=e.filename;return be(t)?{TSInterfaceDeclaration(t){if(!(0,c.hasIdWithName)(t))return;let n=t.id.name;g(n)&&e.report({node:t,messageId:`noCoreTypesInApps`,data:{typeName:n}})},TSTypeAliasDeclaration(t){if(!(0,c.hasIdWithName)(t))return;let n=t.id.name;g(n)&&e.report({node:t,messageId:`noCoreTypesInApps`,data:{typeName:n}})},ClassDeclaration(t){if(!(0,c.hasIdWithName)(t))return;let n=t.id.name;g(n)&&e.report({node:t,messageId:`noCoreTypesInApps`,data:{typeName:n}})}}:{}}},v={node:[`fs`,`path`,`os`,`crypto`,`child_process`,`cluster`,`dgram`,`dns`,`http`,`https`,`net`,`readline`,`stream`,`tls`,`tty`,`udp`,`url`,`util`,`v8`,`vm`,`worker_threads`,`zlib`],browser:[`window`,`document`,`navigator`,`localStorage`,`sessionStorage`,`fetch`,`XMLHttpRequest`,`WebSocket`,`Worker`,`IndexedDB`,`Blob`,`File`,`FileReader`,`URL`,`URLSearchParams`,`History`,`Location`,`Screen`,`AudioContext`,`Canvas`,`Notification`,`Performance`,`ServiceWorker`],electron:[`ipcRenderer`,`ipcMain`,`app`,`BrowserWindow`,`dialog`,`Menu`,`Tray`,`nativeImage`,`shell`,`clipboard`]},xe=new Set(v.node),Se=new Set(v.browser),Ce=new Set(v.electron),we=[/\/domains\/shared-kernel\//,/\/domains\/page-domain\//,/\/domains\/repository-domain\//,/\/domains\/agent-domain\//,/\/domains\/collab-domain\//,/\/domains\/identity-domain\//,/\/domains\/workflow-domain\//,/\/domains\/chat-domain\//,/\/domains\/workspace-domain\//];function Te(e){let t=e.replace(/\\/g,`/`);return we.some(e=>e.test(t))}function Ee(e){if(e.startsWith(`node:`)||xe.has(e))return`node`;for(let t of v.node)if(e.startsWith(`${t}/`))return`node`;return null}function y(e){return Se.has(e)}function b(e){return Ce.has(e)}function De(e){return typeof e==`object`&&!!e&&`object`in e&&e.object!==null&&typeof e.object==`object`&&`type`in e.object&&`name`in e.object}function Oe(e){return typeof e==`object`&&!!e&&`name`in e&&typeof e.name==`string`}function ke(e,t){if(!(0,c.isImportDeclaration)(e))return;let n=e.source.value;if(typeof n==`string`&&Ee(n)){let r=n.replace(/^node:/,``);t.report({node:e,messageId:`nodeImport`,data:{moduleName:r}})}}function Ae(e,t){if(De(e)&&e.object.type===`Identifier`){let n=e.object.name;y(n)&&t.report({node:e,messageId:`browserAPI`,data:{apiName:n}}),b(n)&&t.report({node:e,messageId:`electronAPI`,data:{apiName:n}})}}function je(e,t){if(!Oe(e))return;let n=e.name;(y(n)||b(n))&&e.parent&&e.parent.type!==`MemberExpression`&&t.report({node:e,messageId:`globalAPI`,data:{globalName:n}})}const Me={meta:{type:`problem`,docs:{description:`禁止在业务域层直接使用平台特定 API`},messages:{nodeImport:`平台代码泄漏: 业务域层禁止直接导入 Node.js 模块 '{{moduleName}}'。请通过 packages/platform 层的接口间接访问。`,browserAPI:`平台代码泄漏: 业务域层禁止直接使用浏览器 API '{{apiName}}'。请通过 packages/platform 层的接口间接访问。`,electronAPI:`平台代码泄漏: 业务域层禁止直接使用 Electron API '{{apiName}}'。请通过 packages/platform 层的接口间接访问。`,globalAPI:`平台代码泄漏: 业务域层禁止直接访问全局对象 '{{globalName}}'。请通过 packages/platform 层的接口间接访问。`},schema:[]},create(e){let t=e.filename;return Te(t)?{ImportDeclaration(t){ke(t,e)},MemberExpression(t){Ae(t,e)},Identifier(t){je(t,e)}}:{}}},Ne=[/\/packages\/platform\//,/\/packages\/ui\//,/\/packages\/ui-kit\//,/\/packages\/engine\//,/\/packages\/utils\//,/\/packages\/types\//],Pe=[`Page`,`Repository`,`Agent`,`Workflow`,`Workspace`,`User`,`Auth`,`Session`,`Message`,`Conversation`,`Sync`,`Favorite`,`Folder`,`Team`,`Execution`,`Task`,`Step`,`Trigger`],Fe=[/^validate/,/^calculate/,/^compute/,/^determine/,/^check/,/^can/,/^should/,/^isAllowed/,/^isPermitted/,/^hasPermission/,/^applyRule/,/^enforce/,/^execute/];function Ie(e){let t=e.replace(/\\/g,`/`);return Ne.some(e=>e.test(t))}function x(e){let t=e.charAt(0).toUpperCase()+e.slice(1);return Pe.some(e=>t.includes(e))}function Le(e){return Fe.some(t=>t.test(e))}function Re(e){return typeof e==`object`&&!!e&&`key`in e&&e.key!==null&&typeof e.key==`object`&&`type`in e.key&&e.key.type===`Identifier`&&`name`in e.key&&typeof e.key.name==`string`}function ze(e){return typeof e==`object`&&!!e&&`id`in e&&e.id!==null&&typeof e.id==`object`&&`type`in e.id&&e.id.type===`Identifier`&&`name`in e.id&&typeof e.id.name==`string`&&`type`in e&&typeof e.type==`string`}function Be(e,t){(0,c.hasIdWithName)(e)&&x(e.id.name)&&t.report({node:e,messageId:`businessClass`,data:{className:e.id.name}})}function Ve(e,t){Re(e)&&Le(e.key.name)&&t.report({node:e,messageId:`businessMethod`,data:{methodName:e.key.name}})}function He(e,t){(0,c.hasIdWithName)(e)&&x(e.id.name)&&t.report({node:e,messageId:`businessInterface`,data:{interfaceName:e.id.name}})}function Ue(e,t){ze(e)&&x(e.id.name)&&t.report({node:e,messageId:`businessType`,data:{typeName:e.id.name}})}const We={meta:{type:`suggestion`,docs:{description:`检测技术层中可能存在的业务逻辑`},messages:{businessClass:`业务逻辑泄漏嫌疑: 技术层发现业务相关类 '{{className}}'。业务逻辑应该放在 domains/ 层。`,businessMethod:`业务逻辑泄漏嫌疑: 技术层发现业务规则方法 '{{methodName}}'。业务规则应该放在 domains/ 层。`,businessInterface:`业务逻辑泄漏嫌疑: 技术层发现业务相关接口 '{{interfaceName}}'。业务接口应该放在 domains/ 层。`,businessType:`业务逻辑泄漏嫌疑: 技术层发现业务相关类型 '{{typeName}}'。业务类型应该放在 domains/ 层。`},schema:[]},create(e){let t=e.filename;return Ie(t)?{ClassDeclaration(t){Be(t,e)},MethodDefinition(t){Ve(t,e)},TSInterfaceDeclaration(t){He(t,e)},TSTypeAliasDeclaration(t){Ue(t,e)}}:{}}};function Ge(e){return e.startsWith(`create`)||e.startsWith(`make`)||e.startsWith(`build`)}function Ke(e){return/domains\/[^/]+\/(implementation|contract)\/src\/index\.ts$/.test(e)?`main`:/domains\/[^/]+\/(implementation|contract)\/src\/(domain|application|infrastructure)\/index\.ts$/.test(e)?`layer`:/domains\/[^/]+\/(implementation|contract)\/src\/(domain|application|infrastructure)\/\w+\/index\.ts$/.test(e)?`submodule`:`none`}function qe(e){return e.includes(`/infrastructure/`)}const Je=[],Ye=[{pattern:/^(?!create)[A-Za-z]+Repository(Drizzle|Memory|Sqlite|Mysql)$/,messageId:`forbiddenRepositoryExport`,message:`禁止导出具体仓储实现类`},{pattern:/^(?!create)[A-Za-z]*Table$/,messageId:`forbiddenTableExport`,message:`禁止导出数据库表定义`},{pattern:/[A-Za-z]+OrmEntity$/,messageId:`forbiddenOrmEntityExportFromMain`,message:`禁止从主入口导出 ORM 实体,应从 ./typeorm 入口导出`},{pattern:/[A-Z_]+_ORM_ENTITIES$/,messageId:`forbiddenEntitiesExportFromMain`,message:`禁止从主入口导出实体集合,应从 ./typeorm 入口导出`},{pattern:/[A-Za-z]+OrmMapper$/,messageId:`forbiddenOrmMapperExportFromMain`,message:`禁止从主入口导出 ORM Mapper,这是基础设施层实现细节`}],Xe=/^(?!create)[A-Za-z]*Schema$/,Ze=new WeakMap;function Qe(e,t,n){if(!n)return $e(e,t);let r=Ze.get(n);if(r||(r=new Map,Ze.set(n,r)),r.has(t))return r.get(t);let i=$e(e,t);return r.set(t,i),i}function $e(e,t){let n=[],r=/export\s*\*\s*from/.test(e),i=e.matchAll(/export\s+type\s+\{([^}]+)\}/g);for(let e of i){let t=e[1];if(t){let e=t.split(`,`).map(e=>{let t=e.trim().split(` as `);return t[0]?t[0].trim():``}).filter(e=>e);n.push(...e)}}let a=e.matchAll(/export\s+(?!type)\{([^}]+)\}/g);for(let e of a){let t=e[1];if(t){let e=t.split(`,`).map(e=>{let t=e.trim().split(` as `);return t[0]?t[0].trim():``}).filter(e=>e);n.push(...e)}}let o=e.matchAll(/export\s+(class|function|const|let|interface|type)\s+(\w+)/g);for(let e of o){let t=e[2];t&&n.push(t)}let s=[],c=qe(t);if(Ke(t)===`submodule`)return{usesExportStar:r,exports:n,forbiddenIssues:s};for(let e of n)if(!Ge(e)){for(let{pattern:t,messageId:n}of Je)t.test(e)&&s.push({messageId:n,exportName:e});for(let{pattern:t,messageId:n}of Ye)t.test(e)&&s.push({messageId:n,exportName:e});c&&Xe.test(e)&&s.push({messageId:`forbiddenSchemaExport`,exportName:e})}return{usesExportStar:r,exports:n,forbiddenIssues:s}}const et={meta:{type:`problem`,docs:{description:`Domain 包导出规范:禁止 export *、禁止导出具体实现类、禁止导出数据库表和 Schema`,recommended:!0},schema:[],messages:{forbiddenExportStar:`禁止使用 export *,应使用显式导出(export { ... } 或 export type { ... })`,forbiddenRepositoryExport:`禁止导出具体仓储实现类 {{exportName}},应使用工厂函数 createXxxRepository`,forbiddenTableExport:`禁止导出数据库表定义 {{exportName}}`,forbiddenSchemaExport:`禁止导出 Schema 定义 {{exportName}}`,forbiddenOrmEntityExportFromMain:`禁止从主入口导出 ORM 实体 {{exportName}},应从 ./typeorm 入口导出`,forbiddenEntitiesExportFromMain:`禁止从主入口导出实体集合 {{exportName}},应从 ./typeorm 入口导出`,forbiddenOrmMapperExportFromMain:`禁止从主入口导出 ORM Mapper {{exportName}},这是基础设施层实现细节`}},create(e){let t=e.filename;if(Ke(t)===`none`)return{};let n=e.sourceCode.text,{usesExportStar:r,forbiddenIssues:i}=Qe(n,t,e);return{Program(t){r&&e.report({node:t,messageId:`forbiddenExportStar`});for(let n of i)e.report({node:t,messageId:n.messageId,data:{exportName:n.exportName}})}}}},tt=/@longzai-intelligence\/[^/]+\/typeorm/,nt=/@longzai-intelligence\/[^/]+\/infrastructure\//,rt=[/data-source\.ts$/,/data-source\.config\.ts$/,/data-source\.[a-z-]+\.ts$/,/database\.module\.ts$/,/database\.ts$/,/database\.config\.ts$/,/database\.service\.ts$/];function it(e){return rt.some(t=>t.test(e))}const at={meta:{type:`problem`,docs:{description:`Domain TypeORM 导入规范:非 DataSource 场景禁止导入 /typeorm 入口,禁止 infrastructure/* deep import`,recommended:!0},schema:[],messages:{forbiddenTypeormImport:`非 DataSource 场景禁止从 /typeorm 入口导入 ORM 实体,该入口仅供 DataSource/迁移基础设施使用`,forbiddenInfrastructureImport:`禁止 infrastructure/* deep import,应使用受控入口(主入口或 ./typeorm)`}},create(e){let t=e.filename,n=it(t);return{ImportDeclaration(t){if(!t.source)return;let r=t.source.value;typeof r==`string`&&(tt.test(r)&&(n||e.report({node:t,messageId:`forbiddenTypeormImport`})),nt.test(r)&&e.report({node:t,messageId:`forbiddenInfrastructureImport`}))}}}};function S(e){if(typeof e!=`object`||!e)return!1;let t=e;return`name`in t&&typeof t.name==`string`&&`isSpecialFile`in t&&typeof t.isSpecialFile==`function`&&`getNamingRules`in t&&typeof t.getNamingRules==`function`&&`shouldSkipTypeSuffix`in t&&typeof t.shouldSkipTypeSuffix==`function`}const ot=[{pattern:/\.service\.drizzle\.ts$/,case:`kebab-case`,description:`Drizzle Service 文件应使用 xxx.service.drizzle.ts 格式(kebab-case)`},{pattern:/\.service\.memory\.ts$/,case:`kebab-case`,description:`Memory Service 文件应使用 xxx.service.memory.ts 格式(kebab-case)`},{pattern:/\.service\.ts$/,case:`kebab-case`,description:`服务文件应使用 xxx.service.ts 格式(kebab-case)`},{pattern:/\.controller\.ts$/,case:`kebab-case`,description:`控制器文件应使用 xxx.controller.ts 格式(kebab-case)`},{pattern:/\.module\.ts$/,case:`kebab-case`,description:`模块文件应使用 xxx.module.ts 格式(kebab-case)`},{pattern:/\.repository\.drizzle\.ts$/,case:`kebab-case`,description:`Drizzle Repository 文件应使用 xxx.repository.drizzle.ts 格式(kebab-case)`},{pattern:/\.repository\.memory\.ts$/,case:`kebab-case`,description:`Memory Repository 文件应使用 xxx.repository.memory.ts 格式(kebab-case)`},{pattern:/\.repository\.interface\.ts$/,case:`kebab-case`,description:`Repository 接口文件应使用 xxx.repository.interface.ts 格式(kebab-case)`},{pattern:/\.repository\.types\.ts$/,case:`kebab-case`,description:`Repository 类型文件应使用 xxx.repository.types.ts 格式(kebab-case)`},{pattern:/\.repository\.ts$/,case:`kebab-case`,description:`Repository 文件应使用 xxx.repository.ts 格式(kebab-case)`},{pattern:/\.entity\.types\.ts$/,case:`kebab-case`,description:`Entity 类型文件应使用 xxx.entity.types.ts 格式(kebab-case)`},{pattern:/\.entity\.interface\.ts$/,case:`kebab-case`,description:`Entity 接口文件应使用 xxx.entity.interface.ts 格式(kebab-case)`},{pattern:/\.entity\.ts$/,case:`kebab-case`,description:`Entity 文件应使用 xxx.entity.ts 格式(kebab-case)`},{pattern:/\.dto\.ts$/,case:`kebab-case`,description:`DTO 文件应使用 xxx.dto.ts 格式(kebab-case)`},{pattern:/\.port\.interface\.ts$/,case:`kebab-case`,description:`Port 接口文件应使用 xxx.port.interface.ts 格式(kebab-case)`},{pattern:/\.interface\.ts$/,case:`kebab-case`,description:`接口文件应使用 xxx.interface.ts 格式(kebab-case)`},{pattern:/\.types\.ts$/,case:`kebab-case`,description:`类型文件应使用 xxx.types.ts 格式(kebab-case)`},{pattern:/\.schema\.ts$/,case:`kebab-case`,description:`Schema 文件应使用 xxx.schema.ts 格式(kebab-case)`},{pattern:/\.port\.ts$/,case:`kebab-case`,description:`Port 文件应使用 xxx.port.ts 格式(kebab-case)`},{pattern:/\.port\.adapter\.ts$/,case:`kebab-case`,description:`Port Adapter 文件应使用 xxx.port.adapter.ts 格式(kebab-case)`},{pattern:/\.adapter\.ts$/,case:`kebab-case`,description:`Adapter 文件应使用 xxx.adapter.ts 格式(kebab-case)`},{pattern:/\.events\.ts$/,case:`kebab-case`,description:`Events 文件应使用 xxx.events.ts 格式(kebab-case)`},{pattern:/\.mapper\.ts$/,case:`kebab-case`,description:`Mapper 文件应使用 xxx.mapper.ts 格式(kebab-case)`},{pattern:/\.ipc\.ts$/,case:`kebab-case`,description:`IPC 文件应使用 xxx.ipc.ts 格式(kebab-case)`},{pattern:/\.config\.ts$/,case:`kebab-case`,description:`配置文件应使用 xxx.config.ts 格式(kebab-case)`},{pattern:/\.errors\.ts$/,case:`kebab-case`,description:`错误文件应使用 xxx.errors.ts 格式(kebab-case)`},{pattern:/\.utils\.ts$/,case:`kebab-case`,description:`工具函数文件应使用 xxx.utils.ts 格式(kebab-case)`},{pattern:/\.constants\.ts$/,case:`kebab-case`,description:`常量文件应使用 xxx.constants.ts 格式(kebab-case)`},{pattern:/\.atom\.ts$/,case:`kebab-case`,description:`Atom 文件应使用 xxx.atom.ts 格式(kebab-case)`},{pattern:/\.vo\.ts$/,case:`kebab-case`,description:`值对象文件应使用 xxx.vo.ts 格式(kebab-case)`},{pattern:/\.usecase\.ts$/,case:`kebab-case`,description:`UseCase 文件应使用 xxx.usecase.ts 格式(kebab-case)`},{pattern:/\.styles\.css$/,case:`kebab-case`,description:`样式文件应使用 xxx.styles.css 格式(kebab-case)`},{pattern:/\.extension\.tsx?$/,case:`kebab-case`,description:`扩展文件应使用 xxx.extension.ts(x) 格式(kebab-case)`}],st=[{pattern:/^use[A-Z][a-zA-Z]*\.spec\.tsx?$/,case:`camelCase`,description:`Hook 测试文件应使用 camelCase 并以 use 前缀开头(如 useChat.spec.ts)`},{pattern:/^use[A-Z][a-zA-Z]*\.test\.tsx?$/,case:`camelCase`,description:`Hook 测试文件应使用 camelCase 并以 use 前缀开头(如 useChat.test.ts)`},{pattern:/^use[A-Z][a-zA-Z]*\.types\.ts$/,case:`camelCase`,description:`Hook 类型文件应使用 camelCase 并以 use 前缀开头(如 useChat.types.ts)`},{pattern:/\.spec\.ts$/,case:`kebab-case-test`,description:`测试文件应使用 xxx.spec.ts 格式(kebab-case)`},{pattern:/\.test\.ts$/,case:`kebab-case-test`,description:`测试文件应使用 xxx.test.ts 格式(kebab-case)`},{pattern:/\.spec\.tsx$/,case:`kebab-case-test`,description:`测试文件应使用 xxx.spec.tsx 格式(kebab-case)`},{pattern:/\.test\.tsx$/,case:`kebab-case-test`,description:`测试文件应使用 xxx.test.tsx 格式(kebab-case)`},{pattern:/^use[A-Z][a-zA-Z]*\.tsx?$/,case:`camelCase`,description:`Hook 文件应使用 camelCase 并以 use 前缀开头(如 useChat.ts)`}],C={pattern:/^[A-Z][a-zA-Z]*\.tsx$/,case:`PascalCase`,description:`React 组件文件应使用 PascalCase(如 ChatPage.tsx)`};[...st,...ot];const ct=[`index.ts`,`index.tsx`,`main.ts`,`main.tsx`,`App.tsx`,`types.ts`,`errors.ts`,`constants.ts`,`persistence.ts`,`typeorm.ts`],lt=[`impl`,`functions`,`methods`,`handlers`,`classes`];function ut(e){let t=e.replace(/\.tsx?$/,``);return[/s$/,/es$/,/ies$/].some(e=>e.test(t))}function dt(e){return/^v\d+(-[a-z0-9-]+)?\.ts$/.test(e)}function ft(e){let t=e.replace(/\.tsx?$/,``);for(let e of lt){if(t.endsWith(`.${e}`))return e;let n=t.split(`.`);if(n.length>=2&&n[n.length-1]===e)return e}return null}function pt(e){if(!e.endsWith(`.tsx`))return!1;let t=e.replace(`.tsx`,``);return/^[A-Z][a-zA-Z0-9]*$/.test(t)}function mt(e){if(!e.endsWith(`.ts`)&&!e.endsWith(`.tsx`))return!1;let t=e.replace(/\.tsx?$/,``);return/^use[A-Z][a-zA-Z0-9]*$/.test(t)}function ht(e){for(let t of[`.test.ts`,`.test.tsx`,`.spec.ts`,`.spec.tsx`])if(e.endsWith(t)){let n=t.endsWith(`.tsx`)?`.tsx`:`.ts`;return e.replace(t,n)}return e}const w={name:`base`,isSpecialFile(e){return!!(ct.includes(e)||e.endsWith(`.d.ts`)||dt(e))},getNamingRules(){return[...st,...ot,C]},shouldSkipTypeSuffix(e){let t=ht(e);return!!(ct.includes(t)||t.endsWith(`.d.ts`)||dt(t)||pt(t)||mt(t)||!ft(t)&&ut(t))}},T=[`page.tsx`,`page.ts`,`layout.tsx`,`layout.ts`,`loading.tsx`,`loading.ts`,`error.tsx`,`error.ts`,`not-found.tsx`,`not-found.ts`,`template.tsx`,`template.ts`,`default.tsx`,`default.ts`,`global-error.tsx`,`global-error.ts`,`middleware.ts`,`route.ts`],E={name:`nextjs`,isSpecialFile(e){return T.includes(e)},getNamingRules(){return[]},shouldSkipTypeSuffix(e){return T.includes(e)}},gt=[/^\[.+\]\.tsx?$/,/^_layout\.tsx?$/,/^\(.+\)\.tsx?$/],_t=[`_layout.tsx`,`_layout.ts`,`_sitemap.tsx`,`_sitemap.ts`],D={name:`expo-router`,isSpecialFile(e){return _t.includes(e)?!0:gt.some(t=>t.test(e))},getNamingRules(){return[]},shouldSkipTypeSuffix(e){return this.isSpecialFile(e)}};function vt(...e){return{name:e.map(e=>e.name).join(`+`),isSpecialFile(t,n){return e.some(e=>e.isSpecialFile(t,n))},getNamingRules(){return e.flatMap(e=>e.getNamingRules())},shouldSkipTypeSuffix(t){return e.some(e=>e.shouldSkipTypeSuffix(t))}}}const yt=new Map;function O(e){yt.set(e.name,e)}O(w),O(E),O(D);function k(e){return/^[A-Z][a-zA-Z0-9]*$/.test(e)}function bt(e){return/^[a-z][a-zA-Z0-9]*$/.test(e)}function A(e){return/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/.test(e)}function xt(e){return e.split(`.`).every(e=>A(e)&&e.length>0)}function St(e){return e.split(`.`).every(e=>A(e)&&e.length>0)}function Ct(e,t){if(e.endsWith(`.types`)&&t===`kebab-case`)return xt(e);switch(t){case`PascalCase`:return k(e);case`camelCase`:return bt(e);case`kebab-case`:return A(e);case`kebab-case-test`:return St(e);default:return!1}}const j=new WeakMap;function M(e,t){if(!t)try{return u.default.existsSync(e)}catch{return!1}let n=j.get(t);if(n||(n=new Map,j.set(t,n)),n.has(e))return n.get(e);let r;try{r=u.default.existsSync(e)}catch{r=!1}return n.set(e,r),r}function wt(e,t,n,r){let i=t.substring(6),a=l.default.dirname(i);return M(l.default.join(e,`pages`,a===`.`?``:a,n),r)}function Tt(e,t,n,r){let i=t.substring(11),a=l.default.dirname(i);return M(l.default.join(e,`components`,a===`.`?``:a,n),r)}function Et(e,t,n,r){let i=t.substring(14),a=l.default.dirname(i);return M(l.default.join(e,`ui`,`components`,a===`.`?``:a,n),r)}function Dt(e,t,n,r){let i=t.substring(6),a=l.default.dirname(i);return M(l.default.join(e,`react`,a===`.`?``:a,n),r)}function Ot(e,t,n){let r=e.indexOf(`/__tests__/`),i=e.substring(0,r),a=e.substring(r+11);return a.startsWith(`pages/`)?wt(i,a,t,n):a.startsWith(`components/`)?Tt(i,a,t,n):a.startsWith(`ui/components/`)?Et(i,a,t,n):a.startsWith(`react/`)?Dt(i,a,t,n):M(l.default.join(i,t),n)}function kt(e,t,n){let r=e.replace(/\\/g,`/`),i=r.includes(`/__tests__/`),a=r.includes(`/components/`);if(!a&&!i||!(t.endsWith(`.test.tsx`)||t.endsWith(`.spec.tsx`)||t.endsWith(`.test.ts`)||t.endsWith(`.spec.ts`)))return!1;let o=t.replace(/\.(test|spec)\.(tsx|ts)$/,`.tsx`);return i?Ot(r,o,n):a?M(l.default.join(l.default.dirname(e),o),n):!1}const N=new WeakMap;function At(e,t){if(!t)try{return u.default.existsSync(e)}catch{return!1}let n=N.get(t);if(n||(n=new Map,N.set(t,n)),n.has(e))return n.get(e);let r;try{r=u.default.existsSync(e)}catch{r=!1}return n.set(e,r),r}function jt(e,t,n){if(!e.replace(/\\/g,`/`).includes(`/components/`)||!t.endsWith(`.types.ts`))return!1;let r=t.replace(`.types.ts`,`.tsx`);return At(l.default.join(l.default.dirname(e),r),n)}function Mt(e,t){if(t===C)return e.replace(/\.tsx$/,``);let n=t.pattern.source;return n.startsWith(`^`)&&n.endsWith(`$`)?n.includes(`\\.test\\.`)||n.includes(`\\.spec\\.`)?e.replace(/\.(test|spec)\.(tsx?|jsx?)$/,``):n.includes(`\\.types\\.`)?e.replace(/\.types\.ts$/,``):e.replace(/\.[^.]+$/,``):e.replace(t.pattern,``)}const P={meta:{type:`problem`,docs:{description:`强制执行文件命名规范`},messages:{invalidFileName:`文件命名违规: {{fileName}}。{{description}}`},schema:[]},create(e){let t=e.filename,n=l.default.basename(t),r=S(e.settings?.platformNamingStrategy)?e.settings.platformNamingStrategy:w;if(r.isSpecialFile(n,t)||jt(t,n,e)&&k(n.replace(`.types.ts`,``))||kt(t,n,e)&&k(n.replace(/\.(test|spec)\.(tsx|ts)$/,``)))return{};let i=r.getNamingRules().find(e=>e.pattern.test(n));if(!i&&n.endsWith(`.tsx`)&&(i=C),!i)return{};let a=Mt(n,i);return Ct(n.endsWith(`.types.ts`)&&i.case===`kebab-case`?n.replace(/\.ts$/,``):a,i.case)||e.report({loc:{start:{line:1,column:0},end:{line:1,column:n.length}},messageId:`invalidFileName`,data:{fileName:n,description:i.description}}),{}}};function Nt(e){return e.endsWith(`.types.ts`)?!0:/^[a-z][a-z0-9-]*\.[a-z][a-z0-9-]*\.tsx?$/.test(e)||/^[a-z][a-z0-9-]*\.[a-z][a-z0-9-]*\.[a-z][a-z0-9-]*\.tsx?$/.test(e)}function Pt(e){let t=e.replace(/\.tsx?$/,``);for(let e of lt){if(t.endsWith(`.${e}`))return e;let n=t.split(`.`);if(n.length>=2&&n[n.length-1]===e)return e}return null}function Ft(e){let t=[],n=e.replace(/\.tsx?$/,``);return(n.includes(`service`)||n.includes(`Service`))&&t.push(`.service.ts`),(n.includes(`controller`)||n.includes(`Controller`))&&t.push(`.controller.ts`),(n.includes(`utils`)||n.includes(`helper`)||n.includes(`Helper`))&&t.push(`.utils.ts`),(n.includes(`constant`)||n.includes(`Constant`))&&t.push(`.constants.ts`),(n.includes(`config`)||n.includes(`Config`))&&t.push(`.config.ts`),(n.includes(`atom`)||n.includes(`state`)||n.includes(`State`))&&t.push(`.atom.ts`),t.length===0&&t.push(`.utils.ts`,`.config.ts`,`.constants.ts`),t}function It(e){for(let t of[`.test.ts`,`.test.tsx`,`.spec.ts`,`.spec.tsx`])if(e.endsWith(t)){let n=t.endsWith(`.tsx`)?`.tsx`:`.ts`;return e.replace(t,n)}return e}const F={meta:{type:`problem`,docs:{description:`强制执行文件类型后缀规范,确保文件名明确表达其用途`},messages:{missingTypeSuffix:`文件 "{{fileName}}" 缺少类型后缀。除特殊文件外,所有文件应使用 xxx.yyy.ts 格式明确表达用途。建议: {{suggestions}}`,forbiddenSuffix:`文件 "{{fileName}}" 使用了禁止的后缀 ".{{suffix}}"。该后缀语义过于泛化,无法表达文件用途。请使用更具体的后缀,如 ".utils"、".helpers"、".service" 等。`},schema:[]},create(e){let t=e.filename,n=l.default.basename(t);if((S(e.settings?.platformNamingStrategy)?e.settings.platformNamingStrategy:w).shouldSkipTypeSuffix(n))return{};let r=It(n),i=Pt(r);if(i)return e.report({loc:{start:{line:1,column:0},end:{line:1,column:n.length}},messageId:`forbiddenSuffix`,data:{fileName:n,suffix:i}}),{};if(Nt(r))return{};let a=Ft(r);return e.report({loc:{start:{line:1,column:0},end:{line:1,column:n.length}},messageId:`missingTypeSuffix`,data:{fileName:n,suggestions:a.join(`, `)}}),{}}},Lt=[/\/src\/renderer\//];function Rt(e){let t=e.replace(/\\/g,`/`);return Lt.some(e=>e.test(t))}function zt(e){if(!e.startsWith(`@longzai-intelligence/`))return!1;let t=e.split(`/`);if(t.length<2)return!1;let n=t[1];return n?n.endsWith(`-implementation`):!1}const I={meta:{type:`problem`,docs:{description:`禁止在 Electron renderer 进程中导入 Implementation 包`},messages:{implementationInRenderer:`禁止在 renderer 进程中导入 Implementation 包 "{{packageName}}"。Implementation 包包含 Node.js 特定代码,请在 main 进程中使用,或使用 Contract 包代替。`},schema:[]},create(e){let t=e.filename;return Rt(t)?{ImportDeclaration(t){let n=t.source.value;typeof n==`string`&&zt(n)&&e.report({node:t,messageId:`implementationInRenderer`,data:{packageName:n}})}}:{}}};function Bt(e){return typeof e==`object`&&!!e&&`alias`in e&&typeof e.alias==`string`&&`pathPattern`in e&&typeof e.pathPattern==`string`}function Vt(e){return Array.isArray(e)&&e.every(Bt)}const L=[{alias:`@main`,pathPattern:`src/main`},{alias:`@preload`,pathPattern:`src/preload`},{alias:`@renderer`,pathPattern:`src/renderer/src`},{alias:`@shared`,pathPattern:`src/shared`}];function R(e,t){let n=e.replace(/\\/g,`/`);for(let e of t){let t=e.pathPattern.replace(/\\/g,`/`);if(n.includes(`/${t}/`)||n.endsWith(`/${t}`)||n.includes(`/${t}\\`))return e.alias}return null}function Ht(e,t,n){if(!t.startsWith(`.`))return null;let r=e.replace(/\\/g,`/`),i=r.lastIndexOf(`/`),a=i>0?r.substring(0,i):``;return R(l.default.resolve(a,t).replace(/\\/g,`/`),n)}function Ut(e){return e.startsWith(`./`)||e.startsWith(`../`)}const z={meta:{type:`problem`,docs:{description:`禁止使用相对路径穿越不同包范围,强制使用别名导入`},messages:{noCrossPackageRelativeImport:`禁止使用相对路径跨包导入。当前文件位于 "{{currentPackage}}" 包,目标位于 "{{targetPackage}}" 包。请使用别名导入:{{targetPackage}}/...`},schema:[{type:`object`,properties:{packageBoundaries:{type:`array`,items:{type:`object`,properties:{alias:{type:`string`},pathPattern:{type:`string`}},required:[`alias`,`pathPattern`]}}},additionalProperties:!1}]},create(e){let t=e.filename,n=e.options[0],r=n&&typeof n==`object`?n:{},i=`packageBoundaries`in r&&Array.isArray(r.packageBoundaries)?r.packageBoundaries:L,a=Vt(i)?i:L,o=R(t,a);return o?{ImportDeclaration(n){let r=n.source.value;if(typeof r!=`string`||!Ut(r))return;let i=Ht(t,r,a);i&&o!==i&&e.report({node:n,messageId:`noCrossPackageRelativeImport`,data:{currentPackage:o,targetPackage:i}})}}:{}}},Wt=[/\.test\.ts$/,/\.test\.tsx$/,/\.spec\.ts$/,/\.spec\.tsx$/],Gt=[`/node_modules/`,`/dist/`,`/out/`,`/.bun/`],Kt=[{segment:`/templates/`,type:`templates`},{segment:`/domains/`,type:`domains`},{segment:`/packages/`,type:`packages`},{segment:`/infrastructure/`,type:`infrastructure`}],qt=[{segment:`/src/main/`,process:`main`},{segment:`/src/renderer/`,process:`renderer`},{segment:`/src/preload/`,process:`preload`},{segment:`/src/shared/`,process:`shared`}];function B(e){return e.replace(/\\/g,`/`)}function Jt(e){return Wt.some(t=>t.test(e))}function Yt(e){let t=B(e);return Gt.some(e=>t.includes(e))}function Xt(e){return e.isElectron&&e.electronProcess?`src/${e.electronProcess}/__tests__`:`src/__tests__`}function Zt(e,t){let n=B(e);return t.srcRoot?n.startsWith(`${t.srcRoot}/__tests__/`):!0}function Qt(e,t){let n=B(e),r=l.default.basename(e);if(!t.srcRoot)return`src/__tests__/${r}`;let i=n.indexOf(`/src/`);if(i===-1)return`${t.srcRoot}/__tests__/${r}`;let a=n.slice(i+5).split(`/`);if(a.length>1&&a.pop(),t.isElectron&&t.electronProcess){let e=a.indexOf(t.electronProcess);e!==-1&&a.splice(e,1)}let o=a.indexOf(`__tests__`);o!==-1&&a.splice(o,1);let s=a.join(`/`),c=Xt(t);return s?`${c}/${s}/${r}`:`${c}/${r}`}function $t(e,t){let n=e.indexOf(t),r=e.slice(n+t.length).split(`/`),i=r.findIndex(e=>e===`src`);if(i!==-1)return e.slice(0,n+t.length)+r.slice(0,i+1).join(`/`);let a=t===`/domains/`&&r.length>=2?`${r[0]}/${r[1]}`:r[0];return a?e.slice(0,n+t.length+a.length)+`/src`:e.slice(0,n+t.length)+`src`}function en(e){for(let t of qt)if(e.includes(t.segment))return{electronProcess:t.process,srcRoot:e.slice(0,e.indexOf(t.segment))+t.segment.slice(0,-1)};return{srcRoot:``}}function tn(e){return e.includes(`-desktop`)||e===`desktop`}function nn(e){let t=B(e);for(let e of Kt)if(t.includes(e.segment))return{type:e.type,isElectron:!1,srcRoot:$t(t,e.segment)};if(t.includes(`/database/`)){let e=t.indexOf(`/database/`);return{type:`database`,isElectron:!1,srcRoot:t.slice(0,e+10)+`src`}}if(!t.includes(`/apps/`))return{type:`unknown`,isElectron:!1,srcRoot:``};let n=t.indexOf(`/apps/`),r=t.slice(n+6).split(`/`)[0];if(!r)return{type:`unknown`,isElectron:!1,srcRoot:``};let i=t.slice(0,n+6+r.length)+`/src`;if(!tn(r))return{type:`apps`,isElectron:!1,srcRoot:i};let a=en(t);return{type:`apps`,isElectron:!0,electronProcess:a.electronProcess,srcRoot:a.srcRoot||i}}const rn={meta:{type:`problem`,docs:{description:`强制测试文件放置在 src/__tests__ 目录下`},messages:{invalidTestFileLocation:`测试文件 "{{fileName}}" 必须放置在 {{expectedDir}} 目录下。当前路径: "{{currentPath}}"。建议路径: "{{suggestedPath}}"`},schema:[]},create(e){let t=e.filename,n=l.default.basename(t);if(!Jt(n)||Yt(t)||n.endsWith(`.d.ts`))return{};let r=nn(t);if(r.type===`unknown`||Zt(t,r))return{};let i=Xt(r),a=Qt(t,r);return e.report({loc:{start:{line:1,column:0},end:{line:1,column:n.length}},messageId:`invalidTestFileLocation`,data:{fileName:n,expectedDir:i,currentPath:t,suggestedPath:a}}),{}}},an=[`**/vitest.setup.ts`,`**/jest.setup.ts`,`**/fixtures/**`,`**/helpers/**`,`**/mocks/**`,`**/__mocks__/**`,`**/*.d.ts`],on=[/\.test\.ts$/,/\.test\.tsx$/,/\.spec\.ts$/,/\.spec\.tsx$/];function sn(e){return on.some(t=>t.test(e))}function cn(e,t){let n=t.replace(/[.+^${}()|[\]\\]/g,`\\$&`).replace(/\*\*/g,`{{DOUBLE_STAR}}`).replace(/\*/g,`[^/]*`).replace(/{{DOUBLE_STAR}}/g,`.*`);return RegExp(`^${n}$`).test(e)}function ln(e,t){return t.some(t=>cn(e,t))}function un(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function dn(e){if(typeof e!=`object`||!e)return!1;if(!(`allowPatterns`in e))return!0;let t=e.allowPatterns;return Array.isArray(t)&&un(t)}const fn={meta:{type:`problem`,docs:{description:`禁止在 __tests__ 目录下放置非测试文件`},messages:{nonTestFileInTestsDirectory:`文件 "{{fileName}}" 位于 __tests__ 目录下但不是测试文件。测试目录应仅包含测试文件(*.test.ts, *.spec.ts)。如果是辅助文件,请移动到 src/test-helpers/ 或 src/testing/ 目录。`},schema:[{type:`object`,properties:{allowPatterns:{type:`array`,items:{type:`string`},description:`允许在 __tests__ 目录下的非测试文件 glob 模式`}},additionalProperties:!1}]},create(e){let t=[...an],n=e.options[0];dn(n)&&n.allowPatterns&&(t=[...an,...n.allowPatterns]);let r=e.filename,i=B(r),a=l.default.basename(r);return{Program(){i.includes(`/__tests__/`)&&(sn(a)||ln(i,t)||e.report({loc:{start:{line:1,column:0},end:{line:1,column:a.length}},messageId:`nonTestFileInTestsDirectory`,data:{fileName:a}}))}}}},pn=[/\.test\.ts$/,/\.test\.tsx$/,/\.spec\.ts$/,/\.spec\.tsx$/],V=[`.ts`,`.tsx`],mn=new Set([`node_modules`,`dist`,`out`,`.bun`,`.turbo`,`.cache`,`generated`]),hn=new WeakMap;function gn(e){return e.replace(/\\/g,`/`)}function _n(e,t){let n;try{n=u.default.readdirSync(e,{withFileTypes:!0})}catch{return}for(let r of n){let n=l.default.join(e,r.name);if(r.isDirectory()){if(mn.has(r.name))continue;_n(n,t)}else r.isFile()&&t(n)}}function H(e){return Wt.some(t=>t.test(e))}function vn(e){let t=gn(e);return Gt.some(e=>t.includes(e))}function yn(e){for(let t of pn)if(t.test(e))return e.replace(t,``);return e}function bn(e){let t=gn(e),n=t.indexOf(`/__tests__/`);return n===-1?l.default.dirname(e):t.substring(0,n)}function xn(e,t){for(let n of V){let r=l.default.join(t,e+n);if(u.default.existsSync(r))return r}return null}function Sn(e,t){let n=hn.get(e);if(n||(n=new Map,hn.set(e,n)),n.has(t))return n.get(t);let r=[];return _n(t,e=>r.push(e)),n.set(t,r),r}function Cn(e,t,n,r){let i=l.default.dirname(t),a=[i,l.default.dirname(i)];for(let t of a){let n=xn(e,t);if(n)return n}let o=[n,i];for(let t of o){if(!u.default.existsSync(t))continue;let n=Sn(r,t);for(let t of n){let n=l.default.basename(t);if(!H(n)){for(let r of V)if(n===e+r)return t}}}return null}function wn(e,t){let n=l.default.basename(e),r=yn(n),i=bn(e);if(Cn(r,e,i,t))return{isMatch:!0,suggestion:null};let a=On(i,e,t)[0];if(a){let e=l.default.basename(a,l.default.extname(a)),t=l.default.extname(n),r=n.includes(`.spec.`)?`.spec`:`.test`,i=t.replace(r,``);return{isMatch:!1,suggestion:e+r+i}}return{isMatch:!1,suggestion:null}}function Tn(e){return H(e)||e===`index.ts`||e===`index.tsx`||e.endsWith(`.d.ts`)?!1:V.some(t=>e.endsWith(t))}function En(e,t,n){if(u.default.existsSync(e))try{let r=u.default.readdirSync(e,{withFileTypes:!0});for(let i of r){if(!i.isFile())continue;let r=i.name;if(!Tn(r))continue;let a=l.default.join(e,r);n.has(a)||(t.push(a),n.add(a))}}catch{}}function Dn(e,t,n,r){if(!u.default.existsSync(e))return;let i=Sn(t,e);for(let e of i)Tn(l.default.basename(e))&&(r.has(e)||(n.push(e),r.add(e)))}function On(e,t,n){let r=l.default.dirname(t),i=l.default.dirname(r),a=[],o=new Set,s=[r,i];for(let e of s)En(e,a,o);if(a.length===0){let t=[e,r];for(let e of t)Dn(e,n,a,o)}return a}const kn={meta:{type:`problem`,docs:{description:`确保测试文件名与被测试的源文件名保持一致`},messages:{testFileNotMatchSource:`测试文件 "{{testFileName}}" 未找到匹配的源文件。测试文件名应与源文件名保持一致。{{suggestion}}`},schema:[]},create(e){let t=e.filename,n=l.default.basename(t);if(!H(n)||vn(t)||n.endsWith(`.d.ts`))return{};let r=wn(t,e);if(!r.isMatch){let t=r.suggestion?`建议重命名为 "${r.suggestion}"`:`请确保测试文件名与源文件名匹配(如 user.service.ts -> user.service.test.ts)`;e.report({loc:{start:{line:1,column:0},end:{line:1,column:n.length}},messageId:`testFileNotMatchSource`,data:{testFileName:n,suggestion:t}})}return{}}};function An(e){if(!e||typeof e!=`object`)return!1;let t=e;if(!(`type`in t)||t.type!==d.AST_NODE_TYPES.MemberExpression||!(`object`in t)||!t.object||!(`property`in t)||!t.property)return!1;let n=t.object,r=t.property;return!n||typeof n!=`object`||!r||typeof r!=`object`?!1:`type`in n&&n.type===d.AST_NODE_TYPES.Identifier&&`name`in n&&n.name===`window`&&`type`in r&&r.type===d.AST_NODE_TYPES.Identifier&&`name`in r&&r.name===`electron`}const jn={meta:{type:`problem`,docs:{description:`禁止在 Preload 中直接暴露 @electron-toolkit/preload 的 electronAPI`},messages:{noElectronApiImport:`禁止导入 @electron-toolkit/preload 的 electronAPI。`,noExposeElectronApi:`禁止执行 contextBridge.exposeInMainWorld("electron", electronAPI)。`,noWindowElectronApi:`禁止执行 window.electron = electronAPI。`},schema:[]},create(e){return{ImportDeclaration(t){if(t.source.value===`@electron-toolkit/preload`)for(let n of t.specifiers)n.type===`ImportSpecifier`&&n.imported.type===`Identifier`&&n.imported.name===`electronAPI`&&e.report({node:n,messageId:`noElectronApiImport`})},CallExpression(t){if(t.callee.type!==`MemberExpression`||t.callee.property.type!==`Identifier`||t.callee.property.name!==`exposeInMainWorld`||t.arguments.length<2)return;let[n,r]=t.arguments;n?.type===`Literal`&&n.value===`electron`&&r?.type===`Identifier`&&r.name===`electronAPI`&&e.report({node:t,messageId:`noExposeElectronApi`})},AssignmentExpression(t){t.left.type===`MemberExpression`&&An(t.left)&&t.right.type===`Identifier`&&t.right.name===`electronAPI`&&e.report({node:t,messageId:`noWindowElectronApi`})}}}};function Mn(e){let t=e.replace(/\\/g,`/`);return t.includes(`/src/preload/`)&&!t.includes(`/__tests__/`)}function U(e){return typeof e==`object`&&!!e}function Nn(e){if(!U(e))return null;let t=e.key;return U(t)?typeof t.name==`string`?t.name:typeof t.value==`string`?t.value:null:null}function Pn(e){return!U(e)||!Array.isArray(e.properties)?!1:e.properties.some(e=>{if(!U(e)||e.type!==`Property`)return!1;let t=Nn(e);return t===`on`||t===`send`||t===`invoke`})}const Fn={meta:{type:`problem`,docs:{description:`禁止在 Preload 暴露通用 ipc 桥接对象`},messages:{noIpcBridge:`禁止暴露通用 ipc 桥接对象(on/send/invoke)。请使用领域 API。`},schema:[]},create(e){return Mn(e.filename)?{Property(t){Nn(t)===`ipc`&&U(t.value)&&t.value.type===`ObjectExpression`&&Pn(t.value)&&e.report({node:t,messageId:`noIpcBridge`})}}:{}}};function In(e){let t=e.replace(/\\/g,`/`);return t.includes(`/src/preload/`)&&!t.includes(`/__tests__/`)&&!t.includes(`/src/preload/utils/`)}const Ln={meta:{type:`problem`,docs:{description:`禁止在 Preload 业务代码中直接调用 ipcRenderer`},messages:{noDirectCall:`禁止直接调用 ipcRenderer。请通过 createTypedAPI 或 invoke 封装。`},schema:[]},create(e){return In(e.filename)?{CallExpression(t){t.callee.type===`MemberExpression`&&t.callee.object.type===`Identifier`&&t.callee.object.name===`ipcRenderer`&&e.report({node:t,messageId:`noDirectCall`})}}:{}}};function W(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`Identifier`&&`name`in e&&typeof e.name==`string`}function Rn(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`Property`&&`value`in e&&e.value!==null&&typeof e.value==`object`&&W(e.value)}function zn(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`RestElement`&&`argument`in e&&e.argument!==null&&typeof e.argument==`object`&&W(e.argument)}function Bn(e){let t=[];if(!e||typeof e!=`object`)return t;if(W(e)&&t.push(e.name),`type`in e&&e.type===`ObjectPattern`&&`properties`in e&&Array.isArray(e.properties))for(let n of e.properties)!n||typeof n!=`object`||(Rn(n)?t.push(n.value.name):zn(n)&&t.push(n.argument.name));if(`type`in e&&e.type===`ArrayPattern`&&`elements`in e&&Array.isArray(e.elements))for(let n of e.elements)W(n)&&t.push(n.name);return t}function Vn(e){return`declaration`in e}function Hn(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`VariableDeclaration`&&`kind`in e&&`declarations`in e&&Array.isArray(e.declarations)}function Un(e){if(typeof e!=`object`||!e||!(`range`in e))return!1;let t=e.range;return Array.isArray(t)&&t.length===2}function Wn(e,t,n){return r=>{let i=t.declaration;if(!i||!Un(i)||!e.getTokenBefore(i))return null;let a=e.getText(i),o=n.join(`, `),s=e.getText(t).match(/^(\s*)/),c=s?s[1]:``,l=`${a}`,u=`${c}export { ${o} };`;return r.replaceText(t,`${l}\n${u}`)}}const Gn={meta:{type:`suggestion`,docs:{description:`将 export const/let/var 拆分为独立的声明和导出语句,以便 JSDoc 正确插入`,recommended:!0},fixable:`code`,schema:[],messages:{preferSplitExport:"应将 `export {{kind}} {{names}}` 拆分为独立的声明和导出语句,以便 JSDoc 正确插入注释"}},create(e){let t=e.sourceCode;return{ExportNamedDeclaration(n){if(!Vn(n)||!n.declaration||!Hn(n.declaration))return;let r=n.declaration;if(r.kind!==`const`&&r.kind!==`let`&&r.kind!==`var`)return;let i=r.declarations;if(i.length===0)return;let a=[];i.forEach(e=>{a.push(...Bn(e.id))}),a.length!==0&&e.report({node:n,messageId:`preferSplitExport`,data:{kind:r.kind,names:a.join(`, `)},fix:Wn(t,n,a)})}}}};function Kn(e){return typeof e==`object`&&!!e&&`name`in e&&typeof e.name==`string`&&(!(`severity`in e)||e.severity===`error`||e.severity===`warn`||e.severity===void 0)&&(!(`description`in e)||typeof e.description==`string`||e.description===void 0)}function qn(e){return Array.isArray(e)&&e.every(Kn)}function Jn(e){if(typeof e!=`object`||!e)return!1;if(!(`directories`in e))return!0;let t=e.directories;return Array.isArray(t)&&qn(t)}const Yn=[{name:`apps`,severity:`error`,description:`应用层目录`},{name:`domains`,severity:`error`,description:`领域层目录`},{name:`packages`,severity:`error`,description:`技术层目录`},{name:`infrastructure`,severity:`warn`,description:`基础设施层目录`},{name:`templates`,severity:`warn`,description:`模板层目录`},{name:`docs`,severity:`warn`,description:`文档层目录`}];function Xn(e,t){return(0,u.existsSync)((0,l.join)(e,t,`README.md`))}function Zn(e){return e.cwd}const Qn=new WeakMap;function $n(e){let t=Qn.get(e);return t||(t=new Set,Qn.set(e,t)),t}const er={meta:{type:`problem`,docs:{description:`检查分层目录是否包含 README.md 文件`},messages:{missingReadmeError:`分层目录 "{{directory}}" ({{description}}) 缺少 README.md 文件。分层目录必须包含 README.md 文件,阐明该层职责。`,missingReadmeWarn:`分层目录 "{{directory}}" ({{description}}) 建议添加 README.md 文件,阐明该层职责。`},schema:[{type:`object`,properties:{directories:{type:`array`,items:{type:`object`,properties:{name:{type:`string`},severity:{type:`string`,enum:[`error`,`warn`]},description:{type:`string`}},required:[`name`]}}},additionalProperties:!1}]},create(e){let t=Zn(e),n=$n(e),r=Yn,i=e.options[0];return Jn(i)&&i.directories&&(r=i.directories),{Program(i){if(!n.has(t)){n.add(t);for(let n of r){let r=n.name;if((0,u.existsSync)((0,l.join)(t,r))&&!Xn(t,r)){let t=(n.severity||`error`)===`error`?`missingReadmeError`:`missingReadmeWarn`;e.report({node:i,messageId:t,data:{directory:r,description:n.description||r}})}}}}}}},tr=[{suffix:`.service.drizzle.ts`,classSuffix:`Service`,isInterface:!1,isPrefix:!1},{suffix:`.service.memory.ts`,classSuffix:`Service`,isInterface:!1,isPrefix:!1},{suffix:`.service.ts`,classSuffix:`Service`,isInterface:!1,isPrefix:!1},{suffix:`.controller.ts`,classSuffix:`Controller`,isInterface:!1,isPrefix:!1},{suffix:`.module.ts`,classSuffix:`Module`,isInterface:!1,isPrefix:!1},{suffix:`.repository.drizzle.ts`,classSuffix:`Repository`,isInterface:!1,isPrefix:!1},{suffix:`.repository.memory.ts`,classSuffix:`Repository`,isInterface:!1,isPrefix:!1},{suffix:`.repository.interface.ts`,classSuffix:`Repository`,isInterface:!0,isPrefix:!0},{suffix:`.repository.ts`,classSuffix:`Repository`,isInterface:!1,isPrefix:!1},{suffix:`.entity.ts`,classSuffix:`Entity`,isInterface:!1,isPrefix:!1},{suffix:`.orm-entity.ts`,classSuffix:`OrmEntity`,isInterface:!1,isPrefix:!1},{suffix:`.dto.ts`,classSuffix:`DTO`,isInterface:!1,isPrefix:!1},{suffix:`.port.interface.ts`,classSuffix:`Port`,isInterface:!0,isPrefix:!0},{suffix:`.interface.ts`,classSuffix:``,isInterface:!0,isPrefix:!0},{suffix:`.port.ts`,classSuffix:`Port`,isInterface:!0,isPrefix:!1},{suffix:`.port.adapter.ts`,classSuffix:`PortAdapter`,isInterface:!1,isPrefix:!1},{suffix:`.adapter.ts`,classSuffix:`Adapter`,isInterface:!1,isPrefix:!1},{suffix:`.events.ts`,classSuffix:`Event`,isInterface:!1,isPrefix:!1},{suffix:`.mapper.ts`,classSuffix:`Mapper`,isInterface:!1,isPrefix:!1},{suffix:`.vo.ts`,classSuffix:`VO`,isInterface:!1,isPrefix:!1},{suffix:`.usecase.ts`,classSuffix:`UseCase`,isInterface:!1,isPrefix:!1},{suffix:`.errors.ts`,classSuffix:`Error`,isInterface:!1,isPrefix:!1}];function nr(e){for(let t of tr)if(e.endsWith(t.suffix))return t;return null}function rr(e,t){if(t.isPrefix&&t.isInterface){if(t.classSuffix){let n=t.classSuffix;return e.startsWith(`I`)&&e.endsWith(n)&&e.length>1+n.length}return e.startsWith(`I`)&&e.length>1}return t.isPrefix?e.startsWith(`I`)&&e.length>1:e.endsWith(t.classSuffix)&&e.length>t.classSuffix.length}function ir(e){return e.isPrefix&&e.isInterface?e.classSuffix?`I${e.classSuffix}(如 IUser${e.classSuffix})`:`I 前缀(如 IUser)`:e.isPrefix?`I 前缀(如 IUser)`:`${e.classSuffix} 后缀`}function ar(e,t,n,r){if(!(0,c.hasIdWithName)(e))return;let i=e.id.name;n.isInterface||rr(i,n)||t.report({node:e,messageId:`invalidClassName`,data:{className:i,fileName:r,expectedFormat:ir(n)}})}function or(e,t,n,r){if(!n.isInterface||!(0,c.hasIdWithName)(e))return;let i=e.id.name;rr(i,n)||t.report({node:e,messageId:`invalidInterfaceName`,data:{interfaceName:i,fileName:r,expectedFormat:ir(n)}})}function sr(e){let t=e.filename,n=l.default.basename(t);if(n.endsWith(`.test.ts`)||n.endsWith(`.spec.ts`))return{};let r=nr(n);return r?{ClassDeclaration(t){ar(t,e,r,n)},TSInterfaceDeclaration(t){or(t,e,r,n)}}:{}}const cr={meta:{type:`problem`,docs:{description:`强制执行类名与文件类型后缀的一致性`},messages:{invalidClassName:`类名 "{{className}}" 不符合命名规范。文件 "{{fileName}}" 中的类应使用 {{expectedFormat}}`,invalidInterfaceName:`接口名 "{{interfaceName}}" 不符合命名规范。文件 "{{fileName}}" 中的接口应使用 {{expectedFormat}}`},schema:[]},create:sr},lr=[`types.ts`,`types.d.ts`],ur=[`.port.interface.ts`,`.repository.interface.ts`,`.types.ts`,`.types.d.ts`,`.events.ts`];function dr(e,t){return(0,c.hasIPrefix)(e)?!1:t.endsWith(`.dto.ts`)?(0,c.isValidDtoNameUpperCase)(e):!0}function fr(e){return e.endsWith(`.dto.ts`)?`DTO 后缀(如 UserDTO),禁止 I 前缀`:`PascalCase(如 User、UserRepository),禁止 I 前缀`}function pr(e){if(lr.includes(e))return!0;for(let t of ur)if(e.endsWith(t))return!0;return!1}function mr(e){return e.endsWith(`.port.ts`)?e.replace(`.port.ts`,`.port.interface.ts`):e.endsWith(`.repository.ts`)?e.replace(`.repository.ts`,`.repository.interface.ts`):e.replace(`.ts`,`.interface.ts`)}function hr(e,t){return t.endsWith(`Dto`)?(0,c.createDtoSuffixFixer)(e,t,!0):null}function gr(e,t,n,r){if(dr(n,r))return;if((0,c.hasIPrefix)(n)){e.report({node:t,messageId:`invalidIPrefix`,data:{interfaceName:n,suggestedName:n.substring(1)},fix:(0,c.createRemoveIPrefixFixer)(t,n)});return}let i=hr(t,n);i?e.report({node:t,messageId:`invalidDtoSuffix`,data:{interfaceName:n},fix:i}):e.report({node:t,messageId:`invalidInterfaceName`,data:{interfaceName:n,expectedFormat:fr(r)}})}function _r(e,t,n,r,i){i||r.endsWith(`.dto.ts`)||e.report({node:t,messageId:`invalidFileName`,data:{fileName:r,interfaceName:n,expectedFileName:mr(r)}})}function vr(e,t,n,r){if(!(0,c.hasIdWithNameAndRange)(t))return;let i=t.id.name;gr(e,t,i,n),_r(e,t,i,n,r)}function yr(e){let t=e.filename,n=l.default.basename(t);if(n.endsWith(`.test.ts`)||n.endsWith(`.spec.ts`)||pr(n))return{};let r=n.endsWith(`.interface.ts`);return{TSInterfaceDeclaration(t){vr(e,t,n,r)}}}const br={meta:{type:`problem`,docs:{description:`强制执行接口命名规范(禁止 I 前缀,使用 PascalCase)和文件命名规范(xxx.interface.ts)`},messages:{invalidIPrefix:`接口名 "{{interfaceName}}" 使用了 I 前缀。现代 TypeScript 不推荐使用匈牙利命名法,建议使用 "{{suggestedName}}"`,invalidInterfaceName:`接口名 "{{interfaceName}}" 不符合命名规范。接口名应使用 {{expectedFormat}}`,invalidDtoSuffix:`接口名 "{{interfaceName}}" 后缀应使用 DTO(全大写)而非 Dto(驼峰式)`,invalidFileName:`包含接口 "{{interfaceName}}" 的文件 "{{fileName}}" 应命名为 "{{expectedFileName}}"`},schema:[],fixable:`code`},create:yr},xr=[`.types.ts`,`.types.d.ts`];function Sr(e){return xr.some(t=>e.endsWith(t))}function Cr(e){let t=e.filename,n=l.default.basename(t);return n.endsWith(`.test.ts`)||n.endsWith(`.spec.ts`)||!Sr(n)?{}:{TSInterfaceDeclaration(t){if(!(0,c.hasIdWithNameAndRange)(t))return;let n=t.id.name;(0,c.hasIPrefix)(n)&&e.report({node:t,messageId:`invalidIPrefix`,data:{interfaceName:n,suggestedName:n.substring(1)},fix:(0,c.createRemoveIPrefixFixer)(t,n)})}}}const wr={meta:{type:`problem`,docs:{description:`强制执行 types 文件中的接口命名规范(禁止 I 前缀)`},messages:{invalidIPrefix:`类型文件中的接口名 "{{interfaceName}}" 使用了 I 前缀。现代 TypeScript 不推荐使用匈牙利命名法,建议使用 "{{suggestedName}}"`},schema:[],fixable:`code`},create:Cr};function Tr(e){return e.endsWith(`.dto.ts`)}function Er(e){return e.endsWith(`DTO`)}function Dr(e){let t=e.filename,n=l.default.basename(t);return n.endsWith(`.test.ts`)||n.endsWith(`.spec.ts`)||!Tr(n)?{}:{TSInterfaceDeclaration(t){if(!(0,c.hasIdWithNameAndRange)(t))return;let n=t.id.name;Er(n)?e.report({node:t,messageId:`invalidDtoSuffix`,data:{interfaceName:n},fix:(0,c.createDtoSuffixFixer)(t,n,!1)}):(0,c.isValidDtoNameCamelCase)(n)||e.report({node:t,messageId:`missingDtoSuffix`,data:{interfaceName:n}})}}}const Or={meta:{type:`problem`,docs:{description:`强制执行 DTO 文件中的接口命名规范(Dto 后缀,驼峰式)`},messages:{invalidDtoSuffix:`接口名 "{{interfaceName}}" 后缀应使用 Dto(驼峰式)而非 DTO(全大写)`,missingDtoSuffix:`DTO 文件中的接口名 "{{interfaceName}}" 应以 Dto 结尾(如 UserResponseDto)`},schema:[],fixable:`code`},create:Dr},G=`@longzai-intelligence/config/tsup`,kr=`definePackageConfig`,Ar=[`defineConfig`];function jr(e){return{ImportDeclaration(t){if(!(0,c.isImportDeclaration)(t))return;let n=t.source.value;for(let r of t.specifiers){if(!(0,c.isImportSpecifier)(r))continue;let i=r.imported.name;if(Ar.includes(i)){if(n===`tsup`){e.report({node:t,messageId:`forbiddenTsupImport`,data:{importedName:i,correctExportName:kr,configPackage:G}});continue}n===G&&e.report({node:t,messageId:`forbiddenConfigImport`,data:{importedName:i,correctExportName:kr,configPackage:G}})}}}}}const Mr={meta:{type:`problem`,docs:{description:`强制执行 tsup.config.ts 文件中的配置导入规范,必须使用 definePackageConfig`},messages:{forbiddenTsupImport:`禁止从 tsup 包导入 {{importedName}}。应使用 {{correctExportName}} 从 {{configPackage}} 导入`,forbiddenConfigImport:`禁止从 {{configPackage}} 导入 {{importedName}}。应使用 {{correctExportName}}`},schema:[]},create:jr},K=`@longzai-intelligence/tsdown-config`,Nr=[`defineDomainImplementationConfig`,`defineDomainContractConfig`,`defineSharedKernelConfig`,`defineReactComponentsConfig`,`defineConfigPackageConfig`,`definePackageConfig`],Pr=[`defineConfig`];function Fr(e){return{ImportDeclaration(t){if(!(0,c.isImportDeclaration)(t))return;let n=t.source.value;for(let r of t.specifiers){if(!(0,c.isImportSpecifier)(r))continue;let i=r.imported.name;if(Pr.includes(i)){if(n===`tsdown`){e.report({node:t,messageId:`forbiddenTsdownImport`,data:{importedName:i,presetNames:Nr.join(`、`),configPackage:K}});continue}n===K&&e.report({node:t,messageId:`forbiddenConfigImport`,data:{importedName:i,presetNames:Nr.join(`、`),configPackage:K}})}}}}}const Ir={meta:{type:`problem`,docs:{description:`强制执行 tsdown.config.ts 文件中的配置导入规范,必须使用预设函数`},messages:{forbiddenTsdownImport:`禁止从 tsdown 包导入 {{importedName}}。应使用预设函数({{presetNames}})从 {{configPackage}} 导入`,forbiddenConfigImport:`禁止从 {{configPackage}} 导入 {{importedName}}。应使用预设函数({{presetNames}})`},schema:[]},create:Fr},q=[`@longzai-intelligence/config/vitest`,`@longzai-intelligence/vitest-config`],J=[`createBaseVitestConfig`,`createDomainVitestConfig`,`createDomainUIVitestConfig`,`createPackageVitestConfig`,`createTypeOnlyVitestConfig`,`createDesktopVitestConfig`,`createWebVitestConfig`,`defineVitestConfig`,`defineDomainVitestConfig`,`defineDomainUIVitestConfig`,`definePackageVitestConfig`,`defineTypeOnlyVitestConfig`,`defineDesktopVitestConfig`,`defineWebVitestConfig`],Lr=[`defineConfig`],Rr=[`infrastructure/configs/vitest/vitest.config.ts`];function zr(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`ExportDefaultDeclaration`&&`declaration`in e&&e.declaration!==null&&typeof e.declaration==`object`}function Br(e){return e.endsWith(`vitest.config.ts`)}function Vr(e,t,n){if(!(0,c.isImportDeclaration)(e))return;let r=e.source.value;for(let t of e.specifiers){if(!(0,c.isImportSpecifier)(t))continue;let i=t.imported.name;if(r===`vitest`&&Lr.includes(i)){n.hasForbiddenImport=!0,n.forbiddenImportNode=e,n.forbiddenImportName=i;continue}q.includes(r)&&J.includes(i)&&(n.hasValidImport=!0)}}function Hr(e,t){return!t.hasForbiddenImport||!t.forbiddenImportNode?!1:(e.report({node:t.forbiddenImportNode,messageId:`forbiddenVitestImport`,data:{importedName:t.forbiddenImportName,configPackages:q.join(` 或 `),allowedExports:J.join(`, `)}}),!0)}function Ur(e,t,n){if(!(0,c.isCallExpressionNode)(e))return!1;let r=e.callee.name;return typeof r==`string`&&!J.includes(r)&&!n.hasValidImport?(t.report({node:e,messageId:`invalidConfigFunction`,data:{configPackages:q.join(` 或 `),allowedExports:J.join(`, `)}}),!0):!1}function Wr(e,t,n){return(0,c.isObjectExpressionNode)(e)?n.hasValidImport?!1:(t.report({node:e,messageId:`invalidConfigObject`,data:{configPackages:q.join(` 或 `),allowedExports:J.join(`, `)}}),!0):!1}function Gr(e,t,n){if(!zr(e))return;n.hasExportDefault=!0;let r=e.declaration;Hr(t,n)||Ur(r,t,n)||Wr(r,t,n)}function Kr(e,t){if(!t.hasExportDefault){let t=e.sourceCode.ast;e.report({node:t,messageId:`missingConfigImport`,data:{configPackages:q.join(` 或 `),allowedExports:J.join(`, `)}})}}function qr(e){let t=e.filename;if(!Br(t)||(0,c.isInExcludedPath)(t,Rr))return{};let n={hasValidImport:!1,hasForbiddenImport:!1,hasExportDefault:!1,forbiddenImportNode:null,forbiddenImportName:``};return{ImportDeclaration(t){Vr(t,e,n)},ExportDefaultDeclaration(t){Gr(t,e,n)},"Program:exit"(){Kr(e,n)}}}const Jr={meta:{type:`problem`,docs:{description:`强制执行 vitest.config.ts 文件中的配置导入规范,必须使用共享配置函数`},messages:{forbiddenVitestImport:`禁止从 vitest 包导入 {{importedName}}。应使用共享配置函数({{allowedExports}})从 {{configPackages}} 导入`,invalidConfigFunction:`必须使用共享配置函数({{allowedExports}})从 {{configPackages}} 导入`,missingConfigImport:`vitest.config.ts 必须使用共享配置函数({{allowedExports}})从 {{configPackages}} 导入`},schema:[]},create:qr},Y=`@longzai-intelligence/config/eslint`,X=[`createLibraryConfig`,`createDomainConfig`,`createReactConfig`,`createReactPluginConfig`,`createElectronConfig`,`createNextConfig`,`createNodeConfig`,`createMcpConfig`,`createNestConfig`,`createHonoConfig`,`createExpoConfig`],Yr=[`coreConfig`,`createCoreConfig`,`libraryConfig`,`domainConfig`,`reactConfig`,`electronConfig`,`nextConfig`,`nodeConfig`,`mcpConfig`,`nestConfig`,`honoConfig`,`expoConfig`];function Xr(e,t){e.report({node:t,messageId:`forbiddenDefaultImport`,data:{configPackage:Y,allowedFunctions:X.join(`、`)}})}function Zr(e,t){e.report({node:t,messageId:`forbiddenNamespaceImport`,data:{configPackage:Y,allowedFunctions:X.join(`、`)}})}function Qr(e,t,n){e.report({node:t,messageId:`forbiddenConfigImport`,data:{importedName:n,allowedFunctions:X.join(`、`)}})}function $r(e,t){e.report({node:t,messageId:`missingCreateFunction`,data:{configPackage:Y,allowedFunctions:X.join(`、`)}})}function ei(e,t){if(!(0,c.isImportDeclaration)(t)||t.source.value!==Y)return;let n=[],r=[],i=!1;for(let a of t.specifiers)if((0,c.isImportSpecifier)(a)){if((0,c.isDefaultImport)(a)){Xr(e,t),i=!0;continue}if(a.type===`ImportNamespaceSpecifier`){Zr(e,t),i=!0;continue}Yr.includes(a.imported.name)?r.push(a):X.includes(a.imported.name)&&n.push(a)}if(!i){for(let n of r)Qr(e,t,n.imported.name);r.length===0&&n.length===0&&(t.specifiers.some(e=>(0,c.isImportSpecifier)(e)&&e.type===`ImportSpecifier`&&!X.includes(e.imported.name)&&!Yr.includes(e.imported.name))||$r(e,t))}}function ti(e){return{ImportDeclaration(t){ei(e,t)}}}const ni={meta:{type:`problem`,docs:{description:`强制执行 eslint.config.ts 文件中的配置导入规范,必须使用 createXxxConfig 函数`},messages:{forbiddenDefaultImport:`禁止从 {{configPackage}} 使用默认导入。应使用具名导入 {{allowedFunctions}} 等配置创建函数`,forbiddenNamespaceImport:`禁止从 {{configPackage}} 使用命名空间导入。应使用具名导入 {{allowedFunctions}} 等配置创建函数`,forbiddenConfigImport:`禁止从配置包导入 {{importedName}}。应使用 {{allowedFunctions}} 等配置创建函数`,missingCreateFunction:`必须从 {{configPackage}} 导入至少一个配置创建函数(如 {{allowedFunctions}})`},schema:[]},create:ti},ri=[`./tsconfig/app.json`,`./tsconfig/node.json`,`./tsconfig/test.json`],ii=[`app.json`,`node.json`,`test.json`,`build.json`];function ai(e){return typeof e==`object`&&!!e&&`path`in e&&typeof e.path==`string`}function oi(e){return Array.isArray(e)&&e.every(ai)}function si(e){return!(typeof e!=`object`||!e)}function ci(e){try{let t=(0,u.readFileSync)(e,`utf-8`);return JSON.parse(t)}catch{return null}}function li(e){let t=e.map(e=>e.path);return ri.filter(e=>!t.includes(e))}function ui(e){return e.map(e=>e.path).filter(e=>!ri.includes(e))}const di=new WeakMap;function fi(e,t){let n=di.get(e);if(n||(n=new Map,di.set(e,n)),n.has(t))return n.get(t);let r=(0,u.existsSync)(t),i={hasDir:r,missingFiles:r?pi(t):[]};return n.set(t,i),i}function pi(e){return ii.filter(t=>!(0,u.existsSync)((0,l.join)(e,t)))}function mi(e,t,n){if(!n.references||!oi(n.references)){e.report({node:t,messageId:`missingReferences`});return}let r=li(n.references);r.length>0&&e.report({node:t,messageId:`missingRequiredReference`,data:{missingPath:r[0]}});let i=ui(n.references);for(let n of i)e.report({node:t,messageId:`extraReference`,data:{extraPath:n}})}function hi(e,t,n){return n.files===void 0?!0:Array.isArray(n.files)?n.files.length===0?!0:(e.report({node:t,messageId:`filesMustBeEmpty`}),!1):(e.report({node:t,messageId:`filesMustBeArray`}),!1)}const gi={meta:{type:`problem`,docs:{description:`检查 tsconfig.json 是否正确使用 references 配置`},messages:{missingReferences:`tsconfig.json 必须使用 references 配置,采用目录收拢多配置模式。请添加 references 字段,包含 app.json、node.json、test.json 三个配置。`,missingRequiredReference:`tsconfig.json 的 references 缺少必需的配置: "{{missingPath}}"。references 必须包含 ./tsconfig/app.json、./tsconfig/node.json、./tsconfig/test.json。`,filesMustBeEmpty:`tsconfig.json 使用 references 时,files 必须为空数组 "[]"。请将 files 设置为空数组或移除 files 字段。`,filesMustBeArray:`tsconfig.json 使用 references 时,files 必须为数组类型。请将 files 设置为空数组 "[]"。`,missingTsconfigDirectory:`缺少 tsconfig/ 目录。请创建 tsconfig/ 目录并添加 app.json、node.json、test.json、build.json 配置文件。`,missingConfigFile:`tsconfig/ 目录缺少必需的配置文件: {{missingFiles}}。必需的配置文件包括: app.json、node.json、test.json、build.json。`,extraReference:`tsconfig.json 的 references 包含非必需的配置: "{{extraPath}}"。references 应仅包含 ./tsconfig/app.json、./tsconfig/node.json、./tsconfig/test.json。`},schema:[]},create(e){let t=e.filename;if(!t.endsWith(`tsconfig.json`)||t.includes(`tsconfig/`))return{};let n=(0,l.join)((0,l.dirname)(t),`tsconfig`);return{Program(r){let i=ci(t);if(!si(i))return;let a=fi(e,n);if(!a.hasDir){e.report({node:r,messageId:`missingTsconfigDirectory`});return}if(a.missingFiles.length>0){e.report({node:r,messageId:`missingConfigFile`,data:{missingFiles:a.missingFiles.join(`, `)}});return}hi(e,r,i)&&mi(e,r,i)}}}};function _i(e){let t=e.replace(/\\/g,`/`);return t.includes(`/src/preload/`)&&!t.includes(`/__tests__/`)}const Z={meta:{type:`problem`,docs:{description:`禁止使用字符串字面量作为 IPC 通道名`},messages:{noStringLiteral:`禁止使用字符串字面量作为 IPC 通道名。请使用通道常量。`},schema:[]},create(e){return _i(e.filename)?{CallExpression(t){if(t.callee.type!==`Identifier`||t.callee.name!==`invoke`||t.arguments.length===0)return;let n=t.arguments[0];n&&n.type===`Literal`&&typeof n.value==`string`&&e.report({node:n,messageId:`noStringLiteral`})},ObjectExpression(t){if(t.parent?.type===`CallExpression`&&t.parent.callee.type===`Identifier`&&t.parent.callee.name===`createTypedAPI`)for(let n of t.properties)n.type===`Property`&&n.value.type===`Literal`&&typeof n.value.value==`string`&&e.report({node:n.value,messageId:`noStringLiteral`})}}:{}}};function vi(e){let t=e.replace(/\\/g,`/`);return t.endsWith(`/src/preload/index.ts`)&&!t.includes(`/__tests__/`)}function yi(e){let t=e.parent;for(;t;){if(t.type===`CallExpression`&&t.callee.type===`Identifier`&&t.callee.name===`exposeSafeAPI`)return!0;t=t.parent}return!1}const bi={meta:{type:`problem`,docs:{description:`要求使用 exposeSafeAPI 进行 API 暴露`},messages:{requireExposeSafeApi:`请使用 exposeSafeAPI 进行 API 暴露,而非直接调用 contextBridge.exposeInMainWorld。`},schema:[]},create(e){return vi(e.filename)?{CallExpression(t){t.callee.type===`MemberExpression`&&t.callee.object.type===`Identifier`&&t.callee.object.name===`contextBridge`&&t.callee.property.type===`Identifier`&&t.callee.property.name===`exposeInMainWorld`&&(yi(t)||e.report({node:t,messageId:`requireExposeSafeApi`}))}}:{}}};function xi(e){let t=e.replace(/\\/g,`/`);return t.includes(`/src/preload/utils/`)&&!t.includes(`/__tests__/`)}function Si(e){return e.startsWith(`createTyped`)}const Ci={meta:{type:`problem`,docs:{description:`禁止自定义 IPC 工具函数`},messages:{noCustomIPC:`禁止自定义 IPC 工具函数。请使用 @longzai-intelligence/electron/preload 提供的标准函数。`},schema:[]},create(e){return xi(e.filename)?{FunctionDeclaration(t){t.id&&Si(t.id.name)&&e.report({node:t,messageId:`noCustomIPC`})},VariableDeclaration(t){for(let n of t.declarations){if(n.id.type!==`Identifier`||!Si(n.id.name))continue;let r=n.init;r&&(r.type===`FunctionExpression`||r.type===`ArrowFunctionExpression`)&&e.report({node:t,messageId:`noCustomIPC`})}}}:{}}},wi=new Set([`unwrap`,`unwrapIPCResult`]);function Ti(e){let t=e.replace(/\\/g,`/`);return t.includes(`/src/renderer/`)&&!t.includes(`/__tests__/`)&&!t.endsWith(`.test.ts`)&&!t.endsWith(`.spec.ts`)}function Ei(e){if(e.type!==`CallExpression`)return!1;let{callee:t}=e;if(t.type!==`MemberExpression`)return!1;let{object:n}=t;return n.type===`MemberExpression`?n.object.type===`Identifier`&&n.object.name===`window`:!1}function Di(e){let t=e.parent;for(;t;){if(t.type===`CallExpression`&&t.callee.type===`Identifier`&&wi.has(t.callee.name))return!0;if(t.type===`CallExpression`)break;t=t.parent}return!1}const Oi={meta:{type:`problem`,docs:{description:`渲染层调用 IPC API 时必须使用 unwrap 解包结果`},messages:{requireUnwrap:`渲染层调用 IPC API 时必须使用 unwrap 或 unwrapIPCResult 解包结果。`},schema:[]},create(e){return Ti(e.filename)?{CallExpression(t){Ei(t)&&(Di(t)||e.report({node:t,messageId:`requireUnwrap`}))}}:{}}};function ki(e){return e.endsWith(`Class`)}function Ai(e,t){if(typeof t!=`object`||!t||!(`imported`in t)||!(`local`in t)||t.local===null||typeof t.local!=`object`||!(`name`in t.local)||typeof t.local.name!=`string`||!(`range`in t.local)||!Array.isArray(t.local.range))return;let n=t.local.name,r=t.imported!==null&&typeof t.imported==`object`&&`name`in t.imported&&typeof t.imported.name==`string`?t.imported.name:n;n!==r&&ki(n)&&e.report({node:t,messageId:`noClassSuffixAlias`,data:{aliasName:n,importedName:r}})}function ji(e){return{ImportSpecifier(t){Ai(e,t)}}}const Mi={meta:{type:`problem`,docs:{description:`禁止在 import 别名中使用 "Class" 后缀`},messages:{noClassSuffixAlias:`导入别名 "{{aliasName}}" 使用了 "Class" 后缀,这是不允许的命名方式。请使用更具描述性的名称,或直接使用原始名称 "{{importedName}}"`},schema:[]},create:ji},Ni=/domains\/[^/]+\/implementation\/src\/index\.ts$/,Pi=[/\.\/typeorm/,/\.\/typeorm'/,/\.\/typeorm"/];function Fi(e){return Pi.some(t=>t.test(e))}const Ii={meta:{type:`problem`,docs:{description:`Implementation 包导出控制:禁止从主入口重新导出 typeorm.ts 的内容,typeorm.ts 仅供 DataSource/迁移基础设施使用`,recommended:!0},schema:[],messages:{forbiddenTypeormReExport:`禁止从主入口重新导出 typeorm.ts 的内容。typeorm.ts 是专门的持久化入口,仅供 DataSource/迁移基础设施使用,业务代码应通过主入口导入领域服务`}},create(e){let t=e.filename;return Ni.test(t)?{ExportNamedDeclaration(t){if(!t.source)return;let n=t.source.value;typeof n==`string`&&Fi(n)&&e.report({node:t,messageId:`forbiddenTypeormReExport`})},ExportAllDeclaration(t){if(!t.source)return;let n=t.source.value;typeof n==`string`&&Fi(n)&&e.report({node:t,messageId:`forbiddenTypeormReExport`})}}:{}}},Li={type:`suggestion`,docs:{description:`强制 domain entities 导出命名符合 {DOMAIN}_ORM_ENTITIES 规范`,recommended:!0},fixable:void 0,schema:[],messages:{invalidNaming:`entities 导出命名 "{{name}}" 不符合规范,应使用 "{{expected}}" 格式`,genericNaming:`entities 导出命名 "{{name}}" 是通用名称,应使用具体的 domain 名称 "{{expected}}"`,missingOrm:`entities 导出命名 "{{name}}" 缺少 "_ORM" 前缀,应使用 "{{expected}}"`,typoDetected:`entities 导出命名 "{{name}}" 可能存在拼写错误,应使用 "{{expected}}"`}},Ri=new Set([`DOMAIN_ENTITIES`,`ALL_ENTITIES`,`ENTITIES`]);function zi(e){let t=e.match(/\/domains\/([^/]+)\/implementation\/src\/typeorm\.ts$/);return!t||!t[1]?null:t[1].split(`-`).map(e=>e.toUpperCase()).join(`_`)}function Bi(e,t){return e.endsWith(`_ORM_ENTITIES`)?!1:e.endsWith(`_ENTITIES`)?e.replace(`_ENTITIES`,``)===t.replace(`_ORM_ENTITIES`,``):!1}function Vi(e){return Ri.has(e)}function Hi(e,t){let n=e.length,r=t.length,i=[];for(let a=0;a<=n;a++){i[a]=[];for(let n=0;n<=r;n++)a===0?i[a][n]=n:n===0?i[a][n]=a:e[a-1]===t[n-1]?i[a][n]=i[a-1][n-1]:i[a][n]=Math.min(i[a-1][n-1],i[a][n-1],i[a-1][n])+1}return i[n][r]}function Ui(e,t){let n=e.replace(`_ORM_ENTITIES`,``).replace(`_ENTITIES`,``),r=t.replace(`_ORM_ENTITIES`,``);return n===r?!1:n.toLowerCase()===r.toLowerCase()?!0:Hi(n,r)<=2}function Wi(e,t,n,r){Bi(n,r)?e.report({node:t,messageId:`missingOrm`,data:{name:n,expected:r}}):Vi(n)?e.report({node:t,messageId:`genericNaming`,data:{name:n,expected:r}}):Ui(n,r)?e.report({node:t,messageId:`typoDetected`,data:{name:n,expected:r}}):e.report({node:t,messageId:`invalidNaming`,data:{name:n,expected:r}})}function Gi(e,t,n,r){if(typeof n!=`object`||!n||!(`id`in n)||n.id===null||typeof n.id!=`object`||!(`type`in n.id)||n.id.type!==`Identifier`||!(`name`in n.id)||typeof n.id.name!=`string`)return;let i=n.id.name;!i.endsWith(`_ENTITIES`)&&!i.endsWith(`_ORM_ENTITIES`)||i!==r&&Wi(e,t,i,r)}function Ki(e,t,n,r){if(typeof n!=`object`||!n||!(`exported`in n)||n.exported===null||typeof n.exported!=`object`||!(`type`in n.exported)||n.exported.type!==`Identifier`||!(`name`in n.exported)||typeof n.exported.name!=`string`)return;let i=n.exported.name;!i.endsWith(`_ENTITIES`)&&!i.endsWith(`_ORM_ENTITIES`)||i!==r&&Wi(e,t,i,r)}function qi(e,t){function n(n){if(typeof n==`object`&&n&&`declaration`in n&&n.declaration!==null&&typeof n.declaration==`object`&&`type`in n.declaration&&n.declaration.type===`VariableDeclaration`&&`declarations`in n.declaration&&Array.isArray(n.declaration.declarations))for(let r of n.declaration.declarations)Gi(e,n,r,t);if(typeof n==`object`&&n&&`specifiers`in n&&Array.isArray(n.specifiers))for(let r of n.specifiers)Ki(e,n,r,t)}return n}function Ji(e){let t=e.filename;if(!t.endsWith(`typeorm.ts`))return{};let n=zi(t);return n?{ExportNamedDeclaration:qi(e,`${n}_ORM_ENTITIES`)}:{}}const Yi={meta:Li,create:Ji};function Xi(e){return e.replace(/\\/g,`/`).includes(`/apps/`)}function Zi(e){return e.endsWith(`-implementation`)}function Qi(e){return e.endsWith(`Entity`)}function $i(e){return e.endsWith(`UseCase`)}function ea(e){return[/PortAdapter$/,/_TOKEN$/,/^create\w+Repository$/,/^create\w+Adapter$/].some(t=>t.test(e))}const ta={noEntityImport:`禁止在 apps 层导入 Entity 类 "{{importName}}"。请使用 contract 包的 Port 接口进行操作。`,noUseCaseImport:`禁止在 apps 层导入 UseCase 类 "{{importName}}"。请使用 contract 包的 Port 接口进行操作。`,noImplementationImport:`禁止在 apps 层从 implementation 包导入 "{{importName}}"。请使用 contract 包的 Port 接口。`};function na(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`ImportSpecifier`}function ra(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`Identifier`&&`name`in e&&typeof e.name==`string`}function ia(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`Literal`&&`value`in e&&typeof e.value==`string`}function aa(e){if(!(`imported`in e)||e.imported===null||typeof e.imported!=`object`)return null;let t=e.imported;return ra(t)?t.name:ia(t)?t.value:null}function oa(e,t,n){Qi(n)?e.report({node:t,messageId:`noEntityImport`,data:{importName:n}}):$i(n)?e.report({node:t,messageId:`noUseCaseImport`,data:{importName:n}}):ea(n)||e.report({node:t,messageId:`noImplementationImport`,data:{importName:n}})}function sa(e,t,n){if(!na(t))return;let r=aa(t);r&&oa(e,t,r)}const ca={meta:{type:`problem`,docs:{description:`禁止在 apps 层导入 implementation 包的 Entity 和 UseCase`},messages:ta,schema:[]},create(e){let t=e.filename;return Xi(t)?{ImportDeclaration(t){if(!(`source`in t)||t.source===null||typeof t.source!=`object`||!(`type`in t.source)||t.source.type!==`Literal`||!(`value`in t.source)||typeof t.source.value!=`string`)return;let n=t.source.value;if(Zi(n)&&!(!(`specifiers`in t)||!Array.isArray(t.specifiers)))for(let r of t.specifiers)na(r)&&sa(e,r,n)}}:{}}};var Q=`0.0.2`;function la(e){let t=e.replace(/\\/g,`/`);return t.includes(`/domains/`)&&t.includes(`/implementation/src/index.ts`)}function ua(e){return e.endsWith(`Entity`)}function da(e){return e.endsWith(`Repository`)&&!e.startsWith(`I`)}function fa(e){return e.endsWith(`OrmEntity`)}function pa(e){return e.endsWith(`_ORM_ENTITIES`)}function ma(e){return e.endsWith(`OrmMapper`)}function ha(e){return e.endsWith(`Schema`)}function ga(e){return`exportKind`in e&&typeof e.exportKind==`string`?e.exportKind===`value`:!0}function _a(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`ExportSpecifier`}function va(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`Identifier`&&`name`in e&&typeof e.name==`string`}function ya(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`Literal`&&`value`in e&&typeof e.value==`string`}function ba(e){if(typeof e!=`object`||!e||!(`exported`in e)||e.exported===null||typeof e.exported!=`object`)return null;let t=e.exported;return va(t)?t.name:ya(t)?t.value:null}function $(e,t,n,r){e.report({node:t,messageId:n,data:{exportName:r}})}function xa(e,t,n){return ua(n)&&ga(t)?($(e,t,`noEntityValueExport`,n),!0):!1}function Sa(e,t,n){return da(n)?($(e,t,`noRepositoryTypeExport`,n),!0):!1}function Ca(e,t,n){return fa(n)?($(e,t,`noOrmEntityExport`,n),!0):pa(n)?($(e,t,`noOrmEntitiesExport`,n),!0):ma(n)?($(e,t,`noOrmMapperExport`,n),!0):!1}function wa(e,t,n){ha(n)&&$(e,t,`noSchemaExport`,n)}function Ta(e,t,n){xa(e,t,n)||Sa(e,t,n)||Ca(e,t,n)||wa(e,t,n)}function Ea(e,t){if(!(!(`source`in t)||t.source===null||typeof t.source!=`object`||!(`type`in t.source)||t.source.type!==`Literal`||!(`value`in t.source)||typeof t.source.value!=`string`)&&!(!(`specifiers`in t)||!Array.isArray(t.specifiers)))for(let n of t.specifiers){if(!_a(n))continue;let t=ba(n);t&&Ta(e,n,t)}}const Da={meta:{type:`problem`,docs:{description:`检查 Domain Implementation 包的导出是否符合规范`},messages:{noEntityValueExport:'禁止从主入口值导出 Entity 类 "{{exportName}}"。请改为类型导出:`export type { {{exportName}} }` 或移除导出。',noRepositoryTypeExport:`禁止导出 Repository 类型 "{{exportName}}"。Repository 是内部实现,不应暴露给外部。请移除此导出。`,noOrmEntityExport:`禁止从主入口导出 ORM 实体 "{{exportName}}"。请创建 src/typeorm.ts 入口文件,从该入口导出 ORM 实体。`,noOrmEntitiesExport:`禁止从主入口导出 ORM 实体集合 "{{exportName}}"。请创建 src/typeorm.ts 入口文件,从该入口导出。`,noOrmMapperExport:`禁止导出 ORM Mapper "{{exportName}}"。ORM Mapper 是基础设施实现细节,不应暴露给外部。请移除此导出。`,noSchemaExport:`禁止导出 Schema 定义 "{{exportName}}"。Schema 是实现细节,应完全保留在 Domain 内部。请仅导出从 Schema 推断的类型。`},schema:[]},create(e){let t=e.filename;return la(t)?{ExportNamedDeclaration(t){Ea(e,t)}}:{}}},Oa={meta:{name:`@longzai-intelligence/architecture-core`,version:Q},rules:{"dependency-direction":ve,"no-core-types-in-apps":_,"business-leak":We,"file-naming":P,"require-type-suffix":F,"no-cross-package-relative-import":z,"prefer-split-export-const":Gn,"require-class-suffix":cr,"require-interface-naming":br,"require-type-naming":wr,"require-dto-naming":Or,"no-class-suffix-alias":Mi,"implementation-export-control":Ii,"no-implementation-import-in-apps":ca,"domain-export-compliance":Da}},ka={meta:{name:`@longzai-intelligence/architecture-domain`,version:Q},rules:{"domain-export":et,"domain-typeorm-import":at,"layer-readme-required":er,"require-domain-entities-naming":Yi}},Aa={meta:{name:`@longzai-intelligence/architecture-electron`,version:Q},rules:{"platform-leak":Me,"no-implementation-in-renderer":I,"no-unsafe-electron-api-exposure":jn,"no-generic-ipc-bridge-exposure":Fn,"no-direct-ipcrenderer-in-preload":Ln,"tsconfig-references":gi,"require-typed-ipc-channel":Z,"require-expose-safe-api":bi,"no-custom-ipc-utility":Ci,"require-unwrap-ipc-result":Oi}},ja={meta:{name:`@longzai-intelligence/architecture-library`,version:Q},rules:{"test-file-placement":rn,"no-non-test-files-in-tests-directory":fn,"test-file-matches-source":kn,"require-tsup-config-import":Mr,"require-tsdown-config-import":Ir,"require-vitest-config-import":Jr,"require-eslint-config-import":ni}},Ma={meta:{name:`@longzai-intelligence/architecture`,version:Q},rules:{"dependency-direction":ve,"no-core-types-in-apps":_,"platform-leak":Me,"business-leak":We,"domain-export":et,"domain-typeorm-import":at,"file-naming":P,"require-type-suffix":F,"no-implementation-in-renderer":I,"no-cross-package-relative-import":z,"test-file-placement":rn,"no-non-test-files-in-tests-directory":fn,"test-file-matches-source":kn,"no-unsafe-electron-api-exposure":jn,"no-generic-ipc-bridge-exposure":Fn,"no-direct-ipcrenderer-in-preload":Ln,"prefer-split-export-const":Gn,"layer-readme-required":er,"require-class-suffix":cr,"require-interface-naming":br,"require-type-naming":wr,"require-dto-naming":Or,"require-tsup-config-import":Mr,"require-tsdown-config-import":Ir,"require-vitest-config-import":Jr,"require-eslint-config-import":ni,"tsconfig-references":gi,"require-typed-ipc-channel":Z,"require-expose-safe-api":bi,"no-custom-ipc-utility":Ci,"require-unwrap-ipc-result":Oi,"no-class-suffix-alias":Mi,"implementation-export-control":Ii,"require-domain-entities-naming":Yi,"no-implementation-import-in-apps":ca}};exports.DEFAULT_ARCHITECTURE_CONFIG=p,exports.architectureCorePlugin=Oa,exports.architectureDomainPlugin=ka,exports.architectureElectronPlugin=Aa,exports.architectureLibraryPlugin=ja,exports.architecturePlugin=Ma,exports.default=Ma,exports.baseStrategy=w,exports.composeStrategies=vt,exports.expoRouterStrategy=D,exports.isPlatformNamingStrategy=S,exports.nextJsStrategy=E;
package/dist/index.d.cts CHANGED
@@ -1,23 +1,81 @@
1
1
  import { ESLint } from "eslint";
2
2
 
3
3
  //#region src/plugins/core/index.d.ts
4
- declare const CORE_PLUGIN_NAME = "@longzai-intelligence/architecture-core";
5
4
  declare const architectureCorePlugin: ESLint.Plugin;
6
5
  //#endregion
7
6
  //#region src/plugins/domain/index.d.ts
8
- declare const DOMAIN_PLUGIN_NAME = "@longzai-intelligence/architecture-domain";
9
7
  declare const architectureDomainPlugin: ESLint.Plugin;
10
8
  //#endregion
11
9
  //#region src/plugins/electron/index.d.ts
12
- declare const ELECTRON_PLUGIN_NAME = "@longzai-intelligence/architecture-electron";
13
10
  declare const architectureElectronPlugin: ESLint.Plugin;
14
11
  //#endregion
15
12
  //#region src/plugins/library/index.d.ts
16
- declare const LIBRARY_PLUGIN_NAME = "@longzai-intelligence/architecture-library";
17
13
  declare const architectureLibraryPlugin: ESLint.Plugin;
18
14
  //#endregion
15
+ //#region src/rules/dependency-direction/types/layer.types.d.ts
16
+ type LayerName = 'types' | 'utils' | 'shared-kernel' | 'contract' | 'engine' | 'platform' | 'infrastructure' | 'implementation';
17
+ //#endregion
18
+ //#region src/rules/dependency-direction/types/config.types.d.ts
19
+ type PathPatternConfig = {
20
+ pattern: RegExp;
21
+ layer: LayerName;
22
+ };
23
+ type PackageSuffixMapping = {
24
+ suffix: string;
25
+ layer: LayerName;
26
+ };
27
+ type ArchitectureConfig = {
28
+ pathPatterns?: PathPatternConfig[];
29
+ packagePrefix?: string;
30
+ specialPackageMappings?: Record<string, LayerName>;
31
+ packageSuffixMappings?: PackageSuffixMapping[];
32
+ };
33
+ type DependencyDirectionRuleOptions = {
34
+ pathPatterns?: Array<{
35
+ pattern: string;
36
+ layer: LayerName;
37
+ }>;
38
+ packagePrefix?: string;
39
+ specialPackageMappings?: Record<string, string>;
40
+ packageSuffixMappings?: Array<{
41
+ suffix: string;
42
+ layer: string;
43
+ }>;
44
+ };
45
+ //#endregion
46
+ //#region src/rules/dependency-direction/constants/default-config.constants.d.ts
47
+ declare const DEFAULT_ARCHITECTURE_CONFIG: ArchitectureConfig;
48
+ //#endregion
49
+ //#region src/rules/file-naming/types.d.ts
50
+ type FileNameCase = 'PascalCase' | 'camelCase' | 'kebab-case' | 'kebab-case-test';
51
+ type FileNamingRule = {
52
+ pattern: RegExp;
53
+ case: FileNameCase;
54
+ description: string;
55
+ };
56
+ //#endregion
57
+ //#region src/rules/file-naming/strategies/strategy.types.d.ts
58
+ type PlatformNamingStrategy = {
59
+ readonly name: string;
60
+ isSpecialFile(fileName: string, filePath?: string): boolean;
61
+ getNamingRules(): FileNamingRule[];
62
+ shouldSkipTypeSuffix(fileName: string): boolean;
63
+ };
64
+ declare function isPlatformNamingStrategy(value: unknown): value is PlatformNamingStrategy;
65
+ //#endregion
66
+ //#region src/rules/file-naming/strategies/base.strategy.d.ts
67
+ declare const baseStrategy: PlatformNamingStrategy;
68
+ //#endregion
69
+ //#region src/rules/file-naming/strategies/nextjs.strategy.d.ts
70
+ declare const nextJsStrategy: PlatformNamingStrategy;
71
+ //#endregion
72
+ //#region src/rules/file-naming/strategies/expo-router.strategy.d.ts
73
+ declare const expoRouterStrategy: PlatformNamingStrategy;
74
+ //#endregion
75
+ //#region src/rules/file-naming/strategies/compose.utils.d.ts
76
+ declare function composeStrategies(...strategies: PlatformNamingStrategy[]): PlatformNamingStrategy;
77
+ //#endregion
19
78
  //#region src/index.d.ts
20
- declare const PLUGIN_NAME = "@longzai-intelligence/architecture";
21
79
  declare const architecturePlugin: ESLint.Plugin;
22
80
  //#endregion
23
- export { CORE_PLUGIN_NAME, DOMAIN_PLUGIN_NAME, ELECTRON_PLUGIN_NAME, LIBRARY_PLUGIN_NAME, PLUGIN_NAME, architectureCorePlugin, architectureDomainPlugin, architectureElectronPlugin, architectureLibraryPlugin, architecturePlugin };
81
+ export { type ArchitectureConfig, DEFAULT_ARCHITECTURE_CONFIG, type DependencyDirectionRuleOptions, type PackageSuffixMapping, type PathPatternConfig, type PlatformNamingStrategy, architectureCorePlugin, architectureDomainPlugin, architectureElectronPlugin, architectureLibraryPlugin, architecturePlugin, architecturePlugin as default, baseStrategy, composeStrategies, expoRouterStrategy, isPlatformNamingStrategy, nextJsStrategy };
package/dist/index.d.mts CHANGED
@@ -1,23 +1,81 @@
1
1
  import { ESLint } from "eslint";
2
2
 
3
3
  //#region src/plugins/core/index.d.ts
4
- declare const CORE_PLUGIN_NAME = "@longzai-intelligence/architecture-core";
5
4
  declare const architectureCorePlugin: ESLint.Plugin;
6
5
  //#endregion
7
6
  //#region src/plugins/domain/index.d.ts
8
- declare const DOMAIN_PLUGIN_NAME = "@longzai-intelligence/architecture-domain";
9
7
  declare const architectureDomainPlugin: ESLint.Plugin;
10
8
  //#endregion
11
9
  //#region src/plugins/electron/index.d.ts
12
- declare const ELECTRON_PLUGIN_NAME = "@longzai-intelligence/architecture-electron";
13
10
  declare const architectureElectronPlugin: ESLint.Plugin;
14
11
  //#endregion
15
12
  //#region src/plugins/library/index.d.ts
16
- declare const LIBRARY_PLUGIN_NAME = "@longzai-intelligence/architecture-library";
17
13
  declare const architectureLibraryPlugin: ESLint.Plugin;
18
14
  //#endregion
15
+ //#region src/rules/dependency-direction/types/layer.types.d.ts
16
+ type LayerName = 'types' | 'utils' | 'shared-kernel' | 'contract' | 'engine' | 'platform' | 'infrastructure' | 'implementation';
17
+ //#endregion
18
+ //#region src/rules/dependency-direction/types/config.types.d.ts
19
+ type PathPatternConfig = {
20
+ pattern: RegExp;
21
+ layer: LayerName;
22
+ };
23
+ type PackageSuffixMapping = {
24
+ suffix: string;
25
+ layer: LayerName;
26
+ };
27
+ type ArchitectureConfig = {
28
+ pathPatterns?: PathPatternConfig[];
29
+ packagePrefix?: string;
30
+ specialPackageMappings?: Record<string, LayerName>;
31
+ packageSuffixMappings?: PackageSuffixMapping[];
32
+ };
33
+ type DependencyDirectionRuleOptions = {
34
+ pathPatterns?: Array<{
35
+ pattern: string;
36
+ layer: LayerName;
37
+ }>;
38
+ packagePrefix?: string;
39
+ specialPackageMappings?: Record<string, string>;
40
+ packageSuffixMappings?: Array<{
41
+ suffix: string;
42
+ layer: string;
43
+ }>;
44
+ };
45
+ //#endregion
46
+ //#region src/rules/dependency-direction/constants/default-config.constants.d.ts
47
+ declare const DEFAULT_ARCHITECTURE_CONFIG: ArchitectureConfig;
48
+ //#endregion
49
+ //#region src/rules/file-naming/types.d.ts
50
+ type FileNameCase = 'PascalCase' | 'camelCase' | 'kebab-case' | 'kebab-case-test';
51
+ type FileNamingRule = {
52
+ pattern: RegExp;
53
+ case: FileNameCase;
54
+ description: string;
55
+ };
56
+ //#endregion
57
+ //#region src/rules/file-naming/strategies/strategy.types.d.ts
58
+ type PlatformNamingStrategy = {
59
+ readonly name: string;
60
+ isSpecialFile(fileName: string, filePath?: string): boolean;
61
+ getNamingRules(): FileNamingRule[];
62
+ shouldSkipTypeSuffix(fileName: string): boolean;
63
+ };
64
+ declare function isPlatformNamingStrategy(value: unknown): value is PlatformNamingStrategy;
65
+ //#endregion
66
+ //#region src/rules/file-naming/strategies/base.strategy.d.ts
67
+ declare const baseStrategy: PlatformNamingStrategy;
68
+ //#endregion
69
+ //#region src/rules/file-naming/strategies/nextjs.strategy.d.ts
70
+ declare const nextJsStrategy: PlatformNamingStrategy;
71
+ //#endregion
72
+ //#region src/rules/file-naming/strategies/expo-router.strategy.d.ts
73
+ declare const expoRouterStrategy: PlatformNamingStrategy;
74
+ //#endregion
75
+ //#region src/rules/file-naming/strategies/compose.utils.d.ts
76
+ declare function composeStrategies(...strategies: PlatformNamingStrategy[]): PlatformNamingStrategy;
77
+ //#endregion
19
78
  //#region src/index.d.ts
20
- declare const PLUGIN_NAME = "@longzai-intelligence/architecture";
21
79
  declare const architecturePlugin: ESLint.Plugin;
22
80
  //#endregion
23
- export { CORE_PLUGIN_NAME, DOMAIN_PLUGIN_NAME, ELECTRON_PLUGIN_NAME, LIBRARY_PLUGIN_NAME, PLUGIN_NAME, architectureCorePlugin, architectureDomainPlugin, architectureElectronPlugin, architectureLibraryPlugin, architecturePlugin };
81
+ export { type ArchitectureConfig, DEFAULT_ARCHITECTURE_CONFIG, type DependencyDirectionRuleOptions, type PackageSuffixMapping, type PathPatternConfig, type PlatformNamingStrategy, architectureCorePlugin, architectureDomainPlugin, architectureElectronPlugin, architectureLibraryPlugin, architecturePlugin, architecturePlugin as default, baseStrategy, composeStrategies, expoRouterStrategy, isPlatformNamingStrategy, nextJsStrategy };
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{createDtoSuffixFixer as e,createRemoveIPrefixFixer as t,hasIPrefix as n,hasIdWithName as r,hasIdWithNameAndRange as i,isCallExpressionNode as a,isDefaultImport as o,isImportDeclaration as s,isImportSpecifier as c,isInExcludedPath as ee,isObjectExpressionNode as l,isValidDtoNameCamelCase as te,isValidDtoNameUpperCase as ne}from"@longzai-intelligence/eslint-utils";import u,{dirname as re,join as d}from"node:path";import f,{existsSync as p,readFileSync as ie}from"node:fs";import{AST_NODE_TYPES as m}from"@typescript-eslint/utils";const h={types:0,utils:1,"shared-kernel":2,contract:3,engine:4,platform:5,infrastructure:6,implementation:6},ae=[{pattern:/\/domains\/[^/]+\/implementation\//,layer:`implementation`},{pattern:/\/domains\/[^/]+\/contract\//,layer:`contract`},{pattern:/\/domains\/shared-kernel\//,layer:`shared-kernel`},{pattern:/\/infrastructure\//,layer:`infrastructure`},{pattern:/\/packages\/utils\//,layer:`utils`},{pattern:/\/packages\/errors\//,layer:`utils`},{pattern:/\/packages\/zod-utils\//,layer:`utils`},{pattern:/\/packages\/testing-utils\//,layer:`utils`},{pattern:/\/packages\/engine\/[^/]+\//,layer:`engine`},{pattern:/\/packages\/design-system\/primitives\//,layer:`utils`},{pattern:/\/packages\/design-system\/composites\//,layer:`implementation`},{pattern:/\/packages\/design-system\/utils\//,layer:`utils`},{pattern:/\/packages\/electron\//,layer:`implementation`},{pattern:/\/packages\/typeorm-adapter\//,layer:`implementation`},{pattern:/\/packages\/typeorm-utils\//,layer:`utils`},{pattern:/\/packages\/http-client\//,layer:`utils`},{pattern:/\/packages\/pagination\//,layer:`utils`},{pattern:/\/packages\/turbo-output-parser\//,layer:`utils`},{pattern:/\/packages\/host-contracts\//,layer:`contract`},{pattern:/\/packages\/event-bus\/contract\//,layer:`contract`},{pattern:/\/packages\/event-bus\/implementation\//,layer:`implementation`},{pattern:/\/packages\/payment\/core\//,layer:`contract`},{pattern:/\/packages\/payment\/adapters\//,layer:`implementation`},{pattern:/\/packages\/payment\/presets\//,layer:`implementation`},{pattern:/\/packages\/logger\/core\//,layer:`contract`},{pattern:/\/packages\/logger\/adapters\//,layer:`implementation`},{pattern:/\/packages\/logger\/presets\//,layer:`implementation`},{pattern:/\/packages\/react-devtools\/core\//,layer:`contract`},{pattern:/\/packages\/react-devtools\/adapters\//,layer:`implementation`},{pattern:/\/packages\/react-devtools\/ui\//,layer:`implementation`},{pattern:/\/packages\/react-devtools\/presets\//,layer:`implementation`},{pattern:/\/packages\/feed-parser\/protocol\//,layer:`contract`},{pattern:/\/packages\/feed-parser\/[^/]+\//,layer:`implementation`}],oe=[{pattern:/\/src\/domain\//,layer:`contract`},{pattern:/\/src\/engine\//,layer:`engine`},{pattern:/\/src\/platform\//,layer:`platform`},{pattern:/\/src\/infrastructure\//,layer:`infrastructure`},{pattern:/\/src\/shared\//,layer:`shared-kernel`}],se=[{pattern:/\/src\/domain\//,layer:`contract`},{pattern:/\/src\/engine\//,layer:`engine`},{pattern:/\/src\/platform\//,layer:`platform`},{pattern:/\/src\/infrastructure\//,layer:`infrastructure`},{pattern:/\/src\/shared\//,layer:`shared-kernel`}],ce=new WeakMap;function le(e){let t=e.replace(/\\/g,`/`);for(let{pattern:e,layer:n}of ae)if(e.test(t))return{layer:n,priority:h[n]};return t.includes(`/apps/`)?de(t):t.includes(`/packages/`)?fe(t):null}function ue(e,t){let n=ce.get(t);if(n||(n=new Map,ce.set(t,n)),n.has(e))return n.get(e);let r=le(e);return n.set(e,r),r}function de(e){for(let{pattern:t,layer:n}of oe)if(t.test(e))return{layer:n,priority:h[n]};return null}function fe(e){for(let{pattern:t,layer:n}of se)if(t.test(e))return{layer:n,priority:h[n]};return null}const pe=[{suffix:`-contract`,layer:`contract`},{suffix:`-implementation`,layer:`implementation`},{suffix:`-engine`,layer:`engine`},{suffix:`-runtime`,layer:`engine`}],me={"@longzai-intelligence/shared-kernel":`shared-kernel`,"@longzai-intelligence/utils":`utils`,"@longzai-intelligence/error-utils":`utils`,"@longzai-intelligence/zod-utils":`utils`,"@longzai-intelligence/testing-utils":`utils`,"@longzai-intelligence/host-contracts":`contract`,"@longzai-intelligence/typeorm-adapter":`implementation`,"@longzai-intelligence/typeorm-utils":`utils`,"@longzai-intelligence/http-client":`utils`,"@longzai-intelligence/pagination":`utils`,"@longzai-intelligence/turbo-output-parser":`utils`,"@longzai-intelligence/electron":`implementation`},he=`@longzai-intelligence/`;function ge(e){if(!e.startsWith(he))return null;let t=e.split(`/`)[1];if(!t)return null;let n=me[`${he}${t}`];if(n)return{layer:n,priority:h[n]};for(let{suffix:e,layer:n}of pe)if(t.endsWith(e))return{layer:n,priority:h[n]};return null}const _e={types:`类型层 (Types)`,utils:`工具层 (Utils)`,"shared-kernel":`共享内核层 (Shared Kernel)`,contract:`契约层 (Contract)`,engine:`引擎层 (Engine)`,platform:`平台层 (Platform)`,infrastructure:`基础设施层 (Infrastructure)`,implementation:`实现层 (Implementation)`};function ve(e){return _e[e]}function ye(e,t){return h[e]>=h[t]}const be={meta:{type:`problem`,docs:{description:`强制执行 Clean Architecture 的依赖方向规则`},messages:{invalidDependency:`依赖方向违规: {{currentLayer}} ({{currentLayerName}}) 不能导入 {{importLayer}} ({{importLayerName}})。依赖应该从外层指向内层,请检查导入语句。`},schema:[]},create(e){let t=e.filename,n=ue(t,e);return n?{ImportDeclaration(t){let r=t.source.value;if(typeof r!=`string`)return;let i=ge(r);i&&(ye(n.layer,i.layer)||e.report({node:t,messageId:`invalidDependency`,data:{currentLayer:n.layer,currentLayerName:ve(n.layer),importLayer:i.layer,importLayerName:ve(i.layer)}}))}}:{}}},xe=new Set(`Agent.Page.PageContent.Workspace.WorkspaceMember.User.Session.Task.Repository.Folder.SyncMetadata.SyncError.SyncErrorCode.SyncResult.SyncStatus.SyncConflictData.EntityChange.OfflineOperation.DirtyEntity.PullResult.PushResult.ApiResponse.P2PNode.ConnectionState.NetworkStatus.IMAgent.IMContact.IMConversation.IMMessage.IMGroup.IMGroupSettings`.split(`.`));function Se(e){return e.replace(/\\/g,`/`).includes(`/apps/`)}function g(e){return xe.has(e)}const _={meta:{type:`problem`,docs:{description:`禁止在 apps 层定义核心领域类型`},messages:{noCoreTypesInApps:`禁止在 apps 层定义核心领域类型 "{{typeName}}"。请在 packages/types 或 packages/domain 中定义此类型。`},schema:[]},create(e){let t=e.filename;return Se(t)?{TSInterfaceDeclaration(t){if(!r(t))return;let n=t.id.name;g(n)&&e.report({node:t,messageId:`noCoreTypesInApps`,data:{typeName:n}})},TSTypeAliasDeclaration(t){if(!r(t))return;let n=t.id.name;g(n)&&e.report({node:t,messageId:`noCoreTypesInApps`,data:{typeName:n}})},ClassDeclaration(t){if(!r(t))return;let n=t.id.name;g(n)&&e.report({node:t,messageId:`noCoreTypesInApps`,data:{typeName:n}})}}:{}}},v={node:[`fs`,`path`,`os`,`crypto`,`child_process`,`cluster`,`dgram`,`dns`,`http`,`https`,`net`,`readline`,`stream`,`tls`,`tty`,`udp`,`url`,`util`,`v8`,`vm`,`worker_threads`,`zlib`],browser:[`window`,`document`,`navigator`,`localStorage`,`sessionStorage`,`fetch`,`XMLHttpRequest`,`WebSocket`,`Worker`,`IndexedDB`,`Blob`,`File`,`FileReader`,`URL`,`URLSearchParams`,`History`,`Location`,`Screen`,`AudioContext`,`Canvas`,`Notification`,`Performance`,`ServiceWorker`],electron:[`ipcRenderer`,`ipcMain`,`app`,`BrowserWindow`,`dialog`,`Menu`,`Tray`,`nativeImage`,`shell`,`clipboard`]},Ce=new Set(v.node),we=new Set(v.browser),Te=new Set(v.electron),Ee=[/\/domains\/shared-kernel\//,/\/domains\/page-domain\//,/\/domains\/repository-domain\//,/\/domains\/agent-domain\//,/\/domains\/collab-domain\//,/\/domains\/identity-domain\//,/\/domains\/workflow-domain\//,/\/domains\/chat-domain\//,/\/domains\/workspace-domain\//];function De(e){let t=e.replace(/\\/g,`/`);return Ee.some(e=>e.test(t))}function Oe(e){if(e.startsWith(`node:`)||Ce.has(e))return`node`;for(let t of v.node)if(e.startsWith(`${t}/`))return`node`;return null}function y(e){return we.has(e)}function b(e){return Te.has(e)}function ke(e){return typeof e==`object`&&!!e&&`object`in e&&e.object!==null&&typeof e.object==`object`&&`type`in e.object&&`name`in e.object}function Ae(e){return typeof e==`object`&&!!e&&`name`in e&&typeof e.name==`string`}function je(e,t){if(!s(e))return;let n=e.source.value;if(typeof n==`string`&&Oe(n)){let r=n.replace(/^node:/,``);t.report({node:e,messageId:`nodeImport`,data:{moduleName:r}})}}function Me(e,t){if(ke(e)&&e.object.type===`Identifier`){let n=e.object.name;y(n)&&t.report({node:e,messageId:`browserAPI`,data:{apiName:n}}),b(n)&&t.report({node:e,messageId:`electronAPI`,data:{apiName:n}})}}function Ne(e,t){if(!Ae(e))return;let n=e.name;(y(n)||b(n))&&e.parent&&e.parent.type!==`MemberExpression`&&t.report({node:e,messageId:`globalAPI`,data:{globalName:n}})}const x={meta:{type:`problem`,docs:{description:`禁止在业务域层直接使用平台特定 API`},messages:{nodeImport:`平台代码泄漏: 业务域层禁止直接导入 Node.js 模块 '{{moduleName}}'。请通过 packages/platform 层的接口间接访问。`,browserAPI:`平台代码泄漏: 业务域层禁止直接使用浏览器 API '{{apiName}}'。请通过 packages/platform 层的接口间接访问。`,electronAPI:`平台代码泄漏: 业务域层禁止直接使用 Electron API '{{apiName}}'。请通过 packages/platform 层的接口间接访问。`,globalAPI:`平台代码泄漏: 业务域层禁止直接访问全局对象 '{{globalName}}'。请通过 packages/platform 层的接口间接访问。`},schema:[]},create(e){let t=e.filename;return De(t)?{ImportDeclaration(t){je(t,e)},MemberExpression(t){Me(t,e)},Identifier(t){Ne(t,e)}}:{}}},Pe=[/\/packages\/platform\//,/\/packages\/ui\//,/\/packages\/ui-kit\//,/\/packages\/engine\//,/\/packages\/utils\//,/\/packages\/types\//],Fe=[`Page`,`Repository`,`Agent`,`Workflow`,`Workspace`,`User`,`Auth`,`Session`,`Message`,`Conversation`,`Sync`,`Favorite`,`Folder`,`Team`,`Execution`,`Task`,`Step`,`Trigger`],Ie=[/^validate/,/^calculate/,/^compute/,/^determine/,/^check/,/^can/,/^should/,/^isAllowed/,/^isPermitted/,/^hasPermission/,/^applyRule/,/^enforce/,/^execute/];function Le(e){let t=e.replace(/\\/g,`/`);return Pe.some(e=>e.test(t))}function S(e){let t=e.charAt(0).toUpperCase()+e.slice(1);return Fe.some(e=>t.includes(e))}function Re(e){return Ie.some(t=>t.test(e))}function ze(e){return typeof e==`object`&&!!e&&`key`in e&&e.key!==null&&typeof e.key==`object`&&`type`in e.key&&e.key.type===`Identifier`&&`name`in e.key&&typeof e.key.name==`string`}function Be(e){return typeof e==`object`&&!!e&&`id`in e&&e.id!==null&&typeof e.id==`object`&&`type`in e.id&&e.id.type===`Identifier`&&`name`in e.id&&typeof e.id.name==`string`&&`type`in e&&typeof e.type==`string`}function Ve(e,t){r(e)&&S(e.id.name)&&t.report({node:e,messageId:`businessClass`,data:{className:e.id.name}})}function He(e,t){ze(e)&&Re(e.key.name)&&t.report({node:e,messageId:`businessMethod`,data:{methodName:e.key.name}})}function Ue(e,t){r(e)&&S(e.id.name)&&t.report({node:e,messageId:`businessInterface`,data:{interfaceName:e.id.name}})}function We(e,t){Be(e)&&S(e.id.name)&&t.report({node:e,messageId:`businessType`,data:{typeName:e.id.name}})}const C={meta:{type:`suggestion`,docs:{description:`检测技术层中可能存在的业务逻辑`},messages:{businessClass:`业务逻辑泄漏嫌疑: 技术层发现业务相关类 '{{className}}'。业务逻辑应该放在 domains/ 层。`,businessMethod:`业务逻辑泄漏嫌疑: 技术层发现业务规则方法 '{{methodName}}'。业务规则应该放在 domains/ 层。`,businessInterface:`业务逻辑泄漏嫌疑: 技术层发现业务相关接口 '{{interfaceName}}'。业务接口应该放在 domains/ 层。`,businessType:`业务逻辑泄漏嫌疑: 技术层发现业务相关类型 '{{typeName}}'。业务类型应该放在 domains/ 层。`},schema:[]},create(e){let t=e.filename;return Le(t)?{ClassDeclaration(t){Ve(t,e)},MethodDefinition(t){He(t,e)},TSInterfaceDeclaration(t){Ue(t,e)},TSTypeAliasDeclaration(t){We(t,e)}}:{}}};function Ge(e){return e.startsWith(`create`)||e.startsWith(`make`)||e.startsWith(`build`)}function w(e){return/domains\/[^/]+\/(implementation|contract)\/src\/index\.ts$/.test(e)?`main`:/domains\/[^/]+\/(implementation|contract)\/src\/(domain|application|infrastructure)\/index\.ts$/.test(e)?`layer`:/domains\/[^/]+\/(implementation|contract)\/src\/(domain|application|infrastructure)\/\w+\/index\.ts$/.test(e)?`submodule`:`none`}function Ke(e){return e.includes(`/infrastructure/`)}const qe=[],Je=[{pattern:/^(?!create)[A-Za-z]+Repository(Drizzle|Memory|Sqlite|Mysql)$/,messageId:`forbiddenRepositoryExport`,message:`禁止导出具体仓储实现类`},{pattern:/^(?!create)[A-Za-z]*Table$/,messageId:`forbiddenTableExport`,message:`禁止导出数据库表定义`},{pattern:/[A-Za-z]+OrmEntity$/,messageId:`forbiddenOrmEntityExportFromMain`,message:`禁止从主入口导出 ORM 实体,应从 ./typeorm 入口导出`},{pattern:/[A-Z_]+_ORM_ENTITIES$/,messageId:`forbiddenEntitiesExportFromMain`,message:`禁止从主入口导出实体集合,应从 ./typeorm 入口导出`},{pattern:/[A-Za-z]+OrmMapper$/,messageId:`forbiddenOrmMapperExportFromMain`,message:`禁止从主入口导出 ORM Mapper,这是基础设施层实现细节`}],Ye=/^(?!create)[A-Za-z]*Schema$/,T=new WeakMap;function Xe(e,t,n){if(!n)return E(e,t);let r=T.get(n);if(r||(r=new Map,T.set(n,r)),r.has(t))return r.get(t);let i=E(e,t);return r.set(t,i),i}function E(e,t){let n=[],r=/export\s*\*\s*from/.test(e),i=e.matchAll(/export\s+type\s+\{([^}]+)\}/g);for(let e of i){let t=e[1];if(t){let e=t.split(`,`).map(e=>{let t=e.trim().split(` as `);return t[0]?t[0].trim():``}).filter(e=>e);n.push(...e)}}let a=e.matchAll(/export\s+(?!type)\{([^}]+)\}/g);for(let e of a){let t=e[1];if(t){let e=t.split(`,`).map(e=>{let t=e.trim().split(` as `);return t[0]?t[0].trim():``}).filter(e=>e);n.push(...e)}}let o=e.matchAll(/export\s+(class|function|const|let|interface|type)\s+(\w+)/g);for(let e of o){let t=e[2];t&&n.push(t)}let s=[],c=Ke(t);if(w(t)===`submodule`)return{usesExportStar:r,exports:n,forbiddenIssues:s};for(let e of n)if(!Ge(e)){for(let{pattern:t,messageId:n}of qe)t.test(e)&&s.push({messageId:n,exportName:e});for(let{pattern:t,messageId:n}of Je)t.test(e)&&s.push({messageId:n,exportName:e});c&&Ye.test(e)&&s.push({messageId:`forbiddenSchemaExport`,exportName:e})}return{usesExportStar:r,exports:n,forbiddenIssues:s}}const D={meta:{type:`problem`,docs:{description:`Domain 包导出规范:禁止 export *、禁止导出具体实现类、禁止导出数据库表和 Schema`,recommended:!0},schema:[],messages:{forbiddenExportStar:`禁止使用 export *,应使用显式导出(export { ... } 或 export type { ... })`,forbiddenRepositoryExport:`禁止导出具体仓储实现类 {{exportName}},应使用工厂函数 createXxxRepository`,forbiddenTableExport:`禁止导出数据库表定义 {{exportName}}`,forbiddenSchemaExport:`禁止导出 Schema 定义 {{exportName}}`,forbiddenOrmEntityExportFromMain:`禁止从主入口导出 ORM 实体 {{exportName}},应从 ./typeorm 入口导出`,forbiddenEntitiesExportFromMain:`禁止从主入口导出实体集合 {{exportName}},应从 ./typeorm 入口导出`,forbiddenOrmMapperExportFromMain:`禁止从主入口导出 ORM Mapper {{exportName}},这是基础设施层实现细节`}},create(e){let t=e.filename;if(w(t)===`none`)return{};let n=e.sourceCode.text,{usesExportStar:r,forbiddenIssues:i}=Xe(n,t,e);return{Program(t){r&&e.report({node:t,messageId:`forbiddenExportStar`});for(let n of i)e.report({node:t,messageId:n.messageId,data:{exportName:n.exportName}})}}}},Ze=/@longzai-intelligence\/[^/]+\/typeorm/,Qe=/@longzai-intelligence\/[^/]+\/infrastructure\//,$e=[/data-source\.ts$/,/data-source\.config\.ts$/,/data-source\.[a-z-]+\.ts$/,/database\.module\.ts$/,/database\.ts$/,/database\.config\.ts$/,/database\.service\.ts$/];function et(e){return $e.some(t=>t.test(e))}const O={meta:{type:`problem`,docs:{description:`Domain TypeORM 导入规范:非 DataSource 场景禁止导入 /typeorm 入口,禁止 infrastructure/* deep import`,recommended:!0},schema:[],messages:{forbiddenTypeormImport:`非 DataSource 场景禁止从 /typeorm 入口导入 ORM 实体,该入口仅供 DataSource/迁移基础设施使用`,forbiddenInfrastructureImport:`禁止 infrastructure/* deep import,应使用受控入口(主入口或 ./typeorm)`}},create(e){let t=e.filename,n=et(t);return{ImportDeclaration(t){if(!t.source)return;let r=t.source.value;typeof r==`string`&&(Ze.test(r)&&(n||e.report({node:t,messageId:`forbiddenTypeormImport`})),Qe.test(r)&&e.report({node:t,messageId:`forbiddenInfrastructureImport`}))}}}};function k(e){if(typeof e!=`object`||!e)return!1;let t=e;return`name`in t&&typeof t.name==`string`&&`isSpecialFile`in t&&typeof t.isSpecialFile==`function`&&`getNamingRules`in t&&typeof t.getNamingRules==`function`&&`shouldSkipTypeSuffix`in t&&typeof t.shouldSkipTypeSuffix==`function`}const A=[{pattern:/\.service\.drizzle\.ts$/,case:`kebab-case`,description:`Drizzle Service 文件应使用 xxx.service.drizzle.ts 格式(kebab-case)`},{pattern:/\.service\.memory\.ts$/,case:`kebab-case`,description:`Memory Service 文件应使用 xxx.service.memory.ts 格式(kebab-case)`},{pattern:/\.service\.ts$/,case:`kebab-case`,description:`服务文件应使用 xxx.service.ts 格式(kebab-case)`},{pattern:/\.controller\.ts$/,case:`kebab-case`,description:`控制器文件应使用 xxx.controller.ts 格式(kebab-case)`},{pattern:/\.module\.ts$/,case:`kebab-case`,description:`模块文件应使用 xxx.module.ts 格式(kebab-case)`},{pattern:/\.repository\.drizzle\.ts$/,case:`kebab-case`,description:`Drizzle Repository 文件应使用 xxx.repository.drizzle.ts 格式(kebab-case)`},{pattern:/\.repository\.memory\.ts$/,case:`kebab-case`,description:`Memory Repository 文件应使用 xxx.repository.memory.ts 格式(kebab-case)`},{pattern:/\.repository\.interface\.ts$/,case:`kebab-case`,description:`Repository 接口文件应使用 xxx.repository.interface.ts 格式(kebab-case)`},{pattern:/\.repository\.types\.ts$/,case:`kebab-case`,description:`Repository 类型文件应使用 xxx.repository.types.ts 格式(kebab-case)`},{pattern:/\.repository\.ts$/,case:`kebab-case`,description:`Repository 文件应使用 xxx.repository.ts 格式(kebab-case)`},{pattern:/\.entity\.types\.ts$/,case:`kebab-case`,description:`Entity 类型文件应使用 xxx.entity.types.ts 格式(kebab-case)`},{pattern:/\.entity\.interface\.ts$/,case:`kebab-case`,description:`Entity 接口文件应使用 xxx.entity.interface.ts 格式(kebab-case)`},{pattern:/\.entity\.ts$/,case:`kebab-case`,description:`Entity 文件应使用 xxx.entity.ts 格式(kebab-case)`},{pattern:/\.dto\.ts$/,case:`kebab-case`,description:`DTO 文件应使用 xxx.dto.ts 格式(kebab-case)`},{pattern:/\.port\.interface\.ts$/,case:`kebab-case`,description:`Port 接口文件应使用 xxx.port.interface.ts 格式(kebab-case)`},{pattern:/\.interface\.ts$/,case:`kebab-case`,description:`接口文件应使用 xxx.interface.ts 格式(kebab-case)`},{pattern:/\.types\.ts$/,case:`kebab-case`,description:`类型文件应使用 xxx.types.ts 格式(kebab-case)`},{pattern:/\.schema\.ts$/,case:`kebab-case`,description:`Schema 文件应使用 xxx.schema.ts 格式(kebab-case)`},{pattern:/\.port\.ts$/,case:`kebab-case`,description:`Port 文件应使用 xxx.port.ts 格式(kebab-case)`},{pattern:/\.port\.adapter\.ts$/,case:`kebab-case`,description:`Port Adapter 文件应使用 xxx.port.adapter.ts 格式(kebab-case)`},{pattern:/\.adapter\.ts$/,case:`kebab-case`,description:`Adapter 文件应使用 xxx.adapter.ts 格式(kebab-case)`},{pattern:/\.events\.ts$/,case:`kebab-case`,description:`Events 文件应使用 xxx.events.ts 格式(kebab-case)`},{pattern:/\.mapper\.ts$/,case:`kebab-case`,description:`Mapper 文件应使用 xxx.mapper.ts 格式(kebab-case)`},{pattern:/\.ipc\.ts$/,case:`kebab-case`,description:`IPC 文件应使用 xxx.ipc.ts 格式(kebab-case)`},{pattern:/\.config\.ts$/,case:`kebab-case`,description:`配置文件应使用 xxx.config.ts 格式(kebab-case)`},{pattern:/\.errors\.ts$/,case:`kebab-case`,description:`错误文件应使用 xxx.errors.ts 格式(kebab-case)`},{pattern:/\.utils\.ts$/,case:`kebab-case`,description:`工具函数文件应使用 xxx.utils.ts 格式(kebab-case)`},{pattern:/\.constants\.ts$/,case:`kebab-case`,description:`常量文件应使用 xxx.constants.ts 格式(kebab-case)`},{pattern:/\.atom\.ts$/,case:`kebab-case`,description:`Atom 文件应使用 xxx.atom.ts 格式(kebab-case)`},{pattern:/\.vo\.ts$/,case:`kebab-case`,description:`值对象文件应使用 xxx.vo.ts 格式(kebab-case)`},{pattern:/\.usecase\.ts$/,case:`kebab-case`,description:`UseCase 文件应使用 xxx.usecase.ts 格式(kebab-case)`},{pattern:/\.styles\.css$/,case:`kebab-case`,description:`样式文件应使用 xxx.styles.css 格式(kebab-case)`},{pattern:/\.extension\.tsx?$/,case:`kebab-case`,description:`扩展文件应使用 xxx.extension.ts(x) 格式(kebab-case)`}],j=[{pattern:/^use[A-Z][a-zA-Z]*\.spec\.tsx?$/,case:`camelCase`,description:`Hook 测试文件应使用 camelCase 并以 use 前缀开头(如 useChat.spec.ts)`},{pattern:/^use[A-Z][a-zA-Z]*\.test\.tsx?$/,case:`camelCase`,description:`Hook 测试文件应使用 camelCase 并以 use 前缀开头(如 useChat.test.ts)`},{pattern:/^use[A-Z][a-zA-Z]*\.types\.ts$/,case:`camelCase`,description:`Hook 类型文件应使用 camelCase 并以 use 前缀开头(如 useChat.types.ts)`},{pattern:/\.spec\.ts$/,case:`kebab-case-test`,description:`测试文件应使用 xxx.spec.ts 格式(kebab-case)`},{pattern:/\.test\.ts$/,case:`kebab-case-test`,description:`测试文件应使用 xxx.test.ts 格式(kebab-case)`},{pattern:/\.spec\.tsx$/,case:`kebab-case-test`,description:`测试文件应使用 xxx.spec.tsx 格式(kebab-case)`},{pattern:/\.test\.tsx$/,case:`kebab-case-test`,description:`测试文件应使用 xxx.test.tsx 格式(kebab-case)`},{pattern:/^use[A-Z][a-zA-Z]*\.tsx?$/,case:`camelCase`,description:`Hook 文件应使用 camelCase 并以 use 前缀开头(如 useChat.ts)`}],M={pattern:/^[A-Z][a-zA-Z]*\.tsx$/,case:`PascalCase`,description:`React 组件文件应使用 PascalCase(如 ChatPage.tsx)`};[...j,...A];const N=[`index.ts`,`index.tsx`,`main.ts`,`main.tsx`,`App.tsx`,`types.ts`,`errors.ts`,`constants.ts`,`persistence.ts`,`typeorm.ts`],P=[`impl`,`functions`,`methods`,`handlers`,`classes`];function tt(e){let t=e.replace(/\.tsx?$/,``);return[/s$/,/es$/,/ies$/].some(e=>e.test(t))}function F(e){return/^v\d+(-[a-z0-9-]+)?\.ts$/.test(e)}function nt(e){let t=e.replace(/\.tsx?$/,``);for(let e of P){if(t.endsWith(`.${e}`))return e;let n=t.split(`.`);if(n.length>=2&&n[n.length-1]===e)return e}return null}function rt(e){if(!e.endsWith(`.tsx`))return!1;let t=e.replace(`.tsx`,``);return/^[A-Z][a-zA-Z0-9]*$/.test(t)}function it(e){if(!e.endsWith(`.ts`)&&!e.endsWith(`.tsx`))return!1;let t=e.replace(/\.tsx?$/,``);return/^use[A-Z][a-zA-Z0-9]*$/.test(t)}function at(e){for(let t of[`.test.ts`,`.test.tsx`,`.spec.ts`,`.spec.tsx`])if(e.endsWith(t)){let n=t.endsWith(`.tsx`)?`.tsx`:`.ts`;return e.replace(t,n)}return e}const I={name:`base`,isSpecialFile(e){return!!(N.includes(e)||e.endsWith(`.d.ts`)||F(e))},getNamingRules(){return[...j,...A,M]},shouldSkipTypeSuffix(e){let t=at(e);return!!(N.includes(t)||t.endsWith(`.d.ts`)||F(t)||rt(t)||it(t)||!nt(t)&&tt(t))}},ot=[`page.tsx`,`page.ts`,`layout.tsx`,`layout.ts`,`loading.tsx`,`loading.ts`,`error.tsx`,`error.ts`,`not-found.tsx`,`not-found.ts`,`template.tsx`,`template.ts`,`default.tsx`,`default.ts`,`global-error.tsx`,`global-error.ts`,`middleware.ts`,`route.ts`],st={name:`nextjs`,isSpecialFile(e){return ot.includes(e)},getNamingRules(){return[]},shouldSkipTypeSuffix(e){return ot.includes(e)}},ct=[/^\[.+\]\.tsx?$/,/^_layout\.tsx?$/,/^\(.+\)\.tsx?$/],lt=[`_layout.tsx`,`_layout.ts`,`_sitemap.tsx`,`_sitemap.ts`],ut={name:`expo-router`,isSpecialFile(e){return lt.includes(e)?!0:ct.some(t=>t.test(e))},getNamingRules(){return[]},shouldSkipTypeSuffix(e){return this.isSpecialFile(e)}},dt=new Map;function L(e){dt.set(e.name,e)}L(I),L(st),L(ut);function R(e){return/^[A-Z][a-zA-Z0-9]*$/.test(e)}function ft(e){return/^[a-z][a-zA-Z0-9]*$/.test(e)}function z(e){return/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/.test(e)}function pt(e){return e.split(`.`).every(e=>z(e)&&e.length>0)}function mt(e){return e.split(`.`).every(e=>z(e)&&e.length>0)}function ht(e,t){if(e.endsWith(`.types`)&&t===`kebab-case`)return pt(e);switch(t){case`PascalCase`:return R(e);case`camelCase`:return ft(e);case`kebab-case`:return z(e);case`kebab-case-test`:return mt(e);default:return!1}}const gt=new WeakMap;function B(e,t){if(!t)try{return f.existsSync(e)}catch{return!1}let n=gt.get(t);if(n||(n=new Map,gt.set(t,n)),n.has(e))return n.get(e);let r;try{r=f.existsSync(e)}catch{r=!1}return n.set(e,r),r}function _t(e,t,n,r){let i=t.substring(6),a=u.dirname(i);return B(u.join(e,`pages`,a===`.`?``:a,n),r)}function vt(e,t,n,r){let i=t.substring(11),a=u.dirname(i);return B(u.join(e,`components`,a===`.`?``:a,n),r)}function yt(e,t,n,r){let i=t.substring(14),a=u.dirname(i);return B(u.join(e,`ui`,`components`,a===`.`?``:a,n),r)}function bt(e,t,n,r){let i=t.substring(6),a=u.dirname(i);return B(u.join(e,`react`,a===`.`?``:a,n),r)}function xt(e,t,n){let r=e.indexOf(`/__tests__/`),i=e.substring(0,r),a=e.substring(r+11);return a.startsWith(`pages/`)?_t(i,a,t,n):a.startsWith(`components/`)?vt(i,a,t,n):a.startsWith(`ui/components/`)?yt(i,a,t,n):a.startsWith(`react/`)?bt(i,a,t,n):B(u.join(i,t),n)}function St(e,t,n){let r=e.replace(/\\/g,`/`),i=r.includes(`/__tests__/`),a=r.includes(`/components/`);if(!a&&!i||!(t.endsWith(`.test.tsx`)||t.endsWith(`.spec.tsx`)||t.endsWith(`.test.ts`)||t.endsWith(`.spec.ts`)))return!1;let o=t.replace(/\.(test|spec)\.(tsx|ts)$/,`.tsx`);return i?xt(r,o,n):a?B(u.join(u.dirname(e),o),n):!1}const Ct=new WeakMap;function wt(e,t){if(!t)try{return f.existsSync(e)}catch{return!1}let n=Ct.get(t);if(n||(n=new Map,Ct.set(t,n)),n.has(e))return n.get(e);let r;try{r=f.existsSync(e)}catch{r=!1}return n.set(e,r),r}function Tt(e,t,n){if(!e.replace(/\\/g,`/`).includes(`/components/`)||!t.endsWith(`.types.ts`))return!1;let r=t.replace(`.types.ts`,`.tsx`);return wt(u.join(u.dirname(e),r),n)}function Et(e,t){if(t===M)return e.replace(/\.tsx$/,``);let n=t.pattern.source;return n.startsWith(`^`)&&n.endsWith(`$`)?n.includes(`\\.test\\.`)||n.includes(`\\.spec\\.`)?e.replace(/\.(test|spec)\.(tsx?|jsx?)$/,``):n.includes(`\\.types\\.`)?e.replace(/\.types\.ts$/,``):e.replace(/\.[^.]+$/,``):e.replace(t.pattern,``)}const Dt={meta:{type:`problem`,docs:{description:`强制执行文件命名规范`},messages:{invalidFileName:`文件命名违规: {{fileName}}。{{description}}`},schema:[]},create(e){let t=e.filename,n=u.basename(t),r=k(e.settings?.platformNamingStrategy)?e.settings.platformNamingStrategy:I;if(r.isSpecialFile(n,t)||Tt(t,n,e)&&R(n.replace(`.types.ts`,``))||St(t,n,e)&&R(n.replace(/\.(test|spec)\.(tsx|ts)$/,``)))return{};let i=r.getNamingRules().find(e=>e.pattern.test(n));if(!i&&n.endsWith(`.tsx`)&&(i=M),!i)return{};let a=Et(n,i);return ht(n.endsWith(`.types.ts`)&&i.case===`kebab-case`?n.replace(/\.ts$/,``):a,i.case)||e.report({loc:{start:{line:1,column:0},end:{line:1,column:n.length}},messageId:`invalidFileName`,data:{fileName:n,description:i.description}}),{}}};function Ot(e){return e.endsWith(`.types.ts`)?!0:/^[a-z][a-z0-9-]*\.[a-z][a-z0-9-]*\.tsx?$/.test(e)||/^[a-z][a-z0-9-]*\.[a-z][a-z0-9-]*\.[a-z][a-z0-9-]*\.tsx?$/.test(e)}function kt(e){let t=e.replace(/\.tsx?$/,``);for(let e of P){if(t.endsWith(`.${e}`))return e;let n=t.split(`.`);if(n.length>=2&&n[n.length-1]===e)return e}return null}function At(e){let t=[],n=e.replace(/\.tsx?$/,``);return(n.includes(`service`)||n.includes(`Service`))&&t.push(`.service.ts`),(n.includes(`controller`)||n.includes(`Controller`))&&t.push(`.controller.ts`),(n.includes(`utils`)||n.includes(`helper`)||n.includes(`Helper`))&&t.push(`.utils.ts`),(n.includes(`constant`)||n.includes(`Constant`))&&t.push(`.constants.ts`),(n.includes(`config`)||n.includes(`Config`))&&t.push(`.config.ts`),(n.includes(`atom`)||n.includes(`state`)||n.includes(`State`))&&t.push(`.atom.ts`),t.length===0&&t.push(`.utils.ts`,`.config.ts`,`.constants.ts`),t}function jt(e){for(let t of[`.test.ts`,`.test.tsx`,`.spec.ts`,`.spec.tsx`])if(e.endsWith(t)){let n=t.endsWith(`.tsx`)?`.tsx`:`.ts`;return e.replace(t,n)}return e}const Mt={meta:{type:`problem`,docs:{description:`强制执行文件类型后缀规范,确保文件名明确表达其用途`},messages:{missingTypeSuffix:`文件 "{{fileName}}" 缺少类型后缀。除特殊文件外,所有文件应使用 xxx.yyy.ts 格式明确表达用途。建议: {{suggestions}}`,forbiddenSuffix:`文件 "{{fileName}}" 使用了禁止的后缀 ".{{suffix}}"。该后缀语义过于泛化,无法表达文件用途。请使用更具体的后缀,如 ".utils"、".helpers"、".service" 等。`},schema:[]},create(e){let t=e.filename,n=u.basename(t);if((k(e.settings?.platformNamingStrategy)?e.settings.platformNamingStrategy:I).shouldSkipTypeSuffix(n))return{};let r=jt(n),i=kt(r);if(i)return e.report({loc:{start:{line:1,column:0},end:{line:1,column:n.length}},messageId:`forbiddenSuffix`,data:{fileName:n,suffix:i}}),{};if(Ot(r))return{};let a=At(r);return e.report({loc:{start:{line:1,column:0},end:{line:1,column:n.length}},messageId:`missingTypeSuffix`,data:{fileName:n,suggestions:a.join(`, `)}}),{}}},Nt=[/\/src\/renderer\//];function Pt(e){let t=e.replace(/\\/g,`/`);return Nt.some(e=>e.test(t))}function Ft(e){if(!e.startsWith(`@longzai-intelligence/`))return!1;let t=e.split(`/`);if(t.length<2)return!1;let n=t[1];return n?n.endsWith(`-implementation`):!1}const It={meta:{type:`problem`,docs:{description:`禁止在 Electron renderer 进程中导入 Implementation 包`},messages:{implementationInRenderer:`禁止在 renderer 进程中导入 Implementation 包 "{{packageName}}"。Implementation 包包含 Node.js 特定代码,请在 main 进程中使用,或使用 Contract 包代替。`},schema:[]},create(e){let t=e.filename;return Pt(t)?{ImportDeclaration(t){let n=t.source.value;typeof n==`string`&&Ft(n)&&e.report({node:t,messageId:`implementationInRenderer`,data:{packageName:n}})}}:{}}};function Lt(e){return typeof e==`object`&&!!e&&`alias`in e&&typeof e.alias==`string`&&`pathPattern`in e&&typeof e.pathPattern==`string`}function Rt(e){return Array.isArray(e)&&e.every(Lt)}const zt=[{alias:`@main`,pathPattern:`src/main`},{alias:`@preload`,pathPattern:`src/preload`},{alias:`@renderer`,pathPattern:`src/renderer/src`},{alias:`@shared`,pathPattern:`src/shared`}];function Bt(e,t){let n=e.replace(/\\/g,`/`);for(let e of t){let t=e.pathPattern.replace(/\\/g,`/`);if(n.includes(`/${t}/`)||n.endsWith(`/${t}`)||n.includes(`/${t}\\`))return e.alias}return null}function Vt(e,t,n){if(!t.startsWith(`.`))return null;let r=e.replace(/\\/g,`/`),i=r.lastIndexOf(`/`),a=i>0?r.substring(0,i):``;return Bt(u.resolve(a,t).replace(/\\/g,`/`),n)}function Ht(e){return e.startsWith(`./`)||e.startsWith(`../`)}const Ut={meta:{type:`problem`,docs:{description:`禁止使用相对路径穿越不同包范围,强制使用别名导入`},messages:{noCrossPackageRelativeImport:`禁止使用相对路径跨包导入。当前文件位于 "{{currentPackage}}" 包,目标位于 "{{targetPackage}}" 包。请使用别名导入:{{targetPackage}}/...`},schema:[{type:`object`,properties:{packageBoundaries:{type:`array`,items:{type:`object`,properties:{alias:{type:`string`},pathPattern:{type:`string`}},required:[`alias`,`pathPattern`]}}},additionalProperties:!1}]},create(e){let t=e.filename,n=e.options[0],r=n&&typeof n==`object`?n:{},i=`packageBoundaries`in r&&Array.isArray(r.packageBoundaries)?r.packageBoundaries:zt,a=Rt(i)?i:zt,o=Bt(t,a);return o?{ImportDeclaration(n){let r=n.source.value;if(typeof r!=`string`||!Ht(r))return;let i=Vt(t,r,a);i&&o!==i&&e.report({node:n,messageId:`noCrossPackageRelativeImport`,data:{currentPackage:o,targetPackage:i}})}}:{}}},Wt=[/\.test\.ts$/,/\.test\.tsx$/,/\.spec\.ts$/,/\.spec\.tsx$/],Gt=[`/node_modules/`,`/dist/`,`/out/`,`/.bun/`],Kt=[{segment:`/templates/`,type:`templates`},{segment:`/domains/`,type:`domains`},{segment:`/packages/`,type:`packages`},{segment:`/infrastructure/`,type:`infrastructure`}],qt=[{segment:`/src/main/`,process:`main`},{segment:`/src/renderer/`,process:`renderer`},{segment:`/src/preload/`,process:`preload`},{segment:`/src/shared/`,process:`shared`}];function V(e){return e.replace(/\\/g,`/`)}function Jt(e){return Wt.some(t=>t.test(e))}function Yt(e){let t=V(e);return Gt.some(e=>t.includes(e))}function Xt(e){return e.isElectron&&e.electronProcess?`src/${e.electronProcess}/__tests__`:`src/__tests__`}function Zt(e,t){let n=V(e);return t.srcRoot?n.startsWith(`${t.srcRoot}/__tests__/`):!0}function Qt(e,t){let n=V(e),r=u.basename(e);if(!t.srcRoot)return`src/__tests__/${r}`;let i=n.indexOf(`/src/`);if(i===-1)return`${t.srcRoot}/__tests__/${r}`;let a=n.slice(i+5).split(`/`);if(a.length>1&&a.pop(),t.isElectron&&t.electronProcess){let e=a.indexOf(t.electronProcess);e!==-1&&a.splice(e,1)}let o=a.indexOf(`__tests__`);o!==-1&&a.splice(o,1);let s=a.join(`/`),c=Xt(t);return s?`${c}/${s}/${r}`:`${c}/${r}`}function $t(e,t){let n=e.indexOf(t),r=e.slice(n+t.length).split(`/`),i=r.findIndex(e=>e===`src`);if(i!==-1)return e.slice(0,n+t.length)+r.slice(0,i+1).join(`/`);let a=t===`/domains/`&&r.length>=2?`${r[0]}/${r[1]}`:r[0];return a?e.slice(0,n+t.length+a.length)+`/src`:e.slice(0,n+t.length)+`src`}function en(e){for(let t of qt)if(e.includes(t.segment))return{electronProcess:t.process,srcRoot:e.slice(0,e.indexOf(t.segment))+t.segment.slice(0,-1)};return{srcRoot:``}}function tn(e){return e.includes(`-desktop`)||e===`desktop`}function nn(e){let t=V(e);for(let e of Kt)if(t.includes(e.segment))return{type:e.type,isElectron:!1,srcRoot:$t(t,e.segment)};if(t.includes(`/database/`)){let e=t.indexOf(`/database/`);return{type:`database`,isElectron:!1,srcRoot:t.slice(0,e+10)+`src`}}if(!t.includes(`/apps/`))return{type:`unknown`,isElectron:!1,srcRoot:``};let n=t.indexOf(`/apps/`),r=t.slice(n+6).split(`/`)[0];if(!r)return{type:`unknown`,isElectron:!1,srcRoot:``};let i=t.slice(0,n+6+r.length)+`/src`;if(!tn(r))return{type:`apps`,isElectron:!1,srcRoot:i};let a=en(t);return{type:`apps`,isElectron:!0,electronProcess:a.electronProcess,srcRoot:a.srcRoot||i}}const rn={meta:{type:`problem`,docs:{description:`强制测试文件放置在 src/__tests__ 目录下`},messages:{invalidTestFileLocation:`测试文件 "{{fileName}}" 必须放置在 {{expectedDir}} 目录下。当前路径: "{{currentPath}}"。建议路径: "{{suggestedPath}}"`},schema:[]},create(e){let t=e.filename,n=u.basename(t);if(!Jt(n)||Yt(t)||n.endsWith(`.d.ts`))return{};let r=nn(t);if(r.type===`unknown`||Zt(t,r))return{};let i=Xt(r),a=Qt(t,r);return e.report({loc:{start:{line:1,column:0},end:{line:1,column:n.length}},messageId:`invalidTestFileLocation`,data:{fileName:n,expectedDir:i,currentPath:t,suggestedPath:a}}),{}}},an=[`**/vitest.setup.ts`,`**/jest.setup.ts`,`**/fixtures/**`,`**/helpers/**`,`**/mocks/**`,`**/__mocks__/**`,`**/*.d.ts`],on=[/\.test\.ts$/,/\.test\.tsx$/,/\.spec\.ts$/,/\.spec\.tsx$/];function sn(e){return on.some(t=>t.test(e))}function cn(e,t){let n=t.replace(/[.+^${}()|[\]\\]/g,`\\$&`).replace(/\*\*/g,`{{DOUBLE_STAR}}`).replace(/\*/g,`[^/]*`).replace(/{{DOUBLE_STAR}}/g,`.*`);return RegExp(`^${n}$`).test(e)}function ln(e,t){return t.some(t=>cn(e,t))}function un(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function dn(e){if(typeof e!=`object`||!e)return!1;if(!(`allowPatterns`in e))return!0;let t=e.allowPatterns;return Array.isArray(t)&&un(t)}const fn={meta:{type:`problem`,docs:{description:`禁止在 __tests__ 目录下放置非测试文件`},messages:{nonTestFileInTestsDirectory:`文件 "{{fileName}}" 位于 __tests__ 目录下但不是测试文件。测试目录应仅包含测试文件(*.test.ts, *.spec.ts)。如果是辅助文件,请移动到 src/test-helpers/ 或 src/testing/ 目录。`},schema:[{type:`object`,properties:{allowPatterns:{type:`array`,items:{type:`string`},description:`允许在 __tests__ 目录下的非测试文件 glob 模式`}},additionalProperties:!1}]},create(e){let t=[...an],n=e.options[0];dn(n)&&n.allowPatterns&&(t=[...an,...n.allowPatterns]);let r=e.filename,i=V(r),a=u.basename(r);return{Program(){i.includes(`/__tests__/`)&&(sn(a)||ln(i,t)||e.report({loc:{start:{line:1,column:0},end:{line:1,column:a.length}},messageId:`nonTestFileInTestsDirectory`,data:{fileName:a}}))}}}},pn=[/\.test\.ts$/,/\.test\.tsx$/,/\.spec\.ts$/,/\.spec\.tsx$/],H=[`.ts`,`.tsx`],mn=new Set([`node_modules`,`dist`,`out`,`.bun`,`.turbo`,`.cache`,`generated`]),hn=new WeakMap;function gn(e){return e.replace(/\\/g,`/`)}function _n(e,t){let n;try{n=f.readdirSync(e,{withFileTypes:!0})}catch{return}for(let r of n){let n=u.join(e,r.name);if(r.isDirectory()){if(mn.has(r.name))continue;_n(n,t)}else r.isFile()&&t(n)}}function U(e){return Wt.some(t=>t.test(e))}function vn(e){let t=gn(e);return Gt.some(e=>t.includes(e))}function yn(e){for(let t of pn)if(t.test(e))return e.replace(t,``);return e}function bn(e){let t=gn(e),n=t.indexOf(`/__tests__/`);return n===-1?u.dirname(e):t.substring(0,n)}function xn(e,t){for(let n of H){let r=u.join(t,e+n);if(f.existsSync(r))return r}return null}function Sn(e,t){let n=hn.get(e);if(n||(n=new Map,hn.set(e,n)),n.has(t))return n.get(t);let r=[];return _n(t,e=>r.push(e)),n.set(t,r),r}function Cn(e,t,n,r){let i=u.dirname(t),a=[i,u.dirname(i)];for(let t of a){let n=xn(e,t);if(n)return n}let o=[n,i];for(let t of o){if(!f.existsSync(t))continue;let n=Sn(r,t);for(let t of n){let n=u.basename(t);if(!U(n)){for(let r of H)if(n===e+r)return t}}}return null}function wn(e,t){let n=u.basename(e),r=yn(n),i=bn(e);if(Cn(r,e,i,t))return{isMatch:!0,suggestion:null};let a=On(i,e,t)[0];if(a){let e=u.basename(a,u.extname(a)),t=u.extname(n),r=n.includes(`.spec.`)?`.spec`:`.test`,i=t.replace(r,``);return{isMatch:!1,suggestion:e+r+i}}return{isMatch:!1,suggestion:null}}function Tn(e){return U(e)||e===`index.ts`||e===`index.tsx`||e.endsWith(`.d.ts`)?!1:H.some(t=>e.endsWith(t))}function En(e,t,n){if(f.existsSync(e))try{let r=f.readdirSync(e,{withFileTypes:!0});for(let i of r){if(!i.isFile())continue;let r=i.name;if(!Tn(r))continue;let a=u.join(e,r);n.has(a)||(t.push(a),n.add(a))}}catch{}}function Dn(e,t,n,r){if(!f.existsSync(e))return;let i=Sn(t,e);for(let e of i)Tn(u.basename(e))&&(r.has(e)||(n.push(e),r.add(e)))}function On(e,t,n){let r=u.dirname(t),i=u.dirname(r),a=[],o=new Set,s=[r,i];for(let e of s)En(e,a,o);if(a.length===0){let t=[e,r];for(let e of t)Dn(e,n,a,o)}return a}const W={meta:{type:`problem`,docs:{description:`确保测试文件名与被测试的源文件名保持一致`},messages:{testFileNotMatchSource:`测试文件 "{{testFileName}}" 未找到匹配的源文件。测试文件名应与源文件名保持一致。{{suggestion}}`},schema:[]},create(e){let t=e.filename,n=u.basename(t);if(!U(n)||vn(t)||n.endsWith(`.d.ts`))return{};let r=wn(t,e);if(!r.isMatch){let t=r.suggestion?`建议重命名为 "${r.suggestion}"`:`请确保测试文件名与源文件名匹配(如 user.service.ts -> user.service.test.ts)`;e.report({loc:{start:{line:1,column:0},end:{line:1,column:n.length}},messageId:`testFileNotMatchSource`,data:{testFileName:n,suggestion:t}})}return{}}};function kn(e){if(!e||typeof e!=`object`)return!1;let t=e;if(!(`type`in t)||t.type!==m.MemberExpression||!(`object`in t)||!t.object||!(`property`in t)||!t.property)return!1;let n=t.object,r=t.property;return!n||typeof n!=`object`||!r||typeof r!=`object`?!1:`type`in n&&n.type===m.Identifier&&`name`in n&&n.name===`window`&&`type`in r&&r.type===m.Identifier&&`name`in r&&r.name===`electron`}const An={meta:{type:`problem`,docs:{description:`禁止在 Preload 中直接暴露 @electron-toolkit/preload 的 electronAPI`},messages:{noElectronApiImport:`禁止导入 @electron-toolkit/preload 的 electronAPI。`,noExposeElectronApi:`禁止执行 contextBridge.exposeInMainWorld("electron", electronAPI)。`,noWindowElectronApi:`禁止执行 window.electron = electronAPI。`},schema:[]},create(e){return{ImportDeclaration(t){if(t.source.value===`@electron-toolkit/preload`)for(let n of t.specifiers)n.type===`ImportSpecifier`&&n.imported.type===`Identifier`&&n.imported.name===`electronAPI`&&e.report({node:n,messageId:`noElectronApiImport`})},CallExpression(t){if(t.callee.type!==`MemberExpression`||t.callee.property.type!==`Identifier`||t.callee.property.name!==`exposeInMainWorld`||t.arguments.length<2)return;let[n,r]=t.arguments;n?.type===`Literal`&&n.value===`electron`&&r?.type===`Identifier`&&r.name===`electronAPI`&&e.report({node:t,messageId:`noExposeElectronApi`})},AssignmentExpression(t){t.left.type===`MemberExpression`&&kn(t.left)&&t.right.type===`Identifier`&&t.right.name===`electronAPI`&&e.report({node:t,messageId:`noWindowElectronApi`})}}}};function jn(e){let t=e.replace(/\\/g,`/`);return t.includes(`/src/preload/`)&&!t.includes(`/__tests__/`)}function G(e){return typeof e==`object`&&!!e}function Mn(e){if(!G(e))return null;let t=e.key;return G(t)?typeof t.name==`string`?t.name:typeof t.value==`string`?t.value:null:null}function Nn(e){return!G(e)||!Array.isArray(e.properties)?!1:e.properties.some(e=>{if(!G(e)||e.type!==`Property`)return!1;let t=Mn(e);return t===`on`||t===`send`||t===`invoke`})}const Pn={meta:{type:`problem`,docs:{description:`禁止在 Preload 暴露通用 ipc 桥接对象`},messages:{noIpcBridge:`禁止暴露通用 ipc 桥接对象(on/send/invoke)。请使用领域 API。`},schema:[]},create(e){return jn(e.filename)?{Property(t){Mn(t)===`ipc`&&G(t.value)&&t.value.type===`ObjectExpression`&&Nn(t.value)&&e.report({node:t,messageId:`noIpcBridge`})}}:{}}};function Fn(e){let t=e.replace(/\\/g,`/`);return t.includes(`/src/preload/`)&&!t.includes(`/__tests__/`)&&!t.includes(`/src/preload/utils/`)}const In={meta:{type:`problem`,docs:{description:`禁止在 Preload 业务代码中直接调用 ipcRenderer`},messages:{noDirectCall:`禁止直接调用 ipcRenderer。请通过 createTypedAPI 或 invoke 封装。`},schema:[]},create(e){return Fn(e.filename)?{CallExpression(t){t.callee.type===`MemberExpression`&&t.callee.object.type===`Identifier`&&t.callee.object.name===`ipcRenderer`&&e.report({node:t,messageId:`noDirectCall`})}}:{}}};function K(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`Identifier`&&`name`in e&&typeof e.name==`string`}function Ln(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`Property`&&`value`in e&&e.value!==null&&typeof e.value==`object`&&K(e.value)}function Rn(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`RestElement`&&`argument`in e&&e.argument!==null&&typeof e.argument==`object`&&K(e.argument)}function zn(e){let t=[];if(!e||typeof e!=`object`)return t;if(K(e)&&t.push(e.name),`type`in e&&e.type===`ObjectPattern`&&`properties`in e&&Array.isArray(e.properties))for(let n of e.properties)!n||typeof n!=`object`||(Ln(n)?t.push(n.value.name):Rn(n)&&t.push(n.argument.name));if(`type`in e&&e.type===`ArrayPattern`&&`elements`in e&&Array.isArray(e.elements))for(let n of e.elements)K(n)&&t.push(n.name);return t}function Bn(e){return`declaration`in e}function Vn(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`VariableDeclaration`&&`kind`in e&&`declarations`in e&&Array.isArray(e.declarations)}function Hn(e){if(typeof e!=`object`||!e||!(`range`in e))return!1;let t=e.range;return Array.isArray(t)&&t.length===2}function Un(e,t,n){return r=>{let i=t.declaration;if(!i||!Hn(i)||!e.getTokenBefore(i))return null;let a=e.getText(i),o=n.join(`, `),s=e.getText(t).match(/^(\s*)/),c=s?s[1]:``,ee=`${a}`,l=`${c}export { ${o} };`;return r.replaceText(t,`${ee}\n${l}`)}}const Wn={meta:{type:`suggestion`,docs:{description:`将 export const/let/var 拆分为独立的声明和导出语句,以便 JSDoc 正确插入`,recommended:!0},fixable:`code`,schema:[],messages:{preferSplitExport:"应将 `export {{kind}} {{names}}` 拆分为独立的声明和导出语句,以便 JSDoc 正确插入注释"}},create(e){let t=e.sourceCode;return{ExportNamedDeclaration(n){if(!Bn(n)||!n.declaration||!Vn(n.declaration))return;let r=n.declaration;if(r.kind!==`const`&&r.kind!==`let`&&r.kind!==`var`)return;let i=r.declarations;if(i.length===0)return;let a=[];i.forEach(e=>{a.push(...zn(e.id))}),a.length!==0&&e.report({node:n,messageId:`preferSplitExport`,data:{kind:r.kind,names:a.join(`, `)},fix:Un(t,n,a)})}}}};function Gn(e){return typeof e==`object`&&!!e&&`name`in e&&typeof e.name==`string`&&(!(`severity`in e)||e.severity===`error`||e.severity===`warn`||e.severity===void 0)&&(!(`description`in e)||typeof e.description==`string`||e.description===void 0)}function Kn(e){return Array.isArray(e)&&e.every(Gn)}function qn(e){if(typeof e!=`object`||!e)return!1;if(!(`directories`in e))return!0;let t=e.directories;return Array.isArray(t)&&Kn(t)}const Jn=[{name:`apps`,severity:`error`,description:`应用层目录`},{name:`domains`,severity:`error`,description:`领域层目录`},{name:`packages`,severity:`error`,description:`技术层目录`},{name:`infrastructure`,severity:`warn`,description:`基础设施层目录`},{name:`templates`,severity:`warn`,description:`模板层目录`},{name:`docs`,severity:`warn`,description:`文档层目录`}];function Yn(e,t){return p(d(e,t,`README.md`))}function Xn(e){return e.cwd}const Zn=new WeakMap;function Qn(e){let t=Zn.get(e);return t||(t=new Set,Zn.set(e,t)),t}const $n={meta:{type:`problem`,docs:{description:`检查分层目录是否包含 README.md 文件`},messages:{missingReadmeError:`分层目录 "{{directory}}" ({{description}}) 缺少 README.md 文件。分层目录必须包含 README.md 文件,阐明该层职责。`,missingReadmeWarn:`分层目录 "{{directory}}" ({{description}}) 建议添加 README.md 文件,阐明该层职责。`},schema:[{type:`object`,properties:{directories:{type:`array`,items:{type:`object`,properties:{name:{type:`string`},severity:{type:`string`,enum:[`error`,`warn`]},description:{type:`string`}},required:[`name`]}}},additionalProperties:!1}]},create(e){let t=Xn(e),n=Qn(e),r=Jn,i=e.options[0];return qn(i)&&i.directories&&(r=i.directories),{Program(i){if(!n.has(t)){n.add(t);for(let n of r){let r=n.name;if(p(d(t,r))&&!Yn(t,r)){let t=(n.severity||`error`)===`error`?`missingReadmeError`:`missingReadmeWarn`;e.report({node:i,messageId:t,data:{directory:r,description:n.description||r}})}}}}}}},er=[{suffix:`.service.drizzle.ts`,classSuffix:`Service`,isInterface:!1,isPrefix:!1},{suffix:`.service.memory.ts`,classSuffix:`Service`,isInterface:!1,isPrefix:!1},{suffix:`.service.ts`,classSuffix:`Service`,isInterface:!1,isPrefix:!1},{suffix:`.controller.ts`,classSuffix:`Controller`,isInterface:!1,isPrefix:!1},{suffix:`.module.ts`,classSuffix:`Module`,isInterface:!1,isPrefix:!1},{suffix:`.repository.drizzle.ts`,classSuffix:`Repository`,isInterface:!1,isPrefix:!1},{suffix:`.repository.memory.ts`,classSuffix:`Repository`,isInterface:!1,isPrefix:!1},{suffix:`.repository.interface.ts`,classSuffix:`Repository`,isInterface:!0,isPrefix:!0},{suffix:`.repository.ts`,classSuffix:`Repository`,isInterface:!1,isPrefix:!1},{suffix:`.entity.ts`,classSuffix:`Entity`,isInterface:!1,isPrefix:!1},{suffix:`.orm-entity.ts`,classSuffix:`OrmEntity`,isInterface:!1,isPrefix:!1},{suffix:`.dto.ts`,classSuffix:`DTO`,isInterface:!1,isPrefix:!1},{suffix:`.port.interface.ts`,classSuffix:`Port`,isInterface:!0,isPrefix:!0},{suffix:`.interface.ts`,classSuffix:``,isInterface:!0,isPrefix:!0},{suffix:`.port.ts`,classSuffix:`Port`,isInterface:!0,isPrefix:!1},{suffix:`.port.adapter.ts`,classSuffix:`PortAdapter`,isInterface:!1,isPrefix:!1},{suffix:`.adapter.ts`,classSuffix:`Adapter`,isInterface:!1,isPrefix:!1},{suffix:`.events.ts`,classSuffix:`Event`,isInterface:!1,isPrefix:!1},{suffix:`.mapper.ts`,classSuffix:`Mapper`,isInterface:!1,isPrefix:!1},{suffix:`.vo.ts`,classSuffix:`VO`,isInterface:!1,isPrefix:!1},{suffix:`.usecase.ts`,classSuffix:`UseCase`,isInterface:!1,isPrefix:!1},{suffix:`.errors.ts`,classSuffix:`Error`,isInterface:!1,isPrefix:!1}];function tr(e){for(let t of er)if(e.endsWith(t.suffix))return t;return null}function nr(e,t){if(t.isPrefix&&t.isInterface){if(t.classSuffix){let n=t.classSuffix;return e.startsWith(`I`)&&e.endsWith(n)&&e.length>1+n.length}return e.startsWith(`I`)&&e.length>1}return t.isPrefix?e.startsWith(`I`)&&e.length>1:e.endsWith(t.classSuffix)&&e.length>t.classSuffix.length}function rr(e){return e.isPrefix&&e.isInterface?e.classSuffix?`I${e.classSuffix}(如 IUser${e.classSuffix})`:`I 前缀(如 IUser)`:e.isPrefix?`I 前缀(如 IUser)`:`${e.classSuffix} 后缀`}function ir(e,t,n,i){if(!r(e))return;let a=e.id.name;n.isInterface||nr(a,n)||t.report({node:e,messageId:`invalidClassName`,data:{className:a,fileName:i,expectedFormat:rr(n)}})}function ar(e,t,n,i){if(!n.isInterface||!r(e))return;let a=e.id.name;nr(a,n)||t.report({node:e,messageId:`invalidInterfaceName`,data:{interfaceName:a,fileName:i,expectedFormat:rr(n)}})}function or(e){let t=e.filename,n=u.basename(t);if(n.endsWith(`.test.ts`)||n.endsWith(`.spec.ts`))return{};let r=tr(n);return r?{ClassDeclaration(t){ir(t,e,r,n)},TSInterfaceDeclaration(t){ar(t,e,r,n)}}:{}}const sr={meta:{type:`problem`,docs:{description:`强制执行类名与文件类型后缀的一致性`},messages:{invalidClassName:`类名 "{{className}}" 不符合命名规范。文件 "{{fileName}}" 中的类应使用 {{expectedFormat}}`,invalidInterfaceName:`接口名 "{{interfaceName}}" 不符合命名规范。文件 "{{fileName}}" 中的接口应使用 {{expectedFormat}}`},schema:[]},create:or},cr=[`types.ts`,`types.d.ts`],lr=[`.port.interface.ts`,`.repository.interface.ts`,`.types.ts`,`.types.d.ts`,`.events.ts`];function ur(e,t){return n(e)?!1:t.endsWith(`.dto.ts`)?ne(e):!0}function dr(e){return e.endsWith(`.dto.ts`)?`DTO 后缀(如 UserDTO),禁止 I 前缀`:`PascalCase(如 User、UserRepository),禁止 I 前缀`}function fr(e){if(cr.includes(e))return!0;for(let t of lr)if(e.endsWith(t))return!0;return!1}function pr(e){return e.endsWith(`.port.ts`)?e.replace(`.port.ts`,`.port.interface.ts`):e.endsWith(`.repository.ts`)?e.replace(`.repository.ts`,`.repository.interface.ts`):e.replace(`.ts`,`.interface.ts`)}function mr(t,n){return n.endsWith(`Dto`)?e(t,n,!0):null}function hr(e,r,i,a){if(ur(i,a))return;if(n(i)){e.report({node:r,messageId:`invalidIPrefix`,data:{interfaceName:i,suggestedName:i.substring(1)},fix:t(r,i)});return}let o=mr(r,i);o?e.report({node:r,messageId:`invalidDtoSuffix`,data:{interfaceName:i},fix:o}):e.report({node:r,messageId:`invalidInterfaceName`,data:{interfaceName:i,expectedFormat:dr(a)}})}function gr(e,t,n,r,i){i||r.endsWith(`.dto.ts`)||e.report({node:t,messageId:`invalidFileName`,data:{fileName:r,interfaceName:n,expectedFileName:pr(r)}})}function _r(e,t,n,r){if(!i(t))return;let a=t.id.name;hr(e,t,a,n),gr(e,t,a,n,r)}function vr(e){let t=e.filename,n=u.basename(t);if(n.endsWith(`.test.ts`)||n.endsWith(`.spec.ts`)||fr(n))return{};let r=n.endsWith(`.interface.ts`);return{TSInterfaceDeclaration(t){_r(e,t,n,r)}}}const yr={meta:{type:`problem`,docs:{description:`强制执行接口命名规范(禁止 I 前缀,使用 PascalCase)和文件命名规范(xxx.interface.ts)`},messages:{invalidIPrefix:`接口名 "{{interfaceName}}" 使用了 I 前缀。现代 TypeScript 不推荐使用匈牙利命名法,建议使用 "{{suggestedName}}"`,invalidInterfaceName:`接口名 "{{interfaceName}}" 不符合命名规范。接口名应使用 {{expectedFormat}}`,invalidDtoSuffix:`接口名 "{{interfaceName}}" 后缀应使用 DTO(全大写)而非 Dto(驼峰式)`,invalidFileName:`包含接口 "{{interfaceName}}" 的文件 "{{fileName}}" 应命名为 "{{expectedFileName}}"`},schema:[],fixable:`code`},create:vr},br=[`.types.ts`,`.types.d.ts`];function xr(e){return br.some(t=>e.endsWith(t))}function Sr(e){let r=e.filename,a=u.basename(r);return a.endsWith(`.test.ts`)||a.endsWith(`.spec.ts`)||!xr(a)?{}:{TSInterfaceDeclaration(r){if(!i(r))return;let a=r.id.name;n(a)&&e.report({node:r,messageId:`invalidIPrefix`,data:{interfaceName:a,suggestedName:a.substring(1)},fix:t(r,a)})}}}const Cr={meta:{type:`problem`,docs:{description:`强制执行 types 文件中的接口命名规范(禁止 I 前缀)`},messages:{invalidIPrefix:`类型文件中的接口名 "{{interfaceName}}" 使用了 I 前缀。现代 TypeScript 不推荐使用匈牙利命名法,建议使用 "{{suggestedName}}"`},schema:[],fixable:`code`},create:Sr};function wr(e){return e.endsWith(`.dto.ts`)}function Tr(e){return e.endsWith(`DTO`)}function Er(t){let n=t.filename,r=u.basename(n);return r.endsWith(`.test.ts`)||r.endsWith(`.spec.ts`)||!wr(r)?{}:{TSInterfaceDeclaration(n){if(!i(n))return;let r=n.id.name;Tr(r)?t.report({node:n,messageId:`invalidDtoSuffix`,data:{interfaceName:r},fix:e(n,r,!1)}):te(r)||t.report({node:n,messageId:`missingDtoSuffix`,data:{interfaceName:r}})}}}const Dr={meta:{type:`problem`,docs:{description:`强制执行 DTO 文件中的接口命名规范(Dto 后缀,驼峰式)`},messages:{invalidDtoSuffix:`接口名 "{{interfaceName}}" 后缀应使用 Dto(驼峰式)而非 DTO(全大写)`,missingDtoSuffix:`DTO 文件中的接口名 "{{interfaceName}}" 应以 Dto 结尾(如 UserResponseDto)`},schema:[],fixable:`code`},create:Er},q=`@longzai-intelligence/config/tsup`,Or=`definePackageConfig`,kr=[`defineConfig`];function Ar(e){return{ImportDeclaration(t){if(!s(t))return;let n=t.source.value;for(let r of t.specifiers){if(!c(r))continue;let i=r.imported.name;if(kr.includes(i)){if(n===`tsup`){e.report({node:t,messageId:`forbiddenTsupImport`,data:{importedName:i,correctExportName:Or,configPackage:q}});continue}n===q&&e.report({node:t,messageId:`forbiddenConfigImport`,data:{importedName:i,correctExportName:Or,configPackage:q}})}}}}}const jr={meta:{type:`problem`,docs:{description:`强制执行 tsup.config.ts 文件中的配置导入规范,必须使用 definePackageConfig`},messages:{forbiddenTsupImport:`禁止从 tsup 包导入 {{importedName}}。应使用 {{correctExportName}} 从 {{configPackage}} 导入`,forbiddenConfigImport:`禁止从 {{configPackage}} 导入 {{importedName}}。应使用 {{correctExportName}}`},schema:[]},create:Ar},J=`@longzai-intelligence/tsdown-config`,Mr=[`defineDomainImplementationConfig`,`defineDomainContractConfig`,`defineSharedKernelConfig`,`defineReactComponentsConfig`,`defineConfigPackageConfig`,`definePackageConfig`],Nr=[`defineConfig`];function Pr(e){return{ImportDeclaration(t){if(!s(t))return;let n=t.source.value;for(let r of t.specifiers){if(!c(r))continue;let i=r.imported.name;if(Nr.includes(i)){if(n===`tsdown`){e.report({node:t,messageId:`forbiddenTsdownImport`,data:{importedName:i,presetNames:Mr.join(`、`),configPackage:J}});continue}n===J&&e.report({node:t,messageId:`forbiddenConfigImport`,data:{importedName:i,presetNames:Mr.join(`、`),configPackage:J}})}}}}}const Fr={meta:{type:`problem`,docs:{description:`强制执行 tsdown.config.ts 文件中的配置导入规范,必须使用预设函数`},messages:{forbiddenTsdownImport:`禁止从 tsdown 包导入 {{importedName}}。应使用预设函数({{presetNames}})从 {{configPackage}} 导入`,forbiddenConfigImport:`禁止从 {{configPackage}} 导入 {{importedName}}。应使用预设函数({{presetNames}})`},schema:[]},create:Pr},Y=[`@longzai-intelligence/config/vitest`,`@longzai-intelligence/vitest-config`],X=[`createBaseVitestConfig`,`createDomainVitestConfig`,`createDomainUIVitestConfig`,`createPackageVitestConfig`,`createTypeOnlyVitestConfig`,`createDesktopVitestConfig`,`createWebVitestConfig`,`defineVitestConfig`,`defineDomainVitestConfig`,`defineDomainUIVitestConfig`,`definePackageVitestConfig`,`defineTypeOnlyVitestConfig`,`defineDesktopVitestConfig`,`defineWebVitestConfig`],Ir=[`defineConfig`],Lr=[`infrastructure/configs/vitest/vitest.config.ts`];function Rr(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`ExportDefaultDeclaration`&&`declaration`in e&&e.declaration!==null&&typeof e.declaration==`object`}function zr(e){return e.endsWith(`vitest.config.ts`)}function Br(e,t,n){if(!s(e))return;let r=e.source.value;for(let t of e.specifiers){if(!c(t))continue;let i=t.imported.name;if(r===`vitest`&&Ir.includes(i)){n.hasForbiddenImport=!0,n.forbiddenImportNode=e,n.forbiddenImportName=i;continue}Y.includes(r)&&X.includes(i)&&(n.hasValidImport=!0)}}function Vr(e,t){return!t.hasForbiddenImport||!t.forbiddenImportNode?!1:(e.report({node:t.forbiddenImportNode,messageId:`forbiddenVitestImport`,data:{importedName:t.forbiddenImportName,configPackages:Y.join(` 或 `),allowedExports:X.join(`, `)}}),!0)}function Hr(e,t,n){if(!a(e))return!1;let r=e.callee.name;return typeof r==`string`&&!X.includes(r)&&!n.hasValidImport?(t.report({node:e,messageId:`invalidConfigFunction`,data:{configPackages:Y.join(` 或 `),allowedExports:X.join(`, `)}}),!0):!1}function Ur(e,t,n){return l(e)?n.hasValidImport?!1:(t.report({node:e,messageId:`invalidConfigObject`,data:{configPackages:Y.join(` 或 `),allowedExports:X.join(`, `)}}),!0):!1}function Wr(e,t,n){if(!Rr(e))return;n.hasExportDefault=!0;let r=e.declaration;Vr(t,n)||Hr(r,t,n)||Ur(r,t,n)}function Gr(e,t){if(!t.hasExportDefault){let t=e.sourceCode.ast;e.report({node:t,messageId:`missingConfigImport`,data:{configPackages:Y.join(` 或 `),allowedExports:X.join(`, `)}})}}function Kr(e){let t=e.filename;if(!zr(t)||ee(t,Lr))return{};let n={hasValidImport:!1,hasForbiddenImport:!1,hasExportDefault:!1,forbiddenImportNode:null,forbiddenImportName:``};return{ImportDeclaration(t){Br(t,e,n)},ExportDefaultDeclaration(t){Wr(t,e,n)},"Program:exit"(){Gr(e,n)}}}const qr={meta:{type:`problem`,docs:{description:`强制执行 vitest.config.ts 文件中的配置导入规范,必须使用共享配置函数`},messages:{forbiddenVitestImport:`禁止从 vitest 包导入 {{importedName}}。应使用共享配置函数({{allowedExports}})从 {{configPackages}} 导入`,invalidConfigFunction:`必须使用共享配置函数({{allowedExports}})从 {{configPackages}} 导入`,missingConfigImport:`vitest.config.ts 必须使用共享配置函数({{allowedExports}})从 {{configPackages}} 导入`},schema:[]},create:Kr},Z=`@longzai-intelligence/config/eslint`,Q=[`createBaseConfig`,`createLibraryConfig`,`createDomainConfig`,`createReactConfig`,`createElectronConfig`,`createNextConfig`,`createArchitectureConfig`,`createServerConfig`,`createNestConfig`,`createHonoConfig`],Jr=[`baseConfig`,`libraryConfig`,`domainConfig`,`reactConfig`,`electronConfig`,`nextConfig`,`architectureConfig`,`serverConfig`,`nestConfig`,`honoConfig`,`base`,`library`,`domain`,`react`,`electron`,`next`,`architecture`,`server`,`nest`,`hono`];function Yr(e,t){e.report({node:t,messageId:`forbiddenDefaultImport`,data:{configPackage:Z,allowedFunctions:Q.join(`、`)}})}function Xr(e,t){e.report({node:t,messageId:`forbiddenNamespaceImport`,data:{configPackage:Z,allowedFunctions:Q.join(`、`)}})}function Zr(e,t,n){e.report({node:t,messageId:`forbiddenConfigImport`,data:{importedName:n,allowedFunctions:Q.join(`、`)}})}function Qr(e,t){e.report({node:t,messageId:`missingCreateFunction`,data:{configPackage:Z,allowedFunctions:Q.join(`、`)}})}function $r(e,t){if(!s(t)||t.source.value!==Z)return;let n=[],r=[],i=!1;for(let a of t.specifiers)if(c(a)){if(o(a)){Yr(e,t),i=!0;continue}if(a.type===`ImportNamespaceSpecifier`){Xr(e,t),i=!0;continue}Jr.includes(a.imported.name)?r.push(a):Q.includes(a.imported.name)&&n.push(a)}if(!i){for(let n of r)Zr(e,t,n.imported.name);r.length===0&&n.length===0&&(t.specifiers.some(e=>c(e)&&e.type===`ImportSpecifier`&&!Q.includes(e.imported.name)&&!Jr.includes(e.imported.name))||Qr(e,t))}}function ei(e){return{ImportDeclaration(t){$r(e,t)}}}const ti={meta:{type:`problem`,docs:{description:`强制执行 eslint.config.ts 文件中的配置导入规范,必须使用 createXxxConfig 函数`},messages:{forbiddenDefaultImport:`禁止从 {{configPackage}} 使用默认导入。应使用具名导入 {{allowedFunctions}} 等配置创建函数`,forbiddenNamespaceImport:`禁止从 {{configPackage}} 使用命名空间导入。应使用具名导入 {{allowedFunctions}} 等配置创建函数`,forbiddenConfigImport:`禁止从配置包导入 {{importedName}}。应使用 {{allowedFunctions}} 等配置创建函数`,missingCreateFunction:`必须从 {{configPackage}} 导入至少一个配置创建函数(如 {{allowedFunctions}})`},schema:[]},create:ei},ni=[`./tsconfig/app.json`,`./tsconfig/node.json`,`./tsconfig/test.json`],ri=[`app.json`,`node.json`,`test.json`,`build.json`];function ii(e){return typeof e==`object`&&!!e&&`path`in e&&typeof e.path==`string`}function ai(e){return Array.isArray(e)&&e.every(ii)}function oi(e){return!(typeof e!=`object`||!e)}function si(e){try{let t=ie(e,`utf-8`);return JSON.parse(t)}catch{return null}}function ci(e){let t=e.map(e=>e.path);return ni.filter(e=>!t.includes(e))}function li(e){return e.map(e=>e.path).filter(e=>!ni.includes(e))}const ui=new WeakMap;function di(e,t){let n=ui.get(e);if(n||(n=new Map,ui.set(e,n)),n.has(t))return n.get(t);let r=p(t),i={hasDir:r,missingFiles:r?fi(t):[]};return n.set(t,i),i}function fi(e){return ri.filter(t=>!p(d(e,t)))}function pi(e,t,n){if(!n.references||!ai(n.references)){e.report({node:t,messageId:`missingReferences`});return}let r=ci(n.references);r.length>0&&e.report({node:t,messageId:`missingRequiredReference`,data:{missingPath:r[0]}});let i=li(n.references);for(let n of i)e.report({node:t,messageId:`extraReference`,data:{extraPath:n}})}function mi(e,t,n){return n.files===void 0?!0:Array.isArray(n.files)?n.files.length===0?!0:(e.report({node:t,messageId:`filesMustBeEmpty`}),!1):(e.report({node:t,messageId:`filesMustBeArray`}),!1)}const hi={meta:{type:`problem`,docs:{description:`检查 tsconfig.json 是否正确使用 references 配置`},messages:{missingReferences:`tsconfig.json 必须使用 references 配置,采用目录收拢多配置模式。请添加 references 字段,包含 app.json、node.json、test.json 三个配置。`,missingRequiredReference:`tsconfig.json 的 references 缺少必需的配置: "{{missingPath}}"。references 必须包含 ./tsconfig/app.json、./tsconfig/node.json、./tsconfig/test.json。`,filesMustBeEmpty:`tsconfig.json 使用 references 时,files 必须为空数组 "[]"。请将 files 设置为空数组或移除 files 字段。`,filesMustBeArray:`tsconfig.json 使用 references 时,files 必须为数组类型。请将 files 设置为空数组 "[]"。`,missingTsconfigDirectory:`缺少 tsconfig/ 目录。请创建 tsconfig/ 目录并添加 app.json、node.json、test.json、build.json 配置文件。`,missingConfigFile:`tsconfig/ 目录缺少必需的配置文件: {{missingFiles}}。必需的配置文件包括: app.json、node.json、test.json、build.json。`,extraReference:`tsconfig.json 的 references 包含非必需的配置: "{{extraPath}}"。references 应仅包含 ./tsconfig/app.json、./tsconfig/node.json、./tsconfig/test.json。`},schema:[]},create(e){let t=e.filename;if(!t.endsWith(`tsconfig.json`)||t.includes(`tsconfig/`))return{};let n=d(re(t),`tsconfig`);return{Program(r){let i=si(t);if(!oi(i))return;let a=di(e,n);if(!a.hasDir){e.report({node:r,messageId:`missingTsconfigDirectory`});return}if(a.missingFiles.length>0){e.report({node:r,messageId:`missingConfigFile`,data:{missingFiles:a.missingFiles.join(`, `)}});return}mi(e,r,i)&&pi(e,r,i)}}}};function gi(e){let t=e.replace(/\\/g,`/`);return t.includes(`/src/preload/`)&&!t.includes(`/__tests__/`)}const _i={meta:{type:`problem`,docs:{description:`禁止使用字符串字面量作为 IPC 通道名`},messages:{noStringLiteral:`禁止使用字符串字面量作为 IPC 通道名。请使用通道常量。`},schema:[]},create(e){return gi(e.filename)?{CallExpression(t){if(t.callee.type!==`Identifier`||t.callee.name!==`invoke`||t.arguments.length===0)return;let n=t.arguments[0];n&&n.type===`Literal`&&typeof n.value==`string`&&e.report({node:n,messageId:`noStringLiteral`})},ObjectExpression(t){if(t.parent?.type===`CallExpression`&&t.parent.callee.type===`Identifier`&&t.parent.callee.name===`createTypedAPI`)for(let n of t.properties)n.type===`Property`&&n.value.type===`Literal`&&typeof n.value.value==`string`&&e.report({node:n.value,messageId:`noStringLiteral`})}}:{}}};function vi(e){let t=e.replace(/\\/g,`/`);return t.endsWith(`/src/preload/index.ts`)&&!t.includes(`/__tests__/`)}function yi(e){let t=e.parent;for(;t;){if(t.type===`CallExpression`&&t.callee.type===`Identifier`&&t.callee.name===`exposeSafeAPI`)return!0;t=t.parent}return!1}const bi={meta:{type:`problem`,docs:{description:`要求使用 exposeSafeAPI 进行 API 暴露`},messages:{requireExposeSafeApi:`请使用 exposeSafeAPI 进行 API 暴露,而非直接调用 contextBridge.exposeInMainWorld。`},schema:[]},create(e){return vi(e.filename)?{CallExpression(t){t.callee.type===`MemberExpression`&&t.callee.object.type===`Identifier`&&t.callee.object.name===`contextBridge`&&t.callee.property.type===`Identifier`&&t.callee.property.name===`exposeInMainWorld`&&(yi(t)||e.report({node:t,messageId:`requireExposeSafeApi`}))}}:{}}};function xi(e){let t=e.replace(/\\/g,`/`);return t.includes(`/src/preload/utils/`)&&!t.includes(`/__tests__/`)}function Si(e){return e.startsWith(`createTyped`)}const Ci={meta:{type:`problem`,docs:{description:`禁止自定义 IPC 工具函数`},messages:{noCustomIPC:`禁止自定义 IPC 工具函数。请使用 @longzai-intelligence/electron/preload 提供的标准函数。`},schema:[]},create(e){return xi(e.filename)?{FunctionDeclaration(t){t.id&&Si(t.id.name)&&e.report({node:t,messageId:`noCustomIPC`})},VariableDeclaration(t){for(let n of t.declarations){if(n.id.type!==`Identifier`||!Si(n.id.name))continue;let r=n.init;r&&(r.type===`FunctionExpression`||r.type===`ArrowFunctionExpression`)&&e.report({node:t,messageId:`noCustomIPC`})}}}:{}}},wi=new Set([`unwrap`,`unwrapIPCResult`]);function Ti(e){let t=e.replace(/\\/g,`/`);return t.includes(`/src/renderer/`)&&!t.includes(`/__tests__/`)&&!t.endsWith(`.test.ts`)&&!t.endsWith(`.spec.ts`)}function Ei(e){if(e.type!==`CallExpression`)return!1;let{callee:t}=e;if(t.type!==`MemberExpression`)return!1;let{object:n}=t;return n.type===`MemberExpression`?n.object.type===`Identifier`&&n.object.name===`window`:!1}function Di(e){let t=e.parent;for(;t;){if(t.type===`CallExpression`&&t.callee.type===`Identifier`&&wi.has(t.callee.name))return!0;if(t.type===`CallExpression`)break;t=t.parent}return!1}const Oi={meta:{type:`problem`,docs:{description:`渲染层调用 IPC API 时必须使用 unwrap 解包结果`},messages:{requireUnwrap:`渲染层调用 IPC API 时必须使用 unwrap 或 unwrapIPCResult 解包结果。`},schema:[]},create(e){return Ti(e.filename)?{CallExpression(t){Ei(t)&&(Di(t)||e.report({node:t,messageId:`requireUnwrap`}))}}:{}}};function ki(e){return e.endsWith(`Class`)}function Ai(e,t){if(typeof t!=`object`||!t||!(`imported`in t)||!(`local`in t)||t.local===null||typeof t.local!=`object`||!(`name`in t.local)||typeof t.local.name!=`string`||!(`range`in t.local)||!Array.isArray(t.local.range))return;let n=t.local.name,r=t.imported!==null&&typeof t.imported==`object`&&`name`in t.imported&&typeof t.imported.name==`string`?t.imported.name:n;n!==r&&ki(n)&&e.report({node:t,messageId:`noClassSuffixAlias`,data:{aliasName:n,importedName:r}})}function ji(e){return{ImportSpecifier(t){Ai(e,t)}}}const Mi={meta:{type:`problem`,docs:{description:`禁止在 import 别名中使用 "Class" 后缀`},messages:{noClassSuffixAlias:`导入别名 "{{aliasName}}" 使用了 "Class" 后缀,这是不允许的命名方式。请使用更具描述性的名称,或直接使用原始名称 "{{importedName}}"`},schema:[]},create:ji},Ni=/domains\/[^/]+\/implementation\/src\/index\.ts$/,Pi=[/\.\/typeorm/,/\.\/typeorm'/,/\.\/typeorm"/];function Fi(e){return Pi.some(t=>t.test(e))}const Ii={meta:{type:`problem`,docs:{description:`Implementation 包导出控制:禁止从主入口重新导出 typeorm.ts 的内容,typeorm.ts 仅供 DataSource/迁移基础设施使用`,recommended:!0},schema:[],messages:{forbiddenTypeormReExport:`禁止从主入口重新导出 typeorm.ts 的内容。typeorm.ts 是专门的持久化入口,仅供 DataSource/迁移基础设施使用,业务代码应通过主入口导入领域服务`}},create(e){let t=e.filename;return Ni.test(t)?{ExportNamedDeclaration(t){if(!t.source)return;let n=t.source.value;typeof n==`string`&&Fi(n)&&e.report({node:t,messageId:`forbiddenTypeormReExport`})},ExportAllDeclaration(t){if(!t.source)return;let n=t.source.value;typeof n==`string`&&Fi(n)&&e.report({node:t,messageId:`forbiddenTypeormReExport`})}}:{}}},Li={type:`suggestion`,docs:{description:`强制 domain entities 导出命名符合 {DOMAIN}_ORM_ENTITIES 规范`,recommended:!0},fixable:void 0,schema:[],messages:{invalidNaming:`entities 导出命名 "{{name}}" 不符合规范,应使用 "{{expected}}" 格式`,genericNaming:`entities 导出命名 "{{name}}" 是通用名称,应使用具体的 domain 名称 "{{expected}}"`,missingOrm:`entities 导出命名 "{{name}}" 缺少 "_ORM" 前缀,应使用 "{{expected}}"`,typoDetected:`entities 导出命名 "{{name}}" 可能存在拼写错误,应使用 "{{expected}}"`}},Ri=new Set([`DOMAIN_ENTITIES`,`ALL_ENTITIES`,`ENTITIES`]);function zi(e){let t=e.match(/\/domains\/([^/]+)\/implementation\/src\/typeorm\.ts$/);return!t||!t[1]?null:t[1].split(`-`).map(e=>e.toUpperCase()).join(`_`)}function Bi(e,t){return e.endsWith(`_ORM_ENTITIES`)?!1:e.endsWith(`_ENTITIES`)?e.replace(`_ENTITIES`,``)===t.replace(`_ORM_ENTITIES`,``):!1}function Vi(e){return Ri.has(e)}function Hi(e,t){let n=e.length,r=t.length,i=[];for(let a=0;a<=n;a++){i[a]=[];for(let n=0;n<=r;n++)a===0?i[a][n]=n:n===0?i[a][n]=a:e[a-1]===t[n-1]?i[a][n]=i[a-1][n-1]:i[a][n]=Math.min(i[a-1][n-1],i[a][n-1],i[a-1][n])+1}return i[n][r]}function Ui(e,t){let n=e.replace(`_ORM_ENTITIES`,``).replace(`_ENTITIES`,``),r=t.replace(`_ORM_ENTITIES`,``);return n===r?!1:n.toLowerCase()===r.toLowerCase()?!0:Hi(n,r)<=2}function Wi(e,t,n,r){Bi(n,r)?e.report({node:t,messageId:`missingOrm`,data:{name:n,expected:r}}):Vi(n)?e.report({node:t,messageId:`genericNaming`,data:{name:n,expected:r}}):Ui(n,r)?e.report({node:t,messageId:`typoDetected`,data:{name:n,expected:r}}):e.report({node:t,messageId:`invalidNaming`,data:{name:n,expected:r}})}function Gi(e,t,n,r){if(typeof n!=`object`||!n||!(`id`in n)||n.id===null||typeof n.id!=`object`||!(`type`in n.id)||n.id.type!==`Identifier`||!(`name`in n.id)||typeof n.id.name!=`string`)return;let i=n.id.name;!i.endsWith(`_ENTITIES`)&&!i.endsWith(`_ORM_ENTITIES`)||i!==r&&Wi(e,t,i,r)}function Ki(e,t,n,r){if(typeof n!=`object`||!n||!(`exported`in n)||n.exported===null||typeof n.exported!=`object`||!(`type`in n.exported)||n.exported.type!==`Identifier`||!(`name`in n.exported)||typeof n.exported.name!=`string`)return;let i=n.exported.name;!i.endsWith(`_ENTITIES`)&&!i.endsWith(`_ORM_ENTITIES`)||i!==r&&Wi(e,t,i,r)}function qi(e,t){function n(n){if(typeof n==`object`&&n&&`declaration`in n&&n.declaration!==null&&typeof n.declaration==`object`&&`type`in n.declaration&&n.declaration.type===`VariableDeclaration`&&`declarations`in n.declaration&&Array.isArray(n.declaration.declarations))for(let r of n.declaration.declarations)Gi(e,n,r,t);if(typeof n==`object`&&n&&`specifiers`in n&&Array.isArray(n.specifiers))for(let r of n.specifiers)Ki(e,n,r,t)}return n}function Ji(e){let t=e.filename;if(!t.endsWith(`typeorm.ts`))return{};let n=zi(t);return n?{ExportNamedDeclaration:qi(e,`${n}_ORM_ENTITIES`)}:{}}const Yi={meta:Li,create:Ji};function Xi(e){return e.replace(/\\/g,`/`).includes(`/apps/`)}function Zi(e){return e.endsWith(`-implementation`)}function Qi(e){return e.endsWith(`Entity`)}function $i(e){return e.endsWith(`UseCase`)}function ea(e){return[/PortAdapter$/,/_TOKEN$/,/^create\w+Repository$/,/^create\w+Adapter$/].some(t=>t.test(e))}const ta={noEntityImport:`禁止在 apps 层导入 Entity 类 "{{importName}}"。请使用 contract 包的 Port 接口进行操作。`,noUseCaseImport:`禁止在 apps 层导入 UseCase 类 "{{importName}}"。请使用 contract 包的 Port 接口进行操作。`,noImplementationImport:`禁止在 apps 层从 implementation 包导入 "{{importName}}"。请使用 contract 包的 Port 接口。`};function na(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`ImportSpecifier`}function ra(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`Identifier`&&`name`in e&&typeof e.name==`string`}function ia(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`Literal`&&`value`in e&&typeof e.value==`string`}function aa(e){if(!(`imported`in e)||e.imported===null||typeof e.imported!=`object`)return null;let t=e.imported;return ra(t)?t.name:ia(t)?t.value:null}function oa(e,t,n){Qi(n)?e.report({node:t,messageId:`noEntityImport`,data:{importName:n}}):$i(n)?e.report({node:t,messageId:`noUseCaseImport`,data:{importName:n}}):ea(n)||e.report({node:t,messageId:`noImplementationImport`,data:{importName:n}})}function sa(e,t,n){if(!na(t))return;let r=aa(t);r&&oa(e,t,r)}const ca={meta:{type:`problem`,docs:{description:`禁止在 apps 层导入 implementation 包的 Entity 和 UseCase`},messages:ta,schema:[]},create(e){let t=e.filename;return Xi(t)?{ImportDeclaration(t){if(!(`source`in t)||t.source===null||typeof t.source!=`object`||!(`type`in t.source)||t.source.type!==`Literal`||!(`value`in t.source)||typeof t.source.value!=`string`)return;let n=t.source.value;if(Zi(n)&&!(!(`specifiers`in t)||!Array.isArray(t.specifiers)))for(let r of t.specifiers)na(r)&&sa(e,r,n)}}:{}}};function la(e){let t=e.replace(/\\/g,`/`);return t.includes(`/domains/`)&&t.includes(`/implementation/src/index.ts`)}function ua(e){return e.endsWith(`Entity`)}function da(e){return e.endsWith(`Repository`)&&!e.startsWith(`I`)}function fa(e){return e.endsWith(`OrmEntity`)}function pa(e){return e.endsWith(`_ORM_ENTITIES`)}function ma(e){return e.endsWith(`OrmMapper`)}function ha(e){return e.endsWith(`Schema`)}function ga(e){return`exportKind`in e&&typeof e.exportKind==`string`?e.exportKind===`value`:!0}function _a(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`ExportSpecifier`}function va(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`Identifier`&&`name`in e&&typeof e.name==`string`}function ya(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`Literal`&&`value`in e&&typeof e.value==`string`}function ba(e){if(typeof e!=`object`||!e||!(`exported`in e)||e.exported===null||typeof e.exported!=`object`)return null;let t=e.exported;return va(t)?t.name:ya(t)?t.value:null}function $(e,t,n,r){e.report({node:t,messageId:n,data:{exportName:r}})}function xa(e,t,n){return ua(n)&&ga(t)?($(e,t,`noEntityValueExport`,n),!0):!1}function Sa(e,t,n){return da(n)?($(e,t,`noRepositoryTypeExport`,n),!0):!1}function Ca(e,t,n){return fa(n)?($(e,t,`noOrmEntityExport`,n),!0):pa(n)?($(e,t,`noOrmEntitiesExport`,n),!0):ma(n)?($(e,t,`noOrmMapperExport`,n),!0):!1}function wa(e,t,n){ha(n)&&$(e,t,`noSchemaExport`,n)}function Ta(e,t,n){xa(e,t,n)||Sa(e,t,n)||Ca(e,t,n)||wa(e,t,n)}function Ea(e,t){if(!(!(`source`in t)||t.source===null||typeof t.source!=`object`||!(`type`in t.source)||t.source.type!==`Literal`||!(`value`in t.source)||typeof t.source.value!=`string`)&&!(!(`specifiers`in t)||!Array.isArray(t.specifiers)))for(let n of t.specifiers){if(!_a(n))continue;let t=ba(n);t&&Ta(e,n,t)}}const Da={meta:{type:`problem`,docs:{description:`检查 Domain Implementation 包的导出是否符合规范`},messages:{noEntityValueExport:'禁止从主入口值导出 Entity 类 "{{exportName}}"。请改为类型导出:`export type { {{exportName}} }` 或移除导出。',noRepositoryTypeExport:`禁止导出 Repository 类型 "{{exportName}}"。Repository 是内部实现,不应暴露给外部。请移除此导出。`,noOrmEntityExport:`禁止从主入口导出 ORM 实体 "{{exportName}}"。请创建 src/typeorm.ts 入口文件,从该入口导出 ORM 实体。`,noOrmEntitiesExport:`禁止从主入口导出 ORM 实体集合 "{{exportName}}"。请创建 src/typeorm.ts 入口文件,从该入口导出。`,noOrmMapperExport:`禁止导出 ORM Mapper "{{exportName}}"。ORM Mapper 是基础设施实现细节,不应暴露给外部。请移除此导出。`,noSchemaExport:`禁止导出 Schema 定义 "{{exportName}}"。Schema 是实现细节,应完全保留在 Domain 内部。请仅导出从 Schema 推断的类型。`},schema:[]},create(e){let t=e.filename;return la(t)?{ExportNamedDeclaration(t){Ea(e,t)}}:{}}},Oa=`@longzai-intelligence/architecture-core`,ka={meta:{name:Oa,version:`1.0.0`},rules:{"dependency-direction":be,"no-core-types-in-apps":_,"business-leak":C,"file-naming":Dt,"require-type-suffix":Mt,"no-cross-package-relative-import":Ut,"prefer-split-export-const":Wn,"require-class-suffix":sr,"require-interface-naming":yr,"require-type-naming":Cr,"require-dto-naming":Dr,"no-class-suffix-alias":Mi,"implementation-export-control":Ii,"no-implementation-import-in-apps":ca,"domain-export-compliance":Da}},Aa=`@longzai-intelligence/architecture-domain`,ja={meta:{name:Aa,version:`1.0.0`},rules:{"domain-export":D,"domain-typeorm-import":O,"layer-readme-required":$n,"require-domain-entities-naming":Yi}},Ma=`@longzai-intelligence/architecture-electron`,Na={meta:{name:Ma,version:`1.0.0`},rules:{"platform-leak":x,"no-implementation-in-renderer":It,"no-unsafe-electron-api-exposure":An,"no-generic-ipc-bridge-exposure":Pn,"no-direct-ipcrenderer-in-preload":In,"tsconfig-references":hi,"require-typed-ipc-channel":_i,"require-expose-safe-api":bi,"no-custom-ipc-utility":Ci,"require-unwrap-ipc-result":Oi}},Pa=`@longzai-intelligence/architecture-library`,Fa={meta:{name:Pa,version:`1.0.0`},rules:{"test-file-placement":rn,"no-non-test-files-in-tests-directory":fn,"test-file-matches-source":W,"require-tsup-config-import":jr,"require-tsdown-config-import":Fr,"require-vitest-config-import":qr,"require-eslint-config-import":ti}},Ia=`@longzai-intelligence/architecture`,La={meta:{name:Ia,version:`1.0.0`},rules:{"dependency-direction":be,"no-core-types-in-apps":_,"platform-leak":x,"business-leak":C,"domain-export":D,"domain-typeorm-import":O,"file-naming":Dt,"require-type-suffix":Mt,"no-implementation-in-renderer":It,"no-cross-package-relative-import":Ut,"test-file-placement":rn,"no-non-test-files-in-tests-directory":fn,"test-file-matches-source":W,"no-unsafe-electron-api-exposure":An,"no-generic-ipc-bridge-exposure":Pn,"no-direct-ipcrenderer-in-preload":In,"prefer-split-export-const":Wn,"layer-readme-required":$n,"require-class-suffix":sr,"require-interface-naming":yr,"require-type-naming":Cr,"require-dto-naming":Dr,"require-tsup-config-import":jr,"require-tsdown-config-import":Fr,"require-vitest-config-import":qr,"require-eslint-config-import":ti,"tsconfig-references":hi,"require-typed-ipc-channel":_i,"require-expose-safe-api":bi,"no-custom-ipc-utility":Ci,"require-unwrap-ipc-result":Oi,"no-class-suffix-alias":Mi,"implementation-export-control":Ii,"require-domain-entities-naming":Yi,"no-implementation-import-in-apps":ca}};export{Oa as CORE_PLUGIN_NAME,Aa as DOMAIN_PLUGIN_NAME,Ma as ELECTRON_PLUGIN_NAME,Pa as LIBRARY_PLUGIN_NAME,Ia as PLUGIN_NAME,ka as architectureCorePlugin,ja as architectureDomainPlugin,Na as architectureElectronPlugin,Fa as architectureLibraryPlugin,La as architecturePlugin};
1
+ import{createDtoSuffixFixer as e,createRemoveIPrefixFixer as t,hasIPrefix as n,hasIdWithName as r,hasIdWithNameAndRange as i,isCallExpressionNode as a,isDefaultImport as o,isImportDeclaration as s,isImportSpecifier as c,isInExcludedPath as ee,isObjectExpressionNode as l,isValidDtoNameCamelCase as te,isValidDtoNameUpperCase as ne}from"@longzai-intelligence/eslint-utils";import u,{dirname as re,join as d}from"node:path";import f,{existsSync as p,readFileSync as ie}from"node:fs";import{AST_NODE_TYPES as m}from"@typescript-eslint/utils";const h={types:0,utils:1,"shared-kernel":2,contract:3,engine:4,platform:5,infrastructure:6,implementation:6},g={"@longzai-intelligence/shared-kernel":`shared-kernel`,"@longzai-intelligence/utils":`utils`,"@longzai-intelligence/error-utils":`utils`,"@longzai-intelligence/zod-utils":`utils`,"@longzai-intelligence/testing-utils":`utils`,"@longzai-intelligence/host-contracts":`contract`,"@longzai-intelligence/typeorm-adapter":`implementation`,"@longzai-intelligence/typeorm-utils":`utils`,"@longzai-intelligence/http-client":`utils`,"@longzai-intelligence/pagination":`utils`,"@longzai-intelligence/turbo-output-parser":`utils`,"@longzai-intelligence/electron":`implementation`},_=[{suffix:`-contract`,layer:`contract`},{suffix:`-implementation`,layer:`implementation`},{suffix:`-engine`,layer:`engine`},{suffix:`-runtime`,layer:`engine`}],v={pathPatterns:[{pattern:/\/domains\/[^/]+\/implementation\//,layer:`implementation`},{pattern:/\/domains\/[^/]+\/contract\//,layer:`contract`},{pattern:/\/domains\/shared-kernel\//,layer:`shared-kernel`},{pattern:/\/infrastructure\//,layer:`infrastructure`},{pattern:/\/packages\/utils\//,layer:`utils`},{pattern:/\/packages\/errors\//,layer:`utils`},{pattern:/\/packages\/zod-utils\//,layer:`utils`},{pattern:/\/packages\/testing-utils\//,layer:`utils`},{pattern:/\/packages\/engine\/[^/]+\//,layer:`engine`},{pattern:/\/packages\/design-system\/primitives\//,layer:`utils`},{pattern:/\/packages\/design-system\/composites\//,layer:`implementation`},{pattern:/\/packages\/design-system\/utils\//,layer:`utils`},{pattern:/\/packages\/electron\//,layer:`implementation`},{pattern:/\/packages\/typeorm-adapter\//,layer:`implementation`},{pattern:/\/packages\/typeorm-utils\//,layer:`utils`},{pattern:/\/packages\/http-client\//,layer:`utils`},{pattern:/\/packages\/pagination\//,layer:`utils`},{pattern:/\/packages\/turbo-output-parser\//,layer:`utils`},{pattern:/\/packages\/host-contracts\//,layer:`contract`},{pattern:/\/packages\/event-bus\/contract\//,layer:`contract`},{pattern:/\/packages\/event-bus\/implementation\//,layer:`implementation`},{pattern:/\/packages\/payment\/core\//,layer:`contract`},{pattern:/\/packages\/payment\/adapters\//,layer:`implementation`},{pattern:/\/packages\/payment\/presets\//,layer:`implementation`},{pattern:/\/packages\/logger\/core\//,layer:`contract`},{pattern:/\/packages\/logger\/adapters\//,layer:`implementation`},{pattern:/\/packages\/logger\/presets\//,layer:`implementation`},{pattern:/\/packages\/react-devtools\/core\//,layer:`contract`},{pattern:/\/packages\/react-devtools\/adapters\//,layer:`implementation`},{pattern:/\/packages\/react-devtools\/ui\//,layer:`implementation`},{pattern:/\/packages\/react-devtools\/presets\//,layer:`implementation`},{pattern:/\/packages\/feed-parser\/protocol\//,layer:`contract`},{pattern:/\/packages\/feed-parser\/[^/]+\//,layer:`implementation`}],packagePrefix:`@longzai-intelligence/`,specialPackageMappings:g,packageSuffixMappings:_},ae=[{pattern:/\/src\/domain\//,layer:`contract`},{pattern:/\/src\/engine\//,layer:`engine`},{pattern:/\/src\/platform\//,layer:`platform`},{pattern:/\/src\/infrastructure\//,layer:`infrastructure`},{pattern:/\/src\/shared\//,layer:`shared-kernel`}],oe=[{pattern:/\/src\/domain\//,layer:`contract`},{pattern:/\/src\/engine\//,layer:`engine`},{pattern:/\/src\/platform\//,layer:`platform`},{pattern:/\/src\/infrastructure\//,layer:`infrastructure`},{pattern:/\/src\/shared\//,layer:`shared-kernel`}],se=new WeakMap;function ce(e,t){let n=e.replace(/\\/g,`/`),r=t??v.pathPatterns;if(r){for(let{pattern:e,layer:t}of r)if(e.test(n))return{layer:t,priority:h[t]}}return n.includes(`/apps/`)?ue(n):n.includes(`/packages/`)?de(n):null}function le(e,t,n){let r=se.get(t);if(r||(r=new Map,se.set(t,r)),r.has(e))return r.get(e);let i=ce(e,n);return r.set(e,i),i}function ue(e){for(let{pattern:t,layer:n}of ae)if(t.test(e))return{layer:n,priority:h[n]};return null}function de(e){for(let{pattern:t,layer:n}of oe)if(t.test(e))return{layer:n,priority:h[n]};return null}function fe(e,t){let n=t?.packagePrefix??`@longzai-intelligence/`;if(!e.startsWith(n))return null;let r=e.split(`/`)[1];if(!r)return null;let i=`${n}${r}`,a=(t?.specialPackageMappings??g)[i];if(a)return{layer:a,priority:h[a]};let o=t?.packageSuffixMappings??_;for(let{suffix:e,layer:t}of o)if(r.endsWith(e))return{layer:t,priority:h[t]};return null}const pe={types:`类型层 (Types)`,utils:`工具层 (Utils)`,"shared-kernel":`共享内核层 (Shared Kernel)`,contract:`契约层 (Contract)`,engine:`引擎层 (Engine)`,platform:`平台层 (Platform)`,infrastructure:`基础设施层 (Infrastructure)`,implementation:`实现层 (Implementation)`};function me(e){return pe[e]}function he(e,t){return h[e]>=h[t]}const ge=new Set([`types`,`utils`,`shared-kernel`,`contract`,`engine`,`platform`,`infrastructure`,`implementation`]);function y(e){return ge.has(e)}function _e(e){return e?e.reduce((e,{pattern:t,layer:n})=>(y(n)&&e.push({pattern:ve(t),layer:n}),e),[]):[]}function ve(e){let t=e.match(/^\/(.+)\/([gimsuvy]*)$/);if(t&&t[1]){let e=t[1],n=t[2]??``;return new RegExp(e,n)}return new RegExp(e)}function ye(e){if(!e)return;let t={};for(let[n,r]of Object.entries(e))y(r)&&(t[n]=r);return Object.keys(t).length>0?t:void 0}function be(e){if(!e||e.length===0)return;let t=[];for(let{suffix:n,layer:r}of e)y(r)&&t.push({suffix:n,layer:r});return t.length>0?t:void 0}function xe(e){let t={};return e.pathPatterns&&(t.pathPatterns=_e(e.pathPatterns)),e.packagePrefix&&(t.packagePrefix=e.packagePrefix),e.specialPackageMappings&&(t.specialPackageMappings=ye(e.specialPackageMappings)),e.packageSuffixMappings&&(t.packageSuffixMappings=be(e.packageSuffixMappings)),t}const b={meta:{type:`problem`,docs:{description:`强制执行 Clean Architecture 的依赖方向规则`},messages:{invalidDependency:`依赖方向违规: {{currentLayer}} ({{currentLayerName}}) 不能导入 {{importLayer}} ({{importLayerName}})。依赖应该从外层指向内层,请检查导入语句。`},schema:[{type:`object`,properties:{pathPatterns:{type:`array`,items:{type:`object`,properties:{pattern:{type:`string`},layer:{type:`string`}},required:[`pattern`,`layer`],additionalProperties:!1}},packagePrefix:{type:`string`},specialPackageMappings:{type:`object`,additionalProperties:{type:`string`}},packageSuffixMappings:{type:`array`,items:{type:`object`,properties:{suffix:{type:`string`},layer:{type:`string`}},required:[`suffix`,`layer`],additionalProperties:!1}}},additionalProperties:!1}]},create(e){let t=xe(e.options?.[0]||{}),n={pathPatterns:t.pathPatterns??v.pathPatterns,packagePrefix:t.packagePrefix??v.packagePrefix,specialPackageMappings:t.specialPackageMappings??v.specialPackageMappings,packageSuffixMappings:t.packageSuffixMappings??v.packageSuffixMappings},r=e.filename,i=le(r,e,n.pathPatterns);return i?{ImportDeclaration(t){let r=t.source.value;if(typeof r!=`string`)return;let a=fe(r,n);a&&(he(i.layer,a.layer)||e.report({node:t,messageId:`invalidDependency`,data:{currentLayer:i.layer,currentLayerName:me(i.layer),importLayer:a.layer,importLayerName:me(a.layer)}}))}}:{}}},Se=new Set(`Agent.Page.PageContent.Workspace.WorkspaceMember.User.Session.Task.Repository.Folder.SyncMetadata.SyncError.SyncErrorCode.SyncResult.SyncStatus.SyncConflictData.EntityChange.OfflineOperation.DirtyEntity.PullResult.PushResult.ApiResponse.P2PNode.ConnectionState.NetworkStatus.IMAgent.IMContact.IMConversation.IMMessage.IMGroup.IMGroupSettings`.split(`.`));function Ce(e){return e.replace(/\\/g,`/`).includes(`/apps/`)}function x(e){return Se.has(e)}const S={meta:{type:`problem`,docs:{description:`禁止在 apps 层定义核心领域类型`},messages:{noCoreTypesInApps:`禁止在 apps 层定义核心领域类型 "{{typeName}}"。请在 packages/types 或 packages/domain 中定义此类型。`},schema:[]},create(e){let t=e.filename;return Ce(t)?{TSInterfaceDeclaration(t){if(!r(t))return;let n=t.id.name;x(n)&&e.report({node:t,messageId:`noCoreTypesInApps`,data:{typeName:n}})},TSTypeAliasDeclaration(t){if(!r(t))return;let n=t.id.name;x(n)&&e.report({node:t,messageId:`noCoreTypesInApps`,data:{typeName:n}})},ClassDeclaration(t){if(!r(t))return;let n=t.id.name;x(n)&&e.report({node:t,messageId:`noCoreTypesInApps`,data:{typeName:n}})}}:{}}},C={node:[`fs`,`path`,`os`,`crypto`,`child_process`,`cluster`,`dgram`,`dns`,`http`,`https`,`net`,`readline`,`stream`,`tls`,`tty`,`udp`,`url`,`util`,`v8`,`vm`,`worker_threads`,`zlib`],browser:[`window`,`document`,`navigator`,`localStorage`,`sessionStorage`,`fetch`,`XMLHttpRequest`,`WebSocket`,`Worker`,`IndexedDB`,`Blob`,`File`,`FileReader`,`URL`,`URLSearchParams`,`History`,`Location`,`Screen`,`AudioContext`,`Canvas`,`Notification`,`Performance`,`ServiceWorker`],electron:[`ipcRenderer`,`ipcMain`,`app`,`BrowserWindow`,`dialog`,`Menu`,`Tray`,`nativeImage`,`shell`,`clipboard`]},we=new Set(C.node),Te=new Set(C.browser),Ee=new Set(C.electron),De=[/\/domains\/shared-kernel\//,/\/domains\/page-domain\//,/\/domains\/repository-domain\//,/\/domains\/agent-domain\//,/\/domains\/collab-domain\//,/\/domains\/identity-domain\//,/\/domains\/workflow-domain\//,/\/domains\/chat-domain\//,/\/domains\/workspace-domain\//];function Oe(e){let t=e.replace(/\\/g,`/`);return De.some(e=>e.test(t))}function ke(e){if(e.startsWith(`node:`)||we.has(e))return`node`;for(let t of C.node)if(e.startsWith(`${t}/`))return`node`;return null}function Ae(e){return Te.has(e)}function je(e){return Ee.has(e)}function Me(e){return typeof e==`object`&&!!e&&`object`in e&&e.object!==null&&typeof e.object==`object`&&`type`in e.object&&`name`in e.object}function Ne(e){return typeof e==`object`&&!!e&&`name`in e&&typeof e.name==`string`}function Pe(e,t){if(!s(e))return;let n=e.source.value;if(typeof n==`string`&&ke(n)){let r=n.replace(/^node:/,``);t.report({node:e,messageId:`nodeImport`,data:{moduleName:r}})}}function Fe(e,t){if(Me(e)&&e.object.type===`Identifier`){let n=e.object.name;Ae(n)&&t.report({node:e,messageId:`browserAPI`,data:{apiName:n}}),je(n)&&t.report({node:e,messageId:`electronAPI`,data:{apiName:n}})}}function Ie(e,t){if(!Ne(e))return;let n=e.name;(Ae(n)||je(n))&&e.parent&&e.parent.type!==`MemberExpression`&&t.report({node:e,messageId:`globalAPI`,data:{globalName:n}})}const Le={meta:{type:`problem`,docs:{description:`禁止在业务域层直接使用平台特定 API`},messages:{nodeImport:`平台代码泄漏: 业务域层禁止直接导入 Node.js 模块 '{{moduleName}}'。请通过 packages/platform 层的接口间接访问。`,browserAPI:`平台代码泄漏: 业务域层禁止直接使用浏览器 API '{{apiName}}'。请通过 packages/platform 层的接口间接访问。`,electronAPI:`平台代码泄漏: 业务域层禁止直接使用 Electron API '{{apiName}}'。请通过 packages/platform 层的接口间接访问。`,globalAPI:`平台代码泄漏: 业务域层禁止直接访问全局对象 '{{globalName}}'。请通过 packages/platform 层的接口间接访问。`},schema:[]},create(e){let t=e.filename;return Oe(t)?{ImportDeclaration(t){Pe(t,e)},MemberExpression(t){Fe(t,e)},Identifier(t){Ie(t,e)}}:{}}},Re=[/\/packages\/platform\//,/\/packages\/ui\//,/\/packages\/ui-kit\//,/\/packages\/engine\//,/\/packages\/utils\//,/\/packages\/types\//],ze=[`Page`,`Repository`,`Agent`,`Workflow`,`Workspace`,`User`,`Auth`,`Session`,`Message`,`Conversation`,`Sync`,`Favorite`,`Folder`,`Team`,`Execution`,`Task`,`Step`,`Trigger`],Be=[/^validate/,/^calculate/,/^compute/,/^determine/,/^check/,/^can/,/^should/,/^isAllowed/,/^isPermitted/,/^hasPermission/,/^applyRule/,/^enforce/,/^execute/];function Ve(e){let t=e.replace(/\\/g,`/`);return Re.some(e=>e.test(t))}function w(e){let t=e.charAt(0).toUpperCase()+e.slice(1);return ze.some(e=>t.includes(e))}function He(e){return Be.some(t=>t.test(e))}function Ue(e){return typeof e==`object`&&!!e&&`key`in e&&e.key!==null&&typeof e.key==`object`&&`type`in e.key&&e.key.type===`Identifier`&&`name`in e.key&&typeof e.key.name==`string`}function We(e){return typeof e==`object`&&!!e&&`id`in e&&e.id!==null&&typeof e.id==`object`&&`type`in e.id&&e.id.type===`Identifier`&&`name`in e.id&&typeof e.id.name==`string`&&`type`in e&&typeof e.type==`string`}function Ge(e,t){r(e)&&w(e.id.name)&&t.report({node:e,messageId:`businessClass`,data:{className:e.id.name}})}function Ke(e,t){Ue(e)&&He(e.key.name)&&t.report({node:e,messageId:`businessMethod`,data:{methodName:e.key.name}})}function qe(e,t){r(e)&&w(e.id.name)&&t.report({node:e,messageId:`businessInterface`,data:{interfaceName:e.id.name}})}function Je(e,t){We(e)&&w(e.id.name)&&t.report({node:e,messageId:`businessType`,data:{typeName:e.id.name}})}const Ye={meta:{type:`suggestion`,docs:{description:`检测技术层中可能存在的业务逻辑`},messages:{businessClass:`业务逻辑泄漏嫌疑: 技术层发现业务相关类 '{{className}}'。业务逻辑应该放在 domains/ 层。`,businessMethod:`业务逻辑泄漏嫌疑: 技术层发现业务规则方法 '{{methodName}}'。业务规则应该放在 domains/ 层。`,businessInterface:`业务逻辑泄漏嫌疑: 技术层发现业务相关接口 '{{interfaceName}}'。业务接口应该放在 domains/ 层。`,businessType:`业务逻辑泄漏嫌疑: 技术层发现业务相关类型 '{{typeName}}'。业务类型应该放在 domains/ 层。`},schema:[]},create(e){let t=e.filename;return Ve(t)?{ClassDeclaration(t){Ge(t,e)},MethodDefinition(t){Ke(t,e)},TSInterfaceDeclaration(t){qe(t,e)},TSTypeAliasDeclaration(t){Je(t,e)}}:{}}};function Xe(e){return e.startsWith(`create`)||e.startsWith(`make`)||e.startsWith(`build`)}function Ze(e){return/domains\/[^/]+\/(implementation|contract)\/src\/index\.ts$/.test(e)?`main`:/domains\/[^/]+\/(implementation|contract)\/src\/(domain|application|infrastructure)\/index\.ts$/.test(e)?`layer`:/domains\/[^/]+\/(implementation|contract)\/src\/(domain|application|infrastructure)\/\w+\/index\.ts$/.test(e)?`submodule`:`none`}function Qe(e){return e.includes(`/infrastructure/`)}const $e=[],et=[{pattern:/^(?!create)[A-Za-z]+Repository(Drizzle|Memory|Sqlite|Mysql)$/,messageId:`forbiddenRepositoryExport`,message:`禁止导出具体仓储实现类`},{pattern:/^(?!create)[A-Za-z]*Table$/,messageId:`forbiddenTableExport`,message:`禁止导出数据库表定义`},{pattern:/[A-Za-z]+OrmEntity$/,messageId:`forbiddenOrmEntityExportFromMain`,message:`禁止从主入口导出 ORM 实体,应从 ./typeorm 入口导出`},{pattern:/[A-Z_]+_ORM_ENTITIES$/,messageId:`forbiddenEntitiesExportFromMain`,message:`禁止从主入口导出实体集合,应从 ./typeorm 入口导出`},{pattern:/[A-Za-z]+OrmMapper$/,messageId:`forbiddenOrmMapperExportFromMain`,message:`禁止从主入口导出 ORM Mapper,这是基础设施层实现细节`}],tt=/^(?!create)[A-Za-z]*Schema$/,nt=new WeakMap;function rt(e,t,n){if(!n)return it(e,t);let r=nt.get(n);if(r||(r=new Map,nt.set(n,r)),r.has(t))return r.get(t);let i=it(e,t);return r.set(t,i),i}function it(e,t){let n=[],r=/export\s*\*\s*from/.test(e),i=e.matchAll(/export\s+type\s+\{([^}]+)\}/g);for(let e of i){let t=e[1];if(t){let e=t.split(`,`).map(e=>{let t=e.trim().split(` as `);return t[0]?t[0].trim():``}).filter(e=>e);n.push(...e)}}let a=e.matchAll(/export\s+(?!type)\{([^}]+)\}/g);for(let e of a){let t=e[1];if(t){let e=t.split(`,`).map(e=>{let t=e.trim().split(` as `);return t[0]?t[0].trim():``}).filter(e=>e);n.push(...e)}}let o=e.matchAll(/export\s+(class|function|const|let|interface|type)\s+(\w+)/g);for(let e of o){let t=e[2];t&&n.push(t)}let s=[],c=Qe(t);if(Ze(t)===`submodule`)return{usesExportStar:r,exports:n,forbiddenIssues:s};for(let e of n)if(!Xe(e)){for(let{pattern:t,messageId:n}of $e)t.test(e)&&s.push({messageId:n,exportName:e});for(let{pattern:t,messageId:n}of et)t.test(e)&&s.push({messageId:n,exportName:e});c&&tt.test(e)&&s.push({messageId:`forbiddenSchemaExport`,exportName:e})}return{usesExportStar:r,exports:n,forbiddenIssues:s}}const at={meta:{type:`problem`,docs:{description:`Domain 包导出规范:禁止 export *、禁止导出具体实现类、禁止导出数据库表和 Schema`,recommended:!0},schema:[],messages:{forbiddenExportStar:`禁止使用 export *,应使用显式导出(export { ... } 或 export type { ... })`,forbiddenRepositoryExport:`禁止导出具体仓储实现类 {{exportName}},应使用工厂函数 createXxxRepository`,forbiddenTableExport:`禁止导出数据库表定义 {{exportName}}`,forbiddenSchemaExport:`禁止导出 Schema 定义 {{exportName}}`,forbiddenOrmEntityExportFromMain:`禁止从主入口导出 ORM 实体 {{exportName}},应从 ./typeorm 入口导出`,forbiddenEntitiesExportFromMain:`禁止从主入口导出实体集合 {{exportName}},应从 ./typeorm 入口导出`,forbiddenOrmMapperExportFromMain:`禁止从主入口导出 ORM Mapper {{exportName}},这是基础设施层实现细节`}},create(e){let t=e.filename;if(Ze(t)===`none`)return{};let n=e.sourceCode.text,{usesExportStar:r,forbiddenIssues:i}=rt(n,t,e);return{Program(t){r&&e.report({node:t,messageId:`forbiddenExportStar`});for(let n of i)e.report({node:t,messageId:n.messageId,data:{exportName:n.exportName}})}}}},ot=/@longzai-intelligence\/[^/]+\/typeorm/,st=/@longzai-intelligence\/[^/]+\/infrastructure\//,ct=[/data-source\.ts$/,/data-source\.config\.ts$/,/data-source\.[a-z-]+\.ts$/,/database\.module\.ts$/,/database\.ts$/,/database\.config\.ts$/,/database\.service\.ts$/];function lt(e){return ct.some(t=>t.test(e))}const ut={meta:{type:`problem`,docs:{description:`Domain TypeORM 导入规范:非 DataSource 场景禁止导入 /typeorm 入口,禁止 infrastructure/* deep import`,recommended:!0},schema:[],messages:{forbiddenTypeormImport:`非 DataSource 场景禁止从 /typeorm 入口导入 ORM 实体,该入口仅供 DataSource/迁移基础设施使用`,forbiddenInfrastructureImport:`禁止 infrastructure/* deep import,应使用受控入口(主入口或 ./typeorm)`}},create(e){let t=e.filename,n=lt(t);return{ImportDeclaration(t){if(!t.source)return;let r=t.source.value;typeof r==`string`&&(ot.test(r)&&(n||e.report({node:t,messageId:`forbiddenTypeormImport`})),st.test(r)&&e.report({node:t,messageId:`forbiddenInfrastructureImport`}))}}}};function T(e){if(typeof e!=`object`||!e)return!1;let t=e;return`name`in t&&typeof t.name==`string`&&`isSpecialFile`in t&&typeof t.isSpecialFile==`function`&&`getNamingRules`in t&&typeof t.getNamingRules==`function`&&`shouldSkipTypeSuffix`in t&&typeof t.shouldSkipTypeSuffix==`function`}const dt=[{pattern:/\.service\.drizzle\.ts$/,case:`kebab-case`,description:`Drizzle Service 文件应使用 xxx.service.drizzle.ts 格式(kebab-case)`},{pattern:/\.service\.memory\.ts$/,case:`kebab-case`,description:`Memory Service 文件应使用 xxx.service.memory.ts 格式(kebab-case)`},{pattern:/\.service\.ts$/,case:`kebab-case`,description:`服务文件应使用 xxx.service.ts 格式(kebab-case)`},{pattern:/\.controller\.ts$/,case:`kebab-case`,description:`控制器文件应使用 xxx.controller.ts 格式(kebab-case)`},{pattern:/\.module\.ts$/,case:`kebab-case`,description:`模块文件应使用 xxx.module.ts 格式(kebab-case)`},{pattern:/\.repository\.drizzle\.ts$/,case:`kebab-case`,description:`Drizzle Repository 文件应使用 xxx.repository.drizzle.ts 格式(kebab-case)`},{pattern:/\.repository\.memory\.ts$/,case:`kebab-case`,description:`Memory Repository 文件应使用 xxx.repository.memory.ts 格式(kebab-case)`},{pattern:/\.repository\.interface\.ts$/,case:`kebab-case`,description:`Repository 接口文件应使用 xxx.repository.interface.ts 格式(kebab-case)`},{pattern:/\.repository\.types\.ts$/,case:`kebab-case`,description:`Repository 类型文件应使用 xxx.repository.types.ts 格式(kebab-case)`},{pattern:/\.repository\.ts$/,case:`kebab-case`,description:`Repository 文件应使用 xxx.repository.ts 格式(kebab-case)`},{pattern:/\.entity\.types\.ts$/,case:`kebab-case`,description:`Entity 类型文件应使用 xxx.entity.types.ts 格式(kebab-case)`},{pattern:/\.entity\.interface\.ts$/,case:`kebab-case`,description:`Entity 接口文件应使用 xxx.entity.interface.ts 格式(kebab-case)`},{pattern:/\.entity\.ts$/,case:`kebab-case`,description:`Entity 文件应使用 xxx.entity.ts 格式(kebab-case)`},{pattern:/\.dto\.ts$/,case:`kebab-case`,description:`DTO 文件应使用 xxx.dto.ts 格式(kebab-case)`},{pattern:/\.port\.interface\.ts$/,case:`kebab-case`,description:`Port 接口文件应使用 xxx.port.interface.ts 格式(kebab-case)`},{pattern:/\.interface\.ts$/,case:`kebab-case`,description:`接口文件应使用 xxx.interface.ts 格式(kebab-case)`},{pattern:/\.types\.ts$/,case:`kebab-case`,description:`类型文件应使用 xxx.types.ts 格式(kebab-case)`},{pattern:/\.schema\.ts$/,case:`kebab-case`,description:`Schema 文件应使用 xxx.schema.ts 格式(kebab-case)`},{pattern:/\.port\.ts$/,case:`kebab-case`,description:`Port 文件应使用 xxx.port.ts 格式(kebab-case)`},{pattern:/\.port\.adapter\.ts$/,case:`kebab-case`,description:`Port Adapter 文件应使用 xxx.port.adapter.ts 格式(kebab-case)`},{pattern:/\.adapter\.ts$/,case:`kebab-case`,description:`Adapter 文件应使用 xxx.adapter.ts 格式(kebab-case)`},{pattern:/\.events\.ts$/,case:`kebab-case`,description:`Events 文件应使用 xxx.events.ts 格式(kebab-case)`},{pattern:/\.mapper\.ts$/,case:`kebab-case`,description:`Mapper 文件应使用 xxx.mapper.ts 格式(kebab-case)`},{pattern:/\.ipc\.ts$/,case:`kebab-case`,description:`IPC 文件应使用 xxx.ipc.ts 格式(kebab-case)`},{pattern:/\.config\.ts$/,case:`kebab-case`,description:`配置文件应使用 xxx.config.ts 格式(kebab-case)`},{pattern:/\.errors\.ts$/,case:`kebab-case`,description:`错误文件应使用 xxx.errors.ts 格式(kebab-case)`},{pattern:/\.utils\.ts$/,case:`kebab-case`,description:`工具函数文件应使用 xxx.utils.ts 格式(kebab-case)`},{pattern:/\.constants\.ts$/,case:`kebab-case`,description:`常量文件应使用 xxx.constants.ts 格式(kebab-case)`},{pattern:/\.atom\.ts$/,case:`kebab-case`,description:`Atom 文件应使用 xxx.atom.ts 格式(kebab-case)`},{pattern:/\.vo\.ts$/,case:`kebab-case`,description:`值对象文件应使用 xxx.vo.ts 格式(kebab-case)`},{pattern:/\.usecase\.ts$/,case:`kebab-case`,description:`UseCase 文件应使用 xxx.usecase.ts 格式(kebab-case)`},{pattern:/\.styles\.css$/,case:`kebab-case`,description:`样式文件应使用 xxx.styles.css 格式(kebab-case)`},{pattern:/\.extension\.tsx?$/,case:`kebab-case`,description:`扩展文件应使用 xxx.extension.ts(x) 格式(kebab-case)`}],ft=[{pattern:/^use[A-Z][a-zA-Z]*\.spec\.tsx?$/,case:`camelCase`,description:`Hook 测试文件应使用 camelCase 并以 use 前缀开头(如 useChat.spec.ts)`},{pattern:/^use[A-Z][a-zA-Z]*\.test\.tsx?$/,case:`camelCase`,description:`Hook 测试文件应使用 camelCase 并以 use 前缀开头(如 useChat.test.ts)`},{pattern:/^use[A-Z][a-zA-Z]*\.types\.ts$/,case:`camelCase`,description:`Hook 类型文件应使用 camelCase 并以 use 前缀开头(如 useChat.types.ts)`},{pattern:/\.spec\.ts$/,case:`kebab-case-test`,description:`测试文件应使用 xxx.spec.ts 格式(kebab-case)`},{pattern:/\.test\.ts$/,case:`kebab-case-test`,description:`测试文件应使用 xxx.test.ts 格式(kebab-case)`},{pattern:/\.spec\.tsx$/,case:`kebab-case-test`,description:`测试文件应使用 xxx.spec.tsx 格式(kebab-case)`},{pattern:/\.test\.tsx$/,case:`kebab-case-test`,description:`测试文件应使用 xxx.test.tsx 格式(kebab-case)`},{pattern:/^use[A-Z][a-zA-Z]*\.tsx?$/,case:`camelCase`,description:`Hook 文件应使用 camelCase 并以 use 前缀开头(如 useChat.ts)`}],E={pattern:/^[A-Z][a-zA-Z]*\.tsx$/,case:`PascalCase`,description:`React 组件文件应使用 PascalCase(如 ChatPage.tsx)`};[...ft,...dt];const pt=[`index.ts`,`index.tsx`,`main.ts`,`main.tsx`,`App.tsx`,`types.ts`,`errors.ts`,`constants.ts`,`persistence.ts`,`typeorm.ts`],mt=[`impl`,`functions`,`methods`,`handlers`,`classes`];function ht(e){let t=e.replace(/\.tsx?$/,``);return[/s$/,/es$/,/ies$/].some(e=>e.test(t))}function D(e){return/^v\d+(-[a-z0-9-]+)?\.ts$/.test(e)}function gt(e){let t=e.replace(/\.tsx?$/,``);for(let e of mt){if(t.endsWith(`.${e}`))return e;let n=t.split(`.`);if(n.length>=2&&n[n.length-1]===e)return e}return null}function _t(e){if(!e.endsWith(`.tsx`))return!1;let t=e.replace(`.tsx`,``);return/^[A-Z][a-zA-Z0-9]*$/.test(t)}function vt(e){if(!e.endsWith(`.ts`)&&!e.endsWith(`.tsx`))return!1;let t=e.replace(/\.tsx?$/,``);return/^use[A-Z][a-zA-Z0-9]*$/.test(t)}function yt(e){for(let t of[`.test.ts`,`.test.tsx`,`.spec.ts`,`.spec.tsx`])if(e.endsWith(t)){let n=t.endsWith(`.tsx`)?`.tsx`:`.ts`;return e.replace(t,n)}return e}const O={name:`base`,isSpecialFile(e){return!!(pt.includes(e)||e.endsWith(`.d.ts`)||D(e))},getNamingRules(){return[...ft,...dt,E]},shouldSkipTypeSuffix(e){let t=yt(e);return!!(pt.includes(t)||t.endsWith(`.d.ts`)||D(t)||_t(t)||vt(t)||!gt(t)&&ht(t))}},k=[`page.tsx`,`page.ts`,`layout.tsx`,`layout.ts`,`loading.tsx`,`loading.ts`,`error.tsx`,`error.ts`,`not-found.tsx`,`not-found.ts`,`template.tsx`,`template.ts`,`default.tsx`,`default.ts`,`global-error.tsx`,`global-error.ts`,`middleware.ts`,`route.ts`],A={name:`nextjs`,isSpecialFile(e){return k.includes(e)},getNamingRules(){return[]},shouldSkipTypeSuffix(e){return k.includes(e)}},bt=[/^\[.+\]\.tsx?$/,/^_layout\.tsx?$/,/^\(.+\)\.tsx?$/],xt=[`_layout.tsx`,`_layout.ts`,`_sitemap.tsx`,`_sitemap.ts`],j={name:`expo-router`,isSpecialFile(e){return xt.includes(e)?!0:bt.some(t=>t.test(e))},getNamingRules(){return[]},shouldSkipTypeSuffix(e){return this.isSpecialFile(e)}};function St(...e){return{name:e.map(e=>e.name).join(`+`),isSpecialFile(t,n){return e.some(e=>e.isSpecialFile(t,n))},getNamingRules(){return e.flatMap(e=>e.getNamingRules())},shouldSkipTypeSuffix(t){return e.some(e=>e.shouldSkipTypeSuffix(t))}}}const Ct=new Map;function M(e){Ct.set(e.name,e)}M(O),M(A),M(j);function N(e){return/^[A-Z][a-zA-Z0-9]*$/.test(e)}function wt(e){return/^[a-z][a-zA-Z0-9]*$/.test(e)}function P(e){return/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/.test(e)}function Tt(e){return e.split(`.`).every(e=>P(e)&&e.length>0)}function Et(e){return e.split(`.`).every(e=>P(e)&&e.length>0)}function Dt(e,t){if(e.endsWith(`.types`)&&t===`kebab-case`)return Tt(e);switch(t){case`PascalCase`:return N(e);case`camelCase`:return wt(e);case`kebab-case`:return P(e);case`kebab-case-test`:return Et(e);default:return!1}}const F=new WeakMap;function I(e,t){if(!t)try{return f.existsSync(e)}catch{return!1}let n=F.get(t);if(n||(n=new Map,F.set(t,n)),n.has(e))return n.get(e);let r;try{r=f.existsSync(e)}catch{r=!1}return n.set(e,r),r}function Ot(e,t,n,r){let i=t.substring(6),a=u.dirname(i);return I(u.join(e,`pages`,a===`.`?``:a,n),r)}function kt(e,t,n,r){let i=t.substring(11),a=u.dirname(i);return I(u.join(e,`components`,a===`.`?``:a,n),r)}function At(e,t,n,r){let i=t.substring(14),a=u.dirname(i);return I(u.join(e,`ui`,`components`,a===`.`?``:a,n),r)}function jt(e,t,n,r){let i=t.substring(6),a=u.dirname(i);return I(u.join(e,`react`,a===`.`?``:a,n),r)}function Mt(e,t,n){let r=e.indexOf(`/__tests__/`),i=e.substring(0,r),a=e.substring(r+11);return a.startsWith(`pages/`)?Ot(i,a,t,n):a.startsWith(`components/`)?kt(i,a,t,n):a.startsWith(`ui/components/`)?At(i,a,t,n):a.startsWith(`react/`)?jt(i,a,t,n):I(u.join(i,t),n)}function Nt(e,t,n){let r=e.replace(/\\/g,`/`),i=r.includes(`/__tests__/`),a=r.includes(`/components/`);if(!a&&!i||!(t.endsWith(`.test.tsx`)||t.endsWith(`.spec.tsx`)||t.endsWith(`.test.ts`)||t.endsWith(`.spec.ts`)))return!1;let o=t.replace(/\.(test|spec)\.(tsx|ts)$/,`.tsx`);return i?Mt(r,o,n):a?I(u.join(u.dirname(e),o),n):!1}const L=new WeakMap;function Pt(e,t){if(!t)try{return f.existsSync(e)}catch{return!1}let n=L.get(t);if(n||(n=new Map,L.set(t,n)),n.has(e))return n.get(e);let r;try{r=f.existsSync(e)}catch{r=!1}return n.set(e,r),r}function Ft(e,t,n){if(!e.replace(/\\/g,`/`).includes(`/components/`)||!t.endsWith(`.types.ts`))return!1;let r=t.replace(`.types.ts`,`.tsx`);return Pt(u.join(u.dirname(e),r),n)}function It(e,t){if(t===E)return e.replace(/\.tsx$/,``);let n=t.pattern.source;return n.startsWith(`^`)&&n.endsWith(`$`)?n.includes(`\\.test\\.`)||n.includes(`\\.spec\\.`)?e.replace(/\.(test|spec)\.(tsx?|jsx?)$/,``):n.includes(`\\.types\\.`)?e.replace(/\.types\.ts$/,``):e.replace(/\.[^.]+$/,``):e.replace(t.pattern,``)}const R={meta:{type:`problem`,docs:{description:`强制执行文件命名规范`},messages:{invalidFileName:`文件命名违规: {{fileName}}。{{description}}`},schema:[]},create(e){let t=e.filename,n=u.basename(t),r=T(e.settings?.platformNamingStrategy)?e.settings.platformNamingStrategy:O;if(r.isSpecialFile(n,t)||Ft(t,n,e)&&N(n.replace(`.types.ts`,``))||Nt(t,n,e)&&N(n.replace(/\.(test|spec)\.(tsx|ts)$/,``)))return{};let i=r.getNamingRules().find(e=>e.pattern.test(n));if(!i&&n.endsWith(`.tsx`)&&(i=E),!i)return{};let a=It(n,i);return Dt(n.endsWith(`.types.ts`)&&i.case===`kebab-case`?n.replace(/\.ts$/,``):a,i.case)||e.report({loc:{start:{line:1,column:0},end:{line:1,column:n.length}},messageId:`invalidFileName`,data:{fileName:n,description:i.description}}),{}}};function Lt(e){return e.endsWith(`.types.ts`)?!0:/^[a-z][a-z0-9-]*\.[a-z][a-z0-9-]*\.tsx?$/.test(e)||/^[a-z][a-z0-9-]*\.[a-z][a-z0-9-]*\.[a-z][a-z0-9-]*\.tsx?$/.test(e)}function Rt(e){let t=e.replace(/\.tsx?$/,``);for(let e of mt){if(t.endsWith(`.${e}`))return e;let n=t.split(`.`);if(n.length>=2&&n[n.length-1]===e)return e}return null}function zt(e){let t=[],n=e.replace(/\.tsx?$/,``);return(n.includes(`service`)||n.includes(`Service`))&&t.push(`.service.ts`),(n.includes(`controller`)||n.includes(`Controller`))&&t.push(`.controller.ts`),(n.includes(`utils`)||n.includes(`helper`)||n.includes(`Helper`))&&t.push(`.utils.ts`),(n.includes(`constant`)||n.includes(`Constant`))&&t.push(`.constants.ts`),(n.includes(`config`)||n.includes(`Config`))&&t.push(`.config.ts`),(n.includes(`atom`)||n.includes(`state`)||n.includes(`State`))&&t.push(`.atom.ts`),t.length===0&&t.push(`.utils.ts`,`.config.ts`,`.constants.ts`),t}function Bt(e){for(let t of[`.test.ts`,`.test.tsx`,`.spec.ts`,`.spec.tsx`])if(e.endsWith(t)){let n=t.endsWith(`.tsx`)?`.tsx`:`.ts`;return e.replace(t,n)}return e}const z={meta:{type:`problem`,docs:{description:`强制执行文件类型后缀规范,确保文件名明确表达其用途`},messages:{missingTypeSuffix:`文件 "{{fileName}}" 缺少类型后缀。除特殊文件外,所有文件应使用 xxx.yyy.ts 格式明确表达用途。建议: {{suggestions}}`,forbiddenSuffix:`文件 "{{fileName}}" 使用了禁止的后缀 ".{{suffix}}"。该后缀语义过于泛化,无法表达文件用途。请使用更具体的后缀,如 ".utils"、".helpers"、".service" 等。`},schema:[]},create(e){let t=e.filename,n=u.basename(t);if((T(e.settings?.platformNamingStrategy)?e.settings.platformNamingStrategy:O).shouldSkipTypeSuffix(n))return{};let r=Bt(n),i=Rt(r);if(i)return e.report({loc:{start:{line:1,column:0},end:{line:1,column:n.length}},messageId:`forbiddenSuffix`,data:{fileName:n,suffix:i}}),{};if(Lt(r))return{};let a=zt(r);return e.report({loc:{start:{line:1,column:0},end:{line:1,column:n.length}},messageId:`missingTypeSuffix`,data:{fileName:n,suggestions:a.join(`, `)}}),{}}},Vt=[/\/src\/renderer\//];function Ht(e){let t=e.replace(/\\/g,`/`);return Vt.some(e=>e.test(t))}function Ut(e){if(!e.startsWith(`@longzai-intelligence/`))return!1;let t=e.split(`/`);if(t.length<2)return!1;let n=t[1];return n?n.endsWith(`-implementation`):!1}const Wt={meta:{type:`problem`,docs:{description:`禁止在 Electron renderer 进程中导入 Implementation 包`},messages:{implementationInRenderer:`禁止在 renderer 进程中导入 Implementation 包 "{{packageName}}"。Implementation 包包含 Node.js 特定代码,请在 main 进程中使用,或使用 Contract 包代替。`},schema:[]},create(e){let t=e.filename;return Ht(t)?{ImportDeclaration(t){let n=t.source.value;typeof n==`string`&&Ut(n)&&e.report({node:t,messageId:`implementationInRenderer`,data:{packageName:n}})}}:{}}};function Gt(e){return typeof e==`object`&&!!e&&`alias`in e&&typeof e.alias==`string`&&`pathPattern`in e&&typeof e.pathPattern==`string`}function Kt(e){return Array.isArray(e)&&e.every(Gt)}const qt=[{alias:`@main`,pathPattern:`src/main`},{alias:`@preload`,pathPattern:`src/preload`},{alias:`@renderer`,pathPattern:`src/renderer/src`},{alias:`@shared`,pathPattern:`src/shared`}];function Jt(e,t){let n=e.replace(/\\/g,`/`);for(let e of t){let t=e.pathPattern.replace(/\\/g,`/`);if(n.includes(`/${t}/`)||n.endsWith(`/${t}`)||n.includes(`/${t}\\`))return e.alias}return null}function Yt(e,t,n){if(!t.startsWith(`.`))return null;let r=e.replace(/\\/g,`/`),i=r.lastIndexOf(`/`),a=i>0?r.substring(0,i):``;return Jt(u.resolve(a,t).replace(/\\/g,`/`),n)}function Xt(e){return e.startsWith(`./`)||e.startsWith(`../`)}const Zt={meta:{type:`problem`,docs:{description:`禁止使用相对路径穿越不同包范围,强制使用别名导入`},messages:{noCrossPackageRelativeImport:`禁止使用相对路径跨包导入。当前文件位于 "{{currentPackage}}" 包,目标位于 "{{targetPackage}}" 包。请使用别名导入:{{targetPackage}}/...`},schema:[{type:`object`,properties:{packageBoundaries:{type:`array`,items:{type:`object`,properties:{alias:{type:`string`},pathPattern:{type:`string`}},required:[`alias`,`pathPattern`]}}},additionalProperties:!1}]},create(e){let t=e.filename,n=e.options[0],r=n&&typeof n==`object`?n:{},i=`packageBoundaries`in r&&Array.isArray(r.packageBoundaries)?r.packageBoundaries:qt,a=Kt(i)?i:qt,o=Jt(t,a);return o?{ImportDeclaration(n){let r=n.source.value;if(typeof r!=`string`||!Xt(r))return;let i=Yt(t,r,a);i&&o!==i&&e.report({node:n,messageId:`noCrossPackageRelativeImport`,data:{currentPackage:o,targetPackage:i}})}}:{}}},Qt=[/\.test\.ts$/,/\.test\.tsx$/,/\.spec\.ts$/,/\.spec\.tsx$/],$t=[`/node_modules/`,`/dist/`,`/out/`,`/.bun/`],en=[{segment:`/templates/`,type:`templates`},{segment:`/domains/`,type:`domains`},{segment:`/packages/`,type:`packages`},{segment:`/infrastructure/`,type:`infrastructure`}],tn=[{segment:`/src/main/`,process:`main`},{segment:`/src/renderer/`,process:`renderer`},{segment:`/src/preload/`,process:`preload`},{segment:`/src/shared/`,process:`shared`}];function B(e){return e.replace(/\\/g,`/`)}function nn(e){return Qt.some(t=>t.test(e))}function rn(e){let t=B(e);return $t.some(e=>t.includes(e))}function an(e){return e.isElectron&&e.electronProcess?`src/${e.electronProcess}/__tests__`:`src/__tests__`}function on(e,t){let n=B(e);return t.srcRoot?n.startsWith(`${t.srcRoot}/__tests__/`):!0}function sn(e,t){let n=B(e),r=u.basename(e);if(!t.srcRoot)return`src/__tests__/${r}`;let i=n.indexOf(`/src/`);if(i===-1)return`${t.srcRoot}/__tests__/${r}`;let a=n.slice(i+5).split(`/`);if(a.length>1&&a.pop(),t.isElectron&&t.electronProcess){let e=a.indexOf(t.electronProcess);e!==-1&&a.splice(e,1)}let o=a.indexOf(`__tests__`);o!==-1&&a.splice(o,1);let s=a.join(`/`),c=an(t);return s?`${c}/${s}/${r}`:`${c}/${r}`}function cn(e,t){let n=e.indexOf(t),r=e.slice(n+t.length).split(`/`),i=r.findIndex(e=>e===`src`);if(i!==-1)return e.slice(0,n+t.length)+r.slice(0,i+1).join(`/`);let a=t===`/domains/`&&r.length>=2?`${r[0]}/${r[1]}`:r[0];return a?e.slice(0,n+t.length+a.length)+`/src`:e.slice(0,n+t.length)+`src`}function ln(e){for(let t of tn)if(e.includes(t.segment))return{electronProcess:t.process,srcRoot:e.slice(0,e.indexOf(t.segment))+t.segment.slice(0,-1)};return{srcRoot:``}}function un(e){return e.includes(`-desktop`)||e===`desktop`}function dn(e){let t=B(e);for(let e of en)if(t.includes(e.segment))return{type:e.type,isElectron:!1,srcRoot:cn(t,e.segment)};if(t.includes(`/database/`)){let e=t.indexOf(`/database/`);return{type:`database`,isElectron:!1,srcRoot:t.slice(0,e+10)+`src`}}if(!t.includes(`/apps/`))return{type:`unknown`,isElectron:!1,srcRoot:``};let n=t.indexOf(`/apps/`),r=t.slice(n+6).split(`/`)[0];if(!r)return{type:`unknown`,isElectron:!1,srcRoot:``};let i=t.slice(0,n+6+r.length)+`/src`;if(!un(r))return{type:`apps`,isElectron:!1,srcRoot:i};let a=ln(t);return{type:`apps`,isElectron:!0,electronProcess:a.electronProcess,srcRoot:a.srcRoot||i}}const fn={meta:{type:`problem`,docs:{description:`强制测试文件放置在 src/__tests__ 目录下`},messages:{invalidTestFileLocation:`测试文件 "{{fileName}}" 必须放置在 {{expectedDir}} 目录下。当前路径: "{{currentPath}}"。建议路径: "{{suggestedPath}}"`},schema:[]},create(e){let t=e.filename,n=u.basename(t);if(!nn(n)||rn(t)||n.endsWith(`.d.ts`))return{};let r=dn(t);if(r.type===`unknown`||on(t,r))return{};let i=an(r),a=sn(t,r);return e.report({loc:{start:{line:1,column:0},end:{line:1,column:n.length}},messageId:`invalidTestFileLocation`,data:{fileName:n,expectedDir:i,currentPath:t,suggestedPath:a}}),{}}},pn=[`**/vitest.setup.ts`,`**/jest.setup.ts`,`**/fixtures/**`,`**/helpers/**`,`**/mocks/**`,`**/__mocks__/**`,`**/*.d.ts`],mn=[/\.test\.ts$/,/\.test\.tsx$/,/\.spec\.ts$/,/\.spec\.tsx$/];function hn(e){return mn.some(t=>t.test(e))}function gn(e,t){let n=t.replace(/[.+^${}()|[\]\\]/g,`\\$&`).replace(/\*\*/g,`{{DOUBLE_STAR}}`).replace(/\*/g,`[^/]*`).replace(/{{DOUBLE_STAR}}/g,`.*`);return RegExp(`^${n}$`).test(e)}function _n(e,t){return t.some(t=>gn(e,t))}function vn(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function yn(e){if(typeof e!=`object`||!e)return!1;if(!(`allowPatterns`in e))return!0;let t=e.allowPatterns;return Array.isArray(t)&&vn(t)}const bn={meta:{type:`problem`,docs:{description:`禁止在 __tests__ 目录下放置非测试文件`},messages:{nonTestFileInTestsDirectory:`文件 "{{fileName}}" 位于 __tests__ 目录下但不是测试文件。测试目录应仅包含测试文件(*.test.ts, *.spec.ts)。如果是辅助文件,请移动到 src/test-helpers/ 或 src/testing/ 目录。`},schema:[{type:`object`,properties:{allowPatterns:{type:`array`,items:{type:`string`},description:`允许在 __tests__ 目录下的非测试文件 glob 模式`}},additionalProperties:!1}]},create(e){let t=[...pn],n=e.options[0];yn(n)&&n.allowPatterns&&(t=[...pn,...n.allowPatterns]);let r=e.filename,i=B(r),a=u.basename(r);return{Program(){i.includes(`/__tests__/`)&&(hn(a)||_n(i,t)||e.report({loc:{start:{line:1,column:0},end:{line:1,column:a.length}},messageId:`nonTestFileInTestsDirectory`,data:{fileName:a}}))}}}},xn=[/\.test\.ts$/,/\.test\.tsx$/,/\.spec\.ts$/,/\.spec\.tsx$/],V=[`.ts`,`.tsx`],Sn=new Set([`node_modules`,`dist`,`out`,`.bun`,`.turbo`,`.cache`,`generated`]),Cn=new WeakMap;function wn(e){return e.replace(/\\/g,`/`)}function Tn(e,t){let n;try{n=f.readdirSync(e,{withFileTypes:!0})}catch{return}for(let r of n){let n=u.join(e,r.name);if(r.isDirectory()){if(Sn.has(r.name))continue;Tn(n,t)}else r.isFile()&&t(n)}}function H(e){return Qt.some(t=>t.test(e))}function En(e){let t=wn(e);return $t.some(e=>t.includes(e))}function Dn(e){for(let t of xn)if(t.test(e))return e.replace(t,``);return e}function On(e){let t=wn(e),n=t.indexOf(`/__tests__/`);return n===-1?u.dirname(e):t.substring(0,n)}function kn(e,t){for(let n of V){let r=u.join(t,e+n);if(f.existsSync(r))return r}return null}function An(e,t){let n=Cn.get(e);if(n||(n=new Map,Cn.set(e,n)),n.has(t))return n.get(t);let r=[];return Tn(t,e=>r.push(e)),n.set(t,r),r}function jn(e,t,n,r){let i=u.dirname(t),a=[i,u.dirname(i)];for(let t of a){let n=kn(e,t);if(n)return n}let o=[n,i];for(let t of o){if(!f.existsSync(t))continue;let n=An(r,t);for(let t of n){let n=u.basename(t);if(!H(n)){for(let r of V)if(n===e+r)return t}}}return null}function Mn(e,t){let n=u.basename(e),r=Dn(n),i=On(e);if(jn(r,e,i,t))return{isMatch:!0,suggestion:null};let a=In(i,e,t)[0];if(a){let e=u.basename(a,u.extname(a)),t=u.extname(n),r=n.includes(`.spec.`)?`.spec`:`.test`,i=t.replace(r,``);return{isMatch:!1,suggestion:e+r+i}}return{isMatch:!1,suggestion:null}}function Nn(e){return H(e)||e===`index.ts`||e===`index.tsx`||e.endsWith(`.d.ts`)?!1:V.some(t=>e.endsWith(t))}function Pn(e,t,n){if(f.existsSync(e))try{let r=f.readdirSync(e,{withFileTypes:!0});for(let i of r){if(!i.isFile())continue;let r=i.name;if(!Nn(r))continue;let a=u.join(e,r);n.has(a)||(t.push(a),n.add(a))}}catch{}}function Fn(e,t,n,r){if(!f.existsSync(e))return;let i=An(t,e);for(let e of i)Nn(u.basename(e))&&(r.has(e)||(n.push(e),r.add(e)))}function In(e,t,n){let r=u.dirname(t),i=u.dirname(r),a=[],o=new Set,s=[r,i];for(let e of s)Pn(e,a,o);if(a.length===0){let t=[e,r];for(let e of t)Fn(e,n,a,o)}return a}const Ln={meta:{type:`problem`,docs:{description:`确保测试文件名与被测试的源文件名保持一致`},messages:{testFileNotMatchSource:`测试文件 "{{testFileName}}" 未找到匹配的源文件。测试文件名应与源文件名保持一致。{{suggestion}}`},schema:[]},create(e){let t=e.filename,n=u.basename(t);if(!H(n)||En(t)||n.endsWith(`.d.ts`))return{};let r=Mn(t,e);if(!r.isMatch){let t=r.suggestion?`建议重命名为 "${r.suggestion}"`:`请确保测试文件名与源文件名匹配(如 user.service.ts -> user.service.test.ts)`;e.report({loc:{start:{line:1,column:0},end:{line:1,column:n.length}},messageId:`testFileNotMatchSource`,data:{testFileName:n,suggestion:t}})}return{}}};function Rn(e){if(!e||typeof e!=`object`)return!1;let t=e;if(!(`type`in t)||t.type!==m.MemberExpression||!(`object`in t)||!t.object||!(`property`in t)||!t.property)return!1;let n=t.object,r=t.property;return!n||typeof n!=`object`||!r||typeof r!=`object`?!1:`type`in n&&n.type===m.Identifier&&`name`in n&&n.name===`window`&&`type`in r&&r.type===m.Identifier&&`name`in r&&r.name===`electron`}const zn={meta:{type:`problem`,docs:{description:`禁止在 Preload 中直接暴露 @electron-toolkit/preload 的 electronAPI`},messages:{noElectronApiImport:`禁止导入 @electron-toolkit/preload 的 electronAPI。`,noExposeElectronApi:`禁止执行 contextBridge.exposeInMainWorld("electron", electronAPI)。`,noWindowElectronApi:`禁止执行 window.electron = electronAPI。`},schema:[]},create(e){return{ImportDeclaration(t){if(t.source.value===`@electron-toolkit/preload`)for(let n of t.specifiers)n.type===`ImportSpecifier`&&n.imported.type===`Identifier`&&n.imported.name===`electronAPI`&&e.report({node:n,messageId:`noElectronApiImport`})},CallExpression(t){if(t.callee.type!==`MemberExpression`||t.callee.property.type!==`Identifier`||t.callee.property.name!==`exposeInMainWorld`||t.arguments.length<2)return;let[n,r]=t.arguments;n?.type===`Literal`&&n.value===`electron`&&r?.type===`Identifier`&&r.name===`electronAPI`&&e.report({node:t,messageId:`noExposeElectronApi`})},AssignmentExpression(t){t.left.type===`MemberExpression`&&Rn(t.left)&&t.right.type===`Identifier`&&t.right.name===`electronAPI`&&e.report({node:t,messageId:`noWindowElectronApi`})}}}};function Bn(e){let t=e.replace(/\\/g,`/`);return t.includes(`/src/preload/`)&&!t.includes(`/__tests__/`)}function U(e){return typeof e==`object`&&!!e}function Vn(e){if(!U(e))return null;let t=e.key;return U(t)?typeof t.name==`string`?t.name:typeof t.value==`string`?t.value:null:null}function Hn(e){return!U(e)||!Array.isArray(e.properties)?!1:e.properties.some(e=>{if(!U(e)||e.type!==`Property`)return!1;let t=Vn(e);return t===`on`||t===`send`||t===`invoke`})}const Un={meta:{type:`problem`,docs:{description:`禁止在 Preload 暴露通用 ipc 桥接对象`},messages:{noIpcBridge:`禁止暴露通用 ipc 桥接对象(on/send/invoke)。请使用领域 API。`},schema:[]},create(e){return Bn(e.filename)?{Property(t){Vn(t)===`ipc`&&U(t.value)&&t.value.type===`ObjectExpression`&&Hn(t.value)&&e.report({node:t,messageId:`noIpcBridge`})}}:{}}};function Wn(e){let t=e.replace(/\\/g,`/`);return t.includes(`/src/preload/`)&&!t.includes(`/__tests__/`)&&!t.includes(`/src/preload/utils/`)}const Gn={meta:{type:`problem`,docs:{description:`禁止在 Preload 业务代码中直接调用 ipcRenderer`},messages:{noDirectCall:`禁止直接调用 ipcRenderer。请通过 createTypedAPI 或 invoke 封装。`},schema:[]},create(e){return Wn(e.filename)?{CallExpression(t){t.callee.type===`MemberExpression`&&t.callee.object.type===`Identifier`&&t.callee.object.name===`ipcRenderer`&&e.report({node:t,messageId:`noDirectCall`})}}:{}}};function W(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`Identifier`&&`name`in e&&typeof e.name==`string`}function Kn(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`Property`&&`value`in e&&e.value!==null&&typeof e.value==`object`&&W(e.value)}function qn(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`RestElement`&&`argument`in e&&e.argument!==null&&typeof e.argument==`object`&&W(e.argument)}function Jn(e){let t=[];if(!e||typeof e!=`object`)return t;if(W(e)&&t.push(e.name),`type`in e&&e.type===`ObjectPattern`&&`properties`in e&&Array.isArray(e.properties))for(let n of e.properties)!n||typeof n!=`object`||(Kn(n)?t.push(n.value.name):qn(n)&&t.push(n.argument.name));if(`type`in e&&e.type===`ArrayPattern`&&`elements`in e&&Array.isArray(e.elements))for(let n of e.elements)W(n)&&t.push(n.name);return t}function Yn(e){return`declaration`in e}function Xn(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`VariableDeclaration`&&`kind`in e&&`declarations`in e&&Array.isArray(e.declarations)}function Zn(e){if(typeof e!=`object`||!e||!(`range`in e))return!1;let t=e.range;return Array.isArray(t)&&t.length===2}function Qn(e,t,n){return r=>{let i=t.declaration;if(!i||!Zn(i)||!e.getTokenBefore(i))return null;let a=e.getText(i),o=n.join(`, `),s=e.getText(t).match(/^(\s*)/),c=s?s[1]:``,ee=`${a}`,l=`${c}export { ${o} };`;return r.replaceText(t,`${ee}\n${l}`)}}const $n={meta:{type:`suggestion`,docs:{description:`将 export const/let/var 拆分为独立的声明和导出语句,以便 JSDoc 正确插入`,recommended:!0},fixable:`code`,schema:[],messages:{preferSplitExport:"应将 `export {{kind}} {{names}}` 拆分为独立的声明和导出语句,以便 JSDoc 正确插入注释"}},create(e){let t=e.sourceCode;return{ExportNamedDeclaration(n){if(!Yn(n)||!n.declaration||!Xn(n.declaration))return;let r=n.declaration;if(r.kind!==`const`&&r.kind!==`let`&&r.kind!==`var`)return;let i=r.declarations;if(i.length===0)return;let a=[];i.forEach(e=>{a.push(...Jn(e.id))}),a.length!==0&&e.report({node:n,messageId:`preferSplitExport`,data:{kind:r.kind,names:a.join(`, `)},fix:Qn(t,n,a)})}}}};function er(e){return typeof e==`object`&&!!e&&`name`in e&&typeof e.name==`string`&&(!(`severity`in e)||e.severity===`error`||e.severity===`warn`||e.severity===void 0)&&(!(`description`in e)||typeof e.description==`string`||e.description===void 0)}function tr(e){return Array.isArray(e)&&e.every(er)}function nr(e){if(typeof e!=`object`||!e)return!1;if(!(`directories`in e))return!0;let t=e.directories;return Array.isArray(t)&&tr(t)}const rr=[{name:`apps`,severity:`error`,description:`应用层目录`},{name:`domains`,severity:`error`,description:`领域层目录`},{name:`packages`,severity:`error`,description:`技术层目录`},{name:`infrastructure`,severity:`warn`,description:`基础设施层目录`},{name:`templates`,severity:`warn`,description:`模板层目录`},{name:`docs`,severity:`warn`,description:`文档层目录`}];function ir(e,t){return p(d(e,t,`README.md`))}function ar(e){return e.cwd}const or=new WeakMap;function sr(e){let t=or.get(e);return t||(t=new Set,or.set(e,t)),t}const cr={meta:{type:`problem`,docs:{description:`检查分层目录是否包含 README.md 文件`},messages:{missingReadmeError:`分层目录 "{{directory}}" ({{description}}) 缺少 README.md 文件。分层目录必须包含 README.md 文件,阐明该层职责。`,missingReadmeWarn:`分层目录 "{{directory}}" ({{description}}) 建议添加 README.md 文件,阐明该层职责。`},schema:[{type:`object`,properties:{directories:{type:`array`,items:{type:`object`,properties:{name:{type:`string`},severity:{type:`string`,enum:[`error`,`warn`]},description:{type:`string`}},required:[`name`]}}},additionalProperties:!1}]},create(e){let t=ar(e),n=sr(e),r=rr,i=e.options[0];return nr(i)&&i.directories&&(r=i.directories),{Program(i){if(!n.has(t)){n.add(t);for(let n of r){let r=n.name;if(p(d(t,r))&&!ir(t,r)){let t=(n.severity||`error`)===`error`?`missingReadmeError`:`missingReadmeWarn`;e.report({node:i,messageId:t,data:{directory:r,description:n.description||r}})}}}}}}},lr=[{suffix:`.service.drizzle.ts`,classSuffix:`Service`,isInterface:!1,isPrefix:!1},{suffix:`.service.memory.ts`,classSuffix:`Service`,isInterface:!1,isPrefix:!1},{suffix:`.service.ts`,classSuffix:`Service`,isInterface:!1,isPrefix:!1},{suffix:`.controller.ts`,classSuffix:`Controller`,isInterface:!1,isPrefix:!1},{suffix:`.module.ts`,classSuffix:`Module`,isInterface:!1,isPrefix:!1},{suffix:`.repository.drizzle.ts`,classSuffix:`Repository`,isInterface:!1,isPrefix:!1},{suffix:`.repository.memory.ts`,classSuffix:`Repository`,isInterface:!1,isPrefix:!1},{suffix:`.repository.interface.ts`,classSuffix:`Repository`,isInterface:!0,isPrefix:!0},{suffix:`.repository.ts`,classSuffix:`Repository`,isInterface:!1,isPrefix:!1},{suffix:`.entity.ts`,classSuffix:`Entity`,isInterface:!1,isPrefix:!1},{suffix:`.orm-entity.ts`,classSuffix:`OrmEntity`,isInterface:!1,isPrefix:!1},{suffix:`.dto.ts`,classSuffix:`DTO`,isInterface:!1,isPrefix:!1},{suffix:`.port.interface.ts`,classSuffix:`Port`,isInterface:!0,isPrefix:!0},{suffix:`.interface.ts`,classSuffix:``,isInterface:!0,isPrefix:!0},{suffix:`.port.ts`,classSuffix:`Port`,isInterface:!0,isPrefix:!1},{suffix:`.port.adapter.ts`,classSuffix:`PortAdapter`,isInterface:!1,isPrefix:!1},{suffix:`.adapter.ts`,classSuffix:`Adapter`,isInterface:!1,isPrefix:!1},{suffix:`.events.ts`,classSuffix:`Event`,isInterface:!1,isPrefix:!1},{suffix:`.mapper.ts`,classSuffix:`Mapper`,isInterface:!1,isPrefix:!1},{suffix:`.vo.ts`,classSuffix:`VO`,isInterface:!1,isPrefix:!1},{suffix:`.usecase.ts`,classSuffix:`UseCase`,isInterface:!1,isPrefix:!1},{suffix:`.errors.ts`,classSuffix:`Error`,isInterface:!1,isPrefix:!1}];function ur(e){for(let t of lr)if(e.endsWith(t.suffix))return t;return null}function dr(e,t){if(t.isPrefix&&t.isInterface){if(t.classSuffix){let n=t.classSuffix;return e.startsWith(`I`)&&e.endsWith(n)&&e.length>1+n.length}return e.startsWith(`I`)&&e.length>1}return t.isPrefix?e.startsWith(`I`)&&e.length>1:e.endsWith(t.classSuffix)&&e.length>t.classSuffix.length}function fr(e){return e.isPrefix&&e.isInterface?e.classSuffix?`I${e.classSuffix}(如 IUser${e.classSuffix})`:`I 前缀(如 IUser)`:e.isPrefix?`I 前缀(如 IUser)`:`${e.classSuffix} 后缀`}function pr(e,t,n,i){if(!r(e))return;let a=e.id.name;n.isInterface||dr(a,n)||t.report({node:e,messageId:`invalidClassName`,data:{className:a,fileName:i,expectedFormat:fr(n)}})}function mr(e,t,n,i){if(!n.isInterface||!r(e))return;let a=e.id.name;dr(a,n)||t.report({node:e,messageId:`invalidInterfaceName`,data:{interfaceName:a,fileName:i,expectedFormat:fr(n)}})}function hr(e){let t=e.filename,n=u.basename(t);if(n.endsWith(`.test.ts`)||n.endsWith(`.spec.ts`))return{};let r=ur(n);return r?{ClassDeclaration(t){pr(t,e,r,n)},TSInterfaceDeclaration(t){mr(t,e,r,n)}}:{}}const gr={meta:{type:`problem`,docs:{description:`强制执行类名与文件类型后缀的一致性`},messages:{invalidClassName:`类名 "{{className}}" 不符合命名规范。文件 "{{fileName}}" 中的类应使用 {{expectedFormat}}`,invalidInterfaceName:`接口名 "{{interfaceName}}" 不符合命名规范。文件 "{{fileName}}" 中的接口应使用 {{expectedFormat}}`},schema:[]},create:hr},_r=[`types.ts`,`types.d.ts`],vr=[`.port.interface.ts`,`.repository.interface.ts`,`.types.ts`,`.types.d.ts`,`.events.ts`];function yr(e,t){return n(e)?!1:t.endsWith(`.dto.ts`)?ne(e):!0}function br(e){return e.endsWith(`.dto.ts`)?`DTO 后缀(如 UserDTO),禁止 I 前缀`:`PascalCase(如 User、UserRepository),禁止 I 前缀`}function xr(e){if(_r.includes(e))return!0;for(let t of vr)if(e.endsWith(t))return!0;return!1}function Sr(e){return e.endsWith(`.port.ts`)?e.replace(`.port.ts`,`.port.interface.ts`):e.endsWith(`.repository.ts`)?e.replace(`.repository.ts`,`.repository.interface.ts`):e.replace(`.ts`,`.interface.ts`)}function Cr(t,n){return n.endsWith(`Dto`)?e(t,n,!0):null}function wr(e,r,i,a){if(yr(i,a))return;if(n(i)){e.report({node:r,messageId:`invalidIPrefix`,data:{interfaceName:i,suggestedName:i.substring(1)},fix:t(r,i)});return}let o=Cr(r,i);o?e.report({node:r,messageId:`invalidDtoSuffix`,data:{interfaceName:i},fix:o}):e.report({node:r,messageId:`invalidInterfaceName`,data:{interfaceName:i,expectedFormat:br(a)}})}function Tr(e,t,n,r,i){i||r.endsWith(`.dto.ts`)||e.report({node:t,messageId:`invalidFileName`,data:{fileName:r,interfaceName:n,expectedFileName:Sr(r)}})}function Er(e,t,n,r){if(!i(t))return;let a=t.id.name;wr(e,t,a,n),Tr(e,t,a,n,r)}function Dr(e){let t=e.filename,n=u.basename(t);if(n.endsWith(`.test.ts`)||n.endsWith(`.spec.ts`)||xr(n))return{};let r=n.endsWith(`.interface.ts`);return{TSInterfaceDeclaration(t){Er(e,t,n,r)}}}const Or={meta:{type:`problem`,docs:{description:`强制执行接口命名规范(禁止 I 前缀,使用 PascalCase)和文件命名规范(xxx.interface.ts)`},messages:{invalidIPrefix:`接口名 "{{interfaceName}}" 使用了 I 前缀。现代 TypeScript 不推荐使用匈牙利命名法,建议使用 "{{suggestedName}}"`,invalidInterfaceName:`接口名 "{{interfaceName}}" 不符合命名规范。接口名应使用 {{expectedFormat}}`,invalidDtoSuffix:`接口名 "{{interfaceName}}" 后缀应使用 DTO(全大写)而非 Dto(驼峰式)`,invalidFileName:`包含接口 "{{interfaceName}}" 的文件 "{{fileName}}" 应命名为 "{{expectedFileName}}"`},schema:[],fixable:`code`},create:Dr},kr=[`.types.ts`,`.types.d.ts`];function Ar(e){return kr.some(t=>e.endsWith(t))}function jr(e){let r=e.filename,a=u.basename(r);return a.endsWith(`.test.ts`)||a.endsWith(`.spec.ts`)||!Ar(a)?{}:{TSInterfaceDeclaration(r){if(!i(r))return;let a=r.id.name;n(a)&&e.report({node:r,messageId:`invalidIPrefix`,data:{interfaceName:a,suggestedName:a.substring(1)},fix:t(r,a)})}}}const Mr={meta:{type:`problem`,docs:{description:`强制执行 types 文件中的接口命名规范(禁止 I 前缀)`},messages:{invalidIPrefix:`类型文件中的接口名 "{{interfaceName}}" 使用了 I 前缀。现代 TypeScript 不推荐使用匈牙利命名法,建议使用 "{{suggestedName}}"`},schema:[],fixable:`code`},create:jr};function Nr(e){return e.endsWith(`.dto.ts`)}function Pr(e){return e.endsWith(`DTO`)}function Fr(t){let n=t.filename,r=u.basename(n);return r.endsWith(`.test.ts`)||r.endsWith(`.spec.ts`)||!Nr(r)?{}:{TSInterfaceDeclaration(n){if(!i(n))return;let r=n.id.name;Pr(r)?t.report({node:n,messageId:`invalidDtoSuffix`,data:{interfaceName:r},fix:e(n,r,!1)}):te(r)||t.report({node:n,messageId:`missingDtoSuffix`,data:{interfaceName:r}})}}}const Ir={meta:{type:`problem`,docs:{description:`强制执行 DTO 文件中的接口命名规范(Dto 后缀,驼峰式)`},messages:{invalidDtoSuffix:`接口名 "{{interfaceName}}" 后缀应使用 Dto(驼峰式)而非 DTO(全大写)`,missingDtoSuffix:`DTO 文件中的接口名 "{{interfaceName}}" 应以 Dto 结尾(如 UserResponseDto)`},schema:[],fixable:`code`},create:Fr},G=`@longzai-intelligence/config/tsup`,Lr=`definePackageConfig`,Rr=[`defineConfig`];function zr(e){return{ImportDeclaration(t){if(!s(t))return;let n=t.source.value;for(let r of t.specifiers){if(!c(r))continue;let i=r.imported.name;if(Rr.includes(i)){if(n===`tsup`){e.report({node:t,messageId:`forbiddenTsupImport`,data:{importedName:i,correctExportName:Lr,configPackage:G}});continue}n===G&&e.report({node:t,messageId:`forbiddenConfigImport`,data:{importedName:i,correctExportName:Lr,configPackage:G}})}}}}}const Br={meta:{type:`problem`,docs:{description:`强制执行 tsup.config.ts 文件中的配置导入规范,必须使用 definePackageConfig`},messages:{forbiddenTsupImport:`禁止从 tsup 包导入 {{importedName}}。应使用 {{correctExportName}} 从 {{configPackage}} 导入`,forbiddenConfigImport:`禁止从 {{configPackage}} 导入 {{importedName}}。应使用 {{correctExportName}}`},schema:[]},create:zr},K=`@longzai-intelligence/tsdown-config`,Vr=[`defineDomainImplementationConfig`,`defineDomainContractConfig`,`defineSharedKernelConfig`,`defineReactComponentsConfig`,`defineConfigPackageConfig`,`definePackageConfig`],Hr=[`defineConfig`];function Ur(e){return{ImportDeclaration(t){if(!s(t))return;let n=t.source.value;for(let r of t.specifiers){if(!c(r))continue;let i=r.imported.name;if(Hr.includes(i)){if(n===`tsdown`){e.report({node:t,messageId:`forbiddenTsdownImport`,data:{importedName:i,presetNames:Vr.join(`、`),configPackage:K}});continue}n===K&&e.report({node:t,messageId:`forbiddenConfigImport`,data:{importedName:i,presetNames:Vr.join(`、`),configPackage:K}})}}}}}const Wr={meta:{type:`problem`,docs:{description:`强制执行 tsdown.config.ts 文件中的配置导入规范,必须使用预设函数`},messages:{forbiddenTsdownImport:`禁止从 tsdown 包导入 {{importedName}}。应使用预设函数({{presetNames}})从 {{configPackage}} 导入`,forbiddenConfigImport:`禁止从 {{configPackage}} 导入 {{importedName}}。应使用预设函数({{presetNames}})`},schema:[]},create:Ur},q=[`@longzai-intelligence/config/vitest`,`@longzai-intelligence/vitest-config`],J=[`createBaseVitestConfig`,`createDomainVitestConfig`,`createDomainUIVitestConfig`,`createPackageVitestConfig`,`createTypeOnlyVitestConfig`,`createDesktopVitestConfig`,`createWebVitestConfig`,`defineVitestConfig`,`defineDomainVitestConfig`,`defineDomainUIVitestConfig`,`definePackageVitestConfig`,`defineTypeOnlyVitestConfig`,`defineDesktopVitestConfig`,`defineWebVitestConfig`],Gr=[`defineConfig`],Kr=[`infrastructure/configs/vitest/vitest.config.ts`];function qr(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`ExportDefaultDeclaration`&&`declaration`in e&&e.declaration!==null&&typeof e.declaration==`object`}function Jr(e){return e.endsWith(`vitest.config.ts`)}function Yr(e,t,n){if(!s(e))return;let r=e.source.value;for(let t of e.specifiers){if(!c(t))continue;let i=t.imported.name;if(r===`vitest`&&Gr.includes(i)){n.hasForbiddenImport=!0,n.forbiddenImportNode=e,n.forbiddenImportName=i;continue}q.includes(r)&&J.includes(i)&&(n.hasValidImport=!0)}}function Xr(e,t){return!t.hasForbiddenImport||!t.forbiddenImportNode?!1:(e.report({node:t.forbiddenImportNode,messageId:`forbiddenVitestImport`,data:{importedName:t.forbiddenImportName,configPackages:q.join(` 或 `),allowedExports:J.join(`, `)}}),!0)}function Zr(e,t,n){if(!a(e))return!1;let r=e.callee.name;return typeof r==`string`&&!J.includes(r)&&!n.hasValidImport?(t.report({node:e,messageId:`invalidConfigFunction`,data:{configPackages:q.join(` 或 `),allowedExports:J.join(`, `)}}),!0):!1}function Qr(e,t,n){return l(e)?n.hasValidImport?!1:(t.report({node:e,messageId:`invalidConfigObject`,data:{configPackages:q.join(` 或 `),allowedExports:J.join(`, `)}}),!0):!1}function $r(e,t,n){if(!qr(e))return;n.hasExportDefault=!0;let r=e.declaration;Xr(t,n)||Zr(r,t,n)||Qr(r,t,n)}function ei(e,t){if(!t.hasExportDefault){let t=e.sourceCode.ast;e.report({node:t,messageId:`missingConfigImport`,data:{configPackages:q.join(` 或 `),allowedExports:J.join(`, `)}})}}function ti(e){let t=e.filename;if(!Jr(t)||ee(t,Kr))return{};let n={hasValidImport:!1,hasForbiddenImport:!1,hasExportDefault:!1,forbiddenImportNode:null,forbiddenImportName:``};return{ImportDeclaration(t){Yr(t,e,n)},ExportDefaultDeclaration(t){$r(t,e,n)},"Program:exit"(){ei(e,n)}}}const ni={meta:{type:`problem`,docs:{description:`强制执行 vitest.config.ts 文件中的配置导入规范,必须使用共享配置函数`},messages:{forbiddenVitestImport:`禁止从 vitest 包导入 {{importedName}}。应使用共享配置函数({{allowedExports}})从 {{configPackages}} 导入`,invalidConfigFunction:`必须使用共享配置函数({{allowedExports}})从 {{configPackages}} 导入`,missingConfigImport:`vitest.config.ts 必须使用共享配置函数({{allowedExports}})从 {{configPackages}} 导入`},schema:[]},create:ti},Y=`@longzai-intelligence/config/eslint`,X=[`createLibraryConfig`,`createDomainConfig`,`createReactConfig`,`createReactPluginConfig`,`createElectronConfig`,`createNextConfig`,`createNodeConfig`,`createMcpConfig`,`createNestConfig`,`createHonoConfig`,`createExpoConfig`],ri=[`coreConfig`,`createCoreConfig`,`libraryConfig`,`domainConfig`,`reactConfig`,`electronConfig`,`nextConfig`,`nodeConfig`,`mcpConfig`,`nestConfig`,`honoConfig`,`expoConfig`];function ii(e,t){e.report({node:t,messageId:`forbiddenDefaultImport`,data:{configPackage:Y,allowedFunctions:X.join(`、`)}})}function ai(e,t){e.report({node:t,messageId:`forbiddenNamespaceImport`,data:{configPackage:Y,allowedFunctions:X.join(`、`)}})}function oi(e,t,n){e.report({node:t,messageId:`forbiddenConfigImport`,data:{importedName:n,allowedFunctions:X.join(`、`)}})}function si(e,t){e.report({node:t,messageId:`missingCreateFunction`,data:{configPackage:Y,allowedFunctions:X.join(`、`)}})}function ci(e,t){if(!s(t)||t.source.value!==Y)return;let n=[],r=[],i=!1;for(let a of t.specifiers)if(c(a)){if(o(a)){ii(e,t),i=!0;continue}if(a.type===`ImportNamespaceSpecifier`){ai(e,t),i=!0;continue}ri.includes(a.imported.name)?r.push(a):X.includes(a.imported.name)&&n.push(a)}if(!i){for(let n of r)oi(e,t,n.imported.name);r.length===0&&n.length===0&&(t.specifiers.some(e=>c(e)&&e.type===`ImportSpecifier`&&!X.includes(e.imported.name)&&!ri.includes(e.imported.name))||si(e,t))}}function li(e){return{ImportDeclaration(t){ci(e,t)}}}const ui={meta:{type:`problem`,docs:{description:`强制执行 eslint.config.ts 文件中的配置导入规范,必须使用 createXxxConfig 函数`},messages:{forbiddenDefaultImport:`禁止从 {{configPackage}} 使用默认导入。应使用具名导入 {{allowedFunctions}} 等配置创建函数`,forbiddenNamespaceImport:`禁止从 {{configPackage}} 使用命名空间导入。应使用具名导入 {{allowedFunctions}} 等配置创建函数`,forbiddenConfigImport:`禁止从配置包导入 {{importedName}}。应使用 {{allowedFunctions}} 等配置创建函数`,missingCreateFunction:`必须从 {{configPackage}} 导入至少一个配置创建函数(如 {{allowedFunctions}})`},schema:[]},create:li},di=[`./tsconfig/app.json`,`./tsconfig/node.json`,`./tsconfig/test.json`],fi=[`app.json`,`node.json`,`test.json`,`build.json`];function pi(e){return typeof e==`object`&&!!e&&`path`in e&&typeof e.path==`string`}function mi(e){return Array.isArray(e)&&e.every(pi)}function hi(e){return!(typeof e!=`object`||!e)}function gi(e){try{let t=ie(e,`utf-8`);return JSON.parse(t)}catch{return null}}function _i(e){let t=e.map(e=>e.path);return di.filter(e=>!t.includes(e))}function vi(e){return e.map(e=>e.path).filter(e=>!di.includes(e))}const yi=new WeakMap;function bi(e,t){let n=yi.get(e);if(n||(n=new Map,yi.set(e,n)),n.has(t))return n.get(t);let r=p(t),i={hasDir:r,missingFiles:r?xi(t):[]};return n.set(t,i),i}function xi(e){return fi.filter(t=>!p(d(e,t)))}function Si(e,t,n){if(!n.references||!mi(n.references)){e.report({node:t,messageId:`missingReferences`});return}let r=_i(n.references);r.length>0&&e.report({node:t,messageId:`missingRequiredReference`,data:{missingPath:r[0]}});let i=vi(n.references);for(let n of i)e.report({node:t,messageId:`extraReference`,data:{extraPath:n}})}function Ci(e,t,n){return n.files===void 0?!0:Array.isArray(n.files)?n.files.length===0?!0:(e.report({node:t,messageId:`filesMustBeEmpty`}),!1):(e.report({node:t,messageId:`filesMustBeArray`}),!1)}const wi={meta:{type:`problem`,docs:{description:`检查 tsconfig.json 是否正确使用 references 配置`},messages:{missingReferences:`tsconfig.json 必须使用 references 配置,采用目录收拢多配置模式。请添加 references 字段,包含 app.json、node.json、test.json 三个配置。`,missingRequiredReference:`tsconfig.json 的 references 缺少必需的配置: "{{missingPath}}"。references 必须包含 ./tsconfig/app.json、./tsconfig/node.json、./tsconfig/test.json。`,filesMustBeEmpty:`tsconfig.json 使用 references 时,files 必须为空数组 "[]"。请将 files 设置为空数组或移除 files 字段。`,filesMustBeArray:`tsconfig.json 使用 references 时,files 必须为数组类型。请将 files 设置为空数组 "[]"。`,missingTsconfigDirectory:`缺少 tsconfig/ 目录。请创建 tsconfig/ 目录并添加 app.json、node.json、test.json、build.json 配置文件。`,missingConfigFile:`tsconfig/ 目录缺少必需的配置文件: {{missingFiles}}。必需的配置文件包括: app.json、node.json、test.json、build.json。`,extraReference:`tsconfig.json 的 references 包含非必需的配置: "{{extraPath}}"。references 应仅包含 ./tsconfig/app.json、./tsconfig/node.json、./tsconfig/test.json。`},schema:[]},create(e){let t=e.filename;if(!t.endsWith(`tsconfig.json`)||t.includes(`tsconfig/`))return{};let n=d(re(t),`tsconfig`);return{Program(r){let i=gi(t);if(!hi(i))return;let a=bi(e,n);if(!a.hasDir){e.report({node:r,messageId:`missingTsconfigDirectory`});return}if(a.missingFiles.length>0){e.report({node:r,messageId:`missingConfigFile`,data:{missingFiles:a.missingFiles.join(`, `)}});return}Ci(e,r,i)&&Si(e,r,i)}}}};function Ti(e){let t=e.replace(/\\/g,`/`);return t.includes(`/src/preload/`)&&!t.includes(`/__tests__/`)}const Ei={meta:{type:`problem`,docs:{description:`禁止使用字符串字面量作为 IPC 通道名`},messages:{noStringLiteral:`禁止使用字符串字面量作为 IPC 通道名。请使用通道常量。`},schema:[]},create(e){return Ti(e.filename)?{CallExpression(t){if(t.callee.type!==`Identifier`||t.callee.name!==`invoke`||t.arguments.length===0)return;let n=t.arguments[0];n&&n.type===`Literal`&&typeof n.value==`string`&&e.report({node:n,messageId:`noStringLiteral`})},ObjectExpression(t){if(t.parent?.type===`CallExpression`&&t.parent.callee.type===`Identifier`&&t.parent.callee.name===`createTypedAPI`)for(let n of t.properties)n.type===`Property`&&n.value.type===`Literal`&&typeof n.value.value==`string`&&e.report({node:n.value,messageId:`noStringLiteral`})}}:{}}};function Di(e){let t=e.replace(/\\/g,`/`);return t.endsWith(`/src/preload/index.ts`)&&!t.includes(`/__tests__/`)}function Oi(e){let t=e.parent;for(;t;){if(t.type===`CallExpression`&&t.callee.type===`Identifier`&&t.callee.name===`exposeSafeAPI`)return!0;t=t.parent}return!1}const ki={meta:{type:`problem`,docs:{description:`要求使用 exposeSafeAPI 进行 API 暴露`},messages:{requireExposeSafeApi:`请使用 exposeSafeAPI 进行 API 暴露,而非直接调用 contextBridge.exposeInMainWorld。`},schema:[]},create(e){return Di(e.filename)?{CallExpression(t){t.callee.type===`MemberExpression`&&t.callee.object.type===`Identifier`&&t.callee.object.name===`contextBridge`&&t.callee.property.type===`Identifier`&&t.callee.property.name===`exposeInMainWorld`&&(Oi(t)||e.report({node:t,messageId:`requireExposeSafeApi`}))}}:{}}};function Ai(e){let t=e.replace(/\\/g,`/`);return t.includes(`/src/preload/utils/`)&&!t.includes(`/__tests__/`)}function ji(e){return e.startsWith(`createTyped`)}const Mi={meta:{type:`problem`,docs:{description:`禁止自定义 IPC 工具函数`},messages:{noCustomIPC:`禁止自定义 IPC 工具函数。请使用 @longzai-intelligence/electron/preload 提供的标准函数。`},schema:[]},create(e){return Ai(e.filename)?{FunctionDeclaration(t){t.id&&ji(t.id.name)&&e.report({node:t,messageId:`noCustomIPC`})},VariableDeclaration(t){for(let n of t.declarations){if(n.id.type!==`Identifier`||!ji(n.id.name))continue;let r=n.init;r&&(r.type===`FunctionExpression`||r.type===`ArrowFunctionExpression`)&&e.report({node:t,messageId:`noCustomIPC`})}}}:{}}},Ni=new Set([`unwrap`,`unwrapIPCResult`]);function Pi(e){let t=e.replace(/\\/g,`/`);return t.includes(`/src/renderer/`)&&!t.includes(`/__tests__/`)&&!t.endsWith(`.test.ts`)&&!t.endsWith(`.spec.ts`)}function Fi(e){if(e.type!==`CallExpression`)return!1;let{callee:t}=e;if(t.type!==`MemberExpression`)return!1;let{object:n}=t;return n.type===`MemberExpression`?n.object.type===`Identifier`&&n.object.name===`window`:!1}function Ii(e){let t=e.parent;for(;t;){if(t.type===`CallExpression`&&t.callee.type===`Identifier`&&Ni.has(t.callee.name))return!0;if(t.type===`CallExpression`)break;t=t.parent}return!1}const Z={meta:{type:`problem`,docs:{description:`渲染层调用 IPC API 时必须使用 unwrap 解包结果`},messages:{requireUnwrap:`渲染层调用 IPC API 时必须使用 unwrap 或 unwrapIPCResult 解包结果。`},schema:[]},create(e){return Pi(e.filename)?{CallExpression(t){Fi(t)&&(Ii(t)||e.report({node:t,messageId:`requireUnwrap`}))}}:{}}};function Li(e){return e.endsWith(`Class`)}function Ri(e,t){if(typeof t!=`object`||!t||!(`imported`in t)||!(`local`in t)||t.local===null||typeof t.local!=`object`||!(`name`in t.local)||typeof t.local.name!=`string`||!(`range`in t.local)||!Array.isArray(t.local.range))return;let n=t.local.name,r=t.imported!==null&&typeof t.imported==`object`&&`name`in t.imported&&typeof t.imported.name==`string`?t.imported.name:n;n!==r&&Li(n)&&e.report({node:t,messageId:`noClassSuffixAlias`,data:{aliasName:n,importedName:r}})}function zi(e){return{ImportSpecifier(t){Ri(e,t)}}}const Bi={meta:{type:`problem`,docs:{description:`禁止在 import 别名中使用 "Class" 后缀`},messages:{noClassSuffixAlias:`导入别名 "{{aliasName}}" 使用了 "Class" 后缀,这是不允许的命名方式。请使用更具描述性的名称,或直接使用原始名称 "{{importedName}}"`},schema:[]},create:zi},Vi=/domains\/[^/]+\/implementation\/src\/index\.ts$/,Hi=[/\.\/typeorm/,/\.\/typeorm'/,/\.\/typeorm"/];function Ui(e){return Hi.some(t=>t.test(e))}const Wi={meta:{type:`problem`,docs:{description:`Implementation 包导出控制:禁止从主入口重新导出 typeorm.ts 的内容,typeorm.ts 仅供 DataSource/迁移基础设施使用`,recommended:!0},schema:[],messages:{forbiddenTypeormReExport:`禁止从主入口重新导出 typeorm.ts 的内容。typeorm.ts 是专门的持久化入口,仅供 DataSource/迁移基础设施使用,业务代码应通过主入口导入领域服务`}},create(e){let t=e.filename;return Vi.test(t)?{ExportNamedDeclaration(t){if(!t.source)return;let n=t.source.value;typeof n==`string`&&Ui(n)&&e.report({node:t,messageId:`forbiddenTypeormReExport`})},ExportAllDeclaration(t){if(!t.source)return;let n=t.source.value;typeof n==`string`&&Ui(n)&&e.report({node:t,messageId:`forbiddenTypeormReExport`})}}:{}}},Gi={type:`suggestion`,docs:{description:`强制 domain entities 导出命名符合 {DOMAIN}_ORM_ENTITIES 规范`,recommended:!0},fixable:void 0,schema:[],messages:{invalidNaming:`entities 导出命名 "{{name}}" 不符合规范,应使用 "{{expected}}" 格式`,genericNaming:`entities 导出命名 "{{name}}" 是通用名称,应使用具体的 domain 名称 "{{expected}}"`,missingOrm:`entities 导出命名 "{{name}}" 缺少 "_ORM" 前缀,应使用 "{{expected}}"`,typoDetected:`entities 导出命名 "{{name}}" 可能存在拼写错误,应使用 "{{expected}}"`}},Ki=new Set([`DOMAIN_ENTITIES`,`ALL_ENTITIES`,`ENTITIES`]);function qi(e){let t=e.match(/\/domains\/([^/]+)\/implementation\/src\/typeorm\.ts$/);return!t||!t[1]?null:t[1].split(`-`).map(e=>e.toUpperCase()).join(`_`)}function Ji(e,t){return e.endsWith(`_ORM_ENTITIES`)?!1:e.endsWith(`_ENTITIES`)?e.replace(`_ENTITIES`,``)===t.replace(`_ORM_ENTITIES`,``):!1}function Yi(e){return Ki.has(e)}function Xi(e,t){let n=e.length,r=t.length,i=[];for(let a=0;a<=n;a++){i[a]=[];for(let n=0;n<=r;n++)a===0?i[a][n]=n:n===0?i[a][n]=a:e[a-1]===t[n-1]?i[a][n]=i[a-1][n-1]:i[a][n]=Math.min(i[a-1][n-1],i[a][n-1],i[a-1][n])+1}return i[n][r]}function Zi(e,t){let n=e.replace(`_ORM_ENTITIES`,``).replace(`_ENTITIES`,``),r=t.replace(`_ORM_ENTITIES`,``);return n===r?!1:n.toLowerCase()===r.toLowerCase()?!0:Xi(n,r)<=2}function Qi(e,t,n,r){Ji(n,r)?e.report({node:t,messageId:`missingOrm`,data:{name:n,expected:r}}):Yi(n)?e.report({node:t,messageId:`genericNaming`,data:{name:n,expected:r}}):Zi(n,r)?e.report({node:t,messageId:`typoDetected`,data:{name:n,expected:r}}):e.report({node:t,messageId:`invalidNaming`,data:{name:n,expected:r}})}function $i(e,t,n,r){if(typeof n!=`object`||!n||!(`id`in n)||n.id===null||typeof n.id!=`object`||!(`type`in n.id)||n.id.type!==`Identifier`||!(`name`in n.id)||typeof n.id.name!=`string`)return;let i=n.id.name;!i.endsWith(`_ENTITIES`)&&!i.endsWith(`_ORM_ENTITIES`)||i!==r&&Qi(e,t,i,r)}function ea(e,t,n,r){if(typeof n!=`object`||!n||!(`exported`in n)||n.exported===null||typeof n.exported!=`object`||!(`type`in n.exported)||n.exported.type!==`Identifier`||!(`name`in n.exported)||typeof n.exported.name!=`string`)return;let i=n.exported.name;!i.endsWith(`_ENTITIES`)&&!i.endsWith(`_ORM_ENTITIES`)||i!==r&&Qi(e,t,i,r)}function ta(e,t){function n(n){if(typeof n==`object`&&n&&`declaration`in n&&n.declaration!==null&&typeof n.declaration==`object`&&`type`in n.declaration&&n.declaration.type===`VariableDeclaration`&&`declarations`in n.declaration&&Array.isArray(n.declaration.declarations))for(let r of n.declaration.declarations)$i(e,n,r,t);if(typeof n==`object`&&n&&`specifiers`in n&&Array.isArray(n.specifiers))for(let r of n.specifiers)ea(e,n,r,t)}return n}function na(e){let t=e.filename;if(!t.endsWith(`typeorm.ts`))return{};let n=qi(t);return n?{ExportNamedDeclaration:ta(e,`${n}_ORM_ENTITIES`)}:{}}const ra={meta:Gi,create:na};function ia(e){return e.replace(/\\/g,`/`).includes(`/apps/`)}function aa(e){return e.endsWith(`-implementation`)}function oa(e){return e.endsWith(`Entity`)}function sa(e){return e.endsWith(`UseCase`)}function ca(e){return[/PortAdapter$/,/_TOKEN$/,/^create\w+Repository$/,/^create\w+Adapter$/].some(t=>t.test(e))}const la={noEntityImport:`禁止在 apps 层导入 Entity 类 "{{importName}}"。请使用 contract 包的 Port 接口进行操作。`,noUseCaseImport:`禁止在 apps 层导入 UseCase 类 "{{importName}}"。请使用 contract 包的 Port 接口进行操作。`,noImplementationImport:`禁止在 apps 层从 implementation 包导入 "{{importName}}"。请使用 contract 包的 Port 接口。`};function ua(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`ImportSpecifier`}function da(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`Identifier`&&`name`in e&&typeof e.name==`string`}function fa(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`Literal`&&`value`in e&&typeof e.value==`string`}function pa(e){if(!(`imported`in e)||e.imported===null||typeof e.imported!=`object`)return null;let t=e.imported;return da(t)?t.name:fa(t)?t.value:null}function ma(e,t,n){oa(n)?e.report({node:t,messageId:`noEntityImport`,data:{importName:n}}):sa(n)?e.report({node:t,messageId:`noUseCaseImport`,data:{importName:n}}):ca(n)||e.report({node:t,messageId:`noImplementationImport`,data:{importName:n}})}function ha(e,t,n){if(!ua(t))return;let r=pa(t);r&&ma(e,t,r)}const ga={meta:{type:`problem`,docs:{description:`禁止在 apps 层导入 implementation 包的 Entity 和 UseCase`},messages:la,schema:[]},create(e){let t=e.filename;return ia(t)?{ImportDeclaration(t){if(!(`source`in t)||t.source===null||typeof t.source!=`object`||!(`type`in t.source)||t.source.type!==`Literal`||!(`value`in t.source)||typeof t.source.value!=`string`)return;let n=t.source.value;if(aa(n)&&!(!(`specifiers`in t)||!Array.isArray(t.specifiers)))for(let r of t.specifiers)ua(r)&&ha(e,r,n)}}:{}}};var Q=`0.0.2`;function _a(e){let t=e.replace(/\\/g,`/`);return t.includes(`/domains/`)&&t.includes(`/implementation/src/index.ts`)}function va(e){return e.endsWith(`Entity`)}function ya(e){return e.endsWith(`Repository`)&&!e.startsWith(`I`)}function ba(e){return e.endsWith(`OrmEntity`)}function xa(e){return e.endsWith(`_ORM_ENTITIES`)}function Sa(e){return e.endsWith(`OrmMapper`)}function Ca(e){return e.endsWith(`Schema`)}function wa(e){return`exportKind`in e&&typeof e.exportKind==`string`?e.exportKind===`value`:!0}function Ta(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`ExportSpecifier`}function Ea(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`Identifier`&&`name`in e&&typeof e.name==`string`}function Da(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`Literal`&&`value`in e&&typeof e.value==`string`}function Oa(e){if(typeof e!=`object`||!e||!(`exported`in e)||e.exported===null||typeof e.exported!=`object`)return null;let t=e.exported;return Ea(t)?t.name:Da(t)?t.value:null}function $(e,t,n,r){e.report({node:t,messageId:n,data:{exportName:r}})}function ka(e,t,n){return va(n)&&wa(t)?($(e,t,`noEntityValueExport`,n),!0):!1}function Aa(e,t,n){return ya(n)?($(e,t,`noRepositoryTypeExport`,n),!0):!1}function ja(e,t,n){return ba(n)?($(e,t,`noOrmEntityExport`,n),!0):xa(n)?($(e,t,`noOrmEntitiesExport`,n),!0):Sa(n)?($(e,t,`noOrmMapperExport`,n),!0):!1}function Ma(e,t,n){Ca(n)&&$(e,t,`noSchemaExport`,n)}function Na(e,t,n){ka(e,t,n)||Aa(e,t,n)||ja(e,t,n)||Ma(e,t,n)}function Pa(e,t){if(!(!(`source`in t)||t.source===null||typeof t.source!=`object`||!(`type`in t.source)||t.source.type!==`Literal`||!(`value`in t.source)||typeof t.source.value!=`string`)&&!(!(`specifiers`in t)||!Array.isArray(t.specifiers)))for(let n of t.specifiers){if(!Ta(n))continue;let t=Oa(n);t&&Na(e,n,t)}}const Fa={meta:{type:`problem`,docs:{description:`检查 Domain Implementation 包的导出是否符合规范`},messages:{noEntityValueExport:'禁止从主入口值导出 Entity 类 "{{exportName}}"。请改为类型导出:`export type { {{exportName}} }` 或移除导出。',noRepositoryTypeExport:`禁止导出 Repository 类型 "{{exportName}}"。Repository 是内部实现,不应暴露给外部。请移除此导出。`,noOrmEntityExport:`禁止从主入口导出 ORM 实体 "{{exportName}}"。请创建 src/typeorm.ts 入口文件,从该入口导出 ORM 实体。`,noOrmEntitiesExport:`禁止从主入口导出 ORM 实体集合 "{{exportName}}"。请创建 src/typeorm.ts 入口文件,从该入口导出。`,noOrmMapperExport:`禁止导出 ORM Mapper "{{exportName}}"。ORM Mapper 是基础设施实现细节,不应暴露给外部。请移除此导出。`,noSchemaExport:`禁止导出 Schema 定义 "{{exportName}}"。Schema 是实现细节,应完全保留在 Domain 内部。请仅导出从 Schema 推断的类型。`},schema:[]},create(e){let t=e.filename;return _a(t)?{ExportNamedDeclaration(t){Pa(e,t)}}:{}}},Ia={meta:{name:`@longzai-intelligence/architecture-core`,version:Q},rules:{"dependency-direction":b,"no-core-types-in-apps":S,"business-leak":Ye,"file-naming":R,"require-type-suffix":z,"no-cross-package-relative-import":Zt,"prefer-split-export-const":$n,"require-class-suffix":gr,"require-interface-naming":Or,"require-type-naming":Mr,"require-dto-naming":Ir,"no-class-suffix-alias":Bi,"implementation-export-control":Wi,"no-implementation-import-in-apps":ga,"domain-export-compliance":Fa}},La={meta:{name:`@longzai-intelligence/architecture-domain`,version:Q},rules:{"domain-export":at,"domain-typeorm-import":ut,"layer-readme-required":cr,"require-domain-entities-naming":ra}},Ra={meta:{name:`@longzai-intelligence/architecture-electron`,version:Q},rules:{"platform-leak":Le,"no-implementation-in-renderer":Wt,"no-unsafe-electron-api-exposure":zn,"no-generic-ipc-bridge-exposure":Un,"no-direct-ipcrenderer-in-preload":Gn,"tsconfig-references":wi,"require-typed-ipc-channel":Ei,"require-expose-safe-api":ki,"no-custom-ipc-utility":Mi,"require-unwrap-ipc-result":Z}},za={meta:{name:`@longzai-intelligence/architecture-library`,version:Q},rules:{"test-file-placement":fn,"no-non-test-files-in-tests-directory":bn,"test-file-matches-source":Ln,"require-tsup-config-import":Br,"require-tsdown-config-import":Wr,"require-vitest-config-import":ni,"require-eslint-config-import":ui}},Ba={meta:{name:`@longzai-intelligence/architecture`,version:Q},rules:{"dependency-direction":b,"no-core-types-in-apps":S,"platform-leak":Le,"business-leak":Ye,"domain-export":at,"domain-typeorm-import":ut,"file-naming":R,"require-type-suffix":z,"no-implementation-in-renderer":Wt,"no-cross-package-relative-import":Zt,"test-file-placement":fn,"no-non-test-files-in-tests-directory":bn,"test-file-matches-source":Ln,"no-unsafe-electron-api-exposure":zn,"no-generic-ipc-bridge-exposure":Un,"no-direct-ipcrenderer-in-preload":Gn,"prefer-split-export-const":$n,"layer-readme-required":cr,"require-class-suffix":gr,"require-interface-naming":Or,"require-type-naming":Mr,"require-dto-naming":Ir,"require-tsup-config-import":Br,"require-tsdown-config-import":Wr,"require-vitest-config-import":ni,"require-eslint-config-import":ui,"tsconfig-references":wi,"require-typed-ipc-channel":Ei,"require-expose-safe-api":ki,"no-custom-ipc-utility":Mi,"require-unwrap-ipc-result":Z,"no-class-suffix-alias":Bi,"implementation-export-control":Wi,"require-domain-entities-naming":ra,"no-implementation-import-in-apps":ga}};export{v as DEFAULT_ARCHITECTURE_CONFIG,Ia as architectureCorePlugin,La as architectureDomainPlugin,Ra as architectureElectronPlugin,za as architectureLibraryPlugin,Ba as architecturePlugin,Ba as default,O as baseStrategy,St as composeStrategies,j as expoRouterStrategy,T as isPlatformNamingStrategy,A as nextJsStrategy};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longzai-intelligence/eslint-plugin-architecture",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "types": "./dist/index.d.mts",
@@ -20,7 +20,7 @@
20
20
  "scripts": {
21
21
  "build": "tsdown",
22
22
  "build:prod": "NODE_ENV=production tsdown",
23
- "prepublish": "bun run build:prod",
23
+ "prepublishOnly": "bun run build:prod",
24
24
  "dev": "tsdown --watch",
25
25
  "clean": "rimraf dist",
26
26
  "test": "vitest run",
@@ -38,16 +38,16 @@
38
38
  "typescript": "^5.9.3"
39
39
  },
40
40
  "dependencies": {
41
- "@longzai-intelligence/eslint-utils": "workspace:*",
42
- "@typescript-eslint/utils": "^8.57.2"
41
+ "@longzai-intelligence/eslint-utils": "0.0.2",
42
+ "@typescript-eslint/utils": "^8.58.0"
43
43
  },
44
44
  "devDependencies": {
45
- "@longzai-intelligence/eslint-config": "workspace:*",
45
+ "@longzai-intelligence/eslint-config": "0.1.0",
46
46
  "@longzai-intelligence/typescript-config": "0.0.2",
47
- "@longzai-intelligence/vitest-config": "0.0.1",
48
- "@types/node": "^25.5.0",
47
+ "@longzai-intelligence/vitest-config": "0.0.3",
48
+ "@types/node": "^25.5.2",
49
49
  "rimraf": "^6.1.3",
50
- "vitest": "^4.1.1",
50
+ "vitest": "^4.1.2",
51
51
  "tsdown": "^0.21.7",
52
52
  "@longzai-intelligence/tsdown-config": "0.0.1"
53
53
  },