workspai 0.68.0 → 0.69.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 (175) hide show
  1. package/README.md +38 -18
  2. package/contracts/cli-runtime-command-inventory.v1.snapshot.json +459 -0
  3. package/contracts/extension-cli-compatibility.v1.json +11 -0
  4. package/contracts/published-contract-catalog.v1.json +55 -0
  5. package/contracts/runtime-command-surface.v1.json +282 -0
  6. package/contracts/workspace-intelligence/architecture-change-lease.v1.json +50 -0
  7. package/contracts/workspace-intelligence/architecture-surprise-report.v1.json +46 -0
  8. package/contracts/workspace-intelligence/change-operation-result.v1.json +43 -0
  9. package/contracts/workspace-intelligence/decision-checkpoint.v1.json +18 -0
  10. package/contracts/workspace-intelligence/decision-event.v1.json +134 -0
  11. package/contracts/workspace-intelligence/decision-transaction.v1.json +29 -0
  12. package/contracts/workspace-intelligence/goal-index.v1.json +13 -0
  13. package/contracts/workspace-intelligence/goal-pack.v1.json +2 -1
  14. package/contracts/workspace-intelligence/predicted-architecture-change.v1.json +34 -0
  15. package/contracts/workspace-intelligence/proof-carrying-change-capsule-export.v1.json +14 -0
  16. package/contracts/workspace-intelligence/proof-carrying-change-capsule-validation.v1.json +16 -0
  17. package/contracts/workspace-intelligence/proof-carrying-change-capsule.v1.json +62 -0
  18. package/contracts/workspace-intelligence/proof-carrying-change-list.v1.json +80 -0
  19. package/contracts/workspace-intelligence/workspace-knowledge-graph-change-overlay.v1.json +9 -1
  20. package/dist/analyze-GPYPXXRT.js +1 -0
  21. package/dist/{artifact-remediation-plan-I7IKC5MR.js → artifact-remediation-plan-JHHZ4L24.js} +1 -1
  22. package/dist/autopilot-release-FL47VMF7.js +1 -0
  23. package/dist/capabilities-command-MYSLJIYS.js +1 -0
  24. package/dist/chunk-2LZWBUJD.js +1 -0
  25. package/dist/{chunk-7DDEMDG2.js → chunk-37ZLNFV5.js} +2 -2
  26. package/dist/{chunk-OFYY4725.js → chunk-3G5FF2JZ.js} +1 -1
  27. package/dist/chunk-3HFFKW4Q.js +2 -0
  28. package/dist/{chunk-BHM6RHTA.js → chunk-3WHE7V4M.js} +1 -1
  29. package/dist/chunk-A3MYO55A.js +3 -0
  30. package/dist/chunk-ABMB6MJT.js +1 -0
  31. package/dist/chunk-AD4ZY3RF.js +12 -0
  32. package/dist/chunk-BM2F5C4J.js +1 -0
  33. package/dist/chunk-COICGD62.js +1 -0
  34. package/dist/{chunk-4WVOAX2V.js → chunk-DWL3PPLA.js} +1 -1
  35. package/dist/{chunk-3Z4SVBMR.js → chunk-EBEAJIBI.js} +1 -1
  36. package/dist/chunk-EBQS5T7Q.js +7 -0
  37. package/dist/{chunk-5OV2WXAR.js → chunk-EG6EZ7HW.js} +1 -1
  38. package/dist/chunk-ERVWW5HX.js +1 -0
  39. package/dist/chunk-EZPLMAW2.js +1 -0
  40. package/dist/chunk-FIK343LI.js +1 -0
  41. package/dist/chunk-GSSJJS5M.js +6 -0
  42. package/dist/{chunk-TMRCPT7S.js → chunk-GYN6RPNU.js} +1 -1
  43. package/dist/{chunk-6E2Y3XGT.js → chunk-HCFOVANQ.js} +1 -1
  44. package/dist/chunk-I3UCODXU.js +1 -0
  45. package/dist/{chunk-3BMYMZQB.js → chunk-IGJA6GBQ.js} +1 -1
  46. package/dist/{chunk-FX5J6JCK.js → chunk-IVYPC36J.js} +1 -1
  47. package/dist/chunk-K33JJVQZ.js +2 -0
  48. package/dist/{chunk-KDY4X7SQ.js → chunk-M37ALD4V.js} +1 -1
  49. package/dist/{chunk-3XF7O66C.js → chunk-MAWHHHU3.js} +5 -5
  50. package/dist/chunk-MBICKDYP.js +1 -0
  51. package/dist/{chunk-QMQBX3RV.js → chunk-MGL6DBOR.js} +1 -1
  52. package/dist/chunk-MHQHRMKU.js +5 -0
  53. package/dist/{chunk-2C5XJBYI.js → chunk-N2Q4MSSP.js} +64 -64
  54. package/dist/chunk-N4B2M44I.js +1 -0
  55. package/dist/chunk-NSH7TTSV.js +1 -0
  56. package/dist/chunk-O5XQP5E7.js +1 -0
  57. package/dist/chunk-ODK4LCEL.js +1 -0
  58. package/dist/chunk-OU3BBWH5.js +49 -0
  59. package/dist/chunk-OZXCNVGW.js +2 -0
  60. package/dist/{chunk-SLFOUSRW.js → chunk-QYEQVNBF.js} +1 -1
  61. package/dist/chunk-RVOW3BHQ.js +2 -0
  62. package/dist/chunk-TKXRP2B4.js +1 -0
  63. package/dist/chunk-UNXG3ZFV.js +1 -0
  64. package/dist/chunk-UW4SESKD.js +2 -0
  65. package/dist/{chunk-2MTJWPQ4.js → chunk-V52R2W2Q.js} +1 -1
  66. package/dist/chunk-V6TIT6M3.js +157 -0
  67. package/dist/chunk-VNKAISFE.js +8 -0
  68. package/dist/chunk-W6WRT77T.js +1 -0
  69. package/dist/chunk-WHR5SL33.js +4 -0
  70. package/dist/{chunk-IXXQMD34.js → chunk-WZ5V5U2K.js} +1 -1
  71. package/dist/chunk-XPGCFVGC.js +4 -0
  72. package/dist/chunk-YKY4JFCF.js +1 -0
  73. package/dist/{chunk-VIN7NJW3.js → chunk-YWZBGSFE.js} +3 -3
  74. package/dist/chunk-YZL7ZY7J.js +2 -0
  75. package/dist/{create-U5PQHOZ4.js → create-GWBQ74ZI.js} +1 -1
  76. package/dist/doctor-OQAXSMEM.js +1 -0
  77. package/dist/goal-lifecycle-YWBVQ2DF.js +1 -0
  78. package/dist/goal-pack-KUXPZVNO.js +1 -0
  79. package/dist/index.d.ts +35 -2
  80. package/dist/index.js +239 -239
  81. package/dist/pipeline-PGB5TEV3.js +5 -0
  82. package/dist/{project-agent-entry-MH7364BE.js → project-agent-entry-H3JAGNLS.js} +1 -1
  83. package/dist/{project-intelligence-lens-ZCCHUKVI.js → project-intelligence-lens-7NMKHV5N.js} +1 -1
  84. package/dist/{project-test-coverage-JPWTBSSJ.js → project-test-coverage-3DKZKLWY.js} +1 -1
  85. package/dist/proof-carrying-change-QFH7WI2E.js +1 -0
  86. package/dist/verified-goal-7XHRWYSE.js +1 -0
  87. package/dist/{workspace-B33BFZZ3.js → workspace-TJHCETBV.js} +1 -1
  88. package/dist/{workspace-agent-sync-T3MJO2MX.js → workspace-agent-sync-Z35NTXCB.js} +1 -1
  89. package/dist/{workspace-archive-NOSGRKRZ.js → workspace-archive-OSMU3CK6.js} +1 -1
  90. package/dist/{workspace-context-KOCEP4MJ.js → workspace-context-KNJQUJWC.js} +1 -1
  91. package/dist/{workspace-contract-MQ3QE52V.js → workspace-contract-VIUQT5SZ.js} +1 -1
  92. package/dist/workspace-explain-HM6GMK26.js +1 -0
  93. package/dist/workspace-explain-contract-KV7RTEJU.js +1 -0
  94. package/dist/{workspace-feedback-3YLIUFQ7.js → workspace-feedback-YSPEGCON.js} +1 -1
  95. package/dist/{workspace-foundation-O7O3QIS4.js → workspace-foundation-PLXFPI3J.js} +1 -1
  96. package/dist/{workspace-graph-stream-XTGGBD7D.js → workspace-graph-stream-FNRQ2FTB.js} +1 -1
  97. package/dist/workspace-graph-token-efficiency-WNAFAN2F.js +1 -0
  98. package/dist/{workspace-history-7HDZZ4G5.js → workspace-history-HDDFG6LH.js} +1 -1
  99. package/dist/{workspace-intelligence-TFEQBPUP.js → workspace-intelligence-QLSD5EEV.js} +1 -1
  100. package/dist/{workspace-intelligence-benchmark-PLVUBGWO.js → workspace-intelligence-benchmark-S5OXVNLC.js} +1 -1
  101. package/dist/{workspace-intelligence-evaluation-OJIQS5SN.js → workspace-intelligence-evaluation-QDSOOUHH.js} +1 -1
  102. package/dist/{workspace-intelligence-runner-6ZAV6RO4.js → workspace-intelligence-runner-4EW4T2OW.js} +1 -1
  103. package/dist/workspace-intelligence-runtime-registry-ZLPF7BAY.js +1 -0
  104. package/dist/{workspace-knowledge-graph-AUXYL3L6.js → workspace-knowledge-graph-EEOW5VAJ.js} +1 -1
  105. package/dist/workspace-knowledge-graph-change-overlay-FIIAFLO6.js +1 -0
  106. package/dist/{workspace-knowledge-graph-contract-X52KXBXJ.js → workspace-knowledge-graph-contract-FVX5T7SU.js} +1 -1
  107. package/dist/{workspace-knowledge-graph-query-A7TKONWY.js → workspace-knowledge-graph-query-WHCGPBGS.js} +1 -1
  108. package/dist/workspace-knowledge-graph-snapshot-X347REDB.js +1 -0
  109. package/dist/workspace-mcp-serve-NQ42PE2I.js +3 -0
  110. package/dist/{workspace-model-GVXNLSQM.js → workspace-model-NCOOY5LC.js} +1 -1
  111. package/dist/{workspace-onboarding-ECZ2KJ2A.js → workspace-onboarding-JNC7ZFMR.js} +1 -1
  112. package/dist/{workspace-readme-6N5Y2ZSJ.js → workspace-readme-OV2ADTLW.js} +2 -2
  113. package/dist/{workspace-registry-summary-5SFBTRGQ.js → workspace-registry-summary-ONT4VOJX.js} +1 -1
  114. package/dist/{workspace-repair-engine-CKJCTWKX.js → workspace-repair-engine-WMJCYWO4.js} +2 -2
  115. package/dist/workspace-run-3S35MDX6.js +1 -0
  116. package/dist/{workspace-verify-D3QTMAUI.js → workspace-verify-MLABQUWK.js} +1 -1
  117. package/dist/{workspace-watch-XYJEW2Z2.js → workspace-watch-MJOG5AZ3.js} +1 -1
  118. package/docs/README.md +2 -0
  119. package/docs/ci-workflows.md +1 -1
  120. package/docs/commands-reference.md +23 -0
  121. package/docs/contracts/ARTIFACT_CATALOG.md +37 -18
  122. package/docs/contracts/COMMAND_OWNERSHIP_MATRIX.md +17 -0
  123. package/docs/contracts/PROOF_CARRYING_CHANGE_CONTRACT_PLAN.md +65 -0
  124. package/docs/proof-carrying-change.implementation.v1.json +118 -0
  125. package/docs/proof-carrying-change.md +202 -0
  126. package/package.json +1 -1
  127. package/dist/analyze-JDEWUBC6.js +0 -1
  128. package/dist/autopilot-release-OELUFNLL.js +0 -1
  129. package/dist/capabilities-command-RAAYENQ6.js +0 -1
  130. package/dist/chunk-2KX6KHEC.js +0 -1
  131. package/dist/chunk-3KU3YUWD.js +0 -2
  132. package/dist/chunk-3NF3M3RE.js +0 -1
  133. package/dist/chunk-3OGPTLI2.js +0 -1
  134. package/dist/chunk-5ME4W4LN.js +0 -1
  135. package/dist/chunk-5XUAAQSV.js +0 -5
  136. package/dist/chunk-5YZ2W57R.js +0 -8
  137. package/dist/chunk-7DZNZ3GM.js +0 -3
  138. package/dist/chunk-BG6IX6HA.js +0 -1
  139. package/dist/chunk-BMAFHX6A.js +0 -1
  140. package/dist/chunk-BUYLM6QV.js +0 -1
  141. package/dist/chunk-C2VTO5WT.js +0 -2
  142. package/dist/chunk-CPR2CMOY.js +0 -1
  143. package/dist/chunk-CSZPE637.js +0 -2
  144. package/dist/chunk-DFVG4DDZ.js +0 -6
  145. package/dist/chunk-EHLGPLIU.js +0 -1
  146. package/dist/chunk-FPDH3N3A.js +0 -7
  147. package/dist/chunk-GVQKAINC.js +0 -49
  148. package/dist/chunk-IKUFNK46.js +0 -2
  149. package/dist/chunk-JYMO7QXQ.js +0 -1
  150. package/dist/chunk-KY2GOSO5.js +0 -1
  151. package/dist/chunk-LEOFD3W5.js +0 -12
  152. package/dist/chunk-LPCZHKD5.js +0 -1
  153. package/dist/chunk-N5HPMATQ.js +0 -1
  154. package/dist/chunk-P3622IM5.js +0 -4
  155. package/dist/chunk-Q7UGDNSM.js +0 -1
  156. package/dist/chunk-RVAOJOXA.js +0 -2
  157. package/dist/chunk-TCLKGPXF.js +0 -2
  158. package/dist/chunk-W5VKBDSD.js +0 -157
  159. package/dist/chunk-WRZSQDZV.js +0 -1
  160. package/dist/chunk-Y4Z6CEII.js +0 -1
  161. package/dist/chunk-ZEEV5J4I.js +0 -1
  162. package/dist/chunk-ZGHJIQXL.js +0 -1
  163. package/dist/doctor-D7YI7LSA.js +0 -1
  164. package/dist/goal-lifecycle-BMS6GSIU.js +0 -1
  165. package/dist/goal-pack-RBSVQMMX.js +0 -1
  166. package/dist/pipeline-QOMXH2EK.js +0 -5
  167. package/dist/verified-goal-XUXU2X5H.js +0 -1
  168. package/dist/workspace-explain-DTFCKYXK.js +0 -1
  169. package/dist/workspace-explain-contract-WMREJWHF.js +0 -1
  170. package/dist/workspace-graph-token-efficiency-5LJKQU2J.js +0 -1
  171. package/dist/workspace-intelligence-runtime-registry-UKFB3BI7.js +0 -1
  172. package/dist/workspace-knowledge-graph-change-overlay-XG6FC4IX.js +0 -1
  173. package/dist/workspace-knowledge-graph-snapshot-GPBDAKAU.js +0 -1
  174. package/dist/workspace-mcp-serve-TDUXJUAA.js +0 -3
  175. package/dist/workspace-run-ZZ5WHL7W.js +0 -1
@@ -0,0 +1 @@
1
+ import {b,d}from'./chunk-AD4ZY3RF.js';import {f}from'./chunk-OZXCNVGW.js';import {p,q}from'./chunk-ODK4LCEL.js';import A from'fs-extra';function t(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function S(e){let s=t(e);return !!(s&&s.schemaVersion===q.model&&t(s.workspace)&&Array.isArray(s.projects)&&(t(s.projectTopology)||t(s.graph)))}function W(e){let s=t(e);return !!(s&&s.schemaVersion===q.knowledgeGraph&&t(s.source)&&t(s.workspace)&&Array.isArray(s.entities)&&Array.isArray(s.relations)&&Array.isArray(s.proofs)&&Array.isArray(s.providers)&&t(s.quality))}async function g(e){try{return await A.readJson(e)}catch{return null}}async function I(e){let[s,i]=await Promise.all([f(e,p.model),f(e,p.knowledgeGraph)]);if(!s)return {status:"miss",reason:"missing-model"};if(!i)return {status:"miss",reason:"missing-graph"};let[n,o]=await Promise.all([g(s),g(i)]);if(!S(n))return {status:"miss",reason:"invalid-model"};if(!W(o))return {status:"miss",reason:"invalid-graph"};if(o.proofs.some(r=>r.freshness==="stale"))return {status:"miss",reason:"stale-proof"};try{b(o,n);}catch{return {status:"miss",reason:"source-mismatch"}}let a=o.source.inputs;if(!a)return {status:"miss",reason:"missing-input-fingerprint"};let f$1=a.scopes.filter(r=>r.kind==="workspace"),m=a.scopes.filter(r=>r.kind==="project"),k=n.projects.map(r=>r.name).sort(),w=m.map(r=>r.id).sort(),y=new Set(m.map(r=>r.fileLimit));if(a.schemaVersion!=="workspace-knowledge-graph-inputs.v1"||a.strategy!=="hybrid-git-content-v2"||a.hashAlgorithm!=="sha256"||f$1.length!==1||y.size>1||JSON.stringify(k)!==JSON.stringify(w))return {status:"miss",reason:"invalid-input-fingerprint"};let u;try{u=await d({workspacePath:e,projects:n.projects.map(r=>({id:r.name,path:r.path,...r.absolutePath?{absolutePath:r.absolutePath}:{}})),expected:a});}catch{return {status:"miss",reason:"input-scan-failed"}}return u?{status:"hit",model:n,graph:o,modelPath:s,graphPath:i}:{status:"miss",reason:"live-input-mismatch"}}export{I as a};
@@ -1 +1 @@
1
- import {b}from'./chunk-FPDH3N3A.js';import {c,d,a,b as b$1}from'./chunk-VQZ5PI5J.js';import n from'fs';import o from'path';function _(t){return b({startPath:t})?.workspacePath??null}function k(t){let s=o.resolve(t),p=n.existsSync(o.join(s,c))||n.existsSync(o.join(s,d))||n.existsSync(o.join(s,a,"workspace.json"))||n.existsSync(o.join(s,b$1,"workspace.json")),A=n.existsSync(o.join(s,a,"project.json"))||n.existsSync(o.join(s,a,"context.json"))||n.existsSync(o.join(s,b$1,"project.json"))||n.existsSync(o.join(s,b$1,"context.json"));return p&&!A}export{_ as a,k as b};
1
+ import {b}from'./chunk-EBQS5T7Q.js';import {c,d,a,b as b$1}from'./chunk-VQZ5PI5J.js';import n from'fs';import o from'path';function _(t){return b({startPath:t})?.workspacePath??null}function k(t){let s=o.resolve(t),p=n.existsSync(o.join(s,c))||n.existsSync(o.join(s,d))||n.existsSync(o.join(s,a,"workspace.json"))||n.existsSync(o.join(s,b$1,"workspace.json")),A=n.existsSync(o.join(s,a,"project.json"))||n.existsSync(o.join(s,a,"context.json"))||n.existsSync(o.join(s,b$1,"project.json"))||n.existsSync(o.join(s,b$1,"context.json"));return p&&!A}export{_ as a,k as b};
@@ -0,0 +1,5 @@
1
+ import {c as c$1,b as b$1}from'./chunk-WCJU3CFG.js';import {d,b,e}from'./chunk-ERVWW5HX.js';import {a}from'./chunk-TKXRP2B4.js';import {d as d$2}from'./chunk-S5KTATOU.js';import {a as a$1}from'./chunk-NMXGSVMD.js';import {q as q$1,z as z$1,u as u$1}from'./chunk-KFTJVVJR.js';import {k,m,g,f as f$1}from'./chunk-U5ENEDJA.js';import {f}from'./chunk-OZXCNVGW.js';import {p,t}from'./chunk-ODK4LCEL.js';import {a as a$2}from'./chunk-TQEMLBAG.js';import {c,d as d$1}from'./chunk-25AWHAB5.js';import {e as e$1,g as g$1}from'./chunk-RGNCL5OB.js';import {u,q,t as t$1}from'./chunk-VQZ5PI5J.js';import J from'fs';import w from'path';import T from'chalk';import {execa}from'execa';var ct={"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:[]}}},dt={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$1(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 ct[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=dt[t]?.[e]??[];return n.length>0?n[0]:void 0}}var lt={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=lt[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 pt(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 pt(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 mt(e){return e in qe?qe[e]:null}function ft(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=mt(r);if(!n)return ft(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 gt=new Set(["init","test","build","start"]),yt=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 ht(e){for(let r of e)if(await z(r))return true;return false}async function kt(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$1(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 bt(e){let r=e?.trim();return r?r.startsWith("project:")?r.slice(8).trim()||null:r:null}async function wt(e){let r=w.join(e,p.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:yt,includeHiddenDirs:false,descendIntoMatchedProjects:false,isProjectDir:async(t,n)=>await ht([...u(t,"context.json"),...u(t,"project.json")])?true:w.resolve(t)===w.resolve(n)?false:k(t).length>0})}async function rt(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=bt(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 rt(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$1){let n=await f(e,t.workspaceContract)??q(e,"workspace.contract.json");if(await z(n))try{let d=await St(e,r,t$1,n);if(d.graphStatus!=="missing")return d}catch{return {expanded:t$1,graphStatus:"invalid",expansionDepth:0}}let o=await f(e,".workspai/workspace-dependency-graph.json")??q(e,"workspace-dependency-graph.json");if(!await z(o))return {expanded:t$1,graphStatus:"missing",expansionDepth:0};let s;try{s=await ae(o);}catch{return {expanded:t$1,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$1,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$1=d$2(c,t$1);return {expanded:f$1.reached,graphStatus:"loaded",expansionDepth:f$1.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:{},P=Array.isArray(y.dependsOn)?y.dependsOn.filter(R=>typeof R=="string"):[],$=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 P){let E=c.get(R);E&&(i.has(E)||i.set(E,new Set),i.get(E)?.add(g));}for(let R of $)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$2(i,t);return {expanded:l.reached,graphStatus:"loaded",expansionDepth:l.added}}async function Ct(e,r){if(typeof r=="boolean")return r;let t=t$1(e,"policies.yml").find(s=>J.existsSync(s))??q(e,"policies.yml");if(!await z(t))return true;let n="";try{n=await J.promises.readFile(t,"utf-8");}catch{return true}let o=n.match(/^[\t ]*rules\.enforce_workspace_run_gates:\s*(true|false)\s*(?:#.*)?$/m);return o?o[1]==="true":true}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
+ `);let t=3;return [...e.slice(0,t),...e.slice(-(r-t))].join(`
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$1(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=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.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 kt(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 A=jt(f);return A?execa(A.file,A.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 A=`${l}
4
+ ${h}`,G=Date.now()-y;k=i===124||ge(A)==="timeout"||i===143&&G>=Math.floor(g*.8)?"timeout":ge(A);}}catch(v){let A=typeof v=="object"&&v!==null&&"timedOut"in v&&!!v.timedOut;return {exitCode:A?124:1,command:f,message:A?`Stage timed out after ${g}ms`:v instanceof Error?v.message:"Command execution failed",errorCategory:A?"timeout":"runtime"}}let P=`${l}
5
+ ${h}`.split(/\r?\n/).map(v=>v.trim()).filter(Boolean),$=Ot(P),L=Dt(P),R=Date.now()-y,E=i===124||k==="timeout"||i===143&&R>=Math.floor(g*.8),O=i===0?void 0:E?"timeout":k,M=i===0||!O?void 0:{category:O,exitCode:i,command:f,timedOut:E,timeoutMs:g,...$?{outputExcerpt:$}:{}};return {exitCode:i,command:f,errorCategory:O,healthStatus:S,failureDiagnostic:M,message:E?`Stage timed out after ${g}ms`:i!==0?L?`Stage failed with exit code ${i}: ${L}`:`Stage failed with exit code ${i}`:void 0}}function et(e){try{return JSON.parse(e)}catch{return null}}function Wt(e){switch(e){case "dotnet":return "Install .NET 8+ SDK, then rerun `npx workspai setup dotnet` or `npx workspai init`.";case "go":return "Install Go 1.21+, then rerun `npx workspai setup go` or `npx workspai init`.";case "java":case "jvm-generic":return "Install Java 21+ and Maven/Gradle, then rerun `npx workspai setup java` or `npx workspai init`.";case "node":return "Install Node.js LTS and npm/pnpm/yarn, then rerun `npx workspai setup node` or `npx workspai init`.";case "python":return "Install Python 3.10+ and pip/Poetry, then rerun `npx workspai setup python` or `npx workspai init`.";default:return null}}async function It(e){let r=[],t=await he(["doctor","workspace","--json"],e);if(t.exitCode!==0)r.push({gate:"doctor-workspace",status:"fail",summary:"doctor workspace command failed"});else {let s=et(t.stdout)?.healthScore,u=Number(s?.errors??0);Number.isFinite(u)&&u>0?r.push({gate:"doctor-workspace",status:"fail",summary:`doctor workspace reports ${u} error(s)`}):r.push({gate:"doctor-workspace",status:"pass",summary:"doctor workspace passed"});}let n=await he(["readiness","--json"],e);if(n.exitCode!==0)r.push({gate:"readiness",status:"fail",summary:"readiness command failed"});else {let o=et(n.stdout),s=String(o?.overallStatus??"").toLowerCase();s==="fail"?r.push({gate:"readiness",status:"fail",summary:"readiness overall status is fail"}):s==="warn"?r.push({gate:"readiness",status:"warn",summary:"readiness overall status is warn"}):r.push({gate:"readiness",status:"pass",summary:"readiness overall status is pass"});}return r}var $t=new Set(["dev","stop"]);function Mt(e){let r=e.trim();return !r||$t.has(r.toLowerCase())?false:gt.has(r)?true:/^[a-z][a-z0-9_-]*$/i.test(r)}function tt(e,r,t){let n=I(w.relative(t,r));return (Array.isArray(e.projects)?e.projects:[]).some(s=>{if(!s||typeof s!="object")return false;let u=s,c=[u.relativePath,u.path].filter(m=>typeof m=="string"&&m.length>0).map(m=>I(m));return u.status==="passed"&&(c.includes(n)||c.some(m=>m.endsWith(`/${n}`)))})}function Nt(e,r){return oe(e,r)?.dependencies??[]}function _t(e,r){let t=Math.max(1,Math.min(4,r)),n=Number(e??t);return Number.isFinite(n)?Math.max(1,Math.min(16,Math.trunc(n))):t}async function br(e$1){if(!Mt(e$1.stage))throw new Error(`Unsupported workspace run stage: ${e$1.stage}`);let r=Date.now(),t=w.resolve(e$1.workspacePath);c({blockId:"workspace.run.resolve",status:"running",message:"Resolving workspace project fleet",component:"workspace-run"});let n=await d(t),o=await wt(t),{projects:s,normalizedScope:u}=await xt(t,o,e$1.scope),c$1=e$1.affected===true,m=e$1.blastRadius===true,f=e$1.since?.trim()||"HEAD~1",d$2=c$1?await vt(t,s,f):new Set(s),i,l="not-applicable",h=0,k="all";if(c$1&&m){let p=await Rt(t,o,d$2);i=p.expanded,l=p.graphStatus,h=p.expansionDepth,k="affected+blast-radius";}else c$1?(i=d$2,k="affected"):(i=d$2,k="all");c({blockId:"workspace.run.resolve",status:"succeeded",message:`Resolved ${s.length} project(s)`,component:"workspace-run",attributes:{projects:s.length,selectionMode:k}}),c({blockId:"workspace.run.gates",status:"running",message:"Evaluating workspace run gates",component:"workspace-run"});let S=e$1.stage==="init"||e$1.planOnly===true?false:await Ct(t,e$1.enforceGates),g=S?await It(t):[{gate:"doctor-workspace",status:"skipped",summary:"workspace run gates disabled"},{gate:"readiness",status:"skipped",summary:"workspace run gates disabled"}],y=g.find(p=>p.status==="fail");c({blockId:"workspace.run.gates",status:y?"blocked":"succeeded",message:y?`Blocked by ${y.gate}`:"Workspace run gates passed",component:"workspace-run",attributes:{gates:g}});let P=s.filter(p=>i.has(p)),$=e$1.continueOnError===true||e$1.stage==="init",L=e$1.parallel===true,R=_t(e$1.maxWorkers,P.length),E=P.length,O=0;c({blockId:"workspace.run.execute",status:y?"blocked":"running",message:y?`Execution blocked by ${y.gate}`:`Executing ${e$1.stage} across ${E} project(s)`,component:"workspace-run",progress:{completed:0,total:E},attributes:{stage:e$1.stage,parallel:L,maxWorkers:R}}),e$1.json||console.log(T.gray(`Workspace run (${e$1.stage}) started: ${E} target(s), ${L?`parallel x${R}`:"sequential"}`));let M=new Map;for(let p of o){let b=I(w.relative(t,p)),a=await rt(p),N=s.includes(p),j=N&&i.has(p);M.set(p,{path:p,relativePath:b,projectName:a??(w.basename(b)||w.basename(p)),selected:j,affected:j,status:"skipped",exitCode:null,durationMs:0,reason:j?void 0:N?"not affected":"outside scope",framework:void 0,runtimeDetected:void 0,executionCommand:void 0});}if(y)for(let p of P){let b=M.get(p);b&&(b.status="skipped",b.reason=`blocked by ${y.gate}`);}else {let p=async b=>{let a$1=M.get(b);if(!a$1)return;let N=I(w.relative(t,b));e$1.json||console.log(T.gray(`\u23F3 [${O}/${E}] ${e$1.stage} ${N}`)),a$1.selected=true,a$1.affected=true;let j=Date.now(),W=a(b),D=e$1.runtime?.trim().toLowerCase(),B=W.units.filter(x=>!D||x.runtime===D).map(x=>({unit:x,stage:x.stages.find(F=>F.stage===e$1.stage)})).filter(x=>!!x.stage),Y=B.map(({unit:x,stage:F})=>({unitId:x.id,runtime:x.runtime,role:x.role,root:x.root,manifest:x.manifest,stage:F.stage,command:F.command,status:"planned",exitCode:null,durationMs:0}));if(a$1.runtimeExecutions=Y,e$1.planOnly){a$1.runtimeDetected=B[0]?.unit.runtime,a$1.status="skipped",a$1.reason=B.length>0?`plan only: ${B.length} runtime unit(s)`:D?`no ${D} runtime unit supports stage "${e$1.stage}"`:`no runtime unit supports stage "${e$1.stage}"`,a$1.durationMs=Date.now()-j,O+=1;return}if(W.polyglot||D){if(B.length===0){a$1.status="failed",a$1.reason=D?`No ${D} runtime unit supports stage "${e$1.stage}"`:`No runtime unit supports stage "${e$1.stage}"`,a$1.errorCategory="setup",a$1.errorMessage=a$1.reason,a$1.exitCode=127,a$1.durationMs=Date.now()-j,O+=1;return}let x;for(let C=0;C<B.length;C+=1){let{unit:xe,stage:ve}=B[C],V=Y[C],Re=w.resolve(b,xe.root),ut=Date.now(),de=await Qe(Re),U=await Ze(Re,e$1.stage,xe.runtime,de.framework,{[e$1.stage]:ve.command},de.environmentCommandVariants,de.environment);if(V.durationMs=Date.now()-ut,V.exitCode=U.exitCode,V.status=U.exitCode===0?"passed":"failed",V.reason=U.message,V.errorCategory=U.errorCategory,V.failureDiagnostic=U.failureDiagnostic,U.exitCode!==0&&!x&&(x=U.message??ve.command),U.exitCode!==0&&!$){for(let Se of Y.slice(C+1))Se.status="skipped",Se.reason="stopped after runtime-unit failure";break}}let F=Y.find(C=>C.status==="failed");a$1.runtimeDetected=B[0]?.unit.runtime,a$1.executionCommand=Y.filter(C=>C.status!=="skipped").map(C=>`[${C.runtime}:${C.root}] ${C.command}`).join(" && "),a$1.durationMs=Date.now()-j,a$1.exitCode=F?.exitCode??0,a$1.status=F?"failed":"passed",a$1.reason=F?x??"runtime-unit stage failed":void 0,a$1.errorCategory=F?F.errorCategory??"runtime":void 0,a$1.errorMessage=a$1.reason,a$1.failureDiagnostic=F?.failureDiagnostic,O+=1;return}let{runtime:ie,framework:ue,commandOverrides:st,environmentCommandVariants:at,environment:it}=await Qe(b);a$1.runtimeDetected=ie,a$1.framework=ue;let ce=Ye(b,e$1.stage);if(!ce.supported){a$1.status=ce.shouldFail===false?"skipped":"failed",a$1.reason=ce.reason??`stage "${e$1.stage}" unsupported for project`,a$1.durationMs=Date.now()-j,a$1.exitCode=a$1.status==="failed"?127:null,a$1.status==="failed"&&(a$1.errorCategory="setup",a$1.errorMessage=a$1.reason),O+=1;return}if(e$1.reusePassed&&n){let x=n.stages[e$1.stage]??n.stages[e$1.stage];if(x&&tt(x,b,t)){a$1.status="passed",a$1.reason="reused passed result from workspace-run-last.json",a$1.durationMs=Date.now()-j,a$1.exitCode=0,O+=1,e$1.json||console.log(T.gray(`\u21BA reused passed cache for ${N}`));return}}let we=Nt(ie,ue).filter(x=>x!==e$1.stage);if(we.length>0&&n){let x=we.find(F=>{let C=n.stages[F];return !C||!tt(C,b,t)});if(x){a$1.status="skipped",a$1.reason=`dependency stage "${x}" not satisfied in workspace-run-last.json`,a$1.durationMs=Date.now()-j,a$1.exitCode=null,O+=1;return}}let K=await Ze(b,e$1.stage,ie,ue,st,at,it);if(a$1.executionCommand=K.command,a$1.errorCategory=K.errorCategory,a$1.healthStatus=K.healthStatus,a$1.failureDiagnostic=K.failureDiagnostic,a$1.durationMs=Date.now()-j,a$1.exitCode=K.exitCode,K.exitCode===0?(a$1.status="passed",a$1.reason=void 0):(a$1.status="failed",a$1.reason=K.message||"stage command failed",a$1.errorMessage=K.message),O+=1,!e$1.json){let x=E>0?Math.round(O/E*100):100,F=a$1.status==="passed"?T.green("\u2705"):T.red("\u274C");if(console.log(T.gray(`${F} [${O}/${E}] (${x}%) ${N} ${a$1.durationMs}ms`)),a$1.status==="failed"){a$1.reason&&console.log(T.red(` Reason: ${a$1.reason}`)),a$1.executionCommand&&console.log(T.gray(` Command: ${a$1.executionCommand}`));let C=Wt(a$1.runtimeDetected);C&&a$1.errorCategory==="setup"&&console.log(T.gray(` Hint: ${C}`));}}};if(L&&P.length>1){let b=0,a=false,N=new Array(R).fill(null).map(async()=>{for(;b<P.length;){if(a&&!$)return;let j=b;b+=1;let W=P[j];await p(W),M.get(W)?.status==="failed"&&(a=true);}});if(await Promise.all(N),!$&&a){let j=false;for(let W of P){let D=M.get(W);if(D){if(D.status==="failed"){j=true;continue}j&&D.status==="skipped"&&(D.reason=D.reason||"stopped after failure");}}}}else for(let b of P){await p(b);let a=M.get(b);if(!$&&a?.status==="failed"){let N=P.slice(P.indexOf(b)+1);for(let j of N){let W=M.get(j);W&&(W.status="skipped",W.reason="stopped after failure");}break}}}let v=[];for(let p of o){let b=M.get(p);b&&v.push(b);}let A=v.filter(p=>p.status==="passed").length,G=v.filter(p=>p.status==="failed").length,q=v.filter(p=>p.status==="skipped").length;c({blockId:"workspace.run.execute",status:G>0?"failed":y?"blocked":"succeeded",message:`Workspace run finished: ${A} passed, ${G} failed, ${q} skipped`,component:"workspace-run",progress:{completed:E,total:E,percent:100},attributes:{passed:A,failed:G,skipped:q,stage:e$1.stage}});let ke=e$1.strict===true,nt=G>0||ke&&g.some(p=>p.status==="fail"||p.status==="warn")?1:0,be={schemaVersion:"1.0",workspacePath:t,stage:e$1.stage,generatedAt:new Date().toISOString(),durationMs:Date.now()-r,options:{affected:c$1,blastRadius:m,since:c$1?f:null,parallel:L,maxWorkers:R,continueOnError:$,strict:ke,enforceGates:S,scope:u,reusePassed:e$1.reusePassed===true,planOnly:e$1.planOnly===true,runtime:e$1.runtime?.trim()||null},selection:{mode:k,since:c$1?f:null,scope:u,graphStatus:l,expansionDepth:h},gates:{enforced:S,results:g,blocked:!!y,blockingGate:y?.gate},summary:{projectCount:o.length,selectedCount:P.length,passed:A,failed:G,skipped:q,exitCode:nt},projects:v,enterpriseControls:{jsonReady:true,evidencePath:b}},ot=w.join(t,b);c({blockId:"workspace.run.publish",status:"running",message:"Publishing workspace run evidence",component:"workspace.run"});try{await e(t,be),c({blockId:"workspace.run.publish",status:"succeeded",message:"Workspace run evidence published",component:"workspace.run"}),d$1({workspacePath:t,relativePath:b,blockId:"workspace.run.publish"});}catch(p){throw c({blockId:"workspace.run.publish",status:"failed",message:p instanceof Error?p.message:"Workspace run evidence publish failed",component:"workspace.run"}),p}return e$1.json||(y&&(console.log(T.red(`\u274C Workspace run blocked by ${y.gate}`)),console.log(T.gray(` ${y.summary}`))),console.log(T.cyan(`Workspace run (${e$1.stage}) => passed: ${A}, failed: ${G}, skipped: ${q}`)),console.log(T.gray(`Report: ${ot}`))),be}export{br as a};