@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.
Files changed (166) hide show
  1. package/README.md +3 -2
  2. package/bin/morph-spec.js +13 -23
  3. package/docs/CHEATSHEET.md +3 -3
  4. package/docs/QUICKSTART.md +1 -1
  5. package/framework/CLAUDE.md +3 -1
  6. package/framework/MORPH.md +8 -3
  7. package/framework/agents.json +4 -4
  8. package/framework/docs/CLI.md +28 -18
  9. package/framework/evals/review-checklist.md +35 -18
  10. package/framework/hooks/README.md +18 -11
  11. package/framework/hooks/claude-code/core/README.md +2 -2
  12. package/framework/hooks/claude-code/core/chain.js +9 -25
  13. package/framework/hooks/claude-code/core/comment-guard.js +3 -9
  14. package/framework/hooks/claude-code/core/conventional-commit.js +3 -3
  15. package/framework/hooks/claude-code/core/graph-refresh-kick.js +6 -6
  16. package/framework/hooks/claude-code/core/masked-exit.js +4 -3
  17. package/framework/hooks/claude-code/core/pre-bash-denylist.js +2 -2
  18. package/framework/hooks/claude-code/core/protect-spec-files.js +2 -4
  19. package/framework/hooks/claude-code/core/stack-changed.js +5 -4
  20. package/framework/hooks/claude-code/core/validate-completion.js +15 -12
  21. package/framework/hooks/shared/contract.js +22 -1
  22. package/framework/hooks/shared/git-paths.js +6 -0
  23. package/framework/hooks/shared/graph-freshness.js +3 -3
  24. package/framework/hooks/shared/graph-refresh.js +5 -10
  25. package/framework/hooks/shared/hook-response.js +1 -18
  26. package/framework/hooks/shared/payload-utils.js +12 -1
  27. package/framework/hooks/shared/phase-utils.js +4 -52
  28. package/framework/hooks/shared/report-progress.js +1 -1
  29. package/framework/mcp/registry.json +16 -32
  30. package/framework/rules/ai-agents-standards.md +9 -1
  31. package/framework/rules/dotnet-templates.md +32 -33
  32. package/framework/rules/gsap-standards.md +8 -0
  33. package/framework/rules/infrastructure-standards.md +9 -9
  34. package/framework/rules/mcp-standards.md +10 -0
  35. package/framework/rules/neon-standards.md +4 -4
  36. package/framework/rules/nextjs-templates.md +10 -11
  37. package/framework/rules/ui-design.md +2 -2
  38. package/framework/schemas/config.schema.json +11 -0
  39. package/framework/skills/core/create-umbraco-lp/SKILL.md +1 -1
  40. package/framework/skills/core/migrate-lp-to-umbraco/SKILL.md +1 -1
  41. package/framework/skills/core/morph-apply/SKILL.md +6 -4
  42. package/framework/skills/core/morph-plan/SKILL.md +1 -1
  43. package/framework/skills/core/morph-uiux/SKILL.md +5 -5
  44. package/framework/standards/STANDARDS.json +8 -4
  45. package/framework/standards/STANDARDS.meta.json +1 -1
  46. package/framework/standards/ai-agents/agent-archetypes.md +1 -1
  47. package/framework/standards/ai-agents/middleware-patterns.md +0 -2
  48. package/framework/standards/ai-agents/prompt-sources.md +2 -2
  49. package/framework/standards/ai-agents/providers/model-registry.md +9 -12
  50. package/framework/standards/ai-agents/rag-custom-pgvector.md +2 -9
  51. package/framework/standards/frontend/design-system/ai-image-generation.md +1 -1
  52. package/framework/standards/infrastructure/docker/local-compose-isolation.md +2 -2
  53. package/framework/standards/integration/mcp/mcp-tools.md +125 -267
  54. package/framework/templates/README.md +52 -82
  55. package/framework/templates/REGISTRY.json +1 -281
  56. package/framework/templates/code/sql/ai-agents/agent-prompts-migration.sql.template +3 -4
  57. package/framework/templates/context/design-system.md +1 -1
  58. package/framework/templates/docs/plan.md +2 -2
  59. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Providers/model-registry.v2.json +1 -1
  60. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/MediaDisclosureTests.cs +1 -1
  61. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Morph.AiKit.Tests.csproj +3 -5
  62. package/framework/templates/frontend/nextjs/gsap-scroll-section.tsx.hbs +13 -17
  63. package/framework/templates/infrastructure/docker/docker-compose.template.yml +15 -16
  64. package/framework/templates/infrastructure/github/README.md +10 -13
  65. package/package.json +7 -16
  66. package/src/commands/graph/build.js +2 -2
  67. package/src/commands/mcp/manual-setup.js +95 -0
  68. package/src/commands/mcp/mcp-setup.js +26 -192
  69. package/src/commands/project/doctor.js +48 -142
  70. package/src/commands/project/env.js +2 -1
  71. package/src/commands/project/init-contract.js +2 -2
  72. package/src/commands/project/init.js +34 -294
  73. package/src/commands/project/stack-scan.js +6 -14
  74. package/src/commands/project/stack-set.js +3 -1
  75. package/src/commands/project/standards.js +1 -2
  76. package/src/commands/project/update.js +87 -205
  77. package/src/commands/scaffold/scaffold.js +43 -5
  78. package/src/commands/validation/check.js +12 -10
  79. package/src/commands/validation/prove-red.js +61 -22
  80. package/src/core/paths/output-schema.js +8 -27
  81. package/src/core/templates/template-registry.js +8 -43
  82. package/src/core/templates/template-renderer.js +3 -200
  83. package/src/lib/ai/ai-checks.js +1 -1
  84. package/src/lib/ai/ai-project-scan.js +2 -5
  85. package/src/lib/ai/code-audit.js +3 -8
  86. package/src/lib/ai/registry-audit.js +2 -1
  87. package/src/lib/check/signals.js +25 -7
  88. package/src/lib/config/project-config.js +3 -2
  89. package/src/lib/contract/apply.js +2 -1
  90. package/src/lib/contract/defaults.js +2 -2
  91. package/src/lib/contract/merge.js +1 -0
  92. package/src/lib/contract/scan.js +5 -5
  93. package/src/lib/detectors/claude-config-detector.js +44 -98
  94. package/src/lib/detectors/mcp-config.js +2 -1
  95. package/src/lib/diff/diff-lines.js +4 -9
  96. package/src/lib/generators/scaffold-generator.js +5 -17
  97. package/src/lib/git/default-branch.js +5 -13
  98. package/src/lib/graph/graph-health.js +1 -1
  99. package/src/lib/graph/graph-loader.js +2 -1
  100. package/src/lib/graph/graphifyignore.js +5 -5
  101. package/src/lib/graph/sanitize.js +2 -2
  102. package/src/lib/installers/effects.js +0 -13
  103. package/src/lib/installers/install-manifest.js +56 -0
  104. package/src/lib/installers/mcp-installer.js +16 -19
  105. package/src/lib/installers/memory-installer.js +5 -8
  106. package/src/lib/installers/rules-installer.js +9 -15
  107. package/src/lib/installers/stack-assets.js +54 -7
  108. package/src/lib/installers/stack-sync.js +16 -16
  109. package/src/lib/installers/stack-tooling.js +4 -3
  110. package/src/lib/json-file.js +9 -0
  111. package/src/lib/plan/artifact-vocabulary.js +1 -1
  112. package/src/lib/plan/checks.js +4 -3
  113. package/src/lib/plan/media.js +6 -6
  114. package/src/lib/plan/plan-parser.js +6 -11
  115. package/src/lib/review-reports.js +13 -18
  116. package/src/lib/scan/worktree-dirs.js +1 -3
  117. package/src/lib/specs/adr-index.js +4 -4
  118. package/src/lib/specs/revocations.js +3 -3
  119. package/src/lib/stack/stack-scan.js +4 -4
  120. package/src/lib/standards/registry.js +1 -1
  121. package/src/lib/standards/verified-against.js +3 -3
  122. package/src/lib/tests-audit/audit.js +3 -3
  123. package/src/lib/text.js +5 -0
  124. package/src/scripts/global-install.js +41 -19
  125. package/src/scripts/setup-infra.js +68 -187
  126. package/src/utils/agents-installer.js +21 -60
  127. package/src/utils/claude-md-injector.js +16 -50
  128. package/src/utils/claude-settings-manager.js +29 -27
  129. package/src/utils/file-copier.js +3 -4
  130. package/src/utils/hooks-installer.js +83 -62
  131. package/src/utils/skills-installer.js +18 -78
  132. package/src/utils/version-checker.js +2 -31
  133. package/CLAUDE.md +0 -118
  134. package/framework/commands/create-umbraco-lp.md +0 -37
  135. package/framework/commands/migrate-lp-to-umbraco.md +0 -35
  136. package/framework/commands/morph-apply.md +0 -14
  137. package/framework/hooks/shared/spawn-command.js +0 -23
  138. package/framework/templates/CLAUDE.md.core.guide.md +0 -29
  139. package/framework/templates/CLAUDE.md.core.template +0 -22
  140. package/framework/templates/IDE-SNIPPETS.md +0 -262
  141. package/framework/templates/code/dotnet/ai-agents/AgentBootstrap.cs.template +0 -26
  142. package/framework/templates/code/dotnet/ai-agents/EmbeddingService.cs.template +0 -28
  143. package/framework/templates/code/dotnet/ai-agents/ModelRegistry.cs.template +0 -99
  144. package/framework/templates/code/dotnet/ai-agents/ResilientToolMiddleware.cs.template +0 -40
  145. package/framework/templates/code/dotnet/ai-agents/VectorSearchTool.cs.template +0 -54
  146. package/framework/templates/code/dotnet/ai-agents/model-registry.json.template +0 -53
  147. package/framework/templates/code/dotnet/contracts/README.md +0 -74
  148. package/framework/templates/code/dotnet/database/vector-entity.cs +0 -49
  149. package/framework/templates/code/sql/ai-agents/pgvector-embeddings-migration.sql.template +0 -91
  150. package/framework/templates/code/sql/postgresql-migration.template.sql +0 -108
  151. package/framework/templates/code/typescript/contracts.ts +0 -140
  152. package/framework/templates/context/ARCHITECTURE.md +0 -106
  153. package/framework/templates/examples/design-system-examples.md +0 -354
  154. package/framework/templates/infrastructure/docker/Dockerfile.template +0 -58
  155. package/framework/templates/infrastructure/github/actions/docker-build-push/action.yml.hbs +0 -45
  156. package/framework/templates/infrastructure/github/actions/health-check/action.yml.hbs +0 -27
  157. package/framework/templates/integrations/asaas-client.cs +0 -332
  158. package/framework/templates/integrations/asaas-webhook.cs +0 -290
  159. package/framework/templates/integrations/neon-auth-config.cs +0 -170
  160. package/framework/templates/ui/design-system.css +0 -226
  161. package/src/commands/context/context-refresh.js +0 -63
  162. package/src/lib/detectors/index.js +0 -178
  163. package/src/lib/generators/architecture-scanner.js +0 -543
  164. package/src/lib/generators/settings-generator.js +0 -97
  165. package/src/lib/graph/god-nodes.js +0 -65
  166. package/src/lib/installers/templates-reconcile.js +0 -26
@@ -1,134 +1,104 @@
1
1
  # MORPH-SPEC Template System
2
2
 
3
- > Handlebars templates organized by **technology**, indexed by `REGISTRY.json`.
3
+ > Templates organized by **technology**, indexed by `REGISTRY.json`.
4
4
 
5
- ## Overview
6
-
7
- **89 templates**, grouped by the technology they target (dotnet, typescript, sql, docker,
8
- nextjs) rather than by stack. A template for a .NET slice serves every stack with a .NET
9
- backend, so a new stack reuses what exists instead of copying it.
5
+ Templates are grouped by the technology they target (dotnet, sql, docker, nextjs)
6
+ rather than by stack: a .NET slice template serves every stack with a .NET backend.
10
7
 
11
8
  `REGISTRY.json` is the source of truth: it maps each template `id` to its `kind`, `path` and
12
- `category` (the shape per kind is in its `kinds` block). Nothing resolves a template by hardcoded path — code goes
13
- through the registry, and this README never repeats a path the registry already owns.
9
+ `category` (the shape per kind is in its `kinds` block). Code resolves a template by id through
10
+ the registry, never by a hardcoded path, and this README repeats no path the registry owns.
11
+
12
+ | Kind | What it is |
13
+ |------|------------|
14
+ | `template` | Rendered to an output file |
15
+ | `fragment` | A reference snippet read as an example, never rendered |
16
+ | `project` | A whole compilable project registered as one unit (`ai-kit`) |
14
17
 
15
18
  ---
16
19
 
17
- ## 📁 Directory Structure
20
+ ## Directory structure
18
21
 
19
22
  ```
20
23
  framework/templates/
21
- ├── docs/ # plan.md (the plan's single source)
22
- ├── context/ # ARCHITECTURE.md, design-system.md
23
- │
24
- ├── code/ # Code templates, by technology
24
+ ├── docs/ # plan.md — the grammar `morph-spec plan-check` parses
25
+ ├── context/ # design-system.md
26
+ ├── code/
25
27
  │ ├── dotnet/ # abstractions, ai-agents, constants, contracts, database,
26
28
  │ │ # exceptions, extensions, feature, jobs, pipelines
27
- │ ├── typescript/ # contracts.ts
28
- │ └── sql/ # postgresql migrations, RLS policy, ai-agents
29
- │
30
- ├── frontend/
31
- │ └── nextjs/ # page, client-component, feature-form, use-feature, env, tsconfig…
32
- │
29
+ │ └── sql/ # postgresql migration, RLS policy, ai-agents
30
+ ├── dotnet/ai-kit/ # Morph.AiKit — the compilable .NET solution behind the ai-agents standards
31
+ ├── frontend/nextjs/ # page, client-component, feature-form, use-feature, env, tsconfig…
33
32
  ├── infrastructure/
34
33
  │ ├── docker/ # Dockerfiles, compose, Coolify config
35
- │ └── github/ # Actions workflows + composite actions (.hbs)
36
- │
37
- ├── integrations/ # asaas-client, asaas-webhook, neon-auth-config
38
- ├── ui/ # design-system.css
39
- ├── examples/ # design-system-examples.md
40
- └── REGISTRY.json # template metadata — the index every consumer reads
34
+ │ └── github/ # Actions workflows (.hbs)
35
+ └── REGISTRY.json
41
36
  ```
42
37
 
43
38
  ---
44
39
 
45
- ## ⚙️ Template Engine: Handlebars
46
-
47
- All templates render through Handlebars with custom helpers registered in
48
- `src/core/templates/template-renderer.js`.
49
-
50
- ```handlebars
51
- # Feature: {{titleCase FEATURE_NAME}}
52
-
53
- namespace {{pascalCase FEATURE_NAME}};
40
+ ## Template engine: Handlebars
54
41
 
55
- Created: {{now}}
56
- ```
57
-
58
- ### Available helpers
42
+ Templates render through Handlebars with the helpers registered in
43
+ `src/core/templates/template-renderer.js`:
59
44
 
60
45
  | Group | Helpers |
61
46
  |-------|---------|
62
- | **Case** | `pascalCase` `camelCase` `snakeCase` `upperSnakeCase` `kebabCase` `titleCase` `uppercase` `lowercase` `capitalize` |
63
- | **Words** | `pluralize` `singularize` |
64
- | **Comparison** | `eq` `ne` `lt` `gt` `lte` `gte` |
65
- | **Logic** | `and` `or` `not` `default` |
66
- | **String** | `trim` `replace` `concat` `substr` `startsWith` `endsWith` `contains` `length` |
67
- | **Math** | `add` `subtract` `multiply` `divide` `mod` `round` |
68
- | **Array** | `join` `first` `last` `slice` |
69
- | **Misc** | `json` `now` `year` `formatDate` |
47
+ | **Case** | `pascalCase` `camelCase` `snakeCase` `upperSnakeCase` `kebabCase` `titleCase` |
48
+ | **Words** | `pluralize` |
49
+ | **Logic** | `eq` `and` `or` `default` |
50
+ | **Misc** | `now` `add` |
70
51
 
71
52
  ```handlebars
72
- {{#if (eq STACK "nextjs-neon")}}
73
- // Neon-specific code
74
- {{else}}
75
- // Generic code
53
+ namespace {{pascalCase FEATURE_NAME}};
54
+
55
+ {{#if (eq STACK "nextjs")}}
56
+ // Next.js only
76
57
  {{/if}}
77
58
  ```
78
59
 
79
- ---
60
+ A helper that is not in the table does not exist: Handlebars throws on it at render time.
80
61
 
81
- ## 🔗 How templates are consumed
62
+ ---
82
63
 
83
- Templates are **resolved from the installed npm package**, not copied into projects.
84
- `morph-spec setup-infra` deliberately skips copying `framework/templates/` — a target project
85
- gets the package's templates for free and stays current on every upgrade.
64
+ ## How templates are consumed
86
65
 
87
- **The consumer is the scaffolder**, which pairs a REGISTRY `id` with an output shape:
66
+ Templates are **resolved from the installed npm package**, never copied into a project: a
67
+ target project gets the package's templates and stays current on every upgrade.
88
68
 
89
69
  ```bash
90
70
  morph-spec scaffold dotnet <feature> <slice-name> # VSA slice (endpoint, handler, request,
91
71
  # response, validator, errors, entity)
92
72
  morph-spec scaffold nextjs <feature> # page, client component, form, hook
73
+ morph-spec scaffold show <template-id> # print one template by its registry id
93
74
  ```
94
75
 
95
- There is **no `morph-spec template` command** — the v4 CLI surface (`list`/`show`/`render`/
96
- `customize`) was removed in the v4→v5 migration. To use a template by hand, read the file and
97
- follow its pattern, or call `renderTemplate()` from the renderer module.
98
-
99
- ### Local override
100
-
101
- A project may shadow any packaged template by placing a file at the same relative path under
102
- `.morph/framework/templates/{path}`. The local copy wins, and **stops receiving framework
103
- updates** — only override when the packaged template genuinely does not fit.
76
+ `scaffold show` is how a session reads a template or a fragment; the ids are listed in the stack
77
+ rules (`*-templates`, `infrastructure-standards`, `neon-standards`, `ai-agents-standards`,
78
+ `gsap-standards`). A `project` is not printed:
79
+ read its files in the package.
104
80
 
105
81
  ---
106
82
 
107
- ## ➕ Adding a template
83
+ ## Adding a template
108
84
 
109
- 1. Create the file under the right technology directory:
110
- `framework/templates/code/{technology}/...` (Handlebars syntax, `.hbs` when the extension
111
- would otherwise confuse tooling).
85
+ 1. Create the file under the right technology directory (Handlebars syntax, `.hbs` when the
86
+ extension would otherwise confuse tooling).
112
87
  2. Register it in `REGISTRY.json` with a unique `id`, its `kind`, `path` and `category`, plus
113
- the fields its kind requires (`kinds` block; `scripts/validate-framework.js` checks them).
114
- 3. If a generator should emit it, add the `id` to the relevant list in
88
+ the fields its kind requires. `npm run validate` checks the shape, the path, the
89
+ placeholders of an entry with `validatePlaceholders: true`, and that every tracked file
90
+ under `templates/` is registered.
91
+ 3. Cite the `id` in the stack rule that should offer it; a template no rule names is never found.
92
+ 4. If the scaffolder should emit it, add the `id` to the list in
115
93
  `src/lib/generators/scaffold-generator.js`.
116
94
 
117
- ### Deprecating a template
118
-
119
- Add `"deprecated": true` plus `"deprecationReason"` to its `REGISTRY.json` entry. Keep the
120
- file until a major version bump.
95
+ Removing a template is removing the file and its registry entry in the same change.
121
96
 
122
97
  ---
123
98
 
124
- ## 📚 References
99
+ ## References
125
100
 
126
- - **Registry API:** [`src/core/templates/template-registry.js`](../../src/core/templates/template-registry.js)
101
+ - **Registry:** [`src/core/templates/template-registry.js`](../../src/core/templates/template-registry.js)
127
102
  - **Renderer + helpers:** [`src/core/templates/template-renderer.js`](../../src/core/templates/template-renderer.js)
128
103
  - **Scaffold generator:** [`src/lib/generators/scaffold-generator.js`](../../src/lib/generators/scaffold-generator.js)
129
- - **Stack filtering:** [`src/lib/stack-filter.js`](../../src/lib/stack-filter.js)
130
104
  - **Handlebars docs:** https://handlebarsjs.com/
131
-
132
- ---
133
-
134
- **MORPH-SPEC Template System** — technology-based, registry-indexed, resolved from the package.