@mandujs/mcp 0.9.19 → 0.9.21
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.
- package/README.md +320 -0
- package/package.json +1 -1
- package/src/activity-monitor.ts +847 -231
- package/src/resources/handlers.ts +244 -0
- package/src/resources/skills/guides.ts +1136 -0
- package/src/resources/skills/index.ts +12 -0
- package/src/resources/skills/loader.ts +218 -0
- package/src/resources/skills/mandu-composition/SKILL.md +91 -0
- package/src/resources/skills/mandu-composition/metadata.json +13 -0
- package/src/resources/skills/mandu-composition/rules/_sections.md +26 -0
- package/src/resources/skills/mandu-composition/rules/_template.md +77 -0
- package/src/resources/skills/mandu-composition/rules/comp-arch-avoid-boolean-props.md +146 -0
- package/src/resources/skills/mandu-composition/rules/comp-arch-compound-components.md +164 -0
- package/src/resources/skills/mandu-composition/rules/comp-island-event.md +161 -0
- package/src/resources/skills/mandu-composition/rules/comp-island-slot-split.md +167 -0
- package/src/resources/skills/mandu-composition/rules/comp-pattern-children.md +149 -0
- package/src/resources/skills/mandu-composition/rules/comp-state-context-interface.md +148 -0
- package/src/resources/skills/mandu-composition/rules/comp-state-lift-state.md +150 -0
- package/src/resources/skills/mandu-deployment/SKILL.md +92 -0
- package/src/resources/skills/mandu-deployment/_sections.md +41 -0
- package/src/resources/skills/mandu-deployment/_template.md +38 -0
- package/src/resources/skills/mandu-deployment/metadata.json +13 -0
- package/src/resources/skills/mandu-deployment/rules/deploy-build-bun.md +109 -0
- package/src/resources/skills/mandu-deployment/rules/deploy-build-output.md +115 -0
- package/src/resources/skills/mandu-deployment/rules/deploy-cicd-github.md +219 -0
- package/src/resources/skills/mandu-deployment/rules/deploy-docker-bun.md +150 -0
- package/src/resources/skills/mandu-deployment/rules/deploy-docker-compose.md +223 -0
- package/src/resources/skills/mandu-deployment/rules/deploy-platform-fly.md +152 -0
- package/src/resources/skills/mandu-deployment/rules/deploy-platform-render.md +179 -0
- package/src/resources/skills/mandu-deployment/rules/deploy-platform-supabase.md +323 -0
- package/src/resources/skills/mandu-deployment/rules/deploy-platform-vercel.md +140 -0
- package/src/resources/skills/mandu-fs-routes/SKILL.md +82 -0
- package/src/resources/skills/mandu-fs-routes/metadata.json +12 -0
- package/src/resources/skills/mandu-fs-routes/rules/_sections.md +36 -0
- package/src/resources/skills/mandu-fs-routes/rules/_template.md +69 -0
- package/src/resources/skills/mandu-fs-routes/rules/routes-api-methods.md +65 -0
- package/src/resources/skills/mandu-fs-routes/rules/routes-dynamic-param.md +93 -0
- package/src/resources/skills/mandu-fs-routes/rules/routes-naming-page.md +55 -0
- package/src/resources/skills/mandu-guard/SKILL.md +129 -0
- package/src/resources/skills/mandu-guard/metadata.json +12 -0
- package/src/resources/skills/mandu-guard/rules/_sections.md +36 -0
- package/src/resources/skills/mandu-guard/rules/_template.md +82 -0
- package/src/resources/skills/mandu-guard/rules/guard-config-rules.md +100 -0
- package/src/resources/skills/mandu-guard/rules/guard-layer-direction.md +76 -0
- package/src/resources/skills/mandu-guard/rules/guard-preset-mandu.md +81 -0
- package/src/resources/skills/mandu-guard/rules/guard-validate-import.md +80 -0
- package/src/resources/skills/mandu-hydration/SKILL.md +91 -0
- package/src/resources/skills/mandu-hydration/metadata.json +12 -0
- package/src/resources/skills/mandu-hydration/rules/_sections.md +31 -0
- package/src/resources/skills/mandu-hydration/rules/_template.md +72 -0
- package/src/resources/skills/mandu-hydration/rules/hydration-data-event.md +109 -0
- package/src/resources/skills/mandu-hydration/rules/hydration-directive-use-client.md +55 -0
- package/src/resources/skills/mandu-hydration/rules/hydration-island-setup.md +113 -0
- package/src/resources/skills/mandu-hydration/rules/hydration-priority-visible.md +68 -0
- package/src/resources/skills/mandu-performance/SKILL.md +85 -0
- package/src/resources/skills/mandu-performance/metadata.json +14 -0
- package/src/resources/skills/mandu-performance/rules/_sections.md +31 -0
- package/src/resources/skills/mandu-performance/rules/_template.md +64 -0
- package/src/resources/skills/mandu-performance/rules/perf-async-defer-await.md +103 -0
- package/src/resources/skills/mandu-performance/rules/perf-async-parallel.md +95 -0
- package/src/resources/skills/mandu-performance/rules/perf-bun-file.md +124 -0
- package/src/resources/skills/mandu-performance/rules/perf-bun-serve.md +125 -0
- package/src/resources/skills/mandu-performance/rules/perf-bundle-imports.md +80 -0
- package/src/resources/skills/mandu-performance/rules/perf-bundle-island-lazy.md +145 -0
- package/src/resources/skills/mandu-performance/rules/perf-cache-react.md +98 -0
- package/src/resources/skills/mandu-performance/rules/perf-render-transitions.md +154 -0
- package/src/resources/skills/mandu-security/SKILL.md +87 -0
- package/src/resources/skills/mandu-security/metadata.json +13 -0
- package/src/resources/skills/mandu-security/rules/_sections.md +31 -0
- package/src/resources/skills/mandu-security/rules/_template.md +74 -0
- package/src/resources/skills/mandu-security/rules/sec-auth-guard.md +127 -0
- package/src/resources/skills/mandu-security/rules/sec-env-management.md +133 -0
- package/src/resources/skills/mandu-security/rules/sec-input-validate.md +148 -0
- package/src/resources/skills/mandu-security/rules/sec-protect-csrf.md +146 -0
- package/src/resources/skills/mandu-security/rules/sec-protect-headers.md +138 -0
- package/src/resources/skills/mandu-slot/SKILL.md +85 -0
- package/src/resources/skills/mandu-slot/metadata.json +12 -0
- package/src/resources/skills/mandu-slot/rules/_sections.md +36 -0
- package/src/resources/skills/mandu-slot/rules/_template.md +63 -0
- package/src/resources/skills/mandu-slot/rules/slot-basic-structure.md +38 -0
- package/src/resources/skills/mandu-slot/rules/slot-ctx-response.md +56 -0
- package/src/resources/skills/mandu-slot/rules/slot-guard-auth.md +59 -0
- package/src/resources/skills/mandu-slot/rules/slot-http-methods.md +64 -0
- package/src/resources/skills/mandu-styling/SKILL.md +118 -0
- package/src/resources/skills/mandu-styling/_sections.md +36 -0
- package/src/resources/skills/mandu-styling/_template.md +32 -0
- package/src/resources/skills/mandu-styling/metadata.json +13 -0
- package/src/resources/skills/mandu-styling/rules/style-component-compound.md +235 -0
- package/src/resources/skills/mandu-styling/rules/style-component-slots.md +255 -0
- package/src/resources/skills/mandu-styling/rules/style-component-tokens.md +205 -0
- package/src/resources/skills/mandu-styling/rules/style-island-animations.md +272 -0
- package/src/resources/skills/mandu-styling/rules/style-island-scoping.md +167 -0
- package/src/resources/skills/mandu-styling/rules/style-island-variants.md +221 -0
- package/src/resources/skills/mandu-styling/rules/style-perf-critical.md +209 -0
- package/src/resources/skills/mandu-styling/rules/style-perf-purge.md +192 -0
- package/src/resources/skills/mandu-styling/rules/style-setup-modules.md +162 -0
- package/src/resources/skills/mandu-styling/rules/style-setup-panda.md +164 -0
- package/src/resources/skills/mandu-styling/rules/style-setup-tailwind.md +161 -0
- package/src/resources/skills/mandu-styling/rules/style-theme-darkmode.md +229 -0
- package/src/resources/skills/mandu-testing/SKILL.md +99 -0
- package/src/resources/skills/mandu-testing/metadata.json +13 -0
- package/src/resources/skills/mandu-testing/rules/_sections.md +26 -0
- package/src/resources/skills/mandu-testing/rules/_template.md +65 -0
- package/src/resources/skills/mandu-testing/rules/test-component-island.md +195 -0
- package/src/resources/skills/mandu-testing/rules/test-e2e-playwright.md +196 -0
- package/src/resources/skills/mandu-testing/rules/test-mock-fetch.md +219 -0
- package/src/resources/skills/mandu-testing/rules/test-slot-unit.md +192 -0
- package/src/resources/skills/mandu-ui/SKILL.md +117 -0
- package/src/resources/skills/mandu-ui/_sections.md +23 -0
- package/src/resources/skills/mandu-ui/_template.md +32 -0
- package/src/resources/skills/mandu-ui/metadata.json +13 -0
- package/src/resources/skills/mandu-ui/rules/ui-accessibility-aria.md +232 -0
- package/src/resources/skills/mandu-ui/rules/ui-accessibility-focus.md +238 -0
- package/src/resources/skills/mandu-ui/rules/ui-composition-patterns.md +259 -0
- package/src/resources/skills/mandu-ui/rules/ui-island-integration.md +258 -0
- package/src/resources/skills/mandu-ui/rules/ui-radix-patterns.md +213 -0
- package/src/resources/skills/mandu-ui/rules/ui-shadcn-setup.md +209 -0
- package/src/resources/skills/recipes.ts +932 -0
- package/src/server.ts +3 -0
- package/src/tools/hydration.ts +8 -8
- package/src/tools/index.ts +1 -0
- package/src/tools/seo.ts +417 -0
|
@@ -0,0 +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 옵션. 일부 위반의 자동 수정 기능입니다.
|
|
@@ -0,0 +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 |
|
|
@@ -0,0 +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
|
+
```
|
|
@@ -0,0 +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
|
+
```
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Use Mandu Preset for Full-Stack Projects
|
|
3
|
+
impact: HIGH
|
|
4
|
+
impactDescription: Recommended architecture preset
|
|
5
|
+
tags: guard, preset, architecture
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Use Mandu Preset for Full-Stack Projects
|
|
9
|
+
|
|
10
|
+
The Mandu preset combines FSD (Feature-Sliced Design) for frontend with Clean Architecture for backend.
|
|
11
|
+
|
|
12
|
+
## Preset Selection Guide
|
|
13
|
+
|
|
14
|
+
| Preset | Use Case | Frontend | Backend |
|
|
15
|
+
|--------|----------|----------|---------|
|
|
16
|
+
| `mandu` | Full-stack projects | FSD | Clean |
|
|
17
|
+
| `fsd` | Frontend-focused | FSD | - |
|
|
18
|
+
| `clean` | Backend-focused | - | Clean |
|
|
19
|
+
| `hexagonal` | Domain-heavy | - | Hexagonal |
|
|
20
|
+
| `atomic` | Component libraries | Atomic | - |
|
|
21
|
+
|
|
22
|
+
## Mandu Preset Structure
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
src/
|
|
26
|
+
├── app/ # App entry, routing
|
|
27
|
+
├── pages/ # Page components
|
|
28
|
+
├── widgets/ # Complex UI blocks
|
|
29
|
+
├── features/ # Feature modules
|
|
30
|
+
│ ├── auth/
|
|
31
|
+
│ ├── cart/
|
|
32
|
+
│ └── search/
|
|
33
|
+
├── entities/ # Business entities
|
|
34
|
+
│ ├── user/
|
|
35
|
+
│ ├── product/
|
|
36
|
+
│ └── order/
|
|
37
|
+
├── shared/ # Shared utilities
|
|
38
|
+
│ ├── ui/ # UI components
|
|
39
|
+
│ ├── lib/ # Utility functions
|
|
40
|
+
│ ├── api/ # API client
|
|
41
|
+
│ └── config/ # Configuration
|
|
42
|
+
└── api/ # Backend
|
|
43
|
+
├── application/ # Use cases
|
|
44
|
+
├── domain/ # Business logic
|
|
45
|
+
├── infra/ # Database, external
|
|
46
|
+
└── core/ # Core utilities
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Configuration
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
// mandu.config.ts
|
|
53
|
+
|
|
54
|
+
export default {
|
|
55
|
+
guard: {
|
|
56
|
+
preset: "mandu", // Use mandu preset
|
|
57
|
+
rules: {
|
|
58
|
+
"LAYER_VIOLATION": "error",
|
|
59
|
+
"SLOT_NAMING": "warn",
|
|
60
|
+
},
|
|
61
|
+
ignore: [
|
|
62
|
+
"**/test/**",
|
|
63
|
+
"**/*.test.ts",
|
|
64
|
+
"**/*.spec.ts",
|
|
65
|
+
],
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Switching Presets
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
# Use FSD only (frontend project)
|
|
74
|
+
bunx mandu guard arch --preset fsd
|
|
75
|
+
|
|
76
|
+
# Use Clean only (backend project)
|
|
77
|
+
bunx mandu guard arch --preset clean
|
|
78
|
+
|
|
79
|
+
# Use Mandu (full-stack, default)
|
|
80
|
+
bunx mandu guard arch --preset mandu
|
|
81
|
+
```
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Validate Import Paths Against Architecture
|
|
3
|
+
impact: HIGH
|
|
4
|
+
impactDescription: Prevents architecture violations
|
|
5
|
+
tags: guard, validate, import
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Validate Import Paths Against Architecture
|
|
9
|
+
|
|
10
|
+
Check that all imports respect layer boundaries before committing code.
|
|
11
|
+
|
|
12
|
+
## Valid Import Examples
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
// ✅ features/auth/login.ts → entities/user
|
|
16
|
+
import { User, createUser } from "@/entities/user";
|
|
17
|
+
|
|
18
|
+
// ✅ widgets/header/index.tsx → features/auth
|
|
19
|
+
import { useAuth } from "@/features/auth";
|
|
20
|
+
|
|
21
|
+
// ✅ pages/home/page.tsx → widgets/header
|
|
22
|
+
import { Header } from "@/widgets/header";
|
|
23
|
+
|
|
24
|
+
// ✅ Any layer → shared
|
|
25
|
+
import { formatDate } from "@/shared/lib/date";
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Invalid Import Examples
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
// ❌ entities/user → features/auth (upward)
|
|
32
|
+
import { useAuth } from "@/features/auth"; // VIOLATION!
|
|
33
|
+
|
|
34
|
+
// ❌ shared/lib → entities/user (upward)
|
|
35
|
+
import { User } from "@/entities/user"; // VIOLATION!
|
|
36
|
+
|
|
37
|
+
// ❌ features/auth → features/cart (same layer cross-import)
|
|
38
|
+
import { CartItem } from "@/features/cart"; // VIOLATION!
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Checking Imports
|
|
42
|
+
|
|
43
|
+
### CLI
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# Check single import
|
|
47
|
+
bunx mandu guard check-import \
|
|
48
|
+
--from "src/features/auth/index.ts" \
|
|
49
|
+
--import "@/entities/user"
|
|
50
|
+
|
|
51
|
+
# Check all imports in a file
|
|
52
|
+
bunx mandu guard check src/features/auth/index.ts
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### MCP Tool
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
// Check import validity
|
|
59
|
+
mandu_check_import({
|
|
60
|
+
fromFile: "src/features/auth/index.ts",
|
|
61
|
+
importPath: "@/entities/user"
|
|
62
|
+
})
|
|
63
|
+
// Returns: { valid: true, layer: "features", targetLayer: "entities" }
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Fixing Violations
|
|
67
|
+
|
|
68
|
+
| Pattern | Problem | Solution |
|
|
69
|
+
|---------|---------|----------|
|
|
70
|
+
| Upward import | Lower layer needs higher | Move shared logic down or use DI |
|
|
71
|
+
| Cross-feature import | Feature A uses Feature B | Extract to shared or create entity |
|
|
72
|
+
| Circular import | A → B → A | Restructure or use interfaces |
|
|
73
|
+
|
|
74
|
+
## CI Integration
|
|
75
|
+
|
|
76
|
+
```yaml
|
|
77
|
+
# .github/workflows/guard.yml
|
|
78
|
+
- name: Check Architecture
|
|
79
|
+
run: bunx mandu guard arch --ci
|
|
80
|
+
```
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: mandu-hydration
|
|
3
|
+
description: |
|
|
4
|
+
Island Hydration pattern for Mandu. Use when creating interactive components,
|
|
5
|
+
client-side state, or partial hydration. Triggers on tasks involving
|
|
6
|
+
"use client", client.tsx, useState, useEffect, Island, or hydration.
|
|
7
|
+
license: MIT
|
|
8
|
+
metadata:
|
|
9
|
+
author: mandu
|
|
10
|
+
version: "1.0.0"
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# Mandu Island Hydration
|
|
14
|
+
|
|
15
|
+
Island Hydration은 페이지의 일부분만 클라이언트에서 인터랙티브하게 만드는 기술입니다.
|
|
16
|
+
대부분의 페이지는 정적 HTML로 유지하고, 필요한 부분만 JavaScript를 로드합니다.
|
|
17
|
+
|
|
18
|
+
## When to Apply
|
|
19
|
+
|
|
20
|
+
Reference these guidelines when:
|
|
21
|
+
- Creating interactive client components
|
|
22
|
+
- Adding client-side state to pages
|
|
23
|
+
- Implementing partial hydration
|
|
24
|
+
- Setting up client-server data flow
|
|
25
|
+
- Working with Island communication
|
|
26
|
+
|
|
27
|
+
## Rule Categories by Priority
|
|
28
|
+
|
|
29
|
+
| Priority | Category | Impact | Prefix |
|
|
30
|
+
|----------|----------|--------|--------|
|
|
31
|
+
| 1 | Client Directive | CRITICAL | `hydration-directive-` |
|
|
32
|
+
| 2 | Island Structure | HIGH | `hydration-island-` |
|
|
33
|
+
| 3 | Hydration Priority | MEDIUM | `hydration-priority-` |
|
|
34
|
+
| 4 | Data Flow | MEDIUM | `hydration-data-` |
|
|
35
|
+
|
|
36
|
+
## Quick Reference
|
|
37
|
+
|
|
38
|
+
### 1. Client Directive (CRITICAL)
|
|
39
|
+
|
|
40
|
+
- `hydration-directive-use-client` - Add "use client" directive for client components
|
|
41
|
+
- `hydration-directive-file-naming` - Use .client.tsx for client component files
|
|
42
|
+
|
|
43
|
+
### 2. Island Structure (HIGH)
|
|
44
|
+
|
|
45
|
+
- `hydration-island-setup` - Use Mandu.island() with setup function
|
|
46
|
+
- `hydration-island-render` - Separate state logic from render
|
|
47
|
+
|
|
48
|
+
### 3. Hydration Priority (MEDIUM)
|
|
49
|
+
|
|
50
|
+
- `hydration-priority-immediate` - Load on page load (critical interactions)
|
|
51
|
+
- `hydration-priority-visible` - Load when visible (default)
|
|
52
|
+
- `hydration-priority-idle` - Load when browser idle
|
|
53
|
+
- `hydration-priority-interaction` - Load on user interaction
|
|
54
|
+
|
|
55
|
+
### 4. Data Flow (MEDIUM)
|
|
56
|
+
|
|
57
|
+
- `hydration-data-server` - Access server data with useServerData
|
|
58
|
+
- `hydration-data-event` - Communicate between Islands with useIslandEvent
|
|
59
|
+
|
|
60
|
+
## Hydration Strategies
|
|
61
|
+
|
|
62
|
+
| Strategy | Description | Use Case |
|
|
63
|
+
|----------|-------------|----------|
|
|
64
|
+
| `none` | No JavaScript | Pure static pages |
|
|
65
|
+
| `island` | Partial hydration (default) | Static + interactive mix |
|
|
66
|
+
| `full` | Full hydration | SPA-style pages |
|
|
67
|
+
|
|
68
|
+
## Client Hooks
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
import {
|
|
72
|
+
useServerData,
|
|
73
|
+
useHydrated,
|
|
74
|
+
useIslandEvent,
|
|
75
|
+
} from "@mandujs/core/client";
|
|
76
|
+
|
|
77
|
+
// Access SSR data
|
|
78
|
+
const data = useServerData<UserData>("user", defaultValue);
|
|
79
|
+
|
|
80
|
+
// Check hydration status
|
|
81
|
+
const isHydrated = useHydrated();
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## How to Use
|
|
85
|
+
|
|
86
|
+
Read individual rule files for detailed explanations:
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
rules/hydration-directive-use-client.md
|
|
90
|
+
rules/hydration-island-setup.md
|
|
91
|
+
```
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "1.0.0",
|
|
3
|
+
"organization": "Mandu Framework",
|
|
4
|
+
"date": "February 2026",
|
|
5
|
+
"abstract": "Island Hydration 패턴 가이드. 부분 hydration으로 페이지의 일부만 인터랙티브하게 만드는 기술입니다. \"use client\" 지시어, Mandu.island() API, hydration 우선순위, Island 간 통신을 다룹니다.",
|
|
6
|
+
"references": [
|
|
7
|
+
"https://jasonformat.com/islands-architecture/",
|
|
8
|
+
"https://docs.astro.build/en/concepts/islands/",
|
|
9
|
+
"https://fresh.deno.dev/docs/concepts/islands"
|
|
10
|
+
],
|
|
11
|
+
"tags": ["hydration", "island", "client", "interactive", "mandu"]
|
|
12
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
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. Client Directive (hydration-directive)
|
|
9
|
+
|
|
10
|
+
**Impact:** CRITICAL
|
|
11
|
+
**Description:** "use client" 지시어와 .client.tsx 파일 명명. 클라이언트 컴포넌트 식별에 필수입니다.
|
|
12
|
+
|
|
13
|
+
## 2. Island Structure (hydration-island)
|
|
14
|
+
|
|
15
|
+
**Impact:** HIGH
|
|
16
|
+
**Description:** Mandu.island() API로 Island 컴포넌트 구조화. setup/render 분리 패턴을 다룹니다.
|
|
17
|
+
|
|
18
|
+
## 3. Hydration Priority (hydration-priority)
|
|
19
|
+
|
|
20
|
+
**Impact:** MEDIUM
|
|
21
|
+
**Description:** immediate, visible, idle, interaction 우선순위. 초기 로드 성능 최적화에 중요합니다.
|
|
22
|
+
|
|
23
|
+
## 4. Data Flow (hydration-data)
|
|
24
|
+
|
|
25
|
+
**Impact:** MEDIUM
|
|
26
|
+
**Description:** useServerData, useIslandEvent를 통한 데이터 흐름. 서버-클라이언트, Island 간 통신입니다.
|
|
27
|
+
|
|
28
|
+
## 5. Error Handling (hydration-error)
|
|
29
|
+
|
|
30
|
+
**Impact:** LOW
|
|
31
|
+
**Description:** errorBoundary, loading 상태 처리. 사용자 경험 향상을 위한 폴백 UI입니다.
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# Rule Template
|
|
2
|
+
|
|
3
|
+
Use this template when creating new rules for mandu-hydration.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
```markdown
|
|
8
|
+
---
|
|
9
|
+
title: Rule Title Here
|
|
10
|
+
impact: CRITICAL | HIGH | MEDIUM | LOW
|
|
11
|
+
impactDescription: 영향 설명
|
|
12
|
+
tags: hydration, tag1, tag2
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Rule Title Here
|
|
16
|
+
|
|
17
|
+
**Impact: {LEVEL} ({impactDescription})**
|
|
18
|
+
|
|
19
|
+
규칙의 목적과 중요성을 설명합니다.
|
|
20
|
+
|
|
21
|
+
**Incorrect (문제점 설명):**
|
|
22
|
+
|
|
23
|
+
\`\`\`tsx
|
|
24
|
+
// 잘못된 예시
|
|
25
|
+
import { useState } from "react";
|
|
26
|
+
|
|
27
|
+
export default function Counter() {
|
|
28
|
+
const [count, setCount] = useState(0); // ❌ "use client" 없음
|
|
29
|
+
return <button>{count}</button>;
|
|
30
|
+
}
|
|
31
|
+
\`\`\`
|
|
32
|
+
|
|
33
|
+
**Correct (올바른 방법):**
|
|
34
|
+
|
|
35
|
+
\`\`\`tsx
|
|
36
|
+
// 올바른 예시
|
|
37
|
+
"use client";
|
|
38
|
+
|
|
39
|
+
import { useState } from "react";
|
|
40
|
+
|
|
41
|
+
export default function Counter() {
|
|
42
|
+
const [count, setCount] = useState(0); // ✅ 작동함
|
|
43
|
+
return <button onClick={() => setCount(c => c + 1)}>{count}</button>;
|
|
44
|
+
}
|
|
45
|
+
\`\`\`
|
|
46
|
+
|
|
47
|
+
Reference: [관련 문서 링크](https://example.com)
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Naming Convention
|
|
53
|
+
|
|
54
|
+
- 파일명: `{section}-{rule-name}.md`
|
|
55
|
+
- 예시: `hydration-directive-use-client.md`, `hydration-island-setup.md`
|
|
56
|
+
|
|
57
|
+
## Hydration Strategies Quick Reference
|
|
58
|
+
|
|
59
|
+
| Strategy | JavaScript | Use Case |
|
|
60
|
+
|----------|------------|----------|
|
|
61
|
+
| `none` | 없음 | 순수 정적 페이지 |
|
|
62
|
+
| `island` | 부분 | 정적 + 인터랙티브 혼합 (기본값) |
|
|
63
|
+
| `full` | 전체 | SPA 스타일 페이지 |
|
|
64
|
+
|
|
65
|
+
## Priority Quick Reference
|
|
66
|
+
|
|
67
|
+
| Priority | Load Time | Use Case |
|
|
68
|
+
|----------|-----------|----------|
|
|
69
|
+
| `immediate` | 페이지 로드 | 중요한 인터랙션 |
|
|
70
|
+
| `visible` | 뷰포트 진입 | 스크롤 아래 콘텐츠 (기본값) |
|
|
71
|
+
| `idle` | 브라우저 유휴 | 비중요 기능 |
|
|
72
|
+
| `interaction` | 사용자 액션 | 클릭해야 활성화 |
|