@el-j/magic-helix-core 4.0.0-beta.2 → 4.0.0-beta.4

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 (165) hide show
  1. package/dist/index-B88j4AyE.js +13 -0
  2. package/dist/index-B88j4AyE.js.map +1 -0
  3. package/dist/index-CY-pQbuu.cjs +2 -0
  4. package/dist/index-CY-pQbuu.cjs.map +1 -0
  5. package/dist/index.cjs +75 -1
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.d.ts +0 -1
  8. package/dist/index.mjs +2214 -51
  9. package/dist/index.mjs.map +1 -1
  10. package/dist/pattern-combiner.d.ts +1 -1
  11. package/dist/plugin-loader.d.ts +2 -1
  12. package/package.json +4 -4
  13. package/dist/BasePlugin-6wv0hYJ9.js +0 -98
  14. package/dist/BasePlugin-6wv0hYJ9.js.map +0 -1
  15. package/dist/BasePlugin-odQJAKA-.cjs +0 -2
  16. package/dist/BasePlugin-odQJAKA-.cjs.map +0 -1
  17. package/dist/builtin-plugins/base/BasePlugin.d.ts +0 -69
  18. package/dist/builtin-plugins/cpp/index.d.ts +0 -46
  19. package/dist/builtin-plugins/csharp/index.d.ts +0 -20
  20. package/dist/builtin-plugins/go/index.d.ts +0 -23
  21. package/dist/builtin-plugins/index.d.ts +0 -16
  22. package/dist/builtin-plugins/java/index.d.ts +0 -22
  23. package/dist/builtin-plugins/nodejs/index.d.ts +0 -44
  24. package/dist/builtin-plugins/php/index.d.ts +0 -20
  25. package/dist/builtin-plugins/python/index.d.ts +0 -27
  26. package/dist/builtin-plugins/ruby/index.d.ts +0 -20
  27. package/dist/builtin-plugins/rust/index.d.ts +0 -53
  28. package/dist/builtin-plugins/swift/index.d.ts +0 -22
  29. package/dist/default_templates/angular/angular-core.md +0 -19
  30. package/dist/default_templates/architecture/codeowners.md +0 -123
  31. package/dist/default_templates/architecture/monorepo.md +0 -146
  32. package/dist/default_templates/architecture/nx.md +0 -122
  33. package/dist/default_templates/architecture/turborepo.md +0 -114
  34. package/dist/default_templates/ci/github-actions.md +0 -268
  35. package/dist/default_templates/ci/gitlab-ci.md +0 -330
  36. package/dist/default_templates/containers/docker-multistage.md +0 -120
  37. package/dist/default_templates/containers/kubernetes-deploy.md +0 -210
  38. package/dist/default_templates/devops/docker-compose.md +0 -111
  39. package/dist/default_templates/devops/docker-dockerfile.md +0 -94
  40. package/dist/default_templates/devops/github-actions.md +0 -160
  41. package/dist/default_templates/devops/gitlab-ci.md +0 -210
  42. package/dist/default_templates/dotnet/framework-aspnetcore.md +0 -205
  43. package/dist/default_templates/dotnet/framework-blazor.md +0 -271
  44. package/dist/default_templates/dotnet/lang-csharp.md +0 -162
  45. package/dist/default_templates/generic/lang-typescript.md +0 -57
  46. package/dist/default_templates/generic/state-redux.md +0 -21
  47. package/dist/default_templates/generic/state-rxjs.md +0 -6
  48. package/dist/default_templates/generic/style-mui.md +0 -23
  49. package/dist/default_templates/generic/style-tailwind.md +0 -76
  50. package/dist/default_templates/generic/test-cypress.md +0 -21
  51. package/dist/default_templates/generic/test-jest.md +0 -20
  52. package/dist/default_templates/generic/test-playwright.md +0 -21
  53. package/dist/default_templates/generic/test-vitest.md +0 -131
  54. package/dist/default_templates/go/lang-go.md +0 -571
  55. package/dist/default_templates/java/build-gradle.md +0 -102
  56. package/dist/default_templates/java/build-maven.md +0 -86
  57. package/dist/default_templates/java/framework-spring-boot.md +0 -179
  58. package/dist/default_templates/java/lang-java.md +0 -78
  59. package/dist/default_templates/java/lang-kotlin.md +0 -88
  60. package/dist/default_templates/meta/magic-helix-meta.md +0 -213
  61. package/dist/default_templates/meta/meta-debug.md +0 -459
  62. package/dist/default_templates/meta/meta-implement.md +0 -450
  63. package/dist/default_templates/meta/meta-roadmap.md +0 -265
  64. package/dist/default_templates/nestjs/nestjs-core.md +0 -7
  65. package/dist/default_templates/patterns/architecture/clean-architecture.md +0 -469
  66. package/dist/default_templates/patterns/architecture/dependency-injection.md +0 -517
  67. package/dist/default_templates/patterns/architecture/domain-driven-design.md +0 -621
  68. package/dist/default_templates/patterns/architecture/layered-architecture.md +0 -382
  69. package/dist/default_templates/patterns/architecture/repository-pattern.md +0 -408
  70. package/dist/default_templates/patterns/domain-expertise/nextjs-rules.md +0 -115
  71. package/dist/default_templates/patterns/domain-expertise/react-patterns.md +0 -181
  72. package/dist/default_templates/patterns/domain-expertise/server-components.md +0 -212
  73. package/dist/default_templates/patterns/domain-expertise/shadcn-ui.md +0 -52
  74. package/dist/default_templates/patterns/domain-expertise/tailwind-patterns.md +0 -52
  75. package/dist/default_templates/patterns/environment/container-awareness.md +0 -17
  76. package/dist/default_templates/patterns/environment/ide-features.md +0 -17
  77. package/dist/default_templates/patterns/environment/os-commands.md +0 -17
  78. package/dist/default_templates/patterns/organization/heading-hierarchy.md +0 -103
  79. package/dist/default_templates/patterns/organization/sequential-workflows.md +0 -102
  80. package/dist/default_templates/patterns/organization/xml-rule-groups.md +0 -64
  81. package/dist/default_templates/patterns/reasoning/agent-loop.md +0 -151
  82. package/dist/default_templates/patterns/reasoning/confirmation-gates.md +0 -141
  83. package/dist/default_templates/patterns/reasoning/dependency-analysis.md +0 -132
  84. package/dist/default_templates/patterns/reasoning/one-tool-per-iteration.md +0 -152
  85. package/dist/default_templates/patterns/reasoning/preview-before-action.md +0 -194
  86. package/dist/default_templates/patterns/reasoning/reflection-checkpoints.md +0 -166
  87. package/dist/default_templates/patterns/reasoning/result-verification.md +0 -157
  88. package/dist/default_templates/patterns/reasoning/subtask-breakdown.md +0 -131
  89. package/dist/default_templates/patterns/reasoning/thinking-tags.md +0 -100
  90. package/dist/default_templates/patterns/role-definition/capability-declarations.md +0 -72
  91. package/dist/default_templates/patterns/role-definition/expert-identity.md +0 -45
  92. package/dist/default_templates/patterns/role-definition/scope-boundaries.md +0 -61
  93. package/dist/default_templates/patterns/safety/code-safety-rules.md +0 -17
  94. package/dist/default_templates/patterns/safety/credential-handling.md +0 -17
  95. package/dist/default_templates/patterns/safety/destructive-warnings.md +0 -17
  96. package/dist/default_templates/patterns/safety/refusal-messages.md +0 -17
  97. package/dist/default_templates/patterns/tone/adaptive-tone.md +0 -17
  98. package/dist/default_templates/patterns/tone/concise-communication.md +0 -17
  99. package/dist/default_templates/patterns/tone/forbidden-phrases.md +0 -17
  100. package/dist/default_templates/patterns/tool-guidelines/function-schemas.md +0 -143
  101. package/dist/default_templates/patterns/tool-guidelines/parameter-examples.md +0 -137
  102. package/dist/default_templates/patterns/tool-guidelines/usage-policies.md +0 -105
  103. package/dist/default_templates/php/framework-laravel.md +0 -112
  104. package/dist/default_templates/php/lang-php.md +0 -94
  105. package/dist/default_templates/python/lang-python.md +0 -508
  106. package/dist/default_templates/react/react-core.md +0 -677
  107. package/dist/default_templates/react/react-zustand.md +0 -7
  108. package/dist/default_templates/ruby/framework-rails.md +0 -309
  109. package/dist/default_templates/ruby/framework-sinatra.md +0 -227
  110. package/dist/default_templates/ruby/lang-ruby.md +0 -216
  111. package/dist/default_templates/rust/lang-rust.md +0 -89
  112. package/dist/default_templates/swift/framework-vapor.md +0 -352
  113. package/dist/default_templates/swift/lang-swift.md +0 -291
  114. package/dist/default_templates/vue/style-primevue.md +0 -6
  115. package/dist/default_templates/vue/style-quasar.md +0 -22
  116. package/dist/default_templates/vue/vue-core.md +0 -108
  117. package/dist/default_templates/vue/vue-pinia.md +0 -5
  118. package/dist/index-0GK4RlUx.js +0 -1748
  119. package/dist/index-0GK4RlUx.js.map +0 -1
  120. package/dist/index-AkVwRl-r.js +0 -92
  121. package/dist/index-AkVwRl-r.js.map +0 -1
  122. package/dist/index-B6BeG1yT.cjs +0 -68
  123. package/dist/index-B6BeG1yT.cjs.map +0 -1
  124. package/dist/index-B8pyjKdF.js +0 -94
  125. package/dist/index-B8pyjKdF.js.map +0 -1
  126. package/dist/index-BQ6v041y.js +0 -13
  127. package/dist/index-BQ6v041y.js.map +0 -1
  128. package/dist/index-Baxb1vI_.js +0 -210
  129. package/dist/index-Baxb1vI_.js.map +0 -1
  130. package/dist/index-Bg8DD8ku.js +0 -216
  131. package/dist/index-Bg8DD8ku.js.map +0 -1
  132. package/dist/index-BqTqxCpG.cjs +0 -89
  133. package/dist/index-BqTqxCpG.cjs.map +0 -1
  134. package/dist/index-Bv4Q1Pr7.cjs +0 -33
  135. package/dist/index-Bv4Q1Pr7.cjs.map +0 -1
  136. package/dist/index-CN8J45Nc.cjs +0 -24
  137. package/dist/index-CN8J45Nc.cjs.map +0 -1
  138. package/dist/index-CPbv2Od1.js +0 -62
  139. package/dist/index-CPbv2Od1.js.map +0 -1
  140. package/dist/index-Cf-MC6Al.js +0 -63
  141. package/dist/index-Cf-MC6Al.js.map +0 -1
  142. package/dist/index-DDPXXXDy.cjs +0 -19
  143. package/dist/index-DDPXXXDy.cjs.map +0 -1
  144. package/dist/index-DO30AzDe.cjs +0 -19
  145. package/dist/index-DO30AzDe.cjs.map +0 -1
  146. package/dist/index-DkvW5yBY.js +0 -2249
  147. package/dist/index-DkvW5yBY.js.map +0 -1
  148. package/dist/index-Dn1ehjIj.cjs +0 -80
  149. package/dist/index-Dn1ehjIj.cjs.map +0 -1
  150. package/dist/index-DqHvgoXJ.cjs +0 -19
  151. package/dist/index-DqHvgoXJ.cjs.map +0 -1
  152. package/dist/index-K39pdw94.cjs +0 -31
  153. package/dist/index-K39pdw94.cjs.map +0 -1
  154. package/dist/index-OT2XAJkc.js +0 -117
  155. package/dist/index-OT2XAJkc.js.map +0 -1
  156. package/dist/index-TPAX4XKg.cjs +0 -30
  157. package/dist/index-TPAX4XKg.cjs.map +0 -1
  158. package/dist/index-WmVSB57y.js +0 -107
  159. package/dist/index-WmVSB57y.js.map +0 -1
  160. package/dist/index-mYXvc3Fs.js +0 -68
  161. package/dist/index-mYXvc3Fs.js.map +0 -1
  162. package/dist/index-nioXOg4m.cjs +0 -76
  163. package/dist/index-nioXOg4m.cjs.map +0 -1
  164. package/dist/index-okhY3fWD.cjs +0 -2
  165. package/dist/index-okhY3fWD.cjs.map +0 -1
@@ -1,205 +0,0 @@
1
- # ASP.NET Core Framework Instructions
2
-
3
- ## Architecture
4
-
5
- ### Minimal API (Modern)
6
- ```csharp
7
- var builder = WebApplication.CreateBuilder(args);
8
- builder.Services.AddEndpointsApiExplorer();
9
- builder.Services.AddSwaggerGen();
10
-
11
- var app = builder.Build();
12
-
13
- app.MapGet("/api/users/{id}", async (int id, UserService service) => {
14
- var user = await service.GetUserAsync(id);
15
- return user is not null ? Results.Ok(user) : Results.NotFound();
16
- });
17
-
18
- app.Run();
19
- ```
20
-
21
- ### Controller-based API
22
- ```csharp
23
- [ApiController]
24
- [Route("api/[controller]")]
25
- public class UsersController : ControllerBase {
26
- private readonly UserService _service;
27
-
28
- public UsersController(UserService service) => _service = service;
29
-
30
- [HttpGet("{id}")]
31
- public async Task<ActionResult<User>> GetUser(int id) {
32
- var user = await _service.GetUserAsync(id);
33
- return user is not null ? Ok(user) : NotFound();
34
- }
35
-
36
- [HttpPost]
37
- public async Task<ActionResult<User>> CreateUser(CreateUserRequest request) {
38
- var user = await _service.CreateUserAsync(request);
39
- return CreatedAtAction(nameof(GetUser), new { id = user.Id }, user);
40
- }
41
- }
42
- ```
43
-
44
- ## Dependency Injection
45
-
46
- ```csharp
47
- // Program.cs
48
- builder.Services.AddDbContext<AppDbContext>(options =>
49
- options.UseNpgsql(builder.Configuration.GetConnectionString("DefaultConnection")));
50
-
51
- builder.Services.AddScoped<IUserRepository, UserRepository>();
52
- builder.Services.AddScoped<UserService>();
53
- builder.Services.AddSingleton<ICacheService, RedisCacheService>();
54
- ```
55
-
56
- ## Entity Framework Core
57
-
58
- ### DbContext
59
- ```csharp
60
- public class AppDbContext : DbContext {
61
- public AppDbContext(DbContextOptions<AppDbContext> options) : base(options) { }
62
-
63
- public DbSet<User> Users => Set<User>();
64
- public DbSet<Order> Orders => Set<Order>();
65
-
66
- protected override void OnModelCreating(ModelBuilder modelBuilder) {
67
- modelBuilder.Entity<User>(entity => {
68
- entity.HasKey(e => e.Id);
69
- entity.HasIndex(e => e.Email).IsUnique();
70
- entity.Property(e => e.Name).HasMaxLength(100).IsRequired();
71
- });
72
- }
73
- }
74
- ```
75
-
76
- ### Migrations
77
- ```bash
78
- dotnet ef migrations add InitialCreate
79
- dotnet ef database update
80
- dotnet ef migrations remove
81
- ```
82
-
83
- ## Configuration
84
-
85
- ### appsettings.json
86
- ```json
87
- {
88
- "ConnectionStrings": {
89
- "DefaultConnection": "Server=localhost;Database=myapp;User Id=sa;Password=P@ssw0rd;"
90
- },
91
- "Logging": {
92
- "LogLevel": {
93
- "Default": "Information",
94
- "Microsoft.AspNetCore": "Warning"
95
- }
96
- },
97
- "JwtSettings": {
98
- "Secret": "${JWT_SECRET}",
99
- "ExpirationMinutes": 60
100
- }
101
- }
102
- ```
103
-
104
- ### Options Pattern
105
- ```csharp
106
- public class JwtSettings {
107
- public string Secret { get; set; } = string.Empty;
108
- public int ExpirationMinutes { get; set; }
109
- }
110
-
111
- // Register
112
- builder.Services.Configure<JwtSettings>(
113
- builder.Configuration.GetSection("JwtSettings"));
114
-
115
- // Use
116
- public class AuthService {
117
- private readonly JwtSettings _settings;
118
-
119
- public AuthService(IOptions<JwtSettings> options) {
120
- _settings = options.Value;
121
- }
122
- }
123
- ```
124
-
125
- ## Middleware
126
-
127
- ```csharp
128
- public class RequestLoggingMiddleware {
129
- private readonly RequestDelegate _next;
130
- private readonly ILogger<RequestLoggingMiddleware> _logger;
131
-
132
- public RequestLoggingMiddleware(RequestDelegate next, ILogger<RequestLoggingMiddleware> logger) {
133
- _next = next;
134
- _logger = logger;
135
- }
136
-
137
- public async Task InvokeAsync(HttpContext context) {
138
- _logger.LogInformation("Request: {Method} {Path}", context.Request.Method, context.Request.Path);
139
- await _next(context);
140
- }
141
- }
142
-
143
- // Register
144
- app.UseMiddleware<RequestLoggingMiddleware>();
145
- ```
146
-
147
- ## Authentication & Authorization
148
-
149
- ```csharp
150
- builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
151
- .AddJwtBearer(options => {
152
- options.TokenValidationParameters = new TokenValidationParameters {
153
- ValidateIssuer = true,
154
- ValidateAudience = true,
155
- ValidateLifetime = true,
156
- ValidateIssuerSigningKey = true,
157
- ValidIssuer = builder.Configuration["Jwt:Issuer"],
158
- ValidAudience = builder.Configuration["Jwt:Audience"],
159
- IssuerSigningKey = new SymmetricSecurityKey(
160
- Encoding.UTF8.GetBytes(builder.Configuration["Jwt:Key"]!))
161
- };
162
- });
163
-
164
- builder.Services.AddAuthorization(options => {
165
- options.AddPolicy("AdminOnly", policy => policy.RequireRole("Admin"));
166
- });
167
- ```
168
-
169
- ## Health Checks
170
-
171
- ```csharp
172
- builder.Services.AddHealthChecks()
173
- .AddNpgSql(builder.Configuration.GetConnectionString("DefaultConnection")!)
174
- .AddRedis(builder.Configuration.GetConnectionString("Redis")!);
175
-
176
- app.MapHealthChecks("/health");
177
- ```
178
-
179
- ## Docker Production Setup
180
-
181
- ```dockerfile
182
- FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine
183
- WORKDIR /app
184
- COPY --from=build /app/publish .
185
-
186
- ENV ASPNETCORE_URLS=http://+:8080
187
- ENV ASPNETCORE_ENVIRONMENT=Production
188
-
189
- EXPOSE 8080
190
- HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
191
- CMD wget --no-verbose --tries=1 --spider http://localhost:8080/health || exit 1
192
-
193
- ENTRYPOINT ["dotnet", "MyApp.dll"]
194
- ```
195
-
196
- ## Performance Best Practices
197
-
198
- - Use async/await throughout
199
- - Enable response compression
200
- - Implement caching (ResponseCache, MemoryCache, Redis)
201
- - Use connection pooling for databases
202
- - Minimize allocations in hot paths
203
- - Use `Span<T>` for high-performance scenarios
204
- - Enable HTTP/2 and HTTP/3
205
- - Use output caching (ASP.NET Core 7+)
@@ -1,271 +0,0 @@
1
- # Blazor Framework Instructions
2
-
3
- ## Blazor Modes
4
-
5
- ### Blazor WebAssembly (Client-side)
6
- - Runs in browser via WebAssembly
7
- - Full .NET runtime in browser
8
- - Offline capable after initial load
9
- - Slower initial load time
10
-
11
- ### Blazor Server (Server-side)
12
- - UI updates via SignalR connection
13
- - Fast initial load
14
- - Less client resources needed
15
- - Requires persistent connection
16
-
17
- ### Blazor Hybrid (.NET MAUI)
18
- - Native desktop/mobile apps
19
- - Uses platform WebView
20
- - Full .NET access
21
-
22
- ## Component Structure
23
-
24
- ### Basic Component
25
- ```razor
26
- @page "/users"
27
- @inject UserService UserService
28
-
29
- <h3>Users</h3>
30
-
31
- @if (users == null) {
32
- <p>Loading...</p>
33
- } else {
34
- <ul>
35
- @foreach (var user in users) {
36
- <li>@user.Name - @user.Email</li>
37
- }
38
- </ul>
39
- }
40
-
41
- @code {
42
- private List<User>? users;
43
-
44
- protected override async Task OnInitializedAsync() {
45
- users = await UserService.GetUsersAsync();
46
- }
47
- }
48
- ```
49
-
50
- ### Component with Parameters
51
- ```razor
52
- @* UserCard.razor *@
53
- <div class="card">
54
- <h4>@User.Name</h4>
55
- <p>@User.Email</p>
56
- <button @onclick="OnDeleteClick">Delete</button>
57
- </div>
58
-
59
- @code {
60
- [Parameter]
61
- public User User { get; set; } = null!;
62
-
63
- [Parameter]
64
- public EventCallback<User> OnDelete { get; set; }
65
-
66
- private async Task OnDeleteClick() {
67
- await OnDelete.InvokeAsync(User);
68
- }
69
- }
70
- ```
71
-
72
- ## Data Binding
73
-
74
- ### Two-way Binding
75
- ```razor
76
- <input @bind="username" />
77
- <input @bind="username" @bind:event="oninput" />
78
-
79
- @code {
80
- private string username = "";
81
- }
82
- ```
83
-
84
- ### Form Validation
85
- ```razor
86
- <EditForm Model="user" OnValidSubmit="HandleSubmit">
87
- <DataAnnotationsValidator />
88
- <ValidationSummary />
89
-
90
- <InputText @bind-Value="user.Name" />
91
- <ValidationMessage For="@(() => user.Name)" />
92
-
93
- <InputText @bind-Value="user.Email" type="email" />
94
- <ValidationMessage For="@(() => user.Email)" />
95
-
96
- <button type="submit">Submit</button>
97
- </EditForm>
98
-
99
- @code {
100
- private UserDto user = new();
101
-
102
- private async Task HandleSubmit() {
103
- await UserService.CreateUserAsync(user);
104
- }
105
- }
106
-
107
- public class UserDto {
108
- [Required]
109
- [StringLength(100)]
110
- public string Name { get; set; } = "";
111
-
112
- [Required]
113
- [EmailAddress]
114
- public string Email { get; set; } = "";
115
- }
116
- ```
117
-
118
- ## Dependency Injection
119
-
120
- ```csharp
121
- // Program.cs (Blazor WebAssembly)
122
- builder.Services.AddScoped<UserService>();
123
- builder.Services.AddScoped(sp => new HttpClient {
124
- BaseAddress = new Uri(builder.HostEnvironment.BaseAddress)
125
- });
126
-
127
- // Program.cs (Blazor Server)
128
- builder.Services.AddScoped<UserService>();
129
- builder.Services.AddDbContext<AppDbContext>(options =>
130
- options.UseNpgsql(builder.Configuration.GetConnectionString("DefaultConnection")));
131
- ```
132
-
133
- ## JavaScript Interop
134
-
135
- ```razor
136
- @inject IJSRuntime JS
137
-
138
- <button @onclick="ShowAlert">Show Alert</button>
139
-
140
- @code {
141
- private async Task ShowAlert() {
142
- await JS.InvokeVoidAsync("alert", "Hello from Blazor!");
143
- }
144
- }
145
- ```
146
-
147
- ```javascript
148
- // wwwroot/js/app.js
149
- window.blazorHelpers = {
150
- focusElement: (elementId) => {
151
- document.getElementById(elementId)?.focus();
152
- }
153
- };
154
- ```
155
-
156
- ```csharp
157
- await JS.InvokeVoidAsync("blazorHelpers.focusElement", "myInput");
158
- ```
159
-
160
- ## State Management
161
-
162
- ### Cascading Parameters
163
- ```razor
164
- <CascadingValue Value="theme">
165
- <ChildComponent />
166
- </CascadingValue>
167
-
168
- @code {
169
- private string theme = "dark";
170
- }
171
-
172
- // In child component
173
- @code {
174
- [CascadingParameter]
175
- public string Theme { get; set; } = "";
176
- }
177
- ```
178
-
179
- ### Scoped Service for State
180
- ```csharp
181
- public class AppState {
182
- public event Action? OnChange;
183
- private string? _currentUser;
184
-
185
- public string? CurrentUser {
186
- get => _currentUser;
187
- set {
188
- _currentUser = value;
189
- NotifyStateChanged();
190
- }
191
- }
192
-
193
- private void NotifyStateChanged() => OnChange?.Invoke();
194
- }
195
-
196
- // Register as scoped
197
- builder.Services.AddScoped<AppState>();
198
-
199
- // Use in component
200
- @implements IDisposable
201
- @inject AppState AppState
202
-
203
- @code {
204
- protected override void OnInitialized() {
205
- AppState.OnChange += StateHasChanged;
206
- }
207
-
208
- public void Dispose() {
209
- AppState.OnChange -= StateHasChanged;
210
- }
211
- }
212
- ```
213
-
214
- ## Performance Optimization
215
-
216
- ### Virtualization
217
- ```razor
218
- <Virtualize Items="@users" Context="user">
219
- <UserCard User="user" />
220
- </Virtualize>
221
- ```
222
-
223
- ### Lazy Loading
224
- ```razor
225
- @page "/admin"
226
- @attribute [Authorize(Roles = "Admin")]
227
-
228
- <h3>Admin Panel</h3>
229
- ```
230
-
231
- ```csharp
232
- // Program.cs
233
- builder.Services.AddScoped<LazyAssemblyLoader>();
234
-
235
- // Load assemblies on demand
236
- await LazyAssemblyLoader.LoadAssembliesAsync(new[] { "AdminModule.dll" });
237
- ```
238
-
239
- ## Docker Deployment
240
-
241
- ### Blazor WebAssembly
242
- ```dockerfile
243
- FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
244
- WORKDIR /src
245
- COPY . .
246
- RUN dotnet publish -c Release -o /app/publish
247
-
248
- FROM nginx:alpine
249
- COPY --from=build /app/publish/wwwroot /usr/share/nginx/html
250
- COPY nginx.conf /etc/nginx/nginx.conf
251
- ```
252
-
253
- ### Blazor Server
254
- ```dockerfile
255
- FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine
256
- WORKDIR /app
257
- COPY --from=build /app/publish .
258
- EXPOSE 8080
259
- ENTRYPOINT ["dotnet", "BlazorApp.dll"]
260
- ```
261
-
262
- ## Best Practices
263
-
264
- - Use `@key` for list items to improve rendering performance
265
- - Avoid unnecessary re-renders with `ShouldRender()`
266
- - Use `StateHasChanged()` sparingly
267
- - Implement proper error boundaries
268
- - Use streaming rendering for improved perceived performance
269
- - Minimize JS interop calls
270
- - Use virtual scrolling for large lists
271
- - Implement proper loading states
@@ -1,162 +0,0 @@
1
- # C# / .NET Instructions
2
-
3
- ## Project Type
4
- - Language: C#
5
- - Framework: {.NET 6|.NET 7|.NET 8}
6
- - App Type: {ASP.NET Core|Console|Library|Blazor|MAUI}
7
-
8
- ## Build Commands
9
-
10
- ```bash
11
- dotnet restore # Restore NuGet packages
12
- dotnet build # Build project
13
- dotnet test # Run tests
14
- dotnet run # Run application
15
- dotnet publish -c Release # Publish for deployment
16
- ```
17
-
18
- ## Code Conventions
19
-
20
- ### C# Modern Features
21
- ```csharp
22
- // Nullable reference types (C# 8+)
23
- #nullable enable
24
- public class User {
25
- public string Name { get; set; } = string.Empty;
26
- public string? Email { get; set; }
27
- }
28
-
29
- // Records (C# 9+)
30
- public record Product(int Id, string Name, decimal Price);
31
-
32
- // Pattern matching (C# 9+)
33
- var result = value switch {
34
- null => "null",
35
- > 0 => "positive",
36
- < 0 => "negative",
37
- _ => "zero"
38
- };
39
- ```
40
-
41
- ### Async/Await
42
- ```csharp
43
- public async Task<User> GetUserAsync(int id) {
44
- var user = await _context.Users.FindAsync(id);
45
- return user ?? throw new NotFoundException();
46
- }
47
- ```
48
-
49
- ### LINQ
50
- ```csharp
51
- var activeUsers = users
52
- .Where(u => u.IsActive)
53
- .OrderBy(u => u.Name)
54
- .Select(u => new UserDto(u.Id, u.Name));
55
- ```
56
-
57
- ## Docker Optimization
58
-
59
- ### Multi-stage Dockerfile
60
- ```dockerfile
61
- # Build stage
62
- FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
63
- WORKDIR /src
64
- COPY ["MyApp.csproj", "./"]
65
- RUN dotnet restore
66
- COPY . .
67
- RUN dotnet publish -c Release -o /app/publish
68
-
69
- # Runtime stage
70
- FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine
71
- WORKDIR /app
72
- COPY --from=build /app/publish .
73
-
74
- # Non-root user
75
- RUN adduser -u 1000 -D appuser && chown -R appuser /app
76
- USER appuser
77
-
78
- EXPOSE 8080
79
- ENTRYPOINT ["dotnet", "MyApp.dll"]
80
- ```
81
-
82
- ### Docker Compose for Development
83
- ```yaml
84
- services:
85
- app:
86
- build: .
87
- ports:
88
- - "8080:8080"
89
- environment:
90
- - ASPNETCORE_ENVIRONMENT=Development
91
- - ConnectionStrings__DefaultConnection=Server=db;Database=mydb;
92
- depends_on:
93
- - db
94
-
95
- db:
96
- image: postgres:15-alpine
97
- environment:
98
- POSTGRES_PASSWORD: devpassword
99
- ```
100
-
101
- ## Testing
102
-
103
- ### Unit Tests (xUnit)
104
- ```csharp
105
- public class UserServiceTests {
106
- [Fact]
107
- public async Task GetUser_ReturnsUser_WhenExists() {
108
- // Arrange
109
- var service = new UserService(mockRepo);
110
-
111
- // Act
112
- var result = await service.GetUserAsync(1);
113
-
114
- // Assert
115
- Assert.NotNull(result);
116
- Assert.Equal("John", result.Name);
117
- }
118
- }
119
- ```
120
-
121
- ### Integration Tests
122
- ```csharp
123
- public class ApiTests : IClassFixture<WebApplicationFactory<Program>> {
124
- private readonly HttpClient _client;
125
-
126
- public ApiTests(WebApplicationFactory<Program> factory) {
127
- _client = factory.CreateClient();
128
- }
129
-
130
- [Fact]
131
- public async Task GetUser_ReturnsOk() {
132
- var response = await _client.GetAsync("/api/users/1");
133
- response.EnsureSuccessStatusCode();
134
- }
135
- }
136
- ```
137
-
138
- ## NuGet Package Management
139
-
140
- ```bash
141
- dotnet add package Microsoft.EntityFrameworkCore
142
- dotnet remove package OldPackage
143
- dotnet list package --outdated
144
- ```
145
-
146
- ## Performance Tips
147
-
148
- - Use `Span<T>` and `Memory<T>` for high-performance scenarios
149
- - Enable nullable reference types for better null safety
150
- - Use `ValueTask` for frequently synchronous operations
151
- - Leverage record types for immutable DTOs
152
- - Use source generators to reduce reflection overhead
153
- - Profile with dotnet-trace and dotnet-counters
154
-
155
- ## Security
156
-
157
- - Enable nullable reference types
158
- - Use `IOptions<T>` for configuration
159
- - Implement proper authentication/authorization
160
- - Validate user input
161
- - Use parameterized queries (EF Core does this)
162
- - Keep dependencies updated
@@ -1,57 +0,0 @@
1
- # Language: TypeScript
2
-
3
- ## Expert Identity
4
- You are an expert TypeScript developer with deep knowledge of static typing, modern ECMAScript features, and type-safe application development.
5
-
6
- ## Core Capabilities
7
- - Write type-safe TypeScript code using strict mode
8
- - Design robust type systems with interfaces and utility types
9
- - Apply modern TypeScript patterns for null safety and immutability
10
- - Debug type errors and provide clear type annotations
11
-
12
- ## Coding Standards
13
-
14
- ### Type Safety
15
- * **ALWAYS** use strict mode (`"strict": true` in `tsconfig.json`).
16
- * **AVOID** the `any` type. Prefer `unknown` when the type is truly unknown.
17
- * **ALWAYS** use `interface` for public API definitions (e.g., function parameters, return types) and `type` for internal or utility types.
18
-
19
- ### Modern Syntax
20
- * **ALWAYS** use optional chaining (`?.`) and nullish coalescing (`??`) over `&&` checks.
21
- * **NEVER** use `require`. Always use ES module `import` syntax.
22
-
23
- ## Examples
24
-
25
- ### Proper Interface Definition
26
- ```typescript
27
- // ✅ Good: Interface for public API
28
- interface UserProfile {
29
- id: string;
30
- name: string;
31
- email?: string; // Optional property
32
- }
33
-
34
- function getUser(id: string): Promise<UserProfile> {
35
- // Implementation
36
- }
37
- ```
38
-
39
- ### Type-Safe Null Handling
40
- ```typescript
41
- // ✅ Good: Using optional chaining and nullish coalescing
42
- const displayName = user?.profile?.name ?? 'Anonymous';
43
-
44
- // ❌ Bad: Manual null checks
45
- const displayName = user && user.profile && user.profile.name ? user.profile.name : 'Anonymous';
46
- ```
47
-
48
- ## Safety Guidelines
49
- - Never generate code that bypasses TypeScript's type system with `@ts-ignore` or `as any` without explicit user request
50
- - Always validate that suggested code compiles without type errors
51
- - Refuse to implement patterns that compromise type safety when asked
52
-
53
- ## Tool Usage
54
- When using file editing or code generation tools:
55
- - Always include proper TypeScript type annotations
56
- - Ensure imports are typed correctly
57
- - Verify that generated code is compatible with strict mode
@@ -1,21 +0,0 @@
1
- # State Management: Redux
2
- - **ALWAYS** use Redux Toolkit (`@reduxjs/toolkit`) for modern Redux development.
3
- - **ALWAYS** use `createSlice()` for reducer logic and actions.
4
- - **ALWAYS** use `configureStore()` for store setup with good defaults.
5
- - **ALWAYS** use TypeScript for type-safe Redux code.
6
- - **ALWAYS** define action types as string constants or use `createAction()`.
7
- - **ALWAYS** use `createAsyncThunk()` for async logic and API calls.
8
- - **ALWAYS** normalize state shape for better performance and consistency.
9
- - **ALWAYS** use selector functions with `createSelector()` for computed values.
10
- - **ALWAYS** use `useSelector()` and `useDispatch()` hooks in React components.
11
- - **ALWAYS** avoid direct state mutations - use immutable updates.
12
- - **ALWAYS** use `redux-persist` for state persistence when needed.
13
- - **ALWAYS** use `redux-saga` or `redux-thunk` for complex async flows.
14
- - **ALWAYS** use `redux-devtools-extension` for debugging in development.
15
- - **ALWAYS** write comprehensive tests for reducers and selectors.
16
- - **ALWAYS** use `entityAdapter` from RTK for CRUD operations.
17
- - **ALWAYS** handle loading and error states in async thunks.
18
- - **ALWAYS** use `extraReducers` in `createSlice()` for async thunk handling.
19
- - **ALWAYS** keep reducers pure and side-effect free.
20
- - **ALWAYS** use meaningful action names and payload structures.
21
- - **ALWAYS** document complex state transformations with comments.