@polymorphism-tech/morph-spec 4.12.0 → 4.13.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/README.md +21 -29
- package/bin/morph-spec.js +41 -24
- package/bin/task-manager.js +962 -1341
- package/bin/validate.js +1 -1
- package/claude-plugin.json +1 -1
- package/docs/CHEATSHEET.md +10 -11
- package/docs/QUICKSTART.md +15 -15
- package/framework/CLAUDE.md +5 -2
- package/framework/agents/README.md +3 -4
- package/framework/agents/ai-agents/ai-system-architect.md +6 -10
- package/framework/agents/architecture/seo-growth-hacker.md +166 -326
- package/framework/agents/architecture/standards-architect.md +21 -31
- package/framework/agents/backend/dotnet-senior.md +160 -86
- package/framework/agents/backend/ef-modeler.md +2 -6
- package/framework/agents/backend/hangfire-orchestrator.md +8 -9
- package/framework/agents/backend/ms-agent-expert.md +1 -1
- package/framework/agents/frontend/nextjs-expert.md +198 -133
- package/framework/agents/frontend/ui-ux-designer.md +226 -267
- package/framework/agents/infrastructure/infra-architect.md +191 -27
- package/framework/agents/integrations/clerk-auth.md +19 -26
- package/framework/agents/integrations/hangfire-integration.md +1 -4
- package/framework/agents.json +215 -1453
- package/framework/commands/morph-apply.md +4 -4
- package/framework/commands/morph-preflight.md +4 -26
- package/framework/commands/morph-proposal.md +19 -19
- package/framework/commands/morph-status.md +2 -2
- package/framework/commands/morph-troubleshoot.md +6 -13
- package/framework/hooks/README.md +1 -6
- package/framework/hooks/claude-code/post-tool-use/validator-feedback.js +4 -6
- package/framework/hooks/claude-code/pre-compact/save-morph-context.js +12 -7
- package/framework/hooks/claude-code/pre-tool-use/enforce-phase-writes.js +2 -2
- package/framework/hooks/claude-code/pre-tool-use/protect-spec-files.js +2 -2
- package/framework/hooks/claude-code/pre-tool-use/task-tracking-guard.js +5 -10
- package/framework/hooks/claude-code/session-start/inject-morph-context.js +63 -30
- package/framework/hooks/claude-code/session-start/resume-context.js +77 -0
- package/framework/hooks/claude-code/statusline.py +4 -5
- package/framework/hooks/claude-code/stop/validate-completion.js +4 -4
- package/framework/hooks/claude-code/user-prompt/enrich-prompt.js +8 -8
- package/framework/hooks/shared/compact-restore.js +28 -5
- package/framework/hooks/shared/phase-utils.js +4 -8
- package/framework/hooks/shared/state-reader.js +34 -3
- package/framework/phases.json +7 -45
- package/framework/rules/ai-agents-standards.md +15 -0
- package/framework/rules/asaas-standards.md +13 -0
- package/framework/rules/clerk-standards.md +13 -0
- package/framework/rules/csharp-standards.md +8 -4
- package/framework/rules/data-standards.md +18 -0
- package/framework/rules/dotnet-templates.md +87 -0
- package/framework/rules/frontend-standards.md +13 -13
- package/framework/rules/hangfire-standards.md +13 -0
- package/framework/rules/infrastructure-standards.md +27 -16
- package/framework/rules/morph-workflow.md +73 -13
- package/framework/rules/nextjs-standards.md +1 -0
- package/framework/rules/nextjs-templates.md +40 -0
- package/framework/rules/resend-standards.md +12 -0
- package/framework/rules/supabase-standards.md +29 -0
- package/framework/skills/README.md +6 -8
- package/framework/skills/level-0-meta/mcp-registry.json +21 -99
- package/framework/{standards/ai-agents/team-orchestration.md → skills/level-0-meta/morph-agent-teams/SKILL.md} +472 -479
- package/framework/skills/level-0-meta/morph-brainstorming/SKILL.md +28 -1
- package/framework/skills/level-0-meta/morph-checklist/SKILL.md +2 -2
- package/framework/skills/level-0-meta/morph-code-review/SKILL.md +1 -5
- package/framework/skills/level-0-meta/morph-code-review/scripts/scan-csharp.mjs +1 -1
- package/framework/skills/level-0-meta/morph-frontend-review/SKILL.md +23 -41
- package/framework/skills/level-0-meta/morph-init/SKILL.md +18 -14
- package/framework/skills/level-0-meta/morph-parallel-dispatch/SKILL.md +225 -0
- package/framework/skills/level-0-meta/morph-post-implementation/SKILL.md +20 -0
- package/framework/skills/level-0-meta/morph-tool-usage-guide/SKILL.md +4 -8
- package/framework/skills/level-0-meta/morph-tool-usage-guide/references/tools-per-phase.md +15 -59
- package/framework/skills/level-0-meta/morph-verification-before-completion/SKILL.md +7 -19
- package/framework/skills/level-0-meta/morph-verification-before-completion/scripts/check-phase-outputs.mjs +8 -8
- package/framework/skills/level-1-workflows/README.md +1 -1
- package/framework/skills/level-1-workflows/morph-phase-codebase-analysis/SKILL.md +49 -50
- package/framework/skills/level-1-workflows/morph-phase-design/SKILL.md +58 -124
- package/framework/skills/level-1-workflows/morph-phase-design/references/architecture-analysis-guide.md +5 -50
- package/framework/skills/level-1-workflows/morph-phase-design/references/spec-example.md +1 -1
- package/framework/skills/level-1-workflows/morph-phase-implement/SKILL.md +127 -159
- package/framework/skills/level-1-workflows/morph-phase-implement/prompts/implementer-prompt.md +4 -3
- package/framework/skills/level-1-workflows/morph-phase-implement/prompts/spec-reviewer-prompt.md +2 -2
- package/framework/skills/level-1-workflows/morph-phase-implement/references/recap-example.md +1 -1
- package/framework/skills/level-1-workflows/morph-phase-plan/SKILL.md +17 -13
- package/framework/skills/level-1-workflows/morph-phase-tasks/SKILL.md +22 -40
- package/framework/skills/level-1-workflows/morph-phase-tasks/references/task-planning-patterns.md +0 -2
- package/framework/skills/level-1-workflows/morph-phase-tasks/references/tasks-example.md +5 -5
- package/framework/skills/level-1-workflows/morph-phase-uiux/SKILL.md +57 -77
- package/framework/skills/level-1-workflows/morph-scope-escalation/SKILL.md +1 -1
- package/framework/squad-templates/backend-only.json +6 -6
- package/framework/squad-templates/frontend-only.json +17 -8
- package/framework/squad-templates/full-stack.json +29 -24
- package/framework/standards/STANDARDS.json +1021 -2369
- package/framework/standards/backend/dotnet/fluent-validation-vsa.md +200 -0
- package/framework/standards/backend/dotnet/result-pattern.md +213 -0
- package/framework/standards/backend/dotnet/scalar-ui.md +172 -0
- package/framework/standards/backend/dotnet/scrutor.md +158 -0
- package/framework/standards/backend/dotnet/vsa-handler-patterns.md +274 -0
- package/framework/standards/frontend/nextjs/motion-patterns.md +1 -1
- package/framework/standards/infrastructure/supabase/mcp-setup.md +83 -193
- package/framework/standards/integration/mcp/mcp-tools.md +91 -77
- package/framework/templates/IDE-SNIPPETS.md +2 -6
- package/framework/templates/README.md +709 -814
- package/framework/templates/REGISTRY.json +223 -762
- package/framework/templates/code/dotnet/abstractions/api-endpoint.cs +7 -0
- package/framework/templates/code/dotnet/abstractions/error.cs +60 -0
- package/framework/templates/code/dotnet/abstractions/handler.cs +12 -0
- package/framework/templates/code/dotnet/abstractions/result.cs +74 -0
- package/framework/templates/code/dotnet/backend/repository.cs +148 -141
- package/framework/templates/code/dotnet/constants/api-tags.cs +6 -0
- package/framework/templates/code/dotnet/exceptions/exception-handler.cs +32 -0
- package/framework/templates/code/dotnet/extensions/database-extensions.cs +20 -0
- package/framework/templates/code/dotnet/extensions/handler-registration.cs +38 -0
- package/framework/templates/code/dotnet/extensions/health-checks.cs +24 -0
- package/framework/templates/code/dotnet/extensions/map-endpoints.cs +35 -0
- package/framework/templates/code/dotnet/extensions/result-extensions.cs +29 -0
- package/framework/templates/code/dotnet/feature/endpoint.cs.hbs +21 -0
- package/framework/templates/code/dotnet/feature/entity.cs.hbs +8 -0
- package/framework/templates/code/dotnet/feature/errors.cs.hbs +8 -0
- package/framework/templates/code/dotnet/feature/handler.cs.hbs +24 -0
- package/framework/templates/code/dotnet/feature/request.cs.hbs +4 -0
- package/framework/templates/code/dotnet/feature/response.cs.hbs +4 -0
- package/framework/templates/code/dotnet/feature/validator.cs.hbs +15 -0
- package/framework/templates/code/dotnet/jobs/job.cs +21 -17
- package/framework/templates/code/dotnet/pipelines/logging-decorator.cs +31 -0
- package/framework/templates/code/dotnet/pipelines/validation-decorator.cs +97 -0
- package/framework/templates/code/dotnet/test.cs +192 -106
- package/framework/templates/context/ARCHITECTURE.md +89 -0
- package/framework/templates/context/CONTEXT-FEATURE.md +2 -2
- package/framework/templates/context/CONTEXT.md +180 -181
- package/framework/templates/context/design-system.md +1 -5
- package/framework/templates/docs/onboarding.md +2 -3
- package/framework/templates/docs/proposal.md +171 -182
- package/framework/templates/docs/spec.md +1 -3
- package/framework/templates/docs/ui-components.md +0 -72
- package/framework/templates/examples/design-system-examples.md +4 -4
- package/framework/templates/feature/decisions.md +0 -66
- package/framework/templates/feature/recap.md +1 -2
- package/framework/templates/infrastructure/github/README.md +56 -593
- package/framework/templates/integrations/clerk-config.cs +0 -41
- package/framework/templates/meta-prompts/parallel-workers/parallel-worker.md +2 -2
- package/framework/templates/meta-prompts/squad-leaders/backend-squad.md +1 -2
- package/framework/templates/meta-prompts/squad-leaders/frontend-squad.md +83 -126
- package/framework/templates/meta-prompts/validators/pre-commit-validator.md +2 -2
- package/framework/templates/project/validate.js +2 -4
- package/framework/templates/ui/design-system.css +1 -1
- package/framework/workflows/README.md +8 -8
- package/framework/workflows/configs/fast-track.json +51 -0
- package/framework/workflows/configs/full.json +68 -0
- package/framework/workflows/configs/standard.json +7 -3
- package/framework/workflows/docs/STORY-DRIVEN-DEVELOPMENT.md +1 -1
- package/framework/workflows/docs/enforcement-pipeline.md +18 -19
- package/framework/workflows/docs/full-morph.md +69 -76
- package/framework/workflows/docs/standard.md +49 -44
- package/framework/workflows/docs/ui-refresh.md +1 -1
- package/package.json +3 -3
- package/src/commands/agents/dispatch-agents.js +55 -116
- package/src/commands/context/context-refresh.js +79 -0
- package/src/commands/phase/phase-reset.js +1 -1
- package/src/commands/project/doctor.js +10 -32
- package/src/commands/project/init.js +12 -0
- package/src/commands/project/status.js +6 -12
- package/src/commands/scaffold/scaffold.js +131 -0
- package/src/commands/scope/escalate.js +1 -1
- package/src/commands/state/advance-phase.js +15 -29
- package/src/commands/state/state.js +20 -5
- package/src/commands/tasks/task.js +0 -30
- package/src/commands/validation/validate-feature.js +3 -10
- package/src/core/paths/output-schema.js +12 -13
- package/src/core/state/phase-state-machine.js +211 -217
- package/src/core/state/state-manager.js +9 -9
- package/src/lib/agents/agents-manager.js +2 -2
- package/src/lib/agents/output-collector.js +1 -2
- package/src/lib/detectors/design-system-detector.js +4 -4
- package/src/lib/detectors/index.js +1 -11
- package/src/lib/generators/architecture-scanner.js +640 -0
- package/src/lib/generators/context-generator.js +3 -3
- package/src/lib/generators/design-system-generator.js +508 -587
- package/src/lib/generators/index.js +12 -10
- package/src/lib/generators/metadata-extractor.js +386 -387
- package/src/lib/generators/recap-generator.js +4 -4
- package/src/lib/generators/scaffold-generator.js +317 -0
- package/src/lib/generators/settings-generator.js +0 -1
- package/src/lib/phase-chain/phase-validator.js +64 -42
- package/src/lib/stack/stack-profile.js +2 -2
- package/src/lib/standards/digest-builder.js +72 -285
- package/src/lib/tasks/task-parser.js +11 -5
- package/src/lib/validators/architecture/architecture-validator.js +259 -387
- package/src/lib/validators/content/content-validator.js +287 -287
- package/src/lib/validators/css/css-validator.js +340 -352
- package/src/lib/validators/packages/package-validator.js +347 -360
- package/src/lib/validators/shared/issue-counter.js +14 -18
- package/src/lib/validators/validation-runner.js +3 -19
- package/src/scripts/setup-infra.js +1 -1
- package/src/utils/agents-installer.js +24 -3
- package/src/utils/file-copier.js +1 -0
- package/src/utils/hooks-installer.js +11 -19
- package/src/utils/skills-installer.js +178 -178
- package/framework/agents/architecture/prompt-engineer.md +0 -195
- package/framework/agents/backend/api-designer.md +0 -106
- package/framework/agents/frontend/blazor-builder.md +0 -229
- package/framework/agents/frontend/nextjs-ui-specialist.md +0 -218
- package/framework/agents/infrastructure/azure-architect.md +0 -150
- package/framework/agents/infrastructure/azure-deploy-specialist.md +0 -707
- package/framework/agents/infrastructure/bicep-architect.md +0 -132
- package/framework/agents/infrastructure/container-specialist.md +0 -137
- package/framework/agents/infrastructure/devops-engineer.md +0 -126
- package/framework/agents/integrations/azure-identity.md +0 -148
- package/framework/agents/quality/code-analyzer.md +0 -239
- package/framework/agents/quality/testing-specialist.md +0 -130
- package/framework/hooks/claude-code/notification/approval-reminder.js +0 -57
- package/framework/hooks/claude-code/post-tool-use/context-refresh.js +0 -109
- package/framework/hooks/claude-code/post-tool-use/skill-reminder.js +0 -78
- package/framework/index/troubleshooting-index.json +0 -184
- package/framework/rules/testing-standards.md +0 -14
- package/framework/skills/level-0-meta/morph-replicate/SKILL.md +0 -230
- package/framework/skills/level-0-meta/morph-replicate/references/blazor-html-mapping.md +0 -70
- package/framework/skills/level-1-workflows/morph-phase-clarify/SKILL.md +0 -256
- package/framework/skills/level-1-workflows/morph-phase-clarify/references/clarifications-example.md +0 -117
- package/framework/skills/level-1-workflows/morph-phase-setup/SKILL.md +0 -269
- package/framework/standards/ai-agents/blazor-ui.md +0 -364
- package/framework/standards/architecture/ddd/aggregates.md +0 -120
- package/framework/standards/architecture/ddd/bounded-contexts.md +0 -105
- package/framework/standards/architecture/ddd/complexity-levels.md +0 -108
- package/framework/standards/architecture/ddd/entities.md +0 -99
- package/framework/standards/architecture/ddd/ubiquitous-language.md +0 -58
- package/framework/standards/architecture/ddd/value-objects.md +0 -124
- package/framework/standards/backend/api/minimal-api.md +0 -494
- package/framework/standards/backend/api/rest.md +0 -492
- package/framework/standards/backend/authentication/passkeys.md +0 -428
- package/framework/standards/backend/database/ef-core.md +0 -199
- package/framework/standards/backend/database/migrations.md +0 -393
- package/framework/standards/backend/database/repository-patterns.md +0 -528
- package/framework/standards/backend/dotnet/async.md +0 -366
- package/framework/standards/backend/dotnet/core.md +0 -117
- package/framework/standards/backend/dotnet/di.md +0 -439
- package/framework/standards/backend/dotnet/program-cs-checklist.md +0 -92
- package/framework/standards/context/analytics.md +0 -96
- package/framework/standards/context/bundles.md +0 -110
- package/framework/standards/context/priming.md +0 -78
- package/framework/standards/core/architecture.md +0 -185
- package/framework/standards/core/coding.md +0 -214
- package/framework/standards/core/git-branching-strategy.md +0 -403
- package/framework/standards/core/git.md +0 -185
- package/framework/standards/core/testing.md +0 -295
- package/framework/standards/data/nosql/blob-storage.md +0 -102
- package/framework/standards/data/vector-search/azure-ai-search.md +0 -121
- package/framework/standards/frontend/blazor/design-checklist.md +0 -222
- package/framework/standards/frontend/blazor/fluent-ui-setup.md +0 -595
- package/framework/standards/frontend/blazor/fluent-ui.md +0 -137
- package/framework/standards/frontend/blazor/html-conversion.md +0 -184
- package/framework/standards/frontend/blazor/lifecycle.md +0 -195
- package/framework/standards/frontend/blazor/pitfalls.md +0 -198
- package/framework/standards/frontend/blazor/state.md +0 -191
- package/framework/standards/frontend/design-system/aesthetic-direction.md +0 -266
- package/framework/standards/frontend/design-system/design-trends.md +0 -171
- package/framework/standards/infrastructure/azure/azure.md +0 -624
- package/framework/standards/infrastructure/azure/bicep/bicep-patterns.md +0 -422
- package/framework/standards/infrastructure/azure/devops/azure-devops-setup.md +0 -516
- package/framework/standards/infrastructure/azure/devops/local-development.md +0 -520
- package/framework/standards/infrastructure/azure/services/functions.md +0 -486
- package/framework/standards/infrastructure/azure/services/service-bus.md +0 -459
- package/framework/standards/infrastructure/azure/services/storage.md +0 -407
- package/framework/standards/infrastructure/vercel/vercel-database.md +0 -106
- package/framework/standards/integration/api/graphql.md +0 -91
- package/framework/standards/integration/api/grpc.md +0 -114
- package/framework/standards/integration/api/rest-design.md +0 -95
- package/framework/standards/integration/event-driven/cqrs.md +0 -101
- package/framework/standards/integration/event-driven/event-sourcing.md +0 -124
- package/framework/standards/integration/event-driven/service-bus.md +0 -95
- package/framework/standards/observability/logging.md +0 -131
- package/framework/standards/observability/metrics.md +0 -121
- package/framework/standards/observability/monitoring.md +0 -114
- package/framework/standards/observability/tracing.md +0 -132
- package/framework/standards/workflows/parallel-execution.md +0 -112
- package/framework/standards/workflows/thread-management.md +0 -113
- package/framework/templates/code/dotnet/backend/service.cs +0 -139
- package/framework/templates/code/dotnet/contracts/Commands.cs +0 -74
- package/framework/templates/code/dotnet/contracts/Entities.cs +0 -25
- package/framework/templates/code/dotnet/contracts/Queries.cs +0 -74
- package/framework/templates/code/dotnet/contracts/api-contracts.cs +0 -173
- package/framework/templates/code/dotnet/contracts/contracts-level1.cs +0 -69
- package/framework/templates/code/dotnet/contracts/contracts-level2.cs +0 -86
- package/framework/templates/code/dotnet/contracts/contracts-level3.cs +0 -41
- package/framework/templates/code/dotnet/frontend/component.razor +0 -239
- package/framework/templates/infrastructure/azure/Dockerfile.example +0 -82
- package/framework/templates/infrastructure/azure/README.md +0 -286
- package/framework/templates/infrastructure/azure/app-insights.bicep +0 -63
- package/framework/templates/infrastructure/azure/app-service.bicep +0 -164
- package/framework/templates/infrastructure/azure/container-app-env.bicep +0 -49
- package/framework/templates/infrastructure/azure/container-app.bicep +0 -156
- package/framework/templates/infrastructure/azure/deploy-checklist.md +0 -426
- package/framework/templates/infrastructure/azure/deploy.ps1 +0 -229
- package/framework/templates/infrastructure/azure/deploy.sh +0 -208
- package/framework/templates/infrastructure/azure/key-vault.bicep +0 -91
- package/framework/templates/infrastructure/azure/main.bicep +0 -189
- package/framework/templates/infrastructure/azure/parameters.dev.json +0 -29
- package/framework/templates/infrastructure/azure/parameters.prod.json +0 -29
- package/framework/templates/infrastructure/azure/parameters.staging.json +0 -29
- package/framework/templates/infrastructure/azure/sql-database.bicep +0 -103
- package/framework/templates/infrastructure/azure/storage.bicep +0 -106
- package/framework/templates/infrastructure/github/actions/azure-auth/action.yml.hbs +0 -22
- package/framework/templates/infrastructure/github/workflows/deploy-azure-app-service.yml.hbs +0 -61
- package/framework/templates/integrations/azure-identity-config.cs +0 -288
- package/framework/templates/project-structure/dotnet-ddd.md +0 -70
- package/framework/templates/saas/subscription.cs +0 -347
- package/framework/templates/saas/tenant.cs +0 -338
- package/framework/templates/ui/FluentDesignTheme.cs +0 -149
- package/framework/templates/ui/MudTheme.cs +0 -281
- package/framework/workflows/configs/nodejs-cli.json +0 -40
- package/src/commands/standards/context-budget.js +0 -89
- package/src/lib/standards/index.js +0 -7
- package/src/lib/standards/standards-context-injector.js +0 -302
- package/src/lib/validators/blazor/blazor-concurrency-analyzer.js +0 -316
- package/src/lib/validators/blazor/blazor-state-validator.js +0 -279
- package/src/lib/validators/blazor/blazor-validator.js +0 -369
- package/src/lib/validators/blazor/index.js +0 -9
|
@@ -1,302 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Standards Context Injector
|
|
3
|
-
*
|
|
4
|
-
* Automatically loads and surfaces relevant standards content for agents.
|
|
5
|
-
* Resolution order: project overrides → framework standards → content standards
|
|
6
|
-
*
|
|
7
|
-
* @module standards-context-injector
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { readFileSync, existsSync } from 'fs';
|
|
11
|
-
import { join } from 'path';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Agent → Standards mapping
|
|
15
|
-
* Maps each agent ID to relevant standard files (hierarchical paths without .md extension)
|
|
16
|
-
*/
|
|
17
|
-
const AGENT_STANDARDS_MAP = {
|
|
18
|
-
// Tier 1: Orchestrators
|
|
19
|
-
'standards-architect': [
|
|
20
|
-
'core/architecture',
|
|
21
|
-
'core/coding',
|
|
22
|
-
'infrastructure/azure/azure', // Stack-specific (kept in .morph/framework/standards/)
|
|
23
|
-
'backend/dotnet/core',
|
|
24
|
-
'backend/dotnet/program-cs-checklist'
|
|
25
|
-
],
|
|
26
|
-
'ai-system-architect': [
|
|
27
|
-
'ai-agents/setup',
|
|
28
|
-
'ai-agents/workflows',
|
|
29
|
-
'ai-agents/production',
|
|
30
|
-
'ai-agents/blazor-ui',
|
|
31
|
-
'core/architecture',
|
|
32
|
-
'core/coding'
|
|
33
|
-
],
|
|
34
|
-
'popm-advisor': [], // No technical standards
|
|
35
|
-
|
|
36
|
-
// Tier 2: Domain Leaders
|
|
37
|
-
'dotnet-senior': [
|
|
38
|
-
'core/coding',
|
|
39
|
-
'core/architecture',
|
|
40
|
-
'core/testing',
|
|
41
|
-
'backend/dotnet/core',
|
|
42
|
-
'backend/dotnet/async',
|
|
43
|
-
'backend/dotnet/di',
|
|
44
|
-
'backend/database/ef-core',
|
|
45
|
-
'backend/api/rest'
|
|
46
|
-
],
|
|
47
|
-
'infra-architect': [
|
|
48
|
-
'core/architecture',
|
|
49
|
-
'core/coding'
|
|
50
|
-
],
|
|
51
|
-
// Tier 3: Specialists - Infrastructure Squad
|
|
52
|
-
'azure-architect': [
|
|
53
|
-
'infrastructure/azure/azure', // Stack-specific
|
|
54
|
-
'core/architecture',
|
|
55
|
-
'backend/dotnet/core'
|
|
56
|
-
],
|
|
57
|
-
'ui-designer': [
|
|
58
|
-
'frontend/design-system/naming',
|
|
59
|
-
'frontend/design-system/animations',
|
|
60
|
-
'frontend/blazor/fluent-ui-setup', // Stack-specific
|
|
61
|
-
'frontend/blazor/fluent-ui'
|
|
62
|
-
],
|
|
63
|
-
|
|
64
|
-
// Tier 3: Specialists - Backend Squad
|
|
65
|
-
'ef-modeler': [
|
|
66
|
-
'backend/database/ef-core',
|
|
67
|
-
'backend/database/migrations',
|
|
68
|
-
'backend/database/repository-patterns',
|
|
69
|
-
'core/architecture',
|
|
70
|
-
'core/coding',
|
|
71
|
-
'backend/dotnet/core'
|
|
72
|
-
],
|
|
73
|
-
'event-architect': [
|
|
74
|
-
'core/architecture',
|
|
75
|
-
'core/coding',
|
|
76
|
-
'backend/dotnet/core'
|
|
77
|
-
],
|
|
78
|
-
'api-designer': [
|
|
79
|
-
'backend/api/rest',
|
|
80
|
-
'backend/api/validation',
|
|
81
|
-
'core/architecture',
|
|
82
|
-
'core/coding',
|
|
83
|
-
'backend/dotnet/core'
|
|
84
|
-
],
|
|
85
|
-
'nosql-cache-expert': [
|
|
86
|
-
'core/architecture',
|
|
87
|
-
'core/coding'
|
|
88
|
-
],
|
|
89
|
-
'ddd-expert': [
|
|
90
|
-
'core/architecture',
|
|
91
|
-
'core/coding'
|
|
92
|
-
],
|
|
93
|
-
'hangfire-orchestrator': [
|
|
94
|
-
'core/architecture',
|
|
95
|
-
'core/coding',
|
|
96
|
-
'frontend/blazor/lifecycle', // Background jobs + Blazor lifecycle
|
|
97
|
-
'backend/database/repository-patterns', // Factory pattern
|
|
98
|
-
'backend/dotnet/core'
|
|
99
|
-
],
|
|
100
|
-
'ms-agent-expert': [
|
|
101
|
-
'ai-agents/setup',
|
|
102
|
-
'ai-agents/workflows',
|
|
103
|
-
'ai-agents/production',
|
|
104
|
-
'ai-agents/blazor-ui',
|
|
105
|
-
'core/coding',
|
|
106
|
-
'core/architecture'
|
|
107
|
-
],
|
|
108
|
-
'asaas-financial': [
|
|
109
|
-
'core/coding',
|
|
110
|
-
'core/architecture'
|
|
111
|
-
],
|
|
112
|
-
'clerk-auth': [
|
|
113
|
-
'core/coding',
|
|
114
|
-
'core/architecture',
|
|
115
|
-
'backend/authentication/passkeys' // Stack-specific
|
|
116
|
-
],
|
|
117
|
-
'resend-email': [
|
|
118
|
-
'core/coding',
|
|
119
|
-
'core/architecture'
|
|
120
|
-
],
|
|
121
|
-
|
|
122
|
-
// Tier 3: Specialists - Frontend Squad
|
|
123
|
-
'blazor-builder': [
|
|
124
|
-
'frontend/blazor/lifecycle',
|
|
125
|
-
'frontend/blazor/state',
|
|
126
|
-
'frontend/blazor/pitfalls',
|
|
127
|
-
'frontend/blazor/html-conversion',
|
|
128
|
-
'frontend/blazor/fluent-ui',
|
|
129
|
-
'frontend/design-system/naming',
|
|
130
|
-
'frontend/design-system/animations',
|
|
131
|
-
'backend/database/ef-core', // DbContext usage
|
|
132
|
-
'core/coding',
|
|
133
|
-
'core/architecture'
|
|
134
|
-
],
|
|
135
|
-
'nextjs-expert': [
|
|
136
|
-
'core/coding'
|
|
137
|
-
],
|
|
138
|
-
'css-specialist': [
|
|
139
|
-
'frontend/design-system/naming',
|
|
140
|
-
'frontend/design-system/animations',
|
|
141
|
-
'frontend/blazor/fluent-ui'
|
|
142
|
-
],
|
|
143
|
-
|
|
144
|
-
// Tier 3: Specialists - Infrastructure Squad
|
|
145
|
-
'bicep-architect': [
|
|
146
|
-
'infrastructure/azure/azure', // Stack-specific
|
|
147
|
-
'core/architecture'
|
|
148
|
-
],
|
|
149
|
-
'devops-engineer': [
|
|
150
|
-
'infrastructure/azure/azure', // Stack-specific
|
|
151
|
-
'backend/dotnet/core'
|
|
152
|
-
],
|
|
153
|
-
'container-specialist': [
|
|
154
|
-
'infrastructure/azure/azure', // Stack-specific
|
|
155
|
-
'backend/dotnet/core'
|
|
156
|
-
],
|
|
157
|
-
'observability-expert': [
|
|
158
|
-
'infrastructure/azure/azure', // Stack-specific
|
|
159
|
-
'core/architecture'
|
|
160
|
-
],
|
|
161
|
-
'azure-identity': [
|
|
162
|
-
'infrastructure/azure/azure', // Stack-specific
|
|
163
|
-
'core/architecture',
|
|
164
|
-
'backend/authentication/passkeys' // Stack-specific
|
|
165
|
-
],
|
|
166
|
-
|
|
167
|
-
// Tier 3: Specialists - Quality Squad
|
|
168
|
-
'testing-specialist': [
|
|
169
|
-
'core/testing',
|
|
170
|
-
'core/coding',
|
|
171
|
-
'core/architecture',
|
|
172
|
-
'backend/dotnet/core'
|
|
173
|
-
],
|
|
174
|
-
'code-analyzer': [
|
|
175
|
-
'core/coding',
|
|
176
|
-
'core/architecture',
|
|
177
|
-
'backend/dotnet/core',
|
|
178
|
-
'backend/dotnet/program-cs-checklist'
|
|
179
|
-
],
|
|
180
|
-
'troubleshooting-expert': [
|
|
181
|
-
'core/architecture',
|
|
182
|
-
'frontend/blazor/pitfalls',
|
|
183
|
-
'backend/dotnet/core'
|
|
184
|
-
],
|
|
185
|
-
'load-testing-expert': [
|
|
186
|
-
'core/architecture',
|
|
187
|
-
'infrastructure/azure/azure' // Stack-specific
|
|
188
|
-
],
|
|
189
|
-
'documentation-specialist': [], // No technical standards
|
|
190
|
-
|
|
191
|
-
// Tier 4: Validators
|
|
192
|
-
'security-expert': [
|
|
193
|
-
'core/coding',
|
|
194
|
-
'core/architecture',
|
|
195
|
-
'backend/authentication/passkeys' // Stack-specific
|
|
196
|
-
]
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* Load a single standard file with project override support
|
|
201
|
-
* @param {string} standardName - Standard path without .md extension (e.g., "core/coding", "backend/database/ef-core")
|
|
202
|
-
* @param {string} projectPath - Root path of the project
|
|
203
|
-
* @returns {string|null} Standard content or null if not found
|
|
204
|
-
*/
|
|
205
|
-
function loadStandard(standardName, projectPath) {
|
|
206
|
-
const locations = [
|
|
207
|
-
// 1. Project override
|
|
208
|
-
join(projectPath, '.morph/context', `${standardName}.md`),
|
|
209
|
-
// 2. Project-level standards (.morph/framework/standards/)
|
|
210
|
-
join(projectPath, '.morph/framework/standards', `${standardName}.md`),
|
|
211
|
-
// 3. Framework standards (hierarchical structure: core/, backend/, frontend/, infrastructure/)
|
|
212
|
-
join(projectPath, 'framework/standards', `${standardName}.md`)
|
|
213
|
-
];
|
|
214
|
-
|
|
215
|
-
for (const path of locations) {
|
|
216
|
-
if (existsSync(path)) {
|
|
217
|
-
try {
|
|
218
|
-
return readFileSync(path, 'utf8');
|
|
219
|
-
} catch (err) {
|
|
220
|
-
// Continue to next location
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
return null;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* Load all relevant standards for a given agent
|
|
230
|
-
* @param {string} agentId - Agent ID (e.g., 'blazor-builder')
|
|
231
|
-
* @param {string} projectPath - Root path of the project
|
|
232
|
-
* @returns {Object} { sections: [{standard, content}], fullContent: string }
|
|
233
|
-
*/
|
|
234
|
-
export function loadStandardsForAgent(agentId, projectPath = '.') {
|
|
235
|
-
const standardNames = AGENT_STANDARDS_MAP[agentId] || [];
|
|
236
|
-
const sections = [];
|
|
237
|
-
const contentParts = [];
|
|
238
|
-
|
|
239
|
-
// Load inferred standards if exists (project-specific learnings)
|
|
240
|
-
const inferredPath = join(projectPath, '.morph/context/inferred.md');
|
|
241
|
-
if (existsSync(inferredPath)) {
|
|
242
|
-
try {
|
|
243
|
-
const inferredContent = readFileSync(inferredPath, 'utf8');
|
|
244
|
-
sections.push({
|
|
245
|
-
standard: 'inferred',
|
|
246
|
-
content: inferredContent
|
|
247
|
-
});
|
|
248
|
-
contentParts.push(`# Project-Specific Standards (Inferred)\n\n${inferredContent}`);
|
|
249
|
-
} catch (err) {
|
|
250
|
-
// Ignore if can't read
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
// Load each standard
|
|
255
|
-
for (const standardName of standardNames) {
|
|
256
|
-
const content = loadStandard(standardName, projectPath);
|
|
257
|
-
if (content) {
|
|
258
|
-
sections.push({
|
|
259
|
-
standard: standardName,
|
|
260
|
-
content
|
|
261
|
-
});
|
|
262
|
-
contentParts.push(`# ${standardName}\n\n${content}`);
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
return {
|
|
267
|
-
sections,
|
|
268
|
-
fullContent: contentParts.join('\n\n---\n\n'),
|
|
269
|
-
standardNames // For debugging/introspection
|
|
270
|
-
};
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
* Get list of standards for an agent (without loading content)
|
|
275
|
-
* @param {string} agentId - Agent ID
|
|
276
|
-
* @returns {string[]} Array of standard names
|
|
277
|
-
*/
|
|
278
|
-
export function getStandardsListForAgent(agentId) {
|
|
279
|
-
return AGENT_STANDARDS_MAP[agentId] || [];
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
/**
|
|
283
|
-
* Check if a standard exists in any location
|
|
284
|
-
* @param {string} standardName - Standard path without .md extension (e.g., "core/coding", "backend/database/ef-core")
|
|
285
|
-
* @param {string} projectPath - Root path of the project
|
|
286
|
-
* @returns {Object} { exists: boolean, location: string|null }
|
|
287
|
-
*/
|
|
288
|
-
export function checkStandardExists(standardName, projectPath = '.') {
|
|
289
|
-
const locations = [
|
|
290
|
-
{ type: 'project', path: join(projectPath, '.morph/context', `${standardName}.md`) },
|
|
291
|
-
{ type: 'morph', path: join(projectPath, '.morph/framework/standards', `${standardName}.md`) },
|
|
292
|
-
{ type: 'framework', path: join(projectPath, 'framework/standards', `${standardName}.md`) }
|
|
293
|
-
];
|
|
294
|
-
|
|
295
|
-
for (const loc of locations) {
|
|
296
|
-
if (existsSync(loc.path)) {
|
|
297
|
-
return { exists: true, location: loc.type, path: loc.path };
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
return { exists: false, location: null, path: null };
|
|
302
|
-
}
|
|
@@ -1,316 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Blazor Concurrency Analyzer
|
|
3
|
-
*
|
|
4
|
-
* Detects potential DbContext concurrency issues in Blazor Server applications.
|
|
5
|
-
* Identifies patterns that lead to "A second operation was started" exceptions.
|
|
6
|
-
*
|
|
7
|
-
* @module blazor-concurrency-analyzer
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { readFileSync } from 'fs';
|
|
11
|
-
import { glob } from 'glob';
|
|
12
|
-
import { countIssues } from '../shared/index.js';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @typedef {Object} ConcurrencyIssue
|
|
16
|
-
* @property {'error' | 'warning' | 'info'} type
|
|
17
|
-
* @property {string} message
|
|
18
|
-
* @property {string} [suggestion]
|
|
19
|
-
* @property {string} file
|
|
20
|
-
* @property {number} [line]
|
|
21
|
-
* @property {string} [code]
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
// Patterns that indicate scoped DbContext injection
|
|
25
|
-
const SCOPED_DBCONTEXT_PATTERNS = [
|
|
26
|
-
/private readonly (\w+DbContext)\s+_\w+/g,
|
|
27
|
-
/\[Inject\]\s*(?:private|public)\s+(\w+DbContext)/g,
|
|
28
|
-
/private readonly I(\w+)Repository\s+_\w+/g,
|
|
29
|
-
];
|
|
30
|
-
|
|
31
|
-
// Patterns that indicate background operations
|
|
32
|
-
const BACKGROUND_OPERATION_PATTERNS = [
|
|
33
|
-
/Task\.Run\s*\(/,
|
|
34
|
-
/Task\.Factory\.StartNew\s*\(/,
|
|
35
|
-
/Parallel\.For/,
|
|
36
|
-
/Parallel\.ForEach/,
|
|
37
|
-
/\.ConfigureAwait\(false\)/,
|
|
38
|
-
/_ = \w+Async\(/, // Fire-and-forget pattern
|
|
39
|
-
/ThreadPool\.QueueUserWorkItem/,
|
|
40
|
-
];
|
|
41
|
-
|
|
42
|
-
// Patterns that indicate factory usage (GOOD)
|
|
43
|
-
const FACTORY_PATTERNS = [
|
|
44
|
-
/IDbContextFactory<\w+>/,
|
|
45
|
-
/IDbContextFactory\s*<\s*\w+\s*>/,
|
|
46
|
-
/_factory\.CreateDbContext/,
|
|
47
|
-
/_contextFactory\.CreateDbContext/,
|
|
48
|
-
/await using var \w+ = .*CreateDbContext/,
|
|
49
|
-
];
|
|
50
|
-
|
|
51
|
-
// Hangfire patterns
|
|
52
|
-
const HANGFIRE_PATTERNS = [
|
|
53
|
-
/BackgroundJob\.Enqueue/,
|
|
54
|
-
/BackgroundJob\.Schedule/,
|
|
55
|
-
/RecurringJob\.AddOrUpdate/,
|
|
56
|
-
/\[AutomaticRetry\]/,
|
|
57
|
-
];
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Checks for scoped DbContext used in background operations.
|
|
61
|
-
*
|
|
62
|
-
* @param {string} content - File content
|
|
63
|
-
* @param {string} filePath - Path to the file
|
|
64
|
-
* @returns {ConcurrencyIssue[]}
|
|
65
|
-
*/
|
|
66
|
-
export function checkScopedDbContextInBackground(content, filePath) {
|
|
67
|
-
const issues = [];
|
|
68
|
-
const lines = content.split('\n');
|
|
69
|
-
|
|
70
|
-
// First, check if file has scoped DbContext
|
|
71
|
-
let hasScopedDbContext = false;
|
|
72
|
-
let dbContextLine = 0;
|
|
73
|
-
|
|
74
|
-
lines.forEach((line, index) => {
|
|
75
|
-
SCOPED_DBCONTEXT_PATTERNS.forEach((pattern) => {
|
|
76
|
-
if (pattern.test(line)) {
|
|
77
|
-
hasScopedDbContext = true;
|
|
78
|
-
dbContextLine = index + 1;
|
|
79
|
-
}
|
|
80
|
-
pattern.lastIndex = 0;
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
if (!hasScopedDbContext) {
|
|
85
|
-
return issues;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// Check if file has factory pattern (GOOD - no issues)
|
|
89
|
-
const hasFactory = FACTORY_PATTERNS.some((pattern) => pattern.test(content));
|
|
90
|
-
|
|
91
|
-
if (hasFactory) {
|
|
92
|
-
return issues; // Using factory pattern correctly
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// Check for background operations
|
|
96
|
-
lines.forEach((line, index) => {
|
|
97
|
-
BACKGROUND_OPERATION_PATTERNS.forEach((pattern) => {
|
|
98
|
-
if (pattern.test(line)) {
|
|
99
|
-
issues.push({
|
|
100
|
-
type: 'error',
|
|
101
|
-
message: 'Operacao background com DbContext scoped detectada',
|
|
102
|
-
suggestion:
|
|
103
|
-
'Use IDbContextFactory<T> ou Repository Factory pattern para operacoes background. Ver framework/standards/backend/database/ef-core.md',
|
|
104
|
-
file: filePath,
|
|
105
|
-
line: index + 1,
|
|
106
|
-
code: line.trim(),
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
return issues;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Checks for Hangfire jobs using scoped services.
|
|
117
|
-
*
|
|
118
|
-
* @param {string} content - File content
|
|
119
|
-
* @param {string} filePath - Path to the file
|
|
120
|
-
* @returns {ConcurrencyIssue[]}
|
|
121
|
-
*/
|
|
122
|
-
export function checkHangfireWithScopedServices(content, filePath) {
|
|
123
|
-
const issues = [];
|
|
124
|
-
const lines = content.split('\n');
|
|
125
|
-
|
|
126
|
-
// Check if file has Hangfire patterns
|
|
127
|
-
const hasHangfire = HANGFIRE_PATTERNS.some((pattern) => pattern.test(content));
|
|
128
|
-
|
|
129
|
-
if (!hasHangfire) {
|
|
130
|
-
return issues;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
// Check if using factory pattern
|
|
134
|
-
const hasFactory = FACTORY_PATTERNS.some((pattern) => pattern.test(content));
|
|
135
|
-
|
|
136
|
-
if (hasFactory) {
|
|
137
|
-
return issues; // Good - using factory
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
// Check for scoped DbContext
|
|
141
|
-
const hasScopedDbContext = SCOPED_DBCONTEXT_PATTERNS.some((pattern) => {
|
|
142
|
-
const result = pattern.test(content);
|
|
143
|
-
pattern.lastIndex = 0;
|
|
144
|
-
return result;
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
if (hasScopedDbContext) {
|
|
148
|
-
lines.forEach((line, index) => {
|
|
149
|
-
HANGFIRE_PATTERNS.forEach((pattern) => {
|
|
150
|
-
if (pattern.test(line)) {
|
|
151
|
-
issues.push({
|
|
152
|
-
type: 'error',
|
|
153
|
-
message: 'Hangfire job com DbContext scoped',
|
|
154
|
-
suggestion:
|
|
155
|
-
'Hangfire jobs rodam fora do escopo HTTP. Use IDbContextFactory<T> para criar contextos isolados.',
|
|
156
|
-
file: filePath,
|
|
157
|
-
line: index + 1,
|
|
158
|
-
code: line.trim(),
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
return issues;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* Checks for scoped services injected into singleton services.
|
|
170
|
-
*
|
|
171
|
-
* @param {string} content - File content
|
|
172
|
-
* @param {string} filePath - Path to the file
|
|
173
|
-
* @returns {ConcurrencyIssue[]}
|
|
174
|
-
*/
|
|
175
|
-
export function checkScopedInSingleton(content, filePath) {
|
|
176
|
-
const issues = [];
|
|
177
|
-
const lines = content.split('\n');
|
|
178
|
-
|
|
179
|
-
// Type guard: filePath must be a string (validation-runner may pass options object)
|
|
180
|
-
if (typeof filePath !== 'string') return [];
|
|
181
|
-
|
|
182
|
-
// Check if class might be a singleton (common naming patterns)
|
|
183
|
-
const isSingletonCandidate =
|
|
184
|
-
filePath.includes('BackgroundService') ||
|
|
185
|
-
filePath.includes('HostedService') ||
|
|
186
|
-
filePath.includes('Worker') ||
|
|
187
|
-
content.includes(': BackgroundService') ||
|
|
188
|
-
content.includes(': IHostedService') ||
|
|
189
|
-
content.includes('[Singleton]');
|
|
190
|
-
|
|
191
|
-
if (!isSingletonCandidate) {
|
|
192
|
-
return issues;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
// Check for scoped service injection
|
|
196
|
-
lines.forEach((line, index) => {
|
|
197
|
-
SCOPED_DBCONTEXT_PATTERNS.forEach((pattern) => {
|
|
198
|
-
if (pattern.test(line)) {
|
|
199
|
-
issues.push({
|
|
200
|
-
type: 'warning',
|
|
201
|
-
message: 'Possivel injecao de servico scoped em singleton',
|
|
202
|
-
suggestion:
|
|
203
|
-
'Services scoped (DbContext, Repositories) nao devem ser injetados em singletons. Use IServiceScopeFactory ou IDbContextFactory.',
|
|
204
|
-
file: filePath,
|
|
205
|
-
line: index + 1,
|
|
206
|
-
code: line.trim(),
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
pattern.lastIndex = 0;
|
|
210
|
-
});
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
return issues;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
/**
|
|
217
|
-
* Checks for concurrent DbContext access in Blazor components.
|
|
218
|
-
*
|
|
219
|
-
* @param {string} content - File content
|
|
220
|
-
* @param {string} filePath - Path to the file
|
|
221
|
-
* @returns {ConcurrencyIssue[]}
|
|
222
|
-
*/
|
|
223
|
-
export function checkConcurrentAccess(content, filePath) {
|
|
224
|
-
const issues = [];
|
|
225
|
-
const lines = content.split('\n');
|
|
226
|
-
|
|
227
|
-
// Check for multiple Task.WhenAll with repository/context calls
|
|
228
|
-
if (content.includes('Task.WhenAll') || content.includes('Task.WhenAny')) {
|
|
229
|
-
// Check if the tasks involve database operations
|
|
230
|
-
const hasDbOperations =
|
|
231
|
-
content.includes('Repository') ||
|
|
232
|
-
content.includes('DbContext') ||
|
|
233
|
-
content.includes('SaveChangesAsync') ||
|
|
234
|
-
content.includes('ToListAsync');
|
|
235
|
-
|
|
236
|
-
if (hasDbOperations) {
|
|
237
|
-
lines.forEach((line, index) => {
|
|
238
|
-
if (line.includes('Task.WhenAll') || line.includes('Task.WhenAny')) {
|
|
239
|
-
issues.push({
|
|
240
|
-
type: 'warning',
|
|
241
|
-
message: 'Task.WhenAll/WhenAny com possivel acesso concorrente ao DbContext',
|
|
242
|
-
suggestion:
|
|
243
|
-
'Se as tasks acessam o mesmo DbContext, isso causara erros. Cada task deve ter seu proprio contexto via IDbContextFactory.',
|
|
244
|
-
file: filePath,
|
|
245
|
-
line: index + 1,
|
|
246
|
-
code: line.trim(),
|
|
247
|
-
});
|
|
248
|
-
}
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
return issues;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
/**
|
|
257
|
-
* Runs all concurrency checks on a file.
|
|
258
|
-
*
|
|
259
|
-
* @param {string} content - File content
|
|
260
|
-
* @param {string} filePath - Path to the file
|
|
261
|
-
* @returns {ConcurrencyIssue[]}
|
|
262
|
-
*/
|
|
263
|
-
export function analyzeConcurrency(content, filePath) {
|
|
264
|
-
const issues = [];
|
|
265
|
-
|
|
266
|
-
issues.push(...checkScopedDbContextInBackground(content, filePath));
|
|
267
|
-
issues.push(...checkHangfireWithScopedServices(content, filePath));
|
|
268
|
-
issues.push(...checkScopedInSingleton(content, filePath));
|
|
269
|
-
issues.push(...checkConcurrentAccess(content, filePath));
|
|
270
|
-
|
|
271
|
-
return issues;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
/**
|
|
276
|
-
* Project-level concurrency validator. Scans all .cs files in projectPath.
|
|
277
|
-
* Follows the same interface as other project-level validators (validateNextComponentFiles, etc.)
|
|
278
|
-
*
|
|
279
|
-
* @param {string} projectPath - Project root path
|
|
280
|
-
* @param {Object} [_options]
|
|
281
|
-
* @returns {Promise<{errors: number, warnings: number, issues: Array}>}
|
|
282
|
-
*/
|
|
283
|
-
export async function validateConcurrencyFiles(projectPath, _options = {}) {
|
|
284
|
-
const result = { errors: 0, warnings: 0, issues: [] };
|
|
285
|
-
const pattern = projectPath.replace(/\\/g, '/') + '/**/*.cs';
|
|
286
|
-
const files = await glob(pattern, { ignore: ['**/node_modules/**', '**/obj/**', '**/bin/**'] });
|
|
287
|
-
|
|
288
|
-
for (const filePath of files) {
|
|
289
|
-
const content = readFileSync(filePath, 'utf8');
|
|
290
|
-
const relPath = filePath.replace(projectPath.replace(/\\/g, '/') + '/', '');
|
|
291
|
-
const fileIssues = analyzeConcurrency(content, relPath);
|
|
292
|
-
for (const issue of fileIssues) {
|
|
293
|
-
result.issues.push({
|
|
294
|
-
level: issue.type,
|
|
295
|
-
message: issue.message,
|
|
296
|
-
file: issue.file,
|
|
297
|
-
line: issue.line,
|
|
298
|
-
solution: issue.suggestion,
|
|
299
|
-
});
|
|
300
|
-
if (issue.type === 'error') result.errors++;
|
|
301
|
-
else result.warnings++;
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
return result;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
export default {
|
|
309
|
-
analyzeConcurrency,
|
|
310
|
-
validateConcurrencyFiles,
|
|
311
|
-
checkScopedDbContextInBackground,
|
|
312
|
-
checkHangfireWithScopedServices,
|
|
313
|
-
checkScopedInSingleton,
|
|
314
|
-
checkConcurrentAccess,
|
|
315
|
-
countIssues,
|
|
316
|
-
};
|