rapidkit 0.41.5 → 0.42.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/contracts/extension-cli-compatibility.v1.json +1 -1
- package/dist/analyze-XSPWKPA4.js +1 -0
- package/dist/autopilot-release-MVFRZMHD.js +1 -0
- package/dist/chunk-2LBPX5K3.js +2 -0
- package/dist/chunk-2ZLIVGO7.js +2 -0
- package/dist/{chunk-U7TS7W2V.js → chunk-3HBNF2A3.js} +1 -1
- package/dist/{chunk-UZW5QFRW.js → chunk-4KUIFXHM.js} +3 -3
- package/dist/chunk-4ZSDU5OO.js +4 -0
- package/dist/{chunk-U5IRABWC.js → chunk-5PFGOXBQ.js} +2 -2
- package/dist/chunk-5QAVZET2.js +1 -0
- package/dist/{chunk-HCJV2ITA.js → chunk-DZU4KPPW.js} +1 -1
- package/dist/chunk-F7GYXSBT.js +916 -0
- package/dist/{chunk-THSTNVE3.js → chunk-FB35IONI.js} +1 -1
- package/dist/chunk-FEA53XL6.js +4 -0
- package/dist/chunk-FSIZLBTL.js +1 -0
- package/dist/{chunk-TXUBE6KV.js → chunk-IS2XUPMP.js} +1 -1
- package/dist/chunk-LANBSCGS.js +13 -0
- package/dist/{chunk-FI4VMG2I.js → chunk-M44C2P3R.js} +1 -1
- package/dist/{chunk-SO2SSVWN.js → chunk-MQGVCTUL.js} +1 -1
- package/dist/{chunk-GDWLW7GF.js → chunk-QKVEWX4L.js} +1 -1
- package/dist/{chunk-3VI4Y7LZ.js → chunk-QOH5TIRZ.js} +1 -1
- package/dist/{chunk-T5GS4BUP.js → chunk-YM5Q3PV6.js} +1 -1
- package/dist/chunk-YWUWRSNO.js +1 -0
- package/dist/{create-P3USIH52.js → create-EAE2AJJL.js} +1 -1
- package/dist/{doctor-KYNACWFC.js → doctor-E6JE4Q3B.js} +1 -1
- package/dist/index.js +160 -159
- package/dist/{pipeline-SU3FJUKI.js → pipeline-TRA4MMZC.js} +1 -1
- package/dist/{workspace-5DKOA7TN.js → workspace-IBTKZX7T.js} +1 -1
- package/dist/{workspace-agent-sync-HZ4UBSZ2.js → workspace-agent-sync-LEYLJ42D.js} +1 -1
- package/dist/{workspace-context-R3XWWLFP.js → workspace-context-NTG3D4DI.js} +1 -1
- package/dist/workspace-explain-P2EBRNP6.js +1 -0
- package/dist/{workspace-foundation-H6IPS4MW.js → workspace-foundation-6AUEEJQQ.js} +1 -1
- package/dist/{workspace-intelligence-5BBKUJAG.js → workspace-intelligence-C6NT557E.js} +1 -1
- package/dist/{workspace-marker-HAC7BMEG.js → workspace-marker-5GAJSOFP.js} +1 -1
- package/dist/{workspace-mcp-serve-TQTJ4HWI.js → workspace-mcp-serve-GM7A3IVM.js} +1 -1
- package/dist/{workspace-model-YAC5BKLL.js → workspace-model-AOTSEAVW.js} +1 -1
- package/dist/workspace-python-engine-state-AEEZ7QYB.js +2 -0
- package/dist/workspace-run-ATFFJCMK.js +1 -0
- package/dist/{workspace-verify-5RZSDKGR.js → workspace-verify-7R3XBNKE.js} +1 -1
- package/dist/{workspace-watch-P2PGSYDD.js → workspace-watch-SGY2DEZ5.js} +1 -1
- package/docs/commands-reference.md +30 -3
- package/package.json +2 -2
- package/dist/analyze-JYHEGUSH.js +0 -1
- package/dist/autopilot-release-ZADU63OD.js +0 -1
- package/dist/chunk-7BEZH5LE.js +0 -2
- package/dist/chunk-DAPZJHMN.js +0 -4
- package/dist/chunk-E5ZVQL3C.js +0 -13
- package/dist/chunk-LRF6PQOZ.js +0 -1
- package/dist/chunk-P5NZE2RV.js +0 -883
- package/dist/chunk-Q4HEXEDW.js +0 -4
- package/dist/chunk-T7B3GF3Q.js +0 -1
- package/dist/chunk-YBS2HGO3.js +0 -2
- package/dist/workspace-explain-5RDFGHUN.js +0 -1
- package/dist/workspace-run-P5UOJSLQ.js +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {c,b}from'./chunk-ULIVVMT6.js';import {f as f$1,e}from'./chunk-PCXSTKZ5.js';import {b as b$2}from'./chunk-KMUWWZRT.js';import {j,g}from'./chunk-COBMOVUK.js';import {b as b$1}from'./chunk-CDCYRBAY.js';import {c as c$3,a as a$2,b as b$3}from'./chunk-NFUXULIF.js';import {q}from'./chunk-YBS2HGO3.js';import {i,d,b as b$5,a as a$4}from'./chunk-UZW5QFRW.js';import {a as a$1}from'./chunk-TDSIF42O.js';import {f}from'./chunk-OLDPVVSV.js';import {c as c$2,l,i as i$1,b as b$4,q as q$1,m,o}from'./chunk-WRMCPKGA.js';import {a as a$3}from'./chunk-2FIX2MDC.js';import {a}from'./chunk-HHJAANUC.js';import p from'chalk';import {createHash}from'crypto';import {execa}from'execa';import c$1 from'fs-extra';import s from'path';function Qe(e){return `"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function Ft(e){let t=`scripts.${e.scriptName}=${e.scriptValue}`;return `cd ${Qe(e.projectPath)} && npm pkg set ${Qe(t)}`}function Ae(e){return `rapidkit:doctor:repair ${Buffer.from(JSON.stringify(e),"utf8").toString("base64url")}`}function et(e){let t=s.join(e.projectPath,e.relativePath),i={type:"file-create",path:t,content:e.content,overwrite:false};return {id:`${e.issueId}.file-create`,issueId:e.issueId,title:e.title,status:"available",fixKind:"file-create",risk:e.risk??"safe",canAutoFix:true,canEditFiles:true,requiresApproval:true,requiresReview:e.requiresReview??false,files:[t],command:Ae(i),operation:i,verifyCommand:"npx rapidkit doctor project --json",refreshCommands:["npx rapidkit doctor project --json","npx rapidkit workspace verify --json"],reason:e.reason,limitations:e.limitations}}function Nt(e){let t=s.join(e.projectPath,e.relativePath),i={type:"file-append",path:t,lines:e.lines,ensureNewline:true};return {id:`${e.issueId}.file-append`,issueId:e.issueId,title:e.title,status:"available",fixKind:"file-append",risk:e.risk??"safe",canAutoFix:true,canEditFiles:true,requiresApproval:true,requiresReview:e.requiresReview??false,files:[t],command:Ae(i),operation:i,verifyCommand:"npx rapidkit doctor project --json",refreshCommands:["npx rapidkit doctor project --json","npx rapidkit workspace verify --json"],reason:e.reason,limitations:e.limitations}}function It(e){let t=s.join(e.projectPath,e.sourceRelativePath),i=s.join(e.projectPath,e.targetRelativePath),n={type:"file-copy",sourcePath:t,path:i,overwrite:false};return {id:`${e.issueId}.file-copy`,issueId:e.issueId,title:e.title,status:"available",fixKind:"file-copy",risk:e.risk??"safe",canAutoFix:true,canEditFiles:true,requiresApproval:true,requiresReview:e.requiresReview??false,files:[t,i],command:Ae(n),operation:n,verifyCommand:"npx rapidkit doctor project --json",refreshCommands:["npx rapidkit doctor project --json","npx rapidkit workspace verify --json"],reason:e.reason,limitations:e.limitations}}function At(e){return e.lint&&e.lint.trim().length>0?"npm run lint":e.build&&e.build.trim().length>0?"npm run build":null}function Ot(e){let t=`frontend-script-${e.scriptName}`,i=s.join(e.projectPath,"package.json"),n=["npx rapidkit doctor project --json","npx rapidkit workspace verify --json"];return e.scriptValue?{id:`${t}.package-json-script`,issueId:t,title:`Add package.json ${e.scriptName} script`,status:"available",fixKind:"package-json-script",risk:"guarded",canAutoFix:true,canEditFiles:true,requiresApproval:true,requiresReview:false,files:[i],command:Ft({projectPath:e.projectPath,scriptName:e.scriptName,scriptValue:e.scriptValue}),operation:{type:"package-json-script",path:i,scriptName:e.scriptName,scriptValue:e.scriptValue},verifyCommand:"npx rapidkit doctor project --json",refreshCommands:n,reason:`Reuse the existing ${e.scriptValue} validation path as the ${e.scriptName} gate for ${e.frameworkDisplayName}.`}:{id:`${t}.manual`,issueId:t,title:`Define ${e.scriptName} script`,status:"manual",fixKind:"manual",risk:"guarded",canAutoFix:false,canEditFiles:false,requiresApproval:true,requiresReview:true,files:[i],refreshCommands:n,reason:`No safe ${e.frameworkDisplayName} fallback script could be inferred from existing package.json scripts.`,limitations:["Add a real test/lint/build command that matches the project quality gate before release."]}}function Mt(e){let t=s.join(e.projectPath,"package.json");return {id:`${e.issueId}.package-json-script`,issueId:e.issueId,title:e.title,status:"available",fixKind:"package-json-script",risk:e.risk??"guarded",canAutoFix:true,canEditFiles:true,requiresApproval:true,requiresReview:e.requiresReview??false,files:[t],command:Ft({projectPath:e.projectPath,scriptName:e.scriptName,scriptValue:e.scriptValue}),operation:{type:"package-json-script",path:t,scriptName:e.scriptName,scriptValue:e.scriptValue},verifyCommand:"npx rapidkit doctor project --json",refreshCommands:["npx rapidkit doctor project --json","npx rapidkit workspace verify --json"],reason:e.reason,limitations:e.limitations}}function Tt(e){let t=s.join(e.projectPath,"Makefile"),i={type:"makefile-target",path:t,target:e.targetName,command:e.command,phony:true};return {id:`${e.issueId}.makefile-target`,issueId:e.issueId,title:e.title,status:"available",fixKind:"file-append",risk:e.risk??"guarded",canAutoFix:true,canEditFiles:true,requiresApproval:true,requiresReview:e.requiresReview??true,files:[t],command:Ae(i),operation:i,verifyCommand:"npx rapidkit doctor project --json",refreshCommands:["npx rapidkit doctor project --json","npx rapidkit workspace verify --json"],reason:e.reason,limitations:e.limitations}}function Ht(e){return {id:`${e.issueId}.command`,issueId:e.issueId,title:e.title,status:"available",fixKind:e.fixKind??"command",risk:e.risk??"guarded",canAutoFix:true,canEditFiles:false,requiresApproval:true,requiresReview:e.requiresReview??true,files:e.files.map(t=>s.join(e.projectPath,t)),command:`cd ${Qe(e.projectPath)} && ${e.command}`,verifyCommand:"npx rapidkit doctor project --json",refreshCommands:["npx rapidkit doctor project --json","npx rapidkit workspace verify --json"],reason:e.reason,limitations:e.limitations}}var yn=[".eslintrc.js",".eslintrc.cjs",".eslintrc.json",".eslintrc.yaml",".eslintrc.yml","eslint.config.js","eslint.config.mjs","eslint.config.cjs"],hn=["tests","test","src/test","__tests__","e2e","playwright","cypress"],kn=["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"],wn=["src","app","pages"],vn=["dev","build","test","lint"];function _t(e){let t=e?.scripts;if(!t||typeof t!="object"||Array.isArray(t))return {};let i={};for(let[n,o]of Object.entries(t))typeof o=="string"&&o.trim().length>0&&(i[n]=o);return i}async function Bt(e,t){for(let o of yn)if(await c$1.pathExists(s.join(e,o)))return true;let i=t??(await c$1.pathExists(s.join(e,"package.json"))?await c$1.readJson(s.join(e,"package.json")):null);if(!i)return false;if(i.eslintConfig)return true;let n={...i.dependencies??{},...i.devDependencies??{}};return !!(n.eslint||n["@eslint/js"]||n["@eslint/eslintrc"])}async function qt(e,t){for(let o of hn)if(await c$1.pathExists(s.join(e,o)))return true;for(let o of kn)if(await c$1.pathExists(s.join(e,o)))return true;let i=_t(t);if(i.test||i["test:unit"]||i["test:e2e"]||i["test:ci"]||i["test:watch"])return true;let n={...t?.dependencies??{},...t?.devDependencies??{}};return n.vitest||n.jest||n["@playwright/test"]||n.cypress?true:await bn(e)}async function bn(e){let t=["src","app","pages","components"],i=/\.(test|spec)\.(tsx?|jsx?|vue|svelte)$/i,o=new Set(["node_modules",".git","dist","build",".next","coverage",".turbo"]);for(let a of t){let r=s.join(e,a);if(!await c$1.pathExists(r))continue;let l=[{dir:r,depth:0}];for(;l.length>0;){let d=l.shift();if(!d)break;let u=[];try{u=await c$1.readdir(d.dir);}catch{continue}for(let h of u){let y=s.join(d.dir,h);if(i.test(h))return true;if(!(d.depth>=3||o.has(h)||h.startsWith(".")))try{(await c$1.stat(y)).isDirectory()&&l.push({dir:y,depth:d.depth+1});}catch{continue}}}}return false}async function tt(e){for(let t of wn){let i=s.join(e,t);if(await c$1.pathExists(i))try{if((await c$1.readdir(i)).some(o=>!o.startsWith(".")))return true}catch{continue}}return false}function jn(e){let t=e.key;return b$5(t).key}function xn(e,t,i){return a$4(t,i).some(o=>!!e[o])}async function Kt(e){let{projectPath:t,detection:i,packageJsonData:n}=e,o=jn(i),a=b$5(o),r=_t(n),l=[],d=await c$1.pathExists(s.join(t,"package-lock.json"))||await c$1.pathExists(s.join(t,"pnpm-lock.yaml"))||await c$1.pathExists(s.join(t,"yarn.lock"))||await c$1.pathExists(s.join(t,"bun.lockb"));l.push({id:"frontend-lockfile-integrity",label:"Frontend lockfile integrity",status:d?"pass":"warn",severity:"warn",scope:"project-scoped",reason:d?"Node lockfile detected for deterministic dependency restore.":"No Node lockfile detected (package-lock/yarn.lock/pnpm-lock.yaml/bun.lockb).",recommendation:d?void 0:"Commit a lockfile for deterministic installs and CI parity."});let u=await c$1.pathExists(s.join(t,"tsconfig.json")),h=await c$1.pathExists(s.join(t,"jsconfig.json")),y=u||h;l.push({id:"frontend-typescript-surface",label:"TypeScript project surface",status:y?"pass":"warn",severity:"warn",scope:"project-scoped",reason:y?u?"tsconfig.json detected.":"jsconfig.json detected.":"No tsconfig.json or jsconfig.json detected.",recommendation:y?void 0:"Add tsconfig.json (or jsconfig.json) for typed frontend builds and IDE parity."});let w=a.fileHints.length>0&&a.fileHints.some(f=>c$1.pathExistsSync(s.join(t,f)));l.push({id:"frontend-framework-config",label:`${a.displayName} config surface`,status:w?"pass":"warn",severity:"warn",scope:"project-scoped",reason:w?`${a.displayName} configuration artifacts detected.`:`No ${a.displayName} config markers detected (${a.fileHints.join(", ")||"n/a"}).`,recommendation:w?void 0:"Keep framework config files in-repo for reproducible dev/build behavior."});for(let f of vn){let v=xn(r,o,f),x=f==="dev"||f==="build",k=!v&&f==="test"?Ot({projectPath:t,frameworkDisplayName:a.displayName,scriptName:f,scriptValue:At(r)}):void 0;l.push({id:`frontend-script-${f}`,label:`${f} script surface`,status:v?"pass":x?"fail":"warn",severity:x?"error":"warn",scope:"project-scoped",reason:v?`package.json exposes a ${f} script for ${a.displayName}.`:`No ${f} script detected for ${a.displayName}.`,recommendation:v?void 0:`Add a "${a$4(o,f)[0]??f}" script to package.json.`,repairCapability:k});}let g=await tt(t);return l.push({id:"frontend-source-tree",label:"Frontend source tree",status:g?"pass":"warn",severity:"warn",scope:"project-scoped",reason:g?"Application source directories detected (src/app/pages).":"No frontend source directories detected under src/, app/, or pages/.",recommendation:g?void 0:"Ensure the scaffolded application tree exists before running lifecycle commands."}),l}var Pn={node:["package-lock.json","pnpm-lock.yaml","yarn.lock","bun.lock","bun.lockb"],deno:["deno.lock"],bun:["bun.lock","bun.lockb"],python:["uv.lock","poetry.lock","requirements.txt","requirements.lock"],go:["go.sum"],java:["pom.xml","gradle.lockfile","gradle/libs.versions.toml"],rust:["Cargo.lock"],elixir:["mix.lock"],clojure:["deps.edn","project.clj"],php:["composer.lock"],ruby:["Gemfile.lock"],dotnet:["packages.lock.json","Directory.Packages.props"],unknown:[]},Cn={node:["package.json"],deno:["deno.json","deno.jsonc"],bun:["package.json","bunfig.toml"],python:["pyproject.toml","requirements.txt","setup.py"],go:["go.mod"],java:["pom.xml","build.gradle","build.gradle.kts"],rust:["Cargo.toml"],elixir:["mix.exs"],clojure:["deps.edn","project.clj"],php:["composer.json"],ruby:["Gemfile"],dotnet:["*.csproj","*.sln"],unknown:[]},Rn=["node_modules",".git",".rapidkit/reports",".venv","dist","build","coverage",".env",".env.*","!.env.example"].join(`
|
|
1
|
+
import {c,b}from'./chunk-ULIVVMT6.js';import {f as f$1,e}from'./chunk-PCXSTKZ5.js';import {b as b$2}from'./chunk-KMUWWZRT.js';import {j,g}from'./chunk-COBMOVUK.js';import {b as b$1}from'./chunk-CDCYRBAY.js';import {c as c$3,a as a$2,b as b$3}from'./chunk-NFUXULIF.js';import {q}from'./chunk-2ZLIVGO7.js';import {i,d,b as b$5,a as a$4}from'./chunk-4KUIFXHM.js';import {a as a$1}from'./chunk-TDSIF42O.js';import {f}from'./chunk-OLDPVVSV.js';import {c as c$2,l,i as i$1,b as b$4,q as q$1,m,o}from'./chunk-WRMCPKGA.js';import {a as a$3}from'./chunk-2FIX2MDC.js';import {a}from'./chunk-HHJAANUC.js';import p from'chalk';import {createHash}from'crypto';import {execa}from'execa';import c$1 from'fs-extra';import s from'path';function Qe(e){return `"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function Ft(e){let t=`scripts.${e.scriptName}=${e.scriptValue}`;return `cd ${Qe(e.projectPath)} && npm pkg set ${Qe(t)}`}function Ae(e){return `rapidkit:doctor:repair ${Buffer.from(JSON.stringify(e),"utf8").toString("base64url")}`}function et(e){let t=s.join(e.projectPath,e.relativePath),i={type:"file-create",path:t,content:e.content,overwrite:false};return {id:`${e.issueId}.file-create`,issueId:e.issueId,title:e.title,status:"available",fixKind:"file-create",risk:e.risk??"safe",canAutoFix:true,canEditFiles:true,requiresApproval:true,requiresReview:e.requiresReview??false,files:[t],command:Ae(i),operation:i,verifyCommand:"npx rapidkit doctor project --json",refreshCommands:["npx rapidkit doctor project --json","npx rapidkit workspace verify --json"],reason:e.reason,limitations:e.limitations}}function Nt(e){let t=s.join(e.projectPath,e.relativePath),i={type:"file-append",path:t,lines:e.lines,ensureNewline:true};return {id:`${e.issueId}.file-append`,issueId:e.issueId,title:e.title,status:"available",fixKind:"file-append",risk:e.risk??"safe",canAutoFix:true,canEditFiles:true,requiresApproval:true,requiresReview:e.requiresReview??false,files:[t],command:Ae(i),operation:i,verifyCommand:"npx rapidkit doctor project --json",refreshCommands:["npx rapidkit doctor project --json","npx rapidkit workspace verify --json"],reason:e.reason,limitations:e.limitations}}function It(e){let t=s.join(e.projectPath,e.sourceRelativePath),i=s.join(e.projectPath,e.targetRelativePath),n={type:"file-copy",sourcePath:t,path:i,overwrite:false};return {id:`${e.issueId}.file-copy`,issueId:e.issueId,title:e.title,status:"available",fixKind:"file-copy",risk:e.risk??"safe",canAutoFix:true,canEditFiles:true,requiresApproval:true,requiresReview:e.requiresReview??false,files:[t,i],command:Ae(n),operation:n,verifyCommand:"npx rapidkit doctor project --json",refreshCommands:["npx rapidkit doctor project --json","npx rapidkit workspace verify --json"],reason:e.reason,limitations:e.limitations}}function At(e){return e.lint&&e.lint.trim().length>0?"npm run lint":e.build&&e.build.trim().length>0?"npm run build":null}function Ot(e){let t=`frontend-script-${e.scriptName}`,i=s.join(e.projectPath,"package.json"),n=["npx rapidkit doctor project --json","npx rapidkit workspace verify --json"];return e.scriptValue?{id:`${t}.package-json-script`,issueId:t,title:`Add package.json ${e.scriptName} script`,status:"available",fixKind:"package-json-script",risk:"guarded",canAutoFix:true,canEditFiles:true,requiresApproval:true,requiresReview:false,files:[i],command:Ft({projectPath:e.projectPath,scriptName:e.scriptName,scriptValue:e.scriptValue}),operation:{type:"package-json-script",path:i,scriptName:e.scriptName,scriptValue:e.scriptValue},verifyCommand:"npx rapidkit doctor project --json",refreshCommands:n,reason:`Reuse the existing ${e.scriptValue} validation path as the ${e.scriptName} gate for ${e.frameworkDisplayName}.`}:{id:`${t}.manual`,issueId:t,title:`Define ${e.scriptName} script`,status:"manual",fixKind:"manual",risk:"guarded",canAutoFix:false,canEditFiles:false,requiresApproval:true,requiresReview:true,files:[i],refreshCommands:n,reason:`No safe ${e.frameworkDisplayName} fallback script could be inferred from existing package.json scripts.`,limitations:["Add a real test/lint/build command that matches the project quality gate before release."]}}function Mt(e){let t=s.join(e.projectPath,"package.json");return {id:`${e.issueId}.package-json-script`,issueId:e.issueId,title:e.title,status:"available",fixKind:"package-json-script",risk:e.risk??"guarded",canAutoFix:true,canEditFiles:true,requiresApproval:true,requiresReview:e.requiresReview??false,files:[t],command:Ft({projectPath:e.projectPath,scriptName:e.scriptName,scriptValue:e.scriptValue}),operation:{type:"package-json-script",path:t,scriptName:e.scriptName,scriptValue:e.scriptValue},verifyCommand:"npx rapidkit doctor project --json",refreshCommands:["npx rapidkit doctor project --json","npx rapidkit workspace verify --json"],reason:e.reason,limitations:e.limitations}}function Tt(e){let t=s.join(e.projectPath,"Makefile"),i={type:"makefile-target",path:t,target:e.targetName,command:e.command,phony:true};return {id:`${e.issueId}.makefile-target`,issueId:e.issueId,title:e.title,status:"available",fixKind:"file-append",risk:e.risk??"guarded",canAutoFix:true,canEditFiles:true,requiresApproval:true,requiresReview:e.requiresReview??true,files:[t],command:Ae(i),operation:i,verifyCommand:"npx rapidkit doctor project --json",refreshCommands:["npx rapidkit doctor project --json","npx rapidkit workspace verify --json"],reason:e.reason,limitations:e.limitations}}function Ht(e){return {id:`${e.issueId}.command`,issueId:e.issueId,title:e.title,status:"available",fixKind:e.fixKind??"command",risk:e.risk??"guarded",canAutoFix:true,canEditFiles:false,requiresApproval:true,requiresReview:e.requiresReview??true,files:e.files.map(t=>s.join(e.projectPath,t)),command:`cd ${Qe(e.projectPath)} && ${e.command}`,verifyCommand:"npx rapidkit doctor project --json",refreshCommands:["npx rapidkit doctor project --json","npx rapidkit workspace verify --json"],reason:e.reason,limitations:e.limitations}}var yn=[".eslintrc.js",".eslintrc.cjs",".eslintrc.json",".eslintrc.yaml",".eslintrc.yml","eslint.config.js","eslint.config.mjs","eslint.config.cjs"],hn=["tests","test","src/test","__tests__","e2e","playwright","cypress"],kn=["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"],wn=["src","app","pages"],vn=["dev","build","test","lint"];function _t(e){let t=e?.scripts;if(!t||typeof t!="object"||Array.isArray(t))return {};let i={};for(let[n,o]of Object.entries(t))typeof o=="string"&&o.trim().length>0&&(i[n]=o);return i}async function Bt(e,t){for(let o of yn)if(await c$1.pathExists(s.join(e,o)))return true;let i=t??(await c$1.pathExists(s.join(e,"package.json"))?await c$1.readJson(s.join(e,"package.json")):null);if(!i)return false;if(i.eslintConfig)return true;let n={...i.dependencies??{},...i.devDependencies??{}};return !!(n.eslint||n["@eslint/js"]||n["@eslint/eslintrc"])}async function qt(e,t){for(let o of hn)if(await c$1.pathExists(s.join(e,o)))return true;for(let o of kn)if(await c$1.pathExists(s.join(e,o)))return true;let i=_t(t);if(i.test||i["test:unit"]||i["test:e2e"]||i["test:ci"]||i["test:watch"])return true;let n={...t?.dependencies??{},...t?.devDependencies??{}};return n.vitest||n.jest||n["@playwright/test"]||n.cypress?true:await bn(e)}async function bn(e){let t=["src","app","pages","components"],i=/\.(test|spec)\.(tsx?|jsx?|vue|svelte)$/i,o=new Set(["node_modules",".git","dist","build",".next","coverage",".turbo"]);for(let a of t){let r=s.join(e,a);if(!await c$1.pathExists(r))continue;let l=[{dir:r,depth:0}];for(;l.length>0;){let d=l.shift();if(!d)break;let u=[];try{u=await c$1.readdir(d.dir);}catch{continue}for(let h of u){let y=s.join(d.dir,h);if(i.test(h))return true;if(!(d.depth>=3||o.has(h)||h.startsWith(".")))try{(await c$1.stat(y)).isDirectory()&&l.push({dir:y,depth:d.depth+1});}catch{continue}}}}return false}async function tt(e){for(let t of wn){let i=s.join(e,t);if(await c$1.pathExists(i))try{if((await c$1.readdir(i)).some(o=>!o.startsWith(".")))return true}catch{continue}}return false}function jn(e){let t=e.key;return b$5(t).key}function xn(e,t,i){return a$4(t,i).some(o=>!!e[o])}async function Kt(e){let{projectPath:t,detection:i,packageJsonData:n}=e,o=jn(i),a=b$5(o),r=_t(n),l=[],d=await c$1.pathExists(s.join(t,"package-lock.json"))||await c$1.pathExists(s.join(t,"pnpm-lock.yaml"))||await c$1.pathExists(s.join(t,"yarn.lock"))||await c$1.pathExists(s.join(t,"bun.lockb"));l.push({id:"frontend-lockfile-integrity",label:"Frontend lockfile integrity",status:d?"pass":"warn",severity:"warn",scope:"project-scoped",reason:d?"Node lockfile detected for deterministic dependency restore.":"No Node lockfile detected (package-lock/yarn.lock/pnpm-lock.yaml/bun.lockb).",recommendation:d?void 0:"Commit a lockfile for deterministic installs and CI parity."});let u=await c$1.pathExists(s.join(t,"tsconfig.json")),h=await c$1.pathExists(s.join(t,"jsconfig.json")),y=u||h;l.push({id:"frontend-typescript-surface",label:"TypeScript project surface",status:y?"pass":"warn",severity:"warn",scope:"project-scoped",reason:y?u?"tsconfig.json detected.":"jsconfig.json detected.":"No tsconfig.json or jsconfig.json detected.",recommendation:y?void 0:"Add tsconfig.json (or jsconfig.json) for typed frontend builds and IDE parity."});let w=a.fileHints.length>0&&a.fileHints.some(f=>c$1.pathExistsSync(s.join(t,f)));l.push({id:"frontend-framework-config",label:`${a.displayName} config surface`,status:w?"pass":"warn",severity:"warn",scope:"project-scoped",reason:w?`${a.displayName} configuration artifacts detected.`:`No ${a.displayName} config markers detected (${a.fileHints.join(", ")||"n/a"}).`,recommendation:w?void 0:"Keep framework config files in-repo for reproducible dev/build behavior."});for(let f of vn){let v=xn(r,o,f),x=f==="dev"||f==="build",k=!v&&f==="test"?Ot({projectPath:t,frameworkDisplayName:a.displayName,scriptName:f,scriptValue:At(r)}):void 0;l.push({id:`frontend-script-${f}`,label:`${f} script surface`,status:v?"pass":x?"fail":"warn",severity:x?"error":"warn",scope:"project-scoped",reason:v?`package.json exposes a ${f} script for ${a.displayName}.`:`No ${f} script detected for ${a.displayName}.`,recommendation:v?void 0:`Add a "${a$4(o,f)[0]??f}" script to package.json.`,repairCapability:k});}let g=await tt(t);return l.push({id:"frontend-source-tree",label:"Frontend source tree",status:g?"pass":"warn",severity:"warn",scope:"project-scoped",reason:g?"Application source directories detected (src/app/pages).":"No frontend source directories detected under src/, app/, or pages/.",recommendation:g?void 0:"Ensure the scaffolded application tree exists before running lifecycle commands."}),l}var Pn={node:["package-lock.json","pnpm-lock.yaml","yarn.lock","bun.lock","bun.lockb"],deno:["deno.lock"],bun:["bun.lock","bun.lockb"],python:["uv.lock","poetry.lock","requirements.txt","requirements.lock"],go:["go.sum"],java:["pom.xml","gradle.lockfile","gradle/libs.versions.toml"],rust:["Cargo.lock"],elixir:["mix.lock"],clojure:["deps.edn","project.clj"],php:["composer.lock"],ruby:["Gemfile.lock"],dotnet:["packages.lock.json","Directory.Packages.props"],unknown:[]},Cn={node:["package.json"],deno:["deno.json","deno.jsonc"],bun:["package.json","bunfig.toml"],python:["pyproject.toml","requirements.txt","setup.py"],go:["go.mod"],java:["pom.xml","build.gradle","build.gradle.kts"],rust:["Cargo.toml"],elixir:["mix.exs"],clojure:["deps.edn","project.clj"],php:["composer.json"],ruby:["Gemfile"],dotnet:["*.csproj","*.sln"],unknown:[]},Rn=["node_modules",".git",".rapidkit/reports",".venv","dist","build","coverage",".env",".env.*","!.env.example"].join(`
|
|
2
2
|
`),nt=[".env",".env.*","!.env.example"];function Re(e){return e?e==="bun"?"node":e==="python"||e==="node"||e==="go"||e==="java"||e==="rust"||e==="elixir"||e==="clojure"||e==="deno"||e==="php"||e==="ruby"||e==="dotnet"?e:"unknown":"unknown"}async function Oe(e,t){for(let i of t){if(i.includes("*")){let n=i.replace("*","");if(await Dn(e,n,2))return true;continue}if(await c$1.pathExists(s.join(e,i)))return true}return false}async function Dn(e,t,i){let n=[{dir:e,depth:0}],o=new Set(["node_modules",".git",".rapidkit","dist","build","coverage"]);for(;n.length>0;){let a=n.shift();if(!a)break;let r=[];try{r=await c$1.readdir(a.dir,{withFileTypes:true});}catch{continue}for(let l of r){if(o.has(l.name))continue;let d=s.join(a.dir,l.name);if(l.isFile()&&l.name.endsWith(t))return true;l.isDirectory()&&a.depth<i&&!l.name.startsWith(".")&&n.push({dir:d,depth:a.depth+1});}}return false}async function Me(e){try{return await c$1.pathExists(e)?await c$1.readFile(e,"utf8"):""}catch{return ""}}async function it(e,t){let i=[];for(let n of t){let o=await Me(s.join(e,n));o&&i.push(o);}return i.join(`
|
|
3
3
|
`)}async function En(e){if(e.runtime==="node"){let t=typeof e.packageJsonData?.packageManager=="string"?e.packageJsonData.packageManager.split("@")[0]:null;return {command:t==="pnpm"?"pnpm install":t==="yarn"?"yarn install":t==="bun"?"bun install":"npm install",title:"Generate Node dependency lockfile",files:["package.json","package-lock.json","pnpm-lock.yaml","yarn.lock","bun.lock"],limitations:["Review dependency and lockfile changes before committing."]}}if(e.runtime==="go"&&await c$1.pathExists(s.join(e.projectPath,"go.mod")))return {command:"go mod tidy",title:"Reconcile Go module graph",files:["go.mod","go.sum"],limitations:["Review go.mod/go.sum changes before committing."]};if(e.runtime==="rust")return {command:"cargo fetch",title:"Generate Rust dependency baseline",files:["Cargo.toml","Cargo.lock"],limitations:["Review Cargo.lock changes before committing."]};if(e.runtime==="php")return {command:"composer install",title:"Generate Composer lockfile",files:["composer.json","composer.lock"],limitations:["Review composer.lock changes before committing."]};if(e.runtime==="ruby")return {command:"bundle install",title:"Generate Bundler lockfile",files:["Gemfile","Gemfile.lock"],limitations:["Review Gemfile.lock changes before committing."]};if(e.runtime==="dotnet")return {command:"dotnet restore",title:".NET dependency restore",files:["*.sln","*.csproj","packages.lock.json","Directory.Packages.props"],limitations:["Enable NuGet lock files in the project when release policy requires deterministic restore."]};if(e.runtime==="elixir")return {command:"mix deps.get",title:"Generate Elixir dependency lockfile",files:["mix.exs","mix.lock"],limitations:["Review mix.lock changes before committing."]};if(e.runtime==="clojure")return {command:"clojure -P",title:"Prepare Clojure dependency baseline",files:["deps.edn","project.clj"],limitations:["Review dependency cache and CI restore policy before release."]};if(e.runtime==="python"){let t=await Me(s.join(e.projectPath,"pyproject.toml"));if(/\[tool\.poetry\]/.test(t))return {command:"poetry install --no-root",title:"Install Poetry dependency baseline",files:["pyproject.toml","poetry.lock"],limitations:["Review poetry.lock changes before committing when Poetry resolves or updates the lockfile."]};if(/\[tool\.uv\]|\[project\]/.test(t))return {command:"uv lock",title:"Generate uv lockfile",files:["pyproject.toml","uv.lock"],limitations:["Review uv.lock changes before committing."]}}return null}function rt(e){let t=e?.scripts;if(!t||typeof t!="object"||Array.isArray(t))return {};let i={};for(let[n,o]of Object.entries(t))typeof o=="string"&&o.trim().length>0&&(i[n]=o);return i}function Sn(e){if(e.runtime==="node"){let i=rt(e.packageJsonData);if(!e.packageJsonData)return null;if(e.kind==="test"){let n=i.lint?"npm run lint":i.build?"npm run build":null;return n?{command:n,title:"Define Node test script",targetName:"test",files:["package.json"],limitations:["Replace this fallback with real tests when product coverage is required."]}:null}return e.kind==="security"?{command:"npm audit --audit-level=moderate",title:"Define Node security audit script",targetName:"audit",files:["package.json"]}:null}return {python:{test:{command:"python -m pytest",title:"Define Python test command",targetName:"test",files:["Makefile","pyproject.toml"]},quality:{command:"python -m ruff check .",title:"Define Python quality command",targetName:"quality",files:["Makefile","pyproject.toml"],limitations:["Ensure ruff is declared in project dev dependencies before enforcing in CI."]},security:{command:"python -m pip_audit",title:"Define Python security audit command",targetName:"security",files:["Makefile","pyproject.toml"],limitations:["Ensure pip-audit is available in the project toolchain before enforcing in CI."]}},go:{test:{command:"go test ./...",title:"Define Go test command",targetName:"test",files:["Makefile","go.mod"]},quality:{command:"gofmt -w .",title:"Define Go formatting command",targetName:"quality",files:["Makefile","go.mod"],limitations:["Use CI-specific check mode if formatting should not mutate files in pipelines."]},security:{command:"govulncheck ./...",title:"Define Go vulnerability scan command",targetName:"security",files:["Makefile","go.mod"],limitations:["Ensure govulncheck is installed or provisioned by CI before enforcing."]}},rust:{test:{command:"cargo test",title:"Define Rust test command",targetName:"test",files:["Makefile","Cargo.toml"]},quality:{command:"cargo fmt -- --check && cargo clippy --all-targets -- -D warnings",title:"Define Rust quality command",targetName:"quality",files:["Makefile","Cargo.toml"]},security:{command:"cargo audit",title:"Define Rust security audit command",targetName:"security",files:["Makefile","Cargo.toml"],limitations:["Ensure cargo-audit is installed or provisioned by CI before enforcing."]}},php:{test:{command:"vendor/bin/phpunit",title:"Define PHP test command",targetName:"test",files:["Makefile","composer.json"]},quality:{command:"vendor/bin/phpstan analyse",title:"Define PHP static analysis command",targetName:"quality",files:["Makefile","composer.json"],limitations:["Ensure phpstan is declared in require-dev before enforcing in CI."]},security:{command:"composer audit",title:"Define Composer security audit command",targetName:"security",files:["Makefile","composer.json"]}},ruby:{test:{command:"bundle exec rspec",title:"Define Ruby test command",targetName:"test",files:["Makefile","Gemfile"],limitations:["Use bundle exec ruby -Itest when the project uses minitest instead of RSpec."]},quality:{command:"bundle exec rubocop",title:"Define Ruby quality command",targetName:"quality",files:["Makefile","Gemfile"]},security:{command:"bundle exec bundler-audit check",title:"Define Ruby security audit command",targetName:"security",files:["Makefile","Gemfile"],limitations:["Ensure bundler-audit is installed or provisioned by CI before enforcing."]}},dotnet:{test:{command:"dotnet test",title:"Define .NET test command",targetName:"test",files:["Makefile","*.sln","*.csproj"]},quality:{command:"dotnet format --verify-no-changes",title:"Define .NET formatting gate",targetName:"quality",files:["Makefile","*.sln","*.csproj"]},security:{command:"dotnet list package --vulnerable",title:"Define .NET package vulnerability check",targetName:"security",files:["Makefile","*.sln","*.csproj"]}},java:{test:{command:"mvn test",title:"Define Java test command",targetName:"test",files:["Makefile","pom.xml","build.gradle","build.gradle.kts"],limitations:["Use ./gradlew test when the project is Gradle-first."]},quality:{command:"mvn verify",title:"Define Java verification command",targetName:"quality",files:["Makefile","pom.xml","build.gradle","build.gradle.kts"],limitations:["Use ./gradlew check when the project is Gradle-first."]},security:{command:"mvn org.owasp:dependency-check-maven:check",title:"Define Java dependency vulnerability check",targetName:"security",files:["Makefile","pom.xml"],limitations:["Review OWASP dependency-check policy and cache behavior before enforcing in CI."]}}}[e.runtime]?.[e.kind]??null}async function $n(e){return Tt({issueId:e.issueId,title:e.contract.title,projectPath:e.projectPath,targetName:e.contract.targetName,command:e.contract.command,reason:e.reason,risk:"guarded",requiresReview:true,limitations:e.contract.limitations})}async function ot(e){let t=Sn({runtime:e.runtime,kind:e.kind,packageJsonData:e.packageJsonData});if(t)return e.runtime==="node"&&e.packageJsonData?Mt({issueId:e.issueId,title:t.title,projectPath:e.projectPath,scriptName:t.targetName,scriptValue:t.command,reason:e.reason,risk:"guarded",limitations:t.limitations}):$n({issueId:e.issueId,projectPath:e.projectPath,contract:t,reason:e.reason})}function De(e){return {id:`${e.issueId}.manual`,issueId:e.issueId,title:e.title,status:"manual",fixKind:"manual",risk:"guarded",canAutoFix:false,canEditFiles:false,requiresApproval:true,requiresReview:true,files:e.files.map(t=>s.join(e.projectPath,t)),refreshCommands:["npx rapidkit doctor project --json","npx rapidkit workspace verify --json"],reason:e.reason,limitations:e.limitations}}function Fn(e){return et({issueId:"surface-dockerignore",title:"Create .dockerignore",projectPath:e,relativePath:".dockerignore",content:`${Rn}
|
|
4
4
|
`,reason:"Create a Docker build ignore baseline to keep secrets, dependencies, and reports out of container contexts."})}async function Nn(e){if(!await c$1.pathExists(s.join(e,".gitignore")))return et({issueId:"surface-security-hygiene",title:"Create .gitignore secret baseline",projectPath:e,relativePath:".gitignore",content:`${nt.join(`
|
|
5
5
|
`)}
|
|
6
|
-
`,reason:"Create a minimal ignore baseline so local env files are not committed accidentally."});let t=await Me(s.join(e,".gitignore")),i=nt.filter(n=>!t.split(/\r?\n/).includes(n));return Nt({issueId:"surface-security-hygiene",title:"Append .gitignore secret baseline",projectPath:e,relativePath:".gitignore",lines:i,reason:"Append missing env-file ignore rules so local secrets stay out of source control."})}async function In(e){let t=Cn[e.runtime]??[],i=Pn[e.runtime]??[];if(t.length===0&&i.length===0)return null;let n=await Oe(e.projectPath,t),o=await Oe(e.projectPath,i),a=n&&!o?await En({projectPath:e.projectPath,runtime:e.runtime,packageJsonData:e.packageJsonData}):null;return {id:"surface-dependency-contract",label:"Dependency contract",status:!n||o?"pass":"warn",severity:"warn",scope:"project-scoped",reason:n?o?"Dependency manifest and deterministic lock/baseline markers detected.":`Dependency manifest detected, but no deterministic baseline found (${i.join(", ")}).`:"No dependency manifest markers detected for this runtime.",recommendation:n&&!o?"Generate and commit the runtime-native lockfile or package baseline before release.":void 0,repairCapability:n&&!o&&a?Ht({issueId:"surface-dependency-contract",title:a.title,projectPath:e.projectPath,command:a.command,files:a.files,fixKind:"dependency-sync",reason:"Generate the runtime-native dependency baseline so CI, Doctor, and Studio share deterministic dependency evidence.",limitations:a.limitations}):void 0}}async function An(e){let t=await c$1.pathExists(s.join(e.projectPath,".env.example")),i=await c$1.pathExists(s.join(e.projectPath,".env")),n=await c$1.pathExists(s.join(e.projectPath,"docs","env.md"))||await c$1.pathExists(s.join(e.projectPath,"ENVIRONMENT.md")),o=await c$1.pathExists(s.join(e.projectPath,"config")),a=t||n||o,r=e.projectKind==="frontend";return {id:"surface-env-contract",label:"Environment/config contract",status:a?"pass":"warn",severity:"warn",scope:"project-scoped",reason:a?"Environment/config contract marker detected.":r?"No frontend environment contract marker detected.":"No environment/config contract marker detected.",recommendation:a?void 0:"Add .env.example, config schema, or environment documentation for deterministic setup.",repairCapability:a?t&&!i?It({issueId:"surface-env-contract",title:"Create local .env from .env.example",projectPath:e.projectPath,sourceRelativePath:".env.example",targetRelativePath:".env",reason:"Seed the local environment file from the reviewed example without overwriting an existing .env."}):void 0:De({issueId:"surface-env-contract",title:"Define environment contract",projectPath:e.projectPath,files:[".env.example"],reason:"Environment contracts are product-specific; Doctor can identify the missing baseline, but values must be reviewed by the project owner."})}}async function On(e){let t=await c$1.pathExists(s.join(e.projectPath,"Dockerfile")),i=await c$1.pathExists(s.join(e.projectPath,".dockerignore")),n=await c$1.pathExists(s.join(e.projectPath,"docker-compose.yml"))||await c$1.pathExists(s.join(e.projectPath,"compose.yml"));return t?{id:"surface-dockerignore",label:"Container build context hygiene",status:i?"pass":"warn",severity:"warn",scope:"project-scoped",reason:i?"Dockerfile and .dockerignore detected.":"Dockerfile detected without .dockerignore.",recommendation:i?void 0:"Add .dockerignore to exclude dependencies, reports, git metadata, and local env files from image builds.",repairCapability:i?void 0:Fn(e.projectPath)}:{id:"surface-container-contract",label:"Container contract",status:n?"pass":"warn",severity:"warn",scope:"project-scoped",reason:n?"Compose surface detected; project has a local container orchestration baseline.":"No Dockerfile or compose surface detected.",recommendation:e.projectKind==="backend"||e.projectKind==="fullstack"?"Add Dockerfile or compose baseline when this service is expected to run in containerized environments.":"Add container baseline only if this app is shipped through containerized environments."}}async function Mn(e){let t=["k8s","kubernetes","deploy","deployments","charts","helm","kustomization.yaml","kustomization.yml"];if(!await Oe(e.projectPath,t))return {id:"surface-deploy-contract",label:"Deployment contract",status:"warn",severity:"warn",scope:"project-scoped",reason:"No Kubernetes/Helm/Kustomize deployment surface detected.",recommendation:e.projectKind==="backend"||e.projectKind==="fullstack"?"Add deployment manifests or document the non-Kubernetes deployment path.":"Document the deployment path when this frontend is production-hosted."};let n=await it(e.projectPath,["k8s/deployment.yaml","k8s/deployment.yml","kubernetes/deployment.yaml","deploy/deployment.yaml","deployment.yaml","deployment.yml","values.yaml","charts/values.yaml"]),o=/readinessProbe|livenessProbe|startupProbe/.test(n),a=/resources:\s*[\s\S]*(limits:|requests:)/.test(n),r=o&&a;return {id:"surface-kubernetes-readiness",label:"Deployment readiness controls",status:r?"pass":"warn",severity:"warn",scope:"project-scoped",reason:r?"Deployment surface includes probe and resource-control markers.":"Deployment surface detected, but readiness/liveness probes or resource controls are incomplete.",recommendation:r?void 0:"Add readiness/liveness/startup probes and resource requests/limits to production deployment manifests.",repairCapability:r?void 0:De({issueId:"surface-kubernetes-readiness",title:"Harden deployment readiness controls",projectPath:e.projectPath,files:["k8s/","helm/","deploy/"],reason:"Deployment manifests are environment-specific and should be reviewed before mutation."})}}async function Tn(e){let t=await c$1.pathExists(s.join(e.projectPath,".gitignore")),n=(await Me(s.join(e.projectPath,".gitignore"))).split(/\r?\n/),o=t&&nt.every(h=>n.includes(h)),a=rt(e.packageJsonData),r=!!(a.audit||a["security:audit"]||a["audit:security"]||a["npm:audit"]),l=Number(e.vulnerabilities??0),d=l>0;return {id:"surface-security-hygiene",label:"Security hygiene surface",status:o&&!d?"pass":d?"fail":"warn",severity:d?"error":"warn",scope:"project-scoped",reason:d?`${l} moderate/high/critical dependency vulnerability(ies) reported.`:o?"Repository ignore baseline covers env-file secrets and no dependency vulnerabilities were reported by Doctor.":t?"Repository ignore baseline exists, but env-file secret rules are incomplete.":"No .gitignore baseline detected for local secrets/build artifacts.",recommendation:d?"Run the runtime-native audit fix path without force, review lockfile changes, then rerun Doctor.":o?r?void 0:"Consider adding a security audit script for CI parity.":"Add .gitignore entries for env files, build output, dependency directories, and local reports.",repairCapability:d?De({issueId:"surface-security-hygiene",title:"Review dependency vulnerability fix",projectPath:e.projectPath,files:["package.json","package-lock.json","pnpm-lock.yaml","yarn.lock"],reason:"Dependency vulnerability remediation can change transitive dependency graphs and must be reviewed.",limitations:["Avoid npm audit fix --force unless a maintainer explicitly accepts breaking changes."]}):o?void 0:await Nn(e.projectPath)}}async function Hn(e){let t=Re(e.runtimeFamily),i=e.hasTests===true,n=i?void 0:await ot({issueId:"surface-test-contract",projectPath:e.projectPath,runtime:t,kind:"test",packageJsonData:e.packageJsonData,reason:"Create a deterministic runtime-native test command contract so Doctor, CI, and Studio can verify changes consistently."});return {id:"surface-test-contract",label:"Test contract",status:i?"pass":"warn",severity:"warn",scope:"project-scoped",reason:i?"Test surface detected through scripts, config, directories, or test files.":"No test surface detected by Doctor.",recommendation:i?void 0:"Add at least one deterministic test command or test baseline before release.",repairCapability:n??(i?void 0:De({issueId:"surface-test-contract",title:"Define test contract",projectPath:e.projectPath,files:["package.json","pyproject.toml","go.mod","pom.xml"],reason:"Doctor can identify missing test surfaces, but the correct test runner depends on product intent."}))}}function _n(e){let t=rt(e.packageJsonData),i=!!(t.format||t["format:check"]||t.prettier);return {id:"surface-format-contract",label:"Format contract",status:i?"pass":"warn",severity:"warn",scope:"project-scoped",reason:i?"Format script detected in package.json.":"No explicit format script detected by Doctor.",recommendation:i?void 0:"Add a formatter command or document the formatting tool used by CI."}}async function Bn(e){let t=Re(e.runtimeFamily),n={node:["vitest.config.ts","jest.config.js","playwright.config.ts","cypress.config.ts"],deno:["deno.json","deno.jsonc"],bun:["bunfig.toml"],python:["pytest.ini","tox.ini","noxfile.py","tests","pyproject.toml"],go:["*_test.go"],java:["src/test","pom.xml","build.gradle","build.gradle.kts"],rust:["tests","Cargo.toml"],elixir:["test","mix.exs"],clojure:["test","deps.edn","project.clj"],php:["phpunit.xml","phpunit.xml.dist","tests"],ruby:["spec","test",".rspec"],dotnet:["*.Tests.csproj","*.Test.csproj","*.sln"],unknown:[]}[t]??[];if(n.length===0)return null;let o=await Oe(e.projectPath,n),a=e.hasTests===true&&o;return {id:"runtime-test-depth",label:"Runtime-native test depth",status:a?"pass":("warn"),severity:"warn",scope:"project-scoped",reason:a?"Runtime-native test markers detected.":e.hasTests?"Generic test surface detected, but runtime-native test markers are incomplete.":"No runtime-native test markers detected.",recommendation:a?void 0:"Add runtime-native tests/config so Doctor, CI, and Studio can verify changes deterministically."}}async function qn(e){let t=Re(e.runtimeFamily),n={node:["eslint.config.js","eslint.config.mjs",".eslintrc.json","prettier.config.js"],deno:["deno.json","deno.jsonc"],bun:["eslint.config.js","biome.json","bunfig.toml"],python:["ruff.toml","pyproject.toml",".flake8","mypy.ini","Makefile"],go:[".golangci.yml",".golangci.yaml","Makefile"],java:["checkstyle.xml","pom.xml","build.gradle","build.gradle.kts"],rust:["rustfmt.toml","clippy.toml","Cargo.toml"],elixir:[".formatter.exs","credo.exs","mix.exs"],clojure:["cljfmt.edn",".clj-kondo","deps.edn"],php:["phpcs.xml","phpstan.neon","pint.json","composer.json"],ruby:[".rubocop.yml","Gemfile"],dotnet:[".editorconfig","Directory.Build.props","global.json"],unknown:[]}[t]??[];if(n.length===0)return null;let o=await it(e.projectPath,n),a=/eslint|prettier|biome|ruff|black|mypy|golangci|checkstyle|spotless|pmd|clippy|rustfmt|credo|clj-kondo|phpstan|phpcs|pint|rubocop|editorconfig|dotnet format/i.test(o),r=a?void 0:await ot({issueId:"runtime-quality-tooling",projectPath:e.projectPath,runtime:t,kind:"quality",packageJsonData:e.packageJsonData,reason:"Create a deterministic runtime-native quality command contract so CI and Studio can verify formatting/static-analysis consistently."});return {id:"runtime-quality-tooling",label:"Runtime-native quality tooling",status:a?"pass":"warn",severity:"warn",scope:"project-scoped",reason:a?"Runtime-native lint/format/static-analysis markers detected.":"No runtime-native lint/format/static-analysis markers detected.",recommendation:a?void 0:"Add runtime-native lint/format/static-analysis tooling and expose it to CI.",repairCapability:r}}async function Kn(e){let t=Re(e.runtimeFamily),n={node:["package.json"],deno:["deno.json","deno.jsonc"],bun:["package.json","bunfig.toml"],python:["pyproject.toml","requirements.txt","Makefile"],go:["Makefile","go.mod"],java:["pom.xml","build.gradle","build.gradle.kts"],rust:["Cargo.toml"],elixir:["mix.exs"],clojure:["deps.edn","project.clj"],php:["composer.json"],ruby:["Gemfile",".bundler-audit.yml"],dotnet:["Directory.Build.props","*.csproj"],unknown:[]}[t]??[];if(n.length===0)return null;let o=await it(e.projectPath,n),a=/npm audit|pnpm audit|yarn audit|bun audit|pip[-_]audit|safety|bandit|govulncheck|gosec|dependency-check|owasp|cargo audit|mix hex.audit|composer audit|bundler-audit|brakeman|NuGetAudit|dotnet list package --vulnerable/i.test(o),r=a?void 0:await ot({issueId:"runtime-security-tooling",projectPath:e.projectPath,runtime:t,kind:"security",packageJsonData:e.packageJsonData,reason:"Create a deterministic runtime-native security audit command contract so CI and Studio can verify dependency risk consistently."});return {id:"runtime-security-tooling",label:"Runtime-native security tooling",status:a?"pass":"warn",severity:"warn",scope:"project-scoped",reason:a?"Runtime-native security audit tooling marker detected.":"No runtime-native security audit tooling marker detected.",recommendation:a?void 0:"Expose a runtime-native dependency/security audit command for CI and Studio verification.",repairCapability:a?void 0:r||De({issueId:"runtime-security-tooling",title:"Define runtime security audit command",projectPath:e.projectPath,files:["package.json","pyproject.toml","Makefile","pom.xml","Cargo.toml"],reason:"Security tooling differs by runtime and organization policy; Doctor records the missing contract for review."})}}async function Gt(e){let t=Re(e.runtimeFamily),i=[],n=await In({projectPath:e.projectPath,runtime:t,packageJsonData:e.packageJsonData});n&&i.push(n),i.push(await An(e)),i.push(await On(e)),i.push(await Mn(e)),i.push(await Tn(e)),i.push(await Hn(e)),t==="node"&&i.push(_n(e));let o=await Promise.all([Bn(e),qn(e),Kn(e)]);for(let a of o)a&&i.push(a);return i}function Wn(e){return [...new Set(e.filter(t=>t&&t.trim().length>0))]}function Wt(e){return [...new Set(e.filter(t=>t&&t.trim().length>0))]}function Vn(){let e=q$1().map(n=>s.join(n,b$4()?"poetry.exe":"poetry")),t=b$4()?[s.join(process.env.APPDATA||"","Python","Scripts","poetry.exe"),s.join(process.env.USERPROFILE||"","AppData","Roaming","Python","Scripts","poetry.exe")]:[],i=b$4()?[]:["/usr/local/bin/poetry","/usr/bin/poetry"];return Wn([...e,...t,...i])}function Jn(e){let t=q$1().map(d=>({location:"Global (user-local)",path:s.join(d,b$4()?"rapidkit.exe":"rapidkit")})),i=[{location:"Global (pipx)",path:s.join(e,".local","bin","rapidkit")},{location:"Global (pipx)",path:s.join(e,"AppData","Roaming","Python","Scripts","rapidkit.exe")},{location:"Global (pyenv)",path:s.join(e,".pyenv","shims","rapidkit")},{location:"Global (system)",path:"/usr/local/bin/rapidkit"},{location:"Global (system)",path:"/usr/bin/rapidkit"}],n=m(s.join(process.cwd(),".venv")),o$1=o(process.cwd()),a=[{location:"Workspace (.venv)",path:n},...o$1.map(d=>({location:"Workspace (launcher)",path:d}))],r=[...t,...i,...a],l=new Set;return r.filter(d=>l.has(d.path)?false:(l.add(d.path),true))}function Ln(e){let t=new Map([["Workspace (.venv)",0],["Global (user-local)",1],["Global (pipx)",2],["Global (pyenv)",3],["Global (system)",4]]);return [...e].sort((i,n)=>{let o=t.get(i.location)??Number.MAX_SAFE_INTEGER,a=t.get(n.location)??Number.MAX_SAFE_INTEGER;return o!==a?o-a:i.path.localeCompare(n.path)})}function fe(e){let t=0,i=e.issues.some(n=>n.toLowerCase().includes("environment file missing"));return e.hasEnvFile===false&&!i&&(t+=1),typeof e.vulnerabilities=="number"&&e.vulnerabilities>0&&(t+=1),t}function ct(e){return e.filter(t=>fe(t)>0).length}function ut(e){return e.reduce((t,i)=>t+fe(i),0)}function Un(e){let t=e.coreVersion?.split(".")[0],i=e.npmVersion?.split(".")[0];return !t||!i?false:t!==i}var zn="doctor-project-scan-v2",nn="doctor-workspace-cache-v2",Yn=Object.freeze({version:"doctor-evidence-v1",scoringPolicyVersion:"doctor-score-policy-v1",generatedBy:"rapidkit-npm",deterministicScoreBreakdown:true,scopeModel:"workspace-aggregate-or-project-scoped"}),Ee=Object.freeze({local:{name:"local",exitOnErrors:true,exitOnWarnings:false,warningExitCode:0,advisoryWarningsBlockRelease:false,description:"Local diagnostics: report warnings without blocking the developer loop."},ci:{name:"ci",exitOnErrors:true,exitOnWarnings:true,warningExitCode:2,advisoryWarningsBlockRelease:false,description:"CI diagnostics: errors fail, warnings return a distinct warning exit code."},release:{name:"release",exitOnErrors:true,exitOnWarnings:true,warningExitCode:1,advisoryWarningsBlockRelease:true,description:"Release gate: any warning/error blocks release readiness."},"enterprise-strict":{name:"enterprise-strict",exitOnErrors:true,exitOnWarnings:true,warningExitCode:1,advisoryWarningsBlockRelease:true,description:"Enterprise strict gate: all warnings/errors block release and must carry evidence or repair guidance."}});function we(){return {...Yn}}function _e(e){let t=e.profile?.trim();return t&&t in Ee?{...Ee[t]}:e.strict?{...Ee.release}:e.ci?{...Ee.ci}:{...Ee.local}}function He(e){return !e||e.total<=0?null:Math.round(e.passed/e.total*100)}function Qn(e){return e.id==="surface-security-hygiene"&&/vulnerabilit/i.test(`${e.reason} ${e.recommendation??""}`)?{category:"state",ttlSeconds:300,reason:"Dependency vulnerability evidence is live state and must be refreshed before release use."}:e.id.includes("script")||e.id.includes("test")||e.id.includes("quality")||e.id.includes("format")||e.id.includes("runtime")||e.id.includes("lockfile")?{category:"verification",ttlSeconds:1440*60,reason:"Verification/tooling evidence can drift with dependency and config changes; refresh daily or before release."}:e.id.includes("dependency")||e.id.includes("env")||e.id.includes("container")||e.id.includes("docker")||e.id.includes("deploy")||e.id.includes("kubernetes")||e.id.includes("source-tree")||e.id.includes("framework")||e.id.includes("typescript")?{category:"structure",ttlSeconds:10080*60,reason:"Structural workspace/project evidence is durable but should be refreshed when files or manifests change."}:{category:"verification",ttlSeconds:1440*60,reason:"Default Doctor evidence freshness contract for project-scoped verification."}}function Xn(e,t){let i=Qn(e),n=Date.parse(t),o=typeof i.ttlSeconds=="number"?i.ttlSeconds*1e3:null,a=o!==null&&Number.isFinite(n)?new Date(n+o).toISOString():void 0,r=!Number.isFinite(n)||o!==null&&!a?"unknown":o!==null&&Date.now()>n+o?"stale":"fresh";return {category:i.category,generatedAt:t,ttlSeconds:i.ttlSeconds,...a?{expiresAt:a}:{},status:r,verifyBeforeUse:i.category!=="structure"||r!=="fresh",reason:i.reason}}function Zn(e){let t=e.id.toLowerCase(),i=`${e.label} ${e.reason} ${e.recommendation??""}`.toLowerCase();return t.includes("dependency")||t.includes("lockfile")||i.includes("lockfile")?"dependency":t.includes("security")||i.includes("vulnerabilit")||i.includes("audit")?"security":t.includes("env")||i.includes(".env")||i.includes("environment")?"environment":t.includes("test")?"test":t.includes("quality")||t.includes("format")||t.includes("lint")?"quality":t.includes("docker")||t.includes("container")?"container":t.includes("deploy")||t.includes("kubernetes")?"deployment":t.includes("runtime")?"runtime":t.includes("contract")?"workspace-contract":t.includes("source-tree")?"source-tree":t.includes("framework")||t.includes("typescript")?"framework":t.includes("custom")?"custom":t.includes("script")||t.includes("config")?"configuration":"unknown"}function ei(e,t){return e.status==="pass"?"none":t==="security"?"security-risk":t==="deployment"||t==="runtime"?"runtime-risk":t==="dependency"||t==="test"||t==="quality"||t==="workspace-contract"?e.severity==="error"||e.status==="fail"?"release-risk":"ci-risk":t==="container"||t==="environment"?"release-risk":"developer-friction"}function ti(e){let{probe:t,freshness:i}=e,n=t.repairCapability;if(t.status==="pass")return {mode:"none",confidence:"high",primaryActionLabel:"No action required",requiresApproval:false,requiresFreshEvidence:false,reason:"Probe is passing.",relatedCommands:[]};if(i.status!=="fresh")return {mode:"refresh-evidence",confidence:"high",primaryActionLabel:"Refresh evidence",requiresApproval:false,requiresFreshEvidence:true,reason:`Evidence is ${i.status}; refresh Doctor before applying repairs.`,relatedCommands:["npx rapidkit doctor project --json"]};if(i.verifyBeforeUse&&i.category==="state")return {mode:"verify-before-fix",confidence:"high",primaryActionLabel:"Verify live state",requiresApproval:false,requiresFreshEvidence:true,reason:"Live state evidence must be re-read before Studio claims a fix path.",relatedCommands:["npx rapidkit doctor project --json"]};if(n?.status==="available"&&n.canAutoFix){let o=n.canEditFiles;return {mode:o?"edit-file":"run-command",confidence:"high",primaryActionLabel:o?"Apply file fix":"Run fix command",requiresApproval:n.requiresApproval,requiresFreshEvidence:i.verifyBeforeUse,reason:n.reason,relatedCommands:Wt([...n.command?[n.command]:[],...n.verifyCommand?[n.verifyCommand]:[],...n.refreshCommands])}}return n?.status==="manual"||n?.requiresReview?{mode:"review-required",confidence:"medium",primaryActionLabel:"Review fix path",requiresApproval:true,requiresFreshEvidence:i.verifyBeforeUse,reason:n?.reason??t.recommendation??t.reason,relatedCommands:Wt(n?.refreshCommands??["npx rapidkit doctor project --json"])}:t.recommendation?{mode:"manual-guidance",confidence:"medium",primaryActionLabel:"Inspect guidance",requiresApproval:false,requiresFreshEvidence:i.verifyBeforeUse,reason:t.recommendation,relatedCommands:["npx rapidkit doctor project --json"]}:{mode:"manual-guidance",confidence:"low",primaryActionLabel:"Inspect issue",requiresApproval:false,requiresFreshEvidence:i.verifyBeforeUse,reason:"Doctor classified the issue but does not have a deterministic repair path yet.",relatedCommands:["npx rapidkit doctor project --json"]}}function rn(e,t){let i=Xn(e,e.freshness?.generatedAt??t),n=e.issueClass??Zn(e),o=e.operationalImpact??ei(e,n),a=e.repairIntent??ti({probe:e,freshness:i});return {...e,freshness:i,issueClass:n,operationalImpact:o,repairIntent:a}}function Vt(e,t){Array.isArray(e.probes)&&(e.probes=e.probes.map(i=>rn(i,t)));}function on(e,t){let i=e.flatMap(d=>Array.isArray(d.probes)?d.probes.map(u=>u.freshness).filter(u=>!!u):[]),n=i.filter(d=>d.status==="stale").length,o=i.filter(d=>d.status==="unknown").length,a=i.filter(d=>d.category==="state").length,r=i.filter(d=>d.verifyBeforeUse).length,l=i.map(d=>d.generatedAt).filter(Boolean).sort()[0];return {generatedAt:t,status:n>0?"stale":o>0?"unknown":"fresh",staleProbeCount:n,unknownProbeCount:o,liveStateProbeCount:a,verifyBeforeUseProbeCount:r,...l?{oldestProbeGeneratedAt:l}:{}}}function an(e){return typeof e=="number"?e:Array.isArray(e)?e.length:0}async function sn(e,t){try{if(!await c$1.pathExists(e))return null;let i=await c$1.readJSON(e);return c$3(i,t)?i:null}catch{return null}}function cn(e,t){if(!e?.system)return [];let i=[{id:"python",current:t.python},{id:"poetry",current:t.poetry},{id:"pipx",current:t.pipx},{id:"go",current:t.go},{id:"rapidkitCore",current:t.rapidkitCore}],n=[];for(let o of i){let a=e.system?.[o.id]?.status;!a||a===o.current.status||n.push({id:o.id,from:a,to:o.current.status});}return n}function ni(e,t){let i=new Map;for(let w of t.projects)i.set(w.path||w.name,w.issues.length);if(!e)return {baselineAvailable:false,newIssueCount:0,resolvedIssueCount:0,netIssueDelta:0,scoreDeltaPercent:null,systemStatusChanges:[],regressedProjects:[],improvedProjects:[]};let n=Array.isArray(e.projects)?e.projects:[],o=new Map;for(let w of n){let g=w.path||w.name;g&&o.set(g,an(w.issues));}let a=0,r=0,l=new Set,d=new Set,u=new Set([...Array.from(o.keys()),...Array.from(i.keys())]);for(let w of u){let g=o.get(w)??0,f=i.get(w)??0;f>g?(a+=f-g,l.add(w)):f<g&&(r+=g-f,d.add(w));}let h=He(e.healthScore),y=He(t.healthScore);return {baselineAvailable:true,previousGeneratedAt:e.generatedAt,newIssueCount:a,resolvedIssueCount:r,netIssueDelta:a-r,scoreDeltaPercent:h===null||y===null?null:y-h,systemStatusChanges:cn(e,{python:t.python,poetry:t.poetry,pipx:t.pipx,go:t.go,rapidkitCore:t.rapidkitCore}),regressedProjects:Array.from(l).sort(),improvedProjects:Array.from(d).sort()}}function ii(e,t){if(!e)return {baselineAvailable:false,newIssueCount:0,resolvedIssueCount:0,netIssueDelta:0,scoreDeltaPercent:null,systemStatusChanges:[],regressedProjects:[],improvedProjects:[]};let i=an(e.project?.issues),n=t.project.issues.length,o=Math.max(n-i,0),a=Math.max(i-n,0),r=He(e.healthScore),l=He(t.healthScore),d=t.project.path||t.project.name;return {baselineAvailable:true,previousGeneratedAt:e.generatedAt,newIssueCount:o,resolvedIssueCount:a,netIssueDelta:o-a,scoreDeltaPercent:r===null||l===null?null:l-r,systemStatusChanges:cn(e,{python:t.python,poetry:t.poetry,pipx:t.pipx,go:t.go,rapidkitCore:t.rapidkitCore}),regressedProjects:o>0?[d]:[],improvedProjects:a>0?[d]:[]}}function ln(e){let t=e??[],i=0,n=0;for(let r of t){if(r.scope==="project-scoped"){i+=1;continue}(r.scope==="workspace-aggregate"||r.scope==="host-system")&&(n+=1);}let o=i>0&&n>0?1:0,a=o>0?"mixed":i>0?"scoped":n>0?"aggregated":"unknown";return {scopedCount:i,aggregatedCount:n,mixedCount:o,dominantScope:a}}function V(e,t){return b$4()?`cd "${e}"; ${t}`:`cd ${e} && ${t}`}function ae(e){return b$4()?V(e,"Copy-Item .env.example .env"):V(e,"cp .env.example .env")}function Jt(e){return V(e,"poetry install --no-root")}function ri(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 oi(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 ai(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 lt(e,t){let i=q(t);e.commandCapabilities=i,e.supportTier=i.frameworkSupportTier;}function Te(e,t,i,n){e.framework=t,e.frameworkConfidence=i,e.supportTier=ri(t),e.projectKind=oi(t),e.runtimeFamily=ai(t);}function dn(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 mt(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 si(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 ci(e,t){e.framework=mt(t),e.frameworkKey=t.key,e.importStack=t.importStack,e.frameworkConfidence=t.confidence,e.supportTier=t.supportTier,e.projectKind="frontend",e.runtimeFamily=dn(t.runtime);}function Z(e,t){e.framework=mt(t),e.frameworkKey=t.key,e.importStack=t.importStack,e.frameworkConfidence=t.confidence,e.supportTier=t.supportTier,e.projectKind=si(t)?"generic":"backend",e.runtimeFamily=dn(t.runtime);}function li(e){let t=e.dependencies,i=e.scripts??{},n=(e.kitName??"").toLowerCase(),o=r=>!!t[r],a=Object.values(i).filter(r=>typeof r=="string").join(" ").toLowerCase();return o("next")||a.includes("next ")?{framework:"Next.js",confidence:"high"}:o("nuxt")||a.includes("nuxt ")?{framework:"Nuxt",confidence:"high"}:o("@nestjs/core")||n.startsWith("nestjs.")?{framework:"NestJS",confidence:"high"}:o("express")?{framework:"Express",confidence:"high"}:o("fastify")?{framework:"Fastify",confidence:"high"}:o("koa")?{framework:"Koa",confidence:"high"}:o("@angular/core")?{framework:"Angular",confidence:"high"}:o("@sveltejs/kit")||a.includes("svelte-kit")?{framework:"SvelteKit",confidence:"high"}:o("vue")?{framework:"Vue",confidence:"medium"}:o("react")&&o("react-dom")?{framework:"React",confidence:"medium"}:{framework:"Node.js",confidence:"low"}}async function di(e,t){let i$1=i(e,t??null);return i$1.runtime!=="python"?{framework:"Python",confidence:"low"}:{framework:mt(i$1),confidence:i$1.confidence}}async function Lt(e){try{let t=await c$1.stat(e);return `${s.basename(e)}:${t.isDirectory()?"d":"f"}:${t.size}:${t.mtimeMs}`}catch{return `${s.basename(e)}:missing`}}async function pi(e){try{let t=new Set([".git",".venv","node_modules",".rapidkit","dist","build","coverage","__pycache__"]),i=new Set,n=async r=>{if(await Se(r))return true;let l=["package.json","pyproject.toml","requirements.txt","go.mod","pom.xml","build.gradle","build.gradle.kts","*.csproj","Cargo.toml","composer.json","Gemfile","mix.exs","deps.edn","deno.json","deno.jsonc"];for(let d of l){if(d==="*.csproj"){if((await c$1.readdir(r).catch(()=>[])).some(h=>h.endsWith(".csproj")))return true;continue}if(await c$1.pathExists(s.join(r,d)))return true}return false};await Se(e)&&i.add(e);let o=await a(e);for(let r of o){let l=s.isAbsolute(r.path)?r.path:s.join(e,r.path);await n(l)&&i.add(l);}return (await a$1(e,{skipDirs:t,descendIntoMatchedProjects:false,isProjectDir:async(r,l)=>s.resolve(r)===s.resolve(l)?Se(r):n(r)})).forEach(r=>i.add(r)),i.size===0&&(await Ri(e,3,t)).forEach(l=>i.add(l)),i.size===0&&!await b$2(e)&&await n(e)&&i.add(e),Array.from(i).sort((r,l)=>r.localeCompare(l))}catch{return []}}async function ui(e,t){let i=[s.join(e,".rapidkit-workspace"),s.join(e,".rapidkit","workspace.json"),s.join(e,".rapidkit","imported-projects.json"),s.join(e,".rapidkit","policies.yml"),s.join(e,".rapidkit","toolchain.lock"),s.join(e,".rapidkit","cache-config.yml")],n=[".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"],o=await Promise.all(i.map(Lt)),a=await Promise.all(t.map(async r=>{let l=await Promise.all(n.map(d=>Lt(s.join(r,d))));return `${r}::${l.join("|")}`}));return [zn,...o,...a].join("||")}async function mi(e,t){try{if(!await c$1.pathExists(e))return null;let i=await c$1.readJSON(e);return !i||i.signature!==t||!Array.isArray(i.projects)||typeof i.schemaVersion=="string"&&i.schemaVersion!==nn?null:i}catch{return null}}async function fi(e,t){try{await c$1.ensureDir(s.dirname(e)),await c$1.writeJSON(e,t,{spaces:2});}catch{}}async function gi(e$1,t,i){let n=s.join(e$1,".rapidkit","reports","doctor-last-run.json");try{await c$1.ensureDir(s.dirname(n));let o=[];for(let a of t.projects)for(let r of a.issues??[])typeof r=="string"&&r.trim()&&o.push(`${a.name}: ${r.trim()}`);for(let[a,r]of [["python",t.python],["rapidkitCore",t.rapidkitCore]])if(r?.status==="error"){let l=typeof r.message=="string"?r.message:`${a} check failed`;o.push(`${a}: ${l}`);}return await c$1.writeJSON(n,f$1({schemaVersion:a$2,evidenceType:"workspace",contract:we(),policyProfile:t.policyProfile,workspacePath:e$1,workspaceName:t.workspaceName,projectScanCached:t.projectScanCached??false,projectScanSignature:t.projectScanSignature,cachePath:i,healthScore:t.healthScore,evidenceFreshness:t.evidenceFreshness,system:{python:t.python,poetry:t.poetry,pipx:t.pipx,go:t.go,rapidkitCore:t.rapidkitCore,versions:{core:t.coreVersion,npm:t.npmVersion}},projects:t.projects,summary:{totalProjects:t.projects.length,totalIssues:t.projects.reduce((a,r)=>a+r.issues.length,0),projectAdvisoryWarningProjects:ct(t.projects),projectAdvisoryWarnings:ut(t.projects),hasSystemErrors:[t.python,t.rapidkitCore].some(a=>a.status==="error"),scopeProvenance:t.scopeProvenance},driftDelta:t.driftDelta,scoreBreakdown:t.scoreBreakdown??[]},{commandId:"checkWorkspaceHealth",exitCode:je(t.healthScore,{profile:t.policyProfile?.name}),generatedAt:new Date().toISOString(),blockers:o.slice(0,12),runId:e()}),{spaces:2}),n}catch{return}}async function ft(){let[e,t,i,n,o]=await Promise.all([yi(),hi(),ki(),wi(),vi()]);return {python:e,poetry:t,pipx:i,go:n,rapidkitCore:o}}async function yi(){let e=i$1();for(let t of e)try{let{stdout:i}=await execa(t,["--version"],{timeout:3e3}),n=i.match(/Python (\d+\.\d+\.\d+)/);if(n){let o=n[1],[a,r]=o.split(".").map(Number);return a<3||a===3&&r<10?{status:"warn",message:`Python ${o} (requires 3.10+)`,details:`${t} found but version is below minimum requirement`}:{status:"ok",message:`Python ${o}`,details:`Using ${t}`}}}catch{continue}return {status:"error",message:"Python not found",details:"Install Python 3.10+ and ensure it's in PATH"}}async function hi(){try{let{stdout:e}=await execa("poetry",["--version"],{timeout:3e3}),t=e.match(/Poetry .*version ([\d.]+)/);return t?{status:"ok",message:`Poetry ${t[1]}`,details:"Available for dependency management"}:{status:"warn",message:"Poetry version unknown"}}catch{let e=i$1().map(t=>({cmd:t,args:t==="py"?["-3","-m","poetry","--version"]:["-m","poetry","--version"]}));for(let t of e)try{let{stdout:i}=await execa(t.cmd,t.args,{timeout:3e3,shell:c$2()}),n=i.match(/Poetry .*version ([\d.]+)/)||i.match(/([\d.]+)/);return {status:"ok",message:n?.[1]?`Poetry ${n[1]}`:"Poetry detected",details:`Available via ${t.cmd} ${t.args.join(" ")}`}}catch{continue}for(let t of Vn())try{if(!await c$1.pathExists(t))continue;let{stdout:i}=await execa(t,["--version"],{timeout:3e3,shell:c$2()}),n=i.match(/Poetry .*version ([\d.]+)/)||i.match(/([\d.]+)/);return {status:"ok",message:n?.[1]?`Poetry ${n[1]}`:"Poetry detected",details:`Available at ${t}`}}catch{continue}return {status:"warn",message:"Poetry not installed",details:"Optional: Install for better dependency management"}}}async function ki(){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=i$1();for(let t of e)try{let i=t==="py"?["-3","-m","pipx","--version"]:["-m","pipx","--version"],{stdout:n}=await execa(t,i,{timeout:3e3,shell:c$2()});return {status:"ok",message:`pipx ${n.trim()}`,details:`Available via ${t} ${i.join(" ")}`}}catch{continue}return {status:"warn",message:"pipx not installed",details:"Optional: Install for isolated Python tools"}}}async function wi(){try{let{stdout:e}=await execa("go",["version"],{timeout:3e3}),t=e.match(/go version go(\d+\.\d+(?:\.\d+)?)/);return t?{status:"ok",message:`Go ${t[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 vi(){let e=process.env.HOME||process.env.USERPROFILE||"",t=[],i=Jn(e);for(let{location:o,path:a}of i)try{if(await c$1.pathExists(a)){let{stdout:r,exitCode:l}=await execa(a,["--version"],{timeout:3e3,reject:false});if(l===0&&(r.includes("RapidKit Version")||r.includes("RapidKit"))){let d=r.match(/v?([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);d&&t.push({location:o,path:a,version:d[1]});}}}catch{continue}if(t.length>0){let o=t.filter(r=>r.location!=="Workspace (launcher)");if(o.length>0){let r=Ln(o),l=r[0].version,d=r.some(y=>y.location==="Workspace (.venv)"),u=r.some(y=>y.location.startsWith("Global (")),h=!d&&u?"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 ${l}`,details:h,paths:r.map(y=>({location:y.location,path:y.path,version:y.version}))}}return {status:"ok",message:`RapidKit Core ${t[0].version}`,details:"Detected via workspace launcher"}}try{let{stdout:o,exitCode:a}=await execa("rapidkit",["--version"],{timeout:3e3,reject:false});if(a===0&&(o.includes("RapidKit Version")||o.includes("RapidKit"))){let r=o.match(/v?([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);if(r)return {status:"ok",message:`RapidKit Core ${r[1]}`,details:"Available via PATH"}}}catch{}try{let{stdout:o,exitCode:a}=await execa("poetry",["run","rapidkit","--version"],{timeout:3e3,reject:false});if(a===0&&(o.includes("RapidKit Version")||o.includes("RapidKit"))){let r=o.match(/v?([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);if(r)return {status:"ok",message:`RapidKit Core ${r[1]}`,details:"Available via Poetry"}}}catch{}let n=i$1();for(let o of n)try{let{stdout:a,exitCode:r}=await execa(o,["-c","import rapidkit_core; print(rapidkit_core.__version__)"],{timeout:3e3,reject:false});if(r===0&&a&&!a.includes("Traceback")&&!a.includes("ModuleNotFoundError")){let l=a.trim();if(l)return {status:"ok",message:`RapidKit Core ${l}`,details:`Available in ${o} environment`}}}catch{continue}return {status:"error",message:"RapidKit Core not installed",details:"Install with: pipx install rapidkit-core"}}async function U(e,t,i){let n=s.join(e,"Dockerfile");t.hasDocker=await c$1.pathExists(n);let o=s.join(e,"tests"),a=s.join(e,"test"),r=s.join(e,"src","test"),l$1=await c$1.pathExists(o)||await c$1.pathExists(a)||await c$1.pathExists(r),d=false;if(t.framework==="Go/Fiber"||t.framework==="Go/Gin")try{let u=[{dir:e,depth:0}],h=4,y=new Set([".git",".venv","node_modules","dist","build","vendor"]);for(;u.length>0&&!d;){let w=u.shift();if(!w)break;let g=[];try{g=await c$1.readdir(w.dir);}catch{continue}for(let f of g){let v=s.join(w.dir,f),x;try{x=await c$1.stat(v);}catch{continue}if(x.isFile()&&f.endsWith("_test.go")){d=true;break}x.isDirectory()&&w.depth<h&&!y.has(f)&&!f.startsWith(".")&&u.push({dir:v,depth:w.depth+1});}}}catch{}if(t.hasTests=l$1||d,t.runtimeFamily==="node"&&!t.hasTests&&(t.hasTests=await qt(e,i)),t.runtimeFamily==="node")t.hasCodeQuality=await Bt(e,i);else if(t.framework==="Go/Fiber"||t.framework==="Go/Gin"){let u=s.join(e,".golangci.yml"),h=s.join(e,".golangci.yaml"),y=s.join(e,"Makefile"),w=await c$1.pathExists(y)&&(await c$1.readFile(y,"utf8")).includes("golangci-lint");t.hasCodeQuality=await c$1.pathExists(u)||await c$1.pathExists(h)||w;}else if(t.runtimeFamily==="python"){let u=s.join(e,"ruff.toml"),h=s.join(e,"pyproject.toml");if(await c$1.pathExists(h))try{let y=await c$1.readFile(h,"utf8");t.hasCodeQuality=y.includes("[tool.ruff]")||await c$1.pathExists(u);}catch{t.hasCodeQuality=await c$1.pathExists(u);}}else if(t.framework==="Spring Boot"){let u=s.join(e,"pom.xml");if(await c$1.pathExists(u))try{let h=await c$1.readFile(u,"utf8");t.hasCodeQuality=h.includes("spotless")||h.includes("checkstyle")||h.includes("pmd")||h.includes("maven-enforcer-plugin");}catch{t.hasCodeQuality=false;}}try{if(t.runtimeFamily==="node"){let{stdout:u}=await execa("npm",["audit","--json"],{cwd:e,reject:false});if(u)try{let y=JSON.parse(u).metadata?.vulnerabilities;y&&(t.vulnerabilities=(y.high||0)+(y.critical||0)+(y.moderate||0));}catch{}}else if(t.runtimeFamily==="python"){let u=s.join(e,".venv"),h=l(u);if(await c$1.pathExists(h))try{let{stdout:y}=await execa(h,["-m","pip","list","--format=json"],{timeout:5e3,reject:false});if(y){JSON.parse(y);t.vulnerabilities=0;}}catch{}}}catch{}}function G(e,t){e.probes||(e.probes=[]);let i=rn(t,new Date().toISOString());e.probes.push(i),i.repairCapability&&(e.repairCapabilities||(e.repairCapabilities=[]),e.repairCapabilities.push(i.repairCapability),i.repairCapability.status==="available"&&i.repairCapability.canAutoFix&&i.repairCapability.command&&(e.fixCommands=e.fixCommands??[],e.fixCommands.includes(i.repairCapability.command)||e.fixCommands.push(i.repairCapability.command)));}async function bi(e,t){let i=t.runtimeFamily||"unknown";if(t.projectKind==="backend"||t.projectKind==="generic"){if(i==="node"){let o=await c$1.pathExists(s.join(e,"package-lock.json"))||await c$1.pathExists(s.join(e,"pnpm-lock.yaml"))||await c$1.pathExists(s.join(e,"yarn.lock"));G(t,{id:"adapter-node-lockfile-integrity",label:"Node adapter lockfile integrity",status:o?"pass":"warn",severity:"warn",scope:"project-scoped",reason:o?"Node lockfile detected for deterministic dependency restore.":"No Node lockfile detected (package-lock/yarn.lock/pnpm-lock.yaml).",recommendation:o?void 0:"Commit a lockfile for deterministic installs and CI parity."});let a=await c$1.pathExists(s.join(e,"src/main.ts"))||await c$1.pathExists(s.join(e,"src/main.js"))||await c$1.pathExists(s.join(e,"src/server.ts"))||await c$1.pathExists(s.join(e,"src/server.js"));G(t,{id:"adapter-node-boot-entrypoint",label:"Node adapter boot entrypoint",status:a?"pass":"warn",severity:"warn",scope:"project-scoped",reason:a?"Boot entrypoint markers detected for service startup path.":"No canonical Node boot entrypoint markers detected.",recommendation:a?void 0:"Define and document service bootstrap entrypoint (main/server)."});return}if(i==="python"){let o=await c$1.pathExists(s.join(e,"poetry.lock"))||await c$1.pathExists(s.join(e,"requirements.txt"))||await c$1.pathExists(s.join(e,"uv.lock"));G(t,{id:"adapter-python-lockfile-integrity",label:"Python adapter dependency integrity",status:o?"pass":"warn",severity:"warn",scope:"project-scoped",reason:o?"Python dependency contract file detected.":"No Python dependency contract file detected (poetry.lock/requirements/uv.lock).",recommendation:o?void 0:"Pin dependency contract for deterministic setup and reproducible CI."});let a=await c$1.pathExists(s.join(e,"app/main.py"))||await c$1.pathExists(s.join(e,"main.py"))||await c$1.pathExists(s.join(e,"manage.py"));G(t,{id:"adapter-python-boot-entrypoint",label:"Python adapter boot entrypoint",status:a?"pass":"warn",severity:"warn",scope:"project-scoped",reason:a?"Python application entrypoint markers detected.":"No Python application entrypoint markers detected.",recommendation:a?void 0:"Expose explicit app/main entrypoint for deterministic boot probes."});return}if(i==="java"){let o=await c$1.pathExists(s.join(e,"mvnw"))||await c$1.pathExists(s.join(e,"gradlew"));G(t,{id:"adapter-java-build-wrapper",label:"Java adapter build wrapper",status:o?"pass":"warn",severity:"warn",scope:"project-scoped",reason:o?"Build wrapper detected (mvnw/gradlew).":"No Java build wrapper detected.",recommendation:o?void 0:"Commit mvnw or gradlew for reproducible enterprise pipelines."});return}if(i==="go"){let o=await c$1.pathExists(s.join(e,"go.sum"));G(t,{id:"adapter-go-module-integrity",label:"Go adapter module integrity",status:o?"pass":"warn",severity:"warn",scope:"project-scoped",reason:o?"go.sum detected for deterministic module verification.":"go.sum missing; module integrity baseline is incomplete.",recommendation:o?void 0:"Generate and commit go.sum in the repository baseline."});}}}async function ji(e,t){let i=[s.join(e,".rapidkit","doctor.adapters.json"),s.join(e,"doctor.adapters.json")];for(let n of i)if(await c$1.pathExists(n))try{let o=await c$1.readJSON(n),a=Array.isArray(o?.checks)?o.checks:[];for(let r=0;r<a.length;r+=1){let l=a[r]||{},d=Array.isArray(l.runtimes)?l.runtimes:[];if(d.length>0&&!d.includes(t.runtimeFamily||"unknown"))continue;let u=typeof l.id=="string"&&l.id.trim().length>0?l.id.trim():`adapter-check-${r+1}`,h=typeof l.label=="string"&&l.label.trim().length>0?l.label.trim():u,y=l.severity||"warn",w=Array.isArray(l.anyOfPaths)?l.anyOfPaths.filter(Boolean):[],g=Array.isArray(l.allOfPaths)?l.allOfPaths.filter(Boolean):[],f=w.length===0;for(let k of w)if(await c$1.pathExists(s.join(e,k))){f=true;break}let v=true;for(let k of g)if(!await c$1.pathExists(s.join(e,k))){v=false;break}let x=f&&v;G(t,{id:u,label:h,status:x?"pass":y==="error"?"fail":"warn",severity:y,scope:"project-scoped",reason:x?l.passReason||"Custom adapter contract satisfied.":l.failReason||`Custom adapter check failed from ${s.basename(n)}.`,recommendation:l.recommendation});}}catch{G(t,{id:"custom-adapter-config",label:"Custom doctor adapter configuration",status:"warn",severity:"warn",scope:"project-scoped",reason:`Failed to parse ${s.basename(n)}.`,recommendation:"Fix JSON syntax in doctor.adapters.json to re-enable adapter checks."});}}async function z(e,t){if(!(t.projectKind==="backend"||t.projectKind==="generic"))return;let n=s.join(e,".env"),o=s.join(e,".env.example"),a=await c$1.pathExists(n)||await c$1.pathExists(o)||await c$1.pathExists(s.join(e,"config"));G(t,{id:"config-surface",label:"Configuration contract surface",status:a?"pass":"warn",severity:"warn",scope:"project-scoped",reason:a?"Configuration artifacts detected (.env/.env.example/config).":"No explicit configuration contract artifacts detected.",recommendation:a?void 0:"Add .env.example or explicit config contract documentation for deterministic setup."});let r={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"]},l=t.runtimeFamily||"unknown",d=r[l]||r.unknown,u=false;for(let w of d)if(await c$1.pathExists(s.join(e,w))){u=true;break}G(t,{id:"migration-surface",label:"Migration/readiness surface",status:u?"pass":"warn",severity:"warn",scope:"project-scoped",reason:u?"Migration or schema evolution markers detected.":"No migration markers detected for this backend runtime.",recommendation:u?void 0:"Add migration tooling baseline (migrations dir or runtime-native migration config)."});let h=["src/health","src/healthcheck","src/main/resources/application.yml","src/main/resources/application.properties","app/health.py","routes/health.ts","routes/health.js"],y=false;for(let w of h)if(await c$1.pathExists(s.join(e,w))){y=true;break}G(t,{id:"runtime-health-surface",label:"Runtime health probe surface",status:y?"pass":"warn",severity:"warn",scope:"project-scoped",reason:y?"Health endpoint/config markers detected.":"No explicit runtime health endpoint markers detected.",recommendation:y?void 0:"Expose a deterministic health endpoint and keep it covered in verify pack."}),await bi(e,t);}async function xi(e,t,i,n){let o=await Kt({projectPath:e,detection:n,packageJsonData:i});for(let a of o)G(t,a);}async function Y(e,t,i){let n=await Gt({projectPath:e,runtimeFamily:t.runtimeFamily,projectKind:t.projectKind,packageJsonData:i,hasTests:t.hasTests,vulnerabilities:t.vulnerabilities});for(let o of n)G(t,o);}async function Q(e,t){let i=[s.join(e,".rapidkit","doctor.probes.json"),s.join(e,"doctor.probes.json")];for(let n of i)if(await c$1.pathExists(n))try{let o=await c$1.readJSON(n),a=Array.isArray(o?.probes)?o.probes:[];for(let r=0;r<a.length;r+=1){let l=a[r]||{},d=typeof l.id=="string"&&l.id.trim().length>0?l.id.trim():`custom-probe-${r+1}`,u=typeof l.label=="string"&&l.label.trim().length>0?l.label.trim():d,h=l.severity||"warn",y=Array.isArray(l.anyOfPaths)?l.anyOfPaths.filter(Boolean):[],w=Array.isArray(l.allOfPaths)?l.allOfPaths.filter(Boolean):[],g=y.length===0;for(let x of y)if(await c$1.pathExists(s.join(e,x))){g=true;break}let f=true;for(let x of w)if(!await c$1.pathExists(s.join(e,x))){f=false;break}let v=g&&f;G(t,{id:d,label:u,status:v?"pass":h==="error"?"fail":"warn",severity:h,scope:"project-scoped",reason:v?"Custom probe contract satisfied.":`Custom probe failed from ${s.basename(n)}.`,recommendation:l.recommendation});}}catch{G(t,{id:"custom-probe-config",label:"Custom doctor probe configuration",status:"warn",severity:"warn",scope:"project-scoped",reason:`Failed to parse ${s.basename(n)}.`,recommendation:"Fix JSON syntax in doctor.probes.json to re-enable custom probes."});}await ji(e,t);}async function Be(e,t={}){let n={name:s.basename(e),path:e,venvActive:false,depsInstalled:false,coreInstalled:false,issues:[],fixCommands:[]},o=t.allowNonRapidkit===true,a=s.join(e,".rapidkit");if(!await c$1.pathExists(a)){if(!o)return n.issues.push("Not a valid RapidKit project (missing .rapidkit directory)"),n;n.issues.push("Not a RapidKit-managed project (running generic backend diagnostics)");}try{let b=s.join(e,"registry.json");if(await c$1.pathExists(b)){let P=await c$1.readJson(b);P.installed_modules&&(n.stats={modules:P.installed_modules.length});}}catch{}try{let{auditProjectModulePaths:b}=await import('./module-layout-NZ43RSC5.js'),P=await b(e);if(P.issues.length>0){for(let S of P.issues)n.issues.push(`${S.message} (${S.slug})`);n.fixCommands=n.fixCommands??[],n.fixCommands.push("npx rapidkit workspace contract verify --strict --json"),n.fixCommands.push("npx rapidkit add module <slug> # reinstall via Core-backed module install");}}catch{}let r=null;try{let b=s.join(a,"project.json");if(await c$1.pathExists(b)){r=await c$1.readJson(b);let P=r?.kit_name||r?.kit;P&&(n.kit=P);}}catch{}try{let b=s.join(e,".git");if(await c$1.pathExists(b)){let{stdout:P}=await execa("git",["log","-1","--format=%cr"],{cwd:e,reject:false});P&&(n.lastModified=P.trim());}else {let P=await c$1.stat(e),H=Date.now()-P.mtime.getTime(),F=Math.floor(H/(1e3*60*60*24));n.lastModified=F===0?"today":`${F} day${F>1?"s":""} ago`;}}catch{}let l$1=s.join(e,"package.json"),d$1=s.join(e,"pyproject.toml"),u=s.join(e,"requirements.txt"),h=s.join(e,"go.mod"),y=s.join(e,"pom.xml"),w=s.join(e,"build.sbt"),g=s.join(e,"Cargo.toml"),f=s.join(e,"mix.exs"),v=s.join(e,"deps.edn"),x=s.join(e,"project.clj"),k=s.join(e,"deno.json"),R=s.join(e,"deno.jsonc"),I=s.join(e,"bun.lockb"),T=s.join(e,"bun.lock"),m=s.join(e,"composer.json"),D=s.join(e,"Gemfile"),C=await c$1.pathExists(l$1),ee=await c$1.pathExists(d$1)||await c$1.pathExists(u),j=await c$1.pathExists(m),te=await c$1.pathExists(D),O=await c$1.pathExists(g),re=await c$1.pathExists(f),Fe=await c$1.pathExists(v)||await c$1.pathExists(x),Ne=await c$1.pathExists(w),Ie=await c$1.pathExists(k)||await c$1.pathExists(R),W=r?.runtime==="dotnet";try{W=W||await Ut(e,".csproj",3)||await Ut(e,".sln",2);}catch{W=r?.runtime==="dotnet";}let Pe=await c$1.pathExists(h)||r?.runtime==="go"||typeof r?.kit_name=="string"&&(r.kit_name.startsWith("gofiber")||r.kit_name.startsWith("gogin")),le=C&&(await c$1.pathExists(I)||await c$1.pathExists(T)||typeof r?.packageManager=="string"&&(r?.packageManager).toLowerCase().startsWith("bun@"));if(Pe){Z(n,i(e,r??null)),n.isGoProject=true,n.venvActive=true,n.coreInstalled=false;try{await execa("go",["version"],{timeout:3e3});}catch{n.issues.push("Go toolchain not found \u2014 install from https://go.dev/dl/"),n.fixCommands?.push("https://go.dev/dl/");}let b=s.join(e,"go.sum");return await c$1.pathExists(b)?n.depsInstalled=true:(n.depsInstalled=false,n.issues.push("Go dependencies not downloaded (go.sum missing)"),n.fixCommands?.push(V(e,"go mod tidy"))),await U(e,n),await Y(e,n),await z(e,n),await Q(e,n),n}if(await c$1.pathExists(y)||r?.runtime==="java"||typeof r?.kit_name=="string"&&r.kit_name.startsWith("springboot")){Z(n,i(e,r??null)),n.venvActive=true,n.coreInstalled=false;let b=await c$1.pathExists(y),P=await c$1.pathExists(s.join(e,"build.gradle"))||await c$1.pathExists(s.join(e,"build.gradle.kts")),S=await c$1.pathExists(s.join(e,"mvnw"))||await c$1.pathExists(s.join(e,"mvnw.cmd")),H=await c$1.pathExists(s.join(e,"gradlew"))||await c$1.pathExists(s.join(e,"gradlew.bat"));try{await execa("java",["-version"],{timeout:3e3,reject:false});}catch{n.issues.push("Java runtime not found \u2014 install JDK 21+ and ensure java is on PATH"),n.fixCommands?.push("https://adoptium.net/");}if(b){if(!S)try{await execa("mvn",["-version"],{timeout:3e3,reject:false});}catch{n.issues.push("Maven not found \u2014 install Maven 3.9+ or add Maven Wrapper"),n.fixCommands?.push("https://maven.apache.org/install.html");}}else if(P&&!H)try{await execa("gradle",["--version"],{timeout:3e3,reject:false});}catch{n.issues.push("Gradle not found \u2014 install Gradle 8+ or add Gradle Wrapper"),n.fixCommands?.push("https://gradle.org/install/");}let F=s.join(e,"target"),A=s.join(e,"build","libs"),J=s.join(e,".rapidkit","cache","java","m2"),$=s.join(e,".rapidkit","cache","java","gradle");n.depsInstalled=await c$1.pathExists(F)||await c$1.pathExists(A)||await c$1.pathExists(J)||await c$1.pathExists($),n.depsInstalled||(n.issues.push("Java dependencies are not warmed or built yet"),n.fixCommands?.push(V(e,"rapidkit init")));let B=s.join(e,".env");if(n.hasEnvFile=await c$1.pathExists(B),!n.hasEnvFile){let de=s.join(e,".env.example");await c$1.pathExists(de)&&(n.issues.push("Environment file missing (found .env.example)"),n.fixCommands?.push(ae(e)));}let ie=s.join(e,"src","main","resources","application.yml");if(await c$1.pathExists(ie))try{let de=await c$1.readFile(ie,"utf-8");/include:\s*[^\n]*health/i.test(de)||/management:\s*[\s\S]*endpoint:\s*[\s\S]*health:/i.test(de)||(n.issues.push("Actuator health endpoint exposure is not clearly configured in application.yml"),n.fixCommands?.push(V(e,"Ensure management.endpoints.web.exposure.include contains health in src/main/resources/application.yml")));}catch{n.issues.push("Unable to read application.yml for Spring Actuator health checks");}return await U(e,n),await Y(e,n),await z(e,n),await Q(e,n),n}if(O){Z(n,i(e,r??null)),n.venvActive=true,n.coreInstalled=false;let b=s.join(e,"Cargo.lock"),P=s.join(e,"target");n.depsInstalled=await c$1.pathExists(b)||await c$1.pathExists(P),n.depsInstalled||(n.issues.push("Rust dependencies are not resolved yet (Cargo.lock/target missing)"),n.fixCommands?.push(V(e,"cargo fetch")));let S=s.join(e,".env");if(n.hasEnvFile=await c$1.pathExists(S),!n.hasEnvFile){let H=s.join(e,".env.example");await c$1.pathExists(H)&&(n.issues.push("Environment file missing (found .env.example)"),n.fixCommands?.push(ae(e)));}return await U(e,n),await Y(e,n),await z(e,n),await Q(e,n),n}if(re){Z(n,i(e,r??null)),n.venvActive=true,n.coreInstalled=false;let b=s.join(e,"mix.lock"),P=s.join(e,"deps");n.depsInstalled=await c$1.pathExists(b)||await c$1.pathExists(P),n.depsInstalled||(n.issues.push("Elixir dependencies not installed (mix.lock/deps missing)"),n.fixCommands?.push(V(e,"mix deps.get")));let S=s.join(e,".env");if(n.hasEnvFile=await c$1.pathExists(S),!n.hasEnvFile){let H=s.join(e,".env.example");await c$1.pathExists(H)&&(n.issues.push("Environment file missing (found .env.example)"),n.fixCommands?.push(ae(e)));}return await U(e,n),await Y(e,n),await z(e,n),await Q(e,n),n}if(Fe){Z(n,i(e,r??null)),n.venvActive=true,n.coreInstalled=false;let b=s.join(e,".cpcache"),P=s.join(e,"target"),S=await c$1.pathExists(v)||await c$1.pathExists(x);return n.depsInstalled=await c$1.pathExists(b)||await c$1.pathExists(P)||S,n.depsInstalled||(n.issues.push("Clojure dependency cache not initialized"),n.fixCommands?.push(V(e,"clojure -P"))),await U(e,n),await Y(e,n),await z(e,n),await Q(e,n),n}if(Ne){Z(n,i(e,r??null)),n.venvActive=true,n.coreInstalled=false;let b=s.join(e,"target");n.depsInstalled=await c$1.pathExists(b),n.depsInstalled||(n.issues.push("Scala build artifacts missing (run dependency/build warmup)"),n.fixCommands?.push(V(e,"sbt compile")));let P=s.join(e,".env");if(n.hasEnvFile=await c$1.pathExists(P),!n.hasEnvFile){let S=s.join(e,".env.example");await c$1.pathExists(S)&&(n.issues.push("Environment file missing (found .env.example)"),n.fixCommands?.push(ae(e)));}return await U(e,n),await Y(e,n),await z(e,n),await Q(e,n),n}if(Ie){Z(n,i(e,r??null)),n.venvActive=true,n.coreInstalled=false,n.depsInstalled=true;let b=s.join(e,".env");if(n.hasEnvFile=await c$1.pathExists(b),!n.hasEnvFile){let P=s.join(e,".env.example");await c$1.pathExists(P)&&(n.issues.push("Environment file missing (found .env.example)"),n.fixCommands?.push(ae(e)));}return await U(e,n),await Y(e,n),await z(e,n),await Q(e,n),n}if(C){let b=null;try{b=await c$1.readJson(l$1);}catch{b=null;}let P={...b?.dependencies??{},...b?.devDependencies??{}},S=b?.scripts??{},H=typeof r?.kit_name=="string"?r.kit_name.toLowerCase():typeof r?.kit=="string"?r.kit.toLowerCase():"",F=d(e,r),A=li({dependencies:P,scripts:S,kitName:H});if(le)Te(n,"Bun","high");else {let $=i(e,r??null);$.key==="nestjs"||$.key==="express"||$.key==="fastify"||$.key==="koa"?Z(n,$):F.key!=="unknown"?ci(n,F):$.key!=="unknown"&&$.key!=="node"?Z(n,$):Te(n,A.framework,A.confidence);}n.venvActive=true;let J=s.join(e,"node_modules");if(await c$1.pathExists(J))try{let B=(await c$1.readdir(J)).filter(ie=>!ie.startsWith(".")&&!ie.startsWith("_"));n.depsInstalled=B.length>0;}catch{n.depsInstalled=false;}if(n.depsInstalled||(n.issues.push("Dependencies not installed (node_modules empty or missing)"),n.fixCommands?.push(V(e,le?"bun install":"rapidkit init"))),n.coreInstalled=false,n.projectKind==="frontend"){let $=[".env",".env.local",".env.development",".env.development.local",".env.production",".env.production.local"];if((await Promise.all($.map(ie=>c$1.pathExists(s.join(e,ie))))).some(Boolean))n.hasEnvFile=true;else {let ie=s.join(e,".env.example");await c$1.pathExists(ie)&&(n.hasEnvFile=false,n.issues.push("Environment file missing (found .env.example)"),n.fixCommands?.push(ae(e)));}}else {let $=s.join(e,".env");if(n.hasEnvFile=await c$1.pathExists($),!n.hasEnvFile){let B=s.join(e,".env.example");await c$1.pathExists(B)&&(n.issues.push("Environment file missing (found .env.example)"),n.fixCommands?.push(ae(e)));}}if(n.projectKind==="frontend")n.modulesHealthy=await tt(e),n.missingModules=[];else {let $=s.join(e,"src");if(n.modulesHealthy=true,n.missingModules=[],await c$1.pathExists($))try{let B=await c$1.readdir($);n.modulesHealthy=B.length>0;}catch{n.modulesHealthy=false;}}return await U(e,n,b),await Y(e,n,b),n.projectKind==="frontend"?await xi(e,n,b,F.key!=="unknown"?F:d(e,r)):await z(e,n),await Q(e,n),n}if(ee){let b=await di(e,r);Te(n,b.framework,b.confidence);let P=s.join(e,".venv");if(await c$1.pathExists(P)){n.venvActive=true;let A=l(P);if(await c$1.pathExists(A)){try{let{stdout:B}=await execa(A,["-c","import rapidkit_core; print(rapidkit_core.__version__)"],{timeout:2e3});n.coreInstalled=true,n.coreVersion=B.trim();}catch{n.coreInstalled=false;}let J="fastapi";n.framework==="Django"?J="django":n.framework==="Flask"?J="flask":n.framework==="Python"&&(J="");let $=true;if(J)try{await execa(A,["-c",`import ${J}`],{timeout:2e3}),n.depsInstalled=true,$=false;}catch{$=true;}if($)try{let B=s.join(P,"lib");if(await c$1.pathExists(B)){let de=(await c$1.readdir(B)).find(Ce=>Ce.startsWith("python"));if(de){let Ce=s.join(B,de,"site-packages");if(await c$1.pathExists(Ce)){let gn=(await c$1.readdir(Ce)).filter(Ge=>!Ge.startsWith("_")&&!Ge.includes("dist-info")&&!["pip","setuptools","wheel","pkg_resources"].includes(Ge));n.depsInstalled=gn.length>0;}}}n.depsInstalled||(n.issues.push("Dependencies not installed"),n.fixCommands?.push(Jt(e)));}catch{n.issues.push("Could not verify dependency installation");}}else n.issues.push("Virtual environment exists but Python executable not found");}else n.issues.push("Virtual environment not created"),n.fixCommands?.push(Jt(e));let S=s.join(e,".env");if(n.hasEnvFile=await c$1.pathExists(S),!n.hasEnvFile){let A=s.join(e,".env.example");await c$1.pathExists(A)&&(n.issues.push("Environment file missing (found .env.example)"),n.fixCommands?.push(ae(e)));}let H=s.join(e,"src"),F=s.join(e,"modules");if(n.modulesHealthy=true,n.missingModules=[],await c$1.pathExists(H)){let A=s.join(H,"__init__.py");await c$1.pathExists(A)||(n.modulesHealthy=false,n.missingModules.push("src/__init__.py"));}if(await c$1.pathExists(F))try{let A=await Pi(F);for(let J of A){let $=s.join(F,J,"__init__.py");await c$1.pathExists($)||(n.modulesHealthy=false,n.missingModules.push(`modules/${J}/__init__.py`));}}catch{}return !n.modulesHealthy&&n.missingModules.length>0&&n.issues.push(`Missing module init files: ${n.missingModules.join(", ")}`),await U(e,n),await Y(e,n),await z(e,n),await Q(e,n),n}if(j){Z(n,i(e,r??null)),n.venvActive=true,n.coreInstalled=false;let b=s.join(e,"vendor");n.depsInstalled=await c$1.pathExists(b),n.depsInstalled||(n.issues.push("PHP dependencies not installed (vendor missing)"),n.fixCommands?.push(V(e,"composer install")));let P=s.join(e,".env");if(n.hasEnvFile=await c$1.pathExists(P),!n.hasEnvFile){let S=s.join(e,".env.example");await c$1.pathExists(S)&&(n.issues.push("Environment file missing (found .env.example)"),n.fixCommands?.push(ae(e)));}return await U(e,n),await Y(e,n),await z(e,n),await Q(e,n),n}if(te){Z(n,i(e,r??null)),n.venvActive=true,n.coreInstalled=false;let b=await c$1.pathExists(s.join(e,"Gemfile.lock")),P=await c$1.pathExists(s.join(e,"vendor","bundle"));n.depsInstalled=b||P,n.depsInstalled||(n.issues.push("Ruby dependencies not installed (Gemfile.lock/vendor missing)"),n.fixCommands?.push(V(e,"bundle install")));let S=s.join(e,".env");return n.hasEnvFile=await c$1.pathExists(S),await U(e,n),await Y(e,n),await z(e,n),await Q(e,n),n}if(W){Z(n,i(e,r??null)),n.venvActive=true,n.coreInstalled=false;let b=s.join(e,"obj"),P=s.join(e,"src","obj"),S=s.join(e,"packages.lock.json");n.depsInstalled=await c$1.pathExists(b)||await c$1.pathExists(P)||await c$1.pathExists(S),n.depsInstalled||(n.issues.push(".NET restore/build artifacts not found"),n.fixCommands?.push(V(e,"dotnet restore")));let H=s.join(e,".env");return n.hasEnvFile=await c$1.pathExists(H),await U(e,n),await Y(e,n),await z(e,n),await Q(e,n),n}return Te(n,"Unknown","low"),n.issues.push("Unknown project type (no recognized runtime marker files)"),await U(e,n),await Y(e,n),await z(e,n),await Q(e,n),n}async function Pi(e){try{return (await c$1.readdir(e,{withFileTypes:true})).filter(i=>i.isDirectory()).map(i=>i.name)}catch{try{let t=await c$1.readdir(e),i=[];for(let n of t)try{(await c$1.stat(s.join(e,n))).isDirectory()&&i.push(n);}catch{continue}return i}catch{return []}}}async function Ut(e,t,i){let n=[{dir:e,depth:0}],o=new Set([".git",".rapidkit","node_modules","bin","obj","target"]);for(;n.length>0;){let a=n.shift();if(!a||a.depth>i)continue;let r;try{r=await c$1.readdir(a.dir,{withFileTypes:true});}catch{continue}for(let l of r){if(l.isFile()&&l.name.toLowerCase().endsWith(t.toLowerCase()))return true;l.isDirectory()&&!o.has(l.name)&&n.push({dir:s.join(a.dir,l.name),depth:a.depth+1});}}return false}async function Se(e){let t=s.join(e,".rapidkit");if(!await c$1.pathExists(t))return false;let i=["project.json","context.json","file-hashes.json"];for(let n of i)if(await c$1.pathExists(s.join(t,n)))return true;return false}function Ci(e,t){if(t.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 Ri(e,t,i){let n=new Set,o=[{dir:e,depth:0}];for(;o.length>0;){let a=o.shift();if(!a)break;try{let r=await c$1.readdir(a.dir);for(let l of r){if(Ci(l,i))continue;let d=s.join(a.dir,l),u;try{u=await c$1.stat(d);}catch{continue}if(u.isDirectory()){if(await Se(d)){n.add(d);continue}a.depth<t&&o.push({dir:d,depth:a.depth+1});}}}catch{continue}}return Array.from(n)}async function $e(e){let t=s.resolve(e),i=s.parse(t).root;for(;;){if(await Si(t))return t;if(t===i)break;t=s.dirname(t);}return null}async function Di(e){let t=s.resolve(e),i=await $e(t),n=i??s.parse(t).root;for(;;){if(await Se(t)||await Ei(t)&&(!i||t!==i))return t;if(t===n)break;t=s.dirname(t);}return null}function zt(e){let t=s.resolve(e);return process.platform==="darwin"?t.replace(/^\/private(?=\/var\/)/,""):t}async function Ei(e){let t=["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 t)if(await c$1.pathExists(s.join(e,i)))return true;return false}async function Si(e){let t=[s.join(e,".rapidkit-workspace"),s.join(e,".rapidkit","workspace-marker.json"),s.join(e,".rapidkit","config.json")];return Promise.all(t.map(i=>c$1.pathExists(i))).then(i=>i.some(Boolean))}function gt(e,t){let i=0,n=0,o=0;return e.forEach(r=>{r.status==="ok"?i++:r.status==="warn"?n++:r.status==="error"&&o++;}),t.forEach(r=>{let l=fe(r),d=r.isGoProject?r.issues.length===0&&r.depsInstalled:r.issues.length===0&&r.venvActive&&r.depsInstalled;if(r.issues.length>0||l>0||!d){n++;return}i++;}),{total:i+n+o,passed:i,warnings:n,errors:o}}function pn(e,t,i={}){let n=[];for(let a of e)n.push({id:a.id,label:a.label,status:a.result.status,scope:"host-system",policyRuleId:"system-status-derived",reason:a.result.details||a.result.message});let o=[...t].sort((a,r)=>{let l=`${a.path||""}|${a.name||""}`.toLowerCase(),d=`${r.path||""}|${r.name||""}`.toLowerCase();return l.localeCompare(d)});for(let a of o){let r=a.issues.length>0,l=fe(a),d=r||l>0?"warn":"ok",u=r?`${a.issues.length} blocking issue(s)`:l>0?`${l} advisory warning(s)`:"Project checks passed";n.push({id:`project:${a.name}`,label:`Project ${a.name}`,status:d,scope:"project-scoped",policyRuleId:r?"project-blocking-issues":l>0?"project-advisory-warnings":"project-checks-passed",reason:u});}if(i.includeWorkspaceAggregateRules){let a=t.reduce((d,u)=>d+u.issues.length,0),r=ut(t),l=e.filter(d=>d.result.status==="error").length;n.push({id:"workspace:projects-discovered",label:"Workspace projects discovered",status:t.length>0?"ok":"warn",scope:"workspace-aggregate",policyRuleId:"workspace-project-discovery",reason:t.length>0?`${t.length} project(s) discovered for workspace analysis.`:"No projects discovered for workspace analysis."}),n.push({id:"workspace:system-error-gate",label:"Workspace system error gate",status:l>0?"error":"ok",scope:"workspace-aggregate",policyRuleId:"workspace-system-error-gate",reason:l>0?`${l} system requirement gate(s) failed.`:"All system requirement gates passed."}),n.push({id:"workspace:blocking-issues-gate",label:"Workspace blocking issues gate",status:a>0?"warn":"ok",scope:"workspace-aggregate",policyRuleId:"workspace-blocking-issues-gate",reason:a>0?`${a} blocking project issue(s) detected.`:"No blocking project issues detected."}),n.push({id:"workspace:advisory-warnings-gate",label:"Workspace advisory warnings gate",status:r>0?"warn":"ok",scope:"workspace-aggregate",policyRuleId:"workspace-advisory-warning-gate",reason:r>0?`${r} advisory warning(s) detected.`:"No advisory warnings detected."});}return n}async function at(e,t=true,i=_e({})){let n=s.basename(e);try{let g=s.join(e,".rapidkit-workspace");await c$1.pathExists(g)&&(n=(await c$1.readJSON(g)).name||n);}catch{try{let g=s.join(e,".rapidkit","config.json");n=(await c$1.readJSON(g)).workspace_name||n;}catch{}}let[o,a]=await Promise.all([ft(),pi(e)]),r={workspacePath:e,workspaceName:n,python:o.python,poetry:o.poetry,pipx:o.pipx,go:o.go,rapidkitCore:o.rapidkitCore,projects:[],policyProfile:i};f.debug(`Workspace scan found ${a.length} project(s)`);let l=await ui(e,a),d=s.join(e,".rapidkit","reports","doctor-workspace-cache.json"),u=t?await mi(d,l):null;if(u){r.projects=u.projects;for(let g of r.projects)Vt(g,u.generatedAt),lt(g,g.path);r.projectScanCached=true,f.debug(`Workspace project health cache hit: ${d}`);}else try{let g=new Date().toISOString(),f$1=await Promise.all(a.map(v=>Be(v,{allowNonRapidkit:true})));for(let v of f$1)Vt(v,g),lt(v,v.path);r.projects=f$1,r.projectScanCached=false,await fi(d,{schemaVersion:nn,signature:l,generatedAt:g,projects:f$1}),f.debug(`Workspace project health cache refreshed: ${d}`);}catch(g){f.debug(`Failed to scan workspace projects: ${g}`);}r.projectScanSignature=l,r.projectScanCachePath=d;let h=[r.python,r.poetry,r.pipx,r.go,r.rapidkitCore];if(r.healthScore=gt(h,r.projects),r.scoreBreakdown=pn([{id:"system-python",label:"Python",result:r.python},{id:"system-poetry",label:"Poetry",result:r.poetry},{id:"system-pipx",label:"pipx",result:r.pipx},{id:"system-go",label:"Go",result:r.go},{id:"system-rapidkit-core",label:"RapidKit Core",result:r.rapidkitCore}],r.projects,{includeWorkspaceAggregateRules:true}),r.scopeProvenance=ln(r.scoreBreakdown),r.evidenceFreshness=on(r.projects,new Date().toISOString()),r.rapidkitCore.status==="ok"){let g=r.rapidkitCore.message.match(/([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);g&&(r.coreVersion=g[1]);}let y=s.join(e,".rapidkit","reports","doctor-last-run.json"),w=await sn(y,"workspace");return r.driftDelta=ni(w,r),r.evidencePath=await gi(e,r,u?d:null),r}function Yt(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,repairCapabilities:e.repairCapabilities,commandCapabilities:e.commandCapabilities}}async function $i(e$1,t){let i=e$1||t.projectPath,n=s.join(i,".rapidkit","reports","doctor-project-last-run.json");try{await c$1.ensureDir(s.dirname(n));let o=t.project.issues.filter(a=>typeof a=="string"&&a.trim().length>0).slice(0,12);if(await c$1.writeJSON(n,f$1({schemaVersion:b$3,evidenceType:"project",contract:we(),policyProfile:t.policyProfile,workspacePath:e$1||null,projectPath:t.projectPath,projectName:t.projectName,healthScore:t.healthScore,evidenceFreshness:t.evidenceFreshness,system:{python:t.python,poetry:t.poetry,pipx:t.pipx,go:t.go,rapidkitCore:t.rapidkitCore},project:t.project,driftDelta:t.driftDelta,summary:{scopeProvenance:t.scopeProvenance},scoreBreakdown:t.scoreBreakdown??[]},{commandId:"projectDoctor",exitCode:je(t.healthScore,{profile:t.policyProfile?.name}),generatedAt:new Date().toISOString(),blockers:o,runId:e()}),{spaces:2}),e$1&&s.resolve(e$1)!==s.resolve(t.projectPath)){let a=s.join(t.projectPath,".rapidkit","reports","doctor-project-last-run.json");await c$1.ensureDir(s.dirname(a)),await c$1.copy(n,a,{overwrite:true});}return n}catch{return}}async function dt(e,t,i=[]){let n=s.join(e,".rapidkit","reports","doctor-remediation-plan-last-run.json");try{await c$1.ensureDir(s.dirname(n)),await c$1.writeJSON(n,t,{spaces:2});for(let o of i){if(s.resolve(o)===s.resolve(e))continue;let a=s.join(o,".rapidkit","reports","doctor-remediation-plan-last-run.json");await c$1.ensureDir(s.dirname(a)),await c$1.copy(n,a,{overwrite:true});}return n}catch{return}}async function ve(e,t,i=[]){let n=s.join(e,".rapidkit","reports","doctor-fix-result-last-run.json");try{await c$1.ensureDir(s.dirname(n)),await c$1.writeJSON(n,t,{spaces:2});for(let o of i){if(s.resolve(o)===s.resolve(e))continue;let a=s.join(o,".rapidkit","reports","doctor-fix-result-last-run.json");await c$1.ensureDir(s.dirname(a)),await c$1.copy(n,a,{overwrite:true});}return n}catch{return}}async function be(e,t,i){try{await j(e,g(t,i));}catch{}}async function Qt(e,t=_e({})){let i=await $e(e),n=await ft(),o=await Be(e,{allowNonRapidkit:true});lt(o,e);let a=gt([n.python,n.poetry,n.pipx,n.go,n.rapidkitCore],[o]),r={workspacePath:i||void 0,projectPath:e,projectName:s.basename(e),python:n.python,poetry:n.poetry,pipx:n.pipx,go:n.go,rapidkitCore:n.rapidkitCore,project:o,healthScore:a,policyProfile:t};r.scoreBreakdown=pn([{id:"system-python",label:"Python",result:r.python},{id:"system-poetry",label:"Poetry",result:r.poetry},{id:"system-pipx",label:"pipx",result:r.pipx},{id:"system-go",label:"Go",result:r.go},{id:"system-rapidkit-core",label:"RapidKit Core",result:r.rapidkitCore}],[r.project]),r.scopeProvenance=ln(r.scoreBreakdown),r.evidenceFreshness=on([r.project],new Date().toISOString());let l=i||e,d=s.join(l,".rapidkit","reports","doctor-project-last-run.json"),u=await sn(d,"project");return r.driftDelta=ii(u,r),r.evidencePath=await $i(i||void 0,r),r}function K(e,t){let i=e.status==="ok"?"\u2705":e.status==="warn"?"\u26A0\uFE0F":"\u274C",n=e.status==="ok"?p.green:e.status==="warn"?p.yellow:p.red;console.log(`${i} ${p.bold(t)}: ${n(e.message)}`),e.paths&&e.paths.length>0&&e.paths.forEach(o=>{let a=o.version?p.cyan(` -> ${o.version}`):"";console.log(` ${p.cyan("\u2022")} ${p.gray(o.location)}: ${p.dim(o.path)}${a}`);}),e.details&&console.log(` ${p.gray(e.details)}`);}function Xt(e){let t=e.issues.length>0,i=t?"\u26A0\uFE0F":"\u2705",n=t?p.yellow:p.green;if(console.log(`
|
|
6
|
+
`,reason:"Create a minimal ignore baseline so local env files are not committed accidentally."});let t=await Me(s.join(e,".gitignore")),i=nt.filter(n=>!t.split(/\r?\n/).includes(n));return Nt({issueId:"surface-security-hygiene",title:"Append .gitignore secret baseline",projectPath:e,relativePath:".gitignore",lines:i,reason:"Append missing env-file ignore rules so local secrets stay out of source control."})}async function In(e){let t=Cn[e.runtime]??[],i=Pn[e.runtime]??[];if(t.length===0&&i.length===0)return null;let n=await Oe(e.projectPath,t),o=await Oe(e.projectPath,i),a=n&&!o?await En({projectPath:e.projectPath,runtime:e.runtime,packageJsonData:e.packageJsonData}):null;return {id:"surface-dependency-contract",label:"Dependency contract",status:!n||o?"pass":"warn",severity:"warn",scope:"project-scoped",reason:n?o?"Dependency manifest and deterministic lock/baseline markers detected.":`Dependency manifest detected, but no deterministic baseline found (${i.join(", ")}).`:"No dependency manifest markers detected for this runtime.",recommendation:n&&!o?"Generate and commit the runtime-native lockfile or package baseline before release.":void 0,repairCapability:n&&!o&&a?Ht({issueId:"surface-dependency-contract",title:a.title,projectPath:e.projectPath,command:a.command,files:a.files,fixKind:"dependency-sync",reason:"Generate the runtime-native dependency baseline so CI, Doctor, and Studio share deterministic dependency evidence.",limitations:a.limitations}):void 0}}async function An(e){let t=await c$1.pathExists(s.join(e.projectPath,".env.example")),i=await c$1.pathExists(s.join(e.projectPath,".env")),n=await c$1.pathExists(s.join(e.projectPath,"docs","env.md"))||await c$1.pathExists(s.join(e.projectPath,"ENVIRONMENT.md")),o=await c$1.pathExists(s.join(e.projectPath,"config")),a=t||n||o,r=e.projectKind==="frontend";return {id:"surface-env-contract",label:"Environment/config contract",status:a?"pass":"warn",severity:"warn",scope:"project-scoped",reason:a?"Environment/config contract marker detected.":r?"No frontend environment contract marker detected.":"No environment/config contract marker detected.",recommendation:a?void 0:"Add .env.example, config schema, or environment documentation for deterministic setup.",repairCapability:a?t&&!i?It({issueId:"surface-env-contract",title:"Create local .env from .env.example",projectPath:e.projectPath,sourceRelativePath:".env.example",targetRelativePath:".env",reason:"Seed the local environment file from the reviewed example without overwriting an existing .env."}):void 0:De({issueId:"surface-env-contract",title:"Define environment contract",projectPath:e.projectPath,files:[".env.example"],reason:"Environment contracts are product-specific; Doctor can identify the missing baseline, but values must be reviewed by the project owner."})}}async function On(e){let t=await c$1.pathExists(s.join(e.projectPath,"Dockerfile")),i=await c$1.pathExists(s.join(e.projectPath,".dockerignore")),n=await c$1.pathExists(s.join(e.projectPath,"docker-compose.yml"))||await c$1.pathExists(s.join(e.projectPath,"compose.yml"));return t?{id:"surface-dockerignore",label:"Container build context hygiene",status:i?"pass":"warn",severity:"warn",scope:"project-scoped",reason:i?"Dockerfile and .dockerignore detected.":"Dockerfile detected without .dockerignore.",recommendation:i?void 0:"Add .dockerignore to exclude dependencies, reports, git metadata, and local env files from image builds.",repairCapability:i?void 0:Fn(e.projectPath)}:{id:"surface-container-contract",label:"Container contract",status:n?"pass":"warn",severity:"warn",scope:"project-scoped",reason:n?"Compose surface detected; project has a local container orchestration baseline.":"No Dockerfile or compose surface detected.",recommendation:e.projectKind==="backend"||e.projectKind==="fullstack"?"Add Dockerfile or compose baseline when this service is expected to run in containerized environments.":"Add container baseline only if this app is shipped through containerized environments."}}async function Mn(e){let t=["k8s","kubernetes","deploy","deployments","charts","helm","kustomization.yaml","kustomization.yml"];if(!await Oe(e.projectPath,t))return {id:"surface-deploy-contract",label:"Deployment contract",status:"warn",severity:"warn",scope:"project-scoped",reason:"No Kubernetes/Helm/Kustomize deployment surface detected.",recommendation:e.projectKind==="backend"||e.projectKind==="fullstack"?"Add deployment manifests or document the non-Kubernetes deployment path.":"Document the deployment path when this frontend is production-hosted."};let n=await it(e.projectPath,["k8s/deployment.yaml","k8s/deployment.yml","kubernetes/deployment.yaml","deploy/deployment.yaml","deployment.yaml","deployment.yml","values.yaml","charts/values.yaml"]),o=/readinessProbe|livenessProbe|startupProbe/.test(n),a=/resources:\s*[\s\S]*(limits:|requests:)/.test(n),r=o&&a;return {id:"surface-kubernetes-readiness",label:"Deployment readiness controls",status:r?"pass":"warn",severity:"warn",scope:"project-scoped",reason:r?"Deployment surface includes probe and resource-control markers.":"Deployment surface detected, but readiness/liveness probes or resource controls are incomplete.",recommendation:r?void 0:"Add readiness/liveness/startup probes and resource requests/limits to production deployment manifests.",repairCapability:r?void 0:De({issueId:"surface-kubernetes-readiness",title:"Harden deployment readiness controls",projectPath:e.projectPath,files:["k8s/","helm/","deploy/"],reason:"Deployment manifests are environment-specific and should be reviewed before mutation."})}}async function Tn(e){let t=await c$1.pathExists(s.join(e.projectPath,".gitignore")),n=(await Me(s.join(e.projectPath,".gitignore"))).split(/\r?\n/),o=t&&nt.every(h=>n.includes(h)),a=rt(e.packageJsonData),r=!!(a.audit||a["security:audit"]||a["audit:security"]||a["npm:audit"]),l=Number(e.vulnerabilities??0),d=l>0;return {id:"surface-security-hygiene",label:"Security hygiene surface",status:o&&!d?"pass":d?"fail":"warn",severity:d?"error":"warn",scope:"project-scoped",reason:d?`${l} moderate/high/critical dependency vulnerability(ies) reported.`:o?"Repository ignore baseline covers env-file secrets and no dependency vulnerabilities were reported by Doctor.":t?"Repository ignore baseline exists, but env-file secret rules are incomplete.":"No .gitignore baseline detected for local secrets/build artifacts.",recommendation:d?"Run the runtime-native audit fix path without force, review lockfile changes, then rerun Doctor.":o?r?void 0:"Consider adding a security audit script for CI parity.":"Add .gitignore entries for env files, build output, dependency directories, and local reports.",repairCapability:d?De({issueId:"surface-security-hygiene",title:"Review dependency vulnerability fix",projectPath:e.projectPath,files:["package.json","package-lock.json","pnpm-lock.yaml","yarn.lock"],reason:"Dependency vulnerability remediation can change transitive dependency graphs and must be reviewed.",limitations:["Avoid npm audit fix --force unless a maintainer explicitly accepts breaking changes."]}):o?void 0:await Nn(e.projectPath)}}async function Hn(e){let t=Re(e.runtimeFamily),i=e.hasTests===true,n=i?void 0:await ot({issueId:"surface-test-contract",projectPath:e.projectPath,runtime:t,kind:"test",packageJsonData:e.packageJsonData,reason:"Create a deterministic runtime-native test command contract so Doctor, CI, and Studio can verify changes consistently."});return {id:"surface-test-contract",label:"Test contract",status:i?"pass":"warn",severity:"warn",scope:"project-scoped",reason:i?"Test surface detected through scripts, config, directories, or test files.":"No test surface detected by Doctor.",recommendation:i?void 0:"Add at least one deterministic test command or test baseline before release.",repairCapability:n??(i?void 0:De({issueId:"surface-test-contract",title:"Define test contract",projectPath:e.projectPath,files:["package.json","pyproject.toml","go.mod","pom.xml"],reason:"Doctor can identify missing test surfaces, but the correct test runner depends on product intent."}))}}function _n(e){let t=rt(e.packageJsonData),i=!!(t.format||t["format:check"]||t.prettier);return {id:"surface-format-contract",label:"Format contract",status:i?"pass":"warn",severity:"warn",scope:"project-scoped",reason:i?"Format script detected in package.json.":"No explicit format script detected by Doctor.",recommendation:i?void 0:"Add a formatter command or document the formatting tool used by CI."}}async function Bn(e){let t=Re(e.runtimeFamily),n={node:["vitest.config.ts","jest.config.js","playwright.config.ts","cypress.config.ts"],deno:["deno.json","deno.jsonc"],bun:["bunfig.toml"],python:["pytest.ini","tox.ini","noxfile.py","tests","pyproject.toml"],go:["*_test.go"],java:["src/test","pom.xml","build.gradle","build.gradle.kts"],rust:["tests","Cargo.toml"],elixir:["test","mix.exs"],clojure:["test","deps.edn","project.clj"],php:["phpunit.xml","phpunit.xml.dist","tests"],ruby:["spec","test",".rspec"],dotnet:["*.Tests.csproj","*.Test.csproj","*.sln"],unknown:[]}[t]??[];if(n.length===0)return null;let o=await Oe(e.projectPath,n),a=e.hasTests===true&&o;return {id:"runtime-test-depth",label:"Runtime-native test depth",status:a?"pass":("warn"),severity:"warn",scope:"project-scoped",reason:a?"Runtime-native test markers detected.":e.hasTests?"Generic test surface detected, but runtime-native test markers are incomplete.":"No runtime-native test markers detected.",recommendation:a?void 0:"Add runtime-native tests/config so Doctor, CI, and Studio can verify changes deterministically."}}async function qn(e){let t=Re(e.runtimeFamily),n={node:["eslint.config.js","eslint.config.mjs",".eslintrc.json","prettier.config.js"],deno:["deno.json","deno.jsonc"],bun:["eslint.config.js","biome.json","bunfig.toml"],python:["ruff.toml","pyproject.toml",".flake8","mypy.ini","Makefile"],go:[".golangci.yml",".golangci.yaml","Makefile"],java:["checkstyle.xml","pom.xml","build.gradle","build.gradle.kts"],rust:["rustfmt.toml","clippy.toml","Cargo.toml"],elixir:[".formatter.exs","credo.exs","mix.exs"],clojure:["cljfmt.edn",".clj-kondo","deps.edn"],php:["phpcs.xml","phpstan.neon","pint.json","composer.json"],ruby:[".rubocop.yml","Gemfile"],dotnet:[".editorconfig","Directory.Build.props","global.json"],unknown:[]}[t]??[];if(n.length===0)return null;let o=await it(e.projectPath,n),a=/eslint|prettier|biome|ruff|black|mypy|golangci|checkstyle|spotless|pmd|clippy|rustfmt|credo|clj-kondo|phpstan|phpcs|pint|rubocop|editorconfig|dotnet format/i.test(o),r=a?void 0:await ot({issueId:"runtime-quality-tooling",projectPath:e.projectPath,runtime:t,kind:"quality",packageJsonData:e.packageJsonData,reason:"Create a deterministic runtime-native quality command contract so CI and Studio can verify formatting/static-analysis consistently."});return {id:"runtime-quality-tooling",label:"Runtime-native quality tooling",status:a?"pass":"warn",severity:"warn",scope:"project-scoped",reason:a?"Runtime-native lint/format/static-analysis markers detected.":"No runtime-native lint/format/static-analysis markers detected.",recommendation:a?void 0:"Add runtime-native lint/format/static-analysis tooling and expose it to CI.",repairCapability:r}}async function Kn(e){let t=Re(e.runtimeFamily),n={node:["package.json"],deno:["deno.json","deno.jsonc"],bun:["package.json","bunfig.toml"],python:["pyproject.toml","requirements.txt","Makefile"],go:["Makefile","go.mod"],java:["pom.xml","build.gradle","build.gradle.kts"],rust:["Cargo.toml"],elixir:["mix.exs"],clojure:["deps.edn","project.clj"],php:["composer.json"],ruby:["Gemfile",".bundler-audit.yml"],dotnet:["Directory.Build.props","*.csproj"],unknown:[]}[t]??[];if(n.length===0)return null;let o=await it(e.projectPath,n),a=/npm audit|pnpm audit|yarn audit|bun audit|pip[-_]audit|safety|bandit|govulncheck|gosec|dependency-check|owasp|cargo audit|mix hex.audit|composer audit|bundler-audit|brakeman|NuGetAudit|dotnet list package --vulnerable/i.test(o),r=a?void 0:await ot({issueId:"runtime-security-tooling",projectPath:e.projectPath,runtime:t,kind:"security",packageJsonData:e.packageJsonData,reason:"Create a deterministic runtime-native security audit command contract so CI and Studio can verify dependency risk consistently."});return {id:"runtime-security-tooling",label:"Runtime-native security tooling",status:a?"pass":"warn",severity:"warn",scope:"project-scoped",reason:a?"Runtime-native security audit tooling marker detected.":"No runtime-native security audit tooling marker detected.",recommendation:a?void 0:"Expose a runtime-native dependency/security audit command for CI and Studio verification.",repairCapability:a?void 0:r||De({issueId:"runtime-security-tooling",title:"Define runtime security audit command",projectPath:e.projectPath,files:["package.json","pyproject.toml","Makefile","pom.xml","Cargo.toml"],reason:"Security tooling differs by runtime and organization policy; Doctor records the missing contract for review."})}}async function Gt(e){let t=Re(e.runtimeFamily),i=[],n=await In({projectPath:e.projectPath,runtime:t,packageJsonData:e.packageJsonData});n&&i.push(n),i.push(await An(e)),i.push(await On(e)),i.push(await Mn(e)),i.push(await Tn(e)),i.push(await Hn(e)),t==="node"&&i.push(_n(e));let o=await Promise.all([Bn(e),qn(e),Kn(e)]);for(let a of o)a&&i.push(a);return i}function Wn(e){return [...new Set(e.filter(t=>t&&t.trim().length>0))]}function Wt(e){return [...new Set(e.filter(t=>t&&t.trim().length>0))]}function Vn(){let e=q$1().map(n=>s.join(n,b$4()?"poetry.exe":"poetry")),t=b$4()?[s.join(process.env.APPDATA||"","Python","Scripts","poetry.exe"),s.join(process.env.USERPROFILE||"","AppData","Roaming","Python","Scripts","poetry.exe")]:[],i=b$4()?[]:["/usr/local/bin/poetry","/usr/bin/poetry"];return Wn([...e,...t,...i])}function Jn(e){let t=q$1().map(d=>({location:"Global (user-local)",path:s.join(d,b$4()?"rapidkit.exe":"rapidkit")})),i=[{location:"Global (pipx)",path:s.join(e,".local","bin","rapidkit")},{location:"Global (pipx)",path:s.join(e,"AppData","Roaming","Python","Scripts","rapidkit.exe")},{location:"Global (pyenv)",path:s.join(e,".pyenv","shims","rapidkit")},{location:"Global (system)",path:"/usr/local/bin/rapidkit"},{location:"Global (system)",path:"/usr/bin/rapidkit"}],n=m(s.join(process.cwd(),".venv")),o$1=o(process.cwd()),a=[{location:"Workspace (.venv)",path:n},...o$1.map(d=>({location:"Workspace (launcher)",path:d}))],r=[...t,...i,...a],l=new Set;return r.filter(d=>l.has(d.path)?false:(l.add(d.path),true))}function Ln(e){let t=new Map([["Workspace (.venv)",0],["Global (user-local)",1],["Global (pipx)",2],["Global (pyenv)",3],["Global (system)",4]]);return [...e].sort((i,n)=>{let o=t.get(i.location)??Number.MAX_SAFE_INTEGER,a=t.get(n.location)??Number.MAX_SAFE_INTEGER;return o!==a?o-a:i.path.localeCompare(n.path)})}function fe(e){let t=0,i=e.issues.some(n=>n.toLowerCase().includes("environment file missing"));return e.hasEnvFile===false&&!i&&(t+=1),typeof e.vulnerabilities=="number"&&e.vulnerabilities>0&&(t+=1),t}function ct(e){return e.filter(t=>fe(t)>0).length}function ut(e){return e.reduce((t,i)=>t+fe(i),0)}function Un(e){let t=e.coreVersion?.split(".")[0],i=e.npmVersion?.split(".")[0];return !t||!i?false:t!==i}var zn="doctor-project-scan-v2",nn="doctor-workspace-cache-v2",Yn=Object.freeze({version:"doctor-evidence-v1",scoringPolicyVersion:"doctor-score-policy-v1",generatedBy:"rapidkit-npm",deterministicScoreBreakdown:true,scopeModel:"workspace-aggregate-or-project-scoped"}),Ee=Object.freeze({local:{name:"local",exitOnErrors:true,exitOnWarnings:false,warningExitCode:0,advisoryWarningsBlockRelease:false,description:"Local diagnostics: report warnings without blocking the developer loop."},ci:{name:"ci",exitOnErrors:true,exitOnWarnings:true,warningExitCode:2,advisoryWarningsBlockRelease:false,description:"CI diagnostics: errors fail, warnings return a distinct warning exit code."},release:{name:"release",exitOnErrors:true,exitOnWarnings:true,warningExitCode:1,advisoryWarningsBlockRelease:true,description:"Release gate: any warning/error blocks release readiness."},"enterprise-strict":{name:"enterprise-strict",exitOnErrors:true,exitOnWarnings:true,warningExitCode:1,advisoryWarningsBlockRelease:true,description:"Enterprise strict gate: all warnings/errors block release and must carry evidence or repair guidance."}});function we(){return {...Yn}}function _e(e){let t=e.profile?.trim();return t&&t in Ee?{...Ee[t]}:e.strict?{...Ee.release}:e.ci?{...Ee.ci}:{...Ee.local}}function He(e){return !e||e.total<=0?null:Math.round(e.passed/e.total*100)}function Qn(e){return e.id==="surface-security-hygiene"&&/vulnerabilit/i.test(`${e.reason} ${e.recommendation??""}`)?{category:"state",ttlSeconds:300,reason:"Dependency vulnerability evidence is live state and must be refreshed before release use."}:e.id.includes("script")||e.id.includes("test")||e.id.includes("quality")||e.id.includes("format")||e.id.includes("runtime")||e.id.includes("lockfile")?{category:"verification",ttlSeconds:1440*60,reason:"Verification/tooling evidence can drift with dependency and config changes; refresh daily or before release."}:e.id.includes("dependency")||e.id.includes("env")||e.id.includes("container")||e.id.includes("docker")||e.id.includes("deploy")||e.id.includes("kubernetes")||e.id.includes("source-tree")||e.id.includes("framework")||e.id.includes("typescript")?{category:"structure",ttlSeconds:10080*60,reason:"Structural workspace/project evidence is durable but should be refreshed when files or manifests change."}:{category:"verification",ttlSeconds:1440*60,reason:"Default Doctor evidence freshness contract for project-scoped verification."}}function Xn(e,t){let i=Qn(e),n=Date.parse(t),o=typeof i.ttlSeconds=="number"?i.ttlSeconds*1e3:null,a=o!==null&&Number.isFinite(n)?new Date(n+o).toISOString():void 0,r=!Number.isFinite(n)||o!==null&&!a?"unknown":o!==null&&Date.now()>n+o?"stale":"fresh";return {category:i.category,generatedAt:t,ttlSeconds:i.ttlSeconds,...a?{expiresAt:a}:{},status:r,verifyBeforeUse:i.category!=="structure"||r!=="fresh",reason:i.reason}}function Zn(e){let t=e.id.toLowerCase(),i=`${e.label} ${e.reason} ${e.recommendation??""}`.toLowerCase();return t.includes("dependency")||t.includes("lockfile")||i.includes("lockfile")?"dependency":t.includes("security")||i.includes("vulnerabilit")||i.includes("audit")?"security":t.includes("env")||i.includes(".env")||i.includes("environment")?"environment":t.includes("test")?"test":t.includes("quality")||t.includes("format")||t.includes("lint")?"quality":t.includes("docker")||t.includes("container")?"container":t.includes("deploy")||t.includes("kubernetes")?"deployment":t.includes("runtime")?"runtime":t.includes("contract")?"workspace-contract":t.includes("source-tree")?"source-tree":t.includes("framework")||t.includes("typescript")?"framework":t.includes("custom")?"custom":t.includes("script")||t.includes("config")?"configuration":"unknown"}function ei(e,t){return e.status==="pass"?"none":t==="security"?"security-risk":t==="deployment"||t==="runtime"?"runtime-risk":t==="dependency"||t==="test"||t==="quality"||t==="workspace-contract"?e.severity==="error"||e.status==="fail"?"release-risk":"ci-risk":t==="container"||t==="environment"?"release-risk":"developer-friction"}function ti(e){let{probe:t,freshness:i}=e,n=t.repairCapability;if(t.status==="pass")return {mode:"none",confidence:"high",primaryActionLabel:"No action required",requiresApproval:false,requiresFreshEvidence:false,reason:"Probe is passing.",relatedCommands:[]};if(i.status!=="fresh")return {mode:"refresh-evidence",confidence:"high",primaryActionLabel:"Refresh evidence",requiresApproval:false,requiresFreshEvidence:true,reason:`Evidence is ${i.status}; refresh Doctor before applying repairs.`,relatedCommands:["npx rapidkit doctor project --json"]};if(i.verifyBeforeUse&&i.category==="state")return {mode:"verify-before-fix",confidence:"high",primaryActionLabel:"Verify live state",requiresApproval:false,requiresFreshEvidence:true,reason:"Live state evidence must be re-read before Studio claims a fix path.",relatedCommands:["npx rapidkit doctor project --json"]};if(n?.status==="available"&&n.canAutoFix){let o=n.canEditFiles;return {mode:o?"edit-file":"run-command",confidence:"high",primaryActionLabel:o?"Apply file fix":"Run fix command",requiresApproval:n.requiresApproval,requiresFreshEvidence:i.verifyBeforeUse,reason:n.reason,relatedCommands:Wt([...n.command?[n.command]:[],...n.verifyCommand?[n.verifyCommand]:[],...n.refreshCommands])}}return n?.status==="manual"||n?.requiresReview?{mode:"review-required",confidence:"medium",primaryActionLabel:"Review fix path",requiresApproval:true,requiresFreshEvidence:i.verifyBeforeUse,reason:n?.reason??t.recommendation??t.reason,relatedCommands:Wt(n?.refreshCommands??["npx rapidkit doctor project --json"])}:t.recommendation?{mode:"manual-guidance",confidence:"medium",primaryActionLabel:"Inspect guidance",requiresApproval:false,requiresFreshEvidence:i.verifyBeforeUse,reason:t.recommendation,relatedCommands:["npx rapidkit doctor project --json"]}:{mode:"manual-guidance",confidence:"low",primaryActionLabel:"Inspect issue",requiresApproval:false,requiresFreshEvidence:i.verifyBeforeUse,reason:"Doctor classified the issue but does not have a deterministic repair path yet.",relatedCommands:["npx rapidkit doctor project --json"]}}function rn(e,t){let i=Xn(e,e.freshness?.generatedAt??t),n=e.issueClass??Zn(e),o=e.operationalImpact??ei(e,n),a=e.repairIntent??ti({probe:e,freshness:i});return {...e,freshness:i,issueClass:n,operationalImpact:o,repairIntent:a}}function Vt(e,t){Array.isArray(e.probes)&&(e.probes=e.probes.map(i=>rn(i,t)));}function on(e,t){let i=e.flatMap(d=>Array.isArray(d.probes)?d.probes.map(u=>u.freshness).filter(u=>!!u):[]),n=i.filter(d=>d.status==="stale").length,o=i.filter(d=>d.status==="unknown").length,a=i.filter(d=>d.category==="state").length,r=i.filter(d=>d.verifyBeforeUse).length,l=i.map(d=>d.generatedAt).filter(Boolean).sort()[0];return {generatedAt:t,status:n>0?"stale":o>0?"unknown":"fresh",staleProbeCount:n,unknownProbeCount:o,liveStateProbeCount:a,verifyBeforeUseProbeCount:r,...l?{oldestProbeGeneratedAt:l}:{}}}function an(e){return typeof e=="number"?e:Array.isArray(e)?e.length:0}async function sn(e,t){try{if(!await c$1.pathExists(e))return null;let i=await c$1.readJSON(e);return c$3(i,t)?i:null}catch{return null}}function cn(e,t){if(!e?.system)return [];let i=[{id:"python",current:t.python},{id:"poetry",current:t.poetry},{id:"pipx",current:t.pipx},{id:"go",current:t.go},{id:"rapidkitCore",current:t.rapidkitCore}],n=[];for(let o of i){let a=e.system?.[o.id]?.status;!a||a===o.current.status||n.push({id:o.id,from:a,to:o.current.status});}return n}function ni(e,t){let i=new Map;for(let w of t.projects)i.set(w.path||w.name,w.issues.length);if(!e)return {baselineAvailable:false,newIssueCount:0,resolvedIssueCount:0,netIssueDelta:0,scoreDeltaPercent:null,systemStatusChanges:[],regressedProjects:[],improvedProjects:[]};let n=Array.isArray(e.projects)?e.projects:[],o=new Map;for(let w of n){let g=w.path||w.name;g&&o.set(g,an(w.issues));}let a=0,r=0,l=new Set,d=new Set,u=new Set([...Array.from(o.keys()),...Array.from(i.keys())]);for(let w of u){let g=o.get(w)??0,f=i.get(w)??0;f>g?(a+=f-g,l.add(w)):f<g&&(r+=g-f,d.add(w));}let h=He(e.healthScore),y=He(t.healthScore);return {baselineAvailable:true,previousGeneratedAt:e.generatedAt,newIssueCount:a,resolvedIssueCount:r,netIssueDelta:a-r,scoreDeltaPercent:h===null||y===null?null:y-h,systemStatusChanges:cn(e,{python:t.python,poetry:t.poetry,pipx:t.pipx,go:t.go,rapidkitCore:t.rapidkitCore}),regressedProjects:Array.from(l).sort(),improvedProjects:Array.from(d).sort()}}function ii(e,t){if(!e)return {baselineAvailable:false,newIssueCount:0,resolvedIssueCount:0,netIssueDelta:0,scoreDeltaPercent:null,systemStatusChanges:[],regressedProjects:[],improvedProjects:[]};let i=an(e.project?.issues),n=t.project.issues.length,o=Math.max(n-i,0),a=Math.max(i-n,0),r=He(e.healthScore),l=He(t.healthScore),d=t.project.path||t.project.name;return {baselineAvailable:true,previousGeneratedAt:e.generatedAt,newIssueCount:o,resolvedIssueCount:a,netIssueDelta:o-a,scoreDeltaPercent:r===null||l===null?null:l-r,systemStatusChanges:cn(e,{python:t.python,poetry:t.poetry,pipx:t.pipx,go:t.go,rapidkitCore:t.rapidkitCore}),regressedProjects:o>0?[d]:[],improvedProjects:a>0?[d]:[]}}function ln(e){let t=e??[],i=0,n=0;for(let r of t){if(r.scope==="project-scoped"){i+=1;continue}(r.scope==="workspace-aggregate"||r.scope==="host-system")&&(n+=1);}let o=i>0&&n>0?1:0,a=o>0?"mixed":i>0?"scoped":n>0?"aggregated":"unknown";return {scopedCount:i,aggregatedCount:n,mixedCount:o,dominantScope:a}}function V(e,t){return b$4()?`cd "${e}"; ${t}`:`cd ${e} && ${t}`}function ae(e){return b$4()?V(e,"Copy-Item .env.example .env"):V(e,"cp .env.example .env")}function Jt(e){return V(e,"poetry install --no-root")}function ri(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 oi(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 ai(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 lt(e,t){let i=q(t);e.commandCapabilities=i,e.supportTier=i.frameworkSupportTier;}function Te(e,t,i,n){e.framework=t,e.frameworkConfidence=i,e.supportTier=ri(t),e.projectKind=oi(t),e.runtimeFamily=ai(t);}function dn(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 mt(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 si(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 ci(e,t){e.framework=mt(t),e.frameworkKey=t.key,e.importStack=t.importStack,e.frameworkConfidence=t.confidence,e.supportTier=t.supportTier,e.projectKind="frontend",e.runtimeFamily=dn(t.runtime);}function Z(e,t){e.framework=mt(t),e.frameworkKey=t.key,e.importStack=t.importStack,e.frameworkConfidence=t.confidence,e.supportTier=t.supportTier,e.projectKind=si(t)?"generic":"backend",e.runtimeFamily=dn(t.runtime);}function li(e){let t=e.dependencies,i=e.scripts??{},n=(e.kitName??"").toLowerCase(),o=r=>!!t[r],a=Object.values(i).filter(r=>typeof r=="string").join(" ").toLowerCase();return o("next")||a.includes("next ")?{framework:"Next.js",confidence:"high"}:o("nuxt")||a.includes("nuxt ")?{framework:"Nuxt",confidence:"high"}:o("@nestjs/core")||n.startsWith("nestjs.")?{framework:"NestJS",confidence:"high"}:o("express")?{framework:"Express",confidence:"high"}:o("fastify")?{framework:"Fastify",confidence:"high"}:o("koa")?{framework:"Koa",confidence:"high"}:o("@angular/core")?{framework:"Angular",confidence:"high"}:o("@sveltejs/kit")||a.includes("svelte-kit")?{framework:"SvelteKit",confidence:"high"}:o("vue")?{framework:"Vue",confidence:"medium"}:o("react")&&o("react-dom")?{framework:"React",confidence:"medium"}:{framework:"Node.js",confidence:"low"}}async function di(e,t){let i$1=i(e,t??null);return i$1.runtime!=="python"?{framework:"Python",confidence:"low"}:{framework:mt(i$1),confidence:i$1.confidence}}async function Lt(e){try{let t=await c$1.stat(e);return `${s.basename(e)}:${t.isDirectory()?"d":"f"}:${t.size}:${t.mtimeMs}`}catch{return `${s.basename(e)}:missing`}}async function pi(e){try{let t=new Set([".git",".venv","node_modules",".rapidkit","dist","build","coverage","__pycache__"]),i=new Set,n=async r=>{if(await Se(r))return true;let l=["package.json","pyproject.toml","requirements.txt","go.mod","pom.xml","build.gradle","build.gradle.kts","*.csproj","Cargo.toml","composer.json","Gemfile","mix.exs","deps.edn","deno.json","deno.jsonc"];for(let d of l){if(d==="*.csproj"){if((await c$1.readdir(r).catch(()=>[])).some(h=>h.endsWith(".csproj")))return true;continue}if(await c$1.pathExists(s.join(r,d)))return true}return false};await Se(e)&&i.add(e);let o=await a(e);for(let r of o){let l=s.isAbsolute(r.path)?r.path:s.join(e,r.path);await n(l)&&i.add(l);}return (await a$1(e,{skipDirs:t,descendIntoMatchedProjects:false,isProjectDir:async(r,l)=>s.resolve(r)===s.resolve(l)?Se(r):n(r)})).forEach(r=>i.add(r)),i.size===0&&(await Ri(e,3,t)).forEach(l=>i.add(l)),i.size===0&&!await b$2(e)&&await n(e)&&i.add(e),Array.from(i).sort((r,l)=>r.localeCompare(l))}catch{return []}}async function ui(e,t){let i=[s.join(e,".rapidkit-workspace"),s.join(e,".rapidkit","workspace.json"),s.join(e,".rapidkit","imported-projects.json"),s.join(e,".rapidkit","policies.yml"),s.join(e,".rapidkit","toolchain.lock"),s.join(e,".rapidkit","cache-config.yml")],n=[".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"],o=await Promise.all(i.map(Lt)),a=await Promise.all(t.map(async r=>{let l=await Promise.all(n.map(d=>Lt(s.join(r,d))));return `${r}::${l.join("|")}`}));return [zn,...o,...a].join("||")}async function mi(e,t){try{if(!await c$1.pathExists(e))return null;let i=await c$1.readJSON(e);return !i||i.signature!==t||!Array.isArray(i.projects)||typeof i.schemaVersion=="string"&&i.schemaVersion!==nn?null:i}catch{return null}}async function fi(e,t){try{await c$1.ensureDir(s.dirname(e)),await c$1.writeJSON(e,t,{spaces:2});}catch{}}async function gi(e$1,t,i){let n=s.join(e$1,".rapidkit","reports","doctor-last-run.json");try{await c$1.ensureDir(s.dirname(n));let o=[];for(let a of t.projects)for(let r of a.issues??[])typeof r=="string"&&r.trim()&&o.push(`${a.name}: ${r.trim()}`);for(let[a,r]of [["python",t.python],["rapidkitCore",t.rapidkitCore]])if(r?.status==="error"){let l=typeof r.message=="string"?r.message:`${a} check failed`;o.push(`${a}: ${l}`);}return await c$1.writeJSON(n,f$1({schemaVersion:a$2,evidenceType:"workspace",contract:we(),policyProfile:t.policyProfile,workspacePath:e$1,workspaceName:t.workspaceName,projectScanCached:t.projectScanCached??false,projectScanSignature:t.projectScanSignature,cachePath:i,healthScore:t.healthScore,evidenceFreshness:t.evidenceFreshness,system:{python:t.python,poetry:t.poetry,pipx:t.pipx,go:t.go,rapidkitCore:t.rapidkitCore,versions:{core:t.coreVersion,npm:t.npmVersion}},projects:t.projects,summary:{totalProjects:t.projects.length,totalIssues:t.projects.reduce((a,r)=>a+r.issues.length,0),projectAdvisoryWarningProjects:ct(t.projects),projectAdvisoryWarnings:ut(t.projects),hasSystemErrors:[t.python,t.rapidkitCore].some(a=>a.status==="error"),scopeProvenance:t.scopeProvenance},driftDelta:t.driftDelta,scoreBreakdown:t.scoreBreakdown??[]},{commandId:"checkWorkspaceHealth",exitCode:je(t.healthScore,{profile:t.policyProfile?.name}),generatedAt:new Date().toISOString(),blockers:o.slice(0,12),runId:e()}),{spaces:2}),n}catch{return}}async function ft(){let[e,t,i,n,o]=await Promise.all([yi(),hi(),ki(),wi(),vi()]);return {python:e,poetry:t,pipx:i,go:n,rapidkitCore:o}}async function yi(){let e=i$1();for(let t of e)try{let{stdout:i}=await execa(t,["--version"],{timeout:3e3}),n=i.match(/Python (\d+\.\d+\.\d+)/);if(n){let o=n[1],[a,r]=o.split(".").map(Number);return a<3||a===3&&r<10?{status:"warn",message:`Python ${o} (requires 3.10+)`,details:`${t} found but version is below minimum requirement`}:{status:"ok",message:`Python ${o}`,details:`Using ${t}`}}}catch{continue}return {status:"error",message:"Python not found",details:"Install Python 3.10+ and ensure it's in PATH"}}async function hi(){try{let{stdout:e}=await execa("poetry",["--version"],{timeout:3e3}),t=e.match(/Poetry .*version ([\d.]+)/);return t?{status:"ok",message:`Poetry ${t[1]}`,details:"Available for dependency management"}:{status:"warn",message:"Poetry version unknown"}}catch{let e=i$1().map(t=>({cmd:t,args:t==="py"?["-3","-m","poetry","--version"]:["-m","poetry","--version"]}));for(let t of e)try{let{stdout:i}=await execa(t.cmd,t.args,{timeout:3e3,shell:c$2()}),n=i.match(/Poetry .*version ([\d.]+)/)||i.match(/([\d.]+)/);return {status:"ok",message:n?.[1]?`Poetry ${n[1]}`:"Poetry detected",details:`Available via ${t.cmd} ${t.args.join(" ")}`}}catch{continue}for(let t of Vn())try{if(!await c$1.pathExists(t))continue;let{stdout:i}=await execa(t,["--version"],{timeout:3e3,shell:c$2()}),n=i.match(/Poetry .*version ([\d.]+)/)||i.match(/([\d.]+)/);return {status:"ok",message:n?.[1]?`Poetry ${n[1]}`:"Poetry detected",details:`Available at ${t}`}}catch{continue}return {status:"warn",message:"Poetry not installed",details:"Optional: Install for better dependency management"}}}async function ki(){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=i$1();for(let t of e)try{let i=t==="py"?["-3","-m","pipx","--version"]:["-m","pipx","--version"],{stdout:n}=await execa(t,i,{timeout:3e3,shell:c$2()});return {status:"ok",message:`pipx ${n.trim()}`,details:`Available via ${t} ${i.join(" ")}`}}catch{continue}return {status:"warn",message:"pipx not installed",details:"Optional: Install for isolated Python tools"}}}async function wi(){try{let{stdout:e}=await execa("go",["version"],{timeout:3e3}),t=e.match(/go version go(\d+\.\d+(?:\.\d+)?)/);return t?{status:"ok",message:`Go ${t[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 vi(){let e=process.env.HOME||process.env.USERPROFILE||"",t=[],i=Jn(e);for(let{location:o,path:a}of i)try{if(await c$1.pathExists(a)){let{stdout:r,exitCode:l}=await execa(a,["--version"],{timeout:3e3,reject:false});if(l===0&&(r.includes("RapidKit Version")||r.includes("RapidKit"))){let d=r.match(/v?([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);d&&t.push({location:o,path:a,version:d[1]});}}}catch{continue}if(t.length>0){let o=t.filter(r=>r.location!=="Workspace (launcher)");if(o.length>0){let r=Ln(o),l=r[0].version,d=r.some(y=>y.location==="Workspace (.venv)"),u=r.some(y=>y.location.startsWith("Global (")),h=!d&&u?"Workspace (.venv): not installed (optional). For RapidKit module-enabled projects, run npx rapidkit workspace run init inside this workspace to install the local Python engine.":void 0;return {status:"ok",message:`RapidKit Core ${l}`,details:h,paths:r.map(y=>({location:y.location,path:y.path,version:y.version}))}}return {status:"ok",message:`RapidKit Core ${t[0].version}`,details:"Detected via workspace launcher"}}try{let{stdout:o,exitCode:a}=await execa("rapidkit",["--version"],{timeout:3e3,reject:false});if(a===0&&(o.includes("RapidKit Version")||o.includes("RapidKit"))){let r=o.match(/v?([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);if(r)return {status:"ok",message:`RapidKit Core ${r[1]}`,details:"Available via PATH"}}}catch{}try{let{stdout:o,exitCode:a}=await execa("poetry",["run","rapidkit","--version"],{timeout:3e3,reject:false});if(a===0&&(o.includes("RapidKit Version")||o.includes("RapidKit"))){let r=o.match(/v?([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);if(r)return {status:"ok",message:`RapidKit Core ${r[1]}`,details:"Available via Poetry"}}}catch{}let n=i$1();for(let o of n)try{let{stdout:a,exitCode:r}=await execa(o,["-c","import rapidkit_core; print(rapidkit_core.__version__)"],{timeout:3e3,reject:false});if(r===0&&a&&!a.includes("Traceback")&&!a.includes("ModuleNotFoundError")){let l=a.trim();if(l)return {status:"ok",message:`RapidKit Core ${l}`,details:`Available in ${o} environment`}}}catch{continue}return {status:"error",message:"RapidKit Core not installed",details:"Install with: pipx install rapidkit-core"}}async function U(e,t,i){let n=s.join(e,"Dockerfile");t.hasDocker=await c$1.pathExists(n);let o=s.join(e,"tests"),a=s.join(e,"test"),r=s.join(e,"src","test"),l$1=await c$1.pathExists(o)||await c$1.pathExists(a)||await c$1.pathExists(r),d=false;if(t.framework==="Go/Fiber"||t.framework==="Go/Gin")try{let u=[{dir:e,depth:0}],h=4,y=new Set([".git",".venv","node_modules","dist","build","vendor"]);for(;u.length>0&&!d;){let w=u.shift();if(!w)break;let g=[];try{g=await c$1.readdir(w.dir);}catch{continue}for(let f of g){let v=s.join(w.dir,f),x;try{x=await c$1.stat(v);}catch{continue}if(x.isFile()&&f.endsWith("_test.go")){d=true;break}x.isDirectory()&&w.depth<h&&!y.has(f)&&!f.startsWith(".")&&u.push({dir:v,depth:w.depth+1});}}}catch{}if(t.hasTests=l$1||d,t.runtimeFamily==="node"&&!t.hasTests&&(t.hasTests=await qt(e,i)),t.runtimeFamily==="node")t.hasCodeQuality=await Bt(e,i);else if(t.framework==="Go/Fiber"||t.framework==="Go/Gin"){let u=s.join(e,".golangci.yml"),h=s.join(e,".golangci.yaml"),y=s.join(e,"Makefile"),w=await c$1.pathExists(y)&&(await c$1.readFile(y,"utf8")).includes("golangci-lint");t.hasCodeQuality=await c$1.pathExists(u)||await c$1.pathExists(h)||w;}else if(t.runtimeFamily==="python"){let u=s.join(e,"ruff.toml"),h=s.join(e,"pyproject.toml");if(await c$1.pathExists(h))try{let y=await c$1.readFile(h,"utf8");t.hasCodeQuality=y.includes("[tool.ruff]")||await c$1.pathExists(u);}catch{t.hasCodeQuality=await c$1.pathExists(u);}}else if(t.framework==="Spring Boot"){let u=s.join(e,"pom.xml");if(await c$1.pathExists(u))try{let h=await c$1.readFile(u,"utf8");t.hasCodeQuality=h.includes("spotless")||h.includes("checkstyle")||h.includes("pmd")||h.includes("maven-enforcer-plugin");}catch{t.hasCodeQuality=false;}}try{if(t.runtimeFamily==="node"){let{stdout:u}=await execa("npm",["audit","--json"],{cwd:e,reject:false});if(u)try{let y=JSON.parse(u).metadata?.vulnerabilities;y&&(t.vulnerabilities=(y.high||0)+(y.critical||0)+(y.moderate||0));}catch{}}else if(t.runtimeFamily==="python"){let u=s.join(e,".venv"),h=l(u);if(await c$1.pathExists(h))try{let{stdout:y}=await execa(h,["-m","pip","list","--format=json"],{timeout:5e3,reject:false});if(y){JSON.parse(y);t.vulnerabilities=0;}}catch{}}}catch{}}function G(e,t){e.probes||(e.probes=[]);let i=rn(t,new Date().toISOString());e.probes.push(i),i.repairCapability&&(e.repairCapabilities||(e.repairCapabilities=[]),e.repairCapabilities.push(i.repairCapability),i.repairCapability.status==="available"&&i.repairCapability.canAutoFix&&i.repairCapability.command&&(e.fixCommands=e.fixCommands??[],e.fixCommands.includes(i.repairCapability.command)||e.fixCommands.push(i.repairCapability.command)));}async function bi(e,t){let i=t.runtimeFamily||"unknown";if(t.projectKind==="backend"||t.projectKind==="generic"){if(i==="node"){let o=await c$1.pathExists(s.join(e,"package-lock.json"))||await c$1.pathExists(s.join(e,"pnpm-lock.yaml"))||await c$1.pathExists(s.join(e,"yarn.lock"));G(t,{id:"adapter-node-lockfile-integrity",label:"Node adapter lockfile integrity",status:o?"pass":"warn",severity:"warn",scope:"project-scoped",reason:o?"Node lockfile detected for deterministic dependency restore.":"No Node lockfile detected (package-lock/yarn.lock/pnpm-lock.yaml).",recommendation:o?void 0:"Commit a lockfile for deterministic installs and CI parity."});let a=await c$1.pathExists(s.join(e,"src/main.ts"))||await c$1.pathExists(s.join(e,"src/main.js"))||await c$1.pathExists(s.join(e,"src/server.ts"))||await c$1.pathExists(s.join(e,"src/server.js"));G(t,{id:"adapter-node-boot-entrypoint",label:"Node adapter boot entrypoint",status:a?"pass":"warn",severity:"warn",scope:"project-scoped",reason:a?"Boot entrypoint markers detected for service startup path.":"No canonical Node boot entrypoint markers detected.",recommendation:a?void 0:"Define and document service bootstrap entrypoint (main/server)."});return}if(i==="python"){let o=await c$1.pathExists(s.join(e,"poetry.lock"))||await c$1.pathExists(s.join(e,"requirements.txt"))||await c$1.pathExists(s.join(e,"uv.lock"));G(t,{id:"adapter-python-lockfile-integrity",label:"Python adapter dependency integrity",status:o?"pass":"warn",severity:"warn",scope:"project-scoped",reason:o?"Python dependency contract file detected.":"No Python dependency contract file detected (poetry.lock/requirements/uv.lock).",recommendation:o?void 0:"Pin dependency contract for deterministic setup and reproducible CI."});let a=await c$1.pathExists(s.join(e,"app/main.py"))||await c$1.pathExists(s.join(e,"main.py"))||await c$1.pathExists(s.join(e,"manage.py"));G(t,{id:"adapter-python-boot-entrypoint",label:"Python adapter boot entrypoint",status:a?"pass":"warn",severity:"warn",scope:"project-scoped",reason:a?"Python application entrypoint markers detected.":"No Python application entrypoint markers detected.",recommendation:a?void 0:"Expose explicit app/main entrypoint for deterministic boot probes."});return}if(i==="java"){let o=await c$1.pathExists(s.join(e,"mvnw"))||await c$1.pathExists(s.join(e,"gradlew"));G(t,{id:"adapter-java-build-wrapper",label:"Java adapter build wrapper",status:o?"pass":"warn",severity:"warn",scope:"project-scoped",reason:o?"Build wrapper detected (mvnw/gradlew).":"No Java build wrapper detected.",recommendation:o?void 0:"Commit mvnw or gradlew for reproducible enterprise pipelines."});return}if(i==="go"){let o=await c$1.pathExists(s.join(e,"go.sum"));G(t,{id:"adapter-go-module-integrity",label:"Go adapter module integrity",status:o?"pass":"warn",severity:"warn",scope:"project-scoped",reason:o?"go.sum detected for deterministic module verification.":"go.sum missing; module integrity baseline is incomplete.",recommendation:o?void 0:"Generate and commit go.sum in the repository baseline."});}}}async function ji(e,t){let i=[s.join(e,".rapidkit","doctor.adapters.json"),s.join(e,"doctor.adapters.json")];for(let n of i)if(await c$1.pathExists(n))try{let o=await c$1.readJSON(n),a=Array.isArray(o?.checks)?o.checks:[];for(let r=0;r<a.length;r+=1){let l=a[r]||{},d=Array.isArray(l.runtimes)?l.runtimes:[];if(d.length>0&&!d.includes(t.runtimeFamily||"unknown"))continue;let u=typeof l.id=="string"&&l.id.trim().length>0?l.id.trim():`adapter-check-${r+1}`,h=typeof l.label=="string"&&l.label.trim().length>0?l.label.trim():u,y=l.severity||"warn",w=Array.isArray(l.anyOfPaths)?l.anyOfPaths.filter(Boolean):[],g=Array.isArray(l.allOfPaths)?l.allOfPaths.filter(Boolean):[],f=w.length===0;for(let k of w)if(await c$1.pathExists(s.join(e,k))){f=true;break}let v=true;for(let k of g)if(!await c$1.pathExists(s.join(e,k))){v=false;break}let x=f&&v;G(t,{id:u,label:h,status:x?"pass":y==="error"?"fail":"warn",severity:y,scope:"project-scoped",reason:x?l.passReason||"Custom adapter contract satisfied.":l.failReason||`Custom adapter check failed from ${s.basename(n)}.`,recommendation:l.recommendation});}}catch{G(t,{id:"custom-adapter-config",label:"Custom doctor adapter configuration",status:"warn",severity:"warn",scope:"project-scoped",reason:`Failed to parse ${s.basename(n)}.`,recommendation:"Fix JSON syntax in doctor.adapters.json to re-enable adapter checks."});}}async function z(e,t){if(!(t.projectKind==="backend"||t.projectKind==="generic"))return;let n=s.join(e,".env"),o=s.join(e,".env.example"),a=await c$1.pathExists(n)||await c$1.pathExists(o)||await c$1.pathExists(s.join(e,"config"));G(t,{id:"config-surface",label:"Configuration contract surface",status:a?"pass":"warn",severity:"warn",scope:"project-scoped",reason:a?"Configuration artifacts detected (.env/.env.example/config).":"No explicit configuration contract artifacts detected.",recommendation:a?void 0:"Add .env.example or explicit config contract documentation for deterministic setup."});let r={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"]},l=t.runtimeFamily||"unknown",d=r[l]||r.unknown,u=false;for(let w of d)if(await c$1.pathExists(s.join(e,w))){u=true;break}G(t,{id:"migration-surface",label:"Migration/readiness surface",status:u?"pass":"warn",severity:"warn",scope:"project-scoped",reason:u?"Migration or schema evolution markers detected.":"No migration markers detected for this backend runtime.",recommendation:u?void 0:"Add migration tooling baseline (migrations dir or runtime-native migration config)."});let h=["src/health","src/healthcheck","src/main/resources/application.yml","src/main/resources/application.properties","app/health.py","routes/health.ts","routes/health.js"],y=false;for(let w of h)if(await c$1.pathExists(s.join(e,w))){y=true;break}G(t,{id:"runtime-health-surface",label:"Runtime health probe surface",status:y?"pass":"warn",severity:"warn",scope:"project-scoped",reason:y?"Health endpoint/config markers detected.":"No explicit runtime health endpoint markers detected.",recommendation:y?void 0:"Expose a deterministic health endpoint and keep it covered in verify pack."}),await bi(e,t);}async function xi(e,t,i,n){let o=await Kt({projectPath:e,detection:n,packageJsonData:i});for(let a of o)G(t,a);}async function Y(e,t,i){let n=await Gt({projectPath:e,runtimeFamily:t.runtimeFamily,projectKind:t.projectKind,packageJsonData:i,hasTests:t.hasTests,vulnerabilities:t.vulnerabilities});for(let o of n)G(t,o);}async function Q(e,t){let i=[s.join(e,".rapidkit","doctor.probes.json"),s.join(e,"doctor.probes.json")];for(let n of i)if(await c$1.pathExists(n))try{let o=await c$1.readJSON(n),a=Array.isArray(o?.probes)?o.probes:[];for(let r=0;r<a.length;r+=1){let l=a[r]||{},d=typeof l.id=="string"&&l.id.trim().length>0?l.id.trim():`custom-probe-${r+1}`,u=typeof l.label=="string"&&l.label.trim().length>0?l.label.trim():d,h=l.severity||"warn",y=Array.isArray(l.anyOfPaths)?l.anyOfPaths.filter(Boolean):[],w=Array.isArray(l.allOfPaths)?l.allOfPaths.filter(Boolean):[],g=y.length===0;for(let x of y)if(await c$1.pathExists(s.join(e,x))){g=true;break}let f=true;for(let x of w)if(!await c$1.pathExists(s.join(e,x))){f=false;break}let v=g&&f;G(t,{id:d,label:u,status:v?"pass":h==="error"?"fail":"warn",severity:h,scope:"project-scoped",reason:v?"Custom probe contract satisfied.":`Custom probe failed from ${s.basename(n)}.`,recommendation:l.recommendation});}}catch{G(t,{id:"custom-probe-config",label:"Custom doctor probe configuration",status:"warn",severity:"warn",scope:"project-scoped",reason:`Failed to parse ${s.basename(n)}.`,recommendation:"Fix JSON syntax in doctor.probes.json to re-enable custom probes."});}await ji(e,t);}async function Be(e,t={}){let n={name:s.basename(e),path:e,venvActive:false,depsInstalled:false,coreInstalled:false,issues:[],fixCommands:[]},o=t.allowNonRapidkit===true,a=s.join(e,".rapidkit");if(!await c$1.pathExists(a)){if(!o)return n.issues.push("Not a valid RapidKit project (missing .rapidkit directory)"),n;n.issues.push("Not a RapidKit-managed project (running generic backend diagnostics)");}try{let b=s.join(e,"registry.json");if(await c$1.pathExists(b)){let P=await c$1.readJson(b);P.installed_modules&&(n.stats={modules:P.installed_modules.length});}}catch{}try{let{auditProjectModulePaths:b}=await import('./module-layout-NZ43RSC5.js'),P=await b(e);if(P.issues.length>0){for(let S of P.issues)n.issues.push(`${S.message} (${S.slug})`);n.fixCommands=n.fixCommands??[],n.fixCommands.push("npx rapidkit workspace contract verify --strict --json"),n.fixCommands.push("npx rapidkit add module <slug> # reinstall via Core-backed module install");}}catch{}let r=null;try{let b=s.join(a,"project.json");if(await c$1.pathExists(b)){r=await c$1.readJson(b);let P=r?.kit_name||r?.kit;P&&(n.kit=P);}}catch{}try{let b=s.join(e,".git");if(await c$1.pathExists(b)){let{stdout:P}=await execa("git",["log","-1","--format=%cr"],{cwd:e,reject:false});P&&(n.lastModified=P.trim());}else {let P=await c$1.stat(e),H=Date.now()-P.mtime.getTime(),F=Math.floor(H/(1e3*60*60*24));n.lastModified=F===0?"today":`${F} day${F>1?"s":""} ago`;}}catch{}let l$1=s.join(e,"package.json"),d$1=s.join(e,"pyproject.toml"),u=s.join(e,"requirements.txt"),h=s.join(e,"go.mod"),y=s.join(e,"pom.xml"),w=s.join(e,"build.sbt"),g=s.join(e,"Cargo.toml"),f=s.join(e,"mix.exs"),v=s.join(e,"deps.edn"),x=s.join(e,"project.clj"),k=s.join(e,"deno.json"),R=s.join(e,"deno.jsonc"),I=s.join(e,"bun.lockb"),T=s.join(e,"bun.lock"),m=s.join(e,"composer.json"),D=s.join(e,"Gemfile"),C=await c$1.pathExists(l$1),ee=await c$1.pathExists(d$1)||await c$1.pathExists(u),j=await c$1.pathExists(m),te=await c$1.pathExists(D),O=await c$1.pathExists(g),re=await c$1.pathExists(f),Fe=await c$1.pathExists(v)||await c$1.pathExists(x),Ne=await c$1.pathExists(w),Ie=await c$1.pathExists(k)||await c$1.pathExists(R),W=r?.runtime==="dotnet";try{W=W||await Ut(e,".csproj",3)||await Ut(e,".sln",2);}catch{W=r?.runtime==="dotnet";}let Pe=await c$1.pathExists(h)||r?.runtime==="go"||typeof r?.kit_name=="string"&&(r.kit_name.startsWith("gofiber")||r.kit_name.startsWith("gogin")),le=C&&(await c$1.pathExists(I)||await c$1.pathExists(T)||typeof r?.packageManager=="string"&&(r?.packageManager).toLowerCase().startsWith("bun@"));if(Pe){Z(n,i(e,r??null)),n.isGoProject=true,n.venvActive=true,n.coreInstalled=false;try{await execa("go",["version"],{timeout:3e3});}catch{n.issues.push("Go toolchain not found \u2014 install from https://go.dev/dl/"),n.fixCommands?.push("https://go.dev/dl/");}let b=s.join(e,"go.sum");return await c$1.pathExists(b)?n.depsInstalled=true:(n.depsInstalled=false,n.issues.push("Go dependencies not downloaded (go.sum missing)"),n.fixCommands?.push(V(e,"go mod tidy"))),await U(e,n),await Y(e,n),await z(e,n),await Q(e,n),n}if(await c$1.pathExists(y)||r?.runtime==="java"||typeof r?.kit_name=="string"&&r.kit_name.startsWith("springboot")){Z(n,i(e,r??null)),n.venvActive=true,n.coreInstalled=false;let b=await c$1.pathExists(y),P=await c$1.pathExists(s.join(e,"build.gradle"))||await c$1.pathExists(s.join(e,"build.gradle.kts")),S=await c$1.pathExists(s.join(e,"mvnw"))||await c$1.pathExists(s.join(e,"mvnw.cmd")),H=await c$1.pathExists(s.join(e,"gradlew"))||await c$1.pathExists(s.join(e,"gradlew.bat"));try{await execa("java",["-version"],{timeout:3e3,reject:false});}catch{n.issues.push("Java runtime not found \u2014 install JDK 21+ and ensure java is on PATH"),n.fixCommands?.push("https://adoptium.net/");}if(b){if(!S)try{await execa("mvn",["-version"],{timeout:3e3,reject:false});}catch{n.issues.push("Maven not found \u2014 install Maven 3.9+ or add Maven Wrapper"),n.fixCommands?.push("https://maven.apache.org/install.html");}}else if(P&&!H)try{await execa("gradle",["--version"],{timeout:3e3,reject:false});}catch{n.issues.push("Gradle not found \u2014 install Gradle 8+ or add Gradle Wrapper"),n.fixCommands?.push("https://gradle.org/install/");}let F=s.join(e,"target"),A=s.join(e,"build","libs"),J=s.join(e,".rapidkit","cache","java","m2"),$=s.join(e,".rapidkit","cache","java","gradle");n.depsInstalled=await c$1.pathExists(F)||await c$1.pathExists(A)||await c$1.pathExists(J)||await c$1.pathExists($),n.depsInstalled||(n.issues.push("Java dependencies are not warmed or built yet"),n.fixCommands?.push(V(e,"rapidkit init")));let B=s.join(e,".env");if(n.hasEnvFile=await c$1.pathExists(B),!n.hasEnvFile){let de=s.join(e,".env.example");await c$1.pathExists(de)&&(n.issues.push("Environment file missing (found .env.example)"),n.fixCommands?.push(ae(e)));}let ie=s.join(e,"src","main","resources","application.yml");if(await c$1.pathExists(ie))try{let de=await c$1.readFile(ie,"utf-8");/include:\s*[^\n]*health/i.test(de)||/management:\s*[\s\S]*endpoint:\s*[\s\S]*health:/i.test(de)||(n.issues.push("Actuator health endpoint exposure is not clearly configured in application.yml"),n.fixCommands?.push(V(e,"Ensure management.endpoints.web.exposure.include contains health in src/main/resources/application.yml")));}catch{n.issues.push("Unable to read application.yml for Spring Actuator health checks");}return await U(e,n),await Y(e,n),await z(e,n),await Q(e,n),n}if(O){Z(n,i(e,r??null)),n.venvActive=true,n.coreInstalled=false;let b=s.join(e,"Cargo.lock"),P=s.join(e,"target");n.depsInstalled=await c$1.pathExists(b)||await c$1.pathExists(P),n.depsInstalled||(n.issues.push("Rust dependencies are not resolved yet (Cargo.lock/target missing)"),n.fixCommands?.push(V(e,"cargo fetch")));let S=s.join(e,".env");if(n.hasEnvFile=await c$1.pathExists(S),!n.hasEnvFile){let H=s.join(e,".env.example");await c$1.pathExists(H)&&(n.issues.push("Environment file missing (found .env.example)"),n.fixCommands?.push(ae(e)));}return await U(e,n),await Y(e,n),await z(e,n),await Q(e,n),n}if(re){Z(n,i(e,r??null)),n.venvActive=true,n.coreInstalled=false;let b=s.join(e,"mix.lock"),P=s.join(e,"deps");n.depsInstalled=await c$1.pathExists(b)||await c$1.pathExists(P),n.depsInstalled||(n.issues.push("Elixir dependencies not installed (mix.lock/deps missing)"),n.fixCommands?.push(V(e,"mix deps.get")));let S=s.join(e,".env");if(n.hasEnvFile=await c$1.pathExists(S),!n.hasEnvFile){let H=s.join(e,".env.example");await c$1.pathExists(H)&&(n.issues.push("Environment file missing (found .env.example)"),n.fixCommands?.push(ae(e)));}return await U(e,n),await Y(e,n),await z(e,n),await Q(e,n),n}if(Fe){Z(n,i(e,r??null)),n.venvActive=true,n.coreInstalled=false;let b=s.join(e,".cpcache"),P=s.join(e,"target"),S=await c$1.pathExists(v)||await c$1.pathExists(x);return n.depsInstalled=await c$1.pathExists(b)||await c$1.pathExists(P)||S,n.depsInstalled||(n.issues.push("Clojure dependency cache not initialized"),n.fixCommands?.push(V(e,"clojure -P"))),await U(e,n),await Y(e,n),await z(e,n),await Q(e,n),n}if(Ne){Z(n,i(e,r??null)),n.venvActive=true,n.coreInstalled=false;let b=s.join(e,"target");n.depsInstalled=await c$1.pathExists(b),n.depsInstalled||(n.issues.push("Scala build artifacts missing (run dependency/build warmup)"),n.fixCommands?.push(V(e,"sbt compile")));let P=s.join(e,".env");if(n.hasEnvFile=await c$1.pathExists(P),!n.hasEnvFile){let S=s.join(e,".env.example");await c$1.pathExists(S)&&(n.issues.push("Environment file missing (found .env.example)"),n.fixCommands?.push(ae(e)));}return await U(e,n),await Y(e,n),await z(e,n),await Q(e,n),n}if(Ie){Z(n,i(e,r??null)),n.venvActive=true,n.coreInstalled=false,n.depsInstalled=true;let b=s.join(e,".env");if(n.hasEnvFile=await c$1.pathExists(b),!n.hasEnvFile){let P=s.join(e,".env.example");await c$1.pathExists(P)&&(n.issues.push("Environment file missing (found .env.example)"),n.fixCommands?.push(ae(e)));}return await U(e,n),await Y(e,n),await z(e,n),await Q(e,n),n}if(C){let b=null;try{b=await c$1.readJson(l$1);}catch{b=null;}let P={...b?.dependencies??{},...b?.devDependencies??{}},S=b?.scripts??{},H=typeof r?.kit_name=="string"?r.kit_name.toLowerCase():typeof r?.kit=="string"?r.kit.toLowerCase():"",F=d(e,r),A=li({dependencies:P,scripts:S,kitName:H});if(le)Te(n,"Bun","high");else {let $=i(e,r??null);$.key==="nestjs"||$.key==="express"||$.key==="fastify"||$.key==="koa"?Z(n,$):F.key!=="unknown"?ci(n,F):$.key!=="unknown"&&$.key!=="node"?Z(n,$):Te(n,A.framework,A.confidence);}n.venvActive=true;let J=s.join(e,"node_modules");if(await c$1.pathExists(J))try{let B=(await c$1.readdir(J)).filter(ie=>!ie.startsWith(".")&&!ie.startsWith("_"));n.depsInstalled=B.length>0;}catch{n.depsInstalled=false;}if(n.depsInstalled||(n.issues.push("Dependencies not installed (node_modules empty or missing)"),n.fixCommands?.push(V(e,le?"bun install":"rapidkit init"))),n.coreInstalled=false,n.projectKind==="frontend"){let $=[".env",".env.local",".env.development",".env.development.local",".env.production",".env.production.local"];if((await Promise.all($.map(ie=>c$1.pathExists(s.join(e,ie))))).some(Boolean))n.hasEnvFile=true;else {let ie=s.join(e,".env.example");await c$1.pathExists(ie)&&(n.hasEnvFile=false,n.issues.push("Environment file missing (found .env.example)"),n.fixCommands?.push(ae(e)));}}else {let $=s.join(e,".env");if(n.hasEnvFile=await c$1.pathExists($),!n.hasEnvFile){let B=s.join(e,".env.example");await c$1.pathExists(B)&&(n.issues.push("Environment file missing (found .env.example)"),n.fixCommands?.push(ae(e)));}}if(n.projectKind==="frontend")n.modulesHealthy=await tt(e),n.missingModules=[];else {let $=s.join(e,"src");if(n.modulesHealthy=true,n.missingModules=[],await c$1.pathExists($))try{let B=await c$1.readdir($);n.modulesHealthy=B.length>0;}catch{n.modulesHealthy=false;}}return await U(e,n,b),await Y(e,n,b),n.projectKind==="frontend"?await xi(e,n,b,F.key!=="unknown"?F:d(e,r)):await z(e,n),await Q(e,n),n}if(ee){let b=await di(e,r);Te(n,b.framework,b.confidence);let P=s.join(e,".venv");if(await c$1.pathExists(P)){n.venvActive=true;let A=l(P);if(await c$1.pathExists(A)){try{let{stdout:B}=await execa(A,["-c","import rapidkit_core; print(rapidkit_core.__version__)"],{timeout:2e3});n.coreInstalled=true,n.coreVersion=B.trim();}catch{n.coreInstalled=false;}let J="fastapi";n.framework==="Django"?J="django":n.framework==="Flask"?J="flask":n.framework==="Python"&&(J="");let $=true;if(J)try{await execa(A,["-c",`import ${J}`],{timeout:2e3}),n.depsInstalled=true,$=false;}catch{$=true;}if($)try{let B=s.join(P,"lib");if(await c$1.pathExists(B)){let de=(await c$1.readdir(B)).find(Ce=>Ce.startsWith("python"));if(de){let Ce=s.join(B,de,"site-packages");if(await c$1.pathExists(Ce)){let gn=(await c$1.readdir(Ce)).filter(Ge=>!Ge.startsWith("_")&&!Ge.includes("dist-info")&&!["pip","setuptools","wheel","pkg_resources"].includes(Ge));n.depsInstalled=gn.length>0;}}}n.depsInstalled||(n.issues.push("Dependencies not installed"),n.fixCommands?.push(Jt(e)));}catch{n.issues.push("Could not verify dependency installation");}}else n.issues.push("Virtual environment exists but Python executable not found");}else n.issues.push("Virtual environment not created"),n.fixCommands?.push(Jt(e));let S=s.join(e,".env");if(n.hasEnvFile=await c$1.pathExists(S),!n.hasEnvFile){let A=s.join(e,".env.example");await c$1.pathExists(A)&&(n.issues.push("Environment file missing (found .env.example)"),n.fixCommands?.push(ae(e)));}let H=s.join(e,"src"),F=s.join(e,"modules");if(n.modulesHealthy=true,n.missingModules=[],await c$1.pathExists(H)){let A=s.join(H,"__init__.py");await c$1.pathExists(A)||(n.modulesHealthy=false,n.missingModules.push("src/__init__.py"));}if(await c$1.pathExists(F))try{let A=await Pi(F);for(let J of A){let $=s.join(F,J,"__init__.py");await c$1.pathExists($)||(n.modulesHealthy=false,n.missingModules.push(`modules/${J}/__init__.py`));}}catch{}return !n.modulesHealthy&&n.missingModules.length>0&&n.issues.push(`Missing module init files: ${n.missingModules.join(", ")}`),await U(e,n),await Y(e,n),await z(e,n),await Q(e,n),n}if(j){Z(n,i(e,r??null)),n.venvActive=true,n.coreInstalled=false;let b=s.join(e,"vendor");n.depsInstalled=await c$1.pathExists(b),n.depsInstalled||(n.issues.push("PHP dependencies not installed (vendor missing)"),n.fixCommands?.push(V(e,"composer install")));let P=s.join(e,".env");if(n.hasEnvFile=await c$1.pathExists(P),!n.hasEnvFile){let S=s.join(e,".env.example");await c$1.pathExists(S)&&(n.issues.push("Environment file missing (found .env.example)"),n.fixCommands?.push(ae(e)));}return await U(e,n),await Y(e,n),await z(e,n),await Q(e,n),n}if(te){Z(n,i(e,r??null)),n.venvActive=true,n.coreInstalled=false;let b=await c$1.pathExists(s.join(e,"Gemfile.lock")),P=await c$1.pathExists(s.join(e,"vendor","bundle"));n.depsInstalled=b||P,n.depsInstalled||(n.issues.push("Ruby dependencies not installed (Gemfile.lock/vendor missing)"),n.fixCommands?.push(V(e,"bundle install")));let S=s.join(e,".env");return n.hasEnvFile=await c$1.pathExists(S),await U(e,n),await Y(e,n),await z(e,n),await Q(e,n),n}if(W){Z(n,i(e,r??null)),n.venvActive=true,n.coreInstalled=false;let b=s.join(e,"obj"),P=s.join(e,"src","obj"),S=s.join(e,"packages.lock.json");n.depsInstalled=await c$1.pathExists(b)||await c$1.pathExists(P)||await c$1.pathExists(S),n.depsInstalled||(n.issues.push(".NET restore/build artifacts not found"),n.fixCommands?.push(V(e,"dotnet restore")));let H=s.join(e,".env");return n.hasEnvFile=await c$1.pathExists(H),await U(e,n),await Y(e,n),await z(e,n),await Q(e,n),n}return Te(n,"Unknown","low"),n.issues.push("Unknown project type (no recognized runtime marker files)"),await U(e,n),await Y(e,n),await z(e,n),await Q(e,n),n}async function Pi(e){try{return (await c$1.readdir(e,{withFileTypes:true})).filter(i=>i.isDirectory()).map(i=>i.name)}catch{try{let t=await c$1.readdir(e),i=[];for(let n of t)try{(await c$1.stat(s.join(e,n))).isDirectory()&&i.push(n);}catch{continue}return i}catch{return []}}}async function Ut(e,t,i){let n=[{dir:e,depth:0}],o=new Set([".git",".rapidkit","node_modules","bin","obj","target"]);for(;n.length>0;){let a=n.shift();if(!a||a.depth>i)continue;let r;try{r=await c$1.readdir(a.dir,{withFileTypes:true});}catch{continue}for(let l of r){if(l.isFile()&&l.name.toLowerCase().endsWith(t.toLowerCase()))return true;l.isDirectory()&&!o.has(l.name)&&n.push({dir:s.join(a.dir,l.name),depth:a.depth+1});}}return false}async function Se(e){let t=s.join(e,".rapidkit");if(!await c$1.pathExists(t))return false;let i=["project.json","context.json","file-hashes.json"];for(let n of i)if(await c$1.pathExists(s.join(t,n)))return true;return false}function Ci(e,t){if(t.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 Ri(e,t,i){let n=new Set,o=[{dir:e,depth:0}];for(;o.length>0;){let a=o.shift();if(!a)break;try{let r=await c$1.readdir(a.dir);for(let l of r){if(Ci(l,i))continue;let d=s.join(a.dir,l),u;try{u=await c$1.stat(d);}catch{continue}if(u.isDirectory()){if(await Se(d)){n.add(d);continue}a.depth<t&&o.push({dir:d,depth:a.depth+1});}}}catch{continue}}return Array.from(n)}async function $e(e){let t=s.resolve(e),i=s.parse(t).root;for(;;){if(await Si(t))return t;if(t===i)break;t=s.dirname(t);}return null}async function Di(e){let t=s.resolve(e),i=await $e(t),n=i??s.parse(t).root;for(;;){if(await Se(t)||await Ei(t)&&(!i||t!==i))return t;if(t===n)break;t=s.dirname(t);}return null}function zt(e){let t=s.resolve(e);return process.platform==="darwin"?t.replace(/^\/private(?=\/var\/)/,""):t}async function Ei(e){let t=["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 t)if(await c$1.pathExists(s.join(e,i)))return true;return false}async function Si(e){let t=[s.join(e,".rapidkit-workspace"),s.join(e,".rapidkit","workspace-marker.json"),s.join(e,".rapidkit","config.json")];return Promise.all(t.map(i=>c$1.pathExists(i))).then(i=>i.some(Boolean))}function gt(e,t){let i=0,n=0,o=0;return e.forEach(r=>{r.status==="ok"?i++:r.status==="warn"?n++:r.status==="error"&&o++;}),t.forEach(r=>{let l=fe(r),d=r.isGoProject?r.issues.length===0&&r.depsInstalled:r.issues.length===0&&r.venvActive&&r.depsInstalled;if(r.issues.length>0||l>0||!d){n++;return}i++;}),{total:i+n+o,passed:i,warnings:n,errors:o}}function pn(e,t,i={}){let n=[];for(let a of e)n.push({id:a.id,label:a.label,status:a.result.status,scope:"host-system",policyRuleId:"system-status-derived",reason:a.result.details||a.result.message});let o=[...t].sort((a,r)=>{let l=`${a.path||""}|${a.name||""}`.toLowerCase(),d=`${r.path||""}|${r.name||""}`.toLowerCase();return l.localeCompare(d)});for(let a of o){let r=a.issues.length>0,l=fe(a),d=r||l>0?"warn":"ok",u=r?`${a.issues.length} blocking issue(s)`:l>0?`${l} advisory warning(s)`:"Project checks passed";n.push({id:`project:${a.name}`,label:`Project ${a.name}`,status:d,scope:"project-scoped",policyRuleId:r?"project-blocking-issues":l>0?"project-advisory-warnings":"project-checks-passed",reason:u});}if(i.includeWorkspaceAggregateRules){let a=t.reduce((d,u)=>d+u.issues.length,0),r=ut(t),l=e.filter(d=>d.result.status==="error").length;n.push({id:"workspace:projects-discovered",label:"Workspace projects discovered",status:t.length>0?"ok":"warn",scope:"workspace-aggregate",policyRuleId:"workspace-project-discovery",reason:t.length>0?`${t.length} project(s) discovered for workspace analysis.`:"No projects discovered for workspace analysis."}),n.push({id:"workspace:system-error-gate",label:"Workspace system error gate",status:l>0?"error":"ok",scope:"workspace-aggregate",policyRuleId:"workspace-system-error-gate",reason:l>0?`${l} system requirement gate(s) failed.`:"All system requirement gates passed."}),n.push({id:"workspace:blocking-issues-gate",label:"Workspace blocking issues gate",status:a>0?"warn":"ok",scope:"workspace-aggregate",policyRuleId:"workspace-blocking-issues-gate",reason:a>0?`${a} blocking project issue(s) detected.`:"No blocking project issues detected."}),n.push({id:"workspace:advisory-warnings-gate",label:"Workspace advisory warnings gate",status:r>0?"warn":"ok",scope:"workspace-aggregate",policyRuleId:"workspace-advisory-warning-gate",reason:r>0?`${r} advisory warning(s) detected.`:"No advisory warnings detected."});}return n}async function at(e,t=true,i=_e({})){let n=s.basename(e);try{let g=s.join(e,".rapidkit-workspace");await c$1.pathExists(g)&&(n=(await c$1.readJSON(g)).name||n);}catch{try{let g=s.join(e,".rapidkit","config.json");n=(await c$1.readJSON(g)).workspace_name||n;}catch{}}let[o,a]=await Promise.all([ft(),pi(e)]),r={workspacePath:e,workspaceName:n,python:o.python,poetry:o.poetry,pipx:o.pipx,go:o.go,rapidkitCore:o.rapidkitCore,projects:[],policyProfile:i};f.debug(`Workspace scan found ${a.length} project(s)`);let l=await ui(e,a),d=s.join(e,".rapidkit","reports","doctor-workspace-cache.json"),u=t?await mi(d,l):null;if(u){r.projects=u.projects;for(let g of r.projects)Vt(g,u.generatedAt),lt(g,g.path);r.projectScanCached=true,f.debug(`Workspace project health cache hit: ${d}`);}else try{let g=new Date().toISOString(),f$1=await Promise.all(a.map(v=>Be(v,{allowNonRapidkit:true})));for(let v of f$1)Vt(v,g),lt(v,v.path);r.projects=f$1,r.projectScanCached=false,await fi(d,{schemaVersion:nn,signature:l,generatedAt:g,projects:f$1}),f.debug(`Workspace project health cache refreshed: ${d}`);}catch(g){f.debug(`Failed to scan workspace projects: ${g}`);}r.projectScanSignature=l,r.projectScanCachePath=d;let h=[r.python,r.poetry,r.pipx,r.go,r.rapidkitCore];if(r.healthScore=gt(h,r.projects),r.scoreBreakdown=pn([{id:"system-python",label:"Python",result:r.python},{id:"system-poetry",label:"Poetry",result:r.poetry},{id:"system-pipx",label:"pipx",result:r.pipx},{id:"system-go",label:"Go",result:r.go},{id:"system-rapidkit-core",label:"RapidKit Core",result:r.rapidkitCore}],r.projects,{includeWorkspaceAggregateRules:true}),r.scopeProvenance=ln(r.scoreBreakdown),r.evidenceFreshness=on(r.projects,new Date().toISOString()),r.rapidkitCore.status==="ok"){let g=r.rapidkitCore.message.match(/([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);g&&(r.coreVersion=g[1]);}let y=s.join(e,".rapidkit","reports","doctor-last-run.json"),w=await sn(y,"workspace");return r.driftDelta=ni(w,r),r.evidencePath=await gi(e,r,u?d:null),r}function Yt(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,repairCapabilities:e.repairCapabilities,commandCapabilities:e.commandCapabilities}}async function $i(e$1,t){let i=e$1||t.projectPath,n=s.join(i,".rapidkit","reports","doctor-project-last-run.json");try{await c$1.ensureDir(s.dirname(n));let o=t.project.issues.filter(a=>typeof a=="string"&&a.trim().length>0).slice(0,12);if(await c$1.writeJSON(n,f$1({schemaVersion:b$3,evidenceType:"project",contract:we(),policyProfile:t.policyProfile,workspacePath:e$1||null,projectPath:t.projectPath,projectName:t.projectName,healthScore:t.healthScore,evidenceFreshness:t.evidenceFreshness,system:{python:t.python,poetry:t.poetry,pipx:t.pipx,go:t.go,rapidkitCore:t.rapidkitCore},project:t.project,driftDelta:t.driftDelta,summary:{scopeProvenance:t.scopeProvenance},scoreBreakdown:t.scoreBreakdown??[]},{commandId:"projectDoctor",exitCode:je(t.healthScore,{profile:t.policyProfile?.name}),generatedAt:new Date().toISOString(),blockers:o,runId:e()}),{spaces:2}),e$1&&s.resolve(e$1)!==s.resolve(t.projectPath)){let a=s.join(t.projectPath,".rapidkit","reports","doctor-project-last-run.json");await c$1.ensureDir(s.dirname(a)),await c$1.copy(n,a,{overwrite:true});}return n}catch{return}}async function dt(e,t,i=[]){let n=s.join(e,".rapidkit","reports","doctor-remediation-plan-last-run.json");try{await c$1.ensureDir(s.dirname(n)),await c$1.writeJSON(n,t,{spaces:2});for(let o of i){if(s.resolve(o)===s.resolve(e))continue;let a=s.join(o,".rapidkit","reports","doctor-remediation-plan-last-run.json");await c$1.ensureDir(s.dirname(a)),await c$1.copy(n,a,{overwrite:true});}return n}catch{return}}async function ve(e,t,i=[]){let n=s.join(e,".rapidkit","reports","doctor-fix-result-last-run.json");try{await c$1.ensureDir(s.dirname(n)),await c$1.writeJSON(n,t,{spaces:2});for(let o of i){if(s.resolve(o)===s.resolve(e))continue;let a=s.join(o,".rapidkit","reports","doctor-fix-result-last-run.json");await c$1.ensureDir(s.dirname(a)),await c$1.copy(n,a,{overwrite:true});}return n}catch{return}}async function be(e,t,i){try{await j(e,g(t,i));}catch{}}async function Qt(e,t=_e({})){let i=await $e(e),n=await ft(),o=await Be(e,{allowNonRapidkit:true});lt(o,e);let a=gt([n.python,n.poetry,n.pipx,n.go,n.rapidkitCore],[o]),r={workspacePath:i||void 0,projectPath:e,projectName:s.basename(e),python:n.python,poetry:n.poetry,pipx:n.pipx,go:n.go,rapidkitCore:n.rapidkitCore,project:o,healthScore:a,policyProfile:t};r.scoreBreakdown=pn([{id:"system-python",label:"Python",result:r.python},{id:"system-poetry",label:"Poetry",result:r.poetry},{id:"system-pipx",label:"pipx",result:r.pipx},{id:"system-go",label:"Go",result:r.go},{id:"system-rapidkit-core",label:"RapidKit Core",result:r.rapidkitCore}],[r.project]),r.scopeProvenance=ln(r.scoreBreakdown),r.evidenceFreshness=on([r.project],new Date().toISOString());let l=i||e,d=s.join(l,".rapidkit","reports","doctor-project-last-run.json"),u=await sn(d,"project");return r.driftDelta=ii(u,r),r.evidencePath=await $i(i||void 0,r),r}function K(e,t){let i=e.status==="ok"?"\u2705":e.status==="warn"?"\u26A0\uFE0F":"\u274C",n=e.status==="ok"?p.green:e.status==="warn"?p.yellow:p.red;console.log(`${i} ${p.bold(t)}: ${n(e.message)}`),e.paths&&e.paths.length>0&&e.paths.forEach(o=>{let a=o.version?p.cyan(` -> ${o.version}`):"";console.log(` ${p.cyan("\u2022")} ${p.gray(o.location)}: ${p.dim(o.path)}${a}`);}),e.details&&console.log(` ${p.gray(e.details)}`);}function Xt(e){let t=e.issues.length>0,i=t?"\u26A0\uFE0F":"\u2705",n=t?p.yellow:p.green;if(console.log(`
|
|
7
7
|
${i} ${p.bold("Project")}: ${n(e.name)}`),e.framework){let r=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(` ${r} Framework: ${p.cyan(e.framework)}${e.kit?p.gray(` (${e.kit})`):""}`);let l=[];e.runtimeFamily&&l.push(`runtime: ${e.runtimeFamily}`),e.projectKind&&l.push(`kind: ${e.projectKind}`),e.supportTier&&l.push(`support: ${e.supportTier}`),e.frameworkConfidence&&l.push(`confidence: ${e.frameworkConfidence}`),l.length>0&&console.log(` ${p.dim("\u21B3")} ${p.gray(l.join(" \u2022 "))}`);}if(console.log(` ${p.gray(`Path: ${e.path}`)}`),e.runtimeFamily==="python"&&(e.venvActive?console.log(` \u2705 Virtual environment: ${p.green("Active")}`):console.log(` \u274C Virtual environment: ${p.red("Not found")}`),e.coreInstalled?console.log(` ${p.dim("\u2139")} RapidKit Core: ${p.gray(e.coreVersion||"In venv")} ${p.dim("(optional)")}`):console.log(` ${p.dim("\u2139")} RapidKit Core: ${p.gray("Using global installation")} ${p.dim("(recommended)")}`)),e.depsInstalled?console.log(` \u2705 Dependencies: ${p.green("Installed")}`):console.log(` \u26A0\uFE0F Dependencies: ${p.yellow("Not installed")}`),e.hasEnvFile!==void 0&&(e.hasEnvFile?console.log(` \u2705 Environment: ${p.green(".env configured")}`):console.log(` \u26A0\uFE0F Environment: ${p.yellow(".env missing")}`)),e.modulesHealthy!==void 0){let r=e.projectKind==="frontend"?"Source tree":"Modules";e.modulesHealthy?console.log(` \u2705 ${r}: ${p.green("Healthy")}`):e.missingModules&&e.missingModules.length>0?console.log(` \u26A0\uFE0F ${r}: ${p.yellow(`Missing ${e.missingModules.length} init file(s)`)}`):e.projectKind==="frontend"&&console.log(` \u26A0\uFE0F ${r}: ${p.yellow("No application directories detected")}`);}if(e.stats){let r=[];e.stats.modules!==void 0&&r.push(`${e.stats.modules} module${e.stats.modules!==1?"s":""}`),r.length>0&&console.log(` \u{1F4CA} Stats: ${p.cyan(r.join(" \u2022 "))}`);}e.lastModified&&console.log(` \u{1F552} Last Modified: ${p.gray(e.lastModified)}`);let a=[];if(e.hasTests!==void 0&&a.push(e.hasTests?"\u2705 Tests":p.dim("\u2298 No tests")),e.hasDocker!==void 0&&a.push(e.hasDocker?"\u2705 Docker":p.dim("\u2298 No Docker")),e.hasCodeQuality!==void 0){let r=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";a.push(e.hasCodeQuality?`\u2705 ${r}`:p.dim(`\u2298 No ${r}`));}if(a.length>0&&console.log(` ${a.join(" \u2022 ")}`),e.vulnerabilities!==void 0&&e.vulnerabilities>0&&console.log(` \u26A0\uFE0F Security: ${p.yellow(`${e.vulnerabilities} vulnerability(ies) found`)}`),e.issues.length>0&&(console.log(` ${p.bold("Issues:")}`),e.issues.forEach(r=>{console.log(` \u2022 ${p.yellow(r)}`);}),e.fixCommands&&e.fixCommands.length>0&&(console.log(`
|
|
8
8
|
${p.bold.cyan("\u{1F527} Quick Fix:")}`),e.fixCommands.forEach(r=>{console.log(` ${p.cyan("$")} ${p.white(r)}`);}))),e.probes&&e.probes.length>0){console.log(` ${p.bold("Probe checks:")}`);for(let r of e.probes){let l=r.status==="pass"?"\u2705":r.status==="warn"?"\u26A0\uFE0F":"\u274C";console.log(` ${l} ${r.label}: ${p.gray(r.reason)}`),r.recommendation&&console.log(` ${p.dim("\u21B3")} ${p.gray(r.recommendation)}`);}}if(e.commandCapabilities){let r=e.commandCapabilities;if(console.log(` ${p.bold("Command support:")}`),console.log(` ${p.green("supported")} ${r.supportedCommands.length} \u2022 ${p.yellow("unsupported")} ${r.unsupportedCommands.length} \u2022 ${p.gray("global")} ${r.globalCommands.length}`),r.unsupportedCommands.length>0){let l=r.unsupportedCommands.slice(0,8).join(", "),d=r.unsupportedCommands.length>8?", ...":"";console.log(` ${p.dim("\u21B3")} ${p.gray(`Unsupported here: ${l}${d}`)}`);}}}async function un(){try{return (await execa("go",["version"],{timeout:a$3(),reject:false})).exitCode===0}catch{return false}}function ge(e,t){let i=[new RegExp(`^cd\\s+"([^"]+)"\\s*(?:&&|;)\\s*${t}\\s*$`,"i"),new RegExp(`^cd\\s+'([^']+)'\\s*(?:&&|;)\\s*${t}\\s*$`,"i"),new RegExp(`^cd\\s+(.+?)\\s*(?:&&|;)\\s*${t}\\s*$`,"i")];for(let n of i){let o=e.match(n);if(o?.[1])return {projectPath:o[1].trim()}}return null}function qe(e){return ge(e,"cp\\s+\\.env\\.example\\s+\\.env")||ge(e,"copy-item\\s+\\.env\\.example\\s+\\.env")}function mn(e){let t=[{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:"bun\\s+install",command:"bun",args:["install"]},{pattern:"poetry\\s+install",command:"poetry",args:["install"]},{pattern:"poetry\\s+install\\s+--no-root",command:"poetry",args:["install","--no-root"]},{pattern:"poetry\\s+lock",command:"poetry",args:["lock"]},{pattern:"uv\\s+lock",command:"uv",args:["lock"]},{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 t){let n=ge(e,i.pattern);if(n)return {projectPath:n.projectPath,command:i.command,args:i.args}}return null}function Fi(){let e=process.env.RAPIDKIT_DOCTOR_FIX_COMMAND_TIMEOUT_MS;if(e){let t=Number.parseInt(e,10);if(Number.isFinite(t)&&t>0)return t}return 6e4}function Ke(e){let t=[/^cd\s+"([^"]+)"\s*(?:&&|;)\s*npm\s+pkg\s+set\s+"scripts\.([^=]+)=([^"]+)"\s*$/i,/^cd\s+'([^']+)'\s*(?:&&|;)\s*npm\s+pkg\s+set\s+'scripts\.([^=]+)=([^']+)'\s*$/i,/^cd\s+(.+?)\s*(?:&&|;)\s*npm\s+pkg\s+set\s+scripts\.([^=\s]+)=(.+)\s*$/i];for(let i of t){let n=e.match(i);if(!(!n?.[1]||!n?.[2]||!n?.[3]))return {projectPath:n[1].trim(),scriptName:n[2].trim(),scriptValue:n[3].trim().replace(/\\"/g,'"').replace(/\\\\/g,"\\")}}return null}function xe(e){let t=e.trim().match(/^rapidkit:doctor:repair\s+([A-Za-z0-9_-]+)$/);if(!t?.[1])return null;try{let i=Buffer.from(t[1],"base64url").toString("utf8"),n=JSON.parse(i);if(!n||typeof n!="object"||Array.isArray(n))return null;let o=n;return o.type==="file-create"&&typeof o.path=="string"&&typeof o.content=="string"&&o.overwrite===false||o.type==="file-append"&&typeof o.path=="string"&&Array.isArray(o.lines)&&o.lines.every(a=>typeof a=="string")&&typeof o.ensureNewline=="boolean"||o.type==="file-copy"&&typeof o.sourcePath=="string"&&typeof o.path=="string"&&o.overwrite===false||o.type==="package-json-script"&&typeof o.path=="string"&&typeof o.scriptName=="string"&&typeof o.scriptValue=="string"||o.type==="json-edit"&&typeof o.path=="string"&&Array.isArray(o.edits)&&o.edits.every(a=>{if(!a||typeof a!="object"||Array.isArray(a))return false;let r=a;return typeof r.pointer=="string"&&r.pointer.startsWith("/")&&(typeof r.value=="string"||typeof r.value=="number"||typeof r.value=="boolean"||r.value===null)})||o.type==="env-key-add"&&typeof o.path=="string"&&Array.isArray(o.keys)&&o.keys.every(a=>{if(!a||typeof a!="object"||Array.isArray(a))return false;let r=a;return typeof r.name=="string"&&/^[A-Z_][A-Z0-9_]*$/i.test(r.name)&&typeof r.value=="string"&&(r.comment===void 0||typeof r.comment=="string")})||o.type==="makefile-target"&&typeof o.path=="string"&&typeof o.target=="string"&&/^[A-Za-z0-9_.:-]+$/.test(o.target)&&typeof o.command=="string"&&o.command.trim().length>0&&typeof o.phony=="boolean"?o:null}catch{return null}}function Ni(e){let t=e.operation?Ii(e.operation):`command:${e.command}`,i=createHash("sha256").update(t).digest("base64url").slice(0,16);return `${e.projectName}:${e.kind}:${i}`}function Ii(e){switch(e.type){case "file-create":return `file-create:${e.path}:${e.overwrite}:${e.content}`;case "file-append":return `file-append:${e.path}:${e.ensureNewline}:${e.lines.join(`
|
|
9
9
|
`)}`;case "file-copy":return `file-copy:${e.sourcePath}:${e.path}:${e.overwrite}`;case "package-json-script":return `package-json-script:${e.path}:${e.scriptName}:${e.scriptValue}`;case "json-edit":return `json-edit:${e.path}:${e.edits.map(t=>`${t.pointer}=${JSON.stringify(t.value)}`).join("|")}`;case "env-key-add":return `env-key-add:${e.path}:${e.keys.map(t=>`${t.name}=${t.value??""}`).join("|")}`;case "makefile-target":return `makefile-target:${e.path}:${e.target}:${e.command}:${e.phony}`;default:return `operation:${JSON.stringify(e)}`}}function ye(e,t){let i=s.resolve(e),n=s.resolve(t),o=s.relative(i,n);if(o.startsWith("..")||s.isAbsolute(o))throw new Error(`Repair target escapes project boundary: ${t}`);return n}async function Ai(e){if(!/^[A-Za-z0-9:_-]+$/.test(e.scriptName))throw new Error(`Unsafe package script name: ${e.scriptName}`);let t=s.join(e.projectPath,"package.json");if(!await c$1.pathExists(t))throw new Error(`package.json not found at ${t}`);let i=await c$1.readJSON(t),n=i.scripts&&typeof i.scripts=="object"&&!Array.isArray(i.scripts)?i.scripts:{},o=n[e.scriptName];typeof o=="string"&&o.trim().length>0||(i.scripts={...n,[e.scriptName]:e.scriptValue},await c$1.writeJSON(t,i,{spaces:2}));}async function Oi(e){let t=ye(e.projectPath,e.operation.path);await c$1.pathExists(t)||(await c$1.ensureDir(s.dirname(t)),await c$1.writeFile(t,e.operation.content,"utf8"));}async function Mi(e){let t=ye(e.projectPath,e.operation.path);await c$1.ensureDir(s.dirname(t));let i=await yt(t),n=i.split(/\r?\n/),o=e.operation.lines.filter(r=>!n.includes(r));if(o.length===0)return;let a=i.length===0||i.endsWith(`
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var o=[{id:"fastapi.standard",aliases:["fastapi","fastapi.standard"],label:"fastapi \u2014 FastAPI Standard Kit",description:"Core-backed FastAPI service scaffold.",owner:"core",runtime:"python",framework:"fastapi",moduleSupport:true,stability:"stable"},{id:"fastapi.ddd",aliases:["fastapi.ddd","fastapi-ddd"],label:"fastapi \u2014 FastAPI DDD Kit",description:"Core-backed FastAPI DDD service scaffold.",owner:"core",runtime:"python",framework:"fastapi",moduleSupport:true,stability:"stable"},{id:"nestjs.standard",aliases:["nestjs","nest","nestjs.standard"],label:"nestjs \u2014 NestJS Standard Kit",description:"Core-backed NestJS service scaffold.",owner:"core",runtime:"node",framework:"nestjs",moduleSupport:true,stability:"stable"},{id:"springboot.standard",aliases:["spring","springboot","springboot.standard","java"],label:"spring \u2014 Spring Boot Standard Kit",description:"npm-backed Spring Boot service scaffold.",owner:"npm",runtime:"java",framework:"springboot",moduleSupport:false,stability:"stable",generator:"springboot",createUsage:"rapidkit create project springboot.standard <name> [--java-version <major>] [--spring-boot-version <semver>] [--group-id <com.example>] [--package-name <com.example.app>] [--port <number>]"},{id:"gofiber.standard",aliases:["go","go.standard","fiber","gofiber","gofiber.standard","go/fiber"],label:"go/fiber \u2014 Go Fiber Standard Kit",description:"npm-backed Go Fiber service scaffold.",owner:"npm",runtime:"go",framework:"gofiber",moduleSupport:false,stability:"stable",generator:"gofiber",createUsage:"rapidkit create project gofiber.standard <name> [--output <dir>]"},{id:"gogin.standard",aliases:["gin","gogin","gogin.standard","go/gin"],label:"go/gin \u2014 Go Gin Standard Kit",description:"npm-backed Go Gin service scaffold.",owner:"npm",runtime:"go",framework:"gogin",moduleSupport:false,stability:"stable",generator:"gogin",createUsage:"rapidkit create project gogin.standard <name> [--output <dir>]"},{id:"dotnet.webapi.clean",aliases:["dotnet","dotnet.webapi","dotnet.webapi.clean","aspnet","aspnetcore","asp.net","asp.net-core","csharp","c#"],label:"dotnet \u2014 ASP.NET Core Clean Web API",description:"npm-backed ASP.NET Core Web API with clean architecture boundaries.",owner:"npm",runtime:"dotnet",framework:"dotnet",moduleSupport:false,stability:"preview",generator:"dotnet-webapi-clean",createUsage:"rapidkit create project dotnet.webapi.clean <name> [--target-framework net8.0] [--root-namespace <Company.Product>] [--port <number>]"}],i=new Map;for(let t of o){i.set(t.id.toLowerCase(),t);for(let e of t.aliases)i.set(e.toLowerCase(),t);}function s(t){return t?i.get(t.trim().toLowerCase())??null:null}function l(t){return s(t)?.id??t}function g(){return o.filter(t=>t.owner==="core"||t.generator)}function m(t){return s(t)?.owner==="npm"}async function f(t,e){if(!t.generator)throw new Error(`Kit is not backed by an npm generator: ${t.id}`);if(t.generator==="gofiber"){let{generateGoFiberKit:r}=await import('./gofiber-standard-BQ4HCXL2.js');await r(e.projectPath,{project_name:e.projectName,module_path:e.projectName,skipGit:e.skipGit,skipInstall:e.skipInstall});return}if(t.generator==="gogin"){let{generateGoGinKit:r}=await import('./gogin-standard-PUBCYW3A.js');await r(e.projectPath,{project_name:e.projectName,module_path:e.projectName,skipGit:e.skipGit,skipInstall:e.skipInstall});return}if(t.generator==="springboot"){let{generateSpringBootKit:r}=await import('./springboot-standard-XFVQI37R.js');await r(e.projectPath,{project_name:e.projectName,artifact_id:e.projectName,java_version:a(e.args,"--java-version")?.trim(),spring_boot_version:a(e.args,"--spring-boot-version")?.trim(),springdoc_version:a(e.args,"--springdoc-version")?.trim(),group_id:a(e.args,"--group-id")?.trim(),package_name:a(e.args,"--package-name")?.trim(),description:a(e.args,"--description")?.trim(),port:a(e.args,"--port")?.trim(),skipGit:e.skipGit,skipInstall:e.skipInstall});return}if(t.generator==="dotnet-webapi-clean"){let{generateDotnetWebApiCleanKit:r}=await import('./dotnet-webapi-clean-K33C77EI.js');await r(e.projectPath,{project_name:e.projectName,target_framework:a(e.args,"--target-framework")?.trim(),root_namespace:a(e.args,"--root-namespace")?.trim(),description:a(e.args,"--description")?.trim(),port:a(e.args,"--port")?.trim(),skipGit:e.skipGit,skipInstall:e.skipInstall});return}throw new Error(`Unhandled npm kit generator: ${t.generator}`)}function a(t,e){let r=t.indexOf(e);if(r>=0&&r+1<t.length)return t[r+1];let n=t.find(p=>p.startsWith(`${e}=`));return n?n.slice(e.length+1):void 0}export{s as a,l as b,g as c,m as d,f as e};
|