@polymorphism-tech/morph-spec 11.1.1 → 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.
- package/README.md +3 -2
- package/bin/morph-spec.js +13 -23
- package/docs/CHEATSHEET.md +3 -3
- package/docs/QUICKSTART.md +1 -1
- package/framework/CLAUDE.md +3 -1
- package/framework/MORPH.md +8 -3
- package/framework/agents.json +4 -4
- package/framework/docs/CLI.md +28 -18
- package/framework/evals/review-checklist.md +35 -18
- package/framework/hooks/README.md +18 -11
- package/framework/hooks/claude-code/core/README.md +2 -2
- package/framework/hooks/claude-code/core/chain.js +9 -25
- package/framework/hooks/claude-code/core/comment-guard.js +3 -9
- package/framework/hooks/claude-code/core/conventional-commit.js +3 -3
- package/framework/hooks/claude-code/core/graph-refresh-kick.js +6 -6
- package/framework/hooks/claude-code/core/masked-exit.js +4 -3
- package/framework/hooks/claude-code/core/pre-bash-denylist.js +2 -2
- package/framework/hooks/claude-code/core/protect-spec-files.js +2 -4
- package/framework/hooks/claude-code/core/stack-changed.js +5 -4
- package/framework/hooks/claude-code/core/validate-completion.js +15 -12
- package/framework/hooks/shared/contract.js +22 -1
- package/framework/hooks/shared/git-paths.js +6 -0
- package/framework/hooks/shared/graph-freshness.js +3 -3
- package/framework/hooks/shared/graph-refresh.js +5 -10
- package/framework/hooks/shared/hook-response.js +1 -18
- package/framework/hooks/shared/payload-utils.js +12 -1
- package/framework/hooks/shared/phase-utils.js +4 -52
- package/framework/hooks/shared/report-progress.js +1 -1
- package/framework/mcp/registry.json +16 -32
- package/framework/rules/ai-agents-standards.md +9 -1
- package/framework/rules/dotnet-templates.md +32 -33
- package/framework/rules/gsap-standards.md +8 -0
- package/framework/rules/infrastructure-standards.md +9 -9
- package/framework/rules/mcp-standards.md +10 -0
- package/framework/rules/neon-standards.md +4 -4
- package/framework/rules/nextjs-templates.md +10 -11
- package/framework/rules/ui-design.md +2 -2
- package/framework/schemas/config.schema.json +11 -0
- package/framework/skills/core/create-umbraco-lp/SKILL.md +1 -1
- package/framework/skills/core/migrate-lp-to-umbraco/SKILL.md +1 -1
- package/framework/skills/core/morph-apply/SKILL.md +6 -4
- package/framework/skills/core/morph-plan/SKILL.md +1 -1
- package/framework/skills/core/morph-uiux/SKILL.md +5 -5
- package/framework/standards/STANDARDS.json +8 -4
- package/framework/standards/STANDARDS.meta.json +1 -1
- package/framework/standards/ai-agents/agent-archetypes.md +1 -1
- package/framework/standards/ai-agents/middleware-patterns.md +0 -2
- package/framework/standards/ai-agents/prompt-sources.md +2 -2
- package/framework/standards/ai-agents/providers/model-registry.md +9 -12
- package/framework/standards/ai-agents/rag-custom-pgvector.md +2 -9
- package/framework/standards/frontend/design-system/ai-image-generation.md +1 -1
- package/framework/standards/infrastructure/docker/local-compose-isolation.md +2 -2
- package/framework/standards/integration/mcp/mcp-tools.md +125 -267
- package/framework/templates/README.md +52 -82
- package/framework/templates/REGISTRY.json +1 -281
- package/framework/templates/code/sql/ai-agents/agent-prompts-migration.sql.template +3 -4
- package/framework/templates/context/design-system.md +1 -1
- package/framework/templates/docs/plan.md +2 -2
- package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Providers/model-registry.v2.json +1 -1
- package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/MediaDisclosureTests.cs +1 -1
- package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Morph.AiKit.Tests.csproj +3 -5
- package/framework/templates/frontend/nextjs/gsap-scroll-section.tsx.hbs +13 -17
- package/framework/templates/infrastructure/docker/docker-compose.template.yml +15 -16
- package/framework/templates/infrastructure/github/README.md +10 -13
- package/package.json +7 -16
- package/src/commands/graph/build.js +2 -2
- package/src/commands/mcp/manual-setup.js +95 -0
- package/src/commands/mcp/mcp-setup.js +26 -192
- package/src/commands/project/doctor.js +48 -142
- package/src/commands/project/env.js +2 -1
- package/src/commands/project/init-contract.js +2 -2
- package/src/commands/project/init.js +34 -294
- package/src/commands/project/stack-scan.js +6 -14
- package/src/commands/project/stack-set.js +3 -1
- package/src/commands/project/standards.js +1 -2
- package/src/commands/project/update.js +87 -205
- package/src/commands/scaffold/scaffold.js +43 -5
- package/src/commands/validation/check.js +12 -10
- package/src/commands/validation/prove-red.js +61 -22
- package/src/core/paths/output-schema.js +8 -27
- package/src/core/templates/template-registry.js +8 -43
- package/src/core/templates/template-renderer.js +3 -200
- package/src/lib/ai/ai-checks.js +1 -1
- package/src/lib/ai/ai-project-scan.js +2 -5
- package/src/lib/ai/code-audit.js +3 -8
- package/src/lib/ai/registry-audit.js +2 -1
- package/src/lib/check/signals.js +25 -7
- package/src/lib/config/project-config.js +3 -2
- package/src/lib/contract/apply.js +2 -1
- package/src/lib/contract/defaults.js +2 -2
- package/src/lib/contract/merge.js +1 -0
- package/src/lib/contract/scan.js +5 -5
- package/src/lib/detectors/claude-config-detector.js +44 -98
- package/src/lib/detectors/mcp-config.js +2 -1
- package/src/lib/diff/diff-lines.js +4 -9
- package/src/lib/generators/scaffold-generator.js +5 -17
- package/src/lib/git/default-branch.js +5 -13
- package/src/lib/graph/graph-health.js +1 -1
- package/src/lib/graph/graph-loader.js +2 -1
- package/src/lib/graph/graphifyignore.js +5 -5
- package/src/lib/graph/sanitize.js +2 -2
- package/src/lib/installers/effects.js +0 -13
- package/src/lib/installers/install-manifest.js +56 -0
- package/src/lib/installers/mcp-installer.js +16 -19
- package/src/lib/installers/memory-installer.js +5 -8
- package/src/lib/installers/rules-installer.js +9 -15
- package/src/lib/installers/stack-assets.js +54 -7
- package/src/lib/installers/stack-sync.js +16 -16
- package/src/lib/installers/stack-tooling.js +4 -3
- package/src/lib/json-file.js +9 -0
- package/src/lib/plan/artifact-vocabulary.js +1 -1
- package/src/lib/plan/checks.js +4 -3
- package/src/lib/plan/media.js +6 -6
- package/src/lib/plan/plan-parser.js +6 -11
- package/src/lib/review-reports.js +13 -18
- package/src/lib/scan/worktree-dirs.js +1 -3
- package/src/lib/specs/adr-index.js +4 -4
- package/src/lib/specs/revocations.js +3 -3
- package/src/lib/stack/stack-scan.js +4 -4
- package/src/lib/standards/registry.js +1 -1
- package/src/lib/standards/verified-against.js +3 -3
- package/src/lib/tests-audit/audit.js +3 -3
- package/src/lib/text.js +5 -0
- package/src/scripts/global-install.js +41 -19
- package/src/scripts/setup-infra.js +68 -187
- package/src/utils/agents-installer.js +21 -60
- package/src/utils/claude-md-injector.js +16 -50
- package/src/utils/claude-settings-manager.js +29 -27
- package/src/utils/file-copier.js +3 -4
- package/src/utils/hooks-installer.js +83 -62
- package/src/utils/skills-installer.js +18 -78
- package/src/utils/version-checker.js +2 -31
- package/CLAUDE.md +0 -118
- package/framework/commands/create-umbraco-lp.md +0 -37
- package/framework/commands/migrate-lp-to-umbraco.md +0 -35
- package/framework/commands/morph-apply.md +0 -14
- package/framework/hooks/shared/spawn-command.js +0 -23
- package/framework/templates/CLAUDE.md.core.guide.md +0 -29
- package/framework/templates/CLAUDE.md.core.template +0 -22
- package/framework/templates/IDE-SNIPPETS.md +0 -262
- package/framework/templates/code/dotnet/ai-agents/AgentBootstrap.cs.template +0 -26
- package/framework/templates/code/dotnet/ai-agents/EmbeddingService.cs.template +0 -28
- package/framework/templates/code/dotnet/ai-agents/ModelRegistry.cs.template +0 -99
- package/framework/templates/code/dotnet/ai-agents/ResilientToolMiddleware.cs.template +0 -40
- package/framework/templates/code/dotnet/ai-agents/VectorSearchTool.cs.template +0 -54
- package/framework/templates/code/dotnet/ai-agents/model-registry.json.template +0 -53
- package/framework/templates/code/dotnet/contracts/README.md +0 -74
- package/framework/templates/code/dotnet/database/vector-entity.cs +0 -49
- package/framework/templates/code/sql/ai-agents/pgvector-embeddings-migration.sql.template +0 -91
- package/framework/templates/code/sql/postgresql-migration.template.sql +0 -108
- package/framework/templates/code/typescript/contracts.ts +0 -140
- package/framework/templates/context/ARCHITECTURE.md +0 -106
- package/framework/templates/examples/design-system-examples.md +0 -354
- package/framework/templates/infrastructure/docker/Dockerfile.template +0 -58
- package/framework/templates/infrastructure/github/actions/docker-build-push/action.yml.hbs +0 -45
- package/framework/templates/infrastructure/github/actions/health-check/action.yml.hbs +0 -27
- package/framework/templates/integrations/asaas-client.cs +0 -332
- package/framework/templates/integrations/asaas-webhook.cs +0 -290
- package/framework/templates/integrations/neon-auth-config.cs +0 -170
- package/framework/templates/ui/design-system.css +0 -226
- package/src/commands/context/context-refresh.js +0 -63
- package/src/lib/detectors/index.js +0 -178
- package/src/lib/generators/architecture-scanner.js +0 -543
- package/src/lib/generators/settings-generator.js +0 -97
- package/src/lib/graph/god-nodes.js +0 -65
- package/src/lib/installers/templates-reconcile.js +0 -26
|
@@ -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
|
-
|
|
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
|
-
|
|
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 (
|
|
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 +
|
|
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:**
|
|
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 `
|
|
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.
|
|
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.
|
|
229
|
-
3.
|
|
230
|
-
4.
|
|
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): `
|
|
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).
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|