@polymorphism-tech/morph-spec 4.3.7 → 4.6.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/.morph/.morphversion +3 -3
- package/.morph/analytics/threads-log.jsonl +6 -9
- package/.morph/config/config.json +2 -3
- package/.morph/framework/standards/STANDARDS.json +812 -0
- package/.morph/{standards → framework/standards}/ai-agents/team-orchestration.md +3 -3
- package/.morph/{standards → framework/standards}/frontend/nextjs/nextjs-patterns.md +17 -0
- package/.morph/framework/standards/integration/mcp/mcp-tools.md +384 -0
- package/.morph/{templates → framework/templates}/README.md +17 -17
- package/.morph/{templates → framework/templates}/REGISTRY.json +48 -233
- package/.morph/framework/templates/code/dotnet/contracts/contracts.cs.hbs +172 -0
- package/.morph/{templates → framework/templates}/context/CONTEXT-FEATURE.md +1 -1
- package/.morph/{templates → framework/templates}/context/CONTEXT.md +3 -3
- package/.morph/framework/templates/docs/clarifications.md +253 -0
- package/.morph/framework/templates/docs/onboarding.md +123 -0
- package/.morph/framework/templates/docs/schema-analysis.md +119 -0
- package/.morph/{templates → framework/templates}/docs/spec.md +149 -149
- package/.morph/framework/templates/docs/ui-components.md +124 -0
- package/.morph/framework/templates/docs/ui-design-system.md +76 -0
- package/.morph/framework/templates/docs/ui-flows.md +167 -0
- package/.morph/framework/templates/docs/ui-mockups.md +98 -0
- package/.morph/framework/templates/docs/user-stories.md +34 -0
- package/.morph/{templates → framework/templates}/examples/spec-examples.md +1 -1
- package/.morph/{templates → framework/templates}/infrastructure/github/README.md +11 -11
- package/.morph/{templates → framework/templates}/infrastructure/github/workflows/deploy-azure-app-service.yml.hbs +2 -2
- package/.morph/{templates → framework/templates}/meta-prompts/parallel-workers/parallel-worker.md +2 -2
- package/.morph/{templates → framework/templates}/meta-prompts/validators/pre-commit-validator.md +1 -1
- package/.morph/logs/tool-failures.log +7 -0
- package/.morph/memory/pre-compact-2026-02-23T15-43-03-521Z.json +16 -0
- package/.morph/state.json +1 -1
- package/CLAUDE.md +77 -155
- package/README.md +20 -18
- package/bin/detect-agents.js +1 -1
- package/bin/morph-spec.js +116 -266
- package/bin/task-manager.cjs +2 -2
- package/bin/validate.js +1 -1
- package/claude-plugin.json +14 -0
- package/docs/claude-alignment-report.md +137 -0
- package/docs/plans/2026-02-22-claude-docs-morph-alignment-analysis.md +512 -0
- package/docs/plans/2026-02-22-claude-settings.md +515 -0
- package/docs/plans/2026-02-22-morph-cc-alignment-impl.md +728 -0
- package/docs/plans/2026-02-22-morph-spec-next.md +478 -0
- package/docs/plans/2026-02-22-native-alignment-design.md +199 -0
- package/docs/plans/2026-02-22-native-alignment-impl.md +925 -0
- package/docs/plans/2026-02-22-native-enrichment-design.md +244 -0
- package/docs/plans/2026-02-22-native-enrichment.md +735 -0
- package/framework/CLAUDE.md +77 -0
- package/framework/{skills/level-2-domains → agents}/ai-agents/ai-system-architect.md +7 -3
- package/framework/{skills/level-2-domains → agents}/architecture/po-pm-advisor.md +7 -1
- package/framework/{skills/level-2-domains → agents}/architecture/prompt-engineer.md +7 -1
- package/framework/{skills/level-2-domains → agents}/architecture/seo-growth-hacker.md +7 -1
- package/framework/{skills/level-2-domains → agents}/architecture/standards-architect.md +10 -6
- package/framework/agents/backend/api-designer.md +103 -0
- package/framework/{skills/level-2-domains → agents}/backend/dotnet-senior.md +7 -1
- package/framework/agents/backend/ef-modeler.md +119 -0
- package/framework/{skills/level-2-domains → agents}/backend/hangfire-orchestrator.md +8 -4
- package/framework/{skills/level-2-domains → agents}/backend/ms-agent-expert.md +7 -3
- package/framework/{skills/level-2-domains → agents}/frontend/blazor-builder.md +7 -3
- package/framework/{skills/level-2-domains → agents}/frontend/nextjs-expert.md +7 -3
- package/framework/{skills/level-2-domains → agents}/frontend/ui-ux-designer.md +8 -2
- package/framework/{skills/level-2-domains → agents}/infrastructure/azure-architect.md +7 -1
- package/framework/{skills/level-2-domains → agents}/infrastructure/azure-deploy-specialist.md +7 -1
- package/framework/{skills/level-2-domains → agents}/infrastructure/bicep-architect.md +7 -3
- package/framework/{skills/level-2-domains → agents}/infrastructure/container-specialist.md +7 -3
- package/framework/{skills/level-2-domains → agents}/infrastructure/devops-engineer.md +7 -3
- package/framework/{skills/level-2-domains → agents}/integrations/asaas-financial.md +7 -3
- package/framework/{skills/level-2-domains → agents}/integrations/azure-identity.md +7 -3
- package/framework/{skills/level-2-domains → agents}/integrations/clerk-auth.md +7 -3
- package/framework/{skills/level-2-domains/integrations/hangfire-orchestrator.md → agents/integrations/hangfire-integration.md} +7 -1
- package/framework/{skills/level-2-domains → agents}/integrations/resend-email.md +7 -3
- package/framework/{skills/level-2-domains → agents}/quality/code-analyzer.md +9 -5
- package/framework/{skills/level-2-domains → agents}/quality/testing-specialist.md +7 -3
- package/framework/commands/morph-apply.md +9 -9
- package/framework/commands/morph-archive.md +8 -8
- package/framework/commands/morph-infra.md +1 -1
- package/framework/commands/morph-proposal.md +9 -9
- package/framework/commands/morph-status.md +3 -3
- package/framework/commands/morph-troubleshoot.md +1 -1
- package/framework/hooks/README.md +201 -282
- package/framework/hooks/claude-code/notification/approval-reminder.js +52 -0
- package/framework/hooks/claude-code/post-tool-use/dispatch.js +83 -0
- package/framework/hooks/claude-code/post-tool-use/handle-tool-failure.js +42 -0
- package/framework/hooks/claude-code/pre-compact/save-morph-context.js +61 -0
- package/framework/hooks/claude-code/pre-tool-use/enforce-phase-writes.js +71 -0
- package/framework/hooks/claude-code/pre-tool-use/protect-readonly-files.js +58 -0
- package/framework/hooks/claude-code/pre-tool-use/protect-spec-files.js +64 -0
- package/framework/hooks/claude-code/session-start/inject-morph-context.js +94 -0
- package/framework/hooks/claude-code/statusline.py +538 -0
- package/framework/hooks/claude-code/statusline.sh +7 -0
- package/framework/hooks/claude-code/stop/validate-completion.js +88 -0
- package/framework/hooks/claude-code/user-prompt/enrich-prompt.js +91 -0
- package/framework/hooks/shared/hook-response.js +45 -0
- package/framework/hooks/shared/phase-utils.js +129 -0
- package/framework/hooks/shared/state-reader.js +138 -0
- package/framework/hooks/shared/stdin-reader.js +26 -0
- package/framework/phases.json +145 -0
- package/framework/rules/csharp-standards.md +10 -0
- package/framework/rules/frontend-standards.md +14 -0
- package/framework/rules/infrastructure-standards.md +13 -0
- package/framework/rules/morph-workflow.md +86 -0
- package/framework/rules/testing-standards.md +11 -0
- package/framework/skills/README.md +66 -0
- package/framework/skills/level-0-meta/brainstorming/SKILL.md +135 -0
- package/framework/skills/level-0-meta/brainstorming/references/proposal-example.md +138 -0
- package/framework/skills/level-0-meta/{code-review.md → code-review/SKILL.md} +13 -4
- package/framework/skills/level-0-meta/code-review/references/review-example.md +164 -0
- package/framework/skills/level-0-meta/code-review/scripts/scan-csharp.mjs +121 -0
- package/framework/skills/level-0-meta/mcp-registry.json +207 -0
- package/framework/skills/level-0-meta/{morph-checklist.md → morph-checklist/SKILL.md} +8 -3
- package/framework/skills/{level-1-workflows/morph-replicate.md → level-0-meta/morph-replicate/SKILL.md} +13 -6
- package/framework/skills/level-0-meta/{simulation-checklist.md → simulation-checklist/SKILL.md} +9 -4
- package/framework/skills/level-0-meta/tool-usage-guide/SKILL.md +334 -0
- package/framework/skills/level-0-meta/verification-before-completion/SKILL.md +147 -0
- package/framework/skills/level-0-meta/verification-before-completion/scripts/check-phase-outputs.mjs +110 -0
- package/framework/skills/level-1-workflows/{phase-clarify.md → phase-clarify/SKILL.md} +65 -4
- package/framework/skills/level-1-workflows/phase-clarify/references/clarifications-example.md +117 -0
- package/framework/skills/level-1-workflows/phase-codebase-analysis/SKILL.md +181 -0
- package/framework/skills/level-1-workflows/phase-design/SKILL.md +303 -0
- package/framework/skills/level-1-workflows/phase-design/references/spec-example.md +253 -0
- package/framework/skills/level-1-workflows/phase-implement/SKILL.md +254 -0
- package/framework/skills/level-1-workflows/phase-implement/references/recap-example.md +132 -0
- package/framework/skills/level-1-workflows/phase-setup/SKILL.md +171 -0
- package/framework/skills/level-1-workflows/{phase-tasks.md → phase-tasks/SKILL.md} +89 -7
- package/framework/skills/level-1-workflows/phase-tasks/references/tasks-example.md +231 -0
- package/framework/skills/level-1-workflows/phase-tasks/scripts/validate-tasks.mjs +112 -0
- package/framework/skills/level-1-workflows/phase-uiux/SKILL.md +246 -0
- package/framework/standards/STANDARDS.json +812 -0
- package/framework/standards/ai-agents/team-orchestration.md +3 -3
- package/framework/standards/frontend/nextjs/nextjs-patterns.md +17 -0
- package/framework/standards/integration/mcp/mcp-tools.md +384 -0
- package/framework/templates/README.md +17 -17
- package/framework/templates/REGISTRY.json +48 -233
- package/framework/templates/code/dotnet/contracts/contracts.cs.hbs +172 -0
- package/framework/templates/context/CONTEXT-FEATURE.md +1 -1
- package/framework/templates/context/CONTEXT.md +3 -3
- package/framework/templates/docs/clarifications.md +253 -0
- package/framework/templates/docs/onboarding.md +123 -0
- package/framework/templates/docs/schema-analysis.md +119 -0
- package/framework/templates/docs/spec.md +149 -149
- package/framework/templates/docs/ui-components.md +124 -0
- package/framework/templates/docs/ui-design-system.md +76 -0
- package/framework/templates/docs/ui-flows.md +167 -0
- package/framework/templates/docs/ui-mockups.md +98 -0
- package/framework/templates/docs/user-stories.md +34 -0
- package/framework/templates/examples/spec-examples.md +1 -1
- package/framework/templates/infrastructure/github/README.md +11 -11
- package/framework/templates/infrastructure/github/workflows/deploy-azure-app-service.yml.hbs +2 -2
- package/framework/templates/meta-prompts/parallel-workers/parallel-worker.md +2 -2
- package/framework/templates/meta-prompts/validators/pre-commit-validator.md +1 -1
- package/framework/workflows/configs/express.json +45 -0
- package/framework/workflows/configs/spec-only.json +43 -0
- package/framework/workflows/docs/enforcement-pipeline.md +8 -8
- package/framework/workflows/docs/full-morph.md +3 -3
- package/package.json +3 -1
- package/scripts/generate-refs.js +336 -0
- package/scripts/generate-standards-registry.js +44 -0
- package/scripts/validate-real.mjs +255 -0
- package/src/commands/feature/create-story.js +362 -361
- package/src/commands/feature/shard-spec.js +225 -224
- package/src/commands/feature/sprint-status.js +1 -1
- package/src/commands/generation/generate-onboarding.js +169 -0
- package/src/commands/generation/generate.js +2 -2
- package/src/commands/mcp/mcp-setup.js +315 -0
- package/src/commands/project/changes.js +66 -0
- package/src/commands/project/checkpoint.js +209 -0
- package/src/commands/project/cost.js +179 -0
- package/src/commands/project/diff.js +278 -0
- package/src/commands/project/doctor.js +55 -7
- package/src/commands/project/init.js +318 -136
- package/src/commands/project/revert.js +173 -0
- package/src/commands/project/standards.js +80 -0
- package/src/commands/project/status.js +376 -0
- package/src/commands/project/update-agents.js +23 -0
- package/src/commands/project/update.js +60 -88
- package/src/commands/state/advance-phase.js +4 -3
- package/src/commands/state/state.js +10 -3
- package/src/commands/state/validate-phase.js +19 -2
- package/src/commands/templates/template-customize.js +4 -4
- package/src/commands/templates/template-render.js +1 -1
- package/src/commands/templates/template-show.js +1 -1
- package/src/commands/validation/validate-feature.js +359 -0
- package/src/core/orchestrator.js +3 -38
- package/src/core/paths/output-schema.js +135 -0
- package/src/core/state/state-manager.js +831 -592
- package/src/core/templates/template-registry.js +2 -2
- package/src/core/workflows/workflow-detector.js +17 -1
- package/src/lib/agents/micro-agent-factory.js +1 -1
- package/src/lib/context/context-bundler.js +2 -1
- package/src/lib/detectors/claude-config-detector.js +390 -0
- package/src/lib/detectors/conversation-analyzer.js +4 -4
- package/src/lib/detectors/design-system-detector.js +6 -5
- package/src/lib/detectors/standards-generator.js +2 -2
- package/src/lib/generators/context-generator.js +539 -538
- package/src/lib/generators/recap-generator.js +1 -1
- package/src/lib/generators/settings-generator.js +210 -0
- package/src/lib/hooks/hook-executor.js +1 -1
- package/src/lib/installers/mcp-installer.js +299 -0
- package/src/lib/learning/learning-system.js +3 -3
- package/src/lib/orchestration/team-orchestrator.js +1 -1
- package/src/lib/standards/standards-context-injector.js +7 -7
- package/src/lib/threads/thread-coordinator.js +1 -1
- package/src/lib/troubleshooting/troubleshoot-grep.js +1 -1
- package/src/lib/validators/contracts/contract-compliance-validator.js +274 -273
- package/src/lib/validators/design-system/design-system-validator.js +1 -1
- package/src/lib/validators/spec-validator.js +258 -258
- package/src/lib/validators/validation-runner.js +270 -269
- package/src/utils/agents-installer.js +206 -0
- package/src/utils/claude-settings-manager.js +258 -0
- package/src/utils/file-copier.js +1 -1
- package/src/utils/hooks-installer.js +354 -28
- package/src/utils/skills-installer.js +118 -0
- package/.morph/project/context/README.md +0 -17
- package/.morph/project/context/detection-log.md +0 -16
- package/.morph/project/standards/inferred.md +0 -59
- package/framework/hooks/agent-stop/validate-and-continue.js +0 -96
- package/framework/hooks/agent-stop/validate-checkpoints.js +0 -101
- package/framework/hooks/agent-stop/validate-tests.js +0 -109
- package/framework/hooks/agent-teams/dispatch.js +0 -67
- package/framework/hooks/agent-teams/phase-advanced.js +0 -80
- package/framework/hooks/agent-teams/task-completed.js +0 -76
- package/framework/hooks/agent-teams/teammate-idle.js +0 -70
- package/framework/skills/level-1-workflows/phase-design.md +0 -213
- package/framework/skills/level-1-workflows/phase-setup.md +0 -106
- package/framework/skills/level-1-workflows/phase-uiux.md +0 -169
- package/framework/skills/level-2-domains/backend/api-designer.md +0 -59
- package/framework/skills/level-2-domains/backend/ef-modeler.md +0 -58
- package/framework/skills/level-3-technologies/README.md +0 -7
- package/framework/skills/level-4-patterns/README.md +0 -7
- package/src/commands/agents/agents-fuse.js +0 -97
- package/src/commands/agents/micro-agent.js +0 -112
- package/src/commands/agents/spawn-team.js +0 -237
- package/src/commands/agents/squad-template.js +0 -146
- package/src/commands/analytics/analytics.js +0 -176
- package/src/commands/context/context-prime.js +0 -63
- package/src/commands/context/core-four.js +0 -54
- package/src/commands/generation/generate-context.js +0 -40
- package/src/commands/project/detect-agents.js +0 -207
- package/src/commands/project/detect-workflow.js +0 -174
- package/src/commands/threads/thread-template.js +0 -103
- package/src/commands/threads/threads.js +0 -261
- package/src/commands/utils/session-summary.js +0 -291
- package/src/llm/analyzer.js +0 -215
- package/src/llm/few-shot-examples.js +0 -216
- package/src/llm/project-config-schema.json +0 -188
- package/src/llm/prompt-builder.js +0 -96
- /package/.morph/{config → framework}/agents.json +0 -0
- /package/.morph/{standards → framework/standards}/ai-agents/blazor-ui.md +0 -0
- /package/.morph/{standards → framework/standards}/ai-agents/production.md +0 -0
- /package/.morph/{standards → framework/standards}/ai-agents/setup.md +0 -0
- /package/.morph/{standards → framework/standards}/ai-agents/workflows.md +0 -0
- /package/.morph/{standards → framework/standards}/architecture/ddd/aggregates.md +0 -0
- /package/.morph/{standards → framework/standards}/architecture/ddd/entities.md +0 -0
- /package/.morph/{standards → framework/standards}/architecture/ddd/value-objects.md +0 -0
- /package/.morph/{standards → framework/standards}/backend/api/minimal-api.md +0 -0
- /package/.morph/{standards → framework/standards}/backend/api/rest.md +0 -0
- /package/.morph/{standards → framework/standards}/backend/api/validation.md +0 -0
- /package/.morph/{standards → framework/standards}/backend/authentication/passkeys.md +0 -0
- /package/.morph/{standards → framework/standards}/backend/database/ef-core.md +0 -0
- /package/.morph/{standards → framework/standards}/backend/database/migrations.md +0 -0
- /package/.morph/{standards → framework/standards}/backend/database/postgresql/database.md +0 -0
- /package/.morph/{standards → framework/standards}/backend/database/repository-patterns.md +0 -0
- /package/.morph/{standards → framework/standards}/backend/database/vector-search-rag.md +0 -0
- /package/.morph/{standards → framework/standards}/backend/dotnet/async.md +0 -0
- /package/.morph/{standards → framework/standards}/backend/dotnet/core.md +0 -0
- /package/.morph/{standards → framework/standards}/backend/dotnet/di.md +0 -0
- /package/.morph/{standards → framework/standards}/backend/dotnet/program-cs-checklist.md +0 -0
- /package/.morph/{standards → framework/standards}/backend/integrations/asaas/asaas-api.md +0 -0
- /package/.morph/{standards → framework/standards}/backend/integrations/clerk/clerk-auth.md +0 -0
- /package/.morph/{standards → framework/standards}/backend/integrations/hangfire/hangfire-jobs.md +0 -0
- /package/.morph/{standards → framework/standards}/backend/integrations/resend/resend-email.md +0 -0
- /package/.morph/{standards → framework/standards}/context/analytics.md +0 -0
- /package/.morph/{standards → framework/standards}/context/bundles.md +0 -0
- /package/.morph/{standards → framework/standards}/context/priming.md +0 -0
- /package/.morph/{standards → framework/standards}/core/architecture.md +0 -0
- /package/.morph/{standards → framework/standards}/core/coding.md +0 -0
- /package/.morph/{standards → framework/standards}/core/git-branching-strategy.md +0 -0
- /package/.morph/{standards → framework/standards}/core/git.md +0 -0
- /package/.morph/{standards → framework/standards}/core/testing.md +0 -0
- /package/.morph/{standards → framework/standards}/data/nosql/blob-storage.md +0 -0
- /package/.morph/{standards → framework/standards}/data/nosql/cache/redis.md +0 -0
- /package/.morph/{standards → framework/standards}/data/nosql/cosmos-db.md +0 -0
- /package/.morph/{standards → framework/standards}/data/vector-search/azure-ai-search.md +0 -0
- /package/.morph/{standards → framework/standards}/data/vector-search/rag-chunking.md +0 -0
- /package/.morph/{standards → framework/standards}/frontend/blazor/design-checklist.md +0 -0
- /package/.morph/{standards → framework/standards}/frontend/blazor/fluent-ui-setup.md +0 -0
- /package/.morph/{standards → framework/standards}/frontend/blazor/fluent-ui.md +0 -0
- /package/.morph/{standards → framework/standards}/frontend/blazor/html-conversion.md +0 -0
- /package/.morph/{standards → framework/standards}/frontend/blazor/lifecycle.md +0 -0
- /package/.morph/{standards → framework/standards}/frontend/blazor/pitfalls.md +0 -0
- /package/.morph/{standards → framework/standards}/frontend/blazor/state.md +0 -0
- /package/.morph/{standards → framework/standards}/frontend/design-system/animations.md +0 -0
- /package/.morph/{standards → framework/standards}/frontend/design-system/naming.md +0 -0
- /package/.morph/{standards → framework/standards}/infrastructure/azure/azure.md +0 -0
- /package/.morph/{standards → framework/standards}/infrastructure/azure/bicep/bicep-patterns.md +0 -0
- /package/.morph/{standards → framework/standards}/infrastructure/azure/devops/azure-devops-setup.md +0 -0
- /package/.morph/{standards → framework/standards}/infrastructure/azure/devops/local-development.md +0 -0
- /package/.morph/{standards → framework/standards}/infrastructure/azure/services/functions.md +0 -0
- /package/.morph/{standards → framework/standards}/infrastructure/azure/services/service-bus.md +0 -0
- /package/.morph/{standards → framework/standards}/infrastructure/azure/services/storage.md +0 -0
- /package/.morph/{standards → framework/standards}/infrastructure/docker/easypanel-deploy.md +0 -0
- /package/.morph/{standards → framework/standards}/infrastructure/supabase/mcp-setup.md +0 -0
- /package/.morph/{standards → framework/standards}/infrastructure/supabase/supabase-auth.md +0 -0
- /package/.morph/{standards → framework/standards}/infrastructure/supabase/supabase-pgvector.md +0 -0
- /package/.morph/{standards → framework/standards}/infrastructure/supabase/supabase-rls.md +0 -0
- /package/.morph/{standards → framework/standards}/infrastructure/supabase/supabase-storage.md +0 -0
- /package/.morph/{standards → framework/standards}/integration/api/graphql.md +0 -0
- /package/.morph/{standards → framework/standards}/integration/api/grpc.md +0 -0
- /package/.morph/{standards → framework/standards}/integration/api/rest-design.md +0 -0
- /package/.morph/{standards → framework/standards}/integration/event-driven/cqrs.md +0 -0
- /package/.morph/{standards → framework/standards}/integration/event-driven/event-sourcing.md +0 -0
- /package/.morph/{standards → framework/standards}/integration/event-driven/service-bus.md +0 -0
- /package/.morph/{standards → framework/standards}/observability/logging.md +0 -0
- /package/.morph/{standards → framework/standards}/observability/metrics.md +0 -0
- /package/.morph/{standards → framework/standards}/observability/monitoring.md +0 -0
- /package/.morph/{standards → framework/standards}/observability/tracing.md +0 -0
- /package/.morph/{standards → framework/standards}/workflows/parallel-execution.md +0 -0
- /package/.morph/{standards → framework/standards}/workflows/thread-management.md +0 -0
- /package/.morph/{templates → framework/templates}/.idea/morph-templates.xml +0 -0
- /package/.morph/{templates → framework/templates}/.vscode/morph-templates.code-snippets +0 -0
- /package/.morph/{templates → framework/templates}/IDE-SNIPPETS.md +0 -0
- /package/.morph/{templates → framework/templates}/code/dotnet/backend/repository.cs +0 -0
- /package/.morph/{templates → framework/templates}/code/dotnet/backend/service.cs +0 -0
- /package/.morph/{templates → framework/templates}/code/dotnet/contracts/Commands.cs +0 -0
- /package/.morph/{templates → framework/templates}/code/dotnet/contracts/Entities.cs +0 -0
- /package/.morph/{templates → framework/templates}/code/dotnet/contracts/Queries.cs +0 -0
- /package/.morph/{templates → framework/templates}/code/dotnet/contracts/README.md +0 -0
- /package/.morph/{templates → framework/templates}/code/dotnet/contracts/api-contracts.cs +0 -0
- /package/.morph/{templates → framework/templates}/code/dotnet/contracts/contracts.cs +0 -0
- /package/.morph/{templates → framework/templates}/code/dotnet/database/migration.cs +0 -0
- /package/.morph/{templates → framework/templates}/code/dotnet/frontend/component.razor +0 -0
- /package/.morph/{templates → framework/templates}/code/dotnet/jobs/agent.cs +0 -0
- /package/.morph/{templates → framework/templates}/code/dotnet/jobs/job.cs +0 -0
- /package/.morph/{templates → framework/templates}/code/dotnet/test.cs +0 -0
- /package/.morph/{templates → framework/templates}/code/sql/rls-policy.sql +0 -0
- /package/.morph/{templates → framework/templates}/code/sql/supabase-migration.sql +0 -0
- /package/.morph/{templates → framework/templates}/code/sql/supabase-migration.template.sql +0 -0
- /package/.morph/{templates → framework/templates}/code/typescript/contracts.ts +0 -0
- /package/.morph/{templates → framework/templates}/docs/proposal.md +0 -0
- /package/.morph/{templates → framework/templates}/examples/design-system-examples.md +0 -0
- /package/.morph/{templates → framework/templates}/feature/decisions.md +0 -0
- /package/.morph/{templates → framework/templates}/feature/recap.md +0 -0
- /package/.morph/{templates → framework/templates}/feature/tasks.md +0 -0
- /package/.morph/{templates → framework/templates}/infrastructure/azure/Dockerfile.example +0 -0
- /package/.morph/{templates → framework/templates}/infrastructure/azure/README.md +0 -0
- /package/.morph/{templates → framework/templates}/infrastructure/azure/app-insights.bicep +0 -0
- /package/.morph/{templates → framework/templates}/infrastructure/azure/app-service.bicep +0 -0
- /package/.morph/{templates → framework/templates}/infrastructure/azure/container-app-env.bicep +0 -0
- /package/.morph/{templates → framework/templates}/infrastructure/azure/container-app.bicep +0 -0
- /package/.morph/{templates → framework/templates}/infrastructure/azure/deploy-checklist.md +0 -0
- /package/.morph/{templates → framework/templates}/infrastructure/azure/deploy.ps1 +0 -0
- /package/.morph/{templates → framework/templates}/infrastructure/azure/deploy.sh +0 -0
- /package/.morph/{templates → framework/templates}/infrastructure/azure/key-vault.bicep +0 -0
- /package/.morph/{templates → framework/templates}/infrastructure/azure/main.bicep +0 -0
- /package/.morph/{templates → framework/templates}/infrastructure/azure/parameters.dev.json +0 -0
- /package/.morph/{templates → framework/templates}/infrastructure/azure/parameters.prod.json +0 -0
- /package/.morph/{templates → framework/templates}/infrastructure/azure/parameters.staging.json +0 -0
- /package/.morph/{templates → framework/templates}/infrastructure/azure/sql-database.bicep +0 -0
- /package/.morph/{templates → framework/templates}/infrastructure/azure/storage.bicep +0 -0
- /package/.morph/{templates → framework/templates}/infrastructure/docker/Dockerfile.template +0 -0
- /package/.morph/{templates → framework/templates}/infrastructure/docker/docker-compose.template.yml +0 -0
- /package/.morph/{templates → framework/templates}/infrastructure/docker/dockerfile-api.dockerfile +0 -0
- /package/.morph/{templates → framework/templates}/infrastructure/docker/dockerfile-web.dockerfile +0 -0
- /package/.morph/{templates → framework/templates}/infrastructure/docker/easypanel.template.json +0 -0
- /package/.morph/{templates → framework/templates}/infrastructure/github/actions/azure-auth/action.yml.hbs +0 -0
- /package/.morph/{templates → framework/templates}/infrastructure/github/actions/docker-build-push/action.yml.hbs +0 -0
- /package/.morph/{templates → framework/templates}/infrastructure/github/actions/health-check/action.yml.hbs +0 -0
- /package/.morph/{templates → framework/templates}/infrastructure/github/workflows/deploy-easypanel.yml.hbs +0 -0
- /package/.morph/{templates → framework/templates}/infrastructure/github/workflows/docker-build-push.yml.hbs +0 -0
- /package/.morph/{templates → framework/templates}/infrastructure/github/workflows/dotnet-build.yml.hbs +0 -0
- /package/.morph/{templates → framework/templates}/integrations/asaas-client.cs +0 -0
- /package/.morph/{templates → framework/templates}/integrations/asaas-webhook.cs +0 -0
- /package/.morph/{templates → framework/templates}/integrations/azure-identity-config.cs +0 -0
- /package/.morph/{templates → framework/templates}/integrations/clerk-config.cs +0 -0
- /package/.morph/{templates → framework/templates}/meta-prompts/fusion/fusion-agent.md +0 -0
- /package/.morph/{templates → framework/templates}/meta-prompts/fusion/fusion-aggregator.md +0 -0
- /package/.morph/{templates → framework/templates}/meta-prompts/hops/hop-retry.md +0 -0
- /package/.morph/{templates → framework/templates}/meta-prompts/hops/hop-validation.md +0 -0
- /package/.morph/{templates → framework/templates}/meta-prompts/hops/hop-wrapper.md +0 -0
- /package/.morph/{templates → framework/templates}/meta-prompts/parallel-workers/parallel-coordinator.md +0 -0
- /package/.morph/{templates → framework/templates}/meta-prompts/squad-leaders/backend-squad.md +0 -0
- /package/.morph/{templates → framework/templates}/meta-prompts/squad-leaders/frontend-squad.md +0 -0
- /package/.morph/{templates → framework/templates}/meta-prompts/squad-leaders/squad-leader.md +0 -0
- /package/.morph/{templates → framework/templates}/meta-prompts/validators/checkpoint-validator.md +0 -0
- /package/.morph/{templates → framework/templates}/saas/subscription.cs +0 -0
- /package/.morph/{templates → framework/templates}/saas/tenant.cs +0 -0
- /package/.morph/{templates → framework/templates}/state.template.json +0 -0
- /package/.morph/{templates → framework/templates}/ui/FluentDesignTheme.cs +0 -0
- /package/.morph/{templates → framework/templates}/ui/MudTheme.cs +0 -0
- /package/.morph/{templates → framework/templates}/ui/design-system.css +0 -0
- /package/framework/{skills/level-2-domains → agents}/README.md +0 -0
- /package/framework/hooks/{commit-msg → git/commit-msg}/conventional-commits.sh +0 -0
- /package/framework/hooks/{pre-commit → git/pre-commit}/agents.sh +0 -0
- /package/framework/hooks/{pre-commit → git/pre-commit}/orchestrator.sh +0 -0
- /package/framework/hooks/{pre-commit → git/pre-commit}/specs.sh +0 -0
- /package/framework/hooks/{pre-push → git/pre-push}/run-tests.sh +0 -0
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: phase-design
|
|
3
|
+
description: MORPH-SPEC Phase 2 (Design). Analyzes codebase/schema, then produces spec.md, contracts.cs, schema-analysis.md, and decisions.md for the feature. Use after setup phase to create a full technical specification with C# contracts based on the real database schema and architecture decision records.
|
|
4
|
+
argument-hint: "[feature-name]"
|
|
5
|
+
user-invocable: false
|
|
6
|
+
allowed-tools: Read, Write, Edit, Bash, Glob, Grep
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# MORPH Design - FASE 2
|
|
10
|
+
|
|
11
|
+
> INTERNAL: Workflow skill used by /morph-proposal during automated phase orchestration. Not a user command.
|
|
12
|
+
|
|
13
|
+
Expanda a proposta em especificação técnica completa, contracts, decisões arquiteturais e estimativa de custos.
|
|
14
|
+
|
|
15
|
+
## Pré-requisitos
|
|
16
|
+
|
|
17
|
+
- [ ] FASE 1 (Setup) concluída
|
|
18
|
+
- [ ] FASE 1.5 (UI/UX) concluída OU pulada (se não houver front-end)
|
|
19
|
+
- [ ] Proposta aprovada pelo usuário
|
|
20
|
+
|
|
21
|
+
## Ferramentas Recomendadas
|
|
22
|
+
|
|
23
|
+
> **Ref:** `framework/skills/level-0-meta/tool-usage-guide/SKILL.md` para guia completo.
|
|
24
|
+
> **Ref:** `framework/standards/integration/mcp/mcp-tools.md` para referência MCP.
|
|
25
|
+
> **Example:** `references/spec-example.md` — filled-in spec.md showing expected output quality.
|
|
26
|
+
|
|
27
|
+
| Ação | Ferramenta | Alternativa |
|
|
28
|
+
|------|------------|-------------|
|
|
29
|
+
| Ler proposal + UI specs | **Read** output files | — |
|
|
30
|
+
| Obter schema do banco | **Supabase MCP** `list_tables()`, `get_table_schema()` | **Grep** queries + **Read** types |
|
|
31
|
+
| Obter relacionamentos de FK | **Supabase MCP** `get_relationships()` | **Grep** JOIN/FK no código |
|
|
32
|
+
| Obter políticas RLS | **Supabase MCP** `query()` com pg_policies | **Read** arquivos de políticas |
|
|
33
|
+
| Encontrar arquivos de query (fallback) | **Grep** `\.from\(` em `*.ts,*.tsx,*.js,*.cs` | — |
|
|
34
|
+
| Encontrar definições de tipo (fallback) | **Glob** `src/**/types/**/*.ts` ou `**/Entities/**/*.cs` | — |
|
|
35
|
+
| Ler arquivos de query/tipos (fallback) | **Read** cada arquivo encontrado | — |
|
|
36
|
+
| Pesquisar biblioteca para ADR | **Context7 MCP** `query_docs()` | **WebSearch** + **WebFetch** |
|
|
37
|
+
| Buscar padrões no código | **GitHub MCP** `search_code()` | **Grep** padrões no projeto |
|
|
38
|
+
| Renderizar template contracts.cs | **Bash** `npx morph-spec template render code/dotnet/contracts/contracts.cs ...` | — |
|
|
39
|
+
| Renderizar template spec.md | **Bash** `npx morph-spec template render docs/spec ...` | — |
|
|
40
|
+
| Renderizar template decisions.md | **Bash** `npx morph-spec template render docs/decisions ...` | — |
|
|
41
|
+
| Criar schema-analysis.md | **Write** no diretório de outputs | — |
|
|
42
|
+
| Atualizar state | **Bash** `npx morph-spec state mark-output ...` | — |
|
|
43
|
+
|
|
44
|
+
**MCPs desta fase:** Supabase (schema analysis — **PRIORITÁRIO**), Context7 (research), GitHub (code search).
|
|
45
|
+
|
|
46
|
+
**Anti-padrões:**
|
|
47
|
+
- ❌ Adivinhar nomes de campos sem verificar schema (use MCP ou Grep primeiro!)
|
|
48
|
+
- ❌ Task agent para ler um único arquivo spec (use Read direto)
|
|
49
|
+
- ❌ WebSearch para schema do banco (use Supabase MCP ou análise de código)
|
|
50
|
+
- ❌ Escrever contracts.cs do zero (use template render)
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Workflow
|
|
55
|
+
|
|
56
|
+
### Passo 1: Carregar Contexto e Standards
|
|
57
|
+
|
|
58
|
+
**Obtenha feature state e standards context:**
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
npx morph-spec state get $ARGUMENTS
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Parse o JSON para obter `activeAgents`, então use standards context (já carregado na FASE 1):
|
|
65
|
+
- Standards relevantes estão em `standardsSummary` do detect-agents
|
|
66
|
+
- Padrões já incluem project overrides + inferred learnings
|
|
67
|
+
|
|
68
|
+
**Leia outputs existentes:**
|
|
69
|
+
1. `.morph/features/$ARGUMENTS/0-proposal/proposal.md` - Proposta inicial
|
|
70
|
+
2. `.morph/features/$ARGUMENTS/2-ui/*.md` - UI/UX specs (se existirem)
|
|
71
|
+
|
|
72
|
+
**Use standards context ao gerar spec.md:**
|
|
73
|
+
- Architecture standards → guiam Technical Architecture section
|
|
74
|
+
- Coding standards → definem contracts.cs patterns
|
|
75
|
+
- Azure standards → determinam Infrastructure Requirements
|
|
76
|
+
|
|
77
|
+
### Passo 2: Analisar Código Existente (CRÍTICO - FAZER ANTES DE CONTRACTS!)
|
|
78
|
+
|
|
79
|
+
**⚠️ ATENÇÃO:** Este passo é OBRIGATÓRIO antes de gerar `contracts.cs`. Previne geração de DTOs com nomes de campos errados.
|
|
80
|
+
|
|
81
|
+
**Delegate para skill dedicada:**
|
|
82
|
+
|
|
83
|
+
> **Ref:** `framework/skills/level-1-workflows/phase-codebase-analysis/SKILL.md` — workflow completo de análise de schema (MCP Supabase → fallback análise estática → SCHEMA-ANALYSIS.md → checkpoint de aprovação)
|
|
84
|
+
|
|
85
|
+
Execute o workflow de `phase-codebase-analysis.md` para:
|
|
86
|
+
1. Detectar se análise é necessária
|
|
87
|
+
2. Tentar MCP Supabase (preferencial) ou análise estática (fallback)
|
|
88
|
+
3. Mapear field name mismatches e type mismatches
|
|
89
|
+
4. Gerar `schema-analysis.md` com findings reais
|
|
90
|
+
5. Apresentar checkpoint ao usuário e aguardar aprovação
|
|
91
|
+
|
|
92
|
+
**Pule se:**
|
|
93
|
+
- Feature é 100% nova (sem dependências em código existente)
|
|
94
|
+
- Não há banco de dados ou APIs envolvidas
|
|
95
|
+
|
|
96
|
+
### Passo 3: Gerar `spec.md`
|
|
97
|
+
|
|
98
|
+
Crie `.morph/features/$ARGUMENTS/1-design/spec.md` com:
|
|
99
|
+
|
|
100
|
+
#### 3.1. Overview
|
|
101
|
+
- **Objetivo:** Resumo de 1-2 parágrafos
|
|
102
|
+
- **Usuários afetados:** Quem vai usar?
|
|
103
|
+
- **Problema resolvido:** Qual dor/necessidade?
|
|
104
|
+
|
|
105
|
+
#### 3.2. Functional Requirements
|
|
106
|
+
Lista detalhada de requisitos funcionais:
|
|
107
|
+
```markdown
|
|
108
|
+
### FR001: {Requisito}
|
|
109
|
+
**Description:** {O que deve fazer}
|
|
110
|
+
**Acceptance Criteria:**
|
|
111
|
+
- [ ] Critério 1
|
|
112
|
+
- [ ] Critério 2
|
|
113
|
+
**Priority:** High/Medium/Low
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
#### 3.3. Non-Functional Requirements
|
|
117
|
+
- Performance (tempos de resposta esperados)
|
|
118
|
+
- Segurança (autenticação, autorização)
|
|
119
|
+
- Escalabilidade (volume de dados/usuários)
|
|
120
|
+
- Disponibilidade (uptime esperado)
|
|
121
|
+
|
|
122
|
+
#### 3.4. Technical Architecture
|
|
123
|
+
- **Camadas:** (Presentation, Application, Domain, Infrastructure)
|
|
124
|
+
- **Patterns:** (Repository, CQRS, DI, etc.)
|
|
125
|
+
- **Dependências:** Bibliotecas/serviços externos necessários
|
|
126
|
+
|
|
127
|
+
#### 3.5. Data Model
|
|
128
|
+
- Entities principais
|
|
129
|
+
- Relacionamentos (1:1, 1:N, N:N)
|
|
130
|
+
- Campos obrigatórios vs opcionais
|
|
131
|
+
- Validações de negócio
|
|
132
|
+
|
|
133
|
+
#### 3.6. Infrastructure Requirements
|
|
134
|
+
Se houver recursos Azure:
|
|
135
|
+
- Banco de dados (Azure SQL, Cosmos DB)
|
|
136
|
+
- Storage (Blob Storage)
|
|
137
|
+
- Compute (Container Apps, App Service)
|
|
138
|
+
- Monitoring (App Insights)
|
|
139
|
+
|
|
140
|
+
**SEMPRE usar Bicep para infra!**
|
|
141
|
+
|
|
142
|
+
### Passo 4: Gerar `contracts.cs` (BASEADO NO SCHEMA REAL!)
|
|
143
|
+
|
|
144
|
+
**⚠️ IMPORTANTE:** Use `schema-analysis.md` (do Passo 2) para gerar DTOs corretos!
|
|
145
|
+
|
|
146
|
+
**Renderizar template:**
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
# Use o template de contracts com dados do schema-analysis.md:
|
|
150
|
+
npx morph-spec template render \
|
|
151
|
+
code/dotnet/contracts/contracts.cs \
|
|
152
|
+
.morph/features/$ARGUMENTS/1-design/contracts.cs \
|
|
153
|
+
'{
|
|
154
|
+
"FEATURE_NAME": "$ARGUMENTS",
|
|
155
|
+
"NAMESPACE": "{ProjectNamespace}",
|
|
156
|
+
"dtos": [...], # Extrair de schema-analysis.md
|
|
157
|
+
"interfaces": [...],
|
|
158
|
+
"enums": [...],
|
|
159
|
+
"valueObjects": [...]
|
|
160
|
+
}'
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
**OU use Read tool para ler template:**
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
# Leia o template base:
|
|
167
|
+
Read: .morph/framework/templates/code/dotnet/contracts/contracts.cs.hbs
|
|
168
|
+
|
|
169
|
+
# Preencha manualmente usando dados de schema-analysis.md
|
|
170
|
+
# Template contém placeholders para:
|
|
171
|
+
# - {{FEATURE_NAME_PASCAL}}
|
|
172
|
+
# - {{NAMESPACE}}
|
|
173
|
+
# - {{#each dtos}}...{{/each}}
|
|
174
|
+
# - {{#each interfaces}}...{{/each}}
|
|
175
|
+
# - {{#each enums}}...{{/each}}
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
**Padrões obrigatórios (já incluídos no template):**
|
|
179
|
+
- Records para DTOs (immutable)
|
|
180
|
+
- Interfaces para serviços
|
|
181
|
+
- CancellationToken em métodos async
|
|
182
|
+
- Nullable reference types habilitados
|
|
183
|
+
- **USAR NOMES DE CAMPOS REAIS DO SCHEMA** (NÃO assumir!)
|
|
184
|
+
- XML documentation comments
|
|
185
|
+
- Value objects para complex types
|
|
186
|
+
|
|
187
|
+
**⚠️ CHECKPOINT: Verificar contra schema-analysis.md**
|
|
188
|
+
- [ ] Todos os field names correspondem ao schema real?
|
|
189
|
+
- [ ] Tipos de dados corretos (JSONB → JsonObject, não string)?
|
|
190
|
+
- [ ] Nullability correta (campo opcional no banco → nullable no DTO)?
|
|
191
|
+
- [ ] Relacionamentos mapeados corretamente?
|
|
192
|
+
- [ ] Template foi renderizado corretamente?
|
|
193
|
+
|
|
194
|
+
### Passo 5: Iniciar `decisions.md`
|
|
195
|
+
|
|
196
|
+
**Renderizar template:**
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
# Use o template de decisions:
|
|
200
|
+
Read: .morph/framework/templates/feature/decisions.md
|
|
201
|
+
|
|
202
|
+
# OU renderize via CLI:
|
|
203
|
+
npx morph-spec template render \
|
|
204
|
+
feature/decisions \
|
|
205
|
+
.morph/features/$ARGUMENTS/1-design/decisions.md \
|
|
206
|
+
'{
|
|
207
|
+
"FEATURE_NAME": "$ARGUMENTS",
|
|
208
|
+
"DATE": "{{DATE}}",
|
|
209
|
+
"decisions": []
|
|
210
|
+
}'
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
**Template contém estrutura para ADRs (Architecture Decision Records):**
|
|
214
|
+
- Status, Context, Decision, Consequences
|
|
215
|
+
- Pros/Cons analysis
|
|
216
|
+
- Alternatives Considered section
|
|
217
|
+
- Date tracking
|
|
218
|
+
|
|
219
|
+
**ADRs obrigatórios:**
|
|
220
|
+
- Escolha de biblioteca UI (se FASE 1.5 executou)
|
|
221
|
+
- Padrões arquiteturais (CQRS, Repository, etc.)
|
|
222
|
+
- Recursos Azure (se houver infra)
|
|
223
|
+
- Integrações externas (APIs, webhooks, etc.)
|
|
224
|
+
- Análise de custos (se houver recursos pagos)
|
|
225
|
+
|
|
226
|
+
### Passo 6: Estimar Custos
|
|
227
|
+
|
|
228
|
+
Se houver recursos Azure na spec:
|
|
229
|
+
|
|
230
|
+
**Limites configuráveis** (em config.json):
|
|
231
|
+
- `costs.limits.freeTierOnly`: $0 (apenas free tier)
|
|
232
|
+
- `costs.limits.withApproval`: $10 (requer confirmação do usuário)
|
|
233
|
+
- `costs.limits.requiresADR`: $10 (requer ADR documentado)
|
|
234
|
+
|
|
235
|
+
Documente custos em `decisions.md` e atualize state:
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
npx morph-spec state set $ARGUMENTS costs.estimated {X.XX}
|
|
239
|
+
npx morph-spec state set $ARGUMENTS costs.approved {true/false}
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### Passo 7: Atualizar State
|
|
243
|
+
|
|
244
|
+
```bash
|
|
245
|
+
npx morph-spec state set $ARGUMENTS phase design
|
|
246
|
+
npx morph-spec state mark-output $ARGUMENTS schema-analysis
|
|
247
|
+
npx morph-spec state mark-output $ARGUMENTS spec
|
|
248
|
+
npx morph-spec state mark-output $ARGUMENTS contracts
|
|
249
|
+
npx morph-spec state mark-output $ARGUMENTS decisions
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
## Outputs Gerados
|
|
253
|
+
|
|
254
|
+
- `.morph/features/$ARGUMENTS/1-design/schema-analysis.md` - **NOVO!** Análise do schema real
|
|
255
|
+
- `.morph/features/$ARGUMENTS/1-design/spec.md` - Especificação técnica completa
|
|
256
|
+
- `.morph/features/$ARGUMENTS/1-design/contracts.cs` - Interfaces, DTOs, Enums (baseados no schema real!)
|
|
257
|
+
- `.morph/features/$ARGUMENTS/1-design/decisions.md` - ADRs (novo ou atualizado)
|
|
258
|
+
- State atualizado com custos estimados
|
|
259
|
+
|
|
260
|
+
## PAUSA OBRIGATÓRIA
|
|
261
|
+
|
|
262
|
+
Apresente ao usuário 3 ações sugeridas:
|
|
263
|
+
|
|
264
|
+
1. **Aprovar design e continuar para clarificação**
|
|
265
|
+
2. **Ajustar escopo/complexidade** - Revisar spec.md
|
|
266
|
+
3. **Modificar contracts** - Ajustar interfaces/DTOs
|
|
267
|
+
|
|
268
|
+
## Critérios de Avanço
|
|
269
|
+
|
|
270
|
+
- [x] `spec.md` completo com todos os requisitos
|
|
271
|
+
- [x] `contracts.cs` com interfaces e DTOs
|
|
272
|
+
- [x] `decisions.md` com ADRs relevantes
|
|
273
|
+
- [x] Custos estimados e documentados (se houver infra)
|
|
274
|
+
- [x] State atualizado
|
|
275
|
+
- [x] Usuário aprovou design
|
|
276
|
+
|
|
277
|
+
---
|
|
278
|
+
|
|
279
|
+
## Integração com Superpowers
|
|
280
|
+
|
|
281
|
+
> Disponível quando o plugin `superpowers` está instalado.
|
|
282
|
+
|
|
283
|
+
| Skill | Quando Usar | Invocação |
|
|
284
|
+
|-------|-------------|-----------|
|
|
285
|
+
| `writing-plans` | Após spec aprovado, para estruturar abordagem de implementação | `Skill(superpowers:writing-plans)` |
|
|
286
|
+
| `brainstorming` | Para explorar alternativas de arquitetura (use morph-spec version) | Use `brainstorming` (morph-spec version) |
|
|
287
|
+
|
|
288
|
+
---
|
|
289
|
+
|
|
290
|
+
## Outputs desta Fase
|
|
291
|
+
|
|
292
|
+
<!-- morph:outputs:design -->
|
|
293
|
+
| Output | Caminho |
|
|
294
|
+
|--------|---------|
|
|
295
|
+
| `schemaAnalysis` | `.morph/features/{feature}/1-design/schema-analysis.md` |
|
|
296
|
+
| `spec` | `.morph/features/{feature}/1-design/spec.md` |
|
|
297
|
+
| `contracts` | `.morph/features/{feature}/1-design/contracts.cs` |
|
|
298
|
+
| `decisions` | `.morph/features/{feature}/1-design/decisions.md` |
|
|
299
|
+
<!-- /morph:outputs -->
|
|
300
|
+
|
|
301
|
+
---
|
|
302
|
+
|
|
303
|
+
Continuar automaticamente para FASE 3 (Clarify) após aprovação.
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
# Feature Specification: Photo Processing Pipeline
|
|
2
|
+
|
|
3
|
+
> Example of a well-structured spec.md. This is a filled-in reference — not a template.
|
|
4
|
+
|
|
5
|
+
| Field | Value |
|
|
6
|
+
|-------|-------|
|
|
7
|
+
| **ID** | photo-processing |
|
|
8
|
+
| **Status** | Approved |
|
|
9
|
+
| **Created** | 2025-01-15 |
|
|
10
|
+
| **Stack** | blazor-azure |
|
|
11
|
+
| **Complexity** | Medium |
|
|
12
|
+
| **Estimated Cost** | ~$5.50/month |
|
|
13
|
+
| **Agents** | Core: All / Specialists: azure-architect, dotnet-senior, blazor-builder |
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Overview
|
|
18
|
+
|
|
19
|
+
**Problem:** Users cannot submit photos for AI transformation — the core product value proposition is blocked.
|
|
20
|
+
|
|
21
|
+
**Solution:** End-to-end pipeline: upload → Blob Storage → Hangfire background job → AI processing → download link.
|
|
22
|
+
|
|
23
|
+
**Success Criteria:**
|
|
24
|
+
- [ ] Upload endpoint accepts .jpg/.png up to 10MB and stores in Azure Blob
|
|
25
|
+
- [ ] Background job processes photo and updates status to Completed within 120s (p95)
|
|
26
|
+
- [ ] Status polling page reflects real-time processing progress
|
|
27
|
+
- [ ] Failed jobs retry up to 3 times with exponential backoff
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Requirements
|
|
32
|
+
|
|
33
|
+
**Functional:**
|
|
34
|
+
FR1: Upload photo (.jpg/.png, max 10MB) via Blazor form
|
|
35
|
+
FR2: Store photo in Azure Blob Storage under `uploads/{jobId}`
|
|
36
|
+
FR3: Enqueue Hangfire background job for AI processing
|
|
37
|
+
FR4: Status polling endpoint returns `{ status, progress, createdAt }`
|
|
38
|
+
FR5: Download endpoint redirects to Blob URL for completed jobs
|
|
39
|
+
|
|
40
|
+
**Non-Functional:**
|
|
41
|
+
NFR1: Processing time < 120s for p95 of requests
|
|
42
|
+
NFR2: Upload endpoint < 2s response time
|
|
43
|
+
NFR3: Retry 3x on AI API failure with 5s/30s/120s backoff
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## User Stories
|
|
48
|
+
|
|
49
|
+
### US001: Upload Photo
|
|
50
|
+
**As** an authenticated user **I want** to upload a photo **so that** the AI can transform it.
|
|
51
|
+
|
|
52
|
+
**Acceptance Criteria:**
|
|
53
|
+
1. Accepts .jpg and .png files only — rejects other formats with clear error
|
|
54
|
+
2. Rejects files larger than 10MB with a specific error message
|
|
55
|
+
3. Returns a `jobId` and redirects to `/processing/{jobId}` on success
|
|
56
|
+
|
|
57
|
+
**Edge Cases:**
|
|
58
|
+
- Network timeout during upload: show retry button
|
|
59
|
+
- Duplicate upload: create new job each time (idempotency not required)
|
|
60
|
+
|
|
61
|
+
### US002: Track Progress
|
|
62
|
+
**As** a user who uploaded a photo **I want** to see real-time status **so that** I know when my photo is ready.
|
|
63
|
+
|
|
64
|
+
**Acceptance Criteria:**
|
|
65
|
+
1. Page polls `/api/status/{jobId}` every 5 seconds
|
|
66
|
+
2. Shows status label: Pending / Processing / Completed / Failed
|
|
67
|
+
3. Shows "Download" button when status = Completed
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Technical Design
|
|
72
|
+
|
|
73
|
+
### Stack
|
|
74
|
+
|
|
75
|
+
| Component | Technology |
|
|
76
|
+
|-----------|------------|
|
|
77
|
+
| Frontend | Blazor Server |
|
|
78
|
+
| Backend | .NET 10 / C# 14 Minimal API |
|
|
79
|
+
| Background Jobs | Hangfire (self-hosted) |
|
|
80
|
+
| Storage | Azure Blob Storage (LRS) |
|
|
81
|
+
| Database | Azure SQL |
|
|
82
|
+
|
|
83
|
+
### Data Model
|
|
84
|
+
|
|
85
|
+
#### ProcessingJob
|
|
86
|
+
|
|
87
|
+
| Column | Type | Constraints |
|
|
88
|
+
|--------|------|-------------|
|
|
89
|
+
| Id | Guid | PK, default NEWID() |
|
|
90
|
+
| OriginalPhotoUrl | nvarchar(500) | NOT NULL |
|
|
91
|
+
| ProcessedPhotoUrl | nvarchar(500) | NULL (populated after processing) |
|
|
92
|
+
| Status | int | NOT NULL, default 0 (Pending) |
|
|
93
|
+
| ErrorMessage | nvarchar(1000) | NULL |
|
|
94
|
+
| RetryCount | int | NOT NULL, default 0 |
|
|
95
|
+
| CreatedAt | datetime2 | NOT NULL, default GETUTCDATE() |
|
|
96
|
+
| UpdatedAt | datetime2 | NOT NULL |
|
|
97
|
+
|
|
98
|
+
#### ProcessingStatus Enum
|
|
99
|
+
|
|
100
|
+
```csharp
|
|
101
|
+
public enum ProcessingStatus
|
|
102
|
+
{
|
|
103
|
+
Pending = 0,
|
|
104
|
+
Processing = 1,
|
|
105
|
+
Completed = 2,
|
|
106
|
+
Failed = 100
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Contracts
|
|
111
|
+
|
|
112
|
+
```csharp
|
|
113
|
+
// Commands
|
|
114
|
+
public record UploadPhotoCommand(IFormFile Photo, string? Email);
|
|
115
|
+
public record UploadPhotoResult(Guid JobId);
|
|
116
|
+
|
|
117
|
+
// Queries
|
|
118
|
+
public record GetJobStatusQuery(Guid JobId);
|
|
119
|
+
public record JobStatusDto(Guid JobId, ProcessingStatus Status, string? ProcessedPhotoUrl, DateTime CreatedAt);
|
|
120
|
+
|
|
121
|
+
// Service Interface
|
|
122
|
+
public interface IPhotoProcessingService
|
|
123
|
+
{
|
|
124
|
+
Task<UploadPhotoResult> UploadAsync(UploadPhotoCommand command, CancellationToken ct);
|
|
125
|
+
Task<JobStatusDto> GetStatusAsync(GetJobStatusQuery query, CancellationToken ct);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Hangfire Job
|
|
129
|
+
public interface IPhotoProcessingJob
|
|
130
|
+
{
|
|
131
|
+
Task ProcessAsync(Guid jobId, CancellationToken ct);
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## UI/UX Design
|
|
138
|
+
|
|
139
|
+
### Upload Page (/upload)
|
|
140
|
+
|
|
141
|
+
```
|
|
142
|
+
┌─────────────────────────────────────┐
|
|
143
|
+
│ Upload Photo │
|
|
144
|
+
│ ───────────────────────────────── │
|
|
145
|
+
│ [📁 Select File] photo.jpg (2.3MB) │
|
|
146
|
+
│ │
|
|
147
|
+
│ Allowed: JPG, PNG — Max: 10MB │
|
|
148
|
+
│ │
|
|
149
|
+
│ [Upload →] │
|
|
150
|
+
│ │
|
|
151
|
+
│ Error state: │
|
|
152
|
+
│ ⚠ File too large. Max size is 10MB. │
|
|
153
|
+
└─────────────────────────────────────┘
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Status Page (/processing/{jobId})
|
|
157
|
+
|
|
158
|
+
```
|
|
159
|
+
┌─────────────────────────────────────┐
|
|
160
|
+
│ Processing your photo │
|
|
161
|
+
│ ───────────────────────────────── │
|
|
162
|
+
│ Status: ⏳ Processing │
|
|
163
|
+
│ ████████░░░░░░░ 60% │
|
|
164
|
+
│ │
|
|
165
|
+
│ Started: 2025-01-15 14:32:01 │
|
|
166
|
+
│ │
|
|
167
|
+
│ [Completed state]: │
|
|
168
|
+
│ Status: ✅ Done! │
|
|
169
|
+
│ [📥 Download] │
|
|
170
|
+
└─────────────────────────────────────┘
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
## Flows
|
|
176
|
+
|
|
177
|
+
### Upload Flow
|
|
178
|
+
**Trigger:** User submits photo form
|
|
179
|
+
|
|
180
|
+
1. User selects file → client validates type/size before submit
|
|
181
|
+
2. `POST /api/upload` — server validates, uploads to Blob at `uploads/{jobId}/original.jpg`
|
|
182
|
+
3. Create `ProcessingJob` entity (status = Pending)
|
|
183
|
+
4. Enqueue Hangfire job with `jobId`
|
|
184
|
+
5. Return `{ jobId }` → client redirects to `/processing/{jobId}`
|
|
185
|
+
|
|
186
|
+
**End State:** Job queued, user on status page
|
|
187
|
+
|
|
188
|
+
### Processing Flow
|
|
189
|
+
**Trigger:** Hangfire executes job
|
|
190
|
+
|
|
191
|
+
1. Load `ProcessingJob` by Id, set status = Processing
|
|
192
|
+
2. Download original from Blob Storage
|
|
193
|
+
3. Call AI API (`POST /transform`, multipart/form-data)
|
|
194
|
+
4. On success: upload result to `uploads/{jobId}/processed.jpg`, set status = Completed
|
|
195
|
+
5. On failure: increment RetryCount, set status = Failed if RetryCount >= 3
|
|
196
|
+
|
|
197
|
+
**End State:** Job = Completed (photo available) or Failed (user sees error)
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
## Cost Estimate
|
|
202
|
+
|
|
203
|
+
| Resource | SKU | Monthly | Justification |
|
|
204
|
+
|----------|-----|---------|---------------|
|
|
205
|
+
| Blob Storage | LRS | $0.02 | ~500 photos/month × 2 files × avg 3MB |
|
|
206
|
+
| Azure SQL | Basic | $4.99 | < 100k jobs/month |
|
|
207
|
+
| Container App | Consumption | $0.49 | Scale to zero when idle |
|
|
208
|
+
| Hangfire | Self-hosted | $0.00 | In-process with Container App |
|
|
209
|
+
| **Total** | | **~$5.50** | |
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
## ADRs
|
|
214
|
+
|
|
215
|
+
### ADR-001: Hangfire over Azure Functions for Background Processing
|
|
216
|
+
**Status:** Accepted
|
|
217
|
+
**Context:** Need async processing for AI photo transformation (30–120s duration).
|
|
218
|
+
**Decision:** Hangfire (self-hosted in Container App)
|
|
219
|
+
**Alternatives:**
|
|
220
|
+
1. Azure Functions — serverless, auto-scaling, but cold start latency + $10/mo for 50k executions
|
|
221
|
+
2. Quartz.NET — more features (CRON, clustering), steeper learning curve
|
|
222
|
+
**Trade-offs:** Simplicity + zero cost vs scalability (Hangfire sufficient for MVP < 10k/month)
|
|
223
|
+
|
|
224
|
+
### ADR-002: Polling over WebSockets for Status Updates
|
|
225
|
+
**Status:** Accepted
|
|
226
|
+
**Context:** Users need real-time feedback; SSE/WebSocket adds Blazor Hub complexity.
|
|
227
|
+
**Decision:** 5-second HTTP polling from Blazor component
|
|
228
|
+
**Trade-offs:** Slightly higher server load vs significantly simpler implementation; polling sufficient at MVP scale
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
## Security
|
|
233
|
+
|
|
234
|
+
| Action | Required Policy |
|
|
235
|
+
|--------|-----------------|
|
|
236
|
+
| Upload | Authenticated user |
|
|
237
|
+
| View status | Owner of job (check UserId) |
|
|
238
|
+
| Download | Owner of job (check UserId) |
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
## Definition of Done
|
|
243
|
+
|
|
244
|
+
- [ ] Upload endpoint working, validated with unit + integration tests
|
|
245
|
+
- [ ] Hangfire job processes photos end-to-end in dev environment
|
|
246
|
+
- [ ] Status page shows correct states (Pending/Processing/Completed/Failed)
|
|
247
|
+
- [ ] Code review approved
|
|
248
|
+
- [ ] Deployed to staging environment
|
|
249
|
+
- [ ] `recap.md` generated with implementation notes
|
|
250
|
+
|
|
251
|
+
---
|
|
252
|
+
|
|
253
|
+
*MORPH-SPEC by Polymorphism Tech*
|