workspai 0.49.0 → 0.51.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 (257) hide show
  1. package/README.md +123 -434
  2. package/contracts/analyze-last-run.v1.json +2 -2
  3. package/contracts/artifact-remediation-plan.v1.json +3 -9
  4. package/contracts/autopilot-release.v1.json +2 -0
  5. package/contracts/bootstrap-compliance.v1.json +2 -1
  6. package/contracts/cli-log-event.v1.json +1 -1
  7. package/contracts/cli-runtime-command-inventory.v1.snapshot.json +80 -0
  8. package/contracts/compatibility-matrix.v1.json +2 -0
  9. package/contracts/create-planner-capabilities.v1.json +153 -32
  10. package/contracts/doctor-project-evidence.v1.json +191 -11
  11. package/contracts/doctor-project-scan.v2.json +2 -0
  12. package/contracts/doctor-remediation-plan.v1.json +2 -2
  13. package/contracts/doctor-remediation-plan.v2.json +2 -2
  14. package/contracts/doctor-workspace-cache.v2.json +2 -0
  15. package/contracts/doctor-workspace-evidence.v1.json +189 -10
  16. package/contracts/extension-cli-compatibility.v1.json +10 -1
  17. package/contracts/infra-plan.v1.json +2 -0
  18. package/contracts/ingestion-plan.v1.json +85 -0
  19. package/contracts/ingestion-result.v1.json +59 -0
  20. package/contracts/mirror-ops.v1.json +2 -1
  21. package/contracts/pipeline-last-run.v1.json +2 -2
  22. package/contracts/private-product-manifest.v1.json +2 -0
  23. package/contracts/product-factory-plan.v1.json +2 -0
  24. package/contracts/project-archive.v1.json +2 -0
  25. package/contracts/project-entry-capability.v1.json +2 -3
  26. package/contracts/project-test-coverage.v1.json +189 -0
  27. package/contracts/project-workspace-link.v1.json +66 -0
  28. package/contracts/project-workspace-resolution.v1.json +28 -0
  29. package/contracts/published-contract-catalog.v1.json +45 -0
  30. package/contracts/release-readiness.v1.json +2 -2
  31. package/contracts/runtime-command-surface.v1.json +1456 -139
  32. package/contracts/transparency-evidence.v1.json +2 -1
  33. package/contracts/workspace-archive-capabilities.v1.json +11 -5
  34. package/contracts/workspace-archive-manifest.v1.json +236 -0
  35. package/contracts/workspace-archive-operation-result.v1.json +236 -0
  36. package/contracts/workspace-contract.v1.json +1 -1
  37. package/contracts/workspace-intelligence/agent-action-outcome.v1.json +2 -2
  38. package/contracts/workspace-intelligence/agent-customization-pack-report.v1.json +1 -1
  39. package/contracts/workspace-intelligence/agent-hooks.v1.json +2 -0
  40. package/contracts/workspace-intelligence/agent-reports-index.v1.json +1 -1
  41. package/contracts/workspace-intelligence/blocker-resolution.v1.json +3 -9
  42. package/contracts/workspace-intelligence/doctor-fix-result.v1.json +2 -2
  43. package/contracts/workspace-intelligence/doctor-graph-diagnosis.v1.json +208 -0
  44. package/contracts/workspace-intelligence/fact-freshness.v1.json +2 -2
  45. package/contracts/workspace-intelligence/mcp-design.v1.json +2 -0
  46. package/contracts/workspace-intelligence/model-usage-event.v1.json +1 -1
  47. package/contracts/workspace-intelligence/project-context-agent.v1.json +360 -0
  48. package/contracts/workspace-intelligence/studio-blocker-handoff.v1.json +1 -1
  49. package/contracts/workspace-intelligence/workspace-context.v1.json +1 -1
  50. package/contracts/workspace-intelligence/workspace-contract-verify.v1.json +2 -2
  51. package/contracts/workspace-intelligence/workspace-dependency-graph.v1.json +1 -1
  52. package/contracts/workspace-intelligence/workspace-explain.v1.json +1 -1
  53. package/contracts/workspace-intelligence/workspace-graph-stream.v1.json +1 -1
  54. package/contracts/workspace-intelligence/workspace-graph-token-efficiency.v1.json +1 -1
  55. package/contracts/workspace-intelligence/workspace-impact.v1.json +1 -1
  56. package/contracts/workspace-intelligence/workspace-intelligence-evaluation-comparison.v1.json +1 -1
  57. package/contracts/workspace-intelligence/workspace-intelligence-evaluation.v1.json +1 -1
  58. package/contracts/workspace-intelligence/workspace-intelligence-history.v1.json +1 -1
  59. package/contracts/workspace-intelligence/workspace-intelligence-run.v1.json +2 -2
  60. package/contracts/workspace-intelligence/workspace-knowledge-graph-change-overlay.v1.json +1 -1
  61. package/contracts/workspace-intelligence/workspace-knowledge-graph.v1.json +48 -5
  62. package/contracts/workspace-intelligence/workspace-knowledge-search.v1.json +1 -1
  63. package/contracts/workspace-intelligence/workspace-model-diff.v1.json +1 -1
  64. package/contracts/workspace-intelligence/workspace-model-snapshot.v1.json +1 -1
  65. package/contracts/workspace-intelligence/workspace-model.v1.json +97 -5
  66. package/contracts/workspace-intelligence/workspace-operational-skill.v1.json +1 -1
  67. package/contracts/workspace-intelligence/workspace-skills-index.v1.json +1 -1
  68. package/contracts/workspace-intelligence/workspace-verify.v1.json +1 -1
  69. package/contracts/workspace-intelligence-architecture.v1.json +33 -7
  70. package/contracts/workspace-intelligence-chain.v1.json +1 -1
  71. package/contracts/workspace-list.v1.json +2 -0
  72. package/contracts/workspace-model-cache.v1.json +2 -0
  73. package/contracts/workspace-registry.v1.json +1 -1
  74. package/contracts/workspace-run-last.v1.json +1 -1
  75. package/contracts/workspace-share-bundle.v1.json +2 -1
  76. package/contracts/workspace-snapshot.v1.json +2 -0
  77. package/contracts/workspace-snapshot.v2.json +2 -0
  78. package/contracts/workspace-sync.v1.json +2 -0
  79. package/contracts/workspace-watch-event.v1.json +2 -0
  80. package/dist/analyze-4H33PAUB.js +1 -0
  81. package/dist/{artifact-remediation-plan-SPOUHMK5.js → artifact-remediation-plan-TQ6KTTXD.js} +1 -1
  82. package/dist/autopilot-release-BHZYM5KX.js +1 -0
  83. package/dist/chunk-2D4UOYOJ.js +1 -0
  84. package/dist/chunk-2OIBHUVH.js +1 -0
  85. package/dist/chunk-3D2PAIRH.js +3 -0
  86. package/dist/chunk-3GRKUP5W.js +33 -0
  87. package/dist/{managed-agent-markers-AXUM75OE.js → chunk-3RBUSW7H.js} +1 -1
  88. package/dist/chunk-4WJC5QCD.js +2 -0
  89. package/dist/chunk-6HLPTJZ3.js +13 -0
  90. package/dist/{chunk-CV5HKU4P.js → chunk-7T4TSV5C.js} +1 -1
  91. package/dist/chunk-AFIFZTOY.js +2 -0
  92. package/dist/{chunk-BMWFQXGW.js → chunk-AHLMIL2T.js} +1 -1
  93. package/dist/chunk-AL237TSJ.js +7 -0
  94. package/dist/chunk-BBGNDMRU.js +2 -0
  95. package/dist/chunk-BG4FWJJ3.js +1 -0
  96. package/dist/{chunk-VU7NZHPM.js → chunk-BHYTI3RH.js} +1 -1
  97. package/dist/chunk-BYTFXQ6G.js +1 -0
  98. package/dist/chunk-CZC5P2MF.js +1 -0
  99. package/dist/chunk-DLM6C7FU.js +8 -0
  100. package/dist/{chunk-CRHYBQI3.js → chunk-DQ3PI7EP.js} +1 -1
  101. package/dist/chunk-E3CT7TYT.js +1 -0
  102. package/dist/chunk-EPVFKJF4.js +1 -0
  103. package/dist/chunk-EWZZUQBR.js +1 -0
  104. package/dist/chunk-FKWB66NQ.js +4 -0
  105. package/dist/{chunk-BGPXQQNY.js → chunk-FZ76CF2W.js} +1 -1
  106. package/dist/chunk-GBAO4GSW.js +2 -0
  107. package/dist/chunk-GQRWRHSR.js +86 -0
  108. package/dist/{chunk-ESLPI3XZ.js → chunk-HE4PUMU4.js} +1 -1
  109. package/dist/chunk-HMGPELXS.js +1 -0
  110. package/dist/chunk-HSZCINFX.js +2 -0
  111. package/dist/{chunk-3VFA7D5T.js → chunk-IND3TUVU.js} +1 -1
  112. package/dist/{chunk-NHN4QXPP.js → chunk-KVSYBHUR.js} +1 -1
  113. package/dist/chunk-L2E2Z4OE.js +5 -0
  114. package/dist/chunk-MAF3LLGK.js +691 -0
  115. package/dist/chunk-MOSXTVPU.js +1 -0
  116. package/dist/chunk-MVLIONQD.js +1 -0
  117. package/dist/chunk-PS5F4DCT.js +1 -0
  118. package/dist/{chunk-K4X3DM7R.js → chunk-Q6TKQVKQ.js} +1 -1
  119. package/dist/chunk-RJIYCDVC.js +1 -0
  120. package/dist/chunk-RVQLMTTI.js +2 -0
  121. package/dist/chunk-SHXJ2GDR.js +75 -0
  122. package/dist/chunk-TDTCMZK7.js +10 -0
  123. package/dist/chunk-TROHVI2V.js +2 -0
  124. package/dist/chunk-U2LR73E2.js +1 -0
  125. package/dist/chunk-U2QL5733.js +36 -0
  126. package/dist/{chunk-TIE2XMGH.js → chunk-VCW5HSPC.js} +12 -12
  127. package/dist/chunk-VRW6KXNK.js +6 -0
  128. package/dist/chunk-VU2BKKMB.js +1 -0
  129. package/dist/chunk-WJVB6SSD.js +16 -0
  130. package/dist/{chunk-32OJDBIG.js → chunk-XBM2P45G.js} +2 -2
  131. package/dist/chunk-Y5YAP4F3.js +2 -0
  132. package/dist/{create-S64IWHAP.js → create-SBFBFXKN.js} +1 -1
  133. package/dist/{demo-kit-DZ7TPG7K.js → demo-kit-KHH63TNA.js} +2 -2
  134. package/dist/{doctor-4NNUDNGZ.js → doctor-OPCMTBJB.js} +1 -1
  135. package/dist/{dotnet-webapi-clean-A6MVDYXX.js → dotnet-webapi-clean-VXEF4SHM.js} +5 -5
  136. package/dist/{gofiber-standard-I5YPQG5V.js → gofiber-standard-AQGSC7ON.js} +3 -3
  137. package/dist/{gogin-standard-VY2L4QT5.js → gogin-standard-7DU3OCBX.js} +3 -3
  138. package/dist/index.d.ts +38 -6
  139. package/dist/index.js +267 -355
  140. package/dist/managed-agent-markers-COE5DJ3W.js +1 -0
  141. package/dist/pipeline-7BUXAFS2.js +5 -0
  142. package/dist/platform-capabilities-PR6YL4KC.js +1 -0
  143. package/dist/project-intelligence-lens-BKKVPCLC.js +1 -0
  144. package/dist/project-test-coverage-BALEHHTT.js +1 -0
  145. package/dist/{pythonRapidkitExec-CVCIK225.js → pythonRapidkitExec-YR7P5LWG.js} +1 -1
  146. package/dist/rust-axum-4HXDICIB.js +140 -0
  147. package/dist/{springboot-standard-55XKCBIZ.js → springboot-standard-EK6GYN5T.js} +7 -7
  148. package/dist/workspace-U6ZQLELX.js +1 -0
  149. package/dist/{workspace-agent-sync-662QHXGF.js → workspace-agent-sync-L4SY7B4Q.js} +1 -1
  150. package/dist/workspace-archive-4JNT4S7N.js +1 -0
  151. package/dist/workspace-context-KOBSLZTI.js +1 -0
  152. package/dist/workspace-contract-SOD3OOVF.js +1 -0
  153. package/dist/workspace-explain-2CTMW2YW.js +1 -0
  154. package/dist/workspace-explain-contract-H7O26QJU.js +1 -0
  155. package/dist/{workspace-feedback-SUVH2LUJ.js → workspace-feedback-ZZ4HPW2T.js} +1 -1
  156. package/dist/{workspace-foundation-WPLD7OEO.js → workspace-foundation-PUIYBQUF.js} +1 -1
  157. package/dist/workspace-graph-stream-BLKIC7VN.js +1 -0
  158. package/dist/workspace-graph-token-efficiency-5FNH4JZ5.js +1 -0
  159. package/dist/{workspace-history-BANOJRQ2.js → workspace-history-SPKNRHIX.js} +1 -1
  160. package/dist/workspace-intelligence-I3ABOH2F.js +1 -0
  161. package/dist/{workspace-intelligence-evaluation-IPH7M3WV.js → workspace-intelligence-evaluation-7CABG5Y6.js} +1 -1
  162. package/dist/workspace-intelligence-runner-Q2XSR3ZL.js +1 -0
  163. package/dist/workspace-intelligence-runtime-registry-ZZ3GRAL2.js +1 -0
  164. package/dist/{workspace-knowledge-graph-ARDC6HHG.js → workspace-knowledge-graph-5MKEI4Z5.js} +1 -1
  165. package/dist/{workspace-knowledge-graph-query-VOSPPH4W.js → workspace-knowledge-graph-query-EKHIE3E2.js} +1 -1
  166. package/dist/{workspace-marker-SMBC3Z2Q.js → workspace-marker-7NHMDIRL.js} +1 -1
  167. package/dist/workspace-mcp-serve-ETNUA72W.js +3 -0
  168. package/dist/workspace-model-HHA37SNH.js +1 -0
  169. package/dist/workspace-model-hash-ZXYPIGCW.js +1 -0
  170. package/dist/workspace-onboarding-ELHZABJE.js +1 -0
  171. package/dist/{workspace-python-engine-state-2MLKJYQG.js → workspace-python-engine-state-J4QKW55K.js} +1 -1
  172. package/dist/workspace-readme-HGGZ4AZB.js +77 -0
  173. package/dist/{workspace-registry-summary-ORDK7A36.js → workspace-registry-summary-D2QM5JF6.js} +1 -1
  174. package/dist/workspace-run-DAAZBCN7.js +1 -0
  175. package/dist/{workspace-verify-EBVL7FWT.js → workspace-verify-4WJTLXRA.js} +1 -1
  176. package/dist/workspace-watch-2PIFTQ6B.js +1 -0
  177. package/docs/GLOSSARY.md +17 -16
  178. package/docs/OPEN_SOURCE_USER_SCENARIOS.md +8 -3
  179. package/docs/README.md +6 -3
  180. package/docs/README_CONTENT_CONTRACT.md +98 -115
  181. package/docs/ci-workflows.md +13 -4
  182. package/docs/commands-reference.md +43 -10
  183. package/docs/contracts/ARTIFACT_CATALOG.md +65 -26
  184. package/docs/contracts/COMMAND_OWNERSHIP_MATRIX.md +2 -0
  185. package/docs/contracts/RUNTIME_SUPPORT_MATRIX.md +3 -3
  186. package/docs/contracts/rapidkit-cli-contracts.json +2 -2
  187. package/docs/create-planner-capabilities.md +36 -5
  188. package/docs/creating-workspaces-and-projects.md +59 -3
  189. package/docs/doctor-command.md +118 -11
  190. package/docs/from-code-to-shared-understanding.md +4 -1
  191. package/docs/graph-benchmark-methodology.md +2 -2
  192. package/docs/workspace-intelligence-evaluation.md +5 -0
  193. package/docs/workspace-knowledge-graph.md +141 -7
  194. package/docs/workspace-operations.md +149 -10
  195. package/package.json +7 -4
  196. package/scripts/enterprise-package-smoke.mjs +24 -1
  197. package/templates/kits/fastapi-ddd/README.md.j2 +1 -1
  198. package/templates/kits/fastapi-standard/README.md.j2 +1 -1
  199. package/templates/kits/nestjs-standard/Dockerfile.j2 +1 -1
  200. package/templates/kits/nestjs-standard/README.md.j2 +1 -1
  201. package/templates/kits/nestjs-standard/package.json.j2 +11 -2
  202. package/dist/analyze-EEEU3MIF.js +0 -1
  203. package/dist/autopilot-release-R4XRTWEM.js +0 -1
  204. package/dist/chunk-22DT744Z.js +0 -1
  205. package/dist/chunk-37CVKXBD.js +0 -1
  206. package/dist/chunk-3NU32T4A.js +0 -2
  207. package/dist/chunk-3ZK2GU7C.js +0 -1
  208. package/dist/chunk-4HDYADHT.js +0 -13
  209. package/dist/chunk-4KUIFXHM.js +0 -5
  210. package/dist/chunk-52PBRX7F.js +0 -1
  211. package/dist/chunk-54EP5CEV.js +0 -8
  212. package/dist/chunk-5XATWNME.js +0 -1
  213. package/dist/chunk-7YHK5NM3.js +0 -2
  214. package/dist/chunk-AFL3ACCR.js +0 -2
  215. package/dist/chunk-BFLJ2R4D.js +0 -80
  216. package/dist/chunk-E2KJ5QWY.js +0 -4
  217. package/dist/chunk-EKZLUMCS.js +0 -933
  218. package/dist/chunk-EYJ2CQSK.js +0 -1
  219. package/dist/chunk-FTY7GGXJ.js +0 -33
  220. package/dist/chunk-FXQJX34Z.js +0 -1
  221. package/dist/chunk-GSWPGELT.js +0 -2
  222. package/dist/chunk-GZTYAEWX.js +0 -1
  223. package/dist/chunk-HDXNIN4N.js +0 -1
  224. package/dist/chunk-HZDXO65G.js +0 -36
  225. package/dist/chunk-J5ENLXDF.js +0 -1
  226. package/dist/chunk-KB44JP4M.js +0 -2
  227. package/dist/chunk-LHOZXC2M.js +0 -2
  228. package/dist/chunk-MER6ZBN2.js +0 -13
  229. package/dist/chunk-NAJCUQ4X.js +0 -2
  230. package/dist/chunk-OA537ZQ5.js +0 -1
  231. package/dist/chunk-OW42TZFB.js +0 -1
  232. package/dist/chunk-P3D5YQB2.js +0 -1
  233. package/dist/chunk-PHXQR6PX.js +0 -2
  234. package/dist/chunk-PRTR2DQ2.js +0 -1
  235. package/dist/chunk-RHQW3DTP.js +0 -1
  236. package/dist/chunk-T4YR4RAI.js +0 -2
  237. package/dist/chunk-WDKNMTJQ.js +0 -1
  238. package/dist/chunk-Y45WZR5N.js +0 -5
  239. package/dist/chunk-YJZOMRAS.js +0 -1
  240. package/dist/pipeline-LHTPE3DR.js +0 -5
  241. package/dist/platform-capabilities-2B4QMZXE.js +0 -1
  242. package/dist/workspace-PJPRBUMQ.js +0 -1
  243. package/dist/workspace-archive-P76EDIUG.js +0 -10
  244. package/dist/workspace-context-23YYCUCP.js +0 -1
  245. package/dist/workspace-contract-TU2I7GC2.js +0 -1
  246. package/dist/workspace-dependency-graph-BP4EXYQ5.js +0 -1
  247. package/dist/workspace-explain-MWUEN643.js +0 -1
  248. package/dist/workspace-explain-contract-ZPI3JXJU.js +0 -1
  249. package/dist/workspace-graph-stream-KAGGQPJT.js +0 -1
  250. package/dist/workspace-graph-token-efficiency-CFGFCJ5V.js +0 -1
  251. package/dist/workspace-intelligence-MFJE7W67.js +0 -1
  252. package/dist/workspace-intelligence-runner-OTYTHV6B.js +0 -1
  253. package/dist/workspace-mcp-serve-EZR6O76D.js +0 -3
  254. package/dist/workspace-model-7OU2M3LE.js +0 -1
  255. package/dist/workspace-model-hash-MHXK5MEI.js +0 -1
  256. package/dist/workspace-run-QND2SIYA.js +0 -1
  257. package/dist/workspace-watch-7HWGA5TF.js +0 -1
@@ -1 +0,0 @@
1
- import {a as a$2,b as b$3}from'./chunk-PYCJWW4B.js';import {b as b$2,c,d as d$1}from'./chunk-PRTR2DQ2.js';import {c as c$1}from'./chunk-HDXNIN4N.js';import {o,a as a$1,n,g,d as d$3,f}from'./chunk-AFL3ACCR.js';import {k}from'./chunk-37CVKXBD.js';import {b as b$4}from'./chunk-J5ENLXDF.js';import {d}from'./chunk-OA537ZQ5.js';import {a as a$3}from'./chunk-T4YR4RAI.js';import {d as d$2,e}from'./chunk-32OJDBIG.js';import {a as a$4}from'./chunk-KB44JP4M.js';import {b as b$1,a,c as c$2}from'./chunk-BMWFQXGW.js';import m from'path';import v from'fs-extra';var oe="rapidkit-blocker-resolution-v1";function ae(e){let t=e.blockers.map(s=>s.trim()).filter(Boolean).slice(0,12),r=e.stderrTail?.trim().slice(-400)??"";return b$4({blockers:t,exitCode:e.exitCode??null,stderrTail:r})}function ge(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 ke(e){let t=ge(e.reason),r=ae({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.",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:oe,blockerId:e.blockerId,sourceCommand:e.sourceCommand,sourceArtifact:e.sourceArtifact,resolutionClass:t,blockerSignature:r,commandRetryHint:t==="artifact-missing"?"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 ce(e){return Array.from(new Set(e.blockingReasons.map(r=>r.trim()).filter(Boolean))).slice(0,12).map((r,s)=>ke({reason:r,blockerId:`blocker-${s+1}`,sourceCommand:e.sourceCommand,sourceArtifact:e.sourceArtifact,verifyCommand:e.verifyCommand,verifyArtifact:e.verifyArtifact}))}function ye(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 he(e){return e.length===0||e.every(t=>ye(t))}function de(e){return e.projectCount>0||e.policyErrorCount>0?{verdict:e.verdict,exitCode:e.exitCode}:e.verdict==="blocked"&&he(e.blockingReasons)?{verdict:"needs-attention",exitCode:1}:{verdict:e.verdict,exitCode:e.exitCode}}function Ue(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 ue=b$1.verify,z=a.verify;function ve(e,t){return m.isAbsolute(t)?t:m.join(e,t)}async function le(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)throw new Error(`Unsupported workspace impact schema: ${String(r.schemaVersion)}`);a$4(t,"contracts/workspace-intelligence/workspace-impact.v1.json",`Workspace impact ${e}`);let s=r;a$4(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=s.diff.currentModel.graph?.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 be(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 we(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 Re(e,t){if(e.id==="workspace.doctor")return m.join(t,a.doctor);if(e.id==="workspace.contract.verify")return m.join(t,a.contractVerify);if(e.id==="workspace.readiness")return m.join(t,a.readiness);if(e.id==="workspace.analyze")return m.join(t,".workspai","reports","analyze-last-run.json");if(e.id==="workspace.pipeline")return m.join(t,".workspai","reports","pipeline-last-run.json");if(e.id==="workspace.doctor-fix")return m.join(t,".workspai","reports","doctor-fix-result-last-run.json");if(e.id.startsWith("project.")&&e.id.includes("."))return m.join(t,".workspai","reports","workspace-run-last.json")}function b(e){return !e||typeof e!="object"||Array.isArray(e)?null:e}function Ce(e){let t=b(e.healthScore),r=b(e.summary),s=typeof t?.errors=="number"?t.errors:0,i=typeof t?.percent=="number"?t.percent:void 0;return s>0||r?.hasSystemErrors===true?{status:"fail",message:`Doctor evidence reports ${s} error(s).`}:typeof i=="number"&&i<70?{status:"warn",message:`Doctor health score is ${i}%.`}:{status:"pass",message:"Doctor evidence is present and healthy."}}function Ae(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 Ee(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 Se(e){let t=b(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 We(e){let t=e.schemaVersion==="rapidkit-doctor-fix-result-v1"?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 je(e,t){let r=await d$2(e,".workspai/reports/doctor-remediation-plan-last-run.json");if(!r)return false;try{let s=b(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 xe(e){return e.id.endsWith(".init")?"init":e.id.endsWith(".test")?"test":e.id.endsWith(".build")?"build":e.id.endsWith(".start")?"start":null}function Pe(e){let t=b(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 Ie(e,t,r){let s=xe(t),i=c$1(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=b(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=C(i.generatedAt,r,`Workspace run evidence for ${t.project??t.id}`);if(g)return {status:"fail",message:g};let c=b(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 C(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 Ve(e){if(e.id==="workspace.doctor")return c$2.doctor;if(e.id==="workspace.readiness")return c$2.readiness;if(e.id==="workspace.contract.verify")return c$2.contractVerify;if(e.id==="workspace.analyze")return c$2.analyze;if(e.id==="workspace.pipeline")return "contracts/pipeline-last-run.v1.json"}async function $e(e,t,r,s){let i=Re(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=b(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=Ve(e);if(g)try{a$4(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=C(d.generatedAt,s,"Doctor evidence");n?c={status:"fail",message:n}:c=Ce(d);}else if(e.id==="workspace.readiness"){let n=C(d.generatedAt,s,"Release readiness evidence");n?c={status:"fail",message:n}:c=Ae(d);}else if(e.id==="workspace.contract.verify"){let n=C(d.generatedAt,s,"Workspace contract verify evidence");n?c={status:"fail",message:n}:c=Ee(d);}else if(e.id==="workspace.analyze"){let n=C(d.generatedAt,s,"Analyze evidence");n?c={status:"fail",message:n}:c=Se(d);}else if(e.id==="workspace.pipeline"){let n=C(d.generatedAt,s,"Pipeline evidence");n?c={status:"fail",message:n}:c=Pe(d);}else if(e.id==="workspace.doctor-fix"){let n=d.schemaVersion==="rapidkit-doctor-fix-result-v1"?d:d.fixResult,a=b(n),f=typeof a?.generatedAt=="string"?a.generatedAt:void 0,y=C(f,s,"Doctor fix result");y?c={status:"fail",message:y}:await je(t,f)?c={status:"skipped",message:"No current doctor remediation steps are pending."}:c=We(d);}else if(e.id.startsWith("project."))c=Ie(d,e,s);else {let n=C(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 Fe(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 Oe(e,t){let r=W(e.affectedProjects.map(a=>a.project?.name).filter(a=>typeof a=="string")),s=new Set(r.map(a=>a.toLowerCase())),i=W(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 j=y.filter(p=>p.status==="fail"),w=j.filter(p=>p.required),x=y.filter(p=>p.status==="missing"),A=x.filter(p=>p.required),P=y.some(p=>p.status==="pass"||p.status==="warn");if(w.length>0){u.push(a),g.push(`graph.subgraph.${a}: ${f} has failed verification evidence (${w.map(p=>p.id).join(", ")}).`);return}if(j.length>0){u.push(a),c=true;return}if(A.length>0){u.push(a),g.push(`graph.subgraph.${a}: ${f} has missing required verification evidence (${A.map(p=>p.id).join(", ")}).`);return}if(x.length>0){u.push(a),c=true;return}if(P){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:W(k),uncovered:W(u),unverifiable:W(d)},blockingReasons:g,needsAttention:c}}function W(e){return [...new Set(e)].sort((t,r)=>t.localeCompare(r))}async function Be(e){let t=m.resolve(e.workspacePath);if(e.fromImpactPath){let o=ve(t,e.fromImpactPath);return {impact:await le(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 le(r),fromImpactRef:g,impactFromDisk:true};let s=m.join(t,d$3);if(await v.pathExists(s))return {impact:await o({workspacePath:t,fromPath:d$3,scope:e.scope,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,observableScanDepth:e.observableScanDepth,now:e.now}),fromImpactRef:d$3,impactFromDisk:false};let i=await k({workspacePath:t,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,observableScanDepth:e.observableScanDepth,now:e.now});return {impact:{schemaVersion:f,generatedAt:(e.now??new Date).toISOString(),fromRef:"baseline",diffRef:a.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:i.graph?.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:b$1.diff,generatedAt:(e.now??new Date).toISOString(),fromRef:"baseline",toRef:a.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 _e(e,t){if(t)return e.generatedAt}async function ft(e){let t=m.resolve(e.workspacePath),{impact:r,fromImpactRef:s,impactFromDisk:i}=await Be(e),o$1=r.diff.currentModel,k$1=i?await k({workspacePath:t,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,observableScanDepth:e.observableScanDepth,now:e.now}):o$1,u=[];if(i){let l=await o({workspacePath:t,fromPath:r.diff.fromRef,diff:r.diff,scope:e.scope,now:e.now}),B=[r.affectedProjects,r.transitiveImpact,r.verificationPlan],_=[l.affectedProjects,l.transitiveImpact,l.verificationPlan];JSON.stringify(B)!==JSON.stringify(_)&&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$1)!==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$1(t,{ref:d$2.ref}),B=r.diff.changes.filter(h=>h.type.startsWith("git.")).map(h=>`${h.type}:${h.target.replace(/^git:/,"")}`).sort(),_=[...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(_)!==JSON.stringify(B))&&u.push("workspace.impact: Impact evidence is stale because Git changes no longer match the diff observation. Regenerate diff and impact.");}let g=_e(r,i),c$1=be([...n(),...r.verificationPlan]).filter(l=>we(e.scope,l)),n$1=[];for(let l of c$1)n$1.push(await $e(l,t,o$1.contracts.exists===true,g));let a=Oe(r,n$1),f=a$2(o$1.graph??{nodes:[],edges:[]}),y=b$2(o$1),j=await Ne(t),w=c(y,j?.freshness?.projectHashes),x={verdict:w.verdict,baseline:w.baseline,changed:w.changed,added:w.added,removed:w.removed,projectHashes:d$1(y)},A=b$3(f),P=o$1.policies?.mode??"warn",p=await De(o$1,t),O=He(P,p),E=Fe(n$1,{blockingReasons:[...a.blockingReasons,...A,...O.blockingReasons,...u],needsAttention:a.needsAttention||O.needsAttention}),fe=n$1.filter(l=>l.status==="missing"&&l.evidencePath).map(l=>l.evidencePath),I=[...n$1.filter(l=>l.required&&(l.status==="fail"||l.status==="missing")).map(l=>`${l.id}: ${l.message}`),...a.blockingReasons,...A,...O.blockingReasons,...u],pe=p.filter(l=>l.severity==="error").length,me=o$1.summary?.projectCount??o$1.projects.length,J=de({projectCount:me,verdict:E.verdict,exitCode:E.exitCode,blockingReasons:I,policyErrorCount:pe});E.verdict=J.verdict,E.exitCode=J.exitCode;let G=I.length>0?ce({blockingReasons:I,verifyCommand:"npx workspai workspace verify --from-impact .workspai/reports/workspace-impact-last-run.json --json",verifyArtifact:z}):[];return {schemaVersion:ue,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:E,steps:n$1,missingEvidence:fe,blockingReasons:I,...G.length>0?{resolutionHints:G}:{},verificationPlan:c$1,affectedSubgraph:a.subgraph,graphIntegrity:f,freshness:x,policyMode:P,policyViolations:p}}async function De(e,t){let r=[];for(let i of e.validation?.issues??[])r.push({source:"model",severity:i.severity,code:i.code,message:i.message,target:i.target});let s=await d$2(t,a.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 He(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 Ne(e){let t=m.join(e,z);try{if(!await v.pathExists(t))return null;let r=await v.readJson(t);return r&&r.schemaVersion===ue?r:null}catch{return null}}async function pt(e$1,t){return e(t,z,a$3(e$1))}function Me(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 mt(e,t){return Me(e,t).exitCode}export{oe as a,Ue as b,ue as c,z as d,Oe as e,ft as f,pt as g,Me as h,mt as i};
@@ -1 +0,0 @@
1
- import {b as b$1}from'./chunk-NHN4QXPP.js';import {i}from'./chunk-MER6ZBN2.js';import {c}from'./chunk-PHXQR6PX.js';import {a}from'./chunk-Y45WZR5N.js';import {f}from'./chunk-7YHK5NM3.js';import {b}from'./chunk-RO73VVHW.js';import {h as h$1,g}from'./chunk-5XATWNME.js';import {promises}from'fs';import c$1 from'path';import v,{homedir}from'os';import {pathToFileURL}from'url';import d from'process';function E(t){let e=t.label.indexOf(" \u2014 ");return e>=0?t.label.slice(e+3).trim():t.label.trim()}function F(){let t=c().map(e=>({value:e.id,label:E(e),hint:e.description,name:e.label})),o=i().map(e=>({value:e.kitId,label:e.displayName,hint:e.commandDisplay("my-app"),name:`${e.displayName} \u2014 ${e.framework}`}));return [...t,...o]}var I=".workspairc.json",N=".rapidkitrc.json",D=["workspai.config.js","workspai.config.mjs","workspai.config.cjs","rapidkit.config.js","rapidkit.config.mjs","rapidkit.config.cjs"],S=["workspai.config.json","rapidkit.config.json"];function W(t){return typeof t=="object"&&t!==null&&"code"in t&&t.code==="ENOENT"}function h(t,o){let e=o instanceof Error?o.message:String(o),n=t.endsWith(".js")&&/module is not defined in ES module scope/i.test(e)?' CommonJS syntax in a .js config is not valid when the project package uses "type": "module"; rename the file to .cjs or use export default.':"";return `Failed to load Workspai config at ${t}.${n} Cause: ${e}`}async function he(){for(let t of [c$1.join(v.homedir(),I),c$1.join(v.homedir(),N)])try{let o=await promises.readFile(t,"utf-8"),e=JSON.parse(o);return f.debug(`Loaded config from ${t}`),e}catch{}return f.debug("No user config found, using defaults"),{}}async function ke(t=process.cwd(),o={}){let e=t,n=c$1.parse(e).root;for(;e!==n;){for(let r of S){let i=c$1.join(e,r);try{let s=await promises.readFile(i,"utf-8"),a=JSON.parse(s);if(!a||typeof a!="object"||Array.isArray(a))throw new Error("configuration root must be a JSON object");return f.debug(`Loaded data-only Workspai config from ${r}`),a}catch(s){if(W(s))continue;throw new Error(h(i,s))}}for(let r of D){let i=c$1.join(e,r);try{await promises.access(i);}catch(s){if(W(s))continue;throw new Error(h(i,s))}if(f.debug(`Found config file: ${i}`),!o.trustExecutableConfig)throw new Error(`Refusing to execute Workspai config at ${i} without explicit trust. Use a data-only workspai.config.json file, pass --trust-config, or set WORKSPAI_TRUST_CONFIG=1.`);try{let a=await import(pathToFileURL(i).href),u=a.default||a;return f.debug(`Loaded Workspai config from ${r}`),u}catch(s){throw new Error(h(i,s))}}e=c$1.dirname(e);}return f.debug("No Workspai config file found, using defaults"),{}}function ye(t,o,e){return {author:e.author||o.workspace?.defaultAuthor||t.author,pythonVersion:e.pythonVersion||o.workspace?.pythonVersion||t.pythonVersion,defaultInstallMethod:e.defaultInstallMethod||o.workspace?.installMethod||t.defaultInstallMethod,defaultKit:e.defaultKit||o.projects?.defaultKit||t.defaultKit,skipGit:e.skipGit??o.projects?.skipGit??t.skipGit,license:e.license||t.license,testRapidKitPath:e.testRapidKitPath||t.testRapidKitPath}}function we(t){return a("DEV_PATH")||t.testRapidKitPath||void 0}function A(t,o){let e=t.indexOf(o);if(e>=0&&e+1<t.length)return t[e+1];let n=t.find(r=>r.startsWith(`${o}=`));if(n)return n.slice(o.length+1)}function L(t){return t.includes("--here")}function j(t,o=d.cwd()){if(L(t))return c$1.resolve(o);let e=A(t,"--output");if(e)return c$1.resolve(e)}function Fe(t,o=d.cwd()){let e=c$1.resolve(t),n=c$1.resolve(o),r=c$1.relative(n,e);return r.length>0&&!r.startsWith("..")&&!c$1.isAbsolute(r)?`cd ${r}`:`cd ${e}`}function Ke(t,o={}){let e=o.argv??[],n=o.outputParent??j(e,d.cwd());return h$1(t.trim(),{homeDir:o.homeDir,outputDir:n})}function Ie(t,o,e={}){return t?c$1.resolve(t)===c$1.resolve(o)?true:e.outputParent===void 0:false}async function Ne(t,o={}){let e=o.cwd??d.cwd(),n=o.homeDir??homedir(),r=j(t,e);if(r!==void 0)return r;let i=o.hasYes??(t.includes("--yes")||t.includes("-y"));if(!(o.interactive??(!i&&!!d.stdin.isTTY&&!b())))return;let a=g(n),{location:u}=await b$1([{type:"rawlist",name:"location",message:"Where should the workspace be created?",choices:[{value:"managed",label:"Managed home",hint:a},{value:"here",label:"Current directory",hint:e}],default:0}]);if(u==="here")return c$1.resolve(e)}export{F as a,he as b,ke as c,ye as d,we as e,Fe as f,Ke as g,Ie as h,Ne as i};
@@ -1,2 +0,0 @@
1
- import {a as a$1,c as c$1,i,g,h as h$1}from'./chunk-4KUIFXHM.js';import {p,q}from'./chunk-5XATWNME.js';import T from'fs';import a from'path';import y from'fs-extra';var V=[{id:"fastapi.standard",aliases:["fastapi","fastapi.standard"],label:"fastapi \u2014 FastAPI Standard Kit",description:"Core-backed FastAPI service scaffold.",owner:"core",runtime:"python",framework:"fastapi",moduleSupport:true,stability:"stable"},{id:"fastapi.ddd",aliases:["fastapi.ddd","fastapi-ddd"],label:"fastapi \u2014 FastAPI DDD Kit",description:"Core-backed FastAPI DDD service scaffold.",owner:"core",runtime:"python",framework:"fastapi",moduleSupport:true,stability:"stable"},{id:"nestjs.standard",aliases:["nestjs","nest","nestjs.standard"],label:"nestjs \u2014 NestJS Standard Kit",description:"Core-backed NestJS service scaffold.",owner:"core",runtime:"node",framework:"nestjs",moduleSupport:true,stability:"stable"},{id:"springboot.standard",aliases:["spring","springboot","springboot.standard","java"],label:"spring \u2014 Spring Boot Standard Kit",description:"npm-backed Spring Boot service scaffold.",owner:"npm",runtime:"java",framework:"springboot",moduleSupport:false,stability:"stable",generator:"springboot",createUsage:"workspai create project springboot.standard <name> [--java-version <major>] [--spring-boot-version <semver>] [--group-id <com.example>] [--package-name <com.example.app>] [--port <number>]"},{id:"gofiber.standard",aliases:["go","go.standard","fiber","gofiber","gofiber.standard","go/fiber"],label:"go/fiber \u2014 Go Fiber Standard Kit",description:"npm-backed Go Fiber service scaffold.",owner:"npm",runtime:"go",framework:"gofiber",moduleSupport:false,stability:"stable",generator:"gofiber",createUsage:"workspai create project gofiber.standard <name> [--output <dir>]"},{id:"gogin.standard",aliases:["gin","gogin","gogin.standard","go/gin"],label:"go/gin \u2014 Go Gin Standard Kit",description:"npm-backed Go Gin service scaffold.",owner:"npm",runtime:"go",framework:"gogin",moduleSupport:false,stability:"stable",generator:"gogin",createUsage:"workspai create project gogin.standard <name> [--output <dir>]"},{id:"dotnet.webapi.clean",aliases:["dotnet","dotnet.webapi","dotnet.webapi.clean","aspnet","aspnetcore","asp.net","asp.net-core","csharp","c#"],label:"dotnet \u2014 ASP.NET Core Clean Web API",description:"npm-backed ASP.NET Core Web API with clean architecture boundaries.",owner:"npm",runtime:"dotnet",framework:"dotnet",moduleSupport:false,stability:"preview",generator:"dotnet-webapi-clean",createUsage:"workspai create project dotnet.webapi.clean <name> [--target-framework net8.0] [--root-namespace <Company.Product>] [--port <number>]"}],O=new Map;for(let e of V){O.set(e.id.toLowerCase(),e);for(let t of e.aliases)O.set(t.toLowerCase(),e);}function P(e){return e?O.get(e.trim().toLowerCase())??null:null}function qe(e){return P(e)?.id??e}function Ye(){return V.filter(e=>e.owner==="core"||e.generator)}function He(e){return P(e)?.owner==="npm"}async function ze(e,t){if(!e.generator)throw new Error(`Kit is not backed by an npm generator: ${e.id}`);if(e.generator==="gofiber"){let{generateGoFiberKit:r}=await import('./gofiber-standard-I5YPQG5V.js');await r(t.projectPath,{project_name:t.projectName,module_path:t.projectName,skipGit:t.skipGit,skipInstall:t.skipInstall});return}if(e.generator==="gogin"){let{generateGoGinKit:r}=await import('./gogin-standard-VY2L4QT5.js');await r(t.projectPath,{project_name:t.projectName,module_path:t.projectName,skipGit:t.skipGit,skipInstall:t.skipInstall});return}if(e.generator==="springboot"){let{generateSpringBootKit:r}=await import('./springboot-standard-55XKCBIZ.js');await r(t.projectPath,{project_name:t.projectName,artifact_id:t.projectName,java_version:c(t.args,"--java-version")?.trim(),spring_boot_version:c(t.args,"--spring-boot-version")?.trim(),springdoc_version:c(t.args,"--springdoc-version")?.trim(),group_id:c(t.args,"--group-id")?.trim(),package_name:c(t.args,"--package-name")?.trim(),description:c(t.args,"--description")?.trim(),port:c(t.args,"--port")?.trim(),skipGit:t.skipGit,skipInstall:t.skipInstall});return}if(e.generator==="dotnet-webapi-clean"){let{generateDotnetWebApiCleanKit:r}=await import('./dotnet-webapi-clean-A6MVDYXX.js');await r(t.projectPath,{project_name:t.projectName,target_framework:c(t.args,"--target-framework")?.trim(),root_namespace:c(t.args,"--root-namespace")?.trim(),description:c(t.args,"--description")?.trim(),port:c(t.args,"--port")?.trim(),skipGit:t.skipGit,skipInstall:t.skipInstall});return}throw new Error(`Unhandled npm kit generator: ${e.generator}`)}function c(e,t){let r=e.indexOf(t);if(r>=0&&r+1<e.length)return e[r+1];let n=e.find(i=>i.startsWith(`${t}=`));return n?n.slice(t.length+1):void 0}var j=["init","dev","start","build","test","lint","format","help"],X={python:{runtime:"python",displayName:"Python",tier:"first-class",scaffoldSupport:true,importSupport:true,lifecycleCommands:j,moduleCommands:true,doctorSupport:"full",notes:["Core-backed Python projects support RapidKit Core modules and lifecycle commands."]},node:{runtime:"node",displayName:"Node.js",tier:"extended",scaffoldSupport:true,importSupport:true,lifecycleCommands:j,moduleCommands:true,doctorSupport:"full",notes:["Node projects support npm-owned lifecycle commands; NestJS is the first-class Node framework."]},go:{runtime:"go",displayName:"Go",tier:"extended",scaffoldSupport:true,importSupport:true,lifecycleCommands:j,moduleCommands:false,doctorSupport:"readiness",notes:["Go projects support workspace governance and lifecycle commands via Go tooling."]},java:{runtime:"java",displayName:"Java / Spring Boot",tier:"extended",scaffoldSupport:true,importSupport:true,lifecycleCommands:j,moduleCommands:false,doctorSupport:"readiness",notes:["Java projects support Maven/Gradle lifecycle commands and workspace governance."]},dotnet:{runtime:"dotnet",displayName:".NET / ASP.NET Core",tier:"extended",scaffoldSupport:true,importSupport:true,lifecycleCommands:j,moduleCommands:false,doctorSupport:"readiness",notes:[".NET projects support dotnet CLI lifecycle commands and workspace governance."]},php:{runtime:"php",displayName:"PHP",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["PHP projects are importable and governed as observed projects until a kit exists."]},ruby:{runtime:"ruby",displayName:"Ruby",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Ruby projects are importable and governed as observed projects until a kit exists."]},rust:{runtime:"rust",displayName:"Rust",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Rust projects are importable and governed as observed projects until a kit exists."]},elixir:{runtime:"elixir",displayName:"Elixir",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Elixir projects are importable and governed as observed projects until a kit exists."]},clojure:{runtime:"clojure",displayName:"Clojure",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Clojure projects are importable and governed as observed projects until a kit exists."]},scala:{runtime:"scala",displayName:"Scala",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Scala projects are importable and governed as observed projects until a kit exists."]},kotlin:{runtime:"kotlin",displayName:"Kotlin",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Kotlin projects are importable and governed as observed projects until a kit exists."]},deno:{runtime:"deno",displayName:"Deno",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Deno projects are importable and governed as observed projects until a kit exists."]},bun:{runtime:"bun",displayName:"Bun",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Bun projects are importable and governed as observed projects until a kit exists."]},unknown:{runtime:"unknown",displayName:"Unknown",tier:"observed",scaffoldSupport:false,importSupport:true,lifecycleCommands:["help"],moduleCommands:false,doctorSupport:"observed",notes:["Unknown projects are tracked safely but require manual command configuration."]}},fe=["fastapi","nestjs"],ge=["django","flask","nextjs","remix","nuxt","react","vite","vue","sveltekit","svelte","angular","astro","solid","express","fastify","koa","echo","gofiber","gogin","springboot","dotnet","laravel","symfony","rails","sinatra","actix","axum","rocket","phoenix","clojure","scala","kotlin","deno","bun"];function x(e){return X[e||"unknown"]??X.unknown}function Q(e){return fe.includes(e)?"first-class":ge.includes(e)?"extended":"observed"}function Z(e){let t=x(e.runtime);return {lifecycleCommands:t.lifecycleCommands,moduleCommands:e.moduleSupport&&t.moduleCommands,unsupportedLifecycleCommands:j.filter(r=>!t.lifecycleCommands.includes(r))}}var ye=["python","node","go","java","dotnet"];function w(e){return !!e&&ye.includes(e)}function E(e,t){return t!=="lint"&&t!=="format"&&t!=="docs"?false:e==="python"}function ee(e){let t=x(e),r=w(t.runtime),n=be[t.runtime]??[],i=Ce[t.runtime]??[];return {runtime:t.runtime,displayName:t.displayName,lifecycleCommands:t.lifecycleCommands,hasExecutor:r,packageManagers:n,primaryFiles:i,notes:t.notes}}var be={python:["poetry","pip","uv"],node:["npm","pnpm","yarn","bun"],go:["go"],java:["maven","gradle"],dotnet:["dotnet"],php:["composer"],ruby:["bundle"],rust:["cargo"],elixir:["mix"],kotlin:["gradle"],deno:["deno"],bun:["bun"]},Ce={python:["pyproject.toml","requirements.txt","requirements.in"],node:["package.json"],go:["go.mod"],java:["pom.xml","build.gradle","build.gradle.kts"],dotnet:["*.csproj","*.sln"],php:["composer.json"],ruby:["Gemfile"],rust:["Cargo.toml"],elixir:["mix.exs"],kotlin:["settings.gradle.kts"],deno:["deno.json","deno.jsonc"],bun:["package.json","bunfig.toml"]};function h(e,t){let r=g({runtime:typeof e?.runtime=="string"?e.runtime:void 0,framework:typeof e?.framework=="string"?e.framework:void 0,kitName:typeof e?.kit_name=="string"?e.kit_name:typeof e?.kit=="string"?e.kit:void 0});return r.runtime!=="unknown"?r.runtime:i(t,e).runtime}function re(e){let t=e;for(;;){for(let n of p(t,"project.json"))if(T.existsSync(n))try{return JSON.parse(T.readFileSync(n,"utf8"))}catch{return null}let r=a.dirname(t);if(r===t)break;t=r;}return null}function st(e,t){return h(e,t)==="go"}function mt(e,t){return h(e,t)==="node"}function ct(e,t){return h(e,t)==="java"}function dt(e,t){return h(e,t)==="dotnet"}function pt(e,t){return h(e,t)==="python"}var Se=["project.json","context.json","file-hashes.json"];async function jt(e){let t=a.resolve(e),r=[];for(let n of Se){let i=q(t,n);if(await y.pathExists(i))continue;let m=a.join(t,".rapidkit",n);if(!await y.pathExists(m))continue;let f=await y.readJson(m);await y.ensureDir(a.dirname(i));let C=`${i}.${process.pid}.${Date.now()}.tmp`;try{await y.writeJson(C,f,{spaces:2}),await y.move(C,i,{overwrite:false}),r.push(i);}finally{await y.remove(C).catch(()=>{});}}return r}function je(e){for(let t of p(e,"context.json"))if(T.existsSync(t))try{return JSON.parse(T.readFileSync(t,"utf8"))}catch{return null}return null}function we(e){let t=e?.engine;return t==="npm"||t==="pip"||t==="python"?t:"unknown"}function xe(e,t){if(e?.module_support===false||t?.module_support===false||!e&&t)return false;let r=typeof e?.kit_name=="string"?e.kit_name:typeof e?.kit=="string"?e.kit:typeof t?.kit=="string"?t.kit:void 0,n=r?P(r):void 0;return n?.owner==="core"&&n.moduleSupport===true}function he(e,t,r){let n=g({runtime:typeof t?.runtime=="string"?t.runtime:typeof r?.runtime=="string"?r.runtime:void 0,framework:typeof t?.framework=="string"?t.framework:typeof r?.framework=="string"?r.framework:void 0,kitName:typeof t?.kit_name=="string"?t.kit_name:typeof t?.kit=="string"?t.kit:typeof r?.kit=="string"?r.kit:void 0});return n.key!=="unknown"?n:i(e,t)}function ne(e){let t=a.resolve(e);if(![...p(t,"project.json"),...p(t,"context.json")].some(f=>T.existsSync(f)))return null;let n=re(t),i=je(t),m=he(t,n,i);return {projectRoot:t,projectJson:n,contextJson:i,detection:m,moduleSupport:xe(n,i),engine:we(i)}}var Ne=["build","dev","start","test","lint","format"],I=["init","test","build","start"],ht=["lint","format","docs"];function Nt(e){return !!e&&Ne.includes(e)}var ve={dev:["dev","start:dev"],start:["start","start:prod","preview"],build:["build"],test:["test","test:unit","test:ci"],lint:["lint"],format:["format","prettier"]},ie={nestjs:{dev:["dev","start:dev"],start:["start","start:prod"],build:["build"],test:["test","test:e2e"],lint:["lint"],format:["format"]},express:{dev:["dev","start:dev"],start:["start"],build:["build"],test:["test"],lint:["lint"],format:["format"]},fastify:{dev:["dev","start:dev"],start:["start"],build:["build"],test:["test"],lint:["lint"],format:["format"]},koa:{dev:["dev","start:dev"],start:["start"],build:["build"],test:["test"],lint:["lint"],format:["format"]}};function Re(e){let t=a.join(e,"package.json");if(!T.existsSync(t))return {};try{let n=JSON.parse(T.readFileSync(t,"utf8")).scripts??{};return Object.fromEntries(Object.entries(n).filter(i=>typeof i[1]=="string"))}catch{return {}}}function Pe(e,t){let r=t?c$1(t):"unknown",n=r!=="unknown"?a$1(r,e):[],i=t?ie[t]?.[e]??[]:[],m=ve[e]??[],f=[...n,...i,...m];return [...new Set(f)]}function ae(e,t,r){let n=Re(e),i=new Set(Object.keys(n));if(i.has(t))return {scriptName:t,source:"package.json"};for(let m of Pe(t,r?.framework))if(i.has(m))return {scriptName:m,source:a$1(c$1(r?.framework??"unknown"),t).includes(m)||ie[r?.framework??""]?.[t]?.includes(m)?"framework-candidate":"generic-candidate"};return null}function B(e){return T.existsSync(a.join(e,"package.json"))}function se(e){let t=ee(e);return t.runtime==="unknown"&&e!=="unknown"?null:{runtime:t.runtime,displayName:t.displayName,supportedCommands:t.lifecycleCommands,packageManagers:t.packageManagers,primaryFiles:t.primaryFiles,notes:t.notes,hasExecutor:t.hasExecutor}}function s(e){try{return T.existsSync(e)}catch{return false}}function b(e){try{return s(e)?T.readFileSync(e,"utf8"):""}catch{return ""}}function u(e,t){let r=b(a.join(e,"Makefile"));return r?new RegExp(`^${t}\\s*:`).test(r):false}function Ee(e){let t=[e];for(;t.length>0;){let r=t.shift();if(!r)break;let n=[];try{n=T.readdirSync(r,{withFileTypes:true});}catch{continue}for(let i of n){if(i.name==="node_modules"||i.name===".git"||i.name==="dist")continue;let m=a.join(r,i.name);if(i.isFile()&&i.name.endsWith(".csproj"))return true;i.isDirectory()&&t.push(m);}}return false}function me(e,t){let r=s(a.join(e,"pyproject.toml")),n=s(a.join(e,"requirements.txt"))||s(a.join(e,"requirements.in")),i=s(a.join(e,"manage.py"));switch(t){case "init":return r||n;case "dev":case "start":return r||i||n;case "test":return r||n||s(a.join(e,"tests"));case "build":return r||n;case "lint":case "format":return r||n||i||s(a.join(e,"setup.py"))||s(a.join(e,"setup.cfg"));default:return false}}function Me(e,t){if(!s(a.join(e,"go.mod")))return false;switch(t){case "init":return true;case "dev":return u(e,"run")||s(a.join(e,"main.go"));case "test":return true;case "build":return true;case "start":return u(e,"run")||s(a.join(e,"main.go"))||s(a.join(e,"cmd"));case "lint":return s(a.join(e,".golangci.yml"))||s(a.join(e,".golangci.yaml"))||u(e,"lint");case "format":return u(e,"fmt")||u(e,"format");default:return false}}function _e(e,t){let r=s(a.join(e,"pom.xml")),n=s(a.join(e,"build.gradle"))||s(a.join(e,"build.gradle.kts"));if(!r&&!n)return false;switch(t){case "init":case "test":case "build":case "dev":case "start":return true;case "lint":return u(e,"lint")||b(a.join(e,"pom.xml")).includes("checkstyle")||b(a.join(e,"build.gradle")).includes("checkstyle")||b(a.join(e,"build.gradle.kts")).includes("checkstyle");case "format":return u(e,"format")||b(a.join(e,"build.gradle")).includes("spotless")||b(a.join(e,"build.gradle.kts")).includes("spotless");default:return false}}function Ae(e,t){if(!Ee(e))return false;switch(t){case "init":case "dev":case "test":case "build":case "start":return true;case "lint":return u(e,"lint")||b(a.join(e,"Directory.Build.props")).includes("EnforceCodeStyleInBuild");case "format":return u(e,"format")||s(a.join(e,".editorconfig"));default:return false}}function Fe(e,t,r){return t==="init"?B(e):ae(e,t,{framework:r})!==null}function Le(e,t,r){switch(t){case "php":return r==="init"&&s(a.join(e,"composer.json"));case "ruby":return r==="init"&&s(a.join(e,"Gemfile"));case "rust":return s(a.join(e,"Cargo.toml"))?r==="init"||r==="test"||r==="build"||r==="start":false;case "elixir":return r==="init"&&s(a.join(e,"mix.exs"));case "deno":return s(a.join(e,"deno.json"))||s(a.join(e,"deno.jsonc"))?r==="init"||r==="dev"||r==="test"||r==="start":r==="init"&&s(a.join(e,"package.json"));case "bun":return s(a.join(e,"bunfig.toml"))||s(a.join(e,"bun.lock"))?r==="init"||r==="dev"||r==="test"||r==="build"||r==="start":r==="init"&&s(a.join(e,"package.json"));default:return false}}function _(e,t,r,n){if(E(t,r))return me(e,r);if(!w(t))return Le(e,t,r);switch(t){case "node":return Fe(e,r,n);case "python":return me(e,r);case "go":return Me(e,r);case "java":return _e(e,r);case "dotnet":return Ae(e,r);default:return false}}function De(e,t,r){return ["init","dev","start","build","test","lint","format"].filter(i=>_(e,t,i,r))}function ce(e){let t=Z({runtime:e.runtime,moduleSupport:e.moduleSupport});if(!e.projectPath)return t;let r=De(e.projectPath,e.runtime,e.framework),n=new Set(["help"]);for(let m of r)t.lifecycleCommands.includes(m)&&n.add(m);e.runtime==="node"&&B(e.projectPath)&&n.add("init");let i=[...n].sort();return {lifecycleCommands:i,moduleCommands:t.moduleCommands,unsupportedLifecycleCommands:t.lifecycleCommands.filter(m=>!i.includes(m)).sort()}}var W=["version","commands","doctor","project","help"],A=["init","dev","start","build","test","lint","format"],$=["add","modules","upgrade","diff","merge","reconcile","rollback","uninstall","checkpoint","snapshot","optimize"],J=["create","list","info","frameworks","license"];W.filter(e=>e!=="help");function Te(e){let t=a.resolve(e);for(;;){if([...p(t,"project.json"),...p(t,"context.json")].some(i=>T.existsSync(i)))return t;let n=a.dirname(t);if(n===t)break;t=n;}return null}function N(e,t){return {command:e,...t}}var Ie=new Set(["dev","lint","format"]),Ke=new Set(I);function Be(e,t){return t?Ke.has(e)?{executionScope:"fleet",fleetEligible:true}:Ie.has(e)?{executionScope:"local-only",fleetEligible:false}:{executionScope:"local-only",fleetEligible:false}:{executionScope:"local-only",fleetEligible:false}}function Ge(e,t){return E(t.runtime,e)?"core":"runtime"}function Ue(e,t,r,n){return !e||!n.lifecycleCommands.includes(t)?false:_(e,r.runtime,t,r.key)}function We(e,t){let r=!!e&&(t.runtime==="python"||w(t.runtime)&&_(e,t.runtime,"build",t.key));return N("docs",{owner:t.runtime==="python"?"core":"runtime",status:r?"supported":"unsupported",reason:r?t.runtime==="python"?"Documentation generation is delegated to Python Core for this project.":"Project documentation commands are available through the npm wrapper for this runtime.":"Documentation commands require a supported Python or npm-executor project manifest."})}function $e(e){let t=a.resolve(e),r=Te(e);return r||(h$1(t).length>0?t:null)}function Je(e=process.cwd()){let t=$e(e),r=t?ne(t):null,n=r?.detection??i(e,r?.projectJson??null),i$1=r?.moduleSupport??false,m=r?.engine??"unknown",f=se(n.runtime),C=x(n.runtime),pe=ce({runtime:n.runtime,moduleSupport:i$1,projectPath:t??void 0,framework:n.key}),g={};for(let o of W)g[o]=N(o,{owner:o==="project"?"core":"npm",status:"supported",reason:o==="project"?"Project detection is a Core contract; workspace project lifecycle remains npm-owned.":o==="help"?"Help is available for every Workspai project through the npm CLI.":"Universal command available across Workspai project types."});for(let o of A){let k=Ue(t,o,n,pe),Y=Ge(o,n),F=Be(o,k);g[o]=N(o,{owner:Y,status:k?"supported":"unsupported",executionScope:F.executionScope,fleetEligible:F.fleetEligible,reason:k?Y==="core"?`Delegated to Python Core for ${n.displayName} projects.`:F.fleetEligible?`Handled by runtime adapter and eligible for workspace fleet stages (${o}).`:o==="dev"?"Local development command only; workspace fleet excludes dev by design.":n.runtime==="node"?`Handled by npm/pnpm/yarn via the resolved ${o} script in package.json.`:`Handled by the ${f?.displayName??n.displayName} runtime adapter for local project execution.`:t?n.runtime==="node"?`No ${o} script was found in package.json for this ${n.displayName} project.`:w(n.runtime)?`The ${n.displayName} runtime is tracked, but ${o} is not available from detected project manifests.`:`${n.displayName} is tracked as an observed runtime; ${o} requires project manifests or explicit scripts.`:"No Workspai project was detected."});}g.docs=We(t,n);for(let o of $)g[o]=N(o,{owner:i$1?"core":"none",status:i$1?"supported":"unsupported",reason:i$1?"Core module/template command supported for this project.":`Core module/template commands are not available for ${n.displayName} projects.`});for(let o of J)g[o]=N(o,{owner:o==="create"?"npm":"core",status:"global",reason:o==="create"?"Create is orchestrated by npm for multi-language workspace support.":"Engine catalog command; not specific to the selected project runtime."});let v=Object.values(g),q=v.filter(o=>A.includes(o.command)).filter(o=>o.status==="supported"),le=I.filter(o=>q.some(k=>k.fleetEligible===true&&k.command===o)),ue=q.filter(o=>o.executionScope==="local-only").map(o=>o.command).sort();return {schemaVersion:1,scope:"project",projectRoot:t,engine:m,runtime:n.runtime,framework:n.key,frameworkDisplayName:n.displayName,frameworkConfidence:n.confidence,frameworkSupportTier:Q(n.key),runtimeSupportTier:C.tier,runtimeDoctorSupport:C.doctorSupport,moduleSupport:i$1,fleetStages:le,localOnlyCommands:ue,commandMap:g,supportedCommands:v.filter(o=>o.status==="supported").map(o=>o.command).sort(),unsupportedCommands:v.filter(o=>o.status==="unsupported").map(o=>o.command).sort(),globalCommands:v.filter(o=>o.status==="global").map(o=>o.command).sort()}}function ir(e,t=process.cwd()){let r=e[0];return r?Je(t).commandMap[r]??null:null}function ar(e){if(e[0]==="project"&&e[1]==="commands")return true;if(e[0]==="commands"&&e.includes("--scope")){let t=e.indexOf("--scope");return e[t+1]==="project"}return e.some(t=>t==="--scope=project")&&e[0]==="commands"}function sr(e,t){return [`Workspai command not supported for this project: ${e.command}`,"",`Project: ${t.projectRoot??"not detected"}`,`Runtime: ${t.runtime}`,`Framework: ${t.frameworkDisplayName}`,`Reason: ${e.reason??"Unsupported for this project type."}`,"","Run `workspai project commands` to inspect supported commands for this project."].join(`
2
- `)}export{P as a,qe as b,Ye as c,He as d,ze as e,x as f,Q as g,w as h,re as i,st as j,mt as k,ct as l,dt as m,pt as n,jt as o,ne as p,Ne as q,ht as r,Nt as s,ae as t,ce as u,Te as v,Je as w,ir as x,ar as y,sr as z};
@@ -1 +0,0 @@
1
- import {b}from'./chunk-J5ENLXDF.js';import {a,b as b$1}from'./chunk-S5KTATOU.js';function f(r){let s=new Map;for(let n of r.projects)s.has(n.name)||s.set(n.name,b(n));return s}function j(r){let s=f(r),n=r.graph??{nodes:r.projects.map(t=>({id:t.name,path:t.path})),edges:[]},a$1=a(n),o=new Map;for(let t of n.nodes){let e=s.get(t.id)??b({missing:t.id}),g=[...b$1(a$1,[t.id],{direction:"dependencies"}).keys()].filter(c=>c!==t.id).sort((c,l)=>c.localeCompare(l)).map(c=>({id:c,hash:s.get(c)??"<unknown>"}));o.set(t.id,{id:t.id,ownHash:e,transitiveInputsHash:b({own:e,dependencies:g})});}return o}function v(r,s){if(!s||Object.keys(s).length===0)return {verdict:"unknown",baseline:"none",changed:[],added:[],removed:[]};let n=[],a=[];for(let[e,i]of r.entries())e in s?s[e]!==i.transitiveInputsHash&&n.push(e):a.push(e);let o=[];for(let e of Object.keys(s))r.has(e)||o.push(e);return n.sort((e,i)=>e.localeCompare(i)),a.sort((e,i)=>e.localeCompare(i)),o.sort((e,i)=>e.localeCompare(i)),{verdict:n.length>0||a.length>0||o.length>0?"stale":"fresh",baseline:"recorded",changed:n,added:a,removed:o}}function w(r){let s={};for(let[n,a]of [...r.entries()].sort((o,t)=>o[0].localeCompare(t[0])))s[n]=a.transitiveInputsHash;return s}export{f as a,j as b,v as c,w as d};
@@ -1 +0,0 @@
1
- import {d as d$1,m}from'./chunk-T4YR4RAI.js';import {d,e}from'./chunk-32OJDBIG.js';import {a as a$1}from'./chunk-A5FBGRJA.js';import {o}from'./chunk-5XATWNME.js';import {r,p}from'./chunk-EYJ2CQSK.js';import a from'path';import {existsSync}from'fs';import u from'fs-extra';var f=".workspai/workspace-registry.v1.json",w="workspace-registry.v1";function x(r){return {slug:r.slug,relativePath:r.relativePath,framework:r.framework,kit:r.kit,source:r.source}}async function A(r){let e=o(r,"workspace.json").find(t=>existsSync(t));if(!e)return {exists:false,legacyProjectCount:0};try{let t=await u.readJson(e),c=Array.isArray(t.projects)?t.projects.length:0,o=typeof t.workspace_name=="string"&&t.workspace_name.trim()||typeof t.name=="string"&&t.name.trim()||a.basename(r);return {exists:true,manifestPath:e,workspaceName:o,profile:typeof t.profile=="string"?t.profile:void 0,legacyProjectCount:c}}catch{return {exists:true,manifestPath:e,legacyProjectCount:0,workspaceName:a.basename(r)}}}async function b(r$1){let e=a$1(r$1);for(let t of r())if(await u.pathExists(t))try{let o=((await u.readJson(t)).workspaces||[]).find(s=>a$1(s.path)===e);if(o)return {exists:true,projectCount:Array.isArray(o.projects)?o.projects.length:0,registryPath:t}}catch{continue}return {exists:false,projectCount:0,registryPath:a.join(p(),"workspaces.json")}}async function E(r,e){let t=a.resolve(r),c=await d(t,d$1),o=await A(t),s=await b(t),i=e?.contract!==void 0||!!c,n=[];if(e?.contract)n=e.contract.projects||[];else if(i)try{let{contract:d}=await m({workspacePath:t});n=d.projects||[];}catch{n=[];}let S={contract:{exists:i,projectCount:n.length,path:d$1},globalRegistry:{exists:s.exists,projectCount:s.projectCount,path:s.registryPath},legacyWorkspaceJson:{exists:o.exists,projectCount:o.legacyProjectCount,path:o.manifestPath?a.relative(t,o.manifestPath):void 0}},p="none",m$1=[],y=0;return i?(p="workspace.contract.json",m$1=n.map(x),y=m$1.length):s.projectCount>0?(p="global-registry",y=s.projectCount):o.legacyProjectCount>0&&(p="legacy-workspace.json",y=o.legacyProjectCount),{contractExists:i,summary:{schemaVersion:w,kind:"rapidkit.workspace.registry",workspacePath:t,workspaceName:o.workspaceName||a.basename(t),profile:o.profile,projectCount:y,authority:p,contractPath:d$1,projects:m$1,sources:S}}}async function Y(r){let e=await d(r,f);if(!e)return null;try{let t=await u.readJson(e);return t?.schemaVersion!==w?null:t}catch{return null}}async function D(r,e$1){let t=await _(r,e$1);return await e(r,f,t),t}async function _(r,e){return {...(await E(r,{contract:e?.contract})).summary,generatedAt:(e?.now??new Date).toISOString(),registrySummaryPath:f}}function H(r,e=""){return r.projectCount>0?r.authority==="workspace.contract.json"?`${r.projectCount} project(s) registered in workspace contract${e}.`:r.authority==="global-registry"?`${r.projectCount} project(s) registered in global workspace registry${e}.`:`${r.projectCount} project(s) registered in legacy workspace manifest${e}.`:`Workspace state exists, but no projects are registered yet${e}.`}export{f as a,w as b,E as c,Y as d,D as e,_ as f,H as g};
@@ -1,2 +0,0 @@
1
- import {a as a$1}from'./chunk-FXQJX34Z.js';import {w}from'./chunk-PHXQR6PX.js';import {a as a$2,d,c,e as e$1}from'./chunk-32OJDBIG.js';import {b as b$1}from'./chunk-3NU32T4A.js';import {a,b}from'./chunk-BMWFQXGW.js';import {e}from'./chunk-RO73VVHW.js';import {p,o}from'./chunk-5XATWNME.js';import {l}from'./chunk-OCGZNSOE.js';import m from'path';import g from'fs-extra';var ne="unknown-run";function M(e$1){let t=e();return !t||t===ne?e$1:{...e$1,runId:t}}var be="workspace-dependency-graph.v1",L=["code-import","package-dep","event-pub-sub","service-dependsOn","shared-resource"],U=["inferred","contract","manual"];var C=".workspai/workspace.contract.json",ae=a.contractVerify,v=1,se=b.contractVerify,j=class extends Error{constructor(o){super(`Workspace contract verification failed: ${o.violations.join("; ")}`);this.verification=o;this.name="WorkspaceContractVerificationError";}verification};function Z(e){return e.replace(/\\/g,"/")}function O(e){let t=Z(e).trim();return !t||t.startsWith("/")||t.startsWith("~")||/^[a-zA-Z]:\//.test(t)||t.includes("\0")?false:!t.split("/").filter(Boolean).some(o=>o===".."||o===".")}function z(e,t){return e.trim().toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^[-_.]+|[-_.]+$/g,"").slice(0,80)||t}function ce(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.trim().length>0):[]}function ie(e){let o=(Array.isArray(e.ports)?e.ports:[]).map(c=>{if(!c||typeof c!="object"||Array.isArray(c))return null;let d=c,f=Number(d.port);if(!Number.isInteger(f)||f<1||f>65535)return null;let u=d.protocol==="https"||d.protocol==="grpc"||d.protocol==="tcp"||d.protocol==="udp"?d.protocol:"http";return {name:typeof d.name=="string"&&d.name.trim()?d.name:"http",port:f,protocol:u}}).filter(c=>c!==null);if(o.length>0)return o;let n=e.frontend&&typeof e.frontend=="object"&&!Array.isArray(e.frontend)?e.frontend:void 0,s=Number(e.port??n?.default_port);return Number.isInteger(s)&&s>=1&&s<=65535?[{name:"http",port:s,protocol:"http"}]:[]}async function A(e){for(let t of e)if(await g.pathExists(t))return t;return null}async function pe(e){for(let t of o(e,"workspace.json"))try{let o=await g.readJson(t);return {name:typeof o.workspace_name=="string"&&o.workspace_name.trim()||typeof o.name=="string"&&o.name.trim()||m.basename(e),profile:typeof o.profile=="string"?o.profile:void 0}}catch{}return {name:m.basename(e)}}async function de(e){let t=[],o=[e],n=new Set,s=new Set([".git",".workspai",".rapidkit","node_modules",".venv","venv","dist","build","target",".next",".turbo",".cache"]);for(;o.length>0;){let c=o.shift();if(!c||n.has(c))continue;n.add(c);let d=await A(p(c,"project.json")),f=await A(p(c,"context.json"));if(d||f){t.push(d??f??"");continue}let u;try{u=await g.readdir(c,{withFileTypes:true});}catch{continue}for(let l of u)!l.isDirectory()||s.has(l.name)||o.push(m.join(c,l.name));}return t.sort()}function ue(e){let t=(e||"").toLowerCase();if(t.includes("fastapi"))return "fastapi";if(t.includes("nestjs"))return "nestjs";if(t.includes("springboot"))return "springboot";if(t.includes("gofiber"))return "fiber";if(t.includes("gogin"))return "gin"}function le(e,t){let o=(e||"").toLowerCase(),n=(t||"").toLowerCase();return o.includes("fastapi")?8e3:o.includes("nestjs")?3e3:o.includes("springboot")?8080:o.includes("gofiber")?3e3:o.includes("gogin")?8080:n==="node"?3e3:n==="python"?8e3:n==="java"||n==="go"?8080:null}function Y(e,t){let o=e;for(;t.has(o)&&o<65535;)o+=1;return o}function _(e,t,o){let n=e!==void 0&&e.source===void 0,s=le(t.kit,t.runtime),c=e?.ports||[],d=t.ports||[],u=(c.length>0?c:d.length>0?d:s?[{name:"http",port:Y(s,o),protocol:"http"}]:[]).map(i=>({...i,port:Y(i.port,o)}));for(let i of u)o.add(i.port);let l={...t,...e,slug:e?.slug||t.slug,relativePath:n&&e?.relativePath&&O(e.relativePath)?e.relativePath:t.relativePath,source:n&&e?.source||t.source,relationship:n&&e?.relationship||t.relationship,externalPath:n&&e?.externalPath||t.externalPath,runtime:e?.runtime||t.runtime,framework:e?.framework||t.framework,kit:e?.kit||t.kit,modules:e?.modules?.length?e.modules:t.modules,ports:u,contracts:{owns:e?.contracts?.owns||[],apis:e?.contracts?.apis||[],publishes:e?.contracts?.publishes||[],consumes:e?.contracts?.consumes||[],dependsOn:e?.contracts?.dependsOn||[],env:e?.contracts?.env||[]}},a=JSON.stringify(e||null)!==JSON.stringify(l);return {project:l,changed:a}}async function Q(e){let t=m.resolve(e.workspacePath),o=await pe(t),n=await de(t),s=await a$1(t),c=[];for(let l of s){let a=m.resolve(l.path),i=await A(p(a,"project.json"))??await A(p(a,"context.json"));!i||n.some(k=>m.resolve(k)===m.resolve(i))||c.push({projectJsonPath:i,registryEntry:l});}let d=[],f=[...n.map(l=>({projectJsonPath:l})),...c];for(let{projectJsonPath:l,registryEntry:a}of f){let i=m.dirname(m.dirname(l)),k=Z(m.relative(t,i)),h=a!==void 0&&!O(k),r=z(a?.name||m.basename(i),m.basename(i)),p=h?`external/${r}`:k||r,w=await g.readJson(l),y=typeof w.kit_name=="string"&&w.kit_name||typeof w.kit=="string"&&w.kit||void 0,R=typeof w.framework=="string"&&w.framework||ue(y);d.push({slug:a?.name||p||m.basename(i),relativePath:p,source:a?.source??"workspace",relationship:a?.relationship,externalPath:h?i:void 0,runtime:typeof w.runtime=="string"?w.runtime:void 0,framework:R,kit:y,modules:ce(w.modules),ports:ie(w),contracts:{owns:[],apis:[],publishes:[],consumes:[],dependsOn:[],env:[]}});}let u=new Map;for(let l of d){let a=z(l.slug,l.relativePath),i=u.get(a);(!i||i.source!=="workspace"&&l.source==="workspace")&&u.set(a,l);}return {schemaVersion:v,kind:"rapidkit.workspace.contract",generatedAt:(e.now??new Date).toISOString(),workspace:o,projects:[...u.values()]}}async function Te(e){let t=m.resolve(e.outputPath||a$2(e.workspacePath,C));if(await g.pathExists(t)&&e.force!==true)throw new Error(`Workspace contract already exists: ${t}. Use --force to overwrite.`);let o=await Q({workspacePath:e.workspacePath,now:e.now}),n=new Set,s={...o,projects:o.projects.map(d=>_(void 0,d,n).project)},c=await te({workspacePath:e.workspacePath,contractPath:t,contract:s});if(e.strict&&c.status==="failed")throw new j(c);return await X({workspacePath:e.workspacePath,contractPath:t,contract:s,now:e.now}),{contractPath:t,contract:s}}async function Ve(e){let t=m.resolve(e.workspacePath),o=a$2(t,C),n=await d(t,C)??o,s=await Q({workspacePath:t,now:e.now}),c=await g.pathExists(n)?await g.readJson(n):null,d$1=new Map((c?.projects||[]).map(h=>[h.slug,h])),f=new Set,u=[],l=[],a=[];for(let h of s.projects){let r=d$1.get(h.slug),p=_(r,h,f);r?p.changed&&l.push(h.slug):u.push(h.slug),a.push(p.project),d$1.delete(h.slug);}for(let h of d$1.values()){if(h.source)continue;let r=_(h,h,f);a.push(r.project);}let i={schemaVersion:v,kind:"rapidkit.workspace.contract",generatedAt:(e.now??new Date).toISOString(),workspace:{...s.workspace,...c?.workspace||{},name:c?.workspace?.name||s.workspace.name},projects:a.sort((h,r)=>h.slug.localeCompare(r.slug))},k=await te({workspacePath:t,contractPath:o,contract:i});if(e.strict&&k.status==="failed")throw new j(k);return await X({workspacePath:t,contractPath:o,contract:i,now:e.now}),{contractPath:o,contract:i,addedProjects:u,updatedProjects:l,verification:k}}async function q(e){return await g.pathExists(e)?{exists:true,contents:await g.readFile(e)}:{exists:false}}async function B(e,t){if(!t.exists){await g.remove(e);return}await g.outputFile(e,t.contents);}async function X(e){let{buildWorkspaceRegistrySummary:t,WORKSPACE_REGISTRY_SUMMARY_RELATIVE_PATH:o}=await import('./workspace-registry-summary-ORDK7A36.js'),n=await t(e.workspacePath,{now:e.now,contract:e.contract}),s=a$2(e.workspacePath,o),c$1=d=>{if(!d||typeof d!="object"||Array.isArray(d))return JSON.stringify(d);let{generatedAt:f,...u}=d;return JSON.stringify(u)};if(await g.pathExists(e.contractPath)&&await g.pathExists(s)){let[d,f]=await Promise.all([g.readJson(e.contractPath),g.readJson(s)]);if(c$1(d)===c$1(e.contract)&&c$1(f)===c$1(n))return}b$1(C,e.contract),b$1(o,n),await c(e.workspacePath,C,async()=>{let[d,f]=await Promise.all([q(e.contractPath),q(s)]);try{if(e.contractPath===a$2(e.workspacePath,C)?await e$1(e.workspacePath,C,e.contract):(await g.ensureDir(m.dirname(e.contractPath)),await g.writeJson(e.contractPath,e.contract,{spaces:2})),process.env.WORKSPAI_TEST_FAIL_WORKSPACE_REGISTRY_PUBLISH==="1")throw new Error("Injected workspace registry summary publication failure.");await e$1(e.workspacePath,o,n);}catch(u){let a=(await Promise.allSettled([B(e.contractPath,d),B(s,f)])).filter(i=>i.status==="rejected");throw a.length>0?new AggregateError([u,...a.map(i=>i.reason)],"Workspace contract publication failed and rollback was incomplete."):u}});}async function ee(e){let t=e.contractPath??(await d(e.workspacePath,C)||a$2(e.workspacePath,C)),o=await g.readJson(t);return {contractPath:t,contract:o}}var me={metadata:[".workspai/project.json",".workspai/context.json",".rapidkit/project.json",".rapidkit/context.json"],manifests:["package.json","package-lock.json","pnpm-lock.yaml","yarn.lock","pyproject.toml","poetry.lock","requirements.txt","go.mod","go.sum","pom.xml","build.gradle","build.gradle.kts","Cargo.toml","Gemfile","composer.json"],entrypoints:["src/main.ts","src/index.ts","src/app.ts","src/main.js","src/index.js","main.py","app/main.py","manage.py","main.go","cmd/main.go","Program.cs"],apiSpecifications:["openapi.yaml","openapi.yml","openapi.json","swagger.yaml","swagger.yml","swagger.json"],infrastructure:["Dockerfile","docker-compose.yml","docker-compose.yaml","compose.yml","compose.yaml","k8s","kubernetes","terraform"],documentation:["README.md","ARCHITECTURE.md","CONTRIBUTING.md","docs"]};function ge(e,t){return t.externalPath?m.resolve(t.externalPath):m.resolve(e,t.relativePath)}async function fe(e){let t={metadata:[],manifests:[],entrypoints:[],apiSpecifications:[],infrastructure:[],documentation:[]};for(let[o,n]of Object.entries(me))for(let s of n)await g.pathExists(m.join(e,s))&&t[o].push(s);try{let o=await g.readdir(e,{withFileTypes:true});for(let n of o)n.isFile()&&(n.name.endsWith(".csproj")||n.name.endsWith(".sln"))&&t.manifests.push(n.name),n.isFile()&&n.name.endsWith(".tf")&&t.infrastructure.push(n.name);}catch{}for(let o of Object.values(t))o.sort((n,s)=>n.localeCompare(s));return t}function W(e){return !e||typeof e!="object"||Array.isArray(e)?[]:Object.keys(e).sort((t,o)=>t.localeCompare(o))}async function he(e){try{let t=await g.readJson(m.join(e,"package.json")),o={runtime:W(t.dependencies),development:W(t.devDependencies),peer:W(t.peerDependencies),optional:W(t.optionalDependencies)};return {...typeof t.name=="string"?{name:t.name}:{},...typeof t.version=="string"?{version:t.version}:{},...typeof t.private=="boolean"?{private:t.private}:{},scripts:W(t.scripts),dependencies:o,dependencyCount:new Set(Object.values(o).flat()).size}}catch{return}}async function ke(e){for(let t of [".env.example",".env.sample",".env.template"])try{return (await g.readFile(m.join(e,t),"utf8")).split(/\r?\n/).map(n=>n.trim()).filter(n=>n.length>0&&!n.startsWith("#")&&n.includes("=")).map(n=>n.slice(0,n.indexOf("=")).trim()).filter(n=>/^[A-Za-z_][A-Za-z0-9_]*$/.test(n)).sort((n,s)=>n.localeCompare(s))}catch{}return []}function we(e,t){try{let o=w(e);if(o.engine!=="unknown")return o;let n=g.pathExistsSync(m.join(e,"package.json"))?"npm":g.pathExistsSync(m.join(e,"pyproject.toml"))?"python":g.pathExistsSync(m.join(e,"requirements.txt"))?"pip":"unknown";return {...o,engine:n,runtime:t.runtime??o.runtime,framework:t.framework??o.framework,frameworkDisplayName:t.framework??o.frameworkDisplayName}}catch{return {schemaVersion:1,scope:"project",projectRoot:null,engine:"unknown",runtime:"unknown",framework:"unknown",frameworkDisplayName:"Unknown",frameworkConfidence:"low",frameworkSupportTier:"observed",runtimeSupportTier:"observed",runtimeDoctorSupport:"observed",moduleSupport:false,fleetStages:[],localOnlyCommands:[],commandMap:{},supportedCommands:[],unsupportedCommands:[],globalCommands:[]}}}function Pe(e,t,o){let n=e.projects.map(s=>({id:s.slug,path:s.relativePath,runtime:s.runtime,framework:s.framework}));return {schemaVersion:"workspace-dependency-graph.v1",generatedAt:t,nodes:n,edges:[],stats:{nodeCount:n.length,edgeCount:0,inferredEdges:0,contractEdges:0,manualEdges:0,authoritativeEdges:0,lowConfidenceEdges:0,orphanCount:n.length,connectedNodeCount:0,density:0,edgeCoverageRatio:n.length===0?1:0,evidenceCoverageRatio:1,hotspotCount:0,hasCycle:false},diagnostics:[{code:"graph.enrichment.failed",severity:"warning",message:o,recommendation:"Review project manifests and graph overrides, then rerun workspace contract graph."}]}}async function Ke(e){let{contractPath:t,contract:o}=await ee(e),n=e.now??new Date,s=n.toISOString(),c;try{let{inferWorkspaceDependencyGraph:r}=await import('./workspace-dependency-graph-BP4EXYQ5.js');c=await r({workspacePath:e.workspacePath,contract:o,now:n,model:{projects:o.projects.map(p=>({name:p.slug,path:p.relativePath,...p.externalPath?{absolutePath:p.externalPath}:{},...p.runtime?{runtime:p.runtime}:{},...p.framework?{framework:p.framework}:{},...p.framework?{kind:p.framework}:{}}))}});}catch(r){c=Pe(o,s,`Graph enrichment failed: ${r instanceof Error?r.message:String(r)}`);}let d=new Map(c.nodes.map(r=>[r.id,r.operationalProfile])),{buildWorkspaceKnowledgeGraph:f}=await import('./workspace-knowledge-graph-ARDC6HHG.js'),u=await f({workspacePath:e.workspacePath,workspace:o.workspace,contract:o,projectTopology:c,now:n,projects:o.projects.map(r=>({id:r.slug,path:r.relativePath,...r.externalPath?{absolutePath:r.externalPath}:{},...r.runtime?{runtime:r.runtime}:{},...r.framework?{framework:r.framework}:{},...r.kit?{kit:r.kit}:{}}))}),l=await Promise.all(o.projects.map(async r=>{let p=ge(e.workspacePath,r),[w,y,R]=await Promise.all([fe(p),he(p),ke(p)]),P=we(p,r);return {id:r.slug,label:r.slug,relativePath:r.relativePath,source:r.source,relationship:r.relationship,externalPath:r.externalPath,runtime:r.runtime??P.runtime,framework:r.framework??P.framework,kit:r.kit,modules:r.modules,ports:r.ports,apis:r.contracts.apis,owns:r.contracts.owns,env:[...new Set([...r.contracts.env,...R])].sort((re,oe)=>re.localeCompare(oe)),contracts:{owns:[...r.contracts.owns],apis:[...r.contracts.apis],publishes:[...r.contracts.publishes],consumes:[...r.contracts.consumes],dependsOn:[...r.contracts.dependsOn],env:[...r.contracts.env]},capabilities:{engine:P.engine,supportTier:P.frameworkSupportTier,runtimeSupportTier:P.runtimeSupportTier,doctorSupport:P.runtimeDoctorSupport,moduleSupport:P.moduleSupport,fleetStages:[...P.fleetStages],localOnlyCommands:[...P.localOnlyCommands],supportedCommands:[...P.supportedCommands]},files:w,...y?{package:y}:{},...d.get(r.slug)?{operationalProfile:d.get(r.slug)}:{}}})),a=new Set(l.map(r=>r.id)),i=new Map,k=[];for(let r of o.projects){for(let p of r.contracts.dependsOn||[])a.has(p)&&k.push({from:p,to:r.slug,type:"dependency",label:"dependsOn"});for(let p of r.contracts.publishes||[])i.has(p)||i.set(p,new Set),i.get(p)?.add(r.slug);}for(let r of o.projects)for(let p of r.contracts.consumes||[]){let w=i.get(p);if(w)for(let y of w)y!==r.slug&&k.push({from:y,to:r.slug,type:"event",label:p});}let h={schemaVersion:1,kind:"rapidkit.workspace.contract.graph",workspace:o.workspace,generatedAt:s,nodes:l.sort((r,p)=>r.id.localeCompare(p.id)),edges:k.sort((r,p)=>`${r.from}:${r.to}:${r.type}:${r.label}`.localeCompare(`${p.from}:${p.to}:${p.type}:${p.label}`)),dependencyGraph:c,knowledgeGraph:u,semantics:{legacyEdges:"producer-to-consumer",dependencyGraphEdges:"consumer-to-dependency"},summary:{projectCount:l.length,dependencyEdges:k.filter(r=>r.type==="dependency").length,eventEdges:k.filter(r=>r.type==="event").length,portCount:l.reduce((r,p)=>r+p.ports.length,0),apiCount:l.reduce((r,p)=>r+p.apis.length,0),relationshipEdges:c.stats.edgeCount,inferredEdges:c.stats.inferredEdges,authoritativeEdges:c.stats.authoritativeEdges,orphanProjects:c.stats.orphanCount,hotspotProjects:c.stats.hotspotCount,evidenceCoverageRatio:c.stats.evidenceCoverageRatio,edgeCoverageRatio:c.stats.edgeCoverageRatio,connectedProjects:c.stats.connectedNodeCount,lowConfidenceEdges:c.stats.lowConfidenceEdges,hasCycle:c.stats.hasCycle,manifestCount:l.reduce((r,p)=>r+p.files.manifests.length,0),entrypointCount:l.reduce((r,p)=>r+p.files.entrypoints.length,0),diagnostics:c.diagnostics?.length??0,relationshipKinds:Object.fromEntries(L.map(r=>[r,c.edges.filter(p=>p.kind===r).length])),relationshipSources:Object.fromEntries(U.map(r=>[r,c.edges.filter(p=>p.source===r).length])),entityCount:u.quality.entityCount,knowledgeRelations:u.quality.relationCount,proofCount:u.quality.proofCount,providerCount:u.providers.length,knowledgeUnknowns:u.quality.unknownCount}};return {contractPath:t,graph:h}}async function te(e){let t=e.contract?{contractPath:e.contractPath??a$2(e.workspacePath,C),contract:e.contract}:await ee(e),{contractPath:o,contract:n}=t,s=[],c=[];n.kind!=="rapidkit.workspace.contract"&&s.push("Contract kind must be rapidkit.workspace.contract."),n.schemaVersion!==v&&s.push(`Contract schemaVersion must be ${v}.`),n.workspace?.name||s.push("Contract workspace.name is required."),Array.isArray(n.projects)||s.push("Contract projects must be an array.");let d=new Set,f=new Map;for(let a of n.projects||[]){if(!a.slug){s.push("Every project must declare slug.");continue}d.has(a.slug)&&s.push(`Duplicate project slug: ${a.slug}.`),d.add(a.slug),a.relativePath?O(a.relativePath)||s.push(`Project ${a.slug} declares unsafe relativePath: ${a.relativePath}.`):s.push(`Project ${a.slug} must declare relativePath.`),a.externalPath&&(a.relationship==="adopted"||a.source==="adopted-local"||a.source==="local-folder"||a.source==="git-url"||s.push(`Project ${a.slug} declares externalPath without imported/adopted provenance.`),m.isAbsolute(a.externalPath)||s.push(`Project ${a.slug} declares non-absolute externalPath.`));for(let i of a.ports||[]){(!Number.isInteger(i.port)||i.port<1||i.port>65535)&&s.push(`Project ${a.slug} declares invalid port: ${i.port}.`);let k=f.get(i.port);k&&s.push(`Port ${i.port} is claimed by both ${k} and ${a.slug}.`),f.set(i.port,a.slug);}for(let i of a.contracts?.apis||[])(!i.name?.trim()||!i.basePath?.startsWith("/"))&&s.push(`Project ${a.slug} declares invalid API contract.`);for(let i of [...a.contracts?.publishes||[],...a.contracts?.consumes||[]])i.trim()||s.push(`Project ${a.slug} declares an empty event contract.`);for(let i of a.contracts?.env||[])/^[A-Z_][A-Z0-9_]*$/.test(i)||s.push(`Project ${a.slug} declares invalid env contract: ${i}.`);for(let i of a.contracts?.dependsOn||[])d.has(i);}for(let a of n.projects||[])for(let i of a.contracts?.dependsOn||[])d.has(i)||s.push(`Project ${a.slug} depends on unknown project: ${i}.`);c.push({id:"schema",status:n.kind==="rapidkit.workspace.contract"&&n.schemaVersion===v?"passed":"failed",message:"Contract schema and kind are valid."}),c.push({id:"projects",status:Array.isArray(n.projects)?"passed":"failed",message:`Contract declares ${Array.isArray(n.projects)?n.projects.length:0} project(s).`}),c.push({id:"ports",status:s.some(a=>a.toLowerCase().includes("port"))?"failed":"passed",message:"Project port declarations are valid and collision-free."}),c.push({id:"dependencies",status:s.some(a=>a.includes("depends on unknown project"))?"failed":"passed",message:"Project dependencies point to known project slugs."}),c.push({id:"contracts",status:s.some(a=>a.includes("unsafe relativePath")||a.includes("invalid API contract")||a.includes("event contract")||a.includes("env contract"))?"failed":"passed",message:"Project path, API, event, and env contracts are valid."});let u=await l(e.workspacePath);if(u.moduleCount>0){for(let a of u.issues)s.push(`${m.basename(a.projectRoot)}: ${a.message} (slug=${a.slug})`);c.push({id:"module-paths",status:u.status,message:u.status==="passed"?`All ${u.moduleCount} registered module(s) resolve under canonical paths.`:`${u.issues.length} registered module(s) missing canonical install paths.`});}else e.strict&&c.push({id:"module-paths",status:"passed",message:"No registry-backed modules declared in workspace projects."});return {status:s.length>0?"failed":"passed",contractPath:o,projectCount:Array.isArray(n.projects)?n.projects.length:0,checks:c,violations:s}}async function $e(e){let t=m.resolve(e.workspacePath),o={schemaVersion:se,generatedAt:e.generatedAt??new Date().toISOString(),status:e.result.status,contractPath:e.result.contractPath,projectCount:e.result.projectCount,checks:e.result.checks,violations:e.result.violations};return e$1(t,ae,M(o))}
2
- export{M as a,be as b,L as c,C as d,ae as e,v as f,se as g,j as h,de as i,Q as j,Te as k,Ve as l,ee as m,Ke as n,te as o,$e as p};
@@ -1 +0,0 @@
1
- var M="workspace-knowledge-search.v1";function k(o){return o.trim().toLowerCase()}var I=new WeakMap;function h(o){let n=I.get(o);if(n)return n;let r=new Map(o.relations.map(t=>[t.id,t])),s=new Map(o.entities.map(t=>[t.id,t])),i=new Map(o.proofs.map(t=>[t.id,t])),a=new Map,d=new Map,l=(t,c)=>{let f=d.get(t)??[];f.push(c),d.set(t,f);};for(let t of o.entities){let c=[t.id,t.label,t.identity.key,...t.kind==="project"&&t.projectId?[t.projectId]:[],...t.identity.aliases];for(let f of new Set(c.map(k))){let w=a.get(f)??[];w.push(t),a.set(f,w);}}for(let t of o.relations)l(t.from,{from:t.from,to:t.to,relationId:t.id,kind:t.kind,direction:"forward",proofIds:t.proofIds}),l(t.to,{from:t.to,to:t.from,relationId:t.id,kind:t.kind,direction:"reverse",proofIds:t.proofIds});for(let t of a.values())t.sort((c,f)=>c.id.localeCompare(f.id));for(let t of d.values())t.sort((c,f)=>c.to.localeCompare(f.to)||c.relationId.localeCompare(f.relationId));let p={entitiesById:s,relationsById:r,entitiesByAlias:a,proofsById:i,adjacency:d};return I.set(o,p),p}function W(o,n){let r=h(o),s=r.relationsById.get(n);if(s)return {found:true,targetType:"relation",relation:s};let i=k(n),a=r.entitiesByAlias.get(i)??[];return a.length===1?{found:true,targetType:"entity",entity:a[0]}:{found:false,query:n,candidates:a.map(d=>d.id).sort()}}function S(o,n){let r=W(o,n);if(!r.found)return {query:n,found:false,target:null,proofs:[],candidates:r.candidates};let s=r.targetType==="entity"?r.entity:r.relation,i=new Set(s.proofIds);return {query:n,found:true,target:s,candidates:[],proofs:[...i].map(a=>h(o).proofsById.get(a)).filter(a=>!!a).sort((a,d)=>a.id.localeCompare(d.id))}}function b(o,n,r){let s=W(o,n),i=W(o,r);if(!s.found||s.targetType!=="entity"||!i.found||i.targetType!=="entity")return {from:n,to:r,found:false,resolvedFrom:s.found&&s.targetType==="entity"?s.entity.id:null,resolvedTo:i.found&&i.targetType==="entity"?i.entity.id:null,entityPath:[],hops:[],proofs:[]};let a=h(o),d=[s.entity.id],l=new Map,p=new Set(d),t=0;for(;t<d.length&&!p.has(i.entity.id);){let g=d[t++];for(let y of a.adjacency.get(g)??[])p.has(y.to)||(p.add(y.to),l.set(y.to,y),d.push(y.to));}if(!p.has(i.entity.id))return {from:n,to:r,found:false,resolvedFrom:s.entity.id,resolvedTo:i.entity.id,entityPath:[],hops:[],proofs:[]};let c=[],f=i.entity.id;for(;f!==s.entity.id;){let g=l.get(f);if(!g)break;c.push(g),f=g.from;}c.reverse();let w=new Set(c.flatMap(g=>g.proofIds));return {from:n,to:r,found:true,resolvedFrom:s.entity.id,resolvedTo:i.entity.id,entityPath:[s.entity.id,...c.map(g=>g.to)],hops:c,proofs:[...w].map(g=>a.proofsById.get(g)).filter(g=>!!g).sort((g,y)=>g.id.localeCompare(y.id))}}function B(o,n){return o.entities.filter(r=>!n||r.kind===n).sort((r,s)=>r.kind.localeCompare(s.kind)||r.label.localeCompare(s.label))}function P(o){let n=Object.values(o.attributes).flatMap(r=>Array.isArray(r)?r:[r]);return [o.id,o.kind,o.label,o.projectId??"",o.identity.key,...o.identity.aliases,...n.map(r=>String(r??""))].join(" ").toLowerCase()}function x(o,n,r){let s=k(o.label),i=k(o.identity.key),a=o.identity.aliases.map(k),d=P(o),l=0;(s===n||i===n||a.includes(n))&&(l+=1e3),(s.startsWith(n)||i.startsWith(n))&&(l+=250),d.includes(n)&&(l+=100);for(let p of r)s===p?l+=80:s.includes(p)&&(l+=30),i.includes(p)&&(l+=20),d.includes(p)&&(l+=10);return l}function R(o,n){let r=k(n.query),s=[...new Set(r.split(/[^a-z0-9_.:/@-]+/u).filter(e=>e.length>1))],i=Math.max(1,Math.min(Math.trunc(n.limit??12),100)),a=Math.max(0,Math.min(Math.trunc(n.relationsPerEntity??4),20)),d=o.entities.filter(e=>!n.kind||e.kind===n.kind).map(e=>({entity:e,score:x(e,r,s)})).filter(e=>r.length===0||e.score>0).sort((e,u)=>u.score-e.score||e.entity.kind.localeCompare(u.entity.kind)||e.entity.label.localeCompare(u.entity.label)),l=d.slice(0,i).map(e=>e.entity),p=new Set(l.map(e=>e.id)),t=new Map,c=o.relations.filter(e=>{if(!(p.has(e.from)||p.has(e.to)))return false;let K=p.has(e.from)?e.from:e.to,m=t.get(K)??0;return m>=a?false:(t.set(K,m+1),true)}),f=h(o),g=[...new Set(c.flatMap(e=>[e.from,e.to]).filter(e=>!p.has(e)))].map(e=>f.entitiesById.get(e)).filter(e=>!!e).map(({id:e,kind:u,label:K,projectId:m})=>({id:e,kind:u,label:K,...m?{projectId:m}:{}})).sort((e,u)=>e.kind.localeCompare(u.kind)||e.label.localeCompare(u.label)),E=[...new Set([...l.flatMap(e=>e.proofIds),...c.flatMap(e=>e.proofIds)])].map(e=>f.proofsById.get(e)).filter(e=>!!e).sort((e,u)=>e.id.localeCompare(u.id));return {schemaVersion:M,query:n.query,kind:n.kind??null,limit:i,totalMatches:d.length,truncated:d.length>l.length,entities:l,relatedEntities:g,relations:c,proofs:E}}export{M as a,W as b,S as c,b as d,B as e,R as f};
@@ -1,5 +0,0 @@
1
- import {f}from'./chunk-7YHK5NM3.js';import {b as b$1}from'./chunk-2FIX2MDC.js';import {execa}from'execa';import l from'chalk';import {createRequire}from'module';import {promises}from'fs';import p from'path';import k from'os';function g(r){let n=r.startsWith("WORKSPAI_")?r:`WORKSPAI_${r.replace(/^RAPIDKIT_/,"")}`,e=r.startsWith("RAPIDKIT_")?r:`RAPIDKIT_${r.replace(/^WORKSPAI_/,"")}`,t=process.env[n]?.trim();return t||process.env[e]?.trim()||void 0}var C="workspai",V=createRequire(import.meta.url),E=V("../package.json"),o=E?.version??"0.0.0";function b(r){let e=r.trim().match(/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/);if(!e)return null;let t=e[4]?e[4].split(".").map(i=>i.match(/^\d+$/)?Number(i):i):[];return {major:Number(e[1]),minor:Number(e[2]),patch:Number(e[3]),prerelease:t}}function w(r,n){let e=b(r),t=b(n);if(!e||!t)return 0;if(e.major!==t.major)return e.major>t.major?1:-1;if(e.minor!==t.minor)return e.minor>t.minor?1:-1;if(e.patch!==t.patch)return e.patch>t.patch?1:-1;if(e.prerelease.length===0&&t.prerelease.length===0)return 0;if(e.prerelease.length===0)return 1;if(t.prerelease.length===0)return -1;let i=Math.max(e.prerelease.length,t.prerelease.length);for(let u=0;u<i;u+=1){let a=e.prerelease[u],s=t.prerelease[u];if(a===void 0)return -1;if(s===void 0)return 1;if(a===s)continue;let d=typeof a=="number",f=typeof s=="number";return d&&f?a>s?1:-1:d?-1:f||String(a)>String(s)?1:-1}return 0}var I=14400*1e3;function y(){let r=g("CACHE_DIR")||(process.env.VITEST_WORKER_ID?p.join(k.homedir(),".workspai","cache",`vitest-${process.env.VITEST_WORKER_ID}`):p.join(k.homedir(),".workspai","cache"));return p.join(r,"update-check.json")}async function N(){try{let r=await promises.readFile(y(),"utf-8"),n=JSON.parse(r);return typeof n.latestVersion=="string"&&typeof n.checkedAt=="number"&&n.currentVersion===o&&Date.now()-n.checkedAt<I?n:null}catch{return null}}async function P(r){try{let n=y();await promises.mkdir(p.dirname(n),{recursive:true}),await promises.writeFile(n,JSON.stringify({latestVersion:r,checkedAt:Date.now(),currentVersion:o}),"utf-8");}catch{}}async function M(){try{f.debug("Checking for updates...");let r=await N();if(r){let t=Math.round((Date.now()-r.checkedAt)/6e4);f.debug(`Update check: cache hit (${t}m old)`),w(r.latestVersion,o)>0&&(console.log(l.yellow(`
2
- \u26A0\uFE0F Update available: ${o} \u2192 ${r.latestVersion}`)),console.log(l.cyan(`Run: npm install -g workspai@latest
3
- `)));return}let{stdout:n}=await execa("npm",["view",C,"version"],{timeout:b$1()}),e=n.trim();await P(e),e&&w(e,o)>0?(console.log(l.yellow(`
4
- \u26A0\uFE0F Update available: ${o} \u2192 ${e}`)),console.log(l.cyan(`Run: npm install -g workspai@latest
5
- `))):f.debug("You are using the latest version");}catch{f.debug("Could not check for updates");}}function J(){return o}export{g as a,M as b,J as c};
@@ -1 +0,0 @@
1
- import {b}from'./chunk-BMWFQXGW.js';var i=b.doctor,s="doctor-project-evidence-v1";function f(r){return !r||typeof r!="object"||Array.isArray(r)?null:r}function u(r,n){let t=f(r);if(!t)return false;let o=t.schemaVersion,e=t.evidenceType;return !(typeof o=="string"&&(o!==i&&o!==s||n==="workspace"&&o!==i||n==="project"&&o!==s)||typeof e=="string"&&(e!=="workspace"&&e!=="project"||n&&e!==n))}export{i as a,s as b,u as c};
@@ -1,5 +0,0 @@
1
- import {a as a$3}from'./chunk-54EP5CEV.js';import {c}from'./chunk-K4X3DM7R.js';import {q}from'./chunk-BFLJ2R4D.js';import {d as d$1}from'./chunk-TIE2XMGH.js';import {c as c$1}from'./chunk-FPJNWPKU.js';import {a as a$4}from'./chunk-BGPXQQNY.js';import {f,e}from'./chunk-T3GJ7YVG.js';import {a}from'./chunk-22DT744Z.js';import {d,a as a$2,e as e$1}from'./chunk-32OJDBIG.js';import {a as a$1}from'./chunk-BMWFQXGW.js';import c$2 from'chalk';import p from'path';function G(a){return a===0?"pass":a===2?"warn":"fail"}function I(a){return a.some(r=>r.status==="fail")?"blocked":a.some(r=>r.status==="warn")?"needs-attention":"ready"}function j(a,r){if(r)return 3;let i=a.some(o=>o.status==="fail"),t=a.some(o=>o.status==="warn");return i?1:t?2:0}function N(a,r){return a===2&&!r?0:a}async function O(a){let r=await d$1(a,true),i=false;try{let{syncWorkspaceContract:t}=await import('./workspace-contract-TU2I7GC2.js');await t({workspacePath:a}),i=true;}catch{i=false;}return {sync:r,contractSynced:i}}async function V(a$5={}){let r=p.resolve(a$5.workspacePath??process.cwd()),i=a(r);if(!i)throw new Error("No Workspai workspace found in current directory or parents");let t=[],o=[],l=false,d$1,f$1,m,y=Date.now();try{let{sync:e,contractSynced:s}=await O(i),n=e.workspaceFound&&(e.added.length>0||e.skipped>=0)||e.workspaceFound?"pass":"warn";t.push({name:"sync",status:n,durationMs:Date.now()-y,summary:e.workspaceFound?`registry sync complete (${e.added.length} added, ${e.skipped} existing)${s?", contract synced":""}`:"workspace not registered in global registry; contract sync attempted"}),e.workspaceFound||o.push("workspace registry entry missing \u2014 run workspai create workspace or register manually");}catch(e){l=true,t.push({name:"sync",status:"fail",durationMs:Date.now()-y,summary:`sync failed: ${e instanceof Error?e.message:String(e)}`}),o.push("workspace sync stage failed");}let w=Date.now();try{let e=await q({workspace:true,json:true,quiet:true,strict:a$5.strict===true,ci:a$5.strict!==true}),s=G(e),n=await d(i,a$1.doctor)??a$2(i,a$1.doctor);t.push({name:"doctor",status:s,durationMs:Date.now()-w,summary:s==="pass"?"doctor workspace passed":s==="warn"?"doctor workspace reported warnings":"doctor workspace did not pass",exitCode:e,evidencePath:n}),s==="fail"?o.push("doctor workspace gate failed"):s==="warn"&&o.push("doctor workspace reported warnings");}catch(e){l=true,t.push({name:"doctor",status:"fail",durationMs:Date.now()-w,summary:`doctor failed: ${e instanceof Error?e.message:String(e)}`}),o.push("doctor workspace stage failed");}if(a$5.skipAnalyze)t.push({name:"analyze",status:"skipped",durationMs:0,summary:"analyze stage skipped"});else {let e=Date.now();try{let s=await a$3({workspacePath:i,json:true,strict:a$5.strict===true});d$1=p.isAbsolute(s.enterpriseControls.evidencePath)?s.enterpriseControls.evidencePath:p.join(i,s.enterpriseControls.evidencePath);let n=s.summary.verdict==="blocked"?"fail":s.summary.verdict==="needs-attention"?"warn":"pass";t.push({name:"analyze",status:n,durationMs:Date.now()-e,summary:`analyze verdict: ${s.summary.verdict} (score ${s.summary.score}/100)`,evidencePath:d$1}),n==="fail"?o.push("analyze reported blocked verdict"):n==="warn"&&o.push("analyze reported needs-attention verdict");}catch(s){l=true,t.push({name:"analyze",status:"fail",durationMs:Date.now()-e,summary:`analyze failed: ${s instanceof Error?s.message:String(s)}`}),o.push("analyze stage failed");}}let h=Date.now();try{let e=await a$4({startPath:i,writeReport:true,skipVerify:a$5.skipVerify===true});f$1=e.evidencePath;let s=e.overallStatus==="pass"?"pass":e.overallStatus==="warn"?"warn":"fail";t.push({name:"readiness",status:s,durationMs:Date.now()-h,summary:`readiness overall: ${e.overallStatus}`,evidencePath:e.evidencePath}),s==="fail"?o.push(...e.blockingReasons.map(n=>`readiness: ${n}`)):s==="warn"&&o.push(...e.gates.filter(n=>n.status==="warn").map(n=>`readiness warn: ${n.gate}: ${n.summary}`));}catch(e){l=true,t.push({name:"readiness",status:"fail",durationMs:Date.now()-h,summary:`readiness failed: ${e instanceof Error?e.message:String(e)}`}),o.push("readiness stage failed");}if(a$5.skipAutopilot)t.push({name:"autopilot",status:"skipped",durationMs:0,summary:"autopilot stage skipped"});else {let e=Date.now(),s=a$5.autopilotMode??"audit";try{let n=await c({workspacePath:i,mode:s,json:true,skipPipelineStages:true});m=n.artifacts.reportPath;let P=n.summary.verdict==="approved"?"pass":n.summary.verdict==="partial"?"warn":"fail";t.push({name:"autopilot",status:P,durationMs:Date.now()-e,summary:`autopilot ${s}: ${n.summary.verdict}`,exitCode:n.summary.exitCode,evidencePath:m}),P!=="pass"&&o.push(...n.blockingReasons.slice(0,5));}catch(n){l=true,t.push({name:"autopilot",status:"fail",durationMs:Date.now()-e,summary:`autopilot failed: ${n instanceof Error?n.message:String(n)}`}),o.push("autopilot release stage failed");}}let M=I(t),k=j(t,l),F=p.join(i,".workspai","reports","pipeline-last-run.json"),u={schemaVersion:"rapidkit-pipeline-v1",generatedAt:new Date().toISOString(),workspacePath:i,summary:{verdict:M,exitCode:k,stagesPassed:t.filter(e=>e.status==="pass").length,stagesWarn:t.filter(e=>e.status==="warn").length,stagesFailed:t.filter(e=>e.status==="fail").length},stages:t,blockingReasons:[...new Set(o)],artifacts:{reportPath:F,analyzeEvidencePath:d$1,readinessEvidencePath:f$1,autopilotEvidencePath:m}};if(a$5.writeReport!==false){let e$2=f(u,{commandId:"workspacePipeline",exitCode:k,generatedAt:u.generatedAt,blockers:u.blockingReasons,runId:e()});await e$1(i,".workspai/reports/pipeline-last-run.json",e$2);}if(a$5.writeReport!==false&&a$5.noAgentSync!==true&&process.env.RAPIDKIT_NO_AGENT_SYNC!=="1"&&a$5.agentSync!==false)try{let{syncWorkspaceAgentGrounding:e}=await import('./workspace-agent-sync-662QHXGF.js'),s=await e({workspacePath:i,write:true,refreshContext:true,strict:false});u.agentGrounding={indexPath:s.indexPath,writtenFiles:s.writtenFiles,blockers:s.blockers};}catch{}return u}async function ae(a){let r;try{r=await V(a);}catch(t){let o=t instanceof Error?t.message:String(t);a.json?console.log(JSON.stringify(c$1({operation:"pipeline",code:"pipeline.failed",message:o}),null,2)):console.log(c$2.red(`Pipeline failed: ${o}`)),process.exit(1);}if(a.json)console.log(JSON.stringify(r,null,2));else {console.log(c$2.bold.cyan(`
2
- \u{1F517} Workspai Governance Pipeline
3
- `)),console.log(c$2.bold(`Workspace: ${c$2.cyan(p.basename(r.workspacePath))}`)),console.log(c$2.gray(`Path: ${r.workspacePath}`)),console.log(c$2.white(`Verdict: ${r.summary.verdict} Exit: ${r.summary.exitCode} (${r.summary.stagesPassed} pass / ${r.summary.stagesWarn} warn / ${r.summary.stagesFailed} fail)`));for(let t of r.stages){let o=t.status==="pass"?c$2.green("PASS"):t.status==="warn"?c$2.yellow("WARN"):t.status==="skipped"?c$2.gray("SKIP"):c$2.red("FAIL");console.log(` - ${t.name}: ${o} ${t.summary}`);}if(r.blockingReasons.length>0){console.log(c$2.bold(`
4
- Blocking reasons:`));for(let t of r.blockingReasons.slice(0,8))console.log(c$2.gray(` \u2022 ${t}`));}console.log(c$2.gray(`
5
- Evidence: ${r.artifacts.reportPath}`)),r.agentGrounding?.writtenFiles.length&&console.log(c$2.gray(`Agent grounding: ${r.agentGrounding.writtenFiles.length} file(s) synced (INDEX + AGENTS.md + Copilot/Cursor/Claude hooks)`));}let i=N(r.summary.exitCode,a.strict===true);i!==0&&process.exit(i);}export{N as pipelineProcessExitCode,V as runPipeline,ae as runPipelineCommand};
@@ -1 +0,0 @@
1
- export{f as augmentPathWithNodeBin,g as buildPackageRunnerSubprocessEnv,a as detectPlatformKind,h as getDefaultPythonCommand,q as getLegacyWorkspaceRegistryDirectory,i as getPythonCommandCandidates,j as getPythonVersionProbeCandidates,o as getRapidkitLocalScriptCandidates,s as getUserLocalBinCandidates,n as getVenvActivateScriptPath,k as getVenvBinDirectory,l as getVenvPythonPath,m as getVenvRapidkitPath,p as getWorkspaceRegistryDirectory,r as getWorkspaceRegistryFileCandidates,b as isWindowsPlatform,d as resolvePackageRunnerExecutable,e as resolvePackageRunnerInvocation,c as shouldUseShellExecution}from'./chunk-EYJ2CQSK.js';
@@ -1 +0,0 @@
1
- export{h as createProject,g as createWorkspace,j as createWorkspaceShareBundle,i as listWorkspaces,a as normalizeWorkspaceEntry,f as registerProjectInWorkspace,e as registerProjectInWorkspaceStrict,c as registerWorkspace,b as registerWorkspaceStrict,d as syncWorkspaceProjects}from'./chunk-TIE2XMGH.js';
@@ -1,10 +0,0 @@
1
- import {e,c,b as b$1,d}from'./chunk-52PBRX7F.js';import {a}from'./chunk-KB44JP4M.js';import {f as f$1,o,l,r}from'./chunk-5XATWNME.js';import z from'crypto';import Z from'os';import f from'path';import {once}from'events';import {createWriteStream,createReadStream}from'fs';import*as X from'readline';import {Transform,Readable}from'stream';import {pipeline}from'stream/promises';import {lookup}from'dns/promises';import N from'net';import h from'fs-extra';import*as q from'yauzl';import*as Y from'yazl';var P=".workspai/archive-manifest.json",S=".rapidkit/archive-manifest.json",he="workspai.workspace.archive",fe=300*1e3,le=5*1024*1024*1024,pe=20*1024*1024*1024,j=2e5,me=5*1024*1024*1024,ue=1e3,O=5,de=64*1024*1024;function ve(r){let t=r.toLowerCase().split("%")[0];if(N.isIPv4(t)){let e=t.split(".").map(Number);return e[0]===0||e[0]===10||e[0]===127||e[0]===169&&e[1]===254||e[0]===172&&e[1]>=16&&e[1]<=31||e[0]===192&&e[1]===168||e[0]===100&&e[1]>=64&&e[1]<=127||e[0]>=224}return N.isIPv6(t)?t==="::"||t==="::1"||t.startsWith("fc")||t.startsWith("fd")||/^fe[89ab]/.test(t)||t.startsWith("ff")||t.startsWith("::ffff:127.")||t.startsWith("::ffff:10.")||t.startsWith("::ffff:192.168."):true}async function K(r,t){let e=new URL(r);if(e.protocol!=="https:"&&e.protocol!=="http:")throw new Error(`Workspace archive URL protocol is not supported: ${e.protocol}`);if(e.protocol!=="https:"&&!t)throw new Error("Remote workspace archives require HTTPS unless private-network access is explicitly enabled.");if(e.username||e.password)throw new Error("Workspace archive URL must not contain embedded credentials.");if(t)return e;let a=e.hostname.replace(/^\[|\]$/g,"").toLowerCase();if(a==="localhost"||a.endsWith(".localhost"))throw new Error("Workspace archive URL resolves to a private or local network address.");let i=N.isIP(a)?[{address:a}]:await lookup(a,{all:true,verbatim:true});if(i.length===0||i.some(({address:s})=>ve(s)))throw new Error("Workspace archive URL resolves to a private or local network address.");return e}async function we(r,t,e){let a=await K(r,e);for(let i=0;i<=O;i+=1){let s=await fetch(a,{signal:t,redirect:"manual",credentials:"omit"});if(![301,302,303,307,308].includes(s.status))return s;let n=s.headers.get("location");if(await s.body?.cancel(),!n)throw new Error("Workspace archive redirect is missing a Location header.");if(i===O)throw new Error(`Workspace archive download exceeded ${O} redirects.`);a=await K(new URL(n,a).href,e);}throw new Error("Workspace archive redirect policy failed.")}var ye=new Set(["__pycache__",".venv","venv","node_modules",".git","dist","build","target",".pytest_cache",".mypy_cache",".ruff_cache","htmlcov",".next",".turbo",".cache"]),ge=new Set([".DS_Store","Thumbs.db",".coverage","npm-debug.log","yarn-error.log","pnpm-debug.log"]),Ee=[/^\.env$/i,/^\.env\.(?!example$|sample$|template$).+/i,/^.*\.pem$/i,/^.*\.key$/i,/^id_rsa$/i,/^id_ed25519$/i];function R(r){return r.replace(/\\/g,"/")}function G(r){return r.trim().replace(/\.workspai-archive\.zip$/i,"").replace(/\.rapidkit-archive\.zip$/i,"").replace(/\.zip$/i,"").trim().toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^[-_.]+|[-_.]+$/g,"").slice(0,64)||"imported-workspace"}function Q(r){let t=R(r).trim();if(!t||t.startsWith("/")||t.startsWith("~")||/^[a-zA-Z]:\//.test(t)||t.includes("\0"))return false;let e=t.split("/").filter(Boolean);return e.length>0&&!e.some(a=>a===".."||a===".")}function ee(r){if(!Q(r))throw new Error(`Archive contains an unsafe path: ${r}`)}function Ae(r,t){let e=f.relative(t,r);return e===""||!!e&&!e.startsWith("..")&&!f.isAbsolute(e)}function ke(r,t){let a=R(r).split("/").filter(Boolean);if((a[0]===".workspai"||a[0]===".rapidkit")&&["cache","reports"].includes(a[1]||"")||a.some(s=>ye.has(s)))return true;let i=a[a.length-1]||"";return ge.has(i)||/\.(?:workspai|rapidkit)-archive\.zip$/i.test(i)||!t?.includeEnv&&Ee.some(s=>s.test(i))?true:i.endsWith(".pyc")||i.endsWith(".log")}async function*te(r,t,e){let a=(await h.readdir(t,{withFileTypes:true})).sort((i,s)=>i.name.localeCompare(s.name));for(let i of a){let s=f.join(t,i.name),n=R(f.relative(r,s));if(!(!n||ke(n,e))){if(i.isDirectory()){yield*te(r,s,e);continue}i.isFile()&&(yield {relativePath:n,fullPath:s});}}}async function Pe(r){for(let t of o(r,"workspace.json"))try{let e=await h.readJson(t);if(typeof e.workspace_name=="string"&&e.workspace_name.trim())return e.workspace_name.trim();if(typeof e.name=="string"&&e.name.trim())return e.name.trim()}catch{}return f.basename(f.resolve(r))}async function We(r){let t=await h.stat(r.fullPath),e=z.createHash("sha256"),a=0;for await(let s of createReadStream(r.fullPath)){let n=Buffer.isBuffer(s)?s:Buffer.from(s);a+=n.length,e.update(n);}let i=await h.stat(r.fullPath);if(t.size!==i.size||t.mtimeMs!==i.mtimeMs||a!==i.size)throw new Error(`Workspace file changed while preparing archive: ${r.relativePath}`);return {...r,size:a,mtimeMs:i.mtimeMs,sha256:e.digest("hex")}}async function k(r,t){r.write(t)||await once(r,"drain");}async function re(r){await new Promise((t,e)=>{r.once("error",e),r.end(t);});}async function*b(r){let t=X.createInterface({input:createReadStream(r),crlfDelay:1/0});for await(let e of t){let a=e.trim();a&&(yield JSON.parse(a));}}async function Se(r){let t=createWriteStream(r.manifestPath,{flags:"wx"});try{await k(t,`{
2
- `);for(let[a,i]of Object.entries(r.manifestBase))await k(t,` ${JSON.stringify(a)}: ${JSON.stringify(i,null,2)},
3
- `);await k(t,` "files": [
4
- `);let e=true;for await(let a of b(r.spoolPath)){let{mtimeMs:i,...s}=a;await k(t,`${e?"":`,
5
- `} ${JSON.stringify(s)}`),e=false;}await k(t,`
6
- ]
7
- }
8
- `),await re(t);}catch(e){throw t.destroy(),await h.remove(r.manifestPath).catch(()=>{}),e}}async function Re(r,t){let e=[];for await(let a of b(t)){let{mtimeMs:i,...s}=a;e.push(s);}return {...r,files:e}}async function _e(r,t){try{await h.rename(r,t);}catch(e){let a=e.code;if(a!=="EEXIST"&&a!=="EPERM")throw e;await h.move(r,t,{overwrite:true});}}async function Ge(r){let t=f.resolve(r.workspacePath);if(!f$1(t))throw new Error("Workspace export requires a Workspai workspace root with .workspai-workspace or a legacy .rapidkit-workspace marker.");let e=await Pe(t),a=f.resolve(r.outputPath||`${G(e)}.workspai-archive.zip`),i={schemaVersion:b$1,version:1,kind:he,workspaceName:e,exportedAt:(r.now??new Date).toISOString(),exportedBy:"workspai",archiveFormat:r.compression==="deflate"?"zip-deflate":"zip-store",containerFormat:"zip64",compression:r.compression==="deflate"?"deflate":"store",streaming:true,security:{envFilesIncluded:r.includeEnv===true,excludedByDefault:[".git","node_modules",".venv","dist","build","target",".env","*.pem","*.key","*.log"]}},s=f.resolve(a);await h.ensureDir(f.dirname(a));let n=`${a}.${process.pid}.${z.randomUUID()}.tmp`,o=await h.mkdtemp(f.join(Z.tmpdir(),"workspai-archive-export-")),p=f.join(o,"manifest-files.jsonl"),l=f.join(o,"archive-manifest.json"),u=new Y.ZipFile,y=r.now??new Date,c$1=r.compression==="deflate";try{let m=createWriteStream(p,{flags:"wx"});try{for await(let d of te(t,t,{includeEnv:r.includeEnv===true})){if(f.resolve(d.fullPath)===s)continue;let v=await We(d),E={path:v.relativePath,size:v.size,sha256:v.sha256,mtimeMs:v.mtimeMs};await k(m,`${JSON.stringify(E)}
9
- `);}await re(m);}catch(d){throw m.destroy(),d}await Se({manifestBase:i,spoolPath:p,manifestPath:l});for await(let d of b(p)){let v=f.join(t,...d.path.split("/"));u.addFile(v,d.path,{compress:c$1,forceZip64Format:d.size>=4294967295,mtime:y});}u.addFile(l,P,{compress:c$1,mtime:y}),u.end({forceZip64Format:true,comment:""}),await pipeline(u.outputStream,createWriteStream(n,{flags:"wx"}));for await(let d of b(p)){let v=f.join(t,...d.path.split("/")),E=await h.stat(v);if(E.size!==d.size||E.mtimeMs!==d.mtimeMs)throw new Error(`Workspace file changed while writing archive: ${d.path}`)}let g=await h.stat(n);await _e(n,a);let w=await Re(i,p);return _({schemaVersion:c,operation:"export",status:"passed",archivePath:a,manifest:w,bytesWritten:g.size})}finally{await h.remove(o).catch(()=>{}),await h.remove(n).catch(()=>{});}}async function ae(r,t={}){if(/^https?:\/\//i.test(r)){let e=await h.mkdtemp(f.join(Z.tmpdir(),"workspai-workspace-archive-")),a=f.join(e,"workspace.workspai-archive.zip"),i=new AbortController,s=t.downloadTimeoutMs??fe,n=s>0?setTimeout(()=>i.abort(new Error("Download timed out")),s):null;try{let o=await we(r,i.signal,t.allowPrivateNetwork===true);if(!o.ok)throw new Error(`Failed to download workspace archive: HTTP ${o.status}`);if(!o.body)throw new Error("Failed to download workspace archive: response body is empty.");let p=t.maxDownloadBytes??le,l=Number(o.headers.get("content-length"));if(Number.isFinite(l)&&l>p)throw new Error(`Workspace archive download exceeds configured limit (${l} > ${p} bytes).`);let u=0,y=new Transform({transform(m,g,w){if(u+=m.length,u>p){w(new Error(`Workspace archive download exceeds configured limit (${p} bytes).`));return}w(null,m);}}),c=Readable.fromWeb(o.body);return await pipeline(c,y,createWriteStream(a,{flags:"wx"})),{archivePath:a,cleanup:e}}catch(o){throw await h.remove(e).catch(()=>{}),i.signal.aborted?new Error(`Workspace archive download timed out after ${s}ms.`,{cause:o}):o}finally{n&&clearTimeout(n);}}return {archivePath:f.resolve(r)}}function be(r){return new Promise((t,e)=>{q.open(r,{autoClose:false,lazyEntries:true,decodeStrings:true,validateEntrySizes:true,strictFileNames:true},(a,i)=>{a||!i?e(a??new Error("Failed to open workspace archive.")):t(i);});})}function ze(r){return new Promise((t,e)=>{let a=[],i=s=>e(s);r.once("error",i),r.on("entry",s=>{try{if(ee(s.fileName),s.isEncrypted())throw new Error(`Encrypted workspace archive entries are not supported: ${s.fileName}`);s.fileName.endsWith("/")||a.push({name:s.fileName,size:s.uncompressedSize,compressedSize:s.compressedSize,crc32:s.crc32,entry:s}),r.readEntry();}catch(n){e(n);}}),r.once("end",()=>{r.removeListener("error",i),t(a);}),r.readEntry();})}function M(r,t){return new Promise((e,a)=>{r.openReadStream(t,(i,s)=>{i||!s?a(i??new Error(`Failed to read ${t.fileName}.`)):e(s);});})}async function xe(r,t,e=de){if(t.size>e)throw new Error(`Workspace archive manifest exceeds ${e} bytes.`);let a=[],i=0,s=await M(r,t.entry);for await(let n of s){let o=Buffer.isBuffer(n)?n:Buffer.from(n);if(i+=o.length,i>e)throw s.destroy(),new Error(`Workspace archive manifest exceeds ${e} bytes.`);a.push(o);}return Buffer.concat(a,i)}function Oe(r){let t=JSON.parse(r.toString("utf-8"));a(t,d,"Workspace archive manifest");let e=new Set;for(let a of t.files){if(!Q(a.path)||R(a.path)!==a.path)throw new Error(`Workspace archive manifest contains an unsafe path: ${a.path}`);if(a.path===P||a.path===S)throw new Error(`Workspace archive manifest cannot inventory itself: ${a.path}`);if(e.has(a.path))throw new Error(`Workspace archive manifest contains duplicate path: ${a.path}`);e.add(a.path);}return t}function _(r){return a(r,e,"Workspace archive operation result"),r}function Ne(r$1){return r(R(r$1))}function Ce(r){let t=new Map;for(let e of r){if(e.name===P||e.name===S)continue;let a=Ne(e.name),i=t.get(a);if(!i){t.set(a,{...e,sourceName:e.name,targetName:a});continue}let s=e.name===a,n=i.sourceName===i.targetName;if(s&&!n){t.set(a,{...e,sourceName:e.name,targetName:a});continue}if(!(i.size===e.size&&i.crc32===e.crc32)&&!n)throw new Error(`Workspace archive contains conflicting entries for ${a}: ${i.sourceName}, ${e.name}`)}return [...t.values()].sort((e,a)=>e.targetName.localeCompare(a.targetName))}async function $(r,t={}){let e=await ae(r,t),a;try{a=await be(e.archivePath);let i=await ze(a);if(i.length>j)throw new Error(`Workspace archive contains too many entries (${i.length} > ${j}).`);for(let l of i){if(l.size>me)throw new Error(`Workspace archive entry is too large: ${l.name}`);if(l.size/Math.max(1,l.compressedSize)>ue)throw new Error(`Workspace archive entry has an unsafe compression ratio: ${l.name}`)}let s=i.reduce((l,u)=>l+u.size,0),n=t.maxExpandedBytes??pe;if(s>n)throw new Error(`Workspace archive payload exceeds configured limit (${s} > ${n} bytes).`);let o=i.find(l=>l.name===P||l.name===S);if(!o)throw new Error(`Workspace archive is missing ${l("","archive-manifest.json").replace(/^\//,"")}.`);let p=Oe(await xe(a,o));return {archivePath:e.archivePath,entries:i,manifest:p,zipFile:a,cleanup:e.cleanup}}catch(i){throw a?.close(),e.cleanup&&await h.remove(e.cleanup).catch(()=>{}),i}}async function T(r){r.zipFile?.close(),r.cleanup&&await h.remove(r.cleanup).catch(()=>{});}async function Me(r){let t=await $(r.archivePathOrUrl,r.safety);try{let e=new Map(t.entries.filter(i=>i.name!==P&&i.name!==S).map(i=>[i.name,i])),a=t.manifest.files.map(i=>({path:i.path,size:e.get(i.path)?.size??i.size,hasChecksum:typeof i.sha256=="string"&&i.sha256.length>0}));return _({schemaVersion:c,operation:"inspect",status:"passed",archivePath:t.archivePath,manifest:t.manifest,fileCount:a.length,totalBytes:a.reduce((i,s)=>i+s.size,0),entries:a})}finally{await T(t);}}async function ie(r){let t=await $(r.archivePathOrUrl,r.safety);try{let e=new Map(t.entries.filter(c=>c.name!==P&&c.name!==S).map(c=>[c.name,c])),a=new Set(t.manifest.files.map(c=>c.path)),i=[...e.keys()].filter(c=>!a.has(c)).sort(),s=[],n=[],o=[],p=0;for(let c of t.manifest.files){ee(c.path);let m=e.get(c.path);if(!m){s.push(c.path);continue}let g=z.createHash("sha256"),w=0,d=await M(t.zipFile,m.entry);for await(let E of d){let I=Buffer.isBuffer(E)?E:Buffer.from(E);w+=I.length,g.update(I);}let v={size:w,sha256:g.digest("hex")};if(w!==m.size||w!==c.size){o.push({path:c.path,expected:{size:c.size,sha256:c.sha256},actual:v});continue}if(!c.sha256){n.push(c.path);continue}if(v.sha256!==c.sha256){o.push({path:c.path,expected:{size:c.size,sha256:c.sha256},actual:v});continue}p+=1;}let l=r.requireChecksums===true&&n.length>0,u=s.length>0||o.length>0||l||i.length>0,y=n.length>0;return _({schemaVersion:c,operation:"verify",archivePath:t.archivePath,manifest:t.manifest,status:u?"failed":y?"warning":"passed",fileCount:t.manifest.files.length,totalBytes:t.manifest.files.reduce((c,m)=>c+m.size,0),verifiedFiles:p,missingChecksumFiles:n,missingArchiveEntries:s,extraArchiveEntries:i,mismatches:o})}finally{await T(t);}}async function Qe(r){let t=await ae(r.archivePathOrUrl,r.safety);try{return await $e({archivePath:t.archivePath,strict:r.strict})}finally{t.cleanup&&await h.remove(t.cleanup).catch(()=>{});}}async function $e(r){let t=await Me({archivePathOrUrl:r.archivePath}),e=await ie({archivePathOrUrl:r.archivePath,requireChecksums:r.strict===true}),a=[],i=[];a.push({id:"manifest-present",status:"passed",message:`Archive manifest found for workspace "${t.manifest.workspaceName}".`}),a.push({id:"integrity",status:e.status,message:e.status==="passed"?`Verified ${e.verifiedFiles}/${e.fileCount} files.`:"Archive integrity verification did not fully pass."});let s=t.manifest.security?.envFilesIncluded===true;a.push({id:"secrets-policy",status:s?"warning":"passed",message:s?"Archive manifest says environment/private files were intentionally included.":"Archive manifest excludes environment/private files by default."}),s&&i.push("Share this archive only through trusted internal channels."),e.missingChecksumFiles.length>0&&i.push("Re-export the archive with the latest RapidKit/Workspai tooling."),e.mismatches.length>0&&i.push("Reject this archive and request a fresh export from the owner."),(e.extraArchiveEntries.length>0||e.missingArchiveEntries.length>0)&&i.push("Regenerate the archive so ZIP entries and manifest entries match."),r.strict===true&&e.status!=="passed"&&i.push("Do not hydrate this archive in strict or production workflows.");let n=a.some(p=>p.status==="failed"),o=a.some(p=>p.status==="warning");return _({schemaVersion:c,operation:"doctor",archivePath:t.archivePath,status:n?"failed":o?"warning":"passed",workspaceName:t.manifest.workspaceName,fileCount:t.fileCount,totalBytes:t.totalBytes,checks:a,recommendedActions:i})}async function Te(r,t){let e=await h.lstat(r).catch(i=>{if(i.code==="ENOENT")return null;throw i});if(!e)return false;if(e.isSymbolicLink())throw new Error(`Output directory must not be a symbolic link: ${r}`);if(!e.isDirectory())throw new Error(`Output path is not a directory: ${r}`);if((await h.readdir(r)).length>0&&!t)throw new Error(`Output directory is not empty: ${r}. Use --force to overwrite.`);return true}async function et(r){let t=await $(r.archivePathOrUrl,r.safety);try{let e=await ie({archivePathOrUrl:t.archivePath,requireChecksums:r.strict===true});if(e.status==="failed"){let o=[e.missingArchiveEntries.length?`missing entries: ${e.missingArchiveEntries.join(", ")}`:"",e.extraArchiveEntries.length?`unexpected entries: ${e.extraArchiveEntries.join(", ")}`:"",e.mismatches.length?`checksum/size mismatches: ${e.mismatches.map(p=>p.path).join(", ")}`:"",e.missingChecksumFiles.length&&r.strict===true?`missing checksums: ${e.missingChecksumFiles.join(", ")}`:""].filter(Boolean).join("; ");throw new Error(`Workspace archive verification failed${o?` (${o})`:""}.`)}if(e.status==="warning"&&r.strict===true)throw new Error(`Workspace archive verification requires checksums for every file: ${e.missingChecksumFiles.join(", ")}`);let a=Ce(t.entries),i=t.manifest,s=f.resolve(r.outputPath||G(i.workspaceName||"imported-workspace")),n=await Te(s,r.force===true);if(!r.dryRun){let o=f.dirname(s),p=`${process.pid}-${z.randomUUID()}`,l=f.join(o,`.${f.basename(s)}.hydrate-${p}.tmp`),u=f.join(o,`.${f.basename(s)}.hydrate-${p}.backup`),y=false,c=false;await h.ensureDir(o);try{await h.ensureDir(l);for(let m of a){let g=f.resolve(l,m.targetName);if(!Ae(g,l))throw new Error(`Archive entry escapes output directory: ${m.targetName}`);await h.ensureDir(f.dirname(g));let w=await M(t.zipFile,m.entry);await pipeline(w,createWriteStream(g,{flags:"wx"}));}n&&(await h.rename(s,u),y=true),await h.rename(l,s),c=true,y&&await h.remove(u).catch(()=>{});}catch(m){throw y&&!await h.pathExists(s)&&await h.rename(u,s).catch(()=>{}),m}finally{await h.remove(l).catch(()=>{}),c&&await h.remove(u).catch(()=>{});}}return _({schemaVersion:c,operation:"hydrate",status:"passed",archivePath:t.archivePath,outputPath:s,dryRun:r.dryRun===true,manifest:i,files:a.map(o=>({path:o.targetName,size:o.size}))})}finally{await T(t);}}
10
- export{he as WORKSPACE_ARCHIVE_KIND,P as WORKSPACE_ARCHIVE_MANIFEST_PATH,K as assertSafeRemoteArchiveUrl,Qe as doctorWorkspaceArchive,Ge as exportWorkspaceArchive,et as hydrateWorkspaceArchive,Me as inspectWorkspaceArchive,ve as isPrivateAddress,Q as isSafeArchiveEntryName,G as sanitizeWorkspaceArchiveName,ke as shouldExcludeWorkspaceArchivePath,ie as verifyWorkspaceArchive};
@@ -1 +0,0 @@
1
- export{d as WORKSPACE_CONTEXT_AGENT_REPORT_PATH,c as WORKSPACE_CONTEXT_SCHEMA_VERSION,e as buildWorkspaceAgentContext,f as writeWorkspaceAgentContext}from'./chunk-LHOZXC2M.js';
@@ -1 +0,0 @@
1
- export{d as WORKSPACE_CONTRACT_PATH,f as WORKSPACE_CONTRACT_SCHEMA_VERSION,e as WORKSPACE_CONTRACT_VERIFY_REPORT_PATH,g as WORKSPACE_CONTRACT_VERIFY_SCHEMA_VERSION,h as WorkspaceContractVerificationError,j as buildWorkspaceContract,n as buildWorkspaceContractGraph,i as discoverProjectJsonFiles,m as readWorkspaceContract,l as syncWorkspaceContract,o as verifyWorkspaceContract,k as writeWorkspaceContract,p as writeWorkspaceContractVerifyEvidence}from'./chunk-T4YR4RAI.js';
@@ -1 +0,0 @@
1
- export{c as WORKSPACE_GRAPH_OVERRIDES_PATH,d as graphHasCycle,e as hashDependencyGraph,f as inferWorkspaceDependencyGraph,g as inferWorkspaceDependencyGraphIncremental}from'./chunk-J5ENLXDF.js';
@@ -1 +0,0 @@
1
- export{b as buildWorkspaceExplain,a as resolveWorkspaceExplainArtifactPath,c as writeWorkspaceExplainReport}from'./chunk-4HDYADHT.js';export{c as WORKSPACE_EXPLAIN_REPORT_PATH,e as WORKSPACE_TRACE_REPORT_PATH,d as WORKSPACE_WHY_REPORT_PATH}from'./chunk-CRHYBQI3.js';export{e as WORKSPACE_MODEL_DIFF_REPORT_PATH}from'./chunk-AFL3ACCR.js';
@@ -1 +0,0 @@
1
- export{a as WORKSPACE_EXPLAIN_SCHEMA_VERSION,b as WORKSPACE_EXPLAIN_TARGETS,e as isWorkspaceExplainReport,c as parseWorkspaceExplainTarget,d as resolveWorkspaceTraceTarget}from'./chunk-VU7NZHPM.js';export{c as WORKSPACE_EXPLAIN_REPORT_PATH,e as WORKSPACE_TRACE_REPORT_PATH,d as WORKSPACE_WHY_REPORT_PATH}from'./chunk-CRHYBQI3.js';
@@ -1 +0,0 @@
1
- import {d,c}from'./chunk-OA537ZQ5.js';import {a}from'./chunk-KB44JP4M.js';import g from'crypto';import H from'path';var S="workspace-graph-stream.v1";function k(o){return c({...o,generatedAt:"<ignored>",proofs:o.proofs.map(s=>({...s,observedAt:"<ignored>"}))})}function w(o){return "observedAt"in o?{...o,observedAt:"<ignored>"}:o}function v(o,s){let r=new Map(o.map(e=>[e.id,e])),a=new Map(s.map(e=>[e.id,e])),i=s.filter(e=>!r.has(e.id)),p=s.filter(e=>{let t=r.get(e.id);return t?c(w(t))!==c(w(e)):false}),d=o.filter(e=>!a.has(e.id)).map(e=>e.id);return {added:i,updated:p,removed:d}}function M(o,s){let r=new Map(o.map(a=>[a.id,a]));return s.filter(a=>{let i=r.get(a.id);return !i||c(i)!==c(a)})}function f(o){return a(o,"contracts/workspace-intelligence/workspace-graph-stream.v1.json","Workspace graph stream event"),o}var I=class{previous=null;revision=0;generation=0;workspaceId;sessionId;now;nextCorrelationId;constructor(s){this.workspaceId=`workspace:${g.createHash("sha256").update(H.resolve(s.workspacePath)).digest("hex")}`,this.sessionId=s.sessionId??g.randomUUID(),this.now=s.now??(()=>new Date),this.nextCorrelationId=s.correlationId??(()=>g.randomUUID());}publish(s,r){let a=this.now().toISOString(),i=d(s),p=k(r),d$1=this.nextCorrelationId(),e={schemaVersion:S,workspaceId:this.workspaceId,sessionId:this.sessionId,generation:this.generation,modelHash:i,graphHash:p,generatedAt:a,causationId:d$1,correlationId:d$1};if(!this.previous){let A=f({...e,type:"graph.snapshot",revision:this.revision,payload:{graph:r,reason:"initial"}});return this.previous=r,A}let t=this.previous,R=this.revision,b=t.source.hash,y=k(t);this.revision+=1,this.generation+=1;let c$1=v(t.entities,r.entities),h=v(t.relations,r.relations),l=v(t.proofs,r.proofs),W=c(t.quality)!==c(r.quality),G=f({...e,generation:this.generation,type:"graph.delta",baseRevision:R,baseModelHash:b,baseGraphHash:y,revision:this.revision,payload:{entitiesAdded:c$1.added,entitiesUpdated:c$1.updated,entitiesRemoved:c$1.removed,relationsAdded:h.added,relationsUpdated:h.updated,relationsRemoved:h.removed,proofsAdded:l.added,proofsUpdated:l.updated,proofsRemoved:l.removed,providersUpdated:M(t.providers,r.providers),quality:W?r.quality:null,diagnostics:r.diagnostics}});return this.previous=r,G}};export{S as WORKSPACE_GRAPH_STREAM_SCHEMA_VERSION,I as WorkspaceGraphStreamPublisher};
@@ -1 +0,0 @@
1
- export{a as WORKSPACE_GRAPH_TOKEN_EFFICIENCY_SCHEMA_VERSION,b as buildWorkspaceGraphTokenEfficiencyReport}from'./chunk-CV5HKU4P.js';
@@ -1 +0,0 @@
1
- export{g as WORKSPACE_IMPACT_REPORT_PATH,f as WORKSPACE_IMPACT_SCHEMA_VERSION,e as WORKSPACE_MODEL_DIFF_REPORT_PATH,c as WORKSPACE_MODEL_DIFF_SCHEMA_VERSION,d as WORKSPACE_MODEL_SNAPSHOT_REPORT_PATH,b as WORKSPACE_MODEL_SNAPSHOT_SCHEMA_VERSION,o as buildWorkspaceImpact,j as buildWorkspaceModelSnapshot,l as diffWorkspaceModel,h as isGitDiffSource,i as parseGitDiffRef,n as workspaceVerificationPlan,p as writeWorkspaceImpact,m as writeWorkspaceModelDiff,k as writeWorkspaceModelSnapshot}from'./chunk-AFL3ACCR.js';export{d as hashWorkspaceModel}from'./chunk-OA537ZQ5.js';
@@ -1 +0,0 @@
1
- import {b as b$1,c}from'./chunk-4HDYADHT.js';import {a as a$2}from'./chunk-54EP5CEV.js';import {q}from'./chunk-BFLJ2R4D.js';import {d}from'./chunk-TIE2XMGH.js';import {a as a$3}from'./chunk-BGPXQQNY.js';import {k as k$2}from'./chunk-HZDXO65G.js';import {a as a$1,e as e$2,f as f$1}from'./chunk-LHOZXC2M.js';import {f,g,h as h$1}from'./chunk-OW42TZFB.js';import {j,k as k$1,l as l$1,m,o,p}from'./chunk-AFL3ACCR.js';import {k,n}from'./chunk-37CVKXBD.js';import {j as j$1,e as e$1}from'./chunk-ESLPI3XZ.js';import {l,o as o$1,p as p$1}from'./chunk-T4YR4RAI.js';import {e}from'./chunk-32OJDBIG.js';import {b as b$2}from'./chunk-3NU32T4A.js';import {a,b,h,i,g as g$1,f as f$2}from'./chunk-BMWFQXGW.js';import se from'path';import ce from'fs-extra';function r(a,t){if(!a)throw new Error(`Workspace Intelligence run semantic violation: ${t}`)}function ee(a,t){return a.length===t.length&&a.every((d,l)=>d===t[l])}function te(a$2){b$2(a.intelligenceRun,a$2,"Workspace Intelligence run report"),r(a$2.chainSchemaVersion===a$1,`chainSchemaVersion must be ${a$1}`),r(a$2.artifactPath===a.intelligenceRun,`artifactPath must be ${a.intelligenceRun}`),r(a$2.preflight.length===g$1.length,`preflight must contain exactly ${g$1.length} entries`);for(let[o,i]of g$1.entries()){let s=a$2.preflight[o];r(s?.id===i,`preflight[${o}].id must be ${i}`),r(ee(s.artifacts,h[i]),`${i} preflight artifacts must match the runtime registry`),i==="sync"?r(s.status==="passed"&&s.result==="synchronized"||s.status==="failed"&&s.result==="failed","sync preflight status and result are incoherent"):r(s.status==="passed"&&(s.result==="created"||s.result==="reused")||s.status==="failed"&&s.result==="failed"||s.status==="skipped"&&s.result==="skipped","baseline preflight status and result are incoherent");}let t=a$2.preflight[1];r(a$2.baselineCreated===(t?.result==="created"),"baselineCreated must match the baseline preflight result"),r(a$2.stages.length===f$2.length,`stages must contain exactly ${f$2.length} canonical steps`);let d=a$2.preflight[0],l=d?.status==="failed";for(let[o,i$1]of f$2.entries()){let s=a$2.stages[o];r(s?.id===i$1,`stages[${o}].id must be ${i$1}`),r(ee(s.artifacts,i[i$1].produces),`${i$1} artifacts must match the runtime registry`),l&&r(s.status==="skipped",`${i$1} must be skipped after a hard failure`),s.status==="passed"?r(s.exitCode===0,`${i$1} passed stage must have exitCode 0`):s.status==="blocked"?r(s.exitCode!==0,`${i$1} blocked stage must have a non-zero exitCode`):s.status==="failed"?(r(s.exitCode===1,`${i$1} failed stage must have exitCode 1`),l=true):(r(s.exitCode===0,`${i$1} skipped stage must have exitCode 0`),r(s.durationMs===0,`${i$1} skipped stage must have durationMs 0`)),o===0&&((d?.status==="failed"||s.status==="failed")&&r(t?.status==="skipped","baseline must be skipped when sync or model fails"),t?.status==="skipped"&&r(d?.status==="failed"||s.status==="failed"||s.status==="skipped","baseline may be skipped only after an upstream failure"),t?.status!=="passed"&&(l=true));}let m=a$2.preflight.some(o=>o.status==="failed")||a$2.stages.some(o=>o.status==="failed"),E=a$2.stages.some(o=>o.status==="blocked"),n=m?"failed":E?"blocked":"passed",u=n==="failed"?1:n==="blocked"?2:0;r(a$2.status===n,`status must be ${n}`),r(a$2.exitCode===u,`exitCode must be ${u}`);}var le=a.intelligenceRun,de=b.intelligenceRun,ae=le;async function $e(a$4){let t=se.resolve(a$4.workspacePath),d$1=[],l$2=[],m$1=false,E=async(e,p)=>{let f=[...h[e]];if(m$1){d$1.push({id:e,status:"skipped",result:"skipped",durationMs:0,artifacts:f,message:"skipped because a required upstream operation failed"});return}let k=Date.now();try{let c=await p();d$1.push({id:e,status:"passed",result:c.result,durationMs:Date.now()-k,artifacts:f,message:c.message});}catch(c){m$1=true,d$1.push({id:e,status:"failed",result:"failed",durationMs:Date.now()-k,artifacts:f,message:c instanceof Error?c.message:String(c)});}},n$1=async(e,p)=>{let f=[...i[e].produces];if(m$1){l$2.push({id:e,status:"skipped",durationMs:0,artifacts:f,exitCode:0,message:"skipped because a required upstream stage failed"});return}let k=Date.now();try{let c=await p(),b=c.exitCode??0;l$2.push({id:e,status:c.blocked||b!==0?"blocked":"passed",durationMs:Date.now()-k,artifacts:f,exitCode:b,message:c.message});}catch(c){m$1=true,l$2.push({id:e,status:"failed",durationMs:Date.now()-k,artifacts:f,exitCode:1,message:c instanceof Error?c.message:String(c)});}};await E("sync",async()=>{let e=await d(t,true),p=await l({workspacePath:t});return {result:"synchronized",message:`registry ${e.added.length} added/${e.skipped} existing; contract ${p.contract.projects.length} projects`}});let u,o$2=()=>{if(!u)throw new Error("canonical workspace model is unavailable");return u};await n$1("model",async()=>(u=await k({workspacePath:t,includeEvidence:true}),await n(u,t),{message:`${u.summary.projectCount} projects modeled`}));let i$1=se.join(t,a.snapshot),s=false;await E("baseline",async()=>{if(!await ce.pathExists(i$1)){let e=await j({workspacePath:t,model:o$2()});return await k$1(e,t),s=true,{result:"created",message:"initial structural baseline created"}}return {result:"reused",message:"existing structural baseline reused"}}),await n$1("diff",async()=>{let e=await l$1({workspacePath:t,fromPath:a.snapshot,model:o$2()});return await m(e,t),{message:e.summary.changed?"workspace changes detected":"no workspace changes"}}),await n$1("impact",async()=>{let e=await o({workspacePath:t,fromPath:a.diff});return await p(e,t),{message:`${e.summary.risk} risk; ${e.summary.affectedProjects} affected`}}),await n$1("doctor-evidence",async()=>{let e=await q({workspace:t,json:true,quiet:true});return {exitCode:e,blocked:e!==0,message:`doctor exit ${e}`}}),await n$1("contract-evidence",async()=>{let e=await o$1({workspacePath:t,strict:true});return await p$1({workspacePath:t,result:e}),{exitCode:e.status==="passed"?0:1,blocked:e.status!=="passed",message:`contract ${e.status}`}}),await n$1("analyze-evidence",async()=>{let e=await a$2({workspacePath:t,json:true,strict:false});return {blocked:e.summary.verdict==="blocked"||a$4.strict===true&&e.summary.verdict==="needs-attention",exitCode:e.summary.verdict==="blocked"||a$4.strict===true&&e.summary.verdict==="needs-attention"?1:0,message:`analyze ${e.summary.verdict} (${e.summary.score}/100)`}}),await n$1("readiness-evidence",async()=>{let e=await a$3({startPath:t,writeReport:true,skipVerify:true});return {blocked:e.overallStatus==="fail"||a$4.strict===true&&e.overallStatus==="warn",exitCode:e.overallStatus==="fail"||a$4.strict===true&&e.overallStatus==="warn"?1:0,message:`pre-verify readiness ${e.overallStatus}`}}),await n$1("verify",async()=>{let e=await f({workspacePath:t,fromImpactPath:a.impact});await g(e,t);let p=h$1(e,{strict:a$4.strict===true});return await j$1(t,e$1(e,p.passed)),{blocked:!p.passed,exitCode:p.exitCode,message:`${e.summary.verdict}; gate ${p.passed?"passed":"blocked"}`}}),await n$1("context",async()=>{u=await k({workspacePath:t,includeEvidence:true});let e=await e$2({workspacePath:t,model:u,agent:a$4.agent??"generic",includeEvidence:true});return await f$1(e,t),{message:`context grounded for ${e.agent}`}}),await n$1("agent-sync",async()=>({message:`${(await k$2({workspacePath:t,agent:a$4.agent??"generic",write:true,refreshContext:false,strict:false,preset:"enterprise"})).writtenFiles.length} grounding files written`})),await n$1("explain",async()=>{let e=await b$1({workspacePath:t,target:{kind:"release-blocked"}});return await c(e,t),{message:e.summary}});let re=l$2.some(e=>e.status==="blocked"),W=m$1?"failed":re?"blocked":"passed",ie=m$1?1:W==="blocked"?2:0,R={schemaVersion:de,chainSchemaVersion:a$1,generatedAt:new Date().toISOString(),workspacePath:t,baselineCreated:s,preflight:d$1,status:W,exitCode:ie,stages:l$2,artifactPath:ae};return te(R),await e(t,ae,R),R}export{le as WORKSPACE_INTELLIGENCE_RUN_REPORT_PATH,de as WORKSPACE_INTELLIGENCE_RUN_SCHEMA_VERSION,$e as runWorkspaceIntelligenceChain};
@@ -1,3 +0,0 @@
1
- import {b}from'./chunk-4HDYADHT.js';import {d,c as c$2,f,e as e$1}from'./chunk-WDKNMTJQ.js';import {c as c$1,e}from'./chunk-VU7NZHPM.js';import {c as c$4,b as b$1}from'./chunk-CRHYBQI3.js';import {d as d$2}from'./chunk-LHOZXC2M.js';import {d as d$3}from'./chunk-OW42TZFB.js';import {h}from'./chunk-37CVKXBD.js';import {c as c$3}from'./chunk-NAJCUQ4X.js';import {e as e$2}from'./chunk-T4YR4RAI.js';import {d as d$1}from'./chunk-32OJDBIG.js';import {a as a$2}from'./chunk-KB44JP4M.js';import {a as a$1,c}from'./chunk-BMWFQXGW.js';import {r}from'./chunk-5XATWNME.js';import u from'path';import N from'readline';import g from'fs-extra';var L=a$1.agentIndex,q=new Map(Object.keys(a$1).flatMap(e=>{let t=c[e];return t?[[a$1[e],t]]:[]}));function M(e,t){return e.kind!==t.kind?false:e.kind==="project"&&t.kind==="project"?e.project.toLowerCase()===t.project.toLowerCase():e.kind==="blocker"&&t.kind==="blocker"?e.blockerId===t.blockerId:e.kind==="trace"&&t.kind==="trace"?e.diffRef===t.diffRef:true}var J=[{name:"getWorkspaceModel",description:"Read workspace-model.json",inputSchema:{type:"object",properties:{}}},{name:"getWorkspaceKnowledgeGraph",description:"Read the current proof-backed workspace knowledge graph artifact",inputSchema:{type:"object",properties:{}}},{name:"getWorkspaceEvaluation",description:"Read the live or finalized provenance-aware model usage and verified-outcome report",inputSchema:{type:"object",properties:{live:{type:"boolean",description:"Read the live report instead of the finalized last-run report"}}}},{name:"queryWorkspaceEntities",description:"List workspace knowledge entities, optionally filtered by kind",inputSchema:{type:"object",properties:{kind:{type:"string",description:"Optional entity kind"}}}},{name:"searchWorkspaceGraph",description:"Return bounded, proof-carrying workspace context matching a text query",inputSchema:{type:"object",properties:{query:{type:"string",description:"Text, path, symbol, service, or concept to find"},kind:{type:"string",description:"Optional entity kind filter"},limit:{type:"integer",minimum:1,maximum:100,default:12}},required:["query"]}},{name:"getWorkspaceGraphEvidence",description:"Resolve portable evidence for a knowledge graph entity or relation",inputSchema:{type:"object",properties:{query:{type:"string"}},required:["query"]}},{name:"findWorkspaceGraphPath",description:"Find a shortest proof-carrying path between two workspace entities",inputSchema:{type:"object",properties:{from:{type:"string"},to:{type:"string"}},required:["from","to"]}},{name:"getEvidenceIndex",description:"Read agent reports INDEX.json",inputSchema:{type:"object",properties:{}}},{name:"getBlockers",description:"Aggregate blocking reasons from verify, explain, and contract-verify reports",inputSchema:{type:"object",properties:{}}},{name:"getSafeCommands",description:"Read safe commands from workspace-context-agent.json",inputSchema:{type:"object",properties:{}}},{name:"getProjectContext",description:"Read scoped project context from workspace-context-agent.json",inputSchema:{type:"object",properties:{project:{type:"string",description:"Optional project name; defaults to active scope"}}}},{name:"getArtifact",description:"Read one workspace-relative artifact path",inputSchema:{type:"object",properties:{relativePath:{type:"string"}},required:["relativePath"]}},{name:"listOperationalSkills",description:"Read workspace-skills-index.json",inputSchema:{type:"object",properties:{}}},{name:"getWorkspaceExplain",description:"Build or read workspace explain report",inputSchema:{type:"object",properties:{target:{type:"string",description:"release-blocked | project:<name> | blocker:<id> | trace:<diffRef> | <project>"}}}}];function H(e){let t=e.trim().replace(/\\/g,"/");return t.length>0&&!u.isAbsolute(t)&&!t.split("/").includes("..")&&(t.startsWith(".workspai/")||t.startsWith(".rapidkit/"))}async function a(e,t){if(!H(t))throw new Error(`Unsafe artifact path: ${t}`);let r$1=await d$1(e,t)??u.join(e,t);if(!await g.pathExists(r$1))return null;let n=await g.readJson(r$1),o=r(t),c=q.get(o);if(c&&a$2(n,c,`MCP artifact ${o}`),o===a$1.knowledgeGraph){let p=u.join(e,h);if(!await g.pathExists(p))throw new Error("Workspace knowledge graph cannot be consumed without its source model.");let l=await g.readJson(p);c$3(n,l);}return n}async function F(e$1){let t=[],r=new Set,o=((await a(e$1,d$3))?.blockingReasons??[]).filter(i=>typeof i=="string"&&i.trim().length>0);if(o.length>0){t.push({artifact:d$3,reasons:o});for(let i of o)r.add(i);}let c=await a(e$1,c$4);if(e(c)){let i=(c.blockingReasons??[]).filter(s=>typeof s=="string"&&s.trim().length>0);if(i.length>0){t.push({artifact:c$4,reasons:i});for(let s of i)r.add(s);}}let p=await a(e$1,e$2),l=(p?.violations??[]).filter(i=>typeof i=="string"&&i.trim().length>0);if(l.length>0||String(p?.status??"").toLowerCase()==="failed"){let i=l.length>0?l:["Workspace contract verification failed"];t.push({artifact:e$2,reasons:i});for(let s of i)r.add(s);}return {blockingReasons:[...r],sources:t}}async function I(e$2,t,r){switch(t){case "getWorkspaceModel":return a(e$2,h);case "getWorkspaceKnowledgeGraph":return a(e$2,a$1.knowledgeGraph);case "getWorkspaceEvaluation":return a(e$2,r.live===true?a$1.evaluationLive:a$1.evaluationLastRun);case "queryWorkspaceEntities":{let n=await a(e$2,a$1.knowledgeGraph);if(!n)return null;let o=String(r.kind??"").trim();return {schemaVersion:n.schemaVersion,generatedAt:n.generatedAt,entities:e$1(n,o||void 0)}}case "searchWorkspaceGraph":{let n=await a(e$2,a$1.knowledgeGraph);if(!n)return null;let o=typeof r.limit=="number"?r.limit:Number(r.limit??12);return f(n,{query:String(r.query??""),...typeof r.kind=="string"&&r.kind.trim()?{kind:r.kind.trim()}:{},limit:Number.isFinite(o)?o:12})}case "getWorkspaceGraphEvidence":{let n=await a(e$2,a$1.knowledgeGraph);return n?c$2(n,String(r.query??"")):null}case "findWorkspaceGraphPath":{let n=await a(e$2,a$1.knowledgeGraph);return n?d(n,String(r.from??""),String(r.to??"")):null}case "getEvidenceIndex":return a(e$2,L);case "getBlockers":return F(e$2);case "getSafeCommands":return {safeCommands:(await a(e$2,d$2))?.safeCommands??[]};case "getProjectContext":{let n=await a(e$2,d$2);if(!n)return null;let o=String(r.project??"").trim(),c=n.scope?.activeProject??void 0,p=o||c,l=Array.isArray(n.projects)?n.projects:[],i=p&&l.find(s=>typeof s.name=="string"&&s.name.toLowerCase()===p.toLowerCase());return {workspace:n.workspace??null,scope:n.scope??null,validation:n.validation??null,project:i??null,safeCommands:n.safeCommands??[]}}case "getArtifact":{let n=String(r.relativePath??"").trim();return a(e$2,n)}case "listOperationalSkills":return a(e$2,b$1);case "getWorkspaceExplain":{let n=String(r.target??"release-blocked").trim(),o=c$1(n);if(!o)throw new Error(`Invalid explain target: ${n}`);let c=await a(e$2,c$4);return e(c)&&M(c.target,o)?c:b({workspacePath:e$2,target:o})}default:throw new Error(`Unknown tool: ${t}`)}}function R(e,t){process.stdout.write(`${JSON.stringify({jsonrpc:"2.0",id:e??null,result:t})}
2
- `);}function E(e,t){process.stdout.write(`${JSON.stringify({jsonrpc:"2.0",id:e??null,error:{code:-32e3,message:t}})}
3
- `);}async function ce(e){let t=u.resolve(e.workspacePath),r=N.createInterface({input:process.stdin,terminal:false});for await(let n of r){let o=n.trim();if(!o)continue;let c;try{c=JSON.parse(o);}catch{E(null,"Invalid JSON-RPC request");continue}let{id:p,method:l,params:i}=c;try{if(l==="initialize"){R(p,{protocolVersion:"2024-11-05",capabilities:{tools:{}},serverInfo:{name:"workspai-workspace-mcp",version:"0.1.0"}});continue}if(l==="notifications/initialized")continue;if(l==="tools/list"){R(p,{tools:J.map(s=>({name:s.name,description:s.description,inputSchema:s.inputSchema}))});continue}if(l==="tools/call"){let s=String(i?.name??""),K=i?.arguments&&typeof i.arguments=="object"?i.arguments:{},S=await I(t,s,K);R(p,{content:[{type:"text",text:JSON.stringify(S,null,2)}],isError:S==null});continue}E(p,`Unsupported method: ${l??"unknown"}`);}catch(s){E(p,s instanceof Error?s.message:String(s));}}}async function pe(e,t,r={}){return I(u.resolve(e),t,r)}export{J as WORKSPACE_MCP_READ_TOOLS,pe as invokeMcpToolForTest,ce as runWorkspaceMcpServe};
@@ -1 +0,0 @@
1
- export{h as WORKSPACE_MODEL_REPORT_PATH,g as WORKSPACE_MODEL_SCHEMA_VERSION,k as buildWorkspaceModel,l as buildWorkspaceModelCached,j as buildWorkspaceModelFacts,m as buildWorkspaceModelIncremental,i as validateWorkspaceModelStrict,n as writeWorkspaceModel}from'./chunk-37CVKXBD.js';
@@ -1 +0,0 @@
1
- export{c as hashCanonicalJson,d as hashWorkspaceModel,a as stableSort,b as stableStringify}from'./chunk-OA537ZQ5.js';
@@ -1 +0,0 @@
1
- export{a as runWorkspaceStage}from'./chunk-E2KJ5QWY.js';export{a as WORKSPACE_RUN_LAST_REPORT_FILENAME}from'./chunk-HDXNIN4N.js';
@@ -1 +0,0 @@
1
- import {a}from'./chunk-PRTR2DQ2.js';import {m as m$1}from'./chunk-37CVKXBD.js';import {b as b$1}from'./chunk-J5ENLXDF.js';import {a as a$1}from'./chunk-KB44JP4M.js';import P from'fs';var w="workspace-watch-event.v1";function b(e){return a$1(e,"contracts/workspace-watch-event.v1.json","Workspace watch event"),e}function g(e){return `${e.from}\0${e.to}\0${e.kind}`}function f(e){return (e.graph?.edges??[]).map(o=>({from:o.from,to:o.to,kind:o.kind}))}function m(e){let r=[...a(e).entries()].sort((a,n)=>a[0].localeCompare(n[0])).map(([a,n])=>({id:a,hash:n})),c=f(e).map(g).sort((a,n)=>a.localeCompare(n));return b$1({projects:r,edges:c})}function R(e,o){let r=a(o),c=e?a(e):new Map,a$1=[],n=[];for(let[t,s]of r.entries())c.has(t)?c.get(t)!==s&&a$1.push(t):n.push(t);let d=[];for(let t of c.keys())r.has(t)||d.push(t);let i=new Map(e?f(e).map(t=>[g(t),t]):[]),l=new Map(f(o).map(t=>[g(t),t])),p=[];for(let[t,s]of l.entries())i.has(t)||p.push(s);let h=[];for(let[t,s]of i.entries())l.has(t)||h.push(s);let u=(t,s)=>g(t).localeCompare(g(s));return a$1.sort((t,s)=>t.localeCompare(s)),n.sort((t,s)=>t.localeCompare(s)),d.sort((t,s)=>t.localeCompare(s)),p.sort(u),h.sort(u),{changedProjects:a$1,addedProjects:n,removedProjects:d,edgesAdded:p,edgesRemoved:h}}var k=class{model=null;sequence=0;rebuild;now;constructor(o,r){this.rebuild=r?.rebuild??(()=>m$1({...o})),this.now=r?.now??(()=>new Date);}get currentModel(){return this.model}async start(){let o=Date.now(),{model:r}=await this.rebuild();return this.model=r,this.buildEvent("ready","initial",null,r,Date.now()-o)}async pulse(){let o=Date.now(),r=this.model,{model:c,mode:a}=await this.rebuild(),n=this.buildEvent(this.hasStructuralChange(r,c)?"changed":"unchanged",a,r,c,Date.now()-o);return this.model=c,n}hasStructuralChange(o,r){return o?m(o)!==m(r):true}buildEvent(o,r,c,a,n){let d=R(c,a),i=m(a),l=c?m(c)!==i:true;return b({schemaVersion:w,kind:o,sequence:this.sequence++,timestamp:this.now().toISOString(),mode:r,modelHash:i,modelHashChanged:l,changedProjects:d.changedProjects,addedProjects:d.addedProjects,removedProjects:d.removedProjects,graph:{nodeCount:a.graph?.nodes.length??0,edgeCount:a.graph?.edges.length??0,edgesAdded:d.edgesAdded,edgesRemoved:d.edgesRemoved},durationMs:n})}},C=new Set([".git",".hg",".svn","node_modules",".venv","venv","dist","build","out","target","coverage","htmlcov",".next",".turbo",".cache"]),y=new Set(["reports","cache","tmp",".cache"]);function S(e){if(!e)return false;let o=e.split(/[\\/]/).filter(Boolean);if(o.some(r=>C.has(r)))return false;for(let r=0;r<o.length-1;r+=1)if((o[r]===".workspai"||o[r]===".rapidkit")&&y.has(o[r+1]))return false;return true}async function I(e){let o=new k(e.buildOptions,e.engineOptions),r=await o.start();if(e.emit(r),o.currentModel&&await e.onModel?.(o.currentModel,r),e.once)return;let c=e.debounceMs??250,a=e.selfWriteSuppressionMs??Math.max(400,c+150),n=null,d=false,i=false,l=0,p=async()=>{if(d){i=true;return}d=true;try{let t=await o.pulse();e.emit(t),o.currentModel&&await e.onModel?.(o.currentModel,t);}catch(t){e.emit(b({schemaVersion:w,kind:"error",sequence:-1,timestamp:new Date().toISOString(),mode:"full",modelHash:o.currentModel?m(o.currentModel):"",modelHashChanged:false,changedProjects:[],addedProjects:[],removedProjects:[],graph:{nodeCount:0,edgeCount:0,edgesAdded:[],edgesRemoved:[]},durationMs:0,error:t instanceof Error?t.message:String(t)}));}finally{d=false,l=Date.now()+a,i&&(i=false,p());}},h=t=>{S(t)&&(d||Date.now()<l||(n&&clearTimeout(n),n=setTimeout(()=>{n=null,p();},c)));};e.onProgress?.(`Watching ${e.workspacePath} for changes (Ctrl+C to stop).`);let u=P.watch(e.workspacePath,{recursive:true},(t,s)=>{typeof s=="string"?h(s):s&&h(Buffer.from(s).toString("utf8"));});await new Promise(t=>{let s=()=>{n&&clearTimeout(n),u.close(),t();};if(e.signal){if(e.signal.aborted){s();return}e.signal.addEventListener("abort",s,{once:true});}u.on("error",()=>s());});}export{w as WORKSPACE_WATCH_EVENT_SCHEMA_VERSION,k as WorkspaceWatchEngine,m as computeWatchModelHash,R as diffWatchModels,S as isWatchRelevantPath,I as runWorkspaceWatch};