@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.
Files changed (122) hide show
  1. package/README.md +320 -0
  2. package/package.json +1 -1
  3. package/src/activity-monitor.ts +847 -231
  4. package/src/resources/handlers.ts +244 -0
  5. package/src/resources/skills/guides.ts +1136 -0
  6. package/src/resources/skills/index.ts +12 -0
  7. package/src/resources/skills/loader.ts +218 -0
  8. package/src/resources/skills/mandu-composition/SKILL.md +91 -0
  9. package/src/resources/skills/mandu-composition/metadata.json +13 -0
  10. package/src/resources/skills/mandu-composition/rules/_sections.md +26 -0
  11. package/src/resources/skills/mandu-composition/rules/_template.md +77 -0
  12. package/src/resources/skills/mandu-composition/rules/comp-arch-avoid-boolean-props.md +146 -0
  13. package/src/resources/skills/mandu-composition/rules/comp-arch-compound-components.md +164 -0
  14. package/src/resources/skills/mandu-composition/rules/comp-island-event.md +161 -0
  15. package/src/resources/skills/mandu-composition/rules/comp-island-slot-split.md +167 -0
  16. package/src/resources/skills/mandu-composition/rules/comp-pattern-children.md +149 -0
  17. package/src/resources/skills/mandu-composition/rules/comp-state-context-interface.md +148 -0
  18. package/src/resources/skills/mandu-composition/rules/comp-state-lift-state.md +150 -0
  19. package/src/resources/skills/mandu-deployment/SKILL.md +92 -0
  20. package/src/resources/skills/mandu-deployment/_sections.md +41 -0
  21. package/src/resources/skills/mandu-deployment/_template.md +38 -0
  22. package/src/resources/skills/mandu-deployment/metadata.json +13 -0
  23. package/src/resources/skills/mandu-deployment/rules/deploy-build-bun.md +109 -0
  24. package/src/resources/skills/mandu-deployment/rules/deploy-build-output.md +115 -0
  25. package/src/resources/skills/mandu-deployment/rules/deploy-cicd-github.md +219 -0
  26. package/src/resources/skills/mandu-deployment/rules/deploy-docker-bun.md +150 -0
  27. package/src/resources/skills/mandu-deployment/rules/deploy-docker-compose.md +223 -0
  28. package/src/resources/skills/mandu-deployment/rules/deploy-platform-fly.md +152 -0
  29. package/src/resources/skills/mandu-deployment/rules/deploy-platform-render.md +179 -0
  30. package/src/resources/skills/mandu-deployment/rules/deploy-platform-supabase.md +323 -0
  31. package/src/resources/skills/mandu-deployment/rules/deploy-platform-vercel.md +140 -0
  32. package/src/resources/skills/mandu-fs-routes/SKILL.md +82 -0
  33. package/src/resources/skills/mandu-fs-routes/metadata.json +12 -0
  34. package/src/resources/skills/mandu-fs-routes/rules/_sections.md +36 -0
  35. package/src/resources/skills/mandu-fs-routes/rules/_template.md +69 -0
  36. package/src/resources/skills/mandu-fs-routes/rules/routes-api-methods.md +65 -0
  37. package/src/resources/skills/mandu-fs-routes/rules/routes-dynamic-param.md +93 -0
  38. package/src/resources/skills/mandu-fs-routes/rules/routes-naming-page.md +55 -0
  39. package/src/resources/skills/mandu-guard/SKILL.md +129 -0
  40. package/src/resources/skills/mandu-guard/metadata.json +12 -0
  41. package/src/resources/skills/mandu-guard/rules/_sections.md +36 -0
  42. package/src/resources/skills/mandu-guard/rules/_template.md +82 -0
  43. package/src/resources/skills/mandu-guard/rules/guard-config-rules.md +100 -0
  44. package/src/resources/skills/mandu-guard/rules/guard-layer-direction.md +76 -0
  45. package/src/resources/skills/mandu-guard/rules/guard-preset-mandu.md +81 -0
  46. package/src/resources/skills/mandu-guard/rules/guard-validate-import.md +80 -0
  47. package/src/resources/skills/mandu-hydration/SKILL.md +91 -0
  48. package/src/resources/skills/mandu-hydration/metadata.json +12 -0
  49. package/src/resources/skills/mandu-hydration/rules/_sections.md +31 -0
  50. package/src/resources/skills/mandu-hydration/rules/_template.md +72 -0
  51. package/src/resources/skills/mandu-hydration/rules/hydration-data-event.md +109 -0
  52. package/src/resources/skills/mandu-hydration/rules/hydration-directive-use-client.md +55 -0
  53. package/src/resources/skills/mandu-hydration/rules/hydration-island-setup.md +113 -0
  54. package/src/resources/skills/mandu-hydration/rules/hydration-priority-visible.md +68 -0
  55. package/src/resources/skills/mandu-performance/SKILL.md +85 -0
  56. package/src/resources/skills/mandu-performance/metadata.json +14 -0
  57. package/src/resources/skills/mandu-performance/rules/_sections.md +31 -0
  58. package/src/resources/skills/mandu-performance/rules/_template.md +64 -0
  59. package/src/resources/skills/mandu-performance/rules/perf-async-defer-await.md +103 -0
  60. package/src/resources/skills/mandu-performance/rules/perf-async-parallel.md +95 -0
  61. package/src/resources/skills/mandu-performance/rules/perf-bun-file.md +124 -0
  62. package/src/resources/skills/mandu-performance/rules/perf-bun-serve.md +125 -0
  63. package/src/resources/skills/mandu-performance/rules/perf-bundle-imports.md +80 -0
  64. package/src/resources/skills/mandu-performance/rules/perf-bundle-island-lazy.md +145 -0
  65. package/src/resources/skills/mandu-performance/rules/perf-cache-react.md +98 -0
  66. package/src/resources/skills/mandu-performance/rules/perf-render-transitions.md +154 -0
  67. package/src/resources/skills/mandu-security/SKILL.md +87 -0
  68. package/src/resources/skills/mandu-security/metadata.json +13 -0
  69. package/src/resources/skills/mandu-security/rules/_sections.md +31 -0
  70. package/src/resources/skills/mandu-security/rules/_template.md +74 -0
  71. package/src/resources/skills/mandu-security/rules/sec-auth-guard.md +127 -0
  72. package/src/resources/skills/mandu-security/rules/sec-env-management.md +133 -0
  73. package/src/resources/skills/mandu-security/rules/sec-input-validate.md +148 -0
  74. package/src/resources/skills/mandu-security/rules/sec-protect-csrf.md +146 -0
  75. package/src/resources/skills/mandu-security/rules/sec-protect-headers.md +138 -0
  76. package/src/resources/skills/mandu-slot/SKILL.md +85 -0
  77. package/src/resources/skills/mandu-slot/metadata.json +12 -0
  78. package/src/resources/skills/mandu-slot/rules/_sections.md +36 -0
  79. package/src/resources/skills/mandu-slot/rules/_template.md +63 -0
  80. package/src/resources/skills/mandu-slot/rules/slot-basic-structure.md +38 -0
  81. package/src/resources/skills/mandu-slot/rules/slot-ctx-response.md +56 -0
  82. package/src/resources/skills/mandu-slot/rules/slot-guard-auth.md +59 -0
  83. package/src/resources/skills/mandu-slot/rules/slot-http-methods.md +64 -0
  84. package/src/resources/skills/mandu-styling/SKILL.md +118 -0
  85. package/src/resources/skills/mandu-styling/_sections.md +36 -0
  86. package/src/resources/skills/mandu-styling/_template.md +32 -0
  87. package/src/resources/skills/mandu-styling/metadata.json +13 -0
  88. package/src/resources/skills/mandu-styling/rules/style-component-compound.md +235 -0
  89. package/src/resources/skills/mandu-styling/rules/style-component-slots.md +255 -0
  90. package/src/resources/skills/mandu-styling/rules/style-component-tokens.md +205 -0
  91. package/src/resources/skills/mandu-styling/rules/style-island-animations.md +272 -0
  92. package/src/resources/skills/mandu-styling/rules/style-island-scoping.md +167 -0
  93. package/src/resources/skills/mandu-styling/rules/style-island-variants.md +221 -0
  94. package/src/resources/skills/mandu-styling/rules/style-perf-critical.md +209 -0
  95. package/src/resources/skills/mandu-styling/rules/style-perf-purge.md +192 -0
  96. package/src/resources/skills/mandu-styling/rules/style-setup-modules.md +162 -0
  97. package/src/resources/skills/mandu-styling/rules/style-setup-panda.md +164 -0
  98. package/src/resources/skills/mandu-styling/rules/style-setup-tailwind.md +161 -0
  99. package/src/resources/skills/mandu-styling/rules/style-theme-darkmode.md +229 -0
  100. package/src/resources/skills/mandu-testing/SKILL.md +99 -0
  101. package/src/resources/skills/mandu-testing/metadata.json +13 -0
  102. package/src/resources/skills/mandu-testing/rules/_sections.md +26 -0
  103. package/src/resources/skills/mandu-testing/rules/_template.md +65 -0
  104. package/src/resources/skills/mandu-testing/rules/test-component-island.md +195 -0
  105. package/src/resources/skills/mandu-testing/rules/test-e2e-playwright.md +196 -0
  106. package/src/resources/skills/mandu-testing/rules/test-mock-fetch.md +219 -0
  107. package/src/resources/skills/mandu-testing/rules/test-slot-unit.md +192 -0
  108. package/src/resources/skills/mandu-ui/SKILL.md +117 -0
  109. package/src/resources/skills/mandu-ui/_sections.md +23 -0
  110. package/src/resources/skills/mandu-ui/_template.md +32 -0
  111. package/src/resources/skills/mandu-ui/metadata.json +13 -0
  112. package/src/resources/skills/mandu-ui/rules/ui-accessibility-aria.md +232 -0
  113. package/src/resources/skills/mandu-ui/rules/ui-accessibility-focus.md +238 -0
  114. package/src/resources/skills/mandu-ui/rules/ui-composition-patterns.md +259 -0
  115. package/src/resources/skills/mandu-ui/rules/ui-island-integration.md +258 -0
  116. package/src/resources/skills/mandu-ui/rules/ui-radix-patterns.md +213 -0
  117. package/src/resources/skills/mandu-ui/rules/ui-shadcn-setup.md +209 -0
  118. package/src/resources/skills/recipes.ts +932 -0
  119. package/src/server.ts +3 -0
  120. package/src/tools/hydration.ts +8 -8
  121. package/src/tools/index.ts +1 -0
  122. package/src/tools/seo.ts +417 -0
@@ -0,0 +1,12 @@
1
+ export { GUIDES, getGuide, listGuides, type GuideId } from "./guides.js";
2
+ export { RECIPES, getRecipe, listRecipes, type RecipeId } from "./recipes.js";
3
+
4
+ // Agent Skills pattern
5
+ export {
6
+ listSkills,
7
+ getSkill,
8
+ listSkillRules,
9
+ getSkillRule,
10
+ type SkillMeta,
11
+ type RuleMeta,
12
+ } from "./loader.js";
@@ -0,0 +1,218 @@
1
+ /**
2
+ * Mandu MCP Skills - File-based Skill Loader
3
+ * Agent Skills 패턴으로 구성된 스킬을 파일 시스템에서 로드
4
+ */
5
+
6
+ import { readdir, readFile } from "fs/promises";
7
+ import { join, dirname } from "path";
8
+ import { fileURLToPath } from "url";
9
+
10
+ const __filename = fileURLToPath(import.meta.url);
11
+ const __dirname = dirname(__filename);
12
+
13
+ export interface SkillMeta {
14
+ id: string;
15
+ name: string;
16
+ description: string;
17
+ version: string;
18
+ author: string;
19
+ }
20
+
21
+ export interface RuleMeta {
22
+ id: string;
23
+ title: string;
24
+ impact: "CRITICAL" | "HIGH" | "MEDIUM" | "LOW";
25
+ impactDescription: string;
26
+ tags: string[];
27
+ }
28
+
29
+ // Available skills
30
+ const SKILL_IDS = [
31
+ "mandu-slot",
32
+ "mandu-fs-routes",
33
+ "mandu-hydration",
34
+ "mandu-guard",
35
+ "mandu-performance",
36
+ "mandu-composition",
37
+ "mandu-security",
38
+ "mandu-testing",
39
+ "mandu-deployment",
40
+ "mandu-styling",
41
+ "mandu-ui",
42
+ ];
43
+
44
+ /**
45
+ * Parse YAML frontmatter from markdown content
46
+ */
47
+ function parseFrontmatter(content: string): { frontmatter: Record<string, unknown>; body: string } {
48
+ const match = content.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n([\s\S]*)$/);
49
+ if (!match) {
50
+ return { frontmatter: {}, body: content };
51
+ }
52
+
53
+ const [, yamlStr, body] = match;
54
+ const frontmatter: Record<string, unknown> = {};
55
+
56
+ // Simple YAML parsing (key: value pairs)
57
+ for (const line of yamlStr.split("\n")) {
58
+ const colonIndex = line.indexOf(":");
59
+ if (colonIndex > 0) {
60
+ const key = line.slice(0, colonIndex).trim();
61
+ let value: unknown = line.slice(colonIndex + 1).trim();
62
+
63
+ // Handle multiline values (description with |)
64
+ if (value === "|") {
65
+ continue; // Will be captured in subsequent lines
66
+ }
67
+
68
+ // Parse arrays (tags)
69
+ if (typeof value === "string" && value.includes(",")) {
70
+ value = value.split(",").map((s) => s.trim());
71
+ }
72
+
73
+ frontmatter[key] = value;
74
+ }
75
+ }
76
+
77
+ return { frontmatter, body };
78
+ }
79
+
80
+ /**
81
+ * List all available skills
82
+ */
83
+ export function listSkills(): SkillMeta[] {
84
+ return SKILL_IDS.map((id) => {
85
+ const name = id.replace("mandu-", "");
86
+ return {
87
+ id,
88
+ name,
89
+ description: getSkillDescription(id),
90
+ version: "1.0.0",
91
+ author: "mandu",
92
+ };
93
+ });
94
+ }
95
+
96
+ function getSkillDescription(id: string): string {
97
+ const descriptions: Record<string, string> = {
98
+ "mandu-slot": "Business logic with Mandu.filling() API",
99
+ "mandu-fs-routes": "File-system based routing patterns",
100
+ "mandu-hydration": "Island hydration and client components",
101
+ "mandu-guard": "Architecture enforcement and layer dependencies",
102
+ "mandu-performance": "Performance optimization patterns for Mandu apps",
103
+ "mandu-composition": "React composition patterns for Islands and state",
104
+ "mandu-security": "Security best practices for authentication and protection",
105
+ "mandu-testing": "Testing patterns with Bun test and Playwright",
106
+ "mandu-deployment": "Production deployment with Render, Supabase, Docker, and CI/CD",
107
+ "mandu-styling": "CSS framework integration with Tailwind, Panda CSS, and theming",
108
+ "mandu-ui": "UI component library integration with shadcn/ui and accessibility",
109
+ };
110
+ return descriptions[id] || "";
111
+ }
112
+
113
+ /**
114
+ * Get a skill's SKILL.md content
115
+ */
116
+ export async function getSkill(skillId: string): Promise<{ meta: SkillMeta; content: string } | null> {
117
+ if (!SKILL_IDS.includes(skillId)) {
118
+ return null;
119
+ }
120
+
121
+ const skillPath = join(__dirname, skillId, "SKILL.md");
122
+
123
+ try {
124
+ const content = await readFile(skillPath, "utf-8");
125
+ const { frontmatter, body } = parseFrontmatter(content);
126
+
127
+ return {
128
+ meta: {
129
+ id: skillId,
130
+ name: (frontmatter.name as string) || skillId,
131
+ description: (frontmatter.description as string) || "",
132
+ version: ((frontmatter.metadata as Record<string, string>)?.version as string) || "1.0.0",
133
+ author: ((frontmatter.metadata as Record<string, string>)?.author as string) || "mandu",
134
+ },
135
+ content: body,
136
+ };
137
+ } catch {
138
+ return null;
139
+ }
140
+ }
141
+
142
+ /**
143
+ * List rules for a skill
144
+ */
145
+ export async function listSkillRules(skillId: string): Promise<RuleMeta[]> {
146
+ if (!SKILL_IDS.includes(skillId)) {
147
+ return [];
148
+ }
149
+
150
+ const rulesPath = join(__dirname, skillId, "rules");
151
+
152
+ try {
153
+ const files = await readdir(rulesPath);
154
+ const rules: RuleMeta[] = [];
155
+
156
+ for (const file of files) {
157
+ if (!file.endsWith(".md")) continue;
158
+
159
+ const ruleId = file.replace(".md", "");
160
+ const content = await readFile(join(rulesPath, file), "utf-8");
161
+ const { frontmatter } = parseFrontmatter(content);
162
+
163
+ rules.push({
164
+ id: ruleId,
165
+ title: (frontmatter.title as string) || ruleId,
166
+ impact: (frontmatter.impact as RuleMeta["impact"]) || "MEDIUM",
167
+ impactDescription: (frontmatter.impactDescription as string) || "",
168
+ tags: Array.isArray(frontmatter.tags)
169
+ ? (frontmatter.tags as string[])
170
+ : typeof frontmatter.tags === "string"
171
+ ? frontmatter.tags.split(",").map((s: string) => s.trim())
172
+ : [],
173
+ });
174
+ }
175
+
176
+ // Sort by impact priority
177
+ const impactOrder = { CRITICAL: 0, HIGH: 1, MEDIUM: 2, LOW: 3 };
178
+ return rules.sort((a, b) => impactOrder[a.impact] - impactOrder[b.impact]);
179
+ } catch {
180
+ return [];
181
+ }
182
+ }
183
+
184
+ /**
185
+ * Get a specific rule's content
186
+ */
187
+ export async function getSkillRule(
188
+ skillId: string,
189
+ ruleId: string
190
+ ): Promise<{ meta: RuleMeta; content: string } | null> {
191
+ if (!SKILL_IDS.includes(skillId)) {
192
+ return null;
193
+ }
194
+
195
+ const rulePath = join(__dirname, skillId, "rules", `${ruleId}.md`);
196
+
197
+ try {
198
+ const content = await readFile(rulePath, "utf-8");
199
+ const { frontmatter, body } = parseFrontmatter(content);
200
+
201
+ return {
202
+ meta: {
203
+ id: ruleId,
204
+ title: (frontmatter.title as string) || ruleId,
205
+ impact: (frontmatter.impact as RuleMeta["impact"]) || "MEDIUM",
206
+ impactDescription: (frontmatter.impactDescription as string) || "",
207
+ tags: Array.isArray(frontmatter.tags)
208
+ ? (frontmatter.tags as string[])
209
+ : typeof frontmatter.tags === "string"
210
+ ? frontmatter.tags.split(",").map((s: string) => s.trim())
211
+ : [],
212
+ },
213
+ content: body,
214
+ };
215
+ } catch {
216
+ return null;
217
+ }
218
+ }
@@ -0,0 +1,91 @@
1
+ ---
2
+ name: mandu-composition
3
+ description: |
4
+ React composition patterns for Mandu applications. Use when designing
5
+ Island components, managing shared state, or building reusable component
6
+ APIs. Triggers on compound components, context providers, boolean props,
7
+ or component architecture tasks.
8
+ license: MIT
9
+ metadata:
10
+ author: mandu
11
+ version: "1.0.0"
12
+ ---
13
+
14
+ # Mandu Composition
15
+
16
+ Mandu 애플리케이션을 위한 React 컴포지션 패턴 가이드. Island 컴파운드 컴포넌트, 상태 관리 인터페이스, Provider 패턴, slot-client 분리를 다룹니다. Vercel의 Composition Patterns를 Mandu 컨텍스트로 변환하여 적용합니다.
17
+
18
+ ## When to Apply
19
+
20
+ Reference these guidelines when:
21
+ - Designing Island component architecture
22
+ - Managing shared state between Islands
23
+ - Building reusable component APIs
24
+ - Refactoring components with boolean prop proliferation
25
+ - Working with compound components or context providers
26
+
27
+ ## Rule Categories by Priority
28
+
29
+ | Priority | Category | Impact | Prefix |
30
+ |----------|----------|--------|--------|
31
+ | 1 | Component Architecture | HIGH | `comp-arch-` |
32
+ | 2 | State Management | HIGH | `comp-state-` |
33
+ | 3 | Island Patterns | MEDIUM | `comp-island-` |
34
+ | 4 | Implementation Patterns | MEDIUM | `comp-pattern-` |
35
+
36
+ ## Quick Reference
37
+
38
+ ### 1. Component Architecture (HIGH)
39
+
40
+ - `comp-arch-avoid-boolean-props` - Use composition instead of boolean customization
41
+ - `comp-arch-compound-components` - Structure Islands as compound components
42
+ - `comp-arch-explicit-variants` - Create explicit variant components
43
+
44
+ ### 2. State Management (HIGH)
45
+
46
+ - `comp-state-context-interface` - Define generic state/actions/meta interface
47
+ - `comp-state-lift-state` - Move state into provider for sibling access
48
+ - `comp-state-decouple-impl` - Provider is the only place knowing implementation
49
+
50
+ ### 3. Island Patterns (MEDIUM)
51
+
52
+ - `comp-island-compound` - Compose Islands with shared context
53
+ - `comp-island-event` - Communicate between Islands with useIslandEvent
54
+ - `comp-island-slot-split` - Separate server logic (slot) from client (Island)
55
+
56
+ ### 4. Implementation Patterns (MEDIUM)
57
+
58
+ - `comp-pattern-children` - Use children for composition over render props
59
+ - `comp-pattern-provider-boundary` - Understand provider boundary vs visual nesting
60
+
61
+ ## Core Principle
62
+
63
+ **Lift state, compose internals, make state dependency-injectable.**
64
+
65
+ ```
66
+ ┌─────────────────────────────────────────┐
67
+ │ Provider (state + actions + meta) │
68
+ │ ┌───────────────────────────────────┐ │
69
+ │ │ Composer.Frame │ │
70
+ │ │ ┌─────────┐ ┌─────────────────┐ │ │
71
+ │ │ │ Input │ │ Footer │ │ │
72
+ │ │ └─────────┘ │ ┌─────┐ ┌─────┐ │ │ │
73
+ │ │ │ │Emoji│ │Send │ │ │ │
74
+ │ │ │ └─────┘ └─────┘ │ │ │
75
+ │ │ └─────────────────┘ │ │
76
+ │ └───────────────────────────────────┘ │
77
+ │ ┌───────────────┐ ← Outside Frame │
78
+ │ │ Preview │ but inside │
79
+ │ └───────────────┘ Provider! │
80
+ └─────────────────────────────────────────┘
81
+ ```
82
+
83
+ ## How to Use
84
+
85
+ Read individual rule files for detailed explanations:
86
+
87
+ ```
88
+ rules/comp-arch-compound-components.md
89
+ rules/comp-state-context-interface.md
90
+ rules/comp-island-event.md
91
+ ```
@@ -0,0 +1,13 @@
1
+ {
2
+ "version": "1.0.0",
3
+ "organization": "Mandu Framework",
4
+ "date": "February 2026",
5
+ "abstract": "Mandu 애플리케이션을 위한 React 컴포지션 패턴 가이드. Island 컴파운드 컴포넌트, state/actions/meta 인터페이스, Provider 패턴, useIslandEvent를 통한 Island 간 통신, slot-client 분리 패턴을 다룹니다. Vercel Composition Patterns 기반으로 Mandu 컨텍스트에 맞게 변환되었습니다.",
6
+ "references": [
7
+ "https://react.dev/learn/passing-data-deeply-with-context",
8
+ "https://react.dev/learn/scaling-up-with-reducer-and-context",
9
+ "https://www.patterns.dev/react/compound-pattern",
10
+ "https://kentcdodds.com/blog/compound-components-with-react-hooks"
11
+ ],
12
+ "tags": ["composition", "compound", "context", "state", "island", "mandu"]
13
+ }
@@ -0,0 +1,26 @@
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. Component Architecture (comp-arch)
9
+
10
+ **Impact:** HIGH
11
+ **Description:** Boolean props 대신 컴포지션 사용, 컴파운드 컴포넌트 구조화. 코드베이스가 확장됨에 따라 유지보수성에 큰 영향을 미칩니다.
12
+
13
+ ## 2. State Management (comp-state)
14
+
15
+ **Impact:** HIGH
16
+ **Description:** state/actions/meta 인터페이스 정의, Provider를 통한 의존성 주입. 같은 UI를 다양한 상태 구현과 함께 재사용할 수 있게 합니다.
17
+
18
+ ## 3. Island Patterns (comp-island)
19
+
20
+ **Impact:** MEDIUM
21
+ **Description:** Mandu Island 특화 패턴. 컴파운드 Island, Island 간 이벤트 통신, slot-client 분리를 다룹니다.
22
+
23
+ ## 4. Implementation Patterns (comp-pattern)
24
+
25
+ **Impact:** MEDIUM
26
+ **Description:** children 활용, Provider 경계 이해 등 구현 세부 사항. 올바른 패턴 적용으로 유연성을 확보합니다.
@@ -0,0 +1,77 @@
1
+ # Rule Template
2
+
3
+ Use this template when creating new rules for mandu-composition.
4
+
5
+ ---
6
+
7
+ ```markdown
8
+ ---
9
+ title: Rule Title Here
10
+ impact: HIGH | MEDIUM | LOW
11
+ impactDescription: 영향 설명 (예: "enables flexible composition")
12
+ tags: composition, tag1, tag2
13
+ ---
14
+
15
+ ## Rule Title Here
16
+
17
+ **Impact: {LEVEL} ({impactDescription})**
18
+
19
+ 규칙의 목적과 아키텍처적 영향을 설명합니다.
20
+
21
+ **Incorrect (문제가 되는 패턴):**
22
+
23
+ \`\`\`tsx
24
+ // ❌ Boolean props로 기능 추가
25
+ function Composer({
26
+ showAttachments,
27
+ showFormatting,
28
+ showEmojis,
29
+ isCompact,
30
+ isReadOnly,
31
+ }: Props) {
32
+ return (
33
+ <form>
34
+ {!isReadOnly && <Input />}
35
+ {showAttachments && <Attachments />}
36
+ {showFormatting && <Formatting />}
37
+ {showEmojis && <Emojis />}
38
+ </form>
39
+ );
40
+ }
41
+ ```
42
+
43
+ **Correct (컴포지션 패턴):**
44
+
45
+ \`\`\`tsx
46
+ // ✅ 컴포지션으로 유연하게 구성
47
+ <Composer.Provider state={state} actions={actions}>
48
+ <Composer.Frame>
49
+ <Composer.Input />
50
+ <Composer.Footer>
51
+ <Composer.Emojis />
52
+ <Composer.Submit />
53
+ </Composer.Footer>
54
+ </Composer.Frame>
55
+ </Composer.Provider>
56
+ \`\`\`
57
+
58
+ ## Mandu Context
59
+
60
+ Mandu Island에서 이 패턴을 적용하는 방법을 설명합니다.
61
+
62
+ Reference: [관련 문서 링크](https://example.com)
63
+ ```
64
+
65
+ ---
66
+
67
+ ## Naming Convention
68
+
69
+ - 파일명: `comp-{category}-{rule-name}.md`
70
+ - 예시: `comp-arch-compound-components.md`, `comp-state-context-interface.md`
71
+
72
+ ## Core Principle
73
+
74
+ **Lift state, compose internals, make state dependency-injectable.**
75
+
76
+ UI는 조합 가능한 조각들이고, 상태는 Provider가 주입합니다.
77
+ Provider를 바꾸면 UI는 그대로 유지됩니다.
@@ -0,0 +1,146 @@
1
+ ---
2
+ title: Use Composition Instead of Boolean Props
3
+ impact: HIGH
4
+ impactDescription: Prevents prop explosion and improves flexibility
5
+ tags: composition, boolean, props, architecture
6
+ ---
7
+
8
+ ## Use Composition Instead of Boolean Props
9
+
10
+ **Impact: HIGH (Prevents prop explosion and improves flexibility)**
11
+
12
+ 동작을 커스터마이즈하기 위해 boolean props를 추가하지 마세요. 대신 컴포지션을 사용하세요.
13
+
14
+ **Incorrect (boolean props 폭발):**
15
+
16
+ ```tsx
17
+ // ❌ Boolean props가 계속 늘어남
18
+ function Card({
19
+ title,
20
+ children,
21
+ showHeader,
22
+ showFooter,
23
+ showActions,
24
+ isCompact,
25
+ isHighlighted,
26
+ isBordered,
27
+ isClickable,
28
+ isLoading,
29
+ }: CardProps) {
30
+ return (
31
+ <div className={cn(
32
+ "card",
33
+ isCompact && "card--compact",
34
+ isHighlighted && "card--highlighted",
35
+ isBordered && "card--bordered",
36
+ isClickable && "card--clickable",
37
+ )}>
38
+ {isLoading && <Spinner />}
39
+ {showHeader && <Header>{title}</Header>}
40
+ {children}
41
+ {showFooter && <Footer />}
42
+ {showActions && <Actions />}
43
+ </div>
44
+ );
45
+ }
46
+
47
+ // 사용 시 복잡한 props 조합
48
+ <Card
49
+ title="Settings"
50
+ showHeader
51
+ showFooter
52
+ showActions
53
+ isCompact
54
+ isBordered
55
+ isClickable={false}
56
+ isLoading={loading}
57
+ >
58
+ {content}
59
+ </Card>
60
+ ```
61
+
62
+ **Correct (컴포지션 패턴):**
63
+
64
+ ```tsx
65
+ // ✅ 기본 Card와 조합 가능한 서브컴포넌트
66
+ function Card({ children, className }: CardProps) {
67
+ return <div className={cn("card", className)}>{children}</div>;
68
+ }
69
+
70
+ function CardHeader({ children }: { children: React.ReactNode }) {
71
+ return <div className="card-header">{children}</div>;
72
+ }
73
+
74
+ function CardFooter({ children }: { children: React.ReactNode }) {
75
+ return <div className="card-footer">{children}</div>;
76
+ }
77
+
78
+ function CardActions({ children }: { children: React.ReactNode }) {
79
+ return <div className="card-actions">{children}</div>;
80
+ }
81
+
82
+ // Variants는 명시적 컴포넌트로
83
+ function CompactCard({ children }: CardProps) {
84
+ return <Card className="card--compact">{children}</Card>;
85
+ }
86
+
87
+ function HighlightedCard({ children }: CardProps) {
88
+ return <Card className="card--highlighted">{children}</Card>;
89
+ }
90
+
91
+ // Export
92
+ export { Card, CardHeader, CardFooter, CardActions, CompactCard, HighlightedCard };
93
+ ```
94
+
95
+ **사용법:**
96
+
97
+ ```tsx
98
+ // 필요한 것만 명시적으로 조합
99
+ <Card>
100
+ <CardHeader>Settings</CardHeader>
101
+ <SettingsContent />
102
+ <CardFooter>
103
+ <CardActions>
104
+ <SaveButton />
105
+ <CancelButton />
106
+ </CardActions>
107
+ </CardFooter>
108
+ </Card>
109
+
110
+ // Compact variant
111
+ <CompactCard>
112
+ <QuickStats />
113
+ </CompactCard>
114
+ ```
115
+
116
+ ## Mandu Island에서의 적용
117
+
118
+ ```tsx
119
+ // app/dashboard/client.tsx
120
+ "use client";
121
+
122
+ // ❌ 피해야 할 패턴
123
+ export function DashboardIsland({
124
+ showCharts,
125
+ showStats,
126
+ showAlerts,
127
+ isCompact,
128
+ }: Props) { ... }
129
+
130
+ // ✅ 권장 패턴
131
+ export const Dashboard = {
132
+ Provider: DashboardProvider,
133
+ Charts: DashboardCharts,
134
+ Stats: DashboardStats,
135
+ Alerts: DashboardAlerts,
136
+ CompactLayout: DashboardCompactLayout,
137
+ };
138
+ ```
139
+
140
+ ## 언제 Boolean Props가 괜찮은가?
141
+
142
+ - 단일 시각적 상태 (disabled, loading)
143
+ - 토글 가능한 단일 기능 (checked, open)
144
+ - 컴포지션이 과도한 경우의 간단한 변형
145
+
146
+ Reference: [Avoid Boolean Props](https://spicefactory.co/blog/2019/03/26/how-to-avoid-the-boolean-trap-when-designing-react-components/)