rapidkit 0.27.4 → 0.27.6
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 +12 -4
- package/dist/chunk-2FIX2MDC.js +1 -0
- package/dist/{chunk-ZAZJEYYT.js → chunk-7OGOVP5U.js} +2 -2
- package/dist/chunk-AC6KIKII.js +5 -0
- package/dist/chunk-BFCIY2QK.js +33 -0
- package/dist/chunk-VKLL63TL.js +1 -0
- package/dist/create-TWGGH5XC.js +842 -0
- package/dist/{demo-kit-HMJZ3A3M.js → demo-kit-KTRITRWH.js} +1 -1
- package/dist/doctor-DDIR7LBO.js +50 -0
- package/dist/{gofiber-standard-JDPREQCP.js → gofiber-standard-TFPNBIMS.js} +1 -1
- package/dist/{gogin-standard-DCERHHVB.js → gogin-standard-7UJ2OBYL.js} +1 -1
- package/dist/index.js +112 -112
- package/dist/package.json +5 -1
- package/dist/pythonRapidkitExec-4MP62M5R.js +1 -0
- package/dist/{springboot-standard-AGTOOTNT.js → springboot-standard-H6GYMH3P.js} +1 -1
- package/dist/{workspace-HEHMJ3QC.js → workspace-YKWUI37R.js} +45 -45
- package/dist/workspace-run-GVE4J6HT.js +3 -0
- package/package.json +5 -1
- package/dist/chunk-Q7ULIFQA.js +0 -5
- package/dist/chunk-UOGFCKQ5.js +0 -33
- package/dist/create-GHYIP4PM.js +0 -781
- package/dist/doctor-SZXHMRFR.js +0 -47
- package/dist/pythonRapidkitExec-K2SFGAYJ.js +0 -1
- package/dist/workspace-run-M7XJ3QH5.js +0 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {b}from'./chunk-
|
|
1
|
+
import {b}from'./chunk-AC6KIKII.js';import {promises}from'fs';import a from'path';import E from'nunjucks';import t from'chalk';import _ from'ora';import {fileURLToPath}from'url';import {execa}from'execa';import N from'crypto';var P=fileURLToPath(import.meta.url),K=a.dirname(P);function T(i=32){let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",v=N.randomBytes(i),r="";for(let p=0;p<i;p++)r+=e[v[p]%e.length];return r}async function U(i,e){let r=(e.template||"fastapi")==="fastapi",p=r?"FastAPI":"NestJS",d=e.kit_name||(r?"fastapi.standard":"nestjs.standard"),I=d.replace(".","/"),h=_(`Generating ${p} project...`).start();try{let u=a.resolve(K,".."),l;d==="fastapi.ddd"?l="fastapi-ddd":d.startsWith("fastapi")?l="fastapi-standard":l="nestjs-standard";let k=a.join(u,"templates","kits",l),w=E.configure(k,{autoescape:false,trimBlocks:true,lstripBlocks:true});w.addFilter("generate_secret",function(n,o=32){return T(o)});let S={project_name:e.project_name,author:e.author||"RapidKit User",description:e.description||(r?"FastAPI service generated with RapidKit":"NestJS application generated with RapidKit"),app_version:e.app_version||"0.1.0",license:e.license||"MIT",package_manager:e.package_manager||"npm",node_version:e.node_version||"20.0.0",database_type:e.database_type||"postgresql",include_caching:e.include_caching||false,created_at:new Date().toISOString(),rapidkit_version:b()},j;r?j=["src/main.py.j2","src/__init__.py.j2","src/cli.py.j2","src/routing/__init__.py.j2","src/routing/health.py.j2","src/modules/__init__.py.j2","tests/__init__.py.j2","README.md.j2","pyproject.toml.j2","Makefile.j2",".rapidkit/__init__.py.j2",".rapidkit/project.json.j2",".rapidkit/cli.py.j2",".rapidkit/rapidkit.j2",".rapidkit/activate.j2","rapidkit.j2","rapidkit.cmd.j2"]:j=["src/main.ts.j2","src/app.module.ts.j2","src/app.controller.ts.j2","src/app.service.ts.j2","src/config/configuration.ts.j2","src/config/validation.ts.j2","src/config/index.ts.j2","src/modules/index.ts.j2","src/examples/examples.module.ts.j2","src/examples/examples.controller.ts.j2","src/examples/examples.service.ts.j2","src/examples/dto/create-note.dto.ts.j2","test/app.controller.spec.ts.j2","test/examples.controller.spec.ts.j2","test/app.e2e-spec.ts.j2","test/jest-e2e.json.j2","package.json.j2","tsconfig.json.j2","tsconfig.build.json.j2","nest-cli.json.j2","jest.config.ts.j2","eslint.config.cjs.j2",".env.example.j2","docker-compose.yml.j2","Dockerfile.j2","README.md.j2",".rapidkit/project.json.j2",".rapidkit/rapidkit.j2",".rapidkit/rapidkit.cmd.j2",".rapidkit/activate.j2","rapidkit.j2","rapidkit.cmd.j2"];for(let n of j){let o=a.join(k,n);try{await promises.access(o);}catch{continue}let y=await promises.readFile(o,"utf-8"),m;try{m=w.renderString(y,S);}catch(R){throw console.error(`Failed to render template: ${n}`),R}let c=n.replace(/\.j2$/,""),f=a.join(i,c);await promises.mkdir(a.dirname(f),{recursive:true}),await promises.writeFile(f,m),(c.endsWith(".rapidkit/rapidkit")||c.endsWith(".rapidkit/cli.py")||c.endsWith(".rapidkit/activate")||c==="rapidkit")&&await promises.chmod(f,493);}if(r){let n=a.join(k,".rapidkit","context.json"),o=a.join(i,".rapidkit","context.json");try{await promises.mkdir(a.join(i,".rapidkit"),{recursive:true}),await promises.copyFile(n,o);}catch{await promises.mkdir(a.join(i,".rapidkit"),{recursive:true});let m=e.engine||"pip";await promises.writeFile(o,JSON.stringify({engine:m,created_by:"rapidkit-npm-fallback"},null,2));}}let x=a.join(i,".rapidkit");await promises.mkdir(x,{recursive:true});let F=a.join(x,"project.json"),A={kit_name:d,profile:I,created_at:new Date().toISOString(),created_by:"rapidkit-npm-fallback",runtime:r?"python":"node"};await promises.writeFile(F,JSON.stringify(A,null,2),"utf-8");let D=r?`# Python
|
|
2
2
|
__pycache__/
|
|
3
3
|
*.py[cod]
|
|
4
4
|
*$py.class
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import {e}from'./chunk-TYC54P7X.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$1}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 Ye from'inquirer';function Ze(e){return [...new Set(e.filter(s=>s&&s.trim().length>0))]}function et(){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 Ze([...e,...s,...r])}function tt(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$1(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 st(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 ge(e){return e.filter(s=>Y(s)>0).length}function ke(e){return e.reduce((s,r)=>s+Y(r),0)}var nt="doctor-project-scan-v2",Ie="doctor-workspace-cache-v1",ot=Object.freeze({version:"doctor-evidence-v1",scoringPolicyVersion:"doctor-score-policy-v1",generatedBy:"rapidkit-npm",deterministicScoreBreakdown:true,scopeModel:"workspace-aggregate-or-project-scoped"});function ce(){return {...ot}}function le(e){return !e||e.total<=0?null:Math.round(e.passed/e.total*100)}function He(e){return typeof e=="number"?e:Array.isArray(e)?e.length:0}async function Ne(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 Me(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 it(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,He(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=le(e.healthScore),g=le(s.healthScore);return {baselineAvailable:true,previousGeneratedAt:e.generatedAt,newIssueCount:o,resolvedIssueCount:n,netIssueDelta:o-n,scoreDeltaPercent:f===null||g===null?null:g-f,systemStatusChanges:Me(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 at(e,s){if(!e)return {baselineAvailable:false,newIssueCount:0,resolvedIssueCount:0,netIssueDelta:0,scoreDeltaPercent:null,systemStatusChanges:[],regressedProjects:[],improvedProjects:[]};let r=He(e.project?.issues),t=s.project.issues.length,l=Math.max(t-r,0),o=Math.max(r-t,0),n=le(e.healthScore),d=le(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:Me(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 Ge(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 rt(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 ct(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 lt(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 re(e,s,r){e.framework=s,e.frameworkConfidence=r,e.supportTier=rt(s),e.projectKind=ct(s),e.runtimeFamily=lt(s);}function dt(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 We(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 ut(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=We(s),e.frameworkKey=s.key,e.importStack=s.importStack,e.frameworkConfidence=s.confidence,e.supportTier=s.supportTier,e.projectKind=ut(s)?"generic":"backend",e.runtimeFamily=dt(s.runtime);}function pt(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 mt(e$1){let s=e(e$1);return s.runtime!=="python"?{framework:"Python",confidence:"low"}:{framework:We(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 ft(e){try{let s=new Set([".git",".venv","node_modules",".rapidkit","dist","build","coverage","__pycache__"]),r=new Set;await de(e)&&r.add(e);let t=async(l,o)=>{if(o<0)return;let n=await Be(l);for(let d of n){if(Ke(d,s))continue;let u=i.join(l,d);if(await de(u)){r.add(u);continue}o>0&&await t(u,o-1);}};return await t(e,1),r.size===0&&(await Pt(e,3,s)).forEach(o=>r.add(o)),Array.from(r).sort((l,o)=>l.localeCompare(o))}catch{return []}}async function gt(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 [nt,...l,...o].join("||")}async function ht(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!==Ie?null:r}catch{return null}}async function yt(e,s){try{await a$1.ensureDir(i.dirname(e)),await a$1.writeJSON(e,s,{spaces:2});}catch{}}async function kt(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:ce(),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:ge(s.projects),projectAdvisoryWarnings:ke(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 we(){let[e,s,r,t,l]=await Promise.all([wt(),vt(),xt(),bt(),jt()]);return {python:e,poetry:s,pipx:r,go:t,rapidkitCore:l}}async function wt(){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 vt(){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 et())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 xt(){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 bt(){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 jt(){let e=process.env.HOME||process.env.USERPROFILE||"",s=[],r=tt(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=st(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 D(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 A(e,s){e.probes||(e.probes=[]),e.probes.push(s);}async function Ct(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"));A(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"));A(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"));A(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"));A(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"));A(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"));A(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 Et(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 x=v&&y;A(s,{id:m,label:f,status:x?"pass":g==="error"?"fail":"warn",severity:g,scope:"project-scoped",reason:x?d.passReason||"Custom adapter contract satisfied.":d.failReason||`Custom adapter check failed from ${i.basename(t)}.`,recommendation:d.recommendation});}}catch{A(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 M(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"));A(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}A(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}A(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 Ct(e,s);}async function G(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 x of g)if(await a$1.pathExists(i.join(e,x))){h=true;break}let v=true;for(let x of p)if(!await a$1.pathExists(i.join(e,x))){v=false;break}let y=h&&v;A(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{A(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 Et(e,s);}async function ve(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{}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),I=Date.now()-w.mtime.getTime(),H=Math.floor(I/(1e3*60*60*24));t.lastModified=H===0?"today":`${H} day${H>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"),x=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),Je=await a$1.pathExists(v),qe=await a$1.pathExists(y)||await a$1.pathExists(x),Ue=await a$1.pathExists(p),ze=await a$1.pathExists(T)||await a$1.pathExists(W),ue=false;try{ue=(await a$1.readdir(e$1)).some(w=>w.endsWith(".csproj")||w.endsWith(".sln"));}catch{ue=false;}let Qe=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(Qe){_(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 D(e$1,t),await M(e$1,t),await G(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")),I=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&&!I)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 H=i.join(e$1,"target"),S=i.join(e$1,"build","libs"),$=i.join(e$1,".rapidkit","cache","java","m2"),C=i.join(e$1,".rapidkit","cache","java","gradle");t.depsInstalled=await a$1.pathExists(H)||await a$1.pathExists(S)||await a$1.pathExists($)||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 N=i.join(e$1,".env");if(t.hasEnvFile=await a$1.pathExists(N),!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 D(e$1,t),await M(e$1,t),await G(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 I=i.join(e$1,".env.example");await a$1.pathExists(I)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(L(e$1)));}return await D(e$1,t),await M(e$1,t),await G(e$1,t),t}if(Je){_(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 I=i.join(e$1,".env.example");await a$1.pathExists(I)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(L(e$1)));}return await D(e$1,t),await M(e$1,t),await G(e$1,t),t}if(qe){_(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(x);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 D(e$1,t),await M(e$1,t),await G(e$1,t),t}if(Ue){_(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 D(e$1,t),await M(e$1,t),await G(e$1,t),t}if(ze){_(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 D(e$1,t),await M(e$1,t),await G(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??{},I=typeof n?.kit_name=="string"?n.kit_name.toLowerCase():typeof n?.kit=="string"?n.kit.toLowerCase():"",H=pt({dependencies:w,scripts:j,kitName:I});if(xe)re(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):re(t,H.framework,H.confidence);}t.venvActive=true;let S=i.join(e$1,"node_modules");if(await a$1.pathExists(S))try{let N=(await a$1.readdir(S)).filter(V=>!V.startsWith(".")&&!V.startsWith("_"));t.depsInstalled=N.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 N=i.join(e$1,".env.example");await a$1.pathExists(N)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(L(e$1)));}}let $=i.join(e$1,"src");if(t.modulesHealthy=true,t.missingModules=[],await a$1.pathExists($))try{let C=await a$1.readdir($);t.modulesHealthy=C.length>0;}catch{t.modulesHealthy=false;}return await D(e$1,t),await M(e$1,t),await G(e$1,t),t}if(B){let k=await mt(e$1);re(t,k.framework,k.confidence);let w=i.join(e$1,".venv");if(await a$1.pathExists(w)){t.venvActive=true;let S=f(w);if(await a$1.pathExists(S)){try{let{stdout:N}=await execa(S,["-c","import rapidkit_core; print(rapidkit_core.__version__)"],{timeout:2e3});t.coreInstalled=true,t.coreVersion=N.trim();}catch{t.coreInstalled=false;}let $="fastapi";t.framework==="Django"?$="django":t.framework==="Flask"?$="flask":t.framework==="Python"&&($="");let C=true;if($)try{await execa(S,["-c",`import ${$}`],{timeout:2e3}),t.depsInstalled=true,C=false;}catch{C=true;}if(C)try{let N=i.join(w,"lib");if(await a$1.pathExists(N)){let z=(await a$1.readdir(N)).find(oe=>oe.startsWith("python"));if(z){let oe=i.join(N,z,"site-packages");if(await a$1.pathExists(oe)){let Xe=(await a$1.readdir(oe)).filter(pe=>!pe.startsWith("_")&&!pe.includes("dist-info")&&!["pip","setuptools","wheel","pkg_resources"].includes(pe));t.depsInstalled=Xe.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 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)));}let I=i.join(e$1,"src"),H=i.join(e$1,"modules");if(t.modulesHealthy=true,t.missingModules=[],await a$1.pathExists(I)){let S=i.join(I,"__init__.py");await a$1.pathExists(S)||(t.modulesHealthy=false,t.missingModules.push("src/__init__.py"));}if(await a$1.pathExists(H))try{let S=await Be(H);for(let $ of S){let C=i.join(H,$,"__init__.py");await a$1.pathExists(C)||(t.modulesHealthy=false,t.missingModules.push(`modules/${$}/__init__.py`));}}catch{}return !t.modulesHealthy&&t.missingModules.length>0&&t.issues.push(`Missing module init files: ${t.missingModules.join(", ")}`),await D(e$1,t),await M(e$1,t),await G(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 D(e$1,t),await M(e$1,t),await G(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 D(e$1,t),await M(e$1,t),await G(e$1,t),t}if(ue){_(t,e(e$1,n??null)),t.venvActive=true,t.coreInstalled=false;let k=i.join(e$1,"obj"),w=i.join(e$1,"packages.lock.json");t.depsInstalled=await a$1.pathExists(k)||await a$1.pathExists(w),t.depsInstalled||(t.issues.push(".NET restore/build artifacts not found"),t.fixCommands?.push(P(e$1,"dotnet restore")));let j=i.join(e$1,".env");return t.hasEnvFile=await a$1.pathExists(j),await D(e$1,t),t}return re(t,"Unknown","low"),t.issues.push("Unknown project type (no recognized runtime marker files)"),await D(e$1,t),await M(e$1,t),await G(e$1,t),t}async function Be(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 de(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 Ke(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 Pt(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(Ke(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 de(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 $t(s))return s;if(s===r)break;s=i.dirname(s);}return null}async function St(e){let s=i.resolve(e),r=await ae(s),t=r??i.parse(s).root;for(;;){if(await de(s)||await Rt(s)&&(!r||s!==r))return s;if(s===t)break;s=i.dirname(s);}return null}function $e(e){let s=i.resolve(e);return process.platform==="darwin"?s.replace(/^\/private(?=\/var\/)/,""):s}async function Rt(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 $t(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 _e(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 Te(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=ke(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 Fe(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([we(),ft(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 gt(e,l),d=i.join(e,".rapidkit","reports","doctor-workspace-cache.json"),u=s?await ht(d,n):null;if(u)o.projects=u.projects,o.projectScanCached=true,a.debug(`Workspace project health cache hit: ${d}`);else try{let p=await Promise.all(l.map(h=>ve(h)));o.projects=p,o.projectScanCached=false,await yt(d,{schemaVersion:Ie,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=_e(m,o.projects),o.scoreBreakdown=Te([{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=Ge(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 Ne(f,"workspace");return o.driftDelta=it(g,o),o.evidencePath=await kt(e,o,u?d:null),o}async function Ft(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:ce(),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 Dt(e){let s=await ae(e),r=await we(),t=await ve(e,{allowNonRapidkit:true}),l=_e([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=Te([{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=Ge(o.scoreBreakdown);let n=s||e,d=i.join(n,".rapidkit","reports","doctor-project-last-run.json"),u=await Ne(d,"project");return o.driftDelta=at(u,o),o.evidencePath=await Ft(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 De(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)}`);}}}async function Oe(){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 Ve(e){return Z(e,"cp\\s+\\.env\\.example\\s+\\.env")||Z(e,"copy-item\\s+\\.env\\.example\\s+\\.env")}function Le(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 he(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"}:Ve(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"}:Le(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 ye(e){let s=e.filter(m=>m.fixCommands&&m.fixCommands.length>0),r=s.flatMap(m=>(m.fixCommands??[]).map(f=>he(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 Oe()),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 Ae(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 At(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 It(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 Ht(e){let s=await ve(e,{allowNonRapidkit:true});return {issues:s.issues.length,healthy:s.issues.length===0}}async function te(e,s=false,r={}){let t=await ye(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,x)=>{console.log(` ${x+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 Ye.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 x=he(h,y),T=`${h.path}::${y}`;if(!p.has(T)){p.add(T);try{if(console.log(c.gray(` $ ${y}`)),x.kind==="manual-url"){console.log(c.yellow(` \u2139 Manual action required: open ${y}`)),console.log(c.green(` \u2705 Recorded as guidance
|
|
13
|
+
`));continue}if(!x.executable){console.log(c.yellow(" \u26A0 Step is non-executable by policy")),console.log(c.green(` \u2705 Recorded as guidance
|
|
14
|
+
`));continue}x.risk!=="safe"&&await At(d,x.projectPath);let W=Ve(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 Oe()),!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=Le(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&&Ae(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=x.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&&Ae(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=he(h,y);if(J.risk!=="safe"){let q=d.get(J.projectPath);if(q)try{await It(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 Ht(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 zt(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 Fe(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 ye(n.projects):void 0,g={contract:ce(),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})),summary:{totalProjects:n.projects.length,totalIssues:n.projects.reduce((p,h)=>p+h.issues.length,0),projectAdvisoryWarningProjects:ge(n.projects),projectAdvisoryWarnings:ke(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=>De(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=ge(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 Fe(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 St(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 Dt(o),d=n.workspacePath?$e(n.workspacePath):null,u=$e(n.project.path);if(e.json){let x=e.plan?await ye([n.project]):void 0,T={contract:ce(),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},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??[],...x?{remediationPlan:x}:{}};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):`)),De(n.project);let h=[n.python,n.rapidkitCore].some(x=>x.status==="error"),v=n.project.issues.length,y=Y(n.project);if(h||v>0||y>0){let x=y>0?` and ${y} advisory warning(s)`:"";console.log(c.bold.yellow(`
|
|
42
|
+
\u26A0\uFE0F Found ${v} project issue(s)${x}`)),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 we(),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{zt as runDoctor};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {c,b as b$1,d as d$1,e,f,a}from'./chunk-U7XJZHU6.js';import {b}from'./chunk-
|
|
1
|
+
import {c,b as b$1,d as d$1,e,f,a}from'./chunk-U7XJZHU6.js';import {b}from'./chunk-AC6KIKII.js';import {promises}from'fs';import d from'path';import o from'chalk';import S from'ora';import {execa}from'execa';function _(e){return `package main
|
|
2
2
|
|
|
3
3
|
import (
|
|
4
4
|
"fmt"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {c,b as b$2,d as d$1,e,f,a}from'./chunk-U7XJZHU6.js';import {b as b$1}from'./chunk-
|
|
1
|
+
import {c,b as b$2,d as d$1,e,f,a}from'./chunk-U7XJZHU6.js';import {b as b$1}from'./chunk-AC6KIKII.js';import {promises}from'fs';import d from'path';import o from'chalk';import _ from'ora';import {execa}from'execa';function T(e){return `package main
|
|
2
2
|
|
|
3
3
|
import (
|
|
4
4
|
"context"
|