@flisk-sh/flisk 0.0.0-stage → 1.3.190

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 (440) hide show
  1. package/CHANGELOG.md +492 -0
  2. package/LICENSE +21 -0
  3. package/README.md +479 -2
  4. package/Tiltfile +151 -0
  5. package/cli/bin/flisk.js +42 -0
  6. package/cli/dist/agent-runtimes/custom.js +335 -0
  7. package/cli/dist/agent-runtimes/registry.js +34 -0
  8. package/cli/dist/backend-frameworks/elysia.js +38 -0
  9. package/cli/dist/backend-frameworks/express.js +49 -0
  10. package/cli/dist/backend-frameworks/fastify.js +43 -0
  11. package/cli/dist/backend-frameworks/h3.js +37 -0
  12. package/cli/dist/backend-frameworks/koa.js +47 -0
  13. package/cli/dist/backend-frameworks/mcp.js +86 -0
  14. package/cli/dist/backend-frameworks/nestjs.js +55 -0
  15. package/cli/dist/backend-frameworks/registry.js +134 -0
  16. package/cli/dist/backend-frameworks/types.js +1 -0
  17. package/cli/dist/backend-languages/bun.js +76 -0
  18. package/cli/dist/backend-languages/go.js +125 -0
  19. package/cli/dist/backend-languages/node.js +122 -0
  20. package/cli/dist/backend-languages/python.js +94 -0
  21. package/cli/dist/backend-languages/registry.js +37 -0
  22. package/cli/dist/backend-languages/rust.js +82 -0
  23. package/cli/dist/backend-languages/types.js +1 -0
  24. package/cli/dist/cli.js +29 -0
  25. package/cli/dist/commands/__tests__/project-e2e-helpers.js +49 -0
  26. package/cli/dist/commands/__tests__/ui-loading-screen.test.js +16 -0
  27. package/cli/dist/commands/agent.js +182 -0
  28. package/cli/dist/commands/completion-candidates.js +116 -0
  29. package/cli/dist/commands/completion.js +843 -0
  30. package/cli/dist/commands/config.js +362 -0
  31. package/cli/dist/commands/doctor.js +1504 -0
  32. package/cli/dist/commands/down.js +114 -0
  33. package/cli/dist/commands/eject.js +108 -0
  34. package/cli/dist/commands/help.js +152 -0
  35. package/cli/dist/commands/import.js +164 -0
  36. package/cli/dist/commands/logs.js +119 -0
  37. package/cli/dist/commands/maintainers.js +102 -0
  38. package/cli/dist/commands/mcp.js +28 -0
  39. package/cli/dist/commands/networks.js +306 -0
  40. package/cli/dist/commands/project.js +447 -0
  41. package/cli/dist/commands/projects.js +103 -0
  42. package/cli/dist/commands/registry.js +53 -0
  43. package/cli/dist/commands/resource.js +992 -0
  44. package/cli/dist/commands/resources.js +127 -0
  45. package/cli/dist/commands/restart.js +89 -0
  46. package/cli/dist/commands/runtime.js +75 -0
  47. package/cli/dist/commands/stack.js +171 -0
  48. package/cli/dist/commands/stacks.js +71 -0
  49. package/cli/dist/commands/status.js +211 -0
  50. package/cli/dist/commands/ui.js +725 -0
  51. package/cli/dist/commands/up.js +609 -0
  52. package/cli/dist/commands/upgrade.js +840 -0
  53. package/cli/dist/commands/version.js +10 -0
  54. package/cli/dist/components/Accessible.js +11 -0
  55. package/cli/dist/components/BaseTooltip.js +30 -0
  56. package/cli/dist/components/DetailPanel.js +33 -0
  57. package/cli/dist/components/FileTree.js +51 -0
  58. package/cli/dist/components/ResourceSelectInput.js +42 -0
  59. package/cli/dist/components/ResourceTable.js +35 -0
  60. package/cli/dist/components/ServiceIssues.js +13 -0
  61. package/cli/dist/components/TUIHeader.js +27 -0
  62. package/cli/dist/components/TabBar.js +27 -0
  63. package/cli/dist/components/Tooltip.js +13 -0
  64. package/cli/dist/components/index.js +11 -0
  65. package/cli/dist/components/ui-theme.js +120 -0
  66. package/cli/dist/config/platform-standards.js +182 -0
  67. package/cli/dist/frontend-frameworks/lit.js +64 -0
  68. package/cli/dist/frontend-frameworks/preact.js +62 -0
  69. package/cli/dist/frontend-frameworks/qwik.js +61 -0
  70. package/cli/dist/frontend-frameworks/react.js +69 -0
  71. package/cli/dist/frontend-frameworks/registry.js +83 -0
  72. package/cli/dist/frontend-frameworks/solid.js +62 -0
  73. package/cli/dist/frontend-frameworks/svelte.js +67 -0
  74. package/cli/dist/frontend-frameworks/tanstack-router.js +101 -0
  75. package/cli/dist/frontend-frameworks/types.js +1 -0
  76. package/cli/dist/frontend-frameworks/vanilla.js +59 -0
  77. package/cli/dist/frontend-frameworks/vue.js +72 -0
  78. package/cli/dist/generator/__tests__/golden-helpers.js +43 -0
  79. package/cli/dist/generator/extension-fetch.js +291 -0
  80. package/cli/dist/generator/resource-templates.js +133 -0
  81. package/cli/dist/generator/template-engine.js +801 -0
  82. package/cli/dist/index.js +10 -0
  83. package/cli/dist/mcp/server.js +101 -0
  84. package/cli/dist/mcp/tools.js +351 -0
  85. package/cli/dist/program.js +37 -0
  86. package/cli/dist/types/index.js +38 -0
  87. package/cli/dist/utils/agent-host.js +36 -0
  88. package/cli/dist/utils/atomic-write.js +36 -0
  89. package/cli/dist/utils/bun-floor.js +9 -0
  90. package/cli/dist/utils/bun-requirement.js +10 -0
  91. package/cli/dist/utils/cache.js +63 -0
  92. package/cli/dist/utils/cold-preflight.js +257 -0
  93. package/cli/dist/utils/command-helpers.js +57 -0
  94. package/cli/dist/utils/constants.js +160 -0
  95. package/cli/dist/utils/discovery-context.js +71 -0
  96. package/cli/dist/utils/discovery-paths.js +93 -0
  97. package/cli/dist/utils/docker.js +34 -0
  98. package/cli/dist/utils/doctor-crashloop.js +161 -0
  99. package/cli/dist/utils/doctor-fix.js +391 -0
  100. package/cli/dist/utils/doctor-host.js +66 -0
  101. package/cli/dist/utils/doctor-report.js +78 -0
  102. package/cli/dist/utils/doctor-runtime.js +880 -0
  103. package/cli/dist/utils/doctor-starlark.js +132 -0
  104. package/cli/dist/utils/doctor-wiring.js +698 -0
  105. package/cli/dist/utils/down-cleanup.js +125 -0
  106. package/cli/dist/utils/env-validator.js +266 -0
  107. package/cli/dist/utils/errors.js +175 -0
  108. package/cli/dist/utils/exec-async.js +31 -0
  109. package/cli/dist/utils/file-helpers.js +104 -0
  110. package/cli/dist/utils/formatting.js +165 -0
  111. package/cli/dist/utils/generated-paths.js +51 -0
  112. package/cli/dist/utils/help-command.js +11 -0
  113. package/cli/dist/utils/host-port-config.js +140 -0
  114. package/cli/dist/utils/host-port-plan.js +100 -0
  115. package/cli/dist/utils/json-output.js +29 -0
  116. package/cli/dist/utils/machine-output.js +33 -0
  117. package/cli/dist/utils/paths.js +43 -0
  118. package/cli/dist/utils/platform.js +58 -0
  119. package/cli/dist/utils/port-assignment.js +75 -0
  120. package/cli/dist/utils/port-conflict-fix.js +25 -0
  121. package/cli/dist/utils/port-fallback-notice.js +17 -0
  122. package/cli/dist/utils/port-listener-probe.js +20 -0
  123. package/cli/dist/utils/project-config-defaults.js +17 -0
  124. package/cli/dist/utils/project-features.js +91 -0
  125. package/cli/dist/utils/project-templates.js +32 -0
  126. package/cli/dist/utils/prompt.js +97 -0
  127. package/cli/dist/utils/resource-features.js +184 -0
  128. package/cli/dist/utils/resource-kind.js +9 -0
  129. package/cli/dist/utils/schema-version-gate.js +45 -0
  130. package/cli/dist/utils/search-status.js +12 -0
  131. package/cli/dist/utils/secret-redaction.js +73 -0
  132. package/cli/dist/utils/service-config-checks.js +189 -0
  133. package/cli/dist/utils/service-manifest.js +254 -0
  134. package/cli/dist/utils/service-runtime-state.js +66 -0
  135. package/cli/dist/utils/service-urls.js +112 -0
  136. package/cli/dist/utils/services.js +360 -0
  137. package/cli/dist/utils/shared-infra.js +45 -0
  138. package/cli/dist/utils/shared-platform-postgres.js +232 -0
  139. package/cli/dist/utils/single-flight.js +21 -0
  140. package/cli/dist/utils/smoke.js +401 -0
  141. package/cli/dist/utils/spinner.js +40 -0
  142. package/cli/dist/utils/stack-features.js +15 -0
  143. package/cli/dist/utils/stack-status.js +14 -0
  144. package/cli/dist/utils/startup-report.js +78 -0
  145. package/cli/dist/utils/status-message.js +21 -0
  146. package/cli/dist/utils/status-ports.js +33 -0
  147. package/cli/dist/utils/suggestions.js +63 -0
  148. package/cli/dist/utils/tar.js +46 -0
  149. package/cli/dist/utils/tdk-version.js +51 -0
  150. package/cli/dist/utils/terminal-layout.js +19 -0
  151. package/cli/dist/utils/tilt-events.js +194 -0
  152. package/cli/dist/utils/tilt-logs.js +61 -0
  153. package/cli/dist/utils/tilt-port-owner.js +63 -0
  154. package/cli/dist/utils/tilt-process.js +54 -0
  155. package/cli/dist/utils/tilt-resource-state.js +32 -0
  156. package/cli/dist/utils/tilt-startup.js +49 -0
  157. package/cli/dist/utils/tilt-unreachable-message.js +9 -0
  158. package/cli/dist/utils/tilt.js +104 -0
  159. package/cli/dist/utils/ui-keymap.js +129 -0
  160. package/cli/dist/utils/ui-service-state.js +34 -0
  161. package/cli/dist/utils/up-only.js +28 -0
  162. package/cli/dist/utils/up-readiness.js +118 -0
  163. package/cli/dist/utils/url-actions.js +103 -0
  164. package/cli/dist/utils/validation.js +62 -0
  165. package/cli/dist/utils/which.js +56 -0
  166. package/cli/dist/utils/windows-doctor.js +176 -0
  167. package/cli/dist-bundle/chunk-6EA4DGCY.js +2 -0
  168. package/cli/dist-bundle/chunk-BZ4H7MM4.js +3 -0
  169. package/cli/dist-bundle/chunk-CLCUIDBH.js +510 -0
  170. package/cli/dist-bundle/cli.js +2017 -0
  171. package/cli/dist-bundle/cold-preflight-SY26O2IG.js +2 -0
  172. package/cli/dist-bundle/devtools-ZUHXW33W.js +5 -0
  173. package/cli/dist-bundle/extension-fetch-J4FFH7TJ.js +2 -0
  174. package/cli/package.json +83 -0
  175. package/cli/shared-platform-engineering/docker-templates/bun-hoisted-symlink-fix.sh +25 -0
  176. package/cli/shared-platform-engineering/docker-templates/infisical-entrypoint.sh +466 -0
  177. package/cli/shared-platform-engineering/docker-templates/install-deps.sh +154 -0
  178. package/cli/shared-platform-engineering/docker-templates/prisma-bun-client-link-fix.sh +14 -0
  179. package/cli/shared-platform-engineering/docker-templates/prisma-normalize-client.sh +58 -0
  180. package/cli/templates/.tiltignore.hbs +72 -0
  181. package/cli/templates/TILT_RESOURCE_DEFAULTS.star.hbs +220 -0
  182. package/cli/templates/TILT_TECH_STACK.star.hbs +149 -0
  183. package/cli/templates/Tiltfile.hbs +381 -0
  184. package/cli/templates/spec.master.hbs +192 -0
  185. package/discovery/AGENTS.md +362 -0
  186. package/discovery/TILT_DISCOVERY.star +429 -0
  187. package/discovery/Tiltfile +58 -0
  188. package/discovery/config.star +265 -0
  189. package/discovery/constants.star +167 -0
  190. package/discovery/deterministic.star +213 -0
  191. package/discovery/discovery_daemon.star +193 -0
  192. package/discovery/discovery_orchestrator.star +492 -0
  193. package/discovery/filtering.star +7 -0
  194. package/discovery/identity-management-backend/service.yaml +26 -0
  195. package/discovery/identity-management-frontend/service.yaml +29 -0
  196. package/discovery/identity-sdk/service.yaml +9 -0
  197. package/discovery/incremental_discovery.star +215 -0
  198. package/discovery/indexing.star +9 -0
  199. package/discovery/json_manifest_scanner.star +57 -0
  200. package/discovery/libraries.star +48 -0
  201. package/discovery/loading.star +25 -0
  202. package/discovery/manifest/constants.star +106 -0
  203. package/discovery/manifest/loading.star +418 -0
  204. package/discovery/manifest/normalize.star +289 -0
  205. package/discovery/manifest/validation.star +110 -0
  206. package/discovery/normalization.star +13 -0
  207. package/discovery/registry.star +562 -0
  208. package/discovery/resource_snapshot.py +384 -0
  209. package/discovery/resource_snapshot.star +145 -0
  210. package/discovery/schemas.star +3 -0
  211. package/discovery/services/platform/cdc/debezium/nats-connector/service.yaml +9 -0
  212. package/discovery/services/platform/cdc/nats-http-bridge/service.yaml +9 -0
  213. package/discovery/services/platform/orchestrator/orchestrator-glue-backend/service.yaml +26 -0
  214. package/discovery/services/platform/synthetic-monitor/service.yaml +9 -0
  215. package/discovery/test_resource_snapshot.py +253 -0
  216. package/discovery/validation.star +80 -0
  217. package/discovery/versioning.star +3 -0
  218. package/engine/AGENTS.md +706 -0
  219. package/engine/README.md +31 -0
  220. package/engine/REFACTORING_MANIFEST_SYSTEM.md +974 -0
  221. package/engine/Tiltfile +86 -0
  222. package/engine/assets/docker/golden-layers.Dockerfile +204 -0
  223. package/engine/assets/docker/wake-gateway/Dockerfile +28 -0
  224. package/engine/assets/docker/wake-gateway/decide.test.ts +177 -0
  225. package/engine/assets/docker/wake-gateway/decide.ts +135 -0
  226. package/engine/assets/docker/wake-gateway/server.ts +363 -0
  227. package/engine/assets/scripts/cleanup-completed-migrator-images.sh +39 -0
  228. package/engine/assets/scripts/cleanup-tilt-images.sh +122 -0
  229. package/engine/assets/scripts/mac-m1-resource-monitor.sh +123 -0
  230. package/engine/config.star +5 -0
  231. package/engine/entrypoint.star +101 -0
  232. package/engine/lifecycle/orchestrator.star +263 -0
  233. package/engine/paths.star +719 -0
  234. package/engine/schemas/project-schema.json +147 -0
  235. package/engine/schemas/service-schema.json +537 -0
  236. package/engine/scripts/README.md +89 -0
  237. package/engine/scripts/build-and-publish-lib.sh +207 -0
  238. package/engine/scripts/check-lib-publish.sh +87 -0
  239. package/engine/scripts/debug-container.sh +265 -0
  240. package/engine/scripts/generate-manifest.sh +200 -0
  241. package/engine/spec.master +702 -0
  242. package/engine/spec.master.example +341 -0
  243. package/engine/topologies/README.md +33 -0
  244. package/engine/topologies/platform/docker/AGENTS.md +59 -0
  245. package/engine/topologies/platform/docker/auth/auth.star +207 -0
  246. package/engine/topologies/platform/docker/build/frontend_build_plan.star +65 -0
  247. package/engine/topologies/platform/docker/build/golden_image.star +37 -0
  248. package/engine/topologies/platform/docker/build/golden_image_build.star +144 -0
  249. package/engine/topologies/platform/docker/build/golden_image_constants.star +100 -0
  250. package/engine/topologies/platform/docker/build/golden_image_dockerfile.star +263 -0
  251. package/engine/topologies/platform/docker/compose/compose.star +637 -0
  252. package/engine/topologies/platform/docker/compose/compose_helpers.star +54 -0
  253. package/engine/topologies/platform/docker/compose/traefik_standalone.star +171 -0
  254. package/engine/topologies/platform/docker/config/bunignore.star +144 -0
  255. package/engine/topologies/platform/docker/config/dockerignore.star +152 -0
  256. package/engine/topologies/platform/docker/config/healthcheck.star +58 -0
  257. package/engine/topologies/platform/docker/constants.star +211 -0
  258. package/engine/topologies/platform/docker/dockerfile/dockerfile.star +56 -0
  259. package/engine/topologies/platform/docker/dockerfile/language_dockerfile.star +264 -0
  260. package/engine/topologies/platform/docker/generators/golden_docker_generator_v2.star +76 -0
  261. package/engine/topologies/platform/docker/index.star +40 -0
  262. package/engine/topologies/platform/docker/layers/bun_helpers.star +25 -0
  263. package/engine/topologies/platform/docker/layers/infisical/index.star +42 -0
  264. package/engine/topologies/platform/docker/layers/infisical/infisical_docker.star +264 -0
  265. package/engine/topologies/platform/docker/layers/l1_base_layers.star +89 -0
  266. package/engine/topologies/platform/docker/layers/l2_dependency_layers.star +147 -0
  267. package/engine/topologies/platform/docker/layers/l3_builder_layers.star +229 -0
  268. package/engine/topologies/platform/docker/layers/l4_runtime_layers.star +282 -0
  269. package/engine/topologies/platform/docker/layers/prisma/constants.star +138 -0
  270. package/engine/topologies/platform/docker/layers/prisma/db_readiness.star +98 -0
  271. package/engine/topologies/platform/docker/layers/prisma/filesystem_setup.star +131 -0
  272. package/engine/topologies/platform/docker/layers/prisma/migrate_script.star +100 -0
  273. package/engine/topologies/platform/docker/layers/prisma/prisma_build.star +128 -0
  274. package/engine/topologies/platform/docker/layers/prisma/prisma_runtime.star +205 -0
  275. package/engine/topologies/platform/docker/layers/prisma/secret_resolution.star +121 -0
  276. package/engine/topologies/platform/docker/networking/api_path_constants.star +206 -0
  277. package/engine/topologies/platform/docker/networking/sablier_container_cycle.star +31 -0
  278. package/engine/topologies/platform/docker/networking/traefik.star +266 -0
  279. package/engine/topologies/platform/docker/networking/traefik_constants.star +148 -0
  280. package/engine/topologies/platform/docker/networking/traefik_helpers.star +162 -0
  281. package/engine/topologies/platform/docker/networking/traefik_static_routes.star +165 -0
  282. package/engine/topologies/platform/docker/secrets/env_secrets.star +74 -0
  283. package/engine/topologies/platform/docker/secrets/infisical.star +109 -0
  284. package/engine/topologies/platform/net/AGENTS.md +64 -0
  285. package/engine/topologies/platform/net/proxy.star +6 -0
  286. package/engine/topologies/platform/registries/local.star +6 -0
  287. package/engine/topologies/platform/registries/verdaccio_loader.star +20 -0
  288. package/engine/topologies/platform/security/AGENTS.md +49 -0
  289. package/engine/topologies/platform/security/secrets.star +241 -0
  290. package/engine/topologies/platform/state/AGENTS.md +64 -0
  291. package/engine/topologies/platform/state/relational.star +6 -0
  292. package/engine/topologies/tilt/common/AGENTS.md +59 -0
  293. package/engine/topologies/tilt/common/utils.star +409 -0
  294. package/engine/topologies/tilt/common/utils_debug.star +71 -0
  295. package/engine/topologies/tilt/common/utils_deterministic.star +170 -0
  296. package/engine/topologies/tilt/common/utils_docker_networks.star +54 -0
  297. package/engine/topologies/tilt/common/utils_env.star +92 -0
  298. package/engine/topologies/tilt/common/utils_output.star +99 -0
  299. package/engine/topologies/tilt/config/AGENTS.md +68 -0
  300. package/engine/topologies/tilt/config/defaults.star +5 -0
  301. package/engine/topologies/tilt/config/feature_flags.star +12 -0
  302. package/engine/topologies/tilt/config/global.star +57 -0
  303. package/engine/topologies/tilt/config/profiles.star +398 -0
  304. package/engine/topologies/tilt/generators/agents_md.star +64 -0
  305. package/engine/topologies/tilt/generators/api_gateway.star +147 -0
  306. package/engine/topologies/tilt/generators/index.star +126 -0
  307. package/engine/topologies/tilt/generators/infisical/README.md +424 -0
  308. package/engine/topologies/tilt/generators/infisical/examples.star +314 -0
  309. package/engine/topologies/tilt/generators/infisical/index.star +59 -0
  310. package/engine/topologies/tilt/generators/infisical/machine_identity.star +422 -0
  311. package/engine/topologies/tilt/generators/infisical/organization.star +536 -0
  312. package/engine/topologies/tilt/generators/infisical/path_manager.star +478 -0
  313. package/engine/topologies/tilt/generators/infisical/secrets_generator.star +422 -0
  314. package/engine/topologies/tilt/generators/nginx_conf.star +145 -0
  315. package/engine/topologies/tilt/generators/npmrc.star +132 -0
  316. package/engine/topologies/tilt/generators/tsconfig.star +25 -0
  317. package/engine/topologies/tilt/generators/typescript/backend_library_tsconfig.star +73 -0
  318. package/engine/topologies/tilt/generators/typescript/backend_tsconfig.star +137 -0
  319. package/engine/topologies/tilt/generators/typescript/common.star +9 -0
  320. package/engine/topologies/tilt/generators/typescript/frontend_library_tsconfig.star +78 -0
  321. package/engine/topologies/tilt/generators/typescript/frontend_tsconfig.star +140 -0
  322. package/engine/topologies/tilt/generators/typescript/include.star +25 -0
  323. package/engine/topologies/tilt/generators/typescript/playwright_config.star +42 -0
  324. package/engine/topologies/tilt/generators/typescript/prisma_config.star +51 -0
  325. package/engine/topologies/tilt/generators/validators.star +868 -0
  326. package/engine/topologies/tilt/generators/vite/backend.star +80 -0
  327. package/engine/topologies/tilt/generators/vite/frameworks/lit.star +92 -0
  328. package/engine/topologies/tilt/generators/vite/frameworks/preact.star +94 -0
  329. package/engine/topologies/tilt/generators/vite/frameworks/qwik.star +94 -0
  330. package/engine/topologies/tilt/generators/vite/frameworks/react.star +128 -0
  331. package/engine/topologies/tilt/generators/vite/frameworks/solid.star +94 -0
  332. package/engine/topologies/tilt/generators/vite/frameworks/svelte.star +94 -0
  333. package/engine/topologies/tilt/generators/vite/frameworks/vanilla.star +92 -0
  334. package/engine/topologies/tilt/generators/vite/frameworks/vue.star +94 -0
  335. package/engine/topologies/tilt/generators/vite/frontend.star +153 -0
  336. package/engine/topologies/tilt/generators/vite/generators.star +45 -0
  337. package/engine/topologies/tilt/generators/vite/helpers.star +256 -0
  338. package/engine/topologies/tilt/generators/vite/library.star +67 -0
  339. package/engine/topologies/tilt/generators/vite/sdk.star +75 -0
  340. package/engine/topologies/tilt/generators/vite/templates.star +460 -0
  341. package/engine/topologies/tilt/generators/vite_config.star +24 -0
  342. package/engine/topologies/tilt/manifest/AGENTS.md +61 -0
  343. package/engine/topologies/tilt/manifest/README.md +679 -0
  344. package/engine/topologies/tilt/manifest/__init__.star +220 -0
  345. package/engine/topologies/tilt/manifest/constants.star +262 -0
  346. package/engine/topologies/tilt/manifest/errors.star +268 -0
  347. package/engine/topologies/tilt/manifest/integration.star +348 -0
  348. package/engine/topologies/tilt/manifest/json_to_yaml.py +61 -0
  349. package/engine/topologies/tilt/manifest/loader.star +239 -0
  350. package/engine/topologies/tilt/manifest/mapper.star +229 -0
  351. package/engine/topologies/tilt/manifest/parser.star +490 -0
  352. package/engine/topologies/tilt/manifest/schema.star +502 -0
  353. package/engine/topologies/tilt/manifest/tests/test_integration.star +278 -0
  354. package/engine/topologies/tilt/manifest/tests/test_loader_parser.star +475 -0
  355. package/engine/topologies/tilt/manifest/tests/test_manifest.star +319 -0
  356. package/engine/topologies/tilt/manifest/tests/test_validator.star +472 -0
  357. package/engine/topologies/tilt/manifest/validator.star +744 -0
  358. package/engine/topologies/tilt/manifest/yaml_to_json.py +20 -0
  359. package/engine/topologies/tilt/resources/AGENTS.md +71 -0
  360. package/engine/topologies/tilt/resources/build_concurrency.star +56 -0
  361. package/engine/topologies/tilt/resources/conditions.star +5 -0
  362. package/engine/topologies/tilt/resources/databases.star +246 -0
  363. package/engine/topologies/tilt/resources/declaration.star +5 -0
  364. package/engine/topologies/tilt/resources/deps.star +5 -0
  365. package/engine/topologies/tilt/resources/infra-loader.star +504 -0
  366. package/engine/topologies/tilt/resources/libs.star +32 -0
  367. package/engine/topologies/tilt/resources/libs_discovery.star +104 -0
  368. package/engine/topologies/tilt/resources/libs_paths.star +81 -0
  369. package/engine/topologies/tilt/resources/libs_resource_definition.star +153 -0
  370. package/engine/topologies/tilt/resources/libs_setup.star +166 -0
  371. package/engine/topologies/tilt/resources/libs_tsconfig.star +39 -0
  372. package/engine/topologies/tilt/resources/orchestrator/apply.star +79 -0
  373. package/engine/topologies/tilt/resources/orchestrator/apply_compose_resource_registration.star +864 -0
  374. package/engine/topologies/tilt/resources/orchestrator/apply_manifest_orchestration.star +90 -0
  375. package/engine/topologies/tilt/resources/orchestrator/apply_migrator_orchestration.star +150 -0
  376. package/engine/topologies/tilt/resources/orchestrator/apply_resource_validation.star +38 -0
  377. package/engine/topologies/tilt/resources/orchestrator/apply_runtime_flags.star +46 -0
  378. package/engine/topologies/tilt/resources/orchestrator/builders/typescript.star +193 -0
  379. package/engine/topologies/tilt/resources/orchestrator/generators/dependencies/AGENTS.md +75 -0
  380. package/engine/topologies/tilt/resources/orchestrator/generators/dependencies/index.star +23 -0
  381. package/engine/topologies/tilt/resources/orchestrator/generators/dependencies/resolver.star +136 -0
  382. package/engine/topologies/tilt/resources/orchestrator/generators/env.star +219 -0
  383. package/engine/topologies/tilt/resources/orchestrator/generators/frontend.star +172 -0
  384. package/engine/topologies/tilt/resources/orchestrator/generators/manifest_resource.star +577 -0
  385. package/engine/topologies/tilt/resources/orchestrator/helpers.star +35 -0
  386. package/engine/topologies/tilt/resources/orchestrator.star +56 -0
  387. package/engine/topologies/tilt/resources/ordering.star +5 -0
  388. package/engine/topologies/tilt/resources/shared-platform-postgres.star +30 -0
  389. package/engine/topologies/tilt/resources/triggers.star +5 -0
  390. package/engine/topologies/tilt/resources/watchers.star +304 -0
  391. package/engine/where-things-live.star +719 -0
  392. package/examples/tdk-example/LICENSE +21 -0
  393. package/examples/tdk-example/README.md +23 -0
  394. package/examples/tdk-example/TILT_SERVICE_DEFAULTS.star +42 -0
  395. package/examples/tdk-example/TILT_TECH_STACK.star +67 -0
  396. package/examples/tdk-example/Tiltfile +25 -0
  397. package/examples/tdk-example/services/platform/messaging/docker-compose.yml +26 -0
  398. package/examples/tdk-example/services/shop/orders-api/package.json +20 -0
  399. package/examples/tdk-example/services/shop/orders-api/service.json +14 -0
  400. package/examples/tdk-example/services/shop/orders-api/src/index.ts +81 -0
  401. package/examples/tdk-example/services/shop/orders-app/index.html +12 -0
  402. package/examples/tdk-example/services/shop/orders-app/package.json +23 -0
  403. package/examples/tdk-example/services/shop/orders-app/public/.gitkeep +0 -0
  404. package/examples/tdk-example/services/shop/orders-app/service.json +9 -0
  405. package/examples/tdk-example/services/shop/orders-app/src/main.tsx +9 -0
  406. package/examples/tdk-example/services/shop/orders-app/src/orders.tsx +67 -0
  407. package/examples/tdk-example/services/shop/orders-app/src/style.css +15 -0
  408. package/examples/tdk-example/services/shop/orders-worker/package.json +18 -0
  409. package/examples/tdk-example/services/shop/orders-worker/service.json +13 -0
  410. package/examples/tdk-example/services/shop/orders-worker/src/index.ts +33 -0
  411. package/ext/Tiltfile +66 -0
  412. package/ext/ide-components/README.md +221 -0
  413. package/ext/ide-components/code_viewer/server.py +208 -0
  414. package/ext/ide-components/config_inspector/server.py +1052 -0
  415. package/ext/ide-components/file_browser/server.py +287 -0
  416. package/ext/ide-components/shared/config_service.py +471 -0
  417. package/ext/ide-components/shared/file_utils.py +300 -0
  418. package/ext/ide-components/shared/http_utils.py +234 -0
  419. package/ext/ide-components/shared/static/styles.css +1334 -0
  420. package/ext/ide-components/shared/syntax_highlighter.py +142 -0
  421. package/ext/ide-components/shared/template_engine.py +125 -0
  422. package/ext/ide-components/shared/templates/base.html +121 -0
  423. package/ext/ide-components/shared/test_config_service.py +328 -0
  424. package/ext/ide-components/shared/tilt_integration.py +160 -0
  425. package/ext/ui-enhancements/cron-status-server.sh +51 -0
  426. package/ext/ui-enhancements/cron-status-tracker.sh +148 -0
  427. package/ext/ui-enhancements/extension.yaml +36 -0
  428. package/ext/ui-enhancements/tiltfile.py +101 -0
  429. package/ext/ui-enhancements/ui/cron-jobs-tab.css +396 -0
  430. package/ext/ui-enhancements/ui/help-panel.css +279 -0
  431. package/ext/ui-enhancements/ui/icons.css +125 -0
  432. package/ext/ui-enhancements/ui/tooltips.css +114 -0
  433. package/package.json +94 -4
  434. package/shared-platform-engineering/docker-templates/bun-hoisted-symlink-fix.sh +25 -0
  435. package/shared-platform-engineering/docker-templates/infisical-entrypoint.sh +466 -0
  436. package/shared-platform-engineering/docker-templates/install-deps.sh +154 -0
  437. package/shared-platform-engineering/docker-templates/prisma-bun-client-link-fix.sh +14 -0
  438. package/shared-platform-engineering/docker-templates/prisma-normalize-client.sh +58 -0
  439. package/specs/specs/TILT_SERVICE_DEFAULTS.star +207 -0
  440. package/specs/specs/TILT_TECH_STACK.star +161 -0
@@ -0,0 +1,868 @@
1
+ # Copyright (c) 2026 Flisk Landscape contributors
2
+ # SPDX-License-Identifier: MIT
3
+ # =============================================================================
4
+ # 🛡️ VALIDATORS - Pre-Flight Validation Generators
5
+ # =============================================================================
6
+ # These generators run BEFORE services start to catch issues early
7
+ # They prevent vibe-coding failures by enforcing constraints at build time
8
+ # =============================================================================
9
+
10
+ # === INLINED CONSTANTS for pure extension loading ===
11
+ BASE_PORT_FRONTEND = 3000
12
+ # === END INLINED CONSTANTS ===
13
+
14
+
15
+ """
16
+ Validators Architecture:
17
+ 1. docker_path_validator - Ensures path aliases work in Docker context
18
+ 2. dependency_validator - Ensures all declared dependencies exist
19
+ 3. db_readiness_validator - Validates database credentials before startup
20
+ 4. package_publish_validator - Ensures shared packages are published
21
+ 5. env_var_validator - Validates all required environment variables
22
+ 6. resource_health_validator - Pre-flight health checks
23
+ 7. shared_package_copier - Copies shared packages to Docker context
24
+ """
25
+
26
+ load("../common/utils.star", "Utils")
27
+ load("../../platform/docker/constants.star", "PlatformDockerConstants")
28
+ load("../manifest/constants.star", "GENERATED_CONFIG_FILENAMES")
29
+ load("../resources/shared-platform-postgres.star", "is_shared_platform_postgres_dependency")
30
+
31
+ load("../common/utils.star", "LIBRARY_ROOTS")
32
+
33
+ # =============================================================================
34
+ # 1. Docker Path Alias Validator
35
+ # =============================================================================
36
+
37
+ def validate_docker_path_aliases(resource_path, manifest, library_roots):
38
+ """
39
+ Validates that TypeScript path aliases in Docker tsconfig will resolve correctly.
40
+
41
+ Problem: Docker builds fail when tsconfig has path aliases to shared packages
42
+ that aren't copied to the Docker context.
43
+
44
+ Solution:
45
+ - Warn about path aliases that point outside Docker context
46
+ - Recommend removing internal_deps from Docker tsconfig
47
+ - Suggest using node_modules resolution instead
48
+
49
+ Returns: (is_valid, warnings, fixes)
50
+ """
51
+ warnings = []
52
+ fixes = []
53
+
54
+ resource_name = manifest.get("appName", "unknown")
55
+ app_type = manifest.get("appType", "backend")
56
+
57
+ # Check if this is a frontend service (most affected)
58
+ if app_type == "frontend":
59
+ # Check for internal dependencies that would break Docker build
60
+ package_json_path = resource_path + "/package.json"
61
+ if os.path.exists(package_json_path):
62
+ package_json = read_json(package_json_path)
63
+ deps = package_json.get("dependencies", {})
64
+
65
+ internal_scope = "@" + PlatformDockerConstants.PROJECT_NAME + "/"
66
+ # Build list manually (Starlark doesn't support list comprehensions with if)
67
+ internal_deps = []
68
+ for name in deps.keys():
69
+ if name.startswith(internal_scope):
70
+ internal_deps.append(name)
71
+
72
+ if internal_deps:
73
+ warnings.append({
74
+ "level": "error",
75
+ "message": "Frontend '{}' has internal deps that will fail Docker build".format(resource_name),
76
+ "details": "The following packages use path aliases that won't resolve in Docker:",
77
+ "packages": internal_deps,
78
+ "impact": "Build will fail with 'Module not found' errors",
79
+ })
80
+
81
+ fixes.append({
82
+ "action": "Remove path aliases from Docker tsconfig",
83
+ "generator": "typescript/frontend_tsconfig.star",
84
+ "change": "Set internal_deps=None when is_docker=True",
85
+ "rationale": "Docker builds should resolve from node_modules, not source paths",
86
+ })
87
+
88
+ # Count errors manually (Starlark doesn't support list comprehensions with if)
89
+ error_count = 0
90
+ for w in warnings:
91
+ if w["level"] == "error":
92
+ error_count += 1
93
+ is_valid = error_count == 0
94
+
95
+ return struct(
96
+ is_valid=is_valid,
97
+ warnings=warnings,
98
+ fixes=fixes,
99
+ resource_name=resource_name,
100
+ )
101
+
102
+ def generate_docker_path_validation_report(resource_path, manifest, write_fn=None):
103
+ """
104
+ Generates a validation report for Docker path aliases.
105
+ Called during config-gen to catch issues before Docker build.
106
+ """
107
+ result = validate_docker_path_aliases(resource_path, manifest, LIBRARY_ROOTS)
108
+
109
+ if not result.is_valid:
110
+ report = {
111
+ "timestamp": "now",
112
+ "service": result.resource_name,
113
+ "status": "FAILED",
114
+ "warnings": result.warnings,
115
+ "fixes": result.fixes,
116
+ "recommendation": "Regenerate tsconfig without Docker path aliases",
117
+ }
118
+
119
+ if write_fn:
120
+ write_fn("docker-path-validation.json", Utils.encode_json(report))
121
+
122
+ # Also print to Tilt UI
123
+ print("⚠️ Docker Path Validation Failed for {}".format(result.resource_name))
124
+ for warning in result.warnings:
125
+ print(" ❌ {}: {}".format(warning["level"].upper(), warning["message"]))
126
+ for fix in result.fixes:
127
+ print(" 💡 Fix: {}".format(fix["action"]))
128
+
129
+ return report
130
+
131
+ return {"status": "PASSED", "service": result.resource_name}
132
+
133
+ # =============================================================================
134
+ # 2. Dependency Graph Validator
135
+ # =============================================================================
136
+
137
+ def validate_dependency_graph(resource_path, manifest, all_services):
138
+ """
139
+ Validates that all declared dependencies actually exist.
140
+
141
+ Problem: Services declare dependencies on libraries that don't exist,
142
+ causing Tilt warnings and runtime failures.
143
+
144
+ Solution:
145
+ - Check all @{npm_scope}/* dependencies exist in library_roots
146
+ - Check dependsOn in manifest exist as services
147
+ - Generate missing dependency report
148
+
149
+ Returns: (is_valid, missing_deps, suggestions)
150
+ """
151
+ missing_deps = []
152
+ warnings = []
153
+
154
+ resource_name = manifest.get("appName", "unknown")
155
+
156
+ # Check package.json dependencies
157
+ package_json_path = resource_path + "/package.json"
158
+ if os.path.exists(package_json_path):
159
+ package_json = read_json(package_json_path)
160
+ deps = package_json.get("dependencies", {})
161
+ dev_deps = package_json.get("devDependencies", {})
162
+ all_deps = dict(deps, **dev_deps)
163
+
164
+ internal_scope = "@" + PlatformDockerConstants.PROJECT_NAME + "/"
165
+
166
+ for dep_name in all_deps.keys():
167
+ if dep_name.startswith(internal_scope):
168
+ lib_name = dep_name.replace(internal_scope, "")
169
+
170
+ # Check if library exists in known library directories
171
+ found = False
172
+ for lib_type, lib_root in LIBRARY_ROOTS.items():
173
+ lib_path = "{}/{}".format(lib_root, lib_name)
174
+ if os.path.exists(lib_path):
175
+ found = True
176
+ break
177
+
178
+ if not found:
179
+ missing_deps.append({
180
+ "name": dep_name,
181
+ "type": "library",
182
+ "source": "package.json",
183
+ })
184
+
185
+ # Check manifest dependsOn
186
+ internal_deps = manifest.get("dependsOn", [])
187
+ for dep in internal_deps:
188
+ # Shared platform Postgres aliases are not app services; they resolve to
189
+ # the Tilt resource `postgres` and must not be reported as missing.
190
+ if is_shared_platform_postgres_dependency(dep):
191
+ continue
192
+ dep_exists = False
193
+ for svc in all_services:
194
+ # Check service name/stack match (supports legacy 'stack' field)
195
+ svc_stack = svc.get("stack") or svc.get("stack")
196
+ if svc.get("name") == dep or svc_stack == dep:
197
+ dep_exists = True
198
+ break
199
+ # Check if any resource within the service matches
200
+ for resource in svc.get("resources", []):
201
+ if resource.get("name") == dep:
202
+ dep_exists = True
203
+ break
204
+ if dep_exists:
205
+ break
206
+
207
+ if not dep_exists:
208
+ missing_deps.append({
209
+ "name": dep,
210
+ "type": "service",
211
+ "source": "service.json dependsOn",
212
+ })
213
+
214
+ is_valid = len(missing_deps) == 0
215
+
216
+ return struct(
217
+ is_valid=is_valid,
218
+ missing_deps=missing_deps,
219
+ resource_name=resource_name,
220
+ )
221
+
222
+ def generate_dependency_validation_report(resource_path, manifest, all_services, write_fn=None):
223
+ """
224
+ Generates a validation report for service dependencies.
225
+ """
226
+ result = validate_dependency_graph(resource_path, manifest, all_services)
227
+
228
+ if not result.is_valid:
229
+ report = {
230
+ "timestamp": "now",
231
+ "service": result.resource_name,
232
+ "status": "FAILED",
233
+ "missing_dependencies": result.missing_deps,
234
+ "recommendation": "Create missing libraries or update dependencies",
235
+ }
236
+
237
+ if write_fn:
238
+ write_fn("dependency-validation.json", Utils.encode_json(report))
239
+
240
+ print("⚠️ Dependency Validation Failed for {}".format(result.resource_name))
241
+ for dep in result.missing_deps:
242
+ print(" ❌ Missing {}: {} (from {})".format(
243
+ dep["type"], dep["name"], dep["source"]
244
+ ))
245
+
246
+ return report
247
+
248
+ return {"status": "PASSED", "service": result.resource_name}
249
+
250
+ # =============================================================================
251
+ # 3. Database Readiness Validator
252
+ # =============================================================================
253
+
254
+ def validate_database_readiness(resource_name, db_name, db_config):
255
+ """
256
+ Validates database configuration before service startup.
257
+
258
+ Problem: Services fail to start because database credentials are wrong,
259
+ database doesn't exist, or connection fails.
260
+
261
+ Solution:
262
+ - Check DATABASE_URL is properly formed
263
+ - Validate database credentials format
264
+ - Ensure database name matches manifest
265
+ - Generate proper connection string
266
+
267
+ Returns: (is_valid, connection_string, errors)
268
+ """
269
+ errors = []
270
+
271
+ # Validate database name
272
+ if not db_name:
273
+ errors.append({
274
+ "field": "databaseName",
275
+ "error": "No database name specified in manifest",
276
+ "fix": "Add 'databaseName' to service.json",
277
+ })
278
+
279
+ # Validate database config
280
+ if not db_config:
281
+ errors.append({
282
+ "field": "database",
283
+ "error": "No database configuration found",
284
+ "fix": "Check GLOBAL_CONFIG.database in discovery/config.star",
285
+ })
286
+
287
+ # Build connection string
288
+ connection_string = None
289
+ if db_name and db_config:
290
+ host = db_config.get("host", "localhost")
291
+ port = db_config.get("port", 5432)
292
+ user = db_config.get("user", "postgres")
293
+ # ⚠️ SECURITY: No default password - must be explicitly provided
294
+ password = db_config.get("password")
295
+
296
+ if not password:
297
+ errors.append({
298
+ "field": "database.password",
299
+ "error": "Database password is required but not provided",
300
+ "fix": "Set DB_PASSWORD or POSTGRES_PASSWORD environment variable",
301
+ })
302
+ else:
303
+ connection_string = "postgresql://{}:{}@{}:{}/{}".format(
304
+ user, password, host, port, db_name
305
+ )
306
+
307
+ is_valid = len(errors) == 0
308
+
309
+ return struct(
310
+ is_valid=is_valid,
311
+ connection_string=connection_string,
312
+ errors=errors,
313
+ resource_name=resource_name,
314
+ )
315
+
316
+ def generate_db_readiness_check(resource_name, db_name, db_config, write_fn=None):
317
+ """
318
+ Generates database readiness validation and entrypoint script.
319
+ """
320
+ result = validate_database_readiness(resource_name, db_name, db_config)
321
+
322
+ if not result.is_valid:
323
+ report = {
324
+ "timestamp": "now",
325
+ "service": resource_name,
326
+ "status": "FAILED",
327
+ "errors": result.errors,
328
+ "recommendation": "Fix database configuration in manifest",
329
+ }
330
+
331
+ if write_fn:
332
+ write_fn("db-readiness-validation.json", Utils.encode_json(report))
333
+
334
+ print("⚠️ Database Validation Failed for {}".format(resource_name))
335
+ for error in result.errors:
336
+ print(" ❌ {}: {}".format(error["field"], error["error"]))
337
+
338
+ return report
339
+
340
+ # Generate connection string report
341
+ if write_fn:
342
+ write_fn("db-connection-string.txt", result.connection_string)
343
+
344
+ return {
345
+ "status": "PASSED",
346
+ "service": resource_name,
347
+ "connection_string": result.connection_string,
348
+ }
349
+
350
+ # =============================================================================
351
+ # 4. Package Publish Validator
352
+ # =============================================================================
353
+
354
+ def validate_package_publishing(resource_path, manifest, verdaccio_url):
355
+ """
356
+ Validates that all @{npm_scope} dependencies are published to Verdaccio.
357
+
358
+ Problem: Docker builds fail because shared packages aren't published,
359
+ causing 'npm package not found' errors.
360
+
361
+ Solution:
362
+ - Check each @{npm_scope} dependency exists in Verdaccio
363
+ - Compare local package version with published version
364
+ - Warn if local is newer than published
365
+
366
+ Returns: (is_valid, unpublished_packages, version_mismatches)
367
+ """
368
+ unpublished = []
369
+ version_mismatches = []
370
+
371
+ resource_name = manifest.get("appName", "unknown")
372
+
373
+ package_json_path = resource_path + "/package.json"
374
+ if not os.path.exists(package_json_path):
375
+ return struct(
376
+ is_valid=True,
377
+ unpublished_packages=[],
378
+ version_mismatches=[],
379
+ resource_name=resource_name,
380
+ )
381
+
382
+ package_json = read_json(package_json_path)
383
+ deps = package_json.get("dependencies", {})
384
+
385
+ internal_scope = "@" + PlatformDockerConstants.PROJECT_NAME + "/"
386
+
387
+ for dep_name, dep_version in deps.items():
388
+ if not dep_name.startswith(internal_scope):
389
+ continue
390
+
391
+ lib_name = dep_name.replace(internal_scope, "")
392
+
393
+ # Check if package exists in Verdaccio
394
+ # (This would be an actual HTTP check in real implementation)
395
+ # For now, we check if library source exists
396
+ found = False
397
+ for lib_root in LIBRARY_ROOTS.values():
398
+ lib_path = "{}/{}".format(lib_root, lib_name)
399
+ if os.path.exists(lib_path):
400
+ found = True
401
+
402
+ # Check local package.json version
403
+ lib_package_path = "{}/package.json".format(lib_path)
404
+ if os.path.exists(lib_package_path):
405
+ lib_package = read_json(lib_package_path)
406
+ local_version = lib_package.get("version", "0.0.0")
407
+
408
+ # Parse requested version
409
+ requested_version = dep_version.replace("^", "").replace("~", "")
410
+
411
+ if local_version != requested_version:
412
+ version_mismatches.append({
413
+ "package": dep_name,
414
+ "requested": requested_version,
415
+ "local": local_version,
416
+ })
417
+ break
418
+
419
+ if not found:
420
+ unpublished.append(dep_name)
421
+
422
+ is_valid = len(unpublished) == 0
423
+
424
+ return struct(
425
+ is_valid=is_valid,
426
+ unpublished_packages=unpublished,
427
+ version_mismatches=version_mismatches,
428
+ resource_name=resource_name,
429
+ )
430
+
431
+ def generate_package_publish_report(resource_path, manifest, verdaccio_url, write_fn=None):
432
+ """
433
+ Generates a report of package publishing status.
434
+ """
435
+ result = validate_package_publishing(resource_path, manifest, verdaccio_url)
436
+
437
+ if not result.is_valid or result.version_mismatches:
438
+ report = {
439
+ "timestamp": "now",
440
+ "service": result.resource_name,
441
+ "status": "WARNING" if not result.is_valid else "VERSION_MISMATCH",
442
+ "unpublished_packages": result.unpublished_packages,
443
+ "version_mismatches": result.version_mismatches,
444
+ "recommendation": "Run 'bun run publish:all' to publish packages",
445
+ }
446
+
447
+ if write_fn:
448
+ write_fn("package-publish-validation.json", Utils.encode_json(report))
449
+
450
+ if not result.is_valid:
451
+ print("⚠️ Package Publishing Validation Failed for {}".format(result.resource_name))
452
+ for pkg in result.unpublished_packages:
453
+ print(" ❌ Package not found: {}".format(pkg))
454
+
455
+ if result.version_mismatches:
456
+ print("⚠️ Version Mismatches for {}".format(result.resource_name))
457
+ for mismatch in result.version_mismatches:
458
+ print(" ⚡ {}: requested {} but local is {}".format(
459
+ mismatch["package"],
460
+ mismatch["requested"],
461
+ mismatch["local"]
462
+ ))
463
+
464
+ return report
465
+
466
+ return {"status": "PASSED", "service": result.resource_name}
467
+
468
+ # =============================================================================
469
+ # 5. Environment Variable Validator
470
+ # =============================================================================
471
+
472
+ def validate_environment_variables(resource_path, manifest, required_vars):
473
+ """
474
+ Validates that all required environment variables are defined.
475
+
476
+ Problem: Services fail at runtime because environment variables are missing.
477
+
478
+ Solution:
479
+ - Define required vars in manifest
480
+ - Check .env files exist
481
+ - Validate variables are set in Tilt context
482
+
483
+ Returns: (is_valid, missing_vars, env_files)
484
+ """
485
+ missing_vars = []
486
+ env_files = []
487
+
488
+ resource_name = manifest.get("appName", "unknown")
489
+
490
+ # Check for .env files
491
+ for env_file in [".env", ".env.local", ".env.docker"]:
492
+ env_path = "{}/{}".format(resource_path, env_file)
493
+ if os.path.exists(env_path):
494
+ env_files.append(env_file)
495
+
496
+ # Check required variables
497
+ manifest_required = manifest.get("requiredEnvVars", [])
498
+ all_required = list(set(required_vars + manifest_required))
499
+
500
+ for var in all_required:
501
+ if not os.environ.get(var):
502
+ missing_vars.append(var)
503
+
504
+ is_valid = len(missing_vars) == 0
505
+
506
+ return struct(
507
+ is_valid=is_valid,
508
+ missing_vars=missing_vars,
509
+ env_files=env_files,
510
+ resource_name=resource_name,
511
+ )
512
+
513
+ def generate_env_validation_report(resource_path, manifest, required_vars, write_fn=None):
514
+ """
515
+ Generates environment variable validation report.
516
+ """
517
+ result = validate_environment_variables(resource_path, manifest, required_vars)
518
+
519
+ if not result.is_valid:
520
+ report = {
521
+ "timestamp": "now",
522
+ "service": result.resource_name,
523
+ "status": "FAILED",
524
+ "missing_variables": result.missing_vars,
525
+ "env_files_found": result.env_files,
526
+ "recommendation": "Set missing environment variables or add .env file",
527
+ }
528
+
529
+ if write_fn:
530
+ write_fn("env-validation.json", Utils.encode_json(report))
531
+
532
+ print("⚠️ Environment Variable Validation Failed for {}".format(result.resource_name))
533
+ for var in result.missing_vars:
534
+ print(" ❌ Missing: {}".format(var))
535
+
536
+ return report
537
+
538
+ return {
539
+ "status": "PASSED",
540
+ "service": result.resource_name,
541
+ "env_files": result.env_files,
542
+ }
543
+
544
+ # =============================================================================
545
+ # 6. Service Health Pre-Flight Validator
546
+ # =============================================================================
547
+
548
+ def generate_resource_health_check(resource_name, resource_path, manifest, checks):
549
+ """
550
+ Generates a comprehensive pre-flight health check script.
551
+
552
+ Runs before service starts to validate:
553
+ - File structure is correct
554
+ - Required files exist
555
+ - Dependencies are resolvable
556
+ - Ports are available
557
+
558
+ Returns: health_check_script (bash)
559
+ """
560
+ app_type = manifest.get("appType", "backend")
561
+
562
+ health_checks = []
563
+
564
+ # Check 1: Required files exist
565
+ frontend_entry = "src/main.ts" if manifest.get("framework", "react") in ["vue", "svelte", "lit", "vanilla"] else "src/main.tsx"
566
+ backend_files = {
567
+ "python": ["pyproject.toml", "src/main.py"],
568
+ "go": ["go.mod", "main.go"],
569
+ "rust": ["Cargo.toml", "src/main.rs"],
570
+ "node": ["package.json", "src/index.js"],
571
+ }.get(manifest.get("language", "bun"), ["package.json", "prisma/schema.prisma"])
572
+ required_files = {
573
+ "backend": backend_files,
574
+ "frontend": ["package.json", "index.html", frontend_entry],
575
+ "library": ["package.json"],
576
+ }.get(app_type, ["package.json"])
577
+
578
+ for req_file in required_files:
579
+ health_checks.append('''
580
+ if [ ! -f "{}" ]; then
581
+ echo "❌ Missing required file: {}"
582
+ exit 1
583
+ fi
584
+ '''.format(req_file, req_file))
585
+
586
+ # Check 2: Package.json is valid JSON (Python and Go backends have no package.json)
587
+ if manifest.get("language", "bun") not in ["python", "go", "rust"]:
588
+ health_checks.append('''
589
+ if ! cat package.json | head -1 > /dev/null 2>&1; then
590
+ echo "❌ package.json is not valid"
591
+ exit 1
592
+ fi
593
+ ''')
594
+
595
+ # Check 3: Port availability (for local dev)
596
+ port = manifest.get("port", BASE_PORT_FRONTEND)
597
+ health_checks.append('''
598
+ # Check if port is already in use
599
+ if command -v lsof > /dev/null 2>&1; then
600
+ if lsof -Pi :{} -sTCP:LISTEN -t >/dev/null 2>&1; then
601
+ echo "⚠️ Port {} is already in use"
602
+ fi
603
+ fi
604
+ '''.format(port, port))
605
+
606
+ # Combine into script
607
+ script = '''#!/bin/bash
608
+ # Auto-generated health check for {}
609
+ # Generated: {}
610
+
611
+ echo "🔍 Running pre-flight health checks for {}..."
612
+
613
+ {}
614
+
615
+ echo "✅ All health checks passed for {}"
616
+ '''.format(
617
+ resource_name,
618
+ "now",
619
+ resource_name,
620
+ "\n".join(health_checks),
621
+ resource_name
622
+ )
623
+
624
+ return script
625
+
626
+ def generate_health_check_resource(resource_path, resource_name, manifest, write_fn=None):
627
+ """
628
+ Generates health check files and optionally writes them.
629
+ """
630
+ checks = {} # Could be expanded with more check types
631
+
632
+ script = generate_resource_health_check(resource_name, resource_path, manifest, checks)
633
+
634
+ if write_fn:
635
+ write_fn("health-check.sh", script)
636
+
637
+ return script
638
+
639
+ # =============================================================================
640
+ # 7. Shared Package Copier (for Docker Context)
641
+ # =============================================================================
642
+
643
+ def generate_shared_package_copy_list(resource_path, manifest):
644
+ """
645
+ Generates a list of shared packages that need to be copied to Docker context.
646
+
647
+ Problem: Frontend builds fail because shared packages are referenced via
648
+ path aliases but not available in Docker build context.
649
+
650
+ Solution: Copy required shared packages to service directory before Docker build.
651
+
652
+ Returns: list of {source, destination, package_name} dicts
653
+ """
654
+ packages_to_copy = []
655
+
656
+ resource_name = manifest.get("appName", "unknown")
657
+
658
+ package_json_path = resource_path + "/package.json"
659
+ if not os.path.exists(package_json_path):
660
+ return packages_to_copy
661
+
662
+ package_json = read_json(package_json_path)
663
+ deps = package_json.get("dependencies", {})
664
+
665
+ internal_scope = "@" + PlatformDockerConstants.PROJECT_NAME + "/"
666
+
667
+ for dep_name in deps.keys():
668
+ if not dep_name.startswith(internal_scope):
669
+ continue
670
+
671
+ lib_name = dep_name.replace(internal_scope, "")
672
+
673
+ # Find library source path
674
+ for lib_root in LIBRARY_ROOTS.values():
675
+ lib_path = "{}/{}".format(lib_root, lib_name)
676
+ if os.path.exists(lib_path):
677
+ # Destination: .docker-shared-packages/{lib_name}
678
+ dest = ".docker-shared-packages/{}".format(lib_name)
679
+
680
+ packages_to_copy.append({
681
+ "source": lib_path,
682
+ "destination": dest,
683
+ "package_name": dep_name,
684
+ "lib_name": lib_name,
685
+ })
686
+ break
687
+
688
+ return packages_to_copy
689
+
690
+ def generate_docker_shared_packages_config(resource_path, manifest, write_fn=None):
691
+ """
692
+ Generates configuration for copying shared packages to Docker context.
693
+
694
+ This creates a JSON file that can be used by a local_resource to copy
695
+ packages before Docker build.
696
+ """
697
+ packages = generate_shared_package_copy_list(resource_path, manifest)
698
+
699
+ config = {
700
+ "timestamp": "now",
701
+ "service": manifest.get("appName", "unknown"),
702
+ "packages": packages,
703
+ "copy_script": "#!/bin/bash\n# Copy shared packages to Docker context\n" + "\n".join([
704
+ "mkdir -p {dest} && cp -r {src}/* {dest}/".format(
705
+ src=p["source"],
706
+ dest=p["destination"]
707
+ )
708
+ for p in packages
709
+ ]) if packages else "# No shared packages to copy",
710
+ }
711
+
712
+ if write_fn:
713
+ write_fn("docker-shared-packages.json", Utils.encode_json(config))
714
+
715
+ return config
716
+
717
+ # =============================================================================
718
+ # Master Validation Orchestrator
719
+ # =============================================================================
720
+
721
+ def run_all_validations(resource_path, manifest, all_services, global_config, write_fn=None):
722
+ """
723
+ Runs all validators and generates a comprehensive report.
724
+
725
+ This is the main entry point called during config-gen.
726
+ """
727
+ reports = {}
728
+ all_valid = True
729
+
730
+ # 1. Docker Path Validation
731
+ reports["docker_paths"] = generate_docker_path_validation_report(
732
+ resource_path, manifest, write_fn
733
+ )
734
+ if reports["docker_paths"].get("status") == "FAILED":
735
+ all_valid = False
736
+
737
+ # 2. Dependency Validation
738
+ reports["dependencies"] = generate_dependency_validation_report(
739
+ resource_path, manifest, all_services, write_fn
740
+ )
741
+ if reports["dependencies"].get("status") == "FAILED":
742
+ all_valid = False
743
+
744
+ # 3. Database Validation
745
+ db_config = global_config.get("database", {})
746
+ db_name = manifest.get("databaseName", "")
747
+ reports["database"] = generate_db_readiness_check(
748
+ manifest.get("appName"), db_name, db_config, write_fn
749
+ )
750
+ if reports["database"].get("status") == "FAILED":
751
+ all_valid = False
752
+
753
+ # 4. Package Publishing Validation
754
+ verdaccio_url = global_config.get("verdaccio_url_local", PlatformDockerConstants.VERDACCIO_URL_LOCAL)
755
+ reports["packages"] = generate_package_publish_report(
756
+ resource_path, manifest, verdaccio_url, write_fn
757
+ )
758
+ # Warnings don't fail validation
759
+
760
+ # 5. Environment Variable Validation
761
+ required_vars = ["VERDACCIO_URL_DOCKER", "TILT_ENV"]
762
+ reports["environment"] = generate_env_validation_report(
763
+ resource_path, manifest, required_vars, write_fn
764
+ )
765
+ if reports["environment"].get("status") == "FAILED":
766
+ all_valid = False
767
+
768
+ # 6. Health Check Script
769
+ reports["health_check"] = generate_health_check_resource(
770
+ resource_path, manifest.get("appName"), manifest, write_fn
771
+ )
772
+
773
+ # 7. Shared Package Copy Config
774
+ reports["shared_packages"] = generate_docker_shared_packages_config(
775
+ resource_path, manifest, write_fn
776
+ )
777
+
778
+ # Master Report
779
+ # Count passed, failed, and warnings using regular loops (Starlark doesn't support generator expressions)
780
+ passed_count = 0
781
+ failed_count = 0
782
+ warnings_count = 0
783
+ for r in reports.values():
784
+ if type(r) == "dict":
785
+ status = r.get("status")
786
+ if status == "PASSED":
787
+ passed_count += 1
788
+ elif status == "FAILED":
789
+ failed_count += 1
790
+ elif status == "WARNING":
791
+ warnings_count += 1
792
+
793
+ master_report = {
794
+ "service": manifest.get("appName", "unknown"),
795
+ "overall_status": "PASSED" if all_valid else "FAILED",
796
+ "reports": reports,
797
+ "summary": {
798
+ "validations_run": 7,
799
+ "passed": passed_count,
800
+ "failed": failed_count,
801
+ "warnings": warnings_count,
802
+ }
803
+ }
804
+
805
+ if write_fn:
806
+ write_fn("validation-master-report.json", Utils.encode_json(master_report))
807
+
808
+ # Print compact validation summary
809
+ resource_name = manifest.get("appName", "unknown")
810
+
811
+ # Build compact validation summary - only show failures prominently
812
+ failed_validations = []
813
+ passed_count = 0
814
+ unknown_count = 0
815
+
816
+ for name, report in reports.items():
817
+ if type(report) == "dict":
818
+ status = report.get("status", "UNKNOWN")
819
+ if status == "FAILED":
820
+ failed_validations.append(name)
821
+ elif status == "PASSED":
822
+ passed_count += 1
823
+ elif status == "UNKNOWN":
824
+ unknown_count += 1
825
+
826
+ # Print compact summary
827
+ if all_valid:
828
+ # All passed - just show summary line
829
+ print("✅ {}: {} validations passed".format(resource_name, passed_count))
830
+ else:
831
+ # Some failed - show service and failures
832
+ print("❌ {}: {} validation(s) failed".format(resource_name, len(failed_validations)))
833
+ for failed in failed_validations:
834
+ print(" ❌ {}".format(failed))
835
+
836
+ # Show warnings/unknown only in verbose mode
837
+ is_verbose = os.environ.get('TILT_LOG_LEVEL') == 'verbose'
838
+ if is_verbose and unknown_count > 0:
839
+ print(" ○ {} not checked".format(unknown_count))
840
+
841
+ return master_report
842
+
843
+ # =============================================================================
844
+ # Exports
845
+ # =============================================================================
846
+
847
+ Validators = struct(
848
+ # Individual validators
849
+ validate_docker_path_aliases=validate_docker_path_aliases,
850
+ validate_dependency_graph=validate_dependency_graph,
851
+ validate_database_readiness=validate_database_readiness,
852
+ validate_package_publishing=validate_package_publishing,
853
+ validate_environment_variables=validate_environment_variables,
854
+
855
+ # Report generators
856
+ generate_docker_path_validation_report=generate_docker_path_validation_report,
857
+ generate_dependency_validation_report=generate_dependency_validation_report,
858
+ generate_db_readiness_check=generate_db_readiness_check,
859
+ generate_package_publish_report=generate_package_publish_report,
860
+ generate_env_validation_report=generate_env_validation_report,
861
+ generate_health_check_resource=generate_health_check_resource,
862
+ generate_docker_shared_packages_config=generate_docker_shared_packages_config,
863
+
864
+ # Master orchestrator
865
+ run_all_validations=run_all_validations,
866
+ )
867
+
868
+ GLOBAL_CONFIG = {}