@mandujs/mcp 0.13.0 → 0.16.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 (136) hide show
  1. package/README.md +6 -7
  2. package/package.json +3 -2
  3. package/src/adapters/index.ts +20 -20
  4. package/src/adapters/monitor-adapter.ts +100 -100
  5. package/src/adapters/tool-adapter.ts +88 -88
  6. package/src/executor/error-handler.ts +250 -250
  7. package/src/executor/index.ts +22 -22
  8. package/src/executor/tool-executor.ts +148 -148
  9. package/src/hooks/config-watcher.ts +174 -174
  10. package/src/hooks/index.ts +23 -23
  11. package/src/hooks/mcp-hooks.ts +227 -227
  12. package/src/logging/index.ts +15 -15
  13. package/src/logging/mcp-transport.ts +134 -134
  14. package/src/registry/index.ts +13 -13
  15. package/src/registry/mcp-tool-registry.ts +298 -298
  16. package/src/resources/skills/guides.ts +1136 -1136
  17. package/src/resources/skills/index.ts +12 -12
  18. package/src/resources/skills/loader.ts +218 -218
  19. package/src/resources/skills/mandu-composition/SKILL.md +91 -91
  20. package/src/resources/skills/mandu-composition/metadata.json +13 -13
  21. package/src/resources/skills/mandu-composition/rules/_sections.md +26 -26
  22. package/src/resources/skills/mandu-composition/rules/_template.md +77 -77
  23. package/src/resources/skills/mandu-composition/rules/comp-arch-avoid-boolean-props.md +146 -146
  24. package/src/resources/skills/mandu-composition/rules/comp-arch-compound-components.md +164 -164
  25. package/src/resources/skills/mandu-composition/rules/comp-island-event.md +161 -161
  26. package/src/resources/skills/mandu-composition/rules/comp-island-slot-split.md +167 -167
  27. package/src/resources/skills/mandu-composition/rules/comp-pattern-children.md +149 -149
  28. package/src/resources/skills/mandu-composition/rules/comp-state-context-interface.md +148 -148
  29. package/src/resources/skills/mandu-composition/rules/comp-state-lift-state.md +150 -150
  30. package/src/resources/skills/mandu-deployment/SKILL.md +92 -92
  31. package/src/resources/skills/mandu-deployment/_sections.md +41 -41
  32. package/src/resources/skills/mandu-deployment/_template.md +38 -38
  33. package/src/resources/skills/mandu-deployment/metadata.json +13 -13
  34. package/src/resources/skills/mandu-deployment/rules/deploy-build-bun.md +109 -109
  35. package/src/resources/skills/mandu-deployment/rules/deploy-build-output.md +115 -115
  36. package/src/resources/skills/mandu-deployment/rules/deploy-cicd-github.md +219 -219
  37. package/src/resources/skills/mandu-deployment/rules/deploy-docker-bun.md +150 -150
  38. package/src/resources/skills/mandu-deployment/rules/deploy-docker-compose.md +223 -223
  39. package/src/resources/skills/mandu-deployment/rules/deploy-platform-fly.md +152 -152
  40. package/src/resources/skills/mandu-deployment/rules/deploy-platform-render.md +179 -179
  41. package/src/resources/skills/mandu-deployment/rules/deploy-platform-supabase.md +323 -323
  42. package/src/resources/skills/mandu-deployment/rules/deploy-platform-vercel.md +140 -140
  43. package/src/resources/skills/mandu-fs-routes/SKILL.md +82 -82
  44. package/src/resources/skills/mandu-fs-routes/metadata.json +12 -12
  45. package/src/resources/skills/mandu-fs-routes/rules/_sections.md +36 -36
  46. package/src/resources/skills/mandu-fs-routes/rules/_template.md +69 -69
  47. package/src/resources/skills/mandu-fs-routes/rules/routes-api-methods.md +65 -65
  48. package/src/resources/skills/mandu-fs-routes/rules/routes-dynamic-param.md +93 -93
  49. package/src/resources/skills/mandu-fs-routes/rules/routes-naming-page.md +55 -55
  50. package/src/resources/skills/mandu-guard/SKILL.md +129 -129
  51. package/src/resources/skills/mandu-guard/metadata.json +12 -12
  52. package/src/resources/skills/mandu-guard/rules/_sections.md +36 -36
  53. package/src/resources/skills/mandu-guard/rules/_template.md +82 -82
  54. package/src/resources/skills/mandu-guard/rules/guard-config-rules.md +100 -100
  55. package/src/resources/skills/mandu-guard/rules/guard-layer-direction.md +76 -76
  56. package/src/resources/skills/mandu-guard/rules/guard-preset-mandu.md +81 -81
  57. package/src/resources/skills/mandu-guard/rules/guard-validate-import.md +80 -80
  58. package/src/resources/skills/mandu-hydration/SKILL.md +91 -91
  59. package/src/resources/skills/mandu-hydration/metadata.json +12 -12
  60. package/src/resources/skills/mandu-hydration/rules/_sections.md +31 -31
  61. package/src/resources/skills/mandu-hydration/rules/_template.md +72 -72
  62. package/src/resources/skills/mandu-hydration/rules/hydration-data-event.md +109 -109
  63. package/src/resources/skills/mandu-hydration/rules/hydration-directive-use-client.md +55 -55
  64. package/src/resources/skills/mandu-hydration/rules/hydration-island-setup.md +113 -113
  65. package/src/resources/skills/mandu-hydration/rules/hydration-priority-visible.md +68 -68
  66. package/src/resources/skills/mandu-performance/SKILL.md +85 -85
  67. package/src/resources/skills/mandu-performance/metadata.json +14 -14
  68. package/src/resources/skills/mandu-performance/rules/_sections.md +31 -31
  69. package/src/resources/skills/mandu-performance/rules/_template.md +64 -64
  70. package/src/resources/skills/mandu-performance/rules/perf-async-defer-await.md +103 -103
  71. package/src/resources/skills/mandu-performance/rules/perf-async-parallel.md +95 -95
  72. package/src/resources/skills/mandu-performance/rules/perf-bun-file.md +124 -124
  73. package/src/resources/skills/mandu-performance/rules/perf-bun-serve.md +125 -125
  74. package/src/resources/skills/mandu-performance/rules/perf-bundle-imports.md +80 -80
  75. package/src/resources/skills/mandu-performance/rules/perf-bundle-island-lazy.md +145 -145
  76. package/src/resources/skills/mandu-performance/rules/perf-cache-react.md +98 -98
  77. package/src/resources/skills/mandu-performance/rules/perf-render-transitions.md +154 -154
  78. package/src/resources/skills/mandu-security/SKILL.md +87 -87
  79. package/src/resources/skills/mandu-security/metadata.json +13 -13
  80. package/src/resources/skills/mandu-security/rules/_sections.md +31 -31
  81. package/src/resources/skills/mandu-security/rules/_template.md +74 -74
  82. package/src/resources/skills/mandu-security/rules/sec-auth-guard.md +127 -127
  83. package/src/resources/skills/mandu-security/rules/sec-env-management.md +133 -133
  84. package/src/resources/skills/mandu-security/rules/sec-input-validate.md +148 -148
  85. package/src/resources/skills/mandu-security/rules/sec-protect-csrf.md +146 -146
  86. package/src/resources/skills/mandu-security/rules/sec-protect-headers.md +138 -138
  87. package/src/resources/skills/mandu-slot/SKILL.md +85 -85
  88. package/src/resources/skills/mandu-slot/metadata.json +12 -12
  89. package/src/resources/skills/mandu-slot/rules/_sections.md +36 -36
  90. package/src/resources/skills/mandu-slot/rules/_template.md +63 -63
  91. package/src/resources/skills/mandu-slot/rules/slot-basic-structure.md +38 -38
  92. package/src/resources/skills/mandu-slot/rules/slot-ctx-response.md +56 -56
  93. package/src/resources/skills/mandu-slot/rules/slot-guard-auth.md +59 -59
  94. package/src/resources/skills/mandu-slot/rules/slot-http-methods.md +64 -64
  95. package/src/resources/skills/mandu-styling/SKILL.md +154 -154
  96. package/src/resources/skills/mandu-styling/_sections.md +43 -43
  97. package/src/resources/skills/mandu-styling/_template.md +32 -32
  98. package/src/resources/skills/mandu-styling/metadata.json +15 -15
  99. package/src/resources/skills/mandu-styling/rules/style-component-compound.md +235 -235
  100. package/src/resources/skills/mandu-styling/rules/style-component-slots.md +255 -255
  101. package/src/resources/skills/mandu-styling/rules/style-component-tokens.md +205 -205
  102. package/src/resources/skills/mandu-styling/rules/style-island-animations.md +272 -272
  103. package/src/resources/skills/mandu-styling/rules/style-island-scoping.md +167 -167
  104. package/src/resources/skills/mandu-styling/rules/style-island-variants.md +221 -221
  105. package/src/resources/skills/mandu-styling/rules/style-perf-critical.md +209 -209
  106. package/src/resources/skills/mandu-styling/rules/style-perf-purge.md +192 -192
  107. package/src/resources/skills/mandu-styling/rules/style-setup-modules.md +162 -162
  108. package/src/resources/skills/mandu-styling/rules/style-setup-panda.md +164 -164
  109. package/src/resources/skills/mandu-styling/rules/style-setup-tailwind.md +170 -170
  110. package/src/resources/skills/mandu-styling/rules/style-tailwind-v4-gotchas.md +179 -179
  111. package/src/resources/skills/mandu-styling/rules/style-theme-darkmode.md +229 -229
  112. package/src/resources/skills/mandu-testing/SKILL.md +99 -99
  113. package/src/resources/skills/mandu-testing/metadata.json +13 -13
  114. package/src/resources/skills/mandu-testing/rules/_sections.md +26 -26
  115. package/src/resources/skills/mandu-testing/rules/_template.md +65 -65
  116. package/src/resources/skills/mandu-testing/rules/test-component-island.md +195 -195
  117. package/src/resources/skills/mandu-testing/rules/test-e2e-playwright.md +196 -196
  118. package/src/resources/skills/mandu-testing/rules/test-mock-fetch.md +219 -219
  119. package/src/resources/skills/mandu-testing/rules/test-slot-unit.md +192 -192
  120. package/src/resources/skills/mandu-ui/SKILL.md +117 -117
  121. package/src/resources/skills/mandu-ui/_sections.md +23 -23
  122. package/src/resources/skills/mandu-ui/_template.md +32 -32
  123. package/src/resources/skills/mandu-ui/metadata.json +13 -13
  124. package/src/resources/skills/mandu-ui/rules/ui-accessibility-aria.md +232 -232
  125. package/src/resources/skills/mandu-ui/rules/ui-accessibility-focus.md +238 -238
  126. package/src/resources/skills/mandu-ui/rules/ui-composition-patterns.md +259 -259
  127. package/src/resources/skills/mandu-ui/rules/ui-island-integration.md +258 -258
  128. package/src/resources/skills/mandu-ui/rules/ui-radix-patterns.md +213 -213
  129. package/src/resources/skills/mandu-ui/rules/ui-shadcn-setup.md +209 -209
  130. package/src/resources/skills/recipes.ts +932 -932
  131. package/src/tools/ate.ts +129 -0
  132. package/src/tools/index.ts +4 -1
  133. package/src/tools/project.ts +334 -334
  134. package/src/tools/runtime.ts +497 -497
  135. package/src/tools/seo.ts +417 -417
  136. package/src/utils/withWarnings.ts +83 -83
@@ -1,12 +1,12 @@
1
- {
2
- "version": "1.0.0",
3
- "organization": "Mandu Framework",
4
- "date": "February 2026",
5
- "abstract": "아키텍처 가드 시스템 가이드. 레이어 간 의존성 규칙을 강제하고 위반을 실시간으로 감지합니다. FSD, Clean Architecture, Hexagonal 등 다양한 프리셋을 지원하며, CI/CD 파이프라인에 통합할 수 있습니다.",
6
- "references": [
7
- "https://feature-sliced.design/",
8
- "https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html",
9
- "https://alistair.cockburn.us/hexagonal-architecture/"
10
- ],
11
- "tags": ["guard", "architecture", "layers", "dependencies", "mandu"]
12
- }
1
+ {
2
+ "version": "1.0.0",
3
+ "organization": "Mandu Framework",
4
+ "date": "February 2026",
5
+ "abstract": "아키텍처 가드 시스템 가이드. 레이어 간 의존성 규칙을 강제하고 위반을 실시간으로 감지합니다. FSD, Clean Architecture, Hexagonal 등 다양한 프리셋을 지원하며, CI/CD 파이프라인에 통합할 수 있습니다.",
6
+ "references": [
7
+ "https://feature-sliced.design/",
8
+ "https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html",
9
+ "https://alistair.cockburn.us/hexagonal-architecture/"
10
+ ],
11
+ "tags": ["guard", "architecture", "layers", "dependencies", "mandu"]
12
+ }
@@ -1,36 +1,36 @@
1
- # Sections
2
-
3
- This file defines all sections, their ordering, impact levels, and descriptions.
4
- The section ID (in parentheses) is the filename prefix used to group rules.
5
-
6
- ---
7
-
8
- ## 1. Layer Rules (guard-layer)
9
-
10
- **Impact:** CRITICAL
11
- **Description:** 레이어 의존성 방향 규칙. 상위→하위만 허용, 역방향 import 금지. 아키텍처 무결성의 핵심입니다.
12
-
13
- ## 2. Presets (guard-preset)
14
-
15
- **Impact:** HIGH
16
- **Description:** mandu, fsd, clean, hexagonal 프리셋 선택. 프로젝트 유형에 맞는 아키텍처 템플릿입니다.
17
-
18
- ## 3. Validation (guard-validate)
19
-
20
- **Impact:** HIGH
21
- **Description:** import 경로, 파일 위치, 네이밍 검증. 실시간 위반 감지와 리포팅입니다.
22
-
23
- ## 4. Configuration (guard-config)
24
-
25
- **Impact:** MEDIUM
26
- **Description:** 규칙 severity 설정, ignore 패턴. 프로젝트 특성에 맞게 가드를 커스터마이징합니다.
27
-
28
- ## 5. CI Integration (guard-ci)
29
-
30
- **Impact:** MEDIUM
31
- **Description:** --ci 플래그, exit code, 리포트 생성. 자동화된 아키텍처 검증 파이프라인입니다.
32
-
33
- ## 6. Auto Fix (guard-fix)
34
-
35
- **Impact:** LOW
36
- **Description:** --auto-correct 옵션. 일부 위반의 자동 수정 기능입니다.
1
+ # Sections
2
+
3
+ This file defines all sections, their ordering, impact levels, and descriptions.
4
+ The section ID (in parentheses) is the filename prefix used to group rules.
5
+
6
+ ---
7
+
8
+ ## 1. Layer Rules (guard-layer)
9
+
10
+ **Impact:** CRITICAL
11
+ **Description:** 레이어 의존성 방향 규칙. 상위→하위만 허용, 역방향 import 금지. 아키텍처 무결성의 핵심입니다.
12
+
13
+ ## 2. Presets (guard-preset)
14
+
15
+ **Impact:** HIGH
16
+ **Description:** mandu, fsd, clean, hexagonal 프리셋 선택. 프로젝트 유형에 맞는 아키텍처 템플릿입니다.
17
+
18
+ ## 3. Validation (guard-validate)
19
+
20
+ **Impact:** HIGH
21
+ **Description:** import 경로, 파일 위치, 네이밍 검증. 실시간 위반 감지와 리포팅입니다.
22
+
23
+ ## 4. Configuration (guard-config)
24
+
25
+ **Impact:** MEDIUM
26
+ **Description:** 규칙 severity 설정, ignore 패턴. 프로젝트 특성에 맞게 가드를 커스터마이징합니다.
27
+
28
+ ## 5. CI Integration (guard-ci)
29
+
30
+ **Impact:** MEDIUM
31
+ **Description:** --ci 플래그, exit code, 리포트 생성. 자동화된 아키텍처 검증 파이프라인입니다.
32
+
33
+ ## 6. Auto Fix (guard-fix)
34
+
35
+ **Impact:** LOW
36
+ **Description:** --auto-correct 옵션. 일부 위반의 자동 수정 기능입니다.
@@ -1,82 +1,82 @@
1
- # Rule Template
2
-
3
- Use this template when creating new rules for mandu-guard.
4
-
5
- ---
6
-
7
- ```markdown
8
- ---
9
- title: Rule Title Here
10
- impact: CRITICAL | HIGH | MEDIUM | LOW
11
- impactDescription: 영향 설명
12
- tags: guard, tag1, tag2
13
- ---
14
-
15
- ## Rule Title Here
16
-
17
- **Impact: {LEVEL} ({impactDescription})**
18
-
19
- 규칙의 목적과 중요성을 설명합니다.
20
-
21
- **Incorrect (위반 예시):**
22
-
23
- \`\`\`typescript
24
- // ❌ entities → features (역방향 의존)
25
- // src/entities/user/index.ts
26
- import { useAuth } from "@/features/auth"; // VIOLATION!
27
-
28
- export function User() {
29
- const { isLoggedIn } = useAuth();
30
- }
31
- \`\`\`
32
-
33
- **Correct (올바른 방향):**
34
-
35
- \`\`\`typescript
36
- // ✅ features → entities (순방향 의존)
37
- // src/features/auth/index.ts
38
- import { User } from "@/entities/user";
39
-
40
- export function useAuth() {
41
- const user = getCurrentUser();
42
- return { user, isLoggedIn: !!user };
43
- }
44
- \`\`\`
45
-
46
- ## CLI Command
47
-
48
- \`\`\`bash
49
- bunx mandu guard arch --ci
50
- \`\`\`
51
-
52
- Reference: [관련 문서 링크](https://example.com)
53
- ```
54
-
55
- ---
56
-
57
- ## Naming Convention
58
-
59
- - 파일명: `{section}-{rule-name}.md`
60
- - 예시: `guard-layer-direction.md`, `guard-preset-mandu.md`
61
-
62
- ## Layer Hierarchy Quick Reference
63
-
64
- ### Frontend (FSD)
65
- ```
66
- app → pages → widgets → features → entities → shared
67
- ```
68
-
69
- ### Backend (Clean)
70
- ```
71
- api → application → domain → infra → core → shared
72
- ```
73
-
74
- ## Rule IDs Quick Reference
75
-
76
- | Rule ID | Description |
77
- |---------|-------------|
78
- | `LAYER_VIOLATION` | 레이어 의존성 위반 |
79
- | `GENERATED_DIRECT_EDIT` | generated 파일 직접 수정 |
80
- | `WRONG_SLOT_LOCATION` | 잘못된 slot 파일 위치 |
81
- | `SLOT_NAMING` | slot 파일 이름 규칙 위반 |
82
- | `FORBIDDEN_IMPORT` | 금지된 import |
1
+ # Rule Template
2
+
3
+ Use this template when creating new rules for mandu-guard.
4
+
5
+ ---
6
+
7
+ ```markdown
8
+ ---
9
+ title: Rule Title Here
10
+ impact: CRITICAL | HIGH | MEDIUM | LOW
11
+ impactDescription: 영향 설명
12
+ tags: guard, tag1, tag2
13
+ ---
14
+
15
+ ## Rule Title Here
16
+
17
+ **Impact: {LEVEL} ({impactDescription})**
18
+
19
+ 규칙의 목적과 중요성을 설명합니다.
20
+
21
+ **Incorrect (위반 예시):**
22
+
23
+ \`\`\`typescript
24
+ // ❌ entities → features (역방향 의존)
25
+ // src/entities/user/index.ts
26
+ import { useAuth } from "@/features/auth"; // VIOLATION!
27
+
28
+ export function User() {
29
+ const { isLoggedIn } = useAuth();
30
+ }
31
+ \`\`\`
32
+
33
+ **Correct (올바른 방향):**
34
+
35
+ \`\`\`typescript
36
+ // ✅ features → entities (순방향 의존)
37
+ // src/features/auth/index.ts
38
+ import { User } from "@/entities/user";
39
+
40
+ export function useAuth() {
41
+ const user = getCurrentUser();
42
+ return { user, isLoggedIn: !!user };
43
+ }
44
+ \`\`\`
45
+
46
+ ## CLI Command
47
+
48
+ \`\`\`bash
49
+ bunx mandu guard arch --ci
50
+ \`\`\`
51
+
52
+ Reference: [관련 문서 링크](https://example.com)
53
+ ```
54
+
55
+ ---
56
+
57
+ ## Naming Convention
58
+
59
+ - 파일명: `{section}-{rule-name}.md`
60
+ - 예시: `guard-layer-direction.md`, `guard-preset-mandu.md`
61
+
62
+ ## Layer Hierarchy Quick Reference
63
+
64
+ ### Frontend (FSD)
65
+ ```
66
+ app → pages → widgets → features → entities → shared
67
+ ```
68
+
69
+ ### Backend (Clean)
70
+ ```
71
+ api → application → domain → infra → core → shared
72
+ ```
73
+
74
+ ## Rule IDs Quick Reference
75
+
76
+ | Rule ID | Description |
77
+ |---------|-------------|
78
+ | `LAYER_VIOLATION` | 레이어 의존성 위반 |
79
+ | `GENERATED_DIRECT_EDIT` | generated 파일 직접 수정 |
80
+ | `WRONG_SLOT_LOCATION` | 잘못된 slot 파일 위치 |
81
+ | `SLOT_NAMING` | slot 파일 이름 규칙 위반 |
82
+ | `FORBIDDEN_IMPORT` | 금지된 import |
@@ -1,100 +1,100 @@
1
- ---
2
- title: Configure Rule Severity Levels
3
- impact: MEDIUM
4
- impactDescription: Customize guard behavior
5
- tags: guard, config, rules
6
- ---
7
-
8
- ## Configure Rule Severity Levels
9
-
10
- Set severity levels for each guard rule based on your project needs.
11
-
12
- ## Severity Levels
13
-
14
- | Level | Behavior | Use Case |
15
- |-------|----------|----------|
16
- | `error` | Fails check, blocks CI | Critical violations |
17
- | `warn` | Reports issue, continues | Gradual migration |
18
- | `off` | Ignores rule | Not applicable to project |
19
-
20
- ## Configuration File
21
-
22
- ```typescript
23
- // mandu.config.ts
24
-
25
- export default {
26
- guard: {
27
- preset: "mandu",
28
- rules: {
29
- // Core rules
30
- "LAYER_VIOLATION": "error", // Always enforce layers
31
- "GENERATED_DIRECT_EDIT": "error", // Protect generated files
32
-
33
- // Naming rules
34
- "SLOT_NAMING": "warn", // Warn during migration
35
- "WRONG_SLOT_LOCATION": "error",
36
-
37
- // Security rules
38
- "FORBIDDEN_IMPORT": "error", // Block dangerous imports
39
- },
40
- },
41
- };
42
- ```
43
-
44
- ## Available Rules
45
-
46
- | Rule ID | Default | Description |
47
- |---------|---------|-------------|
48
- | `LAYER_VIOLATION` | error | Layer dependency violation |
49
- | `GENERATED_DIRECT_EDIT` | error | Direct edit of generated files |
50
- | `WRONG_SLOT_LOCATION` | error | Slot file in wrong directory |
51
- | `SLOT_NAMING` | error | Incorrect slot file naming |
52
- | `FORBIDDEN_IMPORT` | warn | Importing fs, child_process, etc. in browser code |
53
- | `CIRCULAR_DEPENDENCY` | warn | Circular import detected |
54
- | `DEEP_IMPORT` | warn | Importing from nested paths instead of index |
55
-
56
- ## Ignoring Paths
57
-
58
- ```typescript
59
- export default {
60
- guard: {
61
- ignore: [
62
- "**/test/**", // Test files
63
- "**/*.test.ts", // Test files
64
- "**/*.spec.ts", // Spec files
65
- "**/mocks/**", // Mock files
66
- "scripts/**", // Build scripts
67
- ],
68
- },
69
- };
70
- ```
71
-
72
- ## Per-File Override
73
-
74
- ```typescript
75
- // src/features/legacy/index.ts
76
-
77
- // @guard-disable LAYER_VIOLATION
78
- import { oldHelper } from "@/entities/legacy"; // Allowed temporarily
79
- // @guard-enable LAYER_VIOLATION
80
- ```
81
-
82
- ## Gradual Migration
83
-
84
- ```typescript
85
- // Start with warnings for legacy code
86
- {
87
- rules: {
88
- "LAYER_VIOLATION": "warn", // Start with warn
89
- "SLOT_NAMING": "off", // Fix later
90
- }
91
- }
92
-
93
- // After migration, enforce strictly
94
- {
95
- rules: {
96
- "LAYER_VIOLATION": "error", // Now enforce
97
- "SLOT_NAMING": "error", // Now enforce
98
- }
99
- }
100
- ```
1
+ ---
2
+ title: Configure Rule Severity Levels
3
+ impact: MEDIUM
4
+ impactDescription: Customize guard behavior
5
+ tags: guard, config, rules
6
+ ---
7
+
8
+ ## Configure Rule Severity Levels
9
+
10
+ Set severity levels for each guard rule based on your project needs.
11
+
12
+ ## Severity Levels
13
+
14
+ | Level | Behavior | Use Case |
15
+ |-------|----------|----------|
16
+ | `error` | Fails check, blocks CI | Critical violations |
17
+ | `warn` | Reports issue, continues | Gradual migration |
18
+ | `off` | Ignores rule | Not applicable to project |
19
+
20
+ ## Configuration File
21
+
22
+ ```typescript
23
+ // mandu.config.ts
24
+
25
+ export default {
26
+ guard: {
27
+ preset: "mandu",
28
+ rules: {
29
+ // Core rules
30
+ "LAYER_VIOLATION": "error", // Always enforce layers
31
+ "GENERATED_DIRECT_EDIT": "error", // Protect generated files
32
+
33
+ // Naming rules
34
+ "SLOT_NAMING": "warn", // Warn during migration
35
+ "WRONG_SLOT_LOCATION": "error",
36
+
37
+ // Security rules
38
+ "FORBIDDEN_IMPORT": "error", // Block dangerous imports
39
+ },
40
+ },
41
+ };
42
+ ```
43
+
44
+ ## Available Rules
45
+
46
+ | Rule ID | Default | Description |
47
+ |---------|---------|-------------|
48
+ | `LAYER_VIOLATION` | error | Layer dependency violation |
49
+ | `GENERATED_DIRECT_EDIT` | error | Direct edit of generated files |
50
+ | `WRONG_SLOT_LOCATION` | error | Slot file in wrong directory |
51
+ | `SLOT_NAMING` | error | Incorrect slot file naming |
52
+ | `FORBIDDEN_IMPORT` | warn | Importing fs, child_process, etc. in browser code |
53
+ | `CIRCULAR_DEPENDENCY` | warn | Circular import detected |
54
+ | `DEEP_IMPORT` | warn | Importing from nested paths instead of index |
55
+
56
+ ## Ignoring Paths
57
+
58
+ ```typescript
59
+ export default {
60
+ guard: {
61
+ ignore: [
62
+ "**/test/**", // Test files
63
+ "**/*.test.ts", // Test files
64
+ "**/*.spec.ts", // Spec files
65
+ "**/mocks/**", // Mock files
66
+ "scripts/**", // Build scripts
67
+ ],
68
+ },
69
+ };
70
+ ```
71
+
72
+ ## Per-File Override
73
+
74
+ ```typescript
75
+ // src/features/legacy/index.ts
76
+
77
+ // @guard-disable LAYER_VIOLATION
78
+ import { oldHelper } from "@/entities/legacy"; // Allowed temporarily
79
+ // @guard-enable LAYER_VIOLATION
80
+ ```
81
+
82
+ ## Gradual Migration
83
+
84
+ ```typescript
85
+ // Start with warnings for legacy code
86
+ {
87
+ rules: {
88
+ "LAYER_VIOLATION": "warn", // Start with warn
89
+ "SLOT_NAMING": "off", // Fix later
90
+ }
91
+ }
92
+
93
+ // After migration, enforce strictly
94
+ {
95
+ rules: {
96
+ "LAYER_VIOLATION": "error", // Now enforce
97
+ "SLOT_NAMING": "error", // Now enforce
98
+ }
99
+ }
100
+ ```
@@ -1,76 +1,76 @@
1
- ---
2
- title: Dependencies Must Flow Downward Only
3
- impact: CRITICAL
4
- impactDescription: Core architecture principle
5
- tags: guard, layer, dependency
6
- ---
7
-
8
- ## Dependencies Must Flow Downward Only
9
-
10
- In layered architecture, imports must always flow from higher to lower layers.
11
-
12
- **Incorrect (upward dependency):**
13
-
14
- ```typescript
15
- // ❌ entities/user/index.ts importing from features (higher layer)
16
- import { useAuth } from "@/features/auth";
17
-
18
- export function User() {
19
- const { isLoggedIn } = useAuth(); // VIOLATION!
20
- // ...
21
- }
22
- ```
23
-
24
- **Correct (downward dependency):**
25
-
26
- ```typescript
27
- // ✅ features/auth/index.ts importing from entities (lower layer)
28
- import { User } from "@/entities/user";
29
-
30
- export function useAuth() {
31
- const user = getCurrentUser(); // Uses entity
32
- return { user, isLoggedIn: !!user };
33
- }
34
- ```
35
-
36
- ## Layer Hierarchy (Mandu Preset)
37
-
38
- ### Frontend Layers (top to bottom)
39
-
40
- ```
41
- app → Can import: pages, widgets, features, entities, shared
42
- pages → Can import: widgets, features, entities, shared
43
- widgets → Can import: features, entities, shared
44
- features → Can import: entities, shared
45
- entities → Can import: shared
46
- shared → Can import: (nothing above)
47
- ```
48
-
49
- ### Backend Layers (top to bottom)
50
-
51
- ```
52
- api → Can import: application, domain, infra, core, shared
53
- application → Can import: domain, infra, core, shared
54
- domain → Can import: core, shared
55
- infra → Can import: core, shared
56
- core → Can import: shared
57
- shared → Can import: (nothing above)
58
- ```
59
-
60
- ## Common Violations
61
-
62
- | Violation | Fix |
63
- |-----------|-----|
64
- | Entity imports Feature | Move shared logic to Entity or Shared |
65
- | Domain imports API | Use dependency injection |
66
- | Shared imports Feature | Extract to Shared or keep in Feature |
67
-
68
- ## Checking Dependencies
69
-
70
- ```bash
71
- # Check all architecture rules
72
- bunx mandu guard arch
73
-
74
- # Check specific file
75
- bunx mandu guard check src/entities/user/index.ts
76
- ```
1
+ ---
2
+ title: Dependencies Must Flow Downward Only
3
+ impact: CRITICAL
4
+ impactDescription: Core architecture principle
5
+ tags: guard, layer, dependency
6
+ ---
7
+
8
+ ## Dependencies Must Flow Downward Only
9
+
10
+ In layered architecture, imports must always flow from higher to lower layers.
11
+
12
+ **Incorrect (upward dependency):**
13
+
14
+ ```typescript
15
+ // ❌ entities/user/index.ts importing from features (higher layer)
16
+ import { useAuth } from "@/features/auth";
17
+
18
+ export function User() {
19
+ const { isLoggedIn } = useAuth(); // VIOLATION!
20
+ // ...
21
+ }
22
+ ```
23
+
24
+ **Correct (downward dependency):**
25
+
26
+ ```typescript
27
+ // ✅ features/auth/index.ts importing from entities (lower layer)
28
+ import { User } from "@/entities/user";
29
+
30
+ export function useAuth() {
31
+ const user = getCurrentUser(); // Uses entity
32
+ return { user, isLoggedIn: !!user };
33
+ }
34
+ ```
35
+
36
+ ## Layer Hierarchy (Mandu Preset)
37
+
38
+ ### Frontend Layers (top to bottom)
39
+
40
+ ```
41
+ app → Can import: pages, widgets, features, entities, shared
42
+ pages → Can import: widgets, features, entities, shared
43
+ widgets → Can import: features, entities, shared
44
+ features → Can import: entities, shared
45
+ entities → Can import: shared
46
+ shared → Can import: (nothing above)
47
+ ```
48
+
49
+ ### Backend Layers (top to bottom)
50
+
51
+ ```
52
+ api → Can import: application, domain, infra, core, shared
53
+ application → Can import: domain, infra, core, shared
54
+ domain → Can import: core, shared
55
+ infra → Can import: core, shared
56
+ core → Can import: shared
57
+ shared → Can import: (nothing above)
58
+ ```
59
+
60
+ ## Common Violations
61
+
62
+ | Violation | Fix |
63
+ |-----------|-----|
64
+ | Entity imports Feature | Move shared logic to Entity or Shared |
65
+ | Domain imports API | Use dependency injection |
66
+ | Shared imports Feature | Extract to Shared or keep in Feature |
67
+
68
+ ## Checking Dependencies
69
+
70
+ ```bash
71
+ # Check all architecture rules
72
+ bunx mandu guard arch
73
+
74
+ # Check specific file
75
+ bunx mandu guard check src/entities/user/index.ts
76
+ ```