@friggframework/devtools 2.0.0-next.6 → 2.0.0-next.61

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 (357) hide show
  1. package/frigg-cli/README.md +1289 -0
  2. package/frigg-cli/__tests__/unit/commands/build.test.js +279 -0
  3. package/frigg-cli/__tests__/unit/commands/db-setup.test.js +649 -0
  4. package/frigg-cli/__tests__/unit/commands/deploy.test.js +320 -0
  5. package/frigg-cli/__tests__/unit/commands/doctor.test.js +309 -0
  6. package/frigg-cli/__tests__/unit/commands/install.test.js +400 -0
  7. package/frigg-cli/__tests__/unit/commands/ui.test.js +346 -0
  8. package/frigg-cli/__tests__/unit/dependencies.test.js +74 -0
  9. package/frigg-cli/__tests__/unit/utils/database-validator.test.js +397 -0
  10. package/frigg-cli/__tests__/unit/utils/error-messages.test.js +345 -0
  11. package/frigg-cli/__tests__/unit/version-detection.test.js +171 -0
  12. package/frigg-cli/__tests__/utils/mock-factory.js +270 -0
  13. package/frigg-cli/__tests__/utils/prisma-mock.js +194 -0
  14. package/frigg-cli/__tests__/utils/test-fixtures.js +463 -0
  15. package/frigg-cli/__tests__/utils/test-setup.js +287 -0
  16. package/frigg-cli/build-command/index.js +53 -14
  17. package/frigg-cli/db-setup-command/index.js +246 -0
  18. package/frigg-cli/deploy-command/SPEC-DEPLOY-DRY-RUN.md +981 -0
  19. package/frigg-cli/deploy-command/index.js +295 -17
  20. package/frigg-cli/doctor-command/index.js +335 -0
  21. package/frigg-cli/generate-command/__tests__/generate-command.test.js +301 -0
  22. package/frigg-cli/generate-command/azure-generator.js +43 -0
  23. package/frigg-cli/generate-command/gcp-generator.js +47 -0
  24. package/frigg-cli/generate-command/index.js +332 -0
  25. package/frigg-cli/generate-command/terraform-generator.js +555 -0
  26. package/frigg-cli/generate-iam-command.js +118 -0
  27. package/frigg-cli/index.js +142 -1
  28. package/frigg-cli/index.test.js +1 -4
  29. package/frigg-cli/init-command/backend-first-handler.js +756 -0
  30. package/frigg-cli/init-command/index.js +93 -0
  31. package/frigg-cli/init-command/template-handler.js +143 -0
  32. package/frigg-cli/install-command/index.js +1 -4
  33. package/frigg-cli/jest.config.js +124 -0
  34. package/frigg-cli/package.json +63 -0
  35. package/frigg-cli/repair-command/index.js +564 -0
  36. package/frigg-cli/start-command/index.js +125 -6
  37. package/frigg-cli/start-command/start-command.test.js +297 -0
  38. package/frigg-cli/test/init-command.test.js +180 -0
  39. package/frigg-cli/test/npm-registry.test.js +319 -0
  40. package/frigg-cli/ui-command/index.js +154 -0
  41. package/frigg-cli/utils/app-resolver.js +319 -0
  42. package/frigg-cli/utils/backend-path.js +16 -17
  43. package/frigg-cli/utils/database-validator.js +167 -0
  44. package/frigg-cli/utils/error-messages.js +329 -0
  45. package/frigg-cli/utils/npm-registry.js +167 -0
  46. package/frigg-cli/utils/process-manager.js +199 -0
  47. package/frigg-cli/utils/repo-detection.js +405 -0
  48. package/infrastructure/ARCHITECTURE.md +487 -0
  49. package/infrastructure/CLAUDE.md +481 -0
  50. package/infrastructure/HEALTH.md +468 -0
  51. package/infrastructure/README.md +522 -0
  52. package/infrastructure/__tests__/fixtures/mock-aws-resources.js +391 -0
  53. package/infrastructure/__tests__/helpers/test-utils.js +277 -0
  54. package/infrastructure/__tests__/postgres-config.test.js +914 -0
  55. package/infrastructure/__tests__/template-generation.test.js +687 -0
  56. package/infrastructure/create-frigg-infrastructure.js +129 -20
  57. package/infrastructure/docs/POSTGRES-CONFIGURATION.md +630 -0
  58. package/infrastructure/docs/PRE-DEPLOYMENT-HEALTH-CHECK-SPEC.md +1317 -0
  59. package/infrastructure/docs/WEBSOCKET-CONFIGURATION.md +105 -0
  60. package/infrastructure/docs/deployment-instructions.md +268 -0
  61. package/infrastructure/docs/generate-iam-command.md +278 -0
  62. package/infrastructure/docs/iam-policy-templates.md +193 -0
  63. package/infrastructure/domains/database/aurora-builder.js +809 -0
  64. package/infrastructure/domains/database/aurora-builder.test.js +950 -0
  65. package/infrastructure/domains/database/aurora-discovery.js +87 -0
  66. package/infrastructure/domains/database/aurora-discovery.test.js +188 -0
  67. package/infrastructure/domains/database/aurora-resolver.js +210 -0
  68. package/infrastructure/domains/database/aurora-resolver.test.js +347 -0
  69. package/infrastructure/domains/database/migration-builder.js +701 -0
  70. package/infrastructure/domains/database/migration-builder.test.js +321 -0
  71. package/infrastructure/domains/database/migration-resolver.js +163 -0
  72. package/infrastructure/domains/database/migration-resolver.test.js +337 -0
  73. package/infrastructure/domains/health/application/ports/IPropertyReconciler.js +164 -0
  74. package/infrastructure/domains/health/application/ports/IResourceDetector.js +129 -0
  75. package/infrastructure/domains/health/application/ports/IResourceImporter.js +142 -0
  76. package/infrastructure/domains/health/application/ports/IStackRepository.js +131 -0
  77. package/infrastructure/domains/health/application/ports/index.js +26 -0
  78. package/infrastructure/domains/health/application/use-cases/__tests__/execute-resource-import-use-case.test.js +679 -0
  79. package/infrastructure/domains/health/application/use-cases/__tests__/mismatch-analyzer-method-name.test.js +167 -0
  80. package/infrastructure/domains/health/application/use-cases/__tests__/repair-via-import-use-case.test.js +1130 -0
  81. package/infrastructure/domains/health/application/use-cases/execute-resource-import-use-case.js +221 -0
  82. package/infrastructure/domains/health/application/use-cases/reconcile-properties-use-case.js +152 -0
  83. package/infrastructure/domains/health/application/use-cases/reconcile-properties-use-case.test.js +343 -0
  84. package/infrastructure/domains/health/application/use-cases/repair-via-import-use-case.js +535 -0
  85. package/infrastructure/domains/health/application/use-cases/repair-via-import-use-case.test.js +376 -0
  86. package/infrastructure/domains/health/application/use-cases/run-health-check-use-case.js +213 -0
  87. package/infrastructure/domains/health/application/use-cases/run-health-check-use-case.test.js +441 -0
  88. package/infrastructure/domains/health/docs/ACME-DEV-DRIFT-ANALYSIS.md +267 -0
  89. package/infrastructure/domains/health/docs/BUILD-VS-DEPLOYED-TEMPLATE-ANALYSIS.md +324 -0
  90. package/infrastructure/domains/health/docs/ORPHAN-DETECTION-ANALYSIS.md +386 -0
  91. package/infrastructure/domains/health/docs/SPEC-CLEANUP-COMMAND.md +1419 -0
  92. package/infrastructure/domains/health/docs/TDD-IMPLEMENTATION-SUMMARY.md +391 -0
  93. package/infrastructure/domains/health/docs/TEMPLATE-COMPARISON-IMPLEMENTATION.md +551 -0
  94. package/infrastructure/domains/health/domain/entities/issue.js +299 -0
  95. package/infrastructure/domains/health/domain/entities/issue.test.js +528 -0
  96. package/infrastructure/domains/health/domain/entities/property-mismatch.js +108 -0
  97. package/infrastructure/domains/health/domain/entities/property-mismatch.test.js +275 -0
  98. package/infrastructure/domains/health/domain/entities/resource.js +159 -0
  99. package/infrastructure/domains/health/domain/entities/resource.test.js +432 -0
  100. package/infrastructure/domains/health/domain/entities/stack-health-report.js +306 -0
  101. package/infrastructure/domains/health/domain/entities/stack-health-report.test.js +601 -0
  102. package/infrastructure/domains/health/domain/services/__tests__/health-score-percentage-based.test.js +380 -0
  103. package/infrastructure/domains/health/domain/services/__tests__/import-progress-monitor.test.js +971 -0
  104. package/infrastructure/domains/health/domain/services/__tests__/import-template-generator.test.js +1150 -0
  105. package/infrastructure/domains/health/domain/services/__tests__/logical-id-mapper.test.js +672 -0
  106. package/infrastructure/domains/health/domain/services/__tests__/template-parser.test.js +496 -0
  107. package/infrastructure/domains/health/domain/services/__tests__/update-progress-monitor.test.js +419 -0
  108. package/infrastructure/domains/health/domain/services/health-score-calculator.js +248 -0
  109. package/infrastructure/domains/health/domain/services/health-score-calculator.test.js +504 -0
  110. package/infrastructure/domains/health/domain/services/import-progress-monitor.js +195 -0
  111. package/infrastructure/domains/health/domain/services/import-template-generator.js +435 -0
  112. package/infrastructure/domains/health/domain/services/logical-id-mapper.js +345 -0
  113. package/infrastructure/domains/health/domain/services/mismatch-analyzer.js +234 -0
  114. package/infrastructure/domains/health/domain/services/mismatch-analyzer.test.js +431 -0
  115. package/infrastructure/domains/health/domain/services/property-mutability-config.js +382 -0
  116. package/infrastructure/domains/health/domain/services/template-parser.js +245 -0
  117. package/infrastructure/domains/health/domain/services/update-progress-monitor.js +192 -0
  118. package/infrastructure/domains/health/domain/value-objects/health-score.js +138 -0
  119. package/infrastructure/domains/health/domain/value-objects/health-score.test.js +267 -0
  120. package/infrastructure/domains/health/domain/value-objects/property-mutability.js +161 -0
  121. package/infrastructure/domains/health/domain/value-objects/property-mutability.test.js +198 -0
  122. package/infrastructure/domains/health/domain/value-objects/resource-state.js +167 -0
  123. package/infrastructure/domains/health/domain/value-objects/resource-state.test.js +196 -0
  124. package/infrastructure/domains/health/domain/value-objects/stack-identifier.js +192 -0
  125. package/infrastructure/domains/health/domain/value-objects/stack-identifier.test.js +262 -0
  126. package/infrastructure/domains/health/infrastructure/adapters/__tests__/orphan-detection-cfn-tagged.test.js +312 -0
  127. package/infrastructure/domains/health/infrastructure/adapters/__tests__/orphan-detection-multi-stack.test.js +367 -0
  128. package/infrastructure/domains/health/infrastructure/adapters/__tests__/orphan-detection-relationship-analysis.test.js +432 -0
  129. package/infrastructure/domains/health/infrastructure/adapters/aws-property-reconciler.js +784 -0
  130. package/infrastructure/domains/health/infrastructure/adapters/aws-property-reconciler.test.js +1133 -0
  131. package/infrastructure/domains/health/infrastructure/adapters/aws-resource-detector.js +565 -0
  132. package/infrastructure/domains/health/infrastructure/adapters/aws-resource-detector.test.js +554 -0
  133. package/infrastructure/domains/health/infrastructure/adapters/aws-resource-importer.js +318 -0
  134. package/infrastructure/domains/health/infrastructure/adapters/aws-resource-importer.test.js +398 -0
  135. package/infrastructure/domains/health/infrastructure/adapters/aws-stack-repository.js +777 -0
  136. package/infrastructure/domains/health/infrastructure/adapters/aws-stack-repository.test.js +580 -0
  137. package/infrastructure/domains/integration/integration-builder.js +404 -0
  138. package/infrastructure/domains/integration/integration-builder.test.js +690 -0
  139. package/infrastructure/domains/integration/integration-resolver.js +170 -0
  140. package/infrastructure/domains/integration/integration-resolver.test.js +369 -0
  141. package/infrastructure/domains/integration/websocket-builder.js +69 -0
  142. package/infrastructure/domains/integration/websocket-builder.test.js +195 -0
  143. package/infrastructure/domains/networking/vpc-builder.js +2051 -0
  144. package/infrastructure/domains/networking/vpc-builder.test.js +1960 -0
  145. package/infrastructure/domains/networking/vpc-discovery.js +177 -0
  146. package/infrastructure/domains/networking/vpc-discovery.test.js +350 -0
  147. package/infrastructure/domains/networking/vpc-resolver.js +505 -0
  148. package/infrastructure/domains/networking/vpc-resolver.test.js +801 -0
  149. package/infrastructure/domains/parameters/ssm-builder.js +79 -0
  150. package/infrastructure/domains/parameters/ssm-builder.test.js +189 -0
  151. package/infrastructure/domains/parameters/ssm-discovery.js +84 -0
  152. package/infrastructure/domains/parameters/ssm-discovery.test.js +210 -0
  153. package/infrastructure/domains/security/iam-generator.js +816 -0
  154. package/infrastructure/domains/security/iam-generator.test.js +204 -0
  155. package/infrastructure/domains/security/kms-builder.js +415 -0
  156. package/infrastructure/domains/security/kms-builder.test.js +392 -0
  157. package/infrastructure/domains/security/kms-discovery.js +80 -0
  158. package/infrastructure/domains/security/kms-discovery.test.js +177 -0
  159. package/infrastructure/domains/security/kms-resolver.js +96 -0
  160. package/infrastructure/domains/security/kms-resolver.test.js +216 -0
  161. package/infrastructure/domains/security/templates/frigg-deployment-iam-stack.yaml +401 -0
  162. package/infrastructure/domains/security/templates/iam-policy-basic.json +218 -0
  163. package/infrastructure/domains/security/templates/iam-policy-full.json +288 -0
  164. package/infrastructure/domains/shared/base-builder.js +112 -0
  165. package/infrastructure/domains/shared/base-resolver.js +186 -0
  166. package/infrastructure/domains/shared/base-resolver.test.js +305 -0
  167. package/infrastructure/domains/shared/builder-orchestrator.js +212 -0
  168. package/infrastructure/domains/shared/builder-orchestrator.test.js +213 -0
  169. package/infrastructure/domains/shared/cloudformation-discovery-v2.js +334 -0
  170. package/infrastructure/domains/shared/cloudformation-discovery.js +672 -0
  171. package/infrastructure/domains/shared/cloudformation-discovery.test.js +985 -0
  172. package/infrastructure/domains/shared/environment-builder.js +119 -0
  173. package/infrastructure/domains/shared/environment-builder.test.js +247 -0
  174. package/infrastructure/domains/shared/providers/aws-provider-adapter.js +579 -0
  175. package/infrastructure/domains/shared/providers/aws-provider-adapter.test.js +416 -0
  176. package/infrastructure/domains/shared/providers/azure-provider-adapter.stub.js +93 -0
  177. package/infrastructure/domains/shared/providers/cloud-provider-adapter.js +136 -0
  178. package/infrastructure/domains/shared/providers/gcp-provider-adapter.stub.js +82 -0
  179. package/infrastructure/domains/shared/providers/provider-factory.js +108 -0
  180. package/infrastructure/domains/shared/providers/provider-factory.test.js +170 -0
  181. package/infrastructure/domains/shared/resource-discovery.enhanced.test.js +306 -0
  182. package/infrastructure/domains/shared/resource-discovery.js +233 -0
  183. package/infrastructure/domains/shared/resource-discovery.test.js +588 -0
  184. package/infrastructure/domains/shared/types/app-definition.js +205 -0
  185. package/infrastructure/domains/shared/types/discovery-result.js +106 -0
  186. package/infrastructure/domains/shared/types/discovery-result.test.js +258 -0
  187. package/infrastructure/domains/shared/types/index.js +46 -0
  188. package/infrastructure/domains/shared/types/resource-ownership.js +108 -0
  189. package/infrastructure/domains/shared/types/resource-ownership.test.js +101 -0
  190. package/infrastructure/domains/shared/utilities/base-definition-factory.js +394 -0
  191. package/infrastructure/domains/shared/utilities/base-definition-factory.js.bak +338 -0
  192. package/infrastructure/domains/shared/utilities/base-definition-factory.test.js +291 -0
  193. package/infrastructure/domains/shared/utilities/handler-path-resolver.js +134 -0
  194. package/infrastructure/domains/shared/utilities/handler-path-resolver.test.js +268 -0
  195. package/infrastructure/domains/shared/utilities/prisma-layer-manager.js +159 -0
  196. package/infrastructure/domains/shared/utilities/prisma-layer-manager.test.js +444 -0
  197. package/infrastructure/domains/shared/validation/env-validator.js +78 -0
  198. package/infrastructure/domains/shared/validation/env-validator.test.js +173 -0
  199. package/infrastructure/domains/shared/validation/plugin-validator.js +187 -0
  200. package/infrastructure/domains/shared/validation/plugin-validator.test.js +323 -0
  201. package/infrastructure/esbuild.config.js +53 -0
  202. package/infrastructure/infrastructure-composer.js +117 -0
  203. package/infrastructure/infrastructure-composer.test.js +1895 -0
  204. package/infrastructure/integration.test.js +383 -0
  205. package/infrastructure/scripts/build-prisma-layer.js +701 -0
  206. package/infrastructure/scripts/build-prisma-layer.test.js +170 -0
  207. package/infrastructure/scripts/build-time-discovery.js +238 -0
  208. package/infrastructure/scripts/build-time-discovery.test.js +379 -0
  209. package/infrastructure/scripts/run-discovery.js +110 -0
  210. package/infrastructure/scripts/verify-prisma-layer.js +72 -0
  211. package/layers/prisma/.build-complete +3 -0
  212. package/layers/prisma/nodejs/package.json +8 -0
  213. package/management-ui/.eslintrc.js +22 -0
  214. package/management-ui/README.md +203 -0
  215. package/management-ui/components.json +21 -0
  216. package/management-ui/docs/phase2-integration-guide.md +320 -0
  217. package/management-ui/index.html +13 -0
  218. package/management-ui/package.json +76 -0
  219. package/management-ui/packages/devtools/frigg-cli/ui-command/index.js +302 -0
  220. package/management-ui/postcss.config.js +6 -0
  221. package/management-ui/server/api/backend.js +256 -0
  222. package/management-ui/server/api/cli.js +315 -0
  223. package/management-ui/server/api/codegen.js +663 -0
  224. package/management-ui/server/api/connections.js +857 -0
  225. package/management-ui/server/api/discovery.js +185 -0
  226. package/management-ui/server/api/environment/index.js +1 -0
  227. package/management-ui/server/api/environment/router.js +378 -0
  228. package/management-ui/server/api/environment.js +328 -0
  229. package/management-ui/server/api/integrations.js +876 -0
  230. package/management-ui/server/api/logs.js +248 -0
  231. package/management-ui/server/api/monitoring.js +282 -0
  232. package/management-ui/server/api/open-ide.js +31 -0
  233. package/management-ui/server/api/project.js +1029 -0
  234. package/management-ui/server/api/users/sessions.js +371 -0
  235. package/management-ui/server/api/users/simulation.js +254 -0
  236. package/management-ui/server/api/users.js +362 -0
  237. package/management-ui/server/api-contract.md +275 -0
  238. package/management-ui/server/index.js +873 -0
  239. package/management-ui/server/middleware/errorHandler.js +93 -0
  240. package/management-ui/server/middleware/security.js +32 -0
  241. package/management-ui/server/processManager.js +296 -0
  242. package/management-ui/server/server.js +346 -0
  243. package/management-ui/server/services/aws-monitor.js +413 -0
  244. package/management-ui/server/services/npm-registry.js +347 -0
  245. package/management-ui/server/services/template-engine.js +538 -0
  246. package/management-ui/server/utils/cliIntegration.js +220 -0
  247. package/management-ui/server/utils/environment/auditLogger.js +471 -0
  248. package/management-ui/server/utils/environment/awsParameterStore.js +275 -0
  249. package/management-ui/server/utils/environment/encryption.js +278 -0
  250. package/management-ui/server/utils/environment/envFileManager.js +286 -0
  251. package/management-ui/server/utils/import-commonjs.js +28 -0
  252. package/management-ui/server/utils/response.js +83 -0
  253. package/management-ui/server/websocket/handler.js +325 -0
  254. package/management-ui/src/App.jsx +25 -0
  255. package/management-ui/src/assets/FriggLogo.svg +1 -0
  256. package/management-ui/src/components/AppRouter.jsx +65 -0
  257. package/management-ui/src/components/Button.jsx +70 -0
  258. package/management-ui/src/components/Card.jsx +97 -0
  259. package/management-ui/src/components/EnvironmentCompare.jsx +400 -0
  260. package/management-ui/src/components/EnvironmentEditor.jsx +372 -0
  261. package/management-ui/src/components/EnvironmentImportExport.jsx +469 -0
  262. package/management-ui/src/components/EnvironmentSchema.jsx +491 -0
  263. package/management-ui/src/components/EnvironmentSecurity.jsx +463 -0
  264. package/management-ui/src/components/ErrorBoundary.jsx +73 -0
  265. package/management-ui/src/components/IntegrationCard.jsx +481 -0
  266. package/management-ui/src/components/IntegrationCardEnhanced.jsx +770 -0
  267. package/management-ui/src/components/IntegrationExplorer.jsx +379 -0
  268. package/management-ui/src/components/IntegrationStatus.jsx +336 -0
  269. package/management-ui/src/components/Layout.jsx +716 -0
  270. package/management-ui/src/components/LoadingSpinner.jsx +113 -0
  271. package/management-ui/src/components/RepositoryPicker.jsx +248 -0
  272. package/management-ui/src/components/SessionMonitor.jsx +350 -0
  273. package/management-ui/src/components/StatusBadge.jsx +208 -0
  274. package/management-ui/src/components/UserContextSwitcher.jsx +212 -0
  275. package/management-ui/src/components/UserSimulation.jsx +327 -0
  276. package/management-ui/src/components/Welcome.jsx +434 -0
  277. package/management-ui/src/components/codegen/APIEndpointGenerator.jsx +637 -0
  278. package/management-ui/src/components/codegen/APIModuleSelector.jsx +227 -0
  279. package/management-ui/src/components/codegen/CodeGenerationWizard.jsx +247 -0
  280. package/management-ui/src/components/codegen/CodePreviewEditor.jsx +316 -0
  281. package/management-ui/src/components/codegen/DynamicModuleForm.jsx +271 -0
  282. package/management-ui/src/components/codegen/FormBuilder.jsx +737 -0
  283. package/management-ui/src/components/codegen/IntegrationGenerator.jsx +855 -0
  284. package/management-ui/src/components/codegen/ProjectScaffoldWizard.jsx +797 -0
  285. package/management-ui/src/components/codegen/SchemaBuilder.jsx +303 -0
  286. package/management-ui/src/components/codegen/TemplateSelector.jsx +586 -0
  287. package/management-ui/src/components/codegen/index.js +10 -0
  288. package/management-ui/src/components/connections/ConnectionConfigForm.jsx +362 -0
  289. package/management-ui/src/components/connections/ConnectionHealthMonitor.jsx +182 -0
  290. package/management-ui/src/components/connections/ConnectionTester.jsx +200 -0
  291. package/management-ui/src/components/connections/EntityRelationshipMapper.jsx +292 -0
  292. package/management-ui/src/components/connections/OAuthFlow.jsx +204 -0
  293. package/management-ui/src/components/connections/index.js +5 -0
  294. package/management-ui/src/components/index.js +21 -0
  295. package/management-ui/src/components/monitoring/APIGatewayMetrics.jsx +222 -0
  296. package/management-ui/src/components/monitoring/LambdaMetrics.jsx +169 -0
  297. package/management-ui/src/components/monitoring/MetricsChart.jsx +197 -0
  298. package/management-ui/src/components/monitoring/MonitoringDashboard.jsx +393 -0
  299. package/management-ui/src/components/monitoring/SQSMetrics.jsx +246 -0
  300. package/management-ui/src/components/monitoring/index.js +6 -0
  301. package/management-ui/src/components/monitoring/monitoring.css +218 -0
  302. package/management-ui/src/components/theme-provider.jsx +52 -0
  303. package/management-ui/src/components/theme-toggle.jsx +39 -0
  304. package/management-ui/src/components/ui/badge.tsx +36 -0
  305. package/management-ui/src/components/ui/button.test.jsx +56 -0
  306. package/management-ui/src/components/ui/button.tsx +57 -0
  307. package/management-ui/src/components/ui/card.tsx +76 -0
  308. package/management-ui/src/components/ui/dropdown-menu.tsx +199 -0
  309. package/management-ui/src/components/ui/select.tsx +157 -0
  310. package/management-ui/src/components/ui/skeleton.jsx +15 -0
  311. package/management-ui/src/hooks/useFrigg.jsx +387 -0
  312. package/management-ui/src/hooks/useSocket.jsx +58 -0
  313. package/management-ui/src/index.css +193 -0
  314. package/management-ui/src/lib/utils.ts +6 -0
  315. package/management-ui/src/main.jsx +10 -0
  316. package/management-ui/src/pages/CodeGeneration.jsx +14 -0
  317. package/management-ui/src/pages/Connections.jsx +252 -0
  318. package/management-ui/src/pages/ConnectionsEnhanced.jsx +633 -0
  319. package/management-ui/src/pages/Dashboard.jsx +311 -0
  320. package/management-ui/src/pages/Environment.jsx +314 -0
  321. package/management-ui/src/pages/IntegrationConfigure.jsx +669 -0
  322. package/management-ui/src/pages/IntegrationDiscovery.jsx +567 -0
  323. package/management-ui/src/pages/IntegrationTest.jsx +742 -0
  324. package/management-ui/src/pages/Integrations.jsx +253 -0
  325. package/management-ui/src/pages/Monitoring.jsx +17 -0
  326. package/management-ui/src/pages/Simulation.jsx +155 -0
  327. package/management-ui/src/pages/Users.jsx +492 -0
  328. package/management-ui/src/services/api.js +41 -0
  329. package/management-ui/src/services/apiModuleService.js +193 -0
  330. package/management-ui/src/services/websocket-handlers.js +120 -0
  331. package/management-ui/src/test/api/project.test.js +273 -0
  332. package/management-ui/src/test/components/Welcome.test.jsx +378 -0
  333. package/management-ui/src/test/mocks/server.js +178 -0
  334. package/management-ui/src/test/setup.js +61 -0
  335. package/management-ui/src/test/utils/test-utils.jsx +134 -0
  336. package/management-ui/src/utils/repository.js +98 -0
  337. package/management-ui/src/utils/repository.test.js +118 -0
  338. package/management-ui/src/workflows/phase2-integration-workflows.js +884 -0
  339. package/management-ui/tailwind.config.js +63 -0
  340. package/management-ui/tsconfig.json +37 -0
  341. package/management-ui/tsconfig.node.json +10 -0
  342. package/management-ui/vite.config.js +26 -0
  343. package/management-ui/vitest.config.js +38 -0
  344. package/package.json +35 -14
  345. package/test/index.js +2 -4
  346. package/test/mock-integration.js +4 -14
  347. package/infrastructure/app-handler-helpers.js +0 -57
  348. package/infrastructure/backend-utils.js +0 -87
  349. package/infrastructure/routers/auth.js +0 -26
  350. package/infrastructure/routers/integration-defined-routers.js +0 -42
  351. package/infrastructure/routers/middleware/loadUser.js +0 -15
  352. package/infrastructure/routers/middleware/requireLoggedInUser.js +0 -12
  353. package/infrastructure/routers/user.js +0 -41
  354. package/infrastructure/routers/websocket.js +0 -55
  355. package/infrastructure/serverless-template.js +0 -291
  356. package/infrastructure/workers/integration-defined-workers.js +0 -24
  357. package/test/auther-definition-tester.js +0 -125
@@ -0,0 +1,1289 @@
1
+ # Frigg CLI - Complete Documentation
2
+
3
+ ## Overview
4
+
5
+ The Frigg CLI provides tools for building, deploying, and managing serverless integrations on cloud platforms. Built with Domain-Driven Design and Hexagonal Architecture for multi-cloud extensibility.
6
+
7
+ ---
8
+
9
+ ## Command Reference
10
+
11
+ ### Core Commands
12
+
13
+ #### `frigg init [options]`
14
+
15
+ **Status:** To be documented (command may not be merged yet)
16
+
17
+ Initialize a new Frigg application with scaffolding and configuration.
18
+
19
+ **Usage:**
20
+ ```bash
21
+ frigg init
22
+ frigg init my-app
23
+ frigg init --template typescript
24
+ ```
25
+
26
+ **What it does:**
27
+ - TBD - Full documentation pending implementation merge
28
+
29
+ **Options:**
30
+ - TBD
31
+
32
+ **Example Output:**
33
+ - TBD
34
+
35
+ > **Note**: This command may be part of an upcoming release. Documentation will be updated once the implementation is merged to the main branch.
36
+
37
+ ---
38
+
39
+ #### `frigg install <module-name>`
40
+
41
+ Install and configure an API integration module from the Frigg module library.
42
+
43
+ **Usage:**
44
+ ```bash
45
+ frigg install hubspot
46
+ frigg install salesforce
47
+ frigg install stripe
48
+ ```
49
+
50
+ **What it does:**
51
+ - Searches the api-module-library for the specified integration
52
+ - Installs the npm package (@friggframework/api-module-{name})
53
+ - Adds integration to your app definition
54
+ - Configures OAuth flows and webhooks if applicable
55
+ - Creates integration-specific environment variable placeholders
56
+
57
+ **Options:**
58
+ - None currently (could add `--version`, `--registry` in future)
59
+
60
+ **Example Output:**
61
+ ```
62
+ 🔍 Finding integration module: hubspot
63
+ ✓ Found @friggframework/api-module-hubspot@2.0.5
64
+ 📦 Installing package...
65
+ ✓ Package installed successfully
66
+ 🔧 Configuring integration in app definition...
67
+ ✓ Integration configured
68
+ ⚙️ Next steps:
69
+ 1. Set HUBSPOT_CLIENT_ID in your environment
70
+ 2. Set HUBSPOT_CLIENT_SECRET in your environment
71
+ 3. Run 'frigg start' to test locally
72
+ ```
73
+
74
+ ---
75
+
76
+ #### `frigg search <term>`
77
+
78
+ Search for available API integration modules.
79
+
80
+ **Usage:**
81
+ ```bash
82
+ frigg search crm
83
+ frigg search payment
84
+ frigg search
85
+ ```
86
+
87
+ **What it does:**
88
+ - Queries the api-module-library directory
89
+ - Filters modules by name, description, or category
90
+ - Returns list of matching integrations with metadata
91
+
92
+ **Options:**
93
+ - None (searches all if no term provided)
94
+
95
+ **Example Output:**
96
+ ```
97
+ 📚 Available API Modules:
98
+
99
+ CRM Systems:
100
+ • hubspot - HubSpot CRM & Marketing automation
101
+ • salesforce - Salesforce CRM & Sales Cloud
102
+ • pipedrive - Pipedrive sales CRM
103
+
104
+ Payment Processing:
105
+ • stripe - Stripe payment processing
106
+ • square - Square payments & POS
107
+
108
+ Found 5 modules matching "crm"
109
+ ```
110
+
111
+ ---
112
+
113
+ #### `frigg start [options]`
114
+
115
+ Start local development server with hot reload.
116
+
117
+ **Usage:**
118
+ ```bash
119
+ frigg start
120
+ frigg start --stage dev
121
+ frigg start --verbose
122
+ frigg start --frontend
123
+ ```
124
+
125
+ **What it does:**
126
+ 1. Validates DATABASE_URL environment variable
127
+ 2. Detects database type (MongoDB or PostgreSQL)
128
+ 3. Checks Prisma client generation status
129
+ 4. Tests database connection
130
+ 5. Starts serverless-offline for backend
131
+ 6. Optionally starts frontend dev server
132
+
133
+ **Options:**
134
+ - `--stage <stage>` - Deployment stage (default: 'dev')
135
+ - `--verbose` - Enable verbose logging
136
+ - `--frontend` - Also start frontend dev server
137
+ - `--port <port>` - Backend port (default: 3000)
138
+ - `--frontend-port <port>` - Frontend port (default: 3001)
139
+
140
+ **Example Output:**
141
+ ```
142
+ 🚀 Starting Frigg application...
143
+ ✓ DATABASE_URL found
144
+ ✓ Database type: mongodb
145
+ ✓ Prisma client generated
146
+ ✓ Database connection successful
147
+
148
+ Starting backend and optional frontend...
149
+ Starting backend in /Users/dev/my-app/backend...
150
+
151
+ ╔═════════════════════════════════════════════════╗
152
+ ║ ║
153
+ ║ Serverless Offline listening on port 3000 ║
154
+ ║ ║
155
+ ╚═════════════════════════════════════════════════╝
156
+
157
+ endpoints:
158
+ GET - http://localhost:3000/health
159
+ POST - http://localhost:3000/api/authorize
160
+ POST - http://localhost:3000/api/webhook
161
+ ...
162
+ ```
163
+
164
+ **Database Checks:**
165
+ - Validates DATABASE_URL exists and is accessible
166
+ - Determines database type from connection string
167
+ - Verifies Prisma client is generated for the correct database
168
+ - Tests connection with timeout
169
+ - Provides helpful error messages for connection failures
170
+
171
+ ---
172
+
173
+ #### `frigg deploy [options]`
174
+
175
+ Deploy serverless infrastructure to cloud provider.
176
+
177
+ **Usage:**
178
+ ```bash
179
+ frigg deploy
180
+ frigg deploy --stage production
181
+ frigg deploy --region us-west-2
182
+ frigg deploy --force
183
+ frigg deploy --skip-env-validation
184
+ frigg deploy --skip-doctor # Skip health check (not recommended)
185
+ frigg deploy --no-interactive # CI/CD mode (no prompts, auto-repair safe issues)
186
+ ```
187
+
188
+ **What it does:**
189
+ 1. **Runs health check** (`frigg doctor`) to detect infrastructure issues
190
+ 2. **Auto-repairs safe issues** (or prompts for confirmation in interactive mode)
191
+ 3. **Fails if critical issues found** (unless `--skip-doctor` flag used)
192
+ 4. Loads app definition from index.js
193
+ 5. Validates required environment variables
194
+ 6. Discovers existing cloud resources (VPC, KMS, Aurora, etc.)
195
+ 7. Makes ownership decisions (resources managed in CloudFormation stack)
196
+ 8. Generates CloudFormation resources
197
+ 9. Generates serverless.yml configuration
198
+ 10. Executes `osls deploy` with filtered environment
199
+ 11. Creates/updates stack in cloud provider
200
+
201
+ **Options:**
202
+ - `--stage <stage>` - Deployment stage (default: 'dev')
203
+ - `--region <region>` - Cloud provider region (overrides app definition)
204
+ - `--force` - Force deployment even if no changes detected
205
+ - `--skip-env-validation` - Skip environment variable validation warnings
206
+ - `--skip-doctor` - Skip infrastructure health check ⚠️ Not recommended
207
+ - `--no-interactive` - Non-interactive mode for CI/CD (auto-repair safe issues, fail on risky changes)
208
+ - `--verbose` - Enable verbose logging
209
+
210
+ **Example Output:**
211
+ ```
212
+ 🔧 Loading environment configuration from appDefinition...
213
+ Found 3 environment variables: DATABASE_URL, JWT_SECRET, STRIPE_API_KEY
214
+
215
+ 🔍 Discovering existing infrastructure...
216
+
217
+ [VPC Builder] Discovering VPC resources...
218
+ Found VPC: vpc-0abc123def456 (existing in AWS)
219
+ 📋 Resource Ownership Decision: external - Using existing VPC vpc-0abc123def456
220
+ [VPC Builder] ✅ VPC configuration completed
221
+
222
+ [KMS Builder] Discovering KMS keys...
223
+ Found KMS key: alias/frigg-my-app-dev
224
+ 📋 Resource Ownership Decision: stack - Will create FriggKMSKey in stack
225
+ [KMS Builder] ✅ KMS configuration completed
226
+
227
+ [Aurora Builder] Discovering Aurora clusters...
228
+ No existing Aurora cluster found
229
+ 📋 Resource Ownership Decision: stack - Will create AuroraCluster in stack
230
+ [Aurora Builder] ✅ Aurora configuration completed
231
+
232
+ 🚀 Deploying serverless application...
233
+
234
+ Deploying my-app to stage dev (us-east-1)
235
+
236
+ Creating CloudFormation stack...
237
+ ✓ Stack created: my-app-dev
238
+ ✓ VPC endpoints configured
239
+ ✓ Aurora cluster created
240
+ ✓ Lambda functions deployed (12)
241
+ ✓ API Gateway configured
242
+ ✓ CloudWatch alarms created
243
+
244
+ Stack Outputs:
245
+ ServiceEndpoint: https://abc123.execute-api.us-east-1.amazonaws.com/dev
246
+ AuroraEndpoint: my-app-dev.cluster-abc123.us-east-1.rds.amazonaws.com
247
+
248
+ Deployment completed in 3m 42s
249
+ ```
250
+
251
+ **Environment Variable Handling:**
252
+ - Passes only necessary environment variables to serverless (security)
253
+ - Includes AWS credentials (AWS_* prefix)
254
+ - Includes app-defined environment variables from definition
255
+ - Validates required variables exist
256
+ - Warns about missing optional variables
257
+
258
+ **Resource Ownership:**
259
+ - Resources can be marked as `STACK` (managed in CloudFormation) or `EXTERNAL` (use existing by ID)
260
+ - Default behavior: manage resources in CloudFormation stack for full lifecycle control
261
+ - Doctor/repair handles edge cases (orphaned resources, drift) before deployment
262
+ - Explicit ownership in app definition recommended for production
263
+
264
+ **CI/CD Deployment:**
265
+ - Use `--no-interactive` flag to prevent prompts
266
+ - Deployment will auto-fix safe issues (mutable property drift)
267
+ - Deployment will **fail fast** on risky issues (orphaned resources, immutable property changes)
268
+ - Prevents stack rollbacks and 2+ hour waits from bad deployments
269
+ - Returns non-zero exit code if issues require manual intervention
270
+
271
+ **Example CI/CD Pipeline:**
272
+ ```yaml
273
+ # GitHub Actions / GitLab CI / etc.
274
+ - name: Deploy to production
275
+ run: |
276
+ frigg deploy \
277
+ --stage production \
278
+ --no-interactive \
279
+ --skip-env-validation
280
+ env:
281
+ AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
282
+ AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
283
+ DATABASE_URL: ${{ secrets.DATABASE_URL }}
284
+ ```
285
+
286
+ ---
287
+
288
+ #### `frigg db:setup [options]`
289
+
290
+ Initialize database and Prisma configuration.
291
+
292
+ **Usage:**
293
+ ```bash
294
+ frigg db:setup
295
+ frigg db:setup --mongodb
296
+ frigg db:setup --postgresql
297
+ frigg db:setup --generate-only
298
+ ```
299
+
300
+ **What it does:**
301
+ 1. Detects database type (MongoDB, AWS DocumentDB, or PostgreSQL) from the app definition and `DATABASE_URL`
302
+ 2. Validates that `DATABASE_URL` exists and is not empty
303
+ 3. Generates the correct Prisma client (DocumentDB reuses the MongoDB client)
304
+ 4. Checks Prisma migration state for the selected database
305
+ 5. Runs `prisma migrate` for PostgreSQL or `prisma db push` for MongoDB/DocumentDB
306
+ 6. Prints next steps (database connectivity health checks now happen during `frigg start`)
307
+
308
+ **Options:**
309
+ - `--mongodb` - Force MongoDB-compatible configuration (also applies to AWS DocumentDB)
310
+ - `--postgresql` - Force PostgreSQL configuration
311
+ - `--generate-only` - Only generate Prisma client, don't push schema
312
+ - `--verbose` - Show detailed progress and Prisma output
313
+
314
+ **Example Output (MongoDB/DocumentDB):**
315
+ ```
316
+ 🗄️ Setting up database...
317
+ ✓ DATABASE_URL found
318
+ ✓ Database type detected: AWS DocumentDB (MongoDB-compatible)
319
+ ✓ Generating Prisma client for mongodb...
320
+ ✓ Prisma client generated successfully
321
+ ✓ Pushing schema to database...
322
+ ✓ Database schema synchronized
323
+
324
+ Database setup complete!
325
+ ```
326
+
327
+ > **AWS DocumentDB notes:** Use a MongoDB-style connection string that includes `tls=true`, `replicaSet=rs0`, and `retryWrites=false`. The CLI automatically treats `database.documentDB.enable` as MongoDB-compatible during setup.
328
+
329
+ **Error Handling:**
330
+ - Validates `DATABASE_URL` format for each database type
331
+ - Provides helpful error messages for:
332
+ - Connection timeout
333
+ - Invalid credentials
334
+ - Network issues
335
+ - Schema validation errors
336
+ - Suggests fixes based on error type
337
+
338
+ ---
339
+
340
+ #### `frigg generate <type> <name>`
341
+
342
+ Generate boilerplate code for integrations, handlers, or tests.
343
+
344
+ **Usage:**
345
+ ```bash
346
+ frigg generate integration shopify
347
+ frigg generate handler payment-webhook
348
+ frigg generate test integration-shopify
349
+ ```
350
+
351
+ **What it does:**
352
+ - Creates file structure from templates
353
+ - Generates TypeScript or JavaScript based on project
354
+ - Includes proper imports and exports
355
+ - Follows Frigg framework conventions
356
+ - Updates relevant configuration files
357
+
358
+ **Types:**
359
+ - `integration` - New integration module
360
+ - `handler` - API handler/route
361
+ - `test` - Test file
362
+ - `migration` - Database migration
363
+
364
+ **Options:**
365
+ - `--typescript` - Generate TypeScript files
366
+ - `--javascript` - Generate JavaScript files
367
+ - `--template <name>` - Use specific template
368
+
369
+ **Example Output:**
370
+ ```
371
+ ✨ Generating integration: shopify
372
+
373
+ Created files:
374
+ ✓ backend/integrations/shopify/index.js
375
+ ✓ backend/integrations/shopify/api.js
376
+ ✓ backend/integrations/shopify/config.js
377
+ ✓ backend/integrations/shopify/definition.js
378
+ ✓ backend/integrations/shopify/__tests__/integration.test.js
379
+
380
+ Updated files:
381
+ ✓ backend/index.js (added integration import)
382
+
383
+ Next steps:
384
+ 1. Configure OAuth settings in definition.js
385
+ 2. Implement API methods in api.js
386
+ 3. Add integration to app definition
387
+ 4. Run tests: npm test shopify
388
+ ```
389
+
390
+ ---
391
+
392
+ ### New Infrastructure Health Commands
393
+
394
+ #### `frigg doctor [options]`
395
+
396
+ **Status:** Planned (implementation in progress)
397
+
398
+ Run comprehensive health check on deployed infrastructure.
399
+
400
+ **Usage:**
401
+ ```bash
402
+ frigg doctor
403
+ frigg doctor --stack my-app-prod
404
+ frigg doctor --region us-west-2
405
+ frigg doctor --verbose
406
+ frigg doctor --format json
407
+ ```
408
+
409
+ **What it does:**
410
+ 1. Discovers resources in CloudFormation stack
411
+ 2. Discovers resources in cloud provider (AWS/GCP/Azure)
412
+ 3. Compares desired state (app definition) with actual state
413
+ 4. Detects infrastructure issues:
414
+ - **Orphaned Resources** - Resources exist in cloud but not in stack
415
+ - **Missing Resources** - Resources defined in stack but don't exist
416
+ - **Drifted Resources** - Properties differ between stack and actual
417
+ - **Property Mismatches** - Configuration drift on specific properties
418
+ 5. Calculates health score (0-100)
419
+ 6. Provides actionable remediation suggestions
420
+
421
+ **Options:**
422
+ - `--stack <name>` - CloudFormation stack name (default: from app definition)
423
+ - `--region <region>` - Cloud provider region
424
+ - `--format <format>` - Output format: `table` (default), `json`, `yaml`
425
+ - `--verbose` - Show detailed property comparisons
426
+ - `--check <domain>` - Check specific domain only: `vpc`, `kms`, `aurora`, `all`
427
+ - `--exit-code` - Exit with non-zero code if unhealthy (for CI/CD)
428
+
429
+ **Example Output:**
430
+
431
+ ```
432
+ 🩺 Running infrastructure health check...
433
+
434
+ Stack: my-app-prod (us-east-1)
435
+ Region: us-east-1
436
+ Account: 123456789012
437
+
438
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
439
+ HEALTH SCORE: 65 (degraded)
440
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
441
+
442
+ 📊 Resource Summary
443
+ ✓ 12 resources healthy
444
+ ⚠ 3 resources with warnings
445
+ ✗ 2 critical issues
446
+
447
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
448
+
449
+ 🔴 CRITICAL ISSUES (2)
450
+
451
+ [1] Orphaned Resource
452
+ Type: AWS::RDS::DBCluster
453
+ Physical ID: my-app-prod-aurora-cluster
454
+ Status: ORPHANED
455
+ Issue: Resource exists in AWS but not managed by CloudFormation stack
456
+ Impact: Stack doesn't track this resource. Manual deletion could break app.
457
+
458
+ Resolution: Run 'frigg repair --import' to import into stack
459
+
460
+ [2] Property Mismatch (Immutable)
461
+ Resource: ProductionBucket (AWS::S3::Bucket)
462
+ Property: BucketName
463
+ Expected: my-app-prod-bucket-v2
464
+ Actual: my-app-prod-bucket-v1
465
+ Mutability: IMMUTABLE
466
+ Impact: Requires resource replacement to fix
467
+
468
+ Resolution: Run 'frigg repair --reconcile' to plan replacement
469
+
470
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
471
+
472
+ ⚠️ WARNINGS (3)
473
+
474
+ [1] Property Drift (Mutable)
475
+ Resource: ProdVPC (AWS::EC2::VPC)
476
+ Property: Tags
477
+ Expected: [{"Key": "Environment", "Value": "production"}]
478
+ Actual: [{"Key": "Env", "Value": "prod"}]
479
+ Mutability: MUTABLE
480
+ Impact: Configuration drift - can be auto-fixed
481
+
482
+ Resolution: Run 'frigg repair --reconcile'
483
+
484
+ [2] Property Drift (Mutable)
485
+ Resource: FriggKMSKey (AWS::KMS::Key)
486
+ Property: EnableKeyRotation
487
+ Expected: true
488
+ Actual: false
489
+ Mutability: MUTABLE
490
+ Impact: Key rotation disabled - security risk
491
+
492
+ Resolution: Run 'frigg repair --reconcile'
493
+
494
+ [3] Missing Tag
495
+ Resource: LambdaExecutionRole (AWS::IAM::Role)
496
+ Expected Tag: CostCenter
497
+ Impact: Cost tracking incomplete
498
+
499
+ Resolution: Update app definition and redeploy
500
+
501
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
502
+
503
+ 💡 RECOMMENDATIONS
504
+
505
+ High Priority:
506
+ • Import orphaned Aurora cluster to prevent data loss
507
+ • Plan S3 bucket replacement (requires downtime)
508
+
509
+ Medium Priority:
510
+ • Fix 2 mutable property drifts
511
+ • Enable KMS key rotation for security
512
+
513
+ Low Priority:
514
+ • Add missing tags for cost tracking
515
+
516
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
517
+
518
+ Next steps:
519
+ 1. Review critical issues above
520
+ 2. Run 'frigg repair' to fix detected issues
521
+ 3. Re-run 'frigg doctor' to verify fixes
522
+
523
+ For detailed report: frigg doctor --format json > health-report.json
524
+ ```
525
+
526
+ **JSON Output** (with `--format json`):
527
+ ```json
528
+ {
529
+ "stack": {
530
+ "name": "my-app-prod",
531
+ "region": "us-east-1",
532
+ "accountId": "123456789012"
533
+ },
534
+ "healthScore": 65,
535
+ "assessment": "degraded",
536
+ "summary": {
537
+ "healthy": 12,
538
+ "warnings": 3,
539
+ "critical": 2,
540
+ "total": 17
541
+ },
542
+ "issues": [
543
+ {
544
+ "severity": "critical",
545
+ "type": "orphaned_resource",
546
+ "resource": {
547
+ "type": "AWS::RDS::DBCluster",
548
+ "physicalId": "my-app-prod-aurora-cluster",
549
+ "state": "ORPHANED"
550
+ },
551
+ "description": "Resource exists in AWS but not managed by stack",
552
+ "impact": "Stack doesn't track this resource",
553
+ "resolution": {
554
+ "command": "frigg repair --import",
555
+ "canAutoFix": true
556
+ }
557
+ },
558
+ {
559
+ "severity": "critical",
560
+ "type": "property_mismatch",
561
+ "resource": {
562
+ "logicalId": "ProductionBucket",
563
+ "type": "AWS::S3::Bucket",
564
+ "physicalId": "my-app-prod-bucket-v1"
565
+ },
566
+ "mismatch": {
567
+ "propertyPath": "Properties.BucketName",
568
+ "expected": "my-app-prod-bucket-v2",
569
+ "actual": "my-app-prod-bucket-v1",
570
+ "mutability": "IMMUTABLE"
571
+ },
572
+ "impact": "Requires resource replacement",
573
+ "resolution": {
574
+ "command": "frigg repair --reconcile",
575
+ "canAutoFix": false,
576
+ "requiresReplacement": true
577
+ }
578
+ }
579
+ ],
580
+ "recommendations": [
581
+ {
582
+ "priority": "high",
583
+ "action": "Import orphaned Aurora cluster",
584
+ "reason": "Prevent data loss"
585
+ },
586
+ {
587
+ "priority": "high",
588
+ "action": "Plan S3 bucket replacement",
589
+ "reason": "Requires downtime coordination"
590
+ }
591
+ ],
592
+ "timestamp": "2025-10-26T01:23:45.678Z"
593
+ }
594
+ ```
595
+
596
+ **Exit Codes** (with `--exit-code`):
597
+ - `0` - Healthy (score >= 80)
598
+ - `1` - Degraded (score 40-79)
599
+ - `2` - Unhealthy (score < 40)
600
+ - `3` - Error running health check
601
+
602
+ **Use Cases:**
603
+ - **Pre-deployment validation** - Run before deploy to catch issues
604
+ - **CI/CD health gates** - Fail pipeline if score below threshold
605
+ - **Scheduled audits** - Cron job to monitor infrastructure drift
606
+ - **Incident investigation** - Diagnose production issues
607
+ - **Compliance checks** - Verify security configurations
608
+
609
+ ---
610
+
611
+ #### `frigg repair [options]`
612
+
613
+ **Status:** Planned (implementation in progress)
614
+
615
+ Repair infrastructure issues detected by `frigg doctor`.
616
+
617
+ **Usage:**
618
+ ```bash
619
+ frigg repair # Interactive mode
620
+ frigg repair --import # Import orphaned resources
621
+ frigg repair --reconcile # Fix property mismatches
622
+ frigg repair --clean-deploy # Delete and recreate resources
623
+ frigg repair --auto # Auto-fix all fixable issues (CI/CD mode)
624
+ frigg repair --dry-run # Show what would be fixed
625
+ frigg repair --issue <id> # Fix specific issue only
626
+ ```
627
+
628
+ **What it does:**
629
+
630
+ **Import Mode** (`--import`):
631
+ 1. Discovers orphaned resources (exist in cloud, not in stack)
632
+ 2. Validates resources are importable
633
+ 3. Generates CloudFormation import change set
634
+ 4. Displays resources to be imported
635
+ 5. Confirms with user (unless --auto)
636
+ 6. Executes CloudFormation import operation
637
+ 7. Updates stack to track resources
638
+
639
+ **Reconcile Mode** (`--reconcile`):
640
+ 1. Detects property mismatches (drift)
641
+ 2. Categorizes by mutability:
642
+ - **Mutable** - Can update without replacement
643
+ - **Immutable** - Requires resource replacement
644
+ - **Conditional** - Depends on other properties
645
+ 3. Auto-fixes mutable properties
646
+ 4. Plans replacement for immutable properties
647
+ 5. Prompts for confirmation on destructive changes
648
+ 6. Executes updates via CloudFormation
649
+
650
+ **Clean Deploy Mode** (`--clean-deploy`):
651
+ 1. Identifies resources that can't be imported/reconciled
652
+ 2. Plans deletion of problematic resources
653
+ 3. Generates new resource definitions
654
+ 4. Confirms destructive operation
655
+ 5. Deletes old resources
656
+ 6. Creates new resources via CloudFormation
657
+ 7. Updates application references
658
+
659
+ **Options:**
660
+ - `--import` - Import orphaned resources into stack
661
+ - `--reconcile` - Fix property mismatches
662
+ - `--clean-deploy` - Delete and recreate resources
663
+ - `--auto` - Auto-fix without prompts (for CI/CD)
664
+ - `--dry-run` - Show planned changes without executing
665
+ - `--issue <id>` - Fix only specific issue from doctor report
666
+ - `--force` - Skip safety checks (dangerous!)
667
+ - `--backup` - Create backup before destructive operations
668
+
669
+ **Example Output:**
670
+
671
+ **Interactive Mode:**
672
+ ```
673
+ 🔧 Frigg Repair - Infrastructure Remediation
674
+
675
+ 🩺 Running health check first...
676
+ Found 5 issues to repair:
677
+ • 2 orphaned resources
678
+ • 2 property mismatches (mutable)
679
+ • 1 property mismatch (immutable)
680
+
681
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
682
+
683
+ What would you like to do?
684
+
685
+ [1] Import orphaned resources (2)
686
+ ├─ AWS::RDS::DBCluster - my-app-prod-aurora-cluster
687
+ └─ AWS::EC2::VPC - vpc-0abc123
688
+
689
+ [2] Fix mutable property drift (2) ⚡ Auto-fixable
690
+ ├─ ProdVPC: Tags property mismatch
691
+ └─ FriggKMSKey: EnableKeyRotation mismatch
692
+
693
+ [3] Plan immutable property replacement (1) ⚠️ Requires downtime
694
+ └─ ProductionBucket: BucketName mismatch
695
+
696
+ [4] Fix all auto-fixable issues
697
+ [5] Show detailed repair plan
698
+ [Q] Quit
699
+
700
+ Select option [1-5, Q]:
701
+ ```
702
+
703
+ **After selecting option 1 (Import):**
704
+ ```
705
+ 🔍 Analyzing resources for import...
706
+
707
+ Resources to import:
708
+ ┌──────────────────────────────────────────────────────────────┐
709
+ │ Resource 1: Aurora Database Cluster │
710
+ ├──────────────────────────────────────────────────────────────┤
711
+ │ Type: AWS::RDS::DBCluster │
712
+ │ Physical ID: my-app-prod-aurora-cluster │
713
+ │ Logical ID: AuroraCluster (will be assigned) │
714
+ │ Status: Ready for import │
715
+ │ Properties: Will be matched from existing resource │
716
+ └──────────────────────────────────────────────────────────────┘
717
+
718
+ ┌──────────────────────────────────────────────────────────────┐
719
+ │ Resource 2: VPC │
720
+ ├──────────────────────────────────────────────────────────────┤
721
+ │ Type: AWS::EC2::VPC │
722
+ │ Physical ID: vpc-0abc123 │
723
+ │ Logical ID: ProdVPC (will be assigned) │
724
+ │ Status: Ready for import │
725
+ │ Properties: Will be matched from existing resource │
726
+ └──────────────────────────────────────────────────────────────┘
727
+
728
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
729
+
730
+ ⚠️ IMPORTANT: CloudFormation Import Requirements
731
+
732
+ ✓ Resources must be in a stable state
733
+ ✓ Resources must be importable resource types
734
+ ✓ Stack must be in UPDATE_COMPLETE or CREATE_COMPLETE state
735
+ ✓ Import operation cannot be rolled back
736
+
737
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
738
+
739
+ Proceed with import? [y/N]: y
740
+
741
+ Creating CloudFormation change set for import...
742
+ ✓ Change set created: import-2025-10-26-01-23-45
743
+
744
+ Reviewing change set...
745
+ ✓ Validation passed
746
+
747
+ Executing import operation...
748
+ [████████████████████████████████] 100% - Importing resources
749
+
750
+ ✓ AuroraCluster imported successfully
751
+ ✓ ProdVPC imported successfully
752
+
753
+ Import completed! Resources are now managed by CloudFormation.
754
+
755
+ Next steps:
756
+ • Run 'frigg doctor' to verify health improved
757
+ • Future deploys will manage these resources
758
+ ```
759
+
760
+ **After selecting option 2 (Fix Mutable Drift):**
761
+ ```
762
+ 🔄 Reconciling property mismatches...
763
+
764
+ Planned Updates:
765
+ ┌──────────────────────────────────────────────────────────────┐
766
+ │ Update 1: ProdVPC (AWS::EC2::VPC) │
767
+ ├──────────────────────────────────────────────────────────────┤
768
+ │ Property: Tags │
769
+ │ Current: [{"Key": "Env", "Value": "prod"}] │
770
+ │ Desired: [{"Key": "Environment", "Value": "production"}] │
771
+ │ Impact: No interruption │
772
+ │ Auto-fix: ✓ Yes │
773
+ └──────────────────────────────────────────────────────────────┘
774
+
775
+ ┌──────────────────────────────────────────────────────────────┐
776
+ │ Update 2: FriggKMSKey (AWS::KMS::Key) │
777
+ ├──────────────────────────────────────────────────────────────┤
778
+ │ Property: EnableKeyRotation │
779
+ │ Current: false │
780
+ │ Desired: true │
781
+ │ Impact: No interruption │
782
+ │ Auto-fix: ✓ Yes │
783
+ └──────────────────────────────────────────────────────────────┘
784
+
785
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
786
+
787
+ These changes are safe (no resource replacement required).
788
+
789
+ Proceed with updates? [y/N]: y
790
+
791
+ Applying updates via CloudFormation...
792
+ [████████████████████████████████] 100% - Updating stack
793
+
794
+ ✓ ProdVPC tags updated
795
+ ✓ FriggKMSKey rotation enabled
796
+
797
+ Property drift fixed! Stack now matches desired configuration.
798
+ ```
799
+
800
+ **Dry Run Mode** (`--dry-run`):
801
+ ```
802
+ 🔬 Repair Dry Run - No changes will be made
803
+
804
+ Detected Issues:
805
+ ✓ 2 orphaned resources → Would import via CloudFormation
806
+ ✓ 2 mutable property drifts → Would update properties
807
+ ✗ 1 immutable property drift → Requires manual intervention
808
+
809
+ Planned Actions:
810
+
811
+ [1] Import Resources
812
+ Command: aws cloudformation create-change-set \
813
+ --stack-name my-app-prod \
814
+ --change-set-type IMPORT \
815
+ --resources-to-import file://resources.json
816
+
817
+ [2] Update Properties
818
+ Update: ProdVPC.Tags
819
+ From: [{"Key": "Env", "Value": "prod"}]
820
+ To: [{"Key": "Environment", "Value": "production"}]
821
+
822
+ Update: FriggKMSKey.EnableKeyRotation
823
+ From: false
824
+ To: true
825
+
826
+ [3] Manual Action Required
827
+ Resource: ProductionBucket
828
+ Issue: BucketName is immutable
829
+ Current: my-app-prod-bucket-v1
830
+ Desired: my-app-prod-bucket-v2
831
+
832
+ Resolution steps:
833
+ 1. Create new bucket: my-app-prod-bucket-v2
834
+ 2. Copy data from old bucket to new bucket
835
+ 3. Update application configuration
836
+ 4. Delete old bucket: my-app-prod-bucket-v1
837
+ 5. Update CloudFormation stack
838
+
839
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
840
+
841
+ To execute repairs, run: frigg repair --auto
842
+ To execute specific issue: frigg repair --issue <id>
843
+ ```
844
+
845
+ **Exit Codes:**
846
+ - `0` - Repairs completed successfully
847
+ - `1` - Some repairs failed
848
+ - `2` - Repairs require manual intervention
849
+ - `3` - Error during repair operation
850
+
851
+ **Safety Features:**
852
+ - **Confirmation prompts** for destructive operations
853
+ - **Dry-run mode** to preview changes
854
+ - **Backup creation** before deletions
855
+ - **Rollback support** via CloudFormation
856
+ - **Validation** before import/update
857
+ - **Issue-specific** repair to limit blast radius
858
+
859
+ **Use Cases:**
860
+ - **Import unmanaged resources** - Bring existing infrastructure under CloudFormation management
861
+ - **Fix configuration drift** - Align actual state with desired state
862
+ - **Clean up orphaned resources** - Remove resources outside stack control
863
+ - **Remediate security issues** - Fix misconfigurations automatically
864
+ - **CI/CD integration** - Auto-repair in deployment pipelines
865
+
866
+ ---
867
+
868
+ ## Multi-Cloud Provider Support
869
+
870
+ ### Current Status
871
+ - **AWS**: Fully supported
872
+ - **GCP**: Planned
873
+ - **Azure**: Planned
874
+ - **Cloudflare**: Planned
875
+
876
+ ### Architecture for Multi-Cloud
877
+
878
+ The CLI uses Hexagonal Architecture (Ports & Adapters) to support multiple cloud providers:
879
+
880
+ **Domain Layer** (Provider-Agnostic):
881
+ ```
882
+ packages/devtools/infrastructure/domains/health/
883
+ domain/ # Pure domain logic (no provider specifics)
884
+ entities/ # Resource, Issue, StackHealthReport
885
+ value-objects/ # HealthScore, ResourceState, PropertyMutability
886
+ services/ # HealthScoreCalculator, DriftDetector
887
+
888
+ application/ # Use cases (orchestration)
889
+ use-cases/ # RunHealthCheck, RepairStack, ImportResource
890
+ ports/ # Interfaces for adapters
891
+ StackRepository.js # Port interface
892
+ ResourceDetector.js # Port interface
893
+ DriftDetector.js # Port interface
894
+ ```
895
+
896
+ **Infrastructure Layer** (Provider-Specific Adapters):
897
+ ```
898
+ packages/devtools/infrastructure/domains/health/
899
+ infrastructure/
900
+ adapters/
901
+ aws/ # AWS-specific implementations
902
+ AWSStackRepository.js # CloudFormation
903
+ AWSResourceDetector.js # AWS APIs (EC2, RDS, etc.)
904
+ AWSCloudFormationImporter.js # Import operations
905
+
906
+ gcp/ # GCP-specific implementations (future)
907
+ GCPStackRepository.js # Deployment Manager
908
+ GCPResourceDetector.js # GCP APIs
909
+ GCPDeploymentImporter.js
910
+
911
+ azure/ # Azure-specific implementations (future)
912
+ AzureStackRepository.js # ARM Templates
913
+ AzureResourceDetector.js # Azure APIs
914
+ AzureResourceImporter.js
915
+ ```
916
+
917
+ **Provider Selection**:
918
+ ```javascript
919
+ // App definition specifies provider
920
+ {
921
+ provider: 'aws', // or 'gcp', 'azure', 'cloudflare'
922
+ region: 'us-east-1',
923
+ // ... rest of definition
924
+ }
925
+
926
+ // CLI auto-selects correct adapter
927
+ const adapters = getAdaptersForProvider(appDefinition.provider);
928
+ const useCase = new RunHealthCheckUseCase({
929
+ stackRepository: adapters.stackRepository, // AWS/GCP/Azure
930
+ resourceDetector: adapters.resourceDetector, // Provider-specific
931
+ driftDetector: adapters.driftDetector, // Provider-specific
932
+ });
933
+ ```
934
+
935
+ **Provider-Specific Domains**:
936
+
937
+ Some infrastructure domains are inherently provider-specific:
938
+
939
+ ```
940
+ domains/
941
+ networking/
942
+ vpc-builder.js # AWS VPC
943
+ vnet-builder.js # Azure VNet (future)
944
+ network-builder.js # GCP Network (future)
945
+
946
+ database/
947
+ aurora-builder.js # AWS Aurora
948
+ cloud-sql-builder.js # GCP Cloud SQL (future)
949
+ cosmos-db-builder.js # Azure Cosmos DB (future)
950
+ ```
951
+
952
+ Builder orchestrator selects appropriate builders based on provider:
953
+ ```javascript
954
+ const orchestrator = new BuilderOrchestrator(
955
+ getBuilders(appDefinition.provider) // Returns AWS/GCP/Azure builders
956
+ );
957
+ ```
958
+
959
+ ---
960
+
961
+ ## Environment Variables
962
+
963
+ ### Required (varies by features used)
964
+
965
+ **Database:**
966
+ - `DATABASE_URL` - Connection string for MongoDB or PostgreSQL
967
+
968
+ **AWS Deployment:**
969
+ - `AWS_ACCESS_KEY_ID` - AWS access key
970
+ - `AWS_SECRET_ACCESS_KEY` - AWS secret key
971
+ - `AWS_REGION` - AWS region (or use --region flag)
972
+
973
+ **Encryption:**
974
+ - `KMS_KEY_ARN` - AWS KMS key ARN (or auto-discovered)
975
+ - `AES_KEY_ID` - AES key ID (if using AES encryption)
976
+ - `AES_KEY` - AES encryption key (32 characters)
977
+
978
+ **Optional:**
979
+ - `STAGE` - Deployment stage (default: 'dev')
980
+ - `FRIGG_SKIP_AWS_DISCOVERY` - Skip AWS resource discovery (speeds up local dev)
981
+ - `NODE_ENV` - Node environment (development, production, test)
982
+
983
+ ### App-Defined Variables
984
+
985
+ Additional environment variables can be defined in your app definition:
986
+
987
+ ```javascript
988
+ {
989
+ environment: {
990
+ JWT_SECRET: true, // Mark as required
991
+ STRIPE_API_KEY: true,
992
+ SENDGRID_API_KEY: true,
993
+ FEATURE_FLAG_X: true,
994
+ }
995
+ }
996
+ ```
997
+
998
+ These are validated during deploy and passed to Lambda functions.
999
+
1000
+ ---
1001
+
1002
+ ## Configuration Files
1003
+
1004
+ ### `index.js` (App Definition)
1005
+
1006
+ Entry point for your Frigg application:
1007
+
1008
+ ```javascript
1009
+ const { ModuleManager, IntegrationManager } = require('@friggframework/core');
1010
+ const HubSpotIntegration = require('@friggframework/api-module-hubspot');
1011
+
1012
+ const Definition = {
1013
+ name: 'my-integration-app',
1014
+ version: '1.0.0',
1015
+
1016
+ provider: 'aws',
1017
+ region: 'us-east-1',
1018
+
1019
+ integrations: [
1020
+ {
1021
+ Definition: HubSpotIntegration.Definition,
1022
+ ownership: {
1023
+ queue: 'STACK', // Create queue in CloudFormation
1024
+ },
1025
+ },
1026
+ ],
1027
+
1028
+ database: {
1029
+ type: 'mongodb',
1030
+ ownership: 'STACK', // Create Aurora in CloudFormation
1031
+ },
1032
+
1033
+ vpc: {
1034
+ ownership: 'EXTERNAL',
1035
+ vpcId: 'vpc-0abc123', // Use existing VPC
1036
+ },
1037
+
1038
+ kms: {
1039
+ ownership: 'STACK', // Create KMS key in CloudFormation
1040
+ },
1041
+
1042
+ encryption: {
1043
+ useDefaultKMSForFieldLevelEncryption: true,
1044
+ },
1045
+
1046
+ environment: {
1047
+ DATABASE_URL: true,
1048
+ JWT_SECRET: true,
1049
+ },
1050
+ };
1051
+
1052
+ module.exports = { Definition };
1053
+ ```
1054
+
1055
+ ### `infrastructure.js` (Generated)
1056
+
1057
+ This file is **generated** by the Frigg infrastructure composer and should not be edited manually. It's referenced by `osls deploy` command.
1058
+
1059
+ ---
1060
+
1061
+ ## Architecture Overview
1062
+
1063
+ ```
1064
+ ┌─────────────────────────────────────────────────────────┐
1065
+ │ Frigg CLI Commands │
1066
+ │ • frigg install • frigg deploy • frigg doctor │
1067
+ │ • frigg search • frigg start • frigg repair │
1068
+ │ • frigg generate • frigg db:setup │
1069
+ └───────────────┬─────────────────────────────────────────┘
1070
+
1071
+ ┌───────────────▼─────────────────────────────────────────┐
1072
+ │ Infrastructure Composer │
1073
+ │ packages/devtools/infrastructure/ │
1074
+ │ │
1075
+ │ • Loads app definition (index.js) │
1076
+ │ • Orchestrates domain builders │
1077
+ │ • Generates serverless configuration │
1078
+ └───────────────┬─────────────────────────────────────────┘
1079
+
1080
+ ┌───────────────▼─────────────────────────────────────────┐
1081
+ │ Domain Builders (Hexagonal Architecture) │
1082
+ │ │
1083
+ │ Discovery → Resolution → Building │
1084
+ │ │
1085
+ │ • VpcBuilder (networking) │
1086
+ │ • KmsBuilder (security) │
1087
+ │ • AuroraBuilder (database) │
1088
+ │ • MigrationBuilder (database) │
1089
+ │ • IntegrationBuilder (integration) │
1090
+ │ • SsmBuilder (parameters) │
1091
+ │ • WebsocketBuilder (integration) │
1092
+ └───────────────┬─────────────────────────────────────────┘
1093
+
1094
+ ┌───────────────▼─────────────────────────────────────────┐
1095
+ │ OSS-Serverless (Deployment) │
1096
+ │ • Packages Lambda functions │
1097
+ │ • Generates CloudFormation templates │
1098
+ │ • Deploys to AWS │
1099
+ └─────────────────────────────────────────────────────────┘
1100
+ ```
1101
+
1102
+ ---
1103
+
1104
+ ## Common Workflows
1105
+
1106
+ ### Initial Project Setup
1107
+
1108
+ ```bash
1109
+ # 1. Install integrations
1110
+ frigg install hubspot
1111
+ frigg install stripe
1112
+
1113
+ # 2. Set up database
1114
+ export DATABASE_URL="mongodb://localhost:27017/myapp"
1115
+ frigg db:setup
1116
+
1117
+ # 3. Start local development
1118
+ frigg start --frontend
1119
+
1120
+ # 4. Test integration flows locally
1121
+ # Visit http://localhost:3000
1122
+
1123
+ # 5. Deploy to dev
1124
+ frigg deploy --stage dev
1125
+
1126
+ # 6. Deploy to production
1127
+ frigg deploy --stage production
1128
+ ```
1129
+
1130
+ ### Infrastructure Health Workflow
1131
+
1132
+ ```bash
1133
+ # 1. Check infrastructure health
1134
+ frigg doctor --stage production
1135
+
1136
+ # 2. Review issues (health score, orphaned resources, drift)
1137
+
1138
+ # 3. Fix auto-fixable issues
1139
+ frigg repair --auto
1140
+
1141
+ # 4. Manually fix complex issues
1142
+ frigg repair --issue 3
1143
+
1144
+ # 5. Verify health improved
1145
+ frigg doctor --stage production
1146
+ ```
1147
+
1148
+ ### Troubleshooting Deployment Issues
1149
+
1150
+ ```bash
1151
+ # 1. Enable verbose logging
1152
+ frigg deploy --stage dev --verbose
1153
+
1154
+ # 2. Check for orphaned resources
1155
+ frigg doctor --verbose
1156
+
1157
+ # 3. Import orphaned resources
1158
+ frigg repair --import
1159
+
1160
+ # 4. Retry deployment
1161
+ frigg deploy --stage dev --force
1162
+ ```
1163
+
1164
+ ---
1165
+
1166
+ ## Exit Codes
1167
+
1168
+ All commands follow consistent exit code conventions:
1169
+
1170
+ - `0` - Success
1171
+ - `1` - General error
1172
+ - `2` - Configuration error
1173
+ - `3` - Network/API error
1174
+ - `4` - Validation error
1175
+ - `5` - User cancelled operation
1176
+
1177
+ ---
1178
+
1179
+ ## Getting Help
1180
+
1181
+ ```bash
1182
+ frigg --help # General help
1183
+ frigg <command> --help # Command-specific help
1184
+ frigg --version # Show version
1185
+ ```
1186
+
1187
+ **Community Support:**
1188
+ - GitHub Issues: https://github.com/friggframework/frigg/issues
1189
+ - Documentation: https://docs.friggframework.org
1190
+ - Slack: Join via https://friggframework.org/#contact
1191
+
1192
+ ---
1193
+
1194
+ ## Package Structure & Global Installation
1195
+
1196
+ ### Overview
1197
+
1198
+ The Frigg CLI is a standalone globally-installable npm package that can be installed via `npm i -g @friggframework/frigg-cli`. It includes version detection logic to automatically prefer local project installations when available.
1199
+
1200
+ ### Package Structure
1201
+
1202
+ **@friggframework/frigg-cli** (standalone package)
1203
+ ```
1204
+ ├── package.json
1205
+ │ ├── dependencies: @friggframework/core@^2.0.0-next.0
1206
+ │ ├── dependencies: @friggframework/devtools@^2.0.0-next.0
1207
+ │ └── publishConfig: { access: "public" }
1208
+ └── index.js (with version detection wrapper)
1209
+ ```
1210
+
1211
+ **Key Changes from Previous Structure:**
1212
+ - ✅ Replaced `workspace:*` with concrete versions (`^2.0.0-next.0`)
1213
+ - ✅ Added `@friggframework/devtools` as dependency
1214
+ - ✅ Added `publishConfig` for public npm publishing
1215
+ - ✅ Removed bin entry from devtools package.json
1216
+
1217
+ **Note:** Since `@friggframework/devtools` is a dependency, the global install size includes devtools. The main benefit is proper version resolution (no `workspace:*` errors) and automatic local CLI preference.
1218
+
1219
+ ### Version Detection Logic
1220
+
1221
+ When you run `frigg` (globally installed), the CLI:
1222
+
1223
+ 1. **Checks for skip flag**
1224
+ - If `FRIGG_CLI_SKIP_VERSION_CHECK=true`, skips detection (prevents recursion)
1225
+
1226
+ 2. **Looks for local installation**
1227
+ - Searches for `node_modules/@friggframework/frigg-cli` in current directory
1228
+
1229
+ 3. **Compares versions**
1230
+ - Uses `semver.compare(localVersion, globalVersion)`
1231
+
1232
+ 4. **Makes decision**:
1233
+ - **Local ≥ Global**: Uses local CLI (spawns subprocess)
1234
+ - **Global > Local**: Warns and uses global
1235
+ - **No local**: Uses global silently
1236
+
1237
+ ### Benefits
1238
+
1239
+ | Aspect | Before | After |
1240
+ |--------|--------|-------|
1241
+ | **Global Install** | `npm i -g @friggframework/devtools` | `npm i -g @friggframework/frigg-cli` |
1242
+ | **Dependencies** | workspace:* (broken) | Concrete versions (works) |
1243
+ | **Version Preference** | No detection | Automatic local preference |
1244
+ | **Version Warnings** | None | Mismatch alerts |
1245
+ | **Publishability** | ❌ Fails | ✅ Works |
1246
+ | **Local Project Isolation** | ❌ Uses global versions | ✅ Uses local versions when available |
1247
+
1248
+ ### Publishing Workflow
1249
+
1250
+ ```bash
1251
+ # Publish to npm
1252
+ cd packages/frigg-cli
1253
+ npm version patch # or minor, major
1254
+ npm publish
1255
+
1256
+ # Users can now install globally
1257
+ npm install -g @friggframework/frigg-cli
1258
+
1259
+ # And it will automatically use local versions when available
1260
+ ```
1261
+
1262
+ ### Migration Path
1263
+
1264
+ **For existing users:**
1265
+
1266
+ ```bash
1267
+ # Step 1: Uninstall old global devtools
1268
+ npm uninstall -g @friggframework/devtools
1269
+
1270
+ # Step 2: Install new global CLI
1271
+ npm install -g @friggframework/frigg-cli
1272
+
1273
+ # Step 3: Update local project dependencies
1274
+ npm install @friggframework/frigg-cli@latest
1275
+ ```
1276
+
1277
+ **For new projects:**
1278
+
1279
+ ```bash
1280
+ # Global CLI (once per machine)
1281
+ npm install -g @friggframework/frigg-cli
1282
+
1283
+ # Local project dependencies
1284
+ npx create-frigg-app my-app
1285
+ # (Will automatically include @friggframework/frigg-cli in package.json)
1286
+ ```
1287
+
1288
+ **Status:** ✅ Complete and tested (15 passing tests)
1289
+