@polymorphism-tech/morph-spec 11.2.0 → 11.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (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 +9 -3
  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,170 +0,0 @@
1
- // Neon Auth signs with EdDSA (Ed25519), which Microsoft.IdentityModel cannot verify: needs BouncyCastle.Cryptography >= 2.3.1 (CVE-2024-30172).
2
- using System.Security.Claims;
3
- using System.Text;
4
- using Microsoft.AspNetCore.Authentication;
5
- using Microsoft.AspNetCore.Authentication.JwtBearer;
6
- using Microsoft.Extensions.Options;
7
- using Microsoft.IdentityModel.JsonWebTokens;
8
- using Microsoft.IdentityModel.Tokens;
9
- using Org.BouncyCastle.Crypto.Parameters;
10
- using Org.BouncyCastle.Crypto.Signers;
11
-
12
- namespace {{Namespace}}.Infrastructure.Auth;
13
-
14
- public class NeonAuthOptions
15
- {
16
- public const string SectionName = "NeonAuth";
17
-
18
- // Public value, commit it in appsettings.Development.json: when missing, every request is a bare 401 with nothing in the logs.
19
- public string BaseUrl { get; set; } = string.Empty;
20
- }
21
-
22
- public sealed class NeonAuthJwksProvider(HttpClient httpClient, IOptions<NeonAuthOptions> options)
23
- {
24
- private static readonly TimeSpan CacheTtl = TimeSpan.FromMinutes(15);
25
- private readonly SemaphoreSlim _refreshLock = new(1, 1);
26
- private JsonWebKeySet? _cached;
27
- private DateTimeOffset _cachedAt;
28
-
29
- public async Task<JsonWebKey?> GetKeyAsync(string kid, CancellationToken cancellationToken)
30
- {
31
- var keySet = await GetKeySetAsync(forceRefresh: false, cancellationToken);
32
- var key = keySet.Keys.FirstOrDefault(k => k.Kid == kid);
33
- if (key is not null) return key;
34
-
35
- // Unknown kid may be a key rotation: refresh once instead of waiting out the TTL.
36
- keySet = await GetKeySetAsync(forceRefresh: true, cancellationToken);
37
- return keySet.Keys.FirstOrDefault(k => k.Kid == kid);
38
- }
39
-
40
- private async Task<JsonWebKeySet> GetKeySetAsync(bool forceRefresh, CancellationToken cancellationToken)
41
- {
42
- if (!forceRefresh && _cached is not null && DateTimeOffset.UtcNow - _cachedAt < CacheTtl)
43
- return _cached;
44
-
45
- await _refreshLock.WaitAsync(cancellationToken);
46
- try
47
- {
48
- if (!forceRefresh && _cached is not null && DateTimeOffset.UtcNow - _cachedAt < CacheTtl)
49
- return _cached;
50
-
51
- var jwksUri = $"{options.Value.BaseUrl.TrimEnd('/')}/.well-known/jwks.json";
52
- var json = await httpClient.GetStringAsync(jwksUri, cancellationToken);
53
- _cached = new JsonWebKeySet(json);
54
- _cachedAt = DateTimeOffset.UtcNow;
55
- return _cached;
56
- }
57
- finally
58
- {
59
- _refreshLock.Release();
60
- }
61
- }
62
- }
63
-
64
- public static class NeonAuthServiceExtensions
65
- {
66
- public static IServiceCollection AddNeonAuthentication(
67
- this IServiceCollection services,
68
- IConfiguration configuration)
69
- {
70
- services.Configure<NeonAuthOptions>(configuration.GetSection(NeonAuthOptions.SectionName));
71
- services.AddHttpClient<NeonAuthJwksProvider>();
72
-
73
- services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
74
- .AddJwtBearer(options =>
75
- {
76
- // No options.Authority: Neon Auth serves no /.well-known/openid-configuration to fetch.
77
- options.TokenValidationParameters = new TokenValidationParameters
78
- {
79
- ValidateIssuer = true,
80
- ValidIssuer = configuration["NeonAuth:BaseUrl"],
81
- ValidateAudience = false,
82
- ValidateLifetime = true,
83
- NameClaimType = "sub",
84
- // The key is trusted inside SignatureValidator below, not by this flag.
85
- ValidateIssuerSigningKey = false,
86
- };
87
- });
88
-
89
- // Separate pass because the validator needs NeonAuthJwksProvider from DI.
90
- services.AddOptions<JwtBearerOptions>(JwtBearerDefaults.AuthenticationScheme)
91
- .Configure<NeonAuthJwksProvider>((options, jwks) =>
92
- {
93
- options.TokenValidationParameters.SignatureValidator = (token, _) =>
94
- {
95
- var jwt = new JsonWebToken(token);
96
-
97
- // Pin the algorithm against alg-substitution attacks.
98
- if (!string.Equals(jwt.Alg, "EdDSA", StringComparison.Ordinal))
99
- throw new SecurityTokenInvalidSignatureException(
100
- $"Unsupported alg '{jwt.Alg}' — Neon Auth tokens must be EdDSA.");
101
-
102
- var kid = jwt.Kid;
103
- if (string.IsNullOrEmpty(kid))
104
- throw new SecurityTokenInvalidSignatureException("Token is missing 'kid'.");
105
-
106
- // SignatureValidator has no async overload; the JWKS is cached, so only a cold miss blocks on I/O.
107
- var jwk = jwks.GetKeyAsync(kid, CancellationToken.None).GetAwaiter().GetResult()
108
- ?? throw new SecurityTokenInvalidSignatureException(
109
- $"No JWKS key found for kid '{kid}'.");
110
-
111
- if (jwk.Kty != "OKP" || jwk.Crv != "Ed25519")
112
- throw new SecurityTokenInvalidSignatureException(
113
- "JWKS key is not an Ed25519 (OKP) key.");
114
-
115
- var parts = token.Split('.');
116
- if (parts.Length != 3)
117
- throw new SecurityTokenInvalidSignatureException(
118
- "Malformed JWT — expected 3 segments.");
119
-
120
- var signingInput = Encoding.ASCII.GetBytes($"{parts[0]}.{parts[1]}");
121
- var signature = Base64UrlEncoder.DecodeBytes(parts[2]);
122
- var publicKey = new Ed25519PublicKeyParameters(Base64UrlEncoder.DecodeBytes(jwk.X), 0);
123
-
124
- var verifier = new Ed25519Signer();
125
- verifier.Init(forSigning: false, publicKey);
126
- verifier.BlockUpdate(signingInput, 0, signingInput.Length);
127
-
128
- if (!verifier.VerifySignature(signature))
129
- throw new SecurityTokenInvalidSignatureException(
130
- "Ed25519 signature verification failed.");
131
-
132
- // Must be JsonWebToken: returning a JwtSecurityToken fails with IDX10506 on ASP.NET Core 8+.
133
- return jwt;
134
- };
135
- });
136
-
137
- services.AddAuthorization();
138
-
139
- return services;
140
- }
141
- }
142
-
143
- public interface ICurrentUserService
144
- {
145
- string? UserId { get; }
146
- string? Email { get; }
147
- bool IsAuthenticated { get; }
148
- }
149
-
150
- public class CurrentUserService(IHttpContextAccessor httpContextAccessor) : ICurrentUserService
151
- {
152
- public string? UserId =>
153
- httpContextAccessor.HttpContext?.User.FindFirstValue("sub");
154
-
155
- public string? Email =>
156
- httpContextAccessor.HttpContext?.User.FindFirstValue("email");
157
-
158
- public bool IsAuthenticated =>
159
- httpContextAccessor.HttpContext?.User.Identity?.IsAuthenticated ?? false;
160
- }
161
-
162
- public static class NeonAuthMiddlewareExtensions
163
- {
164
- public static IApplicationBuilder UseNeonAuthentication(this IApplicationBuilder app)
165
- {
166
- app.UseAuthentication();
167
- app.UseAuthorization();
168
- return app;
169
- }
170
- }
@@ -1,226 +0,0 @@
1
- /**
2
- * Design System - {Project Name}
3
- *
4
- * CSS Variables generated from design-system.md
5
- * Use estas variáveis em todo o projeto para manter consistência visual.
6
- *
7
- * Template MORPH-SPEC by Polymorphism Tech
8
- */
9
-
10
- :root {
11
- /* ========================================
12
- * CORES PRINCIPAIS
13
- * ======================================== */
14
-
15
- --color-primary: #{hex da cor primária};
16
- --color-primary-hover: #{hex da cor primária mais escura};
17
- --color-primary-active: #{hex da cor primária ainda mais escura};
18
-
19
- --color-secondary: #{hex da cor secundária};
20
- --color-secondary-hover: #{hex};
21
- --color-secondary-active: #{hex};
22
-
23
- /* ========================================
24
- * CORES DE ESTADO
25
- * ======================================== */
26
-
27
- --color-success: #{hex};
28
- --color-success-bg: #{hex com transparência ou shade mais claro};
29
- --color-success-border: #{hex};
30
-
31
- --color-error: #{hex};
32
- --color-error-bg: #{hex};
33
- --color-error-border: #{hex};
34
-
35
- --color-warning: #{hex};
36
- --color-warning-bg: #{hex};
37
- --color-warning-border: #{hex};
38
-
39
- --color-info: #{hex};
40
- --color-info-bg: #{hex};
41
- --color-info-border: #{hex};
42
-
43
- /* ========================================
44
- * ESCALA DE NEUTROS (Cinzas)
45
- * ======================================== */
46
-
47
- --color-gray-50: #{hex};
48
- --color-gray-100: #{hex};
49
- --color-gray-200: #{hex};
50
- --color-gray-300: #{hex};
51
- --color-gray-400: #{hex};
52
- --color-gray-500: #{hex};
53
- --color-gray-600: #{hex};
54
- --color-gray-700: #{hex};
55
- --color-gray-800: #{hex};
56
- --color-gray-900: #{hex};
57
-
58
- /* ========================================
59
- * TIPOGRAFIA - FONTES
60
- * ======================================== */
61
-
62
- --font-sans: '{Font Name}', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
63
- --font-serif: '{Font Name}', Georgia, 'Times New Roman', serif;
64
- --font-mono: '{Font Name}', 'Fira Code', 'Courier New', Consolas, monospace;
65
-
66
- /* ========================================
67
- * TIPOGRAFIA - TAMANHOS
68
- * ======================================== */
69
-
70
- --text-xs: 0.75rem; /* 12px */
71
- --text-sm: 0.875rem; /* 14px */
72
- --text-base: 1rem; /* 16px */
73
- --text-lg: 1.125rem; /* 18px */
74
- --text-xl: 1.25rem; /* 20px */
75
- --text-2xl: 1.5rem; /* 24px */
76
- --text-3xl: 1.875rem; /* 30px */
77
- --text-4xl: 2.25rem; /* 36px */
78
- --text-5xl: 3rem; /* 48px */
79
-
80
- /* ========================================
81
- * TIPOGRAFIA - LINE HEIGHTS
82
- * ======================================== */
83
-
84
- --leading-none: 1;
85
- --leading-tight: 1.25;
86
- --leading-snug: 1.375;
87
- --leading-normal: 1.5;
88
- --leading-relaxed: 1.625;
89
- --leading-loose: 2;
90
-
91
- /* ========================================
92
- * TIPOGRAFIA - FONT WEIGHTS
93
- * ======================================== */
94
-
95
- --font-light: 300;
96
- --font-regular: 400;
97
- --font-medium: 500;
98
- --font-semibold: 600;
99
- --font-bold: 700;
100
- --font-extrabold: 800;
101
-
102
- /* ========================================
103
- * ESPAÇAMENTO
104
- * Baseado em múltiplos de {base}px (ex: 4px)
105
- * ======================================== */
106
-
107
- --space-0: 0;
108
- --space-1: 0.25rem; /* 4px */
109
- --space-2: 0.5rem; /* 8px */
110
- --space-3: 0.75rem; /* 12px */
111
- --space-4: 1rem; /* 16px */
112
- --space-5: 1.25rem; /* 20px */
113
- --space-6: 1.5rem; /* 24px */
114
- --space-7: 1.75rem; /* 28px */
115
- --space-8: 2rem; /* 32px */
116
- --space-10: 2.5rem; /* 40px */
117
- --space-12: 3rem; /* 48px */
118
- --space-16: 4rem; /* 64px */
119
- --space-20: 5rem; /* 80px */
120
- --space-24: 6rem; /* 96px */
121
-
122
- /* ========================================
123
- * BORDER RADIUS
124
- * ======================================== */
125
-
126
- --rounded-none: 0;
127
- --rounded-sm: 0.125rem; /* 2px */
128
- --rounded-md: 0.375rem; /* 6px */
129
- --rounded-lg: 0.5rem; /* 8px */
130
- --rounded-xl: 0.75rem; /* 12px */
131
- --rounded-2xl: 1rem; /* 16px */
132
- --rounded-full: 9999px;
133
-
134
- /* ========================================
135
- * SOMBRAS (Shadows)
136
- * ======================================== */
137
-
138
- --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
139
- --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
140
- --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
141
- --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
142
- --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
143
-
144
- /* ========================================
145
- * Z-INDEX LAYERS
146
- * ======================================== */
147
-
148
- --z-0: 0;
149
- --z-10: 10;
150
- --z-20: 20;
151
- --z-30: 30;
152
- --z-40: 40;
153
- --z-50: 50; /* Modals, dropdowns */
154
- --z-100: 100; /* Tooltips */
155
- --z-max: 9999; /* Toasts, notifications */
156
-
157
- /* ========================================
158
- * TRANSITIONS / ANIMATIONS
159
- * ======================================== */
160
-
161
- --transition-fast: 150ms ease-in-out;
162
- --transition-base: 250ms ease-in-out;
163
- --transition-slow: 350ms ease-in-out;
164
-
165
- --ease-in: cubic-bezier(0.4, 0, 1, 1);
166
- --ease-out: cubic-bezier(0, 0, 0.2, 1);
167
- --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
168
-
169
- /* ========================================
170
- * BREAKPOINTS (informativo - usar em media queries)
171
- * ======================================== */
172
-
173
- /* @media (min-width: 640px) - sm */
174
- /* @media (min-width: 768px) - md */
175
- /* @media (min-width: 1024px) - lg */
176
- /* @media (min-width: 1280px) - xl */
177
- /* @media (min-width: 1536px) - 2xl */
178
- }
179
-
180
- /* ========================================
181
- * MODO ESCURO (Dark Mode)
182
- * Opcional - ajuste as cores para dark theme
183
- * ======================================== */
184
-
185
- @media (prefers-color-scheme: dark) {
186
- :root {
187
- /* Inverter cores conforme necessário */
188
- --color-gray-50: #{hex do gray-900};
189
- --color-gray-900: #{hex do gray-50};
190
- /* ... outras inversões */
191
- }
192
- }
193
-
194
- /* ========================================
195
- * CLASSES UTILITÁRIAS (Exemplo)
196
- * ======================================== */
197
-
198
- /* Exemplo de uso das variáveis */
199
- .btn-primary {
200
- background-color: var(--color-primary);
201
- color: white;
202
- padding: var(--space-2) var(--space-4);
203
- border-radius: var(--rounded-md);
204
- font-weight: var(--font-semibold);
205
- transition: background-color var(--transition-base);
206
- }
207
-
208
- .btn-primary:hover {
209
- background-color: var(--color-primary-hover);
210
- }
211
-
212
- .card {
213
- background-color: white;
214
- padding: var(--space-6);
215
- border-radius: var(--rounded-lg);
216
- box-shadow: var(--shadow-md);
217
- }
218
-
219
- .text-muted {
220
- color: var(--color-gray-600);
221
- font-size: var(--text-sm);
222
- }
223
-
224
- /* ========================================
225
- * FIM DO DESIGN SYSTEM
226
- * ======================================== */
@@ -1,153 +0,0 @@
1
- import { existsSync, readFileSync, readdirSync } from 'fs';
2
- import { join } from 'path';
3
-
4
- import { PACKAGE_LOCATIONS } from '../../../framework/hooks/shared/frontend-locations.js';
5
-
6
- export { PACKAGE_LOCATIONS };
7
-
8
- export function detectProject(targetPath) {
9
- const structure = {
10
- stack: 'unknown',
11
- uiLibrary: null,
12
- integrations: [],
13
- hasVercel: false,
14
- };
15
-
16
- try {
17
- const allDeps = {};
18
- let rootPkg = null;
19
- let scripts = [];
20
- for (const loc of PACKAGE_LOCATIONS) {
21
- const pkgPath = join(targetPath, loc, 'package.json');
22
- if (!existsSync(pkgPath)) continue;
23
- try {
24
- const pkg = JSON.parse(readFileSync(pkgPath, 'utf8'));
25
- if (loc === '.') rootPkg = pkg;
26
- Object.assign(allDeps, pkg.dependencies, pkg.devDependencies);
27
- scripts.push(...Object.keys(pkg.scripts || {}));
28
- if (loc !== '.' && (pkg.dependencies?.next || pkg.dependencies?.react || pkg.dependencies?.vue)) {
29
- structure.frontendPath = loc;
30
- }
31
- } catch {}
32
- }
33
- const depNames = Object.keys(allDeps);
34
-
35
- if (depNames.length > 0) {
36
-
37
- if (depNames.includes('next')) {
38
- structure.stack = 'nextjs';
39
- } else if (depNames.includes('react')) {
40
- structure.stack = 'react';
41
- } else if (depNames.includes('vue')) {
42
- structure.stack = 'vue';
43
- } else if (depNames.includes('express') || depNames.includes('fastify') || depNames.includes('hono')) {
44
- structure.stack = 'node';
45
- } else if (rootPkg?.name) {
46
- structure.stack = 'node';
47
- }
48
-
49
- if (existsSync(join(targetPath, 'components.json')) || existsSync(join(targetPath, structure.frontendPath || '.', 'components.json')) || depNames.includes('@shadcn/ui')) {
50
- structure.uiLibrary = 'shadcn';
51
- }
52
-
53
- if (depNames.includes('@neondatabase/serverless') || depNames.includes('postgres') || depNames.includes('pg')) {
54
- structure.integrations.push('neon');
55
- }
56
- if (depNames.includes('@neon/auth') || depNames.includes('@neondatabase/auth')) {
57
- structure.integrations.push('neon-auth');
58
- }
59
- if (depNames.includes('stripe')) {
60
- structure.integrations.push('stripe');
61
- }
62
-
63
- if (depNames.includes('vercel') || scripts.includes('vercel')) {
64
- structure.hasVercel = true;
65
- }
66
- }
67
-
68
- let hasDotnet = false;
69
- const csprojLocations = ['.', 'src', 'src/Api', 'src/Web', 'src/backend'];
70
-
71
- function checkCsproj(filePath) {
72
- hasDotnet = true;
73
- try {
74
- const content = readFileSync(filePath, 'utf8');
75
- if (content.includes('Hangfire')) {
76
- if (!structure.integrations.includes('hangfire')) structure.integrations.push('hangfire');
77
- }
78
- // Same heuristic as the package.json side (`pg`/`postgres` → neon).
79
- if (content.includes('Npgsql')) {
80
- if (!structure.integrations.includes('neon')) structure.integrations.push('neon');
81
- }
82
- } catch {}
83
- }
84
-
85
- for (const loc of csprojLocations) {
86
- try {
87
- const dir = join(targetPath, loc);
88
- if (!existsSync(dir)) continue;
89
- const entries = readdirSyncSafe(dir);
90
- for (const e of entries.filter(f => f.endsWith('.csproj'))) {
91
- checkCsproj(join(dir, e));
92
- }
93
- for (const sub of entries) {
94
- const subDir = join(dir, sub);
95
- for (const e of readdirSyncSafe(subDir).filter(f => f.endsWith('.csproj'))) {
96
- checkCsproj(join(subDir, e));
97
- }
98
- }
99
- } catch {}
100
- }
101
-
102
- if (hasDotnet) {
103
- if (structure.stack === 'nextjs' || structure.stack === 'react' || structure.stack === 'vue') {
104
- structure.stack = `${structure.stack}+dotnet`;
105
- } else if (structure.stack === 'unknown') {
106
- structure.stack = 'dotnet';
107
- }
108
- }
109
-
110
- if (existsSync(join(targetPath, 'vercel.json'))) {
111
- structure.hasVercel = true;
112
- }
113
-
114
- if (structure.stack === 'unknown' && existsSync(join(targetPath, 'tsconfig.json'))) {
115
- structure.stack = 'node';
116
- }
117
-
118
- if (existsSync(join(targetPath, 'docker-compose.yml')) ||
119
- existsSync(join(targetPath, 'docker-compose.yaml')) ||
120
- existsSync(join(targetPath, 'Dockerfile'))) {
121
- if (!structure.integrations.includes('docker')) structure.integrations.push('docker');
122
- }
123
-
124
- const azureSignals = [
125
- '.azure',
126
- 'azure-pipelines.yml',
127
- 'infra/main.bicep',
128
- 'infra',
129
- ];
130
- const hasAzure = azureSignals.some(signal => {
131
- const p = join(targetPath, signal);
132
- if (!existsSync(p)) return false;
133
- if (signal === 'infra') {
134
- return readdirSyncSafe(p).some(f => f.endsWith('.bicep'));
135
- }
136
- return true;
137
- });
138
- if (hasAzure && !structure.integrations.includes('azure')) {
139
- structure.integrations.push('azure');
140
- }
141
- } catch {
142
- }
143
-
144
- return { structure };
145
- }
146
-
147
- function readdirSyncSafe(dir) {
148
- try {
149
- return readdirSync(dir);
150
- } catch {
151
- return [];
152
- }
153
- }
@@ -1,26 +0,0 @@
1
- import { existsSync } from 'fs';
2
- import { compareVersions } from '../../utils/version-checker.js';
3
- import { realEffects } from './effects.js';
4
-
5
- // Last CLI version whose install still copied `.morph/framework/templates/` unconditionally.
6
- export const LAST_VERSION_THAT_COPIED_TEMPLATES = '8.17.0';
7
-
8
- // Decided by the PRIOR recorded version, not by diffing: a diff can't tell a stale copy from an override.
9
- // Unrecorded or <= the boundary → only the old installer could have written it, delete.
10
- // Newer → placed deliberately, preserve.
11
- export function reconcileLegacyTemplatesCopy(templatesDest, priorProjectVersion, fx = realEffects()) {
12
- if (!existsSync(templatesDest)) return 'absent';
13
-
14
- const isLegacy = !priorProjectVersion
15
- || compareVersions(priorProjectVersion, LAST_VERSION_THAT_COPIED_TEMPLATES) <= 0;
16
-
17
- if (!isLegacy) return 'preserved-override';
18
-
19
- try {
20
- fx.remove(templatesDest);
21
- return 'removed-legacy';
22
- } catch {
23
- // Couldn't remove: leave it; the resolver's override-first check picks it up.
24
- return 'preserved-override';
25
- }
26
- }