rapidkit 0.38.0 → 0.40.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.
Files changed (80) hide show
  1. package/README.md +96 -31
  2. package/contracts/agent-customization-pack.v1.json +159 -0
  3. package/contracts/extension-cli-compatibility.v1.json +10 -0
  4. package/contracts/runtime-command-surface.v1.json +33 -0
  5. package/contracts/workspace-intelligence/workspace-dependency-graph.v1.json +92 -0
  6. package/contracts/workspace-intelligence/workspace-impact.v1.json +32 -2
  7. package/contracts/workspace-intelligence/workspace-model.v1.json +5 -0
  8. package/contracts/workspace-intelligence/workspace-verify.v1.json +103 -1
  9. package/dist/analyze-RHQM4AB2.js +1 -0
  10. package/dist/autopilot-release-S32GYUAQ.js +1 -0
  11. package/dist/chunk-3YLMCP3V.js +1 -0
  12. package/dist/chunk-4FJQWL7P.js +4 -0
  13. package/dist/chunk-4Q2ZZKGB.js +1 -0
  14. package/dist/chunk-6G2KSHP6.js +2 -0
  15. package/dist/{chunk-PPQYTYQG.js → chunk-6KD5F6LX.js} +4 -4
  16. package/dist/{chunk-NKNMGWAZ.js → chunk-CY2WXWYQ.js} +1 -1
  17. package/dist/{chunk-TVIOAZ6E.js → chunk-ERCD6NFF.js} +15 -15
  18. package/dist/chunk-G76C74EV.js +1 -0
  19. package/dist/chunk-GOM3RFB3.js +2 -0
  20. package/dist/chunk-HTYMXMQM.js +1 -0
  21. package/dist/chunk-KYH364KQ.js +1 -0
  22. package/dist/chunk-NAMOYGLS.js +2 -0
  23. package/dist/chunk-OWNGSAO3.js +2 -0
  24. package/dist/chunk-PYCJWW4B.js +1 -0
  25. package/dist/chunk-QPEBI6AB.js +2 -0
  26. package/dist/{chunk-5NBYSXOZ.js → chunk-RXWM5DSC.js} +2 -2
  27. package/dist/chunk-S5KTATOU.js +1 -0
  28. package/dist/chunk-TYZPPUBH.js +1 -0
  29. package/dist/chunk-VQMZC5TC.js +9 -0
  30. package/dist/{chunk-JBDQADHY.js → chunk-WHCON2VN.js} +11 -11
  31. package/dist/chunk-X7PWDIQW.js +1 -0
  32. package/dist/{chunk-7XW2I6MP.js → chunk-ZWKLRZE5.js} +2 -2
  33. package/dist/{create-Y3XJOKL5.js → create-XVDDQA42.js} +1 -1
  34. package/dist/{demo-kit-3VTLJBP7.js → demo-kit-RWGOEDW4.js} +1 -1
  35. package/dist/{doctor-QC662YLH.js → doctor-UOLOGJ2Z.js} +1 -1
  36. package/dist/{dotnet-webapi-clean-FX533F5U.js → dotnet-webapi-clean-RTBRPDPL.js} +1 -1
  37. package/dist/{gofiber-standard-35CJZ7S3.js → gofiber-standard-UGIRKPKL.js} +1 -1
  38. package/dist/{gogin-standard-SAX6C4ZK.js → gogin-standard-HJ7SPFNT.js} +1 -1
  39. package/dist/index.d.ts +32 -1
  40. package/dist/index.js +154 -154
  41. package/dist/pipeline-M52LR5FJ.js +5 -0
  42. package/dist/{springboot-standard-SFMSLTX4.js → springboot-standard-IWJSVDLZ.js} +1 -1
  43. package/dist/{workspace-WBKFXH4Z.js → workspace-L4ITCKMM.js} +1 -1
  44. package/dist/workspace-agent-sync-G7JU77IK.js +25 -0
  45. package/dist/{workspace-context-V4UGIHSC.js → workspace-context-NMMQMHNU.js} +1 -1
  46. package/dist/{workspace-foundation-T45HAWKL.js → workspace-foundation-HNIRAIBF.js} +1 -1
  47. package/dist/workspace-graph-ICB7OVAZ.js +3 -0
  48. package/dist/workspace-history-LHUTLE3S.js +1 -0
  49. package/dist/{workspace-intelligence-MGL3Z25K.js → workspace-intelligence-64IWAYHS.js} +1 -1
  50. package/dist/workspace-model-SDHH5RBC.js +1 -0
  51. package/dist/workspace-run-A26PEGQT.js +1 -0
  52. package/dist/workspace-verify-6Q6MGRG6.js +1 -0
  53. package/dist/workspace-watch-JDXVGW4H.js +1 -0
  54. package/docs/ci-workflows.md +21 -18
  55. package/docs/commands-reference.md +1 -1
  56. package/docs/contracts/ARTIFACT_CATALOG.md +194 -32
  57. package/docs/contracts/CLI_LOG_EVENT_STREAM.md +123 -0
  58. package/docs/contracts/README.md +9 -7
  59. package/docs/examples/ci-agent-grounding.yml +5 -2
  60. package/package.json +11 -6
  61. package/scripts/check-agent-customization-drift.mjs +75 -0
  62. package/dist/analyze-6RFG7C7Z.js +0 -1
  63. package/dist/autopilot-release-SBPGNGAB.js +0 -1
  64. package/dist/chunk-2ED6SPXP.js +0 -1
  65. package/dist/chunk-3R7UJAX5.js +0 -1
  66. package/dist/chunk-6E5TBB2C.js +0 -2
  67. package/dist/chunk-6P5DCHBQ.js +0 -4
  68. package/dist/chunk-ABPDGFVD.js +0 -2
  69. package/dist/chunk-B2KOIORF.js +0 -1
  70. package/dist/chunk-C7WILE56.js +0 -1
  71. package/dist/chunk-HEG6DIGW.js +0 -2
  72. package/dist/chunk-IW3KLQXE.js +0 -2
  73. package/dist/chunk-RELR4O5E.js +0 -2
  74. package/dist/chunk-T5LN7EO5.js +0 -9
  75. package/dist/chunk-XESEBTPE.js +0 -1
  76. package/dist/pipeline-C4UCLETO.js +0 -5
  77. package/dist/workspace-agent-sync-3FFFJYKF.js +0 -17
  78. package/dist/workspace-model-IKMGY2BX.js +0 -1
  79. package/dist/workspace-run-HOR56FON.js +0 -1
  80. package/dist/workspace-verify-A3J6D7T2.js +0 -1
@@ -0,0 +1 @@
1
+ import {e as e$1,a as a$4,d}from'./chunk-X7PWDIQW.js';import {g,a as a$5}from'./chunk-GDGATWR5.js';import {a}from'./chunk-RV6HBTFC.js';import {a as a$3,q as q$1,k}from'./chunk-YBS2HGO3.js';import {i,h}from'./chunk-UZW5QFRW.js';import {a as a$2}from'./chunk-VKLL63TL.js';import {e}from'./chunk-GOM3RFB3.js';import {a as a$1}from'./chunk-HHJAANUC.js';import m from'path';import P from'fs-extra';import rt from'crypto';import {createRequire}from'module';var Ve="unknown-run";function we(t){let e$1=e();return !e$1||e$1===Ve?t:{...t,runId:e$1}}var Ee="workspace-dependency-graph.v1",Pe=["code-import","package-dep","event-pub-sub","service-dependsOn","shared-resource"];var je=".rapidkit/workspace-graph.overrides.json",$e=new Set([".ts",".tsx",".js",".jsx",".mjs",".cjs"]),Ke=new Set([".git",".hg",".svn",".rapidkit",".venv","node_modules","dist","build","out","target","coverage","htmlcov",".next",".turbo",".cache"]),be=600,Se=5,He=256*1024,ve={inferred:1,contract:2,manual:3};function Be(t){return t.split(m.sep).join("/")}function H(t,e){return Be(m.relative(t,e)||".")}function Ce(t){let e=new Map;for(let n of t.projects)e.has(n.name)||e.set(n.name,{id:n.name,path:n.path,...n.runtime?{runtime:n.runtime}:{},...n.framework?{framework:n.framework}:{},...n.kind?{kind:n.kind}:{}});return [...e.values()].sort((n,s)=>n.id.localeCompare(s.id))}function We(t,e){let n=new Map,s=new Map;for(let r of e.projects){if(n.has(r.name))continue;let a=r.absolutePath?m.resolve(r.absolutePath):m.resolve(t,r.path);n.set(r.name,a),s.has(a)||s.set(a,r.name);}let o=[...s.entries()].map(([r,a])=>({dir:r,id:a})).sort((r,a)=>a.dir.length-r.dir.length||r.dir.localeCompare(a.dir));return {idToDir:n,dirToId:s,sortedDirs:o}}function B(t,e){let n=m.resolve(e);for(let{dir:s,id:o}of t.sortedDirs)if(n===s||n.startsWith(`${s}${m.sep}`))return o;return null}async function ee(t){try{if(!await P.pathExists(t))return null;let e=await P.readJSON(t);return e&&typeof e=="object"&&!Array.isArray(e)?e:null}catch{return null}}async function ne(t){try{return await P.pathExists(t)?await P.readFile(t,"utf8"):null}catch{return null}}async function Re(t,e){let n=[],s=new Map;for(let[o,r]of e.idToDir.entries()){let a=await ee(m.join(r,"package.json")),i=typeof a?.name=="string"?a.name.trim():"";i&&!s.has(i)&&s.set(i,o);}for(let[o,r]of e.idToDir.entries()){let a=await ee(m.join(r,"package.json"));if(a){let i=["dependencies","devDependencies","peerDependencies","optionalDependencies"],c=new Set;for(let p of i){let l=a[p];if(!(!l||typeof l!="object"||Array.isArray(l)))for(let d of Object.keys(l)){let u=s.get(d);!u||u===o||c.has(u)||(c.add(u),n.push({from:o,to:u,kind:"package-dep",source:"inferred",confidence:"high",evidence:[{file:H(t,m.join(r,"package.json")),detail:`declares dependency ${d}`}]}));}}}n.push(...await Le(t,e,o,r)),n.push(...await ze(t,e,o,r));}return n}async function Le(t,e,n,s){let o=await ne(m.join(s,"pyproject.toml"));if(!o)return [];let r=[],a=new Set,i=/path\s*=\s*["']([^"']+)["']/g,c;for(;(c=i.exec(o))!==null;){let p=B(e,m.resolve(s,c[1]));!p||p===n||a.has(p)||(a.add(p),r.push({from:n,to:p,kind:"package-dep",source:"inferred",confidence:"high",evidence:[{file:H(t,m.join(s,"pyproject.toml")),detail:`path dependency ${c[1]}`}]}));}return r}async function ze(t,e,n,s){let o=await ne(m.join(s,"go.mod"));if(!o)return [];let r=[],a=new Set,i=/replace\s+\S+\s+=>\s+(\.[^\s]+)/g,c;for(;(c=i.exec(o))!==null;){let p=B(e,m.resolve(s,c[1]));!p||p===n||a.has(p)||(a.add(p),r.push({from:n,to:p,kind:"package-dep",source:"inferred",confidence:"high",evidence:[{file:H(t,m.join(s,"go.mod")),detail:`go.mod replace ${c[1]}`}]}));}return r}async function Je(t,e){let n=[],s=[t];for(;s.length>0&&n.length<e;){let o=s.shift();if(!o)continue;let r=[];try{r=await P.readdir(o,{withFileTypes:true});}catch{continue}let a=[],i=[];for(let c of r)if(c.isDirectory()){if(Ke.has(c.name)||c.name.startsWith("."))continue;a.push(m.join(o,c.name));}else c.isFile()&&$e.has(m.extname(c.name))&&i.push(m.join(o,c.name));i.sort((c,p)=>c.localeCompare(p)),a.sort((c,p)=>c.localeCompare(p));for(let c of i){if(n.length>=e)break;n.push(c);}s.push(...a);}return n}var qe=[/\bfrom\s+["']([^"']+)["']/g,/\bimport\s+["']([^"']+)["']/g,/\bimport\s*\(\s*["']([^"']+)["']\s*\)/g,/\brequire\s*\(\s*["']([^"']+)["']\s*\)/g];function Ue(t){let e=new Set;for(let n of qe){n.lastIndex=0;let s;for(;(s=n.exec(t))!==null;){let o=s[1];o.startsWith(".")&&e.add(o);}}return [...e]}async function te(t,e,n,s){let o=new Map;for(let[r,a]of e.idToDir.entries()){if(s&&!s.has(r))continue;let i=await Je(a,n);for(let c of i){let p=await P.stat(c).catch(()=>null);if(!p||p.size>He)continue;let l=await ne(c);if(l)for(let d of Ue(l)){let u=m.resolve(m.dirname(c),d),k=B(e,u);if(!k||k===r)continue;let j=`${r}\0${k}`,y=o.get(j);y||(y={from:r,to:k,evidence:[]},o.set(j,y)),y.evidence.length<Se&&y.evidence.push({file:H(t,c),detail:`imports ${d}`});}}}return [...o.values()].map(r=>({from:r.from,to:r.to,kind:"code-import",source:"inferred",confidence:"medium",evidence:r.evidence}))}function Xe(t,e,n){let s=new Map;for(let o of n.projects){let r=Ye(t,e,o);r&&s.set(o.slug,r);}return s}function Ye(t,e,n){let s=[n.relativePath,n.externalPath].filter(o=>typeof o=="string"&&o.length>0);for(let o of s){let r=m.resolve(t,o),a=e.dirToId.get(r)??B(e,r);if(a)return a}return e.idToDir.has(n.slug)?n.slug:null}function Me(t,e,n){let s=[],o=Xe(t,e,n),r=a$5,a=new Map,i=new Map;for(let c of n.projects){let p=o.get(c.slug);if(!p)continue;let l=c.contracts??{publishes:[],consumes:[],dependsOn:[]};for(let d of l.dependsOn??[]){let u=o.get(d);!u||u===p||s.push({from:p,to:u,kind:"service-dependsOn",source:"contract",confidence:"high",evidence:[{file:r,detail:`dependsOn ${d}`}]});}for(let d of l.publishes??[])a.has(d)||a.set(d,new Set),a.get(d)?.add(p);for(let d of l.consumes??[])i.has(d)||i.set(d,new Set),i.get(d)?.add(p);}for(let[c,p]of a.entries()){let l=i.get(c);if(l)for(let d of l)for(let u of p)d!==u&&s.push({from:d,to:u,kind:"event-pub-sub",source:"contract",confidence:"high",evidence:[{file:r,detail:`consumes event ${c}`}]});}return s.push(...Qe(n,o)),s}function Z(t){return t.toLowerCase().replace(/[^a-z0-9]/g,"")}function Qe(t,e){let n=[],s=t.projects.map(o=>({project:o,id:e.get(o.slug)})).filter(o=>!!o.id).filter(o=>Z(o.project.slug).length>=3);for(let o of t.projects){let r=e.get(o.slug);if(!r)continue;let a=o.contracts?.env??[];if(a.length===0)continue;let i=new Set;for(let c of a){let p=Z(c);for(let l of s)l.id===r||i.has(l.id)||!(p.includes(Z(l.project.slug))&&(l.project.ports?.length??0)>0)||(i.add(l.id),n.push({from:r,to:l.id,kind:"shared-resource",source:"inferred",confidence:"low",evidence:[{file:a$5,detail:`env ${c} references ${l.project.slug}`}]}));}}return n}async function xe(t,e){let n=await ee(m.join(t,je)),s=Array.isArray(n?.edges)?n?.edges:[],o=[],r=new Set(Pe);for(let a of s){if(!a||typeof a!="object"||Array.isArray(a))continue;let i=a,c=typeof i.from=="string"?i.from:"",p=typeof i.to=="string"?i.to:"",l=typeof i.kind=="string"?i.kind:"";if(!e.has(c)||!e.has(p)||c===p||!r.has(l))continue;let d=Array.isArray(i.evidence)?i.evidence.map(u=>u&&typeof u=="object"&&typeof u.file=="string"?{file:u.file,...typeof u.detail=="string"?{detail:u.detail}:{}}:null).filter(u=>!!u):[];o.push({from:c,to:p,kind:l,source:"manual",confidence:"high",evidence:d.length>0?d:[{file:je,detail:"manual edge"}]});}return o}function Ze(t){return `${t.from}\0${t.to}\0${t.kind}`}function et(t){let e=new Set,n=[];for(let s of t){let o=`${s.file}\0${s.detail??""}`;e.has(o)||(e.add(o),n.push(s));}return n.sort((s,o)=>s.file.localeCompare(o.file)||(s.detail??"").localeCompare(o.detail??"")).slice(0,Se)}function tt(t){let e=new Map;for(let n of t){let s=Ze(n),o=e.get(s);if(!o){e.set(s,{...n,evidence:[...n.evidence]});continue}let r=ve[o.source],a=ve[n.source];a>r?e.set(s,{...n,evidence:[...n.evidence,...o.evidence]}):a===r&&o.evidence.push(...n.evidence);}return [...e.values()].map(n=>({from:n.from,to:n.to,kind:n.kind,source:n.source,confidence:n.confidence,evidence:et(n.evidence)})).sort((n,s)=>n.from.localeCompare(s.from)||n.to.localeCompare(s.to)||n.kind.localeCompare(s.kind)||n.source.localeCompare(s.source))}function nt(t,e){let n=new Map;for(let c of t)n.set(c.id,[]);for(let c of e)n.has(c.from)||n.set(c.from,[]),n.get(c.from)?.push(c.to);let s=0,o=1,r=2,a=new Map;for(let c of n.keys())a.set(c,s);let i=c=>{let p=[{id:c,index:0}];for(a.set(c,o);p.length>0;){let l=p[p.length-1],d=n.get(l.id)??[];if(l.index>=d.length){a.set(l.id,r),p.pop();continue}let u=d[l.index];l.index+=1;let k=a.get(u)??s;if(k===o)return true;k===s&&(a.set(u,o),p.push({id:u,index:0}));}return false};for(let c of [...n.keys()].sort())if(a.get(c)===s&&i(c))return true;return false}function Ae(t,e,n,s){let o=tt(n.filter(r=>e.has(r.from)&&e.has(r.to)));return {schemaVersion:Ee,generatedAt:(s??new Date).toISOString(),nodes:t,edges:o,stats:{nodeCount:t.length,edgeCount:o.length,inferredEdges:o.filter(r=>r.source==="inferred").length,contractEdges:o.filter(r=>r.source==="contract").length,manualEdges:o.filter(r=>r.source==="manual").length,hasCycle:nt(t,o)}}}async function Ie(t){let e=m.resolve(t.workspacePath),n=t.maxImportFilesPerProject??be,s=Ce(t.model),o=new Set(s.map(i=>i.id)),r=We(e,t.model),a=[];return a.push(...await Re(e,r)),a.push(...await te(e,r,n)),t.contract&&a.push(...Me(e,r,t.contract)),a.push(...await xe(e,o)),Ae(s,o,a,t.now)}async function De(t){let e=m.resolve(t.workspacePath),n=t.maxImportFilesPerProject??be,s=Ce(t.model),o=new Set(s.map(i=>i.id)),r=We(e,t.model),a=[];if(a.push(...await Re(e,r)),t.structuralChange)a.push(...await te(e,r,n));else {a.push(...await te(e,r,n,t.changedProjectIds));for(let i of t.previousGraph.edges)i.kind==="code-import"&&i.source==="inferred"&&!t.changedProjectIds.has(i.from)&&o.has(i.from)&&o.has(i.to)&&a.push({from:i.from,to:i.to,kind:"code-import",source:"inferred",confidence:i.confidence,evidence:i.evidence});}return t.contract&&a.push(...Me(e,r,t.contract)),a.push(...await xe(e,o)),Ae(s,o,a,t.now)}var re="workspace-model-cache.v1",_e=".rapidkit/cache/workspace-model.v1.json",Oe=["package.json","pyproject.toml","requirements.txt","go.mod","go.sum","pom.xml","build.gradle","build.gradle.kts","Cargo.toml","composer.json","Gemfile","rapidkit.project.json",".rapidkit/project.json"],st=[".rapidkit/workspace.contract.json",".rapidkit/workspace.json","rapidkit.workspace.json",".rapidkit/policies.yml",".rapidkit/policies.yaml"],at=new Set([".ts",".tsx",".js",".jsx",".mjs",".cjs"]),it=new Set([".git",".rapidkit","node_modules","dist","build","out","target","coverage",".next",".turbo",".cache",".venv"]),ct=1500,_=null;function oe(){if(_)return _;try{_=createRequire(import.meta.url)("../package.json")?.version??"0.0.0";}catch{_="0.0.0";}return _}async function L(t){try{let e=await P.readFile(t);return rt.createHash("sha256").update(e).digest("hex")}catch{return null}}async function dt(t){let e={};for(let o of Oe){let r=await L(m.join(t,o));r&&(e[o]=r);}let n=[],s=[t];for(;s.length>0&&n.length<ct;){let o=s.shift();if(!o)continue;let r=[];try{r=await P.readdir(o,{withFileTypes:true});}catch{continue}let a=[];for(let i of r)if(i.isDirectory()){if(it.has(i.name)||i.name.startsWith("."))continue;a.push(m.join(o,i.name));}else if(i.isFile()&&at.has(m.extname(i.name))){let c=m.join(o,i.name),p=await P.stat(c).catch(()=>null);if(p){let l=m.relative(t,c).split(m.sep).join("/");n.push(`${l}:${p.size}:${Math.round(p.mtimeMs)}`);}}a.sort((i,c)=>i.localeCompare(c)),s.push(...a);}return n.sort((o,r)=>o.localeCompare(r)),d({manifests:e,source:n})}async function z(t,e){let n=m.resolve(t),s={},o=[...new Set(e.map(r=>m.relative(n,m.resolve(r)).split(m.sep).join("/")))].sort((r,a)=>r.localeCompare(a));for(let r of o)s[r]=await dt(m.join(n,r));return s}async function J(t){let e=m.resolve(t),n={};for(let s of st){let o=await L(m.join(e,s));o&&(n[s]=o);}return n}async function q(t){let e=m.resolve(t.workspacePath),n=[...new Set(t.projectPaths.map(r=>m.relative(e,m.resolve(r)).split(m.sep).join("/")))].sort((r,a)=>r.localeCompare(a)),s=[];for(let r of n){let a={};for(let i of Oe){let c=await L(m.join(e,r,i));c&&(a[i]=c);}s.push({project:r,manifests:a});}let o={};for(let r of [".rapidkit/workspace.contract.json",".rapidkit/workspace.json","rapidkit.workspace.json",".rapidkit/policies.yml",".rapidkit/policies.yaml"]){let a=await L(m.join(e,r));a&&(o[r]=a);}return d({cacheSchema:re,cliVersion:t.cliVersion,flags:t.flags,workspaceJson:t.workspaceJson??null,marker:t.marker??null,projects:s,workspaceFiles:o})}async function se(t){let e=m.join(m.resolve(t),_e);try{if(!await P.pathExists(e))return null;let n=await P.readJson(e);return !n||n.schemaVersion!==re||typeof n.inputsHash!="string"||typeof n.cliVersion!="string"||!n.model?null:n}catch{return null}}async function U(t,e){let n=m.join(m.resolve(t),_e);await P.ensureDir(m.dirname(n));let s={schemaVersion:re,...e};return await P.writeJson(n,s,{spaces:2}),n}var pt="workspace-model.v1",lt=".rapidkit/reports/workspace-model.json",ut=["package.json","pyproject.toml","requirements.txt","go.mod","pom.xml","build.gradle","build.gradle.kts","Cargo.toml","composer.json","Gemfile","mix.exs","deno.json","deno.jsonc","bun.lock","bun.lockb","deps.edn","project.clj","build.sbt","docker-compose.yml","docker-compose.yaml","terraform.tf"],mt=new Set([".git",".hg",".svn",".rapidkit",".venv","node_modules","dist","build","target","coverage","htmlcov",".next",".turbo"]);function Ne(t,e){return (m.relative(t,e)||".").split(m.sep).join("/")}async function Te(t){try{if(!await P.pathExists(t))return null;let e=await P.readJSON(t);return e&&typeof e=="object"?e:null}catch{return null}}async function gt(t,e){for(let n of e)if(await P.pathExists(m.join(t,n)))return true;return false}function ae(t){let e=Number.parseInt(process.env.RAPIDKIT_WORKSPACE_MODEL_SCAN_DEPTH??"",10),n=typeof t=="number"&&Number.isFinite(t)?t:Number.isFinite(e)?e:4;return Math.min(12,Math.max(1,Math.trunc(n)))}async function ie(t,e){let n=m.resolve(t),s=[{dirPath:n,depth:0}],o=new Set,r=new Set;for(;s.length>0;){let a=s.shift();if(!a)continue;let i=m.resolve(a.dirPath);if(r.has(i))continue;if(r.add(i),i!==n&&await gt(i,ut)){o.add(i);continue}if(a.depth>=e)continue;let c=[];try{c=await P.readdir(i,{withFileTypes:true});}catch{continue}for(let p of c)!p.isDirectory()||mt.has(p.name)||p.name.startsWith(".")&&p.name!==".config"||s.push({dirPath:m.join(i,p.name),depth:a.depth+1});}return Array.from(o).sort((a,i)=>a.localeCompare(i))}function ce(t){let e=new Set,n=[];for(let s of t){let o=m.resolve(s);e.has(o)||(e.add(o),n.push(o));}return n.sort((s,o)=>s.localeCompare(o))}function Ge(t,e){let n=t?.[e];return typeof n=="string"&&n.trim()?n.trim():void 0}function ft(t,e){return t?.[e]===true}function ht(t,e,n){let s=t?.frontend&&typeof t.frontend=="object"&&!Array.isArray(t.frontend)?t.frontend:void 0,o=Ge(s,"generator"),r=Ge(s,"command_display"),a=typeof e=="string"&&e.startsWith("frontend.");if(!(!o&&!a))return {...o?{id:o}:{},...e?{kit:e}:{},displayName:n,source:ft(s,"official_generator")?"official-generator":"metadata",...r?{commandDisplay:r}:{}}}async function kt(t){let e=[".rapidkit/project.json",".rapidkit/context.json","package.json","pyproject.toml","requirements.txt","go.mod","pom.xml","build.gradle","build.gradle.kts","Cargo.toml","composer.json","Gemfile","mix.exs","deno.json","Dockerfile","docker-compose.yml","README.md"],n=[];for(let s of e)await P.pathExists(m.join(t,s))&&n.push(s);return n}async function v(t,e,n){let s=m.join(t,e),o=await P.pathExists(s),r={path:e.split(m.sep).join("/"),exists:o};if(o&&n){let a=await Te(s);typeof a?.generatedAt=="string"&&(r.generatedAt=a.generatedAt);let i=a?.status??a?.result??a?.verdict;typeof i=="string"&&(r.status=i);}return r}async function yt(t,e,n){let o=`${Ne(t,e)}/.rapidkit/reports`,r=await v(t,`${o}/doctor-project-last-run.json`,n);return {doctor:r?.exists===true?r:await v(t,`${o}/doctor-last-run.json`,n),analyze:await v(t,`${o}/analyze-last-run.json`,n),readiness:await v(t,`${o}/release-readiness-last-run.json`,n)}}async function wt(t,e,n){let s=a$3(e),o=i(e,s),r=q$1(e),a=k(o.runtime),i$1=await e$1(e,s),c=typeof s?.name=="string"&&s.name.trim()?s.name.trim():m.basename(e),p=typeof s?.kit_name=="string"?s.kit_name:typeof s?.kit=="string"?s.kit:void 0,l=typeof s?.engine=="string"?s.engine:r.engine!=="unknown"?r.engine:void 0,d=ht(s,p,o.displayName),u=a$4({kitId:p,framework:o.key,runtime:o.runtime});return {name:c,path:Ne(t,e),...n.includeAbsolutePaths?{absolutePath:e}:{},kind:i$1,runtime:o.runtime,runtimeCandidates:h(e),framework:o.key,frameworkDisplayName:o.displayName,confidence:o.confidence,detectionSource:o.source,supportTier:o.supportTier,runtimeSupportTier:a.tier,runtimeDoctorSupport:a.doctorSupport,moduleSupport:r.moduleSupport,...p?{kit:p}:{},...l?{engine:l}:{},...d?{generator:d}:{},createCapability:u,commands:{supported:r.supportedCommands,unsupported:r.unsupportedCommands,global:r.globalCommands,fleetStages:r.fleetStages,localOnly:r.localOnlyCommands,map:r.commandMap},importantFiles:await kt(e),evidence:await yt(t,e,n.includeEvidence),provenance:{path:"filesystem discovery",runtime:o.source,framework:o.source,commands:"project command capability matrix",createCapability:"create planner capability contract",evidence:"project .rapidkit/reports"}}}async function de(t){return Te(m.join(t,".rapidkit","workspace.json"))}function Et(t){return t.some(e=>e.kind==="frontend")&&t.length>1?"full-stack-workspace":t.some(e=>e.kind==="frontend")?"frontend-workspace":t.length>1?"backend-platform":"backend-workspace"}function Pt(t){let e=new Set;for(let n of t){let s=`${n.name} ${n.path}`.toLowerCase();for(let o of ["auth","billing","payment","notification","order","admin","report","search","analytics"])s.includes(o)&&e.add(o);}return Array.from(e).sort()}function E(t,e,n,s){return {severity:t,code:e,message:n,target:s}}function Fe(t){let e=[];t.workspace.name.trim()||e.push(E("error","workspace.name.missing","Workspace name could not be resolved.","workspace")),t.workspace.type==="observed-workspace"&&e.push(E("warning","workspace.marker.missing","Workspace marker is missing; model is based on filesystem observation.","workspace.marker")),t.summary.projectCount===0&&e.push(E("warning","workspace.projects.empty","No project roots were detected in this workspace.","projects")),t.contracts.exists||e.push(E("warning","workspace.contract.missing","Workspace contract is missing; dependency and API edges may be incomplete.",t.contracts.workspaceContractPath));let n=new Map;for(let r of t.projects){let a=r.name.toLowerCase(),i=n.get(a)??[];i.push(r),n.set(a,i),r.importantFiles.length||e.push(E("warning","project.markers.missing",`Project ${r.name} has no important manifest files recorded.`,r.path)),r.runtime==="unknown"&&e.push(E("warning","project.runtime.unknown",`Project ${r.name} runtime could not be confidently detected.`,r.path));let c=["test","build"];for(let d of c)r.commands.supported.includes(d)&&r.commands.unsupported.includes(d)&&e.push(E("error","project.commands.conflict",`Project ${r.name} marks ${d} as both supported and unsupported.`,r.path));let p=new Set(r.commands.fleetStages),l=new Set(r.commands.localOnly);for(let d of r.commands.fleetStages){l.has(d)&&e.push(E("error","project.commands.scope-conflict",`Project ${r.name} marks ${d} as both fleet and local-only.`,r.path));let u=r.commands.map[d];(!u||u.status!=="supported"||u.fleetEligible!==true||u.executionScope!=="fleet")&&e.push(E("error","project.commands.fleet-stage-invalid",`Project ${r.name} advertises ${d} as a fleet stage without a supported fleet capability.`,r.path));}for(let d of r.commands.localOnly){let u=r.commands.map[d];(!u||u.status!=="supported"||u.executionScope!=="local-only"||u.fleetEligible===true)&&e.push(E("error","project.commands.local-only-invalid",`Project ${r.name} advertises ${d} as local-only without a matching local-only capability.`,r.path));}for(let d of Object.values(r.commands.map))d.status==="supported"&&(d.fleetEligible===true&&!p.has(d.command)&&e.push(E("error","project.commands.fleet-stage-missing",`Project ${r.name} capability ${d.command} is fleet-eligible but missing from fleetStages.`,r.path)),d.executionScope==="local-only"&&d.fleetEligible!==true&&!l.has(d.command)&&e.push(E("error","project.commands.local-only-missing",`Project ${r.name} capability ${d.command} is local-only but missing from localOnly commands.`,r.path)));}for(let[r,a]of n.entries())a.length>1&&e.push(E("error","project.name.duplicate",`Project name "${r}" is ambiguous across ${a.length} project roots.`,a.map(i=>i.path).join(", ")));let s=e.filter(r=>r.severity==="error").length,o=e.filter(r=>r.severity==="warning").length;return {status:s>0?"failed":o>0?"warning":"passed",errors:s,warnings:o,issues:e}}function an(t){return Fe(t)}async function X(t){let e=m.resolve(t.workspacePath),n=t.includeAbsolutePaths===true,s=t.includeEvidence===true,o=ae(t.observableScanDepth),r=t.now??new Date,[a$3,i,c,p,l]=await Promise.all([a(e),de(e),a$1(e),a$2(e,{descendIntoMatchedProjects:false}),ie(e,o)]),d=ce([...p,...l,...c.map(g=>m.isAbsolute(g.path)?g.path:m.join(e,g.path))]),u=t.reuseProjectModels,k=await Promise.all(d.map(g=>{if(u){let W=m.relative(e,m.resolve(g)).split(m.sep).join("/"),R=u.get(W);if(R)return Promise.resolve(R)}return wt(e,g,{includeAbsolutePaths:n,includeEvidence:s})})),j=typeof i?.workspace_name=="string"?i.workspace_name:typeof i?.name=="string"?i.name:a$3?.name||m.basename(e),y=typeof i?.profile=="string"?i.profile:typeof i?.mode=="string"?i.mode:void 0,x=Array.from(new Set(k.map(g=>g.kind))).sort(),C=Array.from(new Set(k.map(g=>g.runtime))).sort(),Y=Array.from(new Set(k.map(g=>g.framework))).sort(),A=[".rapidkit/policies.yml",".rapidkit/policies.yaml"].find(g=>P.existsSync(m.join(e,g))),I=".rapidkit/workspace.contract.json",b=await P.pathExists(m.join(e,I)),O={schemaVersion:pt,generatedAt:r.toISOString(),workspace:{name:j,root:e,...y?{profile:y}:{},type:a$3?"rapidkit-workspace":"observed-workspace",...a$3?{marker:{createdBy:a$3.createdBy,version:a$3.version,createdAt:a$3.createdAt}}:{}},identity:{workspaceType:Et(k),surfaces:x,runtimeFamilies:C,businessCapabilities:Pt(k)},discovery:{observableScanDepth:o},projects:k,policies:{mode:typeof i?.policy_mode=="string"?i.policy_mode:typeof i?.policyMode=="string"?i.policyMode:"warn",source:A??null,exists:!!A},contracts:{workspaceContractPath:I,exists:b,status:b?"known":"missing"},evidence:{doctor:await v(e,".rapidkit/reports/doctor-last-run.json",s),analyze:await v(e,".rapidkit/reports/analyze-last-run.json",s),readiness:await v(e,".rapidkit/reports/release-readiness-last-run.json",s),pipeline:await v(e,".rapidkit/reports/pipeline-last-run.json",s)},summary:{projectCount:k.length,runtimes:C,frameworks:Y,firstClassProjects:k.filter(g=>g.supportTier==="first-class").length,observedProjects:k.filter(g=>g.supportTier==="observed").length}},D=await St(e,O,{contractExists:b,now:r,incrementalGraph:t.incrementalGraph}),G={...O,graph:D},w=Fe(G);return {...G,validation:w}}async function cn(t){if(t.cache!==true)return {model:await X(t),cache:"disabled"};let e=m.resolve(t.workspacePath),n=ae(t.observableScanDepth),s=oe(),[o,r,a$3,i,c]=await Promise.all([a(e),de(e),a$1(e),a$2(e,{descendIntoMatchedProjects:false}),ie(e,n)]),p=ce([...i,...c,...a$3.map(y=>m.isAbsolute(y.path)?y.path:m.join(e,y.path))]),l=await q({workspacePath:e,cliVersion:s,flags:{includeAbsolutePaths:t.includeAbsolutePaths===true,includeEvidence:t.includeEvidence===true,observableScanDepth:n},projectPaths:p,workspaceJson:r,marker:o}),d=await se(e);if(d&&d.cliVersion===s&&d.inputsHash===l)return {model:d.model,cache:"hit"};let u=await X({...t}),[k,j]=await Promise.all([z(e,p),J(e)]);return await U(e,{cliVersion:s,inputsHash:l,generatedAt:(t.now??new Date).toISOString(),model:u,projectSignatures:k,workspaceFileSignatures:j}),{model:u,cache:"miss"}}function jt(t,e){let n=new Set,s=new Set,o=new Set;for(let[r,a]of Object.entries(e))r in t?t[r]!==a&&n.add(r):s.add(r);for(let r of Object.keys(t))r in e||o.add(r);return {changed:n,added:s,removed:o}}function vt(t={},e={}){let n=new Set([...Object.keys(t),...Object.keys(e)]);for(let s of n)if(t[s]!==e[s])return false;return true}async function dn(t){let e=m.resolve(t.workspacePath),n=ae(t.observableScanDepth),s=oe(),o=t.now??new Date,[r,a$3,i,c,p]=await Promise.all([a(e),de(e),a$1(e),a$2(e,{descendIntoMatchedProjects:false}),ie(e,n)]),l=ce([...c,...p,...i.map(w=>m.isAbsolute(w.path)?w.path:m.join(e,w.path))]),d=await se(e),u=async()=>{let w=await X({...t}),g=await q({workspacePath:e,cliVersion:s,flags:{includeAbsolutePaths:t.includeAbsolutePaths===true,includeEvidence:t.includeEvidence===true,observableScanDepth:n},projectPaths:l,workspaceJson:a$3,marker:r}),[W,R]=await Promise.all([z(e,l),J(e)]);return await U(e,{cliVersion:s,inputsHash:g,generatedAt:o.toISOString(),model:w,projectSignatures:W,workspaceFileSignatures:R}),{model:w,mode:"full"}};if(!d||d.cliVersion!==s||!d.projectSignatures||!d.model?.graph)return u();let k=await J(e);if(!vt(d.workspaceFileSignatures,k))return u();let j=await z(e,l),{changed:y,added:x,removed:C}=jt(d.projectSignatures,j);if(y.size===0&&x.size===0&&C.size===0)return {model:d.model,mode:"unchanged"};let Y=new Set([...y,...x]),A=new Map;for(let w of d.model.projects){let g=w.path.split(m.sep).join("/");!Y.has(g)&&!C.has(g)&&A.set(g,w);}let I=new Set,b=false;for(let w of d.model.projects){let g=w.path.split(m.sep).join("/");y.has(g)&&I.add(w.name);}let O=x.size>0||C.size>0,D=await X({...t,reuseProjectModels:A,incrementalGraph:{previousGraph:d.model.graph,changedProjectIds:I,structuralChange:O||b}});for(let w of d.model.projects){let g=w.path.split(m.sep).join("/");if(!y.has(g))continue;let W=D.projects.find(R=>R.path.split(m.sep).join("/")===g);if(W&&W.name!==w.name){b=true;break}}if(b)return u();let G=await q({workspacePath:e,cliVersion:s,flags:{includeAbsolutePaths:t.includeAbsolutePaths===true,includeEvidence:t.includeEvidence===true,observableScanDepth:n},projectPaths:l,workspaceJson:a$3,marker:r});return await U(e,{cliVersion:s,inputsHash:G,generatedAt:o.toISOString(),model:D,projectSignatures:j,workspaceFileSignatures:k}),{model:D,mode:"incremental"}}async function bt(t){try{let{contract:e}=await g({workspacePath:t});return e&&typeof e=="object"?e:null}catch{return null}}async function St(t,e,n){let s=n.contractExists?await bt(t):null;try{return n.incrementalGraph?await De({workspacePath:t,model:e,contract:s,now:n.now,previousGraph:n.incrementalGraph.previousGraph,changedProjectIds:n.incrementalGraph.changedProjectIds,structuralChange:n.incrementalGraph.structuralChange}):await Ie({workspacePath:t,model:e,contract:s,now:n.now})}catch{let o=e.projects.map(r=>({id:r.name,path:r.path}));return {schemaVersion:"workspace-dependency-graph.v1",generatedAt:n.now.toISOString(),nodes:o,edges:[],stats:{nodeCount:o.length,edgeCount:0,inferredEdges:0,contractEdges:0,manualEdges:0,hasCycle:false}}}}async function pn(t,e){let n=m.join(e,lt);return await P.ensureDir(m.dirname(n)),await P.writeJSON(n,we(t),{spaces:2}),n}export{we as a,pt as b,lt as c,an as d,X as e,cn as f,dn as g,pn as h};
@@ -0,0 +1,9 @@
1
+ import {a,b}from'./chunk-KMUWWZRT.js';import {f as f$1,e}from'./chunk-4Q2ZZKGB.js';import {h as h$1,i}from'./chunk-UZW5QFRW.js';import {a as a$1}from'./chunk-VKLL63TL.js';import h from'fs';import o from'path';import s from'chalk';var S=new Set([".git",".rapidkit",".venv","node_modules","dist","build","target","coverage","htmlcov",".next"]);async function y(e){try{return await h.promises.access(e,h.constants.F_OK),true}catch{return false}}async function z(e){try{let n=JSON.parse(await h.promises.readFile(e,"utf-8"));return n&&typeof n=="object"&&!Array.isArray(n)?n:null}catch{return null}}async function T(e){try{return await h.promises.readFile(e,"utf-8")}catch{return ""}}function N(e){return a(e)}async function K(e,n){return await y(o.join(e,".rapidkit","project.json"))||await y(o.join(e,".rapidkit","context.json"))?true:b(e)?false:o.resolve(e)===o.resolve(n)?h$1(e).length>0:h$1(e).length>0}async function O(e){let n=await a$1(e,{skipDirs:S,includeHiddenDirs:false,descendIntoMatchedProjects:false,isProjectDir:K});return n.length>0?n:b(e)?[]:h$1(e).length>0?[e]:[]}function _(e,n){return o.relative(e,n).replace(/\\/g,"/")||"."}async function A(e,n){for(let t of n)if(await y(o.join(e,t)))return true;return false}async function M(e){return A(e,["health","health.ts","health.js","health.py","health.go","health.kt","health.rb","health.php","healthcheck","health-check","src/health.ts","src/health.js","src/health.py","src/health.go","src/health.kt","src/health.rb","src/health.php","src/healthcheck.ts","src/healthcheck.js","src/liveness.ts","src/readiness.ts","src/ping.ts"])}async function J(e){if(await A(e,["tests","test","__tests__","src/__tests__","pytest.ini","vitest.config.ts","jest.config.ts"]))return true;let t=await z(o.join(e,"package.json")),i=t?.scripts&&typeof t.scripts=="object"?t.scripts:{};return typeof i.test=="string"&&i.test.trim().length>0}async function W(e){let n=await z(o.join(e,"package.json")),t=n?.scripts&&typeof n.scripts=="object"?n.scripts:{};return Object.keys(t).sort()}function f(e,n,t,i,r,c){return {id:e,severity:n,target:t,title:i,detail:r,remediation:c}}function H(e){let n=e.reduce((t,i)=>i.severity==="fail"?t+28:i.severity==="warn"?t+12:t+3,0);return Math.max(0,100-n)}async function B(e,n){let t=await z(o.join(n,".rapidkit","project.json")),i$1=i(n,t),r=h$1(n),c=i$1.runtime==="unknown"?r[0]||"unknown":i$1.runtime,a=_(e,n),d=a,u=await W(n),g=await y(o.join(n,".rapidkit","project.json"))||await y(o.join(n,".rapidkit","context.json")),m=await J(n),k=await A(n,["Dockerfile","dockerfile"]),w=await A(n,[".env.example","env.example","config/env.example"]),P=await A(n,[".github/workflows/ci.yml",".github/workflows/ci.yaml",".github/workflows/main.yml",".github/workflows/build.yml",".github/workflows/test.yml",".github/workflows/deploy.yml",".gitlab-ci.yml",".circleci/config.yml","azure-pipelines.yml","bitbucket-pipelines.yml","cloudbuild.yaml"]),R=await M(n),l=[];return i$1.key==="unknown"&&l.push(f("project.stack.unknown","fail",d,"Project stack is unknown","RapidKit cannot confidently classify this backend project.","Add .rapidkit/project.json metadata or import the project with `rapidkit import`.")),g||l.push(f("project.marker.missing","warn",d,"RapidKit marker is missing","The project can be detected by files, but it is not registered with RapidKit metadata.","Run `rapidkit import <path>` from a workspace or create the project through RapidKit.")),m||l.push(f("project.tests.missing","warn",d,"Test entrypoint is missing","No common test folder, config, or package test script was found.","Add a test command so `rapidkit workspace run test --affected` can gate changes.")),w||l.push(f("project.env.example.missing","info",d,"Environment example is missing","No .env.example or env.example file was found.","Add an env example for onboarding and CI secret documentation.")),P||l.push(f("project.ci.missing","warn",d,"Continuous integration is missing","No recognized CI/CD configuration file was detected for this project.","Add CI configuration so tests and checks run automatically for every change.")),R||l.push(f("project.health.missing","info",d,"Health or readiness probe is missing","The project has no obvious health or readiness endpoint to support automated deployment and runtime checks.","Add a simple health endpoint and document it for readiness gates and observability.")),k||l.push(f("project.container.missing","info",d,"Container recipe is missing","No Dockerfile was found for this project.","Add a Dockerfile when the service is intended for containerized deployment.")),{name:o.basename(n),path:n,relativePath:a,runtime:c,framework:i$1.key,confidence:i$1.confidence,supportTier:i$1.supportTier,hasRapidKitMarker:g,hasTests:m,hasDockerfile:k,hasEnvExample:w,hasCiConfig:P,hasHealthEndpoint:R,scripts:u,findings:l,score:H(l)}}function U(e){return e.name.toLowerCase()}async function V(e){let n=new Map(e.map(r=>[U(r),r])),t=[];for(let r of e){let c=await z(o.join(r.path,"package.json")),a={...c?.dependencies??{},...c?.devDependencies??{},...c?.peerDependencies??{}};for(let u of Object.keys(a)){let g=u.replace(/^@[^/]+\//,"").toLowerCase(),m=n.get(g);m&&m.relativePath!==r.relativePath&&t.push({from:r.relativePath,to:m.relativePath,kind:"package"});}let d=await T(o.join(r.path,"pyproject.toml"));for(let u of e)u.relativePath!==r.relativePath&&d.includes(u.name)&&t.push({from:r.relativePath,to:u.relativePath,kind:"workspace-reference"});}let i=new Set;return t.filter(r=>{let c=`${r.from}\0${r.to}\0${r.kind}`;return i.has(c)?false:(i.add(c),true)})}function L(e,n){let t=new Map;for(let i of e)t.set(i.relativePath,{project:i.relativePath,directDependents:0,directDependencies:0});for(let i of n){let r=t.get(i.from),c=t.get(i.to);r&&(r.directDependencies+=1),c&&(c.directDependents+=1);}return Array.from(t.values()).sort((i,r)=>r.directDependents-i.directDependents||r.directDependencies-i.directDependencies)}async function q(e){let n=await z(o.join(e,".rapidkit","workspace.json"));return typeof n?.profile=="string"?n.profile:null}function Q(e){return {fail:e.filter(n=>n.severity==="fail").length,warn:e.filter(n=>n.severity==="warn").length,info:e.filter(n=>n.severity==="info").length}}function X(e){if(e.projectCount===0)return e.workspaceDetected?["Add your first project: npx rapidkit create project <name> --kit <kit>","Import an existing service: npx rapidkit import <path>"]:["Create a RapidKit workspace: npx rapidkit create workspace my-workspace --profile polyglot","Import an existing service: npx rapidkit import ../service"];let n=[];return e.findings.some(t=>t.id==="workspace.marker.missing")&&n.push("Initialize workspace metadata with `rapidkit bootstrap --profile polyglot`."),e.findings.some(t=>t.id==="project.marker.missing")&&n.push("Register detected projects with `rapidkit import <path>` or recreate them via `rapidkit create project`."),e.findings.some(t=>t.id==="project.tests.missing")&&n.push("Add test entrypoints, then gate changes with `rapidkit workspace run test --affected --strict`."),e.findings.some(t=>t.id==="project.ci.missing")&&n.push("Add CI/CD configuration to catch regressions early and make workspace health checks actionable."),e.findings.some(t=>t.id==="project.health.missing")&&n.push("Add a health/readiness endpoint so runtime probes and deployment checks can verify service health."),e.hasGraph||n.push("Create `.rapidkit/workspace-dependency-graph.json` or use analyze output as the first graph seed."),n.push("Run `rapidkit autopilot release --mode audit --json` before release."),Array.from(new Set(n))}async function ae(e$1={}){let n=o.resolve(e$1.workspacePath||process.cwd());if(!await y(n))throw new Error(`Workspace path does not exist: ${n}`);let t=N(n)??n,i=await y(o.join(t,".rapidkit-workspace"))||await y(o.join(t,".rapidkit","workspace.json")),r=await q(t),c=await O(t),a=await Promise.all(c.map(p=>B(t,p))),d=await V(a),u=L(a,d),g=[];i||g.push(f("workspace.marker.missing","warn",".","Workspace metadata is missing","The directory can be analyzed, but it is not a registered RapidKit workspace.","Run `rapidkit create workspace` or `rapidkit bootstrap --profile polyglot` in a workspace root.")),a.length===0&&g.push(f("workspace.projects.missing","warn",".","No backend projects detected","RapidKit did not find runtime markers or project metadata under this root.","Create a project with `rapidkit create project` or import one with `rapidkit import <path>`."));let m=[...g,...a.flatMap(p=>p.findings)],k=Q(m),w={};for(let p of a)w[p.runtime]=(w[p.runtime]||0)+1;let P=a.length>0?Math.round(a.reduce((p,v)=>p+v.score,0)/a.length):0,R=g.reduce((p,v)=>p+(v.severity==="fail"?20:v.severity==="warn"?8:2),0),l=Math.max(0,P-R),E=k.fail>0||e$1.strict&&k.warn>0?"blocked":k.warn>0?"needs-attention":"ready",j={schemaVersion:"rapidkit-analyze-v1",generatedAt:new Date().toISOString(),workspacePath:t,workspaceDetected:i,profile:r,summary:{score:l,verdict:E,projectCount:a.length,runtimeCount:Object.keys(w).length,findings:k},runtimes:w,projects:a,dependencyGraph:{status:d.length>0?"generated":"empty",edges:d,topImpactedProjects:u.slice(0,5)},findings:m,nextActions:X({findings:m,projectCount:a.length,hasGraph:d.length>0,workspaceDetected:i}),enterpriseControls:{jsonReady:true,ciGateCommand:"rapidkit analyze --json --strict",releaseGateCommand:"rapidkit autopilot release --mode enforce --json",evidencePath:".rapidkit/reports/analyze-last-run.json"}};if(e$1.output&&(await h.promises.mkdir(o.dirname(o.resolve(e$1.output)),{recursive:true}),await h.promises.writeFile(o.resolve(e$1.output),`${JSON.stringify(j,null,2)}
2
+ `)),!e$1.output&&i){let p=o.join(t,".rapidkit","reports","analyze-last-run.json");await h.promises.mkdir(o.dirname(p),{recursive:true});let v=f$1(j,{commandId:"workspaceAnalyze",exitCode:j.summary.verdict==="blocked"?2:j.summary.verdict==="needs-attention"?1:0,generatedAt:j.generatedAt,blockers:j.findings.filter(x=>x.severity==="fail").map(x=>x.title).slice(0,12),runId:e()});await h.promises.writeFile(p,`${JSON.stringify(v,null,2)}
3
+ `);}return j}function ce(e){let n=e.summary.verdict==="ready"?s.green:e.summary.verdict==="needs-attention"?s.yellow:s.red;if(console.log(s.bold(`
4
+ RapidKit Workspace Analysis
5
+ `)),console.log(s.cyan("Workspace:"),e.workspacePath),console.log(s.cyan("Profile:"),e.profile||"not configured"),console.log(s.cyan("Score:"),`${e.summary.score}/100`),console.log(s.cyan("Verdict:"),n(e.summary.verdict)),console.log(s.gray(`Projects: ${e.summary.projectCount}, runtimes: ${e.summary.runtimeCount}, findings: ${e.summary.findings.fail} fail / ${e.summary.findings.warn} warn / ${e.summary.findings.info} info`)),e.projects.length>0){console.log(s.bold(`
6
+ Projects`));for(let t of e.projects){let i=t.score>=85?s.green("pass"):t.score>=65?s.yellow("watch"):s.red("risk");console.log(` ${t.relativePath} ${s.gray(`${t.runtime}/${t.framework}`)} ${i} ${t.score}/100`);}}if(e.dependencyGraph.status==="generated"&&(console.log(s.bold(`
7
+ Dependency Graph`)),console.log(s.gray(` edges: ${e.dependencyGraph.edges.length}`)),e.dependencyGraph.topImpactedProjects.length>0)){console.log(s.gray(" Top impacted projects:"));for(let t of e.dependencyGraph.topImpactedProjects.slice(0,3))console.log(` ${t.project} (${t.directDependents} dependents, ${t.directDependencies} dependencies)`);}if(e.findings.length>0){console.log(s.bold(`
8
+ Top Findings`));for(let t of e.findings.slice(0,8)){let i=t.severity==="fail"?s.red:t.severity==="warn"?s.yellow:s.gray;console.log(` ${i(t.severity.toUpperCase())} ${t.target}: ${t.title}`),console.log(s.gray(` ${t.remediation}`));}}console.log(s.bold(`
9
+ Next Actions`));for(let t of e.nextActions.slice(0,5))console.log(s.gray(` - ${t}`));console.log();}export{ae as a,ce as b};
@@ -1,4 +1,4 @@
1
- import {b}from'./chunk-C7WILE56.js';import {c,a as a$2,b as b$2}from'./chunk-NFUXULIF.js';import {q as q$1}from'./chunk-YBS2HGO3.js';import {e as e$1,d as d$1}from'./chunk-B2KOIORF.js';import {i,d,b as b$3,a as a$5}from'./chunk-UZW5QFRW.js';import {e}from'./chunk-RELR4O5E.js';import {b as b$1,f,d as d$2,a as a$4,k,g,i as i$1}from'./chunk-Z5LKRG57.js';import {a as a$3}from'./chunk-2FIX2MDC.js';import {a as a$1}from'./chunk-HHJAANUC.js';import l from'chalk';import {execa}from'execa';import r from'fs-extra';import a from'path';var bt=[".eslintrc.js",".eslintrc.cjs",".eslintrc.json",".eslintrc.yaml",".eslintrc.yml","eslint.config.js","eslint.config.mjs","eslint.config.cjs"],xt=["tests","test","src/test","__tests__","e2e","playwright","cypress"],jt=["vitest.config.ts","vitest.config.js","vitest.config.mjs","jest.config.js","jest.config.ts","jest.config.mjs","playwright.config.ts","playwright.config.js","cypress.config.js","cypress.config.ts"],Ct=["src","app","pages"],Et=["dev","build","test","lint"];function Oe(e){let n=e?.scripts;if(!n||typeof n!="object"||Array.isArray(n))return {};let i={};for(let[t,c]of Object.entries(n))typeof c=="string"&&c.trim().length>0&&(i[t]=c);return i}async function Le(e,n){for(let c of bt)if(await r.pathExists(a.join(e,c)))return true;let i=n??(await r.pathExists(a.join(e,"package.json"))?await r.readJson(a.join(e,"package.json")):null);if(!i)return false;if(i.eslintConfig)return true;let t={...i.dependencies??{},...i.devDependencies??{}};return !!(t.eslint||t["@eslint/js"]||t["@eslint/eslintrc"])}async function Ve(e,n){for(let c of xt)if(await r.pathExists(a.join(e,c)))return true;for(let c of jt)if(await r.pathExists(a.join(e,c)))return true;let i=Oe(n);if(i.test||i["test:unit"]||i["test:e2e"]||i["test:ci"]||i["test:watch"])return true;let t={...n?.dependencies??{},...n?.devDependencies??{}};return t.vitest||t.jest||t["@playwright/test"]||t.cypress?true:await Pt(e)}async function Pt(e){let n=["src","app","pages","components"],i=/\.(test|spec)\.(tsx?|jsx?|vue|svelte)$/i,c=new Set(["node_modules",".git","dist","build",".next","coverage",".turbo"]);for(let o of n){let s=a.join(e,o);if(!await r.pathExists(s))continue;let d=[{dir:s,depth:0}];for(;d.length>0;){let u=d.shift();if(!u)break;let p=[];try{p=await r.readdir(u.dir);}catch{continue}for(let f of p){let m=a.join(u.dir,f);if(i.test(f))return true;if(!(u.depth>=3||c.has(f)||f.startsWith(".")))try{(await r.stat(m)).isDirectory()&&d.push({dir:m,depth:u.depth+1});}catch{continue}}}}return false}async function je(e){for(let n of Ct){let i=a.join(e,n);if(await r.pathExists(i))try{if((await r.readdir(i)).some(c=>!c.startsWith(".")))return true}catch{continue}}return false}function St(e){let n=e.key;return b$3(n).key}function $t(e,n,i){return a$5(n,i).some(c=>!!e[c])}async function Je(e){let{projectPath:n,detection:i,packageJsonData:t}=e,c=St(i),o=b$3(c),s=Oe(t),d=[],u=await r.pathExists(a.join(n,"package-lock.json"))||await r.pathExists(a.join(n,"pnpm-lock.yaml"))||await r.pathExists(a.join(n,"yarn.lock"))||await r.pathExists(a.join(n,"bun.lockb"));d.push({id:"frontend-lockfile-integrity",label:"Frontend lockfile integrity",status:u?"pass":"warn",severity:"warn",scope:"project-scoped",reason:u?"Node lockfile detected for deterministic dependency restore.":"No Node lockfile detected (package-lock/yarn.lock/pnpm-lock.yaml/bun.lockb).",recommendation:u?void 0:"Commit a lockfile for deterministic installs and CI parity."});let p=await r.pathExists(a.join(n,"tsconfig.json")),f=await r.pathExists(a.join(n,"jsconfig.json")),m=p||f;d.push({id:"frontend-typescript-surface",label:"TypeScript project surface",status:m?"pass":"warn",severity:"warn",scope:"project-scoped",reason:m?p?"tsconfig.json detected.":"jsconfig.json detected.":"No tsconfig.json or jsconfig.json detected.",recommendation:m?void 0:"Add tsconfig.json (or jsconfig.json) for typed frontend builds and IDE parity."});let g=o.fileHints.length>0&&o.fileHints.some(y=>r.pathExistsSync(a.join(n,y)));d.push({id:"frontend-framework-config",label:`${o.displayName} config surface`,status:g?"pass":"warn",severity:"warn",scope:"project-scoped",reason:g?`${o.displayName} configuration artifacts detected.`:`No ${o.displayName} config markers detected (${o.fileHints.join(", ")||"n/a"}).`,recommendation:g?void 0:"Keep framework config files in-repo for reproducible dev/build behavior."});for(let y of Et){let k=$t(s,c,y),b=y==="dev"||y==="build";d.push({id:`frontend-script-${y}`,label:`${y} script surface`,status:k?"pass":b?"fail":"warn",severity:b?"error":"warn",scope:"project-scoped",reason:k?`package.json exposes a ${y} script for ${o.displayName}.`:`No ${y} script detected for ${o.displayName}.`,recommendation:k?void 0:`Add a "${a$5(c,y)[0]??y}" script to package.json.`});}let h=await je(n);return d.push({id:"frontend-source-tree",label:"Frontend source tree",status:h?"pass":"warn",severity:"warn",scope:"project-scoped",reason:h?"Application source directories detected (src/app/pages).":"No frontend source directories detected under src/, app/, or pages/.",recommendation:h?void 0:"Ensure the scaffolded application tree exists before running lifecycle commands."}),d}function Rt(e){return [...new Set(e.filter(n=>n&&n.trim().length>0))]}function Ft(){let e=k().map(t=>a.join(t,a$4()?"poetry.exe":"poetry")),n=a$4()?[a.join(process.env.APPDATA||"","Python","Scripts","poetry.exe"),a.join(process.env.USERPROFILE||"","AppData","Roaming","Python","Scripts","poetry.exe")]:[],i=a$4()?[]:["/usr/local/bin/poetry","/usr/bin/poetry"];return Rt([...e,...n,...i])}function Dt(e){let n=k().map(u=>({location:"Global (user-local)",path:a.join(u,a$4()?"rapidkit.exe":"rapidkit")})),i=[{location:"Global (pipx)",path:a.join(e,".local","bin","rapidkit")},{location:"Global (pipx)",path:a.join(e,"AppData","Roaming","Python","Scripts","rapidkit.exe")},{location:"Global (pyenv)",path:a.join(e,".pyenv","shims","rapidkit")},{location:"Global (system)",path:"/usr/local/bin/rapidkit"},{location:"Global (system)",path:"/usr/bin/rapidkit"}],t=g(a.join(process.cwd(),".venv")),c=i$1(process.cwd()),o=[{location:"Workspace (.venv)",path:t},...c.map(u=>({location:"Workspace (launcher)",path:u}))],s=[...n,...i,...o],d=new Set;return s.filter(u=>d.has(u.path)?false:(d.add(u.path),true))}function At(e){let n=new Map([["Workspace (.venv)",0],["Global (user-local)",1],["Global (pipx)",2],["Global (pyenv)",3],["Global (system)",4]]);return [...e].sort((i,t)=>{let c=n.get(i.location)??Number.MAX_SAFE_INTEGER,o=n.get(t.location)??Number.MAX_SAFE_INTEGER;return c!==o?c-o:i.path.localeCompare(t.path)})}function ee(e){let n=0,i=e.issues.some(t=>t.toLowerCase().includes("environment file missing"));return e.hasEnvFile===false&&!i&&(n+=1),typeof e.vulnerabilities=="number"&&e.vulnerabilities>0&&(n+=1),n}function Ce(e){return e.filter(n=>ee(n)>0).length}function $e(e){return e.reduce((n,i)=>n+ee(i),0)}var It="doctor-project-scan-v2",et="doctor-workspace-cache-v2",Nt=Object.freeze({version:"doctor-evidence-v1",scoringPolicyVersion:"doctor-score-policy-v1",generatedBy:"rapidkit-npm",deterministicScoreBreakdown:true,scopeModel:"workspace-aggregate-or-project-scoped"});function me(){return {...Nt}}function fe(e){return !e||e.total<=0?null:Math.round(e.passed/e.total*100)}function tt(e){return typeof e=="number"?e:Array.isArray(e)?e.length:0}async function nt(e,n){try{if(!await r.pathExists(e))return null;let i=await r.readJSON(e);return c(i,n)?i:null}catch{return null}}function st(e,n){if(!e?.system)return [];let i=[{id:"python",current:n.python},{id:"poetry",current:n.poetry},{id:"pipx",current:n.pipx},{id:"go",current:n.go},{id:"rapidkitCore",current:n.rapidkitCore}],t=[];for(let c of i){let o=e.system?.[c.id]?.status;!o||o===c.current.status||t.push({id:c.id,from:o,to:c.current.status});}return t}function Ht(e,n){let i=new Map;for(let g of n.projects)i.set(g.path||g.name,g.issues.length);if(!e)return {baselineAvailable:false,newIssueCount:0,resolvedIssueCount:0,netIssueDelta:0,scoreDeltaPercent:null,systemStatusChanges:[],regressedProjects:[],improvedProjects:[]};let t=Array.isArray(e.projects)?e.projects:[],c=new Map;for(let g of t){let h=g.path||g.name;h&&c.set(h,tt(g.issues));}let o=0,s=0,d=new Set,u=new Set,p=new Set([...Array.from(c.keys()),...Array.from(i.keys())]);for(let g of p){let h=c.get(g)??0,y=i.get(g)??0;y>h?(o+=y-h,d.add(g)):y<h&&(s+=h-y,u.add(g));}let f=fe(e.healthScore),m=fe(n.healthScore);return {baselineAvailable:true,previousGeneratedAt:e.generatedAt,newIssueCount:o,resolvedIssueCount:s,netIssueDelta:o-s,scoreDeltaPercent:f===null||m===null?null:m-f,systemStatusChanges:st(e,{python:n.python,poetry:n.poetry,pipx:n.pipx,go:n.go,rapidkitCore:n.rapidkitCore}),regressedProjects:Array.from(d).sort(),improvedProjects:Array.from(u).sort()}}function Mt(e,n){if(!e)return {baselineAvailable:false,newIssueCount:0,resolvedIssueCount:0,netIssueDelta:0,scoreDeltaPercent:null,systemStatusChanges:[],regressedProjects:[],improvedProjects:[]};let i=tt(e.project?.issues),t=n.project.issues.length,c=Math.max(t-i,0),o=Math.max(i-t,0),s=fe(e.healthScore),d=fe(n.healthScore),u=n.project.path||n.project.name;return {baselineAvailable:true,previousGeneratedAt:e.generatedAt,newIssueCount:c,resolvedIssueCount:o,netIssueDelta:c-o,scoreDeltaPercent:s===null||d===null?null:d-s,systemStatusChanges:st(e,{python:n.python,poetry:n.poetry,pipx:n.pipx,go:n.go,rapidkitCore:n.rapidkitCore}),regressedProjects:c>0?[u]:[],improvedProjects:o>0?[u]:[]}}function ot(e){let n=e??[],i=0,t=0;for(let s of n){if(s.scope==="project-scoped"){i+=1;continue}(s.scope==="workspace-aggregate"||s.scope==="host-system")&&(t+=1);}let c=i>0&&t>0?1:0,o=c>0?"mixed":i>0?"scoped":t>0?"aggregated":"unknown";return {scopedCount:i,aggregatedCount:t,mixedCount:c,dominantScope:o}}function R(e,n){return a$4()?`cd "${e}"; ${n}`:`cd ${e} && ${n}`}function q(e){return a$4()?R(e,"Copy-Item .env.example .env"):R(e,"cp .env.example .env")}function Tt(e){return e==="FastAPI"||e==="NestJS"?"first-class":e==="Django"||e==="Flask"||e==="Express"||e==="Fastify"||e==="Koa"||e==="Go/Fiber"||e==="Go/Gin"||e==="Spring Boot"||e==="Rust"||e==="Phoenix"||e==="Elixir"||e==="Clojure"||e==="Scala"||e==="Kotlin"||e==="Deno"||e==="Bun"||e==="PHP"||e==="Laravel"||e==="Ruby"||e==="Ruby on Rails"||e==="ASP.NET"?"extended":"observed"}function Bt(e){return e==="Next.js"||e==="Remix"||e==="Nuxt"||e==="React"||e==="Vue"||e==="Angular"||e==="SvelteKit"||e==="Svelte"||e==="Vite"||e==="Astro"||e==="Solid"?"frontend":e==="Unknown"||e==="Node.js"||e==="Python"?"generic":"backend"}function _t(e){return e==="NestJS"||e==="Next.js"||e==="Remix"||e==="Nuxt"||e==="React"||e==="Vue"||e==="Angular"||e==="SvelteKit"||e==="Svelte"||e==="Vite"||e==="Astro"||e==="Solid"||e==="Bun"||e==="Express"||e==="Fastify"||e==="Koa"||e==="Node.js"?"node":e==="FastAPI"||e==="Django"||e==="Flask"||e==="Python"?"python":e==="Go/Fiber"||e==="Go/Gin"?"go":e==="Spring Boot"?"java":e==="Rust"?"rust":e==="Elixir"||e==="Phoenix"?"elixir":e==="Clojure"?"clojure":e==="Deno"?"deno":e==="Laravel"||e==="PHP"?"php":e==="Ruby on Rails"||e==="Ruby"?"ruby":e==="ASP.NET"?"dotnet":"unknown"}function Ee(e,n){let i=q$1(n);e.commandCapabilities=i,e.supportTier=i.frameworkSupportTier;}function pe(e,n,i,t){e.framework=n,e.frameworkConfidence=i,e.supportTier=Tt(n),e.projectKind=Bt(n),e.runtimeFamily=_t(n);}function it(e){return e==="python"?"python":e==="node"||e==="bun"?"node":e==="go"?"go":e==="java"?"java":e==="rust"?"rust":e==="elixir"?"elixir":e==="clojure"?"clojure":e==="deno"?"deno":e==="php"?"php":e==="ruby"?"ruby":e==="dotnet"?"dotnet":"unknown"}function Re(e){switch(e.key){case "fastapi":return "FastAPI";case "django":return "Django";case "flask":return "Flask";case "python":return "Python";case "nestjs":return "NestJS";case "nextjs":return "Next.js";case "remix":return "Remix";case "nuxt":return "Nuxt";case "react":return "React";case "vite":return "Vite";case "vue":return "Vue";case "sveltekit":return "SvelteKit";case "svelte":return "Svelte";case "angular":return "Angular";case "astro":return "Astro";case "solid":return "Solid";case "express":return "Express";case "fastify":return "Fastify";case "koa":return "Koa";case "node":return "Node.js";case "gofiber":return "Go/Fiber";case "gogin":return "Go/Gin";case "echo":return "Echo";case "go":return "Go";case "springboot":return "Spring Boot";case "java":return "Java";case "laravel":return "Laravel";case "php":return "PHP";case "rails":return "Ruby on Rails";case "ruby":return "Ruby";case "dotnet":return "ASP.NET";case "phoenix":return "Phoenix";case "elixir":return "Elixir";case "clojure":return "Clojure";case "scala":return "Scala";case "kotlin":return "Kotlin";case "deno":return "Deno";case "bun":return "Bun";case "actix":case "axum":case "rocket":case "rust":return "Rust";case "sinatra":case "symfony":case "unknown":return "Unknown";default:return "Unknown"}}function Gt(e){return e.key==="python"||e.key==="node"||e.key==="go"||e.key==="java"||e.key==="php"||e.key==="ruby"||e.key==="dotnet"||e.key==="rust"||e.key==="elixir"||e.key==="clojure"||e.key==="scala"||e.key==="kotlin"||e.key==="deno"||e.key==="bun"||e.key==="unknown"}function Kt(e,n){e.framework=Re(n),e.frameworkKey=n.key,e.importStack=n.importStack,e.frameworkConfidence=n.confidence,e.supportTier=n.supportTier,e.projectKind="frontend",e.runtimeFamily=it(n.runtime);}function G(e,n){e.framework=Re(n),e.frameworkKey=n.key,e.importStack=n.importStack,e.frameworkConfidence=n.confidence,e.supportTier=n.supportTier,e.projectKind=Gt(n)?"generic":"backend",e.runtimeFamily=it(n.runtime);}function Wt(e){let n=e.dependencies,i=e.scripts??{},t=(e.kitName??"").toLowerCase(),c=s=>!!n[s],o=Object.values(i).filter(s=>typeof s=="string").join(" ").toLowerCase();return c("next")||o.includes("next ")?{framework:"Next.js",confidence:"high"}:c("nuxt")||o.includes("nuxt ")?{framework:"Nuxt",confidence:"high"}:c("@nestjs/core")||t.startsWith("nestjs.")?{framework:"NestJS",confidence:"high"}:c("express")?{framework:"Express",confidence:"high"}:c("fastify")?{framework:"Fastify",confidence:"high"}:c("koa")?{framework:"Koa",confidence:"high"}:c("@angular/core")?{framework:"Angular",confidence:"high"}:c("@sveltejs/kit")||o.includes("svelte-kit")?{framework:"SvelteKit",confidence:"high"}:c("vue")?{framework:"Vue",confidence:"medium"}:c("react")&&c("react-dom")?{framework:"React",confidence:"medium"}:{framework:"Node.js",confidence:"low"}}async function Ot(e){let n=i(e);return n.runtime!=="python"?{framework:"Python",confidence:"low"}:{framework:Re(n),confidence:n.confidence}}async function qe(e){try{let n=await r.stat(e);return `${a.basename(e)}:${n.isDirectory()?"d":"f"}:${n.size}:${n.mtimeMs}`}catch{return `${a.basename(e)}:missing`}}async function Lt(e){try{let n=new Set([".git",".venv","node_modules",".rapidkit","dist","build","coverage","__pycache__"]),i=new Set;await le(e)&&i.add(e);let t=await a$1(e);for(let o of t){let s=a.isAbsolute(o.path)?o.path:a.join(e,o.path);await le(s)&&i.add(s);}let c=async(o,s)=>{if(s<0)return;let d=await at(o);for(let u of d){if(rt(u,n))continue;let p=a.join(o,u);if(await le(p)){i.add(p);continue}s>0&&await c(p,s-1);}};return await c(e,1),i.size===0&&(await sn(e,3,n)).forEach(s=>i.add(s)),Array.from(i).sort((o,s)=>o.localeCompare(s))}catch{return []}}async function Vt(e,n){let i=[a.join(e,".rapidkit-workspace"),a.join(e,".rapidkit","workspace.json"),a.join(e,".rapidkit","imported-projects.json"),a.join(e,".rapidkit","policies.yml"),a.join(e,".rapidkit","toolchain.lock"),a.join(e,".rapidkit","cache-config.yml")],t=[".rapidkit/project.json",".rapidkit/context.json",".rapidkit/file-hashes.json","package.json","pyproject.toml","composer.json","Gemfile","Gemfile.lock","go.mod","go.sum","pom.xml","requirements.txt","Dockerfile","Makefile",".env",".env.example","src","modules","tests","test",".venv","node_modules"],c=await Promise.all(i.map(qe)),o=await Promise.all(n.map(async s=>{let d=await Promise.all(t.map(u=>qe(a.join(s,u))));return `${s}::${d.join("|")}`}));return [It,...c,...o].join("||")}async function Jt(e,n){try{if(!await r.pathExists(e))return null;let i=await r.readJSON(e);return !i||i.signature!==n||!Array.isArray(i.projects)||typeof i.schemaVersion=="string"&&i.schemaVersion!==et?null:i}catch{return null}}async function qt(e,n){try{await r.ensureDir(a.dirname(e)),await r.writeJSON(e,n,{spaces:2});}catch{}}async function Ut(e,n,i){let t=a.join(e,".rapidkit","reports","doctor-last-run.json");try{await r.ensureDir(a.dirname(t));let c=[];for(let o of n.projects)for(let s of o.issues??[])typeof s=="string"&&s.trim()&&c.push(`${o.name}: ${s.trim()}`);for(let[o,s]of [["python",n.python],["rapidkitCore",n.rapidkitCore]])if(s?.status==="error"){let d=typeof s.message=="string"?s.message:`${o} check failed`;c.push(`${o}: ${d}`);}return await r.writeJSON(t,e$1({schemaVersion:a$2,evidenceType:"workspace",contract:me(),workspacePath:e,workspaceName:n.workspaceName,projectScanCached:n.projectScanCached??false,projectScanSignature:n.projectScanSignature,cachePath:i,healthScore:n.healthScore,system:{python:n.python,poetry:n.poetry,pipx:n.pipx,go:n.go,rapidkitCore:n.rapidkitCore,versions:{core:n.coreVersion,npm:n.npmVersion}},projects:n.projects,summary:{totalProjects:n.projects.length,totalIssues:n.projects.reduce((o,s)=>o+s.issues.length,0),projectAdvisoryWarningProjects:Ce(n.projects),projectAdvisoryWarnings:$e(n.projects),hasSystemErrors:[n.python,n.rapidkitCore].some(o=>o.status==="error"),scopeProvenance:n.scopeProvenance},driftDelta:n.driftDelta,scoreBreakdown:n.scoreBreakdown??[]},{commandId:"checkWorkspaceHealth",exitCode:oe(n.healthScore,{}),generatedAt:new Date().toISOString(),blockers:c.slice(0,12),runId:d$1()}),{spaces:2}),t}catch{return}}async function Fe(){let[e,n,i,t,c]=await Promise.all([zt(),Qt(),Xt(),Yt(),Zt()]);return {python:e,poetry:n,pipx:i,go:t,rapidkitCore:c}}async function zt(){let e=d$2();for(let n of e)try{let{stdout:i}=await execa(n,["--version"],{timeout:3e3}),t=i.match(/Python (\d+\.\d+\.\d+)/);if(t){let c=t[1],[o,s]=c.split(".").map(Number);return o<3||o===3&&s<10?{status:"warn",message:`Python ${c} (requires 3.10+)`,details:`${n} found but version is below minimum requirement`}:{status:"ok",message:`Python ${c}`,details:`Using ${n}`}}}catch{continue}return {status:"error",message:"Python not found",details:"Install Python 3.10+ and ensure it's in PATH"}}async function Qt(){try{let{stdout:e}=await execa("poetry",["--version"],{timeout:3e3}),n=e.match(/Poetry .*version ([\d.]+)/);return n?{status:"ok",message:`Poetry ${n[1]}`,details:"Available for dependency management"}:{status:"warn",message:"Poetry version unknown"}}catch{let e=d$2().map(n=>({cmd:n,args:n==="py"?["-3","-m","poetry","--version"]:["-m","poetry","--version"]}));for(let n of e)try{let{stdout:i}=await execa(n.cmd,n.args,{timeout:3e3,shell:b$1()}),t=i.match(/Poetry .*version ([\d.]+)/)||i.match(/([\d.]+)/);return {status:"ok",message:t?.[1]?`Poetry ${t[1]}`:"Poetry detected",details:`Available via ${n.cmd} ${n.args.join(" ")}`}}catch{continue}for(let n of Ft())try{if(!await r.pathExists(n))continue;let{stdout:i}=await execa(n,["--version"],{timeout:3e3,shell:b$1()}),t=i.match(/Poetry .*version ([\d.]+)/)||i.match(/([\d.]+)/);return {status:"ok",message:t?.[1]?`Poetry ${t[1]}`:"Poetry detected",details:`Available at ${n}`}}catch{continue}return {status:"warn",message:"Poetry not installed",details:"Optional: Install for better dependency management"}}}async function Xt(){try{let{stdout:e}=await execa("pipx",["--version"],{timeout:3e3});return {status:"ok",message:`pipx ${e.trim()}`,details:"Available for global tool installation"}}catch{let e=d$2();for(let n of e)try{let i=n==="py"?["-3","-m","pipx","--version"]:["-m","pipx","--version"],{stdout:t}=await execa(n,i,{timeout:3e3,shell:b$1()});return {status:"ok",message:`pipx ${t.trim()}`,details:`Available via ${n} ${i.join(" ")}`}}catch{continue}return {status:"warn",message:"pipx not installed",details:"Optional: Install for isolated Python tools"}}}async function Yt(){try{let{stdout:e}=await execa("go",["version"],{timeout:3e3}),n=e.match(/go version go(\d+\.\d+(?:\.\d+)?)/);return n?{status:"ok",message:`Go ${n[1]}`,details:"Available for Go/Fiber and Go/Gin projects"}:{status:"ok",message:"Go (version unknown)",details:"go found in PATH"}}catch{return {status:"warn",message:"Go not installed",details:"Optional: Required only for gofiber.standard / gogin.standard projects \u2014 https://go.dev/dl/"}}}async function Zt(){let e=process.env.HOME||process.env.USERPROFILE||"",n=[],i=Dt(e);for(let{location:c,path:o}of i)try{if(await r.pathExists(o)){let{stdout:s,exitCode:d}=await execa(o,["--version"],{timeout:3e3,reject:false});if(d===0&&(s.includes("RapidKit Version")||s.includes("RapidKit"))){let u=s.match(/v?([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);u&&n.push({location:c,path:o,version:u[1]});}}}catch{continue}if(n.length>0){let c=n.filter(s=>s.location!=="Workspace (launcher)");if(c.length>0){let s=At(c),d=s[0].version,u=s.some(m=>m.location==="Workspace (.venv)"),p=s.some(m=>m.location.startsWith("Global (")),f=!u&&p?"Workspace (.venv): not installed (optional). For best project-level performance and isolation, run npx rapidkit workspace run init inside this workspace.":void 0;return {status:"ok",message:`RapidKit Core ${d}`,details:f,paths:s.map(m=>({location:m.location,path:m.path,version:m.version}))}}return {status:"ok",message:`RapidKit Core ${n[0].version}`,details:"Detected via workspace launcher"}}try{let{stdout:c,exitCode:o}=await execa("rapidkit",["--version"],{timeout:3e3,reject:false});if(o===0&&(c.includes("RapidKit Version")||c.includes("RapidKit"))){let s=c.match(/v?([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);if(s)return {status:"ok",message:`RapidKit Core ${s[1]}`,details:"Available via PATH"}}}catch{}try{let{stdout:c,exitCode:o}=await execa("poetry",["run","rapidkit","--version"],{timeout:3e3,reject:false});if(o===0&&(c.includes("RapidKit Version")||c.includes("RapidKit"))){let s=c.match(/v?([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);if(s)return {status:"ok",message:`RapidKit Core ${s[1]}`,details:"Available via Poetry"}}}catch{}let t=d$2();for(let c of t)try{let{stdout:o,exitCode:s}=await execa(c,["-c","import rapidkit_core; print(rapidkit_core.__version__)"],{timeout:3e3,reject:false});if(s===0&&o&&!o.includes("Traceback")&&!o.includes("ModuleNotFoundError")){let d=o.trim();if(d)return {status:"ok",message:`RapidKit Core ${d}`,details:`Available in ${c} environment`}}}catch{continue}return {status:"error",message:"RapidKit Core not installed",details:"Install with: pipx install rapidkit-core"}}async function T(e,n,i){let t=a.join(e,"Dockerfile");n.hasDocker=await r.pathExists(t);let c=a.join(e,"tests"),o=a.join(e,"test"),s=a.join(e,"src","test"),d=await r.pathExists(c)||await r.pathExists(o)||await r.pathExists(s),u=false;if(n.framework==="Go/Fiber"||n.framework==="Go/Gin")try{let p=[{dir:e,depth:0}],f=4,m=new Set([".git",".venv","node_modules","dist","build","vendor"]);for(;p.length>0&&!u;){let g=p.shift();if(!g)break;let h=[];try{h=await r.readdir(g.dir);}catch{continue}for(let y of h){let k=a.join(g.dir,y),b;try{b=await r.stat(k);}catch{continue}if(b.isFile()&&y.endsWith("_test.go")){u=true;break}b.isDirectory()&&g.depth<f&&!m.has(y)&&!y.startsWith(".")&&p.push({dir:k,depth:g.depth+1});}}}catch{}if(n.hasTests=d||u,n.runtimeFamily==="node"&&!n.hasTests&&(n.hasTests=await Ve(e,i)),n.runtimeFamily==="node")n.hasCodeQuality=await Le(e,i);else if(n.framework==="Go/Fiber"||n.framework==="Go/Gin"){let p=a.join(e,".golangci.yml"),f=a.join(e,".golangci.yaml"),m=a.join(e,"Makefile"),g=await r.pathExists(m)&&(await r.readFile(m,"utf8")).includes("golangci-lint");n.hasCodeQuality=await r.pathExists(p)||await r.pathExists(f)||g;}else if(n.runtimeFamily==="python"){let p=a.join(e,"ruff.toml"),f=a.join(e,"pyproject.toml");if(await r.pathExists(f))try{let m=await r.readFile(f,"utf8");n.hasCodeQuality=m.includes("[tool.ruff]")||await r.pathExists(p);}catch{n.hasCodeQuality=await r.pathExists(p);}}else if(n.framework==="Spring Boot"){let p=a.join(e,"pom.xml");if(await r.pathExists(p))try{let f=await r.readFile(p,"utf8");n.hasCodeQuality=f.includes("spotless")||f.includes("checkstyle")||f.includes("pmd")||f.includes("maven-enforcer-plugin");}catch{n.hasCodeQuality=false;}}try{if(n.runtimeFamily==="node"){let{stdout:p}=await execa("npm",["audit","--json"],{cwd:e,reject:false});if(p)try{let m=JSON.parse(p).metadata?.vulnerabilities;m&&(n.vulnerabilities=(m.high||0)+(m.critical||0)+(m.moderate||0));}catch{}}else if(n.runtimeFamily==="python"){let p=a.join(e,".venv"),f$1=f(p);if(await r.pathExists(f$1))try{let{stdout:m}=await execa(f$1,["-m","pip","list","--format=json"],{timeout:5e3,reject:false});if(m){JSON.parse(m);n.vulnerabilities=0;}}catch{}}}catch{}}function I(e,n){e.probes||(e.probes=[]),e.probes.push(n);}async function en(e,n){let i=n.runtimeFamily||"unknown";if(n.projectKind==="backend"||n.projectKind==="generic"){if(i==="node"){let c=await r.pathExists(a.join(e,"package-lock.json"))||await r.pathExists(a.join(e,"pnpm-lock.yaml"))||await r.pathExists(a.join(e,"yarn.lock"));I(n,{id:"adapter-node-lockfile-integrity",label:"Node adapter lockfile integrity",status:c?"pass":"warn",severity:"warn",scope:"project-scoped",reason:c?"Node lockfile detected for deterministic dependency restore.":"No Node lockfile detected (package-lock/yarn.lock/pnpm-lock.yaml).",recommendation:c?void 0:"Commit a lockfile for deterministic installs and CI parity."});let o=await r.pathExists(a.join(e,"src/main.ts"))||await r.pathExists(a.join(e,"src/main.js"))||await r.pathExists(a.join(e,"src/server.ts"))||await r.pathExists(a.join(e,"src/server.js"));I(n,{id:"adapter-node-boot-entrypoint",label:"Node adapter boot entrypoint",status:o?"pass":"warn",severity:"warn",scope:"project-scoped",reason:o?"Boot entrypoint markers detected for service startup path.":"No canonical Node boot entrypoint markers detected.",recommendation:o?void 0:"Define and document service bootstrap entrypoint (main/server)."});return}if(i==="python"){let c=await r.pathExists(a.join(e,"poetry.lock"))||await r.pathExists(a.join(e,"requirements.txt"))||await r.pathExists(a.join(e,"uv.lock"));I(n,{id:"adapter-python-lockfile-integrity",label:"Python adapter dependency integrity",status:c?"pass":"warn",severity:"warn",scope:"project-scoped",reason:c?"Python dependency contract file detected.":"No Python dependency contract file detected (poetry.lock/requirements/uv.lock).",recommendation:c?void 0:"Pin dependency contract for deterministic setup and reproducible CI."});let o=await r.pathExists(a.join(e,"app/main.py"))||await r.pathExists(a.join(e,"main.py"))||await r.pathExists(a.join(e,"manage.py"));I(n,{id:"adapter-python-boot-entrypoint",label:"Python adapter boot entrypoint",status:o?"pass":"warn",severity:"warn",scope:"project-scoped",reason:o?"Python application entrypoint markers detected.":"No Python application entrypoint markers detected.",recommendation:o?void 0:"Expose explicit app/main entrypoint for deterministic boot probes."});return}if(i==="java"){let c=await r.pathExists(a.join(e,"mvnw"))||await r.pathExists(a.join(e,"gradlew"));I(n,{id:"adapter-java-build-wrapper",label:"Java adapter build wrapper",status:c?"pass":"warn",severity:"warn",scope:"project-scoped",reason:c?"Build wrapper detected (mvnw/gradlew).":"No Java build wrapper detected.",recommendation:c?void 0:"Commit mvnw or gradlew for reproducible enterprise pipelines."});return}if(i==="go"){let c=await r.pathExists(a.join(e,"go.sum"));I(n,{id:"adapter-go-module-integrity",label:"Go adapter module integrity",status:c?"pass":"warn",severity:"warn",scope:"project-scoped",reason:c?"go.sum detected for deterministic module verification.":"go.sum missing; module integrity baseline is incomplete.",recommendation:c?void 0:"Generate and commit go.sum in the repository baseline."});}}}async function tn(e,n){let i=[a.join(e,".rapidkit","doctor.adapters.json"),a.join(e,"doctor.adapters.json")];for(let t of i)if(await r.pathExists(t))try{let c=await r.readJSON(t),o=Array.isArray(c?.checks)?c.checks:[];for(let s=0;s<o.length;s+=1){let d=o[s]||{},u=Array.isArray(d.runtimes)?d.runtimes:[];if(u.length>0&&!u.includes(n.runtimeFamily||"unknown"))continue;let p=typeof d.id=="string"&&d.id.trim().length>0?d.id.trim():`adapter-check-${s+1}`,f=typeof d.label=="string"&&d.label.trim().length>0?d.label.trim():p,m=d.severity||"warn",g=Array.isArray(d.anyOfPaths)?d.anyOfPaths.filter(Boolean):[],h=Array.isArray(d.allOfPaths)?d.allOfPaths.filter(Boolean):[],y=g.length===0;for(let L of g)if(await r.pathExists(a.join(e,L))){y=true;break}let k=true;for(let L of h)if(!await r.pathExists(a.join(e,L))){k=false;break}let b=y&&k;I(n,{id:p,label:f,status:b?"pass":m==="error"?"fail":"warn",severity:m,scope:"project-scoped",reason:b?d.passReason||"Custom adapter contract satisfied.":d.failReason||`Custom adapter check failed from ${a.basename(t)}.`,recommendation:d.recommendation});}}catch{I(n,{id:"custom-adapter-config",label:"Custom doctor adapter configuration",status:"warn",severity:"warn",scope:"project-scoped",reason:`Failed to parse ${a.basename(t)}.`,recommendation:"Fix JSON syntax in doctor.adapters.json to re-enable adapter checks."});}}async function B(e,n){if(!(n.projectKind==="backend"||n.projectKind==="generic"))return;let t=a.join(e,".env"),c=a.join(e,".env.example"),o=await r.pathExists(t)||await r.pathExists(c)||await r.pathExists(a.join(e,"config"));I(n,{id:"config-surface",label:"Configuration contract surface",status:o?"pass":"warn",severity:"warn",scope:"project-scoped",reason:o?"Configuration artifacts detected (.env/.env.example/config).":"No explicit configuration contract artifacts detected.",recommendation:o?void 0:"Add .env.example or explicit config contract documentation for deterministic setup."});let s={python:["alembic.ini","migrations","versions"],node:["prisma/schema.prisma","migrations","typeorm.config.ts","typeorm.config.js"],go:["migrations","db/migrations"],java:["src/main/resources/db/migration","src/main/resources/liquibase"],rust:["migrations","sqlx-data.json"],elixir:["priv/repo/migrations"],clojure:["resources/migrations","migrations"],deno:["migrations"],php:["database/migrations","migrations"],ruby:["db/migrate"],dotnet:["Migrations","Data/Migrations"],unknown:["migrations"]},d=n.runtimeFamily||"unknown",u=s[d]||s.unknown,p=false;for(let g of u)if(await r.pathExists(a.join(e,g))){p=true;break}I(n,{id:"migration-surface",label:"Migration/readiness surface",status:p?"pass":"warn",severity:"warn",scope:"project-scoped",reason:p?"Migration or schema evolution markers detected.":"No migration markers detected for this backend runtime.",recommendation:p?void 0:"Add migration tooling baseline (migrations dir or runtime-native migration config)."});let f=["src/health","src/healthcheck","src/main/resources/application.yml","src/main/resources/application.properties","app/health.py","routes/health.ts","routes/health.js"],m=false;for(let g of f)if(await r.pathExists(a.join(e,g))){m=true;break}I(n,{id:"runtime-health-surface",label:"Runtime health probe surface",status:m?"pass":"warn",severity:"warn",scope:"project-scoped",reason:m?"Health endpoint/config markers detected.":"No explicit runtime health endpoint markers detected.",recommendation:m?void 0:"Expose a deterministic health endpoint and keep it covered in verify pack."}),await en(e,n);}async function nn(e,n,i,t){let c=await Je({projectPath:e,detection:t,packageJsonData:i});for(let o of c)I(n,o);}async function _(e,n){let i=[a.join(e,".rapidkit","doctor.probes.json"),a.join(e,"doctor.probes.json")];for(let t of i)if(await r.pathExists(t))try{let c=await r.readJSON(t),o=Array.isArray(c?.probes)?c.probes:[];for(let s=0;s<o.length;s+=1){let d=o[s]||{},u=typeof d.id=="string"&&d.id.trim().length>0?d.id.trim():`custom-probe-${s+1}`,p=typeof d.label=="string"&&d.label.trim().length>0?d.label.trim():u,f=d.severity||"warn",m=Array.isArray(d.anyOfPaths)?d.anyOfPaths.filter(Boolean):[],g=Array.isArray(d.allOfPaths)?d.allOfPaths.filter(Boolean):[],h=m.length===0;for(let b of m)if(await r.pathExists(a.join(e,b))){h=true;break}let y=true;for(let b of g)if(!await r.pathExists(a.join(e,b))){y=false;break}let k=h&&y;I(n,{id:u,label:p,status:k?"pass":f==="error"?"fail":"warn",severity:f,scope:"project-scoped",reason:k?"Custom probe contract satisfied.":`Custom probe failed from ${a.basename(t)}.`,recommendation:d.recommendation});}}catch{I(n,{id:"custom-probe-config",label:"Custom doctor probe configuration",status:"warn",severity:"warn",scope:"project-scoped",reason:`Failed to parse ${a.basename(t)}.`,recommendation:"Fix JSON syntax in doctor.probes.json to re-enable custom probes."});}await tn(e,n);}async function De(e,n={}){let t={name:a.basename(e),path:e,venvActive:false,depsInstalled:false,coreInstalled:false,issues:[],fixCommands:[]},c=n.allowNonRapidkit===true,o=a.join(e,".rapidkit");if(!await r.pathExists(o)){if(!c)return t.issues.push("Not a valid RapidKit project (missing .rapidkit directory)"),t;t.issues.push("Not a RapidKit-managed project (running generic backend diagnostics)");}try{let w=a.join(e,"registry.json");if(await r.pathExists(w)){let v=await r.readJson(w);v.installed_modules&&(t.stats={modules:v.installed_modules.length});}}catch{}try{let{auditProjectModulePaths:w}=await import('./module-layout-NZ43RSC5.js'),v=await w(e);if(v.issues.length>0){for(let C of v.issues)t.issues.push(`${C.message} (${C.slug})`);t.fixCommands=t.fixCommands??[],t.fixCommands.push("npx rapidkit workspace contract verify --strict --json"),t.fixCommands.push("npx rapidkit add module <slug> # reinstall via Core-backed module install");}}catch{}let s=null;try{let w=a.join(o,"project.json");if(await r.pathExists(w)){s=await r.readJson(w);let v=s?.kit_name||s?.kit;v&&(t.kit=v);}}catch{}try{let w=a.join(e,".git");if(await r.pathExists(w)){let{stdout:v}=await execa("git",["log","-1","--format=%cr"],{cwd:e,reject:false});v&&(t.lastModified=v.trim());}else {let v=await r.stat(e),F=Date.now()-v.mtime.getTime(),D=Math.floor(F/(1e3*60*60*24));t.lastModified=D===0?"today":`${D} day${D>1?"s":""} ago`;}}catch{}let d$1=a.join(e,"package.json"),u=a.join(e,"pyproject.toml"),p=a.join(e,"requirements.txt"),f$1=a.join(e,"go.mod"),m=a.join(e,"pom.xml"),g=a.join(e,"build.sbt"),h=a.join(e,"Cargo.toml"),y=a.join(e,"mix.exs"),k=a.join(e,"deps.edn"),b=a.join(e,"project.clj"),L=a.join(e,"deno.json"),K=a.join(e,"deno.jsonc"),U=a.join(e,"bun.lockb"),z=a.join(e,"bun.lock"),V=a.join(e,"composer.json"),ie=a.join(e,"Gemfile"),Q=await r.pathExists(d$1),W=await r.pathExists(u)||await r.pathExists(p),N=await r.pathExists(V),ne=await r.pathExists(ie),ae=await r.pathExists(h),mt=await r.pathExists(y),ft=await r.pathExists(k)||await r.pathExists(b),gt=await r.pathExists(g),ht=await r.pathExists(L)||await r.pathExists(K),ue=s?.runtime==="dotnet";try{ue=ue||await Ue(e,".csproj",3)||await Ue(e,".sln",2);}catch{ue=s?.runtime==="dotnet";}let yt=await r.pathExists(f$1)||s?.runtime==="go"||typeof s?.kit_name=="string"&&(s.kit_name.startsWith("gofiber")||s.kit_name.startsWith("gogin")),Ae=Q&&(await r.pathExists(U)||await r.pathExists(z)||typeof s?.packageManager=="string"&&(s?.packageManager).toLowerCase().startsWith("bun@"));if(yt){G(t,i(e,s??null)),t.isGoProject=true,t.venvActive=true,t.coreInstalled=false;try{await execa("go",["version"],{timeout:3e3});}catch{t.issues.push("Go toolchain not found \u2014 install from https://go.dev/dl/"),t.fixCommands?.push("https://go.dev/dl/");}let w=a.join(e,"go.sum");return await r.pathExists(w)?t.depsInstalled=true:(t.depsInstalled=false,t.issues.push("Go dependencies not downloaded (go.sum missing)"),t.fixCommands?.push(R(e,"go mod tidy"))),await T(e,t),await B(e,t),await _(e,t),t}if(await r.pathExists(m)||s?.runtime==="java"||typeof s?.kit_name=="string"&&s.kit_name.startsWith("springboot")){G(t,i(e,s??null)),t.venvActive=true,t.coreInstalled=false;let w=await r.pathExists(m),v=await r.pathExists(a.join(e,"build.gradle"))||await r.pathExists(a.join(e,"build.gradle.kts")),C=await r.pathExists(a.join(e,"mvnw"))||await r.pathExists(a.join(e,"mvnw.cmd")),F=await r.pathExists(a.join(e,"gradlew"))||await r.pathExists(a.join(e,"gradlew.bat"));try{await execa("java",["-version"],{timeout:3e3,reject:false});}catch{t.issues.push("Java runtime not found \u2014 install JDK 21+ and ensure java is on PATH"),t.fixCommands?.push("https://adoptium.net/");}if(w){if(!C)try{await execa("mvn",["-version"],{timeout:3e3,reject:false});}catch{t.issues.push("Maven not found \u2014 install Maven 3.9+ or add Maven Wrapper"),t.fixCommands?.push("https://maven.apache.org/install.html");}}else if(v&&!F)try{await execa("gradle",["--version"],{timeout:3e3,reject:false});}catch{t.issues.push("Gradle not found \u2014 install Gradle 8+ or add Gradle Wrapper"),t.fixCommands?.push("https://gradle.org/install/");}let D=a.join(e,"target"),A=a.join(e,"build","libs"),H=a.join(e,".rapidkit","cache","java","m2"),j=a.join(e,".rapidkit","cache","java","gradle");t.depsInstalled=await r.pathExists(D)||await r.pathExists(A)||await r.pathExists(H)||await r.pathExists(j),t.depsInstalled||(t.issues.push("Java dependencies are not warmed or built yet"),t.fixCommands?.push(R(e,"rapidkit init")));let P=a.join(e,".env");if(t.hasEnvFile=await r.pathExists(P),!t.hasEnvFile){let X=a.join(e,".env.example");await r.pathExists(X)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(q(e)));}let J=a.join(e,"src","main","resources","application.yml");if(await r.pathExists(J))try{let X=await r.readFile(J,"utf-8");/include:\s*[^\n]*health/i.test(X)||/management:\s*[\s\S]*endpoint:\s*[\s\S]*health:/i.test(X)||(t.issues.push("Actuator health endpoint exposure is not clearly configured in application.yml"),t.fixCommands?.push(R(e,"Ensure management.endpoints.web.exposure.include contains health in src/main/resources/application.yml")));}catch{t.issues.push("Unable to read application.yml for Spring Actuator health checks");}return await T(e,t),await B(e,t),await _(e,t),t}if(ae){G(t,i(e,s??null)),t.venvActive=true,t.coreInstalled=false;let w=a.join(e,"Cargo.lock"),v=a.join(e,"target");t.depsInstalled=await r.pathExists(w)||await r.pathExists(v),t.depsInstalled||(t.issues.push("Rust dependencies are not resolved yet (Cargo.lock/target missing)"),t.fixCommands?.push(R(e,"cargo fetch")));let C=a.join(e,".env");if(t.hasEnvFile=await r.pathExists(C),!t.hasEnvFile){let F=a.join(e,".env.example");await r.pathExists(F)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(q(e)));}return await T(e,t),await B(e,t),await _(e,t),t}if(mt){G(t,i(e,s??null)),t.venvActive=true,t.coreInstalled=false;let w=a.join(e,"mix.lock"),v=a.join(e,"deps");t.depsInstalled=await r.pathExists(w)||await r.pathExists(v),t.depsInstalled||(t.issues.push("Elixir dependencies not installed (mix.lock/deps missing)"),t.fixCommands?.push(R(e,"mix deps.get")));let C=a.join(e,".env");if(t.hasEnvFile=await r.pathExists(C),!t.hasEnvFile){let F=a.join(e,".env.example");await r.pathExists(F)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(q(e)));}return await T(e,t),await B(e,t),await _(e,t),t}if(ft){G(t,i(e,s??null)),t.venvActive=true,t.coreInstalled=false;let w=a.join(e,".cpcache"),v=a.join(e,"target"),C=await r.pathExists(k)||await r.pathExists(b);return t.depsInstalled=await r.pathExists(w)||await r.pathExists(v)||C,t.depsInstalled||(t.issues.push("Clojure dependency cache not initialized"),t.fixCommands?.push(R(e,"clojure -P"))),await T(e,t),await B(e,t),await _(e,t),t}if(gt){G(t,i(e,s??null)),t.venvActive=true,t.coreInstalled=false;let w=a.join(e,"target");t.depsInstalled=await r.pathExists(w),t.depsInstalled||(t.issues.push("Scala build artifacts missing (run dependency/build warmup)"),t.fixCommands?.push(R(e,"sbt compile")));let v=a.join(e,".env");if(t.hasEnvFile=await r.pathExists(v),!t.hasEnvFile){let C=a.join(e,".env.example");await r.pathExists(C)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(q(e)));}return await T(e,t),await B(e,t),await _(e,t),t}if(ht){G(t,i(e,s??null)),t.venvActive=true,t.coreInstalled=false,t.depsInstalled=true;let w=a.join(e,".env");if(t.hasEnvFile=await r.pathExists(w),!t.hasEnvFile){let v=a.join(e,".env.example");await r.pathExists(v)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(q(e)));}return await T(e,t),await B(e,t),await _(e,t),t}if(Q){let w=null;try{w=await r.readJson(d$1);}catch{w=null;}let v={...w?.dependencies??{},...w?.devDependencies??{}},C=w?.scripts??{},F=typeof s?.kit_name=="string"?s.kit_name.toLowerCase():typeof s?.kit=="string"?s.kit.toLowerCase():"",D=d(e,s),A=Wt({dependencies:v,scripts:C,kitName:F});if(Ae)pe(t,"Bun","high");else {let j=i(e,s??null);j.key==="nestjs"||j.key==="express"||j.key==="fastify"||j.key==="koa"?G(t,j):D.key!=="unknown"?Kt(t,D):j.key!=="unknown"&&j.key!=="node"?G(t,j):pe(t,A.framework,A.confidence);}t.venvActive=true;let H=a.join(e,"node_modules");if(await r.pathExists(H))try{let P=(await r.readdir(H)).filter(J=>!J.startsWith(".")&&!J.startsWith("_"));t.depsInstalled=P.length>0;}catch{t.depsInstalled=false;}if(t.depsInstalled||(t.issues.push("Dependencies not installed (node_modules empty or missing)"),t.fixCommands?.push(R(e,Ae?"bun install":"rapidkit init"))),t.coreInstalled=false,t.projectKind==="frontend"){let j=[".env",".env.local",".env.development",".env.development.local",".env.production",".env.production.local"];if((await Promise.all(j.map(J=>r.pathExists(a.join(e,J))))).some(Boolean))t.hasEnvFile=true;else {let J=a.join(e,".env.example");await r.pathExists(J)&&(t.hasEnvFile=false,t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(q(e)));}}else {let j=a.join(e,".env");if(t.hasEnvFile=await r.pathExists(j),!t.hasEnvFile){let P=a.join(e,".env.example");await r.pathExists(P)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(q(e)));}}if(t.projectKind==="frontend")t.modulesHealthy=await je(e),t.missingModules=[];else {let j=a.join(e,"src");if(t.modulesHealthy=true,t.missingModules=[],await r.pathExists(j))try{let P=await r.readdir(j);t.modulesHealthy=P.length>0;}catch{t.modulesHealthy=false;}}return await T(e,t,w),t.projectKind==="frontend"?await nn(e,t,w,D.key!=="unknown"?D:d(e,s)):await B(e,t),await _(e,t),t}if(W){let w=await Ot(e);pe(t,w.framework,w.confidence);let v=a.join(e,".venv");if(await r.pathExists(v)){t.venvActive=true;let A=f(v);if(await r.pathExists(A)){try{let{stdout:P}=await execa(A,["-c","import rapidkit_core; print(rapidkit_core.__version__)"],{timeout:2e3});t.coreInstalled=true,t.coreVersion=P.trim();}catch{t.coreInstalled=false;}let H="fastapi";t.framework==="Django"?H="django":t.framework==="Flask"?H="flask":t.framework==="Python"&&(H="");let j=true;if(H)try{await execa(A,["-c",`import ${H}`],{timeout:2e3}),t.depsInstalled=true,j=false;}catch{j=true;}if(j)try{let P=a.join(v,"lib");if(await r.pathExists(P)){let X=(await r.readdir(P)).find(re=>re.startsWith("python"));if(X){let re=a.join(P,X,"site-packages");if(await r.pathExists(re)){let kt=(await r.readdir(re)).filter(ge=>!ge.startsWith("_")&&!ge.includes("dist-info")&&!["pip","setuptools","wheel","pkg_resources"].includes(ge));t.depsInstalled=kt.length>0;}}}t.depsInstalled||(t.issues.push("Dependencies not installed"),t.fixCommands?.push(R(e,"rapidkit init")));}catch{t.issues.push("Could not verify dependency installation");}}else t.issues.push("Virtual environment exists but Python executable not found");}else t.issues.push("Virtual environment not created"),t.fixCommands?.push(R(e,"rapidkit init"));let C=a.join(e,".env");if(t.hasEnvFile=await r.pathExists(C),!t.hasEnvFile){let A=a.join(e,".env.example");await r.pathExists(A)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(q(e)));}let F=a.join(e,"src"),D=a.join(e,"modules");if(t.modulesHealthy=true,t.missingModules=[],await r.pathExists(F)){let A=a.join(F,"__init__.py");await r.pathExists(A)||(t.modulesHealthy=false,t.missingModules.push("src/__init__.py"));}if(await r.pathExists(D))try{let A=await at(D);for(let H of A){let j=a.join(D,H,"__init__.py");await r.pathExists(j)||(t.modulesHealthy=false,t.missingModules.push(`modules/${H}/__init__.py`));}}catch{}return !t.modulesHealthy&&t.missingModules.length>0&&t.issues.push(`Missing module init files: ${t.missingModules.join(", ")}`),await T(e,t),await B(e,t),await _(e,t),t}if(N){G(t,i(e,s??null)),t.venvActive=true,t.coreInstalled=false;let w=a.join(e,"vendor");t.depsInstalled=await r.pathExists(w),t.depsInstalled||(t.issues.push("PHP dependencies not installed (vendor missing)"),t.fixCommands?.push(R(e,"composer install")));let v=a.join(e,".env");if(t.hasEnvFile=await r.pathExists(v),!t.hasEnvFile){let C=a.join(e,".env.example");await r.pathExists(C)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(q(e)));}return await T(e,t),await B(e,t),await _(e,t),t}if(ne){G(t,i(e,s??null)),t.venvActive=true,t.coreInstalled=false;let w=await r.pathExists(a.join(e,"Gemfile.lock")),v=await r.pathExists(a.join(e,"vendor","bundle"));t.depsInstalled=w||v,t.depsInstalled||(t.issues.push("Ruby dependencies not installed (Gemfile.lock/vendor missing)"),t.fixCommands?.push(R(e,"bundle install")));let C=a.join(e,".env");return t.hasEnvFile=await r.pathExists(C),await T(e,t),await B(e,t),await _(e,t),t}if(ue){G(t,i(e,s??null)),t.venvActive=true,t.coreInstalled=false;let w=a.join(e,"obj"),v=a.join(e,"src","obj"),C=a.join(e,"packages.lock.json");t.depsInstalled=await r.pathExists(w)||await r.pathExists(v)||await r.pathExists(C),t.depsInstalled||(t.issues.push(".NET restore/build artifacts not found"),t.fixCommands?.push(R(e,"dotnet restore")));let F=a.join(e,".env");return t.hasEnvFile=await r.pathExists(F),await T(e,t),await B(e,t),await _(e,t),t}return pe(t,"Unknown","low"),t.issues.push("Unknown project type (no recognized runtime marker files)"),await T(e,t),await B(e,t),await _(e,t),t}async function at(e){try{return (await r.readdir(e,{withFileTypes:true})).filter(i=>i.isDirectory()).map(i=>i.name)}catch{try{let n=await r.readdir(e),i=[];for(let t of n)try{(await r.stat(a.join(e,t))).isDirectory()&&i.push(t);}catch{continue}return i}catch{return []}}}async function Ue(e,n,i){let t=[{dir:e,depth:0}],c=new Set([".git",".rapidkit","node_modules","bin","obj","target"]);for(;t.length>0;){let o=t.shift();if(!o||o.depth>i)continue;let s;try{s=await r.readdir(o.dir,{withFileTypes:true});}catch{continue}for(let d of s){if(d.isFile()&&d.name.toLowerCase().endsWith(n.toLowerCase()))return true;d.isDirectory()&&!c.has(d.name)&&t.push({dir:a.join(o.dir,d.name),depth:o.depth+1});}}return false}async function le(e){let n=a.join(e,".rapidkit");if(!await r.pathExists(n))return false;let i=["project.json","context.json","file-hashes.json"];for(let t of i)if(await r.pathExists(a.join(n,t)))return true;return false}function rt(e,n){if(n.has(e))return true;let i=e.toLowerCase();return !!(i==="dist"||i.startsWith("dist-")||i.startsWith("dist_")||i==="build"||i.startsWith("build-")||i.startsWith("build_"))}async function sn(e,n,i){let t=new Set,c=[{dir:e,depth:0}];for(;c.length>0;){let o=c.shift();if(!o)break;try{let s=await r.readdir(o.dir);for(let d of s){if(rt(d,i))continue;let u=a.join(o.dir,d),p;try{p=await r.stat(u);}catch{continue}if(p.isDirectory()){if(await le(u)){t.add(u);continue}o.depth<n&&c.push({dir:u,depth:o.depth+1});}}}catch{continue}}return Array.from(t)}async function de(e){let n=a.resolve(e),i=a.parse(n).root;for(;;){if(await rn(n))return n;if(n===i)break;n=a.dirname(n);}return null}async function on(e){let n=a.resolve(e),i=await de(n),t=i??a.parse(n).root;for(;;){if(await le(n)||await an(n)&&(!i||n!==i))return n;if(n===t)break;n=a.dirname(n);}return null}function ze(e){let n=a.resolve(e);return process.platform==="darwin"?n.replace(/^\/private(?=\/var\/)/,""):n}async function an(e){let n=["package.json","pyproject.toml","requirements.txt","go.mod","pom.xml","build.sbt","Cargo.toml","mix.exs","deps.edn","project.clj","deno.json","deno.jsonc","composer.json","Gemfile"];for(let i of n)if(await r.pathExists(a.join(e,i)))return true;return false}async function rn(e){let n=[a.join(e,".rapidkit-workspace"),a.join(e,".rapidkit","workspace-marker.json"),a.join(e,".rapidkit","config.json")];return Promise.all(n.map(i=>r.pathExists(i))).then(i=>i.some(Boolean))}function ct(e,n){let i=0,t=0,c=0;return e.forEach(s=>{s.status==="ok"?i++:s.status==="warn"?t++:s.status==="error"&&c++;}),n.forEach(s=>{let d=ee(s),u=s.isGoProject?s.issues.length===0&&s.depsInstalled:s.issues.length===0&&s.venvActive&&s.depsInstalled;if(s.issues.length>0||d>0||!u){t++;return}i++;}),{total:i+t+c,passed:i,warnings:t,errors:c}}function lt(e,n,i={}){let t=[];for(let o of e)t.push({id:o.id,label:o.label,status:o.result.status,scope:"host-system",policyRuleId:"system-status-derived",reason:o.result.details||o.result.message});let c=[...n].sort((o,s)=>{let d=`${o.path||""}|${o.name||""}`.toLowerCase(),u=`${s.path||""}|${s.name||""}`.toLowerCase();return d.localeCompare(u)});for(let o of c){let s=o.issues.length>0,d=ee(o),u=s||d>0?"warn":"ok",p=s?`${o.issues.length} blocking issue(s)`:d>0?`${d} advisory warning(s)`:"Project checks passed";t.push({id:`project:${o.name}`,label:`Project ${o.name}`,status:u,scope:"project-scoped",policyRuleId:s?"project-blocking-issues":d>0?"project-advisory-warnings":"project-checks-passed",reason:p});}if(i.includeWorkspaceAggregateRules){let o=n.reduce((u,p)=>u+p.issues.length,0),s=$e(n),d=e.filter(u=>u.result.status==="error").length;t.push({id:"workspace:projects-discovered",label:"Workspace projects discovered",status:n.length>0?"ok":"warn",scope:"workspace-aggregate",policyRuleId:"workspace-project-discovery",reason:n.length>0?`${n.length} project(s) discovered for workspace analysis.`:"No projects discovered for workspace analysis."}),t.push({id:"workspace:system-error-gate",label:"Workspace system error gate",status:d>0?"error":"ok",scope:"workspace-aggregate",policyRuleId:"workspace-system-error-gate",reason:d>0?`${d} system requirement gate(s) failed.`:"All system requirement gates passed."}),t.push({id:"workspace:blocking-issues-gate",label:"Workspace blocking issues gate",status:o>0?"warn":"ok",scope:"workspace-aggregate",policyRuleId:"workspace-blocking-issues-gate",reason:o>0?`${o} blocking project issue(s) detected.`:"No blocking project issues detected."}),t.push({id:"workspace:advisory-warnings-gate",label:"Workspace advisory warnings gate",status:s>0?"warn":"ok",scope:"workspace-aggregate",policyRuleId:"workspace-advisory-warning-gate",reason:s>0?`${s} advisory warning(s) detected.`:"No advisory warnings detected."});}return t}async function Qe(e$1,n=true){let i=a.basename(e$1);try{let g=a.join(e$1,".rapidkit-workspace");await r.pathExists(g)&&(i=(await r.readJSON(g)).name||i);}catch{try{let g=a.join(e$1,".rapidkit","config.json");i=(await r.readJSON(g)).workspace_name||i;}catch{}}let[t,c]=await Promise.all([Fe(),Lt(e$1)]),o={workspacePath:e$1,workspaceName:i,python:t.python,poetry:t.poetry,pipx:t.pipx,go:t.go,rapidkitCore:t.rapidkitCore,projects:[]};e.debug(`Workspace scan found ${c.length} project(s)`);let s=await Vt(e$1,c),d=a.join(e$1,".rapidkit","reports","doctor-workspace-cache.json"),u=n?await Jt(d,s):null;if(u){o.projects=u.projects;for(let g of o.projects)Ee(g,g.path);o.projectScanCached=true,e.debug(`Workspace project health cache hit: ${d}`);}else try{let g=await Promise.all(c.map(h=>De(h)));for(let h of g)Ee(h,h.path);o.projects=g,o.projectScanCached=false,await qt(d,{schemaVersion:et,signature:s,generatedAt:new Date().toISOString(),projects:g}),e.debug(`Workspace project health cache refreshed: ${d}`);}catch(g){e.debug(`Failed to scan workspace projects: ${g}`);}o.projectScanSignature=s,o.projectScanCachePath=d;let p=[o.python,o.poetry,o.pipx,o.go,o.rapidkitCore];if(o.healthScore=ct(p,o.projects),o.scoreBreakdown=lt([{id:"system-python",label:"Python",result:o.python},{id:"system-poetry",label:"Poetry",result:o.poetry},{id:"system-pipx",label:"pipx",result:o.pipx},{id:"system-go",label:"Go",result:o.go},{id:"system-rapidkit-core",label:"RapidKit Core",result:o.rapidkitCore}],o.projects,{includeWorkspaceAggregateRules:true}),o.scopeProvenance=ot(o.scoreBreakdown),o.rapidkitCore.status==="ok"){let g=o.rapidkitCore.message.match(/([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);g&&(o.coreVersion=g[1]);}let f=a.join(e$1,".rapidkit","reports","doctor-last-run.json"),m=await nt(f,"workspace");return o.driftDelta=Ht(m,o),o.evidencePath=await Ut(e$1,o,u?d:null),o}function Xe(e){return {name:e.name,path:e.path,framework:e.framework,frameworkKey:e.frameworkKey,importStack:e.importStack,runtimeFamily:e.runtimeFamily,projectKind:e.projectKind,supportTier:e.supportTier,frameworkConfidence:e.frameworkConfidence,kit:e.kit,venvActive:e.venvActive,depsInstalled:e.depsInstalled,hasEnvFile:e.hasEnvFile,modulesHealthy:e.modulesHealthy,missingModules:e.missingModules,hasTests:e.hasTests,hasDocker:e.hasDocker,hasCodeQuality:e.hasCodeQuality,vulnerabilities:e.vulnerabilities,coreInstalled:e.coreInstalled,coreVersion:e.coreVersion,lastModified:e.lastModified,stats:e.stats,issues:e.issues,fixCommands:e.fixCommands,probes:e.probes,commandCapabilities:e.commandCapabilities}}async function cn(e,n){let i=e||n.projectPath,t=a.join(i,".rapidkit","reports","doctor-project-last-run.json");try{await r.ensureDir(a.dirname(t));let c=n.project.issues.filter(o=>typeof o=="string"&&o.trim().length>0).slice(0,12);return await r.writeJSON(t,e$1({schemaVersion:b$2,evidenceType:"project",contract:me(),workspacePath:e||null,projectPath:n.projectPath,projectName:n.projectName,healthScore:n.healthScore,system:{python:n.python,poetry:n.poetry,pipx:n.pipx,go:n.go,rapidkitCore:n.rapidkitCore},project:n.project,driftDelta:n.driftDelta,summary:{scopeProvenance:n.scopeProvenance},scoreBreakdown:n.scoreBreakdown??[]},{commandId:"projectDoctor",exitCode:oe(n.healthScore,{}),generatedAt:new Date().toISOString(),blockers:c,runId:d$1()}),{spaces:2}),t}catch{return}}async function ln(e){let n=await de(e),i=await Fe(),t=await De(e,{allowNonRapidkit:true});Ee(t,e);let c=ct([i.python,i.poetry,i.pipx,i.go,i.rapidkitCore],[t]),o={workspacePath:n||void 0,projectPath:e,projectName:a.basename(e),python:i.python,poetry:i.poetry,pipx:i.pipx,go:i.go,rapidkitCore:i.rapidkitCore,project:t,healthScore:c};o.scoreBreakdown=lt([{id:"system-python",label:"Python",result:o.python},{id:"system-poetry",label:"Poetry",result:o.poetry},{id:"system-pipx",label:"pipx",result:o.pipx},{id:"system-go",label:"Go",result:o.go},{id:"system-rapidkit-core",label:"RapidKit Core",result:o.rapidkitCore}],[o.project]),o.scopeProvenance=ot(o.scoreBreakdown);let s=n||e,d=a.join(s,".rapidkit","reports","doctor-project-last-run.json"),u=await nt(d,"project");return o.driftDelta=Mt(u,o),o.evidencePath=await cn(n||void 0,o),o}function $(e,n){let i=e.status==="ok"?"\u2705":e.status==="warn"?"\u26A0\uFE0F":"\u274C",t=e.status==="ok"?l.green:e.status==="warn"?l.yellow:l.red;console.log(`${i} ${l.bold(n)}: ${t(e.message)}`),e.paths&&e.paths.length>0&&e.paths.forEach(c=>{let o=c.version?l.cyan(` -> ${c.version}`):"";console.log(` ${l.cyan("\u2022")} ${l.gray(c.location)}: ${l.dim(c.path)}${o}`);}),e.details&&console.log(` ${l.gray(e.details)}`);}function Ye(e){let n=e.issues.length>0,i=n?"\u26A0\uFE0F":"\u2705",t=n?l.yellow:l.green;if(console.log(`
1
+ import {b}from'./chunk-3YLMCP3V.js';import {c,a as a$2,b as b$2}from'./chunk-NFUXULIF.js';import {q as q$1}from'./chunk-YBS2HGO3.js';import {f as f$2,e}from'./chunk-4Q2ZZKGB.js';import {i,d,b as b$3,a as a$5}from'./chunk-UZW5QFRW.js';import {f}from'./chunk-6G2KSHP6.js';import {b as b$1,f as f$1,d as d$1,a as a$4,k,g,i as i$1}from'./chunk-Z5LKRG57.js';import {a as a$3}from'./chunk-2FIX2MDC.js';import {a as a$1}from'./chunk-HHJAANUC.js';import l from'chalk';import {execa}from'execa';import r from'fs-extra';import a from'path';var bt=[".eslintrc.js",".eslintrc.cjs",".eslintrc.json",".eslintrc.yaml",".eslintrc.yml","eslint.config.js","eslint.config.mjs","eslint.config.cjs"],xt=["tests","test","src/test","__tests__","e2e","playwright","cypress"],jt=["vitest.config.ts","vitest.config.js","vitest.config.mjs","jest.config.js","jest.config.ts","jest.config.mjs","playwright.config.ts","playwright.config.js","cypress.config.js","cypress.config.ts"],Ct=["src","app","pages"],Et=["dev","build","test","lint"];function Oe(e){let n=e?.scripts;if(!n||typeof n!="object"||Array.isArray(n))return {};let i={};for(let[t,c]of Object.entries(n))typeof c=="string"&&c.trim().length>0&&(i[t]=c);return i}async function Le(e,n){for(let c of bt)if(await r.pathExists(a.join(e,c)))return true;let i=n??(await r.pathExists(a.join(e,"package.json"))?await r.readJson(a.join(e,"package.json")):null);if(!i)return false;if(i.eslintConfig)return true;let t={...i.dependencies??{},...i.devDependencies??{}};return !!(t.eslint||t["@eslint/js"]||t["@eslint/eslintrc"])}async function Ve(e,n){for(let c of xt)if(await r.pathExists(a.join(e,c)))return true;for(let c of jt)if(await r.pathExists(a.join(e,c)))return true;let i=Oe(n);if(i.test||i["test:unit"]||i["test:e2e"]||i["test:ci"]||i["test:watch"])return true;let t={...n?.dependencies??{},...n?.devDependencies??{}};return t.vitest||t.jest||t["@playwright/test"]||t.cypress?true:await Pt(e)}async function Pt(e){let n=["src","app","pages","components"],i=/\.(test|spec)\.(tsx?|jsx?|vue|svelte)$/i,c=new Set(["node_modules",".git","dist","build",".next","coverage",".turbo"]);for(let o of n){let s=a.join(e,o);if(!await r.pathExists(s))continue;let d=[{dir:s,depth:0}];for(;d.length>0;){let u=d.shift();if(!u)break;let p=[];try{p=await r.readdir(u.dir);}catch{continue}for(let f of p){let m=a.join(u.dir,f);if(i.test(f))return true;if(!(u.depth>=3||c.has(f)||f.startsWith(".")))try{(await r.stat(m)).isDirectory()&&d.push({dir:m,depth:u.depth+1});}catch{continue}}}}return false}async function je(e){for(let n of Ct){let i=a.join(e,n);if(await r.pathExists(i))try{if((await r.readdir(i)).some(c=>!c.startsWith(".")))return true}catch{continue}}return false}function St(e){let n=e.key;return b$3(n).key}function $t(e,n,i){return a$5(n,i).some(c=>!!e[c])}async function Je(e){let{projectPath:n,detection:i,packageJsonData:t}=e,c=St(i),o=b$3(c),s=Oe(t),d=[],u=await r.pathExists(a.join(n,"package-lock.json"))||await r.pathExists(a.join(n,"pnpm-lock.yaml"))||await r.pathExists(a.join(n,"yarn.lock"))||await r.pathExists(a.join(n,"bun.lockb"));d.push({id:"frontend-lockfile-integrity",label:"Frontend lockfile integrity",status:u?"pass":"warn",severity:"warn",scope:"project-scoped",reason:u?"Node lockfile detected for deterministic dependency restore.":"No Node lockfile detected (package-lock/yarn.lock/pnpm-lock.yaml/bun.lockb).",recommendation:u?void 0:"Commit a lockfile for deterministic installs and CI parity."});let p=await r.pathExists(a.join(n,"tsconfig.json")),f=await r.pathExists(a.join(n,"jsconfig.json")),m=p||f;d.push({id:"frontend-typescript-surface",label:"TypeScript project surface",status:m?"pass":"warn",severity:"warn",scope:"project-scoped",reason:m?p?"tsconfig.json detected.":"jsconfig.json detected.":"No tsconfig.json or jsconfig.json detected.",recommendation:m?void 0:"Add tsconfig.json (or jsconfig.json) for typed frontend builds and IDE parity."});let g=o.fileHints.length>0&&o.fileHints.some(y=>r.pathExistsSync(a.join(n,y)));d.push({id:"frontend-framework-config",label:`${o.displayName} config surface`,status:g?"pass":"warn",severity:"warn",scope:"project-scoped",reason:g?`${o.displayName} configuration artifacts detected.`:`No ${o.displayName} config markers detected (${o.fileHints.join(", ")||"n/a"}).`,recommendation:g?void 0:"Keep framework config files in-repo for reproducible dev/build behavior."});for(let y of Et){let k=$t(s,c,y),b=y==="dev"||y==="build";d.push({id:`frontend-script-${y}`,label:`${y} script surface`,status:k?"pass":b?"fail":"warn",severity:b?"error":"warn",scope:"project-scoped",reason:k?`package.json exposes a ${y} script for ${o.displayName}.`:`No ${y} script detected for ${o.displayName}.`,recommendation:k?void 0:`Add a "${a$5(c,y)[0]??y}" script to package.json.`});}let h=await je(n);return d.push({id:"frontend-source-tree",label:"Frontend source tree",status:h?"pass":"warn",severity:"warn",scope:"project-scoped",reason:h?"Application source directories detected (src/app/pages).":"No frontend source directories detected under src/, app/, or pages/.",recommendation:h?void 0:"Ensure the scaffolded application tree exists before running lifecycle commands."}),d}function Rt(e){return [...new Set(e.filter(n=>n&&n.trim().length>0))]}function Ft(){let e=k().map(t=>a.join(t,a$4()?"poetry.exe":"poetry")),n=a$4()?[a.join(process.env.APPDATA||"","Python","Scripts","poetry.exe"),a.join(process.env.USERPROFILE||"","AppData","Roaming","Python","Scripts","poetry.exe")]:[],i=a$4()?[]:["/usr/local/bin/poetry","/usr/bin/poetry"];return Rt([...e,...n,...i])}function Dt(e){let n=k().map(u=>({location:"Global (user-local)",path:a.join(u,a$4()?"rapidkit.exe":"rapidkit")})),i=[{location:"Global (pipx)",path:a.join(e,".local","bin","rapidkit")},{location:"Global (pipx)",path:a.join(e,"AppData","Roaming","Python","Scripts","rapidkit.exe")},{location:"Global (pyenv)",path:a.join(e,".pyenv","shims","rapidkit")},{location:"Global (system)",path:"/usr/local/bin/rapidkit"},{location:"Global (system)",path:"/usr/bin/rapidkit"}],t=g(a.join(process.cwd(),".venv")),c=i$1(process.cwd()),o=[{location:"Workspace (.venv)",path:t},...c.map(u=>({location:"Workspace (launcher)",path:u}))],s=[...n,...i,...o],d=new Set;return s.filter(u=>d.has(u.path)?false:(d.add(u.path),true))}function At(e){let n=new Map([["Workspace (.venv)",0],["Global (user-local)",1],["Global (pipx)",2],["Global (pyenv)",3],["Global (system)",4]]);return [...e].sort((i,t)=>{let c=n.get(i.location)??Number.MAX_SAFE_INTEGER,o=n.get(t.location)??Number.MAX_SAFE_INTEGER;return c!==o?c-o:i.path.localeCompare(t.path)})}function ee(e){let n=0,i=e.issues.some(t=>t.toLowerCase().includes("environment file missing"));return e.hasEnvFile===false&&!i&&(n+=1),typeof e.vulnerabilities=="number"&&e.vulnerabilities>0&&(n+=1),n}function Ce(e){return e.filter(n=>ee(n)>0).length}function $e(e){return e.reduce((n,i)=>n+ee(i),0)}var It="doctor-project-scan-v2",et="doctor-workspace-cache-v2",Nt=Object.freeze({version:"doctor-evidence-v1",scoringPolicyVersion:"doctor-score-policy-v1",generatedBy:"rapidkit-npm",deterministicScoreBreakdown:true,scopeModel:"workspace-aggregate-or-project-scoped"});function me(){return {...Nt}}function fe(e){return !e||e.total<=0?null:Math.round(e.passed/e.total*100)}function tt(e){return typeof e=="number"?e:Array.isArray(e)?e.length:0}async function nt(e,n){try{if(!await r.pathExists(e))return null;let i=await r.readJSON(e);return c(i,n)?i:null}catch{return null}}function st(e,n){if(!e?.system)return [];let i=[{id:"python",current:n.python},{id:"poetry",current:n.poetry},{id:"pipx",current:n.pipx},{id:"go",current:n.go},{id:"rapidkitCore",current:n.rapidkitCore}],t=[];for(let c of i){let o=e.system?.[c.id]?.status;!o||o===c.current.status||t.push({id:c.id,from:o,to:c.current.status});}return t}function Ht(e,n){let i=new Map;for(let g of n.projects)i.set(g.path||g.name,g.issues.length);if(!e)return {baselineAvailable:false,newIssueCount:0,resolvedIssueCount:0,netIssueDelta:0,scoreDeltaPercent:null,systemStatusChanges:[],regressedProjects:[],improvedProjects:[]};let t=Array.isArray(e.projects)?e.projects:[],c=new Map;for(let g of t){let h=g.path||g.name;h&&c.set(h,tt(g.issues));}let o=0,s=0,d=new Set,u=new Set,p=new Set([...Array.from(c.keys()),...Array.from(i.keys())]);for(let g of p){let h=c.get(g)??0,y=i.get(g)??0;y>h?(o+=y-h,d.add(g)):y<h&&(s+=h-y,u.add(g));}let f=fe(e.healthScore),m=fe(n.healthScore);return {baselineAvailable:true,previousGeneratedAt:e.generatedAt,newIssueCount:o,resolvedIssueCount:s,netIssueDelta:o-s,scoreDeltaPercent:f===null||m===null?null:m-f,systemStatusChanges:st(e,{python:n.python,poetry:n.poetry,pipx:n.pipx,go:n.go,rapidkitCore:n.rapidkitCore}),regressedProjects:Array.from(d).sort(),improvedProjects:Array.from(u).sort()}}function Mt(e,n){if(!e)return {baselineAvailable:false,newIssueCount:0,resolvedIssueCount:0,netIssueDelta:0,scoreDeltaPercent:null,systemStatusChanges:[],regressedProjects:[],improvedProjects:[]};let i=tt(e.project?.issues),t=n.project.issues.length,c=Math.max(t-i,0),o=Math.max(i-t,0),s=fe(e.healthScore),d=fe(n.healthScore),u=n.project.path||n.project.name;return {baselineAvailable:true,previousGeneratedAt:e.generatedAt,newIssueCount:c,resolvedIssueCount:o,netIssueDelta:c-o,scoreDeltaPercent:s===null||d===null?null:d-s,systemStatusChanges:st(e,{python:n.python,poetry:n.poetry,pipx:n.pipx,go:n.go,rapidkitCore:n.rapidkitCore}),regressedProjects:c>0?[u]:[],improvedProjects:o>0?[u]:[]}}function ot(e){let n=e??[],i=0,t=0;for(let s of n){if(s.scope==="project-scoped"){i+=1;continue}(s.scope==="workspace-aggregate"||s.scope==="host-system")&&(t+=1);}let c=i>0&&t>0?1:0,o=c>0?"mixed":i>0?"scoped":t>0?"aggregated":"unknown";return {scopedCount:i,aggregatedCount:t,mixedCount:c,dominantScope:o}}function R(e,n){return a$4()?`cd "${e}"; ${n}`:`cd ${e} && ${n}`}function q(e){return a$4()?R(e,"Copy-Item .env.example .env"):R(e,"cp .env.example .env")}function Tt(e){return e==="FastAPI"||e==="NestJS"?"first-class":e==="Django"||e==="Flask"||e==="Express"||e==="Fastify"||e==="Koa"||e==="Go/Fiber"||e==="Go/Gin"||e==="Spring Boot"||e==="Rust"||e==="Phoenix"||e==="Elixir"||e==="Clojure"||e==="Scala"||e==="Kotlin"||e==="Deno"||e==="Bun"||e==="PHP"||e==="Laravel"||e==="Ruby"||e==="Ruby on Rails"||e==="ASP.NET"?"extended":"observed"}function Bt(e){return e==="Next.js"||e==="Remix"||e==="Nuxt"||e==="React"||e==="Vue"||e==="Angular"||e==="SvelteKit"||e==="Svelte"||e==="Vite"||e==="Astro"||e==="Solid"?"frontend":e==="Unknown"||e==="Node.js"||e==="Python"?"generic":"backend"}function _t(e){return e==="NestJS"||e==="Next.js"||e==="Remix"||e==="Nuxt"||e==="React"||e==="Vue"||e==="Angular"||e==="SvelteKit"||e==="Svelte"||e==="Vite"||e==="Astro"||e==="Solid"||e==="Bun"||e==="Express"||e==="Fastify"||e==="Koa"||e==="Node.js"?"node":e==="FastAPI"||e==="Django"||e==="Flask"||e==="Python"?"python":e==="Go/Fiber"||e==="Go/Gin"?"go":e==="Spring Boot"?"java":e==="Rust"?"rust":e==="Elixir"||e==="Phoenix"?"elixir":e==="Clojure"?"clojure":e==="Deno"?"deno":e==="Laravel"||e==="PHP"?"php":e==="Ruby on Rails"||e==="Ruby"?"ruby":e==="ASP.NET"?"dotnet":"unknown"}function Ee(e,n){let i=q$1(n);e.commandCapabilities=i,e.supportTier=i.frameworkSupportTier;}function pe(e,n,i,t){e.framework=n,e.frameworkConfidence=i,e.supportTier=Tt(n),e.projectKind=Bt(n),e.runtimeFamily=_t(n);}function it(e){return e==="python"?"python":e==="node"||e==="bun"?"node":e==="go"?"go":e==="java"?"java":e==="rust"?"rust":e==="elixir"?"elixir":e==="clojure"?"clojure":e==="deno"?"deno":e==="php"?"php":e==="ruby"?"ruby":e==="dotnet"?"dotnet":"unknown"}function Re(e){switch(e.key){case "fastapi":return "FastAPI";case "django":return "Django";case "flask":return "Flask";case "python":return "Python";case "nestjs":return "NestJS";case "nextjs":return "Next.js";case "remix":return "Remix";case "nuxt":return "Nuxt";case "react":return "React";case "vite":return "Vite";case "vue":return "Vue";case "sveltekit":return "SvelteKit";case "svelte":return "Svelte";case "angular":return "Angular";case "astro":return "Astro";case "solid":return "Solid";case "express":return "Express";case "fastify":return "Fastify";case "koa":return "Koa";case "node":return "Node.js";case "gofiber":return "Go/Fiber";case "gogin":return "Go/Gin";case "echo":return "Echo";case "go":return "Go";case "springboot":return "Spring Boot";case "java":return "Java";case "laravel":return "Laravel";case "php":return "PHP";case "rails":return "Ruby on Rails";case "ruby":return "Ruby";case "dotnet":return "ASP.NET";case "phoenix":return "Phoenix";case "elixir":return "Elixir";case "clojure":return "Clojure";case "scala":return "Scala";case "kotlin":return "Kotlin";case "deno":return "Deno";case "bun":return "Bun";case "actix":case "axum":case "rocket":case "rust":return "Rust";case "sinatra":case "symfony":case "unknown":return "Unknown";default:return "Unknown"}}function Gt(e){return e.key==="python"||e.key==="node"||e.key==="go"||e.key==="java"||e.key==="php"||e.key==="ruby"||e.key==="dotnet"||e.key==="rust"||e.key==="elixir"||e.key==="clojure"||e.key==="scala"||e.key==="kotlin"||e.key==="deno"||e.key==="bun"||e.key==="unknown"}function Kt(e,n){e.framework=Re(n),e.frameworkKey=n.key,e.importStack=n.importStack,e.frameworkConfidence=n.confidence,e.supportTier=n.supportTier,e.projectKind="frontend",e.runtimeFamily=it(n.runtime);}function G(e,n){e.framework=Re(n),e.frameworkKey=n.key,e.importStack=n.importStack,e.frameworkConfidence=n.confidence,e.supportTier=n.supportTier,e.projectKind=Gt(n)?"generic":"backend",e.runtimeFamily=it(n.runtime);}function Wt(e){let n=e.dependencies,i=e.scripts??{},t=(e.kitName??"").toLowerCase(),c=s=>!!n[s],o=Object.values(i).filter(s=>typeof s=="string").join(" ").toLowerCase();return c("next")||o.includes("next ")?{framework:"Next.js",confidence:"high"}:c("nuxt")||o.includes("nuxt ")?{framework:"Nuxt",confidence:"high"}:c("@nestjs/core")||t.startsWith("nestjs.")?{framework:"NestJS",confidence:"high"}:c("express")?{framework:"Express",confidence:"high"}:c("fastify")?{framework:"Fastify",confidence:"high"}:c("koa")?{framework:"Koa",confidence:"high"}:c("@angular/core")?{framework:"Angular",confidence:"high"}:c("@sveltejs/kit")||o.includes("svelte-kit")?{framework:"SvelteKit",confidence:"high"}:c("vue")?{framework:"Vue",confidence:"medium"}:c("react")&&c("react-dom")?{framework:"React",confidence:"medium"}:{framework:"Node.js",confidence:"low"}}async function Ot(e){let n=i(e);return n.runtime!=="python"?{framework:"Python",confidence:"low"}:{framework:Re(n),confidence:n.confidence}}async function qe(e){try{let n=await r.stat(e);return `${a.basename(e)}:${n.isDirectory()?"d":"f"}:${n.size}:${n.mtimeMs}`}catch{return `${a.basename(e)}:missing`}}async function Lt(e){try{let n=new Set([".git",".venv","node_modules",".rapidkit","dist","build","coverage","__pycache__"]),i=new Set;await le(e)&&i.add(e);let t=await a$1(e);for(let o of t){let s=a.isAbsolute(o.path)?o.path:a.join(e,o.path);await le(s)&&i.add(s);}let c=async(o,s)=>{if(s<0)return;let d=await at(o);for(let u of d){if(rt(u,n))continue;let p=a.join(o,u);if(await le(p)){i.add(p);continue}s>0&&await c(p,s-1);}};return await c(e,1),i.size===0&&(await sn(e,3,n)).forEach(s=>i.add(s)),Array.from(i).sort((o,s)=>o.localeCompare(s))}catch{return []}}async function Vt(e,n){let i=[a.join(e,".rapidkit-workspace"),a.join(e,".rapidkit","workspace.json"),a.join(e,".rapidkit","imported-projects.json"),a.join(e,".rapidkit","policies.yml"),a.join(e,".rapidkit","toolchain.lock"),a.join(e,".rapidkit","cache-config.yml")],t=[".rapidkit/project.json",".rapidkit/context.json",".rapidkit/file-hashes.json","package.json","pyproject.toml","composer.json","Gemfile","Gemfile.lock","go.mod","go.sum","pom.xml","requirements.txt","Dockerfile","Makefile",".env",".env.example","src","modules","tests","test",".venv","node_modules"],c=await Promise.all(i.map(qe)),o=await Promise.all(n.map(async s=>{let d=await Promise.all(t.map(u=>qe(a.join(s,u))));return `${s}::${d.join("|")}`}));return [It,...c,...o].join("||")}async function Jt(e,n){try{if(!await r.pathExists(e))return null;let i=await r.readJSON(e);return !i||i.signature!==n||!Array.isArray(i.projects)||typeof i.schemaVersion=="string"&&i.schemaVersion!==et?null:i}catch{return null}}async function qt(e,n){try{await r.ensureDir(a.dirname(e)),await r.writeJSON(e,n,{spaces:2});}catch{}}async function Ut(e$1,n,i){let t=a.join(e$1,".rapidkit","reports","doctor-last-run.json");try{await r.ensureDir(a.dirname(t));let c=[];for(let o of n.projects)for(let s of o.issues??[])typeof s=="string"&&s.trim()&&c.push(`${o.name}: ${s.trim()}`);for(let[o,s]of [["python",n.python],["rapidkitCore",n.rapidkitCore]])if(s?.status==="error"){let d=typeof s.message=="string"?s.message:`${o} check failed`;c.push(`${o}: ${d}`);}return await r.writeJSON(t,f$2({schemaVersion:a$2,evidenceType:"workspace",contract:me(),workspacePath:e$1,workspaceName:n.workspaceName,projectScanCached:n.projectScanCached??false,projectScanSignature:n.projectScanSignature,cachePath:i,healthScore:n.healthScore,system:{python:n.python,poetry:n.poetry,pipx:n.pipx,go:n.go,rapidkitCore:n.rapidkitCore,versions:{core:n.coreVersion,npm:n.npmVersion}},projects:n.projects,summary:{totalProjects:n.projects.length,totalIssues:n.projects.reduce((o,s)=>o+s.issues.length,0),projectAdvisoryWarningProjects:Ce(n.projects),projectAdvisoryWarnings:$e(n.projects),hasSystemErrors:[n.python,n.rapidkitCore].some(o=>o.status==="error"),scopeProvenance:n.scopeProvenance},driftDelta:n.driftDelta,scoreBreakdown:n.scoreBreakdown??[]},{commandId:"checkWorkspaceHealth",exitCode:oe(n.healthScore,{}),generatedAt:new Date().toISOString(),blockers:c.slice(0,12),runId:e()}),{spaces:2}),t}catch{return}}async function Fe(){let[e,n,i,t,c]=await Promise.all([zt(),Qt(),Xt(),Yt(),Zt()]);return {python:e,poetry:n,pipx:i,go:t,rapidkitCore:c}}async function zt(){let e=d$1();for(let n of e)try{let{stdout:i}=await execa(n,["--version"],{timeout:3e3}),t=i.match(/Python (\d+\.\d+\.\d+)/);if(t){let c=t[1],[o,s]=c.split(".").map(Number);return o<3||o===3&&s<10?{status:"warn",message:`Python ${c} (requires 3.10+)`,details:`${n} found but version is below minimum requirement`}:{status:"ok",message:`Python ${c}`,details:`Using ${n}`}}}catch{continue}return {status:"error",message:"Python not found",details:"Install Python 3.10+ and ensure it's in PATH"}}async function Qt(){try{let{stdout:e}=await execa("poetry",["--version"],{timeout:3e3}),n=e.match(/Poetry .*version ([\d.]+)/);return n?{status:"ok",message:`Poetry ${n[1]}`,details:"Available for dependency management"}:{status:"warn",message:"Poetry version unknown"}}catch{let e=d$1().map(n=>({cmd:n,args:n==="py"?["-3","-m","poetry","--version"]:["-m","poetry","--version"]}));for(let n of e)try{let{stdout:i}=await execa(n.cmd,n.args,{timeout:3e3,shell:b$1()}),t=i.match(/Poetry .*version ([\d.]+)/)||i.match(/([\d.]+)/);return {status:"ok",message:t?.[1]?`Poetry ${t[1]}`:"Poetry detected",details:`Available via ${n.cmd} ${n.args.join(" ")}`}}catch{continue}for(let n of Ft())try{if(!await r.pathExists(n))continue;let{stdout:i}=await execa(n,["--version"],{timeout:3e3,shell:b$1()}),t=i.match(/Poetry .*version ([\d.]+)/)||i.match(/([\d.]+)/);return {status:"ok",message:t?.[1]?`Poetry ${t[1]}`:"Poetry detected",details:`Available at ${n}`}}catch{continue}return {status:"warn",message:"Poetry not installed",details:"Optional: Install for better dependency management"}}}async function Xt(){try{let{stdout:e}=await execa("pipx",["--version"],{timeout:3e3});return {status:"ok",message:`pipx ${e.trim()}`,details:"Available for global tool installation"}}catch{let e=d$1();for(let n of e)try{let i=n==="py"?["-3","-m","pipx","--version"]:["-m","pipx","--version"],{stdout:t}=await execa(n,i,{timeout:3e3,shell:b$1()});return {status:"ok",message:`pipx ${t.trim()}`,details:`Available via ${n} ${i.join(" ")}`}}catch{continue}return {status:"warn",message:"pipx not installed",details:"Optional: Install for isolated Python tools"}}}async function Yt(){try{let{stdout:e}=await execa("go",["version"],{timeout:3e3}),n=e.match(/go version go(\d+\.\d+(?:\.\d+)?)/);return n?{status:"ok",message:`Go ${n[1]}`,details:"Available for Go/Fiber and Go/Gin projects"}:{status:"ok",message:"Go (version unknown)",details:"go found in PATH"}}catch{return {status:"warn",message:"Go not installed",details:"Optional: Required only for gofiber.standard / gogin.standard projects \u2014 https://go.dev/dl/"}}}async function Zt(){let e=process.env.HOME||process.env.USERPROFILE||"",n=[],i=Dt(e);for(let{location:c,path:o}of i)try{if(await r.pathExists(o)){let{stdout:s,exitCode:d}=await execa(o,["--version"],{timeout:3e3,reject:false});if(d===0&&(s.includes("RapidKit Version")||s.includes("RapidKit"))){let u=s.match(/v?([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);u&&n.push({location:c,path:o,version:u[1]});}}}catch{continue}if(n.length>0){let c=n.filter(s=>s.location!=="Workspace (launcher)");if(c.length>0){let s=At(c),d=s[0].version,u=s.some(m=>m.location==="Workspace (.venv)"),p=s.some(m=>m.location.startsWith("Global (")),f=!u&&p?"Workspace (.venv): not installed (optional). For best project-level performance and isolation, run npx rapidkit workspace run init inside this workspace.":void 0;return {status:"ok",message:`RapidKit Core ${d}`,details:f,paths:s.map(m=>({location:m.location,path:m.path,version:m.version}))}}return {status:"ok",message:`RapidKit Core ${n[0].version}`,details:"Detected via workspace launcher"}}try{let{stdout:c,exitCode:o}=await execa("rapidkit",["--version"],{timeout:3e3,reject:false});if(o===0&&(c.includes("RapidKit Version")||c.includes("RapidKit"))){let s=c.match(/v?([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);if(s)return {status:"ok",message:`RapidKit Core ${s[1]}`,details:"Available via PATH"}}}catch{}try{let{stdout:c,exitCode:o}=await execa("poetry",["run","rapidkit","--version"],{timeout:3e3,reject:false});if(o===0&&(c.includes("RapidKit Version")||c.includes("RapidKit"))){let s=c.match(/v?([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);if(s)return {status:"ok",message:`RapidKit Core ${s[1]}`,details:"Available via Poetry"}}}catch{}let t=d$1();for(let c of t)try{let{stdout:o,exitCode:s}=await execa(c,["-c","import rapidkit_core; print(rapidkit_core.__version__)"],{timeout:3e3,reject:false});if(s===0&&o&&!o.includes("Traceback")&&!o.includes("ModuleNotFoundError")){let d=o.trim();if(d)return {status:"ok",message:`RapidKit Core ${d}`,details:`Available in ${c} environment`}}}catch{continue}return {status:"error",message:"RapidKit Core not installed",details:"Install with: pipx install rapidkit-core"}}async function T(e,n,i){let t=a.join(e,"Dockerfile");n.hasDocker=await r.pathExists(t);let c=a.join(e,"tests"),o=a.join(e,"test"),s=a.join(e,"src","test"),d=await r.pathExists(c)||await r.pathExists(o)||await r.pathExists(s),u=false;if(n.framework==="Go/Fiber"||n.framework==="Go/Gin")try{let p=[{dir:e,depth:0}],f=4,m=new Set([".git",".venv","node_modules","dist","build","vendor"]);for(;p.length>0&&!u;){let g=p.shift();if(!g)break;let h=[];try{h=await r.readdir(g.dir);}catch{continue}for(let y of h){let k=a.join(g.dir,y),b;try{b=await r.stat(k);}catch{continue}if(b.isFile()&&y.endsWith("_test.go")){u=true;break}b.isDirectory()&&g.depth<f&&!m.has(y)&&!y.startsWith(".")&&p.push({dir:k,depth:g.depth+1});}}}catch{}if(n.hasTests=d||u,n.runtimeFamily==="node"&&!n.hasTests&&(n.hasTests=await Ve(e,i)),n.runtimeFamily==="node")n.hasCodeQuality=await Le(e,i);else if(n.framework==="Go/Fiber"||n.framework==="Go/Gin"){let p=a.join(e,".golangci.yml"),f=a.join(e,".golangci.yaml"),m=a.join(e,"Makefile"),g=await r.pathExists(m)&&(await r.readFile(m,"utf8")).includes("golangci-lint");n.hasCodeQuality=await r.pathExists(p)||await r.pathExists(f)||g;}else if(n.runtimeFamily==="python"){let p=a.join(e,"ruff.toml"),f=a.join(e,"pyproject.toml");if(await r.pathExists(f))try{let m=await r.readFile(f,"utf8");n.hasCodeQuality=m.includes("[tool.ruff]")||await r.pathExists(p);}catch{n.hasCodeQuality=await r.pathExists(p);}}else if(n.framework==="Spring Boot"){let p=a.join(e,"pom.xml");if(await r.pathExists(p))try{let f=await r.readFile(p,"utf8");n.hasCodeQuality=f.includes("spotless")||f.includes("checkstyle")||f.includes("pmd")||f.includes("maven-enforcer-plugin");}catch{n.hasCodeQuality=false;}}try{if(n.runtimeFamily==="node"){let{stdout:p}=await execa("npm",["audit","--json"],{cwd:e,reject:false});if(p)try{let m=JSON.parse(p).metadata?.vulnerabilities;m&&(n.vulnerabilities=(m.high||0)+(m.critical||0)+(m.moderate||0));}catch{}}else if(n.runtimeFamily==="python"){let p=a.join(e,".venv"),f=f$1(p);if(await r.pathExists(f))try{let{stdout:m}=await execa(f,["-m","pip","list","--format=json"],{timeout:5e3,reject:false});if(m){JSON.parse(m);n.vulnerabilities=0;}}catch{}}}catch{}}function I(e,n){e.probes||(e.probes=[]),e.probes.push(n);}async function en(e,n){let i=n.runtimeFamily||"unknown";if(n.projectKind==="backend"||n.projectKind==="generic"){if(i==="node"){let c=await r.pathExists(a.join(e,"package-lock.json"))||await r.pathExists(a.join(e,"pnpm-lock.yaml"))||await r.pathExists(a.join(e,"yarn.lock"));I(n,{id:"adapter-node-lockfile-integrity",label:"Node adapter lockfile integrity",status:c?"pass":"warn",severity:"warn",scope:"project-scoped",reason:c?"Node lockfile detected for deterministic dependency restore.":"No Node lockfile detected (package-lock/yarn.lock/pnpm-lock.yaml).",recommendation:c?void 0:"Commit a lockfile for deterministic installs and CI parity."});let o=await r.pathExists(a.join(e,"src/main.ts"))||await r.pathExists(a.join(e,"src/main.js"))||await r.pathExists(a.join(e,"src/server.ts"))||await r.pathExists(a.join(e,"src/server.js"));I(n,{id:"adapter-node-boot-entrypoint",label:"Node adapter boot entrypoint",status:o?"pass":"warn",severity:"warn",scope:"project-scoped",reason:o?"Boot entrypoint markers detected for service startup path.":"No canonical Node boot entrypoint markers detected.",recommendation:o?void 0:"Define and document service bootstrap entrypoint (main/server)."});return}if(i==="python"){let c=await r.pathExists(a.join(e,"poetry.lock"))||await r.pathExists(a.join(e,"requirements.txt"))||await r.pathExists(a.join(e,"uv.lock"));I(n,{id:"adapter-python-lockfile-integrity",label:"Python adapter dependency integrity",status:c?"pass":"warn",severity:"warn",scope:"project-scoped",reason:c?"Python dependency contract file detected.":"No Python dependency contract file detected (poetry.lock/requirements/uv.lock).",recommendation:c?void 0:"Pin dependency contract for deterministic setup and reproducible CI."});let o=await r.pathExists(a.join(e,"app/main.py"))||await r.pathExists(a.join(e,"main.py"))||await r.pathExists(a.join(e,"manage.py"));I(n,{id:"adapter-python-boot-entrypoint",label:"Python adapter boot entrypoint",status:o?"pass":"warn",severity:"warn",scope:"project-scoped",reason:o?"Python application entrypoint markers detected.":"No Python application entrypoint markers detected.",recommendation:o?void 0:"Expose explicit app/main entrypoint for deterministic boot probes."});return}if(i==="java"){let c=await r.pathExists(a.join(e,"mvnw"))||await r.pathExists(a.join(e,"gradlew"));I(n,{id:"adapter-java-build-wrapper",label:"Java adapter build wrapper",status:c?"pass":"warn",severity:"warn",scope:"project-scoped",reason:c?"Build wrapper detected (mvnw/gradlew).":"No Java build wrapper detected.",recommendation:c?void 0:"Commit mvnw or gradlew for reproducible enterprise pipelines."});return}if(i==="go"){let c=await r.pathExists(a.join(e,"go.sum"));I(n,{id:"adapter-go-module-integrity",label:"Go adapter module integrity",status:c?"pass":"warn",severity:"warn",scope:"project-scoped",reason:c?"go.sum detected for deterministic module verification.":"go.sum missing; module integrity baseline is incomplete.",recommendation:c?void 0:"Generate and commit go.sum in the repository baseline."});}}}async function tn(e,n){let i=[a.join(e,".rapidkit","doctor.adapters.json"),a.join(e,"doctor.adapters.json")];for(let t of i)if(await r.pathExists(t))try{let c=await r.readJSON(t),o=Array.isArray(c?.checks)?c.checks:[];for(let s=0;s<o.length;s+=1){let d=o[s]||{},u=Array.isArray(d.runtimes)?d.runtimes:[];if(u.length>0&&!u.includes(n.runtimeFamily||"unknown"))continue;let p=typeof d.id=="string"&&d.id.trim().length>0?d.id.trim():`adapter-check-${s+1}`,f=typeof d.label=="string"&&d.label.trim().length>0?d.label.trim():p,m=d.severity||"warn",g=Array.isArray(d.anyOfPaths)?d.anyOfPaths.filter(Boolean):[],h=Array.isArray(d.allOfPaths)?d.allOfPaths.filter(Boolean):[],y=g.length===0;for(let L of g)if(await r.pathExists(a.join(e,L))){y=true;break}let k=true;for(let L of h)if(!await r.pathExists(a.join(e,L))){k=false;break}let b=y&&k;I(n,{id:p,label:f,status:b?"pass":m==="error"?"fail":"warn",severity:m,scope:"project-scoped",reason:b?d.passReason||"Custom adapter contract satisfied.":d.failReason||`Custom adapter check failed from ${a.basename(t)}.`,recommendation:d.recommendation});}}catch{I(n,{id:"custom-adapter-config",label:"Custom doctor adapter configuration",status:"warn",severity:"warn",scope:"project-scoped",reason:`Failed to parse ${a.basename(t)}.`,recommendation:"Fix JSON syntax in doctor.adapters.json to re-enable adapter checks."});}}async function B(e,n){if(!(n.projectKind==="backend"||n.projectKind==="generic"))return;let t=a.join(e,".env"),c=a.join(e,".env.example"),o=await r.pathExists(t)||await r.pathExists(c)||await r.pathExists(a.join(e,"config"));I(n,{id:"config-surface",label:"Configuration contract surface",status:o?"pass":"warn",severity:"warn",scope:"project-scoped",reason:o?"Configuration artifacts detected (.env/.env.example/config).":"No explicit configuration contract artifacts detected.",recommendation:o?void 0:"Add .env.example or explicit config contract documentation for deterministic setup."});let s={python:["alembic.ini","migrations","versions"],node:["prisma/schema.prisma","migrations","typeorm.config.ts","typeorm.config.js"],go:["migrations","db/migrations"],java:["src/main/resources/db/migration","src/main/resources/liquibase"],rust:["migrations","sqlx-data.json"],elixir:["priv/repo/migrations"],clojure:["resources/migrations","migrations"],deno:["migrations"],php:["database/migrations","migrations"],ruby:["db/migrate"],dotnet:["Migrations","Data/Migrations"],unknown:["migrations"]},d=n.runtimeFamily||"unknown",u=s[d]||s.unknown,p=false;for(let g of u)if(await r.pathExists(a.join(e,g))){p=true;break}I(n,{id:"migration-surface",label:"Migration/readiness surface",status:p?"pass":"warn",severity:"warn",scope:"project-scoped",reason:p?"Migration or schema evolution markers detected.":"No migration markers detected for this backend runtime.",recommendation:p?void 0:"Add migration tooling baseline (migrations dir or runtime-native migration config)."});let f=["src/health","src/healthcheck","src/main/resources/application.yml","src/main/resources/application.properties","app/health.py","routes/health.ts","routes/health.js"],m=false;for(let g of f)if(await r.pathExists(a.join(e,g))){m=true;break}I(n,{id:"runtime-health-surface",label:"Runtime health probe surface",status:m?"pass":"warn",severity:"warn",scope:"project-scoped",reason:m?"Health endpoint/config markers detected.":"No explicit runtime health endpoint markers detected.",recommendation:m?void 0:"Expose a deterministic health endpoint and keep it covered in verify pack."}),await en(e,n);}async function nn(e,n,i,t){let c=await Je({projectPath:e,detection:t,packageJsonData:i});for(let o of c)I(n,o);}async function _(e,n){let i=[a.join(e,".rapidkit","doctor.probes.json"),a.join(e,"doctor.probes.json")];for(let t of i)if(await r.pathExists(t))try{let c=await r.readJSON(t),o=Array.isArray(c?.probes)?c.probes:[];for(let s=0;s<o.length;s+=1){let d=o[s]||{},u=typeof d.id=="string"&&d.id.trim().length>0?d.id.trim():`custom-probe-${s+1}`,p=typeof d.label=="string"&&d.label.trim().length>0?d.label.trim():u,f=d.severity||"warn",m=Array.isArray(d.anyOfPaths)?d.anyOfPaths.filter(Boolean):[],g=Array.isArray(d.allOfPaths)?d.allOfPaths.filter(Boolean):[],h=m.length===0;for(let b of m)if(await r.pathExists(a.join(e,b))){h=true;break}let y=true;for(let b of g)if(!await r.pathExists(a.join(e,b))){y=false;break}let k=h&&y;I(n,{id:u,label:p,status:k?"pass":f==="error"?"fail":"warn",severity:f,scope:"project-scoped",reason:k?"Custom probe contract satisfied.":`Custom probe failed from ${a.basename(t)}.`,recommendation:d.recommendation});}}catch{I(n,{id:"custom-probe-config",label:"Custom doctor probe configuration",status:"warn",severity:"warn",scope:"project-scoped",reason:`Failed to parse ${a.basename(t)}.`,recommendation:"Fix JSON syntax in doctor.probes.json to re-enable custom probes."});}await tn(e,n);}async function De(e,n={}){let t={name:a.basename(e),path:e,venvActive:false,depsInstalled:false,coreInstalled:false,issues:[],fixCommands:[]},c=n.allowNonRapidkit===true,o=a.join(e,".rapidkit");if(!await r.pathExists(o)){if(!c)return t.issues.push("Not a valid RapidKit project (missing .rapidkit directory)"),t;t.issues.push("Not a RapidKit-managed project (running generic backend diagnostics)");}try{let w=a.join(e,"registry.json");if(await r.pathExists(w)){let v=await r.readJson(w);v.installed_modules&&(t.stats={modules:v.installed_modules.length});}}catch{}try{let{auditProjectModulePaths:w}=await import('./module-layout-NZ43RSC5.js'),v=await w(e);if(v.issues.length>0){for(let C of v.issues)t.issues.push(`${C.message} (${C.slug})`);t.fixCommands=t.fixCommands??[],t.fixCommands.push("npx rapidkit workspace contract verify --strict --json"),t.fixCommands.push("npx rapidkit add module <slug> # reinstall via Core-backed module install");}}catch{}let s=null;try{let w=a.join(o,"project.json");if(await r.pathExists(w)){s=await r.readJson(w);let v=s?.kit_name||s?.kit;v&&(t.kit=v);}}catch{}try{let w=a.join(e,".git");if(await r.pathExists(w)){let{stdout:v}=await execa("git",["log","-1","--format=%cr"],{cwd:e,reject:false});v&&(t.lastModified=v.trim());}else {let v=await r.stat(e),F=Date.now()-v.mtime.getTime(),D=Math.floor(F/(1e3*60*60*24));t.lastModified=D===0?"today":`${D} day${D>1?"s":""} ago`;}}catch{}let d$1=a.join(e,"package.json"),u=a.join(e,"pyproject.toml"),p=a.join(e,"requirements.txt"),f=a.join(e,"go.mod"),m=a.join(e,"pom.xml"),g=a.join(e,"build.sbt"),h=a.join(e,"Cargo.toml"),y=a.join(e,"mix.exs"),k=a.join(e,"deps.edn"),b=a.join(e,"project.clj"),L=a.join(e,"deno.json"),K=a.join(e,"deno.jsonc"),U=a.join(e,"bun.lockb"),z=a.join(e,"bun.lock"),V=a.join(e,"composer.json"),ie=a.join(e,"Gemfile"),Q=await r.pathExists(d$1),W=await r.pathExists(u)||await r.pathExists(p),N=await r.pathExists(V),ne=await r.pathExists(ie),ae=await r.pathExists(h),mt=await r.pathExists(y),ft=await r.pathExists(k)||await r.pathExists(b),gt=await r.pathExists(g),ht=await r.pathExists(L)||await r.pathExists(K),ue=s?.runtime==="dotnet";try{ue=ue||await Ue(e,".csproj",3)||await Ue(e,".sln",2);}catch{ue=s?.runtime==="dotnet";}let yt=await r.pathExists(f)||s?.runtime==="go"||typeof s?.kit_name=="string"&&(s.kit_name.startsWith("gofiber")||s.kit_name.startsWith("gogin")),Ae=Q&&(await r.pathExists(U)||await r.pathExists(z)||typeof s?.packageManager=="string"&&(s?.packageManager).toLowerCase().startsWith("bun@"));if(yt){G(t,i(e,s??null)),t.isGoProject=true,t.venvActive=true,t.coreInstalled=false;try{await execa("go",["version"],{timeout:3e3});}catch{t.issues.push("Go toolchain not found \u2014 install from https://go.dev/dl/"),t.fixCommands?.push("https://go.dev/dl/");}let w=a.join(e,"go.sum");return await r.pathExists(w)?t.depsInstalled=true:(t.depsInstalled=false,t.issues.push("Go dependencies not downloaded (go.sum missing)"),t.fixCommands?.push(R(e,"go mod tidy"))),await T(e,t),await B(e,t),await _(e,t),t}if(await r.pathExists(m)||s?.runtime==="java"||typeof s?.kit_name=="string"&&s.kit_name.startsWith("springboot")){G(t,i(e,s??null)),t.venvActive=true,t.coreInstalled=false;let w=await r.pathExists(m),v=await r.pathExists(a.join(e,"build.gradle"))||await r.pathExists(a.join(e,"build.gradle.kts")),C=await r.pathExists(a.join(e,"mvnw"))||await r.pathExists(a.join(e,"mvnw.cmd")),F=await r.pathExists(a.join(e,"gradlew"))||await r.pathExists(a.join(e,"gradlew.bat"));try{await execa("java",["-version"],{timeout:3e3,reject:false});}catch{t.issues.push("Java runtime not found \u2014 install JDK 21+ and ensure java is on PATH"),t.fixCommands?.push("https://adoptium.net/");}if(w){if(!C)try{await execa("mvn",["-version"],{timeout:3e3,reject:false});}catch{t.issues.push("Maven not found \u2014 install Maven 3.9+ or add Maven Wrapper"),t.fixCommands?.push("https://maven.apache.org/install.html");}}else if(v&&!F)try{await execa("gradle",["--version"],{timeout:3e3,reject:false});}catch{t.issues.push("Gradle not found \u2014 install Gradle 8+ or add Gradle Wrapper"),t.fixCommands?.push("https://gradle.org/install/");}let D=a.join(e,"target"),A=a.join(e,"build","libs"),H=a.join(e,".rapidkit","cache","java","m2"),j=a.join(e,".rapidkit","cache","java","gradle");t.depsInstalled=await r.pathExists(D)||await r.pathExists(A)||await r.pathExists(H)||await r.pathExists(j),t.depsInstalled||(t.issues.push("Java dependencies are not warmed or built yet"),t.fixCommands?.push(R(e,"rapidkit init")));let P=a.join(e,".env");if(t.hasEnvFile=await r.pathExists(P),!t.hasEnvFile){let X=a.join(e,".env.example");await r.pathExists(X)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(q(e)));}let J=a.join(e,"src","main","resources","application.yml");if(await r.pathExists(J))try{let X=await r.readFile(J,"utf-8");/include:\s*[^\n]*health/i.test(X)||/management:\s*[\s\S]*endpoint:\s*[\s\S]*health:/i.test(X)||(t.issues.push("Actuator health endpoint exposure is not clearly configured in application.yml"),t.fixCommands?.push(R(e,"Ensure management.endpoints.web.exposure.include contains health in src/main/resources/application.yml")));}catch{t.issues.push("Unable to read application.yml for Spring Actuator health checks");}return await T(e,t),await B(e,t),await _(e,t),t}if(ae){G(t,i(e,s??null)),t.venvActive=true,t.coreInstalled=false;let w=a.join(e,"Cargo.lock"),v=a.join(e,"target");t.depsInstalled=await r.pathExists(w)||await r.pathExists(v),t.depsInstalled||(t.issues.push("Rust dependencies are not resolved yet (Cargo.lock/target missing)"),t.fixCommands?.push(R(e,"cargo fetch")));let C=a.join(e,".env");if(t.hasEnvFile=await r.pathExists(C),!t.hasEnvFile){let F=a.join(e,".env.example");await r.pathExists(F)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(q(e)));}return await T(e,t),await B(e,t),await _(e,t),t}if(mt){G(t,i(e,s??null)),t.venvActive=true,t.coreInstalled=false;let w=a.join(e,"mix.lock"),v=a.join(e,"deps");t.depsInstalled=await r.pathExists(w)||await r.pathExists(v),t.depsInstalled||(t.issues.push("Elixir dependencies not installed (mix.lock/deps missing)"),t.fixCommands?.push(R(e,"mix deps.get")));let C=a.join(e,".env");if(t.hasEnvFile=await r.pathExists(C),!t.hasEnvFile){let F=a.join(e,".env.example");await r.pathExists(F)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(q(e)));}return await T(e,t),await B(e,t),await _(e,t),t}if(ft){G(t,i(e,s??null)),t.venvActive=true,t.coreInstalled=false;let w=a.join(e,".cpcache"),v=a.join(e,"target"),C=await r.pathExists(k)||await r.pathExists(b);return t.depsInstalled=await r.pathExists(w)||await r.pathExists(v)||C,t.depsInstalled||(t.issues.push("Clojure dependency cache not initialized"),t.fixCommands?.push(R(e,"clojure -P"))),await T(e,t),await B(e,t),await _(e,t),t}if(gt){G(t,i(e,s??null)),t.venvActive=true,t.coreInstalled=false;let w=a.join(e,"target");t.depsInstalled=await r.pathExists(w),t.depsInstalled||(t.issues.push("Scala build artifacts missing (run dependency/build warmup)"),t.fixCommands?.push(R(e,"sbt compile")));let v=a.join(e,".env");if(t.hasEnvFile=await r.pathExists(v),!t.hasEnvFile){let C=a.join(e,".env.example");await r.pathExists(C)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(q(e)));}return await T(e,t),await B(e,t),await _(e,t),t}if(ht){G(t,i(e,s??null)),t.venvActive=true,t.coreInstalled=false,t.depsInstalled=true;let w=a.join(e,".env");if(t.hasEnvFile=await r.pathExists(w),!t.hasEnvFile){let v=a.join(e,".env.example");await r.pathExists(v)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(q(e)));}return await T(e,t),await B(e,t),await _(e,t),t}if(Q){let w=null;try{w=await r.readJson(d$1);}catch{w=null;}let v={...w?.dependencies??{},...w?.devDependencies??{}},C=w?.scripts??{},F=typeof s?.kit_name=="string"?s.kit_name.toLowerCase():typeof s?.kit=="string"?s.kit.toLowerCase():"",D=d(e,s),A=Wt({dependencies:v,scripts:C,kitName:F});if(Ae)pe(t,"Bun","high");else {let j=i(e,s??null);j.key==="nestjs"||j.key==="express"||j.key==="fastify"||j.key==="koa"?G(t,j):D.key!=="unknown"?Kt(t,D):j.key!=="unknown"&&j.key!=="node"?G(t,j):pe(t,A.framework,A.confidence);}t.venvActive=true;let H=a.join(e,"node_modules");if(await r.pathExists(H))try{let P=(await r.readdir(H)).filter(J=>!J.startsWith(".")&&!J.startsWith("_"));t.depsInstalled=P.length>0;}catch{t.depsInstalled=false;}if(t.depsInstalled||(t.issues.push("Dependencies not installed (node_modules empty or missing)"),t.fixCommands?.push(R(e,Ae?"bun install":"rapidkit init"))),t.coreInstalled=false,t.projectKind==="frontend"){let j=[".env",".env.local",".env.development",".env.development.local",".env.production",".env.production.local"];if((await Promise.all(j.map(J=>r.pathExists(a.join(e,J))))).some(Boolean))t.hasEnvFile=true;else {let J=a.join(e,".env.example");await r.pathExists(J)&&(t.hasEnvFile=false,t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(q(e)));}}else {let j=a.join(e,".env");if(t.hasEnvFile=await r.pathExists(j),!t.hasEnvFile){let P=a.join(e,".env.example");await r.pathExists(P)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(q(e)));}}if(t.projectKind==="frontend")t.modulesHealthy=await je(e),t.missingModules=[];else {let j=a.join(e,"src");if(t.modulesHealthy=true,t.missingModules=[],await r.pathExists(j))try{let P=await r.readdir(j);t.modulesHealthy=P.length>0;}catch{t.modulesHealthy=false;}}return await T(e,t,w),t.projectKind==="frontend"?await nn(e,t,w,D.key!=="unknown"?D:d(e,s)):await B(e,t),await _(e,t),t}if(W){let w=await Ot(e);pe(t,w.framework,w.confidence);let v=a.join(e,".venv");if(await r.pathExists(v)){t.venvActive=true;let A=f$1(v);if(await r.pathExists(A)){try{let{stdout:P}=await execa(A,["-c","import rapidkit_core; print(rapidkit_core.__version__)"],{timeout:2e3});t.coreInstalled=true,t.coreVersion=P.trim();}catch{t.coreInstalled=false;}let H="fastapi";t.framework==="Django"?H="django":t.framework==="Flask"?H="flask":t.framework==="Python"&&(H="");let j=true;if(H)try{await execa(A,["-c",`import ${H}`],{timeout:2e3}),t.depsInstalled=true,j=false;}catch{j=true;}if(j)try{let P=a.join(v,"lib");if(await r.pathExists(P)){let X=(await r.readdir(P)).find(re=>re.startsWith("python"));if(X){let re=a.join(P,X,"site-packages");if(await r.pathExists(re)){let kt=(await r.readdir(re)).filter(ge=>!ge.startsWith("_")&&!ge.includes("dist-info")&&!["pip","setuptools","wheel","pkg_resources"].includes(ge));t.depsInstalled=kt.length>0;}}}t.depsInstalled||(t.issues.push("Dependencies not installed"),t.fixCommands?.push(R(e,"rapidkit init")));}catch{t.issues.push("Could not verify dependency installation");}}else t.issues.push("Virtual environment exists but Python executable not found");}else t.issues.push("Virtual environment not created"),t.fixCommands?.push(R(e,"rapidkit init"));let C=a.join(e,".env");if(t.hasEnvFile=await r.pathExists(C),!t.hasEnvFile){let A=a.join(e,".env.example");await r.pathExists(A)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(q(e)));}let F=a.join(e,"src"),D=a.join(e,"modules");if(t.modulesHealthy=true,t.missingModules=[],await r.pathExists(F)){let A=a.join(F,"__init__.py");await r.pathExists(A)||(t.modulesHealthy=false,t.missingModules.push("src/__init__.py"));}if(await r.pathExists(D))try{let A=await at(D);for(let H of A){let j=a.join(D,H,"__init__.py");await r.pathExists(j)||(t.modulesHealthy=false,t.missingModules.push(`modules/${H}/__init__.py`));}}catch{}return !t.modulesHealthy&&t.missingModules.length>0&&t.issues.push(`Missing module init files: ${t.missingModules.join(", ")}`),await T(e,t),await B(e,t),await _(e,t),t}if(N){G(t,i(e,s??null)),t.venvActive=true,t.coreInstalled=false;let w=a.join(e,"vendor");t.depsInstalled=await r.pathExists(w),t.depsInstalled||(t.issues.push("PHP dependencies not installed (vendor missing)"),t.fixCommands?.push(R(e,"composer install")));let v=a.join(e,".env");if(t.hasEnvFile=await r.pathExists(v),!t.hasEnvFile){let C=a.join(e,".env.example");await r.pathExists(C)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(q(e)));}return await T(e,t),await B(e,t),await _(e,t),t}if(ne){G(t,i(e,s??null)),t.venvActive=true,t.coreInstalled=false;let w=await r.pathExists(a.join(e,"Gemfile.lock")),v=await r.pathExists(a.join(e,"vendor","bundle"));t.depsInstalled=w||v,t.depsInstalled||(t.issues.push("Ruby dependencies not installed (Gemfile.lock/vendor missing)"),t.fixCommands?.push(R(e,"bundle install")));let C=a.join(e,".env");return t.hasEnvFile=await r.pathExists(C),await T(e,t),await B(e,t),await _(e,t),t}if(ue){G(t,i(e,s??null)),t.venvActive=true,t.coreInstalled=false;let w=a.join(e,"obj"),v=a.join(e,"src","obj"),C=a.join(e,"packages.lock.json");t.depsInstalled=await r.pathExists(w)||await r.pathExists(v)||await r.pathExists(C),t.depsInstalled||(t.issues.push(".NET restore/build artifacts not found"),t.fixCommands?.push(R(e,"dotnet restore")));let F=a.join(e,".env");return t.hasEnvFile=await r.pathExists(F),await T(e,t),await B(e,t),await _(e,t),t}return pe(t,"Unknown","low"),t.issues.push("Unknown project type (no recognized runtime marker files)"),await T(e,t),await B(e,t),await _(e,t),t}async function at(e){try{return (await r.readdir(e,{withFileTypes:true})).filter(i=>i.isDirectory()).map(i=>i.name)}catch{try{let n=await r.readdir(e),i=[];for(let t of n)try{(await r.stat(a.join(e,t))).isDirectory()&&i.push(t);}catch{continue}return i}catch{return []}}}async function Ue(e,n,i){let t=[{dir:e,depth:0}],c=new Set([".git",".rapidkit","node_modules","bin","obj","target"]);for(;t.length>0;){let o=t.shift();if(!o||o.depth>i)continue;let s;try{s=await r.readdir(o.dir,{withFileTypes:true});}catch{continue}for(let d of s){if(d.isFile()&&d.name.toLowerCase().endsWith(n.toLowerCase()))return true;d.isDirectory()&&!c.has(d.name)&&t.push({dir:a.join(o.dir,d.name),depth:o.depth+1});}}return false}async function le(e){let n=a.join(e,".rapidkit");if(!await r.pathExists(n))return false;let i=["project.json","context.json","file-hashes.json"];for(let t of i)if(await r.pathExists(a.join(n,t)))return true;return false}function rt(e,n){if(n.has(e))return true;let i=e.toLowerCase();return !!(i==="dist"||i.startsWith("dist-")||i.startsWith("dist_")||i==="build"||i.startsWith("build-")||i.startsWith("build_"))}async function sn(e,n,i){let t=new Set,c=[{dir:e,depth:0}];for(;c.length>0;){let o=c.shift();if(!o)break;try{let s=await r.readdir(o.dir);for(let d of s){if(rt(d,i))continue;let u=a.join(o.dir,d),p;try{p=await r.stat(u);}catch{continue}if(p.isDirectory()){if(await le(u)){t.add(u);continue}o.depth<n&&c.push({dir:u,depth:o.depth+1});}}}catch{continue}}return Array.from(t)}async function de(e){let n=a.resolve(e),i=a.parse(n).root;for(;;){if(await rn(n))return n;if(n===i)break;n=a.dirname(n);}return null}async function on(e){let n=a.resolve(e),i=await de(n),t=i??a.parse(n).root;for(;;){if(await le(n)||await an(n)&&(!i||n!==i))return n;if(n===t)break;n=a.dirname(n);}return null}function ze(e){let n=a.resolve(e);return process.platform==="darwin"?n.replace(/^\/private(?=\/var\/)/,""):n}async function an(e){let n=["package.json","pyproject.toml","requirements.txt","go.mod","pom.xml","build.sbt","Cargo.toml","mix.exs","deps.edn","project.clj","deno.json","deno.jsonc","composer.json","Gemfile"];for(let i of n)if(await r.pathExists(a.join(e,i)))return true;return false}async function rn(e){let n=[a.join(e,".rapidkit-workspace"),a.join(e,".rapidkit","workspace-marker.json"),a.join(e,".rapidkit","config.json")];return Promise.all(n.map(i=>r.pathExists(i))).then(i=>i.some(Boolean))}function ct(e,n){let i=0,t=0,c=0;return e.forEach(s=>{s.status==="ok"?i++:s.status==="warn"?t++:s.status==="error"&&c++;}),n.forEach(s=>{let d=ee(s),u=s.isGoProject?s.issues.length===0&&s.depsInstalled:s.issues.length===0&&s.venvActive&&s.depsInstalled;if(s.issues.length>0||d>0||!u){t++;return}i++;}),{total:i+t+c,passed:i,warnings:t,errors:c}}function lt(e,n,i={}){let t=[];for(let o of e)t.push({id:o.id,label:o.label,status:o.result.status,scope:"host-system",policyRuleId:"system-status-derived",reason:o.result.details||o.result.message});let c=[...n].sort((o,s)=>{let d=`${o.path||""}|${o.name||""}`.toLowerCase(),u=`${s.path||""}|${s.name||""}`.toLowerCase();return d.localeCompare(u)});for(let o of c){let s=o.issues.length>0,d=ee(o),u=s||d>0?"warn":"ok",p=s?`${o.issues.length} blocking issue(s)`:d>0?`${d} advisory warning(s)`:"Project checks passed";t.push({id:`project:${o.name}`,label:`Project ${o.name}`,status:u,scope:"project-scoped",policyRuleId:s?"project-blocking-issues":d>0?"project-advisory-warnings":"project-checks-passed",reason:p});}if(i.includeWorkspaceAggregateRules){let o=n.reduce((u,p)=>u+p.issues.length,0),s=$e(n),d=e.filter(u=>u.result.status==="error").length;t.push({id:"workspace:projects-discovered",label:"Workspace projects discovered",status:n.length>0?"ok":"warn",scope:"workspace-aggregate",policyRuleId:"workspace-project-discovery",reason:n.length>0?`${n.length} project(s) discovered for workspace analysis.`:"No projects discovered for workspace analysis."}),t.push({id:"workspace:system-error-gate",label:"Workspace system error gate",status:d>0?"error":"ok",scope:"workspace-aggregate",policyRuleId:"workspace-system-error-gate",reason:d>0?`${d} system requirement gate(s) failed.`:"All system requirement gates passed."}),t.push({id:"workspace:blocking-issues-gate",label:"Workspace blocking issues gate",status:o>0?"warn":"ok",scope:"workspace-aggregate",policyRuleId:"workspace-blocking-issues-gate",reason:o>0?`${o} blocking project issue(s) detected.`:"No blocking project issues detected."}),t.push({id:"workspace:advisory-warnings-gate",label:"Workspace advisory warnings gate",status:s>0?"warn":"ok",scope:"workspace-aggregate",policyRuleId:"workspace-advisory-warning-gate",reason:s>0?`${s} advisory warning(s) detected.`:"No advisory warnings detected."});}return t}async function Qe(e,n=true){let i=a.basename(e);try{let g=a.join(e,".rapidkit-workspace");await r.pathExists(g)&&(i=(await r.readJSON(g)).name||i);}catch{try{let g=a.join(e,".rapidkit","config.json");i=(await r.readJSON(g)).workspace_name||i;}catch{}}let[t,c]=await Promise.all([Fe(),Lt(e)]),o={workspacePath:e,workspaceName:i,python:t.python,poetry:t.poetry,pipx:t.pipx,go:t.go,rapidkitCore:t.rapidkitCore,projects:[]};f.debug(`Workspace scan found ${c.length} project(s)`);let s=await Vt(e,c),d=a.join(e,".rapidkit","reports","doctor-workspace-cache.json"),u=n?await Jt(d,s):null;if(u){o.projects=u.projects;for(let g of o.projects)Ee(g,g.path);o.projectScanCached=true,f.debug(`Workspace project health cache hit: ${d}`);}else try{let g=await Promise.all(c.map(h=>De(h)));for(let h of g)Ee(h,h.path);o.projects=g,o.projectScanCached=false,await qt(d,{schemaVersion:et,signature:s,generatedAt:new Date().toISOString(),projects:g}),f.debug(`Workspace project health cache refreshed: ${d}`);}catch(g){f.debug(`Failed to scan workspace projects: ${g}`);}o.projectScanSignature=s,o.projectScanCachePath=d;let p=[o.python,o.poetry,o.pipx,o.go,o.rapidkitCore];if(o.healthScore=ct(p,o.projects),o.scoreBreakdown=lt([{id:"system-python",label:"Python",result:o.python},{id:"system-poetry",label:"Poetry",result:o.poetry},{id:"system-pipx",label:"pipx",result:o.pipx},{id:"system-go",label:"Go",result:o.go},{id:"system-rapidkit-core",label:"RapidKit Core",result:o.rapidkitCore}],o.projects,{includeWorkspaceAggregateRules:true}),o.scopeProvenance=ot(o.scoreBreakdown),o.rapidkitCore.status==="ok"){let g=o.rapidkitCore.message.match(/([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);g&&(o.coreVersion=g[1]);}let f$1=a.join(e,".rapidkit","reports","doctor-last-run.json"),m=await nt(f$1,"workspace");return o.driftDelta=Ht(m,o),o.evidencePath=await Ut(e,o,u?d:null),o}function Xe(e){return {name:e.name,path:e.path,framework:e.framework,frameworkKey:e.frameworkKey,importStack:e.importStack,runtimeFamily:e.runtimeFamily,projectKind:e.projectKind,supportTier:e.supportTier,frameworkConfidence:e.frameworkConfidence,kit:e.kit,venvActive:e.venvActive,depsInstalled:e.depsInstalled,hasEnvFile:e.hasEnvFile,modulesHealthy:e.modulesHealthy,missingModules:e.missingModules,hasTests:e.hasTests,hasDocker:e.hasDocker,hasCodeQuality:e.hasCodeQuality,vulnerabilities:e.vulnerabilities,coreInstalled:e.coreInstalled,coreVersion:e.coreVersion,lastModified:e.lastModified,stats:e.stats,issues:e.issues,fixCommands:e.fixCommands,probes:e.probes,commandCapabilities:e.commandCapabilities}}async function cn(e$1,n){let i=e$1||n.projectPath,t=a.join(i,".rapidkit","reports","doctor-project-last-run.json");try{await r.ensureDir(a.dirname(t));let c=n.project.issues.filter(o=>typeof o=="string"&&o.trim().length>0).slice(0,12);return await r.writeJSON(t,f$2({schemaVersion:b$2,evidenceType:"project",contract:me(),workspacePath:e$1||null,projectPath:n.projectPath,projectName:n.projectName,healthScore:n.healthScore,system:{python:n.python,poetry:n.poetry,pipx:n.pipx,go:n.go,rapidkitCore:n.rapidkitCore},project:n.project,driftDelta:n.driftDelta,summary:{scopeProvenance:n.scopeProvenance},scoreBreakdown:n.scoreBreakdown??[]},{commandId:"projectDoctor",exitCode:oe(n.healthScore,{}),generatedAt:new Date().toISOString(),blockers:c,runId:e()}),{spaces:2}),t}catch{return}}async function ln(e){let n=await de(e),i=await Fe(),t=await De(e,{allowNonRapidkit:true});Ee(t,e);let c=ct([i.python,i.poetry,i.pipx,i.go,i.rapidkitCore],[t]),o={workspacePath:n||void 0,projectPath:e,projectName:a.basename(e),python:i.python,poetry:i.poetry,pipx:i.pipx,go:i.go,rapidkitCore:i.rapidkitCore,project:t,healthScore:c};o.scoreBreakdown=lt([{id:"system-python",label:"Python",result:o.python},{id:"system-poetry",label:"Poetry",result:o.poetry},{id:"system-pipx",label:"pipx",result:o.pipx},{id:"system-go",label:"Go",result:o.go},{id:"system-rapidkit-core",label:"RapidKit Core",result:o.rapidkitCore}],[o.project]),o.scopeProvenance=ot(o.scoreBreakdown);let s=n||e,d=a.join(s,".rapidkit","reports","doctor-project-last-run.json"),u=await nt(d,"project");return o.driftDelta=Mt(u,o),o.evidencePath=await cn(n||void 0,o),o}function $(e,n){let i=e.status==="ok"?"\u2705":e.status==="warn"?"\u26A0\uFE0F":"\u274C",t=e.status==="ok"?l.green:e.status==="warn"?l.yellow:l.red;console.log(`${i} ${l.bold(n)}: ${t(e.message)}`),e.paths&&e.paths.length>0&&e.paths.forEach(c=>{let o=c.version?l.cyan(` -> ${c.version}`):"";console.log(` ${l.cyan("\u2022")} ${l.gray(c.location)}: ${l.dim(c.path)}${o}`);}),e.details&&console.log(` ${l.gray(e.details)}`);}function Ye(e){let n=e.issues.length>0,i=n?"\u26A0\uFE0F":"\u2705",t=n?l.yellow:l.green;if(console.log(`
2
2
  ${i} ${l.bold("Project")}: ${t(e.name)}`),e.framework){let s=e.framework==="FastAPI"||e.framework==="Django"||e.framework==="Flask"?"\u{1F40D}":e.framework==="NestJS"?"\u{1F985}":e.framework==="Next.js"||e.framework==="Nuxt"||e.framework==="Remix"?"\u25B2":e.framework==="React"||e.framework==="Vite"?"\u269B\uFE0F":e.framework==="Vue"?"\u{1F7E2}":e.framework==="Angular"?"\u{1F170}\uFE0F":e.framework==="SvelteKit"?"\u{1F9E1}":e.framework==="Spring Boot"?"\u2615":e.framework==="Rust"?"\u{1F980}":e.framework==="Elixir"||e.framework==="Phoenix"?"\u{1F9EA}":e.framework==="Clojure"?"\u2699\uFE0F":e.framework==="Scala"?"\u{1F53A}":e.framework==="Kotlin"?"\u{1F7E3}":e.framework==="Deno"?"\u{1F995}":e.framework==="Bun"?"\u{1F956}":e.framework==="Go/Fiber"||e.framework==="Go/Gin"?"\u{1F439}":e.framework==="Laravel"||e.framework==="PHP"?"\u{1F418}":e.framework==="Ruby on Rails"||e.framework==="Ruby"?"\u{1F48E}":e.framework==="ASP.NET"?"\u{1F537}":"\u{1F4E6}";console.log(` ${s} Framework: ${l.cyan(e.framework)}${e.kit?l.gray(` (${e.kit})`):""}`);let d=[];e.runtimeFamily&&d.push(`runtime: ${e.runtimeFamily}`),e.projectKind&&d.push(`kind: ${e.projectKind}`),e.supportTier&&d.push(`support: ${e.supportTier}`),e.frameworkConfidence&&d.push(`confidence: ${e.frameworkConfidence}`),d.length>0&&console.log(` ${l.dim("\u21B3")} ${l.gray(d.join(" \u2022 "))}`);}if(console.log(` ${l.gray(`Path: ${e.path}`)}`),e.runtimeFamily==="python"&&(e.venvActive?console.log(` \u2705 Virtual environment: ${l.green("Active")}`):console.log(` \u274C Virtual environment: ${l.red("Not found")}`),e.coreInstalled?console.log(` ${l.dim("\u2139")} RapidKit Core: ${l.gray(e.coreVersion||"In venv")} ${l.dim("(optional)")}`):console.log(` ${l.dim("\u2139")} RapidKit Core: ${l.gray("Using global installation")} ${l.dim("(recommended)")}`)),e.depsInstalled?console.log(` \u2705 Dependencies: ${l.green("Installed")}`):console.log(` \u26A0\uFE0F Dependencies: ${l.yellow("Not installed")}`),e.hasEnvFile!==void 0&&(e.hasEnvFile?console.log(` \u2705 Environment: ${l.green(".env configured")}`):console.log(` \u26A0\uFE0F Environment: ${l.yellow(".env missing")}`)),e.modulesHealthy!==void 0){let s=e.projectKind==="frontend"?"Source tree":"Modules";e.modulesHealthy?console.log(` \u2705 ${s}: ${l.green("Healthy")}`):e.missingModules&&e.missingModules.length>0?console.log(` \u26A0\uFE0F ${s}: ${l.yellow(`Missing ${e.missingModules.length} init file(s)`)}`):e.projectKind==="frontend"&&console.log(` \u26A0\uFE0F ${s}: ${l.yellow("No application directories detected")}`);}if(e.stats){let s=[];e.stats.modules!==void 0&&s.push(`${e.stats.modules} module${e.stats.modules!==1?"s":""}`),s.length>0&&console.log(` \u{1F4CA} Stats: ${l.cyan(s.join(" \u2022 "))}`);}e.lastModified&&console.log(` \u{1F552} Last Modified: ${l.gray(e.lastModified)}`);let o=[];if(e.hasTests!==void 0&&o.push(e.hasTests?"\u2705 Tests":l.dim("\u2298 No tests")),e.hasDocker!==void 0&&o.push(e.hasDocker?"\u2705 Docker":l.dim("\u2298 No Docker")),e.hasCodeQuality!==void 0){let s=e.runtimeFamily==="node"?"ESLint":e.runtimeFamily==="rust"?"clippy":e.runtimeFamily==="elixir"?"Credo":e.runtimeFamily==="clojure"?"clj-kondo":e.runtimeFamily==="deno"?"deno lint":e.framework==="Spring Boot"?"Static analysis":e.framework==="Go/Fiber"||e.framework==="Go/Gin"?"golangci-lint":e.runtimeFamily==="python"?"Ruff":"Lint";o.push(e.hasCodeQuality?`\u2705 ${s}`:l.dim(`\u2298 No ${s}`));}if(o.length>0&&console.log(` ${o.join(" \u2022 ")}`),e.vulnerabilities!==void 0&&e.vulnerabilities>0&&console.log(` \u26A0\uFE0F Security: ${l.yellow(`${e.vulnerabilities} vulnerability(ies) found`)}`),e.issues.length>0&&(console.log(` ${l.bold("Issues:")}`),e.issues.forEach(s=>{console.log(` \u2022 ${l.yellow(s)}`);}),e.fixCommands&&e.fixCommands.length>0&&(console.log(`
3
3
  ${l.bold.cyan("\u{1F527} Quick Fix:")}`),e.fixCommands.forEach(s=>{console.log(` ${l.cyan("$")} ${l.white(s)}`);}))),e.probes&&e.probes.length>0){console.log(` ${l.bold("Probe checks:")}`);for(let s of e.probes){let d=s.status==="pass"?"\u2705":s.status==="warn"?"\u26A0\uFE0F":"\u274C";console.log(` ${d} ${s.label}: ${l.gray(s.reason)}`),s.recommendation&&console.log(` ${l.dim("\u21B3")} ${l.gray(s.recommendation)}`);}}if(e.commandCapabilities){let s=e.commandCapabilities;if(console.log(` ${l.bold("Command support:")}`),console.log(` ${l.green("supported")} ${s.supportedCommands.length} \u2022 ${l.yellow("unsupported")} ${s.unsupportedCommands.length} \u2022 ${l.gray("global")} ${s.globalCommands.length}`),s.unsupportedCommands.length>0){let d=s.unsupportedCommands.slice(0,8).join(", "),u=s.unsupportedCommands.length>8?", ...":"";console.log(` ${l.dim("\u21B3")} ${l.gray(`Unsupported here: ${d}${u}`)}`);}}}async function dt(){try{return (await execa("go",["version"],{timeout:a$3(),reject:false})).exitCode===0}catch{return false}}function te(e,n){let i=[new RegExp(`^cd\\s+"([^"]+)"\\s*(?:&&|;)\\s*${n}\\s*$`,"i"),new RegExp(`^cd\\s+'([^']+)'\\s*(?:&&|;)\\s*${n}\\s*$`,"i"),new RegExp(`^cd\\s+(.+?)\\s*(?:&&|;)\\s*${n}\\s*$`,"i")];for(let t of i){let c=e.match(t);if(c?.[1])return {projectPath:c[1].trim()}}return null}function ut(e){return te(e,"cp\\s+\\.env\\.example\\s+\\.env")||te(e,"copy-item\\s+\\.env\\.example\\s+\\.env")}function pt(e){let n=[{pattern:"npm\\s+install",command:"npm",args:["install"]},{pattern:"npm\\s+ci",command:"npm",args:["ci"]},{pattern:"pnpm\\s+install",command:"pnpm",args:["install"]},{pattern:"yarn\\s+install",command:"yarn",args:["install"]},{pattern:"poetry\\s+install",command:"poetry",args:["install"]},{pattern:"pip\\s+install\\s+-r\\s+requirements\\.txt",command:"pip",args:["install","-r","requirements.txt"]},{pattern:"composer\\s+install",command:"composer",args:["install"]},{pattern:"bundle\\s+install",command:"bundle",args:["install"]},{pattern:"dotnet\\s+restore",command:"dotnet",args:["restore"]},{pattern:"cargo\\s+fetch",command:"cargo",args:["fetch"]},{pattern:"mix\\s+deps\\.get",command:"mix",args:["deps.get"]},{pattern:"clojure\\s+-P",command:"clojure",args:["-P"]},{pattern:"sbt\\s+compile",command:"sbt",args:["compile"]}];for(let i of n){let t=te(e,i.pattern);if(t)return {projectPath:t.projectPath,command:i.command,args:i.args}}return null}function Pe(e,n){return /^https?:\/\//i.test(n.trim())?{projectName:e.name,projectPath:e.path,originalCommand:n,kind:"manual-url",risk:"safe",executable:false,reason:"Manual guidance URL"}:ut(n)?{projectName:e.name,projectPath:e.path,originalCommand:n,kind:"env-copy",risk:"safe",executable:true,reason:"Environment seed copy"}:te(n,"rapidkit\\s+init")?{projectName:e.name,projectPath:e.path,originalCommand:n,kind:"rapidkit-init",risk:"guarded",executable:true,reason:"RapidKit initializer may mutate dependencies and configs"}:te(n,"go\\s+mod\\s+tidy")?{projectName:e.name,projectPath:e.path,originalCommand:n,kind:"go-mod-tidy",risk:"guarded",executable:true,reason:"Go module graph reconciliation"}:pt(n)?{projectName:e.name,projectPath:e.path,originalCommand:n,kind:"dependency-sync",risk:"guarded",executable:true,reason:"Dependency synchronization command"}:{projectName:e.name,projectPath:e.path,originalCommand:n,kind:"shell",risk:"invasive",executable:true,reason:"Generic shell command"}}async function Se(e){let n=e.filter(p=>p.fixCommands&&p.fixCommands.length>0),i=n.flatMap(p=>(p.fixCommands??[]).map(f=>Pe(p,f))),t=null,c=[],o=0,s=0,d=0,u=0;for(let p of i){let f=p.executable,m;p.kind==="go-mod-tidy"&&(t===null&&(t=await dt()),t||(f=false,m="Go toolchain not available")),f&&(o+=1,p.risk==="safe"&&(s+=1),p.risk==="guarded"&&(d+=1),p.risk==="invasive"&&(u+=1)),c.push({...p,executableInCurrentEnvironment:f,blockedReason:m});}return {generatedAt:new Date().toISOString(),fixableProjects:n.length,totalSteps:c.length,executableSteps:o,risk:{safe:s,guarded:d,invasive:u},steps:c}}function Ze(e){let n=e instanceof Error?e.message:String(e),i=["ETIMEDOUT","ECONNRESET","ECONNREFUSED","EAI_AGAIN","ENOTFOUND","network","503","504"],t=n.toLowerCase();return i.some(c=>t.includes(c.toLowerCase()))}async function dn(e,n){let i=e.get(n);if(i)return i;let t=`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,c=a.basename(n).replace(/[^a-zA-Z0-9._-]/g,"_"),o=a.join(n,".rapidkit","reports","fix-snapshots",`${c}-${t}`);await r.ensureDir(o);let s=[".env","package-lock.json","pnpm-lock.yaml","yarn.lock","poetry.lock","requirements.txt","go.mod","go.sum","Cargo.lock","composer.lock","Gemfile.lock","pom.xml","build.gradle","build.gradle.kts","gradle.lockfile"],d=new Map;for(let p of s){let f=a.join(n,p);if(!await r.pathExists(f))continue;let m=a.join(o,p);await r.ensureDir(a.dirname(m)),await r.copy(f,m,{overwrite:true}),d.set(f,m);}let u={snapshotRoot:o,files:d};return e.set(n,u),u}async function un(e){for(let[n,i]of e.files.entries())await r.pathExists(i)&&(await r.ensureDir(a.dirname(n)),await r.copy(i,n,{overwrite:true}));}async function pn(e){let n=await De(e,{allowNonRapidkit:true});return {issues:n.issues.length,healthy:n.issues.length===0}}async function se(e,n=false,i={}){let t=await Se(e),c=e.filter(h=>h.fixCommands&&h.fixCommands.length>0),o=null,s=t.steps.some(h=>h.kind==="go-mod-tidy"&&!h.executableInCurrentEnvironment),d=new Map;if(c.length===0){console.log(l.green(`
4
4
  \u2705 No fixes needed - all projects are healthy!`));return}console.log(l.bold.cyan(`
@@ -20,9 +20,9 @@ Use --apply to execute this plan non-interactively, or --fix for interactive con
20
20
  `));continue}let ie=b.kind==="shell"?2:1,Q;for(let W=1;W<=ie;W+=1)try{await execa(k,{shell:true,stdio:"inherit"}),Q=null;break}catch(N){if(Q=N,W<ie&&Ze(N)){console.log(l.yellow(` \u26A0 Retrying command (${W}/${ie-1})...`));continue}throw N}if(Q)throw Q;console.log(l.green(` \u2705 Success
21
21
  `));}catch(K){let U=Pe(h,k);if(U.risk!=="safe"){let z=d.get(U.projectPath);if(z)try{await un(z),console.log(l.yellow(" \u21A9 Rolled back snapshot after failed fix"));}catch(V){console.log(l.red(` \u274C Rollback failed: ${V instanceof Error?V.message:String(V)}`));}}console.log(l.red(` \u274C Failed: ${K instanceof Error?K.message:String(K)}
22
22
  `));}}}try{let k=await pn(h.path);console.log(k.healthy?l.green(` \u2705 Post-fix verification passed for ${h.name}`):l.yellow(` \u26A0 Post-fix verification: ${k.issues} issue(s) remain for ${h.name}`));}catch(k){console.log(l.yellow(` \u26A0 Post-fix verification skipped: ${k instanceof Error?k.message:String(k)}`));}}console.log(l.bold.green(`
23
- \u2705 Fix process completed!`));}function oe(e,n){if(!n.strict&&!n.ci)return 0;let i=Number(e?.errors??0),t=Number(e?.warnings??0);return i>0?1:n.ci&&t>0?2:n.strict&&t>0?1:0}async function Mn(e$1={}){let n=!!(e$1.fix||e$1.plan||e$1.apply),i=!e$1.workspace&&!e$1.project&&n?await de(process.cwd()):null,t=e$1.workspace||!!i,c=!!e$1.project&&!t;if(e$1.json||console.log(l.bold.cyan(`
23
+ \u2705 Fix process completed!`));}function oe(e,n){if(!n.strict&&!n.ci)return 0;let i=Number(e?.errors??0),t=Number(e?.warnings??0);return i>0?1:n.ci&&t>0?2:n.strict&&t>0?1:0}async function Mn(e={}){let n=!!(e.fix||e.plan||e.apply),i=!e.workspace&&!e.project&&n?await de(process.cwd()):null,t=e.workspace||!!i,c=!!e.project&&!t;if(e.json||console.log(l.bold.cyan(`
24
24
  \u{1FA7A} RapidKit Health Check
25
- `)),t){let o=i??await de(process.cwd());o||(e.error("No RapidKit workspace found in current directory or parents"),e.info('Run this command from within a workspace, or use "rapidkit doctor" for system check'),process.exit(1)),e$1.json||(i&&console.log(l.gray("\u2139\uFE0F Detected workspace context; enabling workspace checks for --fix")),console.log(l.bold(`Workspace: ${l.cyan(a.basename(o))}`)),console.log(l.gray(`Path: ${o}`)));let s=await Qe(o);if(e$1.json||(s.projectScanCached&&console.log(l.gray(`\u2139\uFE0F Reused cached project scan${s.projectScanCachePath?` (${a.basename(s.projectScanCachePath)})`:""}`)),s.evidencePath&&console.log(l.gray(`\u2139\uFE0F Evidence saved: ${s.evidencePath}`))),e$1.json){let f=e$1.plan?await Se(s.projects):void 0,m={contract:me(),workspace:{name:a.basename(o),path:o},cache:{projectScan:s.projectScanCached??false,projectScanPath:s.projectScanCachePath,evidencePath:s.evidencePath},healthScore:s.healthScore,system:{python:s.python,poetry:s.poetry,pipx:s.pipx,rapidkitCore:s.rapidkitCore,versions:{core:s.coreVersion,npm:s.npmVersion}},projects:s.projects.map(g=>Xe(g)),summary:{totalProjects:s.projects.length,totalIssues:s.projects.reduce((g,h)=>g+h.issues.length,0),projectAdvisoryWarningProjects:Ce(s.projects),projectAdvisoryWarnings:$e(s.projects),hasSystemErrors:[s.python,s.rapidkitCore].some(g=>g.status==="error"),scopeProvenance:s.scopeProvenance},driftDelta:s.driftDelta,scoreBreakdown:s.scoreBreakdown??[],...f?{remediationPlan:f}:{}};return e$1.quiet||console.log(JSON.stringify(m,null,2)),oe(s.healthScore,e$1)}if(s.healthScore){let f=s.healthScore,m=Math.round(f.passed/f.total*100),g=m>=80?l.green:m>=50?l.yellow:l.red,h="\u2588".repeat(Math.floor(m/5))+"\u2591".repeat(20-Math.floor(m/5));console.log(l.bold(`
25
+ `)),t){let o=i??await de(process.cwd());o||(f.error("No RapidKit workspace found in current directory or parents"),f.info('Run this command from within a workspace, or use "rapidkit doctor" for system check'),process.exit(1)),e.json||(i&&console.log(l.gray("\u2139\uFE0F Detected workspace context; enabling workspace checks for --fix")),console.log(l.bold(`Workspace: ${l.cyan(a.basename(o))}`)),console.log(l.gray(`Path: ${o}`)));let s=await Qe(o);if(e.json||(s.projectScanCached&&console.log(l.gray(`\u2139\uFE0F Reused cached project scan${s.projectScanCachePath?` (${a.basename(s.projectScanCachePath)})`:""}`)),s.evidencePath&&console.log(l.gray(`\u2139\uFE0F Evidence saved: ${s.evidencePath}`))),e.json){let f=e.plan?await Se(s.projects):void 0,m={contract:me(),workspace:{name:a.basename(o),path:o},cache:{projectScan:s.projectScanCached??false,projectScanPath:s.projectScanCachePath,evidencePath:s.evidencePath},healthScore:s.healthScore,system:{python:s.python,poetry:s.poetry,pipx:s.pipx,rapidkitCore:s.rapidkitCore,versions:{core:s.coreVersion,npm:s.npmVersion}},projects:s.projects.map(g=>Xe(g)),summary:{totalProjects:s.projects.length,totalIssues:s.projects.reduce((g,h)=>g+h.issues.length,0),projectAdvisoryWarningProjects:Ce(s.projects),projectAdvisoryWarnings:$e(s.projects),hasSystemErrors:[s.python,s.rapidkitCore].some(g=>g.status==="error"),scopeProvenance:s.scopeProvenance},driftDelta:s.driftDelta,scoreBreakdown:s.scoreBreakdown??[],...f?{remediationPlan:f}:{}};return e.quiet||console.log(JSON.stringify(m,null,2)),oe(s.healthScore,e)}if(s.healthScore){let f=s.healthScore,m=Math.round(f.passed/f.total*100),g=m>=80?l.green:m>=50?l.yellow:l.red,h="\u2588".repeat(Math.floor(m/5))+"\u2591".repeat(20-Math.floor(m/5));console.log(l.bold(`
26
26
  \u{1F4CA} Health Score:`)),console.log(` ${g(`${m}%`)} ${l.gray(h)}`),console.log(` ${l.green(`\u2705 ${f.passed} passed`)} ${l.gray("|")} ${l.yellow(`\u26A0\uFE0F ${f.warnings} warnings`)} ${l.gray("|")} ${l.red(`\u274C ${f.errors} errors`)}`);}if(console.log(l.bold(`
27
27
 
28
28
  System Tools:
@@ -30,21 +30,21 @@ System Tools:
30
30
  \u26A0\uFE0F Version mismatch: Core ${s.coreVersion} / CLI ${s.npmVersion}`)),console.log(l.gray(" Consider updating to matching versions for best compatibility")));}s.projects.length>0?(console.log(l.bold(`
31
31
  \u{1F4E6} Projects (${s.projects.length}):`)),s.projects.forEach(f=>Ye(f))):(console.log(l.bold(`
32
32
  \u{1F4E6} Projects:`)),console.log(l.gray(" No RapidKit projects found in workspace")));let d=s.projects.reduce((f,m)=>f+m.issues.length,0),u=Ce(s.projects),p=[s.python,s.rapidkitCore].some(f=>f.status==="error");if(p||d>0||u>0){let f=u>0?` and ${u} advisory warning project(s)`:"";if(console.log(l.bold.yellow(`
33
- \u26A0\uFE0F Found ${d} project issue(s)${f}`)),p&&console.log(l.bold.red("\u274C System requirements not met")),e$1.plan)await se(s.projects,false,{planOnly:true,json:e$1.json});else if(e$1.fix||e$1.apply){if(await se(s.projects,true,{skipConfirmation:e$1.apply===true}),!e$1.json){let m=await Qe(o,false),g=m.projects.reduce((y,k)=>y+k.issues.length,0),h=[m.python,m.rapidkitCore].some(y=>y.status==="error");h||g>0?(console.log(l.bold.yellow(`
33
+ \u26A0\uFE0F Found ${d} project issue(s)${f}`)),p&&console.log(l.bold.red("\u274C System requirements not met")),e.plan)await se(s.projects,false,{planOnly:true,json:e.json});else if(e.fix||e.apply){if(await se(s.projects,true,{skipConfirmation:e.apply===true}),!e.json){let m=await Qe(o,false),g=m.projects.reduce((y,k)=>y+k.issues.length,0),h=[m.python,m.rapidkitCore].some(y=>y.status==="error");h||g>0?(console.log(l.bold.yellow(`
34
34
  \u26A0\uFE0F Post-fix verification found ${g} remaining issue(s)`)),h&&console.log(l.bold.red("\u274C System requirements still not met"))):console.log(l.bold.green(`
35
35
  \u2705 Post-fix verification passed. Workspace is healthy.`)),m.projectScanCached&&console.log(l.gray(`\u2139\uFE0F Reused cached project scan${m.projectScanCachePath?` (${a.basename(m.projectScanCachePath)})`:""}`)),m.evidencePath&&console.log(l.gray(`\u2139\uFE0F Evidence refreshed: ${m.evidencePath}`));}}else d>0&&await se(s.projects,false);}else console.log(l.bold.green(`
36
- \u2705 All checks passed! Workspace is healthy.`));return oe(s.healthScore,e$1)}else if(c){let o=await on(process.cwd());o||(await de(process.cwd())?(e.error("No backend project found in current directory within this workspace"),e.info("Run this command from inside a project directory in the workspace")):e.error("No RapidKit project found in current directory or parents"),e.info('Run this command from within a project, or use "rapidkit doctor workspace" for workspace checks'),process.exit(1));let s=await ln(o),d=s.workspacePath?ze(s.workspacePath):null,u=ze(s.project.path);if(e$1.json){let b=e$1.plan?await Se([s.project]):void 0,L={contract:me(),scope:"project",workspace:d?{name:a.basename(d),path:d}:null,project:{...Xe(s.project),path:u},evidencePath:s.evidencePath,healthScore:s.healthScore,system:{python:s.python,poetry:s.poetry,pipx:s.pipx,go:s.go,rapidkitCore:s.rapidkitCore},summary:{totalProjects:1,totalIssues:s.project.issues.length,projectAdvisoryWarningProjects:ee(s.project)>0?1:0,projectAdvisoryWarnings:ee(s.project),hasSystemErrors:[s.python,s.rapidkitCore].some(K=>K.status==="error"),scopeProvenance:s.scopeProvenance},driftDelta:s.driftDelta,scoreBreakdown:s.scoreBreakdown??[],...b?{remediationPlan:b}:{}};return e$1.quiet||console.log(JSON.stringify(L,null,2)),oe(s.healthScore,e$1)}console.log(l.bold(`Project: ${l.cyan(a.basename(o))}`)),console.log(l.gray(`Path: ${o}`)),s.workspacePath&&console.log(l.gray(`Workspace: ${a.basename(s.workspacePath)}`)),s.evidencePath&&console.log(l.gray(`\u2139\uFE0F Evidence saved: ${s.evidencePath}`));let p=s.healthScore,f=p.total>0?Math.round(p.passed/p.total*100):0,m=f>=80?l.green:f>=50?l.yellow:l.red,g="\u2588".repeat(Math.floor(f/5))+"\u2591".repeat(20-Math.floor(f/5));console.log(l.bold(`
37
- \u{1F4CA} Health Score:`)),console.log(` ${m(`${f}%`)} ${l.gray(g)}`),console.log(` ${l.green(`\u2705 ${p.passed} passed`)} ${l.gray("|")} ${l.yellow(`\u26A0\uFE0F ${p.warnings} warnings`)} ${l.gray("|")} ${l.red(`\u274C ${p.errors} errors`)}`),console.log(l.bold(`
36
+ \u2705 All checks passed! Workspace is healthy.`));return oe(s.healthScore,e)}else if(c){let o=await on(process.cwd());o||(await de(process.cwd())?(f.error("No backend project found in current directory within this workspace"),f.info("Run this command from inside a project directory in the workspace")):f.error("No RapidKit project found in current directory or parents"),f.info('Run this command from within a project, or use "rapidkit doctor workspace" for workspace checks'),process.exit(1));let s=await ln(o),d=s.workspacePath?ze(s.workspacePath):null,u=ze(s.project.path);if(e.json){let b=e.plan?await Se([s.project]):void 0,L={contract:me(),scope:"project",workspace:d?{name:a.basename(d),path:d}:null,project:{...Xe(s.project),path:u},evidencePath:s.evidencePath,healthScore:s.healthScore,system:{python:s.python,poetry:s.poetry,pipx:s.pipx,go:s.go,rapidkitCore:s.rapidkitCore},summary:{totalProjects:1,totalIssues:s.project.issues.length,projectAdvisoryWarningProjects:ee(s.project)>0?1:0,projectAdvisoryWarnings:ee(s.project),hasSystemErrors:[s.python,s.rapidkitCore].some(K=>K.status==="error"),scopeProvenance:s.scopeProvenance},driftDelta:s.driftDelta,scoreBreakdown:s.scoreBreakdown??[],...b?{remediationPlan:b}:{}};return e.quiet||console.log(JSON.stringify(L,null,2)),oe(s.healthScore,e)}console.log(l.bold(`Project: ${l.cyan(a.basename(o))}`)),console.log(l.gray(`Path: ${o}`)),s.workspacePath&&console.log(l.gray(`Workspace: ${a.basename(s.workspacePath)}`)),s.evidencePath&&console.log(l.gray(`\u2139\uFE0F Evidence saved: ${s.evidencePath}`));let p=s.healthScore,f$1=p.total>0?Math.round(p.passed/p.total*100):0,m=f$1>=80?l.green:f$1>=50?l.yellow:l.red,g="\u2588".repeat(Math.floor(f$1/5))+"\u2591".repeat(20-Math.floor(f$1/5));console.log(l.bold(`
37
+ \u{1F4CA} Health Score:`)),console.log(` ${m(`${f$1}%`)} ${l.gray(g)}`),console.log(` ${l.green(`\u2705 ${p.passed} passed`)} ${l.gray("|")} ${l.yellow(`\u26A0\uFE0F ${p.warnings} warnings`)} ${l.gray("|")} ${l.red(`\u274C ${p.errors} errors`)}`),console.log(l.bold(`
38
38
 
39
39
  System Tools:
40
40
  `)),$(s.python,"Python"),$(s.poetry,"Poetry"),$(s.pipx,"pipx"),$(s.go,"Go"),$(s.rapidkitCore,"RapidKit Core"),console.log(l.bold(`
41
41
  \u{1F4E6} Project (1):`)),Ye(s.project);let h=[s.python,s.rapidkitCore].some(b=>b.status==="error"),y=s.project.issues.length,k=ee(s.project);if(h||y>0||k>0){let b=k>0?` and ${k} advisory warning(s)`:"";console.log(l.bold.yellow(`
42
- \u26A0\uFE0F Found ${y} project issue(s)${b}`)),h&&console.log(l.bold.red("\u274C System requirements not met")),e$1.plan?await se([s.project],false,{planOnly:true,json:e$1.json}):e$1.fix||e$1.apply?await se([s.project],true,{skipConfirmation:e$1.apply===true}):y>0&&await se([s.project],false);}else console.log(l.bold.green(`
43
- \u2705 All checks passed! Project is healthy.`));return oe(s.healthScore,e$1)}else {console.log(l.bold(`System Tools:
42
+ \u26A0\uFE0F Found ${y} project issue(s)${b}`)),h&&console.log(l.bold.red("\u274C System requirements not met")),e.plan?await se([s.project],false,{planOnly:true,json:e.json}):e.fix||e.apply?await se([s.project],true,{skipConfirmation:e.apply===true}):y>0&&await se([s.project],false);}else console.log(l.bold.green(`
43
+ \u2705 All checks passed! Project is healthy.`));return oe(s.healthScore,e)}else {console.log(l.bold(`System Tools:
44
44
  `));let o=await Fe(),s=o.python,d=o.poetry,u=o.pipx,p=o.go,f=o.rapidkitCore;$(s,"Python"),$(d,"Poetry"),$(u,"pipx"),$(p,"Go"),$(f,"RapidKit Core"),[s,f].some(h=>h.status==="error")?(console.log(l.bold.red(`
45
- \u274C Some required tools are missing`)),(e$1.fix||e$1.apply)&&console.log(l.gray(`
45
+ \u274C Some required tools are missing`)),(e.fix||e.apply)&&console.log(l.gray(`
46
46
  Tip: Project auto-fix runs in workspace mode. Run from a workspace and use "rapidkit doctor workspace --fix"`)),console.log(l.gray(`
47
47
  Tip: Run "rapidkit doctor workspace" for workspace-wide checks, or "rapidkit doctor project" for the current project`))):(console.log(l.bold.green(`
48
- \u2705 All required tools are installed!`)),(e$1.fix||e$1.apply)&&console.log(l.gray(`
48
+ \u2705 All required tools are installed!`)),(e.fix||e.apply)&&console.log(l.gray(`
49
49
  Tip: Project auto-fix runs in workspace mode. Run from a workspace and use "rapidkit doctor workspace --fix"`)),console.log(l.gray(`
50
- Tip: Run "rapidkit doctor workspace" for workspace-wide checks, or "rapidkit doctor project" for the current project`))),console.log("");let g=[s,f].filter(h=>h.status==="error").length;return (e$1.strict||e$1.ci)&&g>0?1:0}}export{oe as a,Mn as b};
50
+ Tip: Run "rapidkit doctor workspace" for workspace-wide checks, or "rapidkit doctor project" for the current project`))),console.log("");let g=[s,f].filter(h=>h.status==="error").length;return (e.strict||e.ci)&&g>0?1:0}}export{oe as a,Mn as b};
@@ -0,0 +1 @@
1
+ import {r,j,q}from'./chunk-ZWKLRZE5.js';import A from'crypto';import c from'path';import d from'fs-extra';var E=new Set([...r().map(e=>e.id),...j().map(e=>e.kitId)]),b=[{id:"wordpress-site",aliases:["wordpress","wordpress-site","wp","wp-site"],ecosystem:"wordpress",status:"planned",officialCommands:["wp core download","wp config create","wp db create","wp core install"],adoptAfterCreate:true},{id:"wordpress-block",aliases:["wordpress-block","wp-block","gutenberg-block"],ecosystem:"wordpress",status:"planned",officialCommands:["npx @wordpress/create-block@latest <slug>"],adoptAfterCreate:true},{id:"laravel",aliases:["laravel","php-laravel"],ecosystem:"php",status:"planned",officialCommands:["composer create-project laravel/laravel <name>"],adoptAfterCreate:true},{id:"symfony",aliases:["symfony","php-symfony"],ecosystem:"php",status:"planned",officialCommands:["composer create-project symfony/skeleton <name>"],adoptAfterCreate:true},{id:"rails",aliases:["rails","ruby-on-rails","ruby-rails"],ecosystem:"ruby",status:"planned",officialCommands:["rails new <name>"],adoptAfterCreate:true}],i=new Map;for(let e of b){i.set(e.id,e);for(let t of e.aliases)i.set(t,e);}var h=new Set(["php","ruby","rust","elixir","clojure","scala","kotlin","unknown"]);function o(e){return e?.trim().toLowerCase()||void 0}function R(e){let t=o(e.kitId)??o(e.framework)??o(e.runtime)??"unknown";if(e.projectExists)return {lane:"adopt-only",status:"available",canExecuteCreate:false,requested:t,reason:"Existing projects enter Workspace Intelligence through adopt/import."};let n=e.kitId?q(e.kitId):void 0;if(n&&E.has(n))return {lane:"native-create",status:"available",canExecuteCreate:true,requested:t,resolved:n,reason:"RapidKit owns the create contract, project marker, registry, doctor, and workspace model path."};let s=i.get(t)??i.get(o(e.framework)??"")??i.get(o(e.runtime)??"");if(s)return {lane:"external-create-adopt",status:s.status,canExecuteCreate:false,requested:t,resolved:s.id,officialCommands:s.officialCommands,fallbackLane:"adopt-only",reason:"External generator support is planned but not enabled; use adopt/import until RapidKit owns the post-create contract."};let r=o(e.runtime);return r&&h.has(r)?{lane:"adopt-only",status:"available",canExecuteCreate:false,requested:t,resolved:r,reason:"Runtime can be governed through Workspace Intelligence, but native create is not supported."}:{lane:"adopt-only",status:"available",canExecuteCreate:false,requested:t,reason:"No native create contract is available; use adopt/import to enter Workspace Intelligence."}}function K(e){return !e.canExecuteCreate&&(e.lane==="external-create-adopt"||e.lane==="adopt-only"&&e.resolved!==void 0)}var L="rapidkit-freshness-metadata-v1";function l(e){if(Array.isArray(e))return e.map(t=>l(t));if(e&&typeof e=="object"){let t={};for(let n of Object.keys(e).sort())t[n]=l(e[n]);return t}return e}function v(e){return JSON.stringify(l(e))}function N(e){return A.createHash("sha256").update(v(e)).digest("hex")}var I=new Set(["service","frontend","worker","library","infra","docs","test-suite","unknown"]);async function k(e){try{if(!await d.pathExists(e))return null;let t=await d.readJSON(e);return t&&typeof t=="object"?t:null}catch{return null}}function y(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return I.has(t)?t:null}async function F(e,t){let n=t??await k(c.join(e,".rapidkit","project.json")),s=y(n?.kind)??y(n?.type);if(s)return s;let r=await k(c.join(e,"package.json"));if(r){let a={...r.dependencies??{},...r.devDependencies??{}},C=r.scripts??{},p=Object.values(C).filter(x=>typeof x=="string").join(" ").toLowerCase();if(a.next||a.react||a.vue||a.svelte||a.vite||a["@angular/core"]||p.includes("next ")||p.includes("vite "))return "frontend";if(r.private===true&&!a.express&&!a["@nestjs/core"])return "library"}return await d.pathExists(c.join(e,"Dockerfile"))||await d.pathExists(c.join(e,"docker-compose.yml"))||await d.pathExists(c.join(e,"terraform.tf"))?"infra":"service"}export{R as a,K as b,L as c,N as d,F as e};