rapidkit 0.32.1 → 0.33.0
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 +48 -3
- package/contracts/backend-import-stack-parity.snapshot.json +37 -0
- package/contracts/infra-stack.v1.json +162 -0
- package/contracts/module-layout.v1.json +25 -0
- package/contracts/runtime-command-surface.v1.json +152 -0
- package/data/modules-embeddings.json +16907 -80088
- package/dist/{analyze-ZQHLV2YK.js → analyze-Q2XAYVUQ.js} +1 -1
- package/dist/{autopilot-release-WYDX67HR.js → autopilot-release-2NKDXXFZ.js} +1 -1
- package/dist/chunk-4E6ZGX6V.js +1 -0
- package/dist/{chunk-LSFRHYMD.js → chunk-CXKXZUV6.js} +2 -2
- package/dist/{create-6AMYKNEG.js → chunk-MSW2I3F3.js} +9 -9
- package/dist/chunk-W62Q2D3K.js +33 -0
- package/dist/chunk-Y3UKTEZO.js +2 -0
- package/dist/create-M7LT6WF6.js +1 -0
- package/dist/doctor-T6F2I6VO.js +50 -0
- package/dist/{dotnet-webapi-clean-W7SD3U3W.js → dotnet-webapi-clean-TPQMNFSD.js} +111 -43
- package/dist/index.d.ts +1 -1
- package/dist/index.js +207 -175
- package/dist/module-layout-J56LHEGH.js +1 -0
- package/dist/{pythonRapidkitExec-4MP62M5R.js → pythonRapidkitExec-JXOKKTXZ.js} +1 -1
- package/dist/{workspace-EHYCBFXL.js → workspace-4VGM2NPS.js} +1 -1
- package/dist/workspace-contract-Z5VYUF3T.js +1 -0
- package/dist/workspace-foundation-4EYME5VM.js +1 -0
- package/dist/workspace-run-OYKW5CI7.js +1 -0
- package/package.json +8 -7
- package/dist/chunk-BFCIY2QK.js +0 -33
- package/dist/doctor-SGPUU7UT.js +0 -50
- package/dist/workspace-contract-4UCEM44I.js +0 -2
- package/dist/workspace-run-OIPQYI6V.js +0 -1
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import {i as i$1}from'./chunk-QCZGNOTH.js';import {e}from'./chunk-KXTXQODI.js';import {c as c$1,a as a$2,b as b$1}from'./chunk-NFUXULIF.js';import {b,f,d,a as a$4,k,g,i as i$2}from'./chunk-Z5LKRG57.js';import {a}from'./chunk-VM2TOHNX.js';import {a as a$3}from'./chunk-2FIX2MDC.js';import c from'chalk';import {execa}from'execa';import a$1 from'fs-extra';import i from'path';import et from'inquirer';function tt(e){return [...new Set(e.filter(s=>s&&s.trim().length>0))]}function st(){let e=k().map(t=>i.join(t,a$4()?"poetry.exe":"poetry")),s=a$4()?[i.join(process.env.APPDATA||"","Python","Scripts","poetry.exe"),i.join(process.env.USERPROFILE||"","AppData","Roaming","Python","Scripts","poetry.exe")]:[],r=a$4()?[]:["/usr/local/bin/poetry","/usr/bin/poetry"];return tt([...e,...s,...r])}function nt(e){let s=k().map(u=>({location:"Global (user-local)",path:i.join(u,a$4()?"rapidkit.exe":"rapidkit")})),r=[{location:"Global (pipx)",path:i.join(e,".local","bin","rapidkit")},{location:"Global (pipx)",path:i.join(e,"AppData","Roaming","Python","Scripts","rapidkit.exe")},{location:"Global (pyenv)",path:i.join(e,".pyenv","shims","rapidkit")},{location:"Global (system)",path:"/usr/local/bin/rapidkit"},{location:"Global (system)",path:"/usr/bin/rapidkit"}],t=g(i.join(process.cwd(),".venv")),l=i$2(process.cwd()),o=[{location:"Workspace (.venv)",path:t},...l.map(u=>({location:"Workspace (launcher)",path:u}))],n=[...s,...r,...o],d=new Set;return n.filter(u=>d.has(u.path)?false:(d.add(u.path),true))}function ot(e){let s=new Map([["Workspace (.venv)",0],["Global (user-local)",1],["Global (pipx)",2],["Global (pyenv)",3],["Global (system)",4]]);return [...e].sort((r,t)=>{let l=s.get(r.location)??Number.MAX_SAFE_INTEGER,o=s.get(t.location)??Number.MAX_SAFE_INTEGER;return l!==o?l-o:r.path.localeCompare(t.path)})}function Y(e){let s=0,r=e.issues.some(t=>t.toLowerCase().includes("environment file missing"));return e.hasEnvFile===false&&!r&&(s+=1),typeof e.vulnerabilities=="number"&&e.vulnerabilities>0&&(s+=1),s}function he(e){return e.filter(s=>Y(s)>0).length}function we(e){return e.reduce((s,r)=>s+Y(r),0)}var it="doctor-project-scan-v2",Ne="doctor-workspace-cache-v1",at=Object.freeze({version:"doctor-evidence-v1",scoringPolicyVersion:"doctor-score-policy-v1",generatedBy:"rapidkit-npm",deterministicScoreBreakdown:true,scopeModel:"workspace-aggregate-or-project-scoped"});function de(){return {...at}}function ue(e){return !e||e.total<=0?null:Math.round(e.passed/e.total*100)}function Me(e){return typeof e=="number"?e:Array.isArray(e)?e.length:0}async function Ge(e,s){try{if(!await a$1.pathExists(e))return null;let r=await a$1.readJSON(e);return c$1(r,s)?r:null}catch{return null}}function We(e,s){if(!e?.system)return [];let r=[{id:"python",current:s.python},{id:"poetry",current:s.poetry},{id:"pipx",current:s.pipx},{id:"go",current:s.go},{id:"rapidkitCore",current:s.rapidkitCore}],t=[];for(let l of r){let o=e.system?.[l.id]?.status;!o||o===l.current.status||t.push({id:l.id,from:o,to:l.current.status});}return t}function rt(e,s){let r=new Map;for(let p of s.projects)r.set(p.path||p.name,p.issues.length);if(!e)return {baselineAvailable:false,newIssueCount:0,resolvedIssueCount:0,netIssueDelta:0,scoreDeltaPercent:null,systemStatusChanges:[],regressedProjects:[],improvedProjects:[]};let t=Array.isArray(e.projects)?e.projects:[],l=new Map;for(let p of t){let h=p.path||p.name;h&&l.set(h,Me(p.issues));}let o=0,n=0,d=new Set,u=new Set,m=new Set([...Array.from(l.keys()),...Array.from(r.keys())]);for(let p of m){let h=l.get(p)??0,v=r.get(p)??0;v>h?(o+=v-h,d.add(p)):v<h&&(n+=h-v,u.add(p));}let f=ue(e.healthScore),g=ue(s.healthScore);return {baselineAvailable:true,previousGeneratedAt:e.generatedAt,newIssueCount:o,resolvedIssueCount:n,netIssueDelta:o-n,scoreDeltaPercent:f===null||g===null?null:g-f,systemStatusChanges:We(e,{python:s.python,poetry:s.poetry,pipx:s.pipx,go:s.go,rapidkitCore:s.rapidkitCore}),regressedProjects:Array.from(d).sort(),improvedProjects:Array.from(u).sort()}}function ct(e,s){if(!e)return {baselineAvailable:false,newIssueCount:0,resolvedIssueCount:0,netIssueDelta:0,scoreDeltaPercent:null,systemStatusChanges:[],regressedProjects:[],improvedProjects:[]};let r=Me(e.project?.issues),t=s.project.issues.length,l=Math.max(t-r,0),o=Math.max(r-t,0),n=ue(e.healthScore),d=ue(s.healthScore),u=s.project.path||s.project.name;return {baselineAvailable:true,previousGeneratedAt:e.generatedAt,newIssueCount:l,resolvedIssueCount:o,netIssueDelta:l-o,scoreDeltaPercent:n===null||d===null?null:d-n,systemStatusChanges:We(e,{python:s.python,poetry:s.poetry,pipx:s.pipx,go:s.go,rapidkitCore:s.rapidkitCore}),regressedProjects:l>0?[u]:[],improvedProjects:o>0?[u]:[]}}function Be(e){let s=e??[],r=0,t=0;for(let n of s){if(n.scope==="project-scoped"){r+=1;continue}(n.scope==="workspace-aggregate"||n.scope==="host-system")&&(t+=1);}let l=r>0&&t>0?1:0,o=l>0?"mixed":r>0?"scoped":t>0?"aggregated":"unknown";return {scopedCount:r,aggregatedCount:t,mixedCount:l,dominantScope:o}}function P(e,s){return a$4()?`cd "${e}"; ${s}`:`cd ${e} && ${s}`}function L(e){return a$4()?P(e,"Copy-Item .env.example .env"):P(e,"cp .env.example .env")}function lt(e){return e==="FastAPI"||e==="NestJS"||e==="Go/Fiber"||e==="Go/Gin"||e==="Spring Boot"||e==="Rust"||e==="Phoenix"?"first-class":e==="Django"||e==="Flask"||e==="Express"||e==="Fastify"||e==="Koa"||e==="Elixir"||e==="Clojure"||e==="Scala"||e==="Kotlin"||e==="Deno"||e==="Bun"||e==="PHP"||e==="Laravel"||e==="Ruby"||e==="Ruby on Rails"||e==="ASP.NET"?"extended":"observed"}function dt(e){return e==="Next.js"||e==="Nuxt"||e==="React"||e==="Vue"||e==="Angular"||e==="SvelteKit"?"frontend":e==="Unknown"||e==="Node.js"||e==="Python"?"generic":"backend"}function ut(e){return e==="NestJS"||e==="Next.js"||e==="Nuxt"||e==="React"||e==="Vue"||e==="Angular"||e==="SvelteKit"||e==="Bun"||e==="Express"||e==="Fastify"||e==="Koa"||e==="Node.js"?"node":e==="FastAPI"||e==="Django"||e==="Flask"||e==="Python"?"python":e==="Go/Fiber"||e==="Go/Gin"?"go":e==="Spring Boot"?"java":e==="Rust"?"rust":e==="Elixir"||e==="Phoenix"?"elixir":e==="Clojure"?"clojure":e==="Deno"?"deno":e==="Laravel"||e==="PHP"?"php":e==="Ruby on Rails"||e==="Ruby"?"ruby":e==="ASP.NET"?"dotnet":"unknown"}function le(e,s,r){e.framework=s,e.frameworkConfidence=r,e.supportTier=lt(s),e.projectKind=dt(s),e.runtimeFamily=ut(s);}function pt(e){return e==="python"?"python":e==="node"||e==="bun"?"node":e==="go"?"go":e==="java"?"java":e==="rust"?"rust":e==="elixir"?"elixir":e==="clojure"?"clojure":e==="deno"?"deno":e==="php"?"php":e==="ruby"?"ruby":e==="dotnet"?"dotnet":"unknown"}function Ke(e){switch(e.key){case "fastapi":return "FastAPI";case "django":return "Django";case "flask":return "Flask";case "python":return "Python";case "nestjs":return "NestJS";case "express":return "Express";case "fastify":return "Fastify";case "koa":return "Koa";case "node":return "Node.js";case "gofiber":return "Go/Fiber";case "gogin":return "Go/Gin";case "echo":return "Echo";case "go":return "Go";case "springboot":return "Spring Boot";case "java":return "Java";case "laravel":return "Laravel";case "php":return "PHP";case "rails":return "Ruby on Rails";case "ruby":return "Ruby";case "dotnet":return "ASP.NET";case "phoenix":return "Phoenix";case "elixir":return "Elixir";case "clojure":return "Clojure";case "scala":return "Scala";case "kotlin":return "Kotlin";case "deno":return "Deno";case "bun":return "Bun";case "actix":case "axum":case "rocket":case "rust":return "Rust";case "sinatra":case "symfony":case "unknown":return "Unknown";default:return "Unknown"}}function mt(e){return e.key==="python"||e.key==="node"||e.key==="go"||e.key==="java"||e.key==="php"||e.key==="ruby"||e.key==="dotnet"||e.key==="rust"||e.key==="elixir"||e.key==="clojure"||e.key==="scala"||e.key==="kotlin"||e.key==="deno"||e.key==="bun"||e.key==="unknown"}function _(e,s){e.framework=Ke(s),e.frameworkKey=s.key,e.importStack=s.importStack,e.frameworkConfidence=s.confidence,e.supportTier=s.supportTier,e.projectKind=mt(s)?"generic":"backend",e.runtimeFamily=pt(s.runtime);}function ft(e){let s=e.dependencies,r=e.scripts??{},t=(e.kitName??"").toLowerCase(),l=n=>!!s[n],o=Object.values(r).filter(n=>typeof n=="string").join(" ").toLowerCase();return l("next")||o.includes("next ")?{framework:"Next.js",confidence:"high"}:l("nuxt")||o.includes("nuxt ")?{framework:"Nuxt",confidence:"high"}:l("@nestjs/core")||t.startsWith("nestjs.")?{framework:"NestJS",confidence:"high"}:l("express")?{framework:"Express",confidence:"high"}:l("fastify")?{framework:"Fastify",confidence:"high"}:l("koa")?{framework:"Koa",confidence:"high"}:l("@angular/core")?{framework:"Angular",confidence:"high"}:l("@sveltejs/kit")||o.includes("svelte-kit")?{framework:"SvelteKit",confidence:"high"}:l("vue")?{framework:"Vue",confidence:"medium"}:l("react")&&l("react-dom")?{framework:"React",confidence:"medium"}:{framework:"Node.js",confidence:"low"}}async function gt(e$1){let s=e(e$1);return s.runtime!=="python"?{framework:"Python",confidence:"low"}:{framework:Ke(s),confidence:s.confidence}}async function Re(e){try{let s=await a$1.stat(e);return `${i.basename(e)}:${s.isDirectory()?"d":"f"}:${s.size}:${s.mtimeMs}`}catch{return `${i.basename(e)}:missing`}}async function ht(e){try{let s=new Set([".git",".venv","node_modules",".rapidkit","dist","build","coverage","__pycache__"]),r=new Set;await pe(e)&&r.add(e);let t=async(l,o)=>{if(o<0)return;let n=await _e(l);for(let d of n){if(Te(d,s))continue;let u=i.join(l,d);if(await pe(u)){r.add(u);continue}o>0&&await t(u,o-1);}};return await t(e,1),r.size===0&&(await $t(e,3,s)).forEach(o=>r.add(o)),Array.from(r).sort((l,o)=>l.localeCompare(o))}catch{return []}}async function yt(e,s){let r=[i.join(e,".rapidkit-workspace"),i.join(e,".rapidkit","workspace.json"),i.join(e,".rapidkit","policies.yml"),i.join(e,".rapidkit","toolchain.lock"),i.join(e,".rapidkit","cache-config.yml")],t=[".rapidkit/project.json",".rapidkit/context.json",".rapidkit/file-hashes.json","package.json","pyproject.toml","composer.json","Gemfile","Gemfile.lock","go.mod","go.sum","pom.xml","requirements.txt","Dockerfile","Makefile",".env",".env.example","src","modules","tests","test",".venv","node_modules"],l=await Promise.all(r.map(Re)),o=await Promise.all(s.map(async n=>{let d=await Promise.all(t.map(u=>Re(i.join(n,u))));return `${n}::${d.join("|")}`}));return [it,...l,...o].join("||")}async function kt(e,s){try{if(!await a$1.pathExists(e))return null;let r=await a$1.readJSON(e);return !r||r.signature!==s||!Array.isArray(r.projects)||typeof r.schemaVersion=="string"&&r.schemaVersion!==Ne?null:r}catch{return null}}async function wt(e,s){try{await a$1.ensureDir(i.dirname(e)),await a$1.writeJSON(e,s,{spaces:2});}catch{}}async function vt(e,s,r){let t=i.join(e,".rapidkit","reports","doctor-last-run.json");try{return await a$1.ensureDir(i.dirname(t)),await a$1.writeJSON(t,{schemaVersion:a$2,evidenceType:"workspace",generatedAt:new Date().toISOString(),contract:de(),workspacePath:e,workspaceName:s.workspaceName,projectScanCached:s.projectScanCached??false,projectScanSignature:s.projectScanSignature,cachePath:r,healthScore:s.healthScore,system:{python:s.python,poetry:s.poetry,pipx:s.pipx,go:s.go,rapidkitCore:s.rapidkitCore,versions:{core:s.coreVersion,npm:s.npmVersion}},projects:s.projects,summary:{totalProjects:s.projects.length,totalIssues:s.projects.reduce((l,o)=>l+o.issues.length,0),projectAdvisoryWarningProjects:he(s.projects),projectAdvisoryWarnings:we(s.projects),hasSystemErrors:[s.python,s.rapidkitCore].some(l=>l.status==="error"),scopeProvenance:s.scopeProvenance},driftDelta:s.driftDelta,scoreBreakdown:s.scoreBreakdown??[]},{spaces:2}),t}catch{return}}async function ve(){let[e,s,r,t,l]=await Promise.all([bt(),xt(),jt(),Ct(),Et()]);return {python:e,poetry:s,pipx:r,go:t,rapidkitCore:l}}async function bt(){let e=d();for(let s of e)try{let{stdout:r}=await execa(s,["--version"],{timeout:3e3}),t=r.match(/Python (\d+\.\d+\.\d+)/);if(t){let l=t[1],[o,n]=l.split(".").map(Number);return o<3||o===3&&n<10?{status:"warn",message:`Python ${l} (requires 3.10+)`,details:`${s} found but version is below minimum requirement`}:{status:"ok",message:`Python ${l}`,details:`Using ${s}`}}}catch{continue}return {status:"error",message:"Python not found",details:"Install Python 3.10+ and ensure it's in PATH"}}async function xt(){try{let{stdout:e}=await execa("poetry",["--version"],{timeout:3e3}),s=e.match(/Poetry .*version ([\d.]+)/);return s?{status:"ok",message:`Poetry ${s[1]}`,details:"Available for dependency management"}:{status:"warn",message:"Poetry version unknown"}}catch{let e=d().map(s=>({cmd:s,args:s==="py"?["-3","-m","poetry","--version"]:["-m","poetry","--version"]}));for(let s of e)try{let{stdout:r}=await execa(s.cmd,s.args,{timeout:3e3,shell:b()}),t=r.match(/Poetry .*version ([\d.]+)/)||r.match(/([\d.]+)/);return {status:"ok",message:t?.[1]?`Poetry ${t[1]}`:"Poetry detected",details:`Available via ${s.cmd} ${s.args.join(" ")}`}}catch{continue}for(let s of st())try{if(!await a$1.pathExists(s))continue;let{stdout:r}=await execa(s,["--version"],{timeout:3e3,shell:b()}),t=r.match(/Poetry .*version ([\d.]+)/)||r.match(/([\d.]+)/);return {status:"ok",message:t?.[1]?`Poetry ${t[1]}`:"Poetry detected",details:`Available at ${s}`}}catch{continue}return {status:"warn",message:"Poetry not installed",details:"Optional: Install for better dependency management"}}}async function jt(){try{let{stdout:e}=await execa("pipx",["--version"],{timeout:3e3});return {status:"ok",message:`pipx ${e.trim()}`,details:"Available for global tool installation"}}catch{let e=d();for(let s of e)try{let r=s==="py"?["-3","-m","pipx","--version"]:["-m","pipx","--version"],{stdout:t}=await execa(s,r,{timeout:3e3,shell:b()});return {status:"ok",message:`pipx ${t.trim()}`,details:`Available via ${s} ${r.join(" ")}`}}catch{continue}return {status:"warn",message:"pipx not installed",details:"Optional: Install for isolated Python tools"}}}async function Ct(){try{let{stdout:e}=await execa("go",["version"],{timeout:3e3}),s=e.match(/go version go(\d+\.\d+(?:\.\d+)?)/);return s?{status:"ok",message:`Go ${s[1]}`,details:"Available for Go/Fiber and Go/Gin projects"}:{status:"ok",message:"Go (version unknown)",details:"go found in PATH"}}catch{return {status:"warn",message:"Go not installed",details:"Optional: Required only for gofiber.standard / gogin.standard projects \u2014 https://go.dev/dl/"}}}async function Et(){let e=process.env.HOME||process.env.USERPROFILE||"",s=[],r=nt(e);for(let{location:l,path:o}of r)try{if(await a$1.pathExists(o)){let{stdout:n,exitCode:d}=await execa(o,["--version"],{timeout:3e3,reject:false});if(d===0&&(n.includes("RapidKit Version")||n.includes("RapidKit"))){let u=n.match(/v?([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);u&&s.push({location:l,path:o,version:u[1]});}}}catch{continue}if(s.length>0){let l=s.filter(n=>n.location!=="Workspace (launcher)");if(l.length>0){let n=ot(l),d=n[0].version,u=n.some(g=>g.location==="Workspace (.venv)"),m=n.some(g=>g.location.startsWith("Global (")),f=!u&&m?"Workspace (.venv): not installed (optional). For best project-level performance and isolation, run npx rapidkit workspace run init inside this workspace.":void 0;return {status:"ok",message:`RapidKit Core ${d}`,details:f,paths:n.map(g=>({location:g.location,path:g.path,version:g.version}))}}return {status:"ok",message:`RapidKit Core ${s[0].version}`,details:"Detected via workspace launcher"}}try{let{stdout:l,exitCode:o}=await execa("rapidkit",["--version"],{timeout:3e3,reject:false});if(o===0&&(l.includes("RapidKit Version")||l.includes("RapidKit"))){let n=l.match(/v?([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);if(n)return {status:"ok",message:`RapidKit Core ${n[1]}`,details:"Available via PATH"}}}catch{}try{let{stdout:l,exitCode:o}=await execa("poetry",["run","rapidkit","--version"],{timeout:3e3,reject:false});if(o===0&&(l.includes("RapidKit Version")||l.includes("RapidKit"))){let n=l.match(/v?([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);if(n)return {status:"ok",message:`RapidKit Core ${n[1]}`,details:"Available via Poetry"}}}catch{}let t=d();for(let l of t)try{let{stdout:o,exitCode:n}=await execa(l,["-c","import rapidkit_core; print(rapidkit_core.__version__)"],{timeout:3e3,reject:false});if(n===0&&o&&!o.includes("Traceback")&&!o.includes("ModuleNotFoundError")){let d=o.trim();if(d)return {status:"ok",message:`RapidKit Core ${d}`,details:`Available in ${l} environment`}}}catch{continue}return {status:"error",message:"RapidKit Core not installed",details:"Install with: pipx install rapidkit-core"}}async function A(e,s){let r=i.join(e,"Dockerfile");s.hasDocker=await a$1.pathExists(r);let t=i.join(e,"tests"),l=i.join(e,"test"),o=i.join(e,"src","test"),n=await a$1.pathExists(t)||await a$1.pathExists(l)||await a$1.pathExists(o),d=false;if(s.framework==="Go/Fiber"||s.framework==="Go/Gin")try{let u=[{dir:e,depth:0}],m=4,f=new Set([".git",".venv","node_modules","dist","build","vendor"]);for(;u.length>0&&!d;){let g=u.shift();if(!g)break;let p=[];try{p=await a$1.readdir(g.dir);}catch{continue}for(let h of p){let v=i.join(g.dir,h),y;try{y=await a$1.stat(v);}catch{continue}if(y.isFile()&&h.endsWith("_test.go")){d=true;break}y.isDirectory()&&g.depth<m&&!f.has(h)&&!h.startsWith(".")&&u.push({dir:v,depth:g.depth+1});}}}catch{}if(s.hasTests=n||d,s.runtimeFamily==="node"){let u=i.join(e,".eslintrc.js"),m=i.join(e,".eslintrc.json");s.hasCodeQuality=await a$1.pathExists(u)||await a$1.pathExists(m);}else if(s.framework==="Go/Fiber"||s.framework==="Go/Gin"){let u=i.join(e,".golangci.yml"),m=i.join(e,".golangci.yaml"),f=i.join(e,"Makefile"),g=await a$1.pathExists(f)&&(await a$1.readFile(f,"utf8")).includes("golangci-lint");s.hasCodeQuality=await a$1.pathExists(u)||await a$1.pathExists(m)||g;}else if(s.runtimeFamily==="python"){let u=i.join(e,"ruff.toml"),m=i.join(e,"pyproject.toml");if(await a$1.pathExists(m))try{let f=await a$1.readFile(m,"utf8");s.hasCodeQuality=f.includes("[tool.ruff]")||await a$1.pathExists(u);}catch{s.hasCodeQuality=await a$1.pathExists(u);}}else if(s.framework==="Spring Boot"){let u=i.join(e,"pom.xml");if(await a$1.pathExists(u))try{let m=await a$1.readFile(u,"utf8");s.hasCodeQuality=m.includes("spotless")||m.includes("checkstyle")||m.includes("pmd")||m.includes("maven-enforcer-plugin");}catch{s.hasCodeQuality=false;}}try{if(s.runtimeFamily==="node"){let{stdout:u}=await execa("npm",["audit","--json"],{cwd:e,reject:false});if(u)try{let f=JSON.parse(u).metadata?.vulnerabilities;f&&(s.vulnerabilities=(f.high||0)+(f.critical||0)+(f.moderate||0));}catch{}}else if(s.runtimeFamily==="python"){let u=i.join(e,".venv"),m=f(u);if(await a$1.pathExists(m))try{let{stdout:f}=await execa(m,["-m","pip","list","--format=json"],{timeout:5e3,reject:false});if(f){JSON.parse(f);s.vulnerabilities=0;}}catch{}}}catch{}}function N(e,s){e.probes||(e.probes=[]),e.probes.push(s);}async function Pt(e,s){let r=s.runtimeFamily||"unknown";if(s.projectKind==="backend"||s.projectKind==="generic"){if(r==="node"){let l=await a$1.pathExists(i.join(e,"package-lock.json"))||await a$1.pathExists(i.join(e,"pnpm-lock.yaml"))||await a$1.pathExists(i.join(e,"yarn.lock"));N(s,{id:"adapter-node-lockfile-integrity",label:"Node adapter lockfile integrity",status:l?"pass":"warn",severity:"warn",scope:"project-scoped",reason:l?"Node lockfile detected for deterministic dependency restore.":"No Node lockfile detected (package-lock/yarn.lock/pnpm-lock.yaml).",recommendation:l?void 0:"Commit a lockfile for deterministic installs and CI parity."});let o=await a$1.pathExists(i.join(e,"src/main.ts"))||await a$1.pathExists(i.join(e,"src/main.js"))||await a$1.pathExists(i.join(e,"src/server.ts"))||await a$1.pathExists(i.join(e,"src/server.js"));N(s,{id:"adapter-node-boot-entrypoint",label:"Node adapter boot entrypoint",status:o?"pass":"warn",severity:"warn",scope:"project-scoped",reason:o?"Boot entrypoint markers detected for service startup path.":"No canonical Node boot entrypoint markers detected.",recommendation:o?void 0:"Define and document service bootstrap entrypoint (main/server)."});return}if(r==="python"){let l=await a$1.pathExists(i.join(e,"poetry.lock"))||await a$1.pathExists(i.join(e,"requirements.txt"))||await a$1.pathExists(i.join(e,"uv.lock"));N(s,{id:"adapter-python-lockfile-integrity",label:"Python adapter dependency integrity",status:l?"pass":"warn",severity:"warn",scope:"project-scoped",reason:l?"Python dependency contract file detected.":"No Python dependency contract file detected (poetry.lock/requirements/uv.lock).",recommendation:l?void 0:"Pin dependency contract for deterministic setup and reproducible CI."});let o=await a$1.pathExists(i.join(e,"app/main.py"))||await a$1.pathExists(i.join(e,"main.py"))||await a$1.pathExists(i.join(e,"manage.py"));N(s,{id:"adapter-python-boot-entrypoint",label:"Python adapter boot entrypoint",status:o?"pass":"warn",severity:"warn",scope:"project-scoped",reason:o?"Python application entrypoint markers detected.":"No Python application entrypoint markers detected.",recommendation:o?void 0:"Expose explicit app/main entrypoint for deterministic boot probes."});return}if(r==="java"){let l=await a$1.pathExists(i.join(e,"mvnw"))||await a$1.pathExists(i.join(e,"gradlew"));N(s,{id:"adapter-java-build-wrapper",label:"Java adapter build wrapper",status:l?"pass":"warn",severity:"warn",scope:"project-scoped",reason:l?"Build wrapper detected (mvnw/gradlew).":"No Java build wrapper detected.",recommendation:l?void 0:"Commit mvnw or gradlew for reproducible enterprise pipelines."});return}if(r==="go"){let l=await a$1.pathExists(i.join(e,"go.sum"));N(s,{id:"adapter-go-module-integrity",label:"Go adapter module integrity",status:l?"pass":"warn",severity:"warn",scope:"project-scoped",reason:l?"go.sum detected for deterministic module verification.":"go.sum missing; module integrity baseline is incomplete.",recommendation:l?void 0:"Generate and commit go.sum in the repository baseline."});}}}async function St(e,s){let r=[i.join(e,".rapidkit","doctor.adapters.json"),i.join(e,"doctor.adapters.json")];for(let t of r)if(await a$1.pathExists(t))try{let l=await a$1.readJSON(t),o=Array.isArray(l?.checks)?l.checks:[];for(let n=0;n<o.length;n+=1){let d=o[n]||{},u=Array.isArray(d.runtimes)?d.runtimes:[];if(u.length>0&&!u.includes(s.runtimeFamily||"unknown"))continue;let m=typeof d.id=="string"&&d.id.trim().length>0?d.id.trim():`adapter-check-${n+1}`,f=typeof d.label=="string"&&d.label.trim().length>0?d.label.trim():m,g=d.severity||"warn",p=Array.isArray(d.anyOfPaths)?d.anyOfPaths.filter(Boolean):[],h=Array.isArray(d.allOfPaths)?d.allOfPaths.filter(Boolean):[],v=p.length===0;for(let T of p)if(await a$1.pathExists(i.join(e,T))){v=true;break}let y=true;for(let T of h)if(!await a$1.pathExists(i.join(e,T))){y=false;break}let b=v&&y;N(s,{id:m,label:f,status:b?"pass":g==="error"?"fail":"warn",severity:g,scope:"project-scoped",reason:b?d.passReason||"Custom adapter contract satisfied.":d.failReason||`Custom adapter check failed from ${i.basename(t)}.`,recommendation:d.recommendation});}}catch{N(s,{id:"custom-adapter-config",label:"Custom doctor adapter configuration",status:"warn",severity:"warn",scope:"project-scoped",reason:`Failed to parse ${i.basename(t)}.`,recommendation:"Fix JSON syntax in doctor.adapters.json to re-enable adapter checks."});}}async function I(e,s){if(!(s.projectKind==="backend"||s.projectKind==="generic"))return;let t=i.join(e,".env"),l=i.join(e,".env.example"),o=await a$1.pathExists(t)||await a$1.pathExists(l)||await a$1.pathExists(i.join(e,"config"));N(s,{id:"config-surface",label:"Configuration contract surface",status:o?"pass":"warn",severity:"warn",scope:"project-scoped",reason:o?"Configuration artifacts detected (.env/.env.example/config).":"No explicit configuration contract artifacts detected.",recommendation:o?void 0:"Add .env.example or explicit config contract documentation for deterministic setup."});let n={python:["alembic.ini","migrations","versions"],node:["prisma/schema.prisma","migrations","typeorm.config.ts","typeorm.config.js"],go:["migrations","db/migrations"],java:["src/main/resources/db/migration","src/main/resources/liquibase"],rust:["migrations","sqlx-data.json"],elixir:["priv/repo/migrations"],clojure:["resources/migrations","migrations"],deno:["migrations"],php:["database/migrations","migrations"],ruby:["db/migrate"],dotnet:["Migrations","Data/Migrations"],unknown:["migrations"]},d=s.runtimeFamily||"unknown",u=n[d]||n.unknown,m=false;for(let p of u)if(await a$1.pathExists(i.join(e,p))){m=true;break}N(s,{id:"migration-surface",label:"Migration/readiness surface",status:m?"pass":"warn",severity:"warn",scope:"project-scoped",reason:m?"Migration or schema evolution markers detected.":"No migration markers detected for this backend runtime.",recommendation:m?void 0:"Add migration tooling baseline (migrations dir or runtime-native migration config)."});let f=["src/health","src/healthcheck","src/main/resources/application.yml","src/main/resources/application.properties","app/health.py","routes/health.ts","routes/health.js"],g=false;for(let p of f)if(await a$1.pathExists(i.join(e,p))){g=true;break}N(s,{id:"runtime-health-surface",label:"Runtime health probe surface",status:g?"pass":"warn",severity:"warn",scope:"project-scoped",reason:g?"Health endpoint/config markers detected.":"No explicit runtime health endpoint markers detected.",recommendation:g?void 0:"Expose a deterministic health endpoint and keep it covered in verify pack."}),await Pt(e,s);}async function H(e,s){let r=[i.join(e,".rapidkit","doctor.probes.json"),i.join(e,"doctor.probes.json")];for(let t of r)if(await a$1.pathExists(t))try{let l=await a$1.readJSON(t),o=Array.isArray(l?.probes)?l.probes:[];for(let n=0;n<o.length;n+=1){let d=o[n]||{},u=typeof d.id=="string"&&d.id.trim().length>0?d.id.trim():`custom-probe-${n+1}`,m=typeof d.label=="string"&&d.label.trim().length>0?d.label.trim():u,f=d.severity||"warn",g=Array.isArray(d.anyOfPaths)?d.anyOfPaths.filter(Boolean):[],p=Array.isArray(d.allOfPaths)?d.allOfPaths.filter(Boolean):[],h=g.length===0;for(let b of g)if(await a$1.pathExists(i.join(e,b))){h=true;break}let v=true;for(let b of p)if(!await a$1.pathExists(i.join(e,b))){v=false;break}let y=h&&v;N(s,{id:u,label:m,status:y?"pass":f==="error"?"fail":"warn",severity:f,scope:"project-scoped",reason:y?"Custom probe contract satisfied.":`Custom probe failed from ${i.basename(t)}.`,recommendation:d.recommendation});}}catch{N(s,{id:"custom-probe-config",label:"Custom doctor probe configuration",status:"warn",severity:"warn",scope:"project-scoped",reason:`Failed to parse ${i.basename(t)}.`,recommendation:"Fix JSON syntax in doctor.probes.json to re-enable custom probes."});}await St(e,s);}async function be(e$1,s={}){let t={name:i.basename(e$1),path:e$1,venvActive:false,depsInstalled:false,coreInstalled:false,issues:[],fixCommands:[]},l=s.allowNonRapidkit===true,o=i.join(e$1,".rapidkit");if(!await a$1.pathExists(o)){if(!l)return t.issues.push("Not a valid RapidKit project (missing .rapidkit directory)"),t;t.issues.push("Not a RapidKit-managed project (running generic backend diagnostics)");}try{let k=i.join(e$1,"registry.json");if(await a$1.pathExists(k)){let w=await a$1.readJson(k);w.installed_modules&&(t.stats={modules:w.installed_modules.length});}}catch{}try{let{auditProjectModulePaths:k}=await import('./module-layout-J56LHEGH.js'),w=await k(e$1);if(w.issues.length>0){for(let j of w.issues)t.issues.push(`${j.message} (${j.slug})`);t.fixCommands=t.fixCommands??[],t.fixCommands.push("npx rapidkit workspace contract verify --strict --json"),t.fixCommands.push("npx rapidkit add module <slug> # reinstall via Core-backed module install");}}catch{}let n=null;try{let k=i.join(o,"project.json");if(await a$1.pathExists(k)){n=await a$1.readJson(k);let w=n?.kit_name||n?.kit;w&&(t.kit=w);}}catch{}try{let k=i.join(e$1,".git");if(await a$1.pathExists(k)){let{stdout:w}=await execa("git",["log","-1","--format=%cr"],{cwd:e$1,reject:false});w&&(t.lastModified=w.trim());}else {let w=await a$1.stat(e$1),S=Date.now()-w.mtime.getTime(),M=Math.floor(S/(1e3*60*60*24));t.lastModified=M===0?"today":`${M} day${M>1?"s":""} ago`;}}catch{}let d=i.join(e$1,"package.json"),u=i.join(e$1,"pyproject.toml"),m=i.join(e$1,"requirements.txt"),f$1=i.join(e$1,"go.mod"),g=i.join(e$1,"pom.xml"),p=i.join(e$1,"build.sbt"),h=i.join(e$1,"Cargo.toml"),v=i.join(e$1,"mix.exs"),y=i.join(e$1,"deps.edn"),b=i.join(e$1,"project.clj"),T=i.join(e$1,"deno.json"),W=i.join(e$1,"deno.jsonc"),J=i.join(e$1,"bun.lockb"),q=i.join(e$1,"bun.lock"),O=i.join(e$1,"composer.json"),se=i.join(e$1,"Gemfile"),U=await a$1.pathExists(d),B=await a$1.pathExists(u)||await a$1.pathExists(m),R=await a$1.pathExists(O),ee=await a$1.pathExists(se),ne=await a$1.pathExists(h),Ue=await a$1.pathExists(v),ze=await a$1.pathExists(y)||await a$1.pathExists(b),Qe=await a$1.pathExists(p),Xe=await a$1.pathExists(T)||await a$1.pathExists(W),re=n?.runtime==="dotnet";try{re=re||await Fe(e$1,".csproj",3)||await Fe(e$1,".sln",2);}catch{re=n?.runtime==="dotnet";}let Ye=await a$1.pathExists(f$1)||n?.runtime==="go"||typeof n?.kit_name=="string"&&(n.kit_name.startsWith("gofiber")||n.kit_name.startsWith("gogin")),xe=U&&(await a$1.pathExists(J)||await a$1.pathExists(q)||typeof n?.packageManager=="string"&&(n?.packageManager).toLowerCase().startsWith("bun@"));if(Ye){_(t,e(e$1,n??null)),t.isGoProject=true,t.venvActive=true,t.coreInstalled=false;try{await execa("go",["version"],{timeout:3e3});}catch{t.issues.push("Go toolchain not found \u2014 install from https://go.dev/dl/"),t.fixCommands?.push("https://go.dev/dl/");}let k=i.join(e$1,"go.sum");return await a$1.pathExists(k)?t.depsInstalled=true:(t.depsInstalled=false,t.issues.push("Go dependencies not downloaded (go.sum missing)"),t.fixCommands?.push(P(e$1,"go mod tidy"))),await A(e$1,t),await I(e$1,t),await H(e$1,t),t}if(await a$1.pathExists(g)||n?.runtime==="java"||typeof n?.kit_name=="string"&&n.kit_name.startsWith("springboot")){_(t,e(e$1,n??null)),t.venvActive=true,t.coreInstalled=false;let k=await a$1.pathExists(g),w=await a$1.pathExists(i.join(e$1,"build.gradle"))||await a$1.pathExists(i.join(e$1,"build.gradle.kts")),j=await a$1.pathExists(i.join(e$1,"mvnw"))||await a$1.pathExists(i.join(e$1,"mvnw.cmd")),S=await a$1.pathExists(i.join(e$1,"gradlew"))||await a$1.pathExists(i.join(e$1,"gradlew.bat"));try{await execa("java",["-version"],{timeout:3e3,reject:false});}catch{t.issues.push("Java runtime not found \u2014 install JDK 21+ and ensure java is on PATH"),t.fixCommands?.push("https://adoptium.net/");}if(k){if(!j)try{await execa("mvn",["-version"],{timeout:3e3,reject:false});}catch{t.issues.push("Maven not found \u2014 install Maven 3.9+ or add Maven Wrapper"),t.fixCommands?.push("https://maven.apache.org/install.html");}}else if(w&&!S)try{await execa("gradle",["--version"],{timeout:3e3,reject:false});}catch{t.issues.push("Gradle not found \u2014 install Gradle 8+ or add Gradle Wrapper"),t.fixCommands?.push("https://gradle.org/install/");}let M=i.join(e$1,"target"),$=i.join(e$1,"build","libs"),F=i.join(e$1,".rapidkit","cache","java","m2"),C=i.join(e$1,".rapidkit","cache","java","gradle");t.depsInstalled=await a$1.pathExists(M)||await a$1.pathExists($)||await a$1.pathExists(F)||await a$1.pathExists(C),t.depsInstalled||(t.issues.push("Java dependencies are not warmed or built yet"),t.fixCommands?.push(P(e$1,"rapidkit init")));let G=i.join(e$1,".env");if(t.hasEnvFile=await a$1.pathExists(G),!t.hasEnvFile){let z=i.join(e$1,".env.example");await a$1.pathExists(z)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(L(e$1)));}let V=i.join(e$1,"src","main","resources","application.yml");if(await a$1.pathExists(V))try{let z=await a$1.readFile(V,"utf-8");/include:\s*[^\n]*health/i.test(z)||/management:\s*[\s\S]*endpoint:\s*[\s\S]*health:/i.test(z)||(t.issues.push("Actuator health endpoint exposure is not clearly configured in application.yml"),t.fixCommands?.push(P(e$1,"Ensure management.endpoints.web.exposure.include contains health in src/main/resources/application.yml")));}catch{t.issues.push("Unable to read application.yml for Spring Actuator health checks");}return await A(e$1,t),await I(e$1,t),await H(e$1,t),t}if(ne){_(t,e(e$1,n??null)),t.venvActive=true,t.coreInstalled=false;let k=i.join(e$1,"Cargo.lock"),w=i.join(e$1,"target");t.depsInstalled=await a$1.pathExists(k)||await a$1.pathExists(w),t.depsInstalled||(t.issues.push("Rust dependencies are not resolved yet (Cargo.lock/target missing)"),t.fixCommands?.push(P(e$1,"cargo fetch")));let j=i.join(e$1,".env");if(t.hasEnvFile=await a$1.pathExists(j),!t.hasEnvFile){let S=i.join(e$1,".env.example");await a$1.pathExists(S)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(L(e$1)));}return await A(e$1,t),await I(e$1,t),await H(e$1,t),t}if(Ue){_(t,e(e$1,n??null)),t.venvActive=true,t.coreInstalled=false;let k=i.join(e$1,"mix.lock"),w=i.join(e$1,"deps");t.depsInstalled=await a$1.pathExists(k)||await a$1.pathExists(w),t.depsInstalled||(t.issues.push("Elixir dependencies not installed (mix.lock/deps missing)"),t.fixCommands?.push(P(e$1,"mix deps.get")));let j=i.join(e$1,".env");if(t.hasEnvFile=await a$1.pathExists(j),!t.hasEnvFile){let S=i.join(e$1,".env.example");await a$1.pathExists(S)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(L(e$1)));}return await A(e$1,t),await I(e$1,t),await H(e$1,t),t}if(ze){_(t,e(e$1,n??null)),t.venvActive=true,t.coreInstalled=false;let k=i.join(e$1,".cpcache"),w=i.join(e$1,"target"),j=await a$1.pathExists(y)||await a$1.pathExists(b);return t.depsInstalled=await a$1.pathExists(k)||await a$1.pathExists(w)||j,t.depsInstalled||(t.issues.push("Clojure dependency cache not initialized"),t.fixCommands?.push(P(e$1,"clojure -P"))),await A(e$1,t),await I(e$1,t),await H(e$1,t),t}if(Qe){_(t,e(e$1,n??null)),t.venvActive=true,t.coreInstalled=false;let k=i.join(e$1,"target");t.depsInstalled=await a$1.pathExists(k),t.depsInstalled||(t.issues.push("Scala build artifacts missing (run dependency/build warmup)"),t.fixCommands?.push(P(e$1,"sbt compile")));let w=i.join(e$1,".env");if(t.hasEnvFile=await a$1.pathExists(w),!t.hasEnvFile){let j=i.join(e$1,".env.example");await a$1.pathExists(j)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(L(e$1)));}return await A(e$1,t),await I(e$1,t),await H(e$1,t),t}if(Xe){_(t,e(e$1,n??null)),t.venvActive=true,t.coreInstalled=false,t.depsInstalled=true;let k=i.join(e$1,".env");if(t.hasEnvFile=await a$1.pathExists(k),!t.hasEnvFile){let w=i.join(e$1,".env.example");await a$1.pathExists(w)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(L(e$1)));}return await A(e$1,t),await I(e$1,t),await H(e$1,t),t}if(U){let k=null;try{k=await a$1.readJson(d);}catch{k=null;}let w={...k?.dependencies??{},...k?.devDependencies??{}},j=k?.scripts??{},S=typeof n?.kit_name=="string"?n.kit_name.toLowerCase():typeof n?.kit=="string"?n.kit.toLowerCase():"",M=ft({dependencies:w,scripts:j,kitName:S});if(xe)le(t,"Bun","high");else {let C=e(e$1,n??null);C.key==="nestjs"||C.key==="express"||C.key==="fastify"||C.key==="koa"?_(t,C):le(t,M.framework,M.confidence);}t.venvActive=true;let $=i.join(e$1,"node_modules");if(await a$1.pathExists($))try{let G=(await a$1.readdir($)).filter(V=>!V.startsWith(".")&&!V.startsWith("_"));t.depsInstalled=G.length>0;}catch{t.depsInstalled=false;}if(t.depsInstalled||(t.issues.push("Dependencies not installed (node_modules empty or missing)"),t.fixCommands?.push(P(e$1,xe?"bun install":"rapidkit init"))),t.coreInstalled=false,t.projectKind==="frontend"){let C=[".env",".env.local",".env.development",".env.development.local",".env.production",".env.production.local"];if((await Promise.all(C.map(V=>a$1.pathExists(i.join(e$1,V))))).some(Boolean))t.hasEnvFile=true;else {let V=i.join(e$1,".env.example");await a$1.pathExists(V)&&(t.hasEnvFile=false,t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(L(e$1)));}}else {let C=i.join(e$1,".env");if(t.hasEnvFile=await a$1.pathExists(C),!t.hasEnvFile){let G=i.join(e$1,".env.example");await a$1.pathExists(G)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(L(e$1)));}}let F=i.join(e$1,"src");if(t.modulesHealthy=true,t.missingModules=[],await a$1.pathExists(F))try{let C=await a$1.readdir(F);t.modulesHealthy=C.length>0;}catch{t.modulesHealthy=false;}return await A(e$1,t),await I(e$1,t),await H(e$1,t),t}if(B){let k=await gt(e$1);le(t,k.framework,k.confidence);let w=i.join(e$1,".venv");if(await a$1.pathExists(w)){t.venvActive=true;let $=f(w);if(await a$1.pathExists($)){try{let{stdout:G}=await execa($,["-c","import rapidkit_core; print(rapidkit_core.__version__)"],{timeout:2e3});t.coreInstalled=true,t.coreVersion=G.trim();}catch{t.coreInstalled=false;}let F="fastapi";t.framework==="Django"?F="django":t.framework==="Flask"?F="flask":t.framework==="Python"&&(F="");let C=true;if(F)try{await execa($,["-c",`import ${F}`],{timeout:2e3}),t.depsInstalled=true,C=false;}catch{C=true;}if(C)try{let G=i.join(w,"lib");if(await a$1.pathExists(G)){let z=(await a$1.readdir(G)).find(oe=>oe.startsWith("python"));if(z){let oe=i.join(G,z,"site-packages");if(await a$1.pathExists(oe)){let Ze=(await a$1.readdir(oe)).filter(me=>!me.startsWith("_")&&!me.includes("dist-info")&&!["pip","setuptools","wheel","pkg_resources"].includes(me));t.depsInstalled=Ze.length>0;}}}t.depsInstalled||(t.issues.push("Dependencies not installed"),t.fixCommands?.push(P(e$1,"rapidkit init")));}catch{t.issues.push("Could not verify dependency installation");}}else t.issues.push("Virtual environment exists but Python executable not found");}else t.issues.push("Virtual environment not created"),t.fixCommands?.push(P(e$1,"rapidkit init"));let j=i.join(e$1,".env");if(t.hasEnvFile=await a$1.pathExists(j),!t.hasEnvFile){let $=i.join(e$1,".env.example");await a$1.pathExists($)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(L(e$1)));}let S=i.join(e$1,"src"),M=i.join(e$1,"modules");if(t.modulesHealthy=true,t.missingModules=[],await a$1.pathExists(S)){let $=i.join(S,"__init__.py");await a$1.pathExists($)||(t.modulesHealthy=false,t.missingModules.push("src/__init__.py"));}if(await a$1.pathExists(M))try{let $=await _e(M);for(let F of $){let C=i.join(M,F,"__init__.py");await a$1.pathExists(C)||(t.modulesHealthy=false,t.missingModules.push(`modules/${F}/__init__.py`));}}catch{}return !t.modulesHealthy&&t.missingModules.length>0&&t.issues.push(`Missing module init files: ${t.missingModules.join(", ")}`),await A(e$1,t),await I(e$1,t),await H(e$1,t),t}if(R){_(t,e(e$1,n??null)),t.venvActive=true,t.coreInstalled=false;let k=i.join(e$1,"vendor");t.depsInstalled=await a$1.pathExists(k),t.depsInstalled||(t.issues.push("PHP dependencies not installed (vendor missing)"),t.fixCommands?.push(P(e$1,"composer install")));let w=i.join(e$1,".env");if(t.hasEnvFile=await a$1.pathExists(w),!t.hasEnvFile){let j=i.join(e$1,".env.example");await a$1.pathExists(j)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(L(e$1)));}return await A(e$1,t),await I(e$1,t),await H(e$1,t),t}if(ee){_(t,e(e$1,n??null)),t.venvActive=true,t.coreInstalled=false;let k=await a$1.pathExists(i.join(e$1,"Gemfile.lock")),w=await a$1.pathExists(i.join(e$1,"vendor","bundle"));t.depsInstalled=k||w,t.depsInstalled||(t.issues.push("Ruby dependencies not installed (Gemfile.lock/vendor missing)"),t.fixCommands?.push(P(e$1,"bundle install")));let j=i.join(e$1,".env");return t.hasEnvFile=await a$1.pathExists(j),await A(e$1,t),await I(e$1,t),await H(e$1,t),t}if(re){_(t,e(e$1,n??null)),t.venvActive=true,t.coreInstalled=false;let k=i.join(e$1,"obj"),w=i.join(e$1,"src","obj"),j=i.join(e$1,"packages.lock.json");t.depsInstalled=await a$1.pathExists(k)||await a$1.pathExists(w)||await a$1.pathExists(j),t.depsInstalled||(t.issues.push(".NET restore/build artifacts not found"),t.fixCommands?.push(P(e$1,"dotnet restore")));let S=i.join(e$1,".env");return t.hasEnvFile=await a$1.pathExists(S),await A(e$1,t),await I(e$1,t),await H(e$1,t),t}return le(t,"Unknown","low"),t.issues.push("Unknown project type (no recognized runtime marker files)"),await A(e$1,t),await I(e$1,t),await H(e$1,t),t}async function _e(e){try{return (await a$1.readdir(e,{withFileTypes:true})).filter(r=>r.isDirectory()).map(r=>r.name)}catch{try{let s=await a$1.readdir(e),r=[];for(let t of s)try{(await a$1.stat(i.join(e,t))).isDirectory()&&r.push(t);}catch{continue}return r}catch{return []}}}async function Fe(e,s,r){let t=[{dir:e,depth:0}],l=new Set([".git",".rapidkit","node_modules","bin","obj","target"]);for(;t.length>0;){let o=t.shift();if(!o||o.depth>r)continue;let n;try{n=await a$1.readdir(o.dir,{withFileTypes:true});}catch{continue}for(let d of n){if(d.isFile()&&d.name.toLowerCase().endsWith(s.toLowerCase()))return true;d.isDirectory()&&!l.has(d.name)&&t.push({dir:i.join(o.dir,d.name),depth:o.depth+1});}}return false}async function pe(e){let s=i.join(e,".rapidkit");if(!await a$1.pathExists(s))return false;let r=["project.json","context.json","file-hashes.json"];for(let t of r)if(await a$1.pathExists(i.join(s,t)))return true;return false}function Te(e,s){if(s.has(e))return true;let r=e.toLowerCase();return !!(r==="dist"||r.startsWith("dist-")||r.startsWith("dist_")||r==="build"||r.startsWith("build-")||r.startsWith("build_"))}async function $t(e,s,r){let t=new Set,l=[{dir:e,depth:0}];for(;l.length>0;){let o=l.shift();if(!o)break;try{let n=await a$1.readdir(o.dir);for(let d of n){if(Te(d,r))continue;let u=i.join(o.dir,d),m;try{m=await a$1.stat(u);}catch{continue}if(m.isDirectory()){if(await pe(u)){t.add(u);continue}o.depth<s&&l.push({dir:u,depth:o.depth+1});}}}catch{continue}}return Array.from(t)}async function ae(e){let s=i.resolve(e),r=i.parse(s).root;for(;;){if(await Dt(s))return s;if(s===r)break;s=i.dirname(s);}return null}async function Rt(e){let s=i.resolve(e),r=await ae(s),t=r??i.parse(s).root;for(;;){if(await pe(s)||await Ft(s)&&(!r||s!==r))return s;if(s===t)break;s=i.dirname(s);}return null}function De(e){let s=i.resolve(e);return process.platform==="darwin"?s.replace(/^\/private(?=\/var\/)/,""):s}async function Ft(e){let s=["package.json","pyproject.toml","requirements.txt","go.mod","pom.xml","build.sbt","Cargo.toml","mix.exs","deps.edn","project.clj","deno.json","deno.jsonc","composer.json","Gemfile"];for(let r of s)if(await a$1.pathExists(i.join(e,r)))return true;return false}async function Dt(e){let s=[i.join(e,".rapidkit-workspace"),i.join(e,".rapidkit","workspace-marker.json"),i.join(e,".rapidkit","config.json")];return Promise.all(s.map(r=>a$1.pathExists(r))).then(r=>r.some(Boolean))}function Oe(e,s){let r=0,t=0,l=0;return e.forEach(n=>{n.status==="ok"?r++:n.status==="warn"?t++:n.status==="error"&&l++;}),s.forEach(n=>{let d=Y(n),u=n.isGoProject?n.issues.length===0&&n.depsInstalled:n.issues.length===0&&n.venvActive&&n.depsInstalled;if(n.issues.length>0||d>0||!u){t++;return}r++;}),{total:r+t+l,passed:r,warnings:t,errors:l}}function Ve(e,s,r={}){let t=[];for(let o of e)t.push({id:o.id,label:o.label,status:o.result.status,scope:"host-system",policyRuleId:"system-status-derived",reason:o.result.details||o.result.message});let l=[...s].sort((o,n)=>{let d=`${o.path||""}|${o.name||""}`.toLowerCase(),u=`${n.path||""}|${n.name||""}`.toLowerCase();return d.localeCompare(u)});for(let o of l){let n=o.issues.length>0,d=Y(o),u=n||d>0?"warn":"ok",m=n?`${o.issues.length} blocking issue(s)`:d>0?`${d} advisory warning(s)`:"Project checks passed";t.push({id:`project:${o.name}`,label:`Project ${o.name}`,status:u,scope:"project-scoped",policyRuleId:n?"project-blocking-issues":d>0?"project-advisory-warnings":"project-checks-passed",reason:m});}if(r.includeWorkspaceAggregateRules){let o=s.reduce((u,m)=>u+m.issues.length,0),n=we(s),d=e.filter(u=>u.result.status==="error").length;t.push({id:"workspace:projects-discovered",label:"Workspace projects discovered",status:s.length>0?"ok":"warn",scope:"workspace-aggregate",policyRuleId:"workspace-project-discovery",reason:s.length>0?`${s.length} project(s) discovered for workspace analysis.`:"No projects discovered for workspace analysis."}),t.push({id:"workspace:system-error-gate",label:"Workspace system error gate",status:d>0?"error":"ok",scope:"workspace-aggregate",policyRuleId:"workspace-system-error-gate",reason:d>0?`${d} system requirement gate(s) failed.`:"All system requirement gates passed."}),t.push({id:"workspace:blocking-issues-gate",label:"Workspace blocking issues gate",status:o>0?"warn":"ok",scope:"workspace-aggregate",policyRuleId:"workspace-blocking-issues-gate",reason:o>0?`${o} blocking project issue(s) detected.`:"No blocking project issues detected."}),t.push({id:"workspace:advisory-warnings-gate",label:"Workspace advisory warnings gate",status:n>0?"warn":"ok",scope:"workspace-aggregate",policyRuleId:"workspace-advisory-warning-gate",reason:n>0?`${n} advisory warning(s) detected.`:"No advisory warnings detected."});}return t}async function Ae(e,s=true){let r=i.basename(e);try{let p=i.join(e,".rapidkit-workspace");await a$1.pathExists(p)&&(r=(await a$1.readJSON(p)).name||r);}catch{try{let p=i.join(e,".rapidkit","config.json");r=(await a$1.readJSON(p)).workspace_name||r;}catch{}}let[t,l]=await Promise.all([ve(),ht(e)]),o={workspacePath:e,workspaceName:r,python:t.python,poetry:t.poetry,pipx:t.pipx,go:t.go,rapidkitCore:t.rapidkitCore,projects:[]};a.debug(`Workspace scan found ${l.length} project(s)`);let n=await yt(e,l),d=i.join(e,".rapidkit","reports","doctor-workspace-cache.json"),u=s?await kt(d,n):null;if(u){o.projects=u.projects;for(let p of o.projects)p.commandCapabilities=i$1(p.path);o.projectScanCached=true,a.debug(`Workspace project health cache hit: ${d}`);}else try{let p=await Promise.all(l.map(h=>be(h)));for(let h of p)h.commandCapabilities=i$1(h.path);o.projects=p,o.projectScanCached=false,await wt(d,{schemaVersion:Ne,signature:n,generatedAt:new Date().toISOString(),projects:p}),a.debug(`Workspace project health cache refreshed: ${d}`);}catch(p){a.debug(`Failed to scan workspace projects: ${p}`);}o.projectScanSignature=n,o.projectScanCachePath=d;let m=[o.python,o.poetry,o.pipx,o.go,o.rapidkitCore];if(o.healthScore=Oe(m,o.projects),o.scoreBreakdown=Ve([{id:"system-python",label:"Python",result:o.python},{id:"system-poetry",label:"Poetry",result:o.poetry},{id:"system-pipx",label:"pipx",result:o.pipx},{id:"system-go",label:"Go",result:o.go},{id:"system-rapidkit-core",label:"RapidKit Core",result:o.rapidkitCore}],o.projects,{includeWorkspaceAggregateRules:true}),o.scopeProvenance=Be(o.scoreBreakdown),o.rapidkitCore.status==="ok"){let p=o.rapidkitCore.message.match(/([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);p&&(o.coreVersion=p[1]);}let f=i.join(e,".rapidkit","reports","doctor-last-run.json"),g=await Ge(f,"workspace");return o.driftDelta=rt(g,o),o.evidencePath=await vt(e,o,u?d:null),o}async function At(e,s){let r=e||s.projectPath,t=i.join(r,".rapidkit","reports","doctor-project-last-run.json");try{return await a$1.ensureDir(i.dirname(t)),await a$1.writeJSON(t,{schemaVersion:b$1,evidenceType:"project",generatedAt:new Date().toISOString(),contract:de(),workspacePath:e||null,projectPath:s.projectPath,projectName:s.projectName,healthScore:s.healthScore,system:{python:s.python,poetry:s.poetry,pipx:s.pipx,go:s.go,rapidkitCore:s.rapidkitCore},project:s.project,driftDelta:s.driftDelta,summary:{scopeProvenance:s.scopeProvenance},scoreBreakdown:s.scoreBreakdown??[]},{spaces:2}),t}catch{return}}async function It(e){let s=await ae(e),r=await ve(),t=await be(e,{allowNonRapidkit:true});t.commandCapabilities=i$1(e);let l=Oe([r.python,r.poetry,r.pipx,r.go,r.rapidkitCore],[t]),o={workspacePath:s||void 0,projectPath:e,projectName:i.basename(e),python:r.python,poetry:r.poetry,pipx:r.pipx,go:r.go,rapidkitCore:r.rapidkitCore,project:t,healthScore:l};o.scoreBreakdown=Ve([{id:"system-python",label:"Python",result:o.python},{id:"system-poetry",label:"Poetry",result:o.poetry},{id:"system-pipx",label:"pipx",result:o.pipx},{id:"system-go",label:"Go",result:o.go},{id:"system-rapidkit-core",label:"RapidKit Core",result:o.rapidkitCore}],[o.project]),o.scopeProvenance=Be(o.scoreBreakdown);let n=s||e,d=i.join(n,".rapidkit","reports","doctor-project-last-run.json"),u=await Ge(d,"project");return o.driftDelta=ct(u,o),o.evidencePath=await At(s||void 0,o),o}function E(e,s){let r=e.status==="ok"?"\u2705":e.status==="warn"?"\u26A0\uFE0F":"\u274C",t=e.status==="ok"?c.green:e.status==="warn"?c.yellow:c.red;console.log(`${r} ${c.bold(s)}: ${t(e.message)}`),e.paths&&e.paths.length>0&&e.paths.forEach(l=>{let o=l.version?c.cyan(` -> ${l.version}`):"";console.log(` ${c.cyan("\u2022")} ${c.gray(l.location)}: ${c.dim(l.path)}${o}`);}),e.details&&console.log(` ${c.gray(e.details)}`);}function Ie(e){let s=e.issues.length>0,r=s?"\u26A0\uFE0F":"\u2705",t=s?c.yellow:c.green;if(console.log(`
|
|
2
|
+
${r} ${c.bold("Project")}: ${t(e.name)}`),e.framework){let n=e.framework==="FastAPI"||e.framework==="Django"||e.framework==="Flask"?"\u{1F40D}":e.framework==="NestJS"?"\u{1F985}":e.framework==="Next.js"||e.framework==="Nuxt"?"\u25B2":e.framework==="React"?"\u269B\uFE0F":e.framework==="Vue"?"\u{1F7E2}":e.framework==="Angular"?"\u{1F170}\uFE0F":e.framework==="SvelteKit"?"\u{1F9E1}":e.framework==="Spring Boot"?"\u2615":e.framework==="Rust"?"\u{1F980}":e.framework==="Elixir"||e.framework==="Phoenix"?"\u{1F9EA}":e.framework==="Clojure"?"\u2699\uFE0F":e.framework==="Scala"?"\u{1F53A}":e.framework==="Kotlin"?"\u{1F7E3}":e.framework==="Deno"?"\u{1F995}":e.framework==="Bun"?"\u{1F956}":e.framework==="Go/Fiber"||e.framework==="Go/Gin"?"\u{1F439}":e.framework==="Laravel"||e.framework==="PHP"?"\u{1F418}":e.framework==="Ruby on Rails"||e.framework==="Ruby"?"\u{1F48E}":e.framework==="ASP.NET"?"\u{1F537}":"\u{1F4E6}";console.log(` ${n} Framework: ${c.cyan(e.framework)}${e.kit?c.gray(` (${e.kit})`):""}`);let d=[];e.runtimeFamily&&d.push(`runtime: ${e.runtimeFamily}`),e.projectKind&&d.push(`kind: ${e.projectKind}`),e.supportTier&&d.push(`support: ${e.supportTier}`),e.frameworkConfidence&&d.push(`confidence: ${e.frameworkConfidence}`),d.length>0&&console.log(` ${c.dim("\u21B3")} ${c.gray(d.join(" \u2022 "))}`);}if(console.log(` ${c.gray(`Path: ${e.path}`)}`),e.runtimeFamily==="python"&&(e.venvActive?console.log(` \u2705 Virtual environment: ${c.green("Active")}`):console.log(` \u274C Virtual environment: ${c.red("Not found")}`),e.coreInstalled?console.log(` ${c.dim("\u2139")} RapidKit Core: ${c.gray(e.coreVersion||"In venv")} ${c.dim("(optional)")}`):console.log(` ${c.dim("\u2139")} RapidKit Core: ${c.gray("Using global installation")} ${c.dim("(recommended)")}`)),e.depsInstalled?console.log(` \u2705 Dependencies: ${c.green("Installed")}`):console.log(` \u26A0\uFE0F Dependencies: ${c.yellow("Not installed")}`),e.hasEnvFile!==void 0&&(e.hasEnvFile?console.log(` \u2705 Environment: ${c.green(".env configured")}`):console.log(` \u26A0\uFE0F Environment: ${c.yellow(".env missing")}`)),e.modulesHealthy!==void 0&&(e.modulesHealthy?console.log(` \u2705 Modules: ${c.green("Healthy")}`):e.missingModules&&e.missingModules.length>0&&console.log(` \u26A0\uFE0F Modules: ${c.yellow(`Missing ${e.missingModules.length} init file(s)`)}`)),e.stats){let n=[];e.stats.modules!==void 0&&n.push(`${e.stats.modules} module${e.stats.modules!==1?"s":""}`),n.length>0&&console.log(` \u{1F4CA} Stats: ${c.cyan(n.join(" \u2022 "))}`);}e.lastModified&&console.log(` \u{1F552} Last Modified: ${c.gray(e.lastModified)}`);let o=[];if(e.hasTests!==void 0&&o.push(e.hasTests?"\u2705 Tests":c.dim("\u2298 No tests")),e.hasDocker!==void 0&&o.push(e.hasDocker?"\u2705 Docker":c.dim("\u2298 No Docker")),e.hasCodeQuality!==void 0){let n=e.runtimeFamily==="node"?"ESLint":e.runtimeFamily==="rust"?"clippy":e.runtimeFamily==="elixir"?"Credo":e.runtimeFamily==="clojure"?"clj-kondo":e.runtimeFamily==="deno"?"deno lint":e.framework==="Spring Boot"?"Static analysis":e.framework==="Go/Fiber"||e.framework==="Go/Gin"?"golangci-lint":e.runtimeFamily==="python"?"Ruff":"Lint";o.push(e.hasCodeQuality?`\u2705 ${n}`:c.dim(`\u2298 No ${n}`));}if(o.length>0&&console.log(` ${o.join(" \u2022 ")}`),e.vulnerabilities!==void 0&&e.vulnerabilities>0&&console.log(` \u26A0\uFE0F Security: ${c.yellow(`${e.vulnerabilities} vulnerability(ies) found`)}`),e.issues.length>0&&(console.log(` ${c.bold("Issues:")}`),e.issues.forEach(n=>{console.log(` \u2022 ${c.yellow(n)}`);}),e.fixCommands&&e.fixCommands.length>0&&(console.log(`
|
|
3
|
+
${c.bold.cyan("\u{1F527} Quick Fix:")}`),e.fixCommands.forEach(n=>{console.log(` ${c.cyan("$")} ${c.white(n)}`);}))),e.probes&&e.probes.length>0){console.log(` ${c.bold("Probe checks:")}`);for(let n of e.probes){let d=n.status==="pass"?"\u2705":n.status==="warn"?"\u26A0\uFE0F":"\u274C";console.log(` ${d} ${n.label}: ${c.gray(n.reason)}`),n.recommendation&&console.log(` ${c.dim("\u21B3")} ${c.gray(n.recommendation)}`);}}if(e.commandCapabilities){let n=e.commandCapabilities;if(console.log(` ${c.bold("Command support:")}`),console.log(` ${c.green("supported")} ${n.supportedCommands.length} \u2022 ${c.yellow("unsupported")} ${n.unsupportedCommands.length} \u2022 ${c.gray("global")} ${n.globalCommands.length}`),n.unsupportedCommands.length>0){let d=n.unsupportedCommands.slice(0,8).join(", "),u=n.unsupportedCommands.length>8?", ...":"";console.log(` ${c.dim("\u21B3")} ${c.gray(`Unsupported here: ${d}${u}`)}`);}}}async function Le(){try{return (await execa("go",["version"],{timeout:a$3(),reject:false})).exitCode===0}catch{return false}}function Z(e,s){let r=[new RegExp(`^cd\\s+"([^"]+)"\\s*(?:&&|;)\\s*${s}\\s*$`,"i"),new RegExp(`^cd\\s+'([^']+)'\\s*(?:&&|;)\\s*${s}\\s*$`,"i"),new RegExp(`^cd\\s+(.+?)\\s*(?:&&|;)\\s*${s}\\s*$`,"i")];for(let t of r){let l=e.match(t);if(l?.[1])return {projectPath:l[1].trim()}}return null}function Je(e){return Z(e,"cp\\s+\\.env\\.example\\s+\\.env")||Z(e,"copy-item\\s+\\.env\\.example\\s+\\.env")}function qe(e){let s=[{pattern:"npm\\s+install",command:"npm",args:["install"]},{pattern:"npm\\s+ci",command:"npm",args:["ci"]},{pattern:"pnpm\\s+install",command:"pnpm",args:["install"]},{pattern:"yarn\\s+install",command:"yarn",args:["install"]},{pattern:"poetry\\s+install",command:"poetry",args:["install"]},{pattern:"pip\\s+install\\s+-r\\s+requirements\\.txt",command:"pip",args:["install","-r","requirements.txt"]},{pattern:"composer\\s+install",command:"composer",args:["install"]},{pattern:"bundle\\s+install",command:"bundle",args:["install"]},{pattern:"dotnet\\s+restore",command:"dotnet",args:["restore"]},{pattern:"cargo\\s+fetch",command:"cargo",args:["fetch"]},{pattern:"mix\\s+deps\\.get",command:"mix",args:["deps.get"]},{pattern:"clojure\\s+-P",command:"clojure",args:["-P"]},{pattern:"sbt\\s+compile",command:"sbt",args:["compile"]}];for(let r of s){let t=Z(e,r.pattern);if(t)return {projectPath:t.projectPath,command:r.command,args:r.args}}return null}function ye(e,s){return /^https?:\/\//i.test(s.trim())?{projectName:e.name,projectPath:e.path,originalCommand:s,kind:"manual-url",risk:"safe",executable:false,reason:"Manual guidance URL"}:Je(s)?{projectName:e.name,projectPath:e.path,originalCommand:s,kind:"env-copy",risk:"safe",executable:true,reason:"Environment seed copy"}:Z(s,"rapidkit\\s+init")?{projectName:e.name,projectPath:e.path,originalCommand:s,kind:"rapidkit-init",risk:"guarded",executable:true,reason:"RapidKit initializer may mutate dependencies and configs"}:Z(s,"go\\s+mod\\s+tidy")?{projectName:e.name,projectPath:e.path,originalCommand:s,kind:"go-mod-tidy",risk:"guarded",executable:true,reason:"Go module graph reconciliation"}:qe(s)?{projectName:e.name,projectPath:e.path,originalCommand:s,kind:"dependency-sync",risk:"guarded",executable:true,reason:"Dependency synchronization command"}:{projectName:e.name,projectPath:e.path,originalCommand:s,kind:"shell",risk:"invasive",executable:true,reason:"Generic shell command"}}async function ke(e){let s=e.filter(m=>m.fixCommands&&m.fixCommands.length>0),r=s.flatMap(m=>(m.fixCommands??[]).map(f=>ye(m,f))),t=null,l=[],o=0,n=0,d=0,u=0;for(let m of r){let f=m.executable,g;m.kind==="go-mod-tidy"&&(t===null&&(t=await Le()),t||(f=false,g="Go toolchain not available")),f&&(o+=1,m.risk==="safe"&&(n+=1),m.risk==="guarded"&&(d+=1),m.risk==="invasive"&&(u+=1)),l.push({...m,executableInCurrentEnvironment:f,blockedReason:g});}return {generatedAt:new Date().toISOString(),fixableProjects:s.length,totalSteps:l.length,executableSteps:o,risk:{safe:n,guarded:d,invasive:u},steps:l}}function He(e){let s=e instanceof Error?e.message:String(e),r=["ETIMEDOUT","ECONNRESET","ECONNREFUSED","EAI_AGAIN","ENOTFOUND","network","503","504"],t=s.toLowerCase();return r.some(l=>t.includes(l.toLowerCase()))}async function Ht(e,s){let r=e.get(s);if(r)return r;let t=`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,l=i.basename(s).replace(/[^a-zA-Z0-9._-]/g,"_"),o=i.join(s,".rapidkit","reports","fix-snapshots",`${l}-${t}`);await a$1.ensureDir(o);let n=[".env","package-lock.json","pnpm-lock.yaml","yarn.lock","poetry.lock","requirements.txt","go.mod","go.sum","Cargo.lock","composer.lock","Gemfile.lock","pom.xml","build.gradle","build.gradle.kts","gradle.lockfile"],d=new Map;for(let m of n){let f=i.join(s,m);if(!await a$1.pathExists(f))continue;let g=i.join(o,m);await a$1.ensureDir(i.dirname(g)),await a$1.copy(f,g,{overwrite:true}),d.set(f,g);}let u={snapshotRoot:o,files:d};return e.set(s,u),u}async function Nt(e){for(let[s,r]of e.files.entries())await a$1.pathExists(r)&&(await a$1.ensureDir(i.dirname(s)),await a$1.copy(r,s,{overwrite:true}));}async function Mt(e){let s=await be(e,{allowNonRapidkit:true});return {issues:s.issues.length,healthy:s.issues.length===0}}async function te(e,s=false,r={}){let t=await ke(e),l=e.filter(h=>h.fixCommands&&h.fixCommands.length>0),o=null,n=t.steps.some(h=>h.kind==="go-mod-tidy"&&!h.executableInCurrentEnvironment),d=new Map;if(l.length===0){console.log(c.green(`
|
|
4
|
+
\u2705 No fixes needed - all projects are healthy!`));return}console.log(c.bold.cyan(`
|
|
5
|
+
\u{1F527} Available Fixes:
|
|
6
|
+
`));for(let h of l){let v=h.fixCommands??[];console.log(c.bold(`Project: ${c.yellow(h.name)}`)),v.forEach((y,b)=>{console.log(` ${b+1}. ${c.cyan(y)}`);}),console.log();}if(r.planOnly){if(r.json){console.log(JSON.stringify(t,null,2));return}console.log(c.bold(`
|
|
7
|
+
\u{1F9ED} Remediation Plan
|
|
8
|
+
`)),console.log(c.gray(`Executable steps: ${t.executableSteps}/${t.totalSteps} | risk: safe=${t.risk.safe}, guarded=${t.risk.guarded}, invasive=${t.risk.invasive}`));for(let h of t.steps){let v=h.executableInCurrentEnvironment?c.green("ready"):c.yellow(`blocked${h.blockedReason?` (${h.blockedReason})`:""}`);console.log(` - ${c.cyan(h.projectName)} [${h.risk}] ${h.originalCommand} ${c.gray(`=> ${v}`)}`);}console.log(c.gray(`
|
|
9
|
+
Use --apply to execute this plan non-interactively, or --fix for interactive confirmation.`));return}let u=t.executableSteps,m=t.risk.safe,f=t.risk.guarded,g=t.risk.invasive;if(u===0){console.log(c.gray("\u{1F4A1} No automatic fixes can be applied right now.")),n&&console.log(c.gray(" Install Go to enable go mod tidy fixes, then rerun `rapidkit doctor workspace --fix`."));return}if(!s){console.log(c.gray('\u{1F4A1} Run "npx rapidkit doctor workspace --fix" to apply fixes automatically'));return}if(console.log(c.gray(`Risk policy: safe=${m}, guarded=${f}, invasive=${g}. Guarded/invasive fixes use snapshot + rollback.`)),!r.skipConfirmation){let{confirm:h}=await et.prompt([{type:"confirm",name:"confirm",message:`Apply ${l.reduce((v,y)=>v+(y.fixCommands?.length??0),0)} fix(es)?`,default:false}]);if(!h){console.log(c.yellow(`
|
|
10
|
+
\u26A0\uFE0F Fixes cancelled by user`));return}}console.log(c.bold.cyan(`
|
|
11
|
+
\u{1F680} Applying fixes...
|
|
12
|
+
`));let p=new Set;for(let h of l){let v=h.fixCommands??[];console.log(c.bold(`Fixing ${c.cyan(h.name)}...`));for(let y of v){let b$1=ye(h,y),T=`${h.path}::${y}`;if(!p.has(T)){p.add(T);try{if(console.log(c.gray(` $ ${y}`)),b$1.kind==="manual-url"){console.log(c.yellow(` \u2139 Manual action required: open ${y}`)),console.log(c.green(` \u2705 Recorded as guidance
|
|
13
|
+
`));continue}if(!b$1.executable){console.log(c.yellow(" \u26A0 Step is non-executable by policy")),console.log(c.green(` \u2705 Recorded as guidance
|
|
14
|
+
`));continue}b$1.risk!=="safe"&&await Ht(d,b$1.projectPath);let W=Je(y);if(W){let B=i.join(W.projectPath,".env.example"),R=i.join(W.projectPath,".env");if(!await a$1.pathExists(B))throw new Error(`.env.example not found at ${B}`);if(await a$1.pathExists(R)){console.log(c.green(` \u2705 .env already exists
|
|
15
|
+
`));continue}await a$1.copy(B,R,{overwrite:false,errorOnExist:false}),console.log(c.green(` \u2705 Success
|
|
16
|
+
`));continue}let J=Z(y,"rapidkit\\s+init");if(J){await execa("rapidkit",["init"],{cwd:J.projectPath,shell:b(),stdio:"inherit"}),console.log(c.green(` \u2705 Success
|
|
17
|
+
`));continue}let q=Z(y,"go\\s+mod\\s+tidy");if(q){if(o===null&&(o=await Le()),!o){console.log(c.yellow(" \u26A0 Go toolchain is not installed \u2014 skipping go mod tidy; install Go to apply this fix.")),console.log(c.green(` \u2705 Recorded as guidance
|
|
18
|
+
`));continue}await execa("go",["mod","tidy"],{cwd:q.projectPath,shell:b(),stdio:"inherit"}),console.log(c.green(` \u2705 Success
|
|
19
|
+
`));continue}let O=qe(y);if(O){let R;for(let ee=1;ee<=2;ee+=1)try{await execa(O.command,O.args,{cwd:O.projectPath,shell:b(),stdio:"inherit"}),R=null;break}catch(ne){if(R=ne,ee<2&&He(ne)){console.log(c.yellow(` \u26A0 Retrying dependency sync (${ee}/1)...`));continue}throw ne}if(R)throw R;console.log(c.green(` \u2705 Success
|
|
20
|
+
`));continue}let se=b$1.kind==="shell"?2:1,U;for(let B=1;B<=se;B+=1)try{await execa(y,{shell:true,stdio:"inherit"}),U=null;break}catch(R){if(U=R,B<se&&He(R)){console.log(c.yellow(` \u26A0 Retrying command (${B}/${se-1})...`));continue}throw R}if(U)throw U;console.log(c.green(` \u2705 Success
|
|
21
|
+
`));}catch(W){let J=ye(h,y);if(J.risk!=="safe"){let q=d.get(J.projectPath);if(q)try{await Nt(q),console.log(c.yellow(" \u21A9 Rolled back snapshot after failed fix"));}catch(O){console.log(c.red(` \u274C Rollback failed: ${O instanceof Error?O.message:String(O)}`));}}console.log(c.red(` \u274C Failed: ${W instanceof Error?W.message:String(W)}
|
|
22
|
+
`));}}}try{let y=await Mt(h.path);console.log(y.healthy?c.green(` \u2705 Post-fix verification passed for ${h.name}`):c.yellow(` \u26A0 Post-fix verification: ${y.issues} issue(s) remain for ${h.name}`));}catch(y){console.log(c.yellow(` \u26A0 Post-fix verification skipped: ${y instanceof Error?y.message:String(y)}`));}}console.log(c.bold.green(`
|
|
23
|
+
\u2705 Fix process completed!`));}async function Yt(e={}){let s=!!(e.fix||e.plan||e.apply),r=!e.workspace&&!e.project&&s?await ae(process.cwd()):null,t=e.workspace||!!r,l=!!e.project&&!t;if(e.json||console.log(c.bold.cyan(`
|
|
24
|
+
\u{1FA7A} RapidKit Health Check
|
|
25
|
+
`)),t){let o=r??await ae(process.cwd());o||(a.error("No RapidKit workspace found in current directory or parents"),a.info('Run this command from within a workspace, or use "rapidkit doctor" for system check'),process.exit(1)),e.json||(r&&console.log(c.gray("\u2139\uFE0F Detected workspace context; enabling workspace checks for --fix")),console.log(c.bold(`Workspace: ${c.cyan(i.basename(o))}`)),console.log(c.gray(`Path: ${o}`)));let n=await Ae(o);if(e.json||(n.projectScanCached&&console.log(c.gray(`\u2139\uFE0F Reused cached project scan${n.projectScanCachePath?` (${i.basename(n.projectScanCachePath)})`:""}`)),n.evidencePath&&console.log(c.gray(`\u2139\uFE0F Evidence saved: ${n.evidencePath}`))),e.json){let f=e.plan?await ke(n.projects):void 0,g={contract:de(),workspace:{name:i.basename(o),path:o},cache:{projectScan:n.projectScanCached??false,projectScanPath:n.projectScanCachePath,evidencePath:n.evidencePath},healthScore:n.healthScore,system:{python:n.python,poetry:n.poetry,pipx:n.pipx,rapidkitCore:n.rapidkitCore,versions:{core:n.coreVersion,npm:n.npmVersion}},projects:n.projects.map(p=>({name:p.name,path:p.path,framework:p.framework,frameworkKey:p.frameworkKey,importStack:p.importStack,runtimeFamily:p.runtimeFamily,projectKind:p.projectKind,supportTier:p.supportTier,frameworkConfidence:p.frameworkConfidence,venvActive:p.venvActive,depsInstalled:p.depsInstalled,hasEnvFile:p.hasEnvFile,vulnerabilities:p.vulnerabilities,coreInstalled:p.coreInstalled,coreVersion:p.coreVersion,issues:p.issues,fixCommands:p.fixCommands,probes:p.probes,commandCapabilities:p.commandCapabilities})),summary:{totalProjects:n.projects.length,totalIssues:n.projects.reduce((p,h)=>p+h.issues.length,0),projectAdvisoryWarningProjects:he(n.projects),projectAdvisoryWarnings:we(n.projects),hasSystemErrors:[n.python,n.rapidkitCore].some(p=>p.status==="error"),scopeProvenance:n.scopeProvenance},driftDelta:n.driftDelta,scoreBreakdown:n.scoreBreakdown??[],...f?{remediationPlan:f}:{}};console.log(JSON.stringify(g,null,2));return}if(n.healthScore){let f=n.healthScore,g=Math.round(f.passed/f.total*100),p=g>=80?c.green:g>=50?c.yellow:c.red,h="\u2588".repeat(Math.floor(g/5))+"\u2591".repeat(20-Math.floor(g/5));console.log(c.bold(`
|
|
26
|
+
\u{1F4CA} Health Score:`)),console.log(` ${p(`${g}%`)} ${c.gray(h)}`),console.log(` ${c.green(`\u2705 ${f.passed} passed`)} ${c.gray("|")} ${c.yellow(`\u26A0\uFE0F ${f.warnings} warnings`)} ${c.gray("|")} ${c.red(`\u274C ${f.errors} errors`)}`);}if(console.log(c.bold(`
|
|
27
|
+
|
|
28
|
+
System Tools:
|
|
29
|
+
`)),E(n.python,"Python"),E(n.poetry,"Poetry"),E(n.pipx,"pipx"),E(n.go,"Go"),E(n.rapidkitCore,"RapidKit Core"),n.coreVersion&&n.npmVersion){let f=n.coreVersion.split(".")[1],g=n.npmVersion.split(".")[1];f!==g&&(console.log(c.yellow(`
|
|
30
|
+
\u26A0\uFE0F Version mismatch: Core ${n.coreVersion} / CLI ${n.npmVersion}`)),console.log(c.gray(" Consider updating to matching versions for best compatibility")));}n.projects.length>0?(console.log(c.bold(`
|
|
31
|
+
\u{1F4E6} Projects (${n.projects.length}):`)),n.projects.forEach(f=>Ie(f))):(console.log(c.bold(`
|
|
32
|
+
\u{1F4E6} Projects:`)),console.log(c.gray(" No RapidKit projects found in workspace")));let d=n.projects.reduce((f,g)=>f+g.issues.length,0),u=he(n.projects),m=[n.python,n.rapidkitCore].some(f=>f.status==="error");if(m||d>0||u>0){let f=u>0?` and ${u} advisory warning project(s)`:"";if(console.log(c.bold.yellow(`
|
|
33
|
+
\u26A0\uFE0F Found ${d} project issue(s)${f}`)),m&&console.log(c.bold.red("\u274C System requirements not met")),e.plan)await te(n.projects,false,{planOnly:true,json:e.json});else if(e.fix||e.apply){if(await te(n.projects,true,{skipConfirmation:e.apply===true}),!e.json){let g=await Ae(o,false),p=g.projects.reduce((v,y)=>v+y.issues.length,0),h=[g.python,g.rapidkitCore].some(v=>v.status==="error");h||p>0?(console.log(c.bold.yellow(`
|
|
34
|
+
\u26A0\uFE0F Post-fix verification found ${p} remaining issue(s)`)),h&&console.log(c.bold.red("\u274C System requirements still not met"))):console.log(c.bold.green(`
|
|
35
|
+
\u2705 Post-fix verification passed. Workspace is healthy.`)),g.projectScanCached&&console.log(c.gray(`\u2139\uFE0F Reused cached project scan${g.projectScanCachePath?` (${i.basename(g.projectScanCachePath)})`:""}`)),g.evidencePath&&console.log(c.gray(`\u2139\uFE0F Evidence refreshed: ${g.evidencePath}`));}}else d>0&&await te(n.projects,false);}else console.log(c.bold.green(`
|
|
36
|
+
\u2705 All checks passed! Workspace is healthy.`));}else if(l){let o=await Rt(process.cwd());o||(await ae(process.cwd())?(a.error("No backend project found in current directory within this workspace"),a.info("Run this command from inside a project directory in the workspace")):a.error("No RapidKit project found in current directory or parents"),a.info('Run this command from within a project, or use "rapidkit doctor workspace" for workspace checks'),process.exit(1));let n=await It(o),d=n.workspacePath?De(n.workspacePath):null,u=De(n.project.path);if(e.json){let b=e.plan?await ke([n.project]):void 0,T={contract:de(),scope:"project",workspace:d?{name:i.basename(d),path:d}:null,project:{name:n.project.name,path:u,framework:n.project.framework,frameworkKey:n.project.frameworkKey,importStack:n.project.importStack,runtimeFamily:n.project.runtimeFamily,projectKind:n.project.projectKind,supportTier:n.project.supportTier,frameworkConfidence:n.project.frameworkConfidence,venvActive:n.project.venvActive,depsInstalled:n.project.depsInstalled,hasEnvFile:n.project.hasEnvFile,vulnerabilities:n.project.vulnerabilities,coreInstalled:n.project.coreInstalled,coreVersion:n.project.coreVersion,issues:n.project.issues,fixCommands:n.project.fixCommands,probes:n.project.probes,commandCapabilities:n.project.commandCapabilities},evidencePath:n.evidencePath,healthScore:n.healthScore,system:{python:n.python,poetry:n.poetry,pipx:n.pipx,go:n.go,rapidkitCore:n.rapidkitCore},summary:{totalProjects:1,totalIssues:n.project.issues.length,projectAdvisoryWarningProjects:Y(n.project)>0?1:0,projectAdvisoryWarnings:Y(n.project),hasSystemErrors:[n.python,n.rapidkitCore].some(W=>W.status==="error"),scopeProvenance:n.scopeProvenance},driftDelta:n.driftDelta,scoreBreakdown:n.scoreBreakdown??[],...b?{remediationPlan:b}:{}};console.log(JSON.stringify(T,null,2));return}console.log(c.bold(`Project: ${c.cyan(i.basename(o))}`)),console.log(c.gray(`Path: ${o}`)),n.workspacePath&&console.log(c.gray(`Workspace: ${i.basename(n.workspacePath)}`)),n.evidencePath&&console.log(c.gray(`\u2139\uFE0F Evidence saved: ${n.evidencePath}`));let m=n.healthScore,f=m.total>0?Math.round(m.passed/m.total*100):0,g=f>=80?c.green:f>=50?c.yellow:c.red,p="\u2588".repeat(Math.floor(f/5))+"\u2591".repeat(20-Math.floor(f/5));console.log(c.bold(`
|
|
37
|
+
\u{1F4CA} Health Score:`)),console.log(` ${g(`${f}%`)} ${c.gray(p)}`),console.log(` ${c.green(`\u2705 ${m.passed} passed`)} ${c.gray("|")} ${c.yellow(`\u26A0\uFE0F ${m.warnings} warnings`)} ${c.gray("|")} ${c.red(`\u274C ${m.errors} errors`)}`),console.log(c.bold(`
|
|
38
|
+
|
|
39
|
+
System Tools:
|
|
40
|
+
`)),E(n.python,"Python"),E(n.poetry,"Poetry"),E(n.pipx,"pipx"),E(n.go,"Go"),E(n.rapidkitCore,"RapidKit Core"),console.log(c.bold(`
|
|
41
|
+
\u{1F4E6} Project (1):`)),Ie(n.project);let h=[n.python,n.rapidkitCore].some(b=>b.status==="error"),v=n.project.issues.length,y=Y(n.project);if(h||v>0||y>0){let b=y>0?` and ${y} advisory warning(s)`:"";console.log(c.bold.yellow(`
|
|
42
|
+
\u26A0\uFE0F Found ${v} project issue(s)${b}`)),h&&console.log(c.bold.red("\u274C System requirements not met")),e.plan?await te([n.project],false,{planOnly:true,json:e.json}):e.fix||e.apply?await te([n.project],true,{skipConfirmation:e.apply===true}):v>0&&await te([n.project],false);}else console.log(c.bold.green(`
|
|
43
|
+
\u2705 All checks passed! Project is healthy.`));}else {console.log(c.bold(`System Tools:
|
|
44
|
+
`));let o=await ve(),n=o.python,d=o.poetry,u=o.pipx,m=o.go,f=o.rapidkitCore;E(n,"Python"),E(d,"Poetry"),E(u,"pipx"),E(m,"Go"),E(f,"RapidKit Core"),[n,f].some(p=>p.status==="error")?(console.log(c.bold.red(`
|
|
45
|
+
\u274C Some required tools are missing`)),(e.fix||e.apply)&&console.log(c.gray(`
|
|
46
|
+
Tip: Project auto-fix runs in workspace mode. Run from a workspace and use "rapidkit doctor workspace --fix"`)),console.log(c.gray(`
|
|
47
|
+
Tip: Run "rapidkit doctor workspace" for workspace-wide checks, or "rapidkit doctor project" for the current project`))):(console.log(c.bold.green(`
|
|
48
|
+
\u2705 All required tools are installed!`)),(e.fix||e.apply)&&console.log(c.gray(`
|
|
49
|
+
Tip: Project auto-fix runs in workspace mode. Run from a workspace and use "rapidkit doctor workspace --fix"`)),console.log(c.gray(`
|
|
50
|
+
Tip: Run "rapidkit doctor workspace" for workspace-wide checks, or "rapidkit doctor project" for the current project`)));}console.log("");}export{Yt as runDoctor};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {b,c}from'./chunk-3Q7264EJ.js';import {b as b$2}from'./chunk-AC6KIKII.js';import {promises}from'fs';import n from'path';import
|
|
1
|
+
import {b,c}from'./chunk-3Q7264EJ.js';import {b as b$2}from'./chunk-AC6KIKII.js';import {promises}from'fs';import n from'path';import i from'chalk';import b$1 from'ora';import {execa}from'execa';var C="net8.0",R="8080";function A(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").replace(/-{2,}/g,"-")}function j(e,r){return e.trim().replace(/[^A-Za-z0-9_.]+/g,".").replace(/^\.+|\.+$/g,"").replace(/\.{2,}/g,".").split(".").map(a=>a.replace(/^[^A-Za-z_]+/,"").replace(/[^A-Za-z0-9_]/g,"")).filter(Boolean).join(".")||r}function S(e,r){return e.replace(/[\r\n\t]+/g," ").trim()||r}function y(e){return /^net\d+\.\d+$/.test(e.trim())}function _(){return JSON.stringify({engine:"npm",runtime:"dotnet"},null,2)}function E(e,r){return JSON.stringify({kit_name:"dotnet.webapi.clean",runtime:"dotnet",framework:"dotnet",module_support:false,project_name:e.project_name,root_namespace:e.root_namespace,target_framework:e.target_framework,app_version:e.app_version,created_by:"rapidkit-npm",rapidkit_version:r,created_at:new Date().toISOString()},null,2)}function D(e){return `<Project Sdk="Microsoft.NET.Sdk.Web">
|
|
2
2
|
<PropertyGroup>
|
|
3
3
|
<TargetFramework>${e.target_framework}</TargetFramework>
|
|
4
4
|
<Nullable>enable</Nullable>
|
|
@@ -8,6 +8,7 @@ import {b,c}from'./chunk-3Q7264EJ.js';import {b as b$2}from'./chunk-AC6KIKII.js'
|
|
|
8
8
|
<Version>${e.app_version}</Version>
|
|
9
9
|
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
|
10
10
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
|
11
|
+
<NoWarn>$(NoWarn);1591</NoWarn>
|
|
11
12
|
</PropertyGroup>
|
|
12
13
|
|
|
13
14
|
<ItemGroup>
|
|
@@ -15,7 +16,7 @@ import {b,c}from'./chunk-3Q7264EJ.js';import {b as b$2}from'./chunk-AC6KIKII.js'
|
|
|
15
16
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
|
|
16
17
|
</ItemGroup>
|
|
17
18
|
</Project>
|
|
18
|
-
`}function
|
|
19
|
+
`}function $(e){return `<Project Sdk="Microsoft.NET.Sdk">
|
|
19
20
|
<PropertyGroup>
|
|
20
21
|
<TargetFramework>${e.target_framework}</TargetFramework>
|
|
21
22
|
<ImplicitUsings>enable</ImplicitUsings>
|
|
@@ -35,7 +36,7 @@ import {b,c}from'./chunk-3Q7264EJ.js';import {b as b$2}from'./chunk-AC6KIKII.js'
|
|
|
35
36
|
<ProjectReference Include="..\\src\\${e.project_name}.csproj" />
|
|
36
37
|
</ItemGroup>
|
|
37
38
|
</Project>
|
|
38
|
-
`}function
|
|
39
|
+
`}function I(e){return `using ${e.root_namespace}.Application;
|
|
39
40
|
using ${e.root_namespace}.Infrastructure;
|
|
40
41
|
using ${e.root_namespace}.Presentation;
|
|
41
42
|
|
|
@@ -68,7 +69,7 @@ app.Run();
|
|
|
68
69
|
public partial class Program
|
|
69
70
|
{
|
|
70
71
|
}
|
|
71
|
-
`}function
|
|
72
|
+
`}function P(e){return `namespace ${e.root_namespace}.Application;
|
|
72
73
|
|
|
73
74
|
public sealed class ApplicationInfoOptions
|
|
74
75
|
{
|
|
@@ -80,7 +81,7 @@ public sealed class ApplicationInfoOptions
|
|
|
80
81
|
|
|
81
82
|
public string Description { get; init; } = "${e.description}";
|
|
82
83
|
}
|
|
83
|
-
`}function
|
|
84
|
+
`}function T(e){return `using Microsoft.Extensions.DependencyInjection;
|
|
84
85
|
|
|
85
86
|
namespace ${e.root_namespace}.Application;
|
|
86
87
|
|
|
@@ -92,7 +93,7 @@ public static class ApplicationServiceRegistration
|
|
|
92
93
|
return services;
|
|
93
94
|
}
|
|
94
95
|
}
|
|
95
|
-
`}function
|
|
96
|
+
`}function k(e){return `using Microsoft.Extensions.Options;
|
|
96
97
|
|
|
97
98
|
namespace ${e.root_namespace}.Application;
|
|
98
99
|
|
|
@@ -116,7 +117,7 @@ public sealed class SystemInfoService(IOptions<ApplicationInfoOptions> options)
|
|
|
116
117
|
DateTimeOffset.UtcNow);
|
|
117
118
|
}
|
|
118
119
|
}
|
|
119
|
-
`}function
|
|
120
|
+
`}function x(e){return `using Microsoft.Extensions.DependencyInjection;
|
|
120
121
|
|
|
121
122
|
namespace ${e.root_namespace}.Infrastructure;
|
|
122
123
|
|
|
@@ -127,7 +128,7 @@ public static class InfrastructureServiceRegistration
|
|
|
127
128
|
return services;
|
|
128
129
|
}
|
|
129
130
|
}
|
|
130
|
-
`}function
|
|
131
|
+
`}function w(e){return `using Microsoft.AspNetCore.Diagnostics;
|
|
131
132
|
using Microsoft.AspNetCore.Http;
|
|
132
133
|
using Microsoft.Extensions.DependencyInjection;
|
|
133
134
|
|
|
@@ -161,7 +162,7 @@ internal sealed class GlobalExceptionHandler : IExceptionHandler
|
|
|
161
162
|
return true;
|
|
162
163
|
}
|
|
163
164
|
}
|
|
164
|
-
`}function
|
|
165
|
+
`}function v(e){return `using ${e.root_namespace}.Application;
|
|
165
166
|
|
|
166
167
|
namespace ${e.root_namespace}.Presentation;
|
|
167
168
|
|
|
@@ -179,7 +180,7 @@ public static class SystemEndpoints
|
|
|
179
180
|
return app;
|
|
180
181
|
}
|
|
181
182
|
}
|
|
182
|
-
`}function d(e){return JSON.stringify({RapidKit:{Name:e.project_name,Version:e.app_version,Description:e.description},Logging:{LogLevel:{Default:"Information","Microsoft.AspNetCore":"Warning"}},AllowedHosts:"*",Kestrel:{Endpoints:{Http:{Url:`http://0.0.0.0:${e.port}`}}}},null,2)}function
|
|
183
|
+
`}function d(e){return JSON.stringify({RapidKit:{Name:e.project_name,Version:e.app_version,Description:e.description},Logging:{LogLevel:{Default:"Information","Microsoft.AspNetCore":"Warning"}},AllowedHosts:"*",Kestrel:{Endpoints:{Http:{Url:`http://0.0.0.0:${e.port}`}}}},null,2)}function N(e){return `FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
|
183
184
|
WORKDIR /src
|
|
184
185
|
COPY src/*.csproj ./src/
|
|
185
186
|
COPY tests/*.csproj ./tests/
|
|
@@ -196,7 +197,7 @@ ENV ASPNETCORE_URLS=http://+:${e.port}
|
|
|
196
197
|
COPY --from=build /app/publish .
|
|
197
198
|
HEALTHCHECK --interval=30s --timeout=5s --retries=3 CMD curl -fsS http://localhost:${e.port}/health/live || exit 1
|
|
198
199
|
ENTRYPOINT ["dotnet", "${e.root_namespace}.dll"]
|
|
199
|
-
`}function
|
|
200
|
+
`}function h(e){return `services:
|
|
200
201
|
api:
|
|
201
202
|
build: .
|
|
202
203
|
ports:
|
|
@@ -209,36 +210,38 @@ ENTRYPOINT ["dotnet", "${e.root_namespace}.dll"]
|
|
|
209
210
|
interval: 30s
|
|
210
211
|
timeout: 5s
|
|
211
212
|
retries: 3
|
|
212
|
-
`}function
|
|
213
|
+
`}function V(e){return `.PHONY: init dev start build test lint format docker-up docker-down
|
|
213
214
|
|
|
214
215
|
init:
|
|
215
|
-
dotnet restore
|
|
216
|
+
dotnet restore src/${e.project_name}.csproj
|
|
216
217
|
dotnet tool restore || true
|
|
217
218
|
|
|
218
219
|
dev:
|
|
219
|
-
dotnet
|
|
220
|
+
dotnet run --project src/${e.project_name}.csproj
|
|
220
221
|
|
|
221
222
|
start:
|
|
222
223
|
dotnet run --project src/${e.project_name}.csproj
|
|
223
224
|
|
|
224
225
|
build:
|
|
225
|
-
dotnet build -c Release
|
|
226
|
+
dotnet build src/${e.project_name}.csproj -c Release
|
|
226
227
|
|
|
227
228
|
test:
|
|
228
|
-
dotnet test --collect:"XPlat Code Coverage"
|
|
229
|
+
dotnet test tests/${e.project_name}.Tests.csproj --collect:"XPlat Code Coverage"
|
|
229
230
|
|
|
230
231
|
lint:
|
|
231
|
-
dotnet format --verify-no-changes
|
|
232
|
+
dotnet format src/${e.project_name}.csproj --verify-no-changes
|
|
233
|
+
dotnet format tests/${e.project_name}.Tests.csproj --verify-no-changes
|
|
232
234
|
|
|
233
235
|
format:
|
|
234
|
-
dotnet format
|
|
236
|
+
dotnet format src/${e.project_name}.csproj
|
|
237
|
+
dotnet format tests/${e.project_name}.Tests.csproj
|
|
235
238
|
|
|
236
239
|
docker-up:
|
|
237
240
|
docker compose up --build -d
|
|
238
241
|
|
|
239
242
|
docker-down:
|
|
240
243
|
docker compose down
|
|
241
|
-
`}function
|
|
244
|
+
`}function U(e){return `#!/usr/bin/env sh
|
|
242
245
|
SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
|
243
246
|
CMD="\${1:-help}"
|
|
244
247
|
shift 2>/dev/null || true
|
|
@@ -246,42 +249,58 @@ shift 2>/dev/null || true
|
|
|
246
249
|
case "$CMD" in
|
|
247
250
|
init)
|
|
248
251
|
cd "$SCRIPT_DIR" || exit 1
|
|
249
|
-
dotnet restore "
|
|
252
|
+
dotnet restore "src/${e.project_name}.csproj" || exit $?
|
|
250
253
|
dotnet tool restore 2>/dev/null || true
|
|
251
254
|
;;
|
|
252
|
-
dev) exec dotnet
|
|
255
|
+
dev) exec dotnet run --project "$SCRIPT_DIR/src/${e.project_name}.csproj" "$@" ;;
|
|
253
256
|
start) exec dotnet run --project "$SCRIPT_DIR/src/${e.project_name}.csproj" "$@" ;;
|
|
254
|
-
build) exec dotnet build "$SCRIPT_DIR/${e.project_name}.
|
|
255
|
-
test) exec dotnet test "$SCRIPT_DIR/${e.project_name}.
|
|
256
|
-
lint)
|
|
257
|
-
|
|
257
|
+
build) exec dotnet build "$SCRIPT_DIR/src/${e.project_name}.csproj" -c Release "$@" ;;
|
|
258
|
+
test) exec dotnet test "$SCRIPT_DIR/tests/${e.project_name}.Tests.csproj" "$@" ;;
|
|
259
|
+
lint)
|
|
260
|
+
dotnet format "$SCRIPT_DIR/src/${e.project_name}.csproj" --verify-no-changes "$@" || exit $?
|
|
261
|
+
exec dotnet format "$SCRIPT_DIR/tests/${e.project_name}.Tests.csproj" --verify-no-changes "$@"
|
|
262
|
+
;;
|
|
263
|
+
format|fmt)
|
|
264
|
+
dotnet format "$SCRIPT_DIR/src/${e.project_name}.csproj" "$@" || exit $?
|
|
265
|
+
exec dotnet format "$SCRIPT_DIR/tests/${e.project_name}.Tests.csproj" "$@"
|
|
266
|
+
;;
|
|
258
267
|
help|--help|-h)
|
|
259
268
|
echo "RapidKit \u2014 ASP.NET Core project: ${e.project_name}"
|
|
260
269
|
echo "Available: init, dev, start, build, test, lint, format"
|
|
261
270
|
;;
|
|
262
271
|
*) echo "rapidkit: unknown command: $CMD" >&2; exit 1 ;;
|
|
263
272
|
esac
|
|
264
|
-
`}function
|
|
273
|
+
`}function O(e){return `@echo off
|
|
265
274
|
set CMD=%1
|
|
266
275
|
if "%CMD%"=="" set CMD=help
|
|
267
276
|
shift
|
|
268
277
|
|
|
269
278
|
if "%CMD%"=="init" (
|
|
270
|
-
dotnet restore
|
|
279
|
+
dotnet restore src\\${e.project_name}.csproj
|
|
271
280
|
if errorlevel 1 exit /b %ERRORLEVEL%
|
|
272
281
|
dotnet tool restore 2>nul
|
|
273
282
|
exit /b 0
|
|
274
283
|
)
|
|
275
|
-
if "%CMD%"=="dev" ( dotnet
|
|
284
|
+
if "%CMD%"=="dev" ( dotnet run --project src\\${e.project_name}.csproj %* & exit /b %ERRORLEVEL% )
|
|
276
285
|
if "%CMD%"=="start" ( dotnet run --project src\\${e.project_name}.csproj %* & exit /b %ERRORLEVEL% )
|
|
277
|
-
if "%CMD%"=="build" ( dotnet build
|
|
278
|
-
if "%CMD%"=="test" ( dotnet test
|
|
279
|
-
if "%CMD%"=="lint" (
|
|
280
|
-
|
|
286
|
+
if "%CMD%"=="build" ( dotnet build src\\${e.project_name}.csproj -c Release %* & exit /b %ERRORLEVEL% )
|
|
287
|
+
if "%CMD%"=="test" ( dotnet test tests\\${e.project_name}.Tests.csproj %* & exit /b %ERRORLEVEL% )
|
|
288
|
+
if "%CMD%"=="lint" (
|
|
289
|
+
dotnet format src\\${e.project_name}.csproj --verify-no-changes %*
|
|
290
|
+
if errorlevel 1 exit /b %ERRORLEVEL%
|
|
291
|
+
dotnet format tests\\${e.project_name}.Tests.csproj --verify-no-changes %*
|
|
292
|
+
exit /b %ERRORLEVEL%
|
|
293
|
+
)
|
|
294
|
+
if "%CMD%"=="format" (
|
|
295
|
+
dotnet format src\\${e.project_name}.csproj %*
|
|
296
|
+
if errorlevel 1 exit /b %ERRORLEVEL%
|
|
297
|
+
dotnet format tests\\${e.project_name}.Tests.csproj %*
|
|
298
|
+
exit /b %ERRORLEVEL%
|
|
299
|
+
)
|
|
281
300
|
|
|
282
301
|
echo Available: init, dev, start, build, test, lint, format
|
|
283
302
|
exit /b 1
|
|
284
|
-
`}function
|
|
303
|
+
`}function M(e){return `name: CI
|
|
285
304
|
|
|
286
305
|
on:
|
|
287
306
|
push:
|
|
@@ -300,14 +319,18 @@ jobs:
|
|
|
300
319
|
with:
|
|
301
320
|
dotnet-version: 8.0.x
|
|
302
321
|
- name: Restore
|
|
303
|
-
run:
|
|
322
|
+
run: |
|
|
323
|
+
dotnet restore src/${e.project_name}.csproj
|
|
324
|
+
dotnet restore tests/${e.project_name}.Tests.csproj
|
|
304
325
|
- name: Format check
|
|
305
|
-
run:
|
|
326
|
+
run: |
|
|
327
|
+
dotnet format src/${e.project_name}.csproj --verify-no-changes
|
|
328
|
+
dotnet format tests/${e.project_name}.Tests.csproj --verify-no-changes
|
|
306
329
|
- name: Build
|
|
307
|
-
run: dotnet build
|
|
330
|
+
run: dotnet build src/${e.project_name}.csproj -c Release --no-restore
|
|
308
331
|
- name: Test
|
|
309
|
-
run: dotnet test
|
|
310
|
-
`}function
|
|
332
|
+
run: dotnet test tests/${e.project_name}.Tests.csproj -c Release --no-build --collect:"XPlat Code Coverage"
|
|
333
|
+
`}function W(e){return `using System.Net;
|
|
311
334
|
using Microsoft.AspNetCore.Mvc.Testing;
|
|
312
335
|
using Xunit;
|
|
313
336
|
|
|
@@ -343,15 +366,60 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|
|
343
366
|
# Visual Studio Version 17
|
|
344
367
|
VisualStudioVersion = 17.0.31903.59
|
|
345
368
|
MinimumVisualStudioVersion = 10.0.40219.1
|
|
369
|
+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{33333333-3333-3333-3333-333333333333}"
|
|
370
|
+
EndProject
|
|
371
|
+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{44444444-4444-4444-4444-444444444444}"
|
|
372
|
+
EndProject
|
|
346
373
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "${e.project_name}", "src\\${e.project_name}.csproj", "{11111111-1111-1111-1111-111111111111}"
|
|
347
374
|
EndProject
|
|
348
375
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "${e.project_name}.Tests", "tests\\${e.project_name}.Tests.csproj", "{22222222-2222-2222-2222-222222222222}"
|
|
349
376
|
EndProject
|
|
350
377
|
Global
|
|
378
|
+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
|
379
|
+
Debug|Any CPU = Debug|Any CPU
|
|
380
|
+
Debug|x64 = Debug|x64
|
|
381
|
+
Debug|x86 = Debug|x86
|
|
382
|
+
Release|Any CPU = Release|Any CPU
|
|
383
|
+
Release|x64 = Release|x64
|
|
384
|
+
Release|x86 = Release|x86
|
|
385
|
+
EndGlobalSection
|
|
386
|
+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
|
387
|
+
{11111111-1111-1111-1111-111111111111}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
388
|
+
{11111111-1111-1111-1111-111111111111}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
389
|
+
{11111111-1111-1111-1111-111111111111}.Debug|x64.ActiveCfg = Debug|Any CPU
|
|
390
|
+
{11111111-1111-1111-1111-111111111111}.Debug|x64.Build.0 = Debug|Any CPU
|
|
391
|
+
{11111111-1111-1111-1111-111111111111}.Debug|x86.ActiveCfg = Debug|Any CPU
|
|
392
|
+
{11111111-1111-1111-1111-111111111111}.Debug|x86.Build.0 = Debug|Any CPU
|
|
393
|
+
{11111111-1111-1111-1111-111111111111}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
394
|
+
{11111111-1111-1111-1111-111111111111}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
395
|
+
{11111111-1111-1111-1111-111111111111}.Release|x64.ActiveCfg = Release|Any CPU
|
|
396
|
+
{11111111-1111-1111-1111-111111111111}.Release|x64.Build.0 = Release|Any CPU
|
|
397
|
+
{11111111-1111-1111-1111-111111111111}.Release|x86.ActiveCfg = Release|Any CPU
|
|
398
|
+
{11111111-1111-1111-1111-111111111111}.Release|x86.Build.0 = Release|Any CPU
|
|
399
|
+
{22222222-2222-2222-2222-222222222222}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
400
|
+
{22222222-2222-2222-2222-222222222222}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
401
|
+
{22222222-2222-2222-2222-222222222222}.Debug|x64.ActiveCfg = Debug|Any CPU
|
|
402
|
+
{22222222-2222-2222-2222-222222222222}.Debug|x64.Build.0 = Debug|Any CPU
|
|
403
|
+
{22222222-2222-2222-2222-222222222222}.Debug|x86.ActiveCfg = Debug|Any CPU
|
|
404
|
+
{22222222-2222-2222-2222-222222222222}.Debug|x86.Build.0 = Debug|Any CPU
|
|
405
|
+
{22222222-2222-2222-2222-222222222222}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
406
|
+
{22222222-2222-2222-2222-222222222222}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
407
|
+
{22222222-2222-2222-2222-222222222222}.Release|x64.ActiveCfg = Release|Any CPU
|
|
408
|
+
{22222222-2222-2222-2222-222222222222}.Release|x64.Build.0 = Release|Any CPU
|
|
409
|
+
{22222222-2222-2222-2222-222222222222}.Release|x86.ActiveCfg = Release|Any CPU
|
|
410
|
+
{22222222-2222-2222-2222-222222222222}.Release|x86.Build.0 = Release|Any CPU
|
|
411
|
+
EndGlobalSection
|
|
412
|
+
GlobalSection(SolutionProperties) = preSolution
|
|
413
|
+
HideSolutionNode = FALSE
|
|
414
|
+
EndGlobalSection
|
|
415
|
+
GlobalSection(NestedProjects) = preSolution
|
|
416
|
+
{11111111-1111-1111-1111-111111111111} = {33333333-3333-3333-3333-333333333333}
|
|
417
|
+
{22222222-2222-2222-2222-222222222222} = {44444444-4444-4444-4444-444444444444}
|
|
418
|
+
EndGlobalSection
|
|
351
419
|
EndGlobal
|
|
352
|
-
`.trimStart()}async function
|
|
353
|
-
PORT=${
|
|
354
|
-
`),await c(n.join(e,".github","workflows","ci.yml"),
|
|
420
|
+
`.trimStart()}async function F(e,r){if(!r)try{await execa("git",["init"],{cwd:e,stdio:"ignore"});}catch{console.log(i.gray("\u26A0 git init skipped (git not found or error)"));}}async function L(e){try{await execa("dotnet",["--version"],{cwd:e,timeout:3e3,stdio:"pipe"});}catch{console.log(i.yellow("\u26A0 .NET SDK not found in PATH - project scaffolded, but init/build need .NET 8+")),console.log(i.gray(" Install: https://dotnet.microsoft.com/download"));}}async function Q(e,r){let s=A(r.project_name)||"dotnet-api",c$1=j(r.root_namespace||`RapidKit.${b(s)}`,"RapidKit.App"),a=r.target_framework&&y(r.target_framework)?r.target_framework:C,g=r.port&&/^\d+$/.test(r.port)?r.port:R,o={project_name:s,root_namespace:c$1,description:S(r.description||"","Production-ready ASP.NET Core Web API scaffolded by RapidKit."),target_framework:a,app_version:r.app_version||"0.1.0",port:g,skipGit:r.skipGit??false},f=b$1(`Creating ASP.NET Core Web API project ${s}`).start();await promises.mkdir(e,{recursive:true}),await c(n.join(e,`${s}.sln`),G(o)),await c(n.join(e,"src",`${s}.csproj`),D(o)),await c(n.join(e,"src","Program.cs"),I(o)),await c(n.join(e,"src","Application","ApplicationInfoOptions.cs"),P(o)),await c(n.join(e,"src","Application","ApplicationServiceRegistration.cs"),T(o)),await c(n.join(e,"src","Application","SystemInfoService.cs"),k(o)),await c(n.join(e,"src","Infrastructure","InfrastructureServiceRegistration.cs"),x(o)),await c(n.join(e,"src","Presentation","PresentationServiceRegistration.cs"),w(o)),await c(n.join(e,"src","Presentation","SystemEndpoints.cs"),v(o)),await c(n.join(e,"src","appsettings.json"),d(o)),await c(n.join(e,"src","appsettings.Development.json"),d(o)),await c(n.join(e,"tests",`${s}.Tests.csproj`),$(o)),await c(n.join(e,"tests","RuntimeSmokeTests.cs"),W(o)),await c(n.join(e,"Dockerfile"),N(o)),await c(n.join(e,"docker-compose.yml"),h(o)),await c(n.join(e,"Makefile"),V(o)),await c(n.join(e,"rapidkit"),U(o)),await c(n.join(e,"rapidkit.cmd"),O(o)),await c(n.join(e,".env.example"),`ASPNETCORE_ENVIRONMENT=Development
|
|
421
|
+
PORT=${o.port}
|
|
422
|
+
`),await c(n.join(e,".github","workflows","ci.yml"),M(o)),await c(n.join(e,".rapidkit","context.json"),_()),await c(n.join(e,".rapidkit","project.json"),E(o,b$2())),process.platform!=="win32"&&await promises.chmod(n.join(e,"rapidkit"),493),await F(e,o.skipGit),f.succeed("ASP.NET Core Web API project ready"),await L(e),console.log(i.green(`
|
|
355
423
|
\u2705 ASP.NET Core project ready!
|
|
356
|
-
`)),console.log(
|
|
357
|
-
Endpoints: /health/live, /health/ready, /api/v1/system/info, /docs`)),console.log(
|
|
424
|
+
`)),console.log(i.gray("Next steps:")),console.log(i.white(` cd ${s}`)),console.log(i.white(" ./rapidkit init")),console.log(i.white(" ./rapidkit dev")),console.log(i.gray(`
|
|
425
|
+
Endpoints: /health/live, /health/ready, /api/v1/system/info, /docs`)),console.log(i.gray("\u2139 RapidKit modules are not available for .NET projects yet."));}export{R as DEFAULT_DOTNET_PORT,C as DEFAULT_DOTNET_TARGET_FRAMEWORK,Q as generateDotnetWebApiCleanKit};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
declare function handleCreateOrFallback(args: string[]): Promise<number>;
|
|
3
|
-
declare const NPM_ONLY_TOP_LEVEL_COMMANDS: readonly ["analyze", "readiness", "doctor", "autopilot", "import", "snapshot", "workspace", "bootstrap", "setup", "cache", "mirror", "ai", "config", "product", "shell", "commands"];
|
|
3
|
+
declare const NPM_ONLY_TOP_LEVEL_COMMANDS: readonly ["analyze", "readiness", "doctor", "autopilot", "import", "snapshot", "workspace", "bootstrap", "setup", "cache", "mirror", "ai", "config", "product", "infra", "shell", "commands"];
|
|
4
4
|
declare const NPM_ONLY_SCOPED_COMMANDS: readonly [readonly ["project", "commands"], readonly ["project", "archives"], readonly ["project", "archive"], readonly ["project", "restore"], readonly ["project", "delete"]];
|
|
5
5
|
declare const WRAPPER_ORCHESTRATED_PROJECT_COMMANDS: readonly ["init"];
|
|
6
6
|
declare function isNpmExecInvocation(env?: NodeJS.ProcessEnv): boolean;
|