@polymorphism-tech/morph-spec 4.7.1 → 4.8.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 (138) hide show
  1. package/.morph/analytics/threads-log.jsonl +54 -0
  2. package/.morph/state.json +198 -0
  3. package/LICENSE +1 -2
  4. package/README.md +379 -414
  5. package/bin/morph-spec.js +57 -403
  6. package/bin/validate.js +2 -26
  7. package/claude-plugin.json +2 -2
  8. package/docs/ARCHITECTURE.md +43 -46
  9. package/docs/CHEATSHEET.md +203 -221
  10. package/docs/COMMAND-FLOWS.md +319 -289
  11. package/docs/QUICKSTART.md +2 -8
  12. package/docs/plans/2026-02-22-claude-docs-morph-alignment-analysis.md +2 -0
  13. package/docs/plans/2026-02-22-claude-settings.md +2 -0
  14. package/docs/plans/2026-02-22-morph-cc-alignment-impl.md +2 -0
  15. package/docs/plans/2026-02-22-morph-spec-next.md +2 -0
  16. package/docs/plans/2026-02-22-native-alignment-design.md +2 -0
  17. package/docs/plans/2026-02-22-native-alignment-impl.md +2 -0
  18. package/docs/plans/2026-02-22-native-enrichment-design.md +2 -0
  19. package/docs/plans/2026-02-22-native-enrichment.md +2 -0
  20. package/docs/plans/2026-02-23-ddd-architecture-refactor.md +2 -0
  21. package/docs/plans/2026-02-23-ddd-nextsteps.md +2 -0
  22. package/docs/plans/2026-02-23-infra-architect-refactor.md +2 -0
  23. package/docs/plans/2026-02-23-nextjs-code-review-design.md +2 -1
  24. package/docs/plans/2026-02-23-nextjs-code-review-impl.md +2 -0
  25. package/docs/plans/2026-02-23-nextjs-standards-design.md +2 -1
  26. package/docs/plans/2026-02-23-nextjs-standards-impl.md +2 -0
  27. package/docs/plans/2026-02-24-cli-radical-simplification.md +592 -0
  28. package/docs/plans/2026-02-24-framework-failure-points.md +125 -0
  29. package/docs/plans/2026-02-24-morph-init-design.md +337 -0
  30. package/docs/plans/2026-02-24-morph-init-impl.md +1269 -0
  31. package/docs/plans/2026-02-24-tutorial-command-design.md +71 -0
  32. package/docs/plans/2026-02-24-tutorial-command.md +298 -0
  33. package/framework/CLAUDE.md +2 -2
  34. package/framework/commands/morph-proposal.md +3 -3
  35. package/framework/hooks/README.md +11 -10
  36. package/framework/hooks/claude-code/notification/approval-reminder.js +2 -0
  37. package/framework/hooks/claude-code/post-tool-use/dispatch.js +1 -1
  38. package/framework/hooks/claude-code/pre-tool-use/protect-readonly-files.js +4 -55
  39. package/framework/hooks/claude-code/session-start/inject-morph-context.js +20 -5
  40. package/framework/hooks/claude-code/statusline.py +6 -1
  41. package/framework/hooks/claude-code/stop/validate-completion.js +1 -1
  42. package/framework/hooks/claude-code/user-prompt/enrich-prompt.js +1 -1
  43. package/framework/hooks/dev/check-sync-health.js +117 -0
  44. package/framework/hooks/dev/guard-version-numbers.js +57 -0
  45. package/framework/hooks/dev/sync-standards-registry.js +60 -0
  46. package/framework/hooks/dev/sync-template-registry.js +60 -0
  47. package/framework/hooks/dev/validate-skill-format.js +70 -0
  48. package/framework/hooks/dev/validate-standard-format.js +73 -0
  49. package/framework/hooks/shared/payload-utils.js +39 -0
  50. package/framework/hooks/shared/state-reader.js +25 -1
  51. package/framework/rules/morph-workflow.md +1 -1
  52. package/framework/skills/level-0-meta/morph-init/SKILL.md +216 -0
  53. package/framework/skills/level-0-meta/morph-replicate/SKILL.md +4 -4
  54. package/framework/skills/level-0-meta/tool-usage-guide/SKILL.md +4 -4
  55. package/framework/skills/level-0-meta/verification-before-completion/SKILL.md +1 -1
  56. package/framework/skills/level-1-workflows/phase-clarify/SKILL.md +192 -191
  57. package/framework/skills/level-1-workflows/phase-codebase-analysis/SKILL.md +181 -180
  58. package/framework/skills/level-1-workflows/phase-design/SKILL.md +339 -338
  59. package/framework/skills/level-1-workflows/phase-implement/SKILL.md +254 -253
  60. package/framework/skills/level-1-workflows/phase-setup/SKILL.md +168 -170
  61. package/framework/skills/level-1-workflows/phase-tasks/SKILL.md +284 -283
  62. package/framework/skills/level-1-workflows/phase-uiux/SKILL.md +246 -245
  63. package/framework/templates/examples/design-system-examples.md +1 -1
  64. package/framework/templates/ui/FluentDesignTheme.cs +1 -1
  65. package/framework/templates/ui/MudTheme.cs +1 -1
  66. package/framework/templates/ui/design-system.css +1 -1
  67. package/package.json +4 -2
  68. package/scripts/bump-version.js +248 -0
  69. package/scripts/install-dev-hooks.js +138 -0
  70. package/src/commands/agents/index.js +1 -2
  71. package/src/commands/index.js +13 -16
  72. package/src/commands/project/doctor.js +100 -14
  73. package/src/commands/project/index.js +7 -10
  74. package/src/commands/project/init.js +398 -555
  75. package/src/commands/project/install-plugin-cmd.js +28 -0
  76. package/src/commands/project/setup-infra-cmd.js +12 -0
  77. package/src/commands/project/tutorial.js +115 -0
  78. package/src/commands/project/update.js +22 -37
  79. package/src/commands/state/approve.js +213 -221
  80. package/src/commands/state/index.js +0 -1
  81. package/src/commands/state/state.js +337 -365
  82. package/src/commands/templates/index.js +0 -4
  83. package/src/commands/trust/trust.js +1 -93
  84. package/src/commands/utils/index.js +1 -5
  85. package/src/commands/validation/index.js +1 -5
  86. package/src/core/registry/command-registry.js +11 -285
  87. package/src/core/state/state-manager.js +5 -2
  88. package/src/lib/detectors/index.js +81 -87
  89. package/src/lib/detectors/structure-detector.js +275 -273
  90. package/src/lib/generators/recap-generator.js +232 -225
  91. package/src/lib/installers/mcp-installer.js +18 -3
  92. package/src/scripts/global-install.js +34 -0
  93. package/src/scripts/install-plugin.js +126 -0
  94. package/src/scripts/setup-infra.js +203 -0
  95. package/src/utils/agents-installer.js +10 -1
  96. package/src/utils/hooks-installer.js +70 -17
  97. package/CLAUDE.md +0 -77
  98. package/docs/claude-alignment-report.md +0 -137
  99. package/docs/examples/order-management/contracts.cs +0 -84
  100. package/docs/examples/order-management/proposal.md +0 -24
  101. package/docs/examples/order-management/spec.md +0 -162
  102. package/src/commands/feature/create-story.js +0 -362
  103. package/src/commands/feature/index.js +0 -6
  104. package/src/commands/feature/shard-spec.js +0 -225
  105. package/src/commands/feature/sprint-status.js +0 -250
  106. package/src/commands/generation/generate-onboarding.js +0 -169
  107. package/src/commands/generation/generate.js +0 -276
  108. package/src/commands/generation/index.js +0 -5
  109. package/src/commands/learning/capture-pattern.js +0 -121
  110. package/src/commands/learning/index.js +0 -5
  111. package/src/commands/learning/search-patterns.js +0 -126
  112. package/src/commands/mcp/mcp.js +0 -102
  113. package/src/commands/project/changes.js +0 -66
  114. package/src/commands/project/cost.js +0 -179
  115. package/src/commands/project/detect.js +0 -114
  116. package/src/commands/project/diff.js +0 -278
  117. package/src/commands/project/revert.js +0 -173
  118. package/src/commands/project/standards.js +0 -80
  119. package/src/commands/project/sync.js +0 -167
  120. package/src/commands/project/update-agents.js +0 -23
  121. package/src/commands/state/rollback-phase.js +0 -185
  122. package/src/commands/templates/template-customize.js +0 -87
  123. package/src/commands/templates/template-list.js +0 -114
  124. package/src/commands/templates/template-show.js +0 -129
  125. package/src/commands/templates/template-validate.js +0 -91
  126. package/src/commands/utils/troubleshoot.js +0 -222
  127. package/src/commands/validation/analyze-blazor-concurrency.js +0 -193
  128. package/src/commands/validation/lint-fluent.js +0 -352
  129. package/src/commands/validation/validate-blazor-state.js +0 -210
  130. package/src/commands/validation/validate-blazor.js +0 -156
  131. package/src/commands/validation/validate-css.js +0 -84
  132. package/src/lib/detectors/conversation-analyzer.js +0 -163
  133. package/src/lib/learning/index.js +0 -7
  134. package/src/lib/learning/learning-system.js +0 -520
  135. package/src/lib/troubleshooting/index.js +0 -8
  136. package/src/lib/troubleshooting/troubleshoot-grep.js +0 -198
  137. package/src/lib/troubleshooting/troubleshoot-index.js +0 -144
  138. package/src/llm/environment-detector.js +0 -43
@@ -1,352 +0,0 @@
1
- /**
2
- * lint-fluent command
3
- *
4
- * Lints Fluent UI patterns for common issues beyond icons.
5
- * Focuses on structural patterns in layouts and components.
6
- *
7
- * Usage:
8
- * morph-spec lint-fluent [path]
9
- * morph-spec lint-fluent src/Components --verbose
10
- */
11
-
12
- import { glob } from 'glob';
13
- import { readFileSync, existsSync, statSync } from 'fs';
14
- import { join, resolve, basename } from 'path';
15
- import chalk from 'chalk';
16
- import ora from 'ora';
17
-
18
- /**
19
- * @typedef {Object} LintIssue
20
- * @property {'error' | 'warning' | 'info'} type
21
- * @property {string} message
22
- * @property {string} [suggestion]
23
- * @property {string} file
24
- * @property {number} [line]
25
- */
26
-
27
- /**
28
- * Checks for FluentToastProvider in layout files.
29
- *
30
- * @param {string} content - File content
31
- * @param {string} filePath - Path to the file
32
- * @returns {LintIssue[]}
33
- */
34
- function checkToastProvider(content, filePath) {
35
- const issues = [];
36
- const fileName = basename(filePath).toLowerCase();
37
- const isLayout =
38
- fileName.includes('layout') ||
39
- fileName === 'app.razor' ||
40
- fileName === 'routes.razor';
41
-
42
- if (!isLayout) return issues;
43
-
44
- // Check if uses toast but doesn't have provider
45
- const usesToast =
46
- content.includes('IToastService') || content.includes('ToastService');
47
-
48
- if (!content.includes('<FluentToastProvider') && !content.includes('<FluentToastContainer')) {
49
- if (isLayout) {
50
- issues.push({
51
- type: 'warning',
52
- message: 'FluentToastProvider nao encontrado no layout',
53
- suggestion:
54
- 'Adicione <FluentToastProvider /> ao MainLayout ou App.razor',
55
- file: filePath,
56
- });
57
- }
58
- }
59
-
60
- return issues;
61
- }
62
-
63
- /**
64
- * Checks for FluentDialogProvider in layout files.
65
- *
66
- * @param {string} content - File content
67
- * @param {string} filePath - Path to the file
68
- * @returns {LintIssue[]}
69
- */
70
- function checkDialogProvider(content, filePath) {
71
- const issues = [];
72
- const fileName = basename(filePath).toLowerCase();
73
- const isLayout =
74
- fileName.includes('layout') ||
75
- fileName === 'app.razor' ||
76
- fileName === 'routes.razor';
77
-
78
- if (!isLayout) return issues;
79
-
80
- if (!content.includes('<FluentDialogProvider')) {
81
- issues.push({
82
- type: 'warning',
83
- message: 'FluentDialogProvider nao encontrado no layout',
84
- suggestion:
85
- 'Adicione <FluentDialogProvider /> ao MainLayout ou App.razor',
86
- file: filePath,
87
- });
88
- }
89
-
90
- return issues;
91
- }
92
-
93
- /**
94
- * Checks for @rendermode on FluentDialogProvider.
95
- *
96
- * @param {string} content - File content
97
- * @param {string} filePath - Path to the file
98
- * @returns {LintIssue[]}
99
- */
100
- function checkDialogProviderRenderMode(content, filePath) {
101
- const issues = [];
102
- const lines = content.split('\n');
103
-
104
- lines.forEach((line, index) => {
105
- if (line.includes('<FluentDialogProvider')) {
106
- // Check if it has @rendermode
107
- if (!line.includes('@rendermode') && !lines[index + 1]?.includes('@rendermode')) {
108
- issues.push({
109
- type: 'info',
110
- message: 'FluentDialogProvider sem @rendermode explicito',
111
- suggestion:
112
- 'Considere adicionar @rendermode="InteractiveServer" se usar dialogs interativos',
113
- file: filePath,
114
- line: index + 1,
115
- });
116
- }
117
- }
118
- });
119
-
120
- return issues;
121
- }
122
-
123
- /**
124
- * Checks for correct _Imports.razor setup.
125
- *
126
- * @param {string} content - File content
127
- * @param {string} filePath - Path to the file
128
- * @returns {LintIssue[]}
129
- */
130
- function checkImportsRazor(content, filePath) {
131
- const issues = [];
132
- const fileName = basename(filePath).toLowerCase();
133
-
134
- if (fileName !== '_imports.razor') return issues;
135
-
136
- // Check for Fluent UI using
137
- if (!content.includes('@using Microsoft.FluentUI.AspNetCore.Components')) {
138
- if (
139
- content.includes('FluentButton') ||
140
- content.includes('FluentCard') ||
141
- content.includes('FluentDialog')
142
- ) {
143
- issues.push({
144
- type: 'warning',
145
- message: 'Fluent UI namespace nao encontrado em _Imports.razor',
146
- suggestion:
147
- 'Adicione @using Microsoft.FluentUI.AspNetCore.Components',
148
- file: filePath,
149
- });
150
- }
151
- }
152
-
153
- // Check for Icons alias
154
- if (
155
- content.includes('Icons.Regular') ||
156
- content.includes('Icons.Filled')
157
- ) {
158
- if (
159
- !content.includes(
160
- '@using Icons = Microsoft.FluentUI.AspNetCore.Components.Icons'
161
- )
162
- ) {
163
- issues.push({
164
- type: 'error',
165
- message: 'Alias de Icons nao encontrado em _Imports.razor',
166
- suggestion:
167
- 'Adicione @using Icons = Microsoft.FluentUI.AspNetCore.Components.Icons',
168
- file: filePath,
169
- });
170
- }
171
- }
172
-
173
- return issues;
174
- }
175
-
176
- /**
177
- * Checks for common FluentDataGrid issues.
178
- *
179
- * @param {string} content - File content
180
- * @param {string} filePath - Path to the file
181
- * @returns {LintIssue[]}
182
- */
183
- function checkDataGridPatterns(content, filePath) {
184
- const issues = [];
185
- const lines = content.split('\n');
186
-
187
- lines.forEach((line, index) => {
188
- // Check for large datasets without virtualization
189
- if (line.includes('<FluentDataGrid') && line.includes('Items=')) {
190
- // Look for Virtualize in the same tag or next few lines
191
- const context = lines.slice(index, index + 5).join('\n');
192
- if (!context.includes('Virtualize=')) {
193
- issues.push({
194
- type: 'info',
195
- message: 'FluentDataGrid sem Virtualize',
196
- suggestion:
197
- 'Para listas grandes (>100 itens), considere Virtualize="true"',
198
- file: filePath,
199
- line: index + 1,
200
- });
201
- }
202
- }
203
- });
204
-
205
- return issues;
206
- }
207
-
208
- /**
209
- * Runs all lint checks on a file.
210
- *
211
- * @param {string} content - File content
212
- * @param {string} filePath - Path to the file
213
- * @returns {LintIssue[]}
214
- */
215
- function lintFile(content, filePath) {
216
- const issues = [];
217
-
218
- issues.push(...checkToastProvider(content, filePath));
219
- issues.push(...checkDialogProvider(content, filePath));
220
- issues.push(...checkDialogProviderRenderMode(content, filePath));
221
- issues.push(...checkImportsRazor(content, filePath));
222
- issues.push(...checkDataGridPatterns(content, filePath));
223
-
224
- return issues;
225
- }
226
-
227
- /**
228
- * Main command handler for lint-fluent.
229
- *
230
- * @param {string} [targetPath] - Path to lint (file or directory)
231
- * @param {Object} options - Command options
232
- * @param {boolean} [options.verbose] - Show detailed output
233
- */
234
- export async function lintFluentCommand(targetPath, options = {}) {
235
- const { verbose = false } = options;
236
-
237
- console.log('');
238
- console.log(chalk.cyan('\uD83E\uDDF9 Linting Fluent UI patterns...'));
239
- console.log('');
240
-
241
- // Determine target path
242
- const basePath = targetPath ? resolve(targetPath) : process.cwd();
243
-
244
- if (!existsSync(basePath)) {
245
- console.log(chalk.red(`\u274C Path not found: ${basePath}`));
246
- process.exit(1);
247
- }
248
-
249
- const spinner = ora('Scanning for Razor files...').start();
250
-
251
- let files = [];
252
-
253
- try {
254
- const stats = statSync(basePath);
255
-
256
- if (stats.isFile()) {
257
- if (basePath.endsWith('.razor')) {
258
- files = [basePath];
259
- } else {
260
- spinner.fail('File must be .razor');
261
- process.exit(1);
262
- }
263
- } else {
264
- const pattern = join(basePath, '**/*.razor');
265
- files = await glob(pattern, {
266
- ignore: ['**/node_modules/**', '**/bin/**', '**/obj/**'],
267
- windowsPathsNoEscape: true,
268
- });
269
- }
270
-
271
- spinner.succeed(`Found ${files.length} Razor file(s)`);
272
- } catch (error) {
273
- spinner.fail(`Error scanning files: ${error.message}`);
274
- process.exit(1);
275
- }
276
-
277
- if (files.length === 0) {
278
- console.log(chalk.yellow('\n\u26A0\uFE0F No Razor files found to lint'));
279
- return;
280
- }
281
-
282
- // Lint each file
283
- const allIssues = [];
284
-
285
- for (const file of files) {
286
- try {
287
- const content = readFileSync(file, 'utf-8');
288
- const issues = lintFile(content, file);
289
-
290
- if (issues.length > 0) {
291
- allIssues.push(...issues);
292
- }
293
- } catch (error) {
294
- console.log(chalk.red(`\u274C Error reading ${file}: ${error.message}`));
295
- }
296
- }
297
-
298
- // Output results
299
- console.log('');
300
-
301
- if (allIssues.length === 0) {
302
- console.log(chalk.green('\u2705 No lint issues found!'));
303
- console.log('');
304
- return;
305
- }
306
-
307
- // Display issues
308
- allIssues.forEach((issue) => {
309
- let icon;
310
- let color;
311
-
312
- switch (issue.type) {
313
- case 'error':
314
- icon = '\u274C';
315
- color = chalk.red;
316
- break;
317
- case 'warning':
318
- icon = '\u26A0\uFE0F';
319
- color = chalk.yellow;
320
- break;
321
- case 'info':
322
- icon = '\u2139\uFE0F';
323
- color = chalk.blue;
324
- break;
325
- }
326
-
327
- const location = issue.line ? `${issue.file}:${issue.line}` : issue.file;
328
-
329
- console.log(`${icon} ${color(issue.message)}`);
330
- if (issue.suggestion) {
331
- console.log(chalk.gray(` \u2192 ${issue.suggestion}`));
332
- }
333
- console.log(chalk.dim(` ${location}`));
334
- console.log('');
335
- });
336
-
337
- // Summary
338
- const errors = allIssues.filter((i) => i.type === 'error').length;
339
- const warnings = allIssues.filter((i) => i.type === 'warning').length;
340
- const infos = allIssues.filter((i) => i.type === 'info').length;
341
-
342
- console.log(chalk.gray('-'.repeat(60)));
343
- console.log(
344
- `\n${files.length} arquivo(s) | ${errors} erro(s) | ${warnings} warning(s) | ${infos} info(s)\n`
345
- );
346
-
347
- if (errors > 0) {
348
- process.exit(1);
349
- }
350
- }
351
-
352
- export default lintFluentCommand;
@@ -1,210 +0,0 @@
1
- /**
2
- * validate-blazor-state command
3
- *
4
- * Validates Blazor Server session state patterns.
5
- * Ensures proper Persist + Reload pattern implementation.
6
- *
7
- * Usage:
8
- * morph-spec validate-blazor-state [path]
9
- * morph-spec validate-blazor-state src/ --verbose
10
- */
11
-
12
- import { glob } from 'glob';
13
- import { readFileSync, existsSync, statSync } from 'fs';
14
- import { join, resolve } from 'path';
15
- import chalk from 'chalk';
16
- import ora from 'ora';
17
-
18
- import {
19
- validateBlazorState,
20
- } from '../../lib/validators/blazor/blazor-state-validator.js';
21
- import { countIssues } from '../../lib/validators/shared/index.js';
22
-
23
- /**
24
- * Main command handler for validate-blazor-state.
25
- *
26
- * @param {string} [targetPath] - Path to validate (file or directory)
27
- * @param {Object} options - Command options
28
- * @param {boolean} [options.verbose] - Show detailed output
29
- */
30
- export async function validateBlazorStateCommand(targetPath, options = {}) {
31
- const { verbose = false } = options;
32
-
33
- console.log('');
34
- console.log(
35
- chalk.cyan('\uD83D\uDD0D Validando padroes de SessionState em Blazor Server...')
36
- );
37
- console.log('');
38
-
39
- // Determine target path
40
- const basePath = targetPath ? resolve(targetPath) : process.cwd();
41
-
42
- if (!existsSync(basePath)) {
43
- console.log(chalk.red(`\u274C Path not found: ${basePath}`));
44
- process.exit(1);
45
- }
46
-
47
- const spinner = ora('Scanning for C# and Razor files...').start();
48
-
49
- let files = [];
50
-
51
- try {
52
- const stats = statSync(basePath);
53
-
54
- if (stats.isFile()) {
55
- if (basePath.endsWith('.cs') || basePath.endsWith('.razor')) {
56
- files = [basePath];
57
- } else {
58
- spinner.fail('File must be .cs or .razor');
59
- process.exit(1);
60
- }
61
- } else {
62
- // Find all relevant files
63
- const pattern = join(basePath, '**/*.{cs,razor}');
64
- files = await glob(pattern, {
65
- ignore: [
66
- '**/node_modules/**',
67
- '**/bin/**',
68
- '**/obj/**',
69
- '**/Migrations/**',
70
- ],
71
- windowsPathsNoEscape: true,
72
- });
73
- }
74
-
75
- spinner.succeed(`Found ${files.length} file(s)`);
76
- } catch (error) {
77
- spinner.fail(`Error scanning files: ${error.message}`);
78
- process.exit(1);
79
- }
80
-
81
- if (files.length === 0) {
82
- console.log(chalk.yellow('\n\u26A0\uFE0F No files found to validate'));
83
- return;
84
- }
85
-
86
- // Validate each file
87
- const allIssues = [];
88
- const fileResults = [];
89
-
90
- for (const file of files) {
91
- try {
92
- const content = readFileSync(file, 'utf-8');
93
- const issues = validateBlazorState(content, file);
94
-
95
- if (issues.length > 0) {
96
- allIssues.push(...issues);
97
- fileResults.push({ file, issues });
98
- }
99
- } catch (error) {
100
- if (verbose) {
101
- console.log(chalk.red(`\u274C Error reading ${file}: ${error.message}`));
102
- }
103
- }
104
- }
105
-
106
- // Output results
107
- console.log('');
108
-
109
- if (allIssues.length === 0) {
110
- console.log(
111
- chalk.green('\u2705 Padroes de SessionState validados com sucesso!')
112
- );
113
- console.log(
114
- chalk.gray(
115
- ' Dica: Certifique-se de sempre verificar IsLoaded em OnInitializedAsync.'
116
- )
117
- );
118
- console.log('');
119
- return;
120
- }
121
-
122
- // Display issues
123
- if (verbose) {
124
- fileResults.forEach(({ file, issues }) => {
125
- console.log(chalk.white.bold(`\n${file}`));
126
- console.log(chalk.gray('-'.repeat(60)));
127
-
128
- issues.forEach((issue) => {
129
- const icon =
130
- issue.type === 'error'
131
- ? '\u274C'
132
- : issue.type === 'warning'
133
- ? '\u26A0\uFE0F'
134
- : '\u2139\uFE0F';
135
-
136
- const color =
137
- issue.type === 'error'
138
- ? chalk.red
139
- : issue.type === 'warning'
140
- ? chalk.yellow
141
- : chalk.blue;
142
-
143
- console.log(`${icon} ${color(issue.message)}`);
144
- if (issue.suggestion) {
145
- console.log(chalk.gray(` \u2192 ${issue.suggestion}`));
146
- }
147
- if (issue.line) {
148
- console.log(chalk.dim(` Linha: ${issue.line}`));
149
- }
150
- console.log('');
151
- });
152
- });
153
- } else {
154
- allIssues.forEach((issue) => {
155
- const icon =
156
- issue.type === 'error'
157
- ? '\u274C'
158
- : issue.type === 'warning'
159
- ? '\u26A0\uFE0F'
160
- : '\u2139\uFE0F';
161
-
162
- const color =
163
- issue.type === 'error'
164
- ? chalk.red
165
- : issue.type === 'warning'
166
- ? chalk.yellow
167
- : chalk.blue;
168
-
169
- console.log(`${icon} ${color(issue.message)}`);
170
- if (issue.suggestion) {
171
- console.log(chalk.gray(` \u2192 ${issue.suggestion}`));
172
- }
173
- console.log(chalk.dim(` ${issue.file}`));
174
- console.log('');
175
- });
176
- }
177
-
178
- // Summary
179
- const { errors, warnings, infos } = countIssues(allIssues);
180
- const summaryColor = errors > 0 ? chalk.red : chalk.yellow;
181
-
182
- console.log(chalk.gray('-'.repeat(60)));
183
- console.log(
184
- summaryColor(
185
- `\n${files.length} arquivo(s) validado(s) | ${errors} erro(s) | ${warnings} warning(s) | ${infos} info(s)\n`
186
- )
187
- );
188
-
189
- // Checklist reminder
190
- console.log(chalk.cyan('\uD83D\uDCCB Checklist SessionState:'));
191
- console.log(chalk.gray(' [ ] SessionState tem LoadFrom(entity)?'));
192
- console.log(chalk.gray(' [ ] SessionState tem propriedade IsLoaded?'));
193
- console.log(chalk.gray(' [ ] Paginas verificam IsLoaded em OnInitializedAsync?'));
194
- console.log(chalk.gray(' [ ] SessionMiddleware configurado em Program.cs?'));
195
- console.log(chalk.gray(' [ ] IHttpContextAccessor registrado?'));
196
- console.log('');
197
-
198
- // Recommendation
199
- if (errors > 0) {
200
- console.log(
201
- chalk.cyan(
202
- '\uD83D\uDCD6 Consulte: framework/standards/frontend/blazor/state.md para o padrao completo'
203
- )
204
- );
205
- console.log('');
206
- process.exit(1);
207
- }
208
- }
209
-
210
- export default validateBlazorStateCommand;
@@ -1,156 +0,0 @@
1
- /**
2
- * validate-blazor command
3
- *
4
- * Validates Fluent UI Blazor patterns and icons in Razor files.
5
- *
6
- * Usage:
7
- * morph-spec validate-blazor [path]
8
- * morph-spec validate-blazor src/Components --verbose
9
- */
10
-
11
- import { glob } from 'glob';
12
- import { readFileSync, existsSync, statSync } from 'fs';
13
- import { join, resolve } from 'path';
14
- import chalk from 'chalk';
15
- import ora from 'ora';
16
-
17
- import {
18
- validateBlazorFile,
19
- formatIssues,
20
- } from '../../lib/validators/blazor/blazor-validator.js';
21
- import { countIssues } from '../../lib/validators/shared/index.js';
22
-
23
- /**
24
- * Main command handler for validate-blazor.
25
- *
26
- * @param {string} [targetPath] - Path to validate (file or directory)
27
- * @param {Object} options - Command options
28
- * @param {boolean} [options.verbose] - Show detailed output
29
- * @param {boolean} [options.fix] - Auto-fix issues where possible
30
- */
31
- export async function validateBlazorCommand(targetPath, options = {}) {
32
- const { verbose = false } = options;
33
-
34
- console.log('');
35
- console.log(
36
- chalk.cyan('\uD83D\uDD0D Validating Fluent UI Blazor patterns...')
37
- );
38
- console.log('');
39
-
40
- // Determine target path
41
- const basePath = targetPath ? resolve(targetPath) : process.cwd();
42
-
43
- if (!existsSync(basePath)) {
44
- console.log(chalk.red(`\u274C Path not found: ${basePath}`));
45
- process.exit(1);
46
- }
47
-
48
- const spinner = ora('Scanning for Razor files...').start();
49
-
50
- let files = [];
51
-
52
- try {
53
- const stats = statSync(basePath);
54
-
55
- if (stats.isFile()) {
56
- // Single file
57
- if (
58
- basePath.endsWith('.razor') ||
59
- basePath.endsWith('.razor.cs') ||
60
- basePath.endsWith('.cs')
61
- ) {
62
- files = [basePath];
63
- } else {
64
- spinner.fail('File must be .razor or .cs');
65
- process.exit(1);
66
- }
67
- } else {
68
- // Directory - find all Razor files
69
- const pattern = join(basePath, '**/*.{razor,razor.cs}');
70
- files = await glob(pattern, {
71
- ignore: ['**/node_modules/**', '**/bin/**', '**/obj/**'],
72
- windowsPathsNoEscape: true,
73
- });
74
- }
75
-
76
- spinner.succeed(`Found ${files.length} Razor file(s)`);
77
- } catch (error) {
78
- spinner.fail(`Error scanning files: ${error.message}`);
79
- process.exit(1);
80
- }
81
-
82
- if (files.length === 0) {
83
- console.log(chalk.yellow('\n\u26A0\uFE0F No Razor files found to validate'));
84
- return;
85
- }
86
-
87
- // Validate each file
88
- const allIssues = [];
89
- const fileResults = [];
90
-
91
- for (const file of files) {
92
- try {
93
- const content = readFileSync(file, 'utf-8');
94
- const issues = validateBlazorFile(content, file);
95
-
96
- if (issues.length > 0) {
97
- allIssues.push(...issues);
98
- fileResults.push({ file, issues });
99
- }
100
- } catch (error) {
101
- console.log(chalk.red(`\u274C Error reading ${file}: ${error.message}`));
102
- }
103
- }
104
-
105
- // Output results
106
- console.log('');
107
-
108
- if (allIssues.length === 0) {
109
- console.log(
110
- chalk.green('\u2705 No issues found! All patterns look correct.')
111
- );
112
- console.log('');
113
- return;
114
- }
115
-
116
- // Group and display issues
117
- if (verbose) {
118
- // Verbose: show all issues with details
119
- fileResults.forEach(({ file, issues }) => {
120
- console.log(chalk.white.bold(`\n${file}`));
121
- console.log(chalk.gray('-'.repeat(60)));
122
- console.log(formatIssues(issues));
123
- });
124
- } else {
125
- // Compact: just list issues
126
- allIssues.forEach((issue) => {
127
- const icon = issue.type === 'error' ? '\u274C' : '\u26A0\uFE0F';
128
- const location = issue.line ? `${issue.file}:${issue.line}` : issue.file;
129
-
130
- console.log(`${icon} ${issue.message}`);
131
- if (issue.suggestion) {
132
- console.log(chalk.gray(` \u2192 ${issue.suggestion}`));
133
- }
134
- console.log(chalk.dim(` ${location}`));
135
- console.log('');
136
- });
137
- }
138
-
139
- // Summary
140
- const { errors, warnings } = countIssues(allIssues);
141
- const summaryColor = errors > 0 ? chalk.red : chalk.yellow;
142
-
143
- console.log(chalk.gray('-'.repeat(60)));
144
- console.log(
145
- summaryColor(
146
- `\n${files.length} arquivo(s) validado(s) | ${errors} erro(s) | ${warnings} warning(s)\n`
147
- )
148
- );
149
-
150
- // Exit with error code if there are errors
151
- if (errors > 0) {
152
- process.exit(1);
153
- }
154
- }
155
-
156
- export default validateBlazorCommand;