@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,112 @@
|
|
|
1
|
+
# Reference: Phoenix context and web layer (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/elixir-phoenix`. Read when creating a context, schema, or controller.
|
|
4
|
+
|
|
5
|
+
## Schema + changeset (dumb schema, redacted secrets, explicit JSON allowlist)
|
|
6
|
+
|
|
7
|
+
```elixir
|
|
8
|
+
# lib/my_app/accounts/user.ex
|
|
9
|
+
defmodule MyApp.Accounts.User do
|
|
10
|
+
use Ecto.Schema
|
|
11
|
+
import Ecto.Changeset
|
|
12
|
+
|
|
13
|
+
@derive {Jason.Encoder, only: [:id, :email, :name, :inserted_at]}
|
|
14
|
+
schema "users" do
|
|
15
|
+
field :email, :string
|
|
16
|
+
field :name, :string
|
|
17
|
+
field :hashed_password, :string, redact: true
|
|
18
|
+
timestamps()
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
@required [:email, :name, :password]
|
|
22
|
+
def registration_changeset(user \\ %__MODULE__{}, attrs) do
|
|
23
|
+
user
|
|
24
|
+
|> cast(attrs, @required)
|
|
25
|
+
|> validate_required(@required)
|
|
26
|
+
|> validate_format(:email, ~r/@/, message: "must have @")
|
|
27
|
+
|> validate_length(:name, min: 2, max: 100)
|
|
28
|
+
|> validate_length(:password, min: 8, max: 72)
|
|
29
|
+
|> unique_constraint(:email)
|
|
30
|
+
|> put_password_hash()
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
defp put_password_hash(%Ecto.Changeset{valid?: true, changes: %{password: pw}} = cs),
|
|
34
|
+
do: change(cs, hashed_password: Bcrypt.hash_pwd_salt(pw))
|
|
35
|
+
defp put_password_hash(cs), do: cs
|
|
36
|
+
end
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Context module (the only public API to persistence)
|
|
40
|
+
|
|
41
|
+
```elixir
|
|
42
|
+
# lib/my_app/accounts/accounts.ex
|
|
43
|
+
defmodule MyApp.Accounts do
|
|
44
|
+
import Ecto.Query
|
|
45
|
+
alias MyApp.Repo
|
|
46
|
+
alias MyApp.Accounts.User
|
|
47
|
+
|
|
48
|
+
def get_user(id), do: Repo.get(User, id)
|
|
49
|
+
def get_user!(id), do: Repo.get!(User, id)
|
|
50
|
+
|
|
51
|
+
def create_user(attrs) do
|
|
52
|
+
%User{}
|
|
53
|
+
|> User.registration_changeset(attrs)
|
|
54
|
+
|> Repo.insert()
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def list_users(opts \\ []) do
|
|
58
|
+
limit = Keyword.get(opts, :limit, 20)
|
|
59
|
+
offset = Keyword.get(opts, :offset, 0)
|
|
60
|
+
Repo.all(from u in User, limit: ^limit, offset: ^offset, order_by: [asc: u.inserted_at])
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Thin controller + shared fallback
|
|
66
|
+
|
|
67
|
+
```elixir
|
|
68
|
+
# lib/my_app_web/controllers/user_controller.ex
|
|
69
|
+
defmodule MyAppWeb.UserController do
|
|
70
|
+
use MyAppWeb, :controller
|
|
71
|
+
alias MyApp.Accounts
|
|
72
|
+
action_fallback MyAppWeb.FallbackController
|
|
73
|
+
|
|
74
|
+
def index(conn, _params) do
|
|
75
|
+
users = Accounts.list_users()
|
|
76
|
+
render(conn, :index, users: users)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def create(conn, %{"user" => user_params}) do
|
|
80
|
+
with {:ok, user} <- Accounts.create_user(user_params) do
|
|
81
|
+
conn |> put_status(:created) |> render(:show, user: user)
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def show(conn, %{"id" => id}) do
|
|
86
|
+
with user when not is_nil(user) <- Accounts.get_user(id) do
|
|
87
|
+
render(conn, :show, user: user)
|
|
88
|
+
else
|
|
89
|
+
nil -> {:error, :not_found}
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# lib/my_app_web/controllers/fallback_controller.ex
|
|
95
|
+
defmodule MyAppWeb.FallbackController do
|
|
96
|
+
use MyAppWeb, :controller
|
|
97
|
+
|
|
98
|
+
def call(conn, {:error, %Ecto.Changeset{} = cs}) do
|
|
99
|
+
conn |> put_status(:unprocessable_entity) |> render(:error, changeset: cs)
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def call(conn, {:error, :not_found}) do
|
|
103
|
+
conn |> put_status(:not_found) |> render(:error, message: "Not found")
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def call(conn, {:error, :unauthorized}) do
|
|
107
|
+
conn |> put_status(:unauthorized) |> render(:error, message: "Unauthorized")
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Every `{:error, …}` shape a context can return gets exactly one clause here — controllers never branch on errors themselves.
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Reference: Phoenix channels and GenServer (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/elixir-phoenix`. Read when adding real-time push or a stateful process.
|
|
4
|
+
|
|
5
|
+
## Channel: join, deferred history push, broadcast
|
|
6
|
+
|
|
7
|
+
```elixir
|
|
8
|
+
# lib/my_app_web/channels/room_channel.ex
|
|
9
|
+
defmodule MyAppWeb.RoomChannel do
|
|
10
|
+
use Phoenix.Channel
|
|
11
|
+
alias MyApp.Blog
|
|
12
|
+
|
|
13
|
+
def join("room:" <> room_id, _payload, socket) do
|
|
14
|
+
send(self(), {:after_join, room_id})
|
|
15
|
+
{:ok, assign(socket, :room_id, room_id)}
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def handle_info({:after_join, room_id}, socket) do
|
|
19
|
+
messages = Blog.list_messages(room_id, limit: 50)
|
|
20
|
+
push(socket, "history", %{messages: messages})
|
|
21
|
+
{:noreply, socket}
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def handle_in("new_message", %{"body" => body}, socket) do
|
|
25
|
+
case Blog.create_message(socket.assigns.room_id, body, socket.assigns.current_user) do
|
|
26
|
+
{:ok, msg} ->
|
|
27
|
+
broadcast!(socket, "new_message", %{id: msg.id, body: msg.body})
|
|
28
|
+
{:noreply, socket}
|
|
29
|
+
{:error, _cs} ->
|
|
30
|
+
{:reply, {:error, %{reason: "invalid"}}, socket}
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Notes: `join` stays cheap — expensive loads are deferred via `send(self(), …)` and handled in `handle_info/2`. All persistence goes through the context (`Blog`), never `Repo`.
|
|
37
|
+
|
|
38
|
+
## GenServer: client/server split (stateful counter/cache)
|
|
39
|
+
|
|
40
|
+
```elixir
|
|
41
|
+
defmodule MyApp.StatCounter do
|
|
42
|
+
use GenServer
|
|
43
|
+
|
|
44
|
+
# Client API
|
|
45
|
+
def start_link(opts), do: GenServer.start_link(__MODULE__, %{}, opts)
|
|
46
|
+
def increment(key), do: GenServer.cast(__MODULE__, {:inc, key})
|
|
47
|
+
def get(key), do: GenServer.call(__MODULE__, {:get, key})
|
|
48
|
+
|
|
49
|
+
# Server callbacks
|
|
50
|
+
@impl true
|
|
51
|
+
def init(state), do: {:ok, state}
|
|
52
|
+
|
|
53
|
+
@impl true
|
|
54
|
+
def handle_cast({:inc, key}, state) do
|
|
55
|
+
{:noreply, Map.update(state, key, 1, &(&1 + 1))}
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
@impl true
|
|
59
|
+
def handle_call({:get, key}, _from, state) do
|
|
60
|
+
{:reply, Map.get(state, key, 0), state}
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Start it under the application supervision tree (never unsupervised), name long-lived instances via Registry, and reach for a plain function or supervised Task first — GenServer is only for genuinely stateful processes.
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# Reference: queue and background-job patterns (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `domain/filas-jobs` — idempotency, retry/backoff options, dead-letter handling, graceful shutdown, rate limiting, and enqueue-after-commit. Examples use BullMQ; the patterns port directly to Sidekiq, Celery, or SQS consumers. Evicted from the standing fragment; read when implementing one of these mechanisms.
|
|
4
|
+
|
|
5
|
+
## Idempotency
|
|
6
|
+
|
|
7
|
+
```javascript
|
|
8
|
+
// Pattern 1: atomic lock key — first worker wins, duplicates skip
|
|
9
|
+
async function processEmailJob(job) {
|
|
10
|
+
const lockKey = `email:${job.data.userId}:${job.data.templateId}:${job.id}`;
|
|
11
|
+
const acquired = await redis.set(lockKey, '1', 'NX', 'EX', 3600);
|
|
12
|
+
if (!acquired) return; // another worker already processed this job
|
|
13
|
+
await sendEmail(job.data);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Pattern 2: status check on the target record
|
|
17
|
+
async function processOrderJob(job) {
|
|
18
|
+
const order = await db.orders.findOne(job.data.orderId);
|
|
19
|
+
if (order.status !== 'pending') return; // already processed
|
|
20
|
+
await db.orders.update({ id: order.id, status: 'processing' });
|
|
21
|
+
await fulfillOrder(order);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// ❌ WRONG: re-delivery creates a second invoice
|
|
25
|
+
async function processInvoiceJob(job) {
|
|
26
|
+
await createInvoice(job.data.orderId);
|
|
27
|
+
}
|
|
28
|
+
// ✅ RIGHT: check existence first
|
|
29
|
+
async function processInvoiceJob(job) {
|
|
30
|
+
const exists = await db.invoices.findOne({ orderId: job.data.orderId });
|
|
31
|
+
if (exists) return;
|
|
32
|
+
await createInvoice(job.data.orderId);
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Retry with exponential backoff
|
|
37
|
+
|
|
38
|
+
```javascript
|
|
39
|
+
const queue = new Queue('emails', {
|
|
40
|
+
defaultJobOptions: {
|
|
41
|
+
attempts: 5,
|
|
42
|
+
backoff: { type: 'exponential', delay: 1000 }, // 1s, 2s, 4s, 8s, 16s
|
|
43
|
+
removeOnComplete: { count: 1000 }, // keep recent completions for inspection
|
|
44
|
+
removeOnFail: false, // keep failures for analysis → dead letter
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Dead letter with alerting
|
|
50
|
+
|
|
51
|
+
```javascript
|
|
52
|
+
worker.on('failed', async (job, error) => {
|
|
53
|
+
if (job.attemptsMade >= job.opts.attempts) {
|
|
54
|
+
await db.deadLetterJobs.create({
|
|
55
|
+
jobId: job.id,
|
|
56
|
+
queue: job.queueName,
|
|
57
|
+
payload: job.data,
|
|
58
|
+
lastError: error.message,
|
|
59
|
+
failedAt: new Date(),
|
|
60
|
+
});
|
|
61
|
+
await alertOps('job_dead_lettered', { job: job.id, error: error.message });
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Persist dead letters in the database, not only in the queue backend — they must survive a cache flush.
|
|
67
|
+
|
|
68
|
+
## Graceful shutdown (wrong vs right)
|
|
69
|
+
|
|
70
|
+
```javascript
|
|
71
|
+
// ❌ WRONG: SIGTERM kills the process mid-job — inconsistent state
|
|
72
|
+
process.on('SIGTERM', () => process.exit(0));
|
|
73
|
+
|
|
74
|
+
// ✅ RIGHT: wait for the in-flight job, then close connections
|
|
75
|
+
process.on('SIGTERM', async () => {
|
|
76
|
+
logger.info('Graceful shutdown initiated');
|
|
77
|
+
await worker.close(); // waits for the current job (bounded by its timeout)
|
|
78
|
+
await redis.quit();
|
|
79
|
+
process.exit(0);
|
|
80
|
+
});
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Rate-limited worker (external API)
|
|
84
|
+
|
|
85
|
+
```javascript
|
|
86
|
+
// Use the queue's built-in limiter — e.g. max 100 calls per minute
|
|
87
|
+
const worker = new Worker('api-sync', async (job) => callExternalApi(job.data), {
|
|
88
|
+
connection,
|
|
89
|
+
limiter: { max: 100, duration: 60_000 },
|
|
90
|
+
});
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Enqueue after commit (wrong vs right)
|
|
94
|
+
|
|
95
|
+
```javascript
|
|
96
|
+
// ❌ WRONG: the worker can run BEFORE the commit and not find the order
|
|
97
|
+
await db.transaction(async (trx) => {
|
|
98
|
+
const order = await trx.orders.create({ ... });
|
|
99
|
+
await queue.add('process-order', { orderId: order.id }); // inside the transaction
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
// ✅ RIGHT: enqueue only after the transaction committed
|
|
103
|
+
const order = await db.orders.create({ ... });
|
|
104
|
+
await queue.add('process-order', { orderId: order.id });
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Reference-only payloads (wrong vs right)
|
|
108
|
+
|
|
109
|
+
```javascript
|
|
110
|
+
// ❌ WRONG: hundreds of KB in the payload saturate the queue backend
|
|
111
|
+
await queue.add('send-report', { csvData: largeString });
|
|
112
|
+
|
|
113
|
+
// ✅ RIGHT: store the data, pass its id
|
|
114
|
+
const reportId = await db.reports.create({ data: largeData });
|
|
115
|
+
await queue.add('send-report', { reportId });
|
|
116
|
+
```
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# Reference: dataset preparation, merge/export, quantized inference (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/fine-tuning-huggingface`. Read when preparing data or shipping a trained adapter.
|
|
4
|
+
|
|
5
|
+
## Dataset preparation (quality filters + chat-template formatting)
|
|
6
|
+
|
|
7
|
+
Format prompts through the tokenizer's chat template — never hand-write special-token strings (they differ per model family and rot silently).
|
|
8
|
+
|
|
9
|
+
```python
|
|
10
|
+
# data/prepare.py
|
|
11
|
+
from datasets import Dataset
|
|
12
|
+
from transformers import AutoTokenizer
|
|
13
|
+
|
|
14
|
+
SYSTEM_PROMPT = "You are a helpful assistant specialized in Python code review."
|
|
15
|
+
tokenizer = AutoTokenizer.from_pretrained("org/base-model")
|
|
16
|
+
|
|
17
|
+
def format_instruction(example: dict) -> str:
|
|
18
|
+
messages = [
|
|
19
|
+
{"role": "system", "content": SYSTEM_PROMPT},
|
|
20
|
+
{"role": "user", "content": example["instruction"]},
|
|
21
|
+
{"role": "assistant", "content": example["output"]},
|
|
22
|
+
]
|
|
23
|
+
return tokenizer.apply_chat_template(messages, tokenize=False)
|
|
24
|
+
|
|
25
|
+
def quality_filters(example: dict) -> bool:
|
|
26
|
+
instruction = example.get("instruction", "")
|
|
27
|
+
output = example.get("output", "")
|
|
28
|
+
|
|
29
|
+
# Minimum length checks
|
|
30
|
+
if len(instruction.split()) < 5 or len(output.split()) < 10:
|
|
31
|
+
return False
|
|
32
|
+
|
|
33
|
+
# No truncated outputs
|
|
34
|
+
if output.endswith("...") or output.endswith("etc."):
|
|
35
|
+
return False
|
|
36
|
+
|
|
37
|
+
# Max length: keep sequences under the training context window
|
|
38
|
+
if len(instruction) + len(output) > 6000:
|
|
39
|
+
return False
|
|
40
|
+
|
|
41
|
+
return True
|
|
42
|
+
|
|
43
|
+
def prepare_dataset(raw_data: list[dict]) -> Dataset:
|
|
44
|
+
dataset = Dataset.from_list(raw_data)
|
|
45
|
+
|
|
46
|
+
before = len(dataset)
|
|
47
|
+
dataset = dataset.filter(quality_filters)
|
|
48
|
+
print(f"Filtered: {before - len(dataset)} removed ({len(dataset)} remaining)")
|
|
49
|
+
|
|
50
|
+
dataset = dataset.map(
|
|
51
|
+
lambda x: {"text": format_instruction(x)},
|
|
52
|
+
remove_columns=dataset.column_names,
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
# Seeded split — fixed once, never regenerated mid-project
|
|
56
|
+
return dataset.train_test_split(test_size=0.1, seed=42)
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Merge adapter and export for production
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
# export.py — merge LoRA weights into the base model for serving
|
|
63
|
+
import torch
|
|
64
|
+
from peft import PeftModel
|
|
65
|
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
66
|
+
|
|
67
|
+
def merge_and_export(base_model_id: str, adapter_path: str, output_dir: str):
|
|
68
|
+
model = AutoModelForCausalLM.from_pretrained(
|
|
69
|
+
base_model_id,
|
|
70
|
+
torch_dtype=torch.bfloat16,
|
|
71
|
+
device_map="auto",
|
|
72
|
+
)
|
|
73
|
+
tokenizer = AutoTokenizer.from_pretrained(base_model_id)
|
|
74
|
+
|
|
75
|
+
model = PeftModel.from_pretrained(model, adapter_path)
|
|
76
|
+
model = model.merge_and_unload() # Folds LoRA weights in; removes adapter overhead
|
|
77
|
+
|
|
78
|
+
model.save_pretrained(output_dir, safe_serialization=True)
|
|
79
|
+
tokenizer.save_pretrained(output_dir)
|
|
80
|
+
|
|
81
|
+
def export_to_onnx(model_dir: str, onnx_dir: str):
|
|
82
|
+
from optimum.onnxruntime import ORTModelForCausalLM
|
|
83
|
+
model = ORTModelForCausalLM.from_pretrained(model_dir, export=True)
|
|
84
|
+
model.save_pretrained(onnx_dir)
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Quantized inference (serving without training deps)
|
|
88
|
+
|
|
89
|
+
```python
|
|
90
|
+
from transformers import AutoModelForCausalLM, BitsAndBytesConfig
|
|
91
|
+
import torch
|
|
92
|
+
|
|
93
|
+
bnb_4bit = BitsAndBytesConfig(
|
|
94
|
+
load_in_4bit=True,
|
|
95
|
+
bnb_4bit_compute_dtype=torch.bfloat16,
|
|
96
|
+
bnb_4bit_quant_type="nf4",
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
model = AutoModelForCausalLM.from_pretrained(
|
|
100
|
+
"./merged-model",
|
|
101
|
+
quantization_config=bnb_4bit,
|
|
102
|
+
device_map="auto",
|
|
103
|
+
)
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Evaluation metric selection by task
|
|
107
|
+
|
|
108
|
+
| Task | Primary metric | Secondary |
|
|
109
|
+
|------|----------------|-----------|
|
|
110
|
+
| Classification | F1 / accuracy | Confusion matrix |
|
|
111
|
+
| Summarization | ROUGE-L | BERTScore |
|
|
112
|
+
| Code generation | Pass@k (execution-based) | CodeBLEU |
|
|
113
|
+
| Extraction | Exact match / F1 | Character F1 |
|
|
114
|
+
| Instruction following | LLM-as-judge score | Human eval % |
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# Reference: QLoRA training setup (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/fine-tuning-huggingface`. Read when wiring a training run. Substitute `org/base-model` with the project's base model (which comes from the project config, never hardcoded in shared code).
|
|
4
|
+
|
|
5
|
+
## LoRA config selection
|
|
6
|
+
|
|
7
|
+
```yaml
|
|
8
|
+
# config/lora_config.yaml
|
|
9
|
+
# Target modules vary by architecture — inspect the model and adjust.
|
|
10
|
+
lora_config:
|
|
11
|
+
r: 16 # Rank: 8 = style/format, 16 = structured output, 32+ = domain knowledge
|
|
12
|
+
lora_alpha: 32 # Alpha ≈ 2x rank is a good starting point
|
|
13
|
+
target_modules:
|
|
14
|
+
- q_proj
|
|
15
|
+
- k_proj
|
|
16
|
+
- v_proj
|
|
17
|
+
- o_proj
|
|
18
|
+
- gate_proj
|
|
19
|
+
- up_proj
|
|
20
|
+
- down_proj
|
|
21
|
+
lora_dropout: 0.05
|
|
22
|
+
bias: none
|
|
23
|
+
task_type: CAUSAL_LM
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Training entry point (4-bit quantized base + LoRA + tracked run)
|
|
27
|
+
|
|
28
|
+
```python
|
|
29
|
+
# train.py
|
|
30
|
+
import torch
|
|
31
|
+
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
|
|
32
|
+
from peft import LoraConfig, get_peft_model, prepare_model_for_kbit_training
|
|
33
|
+
from trl import SFTConfig, SFTTrainer
|
|
34
|
+
from datasets import load_dataset
|
|
35
|
+
import wandb
|
|
36
|
+
|
|
37
|
+
BASE_MODEL = "org/base-model" # read from config in real code
|
|
38
|
+
|
|
39
|
+
def train():
|
|
40
|
+
run = wandb.init(
|
|
41
|
+
project="my-llm-finetune",
|
|
42
|
+
name=f"base-model_task_2026-01-01_{wandb.util.generate_id()}",
|
|
43
|
+
config={"model": BASE_MODEL, "task": "instruction-following", "r": 16, "epochs": 3},
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
# QLoRA: 4-bit NF4 quantization with bf16 compute
|
|
47
|
+
bnb_config = BitsAndBytesConfig(
|
|
48
|
+
load_in_4bit=True,
|
|
49
|
+
bnb_4bit_quant_type="nf4",
|
|
50
|
+
bnb_4bit_compute_dtype=torch.bfloat16,
|
|
51
|
+
bnb_4bit_use_double_quant=True,
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
model = AutoModelForCausalLM.from_pretrained(
|
|
55
|
+
BASE_MODEL,
|
|
56
|
+
quantization_config=bnb_config,
|
|
57
|
+
device_map="auto",
|
|
58
|
+
attn_implementation="flash_attention_2",
|
|
59
|
+
)
|
|
60
|
+
model = prepare_model_for_kbit_training(model)
|
|
61
|
+
|
|
62
|
+
tokenizer = AutoTokenizer.from_pretrained(BASE_MODEL)
|
|
63
|
+
if tokenizer.pad_token is None:
|
|
64
|
+
tokenizer.pad_token = tokenizer.eos_token
|
|
65
|
+
tokenizer.padding_side = "right"
|
|
66
|
+
|
|
67
|
+
lora_config = LoraConfig(
|
|
68
|
+
r=16,
|
|
69
|
+
lora_alpha=32,
|
|
70
|
+
target_modules=["q_proj", "k_proj", "v_proj", "o_proj",
|
|
71
|
+
"gate_proj", "up_proj", "down_proj"],
|
|
72
|
+
lora_dropout=0.05,
|
|
73
|
+
bias="none",
|
|
74
|
+
task_type="CAUSAL_LM",
|
|
75
|
+
)
|
|
76
|
+
model = get_peft_model(model, lora_config)
|
|
77
|
+
model.print_trainable_parameters() # Sanity check: ~1-5% of total params
|
|
78
|
+
|
|
79
|
+
dataset = load_dataset("path/to/my_dataset", split="train")
|
|
80
|
+
eval_dataset = load_dataset("path/to/my_dataset", split="validation")
|
|
81
|
+
|
|
82
|
+
training_args = SFTConfig(
|
|
83
|
+
output_dir="./checkpoints",
|
|
84
|
+
num_train_epochs=3,
|
|
85
|
+
per_device_train_batch_size=2,
|
|
86
|
+
gradient_accumulation_steps=8, # Effective batch = 16
|
|
87
|
+
learning_rate=2e-4,
|
|
88
|
+
lr_scheduler_type="cosine",
|
|
89
|
+
warmup_ratio=0.05,
|
|
90
|
+
bf16=True, # Prefer bf16 over fp16 where hardware supports it
|
|
91
|
+
gradient_checkpointing=True,
|
|
92
|
+
optim="paged_adamw_32bit", # Reduced-memory optimizer
|
|
93
|
+
eval_strategy="steps",
|
|
94
|
+
eval_steps=100,
|
|
95
|
+
save_strategy="steps",
|
|
96
|
+
save_steps=100,
|
|
97
|
+
save_total_limit=3,
|
|
98
|
+
load_best_model_at_end=True,
|
|
99
|
+
metric_for_best_model="eval_loss",
|
|
100
|
+
logging_steps=10,
|
|
101
|
+
report_to="wandb",
|
|
102
|
+
group_by_length=True, # Reduces padding waste
|
|
103
|
+
dataloader_num_workers=4,
|
|
104
|
+
dataset_text_field="text", # Column with the formatted prompt
|
|
105
|
+
max_length=2048,
|
|
106
|
+
packing=True, # Packs short sequences together
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
trainer = SFTTrainer(
|
|
110
|
+
model=model,
|
|
111
|
+
args=training_args,
|
|
112
|
+
train_dataset=dataset,
|
|
113
|
+
eval_dataset=eval_dataset,
|
|
114
|
+
processing_class=tokenizer,
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
trainer.train()
|
|
118
|
+
trainer.save_model("./final-adapter") # Saves only the LoRA weights
|
|
119
|
+
run.finish()
|
|
120
|
+
|
|
121
|
+
if __name__ == "__main__":
|
|
122
|
+
train()
|
|
123
|
+
```
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Reference: typed platform channels and golden tests (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/flutter` — one typed Dart API per native capability, explicit error mapping, golden-test harness for shared visuals.
|
|
4
|
+
|
|
5
|
+
## Typed platform-channel wrapper (feature code never sees channel strings)
|
|
6
|
+
|
|
7
|
+
```dart
|
|
8
|
+
// lib/shared/platform/battery_service.dart
|
|
9
|
+
class BatteryService {
|
|
10
|
+
BatteryService([@visibleForTesting MethodChannel? channel])
|
|
11
|
+
: _channel = channel ?? const MethodChannel('com.acme.app/battery');
|
|
12
|
+
|
|
13
|
+
final MethodChannel _channel;
|
|
14
|
+
|
|
15
|
+
/// Returns 0–100. Throws [BatteryUnavailable] — never a raw PlatformException.
|
|
16
|
+
Future<int> batteryLevel() async {
|
|
17
|
+
try {
|
|
18
|
+
final level = await _channel.invokeMethod<int>('getBatteryLevel');
|
|
19
|
+
if (level == null) throw const BatteryUnavailable('null level');
|
|
20
|
+
return level;
|
|
21
|
+
} on PlatformException catch (e) {
|
|
22
|
+
throw BatteryUnavailable(e.message ?? e.code); // explicit error mapping
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
class BatteryUnavailable implements Exception {
|
|
28
|
+
const BatteryUnavailable(this.reason);
|
|
29
|
+
final String reason;
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Kotlin/Swift sides implement the same method names in the same change — a channel with only one side is a broken build for the other platform. Wrapper test: inject a mock channel via `TestDefaultBinaryMessengerBinding` and assert both the success path and the `PlatformException` → domain-error mapping.
|
|
34
|
+
|
|
35
|
+
## Golden tests for shared design-system widgets
|
|
36
|
+
|
|
37
|
+
```dart
|
|
38
|
+
// test/shared/ui/order_tile_golden_test.dart
|
|
39
|
+
void main() {
|
|
40
|
+
testWidgets('OrderTile renders the paid state', (tester) async {
|
|
41
|
+
await tester.pumpWidget(
|
|
42
|
+
MaterialApp(
|
|
43
|
+
theme: AppTheme.light, // the real app theme
|
|
44
|
+
home: Scaffold(
|
|
45
|
+
body: Center(
|
|
46
|
+
child: OrderTile(order: Order.fixture(status: OrderStatus.paid)),
|
|
47
|
+
),
|
|
48
|
+
),
|
|
49
|
+
),
|
|
50
|
+
);
|
|
51
|
+
await expectLater(
|
|
52
|
+
find.byType(OrderTile),
|
|
53
|
+
matchesGoldenFile('goldens/order_tile_paid.png'),
|
|
54
|
+
);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
flutter test # goldens compared on every run
|
|
61
|
+
flutter test --update-goldens test/shared/ui/ # ONLY for an intended visual change
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Golden discipline:
|
|
65
|
+
|
|
66
|
+
- One golden per meaningful visual state (default, loading, error, RTL/dark when supported) — not per pixel-tweak.
|
|
67
|
+
- `--update-goldens` runs scoped to the changed component; the regenerated images are part of the PR and get reviewed like code.
|
|
68
|
+
- Font/rendering differences across machines are solved by the repo's golden setup (CI-generated goldens or a pinned test font) — never by loosening the comparison.
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# Reference: Flutter state and widgets (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/flutter` — feature layout, state holder, async screen with the three states. The state holder below uses `ChangeNotifier` for neutrality; **use whatever pattern the repo already uses** — the shape (logic outside widgets, exposed immutable state, intents as methods) is what matters.
|
|
4
|
+
|
|
5
|
+
## Feature-first layout
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
lib/
|
|
9
|
+
├── app/ # router, theme, dependency wiring
|
|
10
|
+
├── shared/ui/ # design-system widgets (golden-tested)
|
|
11
|
+
└── features/
|
|
12
|
+
└── orders/
|
|
13
|
+
├── data/ # repository, DTOs, mappers
|
|
14
|
+
├── state/ # state holder(s) — no Flutter imports beyond foundation
|
|
15
|
+
└── ui/ # screens + feature widgets
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## State holder — logic testable without a widget tree
|
|
19
|
+
|
|
20
|
+
```dart
|
|
21
|
+
// lib/features/orders/state/orders_state.dart
|
|
22
|
+
sealed class OrdersState {
|
|
23
|
+
const OrdersState();
|
|
24
|
+
}
|
|
25
|
+
class OrdersLoading extends OrdersState { const OrdersLoading(); }
|
|
26
|
+
class OrdersError extends OrdersState { const OrdersError(this.message); final String message; }
|
|
27
|
+
class OrdersLoaded extends OrdersState { const OrdersLoaded(this.orders); final List<Order> orders; }
|
|
28
|
+
|
|
29
|
+
class OrdersController extends ChangeNotifier {
|
|
30
|
+
OrdersController(this._repository);
|
|
31
|
+
final OrdersRepository _repository;
|
|
32
|
+
|
|
33
|
+
OrdersState _state = const OrdersLoading();
|
|
34
|
+
OrdersState get state => _state;
|
|
35
|
+
|
|
36
|
+
Future<void> load() async {
|
|
37
|
+
_emit(const OrdersLoading());
|
|
38
|
+
try {
|
|
39
|
+
final orders = await _repository.fetchOrders();
|
|
40
|
+
_emit(OrdersLoaded(orders));
|
|
41
|
+
} on OrdersException catch (e) {
|
|
42
|
+
_emit(OrdersError(e.message));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
void _emit(OrdersState next) {
|
|
47
|
+
_state = next;
|
|
48
|
+
notifyListeners();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Async screen — loading, error, empty, data. Always.
|
|
54
|
+
|
|
55
|
+
```dart
|
|
56
|
+
// lib/features/orders/ui/orders_screen.dart
|
|
57
|
+
class OrdersScreen extends StatelessWidget {
|
|
58
|
+
const OrdersScreen({super.key, required this.controller});
|
|
59
|
+
final OrdersController controller;
|
|
60
|
+
|
|
61
|
+
@override
|
|
62
|
+
Widget build(BuildContext context) {
|
|
63
|
+
return ListenableBuilder(
|
|
64
|
+
listenable: controller,
|
|
65
|
+
builder: (context, _) => switch (controller.state) {
|
|
66
|
+
OrdersLoading() => const Center(child: CircularProgressIndicator()),
|
|
67
|
+
OrdersError(:final message) => ErrorRetryView(
|
|
68
|
+
message: message, // shared design-system widget
|
|
69
|
+
onRetry: controller.load,
|
|
70
|
+
),
|
|
71
|
+
OrdersLoaded(:final orders) when orders.isEmpty =>
|
|
72
|
+
EmptyView(text: context.l10n.ordersEmpty),
|
|
73
|
+
OrdersLoaded(:final orders) => ListView.builder(
|
|
74
|
+
itemCount: orders.length,
|
|
75
|
+
itemBuilder: (context, i) => OrderTile(order: orders[i]),
|
|
76
|
+
),
|
|
77
|
+
},
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Context across await — guard it
|
|
84
|
+
|
|
85
|
+
```dart
|
|
86
|
+
Future<void> _submit(BuildContext context) async {
|
|
87
|
+
final result = await controller.submit();
|
|
88
|
+
if (!context.mounted) return; // the screen may be gone
|
|
89
|
+
ScaffoldMessenger.of(context).showSnackBar(
|
|
90
|
+
SnackBar(content: Text(result.message)),
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Small-widget rule of thumb: if `build` needs a comment to explain a region, that region is a widget.
|