@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.
- package/LICENSE +21 -0
- package/LICENSING.md +49 -0
- package/README.md +507 -0
- package/assets/settings-template.json +99 -0
- package/bin/invi.js +6 -0
- package/content-dist/LICENSE +95 -0
- package/content-dist/PIPELINE.md +823 -0
- package/content-dist/README.md +128 -0
- package/content-dist/agents/README.md +135 -0
- package/content-dist/agents/mapping.json +476 -0
- package/content-dist/agents/stacks/backend-django.md +66 -0
- package/content-dist/agents/stacks/backend-dotnet.md +72 -0
- package/content-dist/agents/stacks/backend-fastapi.md +66 -0
- package/content-dist/agents/stacks/backend-laravel.md +66 -0
- package/content-dist/agents/stacks/backend-node.md +66 -0
- package/content-dist/agents/stacks/backend-spring.md +66 -0
- package/content-dist/agents/stacks/desktop-delphi.md +73 -0
- package/content-dist/agents/stacks/frontend-angular.md +65 -0
- package/content-dist/agents/stacks/frontend-react.md +67 -0
- package/content-dist/agents/stacks/frontend-svelte.md +67 -0
- package/content-dist/agents/stacks/frontend-vue.md +66 -0
- package/content-dist/agents/stacks/mobile-flutter.md +68 -0
- package/content-dist/agents/stacks/wordpress.md +66 -0
- package/content-dist/agents/universal/invi-qa.md +57 -0
- package/content-dist/agents/universal/invi-reviewer.md +61 -0
- package/content-dist/agents/universal/invi-security.md +55 -0
- package/content-dist/agents/universal/invi-tester.md +55 -0
- package/content-dist/agents/universal/invi-ui.md +85 -0
- package/content-dist/fragments/base.md +37 -0
- package/content-dist/fragments/domain/api-publica-rate-limiting.md +83 -0
- package/content-dist/fragments/domain/autenticacao-enterprise.md +86 -0
- package/content-dist/fragments/domain/busca-elasticsearch.md +86 -0
- package/content-dist/fragments/domain/dashboard-admin-rbac.md +80 -0
- package/content-dist/fragments/domain/design-system.md +71 -0
- package/content-dist/fragments/domain/ecommerce-completo.md +86 -0
- package/content-dist/fragments/domain/filas-jobs.md +80 -0
- package/content-dist/fragments/domain/integracao-crm-erp.md +82 -0
- package/content-dist/fragments/domain/lgpd.md +84 -0
- package/content-dist/fragments/domain/multi-tenancy.md +79 -0
- package/content-dist/fragments/domain/notificacoes-multicanal.md +81 -0
- package/content-dist/fragments/domain/pagamentos-brasil.md +85 -0
- package/content-dist/fragments/domain/plataforma-conteudo.md +77 -0
- package/content-dist/fragments/domain/realtime-websockets.md +92 -0
- package/content-dist/fragments/domain/relatorios-analytics.md +80 -0
- package/content-dist/fragments/domain/saas-stripe-billing.md +79 -0
- package/content-dist/fragments/domain/sistema-pagamentos.md +81 -0
- package/content-dist/fragments/domain/upload-midia.md +81 -0
- package/content-dist/fragments/domain/whatsapp-business.md +82 -0
- package/content-dist/fragments/index.json +1670 -0
- package/content-dist/fragments/references/angular-ngrx/app-config-and-testing.md +81 -0
- package/content-dist/fragments/references/angular-ngrx/store-pattern.md +155 -0
- package/content-dist/fragments/references/ansible-server-setup/layout-and-config.md +143 -0
- package/content-dist/fragments/references/ansible-server-setup/roles.md +238 -0
- package/content-dist/fragments/references/api-publica-rate-limiting/patterns.md +68 -0
- package/content-dist/fragments/references/astro-static/content-and-islands.md +117 -0
- package/content-dist/fragments/references/autenticacao-enterprise/pitfalls.md +70 -0
- package/content-dist/fragments/references/busca-elasticsearch/patterns.md +100 -0
- package/content-dist/fragments/references/chrome-extension-mv3/messaging-and-storage.md +109 -0
- package/content-dist/fragments/references/cli-typescript-commander/commands-and-config.md +136 -0
- package/content-dist/fragments/references/cloud-run-gcp/build-and-deploy.md +127 -0
- package/content-dist/fragments/references/cloud-run-gcp/iam-secrets-networking.md +65 -0
- package/content-dist/fragments/references/computer-vision-yolo/serving-and-export.md +182 -0
- package/content-dist/fragments/references/computer-vision-yolo/training-and-validation.md +131 -0
- package/content-dist/fragments/references/convex-react/functions.md +117 -0
- package/content-dist/fragments/references/convex-react/react-and-storage.md +109 -0
- package/content-dist/fragments/references/dashboard-admin-rbac/patterns.md +73 -0
- package/content-dist/fragments/references/data-pipeline-airflow/dag-patterns.md +149 -0
- package/content-dist/fragments/references/data-pipeline-airflow/operations.md +74 -0
- package/content-dist/fragments/references/delphi-object-pascal/legacy-extraction.md +175 -0
- package/content-dist/fragments/references/django-drf-celery/celery-tasks.md +47 -0
- package/content-dist/fragments/references/django-drf-celery/viewsets-and-serializers.md +92 -0
- package/content-dist/fragments/references/docker-compose-dev/compose-files.md +146 -0
- package/content-dist/fragments/references/docker-compose-dev/dockerfile-and-proxy.md +108 -0
- package/content-dist/fragments/references/dotnet-aspnet/data-and-di.md +90 -0
- package/content-dist/fragments/references/dotnet-aspnet/web-layer.md +88 -0
- package/content-dist/fragments/references/ecommerce-completo/patterns.md +76 -0
- package/content-dist/fragments/references/electron-app/ipc-bridge.md +123 -0
- package/content-dist/fragments/references/electron-app/security-and-packaging.md +134 -0
- package/content-dist/fragments/references/elixir-phoenix/context-and-web.md +112 -0
- package/content-dist/fragments/references/elixir-phoenix/processes.md +65 -0
- package/content-dist/fragments/references/filas-jobs/patterns.md +116 -0
- package/content-dist/fragments/references/fine-tuning-huggingface/data-and-export.md +114 -0
- package/content-dist/fragments/references/fine-tuning-huggingface/training-and-lora.md +123 -0
- package/content-dist/fragments/references/flutter/platform-channels-and-goldens.md +68 -0
- package/content-dist/fragments/references/flutter/state-and-widgets.md +95 -0
- package/content-dist/fragments/references/github-actions-cicd/workflows.md +235 -0
- package/content-dist/fragments/references/go-chi-gorm/http-layer.md +87 -0
- package/content-dist/fragments/references/go-chi-gorm/service-layer.md +58 -0
- package/content-dist/fragments/references/graphql-apollo/resolvers-and-loaders.md +128 -0
- package/content-dist/fragments/references/hono-bun/patterns.md +144 -0
- package/content-dist/fragments/references/integracao-crm-erp/patterns.md +100 -0
- package/content-dist/fragments/references/kubernetes-helm/chart-templates.md +162 -0
- package/content-dist/fragments/references/kubernetes-helm/secrets-storage-deploy.md +78 -0
- package/content-dist/fragments/references/langchain-python-agent/agent-and-cost.md +120 -0
- package/content-dist/fragments/references/langchain-python-agent/memory-and-resilience.md +76 -0
- package/content-dist/fragments/references/laravel/eloquent-and-queues.md +126 -0
- package/content-dist/fragments/references/laravel/http-layer.md +110 -0
- package/content-dist/fragments/references/lgpd/patterns.md +110 -0
- package/content-dist/fragments/references/llm-ops-production/routing-and-budget.md +118 -0
- package/content-dist/fragments/references/llm-ops-production/tracing-eval-ab.md +102 -0
- package/content-dist/fragments/references/microservices-docker/compose-and-gateway.md +93 -0
- package/content-dist/fragments/references/microservices-docker/events-and-correlation.md +88 -0
- package/content-dist/fragments/references/ml-fastapi-serving/metrics-drift-docker.md +97 -0
- package/content-dist/fragments/references/ml-fastapi-serving/serving-core.md +155 -0
- package/content-dist/fragments/references/ml-training-pipeline/dvc-pipeline.md +102 -0
- package/content-dist/fragments/references/ml-training-pipeline/mlflow-registry-ci.md +139 -0
- package/content-dist/fragments/references/monitoring-observability/alerts-and-config.md +169 -0
- package/content-dist/fragments/references/monitoring-observability/instrumentation-node.md +139 -0
- package/content-dist/fragments/references/multi-tenancy/patterns.md +85 -0
- package/content-dist/fragments/references/nestjs-typescript/guards-and-decorators.md +103 -0
- package/content-dist/fragments/references/nestjs-typescript/modules-dtos-setup.md +106 -0
- package/content-dist/fragments/references/nextjs-app-router/patterns.md +177 -0
- package/content-dist/fragments/references/nextjs-prisma-postgres/billing.md +167 -0
- package/content-dist/fragments/references/nextjs-trpc-drizzle/data-and-auth.md +121 -0
- package/content-dist/fragments/references/nextjs-trpc-drizzle/trpc-setup.md +62 -0
- package/content-dist/fragments/references/nodejs-express-typescript/config-and-tokens.md +48 -0
- package/content-dist/fragments/references/nodejs-express-typescript/middleware.md +108 -0
- package/content-dist/fragments/references/notificacoes-multicanal/patterns.md +78 -0
- package/content-dist/fragments/references/nuxt3-tailwind/server-routes.md +79 -0
- package/content-dist/fragments/references/nuxt3-tailwind/state-and-fetching.md +129 -0
- package/content-dist/fragments/references/openai-api-integration/calls.md +210 -0
- package/content-dist/fragments/references/openai-api-integration/client-and-cost.md +71 -0
- package/content-dist/fragments/references/pagamentos-brasil/gateways-reconciliation.md +92 -0
- package/content-dist/fragments/references/pagamentos-brasil/pix-boleto.md +115 -0
- package/content-dist/fragments/references/plataforma-conteudo/patterns.md +74 -0
- package/content-dist/fragments/references/python-fastapi/dependency-injection.md +99 -0
- package/content-dist/fragments/references/python-fastapi/settings-and-tasks.md +47 -0
- package/content-dist/fragments/references/rag-pipeline/ingestion.md +92 -0
- package/content-dist/fragments/references/rag-pipeline/retrieval-and-eval.md +148 -0
- package/content-dist/fragments/references/react-express-monolith/auth-and-client.md +110 -0
- package/content-dist/fragments/references/react-express-monolith/monorepo.md +71 -0
- package/content-dist/fragments/references/react-native-expo/native-patterns.md +103 -0
- package/content-dist/fragments/references/react-native-expo/navigation-and-auth.md +55 -0
- package/content-dist/fragments/references/react-ts-zustand-query/store-and-query.md +152 -0
- package/content-dist/fragments/references/react-typescript/feature-module.md +64 -0
- package/content-dist/fragments/references/react-typescript/forms-and-state.md +69 -0
- package/content-dist/fragments/references/react-typescript/recipes.md +37 -0
- package/content-dist/fragments/references/react-typescript/testing.md +40 -0
- package/content-dist/fragments/references/realtime-websockets/patterns.md +92 -0
- package/content-dist/fragments/references/relatorios-analytics/patterns.md +81 -0
- package/content-dist/fragments/references/remix-express-full/auth-and-uploads.md +88 -0
- package/content-dist/fragments/references/remix-express-full/express-server.md +54 -0
- package/content-dist/fragments/references/remix-typescript/auth-and-db.md +68 -0
- package/content-dist/fragments/references/remix-typescript/loaders-and-actions.md +98 -0
- package/content-dist/fragments/references/rust-axum/error-and-state.md +99 -0
- package/content-dist/fragments/references/rust-axum/handlers.md +87 -0
- package/content-dist/fragments/references/saas-stripe-billing/patterns.md +86 -0
- package/content-dist/fragments/references/serverless-lambda/handler-patterns.md +107 -0
- package/content-dist/fragments/references/sistema-pagamentos/pitfalls.md +54 -0
- package/content-dist/fragments/references/spring-boot/service-and-data.md +96 -0
- package/content-dist/fragments/references/spring-boot/web-layer.md +100 -0
- package/content-dist/fragments/references/supabase-nextjs/clients-and-middleware.md +102 -0
- package/content-dist/fragments/references/supabase-nextjs/rls-and-storage.md +86 -0
- package/content-dist/fragments/references/svelte-sveltekit/hooks-and-state.md +67 -0
- package/content-dist/fragments/references/svelte-sveltekit/load-and-actions.md +80 -0
- package/content-dist/fragments/references/t3-stack/routers-and-callers.md +75 -0
- package/content-dist/fragments/references/t3-stack/trpc-setup.md +60 -0
- package/content-dist/fragments/references/terraform-aws/modules-and-ci.md +114 -0
- package/content-dist/fragments/references/terraform-aws/state-and-workspaces.md +66 -0
- package/content-dist/fragments/references/turborepo-monorepo/pipeline-and-packages.md +84 -0
- package/content-dist/fragments/references/upload-midia/patterns.md +80 -0
- package/content-dist/fragments/references/vector-search-pinecone/client-and-upsert.md +98 -0
- package/content-dist/fragments/references/vector-search-pinecone/query-and-hybrid.md +81 -0
- package/content-dist/fragments/references/vps-deploy-producao/compose-prod.md +97 -0
- package/content-dist/fragments/references/vps-deploy-producao/proxy-and-operations.md +118 -0
- package/content-dist/fragments/references/vscode-extension/activation-and-tree.md +98 -0
- package/content-dist/fragments/references/vscode-extension/webview-csp.md +57 -0
- package/content-dist/fragments/references/vue3-pinia-vite/components-and-stores.md +73 -0
- package/content-dist/fragments/references/vue3-pinia-vite/queries-forms-testing.md +100 -0
- package/content-dist/fragments/references/whatsapp-business/patterns.md +107 -0
- package/content-dist/fragments/references/wordpress/hooks-and-security.md +92 -0
- package/content-dist/fragments/references/wordpress/wp-cli-gates.md +64 -0
- package/content-dist/fragments/stack/angular-ngrx.md +75 -0
- package/content-dist/fragments/stack/ansible-server-setup.md +69 -0
- package/content-dist/fragments/stack/astro-static.md +72 -0
- package/content-dist/fragments/stack/chrome-extension-mv3.md +66 -0
- package/content-dist/fragments/stack/cli-typescript-commander.md +66 -0
- package/content-dist/fragments/stack/cloud-run-gcp.md +63 -0
- package/content-dist/fragments/stack/computer-vision-yolo.md +62 -0
- package/content-dist/fragments/stack/convex-react.md +65 -0
- package/content-dist/fragments/stack/data-pipeline-airflow.md +64 -0
- package/content-dist/fragments/stack/delphi-object-pascal.md +63 -0
- package/content-dist/fragments/stack/django-drf-celery.md +63 -0
- package/content-dist/fragments/stack/docker-compose-dev.md +69 -0
- package/content-dist/fragments/stack/dotnet-aspnet.md +62 -0
- package/content-dist/fragments/stack/electron-app.md +70 -0
- package/content-dist/fragments/stack/elixir-phoenix.md +65 -0
- package/content-dist/fragments/stack/fine-tuning-huggingface.md +69 -0
- package/content-dist/fragments/stack/flutter.md +61 -0
- package/content-dist/fragments/stack/github-actions-cicd.md +73 -0
- package/content-dist/fragments/stack/go-chi-gorm.md +73 -0
- package/content-dist/fragments/stack/graphql-apollo.md +70 -0
- package/content-dist/fragments/stack/hono-bun.md +62 -0
- package/content-dist/fragments/stack/kubernetes-helm.md +67 -0
- package/content-dist/fragments/stack/langchain-python-agent.md +64 -0
- package/content-dist/fragments/stack/laravel.md +64 -0
- package/content-dist/fragments/stack/llm-ops-production.md +63 -0
- package/content-dist/fragments/stack/microservices-docker.md +70 -0
- package/content-dist/fragments/stack/ml-fastapi-serving.md +64 -0
- package/content-dist/fragments/stack/ml-training-pipeline.md +67 -0
- package/content-dist/fragments/stack/monitoring-observability.md +68 -0
- package/content-dist/fragments/stack/nestjs-typescript.md +68 -0
- package/content-dist/fragments/stack/nextjs-app-router.md +65 -0
- package/content-dist/fragments/stack/nextjs-prisma-postgres.md +61 -0
- package/content-dist/fragments/stack/nextjs-trpc-drizzle.md +63 -0
- package/content-dist/fragments/stack/nodejs-express-typescript.md +60 -0
- package/content-dist/fragments/stack/nuxt3-tailwind.md +62 -0
- package/content-dist/fragments/stack/openai-api-integration.md +58 -0
- package/content-dist/fragments/stack/python-fastapi.md +64 -0
- package/content-dist/fragments/stack/rag-pipeline.md +62 -0
- package/content-dist/fragments/stack/react-express-monolith.md +61 -0
- package/content-dist/fragments/stack/react-native-expo.md +68 -0
- package/content-dist/fragments/stack/react-ts-zustand-query.md +64 -0
- package/content-dist/fragments/stack/react-typescript.md +73 -0
- package/content-dist/fragments/stack/remix-express-full.md +63 -0
- package/content-dist/fragments/stack/remix-typescript.md +66 -0
- package/content-dist/fragments/stack/rust-axum.md +63 -0
- package/content-dist/fragments/stack/serverless-lambda.md +65 -0
- package/content-dist/fragments/stack/spring-boot.md +63 -0
- package/content-dist/fragments/stack/supabase-nextjs.md +64 -0
- package/content-dist/fragments/stack/svelte-sveltekit.md +67 -0
- package/content-dist/fragments/stack/t3-stack.md +63 -0
- package/content-dist/fragments/stack/terraform-aws.md +65 -0
- package/content-dist/fragments/stack/turborepo-monorepo.md +61 -0
- package/content-dist/fragments/stack/vector-search-pinecone.md +63 -0
- package/content-dist/fragments/stack/vps-deploy-producao.md +64 -0
- package/content-dist/fragments/stack/vscode-extension.md +64 -0
- package/content-dist/fragments/stack/vue3-pinia-vite.md +65 -0
- package/content-dist/fragments/stack/wordpress.md +63 -0
- package/content-dist/skills/invi-commit/SKILL.md +85 -0
- package/content-dist/skills/invi-journal/SKILL.md +67 -0
- package/content-dist/skills/invi-map/SKILL.md +118 -0
- package/content-dist/skills/invi-mode/SKILL.md +176 -0
- package/content-dist/skills/invi-pr/SKILL.md +142 -0
- package/content-dist/skills/invi-qa/SKILL.md +75 -0
- package/content-dist/skills/invi-refactor-legacy/SKILL.md +90 -0
- package/content-dist/skills/invi-review/SKILL.md +83 -0
- package/content-dist/skills/invi-security/SKILL.md +89 -0
- package/content-dist/skills/invi-status/SKILL.md +72 -0
- package/content-dist/skills/invi-task/SKILL.md +143 -0
- package/content-dist/skills/invi-test/SKILL.md +97 -0
- package/content-dist/skills/po-handoff/SKILL.md +130 -0
- package/content-dist/skills/po-intake/SKILL.md +115 -0
- package/content-dist/skills/po-lint/SKILL.md +82 -0
- package/content-dist/skills/po-spec/SKILL.md +138 -0
- package/content-dist/skills/po-status/SKILL.md +130 -0
- package/content-dist/skills/po-verify/SKILL.md +124 -0
- package/content-dist/templates/requirements/REQ-TEMPLATE.md +110 -0
- package/content-dist/templates/requirements/constitution-TEMPLATE.md +77 -0
- package/dist/baseline.d.ts +21 -0
- package/dist/baseline.d.ts.map +1 -0
- package/dist/baseline.js +43 -0
- package/dist/baseline.js.map +1 -0
- package/dist/cli.d.ts +15 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +345 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/doctor.d.ts +31 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +173 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/export.d.ts +49 -0
- package/dist/commands/export.d.ts.map +1 -0
- package/dist/commands/export.js +95 -0
- package/dist/commands/export.js.map +1 -0
- package/dist/commands/gate.d.ts +42 -0
- package/dist/commands/gate.d.ts.map +1 -0
- package/dist/commands/gate.js +97 -0
- package/dist/commands/gate.js.map +1 -0
- package/dist/commands/init.d.ts +88 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +540 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/journalCmd.d.ts +47 -0
- package/dist/commands/journalCmd.d.ts.map +1 -0
- package/dist/commands/journalCmd.js +89 -0
- package/dist/commands/journalCmd.js.map +1 -0
- package/dist/commands/keys.d.ts +68 -0
- package/dist/commands/keys.d.ts.map +1 -0
- package/dist/commands/keys.js +240 -0
- package/dist/commands/keys.js.map +1 -0
- package/dist/commands/map.d.ts +123 -0
- package/dist/commands/map.d.ts.map +1 -0
- package/dist/commands/map.js +383 -0
- package/dist/commands/map.js.map +1 -0
- package/dist/commands/plan.d.ts +28 -0
- package/dist/commands/plan.d.ts.map +1 -0
- package/dist/commands/plan.js +64 -0
- package/dist/commands/plan.js.map +1 -0
- package/dist/commands/req.d.ts +92 -0
- package/dist/commands/req.d.ts.map +1 -0
- package/dist/commands/req.js +270 -0
- package/dist/commands/req.js.map +1 -0
- package/dist/commands/review.d.ts +40 -0
- package/dist/commands/review.d.ts.map +1 -0
- package/dist/commands/review.js +101 -0
- package/dist/commands/review.js.map +1 -0
- package/dist/commands/run.d.ts +33 -0
- package/dist/commands/run.d.ts.map +1 -0
- package/dist/commands/run.js +151 -0
- package/dist/commands/run.js.map +1 -0
- package/dist/commands/ship.d.ts +45 -0
- package/dist/commands/ship.d.ts.map +1 -0
- package/dist/commands/ship.js +252 -0
- package/dist/commands/ship.js.map +1 -0
- package/dist/commands/status.d.ts +36 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +152 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/sync.d.ts +91 -0
- package/dist/commands/sync.d.ts.map +1 -0
- package/dist/commands/sync.js +331 -0
- package/dist/commands/sync.js.map +1 -0
- package/dist/commands/syncCommits.d.ts +56 -0
- package/dist/commands/syncCommits.d.ts.map +1 -0
- package/dist/commands/syncCommits.js +97 -0
- package/dist/commands/syncCommits.js.map +1 -0
- package/dist/commands/task.d.ts +108 -0
- package/dist/commands/task.d.ts.map +1 -0
- package/dist/commands/task.js +217 -0
- package/dist/commands/task.js.map +1 -0
- package/dist/commands/update.d.ts +92 -0
- package/dist/commands/update.d.ts.map +1 -0
- package/dist/commands/update.js +541 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/commands/verifyTask.d.ts +50 -0
- package/dist/commands/verifyTask.d.ts.map +1 -0
- package/dist/commands/verifyTask.js +172 -0
- package/dist/commands/verifyTask.js.map +1 -0
- package/dist/content.d.ts +128 -0
- package/dist/content.d.ts.map +1 -0
- package/dist/content.js +177 -0
- package/dist/content.js.map +1 -0
- package/dist/detect.d.ts +122 -0
- package/dist/detect.d.ts.map +1 -0
- package/dist/detect.js +594 -0
- package/dist/detect.js.map +1 -0
- package/dist/events.d.ts +36 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +76 -0
- package/dist/events.js.map +1 -0
- package/dist/frontmatter.d.ts +15 -0
- package/dist/frontmatter.d.ts.map +1 -0
- package/dist/frontmatter.js +74 -0
- package/dist/frontmatter.js.map +1 -0
- package/dist/i18n/en.d.ts +421 -0
- package/dist/i18n/en.d.ts.map +1 -0
- package/dist/i18n/en.js +443 -0
- package/dist/i18n/en.js.map +1 -0
- package/dist/i18n/index.d.ts +40 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/index.js +66 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/i18n/pt-BR.d.ts +11 -0
- package/dist/i18n/pt-BR.d.ts.map +1 -0
- package/dist/i18n/pt-BR.js +435 -0
- package/dist/i18n/pt-BR.js.map +1 -0
- package/dist/identity.d.ts +78 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +152 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +79 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +48 -0
- package/dist/index.js.map +1 -0
- package/dist/insights.d.ts +86 -0
- package/dist/insights.d.ts.map +1 -0
- package/dist/insights.js +199 -0
- package/dist/insights.js.map +1 -0
- package/dist/interview.d.ts +81 -0
- package/dist/interview.d.ts.map +1 -0
- package/dist/interview.js +283 -0
- package/dist/interview.js.map +1 -0
- package/dist/inventory.d.ts +79 -0
- package/dist/inventory.d.ts.map +1 -0
- package/dist/inventory.js +86 -0
- package/dist/inventory.js.map +1 -0
- package/dist/journal.d.ts +22 -0
- package/dist/journal.d.ts.map +1 -0
- package/dist/journal.js +88 -0
- package/dist/journal.js.map +1 -0
- package/dist/migrations/legacyNames.d.ts +45 -0
- package/dist/migrations/legacyNames.d.ts.map +1 -0
- package/dist/migrations/legacyNames.js +118 -0
- package/dist/migrations/legacyNames.js.map +1 -0
- package/dist/plan.d.ts +42 -0
- package/dist/plan.d.ts.map +1 -0
- package/dist/plan.js +126 -0
- package/dist/plan.js.map +1 -0
- package/dist/render/agents.d.ts +327 -0
- package/dist/render/agents.d.ts.map +1 -0
- package/dist/render/agents.js +356 -0
- package/dist/render/agents.js.map +1 -0
- package/dist/render/claudeMd.d.ts +29 -0
- package/dist/render/claudeMd.d.ts.map +1 -0
- package/dist/render/claudeMd.js +110 -0
- package/dist/render/claudeMd.js.map +1 -0
- package/dist/render/githooks.d.ts +41 -0
- package/dist/render/githooks.d.ts.map +1 -0
- package/dist/render/githooks.js +168 -0
- package/dist/render/githooks.js.map +1 -0
- package/dist/render/markers.d.ts +13 -0
- package/dist/render/markers.d.ts.map +1 -0
- package/dist/render/markers.js +35 -0
- package/dist/render/markers.js.map +1 -0
- package/dist/render/requirements.d.ts +56 -0
- package/dist/render/requirements.d.ts.map +1 -0
- package/dist/render/requirements.js +86 -0
- package/dist/render/requirements.js.map +1 -0
- package/dist/render/settings.d.ts +43 -0
- package/dist/render/settings.d.ts.map +1 -0
- package/dist/render/settings.js +94 -0
- package/dist/render/settings.js.map +1 -0
- package/dist/render/transparency.d.ts +7 -0
- package/dist/render/transparency.d.ts.map +1 -0
- package/dist/render/transparency.js +164 -0
- package/dist/render/transparency.js.map +1 -0
- package/dist/requirements.d.ts +84 -0
- package/dist/requirements.d.ts.map +1 -0
- package/dist/requirements.js +229 -0
- package/dist/requirements.js.map +1 -0
- package/dist/sizing.d.ts +63 -0
- package/dist/sizing.d.ts.map +1 -0
- package/dist/sizing.js +104 -0
- package/dist/sizing.js.map +1 -0
- package/dist/tasks.d.ts +199 -0
- package/dist/tasks.d.ts.map +1 -0
- package/dist/tasks.js +320 -0
- package/dist/tasks.js.map +1 -0
- package/dist/util/diff3.d.ts +26 -0
- package/dist/util/diff3.d.ts.map +1 -0
- package/dist/util/diff3.js +112 -0
- package/dist/util/diff3.js.map +1 -0
- package/dist/util/fsx.d.ts +33 -0
- package/dist/util/fsx.d.ts.map +1 -0
- package/dist/util/fsx.js +153 -0
- package/dist/util/fsx.js.map +1 -0
- package/dist/util/git.d.ts +58 -0
- package/dist/util/git.d.ts.map +1 -0
- package/dist/util/git.js +171 -0
- package/dist/util/git.js.map +1 -0
- package/dist/util/merge.d.ts +27 -0
- package/dist/util/merge.d.ts.map +1 -0
- package/dist/util/merge.js +78 -0
- package/dist/util/merge.js.map +1 -0
- package/dist/util/out.d.ts +18 -0
- package/dist/util/out.d.ts.map +1 -0
- package/dist/util/out.js +23 -0
- package/dist/util/out.js.map +1 -0
- package/dist/util/proc.d.ts +12 -0
- package/dist/util/proc.d.ts.map +1 -0
- package/dist/util/proc.js +45 -0
- package/dist/util/proc.js.map +1 -0
- package/dist/util/registry.d.ts +58 -0
- package/dist/util/registry.d.ts.map +1 -0
- package/dist/util/registry.js +240 -0
- package/dist/util/registry.js.map +1 -0
- package/dist/verify.d.ts +52 -0
- package/dist/verify.d.ts.map +1 -0
- package/dist/verify.js +205 -0
- package/dist/verify.js.map +1 -0
- package/dist/version.d.ts +5 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +18 -0
- package/dist/version.js.map +1 -0
- package/package.json +63 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# Reference: FastAPI dependency injection (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/python-fastapi` — per-request session, current-user and role dependencies, OAuth2 login flow. Read when wiring auth or a new module's dependencies.
|
|
4
|
+
|
|
5
|
+
## Async session dependency
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
# app/core/database.py
|
|
9
|
+
from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker, create_async_engine
|
|
10
|
+
from app.core.config import settings
|
|
11
|
+
|
|
12
|
+
engine = create_async_engine(
|
|
13
|
+
settings.DATABASE_URL,
|
|
14
|
+
pool_size=10,
|
|
15
|
+
max_overflow=20,
|
|
16
|
+
echo=settings.DEBUG,
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
AsyncSessionLocal = async_sessionmaker(
|
|
20
|
+
engine,
|
|
21
|
+
expire_on_commit=False,
|
|
22
|
+
class_=AsyncSession,
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
async def get_db() -> AsyncGenerator[AsyncSession, None]:
|
|
26
|
+
async with AsyncSessionLocal() as session:
|
|
27
|
+
try:
|
|
28
|
+
yield session
|
|
29
|
+
await session.commit()
|
|
30
|
+
except Exception:
|
|
31
|
+
await session.rollback()
|
|
32
|
+
raise
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Current user + role dependencies
|
|
36
|
+
|
|
37
|
+
```python
|
|
38
|
+
# app/modules/users/dependencies.py
|
|
39
|
+
from fastapi import Depends, HTTPException, status
|
|
40
|
+
from fastapi.security import OAuth2PasswordBearer
|
|
41
|
+
from sqlalchemy.ext.asyncio import AsyncSession
|
|
42
|
+
from app.core.database import get_db
|
|
43
|
+
from app.core.security import decode_access_token
|
|
44
|
+
from app.modules.users.repository import UserRepository
|
|
45
|
+
from app.modules.users.models import User
|
|
46
|
+
|
|
47
|
+
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="/api/v1/auth/login")
|
|
48
|
+
|
|
49
|
+
async def get_current_user(
|
|
50
|
+
token: str = Depends(oauth2_scheme),
|
|
51
|
+
db: AsyncSession = Depends(get_db),
|
|
52
|
+
) -> User:
|
|
53
|
+
payload = decode_access_token(token) # raises 401 if invalid
|
|
54
|
+
user = await UserRepository(db).get_by_id(payload["sub"])
|
|
55
|
+
if not user:
|
|
56
|
+
raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="User not found")
|
|
57
|
+
return user
|
|
58
|
+
|
|
59
|
+
async def require_admin(
|
|
60
|
+
current_user: User = Depends(get_current_user),
|
|
61
|
+
) -> User:
|
|
62
|
+
if current_user.role != "admin":
|
|
63
|
+
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="Admin required")
|
|
64
|
+
return current_user
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Token helpers in `app/core/security.py` should be built on PyJWT and a maintained bcrypt/argon2 binding (not python-jose/passlib — see the fragment's FORBIDDEN list).
|
|
68
|
+
|
|
69
|
+
## OAuth2 password login endpoint
|
|
70
|
+
|
|
71
|
+
```python
|
|
72
|
+
# app/modules/auth/router.py
|
|
73
|
+
from fastapi import APIRouter, Depends, HTTPException, status
|
|
74
|
+
from fastapi.security import OAuth2PasswordRequestForm
|
|
75
|
+
from sqlalchemy.ext.asyncio import AsyncSession
|
|
76
|
+
from app.core.database import get_db
|
|
77
|
+
from app.core.security import verify_password, create_access_token, create_refresh_token
|
|
78
|
+
from app.modules.users.repository import UserRepository
|
|
79
|
+
|
|
80
|
+
router = APIRouter(prefix="/auth", tags=["auth"])
|
|
81
|
+
|
|
82
|
+
@router.post("/login")
|
|
83
|
+
async def login(
|
|
84
|
+
form_data: OAuth2PasswordRequestForm = Depends(),
|
|
85
|
+
db: AsyncSession = Depends(get_db),
|
|
86
|
+
):
|
|
87
|
+
repo = UserRepository(db)
|
|
88
|
+
user = await repo.get_by_email(form_data.username)
|
|
89
|
+
if not user or not verify_password(form_data.password, user.hashed_password):
|
|
90
|
+
raise HTTPException(
|
|
91
|
+
status_code=status.HTTP_401_UNAUTHORIZED,
|
|
92
|
+
detail="Invalid credentials",
|
|
93
|
+
)
|
|
94
|
+
return {
|
|
95
|
+
"access_token": create_access_token({"sub": str(user.id), "role": user.role}),
|
|
96
|
+
"refresh_token": create_refresh_token(str(user.id)),
|
|
97
|
+
"token_type": "bearer",
|
|
98
|
+
}
|
|
99
|
+
```
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Reference: FastAPI settings and background tasks (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/python-fastapi`. Read when configuring the app or adding fire-and-forget work.
|
|
4
|
+
|
|
5
|
+
## Settings pattern (single source of configuration)
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
# app/core/config.py
|
|
9
|
+
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
10
|
+
|
|
11
|
+
class Settings(BaseSettings):
|
|
12
|
+
model_config = SettingsConfigDict(env_file=".env", env_file_encoding="utf-8")
|
|
13
|
+
|
|
14
|
+
DATABASE_URL: str
|
|
15
|
+
SECRET_KEY: str
|
|
16
|
+
ALGORITHM: str = "HS256"
|
|
17
|
+
ACCESS_TOKEN_EXPIRE_MINUTES: int = 15
|
|
18
|
+
REFRESH_TOKEN_EXPIRE_DAYS: int = 7
|
|
19
|
+
DEBUG: bool = False
|
|
20
|
+
CORS_ORIGINS: list[str] = ["http://localhost:5173"]
|
|
21
|
+
|
|
22
|
+
settings = Settings()
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Nothing else reads `os.environ`; services receive `settings` (or values from it) via imports/DI.
|
|
26
|
+
|
|
27
|
+
## Background tasks
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
# app/tasks/email.py
|
|
31
|
+
def send_welcome_email(email: str, name: str) -> None:
|
|
32
|
+
# Runs in a thread pool — keep it synchronous, do NOT declare async here
|
|
33
|
+
...
|
|
34
|
+
|
|
35
|
+
# In the router:
|
|
36
|
+
@router.post("/register", status_code=201)
|
|
37
|
+
async def register(
|
|
38
|
+
body: UserCreateSchema,
|
|
39
|
+
db: AsyncSession = Depends(get_db),
|
|
40
|
+
background_tasks: BackgroundTasks = BackgroundTasks(),
|
|
41
|
+
):
|
|
42
|
+
user = await UserService(db).create(body)
|
|
43
|
+
background_tasks.add_task(send_welcome_email, user.email, user.name)
|
|
44
|
+
return user
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
`BackgroundTasks` is for cheap, loss-tolerable work only; anything that must survive a process restart belongs in a real queue (see `domain/filas-jobs`).
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Reference: RAG ingestion pipeline (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/rag-pipeline` — incremental ingest with hashing, batched embeddings, metadata enrichment, pgvector DDL. Embedding model id and dimensions come from config, not literals.
|
|
4
|
+
|
|
5
|
+
## Ingest pipeline (hash → chunk → enrich → batch embed)
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
# rag/ingestion/pipeline.py
|
|
9
|
+
import hashlib
|
|
10
|
+
import logging
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
from langchain_community.document_loaders import PyMuPDFLoader
|
|
13
|
+
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
|
14
|
+
from langchain_openai import OpenAIEmbeddings
|
|
15
|
+
from rag.config import settings
|
|
16
|
+
from rag.retrieval.vector_store import PGVectorStore
|
|
17
|
+
|
|
18
|
+
logger = logging.getLogger(__name__)
|
|
19
|
+
|
|
20
|
+
embeddings = OpenAIEmbeddings(
|
|
21
|
+
model=settings.EMBEDDING_MODEL,
|
|
22
|
+
dimensions=settings.EMBEDDING_DIMENSIONS,
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
splitter = RecursiveCharacterTextSplitter(
|
|
26
|
+
chunk_size=512,
|
|
27
|
+
chunk_overlap=50,
|
|
28
|
+
length_function=len,
|
|
29
|
+
separators=["\n\n", "\n", ". ", " ", ""],
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
def compute_doc_hash(content: str) -> str:
|
|
33
|
+
return hashlib.sha256(content.encode()).hexdigest()[:16]
|
|
34
|
+
|
|
35
|
+
async def ingest_pdf(file_path: Path, metadata: dict) -> int:
|
|
36
|
+
"""Ingest a PDF, skip unchanged documents. Returns chunks added."""
|
|
37
|
+
loader = PyMuPDFLoader(str(file_path))
|
|
38
|
+
pages = loader.load()
|
|
39
|
+
|
|
40
|
+
doc_hash = compute_doc_hash("".join(p.page_content for p in pages))
|
|
41
|
+
|
|
42
|
+
store = PGVectorStore()
|
|
43
|
+
if await store.document_exists(doc_hash):
|
|
44
|
+
logger.info(f"Document {file_path.name} unchanged, skipping")
|
|
45
|
+
return 0
|
|
46
|
+
|
|
47
|
+
chunks = splitter.split_documents(pages)
|
|
48
|
+
|
|
49
|
+
# Metadata is non-negotiable — every chunk gets provenance
|
|
50
|
+
for i, chunk in enumerate(chunks):
|
|
51
|
+
chunk.metadata.update({
|
|
52
|
+
**metadata,
|
|
53
|
+
"doc_hash": doc_hash,
|
|
54
|
+
"chunk_index": i,
|
|
55
|
+
"total_chunks": len(chunks),
|
|
56
|
+
"source_file": file_path.name,
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
# Batch embed + upsert
|
|
60
|
+
batch_size = 100
|
|
61
|
+
total = 0
|
|
62
|
+
for i in range(0, len(chunks), batch_size):
|
|
63
|
+
batch = chunks[i:i + batch_size]
|
|
64
|
+
await store.aadd_documents(batch)
|
|
65
|
+
total += len(batch)
|
|
66
|
+
logger.info(f"Embedded {total}/{len(chunks)} chunks")
|
|
67
|
+
|
|
68
|
+
return total
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## pgvector DDL (HNSW + metadata indexes)
|
|
72
|
+
|
|
73
|
+
```sql
|
|
74
|
+
CREATE EXTENSION IF NOT EXISTS vector;
|
|
75
|
+
|
|
76
|
+
CREATE TABLE documents (
|
|
77
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
78
|
+
content TEXT NOT NULL,
|
|
79
|
+
embedding VECTOR(1536), -- match configured embedding dimensions
|
|
80
|
+
metadata JSONB NOT NULL DEFAULT '{}',
|
|
81
|
+
doc_hash TEXT,
|
|
82
|
+
created_at TIMESTAMPTZ DEFAULT NOW()
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
-- HNSW for fast ANN search (better than IVFFlat for most workloads)
|
|
86
|
+
CREATE INDEX ON documents USING hnsw (embedding vector_cosine_ops)
|
|
87
|
+
WITH (m = 16, ef_construction = 64);
|
|
88
|
+
|
|
89
|
+
-- Metadata filtering indexes (crucial for performance)
|
|
90
|
+
CREATE INDEX ON documents USING gin (metadata);
|
|
91
|
+
CREATE INDEX ON documents (doc_hash);
|
|
92
|
+
```
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# Reference: RAG retrieval, generation and evaluation (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/rag-pipeline` — hybrid retriever with RRF fusion, reranker, grounded chain, RAGAS quality gate. Model ids come from config.
|
|
4
|
+
|
|
5
|
+
## Hybrid retriever (dense + BM25, RRF fusion)
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
# rag/retrieval/hybrid.py
|
|
9
|
+
import numpy as np
|
|
10
|
+
from typing import List
|
|
11
|
+
from langchain_postgres.vectorstores import PGVector
|
|
12
|
+
from rank_bm25 import BM25Okapi
|
|
13
|
+
from langchain_core.documents import Document
|
|
14
|
+
from langchain_core.retrievers import BaseRetriever
|
|
15
|
+
|
|
16
|
+
class HybridRetriever(BaseRetriever):
|
|
17
|
+
"""Combines dense (pgvector) and sparse (BM25) retrieval with RRF fusion."""
|
|
18
|
+
|
|
19
|
+
def __init__(self, vector_store: PGVector, all_documents: List[Document],
|
|
20
|
+
k: int = 20, final_k: int = 5, rrf_k: int = 60):
|
|
21
|
+
self.vector_store = vector_store
|
|
22
|
+
self.k = k
|
|
23
|
+
self.final_k = final_k
|
|
24
|
+
self.rrf_k = rrf_k
|
|
25
|
+
tokenized = [doc.page_content.lower().split() for doc in all_documents]
|
|
26
|
+
self.bm25 = BM25Okapi(tokenized)
|
|
27
|
+
self.corpus_docs = all_documents
|
|
28
|
+
|
|
29
|
+
def _reciprocal_rank_fusion(self, dense: List[Document], sparse: List[Document]) -> List[Document]:
|
|
30
|
+
"""RRF: score(d) = sum over rankings of 1/(k + rank(d))"""
|
|
31
|
+
scores: dict[str, float] = {}
|
|
32
|
+
doc_map: dict[str, Document] = {}
|
|
33
|
+
for results in (dense, sparse):
|
|
34
|
+
for rank, doc in enumerate(results):
|
|
35
|
+
key = doc.page_content[:100]
|
|
36
|
+
scores[key] = scores.get(key, 0) + 1 / (self.rrf_k + rank + 1)
|
|
37
|
+
doc_map[key] = doc
|
|
38
|
+
ranked = sorted(scores.items(), key=lambda x: x[1], reverse=True)
|
|
39
|
+
return [doc_map[k] for k, _ in ranked[:self.final_k]]
|
|
40
|
+
|
|
41
|
+
def _get_relevant_documents(self, query: str) -> List[Document]:
|
|
42
|
+
dense = self.vector_store.similarity_search(query, k=self.k)
|
|
43
|
+
tokenized_query = query.lower().split()
|
|
44
|
+
bm25_scores = self.bm25.get_scores(tokenized_query)
|
|
45
|
+
top_indices = np.argsort(bm25_scores)[-self.k:][::-1]
|
|
46
|
+
sparse = [self.corpus_docs[i] for i in top_indices if bm25_scores[i] > 0]
|
|
47
|
+
return self._reciprocal_rank_fusion(dense, sparse)
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Reranker (retrieve wide, rerank narrow)
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
# rag/retrieval/reranker.py
|
|
54
|
+
import os
|
|
55
|
+
import cohere
|
|
56
|
+
from typing import List
|
|
57
|
+
from langchain_core.documents import Document
|
|
58
|
+
from rag.config import settings
|
|
59
|
+
|
|
60
|
+
co = cohere.Client(os.environ["COHERE_API_KEY"])
|
|
61
|
+
|
|
62
|
+
def rerank_documents(query: str, documents: List[Document], top_n: int = 5) -> List[Document]:
|
|
63
|
+
"""Rerank retrieved docs with a rerank service — much cheaper than a larger LLM."""
|
|
64
|
+
if not documents:
|
|
65
|
+
return []
|
|
66
|
+
response = co.rerank(
|
|
67
|
+
query=query,
|
|
68
|
+
documents=[doc.page_content for doc in documents],
|
|
69
|
+
top_n=top_n,
|
|
70
|
+
model=settings.RERANK_MODEL,
|
|
71
|
+
)
|
|
72
|
+
return [documents[r.index] for r in response.results]
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Grounded RAG chain
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
# rag/generation/chain.py
|
|
79
|
+
from langchain_openai import ChatOpenAI
|
|
80
|
+
from langchain_core.prompts import ChatPromptTemplate
|
|
81
|
+
from langchain_core.output_parsers import StrOutputParser
|
|
82
|
+
from langchain_core.runnables import RunnablePassthrough
|
|
83
|
+
from rag.config import settings
|
|
84
|
+
from rag.retrieval.hybrid import HybridRetriever
|
|
85
|
+
from rag.retrieval.reranker import rerank_documents
|
|
86
|
+
|
|
87
|
+
SYSTEM_PROMPT = """You are a helpful assistant. Answer questions based ONLY on the provided context.
|
|
88
|
+
If the context doesn't contain enough information to answer, say "I don't have enough information."
|
|
89
|
+
Never make up facts or rely on training knowledge when context is available.
|
|
90
|
+
|
|
91
|
+
Context:
|
|
92
|
+
{context}
|
|
93
|
+
"""
|
|
94
|
+
|
|
95
|
+
def format_docs(docs) -> str:
|
|
96
|
+
return "\n\n---\n\n".join(
|
|
97
|
+
f"[Source: {d.metadata.get('source_file', 'unknown')}]\n{d.page_content}"
|
|
98
|
+
for d in docs
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
def build_rag_chain(retriever: HybridRetriever):
|
|
102
|
+
llm = ChatOpenAI(model=settings.GENERATION_MODEL, temperature=0)
|
|
103
|
+
prompt = ChatPromptTemplate.from_messages([
|
|
104
|
+
("system", SYSTEM_PROMPT),
|
|
105
|
+
("human", "{question}"),
|
|
106
|
+
])
|
|
107
|
+
|
|
108
|
+
def retrieve_and_rerank(question: str):
|
|
109
|
+
docs = retriever.get_relevant_documents(question)
|
|
110
|
+
reranked = rerank_documents(question, docs, top_n=5)
|
|
111
|
+
return format_docs(reranked)
|
|
112
|
+
|
|
113
|
+
return (
|
|
114
|
+
{"context": retrieve_and_rerank, "question": RunnablePassthrough()}
|
|
115
|
+
| prompt
|
|
116
|
+
| llm
|
|
117
|
+
| StrOutputParser()
|
|
118
|
+
)
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## RAGAS quality gate (blocks deployment)
|
|
122
|
+
|
|
123
|
+
```python
|
|
124
|
+
# rag/evaluation/metrics.py
|
|
125
|
+
from ragas import evaluate
|
|
126
|
+
from ragas.metrics import faithfulness, answer_relevancy, context_precision, context_recall
|
|
127
|
+
from datasets import Dataset
|
|
128
|
+
|
|
129
|
+
QUALITY_GATES = {
|
|
130
|
+
"faithfulness": 0.90, # answer grounded in context
|
|
131
|
+
"answer_relevancy": 0.85, # answer addresses the question
|
|
132
|
+
"context_precision": 0.80, # retrieved chunks are relevant
|
|
133
|
+
"context_recall": 0.75, # correct chunks are retrieved
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
def evaluate_rag_pipeline(eval_samples: list[dict]) -> dict:
|
|
137
|
+
"""eval_samples: [{"question", "answer", "contexts", "ground_truth"}]"""
|
|
138
|
+
dataset = Dataset.from_list(eval_samples)
|
|
139
|
+
results = evaluate(dataset, metrics=[
|
|
140
|
+
faithfulness, answer_relevancy, context_precision, context_recall,
|
|
141
|
+
])
|
|
142
|
+
scores = results.to_pandas().mean().to_dict()
|
|
143
|
+
|
|
144
|
+
failed = [m for m, threshold in QUALITY_GATES.items() if scores.get(m, 0) < threshold]
|
|
145
|
+
if failed:
|
|
146
|
+
raise ValueError(f"RAG quality gates failed: {failed}. Scores: {scores}")
|
|
147
|
+
return scores
|
|
148
|
+
```
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# Reference: Cookie-JWT auth and typed API client (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/react-express-monolith` — login/logout with httpOnly cookie, auth middleware, typed frontend client.
|
|
4
|
+
|
|
5
|
+
## Auth routes (cookie JWT)
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
// apps/server/src/routes/auth.ts
|
|
9
|
+
import express from 'express'
|
|
10
|
+
import bcrypt from 'bcryptjs'
|
|
11
|
+
import jwt from 'jsonwebtoken'
|
|
12
|
+
import { z } from 'zod'
|
|
13
|
+
import { db } from '../db'
|
|
14
|
+
import { users } from '../db/schema'
|
|
15
|
+
import { eq } from 'drizzle-orm'
|
|
16
|
+
|
|
17
|
+
const router = express.Router()
|
|
18
|
+
const COOKIE = 'auth_token'
|
|
19
|
+
|
|
20
|
+
const loginSchema = z.object({ email: z.string().email(), password: z.string().min(8) })
|
|
21
|
+
|
|
22
|
+
router.post('/login', async (req, res) => {
|
|
23
|
+
const parsed = loginSchema.safeParse(req.body)
|
|
24
|
+
if (!parsed.success) {
|
|
25
|
+
return res.status(400).json({ error: 'Invalid input', details: parsed.error.flatten().fieldErrors })
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const user = await db.select().from(users).where(eq(users.email, parsed.data.email)).get()
|
|
29
|
+
if (!user || !await bcrypt.compare(parsed.data.password, user.hashedPassword)) {
|
|
30
|
+
return res.status(401).json({ error: 'Invalid credentials' })
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const token = jwt.sign({ sub: user.id, role: user.role }, process.env.JWT_SECRET!, { expiresIn: '7d' })
|
|
34
|
+
res.cookie(COOKIE, token, {
|
|
35
|
+
httpOnly: true,
|
|
36
|
+
secure: process.env.NODE_ENV === 'production',
|
|
37
|
+
sameSite: 'strict',
|
|
38
|
+
maxAge: 7 * 24 * 60 * 60 * 1000,
|
|
39
|
+
})
|
|
40
|
+
const { hashedPassword: _, ...safeUser } = user
|
|
41
|
+
return res.json({ data: safeUser })
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
router.post('/logout', (_req, res) => {
|
|
45
|
+
res.clearCookie(COOKIE)
|
|
46
|
+
res.json({ data: { ok: true } })
|
|
47
|
+
})
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Auth middleware (typed request augmentation)
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
// apps/server/src/middleware/authenticate.ts
|
|
54
|
+
import jwt from 'jsonwebtoken'
|
|
55
|
+
import type { Request, Response, NextFunction } from 'express'
|
|
56
|
+
|
|
57
|
+
export function authenticate(req: Request, res: Response, next: NextFunction): void {
|
|
58
|
+
const token = req.cookies?.auth_token
|
|
59
|
+
if (!token) { res.status(401).json({ error: 'Unauthorized' }); return }
|
|
60
|
+
try {
|
|
61
|
+
const payload = jwt.verify(token, process.env.JWT_SECRET!) as { sub: string; role: string }
|
|
62
|
+
req.userId = payload.sub
|
|
63
|
+
req.userRole = payload.role
|
|
64
|
+
next()
|
|
65
|
+
} catch {
|
|
66
|
+
res.status(401).json({ error: 'Invalid token' })
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
declare global {
|
|
71
|
+
namespace Express {
|
|
72
|
+
interface Request { userId: string; userRole: string }
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Typed API client (the only fetch surface)
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
// apps/client/src/api/client.ts
|
|
81
|
+
import type { ApiResult, User, Post } from '@repo/shared'
|
|
82
|
+
|
|
83
|
+
const BASE = '/api'
|
|
84
|
+
|
|
85
|
+
async function request<T>(path: string, init?: RequestInit): Promise<T> {
|
|
86
|
+
const res = await fetch(`${BASE}${path}`, {
|
|
87
|
+
...init,
|
|
88
|
+
credentials: 'include',
|
|
89
|
+
headers: { 'Content-Type': 'application/json', ...init?.headers },
|
|
90
|
+
})
|
|
91
|
+
const json = await res.json() as ApiResult<T>
|
|
92
|
+
if ('error' in json) throw new Error(json.error)
|
|
93
|
+
return json.data
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export const apiClient = {
|
|
97
|
+
auth: {
|
|
98
|
+
login: (email: string, password: string) =>
|
|
99
|
+
request<User>('/auth/login', { method: 'POST', body: JSON.stringify({ email, password }) }),
|
|
100
|
+
logout: () => request<{ ok: boolean }>('/auth/logout', { method: 'POST' }),
|
|
101
|
+
me: () => request<User>('/auth/me'),
|
|
102
|
+
},
|
|
103
|
+
posts: {
|
|
104
|
+
list: () => request<Post[]>('/posts'),
|
|
105
|
+
create: (data: Pick<Post, 'title' | 'body'>) =>
|
|
106
|
+
request<Post>('/posts', { method: 'POST', body: JSON.stringify(data) }),
|
|
107
|
+
delete: (id: string) => request<{ ok: boolean }>(`/posts/${id}`, { method: 'DELETE' }),
|
|
108
|
+
},
|
|
109
|
+
}
|
|
110
|
+
```
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Reference: Monorepo wiring (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/react-express-monolith` — shared types package, Vite dev proxy, production SPA serving.
|
|
4
|
+
|
|
5
|
+
## Shared types package (zero runtime deps)
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
// packages/shared/src/types.ts
|
|
9
|
+
export interface User {
|
|
10
|
+
id: string
|
|
11
|
+
email: string
|
|
12
|
+
name: string
|
|
13
|
+
role: 'user' | 'admin'
|
|
14
|
+
createdAt: string
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface Post {
|
|
18
|
+
id: string
|
|
19
|
+
title: string
|
|
20
|
+
body: string
|
|
21
|
+
published: boolean
|
|
22
|
+
authorId: string
|
|
23
|
+
author: Pick<User, 'id' | 'name'>
|
|
24
|
+
createdAt: string
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface ApiResponse<T> { data: T }
|
|
28
|
+
export interface ApiError { error: string; details?: Record<string, string[]> }
|
|
29
|
+
export type ApiResult<T> = ApiResponse<T> | ApiError
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Vite dev proxy (no CORS pain in development)
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
// apps/client/vite.config.ts
|
|
36
|
+
import { defineConfig } from 'vite'
|
|
37
|
+
import react from '@vitejs/plugin-react'
|
|
38
|
+
import path from 'node:path'
|
|
39
|
+
|
|
40
|
+
export default defineConfig({
|
|
41
|
+
plugins: [react()],
|
|
42
|
+
resolve: { alias: { '~': path.resolve(__dirname, 'src') } },
|
|
43
|
+
server: {
|
|
44
|
+
proxy: {
|
|
45
|
+
'/api': {
|
|
46
|
+
target: 'http://localhost:3001',
|
|
47
|
+
changeOrigin: true,
|
|
48
|
+
cookieDomainRewrite: 'localhost',
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
})
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Production SPA serving (fallback AFTER API routes)
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
// apps/server/src/index.ts
|
|
59
|
+
import express from 'express'
|
|
60
|
+
import path from 'node:path'
|
|
61
|
+
|
|
62
|
+
const app = express()
|
|
63
|
+
|
|
64
|
+
// ... middleware, API routes first ...
|
|
65
|
+
|
|
66
|
+
if (process.env.NODE_ENV === 'production') {
|
|
67
|
+
const clientDist = path.resolve(__dirname, '../../client/dist')
|
|
68
|
+
app.use(express.static(clientDist))
|
|
69
|
+
app.get('*', (_req, res) => res.sendFile(path.join(clientDist, 'index.html')))
|
|
70
|
+
}
|
|
71
|
+
```
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# Reference: Expo native patterns — storage, lists, permissions, testing (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/react-native-expo`.
|
|
4
|
+
|
|
5
|
+
## Secure storage wrapper
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
// lib/storage.ts
|
|
9
|
+
import * as SecureStore from 'expo-secure-store';
|
|
10
|
+
|
|
11
|
+
export const secureStorage = {
|
|
12
|
+
async get(key: string): Promise<string | null> {
|
|
13
|
+
return await SecureStore.getItemAsync(key);
|
|
14
|
+
},
|
|
15
|
+
async set(key: string, value: string): Promise<void> {
|
|
16
|
+
await SecureStore.setItemAsync(key, value);
|
|
17
|
+
},
|
|
18
|
+
async delete(key: string): Promise<void> {
|
|
19
|
+
await SecureStore.deleteItemAsync(key);
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// SECURITY: NEVER use AsyncStorage for tokens, API keys, or credentials.
|
|
24
|
+
// AsyncStorage is NOT encrypted — use SecureStore for anything sensitive.
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## List performance — FlashList
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
// components/features/UserList.tsx
|
|
31
|
+
import { FlashList } from '@shopify/flash-list';
|
|
32
|
+
|
|
33
|
+
export function UserList({ users }: { users: User[] }) {
|
|
34
|
+
return (
|
|
35
|
+
<FlashList
|
|
36
|
+
data={users}
|
|
37
|
+
estimatedItemSize={72}
|
|
38
|
+
renderItem={({ item }) => <UserRow user={item} />}
|
|
39
|
+
keyExtractor={(item) => item.id}
|
|
40
|
+
ListEmptyComponent={<EmptyState message="No users found" />}
|
|
41
|
+
/>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
// FlashList for >50 items (FlatList is OK below that).
|
|
45
|
+
// ALWAYS set estimatedItemSize. NEVER use ScrollView for dynamic lists.
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Permission-gated native feature
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
// hooks/useCamera.ts
|
|
52
|
+
import * as ImagePicker from 'expo-image-picker';
|
|
53
|
+
import { Alert, Linking } from 'react-native';
|
|
54
|
+
|
|
55
|
+
export function useCamera() {
|
|
56
|
+
async function pickImage() {
|
|
57
|
+
const { status } = await ImagePicker.requestCameraPermissionsAsync();
|
|
58
|
+
|
|
59
|
+
if (status !== 'granted') {
|
|
60
|
+
Alert.alert(
|
|
61
|
+
'Permission required',
|
|
62
|
+
'We need camera access for this feature.',
|
|
63
|
+
[
|
|
64
|
+
{ text: 'Cancel', style: 'cancel' },
|
|
65
|
+
{ text: 'Settings', onPress: () => Linking.openSettings() },
|
|
66
|
+
]
|
|
67
|
+
);
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return await ImagePicker.launchCameraAsync({
|
|
72
|
+
quality: 0.8,
|
|
73
|
+
allowsEditing: true,
|
|
74
|
+
aspect: [1, 1],
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return { pickImage };
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Screen test with a mocked store
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
// __tests__/LoginScreen.test.tsx
|
|
86
|
+
import { render, fireEvent, waitFor } from '@testing-library/react-native';
|
|
87
|
+
import LoginScreen from '../app/(auth)/login';
|
|
88
|
+
|
|
89
|
+
jest.mock('@/stores/auth.store', () => ({
|
|
90
|
+
useAuthStore: () => ({
|
|
91
|
+
login: jest.fn().mockResolvedValue(undefined),
|
|
92
|
+
isAuthenticated: false,
|
|
93
|
+
}),
|
|
94
|
+
}));
|
|
95
|
+
|
|
96
|
+
test('shows validation error for empty email', async () => {
|
|
97
|
+
const { getByText } = render(<LoginScreen />);
|
|
98
|
+
fireEvent.press(getByText('Sign in'));
|
|
99
|
+
await waitFor(() => {
|
|
100
|
+
expect(getByText('Invalid email')).toBeTruthy();
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
```
|