@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,167 @@
1
+ # Reference: SaaS billing patterns (read on demand)
2
+
3
+ Exemplar for `stack/nextjs-prisma-postgres` — subscription schema, verified idempotent Stripe webhook, checkout session, server-side feature gate, transactional email. The exemplars use Drizzle-style schema code; translate to your project's ORM (Prisma models map one-to-one).
4
+
5
+ ## Subscription schema
6
+
7
+ ```typescript
8
+ // db/schema/subscriptions.ts
9
+ import { pgTable, text, timestamp, boolean } from 'drizzle-orm/pg-core';
10
+ import { users } from './users';
11
+
12
+ export const subscriptions = pgTable('subscriptions', {
13
+ id: text('id').primaryKey(),
14
+ userId: text('user_id').references(() => users.id, { onDelete: 'cascade' }).notNull(),
15
+ stripeSubscriptionId: text('stripe_subscription_id').unique().notNull(),
16
+ stripePriceId: text('stripe_price_id').notNull(),
17
+ status: text('status', {
18
+ enum: ['active', 'canceled', 'past_due', 'incomplete', 'trialing'],
19
+ }).notNull(),
20
+ currentPeriodEnd: timestamp('current_period_end').notNull(),
21
+ cancelAtPeriodEnd: boolean('cancel_at_period_end').default(false).notNull(),
22
+ createdAt: timestamp('created_at').defaultNow().notNull(),
23
+ updatedAt: timestamp('updated_at').defaultNow().notNull(),
24
+ });
25
+ ```
26
+
27
+ Users table carries `stripeCustomerId` (unique, nullable) and a `plan` enum defaulting to the free tier.
28
+
29
+ ## Webhook handler — verify signature, upsert idempotently
30
+
31
+ ```typescript
32
+ // app/api/webhooks/stripe/route.ts
33
+ import { headers } from 'next/headers';
34
+ import Stripe from 'stripe';
35
+ import { db } from '@/db';
36
+ import { subscriptions } from '@/db/schema';
37
+ import { eq } from 'drizzle-orm';
38
+
39
+ const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!);
40
+
41
+ export async function POST(req: Request) {
42
+ const body = await req.text();
43
+ const sig = (await headers()).get('stripe-signature')!;
44
+
45
+ let event: Stripe.Event;
46
+ try {
47
+ event = stripe.webhooks.constructEvent(body, sig, process.env.STRIPE_WEBHOOK_SECRET!);
48
+ } catch {
49
+ return new Response('Webhook signature verification failed', { status: 400 });
50
+ }
51
+
52
+ switch (event.type) {
53
+ case 'customer.subscription.created':
54
+ case 'customer.subscription.updated': {
55
+ const sub = event.data.object as Stripe.Subscription;
56
+ await db.insert(subscriptions).values({
57
+ id: crypto.randomUUID(),
58
+ userId: sub.metadata.userId,
59
+ stripeSubscriptionId: sub.id,
60
+ stripePriceId: sub.items.data[0].price.id,
61
+ status: sub.status,
62
+ currentPeriodEnd: new Date(sub.current_period_end * 1000),
63
+ cancelAtPeriodEnd: sub.cancel_at_period_end,
64
+ }).onConflictDoUpdate({
65
+ target: subscriptions.stripeSubscriptionId,
66
+ set: {
67
+ status: sub.status,
68
+ stripePriceId: sub.items.data[0].price.id,
69
+ currentPeriodEnd: new Date(sub.current_period_end * 1000),
70
+ cancelAtPeriodEnd: sub.cancel_at_period_end,
71
+ updatedAt: new Date(),
72
+ },
73
+ });
74
+ break;
75
+ }
76
+ case 'customer.subscription.deleted': {
77
+ const sub = event.data.object as Stripe.Subscription;
78
+ await db.update(subscriptions)
79
+ .set({ status: 'canceled', updatedAt: new Date() })
80
+ .where(eq(subscriptions.stripeSubscriptionId, sub.id));
81
+ break;
82
+ }
83
+ }
84
+
85
+ return new Response('ok', { status: 200 });
86
+ }
87
+ ```
88
+
89
+ ## Checkout session (server-side, user id in metadata)
90
+
91
+ ```typescript
92
+ // lib/stripe.ts
93
+ export async function createCheckoutSession(userId: string, priceId: string) {
94
+ const session = await stripe.checkout.sessions.create({
95
+ mode: 'subscription',
96
+ line_items: [{ price: priceId, quantity: 1 }],
97
+ success_url: `${process.env.NEXT_PUBLIC_APP_URL}/dashboard?success=true`,
98
+ cancel_url: `${process.env.NEXT_PUBLIC_APP_URL}/pricing`,
99
+ metadata: { userId },
100
+ subscription_data: { metadata: { userId } },
101
+ });
102
+ return session.url;
103
+ }
104
+ ```
105
+
106
+ Customer portal: `stripe.billingPortal.sessions.create()` — same server-side rule.
107
+
108
+ ## Server-side feature gate
109
+
110
+ ```typescript
111
+ // lib/auth-utils.ts
112
+ export async function requirePro(userId: string) {
113
+ const sub = await db.query.subscriptions.findFirst({
114
+ where: (s, { eq, and, gt }) => and(
115
+ eq(s.userId, userId),
116
+ eq(s.status, 'active'),
117
+ gt(s.currentPeriodEnd, new Date()),
118
+ ),
119
+ });
120
+ if (!sub) throw new Error('Pro subscription required');
121
+ return sub;
122
+ }
123
+ ```
124
+
125
+ ## Transactional email (typed template)
126
+
127
+ ```typescript
128
+ // lib/email.ts
129
+ import { Resend } from 'resend';
130
+ import { WelcomeEmail } from '@/emails/welcome';
131
+
132
+ const resend = new Resend(process.env.RESEND_API_KEY);
133
+
134
+ export async function sendWelcomeEmail(to: string, name: string) {
135
+ await resend.emails.send({
136
+ from: 'App <noreply@yourdomain.com>',
137
+ to,
138
+ subject: `Welcome, ${name}!`,
139
+ react: WelcomeEmail({ name }),
140
+ });
141
+ }
142
+ ```
143
+
144
+ ## Testing the webhook
145
+
146
+ ```typescript
147
+ // __tests__/webhooks/stripe.test.ts
148
+ import { describe, it, expect } from 'vitest';
149
+
150
+ describe('Stripe webhook', () => {
151
+ it('rejects requests with invalid signature', async () => {
152
+ const res = await fetch('/api/webhooks/stripe', {
153
+ method: 'POST',
154
+ body: '{}',
155
+ headers: { 'stripe-signature': 'invalid' },
156
+ });
157
+ expect(res.status).toBe(400);
158
+ });
159
+ });
160
+ ```
161
+
162
+ Integration testing with the Stripe CLI:
163
+
164
+ ```bash
165
+ stripe listen --forward-to localhost:3000/api/webhooks/stripe
166
+ stripe trigger customer.subscription.updated
167
+ ```
@@ -0,0 +1,121 @@
1
+ # Reference: Drizzle schema, RSC+client hybrid, auth (read on demand)
2
+
3
+ Exemplar for `stack/nextjs-trpc-drizzle` — schema with relations, RSC prefetch hydrating client hooks with optimistic updates, Auth.js config with session type augmentation.
4
+
5
+ ## Drizzle schema + single client
6
+
7
+ ```typescript
8
+ // src/server/db/schema.ts
9
+ import { pgTable, text, boolean, timestamp } from 'drizzle-orm/pg-core'
10
+ import { relations } from 'drizzle-orm'
11
+ import { createId } from '@paralleldrive/cuid2'
12
+
13
+ export const users = pgTable('users', {
14
+ id: text('id').primaryKey().$defaultFn(createId),
15
+ name: text('name'),
16
+ email: text('email').notNull().unique(),
17
+ emailVerified: timestamp('email_verified', { mode: 'date' }),
18
+ image: text('image'),
19
+ role: text('role', { enum: ['user', 'admin'] }).notNull().default('user'),
20
+ })
21
+
22
+ export const posts = pgTable('posts', {
23
+ id: text('id').primaryKey().$defaultFn(createId),
24
+ title: text('title').notNull(),
25
+ content: text('content').notNull(),
26
+ published: boolean('published').notNull().default(false),
27
+ authorId: text('author_id').notNull().references(() => users.id, { onDelete: 'cascade' }),
28
+ createdAt: timestamp('created_at', { mode: 'date' }).defaultNow(),
29
+ })
30
+
31
+ export const usersRelations = relations(users, ({ many }) => ({ posts: many(posts) }))
32
+ export const postsRelations = relations(posts, ({ one }) => ({
33
+ author: one(users, { fields: [posts.authorId], references: [users.id] }),
34
+ }))
35
+ ```
36
+
37
+ ```typescript
38
+ // src/server/db/index.ts — ONE client for the whole app
39
+ import { neon } from '@neondatabase/serverless'
40
+ import { drizzle } from 'drizzle-orm/neon-http'
41
+ import * as schema from './schema'
42
+
43
+ const sql = neon(process.env.DATABASE_URL!)
44
+ export const db = drizzle(sql, { schema })
45
+ export type DB = typeof db
46
+ ```
47
+
48
+ Runtime note: use the serverless HTTP driver on edge runtimes; use a `Pool` on a long-lived Node runtime — never mix, never instantiate per request.
49
+
50
+ ## RSC prefetch → client hydration with optimistic update
51
+
52
+ ```typescript
53
+ // src/app/(dashboard)/dashboard/page.tsx — SERVER COMPONENT
54
+ import { api } from '~/trpc/server'
55
+
56
+ export default async function DashboardPage() {
57
+ const posts = await api.post.list({ limit: 10 })
58
+ return <PostList initialPosts={posts} />
59
+ }
60
+ ```
61
+
62
+ ```typescript
63
+ // src/components/PostList.tsx — CLIENT COMPONENT
64
+ 'use client'
65
+ import { trpc } from '~/trpc/react'
66
+
67
+ export function PostList({ initialPosts }: { initialPosts: Post[] }) {
68
+ const { data: posts } = trpc.post.list.useQuery(
69
+ { limit: 10 },
70
+ { initialData: initialPosts }, // hydrate from RSC
71
+ )
72
+
73
+ const utils = trpc.useUtils()
74
+ const create = trpc.post.create.useMutation({
75
+ onMutate: async (newPost) => {
76
+ await utils.post.list.cancel()
77
+ const prev = utils.post.list.getData({ limit: 10 })
78
+ utils.post.list.setData({ limit: 10 }, (old) =>
79
+ old ? [{ ...newPost, id: 'temp', createdAt: new Date() }, ...old] : old,
80
+ )
81
+ return { prev }
82
+ },
83
+ onError: (_, __, ctx) => utils.post.list.setData({ limit: 10 }, ctx?.prev),
84
+ onSettled: () => utils.post.list.invalidate(),
85
+ })
86
+
87
+ return <ul>{posts?.map((p) => <li key={p.id}>{p.title}</li>)}</ul>
88
+ }
89
+ ```
90
+
91
+ ## Auth.js config with typed session
92
+
93
+ ```typescript
94
+ // src/server/auth.ts
95
+ import NextAuth, { type DefaultSession } from 'next-auth'
96
+ import GitHub from 'next-auth/providers/github'
97
+ import { DrizzleAdapter } from '@auth/drizzle-adapter'
98
+ import { db } from './db'
99
+
100
+ declare module 'next-auth' {
101
+ interface Session {
102
+ user: { id: string; role: 'user' | 'admin' } & DefaultSession['user']
103
+ }
104
+ }
105
+
106
+ export const { handlers, auth, signIn, signOut } = NextAuth({
107
+ adapter: DrizzleAdapter(db),
108
+ providers: [GitHub],
109
+ callbacks: {
110
+ session: ({ session, user }) => ({
111
+ ...session,
112
+ user: {
113
+ ...session.user,
114
+ id: user.id,
115
+ role: (user as typeof user & { role: string }).role ?? 'user',
116
+ },
117
+ }),
118
+ },
119
+ pages: { signIn: '/login' },
120
+ })
121
+ ```
@@ -0,0 +1,62 @@
1
+ # Reference: tRPC + App Router setup (read on demand)
2
+
3
+ Exemplar for `stack/nextjs-trpc-drizzle` — request context, protected procedure, fetch adapter route, RSC caller.
4
+
5
+ ## Context and procedures
6
+
7
+ ```typescript
8
+ // src/server/api/trpc.ts
9
+ import { initTRPC, TRPCError } from '@trpc/server'
10
+ import { cache } from 'react'
11
+ import superjson from 'superjson'
12
+ import { auth } from '../auth'
13
+ import { db } from '../db'
14
+
15
+ export const createTRPCContext = cache(async () => {
16
+ const session = await auth()
17
+ return { db, session }
18
+ })
19
+
20
+ const t = initTRPC.context<typeof createTRPCContext>().create({
21
+ transformer: superjson,
22
+ })
23
+
24
+ export const createTRPCRouter = t.router
25
+ export const createCallerFactory = t.createCallerFactory
26
+ export const publicProcedure = t.procedure
27
+
28
+ export const protectedProcedure = t.procedure.use(async ({ ctx, next }) => {
29
+ if (!ctx.session?.user?.id) throw new TRPCError({ code: 'UNAUTHORIZED' })
30
+ return next({ ctx: { ...ctx, session: ctx.session } })
31
+ })
32
+ ```
33
+
34
+ ## Route handler (fetch adapter)
35
+
36
+ ```typescript
37
+ // src/app/api/trpc/[trpc]/route.ts
38
+ import { fetchRequestHandler } from '@trpc/server/adapters/fetch'
39
+ import { appRouter } from '~/server/api/root'
40
+ import { createTRPCContext } from '~/server/api/trpc'
41
+
42
+ const handler = (req: Request) =>
43
+ fetchRequestHandler({
44
+ endpoint: '/api/trpc',
45
+ req,
46
+ router: appRouter,
47
+ createContext: createTRPCContext,
48
+ })
49
+
50
+ export { handler as GET, handler as POST }
51
+ ```
52
+
53
+ ## RSC caller (no HTTP round trip)
54
+
55
+ ```typescript
56
+ // src/trpc/server.ts
57
+ import { createCallerFactory, appRouter } from '~/server/api/root'
58
+ import { createTRPCContext } from '~/server/api/trpc'
59
+
60
+ const createCaller = createCallerFactory(appRouter)
61
+ export const api = createCaller(await createTRPCContext())
62
+ ```
@@ -0,0 +1,48 @@
1
+ # Reference: Env config and token service (read on demand)
2
+
3
+ Exemplar for `stack/nodejs-express-typescript` — Zod-validated environment module (the only reader of `process.env`) and the JWT token service.
4
+
5
+ ## Validated env module
6
+
7
+ ```typescript
8
+ // src/config/env.ts
9
+ import { z } from 'zod'
10
+
11
+ const envSchema = z.object({
12
+ NODE_ENV: z.enum(['development', 'test', 'production']).default('development'),
13
+ PORT: z.coerce.number().default(3000),
14
+ DATABASE_URL: z.string().url(),
15
+ JWT_ACCESS_SECRET: z.string().min(32),
16
+ JWT_REFRESH_SECRET: z.string().min(32),
17
+ CORS_ORIGIN: z.string().default('http://localhost:5173'),
18
+ })
19
+
20
+ const parsed = envSchema.safeParse(process.env)
21
+ if (!parsed.success) {
22
+ console.error('Invalid environment variables:', parsed.error.format())
23
+ process.exit(1)
24
+ }
25
+
26
+ export const env = parsed.data
27
+ ```
28
+
29
+ ## Token service (short-lived access, separate refresh secret)
30
+
31
+ ```typescript
32
+ // src/modules/auth/auth.service.ts
33
+ import jwt from 'jsonwebtoken'
34
+ import { env } from '../../config/env'
35
+ import type { JwtPayload } from '../../middlewares/auth.middleware'
36
+
37
+ export function signAccessToken(payload: Omit<JwtPayload, 'iat' | 'exp'>): string {
38
+ return jwt.sign(payload, env.JWT_ACCESS_SECRET, { expiresIn: '15m' })
39
+ }
40
+
41
+ export function signRefreshToken(userId: string): string {
42
+ return jwt.sign({ sub: userId }, env.JWT_REFRESH_SECRET, { expiresIn: '7d' })
43
+ }
44
+
45
+ export function verifyRefreshToken(token: string): { sub: string } {
46
+ return jwt.verify(token, env.JWT_REFRESH_SECRET) as { sub: string }
47
+ }
48
+ ```
@@ -0,0 +1,108 @@
1
+ # Reference: Express middleware patterns (read on demand)
2
+
3
+ Exemplar for `stack/nodejs-express-typescript` — JWT auth + role middleware, Zod validation factory, global error handler.
4
+
5
+ ## JWT auth middleware (typed payload, declaration merging)
6
+
7
+ ```typescript
8
+ // src/middlewares/auth.middleware.ts
9
+ import type { Request, Response, NextFunction } from 'express'
10
+ import jwt from 'jsonwebtoken'
11
+ import { env } from '../config/env'
12
+ import { HttpError } from '../shared/errors/HttpError'
13
+
14
+ export interface JwtPayload {
15
+ sub: string
16
+ email: string
17
+ role: 'admin' | 'user'
18
+ iat: number
19
+ exp: number
20
+ }
21
+
22
+ declare global {
23
+ namespace Express {
24
+ interface Request {
25
+ user?: JwtPayload
26
+ }
27
+ }
28
+ }
29
+
30
+ export function authenticate(req: Request, _res: Response, next: NextFunction): void {
31
+ const header = req.headers.authorization
32
+ if (!header?.startsWith('Bearer ')) {
33
+ throw new HttpError(401, 'Missing or invalid Authorization header')
34
+ }
35
+
36
+ const token = header.slice(7)
37
+ try {
38
+ const payload = jwt.verify(token, env.JWT_ACCESS_SECRET) as JwtPayload
39
+ req.user = payload
40
+ next()
41
+ } catch {
42
+ throw new HttpError(401, 'Token expired or invalid')
43
+ }
44
+ }
45
+
46
+ export function authorize(...roles: JwtPayload['role'][]) {
47
+ return (req: Request, _res: Response, next: NextFunction): void => {
48
+ if (!req.user || !roles.includes(req.user.role)) {
49
+ throw new HttpError(403, 'Insufficient permissions')
50
+ }
51
+ next()
52
+ }
53
+ }
54
+ ```
55
+
56
+ ## Zod validation factory (replaces raw input with coerced data)
57
+
58
+ ```typescript
59
+ // src/middlewares/validate.middleware.ts
60
+ import type { Request, Response, NextFunction } from 'express'
61
+ import { ZodSchema } from 'zod'
62
+ import { HttpError } from '../shared/errors/HttpError'
63
+
64
+ type Target = 'body' | 'query' | 'params'
65
+
66
+ export function validate(schema: ZodSchema, target: Target = 'body') {
67
+ return (req: Request, _res: Response, next: NextFunction): void => {
68
+ const result = schema.safeParse(req[target])
69
+ if (!result.success) {
70
+ const messages = result.error.errors.map(e => `${e.path.join('.')}: ${e.message}`)
71
+ throw new HttpError(422, 'Validation failed', messages)
72
+ }
73
+ req[target] = result.data // replace with parsed/coerced data
74
+ next()
75
+ }
76
+ }
77
+ ```
78
+
79
+ ## Global error handler (single exit point)
80
+
81
+ ```typescript
82
+ // src/middlewares/error.middleware.ts
83
+ import type { Request, Response, NextFunction } from 'express'
84
+ import { HttpError } from '../shared/errors/HttpError'
85
+ import { env } from '../config/env'
86
+
87
+ export function errorHandler(
88
+ err: unknown,
89
+ req: Request,
90
+ res: Response,
91
+ _next: NextFunction
92
+ ): void {
93
+ if (err instanceof HttpError) {
94
+ res.status(err.statusCode).json({
95
+ error: err.message,
96
+ ...(err.details && { details: err.details }),
97
+ ...(env.NODE_ENV === 'development' && { stack: err.stack }),
98
+ })
99
+ return
100
+ }
101
+
102
+ console.error('[Unhandled Error]', err)
103
+ res.status(500).json({
104
+ error: 'Internal server error',
105
+ ...(env.NODE_ENV === 'development' && { raw: String(err) }),
106
+ })
107
+ }
108
+ ```
@@ -0,0 +1,78 @@
1
+ # Reference: multi-channel notification patterns (read on demand)
2
+
3
+ Exemplar for `domain/notificacoes-multicanal` — idempotent delivery, preference-filtered fan-out, and invalid push-token cleanup. Evicted from the standing fragment; read when implementing one of these mechanisms.
4
+
5
+ ## Idempotent delivery (wrong vs right)
6
+
7
+ ```javascript
8
+ // ❌ WRONG: every retry sends another email — the user gets duplicates
9
+ async function sendEmailJob(data) {
10
+ await emailProvider.send(data);
11
+ }
12
+
13
+ // ✅ RIGHT: check the delivery record before sending
14
+ async function sendEmailJob(data) {
15
+ const delivery = await db.deliveries.findOne({ id: data.deliveryId });
16
+ if (delivery.status === 'sent') return; // already delivered — skip
17
+ await emailProvider.send(data);
18
+ await delivery.update({ status: 'sent', sentAt: new Date() });
19
+ }
20
+ ```
21
+
22
+ One `deliveries` row per (notification × recipient × channel) is the idempotency anchor: retries re-check it, provider webhooks update it (`delivered`, `bounced`, `unsubscribed`), and the admin status view reads from it.
23
+
24
+ ## Preference-filtered fan-out (wrong vs right)
25
+
26
+ ```javascript
27
+ // ❌ WRONG: blast every user, ignore preferences and bounces
28
+ const users = await db.users.findAll();
29
+ for (const user of users) await sendEmail(user.email, template);
30
+
31
+ // ✅ RIGHT: filter BEFORE enqueueing — preferences, verification, bounce state
32
+ const recipients = await db.users.findAll({
33
+ where: {
34
+ emailNotificationsEnabled: true, // per-channel preference
35
+ emailVerified: true,
36
+ emailBounced: false, // hard-bounced addresses are suppressed
37
+ },
38
+ });
39
+ // Then, per recipient: check the per-event-type preference, quiet hours
40
+ // (recipient's timezone) and the daily frequency cap before creating the
41
+ // delivery record and enqueueing.
42
+ ```
43
+
44
+ Transactional notifications (password reset, purchase confirmation) skip only the *marketing* opt-out checks — never the bounce suppression.
45
+
46
+ ## Invalid push-token cleanup (wrong vs right)
47
+
48
+ ```javascript
49
+ // ❌ WRONG: keep retrying a token the device already rotated
50
+ await pushProvider.send({ token: user.pushToken, ...payload });
51
+ // provider returns invalid-token → ignored
52
+
53
+ // ✅ RIGHT: delete the token the moment the provider rejects it
54
+ try {
55
+ await pushProvider.send({ token: user.pushToken, ...payload });
56
+ } catch (err) {
57
+ if (err.code === 'invalid-registration-token' || err.code === 'unregistered') {
58
+ await db.users.update({ id: user.id, pushToken: null });
59
+ } else {
60
+ throw err; // real failures go through the normal retry path
61
+ }
62
+ }
63
+ ```
64
+
65
+ ## Template rendering discipline
66
+
67
+ ```javascript
68
+ // Validate variables BEFORE rendering — never send broken content
69
+ function renderTemplate(template, vars) {
70
+ const missing = template.requiredVars.filter((v) => vars[v] === undefined);
71
+ if (missing.length > 0) {
72
+ throw new TemplateError(`Missing template variables: ${missing.join(', ')}`);
73
+ }
74
+ return template.render(vars);
75
+ }
76
+ ```
77
+
78
+ Resolution order: DB-stored template (editable without deploy) → file template → hardcoded default. Locale-specific template first, falling back to the default locale.
@@ -0,0 +1,79 @@
1
+ # Reference: Nitro server routes and config (read on demand)
2
+
3
+ Exemplar for `stack/nuxt3-tailwind` — validated server handlers, runtime config split, route rules.
4
+
5
+ ## Server routes (`server/api/<route>.<method>.ts`)
6
+
7
+ File naming defines the HTTP method: `index.get.ts`, `index.post.ts`, `[id].delete.ts`.
8
+
9
+ ```typescript
10
+ // server/api/users/index.get.ts
11
+ export default defineEventHandler(async (event) => {
12
+ // Auth injected by server/middleware/auth.ts — never re-checked per handler
13
+ const user = event.context.user;
14
+ if (!user) throw createError({ statusCode: 401, message: 'Not authenticated' });
15
+
16
+ const query = getQuery(event);
17
+ const page = Number(query.page) || 1;
18
+ const limit = Number(query.limit) || 20;
19
+
20
+ const users = await event.context.db.user.findMany({
21
+ skip: (page - 1) * limit,
22
+ take: limit,
23
+ select: { id: true, name: true, email: true, createdAt: true }, // never sensitive fields
24
+ });
25
+
26
+ return { users, page, limit };
27
+ });
28
+ ```
29
+
30
+ ```typescript
31
+ // server/api/users/index.post.ts
32
+ import { z } from 'zod';
33
+
34
+ const CreateUserSchema = z.object({
35
+ name: z.string().min(1).max(100),
36
+ email: z.string().email(),
37
+ password: z.string().min(8),
38
+ });
39
+
40
+ export default defineEventHandler(async (event) => {
41
+ const body = await readBody(event);
42
+ const result = CreateUserSchema.safeParse(body);
43
+
44
+ if (!result.success) {
45
+ throw createError({
46
+ statusCode: 422,
47
+ data: result.error.flatten().fieldErrors,
48
+ message: 'Invalid input',
49
+ });
50
+ }
51
+
52
+ const user = await event.context.db.user.create({ data: result.data });
53
+ return { user, statusCode: 201 };
54
+ });
55
+ ```
56
+
57
+ ## Runtime config and route rules
58
+
59
+ ```typescript
60
+ // nuxt.config.ts (relevant excerpts)
61
+ export default defineNuxtConfig({
62
+ typescript: { strict: true, typeCheck: true },
63
+
64
+ runtimeConfig: {
65
+ // Server-only — never exposed to the client
66
+ jwtSecret: process.env.JWT_SECRET,
67
+ databaseUrl: process.env.DATABASE_URL,
68
+ // Client-safe — "public" prefix
69
+ public: {
70
+ apiBase: process.env.API_BASE || '/api',
71
+ },
72
+ },
73
+
74
+ routeRules: {
75
+ '/dashboard/**': { ssr: false }, // SPA zone — dashboard needs no SSR
76
+ '/': { prerender: true }, // prerendered landing page
77
+ },
78
+ });
79
+ ```