devarchitect-cli 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +135 -0
- package/dist/bin.js +1 -1
- package/dist/{chunk-YIDMYXTY.js → chunk-VHWMNHY2.js} +70 -70
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {Command}from'commander';import G from'path';import
|
|
2
|
-
`,si=s=>{let e=s.length;for(;e&&ti(s[e-1]);)e--;let t=e;for(;e&&s[e-1]===bt;)e--;if(e===t)return s.slice(0,e);let n=0;for(;n<e&&s[e-n-1]===
|
|
3
|
-
`)&&(n=si(n)),!n)return;n=n.replace(Po,"!").replace(Ro,"#");let a=mn(n);return new Is(s,e,n,t,r,a)},Ps=class{constructor(e){this._ignoreCase=e,this._rules=[],this._basenameCount=0;}_add(e){if(e&&e[pn]){this._rules=this._rules.concat(e._rules._rules),this._basenameCount+=e._rules._basenameCount,this._added=!0;return}Yt(e)&&(e={pattern:e});let t=Qo(e.pattern)&&ni(e,this._ignoreCase);t&&(this._added=!0,this._rules.push(t),gn(t.body)&&this._basenameCount++);}add(e){return this._added=!1,dn(Yt(e)?ei(e):e).forEach(this._add,this),this._added&&(this._literalRules=et),this._added}testLiteral(e){let t=this._literalRules||(this._literalRules=this._rules.filter(({body:i})=>i[i.length-(i[i.length-1]===$e?2:1)]==="*")),n=!1,r=!1,o;for(let i=t.length-1;i>=0;i--){let l=t[i];if(l.checkRegex.test(e)){n=!l.negative,r=l.negative,o=l.negative?et:l;break}}let a={ignored:n,unignored:r};return o&&(a.rule=o),a}test(e,t){let n=this._rules,{length:r}=n,o=this._basenameCount*2>=r,a=o?Yo(e):e;for(let i=r-1;i>=0;i--){let l=n[i];if(l[t].test(o&&l._basenameOnly?a:e)){let{negative:c}=l,d={ignored:!c,unignored:c};return c||(d.rule=l),d}}return {ignored:!1,unignored:!1}}},ri=(s,e)=>{throw new e(s)},ze=(s,e,t)=>Yt(s)?s?ze.isNotRelative(s)?t(`path should be a \`path.relative()\`d string, but got "${e}"`,RangeError):!0:t("path must not be empty",TypeError):t(`path must be a string, but got \`${e}\``,TypeError),hn=s=>{let e=s.charCodeAt(0);if(e===xt)return !0;if(e!==rn)return !1;if(s.length===1)return !0;let t=s.charCodeAt(1);return t===xt?!0:t!==rn?!1:s.length===2||s.charCodeAt(2)===xt};ze.isNotRelative=hn;ze.convert=s=>s;var Rs=class{constructor({ignorecase:e=!0,ignoreCase:t=e,allowRelativePaths:n=!1}={}){Qe(this,pn,!0),this._rules=new Ps(t),this._strictPathCheck=!n,this._initCache();}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null);}add(e){return this._rules.add(e)&&this._initCache(),this}addPattern(e){return this.add(e)}_test(e,t){let n=e&&ze.convert(e);return ze(n,e,this._strictPathCheck?ri:fn),this._t(n,t)}checkIgnore(e){if(e.charCodeAt(e.length-1)!==xt)return this.test(e);let t=this._t(e,this._testCache);if(t.ignored)return t;let n=this._rules.testLiteral(e);return n.ignored||n.unignored?n:t}_t(e,t){if(e in t)return t[e];let n=Xo(e),r=n?this._t(n,t):et;return t[e]=r&&r.ignored?r:this._rules.test(e,qt)}ignores(e){return this._test(e,this._ignoreCache).ignored}createFilter(){return e=>!this.ignores(e)}filter(e){return dn(e).filter(this.createFilter())}test(e){return this._test(e,this._testCache)}},js=s=>new Rs(s),oi=s=>ze(s&&ze.convert(s),s,fn),yn=()=>{let s=t=>/^\\\\\?\\/.test(t)||/["<>|\u0000-\u001F]+/u.test(t)?t:t.replace(/\\/g,"/");ze.convert=s;let e=/^[a-z]:\//i;ze.isNotRelative=t=>e.test(t)||hn(t);};typeof process<"u"&&process.platform==="win32"&&yn();Xt.exports=js;js.default=js;Xt.exports.isPathValid=oi;Qe(Xt.exports,Symbol.for("setupWindows"),yn);});var he=W(U());var Qs={id:"detector-nextjs",name:"Next.js Detector",detect(s){let e=s.hasAnyDependency("next"),t=s.hasFile("next.config.js")||s.hasFile("next.config.mjs")||s.hasFile("next.config.ts");if(!e&&!t)return null;let n=s.fileList.some(h=>h.startsWith("app/")||h.startsWith("src/app/")),r=s.fileList.some(h=>h.startsWith("pages/")||h.startsWith("src/pages/")),o=s.fileList.some(h=>h.startsWith("features/")||h.startsWith("src/features/")||h.startsWith("modules/")||h.startsWith("src/modules/")),a=[],i=["src/app/layout.tsx","src/app/layout.jsx","app/layout.tsx","app/layout.jsx","src/app/page.tsx","src/app/page.jsx","app/page.tsx","app/page.jsx","src/pages/_app.tsx","src/pages/_app.jsx","pages/_app.tsx","pages/_app.jsx","src/pages/index.tsx","pages/index.tsx"];for(let h of i)s.hasFile(h)&&a.push(h);let l=s.packageJson,c=l?.dependencies||{},d=l?.devDependencies||{};return {matched:true,framework:"nextjs",frameworkVersion:c.next||d.next,priority:100,features:{appRouter:n,pagesRouter:r,react:true,tailwind:s.hasAnyDependency("tailwindcss")||s.hasFile("tailwind.config.js")||s.hasFile("tailwind.config.ts"),zustand:s.hasAnyDependency("zustand"),tanstackQuery:s.hasAnyDependency("@tanstack/react-query")||s.hasAnyDependency("react-query"),redux:s.hasAnyDependency("@reduxjs/toolkit")||s.hasAnyDependency("redux"),prisma:s.hasAnyDependency("@prisma/client")||s.hasFile("prisma/schema.prisma"),drizzle:s.hasAnyDependency("drizzle-orm"),featureModules:o?"partial":"none",testingFramework:s.hasAnyDependency("vitest")?"vitest":s.hasAnyDependency("jest")?"jest":s.hasAnyDependency("@playwright/test")?"playwright":null},entryPoints:a,suggestedPresets:["feature-sliced","layered","recommended"]}}};var en={id:"detector-react",name:"React Detector",detect(s){let e=s.hasAnyDependency("react"),t=s.hasAnyDependency("vite")||s.hasFile("vite.config.ts")||s.hasFile("vite.config.js");s.hasAnyDependency("react-scripts");if(!e&&!t)return null;let r=s.fileList.some(u=>u.startsWith("features/")||u.startsWith("src/features/")||u.startsWith("modules/")||u.startsWith("src/modules/")),o=[],a=["src/main.tsx","src/main.jsx","src/index.tsx","src/index.jsx","src/App.tsx","src/App.jsx","index.html"];for(let u of a)s.hasFile(u)&&o.push(u);let i=s.packageJson,l=i?.dependencies||{},c=i?.devDependencies||{},d=l.react||c.react||l.vite||c.vite;return {matched:true,framework:t?"vite":"react",frameworkVersion:d,priority:50,features:{appRouter:false,pagesRouter:false,react:true,tailwind:s.hasAnyDependency("tailwindcss")||s.hasFile("tailwind.config.js")||s.hasFile("tailwind.config.ts"),zustand:s.hasAnyDependency("zustand"),tanstackQuery:s.hasAnyDependency("@tanstack/react-query")||s.hasAnyDependency("react-query"),redux:s.hasAnyDependency("@reduxjs/toolkit")||s.hasAnyDependency("redux"),prisma:s.hasAnyDependency("@prisma/client"),drizzle:s.hasAnyDependency("drizzle-orm"),featureModules:r?"partial":"none",testingFramework:s.hasAnyDependency("vitest")?"vitest":s.hasAnyDependency("jest")?"jest":null},entryPoints:o,suggestedPresets:["feature-sliced","clean-architecture","recommended"]}}};var tn={id:"detector-vue",name:"Vue / Nuxt Detector",detect(s){let e=s.hasAnyDependency("nuxt")||s.hasFile("nuxt.config.ts")||s.hasFile("nuxt.config.js"),t=s.hasAnyDependency("vue");if(!e&&!t)return null;let n=[],r=["src/main.ts","src/main.js","src/App.vue","app.vue"];for(let o of r)s.hasFile(o)&&n.push(o);return {matched:true,framework:e?"nuxt":"vue",priority:e?90:45,features:{react:false,tailwind:s.hasAnyDependency("tailwindcss"),testingFramework:s.hasAnyDependency("vitest")?"vitest":null},entryPoints:n,suggestedPresets:["layered","recommended"]}}};var sn={id:"detector-node",name:"Node.js / Backend Detector",detect(s){let e=s.hasAnyDependency("@nestjs/core")||s.hasFile("nest-cli.json"),t=s.hasAnyDependency("express"),n=s.hasAnyDependency("fastify");if(!e&&!t&&!n&&!s.hasFile("package.json"))return null;let r=e?"nest":t?"express":n?"fastify":"node",o=[],a=["src/main.ts","src/server.ts","src/index.ts","src/app.ts","server.js","index.js"];for(let i of a)s.hasFile(i)&&o.push(i);return {matched:true,framework:r,priority:e?60:t||n?40:10,features:{prisma:s.hasAnyDependency("@prisma/client"),drizzle:s.hasAnyDependency("drizzle-orm"),testingFramework:s.hasAnyDependency("vitest")?"vitest":s.hasAnyDependency("jest")?"jest":null},entryPoints:o,suggestedPresets:e?["clean-architecture","modular-monolith"]:["layered","recommended"]}}};var As=class{plugins=[];constructor(){this.registerBuiltins();}registerBuiltins(){this.register(Qs),this.register(en),this.register(tn),this.register(sn);}register(e){this.plugins=this.plugins.filter(t=>t.id!==e.id),this.plugins.push(e);}getPlugins(){return this.plugins}async detect(e){let t=[];for(let a of this.plugins)try{let i=await a.detect(e);i&&i.matched&&t.push(i);}catch{}if(t.length===0)return {matched:false,framework:"unknown",priority:0,features:{},entryPoints:[],suggestedPresets:["recommended"]};t.sort((a,i)=>i.priority-a.priority);let n=t[0],r=t.reduceRight((a,i)=>({...a,...i.features}),n.features||{}),o=Array.from(new Set(t.flatMap(a=>a.entryPoints||[])));return {...n,features:r,entryPoints:o}}},nn=new As;var bn=W(vn());function Qt(s){return s.replace(/\\/g,"/")}function ci(s){let e=G.join(s,".gitignore");if(!ue.existsSync(e))return null;try{let t=ue.readFileSync(e,"utf8"),n=(0,bn.default)();return n.add(t),n}catch{return null}}async function wn(s,e={}){let t=e.include&&e.include.length>0?e.include:["**/*"],n=["**/node_modules/**","**/.git/**","**/.next/**","**/dist/**","**/build/**","**/out/**","**/coverage/**","**/.turbo/**","**/.devarchitect/cache/**","**/.devarchitect/reports/**","**/*.log"],r=Array.from(new Set([...n,...e.exclude||[]])),o=e.respectGitignore!==false?ci(s):null,i=(await ai(t,{cwd:s,ignore:r,dot:true,onlyFiles:true,followSymbolicLinks:false})).map(Qt);return o?i.filter(c=>!o.ignores(c)).sort():i.sort()}function ui(s){return li.createHash("sha256").update(s).digest("hex")}function es(s){try{let e=ue.readFileSync(s);return ui(e)}catch{return ""}}function fi(s){switch(G.extname(s).toLowerCase()){case ".ts":return "typescript";case ".tsx":return "typescript-react";case ".js":case ".mjs":case ".cjs":return "javascript";case ".jsx":return "javascript-react";case ".json":return "json";case ".css":case ".scss":case ".sass":case ".less":return "stylesheet";case ".html":return "html";case ".md":case ".mdx":return "markdown";case ".vue":return "vue";case ".svelte":return "svelte";default:return "unknown"}}function mi(s){let e=s.split("/"),t=["app","processes","pages","widgets","features","entities","shared"];for(let r of t)if(e.indexOf(r)!==-1)return r;let n=["domain","application","infrastructure","presentation","adapters","core"];for(let r of n)if(e.indexOf(r)!==-1)return r}function gi(s){let e=s.split("/"),t=e.findIndex(n=>n==="features"||n==="modules");if(t!==-1&&t<e.length-1)return e[t+1]}function hi(s){let e=Qt(s).toLowerCase(),t=G.basename(s),n=G.extname(s).toLowerCase();return e.includes("__tests__")||e.includes("__mocks__")||t.includes(".test.")||t.includes(".spec.")?"test":t.includes(".config.")||t.startsWith("tsconfig")||t==="package.json"||t==="turbo.json"||t==="pnpm-workspace.yaml"||e.startsWith(".devarchitect")?"config":[".css",".scss",".sass",".less",".svg",".png",".jpg",".jpeg",".gif",".webp",".ico"].includes(n)?"asset":e.includes("/app/")&&(t.startsWith("page.")||t.startsWith("layout.")||t.startsWith("route.")||t.startsWith("loading.")||t.startsWith("error."))||e.includes("/pages/")||e.includes("/routes/")||t.includes(".route.")?"route":t.startsWith("use")&&(n===".ts"||n===".tsx"||n===".js"||n===".jsx")||e.includes("/hooks/")?"hook":t.toLowerCase().includes("service.")||t.toLowerCase().includes("client.")||e.includes("/services/")||e.includes("/service/")||e.includes("/api/")||e.includes("/repositories/")||e.includes("/repository/")?"service":t.toLowerCase().includes("util.")||t.toLowerCase().includes("helper.")||e.includes("/utils/")||e.includes("/util/")||e.includes("/helpers/")||e.includes("/lib/")?"utility":n===".tsx"||n===".jsx"||n===".vue"||n===".svelte"||e.includes("/components/")||e.includes("/widgets/")||/^[A-Z][a-zA-Z0-9]+\.(ts|js|tsx|jsx)$/.test(t)&&!t.toLowerCase().includes("service")?"component":e.includes("/features/")||e.includes("/modules/")?"module":"unknown"}function yi(s){try{return ue.readFileSync(s,"utf8").split(/\r\n|\r|\n/).length}catch{return 0}}function Sn(s,e){let t=Qt(e),n=G.join(s,e),r=hi(t),o=gi(t),a=mi(t),i=fi(t),l=yi(n),c=es(n);return {id:t,path:t,name:G.basename(t),type:r,language:i,feature:o,layer:a,metrics:{complexity:null,linesOfCode:l,dependencyCount:0,dependentCount:0,exportCount:0,importCount:0},metadata:{hash:c}}}function kn(s){let e=[G.join(s,"tsconfig.json"),G.join(s,"tsconfig.app.json")],t;for(let n of e)if(ue.existsSync(n)){t=n;break}if(!t)return {exists:false,pathAliases:[]};try{let r=ue.readFileSync(t,"utf8").replace(/\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*$/gm,"$1"),a=JSON.parse(r).compilerOptions||{},i=[];if(a.paths&&typeof a.paths=="object")for(let[l,c]of Object.entries(a.paths))Array.isArray(c)&&i.push({prefix:l,targets:c.map(d=>String(d))});return {exists:!0,configPath:G.relative(s,t).replace(/\\/g,"/"),target:a.target,module:a.module,strict:a.strict,pathAliases:i}}catch{return {exists:true,configPath:G.relative(s,t).replace(/\\/g,"/"),pathAliases:[]}}}function $n(s){let e=G.join(s,"package.json");if(!ue.existsSync(e))return {exists:false,name:G.basename(s),raw:{},dependencies:{},devDependencies:{},scripts:{}};try{let t=ue.readFileSync(e,"utf8"),n=JSON.parse(t);return {exists:!0,name:n.name||G.basename(s),version:n.version,raw:n,dependencies:n.dependencies||{},devDependencies:n.devDependencies||{},scripts:n.scripts||{}}}catch{return {exists:true,name:G.basename(s),raw:{},dependencies:{},devDependencies:{},scripts:{}}}}function _n(s){let e=s;for(let t=0;t<5;t++){if(ue.existsSync(G.join(e,"pnpm-lock.yaml")))return "pnpm";if(ue.existsSync(G.join(e,"yarn.lock")))return "yarn";if(ue.existsSync(G.join(e,"bun.lockb"))||ue.existsSync(G.join(e,"bun.lock")))return "bun";if(ue.existsSync(G.join(e,"package-lock.json")))return "npm";let n=G.dirname(e);if(n===e)break;e=n;}return "unknown"}function En(s,e){let t=G.join(s,"pnpm-workspace.yaml");if(ue.existsSync(t))return {isMonorepo:true,workspaces:["pnpm-workspace"]};let n=G.join(s,"lerna.json");if(ue.existsSync(n))return {isMonorepo:true,workspaces:["lerna"]};let r=G.join(s,"turbo.json");return ue.existsSync(r)?{isMonorepo:true,workspaces:["turborepo"]}:e.raw.workspaces?{isMonorepo:true,workspaces:Array.isArray(e.raw.workspaces)?e.raw.workspaces:[]}:{isMonorepo:false,workspaces:[]}}var Os={$schema:"https://devarchitect.dev/schema/config.json",version:1,project:{name:void 0,framework:"auto",root:"."},analysis:{incremental:true,include:["src/**","app/**","pages/**","lib/**","components/**","features/**","modules/**","services/**","hooks/**","packages/**","apps/**","tests/**","__tests__/**"],exclude:["**/node_modules/**","**/.next/**","**/dist/**","**/build/**","**/out/**","**/coverage/**","**/.turbo/**","**/.git/**","**/*.d.ts","**/*.config.*","**/vite.config.*","**/next.config.*"],maxDependencyDepth:20},architecture:{preset:"recommended",rules:{"no-circular-dependencies":"error","no-cross-feature-imports":"error","enforce-public-api":"warning","max-dependency-depth":"warning","no-unresolved-imports":"error"}},ai:{enabled:false,provider:null},guard:{baseline:true,failOnNewErrors:true,failOnNewWarnings:false,ratchetDebt:true}};var p={};Co(p,{BRAND:()=>Wi,DIRTY:()=>tt,EMPTY_PATH:()=>wi,INVALID:()=>D,NEVER:()=>Ea,OK:()=>ge,ParseStatus:()=>pe,Schema:()=>O,ZodAny:()=>qe,ZodArray:()=>Ue,ZodBigInt:()=>nt,ZodBoolean:()=>rt,ZodBranded:()=>Ft,ZodCatch:()=>gt,ZodDate:()=>ot,ZodDefault:()=>mt,ZodDiscriminatedUnion:()=>rs,ZodEffects:()=>Te,ZodEnum:()=>pt,ZodError:()=>we,ZodFirstPartyTypeKind:()=>P,ZodFunction:()=>is,ZodIntersection:()=>lt,ZodIssueCode:()=>w,ZodLazy:()=>dt,ZodLiteral:()=>ut,ZodMap:()=>_t,ZodNaN:()=>At,ZodNativeEnum:()=>ft,ZodNever:()=>je,ZodNull:()=>at,ZodNullable:()=>Me,ZodNumber:()=>st,ZodObject:()=>Se,ZodOptional:()=>Ee,ZodParsedType:()=>_,ZodPipeline:()=>Lt,ZodPromise:()=>Ke,ZodReadonly:()=>ht,ZodRecord:()=>os,ZodSchema:()=>O,ZodSet:()=>Et,ZodString:()=>Ze,ZodSymbol:()=>kt,ZodTransformer:()=>Te,ZodTuple:()=>Le,ZodType:()=>O,ZodUndefined:()=>it,ZodUnion:()=>ct,ZodUnknown:()=>We,ZodVoid:()=>$t,addIssueToContext:()=>$,any:()=>Xi,array:()=>sa,bigint:()=>Zi,boolean:()=>Ln,coerce:()=>_a,custom:()=>On,date:()=>qi,datetimeRegex:()=>Rn,defaultErrorMap:()=>Be,discriminatedUnion:()=>ia,effect:()=>va,enum:()=>ga,function:()=>pa,getErrorMap:()=>wt,getParsedType:()=>Fe,instanceof:()=>Vi,intersection:()=>aa,isAborted:()=>ss,isAsync:()=>St,isDirty:()=>ns,isValid:()=>Ge,late:()=>Ui,lazy:()=>fa,literal:()=>ma,makeIssue:()=>Nt,map:()=>da,nan:()=>Gi,nativeEnum:()=>ha,never:()=>ea,null:()=>Yi,nullable:()=>ba,number:()=>Fn,object:()=>na,objectUtil:()=>Ns,oboolean:()=>$a,onumber:()=>ka,optional:()=>xa,ostring:()=>Ca,pipeline:()=>Sa,preprocess:()=>wa,promise:()=>ya,quotelessJson:()=>vi,record:()=>la,set:()=>ua,setErrorMap:()=>bi,strictObject:()=>ra,string:()=>Nn,symbol:()=>Ki,transformer:()=>va,tuple:()=>ca,undefined:()=>Ji,union:()=>oa,unknown:()=>Qi,util:()=>F,void:()=>ta});var F;(function(s){s.assertEqual=r=>{};function e(r){}s.assertIs=e;function t(r){throw new Error}s.assertNever=t,s.arrayToEnum=r=>{let o={};for(let a of r)o[a]=a;return o},s.getValidEnumValues=r=>{let o=s.objectKeys(r).filter(i=>typeof r[r[i]]!="number"),a={};for(let i of o)a[i]=r[i];return s.objectValues(a)},s.objectValues=r=>s.objectKeys(r).map(function(o){return r[o]}),s.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{let o=[];for(let a in r)Object.prototype.hasOwnProperty.call(r,a)&&o.push(a);return o},s.find=(r,o)=>{for(let a of r)if(o(a))return a},s.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&Number.isFinite(r)&&Math.floor(r)===r;function n(r,o=" | "){return r.map(a=>typeof a=="string"?`'${a}'`:a).join(o)}s.joinValues=n,s.jsonStringifyReplacer=(r,o)=>typeof o=="bigint"?o.toString():o;})(F||(F={}));var Ns;(function(s){s.mergeShapes=(e,t)=>({...e,...t});})(Ns||(Ns={}));var _=F.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Fe=s=>{switch(typeof s){case "undefined":return _.undefined;case "string":return _.string;case "number":return Number.isNaN(s)?_.nan:_.number;case "boolean":return _.boolean;case "function":return _.function;case "bigint":return _.bigint;case "symbol":return _.symbol;case "object":return Array.isArray(s)?_.array:s===null?_.null:s.then&&typeof s.then=="function"&&s.catch&&typeof s.catch=="function"?_.promise:typeof Map<"u"&&s instanceof Map?_.map:typeof Set<"u"&&s instanceof Set?_.set:typeof Date<"u"&&s instanceof Date?_.date:_.object;default:return _.unknown}};var w=F.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),vi=s=>JSON.stringify(s,null,2).replace(/"([^"]+)":/g,"$1:"),we=class s extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n];},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n];};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e;}format(e){let t=e||function(o){return o.message},n={_errors:[]},r=o=>{for(let a of o.issues)if(a.code==="invalid_union")a.unionErrors.map(r);else if(a.code==="invalid_return_type")r(a.returnTypeError);else if(a.code==="invalid_arguments")r(a.argumentsError);else if(a.path.length===0)n._errors.push(t(a));else {let i=n,l=0;for(;l<a.path.length;){let c=a.path[l];l===a.path.length-1?(i[c]=i[c]||{_errors:[]},i[c]._errors.push(t(a))):i[c]=i[c]||{_errors:[]},i=i[c],l++;}}};return r(this),n}static assert(e){if(!(e instanceof s))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,F.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){let t={},n=[];for(let r of this.issues)if(r.path.length>0){let o=r.path[0];t[o]=t[o]||[],t[o].push(e(r));}else n.push(e(r));return {formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};we.create=s=>new we(s);var xi=(s,e)=>{let t;switch(s.code){case w.invalid_type:s.received===_.undefined?t="Required":t=`Expected ${s.expected}, received ${s.received}`;break;case w.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(s.expected,F.jsonStringifyReplacer)}`;break;case w.unrecognized_keys:t=`Unrecognized key(s) in object: ${F.joinValues(s.keys,", ")}`;break;case w.invalid_union:t="Invalid input";break;case w.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${F.joinValues(s.options)}`;break;case w.invalid_enum_value:t=`Invalid enum value. Expected ${F.joinValues(s.options)}, received '${s.received}'`;break;case w.invalid_arguments:t="Invalid function arguments";break;case w.invalid_return_type:t="Invalid function return type";break;case w.invalid_date:t="Invalid date";break;case w.invalid_string:typeof s.validation=="object"?"includes"in s.validation?(t=`Invalid input: must include "${s.validation.includes}"`,typeof s.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${s.validation.position}`)):"startsWith"in s.validation?t=`Invalid input: must start with "${s.validation.startsWith}"`:"endsWith"in s.validation?t=`Invalid input: must end with "${s.validation.endsWith}"`:F.assertNever(s.validation):s.validation!=="regex"?t=`Invalid ${s.validation}`:t="Invalid";break;case w.too_small:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at least":"more than"} ${s.minimum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at least":"over"} ${s.minimum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${s.minimum}`:s.type==="bigint"?t=`Number must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${s.minimum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(s.minimum))}`:t="Invalid input";break;case w.too_big:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at most":"less than"} ${s.maximum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at most":"under"} ${s.maximum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="bigint"?t=`BigInt must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly":s.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(s.maximum))}`:t="Invalid input";break;case w.custom:t="Invalid input";break;case w.invalid_intersection_types:t="Intersection results could not be merged";break;case w.not_multiple_of:t=`Number must be a multiple of ${s.multipleOf}`;break;case w.not_finite:t="Number must be finite";break;default:t=e.defaultError,F.assertNever(s);}return {message:t}},Be=xi;var An=Be;function bi(s){An=s;}function wt(){return An}var Nt=s=>{let{data:e,path:t,errorMaps:n,issueData:r}=s,o=[...t,...r.path||[]],a={...r,path:o};if(r.message!==void 0)return {...r,path:o,message:r.message};let i="",l=n.filter(c=>!!c).slice().reverse();for(let c of l)i=c(a,{data:e,defaultError:i}).message;return {...r,path:o,message:i}},wi=[];function $(s,e){let t=wt(),n=Nt({issueData:e,data:s.data,path:s.path,errorMaps:[s.common.contextualErrorMap,s.schemaErrorMap,t,t===Be?void 0:Be].filter(r=>!!r)});s.common.issues.push(n);}var pe=class s{constructor(){this.value="valid";}dirty(){this.value==="valid"&&(this.value="dirty");}abort(){this.value!=="aborted"&&(this.value="aborted");}static mergeArray(e,t){let n=[];for(let r of t){if(r.status==="aborted")return D;r.status==="dirty"&&e.dirty(),n.push(r.value);}return {status:e.value,value:n}}static async mergeObjectAsync(e,t){let n=[];for(let r of t){let o=await r.key,a=await r.value;n.push({key:o,value:a});}return s.mergeObjectSync(e,n)}static mergeObjectSync(e,t){let n={};for(let r of t){let{key:o,value:a}=r;if(o.status==="aborted"||a.status==="aborted")return D;o.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),o.value!=="__proto__"&&(typeof a.value<"u"||r.alwaysSet)&&(n[o.value]=a.value);}return {status:e.value,value:n}}},D=Object.freeze({status:"aborted"}),tt=s=>({status:"dirty",value:s}),ge=s=>({status:"valid",value:s}),ss=s=>s.status==="aborted",ns=s=>s.status==="dirty",Ge=s=>s.status==="valid",St=s=>typeof Promise<"u"&&s instanceof Promise;var E;(function(s){s.errToObj=e=>typeof e=="string"?{message:e}:e||{},s.toString=e=>typeof e=="string"?e:e?.message;})(E||(E={}));var Ae=class{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r;}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},Tn=(s,e)=>{if(Ge(e))return {success:true,data:e.value};if(!s.common.issues.length)throw new Error("Validation failed but no issues detected.");return {success:false,get error(){if(this._error)return this._error;let t=new we(s.common.issues);return this._error=t,this._error}}};function R(s){if(!s)return {};let{errorMap:e,invalid_type_error:t,required_error:n,description:r}=s;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:r}:{errorMap:(a,i)=>{let{message:l}=s;return a.code==="invalid_enum_value"?{message:l??i.defaultError}:typeof i.data>"u"?{message:l??n??i.defaultError}:a.code!=="invalid_type"?{message:i.defaultError}:{message:l??t??i.defaultError}},description:r}}var O=class{get description(){return this._def.description}_getType(e){return Fe(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Fe(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return {status:new pe,ctx:{common:e.parent.common,data:e.data,parsedType:Fe(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(St(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??false,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Fe(e)},r=this._parseSync({data:e,path:n.path,parent:n});return Tn(n,r)}"~validate"(e){let t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Fe(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:t});return Ge(n)?{value:n.value}:{issues:t.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=true),t.common={issues:[],async:true};}return this._parseAsync({data:e,path:[],parent:t}).then(n=>Ge(n)?{value:n.value}:{issues:t.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:true},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Fe(e)},r=this._parse({data:e,path:n.path,parent:n}),o=await(St(r)?r:Promise.resolve(r));return Tn(n,o)}refine(e,t){let n=r=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(r):t;return this._refinement((r,o)=>{let a=e(r),i=()=>o.addIssue({code:w.custom,...n(r)});return typeof Promise<"u"&&a instanceof Promise?a.then(l=>l?true:(i(),false)):a?true:(i(),false)})}refinement(e,t){return this._refinement((n,r)=>e(n)?true:(r.addIssue(typeof t=="function"?t(n,r):t),false))}_refinement(e){return new Te({schema:this,typeName:P.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)};}optional(){return Ee.create(this,this._def)}nullable(){return Me.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ue.create(this)}promise(){return Ke.create(this,this._def)}or(e){return ct.create([this,e],this._def)}and(e){return lt.create(this,e,this._def)}transform(e){return new Te({...R(this._def),schema:this,typeName:P.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e=="function"?e:()=>e;return new mt({...R(this._def),innerType:this,defaultValue:t,typeName:P.ZodDefault})}brand(){return new Ft({typeName:P.ZodBranded,type:this,...R(this._def)})}catch(e){let t=typeof e=="function"?e:()=>e;return new gt({...R(this._def),innerType:this,catchValue:t,typeName:P.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Lt.create(this,e)}readonly(){return ht.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Si=/^c[^\s-]{8,}$/i,Ci=/^[0-9a-z]+$/,ki=/^[0-9A-HJKMNP-TV-Z]{26}$/i,$i=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,_i=/^[a-z0-9_-]{21}$/i,Ei=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Ai=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Ti=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Di="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Fs,Ii=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Pi=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Ri=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,ji=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Oi=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Ni=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,In="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Fi=new RegExp(`^${In}$`);function Pn(s){let e="[0-5]\\d";s.precision?e=`${e}\\.\\d{${s.precision}}`:s.precision==null&&(e=`${e}(\\.\\d+)?`);let t=s.precision?"+":"?";return `([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function Li(s){return new RegExp(`^${Pn(s)}$`)}function Rn(s){let e=`${In}T${Pn(s)}`,t=[];return t.push(s.local?"Z?":"Z"),s.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Mi(s,e){return !!((e==="v4"||!e)&&Ii.test(s)||(e==="v6"||!e)&&Ri.test(s))}function zi(s,e){if(!Ei.test(s))return false;try{let[t]=s.split(".");if(!t)return !1;let n=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),r=JSON.parse(atob(n));return !(typeof r!="object"||r===null||"typ"in r&&r?.typ!=="JWT"||!r.alg||e&&r.alg!==e)}catch{return false}}function Bi(s,e){return !!((e==="v4"||!e)&&Pi.test(s)||(e==="v6"||!e)&&ji.test(s))}var Ze=class s extends O{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==_.string){let o=this._getOrReturnCtx(e);return $(o,{code:w.invalid_type,expected:_.string,received:o.parsedType}),D}let n=new pe,r;for(let o of this._def.checks)if(o.kind==="min")e.data.length<o.value&&(r=this._getOrReturnCtx(e,r),$(r,{code:w.too_small,minimum:o.value,type:"string",inclusive:true,exact:false,message:o.message}),n.dirty());else if(o.kind==="max")e.data.length>o.value&&(r=this._getOrReturnCtx(e,r),$(r,{code:w.too_big,maximum:o.value,type:"string",inclusive:true,exact:false,message:o.message}),n.dirty());else if(o.kind==="length"){let a=e.data.length>o.value,i=e.data.length<o.value;(a||i)&&(r=this._getOrReturnCtx(e,r),a?$(r,{code:w.too_big,maximum:o.value,type:"string",inclusive:true,exact:true,message:o.message}):i&&$(r,{code:w.too_small,minimum:o.value,type:"string",inclusive:true,exact:true,message:o.message}),n.dirty());}else if(o.kind==="email")Ti.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"email",code:w.invalid_string,message:o.message}),n.dirty());else if(o.kind==="emoji")Fs||(Fs=new RegExp(Di,"u")),Fs.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"emoji",code:w.invalid_string,message:o.message}),n.dirty());else if(o.kind==="uuid")$i.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"uuid",code:w.invalid_string,message:o.message}),n.dirty());else if(o.kind==="nanoid")_i.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"nanoid",code:w.invalid_string,message:o.message}),n.dirty());else if(o.kind==="cuid")Si.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"cuid",code:w.invalid_string,message:o.message}),n.dirty());else if(o.kind==="cuid2")Ci.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"cuid2",code:w.invalid_string,message:o.message}),n.dirty());else if(o.kind==="ulid")ki.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"ulid",code:w.invalid_string,message:o.message}),n.dirty());else if(o.kind==="url")try{new URL(e.data);}catch{r=this._getOrReturnCtx(e,r),$(r,{validation:"url",code:w.invalid_string,message:o.message}),n.dirty();}else o.kind==="regex"?(o.regex.lastIndex=0,o.regex.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"regex",code:w.invalid_string,message:o.message}),n.dirty())):o.kind==="trim"?e.data=e.data.trim():o.kind==="includes"?e.data.includes(o.value,o.position)||(r=this._getOrReturnCtx(e,r),$(r,{code:w.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),n.dirty()):o.kind==="toLowerCase"?e.data=e.data.toLowerCase():o.kind==="toUpperCase"?e.data=e.data.toUpperCase():o.kind==="startsWith"?e.data.startsWith(o.value)||(r=this._getOrReturnCtx(e,r),$(r,{code:w.invalid_string,validation:{startsWith:o.value},message:o.message}),n.dirty()):o.kind==="endsWith"?e.data.endsWith(o.value)||(r=this._getOrReturnCtx(e,r),$(r,{code:w.invalid_string,validation:{endsWith:o.value},message:o.message}),n.dirty()):o.kind==="datetime"?Rn(o).test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{code:w.invalid_string,validation:"datetime",message:o.message}),n.dirty()):o.kind==="date"?Fi.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{code:w.invalid_string,validation:"date",message:o.message}),n.dirty()):o.kind==="time"?Li(o).test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{code:w.invalid_string,validation:"time",message:o.message}),n.dirty()):o.kind==="duration"?Ai.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"duration",code:w.invalid_string,message:o.message}),n.dirty()):o.kind==="ip"?Mi(e.data,o.version)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"ip",code:w.invalid_string,message:o.message}),n.dirty()):o.kind==="jwt"?zi(e.data,o.alg)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"jwt",code:w.invalid_string,message:o.message}),n.dirty()):o.kind==="cidr"?Bi(e.data,o.version)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"cidr",code:w.invalid_string,message:o.message}),n.dirty()):o.kind==="base64"?Oi.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"base64",code:w.invalid_string,message:o.message}),n.dirty()):o.kind==="base64url"?Ni.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"base64url",code:w.invalid_string,message:o.message}),n.dirty()):F.assertNever(o);return {status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(r=>e.test(r),{validation:t,code:w.invalid_string,...E.errToObj(n)})}_addCheck(e){return new s({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...E.errToObj(e)})}url(e){return this._addCheck({kind:"url",...E.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...E.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...E.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...E.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...E.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...E.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...E.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...E.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...E.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...E.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...E.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...E.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:false,local:false,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??false,local:e?.local??false,...E.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...E.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...E.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...E.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...E.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...E.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...E.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...E.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...E.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...E.errToObj(t)})}nonempty(e){return this.min(1,E.errToObj(e))}trim(){return new s({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new s({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new s({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return !!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return !!this._def.checks.find(e=>e.kind==="date")}get isTime(){return !!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return !!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return !!this._def.checks.find(e=>e.kind==="email")}get isURL(){return !!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return !!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return !!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return !!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return !!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return !!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return !!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return !!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return !!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return !!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return !!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};Ze.create=s=>new Ze({checks:[],typeName:P.ZodString,coerce:s?.coerce??false,...R(s)});function Hi(s,e){let t=(s.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,r=t>n?t:n,o=Number.parseInt(s.toFixed(r).replace(".","")),a=Number.parseInt(e.toFixed(r).replace(".",""));return o%a/10**r}var st=class s extends O{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf;}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==_.number){let o=this._getOrReturnCtx(e);return $(o,{code:w.invalid_type,expected:_.number,received:o.parsedType}),D}let n,r=new pe;for(let o of this._def.checks)o.kind==="int"?F.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),$(n,{code:w.invalid_type,expected:"integer",received:"float",message:o.message}),r.dirty()):o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(n=this._getOrReturnCtx(e,n),$(n,{code:w.too_small,minimum:o.value,type:"number",inclusive:o.inclusive,exact:false,message:o.message}),r.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(n=this._getOrReturnCtx(e,n),$(n,{code:w.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:false,message:o.message}),r.dirty()):o.kind==="multipleOf"?Hi(e.data,o.value)!==0&&(n=this._getOrReturnCtx(e,n),$(n,{code:w.not_multiple_of,multipleOf:o.value,message:o.message}),r.dirty()):o.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),$(n,{code:w.not_finite,message:o.message}),r.dirty()):F.assertNever(o);return {status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,true,E.toString(t))}gt(e,t){return this.setLimit("min",e,false,E.toString(t))}lte(e,t){return this.setLimit("max",e,true,E.toString(t))}lt(e,t){return this.setLimit("max",e,false,E.toString(t))}setLimit(e,t,n,r){return new s({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:E.toString(r)}]})}_addCheck(e){return new s({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:E.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:false,message:E.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:false,message:E.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:true,message:E.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:true,message:E.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:E.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:E.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:true,value:Number.MIN_SAFE_INTEGER,message:E.toString(e)})._addCheck({kind:"max",inclusive:true,value:Number.MAX_SAFE_INTEGER,message:E.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return !!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&F.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return true;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);}return Number.isFinite(t)&&Number.isFinite(e)}};st.create=s=>new st({checks:[],typeName:P.ZodNumber,coerce:s?.coerce||false,...R(s)});var nt=class s extends O{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte;}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data);}catch{return this._getInvalidInput(e)}if(this._getType(e)!==_.bigint)return this._getInvalidInput(e);let n,r=new pe;for(let o of this._def.checks)o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(n=this._getOrReturnCtx(e,n),$(n,{code:w.too_small,type:"bigint",minimum:o.value,inclusive:o.inclusive,message:o.message}),r.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(n=this._getOrReturnCtx(e,n),$(n,{code:w.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),r.dirty()):o.kind==="multipleOf"?e.data%o.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),$(n,{code:w.not_multiple_of,multipleOf:o.value,message:o.message}),r.dirty()):F.assertNever(o);return {status:r.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return $(t,{code:w.invalid_type,expected:_.bigint,received:t.parsedType}),D}gte(e,t){return this.setLimit("min",e,true,E.toString(t))}gt(e,t){return this.setLimit("min",e,false,E.toString(t))}lte(e,t){return this.setLimit("max",e,true,E.toString(t))}lt(e,t){return this.setLimit("max",e,false,E.toString(t))}setLimit(e,t,n,r){return new s({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:E.toString(r)}]})}_addCheck(e){return new s({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:false,message:E.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:false,message:E.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:true,message:E.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:true,message:E.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:E.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};nt.create=s=>new nt({checks:[],typeName:P.ZodBigInt,coerce:s?.coerce??false,...R(s)});var rt=class extends O{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==_.boolean){let n=this._getOrReturnCtx(e);return $(n,{code:w.invalid_type,expected:_.boolean,received:n.parsedType}),D}return ge(e.data)}};rt.create=s=>new rt({typeName:P.ZodBoolean,coerce:s?.coerce||false,...R(s)});var ot=class s extends O{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==_.date){let o=this._getOrReturnCtx(e);return $(o,{code:w.invalid_type,expected:_.date,received:o.parsedType}),D}if(Number.isNaN(e.data.getTime())){let o=this._getOrReturnCtx(e);return $(o,{code:w.invalid_date}),D}let n=new pe,r;for(let o of this._def.checks)o.kind==="min"?e.data.getTime()<o.value&&(r=this._getOrReturnCtx(e,r),$(r,{code:w.too_small,message:o.message,inclusive:true,exact:false,minimum:o.value,type:"date"}),n.dirty()):o.kind==="max"?e.data.getTime()>o.value&&(r=this._getOrReturnCtx(e,r),$(r,{code:w.too_big,message:o.message,inclusive:true,exact:false,maximum:o.value,type:"date"}),n.dirty()):F.assertNever(o);return {status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new s({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:E.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:E.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}};ot.create=s=>new ot({checks:[],coerce:s?.coerce||false,typeName:P.ZodDate,...R(s)});var kt=class extends O{_parse(e){if(this._getType(e)!==_.symbol){let n=this._getOrReturnCtx(e);return $(n,{code:w.invalid_type,expected:_.symbol,received:n.parsedType}),D}return ge(e.data)}};kt.create=s=>new kt({typeName:P.ZodSymbol,...R(s)});var it=class extends O{_parse(e){if(this._getType(e)!==_.undefined){let n=this._getOrReturnCtx(e);return $(n,{code:w.invalid_type,expected:_.undefined,received:n.parsedType}),D}return ge(e.data)}};it.create=s=>new it({typeName:P.ZodUndefined,...R(s)});var at=class extends O{_parse(e){if(this._getType(e)!==_.null){let n=this._getOrReturnCtx(e);return $(n,{code:w.invalid_type,expected:_.null,received:n.parsedType}),D}return ge(e.data)}};at.create=s=>new at({typeName:P.ZodNull,...R(s)});var qe=class extends O{constructor(){super(...arguments),this._any=true;}_parse(e){return ge(e.data)}};qe.create=s=>new qe({typeName:P.ZodAny,...R(s)});var We=class extends O{constructor(){super(...arguments),this._unknown=true;}_parse(e){return ge(e.data)}};We.create=s=>new We({typeName:P.ZodUnknown,...R(s)});var je=class extends O{_parse(e){let t=this._getOrReturnCtx(e);return $(t,{code:w.invalid_type,expected:_.never,received:t.parsedType}),D}};je.create=s=>new je({typeName:P.ZodNever,...R(s)});var $t=class extends O{_parse(e){if(this._getType(e)!==_.undefined){let n=this._getOrReturnCtx(e);return $(n,{code:w.invalid_type,expected:_.void,received:n.parsedType}),D}return ge(e.data)}};$t.create=s=>new $t({typeName:P.ZodVoid,...R(s)});var Ue=class s extends O{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==_.array)return $(t,{code:w.invalid_type,expected:_.array,received:t.parsedType}),D;if(r.exactLength!==null){let a=t.data.length>r.exactLength.value,i=t.data.length<r.exactLength.value;(a||i)&&($(t,{code:a?w.too_big:w.too_small,minimum:i?r.exactLength.value:void 0,maximum:a?r.exactLength.value:void 0,type:"array",inclusive:true,exact:true,message:r.exactLength.message}),n.dirty());}if(r.minLength!==null&&t.data.length<r.minLength.value&&($(t,{code:w.too_small,minimum:r.minLength.value,type:"array",inclusive:true,exact:false,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&($(t,{code:w.too_big,maximum:r.maxLength.value,type:"array",inclusive:true,exact:false,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((a,i)=>r.type._parseAsync(new Ae(t,a,t.path,i)))).then(a=>pe.mergeArray(n,a));let o=[...t.data].map((a,i)=>r.type._parseSync(new Ae(t,a,t.path,i)));return pe.mergeArray(n,o)}get element(){return this._def.type}min(e,t){return new s({...this._def,minLength:{value:e,message:E.toString(t)}})}max(e,t){return new s({...this._def,maxLength:{value:e,message:E.toString(t)}})}length(e,t){return new s({...this._def,exactLength:{value:e,message:E.toString(t)}})}nonempty(e){return this.min(1,e)}};Ue.create=(s,e)=>new Ue({type:s,minLength:null,maxLength:null,exactLength:null,typeName:P.ZodArray,...R(e)});function Ct(s){if(s instanceof Se){let e={};for(let t in s.shape){let n=s.shape[t];e[t]=Ee.create(Ct(n));}return new Se({...s._def,shape:()=>e})}else return s instanceof Ue?new Ue({...s._def,type:Ct(s.element)}):s instanceof Ee?Ee.create(Ct(s.unwrap())):s instanceof Me?Me.create(Ct(s.unwrap())):s instanceof Le?Le.create(s.items.map(e=>Ct(e))):s}var Se=class s extends O{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend;}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=F.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==_.object){let c=this._getOrReturnCtx(e);return $(c,{code:w.invalid_type,expected:_.object,received:c.parsedType}),D}let{status:n,ctx:r}=this._processInputParams(e),{shape:o,keys:a}=this._getCached(),i=[];if(!(this._def.catchall instanceof je&&this._def.unknownKeys==="strip"))for(let c in r.data)a.includes(c)||i.push(c);let l=[];for(let c of a){let d=o[c],u=r.data[c];l.push({key:{status:"valid",value:c},value:d._parse(new Ae(r,u,r.path,c)),alwaysSet:c in r.data});}if(this._def.catchall instanceof je){let c=this._def.unknownKeys;if(c==="passthrough")for(let d of i)l.push({key:{status:"valid",value:d},value:{status:"valid",value:r.data[d]}});else if(c==="strict")i.length>0&&($(r,{code:w.unrecognized_keys,keys:i}),n.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else {let c=this._def.catchall;for(let d of i){let u=r.data[d];l.push({key:{status:"valid",value:d},value:c._parse(new Ae(r,u,r.path,d)),alwaysSet:d in r.data});}}return r.common.async?Promise.resolve().then(async()=>{let c=[];for(let d of l){let u=await d.key,h=await d.value;c.push({key:u,value:h,alwaysSet:d.alwaysSet});}return c}).then(c=>pe.mergeObjectSync(n,c)):pe.mergeObjectSync(n,l)}get shape(){return this._def.shape()}strict(e){return E.errToObj,new s({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{let r=this._def.errorMap?.(t,n).message??n.defaultError;return t.code==="unrecognized_keys"?{message:E.errToObj(e).message??r}:{message:r}}}:{}})}strip(){return new s({...this._def,unknownKeys:"strip"})}passthrough(){return new s({...this._def,unknownKeys:"passthrough"})}extend(e){return new s({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new s({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:P.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new s({...this._def,catchall:e})}pick(e){let t={};for(let n of F.objectKeys(e))e[n]&&this.shape[n]&&(t[n]=this.shape[n]);return new s({...this._def,shape:()=>t})}omit(e){let t={};for(let n of F.objectKeys(this.shape))e[n]||(t[n]=this.shape[n]);return new s({...this._def,shape:()=>t})}deepPartial(){return Ct(this)}partial(e){let t={};for(let n of F.objectKeys(this.shape)){let r=this.shape[n];e&&!e[n]?t[n]=r:t[n]=r.optional();}return new s({...this._def,shape:()=>t})}required(e){let t={};for(let n of F.objectKeys(this.shape))if(e&&!e[n])t[n]=this.shape[n];else {let o=this.shape[n];for(;o instanceof Ee;)o=o._def.innerType;t[n]=o;}return new s({...this._def,shape:()=>t})}keyof(){return jn(F.objectKeys(this.shape))}};Se.create=(s,e)=>new Se({shape:()=>s,unknownKeys:"strip",catchall:je.create(),typeName:P.ZodObject,...R(e)});Se.strictCreate=(s,e)=>new Se({shape:()=>s,unknownKeys:"strict",catchall:je.create(),typeName:P.ZodObject,...R(e)});Se.lazycreate=(s,e)=>new Se({shape:s,unknownKeys:"strip",catchall:je.create(),typeName:P.ZodObject,...R(e)});var ct=class extends O{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function r(o){for(let i of o)if(i.result.status==="valid")return i.result;for(let i of o)if(i.result.status==="dirty")return t.common.issues.push(...i.ctx.common.issues),i.result;let a=o.map(i=>new we(i.ctx.common.issues));return $(t,{code:w.invalid_union,unionErrors:a}),D}if(t.common.async)return Promise.all(n.map(async o=>{let a={...t,common:{...t.common,issues:[]},parent:null};return {result:await o._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(r);{let o,a=[];for(let l of n){let c={...t,common:{...t.common,issues:[]},parent:null},d=l._parseSync({data:t.data,path:t.path,parent:c});if(d.status==="valid")return d;d.status==="dirty"&&!o&&(o={result:d,ctx:c}),c.common.issues.length&&a.push(c.common.issues);}if(o)return t.common.issues.push(...o.ctx.common.issues),o.result;let i=a.map(l=>new we(l));return $(t,{code:w.invalid_union,unionErrors:i}),D}}get options(){return this._def.options}};ct.create=(s,e)=>new ct({options:s,typeName:P.ZodUnion,...R(e)});var He=s=>s instanceof dt?He(s.schema):s instanceof Te?He(s.innerType()):s instanceof ut?[s.value]:s instanceof pt?s.options:s instanceof ft?F.objectValues(s.enum):s instanceof mt?He(s._def.innerType):s instanceof it?[void 0]:s instanceof at?[null]:s instanceof Ee?[void 0,...He(s.unwrap())]:s instanceof Me?[null,...He(s.unwrap())]:s instanceof Ft||s instanceof ht?He(s.unwrap()):s instanceof gt?He(s._def.innerType):[],rs=class s extends O{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==_.object)return $(t,{code:w.invalid_type,expected:_.object,received:t.parsedType}),D;let n=this.discriminator,r=t.data[n],o=this.optionsMap.get(r);return o?t.common.async?o._parseAsync({data:t.data,path:t.path,parent:t}):o._parseSync({data:t.data,path:t.path,parent:t}):($(t,{code:w.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),D)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){let r=new Map;for(let o of t){let a=He(o.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let i of a){if(r.has(i))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(i)}`);r.set(i,o);}}return new s({typeName:P.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:r,...R(n)})}};function Ls(s,e){let t=Fe(s),n=Fe(e);if(s===e)return {valid:true,data:s};if(t===_.object&&n===_.object){let r=F.objectKeys(e),o=F.objectKeys(s).filter(i=>r.indexOf(i)!==-1),a={...s,...e};for(let i of o){let l=Ls(s[i],e[i]);if(!l.valid)return {valid:false};a[i]=l.data;}return {valid:true,data:a}}else if(t===_.array&&n===_.array){if(s.length!==e.length)return {valid:false};let r=[];for(let o=0;o<s.length;o++){let a=s[o],i=e[o],l=Ls(a,i);if(!l.valid)return {valid:false};r.push(l.data);}return {valid:true,data:r}}else return t===_.date&&n===_.date&&+s==+e?{valid:true,data:s}:{valid:false}}var lt=class extends O{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(o,a)=>{if(ss(o)||ss(a))return D;let i=Ls(o.value,a.value);return i.valid?((ns(o)||ns(a))&&t.dirty(),{status:t.value,value:i.data}):($(n,{code:w.invalid_intersection_types}),D)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([o,a])=>r(o,a)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};lt.create=(s,e,t)=>new lt({left:s,right:e,typeName:P.ZodIntersection,...R(t)});var Le=class s extends O{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==_.array)return $(n,{code:w.invalid_type,expected:_.array,received:n.parsedType}),D;if(n.data.length<this._def.items.length)return $(n,{code:w.too_small,minimum:this._def.items.length,inclusive:true,exact:false,type:"array"}),D;!this._def.rest&&n.data.length>this._def.items.length&&($(n,{code:w.too_big,maximum:this._def.items.length,inclusive:true,exact:false,type:"array"}),t.dirty());let o=[...n.data].map((a,i)=>{let l=this._def.items[i]||this._def.rest;return l?l._parse(new Ae(n,a,n.path,i)):null}).filter(a=>!!a);return n.common.async?Promise.all(o).then(a=>pe.mergeArray(t,a)):pe.mergeArray(t,o)}get items(){return this._def.items}rest(e){return new s({...this._def,rest:e})}};Le.create=(s,e)=>{if(!Array.isArray(s))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Le({items:s,typeName:P.ZodTuple,rest:null,...R(e)})};var os=class s extends O{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==_.object)return $(n,{code:w.invalid_type,expected:_.object,received:n.parsedType}),D;let r=[],o=this._def.keyType,a=this._def.valueType;for(let i in n.data)r.push({key:o._parse(new Ae(n,i,n.path,i)),value:a._parse(new Ae(n,n.data[i],n.path,i)),alwaysSet:i in n.data});return n.common.async?pe.mergeObjectAsync(t,r):pe.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof O?new s({keyType:e,valueType:t,typeName:P.ZodRecord,...R(n)}):new s({keyType:Ze.create(),valueType:e,typeName:P.ZodRecord,...R(t)})}},_t=class extends O{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==_.map)return $(n,{code:w.invalid_type,expected:_.map,received:n.parsedType}),D;let r=this._def.keyType,o=this._def.valueType,a=[...n.data.entries()].map(([i,l],c)=>({key:r._parse(new Ae(n,i,n.path,[c,"key"])),value:o._parse(new Ae(n,l,n.path,[c,"value"]))}));if(n.common.async){let i=new Map;return Promise.resolve().then(async()=>{for(let l of a){let c=await l.key,d=await l.value;if(c.status==="aborted"||d.status==="aborted")return D;(c.status==="dirty"||d.status==="dirty")&&t.dirty(),i.set(c.value,d.value);}return {status:t.value,value:i}})}else {let i=new Map;for(let l of a){let c=l.key,d=l.value;if(c.status==="aborted"||d.status==="aborted")return D;(c.status==="dirty"||d.status==="dirty")&&t.dirty(),i.set(c.value,d.value);}return {status:t.value,value:i}}}};_t.create=(s,e,t)=>new _t({valueType:e,keyType:s,typeName:P.ZodMap,...R(t)});var Et=class s extends O{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==_.set)return $(n,{code:w.invalid_type,expected:_.set,received:n.parsedType}),D;let r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&($(n,{code:w.too_small,minimum:r.minSize.value,type:"set",inclusive:true,exact:false,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&($(n,{code:w.too_big,maximum:r.maxSize.value,type:"set",inclusive:true,exact:false,message:r.maxSize.message}),t.dirty());let o=this._def.valueType;function a(l){let c=new Set;for(let d of l){if(d.status==="aborted")return D;d.status==="dirty"&&t.dirty(),c.add(d.value);}return {status:t.value,value:c}}let i=[...n.data.values()].map((l,c)=>o._parse(new Ae(n,l,n.path,c)));return n.common.async?Promise.all(i).then(l=>a(l)):a(i)}min(e,t){return new s({...this._def,minSize:{value:e,message:E.toString(t)}})}max(e,t){return new s({...this._def,maxSize:{value:e,message:E.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Et.create=(s,e)=>new Et({valueType:s,minSize:null,maxSize:null,typeName:P.ZodSet,...R(e)});var is=class s extends O{constructor(){super(...arguments),this.validate=this.implement;}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==_.function)return $(t,{code:w.invalid_type,expected:_.function,received:t.parsedType}),D;function n(i,l){return Nt({data:i,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,wt(),Be].filter(c=>!!c),issueData:{code:w.invalid_arguments,argumentsError:l}})}function r(i,l){return Nt({data:i,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,wt(),Be].filter(c=>!!c),issueData:{code:w.invalid_return_type,returnTypeError:l}})}let o={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof Ke){let i=this;return ge(async function(...l){let c=new we([]),d=await i._def.args.parseAsync(l,o).catch(g=>{throw c.addIssue(n(l,g)),c}),u=await Reflect.apply(a,this,d);return await i._def.returns._def.type.parseAsync(u,o).catch(g=>{throw c.addIssue(r(u,g)),c})})}else {let i=this;return ge(function(...l){let c=i._def.args.safeParse(l,o);if(!c.success)throw new we([n(l,c.error)]);let d=Reflect.apply(a,this,c.data),u=i._def.returns.safeParse(d,o);if(!u.success)throw new we([r(d,u.error)]);return u.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new s({...this._def,args:Le.create(e).rest(We.create())})}returns(e){return new s({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new s({args:e||Le.create([]).rest(We.create()),returns:t||We.create(),typeName:P.ZodFunction,...R(n)})}},dt=class extends O{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};dt.create=(s,e)=>new dt({getter:s,typeName:P.ZodLazy,...R(e)});var ut=class extends O{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return $(t,{received:t.data,code:w.invalid_literal,expected:this._def.value}),D}return {status:"valid",value:e.data}}get value(){return this._def.value}};ut.create=(s,e)=>new ut({value:s,typeName:P.ZodLiteral,...R(e)});function jn(s,e){return new pt({values:s,typeName:P.ZodEnum,...R(e)})}var pt=class s extends O{_parse(e){if(typeof e.data!="string"){let t=this._getOrReturnCtx(e),n=this._def.values;return $(t,{expected:F.joinValues(n),received:t.parsedType,code:w.invalid_type}),D}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return $(t,{received:t.data,code:w.invalid_enum_value,options:n}),D}return ge(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return s.create(e,{...this._def,...t})}exclude(e,t=this._def){return s.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}};pt.create=jn;var ft=class extends O{_parse(e){let t=F.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==_.string&&n.parsedType!==_.number){let r=F.objectValues(t);return $(n,{expected:F.joinValues(r),received:n.parsedType,code:w.invalid_type}),D}if(this._cache||(this._cache=new Set(F.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let r=F.objectValues(t);return $(n,{received:n.data,code:w.invalid_enum_value,options:r}),D}return ge(e.data)}get enum(){return this._def.values}};ft.create=(s,e)=>new ft({values:s,typeName:P.ZodNativeEnum,...R(e)});var Ke=class extends O{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==_.promise&&t.common.async===false)return $(t,{code:w.invalid_type,expected:_.promise,received:t.parsedType}),D;let n=t.parsedType===_.promise?t.data:Promise.resolve(t.data);return ge(n.then(r=>this._def.type.parseAsync(r,{path:t.path,errorMap:t.common.contextualErrorMap})))}};Ke.create=(s,e)=>new Ke({type:s,typeName:P.ZodPromise,...R(e)});var Te=class extends O{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===P.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,o={addIssue:a=>{$(n,a),a.fatal?t.abort():t.dirty();},get path(){return n.path}};if(o.addIssue=o.addIssue.bind(o),r.type==="preprocess"){let a=r.transform(n.data,o);if(n.common.async)return Promise.resolve(a).then(async i=>{if(t.value==="aborted")return D;let l=await this._def.schema._parseAsync({data:i,path:n.path,parent:n});return l.status==="aborted"?D:l.status==="dirty"?tt(l.value):t.value==="dirty"?tt(l.value):l});{if(t.value==="aborted")return D;let i=this._def.schema._parseSync({data:a,path:n.path,parent:n});return i.status==="aborted"?D:i.status==="dirty"?tt(i.value):t.value==="dirty"?tt(i.value):i}}if(r.type==="refinement"){let a=i=>{let l=r.refinement(i,o);if(n.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return i};if(n.common.async===false){let i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?D:(i.status==="dirty"&&t.dirty(),a(i.value),{status:t.value,value:i.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>i.status==="aborted"?D:(i.status==="dirty"&&t.dirty(),a(i.value).then(()=>({status:t.value,value:i.value}))))}if(r.type==="transform")if(n.common.async===false){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Ge(a))return D;let i=r.transform(a.value,o);if(i instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return {status:t.value,value:i}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>Ge(a)?Promise.resolve(r.transform(a.value,o)).then(i=>({status:t.value,value:i})):D);F.assertNever(r);}};Te.create=(s,e,t)=>new Te({schema:s,typeName:P.ZodEffects,effect:e,...R(t)});Te.createWithPreprocess=(s,e,t)=>new Te({schema:e,effect:{type:"preprocess",transform:s},typeName:P.ZodEffects,...R(t)});var Ee=class extends O{_parse(e){return this._getType(e)===_.undefined?ge(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Ee.create=(s,e)=>new Ee({innerType:s,typeName:P.ZodOptional,...R(e)});var Me=class extends O{_parse(e){return this._getType(e)===_.null?ge(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Me.create=(s,e)=>new Me({innerType:s,typeName:P.ZodNullable,...R(e)});var mt=class extends O{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===_.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};mt.create=(s,e)=>new mt({innerType:s,typeName:P.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...R(e)});var gt=class extends O{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return St(r)?r.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new we(n.common.issues)},input:n.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new we(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};gt.create=(s,e)=>new gt({innerType:s,typeName:P.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...R(e)});var At=class extends O{_parse(e){if(this._getType(e)!==_.nan){let n=this._getOrReturnCtx(e);return $(n,{code:w.invalid_type,expected:_.nan,received:n.parsedType}),D}return {status:"valid",value:e.data}}};At.create=s=>new At({typeName:P.ZodNaN,...R(s)});var Wi=Symbol("zod_brand"),Ft=class extends O{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},Lt=class s extends O{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return (async()=>{let o=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?D:o.status==="dirty"?(t.dirty(),tt(o.value)):this._def.out._parseAsync({data:o.value,path:n.path,parent:n})})();{let r=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return r.status==="aborted"?D:r.status==="dirty"?(t.dirty(),{status:"dirty",value:r.value}):this._def.out._parseSync({data:r.value,path:n.path,parent:n})}}static create(e,t){return new s({in:e,out:t,typeName:P.ZodPipeline})}},ht=class extends O{_parse(e){let t=this._def.innerType._parse(e),n=r=>(Ge(r)&&(r.value=Object.freeze(r.value)),r);return St(t)?t.then(r=>n(r)):n(t)}unwrap(){return this._def.innerType}};ht.create=(s,e)=>new ht({innerType:s,typeName:P.ZodReadonly,...R(e)});function Dn(s,e){let t=typeof s=="function"?s(e):typeof s=="string"?{message:s}:s;return typeof t=="string"?{message:t}:t}function On(s,e={},t){return s?qe.create().superRefine((n,r)=>{let o=s(n);if(o instanceof Promise)return o.then(a=>{if(!a){let i=Dn(e,n),l=i.fatal??t??true;r.addIssue({code:"custom",...i,fatal:l});}});if(!o){let a=Dn(e,n),i=a.fatal??t??true;r.addIssue({code:"custom",...a,fatal:i});}}):qe.create()}var Ui={object:Se.lazycreate},P;(function(s){s.ZodString="ZodString",s.ZodNumber="ZodNumber",s.ZodNaN="ZodNaN",s.ZodBigInt="ZodBigInt",s.ZodBoolean="ZodBoolean",s.ZodDate="ZodDate",s.ZodSymbol="ZodSymbol",s.ZodUndefined="ZodUndefined",s.ZodNull="ZodNull",s.ZodAny="ZodAny",s.ZodUnknown="ZodUnknown",s.ZodNever="ZodNever",s.ZodVoid="ZodVoid",s.ZodArray="ZodArray",s.ZodObject="ZodObject",s.ZodUnion="ZodUnion",s.ZodDiscriminatedUnion="ZodDiscriminatedUnion",s.ZodIntersection="ZodIntersection",s.ZodTuple="ZodTuple",s.ZodRecord="ZodRecord",s.ZodMap="ZodMap",s.ZodSet="ZodSet",s.ZodFunction="ZodFunction",s.ZodLazy="ZodLazy",s.ZodLiteral="ZodLiteral",s.ZodEnum="ZodEnum",s.ZodEffects="ZodEffects",s.ZodNativeEnum="ZodNativeEnum",s.ZodOptional="ZodOptional",s.ZodNullable="ZodNullable",s.ZodDefault="ZodDefault",s.ZodCatch="ZodCatch",s.ZodPromise="ZodPromise",s.ZodBranded="ZodBranded",s.ZodPipeline="ZodPipeline",s.ZodReadonly="ZodReadonly";})(P||(P={}));var Vi=(s,e={message:`Input not instance of ${s.name}`})=>On(t=>t instanceof s,e),Nn=Ze.create,Fn=st.create,Gi=At.create,Zi=nt.create,Ln=rt.create,qi=ot.create,Ki=kt.create,Ji=it.create,Yi=at.create,Xi=qe.create,Qi=We.create,ea=je.create,ta=$t.create,sa=Ue.create,na=Se.create,ra=Se.strictCreate,oa=ct.create,ia=rs.create,aa=lt.create,ca=Le.create,la=os.create,da=_t.create,ua=Et.create,pa=is.create,fa=dt.create,ma=ut.create,ga=pt.create,ha=ft.create,ya=Ke.create,va=Te.create,xa=Ee.create,ba=Me.create,wa=Te.createWithPreprocess,Sa=Lt.create,Ca=()=>Nn().optional(),ka=()=>Fn().optional(),$a=()=>Ln().optional(),_a={string:(s=>Ze.create({...s,coerce:true})),number:(s=>st.create({...s,coerce:true})),boolean:(s=>rt.create({...s,coerce:true})),bigint:(s=>nt.create({...s,coerce:true})),date:(s=>ot.create({...s,coerce:true}))};var Ea=D;var Aa=p.enum(["component","hook","service","utility","feature","route","module","config","asset","test","unknown"]),Ta=p.enum(["imports","calls","extends","implements","uses"]),Da=p.object({complexity:p.number().nullable().default(null),linesOfCode:p.number().default(0),dependencyCount:p.number().default(0),dependentCount:p.number().default(0),exportCount:p.number().default(0),importCount:p.number().default(0)}),Ia=p.object({id:p.string(),path:p.string(),absolutePath:p.string().optional(),name:p.string(),type:Aa,language:p.string(),feature:p.string().optional(),layer:p.string().optional(),metrics:Da,metadata:p.record(p.unknown()).default({})}),Pa=p.object({source:p.string(),target:p.string(),type:Ta.default("imports"),isExternal:p.boolean().default(false),specifiers:p.array(p.string()).default([]),isTypeOnly:p.boolean().default(false),isDynamic:p.boolean().default(false)});p.object({version:p.string().default("1.0.0"),nodes:p.record(Ia),edges:p.array(Pa),rootPath:p.string(),timestamp:p.string()});var Ra=p.enum(["nextjs","react","vite","vue","nuxt","angular","svelte","sveltekit","astro","remix","express","nest","fastify","node","unknown"]),ja=p.enum(["pnpm","npm","yarn","bun","unknown"]),Oa=p.enum(["TypeScript","JavaScript","Mixed","unknown"]),Na=p.object({name:p.string(),rootDir:p.string(),framework:Ra,frameworkVersion:p.string().optional(),language:Oa,packageManager:ja,runtime:p.string().default("node"),isMonorepo:p.boolean().default(false),workspaces:p.array(p.string()).default([])}),Fa=p.object({appRouter:p.boolean().default(false),pagesRouter:p.boolean().default(false),react:p.boolean().default(false),tailwind:p.boolean().default(false),zustand:p.boolean().default(false),tanstackQuery:p.boolean().default(false),redux:p.boolean().default(false),prisma:p.boolean().default(false),drizzle:p.boolean().default(false),testingFramework:p.string().nullable().default(null),featureModules:p.enum(["full","partial","none"]).default("none"),detectedLibraries:p.array(p.string()).default([])}),La=p.object({sourceFiles:p.number().default(0),totalFiles:p.number().default(0),components:p.number().default(0),hooks:p.number().default(0),services:p.number().default(0),utilities:p.number().default(0),routes:p.number().default(0),tests:p.number().default(0),configs:p.number().default(0),features:p.number().default(0),linesOfCode:p.number().default(0)}),Ma=p.object({prefix:p.string(),targets:p.array(p.string())}),za=p.object({exists:p.boolean().default(false),configPath:p.string().optional(),target:p.string().optional(),module:p.string().optional(),strict:p.boolean().optional(),pathAliases:p.array(Ma).default([])});p.object({version:p.string().default("1.0.0"),timestamp:p.string(),project:Na,detected:Fa,stats:La,entryPoints:p.array(p.string()).default([]),typeScript:za,packageJson:p.record(p.unknown()).optional()});var Ms=p.enum(["error","warning","info"]),Ba=p.object({startLine:p.number(),startColumn:p.number().optional(),endLine:p.number(),endColumn:p.number().optional()});p.object({id:p.string(),ruleId:p.string(),severity:Ms,message:p.string(),filePath:p.string(),location:Ba.optional(),evidence:p.array(p.string()).default([]),suggestion:p.string().optional(),dimension:p.enum(["architecture","complexity","dependencies","duplication","maintainability","testing"]).default("architecture")});var Mn=p.enum(["feature-sliced","clean-architecture","layered","modular-monolith","custom","recommended"]),zn=p.union([Ms,p.enum(["off"]),p.object({severity:Ms,options:p.record(p.unknown()).optional()})]);var Tt=p.object({score:p.number().min(0).max(100).nullable(),status:p.enum(["healthy","warning","critical","unmeasured"]),weight:p.number().min(0).max(1),issueCount:p.number().default(0),summary:p.string().optional()});p.object({overallScore:p.number().min(0).max(100),status:p.enum(["healthy","warning","critical"]),grade:p.enum(["A","B","C","D","F"]),dimensions:p.object({architecture:Tt,complexity:Tt,dependencies:Tt,duplication:Tt,maintainability:Tt,testing:Tt}),metrics:p.object({totalIssues:p.number(),errorCount:p.number(),warningCount:p.number(),infoCount:p.number(),circularDependencies:p.number(),highComplexityCount:p.number(),duplicateBlocksCount:p.number()}),evaluatedAt:p.string()});var Ha=p.enum(["LOW","MEDIUM","HIGH","CRITICAL"]);p.object({target:p.string(),isDirectTarget:p.boolean().default(true),directDependents:p.array(p.string()).default([]),transitiveDependents:p.array(p.string()).default([]),affectedFeatures:p.array(p.string()).default([]),criticalPaths:p.number().default(0),riskAssessment:Ha,affectedModules:p.array(p.string()).default([]),suggestedChecks:p.array(p.string()).default([]),potentialConcerns:p.array(p.string()).default([]),dependencyDistanceMax:p.number().default(0),timestamp:p.string()});var zs=p.object({$schema:p.string().optional(),version:p.number().default(1),project:p.object({name:p.string().optional(),framework:p.string().default("auto"),root:p.string().default(".")}).default({}),analysis:p.object({incremental:p.boolean().default(true),include:p.array(p.string()).default(["src/**","app/**","pages/**","lib/**","components/**","features/**"]),exclude:p.array(p.string()).default(["node_modules/**",".next/**","dist/**","build/**","out/**","coverage/**",".turbo/**",".git/**"]),maxDependencyDepth:p.number().default(20)}).default({}),architecture:p.object({preset:Mn.default("recommended"),layers:p.array(p.string()).optional(),rules:p.record(zn).default({"no-circular-dependencies":"error","no-cross-feature-imports":"error","enforce-public-api":"warning","max-dependency-depth":"warning","no-unresolved-imports":"error"})}).default({}),ai:p.object({enabled:p.boolean().default(false),provider:p.enum(["openai","anthropic","google","local"]).nullable().default(null),model:p.string().optional()}).default({}),guard:p.object({baseline:p.boolean().default(true),failOnNewErrors:p.boolean().default(true),failOnNewWarnings:p.boolean().default(false),ratchetDebt:p.boolean().default(true)}).default({})}),Bs=p.object({version:p.string().default("1.0.0"),createdAt:p.string(),gitCommit:p.string().optional(),issueCounts:p.object({errors:p.number(),warnings:p.number(),circularDependencies:p.number()}),issues:p.array(p.object({ruleId:p.string(),filePath:p.string(),hash:p.string()}))});var de=".devarchitect",as="config.json",Bn="baseline.json";function Wa(s){let e=G.join(s,de,as);if(ue.existsSync(e))return e;let t=G.join(s,".devarchitectrc.json");return ue.existsSync(t)?t:e}function Ce(s){let e=Wa(s);if(!ue.existsSync(e))return {config:{...Os},configPath:e,isDefault:true};try{let t=ue.readFileSync(e,"utf8"),n=JSON.parse(t);return {config:zs.parse(n),configPath:e,isDefault:!1}}catch(t){let n=t instanceof Error?t.message:String(t);throw new Error(`Failed to load DevArchitect config from ${e}: ${n}`)}}function Hn(s,e){let t=G.join(s,de);ue.existsSync(t)||ue.mkdirSync(t,{recursive:true});let n=zs.parse({...Os,...e}),r=G.join(t,as);return ue.writeFileSync(r,JSON.stringify(n,null,2)+`
|
|
4
|
-
`,"utf8"),r}function Wn(s){let e=G.join(s,
|
|
5
|
-
`,"utf8"),r}var
|
|
1
|
+
import {Command}from'commander';import G from'path';import pe from'fs';import ai from'fast-glob';import li from'crypto';import j from'typescript';import {exec,execSync}from'child_process';import Za from'http';var vo=Object.create;var Es=Object.defineProperty;var xo=Object.getOwnPropertyDescriptor;var bo=Object.getOwnPropertyNames;var wo=Object.getPrototypeOf,So=Object.prototype.hasOwnProperty;var Ys=(s,e)=>()=>{try{return e||s((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}},Co=(s,e)=>{for(var t in e)Es(s,t,{get:e[t],enumerable:true});},ko=(s,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of bo(e))!So.call(s,r)&&r!==t&&Es(s,r,{get:()=>e[r],enumerable:!(n=xo(e,r))||n.enumerable});return s};var W=(s,e,t)=>(t=s!=null?vo(wo(s)):{},ko(Es(t,"default",{value:s,enumerable:true}),s));var U=Ys((pc,As)=>{"use strict";var Gt=process||{},Xs=Gt.argv||[],Vt=Gt.env||{},$o=!(Vt.NO_COLOR||Xs.includes("--no-color"))&&(!!Vt.FORCE_COLOR||Xs.includes("--color")||Gt.platform==="win32"||(Gt.stdout||{}).isTTY&&Vt.TERM!=="dumb"||!!Vt.CI),_o=(s,e,t=s)=>n=>{let r=""+n,o=r.indexOf(e,s.length);return ~o?s+Eo(r,e,t,o)+e:s+r+e},Eo=(s,e,t,n)=>{let r="",o=0;do r+=s.substring(o,n)+t,o=n+e.length,n=s.indexOf(e,o);while(~n);return r+s.substring(o)},Qs=(s=$o)=>{let e=s?_o:()=>String;return {isColorSupported:s,reset:e("\x1B[0m","\x1B[0m"),bold:e("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:e("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:e("\x1B[3m","\x1B[23m"),underline:e("\x1B[4m","\x1B[24m"),inverse:e("\x1B[7m","\x1B[27m"),hidden:e("\x1B[8m","\x1B[28m"),strikethrough:e("\x1B[9m","\x1B[29m"),black:e("\x1B[30m","\x1B[39m"),red:e("\x1B[31m","\x1B[39m"),green:e("\x1B[32m","\x1B[39m"),yellow:e("\x1B[33m","\x1B[39m"),blue:e("\x1B[34m","\x1B[39m"),magenta:e("\x1B[35m","\x1B[39m"),cyan:e("\x1B[36m","\x1B[39m"),white:e("\x1B[37m","\x1B[39m"),gray:e("\x1B[90m","\x1B[39m"),bgBlack:e("\x1B[40m","\x1B[49m"),bgRed:e("\x1B[41m","\x1B[49m"),bgGreen:e("\x1B[42m","\x1B[49m"),bgYellow:e("\x1B[43m","\x1B[49m"),bgBlue:e("\x1B[44m","\x1B[49m"),bgMagenta:e("\x1B[45m","\x1B[49m"),bgCyan:e("\x1B[46m","\x1B[49m"),bgWhite:e("\x1B[47m","\x1B[49m"),blackBright:e("\x1B[90m","\x1B[39m"),redBright:e("\x1B[91m","\x1B[39m"),greenBright:e("\x1B[92m","\x1B[39m"),yellowBright:e("\x1B[93m","\x1B[39m"),blueBright:e("\x1B[94m","\x1B[39m"),magentaBright:e("\x1B[95m","\x1B[39m"),cyanBright:e("\x1B[96m","\x1B[39m"),whiteBright:e("\x1B[97m","\x1B[39m"),bgBlackBright:e("\x1B[100m","\x1B[49m"),bgRedBright:e("\x1B[101m","\x1B[49m"),bgGreenBright:e("\x1B[102m","\x1B[49m"),bgYellowBright:e("\x1B[103m","\x1B[49m"),bgBlueBright:e("\x1B[104m","\x1B[49m"),bgMagentaBright:e("\x1B[105m","\x1B[49m"),bgCyanBright:e("\x1B[106m","\x1B[49m"),bgWhiteBright:e("\x1B[107m","\x1B[49m")}};As.exports=Qs();As.exports.createColors=Qs;});var xn=Ys((Tc,Qt)=>{"use strict";function un(s){return Array.isArray(s)?s:[s]}var et=void 0,je="",bt=" ",ge="\\",Ao=/[.*+?()[\]{}^$|\\/]/,To="\uFEFF",Do=/(?:[^\\]|^)\\$/,Io=/^\/\*{2,}$/,Po=/^\\!/,Ro=/^\\#/,jo=/\r?\n/g,Oo="//",xt=47,on=46,_e="/",pn="node-ignore";typeof Symbol<"u"&&(pn=Symbol.for("node-ignore"));var fn=pn,Qe=(s,e,t)=>(Object.defineProperty(s,e,{value:t}),t),mn=()=>!1,an={alnum:"0-9A-Za-z",alpha:"A-Za-z",blank:" \\t",cntrl:"\\x00-\\x1f\\x7f",digit:"0-9",graph:"!-.0-~",lower:"a-z",print:" -.0-~",punct:"!-.:-@\\[-`{-~",space:" \\t\\n\\r",upper:"A-Z",xdigit:"0-9A-Fa-f"},No="\\]^-[",Zt=s=>No.indexOf(s)<0?s:ge+s,Fo="(?!\\/)",Lo=(s,e)=>{if(s)return `[^\\/${e}]`;let t=`[${e}]`;return new RegExp(t).test("/")?Fo+t:t},Mo=(s,e)=>{let{length:t}=s,n=e+1,r=je,o=s[n];(o==="!"||o==="^")&&(r="^",n++);let a=je,i=je;for(;;){let l=s[n];if(l===et)return null;if(l===ge){let c=s[n+1];if(c===et)return null;a+=Zt(c),i=c,n++;}else if(l==="-"&&i&&n+1<t&&s[n+1]!=="]"){n++;let c=s[n];c===ge&&(c=s[n+=1]),i<=c&&(a+=`-${Zt(c)}`),i=je;}else if(l==="["&&s[n+1]===":"){let c=n+2,d=c;for(;d<t&&s[d]!=="]";)d++;if(d===t)return null;if(d>c&&s[d-1]===":"){let u=s.slice(c,d-1);if(!Object.prototype.hasOwnProperty.call(an,u))return null;a+=an[u],i=je,n=d;}else a+=Zt("["),i="[",n=c-2;}else a+=Zt(l),i=l;if(n++,s[n]==="]")return {end:n,source:Lo(r,a)}}},Ds="[]",jt="\0",zo=new RegExp(`${jt}(\\d+)${jt}`,"g"),Jt="\uE000",Yt="\uE001",cn=s=>s===jt||s===Jt||s===Yt,Bo=s=>{let e=[],t=a=>`${jt}${e.push(a)-1}${jt}`,{length:n}=s,r=je,o=0;for(;o<n;){let a=s[o];if(a===ge){let i=s[o+1];i===et||i===_e&&o+2===n?r+=t(Ds):i==="*"||i==="["||i===bt?r+=s.slice(o,o+2):r+=t(Ao.test(i)?ge+i:cn(i)?`[${i}]`:i),o+=2;}else if(cn(a))r+=t(`[${a}]`),o++;else if(a==="["){let i=Mo(s,o);i===null?(r+=t(Ds),o=n):(r+=t(i.source),o=i.end+1);}else r+=a,o++;}return {source:r,sources:e}},Is=null,Ho=/\/(?!$)/,Wo=[[/(\\+)( ?)/g,(s,e,t)=>t?e.slice(0,e.length-e.length%2)+bt:e,ge+bt],[/(^|\/)\*{3,}(?=\/|$)/g,(s,e)=>`${e}**`,"*"],[/[\\$.|*+(){^]/g,s=>`\\${s}`],[/(?!\\)\?/g,()=>"[^/]","?"],[/^\//,()=>"^",_e],[/\//g,()=>"\\/",_e],[/^\^*(?:\\\*\\\*\\\/)+/,()=>"^(?:.*\\/)?","*"],[Is,(s,e)=>!s||s[0]==="^"?s:(Ho.test(e)?"^":"(?:^|\\/)")+s],[/\\\/\\\*\\\*(?=\\\/|$)/g,(s,e,t)=>e+6<t.length?t.slice(e+6)==="\\/"?"(?:\\/[^\\/]+)+":"(?:\\/[^\\/]+)*":`\\/${Yt}`,"*"],[/(^|[^\\]+)(\\\*)+(?=.+)/g,(s,e,t)=>{let n=t.replace(/\\\*/g,"[^\\/]*");return e+n},"*"],[/(^|[^\\])((?:\\\\)*)\\\*$/,(s,e,t)=>t===je?e+Jt:s,"*"],[/\\\\\\(?=[$.|*+(){^])/g,()=>ge,ge+ge],[/\\\\/g,()=>ge,ge+ge],[/\\\[([^\]/]*?)($|\])/g,(s,e,t)=>`\\[${e}${t}`,"["],[Is,s=>{let e=s[s.length-1];return !e||e===Jt||e===Yt?s:e===_e?`${s}$`:`${s}(?=$|\\/$)`}]],Uo=/(^|\\\/)?\uE000$/,Kt="regex",ln="checkRegex",dn="_",Vo=(s,e)=>`${e?`${e}[^/]+`:"[^/]*"}(?=$|\\/$)`,Go=/\uE001$/,Zo=()=>".+(?=$|\\/$)",qt="[^\\/]*",qo=(s,e)=>{let t=je;for(let n=e+1;n<s.length&&!s[n].wildcard;n++)t+=s[n].single;return t},Ko=s=>{if(s.indexOf(qt)<0)return s;let e=[],{length:t}=s,n=0;for(;n<t;){let i=s[n];if(s.startsWith(qt,n))e.push({wildcard:!0}),n+=qt.length;else if(i==="["){let l=n+1;for(s[l]==="^"&&l++,s[l]==="]"&&l++;l<t&&s[l]!=="]";)l+=s[l]===ge?2:1;l++,e.push({single:s.slice(n,l)}),n=l;}else if(i===ge)e.push({single:s.slice(n,n+2)}),n+=2;else if(i==="("){let l=0,c=n;do s[c]===ge?c++:s[c]==="("?l++:s[c]===")"&&l--,c++;while(c<t&&l>0);"*+?".indexOf(s[c])>=0&&c++,e.push({boundary:s.slice(n,c)}),n=c;}else i==="^"||i==="$"?(e.push({boundary:i}),n++):(e.push({single:i}),n++);}let r=je,o=[],a=()=>{let i;o.forEach((l,c)=>{l.wildcard&&(i=c);}),o.forEach((l,c)=>{if(!l.wildcard){r+=l.single;return}r+=c===i?qt:`(?:(?!${qo(o,c)})[^\\/])*`;}),o=[];};return e.forEach(i=>{if(i.boundary===void 0){o.push(i);return}a(),r+=i.boundary;}),a(),r},gn=s=>{Io.test(s)&&(s="**");let{source:e,sources:t}=Bo(s),n=Wo.reduce((r,[o,a,i])=>o===Is?a(r,s):i!==et&&r.indexOf(i)<0?r:o.test(r)?r.replace(o,a.bind(s)):r,e);return t.length?n.replace(zo,(r,o)=>t[o]):n},Jo=(s,e)=>{s[s.length-1]===_e&&(e=gn(s.slice(0,-1)));let t=e.slice(0,-1),n=e[e.length-1];return n===Jt?`${t}$`:n===Yt?`${t}.*$`:Ds},hn=s=>{let e=s.indexOf(_e);return e<0||e===s.length-1},Yo=s=>{let e=s.length-1,t=s.lastIndexOf(_e,s[e]===_e?e-1:e);return t<0?s:s.slice(t+1)},Xo=s=>{if(s.charCodeAt(0)===xt||s.indexOf(Oo)>=0){let n=s.split(_e).filter(Boolean);return n.pop(),n.length?n.join(_e)+_e:je}let e=s.length-1,t=s.lastIndexOf(_e,s.charCodeAt(e)===xt?e-1:e);return t<0?je:s.slice(0,t+1)},Xt=s=>typeof s=="string",Qo=s=>s&&Xt(s)&&!Do.test(s),ei=s=>s.split(jo).filter(Boolean),Ps=class{constructor(e,t,n,r,o,a){this.pattern=e,this.mark=t,this.negative=o,Qe(this,"body",n),Qe(this,"ignoreCase",r),Qe(this,"regexPrefix",a);}get _basenameOnly(){return Qe(this,"_basenameOnly",hn(this.body))}get regex(){let e=dn+Kt;return this[e]?this[e]:this._make(Kt,e)}get checkRegex(){let e=dn+ln;return this[e]?this[e]:this._make(ln,e)}_make(e,t){let n=Ko(e===Kt?this.regexPrefix.replace(Uo,Vo).replace(Go,Zo):Jo(this.body,this.regexPrefix)),r=this.ignoreCase?new RegExp(n,"i"):new RegExp(n);return Qe(this,t,r)}},ti=s=>s==="\r"||s===`
|
|
2
|
+
`,si=s=>{let e=s.length;for(;e&&ti(s[e-1]);)e--;let t=e;for(;e&&s[e-1]===bt;)e--;if(e===t)return s.slice(0,e);let n=0;for(;n<e&&s[e-n-1]===ge;)n++;return n%2?s.slice(0,e-1)+bt:s.slice(0,e)},ni=({pattern:s,mark:e},t)=>{let n=s[0]===To?s.slice(1):s;if(n[0]==="#")return;let r=!1;n[0]==="!"&&(r=!0,n=n.slice(1));let o=n[n.length-1];if((o===bt||o==="\r"||o===`
|
|
3
|
+
`)&&(n=si(n)),!n)return;n=n.replace(Po,"!").replace(Ro,"#");let a=gn(n);return new Ps(s,e,n,t,r,a)},Rs=class{constructor(e){this._ignoreCase=e,this._rules=[],this._basenameCount=0;}_add(e){if(e&&e[fn]){this._rules=this._rules.concat(e._rules._rules),this._basenameCount+=e._rules._basenameCount,this._added=!0;return}Xt(e)&&(e={pattern:e});let t=Qo(e.pattern)&&ni(e,this._ignoreCase);t&&(this._added=!0,this._rules.push(t),hn(t.body)&&this._basenameCount++);}add(e){return this._added=!1,un(Xt(e)?ei(e):e).forEach(this._add,this),this._added&&(this._literalRules=et),this._added}testLiteral(e){let t=this._literalRules||(this._literalRules=this._rules.filter(({body:i})=>i[i.length-(i[i.length-1]===_e?2:1)]==="*")),n=!1,r=!1,o;for(let i=t.length-1;i>=0;i--){let l=t[i];if(l.checkRegex.test(e)){n=!l.negative,r=l.negative,o=l.negative?et:l;break}}let a={ignored:n,unignored:r};return o&&(a.rule=o),a}test(e,t){let n=this._rules,{length:r}=n,o=this._basenameCount*2>=r,a=o?Yo(e):e;for(let i=r-1;i>=0;i--){let l=n[i];if(l[t].test(o&&l._basenameOnly?a:e)){let{negative:c}=l,d={ignored:!c,unignored:c};return c||(d.rule=l),d}}return {ignored:!1,unignored:!1}}},ri=(s,e)=>{throw new e(s)},ze=(s,e,t)=>Xt(s)?s?ze.isNotRelative(s)?t(`path should be a \`path.relative()\`d string, but got "${e}"`,RangeError):!0:t("path must not be empty",TypeError):t(`path must be a string, but got \`${e}\``,TypeError),yn=s=>{let e=s.charCodeAt(0);if(e===xt)return !0;if(e!==on)return !1;if(s.length===1)return !0;let t=s.charCodeAt(1);return t===xt?!0:t!==on?!1:s.length===2||s.charCodeAt(2)===xt};ze.isNotRelative=yn;ze.convert=s=>s;var js=class{constructor({ignorecase:e=!0,ignoreCase:t=e,allowRelativePaths:n=!1}={}){Qe(this,fn,!0),this._rules=new Rs(t),this._strictPathCheck=!n,this._initCache();}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null);}add(e){return this._rules.add(e)&&this._initCache(),this}addPattern(e){return this.add(e)}_test(e,t){let n=e&&ze.convert(e);return ze(n,e,this._strictPathCheck?ri:mn),this._t(n,t)}checkIgnore(e){if(e.charCodeAt(e.length-1)!==xt)return this.test(e);let t=this._t(e,this._testCache);if(t.ignored)return t;let n=this._rules.testLiteral(e);return n.ignored||n.unignored?n:t}_t(e,t){if(e in t)return t[e];let n=Xo(e),r=n?this._t(n,t):et;return t[e]=r&&r.ignored?r:this._rules.test(e,Kt)}ignores(e){return this._test(e,this._ignoreCache).ignored}createFilter(){return e=>!this.ignores(e)}filter(e){return un(e).filter(this.createFilter())}test(e){return this._test(e,this._testCache)}},Os=s=>new js(s),oi=s=>ze(s&&ze.convert(s),s,mn),vn=()=>{let s=t=>/^\\\\\?\\/.test(t)||/["<>|\u0000-\u001F]+/u.test(t)?t:t.replace(/\\/g,"/");ze.convert=s;let e=/^[a-z]:\//i;ze.isNotRelative=t=>e.test(t)||yn(t);};typeof process<"u"&&process.platform==="win32"&&vn();Qt.exports=Os;Os.default=Os;Qt.exports.isPathValid=oi;Qe(Qt.exports,Symbol.for("setupWindows"),vn);});var ye=W(U());var en={id:"detector-nextjs",name:"Next.js Detector",detect(s){let e=s.hasAnyDependency("next"),t=s.hasFile("next.config.js")||s.hasFile("next.config.mjs")||s.hasFile("next.config.ts");if(!e&&!t)return null;let n=s.fileList.some(h=>h.startsWith("app/")||h.startsWith("src/app/")),r=s.fileList.some(h=>h.startsWith("pages/")||h.startsWith("src/pages/")),o=s.fileList.some(h=>h.startsWith("features/")||h.startsWith("src/features/")||h.startsWith("modules/")||h.startsWith("src/modules/")),a=[],i=["src/app/layout.tsx","src/app/layout.jsx","app/layout.tsx","app/layout.jsx","src/app/page.tsx","src/app/page.jsx","app/page.tsx","app/page.jsx","src/pages/_app.tsx","src/pages/_app.jsx","pages/_app.tsx","pages/_app.jsx","src/pages/index.tsx","pages/index.tsx"];for(let h of i)s.hasFile(h)&&a.push(h);let l=s.packageJson,c=l?.dependencies||{},d=l?.devDependencies||{};return {matched:true,framework:"nextjs",frameworkVersion:c.next||d.next,priority:100,features:{appRouter:n,pagesRouter:r,react:true,tailwind:s.hasAnyDependency("tailwindcss")||s.hasFile("tailwind.config.js")||s.hasFile("tailwind.config.ts"),zustand:s.hasAnyDependency("zustand"),tanstackQuery:s.hasAnyDependency("@tanstack/react-query")||s.hasAnyDependency("react-query"),redux:s.hasAnyDependency("@reduxjs/toolkit")||s.hasAnyDependency("redux"),prisma:s.hasAnyDependency("@prisma/client")||s.hasFile("prisma/schema.prisma"),drizzle:s.hasAnyDependency("drizzle-orm"),featureModules:o?"partial":"none",testingFramework:s.hasAnyDependency("vitest")?"vitest":s.hasAnyDependency("jest")?"jest":s.hasAnyDependency("@playwright/test")?"playwright":null},entryPoints:a,suggestedPresets:["feature-sliced","layered","recommended"]}}};var tn={id:"detector-react",name:"React Detector",detect(s){let e=s.hasAnyDependency("react"),t=s.hasAnyDependency("vite")||s.hasFile("vite.config.ts")||s.hasFile("vite.config.js");s.hasAnyDependency("react-scripts");if(!e&&!t)return null;let r=s.fileList.some(u=>u.startsWith("features/")||u.startsWith("src/features/")||u.startsWith("modules/")||u.startsWith("src/modules/")),o=[],a=["src/main.tsx","src/main.jsx","src/index.tsx","src/index.jsx","src/App.tsx","src/App.jsx","index.html"];for(let u of a)s.hasFile(u)&&o.push(u);let i=s.packageJson,l=i?.dependencies||{},c=i?.devDependencies||{},d=l.react||c.react||l.vite||c.vite;return {matched:true,framework:t?"vite":"react",frameworkVersion:d,priority:50,features:{appRouter:false,pagesRouter:false,react:true,tailwind:s.hasAnyDependency("tailwindcss")||s.hasFile("tailwind.config.js")||s.hasFile("tailwind.config.ts"),zustand:s.hasAnyDependency("zustand"),tanstackQuery:s.hasAnyDependency("@tanstack/react-query")||s.hasAnyDependency("react-query"),redux:s.hasAnyDependency("@reduxjs/toolkit")||s.hasAnyDependency("redux"),prisma:s.hasAnyDependency("@prisma/client"),drizzle:s.hasAnyDependency("drizzle-orm"),featureModules:r?"partial":"none",testingFramework:s.hasAnyDependency("vitest")?"vitest":s.hasAnyDependency("jest")?"jest":null},entryPoints:o,suggestedPresets:["feature-sliced","clean-architecture","recommended"]}}};var sn={id:"detector-vue",name:"Vue / Nuxt Detector",detect(s){let e=s.hasAnyDependency("nuxt")||s.hasFile("nuxt.config.ts")||s.hasFile("nuxt.config.js"),t=s.hasAnyDependency("vue");if(!e&&!t)return null;let n=[],r=["src/main.ts","src/main.js","src/App.vue","app.vue"];for(let o of r)s.hasFile(o)&&n.push(o);return {matched:true,framework:e?"nuxt":"vue",priority:e?90:45,features:{react:false,tailwind:s.hasAnyDependency("tailwindcss"),testingFramework:s.hasAnyDependency("vitest")?"vitest":null},entryPoints:n,suggestedPresets:["layered","recommended"]}}};var nn={id:"detector-node",name:"Node.js / Backend Detector",detect(s){let e=s.hasAnyDependency("@nestjs/core")||s.hasFile("nest-cli.json"),t=s.hasAnyDependency("express"),n=s.hasAnyDependency("fastify");if(!e&&!t&&!n&&!s.hasFile("package.json"))return null;let r=e?"nest":t?"express":n?"fastify":"node",o=[],a=["src/main.ts","src/server.ts","src/index.ts","src/app.ts","server.js","index.js"];for(let i of a)s.hasFile(i)&&o.push(i);return {matched:true,framework:r,priority:e?60:t||n?40:10,features:{prisma:s.hasAnyDependency("@prisma/client"),drizzle:s.hasAnyDependency("drizzle-orm"),testingFramework:s.hasAnyDependency("vitest")?"vitest":s.hasAnyDependency("jest")?"jest":null},entryPoints:o,suggestedPresets:e?["clean-architecture","modular-monolith"]:["layered","recommended"]}}};var Ts=class{plugins=[];constructor(){this.registerBuiltins();}registerBuiltins(){this.register(en),this.register(tn),this.register(sn),this.register(nn);}register(e){this.plugins=this.plugins.filter(t=>t.id!==e.id),this.plugins.push(e);}getPlugins(){return this.plugins}async detect(e){let t=[];for(let a of this.plugins)try{let i=await a.detect(e);i&&i.matched&&t.push(i);}catch{}if(t.length===0)return {matched:false,framework:"unknown",priority:0,features:{},entryPoints:[],suggestedPresets:["recommended"]};t.sort((a,i)=>i.priority-a.priority);let n=t[0],r=t.reduceRight((a,i)=>({...a,...i.features}),n.features||{}),o=Array.from(new Set(t.flatMap(a=>a.entryPoints||[])));return {...n,features:r,entryPoints:o}}},rn=new Ts;var wn=W(xn());function es(s){return s.replace(/\\/g,"/")}function ci(s){let e=G.join(s,".gitignore");if(!pe.existsSync(e))return null;try{let t=pe.readFileSync(e,"utf8"),n=(0,wn.default)();return n.add(t),n}catch{return null}}async function Sn(s,e={}){let t=e.include&&e.include.length>0?e.include:["**/*"],n=["**/node_modules/**","**/.git/**","**/.next/**","**/dist/**","**/build/**","**/out/**","**/coverage/**","**/.turbo/**","**/.devarchitect/cache/**","**/.devarchitect/reports/**","**/*.log"],r=Array.from(new Set([...n,...e.exclude||[]])),o=e.respectGitignore!==false?ci(s):null,i=(await ai(t,{cwd:s,ignore:r,dot:true,onlyFiles:true,followSymbolicLinks:false})).map(es);return o?i.filter(c=>!o.ignores(c)).sort():i.sort()}function ui(s){return li.createHash("sha256").update(s).digest("hex")}function ts(s){try{let e=pe.readFileSync(s);return ui(e)}catch{return ""}}function fi(s){switch(G.extname(s).toLowerCase()){case ".ts":return "typescript";case ".tsx":return "typescript-react";case ".js":case ".mjs":case ".cjs":return "javascript";case ".jsx":return "javascript-react";case ".json":return "json";case ".css":case ".scss":case ".sass":case ".less":return "stylesheet";case ".html":return "html";case ".md":case ".mdx":return "markdown";case ".vue":return "vue";case ".svelte":return "svelte";default:return "unknown"}}function mi(s){let e=s.split("/"),t=["app","processes","pages","widgets","features","entities","shared"];for(let r of t)if(e.indexOf(r)!==-1)return r;let n=["domain","application","infrastructure","presentation","adapters","core"];for(let r of n)if(e.indexOf(r)!==-1)return r}function gi(s){let e=s.split("/"),t=e.findIndex(n=>n==="features"||n==="modules");if(t!==-1&&t<e.length-1)return e[t+1]}function hi(s){let e=es(s).toLowerCase(),t=G.basename(s),n=G.extname(s).toLowerCase();return e.includes("__tests__")||e.includes("__mocks__")||t.includes(".test.")||t.includes(".spec.")?"test":t.includes(".config.")||t.startsWith("tsconfig")||t==="package.json"||t==="turbo.json"||t==="pnpm-workspace.yaml"||e.startsWith(".devarchitect")?"config":[".css",".scss",".sass",".less",".svg",".png",".jpg",".jpeg",".gif",".webp",".ico"].includes(n)?"asset":e.includes("/app/")&&(t.startsWith("page.")||t.startsWith("layout.")||t.startsWith("route.")||t.startsWith("loading.")||t.startsWith("error."))||e.includes("/pages/")||e.includes("/routes/")||t.includes(".route.")?"route":t.startsWith("use")&&(n===".ts"||n===".tsx"||n===".js"||n===".jsx")||e.includes("/hooks/")?"hook":t.toLowerCase().includes("service.")||t.toLowerCase().includes("client.")||e.includes("/services/")||e.includes("/service/")||e.includes("/api/")||e.includes("/repositories/")||e.includes("/repository/")?"service":t.toLowerCase().includes("util.")||t.toLowerCase().includes("helper.")||e.includes("/utils/")||e.includes("/util/")||e.includes("/helpers/")||e.includes("/lib/")?"utility":n===".tsx"||n===".jsx"||n===".vue"||n===".svelte"||e.includes("/components/")||e.includes("/widgets/")||/^[A-Z][a-zA-Z0-9]+\.(ts|js|tsx|jsx)$/.test(t)&&!t.toLowerCase().includes("service")?"component":e.includes("/features/")||e.includes("/modules/")?"module":"unknown"}function yi(s){try{return pe.readFileSync(s,"utf8").split(/\r\n|\r|\n/).length}catch{return 0}}function Cn(s,e){let t=es(e),n=G.join(s,e),r=hi(t),o=gi(t),a=mi(t),i=fi(t),l=yi(n),c=ts(n);return {id:t,path:t,name:G.basename(t),type:r,language:i,feature:o,layer:a,metrics:{complexity:null,linesOfCode:l,dependencyCount:0,dependentCount:0,exportCount:0,importCount:0},metadata:{hash:c}}}function kn(s){let e=[G.join(s,"tsconfig.json"),G.join(s,"tsconfig.app.json")],t;for(let n of e)if(pe.existsSync(n)){t=n;break}if(!t)try{let n=pe.readdirSync(s,{withFileTypes:!0}),r=new Set(["node_modules",".git",".next","dist","build","out",".turbo",".vscode",".agents",".claude",".devarchitect"]);for(let o of n)if(o.isDirectory()&&!r.has(o.name)){let a=G.join(s,o.name,"tsconfig.json");if(pe.existsSync(a)){t=a;break}}}catch{}if(!t)return {exists:false,pathAliases:[]};try{let r=pe.readFileSync(t,"utf8").replace(/\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*$/gm,"$1"),a=JSON.parse(r).compilerOptions||{},i=[];if(a.paths&&typeof a.paths=="object")for(let[l,c]of Object.entries(a.paths))Array.isArray(c)&&i.push({prefix:l,targets:c.map(d=>String(d))});return {exists:!0,configPath:G.relative(s,t).replace(/\\/g,"/"),target:a.target,module:a.module,strict:a.strict,pathAliases:i}}catch{return {exists:true,configPath:G.relative(s,t).replace(/\\/g,"/"),pathAliases:[]}}}function vi(s){try{let e=pe.readdirSync(s,{withFileTypes:!0}),t=[],n=new Set(["node_modules",".git",".next","dist","build","out",".turbo",".vscode",".agents",".claude",".devarchitect"]);for(let r of e)if(r.isDirectory()&&!n.has(r.name)){let o=G.join(s,r.name,"package.json");if(pe.existsSync(o)){let a=pe.readFileSync(o,"utf8"),i=JSON.parse(a);t.push({name:i.name||r.name,dir:G.join(s,r.name),info:{exists:!0,name:i.name||r.name,version:i.version,raw:i,dependencies:i.dependencies||{},devDependencies:i.devDependencies||{},scripts:i.scripts||{}}});}}return t}catch{return []}}function $n(s){let e=G.join(s,"package.json");if(!pe.existsSync(e)){let t=vi(s);if(t.length>0){let n={},r={},o={},a=[];for(let i of t)Object.assign(n,i.info.dependencies),Object.assign(r,i.info.devDependencies),Object.assign(o,i.info.scripts),a.push(G.basename(i.dir));return {exists:true,name:t[0].name||G.basename(s),version:t[0].info.version,raw:{name:G.basename(s),workspaces:a,subprojects:t.map(i=>i.name)},dependencies:n,devDependencies:r,scripts:o}}return {exists:false,name:G.basename(s),raw:{},dependencies:{},devDependencies:{},scripts:{}}}try{let t=pe.readFileSync(e,"utf8"),n=JSON.parse(t);return {exists:!0,name:n.name||G.basename(s),version:n.version,raw:n,dependencies:n.dependencies||{},devDependencies:n.devDependencies||{},scripts:n.scripts||{}}}catch{return {exists:true,name:G.basename(s),raw:{},dependencies:{},devDependencies:{},scripts:{}}}}function _n(s){let e=s;for(let t=0;t<5;t++){if(pe.existsSync(G.join(e,"pnpm-lock.yaml")))return "pnpm";if(pe.existsSync(G.join(e,"yarn.lock")))return "yarn";if(pe.existsSync(G.join(e,"bun.lockb"))||pe.existsSync(G.join(e,"bun.lock")))return "bun";if(pe.existsSync(G.join(e,"package-lock.json")))return "npm";let n=G.dirname(e);if(n===e)break;e=n;}return "unknown"}function En(s,e){let t=G.join(s,"pnpm-workspace.yaml");if(pe.existsSync(t))return {isMonorepo:true,workspaces:["pnpm-workspace"]};let n=G.join(s,"lerna.json");if(pe.existsSync(n))return {isMonorepo:true,workspaces:["lerna"]};let r=G.join(s,"turbo.json");return pe.existsSync(r)?{isMonorepo:true,workspaces:["turborepo"]}:e.raw.workspaces?{isMonorepo:true,workspaces:Array.isArray(e.raw.workspaces)?e.raw.workspaces:[]}:{isMonorepo:false,workspaces:[]}}var Ns={$schema:"https://devarchitect.dev/schema/config.json",version:1,project:{name:void 0,framework:"auto",root:"."},analysis:{incremental:true,include:["**/*.{ts,tsx,js,jsx}","src/**","app/**","pages/**","lib/**","components/**","features/**","modules/**","services/**","hooks/**","packages/**","apps/**","**/src/**","**/app/**","**/pages/**","**/lib/**","**/components/**","**/features/**","**/modules/**","**/services/**","**/hooks/**","tests/**","__tests__/**"],exclude:["**/node_modules/**","**/.next/**","**/dist/**","**/build/**","**/out/**","**/coverage/**","**/.turbo/**","**/.git/**","**/*.d.ts","**/*.config.*","**/vite.config.*","**/next.config.*"],maxDependencyDepth:20},architecture:{preset:"recommended",rules:{"no-circular-dependencies":"error","no-cross-feature-imports":"error","enforce-public-api":"warning","max-dependency-depth":"warning","no-unresolved-imports":"error"}},ai:{enabled:false,provider:null},guard:{baseline:true,failOnNewErrors:true,failOnNewWarnings:false,ratchetDebt:true}};var p={};Co(p,{BRAND:()=>Ui,DIRTY:()=>tt,EMPTY_PATH:()=>Si,INVALID:()=>D,NEVER:()=>Aa,OK:()=>he,ParseStatus:()=>fe,Schema:()=>O,ZodAny:()=>qe,ZodArray:()=>Ue,ZodBigInt:()=>nt,ZodBoolean:()=>rt,ZodBranded:()=>Lt,ZodCatch:()=>gt,ZodDate:()=>ot,ZodDefault:()=>mt,ZodDiscriminatedUnion:()=>os,ZodEffects:()=>De,ZodEnum:()=>pt,ZodError:()=>Se,ZodFirstPartyTypeKind:()=>P,ZodFunction:()=>as,ZodIntersection:()=>lt,ZodIssueCode:()=>w,ZodLazy:()=>dt,ZodLiteral:()=>ut,ZodMap:()=>_t,ZodNaN:()=>At,ZodNativeEnum:()=>ft,ZodNever:()=>Oe,ZodNull:()=>at,ZodNullable:()=>Me,ZodNumber:()=>st,ZodObject:()=>Ce,ZodOptional:()=>Ae,ZodParsedType:()=>_,ZodPipeline:()=>Mt,ZodPromise:()=>Ke,ZodReadonly:()=>ht,ZodRecord:()=>is,ZodSchema:()=>O,ZodSet:()=>Et,ZodString:()=>Ze,ZodSymbol:()=>kt,ZodTransformer:()=>De,ZodTuple:()=>Le,ZodType:()=>O,ZodUndefined:()=>it,ZodUnion:()=>ct,ZodUnknown:()=>We,ZodVoid:()=>$t,addIssueToContext:()=>$,any:()=>Qi,array:()=>na,bigint:()=>qi,boolean:()=>Ln,coerce:()=>Ea,custom:()=>On,date:()=>Ki,datetimeRegex:()=>Rn,defaultErrorMap:()=>Be,discriminatedUnion:()=>aa,effect:()=>xa,enum:()=>ha,function:()=>fa,getErrorMap:()=>wt,getParsedType:()=>Fe,instanceof:()=>Gi,intersection:()=>ca,isAborted:()=>ns,isAsync:()=>St,isDirty:()=>rs,isValid:()=>Ge,late:()=>Vi,lazy:()=>ma,literal:()=>ga,makeIssue:()=>Ft,map:()=>ua,nan:()=>Zi,nativeEnum:()=>ya,never:()=>ta,null:()=>Xi,nullable:()=>wa,number:()=>Fn,object:()=>ra,objectUtil:()=>Fs,oboolean:()=>_a,onumber:()=>$a,optional:()=>ba,ostring:()=>ka,pipeline:()=>Ca,preprocess:()=>Sa,promise:()=>va,quotelessJson:()=>xi,record:()=>da,set:()=>pa,setErrorMap:()=>wi,strictObject:()=>oa,string:()=>Nn,symbol:()=>Ji,transformer:()=>xa,tuple:()=>la,undefined:()=>Yi,union:()=>ia,unknown:()=>ea,util:()=>F,void:()=>sa});var F;(function(s){s.assertEqual=r=>{};function e(r){}s.assertIs=e;function t(r){throw new Error}s.assertNever=t,s.arrayToEnum=r=>{let o={};for(let a of r)o[a]=a;return o},s.getValidEnumValues=r=>{let o=s.objectKeys(r).filter(i=>typeof r[r[i]]!="number"),a={};for(let i of o)a[i]=r[i];return s.objectValues(a)},s.objectValues=r=>s.objectKeys(r).map(function(o){return r[o]}),s.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{let o=[];for(let a in r)Object.prototype.hasOwnProperty.call(r,a)&&o.push(a);return o},s.find=(r,o)=>{for(let a of r)if(o(a))return a},s.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&Number.isFinite(r)&&Math.floor(r)===r;function n(r,o=" | "){return r.map(a=>typeof a=="string"?`'${a}'`:a).join(o)}s.joinValues=n,s.jsonStringifyReplacer=(r,o)=>typeof o=="bigint"?o.toString():o;})(F||(F={}));var Fs;(function(s){s.mergeShapes=(e,t)=>({...e,...t});})(Fs||(Fs={}));var _=F.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Fe=s=>{switch(typeof s){case "undefined":return _.undefined;case "string":return _.string;case "number":return Number.isNaN(s)?_.nan:_.number;case "boolean":return _.boolean;case "function":return _.function;case "bigint":return _.bigint;case "symbol":return _.symbol;case "object":return Array.isArray(s)?_.array:s===null?_.null:s.then&&typeof s.then=="function"&&s.catch&&typeof s.catch=="function"?_.promise:typeof Map<"u"&&s instanceof Map?_.map:typeof Set<"u"&&s instanceof Set?_.set:typeof Date<"u"&&s instanceof Date?_.date:_.object;default:return _.unknown}};var w=F.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),xi=s=>JSON.stringify(s,null,2).replace(/"([^"]+)":/g,"$1:"),Se=class s extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n];},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n];};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e;}format(e){let t=e||function(o){return o.message},n={_errors:[]},r=o=>{for(let a of o.issues)if(a.code==="invalid_union")a.unionErrors.map(r);else if(a.code==="invalid_return_type")r(a.returnTypeError);else if(a.code==="invalid_arguments")r(a.argumentsError);else if(a.path.length===0)n._errors.push(t(a));else {let i=n,l=0;for(;l<a.path.length;){let c=a.path[l];l===a.path.length-1?(i[c]=i[c]||{_errors:[]},i[c]._errors.push(t(a))):i[c]=i[c]||{_errors:[]},i=i[c],l++;}}};return r(this),n}static assert(e){if(!(e instanceof s))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,F.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){let t={},n=[];for(let r of this.issues)if(r.path.length>0){let o=r.path[0];t[o]=t[o]||[],t[o].push(e(r));}else n.push(e(r));return {formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};Se.create=s=>new Se(s);var bi=(s,e)=>{let t;switch(s.code){case w.invalid_type:s.received===_.undefined?t="Required":t=`Expected ${s.expected}, received ${s.received}`;break;case w.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(s.expected,F.jsonStringifyReplacer)}`;break;case w.unrecognized_keys:t=`Unrecognized key(s) in object: ${F.joinValues(s.keys,", ")}`;break;case w.invalid_union:t="Invalid input";break;case w.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${F.joinValues(s.options)}`;break;case w.invalid_enum_value:t=`Invalid enum value. Expected ${F.joinValues(s.options)}, received '${s.received}'`;break;case w.invalid_arguments:t="Invalid function arguments";break;case w.invalid_return_type:t="Invalid function return type";break;case w.invalid_date:t="Invalid date";break;case w.invalid_string:typeof s.validation=="object"?"includes"in s.validation?(t=`Invalid input: must include "${s.validation.includes}"`,typeof s.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${s.validation.position}`)):"startsWith"in s.validation?t=`Invalid input: must start with "${s.validation.startsWith}"`:"endsWith"in s.validation?t=`Invalid input: must end with "${s.validation.endsWith}"`:F.assertNever(s.validation):s.validation!=="regex"?t=`Invalid ${s.validation}`:t="Invalid";break;case w.too_small:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at least":"more than"} ${s.minimum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at least":"over"} ${s.minimum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${s.minimum}`:s.type==="bigint"?t=`Number must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${s.minimum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(s.minimum))}`:t="Invalid input";break;case w.too_big:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at most":"less than"} ${s.maximum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at most":"under"} ${s.maximum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="bigint"?t=`BigInt must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly":s.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(s.maximum))}`:t="Invalid input";break;case w.custom:t="Invalid input";break;case w.invalid_intersection_types:t="Intersection results could not be merged";break;case w.not_multiple_of:t=`Number must be a multiple of ${s.multipleOf}`;break;case w.not_finite:t="Number must be finite";break;default:t=e.defaultError,F.assertNever(s);}return {message:t}},Be=bi;var An=Be;function wi(s){An=s;}function wt(){return An}var Ft=s=>{let{data:e,path:t,errorMaps:n,issueData:r}=s,o=[...t,...r.path||[]],a={...r,path:o};if(r.message!==void 0)return {...r,path:o,message:r.message};let i="",l=n.filter(c=>!!c).slice().reverse();for(let c of l)i=c(a,{data:e,defaultError:i}).message;return {...r,path:o,message:i}},Si=[];function $(s,e){let t=wt(),n=Ft({issueData:e,data:s.data,path:s.path,errorMaps:[s.common.contextualErrorMap,s.schemaErrorMap,t,t===Be?void 0:Be].filter(r=>!!r)});s.common.issues.push(n);}var fe=class s{constructor(){this.value="valid";}dirty(){this.value==="valid"&&(this.value="dirty");}abort(){this.value!=="aborted"&&(this.value="aborted");}static mergeArray(e,t){let n=[];for(let r of t){if(r.status==="aborted")return D;r.status==="dirty"&&e.dirty(),n.push(r.value);}return {status:e.value,value:n}}static async mergeObjectAsync(e,t){let n=[];for(let r of t){let o=await r.key,a=await r.value;n.push({key:o,value:a});}return s.mergeObjectSync(e,n)}static mergeObjectSync(e,t){let n={};for(let r of t){let{key:o,value:a}=r;if(o.status==="aborted"||a.status==="aborted")return D;o.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),o.value!=="__proto__"&&(typeof a.value<"u"||r.alwaysSet)&&(n[o.value]=a.value);}return {status:e.value,value:n}}},D=Object.freeze({status:"aborted"}),tt=s=>({status:"dirty",value:s}),he=s=>({status:"valid",value:s}),ns=s=>s.status==="aborted",rs=s=>s.status==="dirty",Ge=s=>s.status==="valid",St=s=>typeof Promise<"u"&&s instanceof Promise;var E;(function(s){s.errToObj=e=>typeof e=="string"?{message:e}:e||{},s.toString=e=>typeof e=="string"?e:e?.message;})(E||(E={}));var Te=class{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r;}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},Tn=(s,e)=>{if(Ge(e))return {success:true,data:e.value};if(!s.common.issues.length)throw new Error("Validation failed but no issues detected.");return {success:false,get error(){if(this._error)return this._error;let t=new Se(s.common.issues);return this._error=t,this._error}}};function R(s){if(!s)return {};let{errorMap:e,invalid_type_error:t,required_error:n,description:r}=s;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:r}:{errorMap:(a,i)=>{let{message:l}=s;return a.code==="invalid_enum_value"?{message:l??i.defaultError}:typeof i.data>"u"?{message:l??n??i.defaultError}:a.code!=="invalid_type"?{message:i.defaultError}:{message:l??t??i.defaultError}},description:r}}var O=class{get description(){return this._def.description}_getType(e){return Fe(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Fe(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return {status:new fe,ctx:{common:e.parent.common,data:e.data,parsedType:Fe(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(St(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??false,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Fe(e)},r=this._parseSync({data:e,path:n.path,parent:n});return Tn(n,r)}"~validate"(e){let t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Fe(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:t});return Ge(n)?{value:n.value}:{issues:t.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=true),t.common={issues:[],async:true};}return this._parseAsync({data:e,path:[],parent:t}).then(n=>Ge(n)?{value:n.value}:{issues:t.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:true},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Fe(e)},r=this._parse({data:e,path:n.path,parent:n}),o=await(St(r)?r:Promise.resolve(r));return Tn(n,o)}refine(e,t){let n=r=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(r):t;return this._refinement((r,o)=>{let a=e(r),i=()=>o.addIssue({code:w.custom,...n(r)});return typeof Promise<"u"&&a instanceof Promise?a.then(l=>l?true:(i(),false)):a?true:(i(),false)})}refinement(e,t){return this._refinement((n,r)=>e(n)?true:(r.addIssue(typeof t=="function"?t(n,r):t),false))}_refinement(e){return new De({schema:this,typeName:P.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)};}optional(){return Ae.create(this,this._def)}nullable(){return Me.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ue.create(this)}promise(){return Ke.create(this,this._def)}or(e){return ct.create([this,e],this._def)}and(e){return lt.create(this,e,this._def)}transform(e){return new De({...R(this._def),schema:this,typeName:P.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e=="function"?e:()=>e;return new mt({...R(this._def),innerType:this,defaultValue:t,typeName:P.ZodDefault})}brand(){return new Lt({typeName:P.ZodBranded,type:this,...R(this._def)})}catch(e){let t=typeof e=="function"?e:()=>e;return new gt({...R(this._def),innerType:this,catchValue:t,typeName:P.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Mt.create(this,e)}readonly(){return ht.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Ci=/^c[^\s-]{8,}$/i,ki=/^[0-9a-z]+$/,$i=/^[0-9A-HJKMNP-TV-Z]{26}$/i,_i=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Ei=/^[a-z0-9_-]{21}$/i,Ai=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Ti=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Di=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Ii="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Ls,Pi=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Ri=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ji=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Oi=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Ni=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Fi=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,In="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Li=new RegExp(`^${In}$`);function Pn(s){let e="[0-5]\\d";s.precision?e=`${e}\\.\\d{${s.precision}}`:s.precision==null&&(e=`${e}(\\.\\d+)?`);let t=s.precision?"+":"?";return `([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function Mi(s){return new RegExp(`^${Pn(s)}$`)}function Rn(s){let e=`${In}T${Pn(s)}`,t=[];return t.push(s.local?"Z?":"Z"),s.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function zi(s,e){return !!((e==="v4"||!e)&&Pi.test(s)||(e==="v6"||!e)&&ji.test(s))}function Bi(s,e){if(!Ai.test(s))return false;try{let[t]=s.split(".");if(!t)return !1;let n=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),r=JSON.parse(atob(n));return !(typeof r!="object"||r===null||"typ"in r&&r?.typ!=="JWT"||!r.alg||e&&r.alg!==e)}catch{return false}}function Hi(s,e){return !!((e==="v4"||!e)&&Ri.test(s)||(e==="v6"||!e)&&Oi.test(s))}var Ze=class s extends O{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==_.string){let o=this._getOrReturnCtx(e);return $(o,{code:w.invalid_type,expected:_.string,received:o.parsedType}),D}let n=new fe,r;for(let o of this._def.checks)if(o.kind==="min")e.data.length<o.value&&(r=this._getOrReturnCtx(e,r),$(r,{code:w.too_small,minimum:o.value,type:"string",inclusive:true,exact:false,message:o.message}),n.dirty());else if(o.kind==="max")e.data.length>o.value&&(r=this._getOrReturnCtx(e,r),$(r,{code:w.too_big,maximum:o.value,type:"string",inclusive:true,exact:false,message:o.message}),n.dirty());else if(o.kind==="length"){let a=e.data.length>o.value,i=e.data.length<o.value;(a||i)&&(r=this._getOrReturnCtx(e,r),a?$(r,{code:w.too_big,maximum:o.value,type:"string",inclusive:true,exact:true,message:o.message}):i&&$(r,{code:w.too_small,minimum:o.value,type:"string",inclusive:true,exact:true,message:o.message}),n.dirty());}else if(o.kind==="email")Di.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"email",code:w.invalid_string,message:o.message}),n.dirty());else if(o.kind==="emoji")Ls||(Ls=new RegExp(Ii,"u")),Ls.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"emoji",code:w.invalid_string,message:o.message}),n.dirty());else if(o.kind==="uuid")_i.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"uuid",code:w.invalid_string,message:o.message}),n.dirty());else if(o.kind==="nanoid")Ei.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"nanoid",code:w.invalid_string,message:o.message}),n.dirty());else if(o.kind==="cuid")Ci.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"cuid",code:w.invalid_string,message:o.message}),n.dirty());else if(o.kind==="cuid2")ki.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"cuid2",code:w.invalid_string,message:o.message}),n.dirty());else if(o.kind==="ulid")$i.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"ulid",code:w.invalid_string,message:o.message}),n.dirty());else if(o.kind==="url")try{new URL(e.data);}catch{r=this._getOrReturnCtx(e,r),$(r,{validation:"url",code:w.invalid_string,message:o.message}),n.dirty();}else o.kind==="regex"?(o.regex.lastIndex=0,o.regex.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"regex",code:w.invalid_string,message:o.message}),n.dirty())):o.kind==="trim"?e.data=e.data.trim():o.kind==="includes"?e.data.includes(o.value,o.position)||(r=this._getOrReturnCtx(e,r),$(r,{code:w.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),n.dirty()):o.kind==="toLowerCase"?e.data=e.data.toLowerCase():o.kind==="toUpperCase"?e.data=e.data.toUpperCase():o.kind==="startsWith"?e.data.startsWith(o.value)||(r=this._getOrReturnCtx(e,r),$(r,{code:w.invalid_string,validation:{startsWith:o.value},message:o.message}),n.dirty()):o.kind==="endsWith"?e.data.endsWith(o.value)||(r=this._getOrReturnCtx(e,r),$(r,{code:w.invalid_string,validation:{endsWith:o.value},message:o.message}),n.dirty()):o.kind==="datetime"?Rn(o).test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{code:w.invalid_string,validation:"datetime",message:o.message}),n.dirty()):o.kind==="date"?Li.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{code:w.invalid_string,validation:"date",message:o.message}),n.dirty()):o.kind==="time"?Mi(o).test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{code:w.invalid_string,validation:"time",message:o.message}),n.dirty()):o.kind==="duration"?Ti.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"duration",code:w.invalid_string,message:o.message}),n.dirty()):o.kind==="ip"?zi(e.data,o.version)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"ip",code:w.invalid_string,message:o.message}),n.dirty()):o.kind==="jwt"?Bi(e.data,o.alg)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"jwt",code:w.invalid_string,message:o.message}),n.dirty()):o.kind==="cidr"?Hi(e.data,o.version)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"cidr",code:w.invalid_string,message:o.message}),n.dirty()):o.kind==="base64"?Ni.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"base64",code:w.invalid_string,message:o.message}),n.dirty()):o.kind==="base64url"?Fi.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"base64url",code:w.invalid_string,message:o.message}),n.dirty()):F.assertNever(o);return {status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(r=>e.test(r),{validation:t,code:w.invalid_string,...E.errToObj(n)})}_addCheck(e){return new s({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...E.errToObj(e)})}url(e){return this._addCheck({kind:"url",...E.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...E.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...E.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...E.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...E.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...E.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...E.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...E.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...E.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...E.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...E.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...E.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:false,local:false,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??false,local:e?.local??false,...E.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...E.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...E.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...E.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...E.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...E.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...E.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...E.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...E.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...E.errToObj(t)})}nonempty(e){return this.min(1,E.errToObj(e))}trim(){return new s({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new s({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new s({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return !!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return !!this._def.checks.find(e=>e.kind==="date")}get isTime(){return !!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return !!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return !!this._def.checks.find(e=>e.kind==="email")}get isURL(){return !!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return !!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return !!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return !!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return !!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return !!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return !!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return !!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return !!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return !!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return !!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};Ze.create=s=>new Ze({checks:[],typeName:P.ZodString,coerce:s?.coerce??false,...R(s)});function Wi(s,e){let t=(s.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,r=t>n?t:n,o=Number.parseInt(s.toFixed(r).replace(".","")),a=Number.parseInt(e.toFixed(r).replace(".",""));return o%a/10**r}var st=class s extends O{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf;}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==_.number){let o=this._getOrReturnCtx(e);return $(o,{code:w.invalid_type,expected:_.number,received:o.parsedType}),D}let n,r=new fe;for(let o of this._def.checks)o.kind==="int"?F.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),$(n,{code:w.invalid_type,expected:"integer",received:"float",message:o.message}),r.dirty()):o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(n=this._getOrReturnCtx(e,n),$(n,{code:w.too_small,minimum:o.value,type:"number",inclusive:o.inclusive,exact:false,message:o.message}),r.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(n=this._getOrReturnCtx(e,n),$(n,{code:w.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:false,message:o.message}),r.dirty()):o.kind==="multipleOf"?Wi(e.data,o.value)!==0&&(n=this._getOrReturnCtx(e,n),$(n,{code:w.not_multiple_of,multipleOf:o.value,message:o.message}),r.dirty()):o.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),$(n,{code:w.not_finite,message:o.message}),r.dirty()):F.assertNever(o);return {status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,true,E.toString(t))}gt(e,t){return this.setLimit("min",e,false,E.toString(t))}lte(e,t){return this.setLimit("max",e,true,E.toString(t))}lt(e,t){return this.setLimit("max",e,false,E.toString(t))}setLimit(e,t,n,r){return new s({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:E.toString(r)}]})}_addCheck(e){return new s({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:E.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:false,message:E.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:false,message:E.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:true,message:E.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:true,message:E.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:E.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:E.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:true,value:Number.MIN_SAFE_INTEGER,message:E.toString(e)})._addCheck({kind:"max",inclusive:true,value:Number.MAX_SAFE_INTEGER,message:E.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return !!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&F.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return true;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);}return Number.isFinite(t)&&Number.isFinite(e)}};st.create=s=>new st({checks:[],typeName:P.ZodNumber,coerce:s?.coerce||false,...R(s)});var nt=class s extends O{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte;}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data);}catch{return this._getInvalidInput(e)}if(this._getType(e)!==_.bigint)return this._getInvalidInput(e);let n,r=new fe;for(let o of this._def.checks)o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(n=this._getOrReturnCtx(e,n),$(n,{code:w.too_small,type:"bigint",minimum:o.value,inclusive:o.inclusive,message:o.message}),r.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(n=this._getOrReturnCtx(e,n),$(n,{code:w.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),r.dirty()):o.kind==="multipleOf"?e.data%o.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),$(n,{code:w.not_multiple_of,multipleOf:o.value,message:o.message}),r.dirty()):F.assertNever(o);return {status:r.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return $(t,{code:w.invalid_type,expected:_.bigint,received:t.parsedType}),D}gte(e,t){return this.setLimit("min",e,true,E.toString(t))}gt(e,t){return this.setLimit("min",e,false,E.toString(t))}lte(e,t){return this.setLimit("max",e,true,E.toString(t))}lt(e,t){return this.setLimit("max",e,false,E.toString(t))}setLimit(e,t,n,r){return new s({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:E.toString(r)}]})}_addCheck(e){return new s({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:false,message:E.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:false,message:E.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:true,message:E.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:true,message:E.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:E.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};nt.create=s=>new nt({checks:[],typeName:P.ZodBigInt,coerce:s?.coerce??false,...R(s)});var rt=class extends O{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==_.boolean){let n=this._getOrReturnCtx(e);return $(n,{code:w.invalid_type,expected:_.boolean,received:n.parsedType}),D}return he(e.data)}};rt.create=s=>new rt({typeName:P.ZodBoolean,coerce:s?.coerce||false,...R(s)});var ot=class s extends O{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==_.date){let o=this._getOrReturnCtx(e);return $(o,{code:w.invalid_type,expected:_.date,received:o.parsedType}),D}if(Number.isNaN(e.data.getTime())){let o=this._getOrReturnCtx(e);return $(o,{code:w.invalid_date}),D}let n=new fe,r;for(let o of this._def.checks)o.kind==="min"?e.data.getTime()<o.value&&(r=this._getOrReturnCtx(e,r),$(r,{code:w.too_small,message:o.message,inclusive:true,exact:false,minimum:o.value,type:"date"}),n.dirty()):o.kind==="max"?e.data.getTime()>o.value&&(r=this._getOrReturnCtx(e,r),$(r,{code:w.too_big,message:o.message,inclusive:true,exact:false,maximum:o.value,type:"date"}),n.dirty()):F.assertNever(o);return {status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new s({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:E.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:E.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}};ot.create=s=>new ot({checks:[],coerce:s?.coerce||false,typeName:P.ZodDate,...R(s)});var kt=class extends O{_parse(e){if(this._getType(e)!==_.symbol){let n=this._getOrReturnCtx(e);return $(n,{code:w.invalid_type,expected:_.symbol,received:n.parsedType}),D}return he(e.data)}};kt.create=s=>new kt({typeName:P.ZodSymbol,...R(s)});var it=class extends O{_parse(e){if(this._getType(e)!==_.undefined){let n=this._getOrReturnCtx(e);return $(n,{code:w.invalid_type,expected:_.undefined,received:n.parsedType}),D}return he(e.data)}};it.create=s=>new it({typeName:P.ZodUndefined,...R(s)});var at=class extends O{_parse(e){if(this._getType(e)!==_.null){let n=this._getOrReturnCtx(e);return $(n,{code:w.invalid_type,expected:_.null,received:n.parsedType}),D}return he(e.data)}};at.create=s=>new at({typeName:P.ZodNull,...R(s)});var qe=class extends O{constructor(){super(...arguments),this._any=true;}_parse(e){return he(e.data)}};qe.create=s=>new qe({typeName:P.ZodAny,...R(s)});var We=class extends O{constructor(){super(...arguments),this._unknown=true;}_parse(e){return he(e.data)}};We.create=s=>new We({typeName:P.ZodUnknown,...R(s)});var Oe=class extends O{_parse(e){let t=this._getOrReturnCtx(e);return $(t,{code:w.invalid_type,expected:_.never,received:t.parsedType}),D}};Oe.create=s=>new Oe({typeName:P.ZodNever,...R(s)});var $t=class extends O{_parse(e){if(this._getType(e)!==_.undefined){let n=this._getOrReturnCtx(e);return $(n,{code:w.invalid_type,expected:_.void,received:n.parsedType}),D}return he(e.data)}};$t.create=s=>new $t({typeName:P.ZodVoid,...R(s)});var Ue=class s extends O{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==_.array)return $(t,{code:w.invalid_type,expected:_.array,received:t.parsedType}),D;if(r.exactLength!==null){let a=t.data.length>r.exactLength.value,i=t.data.length<r.exactLength.value;(a||i)&&($(t,{code:a?w.too_big:w.too_small,minimum:i?r.exactLength.value:void 0,maximum:a?r.exactLength.value:void 0,type:"array",inclusive:true,exact:true,message:r.exactLength.message}),n.dirty());}if(r.minLength!==null&&t.data.length<r.minLength.value&&($(t,{code:w.too_small,minimum:r.minLength.value,type:"array",inclusive:true,exact:false,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&($(t,{code:w.too_big,maximum:r.maxLength.value,type:"array",inclusive:true,exact:false,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((a,i)=>r.type._parseAsync(new Te(t,a,t.path,i)))).then(a=>fe.mergeArray(n,a));let o=[...t.data].map((a,i)=>r.type._parseSync(new Te(t,a,t.path,i)));return fe.mergeArray(n,o)}get element(){return this._def.type}min(e,t){return new s({...this._def,minLength:{value:e,message:E.toString(t)}})}max(e,t){return new s({...this._def,maxLength:{value:e,message:E.toString(t)}})}length(e,t){return new s({...this._def,exactLength:{value:e,message:E.toString(t)}})}nonempty(e){return this.min(1,e)}};Ue.create=(s,e)=>new Ue({type:s,minLength:null,maxLength:null,exactLength:null,typeName:P.ZodArray,...R(e)});function Ct(s){if(s instanceof Ce){let e={};for(let t in s.shape){let n=s.shape[t];e[t]=Ae.create(Ct(n));}return new Ce({...s._def,shape:()=>e})}else return s instanceof Ue?new Ue({...s._def,type:Ct(s.element)}):s instanceof Ae?Ae.create(Ct(s.unwrap())):s instanceof Me?Me.create(Ct(s.unwrap())):s instanceof Le?Le.create(s.items.map(e=>Ct(e))):s}var Ce=class s extends O{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend;}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=F.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==_.object){let c=this._getOrReturnCtx(e);return $(c,{code:w.invalid_type,expected:_.object,received:c.parsedType}),D}let{status:n,ctx:r}=this._processInputParams(e),{shape:o,keys:a}=this._getCached(),i=[];if(!(this._def.catchall instanceof Oe&&this._def.unknownKeys==="strip"))for(let c in r.data)a.includes(c)||i.push(c);let l=[];for(let c of a){let d=o[c],u=r.data[c];l.push({key:{status:"valid",value:c},value:d._parse(new Te(r,u,r.path,c)),alwaysSet:c in r.data});}if(this._def.catchall instanceof Oe){let c=this._def.unknownKeys;if(c==="passthrough")for(let d of i)l.push({key:{status:"valid",value:d},value:{status:"valid",value:r.data[d]}});else if(c==="strict")i.length>0&&($(r,{code:w.unrecognized_keys,keys:i}),n.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else {let c=this._def.catchall;for(let d of i){let u=r.data[d];l.push({key:{status:"valid",value:d},value:c._parse(new Te(r,u,r.path,d)),alwaysSet:d in r.data});}}return r.common.async?Promise.resolve().then(async()=>{let c=[];for(let d of l){let u=await d.key,h=await d.value;c.push({key:u,value:h,alwaysSet:d.alwaysSet});}return c}).then(c=>fe.mergeObjectSync(n,c)):fe.mergeObjectSync(n,l)}get shape(){return this._def.shape()}strict(e){return E.errToObj,new s({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{let r=this._def.errorMap?.(t,n).message??n.defaultError;return t.code==="unrecognized_keys"?{message:E.errToObj(e).message??r}:{message:r}}}:{}})}strip(){return new s({...this._def,unknownKeys:"strip"})}passthrough(){return new s({...this._def,unknownKeys:"passthrough"})}extend(e){return new s({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new s({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:P.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new s({...this._def,catchall:e})}pick(e){let t={};for(let n of F.objectKeys(e))e[n]&&this.shape[n]&&(t[n]=this.shape[n]);return new s({...this._def,shape:()=>t})}omit(e){let t={};for(let n of F.objectKeys(this.shape))e[n]||(t[n]=this.shape[n]);return new s({...this._def,shape:()=>t})}deepPartial(){return Ct(this)}partial(e){let t={};for(let n of F.objectKeys(this.shape)){let r=this.shape[n];e&&!e[n]?t[n]=r:t[n]=r.optional();}return new s({...this._def,shape:()=>t})}required(e){let t={};for(let n of F.objectKeys(this.shape))if(e&&!e[n])t[n]=this.shape[n];else {let o=this.shape[n];for(;o instanceof Ae;)o=o._def.innerType;t[n]=o;}return new s({...this._def,shape:()=>t})}keyof(){return jn(F.objectKeys(this.shape))}};Ce.create=(s,e)=>new Ce({shape:()=>s,unknownKeys:"strip",catchall:Oe.create(),typeName:P.ZodObject,...R(e)});Ce.strictCreate=(s,e)=>new Ce({shape:()=>s,unknownKeys:"strict",catchall:Oe.create(),typeName:P.ZodObject,...R(e)});Ce.lazycreate=(s,e)=>new Ce({shape:s,unknownKeys:"strip",catchall:Oe.create(),typeName:P.ZodObject,...R(e)});var ct=class extends O{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function r(o){for(let i of o)if(i.result.status==="valid")return i.result;for(let i of o)if(i.result.status==="dirty")return t.common.issues.push(...i.ctx.common.issues),i.result;let a=o.map(i=>new Se(i.ctx.common.issues));return $(t,{code:w.invalid_union,unionErrors:a}),D}if(t.common.async)return Promise.all(n.map(async o=>{let a={...t,common:{...t.common,issues:[]},parent:null};return {result:await o._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(r);{let o,a=[];for(let l of n){let c={...t,common:{...t.common,issues:[]},parent:null},d=l._parseSync({data:t.data,path:t.path,parent:c});if(d.status==="valid")return d;d.status==="dirty"&&!o&&(o={result:d,ctx:c}),c.common.issues.length&&a.push(c.common.issues);}if(o)return t.common.issues.push(...o.ctx.common.issues),o.result;let i=a.map(l=>new Se(l));return $(t,{code:w.invalid_union,unionErrors:i}),D}}get options(){return this._def.options}};ct.create=(s,e)=>new ct({options:s,typeName:P.ZodUnion,...R(e)});var He=s=>s instanceof dt?He(s.schema):s instanceof De?He(s.innerType()):s instanceof ut?[s.value]:s instanceof pt?s.options:s instanceof ft?F.objectValues(s.enum):s instanceof mt?He(s._def.innerType):s instanceof it?[void 0]:s instanceof at?[null]:s instanceof Ae?[void 0,...He(s.unwrap())]:s instanceof Me?[null,...He(s.unwrap())]:s instanceof Lt||s instanceof ht?He(s.unwrap()):s instanceof gt?He(s._def.innerType):[],os=class s extends O{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==_.object)return $(t,{code:w.invalid_type,expected:_.object,received:t.parsedType}),D;let n=this.discriminator,r=t.data[n],o=this.optionsMap.get(r);return o?t.common.async?o._parseAsync({data:t.data,path:t.path,parent:t}):o._parseSync({data:t.data,path:t.path,parent:t}):($(t,{code:w.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),D)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){let r=new Map;for(let o of t){let a=He(o.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let i of a){if(r.has(i))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(i)}`);r.set(i,o);}}return new s({typeName:P.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:r,...R(n)})}};function Ms(s,e){let t=Fe(s),n=Fe(e);if(s===e)return {valid:true,data:s};if(t===_.object&&n===_.object){let r=F.objectKeys(e),o=F.objectKeys(s).filter(i=>r.indexOf(i)!==-1),a={...s,...e};for(let i of o){let l=Ms(s[i],e[i]);if(!l.valid)return {valid:false};a[i]=l.data;}return {valid:true,data:a}}else if(t===_.array&&n===_.array){if(s.length!==e.length)return {valid:false};let r=[];for(let o=0;o<s.length;o++){let a=s[o],i=e[o],l=Ms(a,i);if(!l.valid)return {valid:false};r.push(l.data);}return {valid:true,data:r}}else return t===_.date&&n===_.date&&+s==+e?{valid:true,data:s}:{valid:false}}var lt=class extends O{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(o,a)=>{if(ns(o)||ns(a))return D;let i=Ms(o.value,a.value);return i.valid?((rs(o)||rs(a))&&t.dirty(),{status:t.value,value:i.data}):($(n,{code:w.invalid_intersection_types}),D)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([o,a])=>r(o,a)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};lt.create=(s,e,t)=>new lt({left:s,right:e,typeName:P.ZodIntersection,...R(t)});var Le=class s extends O{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==_.array)return $(n,{code:w.invalid_type,expected:_.array,received:n.parsedType}),D;if(n.data.length<this._def.items.length)return $(n,{code:w.too_small,minimum:this._def.items.length,inclusive:true,exact:false,type:"array"}),D;!this._def.rest&&n.data.length>this._def.items.length&&($(n,{code:w.too_big,maximum:this._def.items.length,inclusive:true,exact:false,type:"array"}),t.dirty());let o=[...n.data].map((a,i)=>{let l=this._def.items[i]||this._def.rest;return l?l._parse(new Te(n,a,n.path,i)):null}).filter(a=>!!a);return n.common.async?Promise.all(o).then(a=>fe.mergeArray(t,a)):fe.mergeArray(t,o)}get items(){return this._def.items}rest(e){return new s({...this._def,rest:e})}};Le.create=(s,e)=>{if(!Array.isArray(s))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Le({items:s,typeName:P.ZodTuple,rest:null,...R(e)})};var is=class s extends O{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==_.object)return $(n,{code:w.invalid_type,expected:_.object,received:n.parsedType}),D;let r=[],o=this._def.keyType,a=this._def.valueType;for(let i in n.data)r.push({key:o._parse(new Te(n,i,n.path,i)),value:a._parse(new Te(n,n.data[i],n.path,i)),alwaysSet:i in n.data});return n.common.async?fe.mergeObjectAsync(t,r):fe.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof O?new s({keyType:e,valueType:t,typeName:P.ZodRecord,...R(n)}):new s({keyType:Ze.create(),valueType:e,typeName:P.ZodRecord,...R(t)})}},_t=class extends O{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==_.map)return $(n,{code:w.invalid_type,expected:_.map,received:n.parsedType}),D;let r=this._def.keyType,o=this._def.valueType,a=[...n.data.entries()].map(([i,l],c)=>({key:r._parse(new Te(n,i,n.path,[c,"key"])),value:o._parse(new Te(n,l,n.path,[c,"value"]))}));if(n.common.async){let i=new Map;return Promise.resolve().then(async()=>{for(let l of a){let c=await l.key,d=await l.value;if(c.status==="aborted"||d.status==="aborted")return D;(c.status==="dirty"||d.status==="dirty")&&t.dirty(),i.set(c.value,d.value);}return {status:t.value,value:i}})}else {let i=new Map;for(let l of a){let c=l.key,d=l.value;if(c.status==="aborted"||d.status==="aborted")return D;(c.status==="dirty"||d.status==="dirty")&&t.dirty(),i.set(c.value,d.value);}return {status:t.value,value:i}}}};_t.create=(s,e,t)=>new _t({valueType:e,keyType:s,typeName:P.ZodMap,...R(t)});var Et=class s extends O{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==_.set)return $(n,{code:w.invalid_type,expected:_.set,received:n.parsedType}),D;let r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&($(n,{code:w.too_small,minimum:r.minSize.value,type:"set",inclusive:true,exact:false,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&($(n,{code:w.too_big,maximum:r.maxSize.value,type:"set",inclusive:true,exact:false,message:r.maxSize.message}),t.dirty());let o=this._def.valueType;function a(l){let c=new Set;for(let d of l){if(d.status==="aborted")return D;d.status==="dirty"&&t.dirty(),c.add(d.value);}return {status:t.value,value:c}}let i=[...n.data.values()].map((l,c)=>o._parse(new Te(n,l,n.path,c)));return n.common.async?Promise.all(i).then(l=>a(l)):a(i)}min(e,t){return new s({...this._def,minSize:{value:e,message:E.toString(t)}})}max(e,t){return new s({...this._def,maxSize:{value:e,message:E.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Et.create=(s,e)=>new Et({valueType:s,minSize:null,maxSize:null,typeName:P.ZodSet,...R(e)});var as=class s extends O{constructor(){super(...arguments),this.validate=this.implement;}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==_.function)return $(t,{code:w.invalid_type,expected:_.function,received:t.parsedType}),D;function n(i,l){return Ft({data:i,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,wt(),Be].filter(c=>!!c),issueData:{code:w.invalid_arguments,argumentsError:l}})}function r(i,l){return Ft({data:i,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,wt(),Be].filter(c=>!!c),issueData:{code:w.invalid_return_type,returnTypeError:l}})}let o={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof Ke){let i=this;return he(async function(...l){let c=new Se([]),d=await i._def.args.parseAsync(l,o).catch(g=>{throw c.addIssue(n(l,g)),c}),u=await Reflect.apply(a,this,d);return await i._def.returns._def.type.parseAsync(u,o).catch(g=>{throw c.addIssue(r(u,g)),c})})}else {let i=this;return he(function(...l){let c=i._def.args.safeParse(l,o);if(!c.success)throw new Se([n(l,c.error)]);let d=Reflect.apply(a,this,c.data),u=i._def.returns.safeParse(d,o);if(!u.success)throw new Se([r(d,u.error)]);return u.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new s({...this._def,args:Le.create(e).rest(We.create())})}returns(e){return new s({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new s({args:e||Le.create([]).rest(We.create()),returns:t||We.create(),typeName:P.ZodFunction,...R(n)})}},dt=class extends O{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};dt.create=(s,e)=>new dt({getter:s,typeName:P.ZodLazy,...R(e)});var ut=class extends O{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return $(t,{received:t.data,code:w.invalid_literal,expected:this._def.value}),D}return {status:"valid",value:e.data}}get value(){return this._def.value}};ut.create=(s,e)=>new ut({value:s,typeName:P.ZodLiteral,...R(e)});function jn(s,e){return new pt({values:s,typeName:P.ZodEnum,...R(e)})}var pt=class s extends O{_parse(e){if(typeof e.data!="string"){let t=this._getOrReturnCtx(e),n=this._def.values;return $(t,{expected:F.joinValues(n),received:t.parsedType,code:w.invalid_type}),D}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return $(t,{received:t.data,code:w.invalid_enum_value,options:n}),D}return he(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return s.create(e,{...this._def,...t})}exclude(e,t=this._def){return s.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}};pt.create=jn;var ft=class extends O{_parse(e){let t=F.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==_.string&&n.parsedType!==_.number){let r=F.objectValues(t);return $(n,{expected:F.joinValues(r),received:n.parsedType,code:w.invalid_type}),D}if(this._cache||(this._cache=new Set(F.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let r=F.objectValues(t);return $(n,{received:n.data,code:w.invalid_enum_value,options:r}),D}return he(e.data)}get enum(){return this._def.values}};ft.create=(s,e)=>new ft({values:s,typeName:P.ZodNativeEnum,...R(e)});var Ke=class extends O{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==_.promise&&t.common.async===false)return $(t,{code:w.invalid_type,expected:_.promise,received:t.parsedType}),D;let n=t.parsedType===_.promise?t.data:Promise.resolve(t.data);return he(n.then(r=>this._def.type.parseAsync(r,{path:t.path,errorMap:t.common.contextualErrorMap})))}};Ke.create=(s,e)=>new Ke({type:s,typeName:P.ZodPromise,...R(e)});var De=class extends O{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===P.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,o={addIssue:a=>{$(n,a),a.fatal?t.abort():t.dirty();},get path(){return n.path}};if(o.addIssue=o.addIssue.bind(o),r.type==="preprocess"){let a=r.transform(n.data,o);if(n.common.async)return Promise.resolve(a).then(async i=>{if(t.value==="aborted")return D;let l=await this._def.schema._parseAsync({data:i,path:n.path,parent:n});return l.status==="aborted"?D:l.status==="dirty"?tt(l.value):t.value==="dirty"?tt(l.value):l});{if(t.value==="aborted")return D;let i=this._def.schema._parseSync({data:a,path:n.path,parent:n});return i.status==="aborted"?D:i.status==="dirty"?tt(i.value):t.value==="dirty"?tt(i.value):i}}if(r.type==="refinement"){let a=i=>{let l=r.refinement(i,o);if(n.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return i};if(n.common.async===false){let i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?D:(i.status==="dirty"&&t.dirty(),a(i.value),{status:t.value,value:i.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>i.status==="aborted"?D:(i.status==="dirty"&&t.dirty(),a(i.value).then(()=>({status:t.value,value:i.value}))))}if(r.type==="transform")if(n.common.async===false){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Ge(a))return D;let i=r.transform(a.value,o);if(i instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return {status:t.value,value:i}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>Ge(a)?Promise.resolve(r.transform(a.value,o)).then(i=>({status:t.value,value:i})):D);F.assertNever(r);}};De.create=(s,e,t)=>new De({schema:s,typeName:P.ZodEffects,effect:e,...R(t)});De.createWithPreprocess=(s,e,t)=>new De({schema:e,effect:{type:"preprocess",transform:s},typeName:P.ZodEffects,...R(t)});var Ae=class extends O{_parse(e){return this._getType(e)===_.undefined?he(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Ae.create=(s,e)=>new Ae({innerType:s,typeName:P.ZodOptional,...R(e)});var Me=class extends O{_parse(e){return this._getType(e)===_.null?he(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Me.create=(s,e)=>new Me({innerType:s,typeName:P.ZodNullable,...R(e)});var mt=class extends O{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===_.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};mt.create=(s,e)=>new mt({innerType:s,typeName:P.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...R(e)});var gt=class extends O{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return St(r)?r.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new Se(n.common.issues)},input:n.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new Se(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};gt.create=(s,e)=>new gt({innerType:s,typeName:P.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...R(e)});var At=class extends O{_parse(e){if(this._getType(e)!==_.nan){let n=this._getOrReturnCtx(e);return $(n,{code:w.invalid_type,expected:_.nan,received:n.parsedType}),D}return {status:"valid",value:e.data}}};At.create=s=>new At({typeName:P.ZodNaN,...R(s)});var Ui=Symbol("zod_brand"),Lt=class extends O{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},Mt=class s extends O{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return (async()=>{let o=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?D:o.status==="dirty"?(t.dirty(),tt(o.value)):this._def.out._parseAsync({data:o.value,path:n.path,parent:n})})();{let r=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return r.status==="aborted"?D:r.status==="dirty"?(t.dirty(),{status:"dirty",value:r.value}):this._def.out._parseSync({data:r.value,path:n.path,parent:n})}}static create(e,t){return new s({in:e,out:t,typeName:P.ZodPipeline})}},ht=class extends O{_parse(e){let t=this._def.innerType._parse(e),n=r=>(Ge(r)&&(r.value=Object.freeze(r.value)),r);return St(t)?t.then(r=>n(r)):n(t)}unwrap(){return this._def.innerType}};ht.create=(s,e)=>new ht({innerType:s,typeName:P.ZodReadonly,...R(e)});function Dn(s,e){let t=typeof s=="function"?s(e):typeof s=="string"?{message:s}:s;return typeof t=="string"?{message:t}:t}function On(s,e={},t){return s?qe.create().superRefine((n,r)=>{let o=s(n);if(o instanceof Promise)return o.then(a=>{if(!a){let i=Dn(e,n),l=i.fatal??t??true;r.addIssue({code:"custom",...i,fatal:l});}});if(!o){let a=Dn(e,n),i=a.fatal??t??true;r.addIssue({code:"custom",...a,fatal:i});}}):qe.create()}var Vi={object:Ce.lazycreate},P;(function(s){s.ZodString="ZodString",s.ZodNumber="ZodNumber",s.ZodNaN="ZodNaN",s.ZodBigInt="ZodBigInt",s.ZodBoolean="ZodBoolean",s.ZodDate="ZodDate",s.ZodSymbol="ZodSymbol",s.ZodUndefined="ZodUndefined",s.ZodNull="ZodNull",s.ZodAny="ZodAny",s.ZodUnknown="ZodUnknown",s.ZodNever="ZodNever",s.ZodVoid="ZodVoid",s.ZodArray="ZodArray",s.ZodObject="ZodObject",s.ZodUnion="ZodUnion",s.ZodDiscriminatedUnion="ZodDiscriminatedUnion",s.ZodIntersection="ZodIntersection",s.ZodTuple="ZodTuple",s.ZodRecord="ZodRecord",s.ZodMap="ZodMap",s.ZodSet="ZodSet",s.ZodFunction="ZodFunction",s.ZodLazy="ZodLazy",s.ZodLiteral="ZodLiteral",s.ZodEnum="ZodEnum",s.ZodEffects="ZodEffects",s.ZodNativeEnum="ZodNativeEnum",s.ZodOptional="ZodOptional",s.ZodNullable="ZodNullable",s.ZodDefault="ZodDefault",s.ZodCatch="ZodCatch",s.ZodPromise="ZodPromise",s.ZodBranded="ZodBranded",s.ZodPipeline="ZodPipeline",s.ZodReadonly="ZodReadonly";})(P||(P={}));var Gi=(s,e={message:`Input not instance of ${s.name}`})=>On(t=>t instanceof s,e),Nn=Ze.create,Fn=st.create,Zi=At.create,qi=nt.create,Ln=rt.create,Ki=ot.create,Ji=kt.create,Yi=it.create,Xi=at.create,Qi=qe.create,ea=We.create,ta=Oe.create,sa=$t.create,na=Ue.create,ra=Ce.create,oa=Ce.strictCreate,ia=ct.create,aa=os.create,ca=lt.create,la=Le.create,da=is.create,ua=_t.create,pa=Et.create,fa=as.create,ma=dt.create,ga=ut.create,ha=pt.create,ya=ft.create,va=Ke.create,xa=De.create,ba=Ae.create,wa=Me.create,Sa=De.createWithPreprocess,Ca=Mt.create,ka=()=>Nn().optional(),$a=()=>Fn().optional(),_a=()=>Ln().optional(),Ea={string:(s=>Ze.create({...s,coerce:true})),number:(s=>st.create({...s,coerce:true})),boolean:(s=>rt.create({...s,coerce:true})),bigint:(s=>nt.create({...s,coerce:true})),date:(s=>ot.create({...s,coerce:true}))};var Aa=D;var Ta=p.enum(["component","hook","service","utility","feature","route","module","config","asset","test","unknown"]),Da=p.enum(["imports","calls","extends","implements","uses"]),Ia=p.object({complexity:p.number().nullable().default(null),linesOfCode:p.number().default(0),dependencyCount:p.number().default(0),dependentCount:p.number().default(0),exportCount:p.number().default(0),importCount:p.number().default(0)}),Pa=p.object({id:p.string(),path:p.string(),absolutePath:p.string().optional(),name:p.string(),type:Ta,language:p.string(),feature:p.string().optional(),layer:p.string().optional(),metrics:Ia,metadata:p.record(p.unknown()).default({})}),Ra=p.object({source:p.string(),target:p.string(),type:Da.default("imports"),isExternal:p.boolean().default(false),specifiers:p.array(p.string()).default([]),isTypeOnly:p.boolean().default(false),isDynamic:p.boolean().default(false)});p.object({version:p.string().default("1.0.0"),nodes:p.record(Pa),edges:p.array(Ra),rootPath:p.string(),timestamp:p.string()});var ja=p.enum(["nextjs","react","vite","vue","nuxt","angular","svelte","sveltekit","astro","remix","express","nest","fastify","node","unknown"]),Oa=p.enum(["pnpm","npm","yarn","bun","unknown"]),Na=p.enum(["TypeScript","JavaScript","Mixed","unknown"]),Fa=p.object({name:p.string(),rootDir:p.string(),framework:ja,frameworkVersion:p.string().optional(),language:Na,packageManager:Oa,runtime:p.string().default("node"),isMonorepo:p.boolean().default(false),workspaces:p.array(p.string()).default([])}),La=p.object({appRouter:p.boolean().default(false),pagesRouter:p.boolean().default(false),react:p.boolean().default(false),tailwind:p.boolean().default(false),zustand:p.boolean().default(false),tanstackQuery:p.boolean().default(false),redux:p.boolean().default(false),prisma:p.boolean().default(false),drizzle:p.boolean().default(false),testingFramework:p.string().nullable().default(null),featureModules:p.enum(["full","partial","none"]).default("none"),detectedLibraries:p.array(p.string()).default([])}),Ma=p.object({sourceFiles:p.number().default(0),totalFiles:p.number().default(0),components:p.number().default(0),hooks:p.number().default(0),services:p.number().default(0),utilities:p.number().default(0),routes:p.number().default(0),tests:p.number().default(0),configs:p.number().default(0),features:p.number().default(0),linesOfCode:p.number().default(0)}),za=p.object({prefix:p.string(),targets:p.array(p.string())}),Ba=p.object({exists:p.boolean().default(false),configPath:p.string().optional(),target:p.string().optional(),module:p.string().optional(),strict:p.boolean().optional(),pathAliases:p.array(za).default([])});p.object({version:p.string().default("1.0.0"),timestamp:p.string(),project:Fa,detected:La,stats:Ma,entryPoints:p.array(p.string()).default([]),typeScript:Ba,packageJson:p.record(p.unknown()).optional()});var zs=p.enum(["error","warning","info"]),Ha=p.object({startLine:p.number(),startColumn:p.number().optional(),endLine:p.number(),endColumn:p.number().optional()});p.object({id:p.string(),ruleId:p.string(),severity:zs,message:p.string(),filePath:p.string(),location:Ha.optional(),evidence:p.array(p.string()).default([]),suggestion:p.string().optional(),dimension:p.enum(["architecture","complexity","dependencies","duplication","maintainability","testing"]).default("architecture")});var Mn=p.enum(["feature-sliced","clean-architecture","layered","modular-monolith","custom","recommended"]),zn=p.union([zs,p.enum(["off"]),p.object({severity:zs,options:p.record(p.unknown()).optional()})]);var Tt=p.object({score:p.number().min(0).max(100).nullable(),status:p.enum(["healthy","warning","critical","unmeasured"]),weight:p.number().min(0).max(1),issueCount:p.number().default(0),summary:p.string().optional()});p.object({overallScore:p.number().min(0).max(100),status:p.enum(["healthy","warning","critical"]),grade:p.enum(["A","B","C","D","F"]),dimensions:p.object({architecture:Tt,complexity:Tt,dependencies:Tt,duplication:Tt,maintainability:Tt,testing:Tt}),metrics:p.object({totalIssues:p.number(),errorCount:p.number(),warningCount:p.number(),infoCount:p.number(),circularDependencies:p.number(),highComplexityCount:p.number(),duplicateBlocksCount:p.number()}),evaluatedAt:p.string()});var Wa=p.enum(["LOW","MEDIUM","HIGH","CRITICAL"]);p.object({target:p.string(),isDirectTarget:p.boolean().default(true),directDependents:p.array(p.string()).default([]),transitiveDependents:p.array(p.string()).default([]),affectedFeatures:p.array(p.string()).default([]),criticalPaths:p.number().default(0),riskAssessment:Wa,affectedModules:p.array(p.string()).default([]),suggestedChecks:p.array(p.string()).default([]),potentialConcerns:p.array(p.string()).default([]),dependencyDistanceMax:p.number().default(0),timestamp:p.string()});var Bs=p.object({$schema:p.string().optional(),version:p.number().default(1),project:p.object({name:p.string().optional(),framework:p.string().default("auto"),root:p.string().default(".")}).default({}),analysis:p.object({incremental:p.boolean().default(true),include:p.array(p.string()).default(["src/**","app/**","pages/**","lib/**","components/**","features/**"]),exclude:p.array(p.string()).default(["node_modules/**",".next/**","dist/**","build/**","out/**","coverage/**",".turbo/**",".git/**"]),maxDependencyDepth:p.number().default(20)}).default({}),architecture:p.object({preset:Mn.default("recommended"),layers:p.array(p.string()).optional(),rules:p.record(zn).default({"no-circular-dependencies":"error","no-cross-feature-imports":"error","enforce-public-api":"warning","max-dependency-depth":"warning","no-unresolved-imports":"error"})}).default({}),ai:p.object({enabled:p.boolean().default(false),provider:p.enum(["openai","anthropic","google","local"]).nullable().default(null),model:p.string().optional()}).default({}),guard:p.object({baseline:p.boolean().default(true),failOnNewErrors:p.boolean().default(true),failOnNewWarnings:p.boolean().default(false),ratchetDebt:p.boolean().default(true)}).default({})}),Hs=p.object({version:p.string().default("1.0.0"),createdAt:p.string(),gitCommit:p.string().optional(),issueCounts:p.object({errors:p.number(),warnings:p.number(),circularDependencies:p.number()}),issues:p.array(p.object({ruleId:p.string(),filePath:p.string(),hash:p.string()}))});var ue=".devarchitect",cs="config.json",Bn="baseline.json";function Ua(s){let e=G.join(s,ue,cs);if(pe.existsSync(e))return e;let t=G.join(s,".devarchitectrc.json");return pe.existsSync(t)?t:e}function ke(s){let e=Ua(s);if(!pe.existsSync(e))return {config:{...Ns},configPath:e,isDefault:true};try{let t=pe.readFileSync(e,"utf8"),n=JSON.parse(t);return {config:Bs.parse(n),configPath:e,isDefault:!1}}catch(t){let n=t instanceof Error?t.message:String(t);throw new Error(`Failed to load DevArchitect config from ${e}: ${n}`)}}function Hn(s,e){let t=G.join(s,ue);pe.existsSync(t)||pe.mkdirSync(t,{recursive:true});let n=Bs.parse({...Ns,...e}),r=G.join(t,cs);return pe.writeFileSync(r,JSON.stringify(n,null,2)+`
|
|
4
|
+
`,"utf8"),r}function Wn(s){let e=G.join(s,ue,Bn);if(!pe.existsSync(e))return null;try{let t=pe.readFileSync(e,"utf8"),n=JSON.parse(t);return Hs.parse(n)}catch{return null}}function Un(s,e){let t=G.join(s,ue);pe.existsSync(t)||pe.mkdirSync(t,{recursive:true});let n=Hs.parse(e),r=G.join(t,Bn);return pe.writeFileSync(r,JSON.stringify(n,null,2)+`
|
|
5
|
+
`,"utf8"),r}var ls=class{cacheFilePath;entries=new Map;dirty=false;constructor(e){this.cacheFilePath=G.join(e,ue,"cache","ast-cache.json"),this.load();}load(){if(pe.existsSync(this.cacheFilePath))try{let e=pe.readFileSync(this.cacheFilePath,"utf8"),t=JSON.parse(e);if(t&&t.entries)for(let[n,r]of Object.entries(t.entries))this.entries.set(n,r);}catch{this.entries.clear();}}get(e,t){let n=this.entries.get(e);return !n||n.hash!==t?null:n.parsed}set(e,t,n){this.entries.set(e,{hash:t,parsed:n,timestamp:new Date().toISOString()}),this.dirty=true;}prune(e){for(let t of this.entries.keys())e.has(t)||(this.entries.delete(t),this.dirty=true);}save(){if(this.dirty)try{let e=G.dirname(this.cacheFilePath);pe.existsSync(e)||pe.mkdirSync(e,{recursive:!0});let t={version:"1.0.0",entries:Object.fromEntries(this.entries.entries())};pe.writeFileSync(this.cacheFilePath,JSON.stringify(t,null,2),"utf8"),this.dirty=!1;}catch{}}};async function I(s=process.cwd(),e={}){let t=G.resolve(s),{config:n}=ke(t),r=$n(t),o=kn(t),a=_n(t),i=En(t,r),l=await Sn(t,{include:n.analysis.include,exclude:n.analysis.exclude,respectGitignore:e.respectGitignore}),c=new Set(l),d={rootDir:t,packageJson:r.raw,fileList:l,hasFile:v=>c.has(v.replace(/\\/g,"/")),hasDependency:v=>!!r.dependencies[v],hasDevDependency:v=>!!r.devDependencies[v],hasAnyDependency:v=>!!(r.dependencies[v]||r.devDependencies[v])},h=await(e.pluginRegistry||rn).detect(d),g=l.some(v=>v.endsWith(".ts")||v.endsWith(".tsx")),m=l.some(v=>v.endsWith(".js")||v.endsWith(".jsx")),f="unknown";g&&m?f="Mixed":g||o.exists?f="TypeScript":m&&(f="JavaScript");let b=[],x={sourceFiles:0,totalFiles:l.length,components:0,hooks:0,services:0,utilities:0,routes:0,tests:0,configs:0,features:0,linesOfCode:0},k=new Set;for(let v of l){let S=Cn(t,v);switch(b.push(S),(S.language==="typescript"||S.language==="typescript-react"||S.language==="javascript"||S.language==="javascript-react")&&x.sourceFiles++,x.linesOfCode+=S.metrics.linesOfCode,S.feature&&k.add(S.feature),S.type){case "component":x.components++;break;case "hook":x.hooks++;break;case "service":x.services++;break;case "utility":x.utilities++;break;case "route":x.routes++;break;case "test":x.tests++;break;case "config":x.configs++;break}}return x.features=k.size,{discovery:{version:"1.0.0",timestamp:new Date().toISOString(),project:{name:r.name,rootDir:t,framework:h.framework,frameworkVersion:h.frameworkVersion,language:f,packageManager:a,runtime:"node",isMonorepo:i.isMonorepo,workspaces:i.workspaces},detected:{appRouter:h.features?.appRouter??false,pagesRouter:h.features?.pagesRouter??false,react:h.features?.react??false,tailwind:h.features?.tailwind??false,zustand:h.features?.zustand??false,tanstackQuery:h.features?.tanstackQuery??false,redux:h.features?.redux??false,prisma:h.features?.prisma??false,drizzle:h.features?.drizzle??false,testingFramework:h.features?.testingFramework??null,featureModules:h.features?.featureModules??(k.size>0?"partial":"none"),detectedLibraries:Object.keys(r.dependencies)},stats:x,entryPoints:h.entryPoints||[],typeScript:o,packageJson:r.raw},nodes:b}}var ds=class{nodesMap=new Map;edgesList=[];outgoing=new Map;incoming=new Map;constructor(e=[],t=[]){for(let n of e)this.addNode(n);for(let n of t)this.addEdge(n);}addNode(e){this.nodesMap.set(e.id,e),this.outgoing.has(e.id)||this.outgoing.set(e.id,new Set),this.incoming.has(e.id)||this.incoming.set(e.id,new Set);}getNode(e){return this.nodesMap.get(e)}hasNode(e){return this.nodesMap.has(e)}getAllNodes(){return Array.from(this.nodesMap.values())}addEdge(e){this.edgesList.push(e),this.outgoing.has(e.source)||this.outgoing.set(e.source,new Set),this.outgoing.get(e.source).add(e.target),this.incoming.has(e.target)||this.incoming.set(e.target,new Set),this.incoming.get(e.target).add(e.source);}getAllEdges(){return this.edgesList}getDependencies(e){return Array.from(this.outgoing.get(e)||[])}getDependents(e){return Array.from(this.incoming.get(e)||[])}toProjectGraph(e=""){let t={};for(let[n,r]of this.nodesMap.entries())t[n]={...r,metrics:{...r.metrics,dependencyCount:this.outgoing.get(n)?.size||0,dependentCount:this.incoming.get(n)?.size||0}};return {version:"1.0.0",nodes:t,edges:this.edgesList,rootPath:e,timestamp:new Date().toISOString()}}};function Ve(s){let e=s.getAllNodes().map(l=>l.id),t=new Set,n=new Set,r=[],o=[];function a(l){t.add(l),n.add(l),r.push(l);let c=s.getDependencies(l);for(let d of c)if(s.hasNode(d)){if(!t.has(d))a(d);else if(n.has(d)){let u=r.indexOf(d);if(u!==-1){let h=r.slice(u).concat(d);o.push(h);}}}r.pop(),n.delete(l);}for(let l of e)t.has(l)||a(l);let i=new Map;for(let l of o){let c=l.slice(0,-1);if(c.length===0)continue;let d=0;for(let g=1;g<c.length;g++)c[g]<c[d]&&(d=g);let u=[...c.slice(d),...c.slice(0,d)],h=u.join(" -> ");i.has(h)||i.set(h,[...u,u[0]]);}return Array.from(i.entries()).map(([l,c])=>({id:`cycle-${l}`,path:c,length:c.length-1}))}function us(s,e){let t=e.replace(/\\/g,"/"),n=s.getDependents(t),r=new Set,o=[],a=0;for(let x of n)o.push({id:x,distance:1}),r.add(x);for(;o.length>0;){let{id:x,distance:k}=o.shift();k>a&&(a=k);let A=s.getDependents(x);for(let v of A)r.has(v)||(r.add(v),o.push({id:v,distance:k+1}));}let i=Array.from(r),l=new Set,c=new Set;for(let x of i){let k=s.getNode(x);if(k){k.feature&&c.add(k.feature);let A=x.split("/");A.length>1&&l.add(A.slice(0,2).join("/"));}}let d=s.getNode(t);d?.feature&&c.add(d.feature);let u="LOW",h=i.length,g=c.size;h>25||g>=4?u="CRITICAL":h>10||g>=2?u="HIGH":(h>3||g>=1)&&(u="MEDIUM");let m=c.size,f=[];for(let x of c)f.push(`${x} tests & integration flows`);f.length===0&&f.push(`Unit tests for ${d?.name||t}`);let b=[];return i.length>10&&b.push(`${t} has ${i.length} downstream dependents across the codebase.`),g>2&&b.push(`Shared across multiple business-critical features (${Array.from(c).join(", ")}).`),{target:t,isDirectTarget:true,directDependents:n,transitiveDependents:i,affectedFeatures:Array.from(c),criticalPaths:m,riskAssessment:u,affectedModules:Array.from(l),suggestedChecks:f,potentialConcerns:b,dependencyDistanceMax:a,timestamp:new Date().toISOString()}}function Gn(s){let e=s.getAllNodes(),t=s.getAllEdges(),n=["flowchart TD"];for(let r of e){let o=r.id.replace(/[^a-zA-Z0-9_]/g,"_");n.push(` ${o}["${r.name} (${r.type})"]`);}for(let r of t){let o=r.source.replace(/[^a-zA-Z0-9_]/g,"_"),a=r.target.replace(/[^a-zA-Z0-9_]/g,"_");n.push(` ${o} --> ${a}`);}return n.join(`
|
|
6
6
|
`)}function Zn(s){let e=s.getAllNodes(),t=s.getAllEdges(),n=["digraph DevArchitect {"," rankdir=LR;"];for(let r of e){let o=JSON.stringify(r.id),a=`${r.name}\\n(${r.type})`;n.push(` ${o} [label="${a}"];`);}for(let r of t){let o=JSON.stringify(r.source),a=JSON.stringify(r.target);n.push(` ${o} -> ${a};`);}return n.push("}"),n.join(`
|
|
7
|
-
`)}var
|
|
7
|
+
`)}var Ws=class{id="typescript-ast";name="TypeScript / JavaScript AST Parser";supports(e){let t=e.toLowerCase();return t.endsWith(".ts")||t.endsWith(".tsx")||t.endsWith(".js")||t.endsWith(".jsx")||t.endsWith(".mjs")||t.endsWith(".cjs")}parse(e,t){let n=j.ScriptTarget.Latest,r=e.endsWith(".tsx")||e.endsWith(".jsx"),o=j.createSourceFile(e,t,n,true,r?j.ScriptKind.TSX:j.ScriptKind.TS),a=[],i=[],l=[],c=1,d=m=>o.getLineAndCharacterOfPosition(m).line+1,u=m=>{let f=0;switch(m.kind){case j.SyntaxKind.IfStatement:case j.SyntaxKind.ConditionalExpression:case j.SyntaxKind.ForStatement:case j.SyntaxKind.ForInStatement:case j.SyntaxKind.ForOfStatement:case j.SyntaxKind.WhileStatement:case j.SyntaxKind.DoStatement:case j.SyntaxKind.CaseClause:case j.SyntaxKind.CatchClause:f++;break;case j.SyntaxKind.BinaryExpression:{let x=m.operatorToken.kind;(x===j.SyntaxKind.AmpersandAmpersandToken||x===j.SyntaxKind.BarBarToken||x===j.SyntaxKind.QuestionQuestionToken)&&f++;break}}return f},h=m=>{if(c+=u(m),j.isImportDeclaration(m)){let f=m.moduleSpecifier;if(j.isStringLiteral(f)){let b=f.text,x=m.importClause?.isTypeOnly??false,k=[];if(m.importClause&&(m.importClause.name&&k.push({name:m.importClause.name.text,isDefault:true,isTypeOnly:x}),m.importClause.namedBindings)){if(j.isNamespaceImport(m.importClause.namedBindings))k.push({name:m.importClause.namedBindings.name.text,isNamespace:true,isTypeOnly:x});else if(j.isNamedImports(m.importClause.namedBindings))for(let A of m.importClause.namedBindings.elements)k.push({name:A.name.text,alias:A.propertyName?.text,isTypeOnly:A.isTypeOnly||x});}a.push({source:b,specifiers:k,isTypeOnly:x,isDynamic:false,line:d(m.getStart())});}}if(j.isCallExpression(m)&&m.expression.kind===j.SyntaxKind.ImportKeyword){let f=m.arguments[0];f&&j.isStringLiteral(f)&&a.push({source:f.text,specifiers:[],isTypeOnly:false,isDynamic:true,line:d(m.getStart())});}if(j.isExportDeclaration(m)){let f=m.isTypeOnly;if(m.moduleSpecifier&&j.isStringLiteral(m.moduleSpecifier)&&a.push({source:m.moduleSpecifier.text,specifiers:[],isTypeOnly:f,isDynamic:false,line:d(m.getStart())}),m.exportClause&&j.isNamedExports(m.exportClause))for(let b of m.exportClause.elements)i.push({name:b.name.text,isDefault:false,isTypeOnly:b.isTypeOnly||f,line:d(b.getStart())});}if(j.isExportAssignment(m)&&i.push({name:"default",isDefault:true,isTypeOnly:false,line:d(m.getStart())}),j.isFunctionDeclaration(m)){let f=m.name?.text||"anonymous",b=m.modifiers?.some(A=>A.kind===j.SyntaxKind.ExportKeyword)??false,x=m.modifiers?.some(A=>A.kind===j.SyntaxKind.DefaultKeyword)??false,k=1;m.forEachChild(function A(v){k+=u(v),v.forEachChild(A);}),l.push({name:f,kind:"function",line:d(m.getStart()),complexity:k}),b&&(i.push({name:x?"default":f,isDefault:x,isTypeOnly:false,line:d(m.getStart())}),x&&f!=="anonymous"&&i.push({name:f,isDefault:true,isTypeOnly:false,line:d(m.getStart())}));}if(j.isClassDeclaration(m)){let f=m.name?.text||"anonymous",b=m.modifiers?.some(k=>k.kind===j.SyntaxKind.ExportKeyword)??false,x=m.modifiers?.some(k=>k.kind===j.SyntaxKind.DefaultKeyword)??false;l.push({name:f,kind:"class",line:d(m.getStart()),complexity:1}),b&&(i.push({name:x?"default":f,isDefault:x,isTypeOnly:false,line:d(m.getStart())}),x&&f!=="anonymous"&&i.push({name:f,isDefault:true,isTypeOnly:false,line:d(m.getStart())}));}if(j.isVariableStatement(m)){let f=m.modifiers?.some(b=>b.kind===j.SyntaxKind.ExportKeyword)??false;for(let b of m.declarationList.declarations)if(j.isIdentifier(b.name)){let x=b.name.text;l.push({name:x,kind:"variable",line:d(b.getStart()),complexity:1}),f&&i.push({name:x,isDefault:false,isTypeOnly:false,line:d(b.getStart())});}}if(j.isInterfaceDeclaration(m)){let f=m.name.text,b=m.modifiers?.some(x=>x.kind===j.SyntaxKind.ExportKeyword)??false;l.push({name:f,kind:"interface",line:d(m.getStart()),complexity:1}),b&&i.push({name:f,isDefault:false,isTypeOnly:true,line:d(m.getStart())});}if(j.isTypeAliasDeclaration(m)){let f=m.name.text,b=m.modifiers?.some(x=>x.kind===j.SyntaxKind.ExportKeyword)??false;l.push({name:f,kind:"type",line:d(m.getStart()),complexity:1}),b&&i.push({name:f,isDefault:false,isTypeOnly:true,line:d(m.getStart())});}j.forEachChild(m,h);};h(o);let g=t.split(/\r\n|\r|\n/).length;return {filePath:e,imports:a,exports:i,symbols:l,linesOfCode:g,complexity:c}}},Us=new Ws;var ps=class{knownFiles;pathAliases;rootDir;constructor(e,t=[],n=[]){this.rootDir=G.resolve(e),this.knownFiles=new Set(t.map(r=>this.normalize(r))),this.pathAliases=n;}normalize(e){return e.replace(/\\/g,"/")}resolve(e,t){let n=t.startsWith("./")||t.startsWith("../")||t==="."||t==="..",r=this.pathAliases.some(i=>{let l=i.prefix.replace(/\*$/,"");return t.startsWith(l)});if(!n&&!r)return {isExternal:true,target:t};let o=null;if(n){let i=G.dirname(e);o=G.join(i,t);}else if(r)for(let i of this.pathAliases){let l=i.prefix.replace(/\*$/,"");if(t.startsWith(l)){let c=t.slice(l.length),u=(i.targets[0]||"").replace(/\*$/,"");o=G.join(u,c);break}}if(!o)return {isExternal:true,target:t};o=this.normalize(o);let a=["",".ts",".tsx",".js",".jsx","/index.ts","/index.tsx","/index.js","/index.jsx"];if(o.endsWith(".js")||o.endsWith(".jsx")){let i=o.replace(/\.(js|jsx)$/,"");a.unshift(i+".ts",i+".tsx",i+"/index.ts",i+"/index.tsx");}for(let i of a){let l=i.startsWith(o.replace(/\.(js|jsx)$/,""))?i:this.normalize(o+i);if(this.knownFiles.has(l))return {isExternal:false,target:l,resolvedPath:G.resolve(this.rootDir,l)};let c=G.resolve(this.rootDir,l);if(pe.existsSync(c)&&pe.statSync(c).isFile())return {isExternal:false,target:this.normalize(G.relative(this.rootDir,c)),resolvedPath:c}}return {isExternal:false,target:o}}};function Z(s,e,t,n={}){let r=new ls(s),o=e.map(g=>g.path),a=new ps(s,o,t.pathAliases),i=new Map,l=0,c=0;for(let g of e){if(!Us.supports(g.path))continue;let m=G.resolve(s,g.path);if(!pe.existsSync(m))continue;let f=ts(m),b=null;if(n.useCache!==false&&(b=r.get(g.path,f)),b)l++;else {c++;try{let x=pe.readFileSync(m,"utf8");b=Us.parse(g.path,x),n.useCache!==!1&&r.set(g.path,f,b);}catch{continue}}i.set(g.path,b);}n.useCache!==false&&(r.prune(new Set(o)),r.save());let d=[],u=new Map;for(let g of e)u.set(g.path,g);for(let[g,m]of i.entries()){let f=u.get(g);for(let b of m.imports){let x=a.resolve(g,b.source),k={source:g,target:x.target,type:"imports",isExternal:x.isExternal,specifiers:b.specifiers.map(A=>A.name),isTypeOnly:b.isTypeOnly,isDynamic:b.isDynamic};d.push(k);}f&&(f.metrics.complexity=m.complexity,f.metrics.exportCount=m.exports.length,f.metrics.importCount=m.imports.length,f.metadata.exports=m.exports,f.metadata.symbols=m.symbols);}return {graph:new ds(e,d),parsedFiles:i,cacheHits:l,cacheMisses:c}}function Jn(s){try{return execSync("git diff --cached --name-only",{cwd:s,encoding:"utf8",stdio:["pipe","pipe","ignore"]}).split(/\r\n|\r|\n/).map(t=>t.trim().replace(/\\/g,"/")).filter(Boolean)}catch{return []}}function Yn(s,e="main"){try{let t="";try{t=execSync(`git diff --name-only ${e}...HEAD`,{cwd:s,encoding:"utf8",stdio:["pipe","pipe","ignore"]});}catch{t=execSync("git diff --name-only HEAD",{cwd:s,encoding:"utf8",stdio:["pipe","pipe","ignore"]});}return t.split(/\r\n|\r|\n/).map(n=>n.trim().replace(/\\/g,"/")).filter(Boolean)}catch{return []}}function Xn(s,e="origin"){try{let t="";try{t=execSync('git log @{u}..HEAD --name-only --format=""',{cwd:s,encoding:"utf8",stdio:["pipe","pipe","ignore"]});}catch{try{t=execSync(`git log ${e}/main..HEAD --name-only --format=""`,{cwd:s,encoding:"utf8",stdio:["pipe","pipe","ignore"]});}catch{t=execSync("git diff --name-only HEAD~1 HEAD",{cwd:s,encoding:"utf8",stdio:["pipe","pipe","ignore"]});}}let n=new Set(t.split(/\r\n|\r|\n/).map(r=>r.trim().replace(/\\/g,"/")).filter(Boolean));return Array.from(n)}catch{return []}}function Qn(s){let e=G.join(s,".git","hooks");pe.existsSync(e)||pe.mkdirSync(e,{recursive:true});let t=G.join(e,"pre-commit");return pe.writeFileSync(t,`#!/bin/sh
|
|
8
8
|
# DevArchitect Pre-Commit Guard (Local Safety Net)
|
|
9
9
|
echo "\u{1F6E1}\uFE0F DevArchitect: Validating architecture rules on staged changes..."
|
|
10
10
|
|
|
@@ -16,7 +16,7 @@ if command -v devarchitect >/dev/null 2>&1; then
|
|
|
16
16
|
}
|
|
17
17
|
fi
|
|
18
18
|
exit 0
|
|
19
|
-
`,{mode:493}),{success:true,hookPath:t}}function er(s){let e=G.join(s,".git","hooks");
|
|
19
|
+
`,{mode:493}),{success:true,hookPath:t}}function er(s){let e=G.join(s,".git","hooks");pe.existsSync(e)||pe.mkdirSync(e,{recursive:true});let t=G.join(e,"pre-push");return pe.writeFileSync(t,`#!/bin/sh
|
|
20
20
|
# DevArchitect Pre-Push AI Guardrail (Rovo-Style Quality Gate)
|
|
21
21
|
echo "\u{1F680} DevArchitect: Scanning outgoing commits before push..."
|
|
22
22
|
|
|
@@ -29,12 +29,12 @@ if command -v devarchitect >/dev/null 2>&1; then
|
|
|
29
29
|
}
|
|
30
30
|
fi
|
|
31
31
|
exit 0
|
|
32
|
-
`,{mode:493}),{success:true,hookPath:t}}async function tr(s={}){let e=process.cwd(),t=G.join(e,
|
|
32
|
+
`,{mode:493}),{success:true,hookPath:t}}async function tr(s={}){let e=process.cwd(),t=G.join(e,ue,cs);if(console.log(ye.default.bold(ye.default.cyan(`
|
|
33
33
|
DevArchitect \u2014 Project Initialization
|
|
34
|
-
`))),
|
|
35
|
-
`));return}console.log(
|
|
36
|
-
`),console.log(
|
|
37
|
-
`);}var
|
|
34
|
+
`))),pe.existsSync(t)&&!s.force){console.log(ye.default.yellow(` \u26A0 Configuration already exists at ${t}`)),console.log(ye.default.gray(` Use --force to overwrite.
|
|
35
|
+
`));return}console.log(ye.default.gray(" Scanning repository structure..."));let{discovery:n}=await I(e),r=s.preset||"recommended";s.preset||(n.detected.featureModules!=="none"?r="feature-sliced":n.project.framework==="nest"&&(r="clean-architecture"));let o=Hn(e,{project:{name:n.project.name,framework:n.project.framework,root:"."},architecture:{preset:r,rules:{"no-circular-dependencies":"error","no-cross-feature-imports":"error","enforce-public-api":"warning","max-dependency-depth":"warning","no-unresolved-imports":"error"}}}),a=G.join(e,ue,"cache"),i=G.join(e,ue,"reports");pe.existsSync(a)||pe.mkdirSync(a,{recursive:true}),pe.existsSync(i)||pe.mkdirSync(i,{recursive:true}),console.log(ye.default.green(` \u2714 Initialized DevArchitect configuration at ${ye.default.bold(o)}`)),console.log(` ${ye.default.gray("Framework:")} ${ye.default.bold(n.project.framework)}`),console.log(` ${ye.default.gray("Preset:")} ${ye.default.bold(r)}`),console.log(` ${ye.default.gray("Files:")} ${n.stats.totalFiles} detected
|
|
36
|
+
`),console.log(ye.default.cyan(" Next steps:")),console.log(` Run ${ye.default.bold("devarchitect analyze")} to run project discovery`),console.log(` Run ${ye.default.bold("devarchitect doctor")} to inspect project health
|
|
37
|
+
`);}var gs=W(U());var y=W(U());function sr(s){let e=s.project,t=s.detected,n=s.stats;return [y.default.bold(y.default.cyan("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501")),y.default.bold(y.default.cyan(" DEVARCHITECT PROJECT DISCOVERY")),y.default.bold(y.default.cyan("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501")),` ${y.default.gray("Project:")} ${y.default.bold(e.name)}`,` ${y.default.gray("Framework:")} ${y.default.bold(e.framework)}${e.frameworkVersion?y.default.gray(` (${e.frameworkVersion})`):""}`,` ${y.default.gray("Language:")} ${e.language}`,` ${y.default.gray("Package Manager:")} ${e.packageManager}`,` ${y.default.gray("Is Monorepo:")} ${e.isMonorepo?y.default.green("Yes"):y.default.gray("No")}`,"",y.default.bold(" Detected Features:"),` ${y.default.gray("React")} ${t.react?y.default.green("Yes"):y.default.gray("No")}`,` ${y.default.gray("App Router")} ${t.appRouter?y.default.green("Yes"):y.default.gray("No")}`,` ${y.default.gray("Pages Router")} ${t.pagesRouter?y.default.green("Yes"):y.default.gray("No")}`,` ${y.default.gray("Tailwind CSS")} ${t.tailwind?y.default.green("Yes"):y.default.gray("No")}`,` ${y.default.gray("Zustand")} ${t.zustand?y.default.green("Yes"):y.default.gray("No")}`,` ${y.default.gray("TanStack Query")} ${t.tanstackQuery?y.default.green("Yes"):y.default.gray("No")}`,` ${y.default.gray("Redux")} ${t.redux?y.default.green("Yes"):y.default.gray("No")}`,` ${y.default.gray("Feature Modules")} ${t.featureModules==="full"?y.default.green("Full"):t.featureModules==="partial"?y.default.yellow("Partial"):y.default.gray("None")}`,` ${y.default.gray("Testing")} ${t.testingFramework?y.default.green(t.testingFramework):y.default.gray("None detected")}`,"",y.default.bold(" Repository Structure:"),` ${y.default.gray("Source files")} ${n.sourceFiles}`,` ${y.default.gray("Components")} ${n.components}`,` ${y.default.gray("Hooks")} ${n.hooks}`,` ${y.default.gray("Services")} ${n.services}`,` ${y.default.gray("Utilities")} ${n.utilities}`,` ${y.default.gray("Routes")} ${n.routes}`,` ${y.default.gray("Tests")} ${n.tests}`,` ${y.default.gray("Lines of Code")} ${n.linesOfCode.toLocaleString()}`,y.default.bold(y.default.cyan("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501")),y.default.green(" \u2714 Discovery completed successfully.")].join(`
|
|
38
38
|
`)}function nr(s){let e=s.status==="healthy"?y.default.green:s.status==="warning"?y.default.yellow:y.default.red;return [y.default.bold(y.default.cyan("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501")),y.default.bold(y.default.cyan(" DEVARCHITECT CODE HEALTH SCORE")),y.default.bold(y.default.cyan("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501")),` Overall Health: ${e(y.default.bold(`${s.overallScore}/100`))} [${e(s.status.toUpperCase())}] (Grade ${s.grade})`,"",y.default.bold(" Dimensions:"),` ${y.default.gray("Architecture compliance")} ${s.dimensions.architecture.score??"unmeasured"}/100 (weight 25%)`,` ${y.default.gray("Code complexity")} ${s.dimensions.complexity.score??"unmeasured"}/100 (weight 20%)`,` ${y.default.gray("Dependency health")} ${s.dimensions.dependencies.score??"unmeasured"}/100 (weight 15%)`,` ${y.default.gray("Code duplication")} ${s.dimensions.duplication.score??"unmeasured"}/100 (weight 15%)`,` ${y.default.gray("Maintainability")} ${s.dimensions.maintainability.score??"unmeasured"}/100 (weight 15%)`,` ${y.default.gray("Testing confidence")} ${s.dimensions.testing.score!==null?`${s.dimensions.testing.score}/100`:y.default.gray("unmeasured (10%)")}`,"",y.default.bold(" Issues Summary:"),` Total issues: ${s.metrics.totalIssues}`,` Errors: ${s.metrics.errorCount>0?y.default.red(String(s.metrics.errorCount)):y.default.green("0")}`,` Warnings: ${s.metrics.warningCount>0?y.default.yellow(String(s.metrics.warningCount)):y.default.green("0")}`,` Circular imports: ${s.metrics.circularDependencies>0?y.default.red(String(s.metrics.circularDependencies)):y.default.green("0")}`,y.default.bold(y.default.cyan("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"))].join(`
|
|
39
39
|
`)}function rr(s){let e=s.riskAssessment==="CRITICAL"?y.default.bgRed(y.default.white(y.default.bold(" CRITICAL "))):s.riskAssessment==="HIGH"?y.default.red(y.default.bold("HIGH")):s.riskAssessment==="MEDIUM"?y.default.yellow(y.default.bold("MEDIUM")):y.default.green(y.default.bold("LOW")),t=[y.default.bold(y.default.cyan("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501")),y.default.bold(y.default.cyan(" CHANGE IMPACT ANALYSIS")),y.default.bold(y.default.cyan("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501")),` ${y.default.gray("Target:")} ${y.default.bold(s.target)}`,` ${y.default.gray("Direct dependents:")} ${s.directDependents.length}`,` ${y.default.gray("Transitive dependents:")} ${s.transitiveDependents.length}`,` ${y.default.gray("Affected features:")} ${s.affectedFeatures.length}`,` ${y.default.gray("Critical paths:")} ${s.criticalPaths}`,` ${y.default.gray("Risk assessment:")} ${e}`,""];if(s.affectedModules.length>0){t.push(y.default.bold(" Affected Modules:"));for(let n of s.affectedModules)t.push(` \u2022 ${n}`);t.push("");}if(s.suggestedChecks.length>0){t.push(y.default.bold(" Suggested checks:"));for(let n of s.suggestedChecks)t.push(` ${y.default.green("\u2714")} ${n}`);t.push("");}if(s.potentialConcerns.length>0){t.push(y.default.bold(y.default.yellow(" Potential concerns:")));for(let n of s.potentialConcerns)t.push(` \u26A0 ${n}`);t.push("");}return t.push(y.default.bold(y.default.cyan("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"))),t.join(`
|
|
40
40
|
`)}function or(s){if(s.length===0)return y.default.green("\u2714 No architecture policy violations found.");let e=[y.default.bold(`Architecture Violations (${s.length}):`),""];for(let t of s){let n=t.severity==="error"?y.default.red(y.default.bold("[ERROR]")):t.severity==="warning"?y.default.yellow(y.default.bold("[WARN]")):y.default.blue(y.default.bold("[INFO]"));if(e.push(` ${n} ${y.default.bold(t.ruleId)}: ${t.message}`),e.push(` ${y.default.gray("File:")} ${t.filePath}${t.location?`:${t.location.startLine}`:""}`),t.evidence&&t.evidence.length>0)for(let r of t.evidence)e.push(` ${y.default.gray("Evidence:")} ${r}`);t.suggestion&&e.push(` ${y.default.cyan("Suggestion:")} ${t.suggestion}`),e.push("");}return e.join(`
|
|
@@ -190,7 +190,7 @@ exit 0
|
|
|
190
190
|
`:""}
|
|
191
191
|
</body>
|
|
192
192
|
</html>
|
|
193
|
-
`}function ar(s,e={}){let t=e.port||4321,n=
|
|
193
|
+
`}function ar(s,e={}){let t=e.port||4321,n=qa(s);return new Promise((r,o)=>{let a=Za.createServer(async(i,l)=>{let c=new URL(i.url||"/",`http://${i.headers.host||"localhost"}`);if(c.pathname==="/api/data"){l.writeHead(200,{"Content-Type":"application/json","Access-Control-Allow-Origin":"*"}),l.end(JSON.stringify(s));return}if(c.pathname==="/api/ask"){let d=c.searchParams.get("q")||"",u=null;if(e.onAsk&&d.trim())try{u=await e.onAsk(d);}catch(h){u={error:String(h)};}else u={question:d,topic:"Codebase Intelligence",summary:"Enter a question to query the codebase architecture.",flowSteps:[],relatedFiles:[]};l.writeHead(200,{"Content-Type":"application/json","Access-Control-Allow-Origin":"*"}),l.end(JSON.stringify(u));return}l.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),l.end(n);});a.listen(t,()=>{let i=a.address(),l=typeof i=="object"&&i?i.port:t,c=`http://localhost:${l}`;r({port:l,url:c,server:a});}),a.on("error",i=>{o(i);});})}function qa(s){let e=s.discovery.project,t=s.health,n=Array.from(new Set(s.nodes.map(r=>r.feature).filter(Boolean)));return `<!DOCTYPE html>
|
|
194
194
|
<html lang="en">
|
|
195
195
|
<head>
|
|
196
196
|
<meta charset="UTF-8" />
|
|
@@ -1115,63 +1115,63 @@ exit 0
|
|
|
1115
1115
|
});
|
|
1116
1116
|
</script>
|
|
1117
1117
|
</body>
|
|
1118
|
-
</html>`}async function cr(s={}){let e=process.cwd();try{let{discovery:t,nodes:n}=await I(e);if(s.json){let o=JSON.stringify({discovery:t,nodes:n},null,2);s.output?(
|
|
1118
|
+
</html>`}async function cr(s={}){let e=process.cwd();try{let{discovery:t,nodes:n}=await I(e);if(s.json){let o=JSON.stringify({discovery:t,nodes:n},null,2);s.output?(pe.writeFileSync(s.output,o,"utf8"),console.log(gs.default.green(`\u2714 Exported analysis to ${s.output}`))):console.log(o);return}console.log(`
|
|
1119
1119
|
`+sr(t)+`
|
|
1120
|
-
`);let r=G.join(e,
|
|
1121
|
-
`));}}catch(t){let n=t instanceof Error?t.message:String(t);console.error(
|
|
1120
|
+
`);let r=G.join(e,ue,"reports");if(pe.existsSync(r)){let o=G.join(r,"discovery-report.json");pe.writeFileSync(o,JSON.stringify(t,null,2),"utf8");}if(s.html){let o=ir({discovery:t}),a=s.output||G.join(e,ue,"reports","report.html"),i=G.dirname(a);pe.existsSync(i)||pe.mkdirSync(i,{recursive:!0}),pe.writeFileSync(a,o,"utf8"),console.log(gs.default.green(`\u2714 Generated HTML architecture report at ${a}
|
|
1121
|
+
`));}}catch(t){let n=t instanceof Error?t.message:String(t);console.error(gs.default.red(`
|
|
1122
1122
|
\u2716 Analysis failed: ${n}
|
|
1123
|
-
`)),process.exit(1);}}var
|
|
1124
|
-
\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501`))),console.log(
|
|
1125
|
-
`),r.length===0){console.log(
|
|
1123
|
+
`)),process.exit(1);}}var ve=W(U());async function lr(s={}){let e=process.cwd(),{discovery:t,nodes:n}=await I(e),r=n;if(s.type&&(r=r.filter(a=>a.type===s.type)),s.feature&&(r=r.filter(a=>a.feature===s.feature)),console.log(ve.default.bold(ve.default.cyan(`
|
|
1124
|
+
\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501`))),console.log(ve.default.bold(ve.default.cyan(" DEVARCHITECT REPOSITORY INSPECTION"))),console.log(ve.default.bold(ve.default.cyan("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"))),console.log(` Project: ${ve.default.bold(t.project.name)} (${t.project.framework})`),console.log(` Matched items: ${ve.default.bold(String(r.length))}
|
|
1125
|
+
`),r.length===0){console.log(ve.default.yellow(" No matching files found."));return}let o=new Map;for(let a of r)o.has(a.type)||o.set(a.type,[]),o.get(a.type).push(a);for(let[a,i]of o.entries()){console.log(ve.default.bold(` ${a.toUpperCase()} (${i.length}):`));for(let l of i.slice(0,25)){let c=l.feature?ve.default.magenta(` [${l.feature}]`):"",d=l.layer?ve.default.blue(` (${l.layer})`):"";console.log(` \u2022 ${ve.default.white(l.path)}${c}${d} ${ve.default.gray(`${l.metrics.linesOfCode} LOC`)}`);}i.length>25&&console.log(ve.default.gray(` ... and ${i.length-25} more`)),console.log("");}}var M=W(U());async function dr(){let s=process.cwd();console.log(M.default.bold(M.default.cyan(`
|
|
1126
1126
|
\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501`))),console.log(M.default.bold(M.default.cyan(" DEVARCHITECT PROJECT DOCTOR"))),console.log(M.default.bold(M.default.cyan(`\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
|
|
1127
|
-
`)));let {config:e,isDefault:t}=
|
|
1127
|
+
`)));let {config:e,isDefault:t}=ke(s),{discovery:n}=await I(s);console.log(t?` ${M.default.yellow("\u26A0")} ${M.default.bold("Configuration:")} Using defaults. Run ${M.default.cyan("devarchitect init")} to create .devarchitect/config.json`:` ${M.default.green("\u2714")} ${M.default.bold("Configuration:")} Loaded .devarchitect/config.json (preset: ${e.architecture.preset})`),n.typeScript.exists?(console.log(` ${M.default.green("\u2714")} ${M.default.bold("TypeScript:")} Config found at ${n.typeScript.configPath}`),n.typeScript.strict?console.log(` ${M.default.green("\u2714")} Strict mode enabled`):console.log(` ${M.default.yellow("\u26A0")} Strict mode is not enabled`),n.typeScript.pathAliases.length>0&&console.log(` ${M.default.green("\u2714")} Path aliases configured (${n.typeScript.pathAliases.length} aliases)`)):console.log(` ${M.default.yellow("\u26A0")} ${M.default.bold("TypeScript:")} No tsconfig.json detected`),n.project.framework!=="unknown"?console.log(` ${M.default.green("\u2714")} ${M.default.bold("Framework:")} Detected ${M.default.bold(n.project.framework)}${n.project.frameworkVersion?` v${n.project.frameworkVersion}`:""}`):console.log(` ${M.default.yellow("\u26A0")} ${M.default.bold("Framework:")} Unknown framework or generic Node project`),n.entryPoints.length>0?console.log(` ${M.default.green("\u2714")} ${M.default.bold("Entry Points:")} ${n.entryPoints.join(", ")}`):console.log(` ${M.default.yellow("\u26A0")} ${M.default.bold("Entry Points:")} No standard application entry points identified`),n.detected.testingFramework?console.log(` ${M.default.green("\u2714")} ${M.default.bold("Testing Framework:")} ${n.detected.testingFramework}`):console.log(` ${M.default.gray("\u2139")} ${M.default.bold("Testing Framework:")} No test runner detected`),console.log(M.default.bold(M.default.cyan(`
|
|
1128
1128
|
\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501`))),console.log(M.default.green(` \u2714 Project doctor check complete. Codebase is ready for architectural analysis.
|
|
1129
1129
|
`));}var pr=W(U());async function fr(s,e={}){let t=process.cwd();!s&&!e.staged&&(console.error(pr.default.red(`
|
|
1130
1130
|
\u2716 Error: Please specify a target file path (e.g. devarchitect impact src/services/api.ts)
|
|
1131
|
-
`)),process.exit(1));let{discovery:n,nodes:r}=await I(t),{graph:o}=Z(t,r,n.typeScript),a=s?G.relative(t,G.resolve(t,s)).replace(/\\/g,"/"):"",i=
|
|
1131
|
+
`)),process.exit(1));let{discovery:n,nodes:r}=await I(t),{graph:o}=Z(t,r,n.typeScript),a=s?G.relative(t,G.resolve(t,s)).replace(/\\/g,"/"):"",i=us(o,a);console.log(`
|
|
1132
1132
|
`+rr(i)+`
|
|
1133
|
-
`);}var
|
|
1134
|
-
\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501`))),console.log(
|
|
1135
|
-
`);let a=Je.evaluate({graph:o,nodes:r,edges:o.getAllEdges(),config:t}),i=Ve(o),l=Wn(e);if(s.updateBaseline){Un(e,{version:"1.0.0",createdAt:new Date().toISOString(),issueCounts:{errors:a.filter(d=>d.severity==="error").length,warnings:a.filter(d=>d.severity==="warning").length,circularDependencies:i.length},issues:a.map(d=>({ruleId:d.ruleId,filePath:d.filePath,hash:`${d.ruleId}:${d.filePath}`}))}),console.log(
|
|
1136
|
-
`));return}let c=0;if(t.guard.baseline&&l){let d=new Set(l.issues.map(u=>u.hash));for(let u of a){let h=`${u.ruleId}:${u.filePath}`;!d.has(h)&&u.severity==="error"&&c++;}console.log(
|
|
1137
|
-
`)),process.exit(1)):console.log(
|
|
1138
|
-
`));}var
|
|
1139
|
-
`));}else console.log(
|
|
1140
|
-
\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501`))),console.log(
|
|
1141
|
-
`),console.log(c),console.log(
|
|
1142
|
-
\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501`))),console.log(
|
|
1143
|
-
`));}function
|
|
1133
|
+
`);}var Pe=W(U());var mr={id:"no-circular-dependencies",name:"No Circular Dependencies",description:"Disallows circular dependency import cycles between modules",defaultSeverity:"error",evaluate(s){let e=Ve(s.graph),t=[];for(let n of e)t.push({id:n.id,ruleId:"no-circular-dependencies",severity:"error",message:`Circular dependency cycle detected: ${n.path.join(" -> ")}`,filePath:n.path[0],evidence:n.path,suggestion:"Refactor shared types or functions into a separate utility or shared module.",dimension:"architecture"});return t}};var gr={id:"no-cross-feature-imports",name:"No Cross-Feature Direct Imports",description:"Prevents one feature slice from directly importing internal modules of another feature slice",defaultSeverity:"error",evaluate(s){let e=[],t=new Map(s.nodes.map(n=>[n.path,n]));for(let n of s.edges){if(n.isExternal)continue;let r=t.get(n.source),o=t.get(n.target);r?.feature&&o?.feature&&r.feature!==o.feature&&e.push({id:`cross-feature-${n.source}->${n.target}`,ruleId:"no-cross-feature-imports",severity:"error",message:`Feature '${r.feature}' directly imports from feature '${o.feature}' (${n.target}).`,filePath:n.source,evidence:[`${n.source} -> ${n.target}`],suggestion:"Extract the shared dependency into a shared module or coordinate via an entity/widget layer.",dimension:"architecture"});}return e}};var Ka=new Set(["@prisma/client","prisma","drizzle-orm","typeorm","mongoose","pg","mysql2","sqlite3","better-sqlite3","knex","sequelize"]),hr={id:"no-ui-to-database",name:"No UI to Database Direct Imports",description:"Prevents UI components and client hooks from importing database ORMs and drivers",defaultSeverity:"error",evaluate(s){let e=[],t=new Map(s.nodes.map(n=>[n.path,n]));for(let n of s.edges){if(!n.isExternal)continue;let r=t.get(n.source);r&&(r.type==="component"||r.type==="hook")&&Ka.has(n.target)&&e.push({id:`ui-to-db-${n.source}->${n.target}`,ruleId:"no-ui-to-database",severity:"error",message:`UI ${r.type} '${n.source}' directly imports database driver '${n.target}'.`,filePath:n.source,evidence:[`${n.source} imports ${n.target}`],suggestion:"Move database queries to a backend API route, server action, or service layer.",dimension:"architecture"});}return e}};var yr={id:"enforce-public-api",name:"Enforce Public API Boundaries",description:"Requires consumers to import features/modules through their public index entry point",defaultSeverity:"warning",evaluate(s){let e=[],t=new Map(s.nodes.map(n=>[n.path,n]));for(let n of s.edges){if(n.isExternal)continue;let r=t.get(n.source),o=t.get(n.target);r?.feature&&o?.feature&&r.feature!==o.feature&&(o.name==="index.ts"||o.name==="index.tsx"||o.name==="index.js"||e.push({id:`public-api-${n.source}->${n.target}`,ruleId:"enforce-public-api",severity:"warning",message:`Deep import into feature '${o.feature}': '${n.target}' should be accessed via the feature's public API.`,filePath:n.source,evidence:[`${n.source} -> ${n.target}`],suggestion:`Export the needed functionality from 'src/features/${o.feature}/index.ts' and import from there.`,dimension:"architecture"}));}return e}};var vr={id:"max-dependency-depth",name:"Maximum Dependency Depth",description:"Flags files with excessively deep transitive dependency chains",defaultSeverity:"warning",evaluate(s){let e=[],t=s.config.analysis.maxDependencyDepth||10;for(let n of s.nodes){let r=0,o=new Set([n.path]),a=[n.path];for(;a.length>0&&r<=t+2;){let i=[];for(let l of a){let c=s.graph.getDependencies(l);for(let d of c)!o.has(d)&&s.graph.hasNode(d)&&(o.add(d),i.push(d));}i.length>0&&r++,a=i;}r>t&&e.push({id:`max-depth-${n.path}`,ruleId:"max-dependency-depth",severity:"warning",message:`Transitive dependency depth (${r}) exceeds configured maximum (${t}).`,filePath:n.path,evidence:[`Depth: ${r} layers deep`],suggestion:"Flatten dependency tree by decoupling intermediate layers or introducing dependency inversion.",dimension:"architecture"});}return e}};var xr={id:"no-unresolved-imports",name:"No Unresolved Local Imports",description:"Flags local relative or aliased imports that cannot be resolved to any file",defaultSeverity:"error",evaluate(s){let e=[];for(let t of s.edges)t.isExternal||s.graph.hasNode(t.target)||e.push({id:`unresolved-${t.source}->${t.target}`,ruleId:"no-unresolved-imports",severity:"error",message:`Cannot resolve import '${t.target}' from '${t.source}'. File does not exist.`,filePath:t.source,evidence:[`Import specifier '${t.target}' not found in project`],suggestion:"Check file path, spelling, or ensure file exists.",dimension:"dependencies"});return e}};var hs=[mr,gr,hr,yr,vr,xr],Rt={"feature-sliced":{"no-circular-dependencies":"error","no-cross-feature-imports":"error","enforce-public-api":"error","no-ui-to-database":"error","max-dependency-depth":"warning","no-unresolved-imports":"error"},"clean-architecture":{"no-circular-dependencies":"error","no-ui-to-database":"error","no-cross-feature-imports":"warning","enforce-public-api":"warning","max-dependency-depth":"warning","no-unresolved-imports":"error"},layered:{"no-circular-dependencies":"error","no-ui-to-database":"error","max-dependency-depth":"warning","no-unresolved-imports":"error"},"modular-monolith":{"no-circular-dependencies":"error","no-cross-feature-imports":"error","enforce-public-api":"warning","no-ui-to-database":"warning","max-dependency-depth":"warning","no-unresolved-imports":"error"},recommended:{"no-circular-dependencies":"error","no-cross-feature-imports":"warning","enforce-public-api":"warning","no-ui-to-database":"error","max-dependency-depth":"warning","no-unresolved-imports":"error"},custom:{"no-circular-dependencies":"error","no-unresolved-imports":"error"}};var Gs=class{rules=new Map;constructor(){for(let e of hs)this.registerRule(e);}registerRule(e){this.rules.set(e.id,e);}getRule(e){return this.rules.get(e)}getAllRules(){return Array.from(this.rules.values())}evaluate(e){let t=e.config.architecture.preset||"recommended",n=Rt[t]||Rt.recommended,r=e.config.architecture.rules||{},o=[];for(let a of this.rules.values()){let i=r[a.id],l=a.defaultSeverity;if(n[a.id]&&(l=n[a.id]),typeof i=="string"?l=i:i&&typeof i=="object"&&"severity"in i&&(l=i.severity),l!=="off")try{let c=a.evaluate(e);for(let d of c)o.push({...d,severity:l});}catch{}}return o}},Je=new Gs;async function br(s={}){let e=process.cwd(),{config:t}=ke(e),{discovery:n,nodes:r}=await I(e),{graph:o}=Z(e,r,n.typeScript);console.log(Pe.default.bold(Pe.default.cyan(`
|
|
1134
|
+
\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501`))),console.log(Pe.default.bold(Pe.default.cyan(" DEVARCHITECT ARCHITECTURE VALIDATION"))),console.log(Pe.default.bold(Pe.default.cyan("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"))),console.log(` Preset: ${Pe.default.bold(t.architecture.preset)} | Nodes: ${r.length} | Edges: ${o.getAllEdges().length}
|
|
1135
|
+
`);let a=Je.evaluate({graph:o,nodes:r,edges:o.getAllEdges(),config:t}),i=Ve(o),l=Wn(e);if(s.updateBaseline){Un(e,{version:"1.0.0",createdAt:new Date().toISOString(),issueCounts:{errors:a.filter(d=>d.severity==="error").length,warnings:a.filter(d=>d.severity==="warning").length,circularDependencies:i.length},issues:a.map(d=>({ruleId:d.ruleId,filePath:d.filePath,hash:`${d.ruleId}:${d.filePath}`}))}),console.log(Pe.default.green(`\u2714 Updated architecture baseline with ${a.length} debt items.
|
|
1136
|
+
`));return}let c=0;if(t.guard.baseline&&l){let d=new Set(l.issues.map(u=>u.hash));for(let u of a){let h=`${u.ruleId}:${u.filePath}`;!d.has(h)&&u.severity==="error"&&c++;}console.log(Pe.default.gray(` Architecture Debt Ratchet: Baseline has ${l.issues.length} known debt items.`));}else c=a.filter(d=>d.severity==="error").length;console.log(or(a)),c>0&&t.guard.failOnNewErrors?(console.error(Pe.default.red(`\u2716 Architecture check failed: ${c} new architectural errors detected.
|
|
1137
|
+
`)),process.exit(1)):console.log(Pe.default.green(`\u2714 Architecture policy validation passed.
|
|
1138
|
+
`));}var xe=W(U());async function Sr(s={}){let e=process.cwd(),{discovery:t,nodes:n}=await I(e),{graph:r}=Z(e,n,t.typeScript),o=s.format||"mermaid",a=Ve(r),i=r.getAllEdges(),l=r.getAllNodes(),c="";if(o==="mermaid"?c=Gn(r):o==="dot"?c=Zn(r):o==="json"&&(c=JSON.stringify(r.toProjectGraph(e),null,2)),s.output){let d=G.resolve(e,s.output),u=G.dirname(d);pe.existsSync(u)||pe.mkdirSync(u,{recursive:true}),pe.writeFileSync(d,c,"utf8"),console.log(xe.default.green(`\u2714 Exported architecture graph (${o}) to ${xe.default.bold(d)}
|
|
1139
|
+
`));}else console.log(xe.default.bold(xe.default.cyan(`
|
|
1140
|
+
\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501`))),console.log(xe.default.bold(xe.default.cyan(` DEVARCHITECT ARCHITECTURE GRAPH (${o.toUpperCase()})`))),console.log(xe.default.bold(xe.default.cyan("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"))),console.log(` Nodes: ${xe.default.bold(String(l.length))} | Edges: ${xe.default.bold(String(i.length))} | Cycles: ${a.length>0?xe.default.red(String(a.length)):xe.default.green("0")}
|
|
1141
|
+
`),console.log(c),console.log(xe.default.bold(xe.default.cyan(`
|
|
1142
|
+
\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501`))),console.log(xe.default.gray(` Tip: Use --output graph.${o==="mermaid"?"mmd":o} to save to file
|
|
1143
|
+
`));}function ys(s){let{nodes:e,issues:t,graph:n,hasTests:r,duplicateBlockCount:o=0}=s;if(e.length===0)return {status:"critical",overallScore:0,grade:"F",dimensions:{architecture:{score:0,status:"critical",weight:.25,issueCount:0,summary:"No source files detected in workspace."},complexity:{score:0,status:"critical",weight:.2,issueCount:0,summary:"No source files detected in workspace."},dependencies:{score:0,status:"critical",weight:.15,issueCount:0,summary:"No source files detected in workspace."},duplication:{score:0,status:"critical",weight:.15,issueCount:0,summary:"No source files detected in workspace."},maintainability:{score:0,status:"critical",weight:.15,issueCount:0,summary:"No source files detected in workspace."},testing:{score:null,status:"unmeasured",weight:.1,issueCount:0,summary:"No source files detected."}},metrics:{totalIssues:0,errorCount:0,warningCount:0,infoCount:0,circularDependencies:0,highComplexityCount:0,duplicateBlocksCount:0},evaluatedAt:new Date().toISOString()};let a=e.length,i=t.filter(oe=>oe.severity==="error").length,l=t.filter(oe=>oe.severity==="warning").length,c=t.filter(oe=>oe.ruleId==="no-circular-dependencies").length,d=100-(i*15+l*5+c*20);d=Math.max(0,Math.min(100,Math.round(d)));let u=e.filter(oe=>(oe.metrics.complexity||0)>15),h=u.length/a,g=100-Math.round(h*150);g=Math.max(0,Math.min(100,g));let m=e.filter(oe=>n.getDependencies(oe.path).length>12),f=m.length/a,b=100-Math.round(f*120+c*15);b=Math.max(0,Math.min(100,b));let x=100-o*8;x=Math.max(0,Math.min(100,x));let k=e.filter(oe=>oe.metrics.linesOfCode>250),A=k.length/a,v=100-Math.round(A*100);v=Math.max(0,Math.min(100,v));let S=r?85:null,C=0,T=0;C+=d*.25,T+=.25,C+=g*.2,T+=.2,C+=b*.15,T+=.15,C+=x*.15,T+=.15,C+=v*.15,T+=.15,S!==null&&(C+=S*.1,T+=.1);let ie=Math.round(C/T),re="healthy",X="A";ie>=85?(re="healthy",X=ie>=92?"A":"B"):ie>=65?(re="warning",X=ie>=75?"C":"D"):(re="critical",X="F");let we=oe=>oe===null?"unmeasured":oe>=80?"healthy":oe>=60?"warning":"critical";return {overallScore:ie,status:re,grade:X,dimensions:{architecture:{score:d,status:we(d),weight:.25,issueCount:t.filter(oe=>oe.dimension==="architecture").length,summary:"Compliance score based on rule violations and circular dependencies."},complexity:{score:g,status:we(g),weight:.2,issueCount:u.length,summary:`${u.length} file(s) exceed complexity threshold.`},dependencies:{score:b,status:we(b),weight:.15,issueCount:m.length,summary:`${m.length} file(s) exhibit high module coupling.`},duplication:{score:x,status:we(x),weight:.15,issueCount:o,summary:`${o} repeated code blocks detected.`},maintainability:{score:v,status:we(v),weight:.15,issueCount:k.length,summary:`${k.length} oversized file(s) exceeding 250 LOC.`},testing:{score:S,status:we(S),weight:.1,issueCount:0,summary:r?"Test framework detected":"Unmeasured (no test coverage report configured)"}},metrics:{totalIssues:t.length,errorCount:i,warningCount:l,infoCount:t.filter(oe=>oe.severity==="info").length,circularDependencies:c,highComplexityCount:u.length,duplicateBlocksCount:o},evaluatedAt:new Date().toISOString()}}function Cr(s,e){let t=[],n=[],r=0,o=0;for(let i of s){let l=e.get(i.path);if(!l)continue;o++,r+=l.complexity,l.linesOfCode>250&&n.push({filePath:i.path,linesOfCode:l.linesOfCode});let c="low";l.complexity>=25||l.linesOfCode>=400?c="critical":l.complexity>=15||l.linesOfCode>=250?c="high":(l.complexity>=8||l.linesOfCode>=150)&&(c="moderate");let d=[...l.symbols].sort((u,h)=>h.complexity-u.complexity);c!=="low"&&t.push({filePath:i.path,linesOfCode:l.linesOfCode,complexity:l.complexity,risk:c,topSymbols:d.slice(0,5)});}return t.sort((i,l)=>l.complexity-i.complexity),n.sort((i,l)=>l.linesOfCode-i.linesOfCode),{averageComplexity:o>0?Math.round(r/o*10)/10:0,totalComplexity:r,hotspots:t,oversizedFiles:n}}function kr(s,e,t,n=[]){let r=new Set(n.map(c=>c.replace(/\\/g,"/"))),o=new Map,a=new Set;for(let c of e){if(c.isExternal)continue;a.add(c.target),o.has(c.target)||o.set(c.target,new Set);let d=o.get(c.target);for(let u of c.specifiers)d.add(u);}let i=[],l=[];for(let c of s){let d=r.has(c.path)||c.type==="route"||c.type==="config"||c.type==="test"||c.path.includes("index.html");!d&&!a.has(c.path)&&l.push(c.path);let u=t.get(c.path);if(!u||d)continue;let h=o.get(c.path)||new Set;for(let g of u.exports)g.name==="default"?!h.has("default")&&h.size===0&&i.push({filePath:c.path,exportName:"default",line:g.line,isTypeOnly:g.isTypeOnly}):h.has(g.name)||i.push({filePath:c.path,exportName:g.name,line:g.line,isTypeOnly:g.isTypeOnly});}return {unusedExports:i,orphanedFiles:l}}function vs(s,e,t=6){let n=new Map;for(let l of e){if(l.type==="config"||l.type==="asset"||l.type==="test")continue;let c=G.resolve(s,l.path);if(!pe.existsSync(c))continue;let d;try{d=pe.readFileSync(c,"utf8").split(/\r\n|\r|\n/);}catch{continue}let u=d.map(h=>h.trim());for(let h=0;h<=u.length-t;h++){let g=u.slice(h,h+t);if(g.filter(k=>k.length>2&&!k.startsWith("import ")&&!k.startsWith("export ")&&!k.startsWith("//")&&!k.startsWith("/*")&&k!=="{"&&k!=="}"&&k!=="};").length<Math.floor(t*.75))continue;let f=li.createHash("md5").update(g.join(`
|
|
1144
1144
|
`)).digest("hex");n.has(f)||n.set(f,[]);let b=n.get(f);b.some(k=>k.filePath===l.path&&Math.abs(k.startLine-(h+1))<t)||b.push({filePath:l.path,startLine:h+1,endLine:h+t,snippet:g.slice(0,3).join(`
|
|
1145
1145
|
`)+`
|
|
1146
|
-
...`});}}let r=[],o=0;for(let[l,c]of n.entries())c.length>1&&(r.push({hash:l,lineCount:t,instances:c}),o+=(c.length-1)*t);let a=e.reduce((l,c)=>l+c.metrics.linesOfCode,0)||1,i=Math.round(o/a*1e3)/10;return {clusters:r,totalDuplicateLines:o,duplicationPercentage:i}}function Zs(s,e,t,n=0){let r={};for(let c of e){let d=c.feature||c.layer||"root";if(r[d]||(r[d]={files:[],internalEdges:0,externalEdges:0,publicExports:[]}),r[d].files.push(c.path),r[d].files.sort(),c.name.startsWith("index.")&&Array.isArray(c.metadata.exports)){for(let u of c.metadata.exports)r[d].publicExports.push(u.name);r[d].publicExports.sort();}}let o=t.map(c=>`${c.source} -> ${c.target}`).sort(),a=e.reduce((c,d)=>c+d.metrics.linesOfCode,0),i=JSON.stringify({boundaries:r,edges:o}),l=li.createHash("sha256").update(i).digest("hex");return {version:"1.0.0",projectName:s.name,timestamp:new Date().toISOString(),hash:l,summary:{modulesCount:Object.keys(r).length,componentCount:e.filter(c=>c.type==="component").length,edgeCount:t.length,cycleCount:n,totalLoc:a},boundaries:r,edgesSignature:o}}function _r(s,e){let t=new Set(s.edgesSignature),n=new Set(e.edgesSignature),r=[],o=[];for(let g of e.edgesSignature)t.has(g)||r.push(g);for(let g of s.edgesSignature)n.has(g)||o.push(g);let a=new Set(Object.keys(s.boundaries)),i=new Set(Object.keys(e.boundaries)),l=[],c=[];for(let g of i)a.has(g)||l.push(g);for(let g of a)i.has(g)||c.push(g);let d=Math.max(s.edgesSignature.length,1),u=(r.length+o.length)/d,h=Math.min(100,Math.round(u*100));return {previousTimestamp:s.timestamp,currentTimestamp:e.timestamp,driftScore:h,hasDiverged:s.hash!==e.hash,changes:{addedEdges:r,removedEdges:o,newBoundaries:l,removedBoundaries:c,locDelta:e.summary.totalLoc-s.summary.totalLoc}}}function vs(s,e){let t=[],n=0;for(let r of e){if(!r.path.endsWith(".tsx")&&!r.path.endsWith(".jsx"))continue;let o=G.resolve(s,r.path);if(!ue.existsSync(o))continue;let a;try{a=ue.readFileSync(o,"utf8");}catch{continue}let i=j.createSourceFile(r.path,a,j.ScriptTarget.Latest,true,j.ScriptKind.TSX),l=u=>i.getLineAndCharacterOfPosition(u).line+1,c=r.name.replace(/\.(tsx|jsx)$/,""),d=u=>{if(j.isFunctionDeclaration(u)&&u.name&&(c=u.name.text),j.isFunctionDeclaration(u)||j.isArrowFunction(u)){let h=0;u.forEachChild(function g(m){j.isCallExpression(m)&&j.isIdentifier(m.expression)&&m.expression.text.startsWith("use")&&h++,m.forEachChild(g);}),h>7&&t.push({filePath:r.path,line:l(u.getStart()),componentName:c,issueType:"excessive-hooks",message:`Component '${c}' calls ${h} hooks. Heavy state orchestration leads to frequent re-renders.`,suggestion:"Extract sub-logic into custom hooks or split the component into smaller presentational components."});}if(j.isJsxAttribute(u)&&u.initializer&&j.isJsxExpression(u.initializer)){let h=u.name.getText(i),g=u.initializer.expression,m=u.parent.parent,f=j.isJsxOpeningElement(m)||j.isJsxSelfClosingElement(m)?m.tagName.getText(i):"";/^[A-Z]/.test(f)&&g&&((j.isArrowFunction(g)||j.isFunctionExpression(g))&&t.push({filePath:r.path,line:l(u.getStart()),componentName:c,issueType:"inline-function-prop",message:`Inline function passed to prop '${h}' on <${f} /> creates a new reference on every render.`,suggestion:`Wrap callback with useCallback() if <${f} /> is memoized or renders children.`}),(j.isObjectLiteralExpression(g)||j.isArrayLiteralExpression(g))&&t.push({filePath:r.path,line:l(u.getStart()),componentName:c,issueType:"inline-object-prop",message:`Inline object/array passed to prop '${h}' on <${f} /> creates a new reference every render.`,suggestion:"Move static object outside component or memoize with useMemo()."}));}if(j.isJsxOpeningElement(u)||j.isJsxSelfClosingElement(u)){let h=u.tagName.getText(i);if(h.endsWith(".Provider")||h.endsWith("Context.Provider")){for(let g of u.attributes.properties)if(j.isJsxAttribute(g)&&g.name.getText(i)==="value"&&g.initializer&&j.isJsxExpression(g.initializer)){let m=g.initializer.expression;m&&j.isObjectLiteralExpression(m)&&t.push({filePath:r.path,line:l(g.getStart()),componentName:c,issueType:"unmemoized-context",message:"Context.Provider passes inline object literal directly to 'value'. All consuming components re-render every time parent renders.",suggestion:"Wrap the context value in useMemo(() => ({ ... }), [dependencies])."});}}}if(j.isCallExpression(u)&&j.isIdentifier(u.expression)&&u.expression.text==="useEffect"){let h=u.arguments[0];if(h&&(j.isArrowFunction(h)||j.isFunctionExpression(h))){let g=false;h.forEachChild(function m(f){j.isCallExpression(f)&&j.isIdentifier(f.expression)&&/^set[A-Z]/.test(f.expression.text)&&(g=true),f.forEachChild(m);}),g&&u.arguments.length>1&&t.push({filePath:r.path,line:l(u.getStart()),componentName:c,issueType:"derived-state-effect",message:"useEffect calls setState to synchronize derived state. This causes an unwanted extra render cycle.",suggestion:"Calculate derived state inline during render or wrap in useMemo() instead of an effect."});}}j.forEachChild(u,d);};d(i),n++;}return {totalIssues:t.length,issues:t,componentsAnalyzed:n}}function xs(s,e,t,n){let r=[],o=[],a=new Map,i=new Set;for(let m of t)for(let f of m.specifiers)i.add(f);let l=0;for(let m of e){if(!m.path.endsWith(".ts")&&!m.path.endsWith(".tsx"))continue;let f=G.resolve(s,m.path);if(!ue.existsSync(f))continue;let b;try{b=ue.readFileSync(f,"utf8");}catch{continue}let x=j.createSourceFile(m.path,b,j.ScriptTarget.Latest,true,m.path.endsWith(".tsx")?j.ScriptKind.TSX:j.ScriptKind.TS),k=C=>x.getLineAndCharacterOfPosition(C).line+1,A=new Set,v=C=>{j.isTypeReferenceNode(C)&&j.isIdentifier(C.typeName)&&A.add(C.typeName.text),j.isExpressionWithTypeArguments(C)&&j.isIdentifier(C.expression)&&A.add(C.expression.text),j.forEachChild(C,v);};v(x);let S=C=>{if(C.kind===j.SyntaxKind.AnyKeyword&&o.push({filePath:m.path,line:k(C.getStart()),snippet:C.parent.getText(x).slice(0,60),kind:"explicit-any"}),j.isAsExpression(C)&&C.type.kind===j.SyntaxKind.AnyKeyword&&o.push({filePath:m.path,line:k(C.getStart()),snippet:C.getText(x).slice(0,60),kind:"as-any-cast"}),j.isInterfaceDeclaration(C)){l++;let T=C.name.text,ie=k(C.getStart());C.modifiers?.some($s=>$s.kind===j.SyntaxKind.ExportKeyword)??false;let X=A.has(T),be=i.has(T);!X&&!be&&r.push({filePath:m.path,name:T,kind:"interface",line:ie});let oe=C.members.map($s=>$s.getText(x).replace(/\s+/g,"")).sort().join(";");a.has(T)||a.set(T,[]),a.get(T).push({filePath:m.path,line:ie,structure:oe});}if(j.isTypeAliasDeclaration(C)){l++;let T=C.name.text,ie=k(C.getStart()),re=A.has(T),X=i.has(T);!re&&!X&&r.push({filePath:m.path,name:T,kind:"type",line:ie});}if(j.isEnumDeclaration(C)){l++;let T=C.name.text,ie=k(C.getStart()),re=A.has(T),X=i.has(T);!re&&!X&&r.push({filePath:m.path,name:T,kind:"enum",line:ie});}j.forEachChild(C,S);};S(x);}let c=[];for(let[m,f]of a.entries())if(f.length>1){let b=f[0].structure;f.every(k=>k.structure===b&&b.length>5)&&c.push({typeName:m,structureHash:b,locations:f.map(k=>({filePath:k.filePath,line:k.line}))});}let d=o.length*4,u=r.length*2,h=c.length*5,g=Math.max(0,Math.min(100,100-(d+u+h)));return {unusedTypes:r,anyHotspots:o,duplicateTypes:c,totalTypesDeclared:l,typeSafetyScore:g}}function bs(s,e){let t=[];for(let o of e){if(!o.path.endsWith(".ts")&&!o.path.endsWith(".tsx")&&!o.path.endsWith(".js")&&!o.path.endsWith(".jsx"))continue;let a=G.resolve(s,o.path);if(!ue.existsSync(a))continue;let i;try{i=ue.readFileSync(a,"utf8");}catch{continue}let l=j.createSourceFile(o.path,i,j.ScriptTarget.Latest,true,o.path.endsWith(".tsx")||o.path.endsWith(".jsx")?j.ScriptKind.TSX:j.ScriptKind.TS),c=u=>l.getLineAndCharacterOfPosition(u).line+1;o.metrics.linesOfCode>350&&t.push({filePath:o.path,line:1,category:"god-component",severity:"warning",message:`File has ${o.metrics.linesOfCode} lines of code. It exceeds single-responsibility maintainability thresholds.`,suggestion:"Break this module down into smaller components, custom hooks, or utility services."});let d=u=>{if(j.isCatchClause(u)&&u.block.statements.length===0&&t.push({filePath:o.path,line:c(u.getStart()),category:"empty-catch",severity:"error",message:"Empty catch block silently swallows exceptions. Errors will fail silently without logs or fallback state.",suggestion:"Log the error, rethrow it, or set fallback error state in the catch block."}),j.isCallExpression(u)){let h=u.expression.getText(l);if(h==="fetch"||h.endsWith(".get")||h.endsWith(".post")){let g=false,m=false,f=u.parent;for(;f;){if(j.isTryStatement(f)){g=true;break}if(j.isCallExpression(f)&&f.expression.getText(l).endsWith(".catch")){m=true;break}f=f.parent;}!g&&!m&&t.push({filePath:o.path,line:c(u.getStart()),category:"unhandled-async",severity:"warning",message:`Async call '${h}()' lacks try/catch or .catch() handler. Network or server failures will cause unhandled rejections.`,suggestion:"Wrap in try/catch block or append .catch() to handle network error states gracefully."});}}if(j.isStringLiteral(u)){let h=u.text;(/^(sk-[a-zA-Z0-9]{20,}|ghp_[a-zA-Z0-9]{20,}|AKIA[0-9A-Z]{16})/.test(h)||/(api[_-]?key|secret[_-]?key|auth[_-]?token)\s*[:=]\s*["'][a-zA-Z0-9_-]{16,}["']/i.test(h))&&t.push({filePath:o.path,line:c(u.getStart()),category:"hardcoded-secret",severity:"error",message:"Potential hardcoded API secret or credential detected in source code.",suggestion:"Store credentials in environment variables (process.env) and load via .env files."});}j.isCallExpression(u)&&u.expression.getText(l)==="console.log"&&!o.path.includes(".test.")&&!o.path.includes("__tests__")&&t.push({filePath:o.path,line:c(u.getStart()),category:"console-log",severity:"info",message:"console.log statement left in source code.",suggestion:"Remove debug console logs before production or use a dedicated logging service."}),j.forEachChild(u,d);};d(l);}let n=t.filter(o=>o.severity==="error").length,r=t.filter(o=>o.severity==="warning").length;return {totalSmells:t.length,errorsCount:n,warningsCount:r,smells:t}}function Ir(s,e,t,n,r,o){let a=e.replace(/\\/g,"/"),i=G.resolve(s,a),l=[],c=[];if(ue.existsSync(i))try{let x=ue.readFileSync(i,"utf8"),k=j.createSourceFile(a,x,j.ScriptTarget.Latest,!0,a.endsWith(".tsx")||a.endsWith(".jsx")?j.ScriptKind.TSX:j.ScriptKind.TS),A=v=>k.getLineAndCharacterOfPosition(v).line+1;j.forEachChild(k,v=>{if(j.isFunctionDeclaration(v)&&v.name&&(v.modifiers?.some(C=>C.kind===j.SyntaxKind.ExportKeyword)??!1)){let C=v.parameters.map(T=>T.name.getText(k)).join(", ");l.push({name:v.name.text,kind:"function",line:A(v.getStart()),details:`(${C})`});}if(j.isInterfaceDeclaration(v)&&(v.modifiers?.some(C=>C.kind===j.SyntaxKind.ExportKeyword)??!1)){let C=v.members.map(T=>T.name?.getText(k)||"prop").join(", ");l.push({name:v.name.text,kind:"interface",line:A(v.getStart()),details:`{ ${C} }`});}if(j.isTypeAliasDeclaration(v)&&(v.modifiers?.some(C=>C.kind===j.SyntaxKind.ExportKeyword)??!1)&&l.push({name:v.name.text,kind:"type",line:A(v.getStart()),details:v.type.getText(k).slice(0,40)}),j.isVariableStatement(v)&&(v.modifiers?.some(C=>C.kind===j.SyntaxKind.ExportKeyword)??!1))for(let C of v.declarationList.declarations)j.isIdentifier(C.name)&&l.push({name:C.name.text,kind:"variable",line:A(C.getStart()),details:C.type?C.type.getText(k):"inferred"});});}catch{}let d=r.getDependents(a),u=[];for(let x of d){let k=G.resolve(s,x);if(!ue.existsSync(k))continue;let A=n.filter(C=>C.source===x&&C.target===a),v=Array.from(new Set(A.flatMap(C=>C.specifiers))),S=[];try{let C=ue.readFileSync(k,"utf8"),T=j.createSourceFile(x,C,j.ScriptTarget.Latest,!0,x.endsWith(".tsx")?j.ScriptKind.TSX:j.ScriptKind.TS),ie=X=>T.getLineAndCharacterOfPosition(X).line+1,re=X=>{if(j.isIdentifier(X)&&v.includes(X.text)){let be=X.parent;!j.isImportSpecifier(be)&&!j.isImportClause(be)&&S.push({line:ie(X.getStart()),symbol:X.text,codeSnippet:be.getText(T).slice(0,80).replace(/\s+/g," ")});}j.forEachChild(X,re);};re(T);}catch{}u.push({consumerFile:x,importedSymbols:v,callLines:S.slice(0,10)});}let h=0,g=new Set(d),m=[...d];for(;m.length>0;){let x=m.shift();h++;for(let k of r.getDependents(x))g.has(k)||(g.add(k),m.push(k));}let f="LOW";h>15||d.length>8?f="CRITICAL":h>6||d.length>3?f="HIGH":d.length>0&&(f="MEDIUM"),l.some(x=>x.kind==="interface"||x.kind==="type")&&c.push("Exported types/interfaces are shared with other modules. Renaming or removing properties will cause compiler errors."),u.length>2&&c.push(`Shared across ${u.length} direct consumers. Changing function parameters requires updating all call sites simultaneously.`);let b=["Add optional parameters or overload signatures instead of changing existing parameter positions.","Deprecate old interfaces before deleting them; export both new and legacy signatures during migration.",`Run 'devarchitect impact ${a}' and 'devarchitect validate' after editing to guarantee zero regressions.`];return {targetFile:a,contractMembers:l,directConsumersCount:d.length,transitiveConsumersCount:h,consumers:u,riskLevel:f,breakingChangeWarnings:c,safeRefactoringGuide:b}}function Pr(s,e,t={}){let n=[],r=new Set;for(let o of e){if(!o.endsWith(".ts")&&!o.endsWith(".tsx")&&!o.endsWith(".js")&&!o.endsWith(".jsx"))continue;let a=G.resolve(s,o);if(!ue.existsSync(a))continue;let i=ue.readFileSync(a,"utf8"),l=false;if(t.fixConsoleLogs!==false){let c=/^[ \t]*console\.(log|debug|info)\([^)]*\);?[ \t]*\r?\n?/gm;if(c.test(i)){let d=i.match(c)||[];for(let u of d)n.push({filePath:o,category:"console-log",description:`Remove debug log: ${u.trim()}`,originalSnippet:u.trim(),fixedSnippet:"// [removed by devarchitect fix]"});i=i.replace(c,""),l=true;}}if(t.fixEmptyCatches!==false){let c=/catch\s*(\([a-zA-Z0-9_]*\))?\s*\{\s*\}/g;c.test(i)&&(n.push({filePath:o,category:"empty-catch",description:"Add error console reporting to empty catch block",originalSnippet:"catch (e) {}",fixedSnippet:'catch (error) { console.error("Caught unhandled error:", error); }'}),i=i.replace(c,`catch (error) {
|
|
1146
|
+
...`});}}let r=[],o=0;for(let[l,c]of n.entries())c.length>1&&(r.push({hash:l,lineCount:t,instances:c}),o+=(c.length-1)*t);let a=e.reduce((l,c)=>l+c.metrics.linesOfCode,0)||1,i=Math.round(o/a*1e3)/10;return {clusters:r,totalDuplicateLines:o,duplicationPercentage:i}}function qs(s,e,t,n=0){let r={};for(let c of e){let d=c.feature||c.layer||"root";if(r[d]||(r[d]={files:[],internalEdges:0,externalEdges:0,publicExports:[]}),r[d].files.push(c.path),r[d].files.sort(),c.name.startsWith("index.")&&Array.isArray(c.metadata.exports)){for(let u of c.metadata.exports)r[d].publicExports.push(u.name);r[d].publicExports.sort();}}let o=t.map(c=>`${c.source} -> ${c.target}`).sort(),a=e.reduce((c,d)=>c+d.metrics.linesOfCode,0),i=JSON.stringify({boundaries:r,edges:o}),l=li.createHash("sha256").update(i).digest("hex");return {version:"1.0.0",projectName:s.name,timestamp:new Date().toISOString(),hash:l,summary:{modulesCount:Object.keys(r).length,componentCount:e.filter(c=>c.type==="component").length,edgeCount:t.length,cycleCount:n,totalLoc:a},boundaries:r,edgesSignature:o}}function _r(s,e){let t=new Set(s.edgesSignature),n=new Set(e.edgesSignature),r=[],o=[];for(let g of e.edgesSignature)t.has(g)||r.push(g);for(let g of s.edgesSignature)n.has(g)||o.push(g);let a=new Set(Object.keys(s.boundaries)),i=new Set(Object.keys(e.boundaries)),l=[],c=[];for(let g of i)a.has(g)||l.push(g);for(let g of a)i.has(g)||c.push(g);let d=Math.max(s.edgesSignature.length,1),u=(r.length+o.length)/d,h=Math.min(100,Math.round(u*100));return {previousTimestamp:s.timestamp,currentTimestamp:e.timestamp,driftScore:h,hasDiverged:s.hash!==e.hash,changes:{addedEdges:r,removedEdges:o,newBoundaries:l,removedBoundaries:c,locDelta:e.summary.totalLoc-s.summary.totalLoc}}}function xs(s,e){let t=[],n=0;for(let r of e){if(!r.path.endsWith(".tsx")&&!r.path.endsWith(".jsx"))continue;let o=G.resolve(s,r.path);if(!pe.existsSync(o))continue;let a;try{a=pe.readFileSync(o,"utf8");}catch{continue}let i=j.createSourceFile(r.path,a,j.ScriptTarget.Latest,true,j.ScriptKind.TSX),l=u=>i.getLineAndCharacterOfPosition(u).line+1,c=r.name.replace(/\.(tsx|jsx)$/,""),d=u=>{if(j.isFunctionDeclaration(u)&&u.name&&(c=u.name.text),j.isFunctionDeclaration(u)||j.isArrowFunction(u)){let h=0;u.forEachChild(function g(m){j.isCallExpression(m)&&j.isIdentifier(m.expression)&&m.expression.text.startsWith("use")&&h++,m.forEachChild(g);}),h>7&&t.push({filePath:r.path,line:l(u.getStart()),componentName:c,issueType:"excessive-hooks",message:`Component '${c}' calls ${h} hooks. Heavy state orchestration leads to frequent re-renders.`,suggestion:"Extract sub-logic into custom hooks or split the component into smaller presentational components."});}if(j.isJsxAttribute(u)&&u.initializer&&j.isJsxExpression(u.initializer)){let h=u.name.getText(i),g=u.initializer.expression,m=u.parent.parent,f=j.isJsxOpeningElement(m)||j.isJsxSelfClosingElement(m)?m.tagName.getText(i):"";/^[A-Z]/.test(f)&&g&&((j.isArrowFunction(g)||j.isFunctionExpression(g))&&t.push({filePath:r.path,line:l(u.getStart()),componentName:c,issueType:"inline-function-prop",message:`Inline function passed to prop '${h}' on <${f} /> creates a new reference on every render.`,suggestion:`Wrap callback with useCallback() if <${f} /> is memoized or renders children.`}),(j.isObjectLiteralExpression(g)||j.isArrayLiteralExpression(g))&&t.push({filePath:r.path,line:l(u.getStart()),componentName:c,issueType:"inline-object-prop",message:`Inline object/array passed to prop '${h}' on <${f} /> creates a new reference every render.`,suggestion:"Move static object outside component or memoize with useMemo()."}));}if(j.isJsxOpeningElement(u)||j.isJsxSelfClosingElement(u)){let h=u.tagName.getText(i);if(h.endsWith(".Provider")||h.endsWith("Context.Provider")){for(let g of u.attributes.properties)if(j.isJsxAttribute(g)&&g.name.getText(i)==="value"&&g.initializer&&j.isJsxExpression(g.initializer)){let m=g.initializer.expression;m&&j.isObjectLiteralExpression(m)&&t.push({filePath:r.path,line:l(g.getStart()),componentName:c,issueType:"unmemoized-context",message:"Context.Provider passes inline object literal directly to 'value'. All consuming components re-render every time parent renders.",suggestion:"Wrap the context value in useMemo(() => ({ ... }), [dependencies])."});}}}if(j.isCallExpression(u)&&j.isIdentifier(u.expression)&&u.expression.text==="useEffect"){let h=u.arguments[0];if(h&&(j.isArrowFunction(h)||j.isFunctionExpression(h))){let g=false;h.forEachChild(function m(f){j.isCallExpression(f)&&j.isIdentifier(f.expression)&&/^set[A-Z]/.test(f.expression.text)&&(g=true),f.forEachChild(m);}),g&&u.arguments.length>1&&t.push({filePath:r.path,line:l(u.getStart()),componentName:c,issueType:"derived-state-effect",message:"useEffect calls setState to synchronize derived state. This causes an unwanted extra render cycle.",suggestion:"Calculate derived state inline during render or wrap in useMemo() instead of an effect."});}}j.forEachChild(u,d);};d(i),n++;}return {totalIssues:t.length,issues:t,componentsAnalyzed:n}}function bs(s,e,t,n){let r=[],o=[],a=new Map,i=new Set;for(let m of t)for(let f of m.specifiers)i.add(f);let l=0;for(let m of e){if(!m.path.endsWith(".ts")&&!m.path.endsWith(".tsx"))continue;let f=G.resolve(s,m.path);if(!pe.existsSync(f))continue;let b;try{b=pe.readFileSync(f,"utf8");}catch{continue}let x=j.createSourceFile(m.path,b,j.ScriptTarget.Latest,true,m.path.endsWith(".tsx")?j.ScriptKind.TSX:j.ScriptKind.TS),k=C=>x.getLineAndCharacterOfPosition(C).line+1,A=new Set,v=C=>{j.isTypeReferenceNode(C)&&j.isIdentifier(C.typeName)&&A.add(C.typeName.text),j.isExpressionWithTypeArguments(C)&&j.isIdentifier(C.expression)&&A.add(C.expression.text),j.forEachChild(C,v);};v(x);let S=C=>{if(C.kind===j.SyntaxKind.AnyKeyword&&o.push({filePath:m.path,line:k(C.getStart()),snippet:C.parent.getText(x).slice(0,60),kind:"explicit-any"}),j.isAsExpression(C)&&C.type.kind===j.SyntaxKind.AnyKeyword&&o.push({filePath:m.path,line:k(C.getStart()),snippet:C.getText(x).slice(0,60),kind:"as-any-cast"}),j.isInterfaceDeclaration(C)){l++;let T=C.name.text,ie=k(C.getStart());C.modifiers?.some(_s=>_s.kind===j.SyntaxKind.ExportKeyword)??false;let X=A.has(T),we=i.has(T);!X&&!we&&r.push({filePath:m.path,name:T,kind:"interface",line:ie});let oe=C.members.map(_s=>_s.getText(x).replace(/\s+/g,"")).sort().join(";");a.has(T)||a.set(T,[]),a.get(T).push({filePath:m.path,line:ie,structure:oe});}if(j.isTypeAliasDeclaration(C)){l++;let T=C.name.text,ie=k(C.getStart()),re=A.has(T),X=i.has(T);!re&&!X&&r.push({filePath:m.path,name:T,kind:"type",line:ie});}if(j.isEnumDeclaration(C)){l++;let T=C.name.text,ie=k(C.getStart()),re=A.has(T),X=i.has(T);!re&&!X&&r.push({filePath:m.path,name:T,kind:"enum",line:ie});}j.forEachChild(C,S);};S(x);}let c=[];for(let[m,f]of a.entries())if(f.length>1){let b=f[0].structure;f.every(k=>k.structure===b&&b.length>5)&&c.push({typeName:m,structureHash:b,locations:f.map(k=>({filePath:k.filePath,line:k.line}))});}let d=o.length*4,u=r.length*2,h=c.length*5,g=Math.max(0,Math.min(100,100-(d+u+h)));return {unusedTypes:r,anyHotspots:o,duplicateTypes:c,totalTypesDeclared:l,typeSafetyScore:g}}function ws(s,e){let t=[];for(let o of e){if(!o.path.endsWith(".ts")&&!o.path.endsWith(".tsx")&&!o.path.endsWith(".js")&&!o.path.endsWith(".jsx"))continue;let a=G.resolve(s,o.path);if(!pe.existsSync(a))continue;let i;try{i=pe.readFileSync(a,"utf8");}catch{continue}let l=j.createSourceFile(o.path,i,j.ScriptTarget.Latest,true,o.path.endsWith(".tsx")||o.path.endsWith(".jsx")?j.ScriptKind.TSX:j.ScriptKind.TS),c=u=>l.getLineAndCharacterOfPosition(u).line+1;o.metrics.linesOfCode>350&&t.push({filePath:o.path,line:1,category:"god-component",severity:"warning",message:`File has ${o.metrics.linesOfCode} lines of code. It exceeds single-responsibility maintainability thresholds.`,suggestion:"Break this module down into smaller components, custom hooks, or utility services."});let d=u=>{if(j.isCatchClause(u)&&u.block.statements.length===0&&t.push({filePath:o.path,line:c(u.getStart()),category:"empty-catch",severity:"error",message:"Empty catch block silently swallows exceptions. Errors will fail silently without logs or fallback state.",suggestion:"Log the error, rethrow it, or set fallback error state in the catch block."}),j.isCallExpression(u)){let h=u.expression.getText(l);if(h==="fetch"||h.endsWith(".get")||h.endsWith(".post")){let g=false,m=false,f=u.parent;for(;f;){if(j.isTryStatement(f)){g=true;break}if(j.isCallExpression(f)&&f.expression.getText(l).endsWith(".catch")){m=true;break}f=f.parent;}!g&&!m&&t.push({filePath:o.path,line:c(u.getStart()),category:"unhandled-async",severity:"warning",message:`Async call '${h}()' lacks try/catch or .catch() handler. Network or server failures will cause unhandled rejections.`,suggestion:"Wrap in try/catch block or append .catch() to handle network error states gracefully."});}}if(j.isStringLiteral(u)){let h=u.text;(/^(sk-[a-zA-Z0-9]{20,}|ghp_[a-zA-Z0-9]{20,}|AKIA[0-9A-Z]{16})/.test(h)||/(api[_-]?key|secret[_-]?key|auth[_-]?token)\s*[:=]\s*["'][a-zA-Z0-9_-]{16,}["']/i.test(h))&&t.push({filePath:o.path,line:c(u.getStart()),category:"hardcoded-secret",severity:"error",message:"Potential hardcoded API secret or credential detected in source code.",suggestion:"Store credentials in environment variables (process.env) and load via .env files."});}j.isCallExpression(u)&&u.expression.getText(l)==="console.log"&&!o.path.includes(".test.")&&!o.path.includes("__tests__")&&t.push({filePath:o.path,line:c(u.getStart()),category:"console-log",severity:"info",message:"console.log statement left in source code.",suggestion:"Remove debug console logs before production or use a dedicated logging service."}),j.forEachChild(u,d);};d(l);}let n=t.filter(o=>o.severity==="error").length,r=t.filter(o=>o.severity==="warning").length;return {totalSmells:t.length,errorsCount:n,warningsCount:r,smells:t}}function Ir(s,e,t,n,r,o){let a=e.replace(/\\/g,"/"),i=G.resolve(s,a),l=[],c=[];if(pe.existsSync(i))try{let x=pe.readFileSync(i,"utf8"),k=j.createSourceFile(a,x,j.ScriptTarget.Latest,!0,a.endsWith(".tsx")||a.endsWith(".jsx")?j.ScriptKind.TSX:j.ScriptKind.TS),A=v=>k.getLineAndCharacterOfPosition(v).line+1;j.forEachChild(k,v=>{if(j.isFunctionDeclaration(v)&&v.name&&(v.modifiers?.some(C=>C.kind===j.SyntaxKind.ExportKeyword)??!1)){let C=v.parameters.map(T=>T.name.getText(k)).join(", ");l.push({name:v.name.text,kind:"function",line:A(v.getStart()),details:`(${C})`});}if(j.isInterfaceDeclaration(v)&&(v.modifiers?.some(C=>C.kind===j.SyntaxKind.ExportKeyword)??!1)){let C=v.members.map(T=>T.name?.getText(k)||"prop").join(", ");l.push({name:v.name.text,kind:"interface",line:A(v.getStart()),details:`{ ${C} }`});}if(j.isTypeAliasDeclaration(v)&&(v.modifiers?.some(C=>C.kind===j.SyntaxKind.ExportKeyword)??!1)&&l.push({name:v.name.text,kind:"type",line:A(v.getStart()),details:v.type.getText(k).slice(0,40)}),j.isVariableStatement(v)&&(v.modifiers?.some(C=>C.kind===j.SyntaxKind.ExportKeyword)??!1))for(let C of v.declarationList.declarations)j.isIdentifier(C.name)&&l.push({name:C.name.text,kind:"variable",line:A(C.getStart()),details:C.type?C.type.getText(k):"inferred"});});}catch{}let d=r.getDependents(a),u=[];for(let x of d){let k=G.resolve(s,x);if(!pe.existsSync(k))continue;let A=n.filter(C=>C.source===x&&C.target===a),v=Array.from(new Set(A.flatMap(C=>C.specifiers))),S=[];try{let C=pe.readFileSync(k,"utf8"),T=j.createSourceFile(x,C,j.ScriptTarget.Latest,!0,x.endsWith(".tsx")?j.ScriptKind.TSX:j.ScriptKind.TS),ie=X=>T.getLineAndCharacterOfPosition(X).line+1,re=X=>{if(j.isIdentifier(X)&&v.includes(X.text)){let we=X.parent;!j.isImportSpecifier(we)&&!j.isImportClause(we)&&S.push({line:ie(X.getStart()),symbol:X.text,codeSnippet:we.getText(T).slice(0,80).replace(/\s+/g," ")});}j.forEachChild(X,re);};re(T);}catch{}u.push({consumerFile:x,importedSymbols:v,callLines:S.slice(0,10)});}let h=0,g=new Set(d),m=[...d];for(;m.length>0;){let x=m.shift();h++;for(let k of r.getDependents(x))g.has(k)||(g.add(k),m.push(k));}let f="LOW";h>15||d.length>8?f="CRITICAL":h>6||d.length>3?f="HIGH":d.length>0&&(f="MEDIUM"),l.some(x=>x.kind==="interface"||x.kind==="type")&&c.push("Exported types/interfaces are shared with other modules. Renaming or removing properties will cause compiler errors."),u.length>2&&c.push(`Shared across ${u.length} direct consumers. Changing function parameters requires updating all call sites simultaneously.`);let b=["Add optional parameters or overload signatures instead of changing existing parameter positions.","Deprecate old interfaces before deleting them; export both new and legacy signatures during migration.",`Run 'devarchitect impact ${a}' and 'devarchitect validate' after editing to guarantee zero regressions.`];return {targetFile:a,contractMembers:l,directConsumersCount:d.length,transitiveConsumersCount:h,consumers:u,riskLevel:f,breakingChangeWarnings:c,safeRefactoringGuide:b}}function Pr(s,e,t={}){let n=[],r=new Set;for(let o of e){if(!o.endsWith(".ts")&&!o.endsWith(".tsx")&&!o.endsWith(".js")&&!o.endsWith(".jsx"))continue;let a=G.resolve(s,o);if(!pe.existsSync(a))continue;let i=pe.readFileSync(a,"utf8"),l=false;if(t.fixConsoleLogs!==false){let c=/^[ \t]*console\.(log|debug|info)\([^)]*\);?[ \t]*\r?\n?/gm;if(c.test(i)){let d=i.match(c)||[];for(let u of d)n.push({filePath:o,category:"console-log",description:`Remove debug log: ${u.trim()}`,originalSnippet:u.trim(),fixedSnippet:"// [removed by devarchitect fix]"});i=i.replace(c,""),l=true;}}if(t.fixEmptyCatches!==false){let c=/catch\s*(\([a-zA-Z0-9_]*\))?\s*\{\s*\}/g;c.test(i)&&(n.push({filePath:o,category:"empty-catch",description:"Add error console reporting to empty catch block",originalSnippet:"catch (e) {}",fixedSnippet:'catch (error) { console.error("Caught unhandled error:", error); }'}),i=i.replace(c,`catch (error) {
|
|
1147
1147
|
console.error("Caught error:", error);
|
|
1148
|
-
}`),l=true);}l&&(r.add(o),t.dryRun||
|
|
1149
|
-
`)||e.includes("\r"))return null;if(e.startsWith("@")){let n=e.split("/");if(n.length>=2){let r=`${n[0]}/${n[1]}`;return Or(r)?r:null}return null}let t=e.split("/")[0];return Or(t)?t:null}function Or(s){return /^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/i.test(s)}var
|
|
1148
|
+
}`),l=true);}l&&(r.add(o),t.dryRun||pe.writeFileSync(a,i,"utf8"));}return {modifiedFiles:Array.from(r),actions:n,dryRun:!!t.dryRun}}function Cs(s,e,t,n,r){let o=e.toLowerCase();if(o.includes("complex")||o.includes("hotspot")||o.includes("most complicated")||o.includes("biggest")){let v=[...t].filter(S=>(S.metrics?.complexity||0)>0||(S.metrics?.linesOfCode||0)>0).sort((S,C)=>(C.metrics?.complexity||0)*10+(C.metrics?.linesOfCode||0)-((S.metrics?.complexity||0)*10+(S.metrics?.linesOfCode||0))).slice(0,5);if(v.length>0)return {question:e,topic:"Codebase Complexity Hotspots",summary:`Identified top ${v.length} files with the highest cyclomatic complexity and code volume.`,flowSteps:v.map((S,C)=>`${C+1}. [${S.name}] (${S.path}) \u2014 Complexity: ${S.metrics?.complexity??"N/A"}, Lines: ${S.metrics?.linesOfCode||0} (${S.type})`),relatedFiles:v.map(S=>S.path),evidenceCount:v.length,confidence:"High"}}let a=new Set(["how","does","work","what","is","the","in","and","to","from","where","why","can","i","find","a","an","are","who","which","file","files","uses","used","by","depends","on","call","calls"]),i=o.replace(/[^a-z0-9\s]/g,"").split(/\s+/).filter(v=>v.length>2&&!a.has(v)),l=[];for(let v of t){let S=0,C=v.path.toLowerCase(),T=v.name.toLowerCase(),ie=v.feature?.toLowerCase()||"";for(let re of i)C.includes(re)&&(S+=5),T.includes(re)&&(S+=8),ie.includes(re)&&(S+=10);S>0&&l.push({node:v,score:S});}l.sort((v,S)=>S.score-v.score);let c=l.slice(0,8).map(v=>v.node),d=c[0];if((o.includes("who uses")||o.includes("who imports")||o.includes("what uses")||o.includes("depends on")||o.includes("dependents")||o.includes("who calls"))&&d){let v=r.getDependents(d.path),S=[];return v.length===0?S.push(`\u2022 No other files currently import [${d.name}] directly (it is an entry point or isolated module).`):v.forEach((C,T)=>{S.push(`${T+1}. [${G.basename(C)}] (${C}) imports and depends on [${d.name}]`);}),{question:e,topic:`${d.name} Downstream Dependents & Consumers`,summary:`Found ${v.length} file(s) that import and depend on [${d.name}].`,flowSteps:S,relatedFiles:[d.path,...v],evidenceCount:v.length+1,confidence:"High"}}if((o.startsWith("where is")||o.startsWith("where are")||o.startsWith("which file")||o.includes("locate")||o.includes("where can i find"))&&d){let v=[`Primary Location: ${d.path}`,`Architectural Role: ${d.type.toUpperCase()}${d.layer?` (Layer: ${d.layer})`:""}`,d.feature?`Feature Slice: ${d.feature}`:"Independent module",`Lines of Code: ${d.metrics?.linesOfCode||0} lines`,`Direct Dependencies: ${r.getDependencies(d.path).length} imported modules`];return {question:e,topic:`${d.name} Location & Identity`,summary:`[${d.name}] is located at ${d.path}.`,flowSteps:v,relatedFiles:[d.path],evidenceCount:1,confidence:"High"}}if(c.length===0){let v=t.filter(S=>S.type==="route"||S.name.startsWith("main.")||S.name.startsWith("App."));return {question:e,topic:"Architecture Overview",summary:`Analyzed repository with ${t.length} files. No specific matches found for '${i.join(", ")}'.`,flowSteps:["Application initiates at entry points ("+v.slice(0,3).map(S=>S.name).join(", ")+")","State and UI components render through feature slices and shared utilities"],relatedFiles:v.slice(0,5).map(S=>S.path),evidenceCount:v.length,confidence:"Medium"}}let g=[],m=c.filter(v=>v.type==="component"||v.type==="route"),f=c.filter(v=>v.type==="hook"),b=c.filter(v=>v.type==="service");m.length>0&&g.push(`1. User interaction starts in UI component [${m[0].name}] (${m[0].path})`),f.length>0&&g.push(`2. State orchestration & side-effects handled in hook [${f[0].name}] (${f[0].path})`),b.length>0&&g.push(`3. Data fetching / API communication processed in [${b[0].name}] (${b[0].path})`);let x=r.getDependencies(d.path);x.length>0&&g.push(`4. [${d.name}] delegates to dependencies: ${x.slice(0,3).join(", ")}`);let k=d.feature?`${d.feature.toUpperCase()} Architecture`:`${d.name} Execution Flow`,A=`Found ${c.length} indexed code files and ${x.length} direct dependencies matching your query.`;return {question:e,topic:k,summary:A,flowSteps:g,relatedFiles:c.map(v=>v.path),evidenceCount:c.length+x.length,confidence:c.length>=2?"High":"Medium"}}var rc=[/SECRET/i,/PRIVATE/i,/PASSWORD/i,/DB_PASS/i,/DATABASE_URL/i,/AUTH_TOKEN/i,/ACCESS_TOKEN/i,/API_KEY/i,/CREDENTIALS/i,/SIGNING_KEY/i],Rr=["NEXT_PUBLIC_","VITE_","PUBLIC_","REACT_APP_","NUXT_PUBLIC_"];function jr(s,e){let t=[".env.example",".env.template",".env.sample"],n=null,r=new Set;for(let f of t){let b=G.join(s,f);if(pe.existsSync(b)){n=f;let x=pe.readFileSync(b,"utf8");oc(x,r);break}}let a=[".env",".env.local",".env.development",".env.production",".env.test",...t].filter(f=>pe.existsSync(G.join(s,f))),i=new Map,l=[],c=0,d=/(?:process\.env|import\.meta\.env)(?:\.([a-zA-Z0-9_]+)|\[['"]([a-zA-Z0-9_]+)['"]\])/g;for(let f of e){if(f.type==="config"||f.type==="asset")continue;let b=G.isAbsolute(f.path)?f.path:G.join(s,f.path);if(!pe.existsSync(b))continue;let x="";try{x=pe.readFileSync(b,"utf8");}catch{continue}let k=f.type==="component"||f.type==="route"||f.path.includes("/components/")||f.path.includes("/ui/")||f.path.endsWith(".tsx")||f.path.endsWith(".jsx");x.split(/\r?\n/).forEach((v,S)=>{let C;for(;(C=d.exec(v))!==null;){let T=C[1]||C[2];if(!T||T==="NODE_ENV")continue;c++;let ie={variable:T,filePath:f.path,line:S+1,isClientFile:k};i.has(T)||i.set(T,[]),i.get(T).push(ie);let re=Rr.some(X=>T.startsWith(X));k&&!re&&rc.some(we=>we.test(T))&&l.push({variable:T,filePath:f.path,line:S+1,riskReason:`Potential backend secret '${T}' referenced in client UI file without public prefix (${Rr.join(", ")})`});}});}let u=Array.from(i.keys()).sort(),h=Array.from(r).sort(),g=n?u.filter(f=>!r.has(f)):[],m=n?h.filter(f=>!i.has(f)):[];return {usedVariables:u,declaredInExample:h,missingFromExample:g,unusedInCode:m,clientSecretLeaks:l,envFilesFound:a,totalOccurrences:c}}function oc(s,e){let t=s.split(/\r?\n/);for(let n of t){let r=n.trim();if(!r||r.startsWith("#"))continue;let o=r.indexOf("=");if(o>0){let a=r.slice(0,o).trim();/^[a-zA-Z0-9_]+$/.test(a)&&e.add(a);}else /^[a-zA-Z0-9_]+$/.test(r)&&e.add(r);}}var ic=new Set(["assert","async_hooks","buffer","child_process","cluster","console","constants","crypto","dgram","diagnostics_channel","dns","domain","events","fs","fs/promises","http","http2","https","inspector","module","net","os","path","path/posix","path/win32","perf_hooks","process","punycode","querystring","readline","repl","stream","stream/consumers","stream/promises","stream/web","string_decoder","timers","timers/promises","tls","trace_events","tty","url","util","util/types","v8","vm","wasi","worker_threads","zlib"]);function Nr(s,e){let t=G.join(s,"package.json"),n={},r={},o={};if(pe.existsSync(t))try{let f=JSON.parse(pe.readFileSync(t,"utf8"));n=f.dependencies||{},r=f.devDependencies||{},o=f.peerDependencies||{};}catch{}let a=new Set([...Object.keys(n),...Object.keys(r),...Object.keys(o)]),i=new Set([...Object.keys(n),...Object.keys(o)]),l=new Set(Object.keys(r)),c=new Set;try{let f=["packages","apps","examples"];for(let b of f){let x=G.join(s,b);if(pe.existsSync(x)){let k=pe.readdirSync(x,{withFileTypes:!0});for(let A of k)if(A.isDirectory()){let v=G.join(x,A.name,"package.json");if(pe.existsSync(v))try{let S=JSON.parse(pe.readFileSync(v,"utf8"));if(S.name&&c.add(S.name),S.dependencies)for(let C of Object.keys(S.dependencies))a.add(C);if(S.devDependencies)for(let C of Object.keys(S.devDependencies))a.add(C);}catch{}}}}}catch{}let d=new Map,u=/(?:import\s+(?:[\w*\s{},]*\s+from\s+)?|export\s+(?:[\w*\s{},]*\s+from\s+)?|require\(\s*)['"]([^'"]+)['"]/g;for(let f of e){if(f.type==="config"||f.type==="asset")continue;let b=G.isAbsolute(f.path)?f.path:G.join(s,f.path);if(!pe.existsSync(b))continue;let x="";try{x=pe.readFileSync(b,"utf8");}catch{continue}let k;for(;(k=u.exec(x))!==null;){let A=k[1],v=ac(A);v&&(ic.has(v)||v.startsWith("node:")||(d.has(v)||d.set(v,new Set),d.get(v).add(f.path)));}}let h=[];for(let[f,b]of d.entries())!a.has(f)&&!c.has(f)&&h.push({package:f,importedBy:Array.from(b).slice(0,5)});let g=[];for(let f of Object.keys(n))f.startsWith("@types/")||d.has(f)||g.push(f);let m=[];for(let[f,b]of d.entries())if(l.has(f)&&!i.has(f)){let x=Array.from(b).filter(k=>!k.includes(".test.")&&!k.includes(".spec.")&&!k.includes("/tests/"));x.length>0&&m.push({package:f,importedBy:x.slice(0,5)});}return {phantomDependencies:h,zombieDependencies:g,devDepsInProduction:m,totalPackagesDeclared:a.size,totalExternalImports:d.size}}function ac(s){let e=s.trim();if(e.startsWith(".")||e.startsWith("/")||e.startsWith("@/")||e.startsWith("~/")||e.startsWith("#")||e.includes(" ")||e.includes("$")||e.includes("(")||e.includes(")")||e.includes("*")||e.includes(`
|
|
1149
|
+
`)||e.includes("\r"))return null;if(e.startsWith("@")){let n=e.split("/");if(n.length>=2){let r=`${n[0]}/${n[1]}`;return Or(r)?r:null}return null}let t=e.split("/")[0];return Or(t)?t:null}function Or(s){return /^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/i.test(s)}var cc=new Set(["fs","node:fs","fs/promises","node:fs/promises","child_process","node:child_process","net","node:net","tls","node:tls","cluster","node:cluster","bcrypt","bcryptjs","argon2","@prisma/client","prisma","typeorm","pg","mysql2","mongodb","mongoose","knex","ioredis","redis"]);function Mr(s,e){let t=[],n=/import\s+([\s\S]*?)\s+from\s+['"]([^'"]+)['"]/g;for(let i of e){if(i.type==="config"||i.type==="asset"||i.type==="test")continue;let l=G.isAbsolute(i.path)?i.path:G.join(s,i.path);if(!pe.existsSync(l))continue;let c="";try{c=pe.readFileSync(l,"utf8");}catch{continue}let d=i.type==="component"||i.type==="route"||i.path.includes("/components/")||i.path.includes("/ui/")||i.path.endsWith(".tsx")||i.path.endsWith(".jsx");c.split(/\r?\n/).forEach((h,g)=>{let m;for(;(m=n.exec(h))!==null;){let f=m[1].trim(),b=m[2].trim();d&&cc.has(b)&&t.push({filePath:i.path,line:g+1,type:"server-in-client",specifier:b,message:`Server-only module '${b}' imported in client-side file. This will break browser bundles or leak server logic.`,suggestedFix:"Move server operations to an API route handler or server action."}),b==="lodash"&&f.startsWith("{")&&t.push({filePath:i.path,line:g+1,type:"barrel-trap",specifier:b,message:"Barrel import from 'lodash' pulls entire 70KB+ library into client bundle, defeating tree-shaking.",suggestedFix:"Use direct deep import (e.g. 'lodash/debounce' or 'lodash-es')."}),f.startsWith("* as")&&(b.includes("lucide-react")||b.includes("react-icons")||b.includes("@heroicons"))&&t.push({filePath:i.path,line:g+1,type:"wildcard-import",specifier:b,message:`Wildcard import '* as' from icon library '${b}' bundles hundreds of unrendered SVGs.`,suggestedFix:`Import only the specific icons used: 'import { IconName } from "${b}"'.`});}});}let r=t.filter(i=>i.type==="barrel-trap").length,o=t.filter(i=>i.type==="server-in-client").length,a=t.filter(i=>i.type==="wildcard-import").length;return {totalIssues:t.length,barrelTrapsCount:r,serverInClientCount:o,wildcardImportsCount:a,issues:t}}function Br(s,e,t){let n=e.filter(u=>u.type==="test"||u.path.includes(".test.")||u.path.includes(".spec.")||u.path.includes("/tests/")||u.path.includes("/__tests__/")),r=e.filter(u=>u.type!=="test"&&u.type!=="config"&&u.type!=="asset"&&!u.path.includes(".test.")&&!u.path.includes(".spec.")&&!u.path.includes("/tests/")&&!u.path.includes("/__tests__/")),o=new Map,a=/(?:import\s+(?:[\w*\s{},]*\s+from\s+)?|require\(\s*)['"]([^'"]+)['"]/g;for(let u of n){let h=G.isAbsolute(u.path)?u.path:G.join(s,u.path);if(!pe.existsSync(h))continue;let g="";try{g=pe.readFileSync(h,"utf8");}catch{continue}let m;for(;(m=a.exec(g))!==null;){let b=m[1];if(b.startsWith(".")){let x=G.dirname(h),k=G.resolve(x,b);for(let A of r){let S=(G.isAbsolute(A.path)?A.path:G.join(s,A.path)).replace(/\.[^/.]+$/,""),C=k.replace(/\.[^/.]+$/,"");S===C&&(o.has(A.path)||o.set(A.path,new Set),o.get(A.path).add(u.path));}}}let f=G.basename(u.path).replace(/\.(test|spec)\.[^/.]+$/,"");for(let b of r)G.basename(b.path).replace(/\.[^/.]+$/,"")===f&&(o.has(b.path)||o.set(b.path,new Set),o.get(b.path).add(u.path));}let i=[];for(let u of r)if(!o.has(u.path)){let h=u.metrics?.complexity||1,g=t.getDependents(u.path).length,m=u.metrics?.linesOfCode||10,f=u.type==="service"?1.5:u.type==="hook"?1.3:u.type==="component"?1:.8,b=Math.round((h*4+g*8+Math.min(m,200)*.2)*f),x=b>=35||g>=4?"CRITICAL":b>=20||g>=2?"HIGH":b>=10?"MEDIUM":"LOW";i.push({filePath:u.path,name:u.name,type:u.type,feature:u.feature,complexity:h,dependentsCount:g,linesOfCode:m,riskScore:b,priority:x});}i.sort((u,h)=>h.riskScore-u.riskScore);let l=r.length-i.length,c=r.length>0?Math.round(l/r.length*100):100,d=i.filter(u=>u.priority==="CRITICAL"||u.priority==="HIGH");return {totalSourceFiles:r.length,testedSourceFiles:l,untestedSourceFiles:i.length,coveragePercentage:c,testSuitesCount:n.length,criticalGaps:d.slice(0,10),untestedFiles:i}}async function Ur(s={}){let e=process.cwd(),{config:t}=ke(e),{discovery:n,nodes:r}=await I(e),{graph:o}=Z(e,r,n.typeScript),a=Je.evaluate({graph:o,nodes:r,edges:o.getAllEdges(),config:t}),i=vs(e,r,6),l=ys({nodes:r,issues:a,graph:o,hasTests:!!n.detected.testingFramework,duplicateBlockCount:i.clusters.length});if(s.json){console.log(JSON.stringify(l,null,2));return}console.log(`
|
|
1150
1150
|
`+nr(l)+`
|
|
1151
|
-
`);let c=G.join(e,
|
|
1151
|
+
`);let c=G.join(e,ue,"reports");pe.existsSync(c)&&pe.writeFileSync(G.join(c,"health.json"),JSON.stringify(l,null,2),"utf8");}var ee=W(U());async function Vr(){let s=process.cwd(),{discovery:e,nodes:t}=await I(s),{parsedFiles:n}=Z(s,t,e.typeScript),r=Cr(t,n);if(console.log(ee.default.bold(ee.default.cyan(`
|
|
1152
1152
|
\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501`))),console.log(ee.default.bold(ee.default.cyan(" DEVARCHITECT CODE COMPLEXITY ANALYSIS"))),console.log(ee.default.bold(ee.default.cyan("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"))),console.log(` Average Complexity: ${ee.default.bold(String(r.averageComplexity))} | Total Complexity: ${ee.default.bold(String(r.totalComplexity))}`),console.log(` Hotspot Files: ${r.hotspots.length>0?ee.default.yellow(String(r.hotspots.length)):ee.default.green("0")}`),console.log(` Oversized Files: ${r.oversizedFiles.length>0?ee.default.yellow(String(r.oversizedFiles.length)):ee.default.green("0")}
|
|
1153
1153
|
`),r.hotspots.length>0){console.log(ee.default.bold(" Top Complexity Hotspots:"));for(let o of r.hotspots.slice(0,10)){let a=o.risk==="critical"?ee.default.red:o.risk==="high"?ee.default.yellow:ee.default.white;if(console.log(` \u2022 ${ee.default.bold(o.filePath)}`),console.log(` Complexity: ${a(String(o.complexity))} [${o.risk.toUpperCase()}] | ${o.linesOfCode} LOC`),o.topSymbols.length>0){let i=o.topSymbols.map(l=>`${l.name}() [${l.complexity}]`).join(", ");console.log(` Functions: ${ee.default.gray(i)}`);}}console.log("");}else console.log(ee.default.green(` \u2714 No high-complexity hotspots detected. Codebase control flow is well balanced.
|
|
1154
1154
|
`));if(r.oversizedFiles.length>0){console.log(ee.default.bold(" Oversized Files (> 250 LOC):"));for(let o of r.oversizedFiles.slice(0,10))console.log(` \u2022 ${o.filePath} (${ee.default.yellow(`${o.linesOfCode} LOC`)})`);console.log("");}}var ce=W(U());async function Gr(){let s=process.cwd(),{discovery:e,nodes:t}=await I(s),{graph:n,parsedFiles:r}=Z(s,t,e.typeScript),o=kr(t,n.getAllEdges(),r,e.entryPoints);if(console.log(ce.default.bold(ce.default.cyan(`
|
|
1155
1155
|
\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501`))),console.log(ce.default.bold(ce.default.cyan(" DEVARCHITECT DEAD CODE & UNUSED EXPORTS"))),console.log(ce.default.bold(ce.default.cyan("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"))),console.log(` Unused Exports: ${o.unusedExports.length>0?ce.default.yellow(String(o.unusedExports.length)):ce.default.green("0")}`),console.log(` Orphaned Files: ${o.orphanedFiles.length>0?ce.default.yellow(String(o.orphanedFiles.length)):ce.default.green("0")}
|
|
1156
1156
|
`),o.unusedExports.length>0){console.log(ce.default.bold(" Unused Exported Symbols:"));for(let a of o.unusedExports.slice(0,20)){let i=a.isTypeOnly?ce.default.blue(" [type]"):"";console.log(` \u2022 ${ce.default.bold(a.exportName)}${i} in ${ce.default.gray(`${a.filePath}:${a.line}`)}`);}o.unusedExports.length>20?console.log(ce.default.gray(` ... and ${o.unusedExports.length-20} more
|
|
1157
1157
|
`)):console.log("");}else console.log(ce.default.green(` \u2714 No unused exports detected.
|
|
1158
|
-
`));if(o.orphanedFiles.length>0){console.log(ce.default.bold(" Orphaned Files (Never imported by any other file):"));for(let a of o.orphanedFiles.slice(0,15))console.log(` \u2022 ${ce.default.yellow(a)}`);console.log("");}}var
|
|
1159
|
-
\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501`))),console.log(
|
|
1160
|
-
`),r.clusters.length>0){console.log(
|
|
1161
|
-
`));}var z=W(U());async function qr(){let s=process.cwd(),{discovery:e,nodes:t}=await I(s),{graph:n}=Z(s,t,e.typeScript),r=Ve(n),o=
|
|
1158
|
+
`));if(o.orphanedFiles.length>0){console.log(ce.default.bold(" Orphaned Files (Never imported by any other file):"));for(let a of o.orphanedFiles.slice(0,15))console.log(` \u2022 ${ce.default.yellow(a)}`);console.log("");}}var be=W(U());async function Zr(s={}){let e=process.cwd(),t=s.lines?parseInt(s.lines,10):6,{nodes:n}=await I(e),r=vs(e,n,t);if(console.log(be.default.bold(be.default.cyan(`
|
|
1159
|
+
\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501`))),console.log(be.default.bold(be.default.cyan(" DEVARCHITECT CODE DUPLICATION ANALYSIS"))),console.log(be.default.bold(be.default.cyan("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"))),console.log(` Duplicate Clusters: ${r.clusters.length>0?be.default.yellow(String(r.clusters.length)):be.default.green("0")}`),console.log(` Total Duplicate Lines: ${r.totalDuplicateLines>0?be.default.yellow(String(r.totalDuplicateLines)):be.default.green("0")}`),console.log(` Duplication Ratio: ${r.duplicationPercentage>0?be.default.yellow(`${r.duplicationPercentage}%`):be.default.green("0%")}
|
|
1160
|
+
`),r.clusters.length>0){console.log(be.default.bold(" Duplicate Clusters:"));for(let o=0;o<Math.min(r.clusters.length,10);o++){let a=r.clusters[o];console.log(` [Cluster #${o+1}] (${a.lineCount} lines replicated across ${a.instances.length} locations)`);for(let i of a.instances)console.log(` \u2022 ${be.default.bold(i.filePath)}:${i.startLine}-${i.endLine}`);console.log("");}}else console.log(be.default.green(` \u2714 No duplicate code blocks detected.
|
|
1161
|
+
`));}var z=W(U());async function qr(){let s=process.cwd(),{discovery:e,nodes:t}=await I(s),{graph:n}=Z(s,t,e.typeScript),r=Ve(n),o=qs(e.project,t,n.getAllEdges(),r.length),a=G.join(s,ue,"fingerprint.json"),i=G.dirname(a);pe.existsSync(i)||pe.mkdirSync(i,{recursive:true}),pe.writeFileSync(a,JSON.stringify(o,null,2),"utf8"),console.log(z.default.bold(z.default.cyan(`
|
|
1162
1162
|
\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501`))),console.log(z.default.bold(z.default.cyan(" DEVARCHITECT ARCHITECTURE FINGERPRINT"))),console.log(z.default.bold(z.default.cyan("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"))),console.log(` Project: ${z.default.bold(o.projectName)}`),console.log(` Fingerprint SHA: ${z.default.bold(o.hash.slice(0,16))}...`),console.log(` Module Slices: ${o.summary.modulesCount}`),console.log(` Edges Signature: ${o.summary.edgeCount}`),console.log(` Cycles: ${o.summary.cycleCount}`),console.log(` Total LOC: ${o.summary.totalLoc.toLocaleString()}`),console.log(z.default.bold(z.default.cyan("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"))),console.log(z.default.green(`\u2714 Saved reproducible architecture fingerprint to ${a}
|
|
1163
|
-
`));}async function Kr(){let s=process.cwd(),e=G.join(s,
|
|
1164
|
-
\u26A0 No saved architecture fingerprint found at ${e}.`)),console.log(z.default.gray(" Run `devarchitect fingerprint` first to create an architecture baseline snapshot.\n"));return}let t=
|
|
1163
|
+
`));}async function Kr(){let s=process.cwd(),e=G.join(s,ue,"fingerprint.json");if(!pe.existsSync(e)){console.log(z.default.yellow(`
|
|
1164
|
+
\u26A0 No saved architecture fingerprint found at ${e}.`)),console.log(z.default.gray(" Run `devarchitect fingerprint` first to create an architecture baseline snapshot.\n"));return}let t=pe.readFileSync(e,"utf8"),n=JSON.parse(t),{discovery:r,nodes:o}=await I(s),{graph:a}=Z(s,o,r.typeScript),i=Ve(a),l=qs(r.project,o,a.getAllEdges(),i.length),c=_r(n,l);console.log(z.default.bold(z.default.cyan(`
|
|
1165
1165
|
\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501`))),console.log(z.default.bold(z.default.cyan(" DEVARCHITECT ARCHITECTURE DRIFT DETECTION"))),console.log(z.default.bold(z.default.cyan("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"))),console.log(` Baseline Date: ${new Date(c.previousTimestamp).toLocaleString()}`),console.log(` Current Date: ${new Date(c.currentTimestamp).toLocaleString()}`);let d=c.driftScore>20?z.default.red:c.driftScore>5?z.default.yellow:z.default.green;if(console.log(` Drift Score: ${d(z.default.bold(`${c.driftScore}%`))} ${c.hasDiverged?z.default.yellow("[DIVERGED]"):z.default.green("[IDENTICAL]")}
|
|
1166
1166
|
`),!c.hasDiverged){console.log(z.default.green(` \u2714 Architecture is 100% compliant with baseline fingerprint. No drift detected.
|
|
1167
1167
|
`));return}if(c.changes.newBoundaries.length>0){console.log(z.default.bold(" New Module Boundaries:"));for(let u of c.changes.newBoundaries)console.log(` ${z.default.green("+")} ${u}`);console.log("");}if(c.changes.removedBoundaries.length>0){console.log(z.default.bold(" Removed Module Boundaries:"));for(let u of c.changes.removedBoundaries)console.log(` ${z.default.red("-")} ${u}`);console.log("");}if(c.changes.addedEdges.length>0){console.log(z.default.bold(` Newly Introduced Couplings (${c.changes.addedEdges.length}):`));for(let u of c.changes.addedEdges.slice(0,10))console.log(` ${z.default.yellow("\u2192")} ${u}`);c.changes.addedEdges.length>10&&console.log(z.default.gray(` ... and ${c.changes.addedEdges.length-10} more`)),console.log("");}console.log(z.default.gray(` LOC Delta: ${c.changes.locDelta>=0?"+":""}${c.changes.locDelta} LOC
|
|
1168
|
-
`));}var ae=W(U());function
|
|
1168
|
+
`));}var ae=W(U());function $s(s){return s.replace(/[-_](\w)/g,(e,t)=>t.toUpperCase()).replace(/^\w/,e=>e.toUpperCase())}function Jr(s){let e=$s(s);return e.charAt(0).toLowerCase()+e.slice(1)}function Yr(s,e,t){let n=t.toLowerCase(),r=$s(t),o=Jr(t),i=pe.existsSync(G.join(s,"src"))?G.join(s,"src","features",n):G.join(s,"features",n),l=G.join(i,"components"),c=G.join(i,"hooks"),d=G.join(i,"services"),u=G.join(i,"types");pe.mkdirSync(l,{recursive:true}),pe.mkdirSync(c,{recursive:true}),pe.mkdirSync(d,{recursive:true}),pe.mkdirSync(u,{recursive:true});let h=e.project.language!=="JavaScript",g=h?"ts":"js",m=h?"tsx":"jsx",f=[],b=h?`export interface ${r}Item {
|
|
1169
1169
|
id: string;
|
|
1170
1170
|
name: string;
|
|
1171
1171
|
createdAt: string;
|
|
1172
1172
|
}
|
|
1173
1173
|
`:`// Types for ${r}
|
|
1174
|
-
`,x=G.join(u,`index.${g}`);
|
|
1174
|
+
`,x=G.join(u,`index.${g}`);pe.writeFileSync(x,b,"utf8"),f.push(G.relative(s,x).replace(/\\/g,"/"));let k=`import type { ${r}Item } from '../types/index.js';
|
|
1175
1175
|
|
|
1176
1176
|
export async function fetch${r}List(): Promise<${r}Item[]> {
|
|
1177
1177
|
// Replace with API endpoint call
|
|
@@ -1179,7 +1179,7 @@ export async function fetch${r}List(): Promise<${r}Item[]> {
|
|
|
1179
1179
|
{ id: '1', name: '${r} 1', createdAt: new Date().toISOString() },
|
|
1180
1180
|
];
|
|
1181
1181
|
}
|
|
1182
|
-
`,A=G.join(d,`${o}Service.${g}`);
|
|
1182
|
+
`,A=G.join(d,`${o}Service.${g}`);pe.writeFileSync(A,k,"utf8"),f.push(G.relative(s,A).replace(/\\/g,"/"));let v=`import { useState, useEffect } from 'react';
|
|
1183
1183
|
import { fetch${r}List } from '../services/${o}Service.js';
|
|
1184
1184
|
import type { ${r}Item } from '../types/index.js';
|
|
1185
1185
|
|
|
@@ -1196,7 +1196,7 @@ export function use${r}() {
|
|
|
1196
1196
|
|
|
1197
1197
|
return { data, loading };
|
|
1198
1198
|
}
|
|
1199
|
-
`,S=G.join(c,`use${r}.${g}`);
|
|
1199
|
+
`,S=G.join(c,`use${r}.${g}`);pe.writeFileSync(S,v,"utf8"),f.push(G.relative(s,S).replace(/\\/g,"/"));let C=`import React from 'react';
|
|
1200
1200
|
import { use${r} } from '../hooks/use${r}.js';
|
|
1201
1201
|
|
|
1202
1202
|
export function ${r}View() {
|
|
@@ -1215,12 +1215,12 @@ export function ${r}View() {
|
|
|
1215
1215
|
</section>
|
|
1216
1216
|
);
|
|
1217
1217
|
}
|
|
1218
|
-
`,T=G.join(l,`${r}View.${m}`);
|
|
1218
|
+
`,T=G.join(l,`${r}View.${m}`);pe.writeFileSync(T,C,"utf8"),f.push(G.relative(s,T).replace(/\\/g,"/"));let ie=`// Public API for ${r} feature
|
|
1219
1219
|
export * from './components/${r}View.js';
|
|
1220
1220
|
export * from './hooks/use${r}.js';
|
|
1221
1221
|
export * from './services/${o}Service.js';
|
|
1222
1222
|
export * from './types/index.js';
|
|
1223
|
-
`,re=G.join(i,`index.${g}`);return
|
|
1223
|
+
`,re=G.join(i,`index.${g}`);return pe.writeFileSync(re,ie,"utf8"),f.push(G.relative(s,re).replace(/\\/g,"/")),{createdFiles:f,moduleName:n}}function Xr(s,e,t,n){let r=$s(t),o=pe.existsSync(G.join(s,"src")),a=o?G.join(s,"src","components"):G.join(s,"components");pe.existsSync(a)||pe.mkdirSync(a,{recursive:true});let i=e.project.language!=="JavaScript",l=i?"tsx":"jsx",c=`import React from 'react';
|
|
1224
1224
|
|
|
1225
1225
|
${i?`export interface ${r}Props {
|
|
1226
1226
|
title?: string;
|
|
@@ -1234,7 +1234,7 @@ export function ${r}(${i?`{ title = '${r}', className = '' }: ${r}Props`:"{ titl
|
|
|
1234
1234
|
</div>
|
|
1235
1235
|
);
|
|
1236
1236
|
}
|
|
1237
|
-
`,d=G.join(a,`${r}.${l}`);return
|
|
1237
|
+
`,d=G.join(a,`${r}.${l}`);return pe.writeFileSync(d,c,"utf8"),{createdFiles:[G.relative(s,d).replace(/\\/g,"/")],moduleName:r}}function Qr(s,e,t){let n=Jr(t),r=$s(t),a=pe.existsSync(G.join(s,"src"))?G.join(s,"src","services"):G.join(s,"services");pe.existsSync(a)||pe.mkdirSync(a,{recursive:true});let i=e.project.language!=="JavaScript",l=i?"ts":"js",c=`${i?`export interface ${r}Response {
|
|
1238
1238
|
success: boolean;
|
|
1239
1239
|
data: unknown;
|
|
1240
1240
|
}
|
|
@@ -1245,23 +1245,23 @@ export async function execute${r}(): Promise<${i?`${r}Response`:"any"}> {
|
|
|
1245
1245
|
data: null,
|
|
1246
1246
|
};
|
|
1247
1247
|
}
|
|
1248
|
-
`,d=n.endsWith("Service")?`${n}.${l}`:`${n}Service.${l}`,u=G.join(a,d);return
|
|
1248
|
+
`,d=n.endsWith("Service")?`${n}.${l}`:`${n}Service.${l}`,u=G.join(a,d);return pe.writeFileSync(u,c,"utf8"),{createdFiles:[G.relative(s,u).replace(/\\/g,"/")],moduleName:r}}async function eo(s,e){let t=process.cwd();(!s||!e)&&(console.log(ae.default.red(`
|
|
1249
1249
|
\u2716 Error: Please specify generation type and name.`)),console.log(ae.default.gray(" Example: devarchitect generate feature billing")),console.log(ae.default.gray(" Example: devarchitect generate component UserAvatar")),console.log(ae.default.gray(` Example: devarchitect generate service payment
|
|
1250
1250
|
`)),process.exit(1));let{discovery:n}=await I(t),r=s.toLowerCase();console.log(ae.default.bold(ae.default.cyan(`
|
|
1251
1251
|
\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501`))),console.log(ae.default.bold(ae.default.cyan(" DEVARCHITECT CODE GENERATOR"))),console.log(ae.default.bold(ae.default.cyan("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"))),console.log(` Scaffolding: ${ae.default.bold(r)} '${ae.default.bold(e)}'`),console.log(` Conventions: Framework: ${ae.default.bold(n.project.framework)} | Language: ${ae.default.bold(n.project.language)}
|
|
1252
1252
|
`);try{let o;r==="feature"||r==="module"?o=Yr(t,n,e):r==="component"?o=Xr(t,n,e):r==="service"?o=Qr(t,n,e):(console.log(ae.default.red(`\u2716 Unknown generator type '${s}'. Supported types: feature, component, service`)),process.exit(1)),console.log(ae.default.green(`\u2714 Successfully scaffolded ${r} '${o.moduleName}':
|
|
1253
1253
|
`));for(let a of o.createdFiles)console.log(` ${ae.default.green("+")} ${ae.default.white(a)}`);console.log("");}catch(o){let a=o instanceof Error?o.message:String(o);console.error(ae.default.red(`\u2716 Scaffolding failed: ${a}
|
|
1254
|
-
`)),process.exit(1);}}var le=W(U());async function to(){let s=process.cwd(),{config:e}=
|
|
1254
|
+
`)),process.exit(1);}}var le=W(U());async function to(){let s=process.cwd(),{config:e}=ke(s),t=e.architecture.preset;console.log(le.default.bold(le.default.cyan(`
|
|
1255
1255
|
\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501`))),console.log(le.default.bold(le.default.cyan(" DEVARCHITECT ARCHITECTURE POLICY RULES"))),console.log(le.default.bold(le.default.cyan("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"))),console.log(` Active Preset: ${le.default.bold(t)}
|
|
1256
|
-
`),console.log(le.default.bold(" Built-in Architecture Rules:"));for(let n of
|
|
1256
|
+
`),console.log(le.default.bold(" Built-in Architecture Rules:"));for(let n of hs){let r=e.architecture.rules[n.id],o=Rt[t]?.[n.id]||n.defaultSeverity,a=r||o,i=a==="error"?le.default.red(le.default.bold("[ERROR]")):a==="warning"?le.default.yellow(le.default.bold("[WARN]")):le.default.gray("[OFF]");console.log(` ${i} ${le.default.bold(n.id)}`),console.log(` ${le.default.gray(n.description)}`);}console.log(le.default.bold(`
|
|
1257
1257
|
Supported Architecture Presets:`));for(let n of Object.keys(Rt)){let r=n===t?le.default.green(" (Active)"):"";console.log(` \u2022 ${le.default.bold(n)}${r}`);}console.log("");}var L=W(U());async function so(){let s=process.cwd(),{nodes:e}=await I(s);console.log(L.default.bold(L.default.cyan(`
|
|
1258
|
-
\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501`))),console.log(L.default.bold(L.default.cyan(" DEVARCHITECT REACT RE-RENDER & PERFORMANCE ANALYZER"))),console.log(L.default.bold(L.default.cyan("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501")));let t=
|
|
1258
|
+
\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501`))),console.log(L.default.bold(L.default.cyan(" DEVARCHITECT REACT RE-RENDER & PERFORMANCE ANALYZER"))),console.log(L.default.bold(L.default.cyan("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501")));let t=xs(s,e);if(console.log(` Components Analyzed: ${L.default.bold(String(t.componentsAnalyzed))}`),console.log(` Re-render Bottlenecks: ${t.totalIssues>0?L.default.yellow(L.default.bold(String(t.totalIssues))):L.default.green("0")}
|
|
1259
1259
|
`),t.issues.length===0){console.log(L.default.green(` \u2714 No unnecessary re-render traps or hook anti-patterns detected.
|
|
1260
1260
|
`));return}let n=t.issues.filter(i=>i.issueType==="inline-function-prop"||i.issueType==="inline-object-prop"),r=t.issues.filter(i=>i.issueType==="unmemoized-context"),o=t.issues.filter(i=>i.issueType==="derived-state-effect"),a=t.issues.filter(i=>i.issueType==="excessive-hooks");if(n.length>0){console.log(L.default.bold(L.default.yellow(` \u26A0 Inline JSX Object/Function Allocations (${n.length}):`)));for(let i of n.slice(0,10))console.log(` \u2022 ${L.default.bold(i.filePath)}:${i.line} [${L.default.magenta(i.componentName)}]`),console.log(` ${L.default.gray(i.message)}`),console.log(` ${L.default.cyan("Tip:")} ${i.suggestion}`);n.length>10&&console.log(L.default.gray(` ... and ${n.length-10} more`)),console.log("");}if(r.length>0){console.log(L.default.bold(L.default.red(` \u2716 Unmemoized Context Value Allocations (${r.length}):`)));for(let i of r)console.log(` \u2022 ${L.default.bold(i.filePath)}:${i.line}`),console.log(` ${L.default.gray(i.message)}`),console.log(` ${L.default.cyan("Tip:")} ${i.suggestion}`);console.log("");}if(o.length>0){console.log(L.default.bold(L.default.yellow(` \u26A0 Derived State in useEffect (${o.length}):`)));for(let i of o)console.log(` \u2022 ${L.default.bold(i.filePath)}:${i.line} [${L.default.magenta(i.componentName)}]`),console.log(` ${L.default.gray(i.message)}`),console.log(` ${L.default.cyan("Tip:")} ${i.suggestion}`);console.log("");}if(a.length>0){console.log(L.default.bold(L.default.yellow(` \u26A0 Heavy State Orchestration (${a.length}):`)));for(let i of a)console.log(` \u2022 ${L.default.bold(i.filePath)}:${i.line} [${L.default.magenta(i.componentName)}]`),console.log(` ${L.default.gray(i.message)}`),console.log(` ${L.default.cyan("Tip:")} ${i.suggestion}`);console.log("");}}var B=W(U());async function no(){let s=process.cwd(),{discovery:e,nodes:t}=await I(s),{graph:n}=Z(s,t,e.typeScript);console.log(B.default.bold(B.default.cyan(`
|
|
1261
|
-
\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501`))),console.log(B.default.bold(B.default.cyan(" DEVARCHITECT TYPE SYSTEM & HEALTH ANALYZER"))),console.log(B.default.bold(B.default.cyan("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501")));let o=
|
|
1261
|
+
\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501`))),console.log(B.default.bold(B.default.cyan(" DEVARCHITECT TYPE SYSTEM & HEALTH ANALYZER"))),console.log(B.default.bold(B.default.cyan("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501")));let o=bs(s,t,n.getAllEdges()),a=o.typeSafetyScore>=90?B.default.green:o.typeSafetyScore>=70?B.default.yellow:B.default.red;if(console.log(` Type Safety Score: ${a(B.default.bold(`${o.typeSafetyScore}/100`))}`),console.log(` Total Types Declared: ${B.default.bold(String(o.totalTypesDeclared))}`),console.log(` Unused Types/Enums: ${o.unusedTypes.length>0?B.default.yellow(String(o.unusedTypes.length)):B.default.green("0")}`),console.log(` Unsafe 'any' Hotspots: ${o.anyHotspots.length>0?B.default.red(String(o.anyHotspots.length)):B.default.green("0")}`),console.log(` Duplicate Type Models: ${o.duplicateTypes.length>0?B.default.yellow(String(o.duplicateTypes.length)):B.default.green("0")}
|
|
1262
1262
|
`),o.unusedTypes.length>0){console.log(B.default.bold(B.default.yellow(` \u26A0 Unused Types & Interfaces (${o.unusedTypes.length}):`)));for(let i of o.unusedTypes.slice(0,15))console.log(` \u2022 ${B.default.bold(i.name)} (${i.kind}) in ${B.default.gray(`${i.filePath}:${i.line}`)}`);o.unusedTypes.length>15&&console.log(B.default.gray(` ... and ${o.unusedTypes.length-15} more`)),console.log("");}if(o.anyHotspots.length>0){console.log(B.default.bold(B.default.red(` \u2716 Unsafe 'any' Type Escapes (${o.anyHotspots.length}):`)));for(let i of o.anyHotspots.slice(0,10))console.log(` \u2022 ${B.default.bold(i.filePath)}:${i.line} [${B.default.magenta(i.kind)}]`),console.log(` ${B.default.gray(i.snippet)}`);o.anyHotspots.length>10&&console.log(B.default.gray(` ... and ${o.anyHotspots.length-10} more`)),console.log("");}if(o.duplicateTypes.length>0){console.log(B.default.bold(B.default.yellow(` \u26A0 Duplicate Type Definitions (${o.duplicateTypes.length}):`)));for(let i of o.duplicateTypes){console.log(` \u2022 Type '${B.default.bold(i.typeName)}' declared redundantly across:`);for(let l of i.locations)console.log(` - ${B.default.gray(`${l.filePath}:${l.line}`)}`);console.log(` ${B.default.cyan("Tip:")} Unify into a shared types module to keep contracts in sync.`);}console.log("");}o.unusedTypes.length===0&&o.anyHotspots.length===0&&o.duplicateTypes.length===0&&console.log(B.default.green(` \u2714 Type definitions are clean, unified, and strictly typed.
|
|
1263
1263
|
`));}var Y=W(U());async function ro(){let s=process.cwd(),{nodes:e}=await I(s);console.log(Y.default.bold(Y.default.cyan(`
|
|
1264
|
-
\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501`))),console.log(Y.default.bold(Y.default.cyan(" DEVARCHITECT CODE SMELLS & ANTI-PATTERNS"))),console.log(Y.default.bold(Y.default.cyan("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501")));let t=
|
|
1264
|
+
\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501`))),console.log(Y.default.bold(Y.default.cyan(" DEVARCHITECT CODE SMELLS & ANTI-PATTERNS"))),console.log(Y.default.bold(Y.default.cyan("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501")));let t=ws(s,e);if(console.log(` Total Code Smells: ${t.totalSmells>0?Y.default.yellow(Y.default.bold(String(t.totalSmells))):Y.default.green("0")}`),console.log(` Critical Errors: ${t.errorsCount>0?Y.default.red(Y.default.bold(String(t.errorsCount))):Y.default.green("0")}`),console.log(` Warnings: ${t.warningsCount>0?Y.default.yellow(String(t.warningsCount)):Y.default.green("0")}
|
|
1265
1265
|
`),t.smells.length===0){console.log(Y.default.green(` \u2714 No critical code smells or anti-patterns detected.
|
|
1266
1266
|
`));return}let n=[{key:"empty-catch",title:"Empty Catch Blocks (Swallowed Errors)"},{key:"unhandled-async",title:"Unhandled Async Network / API Calls"},{key:"hardcoded-secret",title:"Potential Hardcoded Secrets / Tokens"},{key:"god-component",title:"Oversized Single-Responsibility Breaches"},{key:"console-log",title:"Leftover Debug Console Logs"}];for(let r of n){let o=t.smells.filter(a=>a.category===r.key);if(o.length>0){console.log(Y.default.bold(` ${o[0].severity==="error"?Y.default.red("\u2716"):Y.default.yellow("\u26A0")} ${r.title} (${o.length}):`));for(let a of o.slice(0,8))console.log(` \u2022 ${Y.default.bold(a.filePath)}:${a.line}`),console.log(` ${Y.default.gray(a.message)}`),console.log(` ${Y.default.cyan("Fix:")} ${a.suggestion}`);o.length>8&&console.log(Y.default.gray(` ... and ${o.length-8} more`)),console.log("");}}}var N=W(U());async function io(s){let e=process.cwd();s||(console.error(N.default.red(`
|
|
1267
1267
|
\u2716 Error: Please specify a target file path to simulate change impact.`)),console.log(N.default.gray(` Example: devarchitect simulate src/services/api.ts
|
|
@@ -1270,10 +1270,10 @@ export async function execute${r}(): Promise<${i?`${r}Response`:"any"}> {
|
|
|
1270
1270
|
`),i.contractMembers.length>0){console.log(N.default.bold(" Exposed Public Contract (What downstream code relies on):"));for(let c of i.contractMembers)console.log(` \u2022 ${N.default.white(c.kind)} ${N.default.bold(c.name)} ${N.default.cyan(c.details)} ${N.default.gray(`(line ${c.line})`)}`);console.log("");}if(i.consumers.length>0){console.log(N.default.bold(" Downstream Consumers & Active Call Sites:"));for(let c of i.consumers){console.log(` ${N.default.yellow("\u2192")} ${N.default.bold(c.consumerFile)}`),console.log(` Imports: ${N.default.cyan(c.importedSymbols.join(", "))}`);for(let d of c.callLines.slice(0,3))console.log(` line ${d.line}: ${N.default.gray(d.codeSnippet)}`);}console.log("");}else console.log(N.default.green(` \u2714 No external consumers depend on this module. Safe to refactor or delete.
|
|
1271
1271
|
`));if(i.breakingChangeWarnings.length>0){console.log(N.default.bold(N.default.red(" \u26A0 Potential Breaking Impacts:")));for(let c of i.breakingChangeWarnings)console.log(` \u2716 ${c}`);console.log("");}console.log(N.default.bold(" Safe Refactoring Playbook:"));for(let c of i.safeRefactoringGuide)console.log(` \u2714 ${N.default.gray(c)}`);console.log(N.default.bold(N.default.cyan(`
|
|
1272
1272
|
\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
|
|
1273
|
-
`)));}var H=W(U());async function co(s={}){let e=process.cwd(),{discovery:t,nodes:n}=await I(e),{graph:r}=Z(e,n,t.typeScript),{config:o}=
|
|
1273
|
+
`)));}var H=W(U());async function co(s={}){let e=process.cwd(),{discovery:t,nodes:n}=await I(e),{graph:r}=Z(e,n,t.typeScript),{config:o}=ke(e),a=[],i="Branch vs "+(s.base||"main");if(s.prePush?(a=Xn(e),i="Outgoing Commits (Pre-Push Scan)"):s.staged?(a=Jn(e),i="Staged Git Changes"):a=Yn(e,s.base||"main"),console.log(H.default.bold(H.default.cyan(`
|
|
1274
1274
|
\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501`))),console.log(H.default.bold(H.default.cyan(" DEVARCHITECT AI CODE REVIEW & PR BLAST RADIUS"))),console.log(H.default.bold(H.default.cyan("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"))),console.log(` Mode: ${H.default.bold(i)} | Changed Files: ${H.default.bold(String(a.length))}
|
|
1275
1275
|
`),a.length===0){console.log(H.default.green(` \u2714 No unpushed or divergent file changes detected.
|
|
1276
|
-
`));return}let l=new Set,c=new Set,d=new Set,u=[];for(let S of a){let C=
|
|
1276
|
+
`));return}let l=new Set,c=new Set,d=new Set,u=[];for(let S of a){let C=us(r,S);for(let T of C.directDependents)l.add(T);for(let T of C.transitiveDependents)c.add(T);for(let T of C.affectedFeatures)d.add(T);u.push({file:S,direct:C.directDependents.length,transitive:C.transitiveDependents.length,features:C.affectedFeatures});}let h=c.size,g=h>25||d.size>=4,m=h>10||d.size>=2,f=h>2,b=g?"CRITICAL RISK":m?"HIGH RISK":f?"MEDIUM RISK":"LOW RISK",x=g?H.default.bgRed(H.default.white(H.default.bold(" CRITICAL RISK "))):m?H.default.red(H.default.bold("HIGH RISK")):f?H.default.yellow(H.default.bold("MEDIUM RISK")):H.default.green(H.default.bold("LOW RISK")),A=Je.evaluate({config:o,nodes:n,edges:r.getAllEdges(),graph:r}).filter(S=>a.includes(S.filePath));console.log(` Cumulative Blast Radius: ${x}`),console.log(` Modified Files: ${a.length}`),console.log(` Direct Callers Impacted: ${l.size}`),console.log(` Total Downstream Impact: ${c.size} files`),console.log(` Affected Business Slices:${d.size>0?Array.from(d).join(", "):"None"}`),console.log(` Architecture Violations: ${A.length>0?H.default.red(`${A.length} in changed files`):H.default.green("0 (Clean)")}
|
|
1277
1277
|
`),console.log(H.default.bold(" Modified Files & Blast Radius:"));for(let S of u)console.log(` \u2022 ${H.default.white(S.file)} ${H.default.gray(`(direct: ${S.direct}, downstream: ${S.transitive})`)}`);if(console.log(""),d.size>0){console.log(H.default.bold(" Suggested Verification Checklist for this PR:"));for(let S of d)console.log(` \u2714 Run all ${S} feature unit & integration tests`);console.log("");}let v=`## \u{1F916} DevArchitect AI Architecture & PR Review
|
|
1278
1278
|
|
|
1279
1279
|
> **Automated Engineering Intelligence Report** for pull request changes.
|
|
@@ -1303,34 +1303,34 @@ ${Array.from(d).map(S=>`- [ ] Run \`${S}\` slice integration tests`).join(`
|
|
|
1303
1303
|
- [ ] Run \`devarchitect fix --dry-run\` to clean up any leftover debug logs
|
|
1304
1304
|
|
|
1305
1305
|
---
|
|
1306
|
-
*Generated automatically by [DevArchitect](https://github.com/Addy3131/devarchitect) \u2014 Understand your codebase. Engineer with confidence.*`;if(s.output&&(
|
|
1307
|
-
`))),process.env.GITHUB_STEP_SUMMARY)try{
|
|
1306
|
+
*Generated automatically by [DevArchitect](https://github.com/Addy3131/devarchitect) \u2014 Understand your codebase. Engineer with confidence.*`;if(s.output&&(pe.writeFileSync(s.output,v,"utf8"),console.log(H.default.green(` \u2714 Written PR review comment to: ${s.output}
|
|
1307
|
+
`))),process.env.GITHUB_STEP_SUMMARY)try{pe.appendFileSync(process.env.GITHUB_STEP_SUMMARY,`
|
|
1308
1308
|
`+v+`
|
|
1309
1309
|
`);}catch{}s.prePush&&(A.length>0&&(console.error(H.default.red(`
|
|
1310
1310
|
\u2716 [Pre-Push Guard Failed]: ${A.length} architectural policy violations detected in outgoing commits.`)),console.error(H.default.yellow(` Run 'devarchitect validate' to inspect or fix the violations before pushing.
|
|
1311
1311
|
`)),process.exit(1)),g&&(console.warn(H.default.yellow(`
|
|
1312
1312
|
\u26A0\uFE0F [Pre-Push Warning]: Critical blast radius detected (${h} downstream files).`)),console.warn(H.default.yellow(` Ensure all downstream integration tests pass.
|
|
1313
|
-
`))));}var
|
|
1314
|
-
\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501`))),console.log(
|
|
1315
|
-
\u2714 Successfully installed Git Safety Hooks:`)),console.log(` 1. Pre-Commit Guard: ${
|
|
1316
|
-
`),console.log(
|
|
1317
|
-
`)));}catch(e){let t=e instanceof Error?e.message:String(e);console.error(
|
|
1313
|
+
`))));}var $e=W(U());async function lo(){let s=process.cwd();console.log($e.default.bold($e.default.cyan(`
|
|
1314
|
+
\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501`))),console.log($e.default.bold($e.default.cyan(" DEVARCHITECT GIT QUALITY GATES & HOOKS INSTALLER"))),console.log($e.default.bold($e.default.cyan("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501")));try{let e=Qn(s),t=er(s);e.success&&t.success&&(console.log($e.default.green(`
|
|
1315
|
+
\u2714 Successfully installed Git Safety Hooks:`)),console.log(` 1. Pre-Commit Guard: ${$e.default.bold(e.hookPath)}`),console.log(` 2. Pre-Push Rovo-Gate: ${$e.default.bold(t.hookPath)}
|
|
1316
|
+
`),console.log($e.default.white(" What happens now:")),console.log($e.default.gray(" \u2022 When you commit: Blocks newly introduced circular imports or boundary debt.")),console.log($e.default.gray(` \u2022 When you push: Scans outgoing commits for critical blast radius regressions.
|
|
1317
|
+
`)));}catch(e){let t=e instanceof Error?e.message:String(e);console.error($e.default.red(`
|
|
1318
1318
|
\u2716 Failed to install Git hooks: ${t}
|
|
1319
1319
|
`));}}var te=W(U());async function uo(s={}){let e=process.cwd(),{nodes:t}=await I(e),n=t.map(o=>o.path);console.log(te.default.bold(te.default.cyan(`
|
|
1320
1320
|
\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501`))),console.log(te.default.bold(te.default.cyan(` DEVARCHITECT AUTOMATED SAFE CODE FIXER ${s.dryRun?"[DRY RUN PREVIEW]":""}`))),console.log(te.default.bold(te.default.cyan("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501")));let r=Pr(e,n,{dryRun:s.dryRun,fixConsoleLogs:s.consoleLogs!==false,fixEmptyCatches:s.emptyCatches!==false});if(console.log(` Actions Generated: ${r.actions.length>0?te.default.bold(String(r.actions.length)):te.default.green("0")}`),console.log(` Files Modified: ${r.modifiedFiles.length>0?te.default.bold(String(r.modifiedFiles.length)):te.default.green("0")}
|
|
1321
1321
|
`),r.actions.length===0){console.log(te.default.green(` \u2714 No auto-fixable code smells or leftover debug logs found.
|
|
1322
1322
|
`));return}console.log(te.default.bold(" Proposed Auto-Remediations:"));for(let o of r.actions.slice(0,15))console.log(` ${te.default.green("\u2714")} ${te.default.bold(o.filePath)} [${te.default.cyan(o.category)}]`),console.log(` ${te.default.gray(o.description)}`),console.log(` - ${te.default.red(o.originalSnippet)}`),console.log(` + ${te.default.green(o.fixedSnippet)}`);r.actions.length>15&&console.log(te.default.gray(` ... and ${r.actions.length-15} more actions`)),console.log(""),s.dryRun?console.log(te.default.yellow(` [DRY RUN] No files were changed on disk. Run without --dry-run to apply changes.
|
|
1323
1323
|
`)):console.log(te.default.green(` \u2714 Successfully applied ${r.actions.length} safe code fixes across ${r.modifiedFiles.length} files.
|
|
1324
|
-
`));}var
|
|
1325
|
-
\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501`))),console.log(
|
|
1326
|
-
\u2714 DevArchitect Studio running at: ${
|
|
1327
|
-
`)),!s.noOpen){let m=process.platform==="win32"?`start ${g}`:process.platform==="darwin"?`open ${g}`:`xdg-open ${g}`;exec(m);}}catch(g){let m=g instanceof Error?g.message:String(g);console.error(
|
|
1324
|
+
`));}var Re=W(U());async function po(s={}){let e=process.cwd(),{config:t}=ke(e),{discovery:n,nodes:r}=await I(e),{graph:o}=Z(e,r,n.typeScript),i=Je.evaluate({graph:o,nodes:r,edges:o.getAllEdges(),config:t}),l=ys({nodes:r,issues:i,graph:o,hasTests:!!n.detected.testingFramework,duplicateBlockCount:0}),c=xs(e,r),d=bs(e,r,o.getAllEdges()),u=ws(e,r);console.log(Re.default.bold(Re.default.cyan(`
|
|
1325
|
+
\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501`))),console.log(Re.default.bold(Re.default.cyan(" DEVARCHITECT STUDIO \u2014 LOCAL WEB DASHBOARD"))),console.log(Re.default.bold(Re.default.cyan("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501")));let h=s.port?parseInt(s.port,10):4321;try{let{url:g}=await ar({discovery:n,health:l,nodes:r,edges:o.getAllEdges(),issues:i,metrics:{rerendersCount:c.totalIssues,unusedTypesCount:d.unusedTypes.length,smellsCount:u.totalSmells}},{port:h,onAsk:m=>Cs(e,m,r,o.getAllEdges(),o)});if(console.log(Re.default.green(`
|
|
1326
|
+
\u2714 DevArchitect Studio running at: ${Re.default.bold(Re.default.underline(g))}`)),console.log(Re.default.gray(` Press Ctrl+C to stop the studio server.
|
|
1327
|
+
`)),!s.noOpen){let m=process.platform==="win32"?`start ${g}`:process.platform==="darwin"?`open ${g}`:`xdg-open ${g}`;exec(m);}}catch(g){let m=g instanceof Error?g.message:String(g);console.error(Re.default.red(`
|
|
1328
1328
|
\u2716 Failed to launch DevArchitect Studio: ${m}
|
|
1329
1329
|
`));}}var se=W(U());async function fo(s){let e=process.cwd();s||(console.error(se.default.red(`
|
|
1330
1330
|
\u2716 Error: Please specify a question about your codebase.`)),console.log(se.default.gray(' Example: devarchitect ask "How does authentication work?"')),console.log(se.default.gray(` Example: devarchitect ask "How does task creation flow?"
|
|
1331
1331
|
`)),process.exit(1));let{discovery:t,nodes:n}=await I(e),{graph:r}=Z(e,n,t.typeScript);console.log(se.default.bold(se.default.cyan(`
|
|
1332
1332
|
\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501`))),console.log(se.default.bold(se.default.cyan(" DEVARCHITECT AI CODEBASE INTELLIGENCE"))),console.log(se.default.bold(se.default.cyan("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"))),console.log(` Question: "${se.default.bold(s)}"
|
|
1333
|
-
`);let o=
|
|
1333
|
+
`);let o=Cs(e,s,n,r.getAllEdges(),r);if(console.log(se.default.bold(` Topic: ${se.default.cyan(o.topic)}`)),console.log(` ${se.default.gray(o.summary)}
|
|
1334
1334
|
`),o.flowSteps.length>0){console.log(se.default.bold(" Architectural Execution Flow:"));for(let i of o.flowSteps)console.log(` ${se.default.white(i)}`);console.log("");}if(o.relatedFiles.length>0){console.log(se.default.bold(" Referenced Source Files:"));for(let i of o.relatedFiles)console.log(` \u2022 ${se.default.green(i)}`);console.log("");}let a=o.confidence==="High"?se.default.green:se.default.yellow;console.log(` Confidence: ${a(o.confidence)} | Evidence: ${o.evidenceCount} indexed code references`),console.log(se.default.bold(se.default.cyan(`\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
|
|
1335
1335
|
`)));}var q=W(U());async function mo(){let s=process.cwd(),{nodes:e}=await I(s),t=jr(s,e);if(console.log(q.default.bold(q.default.cyan(`
|
|
1336
1336
|
\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501`))),console.log(q.default.bold(q.default.cyan(" DEVARCHITECT ENVIRONMENT VARIABLES & SECRET LEAK AUDIT"))),console.log(q.default.bold(q.default.cyan("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"))),console.log(` Variables Used: ${q.default.bold(String(t.usedVariables.length))}`),console.log(` Total Invocations: ${q.default.bold(String(t.totalOccurrences))}`),console.log(` Env Files Found: ${t.envFilesFound.length>0?t.envFilesFound.join(", "):"None"}
|
|
@@ -1353,4 +1353,4 @@ ${Array.from(d).map(S=>`- [ ] Run \`${S}\` slice integration tests`).join(`
|
|
|
1353
1353
|
`));return}console.log(K.default.bold(" Top Untested Architectural Gaps (Ranked by Blast Radius & Risk Score):")),console.log(K.default.gray(` These files have high complexity or multiple downstream consumers but 0 tests:
|
|
1354
1354
|
`));for(let o of r.criticalGaps){let a=o.priority==="CRITICAL"?K.default.bgRed(K.default.white(K.default.bold(" CRITICAL "))):K.default.yellow(K.default.bold(" HIGH "));console.log(` ${a} ${K.default.bold(o.name)} ${K.default.gray(`(${o.type}${o.feature?`, slice: ${o.feature}`:""})`)}`),console.log(` Path: ${K.default.white(o.filePath)}`),console.log(` Risk Score: ${K.default.bold(String(o.riskScore))} | Complexity: ${o.complexity} | Callers: ${o.dependentsCount} | LOC: ${o.linesOfCode}
|
|
1355
1355
|
`);}console.log(K.default.cyan(" \u{1F4A1} Recommendation:")),console.log(K.default.gray(` Add unit/integration test suites for the top critical modules above to protect against regressions.
|
|
1356
|
-
`));}function
|
|
1356
|
+
`));}function Sg(s=process.argv){let e=new Command;e.name("devarchitect").description("DevArchitect \u2014 Understand your codebase. Improve its architecture. Engineer with confidence.").version("0.1.0"),e.command("init").description("Initialize DevArchitect configuration for this repository").option("-p, --preset <preset>","Architecture preset (feature-sliced, clean-architecture, layered, modular-monolith, custom, recommended)").option("-f, --force","Overwrite existing configuration").action(async t=>{await tr(t);}),e.command("analyze").description("Analyze repository structure, framework, and metrics").option("--json","Output discovery results as JSON").option("-o, --output <file>","Save output to a file").option("--html","Generate standalone HTML architecture report").action(async t=>{await cr(t);}),e.command("inspect").description("Inspect components, hooks, services, and modules in the repository").option("-t, --type <type>","Filter by node type (component, hook, service, utility, route, test, module)").option("--feature <feature>","Filter by feature slice name").action(async t=>{await lr(t);}),e.command("doctor").description("Diagnose codebase configuration, TypeScript settings, and health diagnostics").action(async()=>{await dr();}),e.command("impact [target]").description("Calculate dependency blast radius and change impact for a file").option("--staged","Analyze all currently staged Git files").action(async(t,n)=>{await fr(t,n);}),e.command("validate").description("Validate repository against architecture policies").option("--update-baseline","Record current architecture violations in baseline to ratchet technical debt").action(async t=>{await br(t);}),e.command("graph").description("Visualize repository architecture dependency graph").option("-f, --format <format>","Graph format: mermaid, dot, json","mermaid").option("-o, --output <file>","Export graph to file").action(async t=>{await Sr(t);}),e.command("health").description("Calculate transparent 0-100 codebase health score").option("--json","Output health metrics as JSON").action(async t=>{await Ur(t);}),e.command("complexity").description("Identify high cyclomatic complexity functions and oversized files").action(async()=>{await Vr();}),e.command("deadcode").description("Detect unused exports and orphaned files across the repository").action(async()=>{await Gr();}),e.command("duplication").description("Detect repeated code blocks and duplicate logic clusters").option("-l, --lines <number>","Minimum duplicate line threshold","6").action(async t=>{await Zr(t);}),e.command("fingerprint").description("Generate reproducible cryptographic architecture fingerprint").action(async()=>{await qr();}),e.command("drift").description("Detect architectural divergence and drift from saved baseline fingerprint").action(async()=>{await Kr();}),e.command("generate <type> <name>").description("Scaffold architecture-compliant feature, component, or service matching existing conventions").action(async(t,n)=>{await eo(t,n);}),e.command("rules").description("List available architecture policies and presets").action(async()=>{await to();}),e.command("rerenders").description("Analyze React components for re-render bottlenecks, inline JSX allocations & hook anti-patterns").action(async()=>{await so();}),e.command("types").description("Analyze TypeScript health: unused types, any hotspots & duplicate definitions").action(async()=>{await no();}),e.command("smells").description("Detect code smells, unhandled async promises, god components & empty catch blocks").action(async()=>{await ro();}),e.command("simulate [target]").description("Simulate breaking change contract impact and map all call sites before modifying a file").action(async t=>{await io(t);}),e.command("pr").description("Analyze cumulative blast radius for branch changes and generate AI PR architectural review").option("-b, --base <branch>","Base branch to diff against","main").option("--staged","Analyze only currently staged files").option("--pre-push","Run outgoing commits check for git pre-push hook").option("--github-comment","Format review for GitHub / Bitbucket PR comment").option("-o, --output <file>","Save PR markdown review to file").action(async t=>{await co(t);}),e.command("install-hooks").description("Install Git pre-commit & pre-push quality gates (Rovo-style quality gates)").action(async()=>{await lo();}),e.command("fix").description("Automatically apply safe refactoring fixes for empty catches and leftover console logs").option("--dry-run","Preview changes without modifying files").action(async t=>{await uo(t);}),e.command("studio").description("Launch DevArchitect Studio local interactive web dashboard").option("-p, --port <port>","Port to run studio on","4321").option("--no-open","Do not automatically open the browser").action(async t=>{await po(t);}),e.command("ask <question>").description("Ask natural language questions about your repository architecture and data flow").action(async t=>{await fo(t);}),e.command("env").description("Audit environment variables for missing .env.example definitions and client secret leaks").action(async()=>{await mo();}),e.command("deps").description("Detect phantom dependencies (used in code but missing from package.json) and zombie packages").action(async()=>{await go();}),e.command("bloat").description("Detect heavy barrel import traps, server modules in client UI, and wildcard icon imports").action(async()=>{await ho();}),e.command("test-map").description("Analyze architectural test coverage gaps and rank untested files by blast radius risk").action(async()=>{await yo();}),e.parse(s);}export{ho as A,yo as B,Sg as C,tr as a,cr as b,lr as c,dr as d,fr as e,br as f,Sr as g,Ur as h,Vr as i,Gr as j,Zr as k,qr as l,Kr as m,eo as n,to as o,so as p,no as q,ro as r,io as s,co as t,lo as u,uo as v,po as w,fo as x,mo as y,go as z};
|