rapidkit 0.37.1 → 0.39.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 +185 -118
- package/contracts/create-planner-capabilities.v1.json +251 -0
- package/contracts/runtime-command-surface.v1.json +85 -0
- package/contracts/workspace-intelligence/workspace-dependency-graph.v1.json +92 -0
- package/contracts/workspace-intelligence/workspace-impact.v1.json +32 -2
- package/contracts/workspace-intelligence/workspace-model.v1.json +5 -0
- package/contracts/workspace-intelligence/workspace-verify.v1.json +103 -1
- package/dist/analyze-RHQM4AB2.js +1 -0
- package/dist/autopilot-release-FWKOY2BD.js +1 -0
- package/dist/chunk-3YLMCP3V.js +1 -0
- package/dist/chunk-4FJQWL7P.js +4 -0
- package/dist/chunk-4Q2ZZKGB.js +1 -0
- package/dist/chunk-6G2KSHP6.js +2 -0
- package/dist/{chunk-PPQYTYQG.js → chunk-6KD5F6LX.js} +4 -4
- package/dist/{chunk-IOIWVHRO.js → chunk-ERCD6NFF.js} +22 -22
- package/dist/chunk-G76C74EV.js +1 -0
- package/dist/chunk-GOM3RFB3.js +2 -0
- package/dist/{chunk-7RBZGQ7T.js → chunk-GYNIVEYP.js} +1 -1
- package/dist/chunk-HTYMXMQM.js +1 -0
- package/dist/chunk-KYH364KQ.js +1 -0
- package/dist/chunk-OWNGSAO3.js +2 -0
- package/dist/chunk-PYCJWW4B.js +1 -0
- package/dist/chunk-QPEBI6AB.js +2 -0
- package/dist/{chunk-RUUDLAKJ.js → chunk-RXWM5DSC.js} +2 -2
- package/dist/chunk-S5KTATOU.js +1 -0
- package/dist/chunk-TYZPPUBH.js +1 -0
- package/dist/chunk-UY4KRFNL.js +2 -0
- package/dist/chunk-VQMZC5TC.js +9 -0
- package/dist/{chunk-JBDQADHY.js → chunk-WHCON2VN.js} +11 -11
- package/dist/chunk-X7PWDIQW.js +1 -0
- package/dist/chunk-ZWKLRZE5.js +13 -0
- package/dist/{create-HN5HOGQ4.js → create-XVDDQA42.js} +1 -1
- package/dist/{demo-kit-3VTLJBP7.js → demo-kit-RWGOEDW4.js} +1 -1
- package/dist/{doctor-QC662YLH.js → doctor-UOLOGJ2Z.js} +1 -1
- package/dist/{dotnet-webapi-clean-FX533F5U.js → dotnet-webapi-clean-RTBRPDPL.js} +1 -1
- package/dist/{gofiber-standard-35CJZ7S3.js → gofiber-standard-UGIRKPKL.js} +1 -1
- package/dist/{gogin-standard-SAX6C4ZK.js → gogin-standard-HJ7SPFNT.js} +1 -1
- package/dist/index.d.ts +32 -1
- package/dist/index.js +134 -128
- package/dist/pipeline-O5ANBQMK.js +5 -0
- package/dist/{springboot-standard-SFMSLTX4.js → springboot-standard-IWJSVDLZ.js} +1 -1
- package/dist/{workspace-2AL5C3QZ.js → workspace-L4ITCKMM.js} +1 -1
- package/dist/{workspace-agent-sync-4R7S3F6T.js → workspace-agent-sync-SALW6TVR.js} +1 -1
- package/dist/{workspace-context-CKACDTVE.js → workspace-context-NMMQMHNU.js} +1 -1
- package/dist/{workspace-foundation-L6ZBGMVE.js → workspace-foundation-HNIRAIBF.js} +1 -1
- package/dist/workspace-graph-ICB7OVAZ.js +3 -0
- package/dist/workspace-history-LHUTLE3S.js +1 -0
- package/dist/{workspace-intelligence-3TWXJQ7Y.js → workspace-intelligence-64IWAYHS.js} +1 -1
- package/dist/workspace-model-SDHH5RBC.js +1 -0
- package/dist/workspace-run-EP7XGEM6.js +1 -0
- package/dist/workspace-verify-6Q6MGRG6.js +1 -0
- package/dist/workspace-watch-JDXVGW4H.js +1 -0
- package/docs/README.md +1 -0
- package/docs/contracts/ARTIFACT_CATALOG.md +211 -56
- package/docs/contracts/CLI_LOG_EVENT_STREAM.md +123 -0
- package/docs/contracts/README.md +15 -14
- package/docs/create-planner-capabilities.md +81 -0
- package/package.json +8 -5
- package/dist/analyze-6RFG7C7Z.js +0 -1
- package/dist/autopilot-release-QNZ2IL7K.js +0 -1
- package/dist/chunk-3SWQKRXH.js +0 -2
- package/dist/chunk-6P5DCHBQ.js +0 -4
- package/dist/chunk-B2KOIORF.js +0 -1
- package/dist/chunk-C7OVQQXT.js +0 -1
- package/dist/chunk-C7WILE56.js +0 -1
- package/dist/chunk-HEG6DIGW.js +0 -2
- package/dist/chunk-RELR4O5E.js +0 -2
- package/dist/chunk-T5LN7EO5.js +0 -9
- package/dist/chunk-TRXYRHD7.js +0 -2
- package/dist/chunk-U6QUN6V2.js +0 -2
- package/dist/chunk-UXKB4KGZ.js +0 -13
- package/dist/chunk-YJ24EV3P.js +0 -1
- package/dist/pipeline-IMB3C3JY.js +0 -5
- package/dist/workspace-model-NQVZN5W4.js +0 -1
- package/dist/workspace-run-PNMZJNDC.js +0 -1
- package/dist/workspace-verify-EO435PS4.js +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {a,b as b$1,d}from'./chunk-FV5A3N3I.js';import {d as d$1}from'./chunk-S5KTATOU.js';import {n,q as q$1,g}from'./chunk-YBS2HGO3.js';import {h,i,f,e}from'./chunk-UZW5QFRW.js';import {a as a$1}from'./chunk-VKLL63TL.js';import M from'fs';import b from'path';import v from'chalk';import {execa}from'execa';function pe(e){return M.existsSync(b.join(e,"bun.lock"))||M.existsSync(b.join(e,"bunfig.toml"))?"bun":M.existsSync(b.join(e,"pnpm-lock.yaml"))?"pnpm":M.existsSync(b.join(e,"yarn.lock"))?"yarn":(M.existsSync(b.join(e,"package-lock.json")),"npm")}function me(e,r,t=pe(e)){return t==="npm"?`npm run ${r}`:`${t} run ${r}`}function ge(e,r=pe(e)){return `${r} install`}var Ae={"python-fastapi":{runtime:"python",framework:"FastAPI",markers:["pyproject.toml","fastapi"],commands:{init:"python -m pip install -e .",test:"pytest",build:"python -m build",start:"uvicorn main:app --reload"},errorPatterns:{setup:["ModuleNotFoundError","No module named","pip: command not found"],"test-failure":["FAILED","ERROR","test session started"],dependency:["ImportError","missing.*dependency"],runtime:["TypeError","AttributeError","ValueError"],timeout:["timeout","Timeout","timed out"],unknown:[]},healthCheck:{stage:"start",type:"http",value:"http://localhost:8000/docs"},validation:{command:"python -m pip list | grep fastapi",error:"FastAPI not installed"}},"python-django":{runtime:"python",framework:"Django",markers:["manage.py","django"],commands:{init:"python manage.py migrate",test:"python manage.py test",build:"python manage.py collectstatic --noinput",start:"python manage.py runserver 0.0.0.0:8000"},errorPatterns:{setup:["ModuleNotFoundError","ProgrammingError.*migrate"],"test-failure":["FAILED","ERROR","Ran.*test"],dependency:["ImportError","missing.*dependency"],runtime:["DatabaseError","ImproperlyConfigured"],timeout:["timeout","Timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:8e3},dependencies:["init"]},"node-nestjs":{runtime:"node",framework:"NestJS",markers:["package.json","@nestjs/core"],commands:{init:"npm install",test:"npm run test",build:"npm run build",start:"npm run start"},errorPatterns:{setup:["npm ERR!","ENOENT","not found"],"test-failure":["Tests.*failed","FAIL","fail.*test"],dependency:["Cannot find module","ERR_MODULE_NOT_FOUND"],runtime:["TypeError","Error: ","ReferenceError"],timeout:["timeout","TIMEOUT"],unknown:[]},healthCheck:{stage:"start",type:"port",value:3e3}},"node-express":{runtime:"node",framework:"Express",markers:["package.json","express"],commands:{init:"npm install",test:"npm run test",build:"npm run build",start:"npm start"},errorPatterns:{setup:["npm ERR!","ENOENT"],"test-failure":["failed","FAIL"],dependency:["Cannot find module"],runtime:["Error","TypeError"],timeout:["timeout"],unknown:[]}},"go-fiber":{runtime:"go",framework:"Fiber",markers:["go.mod","fiber"],commands:{init:"go mod download && go mod tidy",test:"go test ./...",build:"go build -o app .",start:"./app"},errorPatterns:{setup:["go: .*not found","cannot find","go mod tidy"],"test-failure":["FAIL","--- FAIL"],dependency:["missing.*module"],runtime:["panic","fatal","Error"],timeout:["timeout","context deadline"],unknown:[]},dependencies:["init"]},"go-gin":{runtime:"go",framework:"Gin",markers:["go.mod","gin-gonic"],commands:{init:"go mod download && go mod tidy",test:"go test ./...",build:"go build -o app .",start:"./app"},errorPatterns:{setup:["go: .*not found"],"test-failure":["FAIL"],dependency:["missing.*module"],runtime:["panic"],timeout:["timeout"],unknown:[]}},"java-springboot":{runtime:"java",framework:"Spring Boot",markers:["pom.xml","build.gradle","spring-boot"],commands:{init:"mvn dependency:go-offline",test:"mvn test",build:"mvn package -DskipTests",start:"mvn spring-boot:run"},errorPatterns:{setup:["\\[ERROR\\]","BUILD FAILURE","missing dependencies"],"test-failure":["\\[ERROR\\] Tests run:","BUILD FAILURE"],dependency:["missing.*dependency"],runtime:["Exception","Error","NullPointerException"],timeout:["timeout","Timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:8080}},"php-laravel":{runtime:"php",framework:"Laravel",markers:["composer.json","artisan","app/Models"],commands:{init:"composer install && php artisan migrate:fresh --seed",test:"php artisan test",build:"php artisan config:cache && php artisan route:cache && php artisan view:cache",start:"php artisan serve --host=0.0.0.0 --port=8000"},errorPatterns:{setup:["Composer.*lock","Fatal error","Class.*not found"],"test-failure":["FAILED","Tests.*failed"],dependency:["Class.*not found","require.*failed"],runtime:["Fatal error","Exception","Error"],timeout:["timeout","Timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:8e3},dependencies:["init"]},"php-symfony":{runtime:"php",framework:"Symfony",markers:["composer.json","symfony.lock","bin/console"],commands:{init:"composer install && php bin/console doctrine:database:create",test:"php bin/phpunit",build:"php bin/console cache:clear --env=prod",start:"symfony serve --no-tls"},errorPatterns:{setup:["Composer.*error","Fatal error"],"test-failure":["FAILED","failure"],dependency:["Class.*not found"],runtime:["Fatal error","Exception"],timeout:["timeout"],unknown:[]},dependencies:["init"]},"rust-actix":{runtime:"rust",framework:"Actix-web",markers:["Cargo.toml","actix"],commands:{init:"cargo fetch",test:"cargo test",build:"cargo build --release",start:"cargo run --release"},errorPatterns:{setup:["error: .*could not find","failed.*download"],"test-failure":["test result:","FAILED"],dependency:["can.t find.*crate"],runtime:["error\\[E","thread.*panicked"],timeout:["timeout"],unknown:[]},validation:{command:"cargo --version",error:"Rust/Cargo not installed"}},"rust-axum":{runtime:"rust",framework:"Axum",markers:["Cargo.toml","axum"],commands:{init:"cargo fetch",test:"cargo test",build:"cargo build --release",start:"cargo run --release"},errorPatterns:{setup:["error: .*could not find"],"test-failure":["test result:","FAILED"],dependency:["can.t find.*crate"],runtime:["error\\[E"],timeout:["timeout"],unknown:[]}},"rust-rocket":{runtime:"rust",framework:"Rocket",markers:["Cargo.toml","rocket"],commands:{init:"cargo fetch",test:"cargo test",build:"cargo build --release",start:"cargo run --release"},errorPatterns:{setup:["error: .*could not find"],"test-failure":["FAILED"],dependency:["can.t find"],runtime:["error\\[E"],timeout:["timeout"],unknown:[]}},"dotnet-aspnetcore":{runtime:"dotnet",framework:"ASP.NET Core",markers:[".csproj",".sln","Program.cs"],commands:{init:"dotnet restore",test:"dotnet test",build:"dotnet build -c Release",start:"dotnet run"},errorPatterns:{setup:["error CS","CSPROJ.*not found","NuGet.*restore"],"test-failure":["Failed:.*test","FAILED"],dependency:["error NU1101"],runtime:["error CS","Exception"],timeout:["timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:5e3}},"elixir-phoenix":{runtime:"elixir",framework:"Phoenix",markers:["mix.exs","phoenix"],commands:{init:"mix setup",test:"mix test",build:"mix compile --all-warnings",start:"mix phx.server"},errorPatterns:{setup:["\\*\\* \\(.*Error\\)","Mix.InstallError"],"test-failure":["\\d+\\sfailed","FAILED"],dependency:["dependencies are not available"],runtime:["\\*\\* \\(","RuntimeError"],timeout:["timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:4e3},dependencies:["init"]},"ruby-rails":{runtime:"ruby",framework:"Rails",markers:["Gemfile","config/application.rb","bin/rails"],commands:{init:"bundle install && rails db:prepare",test:"rails test",build:"rails assets:precompile",start:"rails server --binding=0.0.0.0 --port=3000"},errorPatterns:{setup:["Bundler::.*Error","Gem::.*Error"],"test-failure":["failures,","error,","FAILED"],dependency:["Could not find.*gem"],runtime:["Error","Exception","NoMethodError"],timeout:["timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:3e3},dependencies:["init"]},"ruby-sinatra":{runtime:"ruby",framework:"Sinatra",markers:["Gemfile","app.rb","sinatra"],commands:{init:"bundle install",test:"rspec",build:`echo "Sinatra apps don't require build"`,start:"ruby app.rb"},errorPatterns:{setup:["Bundler.*Error","Gem.*Error"],"test-failure":["failure","FAILED"],dependency:["Could not find.*gem"],runtime:["Error","NoMethodError"],timeout:["timeout"],unknown:[]}}},Te={init:{python:["pip install -e .","poetry install","pip install -r requirements.txt"],node:["npm install","pnpm install","yarn install"],go:["go mod download && go mod tidy","go get ./..."],java:["mvn dependency:go-offline","gradle dependencies"],php:["composer install"],rust:["cargo fetch"],dotnet:["dotnet restore"],elixir:["mix deps.get"],ruby:["bundle install"],"jvm-generic":["mvn dependency:go-offline","gradle dependencies"],unknown:[]},test:{python:["pytest","python -m unittest","python -m pytest"],node:["npm test","npm run test"],go:["go test ./...","make test"],java:["mvn test","gradle test"],php:["php artisan test","phpunit","pest"],rust:["cargo test"],dotnet:["dotnet test"],elixir:["mix test"],ruby:["rspec","ruby -m minitest"],"jvm-generic":["mvn test","gradle test"],unknown:[]},build:{python:["python -m build","python setup.py build"],node:["npm run build"],go:["go build -o app .","go build ./..."],java:["mvn package -DskipTests","gradle build -x test"],php:['echo "PHP build: typically no build step"'],rust:["cargo build --release"],dotnet:["dotnet build -c Release"],elixir:["mix compile"],ruby:["gem build *.gemspec"],"jvm-generic":["mvn package -DskipTests","gradle build"],unknown:[]},start:{python:["python app.py","python main.py","uvicorn main:app --reload"],node:["npm start","node index.js","node src/index.js"],go:["./app","go run main.go","go run ./..."],java:["mvn spring-boot:run","gradle bootRun","java -jar target/*.jar"],php:["php -S 0.0.0.0:8000","php artisan serve"],rust:["cargo run --release","./target/release/app"],dotnet:["dotnet run"],elixir:["mix phx.server","iex -S mix"],ruby:["rails server","ruby app.rb","bundle exec puma"],"jvm-generic":["java -jar *.jar","gradle run"],unknown:[]}};function fe(e$1,r,t){if(r){let o=r.trim().toLowerCase().replace(/[_.\s]+/g,"-"),a=e(r),m=`${e$1}-${a==="gofiber"?"fiber":a==="gogin"?"gin":a==="dotnet"?"aspnetcore":a!=="unknown"?a:o==="fiber"?"fiber":o==="aspnetcore"||o==="asp-net-core"?"aspnetcore":o}`,g=Ae[m];if(g&&g.commands[t])return g.commands[t]}let n=Te[t]?.[e$1]??[];return n.length>0?n[0]:void 0}var Ne={test:"test",build:"build",start:"start"};function J(e){if(e.stage==="init")return e.runtime==="node"?ge(e.projectPath):fe(e.runtime,e.framework,e.stage);if(e.runtime==="node"){let r=Ne[e.stage];if(r){let t=g(e.projectPath,r,{framework:e.framework});if(t)return me(e.projectPath,t.scriptName)}}return fe(e.runtime,e.framework,e.stage)}function Ie(e){let r=h(e).map(t=>t==="python"?"python":t==="node"||t==="bun"?"node":t==="go"?"go":t==="java"?"java":t==="php"?"php":t==="rust"?"rust":t==="dotnet"?"dotnet":t==="elixir"?"elixir":t==="ruby"?"ruby":t==="clojure"||t==="scala"||t==="kotlin"?"jvm-generic":null).filter(t=>t!==null).filter((t,n,o)=>o.indexOf(t)===n);return {primary:r.length>0?r[0]:"unknown",secondary:r.slice(1)}}function ye(e){return Ie(e).primary}function he(e,r){if(!e)return "unknown";r||(r={setup:["ModuleNotFoundError","npm ERR!","error:","not found"],"test-failure":["FAILED","FAIL","failed"],dependency:["cannot find module","import.*error"],runtime:["Exception","Error:","panic","TypeError"],timeout:["timeout","Timeout","deadline exceeded"],unknown:[]});for(let[t,n]of Object.entries(r))for(let o of n)if(new RegExp(o,"i").test(e))return t;return "unknown"}async function G(e){let r=e.split(/[&|;]\s*/)[0].trim().split(/\s+/)[0];if(["echo","cd","pwd","test","true","false","exit"].includes(r))return {valid:true};try{let n=process.platform==="win32"?"where":"which";if((await execa(n,[r],{reject:false})).exitCode===0)return {valid:true}}catch{}return {valid:false,reason:`Command '${r}' not found or not executable`}}function ke(e,r,t){if(!r)return e;let n=typeof r=="object"&&!Array.isArray(r)&&("dev"in r||"staging"in r||"prod"in r||"default"in r)&&!Object.keys(r).some(o=>["init","test","build","start"].includes(o))?r:{};return t&&typeof n[t]=="string"?n[t]:typeof n.default=="string"?n.default:e}var we={init:"init",test:"test",build:"build",start:"start"};function We(e){return e in we?we[e]:null}function be(e,r,t=q$1(e)){let n=We(r);if(!n)return {supported:false,reason:`Workspace stage "${r}" is not part of the RapidKit fleet contract.`};if(!t.projectRoot)return {supported:false,reason:"No RapidKit project metadata was detected for this target."};let o=t.commandMap[n];return !o||o.status!=="supported"?{supported:false,reason:o?.reason??`Command "${n}" is not supported for this project runtime/framework.`}:{supported:true}}var $e=new Set(["init","test","build","start"]),De=new Set([".git","node_modules",".rapidkit",".venv","dist","build","coverage","htmlcov"]);async function T(e){try{return await M.promises.access(e,M.constants.F_OK),true}catch{return false}}async function Me(e,r,t){if(r==="python"){let n=b.join(e,".rapidkit","cli.py");return await T(n)?{valid:true}:{valid:false,reason:"Project-local .rapidkit/cli.py is missing. Run `rapidkit init` in this project first."}}return G(t)}async function Q(e){let r=await M.promises.readFile(e,"utf-8");return JSON.parse(r)}function P(e){return e.replace(/\\/g,"/")}function Oe(e){let r=e?.trim();return r?r.startsWith("project:")?r.slice(8).trim()||null:r:null}async function Le(e){return a$1(e,{skipDirs:De,includeHiddenDirs:false,descendIntoMatchedProjects:false,isProjectDir:async(r,t)=>await T(b.join(r,".rapidkit","context.json"))||await T(b.join(r,".rapidkit","project.json"))?true:b.resolve(r)===b.resolve(t)?false:h(r).length>0})}async function _e(e){for(let r of [b.join(".rapidkit","project.json"),b.join(".rapidkit","context.json")]){let t=b.join(e,r);if(await T(t))try{let n=await Q(t),o=n.name??n.projectName??n.slug;if(typeof o=="string"&&o.trim())return o.trim()}catch{}}return null}async function Ge(e,r,t){let n=Oe(t);if(!n)return {projects:r,normalizedScope:null};let o=P(n).toLowerCase(),a=[];for(let u of r){let m=P(b.relative(e,u)),g=b.basename(u),y=await _e(u);[m,g,y].filter(s=>typeof s=="string"&&s.length>0).map(s=>P(s).toLowerCase()).includes(o)&&a.push(u);}if(a.length===0)throw new Error(`Workspace run scope did not match any project: ${t}`);return {projects:a,normalizedScope:n}}async function Be(e,r,t){let n=await execa("git",["diff","--name-only",`${t}...HEAD`],{cwd:e,reject:false});if(n.exitCode!==0)return new Set(r);let o=n.stdout.split(/\r?\n/).map(u=>u.trim()).filter(u=>u.length>0).map(u=>P(u));if(o.length===0)return new Set;let a=new Set;for(let u of r){let m=P(b.relative(e,u));if(!m||m===".")continue;let g=`${m}/`;o.some(y=>y===m||y.startsWith(g))&&a.add(u);}return a}async function Ke(e,r,t){let n=b.join(e,".rapidkit","workspace.contract.json");if(await T(n))try{let p=await Ve(e,r,t,n);if(p.graphStatus!=="missing")return p}catch{return {expanded:t,graphStatus:"invalid",expansionDepth:0}}let o=b.join(e,".rapidkit","workspace-dependency-graph.json");if(!await T(o))return {expanded:t,graphStatus:"missing",expansionDepth:0};let a;try{a=await Q(o);}catch{return {expanded:t,graphStatus:"invalid",expansionDepth:0}}let u=new Set(r.map(p=>b.resolve(p))),m=new Map;if(!a||typeof a!="object"||Array.isArray(a))return {expanded:t,graphStatus:"invalid",expansionDepth:0};let g=Array.isArray(a.projects)?a.projects:[];for(let p of g){if(!p||typeof p!="object"||Array.isArray(p))continue;let s=p,d=typeof s.path=="string"?s.path:"",f=b.resolve(e,d);if(!u.has(f))continue;let k=Array.isArray(s.dependsOn)?s.dependsOn.filter(R=>typeof R=="string"):[];for(let R of k){let c=b.resolve(e,R);u.has(c)&&(m.has(c)||m.set(c,new Set),m.get(c)?.add(f));}}let y=d$1(m,t);return {expanded:y.reached,graphStatus:"loaded",expansionDepth:y.added}}async function Ve(e,r,t,n){let o=await Q(n);if(!o||typeof o!="object"||Array.isArray(o))return {expanded:t,graphStatus:"invalid",expansionDepth:0};let a=o,u=Array.isArray(a.projects)?a.projects:null;if(!u)return {expanded:t,graphStatus:"invalid",expansionDepth:0};let m=new Map,g=new Map;for(let f of r){let k=P(b.relative(e,f));g.set(k,b.resolve(f));}let y=new Map,p=new Map,s=new Map;for(let f of u){if(!f||typeof f!="object"||Array.isArray(f))continue;let k=f,R=typeof k.slug=="string"?k.slug:"",c=typeof k.relativePath=="string"?P(k.relativePath):R,h=g.get(c);!R||!h||m.set(R,h);}for(let f of u){if(!f||typeof f!="object"||Array.isArray(f))continue;let k=f,R=typeof k.slug=="string"?k.slug:"",c=m.get(R);if(!c)continue;let h=k.contracts&&typeof k.contracts=="object"&&!Array.isArray(k.contracts)?k.contracts:{},N=Array.isArray(h.dependsOn)?h.dependsOn.filter(x=>typeof x=="string"):[],W=Array.isArray(h.publishes)?h.publishes.filter(x=>typeof x=="string"):[],$=Array.isArray(h.consumes)?h.consumes.filter(x=>typeof x=="string"):[];for(let x of N){let S=m.get(x);S&&(s.has(S)||s.set(S,new Set),s.get(S)?.add(c));}for(let x of W)y.has(x)||y.set(x,new Set),y.get(x)?.add(c);for(let x of $)p.has(x)||p.set(x,new Set),p.get(x)?.add(c);}for(let[f,k]of y.entries()){let R=p.get(f);if(R)for(let c of k){s.has(c)||s.set(c,new Set);for(let h of R)h!==c&&s.get(c)?.add(h);}}let d=d$1(s,t);return {expanded:d.reached,graphStatus:"loaded",expansionDepth:d.added}}async function He(e,r){if(typeof r=="boolean")return r;let t=b.join(e,".rapidkit","policies.yml");if(!await T(t))return true;let n="";try{n=await M.promises.readFile(t,"utf-8");}catch{return true}let o=n.match(/^[\t ]*rules\.enforce_workspace_run_gates:\s*(true|false)\s*(?:#.*)?$/m);return o?o[1]==="true":true}async function q(e,r){let t=process.argv[1];if(!t)return {exitCode:1,stdout:"",stderr:"RapidKit entrypoint is unavailable for nested workspace-run execution."};let n=await execa(process.execPath,[t,...e],{cwd:r,reject:false,env:{...process.env,RAPIDKIT_WORKSPACE_RUN_CHILD:"1"}});return {exitCode:Number(n.exitCode??1),stdout:n.stdout,stderr:n.stderr}}function ze(e){return e==="node"||e==="go"||e==="java"||e==="python"||e==="dotnet"}function Ue(){return process.env.VITEST==="true"||process.env.VITEST==="1"||process.env.NODE_ENV==="test"}async function Je(e){let r=process.cwd();try{process.chdir(e);let{handleInitCommand:t}=await import('./index.js');return {exitCode:await t(["init"]),stdout:"",stderr:""}}finally{process.chdir(r);}}async function qe(e$1){let r=s=>{let d=f(s);return d==="node"||d==="bun"?"node":d==="python"?"python":d==="go"?"go":d==="java"?"java":d==="php"?"php":d==="ruby"?"ruby":d==="rust"?"rust":d==="dotnet"?"dotnet":d==="elixir"?"elixir":d==="clojure"||d==="scala"||d==="kotlin"?"jvm-generic":ye(e$1)},t=s=>{if(!s)return;let d=e(s);if(new Set(["fastapi","django","flask","nestjs","express","fastify","koa","gofiber","gogin","echo","springboot","laravel","symfony","rails","sinatra","dotnet","actix","axum","rocket","phoenix"]).has(d))return d},n$1=n(e$1),o=n$1?.detection??i(e$1,n$1?.projectJson??null),a=n$1?.contextJson,u=r(o.runtime),m=t(o.key),g={},y=new Set(["init","test","build","start"]);if(a?.commands&&typeof a.commands=="object")for(let[s,d]of Object.entries(a.commands))typeof d=="string"&&y.has(s)&&(g[s]=d);let p;if(a?.commandEnvironments&&typeof a.commandEnvironments=="object"){let s=a.commandEnvironments;p={dev:typeof s.dev=="string"?s.dev:void 0,staging:typeof s.staging=="string"?s.staging:void 0,prod:typeof s.prod=="string"?s.prod:void 0,default:typeof s.default=="string"?s.default:void 0};}return {runtime:u,framework:m,commandOverrides:Object.keys(g).length>0?g:void 0,environmentCommandVariants:p,environment:typeof a?.environment=="string"?a.environment:void 0}}async function Ye(e,r,t,n,o,a,u){let m=!o?.[r]&&ze(t),g;if(o&&o[r]?g=o[r]:m?g=`rapidkit ${r}`:g=J({projectPath:e,runtime:t,framework:n,stage:r}),!g)return {exitCode:127,command:`<stage not supported for ${t}>`,message:`No stage command found for runtime '${t}' and framework '${n||"unknown"}'`,errorCategory:"runtime"};let y=ke(g,a,u);if(!y)return {exitCode:127,command:g,message:"Failed to resolve stage command",errorCategory:"runtime"};let p=J({projectPath:e,runtime:t,framework:n,stage:r});if(m){if(p){let c=m?await Me(e,t,p):await G(p);if(!c.valid)return {exitCode:127,command:y,message:c.reason||"Command not available",errorCategory:"setup"}}}else {let c=await G(y);if(!c.valid)return {exitCode:127,command:y,message:c.reason||"Command not available",errorCategory:"setup"}}let s=0,d="",f="",k;try{let c=m?r==="init"&&Ue()?await Je(e):await q([r],e):await execa(y,[],{cwd:e,reject:false,shell:true});if(s=Number(c.exitCode??0),d=c.stdout,f=c.stderr,s!==0){let h=`${d}
|
|
2
|
+
${f}`;k=he(h);}}catch(c){return {exitCode:1,command:y,message:c instanceof Error?c.message:"Command execution failed",errorCategory:"runtime"}}return {exitCode:s,command:y,errorCategory:k,healthStatus:void 0,message:s!==0?`Stage failed with exit code ${s}`:void 0}}function xe(e){try{return JSON.parse(e)}catch{return null}}function Qe(e){switch(e){case "dotnet":return "Install .NET 8+ SDK, then rerun `npx rapidkit setup dotnet` or `npx rapidkit init`.";case "go":return "Install Go 1.21+, then rerun `npx rapidkit setup go` or `npx rapidkit init`.";case "java":case "jvm-generic":return "Install Java 21+ and Maven/Gradle, then rerun `npx rapidkit setup java` or `npx rapidkit init`.";case "node":return "Install Node.js LTS and npm/pnpm/yarn, then rerun `npx rapidkit setup node` or `npx rapidkit init`.";case "python":return "Install Python 3.10+ and pip/Poetry, then rerun `npx rapidkit setup python` or `npx rapidkit init`.";default:return null}}async function Xe(e){let r=[],t=await q(["doctor","workspace","--json"],e);if(t.exitCode!==0)r.push({gate:"doctor-workspace",status:"fail",summary:"doctor workspace command failed"});else {let a=xe(t.stdout)?.healthScore,u=Number(a?.errors??0);Number.isFinite(u)&&u>0?r.push({gate:"doctor-workspace",status:"fail",summary:`doctor workspace reports ${u} error(s)`}):r.push({gate:"doctor-workspace",status:"pass",summary:"doctor workspace passed"});}let n=await q(["readiness","--json"],e);if(n.exitCode!==0)r.push({gate:"readiness",status:"fail",summary:"readiness command failed"});else {let o=xe(n.stdout),a=String(o?.overallStatus??"").toLowerCase();a==="fail"?r.push({gate:"readiness",status:"fail",summary:"readiness overall status is fail"}):a==="warn"?r.push({gate:"readiness",status:"warn",summary:"readiness overall status is warn"}):r.push({gate:"readiness",status:"pass",summary:"readiness overall status is pass"});}return r}function Ze(e){return $e.has(e)}function et(e,r){let t=Math.max(1,Math.min(4,r)),n=Number(e??t);return Number.isFinite(n)?Math.max(1,Math.min(16,Math.trunc(n))):t}async function Ft(e){if(!Ze(e.stage))throw new Error(`Unsupported workspace run stage: ${e.stage}`);let r=Date.now(),t=b.resolve(e.workspacePath),n=await Le(t),{projects:o,normalizedScope:a$1}=await Ge(t,n,e.scope),u=e.affected===true,m=e.blastRadius===true,g=e.since?.trim()||"HEAD~1",y=u?await Be(t,o,g):new Set(o),p,s="not-applicable",d$1=0,f="all";if(u&&m){let l=await Ke(t,n,y);p=l.expanded,s=l.graphStatus,d$1=l.expansionDepth,f="affected+blast-radius";}else u?(p=y,f="affected"):(p=y,f="all");let k=e.stage==="init"?false:await He(t,e.enforceGates),R=k?await Xe(t):[{gate:"doctor-workspace",status:"skipped",summary:"workspace run gates disabled"},{gate:"readiness",status:"skipped",summary:"workspace run gates disabled"}],c=R.find(l=>l.status==="fail"),h=o.filter(l=>p.has(l)),N=e.continueOnError===true||e.stage==="init",W=e.parallel===true,$=et(e.maxWorkers,h.length),x=h.length,S=0;e.json||console.log(v.gray(`Workspace run (${e.stage}) started: ${x} target(s), ${W?`parallel x${$}`:"sequential"}`));let F=new Map;for(let l of n){let w=o.includes(l),i=w&&p.has(l);F.set(l,{path:l,relativePath:P(b.relative(t,l)),selected:i,affected:i,status:"skipped",exitCode:null,durationMs:0,reason:i?void 0:w?"not affected":"outside scope",framework:void 0,runtimeDetected:void 0,executionCommand:void 0});}if(c)for(let l of h){let w=F.get(l);w&&(w.status="skipped",w.reason=`blocked by ${c.gate}`);}else {let l=async w=>{let i=F.get(w);if(!i)return;let I=P(b.relative(t,w));e.json||console.log(v.gray(`\u23F3 [${S}/${x}] ${e.stage} ${I}`)),i.selected=true,i.affected=true;let E=Date.now(),{runtime:j,framework:C,commandOverrides:je,environmentCommandVariants:Se,environment:Ee}=await qe(w);i.runtimeDetected=j,i.framework=C;let re=be(w,e.stage);if(!re.supported){i.status="skipped",i.reason=re.reason??`stage "${e.stage}" unsupported for project`,i.durationMs=Date.now()-E,i.exitCode=null,S+=1;return}let A=await Ye(w,e.stage,j,C,je,Se,Ee);if(i.executionCommand=A.command,i.errorCategory=A.errorCategory,i.healthStatus=A.healthStatus,i.durationMs=Date.now()-E,i.exitCode=A.exitCode,A.exitCode===0?(i.status="passed",i.reason=void 0):(i.status="failed",i.reason=A.message||"stage command failed",i.errorMessage=A.message),S+=1,!e.json){let Ce=x>0?Math.round(S/x*100):100,Pe=i.status==="passed"?v.green("\u2705"):v.red("\u274C");if(console.log(v.gray(`${Pe} [${S}/${x}] (${Ce}%) ${I} ${i.durationMs}ms`)),i.status==="failed"){i.reason&&console.log(v.red(` Reason: ${i.reason}`)),i.executionCommand&&console.log(v.gray(` Command: ${i.executionCommand}`));let ne=Qe(i.runtimeDetected);ne&&i.errorCategory==="setup"&&console.log(v.gray(` Hint: ${ne}`));}}};if(W&&h.length>1){let w=0,i=false,I=new Array($).fill(null).map(async()=>{for(;w<h.length;){if(i&&!N)return;let E=w;w+=1;let j=h[E];await l(j),F.get(j)?.status==="failed"&&(i=true);}});if(await Promise.all(I),!N&&i){let E=false;for(let j of h){let C=F.get(j);if(C){if(C.status==="failed"){E=true;continue}E&&C.status==="skipped"&&(C.reason=C.reason||"stopped after failure");}}}}else for(let w of h){await l(w);let i=F.get(w);if(!N&&i?.status==="failed"){let I=h.slice(h.indexOf(w)+1);for(let E of I){let j=F.get(E);j&&(j.status="skipped",j.reason="stopped after failure");}break}}}let D=[];for(let l of n){let w=F.get(l);w&&D.push(w);}let X=D.filter(l=>l.status==="passed").length,K=D.filter(l=>l.status==="failed").length,Z=D.filter(l=>l.status==="skipped").length,ee=e.strict===true,Re=K>0||ee&&R.some(l=>l.status==="fail"||l.status==="warn")?1:0,te={schemaVersion:"1.0",workspacePath:t,stage:e.stage,generatedAt:new Date().toISOString(),durationMs:Date.now()-r,options:{affected:u,blastRadius:m,since:u?g:null,parallel:W,maxWorkers:$,continueOnError:N,strict:ee,enforceGates:k,scope:a$1},selection:{mode:f,since:u?g:null,scope:a$1,graphStatus:s,expansionDepth:d$1},gates:{enforced:k,results:R,blocked:!!c,blockingGate:c?.gate},summary:{projectCount:n.length,selectedCount:h.length,passed:X,failed:K,skipped:Z,exitCode:Re},projects:D,enterpriseControls:{jsonReady:true,evidencePath:b$1}},ve=b.join(t,".rapidkit","reports",a);return await d(t,te),e.json||(c&&(console.log(v.red(`\u274C Workspace run blocked by ${c.gate}`)),console.log(v.gray(` ${c.summary}`))),console.log(v.cyan(`Workspace run (${e.stage}) => passed: ${X}, failed: ${K}, skipped: ${Z}`)),console.log(v.gray(`Report: ${ve}`))),te}export{Ft as a};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import {a,b}from'./chunk-KMUWWZRT.js';import {f as f$1,e}from'./chunk-4Q2ZZKGB.js';import {h as h$1,i}from'./chunk-UZW5QFRW.js';import {a as a$1}from'./chunk-VKLL63TL.js';import h from'fs';import o from'path';import s from'chalk';var S=new Set([".git",".rapidkit",".venv","node_modules","dist","build","target","coverage","htmlcov",".next"]);async function y(e){try{return await h.promises.access(e,h.constants.F_OK),true}catch{return false}}async function z(e){try{let n=JSON.parse(await h.promises.readFile(e,"utf-8"));return n&&typeof n=="object"&&!Array.isArray(n)?n:null}catch{return null}}async function T(e){try{return await h.promises.readFile(e,"utf-8")}catch{return ""}}function N(e){return a(e)}async function K(e,n){return await y(o.join(e,".rapidkit","project.json"))||await y(o.join(e,".rapidkit","context.json"))?true:b(e)?false:o.resolve(e)===o.resolve(n)?h$1(e).length>0:h$1(e).length>0}async function O(e){let n=await a$1(e,{skipDirs:S,includeHiddenDirs:false,descendIntoMatchedProjects:false,isProjectDir:K});return n.length>0?n:b(e)?[]:h$1(e).length>0?[e]:[]}function _(e,n){return o.relative(e,n).replace(/\\/g,"/")||"."}async function A(e,n){for(let t of n)if(await y(o.join(e,t)))return true;return false}async function M(e){return A(e,["health","health.ts","health.js","health.py","health.go","health.kt","health.rb","health.php","healthcheck","health-check","src/health.ts","src/health.js","src/health.py","src/health.go","src/health.kt","src/health.rb","src/health.php","src/healthcheck.ts","src/healthcheck.js","src/liveness.ts","src/readiness.ts","src/ping.ts"])}async function J(e){if(await A(e,["tests","test","__tests__","src/__tests__","pytest.ini","vitest.config.ts","jest.config.ts"]))return true;let t=await z(o.join(e,"package.json")),i=t?.scripts&&typeof t.scripts=="object"?t.scripts:{};return typeof i.test=="string"&&i.test.trim().length>0}async function W(e){let n=await z(o.join(e,"package.json")),t=n?.scripts&&typeof n.scripts=="object"?n.scripts:{};return Object.keys(t).sort()}function f(e,n,t,i,r,c){return {id:e,severity:n,target:t,title:i,detail:r,remediation:c}}function H(e){let n=e.reduce((t,i)=>i.severity==="fail"?t+28:i.severity==="warn"?t+12:t+3,0);return Math.max(0,100-n)}async function B(e,n){let t=await z(o.join(n,".rapidkit","project.json")),i$1=i(n,t),r=h$1(n),c=i$1.runtime==="unknown"?r[0]||"unknown":i$1.runtime,a=_(e,n),d=a,u=await W(n),g=await y(o.join(n,".rapidkit","project.json"))||await y(o.join(n,".rapidkit","context.json")),m=await J(n),k=await A(n,["Dockerfile","dockerfile"]),w=await A(n,[".env.example","env.example","config/env.example"]),P=await A(n,[".github/workflows/ci.yml",".github/workflows/ci.yaml",".github/workflows/main.yml",".github/workflows/build.yml",".github/workflows/test.yml",".github/workflows/deploy.yml",".gitlab-ci.yml",".circleci/config.yml","azure-pipelines.yml","bitbucket-pipelines.yml","cloudbuild.yaml"]),R=await M(n),l=[];return i$1.key==="unknown"&&l.push(f("project.stack.unknown","fail",d,"Project stack is unknown","RapidKit cannot confidently classify this backend project.","Add .rapidkit/project.json metadata or import the project with `rapidkit import`.")),g||l.push(f("project.marker.missing","warn",d,"RapidKit marker is missing","The project can be detected by files, but it is not registered with RapidKit metadata.","Run `rapidkit import <path>` from a workspace or create the project through RapidKit.")),m||l.push(f("project.tests.missing","warn",d,"Test entrypoint is missing","No common test folder, config, or package test script was found.","Add a test command so `rapidkit workspace run test --affected` can gate changes.")),w||l.push(f("project.env.example.missing","info",d,"Environment example is missing","No .env.example or env.example file was found.","Add an env example for onboarding and CI secret documentation.")),P||l.push(f("project.ci.missing","warn",d,"Continuous integration is missing","No recognized CI/CD configuration file was detected for this project.","Add CI configuration so tests and checks run automatically for every change.")),R||l.push(f("project.health.missing","info",d,"Health or readiness probe is missing","The project has no obvious health or readiness endpoint to support automated deployment and runtime checks.","Add a simple health endpoint and document it for readiness gates and observability.")),k||l.push(f("project.container.missing","info",d,"Container recipe is missing","No Dockerfile was found for this project.","Add a Dockerfile when the service is intended for containerized deployment.")),{name:o.basename(n),path:n,relativePath:a,runtime:c,framework:i$1.key,confidence:i$1.confidence,supportTier:i$1.supportTier,hasRapidKitMarker:g,hasTests:m,hasDockerfile:k,hasEnvExample:w,hasCiConfig:P,hasHealthEndpoint:R,scripts:u,findings:l,score:H(l)}}function U(e){return e.name.toLowerCase()}async function V(e){let n=new Map(e.map(r=>[U(r),r])),t=[];for(let r of e){let c=await z(o.join(r.path,"package.json")),a={...c?.dependencies??{},...c?.devDependencies??{},...c?.peerDependencies??{}};for(let u of Object.keys(a)){let g=u.replace(/^@[^/]+\//,"").toLowerCase(),m=n.get(g);m&&m.relativePath!==r.relativePath&&t.push({from:r.relativePath,to:m.relativePath,kind:"package"});}let d=await T(o.join(r.path,"pyproject.toml"));for(let u of e)u.relativePath!==r.relativePath&&d.includes(u.name)&&t.push({from:r.relativePath,to:u.relativePath,kind:"workspace-reference"});}let i=new Set;return t.filter(r=>{let c=`${r.from}\0${r.to}\0${r.kind}`;return i.has(c)?false:(i.add(c),true)})}function L(e,n){let t=new Map;for(let i of e)t.set(i.relativePath,{project:i.relativePath,directDependents:0,directDependencies:0});for(let i of n){let r=t.get(i.from),c=t.get(i.to);r&&(r.directDependencies+=1),c&&(c.directDependents+=1);}return Array.from(t.values()).sort((i,r)=>r.directDependents-i.directDependents||r.directDependencies-i.directDependencies)}async function q(e){let n=await z(o.join(e,".rapidkit","workspace.json"));return typeof n?.profile=="string"?n.profile:null}function Q(e){return {fail:e.filter(n=>n.severity==="fail").length,warn:e.filter(n=>n.severity==="warn").length,info:e.filter(n=>n.severity==="info").length}}function X(e){if(e.projectCount===0)return e.workspaceDetected?["Add your first project: npx rapidkit create project <name> --kit <kit>","Import an existing service: npx rapidkit import <path>"]:["Create a RapidKit workspace: npx rapidkit create workspace my-workspace --profile polyglot","Import an existing service: npx rapidkit import ../service"];let n=[];return e.findings.some(t=>t.id==="workspace.marker.missing")&&n.push("Initialize workspace metadata with `rapidkit bootstrap --profile polyglot`."),e.findings.some(t=>t.id==="project.marker.missing")&&n.push("Register detected projects with `rapidkit import <path>` or recreate them via `rapidkit create project`."),e.findings.some(t=>t.id==="project.tests.missing")&&n.push("Add test entrypoints, then gate changes with `rapidkit workspace run test --affected --strict`."),e.findings.some(t=>t.id==="project.ci.missing")&&n.push("Add CI/CD configuration to catch regressions early and make workspace health checks actionable."),e.findings.some(t=>t.id==="project.health.missing")&&n.push("Add a health/readiness endpoint so runtime probes and deployment checks can verify service health."),e.hasGraph||n.push("Create `.rapidkit/workspace-dependency-graph.json` or use analyze output as the first graph seed."),n.push("Run `rapidkit autopilot release --mode audit --json` before release."),Array.from(new Set(n))}async function ae(e$1={}){let n=o.resolve(e$1.workspacePath||process.cwd());if(!await y(n))throw new Error(`Workspace path does not exist: ${n}`);let t=N(n)??n,i=await y(o.join(t,".rapidkit-workspace"))||await y(o.join(t,".rapidkit","workspace.json")),r=await q(t),c=await O(t),a=await Promise.all(c.map(p=>B(t,p))),d=await V(a),u=L(a,d),g=[];i||g.push(f("workspace.marker.missing","warn",".","Workspace metadata is missing","The directory can be analyzed, but it is not a registered RapidKit workspace.","Run `rapidkit create workspace` or `rapidkit bootstrap --profile polyglot` in a workspace root.")),a.length===0&&g.push(f("workspace.projects.missing","warn",".","No backend projects detected","RapidKit did not find runtime markers or project metadata under this root.","Create a project with `rapidkit create project` or import one with `rapidkit import <path>`."));let m=[...g,...a.flatMap(p=>p.findings)],k=Q(m),w={};for(let p of a)w[p.runtime]=(w[p.runtime]||0)+1;let P=a.length>0?Math.round(a.reduce((p,v)=>p+v.score,0)/a.length):0,R=g.reduce((p,v)=>p+(v.severity==="fail"?20:v.severity==="warn"?8:2),0),l=Math.max(0,P-R),E=k.fail>0||e$1.strict&&k.warn>0?"blocked":k.warn>0?"needs-attention":"ready",j={schemaVersion:"rapidkit-analyze-v1",generatedAt:new Date().toISOString(),workspacePath:t,workspaceDetected:i,profile:r,summary:{score:l,verdict:E,projectCount:a.length,runtimeCount:Object.keys(w).length,findings:k},runtimes:w,projects:a,dependencyGraph:{status:d.length>0?"generated":"empty",edges:d,topImpactedProjects:u.slice(0,5)},findings:m,nextActions:X({findings:m,projectCount:a.length,hasGraph:d.length>0,workspaceDetected:i}),enterpriseControls:{jsonReady:true,ciGateCommand:"rapidkit analyze --json --strict",releaseGateCommand:"rapidkit autopilot release --mode enforce --json",evidencePath:".rapidkit/reports/analyze-last-run.json"}};if(e$1.output&&(await h.promises.mkdir(o.dirname(o.resolve(e$1.output)),{recursive:true}),await h.promises.writeFile(o.resolve(e$1.output),`${JSON.stringify(j,null,2)}
|
|
2
|
+
`)),!e$1.output&&i){let p=o.join(t,".rapidkit","reports","analyze-last-run.json");await h.promises.mkdir(o.dirname(p),{recursive:true});let v=f$1(j,{commandId:"workspaceAnalyze",exitCode:j.summary.verdict==="blocked"?2:j.summary.verdict==="needs-attention"?1:0,generatedAt:j.generatedAt,blockers:j.findings.filter(x=>x.severity==="fail").map(x=>x.title).slice(0,12),runId:e()});await h.promises.writeFile(p,`${JSON.stringify(v,null,2)}
|
|
3
|
+
`);}return j}function ce(e){let n=e.summary.verdict==="ready"?s.green:e.summary.verdict==="needs-attention"?s.yellow:s.red;if(console.log(s.bold(`
|
|
4
|
+
RapidKit Workspace Analysis
|
|
5
|
+
`)),console.log(s.cyan("Workspace:"),e.workspacePath),console.log(s.cyan("Profile:"),e.profile||"not configured"),console.log(s.cyan("Score:"),`${e.summary.score}/100`),console.log(s.cyan("Verdict:"),n(e.summary.verdict)),console.log(s.gray(`Projects: ${e.summary.projectCount}, runtimes: ${e.summary.runtimeCount}, findings: ${e.summary.findings.fail} fail / ${e.summary.findings.warn} warn / ${e.summary.findings.info} info`)),e.projects.length>0){console.log(s.bold(`
|
|
6
|
+
Projects`));for(let t of e.projects){let i=t.score>=85?s.green("pass"):t.score>=65?s.yellow("watch"):s.red("risk");console.log(` ${t.relativePath} ${s.gray(`${t.runtime}/${t.framework}`)} ${i} ${t.score}/100`);}}if(e.dependencyGraph.status==="generated"&&(console.log(s.bold(`
|
|
7
|
+
Dependency Graph`)),console.log(s.gray(` edges: ${e.dependencyGraph.edges.length}`)),e.dependencyGraph.topImpactedProjects.length>0)){console.log(s.gray(" Top impacted projects:"));for(let t of e.dependencyGraph.topImpactedProjects.slice(0,3))console.log(` ${t.project} (${t.directDependents} dependents, ${t.directDependencies} dependencies)`);}if(e.findings.length>0){console.log(s.bold(`
|
|
8
|
+
Top Findings`));for(let t of e.findings.slice(0,8)){let i=t.severity==="fail"?s.red:t.severity==="warn"?s.yellow:s.gray;console.log(` ${i(t.severity.toUpperCase())} ${t.target}: ${t.title}`),console.log(s.gray(` ${t.remediation}`));}}console.log(s.bold(`
|
|
9
|
+
Next Actions`));for(let t of e.nextActions.slice(0,5))console.log(s.gray(` - ${t}`));console.log();}export{ae as a,ce as b};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {b}from'./chunk-C7WILE56.js';import {c,a as a$2,b as b$2}from'./chunk-NFUXULIF.js';import {q as q$1}from'./chunk-YBS2HGO3.js';import {e as e$1,d as d$1}from'./chunk-B2KOIORF.js';import {i,d,b as b$3,a as a$5}from'./chunk-UZW5QFRW.js';import {e}from'./chunk-RELR4O5E.js';import {b as b$1,f,d as d$2,a as a$4,k,g,i as i$1}from'./chunk-Z5LKRG57.js';import {a as a$3}from'./chunk-2FIX2MDC.js';import {a as a$1}from'./chunk-HHJAANUC.js';import l from'chalk';import {execa}from'execa';import r from'fs-extra';import a from'path';var bt=[".eslintrc.js",".eslintrc.cjs",".eslintrc.json",".eslintrc.yaml",".eslintrc.yml","eslint.config.js","eslint.config.mjs","eslint.config.cjs"],xt=["tests","test","src/test","__tests__","e2e","playwright","cypress"],jt=["vitest.config.ts","vitest.config.js","vitest.config.mjs","jest.config.js","jest.config.ts","jest.config.mjs","playwright.config.ts","playwright.config.js","cypress.config.js","cypress.config.ts"],Ct=["src","app","pages"],Et=["dev","build","test","lint"];function Oe(e){let n=e?.scripts;if(!n||typeof n!="object"||Array.isArray(n))return {};let i={};for(let[t,c]of Object.entries(n))typeof c=="string"&&c.trim().length>0&&(i[t]=c);return i}async function Le(e,n){for(let c of bt)if(await r.pathExists(a.join(e,c)))return true;let i=n??(await r.pathExists(a.join(e,"package.json"))?await r.readJson(a.join(e,"package.json")):null);if(!i)return false;if(i.eslintConfig)return true;let t={...i.dependencies??{},...i.devDependencies??{}};return !!(t.eslint||t["@eslint/js"]||t["@eslint/eslintrc"])}async function Ve(e,n){for(let c of xt)if(await r.pathExists(a.join(e,c)))return true;for(let c of jt)if(await r.pathExists(a.join(e,c)))return true;let i=Oe(n);if(i.test||i["test:unit"]||i["test:e2e"]||i["test:ci"]||i["test:watch"])return true;let t={...n?.dependencies??{},...n?.devDependencies??{}};return t.vitest||t.jest||t["@playwright/test"]||t.cypress?true:await Pt(e)}async function Pt(e){let n=["src","app","pages","components"],i=/\.(test|spec)\.(tsx?|jsx?|vue|svelte)$/i,c=new Set(["node_modules",".git","dist","build",".next","coverage",".turbo"]);for(let o of n){let s=a.join(e,o);if(!await r.pathExists(s))continue;let d=[{dir:s,depth:0}];for(;d.length>0;){let u=d.shift();if(!u)break;let p=[];try{p=await r.readdir(u.dir);}catch{continue}for(let f of p){let m=a.join(u.dir,f);if(i.test(f))return true;if(!(u.depth>=3||c.has(f)||f.startsWith(".")))try{(await r.stat(m)).isDirectory()&&d.push({dir:m,depth:u.depth+1});}catch{continue}}}}return false}async function je(e){for(let n of Ct){let i=a.join(e,n);if(await r.pathExists(i))try{if((await r.readdir(i)).some(c=>!c.startsWith(".")))return true}catch{continue}}return false}function St(e){let n=e.key;return b$3(n).key}function $t(e,n,i){return a$5(n,i).some(c=>!!e[c])}async function Je(e){let{projectPath:n,detection:i,packageJsonData:t}=e,c=St(i),o=b$3(c),s=Oe(t),d=[],u=await r.pathExists(a.join(n,"package-lock.json"))||await r.pathExists(a.join(n,"pnpm-lock.yaml"))||await r.pathExists(a.join(n,"yarn.lock"))||await r.pathExists(a.join(n,"bun.lockb"));d.push({id:"frontend-lockfile-integrity",label:"Frontend lockfile integrity",status:u?"pass":"warn",severity:"warn",scope:"project-scoped",reason:u?"Node lockfile detected for deterministic dependency restore.":"No Node lockfile detected (package-lock/yarn.lock/pnpm-lock.yaml/bun.lockb).",recommendation:u?void 0:"Commit a lockfile for deterministic installs and CI parity."});let p=await r.pathExists(a.join(n,"tsconfig.json")),f=await r.pathExists(a.join(n,"jsconfig.json")),m=p||f;d.push({id:"frontend-typescript-surface",label:"TypeScript project surface",status:m?"pass":"warn",severity:"warn",scope:"project-scoped",reason:m?p?"tsconfig.json detected.":"jsconfig.json detected.":"No tsconfig.json or jsconfig.json detected.",recommendation:m?void 0:"Add tsconfig.json (or jsconfig.json) for typed frontend builds and IDE parity."});let g=o.fileHints.length>0&&o.fileHints.some(y=>r.pathExistsSync(a.join(n,y)));d.push({id:"frontend-framework-config",label:`${o.displayName} config surface`,status:g?"pass":"warn",severity:"warn",scope:"project-scoped",reason:g?`${o.displayName} configuration artifacts detected.`:`No ${o.displayName} config markers detected (${o.fileHints.join(", ")||"n/a"}).`,recommendation:g?void 0:"Keep framework config files in-repo for reproducible dev/build behavior."});for(let y of Et){let k=$t(s,c,y),b=y==="dev"||y==="build";d.push({id:`frontend-script-${y}`,label:`${y} script surface`,status:k?"pass":b?"fail":"warn",severity:b?"error":"warn",scope:"project-scoped",reason:k?`package.json exposes a ${y} script for ${o.displayName}.`:`No ${y} script detected for ${o.displayName}.`,recommendation:k?void 0:`Add a "${a$5(c,y)[0]??y}" script to package.json.`});}let h=await je(n);return d.push({id:"frontend-source-tree",label:"Frontend source tree",status:h?"pass":"warn",severity:"warn",scope:"project-scoped",reason:h?"Application source directories detected (src/app/pages).":"No frontend source directories detected under src/, app/, or pages/.",recommendation:h?void 0:"Ensure the scaffolded application tree exists before running lifecycle commands."}),d}function Rt(e){return [...new Set(e.filter(n=>n&&n.trim().length>0))]}function Ft(){let e=k().map(t=>a.join(t,a$4()?"poetry.exe":"poetry")),n=a$4()?[a.join(process.env.APPDATA||"","Python","Scripts","poetry.exe"),a.join(process.env.USERPROFILE||"","AppData","Roaming","Python","Scripts","poetry.exe")]:[],i=a$4()?[]:["/usr/local/bin/poetry","/usr/bin/poetry"];return Rt([...e,...n,...i])}function Dt(e){let n=k().map(u=>({location:"Global (user-local)",path:a.join(u,a$4()?"rapidkit.exe":"rapidkit")})),i=[{location:"Global (pipx)",path:a.join(e,".local","bin","rapidkit")},{location:"Global (pipx)",path:a.join(e,"AppData","Roaming","Python","Scripts","rapidkit.exe")},{location:"Global (pyenv)",path:a.join(e,".pyenv","shims","rapidkit")},{location:"Global (system)",path:"/usr/local/bin/rapidkit"},{location:"Global (system)",path:"/usr/bin/rapidkit"}],t=g(a.join(process.cwd(),".venv")),c=i$1(process.cwd()),o=[{location:"Workspace (.venv)",path:t},...c.map(u=>({location:"Workspace (launcher)",path:u}))],s=[...n,...i,...o],d=new Set;return s.filter(u=>d.has(u.path)?false:(d.add(u.path),true))}function At(e){let n=new Map([["Workspace (.venv)",0],["Global (user-local)",1],["Global (pipx)",2],["Global (pyenv)",3],["Global (system)",4]]);return [...e].sort((i,t)=>{let c=n.get(i.location)??Number.MAX_SAFE_INTEGER,o=n.get(t.location)??Number.MAX_SAFE_INTEGER;return c!==o?c-o:i.path.localeCompare(t.path)})}function ee(e){let n=0,i=e.issues.some(t=>t.toLowerCase().includes("environment file missing"));return e.hasEnvFile===false&&!i&&(n+=1),typeof e.vulnerabilities=="number"&&e.vulnerabilities>0&&(n+=1),n}function Ce(e){return e.filter(n=>ee(n)>0).length}function $e(e){return e.reduce((n,i)=>n+ee(i),0)}var It="doctor-project-scan-v2",et="doctor-workspace-cache-v2",Nt=Object.freeze({version:"doctor-evidence-v1",scoringPolicyVersion:"doctor-score-policy-v1",generatedBy:"rapidkit-npm",deterministicScoreBreakdown:true,scopeModel:"workspace-aggregate-or-project-scoped"});function me(){return {...Nt}}function fe(e){return !e||e.total<=0?null:Math.round(e.passed/e.total*100)}function tt(e){return typeof e=="number"?e:Array.isArray(e)?e.length:0}async function nt(e,n){try{if(!await r.pathExists(e))return null;let i=await r.readJSON(e);return c(i,n)?i:null}catch{return null}}function st(e,n){if(!e?.system)return [];let i=[{id:"python",current:n.python},{id:"poetry",current:n.poetry},{id:"pipx",current:n.pipx},{id:"go",current:n.go},{id:"rapidkitCore",current:n.rapidkitCore}],t=[];for(let c of i){let o=e.system?.[c.id]?.status;!o||o===c.current.status||t.push({id:c.id,from:o,to:c.current.status});}return t}function Ht(e,n){let i=new Map;for(let g of n.projects)i.set(g.path||g.name,g.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:[],c=new Map;for(let g of t){let h=g.path||g.name;h&&c.set(h,tt(g.issues));}let o=0,s=0,d=new Set,u=new Set,p=new Set([...Array.from(c.keys()),...Array.from(i.keys())]);for(let g of p){let h=c.get(g)??0,y=i.get(g)??0;y>h?(o+=y-h,d.add(g)):y<h&&(s+=h-y,u.add(g));}let f=fe(e.healthScore),m=fe(n.healthScore);return {baselineAvailable:true,previousGeneratedAt:e.generatedAt,newIssueCount:o,resolvedIssueCount:s,netIssueDelta:o-s,scoreDeltaPercent:f===null||m===null?null:m-f,systemStatusChanges:st(e,{python:n.python,poetry:n.poetry,pipx:n.pipx,go:n.go,rapidkitCore:n.rapidkitCore}),regressedProjects:Array.from(d).sort(),improvedProjects:Array.from(u).sort()}}function Mt(e,n){if(!e)return {baselineAvailable:false,newIssueCount:0,resolvedIssueCount:0,netIssueDelta:0,scoreDeltaPercent:null,systemStatusChanges:[],regressedProjects:[],improvedProjects:[]};let i=tt(e.project?.issues),t=n.project.issues.length,c=Math.max(t-i,0),o=Math.max(i-t,0),s=fe(e.healthScore),d=fe(n.healthScore),u=n.project.path||n.project.name;return {baselineAvailable:true,previousGeneratedAt:e.generatedAt,newIssueCount:c,resolvedIssueCount:o,netIssueDelta:c-o,scoreDeltaPercent:s===null||d===null?null:d-s,systemStatusChanges:st(e,{python:n.python,poetry:n.poetry,pipx:n.pipx,go:n.go,rapidkitCore:n.rapidkitCore}),regressedProjects:c>0?[u]:[],improvedProjects:o>0?[u]:[]}}function ot(e){let n=e??[],i=0,t=0;for(let s of n){if(s.scope==="project-scoped"){i+=1;continue}(s.scope==="workspace-aggregate"||s.scope==="host-system")&&(t+=1);}let c=i>0&&t>0?1:0,o=c>0?"mixed":i>0?"scoped":t>0?"aggregated":"unknown";return {scopedCount:i,aggregatedCount:t,mixedCount:c,dominantScope:o}}function R(e,n){return a$4()?`cd "${e}"; ${n}`:`cd ${e} && ${n}`}function q(e){return a$4()?R(e,"Copy-Item .env.example .env"):R(e,"cp .env.example .env")}function Tt(e){return e==="FastAPI"||e==="NestJS"?"first-class":e==="Django"||e==="Flask"||e==="Express"||e==="Fastify"||e==="Koa"||e==="Go/Fiber"||e==="Go/Gin"||e==="Spring Boot"||e==="Rust"||e==="Phoenix"||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 Bt(e){return e==="Next.js"||e==="Remix"||e==="Nuxt"||e==="React"||e==="Vue"||e==="Angular"||e==="SvelteKit"||e==="Svelte"||e==="Vite"||e==="Astro"||e==="Solid"?"frontend":e==="Unknown"||e==="Node.js"||e==="Python"?"generic":"backend"}function _t(e){return e==="NestJS"||e==="Next.js"||e==="Remix"||e==="Nuxt"||e==="React"||e==="Vue"||e==="Angular"||e==="SvelteKit"||e==="Svelte"||e==="Vite"||e==="Astro"||e==="Solid"||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 Ee(e,n){let i=q$1(n);e.commandCapabilities=i,e.supportTier=i.frameworkSupportTier;}function pe(e,n,i,t){e.framework=n,e.frameworkConfidence=i,e.supportTier=Tt(n),e.projectKind=Bt(n),e.runtimeFamily=_t(n);}function it(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 Re(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 "nextjs":return "Next.js";case "remix":return "Remix";case "nuxt":return "Nuxt";case "react":return "React";case "vite":return "Vite";case "vue":return "Vue";case "sveltekit":return "SvelteKit";case "svelte":return "Svelte";case "angular":return "Angular";case "astro":return "Astro";case "solid":return "Solid";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 Gt(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 Kt(e,n){e.framework=Re(n),e.frameworkKey=n.key,e.importStack=n.importStack,e.frameworkConfidence=n.confidence,e.supportTier=n.supportTier,e.projectKind="frontend",e.runtimeFamily=it(n.runtime);}function G(e,n){e.framework=Re(n),e.frameworkKey=n.key,e.importStack=n.importStack,e.frameworkConfidence=n.confidence,e.supportTier=n.supportTier,e.projectKind=Gt(n)?"generic":"backend",e.runtimeFamily=it(n.runtime);}function Wt(e){let n=e.dependencies,i=e.scripts??{},t=(e.kitName??"").toLowerCase(),c=s=>!!n[s],o=Object.values(i).filter(s=>typeof s=="string").join(" ").toLowerCase();return c("next")||o.includes("next ")?{framework:"Next.js",confidence:"high"}:c("nuxt")||o.includes("nuxt ")?{framework:"Nuxt",confidence:"high"}:c("@nestjs/core")||t.startsWith("nestjs.")?{framework:"NestJS",confidence:"high"}:c("express")?{framework:"Express",confidence:"high"}:c("fastify")?{framework:"Fastify",confidence:"high"}:c("koa")?{framework:"Koa",confidence:"high"}:c("@angular/core")?{framework:"Angular",confidence:"high"}:c("@sveltejs/kit")||o.includes("svelte-kit")?{framework:"SvelteKit",confidence:"high"}:c("vue")?{framework:"Vue",confidence:"medium"}:c("react")&&c("react-dom")?{framework:"React",confidence:"medium"}:{framework:"Node.js",confidence:"low"}}async function Ot(e){let n=i(e);return n.runtime!=="python"?{framework:"Python",confidence:"low"}:{framework:Re(n),confidence:n.confidence}}async function qe(e){try{let n=await r.stat(e);return `${a.basename(e)}:${n.isDirectory()?"d":"f"}:${n.size}:${n.mtimeMs}`}catch{return `${a.basename(e)}:missing`}}async function Lt(e){try{let n=new Set([".git",".venv","node_modules",".rapidkit","dist","build","coverage","__pycache__"]),i=new Set;await le(e)&&i.add(e);let t=await a$1(e);for(let o of t){let s=a.isAbsolute(o.path)?o.path:a.join(e,o.path);await le(s)&&i.add(s);}let c=async(o,s)=>{if(s<0)return;let d=await at(o);for(let u of d){if(rt(u,n))continue;let p=a.join(o,u);if(await le(p)){i.add(p);continue}s>0&&await c(p,s-1);}};return await c(e,1),i.size===0&&(await sn(e,3,n)).forEach(s=>i.add(s)),Array.from(i).sort((o,s)=>o.localeCompare(s))}catch{return []}}async function Vt(e,n){let i=[a.join(e,".rapidkit-workspace"),a.join(e,".rapidkit","workspace.json"),a.join(e,".rapidkit","imported-projects.json"),a.join(e,".rapidkit","policies.yml"),a.join(e,".rapidkit","toolchain.lock"),a.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"],c=await Promise.all(i.map(qe)),o=await Promise.all(n.map(async s=>{let d=await Promise.all(t.map(u=>qe(a.join(s,u))));return `${s}::${d.join("|")}`}));return [It,...c,...o].join("||")}async function Jt(e,n){try{if(!await r.pathExists(e))return null;let i=await r.readJSON(e);return !i||i.signature!==n||!Array.isArray(i.projects)||typeof i.schemaVersion=="string"&&i.schemaVersion!==et?null:i}catch{return null}}async function qt(e,n){try{await r.ensureDir(a.dirname(e)),await r.writeJSON(e,n,{spaces:2});}catch{}}async function Ut(e,n,i){let t=a.join(e,".rapidkit","reports","doctor-last-run.json");try{await r.ensureDir(a.dirname(t));let c=[];for(let o of n.projects)for(let s of o.issues??[])typeof s=="string"&&s.trim()&&c.push(`${o.name}: ${s.trim()}`);for(let[o,s]of [["python",n.python],["rapidkitCore",n.rapidkitCore]])if(s?.status==="error"){let d=typeof s.message=="string"?s.message:`${o} check failed`;c.push(`${o}: ${d}`);}return await r.writeJSON(t,e$1({schemaVersion:a$2,evidenceType:"workspace",contract:me(),workspacePath:e,workspaceName:n.workspaceName,projectScanCached:n.projectScanCached??false,projectScanSignature:n.projectScanSignature,cachePath:i,healthScore:n.healthScore,system:{python:n.python,poetry:n.poetry,pipx:n.pipx,go:n.go,rapidkitCore:n.rapidkitCore,versions:{core:n.coreVersion,npm:n.npmVersion}},projects:n.projects,summary:{totalProjects:n.projects.length,totalIssues:n.projects.reduce((o,s)=>o+s.issues.length,0),projectAdvisoryWarningProjects:Ce(n.projects),projectAdvisoryWarnings:$e(n.projects),hasSystemErrors:[n.python,n.rapidkitCore].some(o=>o.status==="error"),scopeProvenance:n.scopeProvenance},driftDelta:n.driftDelta,scoreBreakdown:n.scoreBreakdown??[]},{commandId:"checkWorkspaceHealth",exitCode:oe(n.healthScore,{}),generatedAt:new Date().toISOString(),blockers:c.slice(0,12),runId:d$1()}),{spaces:2}),t}catch{return}}async function Fe(){let[e,n,i,t,c]=await Promise.all([zt(),Qt(),Xt(),Yt(),Zt()]);return {python:e,poetry:n,pipx:i,go:t,rapidkitCore:c}}async function zt(){let e=d$2();for(let n of e)try{let{stdout:i}=await execa(n,["--version"],{timeout:3e3}),t=i.match(/Python (\d+\.\d+\.\d+)/);if(t){let c=t[1],[o,s]=c.split(".").map(Number);return o<3||o===3&&s<10?{status:"warn",message:`Python ${c} (requires 3.10+)`,details:`${n} found but version is below minimum requirement`}:{status:"ok",message:`Python ${c}`,details:`Using ${n}`}}}catch{continue}return {status:"error",message:"Python not found",details:"Install Python 3.10+ and ensure it's in PATH"}}async function Qt(){try{let{stdout:e}=await execa("poetry",["--version"],{timeout:3e3}),n=e.match(/Poetry .*version ([\d.]+)/);return n?{status:"ok",message:`Poetry ${n[1]}`,details:"Available for dependency management"}:{status:"warn",message:"Poetry version unknown"}}catch{let e=d$2().map(n=>({cmd:n,args:n==="py"?["-3","-m","poetry","--version"]:["-m","poetry","--version"]}));for(let n of e)try{let{stdout:i}=await execa(n.cmd,n.args,{timeout:3e3,shell:b$1()}),t=i.match(/Poetry .*version ([\d.]+)/)||i.match(/([\d.]+)/);return {status:"ok",message:t?.[1]?`Poetry ${t[1]}`:"Poetry detected",details:`Available via ${n.cmd} ${n.args.join(" ")}`}}catch{continue}for(let n of Ft())try{if(!await r.pathExists(n))continue;let{stdout:i}=await execa(n,["--version"],{timeout:3e3,shell:b$1()}),t=i.match(/Poetry .*version ([\d.]+)/)||i.match(/([\d.]+)/);return {status:"ok",message:t?.[1]?`Poetry ${t[1]}`:"Poetry detected",details:`Available at ${n}`}}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$2();for(let n of e)try{let i=n==="py"?["-3","-m","pipx","--version"]:["-m","pipx","--version"],{stdout:t}=await execa(n,i,{timeout:3e3,shell:b$1()});return {status:"ok",message:`pipx ${t.trim()}`,details:`Available via ${n} ${i.join(" ")}`}}catch{continue}return {status:"warn",message:"pipx not installed",details:"Optional: Install for isolated Python tools"}}}async function Yt(){try{let{stdout:e}=await execa("go",["version"],{timeout:3e3}),n=e.match(/go version go(\d+\.\d+(?:\.\d+)?)/);return n?{status:"ok",message:`Go ${n[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 Zt(){let e=process.env.HOME||process.env.USERPROFILE||"",n=[],i=Dt(e);for(let{location:c,path:o}of i)try{if(await r.pathExists(o)){let{stdout:s,exitCode:d}=await execa(o,["--version"],{timeout:3e3,reject:false});if(d===0&&(s.includes("RapidKit Version")||s.includes("RapidKit"))){let u=s.match(/v?([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);u&&n.push({location:c,path:o,version:u[1]});}}}catch{continue}if(n.length>0){let c=n.filter(s=>s.location!=="Workspace (launcher)");if(c.length>0){let s=At(c),d=s[0].version,u=s.some(m=>m.location==="Workspace (.venv)"),p=s.some(m=>m.location.startsWith("Global (")),f=!u&&p?"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:s.map(m=>({location:m.location,path:m.path,version:m.version}))}}return {status:"ok",message:`RapidKit Core ${n[0].version}`,details:"Detected via workspace launcher"}}try{let{stdout:c,exitCode:o}=await execa("rapidkit",["--version"],{timeout:3e3,reject:false});if(o===0&&(c.includes("RapidKit Version")||c.includes("RapidKit"))){let s=c.match(/v?([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);if(s)return {status:"ok",message:`RapidKit Core ${s[1]}`,details:"Available via PATH"}}}catch{}try{let{stdout:c,exitCode:o}=await execa("poetry",["run","rapidkit","--version"],{timeout:3e3,reject:false});if(o===0&&(c.includes("RapidKit Version")||c.includes("RapidKit"))){let s=c.match(/v?([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);if(s)return {status:"ok",message:`RapidKit Core ${s[1]}`,details:"Available via Poetry"}}}catch{}let t=d$2();for(let c of t)try{let{stdout:o,exitCode:s}=await execa(c,["-c","import rapidkit_core; print(rapidkit_core.__version__)"],{timeout:3e3,reject:false});if(s===0&&o&&!o.includes("Traceback")&&!o.includes("ModuleNotFoundError")){let d=o.trim();if(d)return {status:"ok",message:`RapidKit Core ${d}`,details:`Available in ${c} environment`}}}catch{continue}return {status:"error",message:"RapidKit Core not installed",details:"Install with: pipx install rapidkit-core"}}async function T(e,n,i){let t=a.join(e,"Dockerfile");n.hasDocker=await r.pathExists(t);let c=a.join(e,"tests"),o=a.join(e,"test"),s=a.join(e,"src","test"),d=await r.pathExists(c)||await r.pathExists(o)||await r.pathExists(s),u=false;if(n.framework==="Go/Fiber"||n.framework==="Go/Gin")try{let p=[{dir:e,depth:0}],f=4,m=new Set([".git",".venv","node_modules","dist","build","vendor"]);for(;p.length>0&&!u;){let g=p.shift();if(!g)break;let h=[];try{h=await r.readdir(g.dir);}catch{continue}for(let y of h){let k=a.join(g.dir,y),b;try{b=await r.stat(k);}catch{continue}if(b.isFile()&&y.endsWith("_test.go")){u=true;break}b.isDirectory()&&g.depth<f&&!m.has(y)&&!y.startsWith(".")&&p.push({dir:k,depth:g.depth+1});}}}catch{}if(n.hasTests=d||u,n.runtimeFamily==="node"&&!n.hasTests&&(n.hasTests=await Ve(e,i)),n.runtimeFamily==="node")n.hasCodeQuality=await Le(e,i);else if(n.framework==="Go/Fiber"||n.framework==="Go/Gin"){let p=a.join(e,".golangci.yml"),f=a.join(e,".golangci.yaml"),m=a.join(e,"Makefile"),g=await r.pathExists(m)&&(await r.readFile(m,"utf8")).includes("golangci-lint");n.hasCodeQuality=await r.pathExists(p)||await r.pathExists(f)||g;}else if(n.runtimeFamily==="python"){let p=a.join(e,"ruff.toml"),f=a.join(e,"pyproject.toml");if(await r.pathExists(f))try{let m=await r.readFile(f,"utf8");n.hasCodeQuality=m.includes("[tool.ruff]")||await r.pathExists(p);}catch{n.hasCodeQuality=await r.pathExists(p);}}else if(n.framework==="Spring Boot"){let p=a.join(e,"pom.xml");if(await r.pathExists(p))try{let f=await r.readFile(p,"utf8");n.hasCodeQuality=f.includes("spotless")||f.includes("checkstyle")||f.includes("pmd")||f.includes("maven-enforcer-plugin");}catch{n.hasCodeQuality=false;}}try{if(n.runtimeFamily==="node"){let{stdout:p}=await execa("npm",["audit","--json"],{cwd:e,reject:false});if(p)try{let m=JSON.parse(p).metadata?.vulnerabilities;m&&(n.vulnerabilities=(m.high||0)+(m.critical||0)+(m.moderate||0));}catch{}}else if(n.runtimeFamily==="python"){let p=a.join(e,".venv"),f$1=f(p);if(await r.pathExists(f$1))try{let{stdout:m}=await execa(f$1,["-m","pip","list","--format=json"],{timeout:5e3,reject:false});if(m){JSON.parse(m);n.vulnerabilities=0;}}catch{}}}catch{}}function I(e,n){e.probes||(e.probes=[]),e.probes.push(n);}async function en(e,n){let i=n.runtimeFamily||"unknown";if(n.projectKind==="backend"||n.projectKind==="generic"){if(i==="node"){let c=await r.pathExists(a.join(e,"package-lock.json"))||await r.pathExists(a.join(e,"pnpm-lock.yaml"))||await r.pathExists(a.join(e,"yarn.lock"));I(n,{id:"adapter-node-lockfile-integrity",label:"Node adapter lockfile integrity",status:c?"pass":"warn",severity:"warn",scope:"project-scoped",reason:c?"Node lockfile detected for deterministic dependency restore.":"No Node lockfile detected (package-lock/yarn.lock/pnpm-lock.yaml).",recommendation:c?void 0:"Commit a lockfile for deterministic installs and CI parity."});let o=await r.pathExists(a.join(e,"src/main.ts"))||await r.pathExists(a.join(e,"src/main.js"))||await r.pathExists(a.join(e,"src/server.ts"))||await r.pathExists(a.join(e,"src/server.js"));I(n,{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(i==="python"){let c=await r.pathExists(a.join(e,"poetry.lock"))||await r.pathExists(a.join(e,"requirements.txt"))||await r.pathExists(a.join(e,"uv.lock"));I(n,{id:"adapter-python-lockfile-integrity",label:"Python adapter dependency integrity",status:c?"pass":"warn",severity:"warn",scope:"project-scoped",reason:c?"Python dependency contract file detected.":"No Python dependency contract file detected (poetry.lock/requirements/uv.lock).",recommendation:c?void 0:"Pin dependency contract for deterministic setup and reproducible CI."});let o=await r.pathExists(a.join(e,"app/main.py"))||await r.pathExists(a.join(e,"main.py"))||await r.pathExists(a.join(e,"manage.py"));I(n,{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(i==="java"){let c=await r.pathExists(a.join(e,"mvnw"))||await r.pathExists(a.join(e,"gradlew"));I(n,{id:"adapter-java-build-wrapper",label:"Java adapter build wrapper",status:c?"pass":"warn",severity:"warn",scope:"project-scoped",reason:c?"Build wrapper detected (mvnw/gradlew).":"No Java build wrapper detected.",recommendation:c?void 0:"Commit mvnw or gradlew for reproducible enterprise pipelines."});return}if(i==="go"){let c=await r.pathExists(a.join(e,"go.sum"));I(n,{id:"adapter-go-module-integrity",label:"Go adapter module integrity",status:c?"pass":"warn",severity:"warn",scope:"project-scoped",reason:c?"go.sum detected for deterministic module verification.":"go.sum missing; module integrity baseline is incomplete.",recommendation:c?void 0:"Generate and commit go.sum in the repository baseline."});}}}async function tn(e,n){let i=[a.join(e,".rapidkit","doctor.adapters.json"),a.join(e,"doctor.adapters.json")];for(let t of i)if(await r.pathExists(t))try{let c=await r.readJSON(t),o=Array.isArray(c?.checks)?c.checks:[];for(let s=0;s<o.length;s+=1){let d=o[s]||{},u=Array.isArray(d.runtimes)?d.runtimes:[];if(u.length>0&&!u.includes(n.runtimeFamily||"unknown"))continue;let p=typeof d.id=="string"&&d.id.trim().length>0?d.id.trim():`adapter-check-${s+1}`,f=typeof d.label=="string"&&d.label.trim().length>0?d.label.trim():p,m=d.severity||"warn",g=Array.isArray(d.anyOfPaths)?d.anyOfPaths.filter(Boolean):[],h=Array.isArray(d.allOfPaths)?d.allOfPaths.filter(Boolean):[],y=g.length===0;for(let L of g)if(await r.pathExists(a.join(e,L))){y=true;break}let k=true;for(let L of h)if(!await r.pathExists(a.join(e,L))){k=false;break}let b=y&&k;I(n,{id:p,label:f,status:b?"pass":m==="error"?"fail":"warn",severity:m,scope:"project-scoped",reason:b?d.passReason||"Custom adapter contract satisfied.":d.failReason||`Custom adapter check failed from ${a.basename(t)}.`,recommendation:d.recommendation});}}catch{I(n,{id:"custom-adapter-config",label:"Custom doctor adapter configuration",status:"warn",severity:"warn",scope:"project-scoped",reason:`Failed to parse ${a.basename(t)}.`,recommendation:"Fix JSON syntax in doctor.adapters.json to re-enable adapter checks."});}}async function B(e,n){if(!(n.projectKind==="backend"||n.projectKind==="generic"))return;let t=a.join(e,".env"),c=a.join(e,".env.example"),o=await r.pathExists(t)||await r.pathExists(c)||await r.pathExists(a.join(e,"config"));I(n,{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 s={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=n.runtimeFamily||"unknown",u=s[d]||s.unknown,p=false;for(let g of u)if(await r.pathExists(a.join(e,g))){p=true;break}I(n,{id:"migration-surface",label:"Migration/readiness surface",status:p?"pass":"warn",severity:"warn",scope:"project-scoped",reason:p?"Migration or schema evolution markers detected.":"No migration markers detected for this backend runtime.",recommendation:p?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"],m=false;for(let g of f)if(await r.pathExists(a.join(e,g))){m=true;break}I(n,{id:"runtime-health-surface",label:"Runtime health probe surface",status:m?"pass":"warn",severity:"warn",scope:"project-scoped",reason:m?"Health endpoint/config markers detected.":"No explicit runtime health endpoint markers detected.",recommendation:m?void 0:"Expose a deterministic health endpoint and keep it covered in verify pack."}),await en(e,n);}async function nn(e,n,i,t){let c=await Je({projectPath:e,detection:t,packageJsonData:i});for(let o of c)I(n,o);}async function _(e,n){let i=[a.join(e,".rapidkit","doctor.probes.json"),a.join(e,"doctor.probes.json")];for(let t of i)if(await r.pathExists(t))try{let c=await r.readJSON(t),o=Array.isArray(c?.probes)?c.probes:[];for(let s=0;s<o.length;s+=1){let d=o[s]||{},u=typeof d.id=="string"&&d.id.trim().length>0?d.id.trim():`custom-probe-${s+1}`,p=typeof d.label=="string"&&d.label.trim().length>0?d.label.trim():u,f=d.severity||"warn",m=Array.isArray(d.anyOfPaths)?d.anyOfPaths.filter(Boolean):[],g=Array.isArray(d.allOfPaths)?d.allOfPaths.filter(Boolean):[],h=m.length===0;for(let b of m)if(await r.pathExists(a.join(e,b))){h=true;break}let y=true;for(let b of g)if(!await r.pathExists(a.join(e,b))){y=false;break}let k=h&&y;I(n,{id:u,label:p,status:k?"pass":f==="error"?"fail":"warn",severity:f,scope:"project-scoped",reason:k?"Custom probe contract satisfied.":`Custom probe failed from ${a.basename(t)}.`,recommendation:d.recommendation});}}catch{I(n,{id:"custom-probe-config",label:"Custom doctor probe configuration",status:"warn",severity:"warn",scope:"project-scoped",reason:`Failed to parse ${a.basename(t)}.`,recommendation:"Fix JSON syntax in doctor.probes.json to re-enable custom probes."});}await tn(e,n);}async function De(e,n={}){let t={name:a.basename(e),path:e,venvActive:false,depsInstalled:false,coreInstalled:false,issues:[],fixCommands:[]},c=n.allowNonRapidkit===true,o=a.join(e,".rapidkit");if(!await r.pathExists(o)){if(!c)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 w=a.join(e,"registry.json");if(await r.pathExists(w)){let v=await r.readJson(w);v.installed_modules&&(t.stats={modules:v.installed_modules.length});}}catch{}try{let{auditProjectModulePaths:w}=await import('./module-layout-NZ43RSC5.js'),v=await w(e);if(v.issues.length>0){for(let C of v.issues)t.issues.push(`${C.message} (${C.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 s=null;try{let w=a.join(o,"project.json");if(await r.pathExists(w)){s=await r.readJson(w);let v=s?.kit_name||s?.kit;v&&(t.kit=v);}}catch{}try{let w=a.join(e,".git");if(await r.pathExists(w)){let{stdout:v}=await execa("git",["log","-1","--format=%cr"],{cwd:e,reject:false});v&&(t.lastModified=v.trim());}else {let v=await r.stat(e),F=Date.now()-v.mtime.getTime(),D=Math.floor(F/(1e3*60*60*24));t.lastModified=D===0?"today":`${D} day${D>1?"s":""} ago`;}}catch{}let d$1=a.join(e,"package.json"),u=a.join(e,"pyproject.toml"),p=a.join(e,"requirements.txt"),f$1=a.join(e,"go.mod"),m=a.join(e,"pom.xml"),g=a.join(e,"build.sbt"),h=a.join(e,"Cargo.toml"),y=a.join(e,"mix.exs"),k=a.join(e,"deps.edn"),b=a.join(e,"project.clj"),L=a.join(e,"deno.json"),K=a.join(e,"deno.jsonc"),U=a.join(e,"bun.lockb"),z=a.join(e,"bun.lock"),V=a.join(e,"composer.json"),ie=a.join(e,"Gemfile"),Q=await r.pathExists(d$1),W=await r.pathExists(u)||await r.pathExists(p),N=await r.pathExists(V),ne=await r.pathExists(ie),ae=await r.pathExists(h),mt=await r.pathExists(y),ft=await r.pathExists(k)||await r.pathExists(b),gt=await r.pathExists(g),ht=await r.pathExists(L)||await r.pathExists(K),ue=s?.runtime==="dotnet";try{ue=ue||await Ue(e,".csproj",3)||await Ue(e,".sln",2);}catch{ue=s?.runtime==="dotnet";}let yt=await r.pathExists(f$1)||s?.runtime==="go"||typeof s?.kit_name=="string"&&(s.kit_name.startsWith("gofiber")||s.kit_name.startsWith("gogin")),Ae=Q&&(await r.pathExists(U)||await r.pathExists(z)||typeof s?.packageManager=="string"&&(s?.packageManager).toLowerCase().startsWith("bun@"));if(yt){G(t,i(e,s??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 w=a.join(e,"go.sum");return await r.pathExists(w)?t.depsInstalled=true:(t.depsInstalled=false,t.issues.push("Go dependencies not downloaded (go.sum missing)"),t.fixCommands?.push(R(e,"go mod tidy"))),await T(e,t),await B(e,t),await _(e,t),t}if(await r.pathExists(m)||s?.runtime==="java"||typeof s?.kit_name=="string"&&s.kit_name.startsWith("springboot")){G(t,i(e,s??null)),t.venvActive=true,t.coreInstalled=false;let w=await r.pathExists(m),v=await r.pathExists(a.join(e,"build.gradle"))||await r.pathExists(a.join(e,"build.gradle.kts")),C=await r.pathExists(a.join(e,"mvnw"))||await r.pathExists(a.join(e,"mvnw.cmd")),F=await r.pathExists(a.join(e,"gradlew"))||await r.pathExists(a.join(e,"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(w){if(!C)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(v&&!F)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 D=a.join(e,"target"),A=a.join(e,"build","libs"),H=a.join(e,".rapidkit","cache","java","m2"),j=a.join(e,".rapidkit","cache","java","gradle");t.depsInstalled=await r.pathExists(D)||await r.pathExists(A)||await r.pathExists(H)||await r.pathExists(j),t.depsInstalled||(t.issues.push("Java dependencies are not warmed or built yet"),t.fixCommands?.push(R(e,"rapidkit init")));let P=a.join(e,".env");if(t.hasEnvFile=await r.pathExists(P),!t.hasEnvFile){let X=a.join(e,".env.example");await r.pathExists(X)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(q(e)));}let J=a.join(e,"src","main","resources","application.yml");if(await r.pathExists(J))try{let X=await r.readFile(J,"utf-8");/include:\s*[^\n]*health/i.test(X)||/management:\s*[\s\S]*endpoint:\s*[\s\S]*health:/i.test(X)||(t.issues.push("Actuator health endpoint exposure is not clearly configured in application.yml"),t.fixCommands?.push(R(e,"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 T(e,t),await B(e,t),await _(e,t),t}if(ae){G(t,i(e,s??null)),t.venvActive=true,t.coreInstalled=false;let w=a.join(e,"Cargo.lock"),v=a.join(e,"target");t.depsInstalled=await r.pathExists(w)||await r.pathExists(v),t.depsInstalled||(t.issues.push("Rust dependencies are not resolved yet (Cargo.lock/target missing)"),t.fixCommands?.push(R(e,"cargo fetch")));let C=a.join(e,".env");if(t.hasEnvFile=await r.pathExists(C),!t.hasEnvFile){let F=a.join(e,".env.example");await r.pathExists(F)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(q(e)));}return await T(e,t),await B(e,t),await _(e,t),t}if(mt){G(t,i(e,s??null)),t.venvActive=true,t.coreInstalled=false;let w=a.join(e,"mix.lock"),v=a.join(e,"deps");t.depsInstalled=await r.pathExists(w)||await r.pathExists(v),t.depsInstalled||(t.issues.push("Elixir dependencies not installed (mix.lock/deps missing)"),t.fixCommands?.push(R(e,"mix deps.get")));let C=a.join(e,".env");if(t.hasEnvFile=await r.pathExists(C),!t.hasEnvFile){let F=a.join(e,".env.example");await r.pathExists(F)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(q(e)));}return await T(e,t),await B(e,t),await _(e,t),t}if(ft){G(t,i(e,s??null)),t.venvActive=true,t.coreInstalled=false;let w=a.join(e,".cpcache"),v=a.join(e,"target"),C=await r.pathExists(k)||await r.pathExists(b);return t.depsInstalled=await r.pathExists(w)||await r.pathExists(v)||C,t.depsInstalled||(t.issues.push("Clojure dependency cache not initialized"),t.fixCommands?.push(R(e,"clojure -P"))),await T(e,t),await B(e,t),await _(e,t),t}if(gt){G(t,i(e,s??null)),t.venvActive=true,t.coreInstalled=false;let w=a.join(e,"target");t.depsInstalled=await r.pathExists(w),t.depsInstalled||(t.issues.push("Scala build artifacts missing (run dependency/build warmup)"),t.fixCommands?.push(R(e,"sbt compile")));let v=a.join(e,".env");if(t.hasEnvFile=await r.pathExists(v),!t.hasEnvFile){let C=a.join(e,".env.example");await r.pathExists(C)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(q(e)));}return await T(e,t),await B(e,t),await _(e,t),t}if(ht){G(t,i(e,s??null)),t.venvActive=true,t.coreInstalled=false,t.depsInstalled=true;let w=a.join(e,".env");if(t.hasEnvFile=await r.pathExists(w),!t.hasEnvFile){let v=a.join(e,".env.example");await r.pathExists(v)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(q(e)));}return await T(e,t),await B(e,t),await _(e,t),t}if(Q){let w=null;try{w=await r.readJson(d$1);}catch{w=null;}let v={...w?.dependencies??{},...w?.devDependencies??{}},C=w?.scripts??{},F=typeof s?.kit_name=="string"?s.kit_name.toLowerCase():typeof s?.kit=="string"?s.kit.toLowerCase():"",D=d(e,s),A=Wt({dependencies:v,scripts:C,kitName:F});if(Ae)pe(t,"Bun","high");else {let j=i(e,s??null);j.key==="nestjs"||j.key==="express"||j.key==="fastify"||j.key==="koa"?G(t,j):D.key!=="unknown"?Kt(t,D):j.key!=="unknown"&&j.key!=="node"?G(t,j):pe(t,A.framework,A.confidence);}t.venvActive=true;let H=a.join(e,"node_modules");if(await r.pathExists(H))try{let P=(await r.readdir(H)).filter(J=>!J.startsWith(".")&&!J.startsWith("_"));t.depsInstalled=P.length>0;}catch{t.depsInstalled=false;}if(t.depsInstalled||(t.issues.push("Dependencies not installed (node_modules empty or missing)"),t.fixCommands?.push(R(e,Ae?"bun install":"rapidkit init"))),t.coreInstalled=false,t.projectKind==="frontend"){let j=[".env",".env.local",".env.development",".env.development.local",".env.production",".env.production.local"];if((await Promise.all(j.map(J=>r.pathExists(a.join(e,J))))).some(Boolean))t.hasEnvFile=true;else {let J=a.join(e,".env.example");await r.pathExists(J)&&(t.hasEnvFile=false,t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(q(e)));}}else {let j=a.join(e,".env");if(t.hasEnvFile=await r.pathExists(j),!t.hasEnvFile){let P=a.join(e,".env.example");await r.pathExists(P)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(q(e)));}}if(t.projectKind==="frontend")t.modulesHealthy=await je(e),t.missingModules=[];else {let j=a.join(e,"src");if(t.modulesHealthy=true,t.missingModules=[],await r.pathExists(j))try{let P=await r.readdir(j);t.modulesHealthy=P.length>0;}catch{t.modulesHealthy=false;}}return await T(e,t,w),t.projectKind==="frontend"?await nn(e,t,w,D.key!=="unknown"?D:d(e,s)):await B(e,t),await _(e,t),t}if(W){let w=await Ot(e);pe(t,w.framework,w.confidence);let v=a.join(e,".venv");if(await r.pathExists(v)){t.venvActive=true;let A=f(v);if(await r.pathExists(A)){try{let{stdout:P}=await execa(A,["-c","import rapidkit_core; print(rapidkit_core.__version__)"],{timeout:2e3});t.coreInstalled=true,t.coreVersion=P.trim();}catch{t.coreInstalled=false;}let H="fastapi";t.framework==="Django"?H="django":t.framework==="Flask"?H="flask":t.framework==="Python"&&(H="");let j=true;if(H)try{await execa(A,["-c",`import ${H}`],{timeout:2e3}),t.depsInstalled=true,j=false;}catch{j=true;}if(j)try{let P=a.join(v,"lib");if(await r.pathExists(P)){let X=(await r.readdir(P)).find(re=>re.startsWith("python"));if(X){let re=a.join(P,X,"site-packages");if(await r.pathExists(re)){let kt=(await r.readdir(re)).filter(ge=>!ge.startsWith("_")&&!ge.includes("dist-info")&&!["pip","setuptools","wheel","pkg_resources"].includes(ge));t.depsInstalled=kt.length>0;}}}t.depsInstalled||(t.issues.push("Dependencies not installed"),t.fixCommands?.push(R(e,"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(R(e,"rapidkit init"));let C=a.join(e,".env");if(t.hasEnvFile=await r.pathExists(C),!t.hasEnvFile){let A=a.join(e,".env.example");await r.pathExists(A)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(q(e)));}let F=a.join(e,"src"),D=a.join(e,"modules");if(t.modulesHealthy=true,t.missingModules=[],await r.pathExists(F)){let A=a.join(F,"__init__.py");await r.pathExists(A)||(t.modulesHealthy=false,t.missingModules.push("src/__init__.py"));}if(await r.pathExists(D))try{let A=await at(D);for(let H of A){let j=a.join(D,H,"__init__.py");await r.pathExists(j)||(t.modulesHealthy=false,t.missingModules.push(`modules/${H}/__init__.py`));}}catch{}return !t.modulesHealthy&&t.missingModules.length>0&&t.issues.push(`Missing module init files: ${t.missingModules.join(", ")}`),await T(e,t),await B(e,t),await _(e,t),t}if(N){G(t,i(e,s??null)),t.venvActive=true,t.coreInstalled=false;let w=a.join(e,"vendor");t.depsInstalled=await r.pathExists(w),t.depsInstalled||(t.issues.push("PHP dependencies not installed (vendor missing)"),t.fixCommands?.push(R(e,"composer install")));let v=a.join(e,".env");if(t.hasEnvFile=await r.pathExists(v),!t.hasEnvFile){let C=a.join(e,".env.example");await r.pathExists(C)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(q(e)));}return await T(e,t),await B(e,t),await _(e,t),t}if(ne){G(t,i(e,s??null)),t.venvActive=true,t.coreInstalled=false;let w=await r.pathExists(a.join(e,"Gemfile.lock")),v=await r.pathExists(a.join(e,"vendor","bundle"));t.depsInstalled=w||v,t.depsInstalled||(t.issues.push("Ruby dependencies not installed (Gemfile.lock/vendor missing)"),t.fixCommands?.push(R(e,"bundle install")));let C=a.join(e,".env");return t.hasEnvFile=await r.pathExists(C),await T(e,t),await B(e,t),await _(e,t),t}if(ue){G(t,i(e,s??null)),t.venvActive=true,t.coreInstalled=false;let w=a.join(e,"obj"),v=a.join(e,"src","obj"),C=a.join(e,"packages.lock.json");t.depsInstalled=await r.pathExists(w)||await r.pathExists(v)||await r.pathExists(C),t.depsInstalled||(t.issues.push(".NET restore/build artifacts not found"),t.fixCommands?.push(R(e,"dotnet restore")));let F=a.join(e,".env");return t.hasEnvFile=await r.pathExists(F),await T(e,t),await B(e,t),await _(e,t),t}return pe(t,"Unknown","low"),t.issues.push("Unknown project type (no recognized runtime marker files)"),await T(e,t),await B(e,t),await _(e,t),t}async function at(e){try{return (await r.readdir(e,{withFileTypes:true})).filter(i=>i.isDirectory()).map(i=>i.name)}catch{try{let n=await r.readdir(e),i=[];for(let t of n)try{(await r.stat(a.join(e,t))).isDirectory()&&i.push(t);}catch{continue}return i}catch{return []}}}async function Ue(e,n,i){let t=[{dir:e,depth:0}],c=new Set([".git",".rapidkit","node_modules","bin","obj","target"]);for(;t.length>0;){let o=t.shift();if(!o||o.depth>i)continue;let s;try{s=await r.readdir(o.dir,{withFileTypes:true});}catch{continue}for(let d of s){if(d.isFile()&&d.name.toLowerCase().endsWith(n.toLowerCase()))return true;d.isDirectory()&&!c.has(d.name)&&t.push({dir:a.join(o.dir,d.name),depth:o.depth+1});}}return false}async function le(e){let n=a.join(e,".rapidkit");if(!await r.pathExists(n))return false;let i=["project.json","context.json","file-hashes.json"];for(let t of i)if(await r.pathExists(a.join(n,t)))return true;return false}function rt(e,n){if(n.has(e))return true;let i=e.toLowerCase();return !!(i==="dist"||i.startsWith("dist-")||i.startsWith("dist_")||i==="build"||i.startsWith("build-")||i.startsWith("build_"))}async function sn(e,n,i){let t=new Set,c=[{dir:e,depth:0}];for(;c.length>0;){let o=c.shift();if(!o)break;try{let s=await r.readdir(o.dir);for(let d of s){if(rt(d,i))continue;let u=a.join(o.dir,d),p;try{p=await r.stat(u);}catch{continue}if(p.isDirectory()){if(await le(u)){t.add(u);continue}o.depth<n&&c.push({dir:u,depth:o.depth+1});}}}catch{continue}}return Array.from(t)}async function de(e){let n=a.resolve(e),i=a.parse(n).root;for(;;){if(await rn(n))return n;if(n===i)break;n=a.dirname(n);}return null}async function on(e){let n=a.resolve(e),i=await de(n),t=i??a.parse(n).root;for(;;){if(await le(n)||await an(n)&&(!i||n!==i))return n;if(n===t)break;n=a.dirname(n);}return null}function ze(e){let n=a.resolve(e);return process.platform==="darwin"?n.replace(/^\/private(?=\/var\/)/,""):n}async function an(e){let n=["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 i of n)if(await r.pathExists(a.join(e,i)))return true;return false}async function rn(e){let n=[a.join(e,".rapidkit-workspace"),a.join(e,".rapidkit","workspace-marker.json"),a.join(e,".rapidkit","config.json")];return Promise.all(n.map(i=>r.pathExists(i))).then(i=>i.some(Boolean))}function ct(e,n){let i=0,t=0,c=0;return e.forEach(s=>{s.status==="ok"?i++:s.status==="warn"?t++:s.status==="error"&&c++;}),n.forEach(s=>{let d=ee(s),u=s.isGoProject?s.issues.length===0&&s.depsInstalled:s.issues.length===0&&s.venvActive&&s.depsInstalled;if(s.issues.length>0||d>0||!u){t++;return}i++;}),{total:i+t+c,passed:i,warnings:t,errors:c}}function lt(e,n,i={}){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 c=[...n].sort((o,s)=>{let d=`${o.path||""}|${o.name||""}`.toLowerCase(),u=`${s.path||""}|${s.name||""}`.toLowerCase();return d.localeCompare(u)});for(let o of c){let s=o.issues.length>0,d=ee(o),u=s||d>0?"warn":"ok",p=s?`${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:s?"project-blocking-issues":d>0?"project-advisory-warnings":"project-checks-passed",reason:p});}if(i.includeWorkspaceAggregateRules){let o=n.reduce((u,p)=>u+p.issues.length,0),s=$e(n),d=e.filter(u=>u.result.status==="error").length;t.push({id:"workspace:projects-discovered",label:"Workspace projects discovered",status:n.length>0?"ok":"warn",scope:"workspace-aggregate",policyRuleId:"workspace-project-discovery",reason:n.length>0?`${n.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:s>0?"warn":"ok",scope:"workspace-aggregate",policyRuleId:"workspace-advisory-warning-gate",reason:s>0?`${s} advisory warning(s) detected.`:"No advisory warnings detected."});}return t}async function Qe(e$1,n=true){let i=a.basename(e$1);try{let g=a.join(e$1,".rapidkit-workspace");await r.pathExists(g)&&(i=(await r.readJSON(g)).name||i);}catch{try{let g=a.join(e$1,".rapidkit","config.json");i=(await r.readJSON(g)).workspace_name||i;}catch{}}let[t,c]=await Promise.all([Fe(),Lt(e$1)]),o={workspacePath:e$1,workspaceName:i,python:t.python,poetry:t.poetry,pipx:t.pipx,go:t.go,rapidkitCore:t.rapidkitCore,projects:[]};e.debug(`Workspace scan found ${c.length} project(s)`);let s=await Vt(e$1,c),d=a.join(e$1,".rapidkit","reports","doctor-workspace-cache.json"),u=n?await Jt(d,s):null;if(u){o.projects=u.projects;for(let g of o.projects)Ee(g,g.path);o.projectScanCached=true,e.debug(`Workspace project health cache hit: ${d}`);}else try{let g=await Promise.all(c.map(h=>De(h)));for(let h of g)Ee(h,h.path);o.projects=g,o.projectScanCached=false,await qt(d,{schemaVersion:et,signature:s,generatedAt:new Date().toISOString(),projects:g}),e.debug(`Workspace project health cache refreshed: ${d}`);}catch(g){e.debug(`Failed to scan workspace projects: ${g}`);}o.projectScanSignature=s,o.projectScanCachePath=d;let p=[o.python,o.poetry,o.pipx,o.go,o.rapidkitCore];if(o.healthScore=ct(p,o.projects),o.scoreBreakdown=lt([{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=ot(o.scoreBreakdown),o.rapidkitCore.status==="ok"){let g=o.rapidkitCore.message.match(/([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);g&&(o.coreVersion=g[1]);}let f=a.join(e$1,".rapidkit","reports","doctor-last-run.json"),m=await nt(f,"workspace");return o.driftDelta=Ht(m,o),o.evidencePath=await Ut(e$1,o,u?d:null),o}function Xe(e){return {name:e.name,path:e.path,framework:e.framework,frameworkKey:e.frameworkKey,importStack:e.importStack,runtimeFamily:e.runtimeFamily,projectKind:e.projectKind,supportTier:e.supportTier,frameworkConfidence:e.frameworkConfidence,kit:e.kit,venvActive:e.venvActive,depsInstalled:e.depsInstalled,hasEnvFile:e.hasEnvFile,modulesHealthy:e.modulesHealthy,missingModules:e.missingModules,hasTests:e.hasTests,hasDocker:e.hasDocker,hasCodeQuality:e.hasCodeQuality,vulnerabilities:e.vulnerabilities,coreInstalled:e.coreInstalled,coreVersion:e.coreVersion,lastModified:e.lastModified,stats:e.stats,issues:e.issues,fixCommands:e.fixCommands,probes:e.probes,commandCapabilities:e.commandCapabilities}}async function cn(e,n){let i=e||n.projectPath,t=a.join(i,".rapidkit","reports","doctor-project-last-run.json");try{await r.ensureDir(a.dirname(t));let c=n.project.issues.filter(o=>typeof o=="string"&&o.trim().length>0).slice(0,12);return await r.writeJSON(t,e$1({schemaVersion:b$2,evidenceType:"project",contract:me(),workspacePath:e||null,projectPath:n.projectPath,projectName:n.projectName,healthScore:n.healthScore,system:{python:n.python,poetry:n.poetry,pipx:n.pipx,go:n.go,rapidkitCore:n.rapidkitCore},project:n.project,driftDelta:n.driftDelta,summary:{scopeProvenance:n.scopeProvenance},scoreBreakdown:n.scoreBreakdown??[]},{commandId:"projectDoctor",exitCode:oe(n.healthScore,{}),generatedAt:new Date().toISOString(),blockers:c,runId:d$1()}),{spaces:2}),t}catch{return}}async function ln(e){let n=await de(e),i=await Fe(),t=await De(e,{allowNonRapidkit:true});Ee(t,e);let c=ct([i.python,i.poetry,i.pipx,i.go,i.rapidkitCore],[t]),o={workspacePath:n||void 0,projectPath:e,projectName:a.basename(e),python:i.python,poetry:i.poetry,pipx:i.pipx,go:i.go,rapidkitCore:i.rapidkitCore,project:t,healthScore:c};o.scoreBreakdown=lt([{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=ot(o.scoreBreakdown);let s=n||e,d=a.join(s,".rapidkit","reports","doctor-project-last-run.json"),u=await nt(d,"project");return o.driftDelta=Mt(u,o),o.evidencePath=await cn(n||void 0,o),o}function $(e,n){let i=e.status==="ok"?"\u2705":e.status==="warn"?"\u26A0\uFE0F":"\u274C",t=e.status==="ok"?l.green:e.status==="warn"?l.yellow:l.red;console.log(`${i} ${l.bold(n)}: ${t(e.message)}`),e.paths&&e.paths.length>0&&e.paths.forEach(c=>{let o=c.version?l.cyan(` -> ${c.version}`):"";console.log(` ${l.cyan("\u2022")} ${l.gray(c.location)}: ${l.dim(c.path)}${o}`);}),e.details&&console.log(` ${l.gray(e.details)}`);}function Ye(e){let n=e.issues.length>0,i=n?"\u26A0\uFE0F":"\u2705",t=n?l.yellow:l.green;if(console.log(`
|
|
1
|
+
import {b}from'./chunk-3YLMCP3V.js';import {c,a as a$2,b as b$2}from'./chunk-NFUXULIF.js';import {q as q$1}from'./chunk-YBS2HGO3.js';import {f as f$2,e}from'./chunk-4Q2ZZKGB.js';import {i,d,b as b$3,a as a$5}from'./chunk-UZW5QFRW.js';import {f}from'./chunk-6G2KSHP6.js';import {b as b$1,f as f$1,d as d$1,a as a$4,k,g,i as i$1}from'./chunk-Z5LKRG57.js';import {a as a$3}from'./chunk-2FIX2MDC.js';import {a as a$1}from'./chunk-HHJAANUC.js';import l from'chalk';import {execa}from'execa';import r from'fs-extra';import a from'path';var bt=[".eslintrc.js",".eslintrc.cjs",".eslintrc.json",".eslintrc.yaml",".eslintrc.yml","eslint.config.js","eslint.config.mjs","eslint.config.cjs"],xt=["tests","test","src/test","__tests__","e2e","playwright","cypress"],jt=["vitest.config.ts","vitest.config.js","vitest.config.mjs","jest.config.js","jest.config.ts","jest.config.mjs","playwright.config.ts","playwright.config.js","cypress.config.js","cypress.config.ts"],Ct=["src","app","pages"],Et=["dev","build","test","lint"];function Oe(e){let n=e?.scripts;if(!n||typeof n!="object"||Array.isArray(n))return {};let i={};for(let[t,c]of Object.entries(n))typeof c=="string"&&c.trim().length>0&&(i[t]=c);return i}async function Le(e,n){for(let c of bt)if(await r.pathExists(a.join(e,c)))return true;let i=n??(await r.pathExists(a.join(e,"package.json"))?await r.readJson(a.join(e,"package.json")):null);if(!i)return false;if(i.eslintConfig)return true;let t={...i.dependencies??{},...i.devDependencies??{}};return !!(t.eslint||t["@eslint/js"]||t["@eslint/eslintrc"])}async function Ve(e,n){for(let c of xt)if(await r.pathExists(a.join(e,c)))return true;for(let c of jt)if(await r.pathExists(a.join(e,c)))return true;let i=Oe(n);if(i.test||i["test:unit"]||i["test:e2e"]||i["test:ci"]||i["test:watch"])return true;let t={...n?.dependencies??{},...n?.devDependencies??{}};return t.vitest||t.jest||t["@playwright/test"]||t.cypress?true:await Pt(e)}async function Pt(e){let n=["src","app","pages","components"],i=/\.(test|spec)\.(tsx?|jsx?|vue|svelte)$/i,c=new Set(["node_modules",".git","dist","build",".next","coverage",".turbo"]);for(let o of n){let s=a.join(e,o);if(!await r.pathExists(s))continue;let d=[{dir:s,depth:0}];for(;d.length>0;){let u=d.shift();if(!u)break;let p=[];try{p=await r.readdir(u.dir);}catch{continue}for(let f of p){let m=a.join(u.dir,f);if(i.test(f))return true;if(!(u.depth>=3||c.has(f)||f.startsWith(".")))try{(await r.stat(m)).isDirectory()&&d.push({dir:m,depth:u.depth+1});}catch{continue}}}}return false}async function je(e){for(let n of Ct){let i=a.join(e,n);if(await r.pathExists(i))try{if((await r.readdir(i)).some(c=>!c.startsWith(".")))return true}catch{continue}}return false}function St(e){let n=e.key;return b$3(n).key}function $t(e,n,i){return a$5(n,i).some(c=>!!e[c])}async function Je(e){let{projectPath:n,detection:i,packageJsonData:t}=e,c=St(i),o=b$3(c),s=Oe(t),d=[],u=await r.pathExists(a.join(n,"package-lock.json"))||await r.pathExists(a.join(n,"pnpm-lock.yaml"))||await r.pathExists(a.join(n,"yarn.lock"))||await r.pathExists(a.join(n,"bun.lockb"));d.push({id:"frontend-lockfile-integrity",label:"Frontend lockfile integrity",status:u?"pass":"warn",severity:"warn",scope:"project-scoped",reason:u?"Node lockfile detected for deterministic dependency restore.":"No Node lockfile detected (package-lock/yarn.lock/pnpm-lock.yaml/bun.lockb).",recommendation:u?void 0:"Commit a lockfile for deterministic installs and CI parity."});let p=await r.pathExists(a.join(n,"tsconfig.json")),f=await r.pathExists(a.join(n,"jsconfig.json")),m=p||f;d.push({id:"frontend-typescript-surface",label:"TypeScript project surface",status:m?"pass":"warn",severity:"warn",scope:"project-scoped",reason:m?p?"tsconfig.json detected.":"jsconfig.json detected.":"No tsconfig.json or jsconfig.json detected.",recommendation:m?void 0:"Add tsconfig.json (or jsconfig.json) for typed frontend builds and IDE parity."});let g=o.fileHints.length>0&&o.fileHints.some(y=>r.pathExistsSync(a.join(n,y)));d.push({id:"frontend-framework-config",label:`${o.displayName} config surface`,status:g?"pass":"warn",severity:"warn",scope:"project-scoped",reason:g?`${o.displayName} configuration artifacts detected.`:`No ${o.displayName} config markers detected (${o.fileHints.join(", ")||"n/a"}).`,recommendation:g?void 0:"Keep framework config files in-repo for reproducible dev/build behavior."});for(let y of Et){let k=$t(s,c,y),b=y==="dev"||y==="build";d.push({id:`frontend-script-${y}`,label:`${y} script surface`,status:k?"pass":b?"fail":"warn",severity:b?"error":"warn",scope:"project-scoped",reason:k?`package.json exposes a ${y} script for ${o.displayName}.`:`No ${y} script detected for ${o.displayName}.`,recommendation:k?void 0:`Add a "${a$5(c,y)[0]??y}" script to package.json.`});}let h=await je(n);return d.push({id:"frontend-source-tree",label:"Frontend source tree",status:h?"pass":"warn",severity:"warn",scope:"project-scoped",reason:h?"Application source directories detected (src/app/pages).":"No frontend source directories detected under src/, app/, or pages/.",recommendation:h?void 0:"Ensure the scaffolded application tree exists before running lifecycle commands."}),d}function Rt(e){return [...new Set(e.filter(n=>n&&n.trim().length>0))]}function Ft(){let e=k().map(t=>a.join(t,a$4()?"poetry.exe":"poetry")),n=a$4()?[a.join(process.env.APPDATA||"","Python","Scripts","poetry.exe"),a.join(process.env.USERPROFILE||"","AppData","Roaming","Python","Scripts","poetry.exe")]:[],i=a$4()?[]:["/usr/local/bin/poetry","/usr/bin/poetry"];return Rt([...e,...n,...i])}function Dt(e){let n=k().map(u=>({location:"Global (user-local)",path:a.join(u,a$4()?"rapidkit.exe":"rapidkit")})),i=[{location:"Global (pipx)",path:a.join(e,".local","bin","rapidkit")},{location:"Global (pipx)",path:a.join(e,"AppData","Roaming","Python","Scripts","rapidkit.exe")},{location:"Global (pyenv)",path:a.join(e,".pyenv","shims","rapidkit")},{location:"Global (system)",path:"/usr/local/bin/rapidkit"},{location:"Global (system)",path:"/usr/bin/rapidkit"}],t=g(a.join(process.cwd(),".venv")),c=i$1(process.cwd()),o=[{location:"Workspace (.venv)",path:t},...c.map(u=>({location:"Workspace (launcher)",path:u}))],s=[...n,...i,...o],d=new Set;return s.filter(u=>d.has(u.path)?false:(d.add(u.path),true))}function At(e){let n=new Map([["Workspace (.venv)",0],["Global (user-local)",1],["Global (pipx)",2],["Global (pyenv)",3],["Global (system)",4]]);return [...e].sort((i,t)=>{let c=n.get(i.location)??Number.MAX_SAFE_INTEGER,o=n.get(t.location)??Number.MAX_SAFE_INTEGER;return c!==o?c-o:i.path.localeCompare(t.path)})}function ee(e){let n=0,i=e.issues.some(t=>t.toLowerCase().includes("environment file missing"));return e.hasEnvFile===false&&!i&&(n+=1),typeof e.vulnerabilities=="number"&&e.vulnerabilities>0&&(n+=1),n}function Ce(e){return e.filter(n=>ee(n)>0).length}function $e(e){return e.reduce((n,i)=>n+ee(i),0)}var It="doctor-project-scan-v2",et="doctor-workspace-cache-v2",Nt=Object.freeze({version:"doctor-evidence-v1",scoringPolicyVersion:"doctor-score-policy-v1",generatedBy:"rapidkit-npm",deterministicScoreBreakdown:true,scopeModel:"workspace-aggregate-or-project-scoped"});function me(){return {...Nt}}function fe(e){return !e||e.total<=0?null:Math.round(e.passed/e.total*100)}function tt(e){return typeof e=="number"?e:Array.isArray(e)?e.length:0}async function nt(e,n){try{if(!await r.pathExists(e))return null;let i=await r.readJSON(e);return c(i,n)?i:null}catch{return null}}function st(e,n){if(!e?.system)return [];let i=[{id:"python",current:n.python},{id:"poetry",current:n.poetry},{id:"pipx",current:n.pipx},{id:"go",current:n.go},{id:"rapidkitCore",current:n.rapidkitCore}],t=[];for(let c of i){let o=e.system?.[c.id]?.status;!o||o===c.current.status||t.push({id:c.id,from:o,to:c.current.status});}return t}function Ht(e,n){let i=new Map;for(let g of n.projects)i.set(g.path||g.name,g.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:[],c=new Map;for(let g of t){let h=g.path||g.name;h&&c.set(h,tt(g.issues));}let o=0,s=0,d=new Set,u=new Set,p=new Set([...Array.from(c.keys()),...Array.from(i.keys())]);for(let g of p){let h=c.get(g)??0,y=i.get(g)??0;y>h?(o+=y-h,d.add(g)):y<h&&(s+=h-y,u.add(g));}let f=fe(e.healthScore),m=fe(n.healthScore);return {baselineAvailable:true,previousGeneratedAt:e.generatedAt,newIssueCount:o,resolvedIssueCount:s,netIssueDelta:o-s,scoreDeltaPercent:f===null||m===null?null:m-f,systemStatusChanges:st(e,{python:n.python,poetry:n.poetry,pipx:n.pipx,go:n.go,rapidkitCore:n.rapidkitCore}),regressedProjects:Array.from(d).sort(),improvedProjects:Array.from(u).sort()}}function Mt(e,n){if(!e)return {baselineAvailable:false,newIssueCount:0,resolvedIssueCount:0,netIssueDelta:0,scoreDeltaPercent:null,systemStatusChanges:[],regressedProjects:[],improvedProjects:[]};let i=tt(e.project?.issues),t=n.project.issues.length,c=Math.max(t-i,0),o=Math.max(i-t,0),s=fe(e.healthScore),d=fe(n.healthScore),u=n.project.path||n.project.name;return {baselineAvailable:true,previousGeneratedAt:e.generatedAt,newIssueCount:c,resolvedIssueCount:o,netIssueDelta:c-o,scoreDeltaPercent:s===null||d===null?null:d-s,systemStatusChanges:st(e,{python:n.python,poetry:n.poetry,pipx:n.pipx,go:n.go,rapidkitCore:n.rapidkitCore}),regressedProjects:c>0?[u]:[],improvedProjects:o>0?[u]:[]}}function ot(e){let n=e??[],i=0,t=0;for(let s of n){if(s.scope==="project-scoped"){i+=1;continue}(s.scope==="workspace-aggregate"||s.scope==="host-system")&&(t+=1);}let c=i>0&&t>0?1:0,o=c>0?"mixed":i>0?"scoped":t>0?"aggregated":"unknown";return {scopedCount:i,aggregatedCount:t,mixedCount:c,dominantScope:o}}function R(e,n){return a$4()?`cd "${e}"; ${n}`:`cd ${e} && ${n}`}function q(e){return a$4()?R(e,"Copy-Item .env.example .env"):R(e,"cp .env.example .env")}function Tt(e){return e==="FastAPI"||e==="NestJS"?"first-class":e==="Django"||e==="Flask"||e==="Express"||e==="Fastify"||e==="Koa"||e==="Go/Fiber"||e==="Go/Gin"||e==="Spring Boot"||e==="Rust"||e==="Phoenix"||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 Bt(e){return e==="Next.js"||e==="Remix"||e==="Nuxt"||e==="React"||e==="Vue"||e==="Angular"||e==="SvelteKit"||e==="Svelte"||e==="Vite"||e==="Astro"||e==="Solid"?"frontend":e==="Unknown"||e==="Node.js"||e==="Python"?"generic":"backend"}function _t(e){return e==="NestJS"||e==="Next.js"||e==="Remix"||e==="Nuxt"||e==="React"||e==="Vue"||e==="Angular"||e==="SvelteKit"||e==="Svelte"||e==="Vite"||e==="Astro"||e==="Solid"||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 Ee(e,n){let i=q$1(n);e.commandCapabilities=i,e.supportTier=i.frameworkSupportTier;}function pe(e,n,i,t){e.framework=n,e.frameworkConfidence=i,e.supportTier=Tt(n),e.projectKind=Bt(n),e.runtimeFamily=_t(n);}function it(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 Re(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 "nextjs":return "Next.js";case "remix":return "Remix";case "nuxt":return "Nuxt";case "react":return "React";case "vite":return "Vite";case "vue":return "Vue";case "sveltekit":return "SvelteKit";case "svelte":return "Svelte";case "angular":return "Angular";case "astro":return "Astro";case "solid":return "Solid";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 Gt(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 Kt(e,n){e.framework=Re(n),e.frameworkKey=n.key,e.importStack=n.importStack,e.frameworkConfidence=n.confidence,e.supportTier=n.supportTier,e.projectKind="frontend",e.runtimeFamily=it(n.runtime);}function G(e,n){e.framework=Re(n),e.frameworkKey=n.key,e.importStack=n.importStack,e.frameworkConfidence=n.confidence,e.supportTier=n.supportTier,e.projectKind=Gt(n)?"generic":"backend",e.runtimeFamily=it(n.runtime);}function Wt(e){let n=e.dependencies,i=e.scripts??{},t=(e.kitName??"").toLowerCase(),c=s=>!!n[s],o=Object.values(i).filter(s=>typeof s=="string").join(" ").toLowerCase();return c("next")||o.includes("next ")?{framework:"Next.js",confidence:"high"}:c("nuxt")||o.includes("nuxt ")?{framework:"Nuxt",confidence:"high"}:c("@nestjs/core")||t.startsWith("nestjs.")?{framework:"NestJS",confidence:"high"}:c("express")?{framework:"Express",confidence:"high"}:c("fastify")?{framework:"Fastify",confidence:"high"}:c("koa")?{framework:"Koa",confidence:"high"}:c("@angular/core")?{framework:"Angular",confidence:"high"}:c("@sveltejs/kit")||o.includes("svelte-kit")?{framework:"SvelteKit",confidence:"high"}:c("vue")?{framework:"Vue",confidence:"medium"}:c("react")&&c("react-dom")?{framework:"React",confidence:"medium"}:{framework:"Node.js",confidence:"low"}}async function Ot(e){let n=i(e);return n.runtime!=="python"?{framework:"Python",confidence:"low"}:{framework:Re(n),confidence:n.confidence}}async function qe(e){try{let n=await r.stat(e);return `${a.basename(e)}:${n.isDirectory()?"d":"f"}:${n.size}:${n.mtimeMs}`}catch{return `${a.basename(e)}:missing`}}async function Lt(e){try{let n=new Set([".git",".venv","node_modules",".rapidkit","dist","build","coverage","__pycache__"]),i=new Set;await le(e)&&i.add(e);let t=await a$1(e);for(let o of t){let s=a.isAbsolute(o.path)?o.path:a.join(e,o.path);await le(s)&&i.add(s);}let c=async(o,s)=>{if(s<0)return;let d=await at(o);for(let u of d){if(rt(u,n))continue;let p=a.join(o,u);if(await le(p)){i.add(p);continue}s>0&&await c(p,s-1);}};return await c(e,1),i.size===0&&(await sn(e,3,n)).forEach(s=>i.add(s)),Array.from(i).sort((o,s)=>o.localeCompare(s))}catch{return []}}async function Vt(e,n){let i=[a.join(e,".rapidkit-workspace"),a.join(e,".rapidkit","workspace.json"),a.join(e,".rapidkit","imported-projects.json"),a.join(e,".rapidkit","policies.yml"),a.join(e,".rapidkit","toolchain.lock"),a.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"],c=await Promise.all(i.map(qe)),o=await Promise.all(n.map(async s=>{let d=await Promise.all(t.map(u=>qe(a.join(s,u))));return `${s}::${d.join("|")}`}));return [It,...c,...o].join("||")}async function Jt(e,n){try{if(!await r.pathExists(e))return null;let i=await r.readJSON(e);return !i||i.signature!==n||!Array.isArray(i.projects)||typeof i.schemaVersion=="string"&&i.schemaVersion!==et?null:i}catch{return null}}async function qt(e,n){try{await r.ensureDir(a.dirname(e)),await r.writeJSON(e,n,{spaces:2});}catch{}}async function Ut(e$1,n,i){let t=a.join(e$1,".rapidkit","reports","doctor-last-run.json");try{await r.ensureDir(a.dirname(t));let c=[];for(let o of n.projects)for(let s of o.issues??[])typeof s=="string"&&s.trim()&&c.push(`${o.name}: ${s.trim()}`);for(let[o,s]of [["python",n.python],["rapidkitCore",n.rapidkitCore]])if(s?.status==="error"){let d=typeof s.message=="string"?s.message:`${o} check failed`;c.push(`${o}: ${d}`);}return await r.writeJSON(t,f$2({schemaVersion:a$2,evidenceType:"workspace",contract:me(),workspacePath:e$1,workspaceName:n.workspaceName,projectScanCached:n.projectScanCached??false,projectScanSignature:n.projectScanSignature,cachePath:i,healthScore:n.healthScore,system:{python:n.python,poetry:n.poetry,pipx:n.pipx,go:n.go,rapidkitCore:n.rapidkitCore,versions:{core:n.coreVersion,npm:n.npmVersion}},projects:n.projects,summary:{totalProjects:n.projects.length,totalIssues:n.projects.reduce((o,s)=>o+s.issues.length,0),projectAdvisoryWarningProjects:Ce(n.projects),projectAdvisoryWarnings:$e(n.projects),hasSystemErrors:[n.python,n.rapidkitCore].some(o=>o.status==="error"),scopeProvenance:n.scopeProvenance},driftDelta:n.driftDelta,scoreBreakdown:n.scoreBreakdown??[]},{commandId:"checkWorkspaceHealth",exitCode:oe(n.healthScore,{}),generatedAt:new Date().toISOString(),blockers:c.slice(0,12),runId:e()}),{spaces:2}),t}catch{return}}async function Fe(){let[e,n,i,t,c]=await Promise.all([zt(),Qt(),Xt(),Yt(),Zt()]);return {python:e,poetry:n,pipx:i,go:t,rapidkitCore:c}}async function zt(){let e=d$1();for(let n of e)try{let{stdout:i}=await execa(n,["--version"],{timeout:3e3}),t=i.match(/Python (\d+\.\d+\.\d+)/);if(t){let c=t[1],[o,s]=c.split(".").map(Number);return o<3||o===3&&s<10?{status:"warn",message:`Python ${c} (requires 3.10+)`,details:`${n} found but version is below minimum requirement`}:{status:"ok",message:`Python ${c}`,details:`Using ${n}`}}}catch{continue}return {status:"error",message:"Python not found",details:"Install Python 3.10+ and ensure it's in PATH"}}async function Qt(){try{let{stdout:e}=await execa("poetry",["--version"],{timeout:3e3}),n=e.match(/Poetry .*version ([\d.]+)/);return n?{status:"ok",message:`Poetry ${n[1]}`,details:"Available for dependency management"}:{status:"warn",message:"Poetry version unknown"}}catch{let e=d$1().map(n=>({cmd:n,args:n==="py"?["-3","-m","poetry","--version"]:["-m","poetry","--version"]}));for(let n of e)try{let{stdout:i}=await execa(n.cmd,n.args,{timeout:3e3,shell:b$1()}),t=i.match(/Poetry .*version ([\d.]+)/)||i.match(/([\d.]+)/);return {status:"ok",message:t?.[1]?`Poetry ${t[1]}`:"Poetry detected",details:`Available via ${n.cmd} ${n.args.join(" ")}`}}catch{continue}for(let n of Ft())try{if(!await r.pathExists(n))continue;let{stdout:i}=await execa(n,["--version"],{timeout:3e3,shell:b$1()}),t=i.match(/Poetry .*version ([\d.]+)/)||i.match(/([\d.]+)/);return {status:"ok",message:t?.[1]?`Poetry ${t[1]}`:"Poetry detected",details:`Available at ${n}`}}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$1();for(let n of e)try{let i=n==="py"?["-3","-m","pipx","--version"]:["-m","pipx","--version"],{stdout:t}=await execa(n,i,{timeout:3e3,shell:b$1()});return {status:"ok",message:`pipx ${t.trim()}`,details:`Available via ${n} ${i.join(" ")}`}}catch{continue}return {status:"warn",message:"pipx not installed",details:"Optional: Install for isolated Python tools"}}}async function Yt(){try{let{stdout:e}=await execa("go",["version"],{timeout:3e3}),n=e.match(/go version go(\d+\.\d+(?:\.\d+)?)/);return n?{status:"ok",message:`Go ${n[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 Zt(){let e=process.env.HOME||process.env.USERPROFILE||"",n=[],i=Dt(e);for(let{location:c,path:o}of i)try{if(await r.pathExists(o)){let{stdout:s,exitCode:d}=await execa(o,["--version"],{timeout:3e3,reject:false});if(d===0&&(s.includes("RapidKit Version")||s.includes("RapidKit"))){let u=s.match(/v?([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);u&&n.push({location:c,path:o,version:u[1]});}}}catch{continue}if(n.length>0){let c=n.filter(s=>s.location!=="Workspace (launcher)");if(c.length>0){let s=At(c),d=s[0].version,u=s.some(m=>m.location==="Workspace (.venv)"),p=s.some(m=>m.location.startsWith("Global (")),f=!u&&p?"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:s.map(m=>({location:m.location,path:m.path,version:m.version}))}}return {status:"ok",message:`RapidKit Core ${n[0].version}`,details:"Detected via workspace launcher"}}try{let{stdout:c,exitCode:o}=await execa("rapidkit",["--version"],{timeout:3e3,reject:false});if(o===0&&(c.includes("RapidKit Version")||c.includes("RapidKit"))){let s=c.match(/v?([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);if(s)return {status:"ok",message:`RapidKit Core ${s[1]}`,details:"Available via PATH"}}}catch{}try{let{stdout:c,exitCode:o}=await execa("poetry",["run","rapidkit","--version"],{timeout:3e3,reject:false});if(o===0&&(c.includes("RapidKit Version")||c.includes("RapidKit"))){let s=c.match(/v?([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);if(s)return {status:"ok",message:`RapidKit Core ${s[1]}`,details:"Available via Poetry"}}}catch{}let t=d$1();for(let c of t)try{let{stdout:o,exitCode:s}=await execa(c,["-c","import rapidkit_core; print(rapidkit_core.__version__)"],{timeout:3e3,reject:false});if(s===0&&o&&!o.includes("Traceback")&&!o.includes("ModuleNotFoundError")){let d=o.trim();if(d)return {status:"ok",message:`RapidKit Core ${d}`,details:`Available in ${c} environment`}}}catch{continue}return {status:"error",message:"RapidKit Core not installed",details:"Install with: pipx install rapidkit-core"}}async function T(e,n,i){let t=a.join(e,"Dockerfile");n.hasDocker=await r.pathExists(t);let c=a.join(e,"tests"),o=a.join(e,"test"),s=a.join(e,"src","test"),d=await r.pathExists(c)||await r.pathExists(o)||await r.pathExists(s),u=false;if(n.framework==="Go/Fiber"||n.framework==="Go/Gin")try{let p=[{dir:e,depth:0}],f=4,m=new Set([".git",".venv","node_modules","dist","build","vendor"]);for(;p.length>0&&!u;){let g=p.shift();if(!g)break;let h=[];try{h=await r.readdir(g.dir);}catch{continue}for(let y of h){let k=a.join(g.dir,y),b;try{b=await r.stat(k);}catch{continue}if(b.isFile()&&y.endsWith("_test.go")){u=true;break}b.isDirectory()&&g.depth<f&&!m.has(y)&&!y.startsWith(".")&&p.push({dir:k,depth:g.depth+1});}}}catch{}if(n.hasTests=d||u,n.runtimeFamily==="node"&&!n.hasTests&&(n.hasTests=await Ve(e,i)),n.runtimeFamily==="node")n.hasCodeQuality=await Le(e,i);else if(n.framework==="Go/Fiber"||n.framework==="Go/Gin"){let p=a.join(e,".golangci.yml"),f=a.join(e,".golangci.yaml"),m=a.join(e,"Makefile"),g=await r.pathExists(m)&&(await r.readFile(m,"utf8")).includes("golangci-lint");n.hasCodeQuality=await r.pathExists(p)||await r.pathExists(f)||g;}else if(n.runtimeFamily==="python"){let p=a.join(e,"ruff.toml"),f=a.join(e,"pyproject.toml");if(await r.pathExists(f))try{let m=await r.readFile(f,"utf8");n.hasCodeQuality=m.includes("[tool.ruff]")||await r.pathExists(p);}catch{n.hasCodeQuality=await r.pathExists(p);}}else if(n.framework==="Spring Boot"){let p=a.join(e,"pom.xml");if(await r.pathExists(p))try{let f=await r.readFile(p,"utf8");n.hasCodeQuality=f.includes("spotless")||f.includes("checkstyle")||f.includes("pmd")||f.includes("maven-enforcer-plugin");}catch{n.hasCodeQuality=false;}}try{if(n.runtimeFamily==="node"){let{stdout:p}=await execa("npm",["audit","--json"],{cwd:e,reject:false});if(p)try{let m=JSON.parse(p).metadata?.vulnerabilities;m&&(n.vulnerabilities=(m.high||0)+(m.critical||0)+(m.moderate||0));}catch{}}else if(n.runtimeFamily==="python"){let p=a.join(e,".venv"),f=f$1(p);if(await r.pathExists(f))try{let{stdout:m}=await execa(f,["-m","pip","list","--format=json"],{timeout:5e3,reject:false});if(m){JSON.parse(m);n.vulnerabilities=0;}}catch{}}}catch{}}function I(e,n){e.probes||(e.probes=[]),e.probes.push(n);}async function en(e,n){let i=n.runtimeFamily||"unknown";if(n.projectKind==="backend"||n.projectKind==="generic"){if(i==="node"){let c=await r.pathExists(a.join(e,"package-lock.json"))||await r.pathExists(a.join(e,"pnpm-lock.yaml"))||await r.pathExists(a.join(e,"yarn.lock"));I(n,{id:"adapter-node-lockfile-integrity",label:"Node adapter lockfile integrity",status:c?"pass":"warn",severity:"warn",scope:"project-scoped",reason:c?"Node lockfile detected for deterministic dependency restore.":"No Node lockfile detected (package-lock/yarn.lock/pnpm-lock.yaml).",recommendation:c?void 0:"Commit a lockfile for deterministic installs and CI parity."});let o=await r.pathExists(a.join(e,"src/main.ts"))||await r.pathExists(a.join(e,"src/main.js"))||await r.pathExists(a.join(e,"src/server.ts"))||await r.pathExists(a.join(e,"src/server.js"));I(n,{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(i==="python"){let c=await r.pathExists(a.join(e,"poetry.lock"))||await r.pathExists(a.join(e,"requirements.txt"))||await r.pathExists(a.join(e,"uv.lock"));I(n,{id:"adapter-python-lockfile-integrity",label:"Python adapter dependency integrity",status:c?"pass":"warn",severity:"warn",scope:"project-scoped",reason:c?"Python dependency contract file detected.":"No Python dependency contract file detected (poetry.lock/requirements/uv.lock).",recommendation:c?void 0:"Pin dependency contract for deterministic setup and reproducible CI."});let o=await r.pathExists(a.join(e,"app/main.py"))||await r.pathExists(a.join(e,"main.py"))||await r.pathExists(a.join(e,"manage.py"));I(n,{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(i==="java"){let c=await r.pathExists(a.join(e,"mvnw"))||await r.pathExists(a.join(e,"gradlew"));I(n,{id:"adapter-java-build-wrapper",label:"Java adapter build wrapper",status:c?"pass":"warn",severity:"warn",scope:"project-scoped",reason:c?"Build wrapper detected (mvnw/gradlew).":"No Java build wrapper detected.",recommendation:c?void 0:"Commit mvnw or gradlew for reproducible enterprise pipelines."});return}if(i==="go"){let c=await r.pathExists(a.join(e,"go.sum"));I(n,{id:"adapter-go-module-integrity",label:"Go adapter module integrity",status:c?"pass":"warn",severity:"warn",scope:"project-scoped",reason:c?"go.sum detected for deterministic module verification.":"go.sum missing; module integrity baseline is incomplete.",recommendation:c?void 0:"Generate and commit go.sum in the repository baseline."});}}}async function tn(e,n){let i=[a.join(e,".rapidkit","doctor.adapters.json"),a.join(e,"doctor.adapters.json")];for(let t of i)if(await r.pathExists(t))try{let c=await r.readJSON(t),o=Array.isArray(c?.checks)?c.checks:[];for(let s=0;s<o.length;s+=1){let d=o[s]||{},u=Array.isArray(d.runtimes)?d.runtimes:[];if(u.length>0&&!u.includes(n.runtimeFamily||"unknown"))continue;let p=typeof d.id=="string"&&d.id.trim().length>0?d.id.trim():`adapter-check-${s+1}`,f=typeof d.label=="string"&&d.label.trim().length>0?d.label.trim():p,m=d.severity||"warn",g=Array.isArray(d.anyOfPaths)?d.anyOfPaths.filter(Boolean):[],h=Array.isArray(d.allOfPaths)?d.allOfPaths.filter(Boolean):[],y=g.length===0;for(let L of g)if(await r.pathExists(a.join(e,L))){y=true;break}let k=true;for(let L of h)if(!await r.pathExists(a.join(e,L))){k=false;break}let b=y&&k;I(n,{id:p,label:f,status:b?"pass":m==="error"?"fail":"warn",severity:m,scope:"project-scoped",reason:b?d.passReason||"Custom adapter contract satisfied.":d.failReason||`Custom adapter check failed from ${a.basename(t)}.`,recommendation:d.recommendation});}}catch{I(n,{id:"custom-adapter-config",label:"Custom doctor adapter configuration",status:"warn",severity:"warn",scope:"project-scoped",reason:`Failed to parse ${a.basename(t)}.`,recommendation:"Fix JSON syntax in doctor.adapters.json to re-enable adapter checks."});}}async function B(e,n){if(!(n.projectKind==="backend"||n.projectKind==="generic"))return;let t=a.join(e,".env"),c=a.join(e,".env.example"),o=await r.pathExists(t)||await r.pathExists(c)||await r.pathExists(a.join(e,"config"));I(n,{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 s={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=n.runtimeFamily||"unknown",u=s[d]||s.unknown,p=false;for(let g of u)if(await r.pathExists(a.join(e,g))){p=true;break}I(n,{id:"migration-surface",label:"Migration/readiness surface",status:p?"pass":"warn",severity:"warn",scope:"project-scoped",reason:p?"Migration or schema evolution markers detected.":"No migration markers detected for this backend runtime.",recommendation:p?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"],m=false;for(let g of f)if(await r.pathExists(a.join(e,g))){m=true;break}I(n,{id:"runtime-health-surface",label:"Runtime health probe surface",status:m?"pass":"warn",severity:"warn",scope:"project-scoped",reason:m?"Health endpoint/config markers detected.":"No explicit runtime health endpoint markers detected.",recommendation:m?void 0:"Expose a deterministic health endpoint and keep it covered in verify pack."}),await en(e,n);}async function nn(e,n,i,t){let c=await Je({projectPath:e,detection:t,packageJsonData:i});for(let o of c)I(n,o);}async function _(e,n){let i=[a.join(e,".rapidkit","doctor.probes.json"),a.join(e,"doctor.probes.json")];for(let t of i)if(await r.pathExists(t))try{let c=await r.readJSON(t),o=Array.isArray(c?.probes)?c.probes:[];for(let s=0;s<o.length;s+=1){let d=o[s]||{},u=typeof d.id=="string"&&d.id.trim().length>0?d.id.trim():`custom-probe-${s+1}`,p=typeof d.label=="string"&&d.label.trim().length>0?d.label.trim():u,f=d.severity||"warn",m=Array.isArray(d.anyOfPaths)?d.anyOfPaths.filter(Boolean):[],g=Array.isArray(d.allOfPaths)?d.allOfPaths.filter(Boolean):[],h=m.length===0;for(let b of m)if(await r.pathExists(a.join(e,b))){h=true;break}let y=true;for(let b of g)if(!await r.pathExists(a.join(e,b))){y=false;break}let k=h&&y;I(n,{id:u,label:p,status:k?"pass":f==="error"?"fail":"warn",severity:f,scope:"project-scoped",reason:k?"Custom probe contract satisfied.":`Custom probe failed from ${a.basename(t)}.`,recommendation:d.recommendation});}}catch{I(n,{id:"custom-probe-config",label:"Custom doctor probe configuration",status:"warn",severity:"warn",scope:"project-scoped",reason:`Failed to parse ${a.basename(t)}.`,recommendation:"Fix JSON syntax in doctor.probes.json to re-enable custom probes."});}await tn(e,n);}async function De(e,n={}){let t={name:a.basename(e),path:e,venvActive:false,depsInstalled:false,coreInstalled:false,issues:[],fixCommands:[]},c=n.allowNonRapidkit===true,o=a.join(e,".rapidkit");if(!await r.pathExists(o)){if(!c)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 w=a.join(e,"registry.json");if(await r.pathExists(w)){let v=await r.readJson(w);v.installed_modules&&(t.stats={modules:v.installed_modules.length});}}catch{}try{let{auditProjectModulePaths:w}=await import('./module-layout-NZ43RSC5.js'),v=await w(e);if(v.issues.length>0){for(let C of v.issues)t.issues.push(`${C.message} (${C.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 s=null;try{let w=a.join(o,"project.json");if(await r.pathExists(w)){s=await r.readJson(w);let v=s?.kit_name||s?.kit;v&&(t.kit=v);}}catch{}try{let w=a.join(e,".git");if(await r.pathExists(w)){let{stdout:v}=await execa("git",["log","-1","--format=%cr"],{cwd:e,reject:false});v&&(t.lastModified=v.trim());}else {let v=await r.stat(e),F=Date.now()-v.mtime.getTime(),D=Math.floor(F/(1e3*60*60*24));t.lastModified=D===0?"today":`${D} day${D>1?"s":""} ago`;}}catch{}let d$1=a.join(e,"package.json"),u=a.join(e,"pyproject.toml"),p=a.join(e,"requirements.txt"),f=a.join(e,"go.mod"),m=a.join(e,"pom.xml"),g=a.join(e,"build.sbt"),h=a.join(e,"Cargo.toml"),y=a.join(e,"mix.exs"),k=a.join(e,"deps.edn"),b=a.join(e,"project.clj"),L=a.join(e,"deno.json"),K=a.join(e,"deno.jsonc"),U=a.join(e,"bun.lockb"),z=a.join(e,"bun.lock"),V=a.join(e,"composer.json"),ie=a.join(e,"Gemfile"),Q=await r.pathExists(d$1),W=await r.pathExists(u)||await r.pathExists(p),N=await r.pathExists(V),ne=await r.pathExists(ie),ae=await r.pathExists(h),mt=await r.pathExists(y),ft=await r.pathExists(k)||await r.pathExists(b),gt=await r.pathExists(g),ht=await r.pathExists(L)||await r.pathExists(K),ue=s?.runtime==="dotnet";try{ue=ue||await Ue(e,".csproj",3)||await Ue(e,".sln",2);}catch{ue=s?.runtime==="dotnet";}let yt=await r.pathExists(f)||s?.runtime==="go"||typeof s?.kit_name=="string"&&(s.kit_name.startsWith("gofiber")||s.kit_name.startsWith("gogin")),Ae=Q&&(await r.pathExists(U)||await r.pathExists(z)||typeof s?.packageManager=="string"&&(s?.packageManager).toLowerCase().startsWith("bun@"));if(yt){G(t,i(e,s??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 w=a.join(e,"go.sum");return await r.pathExists(w)?t.depsInstalled=true:(t.depsInstalled=false,t.issues.push("Go dependencies not downloaded (go.sum missing)"),t.fixCommands?.push(R(e,"go mod tidy"))),await T(e,t),await B(e,t),await _(e,t),t}if(await r.pathExists(m)||s?.runtime==="java"||typeof s?.kit_name=="string"&&s.kit_name.startsWith("springboot")){G(t,i(e,s??null)),t.venvActive=true,t.coreInstalled=false;let w=await r.pathExists(m),v=await r.pathExists(a.join(e,"build.gradle"))||await r.pathExists(a.join(e,"build.gradle.kts")),C=await r.pathExists(a.join(e,"mvnw"))||await r.pathExists(a.join(e,"mvnw.cmd")),F=await r.pathExists(a.join(e,"gradlew"))||await r.pathExists(a.join(e,"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(w){if(!C)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(v&&!F)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 D=a.join(e,"target"),A=a.join(e,"build","libs"),H=a.join(e,".rapidkit","cache","java","m2"),j=a.join(e,".rapidkit","cache","java","gradle");t.depsInstalled=await r.pathExists(D)||await r.pathExists(A)||await r.pathExists(H)||await r.pathExists(j),t.depsInstalled||(t.issues.push("Java dependencies are not warmed or built yet"),t.fixCommands?.push(R(e,"rapidkit init")));let P=a.join(e,".env");if(t.hasEnvFile=await r.pathExists(P),!t.hasEnvFile){let X=a.join(e,".env.example");await r.pathExists(X)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(q(e)));}let J=a.join(e,"src","main","resources","application.yml");if(await r.pathExists(J))try{let X=await r.readFile(J,"utf-8");/include:\s*[^\n]*health/i.test(X)||/management:\s*[\s\S]*endpoint:\s*[\s\S]*health:/i.test(X)||(t.issues.push("Actuator health endpoint exposure is not clearly configured in application.yml"),t.fixCommands?.push(R(e,"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 T(e,t),await B(e,t),await _(e,t),t}if(ae){G(t,i(e,s??null)),t.venvActive=true,t.coreInstalled=false;let w=a.join(e,"Cargo.lock"),v=a.join(e,"target");t.depsInstalled=await r.pathExists(w)||await r.pathExists(v),t.depsInstalled||(t.issues.push("Rust dependencies are not resolved yet (Cargo.lock/target missing)"),t.fixCommands?.push(R(e,"cargo fetch")));let C=a.join(e,".env");if(t.hasEnvFile=await r.pathExists(C),!t.hasEnvFile){let F=a.join(e,".env.example");await r.pathExists(F)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(q(e)));}return await T(e,t),await B(e,t),await _(e,t),t}if(mt){G(t,i(e,s??null)),t.venvActive=true,t.coreInstalled=false;let w=a.join(e,"mix.lock"),v=a.join(e,"deps");t.depsInstalled=await r.pathExists(w)||await r.pathExists(v),t.depsInstalled||(t.issues.push("Elixir dependencies not installed (mix.lock/deps missing)"),t.fixCommands?.push(R(e,"mix deps.get")));let C=a.join(e,".env");if(t.hasEnvFile=await r.pathExists(C),!t.hasEnvFile){let F=a.join(e,".env.example");await r.pathExists(F)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(q(e)));}return await T(e,t),await B(e,t),await _(e,t),t}if(ft){G(t,i(e,s??null)),t.venvActive=true,t.coreInstalled=false;let w=a.join(e,".cpcache"),v=a.join(e,"target"),C=await r.pathExists(k)||await r.pathExists(b);return t.depsInstalled=await r.pathExists(w)||await r.pathExists(v)||C,t.depsInstalled||(t.issues.push("Clojure dependency cache not initialized"),t.fixCommands?.push(R(e,"clojure -P"))),await T(e,t),await B(e,t),await _(e,t),t}if(gt){G(t,i(e,s??null)),t.venvActive=true,t.coreInstalled=false;let w=a.join(e,"target");t.depsInstalled=await r.pathExists(w),t.depsInstalled||(t.issues.push("Scala build artifacts missing (run dependency/build warmup)"),t.fixCommands?.push(R(e,"sbt compile")));let v=a.join(e,".env");if(t.hasEnvFile=await r.pathExists(v),!t.hasEnvFile){let C=a.join(e,".env.example");await r.pathExists(C)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(q(e)));}return await T(e,t),await B(e,t),await _(e,t),t}if(ht){G(t,i(e,s??null)),t.venvActive=true,t.coreInstalled=false,t.depsInstalled=true;let w=a.join(e,".env");if(t.hasEnvFile=await r.pathExists(w),!t.hasEnvFile){let v=a.join(e,".env.example");await r.pathExists(v)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(q(e)));}return await T(e,t),await B(e,t),await _(e,t),t}if(Q){let w=null;try{w=await r.readJson(d$1);}catch{w=null;}let v={...w?.dependencies??{},...w?.devDependencies??{}},C=w?.scripts??{},F=typeof s?.kit_name=="string"?s.kit_name.toLowerCase():typeof s?.kit=="string"?s.kit.toLowerCase():"",D=d(e,s),A=Wt({dependencies:v,scripts:C,kitName:F});if(Ae)pe(t,"Bun","high");else {let j=i(e,s??null);j.key==="nestjs"||j.key==="express"||j.key==="fastify"||j.key==="koa"?G(t,j):D.key!=="unknown"?Kt(t,D):j.key!=="unknown"&&j.key!=="node"?G(t,j):pe(t,A.framework,A.confidence);}t.venvActive=true;let H=a.join(e,"node_modules");if(await r.pathExists(H))try{let P=(await r.readdir(H)).filter(J=>!J.startsWith(".")&&!J.startsWith("_"));t.depsInstalled=P.length>0;}catch{t.depsInstalled=false;}if(t.depsInstalled||(t.issues.push("Dependencies not installed (node_modules empty or missing)"),t.fixCommands?.push(R(e,Ae?"bun install":"rapidkit init"))),t.coreInstalled=false,t.projectKind==="frontend"){let j=[".env",".env.local",".env.development",".env.development.local",".env.production",".env.production.local"];if((await Promise.all(j.map(J=>r.pathExists(a.join(e,J))))).some(Boolean))t.hasEnvFile=true;else {let J=a.join(e,".env.example");await r.pathExists(J)&&(t.hasEnvFile=false,t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(q(e)));}}else {let j=a.join(e,".env");if(t.hasEnvFile=await r.pathExists(j),!t.hasEnvFile){let P=a.join(e,".env.example");await r.pathExists(P)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(q(e)));}}if(t.projectKind==="frontend")t.modulesHealthy=await je(e),t.missingModules=[];else {let j=a.join(e,"src");if(t.modulesHealthy=true,t.missingModules=[],await r.pathExists(j))try{let P=await r.readdir(j);t.modulesHealthy=P.length>0;}catch{t.modulesHealthy=false;}}return await T(e,t,w),t.projectKind==="frontend"?await nn(e,t,w,D.key!=="unknown"?D:d(e,s)):await B(e,t),await _(e,t),t}if(W){let w=await Ot(e);pe(t,w.framework,w.confidence);let v=a.join(e,".venv");if(await r.pathExists(v)){t.venvActive=true;let A=f$1(v);if(await r.pathExists(A)){try{let{stdout:P}=await execa(A,["-c","import rapidkit_core; print(rapidkit_core.__version__)"],{timeout:2e3});t.coreInstalled=true,t.coreVersion=P.trim();}catch{t.coreInstalled=false;}let H="fastapi";t.framework==="Django"?H="django":t.framework==="Flask"?H="flask":t.framework==="Python"&&(H="");let j=true;if(H)try{await execa(A,["-c",`import ${H}`],{timeout:2e3}),t.depsInstalled=true,j=false;}catch{j=true;}if(j)try{let P=a.join(v,"lib");if(await r.pathExists(P)){let X=(await r.readdir(P)).find(re=>re.startsWith("python"));if(X){let re=a.join(P,X,"site-packages");if(await r.pathExists(re)){let kt=(await r.readdir(re)).filter(ge=>!ge.startsWith("_")&&!ge.includes("dist-info")&&!["pip","setuptools","wheel","pkg_resources"].includes(ge));t.depsInstalled=kt.length>0;}}}t.depsInstalled||(t.issues.push("Dependencies not installed"),t.fixCommands?.push(R(e,"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(R(e,"rapidkit init"));let C=a.join(e,".env");if(t.hasEnvFile=await r.pathExists(C),!t.hasEnvFile){let A=a.join(e,".env.example");await r.pathExists(A)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(q(e)));}let F=a.join(e,"src"),D=a.join(e,"modules");if(t.modulesHealthy=true,t.missingModules=[],await r.pathExists(F)){let A=a.join(F,"__init__.py");await r.pathExists(A)||(t.modulesHealthy=false,t.missingModules.push("src/__init__.py"));}if(await r.pathExists(D))try{let A=await at(D);for(let H of A){let j=a.join(D,H,"__init__.py");await r.pathExists(j)||(t.modulesHealthy=false,t.missingModules.push(`modules/${H}/__init__.py`));}}catch{}return !t.modulesHealthy&&t.missingModules.length>0&&t.issues.push(`Missing module init files: ${t.missingModules.join(", ")}`),await T(e,t),await B(e,t),await _(e,t),t}if(N){G(t,i(e,s??null)),t.venvActive=true,t.coreInstalled=false;let w=a.join(e,"vendor");t.depsInstalled=await r.pathExists(w),t.depsInstalled||(t.issues.push("PHP dependencies not installed (vendor missing)"),t.fixCommands?.push(R(e,"composer install")));let v=a.join(e,".env");if(t.hasEnvFile=await r.pathExists(v),!t.hasEnvFile){let C=a.join(e,".env.example");await r.pathExists(C)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(q(e)));}return await T(e,t),await B(e,t),await _(e,t),t}if(ne){G(t,i(e,s??null)),t.venvActive=true,t.coreInstalled=false;let w=await r.pathExists(a.join(e,"Gemfile.lock")),v=await r.pathExists(a.join(e,"vendor","bundle"));t.depsInstalled=w||v,t.depsInstalled||(t.issues.push("Ruby dependencies not installed (Gemfile.lock/vendor missing)"),t.fixCommands?.push(R(e,"bundle install")));let C=a.join(e,".env");return t.hasEnvFile=await r.pathExists(C),await T(e,t),await B(e,t),await _(e,t),t}if(ue){G(t,i(e,s??null)),t.venvActive=true,t.coreInstalled=false;let w=a.join(e,"obj"),v=a.join(e,"src","obj"),C=a.join(e,"packages.lock.json");t.depsInstalled=await r.pathExists(w)||await r.pathExists(v)||await r.pathExists(C),t.depsInstalled||(t.issues.push(".NET restore/build artifacts not found"),t.fixCommands?.push(R(e,"dotnet restore")));let F=a.join(e,".env");return t.hasEnvFile=await r.pathExists(F),await T(e,t),await B(e,t),await _(e,t),t}return pe(t,"Unknown","low"),t.issues.push("Unknown project type (no recognized runtime marker files)"),await T(e,t),await B(e,t),await _(e,t),t}async function at(e){try{return (await r.readdir(e,{withFileTypes:true})).filter(i=>i.isDirectory()).map(i=>i.name)}catch{try{let n=await r.readdir(e),i=[];for(let t of n)try{(await r.stat(a.join(e,t))).isDirectory()&&i.push(t);}catch{continue}return i}catch{return []}}}async function Ue(e,n,i){let t=[{dir:e,depth:0}],c=new Set([".git",".rapidkit","node_modules","bin","obj","target"]);for(;t.length>0;){let o=t.shift();if(!o||o.depth>i)continue;let s;try{s=await r.readdir(o.dir,{withFileTypes:true});}catch{continue}for(let d of s){if(d.isFile()&&d.name.toLowerCase().endsWith(n.toLowerCase()))return true;d.isDirectory()&&!c.has(d.name)&&t.push({dir:a.join(o.dir,d.name),depth:o.depth+1});}}return false}async function le(e){let n=a.join(e,".rapidkit");if(!await r.pathExists(n))return false;let i=["project.json","context.json","file-hashes.json"];for(let t of i)if(await r.pathExists(a.join(n,t)))return true;return false}function rt(e,n){if(n.has(e))return true;let i=e.toLowerCase();return !!(i==="dist"||i.startsWith("dist-")||i.startsWith("dist_")||i==="build"||i.startsWith("build-")||i.startsWith("build_"))}async function sn(e,n,i){let t=new Set,c=[{dir:e,depth:0}];for(;c.length>0;){let o=c.shift();if(!o)break;try{let s=await r.readdir(o.dir);for(let d of s){if(rt(d,i))continue;let u=a.join(o.dir,d),p;try{p=await r.stat(u);}catch{continue}if(p.isDirectory()){if(await le(u)){t.add(u);continue}o.depth<n&&c.push({dir:u,depth:o.depth+1});}}}catch{continue}}return Array.from(t)}async function de(e){let n=a.resolve(e),i=a.parse(n).root;for(;;){if(await rn(n))return n;if(n===i)break;n=a.dirname(n);}return null}async function on(e){let n=a.resolve(e),i=await de(n),t=i??a.parse(n).root;for(;;){if(await le(n)||await an(n)&&(!i||n!==i))return n;if(n===t)break;n=a.dirname(n);}return null}function ze(e){let n=a.resolve(e);return process.platform==="darwin"?n.replace(/^\/private(?=\/var\/)/,""):n}async function an(e){let n=["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 i of n)if(await r.pathExists(a.join(e,i)))return true;return false}async function rn(e){let n=[a.join(e,".rapidkit-workspace"),a.join(e,".rapidkit","workspace-marker.json"),a.join(e,".rapidkit","config.json")];return Promise.all(n.map(i=>r.pathExists(i))).then(i=>i.some(Boolean))}function ct(e,n){let i=0,t=0,c=0;return e.forEach(s=>{s.status==="ok"?i++:s.status==="warn"?t++:s.status==="error"&&c++;}),n.forEach(s=>{let d=ee(s),u=s.isGoProject?s.issues.length===0&&s.depsInstalled:s.issues.length===0&&s.venvActive&&s.depsInstalled;if(s.issues.length>0||d>0||!u){t++;return}i++;}),{total:i+t+c,passed:i,warnings:t,errors:c}}function lt(e,n,i={}){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 c=[...n].sort((o,s)=>{let d=`${o.path||""}|${o.name||""}`.toLowerCase(),u=`${s.path||""}|${s.name||""}`.toLowerCase();return d.localeCompare(u)});for(let o of c){let s=o.issues.length>0,d=ee(o),u=s||d>0?"warn":"ok",p=s?`${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:s?"project-blocking-issues":d>0?"project-advisory-warnings":"project-checks-passed",reason:p});}if(i.includeWorkspaceAggregateRules){let o=n.reduce((u,p)=>u+p.issues.length,0),s=$e(n),d=e.filter(u=>u.result.status==="error").length;t.push({id:"workspace:projects-discovered",label:"Workspace projects discovered",status:n.length>0?"ok":"warn",scope:"workspace-aggregate",policyRuleId:"workspace-project-discovery",reason:n.length>0?`${n.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:s>0?"warn":"ok",scope:"workspace-aggregate",policyRuleId:"workspace-advisory-warning-gate",reason:s>0?`${s} advisory warning(s) detected.`:"No advisory warnings detected."});}return t}async function Qe(e,n=true){let i=a.basename(e);try{let g=a.join(e,".rapidkit-workspace");await r.pathExists(g)&&(i=(await r.readJSON(g)).name||i);}catch{try{let g=a.join(e,".rapidkit","config.json");i=(await r.readJSON(g)).workspace_name||i;}catch{}}let[t,c]=await Promise.all([Fe(),Lt(e)]),o={workspacePath:e,workspaceName:i,python:t.python,poetry:t.poetry,pipx:t.pipx,go:t.go,rapidkitCore:t.rapidkitCore,projects:[]};f.debug(`Workspace scan found ${c.length} project(s)`);let s=await Vt(e,c),d=a.join(e,".rapidkit","reports","doctor-workspace-cache.json"),u=n?await Jt(d,s):null;if(u){o.projects=u.projects;for(let g of o.projects)Ee(g,g.path);o.projectScanCached=true,f.debug(`Workspace project health cache hit: ${d}`);}else try{let g=await Promise.all(c.map(h=>De(h)));for(let h of g)Ee(h,h.path);o.projects=g,o.projectScanCached=false,await qt(d,{schemaVersion:et,signature:s,generatedAt:new Date().toISOString(),projects:g}),f.debug(`Workspace project health cache refreshed: ${d}`);}catch(g){f.debug(`Failed to scan workspace projects: ${g}`);}o.projectScanSignature=s,o.projectScanCachePath=d;let p=[o.python,o.poetry,o.pipx,o.go,o.rapidkitCore];if(o.healthScore=ct(p,o.projects),o.scoreBreakdown=lt([{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=ot(o.scoreBreakdown),o.rapidkitCore.status==="ok"){let g=o.rapidkitCore.message.match(/([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);g&&(o.coreVersion=g[1]);}let f$1=a.join(e,".rapidkit","reports","doctor-last-run.json"),m=await nt(f$1,"workspace");return o.driftDelta=Ht(m,o),o.evidencePath=await Ut(e,o,u?d:null),o}function Xe(e){return {name:e.name,path:e.path,framework:e.framework,frameworkKey:e.frameworkKey,importStack:e.importStack,runtimeFamily:e.runtimeFamily,projectKind:e.projectKind,supportTier:e.supportTier,frameworkConfidence:e.frameworkConfidence,kit:e.kit,venvActive:e.venvActive,depsInstalled:e.depsInstalled,hasEnvFile:e.hasEnvFile,modulesHealthy:e.modulesHealthy,missingModules:e.missingModules,hasTests:e.hasTests,hasDocker:e.hasDocker,hasCodeQuality:e.hasCodeQuality,vulnerabilities:e.vulnerabilities,coreInstalled:e.coreInstalled,coreVersion:e.coreVersion,lastModified:e.lastModified,stats:e.stats,issues:e.issues,fixCommands:e.fixCommands,probes:e.probes,commandCapabilities:e.commandCapabilities}}async function cn(e$1,n){let i=e$1||n.projectPath,t=a.join(i,".rapidkit","reports","doctor-project-last-run.json");try{await r.ensureDir(a.dirname(t));let c=n.project.issues.filter(o=>typeof o=="string"&&o.trim().length>0).slice(0,12);return await r.writeJSON(t,f$2({schemaVersion:b$2,evidenceType:"project",contract:me(),workspacePath:e$1||null,projectPath:n.projectPath,projectName:n.projectName,healthScore:n.healthScore,system:{python:n.python,poetry:n.poetry,pipx:n.pipx,go:n.go,rapidkitCore:n.rapidkitCore},project:n.project,driftDelta:n.driftDelta,summary:{scopeProvenance:n.scopeProvenance},scoreBreakdown:n.scoreBreakdown??[]},{commandId:"projectDoctor",exitCode:oe(n.healthScore,{}),generatedAt:new Date().toISOString(),blockers:c,runId:e()}),{spaces:2}),t}catch{return}}async function ln(e){let n=await de(e),i=await Fe(),t=await De(e,{allowNonRapidkit:true});Ee(t,e);let c=ct([i.python,i.poetry,i.pipx,i.go,i.rapidkitCore],[t]),o={workspacePath:n||void 0,projectPath:e,projectName:a.basename(e),python:i.python,poetry:i.poetry,pipx:i.pipx,go:i.go,rapidkitCore:i.rapidkitCore,project:t,healthScore:c};o.scoreBreakdown=lt([{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=ot(o.scoreBreakdown);let s=n||e,d=a.join(s,".rapidkit","reports","doctor-project-last-run.json"),u=await nt(d,"project");return o.driftDelta=Mt(u,o),o.evidencePath=await cn(n||void 0,o),o}function $(e,n){let i=e.status==="ok"?"\u2705":e.status==="warn"?"\u26A0\uFE0F":"\u274C",t=e.status==="ok"?l.green:e.status==="warn"?l.yellow:l.red;console.log(`${i} ${l.bold(n)}: ${t(e.message)}`),e.paths&&e.paths.length>0&&e.paths.forEach(c=>{let o=c.version?l.cyan(` -> ${c.version}`):"";console.log(` ${l.cyan("\u2022")} ${l.gray(c.location)}: ${l.dim(c.path)}${o}`);}),e.details&&console.log(` ${l.gray(e.details)}`);}function Ye(e){let n=e.issues.length>0,i=n?"\u26A0\uFE0F":"\u2705",t=n?l.yellow:l.green;if(console.log(`
|
|
2
2
|
${i} ${l.bold("Project")}: ${t(e.name)}`),e.framework){let s=e.framework==="FastAPI"||e.framework==="Django"||e.framework==="Flask"?"\u{1F40D}":e.framework==="NestJS"?"\u{1F985}":e.framework==="Next.js"||e.framework==="Nuxt"||e.framework==="Remix"?"\u25B2":e.framework==="React"||e.framework==="Vite"?"\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(` ${s} Framework: ${l.cyan(e.framework)}${e.kit?l.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(` ${l.dim("\u21B3")} ${l.gray(d.join(" \u2022 "))}`);}if(console.log(` ${l.gray(`Path: ${e.path}`)}`),e.runtimeFamily==="python"&&(e.venvActive?console.log(` \u2705 Virtual environment: ${l.green("Active")}`):console.log(` \u274C Virtual environment: ${l.red("Not found")}`),e.coreInstalled?console.log(` ${l.dim("\u2139")} RapidKit Core: ${l.gray(e.coreVersion||"In venv")} ${l.dim("(optional)")}`):console.log(` ${l.dim("\u2139")} RapidKit Core: ${l.gray("Using global installation")} ${l.dim("(recommended)")}`)),e.depsInstalled?console.log(` \u2705 Dependencies: ${l.green("Installed")}`):console.log(` \u26A0\uFE0F Dependencies: ${l.yellow("Not installed")}`),e.hasEnvFile!==void 0&&(e.hasEnvFile?console.log(` \u2705 Environment: ${l.green(".env configured")}`):console.log(` \u26A0\uFE0F Environment: ${l.yellow(".env missing")}`)),e.modulesHealthy!==void 0){let s=e.projectKind==="frontend"?"Source tree":"Modules";e.modulesHealthy?console.log(` \u2705 ${s}: ${l.green("Healthy")}`):e.missingModules&&e.missingModules.length>0?console.log(` \u26A0\uFE0F ${s}: ${l.yellow(`Missing ${e.missingModules.length} init file(s)`)}`):e.projectKind==="frontend"&&console.log(` \u26A0\uFE0F ${s}: ${l.yellow("No application directories detected")}`);}if(e.stats){let s=[];e.stats.modules!==void 0&&s.push(`${e.stats.modules} module${e.stats.modules!==1?"s":""}`),s.length>0&&console.log(` \u{1F4CA} Stats: ${l.cyan(s.join(" \u2022 "))}`);}e.lastModified&&console.log(` \u{1F552} Last Modified: ${l.gray(e.lastModified)}`);let o=[];if(e.hasTests!==void 0&&o.push(e.hasTests?"\u2705 Tests":l.dim("\u2298 No tests")),e.hasDocker!==void 0&&o.push(e.hasDocker?"\u2705 Docker":l.dim("\u2298 No Docker")),e.hasCodeQuality!==void 0){let s=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 ${s}`:l.dim(`\u2298 No ${s}`));}if(o.length>0&&console.log(` ${o.join(" \u2022 ")}`),e.vulnerabilities!==void 0&&e.vulnerabilities>0&&console.log(` \u26A0\uFE0F Security: ${l.yellow(`${e.vulnerabilities} vulnerability(ies) found`)}`),e.issues.length>0&&(console.log(` ${l.bold("Issues:")}`),e.issues.forEach(s=>{console.log(` \u2022 ${l.yellow(s)}`);}),e.fixCommands&&e.fixCommands.length>0&&(console.log(`
|
|
3
3
|
${l.bold.cyan("\u{1F527} Quick Fix:")}`),e.fixCommands.forEach(s=>{console.log(` ${l.cyan("$")} ${l.white(s)}`);}))),e.probes&&e.probes.length>0){console.log(` ${l.bold("Probe checks:")}`);for(let s of e.probes){let d=s.status==="pass"?"\u2705":s.status==="warn"?"\u26A0\uFE0F":"\u274C";console.log(` ${d} ${s.label}: ${l.gray(s.reason)}`),s.recommendation&&console.log(` ${l.dim("\u21B3")} ${l.gray(s.recommendation)}`);}}if(e.commandCapabilities){let s=e.commandCapabilities;if(console.log(` ${l.bold("Command support:")}`),console.log(` ${l.green("supported")} ${s.supportedCommands.length} \u2022 ${l.yellow("unsupported")} ${s.unsupportedCommands.length} \u2022 ${l.gray("global")} ${s.globalCommands.length}`),s.unsupportedCommands.length>0){let d=s.unsupportedCommands.slice(0,8).join(", "),u=s.unsupportedCommands.length>8?", ...":"";console.log(` ${l.dim("\u21B3")} ${l.gray(`Unsupported here: ${d}${u}`)}`);}}}async function dt(){try{return (await execa("go",["version"],{timeout:a$3(),reject:false})).exitCode===0}catch{return false}}function te(e,n){let i=[new RegExp(`^cd\\s+"([^"]+)"\\s*(?:&&|;)\\s*${n}\\s*$`,"i"),new RegExp(`^cd\\s+'([^']+)'\\s*(?:&&|;)\\s*${n}\\s*$`,"i"),new RegExp(`^cd\\s+(.+?)\\s*(?:&&|;)\\s*${n}\\s*$`,"i")];for(let t of i){let c=e.match(t);if(c?.[1])return {projectPath:c[1].trim()}}return null}function ut(e){return te(e,"cp\\s+\\.env\\.example\\s+\\.env")||te(e,"copy-item\\s+\\.env\\.example\\s+\\.env")}function pt(e){let n=[{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 i of n){let t=te(e,i.pattern);if(t)return {projectPath:t.projectPath,command:i.command,args:i.args}}return null}function Pe(e,n){return /^https?:\/\//i.test(n.trim())?{projectName:e.name,projectPath:e.path,originalCommand:n,kind:"manual-url",risk:"safe",executable:false,reason:"Manual guidance URL"}:ut(n)?{projectName:e.name,projectPath:e.path,originalCommand:n,kind:"env-copy",risk:"safe",executable:true,reason:"Environment seed copy"}:te(n,"rapidkit\\s+init")?{projectName:e.name,projectPath:e.path,originalCommand:n,kind:"rapidkit-init",risk:"guarded",executable:true,reason:"RapidKit initializer may mutate dependencies and configs"}:te(n,"go\\s+mod\\s+tidy")?{projectName:e.name,projectPath:e.path,originalCommand:n,kind:"go-mod-tidy",risk:"guarded",executable:true,reason:"Go module graph reconciliation"}:pt(n)?{projectName:e.name,projectPath:e.path,originalCommand:n,kind:"dependency-sync",risk:"guarded",executable:true,reason:"Dependency synchronization command"}:{projectName:e.name,projectPath:e.path,originalCommand:n,kind:"shell",risk:"invasive",executable:true,reason:"Generic shell command"}}async function Se(e){let n=e.filter(p=>p.fixCommands&&p.fixCommands.length>0),i=n.flatMap(p=>(p.fixCommands??[]).map(f=>Pe(p,f))),t=null,c=[],o=0,s=0,d=0,u=0;for(let p of i){let f=p.executable,m;p.kind==="go-mod-tidy"&&(t===null&&(t=await dt()),t||(f=false,m="Go toolchain not available")),f&&(o+=1,p.risk==="safe"&&(s+=1),p.risk==="guarded"&&(d+=1),p.risk==="invasive"&&(u+=1)),c.push({...p,executableInCurrentEnvironment:f,blockedReason:m});}return {generatedAt:new Date().toISOString(),fixableProjects:n.length,totalSteps:c.length,executableSteps:o,risk:{safe:s,guarded:d,invasive:u},steps:c}}function Ze(e){let n=e instanceof Error?e.message:String(e),i=["ETIMEDOUT","ECONNRESET","ECONNREFUSED","EAI_AGAIN","ENOTFOUND","network","503","504"],t=n.toLowerCase();return i.some(c=>t.includes(c.toLowerCase()))}async function dn(e,n){let i=e.get(n);if(i)return i;let t=`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,c=a.basename(n).replace(/[^a-zA-Z0-9._-]/g,"_"),o=a.join(n,".rapidkit","reports","fix-snapshots",`${c}-${t}`);await r.ensureDir(o);let s=[".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 p of s){let f=a.join(n,p);if(!await r.pathExists(f))continue;let m=a.join(o,p);await r.ensureDir(a.dirname(m)),await r.copy(f,m,{overwrite:true}),d.set(f,m);}let u={snapshotRoot:o,files:d};return e.set(n,u),u}async function un(e){for(let[n,i]of e.files.entries())await r.pathExists(i)&&(await r.ensureDir(a.dirname(n)),await r.copy(i,n,{overwrite:true}));}async function pn(e){let n=await De(e,{allowNonRapidkit:true});return {issues:n.issues.length,healthy:n.issues.length===0}}async function se(e,n=false,i={}){let t=await Se(e),c=e.filter(h=>h.fixCommands&&h.fixCommands.length>0),o=null,s=t.steps.some(h=>h.kind==="go-mod-tidy"&&!h.executableInCurrentEnvironment),d=new Map;if(c.length===0){console.log(l.green(`
|
|
4
4
|
\u2705 No fixes needed - all projects are healthy!`));return}console.log(l.bold.cyan(`
|
|
@@ -20,9 +20,9 @@ Use --apply to execute this plan non-interactively, or --fix for interactive con
|
|
|
20
20
|
`));continue}let ie=b.kind==="shell"?2:1,Q;for(let W=1;W<=ie;W+=1)try{await execa(k,{shell:true,stdio:"inherit"}),Q=null;break}catch(N){if(Q=N,W<ie&&Ze(N)){console.log(l.yellow(` \u26A0 Retrying command (${W}/${ie-1})...`));continue}throw N}if(Q)throw Q;console.log(l.green(` \u2705 Success
|
|
21
21
|
`));}catch(K){let U=Pe(h,k);if(U.risk!=="safe"){let z=d.get(U.projectPath);if(z)try{await un(z),console.log(l.yellow(" \u21A9 Rolled back snapshot after failed fix"));}catch(V){console.log(l.red(` \u274C Rollback failed: ${V instanceof Error?V.message:String(V)}`));}}console.log(l.red(` \u274C Failed: ${K instanceof Error?K.message:String(K)}
|
|
22
22
|
`));}}}try{let k=await pn(h.path);console.log(k.healthy?l.green(` \u2705 Post-fix verification passed for ${h.name}`):l.yellow(` \u26A0 Post-fix verification: ${k.issues} issue(s) remain for ${h.name}`));}catch(k){console.log(l.yellow(` \u26A0 Post-fix verification skipped: ${k instanceof Error?k.message:String(k)}`));}}console.log(l.bold.green(`
|
|
23
|
-
\u2705 Fix process completed!`));}function oe(e,n){if(!n.strict&&!n.ci)return 0;let i=Number(e?.errors??0),t=Number(e?.warnings??0);return i>0?1:n.ci&&t>0?2:n.strict&&t>0?1:0}async function Mn(e
|
|
23
|
+
\u2705 Fix process completed!`));}function oe(e,n){if(!n.strict&&!n.ci)return 0;let i=Number(e?.errors??0),t=Number(e?.warnings??0);return i>0?1:n.ci&&t>0?2:n.strict&&t>0?1:0}async function Mn(e={}){let n=!!(e.fix||e.plan||e.apply),i=!e.workspace&&!e.project&&n?await de(process.cwd()):null,t=e.workspace||!!i,c=!!e.project&&!t;if(e.json||console.log(l.bold.cyan(`
|
|
24
24
|
\u{1FA7A} RapidKit Health Check
|
|
25
|
-
`)),t){let o=i??await de(process.cwd());o||(
|
|
25
|
+
`)),t){let o=i??await de(process.cwd());o||(f.error("No RapidKit workspace found in current directory or parents"),f.info('Run this command from within a workspace, or use "rapidkit doctor" for system check'),process.exit(1)),e.json||(i&&console.log(l.gray("\u2139\uFE0F Detected workspace context; enabling workspace checks for --fix")),console.log(l.bold(`Workspace: ${l.cyan(a.basename(o))}`)),console.log(l.gray(`Path: ${o}`)));let s=await Qe(o);if(e.json||(s.projectScanCached&&console.log(l.gray(`\u2139\uFE0F Reused cached project scan${s.projectScanCachePath?` (${a.basename(s.projectScanCachePath)})`:""}`)),s.evidencePath&&console.log(l.gray(`\u2139\uFE0F Evidence saved: ${s.evidencePath}`))),e.json){let f=e.plan?await Se(s.projects):void 0,m={contract:me(),workspace:{name:a.basename(o),path:o},cache:{projectScan:s.projectScanCached??false,projectScanPath:s.projectScanCachePath,evidencePath:s.evidencePath},healthScore:s.healthScore,system:{python:s.python,poetry:s.poetry,pipx:s.pipx,rapidkitCore:s.rapidkitCore,versions:{core:s.coreVersion,npm:s.npmVersion}},projects:s.projects.map(g=>Xe(g)),summary:{totalProjects:s.projects.length,totalIssues:s.projects.reduce((g,h)=>g+h.issues.length,0),projectAdvisoryWarningProjects:Ce(s.projects),projectAdvisoryWarnings:$e(s.projects),hasSystemErrors:[s.python,s.rapidkitCore].some(g=>g.status==="error"),scopeProvenance:s.scopeProvenance},driftDelta:s.driftDelta,scoreBreakdown:s.scoreBreakdown??[],...f?{remediationPlan:f}:{}};return e.quiet||console.log(JSON.stringify(m,null,2)),oe(s.healthScore,e)}if(s.healthScore){let f=s.healthScore,m=Math.round(f.passed/f.total*100),g=m>=80?l.green:m>=50?l.yellow:l.red,h="\u2588".repeat(Math.floor(m/5))+"\u2591".repeat(20-Math.floor(m/5));console.log(l.bold(`
|
|
26
26
|
\u{1F4CA} Health Score:`)),console.log(` ${g(`${m}%`)} ${l.gray(h)}`),console.log(` ${l.green(`\u2705 ${f.passed} passed`)} ${l.gray("|")} ${l.yellow(`\u26A0\uFE0F ${f.warnings} warnings`)} ${l.gray("|")} ${l.red(`\u274C ${f.errors} errors`)}`);}if(console.log(l.bold(`
|
|
27
27
|
|
|
28
28
|
System Tools:
|
|
@@ -30,21 +30,21 @@ System Tools:
|
|
|
30
30
|
\u26A0\uFE0F Version mismatch: Core ${s.coreVersion} / CLI ${s.npmVersion}`)),console.log(l.gray(" Consider updating to matching versions for best compatibility")));}s.projects.length>0?(console.log(l.bold(`
|
|
31
31
|
\u{1F4E6} Projects (${s.projects.length}):`)),s.projects.forEach(f=>Ye(f))):(console.log(l.bold(`
|
|
32
32
|
\u{1F4E6} Projects:`)),console.log(l.gray(" No RapidKit projects found in workspace")));let d=s.projects.reduce((f,m)=>f+m.issues.length,0),u=Ce(s.projects),p=[s.python,s.rapidkitCore].some(f=>f.status==="error");if(p||d>0||u>0){let f=u>0?` and ${u} advisory warning project(s)`:"";if(console.log(l.bold.yellow(`
|
|
33
|
-
\u26A0\uFE0F Found ${d} project issue(s)${f}`)),p&&console.log(l.bold.red("\u274C System requirements not met")),e
|
|
33
|
+
\u26A0\uFE0F Found ${d} project issue(s)${f}`)),p&&console.log(l.bold.red("\u274C System requirements not met")),e.plan)await se(s.projects,false,{planOnly:true,json:e.json});else if(e.fix||e.apply){if(await se(s.projects,true,{skipConfirmation:e.apply===true}),!e.json){let m=await Qe(o,false),g=m.projects.reduce((y,k)=>y+k.issues.length,0),h=[m.python,m.rapidkitCore].some(y=>y.status==="error");h||g>0?(console.log(l.bold.yellow(`
|
|
34
34
|
\u26A0\uFE0F Post-fix verification found ${g} remaining issue(s)`)),h&&console.log(l.bold.red("\u274C System requirements still not met"))):console.log(l.bold.green(`
|
|
35
35
|
\u2705 Post-fix verification passed. Workspace is healthy.`)),m.projectScanCached&&console.log(l.gray(`\u2139\uFE0F Reused cached project scan${m.projectScanCachePath?` (${a.basename(m.projectScanCachePath)})`:""}`)),m.evidencePath&&console.log(l.gray(`\u2139\uFE0F Evidence refreshed: ${m.evidencePath}`));}}else d>0&&await se(s.projects,false);}else console.log(l.bold.green(`
|
|
36
|
-
\u2705 All checks passed! Workspace is healthy.`));return oe(s.healthScore,e
|
|
37
|
-
\u{1F4CA} Health Score:`)),console.log(` ${m(`${f}%`)} ${l.gray(g)}`),console.log(` ${l.green(`\u2705 ${p.passed} passed`)} ${l.gray("|")} ${l.yellow(`\u26A0\uFE0F ${p.warnings} warnings`)} ${l.gray("|")} ${l.red(`\u274C ${p.errors} errors`)}`),console.log(l.bold(`
|
|
36
|
+
\u2705 All checks passed! Workspace is healthy.`));return oe(s.healthScore,e)}else if(c){let o=await on(process.cwd());o||(await de(process.cwd())?(f.error("No backend project found in current directory within this workspace"),f.info("Run this command from inside a project directory in the workspace")):f.error("No RapidKit project found in current directory or parents"),f.info('Run this command from within a project, or use "rapidkit doctor workspace" for workspace checks'),process.exit(1));let s=await ln(o),d=s.workspacePath?ze(s.workspacePath):null,u=ze(s.project.path);if(e.json){let b=e.plan?await Se([s.project]):void 0,L={contract:me(),scope:"project",workspace:d?{name:a.basename(d),path:d}:null,project:{...Xe(s.project),path:u},evidencePath:s.evidencePath,healthScore:s.healthScore,system:{python:s.python,poetry:s.poetry,pipx:s.pipx,go:s.go,rapidkitCore:s.rapidkitCore},summary:{totalProjects:1,totalIssues:s.project.issues.length,projectAdvisoryWarningProjects:ee(s.project)>0?1:0,projectAdvisoryWarnings:ee(s.project),hasSystemErrors:[s.python,s.rapidkitCore].some(K=>K.status==="error"),scopeProvenance:s.scopeProvenance},driftDelta:s.driftDelta,scoreBreakdown:s.scoreBreakdown??[],...b?{remediationPlan:b}:{}};return e.quiet||console.log(JSON.stringify(L,null,2)),oe(s.healthScore,e)}console.log(l.bold(`Project: ${l.cyan(a.basename(o))}`)),console.log(l.gray(`Path: ${o}`)),s.workspacePath&&console.log(l.gray(`Workspace: ${a.basename(s.workspacePath)}`)),s.evidencePath&&console.log(l.gray(`\u2139\uFE0F Evidence saved: ${s.evidencePath}`));let p=s.healthScore,f$1=p.total>0?Math.round(p.passed/p.total*100):0,m=f$1>=80?l.green:f$1>=50?l.yellow:l.red,g="\u2588".repeat(Math.floor(f$1/5))+"\u2591".repeat(20-Math.floor(f$1/5));console.log(l.bold(`
|
|
37
|
+
\u{1F4CA} Health Score:`)),console.log(` ${m(`${f$1}%`)} ${l.gray(g)}`),console.log(` ${l.green(`\u2705 ${p.passed} passed`)} ${l.gray("|")} ${l.yellow(`\u26A0\uFE0F ${p.warnings} warnings`)} ${l.gray("|")} ${l.red(`\u274C ${p.errors} errors`)}`),console.log(l.bold(`
|
|
38
38
|
|
|
39
39
|
System Tools:
|
|
40
40
|
`)),$(s.python,"Python"),$(s.poetry,"Poetry"),$(s.pipx,"pipx"),$(s.go,"Go"),$(s.rapidkitCore,"RapidKit Core"),console.log(l.bold(`
|
|
41
41
|
\u{1F4E6} Project (1):`)),Ye(s.project);let h=[s.python,s.rapidkitCore].some(b=>b.status==="error"),y=s.project.issues.length,k=ee(s.project);if(h||y>0||k>0){let b=k>0?` and ${k} advisory warning(s)`:"";console.log(l.bold.yellow(`
|
|
42
|
-
\u26A0\uFE0F Found ${y} project issue(s)${b}`)),h&&console.log(l.bold.red("\u274C System requirements not met")),e
|
|
43
|
-
\u2705 All checks passed! Project is healthy.`));return oe(s.healthScore,e
|
|
42
|
+
\u26A0\uFE0F Found ${y} project issue(s)${b}`)),h&&console.log(l.bold.red("\u274C System requirements not met")),e.plan?await se([s.project],false,{planOnly:true,json:e.json}):e.fix||e.apply?await se([s.project],true,{skipConfirmation:e.apply===true}):y>0&&await se([s.project],false);}else console.log(l.bold.green(`
|
|
43
|
+
\u2705 All checks passed! Project is healthy.`));return oe(s.healthScore,e)}else {console.log(l.bold(`System Tools:
|
|
44
44
|
`));let o=await Fe(),s=o.python,d=o.poetry,u=o.pipx,p=o.go,f=o.rapidkitCore;$(s,"Python"),$(d,"Poetry"),$(u,"pipx"),$(p,"Go"),$(f,"RapidKit Core"),[s,f].some(h=>h.status==="error")?(console.log(l.bold.red(`
|
|
45
|
-
\u274C Some required tools are missing`)),(e
|
|
45
|
+
\u274C Some required tools are missing`)),(e.fix||e.apply)&&console.log(l.gray(`
|
|
46
46
|
Tip: Project auto-fix runs in workspace mode. Run from a workspace and use "rapidkit doctor workspace --fix"`)),console.log(l.gray(`
|
|
47
47
|
Tip: Run "rapidkit doctor workspace" for workspace-wide checks, or "rapidkit doctor project" for the current project`))):(console.log(l.bold.green(`
|
|
48
|
-
\u2705 All required tools are installed!`)),(e
|
|
48
|
+
\u2705 All required tools are installed!`)),(e.fix||e.apply)&&console.log(l.gray(`
|
|
49
49
|
Tip: Project auto-fix runs in workspace mode. Run from a workspace and use "rapidkit doctor workspace --fix"`)),console.log(l.gray(`
|
|
50
|
-
Tip: Run "rapidkit doctor workspace" for workspace-wide checks, or "rapidkit doctor project" for the current project`))),console.log("");let g=[s,f].filter(h=>h.status==="error").length;return (e
|
|
50
|
+
Tip: Run "rapidkit doctor workspace" for workspace-wide checks, or "rapidkit doctor project" for the current project`))),console.log("");let g=[s,f].filter(h=>h.status==="error").length;return (e.strict||e.ci)&&g>0?1:0}}export{oe as a,Mn as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {r,j,q}from'./chunk-ZWKLRZE5.js';import A from'crypto';import c from'path';import d from'fs-extra';var E=new Set([...r().map(e=>e.id),...j().map(e=>e.kitId)]),b=[{id:"wordpress-site",aliases:["wordpress","wordpress-site","wp","wp-site"],ecosystem:"wordpress",status:"planned",officialCommands:["wp core download","wp config create","wp db create","wp core install"],adoptAfterCreate:true},{id:"wordpress-block",aliases:["wordpress-block","wp-block","gutenberg-block"],ecosystem:"wordpress",status:"planned",officialCommands:["npx @wordpress/create-block@latest <slug>"],adoptAfterCreate:true},{id:"laravel",aliases:["laravel","php-laravel"],ecosystem:"php",status:"planned",officialCommands:["composer create-project laravel/laravel <name>"],adoptAfterCreate:true},{id:"symfony",aliases:["symfony","php-symfony"],ecosystem:"php",status:"planned",officialCommands:["composer create-project symfony/skeleton <name>"],adoptAfterCreate:true},{id:"rails",aliases:["rails","ruby-on-rails","ruby-rails"],ecosystem:"ruby",status:"planned",officialCommands:["rails new <name>"],adoptAfterCreate:true}],i=new Map;for(let e of b){i.set(e.id,e);for(let t of e.aliases)i.set(t,e);}var h=new Set(["php","ruby","rust","elixir","clojure","scala","kotlin","unknown"]);function o(e){return e?.trim().toLowerCase()||void 0}function R(e){let t=o(e.kitId)??o(e.framework)??o(e.runtime)??"unknown";if(e.projectExists)return {lane:"adopt-only",status:"available",canExecuteCreate:false,requested:t,reason:"Existing projects enter Workspace Intelligence through adopt/import."};let n=e.kitId?q(e.kitId):void 0;if(n&&E.has(n))return {lane:"native-create",status:"available",canExecuteCreate:true,requested:t,resolved:n,reason:"RapidKit owns the create contract, project marker, registry, doctor, and workspace model path."};let s=i.get(t)??i.get(o(e.framework)??"")??i.get(o(e.runtime)??"");if(s)return {lane:"external-create-adopt",status:s.status,canExecuteCreate:false,requested:t,resolved:s.id,officialCommands:s.officialCommands,fallbackLane:"adopt-only",reason:"External generator support is planned but not enabled; use adopt/import until RapidKit owns the post-create contract."};let r=o(e.runtime);return r&&h.has(r)?{lane:"adopt-only",status:"available",canExecuteCreate:false,requested:t,resolved:r,reason:"Runtime can be governed through Workspace Intelligence, but native create is not supported."}:{lane:"adopt-only",status:"available",canExecuteCreate:false,requested:t,reason:"No native create contract is available; use adopt/import to enter Workspace Intelligence."}}function K(e){return !e.canExecuteCreate&&(e.lane==="external-create-adopt"||e.lane==="adopt-only"&&e.resolved!==void 0)}var L="rapidkit-freshness-metadata-v1";function l(e){if(Array.isArray(e))return e.map(t=>l(t));if(e&&typeof e=="object"){let t={};for(let n of Object.keys(e).sort())t[n]=l(e[n]);return t}return e}function v(e){return JSON.stringify(l(e))}function N(e){return A.createHash("sha256").update(v(e)).digest("hex")}var I=new Set(["service","frontend","worker","library","infra","docs","test-suite","unknown"]);async function k(e){try{if(!await d.pathExists(e))return null;let t=await d.readJSON(e);return t&&typeof t=="object"?t:null}catch{return null}}function y(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return I.has(t)?t:null}async function F(e,t){let n=t??await k(c.join(e,".rapidkit","project.json")),s=y(n?.kind)??y(n?.type);if(s)return s;let r=await k(c.join(e,"package.json"));if(r){let a={...r.dependencies??{},...r.devDependencies??{}},C=r.scripts??{},p=Object.values(C).filter(x=>typeof x=="string").join(" ").toLowerCase();if(a.next||a.react||a.vue||a.svelte||a.vite||a["@angular/core"]||p.includes("next ")||p.includes("vite "))return "frontend";if(r.private===true&&!a.express&&!a["@nestjs/core"])return "library"}return await d.pathExists(c.join(e,"Dockerfile"))||await d.pathExists(c.join(e,"docker-compose.yml"))||await d.pathExists(c.join(e,"terraform.tf"))?"infra":"service"}export{R as a,K as b,L as c,N as d,F as e};
|