@polymorphism-tech/morph-spec 4.22.0 → 5.0.1

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.
Files changed (211) hide show
  1. package/CLAUDE.md +57 -71
  2. package/README.md +2 -2
  3. package/bin/morph-spec.js +224 -491
  4. package/claude-plugin.json +1 -1
  5. package/docs/CHEATSHEET.md +1 -1
  6. package/docs/QUICKSTART.md +1 -1
  7. package/framework/CLAUDE.md +55 -38
  8. package/framework/MORPH.md +244 -0
  9. package/framework/agents.json +127 -1198
  10. package/framework/commands/morph-apply.md +56 -240
  11. package/framework/commands/morph-archive.md +48 -85
  12. package/framework/commands/morph-preflight.md +7 -7
  13. package/framework/commands/morph-proposal.md +35 -191
  14. package/framework/commands/morph-status.md +19 -50
  15. package/framework/commands/morph-troubleshoot.md +2 -2
  16. package/framework/evals/rubrics/README.md +44 -0
  17. package/framework/evals/rubrics/architecture.md +46 -0
  18. package/framework/evals/rubrics/code-quality.md +50 -0
  19. package/framework/evals/rubrics/contracts.md +47 -0
  20. package/framework/evals/rubrics/test-coverage.md +50 -0
  21. package/framework/evals/scenarios/dotnet-crud.yaml +42 -0
  22. package/framework/evals/scenarios/nextjs-auth.yaml +38 -0
  23. package/framework/evals/suites/standard.yaml +5 -0
  24. package/framework/evals/trace-schema.md +67 -0
  25. package/framework/hooks/claude-code/core/README.md +3 -0
  26. package/framework/hooks/claude-code/core/denylist.json +14 -0
  27. package/framework/hooks/claude-code/{pre-tool-use → core}/enforce-phase-writes.js +5 -5
  28. package/framework/hooks/claude-code/core/post-edit-typecheck.js +69 -0
  29. package/framework/hooks/claude-code/core/pre-bash-denylist.js +29 -0
  30. package/framework/hooks/claude-code/{pre-tool-use → core}/protect-spec-files.js +4 -6
  31. package/framework/hooks/claude-code/{stop → core}/validate-completion.js +13 -82
  32. package/framework/hooks/shared/phase-utils.js +20 -31
  33. package/framework/hooks/shared/state-reader.js +4 -5
  34. package/framework/{skills/level-0-meta/mcp-registry.json → mcp/registry.json} +254 -243
  35. package/framework/phases.json +41 -115
  36. package/framework/rubrics/eval-rubric.json +66 -0
  37. package/framework/skills/README.md +39 -64
  38. package/framework/skills/core/README.md +3 -0
  39. package/framework/skills/core/morph-brainstorming/SKILL.md +102 -0
  40. package/framework/skills/core/morph-eval/SKILL.md +57 -0
  41. package/framework/skills/core/morph-implement/SKILL.md +83 -0
  42. package/framework/skills/core/morph-plan/SKILL.md +64 -0
  43. package/framework/skills/core/morph-review/SKILL.md +62 -0
  44. package/framework/skills/core/morph-stack-scan/SKILL.md +109 -0
  45. package/framework/skills/core/morph-standards/SKILL.md +49 -0
  46. package/framework/templates/CLAUDE.md.core.guide.md +29 -0
  47. package/framework/templates/CLAUDE.md.core.template +22 -0
  48. package/framework/templates/REGISTRY.json +4 -4
  49. package/framework/workflows/configs/fast-track.json +5 -10
  50. package/framework/workflows/configs/full.json +4 -8
  51. package/framework/workflows/configs/quick.json +32 -0
  52. package/framework/workflows/configs/standard.json +57 -64
  53. package/package.json +7 -6
  54. package/src/commands/mcp/mcp-setup.js +58 -31
  55. package/src/commands/project/doctor.js +69 -70
  56. package/src/commands/project/init.js +26 -5
  57. package/src/commands/project/status.js +18 -19
  58. package/src/commands/state/approve.js +1 -1
  59. package/src/commands/validation/validate-feature.js +18 -112
  60. package/src/core/paths/output-schema.js +133 -152
  61. package/src/core/state/phase-state-machine.js +10 -24
  62. package/src/core/state/state-manager.js +17 -17
  63. package/src/core/workflows/workflow-detector.js +214 -31
  64. package/src/core/workflows/workflow-router.js +204 -0
  65. package/src/dashboard/app/pages/AgentMap.jsx +32 -33
  66. package/src/dashboard/app/pages/LiveState.jsx +1 -1
  67. package/src/dashboard/app/pages/PhasePipeline.jsx +2 -4
  68. package/src/dashboard/app/pages/SkillsLibrary.jsx +2 -3
  69. package/src/dashboard/app/pages/Workflows.jsx +2 -2
  70. package/src/dashboard/scanner/agents-scanner.js +30 -35
  71. package/src/lib/agents/metrics-aggregator.js +1 -1
  72. package/src/lib/agents/output-collector.js +7 -9
  73. package/src/lib/context/context-builder.js +289 -0
  74. package/src/lib/detectors/claude-config-detector.js +19 -3
  75. package/src/lib/generators/context-generator.js +20 -42
  76. package/src/lib/generators/index.js +1 -0
  77. package/src/lib/generators/mandate-generator.js +512 -0
  78. package/src/lib/generators/metadata-extractor.js +1 -1
  79. package/src/lib/generators/recap-generator.js +3 -4
  80. package/src/lib/installers/mcp-installer.js +300 -92
  81. package/src/lib/phase-chain/phase-validator.js +36 -40
  82. package/src/lib/stack/stack-profile.js +74 -91
  83. package/src/lib/tasks/task-parser.js +1 -1
  84. package/src/lib/tasks/wave-resolver.js +353 -0
  85. package/src/lib/validators/checkpoint-persistence.js +2 -2
  86. package/src/lib/validators/content/cross-phase-validator.js +281 -0
  87. package/src/lib/validators/content/index.js +1 -0
  88. package/src/lib/validators/shared/emit-validator-dispatch.js +6 -56
  89. package/src/scripts/global-install.js +2 -27
  90. package/src/utils/agents-installer.js +224 -447
  91. package/src/utils/claude-settings-manager.js +57 -15
  92. package/src/utils/file-copier.js +1 -0
  93. package/src/utils/hooks-installer.js +15 -117
  94. package/src/utils/skills-installer.js +12 -18
  95. package/bin/detect-agents.js +0 -226
  96. package/bin/task-manager.js +0 -1036
  97. package/framework/agents/README.md +0 -13
  98. package/framework/agents/ai-agents/ai-system-architect.md +0 -194
  99. package/framework/agents/ai-agents/vector-search-expert.md +0 -247
  100. package/framework/agents/architecture/architecture-expert.md +0 -98
  101. package/framework/agents/architecture/morph-spec-architect.md +0 -66
  102. package/framework/agents/architecture/packages-validator.md +0 -89
  103. package/framework/agents/architecture/security-expert.md +0 -79
  104. package/framework/agents/architecture/seo-growth-hacker.md +0 -168
  105. package/framework/agents/architecture/standards-architect.md +0 -153
  106. package/framework/agents/backend/dotnet-senior.md +0 -163
  107. package/framework/agents/backend/ef-modeler.md +0 -119
  108. package/framework/agents/backend/hangfire-orchestrator.md +0 -133
  109. package/framework/agents/backend/ms-agent-expert.md +0 -55
  110. package/framework/agents/backend/neon-expert.md +0 -379
  111. package/framework/agents/frontend/css-specialist.md +0 -89
  112. package/framework/agents/frontend/design-system-validator.md +0 -100
  113. package/framework/agents/frontend/gsap-animator.md +0 -131
  114. package/framework/agents/frontend/nextjs-component-validator.md +0 -97
  115. package/framework/agents/frontend/nextjs-expert.md +0 -201
  116. package/framework/agents/frontend/ui-designer.md +0 -259
  117. package/framework/agents/infrastructure/infra-architect.md +0 -215
  118. package/framework/agents/integrations/asaas-financial.md +0 -138
  119. package/framework/agents/integrations/neon-auth.md +0 -151
  120. package/framework/agents/integrations/resend-email.md +0 -127
  121. package/framework/hooks/claude-code/post-tool-use/agent-complete.js +0 -122
  122. package/framework/hooks/claude-code/post-tool-use/dispatch.js +0 -363
  123. package/framework/hooks/claude-code/post-tool-use/handle-tool-failure.js +0 -78
  124. package/framework/hooks/claude-code/post-tool-use/validator-feedback.js +0 -194
  125. package/framework/hooks/claude-code/pre-compact/save-morph-context.js +0 -199
  126. package/framework/hooks/claude-code/pre-tool-use/task-tracking-guard.js +0 -55
  127. package/framework/hooks/claude-code/session-start/inject-morph-context.js +0 -323
  128. package/framework/hooks/claude-code/session-start/post-compact-restore.js +0 -41
  129. package/framework/hooks/claude-code/session-start/resume-context.js +0 -77
  130. package/framework/hooks/claude-code/teammate-idle/teammate-idle.js +0 -90
  131. package/framework/hooks/claude-code/user-prompt/enrich-prompt.js +0 -114
  132. package/framework/hooks/shared/compact-restore.js +0 -123
  133. package/framework/hooks/shared/dispatch-helpers.js +0 -147
  134. package/framework/hooks/shared/skill-reminder-helpers.js +0 -79
  135. package/framework/hooks/shared/stale-task-reset.js +0 -57
  136. package/framework/hooks/shared/worktree-helpers.js +0 -75
  137. package/framework/skills/level-0-meta/README.md +0 -7
  138. package/framework/skills/level-0-meta/morph-agent-teams/SKILL.md +0 -472
  139. package/framework/skills/level-0-meta/morph-brainstorming/SKILL.md +0 -174
  140. package/framework/skills/level-0-meta/morph-brainstorming/references/proposal-example.md +0 -138
  141. package/framework/skills/level-0-meta/morph-checklist/SKILL.md +0 -145
  142. package/framework/skills/level-0-meta/morph-code-review/SKILL.md +0 -250
  143. package/framework/skills/level-0-meta/morph-code-review/references/review-example.md +0 -164
  144. package/framework/skills/level-0-meta/morph-code-review/references/review-guidelines.md +0 -100
  145. package/framework/skills/level-0-meta/morph-code-review/scripts/scan-csharp.mjs +0 -151
  146. package/framework/skills/level-0-meta/morph-code-review-nextjs/SKILL.md +0 -165
  147. package/framework/skills/level-0-meta/morph-code-review-nextjs/references/review-example-nextjs.md +0 -254
  148. package/framework/skills/level-0-meta/morph-code-review-nextjs/scripts/scan-nextjs.mjs +0 -189
  149. package/framework/skills/level-0-meta/morph-frontend-review/SKILL.md +0 -344
  150. package/framework/skills/level-0-meta/morph-frontend-review/scripts/scan-accessibility.mjs +0 -376
  151. package/framework/skills/level-0-meta/morph-gemini-image/SKILL.md +0 -290
  152. package/framework/skills/level-0-meta/morph-init/SKILL.md +0 -537
  153. package/framework/skills/level-0-meta/morph-parallel-dispatch/SKILL.md +0 -225
  154. package/framework/skills/level-0-meta/morph-post-implementation/SKILL.md +0 -401
  155. package/framework/skills/level-0-meta/morph-post-implementation/scripts/detect-dev-server.mjs +0 -153
  156. package/framework/skills/level-0-meta/morph-post-implementation/scripts/detect-stack.mjs +0 -234
  157. package/framework/skills/level-0-meta/morph-simulation-checklist/SKILL.md +0 -106
  158. package/framework/skills/level-0-meta/morph-tool-usage-guide/SKILL.md +0 -243
  159. package/framework/skills/level-0-meta/morph-tool-usage-guide/references/tools-per-phase.md +0 -169
  160. package/framework/skills/level-0-meta/morph-verification-before-completion/SKILL.md +0 -148
  161. package/framework/skills/level-0-meta/morph-verification-before-completion/scripts/check-phase-outputs.mjs +0 -110
  162. package/framework/skills/level-1-workflows/README.md +0 -7
  163. package/framework/skills/level-1-workflows/morph-phase-codebase-analysis/SKILL.md +0 -269
  164. package/framework/skills/level-1-workflows/morph-phase-design/SKILL.md +0 -453
  165. package/framework/skills/level-1-workflows/morph-phase-design/references/architecture-analysis-guide.md +0 -44
  166. package/framework/skills/level-1-workflows/morph-phase-design/references/spec-authoring-guide.md +0 -55
  167. package/framework/skills/level-1-workflows/morph-phase-design/references/spec-example.md +0 -253
  168. package/framework/skills/level-1-workflows/morph-phase-implement/.morph/logs/activity.json +0 -38
  169. package/framework/skills/level-1-workflows/morph-phase-implement/SKILL.md +0 -634
  170. package/framework/skills/level-1-workflows/morph-phase-implement/prompts/code-quality-reviewer-prompt.md +0 -50
  171. package/framework/skills/level-1-workflows/morph-phase-implement/prompts/implementer-prompt.md +0 -54
  172. package/framework/skills/level-1-workflows/morph-phase-implement/prompts/spec-reviewer-prompt.md +0 -47
  173. package/framework/skills/level-1-workflows/morph-phase-implement/references/recap-example.md +0 -132
  174. package/framework/skills/level-1-workflows/morph-phase-implement/references/vsa-implementation-guide.md +0 -92
  175. package/framework/skills/level-1-workflows/morph-phase-plan/SKILL.md +0 -257
  176. package/framework/skills/level-1-workflows/morph-phase-tasks/.morph/logs/activity.json +0 -14
  177. package/framework/skills/level-1-workflows/morph-phase-tasks/SKILL.md +0 -291
  178. package/framework/skills/level-1-workflows/morph-phase-tasks/references/task-planning-patterns.md +0 -143
  179. package/framework/skills/level-1-workflows/morph-phase-tasks/references/tasks-example.md +0 -404
  180. package/framework/skills/level-1-workflows/morph-phase-tasks/scripts/validate-tasks.mjs +0 -112
  181. package/framework/skills/level-1-workflows/morph-phase-uiux/SKILL.md +0 -995
  182. package/framework/skills/level-1-workflows/morph-scope-escalation/SKILL.md +0 -147
  183. package/framework/squad-templates/backend-only.json +0 -47
  184. package/framework/squad-templates/frontend-only.json +0 -56
  185. package/framework/squad-templates/full-stack.json +0 -74
  186. package/src/commands/agents/agent-metrics.js +0 -174
  187. package/src/commands/agents/audit-dispatch.js +0 -82
  188. package/src/commands/agents/detect-agents.js +0 -275
  189. package/src/commands/agents/dispatch-agents.js +0 -461
  190. package/src/commands/agents/index.js +0 -13
  191. package/src/commands/agents/manage-agents.js +0 -352
  192. package/src/commands/agents/project-metrics.js +0 -74
  193. package/src/commands/phase/phase-reset.js +0 -74
  194. package/src/commands/scope/escalate.js +0 -217
  195. package/src/commands/state/advance-phase.js +0 -600
  196. package/src/commands/state/phase-runner.js +0 -215
  197. package/src/commands/state/state.js +0 -444
  198. package/src/commands/task/expand.js +0 -100
  199. package/src/commands/tasks/index.js +0 -4
  200. package/src/commands/tasks/task.js +0 -105
  201. package/src/commands/templates/index.js +0 -5
  202. package/src/commands/templates/template-render.js +0 -93
  203. package/src/commands/trust/trust.js +0 -118
  204. package/src/lib/agents/agents-manager.js +0 -349
  205. package/src/lib/build/build-runner.js +0 -99
  206. package/src/lib/checkpoints/checkpoint-hooks.js +0 -111
  207. package/src/lib/contracts/sprint-contract-generator.js +0 -137
  208. package/src/lib/scope/impact-analyzer.js +0 -106
  209. package/src/lib/trust/trust-manager.js +0 -157
  210. package/src/utils/tier-helpers.js +0 -24
  211. /package/framework/hooks/claude-code/{post-tool-use → core}/loop-detect.js +0 -0
@@ -1,174 +0,0 @@
1
- ---
2
- name: morph-brainstorming
3
- description: Morph-spec-aware brainstorming that loads project context, explores multiple design approaches, asks clarifying questions, and produces proposal.md or decisions.md. Use before designing a feature, when facing architectural decisions with multiple valid approaches, or when a feature needs requirements exploration before committing to a direction.
4
- user-invocable: true
5
- argument-hint: "[feature-name or topic]"
6
- allowed-tools: Read, Bash, Glob, Grep, AskUserQuestion
7
- ---
8
-
9
- # Brainstorming — MORPH-SPEC Integrated
10
-
11
- > Explore context, ask questions, generate multiple approaches, and produce a design document before committing to implementation.
12
- >
13
- > **Example:** `references/proposal-example.md` — filled-in proposal.md showing expected quality.
14
-
15
- ## When to Use
16
-
17
- - **Phase 0 (Proposal):** Explore the feature request before writing `proposal.md`
18
- - **Phase 2 (Design):** Explore architectural alternatives before writing `spec.md`
19
- - **Any phase:** When facing a decision with multiple valid approaches
20
-
21
- ## Recommended Tools
22
-
23
- | Action | Tool | Alternative |
24
- |--------|------|-------------|
25
- | Load feature state | **Bash** `morph-spec state get $ARGUMENTS` | — |
26
- | Read project config | **Read** `.morph/config/config.json` | — |
27
- | Scan existing code | **Glob** / **Grep** | — |
28
- | Research libraries | **Context7 MCP** `query_docs()` | **WebSearch** |
29
- | Ask clarifying questions | **AskUserQuestion** (never plain text) | — |
30
- | Render proposal template | **Bash** `morph-spec template render docs/proposal ...` | — |
31
-
32
- ---
33
-
34
- ## Workflow
35
-
36
- ## MANDATORY: Session Tasks
37
-
38
- > **BEFORE starting any brainstorming work**, analyze what you need to do and create session tasks.
39
- >
40
- > **Rules:** Minimum 2 tasks, typically 3-5. Mark `in_progress` before starting, `completed` after.
41
- >
42
- > **Typical tasks:** context exploration, clarifying questions, approach analysis, recommendation, documentation
43
-
44
- ### Step 1: Explore Context
45
-
46
- Gather information before generating ideas. This step is what makes morph-aware brainstorming different from generic brainstorming — it grounds your thinking in the actual project state and constraints.
47
-
48
- 1. **Read state** — `morph-spec state get $ARGUMENTS` → current phase, active agents, existing outputs, task history
49
- 2. **Read config** — `.morph/config/config.json` → stack, architecture style (VSA vs standard), project name, integrations
50
- 3. **Check architecture** — `cat .morph/config/config.json | grep -A3 architecture` → determines which agents and patterns apply
51
- 4. **Read existing outputs** — proposal.md, spec.md, decisions.md (if they exist from prior work)
52
- 5. **Check active agents** — `morph-spec dispatch-agents $ARGUMENTS design --table` → which specialists are available
53
- 6. **Scan codebase** — use Glob/Grep to understand existing patterns, domain models, and service boundaries relevant to the feature
54
- 7. **Check MCP tools** — if Context7, GitHub, or other MCPs are available, use them for research
55
-
56
- ### Step 1.5: Assess Complexity & Recommend Workflow
57
-
58
- Based on the context gathered in Step 1, evaluate the feature's complexity to select the appropriate workflow tier. Use this decision table:
59
-
60
- | Indicator | Fast-Track | Standard | Full |
61
- |-----------|-----------|----------|------|
62
- | Files affected | 1-3 | 3-10 | 10+ |
63
- | Entities/domains | 1 | 1-2 | 3+ |
64
- | External integrations | None | None | 1+ |
65
- | Infrastructure changes | No | No | Yes |
66
- | UI design needed | No | Optional | Yes |
67
- | Examples | CRUD field, rename, toggle, fix | Pagination, filter, export, refactor | Auth system, migration, platform redesign |
68
-
69
- **Actions:**
70
- 1. Count entities, domains, integrations, and UI requirements from the feature request
71
- 2. Match against the table above to determine the tier
72
- 3. Set the workflow in state:
73
- ```bash
74
- morph-spec state set $ARGUMENTS workflow fast-track # or standard / full
75
- ```
76
- 4. Inform the user of the recommendation via `AskUserQuestion` with options to confirm or override:
77
- - Header: `Workflow`
78
- - Question: "Based on complexity analysis, I recommend **{tier}** workflow ({N} phases). Override?"
79
- - Options: `Confirm {tier}` / `Switch to standard` / `Switch to full` / `Switch to fast-track`
80
-
81
- > **Note:** The user can always override later with `morph-spec state set <feature> workflow <tier>`.
82
-
83
- ### Step 2: Ask Clarifying Questions
84
-
85
- Use `AskUserQuestion` to collect responses — **NEVER list questions as plain text**.
86
-
87
- - Maximum 4 questions per call. If you need 5+, make sequential calls (Q1-Q4, then Q5).
88
- - Each question needs 2-4 representative options (the user can type a free response via "Other").
89
- - **Wait for the tool response before proceeding to Step 3.**
90
-
91
- Starter questions to adapt to the feature context:
92
-
93
- | Header (<=12 chars) | Question | Suggested Options |
94
- |--------------------|----------|------------------|
95
- | `Scope` | What's the minimum viable version of this feature? | Basic MVP / Full version / Open-ended |
96
- | `Constraints` | Any performance, budget, or timeline constraints? | No constraints / Performance-critical / Budget-limited |
97
- | `Integration` | Does this need to integrate with existing features/systems? | Yes, integrates with X / Isolated feature / TBD |
98
- | `Users` | Who are the primary users? | End-users / Admins / Internal system |
99
- | `Success` | How will we know this feature works correctly? | Defined metrics / Acceptance tests / User feedback |
100
-
101
- > Adapt the options to the actual feature context — these are starting points, not a fixed template.
102
-
103
- ### Step 3: Generate 2-3 Approaches
104
-
105
- For each approach, document:
106
-
107
- ```markdown
108
- ## Approach A: {Name}
109
-
110
- **Description:** {1-2 sentences}
111
-
112
- **Pros:**
113
- - Pro 1
114
- - Pro 2
115
-
116
- **Cons:**
117
- - Con 1
118
- - Con 2
119
-
120
- **Complexity:** Low / Medium / High
121
- **Estimated Tasks:** ~N
122
- **Key Dependencies:** {list}
123
- ```
124
-
125
- ### Step 4: Recommend and Document
126
-
127
- 1. **Recommend** the best approach with clear reasoning
128
- 2. **Write output** to the appropriate location based on the current phase:
129
-
130
- **Phase 0 (Proposal):**
131
- ```bash
132
- morph-spec template render docs/proposal ".morph/features/$ARGUMENTS/0-proposal/proposal.md" '{"FEATURE_NAME":"...", "DATE":"..."}'
133
- ```
134
- Then edit the rendered file to add the brainstorming results.
135
-
136
- **Phase 2 (Design):**
137
- Write the decision as an ADR (Architecture Decision Record) in `.morph/features/$ARGUMENTS/2-design/decisions.md`.
138
-
139
- 3. **Update state** (mandatory — do not skip):
140
- ```bash
141
- morph-spec state mark-output $ARGUMENTS proposal # Phase 0
142
- morph-spec state mark-output $ARGUMENTS decisions # Phase 2
143
- ```
144
- Then verify the output was recorded:
145
- ```bash
146
- morph-spec state get $ARGUMENTS
147
- ```
148
-
149
- ---
150
-
151
- ## Integration with Superpowers
152
-
153
- > Available when the `superpowers` plugin is installed.
154
-
155
- This skill replaces `superpowers:brainstorming` within morph-spec workflows. It adds:
156
- - Automatic context loading from `.morph/` state and config
157
- - Template rendering for outputs (proposal.md, decisions.md)
158
- - State tracking via `morph-spec state mark-output`
159
- - MCP integration for research (Context7, GitHub)
160
-
161
- For brainstorming **outside** morph-spec workflows, the original `superpowers:brainstorming` skill remains available.
162
-
163
- ---
164
-
165
- ## Anti-patterns
166
-
167
- - Skipping brainstorming for features with multiple valid approaches — exploring alternatives prevents tunnel vision
168
- - Committing to an approach without documenting alternatives — future decisions need context on what was considered
169
- - Brainstorming without loading project context first — leads to approaches that don't fit the existing architecture
170
- - Writing code before completing the brainstorming output — premature implementation before agreement
171
-
172
- ---
173
-
174
- *MORPH-SPEC by Polymorphism Tech*
@@ -1,138 +0,0 @@
1
- # Feature Proposal: Photo Processing Pipeline
2
-
3
- > Example of a well-structured proposal.md. This is a filled-in reference — not a template.
4
-
5
- ## Metadata
6
-
7
- | Field | Value |
8
- |-------|-------|
9
- | **Proposed** | 2025-01-15 |
10
- | **Author** | Product Team |
11
- | **Status** | Approved |
12
- | **Priority** | High |
13
- | **Stack** | blazor-azure |
14
-
15
- ---
16
-
17
- ## Overview
18
-
19
- Users currently cannot upload photos for AI-based transformations because no upload infrastructure exists. This feature adds an end-to-end photo upload, processing, and delivery pipeline using Azure Blob Storage and Hangfire background jobs.
20
-
21
- ---
22
-
23
- ## Problem Statement
24
-
25
- ### What is the problem?
26
-
27
- Users cannot submit photos for AI transformation, blocking the core product value proposition. The system has no file upload capability, no background processing queue, and no way to notify users when processing completes.
28
-
29
- ### Who is affected?
30
-
31
- All end users who want to use the photo transformation feature — the primary user journey is completely unavailable.
32
-
33
- ### What is the impact?
34
-
35
- - User productivity loss: 100% of core use case unavailable
36
- - Revenue impact: Feature is the primary paid tier differentiator
37
- - User satisfaction: Can't demo product to prospects
38
-
39
- ---
40
-
41
- ## Proposed Solution
42
-
43
- ### Overview
44
-
45
- A multi-step pipeline: user uploads a photo via a Blazor form → the file is stored in Azure Blob Storage → a Hangfire background job is queued for AI processing → the user polls for completion → the processed photo is returned via a download link.
46
-
47
- ### Key Features
48
-
49
- 1. **Upload endpoint** — Validates file type/size, stores in Azure Blob
50
- 2. **Background processing** — Hangfire job calls AI API, stores result in Blob
51
- 3. **Status polling** — User sees real-time progress (Pending → Processing → Completed)
52
-
53
- ### User Journey
54
-
55
- ```
56
- 1. User selects a photo file on the upload page
57
- 2. System validates (max 10MB, .jpg/.png only) and shows preview
58
- 3. User clicks "Upload" → system enqueues job, redirects to /processing/{jobId}
59
- 4. User sees progress bar polling every 5 seconds
60
- 5. On completion: "Download" button appears, user gets processed photo
61
- ```
62
-
63
- ---
64
-
65
- ## Success Metrics
66
-
67
- | Metric | Current | Target |
68
- |--------|---------|--------|
69
- | Upload success rate | N/A | >99% |
70
- | Processing time (p95) | N/A | <120s |
71
- | Error recovery rate | N/A | >95% (auto-retry) |
72
-
73
- ---
74
-
75
- ## Scope
76
-
77
- ### In Scope
78
-
79
- - Photo upload (Blazor form, Azure Blob Storage)
80
- - Background processing via Hangfire
81
- - Status polling page with progress indicator
82
- - Download link for processed photo
83
- - Basic error handling and retry logic
84
-
85
- ### Out of Scope
86
-
87
- - Batch uploads (multiple photos at once)
88
- - Email notifications when processing completes
89
- - Photo editing before upload (crop, resize)
90
-
91
- ### Future Considerations
92
-
93
- - Webhooks for external integrations
94
- - Processing history and gallery view
95
-
96
- ---
97
-
98
- ## Risks & Concerns
99
-
100
- | Risk | Likelihood | Impact | Mitigation |
101
- |------|------------|--------|------------|
102
- | AI API unavailable | Medium | High | Retry with exponential backoff, fallback error state |
103
- | Large file upload timeout | Low | Medium | Chunked upload or presigned URL direct to Blob |
104
- | Blob storage costs unexpectedly high | Low | Low | Set blob lifecycle policy (auto-delete after 30 days) |
105
-
106
- ---
107
-
108
- ## Estimated Effort
109
-
110
- | Phase | Estimate |
111
- |-------|----------|
112
- | Design & Spec | 2h |
113
- | Implementation | 6h |
114
- | Testing | 2h |
115
- | **Total** | **10h** |
116
-
117
- ---
118
-
119
- ## Questions & Clarifications
120
-
121
- 1. Maximum file size: 10MB or higher for pro users?
122
- 2. Should processed photos be kept indefinitely or expire after 30 days?
123
- 3. Does the AI API support async webhooks or only polling?
124
-
125
- ---
126
-
127
- ## Next Steps
128
-
129
- Once approved:
130
- 1. Create detailed `spec.md` with technical design
131
- 2. Define contracts in `contracts.cs`
132
- 3. Record decisions in `decisions.md`
133
- 4. Break down into `tasks.md`
134
- 5. Begin implementation
135
-
136
- ---
137
-
138
- *MORPH-SPEC by Polymorphism Tech*
@@ -1,145 +0,0 @@
1
- ---
2
- name: morph-checklist
3
- description: Pre-deploy, security, SEO, performance, accessibility, and LGPD compliance checklists for MORPH-SPEC projects. Use before deploying to production, during security audits, when optimizing for SEO or performance, or when validating Brazilian LGPD data protection compliance.
4
- user-invocable: true
5
- allowed-tools: Read, Write, Edit, Bash, Glob, Grep
6
- ---
7
-
8
- # MORPH Checklists
9
-
10
- Types: `deploy`, `security`, `seo`, `performance`, `accessibility`, `legal-brazil`, `simulation` (see skill: `morph-simulation-checklist`)
11
-
12
- ---
13
-
14
- ## Deploy
15
-
16
- ### MORPH-SPEC Validation (run first)
17
- - [ ] `morph-spec validate-feature {feature}` — passes with 100% pass rate
18
- - [ ] `morph-spec approval-status {feature}` — all gates approved (design, plan, tasks)
19
- - [ ] `morph-spec state get {feature}` — phase is `implement`, all tasks `done`
20
- - [ ] Recap generated: `.morph/features/{feature}/5-implement/recap.md` exists
21
-
22
- ### Pre-Deploy
23
- - [ ] `dotnet build --configuration Release` passes
24
- - [ ] `dotnet test` passes (100% pass rate required — zero tolerance)
25
- - [ ] Migrations applied (`dotnet ef database update`)
26
- - [ ] Env vars configured (connection strings, API keys, feature flags)
27
-
28
- ### Infrastructure
29
- - [ ] Bicep/IaC updated (`az deployment group what-if`)
30
- - [ ] SSL/HTTPS configured
31
- - [ ] DNS pointing correctly
32
- - [ ] Health checks configured
33
-
34
- ### Security & Monitoring
35
- - [ ] Secrets in Key Vault (not in code)
36
- - [ ] Managed Identity configured
37
- - [ ] CORS configured
38
- - [ ] Rate limiting enabled
39
- - [ ] Application Insights + alerts configured
40
-
41
- ### Post-Deploy
42
- - [ ] Smoke tests executed
43
- - [ ] Rollback plan documented
44
-
45
- ---
46
-
47
- ## Security
48
-
49
- ### Auth & Authorization
50
- - [ ] Passwords hashed (bcrypt/Argon2), MFA available
51
- - [ ] JWT with short expiration + refresh tokens
52
- - [ ] RBAC + resource-based authorization
53
- - [ ] Ownership verification (user sees only their data)
54
-
55
- ### Input & Headers
56
- - [ ] Server-side validation (never trust client)
57
- - [ ] HTML sanitized (XSS), parametrized queries (SQLi)
58
- - [ ] File upload validation (type, size, content)
59
- - [ ] Security headers: `X-Content-Type-Options: nosniff`, `X-Frame-Options: DENY`, `CSP: default-src 'self'`
60
-
61
- ### Data
62
- - [ ] PII encrypted at rest, masked in logs
63
- - [ ] Card data never stored (use tokenization)
64
- - [ ] `dotnet list package --vulnerable` clean
65
-
66
- ---
67
-
68
- ## SEO
69
-
70
- - [ ] `<title>` + `<meta description>` (150-160 chars)
71
- - [ ] `<link rel="canonical">` + `robots.txt` + `sitemap.xml`
72
- - [ ] Open Graph tags (og:title, og:description, og:image)
73
- - [ ] URLs friendly, heading hierarchy (H1>H2>H3)
74
- - [ ] Images optimized (WebP, lazy loading, alt text)
75
- - [ ] Core Web Vitals: LCP < 2.5s, FID < 100ms, CLS < 0.1
76
-
77
- ---
78
-
79
- ## Performance
80
-
81
- ### Backend
82
- - [ ] `.AsNoTracking()` for reads, no N+1, projections (`.Select()`)
83
- - [ ] Indexes on search columns
84
- - [ ] Response/distributed caching with invalidation
85
- - [ ] All I/O operations are async (no `.Result` / `.Wait()`)
86
-
87
- ### Frontend
88
- - [ ] Lazy loading, virtualization for large lists
89
- - [ ] Debounce search inputs
90
- - [ ] Memoization for expensive renders
91
-
92
- ### Infrastructure
93
- - [ ] CDN for static assets, gzip/brotli compression
94
- - [ ] Connection pooling, scale-to-zero
95
-
96
- ---
97
-
98
- ## Accessibility (WCAG 2.1)
99
-
100
- - [ ] Alt text on images, captions on videos
101
- - [ ] Contrast >= 4.5:1 (AA), color not sole indicator
102
- - [ ] Keyboard navigation works, focus visible
103
- - [ ] Skip links, `<html lang="...">` with correct locale
104
- - [ ] Labels on all inputs, clear error messages
105
- - [ ] Valid HTML, ARIA used correctly
106
-
107
- ---
108
-
109
- ## Legal Brazil (LGPD — Lei 13.709/2018)
110
-
111
- The Brazilian General Data Protection Law (LGPD) applies to any application that processes personal data of individuals in Brazil. Non-compliance can result in fines up to 2% of revenue (capped at R$50M per violation) from ANPD (Autoridade Nacional de Protecao de Dados).
112
-
113
- ### Documentation (Art. 9, 23, 41)
114
- - [ ] Privacy policy published and accessible from every page — must include: categories of data collected, legal basis per category (Art. 7), processing purpose, retention period, DPO (Encarregado) contact name and email
115
- - [ ] Terms of use covering: service description, user responsibilities, governing forum (Brazilian jurisdiction required)
116
- - [ ] ROPA (Record of Processing Activities) — internal document mapping data flows per Art. 37
117
-
118
- ### Consent & Data Subject Rights (Art. 7-9, 15-18)
119
- - [ ] Cookie consent banner with **granular opt-in** (not just "accept all") — separate toggles for analytics, marketing, essential
120
- - [ ] Explicit consent for marketing communications — checkbox unchecked by default, revocable at any time
121
- - [ ] Data subject rights page implementing all Art. 18 rights:
122
- - [ ] Access: user can view all personal data held
123
- - [ ] Correction: user can update inaccurate data
124
- - [ ] Deletion: user can request full account/data deletion (Art. 18, IX)
125
- - [ ] Portability: user can export data in machine-readable format (JSON/CSV)
126
- - [ ] Opposition: user can object to specific processing
127
- - [ ] Rights requests processed within 15 days (Art. 19)
128
-
129
- ### Technical Controls (Art. 46-49)
130
- - [ ] PII encrypted at rest (AES-256) and in transit (TLS 1.2+)
131
- - [ ] Data minimization: only collect what the legal basis justifies
132
- - [ ] Defined retention periods per data category — automatic purge after expiry
133
- - [ ] Anonymization/pseudonymization for analytics and logs
134
- - [ ] Access logs for all personal data operations (who accessed what, when)
135
- - [ ] Incident response plan: ANPD notification within **72 hours** of breach (Art. 48), user notification "within reasonable time"
136
- - [ ] Data Protection Impact Assessment (DPIA/RIPD) for high-risk processing (Art. 5, XVII)
137
-
138
- ### DPO (Encarregado — Art. 41)
139
- - [ ] DPO designated and publicly identified (name + contact on privacy policy)
140
- - [ ] DPO contact channel operational (email or form)
141
- - [ ] DPO handles ANPD communications and data subject requests
142
-
143
- ---
144
-
145
- *MORPH-SPEC Checklist Skill*