@polymorphism-tech/morph-spec 11.2.0 → 11.3.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.
Files changed (109) hide show
  1. package/README.md +3 -2
  2. package/bin/morph-spec.js +7 -7
  3. package/docs/CHEATSHEET.md +1 -1
  4. package/docs/QUICKSTART.md +1 -1
  5. package/framework/CLAUDE.md +1 -1
  6. package/framework/MORPH.md +2 -2
  7. package/framework/agents.json +4 -4
  8. package/framework/docs/CLI.md +19 -11
  9. package/framework/evals/review-checklist.md +26 -2
  10. package/framework/hooks/README.md +3 -2
  11. package/framework/hooks/claude-code/core/graph-refresh-kick.js +2 -2
  12. package/framework/mcp/registry.json +15 -15
  13. package/framework/rules/ai-agents-standards.md +9 -1
  14. package/framework/rules/gsap-standards.md +8 -0
  15. package/framework/rules/mcp-standards.md +10 -0
  16. package/framework/schemas/config.schema.json +7 -0
  17. package/framework/skills/core/create-umbraco-lp/SKILL.md +1 -1
  18. package/framework/skills/core/migrate-lp-to-umbraco/SKILL.md +1 -1
  19. package/framework/skills/core/morph-apply/SKILL.md +4 -3
  20. package/framework/skills/core/morph-plan/SKILL.md +1 -1
  21. package/framework/skills/core/morph-uiux/SKILL.md +1 -1
  22. package/framework/standards/STANDARDS.json +8 -4
  23. package/framework/standards/STANDARDS.meta.json +1 -1
  24. package/framework/standards/ai-agents/agent-archetypes.md +1 -1
  25. package/framework/standards/ai-agents/middleware-patterns.md +0 -2
  26. package/framework/standards/ai-agents/prompt-sources.md +2 -2
  27. package/framework/standards/ai-agents/providers/model-registry.md +9 -12
  28. package/framework/standards/ai-agents/rag-custom-pgvector.md +2 -9
  29. package/framework/standards/frontend/design-system/ai-image-generation.md +1 -1
  30. package/framework/standards/infrastructure/docker/local-compose-isolation.md +2 -2
  31. package/framework/standards/integration/mcp/mcp-tools.md +124 -266
  32. package/framework/templates/README.md +52 -82
  33. package/framework/templates/REGISTRY.json +0 -206
  34. package/framework/templates/code/sql/ai-agents/agent-prompts-migration.sql.template +3 -4
  35. package/framework/templates/context/design-system.md +1 -1
  36. package/framework/templates/docs/plan.md +1 -1
  37. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Providers/model-registry.v2.json +1 -1
  38. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/MediaDisclosureTests.cs +1 -1
  39. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Morph.AiKit.Tests.csproj +2 -4
  40. package/framework/templates/frontend/nextjs/gsap-scroll-section.tsx.hbs +13 -17
  41. package/framework/templates/infrastructure/github/README.md +10 -13
  42. package/package.json +2 -2
  43. package/src/commands/mcp/manual-setup.js +95 -0
  44. package/src/commands/mcp/mcp-setup.js +23 -191
  45. package/src/commands/project/doctor.js +6 -16
  46. package/src/commands/project/init-contract.js +2 -2
  47. package/src/commands/project/init.js +15 -133
  48. package/src/commands/project/stack-scan.js +6 -14
  49. package/src/commands/project/stack-set.js +1 -1
  50. package/src/commands/project/standards.js +1 -2
  51. package/src/commands/project/update.js +52 -66
  52. package/src/commands/scaffold/scaffold.js +28 -7
  53. package/src/lib/ai/ai-project-scan.js +1 -4
  54. package/src/lib/ai/code-audit.js +1 -6
  55. package/src/lib/ai/registry-audit.js +2 -1
  56. package/src/lib/config/project-config.js +3 -2
  57. package/src/lib/contract/apply.js +2 -1
  58. package/src/lib/contract/merge.js +1 -0
  59. package/src/lib/contract/scan.js +5 -5
  60. package/src/lib/detectors/claude-config-detector.js +45 -47
  61. package/src/lib/detectors/mcp-config.js +2 -1
  62. package/src/lib/diff/diff-lines.js +2 -7
  63. package/src/lib/graph/graph-loader.js +2 -1
  64. package/src/lib/graph/graphifyignore.js +2 -1
  65. package/src/lib/installers/install-manifest.js +56 -0
  66. package/src/lib/installers/mcp-installer.js +14 -5
  67. package/src/lib/installers/rules-installer.js +9 -15
  68. package/src/lib/installers/stack-assets.js +42 -21
  69. package/src/lib/installers/stack-sync.js +12 -12
  70. package/src/lib/installers/stack-tooling.js +4 -3
  71. package/src/lib/json-file.js +9 -0
  72. package/src/lib/plan/artifact-vocabulary.js +1 -1
  73. package/src/lib/plan/checks.js +3 -2
  74. package/src/lib/plan/media.js +3 -3
  75. package/src/lib/plan/plan-parser.js +5 -10
  76. package/src/lib/review-reports.js +5 -4
  77. package/src/lib/stack/stack-scan.js +1 -1
  78. package/src/lib/standards/verified-against.js +1 -1
  79. package/src/lib/tests-audit/audit.js +1 -1
  80. package/src/lib/text.js +5 -0
  81. package/src/scripts/setup-infra.js +22 -33
  82. package/src/utils/agents-installer.js +13 -30
  83. package/src/utils/claude-md-injector.js +16 -50
  84. package/src/utils/claude-settings-manager.js +2 -2
  85. package/src/utils/file-copier.js +3 -4
  86. package/src/utils/hooks-installer.js +55 -20
  87. package/src/utils/skills-installer.js +18 -78
  88. package/framework/templates/IDE-SNIPPETS.md +0 -262
  89. package/framework/templates/code/dotnet/ai-agents/AgentBootstrap.cs.template +0 -26
  90. package/framework/templates/code/dotnet/ai-agents/EmbeddingService.cs.template +0 -28
  91. package/framework/templates/code/dotnet/ai-agents/ModelRegistry.cs.template +0 -99
  92. package/framework/templates/code/dotnet/ai-agents/ResilientToolMiddleware.cs.template +0 -40
  93. package/framework/templates/code/dotnet/ai-agents/VectorSearchTool.cs.template +0 -54
  94. package/framework/templates/code/dotnet/ai-agents/model-registry.json.template +0 -53
  95. package/framework/templates/code/dotnet/contracts/README.md +0 -74
  96. package/framework/templates/code/dotnet/database/vector-entity.cs +0 -49
  97. package/framework/templates/code/sql/ai-agents/pgvector-embeddings-migration.sql.template +0 -91
  98. package/framework/templates/code/sql/postgresql-migration.template.sql +0 -108
  99. package/framework/templates/code/typescript/contracts.ts +0 -140
  100. package/framework/templates/examples/design-system-examples.md +0 -354
  101. package/framework/templates/infrastructure/docker/Dockerfile.template +0 -58
  102. package/framework/templates/infrastructure/github/actions/docker-build-push/action.yml.hbs +0 -45
  103. package/framework/templates/infrastructure/github/actions/health-check/action.yml.hbs +0 -27
  104. package/framework/templates/integrations/asaas-client.cs +0 -332
  105. package/framework/templates/integrations/asaas-webhook.cs +0 -290
  106. package/framework/templates/integrations/neon-auth-config.cs +0 -170
  107. package/framework/templates/ui/design-system.css +0 -226
  108. package/src/lib/detectors/index.js +0 -153
  109. package/src/lib/installers/templates-reconcile.js +0 -26
@@ -1,88 +1,132 @@
1
- # Integration Standard: MCP Tools in MORPH Workflows
1
+ # Integration Standard: MCP Tools in MORPH Work
2
2
 
3
3
  > **Scope:** integration-mcp
4
4
  > **Layer:** 2
5
5
  > **Keywords:** mcp, model-context-protocol, mcp-tools, context7, playwright, mcp-client
6
6
  > **Load When:** an MCP tool is used while planning, designing, implementing or reviewing
7
7
 
8
- **Verified against:** Claude Code 2.1.282 MCP tooling — context7, Playwright (as plugin and as a project MCP server); GitHub via `gh` CLI; Neon via its MCP or `neon`; Microsoft Learn MCP (`https://learn.microsoft.com/api/mcp`, tools listed by `tools/list` on 2026-10-17). Last-verified: 2026-10-30.
8
+ **Verified against:** Claude Code 2.1.282 MCP tooling — context7, Playwright (as plugin and as a project MCP server); GitHub via `gh` CLI; Neon via its MCP or `neon`; Microsoft Learn MCP (`https://learn.microsoft.com/api/mcp`, tools listed by `tools/list` on 2026-10-17); servers, tool lists and `serverNames` read from the morph-spec MCP registry 4.0.0. Last-verified: 2026-11-25.
9
9
 
10
10
  ---
11
11
 
12
- Reference for using Model Context Protocol (MCP) tools across the work on a feature. Each kind of work benefits from different MCPs depending on what data is needed.
12
+ Which Model Context Protocol (MCP) server serves which kind of work on a feature — planning, designing a screen, implementing, reviewing — and what replaces it when it is not connected. This standard covers the MCPs the **coding session** uses; an agent of the product consuming an MCP server is `ai-agents-mcp-tools`.
13
13
 
14
14
  ## Tool Names Depend on Where the Server Is Configured
15
15
 
16
16
  The names below use the `.mcp.json` form, `mcp__<server>__<tool>`. The same server installed as a **plugin** is named `mcp__plugin_<plugin>_<server>__<tool>`: context7 from the plugin is `mcp__plugin_context7_context7__query-docs`, not `mcp__context7__query-docs`. Call the name that exists in your session. The tool part (`query-docs`, `browser_navigate`) is the same under both prefixes.
17
17
 
18
- In a morph persona the grant follows the same rule: the installer emits one `mcp__<name>` per spelling in the registry's `serverNames`, and a grant matches only its own spelling. If a tool you expect is missing, it may be deferred: load it with `ToolSearch` before calling it.
18
+ In a morph persona the grant follows the same rule: the installer emits one `mcp__<name>` per spelling in the registry's `serverNames`, and a grant matches only its own spelling. A persona has only the servers its `mcp` field in `agents.json` grants. If a tool you expect is missing, it may be deferred: load it with `ToolSearch` before calling it.
19
19
 
20
20
  ## MCP Availability Detection
21
21
 
22
- Before using any MCP tool, check if it's available in the current session. There is no "list MCPs" command: attempt the most common operation, and Claude Code reports a tool that doesn't exist. GitHub and Neon are not checked this way — o morph-spec NÃO usa MCP do GitHub nem do Neon: use o `gh` CLI (`gh repo view --json name,defaultBranchRef,languages`) e o `neon` + `psql` (`neon connection-string` dá a URL do banco) via Bash.
22
+ There is no "list MCPs" tool: attempt the cheapest call of the server, and Claude Code reports a tool that does not exist. From the shell, `morph-spec mcp setup --list` shows the install status of each server of the registry and `morph-spec doctor --mcp` checks binaries and environment variables (neither tests the connection).
23
23
 
24
24
  ```javascript
25
- await mcp__context7__resolve-library-id({ libraryName: "react" });
25
+ await mcp__context7__resolve-library-id({ libraryName: "react", query: "react hooks" });
26
26
 
27
- await mcp__playwright__browser_navigate({ url: "https://example.com" });
27
+ await mcp__playwright__browser_navigate({ url: "about:blank" });
28
28
  ```
29
29
 
30
- **Fallback rule:** If an MCP is not available, every phase has a manual alternative using Claude Code native tools (Read, Grep, Glob, Bash).
30
+ **Fallback rule:** every server has a fallback with Claude Code native tools (Read, Grep, Glob, Bash) or a CLI; the table in [The Servers](#the-servers) names it. A missing MCP never blocks the work.
31
31
 
32
32
  ---
33
33
 
34
- ## MCP Providers by Phase
34
+ ## The Servers
35
35
 
36
- ### Phase 1 (Setup) — Project Discovery
36
+ What `morph-spec mcp setup` knows how to install. "Stack" is what makes `init` offer the server.
37
37
 
38
- | Tool | Use Case | Example |
39
- |------|----------|---------|
40
- | **GitHub CLI (`gh`)** | Repo info, recent PRs, issues | `gh repo view --json ...` (Bash) |
41
- | **Filesystem** | Scan project structure | Native Glob/Read preferred |
38
+ | Server | Stack | What it is for | Fallback |
39
+ |--------|-------|----------------|----------|
40
+ | **context7** | any | Current library docs: `resolve-library-id`, then `query-docs` | WebSearch + WebFetch |
41
+ | **playwright** | any | Navigate, snapshot, screenshot, console, click, resize on a running page | WebFetch for read-only content; manual testing |
42
+ | **graphify** | any | Raw symbol graph (`query_graph`, `get_neighbors`, `god_nodes`…), cross-repo through `project_path` | `morph-spec graph explain\|affected` (preferred: it sanitizes the graph), then grep |
43
+ | **microsoft-learn** | dotnet | Official .NET 10 / ASP.NET Core / EF Core / MAF docs: `microsoft_docs_search`, `microsoft_docs_fetch`, `microsoft_code_sample_search` | context7, then WebFetch on learn.microsoft.com |
44
+ | **neon** | neon | Schema inspection, migration dry-run on a throwaway branch, query tuning, snapshots, Neon docs | `psql`/`dotnet ef` on the connection string, `neon` CLI for branches |
45
+ | **shadcn** | nextjs, react | Read-only catalog of components and blocks across the registries of `components.json` | `npx shadcn@latest search\|view\|docs` |
46
+ | **vercel** | nextjs, vercel | Deployments, logs, environment variables (OAuth) | `vercel` CLI |
47
+ | **asaas** | asaas | Asaas API docs, endpoint schemas, code examples | WebFetch `https://docs.asaas.com` |
48
+ | **morph-assets** | nextjs, react | AI image and video generation plus ffmpeg post-production, paid per call | Stock or client-provided media; a static poster instead of video |
42
49
 
43
- ```bash
44
- # Detect project type from repo metadata (gh CLI via Bash — sem MCP)
45
- gh repo view --json name,defaultBranchRef,languages,repositoryTopics
46
- gh pr list --limit 10 --json title,state,updatedAt
47
- gh issue list --limit 10 --json title,labels
50
+ **Never through an MCP:** GitHub (issues, PRs, releases, Actions, code search) is always the `gh` CLI in Bash — it returns structured JSON with `--json`, with no Docker and no PAT in an environment variable. Docker and Azure are their CLIs (`docker`, `az`).
48
51
 
49
- # Fallback: use Glob to detect stack
50
- # Glob: "**/{package.json,*.csproj,*.sln,go.mod,Cargo.toml}"
51
- ```
52
+ ---
53
+
54
+ ## MCP by Kind of Work
52
55
 
53
- ### Phase 2 (UI/UX) — Design References
56
+ ### Planning
54
57
 
55
- | MCP | Use Case | Example |
56
- |-----|----------|---------|
57
- | **Playwright** | Navigate, screenshot, inspect live pages | `mcp__playwright__browser_navigate({ url })` |
58
- | **Context7** | Component library documentation | `mcp__context7__query-docs({ libraryId, query })` |
58
+ The plan needs facts about the repo and about what a library can do, before a scenario promises it.
59
59
 
60
- The screenshot is the visual reference; the snapshot is the accessibility tree (headings, buttons, inputs); the resize tests the mobile layout; Context7 brings the component docs for the UI spec.
60
+ | Need | Tool |
61
+ |------|------|
62
+ | Does the library support this? What changed in the version the project pins? | context7 (`query-docs`); on .NET, Microsoft Learn first |
63
+ | Who depends on this symbol (the `## Reuso` table) | `morph-spec graph affected <symbol> --uses-only`; without a graph, grep |
64
+ | The schema the feature will change | Neon MCP (`get_database_tables`, `describe_table_schema`) or `psql` — see [Neon](#neon-schema-and-migrations) |
65
+ | The issue, its discussion, earlier PRs | `gh issue view`, `gh pr list --json title,state,updatedAt`, `gh search code` |
61
66
 
62
67
  ```javascript
63
- await mcp__playwright__browser_navigate({ url: "https://app.example.com/dashboard" });
64
- const screenshot = await mcp__playwright__browser_take_screenshot();
68
+ const docs = await mcp__context7__query-docs({
69
+ libraryId: "/tanstack/table",
70
+ query: "server-side pagination with manualPagination and rowCount"
71
+ });
72
+ ```
73
+
74
+ ### Designing a screen
65
75
 
76
+ | Need | Tool |
77
+ |------|------|
78
+ | What the project and the registries already offer for the screen | shadcn MCP (`search_items_in_registries`, `view_items_in_registries`) or the shadcn CLI |
79
+ | The props and events of a component | context7 |
80
+ | Open the options page or the prototype and see it at 1280 and 390 | Playwright (`browser_navigate`, `browser_resize`, `browser_take_screenshot`) |
81
+ | How an existing screen is structured | Playwright `browser_snapshot` (the accessibility tree: headings, buttons, inputs) |
82
+ | A preview image for the direction being approved | morph-assets `generate_image` — see [morph-assets](#morph-assets-ai-image-and-video-generation) |
83
+
84
+ ```javascript
85
+ await mcp__playwright__browser_navigate({ url: "http://localhost:4010/prototipos/dashboard.html" });
66
86
  const snapshot = await mcp__playwright__browser_snapshot();
67
87
 
68
- await mcp__playwright__browser_resize({ width: 375, height: 812 });
69
- const mobileScreenshot = await mcp__playwright__browser_take_screenshot();
88
+ await mcp__playwright__browser_resize({ width: 390, height: 844 });
89
+ const mobile = await mcp__playwright__browser_take_screenshot();
90
+ ```
91
+
92
+ ### Implementing
70
93
 
71
- const libId = await mcp__context7__resolve-library-id({
72
- libraryName: "mudblazor",
73
- query: "data grid with sorting and filtering"
74
- });
75
- const docs = await mcp__context7__query-docs({
76
- libraryId: libId,
77
- query: "DataGrid component props and events"
78
- });
94
+ | Need | Tool |
95
+ |------|------|
96
+ | The current API while coding | context7; Microsoft Learn on .NET (search, then fetch the page when the excerpt is cut; `microsoft_code_sample_search` for snippets) |
97
+ | Try a migration before applying it | Neon MCP `prepare_database_migration` on a throwaway branch, then `complete_database_migration`; or `dotnet ef database update` against a branch |
98
+ | Add a catalog component | shadcn `get_add_command_for_items`, then run the command (the server is read-only; installing is the CLI) |
99
+ | Smoke the page that was just built | Playwright: `browser_navigate`, `browser_snapshot`, `browser_console_messages` |
100
+ | Production media the plan asks for | morph-assets, behind a human approval |
101
+ | Deployment status, logs, environment variables | Vercel MCP or the `vercel` CLI |
102
+ | Commit, PR | `git` and `gh pr create` |
103
+
104
+ ```javascript
105
+ const hits = await mcp__microsoft-learn__microsoft_docs_search({ query: "EF Core 10 owned entity types configuration" });
106
+ const page = await mcp__microsoft-learn__microsoft_docs_fetch({ url: hits[0].contentUrl });
107
+
108
+ await mcp__playwright__browser_navigate({ url: `http://localhost:${process.env.PORT}/leads` });
109
+ const snapshot = await mcp__playwright__browser_snapshot();
110
+ const logs = await mcp__playwright__browser_console_messages();
79
111
  ```
80
112
 
81
- Fallback: WebSearch for component documentation, WebFetch for specific component API pages.
113
+ The page runs on the port `morph-spec env` prints for the branch. A screenshot kept as evidence of a `prova: manual` scenario goes under `3-implement/evidencias/`.
114
+
115
+ ### Reviewing
116
+
117
+ The `verifier` proves each `prova: e2e` scenario by navigating the flow with Playwright as a user, at the URL the dispatch gives, checking screen, console and network. It neither starts nor stops the stack: with the stack down, the scenario stays `NÃO PROVADO` with the reason. `verifier` and `reviewer` read blast radius through `morph-spec graph` (the graphify MCP gives the raw graph; without a graph, grep).
118
+
119
+ ```javascript
120
+ await mcp__playwright__browser_navigate({ url: "http://localhost:4010/leads" });
121
+ await mcp__playwright__browser_click({ element: "New lead button", ref: "s1e15" });
122
+ await mcp__playwright__browser_fill_form({ ref: "s1e8", value: "Maria" });
123
+ const after = await mcp__playwright__browser_snapshot();
124
+ const requests = await mcp__playwright__browser_network_requests();
125
+ ```
82
126
 
83
- ### morph-assets MCP — AI Image and Video Generation
127
+ ---
84
128
 
85
- > Available in: **UI/UX** (preview generation), **Implement** (production assets)
129
+ ## morph-assets: AI Image and Video Generation
86
130
 
87
131
  One MCP for image, video and local post-production, all models through OpenRouter. Default image model `openai/gpt-image-2.5-flare`; default video model `bytedance/seedance-1-5-pro` (draft/loop), final `bytedance/seedance-2.0` 1080p via `promoteFrom`. `model` accepts any OpenRouter model by id or alias; `models: [...]` compares the same request across models.
88
132
 
@@ -94,10 +138,10 @@ One MCP for image, video and local post-production, all models through OpenRoute
94
138
  | `generate_video` / `generate_loop_video` | Directional footage (`image` + `endImage`) / ambient loop | `mcp__morph-assets__generate_video({ prompt, image, endImage })` |
95
139
  | `get_video` | Poll one or more video jobs (never resend `generate_video`) | `mcp__morph-assets__get_video({ ids })` |
96
140
  | `media_tool` | ffmpeg post-production: scrub frames, poster, concat, compress, approval picker | `mcp__morph-assets__media_tool({ op: "scrub_frames", input })` |
97
- | `library` | History and metadata (replaces `list_images` / `get_image_info` / `list_videos`) | `mcp__morph-assets__library({ op: "list" })` |
141
+ | `library` | History and metadata of what was generated | `mcp__morph-assets__library({ op: "list" })` |
98
142
  | `list_models` / `usage` | Pick a model from the curation / spend and credit balance | `mcp__morph-assets__usage({ op: "balance" })` |
99
143
 
100
- Read `design-system.md` first to get the project colors and aesthetic direction. Keep edits short and targeted, and iterate with `continue_editing` one change at a time.
144
+ Read the project's design system first (`.morph/context/design-system.md`, when it exists) to get the colors and the aesthetic direction. Keep edits short and targeted, and iterate with `continue_editing` one change at a time.
101
145
 
102
146
  ```javascript
103
147
  const image = await mcp__morph-assets__generate_image({
@@ -116,183 +160,13 @@ await mcp__morph-assets__continue_editing({
116
160
  });
117
161
  ```
118
162
 
119
- Paid per generation: above US$2, over the project budget or with an unknown price the tool returns `CONFIRMATION_REQUIRED` + `confirmToken` (get human approval, then repeat the same call with the token); `dryRun: true` only estimates.
120
-
121
- Fallback: manual image creation, stock photos, or placeholder divs.
122
-
123
- **Use cases by phase:**
124
-
125
- | Phase | Use Case | Tool |
126
- |-------|----------|------|
127
- | UI/UX (2) | Generate preview images for design approval | `generate_image` |
128
- | Implement (7) | Generate production assets from assets.md specs | `generate_image` + `edit_image` |
129
- | Implement (7) | Iterate on generated images for quality | `continue_editing` |
130
-
131
- > **Standard:** See `frontend/design-system/ai-image-generation.md` for prompt engineering patterns, aspect ratio guide, and `assets.md` format, and `frontend/design-system/ai-video-generation.md` for directional footage and the video cost ladder.
132
-
133
- ---
134
-
135
- ### Phase 3 (Design) — Schema & Architecture
136
-
137
- | Tool | Use Case | Example |
138
- |------|----------|---------|
139
- | **Neon CLI (`neon`) / psql** | Database schema, tables, relationships, RLS | `psql <DB_URL> -c "SELECT ..."` |
140
- | **Context7** | Library docs for architecture decisions | `mcp__context7__query-docs()` |
141
- | **Microsoft Learn** (stack .NET) | Official docs for a .NET/EF Core/MAF decision (limits, what is new, migration) | `mcp__microsoft-learn__microsoft_docs_search({ query })` |
142
- | **GitHub CLI (`gh`)** | Check existing code patterns, PRs | `gh search code` (Bash) |
143
-
144
- ```bash
145
- # === SCHEMA ANALYSIS (Critical for contracts.cs) ===
146
-
147
- # 0. Get Neon DB connection string
148
- neon connection-string
149
- # → e.g.: postgresql://user:pass@ep-xxx.us-east-2.aws.neon.tech/neondb?sslmode=require
150
-
151
- # 1. List all tables
152
- pg_dump $(neon connection-string) --schema-only --schema public 2>/dev/null | grep "CREATE TABLE"
153
-
154
- # 2. Get schema for each relevant table
155
- psql $(neon connection-string) -c "SELECT column_name, data_type, is_nullable, column_default \
156
- FROM information_schema.columns WHERE table_name = 'leads' ORDER BY ordinal_position"
157
-
158
- # 3. Get foreign key relationships
159
- psql $(neon connection-string) -c "SELECT tc.table_name, kcu.column_name, ccu.table_name AS foreign_table, \
160
- ccu.column_name AS foreign_column FROM information_schema.table_constraints tc \
161
- JOIN information_schema.key_column_usage kcu ON tc.constraint_name = kcu.constraint_name \
162
- JOIN information_schema.constraint_column_usage ccu ON tc.constraint_name = ccu.constraint_name \
163
- WHERE tc.constraint_type = 'FOREIGN KEY' AND tc.table_name = 'leads'"
164
-
165
- # 4. Check RLS policies (security-critical)
166
- psql $(neon connection-string) -c "SELECT tablename, policyname, cmd, qual FROM pg_policies WHERE tablename = 'leads'"
167
- ```
168
-
169
- **Fallback (Neon database not accessible):**
170
- ```
171
- 1. Grep: "\.from\(|\.select\(|SELECT |DbSet<" → find query files
172
- 2. Read each query file → extract table/column names
173
- 3. Glob: "src/**/types/**/*.ts" or "**/Entities/**/*.cs" → find type definitions
174
- 4. Read type files → map properties to database columns
175
- ```
176
-
177
- ### Phase 4 (Clarify) — Validation & Research
178
-
179
- | MCP | Use Case | Example |
180
- |-----|----------|---------|
181
- | **Context7** | Verify library capabilities, API limits | `mcp__context7__query-docs()` |
182
- | **GitHub CLI (`gh`)** | Check issue discussions, known limitations | `gh search issues` (Bash) |
183
-
184
- The answer confirms a capability or identifies a limitation for the spec update:
185
-
186
- ```javascript
187
- const docs = await mcp__context7__query-docs({
188
- libraryId: "/mudblazor/mudblazor",
189
- query: "DataGrid server-side pagination with virtual scrolling"
190
- });
191
- ```
192
-
193
- Fallback: WebSearch for library capabilities.
194
-
195
- ### Phase 6 (Tasks) — Planning & Organization
196
-
197
- | Tool | Use Case | Example |
198
- |------|----------|---------|
199
- | **GitHub CLI (`gh`)** | Create issues from slices, link to milestone | `gh issue create` (Bash) |
200
- | **Context7** | Estimate complexity based on library docs | `mcp__context7__query-docs()` |
201
-
202
- ```bash
203
- # Create GitHub issues from the plan's slices (if team uses GitHub Projects)
204
- # — one `gh issue create` per slice of .morph/features/{f}/2-plan/checks.json:
205
- gh issue create --title "F1: Create Entity Lead" \
206
- --body "fatia F1 do plan.md + cenários que ela cobre" \
207
- --label "backend" --milestone "feature-x"
208
- ```
209
-
210
- ### Phase 7 (Implement) — Build & Deploy
211
-
212
- | Tool | Use Case | Example |
213
- |------|----------|---------|
214
- | **Neon CLI (`neon`) / psql** | Run migrations, create RLS policies | `dotnet ef database update` |
215
- | **GitHub CLI (`gh`)** | Create PR, push branches | `gh pr create` (Bash) |
216
- | **Context7** | Look up API usage during coding | `mcp__context7__query-docs()` |
217
- | **Microsoft Learn** (stack .NET) | Current .NET 10 / EF Core / ASP.NET Core / MAF API: search, then fetch the page when the excerpt is cut | `mcp__microsoft-learn__microsoft_docs_search({ query })` → `microsoft_docs_fetch({ url })`; `microsoft_code_sample_search` for snippets |
218
- | **Playwright** | Smoke test deployed features, verify UI | `mcp__playwright__browser_navigate()` |
219
- | **Vercel** | Deploy, check logs, manage env vars | `mcp__vercel__list_projects()` |
220
- | **Azure CLI** | Resource management, deployments | `az` commands |
221
- | **Docker CLI** | Build, run, compose, logs (local) | `docker` commands |
222
-
223
- ```bash
224
- # === NEON (Migrations & RLS via EF Core) ===
225
-
226
- # Create migration
227
- dotnet ef migrations add AddStatusToLeads
228
-
229
- # Apply migration to Neon database
230
- dotnet ef database update
231
-
232
- # Verify schema after migration
233
- psql $(neon connection-string) -c "SELECT column_name, data_type FROM information_schema.columns WHERE table_name = 'leads'"
234
-
235
- # Verify RLS policies
236
- psql $(neon connection-string) -c "SELECT policyname, cmd, qual FROM pg_policies WHERE tablename = 'leads'"
237
- ```
238
-
239
- Look up the API while coding, then smoke test the deployed feature: the snapshot shows whether the page renders, the console messages catch JavaScript errors and failed API calls, and the screenshot goes to the slice report (`3-implement/reports/F{n}.md`). Vercel covers deployment status, logs and environment variables.
240
-
241
- ```javascript
242
- const docs = await mcp__context7__query-docs({
243
- libraryId: "/dotnet/efcore",
244
- query: "owned entity types configuration"
245
- });
246
-
247
- await mcp__playwright__browser_navigate({ url: "https://localhost:5001/leads" });
248
- const snapshot = await mcp__playwright__browser_snapshot();
249
- const logs = await mcp__playwright__browser_console_messages();
250
- const screenshot = await mcp__playwright__browser_take_screenshot();
251
-
252
- const projects = await mcp__vercel__list_projects();
253
- const deployments = await mcp__vercel__get_deployments({ projectId: 'my-project' });
254
- const deploymentLogs = await mcp__vercel__get_deployment_logs({ deploymentId: deployments[0].uid });
255
-
256
- await mcp__vercel__manage_env_vars({
257
- projectId: 'my-project',
258
- action: 'set',
259
- key: 'DATABASE_URL',
260
- value: process.env.DATABASE_URL,
261
- target: ['production', 'preview']
262
- });
263
- ```
264
-
265
- PRs/issues: sempre `gh` CLI (Bash). Deployments fallback: `vercel` CLI.
266
-
267
- ---
268
-
269
- ## MCP vs Native Tools Decision
270
-
271
- | Need | MCP Tool | Native Alternative |
272
- |------|----------|--------------------|
273
- | Database schema | Neon CLI (`neon`) / psql | Grep queries + Read types |
274
- | Repo metadata / issues / PRs | Bash `gh` CLI | WebFetch `api.github.com` (read-only) |
275
- | Library docs | Context7 | WebSearch + WebFetch |
276
- | Live page preview | Playwright MCP | WebFetch URL |
277
- | Page interaction (click, type, navigate) | Playwright MCP | Manual testing |
278
- | Responsive layout testing | Playwright MCP (`browser_resize`) | Manual testing |
279
- | Console error checking | Playwright MCP (`browser_console_messages`) | Browser DevTools |
280
- | Container ops | Docker CLI (`docker ps`, `docker logs`, `docker compose`) | — |
281
- | Cloud resources | Azure CLI (`az resource`, `az deployment`) | — |
282
- | Vercel deployments | Vercel MCP | Bash `vercel` CLI |
283
- | AI image and video generation | morph-assets MCP | Manual creation or stock photos |
163
+ Paid per generation: above US$2, over the project budget or with an unknown price the tool returns `CONFIRMATION_REQUIRED` + `confirmToken` (get human approval, then repeat the same call with the token); `dryRun: true` only estimates. Generation is stochastic: a human approves the take, and no unattended run generates media.
284
164
 
285
- **Rule:** MCP tools provide structured data (JSON responses). Native tools require manual parsing. **Always prefer MCP when available** — fall back to native when not. **Exceptions:** Neon, Docker, Azure **and GitHub** always use their respective CLIs directly — never MCP (`gh` já retorna JSON estruturado via `--json`, sem Docker nem PAT em env var).
165
+ > **Standard:** `frontend-design-system-ai-image-generation` for prompt patterns and the aspect ratio guide, `frontend-design-system-ai-video-generation` for directional footage and the video cost ladder.
286
166
 
287
- ---
288
-
289
- ## Common MCP Patterns
290
-
291
- ### Browser (Playwright): Page Automation & Analysis
292
-
293
- Setup: `npx @playwright/mcp@latest`, configured in `.claude/settings.json` or `claude_desktop_config.json` as `{ "mcpServers": { "playwright": { "command": "npx", "args": ["@playwright/mcp@latest"] } } }`.
167
+ ## Playwright: Page Automation
294
168
 
295
- Prefer the accessibility snapshot to the screenshot: it is structured, LLM-friendly, and returns the element `ref`s that the interaction calls take. `browser_fill_form` replaces the field's existing value; `browser_handle_dialog` answers alert, confirm and prompt.
169
+ Prefer the accessibility snapshot to the screenshot: it is structured and returns the element `ref`s that the interaction calls take. `browser_fill_form` replaces the field's existing value; `browser_handle_dialog` answers alert, confirm and prompt.
296
170
 
297
171
  ```javascript
298
172
  await mcp__playwright__browser_navigate({ url: "https://app.example.com/dashboard" });
@@ -315,80 +189,63 @@ const result = await mcp__playwright__browser_evaluate({
315
189
  const logs = await mcp__playwright__browser_console_messages();
316
190
  const requests = await mcp__playwright__browser_network_requests();
317
191
  await mcp__playwright__browser_handle_dialog({ accept: true });
318
- await mcp__playwright__browser_resize({ width: 375, height: 812 });
192
+ await mcp__playwright__browser_resize({ width: 390, height: 844 });
319
193
  await mcp__playwright__browser_pdf_save(); // requires --caps pdf
320
194
  await mcp__playwright__browser_file_upload({ ref: "s1e20", paths: ["/path/to/file.png"] });
321
195
  ```
322
196
 
323
- **Use cases by phase:**
324
-
325
- | Phase | Use Case | Tool |
326
- |-------|----------|------|
327
- | UI/UX (2) | Screenshot reference pages for design | `browser_navigate` + `browser_take_screenshot` |
328
- | UI/UX (2) | Inspect existing app structure | `browser_navigate` + `browser_snapshot` |
329
- | UI/UX (2) | Test responsive layouts | `browser_resize` + `browser_take_screenshot` |
330
- | Clarify (4) | Verify existing UI behavior | `browser_navigate` + `browser_snapshot` |
331
- | Implement (7) | Smoke test deployed features | `browser_navigate` + `browser_click` + `browser_snapshot` |
332
- | Implement (7) | Verify form flows end-to-end | `browser_fill_form` + `browser_click` + `browser_snapshot` |
333
- | Implement (7) | Check console errors after deploy | `browser_navigate` + `browser_console_messages` |
334
- | Implement (7) | Screenshot for the slice report | `browser_take_screenshot` |
335
-
336
- ---
197
+ ## Neon: Schema and Migrations
337
198
 
338
- ### Neon: Full Schema Discovery (via neon + psql)
199
+ Point the agent at a **branch**, never at production. The Neon MCP exposes destructive tools (`delete_branch`, `delete_project`, `reset_from_parent`): never call one without explicit human confirmation.
339
200
 
340
- > **Primary:** Neon CLI (`neon`) + psql connecting to Neon database.
341
- > **Connection:** Always use `neon connection-string` to get the DB URL.
201
+ | Need | Neon MCP | Without the MCP |
202
+ |------|----------|-----------------|
203
+ | Tables and columns | `get_database_tables`, `describe_table_schema` | `psql` on `information_schema.columns` |
204
+ | Dry-run a migration | `prepare_database_migration` → `complete_database_migration` | `neon branches create`, then `dotnet ef database update` on the branch |
205
+ | Schema diff between branches | `compare_database_schema` | `neon branches schema-diff` |
206
+ | Slow queries | `list_slow_queries`, `prepare_query_tuning` | `EXPLAIN (ANALYZE, BUFFERS)` in `psql` |
207
+ | Snapshot before a risky migration | `create_snapshot` | Neon console |
342
208
 
343
209
  ```bash
344
- # Complete workflow for Phase 3 schema analysis
210
+ DB_URL=$(neon connection-string)
345
211
 
346
- # 1. Get Neon DB URL
347
- neon connection-string # → pooled connection string
348
-
349
- # 2. List all tables
350
- pg_dump $(neon connection-string) --schema-only --schema public 2>/dev/null | grep "CREATE TABLE"
351
-
352
- # 3. For each relevant table:
353
- psql $(neon connection-string) -c "SELECT column_name, data_type, is_nullable, column_default \
354
- FROM information_schema.columns WHERE table_name = 'TABLE_NAME' ORDER BY ordinal_position"
212
+ psql "$DB_URL" -c "SELECT column_name, data_type, is_nullable, column_default \
213
+ FROM information_schema.columns WHERE table_name = 'leads' ORDER BY ordinal_position"
355
214
 
356
- # 4. Get relationships
357
- psql $(neon connection-string) -c "SELECT tc.table_name, kcu.column_name, ccu.table_name AS foreign_table \
358
- FROM information_schema.table_constraints tc \
215
+ psql "$DB_URL" -c "SELECT tc.table_name, kcu.column_name, ccu.table_name AS foreign_table, \
216
+ ccu.column_name AS foreign_column FROM information_schema.table_constraints tc \
359
217
  JOIN information_schema.key_column_usage kcu ON tc.constraint_name = kcu.constraint_name \
360
218
  JOIN information_schema.constraint_column_usage ccu ON tc.constraint_name = ccu.constraint_name \
361
- WHERE tc.constraint_type = 'FOREIGN KEY' AND tc.table_name = 'TABLE_NAME'"
219
+ WHERE tc.constraint_type = 'FOREIGN KEY' AND tc.table_name = 'leads'"
362
220
 
363
- # → Write findings to schema-analysis.md
221
+ psql "$DB_URL" -c "SELECT tablename, policyname, cmd, qual FROM pg_policies WHERE tablename = 'leads'"
364
222
  ```
365
223
 
366
- ### Context7: Library Research
224
+ **Database not reachable:** grep the queries (`\.from\(|SELECT |DbSet<`), read the entity and type files, and map properties to columns from the code.
225
+
226
+ ## Context7: Library Research
367
227
 
368
- For any phase needing library documentation: resolve the library ID first, then query the specific documentation with it.
228
+ Resolve the library id first, then query the documentation with it.
369
229
 
370
230
  ```javascript
371
231
  const lib = await mcp__context7__resolve-library-id({
372
- libraryName: "fluent-ui-blazor",
373
- query: "dialog component with form validation"
232
+ libraryName: "tanstack table",
233
+ query: "row selection with a stable row id"
374
234
  });
375
235
 
376
236
  const docs = await mcp__context7__query-docs({
377
237
  libraryId: lib.id,
378
- query: "FluentDialog component usage with EditForm validation"
238
+ query: "getRowId and row selection state on a server-paged table"
379
239
  });
380
240
  ```
381
241
 
382
- ### GitHub: Code Search Across Repo (`gh` CLI — sem MCP)
242
+ ## GitHub: `gh` CLI, Never an MCP
383
243
 
384
- O morph-spec **não instala nem usa MCP do GitHub**. O `gh` CLI (autenticado uma vez via `gh auth login`) cobre a mesma superfície com JSON estruturado, sem Docker e sem PAT em variável de ambiente:
244
+ morph-spec neither installs nor uses a GitHub MCP. The `gh` CLI, authenticated once with `gh auth login`, covers the same surface:
385
245
 
386
246
  ```bash
387
- # Find patterns in large codebase during Phase 2
247
+ gh repo view --json name,defaultBranchRef,languages
388
248
  gh search code "DbSet leads" --repo myorg/myrepo --json path,textMatches
389
- # → Find all places that query the leads table
390
-
391
- # Qualquer endpoint REST sem subcomando dedicado:
392
249
  gh api repos/{owner}/{repo}/branches --jq '.[].name'
393
250
  ```
394
251
 
@@ -397,9 +254,10 @@ gh api repos/{owner}/{repo}/branches --jq '.[].name'
397
254
  ## Security Considerations
398
255
 
399
256
  - **Never pass secrets** in MCP tool parameters (API keys, tokens, passwords)
400
- - **Neon** uses neon/psql — use database branches for development, not production
401
- - **GitHub via `gh` CLI** herda as permissões do login do `gh auth login` (keyring) — sem PAT em env var, sem Docker
402
- - **Always validate tool responses** before using in contracts or code generation
257
+ - **Neon:** a development branch, never production; destructive tools only behind a human
258
+ - **GitHub via `gh`** inherits the permissions of the `gh auth login` session (keyring) — no PAT in an environment variable
259
+ - **Paid tools** (morph-assets): the confirmation token comes from a human, never from the agent
260
+ - **Validate a tool response** before turning it into code or into a line of the plan
403
261
 
404
262
  ---
405
263