workspai 0.46.0 → 0.48.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 (143) hide show
  1. package/README.md +225 -81
  2. package/contracts/agent-customization-pack.v1.json +11 -1
  3. package/contracts/bootstrap-compliance.v1.json +14 -0
  4. package/contracts/cli-runtime-command-inventory.v1.snapshot.json +4 -0
  5. package/contracts/extension-cli-compatibility.v1.json +13 -2
  6. package/contracts/mirror-ops.v1.json +16 -0
  7. package/contracts/published-contract-catalog.v1.json +59 -1
  8. package/contracts/runtime-command-surface.v1.json +294 -2
  9. package/contracts/transparency-evidence.v1.json +13 -0
  10. package/contracts/workspace-contract.v1.json +78 -0
  11. package/contracts/workspace-intelligence/model-usage-event.v1.json +82 -0
  12. package/contracts/workspace-intelligence/workspace-context.v1.json +20 -0
  13. package/contracts/workspace-intelligence/workspace-graph-token-efficiency.v1.json +72 -0
  14. package/contracts/workspace-intelligence/workspace-intelligence-evaluation-comparison.v1.json +53 -0
  15. package/contracts/workspace-intelligence/workspace-intelligence-evaluation.v1.json +120 -0
  16. package/contracts/workspace-intelligence/workspace-intelligence-run.v1.json +6 -1
  17. package/contracts/workspace-intelligence/workspace-knowledge-graph-change-overlay.v1.json +200 -0
  18. package/contracts/workspace-intelligence/workspace-knowledge-graph.v1.json +260 -0
  19. package/contracts/workspace-intelligence/workspace-knowledge-search.v1.json +60 -0
  20. package/contracts/workspace-intelligence-architecture.v1.json +37 -5
  21. package/contracts/workspace-intelligence-chain.v1.json +58 -6
  22. package/contracts/workspace-share-bundle.v1.json +16 -0
  23. package/dist/analyze-EEEU3MIF.js +1 -0
  24. package/dist/artifact-remediation-plan-SPOUHMK5.js +3 -0
  25. package/dist/autopilot-release-XGVXPOZI.js +1 -0
  26. package/dist/chunk-32OJDBIG.js +2 -0
  27. package/dist/chunk-37CVKXBD.js +1 -0
  28. package/dist/chunk-3NU32T4A.js +2 -0
  29. package/dist/chunk-3VFA7D5T.js +1 -0
  30. package/dist/chunk-4HDYADHT.js +13 -0
  31. package/dist/chunk-54EP5CEV.js +8 -0
  32. package/dist/chunk-5S3DJQEP.js +8 -0
  33. package/dist/chunk-AFL3ACCR.js +2 -0
  34. package/dist/{chunk-VFDM65IE.js → chunk-BFLJ2R4D.js} +22 -22
  35. package/dist/chunk-BGPXQQNY.js +4 -0
  36. package/dist/chunk-BMWFQXGW.js +1 -0
  37. package/dist/{chunk-UQWOVV6V.js → chunk-CRHYBQI3.js} +1 -1
  38. package/dist/chunk-CV5HKU4P.js +1 -0
  39. package/dist/chunk-ESLPI3XZ.js +1 -0
  40. package/dist/chunk-FB7SCXAZ.js +1 -0
  41. package/dist/{chunk-WPEEC5BX.js → chunk-HDXNIN4N.js} +1 -1
  42. package/dist/chunk-HZDXO65G.js +36 -0
  43. package/dist/{chunk-J5PIZCAU.js → chunk-I46XEIPL.js} +1 -1
  44. package/dist/chunk-J5ENLXDF.js +1 -0
  45. package/dist/chunk-KB44JP4M.js +2 -0
  46. package/dist/chunk-LHOZXC2M.js +2 -0
  47. package/dist/chunk-NAJCUQ4X.js +2 -0
  48. package/dist/chunk-OA537ZQ5.js +1 -0
  49. package/dist/chunk-OW42TZFB.js +1 -0
  50. package/dist/chunk-P3D5YQB2.js +1 -0
  51. package/dist/chunk-PHXQR6PX.js +2 -0
  52. package/dist/{chunk-ZKAI3PJE.js → chunk-PRTR2DQ2.js} +1 -1
  53. package/dist/{chunk-QA5BGEQW.js → chunk-QNONOO4F.js} +1 -1
  54. package/dist/chunk-RHQW3DTP.js +1 -0
  55. package/dist/chunk-T4YR4RAI.js +2 -0
  56. package/dist/chunk-THIOE2PB.js +2 -0
  57. package/dist/{chunk-4LGXSBCN.js → chunk-VU7NZHPM.js} +1 -1
  58. package/dist/chunk-WDKNMTJQ.js +1 -0
  59. package/dist/{chunk-YUATNVOT.js → chunk-Y5UJLPS4.js} +16 -16
  60. package/dist/{chunk-6IIZJQLV.js → chunk-YJZOMRAS.js} +1 -1
  61. package/dist/{create-WCV3L6XH.js → create-DBQNAMKP.js} +1 -1
  62. package/dist/{doctor-5BWM2EMJ.js → doctor-4NNUDNGZ.js} +1 -1
  63. package/dist/{dotnet-webapi-clean-6TVFBTVI.js → dotnet-webapi-clean-A6MVDYXX.js} +4 -4
  64. package/dist/{gofiber-standard-2BL7GWZB.js → gofiber-standard-I5YPQG5V.js} +1 -1
  65. package/dist/{gogin-standard-XGP3KBXA.js → gogin-standard-VY2L4QT5.js} +1 -1
  66. package/dist/index.d.ts +56 -14
  67. package/dist/index.js +322 -320
  68. package/dist/pipeline-TQM43A3K.js +5 -0
  69. package/dist/{springboot-standard-JJNUID6M.js → springboot-standard-55XKCBIZ.js} +4 -4
  70. package/dist/{workspace-7OXW5YTJ.js → workspace-NCWRINEF.js} +1 -1
  71. package/dist/{workspace-agent-sync-O4IA6VOA.js → workspace-agent-sync-662QHXGF.js} +1 -1
  72. package/dist/{workspace-archive-H74NBBNW.js → workspace-archive-P76EDIUG.js} +1 -1
  73. package/dist/{workspace-context-R7IPUBPG.js → workspace-context-23YYCUCP.js} +1 -1
  74. package/dist/workspace-contract-TU2I7GC2.js +1 -0
  75. package/dist/workspace-dependency-graph-BP4EXYQ5.js +1 -0
  76. package/dist/workspace-explain-MWUEN643.js +1 -0
  77. package/dist/workspace-explain-contract-ZPI3JXJU.js +1 -0
  78. package/dist/{workspace-feedback-REOS36ZZ.js → workspace-feedback-SUVH2LUJ.js} +1 -1
  79. package/dist/{workspace-foundation-KXT4QI5O.js → workspace-foundation-WXJ6I7ES.js} +1 -1
  80. package/dist/workspace-graph-token-efficiency-CFGFCJ5V.js +1 -0
  81. package/dist/{workspace-history-OGOVSKZG.js → workspace-history-BANOJRQ2.js} +1 -1
  82. package/dist/workspace-intelligence-MFJE7W67.js +1 -0
  83. package/dist/workspace-intelligence-evaluation-IPH7M3WV.js +1 -0
  84. package/dist/workspace-intelligence-runner-THYLHHMF.js +1 -0
  85. package/dist/workspace-knowledge-graph-ARDC6HHG.js +1 -0
  86. package/dist/workspace-knowledge-graph-change-overlay-XG6FC4IX.js +1 -0
  87. package/dist/workspace-knowledge-graph-export-UYAYFTWX.js +10 -0
  88. package/dist/workspace-knowledge-graph-query-VOSPPH4W.js +1 -0
  89. package/dist/workspace-mcp-serve-EZR6O76D.js +3 -0
  90. package/dist/workspace-model-7OU2M3LE.js +1 -0
  91. package/dist/workspace-model-hash-MHXK5MEI.js +1 -0
  92. package/dist/{workspace-registry-summary-SZ46R5PD.js → workspace-registry-summary-ORDK7A36.js} +1 -1
  93. package/dist/workspace-run-RLIYSOTN.js +1 -0
  94. package/dist/{workspace-verify-MFQ7IXGD.js → workspace-verify-EBVL7FWT.js} +1 -1
  95. package/dist/workspace-watch-3BPGLFLB.js +1 -0
  96. package/docs/AI_DYNAMIC_INTEGRATION.md +73 -428
  97. package/docs/AI_EXAMPLES.md +37 -395
  98. package/docs/AI_FEATURES.md +76 -456
  99. package/docs/AI_QUICKSTART.md +49 -212
  100. package/docs/GLOSSARY.md +64 -0
  101. package/docs/OPEN_SOURCE_USER_SCENARIOS.md +68 -7
  102. package/docs/README.md +70 -41
  103. package/docs/README_CONTENT_CONTRACT.md +154 -0
  104. package/docs/commands-reference.md +64 -4
  105. package/docs/config-file-guide.md +6 -2
  106. package/docs/contracts/ARTIFACT_CATALOG.md +76 -37
  107. package/docs/contracts/README.md +47 -8
  108. package/docs/graph-benchmark-methodology.md +121 -0
  109. package/docs/workspace-intelligence-evaluation.md +147 -0
  110. package/docs/workspace-knowledge-graph.md +316 -0
  111. package/docs/workspace-operations.md +49 -0
  112. package/package.json +2 -1
  113. package/dist/analyze-BEBEZSZK.js +0 -1
  114. package/dist/artifact-remediation-plan-FFQSESAM.js +0 -3
  115. package/dist/autopilot-release-WUR4CQIT.js +0 -1
  116. package/dist/chunk-2G7FASAO.js +0 -2
  117. package/dist/chunk-4EPHWD27.js +0 -8
  118. package/dist/chunk-CVHMUSRX.js +0 -1
  119. package/dist/chunk-DIPD72H4.js +0 -2
  120. package/dist/chunk-EFYHGCGX.js +0 -2
  121. package/dist/chunk-FWRXA435.js +0 -2
  122. package/dist/chunk-HDURFXW5.js +0 -2
  123. package/dist/chunk-HMUKBW2S.js +0 -4
  124. package/dist/chunk-K4WNYXKK.js +0 -33
  125. package/dist/chunk-LG6RFLPZ.js +0 -1
  126. package/dist/chunk-N7DV5L7C.js +0 -1
  127. package/dist/chunk-PRBVYW3T.js +0 -1
  128. package/dist/chunk-QZLIURER.js +0 -13
  129. package/dist/chunk-RIEF2DDX.js +0 -8
  130. package/dist/chunk-SXMTSV5M.js +0 -1
  131. package/dist/chunk-SXPY523X.js +0 -1
  132. package/dist/chunk-V3LRQZ36.js +0 -1
  133. package/dist/chunk-WYFPXTTS.js +0 -2
  134. package/dist/pipeline-ORIWVVYM.js +0 -5
  135. package/dist/workspace-contract-HKCMOMFE.js +0 -1
  136. package/dist/workspace-explain-GOPQYTPQ.js +0 -1
  137. package/dist/workspace-explain-contract-SVFJAAEI.js +0 -1
  138. package/dist/workspace-intelligence-7IESQSXY.js +0 -1
  139. package/dist/workspace-intelligence-runner-6GJ5M4HB.js +0 -1
  140. package/dist/workspace-mcp-serve-FRVWBO36.js +0 -3
  141. package/dist/workspace-model-PPYX7B4S.js +0 -1
  142. package/dist/workspace-run-V3KKHTVF.js +0 -1
  143. package/dist/workspace-watch-SOPZHRWA.js +0 -1
@@ -0,0 +1 @@
1
+ import {g,f,b as b$3}from'./chunk-J5ENLXDF.js';import {d}from'./chunk-OA537ZQ5.js';import {i}from'./chunk-MER6ZBN2.js';import {a as a$4,m}from'./chunk-T4YR4RAI.js';import {a as a$2}from'./chunk-FXQJX34Z.js';import {c,b as b$2,i as i$1,w,f as f$2}from'./chunk-PHXQR6PX.js';import {i as i$2,h as h$1}from'./chunk-4KUIFXHM.js';import {f as f$1,d as d$1,a as a$5,e}from'./chunk-32OJDBIG.js';import {a as a$1}from'./chunk-GSWPGELT.js';import {a as a$3}from'./chunk-GZTYAEWX.js';import {b as b$1,a}from'./chunk-BMWFQXGW.js';import {p,o}from'./chunk-5XATWNME.js';import p$1 from'path';import C from'fs-extra';import Qe from'crypto';import {createRequire}from'module';var Ue=new Set(["service","frontend","worker","library","infra","docs","test-suite","unknown"]);async function Ie(e){try{if(!await C.pathExists(e))return null;let t=await C.readJSON(e);return t&&typeof t=="object"?t:null}catch{return null}}async function Je(e){for(let t of e){let s=await Ie(t);if(s)return s}return null}function Me(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return Ue.has(t)?t:null}async function Oe(e,t){let s=t??await Je(p(e,"project.json")),n=Me(s?.kind)??Me(s?.type);if(n)return n;let a=typeof s?.kit_name=="string"?s.kit_name:s?.kit,r=typeof s?.framework=="string"?s.framework:null,o=typeof s?.runtime=="string"?s.runtime:null,i=`${typeof a=="string"?a:""} ${r??""} ${o??""}`.trim().toLowerCase();if(/\b(frontend|nextjs|next\.js|react|vue|svelte|vite|angular|astro|remix|nuxt)\b/.test(i))return "frontend";if(/\b(fastapi|nestjs|springboot|spring boot|gofiber|gogin|dotnet|webapi|django|flask|express|fastify|python|node|java|go|rust|php|ruby|elixir)\b/.test(i))return "service";let c=await Ie(p$1.join(e,"package.json"));if(c){let d={...c.dependencies??{},...c.devDependencies??{}},u=c.scripts??{},l=Object.values(u).filter(f=>typeof f=="string").join(" ").toLowerCase();if(d.next||d.react||d.vue||d.svelte||d.vite||d["@angular/core"]||l.includes("next ")||l.includes("vite "))return "frontend";if(c.private===true&&!d.express&&!d["@nestjs/core"])return "library"}return await C.pathExists(p$1.join(e,"Dockerfile"))||await C.pathExists(p$1.join(e,"docker-compose.yml"))||await C.pathExists(p$1.join(e,"terraform.tf"))?"infra":"service"}var qe=new Set(c().map(e=>e.id)),Xe=[...i().map(e=>({id:e.kitId,aliases:[...e.aliases],ecosystem:e.framework,status:"available",canExecuteCreate:true,officialCommands:[e.commandDisplay("<name>",{skipGit:false,skipInstall:false})],adoptAfterCreate:true})),{id:"wordpress-site",aliases:["wordpress","wordpress-site","wp","wp-site"],ecosystem:"wordpress",status:"planned",canExecuteCreate:false,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",canExecuteCreate:false,officialCommands:["npx @wordpress/create-block@latest <slug>"],adoptAfterCreate:true},{id:"laravel",aliases:["laravel","php-laravel"],ecosystem:"php",status:"planned",canExecuteCreate:false,officialCommands:["composer create-project laravel/laravel <name>"],adoptAfterCreate:true},{id:"symfony",aliases:["symfony","php-symfony"],ecosystem:"php",status:"planned",canExecuteCreate:false,officialCommands:["composer create-project symfony/skeleton <name>"],adoptAfterCreate:true},{id:"rails",aliases:["rails","ruby-on-rails","ruby-rails"],ecosystem:"ruby",status:"planned",canExecuteCreate:false,officialCommands:["rails new <name>"],adoptAfterCreate:true}],T=new Map;for(let e of Xe){T.set(e.id,e);for(let t of e.aliases)T.set(t,e);}var Ye=new Set(["php","ruby","rust","elixir","clojure","scala","kotlin","unknown"]);function F(e){return e?.trim().toLowerCase()||void 0}function _e(e){let t=F(e.kitId)??F(e.framework)??F(e.runtime)??"unknown";if(e.projectExists)return {lane:"existing",status:"available",canExecuteCreate:false,requested:t,reason:"Existing projects enter Workspace Intelligence through adopt/import."};let s=e.kitId?b$2(e.kitId):void 0;if(s&&qe.has(s))return {lane:"native",status:"available",canExecuteCreate:true,requested:t,resolved:s,reason:"Workspai owns the create contract, project marker, registry, doctor, and workspace model path."};let n=T.get(t)??T.get(F(e.framework)??"")??T.get(F(e.runtime)??"");if(n)return {lane:"official",status:n.status,canExecuteCreate:n.canExecuteCreate,requested:t,resolved:n.id,officialCommands:n.officialCommands,fallbackLane:n.canExecuteCreate?void 0:"existing",reason:n.status==="available"?"Workspai runs the official ecosystem generator, then registers the project in Workspace Intelligence.":"Official generator support is planned but not enabled; use adopt/import until Workspai owns the post-create contract."};let a=F(e.runtime);return a&&Ye.has(a)?{lane:"existing",status:"available",canExecuteCreate:false,requested:t,resolved:a,reason:"Runtime can be governed through Workspace Intelligence, but native create is not supported."}:{lane:"existing",status:"available",canExecuteCreate:false,requested:t,reason:"No native create contract is available; use adopt/import to enter Workspace Intelligence."}}function Wt(e){return !e.canExecuteCreate&&(e.lane==="official"||e.lane==="existing"&&e.resolved!==void 0)}var ae="workspace-model-cache.v1",oe=".workspai/cache/workspace-model.v1.json",De=["package.json","pyproject.toml","requirements.txt","go.mod","go.sum","pom.xml","build.gradle","build.gradle.kts","Cargo.toml","composer.json","Gemfile","workspai.project.json",".workspai/project.json",".workspai/context.json","rapidkit.project.json",".rapidkit/project.json",".rapidkit/context.json"],Ne=[".workspai/workspace.contract.json",".workspai/workspace.json","workspai.workspace.json",".workspai/policies.yml",".workspai/policies.yaml",".rapidkit/workspace.contract.json",".rapidkit/workspace.json","rapidkit.workspace.json",".rapidkit/policies.yml",".rapidkit/policies.yaml"],et=new Set([".ts",".tsx",".js",".jsx",".mjs",".cjs"]),tt=new Set([".git",".workspai",".rapidkit","node_modules","dist","build","out","target","coverage",".next",".turbo",".cache",".venv"]),rt=1500,V=null;function ie(){if(V)return V;try{V=createRequire(import.meta.url)("../package.json")?.version??"0.0.0";}catch{V="0.0.0";}return V}async function X(e){try{let t=await C.readFile(e);return Qe.createHash("sha256").update(t).digest("hex")}catch{return null}}async function st(e){let t={};for(let a of De){let r=await X(p$1.join(e,a));r&&(t[a]=r);}let s=[],n=[e];for(;n.length>0&&s.length<rt;){let a=n.shift();if(!a)continue;let r=[];try{r=await C.readdir(a,{withFileTypes:true});}catch{continue}let o=[];for(let i of r)if(i.isDirectory()){if(tt.has(i.name)||i.name.startsWith("."))continue;o.push(p$1.join(a,i.name));}else if(i.isFile()&&et.has(p$1.extname(i.name))){let c=p$1.join(a,i.name),d=await C.stat(c).catch(()=>null);if(d){let u=p$1.relative(e,c).split(p$1.sep).join("/");s.push(`${u}:${d.size}:${Math.round(d.mtimeMs)}`);}}o.sort((i,c)=>i.localeCompare(c)),n.push(...o);}return s.sort((a,r)=>a.localeCompare(r)),b$3({manifests:t,source:s})}async function Y(e,t){let s=p$1.resolve(e),n={},a=[...new Set(t.map(r=>p$1.relative(s,p$1.resolve(r)).split(p$1.sep).join("/")))].sort((r,o)=>r.localeCompare(o));for(let r of a)n[r]=await st(p$1.join(s,r));return n}async function Q(e){let t=p$1.resolve(e),s={};for(let n of Ne){let a=await X(p$1.join(t,n));a&&(s[n]=a);}return s}async function Z(e){let t=p$1.resolve(e.workspacePath),s=[...new Set(e.projectPaths.map(r=>p$1.relative(t,p$1.resolve(r)).split(p$1.sep).join("/")))].sort((r,o)=>r.localeCompare(o)),n=[];for(let r of s){let o={};for(let i of De){let c=await X(p$1.join(t,r,i));c&&(o[i]=c);}n.push({project:r,manifests:o});}let a={};for(let r of Ne){let o=await X(p$1.join(t,r));o&&(a[r]=o);}return b$3({cacheSchema:ae,cliVersion:e.cliVersion,flags:e.flags,workspaceJson:e.workspaceJson??null,marker:e.marker??null,projects:n,workspaceFiles:a})}async function ce(e){let t=await d$1(e,oe)??a$5(e,oe);try{if(!await C.pathExists(t))return null;let s=await C.readJson(t);return !s||s.schemaVersion!==ae||typeof s.inputsHash!="string"||typeof s.cliVersion!="string"||!s.model?null:s}catch{return null}}async function ee(e$1,t){let s={schemaVersion:ae,...t};return e(e$1,oe,s)}var Te="rapidkit-fact-freshness-v1",G={durable:720*60*60,derived:10080*60,evidenceBacked:1440*60,live:300,verifyBeforeUse:1440*60};function nt(e){switch(e){case "durable":return G.durable;case "derived":return G.derived;case "evidence-backed":return G.evidenceBacked;case "live":return G.live;case "verify-before-use":return G.verifyBeforeUse}}function ot(e){if(e.status)return e.status;if(e.ttlSeconds===null)return "unknown";let t=Date.parse(e.generatedAt);if(!Number.isFinite(t))return "unknown";let s=t+e.ttlSeconds*1e3;return e.now.getTime()>s?"stale":"fresh"}function at(e){let t=e.now??new Date,s=e.generatedAt??t.toISOString(),n=Date.parse(s),a=Number.isFinite(n),r=a?s:t.toISOString(),o=e.ttlSeconds===void 0?nt(e.kind):e.ttlSeconds,i=ot({generatedAt:r,ttlSeconds:o,status:e.status??(a?void 0:"unknown"),now:t}),c=Date.parse(r),d=o===null||!Number.isFinite(c)?void 0:new Date(c+o*1e3),u=e.verifyBeforeUse??(e.kind==="live"||e.kind==="verify-before-use"||e.category!=="structure"||i!=="fresh");return {schemaVersion:Te,kind:e.kind,category:e.category,generatedAt:r,ttlSeconds:o,...d?{expiresAt:d.toISOString()}:{},status:i,verifyBeforeUse:u,...e.sourceArtifact?{sourceArtifact:e.sourceArtifact}:{},...e.sourcePath?{sourcePath:e.sourcePath}:{},inputsHash:e.inputsHash??b$3(e.value??null),reason:e.reason}}function h(e){return {id:e.id,label:e.label,scope:e.scope,value:e.value,...e.project?{project:e.project}:{},freshness:at({...e.freshness,value:e.value})}}function Ve(e){let t=e.generatedAt??(e.now??new Date).toISOString(),s={durable:0,derived:0,"evidence-backed":0,live:0,"verify-before-use":0},n={structure:0,verification:0,state:0},a=0,r=0,o=0,i=0;for(let c of e.facts)s[c.freshness.kind]+=1,n[c.freshness.category]+=1,c.freshness.status==="stale"&&(a+=1),c.freshness.status==="unknown"&&(r+=1),c.freshness.kind==="live"&&(o+=1),c.freshness.verifyBeforeUse&&(i+=1);return {schemaVersion:Te,generatedAt:t,status:a>0?"stale":r>0?"unknown":"fresh",totalFacts:e.facts.length,staleFacts:a,unknownFacts:r,liveFacts:o,verifyBeforeUseFacts:i,byKind:s,byCategory:n}}var it=b$1.model,te=a.model,ct=["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"],lt=new Set([".git",".hg",".svn",".workspai",".rapidkit",".venv","node_modules","dist","build","target","coverage","htmlcov",".next",".turbo"]);function Ge(e,t){return (p$1.relative(e,t)||".").split(p$1.sep).join("/")}async function Ke(e){try{if(!await C.pathExists(e))return null;let t=await C.readJSON(e);return t&&typeof t=="object"?t:null}catch{return null}}async function dt(e,t){for(let s of t)if(await C.pathExists(p$1.join(e,s)))return true;return false}function le(e){let t=Number.parseInt(process.env.RAPIDKIT_WORKSPACE_MODEL_SCAN_DEPTH??"",10),s=typeof e=="number"&&Number.isFinite(e)?e:Number.isFinite(t)?t:4;return Math.min(12,Math.max(1,Math.trunc(s)))}async function de(e,t){let s=p$1.resolve(e),n=[{dirPath:s,depth:0}],a=new Set,r=new Set;for(;n.length>0;){let o=n.shift();if(!o)continue;let i=p$1.resolve(o.dirPath);if(r.has(i))continue;if(r.add(i),i!==s&&await dt(i,ct)){a.add(i);continue}if(o.depth>=t)continue;let c=[];try{c=await C.readdir(i,{withFileTypes:true});}catch{continue}for(let d of c)!d.isDirectory()||lt.has(d.name)||d.name.startsWith(".")&&d.name!==".config"||n.push({dirPath:p$1.join(i,d.name),depth:o.depth+1});}return Array.from(a).sort((o,i)=>o.localeCompare(i))}function pe(e){let t=new Set,s=[];for(let n of e){let a=p$1.resolve(n);t.has(a)||(t.add(a),s.push(a));}return s.sort((n,a)=>n.localeCompare(a))}function $e(e,t){let s=e?.[t];return typeof s=="string"&&s.trim()?s.trim():void 0}function pt(e,t){return e?.[t]===true}function ut(e,t,s){let n=e?.frontend&&typeof e.frontend=="object"&&!Array.isArray(e.frontend)?e.frontend:void 0,a=$e(n,"generator"),r=$e(n,"command_display"),o=typeof t=="string"&&t.startsWith("frontend.");if(!(!a&&!o))return {...a?{id:a}:{},...t?{kit:t}:{},displayName:s,source:pt(n,"official_generator")?"official-generator":"metadata",...r?{commandDisplay:r}:{}}}async function mt(e){let t=[".workspai/project.json",".workspai/context.json",".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"],s=[];for(let n of t)await C.pathExists(p$1.join(e,n))&&s.push(n);return s}async function S(e,t,s,n=t){let a=await d$1(e,t),r=a!==null,o={path:n.split(p$1.sep).join("/"),exists:r};if(a&&s){let i=await Ke(a);typeof i?.generatedAt=="string"&&(o.generatedAt=i.generatedAt);let c=i?.status??i?.result??i?.verdict;typeof c=="string"&&(o.status=c);}return o}async function ft(e,t,s){let n=Ge(e,t),a=".workspai/reports",r=c=>S(t,`${a}/${c}`,s,`${n}/${a}/${c}`),o=await r("doctor-project-last-run.json");return {doctor:o?.exists===true?o:await r("doctor-last-run.json"),remediationPlan:await r("doctor-remediation-plan-last-run.json"),fixResult:await r("doctor-fix-result-last-run.json"),analyze:await r("analyze-last-run.json"),readiness:await r("release-readiness-last-run.json")}}async function gt(e,t,s){let n=i$1(t),a=i$2(t,n),r=w(t),o=f$2(a.runtime),i=await Oe(t,n),c=typeof n?.name=="string"&&n.name.trim()?n.name.trim():p$1.basename(t),d=typeof n?.kit_name=="string"?n.kit_name:typeof n?.kit=="string"?n.kit:void 0,u=typeof n?.engine=="string"?n.engine:r.engine!=="unknown"?r.engine:void 0,l=ut(n,d,a.displayName),f=_e({kitId:d,framework:a.key,runtime:a.runtime});return {name:c,path:Ge(e,t),...s.includeAbsolutePaths?{absolutePath:t}:{},kind:i,runtime:a.runtime,runtimeCandidates:h$1(t),framework:a.key,frameworkDisplayName:a.displayName,confidence:a.confidence,detectionSource:a.source,supportTier:a.supportTier,runtimeSupportTier:o.tier,runtimeDoctorSupport:o.doctorSupport,moduleSupport:r.moduleSupport,...d?{kit:d}:{},...u?{engine:u}:{},...l?{generator:l}:{},createCapability:f,commands:{supported:r.supportedCommands,unsupported:r.unsupportedCommands,global:r.globalCommands,fleetStages:r.fleetStages,localOnly:r.localOnlyCommands,map:r.commandMap},importantFiles:await mt(t),evidence:await ft(e,t,s.includeEvidence),provenance:{path:"filesystem discovery",runtime:a.source,framework:a.source,commands:"project command capability matrix",createCapability:"create planner capability contract",evidence:"project .workspai/reports"}}}async function ue(e){for(let t of o(e,"workspace.json")){let s=await Ke(t);if(s)return s}return null}function kt(e){return e.length===0?"empty-workspace":e.some(t=>t.kind==="frontend")&&e.length>1?"full-stack-workspace":e.some(t=>t.kind==="frontend")?"frontend-workspace":e.length>1?"backend-platform":"backend-workspace"}function ht(e){let t=new Set;for(let s of e){let n=`${s.name} ${s.path}`.toLowerCase();for(let a of ["auth","billing","payment","notification","order","admin","report","search","analytics"])n.includes(a)&&t.add(a);}return Array.from(t).sort()}function b(e,t,s,n){return {severity:e,code:t,message:s,target:n}}function Be(e){let t=[];e.workspace.name.trim()||t.push(b("error","workspace.name.missing","Workspace name could not be resolved.","workspace")),e.workspace.type==="observed-workspace"&&t.push(b("warning","workspace.marker.missing","Workspace marker is missing; model is based on filesystem observation.","workspace.marker")),e.summary.projectCount===0&&t.push(b("warning","workspace.projects.empty","No project roots were detected in this workspace.","projects")),e.contracts.exists||t.push(b("warning","workspace.contract.missing","Workspace contract is missing; dependency and API edges may be incomplete.",e.contracts.workspaceContractPath));let s=new Map;for(let r of e.projects){let o=r.name.toLowerCase(),i=s.get(o)??[];i.push(r),s.set(o,i),r.importantFiles.length||t.push(b("warning","project.markers.missing",`Project ${r.name} has no important manifest files recorded.`,r.path)),r.runtime==="unknown"&&t.push(b("warning","project.runtime.unknown",`Project ${r.name} runtime could not be confidently detected.`,r.path));let c=["test","build"];for(let l of c)r.commands.supported.includes(l)&&r.commands.unsupported.includes(l)&&t.push(b("error","project.commands.conflict",`Project ${r.name} marks ${l} as both supported and unsupported.`,r.path));let d=new Set(r.commands.fleetStages),u=new Set(r.commands.localOnly);for(let l of r.commands.fleetStages){u.has(l)&&t.push(b("error","project.commands.scope-conflict",`Project ${r.name} marks ${l} as both fleet and local-only.`,r.path));let f=r.commands.map[l];(!f||f.status!=="supported"||f.fleetEligible!==true||f.executionScope!=="fleet")&&t.push(b("error","project.commands.fleet-stage-invalid",`Project ${r.name} advertises ${l} as a fleet stage without a supported fleet capability.`,r.path));}for(let l of r.commands.localOnly){let f=r.commands.map[l];(!f||f.status!=="supported"||f.executionScope!=="local-only"||f.fleetEligible===true)&&t.push(b("error","project.commands.local-only-invalid",`Project ${r.name} advertises ${l} as local-only without a matching local-only capability.`,r.path));}for(let l of Object.values(r.commands.map))l.status==="supported"&&(l.fleetEligible===true&&!d.has(l.command)&&t.push(b("error","project.commands.fleet-stage-missing",`Project ${r.name} capability ${l.command} is fleet-eligible but missing from fleetStages.`,r.path)),l.executionScope==="local-only"&&l.fleetEligible!==true&&!u.has(l.command)&&t.push(b("error","project.commands.local-only-missing",`Project ${r.name} capability ${l.command} is local-only but missing from localOnly commands.`,r.path)));}for(let[r,o]of s.entries())o.length>1&&t.push(b("error","project.name.duplicate",`Project name "${r}" is ambiguous across ${o.length} project roots.`,o.map(i=>i.path).join(", ")));let n=t.filter(r=>r.severity==="error").length,a=t.filter(r=>r.severity==="warning").length;return {status:n>0?"failed":a>0?"warning":"passed",errors:n,warnings:a,issues:t}}function cr(e){return Be(e)}function y(e){return e.join(".")}function yt(e,t){let s=te,n=e.generatedAt,a=[h({id:"workspace.name",label:"Workspace name",scope:"workspace",value:e.workspace.name,freshness:{kind:"durable",category:"structure",generatedAt:n,now:t,sourceArtifact:s,sourcePath:y(["workspace","name"]),reason:"Workspace identity is structural metadata and changes through workspace setup."}}),h({id:"workspace.type",label:"Workspace type",scope:"workspace",value:e.identity.workspaceType,freshness:{kind:"derived",category:"structure",generatedAt:n,now:t,sourceArtifact:s,sourcePath:y(["identity","workspaceType"]),reason:"Workspace type is derived from the current project inventory."}}),h({id:"workspace.projectCount",label:"Project count",scope:"workspace",value:e.summary.projectCount,freshness:{kind:"derived",category:"structure",generatedAt:n,now:t,sourceArtifact:s,sourcePath:y(["summary","projectCount"]),reason:"Project count is derived from workspace discovery and should be refreshed after structural changes."}}),h({id:"workspace.runtimeFamilies",label:"Runtime families",scope:"workspace",value:e.identity.runtimeFamilies,freshness:{kind:"derived",category:"structure",generatedAt:n,now:t,sourceArtifact:s,sourcePath:y(["identity","runtimeFamilies"]),reason:"Runtime coverage is inferred from project surfaces."}}),h({id:"workspace.policyMode",label:"Workspace policy mode",scope:"policy",value:e.policies.mode,freshness:{kind:"durable",category:"structure",generatedAt:n,now:t,sourceArtifact:s,sourcePath:y(["policies","mode"]),reason:"Policy mode is configuration, not runtime state."}}),h({id:"workspace.contract.exists",label:"Workspace contract presence",scope:"contract",value:e.contracts.exists,freshness:{kind:"derived",category:"structure",generatedAt:n,now:t,sourceArtifact:s,sourcePath:y(["contracts","exists"]),reason:"Contract presence is derived from workspace files and should be refreshed before release gating."}})];e.graph&&a.push(h({id:"graph.edgeCount",label:"Dependency graph edge count",scope:"graph",value:e.graph.stats.edgeCount,freshness:{kind:"derived",category:"structure",generatedAt:e.graph.generatedAt??n,now:t,sourceArtifact:s,sourcePath:y(["graph","stats","edgeCount"]),reason:"Graph topology is derived from manifests, imports, and workspace contracts."}}),h({id:"graph.evidenceCoverageRatio",label:"Dependency graph evidence coverage",scope:"graph",value:e.graph.stats.evidenceCoverageRatio,freshness:{kind:"derived",category:"structure",generatedAt:e.graph.generatedAt??n,now:t,sourceArtifact:s,sourcePath:y(["graph","stats","evidenceCoverageRatio"]),reason:"Graph evidence coverage changes when dependency evidence or contract edges change."}}));for(let[r,o]of e.projects.entries()){let i=`projects[${r}]`,c={kind:"derived",category:"structure",generatedAt:n,now:t,sourceArtifact:s,reason:"Project facts are derived from workspace discovery, project metadata, and framework probes."};a.push(h({id:`project.${o.name}.kind`,label:`${o.name} kind`,scope:"project",project:o.name,value:o.kind,freshness:{...c,sourcePath:y([i,"kind"])}}),h({id:`project.${o.name}.runtime`,label:`${o.name} runtime`,scope:"project",project:o.name,value:o.runtime,freshness:{...c,sourcePath:y([i,"runtime"])}}),h({id:`project.${o.name}.framework`,label:`${o.name} framework`,scope:"project",project:o.name,value:o.frameworkDisplayName,freshness:{...c,sourcePath:y([i,"frameworkDisplayName"])}}),h({id:`project.${o.name}.supportTier`,label:`${o.name} support tier`,scope:"project",project:o.name,value:o.supportTier,freshness:{...c,sourcePath:y([i,"supportTier"])}}),h({id:`project.${o.name}.safeFleetStages`,label:`${o.name} safe fleet stages`,scope:"command",project:o.name,value:o.commands.fleetStages,freshness:{...c,sourcePath:y([i,"commands","fleetStages"]),reason:"Safe command availability is derived from package and project command surfaces."}}));for(let[d,u]of Object.entries(o.evidence))a.push(h({id:`project.${o.name}.evidence.${d}`,label:`${o.name} ${d} evidence`,scope:"evidence",project:o.name,value:u?{path:u.path,exists:u.exists,status:u.status??null}:{exists:false},freshness:{kind:u?.exists?"evidence-backed":"verify-before-use",category:"verification",generatedAt:u?.generatedAt??n,now:t,status:u?.exists?void 0:"unknown",sourceArtifact:u?.path??s,sourcePath:y([i,"evidence",d]),verifyBeforeUse:true,reason:u?.exists?"Evidence reports can expire or become stale after source changes.":"Missing evidence must be generated before this fact is used for verification."}}));}for(let[r,o]of Object.entries(e.evidence))a.push(h({id:`workspace.evidence.${r}`,label:`Workspace ${r} evidence`,scope:"evidence",value:o?{path:o.path,exists:o.exists,status:o.status??null}:null,freshness:{kind:o?.exists?"evidence-backed":"verify-before-use",category:"verification",generatedAt:o?.generatedAt??n,now:t,status:o?.exists?void 0:"unknown",sourceArtifact:o?.path??s,sourcePath:y(["evidence",r]),verifyBeforeUse:true,reason:o?.exists?"Workspace evidence can expire or become stale after project, dependency, or policy changes.":"Missing workspace evidence must be generated before release or repair decisions."}}));return a}async function re(e){let t=p$1.resolve(e.workspacePath),s=e.includeAbsolutePaths===true,n=e.includeEvidence===true,a$4=le(e.observableScanDepth),r=e.now??new Date,[o$1,i,c,d,u]=await Promise.all([a$1(t),ue(t),a$2(t),a$3(t,{descendIntoMatchedProjects:false}),de(t,a$4)]),l=pe([...d,...u,...c.map(m=>p$1.isAbsolute(m.path)?m.path:p$1.join(t,m.path))]),f=e.reuseProjectModels,w=await Promise.all(l.map(m=>{if(f){let ze=p$1.relative(t,p$1.resolve(m)).split(p$1.sep).join("/"),me=f.get(ze);if(me)return Promise.resolve(me)}return gt(t,m,{includeAbsolutePaths:s,includeEvidence:n})})),x=typeof i?.workspace_name=="string"?i.workspace_name:typeof i?.name=="string"?i.name:o$1?.name||p$1.basename(t),j=typeof i?.profile=="string"?i.profile:typeof i?.mode=="string"?i.mode:void 0,R=Array.from(new Set(w.map(m=>m.kind))).sort(),E=Array.from(new Set(w.map(m=>m.runtime))).sort(),se=Array.from(new Set(w.map(m=>m.framework))).sort(),M=[".workspai/policies.yml",".workspai/policies.yaml",".rapidkit/policies.yml",".rapidkit/policies.yaml"].find(m=>C.existsSync(p$1.join(t,m))),I=o(t,"workspace.contract.json").map(m=>p$1.relative(t,m).split(p$1.sep).join("/")).find(m=>C.existsSync(p$1.join(t,m)))??".workspai/workspace.contract.json",P=await C.pathExists(p$1.join(t,I)),K={schemaVersion:it,generatedAt:r.toISOString(),workspace:{name:x,root:t,...j?{profile:j}:{},type:o$1?"rapidkit-workspace":"observed-workspace",...o$1?{marker:{createdBy:o$1.createdBy,version:o$1.version,createdAt:o$1.createdAt}}:{}},identity:{workspaceType:kt(w),surfaces:R,runtimeFamilies:E,businessCapabilities:ht(w)},discovery:{observableScanDepth:a$4},projects:w,policies:{mode:typeof i?.policy_mode=="string"?i.policy_mode:typeof i?.policyMode=="string"?i.policyMode:"warn",source:M??null,exists:!!M},contracts:{workspaceContractPath:I,exists:P,status:P?"known":"missing"},evidence:{doctor:await S(t,a.doctor,n),projectDoctor:await S(t,".workspai/reports/doctor-project-last-run.json",n),doctorRemediationPlan:await S(t,".workspai/reports/doctor-remediation-plan-last-run.json",n),artifactRemediationPlan:await S(t,".workspai/reports/artifact-remediation-plan-last-run.json",n),doctorFixResult:await S(t,".workspai/reports/doctor-fix-result-last-run.json",n),analyze:await S(t,a.analyze,n),readiness:await S(t,a.readiness,n),pipeline:await S(t,".workspai/reports/pipeline-last-run.json",n)},summary:{projectCount:w.length,runtimes:E,frameworks:se,firstClassProjects:w.filter(m=>m.supportTier==="first-class").length,observedProjects:w.filter(m=>m.supportTier==="observed").length}},O=await Le(t,K,{contractExists:P,now:r,incrementalGraph:e.incrementalGraph}),_={...K,graph:O},k=Be(_),v=yt({..._},r),W=Ve({facts:v,generatedAt:r.toISOString(),now:r});return {..._,facts:v,factFreshness:W,validation:k}}async function lr(e){if(e.cache!==true)return {model:await re(e),cache:"disabled"};let t=p$1.resolve(e.workspacePath),s=le(e.observableScanDepth),n=ie(),[a,r,o,i,c]=await Promise.all([a$1(t),ue(t),a$2(t),a$3(t,{descendIntoMatchedProjects:false}),de(t,s)]),d=pe([...i,...c,...o.map(j=>p$1.isAbsolute(j.path)?j.path:p$1.join(t,j.path))]),u=await Z({workspacePath:t,cliVersion:n,flags:{includeAbsolutePaths:e.includeAbsolutePaths===true,includeEvidence:e.includeEvidence===true,observableScanDepth:s},projectPaths:d,workspaceJson:r,marker:a}),l=await ce(t);if(l&&l.cliVersion===n&&l.inputsHash===u)return {model:l.model,cache:"hit"};let f=await re({...e}),[w,x]=await Promise.all([Y(t,d),Q(t)]);return await ee(t,{cliVersion:n,inputsHash:u,generatedAt:(e.now??new Date).toISOString(),model:f,projectSignatures:w,workspaceFileSignatures:x}),{model:f,cache:"miss"}}function wt(e,t){let s=new Set,n=new Set,a=new Set;for(let[r,o]of Object.entries(t))r in e?e[r]!==o&&s.add(r):n.add(r);for(let r of Object.keys(e))r in t||a.add(r);return {changed:s,added:n,removed:a}}function vt(e={},t={}){let s=new Set([...Object.keys(e),...Object.keys(t)]);for(let n of s)if(e[n]!==t[n])return false;return true}async function dr(e){let t=p$1.resolve(e.workspacePath),s=le(e.observableScanDepth),n=ie(),a=e.now??new Date,[r,o,i,c,d]=await Promise.all([a$1(t),ue(t),a$2(t),a$3(t,{descendIntoMatchedProjects:false}),de(t,s)]),u=pe([...c,...d,...i.map(k=>p$1.isAbsolute(k.path)?k.path:p$1.join(t,k.path))]),l=await ce(t),f=async()=>{let k=await re({...e}),v=await Z({workspacePath:t,cliVersion:n,flags:{includeAbsolutePaths:e.includeAbsolutePaths===true,includeEvidence:e.includeEvidence===true,observableScanDepth:s},projectPaths:u,workspaceJson:o,marker:r}),[W,m]=await Promise.all([Y(t,u),Q(t)]);return await ee(t,{cliVersion:n,inputsHash:v,generatedAt:a.toISOString(),model:k,projectSignatures:W,workspaceFileSignatures:m}),{model:k,mode:"full"}};if(!l||l.cliVersion!==n||!l.projectSignatures||!l.model?.graph)return f();let w=await Q(t);if(!vt(l.workspaceFileSignatures,w))return f();let x=await Y(t,u),{changed:j,added:R,removed:E}=wt(l.projectSignatures,x);if(j.size===0&&R.size===0&&E.size===0)return {model:l.model,mode:"unchanged"};let se=new Set([...j,...R]),M=new Map;for(let k of l.model.projects){let v=k.path.split(p$1.sep).join("/");!se.has(v)&&!E.has(v)&&M.set(v,k);}let I=new Set,P=false;for(let k of l.model.projects){let v=k.path.split(p$1.sep).join("/");j.has(v)&&I.add(k.name);}let K=R.size>0||E.size>0,O=await re({...e,reuseProjectModels:M,incrementalGraph:{previousGraph:l.model.graph,changedProjectIds:I,structuralChange:K||P}});for(let k of l.model.projects){let v=k.path.split(p$1.sep).join("/");if(!j.has(v))continue;let W=O.projects.find(m=>m.path.split(p$1.sep).join("/")===v);if(W&&W.name!==k.name){P=true;break}}if(P)return f();let _=await Z({workspacePath:t,cliVersion:n,flags:{includeAbsolutePaths:e.includeAbsolutePaths===true,includeEvidence:e.includeEvidence===true,observableScanDepth:s},projectPaths:u,workspaceJson:o,marker:r});return await ee(t,{cliVersion:n,inputsHash:_,generatedAt:a.toISOString(),model:O,projectSignatures:x,workspaceFileSignatures:w}),{model:O,mode:"incremental"}}async function He(e){try{let{contract:t}=await m({workspacePath:e});return t&&typeof t=="object"?t:null}catch{return null}}async function Le(e,t,s){let n=s.contractExists?await He(e):null;try{return s.incrementalGraph?await g({workspacePath:e,model:t,contract:n,now:s.now,previousGraph:s.incrementalGraph.previousGraph,changedProjectIds:s.incrementalGraph.changedProjectIds,structuralChange:s.incrementalGraph.structuralChange}):await f({workspacePath:e,model:t,contract:n,now:s.now})}catch{let a=t.projects.map(r=>({id:r.name,path:r.path}));return {schemaVersion:"workspace-dependency-graph.v1",generatedAt:s.now.toISOString(),nodes:a,edges:[],stats:{nodeCount:a.length,edgeCount:0,inferredEdges:0,contractEdges:0,manualEdges:0,authoritativeEdges:0,lowConfidenceEdges:0,orphanCount:a.length,connectedNodeCount:0,density:0,edgeCoverageRatio:a.length>0?0:1,evidenceCoverageRatio:1,hotspotCount:0,hasCycle:false},diagnostics:a.length>1?[{code:"graph.inference.failed",severity:"warning",message:"Dependency graph inference failed; model contains projects but no dependency edges.",recommendation:"Run workspace model again after fixing graph inputs, or add workspace contract/manual graph overrides.",nodeIds:a.map(r=>r.id).sort((r,o)=>r.localeCompare(o))}]:void 0}}}async function pr(e,t){let s=e.contracts.exists?await He(t):null,{buildWorkspaceKnowledgeGraph:n}=await import('./workspace-knowledge-graph-ARDC6HHG.js'),a$1=a$4(e),r=await n({workspacePath:t,workspace:{name:e.workspace.name,...e.workspace.profile?{profile:e.workspace.profile}:{}},projects:e.projects.map(i=>({id:i.name,path:i.path,...i.absolutePath?{absolutePath:i.absolutePath}:{},runtime:i.runtime,framework:i.framework,...i.kit?{kit:i.kit}:{}})),projectTopology:e.graph??await Le(t,e,{contractExists:e.contracts.exists,now:new Date(e.generatedAt)}),contract:s,now:new Date(e.generatedAt),source:{kind:"workspace-model",artifact:te,hashAlgorithm:"sha256",hash:d(a$1)}}),[,o]=await f$1(t,te,[{relativePath:a.knowledgeGraph,payload:r},{relativePath:te,payload:a$1}]);return o}export{Te as a,h as b,Ve as c,_e as d,Wt as e,Oe as f,it as g,te as h,cr as i,yt as j,re as k,lr as l,dr as m,pr as n};
@@ -0,0 +1,2 @@
1
+ import {a as a$1}from'./chunk-KB44JP4M.js';import {a,c,b,i}from'./chunk-BMWFQXGW.js';import h from'path';var w=Object.keys(a).flatMap(t=>{let o=t,a$1=b[o],r=c[o];return !a$1||!r?[]:[{artifactPath:a[o],schemaVersion:a$1,contractPath:r}]}),m=[{artifactPath:".workspai/workspace.contract.json",schemaVersion:1,contractPath:"contracts/workspace-contract.v1.json"},{artifactPath:".workspai/cache/workspace-model.v1.json",schemaVersion:"workspace-model-cache.v1",contractPath:"contracts/workspace-model-cache.v1.json"},{artifactPath:".workspai/workspace-registry.v1.json",schemaVersion:"workspace-registry.v1",contractPath:"contracts/workspace-registry.v1.json"},{artifactPath:".workspai/compatibility-matrix.json",schemaVersion:"rapidkit.compatibility-matrix.v1",contractPath:"contracts/compatibility-matrix.v1.json"},{artifactPath:".workspai/reports/doctor-workspace-cache.json",schemaVersion:"doctor-workspace-cache-v2",contractPath:"contracts/doctor-workspace-cache.v2.json"},{artifactPath:".workspai/reports/bootstrap-compliance.latest.json",schemaVersion:"bootstrap-compliance.v1",contractPath:"contracts/bootstrap-compliance.v1.json"},{artifactPath:".workspai/reports/mirror-ops.latest.json",schemaVersion:"mirror-ops.v1",contractPath:"contracts/mirror-ops.v1.json"},{artifactPath:".workspai/reports/transparency-evidence.latest.json",schemaVersion:"transparency-evidence.v1",contractPath:"contracts/transparency-evidence.v1.json"},{artifactPath:".workspai/reports/share-bundle.json",schemaVersion:"1.1",schemaVersionField:"schema_version",contractPath:"contracts/workspace-share-bundle.v1.json"},{artifactPath:".workspai/reports/doctor-project-last-run.json",schemaVersion:"doctor-project-evidence-v1",contractPath:"contracts/doctor-project-evidence.v1.json"},{artifactPath:".workspai/reports/doctor-remediation-plan-last-run.json",schemaVersion:"doctor-remediation-plan-v2",contractPath:"contracts/doctor-remediation-plan.v2.json"},{artifactPath:".workspai/reports/artifact-remediation-plan-last-run.json",schemaVersion:"artifact-remediation-plan-v1",contractPath:"contracts/artifact-remediation-plan.v1.json"},{artifactPath:".workspai/reports/doctor-fix-result-last-run.json",schemaVersion:"rapidkit-doctor-fix-result-v1",contractPath:"contracts/workspace-intelligence/doctor-fix-result.v1.json"},{artifactPath:".workspai/reports/pipeline-last-run.json",schemaVersion:"rapidkit-pipeline-v1",contractPath:"contracts/pipeline-last-run.v1.json"},{artifactPath:".workspai/reports/autopilot-release-last-run.json",schemaVersion:"autopilot-release-v1",contractPath:"contracts/autopilot-release.v1.json"},{artifactPath:".workspai/reports/autopilot-release.json",schemaVersion:"autopilot-release-v1",contractPath:"contracts/autopilot-release.v1.json"},{artifactPath:".workspai/reports/workspace-run-last.json",schemaVersion:"workspace-run-v1",contractPath:"contracts/workspace-run-last.v1.json"},{artifactPath:".workspai/reports/workspai-mcp-design.json",schemaVersion:"workspai-mcp-design.v1",contractPath:"contracts/workspace-intelligence/mcp-design.v1.json"},{artifactPath:".workspai/reports/workspace-why-last-run.json",schemaVersion:b.explain,contractPath:c.explain},{artifactPath:".workspai/reports/workspace-trace-last-run.json",schemaVersion:b.explain,contractPath:c.explain},{artifactPath:".vscode/workspai-agent-hooks.json",schemaVersion:"workspai-agent-hooks.v1",contractPath:"contracts/workspace-intelligence/agent-hooks.v1.json"},{artifactPath:".workspai/reports/infra-plan.json",schemaVersion:"rapidkit.infra-plan.v1",contractPath:"contracts/infra-plan.v1.json"}],d={".workspai/workspace.contract.json":[["workspace","sync"],["workspace","contract","sync"]],[a.intelligenceRun]:[["workspace","intelligence","run"]],[a.snapshot]:[["workspace","snapshot"]],[a.history]:[["workspace","feedback","record","--json"]],[a.evaluationLive]:[["workspace","eval","init"],["workspace","eval","record","--json"]],[a.evaluationLastRun]:[["workspace","eval","report","--json"]],".workspai/cache/workspace-model.v1.json":[["workspace","model"]],".workspai/workspace-registry.v1.json":[["workspace","sync"]],".workspai/compatibility-matrix.json":[["bootstrap"]],".workspai/reports/doctor-workspace-cache.json":[["doctor","workspace"]],".workspai/reports/bootstrap-compliance.latest.json":[["bootstrap"]],".workspai/reports/mirror-ops.latest.json":[["mirror","status"]],".workspai/reports/transparency-evidence.latest.json":[["mirror","sync"]],".workspai/reports/share-bundle.json":[["workspace","share"]],".workspai/reports/doctor-project-last-run.json":[["doctor","project"]],".workspai/reports/doctor-remediation-plan-last-run.json":[["workspace","remediation-plan"]],".workspai/reports/artifact-remediation-plan-last-run.json":[["workspace","remediation-plan"]],".workspai/reports/doctor-fix-result-last-run.json":[["doctor","workspace"]],".workspai/reports/pipeline-last-run.json":[["pipeline"]],".workspai/reports/autopilot-release-last-run.json":[["autopilot","release"]],".workspai/reports/autopilot-release.json":[["autopilot","release"]],".workspai/reports/workspace-run-last.json":[["workspace","run"]],".workspai/reports/workspai-mcp-design.json":[["workspace","agent-sync","--write"]],".workspai/reports/workspace-why-last-run.json":[["workspace","why"]],".workspai/reports/workspace-trace-last-run.json":[["workspace","trace"]],".vscode/workspai-agent-hooks.json":[["workspace","agent-sync"]],".workspai/reports/infra-plan.json":[["infra","plan"]]};function j(t){let o=Object.values(i).filter(r=>r.produces.includes(t)).map(r=>[...r.command]),a=d[t]??[];return [...o,...a.map(r=>[...r])]}var k=Object.freeze(Object.fromEntries([...w,...m].map(t=>[t.artifactPath,{...t,producerCommands:j(t.artifactPath)}])));function u(t){return t.split(h.sep).join("/").replace(/^\.\//,"")}var f=[{pattern:/^\.workspai\/reports\/bootstrap-compliance-[^/]+\.json$/,canonicalPath:".workspai/reports/bootstrap-compliance.latest.json"},{pattern:/^\.workspai\/reports\/mirror-ops-[^/]+\.json$/,canonicalPath:".workspai/reports/mirror-ops.latest.json"},{pattern:/^\.workspai\/reports\/transparency-evidence-[^/]+\.json$/,canonicalPath:".workspai/reports/transparency-evidence.latest.json"}];function P(t){let o=u(t),a=k[o];if(a)return a;let r=f.find(c=>c.pattern.test(o));return r?k[r.canonicalPath]??null:null}function y(t,o,a=t){let r=P(t);if(!r)return;let c=r.schemaVersionField??"schemaVersion",i=o&&typeof o=="object"?o[c]:void 0;if(i!==r.schemaVersion)throw new Error(`${a} schemaVersion is ${String(i)}, expected ${r.schemaVersion}`);a$1(o,r.contractPath,a);}
2
+ export{P as a,y as b};
@@ -0,0 +1 @@
1
+ import {b}from'./chunk-BMWFQXGW.js';var o="model-usage-event.v1",s=b.evaluationLive,a="workspace-intelligence-evaluation-comparison.v1",i=["provider-reported","tokenizer-counted","estimated","unavailable"];export{o as a,s as b,a as c,i as d};
@@ -0,0 +1,13 @@
1
+ import {a as a$1}from'./chunk-JEI6BTZI.js';import {a}from'./chunk-VU7NZHPM.js';import {c,e,d}from'./chunk-CRHYBQI3.js';import {d as d$1,b}from'./chunk-OW42TZFB.js';import {g}from'./chunk-AFL3ACCR.js';import {k}from'./chunk-37CVKXBD.js';import {m,a as a$2}from'./chunk-T4YR4RAI.js';import {e as e$1}from'./chunk-32OJDBIG.js';import {b as b$1}from'./chunk-3NU32T4A.js';import {a as a$3}from'./chunk-KB44JP4M.js';import j from'path';import W from'fs-extra';function G(e$1){switch(e$1){case "why":return d;case "trace":return e;default:return c}}async function P(e,n,o){try{if(!await W.pathExists(e))return null;let r=await W.readJson(e);return n?b$1(n,r,e):o&&a$3(r,o,e),r}catch(r){if((n||o)&&await W.pathExists(e))throw r;return null}}function z(e,n){if(!e)return null;let o=n.trim().toLowerCase();return e.projects.find(r=>r.slug.toLowerCase()===o||r.relativePath.toLowerCase()===o)??null}function J(e,n,o){let r=o.trim().toLowerCase(),t=(e.graph?.nodes.map(a=>a.id)??e.projects.map(a=>a.name)).find(a=>a.toLowerCase()===r);if(t)return t;let d=e.projects.find(a=>[a.name,a.path,j.basename(a.path)].filter(u=>u.trim().length>0).some(u=>u.toLowerCase()===r));if(d)return d.name;let c=z(n,o);if(c){let a=e.projects.find(u=>u.path===c.relativePath||u.path.endsWith(`/${c.relativePath}`));if(a)return a.name}return o}function X(e,n){if(!e)return [];let o=n.trim().toLowerCase(),r=new Set;for(let l of e.projects){l.contracts.dependsOn?.some(t=>t.toLowerCase()===o)&&r.add(l.slug);for(let t of l.contracts.consumes??[])for(let d of e.projects)d.contracts.publishes?.includes(t)&&d.slug===o&&r.add(l.slug);}return [...r].sort()}function Y(e,n){if(!e)return [];let o=n.trim().toLowerCase();return e.steps.filter(r=>r.scope==="project"&&r.project?.toLowerCase()===o&&r.command?.display).map(r=>r.command.display).slice(0,8)}function p(e,n,o){return {id:e,title:n,body:o.trim()}}async function me(e){let n=j.resolve(e.workspacePath),o=(e.now??new Date).toISOString(),r=e.model??await k({workspacePath:n,includeEvidence:true}),l=e.contract;if(l===void 0)try{l=(await m({workspacePath:n})).contract;}catch{l=null;}let t=e.verify;t===void 0&&(t=await P(j.join(n,d$1),d$1));let d=e.impact;if(d===void 0&&(d=await P(j.join(n,g),g)),e.target.kind==="release-blocked"){let s=t?.blockingReasons??[],i=(r.summary?.projectCount??r.projects.length)===0,g=[p("verdict",i?"Workspace scaffold posture":"Release verdict",t?i?`Scaffold posture: **${t.summary.verdict}** (exit ${t.summary.exitCode}). Freshness: **${t.freshness.verdict}**. No registered projects yet \u2014 release gates apply after the first project is added.`:`Verdict: **${t.summary.verdict}** (exit ${t.summary.exitCode}). Risk: **${t.impact.risk}**. Freshness: **${t.freshness.verdict}**.`:"No workspace verify report found. Run `npx workspai workspace verify --json --write` first."),p("blockers",i?"Pre-project signals":"Blocking reasons",s.length?s.map(h=>`- ${h}`).join(`
2
+ `):i?"No pre-project signals in the latest verify report.":"No blocking reasons in the latest verify report.")];return t?.resolutionHints?.length&&g.push(p("resolution","Resolution hints",t.resolutionHints.map(h=>`- **${h.blockerId}** (${h.resolutionClass}): ${h.commandRetryHint??h.fixHints[0]?.detail??"See fix hints"}`).join(`
3
+ `))),{schemaVersion:a,generatedAt:o,workspacePath:n,target:e.target,summary:t?i?b(s.length,t.summary.verdict):`${s.length>0||t.summary.verdict==="blocked"?"Release blocked":"Release posture"}: ${t.summary.verdict} with ${s.length} blocking reason(s).`:"Release posture unknown \u2014 verify report missing.",sections:g,releaseRisk:t?.impact.risk,blockingReasons:s,resolutionHints:t?.resolutionHints}}if(e.target.kind==="blocker"){let s=e.target,m=t?.resolutionHints?.find(g=>g.blockerId===s.blockerId),i=t?.blockingReasons.find(g=>g.includes(s.blockerId))??t?.blockingReasons[0];return {schemaVersion:a,generatedAt:o,workspacePath:n,target:s,summary:m?`Blocker ${s.blockerId}: ${m.resolutionClass}`:`Blocker ${s.blockerId} (no structured hint)`,sections:[p("reason","Blocking signal",i??"No matching blocking reason in verify."),p("hint","Resolution class",m?`${m.resolutionClass}
4
+
5
+ ${m.commandRetryHint??""}
6
+
7
+ ${m.fixHints.map(g=>`- ${g.detail}`).join(`
8
+ `)}`:"Run workspace verify to emit resolutionHints for this blocker.")],blockingReasons:i?[i]:[],resolutionHints:m?[m]:[]}}if(e.target.kind==="trace"){let s=j.isAbsolute(e.target.diffRef)?e.target.diffRef:j.join(n,e.target.diffRef),m=await P(s,void 0,"contracts/workspace-intelligence/workspace-model-diff.v1.json"),i=m?.summary?.changedProjects??[...new Set((m?.changes??[]).map(f=>f.project).filter(Boolean))],h=(r.summary?.projectCount??r.projects.length)===0,T=d?.transitiveImpact?.map(f=>`${f.project?.name??f.target} (d${f.distance??0}, via ${f.via??"\u2014"})`)??[],y=t?.affectedSubgraph;return {schemaVersion:a,generatedAt:o,workspacePath:n,target:e.target,summary:i?.length?`Trace from ${i.length} changed project(s) through blast radius to gate coverage.`:h?"Trace: workspace scaffold baseline \u2014 no project changes in the latest diff.":"Trace: diff baseline present with no project changes.",sections:[p("origin","Change origin",i?.length?i.map(f=>`- ${f}`).join(`
9
+ `):"No changed projects in diff."),p("blast-radius","Transitive impact",T.length?T.map(f=>`- ${f}`).join(`
10
+ `):"No transitive impact report."),p("gate","Subgraph gate",y?`Directly changed: ${y.directlyChanged}; transitive dependents: ${y.transitiveDependents}; covered: ${y.covered}; uncovered: ${y.uncovered}; unverifiable: ${y.unverifiable}.`:"No verify subgraph coverage available.")],releaseRisk:d?.summary?.risk??t?.impact.risk,blockingReasons:t?.blockingReasons}}let c=e.target.project,a$2=J(r,l,c),u=r.graph,k$1=u?a$1(u,a$2):{found:false,centrality:null,directDependents:[],transitiveDependents:[]},v=z(l,c),E=X(l,c),b$1=Y(t,c),w=r.projects.find(s=>s.name.toLowerCase()===c.toLowerCase()),x=[p("overview","Project overview",w?`${w.name} (${w.frameworkDisplayName}, ${w.runtime}) at \`${w.path}\`.`:`Project **${c}** ${k$1.found?"exists in graph":"not found in workspace model"}.`),p("consumers","Consumers / dependents",[`Direct dependents: ${k$1.directDependents.join(", ")||"none"}`,`Contract consumers: ${E.join(", ")||"none"}`,`Transitive dependents (blast radius): ${k$1.transitiveDependents.length}`].join(`
11
+ `)),p("contracts","Critical contracts",v?[`Owns: ${v.contracts?.owns?.join(", ")||"none"}`,`Publishes: ${v.contracts.publishes.join(", ")||"none"}`,`Consumes: ${v.contracts.consumes.join(", ")||"none"}`,`APIs: ${v.contracts.apis.map(s=>s.name).join(", ")||"none"}`].join(`
12
+ `):"No workspace.contract.json entry for this project."),p("verification","Required verification",b$1.length?b$1.map(s=>`- ${s}`).join(`
13
+ `):"- `npx workspai workspace verify --json`\n- Project test/build via `workspace run` when configured")];k$1.centrality&&x.push(p("centrality","Graph centrality",`fanIn ${k$1.centrality.fanIn}, fanOut ${k$1.centrality.fanOut}, reach ${k$1.centrality.reach}, hotspot ${k$1.centrality.isHotspot?"yes":"no"}.`));let I=c.trim().toLowerCase(),A=s=>s.project?.name?.toLowerCase()===I||s.target.toLowerCase()===I,S=d?.affectedProjects?.find(A)?.risk??d?.transitiveImpact?.find(A)?.risk??t?.impact.risk??"unknown";return {schemaVersion:a,generatedAt:o,workspacePath:n,target:e.target,summary:`${c}: ${E.length} consumer(s), release risk **${S}**.`,sections:x,releaseRisk:String(S)}}async function fe(e,n,o="explain"){let r=G(o);return await e$1(n,r,a$2(e)),r}export{G as a,me as b,fe as c};
@@ -0,0 +1,8 @@
1
+ import {f as f$2,e}from'./chunk-T3GJ7YVG.js';import {a as a$1,b as b$2}from'./chunk-22DT744Z.js';import {h,i}from'./chunk-4KUIFXHM.js';import {e as e$1}from'./chunk-32OJDBIG.js';import {a as a$2}from'./chunk-GZTYAEWX.js';import {a,b as b$1}from'./chunk-BMWFQXGW.js';import {f as f$1,o as o$1,p as p$1}from'./chunk-5XATWNME.js';import b from'fs';import p from'path';import o from'chalk';var H=new Set([".git",".workspai",".rapidkit",".venv","node_modules","dist","build","target","coverage","htmlcov",".next"]);async function D(e){try{return await b.promises.access(e,b.constants.F_OK),true}catch{return false}}async function P(e){try{let n=JSON.parse(await b.promises.readFile(e,"utf-8"));return n&&typeof n=="object"&&!Array.isArray(n)?n:null}catch{return null}}async function L(e){try{return await b.promises.readFile(e,"utf-8")}catch{return ""}}function K(e){return a$1(e)}async function B(e,n){return await N([...p$1(e,"project.json"),...p$1(e,"context.json")])?true:b$2(e)?false:p.resolve(e)===p.resolve(n)?h(e).length>0:h(e).length>0}async function U(e){let n=await a$2(e,{skipDirs:H,includeHiddenDirs:false,descendIntoMatchedProjects:false,isProjectDir:B});return n.length>0?n:b$2(e)?[]:h(e).length>0?[e]:[]}function V(e,n){return p.relative(e,n).replace(/\\/g,"/")||"."}async function A(e,n){for(let t of n)if(await D(p.join(e,t)))return true;return false}async function N(e){for(let n of e)if(await D(n))return true;return false}async function M(e){for(let n of e){let t=await P(n);if(t)return t}return null}async function q(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 Q(e){if(await A(e,["tests","test","__tests__","src/__tests__","pytest.ini","vitest.config.ts","jest.config.ts"]))return true;let t=await P(p.join(e,"package.json")),r=t?.scripts&&typeof t.scripts=="object"?t.scripts:{};return typeof r.test=="string"&&r.test.trim().length>0}async function X(e){let n=await P(p.join(e,"package.json")),t=n?.scripts&&typeof n.scripts=="object"?n.scripts:{};return Object.keys(t).sort()}function f(e,n,t,r,s,a){return {id:e,severity:n,target:t,title:r,detail:s,remediation:a}}function Y(e){let n=e.reduce((t,r)=>r.severity==="fail"?t+28:r.severity==="warn"?t+12:t+3,0);return Math.max(0,100-n)}async function Z(e,n){let t=await M(p$1(n,"project.json")),r=i(n,t),s=h(n),a=r.runtime==="unknown"?s[0]||"unknown":r.runtime,i$1=V(e,n),l=i$1,u=await X(n),g=await N([...p$1(n,"project.json"),...p$1(n,"context.json")]),d=await Q(n),h$1=await A(n,["Dockerfile","dockerfile"]),k=await A(n,[".env.example","env.example","config/env.example"]),z=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"]),C=await q(n),m=[];return r.key==="unknown"&&m.push(f("project.stack.unknown","fail",l,"Project stack is unknown","Workspai cannot confidently classify this backend project.","Add .workspai/project.json metadata or import the project with `workspai import`.")),g||m.push(f("project.marker.missing","warn",l,"Workspai marker is missing","The project can be detected by files, but it is not registered with Workspai metadata.","Run `workspai import <path>` from a workspace or create the project through Workspai.")),d||m.push(f("project.tests.missing","warn",l,"Test entrypoint is missing","No common test folder, config, or package test script was found.","Add a test command so `workspai workspace run test --affected` can gate changes.")),k||m.push(f("project.env.example.missing","info",l,"Environment example is missing","No .env.example or env.example file was found.","Add an env example for onboarding and CI secret documentation.")),z||m.push(f("project.ci.missing","warn",l,"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.")),C||m.push(f("project.health.missing","info",l,"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.")),h$1||m.push(f("project.container.missing","info",l,"Container recipe is missing","No Dockerfile was found for this project.","Add a Dockerfile when the service is intended for containerized deployment.")),{name:p.basename(n),path:n,relativePath:i$1,runtime:a,framework:r.key,confidence:r.confidence,supportTier:r.supportTier,hasRapidKitMarker:g,hasTests:d,hasDockerfile:h$1,hasEnvExample:k,hasCiConfig:z,hasHealthEndpoint:C,scripts:u,findings:m,score:Y(m)}}function ee(e){return e.name.toLowerCase()}async function ne(e){let n=new Map(e.map(s=>[ee(s),s])),t=[];for(let s of e){let a=await P(p.join(s.path,"package.json")),i={...a?.dependencies??{},...a?.devDependencies??{},...a?.peerDependencies??{}};for(let u of Object.keys(i)){let g=u.replace(/^@[^/]+\//,"").toLowerCase(),d=n.get(g);d&&d.relativePath!==s.relativePath&&t.push({from:s.relativePath,to:d.relativePath,kind:"package"});}let l=await L(p.join(s.path,"pyproject.toml"));for(let u of e)u.relativePath!==s.relativePath&&l.includes(u.name)&&t.push({from:s.relativePath,to:u.relativePath,kind:"workspace-reference"});}let r=new Set;return t.filter(s=>{let a=`${s.from}\0${s.to}\0${s.kind}`;return r.has(a)?false:(r.add(a),true)})}function te(e,n){let t=new Map;for(let r of e)t.set(r.relativePath,{project:r.relativePath,directDependents:0,directDependencies:0});for(let r of n){let s=t.get(r.from),a=t.get(r.to);s&&(s.directDependencies+=1),a&&(a.directDependents+=1);}return Array.from(t.values()).sort((r,s)=>s.directDependents-r.directDependents||s.directDependencies-r.directDependencies)}async function re(e){let n=await M(o$1(e,"workspace.json"));return typeof n?.profile=="string"?n.profile:null}function se(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 oe(e){if(e.projectCount===0)return e.workspaceDetected?["Add your first project: npx workspai create project <name> --kit <kit>","Import an existing service: npx workspai import <path>"]:["Create a Workspai workspace: npx workspai create workspace my-workspace --profile polyglot","Import an existing service: npx workspai import ../service"];let n=[];return e.findings.some(t=>t.id==="workspace.marker.missing")&&n.push("Initialize workspace metadata with `workspai bootstrap --profile polyglot`."),e.findings.some(t=>t.id==="project.marker.missing")&&n.push("Register detected projects with `workspai import <path>` or recreate them via `workspai create project`."),e.findings.some(t=>t.id==="project.tests.missing")&&n.push("Add test entrypoints, then gate changes with `workspai 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 `.workspai/workspace-dependency-graph.json` or use analyze output as the first graph seed."),n.push("Run `workspai autopilot release --mode audit --json` before release."),Array.from(new Set(n))}async function ke(e$2={}){let n=p.resolve(e$2.workspacePath||process.cwd());if(!await D(n))throw new Error(`Workspace path does not exist: ${n}`);let t=K(n)??n,r=f$1(t),s=await re(t),a$1=await U(t),i=await Promise.all(a$1.map(c=>Z(t,c))),l=await ne(i),u=te(i,l),g=[];r||g.push(f("workspace.marker.missing","warn",".","Workspace metadata is missing","The directory can be analyzed, but it is not a registered Workspai workspace.","Run `workspai create workspace` or `workspai bootstrap --profile polyglot` in a workspace root.")),i.length===0&&g.push(f("workspace.projects.missing","warn",".","No backend projects detected","Workspai did not find runtime markers or project metadata under this root.","Create a project with `workspai create project` or import one with `workspai import <path>`."));let d=[...g,...i.flatMap(c=>c.findings)],h=se(d),k={};for(let c of i)k[c.runtime]=(k[c.runtime]||0)+1;let z=i.length>0?Math.round(i.reduce((c,y)=>c+y.score,0)/i.length):0,C=g.reduce((c,y)=>c+(y.severity==="fail"?20:y.severity==="warn"?8:2),0),m=Math.max(0,z-C),O=i.length===0&&h.fail===0&&d.length>0&&d.every(c=>c.id==="workspace.projects.missing"&&c.severity==="warn"),J=h.fail>0||e$2.strict&&h.warn>0&&!O?"blocked":h.warn>0?"needs-attention":"ready",w={schemaVersion:b$1.analyze,generatedAt:new Date().toISOString(),workspacePath:t,workspaceDetected:r,profile:s,summary:{score:m,verdict:J,projectCount:i.length,runtimeCount:Object.keys(k).length,findings:h},runtimes:k,projects:i,dependencyGraph:{status:l.length>0?"generated":"empty",edges:l,topImpactedProjects:u.slice(0,5)},findings:d,nextActions:oe({findings:d,projectCount:i.length,hasGraph:l.length>0,workspaceDetected:r}),enterpriseControls:{jsonReady:true,ciGateCommand:"workspai analyze --json --strict",releaseGateCommand:"workspai autopilot release --mode enforce --json",evidencePath:a.analyze}};if(e$2.output&&(await b.promises.mkdir(p.dirname(p.resolve(e$2.output)),{recursive:true}),await b.promises.writeFile(p.resolve(e$2.output),`${JSON.stringify(w,null,2)}
2
+ `)),!e$2.output&&r){let c=f$2(w,{commandId:"workspaceAnalyze",exitCode:w.summary.verdict==="blocked"?2:w.summary.verdict==="needs-attention"?1:0,generatedAt:w.generatedAt,blockers:w.findings.filter(y=>y.severity==="fail").map(y=>y.title).slice(0,12),runId:e()});await e$1(t,a.analyze,c);}return w}function we(e){let n=e.summary.verdict==="ready"?o.green:e.summary.verdict==="needs-attention"?o.yellow:o.red;if(console.log(o.bold(`
3
+ Workspai Workspace Analysis
4
+ `)),console.log(o.cyan("Workspace:"),e.workspacePath),console.log(o.cyan("Profile:"),e.profile||"not configured"),console.log(o.cyan("Score:"),`${e.summary.score}/100`),console.log(o.cyan("Verdict:"),n(e.summary.verdict)),console.log(o.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(o.bold(`
5
+ Projects`));for(let t of e.projects){let r=t.score>=85?o.green("pass"):t.score>=65?o.yellow("watch"):o.red("risk");console.log(` ${t.relativePath} ${o.gray(`${t.runtime}/${t.framework}`)} ${r} ${t.score}/100`);}}if(e.dependencyGraph.status==="generated"&&(console.log(o.bold(`
6
+ Dependency Graph`)),console.log(o.gray(` edges: ${e.dependencyGraph.edges.length}`)),e.dependencyGraph.topImpactedProjects.length>0)){console.log(o.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(o.bold(`
7
+ Top Findings`));for(let t of e.findings.slice(0,8)){let r=t.severity==="fail"?o.red:t.severity==="warn"?o.yellow:o.gray;console.log(` ${r(t.severity.toUpperCase())} ${t.target}: ${t.title}`),console.log(o.gray(` ${t.remediation}`));}}console.log(o.bold(`
8
+ Next Actions`));for(let t of e.nextActions.slice(0,5))console.log(o.gray(` - ${t}`));console.log();}export{ke as a,we as b};
@@ -0,0 +1,8 @@
1
+ import {a as a$2}from'./chunk-QNONOO4F.js';import {a as a$5}from'./chunk-22DT744Z.js';import {a as a$3,e}from'./chunk-HDXNIN4N.js';import {d,a as a$1,e as e$1}from'./chunk-32OJDBIG.js';import {a}from'./chunk-BMWFQXGW.js';import a$4 from'chalk';import se from'fs';import b from'path';import {execa}from'execa';var G="autopilot-release-last-run.json",V="autopilot-release.json";function j(r){try{return JSON.parse(r)}catch{return null}}function Re(r){let e=b.resolve(r),n=a$5(e);if(!n)throw new Error("No Workspai workspace found in current directory or parents");return n}async function S(r,e){let n=process.argv[1];if(!n)return {exitCode:1,stdout:"",stderr:"RapidKit entrypoint is unavailable for autopilot execution.",crashed:true};try{let o=await execa(process.execPath,[n,...r],{cwd:e,reject:false,env:{...process.env,RAPIDKIT_AUTOPILOT_CHILD:"1"}});return {exitCode:Number(o.exitCode??1),stdout:o.stdout,stderr:o.stderr,crashed:false}}catch(o){return {exitCode:1,stdout:"",stderr:o instanceof Error?o.message:String(o),crashed:true}}}function re(r){let e=r.toLowerCase();return e==="pass"?"pass":e==="warn"?"warn":e==="fail"?"fail":"warn"}function oe(r){return r.summary.failed>0||r.gates.results.some(e=>e.status==="fail")?"fail":r.gates.results.some(e=>e.status==="warn")?"warn":"pass"}function Se(r){let e=r.filter(o=>o.status!=="skipped");if(e.length===0)return 100;let n=e.reduce((o,t)=>t.status==="pass"?o+1:t.status==="warn"?o+.6:o,0);return Math.round(n/e.length*100)}function be(r){return r.executionError?["Re-run: npx workspai autopilot release --mode audit --json","Inspect .workspai/reports/autopilot-release-last-run.json for execution failure details"]:r.blockers.length>0?["Run: npx workspai doctor workspace --plan","Run: npx workspai readiness --json --strict","Run: npx workspai workspace run test --affected --strict"]:r.hasWarnings&&r.mode!=="enforce"?["Review warning-level findings in autopilot report","Optionally run: npx workspai autopilot release --mode safe-fix"]:["Workspace is release-ready based on current autopilot policy"]}async function xe(r,e){await se.promises.mkdir(b.dirname(r),{recursive:true}),await se.promises.writeFile(r,`${JSON.stringify(e,null,2)}
2
+ `,"utf-8");}async function Me(r){let e$2=Re(r.workspacePath),n=r.mode,o=[],t=[],F,H,D,q,Q,X=0,f=false,T=0,L=0,N=-1,W=-1,c="skipped",d$1="skipped",ae=n==="enforce"?["doctor","workspace","--json","--strict"]:["doctor","workspace","--json","--ci"];if(r.skipPipelineStages)o.push({name:"doctor-workspace",status:"skipped",durationMs:0,summary:"doctor stage skipped (pipeline already executed)"},{name:"analyze",status:"skipped",durationMs:0,summary:"analyze stage skipped (pipeline already executed)"},{name:"readiness",status:"skipped",durationMs:0,summary:"readiness stage skipped (pipeline already executed)"});else {let s=Date.now(),l=await S([...ae],e$2),m=Date.now()-s;if(c="pass",l.crashed)c="fail",f=true,t.push(`doctor workspace execution error: ${l.stderr||"unknown error"}`);else if(l.exitCode===1)c="fail",t.push("doctor workspace command failed or reported errors");else if(l.exitCode===2)c="warn",t.push("doctor workspace reported warnings");else if(l.exitCode!==0)c="fail",t.push("doctor workspace command failed");else {let p=j(l.stdout),E=p&&p.healthScore&&typeof p.healthScore=="object"?p.healthScore:{},k=Number(E.errors??0),$=Number(E.warnings??0);Number.isFinite(k)&&k>0?(c="fail",t.push(`doctor workspace reports ${k} error(s)`)):Number.isFinite($)&&$>0&&(c="warn");}N=o.push({name:"doctor-workspace",status:c,durationMs:m,summary:c==="pass"?"doctor workspace passed":c==="warn"?"doctor workspace reported warnings":"doctor workspace reported errors"})-1,n==="enforce"&&c==="warn"&&t.push("doctor workspace reported warnings under enforce mode");let g=Date.now(),w=await S(["analyze","--json"],e$2),v=Date.now()-g;H=await d(e$2,a.analyze)??a$1(e$2,a.analyze);let i="pass";if(w.crashed)i="fail",f=true,t.push(`analyze execution error: ${w.stderr||"unknown error"}`);else if(w.exitCode!==0)i=w.exitCode===2?"warn":"fail",t.push(w.exitCode===2?"analyze reported needs-attention verdict":"analyze command failed or reported blocked verdict");else {let p=j(w.stdout),E=p&&p.summary&&typeof p.summary=="object"?p.summary:{},k=String(E.verdict??"ready");k==="blocked"?(i="fail",t.push("analyze reported blocked verdict")):k==="needs-attention"&&(i="warn");}o.push({name:"analyze",status:i,durationMs:v,summary:i==="pass"?"analyze passed":i==="warn"?"analyze reported needs-attention":"analyze reported blocked verdict"}),n==="enforce"&&i==="warn"&&t.push("analyze reported warnings under enforce mode");let P=Date.now(),h=await S(["readiness","--json"],e$2),y=Date.now()-P;if(d$1="fail",h.crashed)d$1="fail",f=true,t.push(`readiness execution error: ${h.stderr||"unknown error"}`);else if(h.exitCode!==0)d$1="fail",t.push("readiness command failed");else {let p=j(h.stdout),E=String(p?.overallStatus??"fail");if(d$1=re(E),typeof p?.evidencePath=="string"&&p.evidencePath.trim().length>0&&(F=p.evidencePath),d$1==="fail"){let k=Array.isArray(p?.blockingReasons)?p?.blockingReasons.filter($=>typeof $=="string"):[];k.length>0?t.push(...k.map($=>`readiness: ${$}`)):t.push("readiness overall status is fail");}}W=o.push({name:"readiness",status:d$1,durationMs:y,summary:`readiness overall status is ${d$1}`})-1,n==="enforce"&&d$1==="warn"&&t.push("readiness reported warnings under enforce mode");}let ne=Date.now(),z=await S(["doctor","workspace","--plan","--json"],e$2),ie=Date.now()-ne,R="warn";if(z.crashed)R="fail",f=true,t.push(`doctor remediation plan execution error: ${z.stderr||"unknown error"}`);else if(z.exitCode!==0)R="fail",t.push("doctor remediation plan command failed");else {let s=j(z.stdout),l=s&&s.remediationPlan&&typeof s.remediationPlan=="object"?s.remediationPlan:null,m=Number(l?.totalSteps??0),g=Number(l?.executableSteps??0);Number.isFinite(m)&&m>0&&(T=m),Number.isFinite(g)&&g>0&&(L=g),Number.isFinite(m)&&m===0?R="pass":R="warn";}if(o.push({name:"remediation-plan",status:R,durationMs:ie,summary:R==="pass"?"no remediation steps required":"remediation steps available"}),n==="enforce"&&R==="warn"&&t.push("remediation plan has pending steps under enforce mode"),n==="safe-fix"){let s=Date.now(),l=await S(["doctor","workspace","--apply"],e$2),m=Date.now()-s,g=l.crashed||l.exitCode!==0?"fail":"pass";if(l.crashed)f=true,t.push(`doctor remediation apply execution error: ${l.stderr||"unknown error"}`);else if(g==="fail")t.push("doctor remediation apply failed");else {X=L>0?L:T>0?T:1;let w=await S(["doctor","workspace","--json"],e$2);if(w.crashed)c="fail",f=true,t.push(`post-apply doctor execution error: ${w.stderr||"unknown error"}`);else if(w.exitCode!==0)c="fail",t.push("post-apply doctor workspace command failed");else {let i=j(w.stdout),P=i&&i.healthScore&&typeof i.healthScore=="object"?i.healthScore:{},h=Number(P.errors??0),y=Number(P.warnings??0);Number.isFinite(h)&&h>0?(c="fail",t.push(`post-apply doctor reports ${h} error(s)`)):Number.isFinite(y)&&y>0?c="warn":c="pass";}N>=0&&(o[N].status=c,o[N].summary=`doctor workspace post-apply status is ${c}`);let v=await S(["readiness","--json"],e$2);if(v.crashed)d$1="fail",f=true,t.push(`post-apply readiness execution error: ${v.stderr||"unknown error"}`);else if(v.exitCode!==0)d$1="fail",t.push("post-apply readiness command failed");else {let i=j(v.stdout),P=String(i?.overallStatus??"fail");if(d$1=re(P),typeof i?.evidencePath=="string"&&i.evidencePath.trim().length>0&&(F=i.evidencePath),d$1==="fail"){let h=Array.isArray(i?.blockingReasons)?i?.blockingReasons.filter(y=>typeof y=="string"):[];h.length>0?t.push(...h.map(y=>`post-apply readiness: ${y}`)):t.push("post-apply readiness overall status is fail");}}W>=0&&(o[W].status=d$1,o[W].summary=`readiness post-apply overall status is ${d$1}`);}o.push({name:"remediation-apply",status:g,durationMs:m,summary:g==="pass"?"safe remediation apply completed":"safe remediation apply failed"});}else o.push({name:"remediation-apply",status:"skipped",durationMs:0,summary:"remediation apply is skipped for this mode"});let le=Date.now(),x="pass",A="workspace test/build completed for selected projects";try{let s=await a$2({workspacePath:e$2,stage:"test",affected:true,since:r.since,parallel:r.parallel,maxWorkers:r.maxWorkers,strict:true,json:true,enforceGates:false});D=a$1(e$2,b.join(".workspai","reports",a$3)),await e(e$2,s),q=D;let l=oe(s);if(l==="fail")x="fail",A="workspace test stage failed for selected projects",t.push("workspace run test failed for selected projects");else {l==="warn"&&(x="warn",A="workspace test stage completed with warnings",n==="enforce"&&t.push("workspace run test reported warnings under enforce mode"));let m=await a$2({workspacePath:e$2,stage:"build",affected:true,since:r.since,parallel:r.parallel,maxWorkers:r.maxWorkers,strict:true,json:true,enforceGates:false});await e(e$2,m),Q=D;let g=oe(m);g==="fail"?(x="fail",A="workspace build stage failed for selected projects",t.push("workspace run build failed for selected projects")):g==="warn"&&(x="warn",A="workspace test/build completed with warnings",n==="enforce"&&t.push("workspace run test/build reported warnings under enforce mode"));}}catch(s){x="fail",A="workspace test/build orchestration failed",f=true,t.push(`workspace run orchestration error: ${s instanceof Error?s.message:String(s)}`);}let ce=Date.now()-le;o.push({name:"workspace-run-test-build",status:x,durationMs:ce,summary:A});let M=o.filter(s=>s.status==="warn").length,pe=o.filter(s=>s.status==="fail").length,_=n==="enforce"?o.some(s=>s.status==="warn"||s.status==="fail"):pe>0,C=[...new Set(t)],O=f||_?Math.max(1,C.length):0,ue=O>0?C:[],de=O===0?C:[],fe=Se(o),me=f||_?"blocked":M>0?"partial":"approved",ge=f?3:_?1:M>0?2:0,we=be({mode:n,executionError:f,blockers:C,hasWarnings:M>0}),Y=a$1(e$2,".workspai/reports"),he=b.join(Y,G),ke=b.join(Y,V),u={schemaVersion:"autopilot-release-v1",generatedAt:new Date().toISOString(),workspacePath:e$2,mode:n,summary:{releaseScore:fe,verdict:me,blockers:O,warnings:M,safeFixesApplied:X,manualActions:C.length,exitCode:ge},stages:o,blockingReasons:ue,warningReasons:de,nextActions:we,artifacts:{reportPath:he,aliasEvidencePath:ke,analyzeEvidencePath:H,readinessEvidencePath:F,workspaceRunEvidencePath:D,workspaceRunTestPath:q,workspaceRunBuildPath:Q},enterpriseControls:{jsonReady:true,evidencePath:`.workspai/reports/${G}`,aliasEvidencePath:`.workspai/reports/${V}`}};if(await e$1(e$2,`.workspai/reports/${G}`,u),await e$1(e$2,`.workspai/reports/${V}`,u),r.output&&await xe(b.resolve(r.output),u),!r.json){console.log(a$4.bold.cyan(`
3
+ \u{1F680} Workspai Autopilot Release
4
+ `)),console.log(a$4.bold(`Workspace: ${a$4.cyan(b.basename(e$2))}`)),console.log(a$4.gray(`Path: ${e$2}`)),console.log(a$4.white(`Mode: ${n}`)),console.log(a$4.white(`Verdict: ${u.summary.verdict==="approved"?a$4.green("approved"):u.summary.verdict==="partial"?a$4.yellow("partial"):a$4.red("blocked")}`)),console.log(a$4.white(`Release score: ${u.summary.releaseScore}`));for(let s of u.stages){let l=s.status==="pass"?a$4.green("PASS"):s.status==="warn"?a$4.yellow("WARN"):s.status==="skipped"?a$4.gray("SKIP"):a$4.red("FAIL");console.log(` - ${s.name}: ${l} ${s.summary} (${s.durationMs}ms)`);}if(u.blockingReasons.length>0){console.log(a$4.bold.red(`
5
+ Blocking reasons:`));for(let s of u.blockingReasons)console.log(a$4.red(` - ${s}`));}if(u.warningReasons.length>0){console.log(a$4.bold.yellow(`
6
+ Warning reasons:`));for(let s of u.warningReasons)console.log(a$4.yellow(` - ${s}`));}if(u.nextActions.length>0){console.log(a$4.bold(`
7
+ Next actions:`));for(let s of u.nextActions)console.log(a$4.gray(` - ${s}`));}console.log(a$4.gray(`
8
+ Report: ${u.artifacts.reportPath}`));}return u}export{G as a,V as b,Me as c};
@@ -0,0 +1,2 @@
1
+ import {k,h as h$1,g}from'./chunk-37CVKXBD.js';import {a as a$2}from'./chunk-HTYMXMQM.js';import {c}from'./chunk-S5KTATOU.js';import {d,b as b$1}from'./chunk-OA537ZQ5.js';import {a as a$1}from'./chunk-T4YR4RAI.js';import {e}from'./chunk-32OJDBIG.js';import {a as a$3}from'./chunk-KB44JP4M.js';import {b,a}from'./chunk-BMWFQXGW.js';import k$1 from'path';import V from'fs-extra';import {spawnSync}from'child_process';function me(){let e={...process.env};return delete e.GIT_DIR,delete e.GIT_WORK_TREE,delete e.GIT_INDEX_FILE,delete e.GIT_PREFIX,e}function F(e,t,a){let r=spawnSync("git",t,{cwd:e,env:me(),encoding:"utf8",stdio:["ignore","pipe","ignore"]});if(r.status!==0)return {ok:false,stdout:""};let c=r.stdout??"";return {ok:true,stdout:a?.preserveWhitespace?c:c.trim()}}function fe(e){let t=e.replace(/\\/g,"/").replace(/^\.\//,"");return t===".workspai/AGENT-GROUNDING.md"?true:[".workspai/reports/",".workspai/cache/",".rapidkit/reports/",".rapidkit/cache/"].some(a=>t.startsWith(a))}function ue(e){let t=[],a=[],r=[];for(let c of e.split(`
2
+ `)){if(!c.trim())continue;let n=c.slice(0,2),i=c.slice(3).trim();if(i&&!fe(i)){if(n==="??"){a.push(i);continue}n.includes("D")&&r.push(i),t.push(i);}}return {changedFiles:[...new Set(t)].sort(),untrackedFiles:[...new Set(a)].sort(),deletedFiles:[...new Set(r)].sort()}}function X(e,t){let a={available:false,dirty:false,changedFiles:[],untrackedFiles:[],deletedFiles:[]},r=F(e,["rev-parse","--is-inside-work-tree"]);if(!r.ok||r.stdout!=="true")return a;let c=F(e,["rev-parse","--abbrev-ref","HEAD"]),n=F(e,["rev-parse","HEAD"]),i=F(e,["status","--porcelain=v1","--untracked-files=all"],{preserveWhitespace:true}),p=ue(i.stdout),m=p.changedFiles.length>0||p.untrackedFiles.length>0||p.deletedFiles.length>0;return {available:true,branch:c.ok?c.stdout:void 0,commit:n.ok?n.stdout:void 0,ref:t?.ref,dirty:m,changedFiles:p.changedFiles,untrackedFiles:p.untrackedFiles,deletedFiles:p.deletedFiles}}var te=b.snapshot,L=b.diff,T=a.snapshot,re=a.diff,ge=b.impact,ke=a.impact;function oe(e){let t=e.trim().toLowerCase();return t==="git"||t.startsWith("git:")}function he(e){let t=e.trim();return t.toLowerCase()==="git"?"HEAD":t.toLowerCase().startsWith("git:")&&t.slice(4).trim()||"HEAD"}function ae(e,t){return k$1.isAbsolute(t)?t:k$1.join(e,t)}async function we(e){let t=await V.readJson(e);if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`Workspace model input is not a JSON object: ${e}`);let a=t;if(a.schemaVersion===te){a$3(t,"contracts/workspace-intelligence/workspace-model-snapshot.v1.json",`Workspace model snapshot ${e}`);let r=a;if(!r.model||r.model.schemaVersion!==g)throw new Error(`Invalid workspace model snapshot: ${e}`);let c=d(r.model);if(r.modelHash!==c)throw new Error(`Workspace model snapshot hash mismatch: ${e}`);return {model:r.model,hash:r.modelHash}}if(a.schemaVersion===g){a$3(t,"contracts/workspace-intelligence/workspace-model.v1.json",`Workspace model ${e}`);let r=a;return {model:r,hash:d(r)}}throw a.schemaVersion===L?new Error(`workspace diff --from received a diff report (${k$1.basename(e)}). Use a workspace model snapshot or model report as baseline, e.g. ${T}. To analyze an existing diff report, run: npx workspai workspace impact --from ${k$1.basename(e)} --json`):new Error(`Unsupported workspace model input schema: ${String(a.schemaVersion)}`)}async function ye(e){let t=await V.readJson(e);if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`Workspace diff input is not a JSON object: ${e}`);let a=t;if(a.schemaVersion!==L)return null;a$3(t,"contracts/workspace-intelligence/workspace-model-diff.v1.json",`Workspace model diff ${e}`);let r=a;if(!r.currentModel||r.currentModel.schemaVersion!==g||!r.summary||!Array.isArray(r.changes))throw new Error(`Invalid workspace model diff report: ${e}`);if(r.toHash!==d(r.currentModel))throw new Error(`Workspace model diff current-model hash mismatch: ${e}`);return r}async function Je(e){let t=e.model??await k({workspacePath:e.workspacePath,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,observableScanDepth:e.observableScanDepth,now:e.now});return {schemaVersion:te,generatedAt:(e.now??new Date).toISOString(),modelHash:d(t),modelRef:h$1,model:t}}async function Ue(e$1,t){return e(t,T,a$1(e$1))}function x(e){return {name:e.name,path:e.path,kind:e.kind,runtime:e.runtime,framework:e.framework,generator:e.generator,supportTier:e.supportTier,commands:e.commands,importantFiles:e.importantFiles}}function w(e,t){e.push(t);}function We(e,t){let a=[],r=["name","profile","type"],c=["workspaceType","surfaces","runtimeFamilies","businessCapabilities"];for(let n of r){let i=e.workspace[n],p=t.workspace[n];b$1(i)!==b$1(p)&&w(a,{type:"workspace.changed",severity:"info",target:`workspace.${n}`,message:`Workspace metadata field changed: ${String(n)}`,before:i,after:p});}for(let n of c){let i=e.identity[n],p=t.identity[n];b$1(i)!==b$1(p)&&w(a,{type:"workspace.changed",severity:"info",target:`identity.${n}`,message:`Workspace identity field changed: ${String(n)}`,before:i,after:p});}return b$1(e.policies)!==b$1(t.policies)&&w(a,{type:"workspace.changed",severity:"warning",target:"policies",message:"Workspace policy summary changed.",before:e.policies,after:t.policies}),b$1(e.discovery)!==b$1(t.discovery)&&w(a,{type:"workspace.changed",severity:"info",target:"discovery",message:"Workspace discovery settings changed.",before:e.discovery,after:t.discovery}),e.contracts.exists!==t.contracts.exists&&w(a,{type:"workspace.changed",severity:t.contracts.exists?"info":"warning",target:t.contracts.workspaceContractPath,message:"Workspace contract presence changed.",before:e.contracts.exists,after:t.contracts.exists}),a}function be(e,t){let a=e.validation??null,r=t.validation??null;return b$1(a)===b$1(r)?[]:[{type:"validation.changed",severity:r?.status==="failed"?"critical":"warning",target:"validation",message:"Workspace model validation changed.",before:a,after:r}]}function ve(e,t){let a=[],r=new Map(e.projects.map(n=>[n.path,n])),c=new Map(t.projects.map(n=>[n.path,n]));for(let[n,i]of c.entries()){let p=r.get(n);if(!p){w(a,{type:"project.added",severity:"info",target:n,message:`Project added: ${i.name}`,after:x(i)});continue}let m=x(p),l=x(i);if(b$1(m)!==b$1(l)){let u=p.runtime!==i.runtime||p.framework!==i.framework;w(a,{type:"project.changed",severity:u?"warning":"info",target:n,message:`Project changed: ${i.name}`,before:m,after:l});}}for(let[n,i]of r.entries())c.has(n)||w(a,{type:"project.removed",severity:"warning",target:n,message:`Project removed: ${i.name}`,before:x(i)});return a.sort((n,i)=>`${n.type}:${n.target}`.localeCompare(`${i.type}:${i.target}`))}async function je(e){let t=k$1.resolve(e.workspacePath),a=oe(e.fromPath),r=a?he(e.fromPath):void 0,c=e.fromPath;if(a){let f=k$1.join(t,T);if(!await V.pathExists(f))throw new Error("Git-aware workspace diff requires an existing snapshot at .workspai/reports/workspace-model-snapshot.json. Run: npx workspai workspace snapshot --json");c=T;}let n=ae(t,c),i=await we(n),p=e.model??await k({workspacePath:t,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,observableScanDepth:e.observableScanDepth,now:e.now}),m=d(p),l=[...We(i.model,p),...ve(i.model,p),...be(i.model,p)],u;e.includeGitObservation!==false&&(u=e.gitObservation??X(t,{ref:r}),u.available&&Re(l,u,p));let v=l.filter(f=>f.type.startsWith("git.")).length,R=i.hash!==m,y=a?`git:${r??"HEAD"}`:k$1.relative(t,n).split(k$1.sep).join("/");return {schemaVersion:L,generatedAt:(e.now??new Date).toISOString(),fromRef:y,toRef:h$1,fromHash:i.hash,toHash:m,summary:{changed:R||v>0,addedProjects:l.filter(f=>f.type==="project.added").length,removedProjects:l.filter(f=>f.type==="project.removed").length,changedProjects:l.filter(f=>f.type==="project.changed").length,workspaceChanges:l.filter(f=>f.type==="workspace.changed").length,validationChanges:l.filter(f=>f.type==="validation.changed").length,gitChangedFiles:v},git:u?.available?Ce(u,r):{available:false,dirty:false,changedFiles:0,untrackedFiles:0,deletedFiles:0},changes:l,currentModel:p}}async function Xe(e$1,t){return e(t,re,a$1(e$1))}function I(e){return {none:0,low:1,medium:2,high:3,critical:4}[e]}function Y(e){return e.reduce((t,a)=>I(a)>I(t)?a:t,"none")}var N=["none","low","medium","high","critical"];function Me(e){let t=Math.max(1,I(e)-1);return N[t]}function Ie(e){let t=Math.min(N.length-1,I(e)+1);return N[t]}function Q(e){return e.join(" ")}function h(e,t,a,r){return {id:e,label:t,scope:r.scope,project:r.project,display:Q(["npx","workspai",...a]),execute:Q(["npx","--yes","--package","workspai","workspai",...a]),required:r.required!==false}}function Z(e){let t=`project:${e.name}`,a=e.commands.fleetStages;return [h(`project.${e.name}.init`,`Run init for ${e.name}`,["workspace","run","init","--scope",t,"--json"],{scope:"project",project:e.name,required:a.includes("init")}),h(`project.${e.name}.test`,`Run tests for ${e.name}`,["workspace","run","test","--scope",t,"--json"],{scope:"project",project:e.name,required:a.includes("test")}),h(`project.${e.name}.build`,`Run build for ${e.name}`,["workspace","run","build","--scope",t,"--json"],{scope:"project",project:e.name,required:a.includes("build")}),h(`project.${e.name}.start`,`Run start for ${e.name}`,["workspace","run","start","--scope",t,"--json"],{scope:"project",project:e.name,required:a.includes("start")})]}function _(){return [h("workspace.doctor","Run workspace doctor",["doctor","workspace","--json"],{scope:"workspace"}),h("workspace.contract.verify","Verify workspace contract",["workspace","contract","verify","--json"],{scope:"workspace"}),h("workspace.readiness","Run release readiness",["readiness","--json"],{scope:"workspace"}),h("workspace.analyze","Run workspace analyze",["analyze","--json"],{scope:"workspace",required:false}),h("workspace.pipeline","Run governance pipeline",["pipeline","--json"],{scope:"workspace",required:false}),h("workspace.doctor-fix","Verify doctor fix result",["doctor","workspace","--fix","--json"],{scope:"workspace",required:false})]}function Pe(e,t){let a=t.split(k$1.sep).join("/");return e.projects.filter(c=>{let n=c.path.split(k$1.sep).join("/");return a===n||a.startsWith(`${n}/`)}).sort((c,n)=>n.path.length-c.path.length)[0]}function Re(e,t,a){let r=new Set(e.map(n=>n.target)),c=(n,i)=>{let p=i.split(k$1.sep).join("/"),m=`git:${p}`;if(r.has(m))return;let l=Pe(a,p),u=l?`${l.name} (${l.path})`:"workspace";w(e,{type:n,severity:n==="git.deleted"?"warning":"info",target:m,message:`Git ${n==="git.untracked"?"untracked":n==="git.deleted"?"deleted":"changed"} file affects ${u}: ${p}`,after:{path:p,project:l?.name,projectPath:l?.path}}),r.add(m);};for(let n of t.changedFiles)c("git.file.changed",n);for(let n of t.untrackedFiles)c("git.untracked",n);for(let n of t.deletedFiles)c("git.deleted",n);}function Ce(e,t){return {available:true,ref:t??e.ref,branch:e.branch,commit:e.commit,dirty:e.dirty,changedFiles:e.changedFiles.length,untrackedFiles:e.untrackedFiles.length,deletedFiles:e.deletedFiles.length}}function Ee(e){let t=new Set,a=[];for(let r of e){let c=`${r.scope}:${r.project??""}:${r.display}`;t.has(c)||(t.add(c),a.push(r));}return a}function Oe(e){return e.type==="project.removed"?"high":e.severity==="critical"?"critical":e.severity==="warning"?"high":("medium")}function Se(e,t){return e.severity==="critical"?"critical":e.target==="policies"||e.target.includes("contract")?"high":e.type==="validation.changed"?(t?.projectCount??0)===0?"low":"high":e.target==="evidence"?"low":e.severity==="warning"?"medium":"low"}function Ae(e){return e.affectedProjects>0||e.projectCount>0||!e.changes.every(a=>a.severity==="critical"?false:a.type.startsWith("git.")||a.type==="validation.changed")?e.risk:I(e.risk)>=I("high")||e.risk==="medium"?"low":e.risk}function ee(e,t){if(!e||e==="workspace")return true;let a=(e.startsWith("project:")?e.slice(8):e).trim().toLowerCase();return [t.name,t.path,k$1.basename(t.path),t.absolutePath].filter(r=>typeof r=="string"&&r.trim().length>0).map(r=>r.trim().toLowerCase()).includes(a)}function De(e){if(!e.changed)return {headline:"No workspace model impact detected.",bullets:["The current workspace model matches the provided snapshot/report."],unsafeAssumptions:["Do not claim runtime verification passed unless a report exists."]};let t=e.affectedProjects.map(a=>a.project?.name??a.target);return {headline:`Workspace impact risk: ${e.risk}.`,bullets:[`Affected projects: ${t.length?t.join(", "):"none"}.`,`Workspace-level items: ${e.workspaceImpact.length}.`,"Use the verification plan before recommending apply, rollback, or release actions."],unsafeAssumptions:["Do not infer test/build success from impact alone.","Do not apply fixes without project scope and verification evidence.","Use display commands for users and execute commands for automation."]}}async function Ye(e){let t=k$1.resolve(e.workspacePath),a=oe(e.fromPath),r=e.diff;if(!r&&!a){let o=ae(t,e.fromPath);r=await ye(o)??void 0;}r||(r=await je({workspacePath:t,fromPath:e.fromPath,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,includeGitObservation:e.includeGitObservation,gitObservation:e.gitObservation,now:e.now,model:e.model}));let c$1=new Map(r.currentModel.projects.map(o=>[o.path,o])),n=new Map(r.currentModel.projects.map(o=>[o.name,o])),i=r.changes.filter(o=>o.type.startsWith("project.")),p=new Map;for(let o of i){let d=(c$1.get(o.target)??(typeof o.before?.name=="string"?n.get(o.before.name):void 0))?.path??o.target,W=p.get(d)??[];W.push(o),p.set(d,W);}let m=[];for(let[o,s]of p.entries()){let d=c$1.get(o);if(d&&!ee(e.scope,d))continue;let W=Y(s.map(Oe)),C=d?.name??(typeof s[0]?.before?.name=="string"?String(s[0].before.name):o);m.push({id:`project:${C}`,scope:"project",target:o,title:`Project impact: ${C}`,summary:s.map(j=>j.message).join(" "),risk:W,reasons:s.map(j=>`${j.type}: ${j.message}`),project:d?{name:d.name,path:d.path,kind:d.kind,runtime:d.runtime,framework:d.framework,supportTier:d.supportTier,...d.generator?{generator:d.generator}:{}}:void 0,verification:d?Z(d):_()});}let l=r.currentModel.graph,u=l?a$2(l):void 0,v=new Set(m.map(o=>o.project?.name).filter(o=>typeof o=="string")),R=new Map;for(let o of m)if(o.project?.name){let s=u?.byId.get(o.project.name);s&&(o.centrality={fanIn:s.fanIn,fanOut:s.fanOut,reach:s.reach,betweenness:s.betweenness,isHotspot:s.isHotspot},s.isHotspot&&(o.risk=Ie(o.risk),o.reasons=[...o.reasons,`graph.hotspot: critical-path project with ${s.reach} transitive dependent(s); risk escalated.`])),o.origin="direct",o.distance=0,R.set(o.project.name,o.risk);}let y=[],f=0;if(l&&v.size>0){let o=c(l,v);for(let s of o.values()){if(s.distance===0||v.has(s.id))continue;let d=n.get(s.id);if(d&&!ee(e.scope,d))continue;let W=s.path[0],C=s.path[s.path.length-2]??W,j=R.get(W)??"medium",ce=Me(j),M=u?.byId.get(s.id);f=Math.max(f,s.distance),y.push({id:`transitive:${s.id}`,scope:"project",target:d?.path??s.id,title:`Transitive impact: ${s.id}`,summary:`Depends on changed project ${W}${s.via?` via ${s.via}`:""} (distance ${s.distance}).`,risk:ce,reasons:[`graph.dependent: depends on ${C}${s.via?` via ${s.via}`:""} (path ${s.path.join(" -> ")})`],project:d?{name:d.name,path:d.path,kind:d.kind,runtime:d.runtime,framework:d.framework,supportTier:d.supportTier,...d.generator?{generator:d.generator}:{}}:void 0,verification:d?Z(d):_(),origin:"transitive",distance:s.distance,path:s.path,via:s.via,...M?{centrality:{fanIn:M.fanIn,fanOut:M.fanOut,reach:M.reach,betweenness:M.betweenness,isHotspot:M.isHotspot}}:{}});}}y.sort((o,s)=>o.target.localeCompare(s.target));let ne=u?u.hotspots.flatMap(o=>{let s=u.byId.get(o);return s?[{project:o,fanIn:s.fanIn,fanOut:s.fanOut,reach:s.reach,betweenness:s.betweenness}]:[]}):[],se=r.changes.filter(o=>!o.type.startsWith("project.")),K=r.currentModel.summary?.projectCount??r.currentModel.projects.length,P=se.map(o=>({id:`workspace:${o.target}`,scope:"workspace",target:o.target,title:`Workspace impact: ${o.target}`,summary:o.message,risk:Se(o,{projectCount:K}),reasons:[`${o.type}: ${o.message}`],verification:_()})),B=Ee([...m.flatMap(o=>o.verification),...y.flatMap(o=>o.verification),...P.flatMap(o=>o.verification),...r.summary.changed?_():[]]).filter(o=>o.required),ie=Y([...m.map(o=>o.risk),...y.map(o=>o.risk),...P.map(o=>o.risk)]),q=Ae({risk:ie,affectedProjects:m.length,projectCount:K,changes:r.changes}),z={changed:r.summary.changed,risk:q,affectedProjects:m.length,workspaceItems:P.length,recommendedCommands:B.length,blastRadius:{directlyAffected:m.length,transitivelyAffected:y.length,maxDistance:f,graphEdges:l?.edges.length??0}};return {schemaVersion:ge,generatedAt:(e.now??new Date).toISOString(),fromRef:r.fromRef,diffRef:re,workspace:{name:r.currentModel.workspace.name,profile:r.currentModel.workspace.profile,type:r.currentModel.workspace.type},summary:z,affectedProjects:m.sort((o,s)=>o.target.localeCompare(s.target)),transitiveImpact:y,criticalPathHotspots:ne,workspaceImpact:P.sort((o,s)=>o.target.localeCompare(s.target)),verificationPlan:B,agentBrief:De({changed:z.changed,risk:q,affectedProjects:m,workspaceImpact:P}),diff:r}}async function Qe(e$1,t){return e(t,ke,a$1(e$1))}export{X as a,te as b,L as c,T as d,re as e,ge as f,ke as g,oe as h,he as i,Je as j,Ue as k,je as l,Xe as m,_ as n,Ye as o,Qe as p};