workspai 0.43.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 (255) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +624 -0
  3. package/contracts/agent-customization-pack.v1.json +229 -0
  4. package/contracts/analyze-last-run.v1.json +106 -0
  5. package/contracts/artifact-remediation-plan.v1.json +163 -0
  6. package/contracts/backend-import-stack-parity.snapshot.json +37 -0
  7. package/contracts/cli-log-event.v1.json +51 -0
  8. package/contracts/create-planner-capabilities.v1.json +251 -0
  9. package/contracts/doctor-project-evidence.v1.json +304 -0
  10. package/contracts/doctor-remediation-plan.v1.json +496 -0
  11. package/contracts/doctor-workspace-evidence.v1.json +315 -0
  12. package/contracts/extension-cli-compatibility.v1.json +26 -0
  13. package/contracts/infra-stack.v1.json +305 -0
  14. package/contracts/module-layout.v1.json +34 -0
  15. package/contracts/module-support.v1.json +20 -0
  16. package/contracts/pipeline-last-run.v1.json +80 -0
  17. package/contracts/release-readiness.v1.json +60 -0
  18. package/contracts/runtime-command-surface.v1.json +364 -0
  19. package/contracts/workspace-intelligence/agent-action-outcome.v1.json +38 -0
  20. package/contracts/workspace-intelligence/blocker-resolution.v1.json +65 -0
  21. package/contracts/workspace-intelligence/doctor-fix-result.v1.json +44 -0
  22. package/contracts/workspace-intelligence/fact-freshness.v1.json +58 -0
  23. package/contracts/workspace-intelligence/studio-blocker-handoff.v1.json +115 -0
  24. package/contracts/workspace-intelligence/workspace-context.v1.json +142 -0
  25. package/contracts/workspace-intelligence/workspace-contract-verify.v1.json +51 -0
  26. package/contracts/workspace-intelligence/workspace-dependency-graph.v1.json +152 -0
  27. package/contracts/workspace-intelligence/workspace-explain.v1.json +31 -0
  28. package/contracts/workspace-intelligence/workspace-impact.v1.json +114 -0
  29. package/contracts/workspace-intelligence/workspace-intelligence-history.v1.json +40 -0
  30. package/contracts/workspace-intelligence/workspace-model-diff.v1.json +105 -0
  31. package/contracts/workspace-intelligence/workspace-model-snapshot.v1.json +36 -0
  32. package/contracts/workspace-intelligence/workspace-model.v1.json +135 -0
  33. package/contracts/workspace-intelligence/workspace-operational-skill.v1.json +37 -0
  34. package/contracts/workspace-intelligence/workspace-skills-index.v1.json +27 -0
  35. package/contracts/workspace-intelligence/workspace-verify.v1.json +213 -0
  36. package/contracts/workspace-registry.v1.json +83 -0
  37. package/contracts/workspace-run-last.v1.json +112 -0
  38. package/data/modules-embeddings.json +16953 -0
  39. package/dist/analyze-5BU4QIPK.js +1 -0
  40. package/dist/artifact-remediation-plan-5GJWPPRS.js +3 -0
  41. package/dist/autopilot-release-QYUOVB26.js +1 -0
  42. package/dist/chunk-22DT744Z.js +1 -0
  43. package/dist/chunk-2E6WGUN6.js +1 -0
  44. package/dist/chunk-2FIX2MDC.js +1 -0
  45. package/dist/chunk-3KXW53QI.js +1 -0
  46. package/dist/chunk-3ZK2GU7C.js +1 -0
  47. package/dist/chunk-4KUIFXHM.js +5 -0
  48. package/dist/chunk-54XJNLYC.js +13 -0
  49. package/dist/chunk-5SWNSJGW.js +1 -0
  50. package/dist/chunk-5XATWNME.js +1 -0
  51. package/dist/chunk-753LOKFZ.js +2 -0
  52. package/dist/chunk-7YHK5NM3.js +2 -0
  53. package/dist/chunk-A5FBGRJA.js +1 -0
  54. package/dist/chunk-AAKUNWPR.js +78 -0
  55. package/dist/chunk-AFSZHLQT.js +1 -0
  56. package/dist/chunk-AQ4XZZC6.js +1 -0
  57. package/dist/chunk-CVTCPPEF.js +1 -0
  58. package/dist/chunk-DNAY5ALC.js +1 -0
  59. package/dist/chunk-EWYYLJQY.js +2 -0
  60. package/dist/chunk-GSWPGELT.js +2 -0
  61. package/dist/chunk-GZTYAEWX.js +1 -0
  62. package/dist/chunk-HTYMXMQM.js +1 -0
  63. package/dist/chunk-IBJEQHJR.js +205 -0
  64. package/dist/chunk-ICGWHIMK.js +1 -0
  65. package/dist/chunk-JEI6BTZI.js +3 -0
  66. package/dist/chunk-JHC6SCJC.js +1 -0
  67. package/dist/chunk-LO4C4VXR.js +4 -0
  68. package/dist/chunk-LPZFK3Y6.js +920 -0
  69. package/dist/chunk-LUP4U6EE.js +1 -0
  70. package/dist/chunk-LYC6AIF2.js +2 -0
  71. package/dist/chunk-LZQNVH7D.js +1 -0
  72. package/dist/chunk-NAAQMSO3.js +1 -0
  73. package/dist/chunk-NFUXULIF.js +1 -0
  74. package/dist/chunk-OCGZNSOE.js +1 -0
  75. package/dist/chunk-OJEWQO3Z.js +33 -0
  76. package/dist/chunk-OL64GWQC.js +9 -0
  77. package/dist/chunk-PI5KUXDA.js +7 -0
  78. package/dist/chunk-PYCJWW4B.js +1 -0
  79. package/dist/chunk-RE773WOX.js +13 -0
  80. package/dist/chunk-RO73VVHW.js +2 -0
  81. package/dist/chunk-S5KTATOU.js +1 -0
  82. package/dist/chunk-SI3AQKIP.js +1 -0
  83. package/dist/chunk-T3GJ7YVG.js +1 -0
  84. package/dist/chunk-T6OR6YOI.js +2 -0
  85. package/dist/chunk-VRDF2J46.js +653 -0
  86. package/dist/chunk-VZKSNUEE.js +2 -0
  87. package/dist/chunk-WU4ZRRA5.js +4 -0
  88. package/dist/chunk-XEJD4KCV.js +33 -0
  89. package/dist/chunk-XZGVNGRB.js +1 -0
  90. package/dist/chunk-Y45WZR5N.js +5 -0
  91. package/dist/create-WRZO4HK2.js +1 -0
  92. package/dist/demo-kit-AJ5LIM5G.js +149 -0
  93. package/dist/doctor-MF3M3FS3.js +1 -0
  94. package/dist/dotnet-webapi-clean-IPY3MCGQ.js +425 -0
  95. package/dist/gofiber-standard-N5N3QGH3.js +1397 -0
  96. package/dist/gogin-standard-LAWQTBWL.js +1459 -0
  97. package/dist/imported-projects-registry-FOIE27WT.js +1 -0
  98. package/dist/index.d.ts +141 -0
  99. package/dist/index.js +454 -0
  100. package/dist/managed-agent-markers-AXUM75OE.js +8 -0
  101. package/dist/module-layout-NZ43RSC5.js +1 -0
  102. package/dist/pipeline-QCUHFWDY.js +5 -0
  103. package/dist/platform-capabilities-XAVU4HSM.js +1 -0
  104. package/dist/pythonRapidkitExec-3L3XJBSY.js +1 -0
  105. package/dist/springboot-standard-OZYF7ZM7.js +697 -0
  106. package/dist/workspace-PR6VZRBG.js +1 -0
  107. package/dist/workspace-agent-sync-KTYF3HQR.js +1 -0
  108. package/dist/workspace-archive-GCZNI44O.js +3 -0
  109. package/dist/workspace-context-QUTOP2XV.js +1 -0
  110. package/dist/workspace-contract-XUGMCUSQ.js +1 -0
  111. package/dist/workspace-explain-JEONEGZZ.js +1 -0
  112. package/dist/workspace-explain-contract-DNS2YEL7.js +1 -0
  113. package/dist/workspace-feedback-R6H4UFZB.js +1 -0
  114. package/dist/workspace-foundation-KGSV4E6D.js +1 -0
  115. package/dist/workspace-graph-2A5THUCI.js +1 -0
  116. package/dist/workspace-history-CGCK2DJI.js +1 -0
  117. package/dist/workspace-intelligence-QJGVL37U.js +1 -0
  118. package/dist/workspace-marker-SMBC3Z2Q.js +1 -0
  119. package/dist/workspace-mcp-serve-AK4MYEHQ.js +3 -0
  120. package/dist/workspace-model-PNXXOGPO.js +1 -0
  121. package/dist/workspace-python-engine-state-MTWIIZPY.js +2 -0
  122. package/dist/workspace-registry-summary-RUJE6RPH.js +1 -0
  123. package/dist/workspace-run-Y7YMUIHX.js +1 -0
  124. package/dist/workspace-verify-WSDUUTR5.js +1 -0
  125. package/dist/workspace-watch-AGPOJ74Q.js +1 -0
  126. package/docs/AI_DYNAMIC_INTEGRATION.md +440 -0
  127. package/docs/AI_EXAMPLES.md +419 -0
  128. package/docs/AI_FEATURES.md +460 -0
  129. package/docs/AI_QUICKSTART.md +245 -0
  130. package/docs/DEVELOPMENT.md +90 -0
  131. package/docs/From Code to Shared Understanding.png +0 -0
  132. package/docs/OPEN_SOURCE_USER_SCENARIOS.md +170 -0
  133. package/docs/OPTIMIZATION_GUIDE.md +504 -0
  134. package/docs/PACKAGE_MANAGER_POLICY.md +25 -0
  135. package/docs/README.md +125 -0
  136. package/docs/SECURITY.md +63 -0
  137. package/docs/SETUP.md +107 -0
  138. package/docs/UTILITIES.md +221 -0
  139. package/docs/WORKSPACE_MARKER_SPEC.md +276 -0
  140. package/docs/ci-workflows.md +59 -0
  141. package/docs/commands-reference.md +172 -0
  142. package/docs/config-file-guide.md +299 -0
  143. package/docs/contracts/ARTIFACT_CATALOG.md +333 -0
  144. package/docs/contracts/CLI_LOG_EVENT_STREAM.md +123 -0
  145. package/docs/contracts/COMMAND_OWNERSHIP_MATRIX.md +138 -0
  146. package/docs/contracts/NAMING_AND_COEXISTENCE.md +60 -0
  147. package/docs/contracts/README.md +86 -0
  148. package/docs/contracts/RUNTIME_ACCEPTANCE_MATRIX.md +98 -0
  149. package/docs/contracts/RUNTIME_SUPPORT_MATRIX.md +75 -0
  150. package/docs/contracts/rapidkit-cli-contracts.json +239 -0
  151. package/docs/create-planner-capabilities.md +81 -0
  152. package/docs/doctor-command.md +467 -0
  153. package/docs/examples/ci-agent-grounding.yml +65 -0
  154. package/docs/from-code-to-shared-understanding.md +45 -0
  155. package/docs/governance-policy.enterprise.example.json +40 -0
  156. package/docs/mirror-config.enterprise.example.json +60 -0
  157. package/docs/policies.workspace.example.yml +23 -0
  158. package/docs/workspace-operations.md +160 -0
  159. package/docs/workspace-run.md +104 -0
  160. package/package.json +179 -0
  161. package/rapidkit.config.example.cjs +62 -0
  162. package/scripts/check-agent-customization-drift.mjs +78 -0
  163. package/scripts/check-cli-resolution.cjs +72 -0
  164. package/scripts/enforce-package-manager.cjs +10 -0
  165. package/scripts/enterprise-package-smoke.mjs +463 -0
  166. package/scripts/prepack-enterprise.mjs +43 -0
  167. package/templates/generator.js +179 -0
  168. package/templates/kits/fastapi-ddd/README.md.j2 +117 -0
  169. package/templates/kits/fastapi-ddd/common/env.example.j2 +10 -0
  170. package/templates/kits/fastapi-ddd/env.example.j2 +1 -0
  171. package/templates/kits/fastapi-ddd/pyproject.toml.j2 +64 -0
  172. package/templates/kits/fastapi-ddd/src/__init__.py.j2 +3 -0
  173. package/templates/kits/fastapi-ddd/src/app/__init__.py.j2 +11 -0
  174. package/templates/kits/fastapi-ddd/src/app/application/__init__.py.j2 +5 -0
  175. package/templates/kits/fastapi-ddd/src/app/application/interfaces.py.j2 +43 -0
  176. package/templates/kits/fastapi-ddd/src/app/application/use_cases/__init__.py.j2 +6 -0
  177. package/templates/kits/fastapi-ddd/src/app/application/use_cases/health.py.j2 +14 -0
  178. package/templates/kits/fastapi-ddd/src/app/application/use_cases/notes.py.j2 +24 -0
  179. package/templates/kits/fastapi-ddd/src/app/config/__init__.py.j2 +16 -0
  180. package/templates/kits/fastapi-ddd/src/app/domain/__init__.py.j2 +3 -0
  181. package/templates/kits/fastapi-ddd/src/app/domain/models/__init__.py.j2 +6 -0
  182. package/templates/kits/fastapi-ddd/src/app/domain/models/health.py.j2 +16 -0
  183. package/templates/kits/fastapi-ddd/src/app/domain/models/note.py.j2 +27 -0
  184. package/templates/kits/fastapi-ddd/src/app/infrastructure/__init__.py.j2 +5 -0
  185. package/templates/kits/fastapi-ddd/src/app/infrastructure/repositories/__init__.py.j2 +6 -0
  186. package/templates/kits/fastapi-ddd/src/app/infrastructure/repositories/health.py.j2 +17 -0
  187. package/templates/kits/fastapi-ddd/src/app/infrastructure/repositories/notes.py.j2 +28 -0
  188. package/templates/kits/fastapi-ddd/src/app/main.py.j2 +61 -0
  189. package/templates/kits/fastapi-ddd/src/app/presentation/__init__.py.j2 +3 -0
  190. package/templates/kits/fastapi-ddd/src/app/presentation/api/__init__.py.j2 +5 -0
  191. package/templates/kits/fastapi-ddd/src/app/presentation/api/dependencies/__init__.py.j2 +19 -0
  192. package/templates/kits/fastapi-ddd/src/app/presentation/api/router.py.j2 +10 -0
  193. package/templates/kits/fastapi-ddd/src/app/presentation/api/routes/__init__.py.j2 +5 -0
  194. package/templates/kits/fastapi-ddd/src/app/presentation/api/routes/health.py.j2 +27 -0
  195. package/templates/kits/fastapi-ddd/src/app/presentation/api/routes/notes.py.j2 +50 -0
  196. package/templates/kits/fastapi-ddd/src/app/shared/__init__.py.j2 +5 -0
  197. package/templates/kits/fastapi-ddd/src/app/shared/result.py.j2 +28 -0
  198. package/templates/kits/fastapi-ddd/src/cli.py.j2 +170 -0
  199. package/templates/kits/fastapi-ddd/src/main.py.j2 +35 -0
  200. package/templates/kits/fastapi-ddd/src/modules/__init__.py.j2 +3 -0
  201. package/templates/kits/fastapi-ddd/src/routing/__init__.py.j2 +13 -0
  202. package/templates/kits/fastapi-ddd/src/routing/health.py.j2 +7 -0
  203. package/templates/kits/fastapi-ddd/src/routing/notes.py.j2 +7 -0
  204. package/templates/kits/fastapi-ddd/tests/__init__.py.j2 +1 -0
  205. package/templates/kits/fastapi-ddd/tests/test_app_factory.py.j2 +22 -0
  206. package/templates/kits/fastapi-ddd/tests/test_health.py.j2 +17 -0
  207. package/templates/kits/fastapi-ddd/tests/test_notes.py.j2 +27 -0
  208. package/templates/kits/fastapi-standard/README.md.j2 +140 -0
  209. package/templates/kits/fastapi-standard/common/env.example.j2 +10 -0
  210. package/templates/kits/fastapi-standard/env.example.j2 +1 -0
  211. package/templates/kits/fastapi-standard/pyproject.toml.j2 +64 -0
  212. package/templates/kits/fastapi-standard/src/__init__.py.j2 +3 -0
  213. package/templates/kits/fastapi-standard/src/cli.py.j2 +171 -0
  214. package/templates/kits/fastapi-standard/src/main.py.j2 +66 -0
  215. package/templates/kits/fastapi-standard/src/modules/__init__.py.j2 +3 -0
  216. package/templates/kits/fastapi-standard/src/routing/__init__.py.j2 +16 -0
  217. package/templates/kits/fastapi-standard/src/routing/examples.py.j2 +71 -0
  218. package/templates/kits/fastapi-standard/src/routing/health.py.j2 +22 -0
  219. package/templates/kits/fastapi-standard/tests/__init__.py.j2 +1 -0
  220. package/templates/kits/fastapi-standard/tests/test_examples.py.j2 +29 -0
  221. package/templates/kits/fastapi-standard/tests/test_health.py.j2 +17 -0
  222. package/templates/kits/nestjs-standard/Dockerfile.j2 +41 -0
  223. package/templates/kits/nestjs-standard/README.md.j2 +134 -0
  224. package/templates/kits/nestjs-standard/docker-compose.yml.j2 +94 -0
  225. package/templates/kits/nestjs-standard/docs/README.md.j2 +15 -0
  226. package/templates/kits/nestjs-standard/env.example.j2 +18 -0
  227. package/templates/kits/nestjs-standard/eslint.config.cjs.j2 +9 -0
  228. package/templates/kits/nestjs-standard/jest.config.ts.j2 +28 -0
  229. package/templates/kits/nestjs-standard/nest-cli.json.j2 +10 -0
  230. package/templates/kits/nestjs-standard/package.json.j2 +101 -0
  231. package/templates/kits/nestjs-standard/src/app.controller.ts.j2 +14 -0
  232. package/templates/kits/nestjs-standard/src/app.module.ts.j2 +26 -0
  233. package/templates/kits/nestjs-standard/src/app.service.ts.j2 +16 -0
  234. package/templates/kits/nestjs-standard/src/auth/auth.controller.ts.j2 +20 -0
  235. package/templates/kits/nestjs-standard/src/auth/auth.module.ts.j2 +13 -0
  236. package/templates/kits/nestjs-standard/src/auth/auth.service.ts.j2 +6 -0
  237. package/templates/kits/nestjs-standard/src/auth/entities/token.entity.ts.j2 +3 -0
  238. package/templates/kits/nestjs-standard/src/auth/entities/user.entity.ts.j2 +3 -0
  239. package/templates/kits/nestjs-standard/src/auth/entities/webauthn.entity.ts.j2 +3 -0
  240. package/templates/kits/nestjs-standard/src/config/configuration.ts.j2 +85 -0
  241. package/templates/kits/nestjs-standard/src/config/index.ts.j2 +2 -0
  242. package/templates/kits/nestjs-standard/src/config/validation.ts.j2 +21 -0
  243. package/templates/kits/nestjs-standard/src/examples/dto/create-note.dto.ts.j2 +11 -0
  244. package/templates/kits/nestjs-standard/src/examples/examples.controller.ts.j2 +24 -0
  245. package/templates/kits/nestjs-standard/src/examples/examples.module.ts.j2 +10 -0
  246. package/templates/kits/nestjs-standard/src/examples/examples.service.ts.j2 +33 -0
  247. package/templates/kits/nestjs-standard/src/main.ts.j2 +53 -0
  248. package/templates/kits/nestjs-standard/src/modules/index.ts.j2 +25 -0
  249. package/templates/kits/nestjs-standard/test/app.controller.spec.ts.j2 +24 -0
  250. package/templates/kits/nestjs-standard/test/app.e2e-spec.ts.j2 +60 -0
  251. package/templates/kits/nestjs-standard/test/examples.controller.spec.ts.j2 +28 -0
  252. package/templates/kits/nestjs-standard/test/jest-e2e.json.j2 +15 -0
  253. package/templates/kits/nestjs-standard/tsconfig.build.json.j2 +12 -0
  254. package/templates/kits/nestjs-standard/tsconfig.json.j2 +26 -0
  255. package/workspai.config.example.cjs +62 -0
@@ -0,0 +1 @@
1
+ var o=[{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>]"}],i=new Map;for(let t of o){i.set(t.id.toLowerCase(),t);for(let e of t.aliases)i.set(e.toLowerCase(),t);}function s(t){return t?i.get(t.trim().toLowerCase())??null:null}function l(t){return s(t)?.id??t}function g(){return o.filter(t=>t.owner==="core"||t.generator)}function m(t){return s(t)?.owner==="npm"}async function f(t,e){if(!t.generator)throw new Error(`Kit is not backed by an npm generator: ${t.id}`);if(t.generator==="gofiber"){let{generateGoFiberKit:r}=await import('./gofiber-standard-N5N3QGH3.js');await r(e.projectPath,{project_name:e.projectName,module_path:e.projectName,skipGit:e.skipGit,skipInstall:e.skipInstall});return}if(t.generator==="gogin"){let{generateGoGinKit:r}=await import('./gogin-standard-LAWQTBWL.js');await r(e.projectPath,{project_name:e.projectName,module_path:e.projectName,skipGit:e.skipGit,skipInstall:e.skipInstall});return}if(t.generator==="springboot"){let{generateSpringBootKit:r}=await import('./springboot-standard-OZYF7ZM7.js');await r(e.projectPath,{project_name:e.projectName,artifact_id:e.projectName,java_version:a(e.args,"--java-version")?.trim(),spring_boot_version:a(e.args,"--spring-boot-version")?.trim(),springdoc_version:a(e.args,"--springdoc-version")?.trim(),group_id:a(e.args,"--group-id")?.trim(),package_name:a(e.args,"--package-name")?.trim(),description:a(e.args,"--description")?.trim(),port:a(e.args,"--port")?.trim(),skipGit:e.skipGit,skipInstall:e.skipInstall});return}if(t.generator==="dotnet-webapi-clean"){let{generateDotnetWebApiCleanKit:r}=await import('./dotnet-webapi-clean-IPY3MCGQ.js');await r(e.projectPath,{project_name:e.projectName,target_framework:a(e.args,"--target-framework")?.trim(),root_namespace:a(e.args,"--root-namespace")?.trim(),description:a(e.args,"--description")?.trim(),port:a(e.args,"--port")?.trim(),skipGit:e.skipGit,skipInstall:e.skipInstall});return}throw new Error(`Unhandled npm kit generator: ${t.generator}`)}function a(t,e){let r=t.indexOf(e);if(r>=0&&r+1<t.length)return t[r+1];let n=t.find(p=>p.startsWith(`${e}=`));return n?n.slice(e.length+1):void 0}export{s as a,l as b,g as c,m as d,f as e};
@@ -0,0 +1,2 @@
1
+ import {n,k as k$1,j}from'./chunk-5SWNSJGW.js';import {a as a$1}from'./chunk-HTYMXMQM.js';import {c}from'./chunk-S5KTATOU.js';import {a}from'./chunk-VZKSNUEE.js';import de from'crypto';import m from'path';import y from'fs-extra';import {spawnSync}from'child_process';function F(e,t){let r=spawnSync("git",t,{cwd:e,encoding:"utf8",stdio:["ignore","pipe","ignore"]});return r.status!==0?{ok:false,stdout:""}:{ok:true,stdout:(r.stdout??"").trim()}}function pe(e){let t=[],r=[],s=[];for(let c of e.split(`
2
+ `)){if(!c.trim())continue;let o=c.slice(0,2),i=c.slice(3).trim();if(i){if(o==="??"){r.push(i);continue}o.includes("D")&&s.push(i),t.push(i);}}return {changedFiles:[...new Set(t)].sort(),untrackedFiles:[...new Set(r)].sort(),deletedFiles:[...new Set(s)].sort()}}function L(e,t){let r={available:false,dirty:false,changedFiles:[],untrackedFiles:[],deletedFiles:[]},s=F(e,["rev-parse","--is-inside-work-tree"]);if(!s.ok||s.stdout!=="true")return r;let c=F(e,["rev-parse","--abbrev-ref","HEAD"]),o=F(e,["rev-parse","HEAD"]),i=F(e,["status","--porcelain=v1","--untracked-files=all"]),p=pe(i.stdout),f=p.changedFiles.length>0||p.untrackedFiles.length>0||p.deletedFiles.length>0;return {available:true,branch:c.ok?c.stdout:void 0,commit:o.ok?o.stdout:void 0,ref:t?.ref,dirty:f,changedFiles:p.changedFiles,untrackedFiles:p.untrackedFiles,deletedFiles:p.deletedFiles}}var X="workspace-model-snapshot.v1",V="workspace-model-diff.v1",$=".workspai/reports/workspace-model-snapshot.json",Z=".workspai/reports/workspace-model-diff-last-run.json",le="workspace-impact.v1",fe=".workspai/reports/workspace-impact-last-run.json";function ee(e){let t=e.trim().toLowerCase();return t==="git"||t.startsWith("git:")}function me(e){let t=e.trim();return t.toLowerCase()==="git"?"HEAD":t.toLowerCase().startsWith("git:")&&t.slice(4).trim()||"HEAD"}function _(e){if(Array.isArray(e))return e.map(t=>_(t));if(e&&typeof e=="object"){let t={};for(let r of Object.keys(e).sort())t[r]=_(e[r]);return t}return e}function k(e){return JSON.stringify(_(e))}function ue(e){return e.facts?.map(t=>({...t,freshness:{schemaVersion:t.freshness.schemaVersion,kind:t.freshness.kind,category:t.freshness.category,ttlSeconds:t.freshness.ttlSeconds,verifyBeforeUse:t.freshness.verifyBeforeUse,sourceArtifact:t.freshness.sourceArtifact,sourcePath:t.freshness.sourcePath,inputsHash:t.freshness.inputsHash,reason:t.freshness.reason}}))}function E(e){let{runId:t,...r}=e,s={...r,generatedAt:"<ignored>",graph:e.graph?{...e.graph,generatedAt:"<ignored>"}:void 0,facts:ue(e),factFreshness:e.factFreshness?{schemaVersion:e.factFreshness.schemaVersion,totalFacts:e.factFreshness.totalFacts,liveFacts:e.factFreshness.liveFacts,verifyBeforeUseFacts:e.factFreshness.verifyBeforeUseFacts,byKind:e.factFreshness.byKind,byCategory:e.factFreshness.byCategory}:void 0,validation:e.validation?{...e.validation,issues:e.validation.issues.map(c=>({...c})).sort((c,o)=>{let i=`${c.severity}:${c.code}:${c.target}:${c.message}`,p=`${o.severity}:${o.code}:${o.target}:${o.message}`;return i.localeCompare(p)})}:void 0};return de.createHash("sha256").update(k(s)).digest("hex")}function te(e,t){return m.isAbsolute(t)?t:m.join(e,t)}async function ge(e){let t=await y.readJson(e);if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`Workspace model input is not a JSON object: ${e}`);let r=t;if(r.schemaVersion===X){let s=r;if(!s.model||s.model.schemaVersion!==j)throw new Error(`Invalid workspace model snapshot: ${e}`);return {model:s.model,hash:s.modelHash||E(s.model)}}if(r.schemaVersion===j){let s=r;return {model:s,hash:E(s)}}throw r.schemaVersion===V?new Error(`workspace diff --from received a diff report (${m.basename(e)}). Use a workspace model snapshot or model report as baseline, e.g. ${$}. To analyze an existing diff report, run: npx workspai workspace impact --from ${m.basename(e)} --json`):new Error(`Unsupported workspace model input schema: ${String(r.schemaVersion)}`)}async function ke(e){let t=await y.readJson(e);if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`Workspace diff input is not a JSON object: ${e}`);let r=t;if(r.schemaVersion!==V)return null;let s=r;if(!s.currentModel||s.currentModel.schemaVersion!==j||!s.summary||!Array.isArray(s.changes))throw new Error(`Invalid workspace model diff report: ${e}`);return s}async function Ne(e){let t=e.model??await n({workspacePath:e.workspacePath,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,observableScanDepth:e.observableScanDepth,now:e.now});return {schemaVersion:X,generatedAt:(e.now??new Date).toISOString(),modelHash:E(t),modelRef:k$1,model:t}}async function Be(e,t){let r=m.join(t,$);return await y.ensureDir(m.dirname(r)),await y.writeJson(r,a(e),{spaces:2}),r}function A(e){return {name:e.name,path:e.path,kind:e.kind,runtime:e.runtime,framework:e.framework,generator:e.generator,supportTier:e.supportTier,commands:e.commands,importantFiles:e.importantFiles}}function h(e,t){e.push(t);}function he(e,t){let r=[],s=["name","profile","type"],c=["workspaceType","surfaces","runtimeFamilies","businessCapabilities"];for(let o of s){let i=e.workspace[o],p=t.workspace[o];k(i)!==k(p)&&h(r,{type:"workspace.changed",severity:"info",target:`workspace.${o}`,message:`Workspace metadata field changed: ${String(o)}`,before:i,after:p});}for(let o of c){let i=e.identity[o],p=t.identity[o];k(i)!==k(p)&&h(r,{type:"workspace.changed",severity:"info",target:`identity.${o}`,message:`Workspace identity field changed: ${String(o)}`,before:i,after:p});}return k(e.policies)!==k(t.policies)&&h(r,{type:"workspace.changed",severity:"warning",target:"policies",message:"Workspace policy summary changed.",before:e.policies,after:t.policies}),k(e.evidence)!==k(t.evidence)&&h(r,{type:"workspace.changed",severity:"info",target:"evidence",message:"Workspace evidence summary changed.",before:e.evidence,after:t.evidence}),k(e.discovery)!==k(t.discovery)&&h(r,{type:"workspace.changed",severity:"info",target:"discovery",message:"Workspace discovery settings changed.",before:e.discovery,after:t.discovery}),e.contracts.exists!==t.contracts.exists&&h(r,{type:"workspace.changed",severity:t.contracts.exists?"info":"warning",target:t.contracts.workspaceContractPath,message:"Workspace contract presence changed.",before:e.contracts.exists,after:t.contracts.exists}),r}function we(e,t){let r=e.validation??null,s=t.validation??null;return k(r)===k(s)?[]:[{type:"validation.changed",severity:s?.status==="failed"?"critical":"warning",target:"validation",message:"Workspace model validation changed.",before:r,after:s}]}function ye(e,t){let r=[],s=new Map(e.projects.map(o=>[o.path,o])),c=new Map(t.projects.map(o=>[o.path,o]));for(let[o,i]of c.entries()){let p=s.get(o);if(!p){h(r,{type:"project.added",severity:"info",target:o,message:`Project added: ${i.name}`,after:A(i)});continue}let f=A(p),l=A(i);if(k(f)!==k(l)){let g=p.runtime!==i.runtime||p.framework!==i.framework;h(r,{type:"project.changed",severity:g?"warning":"info",target:o,message:`Project changed: ${i.name}`,before:f,after:l});}}for(let[o,i]of s.entries())c.has(o)||h(r,{type:"project.removed",severity:"warning",target:o,message:`Project removed: ${i.name}`,before:A(i)});return r.sort((o,i)=>`${o.type}:${o.target}`.localeCompare(`${i.type}:${i.target}`))}async function We(e){let t=m.resolve(e.workspacePath),r=ee(e.fromPath),s=r?me(e.fromPath):void 0,c=e.fromPath;if(r){let u=m.join(t,$);if(!await y.pathExists(u))throw new Error("Git-aware workspace diff requires an existing snapshot at .workspai/reports/workspace-model-snapshot.json. Run: npx workspai workspace snapshot --json");c=$;}let o=te(t,c),i=await ge(o),p=e.model??await n({workspacePath:t,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,observableScanDepth:e.observableScanDepth,now:e.now}),f=E(p),l=[...he(i.model,p),...ye(i.model,p),...we(i.model,p)],g;e.includeGitObservation!==false&&(g=e.gitObservation??L(t,{ref:s}),g.available&&Me(l,g,p));let b=l.filter(u=>u.type.startsWith("git.")).length,C=i.hash!==f,W=r?`git:${s??"HEAD"}`:m.relative(t,o).split(m.sep).join("/");return {schemaVersion:V,generatedAt:(e.now??new Date).toISOString(),fromRef:W,toRef:k$1,fromHash:i.hash,toHash:f,summary:{changed:C||b>0,addedProjects:l.filter(u=>u.type==="project.added").length,removedProjects:l.filter(u=>u.type==="project.removed").length,changedProjects:l.filter(u=>u.type==="project.changed").length,workspaceChanges:l.filter(u=>u.type==="workspace.changed").length,validationChanges:l.filter(u=>u.type==="validation.changed").length,gitChangedFiles:b},git:g?.available?Pe(g,s):{available:false,dirty:false,changedFiles:0,untrackedFiles:0,deletedFiles:0},changes:l,currentModel:p}}async function Ke(e,t){let r=m.join(t,Z);return await y.ensureDir(m.dirname(r)),await y.writeJson(r,a(e),{spaces:2}),r}function P(e){return {none:0,low:1,medium:2,high:3,critical:4}[e]}function J(e){return e.reduce((t,r)=>P(r)>P(t)?r:t,"none")}var T=["none","low","medium","high","critical"];function ve(e){let t=Math.max(1,P(e)-1);return T[t]}function be(e){let t=Math.min(T.length-1,P(e)+1);return T[t]}function U(e){return e.join(" ")}function w(e,t,r,s){return {id:e,label:t,scope:s.scope,project:s.project,display:U(["npx","workspai",...r]),execute:U(["npx","--yes","--package","workspai","workspai",...r]),required:s.required!==false}}function Y(e){let t=`project:${e.name}`,r=e.commands.fleetStages;return [w(`project.${e.name}.init`,`Run init for ${e.name}`,["workspace","run","init","--scope",t,"--json"],{scope:"project",project:e.name,required:r.includes("init")}),w(`project.${e.name}.test`,`Run tests for ${e.name}`,["workspace","run","test","--scope",t,"--json"],{scope:"project",project:e.name,required:r.includes("test")}),w(`project.${e.name}.build`,`Run build for ${e.name}`,["workspace","run","build","--scope",t,"--json"],{scope:"project",project:e.name,required:r.includes("build")}),w(`project.${e.name}.start`,`Run start for ${e.name}`,["workspace","run","start","--scope",t,"--json"],{scope:"project",project:e.name,required:r.includes("start")})]}function D(){return [w("workspace.doctor","Run workspace doctor",["doctor","workspace","--json"],{scope:"workspace"}),w("workspace.contract.verify","Verify workspace contract",["workspace","contract","verify","--json"],{scope:"workspace"}),w("workspace.readiness","Run release readiness",["readiness","--json"],{scope:"workspace"}),w("workspace.analyze","Run workspace analyze",["analyze","--json"],{scope:"workspace",required:false}),w("workspace.pipeline","Run governance pipeline",["pipeline","--json"],{scope:"workspace",required:false}),w("workspace.doctor-fix","Verify doctor fix result",["doctor","workspace","--fix","--json"],{scope:"workspace",required:false})]}function je(e,t){let r=t.split(m.sep).join("/");return e.projects.filter(c=>{let o=c.path.split(m.sep).join("/");return r===o||r.startsWith(`${o}/`)}).sort((c,o)=>o.path.length-c.path.length)[0]}function Me(e,t,r){let s=new Set(e.map(o=>o.target)),c=(o,i)=>{let p=i.split(m.sep).join("/"),f=`git:${p}`;if(s.has(f))return;let l=je(r,p),g=l?`${l.name} (${l.path})`:"workspace";h(e,{type:o,severity:o==="git.deleted"?"warning":"info",target:f,message:`Git ${o==="git.untracked"?"untracked":o==="git.deleted"?"deleted":"changed"} file affects ${g}: ${p}`,after:{path:p,project:l?.name,projectPath:l?.path}}),s.add(f);};for(let o of t.changedFiles)c("git.file.changed",o);for(let o of t.untrackedFiles)c("git.untracked",o);for(let o of t.deletedFiles)c("git.deleted",o);}function Pe(e,t){return {available:true,ref:t??e.ref,branch:e.branch,commit:e.commit,dirty:e.dirty,changedFiles:e.changedFiles.length,untrackedFiles:e.untrackedFiles.length,deletedFiles:e.deletedFiles.length}}function Ie(e){let t=new Set,r=[];for(let s of e){let c=`${s.scope}:${s.project??""}:${s.display}`;t.has(c)||(t.add(c),r.push(s));}return r}function Ce(e){return e.type==="project.removed"?"high":e.severity==="critical"?"critical":e.severity==="warning"?"high":("medium")}function Re(e,t){return e.severity==="critical"?"critical":e.target==="policies"||e.target.includes("contract")?"high":e.type==="validation.changed"?(t?.projectCount??0)===0?"low":"high":e.target==="evidence"?"low":e.severity==="warning"?"medium":"low"}function Oe(e){return e.affectedProjects>0||e.projectCount>0||!e.changes.every(r=>r.severity==="critical"?false:r.type.startsWith("git.")||r.type==="validation.changed")?e.risk:P(e.risk)>=P("high")||e.risk==="medium"?"low":e.risk}function Q(e,t){if(!e||e==="workspace")return true;let r=(e.startsWith("project:")?e.slice(8):e).trim().toLowerCase();return [t.name,t.path,m.basename(t.path),t.absolutePath].filter(s=>typeof s=="string"&&s.trim().length>0).map(s=>s.trim().toLowerCase()).includes(r)}function Se(e){if(!e.changed)return {headline:"No workspace model impact detected.",bullets:["The current workspace model matches the provided snapshot/report."],unsafeAssumptions:["Do not claim runtime verification passed unless a report exists."]};let t=e.affectedProjects.map(r=>r.project?.name??r.target);return {headline:`Workspace impact risk: ${e.risk}.`,bullets:[`Affected projects: ${t.length?t.join(", "):"none"}.`,`Workspace-level items: ${e.workspaceImpact.length}.`,"Use the verification plan before recommending apply, rollback, or release actions."],unsafeAssumptions:["Do not infer test/build success from impact alone.","Do not apply fixes without project scope and verification evidence.","Use display commands for users and execute commands for automation."]}}async function qe(e){let t=m.resolve(e.workspacePath),r=ee(e.fromPath),s=e.diff;if(!s&&!r){let n=te(t,e.fromPath);s=await ke(n)??void 0;}s||(s=await We({workspacePath:t,fromPath:e.fromPath,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,includeGitObservation:e.includeGitObservation,gitObservation:e.gitObservation,now:e.now,model:e.model}));let c$1=new Map(s.currentModel.projects.map(n=>[n.path,n])),o=new Map(s.currentModel.projects.map(n=>[n.name,n])),i=s.changes.filter(n=>n.type.startsWith("project.")),p=new Map;for(let n of i){let d=(c$1.get(n.target)??(typeof n.before?.name=="string"?o.get(n.before.name):void 0))?.path??n.target,v=p.get(d)??[];v.push(n),p.set(d,v);}let f=[];for(let[n,a]of p.entries()){let d=c$1.get(n);if(d&&!Q(e.scope,d))continue;let v=J(a.map(Ce)),R=d?.name??(typeof a[0]?.before?.name=="string"?String(a[0].before.name):n);f.push({id:`project:${R}`,scope:"project",target:n,title:`Project impact: ${R}`,summary:a.map(j=>j.message).join(" "),risk:v,reasons:a.map(j=>`${j.type}: ${j.message}`),project:d?{name:d.name,path:d.path,kind:d.kind,runtime:d.runtime,framework:d.framework,supportTier:d.supportTier,...d.generator?{generator:d.generator}:{}}:void 0,verification:d?Y(d):D()});}let l=s.currentModel.graph,g=l?a$1(l):void 0,b=new Set(f.map(n=>n.project?.name).filter(n=>typeof n=="string")),C=new Map;for(let n of f)if(n.project?.name){let a=g?.byId.get(n.project.name);a&&(n.centrality={fanIn:a.fanIn,fanOut:a.fanOut,reach:a.reach,betweenness:a.betweenness,isHotspot:a.isHotspot},a.isHotspot&&(n.risk=be(n.risk),n.reasons=[...n.reasons,`graph.hotspot: critical-path project with ${a.reach} transitive dependent(s); risk escalated.`])),n.origin="direct",n.distance=0,C.set(n.project.name,n.risk);}let W=[],u=0;if(l&&b.size>0){let n=c(l,b);for(let a of n.values()){if(a.distance===0||b.has(a.id))continue;let d=o.get(a.id);if(d&&!Q(e.scope,d))continue;let v=a.path[0],R=a.path[a.path.length-2]??v,j=C.get(v)??"medium",oe=ve(j),M=g?.byId.get(a.id);u=Math.max(u,a.distance),W.push({id:`transitive:${a.id}`,scope:"project",target:d?.path??a.id,title:`Transitive impact: ${a.id}`,summary:`Depends on changed project ${v}${a.via?` via ${a.via}`:""} (distance ${a.distance}).`,risk:oe,reasons:[`graph.dependent: depends on ${R}${a.via?` via ${a.via}`:""} (path ${a.path.join(" -> ")})`],project:d?{name:d.name,path:d.path,kind:d.kind,runtime:d.runtime,framework:d.framework,supportTier:d.supportTier,...d.generator?{generator:d.generator}:{}}:void 0,verification:d?Y(d):D(),origin:"transitive",distance:a.distance,path:a.path,via:a.via,...M?{centrality:{fanIn:M.fanIn,fanOut:M.fanOut,reach:M.reach,betweenness:M.betweenness,isHotspot:M.isHotspot}}:{}});}}W.sort((n,a)=>n.target.localeCompare(a.target));let re=g?g.hotspots.flatMap(n=>{let a=g.byId.get(n);return a?[{project:n,fanIn:a.fanIn,fanOut:a.fanOut,reach:a.reach,betweenness:a.betweenness}]:[]}):[],se=s.changes.filter(n=>!n.type.startsWith("project.")),G=s.currentModel.summary?.projectCount??s.currentModel.projects.length,I=se.map(n=>({id:`workspace:${n.target}`,scope:"workspace",target:n.target,title:`Workspace impact: ${n.target}`,summary:n.message,risk:Re(n,{projectCount:G}),reasons:[`${n.type}: ${n.message}`],verification:D()})),N=Ie([...f.flatMap(n=>n.verification),...W.flatMap(n=>n.verification),...I.flatMap(n=>n.verification),...s.summary.changed?D():[]]).filter(n=>n.required),ne=J([...f.map(n=>n.risk),...W.map(n=>n.risk),...I.map(n=>n.risk)]),B=Oe({risk:ne,affectedProjects:f.length,projectCount:G,changes:s.changes}),K={changed:s.summary.changed,risk:B,affectedProjects:f.length,workspaceItems:I.length,recommendedCommands:N.length,blastRadius:{directlyAffected:f.length,transitivelyAffected:W.length,maxDistance:u,graphEdges:l?.edges.length??0}};return {schemaVersion:le,generatedAt:(e.now??new Date).toISOString(),fromRef:s.fromRef,diffRef:Z,workspace:{name:s.currentModel.workspace.name,profile:s.currentModel.workspace.profile,type:s.currentModel.workspace.type},summary:K,affectedProjects:f.sort((n,a)=>n.target.localeCompare(a.target)),transitiveImpact:W,criticalPathHotspots:re,workspaceImpact:I.sort((n,a)=>n.target.localeCompare(a.target)),verificationPlan:N,agentBrief:Se({changed:K.changed,risk:B,affectedProjects:f,workspaceImpact:I}),diff:s}}async function ze(e,t){let r=m.join(t,fe);return await y.ensureDir(m.dirname(r)),await y.writeJson(r,a(e),{spaces:2}),r}export{X as a,V as b,$ as c,Z as d,le as e,fe as f,ee as g,me as h,Ne as i,Be as j,We as k,Ke as l,D as m,qe as n,ze as o};
@@ -0,0 +1 @@
1
+ import p from'os';import o from'path';import c from'fs-extra';function l(n=process.platform){return n==="win32"?"windows":n==="linux"?"linux":n==="darwin"?"macos":"other"}function s(n=process.platform){return l(n)==="windows"}function C(n=process.platform){return s(n)}var u=new Set(["npx","npm","yarn","pnpm"]);function P(n){return n==="npx"?"npx-cli.js":"npm-cli.js"}function g(n,r){let t=r.npm_execpath;if(!t)return null;let e=o.basename(t).toLowerCase();if(n==="npx"&&e!=="npx-cli.js"){let i=o.join(o.dirname(t),"npx-cli.js");return c.existsSync(i)?i:null}if(n==="npm"&&e==="npx-cli.js"){let i=o.join(o.dirname(t),"npm-cli.js");return c.existsSync(i)?i:null}return c.existsSync(t)?t:null}function x(n){if(n!=="npm"&&n!=="npx")return [];let r=P(n),t=o.dirname(process.execPath),e=o.dirname(t);return [o.join(e,"lib","node_modules","npm","bin",r),o.join(e,"lib64","node_modules","npm","bin",r),o.join("/usr","lib","node_modules","npm","bin",r),o.join("/usr","local","lib","node_modules","npm","bin",r),o.join("/usr","share","nodejs","npm","bin",r)]}function _(n,r=process.platform){return h(n,r).command}function h(n,r=process.platform,t=process.env){let e=n.trim();if(!u.has(e))return {command:e,prefixArgs:[]};let i=o.dirname(process.execPath),d=s(r)?".cmd":"",f=[o.join(i,`${e}${d}`),o.join(i,e)];for(let a of f)if(c.existsSync(a))return {command:a,prefixArgs:[]};let m=g(e,t);if(m)return {command:process.execPath,prefixArgs:[m]};for(let a of x(e))if(c.existsSync(a))return {command:process.execPath,prefixArgs:[a]};return e==="npm"?{command:"corepack",prefixArgs:["npm"]}:{command:e,prefixArgs:[]}}function S(n,r=process.platform){let t=s(r)?";":":",e=o.dirname(process.execPath),i=(n??process.env.PATH??"").split(t).filter(Boolean);return i.includes(e)||i.unshift(e),i.join(t)}var j=["npm_config_package","npm_config__package"];function R(n=process.env,r=process.platform){let t=o.join(p.tmpdir(),"rapidkit-corepack"),e={...n,PATH:S(n.PATH,r),COREPACK_HOME:n.COREPACK_HOME??t};for(let i of j)delete e[i];return e}function v(n=process.platform){return s(n)?"python":"python3"}function w(n=process.platform){return s(n)?["python","py","python3"]:["python3","python"]}function D(n=14,r=10,t=process.platform){let e=[];if(s(t)){for(let i=n;i>=r;i-=1)e.push({command:"py",args:[`-3.${i}`,"--version"]});return e.push({command:"py",args:["-3","--version"]}),e.push({command:"python",args:["--version"]}),e}for(let i=n;i>=r;i-=1)e.push({command:`python3.${i}`,args:["--version"]});return e.push({command:"python3",args:["--version"]}),e.push({command:"python",args:["--version"]}),e}function O(n,r=process.platform){return s(r)?o.join(n,"Scripts"):o.join(n,"bin")}function H(n,r=process.platform){return s(r)?o.join(n,"Scripts","python.exe"):o.join(n,"bin","python")}function L(n,r=process.platform){return s(r)?o.join(n,"Scripts","rapidkit.exe"):o.join(n,"bin","rapidkit")}function T(n,r=process.platform){return s(r)?o.join(n,"Scripts","activate"):o.join(n,"bin","activate")}function B(n,r=process.platform){return s(r)?[o.join(n,"workspai.cmd"),o.join(n,".workspai","rapidkit.cmd"),o.join(n,"rapidkit.cmd"),o.join(n,".rapidkit","rapidkit.cmd")]:[o.join(n,"workspai"),o.join(n,".workspai","rapidkit"),o.join(n,"rapidkit"),o.join(n,".rapidkit","rapidkit")]}function y(n=process.env,r=process.platform){let t=n.XDG_CONFIG_HOME||n.APPDATA||o.join(p.homedir(),".config");return s(r)?o.join(t,"workspai"):o.join(p.homedir(),".workspai")}function k(n=process.env,r=process.platform){let t=n.XDG_CONFIG_HOME||n.APPDATA||o.join(p.homedir(),".config");return s(r)?o.join(t,"rapidkit"):o.join(p.homedir(),".rapidkit")}function K(n=process.env,r=process.platform){return [o.join(y(n,r),"workspaces.json"),o.join(k(n,r),"workspaces.json")]}function V(n=process.env,r=process.platform){let t=[];return s(r)?(n.USERPROFILE&&t.push(o.join(n.USERPROFILE,".local","bin")),n.APPDATA&&t.push(o.join(n.APPDATA,"Python","Scripts")),n.LOCALAPPDATA&&t.push(o.join(n.LOCALAPPDATA,"Programs","Python","Scripts"))):t.push(o.join(p.homedir(),".local","bin")),[...new Set(t.filter(Boolean))]}export{l as a,s as b,C as c,_ as d,h as e,S as f,R as g,v as h,w as i,D as j,O as k,H as l,L as m,T as n,B as o,y as p,k as q,K as r,V as s};
@@ -0,0 +1 @@
1
+ import {r,s}from'./chunk-5XATWNME.js';import a from'path';import s$1 from'fs-extra';function o(t,r$1){return a.join(t,r(r$1))}function f(t,r){return a.join(t,s(r))}async function x(t,r){let n=[o(t,r),f(t,r)];for(let i of n)if(await s$1.pathExists(i))return i;return null}async function P(t,r,n){let i=o(t,r);return await s$1.ensureDir(a.dirname(i)),await s$1.writeJson(i,n,{spaces:2}),i}async function d(t,r,n){let i=o(t,r);return await s$1.ensureDir(a.dirname(i)),await s$1.writeFile(i,n,"utf-8"),i}export{o as a,f as b,x as c,P as d,d as e};
@@ -0,0 +1 @@
1
+ var c="doctor-workspace-evidence-v1",i="doctor-project-evidence-v1";function s(r){return !r||typeof r!="object"||Array.isArray(r)?null:r}function p(r,n){let t=s(r);if(!t)return false;let e=t.schemaVersion,o=t.evidenceType;return !(typeof e=="string"&&(e!==c&&e!==i||n==="workspace"&&e!==c||n==="project"&&e!==i)||typeof o=="string"&&(o!=="workspace"&&o!=="project"||n&&o!==n))}export{c as a,i as b,p as c};
@@ -0,0 +1 @@
1
+ import i from'path';import a from'fs-extra';var m="rapidkit.module-layout.v1",c="src/modules/free",h="src/modules/free/{category}/{module}",f="free/{category}/{module}",d="free/",j={fastapi:{moduleCommands:true,injectAnchors:["src/routing/__init__.py","src/modules/__init__.py"],moduleMarkerFiles:["__init__.py"]},nestjs:{moduleCommands:true,injectAnchors:["src/app.module.ts","src/modules/index.ts"],moduleMarkerFiles:["index.ts","module.ts"]}},A=["go","springboot","dotnet"];function p(t){return t.replace(/\\/g,"/")}function g(t){return typeof t=="string"&&t.startsWith(d)}function P(t,e){if(!g(e))throw new Error(`Module slug must start with ${d}: ${e}`);let s=i.join(c,...e.split("/").slice(1));return i.join(t,s)}function w(t){if(!g(t))throw new Error(`Module slug must start with ${d}: ${t}`);return p(i.join(c,...t.split("/").slice(1)))}async function M(t){return await a.pathExists(t)?(await a.stat(t)).isDirectory():false}async function y(t){let e=i.join(t,"registry.json"),s=[],o=0;if(!await a.pathExists(e))return {status:"passed",projectCount:1,moduleCount:0,issues:s};let n=await a.readJson(e);for(let l of n.installed_modules||[]){let u=l?.slug;if(!g(u))continue;o+=1;let r=P(t,u);await M(r)||s.push({projectRoot:t,registryPath:e,slug:u,expectedPath:r,message:`Missing canonical module directory: ${p(i.relative(t,r))}`});}return {status:s.length>0?"failed":"passed",projectCount:1,moduleCount:o,issues:s}}async function O(t){let e=await _(t),s=[],o=[],n=0;for(let l of e){let u=i.dirname(l),r=await y(u);n+=r.moduleCount,o.push(...r.issues),s.push({projectRoot:u,moduleCount:r.moduleCount,issueCount:r.issues.length,status:r.status});}return {workspacePath:t,status:o.length>0?"failed":"passed",projectCount:s.length,moduleCount:n,issues:o,projects:s}}async function _(t){let e=await a.readdir(t,{withFileTypes:true}),s=[];for(let o of e){if(!o.isDirectory())continue;let n=i.join(t,o.name,"registry.json");await a.pathExists(n)&&s.push(n);}return s.sort()}function L(){return {schemaVersion:m,canonicalModuleRoot:c,pathPattern:h,slugPattern:f}}export{m as a,c as b,h as c,f as d,d as e,j as f,A as g,g as h,P as i,w as j,y as k,O as l,L as m};
@@ -0,0 +1,33 @@
1
+ import {l,j as j$1,i,b,s,m,h}from'./chunk-LZQNVH7D.js';import {a}from'./chunk-2FIX2MDC.js';import {c,d}from'./chunk-5XATWNME.js';import yt from'crypto';import tt from'os';import l$1 from'path';import*as u from'fs-extra';import {execa}from'execa';var gt=["version","project","create","add","list","info","upgrade","diff","doctor","license","commands","reconcile","rollback","uninstall","checkpoint","optimize","snapshot","frameworks","modules","merge"],M=new Set(gt);var g=a();async function et(t){for(let e of [c,d]){let r=l$1.join(t,e);if(await u.pathExists(r))try{let n=await u.readJson(r);if(n&&typeof n=="object")return n}catch{return null}}return null}function O(){let t=[],e=i=>{let o=i?.trim();o&&t.push(o);};e(process.env.RAPIDKIT_BRIDGE_PYTHON),e(process.env.RAPIDKIT_PYTHON_CMD),e(process.env.POETRY_PYTHON);let r=_();(r.startsWith("/")||r.startsWith(".")||r.startsWith(".."))&&!r.startsWith("file:")&&e(l(l$1.join(l$1.resolve(r),".venv")));for(let i of j$1())i.args.length===1&&i.args[0]==="--version"&&e(i.command);for(let i$1 of i())e(i$1);return [...new Set(t)]}function v(t,e){return t==="py"?["-3",...e]:e}function Y(t){if(!t)return t;let e=["Installed Poetry version does not support '--no-update'. Falling back to 'poetry lock'."];return t.split(/\r?\n/).filter(i=>!e.some(o=>i.includes(o))).join(`
2
+ `)}var w=class extends Error{code;constructor(e,r){super(r),this.code=e;}};function S(t){if(t instanceof w)switch(t.code){case "PYTHON_NOT_FOUND":return `Workspai could not find Python (python3/python/py) on your PATH.
3
+ Install Python 3.10+ and ensure \`${h()}\` is available, then retry.
4
+ Tip: if you are inside a RapidKit project, use the local ./rapidkit launcher.`;case "BRIDGE_VENV_CREATE_FAILED":return `Workspai failed to create its bridge virtual environment.
5
+ `+(b()?`Ensure Python is installed with venv support.
6
+ `:`Ensure Python venv support is installed (e.g., python3-venv).
7
+ `)+`Details: ${t.message}`;case "BRIDGE_PIP_BOOTSTRAP_FAILED":return `Workspai could not bootstrap pip inside the bridge virtual environment.
8
+ `+(b()?`Ensure pip is available for your Python installation and retry.
9
+ `:`Install python3-venv/python3-pip and retry.
10
+ `)+`Details: ${t.message}`;case "BRIDGE_PIP_UPGRADE_FAILED":return `Workspai could not upgrade pip in the bridge virtual environment.
11
+ Check your network/proxy or disable RAPIDKIT_BRIDGE_UPGRADE_PIP.
12
+ Details: ${t.message}`;case "BRIDGE_PIP_INSTALL_FAILED":return `Workspai could not install rapidkit-core in the bridge virtual environment.
13
+ Check your network/proxy, or install manually with: pipx install rapidkit-core.
14
+ Details: ${t.message}`;default:return `Workspai bridge error: ${t.message}`}return `Workspai failed to run the Python core engine: ${t instanceof Error?t.message:String(t)}`}function _(){let t=process.env.RAPIDKIT_CORE_PYTHON_PACKAGE;return t&&t.trim()?t.trim():"rapidkit-core"}function wt(){let t=_(),e=process.env.RAPIDKIT_CORE_PYTHON_PACKAGE_ID,r=e&&e.trim()?`${t}|${e.trim()}`:t;return yt.createHash("sha256").update(r).digest("hex").slice(0,12)}function j(){let t=process.env.XDG_CACHE_HOME;return t&&t.trim()?t:l$1.join(tt.homedir(),".cache")}function vt(){return l$1.join(j(),"rapidkit","npm-bridge","venv")}function nt(){let t=wt();return l$1.join(j(),"rapidkit","npm-bridge",`venv-${t}`)}function H(t){return l(t)}function U(t){return m(t)}async function rt(t=process.platform,e=process.env){let r=b(t)?["rapidkit.exe","rapidkit.cmd"]:["rapidkit"],n=s(e,t).flatMap(i=>r.map(o=>l$1.join(i,o)));for(let i of [...new Set(n)])try{if(!await u.pathExists(i))continue;let o=await execa(i,["--version","--json"],{reject:false,stdio:"pipe",timeout:4e3});if(o.exitCode===0&&await D(o.stdout))return {cmd:i,baseArgs:[]}}catch{}return null}function it(t){return /[<>=!~]=|@|\.whl$|\.tar\.gz$|\.zip$|git\+|https?:\/\//.test(t)}function Pt(t){return l$1.dirname(l$1.dirname(t))}function ot(){return l$1.join(j(),"rapidkit","npm-bridge","core-commands.json")}async function st(t){let e=!!process.env.RAPIDKIT_DEBUG,r=n=>{e&&process.stderr.write(`[DEBUG] tryRapidkit(${t}): ${n}
15
+ `);};try{r("probing interpreter-specific rapidkit script");let i=((await execa(t,v(t,["-c","import sysconfig, os; print(os.path.join(sysconfig.get_path('scripts'), 'rapidkit'))"]),{reject:false,stdio:"pipe",timeout:2e3})).stdout??"").toString().trim();if(r(`script path: ${i}`),i)try{if(await u.pathExists(i)){r(`found script at ${i}; invoking --version --json`);let o=await execa(i,["--version","--json"],{reject:false,stdio:"pipe",timeout:4e3});if(r(`script exitCode=${o.exitCode}`),o.exitCode===0){let a=(o.stdout??"").toString().trim();try{let s=JSON.parse(a),c=!!s&&typeof s=="object"&&s!==null&&"version"in s;if(r(`script JSON parse ok=${c}`),c)return true}catch{r("script output not valid JSON");}}}}catch(o){r(`interpreter-specific script probe failed: ${String(o)}`);}}catch(n){r(`interpreter-specific script probe error: ${String(n)}`);}try{r('probing importlib.find_spec("rapidkit")');let n=await execa(t,v(t,["-c","import importlib.util; print(1 if importlib.util.find_spec('rapidkit') else 0)"]),{reject:false,stdio:"pipe",timeout:2e3});if(r(`import probe exitCode=${n.exitCode} stdout=${(n.stdout??"").toString().trim()}`),n.exitCode===0&&(n.stdout??"").toString().trim()==="1")return true}catch(n){r(`import probe error: ${String(n)}`);}try{r("probing python -m rapidkit");let n=await execa(t,v(t,["-m","rapidkit","--version","--json"]),{reject:false,stdio:"pipe",timeout:8e3});if(r(`-m probe exitCode=${n.exitCode}`),n.exitCode===0)return true}catch(n){r(`-m probe error: ${String(n)}`);}try{r("probing PATH for rapidkit executables");let n=(process.env.PATH??"").split(l$1.delimiter).filter(Boolean);for(let i of n){let o=l$1.join(i,b()?"rapidkit.exe":"rapidkit");try{if(await u.pathExists(o)){r(`found candidate on PATH: ${o}; invoking --version --json`);let a=await execa(o,["--version","--json"],{reject:false,stdio:"pipe",timeout:4e3});if(r(`candidate exitCode=${a.exitCode}`),a.exitCode===0){let s=(a.stdout??"").toString().trim();try{let c=JSON.parse(s);if(c&&typeof c=="object"&&c!==null&&"version"in c)return true}catch{r("candidate output not valid JSON, skipping");}}}}catch(a){r(`error probing candidate ${o}: ${String(a)}`);}}return r("no valid rapidkit found on PATH"),false}catch(n){return r(`PATH probe error: ${String(n)}`),false}}async function D(t){let e=(t??"").toString().trim();if(!e)return false;try{let r=JSON.parse(e);return !!r&&typeof r=="object"&&r!==null&&"version"in r}catch{return false}}async function at(t,e=process.platform){let r=async o=>{try{let c=(await et(o))?.metadata?.python?.venvPath;return typeof c!="string"||!c.trim()?null:l$1.isAbsolute(c)?c:l$1.join(o,c)}catch{return null}},n=async(o,a)=>{let s=m(a,e);if(await u.pathExists(s)){let p=await execa(s,["--version","--json"],{reject:false,stdio:"pipe",timeout:1500,cwd:o});if(p.exitCode===0&&await D(p.stdout))return {cmd:s,baseArgs:[],workspaceDir:o}}let c=l(a,e);if(await u.pathExists(c)){let p=await execa(c,["-m","rapidkit","--version","--json"],{reject:false,stdio:"pipe",timeout:1500,cwd:o});if(p.exitCode===0&&await D(p.stdout))return {cmd:c,baseArgs:["-m","rapidkit"],workspaceDir:o}}return null},i=t;for(let o=0;o<25;o+=1){let a=await r(i),s=[l$1.join(i,".venv"),a].filter(p=>!!p);for(let p of [...new Set(s)]){let P=await n(i,p);if(P)return P}let c=l$1.dirname(i);if(c===i)break;i=c;}return null}async function Ct(t){try{let e=l$1.join(t,".python-version");if(await u.pathExists(e)){let n=(await u.readFile(e,"utf-8")).trim();if(n)return n}}catch{}try{let e=await et(t);if(typeof e?.pythonVersion=="string"&&e.pythonVersion.trim())return e.pythonVersion.trim();let n=e?.metadata?.python?.pythonVersion;if(typeof n=="string"&&n.trim())return n.trim()}catch{}return null}async function F(t){if(t&&t.trim())try{let a=await at(t);if(a){let s=a.workspaceDir??(l$1.dirname(a.cmd).includes(".venv")?l$1.dirname(l$1.dirname(l$1.dirname(a.cmd))):l$1.dirname(a.cmd)),c=await Ct(s);return c&&(process.env.PYENV_VERSION=c),a}}catch{}let e=await At();if(e.kind==="venv"){let a=Pt(e.pythonPath),s=U(a);return await u.pathExists(s)?{cmd:s,baseArgs:[]}:{cmd:e.pythonPath,baseArgs:["-m","rapidkit"]}}try{if((await execa(e.cmd,["-m","rapidkit","--version","--json"],{reject:false,stdio:"pipe",timeout:4e3})).exitCode===0)return {cmd:e.cmd,baseArgs:["-m","rapidkit"]}}catch{}try{let s=((await execa(e.cmd,["-c","import sysconfig, os; print(os.path.join(sysconfig.get_path('scripts'), 'rapidkit'))"],{reject:false,stdio:"pipe",timeout:2e3})).stdout??"").toString().trim();if(s&&await u.pathExists(s))try{let c=await execa(s,["--version","--json"],{reject:false,stdio:"pipe",timeout:4e3});if(c.exitCode===0&&await D(c.stdout))return {cmd:s,baseArgs:[]}}catch{}}catch{}let r=await rt();if(r)return r;let n=nt(),i=await N(e.cmd),o=U(n);return await u.pathExists(o)?{cmd:o,baseArgs:[]}:{cmd:i,baseArgs:["-m","rapidkit"]}}async function ct(){for(let t of O())try{return await execa(t,v(t,["--version"]),{reject:false,stdio:"pipe",timeout:2e3}),t}catch{}return null}async function B(){let t=null;for(let e of O()){try{await execa(e,v(e,["--version"]),{reject:false,stdio:"pipe",timeout:2e3});}catch(r){t=r;continue}try{return await N(e)}catch(r){t=r;continue}}throw t instanceof w?t:t instanceof Error?new w("BRIDGE_VENV_BOOTSTRAP_FAILED",t.message):new w("PYTHON_NOT_FOUND","No Python interpreter found (python3/python/py).")}async function Et(){let t=!!process.env.RAPIDKIT_DEBUG,e=n=>{t&&process.stderr.write(`[DEBUG] checkRapidkitCore: ${n}
16
+ `);},r=Array.from(new Set([...i(),...j$1(14,10).map(n=>n.command)]));for(let n of r)try{e(`Method 1: trying ${n} import`);let i=await execa(n,v(n,["-c","import rapidkit_core; print(1)"]),{reject:false,stdio:"pipe",timeout:g});if(i.exitCode===0&&i.stdout?.trim()==="1")return e(`\u2713 Found via ${n} import`),true}catch{continue}for(let n of r)try{e(`Method 2: trying ${n} -m pip show`);let i=await execa(n,v(n,["-m","pip","show","rapidkit-core"]),{reject:false,stdio:"pipe",timeout:g});if(i.exitCode===0&&i.stdout?.includes("Name: rapidkit-core"))return e(`\u2713 Found via ${n} -m pip show`),true}catch{continue}for(let n of ["pip","pip3"])try{e(`Method 3: trying ${n} show`);let i=await execa(n,["show","rapidkit-core"],{reject:false,stdio:"pipe",timeout:g});if(i.exitCode===0&&i.stdout?.includes("Name: rapidkit-core"))return e(`\u2713 Found via ${n} show`),true}catch{continue}try{e("Method 4: checking pyenv versions");let n=await execa("pyenv",["versions","--bare"],{reject:false,stdio:"pipe",timeout:g});if(n.exitCode===0&&n.stdout){let i=n.stdout.split(`
17
+ `).filter(o=>o.trim());e(`Found pyenv versions: ${i.join(", ")}`);for(let o of i){let a=process.env.PYENV_ROOT||l$1.join(tt.homedir(),".pyenv"),s=l$1.join(a,"versions",o.trim(),"bin","pip");try{let c=await execa(s,["show","rapidkit-core"],{reject:false,stdio:"pipe",timeout:g});if(c.exitCode===0&&c.stdout?.includes("Name: rapidkit-core"))return e(`\u2713 Found in pyenv ${o}`),true}catch{try{let c=await execa("pyenv",["exec","pip","show","rapidkit-core"],{reject:false,stdio:"pipe",timeout:g,env:{...process.env,PYENV_VERSION:o.trim()}});if(c.exitCode===0&&c.stdout?.includes("Name: rapidkit-core"))return e(`\u2713 Found in pyenv ${o} via PYENV_VERSION`),true}catch{continue}}}}}catch{e("pyenv not available");}for(let n of r)try{e(`Method 5: checking ${n} user site`);let i=await execa(n,v(n,["-m","site","--user-site"]),{reject:false,stdio:"pipe",timeout:g});if(i.exitCode===0&&i.stdout){let o=i.stdout.trim(),a=l$1.join(o,"rapidkit_core");if(await u.pathExists(a))return e("\u2713 Found in user site-packages"),true}}catch{continue}try{e("Method 6: checking pipx");let n=await execa("pipx",["list"],{reject:false,stdio:"pipe",timeout:g});if(n.exitCode===0&&n.stdout?.includes("rapidkit-core"))return e("\u2713 Found via pipx"),true}catch{e("pipx not available");}for(let n of r)try{e(`Method 6: checking ${n} -m pipx list`);let i=await execa(n,v(n,["-m","pipx","list"]),{reject:false,stdio:"pipe",timeout:g});if(i.exitCode===0&&i.stdout?.includes("rapidkit-core"))return e(`\u2713 Found via ${n} -m pipx list`),true}catch{continue}try{if(e("Method 7: checking poetry"),(await execa("poetry",["show","rapidkit-core"],{reject:false,stdio:"pipe",timeout:g})).exitCode===0)return e("\u2713 Found via poetry"),true}catch{e("poetry check failed");}for(let n of r)try{if(e(`Method 7: checking ${n} -m poetry show rapidkit-core`),(await execa(n,v(n,["-m","poetry","show","rapidkit-core"]),{reject:false,stdio:"pipe",timeout:g})).exitCode===0)return e(`\u2713 Found via ${n} -m poetry`),true}catch{continue}try{e("Method 8: checking conda");let n=await execa("conda",["list","rapidkit-core"],{reject:false,stdio:"pipe",timeout:g});if(n.exitCode===0&&n.stdout?.includes("rapidkit-core"))return e("\u2713 Found via conda"),true}catch{e("conda not available");}return e("\u2717 Not found in any environment"),false}function _t(t){let e=t.trim();if(!e||!e.startsWith("rapidkit-core"))return null;let r=e.slice(13).trim();return !r||/[\/@]|\.whl$|\.tar\.gz$|\.zip$|git\+|https?:\/\//.test(r)?null:r}function z(t){let e=t.trim();if(!e)return null;let r=e.split("."),n=[];for(let i of r){let o=i.match(/^(\d+)/);if(!o){n.push(0);continue}n.push(Number.parseInt(o[1],10));}return n}function Z(t,e){let r=Math.max(t.length,e.length);for(let n=0;n<r;n+=1){let i=n<t.length?t[n]:0,o=n<e.length?e[n]:0;if(i>o)return 1;if(i<o)return -1}return 0}function kt(t){return t.length<=1?[t[0]+1]:t.length===2?[t[0]+1,0]:[t[0],t[1]+1,0]}function xt(t){let e=t.split(",").map(n=>n.trim()).filter(Boolean);if(e.length===0)return null;let r=[];for(let n of e){let i=n.match(/^(==|>=|<=|>|<|~=)\s*([0-9][0-9A-Za-z+._-]*)$/);if(!i)return null;r.push({op:i[1],version:i[2]});}return r}function dt(t,e){let r=z(t);if(!r)return false;let n=xt(e);if(!n)return false;for(let i of n){let o=z(i.version);if(!o)return false;let a=Z(r,o);if(i.op==="=="&&a!==0||i.op===">="&&a<0||i.op==="<="&&a>0||i.op===">"&&a<=0||i.op==="<"&&a>=0)return false;if(i.op==="~="){if(a<0)return false;let s=kt(o);if(Z(r,s)>=0)return false}}return true}async function Rt(){let t=Array.from(new Set([...i(),...j$1(14,10).map(r=>r.command)])),e=r=>{let n=r.match(/^Version:\s*(.+)$/m);return n?n[1].trim():null};for(let r of t)try{let n=await execa(r,v(r,["-m","pip","show","rapidkit-core"]),{reject:false,stdio:"pipe",timeout:g});if(n.exitCode===0){let i=e(n.stdout||"");if(i)return i}}catch{continue}for(let r of ["pip","pip3"])try{let n=await execa(r,["show","rapidkit-core"],{reject:false,stdio:"pipe",timeout:g});if(n.exitCode===0){let i=e(n.stdout||"");if(i)return i}}catch{continue}try{let r=await execa("pipx",["list"],{reject:false,stdio:"pipe",timeout:g});if(r.exitCode===0&&r.stdout){let n=r.stdout.match(/rapidkit-core\s+([0-9][0-9A-Za-z+._-]*)/i);if(n?.[1])return n[1]}}catch{}return null}async function bt(){let t=_(),e=_t(t);if(!e)return {isCompatible:false,installedVersion:null,expectedConstraint:null,reason:it(t)?"constraint-unsupported":"constraint-missing"};let r=await Rt();if(!r)return {isCompatible:false,installedVersion:null,expectedConstraint:e,reason:"version-not-detected"};let n=dt(r,e);return {isCompatible:n,installedVersion:r,expectedConstraint:e,reason:n?"compatible":"incompatible-version"}}async function N(t){let e=nt(),r=vt(),n=_(),i=[e];!it(n)&&!await u.pathExists(e)&&await u.pathExists(r)&&i.push(r);for(let m of i){let h=H(m);if(await u.pathExists(h))try{let f=await execa(h,["-c","import importlib.util; print(1 if importlib.util.find_spec('rapidkit') else 0)"],{reject:false,stdio:"pipe",timeout:2e3});if(f.exitCode===0&&(f.stdout??"").toString().trim()==="1")return h;await u.remove(m);}catch{await u.remove(m);}}let o=e,a={...process.env,PIP_DISABLE_PIP_VERSION_CHECK:"1",PIP_NO_PYTHON_VERSION_WARNING:"1"},s=Math.max(0,Number(process.env.RAPIDKIT_BRIDGE_PIP_RETRY??"2")),c=Math.max(200,Number(process.env.RAPIDKIT_BRIDGE_PIP_RETRY_DELAY_MS??"800")),p=Math.max(1e4,Number(process.env.RAPIDKIT_BRIDGE_PIP_TIMEOUT_MS??"120000")),P=m=>new Promise(h=>setTimeout(h,m)),C=async(m,h,f)=>{let y=await execa(m,h,{reject:false,stdio:["ignore","pipe","inherit"],env:a,timeout:f});if(y.exitCode===0)return;let T=(y.stdout??"").toString(),$=(y.stderr??"").toString(),R=[T,$].filter(Boolean).join(`
18
+ `),mt=R?`${m} ${h.join(" ")}
19
+ ${R}`:`${m} ${h.join(" ")}`;throw new Error(mt)},x=async(m,h,f)=>{let y=0;for(;;)try{await C(m,h,f);return}catch(T){if(y>=s)throw T;let $=Math.floor(Math.random()*200),R=c*Math.pow(2,y)+$;y+=1,await P(R);}};try{await u.ensureDir(l$1.dirname(o));try{await C(t,v(t,["-m","venv",o]),6e4);}catch(f){let y=f instanceof Error?f.message:String(f);throw new w("BRIDGE_VENV_CREATE_FAILED",y)}let m=H(o);if((await execa(m,["-m","pip","--version"],{reject:false,stdio:"pipe",timeout:2e3})).exitCode!==0&&(await execa(m,["-m","ensurepip","--default-pip"],{reject:false,stdio:["ignore","pipe","inherit"],env:a,timeout:6e4})).exitCode!==0)throw new w("BRIDGE_PIP_BOOTSTRAP_FAILED","ensurepip failed; install python3-venv/python3-pip and retry.");if(process.env.RAPIDKIT_BRIDGE_UPGRADE_PIP==="1")try{await x(m,["-m","pip","install","-U","pip"],p);}catch(f){let y=f instanceof Error?f.message:String(f);throw new w("BRIDGE_PIP_UPGRADE_FAILED",y)}try{await x(m,["-m","pip","install","-U",_()],p);}catch(f){let y=f instanceof Error?f.message:String(f);throw new w("BRIDGE_PIP_INSTALL_FAILED",y)}return m}catch(m){if(m instanceof w)throw m;let h=m instanceof Error?m.message:String(m);throw new w("BRIDGE_VENV_BOOTSTRAP_FAILED",h)}}async function At(){if(process.env.RAPIDKIT_BRIDGE_FORCE_VENV==="1")return {kind:"venv",pythonPath:await B()};for(let r of O())if(await st(r))return {kind:"system",cmd:r};let t=await ct();if(!t)throw new w("PYTHON_NOT_FOUND","No Python interpreter found (python3/python/py).");let e;try{e=await N(t);}catch{e=await B();}return {kind:"venv",pythonPath:e}}async function Kt(t,e){try{let r=await F(e?.cwd),n=r.cmd,i=[...r.baseArgs,...t];if(t[0]==="init"){let s=await execa(n,i,{cwd:e?.cwd,env:{...process.env,...e?.env},reject:false,stdio:"pipe"}),c=Y((s.stdout??"").toString()),p=Y((s.stderr??"").toString());return c&&process.stdout.write(c.endsWith(`
20
+ `)?c:`${c}
21
+ `),p&&process.stderr.write(p.endsWith(`
22
+ `)?p:`${p}
23
+ `),typeof s.exitCode=="number"?s.exitCode:1}let a=await execa(n,i,{cwd:e?.cwd,env:{...process.env,...e?.env},reject:false,stdio:"inherit"});return typeof a.exitCode=="number"?a.exitCode:1}catch(r){return process.stderr.write(`${S(r)}
24
+ `),1}}var It=[{pattern:/RapidKitError:\s*Directory '([^']+)' exists and force is not set/,message:t=>`\u274C Directory "${l$1.basename(t[1])}" already exists.
25
+ \u{1F4A1} Choose a different name, or remove the existing directory first:
26
+ rm -rf ${t[1]}`},{pattern:/RapidKitError:\s*Project name '([^']+)' is (invalid|not allowed)/i,message:t=>`\u274C Invalid project name: "${t[1]}"
27
+ \u{1F4A1} Use lowercase letters, numbers, and hyphens only (e.g. my-api).`},{pattern:/RapidKitError:\s*Kit '([^']+)' not found/i,message:t=>`\u274C Unknown kit: "${t[1]}"
28
+ \u{1F4A1} Run "npx workspai list" to see available kits.`},{pattern:/RapidKitError:\s*(.+)/,message:t=>`\u274C ${t[1].trim()}`}];async function Wt(t,e){let{spawn:r}=await import('child_process');try{let n=await F(e?.cwd),i=n.cmd,o=[...n.baseArgs,...t];return await new Promise(a=>{let s=r(i,o,{cwd:e?.cwd,env:{...process.env,...e?.env},stdio:["inherit","inherit","pipe"]}),c=[];s.stderr?.on("data",p=>{c.push(p);}),s.on("close",p=>{let P=p??1;if(P!==0&&c.length>0){let C=Buffer.concat(c).toString("utf8");for(let{pattern:x,message:m}of It){let h=C.match(x);if(h){process.stderr.write(m(h)+`
29
+ `),a(P);return}}process.stderr.write(C);}a(P);}),s.on("error",p=>{process.stderr.write(`${S(p)}
30
+ `),a(1);});})}catch(n){return process.stderr.write(`${S(n)}
31
+ `),1}}async function k(t,e){try{let r=await F(e?.cwd),n=r.cmd,i=[...r.baseArgs,...t],o=await execa(n,i,{cwd:e?.cwd,env:{...process.env,...e?.env},reject:false,stdio:"pipe"});return {exitCode:typeof o.exitCode=="number"?o.exitCode:1,stdout:(o.stdout??"").toString(),stderr:(o.stderr??"").toString()}}catch(r){return {exitCode:1,stdout:"",stderr:`${S(r)}
32
+ `}}}function ut(t){let e=new Set,r=t.split(`
33
+ `),n=false;for(let i of r){let o=i.replace(/\r$/,"");if(!n){/^\s*Commands:\s*$/i.test(o)&&(n=true);let c=o.match(/^\s*rapidkit\s+([a-z0-9_-]+)\b/i);if(c){let p=c[1].trim();p&&!p.startsWith("-")&&e.add(p);}continue}if(!o.trim())break;if(/^\s*(Options|Arguments|Usage|Commands)\s*:/i.test(o))continue;let a=o.match(/^\s*([a-z0-9][a-z0-9_-]*)\b/i);if(!a)continue;let s=a[1].trim();s&&!s.startsWith("-")&&e.add(s);}return e}async function pt(){let t=ot();if(!await u.pathExists(t))return null;try{let e=await u.readJson(t);if(e&&e.schema_version===1&&Array.isArray(e.commands))return e}catch{}return null}async function X(t){let e=ot();await u.ensureDir(l$1.dirname(e)),await u.writeJson(e,t,{spaces:2});}async function St(){let t=await k(["version","--json"],{cwd:process.cwd()});if(t.exitCode===0)try{let r=JSON.parse(t.stdout)?.version;return typeof r=="string"?r:void 0}catch{return}}async function Dt(){let t=await k(["commands","--json"],{cwd:process.cwd()});if(t.exitCode!==0)return null;try{let e=JSON.parse(t.stdout);if(e?.schema_version!==1||!Array.isArray(e.commands))return null;let r=e.commands.filter(n=>typeof n=="string");return r.length?r:null}catch{return null}}async function Jt(){let e=Date.now(),r=await pt(),n=await St(),i=!!r?.commands?.length;if(i&&e-r.fetched_at<864e5&&(!n||!r.rapidkit_version||r.rapidkit_version===n))return new Set(r.commands);let o=await Dt();if(o?.length){let p=Array.from(new Set(o)).sort();return await X({schema_version:1,fetched_at:e,rapidkit_version:n,commands:p}),new Set(p)}let a=await k(["--help"],{cwd:process.cwd()});if(a.exitCode!==0)return i&&r?.commands?new Set(r.commands):new Set(M);let s=ut(a.stdout);if(s.size===0)return new Set(M);let c=Array.from(s).sort();return await X({schema_version:1,fetched_at:e,rapidkit_version:n,commands:c}),s}async function Yt(){let e=Date.now(),r=await pt();return !r||e-r.fetched_at>=864e5||!r.commands?.length?null:new Set(r.commands)}function lt(){return l$1.join(j(),"rapidkit","npm-bridge","modules-catalog.json")}async function Ot(){let t=lt();if(!await u.pathExists(t))return null;try{let e=await u.readJson(t);if(e&&e.schema_version===1&&Array.isArray(e.modules))return e}catch{}return null}async function q(t){let e=lt();await u.ensureDir(l$1.dirname(e)),await u.writeJson(e,t,{spaces:2});}function Q(t){try{return JSON.parse(t)}catch{return null}}async function Ht(t={}){let e=typeof t.ttlMs=="number"?t.ttlMs:18e5,r=Date.now(),n=await Ot();if(n?.fetched_at&&r-n.fetched_at<e)return n;let i=["modules","list","--json-schema","1"];t.category&&i.push("--category",t.category),t.tag&&i.push("--tag",t.tag),t.detailed&&i.push("--detailed");let o=await k(i,{cwd:t.cwd,env:t.env});if(o.exitCode===0){let s=Q(o.stdout);if(s&&s.schema_version===1&&Array.isArray(s.modules)){let c={...s,fetched_at:r};return await q(c),c}}let a=await k(["modules","list","--json"],{cwd:t.cwd,env:t.env});if(a.exitCode===0){let s=Q(a.stdout);if(Array.isArray(s)){let c={schema_version:1,generated_at:new Date().toISOString(),filters:{category:t.category??null,tag:t.tag??null,detailed:!!t.detailed},stats:{total:s.length,returned:s.length,invalid:0},modules:s,source:"legacy-json",fetched_at:r};return await q(c),c}}return n||null}var Ut={pythonCommandCandidates:O,pickSystemPython:ct,ensureBridgeVenv:N,ensureBridgeVenvFromCandidates:B,parseCoreCommandsFromHelp:ut,tryRapidkit:st,findUserLocalRapidkitRunner:rt,findWorkspaceRunner:at,checkRapidkitCoreAvailable:Et,checkRapidkitCoreVersionCompatible:bt,isVersionSatisfyingConstraint:dt};export{M as a,Et as b,bt as c,At as d,Kt as e,Wt as f,k as g,Jt as h,Yt as i,Ht as j,Ut as k};
@@ -0,0 +1,9 @@
1
+ import {f as f$2,e}from'./chunk-T3GJ7YVG.js';import {a,b as b$1}from'./chunk-22DT744Z.js';import {h,i}from'./chunk-4KUIFXHM.js';import {e as e$1}from'./chunk-NAAQMSO3.js';import {a as a$1}from'./chunk-GZTYAEWX.js';import {f as f$1,o as o$1,p as p$1}from'./chunk-5XATWNME.js';import b from'fs';import p from'path';import o from'chalk';var _=new Set([".git",".workspai",".rapidkit",".venv","node_modules","dist","build","target","coverage","htmlcov",".next"]);async function D(e){try{return await b.promises.access(e,b.constants.F_OK),true}catch{return false}}async function x(e){try{let n=JSON.parse(await b.promises.readFile(e,"utf-8"));return n&&typeof n=="object"&&!Array.isArray(n)?n:null}catch{return null}}async function J(e){try{return await b.promises.readFile(e,"utf-8")}catch{return ""}}function H(e){return a(e)}async function K(e,n){return await M([...p$1(e,"project.json"),...p$1(e,"context.json")])?true:b$1(e)?false:p.resolve(e)===p.resolve(n)?h(e).length>0:h(e).length>0}async function B(e){let n=await a$1(e,{skipDirs:_,includeHiddenDirs:false,descendIntoMatchedProjects:false,isProjectDir:K});return n.length>0?n:b$1(e)?[]:h(e).length>0?[e]:[]}function U(e,n){return p.relative(e,n).replace(/\\/g,"/")||"."}async function A(e,n){for(let t of n)if(await D(p.join(e,t)))return true;return false}async function M(e){for(let n of e)if(await D(n))return true;return false}async function T(e){for(let n of e){let t=await x(n);if(t)return t}return null}async function V(e){return A(e,["health","health.ts","health.js","health.py","health.go","health.kt","health.rb","health.php","healthcheck","health-check","src/health.ts","src/health.js","src/health.py","src/health.go","src/health.kt","src/health.rb","src/health.php","src/healthcheck.ts","src/healthcheck.js","src/liveness.ts","src/readiness.ts","src/ping.ts"])}async function L(e){if(await A(e,["tests","test","__tests__","src/__tests__","pytest.ini","vitest.config.ts","jest.config.ts"]))return true;let t=await x(p.join(e,"package.json")),r=t?.scripts&&typeof t.scripts=="object"?t.scripts:{};return typeof r.test=="string"&&r.test.trim().length>0}async function q(e){let n=await x(p.join(e,"package.json")),t=n?.scripts&&typeof n.scripts=="object"?n.scripts:{};return Object.keys(t).sort()}function f(e,n,t,r,s,a){return {id:e,severity:n,target:t,title:r,detail:s,remediation:a}}function Q(e){let n=e.reduce((t,r)=>r.severity==="fail"?t+28:r.severity==="warn"?t+12:t+3,0);return Math.max(0,100-n)}async function X(e,n){let t=await T(p$1(n,"project.json")),r=i(n,t),s=h(n),a=r.runtime==="unknown"?s[0]||"unknown":r.runtime,i$1=U(e,n),l=i$1,g=await q(n),m=await M([...p$1(n,"project.json"),...p$1(n,"context.json")]),d=await L(n),h$1=await A(n,["Dockerfile","dockerfile"]),k=await A(n,[".env.example","env.example","config/env.example"]),z=await A(n,[".github/workflows/ci.yml",".github/workflows/ci.yaml",".github/workflows/main.yml",".github/workflows/build.yml",".github/workflows/test.yml",".github/workflows/deploy.yml",".gitlab-ci.yml",".circleci/config.yml","azure-pipelines.yml","bitbucket-pipelines.yml","cloudbuild.yaml"]),P=await V(n),u=[];return r.key==="unknown"&&u.push(f("project.stack.unknown","fail",l,"Project stack is unknown","Workspai cannot confidently classify this backend project.","Add .workspai/project.json metadata or import the project with `workspai import`.")),m||u.push(f("project.marker.missing","warn",l,"Workspai marker is missing","The project can be detected by files, but it is not registered with Workspai metadata.","Run `workspai import <path>` from a workspace or create the project through Workspai.")),d||u.push(f("project.tests.missing","warn",l,"Test entrypoint is missing","No common test folder, config, or package test script was found.","Add a test command so `workspai workspace run test --affected` can gate changes.")),k||u.push(f("project.env.example.missing","info",l,"Environment example is missing","No .env.example or env.example file was found.","Add an env example for onboarding and CI secret documentation.")),z||u.push(f("project.ci.missing","warn",l,"Continuous integration is missing","No recognized CI/CD configuration file was detected for this project.","Add CI configuration so tests and checks run automatically for every change.")),P||u.push(f("project.health.missing","info",l,"Health or readiness probe is missing","The project has no obvious health or readiness endpoint to support automated deployment and runtime checks.","Add a simple health endpoint and document it for readiness gates and observability.")),h$1||u.push(f("project.container.missing","info",l,"Container recipe is missing","No Dockerfile was found for this project.","Add a Dockerfile when the service is intended for containerized deployment.")),{name:p.basename(n),path:n,relativePath:i$1,runtime:a,framework:r.key,confidence:r.confidence,supportTier:r.supportTier,hasRapidKitMarker:m,hasTests:d,hasDockerfile:h$1,hasEnvExample:k,hasCiConfig:z,hasHealthEndpoint:P,scripts:g,findings:u,score:Q(u)}}function Y(e){return e.name.toLowerCase()}async function Z(e){let n=new Map(e.map(s=>[Y(s),s])),t=[];for(let s of e){let a=await x(p.join(s.path,"package.json")),i={...a?.dependencies??{},...a?.devDependencies??{},...a?.peerDependencies??{}};for(let g of Object.keys(i)){let m=g.replace(/^@[^/]+\//,"").toLowerCase(),d=n.get(m);d&&d.relativePath!==s.relativePath&&t.push({from:s.relativePath,to:d.relativePath,kind:"package"});}let l=await J(p.join(s.path,"pyproject.toml"));for(let g of e)g.relativePath!==s.relativePath&&l.includes(g.name)&&t.push({from:s.relativePath,to:g.relativePath,kind:"workspace-reference"});}let r=new Set;return t.filter(s=>{let a=`${s.from}\0${s.to}\0${s.kind}`;return r.has(a)?false:(r.add(a),true)})}function ee(e,n){let t=new Map;for(let r of e)t.set(r.relativePath,{project:r.relativePath,directDependents:0,directDependencies:0});for(let r of n){let s=t.get(r.from),a=t.get(r.to);s&&(s.directDependencies+=1),a&&(a.directDependents+=1);}return Array.from(t.values()).sort((r,s)=>s.directDependents-r.directDependents||s.directDependencies-r.directDependencies)}async function ne(e){let n=await T(o$1(e,"workspace.json"));return typeof n?.profile=="string"?n.profile:null}function te(e){return {fail:e.filter(n=>n.severity==="fail").length,warn:e.filter(n=>n.severity==="warn").length,info:e.filter(n=>n.severity==="info").length}}function re(e){if(e.projectCount===0)return e.workspaceDetected?["Add your first project: npx workspai create project <name> --kit <kit>","Import an existing service: npx workspai import <path>"]:["Create a Workspai workspace: npx workspai create workspace my-workspace --profile polyglot","Import an existing service: npx workspai import ../service"];let n=[];return e.findings.some(t=>t.id==="workspace.marker.missing")&&n.push("Initialize workspace metadata with `workspai bootstrap --profile polyglot`."),e.findings.some(t=>t.id==="project.marker.missing")&&n.push("Register detected projects with `workspai import <path>` or recreate them via `workspai create project`."),e.findings.some(t=>t.id==="project.tests.missing")&&n.push("Add test entrypoints, then gate changes with `workspai workspace run test --affected --strict`."),e.findings.some(t=>t.id==="project.ci.missing")&&n.push("Add CI/CD configuration to catch regressions early and make workspace health checks actionable."),e.findings.some(t=>t.id==="project.health.missing")&&n.push("Add a health/readiness endpoint so runtime probes and deployment checks can verify service health."),e.hasGraph||n.push("Create `.workspai/workspace-dependency-graph.json` or use analyze output as the first graph seed."),n.push("Run `workspai autopilot release --mode audit --json` before release."),Array.from(new Set(n))}async function fe(e$2={}){let n=p.resolve(e$2.workspacePath||process.cwd());if(!await D(n))throw new Error(`Workspace path does not exist: ${n}`);let t=H(n)??n,r=f$1(t),s=await ne(t),a=await B(t),i=await Promise.all(a.map(c=>X(t,c))),l=await Z(i),g=ee(i,l),m=[];r||m.push(f("workspace.marker.missing","warn",".","Workspace metadata is missing","The directory can be analyzed, but it is not a registered Workspai workspace.","Run `workspai create workspace` or `workspai bootstrap --profile polyglot` in a workspace root.")),i.length===0&&m.push(f("workspace.projects.missing","warn",".","No backend projects detected","Workspai did not find runtime markers or project metadata under this root.","Create a project with `workspai create project` or import one with `workspai import <path>`."));let d=[...m,...i.flatMap(c=>c.findings)],h=te(d),k={};for(let c of i)k[c.runtime]=(k[c.runtime]||0)+1;let z=i.length>0?Math.round(i.reduce((c,y)=>c+y.score,0)/i.length):0,P=m.reduce((c,y)=>c+(y.severity==="fail"?20:y.severity==="warn"?8:2),0),u=Math.max(0,z-P),O=i.length===0&&h.fail===0&&d.length>0&&d.every(c=>c.id==="workspace.projects.missing"&&c.severity==="warn"),N=h.fail>0||e$2.strict&&h.warn>0&&!O?"blocked":h.warn>0?"needs-attention":"ready",w={schemaVersion:"rapidkit-analyze-v1",generatedAt:new Date().toISOString(),workspacePath:t,workspaceDetected:r,profile:s,summary:{score:u,verdict:N,projectCount:i.length,runtimeCount:Object.keys(k).length,findings:h},runtimes:k,projects:i,dependencyGraph:{status:l.length>0?"generated":"empty",edges:l,topImpactedProjects:g.slice(0,5)},findings:d,nextActions:re({findings:d,projectCount:i.length,hasGraph:l.length>0,workspaceDetected:r}),enterpriseControls:{jsonReady:true,ciGateCommand:"workspai analyze --json --strict",releaseGateCommand:"workspai autopilot release --mode enforce --json",evidencePath:".workspai/reports/analyze-last-run.json"}};if(e$2.output&&(await b.promises.mkdir(p.dirname(p.resolve(e$2.output)),{recursive:true}),await b.promises.writeFile(p.resolve(e$2.output),`${JSON.stringify(w,null,2)}
2
+ `)),!e$2.output&&r){let c=f$2(w,{commandId:"workspaceAnalyze",exitCode:w.summary.verdict==="blocked"?2:w.summary.verdict==="needs-attention"?1:0,generatedAt:w.generatedAt,blockers:w.findings.filter(y=>y.severity==="fail").map(y=>y.title).slice(0,12),runId:e()});await e$1(t,".workspai/reports/analyze-last-run.json",`${JSON.stringify(c,null,2)}
3
+ `);}return w}function he(e){let n=e.summary.verdict==="ready"?o.green:e.summary.verdict==="needs-attention"?o.yellow:o.red;if(console.log(o.bold(`
4
+ Workspai Workspace Analysis
5
+ `)),console.log(o.cyan("Workspace:"),e.workspacePath),console.log(o.cyan("Profile:"),e.profile||"not configured"),console.log(o.cyan("Score:"),`${e.summary.score}/100`),console.log(o.cyan("Verdict:"),n(e.summary.verdict)),console.log(o.gray(`Projects: ${e.summary.projectCount}, runtimes: ${e.summary.runtimeCount}, findings: ${e.summary.findings.fail} fail / ${e.summary.findings.warn} warn / ${e.summary.findings.info} info`)),e.projects.length>0){console.log(o.bold(`
6
+ Projects`));for(let t of e.projects){let r=t.score>=85?o.green("pass"):t.score>=65?o.yellow("watch"):o.red("risk");console.log(` ${t.relativePath} ${o.gray(`${t.runtime}/${t.framework}`)} ${r} ${t.score}/100`);}}if(e.dependencyGraph.status==="generated"&&(console.log(o.bold(`
7
+ Dependency Graph`)),console.log(o.gray(` edges: ${e.dependencyGraph.edges.length}`)),e.dependencyGraph.topImpactedProjects.length>0)){console.log(o.gray(" Top impacted projects:"));for(let t of e.dependencyGraph.topImpactedProjects.slice(0,3))console.log(` ${t.project} (${t.directDependents} dependents, ${t.directDependencies} dependencies)`);}if(e.findings.length>0){console.log(o.bold(`
8
+ Top Findings`));for(let t of e.findings.slice(0,8)){let r=t.severity==="fail"?o.red:t.severity==="warn"?o.yellow:o.gray;console.log(` ${r(t.severity.toUpperCase())} ${t.target}: ${t.title}`),console.log(o.gray(` ${t.remediation}`));}}console.log(o.bold(`
9
+ Next Actions`));for(let t of e.nextActions.slice(0,5))console.log(o.gray(` - ${t}`));console.log();}export{fe as a,he as b};
@@ -0,0 +1,7 @@
1
+ import {a as a$1}from'./chunk-WU4ZRRA5.js';import {a as a$3}from'./chunk-22DT744Z.js';import {a as a$2,e}from'./chunk-753LOKFZ.js';import {c,a,d}from'./chunk-NAAQMSO3.js';import l from'chalk';import ee from'fs';import b from'path';import {execa}from'execa';var O="autopilot-release-last-run.json",K="autopilot-release.json";function $(s){try{return JSON.parse(s)}catch{return null}}function ke(s){let e=b.resolve(s),a=a$3(e);if(!a)throw new Error("No Workspai workspace found in current directory or parents");return a}async function S(s,e){let a=process.argv[1];if(!a)return {exitCode:1,stdout:"",stderr:"RapidKit entrypoint is unavailable for autopilot execution.",crashed:true};try{let o=await execa(process.execPath,[a,...s],{cwd:e,reject:false,env:{...process.env,RAPIDKIT_AUTOPILOT_CHILD:"1"}});return {exitCode:Number(o.exitCode??1),stdout:o.stdout,stderr:o.stderr,crashed:false}}catch(o){return {exitCode:1,stdout:"",stderr:o instanceof Error?o.message:String(o),crashed:true}}}function te(s){let e=s.toLowerCase();return e==="pass"?"pass":e==="warn"?"warn":e==="fail"?"fail":"warn"}function se(s){return s.summary.failed>0||s.gates.results.some(e=>e.status==="fail")?"fail":s.gates.results.some(e=>e.status==="warn")?"warn":"pass"}function he(s){let e=s.filter(o=>o.status!=="skipped");if(e.length===0)return 100;let a=e.reduce((o,t)=>t.status==="pass"?o+1:t.status==="warn"?o+.6:o,0);return Math.round(a/e.length*100)}function ye(s){return s.executionError?["Re-run: npx workspai autopilot release --mode audit --json","Inspect .workspai/reports/autopilot-release-last-run.json for execution failure details"]:s.blockers.length>0?["Run: npx workspai doctor workspace --plan","Run: npx workspai readiness --json --strict","Run: npx workspai workspace run test --affected --strict"]:s.hasWarnings&&s.mode!=="enforce"?["Review warning-level findings in autopilot report","Optionally run: npx workspai autopilot release --mode safe-fix"]:["Workspace is release-ready based on current autopilot policy"]}async function Re(s,e){await ee.promises.mkdir(b.dirname(s),{recursive:true}),await ee.promises.writeFile(s,`${JSON.stringify(e,null,2)}
2
+ `,"utf-8");}async function De(s){let e$1=ke(s.workspacePath),a$3=s.mode,o=[],t=[],I,G,C,V,H,q=0,f=false,T=0,L=0,D=-1,N=-1,c$1="skipped",u="skipped",re=a$3==="enforce"?["doctor","workspace","--json","--strict"]:["doctor","workspace","--json","--ci"];if(s.skipPipelineStages)o.push({name:"doctor-workspace",status:"skipped",durationMs:0,summary:"doctor stage skipped (pipeline already executed)"},{name:"analyze",status:"skipped",durationMs:0,summary:"analyze stage skipped (pipeline already executed)"},{name:"readiness",status:"skipped",durationMs:0,summary:"readiness stage skipped (pipeline already executed)"});else {let r=Date.now(),i=await S([...re],e$1),m=Date.now()-r;if(c$1="pass",i.crashed)c$1="fail",f=true,t.push(`doctor workspace execution error: ${i.stderr||"unknown error"}`);else if(i.exitCode===1)c$1="fail",t.push("doctor workspace command failed or reported errors");else if(i.exitCode===2)c$1="warn",t.push("doctor workspace reported warnings");else if(i.exitCode!==0)c$1="fail",t.push("doctor workspace command failed");else {let p=$(i.stdout),j=p&&p.healthScore&&typeof p.healthScore=="object"?p.healthScore:{},h=Number(j.errors??0),E=Number(j.warnings??0);Number.isFinite(h)&&h>0?(c$1="fail",t.push(`doctor workspace reports ${h} error(s)`)):Number.isFinite(E)&&E>0&&(c$1="warn");}D=o.push({name:"doctor-workspace",status:c$1,durationMs:m,summary:c$1==="pass"?"doctor workspace passed":c$1==="warn"?"doctor workspace reported warnings":"doctor workspace reported errors"})-1,a$3==="enforce"&&c$1==="warn"&&t.push("doctor workspace reported warnings under enforce mode");let w=Date.now(),g=await S(["analyze","--json"],e$1),v=Date.now()-w;G=await c(e$1,".workspai/reports/analyze-last-run.json")??a(e$1,".workspai/reports/analyze-last-run.json");let n="pass";if(g.crashed)n="fail",f=true,t.push(`analyze execution error: ${g.stderr||"unknown error"}`);else if(g.exitCode!==0)n=g.exitCode===2?"warn":"fail",t.push(g.exitCode===2?"analyze reported needs-attention verdict":"analyze command failed or reported blocked verdict");else {let p=$(g.stdout),j=p&&p.summary&&typeof p.summary=="object"?p.summary:{},h=String(j.verdict??"ready");h==="blocked"?(n="fail",t.push("analyze reported blocked verdict")):h==="needs-attention"&&(n="warn");}o.push({name:"analyze",status:n,durationMs:v,summary:n==="pass"?"analyze passed":n==="warn"?"analyze reported needs-attention":"analyze reported blocked verdict"}),a$3==="enforce"&&n==="warn"&&t.push("analyze reported warnings under enforce mode");let P=Date.now(),k=await S(["readiness","--json"],e$1),y=Date.now()-P;if(u="fail",k.crashed)u="fail",f=true,t.push(`readiness execution error: ${k.stderr||"unknown error"}`);else if(k.exitCode!==0)u="fail",t.push("readiness command failed");else {let p=$(k.stdout),j=String(p?.overallStatus??"fail");if(u=te(j),typeof p?.evidencePath=="string"&&p.evidencePath.trim().length>0&&(I=p.evidencePath),u==="fail"){let h=Array.isArray(p?.blockingReasons)?p?.blockingReasons.filter(E=>typeof E=="string"):[];h.length>0?t.push(...h.map(E=>`readiness: ${E}`)):t.push("readiness overall status is fail");}}N=o.push({name:"readiness",status:u,durationMs:y,summary:`readiness overall status is ${u}`})-1,a$3==="enforce"&&u==="warn"&&t.push("readiness reported warnings under enforce mode");}let oe=Date.now(),W=await S(["doctor","workspace","--plan","--json"],e$1),ae=Date.now()-oe,R="warn";if(W.crashed)R="fail",f=true,t.push(`doctor remediation plan execution error: ${W.stderr||"unknown error"}`);else if(W.exitCode!==0)R="fail",t.push("doctor remediation plan command failed");else {let r=$(W.stdout),i=r&&r.remediationPlan&&typeof r.remediationPlan=="object"?r.remediationPlan:null,m=Number(i?.totalSteps??0),w=Number(i?.executableSteps??0);Number.isFinite(m)&&m>0&&(T=m),Number.isFinite(w)&&w>0&&(L=w),Number.isFinite(m)&&m===0?R="pass":R="warn";}if(o.push({name:"remediation-plan",status:R,durationMs:ae,summary:R==="pass"?"no remediation steps required":"remediation steps available"}),a$3==="enforce"&&R==="warn"&&t.push("remediation plan has pending steps under enforce mode"),a$3==="safe-fix"){let r=Date.now(),i=await S(["doctor","workspace","--apply"],e$1),m=Date.now()-r,w=i.crashed||i.exitCode!==0?"fail":"pass";if(i.crashed)f=true,t.push(`doctor remediation apply execution error: ${i.stderr||"unknown error"}`);else if(w==="fail")t.push("doctor remediation apply failed");else {q=L>0?L:T>0?T:1;let g=await S(["doctor","workspace","--json"],e$1);if(g.crashed)c$1="fail",f=true,t.push(`post-apply doctor execution error: ${g.stderr||"unknown error"}`);else if(g.exitCode!==0)c$1="fail",t.push("post-apply doctor workspace command failed");else {let n=$(g.stdout),P=n&&n.healthScore&&typeof n.healthScore=="object"?n.healthScore:{},k=Number(P.errors??0),y=Number(P.warnings??0);Number.isFinite(k)&&k>0?(c$1="fail",t.push(`post-apply doctor reports ${k} error(s)`)):Number.isFinite(y)&&y>0?c$1="warn":c$1="pass";}D>=0&&(o[D].status=c$1,o[D].summary=`doctor workspace post-apply status is ${c$1}`);let v=await S(["readiness","--json"],e$1);if(v.crashed)u="fail",f=true,t.push(`post-apply readiness execution error: ${v.stderr||"unknown error"}`);else if(v.exitCode!==0)u="fail",t.push("post-apply readiness command failed");else {let n=$(v.stdout),P=String(n?.overallStatus??"fail");if(u=te(P),typeof n?.evidencePath=="string"&&n.evidencePath.trim().length>0&&(I=n.evidencePath),u==="fail"){let k=Array.isArray(n?.blockingReasons)?n?.blockingReasons.filter(y=>typeof y=="string"):[];k.length>0?t.push(...k.map(y=>`post-apply readiness: ${y}`)):t.push("post-apply readiness overall status is fail");}}N>=0&&(o[N].status=u,o[N].summary=`readiness post-apply overall status is ${u}`);}o.push({name:"remediation-apply",status:w,durationMs:m,summary:w==="pass"?"safe remediation apply completed":"safe remediation apply failed"});}else o.push({name:"remediation-apply",status:"skipped",durationMs:0,summary:"remediation apply is skipped for this mode"});let ne=Date.now(),x="pass",A="workspace test/build completed for selected projects";try{let r=await a$1({workspacePath:e$1,stage:"test",affected:true,since:s.since,parallel:s.parallel,maxWorkers:s.maxWorkers,strict:true,json:true,enforceGates:false});C=a(e$1,b.join(".workspai","reports",a$2)),await e(e$1,r),V=C;let i=se(r);if(i==="fail")x="fail",A="workspace test stage failed for selected projects",t.push("workspace run test failed for selected projects");else {i==="warn"&&(x="warn",A="workspace test stage completed with warnings",a$3==="enforce"&&t.push("workspace run test reported warnings under enforce mode"));let m=await a$1({workspacePath:e$1,stage:"build",affected:true,since:s.since,parallel:s.parallel,maxWorkers:s.maxWorkers,strict:true,json:true,enforceGates:false});await e(e$1,m),H=C;let w=se(m);w==="fail"?(x="fail",A="workspace build stage failed for selected projects",t.push("workspace run build failed for selected projects")):w==="warn"&&(x="warn",A="workspace test/build completed with warnings",a$3==="enforce"&&t.push("workspace run test/build reported warnings under enforce mode"));}}catch(r){x="fail",A="workspace test/build orchestration failed",f=true,t.push(`workspace run orchestration error: ${r instanceof Error?r.message:String(r)}`);}let ie=Date.now()-ne;o.push({name:"workspace-run-test-build",status:x,durationMs:ie,summary:A});let z=o.filter(r=>r.status==="warn").length,le=o.filter(r=>r.status==="fail").length,_=a$3==="enforce"?o.some(r=>r.status==="warn"||r.status==="fail"):le>0,M=[...new Set(t)],ce=f||_?Math.max(1,M.length):0,pe=he(o),ue=f||_?"blocked":z>0?"partial":"approved",de=f?3:_?1:z>0?2:0,fe=ye({mode:a$3,executionError:f,blockers:M,hasWarnings:z>0}),Q=a(e$1,".workspai/reports"),me=b.join(Q,O),we=b.join(Q,K),d$1={schemaVersion:"autopilot-release-v1",generatedAt:new Date().toISOString(),workspacePath:e$1,mode:a$3,summary:{releaseScore:pe,verdict:ue,blockers:ce,warnings:z,safeFixesApplied:q,manualActions:M.length,exitCode:de},stages:o,blockingReasons:M,nextActions:fe,artifacts:{reportPath:me,aliasEvidencePath:we,analyzeEvidencePath:G,readinessEvidencePath:I,workspaceRunEvidencePath:C,workspaceRunTestPath:V,workspaceRunBuildPath:H},enterpriseControls:{jsonReady:true,evidencePath:`.workspai/reports/${O}`,aliasEvidencePath:`.workspai/reports/${K}`}};if(await d(e$1,`.workspai/reports/${O}`,d$1),await d(e$1,`.workspai/reports/${K}`,d$1),s.output&&await Re(b.resolve(s.output),d$1),!s.json){console.log(l.bold.cyan(`
3
+ \u{1F680} Workspai Autopilot Release
4
+ `)),console.log(l.bold(`Workspace: ${l.cyan(b.basename(e$1))}`)),console.log(l.gray(`Path: ${e$1}`)),console.log(l.white(`Mode: ${a$3}`)),console.log(l.white(`Verdict: ${d$1.summary.verdict==="approved"?l.green("approved"):d$1.summary.verdict==="partial"?l.yellow("partial"):l.red("blocked")}`)),console.log(l.white(`Release score: ${d$1.summary.releaseScore}`));for(let r of d$1.stages){let i=r.status==="pass"?l.green("PASS"):r.status==="warn"?l.yellow("WARN"):r.status==="skipped"?l.gray("SKIP"):l.red("FAIL");console.log(` - ${r.name}: ${i} ${r.summary} (${r.durationMs}ms)`);}if(d$1.blockingReasons.length>0){console.log(l.bold.red(`
5
+ Blocking reasons:`));for(let r of d$1.blockingReasons)console.log(l.red(` - ${r}`));}if(d$1.nextActions.length>0){console.log(l.bold(`
6
+ Next actions:`));for(let r of d$1.nextActions)console.log(l.gray(` - ${r}`));}console.log(l.gray(`
7
+ Report: ${d$1.artifacts.reportPath}`));}return d$1}export{O as a,K as b,De as c};
@@ -0,0 +1 @@
1
+ function C(s){let o=s.slice(0,-1);if(o.length===0)return s;let t=0;for(let c=1;c<o.length;c+=1)o[c].localeCompare(o[t])<0&&(t=c);let i=[...o.slice(t),...o.slice(0,t)];return i.push(i[0]),i}function G(s,o){let g=new Map;for(let e of s)g.set(e,0);let a=[],d=new Set,n=e=>{let r=[{id:e,index:0}];g.set(e,1);let h=[e];for(;r.length>0;){let l=r[r.length-1],f=o.get(l.id)??[];if(l.index>=f.length){g.set(l.id,2),r.pop(),h.pop();continue}let p=f[l.index];l.index+=1;let u=g.get(p)??0;if(u===1){let m=h.lastIndexOf(p);if(m>=0){let y=C([...h.slice(m),p]),k=y.join(">");d.has(k)||(d.add(k),a.push(y));}continue}u===0&&(g.set(p,1),r.push({id:p,index:0}),h.push(p));}};for(let e of s)g.get(e)===0&&n(e);return a.sort((e,r)=>e.join(">").localeCompare(r.join(">")))}function x(s){let o=[...new Set(s.nodes.map(n=>n.id))].sort((n,e)=>n.localeCompare(e)),t=new Set(o),i=[],c=new Map,g=new Set;for(let n of o)c.set(n,[]);for(let n of s.edges){let e=!t.has(n.from),r=!t.has(n.to);if(e||r){i.push({from:n.from,to:n.to,kind:n.kind,missing:e&&r?"both":e?"from":"to"});continue}c.get(n.from)?.push(n.to),g.add(n.from),g.add(n.to);}for(let n of c.values())n.sort((e,r)=>e.localeCompare(r));let a=G(o,c),d=o.filter(n=>!g.has(n));return i.sort((n,e)=>n.from.localeCompare(e.from)||n.to.localeCompare(e.to)||n.kind.localeCompare(e.kind)),{ok:a.length===0&&i.length===0,cycles:a,danglingEdges:i,orphans:d,stats:{nodeCount:o.length,edgeCount:s.edges.length,cycleCount:a.length,danglingCount:i.length,orphanCount:d.length}}}function I(s){let o=[];for(let t of s.cycles)o.push(`graph.integrity.cycle: ${t.join(" -> ")}`);for(let t of s.danglingEdges)o.push(`graph.integrity.dangling: ${t.from} -> ${t.to} (${t.kind}); missing ${t.missing} endpoint.`);return o}export{x as a,I as b};
@@ -0,0 +1,13 @@
1
+ import {c as c$1}from'./chunk-Y45WZR5N.js';import {e,g,c as c$2}from'./chunk-LZQNVH7D.js';import {q as q$1}from'./chunk-5XATWNME.js';import T from'validate-npm-package-name';import s from'path';import {spawn}from'child_process';import i from'chalk';import m from'fs-extra';var c=class extends Error{constructor(n,r,a){super(n);this.code=r;this.details=a;this.name="RapidKitError",Error.captureStackTrace(this,this.constructor);}code;details},I=class extends c{constructor(t,n){let r=n?`Python ${t}+ required, found ${n}`:`Python ${t}+ not found`;super(r,"PYTHON_NOT_FOUND","Please install Python from https://www.python.org/downloads/");}},$=class extends c{constructor(){super("Poetry is not installed","POETRY_NOT_FOUND","Install Poetry from https://python-poetry.org/docs/#installation");}},E=class extends c{constructor(){super("pipx is not installed","PIPX_NOT_FOUND","Install pipx from https://pypa.github.io/pipx/installation/");}},D=class extends c{constructor(t){super(`Directory "${t}" already exists`,"DIRECTORY_EXISTS","Please choose a different name or remove the existing directory");}},d=class extends c{constructor(t,n){super(`Invalid project name: "${t}"`,"INVALID_PROJECT_NAME",n);}},_=class extends c{constructor(t,n){let r=`Installation failed at: ${t}`,a=`${n.message}
2
+
3
+ Troubleshooting:
4
+ - Check your internet connection
5
+ - Verify Python/Poetry installation
6
+ - Try running with --debug flag for more details`;super(r,"INSTALLATION_ERROR",a);}},b=class extends c{constructor(){super("RapidKit Python package is not yet available on PyPI","RAPIDKIT_NOT_AVAILABLE",`Available options:
7
+ 1. Install Python 3.10+ and retry the same command
8
+ 2. Use the core workflow: npx workspai create workspace <name>
9
+ 3. Offline fallback (limited): npx workspai create project fastapi.standard <name> --output .
10
+
11
+ Legacy: set RAPIDKIT_SHOW_LEGACY=1 to reveal template-mode flags in help.`);}};function O(e){let t=T(e);if(!t.validForNewPackages){let r=t.errors||[],a=t.warnings||[],o=[...r,...a];throw new d(e,`NPM validation failed: ${o.join(", ")}`)}if(!/^[a-z][a-z0-9_-]*$/.test(e))throw new d(e,"Must start with a lowercase letter and contain only lowercase letters, numbers, hyphens, and underscores");if(["test","tests","src","dist","build","lib","python","pip","poetry","node","npm","rapidkit","rapidkit"].includes(e.toLowerCase()))throw new d(e,`"${e}" is a reserved name. Please choose a different name.`);if(e.length<2)throw new d(e,"Name must be at least 2 characters long");if(e.length>214)throw new d(e,"Name must be less than 214 characters");return true}function de(e){let t=L(e.workspacePath,e.result.projectPath)?"imported":"adopted";return {name:e.result.projectName,path:e.result.projectPath,relativePath:V(e.workspacePath,e.result.projectPath),relationship:t,stack:e.result.definition.framework,runtime:"node",framework:e.result.definition.framework,frameworkDisplayName:e.result.definition.displayName,supportTier:"extended",moduleSupport:false,confidence:"high",source:t==="adopted"?"adopted-local":"local-folder",importedAt:e.importedAt??new Date().toISOString()}}function L(e,t){let n=s.relative(s.resolve(e),s.resolve(t));return n===""||n.length>0&&!n.startsWith("..")&&!s.isAbsolute(n)}function V(e,t){return (s.relative(e,t)||".").split(s.sep).join("/")}var G=[{id:"nextjs",kitId:"frontend.nextjs",aliases:["frontend.nextjs","next","nextjs","next.js"],displayName:"Next.js",framework:"nextjs",defaultPort:3e3,commandDisplay:e=>`npx create-next-app@latest ${e}`,commandExec:(e,t)=>({command:"npx",args:["--yes","create-next-app@latest",e,"--yes",...t.skipGit?["--disable-git"]:[],...t.skipInstall?["--skip-install"]:[]]})},{id:"remix",kitId:"frontend.remix",aliases:["frontend.remix","remix","remix-run","react-router"],displayName:"React Router",framework:"remix",defaultPort:5173,commandDisplay:e=>`npx create-react-router@latest ${e}`,commandExec:(e,t)=>({command:"npx",args:["--yes","create-react-router@latest",e,"--yes",...t.skipInstall?["--no-install"]:["--install"],"--no-git-init"]})},{id:"vite-react",kitId:"frontend.vite-react",aliases:["frontend.vite-react","vite-react","react","vite.react"],displayName:"React + Vite",framework:"react",defaultPort:5173,commandDisplay:e=>`npm create vite@latest ${e} -- --template react-ts`,commandExec:e=>({command:"npm",args:["create","vite@latest",e,"--","--template","react-ts","--no-interactive"]})},{id:"vite-vue",kitId:"frontend.vite-vue",aliases:["frontend.vite-vue","vite-vue","vue","vite.vue"],displayName:"Vue + Vite",framework:"vue",defaultPort:5173,commandDisplay:e=>`npm create vite@latest ${e} -- --template vue-ts`,commandExec:e=>({command:"npm",args:["create","vite@latest",e,"--","--template","vue-ts","--no-interactive"]})},{id:"vite-svelte",kitId:"frontend.vite-svelte",aliases:["frontend.vite-svelte","vite-svelte","svelte","vite.svelte"],displayName:"Svelte + Vite",framework:"svelte",defaultPort:5173,commandDisplay:e=>`npm create vite@latest ${e} -- --template svelte-ts`,commandExec:e=>({command:"npm",args:["create","vite@latest",e,"--","--template","svelte-ts","--no-interactive"]})},{id:"vite-solid",kitId:"frontend.vite-solid",aliases:["frontend.vite-solid","vite-solid","solid","solidjs","vite.solid"],displayName:"Solid + Vite",framework:"solid",defaultPort:5173,commandDisplay:e=>`npm create vite@latest ${e} -- --template solid-ts`,commandExec:e=>({command:"npm",args:["create","vite@latest",e,"--","--template","solid-ts","--no-interactive"]})},{id:"vite-vanilla",kitId:"frontend.vite-vanilla",aliases:["frontend.vite-vanilla","vite","vanilla","vite-vanilla"],displayName:"Vite",framework:"vite",defaultPort:5173,commandDisplay:e=>`npm create vite@latest ${e} -- --template vanilla-ts`,commandExec:e=>({command:"npm",args:["create","vite@latest",e,"--","--template","vanilla-ts","--no-interactive"]})},{id:"nuxt",kitId:"frontend.nuxt",aliases:["frontend.nuxt","nuxt","nuxtjs","nuxt.js"],displayName:"Nuxt",framework:"nuxt",defaultPort:3e3,commandDisplay:(e,t)=>`npx create-nuxt@latest ${e} --template minimal --packageManager npm --gitInit ${t?.skipGit?"false":"true"}${t?.skipInstall?" --no-install":""}`,commandExec:(e,t)=>({command:"npx",args:["--yes","create-nuxt@latest",e,"--template","minimal","--packageManager","npm","--gitInit",t.skipGit?"false":"true",...t.skipInstall?["--no-install"]:[]]})},{id:"angular",kitId:"frontend.angular",aliases:["frontend.angular","angular","ng"],displayName:"Angular",framework:"angular",defaultPort:4200,minNodeMajor:18,minNodeMessage:"Angular scaffolding requires Node.js 18.19+ or 20.11+. Upgrade Node, or choose another frontend kit.",commandDisplay:e=>`npx @angular/cli@19 new ${e}`,commandExec:(e,t)=>({command:"npx",args:["--yes","@angular/cli@19","new",e,"--defaults","--skip-git",...t.skipInstall?["--skip-install"]:[]]})},{id:"astro",kitId:"frontend.astro",aliases:["frontend.astro","astro"],displayName:"Astro",framework:"astro",defaultPort:4321,commandDisplay:e=>`npm create astro@4 ${e}`,commandExec:(e,t)=>({command:"npm",args:["create","astro@4",e,"--","--yes",...t.skipInstall?["--no-install"]:[],...t.skipGit?["--no-git"]:[]]})},{id:"sveltekit",kitId:"frontend.sveltekit",aliases:["frontend.sveltekit","sveltekit","svelte-kit"],displayName:"SvelteKit",framework:"sveltekit",defaultPort:5173,commandDisplay:e=>`npx sv@latest create ${e}`,commandExec:(e,t)=>({command:"npx",args:["--yes","sv@latest","create",e,"--template","minimal","--types","ts","--no-add-ons",...t.skipInstall?["--no-install"]:["--install","npm"]]})}],x=new Map;for(let e of G){x.set(e.id,e),x.set(e.kitId,e);for(let t of e.aliases)x.set(t.toLowerCase(),e);}function me(){return [...G]}function u(e){return e?x.get(e.trim().toLowerCase())??null:null}function pe(e){return !!u(e)}function fe(e){if(e[0]!=="create"||e[1]!=="frontend")return null;let t=e[2],n=e[3],r=e.slice(4),a=u(t);return a?["create","project",a.kitId,n??"",...r].filter(Boolean):["create","project",`frontend.${t??""}`,n??"",...r].filter(Boolean)}function A(e,t){return `workspai create project ${u(e)?.id??e.replace(/^frontend\./,"")} ${t}`}function C(e,t){return `npx ${A(e,t)}`}function U(e){let t=u(e);return t?`${A(t.id,"<name>")} [--output <dir>] [--skip-install] [--dry-run]`:"workspai create project <nextjs|remix|vite-react|vite-vue|vite-svelte|vite-solid|vite-vanilla|nuxt|angular|astro|sveltekit> <name> [--output <dir>] [--skip-install] [--dry-run]"}async function ge(e){let t=e.args;if(t[0]!=="create"||t[1]!=="project")throw new Error("Frontend create expects normalized args: create project <frontend.kit> <name>");let n=u(t[2]);if(!n)throw new Error(`Unknown frontend generator: ${t[2]??"(missing)"}`);let r=t[3];if(!r)throw new Error(`Usage: ${U(n.id)}`);O(r),B(n);let a=q(t,"--output")||process.cwd(),o=s.resolve(a,r),p=e.dryRun===true||t.includes("--dry-run"),g=t.includes("--skip-install"),f=t.includes("--skip-git")||t.includes("--no-git"),l=n.commandExec(r,{skipGit:f,skipInstall:g}),k=n.commandDisplay(r,{skipGit:f,skipInstall:g});if(await m.pathExists(o))throw new Error(`Directory "${o}" already exists`);if(p)return Y({definition:n,projectName:r,projectPath:o,commandPlan:l}),{definition:n,projectName:r,projectPath:o,dryRun:p,commandDisplay:k,commandExec:[l.command,...l.args]};await m.ensureDir(s.dirname(o));let v=await S(l.command,l.args,s.dirname(o)),y=await J(o);if(v!==0&&!y)throw new Error(`Official ${n.displayName} generator failed with exit code ${v}`);return v!==0&&y&&console.log(i.yellow(`\u26A0\uFE0F Official ${n.displayName} generator exited with code ${v}, but the scaffold looks complete. Continuing Workspai project setup...`)),f||await K(o),await W({definition:n,projectName:r,projectPath:o,commandDisplay:k,commandExec:[l.command,...l.args],skipGit:f,skipInstall:g}),console.log(i.green(`\u2705 ${n.displayName} project created at ${o}`)),console.log(i.gray(` Display command: ${C(n.id,r)}`)),console.log(i.gray(" Next: cd "+r+" && npx workspai dev")),{definition:n,projectName:r,projectPath:o,dryRun:p,commandDisplay:k,commandExec:[l.command,...l.args]}}async function W(e){let t=new Date().toISOString(),n=await c$1(),r={schema_version:"1.0",name:e.projectName,slug:e.projectName,kind:"frontend",project_type:"frontend",runtime:"node",framework:e.definition.framework,framework_display_name:e.definition.displayName,kit_name:e.definition.kitId,kit:e.definition.kitId,engine:"npm",support_tier:"extended",module_support:false,modules:[],workspai_version:n,rapidkit_version:n,generated_by:"workspai",generated_at:t,frontend:{generator:e.definition.id,official_generator:true,default_port:e.definition.defaultPort,command_display:e.commandDisplay,command_exec:e.commandExec,skip_install:e.skipInstall,skip_git:e.skipGit},contracts:{owns:[],apis:[],publishes:[],consumes:[],dependsOn:[],env:[]}},a={project:e.projectName,runtime:"node",framework:e.definition.framework,kind:"frontend",source:"official-generator"},o={kind:"workspai.frontend_create",schema_version:"1.0",generated_at:t,project:{name:e.projectName,path:e.projectPath,kind:"frontend",runtime:"node",framework:e.definition.framework,framework_display_name:e.definition.displayName,kit_name:e.definition.kitId},generator:{id:e.definition.id,command_display:e.commandDisplay,command_exec:e.commandExec}};for(let[p,g]of [["project.json",r],["context.json",a],["frontend-create.json",o]]){let f=q$1(e.projectPath,p);await m.ensureDir(s.dirname(f)),await m.writeJson(f,g,{spaces:2});}}function Y(e){console.log(i.bold(`
12
+ Workspai frontend create plan: ${e.definition.displayName}`)),console.log(i.gray(`Project: ${e.projectName}`)),console.log(i.gray(`Target: ${e.projectPath}`)),console.log(i.gray(`Show: ${C(e.definition.id,e.projectName)}`)),console.log(i.gray(`Run: ${[e.commandPlan.command,...e.commandPlan.args].join(" ")}`)),console.log(i.gray(`Default: http://localhost:${e.definition.defaultPort}`));}function z(){let e=Number.parseInt(process.versions.node.split(".")[0]??"",10);return Number.isFinite(e)?e:0}function B(e){if(!(!e.minNodeMajor||z()>=e.minNodeMajor))throw new Error(e.minNodeMessage??`${e.displayName} requires Node.js ${e.minNodeMajor}+ (current: ${process.versions.node}).`)}async function J(e){if(!await m.pathExists(e))return false;let t=s.join(e,"package.json");return await m.pathExists(t)?true:(await m.readdir(e)).length>0}async function K(e){let t=s.join(e,".git");if(await m.pathExists(t))return;if(await S("git",["init"],e)===0){console.log(i.gray(" Git repository initialized."));return}console.log(i.yellow("\u26A0\uFE0F Git initialization was skipped or failed. You can run `git init` manually inside the project."));}async function S(e$1,t,n){let r=e(e$1);return await new Promise(a=>{let o=spawn(r.command,[...r.prefixArgs,...t],{cwd:n,stdio:"inherit",shell:c$2(),env:g()});o.on("close",p=>a(p??1)),o.on("error",()=>a(1));})}function q(e,t){let n=e.indexOf(t);if(n>=0&&n+1<e.length)return e[n+1];let r=e.find(a=>a.startsWith(`${t}=`));return r?r.slice(t.length+1):void 0}
13
+ export{c as a,I as b,$ as c,E as d,D as e,_ as f,b as g,O as h,de as i,me as j,u as k,pe as l,fe as m,U as n,ge as o};
@@ -0,0 +1,2 @@
1
+ var g="WORKSPAI_LOG_FORMAT",c="RAPIDKIT_LOG_FORMAT";function L(e=process.argv){let r=process.env[g]?.trim().toLowerCase()||process.env[c]?.trim().toLowerCase();if(r==="json")return "json";if(r==="text")return "text";for(let o=0;o<e.length;o+=1){let t=e[o];if(t==="--log-json")return "json";if(t==="--log-format"){let n=e[o+1]?.trim().toLowerCase();if(n==="json")return "json";if(n==="text")return "text"}if(t?.startsWith("--log-format=")){let n=t.slice(13).trim().toLowerCase();if(n==="json")return "json";if(n==="text")return "text"}}return "text"}function a(e=process.argv){return L(e)==="json"}var l="cli-log-event-v1";var m="unknown-run";function O(e){m=e;}function u(){return m}function p(e){return {schemaVersion:l,runId:u(),timestamp:new Date().toISOString(),level:e.level,event:e.event,component:e.component,message:e.message,...e.command?{command:e.command}:{},...e.metadata&&Object.keys(e.metadata).length>0?{metadata:f(e.metadata)}:{}}}function R(e){a()&&E(p(e));}function E(e){process.stderr.write(`${JSON.stringify(e)}
2
+ `);}function f(e){let r={};for(let[o,t]of Object.entries(e))if(t!==void 0){if(t instanceof Error){r[o]={name:t.name,message:t.message};continue}if(t===null||typeof t=="string"||typeof t=="number"||typeof t=="boolean"){r[o]=t;continue}if(Array.isArray(t)){r[o]=t.map(n=>typeof n=="string"||typeof n=="number"||typeof n=="boolean"?n:String(n));continue}r[o]=String(t);}return r}export{L as a,a as b,l as c,O as d,u as e,R as f,E as g};
@@ -0,0 +1 @@
1
+ function l(r,t){return `${r}\0${t}`}function f(r,t,s){let o=r.get(t);o?o.includes(s)||o.push(s):r.set(t,[s]);}function k(r){let t=new Map,s=new Map,o=new Map,i=new Set(r.nodes.map(e=>e.id));for(let e of r.edges){f(t,e.from,e.to),f(s,e.to,e.from);let n=l(e.from,e.to),d=o.get(n)??[];d.includes(e.kind)||d.push(e.kind),o.set(n,d);}for(let e of t.values())e.sort((n,d)=>n.localeCompare(d));for(let e of s.values())e.sort((n,d)=>n.localeCompare(d));for(let e of o.values())e.sort((n,d)=>n.localeCompare(d));return {forward:t,reverse:s,kindsByPair:o,nodeIds:i}}function v(r,t,s,o){let i=o==="dependents"?l(s,t):l(t,s),e=r.kindsByPair.get(i);return e&&e.length>0?e[0]:null}function m(r,t,s={}){let o=k(r);return x(o,t,s)}function x(r,t,s={}){let o=s.direction??"dependents",i=s.maxDepth??Number.POSITIVE_INFINITY,e=o==="dependents"?r.reverse:r.forward,n=new Map,d=[...new Set(t)].sort((a,p)=>a.localeCompare(p)),g=[];for(let a of d)n.has(a)||(n.set(a,{id:a,distance:0,path:[a],via:null}),g.push(a));let c=0;for(;c<g.length;){let a=g[c++],p=n.get(a);if(!p||p.distance>=i)continue;let h=e.get(a)??[];for(let u of h)n.has(u)||(n.set(u,{id:u,distance:p.distance+1,path:[...p.path,u],via:v(r,a,u,o)}),g.push(u));}return n}function y(r,t,s={}){return m(r,t,{...s,direction:"dependents"})}function D(r,t,s={}){let o=s.maxDepth??Number.POSITIVE_INFINITY,i=new Set,e=new Map,n=[];for(let c of t)i.has(c)||(i.add(c),e.set(c,0),n.push(c));let d=i.size,g=0;for(;g<n.length;){let c=n[g++],a=e.get(c)??0;if(a>=o)continue;let p=r.get(c);if(p)for(let h of p)i.has(h)||(i.add(h),e.set(h,a+1),n.push(h));}return {reached:i,added:i.size-d}}export{k as a,x as b,y as c,D as d};
@@ -0,0 +1 @@
1
+ import {c as c$1,d}from'./chunk-NAAQMSO3.js';import l from'fs-extra';var c="workspace-intelligence-history.v1",f=".workspai/reports/workspace-intelligence-history.json",p=50;function u(t){if(!t||typeof t!="object"||Array.isArray(t))return null;let e=t;return typeof e.generatedAt!="string"?null:e.kind==="agent-action"?typeof e.actionId!="string"||typeof e.summary!="string"||e.outcome!=="ok"&&e.outcome!=="failed"?null:{kind:"agent-action",generatedAt:e.generatedAt,actionId:e.actionId,scope:typeof e.scope=="string"?e.scope:"workspace",summary:e.summary,outcome:e.outcome,...typeof e.evidenceSha256=="string"?{evidenceSha256:e.evidenceSha256}:{}}:e.kind==="doctor-fix"?e.scope!=="workspace"&&e.scope!=="project"||typeof e.summary!="string"||e.outcome!=="ok"&&e.outcome!=="failed"?null:{kind:"doctor-fix",generatedAt:e.generatedAt,scope:e.scope,summary:e.summary,outcome:e.outcome,applied:typeof e.applied=="number"?e.applied:0,failed:typeof e.failed=="number"?e.failed:0,skipped:typeof e.skipped=="number"?e.skipped:0,remainingBlockers:typeof e.remainingBlockers=="number"?e.remainingBlockers:0}:typeof e.verdict!="string"||typeof e.risk!="string"||typeof e.gatePassed!="boolean"?null:{kind:"verify",generatedAt:e.generatedAt,verdict:e.verdict,risk:String(e.risk),affectedProjects:typeof e.affectedProjects=="number"?e.affectedProjects:0,freshness:e.freshness??"unknown",gatePassed:e.gatePassed,blockingReasons:typeof e.blockingReasons=="number"?e.blockingReasons:0,policyViolations:typeof e.policyViolations=="number"?e.policyViolations:0}}function W(t,e){return {kind:"verify",generatedAt:t.generatedAt,verdict:t.summary.verdict,risk:t.impact.risk,affectedProjects:t.impact.affectedProjects,freshness:t.freshness.verdict,gatePassed:e,blockingReasons:t.blockingReasons.length,policyViolations:t.policyViolations.length}}function H(t){return {kind:"agent-action",generatedAt:t.generatedAt,actionId:t.actionId,scope:t.scope,summary:t.summary,outcome:t.outcome,...t.evidenceSha256?{evidenceSha256:t.evidenceSha256}:{}}}function b(t,e){let r=t.appliedFixes.filter(i=>i.outcome==="applied").length,o=t.appliedFixes.filter(i=>i.outcome==="failed").length,n=t.appliedFixes.filter(i=>i.outcome==="skipped").length,s=t.appliedFixes.filter(i=>i.outcome==="guidance").length,a=t.remainingBlockers.length,m=o>0||a>0?"failed":"ok";return {kind:"doctor-fix",generatedAt:t.generatedAt,scope:e,summary:`${r} applied, ${o} failed, ${n} skipped, ${s} guidance, ${a} blocker(s) remaining`,outcome:m,applied:r,failed:o,skipped:n,remainingBlockers:a}}async function k(t){let e=await c$1(t,f);try{if(!e||!await l.pathExists(e))return null;let r=await l.readJson(e);return r?.schemaVersion!==c||!Array.isArray(r.entries)?null:{schemaVersion:c,retention:typeof r.retention=="number"?r.retention:p,entries:r.entries.map(o=>u(o)).filter(o=>o!=null)}}catch{return null}}function g(t,e,r=p){let o=Math.max(1,Math.floor(r)),n=[...t?.entries??[],e],s=n.slice(Math.max(0,n.length-o));return {schemaVersion:c,retention:o,entries:s}}async function R(t,e,r){let o=await k(t),n=g(o,e,r?.retention??p);return await d(t,f,n),n}export{c as a,f as b,p as c,u as d,W as e,H as f,b as g,k as h,g as i,R as j};
@@ -0,0 +1 @@
1
+ import {d,b,g as g$1,a,c}from'./chunk-RO73VVHW.js';import {randomUUID}from'crypto';var i=null;function f(){return i}function V(t){let r=t.argv??process.argv,n=m(r.slice(2)),e={runId:randomUUID(),startedAt:new Date().toISOString(),command:n,cwd:t.cwd??process.cwd(),rapidkitVersion:t.rapidkitVersion,finalized:false};return i=e,d(e.runId),b(r)&&g$1(l(e,"run.started","info","CLI run started")),e}function A(t,r){if(!(!i||i.finalized)){if(i.finalized=true,!b()){i=null;return}t===0?g$1(l(i,"run.completed","info",r??"CLI run completed",{exitCode:t})):g$1(l(i,"run.failed","error",r??"CLI run failed",{exitCode:t})),i=null;}}function w(t=process.argv){a(t)==="json"&&(process.env.WORKSPAI_LOG_FORMAT="json",process.env.RAPIDKIT_LOG_FORMAT="json");let r=t.slice(0,2),n=m(t.slice(2));n.length!==t.length-2&&(process.argv=[...r,...n]);}function m(t){let r=[];for(let n=0;n<t.length;n+=1){let e=t[n];if(e!=="--log-json"){if(e==="--log-format"){n+=1;continue}e.startsWith("--log-format=")||r.push(e);}}return r}function l(t,r,n,e,o){return {schemaVersion:c,runId:t.runId,timestamp:new Date().toISOString(),level:n,event:r,component:"cli",message:e,command:t.command,metadata:{cwd:t.cwd,rapidkitVersion:t.rapidkitVersion,startedAt:t.startedAt,...o}}}var g=false;function L(t){if(g||!t?.force&&(process.env.VITEST==="true"||process.env.VITEST==="1"||process.env.NODE_ENV==="test"))return;g=true;let r=process.exit.bind(process);process.exit=(n=>{let e=typeof n=="number"?n:typeof n=="string"?Number.parseInt(n,10):0,o=Number.isFinite(e)?e:1;return A(o),r(n)});}function h(){return f()?.runId}function y(t,r){let{blockers:n,stderrTail:e,runId:o,generatedAt:p,...C}=r,x=p||(typeof t.generatedAt=="string"?t.generatedAt:void 0)||(typeof t.timestamp=="string"?t.timestamp:void 0)||new Date().toISOString();return {...t,...C,generatedAt:x,...n&&n.length>0?{blockers:n}:{},...e&&e.trim()?{stderrTail:e.trim()}:{},...o?{runId:o}:{}}}export{V as a,A as b,w as c,L as d,h as e,y as f};
@@ -0,0 +1,2 @@
1
+ import {a as a$1,c as c$1,i,g as g$1,h}from'./chunk-4KUIFXHM.js';import {a as a$2}from'./chunk-LUP4U6EE.js';import {p}from'./chunk-5XATWNME.js';import _ from'fs';import a from'path';var g=["init","dev","start","build","test","lint","format","help"],J={python:{runtime:"python",displayName:"Python",tier:"first-class",scaffoldSupport:true,importSupport:true,lifecycleCommands:g,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:g,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:g,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:g,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:g,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."]}},me=["fastapi","nestjs"],ue=["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 S(e){return J[e||"unknown"]??J.unknown}function q(e){return me.includes(e)?"first-class":ue.includes(e)?"extended":"observed"}function Y(e){let t=S(e.runtime);return {lifecycleCommands:t.lifecycleCommands,moduleCommands:e.moduleSupport&&t.moduleCommands,unsupportedLifecycleCommands:g.filter(n=>!t.lifecycleCommands.includes(n))}}var ce=["python","node","go","java","dotnet"];function b(e){return !!e&&ce.includes(e)}function N(e,t){return t!=="lint"&&t!=="format"&&t!=="docs"?false:e==="python"}function H(e){let t=S(e),n=b(t.runtime),r=le[t.runtime]??[],i=de[t.runtime]??[];return {runtime:t.runtime,displayName:t.displayName,lifecycleCommands:t.lifecycleCommands,hasExecutor:n,packageManagers:r,primaryFiles:i,notes:t.notes}}var le={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"]},de={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 x(e,t){let n=g$1({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 n.runtime!=="unknown"?n.runtime:i(t,e).runtime}function X(e){let t=e;for(;;){for(let r of p(t,"project.json"))if(_.existsSync(r))try{return JSON.parse(_.readFileSync(r,"utf8"))}catch{return null}let n=a.dirname(t);if(n===t)break;t=n;}return null}function Ve(e,t){return x(e,t)==="go"}function Xe(e,t){return x(e,t)==="node"}function ze(e,t){return x(e,t)==="java"}function Qe(e,t){return x(e,t)==="dotnet"}function Ze(e,t){return x(e,t)==="python"}function ye(e){for(let t of p(e,"context.json"))if(_.existsSync(t))try{return JSON.parse(_.readFileSync(t,"utf8"))}catch{return null}return null}function Ce(e){let t=e?.engine;return t==="npm"||t==="pip"||t==="python"?t:"unknown"}function ge(e,t){if(e?.module_support===false||t?.module_support===false||!e&&t)return false;let n=typeof e?.kit_name=="string"?e.kit_name:typeof e?.kit=="string"?e.kit:typeof t?.kit=="string"?t.kit:void 0,r=n?a$2(n):void 0;return r?.owner==="core"&&r.moduleSupport===true}function be(e,t,n){let r=g$1({runtime:typeof t?.runtime=="string"?t.runtime:typeof n?.runtime=="string"?n.runtime:void 0,framework:typeof t?.framework=="string"?t.framework:typeof n?.framework=="string"?n.framework:void 0,kitName:typeof t?.kit_name=="string"?t.kit_name:typeof t?.kit=="string"?t.kit:typeof n?.kit=="string"?n.kit:void 0});return r.key!=="unknown"?r:i(e,t)}function z(e){let t=a.resolve(e);if(![...p(t,"project.json"),...p(t,"context.json")].some(k=>_.existsSync(k)))return null;let r=X(t),i=ye(t),m=be(t,r,i);return {projectRoot:t,projectJson:r,contextJson:i,detection:m,moduleSupport:ge(r,i),engine:Ce(i)}}var ke=["build","dev","start","test","lint","format"],A=["init","test","build","start"],ct=["lint","format","docs"];function lt(e){return !!e&&ke.includes(e)}var Se={dev:["dev","start:dev"],start:["start","start:prod","preview"],build:["build"],test:["test","test:unit","test:ci"],lint:["lint"],format:["format","prettier"]},Z={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 xe(e){let t=a.join(e,"package.json");if(!_.existsSync(t))return {};try{let r=JSON.parse(_.readFileSync(t,"utf8")).scripts??{};return Object.fromEntries(Object.entries(r).filter(i=>typeof i[1]=="string"))}catch{return {}}}function je(e,t){let n=t?c$1(t):"unknown",r=n!=="unknown"?a$1(n,e):[],i=t?Z[t]?.[e]??[]:[],m=Se[e]??[],k=[...r,...i,...m];return [...new Set(k)]}function ee(e,t,n){let r=xe(e),i=new Set(Object.keys(r));if(i.has(t))return {scriptName:t,source:"package.json"};for(let m of je(t,n?.framework))if(i.has(m))return {scriptName:m,source:a$1(c$1(n?.framework??"unknown"),t).includes(m)||Z[n?.framework??""]?.[t]?.includes(m)?"framework-candidate":"generic-candidate"};return null}function F(e){return _.existsSync(a.join(e,"package.json"))}function te(e){let t=H(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 _.existsSync(e)}catch{return false}}function f(e){try{return s(e)?_.readFileSync(e,"utf8"):""}catch{return ""}}function c(e,t){let n=f(a.join(e,"Makefile"));return n?new RegExp(`^${t}\\s*:`).test(n):false}function Re(e){let t=[e];for(;t.length>0;){let n=t.shift();if(!n)break;let r=[];try{r=_.readdirSync(n,{withFileTypes:true});}catch{continue}for(let i of r){if(i.name==="node_modules"||i.name===".git"||i.name==="dist")continue;let m=a.join(n,i.name);if(i.isFile()&&i.name.endsWith(".csproj"))return true;i.isDirectory()&&t.push(m);}}return false}function ne(e,t){let n=s(a.join(e,"pyproject.toml")),r=s(a.join(e,"requirements.txt"))||s(a.join(e,"requirements.in")),i=s(a.join(e,"manage.py"));switch(t){case "init":return n||r;case "dev":case "start":return n||i||r;case "test":return n||r||s(a.join(e,"tests"));case "build":return n||r;case "lint":case "format":return n||r||i||s(a.join(e,"setup.py"))||s(a.join(e,"setup.cfg"));default:return false}}function he(e,t){if(!s(a.join(e,"go.mod")))return false;switch(t){case "init":return true;case "dev":return c(e,"run")||s(a.join(e,"main.go"));case "test":return true;case "build":return true;case "start":return c(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"))||c(e,"lint");case "format":return c(e,"fmt")||c(e,"format");default:return false}}function Ne(e,t){let n=s(a.join(e,"pom.xml")),r=s(a.join(e,"build.gradle"))||s(a.join(e,"build.gradle.kts"));if(!n&&!r)return false;switch(t){case "init":case "test":case "build":case "dev":case "start":return true;case "lint":return c(e,"lint")||f(a.join(e,"pom.xml")).includes("checkstyle")||f(a.join(e,"build.gradle")).includes("checkstyle")||f(a.join(e,"build.gradle.kts")).includes("checkstyle");case "format":return c(e,"format")||f(a.join(e,"build.gradle")).includes("spotless")||f(a.join(e,"build.gradle.kts")).includes("spotless");default:return false}}function ve(e,t){if(!Re(e))return false;switch(t){case "init":case "dev":case "test":case "build":case "start":return true;case "lint":return c(e,"lint")||f(a.join(e,"Directory.Build.props")).includes("EnforceCodeStyleInBuild");case "format":return c(e,"format")||s(a.join(e,".editorconfig"));default:return false}}function Ee(e,t,n){return t==="init"?F(e):ee(e,t,{framework:n})!==null}function Pe(e,t,n){switch(t){case "php":return n==="init"&&s(a.join(e,"composer.json"));case "ruby":return n==="init"&&s(a.join(e,"Gemfile"));case "rust":return s(a.join(e,"Cargo.toml"))?n==="init"||n==="test"||n==="build"||n==="start":false;case "elixir":return n==="init"&&s(a.join(e,"mix.exs"));case "deno":return s(a.join(e,"deno.json"))||s(a.join(e,"deno.jsonc"))?n==="init"||n==="dev"||n==="test"||n==="start":n==="init"&&s(a.join(e,"package.json"));case "bun":return s(a.join(e,"bunfig.toml"))||s(a.join(e,"bun.lock"))?n==="init"||n==="dev"||n==="test"||n==="build"||n==="start":n==="init"&&s(a.join(e,"package.json"));default:return false}}function v(e,t,n,r){if(N(t,n))return ne(e,n);if(!b(t))return Pe(e,t,n);switch(t){case "node":return Ee(e,n,r);case "python":return ne(e,n);case "go":return he(e,n);case "java":return Ne(e,n);case "dotnet":return ve(e,n);default:return false}}function we(e,t,n){return ["init","dev","start","build","test","lint","format"].filter(i=>v(e,t,i,n))}function re(e){let t=Y({runtime:e.runtime,moduleSupport:e.moduleSupport});if(!e.projectPath)return t;let n=we(e.projectPath,e.runtime,e.framework),r=new Set(["help"]);for(let m of n)t.lifecycleCommands.includes(m)&&r.add(m);e.runtime==="node"&&F(e.projectPath)&&r.add("init");let i=[...r].sort();return {lifecycleCommands:i,moduleCommands:t.moduleCommands,unsupportedLifecycleCommands:t.lifecycleCommands.filter(m=>!i.includes(m)).sort()}}var T=["version","commands","doctor","project","help"],E=["init","dev","start","build","test","lint","format"],B=["add","modules","upgrade","diff","merge","reconcile","rollback","uninstall","checkpoint","snapshot","optimize"],I=["create","list","info","frameworks","license"];T.filter(e=>e!=="help");function _e(e){let t=a.resolve(e);for(;;){if([...p(t,"project.json"),...p(t,"context.json")].some(i=>_.existsSync(i)))return t;let r=a.dirname(t);if(r===t)break;t=r;}return null}function j(e,t){return {command:e,...t}}var Ae=new Set(["dev","lint","format"]),Le=new Set(A);function Fe(e,t){return t?Le.has(e)?{executionScope:"fleet",fleetEligible:true}:Ae.has(e)?{executionScope:"local-only",fleetEligible:false}:{executionScope:"local-only",fleetEligible:false}:{executionScope:"local-only",fleetEligible:false}}function Oe(e,t){return N(t.runtime,e)?"core":"runtime"}function De(e,t,n,r){return !e||!r.lifecycleCommands.includes(t)?false:v(e,n.runtime,t,n.key)}function Te(e,t){let n=!!e&&(t.runtime==="python"||b(t.runtime)&&v(e,t.runtime,"build",t.key));return j("docs",{owner:t.runtime==="python"?"core":"runtime",status:n?"supported":"unsupported",reason:n?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 Be(e){let t=a.resolve(e),n=_e(e);return n||(h(t).length>0?t:null)}function Ie(e=process.cwd()){let t=Be(e),n=t?z(t):null,r=n?.detection??i(e,n?.projectJson??null),i$1=n?.moduleSupport??false,m=n?.engine??"unknown",k=te(r.runtime),U=S(r.runtime),ie=re({runtime:r.runtime,moduleSupport:i$1,projectPath:t??void 0,framework:r.key}),p={};for(let o of T)p[o]=j(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 E){let y=De(t,o,r,ie),G=Oe(o,r),P=Fe(o,y);p[o]=j(o,{owner:G,status:y?"supported":"unsupported",executionScope:P.executionScope,fleetEligible:P.fleetEligible,reason:y?G==="core"?`Delegated to Python Core for ${r.displayName} projects.`:P.fleetEligible?`Handled by runtime adapter and eligible for workspace fleet stages (${o}).`:o==="dev"?"Local development command only; workspace fleet excludes dev by design.":r.runtime==="node"?`Handled by npm/pnpm/yarn via the resolved ${o} script in package.json.`:`Handled by the ${k?.displayName??r.displayName} runtime adapter for local project execution.`:t?r.runtime==="node"?`No ${o} script was found in package.json for this ${r.displayName} project.`:b(r.runtime)?`The ${r.displayName} runtime is tracked, but ${o} is not available from detected project manifests.`:`${r.displayName} is tracked as an observed runtime; ${o} requires project manifests or explicit scripts.`:"No Workspai project was detected."});}p.docs=Te(t,r);for(let o of B)p[o]=j(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 ${r.displayName} projects.`});for(let o of I)p[o]=j(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 R=Object.values(p),K=R.filter(o=>E.includes(o.command)).filter(o=>o.status==="supported"),ae=A.filter(o=>K.some(y=>y.fleetEligible===true&&y.command===o)),se=K.filter(o=>o.executionScope==="local-only").map(o=>o.command).sort();return {schemaVersion:1,scope:"project",projectRoot:t,engine:m,runtime:r.runtime,framework:r.key,frameworkDisplayName:r.displayName,frameworkConfidence:r.confidence,frameworkSupportTier:q(r.key),runtimeSupportTier:U.tier,runtimeDoctorSupport:U.doctorSupport,moduleSupport:i$1,fleetStages:ae,localOnlyCommands:se,commandMap:p,supportedCommands:R.filter(o=>o.status==="supported").map(o=>o.command).sort(),unsupportedCommands:R.filter(o=>o.status==="unsupported").map(o=>o.command).sort(),globalCommands:R.filter(o=>o.status==="global").map(o=>o.command).sort()}}function Jt(e,t=process.cwd()){let n=e[0];return n?Ie(t).commandMap[n]??null:null}function qt(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 Yt(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{S as a,q as b,b as c,X as d,Ve as e,Xe as f,ze as g,Qe as h,Ze as i,z as j,ke as k,ct as l,lt as m,ee as n,re as o,_e as p,Ie as q,Jt as r,qt as s,Yt as t};