@invictus-group-ai/orchestra 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (466) hide show
  1. package/LICENSE +21 -0
  2. package/LICENSING.md +49 -0
  3. package/README.md +507 -0
  4. package/assets/settings-template.json +99 -0
  5. package/bin/invi.js +6 -0
  6. package/content-dist/LICENSE +95 -0
  7. package/content-dist/PIPELINE.md +823 -0
  8. package/content-dist/README.md +128 -0
  9. package/content-dist/agents/README.md +135 -0
  10. package/content-dist/agents/mapping.json +476 -0
  11. package/content-dist/agents/stacks/backend-django.md +66 -0
  12. package/content-dist/agents/stacks/backend-dotnet.md +72 -0
  13. package/content-dist/agents/stacks/backend-fastapi.md +66 -0
  14. package/content-dist/agents/stacks/backend-laravel.md +66 -0
  15. package/content-dist/agents/stacks/backend-node.md +66 -0
  16. package/content-dist/agents/stacks/backend-spring.md +66 -0
  17. package/content-dist/agents/stacks/desktop-delphi.md +73 -0
  18. package/content-dist/agents/stacks/frontend-angular.md +65 -0
  19. package/content-dist/agents/stacks/frontend-react.md +67 -0
  20. package/content-dist/agents/stacks/frontend-svelte.md +67 -0
  21. package/content-dist/agents/stacks/frontend-vue.md +66 -0
  22. package/content-dist/agents/stacks/mobile-flutter.md +68 -0
  23. package/content-dist/agents/stacks/wordpress.md +66 -0
  24. package/content-dist/agents/universal/invi-qa.md +57 -0
  25. package/content-dist/agents/universal/invi-reviewer.md +61 -0
  26. package/content-dist/agents/universal/invi-security.md +55 -0
  27. package/content-dist/agents/universal/invi-tester.md +55 -0
  28. package/content-dist/agents/universal/invi-ui.md +85 -0
  29. package/content-dist/fragments/base.md +37 -0
  30. package/content-dist/fragments/domain/api-publica-rate-limiting.md +83 -0
  31. package/content-dist/fragments/domain/autenticacao-enterprise.md +86 -0
  32. package/content-dist/fragments/domain/busca-elasticsearch.md +86 -0
  33. package/content-dist/fragments/domain/dashboard-admin-rbac.md +80 -0
  34. package/content-dist/fragments/domain/design-system.md +71 -0
  35. package/content-dist/fragments/domain/ecommerce-completo.md +86 -0
  36. package/content-dist/fragments/domain/filas-jobs.md +80 -0
  37. package/content-dist/fragments/domain/integracao-crm-erp.md +82 -0
  38. package/content-dist/fragments/domain/lgpd.md +84 -0
  39. package/content-dist/fragments/domain/multi-tenancy.md +79 -0
  40. package/content-dist/fragments/domain/notificacoes-multicanal.md +81 -0
  41. package/content-dist/fragments/domain/pagamentos-brasil.md +85 -0
  42. package/content-dist/fragments/domain/plataforma-conteudo.md +77 -0
  43. package/content-dist/fragments/domain/realtime-websockets.md +92 -0
  44. package/content-dist/fragments/domain/relatorios-analytics.md +80 -0
  45. package/content-dist/fragments/domain/saas-stripe-billing.md +79 -0
  46. package/content-dist/fragments/domain/sistema-pagamentos.md +81 -0
  47. package/content-dist/fragments/domain/upload-midia.md +81 -0
  48. package/content-dist/fragments/domain/whatsapp-business.md +82 -0
  49. package/content-dist/fragments/index.json +1670 -0
  50. package/content-dist/fragments/references/angular-ngrx/app-config-and-testing.md +81 -0
  51. package/content-dist/fragments/references/angular-ngrx/store-pattern.md +155 -0
  52. package/content-dist/fragments/references/ansible-server-setup/layout-and-config.md +143 -0
  53. package/content-dist/fragments/references/ansible-server-setup/roles.md +238 -0
  54. package/content-dist/fragments/references/api-publica-rate-limiting/patterns.md +68 -0
  55. package/content-dist/fragments/references/astro-static/content-and-islands.md +117 -0
  56. package/content-dist/fragments/references/autenticacao-enterprise/pitfalls.md +70 -0
  57. package/content-dist/fragments/references/busca-elasticsearch/patterns.md +100 -0
  58. package/content-dist/fragments/references/chrome-extension-mv3/messaging-and-storage.md +109 -0
  59. package/content-dist/fragments/references/cli-typescript-commander/commands-and-config.md +136 -0
  60. package/content-dist/fragments/references/cloud-run-gcp/build-and-deploy.md +127 -0
  61. package/content-dist/fragments/references/cloud-run-gcp/iam-secrets-networking.md +65 -0
  62. package/content-dist/fragments/references/computer-vision-yolo/serving-and-export.md +182 -0
  63. package/content-dist/fragments/references/computer-vision-yolo/training-and-validation.md +131 -0
  64. package/content-dist/fragments/references/convex-react/functions.md +117 -0
  65. package/content-dist/fragments/references/convex-react/react-and-storage.md +109 -0
  66. package/content-dist/fragments/references/dashboard-admin-rbac/patterns.md +73 -0
  67. package/content-dist/fragments/references/data-pipeline-airflow/dag-patterns.md +149 -0
  68. package/content-dist/fragments/references/data-pipeline-airflow/operations.md +74 -0
  69. package/content-dist/fragments/references/delphi-object-pascal/legacy-extraction.md +175 -0
  70. package/content-dist/fragments/references/django-drf-celery/celery-tasks.md +47 -0
  71. package/content-dist/fragments/references/django-drf-celery/viewsets-and-serializers.md +92 -0
  72. package/content-dist/fragments/references/docker-compose-dev/compose-files.md +146 -0
  73. package/content-dist/fragments/references/docker-compose-dev/dockerfile-and-proxy.md +108 -0
  74. package/content-dist/fragments/references/dotnet-aspnet/data-and-di.md +90 -0
  75. package/content-dist/fragments/references/dotnet-aspnet/web-layer.md +88 -0
  76. package/content-dist/fragments/references/ecommerce-completo/patterns.md +76 -0
  77. package/content-dist/fragments/references/electron-app/ipc-bridge.md +123 -0
  78. package/content-dist/fragments/references/electron-app/security-and-packaging.md +134 -0
  79. package/content-dist/fragments/references/elixir-phoenix/context-and-web.md +112 -0
  80. package/content-dist/fragments/references/elixir-phoenix/processes.md +65 -0
  81. package/content-dist/fragments/references/filas-jobs/patterns.md +116 -0
  82. package/content-dist/fragments/references/fine-tuning-huggingface/data-and-export.md +114 -0
  83. package/content-dist/fragments/references/fine-tuning-huggingface/training-and-lora.md +123 -0
  84. package/content-dist/fragments/references/flutter/platform-channels-and-goldens.md +68 -0
  85. package/content-dist/fragments/references/flutter/state-and-widgets.md +95 -0
  86. package/content-dist/fragments/references/github-actions-cicd/workflows.md +235 -0
  87. package/content-dist/fragments/references/go-chi-gorm/http-layer.md +87 -0
  88. package/content-dist/fragments/references/go-chi-gorm/service-layer.md +58 -0
  89. package/content-dist/fragments/references/graphql-apollo/resolvers-and-loaders.md +128 -0
  90. package/content-dist/fragments/references/hono-bun/patterns.md +144 -0
  91. package/content-dist/fragments/references/integracao-crm-erp/patterns.md +100 -0
  92. package/content-dist/fragments/references/kubernetes-helm/chart-templates.md +162 -0
  93. package/content-dist/fragments/references/kubernetes-helm/secrets-storage-deploy.md +78 -0
  94. package/content-dist/fragments/references/langchain-python-agent/agent-and-cost.md +120 -0
  95. package/content-dist/fragments/references/langchain-python-agent/memory-and-resilience.md +76 -0
  96. package/content-dist/fragments/references/laravel/eloquent-and-queues.md +126 -0
  97. package/content-dist/fragments/references/laravel/http-layer.md +110 -0
  98. package/content-dist/fragments/references/lgpd/patterns.md +110 -0
  99. package/content-dist/fragments/references/llm-ops-production/routing-and-budget.md +118 -0
  100. package/content-dist/fragments/references/llm-ops-production/tracing-eval-ab.md +102 -0
  101. package/content-dist/fragments/references/microservices-docker/compose-and-gateway.md +93 -0
  102. package/content-dist/fragments/references/microservices-docker/events-and-correlation.md +88 -0
  103. package/content-dist/fragments/references/ml-fastapi-serving/metrics-drift-docker.md +97 -0
  104. package/content-dist/fragments/references/ml-fastapi-serving/serving-core.md +155 -0
  105. package/content-dist/fragments/references/ml-training-pipeline/dvc-pipeline.md +102 -0
  106. package/content-dist/fragments/references/ml-training-pipeline/mlflow-registry-ci.md +139 -0
  107. package/content-dist/fragments/references/monitoring-observability/alerts-and-config.md +169 -0
  108. package/content-dist/fragments/references/monitoring-observability/instrumentation-node.md +139 -0
  109. package/content-dist/fragments/references/multi-tenancy/patterns.md +85 -0
  110. package/content-dist/fragments/references/nestjs-typescript/guards-and-decorators.md +103 -0
  111. package/content-dist/fragments/references/nestjs-typescript/modules-dtos-setup.md +106 -0
  112. package/content-dist/fragments/references/nextjs-app-router/patterns.md +177 -0
  113. package/content-dist/fragments/references/nextjs-prisma-postgres/billing.md +167 -0
  114. package/content-dist/fragments/references/nextjs-trpc-drizzle/data-and-auth.md +121 -0
  115. package/content-dist/fragments/references/nextjs-trpc-drizzle/trpc-setup.md +62 -0
  116. package/content-dist/fragments/references/nodejs-express-typescript/config-and-tokens.md +48 -0
  117. package/content-dist/fragments/references/nodejs-express-typescript/middleware.md +108 -0
  118. package/content-dist/fragments/references/notificacoes-multicanal/patterns.md +78 -0
  119. package/content-dist/fragments/references/nuxt3-tailwind/server-routes.md +79 -0
  120. package/content-dist/fragments/references/nuxt3-tailwind/state-and-fetching.md +129 -0
  121. package/content-dist/fragments/references/openai-api-integration/calls.md +210 -0
  122. package/content-dist/fragments/references/openai-api-integration/client-and-cost.md +71 -0
  123. package/content-dist/fragments/references/pagamentos-brasil/gateways-reconciliation.md +92 -0
  124. package/content-dist/fragments/references/pagamentos-brasil/pix-boleto.md +115 -0
  125. package/content-dist/fragments/references/plataforma-conteudo/patterns.md +74 -0
  126. package/content-dist/fragments/references/python-fastapi/dependency-injection.md +99 -0
  127. package/content-dist/fragments/references/python-fastapi/settings-and-tasks.md +47 -0
  128. package/content-dist/fragments/references/rag-pipeline/ingestion.md +92 -0
  129. package/content-dist/fragments/references/rag-pipeline/retrieval-and-eval.md +148 -0
  130. package/content-dist/fragments/references/react-express-monolith/auth-and-client.md +110 -0
  131. package/content-dist/fragments/references/react-express-monolith/monorepo.md +71 -0
  132. package/content-dist/fragments/references/react-native-expo/native-patterns.md +103 -0
  133. package/content-dist/fragments/references/react-native-expo/navigation-and-auth.md +55 -0
  134. package/content-dist/fragments/references/react-ts-zustand-query/store-and-query.md +152 -0
  135. package/content-dist/fragments/references/react-typescript/feature-module.md +64 -0
  136. package/content-dist/fragments/references/react-typescript/forms-and-state.md +69 -0
  137. package/content-dist/fragments/references/react-typescript/recipes.md +37 -0
  138. package/content-dist/fragments/references/react-typescript/testing.md +40 -0
  139. package/content-dist/fragments/references/realtime-websockets/patterns.md +92 -0
  140. package/content-dist/fragments/references/relatorios-analytics/patterns.md +81 -0
  141. package/content-dist/fragments/references/remix-express-full/auth-and-uploads.md +88 -0
  142. package/content-dist/fragments/references/remix-express-full/express-server.md +54 -0
  143. package/content-dist/fragments/references/remix-typescript/auth-and-db.md +68 -0
  144. package/content-dist/fragments/references/remix-typescript/loaders-and-actions.md +98 -0
  145. package/content-dist/fragments/references/rust-axum/error-and-state.md +99 -0
  146. package/content-dist/fragments/references/rust-axum/handlers.md +87 -0
  147. package/content-dist/fragments/references/saas-stripe-billing/patterns.md +86 -0
  148. package/content-dist/fragments/references/serverless-lambda/handler-patterns.md +107 -0
  149. package/content-dist/fragments/references/sistema-pagamentos/pitfalls.md +54 -0
  150. package/content-dist/fragments/references/spring-boot/service-and-data.md +96 -0
  151. package/content-dist/fragments/references/spring-boot/web-layer.md +100 -0
  152. package/content-dist/fragments/references/supabase-nextjs/clients-and-middleware.md +102 -0
  153. package/content-dist/fragments/references/supabase-nextjs/rls-and-storage.md +86 -0
  154. package/content-dist/fragments/references/svelte-sveltekit/hooks-and-state.md +67 -0
  155. package/content-dist/fragments/references/svelte-sveltekit/load-and-actions.md +80 -0
  156. package/content-dist/fragments/references/t3-stack/routers-and-callers.md +75 -0
  157. package/content-dist/fragments/references/t3-stack/trpc-setup.md +60 -0
  158. package/content-dist/fragments/references/terraform-aws/modules-and-ci.md +114 -0
  159. package/content-dist/fragments/references/terraform-aws/state-and-workspaces.md +66 -0
  160. package/content-dist/fragments/references/turborepo-monorepo/pipeline-and-packages.md +84 -0
  161. package/content-dist/fragments/references/upload-midia/patterns.md +80 -0
  162. package/content-dist/fragments/references/vector-search-pinecone/client-and-upsert.md +98 -0
  163. package/content-dist/fragments/references/vector-search-pinecone/query-and-hybrid.md +81 -0
  164. package/content-dist/fragments/references/vps-deploy-producao/compose-prod.md +97 -0
  165. package/content-dist/fragments/references/vps-deploy-producao/proxy-and-operations.md +118 -0
  166. package/content-dist/fragments/references/vscode-extension/activation-and-tree.md +98 -0
  167. package/content-dist/fragments/references/vscode-extension/webview-csp.md +57 -0
  168. package/content-dist/fragments/references/vue3-pinia-vite/components-and-stores.md +73 -0
  169. package/content-dist/fragments/references/vue3-pinia-vite/queries-forms-testing.md +100 -0
  170. package/content-dist/fragments/references/whatsapp-business/patterns.md +107 -0
  171. package/content-dist/fragments/references/wordpress/hooks-and-security.md +92 -0
  172. package/content-dist/fragments/references/wordpress/wp-cli-gates.md +64 -0
  173. package/content-dist/fragments/stack/angular-ngrx.md +75 -0
  174. package/content-dist/fragments/stack/ansible-server-setup.md +69 -0
  175. package/content-dist/fragments/stack/astro-static.md +72 -0
  176. package/content-dist/fragments/stack/chrome-extension-mv3.md +66 -0
  177. package/content-dist/fragments/stack/cli-typescript-commander.md +66 -0
  178. package/content-dist/fragments/stack/cloud-run-gcp.md +63 -0
  179. package/content-dist/fragments/stack/computer-vision-yolo.md +62 -0
  180. package/content-dist/fragments/stack/convex-react.md +65 -0
  181. package/content-dist/fragments/stack/data-pipeline-airflow.md +64 -0
  182. package/content-dist/fragments/stack/delphi-object-pascal.md +63 -0
  183. package/content-dist/fragments/stack/django-drf-celery.md +63 -0
  184. package/content-dist/fragments/stack/docker-compose-dev.md +69 -0
  185. package/content-dist/fragments/stack/dotnet-aspnet.md +62 -0
  186. package/content-dist/fragments/stack/electron-app.md +70 -0
  187. package/content-dist/fragments/stack/elixir-phoenix.md +65 -0
  188. package/content-dist/fragments/stack/fine-tuning-huggingface.md +69 -0
  189. package/content-dist/fragments/stack/flutter.md +61 -0
  190. package/content-dist/fragments/stack/github-actions-cicd.md +73 -0
  191. package/content-dist/fragments/stack/go-chi-gorm.md +73 -0
  192. package/content-dist/fragments/stack/graphql-apollo.md +70 -0
  193. package/content-dist/fragments/stack/hono-bun.md +62 -0
  194. package/content-dist/fragments/stack/kubernetes-helm.md +67 -0
  195. package/content-dist/fragments/stack/langchain-python-agent.md +64 -0
  196. package/content-dist/fragments/stack/laravel.md +64 -0
  197. package/content-dist/fragments/stack/llm-ops-production.md +63 -0
  198. package/content-dist/fragments/stack/microservices-docker.md +70 -0
  199. package/content-dist/fragments/stack/ml-fastapi-serving.md +64 -0
  200. package/content-dist/fragments/stack/ml-training-pipeline.md +67 -0
  201. package/content-dist/fragments/stack/monitoring-observability.md +68 -0
  202. package/content-dist/fragments/stack/nestjs-typescript.md +68 -0
  203. package/content-dist/fragments/stack/nextjs-app-router.md +65 -0
  204. package/content-dist/fragments/stack/nextjs-prisma-postgres.md +61 -0
  205. package/content-dist/fragments/stack/nextjs-trpc-drizzle.md +63 -0
  206. package/content-dist/fragments/stack/nodejs-express-typescript.md +60 -0
  207. package/content-dist/fragments/stack/nuxt3-tailwind.md +62 -0
  208. package/content-dist/fragments/stack/openai-api-integration.md +58 -0
  209. package/content-dist/fragments/stack/python-fastapi.md +64 -0
  210. package/content-dist/fragments/stack/rag-pipeline.md +62 -0
  211. package/content-dist/fragments/stack/react-express-monolith.md +61 -0
  212. package/content-dist/fragments/stack/react-native-expo.md +68 -0
  213. package/content-dist/fragments/stack/react-ts-zustand-query.md +64 -0
  214. package/content-dist/fragments/stack/react-typescript.md +73 -0
  215. package/content-dist/fragments/stack/remix-express-full.md +63 -0
  216. package/content-dist/fragments/stack/remix-typescript.md +66 -0
  217. package/content-dist/fragments/stack/rust-axum.md +63 -0
  218. package/content-dist/fragments/stack/serverless-lambda.md +65 -0
  219. package/content-dist/fragments/stack/spring-boot.md +63 -0
  220. package/content-dist/fragments/stack/supabase-nextjs.md +64 -0
  221. package/content-dist/fragments/stack/svelte-sveltekit.md +67 -0
  222. package/content-dist/fragments/stack/t3-stack.md +63 -0
  223. package/content-dist/fragments/stack/terraform-aws.md +65 -0
  224. package/content-dist/fragments/stack/turborepo-monorepo.md +61 -0
  225. package/content-dist/fragments/stack/vector-search-pinecone.md +63 -0
  226. package/content-dist/fragments/stack/vps-deploy-producao.md +64 -0
  227. package/content-dist/fragments/stack/vscode-extension.md +64 -0
  228. package/content-dist/fragments/stack/vue3-pinia-vite.md +65 -0
  229. package/content-dist/fragments/stack/wordpress.md +63 -0
  230. package/content-dist/skills/invi-commit/SKILL.md +85 -0
  231. package/content-dist/skills/invi-journal/SKILL.md +67 -0
  232. package/content-dist/skills/invi-map/SKILL.md +118 -0
  233. package/content-dist/skills/invi-mode/SKILL.md +176 -0
  234. package/content-dist/skills/invi-pr/SKILL.md +142 -0
  235. package/content-dist/skills/invi-qa/SKILL.md +75 -0
  236. package/content-dist/skills/invi-refactor-legacy/SKILL.md +90 -0
  237. package/content-dist/skills/invi-review/SKILL.md +83 -0
  238. package/content-dist/skills/invi-security/SKILL.md +89 -0
  239. package/content-dist/skills/invi-status/SKILL.md +72 -0
  240. package/content-dist/skills/invi-task/SKILL.md +143 -0
  241. package/content-dist/skills/invi-test/SKILL.md +97 -0
  242. package/content-dist/skills/po-handoff/SKILL.md +130 -0
  243. package/content-dist/skills/po-intake/SKILL.md +115 -0
  244. package/content-dist/skills/po-lint/SKILL.md +82 -0
  245. package/content-dist/skills/po-spec/SKILL.md +138 -0
  246. package/content-dist/skills/po-status/SKILL.md +130 -0
  247. package/content-dist/skills/po-verify/SKILL.md +124 -0
  248. package/content-dist/templates/requirements/REQ-TEMPLATE.md +110 -0
  249. package/content-dist/templates/requirements/constitution-TEMPLATE.md +77 -0
  250. package/dist/baseline.d.ts +21 -0
  251. package/dist/baseline.d.ts.map +1 -0
  252. package/dist/baseline.js +43 -0
  253. package/dist/baseline.js.map +1 -0
  254. package/dist/cli.d.ts +15 -0
  255. package/dist/cli.d.ts.map +1 -0
  256. package/dist/cli.js +345 -0
  257. package/dist/cli.js.map +1 -0
  258. package/dist/commands/doctor.d.ts +31 -0
  259. package/dist/commands/doctor.d.ts.map +1 -0
  260. package/dist/commands/doctor.js +173 -0
  261. package/dist/commands/doctor.js.map +1 -0
  262. package/dist/commands/export.d.ts +49 -0
  263. package/dist/commands/export.d.ts.map +1 -0
  264. package/dist/commands/export.js +95 -0
  265. package/dist/commands/export.js.map +1 -0
  266. package/dist/commands/gate.d.ts +42 -0
  267. package/dist/commands/gate.d.ts.map +1 -0
  268. package/dist/commands/gate.js +97 -0
  269. package/dist/commands/gate.js.map +1 -0
  270. package/dist/commands/init.d.ts +88 -0
  271. package/dist/commands/init.d.ts.map +1 -0
  272. package/dist/commands/init.js +540 -0
  273. package/dist/commands/init.js.map +1 -0
  274. package/dist/commands/journalCmd.d.ts +47 -0
  275. package/dist/commands/journalCmd.d.ts.map +1 -0
  276. package/dist/commands/journalCmd.js +89 -0
  277. package/dist/commands/journalCmd.js.map +1 -0
  278. package/dist/commands/keys.d.ts +68 -0
  279. package/dist/commands/keys.d.ts.map +1 -0
  280. package/dist/commands/keys.js +240 -0
  281. package/dist/commands/keys.js.map +1 -0
  282. package/dist/commands/map.d.ts +123 -0
  283. package/dist/commands/map.d.ts.map +1 -0
  284. package/dist/commands/map.js +383 -0
  285. package/dist/commands/map.js.map +1 -0
  286. package/dist/commands/plan.d.ts +28 -0
  287. package/dist/commands/plan.d.ts.map +1 -0
  288. package/dist/commands/plan.js +64 -0
  289. package/dist/commands/plan.js.map +1 -0
  290. package/dist/commands/req.d.ts +92 -0
  291. package/dist/commands/req.d.ts.map +1 -0
  292. package/dist/commands/req.js +270 -0
  293. package/dist/commands/req.js.map +1 -0
  294. package/dist/commands/review.d.ts +40 -0
  295. package/dist/commands/review.d.ts.map +1 -0
  296. package/dist/commands/review.js +101 -0
  297. package/dist/commands/review.js.map +1 -0
  298. package/dist/commands/run.d.ts +33 -0
  299. package/dist/commands/run.d.ts.map +1 -0
  300. package/dist/commands/run.js +151 -0
  301. package/dist/commands/run.js.map +1 -0
  302. package/dist/commands/ship.d.ts +45 -0
  303. package/dist/commands/ship.d.ts.map +1 -0
  304. package/dist/commands/ship.js +252 -0
  305. package/dist/commands/ship.js.map +1 -0
  306. package/dist/commands/status.d.ts +36 -0
  307. package/dist/commands/status.d.ts.map +1 -0
  308. package/dist/commands/status.js +152 -0
  309. package/dist/commands/status.js.map +1 -0
  310. package/dist/commands/sync.d.ts +91 -0
  311. package/dist/commands/sync.d.ts.map +1 -0
  312. package/dist/commands/sync.js +331 -0
  313. package/dist/commands/sync.js.map +1 -0
  314. package/dist/commands/syncCommits.d.ts +56 -0
  315. package/dist/commands/syncCommits.d.ts.map +1 -0
  316. package/dist/commands/syncCommits.js +97 -0
  317. package/dist/commands/syncCommits.js.map +1 -0
  318. package/dist/commands/task.d.ts +108 -0
  319. package/dist/commands/task.d.ts.map +1 -0
  320. package/dist/commands/task.js +217 -0
  321. package/dist/commands/task.js.map +1 -0
  322. package/dist/commands/update.d.ts +92 -0
  323. package/dist/commands/update.d.ts.map +1 -0
  324. package/dist/commands/update.js +541 -0
  325. package/dist/commands/update.js.map +1 -0
  326. package/dist/commands/verifyTask.d.ts +50 -0
  327. package/dist/commands/verifyTask.d.ts.map +1 -0
  328. package/dist/commands/verifyTask.js +172 -0
  329. package/dist/commands/verifyTask.js.map +1 -0
  330. package/dist/content.d.ts +128 -0
  331. package/dist/content.d.ts.map +1 -0
  332. package/dist/content.js +177 -0
  333. package/dist/content.js.map +1 -0
  334. package/dist/detect.d.ts +122 -0
  335. package/dist/detect.d.ts.map +1 -0
  336. package/dist/detect.js +594 -0
  337. package/dist/detect.js.map +1 -0
  338. package/dist/events.d.ts +36 -0
  339. package/dist/events.d.ts.map +1 -0
  340. package/dist/events.js +76 -0
  341. package/dist/events.js.map +1 -0
  342. package/dist/frontmatter.d.ts +15 -0
  343. package/dist/frontmatter.d.ts.map +1 -0
  344. package/dist/frontmatter.js +74 -0
  345. package/dist/frontmatter.js.map +1 -0
  346. package/dist/i18n/en.d.ts +421 -0
  347. package/dist/i18n/en.d.ts.map +1 -0
  348. package/dist/i18n/en.js +443 -0
  349. package/dist/i18n/en.js.map +1 -0
  350. package/dist/i18n/index.d.ts +40 -0
  351. package/dist/i18n/index.d.ts.map +1 -0
  352. package/dist/i18n/index.js +66 -0
  353. package/dist/i18n/index.js.map +1 -0
  354. package/dist/i18n/pt-BR.d.ts +11 -0
  355. package/dist/i18n/pt-BR.d.ts.map +1 -0
  356. package/dist/i18n/pt-BR.js +435 -0
  357. package/dist/i18n/pt-BR.js.map +1 -0
  358. package/dist/identity.d.ts +78 -0
  359. package/dist/identity.d.ts.map +1 -0
  360. package/dist/identity.js +152 -0
  361. package/dist/identity.js.map +1 -0
  362. package/dist/index.d.ts +79 -0
  363. package/dist/index.d.ts.map +1 -0
  364. package/dist/index.js +48 -0
  365. package/dist/index.js.map +1 -0
  366. package/dist/insights.d.ts +86 -0
  367. package/dist/insights.d.ts.map +1 -0
  368. package/dist/insights.js +199 -0
  369. package/dist/insights.js.map +1 -0
  370. package/dist/interview.d.ts +81 -0
  371. package/dist/interview.d.ts.map +1 -0
  372. package/dist/interview.js +283 -0
  373. package/dist/interview.js.map +1 -0
  374. package/dist/inventory.d.ts +79 -0
  375. package/dist/inventory.d.ts.map +1 -0
  376. package/dist/inventory.js +86 -0
  377. package/dist/inventory.js.map +1 -0
  378. package/dist/journal.d.ts +22 -0
  379. package/dist/journal.d.ts.map +1 -0
  380. package/dist/journal.js +88 -0
  381. package/dist/journal.js.map +1 -0
  382. package/dist/migrations/legacyNames.d.ts +45 -0
  383. package/dist/migrations/legacyNames.d.ts.map +1 -0
  384. package/dist/migrations/legacyNames.js +118 -0
  385. package/dist/migrations/legacyNames.js.map +1 -0
  386. package/dist/plan.d.ts +42 -0
  387. package/dist/plan.d.ts.map +1 -0
  388. package/dist/plan.js +126 -0
  389. package/dist/plan.js.map +1 -0
  390. package/dist/render/agents.d.ts +327 -0
  391. package/dist/render/agents.d.ts.map +1 -0
  392. package/dist/render/agents.js +356 -0
  393. package/dist/render/agents.js.map +1 -0
  394. package/dist/render/claudeMd.d.ts +29 -0
  395. package/dist/render/claudeMd.d.ts.map +1 -0
  396. package/dist/render/claudeMd.js +110 -0
  397. package/dist/render/claudeMd.js.map +1 -0
  398. package/dist/render/githooks.d.ts +41 -0
  399. package/dist/render/githooks.d.ts.map +1 -0
  400. package/dist/render/githooks.js +168 -0
  401. package/dist/render/githooks.js.map +1 -0
  402. package/dist/render/markers.d.ts +13 -0
  403. package/dist/render/markers.d.ts.map +1 -0
  404. package/dist/render/markers.js +35 -0
  405. package/dist/render/markers.js.map +1 -0
  406. package/dist/render/requirements.d.ts +56 -0
  407. package/dist/render/requirements.d.ts.map +1 -0
  408. package/dist/render/requirements.js +86 -0
  409. package/dist/render/requirements.js.map +1 -0
  410. package/dist/render/settings.d.ts +43 -0
  411. package/dist/render/settings.d.ts.map +1 -0
  412. package/dist/render/settings.js +94 -0
  413. package/dist/render/settings.js.map +1 -0
  414. package/dist/render/transparency.d.ts +7 -0
  415. package/dist/render/transparency.d.ts.map +1 -0
  416. package/dist/render/transparency.js +164 -0
  417. package/dist/render/transparency.js.map +1 -0
  418. package/dist/requirements.d.ts +84 -0
  419. package/dist/requirements.d.ts.map +1 -0
  420. package/dist/requirements.js +229 -0
  421. package/dist/requirements.js.map +1 -0
  422. package/dist/sizing.d.ts +63 -0
  423. package/dist/sizing.d.ts.map +1 -0
  424. package/dist/sizing.js +104 -0
  425. package/dist/sizing.js.map +1 -0
  426. package/dist/tasks.d.ts +199 -0
  427. package/dist/tasks.d.ts.map +1 -0
  428. package/dist/tasks.js +320 -0
  429. package/dist/tasks.js.map +1 -0
  430. package/dist/util/diff3.d.ts +26 -0
  431. package/dist/util/diff3.d.ts.map +1 -0
  432. package/dist/util/diff3.js +112 -0
  433. package/dist/util/diff3.js.map +1 -0
  434. package/dist/util/fsx.d.ts +33 -0
  435. package/dist/util/fsx.d.ts.map +1 -0
  436. package/dist/util/fsx.js +153 -0
  437. package/dist/util/fsx.js.map +1 -0
  438. package/dist/util/git.d.ts +58 -0
  439. package/dist/util/git.d.ts.map +1 -0
  440. package/dist/util/git.js +171 -0
  441. package/dist/util/git.js.map +1 -0
  442. package/dist/util/merge.d.ts +27 -0
  443. package/dist/util/merge.d.ts.map +1 -0
  444. package/dist/util/merge.js +78 -0
  445. package/dist/util/merge.js.map +1 -0
  446. package/dist/util/out.d.ts +18 -0
  447. package/dist/util/out.d.ts.map +1 -0
  448. package/dist/util/out.js +23 -0
  449. package/dist/util/out.js.map +1 -0
  450. package/dist/util/proc.d.ts +12 -0
  451. package/dist/util/proc.d.ts.map +1 -0
  452. package/dist/util/proc.js +45 -0
  453. package/dist/util/proc.js.map +1 -0
  454. package/dist/util/registry.d.ts +58 -0
  455. package/dist/util/registry.d.ts.map +1 -0
  456. package/dist/util/registry.js +240 -0
  457. package/dist/util/registry.js.map +1 -0
  458. package/dist/verify.d.ts +52 -0
  459. package/dist/verify.d.ts.map +1 -0
  460. package/dist/verify.js +205 -0
  461. package/dist/verify.js.map +1 -0
  462. package/dist/version.d.ts +5 -0
  463. package/dist/version.d.ts.map +1 -0
  464. package/dist/version.js +18 -0
  465. package/dist/version.js.map +1 -0
  466. package/package.json +63 -0
@@ -0,0 +1,54 @@
1
+ # Reference: custom Express server hosting Remix (read on demand)
2
+
3
+ Exemplar for `stack/remix-express-full`. Read when touching the server entry, sessions, or cross-cutting middleware.
4
+
5
+ ## Express bootstrap: Redis sessions, security headers, rate limiting
6
+
7
+ ```typescript
8
+ // server/index.ts
9
+ import express from 'express'
10
+ import { createRequestHandler } from '@remix-run/express'
11
+ import { createClient } from 'redis'
12
+ import session from 'express-session'
13
+ import { RedisStore } from 'connect-redis'
14
+ import { rateLimit } from 'express-rate-limit'
15
+ import compression from 'compression'
16
+ import helmet from 'helmet'
17
+ import morgan from 'morgan'
18
+
19
+ async function bootstrap() {
20
+ const redisClient = createClient({ url: process.env.REDIS_URL })
21
+ await redisClient.connect()
22
+
23
+ const app = express()
24
+
25
+ app.use(helmet({ contentSecurityPolicy: false })) // Remix sets its own CSP
26
+ app.use(compression())
27
+ app.use(morgan('combined'))
28
+ app.use(express.json({ limit: '1mb' }))
29
+ app.use(express.static('public', { maxAge: '1h' }))
30
+
31
+ app.use(session({
32
+ store: new RedisStore({ client: redisClient }),
33
+ secret: process.env.SESSION_SECRET!,
34
+ resave: false,
35
+ saveUninitialized: false,
36
+ cookie: {
37
+ secure: process.env.NODE_ENV === 'production',
38
+ httpOnly: true,
39
+ maxAge: 7 * 24 * 60 * 60 * 1000,
40
+ },
41
+ }))
42
+
43
+ app.use(rateLimit({ windowMs: 60_000, max: 100 }))
44
+
45
+ // Let Remix handle all other routes
46
+ app.all('*', createRequestHandler({ build: await import('../build/server/index.js') }))
47
+
48
+ app.listen(process.env.PORT ?? 3000)
49
+ }
50
+
51
+ bootstrap().catch(console.error)
52
+ ```
53
+
54
+ Key points: the cookie carries only the session id (payload lives in Redis); middleware order is security → compression → logging → parsers → static → session → rate limit → Remix catch-all.
@@ -0,0 +1,68 @@
1
+ # Reference: Remix session auth and Prisma singleton (read on demand)
2
+
3
+ Exemplar for `stack/remix-typescript`.
4
+
5
+ ## Cookie session storage + requireUser
6
+
7
+ ```typescript
8
+ // app/lib/auth.server.ts
9
+ import { createCookieSessionStorage, redirect } from "@remix-run/node";
10
+
11
+ const sessionStorage = createCookieSessionStorage({
12
+ cookie: {
13
+ name: "__session",
14
+ httpOnly: true,
15
+ secure: process.env.NODE_ENV === "production",
16
+ sameSite: "lax",
17
+ secrets: [process.env.SESSION_SECRET!],
18
+ maxAge: 60 * 60 * 24 * 30, // 30 days
19
+ },
20
+ });
21
+
22
+ export async function requireUser(request: Request) {
23
+ const session = await sessionStorage.getSession(request.headers.get("Cookie"));
24
+ const userId = session.get("userId");
25
+ if (!userId) throw redirect("/login");
26
+ const user = await db.user.findUnique({ where: { id: userId } });
27
+ if (!user) throw redirect("/login");
28
+ return user;
29
+ }
30
+ ```
31
+
32
+ ## Prisma client singleton (survives dev HMR)
33
+
34
+ ```typescript
35
+ // app/lib/db.server.ts
36
+ import { PrismaClient } from "@prisma/client";
37
+
38
+ declare global {
39
+ var __db__: PrismaClient | undefined;
40
+ }
41
+
42
+ export const db =
43
+ global.__db__ ||
44
+ new PrismaClient({
45
+ log: process.env.NODE_ENV === "development" ? ["query", "error"] : ["error"],
46
+ });
47
+
48
+ if (process.env.NODE_ENV !== "production") {
49
+ global.__db__ = db;
50
+ }
51
+ ```
52
+
53
+ Prisma discipline: import `db` only from `.server.ts` modules; use explicit `select` (never ship full ORM objects to the client); migrations always carry a descriptive name; seeds live in `prisma/seed.ts`.
54
+
55
+ ## Nested routing anatomy
56
+
57
+ ```
58
+ root.tsx ← providers, global meta, ErrorBoundary, Outlet
59
+ └── _auth.tsx ← pathless layout (auth navbar)
60
+ ├── _auth.login.tsx ← /login
61
+ └── _auth.register.tsx ← /register
62
+ └── dashboard.tsx ← layout: sidebar, authenticated header
63
+ ├── dashboard._index.tsx ← /dashboard
64
+ ├── dashboard.projects.tsx ← /dashboard/projects
65
+ └── dashboard.projects.$id.tsx ← /dashboard/projects/:id
66
+ ```
67
+
68
+ `<Outlet />` appears exactly once per layout route; `useMatches()` for breadcrumbs; `shouldRevalidate` to skip re-fetches after unrelated actions.
@@ -0,0 +1,98 @@
1
+ # Reference: Remix loaders, actions, forms, and error boundaries (read on demand)
2
+
3
+ Exemplar for `stack/remix-typescript`.
4
+
5
+ ## Loader (read) and action (mutation) in one route
6
+
7
+ ```typescript
8
+ // app/routes/dashboard.projects.tsx
9
+ import { json, redirect, type LoaderFunctionArgs, type ActionFunctionArgs } from "@remix-run/node";
10
+ import { useLoaderData } from "@remix-run/react";
11
+ import { z } from "zod";
12
+ import { requireUser } from "~/lib/auth.server";
13
+ import { db } from "~/lib/db.server";
14
+
15
+ export async function loader({ request }: LoaderFunctionArgs) {
16
+ const user = await requireUser(request); // throws redirect if unauthenticated
17
+
18
+ const projects = await db.project.findMany({
19
+ where: { userId: user.id },
20
+ orderBy: { createdAt: "desc" },
21
+ });
22
+
23
+ return json({ projects, user });
24
+ }
25
+
26
+ const CreateProjectSchema = z.object({
27
+ name: z.string().min(1).max(100),
28
+ description: z.string().optional(),
29
+ });
30
+
31
+ export async function action({ request }: ActionFunctionArgs) {
32
+ const user = await requireUser(request);
33
+ const formData = await request.formData();
34
+
35
+ const result = CreateProjectSchema.safeParse(Object.fromEntries(formData));
36
+ if (!result.success) {
37
+ return json({ errors: result.error.flatten().fieldErrors }, { status: 422 });
38
+ }
39
+
40
+ await db.project.create({ data: { ...result.data, userId: user.id } });
41
+ return redirect("/dashboard/projects");
42
+ }
43
+
44
+ export default function ProjectsPage() {
45
+ const { projects } = useLoaderData<typeof loader>();
46
+ return (/* JSX */);
47
+ }
48
+ ```
49
+
50
+ ## Form with pending state and field errors
51
+
52
+ ```tsx
53
+ // Always use Remix <Form>, never a native <form> for mutations
54
+ import { Form, useActionData, useNavigation } from "@remix-run/react";
55
+
56
+ export default function CreateProject() {
57
+ const actionData = useActionData<typeof action>();
58
+ const navigation = useNavigation();
59
+ const isSubmitting = navigation.state === "submitting";
60
+
61
+ return (
62
+ <Form method="post">
63
+ <input name="name" />
64
+ {actionData?.errors?.name && (
65
+ <p className="text-red-500">{actionData.errors.name[0]}</p>
66
+ )}
67
+ <button type="submit" disabled={isSubmitting}>
68
+ {isSubmitting ? "Saving…" : "Create project"}
69
+ </button>
70
+ </Form>
71
+ );
72
+ }
73
+ ```
74
+
75
+ ## Error boundary
76
+
77
+ ```typescript
78
+ export function ErrorBoundary() {
79
+ const error = useRouteError();
80
+
81
+ if (isRouteErrorResponse(error)) {
82
+ return (
83
+ <div>
84
+ <h1>{error.status} {error.statusText}</h1>
85
+ <p>{error.data}</p>
86
+ </div>
87
+ );
88
+ }
89
+
90
+ // Unexpected error: log server-side, show a generic message — never the stack trace
91
+ return (
92
+ <div>
93
+ <h1>Something went wrong</h1>
94
+ <p>Please reload the page.</p>
95
+ </div>
96
+ );
97
+ }
98
+ ```
@@ -0,0 +1,99 @@
1
+ # Reference: Axum error enum, AppState, and bootstrap (read on demand)
2
+
3
+ Exemplar for `stack/rust-axum`.
4
+
5
+ ## AppError with IntoResponse (client never sees internals)
6
+
7
+ ```rust
8
+ // src/error.rs
9
+ use axum::{
10
+ http::StatusCode,
11
+ response::{IntoResponse, Response},
12
+ Json,
13
+ };
14
+ use serde_json::json;
15
+ use thiserror::Error;
16
+
17
+ #[derive(Debug, Error)]
18
+ pub enum AppError {
19
+ #[error("Not found: {0}")]
20
+ NotFound(String),
21
+
22
+ #[error("Unauthorized: {0}")]
23
+ Unauthorized(String),
24
+
25
+ #[error("Unprocessable entity: {0}")]
26
+ UnprocessableEntity(String),
27
+
28
+ #[error("Internal error")]
29
+ Internal(#[from] anyhow::Error),
30
+
31
+ #[error("Database error")]
32
+ Database(#[from] sqlx::Error),
33
+ }
34
+
35
+ impl IntoResponse for AppError {
36
+ fn into_response(self) -> Response {
37
+ let (status, message) = match &self {
38
+ Self::NotFound(msg) => (StatusCode::NOT_FOUND, msg.clone()),
39
+ Self::Unauthorized(msg) => (StatusCode::UNAUTHORIZED, msg.clone()),
40
+ Self::UnprocessableEntity(msg) => (StatusCode::UNPROCESSABLE_ENTITY, msg.clone()),
41
+ Self::Internal(_) | Self::Database(_) => {
42
+ tracing::error!(error = %self); // full error logged server-side only
43
+ (StatusCode::INTERNAL_SERVER_ERROR, "Internal server error".into())
44
+ }
45
+ };
46
+ (status, Json(json!({ "error": message }))).into_response()
47
+ }
48
+ }
49
+ ```
50
+
51
+ ## Cloneable AppState and startup migrations
52
+
53
+ ```rust
54
+ // src/state.rs
55
+ use sqlx::PgPool;
56
+ use std::sync::Arc;
57
+
58
+ #[derive(Clone)]
59
+ pub struct AppState {
60
+ pub db: PgPool, // already Clone + Send + Sync — no Mutex
61
+ pub config: Arc<crate::config::Config>,
62
+ }
63
+
64
+ // src/config.rs
65
+ #[derive(Debug, Clone)]
66
+ pub struct Config {
67
+ pub database_url: String,
68
+ pub jwt_secret: String,
69
+ pub port: u16,
70
+ }
71
+
72
+ impl Config {
73
+ pub fn from_env() -> anyhow::Result<Self> {
74
+ Ok(Self {
75
+ database_url: std::env::var("DATABASE_URL")?,
76
+ jwt_secret: std::env::var("JWT_SECRET")?,
77
+ port: std::env::var("PORT").unwrap_or("3000".into()).parse()?,
78
+ })
79
+ }
80
+ }
81
+
82
+ // src/main.rs
83
+ #[tokio::main]
84
+ async fn main() -> anyhow::Result<()> {
85
+ tracing_subscriber::fmt()
86
+ .with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
87
+ .init();
88
+
89
+ let config = Arc::new(Config::from_env()?);
90
+ let pool = PgPool::connect(&config.database_url).await?;
91
+ sqlx::migrate!("./migrations").run(&pool).await?; // never skipped
92
+
93
+ let state = AppState { db: pool, config: config.clone() };
94
+ let router = routes::create_router(state);
95
+ let listener = tokio::net::TcpListener::bind(format!("0.0.0.0:{}", config.port)).await?;
96
+ axum::serve(listener, router).await?;
97
+ Ok(())
98
+ }
99
+ ```
@@ -0,0 +1,87 @@
1
+ # Reference: Axum handlers, models, and router assembly (read on demand)
2
+
3
+ Exemplar for `stack/rust-axum`.
4
+
5
+ ## Models: DB row + validated request type
6
+
7
+ ```rust
8
+ // src/models/user.rs
9
+ use serde::{Deserialize, Serialize};
10
+ use uuid::Uuid;
11
+ use chrono::{DateTime, Utc};
12
+
13
+ #[derive(Debug, Serialize, sqlx::FromRow)]
14
+ pub struct User {
15
+ pub id: Uuid,
16
+ pub email: String,
17
+ pub name: String,
18
+ pub created_at: DateTime<Utc>,
19
+ }
20
+
21
+ #[derive(Debug, Deserialize, validator::Validate)]
22
+ pub struct CreateUserRequest {
23
+ #[validate(email)]
24
+ pub email: String,
25
+ #[validate(length(min = 2, max = 100))]
26
+ pub name: String,
27
+ }
28
+ ```
29
+
30
+ ## Instrumented handlers with compile-time-checked queries
31
+
32
+ ```rust
33
+ // src/handlers/users.rs
34
+ use axum::{
35
+ extract::{Path, State},
36
+ http::StatusCode,
37
+ Json,
38
+ };
39
+ use uuid::Uuid;
40
+
41
+ #[tracing::instrument(skip(state))]
42
+ pub async fn create_user(
43
+ State(state): State<AppState>,
44
+ Json(body): Json<CreateUserRequest>,
45
+ ) -> Result<(StatusCode, Json<User>), AppError> {
46
+ let user = sqlx::query_as!(
47
+ User,
48
+ "INSERT INTO users (email, name) VALUES ($1, $2) RETURNING *",
49
+ body.email,
50
+ body.name
51
+ )
52
+ .fetch_one(&state.db)
53
+ .await?;
54
+
55
+ Ok((StatusCode::CREATED, Json(user)))
56
+ }
57
+
58
+ #[tracing::instrument(skip(state))]
59
+ pub async fn get_user(
60
+ State(state): State<AppState>,
61
+ Path(id): Path<Uuid>,
62
+ ) -> Result<Json<User>, AppError> {
63
+ let user = sqlx::query_as!(User, "SELECT * FROM users WHERE id = $1", id)
64
+ .fetch_optional(&state.db)
65
+ .await?
66
+ .ok_or_else(|| AppError::NotFound(format!("User {id} not found")))?;
67
+
68
+ Ok(Json(user))
69
+ }
70
+ ```
71
+
72
+ ## Router assembly with tracing layer
73
+
74
+ ```rust
75
+ // src/routes/mod.rs
76
+ use axum::{routing::{get, post}, Router};
77
+
78
+ pub fn create_router(state: AppState) -> Router {
79
+ Router::new()
80
+ .route("/api/users", post(handlers::users::create_user))
81
+ .route("/api/users/{id}", get(handlers::users::get_user))
82
+ .layer(tower_http::trace::TraceLayer::new_for_http())
83
+ .with_state(state)
84
+ }
85
+ ```
86
+
87
+ Note: newer axum releases use `{id}` path-parameter syntax; older ones used `:id`. Match whatever the project's installed version expects.
@@ -0,0 +1,86 @@
1
+ # Reference: Stripe billing patterns (read on demand)
2
+
3
+ Exemplar for `domain/saas-stripe-billing` — queued webhook handling, status-based access gates, end-of-period cancellation, and meter-event usage reporting. Evicted from the standing fragment; read when implementing one of these mechanisms.
4
+
5
+ ## Webhook: verify → dedupe → enqueue → 200
6
+
7
+ ```javascript
8
+ // ❌ WRONG: processing inside the request — provider timeout ⇒ redelivery ⇒ double-apply
9
+ app.post('/webhooks/stripe', async (req, res) => {
10
+ await processSubscriptionChange(req.body);
11
+ res.sendStatus(200);
12
+ });
13
+
14
+ // ✅ RIGHT: verify the signature FIRST, dedupe by event id, enqueue, answer fast
15
+ app.post('/webhooks/stripe', async (req, res) => {
16
+ let event;
17
+ try {
18
+ event = stripe.webhooks.constructEvent(
19
+ req.rawBody, req.headers['stripe-signature'], process.env.STRIPE_WEBHOOK_SECRET,
20
+ );
21
+ } catch {
22
+ return res.sendStatus(400); // unverified payloads are never parsed further
23
+ }
24
+ const fresh = await markProcessedOnce(event.id); // idempotency: event.id as the key
25
+ if (fresh) await queue.add('stripe-event', { id: event.id, type: event.type });
26
+ res.sendStatus(200);
27
+ });
28
+ ```
29
+
30
+ The worker re-fetches the event (or object) from Stripe, switches on `event.type` before touching `event.data.object`, and applies an idempotent state sync. Stripe is the source of truth — the local mirror keeps only `stripe_customer_id`, `stripe_subscription_id`, `plan/price id`, `status`, `period end`.
31
+
32
+ Local development: run the Stripe CLI listener (`stripe listen --forward-to localhost:3000/webhooks/stripe`) to simulate deliveries against the real signature check.
33
+
34
+ ## Access gate on status, never on timestamps
35
+
36
+ ```javascript
37
+ // ❌ WRONG: a past_due user still has a future period end
38
+ if (subscription.current_period_end > Date.now()) allowAccess();
39
+
40
+ // ✅ RIGHT: the status is the gate; past_due means grace period, not cancelled
41
+ if (['active', 'trialing'].includes(subscription.status)) allowAccess();
42
+ ```
43
+
44
+ Feature gates are one centralized middleware resolved from the plan (short-TTL cache, ~60s):
45
+
46
+ ```javascript
47
+ async function requireFeature(feature) {
48
+ return async (req, res, next) => {
49
+ const plan = await getPlanForTenant(req.tenantId); // cached; never from the client
50
+ if (!plan.features.includes(feature)) {
51
+ return res.status(402).json({ code: 'UPGRADE_REQUIRED', feature });
52
+ }
53
+ next();
54
+ };
55
+ }
56
+ ```
57
+
58
+ ## Cancellation and plan changes
59
+
60
+ ```javascript
61
+ // ❌ WRONG: cancels immediately — the user loses the period they paid for
62
+ await stripe.subscriptions.cancel(subId);
63
+
64
+ // ✅ RIGHT: cancel at the end of the paid period (default flow)
65
+ await stripe.subscriptions.update(subId, { cancel_at_period_end: true });
66
+ ```
67
+
68
+ - Upgrades/downgrades: fetch the upcoming-invoice proration preview, show it, and only then apply the change.
69
+ - Every Stripe write call carries an idempotency key (retries must not double-charge).
70
+ - Never delete the Stripe customer — it holds the fiscal/invoice history; cancel subscriptions instead.
71
+ - Never call the Stripe API inside a database transaction: external latency inside a transaction invites deadlocks and lock pileups.
72
+
73
+ ## Usage-based billing (meter events)
74
+
75
+ Stripe's current metering model is Billing Meters: usage is reported as meter events and prices reference the meter. The older usage-records API is deprecated — do not build new metering on it.
76
+
77
+ ```javascript
78
+ // Report usage with the ORIGINAL event timestamp, never server "now"
79
+ await stripe.billing.meterEvents.create({
80
+ event_name: 'api_calls',
81
+ payload: { stripe_customer_id: customerId, value: '25' },
82
+ timestamp: eventOccurredAt, // when the usage actually happened
83
+ });
84
+ ```
85
+
86
+ Late or replayed deliveries with the original timestamp land in the correct billing period; server-time stamps silently shift usage across invoices.
@@ -0,0 +1,107 @@
1
+ # Reference: Lambda handler patterns — Powertools, responses, IAM (read on demand)
2
+
3
+ Exemplar for `stack/serverless-lambda`.
4
+
5
+ ## Module-scope client init (cold-start discipline)
6
+
7
+ ```typescript
8
+ // CORRECT: initialize clients OUTSIDE the handler (module scope)
9
+ // Runs once per container, not per invocation
10
+ const docClient = new DynamoDBDocumentClient(new DynamoDBClient({}))
11
+ const userRepo = new UserRepository(docClient)
12
+
13
+ export const handler = async (event: APIGatewayProxyEventV2) => {
14
+ // docClient already initialized
15
+ }
16
+
17
+ // WRONG: initializing inside the handler pays the cost on every call
18
+ ```
19
+
20
+ ## Powertools + middy handler
21
+
22
+ ```typescript
23
+ // src/handlers/users/get.ts
24
+ import { APIGatewayProxyEventV2, APIGatewayProxyResultV2 } from 'aws-lambda'
25
+ import { Logger } from '@aws-lambda-powertools/logger'
26
+ import { Tracer } from '@aws-lambda-powertools/tracer'
27
+ import { Metrics, MetricUnits } from '@aws-lambda-powertools/metrics'
28
+ import { injectLambdaContext } from '@aws-lambda-powertools/logger/middleware'
29
+ import { captureLambdaHandler } from '@aws-lambda-powertools/tracer/middleware'
30
+ import middy from '@middy/core'
31
+ import { z } from 'zod'
32
+ import { UserService } from '../../services/users.service'
33
+ import { ok, notFound, badRequest } from '../../lib/response'
34
+
35
+ const logger = new Logger({ serviceName: 'users-api', logLevel: 'INFO' })
36
+ const tracer = new Tracer({ serviceName: 'users-api' })
37
+ const metrics = new Metrics({ namespace: 'UsersAPI', serviceName: 'users-api' })
38
+
39
+ const paramsSchema = z.object({
40
+ id: z.string().uuid('Invalid user ID format'),
41
+ })
42
+
43
+ const lambdaHandler = async (event: APIGatewayProxyEventV2): Promise<APIGatewayProxyResultV2> => {
44
+ const parsed = paramsSchema.safeParse(event.pathParameters)
45
+ if (!parsed.success) {
46
+ return badRequest(parsed.error.flatten())
47
+ }
48
+
49
+ const user = await UserService.getById(parsed.data.id)
50
+ if (!user) {
51
+ logger.warn('User not found', { userId: parsed.data.id })
52
+ return notFound('User not found')
53
+ }
54
+
55
+ metrics.addMetric('UserFetched', MetricUnits.Count, 1)
56
+ logger.info('User fetched', { userId: user.id })
57
+ return ok(user)
58
+ }
59
+
60
+ export const handler = middy(lambdaHandler)
61
+ .use(injectLambdaContext(logger, { clearState: true }))
62
+ .use(captureLambdaHandler(tracer))
63
+ ```
64
+
65
+ ## Standard response helpers
66
+
67
+ ```typescript
68
+ // src/lib/response.ts
69
+ import type { APIGatewayProxyResultV2 } from 'aws-lambda'
70
+
71
+ function json(statusCode: number, body: unknown): APIGatewayProxyResultV2 {
72
+ return {
73
+ statusCode,
74
+ headers: { 'Content-Type': 'application/json' },
75
+ body: JSON.stringify(body),
76
+ }
77
+ }
78
+
79
+ export const ok = (data: unknown) => json(200, { data })
80
+ export const created = (data: unknown) => json(201, { data })
81
+ export const badRequest = (details: unknown) => json(400, { error: 'Bad Request', details })
82
+ export const unauthorized = () => json(401, { error: 'Unauthorized' })
83
+ export const forbidden = () => json(403, { error: 'Forbidden' })
84
+ export const notFound = (msg: string) => json(404, { error: msg })
85
+ export const internalError = () => json(500, { error: 'Internal Server Error' })
86
+ ```
87
+
88
+ ## Least-privilege IAM in the IaC stack (SST example)
89
+
90
+ ```typescript
91
+ // sst.config.ts — explicit permissions, never AdministratorAccess
92
+ const usersTable = new sst.aws.Dynamo('UsersTable', {
93
+ fields: { pk: 'string', sk: 'string' },
94
+ primaryIndex: { hashKey: 'pk', rangeKey: 'sk' },
95
+ })
96
+
97
+ const getUserFn = new sst.aws.Function('GetUser', {
98
+ handler: 'packages/functions/src/handlers/users/get.handler',
99
+ environment: {
100
+ USERS_TABLE_NAME: usersTable.name,
101
+ JWT_SECRET: new sst.Secret('JwtSecret').value, // SSM-backed secret, not plaintext env
102
+ },
103
+ permissions: [
104
+ { actions: ['dynamodb:GetItem'], resources: [usersTable.arn] }, // only what this fn needs
105
+ ],
106
+ })
107
+ ```
@@ -0,0 +1,54 @@
1
+ # Reference: payments pitfalls (read on demand)
2
+
3
+ Exemplar for `domain/sistema-pagamentos` — the three failure modes that produce real financial loss, each shown wrong vs right. Evicted from the standing fragment; read when implementing payment creation, 3-D Secure confirmation, or refunds.
4
+
5
+ ## Trusting the frontend for the 3DS outcome (wrong vs right)
6
+
7
+ ```javascript
8
+ // ❌ WRONG: the frontend can be manipulated into claiming 3DS passed
9
+ app.post('/confirm', async (req) => {
10
+ const { paymentIntentId, confirmed3DS } = req.body;
11
+ if (confirmed3DS) await fulfillOrder(paymentIntentId); // DANGER
12
+ });
13
+
14
+ // ✅ RIGHT: only the gateway webhook confirms the outcome.
15
+ // The frontend merely redirects through the issuer authentication;
16
+ // fulfillment is triggered by the signed webhook event:
17
+ // payment_intent.succeeded → fulfillOrder(...)
18
+ // payment_intent.payment_failed → markFailed(...)
19
+ ```
20
+
21
+ ## Refund without a ceiling check (wrong vs right)
22
+
23
+ ```javascript
24
+ // ❌ WRONG: allows refunding more than was captured
25
+ await gateway.refunds.create({ payment_intent: id, amount: refundAmount });
26
+
27
+ // ✅ RIGHT: compute the maximum refundable amount in code first
28
+ const payment = await db.payments.findOne(id);
29
+ const alreadyRefunded = await db.refunds.sum({ paymentId: id });
30
+ const maxRefundable = payment.captured_amount - alreadyRefunded;
31
+ if (refundAmount > maxRefundable) {
32
+ throw new BusinessError('REFUND_EXCEEDS_CAPTURED');
33
+ }
34
+ await gateway.refunds.create({ payment_intent: id, amount: refundAmount });
35
+ ```
36
+
37
+ ## New idempotency key on retry (wrong vs right)
38
+
39
+ ```javascript
40
+ // ❌ WRONG: a fresh key per attempt double-charges when the request
41
+ // reached the gateway but the response was lost
42
+ async function createPayment(data) {
43
+ const key = uuid(); // new key every retry
44
+ return gateway.paymentIntents.create(data, { idempotencyKey: key });
45
+ }
46
+
47
+ // ✅ RIGHT: the key belongs to the logical attempt, not the HTTP call —
48
+ // persist it, and reuse the SAME key on every retry of that attempt
49
+ async function createPayment(data, idempotencyKey) {
50
+ return gateway.paymentIntents.create(data, { idempotencyKey });
51
+ }
52
+ ```
53
+
54
+ The same rule applies locally: store the idempotency key with the payment record and check it before creating a new intent, so a duplicated inbound request short-circuits to the existing payment instead of creating a second one.