@friggframework/devtools 2.0.0-next.5 → 2.0.0-next.51

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