@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
@@ -142,8 +142,6 @@ async ValueTask<object?> ResilientToolMiddleware(
142
142
  }
143
143
  ```
144
144
 
145
- Template completo com registro e stub de anti-hallucination: `templates/code/dotnet/ai-agents/ResilientToolMiddleware.cs.template`.
146
-
147
145
  ---
148
146
 
149
147
  ## Pattern: anti-hallucination
@@ -74,7 +74,7 @@ The agent receives its `instructions:` value from the repository at construction
74
74
  The `agent_prompts` table stores one row per prompt version. See the full migration in:
75
75
 
76
76
  ```
77
- templates/code/sql/ai-agents/agent-prompts-migration.sql.template
77
+ morph-spec scaffold show maf-agent-prompts-migration
78
78
  ```
79
79
 
80
80
  Column summary:
@@ -105,7 +105,7 @@ This index enforces at the database level that only one row per `agent_key` can
105
105
  Reference implementation:
106
106
 
107
107
  ```
108
- templates/code/dotnet/ai-agents/PromptRepository.cs.template
108
+ morph-spec scaffold show maf-prompt-repository
109
109
  ```
110
110
 
111
111
  Interface contract:
@@ -3,7 +3,7 @@
3
3
  > **Scope:** stacks=["dotnet"]
4
4
  > **Layer:** 0 (lista da persona `maf-expert`; resumo injetado pela rule `ai-agents-standards` em `**/Agents/**`, `**/agents/**`, `**/*Agent*.cs`; texto completo sob demanda via `morph-spec standards --find`)
5
5
  > **Keywords:** model registry, provider agnostic, model alias, IChatClient factory, multi-model, model selection, model config, api per alias, responses vs chat, reasoning effort
6
- > **Read by Claude in:** plan (cita este standard quando feature menciona >1 modelo ou multi-provider) + implement (copia o template ModelRegistry.cs e gera config no projeto)
6
+ > **Read by Claude in:** plan (cita este standard quando feature menciona >1 modelo ou multi-provider) + implement (adapta o `ModelRegistry.cs` do ai-kit e gera config no projeto)
7
7
 
8
8
  **Verified against:** Microsoft.Agents.AI 1.20.0 + Microsoft.Extensions.AI 10.9.0 + OpenAI 2.13.0 (ai-pin 2026-09-08); provado por `templates/dotnet/ai-kit/src/Morph.AiKit/Providers/ModelRegistry.cs` e `.../Providers/ModelAlias.cs` e `.../Agents/AgentApi.cs`. Nomes de tipo do `Microsoft.Extensions.AI` e do `OpenAI` medidos por reflexão sobre as assemblies do pin em 2026-09-08. Last-verified: 2026-09-08.
9
9
 
@@ -15,7 +15,7 @@ The project consuming morph-spec maintains a **single JSON file** mapping aliase
15
15
 
16
16
  ```
17
17
  Standard (this file, in framework) — explains the pattern + canonical schema
18
- │ Claude reads + copies template
18
+ │ Claude reads + adapts the ai-kit reference
19
19
  ▼
20
20
  Project (consumer) — config/model-registry.json + src/.../ModelRegistry.cs
21
21
  ```
@@ -189,9 +189,9 @@ Going through `Microsoft.Extensions.AI` (`IChatClient`) or the MAF (`AIAgent`) k
189
189
 
190
190
  **No floating ranges.** Every `PackageReference` above is an exact version. A floating `2.*` on a weekly-cadence SDK is how a production project bought a `MissingMethodException` on the Responses API **after paying for the call**.
191
191
 
192
- **Adding a provider branch:** the `ModelRegistry.cs` template implements `openai` + `ollama`. To add `google`, `anthropic`, or `azure-openai`:
192
+ **Adding a provider branch:** `ModelRegistry` creates no client itself; the project's `IProviderClientFactory.CreateChatClient(ModelAlias)` does. To add `google`, `anthropic`, or `azure-openai`:
193
193
  1. Confirm the current NuGet SDK — community SDKs evolve; check NuGet/context7 before coding.
194
- 2. Add a `case "<provider>":` branch in `ModelRegistry.GetChatClient`'s switch, following the `openai`/`ollama` pattern.
194
+ 2. Add a `"<provider>"` branch to the project's `IProviderClientFactory` implementation, next to the ones it already has.
195
195
  3. Add the SDK `PackageReference` to the project's `.csproj`, with an **exact** version.
196
196
  4. The branch returns an `IChatClient`. If the SDK doesn't expose `IChatClient` natively, wrap it with an adapter.
197
197
 
@@ -212,7 +212,7 @@ var agent = _modelRegistry.GetChatClient("text-default")
212
212
  .AsAIAgent(instructions: prompt);
213
213
  ```
214
214
 
215
- The `ModelRegistry` class in the project owns the mapping. See template `templates/code/dotnet/ai-agents/ModelRegistry.cs.template`, and the compiling reference implementation in `templates/dotnet/ai-kit/src/Morph.AiKit/Providers/`.
215
+ The `ModelRegistry` class in the project owns the mapping. The reference implementation, compiled against the pin, is `src/Morph.AiKit/Providers/` in the ai-kit: `morph-spec scaffold show ai-kit` lists its files and `morph-spec scaffold show ai-kit <file>` prints one.
216
216
 
217
217
  **One client per alias, memoized.** A provider client owns a connection pool and an HTTP handler; rebuilding it per call is how socket exhaustion usually starts. `ModelRegistry.GetChatClient` calls the factory once per alias and hands back the same instance afterwards.
218
218
 
@@ -225,9 +225,9 @@ The `ModelRegistry` class in the project owns the mapping. See template `templat
225
225
  When a task says "register the X agent" and the project has >1 model or >1 provider, Claude:
226
226
 
227
227
  1. Read this standard.
228
- 2. Copy `templates/code/dotnet/ai-agents/ModelRegistry.cs.template` to `src/.../ModelRegistry.cs` in the project. Substitute placeholders.
229
- 3. Copy `templates/code/dotnet/ai-agents/model-registry.json.template` to `config/model-registry.json`. Adjust aliases to project needs, and **declare `api` on every OpenAI alias that is not Responses**.
230
- 4. Wire `ModelRegistry` into DI (see `AgentBootstrap.cs.template`).
228
+ 2. Print `morph-spec scaffold show ai-kit src/Morph.AiKit/Providers/ModelRegistry.cs` (with `ModelAlias.cs` and `IProviderClientFactory.cs` beside it) and adapt them into `src/.../` of the project, under its namespace.
229
+ 3. Print `morph-spec scaffold show ai-kit src/Morph.AiKit/Providers/model-registry.v2.json` and write the project's `config/model-registry.json` from it. Adjust aliases to project needs, and **declare `api` on every OpenAI alias that is not Responses**.
230
+ 4. Register `ModelRegistry` as a singleton in DI, loaded from that file at startup.
231
231
  5. Future agents reference `_modelRegistry.GetChatClient(alias)`.
232
232
 
233
233
  ---
@@ -283,10 +283,7 @@ When a task says "register the X agent" and the project has >1 model or >1 provi
283
283
  - `ai-agents-setup` — provider SDKs, Responses vs Chat Completions setup
284
284
  - `ai-agents-structured-output` — `ResponseFormat` and what else goes into `ChatOptions`
285
285
  - `ai-agents-service-tier-flex` — `serviceTier` in `options`
286
- - Reference implementation (compiles against the pin): `templates/dotnet/ai-kit/src/Morph.AiKit/Providers/`
287
- - Template: `templates/code/dotnet/ai-agents/ModelRegistry.cs.template`
288
- - Template: `templates/code/dotnet/ai-agents/model-registry.json.template`
289
- - Template: `templates/code/dotnet/ai-agents/AgentBootstrap.cs.template`
286
+ - Reference implementation (compiles against the pin): `morph-spec scaffold show ai-kit src/Morph.AiKit/Providers/ModelRegistry.cs`
290
287
 
291
288
  ---
292
289
 
@@ -90,14 +90,10 @@ public static class EmbeddingRegistration
90
90
  }
91
91
  ```
92
92
 
93
- The legacy `templates/code/dotnet/ai-agents/EmbeddingService.cs.template` still generates the wrapper; do not copy it into new code.
94
-
95
93
  ---
96
94
 
97
95
  ## A tabela pgvector
98
96
 
99
- Reference template: `templates/code/sql/ai-agents/pgvector-embeddings-migration.sql.template`
100
-
101
97
  ```sql
102
98
  CREATE TABLE kb_embeddings (
103
99
  id uuid PRIMARY KEY, -- set by the app: deterministic V5 for delta-ingested chunks (rule 3 below), otherwise Guid.CreateVersion7(); never a gen_random_uuid() default
@@ -128,8 +124,6 @@ For pgvector extension setup (`CREATE EXTENSION IF NOT EXISTS vector;`, `UseVect
128
124
 
129
125
  ## VectorSearchTool (tool MAF)
130
126
 
131
- Reference template: `templates/code/dotnet/ai-agents/VectorSearchTool.cs.template`
132
-
133
127
  A sealed class with a `[Description]`-decorated method the agent calls when it needs context from the knowledge base.
134
128
 
135
129
  ```csharp
@@ -179,8 +173,7 @@ Registered on the agent with `tools: [AIFunctionFactory.Create(tool.SearchAsync)
179
173
 
180
174
  The `tenant_id` filter is **never a tool parameter** (that would allow the LLM to cross tenant boundaries). It is injected via a constructor dependency — e.g., a scoped `ITenantContext` or a `Guid currentTenantId` resolved from the authenticated request. See §Multi-tenant below.
181
175
 
182
- Note on raw Npgsql vs EF Core: the EF Core LINQ form above is the default (`ApplicationDbContext` in the slice, no raw SQL). A raw `NpgsqlDataSource` query is acceptable only with a `plan.md` (`## Decisões`) justification (e.g. a project with no EF Core model for this table). The legacy `VectorSearchTool.cs.template` still uses raw SQL and `EmbeddingService`; prefer the block above.
183
-
176
+ Note on raw Npgsql vs EF Core: the EF Core LINQ form above is the default (`ApplicationDbContext` in the slice, no raw SQL). A raw `NpgsqlDataSource` query is acceptable only with a `plan.md` (`## Decisões`) justification (e.g. a project with no EF Core model for this table).
184
177
  ---
185
178
 
186
179
  ## Exemplo de uso
@@ -288,7 +281,7 @@ Each tenant's knowledge is partitioned by `tenant_id`:
288
281
 
289
282
  ```sql
290
283
  ALTER TABLE kb_embeddings ENABLE ROW LEVEL SECURITY;
291
- -- See the project's RLS policy template (templates/code/sql/postgresql-rls-policy.sql)
284
+ -- See the RLS policy template (morph-spec scaffold show sql-rls-policy)
292
285
  -- for the policy pattern that binds app.current_tenant_id to the session.
293
286
  ```
294
287
 
@@ -268,7 +268,7 @@ import Image from 'next/image';
268
268
 
269
269
  ## `assets.md` Format
270
270
 
271
- The `assets.md` file is created during the UI/UX phase (Step 4.5) and consumed by the implement phase.
271
+ `assets.md` is the list of images a feature needs, written while the screen is designed, before any image is generated, and consumed when the assets are produced.
272
272
 
273
273
  ```markdown
274
274
  # Image Assets — {feature}
@@ -27,7 +27,7 @@ A block of 10 ports starting at `4000 + slot × 10`, the slot taken from a hash
27
27
  | +3 | `REDIS_PORT` | `"${REDIS_PORT:-6379}:6379"` (reserved) |
28
28
  | +4..+9 | free | project-specific services |
29
29
 
30
- Also exported: `COMPOSE_PROJECT_NAME` = the branch, lowercased (isolates container, network and volume names). Two branches can hash to the same slot: with many worktrees open at once, a port already taken is the first thing to suspect.
30
+ Also exported: `COMPOSE_PROJECT_NAME` = the branch, lowercased, with every run of characters outside `a-z0-9_-` turned into `-` (isolates container, network and volume names). Two branches can hash to the same slot: with many worktrees open at once, a port already taken is the first thing to suspect.
31
31
 
32
32
  ## Project-named port variables
33
33
 
@@ -46,7 +46,7 @@ Keys are `web`, `api`, `postgres` and `redis`. Each declared name carries the **
46
46
  - ALWAYS keep the database name stable (`POSTGRES_DB: ${POSTGRES_DB:-app}`) — the project name already namespaces the container and the volume; baking a branch name into the DB name outlives the branch
47
47
  - ALWAYS declare a healthcheck on every service — `docker compose up --wait` is meaningless without one
48
48
  - ALWAYS give `DATABASE_URL` an in-network default so the stack comes up with no `.env`: `postgresql://postgres:postgres@postgres:5432/${POSTGRES_DB:-app}`
49
- - ALWAYS read the base URL from the environment in `playwright.config.ts`: `process.env.PLAYWRIGHT_BASE_URL ?? \`http://localhost:${process.env.PORT ?? 3000}\``
49
+ - ALWAYS build the base URL from the port in `playwright.config.ts`: `` baseURL: `http://localhost:${process.env.PORT ?? 3000}` `` — `PORT` is what `morph-spec env` and `morph-spec check` export; nothing in the harness sets a base-URL variable
50
50
  - NEVER put a port from the layout table in a committed `.env` — a value copied from a sibling worktree repoints this stack at the neighbour's postgres. Credentials go in a gitignored file; ports come from the block
51
51
 
52
52
  ## Tearing down