@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,65 @@
|
|
|
1
|
+
# Reference: Cloud Run IAM, secrets, and private networking (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/cloud-run-gcp`. Read when provisioning a new service account, secret, or Cloud SQL connectivity.
|
|
4
|
+
|
|
5
|
+
## Least-privilege service account
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
gcloud iam service-accounts create my-app-sa \
|
|
9
|
+
--display-name="My App Cloud Run SA" \
|
|
10
|
+
--project=$PROJECT_ID
|
|
11
|
+
|
|
12
|
+
SA="my-app-sa@$PROJECT_ID.iam.gserviceaccount.com"
|
|
13
|
+
|
|
14
|
+
# Cloud SQL client role
|
|
15
|
+
gcloud projects add-iam-policy-binding $PROJECT_ID \
|
|
16
|
+
--member="serviceAccount:$SA" \
|
|
17
|
+
--role="roles/cloudsql.client"
|
|
18
|
+
|
|
19
|
+
# Per-secret accessor (NOT project-wide)
|
|
20
|
+
gcloud secrets add-iam-policy-binding my-app-db-url \
|
|
21
|
+
--member="serviceAccount:$SA" \
|
|
22
|
+
--role="roles/secretmanager.secretAccessor"
|
|
23
|
+
|
|
24
|
+
# Bucket-scoped storage access if needed
|
|
25
|
+
gcloud storage buckets add-iam-policy-binding gs://my-app-uploads \
|
|
26
|
+
--member="serviceAccount:$SA" \
|
|
27
|
+
--role="roles/storage.objectUser"
|
|
28
|
+
|
|
29
|
+
# NEVER grant: roles/owner, roles/editor, roles/iam.admin
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Secret Manager lifecycle
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
# Create
|
|
36
|
+
echo -n "postgresql://user:pass@10.x.x.x:5432/mydb" | \
|
|
37
|
+
gcloud secrets create my-app-db-url --data-file=-
|
|
38
|
+
|
|
39
|
+
echo -n "$(openssl rand -hex 32)" | \
|
|
40
|
+
gcloud secrets create my-app-jwt --data-file=-
|
|
41
|
+
|
|
42
|
+
# Rotate (creates a new version; Cloud Run picks it up on next deploy)
|
|
43
|
+
echo -n "new-value" | gcloud secrets versions add my-app-db-url --data-file=-
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Reference them at deploy time with `--set-secrets="DATABASE_URL=my-app-db-url:latest"` — never paste secret values as plain env vars in the console or in `gcloud` invocations.
|
|
47
|
+
|
|
48
|
+
## VPC connector + private Cloud SQL
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
# Serverless VPC Access connector
|
|
52
|
+
gcloud compute networks vpc-access connectors create my-connector \
|
|
53
|
+
--region=us-central1 \
|
|
54
|
+
--subnet=my-connector-subnet \
|
|
55
|
+
--subnet-project=$PROJECT_ID \
|
|
56
|
+
--min-throughput=200 \
|
|
57
|
+
--max-throughput=1000
|
|
58
|
+
|
|
59
|
+
# Cloud SQL: private IP only — remove the public IP
|
|
60
|
+
gcloud sql instances patch my-instance \
|
|
61
|
+
--no-assign-ip \
|
|
62
|
+
--network=projects/$PROJECT_ID/global/networks/my-vpc
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
With private IP the app connects straight to the instance's `10.x.x.x` address (no Auth Proxy needed). Deploy the service with `--vpc-connector=my-connector --vpc-egress=private-ranges-only`.
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
# Reference: YOLO serving, tracking, and export (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/computer-vision-yolo`. Read when building the inference API, adding tracking, or exporting an optimized engine.
|
|
4
|
+
|
|
5
|
+
## Detector singleton (loaded once, warmed up)
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
# app/detector.py
|
|
9
|
+
from ultralytics import YOLO
|
|
10
|
+
from ultralytics.engine.results import Results
|
|
11
|
+
import torch
|
|
12
|
+
import numpy as np
|
|
13
|
+
|
|
14
|
+
class YOLODetector:
|
|
15
|
+
_instance: "YOLODetector | None" = None
|
|
16
|
+
_model: YOLO | None = None
|
|
17
|
+
|
|
18
|
+
@classmethod
|
|
19
|
+
def get_instance(cls) -> "YOLODetector":
|
|
20
|
+
if cls._instance is None:
|
|
21
|
+
cls._instance = cls()
|
|
22
|
+
return cls._instance
|
|
23
|
+
|
|
24
|
+
def load(
|
|
25
|
+
self,
|
|
26
|
+
weights: str, # from config, e.g. models/best.pt
|
|
27
|
+
device: str = "0", # "0" = GPU 0, "cpu" = CPU (dev only)
|
|
28
|
+
half: bool = True, # FP16 on GPU for ~2x throughput
|
|
29
|
+
) -> None:
|
|
30
|
+
self._model = YOLO(weights)
|
|
31
|
+
self._model.to(device)
|
|
32
|
+
if half and torch.cuda.is_available():
|
|
33
|
+
self._model.model.half()
|
|
34
|
+
# Warmup: dummy inference to JIT-compile (cold start is 2-5s)
|
|
35
|
+
dummy = np.zeros((640, 640, 3), dtype=np.uint8)
|
|
36
|
+
self._model(dummy, verbose=False)
|
|
37
|
+
|
|
38
|
+
def detect(
|
|
39
|
+
self,
|
|
40
|
+
image: np.ndarray,
|
|
41
|
+
conf: float = 0.4, # production default — tune per class
|
|
42
|
+
iou: float = 0.45, # library default NMS IoU
|
|
43
|
+
classes: list[int] | None = None,
|
|
44
|
+
max_det: int = 300,
|
|
45
|
+
) -> Results:
|
|
46
|
+
if self._model is None:
|
|
47
|
+
raise RuntimeError("Model not loaded. Call load() first.")
|
|
48
|
+
with torch.inference_mode():
|
|
49
|
+
results = self._model(
|
|
50
|
+
image, conf=conf, iou=iou,
|
|
51
|
+
classes=classes, max_det=max_det, verbose=False,
|
|
52
|
+
)
|
|
53
|
+
return results[0]
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## FastAPI detect endpoint (defensive decode)
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
# app/routes/detect.py
|
|
60
|
+
from fastapi import APIRouter, UploadFile, File, HTTPException
|
|
61
|
+
from app.detector import YOLODetector
|
|
62
|
+
from app.schemas import DetectionResponse, Detection
|
|
63
|
+
import numpy as np
|
|
64
|
+
import cv2
|
|
65
|
+
|
|
66
|
+
router = APIRouter(prefix="/v1")
|
|
67
|
+
|
|
68
|
+
@router.post("/detect", response_model=DetectionResponse)
|
|
69
|
+
async def detect_objects(
|
|
70
|
+
file: UploadFile = File(...),
|
|
71
|
+
conf: float = 0.4,
|
|
72
|
+
classes: str | None = None, # "0,1,2" CSV of class ids
|
|
73
|
+
):
|
|
74
|
+
if not file.content_type.startswith("image/"):
|
|
75
|
+
raise HTTPException(status_code=422, detail="File must be an image")
|
|
76
|
+
|
|
77
|
+
content = await file.read()
|
|
78
|
+
image = cv2.imdecode(np.frombuffer(content, np.uint8), cv2.IMREAD_COLOR)
|
|
79
|
+
if image is None:
|
|
80
|
+
raise HTTPException(status_code=422, detail="Could not decode image")
|
|
81
|
+
|
|
82
|
+
class_filter = [int(c) for c in classes.split(",")] if classes else None
|
|
83
|
+
results = YOLODetector.get_instance().detect(image, conf=conf, classes=class_filter)
|
|
84
|
+
|
|
85
|
+
detections = [
|
|
86
|
+
Detection(
|
|
87
|
+
class_id=int(box.cls),
|
|
88
|
+
class_name=results.names[int(box.cls)],
|
|
89
|
+
confidence=float(box.conf),
|
|
90
|
+
bbox_xyxy=[float(x) for x in box.xyxy[0].tolist()],
|
|
91
|
+
)
|
|
92
|
+
for box in results.boxes
|
|
93
|
+
]
|
|
94
|
+
return DetectionResponse(
|
|
95
|
+
image_shape={"width": image.shape[1], "height": image.shape[0]},
|
|
96
|
+
detections=detections,
|
|
97
|
+
inference_time_ms=results.speed["inference"],
|
|
98
|
+
)
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Object tracking (ByteTrack, streamed)
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
# app/tracker.py
|
|
105
|
+
from ultralytics import YOLO
|
|
106
|
+
|
|
107
|
+
def track_video(video_path: str, weights: str):
|
|
108
|
+
model = YOLO(weights)
|
|
109
|
+
results = model.track(
|
|
110
|
+
source=video_path,
|
|
111
|
+
tracker="bytetrack.yaml", # built into ultralytics
|
|
112
|
+
conf=0.4,
|
|
113
|
+
iou=0.5,
|
|
114
|
+
persist=True, # persist tracking state between frames
|
|
115
|
+
stream=True, # generator — memory-safe for long videos
|
|
116
|
+
)
|
|
117
|
+
for frame_result in results:
|
|
118
|
+
if frame_result.boxes.id is None:
|
|
119
|
+
continue # no tracked objects in this frame
|
|
120
|
+
for box in frame_result.boxes:
|
|
121
|
+
track_id = int(box.id)
|
|
122
|
+
# process: count unique ids, trigger events, log
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Engine export + benchmark
|
|
126
|
+
|
|
127
|
+
```python
|
|
128
|
+
# export/export_engine.py
|
|
129
|
+
from ultralytics import YOLO
|
|
130
|
+
import time
|
|
131
|
+
import numpy as np
|
|
132
|
+
|
|
133
|
+
def export_tensorrt(weights: str):
|
|
134
|
+
model = YOLO(weights)
|
|
135
|
+
model.export(
|
|
136
|
+
format="engine", # TensorRT; "onnx" for portability, "coreml" for Apple
|
|
137
|
+
device=0,
|
|
138
|
+
half=True, # FP16
|
|
139
|
+
imgsz=640,
|
|
140
|
+
simplify=True,
|
|
141
|
+
dynamic=False, # static shape is faster; True for variable input size
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
def benchmark(paths: dict[str, str], n: int = 100):
|
|
145
|
+
"""Compare native checkpoint vs exported engines before switching."""
|
|
146
|
+
dummy = np.random.randint(0, 255, (640, 640, 3), dtype=np.uint8)
|
|
147
|
+
for fmt, path in paths.items():
|
|
148
|
+
model = YOLO(path)
|
|
149
|
+
model(dummy, verbose=False) # warmup
|
|
150
|
+
t0 = time.perf_counter()
|
|
151
|
+
for _ in range(n):
|
|
152
|
+
model(dummy, verbose=False)
|
|
153
|
+
elapsed = (time.perf_counter() - t0) / n * 1000
|
|
154
|
+
print(f"{fmt:10}: {elapsed:.1f} ms/image | {1000 / elapsed:.0f} FPS")
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
TensorRT typically gives a 2-5x speedup over the native checkpoint at FP16; always verify outputs match before deploying the engine.
|
|
158
|
+
|
|
159
|
+
## GPU Dockerfile
|
|
160
|
+
|
|
161
|
+
```dockerfile
|
|
162
|
+
# Pin the NVIDIA PyTorch base image tag in your own Dockerfile.
|
|
163
|
+
FROM nvcr.io/nvidia/pytorch:<tag> AS base
|
|
164
|
+
WORKDIR /app
|
|
165
|
+
|
|
166
|
+
# OpenCV runtime dependencies (Debian bookworm+: libgl1, not libgl1-mesa-glx)
|
|
167
|
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
168
|
+
libgl1 \
|
|
169
|
+
libglib2.0-0 \
|
|
170
|
+
&& rm -rf /var/lib/apt/lists/*
|
|
171
|
+
|
|
172
|
+
COPY requirements.txt .
|
|
173
|
+
RUN pip install --no-cache-dir -r requirements.txt
|
|
174
|
+
|
|
175
|
+
COPY . .
|
|
176
|
+
|
|
177
|
+
ENV PYTHONUNBUFFERED=1 PORT=8000
|
|
178
|
+
EXPOSE 8000
|
|
179
|
+
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "1"]
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Use `--workers 1` with a GPU — multiple workers fight over GPU memory. Scale horizontally with more containers instead.
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# Reference: YOLO training and validation (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/computer-vision-yolo`. Read when setting up a training run or wiring evaluation gates.
|
|
4
|
+
|
|
5
|
+
## Training script with experiment logging
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
# training/train.py
|
|
9
|
+
from ultralytics import YOLO
|
|
10
|
+
import mlflow
|
|
11
|
+
|
|
12
|
+
def train(
|
|
13
|
+
model_size: str = "n", # n, s, m, l, x
|
|
14
|
+
epochs: int = 100,
|
|
15
|
+
imgsz: int = 640,
|
|
16
|
+
batch: int = 16,
|
|
17
|
+
dataset_yaml: str = "datasets/my_dataset/dataset.yaml",
|
|
18
|
+
):
|
|
19
|
+
mlflow.set_experiment("yolo-detection")
|
|
20
|
+
run_name = f"yolo{model_size}_{epochs}ep_{imgsz}px"
|
|
21
|
+
|
|
22
|
+
model = YOLO(f"yolo{model_size}.pt") # pretrained weights
|
|
23
|
+
|
|
24
|
+
results = model.train(
|
|
25
|
+
data=dataset_yaml,
|
|
26
|
+
epochs=epochs,
|
|
27
|
+
imgsz=imgsz,
|
|
28
|
+
batch=batch,
|
|
29
|
+
device=0, # GPU 0; multi-GPU: [0, 1]
|
|
30
|
+
patience=20, # early stopping
|
|
31
|
+
|
|
32
|
+
# Optimizer
|
|
33
|
+
optimizer="AdamW",
|
|
34
|
+
lr0=0.001,
|
|
35
|
+
lrf=0.01, # final LR = lr0 * lrf
|
|
36
|
+
momentum=0.937,
|
|
37
|
+
weight_decay=0.0005,
|
|
38
|
+
|
|
39
|
+
# Augmentation (tune per dataset — see rules below)
|
|
40
|
+
hsv_h=0.015,
|
|
41
|
+
hsv_s=0.7,
|
|
42
|
+
hsv_v=0.4,
|
|
43
|
+
flipud=0.0,
|
|
44
|
+
fliplr=0.5,
|
|
45
|
+
mosaic=1.0, # crucial for small objects
|
|
46
|
+
mixup=0.0, # disable for simple datasets
|
|
47
|
+
copy_paste=0.0, # for instance segmentation
|
|
48
|
+
|
|
49
|
+
# Logging
|
|
50
|
+
project="runs/train",
|
|
51
|
+
name=run_name,
|
|
52
|
+
save=True,
|
|
53
|
+
save_period=10, # checkpoint every 10 epochs
|
|
54
|
+
plots=True,
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
with mlflow.start_run(run_name=run_name):
|
|
58
|
+
mlflow.log_params({
|
|
59
|
+
"model": f"yolo{model_size}",
|
|
60
|
+
"epochs": epochs, "imgsz": imgsz, "batch": batch,
|
|
61
|
+
})
|
|
62
|
+
mlflow.log_metrics({
|
|
63
|
+
"mAP50": results.results_dict["metrics/mAP50(B)"],
|
|
64
|
+
"mAP50-95": results.results_dict["metrics/mAP50-95(B)"],
|
|
65
|
+
"precision": results.results_dict["metrics/precision(B)"],
|
|
66
|
+
"recall": results.results_dict["metrics/recall(B)"],
|
|
67
|
+
})
|
|
68
|
+
mlflow.log_artifact(str(results.save_dir / "weights/best.pt"))
|
|
69
|
+
|
|
70
|
+
return results
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Augmentation tuning by data regime
|
|
74
|
+
|
|
75
|
+
- Small objects (< 32 px): keep `mosaic=1.0`, raise `imgsz` (e.g. 1280).
|
|
76
|
+
- Dense scenes: `copy_paste=0.5` helps.
|
|
77
|
+
- Medical/satellite imagery: reduce augmentation (`flipud=0.5`, less color jitter).
|
|
78
|
+
- Night/thermal imagery: `hsv_h=0`, `hsv_s=0` (no color augmentation).
|
|
79
|
+
|
|
80
|
+
## Dataset layout (YOLO format)
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
datasets/my_dataset/
|
|
84
|
+
├── dataset.yaml # path, train/val/test dirs, nc, names
|
|
85
|
+
├── images/{train,val,test}/ # 70/20/10 split
|
|
86
|
+
└── labels/{train,val,test}/ # one .txt per image:
|
|
87
|
+
# class_id cx cy width height (normalized 0-1)
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Commit the yaml together with the images/labels it describes; never change the split or format mid-experiment.
|
|
91
|
+
|
|
92
|
+
## Validation with quality gates
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
# training/validate.py
|
|
96
|
+
from ultralytics import YOLO
|
|
97
|
+
|
|
98
|
+
QUALITY_GATES = {
|
|
99
|
+
"mAP50": 0.70, # mean average precision at IoU=0.5
|
|
100
|
+
"mAP50-95": 0.50, # strict COCO-style metric
|
|
101
|
+
"precision": 0.75,
|
|
102
|
+
"recall": 0.65,
|
|
103
|
+
}
|
|
104
|
+
# IoU thresholds: 0.5 = standard; 0.75 = strict localization;
|
|
105
|
+
# 0.5-0.95 sweep (COCO) = benchmarking gold standard.
|
|
106
|
+
|
|
107
|
+
def validate_model(weights_path: str, dataset_yaml: str) -> dict:
|
|
108
|
+
model = YOLO(weights_path)
|
|
109
|
+
metrics = model.val(data=dataset_yaml, imgsz=640, conf=0.001, iou=0.7)
|
|
110
|
+
|
|
111
|
+
results = {
|
|
112
|
+
"mAP50": metrics.box.map50,
|
|
113
|
+
"mAP50-95": metrics.box.map,
|
|
114
|
+
"precision": metrics.box.mp,
|
|
115
|
+
"recall": metrics.box.mr,
|
|
116
|
+
"per_class": {
|
|
117
|
+
model.names[i]: {"ap50": ap}
|
|
118
|
+
for i, ap in enumerate(metrics.box.ap50)
|
|
119
|
+
},
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
failures = [
|
|
123
|
+
f"{k}: {v:.3f} < {QUALITY_GATES[k]}"
|
|
124
|
+
for k, v in results.items()
|
|
125
|
+
if k in QUALITY_GATES and v < QUALITY_GATES[k]
|
|
126
|
+
]
|
|
127
|
+
if failures:
|
|
128
|
+
raise ValueError("Quality gates failed:\n" + "\n".join(failures))
|
|
129
|
+
|
|
130
|
+
return results
|
|
131
|
+
```
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# Reference: Convex schema and functions (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/convex-react`. Read when defining tables or writing queries/mutations/actions.
|
|
4
|
+
|
|
5
|
+
## Schema with indexes (source of truth)
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
// convex/schema.ts
|
|
9
|
+
import { defineSchema, defineTable } from 'convex/server'
|
|
10
|
+
import { v } from 'convex/values'
|
|
11
|
+
|
|
12
|
+
export default defineSchema({
|
|
13
|
+
users: defineTable({
|
|
14
|
+
clerkId: v.string(),
|
|
15
|
+
email: v.string(),
|
|
16
|
+
name: v.string(),
|
|
17
|
+
imageUrl: v.optional(v.string()),
|
|
18
|
+
role: v.union(v.literal('user'), v.literal('admin')),
|
|
19
|
+
})
|
|
20
|
+
.index('by_clerk_id', ['clerkId'])
|
|
21
|
+
.index('by_email', ['email']),
|
|
22
|
+
|
|
23
|
+
posts: defineTable({
|
|
24
|
+
title: v.string(),
|
|
25
|
+
body: v.string(),
|
|
26
|
+
authorId: v.id('users'),
|
|
27
|
+
published: v.boolean(),
|
|
28
|
+
imageId: v.optional(v.id('_storage')),
|
|
29
|
+
})
|
|
30
|
+
.index('by_author', ['authorId'])
|
|
31
|
+
.index('by_published', ['published']),
|
|
32
|
+
|
|
33
|
+
likes: defineTable({
|
|
34
|
+
postId: v.id('posts'),
|
|
35
|
+
userId: v.id('users'),
|
|
36
|
+
}).index('by_post_and_user', ['postId', 'userId']),
|
|
37
|
+
})
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Every query pattern gets an index — add it here before writing the function that needs it.
|
|
41
|
+
|
|
42
|
+
## Query, mutation (auth + ownership), action
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
// convex/functions/posts.ts
|
|
46
|
+
import { v } from 'convex/values'
|
|
47
|
+
import { query, mutation, action } from '../_generated/server'
|
|
48
|
+
import { api } from '../_generated/api'
|
|
49
|
+
|
|
50
|
+
// Reactive query — every subscribed client auto-updates on change
|
|
51
|
+
export const list = query({
|
|
52
|
+
args: { limit: v.optional(v.number()) },
|
|
53
|
+
handler: async (ctx, { limit = 20 }) => {
|
|
54
|
+
return ctx.db.query('posts')
|
|
55
|
+
.withIndex('by_published', q => q.eq('published', true))
|
|
56
|
+
.order('desc')
|
|
57
|
+
.take(limit)
|
|
58
|
+
},
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
// Mutation — identity check BEFORE any ctx.db access
|
|
62
|
+
export const create = mutation({
|
|
63
|
+
args: { title: v.string(), body: v.string() },
|
|
64
|
+
handler: async (ctx, args) => {
|
|
65
|
+
const identity = await ctx.auth.getUserIdentity()
|
|
66
|
+
if (!identity) throw new Error('Unauthorized')
|
|
67
|
+
|
|
68
|
+
const user = await ctx.db.query('users')
|
|
69
|
+
.withIndex('by_clerk_id', q => q.eq('clerkId', identity.subject))
|
|
70
|
+
.first()
|
|
71
|
+
if (!user) throw new Error('User not found')
|
|
72
|
+
|
|
73
|
+
return ctx.db.insert('posts', {
|
|
74
|
+
title: args.title,
|
|
75
|
+
body: args.body,
|
|
76
|
+
authorId: user._id,
|
|
77
|
+
published: false,
|
|
78
|
+
})
|
|
79
|
+
},
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
// Ownership check + cleanup of linked storage in the SAME mutation
|
|
83
|
+
export const deletePost = mutation({
|
|
84
|
+
args: { postId: v.id('posts') },
|
|
85
|
+
handler: async (ctx, { postId }) => {
|
|
86
|
+
const identity = await ctx.auth.getUserIdentity()
|
|
87
|
+
if (!identity) throw new Error('Unauthorized')
|
|
88
|
+
const post = await ctx.db.get(postId)
|
|
89
|
+
if (!post) throw new Error('Post not found')
|
|
90
|
+
const user = await ctx.db.query('users')
|
|
91
|
+
.withIndex('by_clerk_id', q => q.eq('clerkId', identity.subject))
|
|
92
|
+
.first()
|
|
93
|
+
if (post.authorId !== user?._id) throw new Error('Forbidden')
|
|
94
|
+
if (post.imageId) await ctx.storage.delete(post.imageId)
|
|
95
|
+
await ctx.db.delete(postId)
|
|
96
|
+
},
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
// Action — external call; NOT transactional; DB only via runQuery/runMutation
|
|
100
|
+
export const enrichPost = action({
|
|
101
|
+
args: { postId: v.id('posts') },
|
|
102
|
+
handler: async (ctx, { postId }) => {
|
|
103
|
+
const post = await ctx.runQuery(api.functions.posts.getById, { postId })
|
|
104
|
+
const response = await fetch(process.env.ENRICHMENT_API_URL!, {
|
|
105
|
+
method: 'POST',
|
|
106
|
+
headers: {
|
|
107
|
+
Authorization: `Bearer ${process.env.ENRICHMENT_API_KEY}`, // npx convex env set
|
|
108
|
+
'Content-Type': 'application/json',
|
|
109
|
+
},
|
|
110
|
+
body: JSON.stringify({ text: post?.body }),
|
|
111
|
+
})
|
|
112
|
+
const { summary } = await response.json()
|
|
113
|
+
await ctx.runMutation(api.functions.posts.updateSummary, { postId, summary })
|
|
114
|
+
return summary
|
|
115
|
+
},
|
|
116
|
+
})
|
|
117
|
+
```
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# Reference: Convex React integration and file storage (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/convex-react`. Read when wiring providers, adding optimistic updates, or uploading files.
|
|
4
|
+
|
|
5
|
+
## Provider wiring (one client, at the root)
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
// src/main.tsx
|
|
9
|
+
import { ClerkProvider, useAuth } from '@clerk/clerk-react'
|
|
10
|
+
import { ConvexProviderWithClerk } from 'convex/react-clerk'
|
|
11
|
+
import { ConvexReactClient } from 'convex/react'
|
|
12
|
+
import React from 'react'
|
|
13
|
+
import ReactDOM from 'react-dom/client'
|
|
14
|
+
import App from './App'
|
|
15
|
+
|
|
16
|
+
const convex = new ConvexReactClient(import.meta.env.VITE_CONVEX_URL)
|
|
17
|
+
|
|
18
|
+
ReactDOM.createRoot(document.getElementById('root')!).render(
|
|
19
|
+
<React.StrictMode>
|
|
20
|
+
<ClerkProvider publishableKey={import.meta.env.VITE_CLERK_PUBLISHABLE_KEY}>
|
|
21
|
+
<ConvexProviderWithClerk client={convex} useAuth={useAuth}>
|
|
22
|
+
<App />
|
|
23
|
+
</ConvexProviderWithClerk>
|
|
24
|
+
</ClerkProvider>
|
|
25
|
+
</React.StrictMode>
|
|
26
|
+
)
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Reactive query + optimistic update
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
// src/components/PostList.tsx
|
|
33
|
+
import { useQuery, useMutation } from 'convex/react'
|
|
34
|
+
import { api } from '../../convex/_generated/api'
|
|
35
|
+
import type { Id } from '../../convex/_generated/dataModel'
|
|
36
|
+
|
|
37
|
+
export function PostList() {
|
|
38
|
+
// Reactive — auto-refreshes when posts change on the server
|
|
39
|
+
const posts = useQuery(api.functions.posts.list, { limit: 20 })
|
|
40
|
+
|
|
41
|
+
const deletePost = useMutation(api.functions.posts.deletePost)
|
|
42
|
+
.withOptimisticUpdate((localStore, { postId }) => {
|
|
43
|
+
const current = localStore.getQuery(api.functions.posts.list, { limit: 20 })
|
|
44
|
+
if (current) {
|
|
45
|
+
localStore.setQuery(
|
|
46
|
+
api.functions.posts.list,
|
|
47
|
+
{ limit: 20 },
|
|
48
|
+
current.filter(p => p._id !== postId),
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
if (!posts) return <p>Loading…</p> // useQuery is undefined while loading
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<ul>
|
|
57
|
+
{posts.map(post => (
|
|
58
|
+
<li key={post._id} className="flex justify-between p-2">
|
|
59
|
+
<span>{post.title}</span>
|
|
60
|
+
<button onClick={() => deletePost({ postId: post._id as Id<'posts'> })}>
|
|
61
|
+
Delete
|
|
62
|
+
</button>
|
|
63
|
+
</li>
|
|
64
|
+
))}
|
|
65
|
+
</ul>
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Optimistic updates revert automatically when the mutation throws — keep the update a pure local-store transform so the revert is clean.
|
|
71
|
+
|
|
72
|
+
## File storage (three-step upload)
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
// convex/functions/files.ts
|
|
76
|
+
import { mutation } from '../_generated/server'
|
|
77
|
+
import { v } from 'convex/values'
|
|
78
|
+
|
|
79
|
+
// Step 1: client asks for an upload URL
|
|
80
|
+
export const generateUploadUrl = mutation({
|
|
81
|
+
handler: async (ctx) => {
|
|
82
|
+
const identity = await ctx.auth.getUserIdentity()
|
|
83
|
+
if (!identity) throw new Error('Unauthorized')
|
|
84
|
+
return ctx.storage.generateUploadUrl()
|
|
85
|
+
},
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
// Step 3: client hands back the storageId; link it to the document
|
|
89
|
+
export const savePostImage = mutation({
|
|
90
|
+
args: { postId: v.id('posts'), storageId: v.id('_storage') },
|
|
91
|
+
handler: async (ctx, { postId, storageId }) => {
|
|
92
|
+
return ctx.db.patch(postId, { imageId: storageId })
|
|
93
|
+
},
|
|
94
|
+
})
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
// Step 2 lives on the client:
|
|
99
|
+
async function uploadImage(file: File, postId: Id<'posts'>) {
|
|
100
|
+
const uploadUrl = await convex.mutation(api.functions.files.generateUploadUrl, {})
|
|
101
|
+
const result = await fetch(uploadUrl, {
|
|
102
|
+
method: 'POST',
|
|
103
|
+
headers: { 'Content-Type': file.type },
|
|
104
|
+
body: file,
|
|
105
|
+
})
|
|
106
|
+
const { storageId } = await result.json()
|
|
107
|
+
await convex.mutation(api.functions.files.savePostImage, { postId, storageId })
|
|
108
|
+
}
|
|
109
|
+
```
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Reference: admin RBAC patterns (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `domain/dashboard-admin-rbac` — centralized permission check, streamed CSV export, automatic audit decorator, and permission-cache invalidation. Evicted from the standing fragment; read when implementing one of these mechanisms.
|
|
4
|
+
|
|
5
|
+
## Centralized permission check (wrong vs right)
|
|
6
|
+
|
|
7
|
+
```javascript
|
|
8
|
+
// ❌ WRONG: magic-string role if/else scattered across the codebase
|
|
9
|
+
if (user.role === 'admin' || user.role === 'super_admin') {
|
|
10
|
+
await deleteUser(id);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// ✅ RIGHT: one permission service, resource:action model, deny-by-default
|
|
14
|
+
await permissionService.authorize(user, 'users:delete'); // throws on deny
|
|
15
|
+
await deleteUser(id);
|
|
16
|
+
|
|
17
|
+
// With row-level conditions (own-only, same organization):
|
|
18
|
+
const allowed = await permissionService.can(user, 'orders:write', { orderId });
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Every admin route runs authn + this authz check in middleware; handlers never re-implement role logic.
|
|
22
|
+
|
|
23
|
+
## Streamed export (wrong vs right)
|
|
24
|
+
|
|
25
|
+
```javascript
|
|
26
|
+
// ❌ WRONG: materializes the whole dataset — OOM at a few hundred k rows
|
|
27
|
+
const users = await db.users.findMany({ where: filters });
|
|
28
|
+
res.json(users);
|
|
29
|
+
|
|
30
|
+
// ✅ RIGHT: stream from a cursor straight to the response
|
|
31
|
+
const cursor = db.users.stream({ where: filters });
|
|
32
|
+
res.setHeader('Content-Type', 'text/csv');
|
|
33
|
+
cursor.pipe(csvTransformer).pipe(res);
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Above the size cap, do not stream inline: enqueue an async export job, return the job id, and deliver the file by link/email when done.
|
|
37
|
+
|
|
38
|
+
## Automatic audit decorator (wrong vs right)
|
|
39
|
+
|
|
40
|
+
```javascript
|
|
41
|
+
// ❌ WRONG: manual audit call after the mutation — forgotten in a
|
|
42
|
+
// meaningful share of endpoints
|
|
43
|
+
await deleteUser(id);
|
|
44
|
+
await auditLog.create({ action: 'users:delete' });
|
|
45
|
+
|
|
46
|
+
// ✅ RIGHT: auditing attached declaratively — impossible to forget
|
|
47
|
+
@Audited('users:delete')
|
|
48
|
+
async deleteUser(id: string, actor: User) { ... }
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
The decorator/middleware records actor, action, resource type/id, before/after state, IP, user agent, and timestamp. The audit table accepts only INSERTs — no UPDATE or DELETE grants, ever.
|
|
52
|
+
|
|
53
|
+
## Permission-cache invalidation
|
|
54
|
+
|
|
55
|
+
```javascript
|
|
56
|
+
// Resolved permissions cached per user with a bounded TTL...
|
|
57
|
+
const key = `perms:${userId}`;
|
|
58
|
+
let perms = await redis.get(key);
|
|
59
|
+
if (!perms) {
|
|
60
|
+
perms = await resolvePermissions(userId); // roles → permissions (+ hierarchy)
|
|
61
|
+
await redis.set(key, JSON.stringify(perms), 'EX', 300);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// ...and invalidated IMMEDIATELY when a role or its permissions change
|
|
65
|
+
async function updateRolePermissions(roleId, changes) {
|
|
66
|
+
await db.roles.update(roleId, changes);
|
|
67
|
+
const userIds = await db.userRoles.userIdsForRole(roleId);
|
|
68
|
+
await redis.del(...userIds.map((id) => `perms:${id}`));
|
|
69
|
+
await auditLog.insert({ action: 'roles:update', resourceId: roleId /* ... */ });
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Never rely on TTL expiry alone for revocation — an admin whose access was removed must lose it on the next request, not minutes later.
|