@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,100 @@
|
|
|
1
|
+
# Reference: CRM/ERP integration patterns (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `domain/integracao-crm-erp` — async webhook acknowledgement, idempotent event processing, the adapter (anti-corruption) layer with an id-mapping table, and incremental sync. Evicted from the standing fragment; read when implementing one of these mechanisms.
|
|
4
|
+
|
|
5
|
+
## Webhook acknowledgement (wrong vs right)
|
|
6
|
+
|
|
7
|
+
```javascript
|
|
8
|
+
// ❌ WRONG: processing inline — if it exceeds the provider's timeout,
|
|
9
|
+
// the webhook is redelivered and the event processed twice
|
|
10
|
+
app.post('/webhooks/crm', async (req, res) => {
|
|
11
|
+
await syncContactToDatabase(req.body); // slow, can fail
|
|
12
|
+
res.sendStatus(200);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
// ✅ RIGHT: verify, persist raw, enqueue, ack immediately
|
|
16
|
+
app.post('/webhooks/crm', async (req, res) => {
|
|
17
|
+
await verifyHmac(req); // fast — and BEFORE any payload parsing
|
|
18
|
+
await queue.add('process-crm-event', { eventId: req.body.id, payload: req.body });
|
|
19
|
+
res.sendStatus(200);
|
|
20
|
+
});
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Idempotent event processing
|
|
24
|
+
|
|
25
|
+
```javascript
|
|
26
|
+
async function processEvent(eventId, payload) {
|
|
27
|
+
const existing = await db.integrationEvents.findOne({ externalId: eventId });
|
|
28
|
+
if (existing?.status === 'processed') return; // duplicate delivery — skip
|
|
29
|
+
|
|
30
|
+
// Apply + mark processed atomically: a crash between the two would
|
|
31
|
+
// otherwise reprocess (or silently drop) the event
|
|
32
|
+
await db.transaction(async (trx) => {
|
|
33
|
+
await applyEvent(payload, trx);
|
|
34
|
+
await trx.integrationEvents.upsert({
|
|
35
|
+
externalId: eventId,
|
|
36
|
+
status: 'processed',
|
|
37
|
+
processedAt: new Date(),
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Adapter (anti-corruption) layer + id mapping
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
// The external schema never leaks into internal models
|
|
47
|
+
interface CrmContact { first_name: string; last_name: string; email_address: string; }
|
|
48
|
+
interface InternalUser { id: string; fullName: string; email: string; }
|
|
49
|
+
|
|
50
|
+
class CrmContactAdapter {
|
|
51
|
+
toInternal(crm: CrmContact): Partial<InternalUser> {
|
|
52
|
+
return { fullName: `${crm.first_name} ${crm.last_name}`, email: crm.email_address };
|
|
53
|
+
}
|
|
54
|
+
toExternal(user: InternalUser): CrmContact {
|
|
55
|
+
const [first_name, ...rest] = user.fullName.split(' ');
|
|
56
|
+
return { first_name, last_name: rest.join(' '), email_address: user.email };
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
```javascript
|
|
62
|
+
// ❌ WRONG: external field names on the internal model
|
|
63
|
+
await db.users.create({ crm_contact_id: crm.id, first_name: crm.first_name });
|
|
64
|
+
|
|
65
|
+
// ✅ RIGHT: adapter transforms; a mapping table owns the external ids
|
|
66
|
+
const internal = adapter.toInternal(crmContact);
|
|
67
|
+
const user = await db.users.create(internal);
|
|
68
|
+
await db.externalIdMappings.create({
|
|
69
|
+
internalId: user.id,
|
|
70
|
+
source: 'crm',
|
|
71
|
+
externalId: crmContact.id,
|
|
72
|
+
});
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Incremental sync with a persisted cursor
|
|
76
|
+
|
|
77
|
+
```javascript
|
|
78
|
+
async function incrementalSync(source) {
|
|
79
|
+
const state = await db.syncStates.findOne({ source });
|
|
80
|
+
const cursor = state?.lastSyncCursor ?? new Date(0).toISOString();
|
|
81
|
+
|
|
82
|
+
const records = await crmClient.getContacts({ modifiedAfter: cursor });
|
|
83
|
+
for (const record of records) {
|
|
84
|
+
await processUpsert(record); // same idempotent path as webhook events
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Advance the cursor atomically with the sync result — a crash mid-sync
|
|
88
|
+
// must re-fetch, never skip
|
|
89
|
+
await db.syncStates.upsert({ source, lastSyncCursor: new Date().toISOString() });
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
```javascript
|
|
94
|
+
// ❌ WRONG: full sync on a schedule — 100k records hit the provider's
|
|
95
|
+
// rate limit and reprocess everything
|
|
96
|
+
await crmClient.getAllContacts();
|
|
97
|
+
|
|
98
|
+
// ✅ RIGHT: only what changed since the cursor
|
|
99
|
+
await crmClient.getContacts({ modifiedAfter: lastSyncCursor });
|
|
100
|
+
```
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
# Reference: Helm chart templates (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/kubernetes-helm` — deployment with probes/lifecycle/securityContext, config-checksum rollout, values layout, HPA scale-down behavior. Read when scaffolding or reviewing a chart.
|
|
4
|
+
|
|
5
|
+
## Deployment template
|
|
6
|
+
|
|
7
|
+
```yaml
|
|
8
|
+
# templates/deployment.yaml
|
|
9
|
+
apiVersion: apps/v1
|
|
10
|
+
kind: Deployment
|
|
11
|
+
metadata:
|
|
12
|
+
name: {{ include "my-app.fullname" . }}
|
|
13
|
+
labels: {{ include "my-app.labels" . | nindent 4 }}
|
|
14
|
+
spec:
|
|
15
|
+
replicas: {{ .Values.replicaCount }}
|
|
16
|
+
selector:
|
|
17
|
+
matchLabels: {{ include "my-app.selectorLabels" . | nindent 6 }}
|
|
18
|
+
strategy:
|
|
19
|
+
type: RollingUpdate
|
|
20
|
+
rollingUpdate:
|
|
21
|
+
maxUnavailable: 0
|
|
22
|
+
maxSurge: 1
|
|
23
|
+
template:
|
|
24
|
+
metadata:
|
|
25
|
+
labels: {{ include "my-app.selectorLabels" . | nindent 8 }}
|
|
26
|
+
annotations:
|
|
27
|
+
# Force pod restart when the ConfigMap changes
|
|
28
|
+
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
|
|
29
|
+
spec:
|
|
30
|
+
terminationGracePeriodSeconds: 60
|
|
31
|
+
securityContext:
|
|
32
|
+
runAsNonRoot: true
|
|
33
|
+
runAsUser: 1000
|
|
34
|
+
fsGroup: 2000
|
|
35
|
+
containers:
|
|
36
|
+
- name: app
|
|
37
|
+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
|
|
38
|
+
imagePullPolicy: IfNotPresent
|
|
39
|
+
ports:
|
|
40
|
+
- containerPort: {{ .Values.service.port }}
|
|
41
|
+
protocol: TCP
|
|
42
|
+
envFrom:
|
|
43
|
+
- configMapRef:
|
|
44
|
+
name: {{ include "my-app.fullname" . }}-config
|
|
45
|
+
- secretRef:
|
|
46
|
+
name: {{ include "my-app.fullname" . }}-secrets
|
|
47
|
+
resources:
|
|
48
|
+
requests:
|
|
49
|
+
cpu: {{ .Values.resources.requests.cpu }}
|
|
50
|
+
memory: {{ .Values.resources.requests.memory }}
|
|
51
|
+
limits:
|
|
52
|
+
cpu: {{ .Values.resources.limits.cpu }}
|
|
53
|
+
memory: {{ .Values.resources.limits.memory }}
|
|
54
|
+
readinessProbe:
|
|
55
|
+
httpGet:
|
|
56
|
+
path: /healthz/ready
|
|
57
|
+
port: {{ .Values.service.port }}
|
|
58
|
+
initialDelaySeconds: 10
|
|
59
|
+
periodSeconds: 5
|
|
60
|
+
failureThreshold: 3
|
|
61
|
+
livenessProbe:
|
|
62
|
+
httpGet:
|
|
63
|
+
path: /healthz/live # simple ping, no external deps
|
|
64
|
+
port: {{ .Values.service.port }}
|
|
65
|
+
initialDelaySeconds: 30
|
|
66
|
+
periodSeconds: 15
|
|
67
|
+
failureThreshold: 3
|
|
68
|
+
startupProbe:
|
|
69
|
+
httpGet:
|
|
70
|
+
path: /healthz/ready
|
|
71
|
+
port: {{ .Values.service.port }}
|
|
72
|
+
failureThreshold: 30 # 30 * 10s = 5 min boot window
|
|
73
|
+
periodSeconds: 10
|
|
74
|
+
lifecycle:
|
|
75
|
+
preStop:
|
|
76
|
+
exec:
|
|
77
|
+
command: ["/bin/sh", "-c", "sleep 5"] # drain in-flight requests
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Values layout
|
|
81
|
+
|
|
82
|
+
```yaml
|
|
83
|
+
# values.yaml — non-sensitive defaults; per-env overrides in values-<env>.yaml
|
|
84
|
+
replicaCount: 2
|
|
85
|
+
|
|
86
|
+
image:
|
|
87
|
+
repository: registry.example.com/my-app
|
|
88
|
+
tag: "" # set at deploy time to a release tag or digest — never "latest"
|
|
89
|
+
|
|
90
|
+
service:
|
|
91
|
+
type: ClusterIP
|
|
92
|
+
port: 3000
|
|
93
|
+
|
|
94
|
+
ingress:
|
|
95
|
+
enabled: true
|
|
96
|
+
className: nginx
|
|
97
|
+
annotations:
|
|
98
|
+
cert-manager.io/cluster-issuer: letsencrypt-prod
|
|
99
|
+
nginx.ingress.kubernetes.io/proxy-body-size: "10m"
|
|
100
|
+
hosts:
|
|
101
|
+
- host: api.example.com
|
|
102
|
+
paths:
|
|
103
|
+
- path: /
|
|
104
|
+
pathType: Prefix
|
|
105
|
+
tls:
|
|
106
|
+
- secretName: myapp-tls
|
|
107
|
+
hosts: [api.example.com]
|
|
108
|
+
|
|
109
|
+
resources:
|
|
110
|
+
requests: { cpu: "100m", memory: "128Mi" }
|
|
111
|
+
limits: { cpu: "500m", memory: "512Mi" }
|
|
112
|
+
|
|
113
|
+
autoscaling:
|
|
114
|
+
enabled: true
|
|
115
|
+
minReplicas: 2
|
|
116
|
+
maxReplicas: 10
|
|
117
|
+
targetCPUUtilizationPercentage: 60
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## HPA with scale-down stabilization
|
|
121
|
+
|
|
122
|
+
```yaml
|
|
123
|
+
# templates/hpa.yaml
|
|
124
|
+
{{- if .Values.autoscaling.enabled }}
|
|
125
|
+
apiVersion: autoscaling/v2
|
|
126
|
+
kind: HorizontalPodAutoscaler
|
|
127
|
+
metadata:
|
|
128
|
+
name: {{ include "my-app.fullname" . }}
|
|
129
|
+
spec:
|
|
130
|
+
scaleTargetRef:
|
|
131
|
+
apiVersion: apps/v1
|
|
132
|
+
kind: Deployment
|
|
133
|
+
name: {{ include "my-app.fullname" . }}
|
|
134
|
+
minReplicas: {{ .Values.autoscaling.minReplicas }}
|
|
135
|
+
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
|
|
136
|
+
metrics:
|
|
137
|
+
- type: Resource
|
|
138
|
+
resource:
|
|
139
|
+
name: cpu
|
|
140
|
+
target:
|
|
141
|
+
type: Utilization
|
|
142
|
+
averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
|
|
143
|
+
behavior:
|
|
144
|
+
scaleDown:
|
|
145
|
+
stabilizationWindowSeconds: 300 # wait 5 min before scaling down
|
|
146
|
+
policies:
|
|
147
|
+
- type: Pods
|
|
148
|
+
value: 1
|
|
149
|
+
periodSeconds: 60
|
|
150
|
+
{{- end }}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Probe semantics
|
|
154
|
+
|
|
155
|
+
```
|
|
156
|
+
readinessProbe → "Can this pod receive traffic?"
|
|
157
|
+
- checks DB / downstream deps; failing pod is removed from Service endpoints
|
|
158
|
+
livenessProbe → "Is the process truly hung?"
|
|
159
|
+
- simple ping only; failure restarts the pod — never check external deps here
|
|
160
|
+
startupProbe → "Has the app finished booting?"
|
|
161
|
+
- suppresses liveness during slow boots; hands off once it succeeds
|
|
162
|
+
```
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Reference: Kubernetes secrets, storage and deploy flow (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/kubernetes-helm` — operator-synced secrets, production StorageClass/PVC, atomic deploy and rollback commands. Read when wiring secrets, persistent data, or the release pipeline.
|
|
4
|
+
|
|
5
|
+
## Operator-synced secret (External Secrets Operator)
|
|
6
|
+
|
|
7
|
+
```yaml
|
|
8
|
+
# templates/externalsecret.yaml
|
|
9
|
+
apiVersion: external-secrets.io/v1beta1
|
|
10
|
+
kind: ExternalSecret
|
|
11
|
+
metadata:
|
|
12
|
+
name: {{ include "my-app.fullname" . }}-secrets
|
|
13
|
+
spec:
|
|
14
|
+
refreshInterval: 1h
|
|
15
|
+
secretStoreRef:
|
|
16
|
+
name: platform-secret-store # ClusterSecretStore configured cluster-wide
|
|
17
|
+
kind: ClusterSecretStore
|
|
18
|
+
target:
|
|
19
|
+
name: {{ include "my-app.fullname" . }}-secrets
|
|
20
|
+
creationPolicy: Owner
|
|
21
|
+
data:
|
|
22
|
+
- secretKey: DATABASE_URL
|
|
23
|
+
remoteRef:
|
|
24
|
+
key: myapp/prod/database
|
|
25
|
+
property: url
|
|
26
|
+
- secretKey: JWT_SECRET
|
|
27
|
+
remoteRef:
|
|
28
|
+
key: myapp/prod/jwt
|
|
29
|
+
property: secret
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Production storage
|
|
33
|
+
|
|
34
|
+
```yaml
|
|
35
|
+
# StorageClass — create once per cluster
|
|
36
|
+
apiVersion: storage.k8s.io/v1
|
|
37
|
+
kind: StorageClass
|
|
38
|
+
metadata:
|
|
39
|
+
name: app-ssd
|
|
40
|
+
provisioner: ebs.csi.aws.com # or the cluster's CSI driver
|
|
41
|
+
parameters:
|
|
42
|
+
type: gp3
|
|
43
|
+
reclaimPolicy: Retain # never Delete for production data
|
|
44
|
+
volumeBindingMode: WaitForFirstConsumer
|
|
45
|
+
---
|
|
46
|
+
apiVersion: v1
|
|
47
|
+
kind: PersistentVolumeClaim
|
|
48
|
+
metadata:
|
|
49
|
+
name: app-data
|
|
50
|
+
spec:
|
|
51
|
+
accessModes: [ReadWriteOnce]
|
|
52
|
+
storageClassName: app-ssd
|
|
53
|
+
resources:
|
|
54
|
+
requests:
|
|
55
|
+
storage: 20Gi
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Atomic deploy and rollback
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
# Deploy — atomic release with layered values, bounded history
|
|
62
|
+
helm upgrade --install my-app ./charts/my-app \
|
|
63
|
+
--namespace my-app --create-namespace \
|
|
64
|
+
--values charts/my-app/values.yaml \
|
|
65
|
+
--values charts/my-app/values-prod.yaml \
|
|
66
|
+
--set image.tag=$IMAGE_TAG \
|
|
67
|
+
--atomic \
|
|
68
|
+
--timeout 5m \
|
|
69
|
+
--history-max 5
|
|
70
|
+
|
|
71
|
+
# Pre-merge checks
|
|
72
|
+
helm lint ./charts/my-app
|
|
73
|
+
helm template my-app ./charts/my-app -f charts/my-app/values-prod.yaml > /dev/null
|
|
74
|
+
|
|
75
|
+
# Recovery — roll back first, investigate after
|
|
76
|
+
helm rollback my-app 0 # 0 = previous revision
|
|
77
|
+
helm history my-app
|
|
78
|
+
```
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# Reference: bounded agent factory and cost tracking (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/langchain-python-agent` — settings, a graph-runtime agent with hard bounds, and a per-feature cost-tracking callback. Model identifiers and prices always come from configuration, never from literals.
|
|
4
|
+
|
|
5
|
+
## Settings
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
# app/config.py
|
|
9
|
+
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
10
|
+
from pydantic import SecretStr
|
|
11
|
+
|
|
12
|
+
class Settings(BaseSettings):
|
|
13
|
+
model_config = SettingsConfigDict(env_file=".env", env_file_encoding="utf-8")
|
|
14
|
+
|
|
15
|
+
primary_api_key: SecretStr
|
|
16
|
+
fallback_api_key: SecretStr
|
|
17
|
+
tracing_api_key: SecretStr
|
|
18
|
+
tracing_project: str = "my-app"
|
|
19
|
+
|
|
20
|
+
# Model identifiers come from env/config — never literals in code
|
|
21
|
+
default_model: str
|
|
22
|
+
fallback_model: str
|
|
23
|
+
temperature: float = 0.0 # deterministic by default
|
|
24
|
+
max_tokens: int = 4096
|
|
25
|
+
max_retries: int = 3
|
|
26
|
+
|
|
27
|
+
redis_url: str = "redis://localhost:6379"
|
|
28
|
+
|
|
29
|
+
settings = Settings()
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Bounded agent (graph runtime)
|
|
33
|
+
|
|
34
|
+
Build agents on the maintained graph runtime (LangGraph prebuilt); the legacy `AgentExecutor`/`initialize_agent` path is deprecated.
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
# app/agents/research_agent.py
|
|
38
|
+
from langchain.chat_models import init_chat_model
|
|
39
|
+
from langgraph.prebuilt import create_react_agent
|
|
40
|
+
from app.config import settings
|
|
41
|
+
from app.tools import web_search_tool
|
|
42
|
+
|
|
43
|
+
def build_research_agent():
|
|
44
|
+
llm = init_chat_model(
|
|
45
|
+
settings.default_model, # provider/model from config
|
|
46
|
+
temperature=settings.temperature,
|
|
47
|
+
max_tokens=settings.max_tokens,
|
|
48
|
+
)
|
|
49
|
+
return create_react_agent(llm, tools=[web_search_tool])
|
|
50
|
+
|
|
51
|
+
# Usage in an endpoint — every run is bounded and traced:
|
|
52
|
+
# result = await agent.ainvoke(
|
|
53
|
+
# {"messages": [("user", user_query)]},
|
|
54
|
+
# config={
|
|
55
|
+
# "recursion_limit": 12, # hard iteration bound
|
|
56
|
+
# "run_name": "ResearchAgent",
|
|
57
|
+
# "tags": ["research"],
|
|
58
|
+
# "metadata": {"session_id": session_id},
|
|
59
|
+
# "callbacks": [cost_cb],
|
|
60
|
+
# },
|
|
61
|
+
# )
|
|
62
|
+
# Wrap the ainvoke in asyncio.wait_for(...) for the wall-clock timeout.
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Per-feature cost tracking callback
|
|
66
|
+
|
|
67
|
+
```python
|
|
68
|
+
# app/callbacks/cost_tracker.py
|
|
69
|
+
from langchain_core.callbacks import BaseCallbackHandler
|
|
70
|
+
from langchain_core.outputs import LLMResult
|
|
71
|
+
import logging
|
|
72
|
+
|
|
73
|
+
logger = logging.getLogger(__name__)
|
|
74
|
+
|
|
75
|
+
class CostCallbackHandler(BaseCallbackHandler):
|
|
76
|
+
"""Token/cost attribution per feature. Rates come from configuration
|
|
77
|
+
(e.g. a versioned models.json) — never hardcode prices."""
|
|
78
|
+
|
|
79
|
+
def __init__(self, feature: str, rate_table: dict[str, dict[str, float]]):
|
|
80
|
+
self.feature = feature
|
|
81
|
+
self.rates = rate_table # model → {"input": .., "output": ..} per 1K tokens
|
|
82
|
+
self.total_input_tokens = 0
|
|
83
|
+
self.total_output_tokens = 0
|
|
84
|
+
self.total_cost_usd = 0.0
|
|
85
|
+
|
|
86
|
+
def on_llm_end(self, response: LLMResult, **kwargs):
|
|
87
|
+
usage = (response.llm_output or {}).get("token_usage", {})
|
|
88
|
+
model = (response.llm_output or {}).get("model_name", "unknown")
|
|
89
|
+
|
|
90
|
+
input_tokens = usage.get("prompt_tokens", 0)
|
|
91
|
+
output_tokens = usage.get("completion_tokens", 0)
|
|
92
|
+
rates = self.rates.get(model, {"input": 0.0, "output": 0.0})
|
|
93
|
+
cost = (input_tokens / 1000 * rates["input"]) + (output_tokens / 1000 * rates["output"])
|
|
94
|
+
|
|
95
|
+
self.total_input_tokens += input_tokens
|
|
96
|
+
self.total_output_tokens += output_tokens
|
|
97
|
+
self.total_cost_usd += cost
|
|
98
|
+
|
|
99
|
+
logger.info({
|
|
100
|
+
"event": "llm_call_complete",
|
|
101
|
+
"feature": self.feature,
|
|
102
|
+
"model": model,
|
|
103
|
+
"input_tokens": input_tokens,
|
|
104
|
+
"output_tokens": output_tokens,
|
|
105
|
+
"cost_usd": round(cost, 6),
|
|
106
|
+
})
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Structured output
|
|
110
|
+
|
|
111
|
+
```python
|
|
112
|
+
from pydantic import BaseModel
|
|
113
|
+
|
|
114
|
+
class Invoice(BaseModel):
|
|
115
|
+
number: str
|
|
116
|
+
total: float
|
|
117
|
+
|
|
118
|
+
extractor = llm.with_structured_output(Invoice)
|
|
119
|
+
invoice = await extractor.ainvoke(raw_text) # never regex-parse completions
|
|
120
|
+
```
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# Reference: session memory, retry and provider fallback (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/langchain-python-agent` — Redis-backed session history with TTL, retry with exponential backoff, and a provider fallback chain.
|
|
4
|
+
|
|
5
|
+
## Redis session history
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
# app/memory/redis_history.py
|
|
9
|
+
from langchain_redis import RedisChatMessageHistory
|
|
10
|
+
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
|
|
11
|
+
from langchain_core.runnables.history import RunnableWithMessageHistory
|
|
12
|
+
from langchain.chat_models import init_chat_model
|
|
13
|
+
from app.config import settings
|
|
14
|
+
|
|
15
|
+
def build_conversational_chain():
|
|
16
|
+
llm = init_chat_model(settings.default_model, temperature=0.7)
|
|
17
|
+
|
|
18
|
+
prompt = ChatPromptTemplate.from_messages([
|
|
19
|
+
("system", "You are a helpful assistant."),
|
|
20
|
+
MessagesPlaceholder(variable_name="history"),
|
|
21
|
+
("human", "{input}"),
|
|
22
|
+
])
|
|
23
|
+
chain = prompt | llm
|
|
24
|
+
|
|
25
|
+
def get_history(session_id: str):
|
|
26
|
+
return RedisChatMessageHistory(
|
|
27
|
+
session_id=session_id,
|
|
28
|
+
redis_url=settings.redis_url,
|
|
29
|
+
ttl=3600, # session expiry — session memory always has a TTL
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
return RunnableWithMessageHistory(
|
|
33
|
+
chain,
|
|
34
|
+
get_history,
|
|
35
|
+
input_messages_key="input",
|
|
36
|
+
history_messages_key="history",
|
|
37
|
+
)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Scope guide: in-memory history for single requests/tests; Redis with TTL for multi-turn sessions; a database-backed history for auditable logs; the vector store for durable semantic recall; summary/compression when the conversation outgrows the context window.
|
|
41
|
+
|
|
42
|
+
## Retry with exponential backoff
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
# app/agents/base.py
|
|
46
|
+
from tenacity import retry, stop_after_attempt, wait_exponential, retry_if_exception_type
|
|
47
|
+
|
|
48
|
+
# Retry only transient provider errors (rate limits, timeouts) — import the
|
|
49
|
+
# provider SDK's specific exception types; never retry on bad input.
|
|
50
|
+
@retry(
|
|
51
|
+
stop=stop_after_attempt(3),
|
|
52
|
+
wait=wait_exponential(multiplier=1, min=2, max=30),
|
|
53
|
+
retry=retry_if_exception_type(TRANSIENT_PROVIDER_ERRORS),
|
|
54
|
+
reraise=True,
|
|
55
|
+
)
|
|
56
|
+
async def call_with_retry(chain, inputs: dict):
|
|
57
|
+
return await chain.ainvoke(inputs)
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Provider fallback chain
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
from langchain.chat_models import init_chat_model
|
|
64
|
+
from app.config import settings
|
|
65
|
+
|
|
66
|
+
def build_llm_with_fallback():
|
|
67
|
+
primary = init_chat_model(settings.default_model, temperature=0)
|
|
68
|
+
fallback = init_chat_model(settings.fallback_model, temperature=0)
|
|
69
|
+
|
|
70
|
+
# On primary-provider failure, transparently retry against the fallback.
|
|
71
|
+
# Log every fallback activation — silent failover hides incidents.
|
|
72
|
+
return primary.with_fallbacks(
|
|
73
|
+
[fallback],
|
|
74
|
+
exceptions_to_handle=TRANSIENT_PROVIDER_ERRORS,
|
|
75
|
+
)
|
|
76
|
+
```
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# Reference: Eloquent discipline and queued jobs (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/laravel` — model hygiene, eager loading, idempotent queued job dispatched after commit. Read when touching models, list queries, or slow work.
|
|
4
|
+
|
|
5
|
+
## Model: relationships, casts, scopes — not workflows
|
|
6
|
+
|
|
7
|
+
```php
|
|
8
|
+
// app/Models/Order.php
|
|
9
|
+
namespace App\Models;
|
|
10
|
+
|
|
11
|
+
use Illuminate\Database\Eloquent\Builder;
|
|
12
|
+
use Illuminate\Database\Eloquent\Model;
|
|
13
|
+
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
14
|
+
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
15
|
+
|
|
16
|
+
class Order extends Model
|
|
17
|
+
{
|
|
18
|
+
// Explicit — $guarded = [] is forbidden.
|
|
19
|
+
protected $fillable = ['customer_id', 'status', 'total'];
|
|
20
|
+
|
|
21
|
+
protected $casts = [
|
|
22
|
+
'total' => 'decimal:2',
|
|
23
|
+
'paid_at' => 'immutable_datetime',
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
public function customer(): BelongsTo
|
|
27
|
+
{
|
|
28
|
+
return $this->belongsTo(Customer::class);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
public function items(): HasMany
|
|
32
|
+
{
|
|
33
|
+
return $this->hasMany(OrderItem::class);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
public function scopeOpen(Builder $query): Builder
|
|
37
|
+
{
|
|
38
|
+
return $query->whereNull('paid_at');
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Eager loading (N+1 is a review blocker)
|
|
44
|
+
|
|
45
|
+
```php
|
|
46
|
+
// In the service/action feeding a list endpoint:
|
|
47
|
+
$orders = Order::query()
|
|
48
|
+
->open()
|
|
49
|
+
->with(['customer', 'items']) // every relation the resource touches
|
|
50
|
+
->latest()
|
|
51
|
+
->paginate(25);
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
```php
|
|
55
|
+
// app/Providers/AppServiceProvider.php — boot(): fail fast outside prod.
|
|
56
|
+
Model::preventLazyLoading(! app()->isProduction());
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Idempotent queued job, dispatched after commit
|
|
60
|
+
|
|
61
|
+
```php
|
|
62
|
+
// app/Jobs/SendOrderConfirmation.php
|
|
63
|
+
namespace App\Jobs;
|
|
64
|
+
|
|
65
|
+
use App\Models\Order;
|
|
66
|
+
use Illuminate\Bus\Queueable;
|
|
67
|
+
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
68
|
+
use Illuminate\Foundation\Bus\Dispatchable;
|
|
69
|
+
use Illuminate\Queue\InteractsWithQueue;
|
|
70
|
+
use Illuminate\Queue\SerializesModels;
|
|
71
|
+
|
|
72
|
+
class SendOrderConfirmation implements ShouldQueue
|
|
73
|
+
{
|
|
74
|
+
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
75
|
+
|
|
76
|
+
public int $tries = 3;
|
|
77
|
+
|
|
78
|
+
/** @return array<int, int> seconds */
|
|
79
|
+
public function backoff(): array
|
|
80
|
+
{
|
|
81
|
+
return [10, 60, 300];
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
public function __construct(public readonly Order $order)
|
|
85
|
+
{
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
public function handle(): void
|
|
89
|
+
{
|
|
90
|
+
// Idempotent: re-running must not double-send.
|
|
91
|
+
if ($this->order->confirmation_sent_at !== null) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
// ... send mail ...
|
|
95
|
+
$this->order->update(['confirmation_sent_at' => now()]);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
```php
|
|
101
|
+
// Dispatch AFTER the transaction commits — never inside it:
|
|
102
|
+
DB::transaction(function () use ($data, &$order) {
|
|
103
|
+
$order = Order::create($data);
|
|
104
|
+
});
|
|
105
|
+
SendOrderConfirmation::dispatch($order);
|
|
106
|
+
|
|
107
|
+
// Or, from inside a transaction:
|
|
108
|
+
SendOrderConfirmation::dispatch($order)->afterCommit();
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Migration + factory move together
|
|
112
|
+
|
|
113
|
+
```php
|
|
114
|
+
// database/migrations/xxxx_add_confirmation_sent_at_to_orders.php
|
|
115
|
+
public function up(): void
|
|
116
|
+
{
|
|
117
|
+
Schema::table('orders', fn (Blueprint $t) => $t->timestamp('confirmation_sent_at')->nullable());
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
public function down(): void
|
|
121
|
+
{
|
|
122
|
+
Schema::table('orders', fn (Blueprint $t) => $t->dropColumn('confirmation_sent_at'));
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Update `OrderFactory` in the same change; run the migration up and down before the PR.
|