workspai 0.66.0 → 0.67.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 (130) hide show
  1. package/README.md +24 -22
  2. package/contracts/cli-runtime-command-inventory.v1.snapshot.json +4 -0
  3. package/contracts/extension-cli-compatibility.v1.json +4 -0
  4. package/contracts/published-contract-catalog.v1.json +20 -0
  5. package/contracts/runtime-command-surface.v1.json +55 -2
  6. package/contracts/workspace-activity-board.v1.json +114 -0
  7. package/contracts/workspace-activity-monitor-fleet.v1.json +18 -0
  8. package/contracts/workspace-activity-monitor-snapshot.v1.json +161 -0
  9. package/contracts/workspace-intelligence/workspace-intelligence-benchmark.v1.json +196 -0
  10. package/contracts/workspace-intelligence-architecture.v1.json +17 -0
  11. package/contracts/workspace-intelligence-chain.v1.json +17 -0
  12. package/dist/analyze-IC2KRVCG.js +1 -0
  13. package/dist/{artifact-remediation-plan-M2XBS2IU.js → artifact-remediation-plan-GFFHC2ZU.js} +1 -1
  14. package/dist/autopilot-release-RECEZAZI.js +1 -0
  15. package/dist/capabilities-command-X4WZIJNR.js +1 -0
  16. package/dist/{chunk-TTHO4MFC.js → chunk-2M62CU3O.js} +1 -1
  17. package/dist/{chunk-JZJBA2V2.js → chunk-2MTJWPQ4.js} +1 -1
  18. package/dist/chunk-2MVIRJJR.js +1 -0
  19. package/dist/chunk-2RPFCBS4.js +1 -0
  20. package/dist/{chunk-O37UBRMX.js → chunk-3O7LZPKA.js} +1 -1
  21. package/dist/chunk-3OGPTLI2.js +1 -0
  22. package/dist/{chunk-3H5ACWWZ.js → chunk-4RV4JVGR.js} +1 -1
  23. package/dist/{chunk-XQFWUM2P.js → chunk-4WVOAX2V.js} +1 -1
  24. package/dist/{chunk-L5CCIIF2.js → chunk-5EVDW7JM.js} +1 -1
  25. package/dist/{chunk-727IQFGN.js → chunk-5ME4W4LN.js} +1 -1
  26. package/dist/{chunk-DUBOKZMA.js → chunk-6254CWUY.js} +12 -12
  27. package/dist/{chunk-AP4PV6WJ.js → chunk-6E2Y3XGT.js} +1 -1
  28. package/dist/{chunk-ZQH2I5RQ.js → chunk-ARUFY5W3.js} +1 -1
  29. package/dist/{chunk-IIFFEEMX.js → chunk-BHFRP7TV.js} +1 -1
  30. package/dist/{chunk-6JX56VAL.js → chunk-BHM6RHTA.js} +1 -1
  31. package/dist/{chunk-VA5VSOBL.js → chunk-BRYJTW6S.js} +1 -1
  32. package/dist/{chunk-3NM3JAZW.js → chunk-BUYLM6QV.js} +1 -1
  33. package/dist/chunk-CPR2CMOY.js +1 -0
  34. package/dist/{chunk-2PACEMNE.js → chunk-CZVT7T2X.js} +1 -1
  35. package/dist/{chunk-7FF5EOIO.js → chunk-EHCKITR4.js} +1 -1
  36. package/dist/{chunk-UPIPSSXY.js → chunk-ENZPM52J.js} +1 -1
  37. package/dist/{chunk-334J2KIP.js → chunk-FPDH3N3A.js} +1 -1
  38. package/dist/{chunk-D4UHRJAP.js → chunk-FX5J6JCK.js} +1 -1
  39. package/dist/{chunk-HJLGXFMK.js → chunk-GIQ4SDRJ.js} +1 -1
  40. package/dist/{chunk-WTWRSEOW.js → chunk-H77ZNH5O.js} +1 -1
  41. package/dist/{chunk-EHH4SKVH.js → chunk-HQLBO23O.js} +3 -3
  42. package/dist/{chunk-AXUA7PFV.js → chunk-HYE5UHPV.js} +1 -1
  43. package/dist/{chunk-XESFJN52.js → chunk-IKUFNK46.js} +1 -1
  44. package/dist/{chunk-YX5VWPR5.js → chunk-IQQMFRWM.js} +1 -1
  45. package/dist/{chunk-PD7Y6HIM.js → chunk-JCGSIDMC.js} +1 -1
  46. package/dist/{chunk-4XEH3WNV.js → chunk-KENOAC2Q.js} +1 -1
  47. package/dist/{chunk-QGAPGZPL.js → chunk-KQ2TMI26.js} +1 -1
  48. package/dist/{chunk-OI2VOU6S.js → chunk-N4QFNOAI.js} +1 -1
  49. package/dist/{chunk-5XGR3LRI.js → chunk-OCNPOYMA.js} +1 -1
  50. package/dist/{chunk-VQOWB26M.js → chunk-PSYQ6IJA.js} +1 -1
  51. package/dist/{chunk-HLWDIIWL.js → chunk-QMQBX3RV.js} +1 -1
  52. package/dist/{chunk-H5RJCS5E.js → chunk-SLFOUSRW.js} +1 -1
  53. package/dist/chunk-SRLWHOLF.js +1 -0
  54. package/dist/chunk-SVYY55IS.js +157 -0
  55. package/dist/{chunk-JRP6WP5C.js → chunk-THIG2YQP.js} +1 -1
  56. package/dist/{chunk-PJPS7CNH.js → chunk-TP7VKEUF.js} +1 -1
  57. package/dist/{chunk-IVF6NEHS.js → chunk-VI4ZRAY6.js} +1 -1
  58. package/dist/{chunk-EP4CUWOO.js → chunk-VWBMDGPY.js} +1 -1
  59. package/dist/{chunk-GAYK3WGV.js → chunk-XDPTAV2T.js} +1 -1
  60. package/dist/{chunk-R2M5OJOK.js → chunk-Y35VLVF6.js} +1 -1
  61. package/dist/{chunk-ECLMYTWT.js → chunk-Y4Z6CEII.js} +1 -1
  62. package/dist/{chunk-UOCERSAN.js → chunk-YYY2WXOH.js} +1 -1
  63. package/dist/{chunk-6UNATTB7.js → chunk-ZGHJIQXL.js} +1 -1
  64. package/dist/chunk-ZI2E7P6O.js +4 -0
  65. package/dist/{create-SOLLXXAB.js → create-72ITVZXV.js} +1 -1
  66. package/dist/{doctor-NQ5PUCUP.js → doctor-CVYUESRQ.js} +1 -1
  67. package/dist/{goal-lifecycle-IPNY7KNR.js → goal-lifecycle-H55AGFCB.js} +1 -1
  68. package/dist/{goal-pack-2WV3EA4Y.js → goal-pack-6OBZOPCD.js} +1 -1
  69. package/dist/index.d.ts +14 -2
  70. package/dist/index.js +129 -129
  71. package/dist/live-command-5VXPR43F.js +15 -0
  72. package/dist/{pipeline-MIMENSI7.js → pipeline-SKYOXWHW.js} +1 -1
  73. package/dist/{project-agent-entry-OWLJ3IHQ.js → project-agent-entry-5IUBEREI.js} +1 -1
  74. package/dist/{project-intelligence-lens-I67EO6AE.js → project-intelligence-lens-LQCN65P2.js} +1 -1
  75. package/dist/{project-test-coverage-OPDVSFPH.js → project-test-coverage-KD4LLFGV.js} +1 -1
  76. package/dist/{verified-goal-46JWNCDY.js → verified-goal-HN7G532B.js} +1 -1
  77. package/dist/{workspace-KO37XHF6.js → workspace-5W7FYGDQ.js} +1 -1
  78. package/dist/{workspace-agent-sync-32FIJQBH.js → workspace-agent-sync-OZCDQORK.js} +1 -1
  79. package/dist/{workspace-archive-6R5DRNZW.js → workspace-archive-NOSGRKRZ.js} +1 -1
  80. package/dist/{workspace-context-JKRPX775.js → workspace-context-L65BR5L6.js} +1 -1
  81. package/dist/{workspace-contract-4T3NYNK5.js → workspace-contract-JYHNEJPV.js} +1 -1
  82. package/dist/workspace-explain-SUBK6FLO.js +1 -0
  83. package/dist/workspace-explain-contract-WMREJWHF.js +1 -0
  84. package/dist/{workspace-feedback-6VQ7T4CR.js → workspace-feedback-MWGCT5R2.js} +1 -1
  85. package/dist/{workspace-foundation-GHWO3BZU.js → workspace-foundation-VIB3PXNH.js} +1 -1
  86. package/dist/{workspace-graph-stream-PTVS47NJ.js → workspace-graph-stream-45JHE4MG.js} +1 -1
  87. package/dist/workspace-graph-token-efficiency-NPECU6Y5.js +1 -0
  88. package/dist/{workspace-history-M2K4M2JY.js → workspace-history-JKW3VJO3.js} +1 -1
  89. package/dist/{workspace-intelligence-PJIPTXL3.js → workspace-intelligence-3C47PK4L.js} +1 -1
  90. package/dist/workspace-intelligence-benchmark-SRDIHX3X.js +1 -0
  91. package/dist/workspace-intelligence-evaluation-OJIQS5SN.js +1 -0
  92. package/dist/{workspace-intelligence-runner-M47QR3JM.js → workspace-intelligence-runner-OWN5ZI6W.js} +1 -1
  93. package/dist/{workspace-intelligence-runtime-registry-FFGQF4A7.js → workspace-intelligence-runtime-registry-UKFB3BI7.js} +1 -1
  94. package/dist/{workspace-knowledge-graph-V2EAYDCL.js → workspace-knowledge-graph-AKG5NUU6.js} +1 -1
  95. package/dist/{workspace-knowledge-graph-contract-VANN7RCA.js → workspace-knowledge-graph-contract-X52KXBXJ.js} +1 -1
  96. package/dist/{workspace-knowledge-graph-query-RASPF7FS.js → workspace-knowledge-graph-query-DXA4CROE.js} +1 -1
  97. package/dist/workspace-knowledge-graph-snapshot-SNI5K2RL.js +1 -0
  98. package/dist/{workspace-mcp-serve-YRORNE4P.js → workspace-mcp-serve-PK226GMV.js} +1 -1
  99. package/dist/{workspace-model-VSVKLX7M.js → workspace-model-R4ISKDB2.js} +1 -1
  100. package/dist/{workspace-onboarding-2VMJZVLZ.js → workspace-onboarding-Y5RPEFUD.js} +1 -1
  101. package/dist/{workspace-readme-6X3GLTBM.js → workspace-readme-PL5V3UDH.js} +1 -1
  102. package/dist/{workspace-registry-summary-QVSJKKTX.js → workspace-registry-summary-STGUGROG.js} +1 -1
  103. package/dist/{workspace-repair-engine-WSKV3Q4V.js → workspace-repair-engine-FNLL5ZDK.js} +1 -1
  104. package/dist/workspace-run-GFBFGUFM.js +1 -0
  105. package/dist/{workspace-verify-EJCSOBIK.js → workspace-verify-AXVX3PF3.js} +1 -1
  106. package/dist/{workspace-watch-JTIFBF4Z.js → workspace-watch-RLBEJKXE.js} +1 -1
  107. package/docs/DEVELOPMENT.md +19 -0
  108. package/docs/README.md +19 -16
  109. package/docs/ci-workflows.md +1 -1
  110. package/docs/commands-reference.md +17 -1
  111. package/docs/contracts/ARTIFACT_CATALOG.md +1 -0
  112. package/docs/contracts/README.md +3 -0
  113. package/docs/workspace-intelligence-benchmark.md +82 -0
  114. package/docs/workspace-live-activity.md +11 -1
  115. package/package.json +4 -2
  116. package/dist/analyze-UJQWGNM2.js +0 -1
  117. package/dist/autopilot-release-U6F4M2BQ.js +0 -1
  118. package/dist/capabilities-command-XUKPO25Z.js +0 -1
  119. package/dist/chunk-5U4L6VF2.js +0 -1
  120. package/dist/chunk-C4S22E6S.js +0 -1
  121. package/dist/chunk-H7MRINGP.js +0 -1
  122. package/dist/chunk-JC4XSU7G.js +0 -1
  123. package/dist/chunk-MZ7U4BIQ.js +0 -157
  124. package/dist/live-command-Q6E45N7S.js +0 -18
  125. package/dist/workspace-explain-MOGL4GEA.js +0 -1
  126. package/dist/workspace-explain-contract-W2E6LF4Q.js +0 -1
  127. package/dist/workspace-graph-token-efficiency-Z5JD5NHI.js +0 -1
  128. package/dist/workspace-intelligence-evaluation-GONCRE6O.js +0 -1
  129. package/dist/workspace-knowledge-graph-snapshot-5YIG6EMG.js +0 -1
  130. package/dist/workspace-run-3BXKTLVL.js +0 -1
@@ -1,4 +1,4 @@
1
- import {a as a$4}from'./chunk-ZEEV5J4I.js';import {f as f$1,e as e$1}from'./chunk-SX6A656X.js';import {a as a$1,b}from'./chunk-HLWDIIWL.js';import {b as b$1,c}from'./chunk-JZJBA2V2.js';import {a as a$2}from'./chunk-NMXGSVMD.js';import {p,a as a$3}from'./chunk-7FF5EOIO.js';import {k as k$1,m,l}from'./chunk-U5ENEDJA.js';import {e as e$2}from'./chunk-GAYK3WGV.js';import {e,f}from'./chunk-6UNATTB7.js';import {k,t,u}from'./chunk-VQZ5PI5J.js';import j from'fs';import i from'path';import a from'chalk';var Z=new Set([".git",".workspai",".rapidkit",".venv","node_modules","dist","build","target","coverage","htmlcov",".next"]);async function I(e){try{return await j.promises.access(e,j.constants.F_OK),true}catch{return false}}async function S(e){try{let n=JSON.parse(await j.promises.readFile(e,"utf-8"));return n&&typeof n=="object"&&!Array.isArray(n)?n:null}catch{return null}}async function v(e){try{return await j.promises.readFile(e,"utf-8")}catch{return ""}}function ee(e){return a$1(e)}async function ne(e,n){return await X([...u(e,"project.json"),...u(e,"context.json")])?true:b(e)?false:i.resolve(e)===i.resolve(n)?k$1(e).length>0:k$1(e).length>0}async function te(e){let n=await a$2(e,{skipDirs:Z,includeHiddenDirs:false,descendIntoMatchedProjects:false,isProjectDir:ne}),r=(await a$3(e)).filter(s=>s.relationship==="adopted"||s.source==="adopted-local").map(s=>i.resolve(s.path)).filter(s=>j.existsSync(s)),o=[...new Set([...n.map(s=>i.resolve(s)),...r])];return o.length>0?o:b(e)?[]:k$1(e).length>0?[e]:[]}function re(e,n){return i.relative(e,n).replace(/\\/g,"/")||"."}async function E(e,n){for(let t of n)if(await I(i.join(e,t)))return true;return false}async function X(e){for(let n of e)if(await I(n))return true;return false}async function Y(e){for(let n of e){let t=await S(n);if(t)return t}return null}async function oe(e){if(await E(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","app/controllers/health_controller.rb","app/controllers/health_check_controller.rb","config/initializers/health_check.rb"]))return true;let t=await v(i.join(e,"config","routes.rb"));return /(?:health|readiness|liveness|readiness_check|health_check)/iu.test(t)}async function se(e,n){if(await E(e,[".env",".env.local"]))return true;let t=n?.contracts&&typeof n.contracts=="object"?n.contracts:null;if(Array.isArray(t?.env)&&t.env.length>0)return true;let r=await S(i.join(e,"package.json")),o={...r?.dependencies??{},...r?.devDependencies??{}};if(Object.keys(o).some(c=>/^(?:dotenv|dotenv-flow|env-cmd)$/iu.test(c)))return true;let s=await v(i.join(e,"pyproject.toml"));if(/\b(?:python-dotenv|pydantic-settings)\b/iu.test(s))return true;let p=[await v(i.join(e,"compose.yaml")),await v(i.join(e,"compose.yml")),await v(i.join(e,"docker-compose.yml")),await v(i.join(e,"docker-compose.yaml"))].join(`
1
+ import {a as a$4}from'./chunk-ZEEV5J4I.js';import {f as f$1,e as e$1}from'./chunk-SX6A656X.js';import {a as a$1,b}from'./chunk-QMQBX3RV.js';import {b as b$1,c}from'./chunk-2MTJWPQ4.js';import {a as a$2}from'./chunk-NMXGSVMD.js';import {p,a as a$3}from'./chunk-EHCKITR4.js';import {k as k$1,m,l}from'./chunk-U5ENEDJA.js';import {e as e$2}from'./chunk-XDPTAV2T.js';import {e,f}from'./chunk-ZGHJIQXL.js';import {k,t,u}from'./chunk-VQZ5PI5J.js';import j from'fs';import i from'path';import a from'chalk';var Z=new Set([".git",".workspai",".rapidkit",".venv","node_modules","dist","build","target","coverage","htmlcov",".next"]);async function I(e){try{return await j.promises.access(e,j.constants.F_OK),true}catch{return false}}async function S(e){try{let n=JSON.parse(await j.promises.readFile(e,"utf-8"));return n&&typeof n=="object"&&!Array.isArray(n)?n:null}catch{return null}}async function v(e){try{return await j.promises.readFile(e,"utf-8")}catch{return ""}}function ee(e){return a$1(e)}async function ne(e,n){return await X([...u(e,"project.json"),...u(e,"context.json")])?true:b(e)?false:i.resolve(e)===i.resolve(n)?k$1(e).length>0:k$1(e).length>0}async function te(e){let n=await a$2(e,{skipDirs:Z,includeHiddenDirs:false,descendIntoMatchedProjects:false,isProjectDir:ne}),r=(await a$3(e)).filter(s=>s.relationship==="adopted"||s.source==="adopted-local").map(s=>i.resolve(s.path)).filter(s=>j.existsSync(s)),o=[...new Set([...n.map(s=>i.resolve(s)),...r])];return o.length>0?o:b(e)?[]:k$1(e).length>0?[e]:[]}function re(e,n){return i.relative(e,n).replace(/\\/g,"/")||"."}async function E(e,n){for(let t of n)if(await I(i.join(e,t)))return true;return false}async function X(e){for(let n of e)if(await I(n))return true;return false}async function Y(e){for(let n of e){let t=await S(n);if(t)return t}return null}async function oe(e){if(await E(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","app/controllers/health_controller.rb","app/controllers/health_check_controller.rb","config/initializers/health_check.rb"]))return true;let t=await v(i.join(e,"config","routes.rb"));return /(?:health|readiness|liveness|readiness_check|health_check)/iu.test(t)}async function se(e,n){if(await E(e,[".env",".env.local"]))return true;let t=n?.contracts&&typeof n.contracts=="object"?n.contracts:null;if(Array.isArray(t?.env)&&t.env.length>0)return true;let r=await S(i.join(e,"package.json")),o={...r?.dependencies??{},...r?.devDependencies??{}};if(Object.keys(o).some(c=>/^(?:dotenv|dotenv-flow|env-cmd)$/iu.test(c)))return true;let s=await v(i.join(e,"pyproject.toml"));if(/\b(?:python-dotenv|pydantic-settings)\b/iu.test(s))return true;let p=[await v(i.join(e,"compose.yaml")),await v(i.join(e,"compose.yml")),await v(i.join(e,"docker-compose.yml")),await v(i.join(e,"docker-compose.yaml"))].join(`
2
2
  `);return /^\s*(?:env_file|environment)\s*:/imu.test(p)}async function ae(e){return (await a$4(e)).detected}async function ie(e){let n=await S(i.join(e,"package.json")),t=n?.scripts&&typeof n.scripts=="object"?n.scripts:{};return Object.keys(t).sort()}function y(e,n,t,r,o,s,p){return {id:e,severity:n,target:t,title:r,detail:o,remediation:s,...p&&p.length>0?{files:[...p]}:{}}}function ce(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 de(e,n,t){let r=await Y(u(n,"project.json")),o=m(n,r),s=l(n),p=o.runtime==="unknown"?s[0]||"unknown":o.runtime,c$1=[p,...s.filter(G=>G!==p)],g=await b$1(n,r,{runtime:p,framework:o.key}),w=["backend","service","worker"].includes(g),h=w&&/^(?:fastapi|django|flask|nestjs|express|fastify|springboot|gofiber|gogin|dotnet-webapi|laravel|rails|phoenix|axum|actix|rocket)$/u.test(o.key),k=re(e,n),u$1=k,b=await ie(n),C=await X([...u(n,"project.json"),...u(n,"context.json")]),P=await ae(n),x=await E(n,["Dockerfile","dockerfile"]),R=await E(n,[".env.example","env.example","config/env.example"]),F=await se(n,r),m$1=await c({projectPath:n,declaration:t?.governance}),d=m$1.ci.status==="repository",l$1=await oe(n),f=[];return o.key==="unknown"&&f.push(y("project.stack.unknown","fail",u$1,"Project stack is unknown","Workspai cannot confidently classify this backend project.","Add .workspai/project.json metadata or import the project with `workspai import`.")),C||f.push(y("project.marker.missing","warn",u$1,"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.")),P||f.push(y("project.tests.missing","warn",u$1,"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.")),w&&F&&!R&&f.push(y("project.env.example.missing","info",u$1,"Environment example is missing","No .env.example or env.example file was found.","Add an env example for onboarding and CI secret documentation.",[".env.example"])),m$1.ci.status==="unknown"?f.push(y("project.ci.missing","warn",u$1,"CI governance is not proven","No repository CI surface or canonical external CI declaration was found for this project.","Add repository CI configuration or declare the external CI authority in the workspace contract.",[".github/workflows/ci.yml"])):m$1.ci.status==="external-observed"&&f.push(y("project.ci.external-observed","info",u$1,"Continuous integration appears externally managed",`Repository documentation references an external CI control plane (${m$1.ci.evidence.join(", ")}).`,"Declare the external CI provider in the canonical workspace contract when authoritative release gating depends on it.")),h&&!l$1&&f.push(y("project.health.missing","info",u$1,"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.")),w&&!x&&f.push(y("project.container.missing","info",u$1,"Container recipe is missing","No Dockerfile was found for this project.","Add a Dockerfile when the service is intended for containerized deployment.",["Dockerfile"])),{name:typeof r?.name=="string"&&r.name.trim()?r.name.trim():i.basename(n),path:n,relativePath:k,runtime:p,runtimeCandidates:c$1,framework:o.key,confidence:o.confidence,supportTier:o.supportTier,hasRapidKitMarker:C,hasTests:P,hasDockerfile:x,hasEnvExample:R,hasCiConfig:d,governance:m$1,hasHealthEndpoint:l$1,scripts:b,findings:f,score:ce(f)}}function le(e){return e.name.toLowerCase()}async function pe(e){let n=new Map(e.map(o=>[le(o),o])),t=[];for(let o of e){let s=await S(i.join(o.path,"package.json")),p={...s?.dependencies??{},...s?.devDependencies??{},...s?.peerDependencies??{}};for(let g of Object.keys(p)){let w=g.replace(/^@[^/]+\//,"").toLowerCase(),h=n.get(w);h&&h.relativePath!==o.relativePath&&t.push({from:o.relativePath,to:h.relativePath,kind:"package"});}let c=await v(i.join(o.path,"pyproject.toml"));for(let g of e)g.relativePath!==o.relativePath&&c.includes(g.name)&&t.push({from:o.relativePath,to:g.relativePath,kind:"workspace-reference"});}let r=new Set;return t.filter(o=>{let s=`${o.from}\0${o.to}\0${o.kind}`;return r.has(s)?false:(r.add(s),true)})}function ue(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 o=t.get(r.from),s=t.get(r.to);o&&(o.directDependencies+=1),s&&(s.directDependents+=1);}return Array.from(t.values()).sort((r,o)=>o.directDependents-r.directDependents||o.directDependencies-r.directDependencies)}async function me(e){let n=await Y(t(e,"workspace.json"));return typeof n?.profile=="string"?n.profile:null}function fe(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 ge(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.hasCanonicalGraph||n.push("Generate canonical topology with `workspai workspace model --write --include-evidence`."),n.push("Run `workspai autopilot release --mode audit --json` before release."),Array.from(new Set(n))}async function Fe(e$3={}){let n=i.resolve(e$3.workspacePath||process.cwd());if(!await I(n))throw new Error(`Workspace path does not exist: ${n}`);let t=ee(n)??n,r=k(t),o=await me(t),s=await te(t),p$1;try{p$1=(await p({workspacePath:t})).contract;}catch{}let c=await Promise.all(s.map(d=>{let l=p$1?.projects.find(f=>{let G=f.externalPath??f.relativePath;return i.resolve(t,G)===i.resolve(d)});return de(t,d,l)})),g=await pe(c),w=ue(c,g),h=[];r||h.push(y("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.")),c.length===0&&h.push(y("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 k$1=[...h,...c.flatMap(d=>d.findings)],u=fe(k$1),b={};for(let d of c)for(let l of d.runtimeCandidates)b[l]=(b[l]||0)+1;let C=c.length>0?Math.round(c.reduce((d,l)=>d+l.score,0)/c.length):0,P=h.reduce((d,l)=>d+(l.severity==="fail"?20:l.severity==="warn"?8:2),0),x=Math.max(0,C-P),R=c.length===0&&u.fail===0&&k$1.length>0&&k$1.every(d=>d.id==="workspace.projects.missing"&&d.severity==="warn"),F=u.fail>0||e$3.strict&&u.warn>0&&!R?"blocked":u.warn>0?"needs-attention":"ready",m={schemaVersion:f.analyze,generatedAt:new Date().toISOString(),workspacePath:t,workspaceDetected:r,profile:o,summary:{statusScope:"source-structure",releaseReadiness:"not-evaluated",score:x,verdict:F,projectCount:c.length,runtimeCount:Object.keys(b).length,findings:u},runtimes:b,projects:c,dependencyGraph:{status:g.length>0?"generated":"empty",edges:g,topImpactedProjects:w.slice(0,5)},findings:k$1,nextActions:ge({findings:k$1,projectCount:c.length,hasCanonicalGraph:await I(i.join(t,e.knowledgeGraph)),workspaceDetected:r}),enterpriseControls:{jsonReady:true,ciGateCommand:"workspai analyze --json --strict",releaseGateCommand:"workspai autopilot release --mode enforce --json",evidencePath:e.analyze}};if(e$3.output&&(await j.promises.mkdir(i.dirname(i.resolve(e$3.output)),{recursive:true}),await j.promises.writeFile(i.resolve(e$3.output),`${JSON.stringify(m,null,2)}
3
3
  `)),!e$3.output&&r){let d=f$1(m,{commandId:"workspaceAnalyze",exitCode:m.summary.verdict==="blocked"?2:m.summary.verdict==="needs-attention"?1:0,generatedAt:m.generatedAt,blockers:m.findings.filter(l=>l.severity==="fail").map(l=>l.title).slice(0,12),runId:e$1()});await e$2(t,e.analyze,d);}return m}function Ge(e){let n=e.summary.verdict==="ready"?a.green:e.summary.verdict==="needs-attention"?a.yellow:a.red;if(console.log(a.bold(`
4
4
  Workspai Workspace Analysis
@@ -1,2 +1,2 @@
1
- import {b}from'./chunk-XESFJN52.js';import {d}from'./chunk-5TY74LLW.js';import {w as w$1,x}from'./chunk-VQZ5PI5J.js';import l from'path';import {randomUUID}from'crypto';import {open,link,copyFile}from'fs/promises';import s from'fs-extra';function I(t,r){let a=l.resolve(t),e=r.trim();if(!e||l.isAbsolute(e))throw new Error(`Workspace artifact path must be non-empty and relative: ${r}`);let i=l.resolve(a,e),n=l.relative(a,i);if(n===".."||n.startsWith(`..${l.sep}`)||l.isAbsolute(n))throw new Error(`Workspace artifact path escapes workspace root: ${r}`);return i}function w(t,r){return I(t,w$1(r))}function F(t,r){return I(t,x(r))}async function M(t,r){let a=l.resolve(t);await s.ensureDir(a);let e=l.dirname(r);await s.ensureDir(e);let[i,n]=await Promise.all([s.realpath(a),s.realpath(e)]),f=l.relative(i,n);if(f===".."||f.startsWith(`..${l.sep}`)||l.isAbsolute(f))throw new Error(`Workspace artifact parent resolves outside workspace root: ${e}`)}async function $(t,r){let a=l.resolve(t),[e,i]=await Promise.all([s.realpath(a),s.realpath(r)]),n=l.relative(e,i);if(n===".."||n.startsWith(`..${l.sep}`)||l.isAbsolute(n))throw new Error(`Workspace artifact resolves outside workspace root: ${r}`)}function L(t){let r=t?.code;return process.platform==="win32"&&(r==="EPERM"||r==="EINVAL"||r==="ENOSYS")}function R(t,r=process.platform){if(r!=="win32")return false;let a=t?.code;return a==="EPERM"||a==="EACCES"||a==="EBUSY"}async function h(t){let r=process.platform==="win32"?6:1,a;for(let e=0;e<r;e+=1)try{await s.remove(t);return}catch(i){if(a=i,!R(i)||e===r-1)throw i;await new Promise(n=>setTimeout(n,10*2**e));}throw a}var g=new Map;async function C(t,r){let a=g.get(t)??Promise.resolve(),e,i=new Promise(f=>{e=f;}),n=a.catch(()=>{}).then(()=>i);g.set(t,n),await a.catch(()=>{});try{return await r()}finally{e(),g.get(t)===n&&g.delete(t);}}async function N(t){try{await t.sync();}catch(r){if(!L(r))throw r}}async function y(t,r,a){await M(t,r);let e=l.dirname(r),i=`${l.basename(r)}.`,n=Date.now();for(let o of await s.readdir(e)){if(!o.startsWith(i)||!o.endsWith(".tmp"))continue;let p=l.join(e,o),u=await s.stat(p).catch(()=>null);u&&n-u.mtimeMs>3e4&&await s.remove(p).catch(()=>{});}let f=`${r}.${process.pid}.${randomUUID()}.tmp`;try{await a(f);let o=await open(f,"r");try{await N(o);}finally{await o.close();}let p=Number(process.env.WORKSPAI_TEST_ATOMIC_WRITE_DELAY_MS??0);Number.isFinite(p)&&p>0&&await new Promise(u=>setTimeout(u,Math.min(p,3e4)));try{await s.rename(f,r);}catch(u){let c=u.code;if(c!=="EEXIST"&&c!=="EPERM")throw u;await s.move(f,r,{overwrite:true});}}finally{await s.remove(f).catch(()=>{});}}async function O(t,r,a,e={}){let i=w(t,r);await M(t,i);let n=`${i}.lock`;return C(n,()=>j(n,r,a,e))}async function j(t,r,a,e){let i=e.timeoutMs??1e4,n=e.staleAfterMs??3e4,f=Date.now(),o;for(;!o;)try{o=await open(t,"wx"),await o.writeFile(`${JSON.stringify({pid:process.pid,createdAt:new Date().toISOString()})}
1
+ import {b}from'./chunk-IKUFNK46.js';import {d}from'./chunk-5TY74LLW.js';import {w as w$1,x}from'./chunk-VQZ5PI5J.js';import l from'path';import {randomUUID}from'crypto';import {open,link,copyFile}from'fs/promises';import s from'fs-extra';function I(t,r){let a=l.resolve(t),e=r.trim();if(!e||l.isAbsolute(e))throw new Error(`Workspace artifact path must be non-empty and relative: ${r}`);let i=l.resolve(a,e),n=l.relative(a,i);if(n===".."||n.startsWith(`..${l.sep}`)||l.isAbsolute(n))throw new Error(`Workspace artifact path escapes workspace root: ${r}`);return i}function w(t,r){return I(t,w$1(r))}function F(t,r){return I(t,x(r))}async function M(t,r){let a=l.resolve(t);await s.ensureDir(a);let e=l.dirname(r);await s.ensureDir(e);let[i,n]=await Promise.all([s.realpath(a),s.realpath(e)]),f=l.relative(i,n);if(f===".."||f.startsWith(`..${l.sep}`)||l.isAbsolute(f))throw new Error(`Workspace artifact parent resolves outside workspace root: ${e}`)}async function $(t,r){let a=l.resolve(t),[e,i]=await Promise.all([s.realpath(a),s.realpath(r)]),n=l.relative(e,i);if(n===".."||n.startsWith(`..${l.sep}`)||l.isAbsolute(n))throw new Error(`Workspace artifact resolves outside workspace root: ${r}`)}function L(t){let r=t?.code;return process.platform==="win32"&&(r==="EPERM"||r==="EINVAL"||r==="ENOSYS")}function R(t,r=process.platform){if(r!=="win32")return false;let a=t?.code;return a==="EPERM"||a==="EACCES"||a==="EBUSY"}async function h(t){let r=process.platform==="win32"?6:1,a;for(let e=0;e<r;e+=1)try{await s.remove(t);return}catch(i){if(a=i,!R(i)||e===r-1)throw i;await new Promise(n=>setTimeout(n,10*2**e));}throw a}var g=new Map;async function C(t,r){let a=g.get(t)??Promise.resolve(),e,i=new Promise(f=>{e=f;}),n=a.catch(()=>{}).then(()=>i);g.set(t,n),await a.catch(()=>{});try{return await r()}finally{e(),g.get(t)===n&&g.delete(t);}}async function N(t){try{await t.sync();}catch(r){if(!L(r))throw r}}async function y(t,r,a){await M(t,r);let e=l.dirname(r),i=`${l.basename(r)}.`,n=Date.now();for(let o of await s.readdir(e)){if(!o.startsWith(i)||!o.endsWith(".tmp"))continue;let p=l.join(e,o),u=await s.stat(p).catch(()=>null);u&&n-u.mtimeMs>3e4&&await s.remove(p).catch(()=>{});}let f=`${r}.${process.pid}.${randomUUID()}.tmp`;try{await a(f);let o=await open(f,"r");try{await N(o);}finally{await o.close();}let p=Number(process.env.WORKSPAI_TEST_ATOMIC_WRITE_DELAY_MS??0);Number.isFinite(p)&&p>0&&await new Promise(u=>setTimeout(u,Math.min(p,3e4)));try{await s.rename(f,r);}catch(u){let c=u.code;if(c!=="EEXIST"&&c!=="EPERM")throw u;await s.move(f,r,{overwrite:true});}}finally{await s.remove(f).catch(()=>{});}}async function O(t,r,a,e={}){let i=w(t,r);await M(t,i);let n=`${i}.lock`;return C(n,()=>j(n,r,a,e))}async function j(t,r,a,e){let i=e.timeoutMs??1e4,n=e.staleAfterMs??3e4,f=Date.now(),o;for(;!o;)try{o=await open(t,"wx"),await o.writeFile(`${JSON.stringify({pid:process.pid,createdAt:new Date().toISOString()})}
2
2
  `),await N(o);}catch(p){if(!(p.code==="EEXIST"||R(p)))throw o&&(await o.close().catch(()=>{}),o=void 0,await h(t).catch(()=>{})),p;o&&(await o.close().catch(()=>{}),o=void 0,await h(t).catch(()=>{}));let[d,_]=await Promise.all([s.stat(t).catch(()=>null),s.readJson(t).catch(()=>null)]),P=Number(_?.pid),A=Number.isInteger(P)&&P>0,E=false;if(A)try{process.kill(P,0),E=true;}catch(v){E=v.code==="EPERM";}let J=!A&&!!(d&&Date.now()-d.mtimeMs>n);if(A&&!E||J){await h(t).catch(()=>{});continue}if(Date.now()-f>=i)throw new Error(`Timed out waiting for workspace artifact lock: ${r}`);await new Promise(v=>setTimeout(v,20));}try{return await a()}finally{await o.close().catch(()=>{}),await h(t);}}async function Q(t,r){let a=[w(t,r),F(t,r)];for(let e of a)if(await s.pathExists(e))return await $(t,e),e;return null}async function Z(t,r,a){b(r,a);let e=w(t,r);return await y(t,e,i=>s.writeJson(i,a,{spaces:2})),d({workspacePath:t,relativePath:r}),e}async function tt(t,r,a){return U(t,r,a.map(e=>({rootPath:t,...e})))}async function U(t,r,a){if(a.length===0)return [];let e=a.map(n=>({...n,rootPath:l.resolve(n.rootPath),path:w(n.rootPath,n.relativePath)})),i=e.find((n,f)=>e.findIndex(o=>o.path===n.path)!==f);if(i)throw new Error(`Duplicate workspace artifact transaction target: ${i.relativePath}`);for(let n of e)b(n.relativePath,n.payload);return O(t,r,async()=>{let n=randomUUID(),f=[];try{for(let o of e){let p=await s.pathExists(o.path),u={path:o.path,rootPath:o.rootPath,exists:p,backupPath:null};if(f.push(u),p){let c=`${o.path}.${process.pid}.${n}.rollback`;await $(o.rootPath,o.path);try{try{await link(o.path,c);}catch{await copyFile(o.path,c);}u.backupPath=c;}catch(d){throw await s.remove(c).catch(()=>{}),d}}}for(let o=0;o<e.length;o+=1){let p=e[o];await y(p.rootPath,p.path,c=>s.writeJson(c,p.payload,{spaces:2}));let u=Number(process.env.WORKSPAI_TEST_FAIL_ARTIFACT_SET_AFTER??0);if(Number.isInteger(u)&&u===o+1)throw new Error(`Injected artifact-set failure after ${u} write(s).`)}for(let o of e)d({workspacePath:o.rootPath,relativePath:o.relativePath});return e.map(o=>o.path)}catch(o){let u=(await Promise.allSettled(f.map(async c=>{if(!c.exists){await s.remove(c.path);return}c.backupPath&&await y(c.rootPath,c.path,d=>copyFile(c.backupPath,d));}))).filter(c=>c.status==="rejected");throw u.length>0?new AggregateError([o,...u.map(c=>c.reason)],"Workspace artifact transaction failed and rollback was incomplete."):o}finally{await Promise.all(f.map(o=>o.backupPath?s.remove(o.backupPath).catch(()=>{}):Promise.resolve()));}})}async function rt(t,r,a){let e=w(t,r);return await y(t,e,i=>s.writeFile(i,a,"utf-8")),d({workspacePath:t,relativePath:r}),e}export{w as a,F as b,O as c,Q as d,Z as e,tt as f,U as g,rt as h};
@@ -1,4 +1,4 @@
1
- import {c as c$1,b as b$1}from'./chunk-WCJU3CFG.js';import {d,b,e}from'./chunk-5XGR3LRI.js';import {a}from'./chunk-LPCZHKD5.js';import {a as a$1}from'./chunk-NMXGSVMD.js';import {d as d$3}from'./chunk-S5KTATOU.js';import {q as q$1,z as z$1,u as u$1}from'./chunk-L5Q2S5GY.js';import {k,m,g,f}from'./chunk-U5ENEDJA.js';import {d as d$2}from'./chunk-GAYK3WGV.js';import {e as e$1,i}from'./chunk-6UNATTB7.js';import {a as a$2}from'./chunk-TQEMLBAG.js';import {c,d as d$1}from'./chunk-5TY74LLW.js';import {e as e$2,g as g$1}from'./chunk-RGNCL5OB.js';import {u,q,t}from'./chunk-VQZ5PI5J.js';import J from'fs';import w from'path';import T from'chalk';import {execa}from'execa';var ut={"python-fastapi":{runtime:"python",framework:"FastAPI",markers:["pyproject.toml","fastapi"],commands:{init:"python -m pip install -e .",test:"pytest",build:"python -m build",start:"uvicorn main:app --reload"},errorPatterns:{setup:["ModuleNotFoundError","No module named","pip: command not found"],"test-failure":["FAILED","ERROR","test session started"],dependency:["ImportError","missing.*dependency"],runtime:["TypeError","AttributeError","ValueError"],timeout:["timeout","Timeout","timed out"],unknown:[]},healthCheck:{stage:"start",type:"http",value:"http://localhost:8000/docs"},validation:{command:"python -m pip list | grep fastapi",error:"FastAPI not installed"}},"python-django":{runtime:"python",framework:"Django",markers:["manage.py","django"],commands:{init:"python manage.py migrate",test:"python manage.py test",build:"python manage.py collectstatic --noinput",start:"python manage.py runserver 0.0.0.0:8000"},errorPatterns:{setup:["ModuleNotFoundError","ProgrammingError.*migrate"],"test-failure":["FAILED","ERROR","Ran.*test"],dependency:["ImportError","missing.*dependency"],runtime:["DatabaseError","ImproperlyConfigured"],timeout:["timeout","Timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:8e3},dependencies:["init"]},"node-nestjs":{runtime:"node",framework:"NestJS",markers:["package.json","@nestjs/core"],commands:{init:"npm install",test:"npm run test",build:"npm run build",start:"npm run start"},errorPatterns:{setup:["npm ERR!","ENOENT","not found"],"test-failure":["Tests.*failed","FAIL","fail.*test"],dependency:["Cannot find module","ERR_MODULE_NOT_FOUND"],runtime:["TypeError","Error: ","ReferenceError"],timeout:["timeout","TIMEOUT"],unknown:[]},healthCheck:{stage:"start",type:"port",value:3e3}},"node-express":{runtime:"node",framework:"Express",markers:["package.json","express"],commands:{init:"npm install",test:"npm run test",build:"npm run build",start:"npm start"},errorPatterns:{setup:["npm ERR!","ENOENT"],"test-failure":["failed","FAIL"],dependency:["Cannot find module"],runtime:["Error","TypeError"],timeout:["timeout"],unknown:[]}},"go-fiber":{runtime:"go",framework:"Fiber",markers:["go.mod","fiber"],commands:{init:"go mod download && go mod tidy",test:"go test ./...",build:"go build -o app .",start:"./app"},errorPatterns:{setup:["go: .*not found","cannot find","go mod tidy"],"test-failure":["FAIL","--- FAIL"],dependency:["missing.*module"],runtime:["panic","fatal","Error"],timeout:["timeout","context deadline"],unknown:[]},dependencies:["init"]},"go-gin":{runtime:"go",framework:"Gin",markers:["go.mod","gin-gonic"],commands:{init:"go mod download && go mod tidy",test:"go test ./...",build:"go build -o app .",start:"./app"},errorPatterns:{setup:["go: .*not found"],"test-failure":["FAIL"],dependency:["missing.*module"],runtime:["panic"],timeout:["timeout"],unknown:[]}},"java-springboot":{runtime:"java",framework:"Spring Boot",markers:["pom.xml","build.gradle","spring-boot"],commands:{init:"mvn dependency:go-offline",test:"mvn test",build:"mvn package -DskipTests",start:"mvn spring-boot:run"},errorPatterns:{setup:["\\[ERROR\\]","BUILD FAILURE","missing dependencies"],"test-failure":["\\[ERROR\\] Tests run:","BUILD FAILURE"],dependency:["missing.*dependency"],runtime:["Exception","Error","NullPointerException"],timeout:["timeout","Timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:8080}},"php-laravel":{runtime:"php",framework:"Laravel",markers:["composer.json","artisan","app/Models"],commands:{init:"composer install && php artisan migrate:fresh --seed",test:"php artisan test",build:"php artisan config:cache && php artisan route:cache && php artisan view:cache",start:"php artisan serve --host=0.0.0.0 --port=8000"},errorPatterns:{setup:["Composer.*lock","Fatal error","Class.*not found"],"test-failure":["FAILED","Tests.*failed"],dependency:["Class.*not found","require.*failed"],runtime:["Fatal error","Exception","Error"],timeout:["timeout","Timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:8e3},dependencies:["init"]},"php-symfony":{runtime:"php",framework:"Symfony",markers:["composer.json","symfony.lock","bin/console"],commands:{init:"composer install && php bin/console doctrine:database:create",test:"php bin/phpunit",build:"php bin/console cache:clear --env=prod",start:"symfony serve --no-tls"},errorPatterns:{setup:["Composer.*error","Fatal error"],"test-failure":["FAILED","failure"],dependency:["Class.*not found"],runtime:["Fatal error","Exception"],timeout:["timeout"],unknown:[]},dependencies:["init"]},"rust-actix":{runtime:"rust",framework:"Actix-web",markers:["Cargo.toml","actix"],commands:{init:"cargo fetch",test:"cargo test",build:"cargo build --release",start:"cargo run --release"},errorPatterns:{setup:["error: .*could not find","failed.*download"],"test-failure":["test result:","FAILED"],dependency:["can.t find.*crate"],runtime:["error\\[E","thread.*panicked"],timeout:["timeout"],unknown:[]},validation:{command:"cargo --version",error:"Rust/Cargo not installed"}},"rust-axum":{runtime:"rust",framework:"Axum",markers:["Cargo.toml","axum"],commands:{init:"cargo fetch",test:"cargo test",build:"cargo build --release",start:"cargo run --release"},errorPatterns:{setup:["error: .*could not find"],"test-failure":["test result:","FAILED"],dependency:["can.t find.*crate"],runtime:["error\\[E"],timeout:["timeout"],unknown:[]}},"rust-rocket":{runtime:"rust",framework:"Rocket",markers:["Cargo.toml","rocket"],commands:{init:"cargo fetch",test:"cargo test",build:"cargo build --release",start:"cargo run --release"},errorPatterns:{setup:["error: .*could not find"],"test-failure":["FAILED"],dependency:["can.t find"],runtime:["error\\[E"],timeout:["timeout"],unknown:[]}},"dotnet-aspnetcore":{runtime:"dotnet",framework:"ASP.NET Core",markers:[".csproj",".sln","Program.cs"],commands:{init:"dotnet restore",test:"dotnet test",build:"dotnet build -c Release",start:"dotnet run"},errorPatterns:{setup:["error CS","CSPROJ.*not found","NuGet.*restore"],"test-failure":["Failed:.*test","FAILED"],dependency:["error NU1101"],runtime:["error CS","Exception"],timeout:["timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:5e3}},"elixir-phoenix":{runtime:"elixir",framework:"Phoenix",markers:["mix.exs","phoenix"],commands:{init:"mix setup",test:"mix test",build:"mix compile --all-warnings",start:"mix phx.server"},errorPatterns:{setup:["\\*\\* \\(.*Error\\)","Mix.InstallError"],"test-failure":["\\d+\\sfailed","FAILED"],dependency:["dependencies are not available"],runtime:["\\*\\* \\(","RuntimeError"],timeout:["timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:4e3},dependencies:["init"]},"ruby-rails":{runtime:"ruby",framework:"Rails",markers:["Gemfile","config/application.rb","bin/rails"],commands:{init:"bundle install && rails db:prepare",test:"rails test",build:"rails assets:precompile",start:"rails server --binding=0.0.0.0 --port=3000"},errorPatterns:{setup:["Bundler::.*Error","Gem::.*Error"],"test-failure":["failures,","error,","FAILED"],dependency:["Could not find.*gem"],runtime:["Error","Exception","NoMethodError"],timeout:["timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:3e3},dependencies:["init"]},"ruby-sinatra":{runtime:"ruby",framework:"Sinatra",markers:["Gemfile","app.rb","sinatra"],commands:{init:"bundle install",test:"rspec",build:`echo "Sinatra apps don't require build"`,start:"ruby app.rb"},errorPatterns:{setup:["Bundler.*Error","Gem.*Error"],"test-failure":["failure","FAILED"],dependency:["Could not find.*gem"],runtime:["Error","NoMethodError"],timeout:["timeout"],unknown:[]}}},ct={init:{python:["pip install -e .","poetry install","pip install -r requirements.txt"],node:["npm install","pnpm install","yarn install"],go:["go mod download && go mod tidy","go get ./..."],java:["mvn dependency:go-offline","gradle dependencies"],php:["composer install"],rust:["cargo fetch"],dotnet:["dotnet restore"],c:["cmake -S . -B build"],cpp:["cmake -S . -B build"],elixir:["mix deps.get"],ruby:["bundle install"],clojure:["clojure -P"],scala:["sbt update"],kotlin:["./gradlew dependencies","gradle dependencies"],deno:[],bun:["bun install"],"jvm-generic":["mvn dependency:go-offline","gradle dependencies"],unknown:[]},test:{python:["pytest","python -m unittest","python -m pytest"],node:["npm test","npm run test"],go:["go test ./...","make test"],java:["mvn test","gradle test"],php:["php artisan test","phpunit","pest"],rust:["cargo test"],dotnet:["dotnet test"],c:["ctest --test-dir build --output-on-failure"],cpp:["ctest --test-dir build --output-on-failure"],elixir:["mix test"],ruby:["rspec","ruby -m minitest"],clojure:["clojure -X:test"],scala:["sbt test"],kotlin:["./gradlew test","gradle test"],deno:["deno task test","deno test"],bun:["bun test","bun run test"],"jvm-generic":["mvn test","gradle test"],unknown:[]},build:{python:["python -m build","python setup.py build"],node:["npm run build"],go:["go build -o app .","go build ./..."],java:["mvn package -DskipTests","gradle build -x test"],php:['echo "PHP build: typically no build step"'],rust:["cargo build --release"],dotnet:["dotnet build -c Release"],c:["cmake --build build"],cpp:["cmake --build build"],elixir:["mix compile"],ruby:["gem build *.gemspec"],clojure:[],scala:["sbt compile"],kotlin:["./gradlew build","gradle build"],deno:["deno task build"],bun:["bun run build"],"jvm-generic":["mvn package -DskipTests","gradle build"],unknown:[]},start:{python:["python app.py","python main.py","uvicorn main:app --reload"],node:["npm start","node index.js","node src/index.js"],go:["./app","go run main.go","go run ./..."],java:["mvn spring-boot:run","gradle bootRun","java -jar target/*.jar"],php:["php -S 0.0.0.0:8000","php artisan serve"],rust:["cargo run --release","./target/release/app"],dotnet:["dotnet run"],c:[],cpp:[],elixir:["mix phx.server","iex -S mix"],ruby:["rails server","ruby app.rb","bundle exec puma"],clojure:["clojure -M:run"],scala:["sbt run"],kotlin:["./gradlew run","gradle run"],deno:["deno task start","deno task dev"],bun:["bun run start","bun run dev"],"jvm-generic":["java -jar *.jar","gradle run"],unknown:[]}};function oe(e,r){if(r){let t=r.trim().toLowerCase().replace(/[_.\s]+/g,"-"),n=f(r),s=`${e}-${n==="gofiber"?"fiber":n==="gogin"?"gin":n==="dotnet"?"aspnetcore":n!=="unknown"?n:t==="fiber"?"fiber":t==="aspnetcore"||t==="asp-net-core"?"aspnetcore":t}`;return ut[s]}}function Be(e,r,t){if(r){let n=oe(e,r);if(n&&n.commands[t])return n.commands[t]}if(["init","test","build","start"].includes(t)){let n=ct[t]?.[e]??[];return n.length>0?n[0]:void 0}}var dt={test:"test",build:"build",start:"start"};function fe(e){if(e.stage==="init")return e.runtime==="node"?c$1(e.projectPath):Be(e.runtime,e.framework,e.stage);if(e.runtime==="node"){let r=dt[e.stage];if(r){let t=u$1(e.projectPath,r,{framework:e.framework});if(t)return b$1(e.projectPath,t.scriptName)}}return Be(e.runtime,e.framework,e.stage)}function lt(e){let r=k(e).map(t=>t==="python"?"python":t==="node"||t==="bun"?"node":t==="go"?"go":t==="java"?"java":t==="php"?"php":t==="rust"?"rust":t==="dotnet"?"dotnet":t==="elixir"?"elixir":t==="ruby"?"ruby":t==="clojure"||t==="scala"||t==="kotlin"?"jvm-generic":null).filter(t=>t!==null).filter((t,n,o)=>o.indexOf(t)===n);return {primary:r.length>0?r[0]:"unknown",secondary:r.slice(1)}}function ze(e){return lt(e).primary}function ge(e,r){if(!e)return "unknown";r||(r={setup:["ModuleNotFoundError","No module named","npm ERR!","error:","not found"],"test-failure":["FAILED","FAIL","failed"],dependency:["cannot find module","import.*error"],runtime:["Exception","Error:","panic","TypeError"],timeout:["timeout","Timeout","deadline exceeded"],unknown:[]});for(let[t,n]of Object.entries(r))for(let o of n)if(new RegExp(o,"i").test(e))return t;return "unknown"}async function se(e,r){let t=e.split(/[&|;]\s*/)[0].trim().split(/\s+/)[0];if(["echo","cd","pwd","test","true","false","exit"].includes(t))return {valid:true};if(t.includes("/")||t.includes("\\")){let o=w.isAbsolute(t)?t:w.resolve(r??process.cwd(),t);try{return await J.promises.access(o,process.platform==="win32"?J.constants.F_OK:J.constants.X_OK),{valid:true}}catch{return {valid:false,reason:`Command '${t}' not found or not executable in '${r??process.cwd()}'`}}}try{let o=process.platform==="win32"?"where":"which";if((await execa(o,[t],{reject:false})).exitCode===0)return {valid:true}}catch{}return {valid:false,reason:`Command '${t}' not found or not executable`}}function Ve(e,r,t){if(!r)return e;let n=typeof r=="object"&&!Array.isArray(r)&&("dev"in r||"staging"in r||"prod"in r||"default"in r)&&!Object.keys(r).some(o=>["init","test","build","start"].includes(o))?r:{};return t&&typeof n[t]=="string"?n[t]:typeof n.default=="string"?n.default:e}async function Je(e,r){if(!e)return {healthy:true};switch(e.type){case "port":{let t=e.value;try{let n=await import('net');return new Promise(o=>{let s=new n.Socket,u=5e3;s.setTimeout(u),s.on("connect",()=>{s.destroy(),o({healthy:true,reason:`Port ${t} is listening`});}),s.on("timeout",()=>{s.destroy(),o({healthy:false,reason:`Port ${t} timeout after ${u}ms`});}),s.on("error",c=>{s.destroy(),o({healthy:false,reason:`Port ${t} error: ${String(c)}`});}),s.connect(t,"localhost");})}catch(n){return {healthy:false,reason:`Port check error: ${n instanceof Error?n.message:String(n)}`}}}case "http":{let t=e.value,n;try{let o=new AbortController;n=setTimeout(()=>o.abort(),5e3);let s=await fetch(t,{method:"GET",signal:o.signal});return {healthy:s.status===200,reason:`HTTP ${s.status}`,metadata:{status:s.status}}}catch(o){return {healthy:false,reason:`HTTP check error: ${o instanceof Error?o.message:String(o)}`}}finally{n&&clearTimeout(n);}}case "log":{let t=e.value;if(!r)return {healthy:true};try{let n=[w.join(r,".workspai","last-run.log"),w.join(r,".rapidkit","last-run.log")].find(o=>J.existsSync(o));if(n){let o=J.readFileSync(n,"utf-8"),s=new RegExp(t,"i");return {healthy:s.test(o),reason:s.test(o)?"Log pattern found":"Log pattern not found"}}return {healthy:true,reason:"No log file to check"}}catch(n){return {healthy:false,reason:`Log check error: ${n instanceof Error?n.message:String(n)}`}}}case "command":{let t=e.value;try{let n=await execa(t,[],{cwd:r,reject:false,shell:true});return {healthy:n.exitCode===0,reason:n.exitCode===0?"Health check passed":"Health check failed",metadata:{exitCode:n.exitCode}}}catch(n){return {healthy:false,reason:`Command check error: ${n instanceof Error?n.message:String(n)}`}}}default:return {healthy:true}}}var qe={init:"init",test:"test",build:"build",start:"start"};function pt(e){return e in qe?qe[e]:null}function mt(e,r){let n=q$1(e)?.contextJson?.commands;if(!n||typeof n!="object"||Array.isArray(n))return;let o=n[r];if(typeof o=="string"&&o.trim().length>0)return o.trim();if(o&&typeof o=="object"&&!Array.isArray(o)){let s=o,u=s.default??s.dev;if(typeof u=="string"&&u.trim().length>0)return u.trim()}}function Ye(e,r,t=z$1(e)){let n=pt(r);if(!n)return mt(e,r)?{supported:true}:{supported:false,reason:`Workspace stage "${r}" is not part of the Workspai fleet contract.`};if(!t.projectRoot)return {supported:false,reason:"No Workspai project metadata was detected for this target."};let o=t.commandMap[n];if(!o||o.status!=="supported"){let s=t.runtimeSupportTier==="observed"||t.frameworkSupportTier==="observed";return {supported:false,reason:o?.reason??`Command "${n}" is not supported for this project runtime/framework.`,shouldFail:!s}}return {supported:true}}var ft=new Set(["init","test","build","start"]),gt=new Set([".git","node_modules",".workspai",".rapidkit",".venv","dist","build","coverage","htmlcov"]);async function z(e){try{return await J.promises.access(e,J.constants.F_OK),true}catch{return false}}async function yt(e){for(let r of e)if(await z(r))return true;return false}async function ht(e,r,t){if(r==="python"){let o=[w.join(e,".workspai","cli.py"),w.join(e,".rapidkit","cli.py")];for(let s of o)if(await z(s))return {valid:true};return {valid:false,reason:"Project-local .workspai/cli.py is missing. Run `workspai init` in this project first."}}let n=t.trim().split(/\s+/)[0];if(n&&["npm","npx","pnpm","yarn"].includes(n)){let o=e$2(n);if((await execa(o.command,[...o.prefixArgs,"--version"],{reject:false,env:g$1()})).exitCode===0)return {valid:true}}return se(t,e)}async function ae(e){let r=await J.promises.readFile(e,"utf-8");return JSON.parse(r)}function I(e){return e.replace(/\\/g,"/")}function kt(e){let r=e?.trim();return r?r.startsWith("project:")?r.slice(8).trim()||null:r:null}async function bt(e){let r=w.join(e,e$1.model);if(await z(r))try{let n=((await ae(r)).projects??[]).map(o=>typeof o.path=="string"?w.resolve(e,o.path):null).filter(o=>!!o).filter((o,s,u)=>u.indexOf(o)===s).filter(o=>J.existsSync(o));if(n.length>0)return n.sort()}catch{}return a$1(e,{skipDirs:gt,includeHiddenDirs:false,descendIntoMatchedProjects:false,isProjectDir:async(t,n)=>await yt([...u(t,"context.json"),...u(t,"project.json")])?true:w.resolve(t)===w.resolve(n)?false:k(t).length>0})}async function wt(e){for(let r of [w.join(".workspai","project.json"),w.join(".workspai","context.json"),w.join(".rapidkit","project.json"),w.join(".rapidkit","context.json")]){let t=w.join(e,r);if(await z(t))try{let n=await ae(t),o=n.name??n.projectName??n.slug;if(typeof o=="string"&&o.trim())return o.trim()}catch{}}return null}async function xt(e,r,t){let n=kt(t);if(!n)return {projects:r,normalizedScope:null};let o=I(n).toLowerCase(),s=[];for(let u of r){let c=I(w.relative(e,u)),m=w.basename(u),f=await wt(u);[c,m,f].filter(i=>typeof i=="string"&&i.length>0).map(i=>I(i).toLowerCase()).includes(o)&&s.push(u);}if(s.length===0)throw new Error(`Workspace run scope did not match any project: ${t}`);return {projects:s,normalizedScope:n}}async function vt(e,r,t){let n=await execa("git",["diff","--name-only",`${t}...HEAD`],{cwd:e,reject:false,env:a$2()});if(n.exitCode!==0)return new Set(r);let o=n.stdout.split(/\r?\n/).map(u=>u.trim()).filter(u=>u.length>0).map(u=>I(u));if(o.length===0)return new Set;let s=new Set;for(let u of r){let c=I(w.relative(e,u));if(!c||c===".")continue;let m=`${c}/`;o.some(f=>f===c||f.startsWith(m))&&s.add(u);}return s}async function Rt(e,r,t){let n=await d$2(e,i.workspaceContract)??q(e,"workspace.contract.json");if(await z(n))try{let d=await St(e,r,t,n);if(d.graphStatus!=="missing")return d}catch{return {expanded:t,graphStatus:"invalid",expansionDepth:0}}let o=await d$2(e,".workspai/workspace-dependency-graph.json")??q(e,"workspace-dependency-graph.json");if(!await z(o))return {expanded:t,graphStatus:"missing",expansionDepth:0};let s;try{s=await ae(o);}catch{return {expanded:t,graphStatus:"invalid",expansionDepth:0}}let u=new Set(r.map(d=>w.resolve(d))),c=new Map;if(!s||typeof s!="object"||Array.isArray(s))return {expanded:t,graphStatus:"invalid",expansionDepth:0};let m=Array.isArray(s.projects)?s.projects:[];for(let d of m){if(!d||typeof d!="object"||Array.isArray(d))continue;let i=d,l=typeof i.path=="string"?i.path:"",h=w.resolve(e,l);if(!u.has(h))continue;let k=Array.isArray(i.dependsOn)?i.dependsOn.filter(S=>typeof S=="string"):[];for(let S of k){let g=w.resolve(e,S);u.has(g)&&(c.has(g)||c.set(g,new Set),c.get(g)?.add(h));}}let f=d$3(c,t);return {expanded:f.reached,graphStatus:"loaded",expansionDepth:f.added}}async function St(e,r,t,n){let o=await ae(n);if(!o||typeof o!="object"||Array.isArray(o))return {expanded:t,graphStatus:"invalid",expansionDepth:0};let s=o,u=Array.isArray(s.projects)?s.projects:null;if(!u)return {expanded:t,graphStatus:"invalid",expansionDepth:0};let c=new Map,m=new Map;for(let h of r){let k=I(w.relative(e,h));m.set(k,w.resolve(h));}let f=new Map,d=new Map,i=new Map;for(let h of u){if(!h||typeof h!="object"||Array.isArray(h))continue;let k=h,S=typeof k.slug=="string"?k.slug:"",g=typeof k.relativePath=="string"?I(k.relativePath):S,y=m.get(g);!S||!y||c.set(S,y);}for(let h of u){if(!h||typeof h!="object"||Array.isArray(h))continue;let k=h,S=typeof k.slug=="string"?k.slug:"",g=c.get(S);if(!g)continue;let y=k.contracts&&typeof k.contracts=="object"&&!Array.isArray(k.contracts)?k.contracts:{},j=Array.isArray(y.dependsOn)?y.dependsOn.filter(R=>typeof R=="string"):[],M=Array.isArray(y.publishes)?y.publishes.filter(R=>typeof R=="string"):[],L=Array.isArray(y.consumes)?y.consumes.filter(R=>typeof R=="string"):[];for(let R of j){let E=c.get(R);E&&(i.has(E)||i.set(E,new Set),i.get(E)?.add(g));}for(let R of M)f.has(R)||f.set(R,new Set),f.get(R)?.add(g);for(let R of L)d.has(R)||d.set(R,new Set),d.get(R)?.add(g);}for(let[h,k]of f.entries()){let S=d.get(h);if(S)for(let g of k){i.has(g)||i.set(g,new Set);for(let y of S)y!==g&&i.get(g)?.add(y);}}let l=d$3(i,t);return {expanded:l.reached,graphStatus:"loaded",expansionDepth:l.added}}async function Ct(e,r){if(typeof r=="boolean")return r;let t$1=t(e,"policies.yml").find(s=>J.existsSync(s))??q(e,"policies.yml");if(!await z(t$1))return true;let n="";try{n=await J.promises.readFile(t$1,"utf-8");}catch{return true}let o=n.match(/^[\t ]*rules\.enforce_workspace_run_gates:\s*(true|false)\s*(?:#.*)?$/m);return o?o[1]==="true":true}function Et(e){let r=process.env.RAPIDKIT_WORKSPACE_RUN_STAGE_TIMEOUT_MS;if(r){let t=Number.parseInt(r,10);if(Number.isFinite(t)&&t>0)return t}return e==="init"?12e4:9e4}function jt(e){let r=e.trim();if(!/^\.\.?[\\/]/.test(r)||/[&|;<>()$`"']/.test(r))return null;let[t,...n]=r.split(/\s+/);return t?{file:t,args:n}:null}function Xe(e,r){let t=Number.parseInt(process.env[e]??"",10);return Number.isFinite(t)&&t>0?t:r}function ye(e){return new Promise(r=>setTimeout(r,e))}async function Pt(e){let r=process.argv[1];if(e.useRapidkitWrapper&&!r)return {exitCode:1,stdout:"",stderr:"Workspai entrypoint is unavailable for startup verification.",healthStatus:{healthy:false,reason:"Workspai entrypoint is unavailable."}};let t=e.useRapidkitWrapper&&r?execa(process.execPath,[r,"start"],{cwd:e.projectPath,reject:false,timeout:e.timeoutMs,env:{...process.env,RAPIDKIT_WORKSPACE_RUN_CHILD:"1"}}):execa(e.finalCommand,[],{cwd:e.projectPath,reject:false,shell:true,timeout:e.timeoutMs}),n=Promise.resolve(t).then(d=>({kind:"exit",result:d}),d=>({kind:"error",error:d})),o=Xe("WORKSPAI_WORKSPACE_RUN_STARTUP_GRACE_MS",2e3),s=await Promise.race([n,ye(o).then(()=>({kind:"alive"}))]);if(s.kind==="error"){let d=typeof s.error=="object"&&s.error!==null&&"timedOut"in s.error&&!!s.error.timedOut;return {exitCode:d?124:1,stdout:"",stderr:s.error instanceof Error?s.error.message:String(s.error),timedOut:d,healthStatus:{healthy:false,reason:"The start command failed before readiness."}}}if(s.kind==="exit"){let d=Number(s.result.exitCode??0);return {exitCode:d,stdout:String(s.result.stdout??""),stderr:String(s.result.stderr??""),healthStatus:{healthy:d===0,reason:d===0?"The start command completed successfully.":`The start command exited with code ${d} before readiness.`}}}let u=oe(e.runtime,e.framework)?.healthCheck,c=u?{healthy:false,reason:"The configured health check has not passed yet."}:{healthy:true,reason:`The service remained alive for ${o}ms (bounded startup smoke).`};if(u){let d=Xe("WORKSPAI_WORKSPACE_RUN_STARTUP_HEALTH_TIMEOUT_MS",15e3),i=Date.now()+d;for(;Date.now()<i;){let l=await Je(u,e.projectPath);if(c={healthy:l.healthy,reason:l.reason},l.healthy)break;if((await Promise.race([n,ye(350).then(()=>({kind:"alive"}))])).kind!=="alive"){c={healthy:false,reason:"The service exited before its configured health check passed."};break}}}try{t.kill?.("SIGTERM",{forceKillAfterDelay:1e3});}catch{try{t.kill?.();}catch{}}let m=await Promise.race([n,ye(2e3).then(()=>({kind:"alive"}))]),f=m.kind==="exit"?m.result:void 0;return {exitCode:c.healthy?0:1,stdout:String(f?.stdout??""),stderr:String(f?.stderr??""),healthStatus:c}}async function he(e,r,t){let n=process.argv[1];if(!n)return {exitCode:1,stdout:"",stderr:"RapidKit entrypoint is unavailable for nested workspace-run execution."};try{let o=await execa(process.execPath,[n,...e],{cwd:r,reject:false,timeout:t,env:{...process.env,RAPIDKIT_WORKSPACE_RUN_CHILD:"1"}});return {exitCode:Number(o.exitCode??1),stdout:o.stdout,stderr:o.stderr}}catch(o){return {exitCode:typeof o=="object"&&o!==null&&"timedOut"in o&&!!o.timedOut?124:1,stdout:typeof o=="object"&&o!==null&&"stdout"in o?String(o.stdout??""):"",stderr:typeof o=="object"&&o!==null&&"stderr"in o?String(o.stderr??""):o instanceof Error?o.message:String(o)}}}function At(e){return e==="node"||e==="go"||e==="java"||e==="python"||e==="dotnet"||e==="rust"||e==="php"}function Ft(){return process.env.VITEST==="true"||process.env.VITEST==="1"||process.env.NODE_ENV==="test"}function Ot(e,r=8){if(e.length<=r)return e.join(`
1
+ import {c as c$1,b as b$1}from'./chunk-WCJU3CFG.js';import {d,b,e}from'./chunk-OCNPOYMA.js';import {a}from'./chunk-LPCZHKD5.js';import {a as a$1}from'./chunk-NMXGSVMD.js';import {d as d$3}from'./chunk-S5KTATOU.js';import {q as q$1,z as z$1,u as u$1}from'./chunk-L5Q2S5GY.js';import {k,m,g,f}from'./chunk-U5ENEDJA.js';import {d as d$2}from'./chunk-XDPTAV2T.js';import {e as e$1,i}from'./chunk-ZGHJIQXL.js';import {a as a$2}from'./chunk-TQEMLBAG.js';import {c,d as d$1}from'./chunk-5TY74LLW.js';import {e as e$2,g as g$1}from'./chunk-RGNCL5OB.js';import {u,q,t}from'./chunk-VQZ5PI5J.js';import J from'fs';import w from'path';import T from'chalk';import {execa}from'execa';var ut={"python-fastapi":{runtime:"python",framework:"FastAPI",markers:["pyproject.toml","fastapi"],commands:{init:"python -m pip install -e .",test:"pytest",build:"python -m build",start:"uvicorn main:app --reload"},errorPatterns:{setup:["ModuleNotFoundError","No module named","pip: command not found"],"test-failure":["FAILED","ERROR","test session started"],dependency:["ImportError","missing.*dependency"],runtime:["TypeError","AttributeError","ValueError"],timeout:["timeout","Timeout","timed out"],unknown:[]},healthCheck:{stage:"start",type:"http",value:"http://localhost:8000/docs"},validation:{command:"python -m pip list | grep fastapi",error:"FastAPI not installed"}},"python-django":{runtime:"python",framework:"Django",markers:["manage.py","django"],commands:{init:"python manage.py migrate",test:"python manage.py test",build:"python manage.py collectstatic --noinput",start:"python manage.py runserver 0.0.0.0:8000"},errorPatterns:{setup:["ModuleNotFoundError","ProgrammingError.*migrate"],"test-failure":["FAILED","ERROR","Ran.*test"],dependency:["ImportError","missing.*dependency"],runtime:["DatabaseError","ImproperlyConfigured"],timeout:["timeout","Timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:8e3},dependencies:["init"]},"node-nestjs":{runtime:"node",framework:"NestJS",markers:["package.json","@nestjs/core"],commands:{init:"npm install",test:"npm run test",build:"npm run build",start:"npm run start"},errorPatterns:{setup:["npm ERR!","ENOENT","not found"],"test-failure":["Tests.*failed","FAIL","fail.*test"],dependency:["Cannot find module","ERR_MODULE_NOT_FOUND"],runtime:["TypeError","Error: ","ReferenceError"],timeout:["timeout","TIMEOUT"],unknown:[]},healthCheck:{stage:"start",type:"port",value:3e3}},"node-express":{runtime:"node",framework:"Express",markers:["package.json","express"],commands:{init:"npm install",test:"npm run test",build:"npm run build",start:"npm start"},errorPatterns:{setup:["npm ERR!","ENOENT"],"test-failure":["failed","FAIL"],dependency:["Cannot find module"],runtime:["Error","TypeError"],timeout:["timeout"],unknown:[]}},"go-fiber":{runtime:"go",framework:"Fiber",markers:["go.mod","fiber"],commands:{init:"go mod download && go mod tidy",test:"go test ./...",build:"go build -o app .",start:"./app"},errorPatterns:{setup:["go: .*not found","cannot find","go mod tidy"],"test-failure":["FAIL","--- FAIL"],dependency:["missing.*module"],runtime:["panic","fatal","Error"],timeout:["timeout","context deadline"],unknown:[]},dependencies:["init"]},"go-gin":{runtime:"go",framework:"Gin",markers:["go.mod","gin-gonic"],commands:{init:"go mod download && go mod tidy",test:"go test ./...",build:"go build -o app .",start:"./app"},errorPatterns:{setup:["go: .*not found"],"test-failure":["FAIL"],dependency:["missing.*module"],runtime:["panic"],timeout:["timeout"],unknown:[]}},"java-springboot":{runtime:"java",framework:"Spring Boot",markers:["pom.xml","build.gradle","spring-boot"],commands:{init:"mvn dependency:go-offline",test:"mvn test",build:"mvn package -DskipTests",start:"mvn spring-boot:run"},errorPatterns:{setup:["\\[ERROR\\]","BUILD FAILURE","missing dependencies"],"test-failure":["\\[ERROR\\] Tests run:","BUILD FAILURE"],dependency:["missing.*dependency"],runtime:["Exception","Error","NullPointerException"],timeout:["timeout","Timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:8080}},"php-laravel":{runtime:"php",framework:"Laravel",markers:["composer.json","artisan","app/Models"],commands:{init:"composer install && php artisan migrate:fresh --seed",test:"php artisan test",build:"php artisan config:cache && php artisan route:cache && php artisan view:cache",start:"php artisan serve --host=0.0.0.0 --port=8000"},errorPatterns:{setup:["Composer.*lock","Fatal error","Class.*not found"],"test-failure":["FAILED","Tests.*failed"],dependency:["Class.*not found","require.*failed"],runtime:["Fatal error","Exception","Error"],timeout:["timeout","Timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:8e3},dependencies:["init"]},"php-symfony":{runtime:"php",framework:"Symfony",markers:["composer.json","symfony.lock","bin/console"],commands:{init:"composer install && php bin/console doctrine:database:create",test:"php bin/phpunit",build:"php bin/console cache:clear --env=prod",start:"symfony serve --no-tls"},errorPatterns:{setup:["Composer.*error","Fatal error"],"test-failure":["FAILED","failure"],dependency:["Class.*not found"],runtime:["Fatal error","Exception"],timeout:["timeout"],unknown:[]},dependencies:["init"]},"rust-actix":{runtime:"rust",framework:"Actix-web",markers:["Cargo.toml","actix"],commands:{init:"cargo fetch",test:"cargo test",build:"cargo build --release",start:"cargo run --release"},errorPatterns:{setup:["error: .*could not find","failed.*download"],"test-failure":["test result:","FAILED"],dependency:["can.t find.*crate"],runtime:["error\\[E","thread.*panicked"],timeout:["timeout"],unknown:[]},validation:{command:"cargo --version",error:"Rust/Cargo not installed"}},"rust-axum":{runtime:"rust",framework:"Axum",markers:["Cargo.toml","axum"],commands:{init:"cargo fetch",test:"cargo test",build:"cargo build --release",start:"cargo run --release"},errorPatterns:{setup:["error: .*could not find"],"test-failure":["test result:","FAILED"],dependency:["can.t find.*crate"],runtime:["error\\[E"],timeout:["timeout"],unknown:[]}},"rust-rocket":{runtime:"rust",framework:"Rocket",markers:["Cargo.toml","rocket"],commands:{init:"cargo fetch",test:"cargo test",build:"cargo build --release",start:"cargo run --release"},errorPatterns:{setup:["error: .*could not find"],"test-failure":["FAILED"],dependency:["can.t find"],runtime:["error\\[E"],timeout:["timeout"],unknown:[]}},"dotnet-aspnetcore":{runtime:"dotnet",framework:"ASP.NET Core",markers:[".csproj",".sln","Program.cs"],commands:{init:"dotnet restore",test:"dotnet test",build:"dotnet build -c Release",start:"dotnet run"},errorPatterns:{setup:["error CS","CSPROJ.*not found","NuGet.*restore"],"test-failure":["Failed:.*test","FAILED"],dependency:["error NU1101"],runtime:["error CS","Exception"],timeout:["timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:5e3}},"elixir-phoenix":{runtime:"elixir",framework:"Phoenix",markers:["mix.exs","phoenix"],commands:{init:"mix setup",test:"mix test",build:"mix compile --all-warnings",start:"mix phx.server"},errorPatterns:{setup:["\\*\\* \\(.*Error\\)","Mix.InstallError"],"test-failure":["\\d+\\sfailed","FAILED"],dependency:["dependencies are not available"],runtime:["\\*\\* \\(","RuntimeError"],timeout:["timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:4e3},dependencies:["init"]},"ruby-rails":{runtime:"ruby",framework:"Rails",markers:["Gemfile","config/application.rb","bin/rails"],commands:{init:"bundle install && rails db:prepare",test:"rails test",build:"rails assets:precompile",start:"rails server --binding=0.0.0.0 --port=3000"},errorPatterns:{setup:["Bundler::.*Error","Gem::.*Error"],"test-failure":["failures,","error,","FAILED"],dependency:["Could not find.*gem"],runtime:["Error","Exception","NoMethodError"],timeout:["timeout"],unknown:[]},healthCheck:{stage:"start",type:"port",value:3e3},dependencies:["init"]},"ruby-sinatra":{runtime:"ruby",framework:"Sinatra",markers:["Gemfile","app.rb","sinatra"],commands:{init:"bundle install",test:"rspec",build:`echo "Sinatra apps don't require build"`,start:"ruby app.rb"},errorPatterns:{setup:["Bundler.*Error","Gem.*Error"],"test-failure":["failure","FAILED"],dependency:["Could not find.*gem"],runtime:["Error","NoMethodError"],timeout:["timeout"],unknown:[]}}},ct={init:{python:["pip install -e .","poetry install","pip install -r requirements.txt"],node:["npm install","pnpm install","yarn install"],go:["go mod download && go mod tidy","go get ./..."],java:["mvn dependency:go-offline","gradle dependencies"],php:["composer install"],rust:["cargo fetch"],dotnet:["dotnet restore"],c:["cmake -S . -B build"],cpp:["cmake -S . -B build"],elixir:["mix deps.get"],ruby:["bundle install"],clojure:["clojure -P"],scala:["sbt update"],kotlin:["./gradlew dependencies","gradle dependencies"],deno:[],bun:["bun install"],"jvm-generic":["mvn dependency:go-offline","gradle dependencies"],unknown:[]},test:{python:["pytest","python -m unittest","python -m pytest"],node:["npm test","npm run test"],go:["go test ./...","make test"],java:["mvn test","gradle test"],php:["php artisan test","phpunit","pest"],rust:["cargo test"],dotnet:["dotnet test"],c:["ctest --test-dir build --output-on-failure"],cpp:["ctest --test-dir build --output-on-failure"],elixir:["mix test"],ruby:["rspec","ruby -m minitest"],clojure:["clojure -X:test"],scala:["sbt test"],kotlin:["./gradlew test","gradle test"],deno:["deno task test","deno test"],bun:["bun test","bun run test"],"jvm-generic":["mvn test","gradle test"],unknown:[]},build:{python:["python -m build","python setup.py build"],node:["npm run build"],go:["go build -o app .","go build ./..."],java:["mvn package -DskipTests","gradle build -x test"],php:['echo "PHP build: typically no build step"'],rust:["cargo build --release"],dotnet:["dotnet build -c Release"],c:["cmake --build build"],cpp:["cmake --build build"],elixir:["mix compile"],ruby:["gem build *.gemspec"],clojure:[],scala:["sbt compile"],kotlin:["./gradlew build","gradle build"],deno:["deno task build"],bun:["bun run build"],"jvm-generic":["mvn package -DskipTests","gradle build"],unknown:[]},start:{python:["python app.py","python main.py","uvicorn main:app --reload"],node:["npm start","node index.js","node src/index.js"],go:["./app","go run main.go","go run ./..."],java:["mvn spring-boot:run","gradle bootRun","java -jar target/*.jar"],php:["php -S 0.0.0.0:8000","php artisan serve"],rust:["cargo run --release","./target/release/app"],dotnet:["dotnet run"],c:[],cpp:[],elixir:["mix phx.server","iex -S mix"],ruby:["rails server","ruby app.rb","bundle exec puma"],clojure:["clojure -M:run"],scala:["sbt run"],kotlin:["./gradlew run","gradle run"],deno:["deno task start","deno task dev"],bun:["bun run start","bun run dev"],"jvm-generic":["java -jar *.jar","gradle run"],unknown:[]}};function oe(e,r){if(r){let t=r.trim().toLowerCase().replace(/[_.\s]+/g,"-"),n=f(r),s=`${e}-${n==="gofiber"?"fiber":n==="gogin"?"gin":n==="dotnet"?"aspnetcore":n!=="unknown"?n:t==="fiber"?"fiber":t==="aspnetcore"||t==="asp-net-core"?"aspnetcore":t}`;return ut[s]}}function Be(e,r,t){if(r){let n=oe(e,r);if(n&&n.commands[t])return n.commands[t]}if(["init","test","build","start"].includes(t)){let n=ct[t]?.[e]??[];return n.length>0?n[0]:void 0}}var dt={test:"test",build:"build",start:"start"};function fe(e){if(e.stage==="init")return e.runtime==="node"?c$1(e.projectPath):Be(e.runtime,e.framework,e.stage);if(e.runtime==="node"){let r=dt[e.stage];if(r){let t=u$1(e.projectPath,r,{framework:e.framework});if(t)return b$1(e.projectPath,t.scriptName)}}return Be(e.runtime,e.framework,e.stage)}function lt(e){let r=k(e).map(t=>t==="python"?"python":t==="node"||t==="bun"?"node":t==="go"?"go":t==="java"?"java":t==="php"?"php":t==="rust"?"rust":t==="dotnet"?"dotnet":t==="elixir"?"elixir":t==="ruby"?"ruby":t==="clojure"||t==="scala"||t==="kotlin"?"jvm-generic":null).filter(t=>t!==null).filter((t,n,o)=>o.indexOf(t)===n);return {primary:r.length>0?r[0]:"unknown",secondary:r.slice(1)}}function ze(e){return lt(e).primary}function ge(e,r){if(!e)return "unknown";r||(r={setup:["ModuleNotFoundError","No module named","npm ERR!","error:","not found"],"test-failure":["FAILED","FAIL","failed"],dependency:["cannot find module","import.*error"],runtime:["Exception","Error:","panic","TypeError"],timeout:["timeout","Timeout","deadline exceeded"],unknown:[]});for(let[t,n]of Object.entries(r))for(let o of n)if(new RegExp(o,"i").test(e))return t;return "unknown"}async function se(e,r){let t=e.split(/[&|;]\s*/)[0].trim().split(/\s+/)[0];if(["echo","cd","pwd","test","true","false","exit"].includes(t))return {valid:true};if(t.includes("/")||t.includes("\\")){let o=w.isAbsolute(t)?t:w.resolve(r??process.cwd(),t);try{return await J.promises.access(o,process.platform==="win32"?J.constants.F_OK:J.constants.X_OK),{valid:true}}catch{return {valid:false,reason:`Command '${t}' not found or not executable in '${r??process.cwd()}'`}}}try{let o=process.platform==="win32"?"where":"which";if((await execa(o,[t],{reject:false})).exitCode===0)return {valid:true}}catch{}return {valid:false,reason:`Command '${t}' not found or not executable`}}function Ve(e,r,t){if(!r)return e;let n=typeof r=="object"&&!Array.isArray(r)&&("dev"in r||"staging"in r||"prod"in r||"default"in r)&&!Object.keys(r).some(o=>["init","test","build","start"].includes(o))?r:{};return t&&typeof n[t]=="string"?n[t]:typeof n.default=="string"?n.default:e}async function Je(e,r){if(!e)return {healthy:true};switch(e.type){case "port":{let t=e.value;try{let n=await import('net');return new Promise(o=>{let s=new n.Socket,u=5e3;s.setTimeout(u),s.on("connect",()=>{s.destroy(),o({healthy:true,reason:`Port ${t} is listening`});}),s.on("timeout",()=>{s.destroy(),o({healthy:false,reason:`Port ${t} timeout after ${u}ms`});}),s.on("error",c=>{s.destroy(),o({healthy:false,reason:`Port ${t} error: ${String(c)}`});}),s.connect(t,"localhost");})}catch(n){return {healthy:false,reason:`Port check error: ${n instanceof Error?n.message:String(n)}`}}}case "http":{let t=e.value,n;try{let o=new AbortController;n=setTimeout(()=>o.abort(),5e3);let s=await fetch(t,{method:"GET",signal:o.signal});return {healthy:s.status===200,reason:`HTTP ${s.status}`,metadata:{status:s.status}}}catch(o){return {healthy:false,reason:`HTTP check error: ${o instanceof Error?o.message:String(o)}`}}finally{n&&clearTimeout(n);}}case "log":{let t=e.value;if(!r)return {healthy:true};try{let n=[w.join(r,".workspai","last-run.log"),w.join(r,".rapidkit","last-run.log")].find(o=>J.existsSync(o));if(n){let o=J.readFileSync(n,"utf-8"),s=new RegExp(t,"i");return {healthy:s.test(o),reason:s.test(o)?"Log pattern found":"Log pattern not found"}}return {healthy:true,reason:"No log file to check"}}catch(n){return {healthy:false,reason:`Log check error: ${n instanceof Error?n.message:String(n)}`}}}case "command":{let t=e.value;try{let n=await execa(t,[],{cwd:r,reject:false,shell:true});return {healthy:n.exitCode===0,reason:n.exitCode===0?"Health check passed":"Health check failed",metadata:{exitCode:n.exitCode}}}catch(n){return {healthy:false,reason:`Command check error: ${n instanceof Error?n.message:String(n)}`}}}default:return {healthy:true}}}var qe={init:"init",test:"test",build:"build",start:"start"};function pt(e){return e in qe?qe[e]:null}function mt(e,r){let n=q$1(e)?.contextJson?.commands;if(!n||typeof n!="object"||Array.isArray(n))return;let o=n[r];if(typeof o=="string"&&o.trim().length>0)return o.trim();if(o&&typeof o=="object"&&!Array.isArray(o)){let s=o,u=s.default??s.dev;if(typeof u=="string"&&u.trim().length>0)return u.trim()}}function Ye(e,r,t=z$1(e)){let n=pt(r);if(!n)return mt(e,r)?{supported:true}:{supported:false,reason:`Workspace stage "${r}" is not part of the Workspai fleet contract.`};if(!t.projectRoot)return {supported:false,reason:"No Workspai project metadata was detected for this target."};let o=t.commandMap[n];if(!o||o.status!=="supported"){let s=t.runtimeSupportTier==="observed"||t.frameworkSupportTier==="observed";return {supported:false,reason:o?.reason??`Command "${n}" is not supported for this project runtime/framework.`,shouldFail:!s}}return {supported:true}}var ft=new Set(["init","test","build","start"]),gt=new Set([".git","node_modules",".workspai",".rapidkit",".venv","dist","build","coverage","htmlcov"]);async function z(e){try{return await J.promises.access(e,J.constants.F_OK),true}catch{return false}}async function yt(e){for(let r of e)if(await z(r))return true;return false}async function ht(e,r,t){if(r==="python"){let o=[w.join(e,".workspai","cli.py"),w.join(e,".rapidkit","cli.py")];for(let s of o)if(await z(s))return {valid:true};return {valid:false,reason:"Project-local .workspai/cli.py is missing. Run `workspai init` in this project first."}}let n=t.trim().split(/\s+/)[0];if(n&&["npm","npx","pnpm","yarn"].includes(n)){let o=e$2(n);if((await execa(o.command,[...o.prefixArgs,"--version"],{reject:false,env:g$1()})).exitCode===0)return {valid:true}}return se(t,e)}async function ae(e){let r=await J.promises.readFile(e,"utf-8");return JSON.parse(r)}function I(e){return e.replace(/\\/g,"/")}function kt(e){let r=e?.trim();return r?r.startsWith("project:")?r.slice(8).trim()||null:r:null}async function bt(e){let r=w.join(e,e$1.model);if(await z(r))try{let n=((await ae(r)).projects??[]).map(o=>typeof o.path=="string"?w.resolve(e,o.path):null).filter(o=>!!o).filter((o,s,u)=>u.indexOf(o)===s).filter(o=>J.existsSync(o));if(n.length>0)return n.sort()}catch{}return a$1(e,{skipDirs:gt,includeHiddenDirs:false,descendIntoMatchedProjects:false,isProjectDir:async(t,n)=>await yt([...u(t,"context.json"),...u(t,"project.json")])?true:w.resolve(t)===w.resolve(n)?false:k(t).length>0})}async function wt(e){for(let r of [w.join(".workspai","project.json"),w.join(".workspai","context.json"),w.join(".rapidkit","project.json"),w.join(".rapidkit","context.json")]){let t=w.join(e,r);if(await z(t))try{let n=await ae(t),o=n.name??n.projectName??n.slug;if(typeof o=="string"&&o.trim())return o.trim()}catch{}}return null}async function xt(e,r,t){let n=kt(t);if(!n)return {projects:r,normalizedScope:null};let o=I(n).toLowerCase(),s=[];for(let u of r){let c=I(w.relative(e,u)),m=w.basename(u),f=await wt(u);[c,m,f].filter(i=>typeof i=="string"&&i.length>0).map(i=>I(i).toLowerCase()).includes(o)&&s.push(u);}if(s.length===0)throw new Error(`Workspace run scope did not match any project: ${t}`);return {projects:s,normalizedScope:n}}async function vt(e,r,t){let n=await execa("git",["diff","--name-only",`${t}...HEAD`],{cwd:e,reject:false,env:a$2()});if(n.exitCode!==0)return new Set(r);let o=n.stdout.split(/\r?\n/).map(u=>u.trim()).filter(u=>u.length>0).map(u=>I(u));if(o.length===0)return new Set;let s=new Set;for(let u of r){let c=I(w.relative(e,u));if(!c||c===".")continue;let m=`${c}/`;o.some(f=>f===c||f.startsWith(m))&&s.add(u);}return s}async function Rt(e,r,t){let n=await d$2(e,i.workspaceContract)??q(e,"workspace.contract.json");if(await z(n))try{let d=await St(e,r,t,n);if(d.graphStatus!=="missing")return d}catch{return {expanded:t,graphStatus:"invalid",expansionDepth:0}}let o=await d$2(e,".workspai/workspace-dependency-graph.json")??q(e,"workspace-dependency-graph.json");if(!await z(o))return {expanded:t,graphStatus:"missing",expansionDepth:0};let s;try{s=await ae(o);}catch{return {expanded:t,graphStatus:"invalid",expansionDepth:0}}let u=new Set(r.map(d=>w.resolve(d))),c=new Map;if(!s||typeof s!="object"||Array.isArray(s))return {expanded:t,graphStatus:"invalid",expansionDepth:0};let m=Array.isArray(s.projects)?s.projects:[];for(let d of m){if(!d||typeof d!="object"||Array.isArray(d))continue;let i=d,l=typeof i.path=="string"?i.path:"",h=w.resolve(e,l);if(!u.has(h))continue;let k=Array.isArray(i.dependsOn)?i.dependsOn.filter(S=>typeof S=="string"):[];for(let S of k){let g=w.resolve(e,S);u.has(g)&&(c.has(g)||c.set(g,new Set),c.get(g)?.add(h));}}let f=d$3(c,t);return {expanded:f.reached,graphStatus:"loaded",expansionDepth:f.added}}async function St(e,r,t,n){let o=await ae(n);if(!o||typeof o!="object"||Array.isArray(o))return {expanded:t,graphStatus:"invalid",expansionDepth:0};let s=o,u=Array.isArray(s.projects)?s.projects:null;if(!u)return {expanded:t,graphStatus:"invalid",expansionDepth:0};let c=new Map,m=new Map;for(let h of r){let k=I(w.relative(e,h));m.set(k,w.resolve(h));}let f=new Map,d=new Map,i=new Map;for(let h of u){if(!h||typeof h!="object"||Array.isArray(h))continue;let k=h,S=typeof k.slug=="string"?k.slug:"",g=typeof k.relativePath=="string"?I(k.relativePath):S,y=m.get(g);!S||!y||c.set(S,y);}for(let h of u){if(!h||typeof h!="object"||Array.isArray(h))continue;let k=h,S=typeof k.slug=="string"?k.slug:"",g=c.get(S);if(!g)continue;let y=k.contracts&&typeof k.contracts=="object"&&!Array.isArray(k.contracts)?k.contracts:{},j=Array.isArray(y.dependsOn)?y.dependsOn.filter(R=>typeof R=="string"):[],M=Array.isArray(y.publishes)?y.publishes.filter(R=>typeof R=="string"):[],L=Array.isArray(y.consumes)?y.consumes.filter(R=>typeof R=="string"):[];for(let R of j){let E=c.get(R);E&&(i.has(E)||i.set(E,new Set),i.get(E)?.add(g));}for(let R of M)f.has(R)||f.set(R,new Set),f.get(R)?.add(g);for(let R of L)d.has(R)||d.set(R,new Set),d.get(R)?.add(g);}for(let[h,k]of f.entries()){let S=d.get(h);if(S)for(let g of k){i.has(g)||i.set(g,new Set);for(let y of S)y!==g&&i.get(g)?.add(y);}}let l=d$3(i,t);return {expanded:l.reached,graphStatus:"loaded",expansionDepth:l.added}}async function Ct(e,r){if(typeof r=="boolean")return r;let t$1=t(e,"policies.yml").find(s=>J.existsSync(s))??q(e,"policies.yml");if(!await z(t$1))return true;let n="";try{n=await J.promises.readFile(t$1,"utf-8");}catch{return true}let o=n.match(/^[\t ]*rules\.enforce_workspace_run_gates:\s*(true|false)\s*(?:#.*)?$/m);return o?o[1]==="true":true}function Et(e){let r=process.env.RAPIDKIT_WORKSPACE_RUN_STAGE_TIMEOUT_MS;if(r){let t=Number.parseInt(r,10);if(Number.isFinite(t)&&t>0)return t}return e==="init"?12e4:9e4}function jt(e){let r=e.trim();if(!/^\.\.?[\\/]/.test(r)||/[&|;<>()$`"']/.test(r))return null;let[t,...n]=r.split(/\s+/);return t?{file:t,args:n}:null}function Xe(e,r){let t=Number.parseInt(process.env[e]??"",10);return Number.isFinite(t)&&t>0?t:r}function ye(e){return new Promise(r=>setTimeout(r,e))}async function Pt(e){let r=process.argv[1];if(e.useRapidkitWrapper&&!r)return {exitCode:1,stdout:"",stderr:"Workspai entrypoint is unavailable for startup verification.",healthStatus:{healthy:false,reason:"Workspai entrypoint is unavailable."}};let t=e.useRapidkitWrapper&&r?execa(process.execPath,[r,"start"],{cwd:e.projectPath,reject:false,timeout:e.timeoutMs,env:{...process.env,RAPIDKIT_WORKSPACE_RUN_CHILD:"1"}}):execa(e.finalCommand,[],{cwd:e.projectPath,reject:false,shell:true,timeout:e.timeoutMs}),n=Promise.resolve(t).then(d=>({kind:"exit",result:d}),d=>({kind:"error",error:d})),o=Xe("WORKSPAI_WORKSPACE_RUN_STARTUP_GRACE_MS",2e3),s=await Promise.race([n,ye(o).then(()=>({kind:"alive"}))]);if(s.kind==="error"){let d=typeof s.error=="object"&&s.error!==null&&"timedOut"in s.error&&!!s.error.timedOut;return {exitCode:d?124:1,stdout:"",stderr:s.error instanceof Error?s.error.message:String(s.error),timedOut:d,healthStatus:{healthy:false,reason:"The start command failed before readiness."}}}if(s.kind==="exit"){let d=Number(s.result.exitCode??0);return {exitCode:d,stdout:String(s.result.stdout??""),stderr:String(s.result.stderr??""),healthStatus:{healthy:d===0,reason:d===0?"The start command completed successfully.":`The start command exited with code ${d} before readiness.`}}}let u=oe(e.runtime,e.framework)?.healthCheck,c=u?{healthy:false,reason:"The configured health check has not passed yet."}:{healthy:true,reason:`The service remained alive for ${o}ms (bounded startup smoke).`};if(u){let d=Xe("WORKSPAI_WORKSPACE_RUN_STARTUP_HEALTH_TIMEOUT_MS",15e3),i=Date.now()+d;for(;Date.now()<i;){let l=await Je(u,e.projectPath);if(c={healthy:l.healthy,reason:l.reason},l.healthy)break;if((await Promise.race([n,ye(350).then(()=>({kind:"alive"}))])).kind!=="alive"){c={healthy:false,reason:"The service exited before its configured health check passed."};break}}}try{t.kill?.("SIGTERM",{forceKillAfterDelay:1e3});}catch{try{t.kill?.();}catch{}}let m=await Promise.race([n,ye(2e3).then(()=>({kind:"alive"}))]),f=m.kind==="exit"?m.result:void 0;return {exitCode:c.healthy?0:1,stdout:String(f?.stdout??""),stderr:String(f?.stderr??""),healthStatus:c}}async function he(e,r,t){let n=process.argv[1];if(!n)return {exitCode:1,stdout:"",stderr:"RapidKit entrypoint is unavailable for nested workspace-run execution."};try{let o=await execa(process.execPath,[n,...e],{cwd:r,reject:false,timeout:t,env:{...process.env,RAPIDKIT_WORKSPACE_RUN_CHILD:"1"}});return {exitCode:Number(o.exitCode??1),stdout:o.stdout,stderr:o.stderr}}catch(o){return {exitCode:typeof o=="object"&&o!==null&&"timedOut"in o&&!!o.timedOut?124:1,stdout:typeof o=="object"&&o!==null&&"stdout"in o?String(o.stdout??""):"",stderr:typeof o=="object"&&o!==null&&"stderr"in o?String(o.stderr??""):o instanceof Error?o.message:String(o)}}}function At(e){return e==="node"||e==="go"||e==="java"||e==="python"||e==="dotnet"||e==="rust"||e==="php"}function Ft(){return process.env.VITEST==="true"||process.env.VITEST==="1"||process.env.NODE_ENV==="test"}function Ot(e,r=8){if(e.length<=r)return e.join(`
2
2
  `);let t=3;return [...e.slice(0,t),...e.slice(-(r-t))].join(`
3
3
  `)}function Dt(e){let r=/(?:\bnot found\b|\bno such\b|\bmissing\b|\bfailed\b|\berror\b|\bexception\b|\bcannot\b|\bdenied\b|\btimeout\b|\btimed out\b|\benoent\b|\beacces\b|\beperm\b)/i;return [...e].reverse().find(t=>r.test(t))??e.at(-1)}async function Tt(e){let r=process.cwd();try{process.chdir(e);let{handleInitCommand:t}=await import('./index.js');return {exitCode:await t(["init"]),stdout:"",stderr:""}}finally{process.chdir(r);}}async function Qe(e){let r=i=>{let l=g(i);return l==="node"||l==="bun"?"node":l==="python"?"python":l==="go"?"go":l==="java"?"java":l==="php"?"php":l==="ruby"?"ruby":l==="rust"?"rust":l==="dotnet"?"dotnet":l==="elixir"?"elixir":l==="clojure"||l==="scala"||l==="kotlin"?"jvm-generic":ze(e)},t=i=>{if(!i)return;let l=f(i);if(new Set(["fastapi","django","flask","nestjs","express","fastify","koa","gofiber","gogin","echo","springboot","laravel","symfony","rails","sinatra","dotnet","actix","axum","rocket","phoenix"]).has(l))return l},n=q$1(e),o=n?.detection??m(e,n?.projectJson??null),s=n?.contextJson,u=r(o.runtime),c=t(o.key),m$1={},f$1=new Set(["init","test","build","start"]);if(s?.commands&&typeof s.commands=="object")for(let[i,l]of Object.entries(s.commands))typeof l=="string"&&f$1.has(i)&&(m$1[i]=l);let d;if(s?.commandEnvironments&&typeof s.commandEnvironments=="object"){let i=s.commandEnvironments;d={dev:typeof i.dev=="string"?i.dev:void 0,staging:typeof i.staging=="string"?i.staging:void 0,prod:typeof i.prod=="string"?i.prod:void 0,default:typeof i.default=="string"?i.default:void 0};}return {runtime:u,framework:c,commandOverrides:Object.keys(m$1).length>0?m$1:void 0,environmentCommandVariants:d,environment:typeof s?.environment=="string"?s.environment:void 0}}async function Ze(e,r,t,n,o,s,u){let c=!o?.[r]&&At(t),m;if(o&&o[r]?m=o[r]:c?m=`rapidkit ${r}`:m=fe({projectPath:e,runtime:t,framework:n,stage:r}),!m)return {exitCode:127,command:`<stage not supported for ${t}>`,message:`No stage command found for runtime '${t}' and framework '${n||"unknown"}'`,errorCategory:"runtime"};let f=Ve(m,s,u);if(!f)return {exitCode:127,command:m,message:"Failed to resolve stage command",errorCategory:"runtime"};let d=fe({projectPath:e,runtime:t,framework:n,stage:r});if(c){if(d){let v=c?await ht(e,t,d):await se(d,e);if(!v.valid)return {exitCode:127,command:f,message:v.reason||"Command not available",errorCategory:"setup"}}}else {let v=await se(f,e);if(!v.valid)return {exitCode:127,command:f,message:v.reason||"Command not available",errorCategory:"setup"}}let i=0,l="",h="",k,S,g=Et(r),y=Date.now();try{let v=r==="start"?await Pt({projectPath:e,finalCommand:f,useRapidkitWrapper:c,runtime:t,framework:n,timeoutMs:g}):c?r==="init"&&Ft()?await Tt(e):await he([r],e,g):await(async()=>{let P=jt(f);return P?execa(P.file,P.args,{cwd:e,reject:false,timeout:g,forceKillAfterDelay:1e3}):execa(f,[],{cwd:e,reject:false,shell:true,timeout:g,forceKillAfterDelay:1e3})})();if(i=Number(v.exitCode??0),l=v.stdout,h=v.stderr,S=r==="start"?v.healthStatus:void 0,i!==0){let P=`${l}
4
4
  ${h}`,G=Date.now()-y;k=i===124||ge(P)==="timeout"||i===143&&G>=Math.floor(g*.8)?"timeout":ge(P);}}catch(v){let P=typeof v=="object"&&v!==null&&"timedOut"in v&&!!v.timedOut;return {exitCode:P?124:1,command:f,message:P?`Stage timed out after ${g}ms`:v instanceof Error?v.message:"Command execution failed",errorCategory:P?"timeout":"runtime"}}let j=`${l}
@@ -1 +1 @@
1
- import {h as h$1}from'./chunk-6UNATTB7.js';import o from'path';var h=h$1.artifactRemediationPlan.schemaVersion;function c(t){return t.replace(/\\/g,"/")}function P(t,r){return t.trim().toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^[-_.]+|[-_.]+$/g,"").slice(0,80)||r}function p(t,r){let e=c(o.relative(t,r));return !e||e.startsWith("..")?true:e.split("/").filter(Boolean).some(a=>a==="..")}function A(t){let r=c(o.relative(t.workspacePath,t.projectPath)),e=p(t.workspacePath,t.projectPath),a=P(t.projectName,o.basename(t.projectPath)),n=e?`external/${a}`:r||a;return {relativePath:r||n,contractRelativePath:n,isExternal:e}}export{h as a,A as b};
1
+ import {h as h$1}from'./chunk-ZGHJIQXL.js';import o from'path';var h=h$1.artifactRemediationPlan.schemaVersion;function c(t){return t.replace(/\\/g,"/")}function P(t,r){return t.trim().toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^[-_.]+|[-_.]+$/g,"").slice(0,80)||r}function p(t,r){let e=c(o.relative(t,r));return !e||e.startsWith("..")?true:e.split("/").filter(Boolean).some(a=>a==="..")}function A(t){let r=c(o.relative(t.workspacePath,t.projectPath)),e=p(t.workspacePath,t.projectPath),a=P(t.projectName,o.basename(t.projectPath)),n=e?`external/${a}`:r||a;return {relativePath:r||n,contractRelativePath:n,isExternal:e}}export{h as a,A as b};
@@ -1 +1 @@
1
- import {b,c,d as d$1}from'./chunk-2PACEMNE.js';import {c as c$2}from'./chunk-5XGR3LRI.js';import {a as a$3}from'./chunk-X7FYEKLI.js';import {c as c$1,d as d$5}from'./chunk-3NM3JAZW.js';import {a as a$1,b as b$1}from'./chunk-PYCJWW4B.js';import {p,a,o,g,d as d$4,f as f$1}from'./chunk-VA5VSOBL.js';import {q,m as m$1,d as d$6}from'./chunk-PJPS7CNH.js';import {d as d$3}from'./chunk-7FF5EOIO.js';import {d as d$2,e as e$1}from'./chunk-GAYK3WGV.js';import {a as a$2}from'./chunk-AFIFZTOY.js';import {d}from'./chunk-EWZZUQBR.js';import {f,e,i,g as g$1,h}from'./chunk-6UNATTB7.js';import m from'path';import v from'fs-extra';var fe="rapidkit-blocker-resolution-v1";function pe(e){let t=e.blockers.map(s=>s.trim()).filter(Boolean).slice(0,12),r=e.stderrTail?.trim().slice(-400)??"";return d$6({blockers:t,exitCode:e.exitCode??null,stderrTail:r})}function we(e){let t=e.trim().toLowerCase();return t?t.includes("missing evidence")||t.includes(": missing")||t.includes("artifact missing")||t.includes("not found on disk")?"artifact-missing":t.includes("policy.")||t.includes("contract")?"config-fixable":t.includes("impact")||t.includes("untracked")||t.includes("grounding")?"semantic-attention":t.includes("failed")||t.includes("blocked")||t.includes(": fail")?"command-failed-repeat":"config-fixable":"unresolvable-without-human"}function me(e){let t=we(e.reason),r=pe({blockers:[e.reason]}),s=t==="artifact-missing"?[{actionKind:"run-once",detail:e.sourceCommand?`Run the source command once: ${e.sourceCommand}`:"Run the mapped workspace intelligence command once to generate the missing artifact.",...e.sourceCommand?{}:{studioActionId:"run-analyze"}}]:t==="semantic-attention"?[{actionKind:"commit-files",detail:"Review workspace-level grounding files (AGENTS.md, agent-sync outputs) and commit or refresh the impact baseline."},{actionKind:"refresh-baseline",detail:"Refresh snapshot + diff + impact before re-running verify."}]:[{actionKind:"edit-file",detail:"Apply the smallest safe file or policy fix for this blocker before re-running verification.",studioActionId:"fix-lens"}];return {schemaVersion:fe,blockerId:e.blockerId,sourceCommand:e.sourceCommand,sourceArtifact:e.sourceArtifact,resolutionClass:t,blockerSignature:r,commandRetryHint:t==="artifact-missing"?e.sourceCommand?`Run the source command once: ${e.sourceCommand}, then verify.`:"Run the source command once, then verify.":"Do not re-run the same failing command; fix the source issue first, then verify.",fixHints:s,verifyCommand:e.verifyCommand,verifyArtifact:e.verifyArtifact}}function Re(e){let t=e.toLowerCase();return t.includes("stale")||t.includes("missing evidence")||t.includes("no projects")||t.includes("projects.empty")||t.includes("projects discovered")||t.includes("projects.missing")||t.includes("not yet run")||t.includes("doctor-last-run")||t.includes("doctor-project-last-run")||t.includes("doctor-remediation-plan-last-run")||t.includes("doctor-fix-result-last-run")||t.includes("pipeline-last-run")||t.includes("release-readiness")||t.includes("analyze-last-run")||t.includes("analyze reported")||t.includes("analyze verdict")||t.includes("analyze needs attention")||t.includes("toolchain.lock")||t.includes("not pinned")||t.includes("readiness:")||t.includes("env:")||t.includes("workspace-run-last")||t.includes("pre-project")||t.includes("before adding projects")||t.includes("workspace.projects.missing")||t.includes("no backend projects")||t.includes("index.json")||t.includes("workspace-intelligence-history")||t.includes("validation warning")||t.includes("workspace model validation")||t.includes("workspace.marker")||t.includes("no project roots")||t.includes("no infrastructure services")||t.includes("infra/overrides")||t.includes("infra dependencies")||t.includes("contract verify")||t.includes("contract inspect")||t.includes("publish verify evidence")}function Ce(e){return e.length===0||e.every(t=>Re(t))}function ge(e){return e.projectCount>0||e.policyErrorCount>0?{verdict:e.verdict,exitCode:e.exitCode}:e.verdict==="blocked"&&Ce(e.blockingReasons)?{verdict:"needs-attention",exitCode:1}:{verdict:e.verdict,exitCode:e.exitCode}}function tt(e,t){let r=t&&t!=="ready"?` (${t.replace(/-/g," ")})`:"";return e===0?`Workspace scaffold ready${r} \u2014 add your first project to continue.`:`Workspace scaffold${r}: ${e} pre-project signal(s) \u2014 add your first project to continue.`}var ye=f.verify,G=e.verify;function Ae(e,t){return m.isAbsolute(t)?t:m.join(e,t)}async function ke(e){let t=await v.readJson(e);if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`Workspace impact input is not a JSON object: ${e}`);let r=t;if(r.schemaVersion!==f$1)throw new Error(`Unsupported workspace impact schema: ${String(r.schemaVersion)}`);a$2(t,"contracts/workspace-intelligence/workspace-impact.v1.json",`Workspace impact ${e}`);let s=r;a$2(s.diff,"contracts/workspace-intelligence/workspace-model-diff.v1.json",`Embedded workspace diff in ${e}`);let i=[];s.summary.affectedProjects!==s.affectedProjects.length&&i.push("summary.affectedProjects does not match affectedProjects.length"),s.summary.workspaceItems!==s.workspaceImpact.length&&i.push("summary.workspaceItems does not match workspaceImpact.length"),s.summary.recommendedCommands!==s.verificationPlan.length&&i.push("summary.recommendedCommands does not match verificationPlan.length"),s.summary.blastRadius.directlyAffected!==s.affectedProjects.length&&i.push("blastRadius.directlyAffected does not match affectedProjects.length"),s.summary.blastRadius.transitivelyAffected!==s.transitiveImpact.length&&i.push("blastRadius.transitivelyAffected does not match transitiveImpact.length");let o=s.transitiveImpact.reduce((u,d)=>Math.max(u,d.distance??0),0);s.summary.blastRadius.maxDistance!==o&&i.push("blastRadius.maxDistance does not match transitive impact distances");let k=m$1(s.diff.currentModel)?.edges.length??0;if(s.summary.blastRadius.graphEdges!==k&&i.push("blastRadius.graphEdges does not match the embedded model graph"),s.summary.changed!==s.diff.summary.changed&&i.push("summary.changed does not match embedded diff summary"),s.fromRef!==s.diff.fromRef&&i.push("fromRef does not match embedded diff fromRef"),s.workspace.name!==s.diff.currentModel.workspace.name&&i.push("workspace.name does not match the embedded model"),s.diff.toHash!==d(s.diff.currentModel)&&i.push("embedded diff current-model hash does not match toHash"),i.length>0)throw new Error(`Workspace impact semantic integrity failed: ${i.join("; ")} (${e})`);return s}function Ee(e){let t=new Set,r=[];for(let s of e){let i=`${s.scope}:${s.project??""}:${s.display}`;t.has(i)||(t.add(i),r.push(s));}return r}function Se(e,t){if(!e||e==="workspace")return true;let r=(e.startsWith("project:")?e.slice(8):e).trim().toLowerCase();return t.scope==="workspace"?true:(t.project??"").trim().toLowerCase()===r}function We(e$1,t){if(e$1.id==="workspace.doctor")return m.join(t,e.doctor);if(e$1.id==="workspace.contract.verify")return m.join(t,e.contractVerify);if(e$1.id==="workspace.readiness")return m.join(t,e.readiness);if(e$1.id==="workspace.analyze")return m.join(t,".workspai","reports","analyze-last-run.json");if(e$1.id==="workspace.pipeline")return m.join(t,".workspai","reports","pipeline-last-run.json");if(e$1.id==="workspace.doctor-fix")return m.join(t,".workspai","reports","doctor-fix-result-last-run.json");if(e$1.id.startsWith("project.")&&e$1.id.includes("."))return m.join(t,".workspai","reports","workspace-run-last.json")}function C(e){return !e||typeof e!="object"||Array.isArray(e)?null:e}function je(e){if(!c$1(e,"workspace"))return {status:"fail",message:"Doctor evidence contract is missing or unsupported."};try{d$5(e);}catch(s){return {status:"fail",message:`Doctor evidence semantic validation failed: ${s instanceof Error?s.message:String(s)}`}}let t=a$3(e);return t.hasSystemErrors||t.blockingFindings>0?{status:"fail",message:`Doctor evidence reports ${t.blockingFindings} canonical blocking finding(s).`}:t.advisoryFindings+t.unknownFindings+t.contradictionCount+t.missingDiagnosisProjects>0||t.staleEvidence||t.unknownFreshness||t.minimumDiagnosisCompleteness<100?{status:"warn",message:`Doctor evidence needs attention (${t.advisoryFindings} advisory, ${t.unknownFindings} unknown, ${t.contradictionCount} contradictory; ${t.minimumDiagnosisCompleteness}% complete).`}:{status:"pass",message:"Canonical Doctor evidence is complete, fresh, and healthy."}}function xe(e){let t=typeof e.overallStatus=="string"?e.overallStatus:"unknown";return t==="fail"?{status:"fail",message:"Release readiness evidence reports blocking failures."}:t==="warn"?{status:"warn",message:"Release readiness evidence reports warnings."}:t==="pass"?{status:"pass",message:"Release readiness evidence passed."}:{status:"warn",message:`Release readiness evidence status is ${t}.`}}function Pe(e){let t=typeof e.status=="string"?e.status:"unknown";return t==="failed"||t==="fail"?{status:"fail",message:"Workspace contract verify evidence failed."}:t==="passed"||t==="pass"?{status:"pass",message:"Workspace contract verify evidence passed."}:{status:"warn",message:`Workspace contract verify evidence status is ${t}.`}}function Ie(e){let t=C(e.summary),r=typeof t?.verdict=="string"?t.verdict:void 0;return r==="blocked"?{status:"fail",message:"Analyze evidence reports blocking findings."}:r==="needs-attention"?{status:"warn",message:"Analyze evidence reports warnings."}:{status:"pass",message:"Analyze evidence is ready."}}function Ve(e){let t=e.schemaVersion===h.doctorFixResult.schemaVersion?e:e.fixResult;if(!t||typeof t!="object"||Array.isArray(t))return {status:"skipped",message:"Doctor fix result not present; run doctor workspace --fix --json to record fixes."};let r=t,s=Array.isArray(r.remainingBlockers)?r.remainingBlockers:[];if(s.length>0)return {status:"fail",message:`Doctor fix result reports ${s.length} remaining blocker(s).`};let i=Array.isArray(r.appliedFixes)?r.appliedFixes:[];return i.length===0?{status:"pass",message:"Doctor fix result recorded with no remaining blockers."}:{status:"pass",message:`Doctor fix result recorded ${i.length} applied fix(es) with no remaining blockers.`}}async function Fe(e,t){let r=await d$2(e,i.doctorRemediationPlan);if(!r)return false;try{let s=C(await v.readJson(r));if(!s||(Array.isArray(s.steps)?s.steps:[]).length>0)return false;let o=typeof s.generatedAt=="string"?s.generatedAt:void 0;if(!o||!t)return true;let k=Date.parse(o),u=Date.parse(t);return !Number.isFinite(k)||!Number.isFinite(u)?true:k>=u}catch{return false}}function $e(e){return e.id.endsWith(".init")?"init":e.id.endsWith(".test")?"test":e.id.endsWith(".build")?"build":e.id.endsWith(".start")?"start":null}function Oe(e){let t=C(e.summary),r=typeof t?.verdict=="string"?t.verdict:void 0;return r==="blocked"?{status:"fail",message:"Pipeline evidence is blocked."}:r==="needs-attention"?{status:"warn",message:"Pipeline evidence needs attention."}:r==="ready"?{status:"pass",message:"Pipeline evidence is ready."}:{status:"warn",message:"Pipeline evidence status is unknown."}}function De(e,t,r){let s=$e(t),i=c$2(e,s??void 0);if(!i)return {status:"missing",message:"Workspace run evidence is missing or unreadable."};let o=i.stage;if(s&&o!==s)return {status:"missing",message:`Workspace run evidence is for stage "${o}", expected "${s}".`};let k=Array.isArray(i.projects)?i.projects:[],u=t.project?.toLowerCase();if(!u)return {status:"missing",message:"Project-scoped workspace run evidence is missing a project identifier."};let d=k.find(g=>{let c=C(g);if(!c)return false;let n=typeof c.projectName=="string"?c.projectName.toLowerCase():"",a=["projectPath","relativePath","path"].map(f=>c[f]).filter(f=>typeof f=="string"&&f.trim().length>0).map(f=>f.replace(/\\/g,"/").toLowerCase());return n===u||a.some(f=>f.endsWith(`/${u}`)||f===u)});if(d){let g=R(i.generatedAt,r,`Workspace run evidence for ${t.project??t.id}`);if(g)return {status:"fail",message:g};let c=C(d),n=typeof c?.status=="string"?c.status:"unknown";return n==="failed"?{status:"fail",message:`Workspace run evidence failed for ${t.project}.`}:n==="passed"?{status:"pass",message:`Workspace run evidence passed for ${t.project}.`}:n==="skipped"?{status:"warn",message:`Workspace run evidence skipped for ${t.project}.`}:{status:"warn",message:`Workspace run evidence status is ${n} for ${t.project}.`}}return {status:"missing",message:`Workspace run evidence does not include project ${t.project}.`}}function R(e,t,r){if(!t)return null;if(typeof e!="string"||e.trim().length===0)return `${r} is stale: missing generatedAt timestamp (required after impact ${t}).`;let s=Date.parse(e),i=Date.parse(t);return Number.isFinite(s)?Number.isFinite(i)&&s<i?`${r} is stale: generated at ${e}, before impact ${t}.`:null:`${r} is stale: invalid generatedAt timestamp (required after impact ${t}).`}function Be(e){if(e.id==="workspace.doctor")return g$1.doctor;if(e.id==="workspace.readiness")return g$1.readiness;if(e.id==="workspace.contract.verify")return g$1.contractVerify;if(e.id==="workspace.analyze")return g$1.analyze;if(e.id==="workspace.pipeline")return "contracts/pipeline-last-run.v1.json"}async function _e(e,t,r,s){let i=We(e,t),o=i?m.relative(t,i).split(m.sep).join("/"):void 0;if(e.id==="workspace.contract.verify"&&!r)return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"skipped",required:e.required,message:"Workspace contract is not present; contract verify skipped."};let k=i?await d$2(t,o??""):null;if(!i||!k)return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"missing",required:e.required,evidencePath:o,message:o?`Missing evidence report: ${o}`:"No evidence mapping exists for this command."};let u;try{u=await v.readJson(k);}catch(n){return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"fail",required:e.required,evidencePath:o,message:`Evidence report is unreadable JSON: ${n instanceof Error?n.message:String(n)}`}}let d=C(u);if(!d)return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"fail",required:e.required,evidencePath:o,message:"Evidence report is not a JSON object."};let g=Be(e);if(g)try{a$2(d,g,`${e.label} evidence`);}catch(n){return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"fail",required:e.required,evidencePath:o,message:`Evidence report is invalid: ${n instanceof Error?n.message:String(n)}`}}let c;if(e.id==="workspace.doctor"){let n=R(d.generatedAt,s,"Doctor evidence");n?c={status:"fail",message:n}:c=je(d);}else if(e.id==="workspace.readiness"){let n=R(d.generatedAt,s,"Release readiness evidence");n?c={status:"fail",message:n}:c=xe(d);}else if(e.id==="workspace.contract.verify"){let n=R(d.generatedAt,s,"Workspace contract verify evidence");n?c={status:"fail",message:n}:c=Pe(d);}else if(e.id==="workspace.analyze"){let n=R(d.generatedAt,s,"Analyze evidence");n?c={status:"fail",message:n}:c=Ie(d);}else if(e.id==="workspace.pipeline"){let n=R(d.generatedAt,s,"Pipeline evidence");n?c={status:"fail",message:n}:c=Oe(d);}else if(e.id==="workspace.doctor-fix"){let n=d.schemaVersion===h.doctorFixResult.schemaVersion?d:d.fixResult,a=C(n),f=typeof a?.generatedAt=="string"?a.generatedAt:void 0,y=R(f,s,"Doctor fix result");y?c={status:"fail",message:y}:await Fe(t,f)?c={status:"skipped",message:"No current doctor remediation steps are pending."}:c=Ve(d);}else if(e.id.startsWith("project."))c=De(d,e,s);else {let n=R(d.generatedAt,s,"Evidence report");n?c={status:"fail",message:n}:c={status:"pass",message:"Evidence report is present."};}return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:c.status,required:e.required,evidencePath:o,message:c.message}}function Ne(e,t={blockingReasons:[],needsAttention:false}){let r=e.filter(n=>n.status==="pass").length,s=e.filter(n=>n.status==="warn").length,i=e.filter(n=>n.status==="fail").length,o=e.filter(n=>n.status==="missing").length,k=e.filter(n=>n.status==="skipped").length,u=e.filter(n=>n.required&&(n.status==="fail"||n.status==="missing")).map(n=>`${n.id}: ${n.message}`),d=e.filter(n=>n.required&&n.status==="missing").length,g="ready",c=0;return u.length>0||t.blockingReasons.length>0?(g="blocked",c=2):(s>0||e.some(n=>!n.required&&n.status==="fail")||d>0||t.needsAttention)&&(g="needs-attention",c=1),{verdict:g,exitCode:c,stepsPassed:r,stepsWarn:s,stepsFailed:i,stepsMissing:o,stepsSkipped:k}}function He(e,t){let r=x(e.affectedProjects.map(a=>a.project?.name).filter(a=>typeof a=="string")),s=new Set(r.map(a=>a.toLowerCase())),i=x(e.transitiveImpact.map(a=>a.project?.name).filter(a=>typeof a=="string").filter(a=>!s.has(a.toLowerCase()))),o=new Map;for(let a of t){if(a.scope!=="project"||!a.project)continue;let f=a.project.toLowerCase(),y=o.get(f)??[];y.push(a),o.set(f,y);}let k=[],u=[],d=[],g=[],c=false,n=(a,f)=>{let y=o.get(a.toLowerCase())??[];if(y.length===0){d.push(a);return}let P=y.filter(p=>p.status==="fail"),b=P.filter(p=>p.required),I=y.filter(p=>p.status==="missing"),E=I.filter(p=>p.required),V=y.some(p=>p.status==="pass"||p.status==="warn");if(b.length>0){u.push(a),g.push(`graph.subgraph.${a}: ${f} has failed verification evidence (${b.map(p=>p.id).join(", ")}).`);return}if(P.length>0){u.push(a),c=true;return}if(E.length>0){u.push(a),g.push(`graph.subgraph.${a}: ${f} has missing required verification evidence (${E.map(p=>p.id).join(", ")}).`);return}if(I.length>0){u.push(a),c=true;return}if(V){k.push(a);return}d.push(a);};for(let a of r)n(a,"directly-changed");for(let a of i)n(a,"transitive dependent");return {subgraph:{totalProjects:r.length+i.length,directlyChanged:r,transitiveDependents:i,covered:x(k),uncovered:x(u),unverifiable:x(d)},blockingReasons:g,needsAttention:c}}function x(e){return [...new Set(e)].sort((t,r)=>t.localeCompare(r))}async function Me(e$1){let t=m.resolve(e$1.workspacePath);if(e$1.fromImpactPath){let o=Ae(t,e$1.fromImpactPath);return {impact:await ke(o),fromImpactRef:m.relative(t,o).split(m.sep).join("/"),impactFromDisk:true}}let r=m.join(t,g);if(await v.pathExists(r))return {impact:await ke(r),fromImpactRef:g,impactFromDisk:true};let s=m.join(t,d$4);if(await v.pathExists(s))return {impact:await p({workspacePath:t,fromPath:d$4,scope:e$1.scope,includeAbsolutePaths:e$1.includeAbsolutePaths,includeEvidence:e$1.includeEvidence,observableScanDepth:e$1.observableScanDepth,now:e$1.now}),fromImpactRef:d$4,impactFromDisk:false};let i=await q({workspacePath:t,includeAbsolutePaths:e$1.includeAbsolutePaths,includeEvidence:e$1.includeEvidence,observableScanDepth:e$1.observableScanDepth,now:e$1.now});return {impact:{schemaVersion:f$1,generatedAt:(e$1.now??new Date).toISOString(),fromRef:"baseline",diffRef:e.diff,workspace:{name:i.workspace.name,profile:i.workspace.profile,type:i.workspace.type},summary:{changed:false,risk:"none",affectedProjects:0,workspaceItems:0,recommendedCommands:0,blastRadius:{directlyAffected:0,transitivelyAffected:0,maxDistance:0,graphEdges:m$1(i)?.edges.length??0}},affectedProjects:[],transitiveImpact:[],criticalPathHotspots:[],workspaceImpact:[],verificationPlan:[],agentBrief:{headline:"Baseline workspace verify run.",bullets:["No impact report or snapshot was available; baseline gates were evaluated."],unsafeAssumptions:["Do not claim runtime verification passed unless evidence exists."]},diff:{schemaVersion:f.diff,generatedAt:(e$1.now??new Date).toISOString(),fromRef:"baseline",toRef:e.model,fromHash:"baseline",toHash:"baseline",summary:{changed:false,addedProjects:0,removedProjects:0,changedProjects:0,workspaceChanges:0,validationChanges:0,gitChangedFiles:0},git:{available:false,dirty:false,changedFiles:0,untrackedFiles:0,deletedFiles:0},changes:[],currentModel:i}},impactFromDisk:false}}function Te(e,t){if(t)return e.generatedAt}async function bt(e){let t=m.resolve(e.workspacePath),{impact:r,fromImpactRef:s,impactFromDisk:i}=await Me(e),o$1=r.diff.currentModel,k=i?await q({workspacePath:t,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,observableScanDepth:e.observableScanDepth,now:e.now}):o$1,u=[];if(i){let l=await p({workspacePath:t,fromPath:r.diff.fromRef,diff:r.diff,scope:e.scope,now:e.now}),W=[r.affectedProjects,r.transitiveImpact,r.verificationPlan],A=[l.affectedProjects,l.transitiveImpact,l.verificationPlan];JSON.stringify(W)!==JSON.stringify(A)&&u.push("workspace.impact: Persisted impact semantics do not match the impact re-derived from the embedded diff. Regenerate diff and impact.");}i&&d(k)!==r.diff.toHash&&u.push("workspace.impact: Impact evidence is stale because the current workspace model no longer matches the embedded model. Regenerate diff and impact.");let d$2=r.diff.git;if(i&&d$2?.available){let l=a(t,{ref:d$2.ref}),W=r.diff.changes.filter(h=>h.type.startsWith("git.")).map(h=>`${h.type}:${h.target.replace(/^git:/,"")}`).sort(),A=[...l.changedFiles.map(h=>`git.file.changed:${h}`),...l.untrackedFiles.map(h=>`git.untracked:${h}`),...l.deletedFiles.map(h=>`git.deleted:${h}`)].sort();(!l.available||l.commit!==d$2.commit||JSON.stringify(A)!==JSON.stringify(W))&&u.push("workspace.impact: Impact evidence is stale because Git changes no longer match the diff observation. Regenerate diff and impact.");}let g=Te(r,i),c$1=Ee([...o(),...r.verificationPlan]).filter(l=>Se(e.scope,l)),n=[];for(let l of c$1)n.push(await _e(l,t,o$1.contracts.exists===true,g));let a$2=He(r,n),f=a$1(m$1(o$1)??{nodes:[],edges:[]}),y=b(o$1),P=await Ke(t),b$2=c(y,P?.freshness?.projectHashes),I={verdict:b$2.verdict,baseline:b$2.baseline,changed:b$2.changed,added:b$2.added,removed:b$2.removed,projectHashes:d$1(y)},E=b$1(f),V=o$1.policies?.mode??"warn",p$1=await Le(o$1,t),B=qe(V,p$1),S=Ne(n,{blockingReasons:[...a$2.blockingReasons,...E,...B.blockingReasons,...u],needsAttention:a$2.needsAttention||B.needsAttention}),he=n.filter(l=>l.status==="missing"&&l.evidencePath).map(l=>l.evidencePath),_=[...n.filter(l=>l.required&&(l.status==="fail"||l.status==="missing")).map(l=>`${l.id}: ${l.message}`),...a$2.blockingReasons,...E,...B.blockingReasons,...u],ve=p$1.filter(l=>l.severity==="error").length,be=o$1.summary?.projectCount??o$1.projects.length,U=ge({projectCount:be,verdict:S.verdict,exitCode:S.exitCode,blockingReasons:_,policyErrorCount:ve});S.verdict=U.verdict,S.exitCode=U.exitCode;let Y=Array.from(new Set(_.map(l=>l.trim()).filter(Boolean))).slice(0,12).map((l,W)=>{let A=n.find(h=>l.startsWith(`${h.id}:`));return me({reason:l,blockerId:`blocker-${W+1}`,sourceCommand:A?.command.display,sourceArtifact:A?.evidencePath,verifyCommand:"npx workspai workspace verify --from-impact .workspai/reports/workspace-impact-last-run.json --json",verifyArtifact:G})});return {schemaVersion:ye,generatedAt:(e.now??new Date).toISOString(),workspacePath:t,mode:"evidence",fromImpactRef:s,scope:e.scope,impact:{changed:r.summary.changed,risk:r.summary.risk,affectedProjects:r.summary.affectedProjects,recommendedCommands:r.summary.recommendedCommands},summary:S,steps:n,missingEvidence:he,blockingReasons:_,...Y.length>0?{resolutionHints:Y}:{},verificationPlan:c$1,affectedSubgraph:a$2.subgraph,graphIntegrity:f,freshness:I,policyMode:V,policyViolations:p$1}}async function Le(e$1,t){let r=[];for(let i of e$1.validation?.issues??[])r.push({source:"model",severity:i.severity,code:i.code,message:i.message,target:i.target});let s=await d$2(t,e.contractVerify);try{if(s&&await v.pathExists(s)){let i=await v.readJson(s);if(Array.isArray(i.violations))for(let o of i.violations)typeof o=="string"&&o.trim().length>0&&r.push({source:"contract",severity:"error",code:"contract.violation",message:o});}}catch{}return r.sort((i,o)=>i.source!==o.source?i.source.localeCompare(o.source):i.code!==o.code?i.code.localeCompare(o.code):i.message.localeCompare(o.message))}function qe(e,t){let r=t.filter(s=>s.severity==="error");return e==="enforce"&&r.length>0?{blockingReasons:r.map(s=>`policy.${s.code}: ${s.message}`),needsAttention:false}:{blockingReasons:[],needsAttention:r.length>0}}async function Ke(e){let t=m.join(e,G);try{if(!await v.pathExists(t))return null;let r=await v.readJson(t);return r&&r.schemaVersion===ye?r:null}catch{return null}}async function wt(e,t){return e$1(t,G,d$3(e))}function ze(e,t){let r=t?.strict?"strict":"default",s=[];if(e.summary.verdict==="blocked")return s.push(...e.blockingReasons),s.length===0&&s.push("verify verdict is blocked."),{passed:false,mode:r,exitCode:2,reasons:s};if(r==="strict"){if(e.summary.verdict!=="ready"&&s.push(`verify verdict is ${e.summary.verdict} (strict requires ready).`),e.freshness.verdict==="stale"){let i=[...e.freshness.changed,...e.freshness.added].slice(0,5);s.push(`freshness is stale${i.length>0?`: ${i.join(", ")}`:""} (strict requires fresh).`);}if(s.length>0)return {passed:false,mode:r,exitCode:1,reasons:s}}return {passed:true,mode:r,exitCode:0,reasons:s}}function Rt(e,t){return ze(e,t).exitCode}export{fe as a,tt as b,ye as c,G as d,He as e,bt as f,wt as g,ze as h,Rt as i};
1
+ import {b,c,d as d$1}from'./chunk-CZVT7T2X.js';import {c as c$2}from'./chunk-OCNPOYMA.js';import {a as a$3}from'./chunk-X7FYEKLI.js';import {c as c$1,d as d$5}from'./chunk-BUYLM6QV.js';import {a as a$1,b as b$1}from'./chunk-PYCJWW4B.js';import {p,a,o,g,d as d$4,f as f$1}from'./chunk-BRYJTW6S.js';import {q,m as m$1,d as d$6}from'./chunk-TP7VKEUF.js';import {d as d$3}from'./chunk-EHCKITR4.js';import {d as d$2,e as e$1}from'./chunk-XDPTAV2T.js';import {a as a$2}from'./chunk-AFIFZTOY.js';import {d}from'./chunk-EWZZUQBR.js';import {f,e,i,g as g$1,h}from'./chunk-ZGHJIQXL.js';import m from'path';import v from'fs-extra';var fe="rapidkit-blocker-resolution-v1";function pe(e){let t=e.blockers.map(s=>s.trim()).filter(Boolean).slice(0,12),r=e.stderrTail?.trim().slice(-400)??"";return d$6({blockers:t,exitCode:e.exitCode??null,stderrTail:r})}function we(e){let t=e.trim().toLowerCase();return t?t.includes("missing evidence")||t.includes(": missing")||t.includes("artifact missing")||t.includes("not found on disk")?"artifact-missing":t.includes("policy.")||t.includes("contract")?"config-fixable":t.includes("impact")||t.includes("untracked")||t.includes("grounding")?"semantic-attention":t.includes("failed")||t.includes("blocked")||t.includes(": fail")?"command-failed-repeat":"config-fixable":"unresolvable-without-human"}function me(e){let t=we(e.reason),r=pe({blockers:[e.reason]}),s=t==="artifact-missing"?[{actionKind:"run-once",detail:e.sourceCommand?`Run the source command once: ${e.sourceCommand}`:"Run the mapped workspace intelligence command once to generate the missing artifact.",...e.sourceCommand?{}:{studioActionId:"run-analyze"}}]:t==="semantic-attention"?[{actionKind:"commit-files",detail:"Review workspace-level grounding files (AGENTS.md, agent-sync outputs) and commit or refresh the impact baseline."},{actionKind:"refresh-baseline",detail:"Refresh snapshot + diff + impact before re-running verify."}]:[{actionKind:"edit-file",detail:"Apply the smallest safe file or policy fix for this blocker before re-running verification.",studioActionId:"fix-lens"}];return {schemaVersion:fe,blockerId:e.blockerId,sourceCommand:e.sourceCommand,sourceArtifact:e.sourceArtifact,resolutionClass:t,blockerSignature:r,commandRetryHint:t==="artifact-missing"?e.sourceCommand?`Run the source command once: ${e.sourceCommand}, then verify.`:"Run the source command once, then verify.":"Do not re-run the same failing command; fix the source issue first, then verify.",fixHints:s,verifyCommand:e.verifyCommand,verifyArtifact:e.verifyArtifact}}function Re(e){let t=e.toLowerCase();return t.includes("stale")||t.includes("missing evidence")||t.includes("no projects")||t.includes("projects.empty")||t.includes("projects discovered")||t.includes("projects.missing")||t.includes("not yet run")||t.includes("doctor-last-run")||t.includes("doctor-project-last-run")||t.includes("doctor-remediation-plan-last-run")||t.includes("doctor-fix-result-last-run")||t.includes("pipeline-last-run")||t.includes("release-readiness")||t.includes("analyze-last-run")||t.includes("analyze reported")||t.includes("analyze verdict")||t.includes("analyze needs attention")||t.includes("toolchain.lock")||t.includes("not pinned")||t.includes("readiness:")||t.includes("env:")||t.includes("workspace-run-last")||t.includes("pre-project")||t.includes("before adding projects")||t.includes("workspace.projects.missing")||t.includes("no backend projects")||t.includes("index.json")||t.includes("workspace-intelligence-history")||t.includes("validation warning")||t.includes("workspace model validation")||t.includes("workspace.marker")||t.includes("no project roots")||t.includes("no infrastructure services")||t.includes("infra/overrides")||t.includes("infra dependencies")||t.includes("contract verify")||t.includes("contract inspect")||t.includes("publish verify evidence")}function Ce(e){return e.length===0||e.every(t=>Re(t))}function ge(e){return e.projectCount>0||e.policyErrorCount>0?{verdict:e.verdict,exitCode:e.exitCode}:e.verdict==="blocked"&&Ce(e.blockingReasons)?{verdict:"needs-attention",exitCode:1}:{verdict:e.verdict,exitCode:e.exitCode}}function tt(e,t){let r=t&&t!=="ready"?` (${t.replace(/-/g," ")})`:"";return e===0?`Workspace scaffold ready${r} \u2014 add your first project to continue.`:`Workspace scaffold${r}: ${e} pre-project signal(s) \u2014 add your first project to continue.`}var ye=f.verify,G=e.verify;function Ae(e,t){return m.isAbsolute(t)?t:m.join(e,t)}async function ke(e){let t=await v.readJson(e);if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`Workspace impact input is not a JSON object: ${e}`);let r=t;if(r.schemaVersion!==f$1)throw new Error(`Unsupported workspace impact schema: ${String(r.schemaVersion)}`);a$2(t,"contracts/workspace-intelligence/workspace-impact.v1.json",`Workspace impact ${e}`);let s=r;a$2(s.diff,"contracts/workspace-intelligence/workspace-model-diff.v1.json",`Embedded workspace diff in ${e}`);let i=[];s.summary.affectedProjects!==s.affectedProjects.length&&i.push("summary.affectedProjects does not match affectedProjects.length"),s.summary.workspaceItems!==s.workspaceImpact.length&&i.push("summary.workspaceItems does not match workspaceImpact.length"),s.summary.recommendedCommands!==s.verificationPlan.length&&i.push("summary.recommendedCommands does not match verificationPlan.length"),s.summary.blastRadius.directlyAffected!==s.affectedProjects.length&&i.push("blastRadius.directlyAffected does not match affectedProjects.length"),s.summary.blastRadius.transitivelyAffected!==s.transitiveImpact.length&&i.push("blastRadius.transitivelyAffected does not match transitiveImpact.length");let o=s.transitiveImpact.reduce((u,d)=>Math.max(u,d.distance??0),0);s.summary.blastRadius.maxDistance!==o&&i.push("blastRadius.maxDistance does not match transitive impact distances");let k=m$1(s.diff.currentModel)?.edges.length??0;if(s.summary.blastRadius.graphEdges!==k&&i.push("blastRadius.graphEdges does not match the embedded model graph"),s.summary.changed!==s.diff.summary.changed&&i.push("summary.changed does not match embedded diff summary"),s.fromRef!==s.diff.fromRef&&i.push("fromRef does not match embedded diff fromRef"),s.workspace.name!==s.diff.currentModel.workspace.name&&i.push("workspace.name does not match the embedded model"),s.diff.toHash!==d(s.diff.currentModel)&&i.push("embedded diff current-model hash does not match toHash"),i.length>0)throw new Error(`Workspace impact semantic integrity failed: ${i.join("; ")} (${e})`);return s}function Ee(e){let t=new Set,r=[];for(let s of e){let i=`${s.scope}:${s.project??""}:${s.display}`;t.has(i)||(t.add(i),r.push(s));}return r}function Se(e,t){if(!e||e==="workspace")return true;let r=(e.startsWith("project:")?e.slice(8):e).trim().toLowerCase();return t.scope==="workspace"?true:(t.project??"").trim().toLowerCase()===r}function We(e$1,t){if(e$1.id==="workspace.doctor")return m.join(t,e.doctor);if(e$1.id==="workspace.contract.verify")return m.join(t,e.contractVerify);if(e$1.id==="workspace.readiness")return m.join(t,e.readiness);if(e$1.id==="workspace.analyze")return m.join(t,".workspai","reports","analyze-last-run.json");if(e$1.id==="workspace.pipeline")return m.join(t,".workspai","reports","pipeline-last-run.json");if(e$1.id==="workspace.doctor-fix")return m.join(t,".workspai","reports","doctor-fix-result-last-run.json");if(e$1.id.startsWith("project.")&&e$1.id.includes("."))return m.join(t,".workspai","reports","workspace-run-last.json")}function C(e){return !e||typeof e!="object"||Array.isArray(e)?null:e}function je(e){if(!c$1(e,"workspace"))return {status:"fail",message:"Doctor evidence contract is missing or unsupported."};try{d$5(e);}catch(s){return {status:"fail",message:`Doctor evidence semantic validation failed: ${s instanceof Error?s.message:String(s)}`}}let t=a$3(e);return t.hasSystemErrors||t.blockingFindings>0?{status:"fail",message:`Doctor evidence reports ${t.blockingFindings} canonical blocking finding(s).`}:t.advisoryFindings+t.unknownFindings+t.contradictionCount+t.missingDiagnosisProjects>0||t.staleEvidence||t.unknownFreshness||t.minimumDiagnosisCompleteness<100?{status:"warn",message:`Doctor evidence needs attention (${t.advisoryFindings} advisory, ${t.unknownFindings} unknown, ${t.contradictionCount} contradictory; ${t.minimumDiagnosisCompleteness}% complete).`}:{status:"pass",message:"Canonical Doctor evidence is complete, fresh, and healthy."}}function xe(e){let t=typeof e.overallStatus=="string"?e.overallStatus:"unknown";return t==="fail"?{status:"fail",message:"Release readiness evidence reports blocking failures."}:t==="warn"?{status:"warn",message:"Release readiness evidence reports warnings."}:t==="pass"?{status:"pass",message:"Release readiness evidence passed."}:{status:"warn",message:`Release readiness evidence status is ${t}.`}}function Pe(e){let t=typeof e.status=="string"?e.status:"unknown";return t==="failed"||t==="fail"?{status:"fail",message:"Workspace contract verify evidence failed."}:t==="passed"||t==="pass"?{status:"pass",message:"Workspace contract verify evidence passed."}:{status:"warn",message:`Workspace contract verify evidence status is ${t}.`}}function Ie(e){let t=C(e.summary),r=typeof t?.verdict=="string"?t.verdict:void 0;return r==="blocked"?{status:"fail",message:"Analyze evidence reports blocking findings."}:r==="needs-attention"?{status:"warn",message:"Analyze evidence reports warnings."}:{status:"pass",message:"Analyze evidence is ready."}}function Ve(e){let t=e.schemaVersion===h.doctorFixResult.schemaVersion?e:e.fixResult;if(!t||typeof t!="object"||Array.isArray(t))return {status:"skipped",message:"Doctor fix result not present; run doctor workspace --fix --json to record fixes."};let r=t,s=Array.isArray(r.remainingBlockers)?r.remainingBlockers:[];if(s.length>0)return {status:"fail",message:`Doctor fix result reports ${s.length} remaining blocker(s).`};let i=Array.isArray(r.appliedFixes)?r.appliedFixes:[];return i.length===0?{status:"pass",message:"Doctor fix result recorded with no remaining blockers."}:{status:"pass",message:`Doctor fix result recorded ${i.length} applied fix(es) with no remaining blockers.`}}async function Fe(e,t){let r=await d$2(e,i.doctorRemediationPlan);if(!r)return false;try{let s=C(await v.readJson(r));if(!s||(Array.isArray(s.steps)?s.steps:[]).length>0)return false;let o=typeof s.generatedAt=="string"?s.generatedAt:void 0;if(!o||!t)return true;let k=Date.parse(o),u=Date.parse(t);return !Number.isFinite(k)||!Number.isFinite(u)?true:k>=u}catch{return false}}function $e(e){return e.id.endsWith(".init")?"init":e.id.endsWith(".test")?"test":e.id.endsWith(".build")?"build":e.id.endsWith(".start")?"start":null}function Oe(e){let t=C(e.summary),r=typeof t?.verdict=="string"?t.verdict:void 0;return r==="blocked"?{status:"fail",message:"Pipeline evidence is blocked."}:r==="needs-attention"?{status:"warn",message:"Pipeline evidence needs attention."}:r==="ready"?{status:"pass",message:"Pipeline evidence is ready."}:{status:"warn",message:"Pipeline evidence status is unknown."}}function De(e,t,r){let s=$e(t),i=c$2(e,s??void 0);if(!i)return {status:"missing",message:"Workspace run evidence is missing or unreadable."};let o=i.stage;if(s&&o!==s)return {status:"missing",message:`Workspace run evidence is for stage "${o}", expected "${s}".`};let k=Array.isArray(i.projects)?i.projects:[],u=t.project?.toLowerCase();if(!u)return {status:"missing",message:"Project-scoped workspace run evidence is missing a project identifier."};let d=k.find(g=>{let c=C(g);if(!c)return false;let n=typeof c.projectName=="string"?c.projectName.toLowerCase():"",a=["projectPath","relativePath","path"].map(f=>c[f]).filter(f=>typeof f=="string"&&f.trim().length>0).map(f=>f.replace(/\\/g,"/").toLowerCase());return n===u||a.some(f=>f.endsWith(`/${u}`)||f===u)});if(d){let g=R(i.generatedAt,r,`Workspace run evidence for ${t.project??t.id}`);if(g)return {status:"fail",message:g};let c=C(d),n=typeof c?.status=="string"?c.status:"unknown";return n==="failed"?{status:"fail",message:`Workspace run evidence failed for ${t.project}.`}:n==="passed"?{status:"pass",message:`Workspace run evidence passed for ${t.project}.`}:n==="skipped"?{status:"warn",message:`Workspace run evidence skipped for ${t.project}.`}:{status:"warn",message:`Workspace run evidence status is ${n} for ${t.project}.`}}return {status:"missing",message:`Workspace run evidence does not include project ${t.project}.`}}function R(e,t,r){if(!t)return null;if(typeof e!="string"||e.trim().length===0)return `${r} is stale: missing generatedAt timestamp (required after impact ${t}).`;let s=Date.parse(e),i=Date.parse(t);return Number.isFinite(s)?Number.isFinite(i)&&s<i?`${r} is stale: generated at ${e}, before impact ${t}.`:null:`${r} is stale: invalid generatedAt timestamp (required after impact ${t}).`}function Be(e){if(e.id==="workspace.doctor")return g$1.doctor;if(e.id==="workspace.readiness")return g$1.readiness;if(e.id==="workspace.contract.verify")return g$1.contractVerify;if(e.id==="workspace.analyze")return g$1.analyze;if(e.id==="workspace.pipeline")return "contracts/pipeline-last-run.v1.json"}async function _e(e,t,r,s){let i=We(e,t),o=i?m.relative(t,i).split(m.sep).join("/"):void 0;if(e.id==="workspace.contract.verify"&&!r)return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"skipped",required:e.required,message:"Workspace contract is not present; contract verify skipped."};let k=i?await d$2(t,o??""):null;if(!i||!k)return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"missing",required:e.required,evidencePath:o,message:o?`Missing evidence report: ${o}`:"No evidence mapping exists for this command."};let u;try{u=await v.readJson(k);}catch(n){return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"fail",required:e.required,evidencePath:o,message:`Evidence report is unreadable JSON: ${n instanceof Error?n.message:String(n)}`}}let d=C(u);if(!d)return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"fail",required:e.required,evidencePath:o,message:"Evidence report is not a JSON object."};let g=Be(e);if(g)try{a$2(d,g,`${e.label} evidence`);}catch(n){return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"fail",required:e.required,evidencePath:o,message:`Evidence report is invalid: ${n instanceof Error?n.message:String(n)}`}}let c;if(e.id==="workspace.doctor"){let n=R(d.generatedAt,s,"Doctor evidence");n?c={status:"fail",message:n}:c=je(d);}else if(e.id==="workspace.readiness"){let n=R(d.generatedAt,s,"Release readiness evidence");n?c={status:"fail",message:n}:c=xe(d);}else if(e.id==="workspace.contract.verify"){let n=R(d.generatedAt,s,"Workspace contract verify evidence");n?c={status:"fail",message:n}:c=Pe(d);}else if(e.id==="workspace.analyze"){let n=R(d.generatedAt,s,"Analyze evidence");n?c={status:"fail",message:n}:c=Ie(d);}else if(e.id==="workspace.pipeline"){let n=R(d.generatedAt,s,"Pipeline evidence");n?c={status:"fail",message:n}:c=Oe(d);}else if(e.id==="workspace.doctor-fix"){let n=d.schemaVersion===h.doctorFixResult.schemaVersion?d:d.fixResult,a=C(n),f=typeof a?.generatedAt=="string"?a.generatedAt:void 0,y=R(f,s,"Doctor fix result");y?c={status:"fail",message:y}:await Fe(t,f)?c={status:"skipped",message:"No current doctor remediation steps are pending."}:c=Ve(d);}else if(e.id.startsWith("project."))c=De(d,e,s);else {let n=R(d.generatedAt,s,"Evidence report");n?c={status:"fail",message:n}:c={status:"pass",message:"Evidence report is present."};}return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:c.status,required:e.required,evidencePath:o,message:c.message}}function Ne(e,t={blockingReasons:[],needsAttention:false}){let r=e.filter(n=>n.status==="pass").length,s=e.filter(n=>n.status==="warn").length,i=e.filter(n=>n.status==="fail").length,o=e.filter(n=>n.status==="missing").length,k=e.filter(n=>n.status==="skipped").length,u=e.filter(n=>n.required&&(n.status==="fail"||n.status==="missing")).map(n=>`${n.id}: ${n.message}`),d=e.filter(n=>n.required&&n.status==="missing").length,g="ready",c=0;return u.length>0||t.blockingReasons.length>0?(g="blocked",c=2):(s>0||e.some(n=>!n.required&&n.status==="fail")||d>0||t.needsAttention)&&(g="needs-attention",c=1),{verdict:g,exitCode:c,stepsPassed:r,stepsWarn:s,stepsFailed:i,stepsMissing:o,stepsSkipped:k}}function He(e,t){let r=x(e.affectedProjects.map(a=>a.project?.name).filter(a=>typeof a=="string")),s=new Set(r.map(a=>a.toLowerCase())),i=x(e.transitiveImpact.map(a=>a.project?.name).filter(a=>typeof a=="string").filter(a=>!s.has(a.toLowerCase()))),o=new Map;for(let a of t){if(a.scope!=="project"||!a.project)continue;let f=a.project.toLowerCase(),y=o.get(f)??[];y.push(a),o.set(f,y);}let k=[],u=[],d=[],g=[],c=false,n=(a,f)=>{let y=o.get(a.toLowerCase())??[];if(y.length===0){d.push(a);return}let P=y.filter(p=>p.status==="fail"),b=P.filter(p=>p.required),I=y.filter(p=>p.status==="missing"),E=I.filter(p=>p.required),V=y.some(p=>p.status==="pass"||p.status==="warn");if(b.length>0){u.push(a),g.push(`graph.subgraph.${a}: ${f} has failed verification evidence (${b.map(p=>p.id).join(", ")}).`);return}if(P.length>0){u.push(a),c=true;return}if(E.length>0){u.push(a),g.push(`graph.subgraph.${a}: ${f} has missing required verification evidence (${E.map(p=>p.id).join(", ")}).`);return}if(I.length>0){u.push(a),c=true;return}if(V){k.push(a);return}d.push(a);};for(let a of r)n(a,"directly-changed");for(let a of i)n(a,"transitive dependent");return {subgraph:{totalProjects:r.length+i.length,directlyChanged:r,transitiveDependents:i,covered:x(k),uncovered:x(u),unverifiable:x(d)},blockingReasons:g,needsAttention:c}}function x(e){return [...new Set(e)].sort((t,r)=>t.localeCompare(r))}async function Me(e$1){let t=m.resolve(e$1.workspacePath);if(e$1.fromImpactPath){let o=Ae(t,e$1.fromImpactPath);return {impact:await ke(o),fromImpactRef:m.relative(t,o).split(m.sep).join("/"),impactFromDisk:true}}let r=m.join(t,g);if(await v.pathExists(r))return {impact:await ke(r),fromImpactRef:g,impactFromDisk:true};let s=m.join(t,d$4);if(await v.pathExists(s))return {impact:await p({workspacePath:t,fromPath:d$4,scope:e$1.scope,includeAbsolutePaths:e$1.includeAbsolutePaths,includeEvidence:e$1.includeEvidence,observableScanDepth:e$1.observableScanDepth,now:e$1.now}),fromImpactRef:d$4,impactFromDisk:false};let i=await q({workspacePath:t,includeAbsolutePaths:e$1.includeAbsolutePaths,includeEvidence:e$1.includeEvidence,observableScanDepth:e$1.observableScanDepth,now:e$1.now});return {impact:{schemaVersion:f$1,generatedAt:(e$1.now??new Date).toISOString(),fromRef:"baseline",diffRef:e.diff,workspace:{name:i.workspace.name,profile:i.workspace.profile,type:i.workspace.type},summary:{changed:false,risk:"none",affectedProjects:0,workspaceItems:0,recommendedCommands:0,blastRadius:{directlyAffected:0,transitivelyAffected:0,maxDistance:0,graphEdges:m$1(i)?.edges.length??0}},affectedProjects:[],transitiveImpact:[],criticalPathHotspots:[],workspaceImpact:[],verificationPlan:[],agentBrief:{headline:"Baseline workspace verify run.",bullets:["No impact report or snapshot was available; baseline gates were evaluated."],unsafeAssumptions:["Do not claim runtime verification passed unless evidence exists."]},diff:{schemaVersion:f.diff,generatedAt:(e$1.now??new Date).toISOString(),fromRef:"baseline",toRef:e.model,fromHash:"baseline",toHash:"baseline",summary:{changed:false,addedProjects:0,removedProjects:0,changedProjects:0,workspaceChanges:0,validationChanges:0,gitChangedFiles:0},git:{available:false,dirty:false,changedFiles:0,untrackedFiles:0,deletedFiles:0},changes:[],currentModel:i}},impactFromDisk:false}}function Te(e,t){if(t)return e.generatedAt}async function bt(e){let t=m.resolve(e.workspacePath),{impact:r,fromImpactRef:s,impactFromDisk:i}=await Me(e),o$1=r.diff.currentModel,k=i?await q({workspacePath:t,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,observableScanDepth:e.observableScanDepth,now:e.now}):o$1,u=[];if(i){let l=await p({workspacePath:t,fromPath:r.diff.fromRef,diff:r.diff,scope:e.scope,now:e.now}),W=[r.affectedProjects,r.transitiveImpact,r.verificationPlan],A=[l.affectedProjects,l.transitiveImpact,l.verificationPlan];JSON.stringify(W)!==JSON.stringify(A)&&u.push("workspace.impact: Persisted impact semantics do not match the impact re-derived from the embedded diff. Regenerate diff and impact.");}i&&d(k)!==r.diff.toHash&&u.push("workspace.impact: Impact evidence is stale because the current workspace model no longer matches the embedded model. Regenerate diff and impact.");let d$2=r.diff.git;if(i&&d$2?.available){let l=a(t,{ref:d$2.ref}),W=r.diff.changes.filter(h=>h.type.startsWith("git.")).map(h=>`${h.type}:${h.target.replace(/^git:/,"")}`).sort(),A=[...l.changedFiles.map(h=>`git.file.changed:${h}`),...l.untrackedFiles.map(h=>`git.untracked:${h}`),...l.deletedFiles.map(h=>`git.deleted:${h}`)].sort();(!l.available||l.commit!==d$2.commit||JSON.stringify(A)!==JSON.stringify(W))&&u.push("workspace.impact: Impact evidence is stale because Git changes no longer match the diff observation. Regenerate diff and impact.");}let g=Te(r,i),c$1=Ee([...o(),...r.verificationPlan]).filter(l=>Se(e.scope,l)),n=[];for(let l of c$1)n.push(await _e(l,t,o$1.contracts.exists===true,g));let a$2=He(r,n),f=a$1(m$1(o$1)??{nodes:[],edges:[]}),y=b(o$1),P=await Ke(t),b$2=c(y,P?.freshness?.projectHashes),I={verdict:b$2.verdict,baseline:b$2.baseline,changed:b$2.changed,added:b$2.added,removed:b$2.removed,projectHashes:d$1(y)},E=b$1(f),V=o$1.policies?.mode??"warn",p$1=await Le(o$1,t),B=qe(V,p$1),S=Ne(n,{blockingReasons:[...a$2.blockingReasons,...E,...B.blockingReasons,...u],needsAttention:a$2.needsAttention||B.needsAttention}),he=n.filter(l=>l.status==="missing"&&l.evidencePath).map(l=>l.evidencePath),_=[...n.filter(l=>l.required&&(l.status==="fail"||l.status==="missing")).map(l=>`${l.id}: ${l.message}`),...a$2.blockingReasons,...E,...B.blockingReasons,...u],ve=p$1.filter(l=>l.severity==="error").length,be=o$1.summary?.projectCount??o$1.projects.length,U=ge({projectCount:be,verdict:S.verdict,exitCode:S.exitCode,blockingReasons:_,policyErrorCount:ve});S.verdict=U.verdict,S.exitCode=U.exitCode;let Y=Array.from(new Set(_.map(l=>l.trim()).filter(Boolean))).slice(0,12).map((l,W)=>{let A=n.find(h=>l.startsWith(`${h.id}:`));return me({reason:l,blockerId:`blocker-${W+1}`,sourceCommand:A?.command.display,sourceArtifact:A?.evidencePath,verifyCommand:"npx workspai workspace verify --from-impact .workspai/reports/workspace-impact-last-run.json --json",verifyArtifact:G})});return {schemaVersion:ye,generatedAt:(e.now??new Date).toISOString(),workspacePath:t,mode:"evidence",fromImpactRef:s,scope:e.scope,impact:{changed:r.summary.changed,risk:r.summary.risk,affectedProjects:r.summary.affectedProjects,recommendedCommands:r.summary.recommendedCommands},summary:S,steps:n,missingEvidence:he,blockingReasons:_,...Y.length>0?{resolutionHints:Y}:{},verificationPlan:c$1,affectedSubgraph:a$2.subgraph,graphIntegrity:f,freshness:I,policyMode:V,policyViolations:p$1}}async function Le(e$1,t){let r=[];for(let i of e$1.validation?.issues??[])r.push({source:"model",severity:i.severity,code:i.code,message:i.message,target:i.target});let s=await d$2(t,e.contractVerify);try{if(s&&await v.pathExists(s)){let i=await v.readJson(s);if(Array.isArray(i.violations))for(let o of i.violations)typeof o=="string"&&o.trim().length>0&&r.push({source:"contract",severity:"error",code:"contract.violation",message:o});}}catch{}return r.sort((i,o)=>i.source!==o.source?i.source.localeCompare(o.source):i.code!==o.code?i.code.localeCompare(o.code):i.message.localeCompare(o.message))}function qe(e,t){let r=t.filter(s=>s.severity==="error");return e==="enforce"&&r.length>0?{blockingReasons:r.map(s=>`policy.${s.code}: ${s.message}`),needsAttention:false}:{blockingReasons:[],needsAttention:r.length>0}}async function Ke(e){let t=m.join(e,G);try{if(!await v.pathExists(t))return null;let r=await v.readJson(t);return r&&r.schemaVersion===ye?r:null}catch{return null}}async function wt(e,t){return e$1(t,G,d$3(e))}function ze(e,t){let r=t?.strict?"strict":"default",s=[];if(e.summary.verdict==="blocked")return s.push(...e.blockingReasons),s.length===0&&s.push("verify verdict is blocked."),{passed:false,mode:r,exitCode:2,reasons:s};if(r==="strict"){if(e.summary.verdict!=="ready"&&s.push(`verify verdict is ${e.summary.verdict} (strict requires ready).`),e.freshness.verdict==="stale"){let i=[...e.freshness.changed,...e.freshness.added].slice(0,5);s.push(`freshness is stale${i.length>0?`: ${i.join(", ")}`:""} (strict requires fresh).`);}if(s.length>0)return {passed:false,mode:r,exitCode:1,reasons:s}}return {passed:true,mode:r,exitCode:0,reasons:s}}function Rt(e,t){return ze(e,t).exitCode}export{fe as a,tt as b,ye as c,G as d,He as e,bt as f,wt as g,ze as h,Rt as i};
@@ -1 +1 @@
1
- var r="workspai.doctor-capabilities.v1",k="universal-doctor-capabilities-v1",t="workspai.doctor-validation.v1",w="doctor-disease-corpus-v1";var o={model:".workspai/reports/workspace-model.json",knowledgeGraph:".workspai/reports/workspace-knowledge-graph.json",snapshot:".workspai/reports/workspace-model-snapshot.json",diff:".workspai/reports/workspace-model-diff-last-run.json",impact:".workspai/reports/workspace-impact-last-run.json",analyze:".workspai/reports/analyze-last-run.json",doctor:".workspai/reports/doctor-last-run.json",contractVerify:".workspai/reports/workspace-contract-verify-last-run.json",readiness:".workspai/reports/release-readiness-last-run.json",verify:".workspai/reports/workspace-verify-last-run.json",history:".workspai/reports/workspace-intelligence-history.json",agentContext:".workspai/reports/workspace-context-agent.json",agentIndex:".workspai/reports/INDEX.json",agentCustomizationPack:".workspai/reports/agent-customization-pack.json",skillsIndex:".workspai/reports/workspace-skills-index.json",agents:"AGENTS.md",explain:".workspai/reports/workspace-explain-last-run.json",intelligenceRun:".workspai/reports/workspace-intelligence-run-last-run.json",evaluationLive:".workspai/reports/workspace-intelligence-evaluation-live.json",evaluationLastRun:".workspai/reports/workspace-intelligence-evaluation-last-run.json",verifiedGoalStatus:".workspai/reports/verified-goal-last-run.json",repairTransaction:".workspai/reports/workspace-repair-last-run.json"},s={model:"workspace-model.v1",knowledgeGraph:"workspace-knowledge-graph.v1",snapshot:"workspace-model-snapshot.v1",diff:"workspace-model-diff.v1",impact:"workspace-impact.v1",analyze:"rapidkit-analyze-v1",doctor:"doctor-workspace-evidence-v1",contractVerify:"workspace-contract-verify.v1",readiness:"release-readiness-v1",verify:"workspace-verify.v1",history:"workspace-intelligence-history.v1",agentContext:"workspace-context.v1",agentIndex:"rapidkit-agent-reports-index.v1",agentCustomizationPack:"rapidkit-agent-customization-pack.v1",skillsIndex:"workspace-skills-index.v1",agents:null,explain:"workspace-explain.v1",intelligenceRun:"workspace-intelligence-run.v1",evaluationLive:"workspace-intelligence-evaluation.v1",evaluationLastRun:"workspace-intelligence-evaluation.v1",verifiedGoalStatus:"workspai.verified-goal-status.v1",repairTransaction:"workspai.workspace-repair-transaction.v1"},c={model:"contracts/workspace-intelligence/workspace-model.v1.json",knowledgeGraph:"contracts/workspace-intelligence/workspace-knowledge-graph.v1.json",snapshot:"contracts/workspace-intelligence/workspace-model-snapshot.v1.json",diff:"contracts/workspace-intelligence/workspace-model-diff.v1.json",impact:"contracts/workspace-intelligence/workspace-impact.v1.json",analyze:"contracts/analyze-last-run.v1.json",doctor:"contracts/doctor-workspace-evidence.v1.json",contractVerify:"contracts/workspace-intelligence/workspace-contract-verify.v1.json",readiness:"contracts/release-readiness.v1.json",verify:"contracts/workspace-intelligence/workspace-verify.v1.json",history:"contracts/workspace-intelligence/workspace-intelligence-history.v1.json",agentContext:"contracts/workspace-intelligence/workspace-context.v1.json",agentIndex:"contracts/workspace-intelligence/agent-reports-index.v1.json",agentCustomizationPack:"contracts/workspace-intelligence/agent-customization-pack-report.v1.json",skillsIndex:"contracts/workspace-intelligence/workspace-skills-index.v1.json",agents:null,explain:"contracts/workspace-intelligence/workspace-explain.v1.json",intelligenceRun:"contracts/workspace-intelligence/workspace-intelligence-run.v1.json",evaluationLive:"contracts/workspace-intelligence/workspace-intelligence-evaluation.v1.json",evaluationLastRun:"contracts/workspace-intelligence/workspace-intelligence-evaluation.v1.json",verifiedGoalStatus:"contracts/workspace-intelligence/verified-goal-status.v1.json",repairTransaction:"contracts/workspace-intelligence/workspace-repair-transaction.v1.json"},l={goalIndex:{artifactPath:".workspai/goals/index.json",schemaVersion:"workspai.goal-index.v1",contractPath:"contracts/workspace-intelligence/goal-index.v1.json",producerCommands:[["goal"]]},projectWorkspaceLink:{artifactPath:".workspai/workspace-link.local.json",schemaVersion:"project-workspace-link.v1",contractPath:"contracts/project-workspace-link.v1.json",producerCommands:[["adopt"],["import"],["project","workspace","relink"],["workspace","sync"]]},projectContextAgent:{artifactPath:".workspai/reports/project-context-agent.json",schemaVersion:"project-context-agent.v1",contractPath:"contracts/workspace-intelligence/project-context-agent.v1.json",producerCommands:[["adopt"],["import"],["workspace","sync"],["workspace","agent-sync","--write"]]},projectKnowledgeGraphReference:{artifactPath:".workspai/reports/project-knowledge-graph-reference.json",schemaVersion:"project-knowledge-graph-reference.v1",contractPath:"contracts/workspace-intelligence/project-knowledge-graph-reference.v1.json",producerCommands:[["adopt"],["import"],["workspace","model"],["workspace","sync"],["workspace","intelligence","run"]]},projectAgentEntry:{artifactPath:".workspai/agent-entry.v1.json",schemaVersion:"workspai.agent-entry.v1",contractPath:"contracts/workspace-intelligence/project-agent-entry.v1.json",producerCommands:[["adopt"],["import"],["workspace","sync"],["workspace","agent-sync","--write"]]},workspaceContract:{artifactPath:".workspai/workspace.contract.json",schemaVersion:1,contractPath:"contracts/workspace-contract.v1.json",producerCommands:[["workspace","sync"],["workspace","contract","sync"]]},workspaceModelCache:{artifactPath:".workspai/cache/workspace-model.v1.json",schemaVersion:"workspace-model-cache.v1",contractPath:"contracts/workspace-model-cache.v1.json",producerCommands:[["workspace","model"]]},workspaceRegistry:{artifactPath:".workspai/workspace-registry.v1.json",schemaVersion:"workspace-registry.v1",contractPath:"contracts/workspace-registry.v1.json",producerCommands:[["workspace","sync"]]},compatibilityMatrix:{artifactPath:".workspai/compatibility-matrix.json",schemaVersion:"rapidkit.compatibility-matrix.v1",contractPath:"contracts/compatibility-matrix.v1.json",producerCommands:[["bootstrap"]]},doctorWorkspaceCache:{artifactPath:".workspai/reports/doctor-workspace-cache.json",schemaVersion:"doctor-workspace-cache-v2",contractPath:"contracts/doctor-workspace-cache.v2.json",producerCommands:[["doctor","workspace"]]},doctorCapabilities:{artifactPath:".workspai/reports/doctor-capabilities.json",schemaVersion:r,contractPath:"contracts/workspace-intelligence/doctor-capabilities.v1.json",producerCommands:[["doctor","capabilities","--write"]]},doctorValidation:{artifactPath:".workspai/reports/doctor-validation-last-run.json",schemaVersion:t,contractPath:"contracts/workspace-intelligence/doctor-validation.v1.json",producerCommands:[["doctor","capabilities","--validate","--write"]]},bootstrapCompliance:{artifactPath:".workspai/reports/bootstrap-compliance.latest.json",schemaVersion:"bootstrap-compliance.v1",contractPath:"contracts/bootstrap-compliance.v1.json",producerCommands:[["bootstrap"]]},mirrorOps:{artifactPath:".workspai/reports/mirror-ops.latest.json",schemaVersion:"mirror-ops.v1",contractPath:"contracts/mirror-ops.v1.json",producerCommands:[["mirror","status"]]},transparencyEvidence:{artifactPath:".workspai/reports/transparency-evidence.latest.json",schemaVersion:"transparency-evidence.v1",contractPath:"contracts/transparency-evidence.v1.json",producerCommands:[["mirror","sync"]]},workspaceShareBundle:{artifactPath:".workspai/reports/share-bundle.json",schemaVersion:"1.1",schemaVersionField:"schema_version",contractPath:"contracts/workspace-share-bundle.v1.json",producerCommands:[["workspace","share"]]},doctorProject:{artifactPath:".workspai/reports/doctor-project-last-run.json",schemaVersion:"doctor-project-evidence-v1",contractPath:"contracts/doctor-project-evidence.v1.json",producerCommands:[["doctor","project"]]},doctorReceipt:{artifactPath:".workspai/reports/doctor-receipt-last-run.json",schemaVersion:"workspai.doctor-receipt.v1",contractPath:"contracts/workspace-intelligence/doctor-receipt.v1.json",producerCommands:[["doctor","workspace"],["doctor","project"]]},projectTestCoverage:{artifactPath:".workspai/reports/project-test-coverage-last-run.json",schemaVersion:"workspai.project-test-coverage.v1",contractPath:"contracts/project-test-coverage.v1.json",producerCommands:[["project","coverage"]]},goalPackLastRun:{artifactPath:".workspai/reports/goal-pack-last-run.json",schemaVersion:"workspai.goal-pack.v1",contractPath:"contracts/workspace-intelligence/goal-pack.v1.json",producerCommands:[["goal"]]},doctorRemediationPlan:{artifactPath:".workspai/reports/doctor-remediation-plan-last-run.json",schemaVersion:"doctor-remediation-plan-v2",contractPath:"contracts/doctor-remediation-plan.v2.json",producerCommands:[["workspace","remediation-plan"]]},artifactRemediationPlan:{artifactPath:".workspai/reports/artifact-remediation-plan-last-run.json",schemaVersion:"artifact-remediation-plan-v1",contractPath:"contracts/artifact-remediation-plan.v1.json",producerCommands:[["workspace","remediation-plan"]]},doctorFixResult:{artifactPath:".workspai/reports/doctor-fix-result-last-run.json",schemaVersion:"rapidkit-doctor-fix-result-v1",contractPath:"contracts/workspace-intelligence/doctor-fix-result.v1.json",producerCommands:[["doctor","workspace"]]},pipelineLastRun:{artifactPath:".workspai/reports/pipeline-last-run.json",schemaVersion:"rapidkit-pipeline-v1",contractPath:"contracts/pipeline-last-run.v1.json",producerCommands:[["pipeline"]]},autopilotReleaseLastRun:{artifactPath:".workspai/reports/autopilot-release-last-run.json",schemaVersion:"autopilot-release-v1",contractPath:"contracts/autopilot-release.v1.json",producerCommands:[["autopilot","release"]]},autopilotReleaseAlias:{artifactPath:".workspai/reports/autopilot-release.json",schemaVersion:"autopilot-release-v1",contractPath:"contracts/autopilot-release.v1.json",producerCommands:[["autopilot","release"]]},workspaceRunLast:{artifactPath:".workspai/reports/workspace-run-last.json",schemaVersion:"workspace-run-v1",contractPath:"contracts/workspace-run-last.v1.json",producerCommands:[["workspace","run"]]},workspaiMcpDesign:{artifactPath:".workspai/reports/workspai-mcp-design.json",schemaVersion:"workspai-mcp-design.v1",contractPath:"contracts/workspace-intelligence/mcp-design.v1.json",producerCommands:[["workspace","agent-sync","--write"]]},legacyMcpDesign:{artifactPath:".workspai/reports/rapidkit-mcp-design.json",schemaVersion:"workspai-mcp-design.v1",contractPath:"contracts/workspace-intelligence/mcp-design.v1.json",producerCommands:[["workspace","agent-sync","--write"]]},workspaceWhy:{artifactPath:".workspai/reports/workspace-why-last-run.json",schemaVersion:s.explain,contractPath:c.explain,producerCommands:[["workspace","why"]]},workspaceTrace:{artifactPath:".workspai/reports/workspace-trace-last-run.json",schemaVersion:s.explain,contractPath:c.explain,producerCommands:[["workspace","trace"]]},agentHooks:{artifactPath:".vscode/workspai-agent-hooks.json",schemaVersion:"workspai-agent-hooks.v1",contractPath:"contracts/workspace-intelligence/agent-hooks.v1.json",producerCommands:[["workspace","agent-sync"]]},infraPlan:{artifactPath:".workspai/reports/infra-plan.json",schemaVersion:"rapidkit.infra-plan.v1",contractPath:"contracts/infra-plan.v1.json",producerCommands:[["infra","plan"]]}},h=Object.freeze(Object.fromEntries(Object.entries(l).map(([a,n])=>[a,n.artifactPath]))),u={[o.intelligenceRun]:[["workspace","intelligence","run"]],[o.snapshot]:[["workspace","snapshot"]],[o.history]:[["workspace","feedback","record","--json"]],[o.evaluationLive]:[["workspace","eval","init"],["workspace","eval","record","--json"]],[o.evaluationLastRun]:[["workspace","eval","report","--json"]],[o.verifiedGoalStatus]:[["workspace","goal","plan"],["workspace","goal","verify"]],[o.repairTransaction]:[["workspace","repair","plan"],["workspace","repair","propose"],["workspace","repair","approve"],["workspace","repair","decide"],["workspace","repair","execute"],["workspace","repair","resume"],["workspace","repair","rollback"],["workspace","repair","cancel"]]},j={analyze:"analyze",workspace:"workspace <action> [subaction] [key] [value]",doctor:"doctor [scope]",readiness:"readiness"},f=["analyze","readiness","doctor","workspace"],C=["model","diff","impact","doctor-evidence","contract-evidence","analyze-evidence","readiness-evidence","verify","context","agent-sync","explain"],P=["sync","baseline"],y={sync:[".workspai/workspace.contract.json",".workspai/workspace-registry.v1.json"],baseline:[o.snapshot]},e=o,d={model:{command:["workspace","model","--json","--write"],produces:[e.model,e.knowledgeGraph]},diff:{command:["workspace","diff","--from",e.snapshot,"--json"],produces:[e.diff]},impact:{command:["workspace","impact","--from",e.diff,"--json"],produces:[e.impact]},"doctor-evidence":{command:["doctor","workspace","--json"],produces:[e.doctor]},"contract-evidence":{command:["workspace","contract","verify","--strict","--json"],produces:[e.contractVerify]},"analyze-evidence":{command:["analyze","--json"],produces:[e.analyze]},"readiness-evidence":{command:["readiness","--json","--skip-verify"],produces:[e.readiness]},verify:{command:["workspace","verify","--from-impact",e.impact,"--json"],produces:[e.verify,e.history]},context:{command:["workspace","context","--for-agent","--json","--write","--no-agent-sync"],produces:[e.agentContext]},"agent-sync":{command:["workspace","agent-sync","--write","--json","--preset","enterprise"],produces:[e.agentIndex,e.agentCustomizationPack,e.skillsIndex,e.agents]},explain:{command:["workspace","explain","release-blocked","--json","--write"],produces:[e.explain]}};function I(a){return d[a]}export{r as a,k as b,t as c,w as d,o as e,s as f,c as g,l as h,h as i,u as j,j as k,f as l,C as m,P as n,y as o,d as p,I as q};
1
+ var r="workspai.doctor-capabilities.v1",k="universal-doctor-capabilities-v1",t="workspai.doctor-validation.v1",w="doctor-disease-corpus-v1";var o={model:".workspai/reports/workspace-model.json",knowledgeGraph:".workspai/reports/workspace-knowledge-graph.json",snapshot:".workspai/reports/workspace-model-snapshot.json",diff:".workspai/reports/workspace-model-diff-last-run.json",impact:".workspai/reports/workspace-impact-last-run.json",analyze:".workspai/reports/analyze-last-run.json",doctor:".workspai/reports/doctor-last-run.json",contractVerify:".workspai/reports/workspace-contract-verify-last-run.json",readiness:".workspai/reports/release-readiness-last-run.json",verify:".workspai/reports/workspace-verify-last-run.json",history:".workspai/reports/workspace-intelligence-history.json",agentContext:".workspai/reports/workspace-context-agent.json",agentIndex:".workspai/reports/INDEX.json",agentCustomizationPack:".workspai/reports/agent-customization-pack.json",skillsIndex:".workspai/reports/workspace-skills-index.json",agents:"AGENTS.md",explain:".workspai/reports/workspace-explain-last-run.json",intelligenceRun:".workspai/reports/workspace-intelligence-run-last-run.json",evaluationLive:".workspai/reports/workspace-intelligence-evaluation-live.json",evaluationLastRun:".workspai/reports/workspace-intelligence-evaluation-last-run.json",verifiedGoalStatus:".workspai/reports/verified-goal-last-run.json",repairTransaction:".workspai/reports/workspace-repair-last-run.json"},s={model:"workspace-model.v1",knowledgeGraph:"workspace-knowledge-graph.v1",snapshot:"workspace-model-snapshot.v1",diff:"workspace-model-diff.v1",impact:"workspace-impact.v1",analyze:"rapidkit-analyze-v1",doctor:"doctor-workspace-evidence-v1",contractVerify:"workspace-contract-verify.v1",readiness:"release-readiness-v1",verify:"workspace-verify.v1",history:"workspace-intelligence-history.v1",agentContext:"workspace-context.v1",agentIndex:"rapidkit-agent-reports-index.v1",agentCustomizationPack:"rapidkit-agent-customization-pack.v1",skillsIndex:"workspace-skills-index.v1",agents:null,explain:"workspace-explain.v1",intelligenceRun:"workspace-intelligence-run.v1",evaluationLive:"workspace-intelligence-evaluation.v1",evaluationLastRun:"workspace-intelligence-evaluation.v1",verifiedGoalStatus:"workspai.verified-goal-status.v1",repairTransaction:"workspai.workspace-repair-transaction.v1"},c={model:"contracts/workspace-intelligence/workspace-model.v1.json",knowledgeGraph:"contracts/workspace-intelligence/workspace-knowledge-graph.v1.json",snapshot:"contracts/workspace-intelligence/workspace-model-snapshot.v1.json",diff:"contracts/workspace-intelligence/workspace-model-diff.v1.json",impact:"contracts/workspace-intelligence/workspace-impact.v1.json",analyze:"contracts/analyze-last-run.v1.json",doctor:"contracts/doctor-workspace-evidence.v1.json",contractVerify:"contracts/workspace-intelligence/workspace-contract-verify.v1.json",readiness:"contracts/release-readiness.v1.json",verify:"contracts/workspace-intelligence/workspace-verify.v1.json",history:"contracts/workspace-intelligence/workspace-intelligence-history.v1.json",agentContext:"contracts/workspace-intelligence/workspace-context.v1.json",agentIndex:"contracts/workspace-intelligence/agent-reports-index.v1.json",agentCustomizationPack:"contracts/workspace-intelligence/agent-customization-pack-report.v1.json",skillsIndex:"contracts/workspace-intelligence/workspace-skills-index.v1.json",agents:null,explain:"contracts/workspace-intelligence/workspace-explain.v1.json",intelligenceRun:"contracts/workspace-intelligence/workspace-intelligence-run.v1.json",evaluationLive:"contracts/workspace-intelligence/workspace-intelligence-evaluation.v1.json",evaluationLastRun:"contracts/workspace-intelligence/workspace-intelligence-evaluation.v1.json",verifiedGoalStatus:"contracts/workspace-intelligence/verified-goal-status.v1.json",repairTransaction:"contracts/workspace-intelligence/workspace-repair-transaction.v1.json"},l={goalIndex:{artifactPath:".workspai/goals/index.json",schemaVersion:"workspai.goal-index.v1",contractPath:"contracts/workspace-intelligence/goal-index.v1.json",producerCommands:[["goal"]]},projectWorkspaceLink:{artifactPath:".workspai/workspace-link.local.json",schemaVersion:"project-workspace-link.v1",contractPath:"contracts/project-workspace-link.v1.json",producerCommands:[["adopt"],["import"],["project","workspace","relink"],["workspace","sync"]]},projectContextAgent:{artifactPath:".workspai/reports/project-context-agent.json",schemaVersion:"project-context-agent.v1",contractPath:"contracts/workspace-intelligence/project-context-agent.v1.json",producerCommands:[["adopt"],["import"],["workspace","sync"],["workspace","agent-sync","--write"]]},projectKnowledgeGraphReference:{artifactPath:".workspai/reports/project-knowledge-graph-reference.json",schemaVersion:"project-knowledge-graph-reference.v1",contractPath:"contracts/workspace-intelligence/project-knowledge-graph-reference.v1.json",producerCommands:[["adopt"],["import"],["workspace","model"],["workspace","sync"],["workspace","intelligence","run"]]},projectAgentEntry:{artifactPath:".workspai/agent-entry.v1.json",schemaVersion:"workspai.agent-entry.v1",contractPath:"contracts/workspace-intelligence/project-agent-entry.v1.json",producerCommands:[["adopt"],["import"],["workspace","sync"],["workspace","agent-sync","--write"]]},workspaceContract:{artifactPath:".workspai/workspace.contract.json",schemaVersion:1,contractPath:"contracts/workspace-contract.v1.json",producerCommands:[["workspace","sync"],["workspace","contract","sync"]]},workspaceModelCache:{artifactPath:".workspai/cache/workspace-model.v1.json",schemaVersion:"workspace-model-cache.v1",contractPath:"contracts/workspace-model-cache.v1.json",producerCommands:[["workspace","model"]]},workspaceRegistry:{artifactPath:".workspai/workspace-registry.v1.json",schemaVersion:"workspace-registry.v1",contractPath:"contracts/workspace-registry.v1.json",producerCommands:[["workspace","sync"]]},compatibilityMatrix:{artifactPath:".workspai/compatibility-matrix.json",schemaVersion:"rapidkit.compatibility-matrix.v1",contractPath:"contracts/compatibility-matrix.v1.json",producerCommands:[["bootstrap"]]},doctorWorkspaceCache:{artifactPath:".workspai/reports/doctor-workspace-cache.json",schemaVersion:"doctor-workspace-cache-v2",contractPath:"contracts/doctor-workspace-cache.v2.json",producerCommands:[["doctor","workspace"]]},doctorCapabilities:{artifactPath:".workspai/reports/doctor-capabilities.json",schemaVersion:r,contractPath:"contracts/workspace-intelligence/doctor-capabilities.v1.json",producerCommands:[["doctor","capabilities","--write"]]},doctorValidation:{artifactPath:".workspai/reports/doctor-validation-last-run.json",schemaVersion:t,contractPath:"contracts/workspace-intelligence/doctor-validation.v1.json",producerCommands:[["doctor","capabilities","--validate","--write"]]},bootstrapCompliance:{artifactPath:".workspai/reports/bootstrap-compliance.latest.json",schemaVersion:"bootstrap-compliance.v1",contractPath:"contracts/bootstrap-compliance.v1.json",producerCommands:[["bootstrap"]]},mirrorOps:{artifactPath:".workspai/reports/mirror-ops.latest.json",schemaVersion:"mirror-ops.v1",contractPath:"contracts/mirror-ops.v1.json",producerCommands:[["mirror","status"]]},transparencyEvidence:{artifactPath:".workspai/reports/transparency-evidence.latest.json",schemaVersion:"transparency-evidence.v1",contractPath:"contracts/transparency-evidence.v1.json",producerCommands:[["mirror","sync"]]},workspaceShareBundle:{artifactPath:".workspai/reports/share-bundle.json",schemaVersion:"1.1",schemaVersionField:"schema_version",contractPath:"contracts/workspace-share-bundle.v1.json",producerCommands:[["workspace","share"]]},doctorProject:{artifactPath:".workspai/reports/doctor-project-last-run.json",schemaVersion:"doctor-project-evidence-v1",contractPath:"contracts/doctor-project-evidence.v1.json",producerCommands:[["doctor","project"]]},doctorReceipt:{artifactPath:".workspai/reports/doctor-receipt-last-run.json",schemaVersion:"workspai.doctor-receipt.v1",contractPath:"contracts/workspace-intelligence/doctor-receipt.v1.json",producerCommands:[["doctor","workspace"],["doctor","project"]]},projectTestCoverage:{artifactPath:".workspai/reports/project-test-coverage-last-run.json",schemaVersion:"workspai.project-test-coverage.v1",contractPath:"contracts/project-test-coverage.v1.json",producerCommands:[["project","coverage"]]},goalPackLastRun:{artifactPath:".workspai/reports/goal-pack-last-run.json",schemaVersion:"workspai.goal-pack.v1",contractPath:"contracts/workspace-intelligence/goal-pack.v1.json",producerCommands:[["goal"]]},doctorRemediationPlan:{artifactPath:".workspai/reports/doctor-remediation-plan-last-run.json",schemaVersion:"doctor-remediation-plan-v2",contractPath:"contracts/doctor-remediation-plan.v2.json",producerCommands:[["workspace","remediation-plan"]]},artifactRemediationPlan:{artifactPath:".workspai/reports/artifact-remediation-plan-last-run.json",schemaVersion:"artifact-remediation-plan-v1",contractPath:"contracts/artifact-remediation-plan.v1.json",producerCommands:[["workspace","remediation-plan"]]},doctorFixResult:{artifactPath:".workspai/reports/doctor-fix-result-last-run.json",schemaVersion:"rapidkit-doctor-fix-result-v1",contractPath:"contracts/workspace-intelligence/doctor-fix-result.v1.json",producerCommands:[["doctor","workspace"]]},pipelineLastRun:{artifactPath:".workspai/reports/pipeline-last-run.json",schemaVersion:"rapidkit-pipeline-v1",contractPath:"contracts/pipeline-last-run.v1.json",producerCommands:[["pipeline"]]},autopilotReleaseLastRun:{artifactPath:".workspai/reports/autopilot-release-last-run.json",schemaVersion:"autopilot-release-v1",contractPath:"contracts/autopilot-release.v1.json",producerCommands:[["autopilot","release"]]},autopilotReleaseAlias:{artifactPath:".workspai/reports/autopilot-release.json",schemaVersion:"autopilot-release-v1",contractPath:"contracts/autopilot-release.v1.json",producerCommands:[["autopilot","release"]]},workspaceRunLast:{artifactPath:".workspai/reports/workspace-run-last.json",schemaVersion:"workspace-run-v1",contractPath:"contracts/workspace-run-last.v1.json",producerCommands:[["workspace","run"]]},workspaiMcpDesign:{artifactPath:".workspai/reports/workspai-mcp-design.json",schemaVersion:"workspai-mcp-design.v1",contractPath:"contracts/workspace-intelligence/mcp-design.v1.json",producerCommands:[["workspace","agent-sync","--write"]]},workspaceIntelligenceBenchmark:{artifactPath:".workspai/reports/workspace-intelligence-benchmark-last-run.json",schemaVersion:"workspace-intelligence-benchmark.v1",contractPath:"contracts/workspace-intelligence/workspace-intelligence-benchmark.v1.json",producerCommands:[["workspace","graph","benchmark-suite","--write"]]},legacyMcpDesign:{artifactPath:".workspai/reports/rapidkit-mcp-design.json",schemaVersion:"workspai-mcp-design.v1",contractPath:"contracts/workspace-intelligence/mcp-design.v1.json",producerCommands:[["workspace","agent-sync","--write"]]},workspaceWhy:{artifactPath:".workspai/reports/workspace-why-last-run.json",schemaVersion:s.explain,contractPath:c.explain,producerCommands:[["workspace","why"]]},workspaceTrace:{artifactPath:".workspai/reports/workspace-trace-last-run.json",schemaVersion:s.explain,contractPath:c.explain,producerCommands:[["workspace","trace"]]},agentHooks:{artifactPath:".vscode/workspai-agent-hooks.json",schemaVersion:"workspai-agent-hooks.v1",contractPath:"contracts/workspace-intelligence/agent-hooks.v1.json",producerCommands:[["workspace","agent-sync"]]},infraPlan:{artifactPath:".workspai/reports/infra-plan.json",schemaVersion:"rapidkit.infra-plan.v1",contractPath:"contracts/infra-plan.v1.json",producerCommands:[["infra","plan"]]}},h=Object.freeze(Object.fromEntries(Object.entries(l).map(([a,n])=>[a,n.artifactPath]))),u={[o.intelligenceRun]:[["workspace","intelligence","run"]],[o.snapshot]:[["workspace","snapshot"]],[o.history]:[["workspace","feedback","record","--json"]],[o.evaluationLive]:[["workspace","eval","init"],["workspace","eval","record","--json"]],[o.evaluationLastRun]:[["workspace","eval","report","--json"]],[o.verifiedGoalStatus]:[["workspace","goal","plan"],["workspace","goal","verify"]],[o.repairTransaction]:[["workspace","repair","plan"],["workspace","repair","propose"],["workspace","repair","approve"],["workspace","repair","decide"],["workspace","repair","execute"],["workspace","repair","resume"],["workspace","repair","rollback"],["workspace","repair","cancel"]]},j={analyze:"analyze",workspace:"workspace <action> [subaction] [key] [value]",doctor:"doctor [scope]",readiness:"readiness"},f=["analyze","readiness","doctor","workspace"],C=["model","diff","impact","doctor-evidence","contract-evidence","analyze-evidence","readiness-evidence","verify","context","agent-sync","explain"],P=["sync","baseline"],y={sync:[".workspai/workspace.contract.json",".workspai/workspace-registry.v1.json"],baseline:[o.snapshot]},e=o,d={model:{command:["workspace","model","--json","--write"],produces:[e.model,e.knowledgeGraph]},diff:{command:["workspace","diff","--from",e.snapshot,"--json"],produces:[e.diff]},impact:{command:["workspace","impact","--from",e.diff,"--json"],produces:[e.impact]},"doctor-evidence":{command:["doctor","workspace","--json"],produces:[e.doctor]},"contract-evidence":{command:["workspace","contract","verify","--strict","--json"],produces:[e.contractVerify]},"analyze-evidence":{command:["analyze","--json"],produces:[e.analyze]},"readiness-evidence":{command:["readiness","--json","--skip-verify"],produces:[e.readiness]},verify:{command:["workspace","verify","--from-impact",e.impact,"--json"],produces:[e.verify,e.history]},context:{command:["workspace","context","--for-agent","--json","--write","--no-agent-sync"],produces:[e.agentContext]},"agent-sync":{command:["workspace","agent-sync","--write","--json","--preset","enterprise"],produces:[e.agentIndex,e.agentCustomizationPack,e.skillsIndex,e.agents]},explain:{command:["workspace","explain","release-blocked","--json","--write"],produces:[e.explain]}};function I(a){return d[a]}export{r as a,k as b,t as c,w as d,o as e,s as f,c as g,l as h,h as i,u as j,j as k,f as l,C as m,P as n,y as o,d as p,I as q};
@@ -0,0 +1,4 @@
1
+ import {e,d,i,a,b,c}from'./chunk-UTV4DTNM.js';import m from'fs';import y from'path';var E=64*1024,w=1024*1024,_="workspace-activity-monitor-snapshot.v1",T="workspace-activity-monitor-fleet.v1";function N(n){if(!n||typeof n!="object")return false;let s=n;return s.schemaVersion===a&&typeof s.eventId=="string"&&typeof s.runId=="string"&&Number.isInteger(s.sequence)&&Number(s.sequence)>0&&typeof s.timestamp=="string"&&!!s.scope&&typeof s.scope?.id=="string"&&typeof s.scope?.label=="string"&&["ephemeral-project","project","workspace"].includes(String(s.scope?.kind))&&typeof s.scope?.portable=="boolean"&&b.includes(s.kind)&&c.includes(s.status)&&(s.attempt===void 0||Number.isInteger(s.attempt)&&s.attempt>0)&&(s.origin===void 0||typeof s.origin.id=="string"&&typeof s.origin.label=="string"&&["project","workspace-root"].includes(s.origin.kind))&&typeof s.message=="string"}function R(n,s){try{let o=m.statSync(n).size,a;if(o<=E+w)a=m.readFileSync(n,"utf8");else {let t=m.openSync(n,"r");try{let r=Buffer.allocUnsafe(E),d=Buffer.allocUnsafe(w),e=m.readSync(t,r,0,r.length,0),i=Math.max(0,o-d.length),p=m.readSync(t,d,0,d.length,i),c=r.subarray(0,e).toString("utf8"),u=d.subarray(0,p).toString("utf8"),l=u.indexOf(`
2
+ `),g=l>=0?u.slice(l+1):"";a=`${c.endsWith(`
3
+ `)?c:`${c}
4
+ `}${g}`,s.push(`Bounded replay window applied to ${y.basename(n)}.`);}finally{m.closeSync(t);}}return a.split(/\r?\n/).filter(Boolean).flatMap(t=>{try{let r=JSON.parse(t);return N(r)?[r]:[]}catch{return s.push(`Ignored an incomplete activity record in ${y.basename(n)}.`),[]}})}catch(o){return s.push(`Unable to read ${y.basename(n)}: ${o instanceof Error?o.message:String(o)}`),[]}}function W(n,s,o){let a=s.get(n.fromBlockId),t=s.get(n.toBlockId);return !a||!t?"planned":t.status!=="planned"?t.status:o!=="running"&&o!=="planned"?"skipped":a.status==="succeeded"||a.status==="warned"?"running":a.status==="failed"?"failed":a.status==="blocked"?"blocked":a.status==="cancelled"?"cancelled":"planned"}function O(n){let s=e(n.targetPath??process.cwd(),{env:n.env}),o=[],a=y.join(s.statePath,"runs"),t=[];try{t=m.readdirSync(a,{withFileTypes:true}).filter(e=>e.isFile()&&e.name.endsWith(".ndjson")).map(e=>{let i=y.join(a,e.name);return {name:e.name,mtimeMs:m.statSync(i).mtimeMs}}).sort((e,i)=>i.mtimeMs-e.mtimeMs);}catch(e){e.code!=="ENOENT"&&o.push(e instanceof Error?e.message:String(e));}n.runId&&(t=t.filter(e=>e.name===`${n.runId}.ndjson`)),t=t.slice(0,Math.max(1,n.maxRuns??25));let r=t.flatMap(e=>R(y.join(a,e.name),o)).sort((e,i)=>e.timestamp.localeCompare(i.timestamp)||e.sequence-i.sequence),d=Math.max(100,n.maxEvents??2e4);return {resolvedScope:s,events:r.slice(-d),diagnostics:o}}function f(n){let s=new Map,o=new Map,a=new Map;for(let t of n.events){let r=s.get(t.runId);if(!r){let d=Array.isArray(t.attributes?.command)?t.attributes.command.filter(e=>typeof e=="string"):[];r={runId:t.runId,...t.parentRunId?{parentRunId:t.parentRunId}:{},...Number.isInteger(Number(t.attributes?.pid))&&Number(t.attributes?.pid)>0?{pid:Number(t.attributes?.pid)}:{},...t.origin?{origin:t.origin}:{},command:d,status:t.status,startedAt:t.timestamp,updatedAt:t.timestamp,blocks:[],edges:[],touches:[],artifacts:[],warnings:[]},s.set(t.runId,r),o.set(t.runId,new Map),a.set(t.runId,new Map);}if(r.updatedAt=t.timestamp,t.kind.startsWith("run.")){if(r.status=t.status,t.kind==="run.started"&&Array.isArray(t.attributes?.command)){let e=t.attributes?.command;r.command=e.filter(i=>typeof i=="string");}let d=Number(t.attributes?.pid);t.kind==="run.started"&&Number.isInteger(d)&&d>0&&(r.pid=d),t.origin&&(r.origin=t.origin),t.durationMs!==void 0&&(r.durationMs=t.durationMs);}if(t.blockId&&t.kind.startsWith("block.")){let d=o.get(t.runId),e=d.get(t.blockId),i=Number(t.attributes?.order),p=e?.attempt??0,c=t.kind==="block.planned"||t.kind==="block.skipped"&&p===0?void 0:t.kind==="block.started"&&e?.status!=="running"?p+1:Math.max(1,p),u=t.attempt??c,l=[...e?.attempts??[]];if(u!==void 0){let g=l.findIndex(B=>B.attempt===u),v=g>=0?l[g]:void 0,b={attempt:u,status:t.status,startedAt:v?.startedAt??t.timestamp,updatedAt:t.timestamp,...t.progress?{progress:t.progress}:v?.progress?{progress:v.progress}:{},...t.durationMs!==void 0?{durationMs:t.durationMs}:v?.durationMs!==void 0?{durationMs:v.durationMs}:{}};g>=0?l[g]=b:l.push(b);}d.set(t.blockId,{id:t.blockId,label:t.kind==="block.planned"||!e?t.message||t.blockId:e.label,status:t.status,order:Number.isFinite(i)?i:e?.order??d.size+1,...t.parentSpanId?{parentId:t.parentSpanId}:e?.parentId?{parentId:e.parentId}:{},...t.progress?{progress:t.progress}:e?.progress?{progress:e.progress}:{},...t.durationMs!==void 0?{durationMs:t.durationMs}:e?.durationMs!==void 0?{durationMs:e.durationMs}:{},...typeof t.attributes?.layoutHint=="string"?{layoutHint:t.attributes.layoutHint}:e?.layoutHint?{layoutHint:e.layoutHint}:{},...typeof t.attributes?.group=="string"?{group:t.attributes.group}:e?.group?{group:e.group}:{},updatedAt:t.timestamp,...u!==void 0?{attempt:u}:e?.attempt?{attempt:e.attempt}:{},attempts:l});}if(t.kind==="edge.declared"&&t.edge){let d=a.get(t.runId),e=Number(t.attributes?.order);d.set(t.edge.id,{id:t.edge.id,fromBlockId:t.edge.fromBlockId,toBlockId:t.edge.toBlockId,kind:t.edge.kind,status:"planned",order:Number.isFinite(e)?e:d.size+1,updatedAt:t.timestamp});}(t.kind==="touch.observed"||t.kind==="touch.planned")&&(r.touches.push({locator:t.target?.locator??t.message,...t.target?.operation?{operation:t.target.operation}:{},at:t.timestamp}),r.touches=r.touches.slice(-20)),t.kind==="artifact.published"&&(r.artifacts.push({locator:t.target?.locator??t.message,at:t.timestamp}),r.artifacts=r.artifacts.slice(-20)),t.kind==="warning.detected"&&(r.warnings.push(t.message),r.warnings=r.warnings.slice(-20));}for(let[t,r]of s){r.blocks=[...o.get(t)?.values()??[]].sort((e,i)=>e.order-i.order||e.id.localeCompare(i.id));let d=o.get(t)??new Map;r.edges=[...a.get(t)?.values()??[]].map(e=>({...e,status:W(e,d,r.status),updatedAt:d.get(e.toBlockId)?.updatedAt??d.get(e.fromBlockId)?.updatedAt??e.updatedAt})).sort((e,i)=>e.order-i.order||e.id.localeCompare(i.id));}return {schemaVersion:_,generatedAt:new Date().toISOString(),scope:n.resolvedScope.scope,runs:[...s.values()].sort((t,r)=>r.updatedAt.localeCompare(t.updatedAt)),diagnostics:[...n.diagnostics??[]]}}function Q(n){let s=Math.max(0,Math.min(n.events.length,Math.floor(n.eventCount)));return f({resolvedScope:n.resolvedScope,events:n.events.slice(0,s),diagnostics:n.diagnostics})}function P(n){try{return process.kill(n,0),true}catch(s){return s.code==="EPERM"}}function x(n,s=P){return {...n,runs:n.runs.map(o=>{if(o.status!=="running"||!o.pid||s(o.pid))return o;let a=Date.parse(o.updatedAt),t=Date.parse(o.startedAt);return {...o,status:"cancelled",orphaned:true,durationMs:Number.isFinite(a)&&Number.isFinite(t)?Math.max(0,a-t):o.durationMs,blocks:o.blocks.map(r=>({...r,status:r.status==="running"?"cancelled":r.status==="planned"?"skipped":r.status,attempts:r.attempts.map((d,e,i)=>e===i.length-1&&d.status==="running"?{...d,status:"cancelled"}:d)})),edges:o.edges.map(r=>({...r,status:r.status==="running"?"cancelled":r.status==="planned"?"skipped":r.status}))}})}}function H(n){let s=[];try{s=m.readdirSync(n.stateHome,{withFileTypes:true}).filter(e=>e.isDirectory()).flatMap(e=>{let i=y.join(n.stateHome,e.name,"runs");try{return [{path:i,mtimeMs:m.statSync(i).mtimeMs}]}catch{return []}}).sort((e,i)=>i.mtimeMs-e.mtimeMs).slice(0,Math.min(200,Math.max(16,n.maxScopes*4)));}catch(e){e.code!=="ENOENT"&&n.diagnostics.push(e instanceof Error?e.message:String(e));}let o=s.flatMap(e=>{try{return m.readdirSync(e.path,{withFileTypes:true}).filter(i=>i.isFile()&&i.name.endsWith(".ndjson")&&(!n.runId||i.name===`${n.runId}.ndjson`)).map(i=>{let p=y.join(e.path,i.name);return {filePath:p,mtimeMs:m.statSync(p).mtimeMs}})}catch{return []}}).sort((e,i)=>i.mtimeMs-e.mtimeMs).slice(0,Math.max(n.maxRuns*4,n.maxScopes*2)),a=new Map;for(let e of o)for(let i of R(e.filePath,n.diagnostics))a.has(i.eventId)||a.set(i.eventId,i);let t=[...a.values()].sort((e,i)=>e.timestamp.localeCompare(i.timestamp)||e.sequence-i.sequence),r=[...new Set([...t].reverse().map(e=>e.runId))].slice(0,n.maxRuns),d=new Set(r);return t.filter(e=>d.has(e.runId))}function X(n={}){let s=[],o=Math.max(1,Math.min(100,n.maxRuns??12)),a=Math.max(1,Math.min(50,n.maxScopes??12)),t=H({stateHome:d(n.env),runId:n.runId,maxRuns:o,maxScopes:a,diagnostics:s}),r=Math.max(100,Math.min(5e5,n.maxEvents??5e4));t=t.slice(-r);let d$1=new Map;for(let i of t){let p=d$1.get(i.scope.id)??{scope:i.scope,events:[]};p.events.push(i),d$1.set(i.scope.id,p);}let e=[...d$1.values()].map(i=>x(f({resolvedScope:{scope:i.scope},events:i.events}))).sort((i,p)=>(p.runs[0]?.updatedAt??"").localeCompare(i.runs[0]?.updatedAt??"")||i.scope.label.localeCompare(p.scope.label)).slice(0,a);return {schemaVersion:T,generatedAt:new Date().toISOString(),scopes:e,diagnostics:s}}function Z(n={}){let s=O(n);return x(f({resolvedScope:s.resolvedScope,events:s.events,diagnostics:s.diagnostics}))}function tt(n={}){let s=e(n.targetPath??process.cwd(),{env:n.env}),o=y.join(s.statePath,"runs");return i(o,{maxRuns:n.maxRuns,maxAgeDays:n.maxAgeDays})}var L=new Set(["planned","running"]),j="workspace-activity-board.v1";function $(n){return L.has(n)}function F(n){return n.command.length>0?`workspai ${n.command.join(" ")}`:`run ${n.runId.slice(0,8)}`}function J(n){return n.slice(1).map((s,o)=>{let a=n[o];return {id:`inferred:${a.id}->${s.id}`,fromBlockId:a.id,toBlockId:s.id,kind:s.layoutHint==="gate"?"gate":s.layoutHint==="sink"?"handoff":"sequence",status:D(a.status,s.status),order:o+1,updatedAt:s.updatedAt,inferred:true}})}function D(n,s){return s!=="planned"?s:n==="succeeded"||n==="warned"?"running":n==="failed"||n==="blocked"||n==="cancelled"?n:"planned"}function Y(n,s,o){let a=[...n.blocks].sort((e,i)=>e.order-i.order||e.id.localeCompare(i.id)),t=a.some(e=>e.parentId),r=a.filter(e=>!t||!!e.parentId).map(e=>({...e,root:!e.parentId})),d=n.edges.length>0?n.edges.map(e=>({...e,inferred:false})):J(r);return {run:n,commandLabel:F(n),active:n.status==="running",nodes:r,edges:d,activeBlockCount:r.filter(e=>e.status==="running").length,warningCount:n.warnings.length+r.filter(e=>e.status==="warned").length,scope:s,locationLabel:n.origin&&(n.origin.label!==s.label||o.originLabel!==n.origin.label)?`${o.scopeLabel}/${o.originLabel}`:o.scopeLabel}}function st(n,s={}){let o=Math.max(1,s.maxRuns??6),a=n.schemaVersion==="workspace-activity-monitor-fleet.v1",t=a?n.scopes:[n],r=new Map,d=new Map;for(let c of t){let u=r.get(c.scope.label)??new Set;u.add(c.scope.id),r.set(c.scope.label,u);for(let l of c.runs){if(!l.origin)continue;let g=`${c.scope.id}\0${l.origin.label}`,v=d.get(g)??new Set;v.add(l.origin.id),d.set(g,v);}}let e=t.flatMap(c=>c.runs.map(u=>{let l=(r.get(c.scope.label)?.size??0)>1?`${c.scope.label}#${c.scope.id.slice(-4)}`:c.scope.label,g=u.origin?`${c.scope.id}\0${u.origin.label}`:void 0,v=u.origin?(d.get(g??"")?.size??0)>1?`${u.origin.label}#${u.origin.id.slice(-4)}`:u.origin.label:void 0;return Y(u,c.scope,{scopeLabel:l,originLabel:v})})).sort((c,u)=>c.active!==u.active?c.active?-1:1:u.run.updatedAt.localeCompare(c.run.updatedAt)),i=(s.activeOnly?e.filter(c=>c.active):e).slice(0,o),p=i.find(c=>c.run.runId===s.selectedRunId)?.run.runId??i.find(c=>c.active)?.run.runId??i[0]?.run.runId;return {schemaVersion:j,scopeLabel:a?"Global activity":t[0]?.scope.label??"activity",generatedAt:n.generatedAt,activeRunCount:e.filter(c=>c.active).length,healthyRunCount:e.filter(c=>c.run.status==="succeeded").length,warningRunCount:e.filter(c=>c.run.status==="warned"||c.warningCount>0).length,failedRunCount:e.filter(c=>c.run.status==="failed").length,...p?{selectedRunId:p}:{},runs:i,diagnostics:a?[...n.diagnostics,...t.flatMap(c=>c.diagnostics)]:n.diagnostics,global:a,scopeCount:t.length}}function it(n,s,o){return n.edges.find(a=>a.fromBlockId===s&&a.toBlockId===o)}function rt(n){return n.runs.map(s=>s.run.runId)}function ot(n){return n.runs.some(s=>s.active||s.nodes.some(o=>$(o.status))||s.edges.some(o=>o.status==="running"))}export{_ as a,T as b,O as c,Q as d,X as e,Z as f,tt as g,j as h,st as i,it as j,rt as k,ot as l};
@@ -1 +1 @@
1
- export{b as buildWorkspaceManifest,f as createProject,a as initializeStandaloneGitRepository,g as registerWorkspaceAtPath,d as resolvePythonFreeFallbackProfile,c as syncWorkspaceFoundationFiles,e as writeWorkspaceLauncher}from'./chunk-JRP6WP5C.js';
1
+ export{b as buildWorkspaceManifest,f as createProject,a as initializeStandaloneGitRepository,g as registerWorkspaceAtPath,d as resolvePythonFreeFallbackProfile,c as syncWorkspaceFoundationFiles,e as writeWorkspaceLauncher}from'./chunk-THIG2YQP.js';
@@ -1 +1 @@
1
- export{a as DOCTOR_WORKSPACE_REPORT_PATH,n as applyEnvKeyAddFix,j as applyFileAppendFix,k as applyFileCopyFix,i as applyFileCreateFix,m as applyJsonEditFix,o as applyMakefileTargetFix,h as applyPackageScriptFix,f as assertOperationPathInsideProject,g as assertOperationPathInsideProjectResolved,e as buildRepairOperationIdentity,q as computeDoctorFixAwareExitCode,p as computeDoctorGateExitCode,l as decodeJsonPointerSegment,d as parseInternalRepairCommand,c as parsePackageScriptFix,b as resolveDoctorPolicyProfile,r as runDoctor}from'./chunk-QGAPGZPL.js';
1
+ export{a as DOCTOR_WORKSPACE_REPORT_PATH,n as applyEnvKeyAddFix,j as applyFileAppendFix,k as applyFileCopyFix,i as applyFileCreateFix,m as applyJsonEditFix,o as applyMakefileTargetFix,h as applyPackageScriptFix,f as assertOperationPathInsideProject,g as assertOperationPathInsideProjectResolved,e as buildRepairOperationIdentity,q as computeDoctorFixAwareExitCode,p as computeDoctorGateExitCode,l as decodeJsonPointerSegment,d as parseInternalRepairCommand,c as parsePackageScriptFix,b as resolveDoctorPolicyProfile,r as runDoctor}from'./chunk-KQ2TMI26.js';
@@ -1 +1 @@
1
- export{f as GOAL_INDEX_PATH,e as GOAL_INDEX_SCHEMA_VERSION,k as buildGoalLifecycleResult,l as inspectGoalLifecycle,p as linkGoalRepairTransaction,n as prepareGoalVerification,m as transitionGoalLifecycle,o as verifyGoalLifecycle}from'./chunk-HJLGXFMK.js';
1
+ export{f as GOAL_INDEX_PATH,e as GOAL_INDEX_SCHEMA_VERSION,k as buildGoalLifecycleResult,l as inspectGoalLifecycle,p as linkGoalRepairTransaction,n as prepareGoalVerification,m as transitionGoalLifecycle,o as verifyGoalLifecycle}from'./chunk-GIQ4SDRJ.js';