@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,148 @@
1
+ ---
2
+ title: Define Generic Context Interface for Dependency Injection
3
+ impact: HIGH
4
+ impactDescription: Enables dependency-injectable state across use-cases
5
+ tags: composition, context, state, typescript, dependency-injection
6
+ ---
7
+
8
+ ## Define Generic Context Interface for Dependency Injection
9
+
10
+ **Impact: HIGH (Enables dependency-injectable state across use-cases)**
11
+
12
+ 컴포넌트 context를 위한 제네릭 인터페이스를 `state`, `actions`, `meta` 세 부분으로 정의하세요. 어떤 Provider든 이 인터페이스를 구현할 수 있어, 같은 UI 컴포넌트가 완전히 다른 상태 구현과 작동할 수 있습니다.
13
+
14
+ **핵심 원칙:** Lift state, compose internals, make state dependency-injectable.
15
+
16
+ **Incorrect (특정 상태 구현에 결합):**
17
+
18
+ ```tsx
19
+ // ❌ 특정 훅에 강하게 결합
20
+ function ComposerInput() {
21
+ const { input, setInput } = useChannelComposerState();
22
+ return <TextInput value={input} onChangeText={setInput} />;
23
+ }
24
+ ```
25
+
26
+ **Correct (제네릭 인터페이스로 의존성 주입):**
27
+
28
+ ```tsx
29
+ // ✅ 어떤 Provider든 구현할 수 있는 제네릭 인터페이스
30
+ interface ComposerState {
31
+ input: string;
32
+ attachments: Attachment[];
33
+ isSubmitting: boolean;
34
+ }
35
+
36
+ interface ComposerActions {
37
+ update: (updater: (state: ComposerState) => ComposerState) => void;
38
+ submit: () => void;
39
+ addAttachment: (file: File) => void;
40
+ }
41
+
42
+ interface ComposerMeta {
43
+ inputRef: React.RefObject<HTMLTextAreaElement>;
44
+ maxLength?: number;
45
+ }
46
+
47
+ interface ComposerContextValue {
48
+ state: ComposerState;
49
+ actions: ComposerActions;
50
+ meta: ComposerMeta;
51
+ }
52
+
53
+ const ComposerContext = createContext<ComposerContextValue | null>(null);
54
+ ```
55
+
56
+ **UI 컴포넌트는 인터페이스만 소비:**
57
+
58
+ ```tsx
59
+ function ComposerInput() {
60
+ const {
61
+ state,
62
+ actions: { update },
63
+ meta,
64
+ } = use(ComposerContext)!;
65
+
66
+ // 이 컴포넌트는 인터페이스를 구현한 어떤 Provider와도 작동
67
+ return (
68
+ <textarea
69
+ ref={meta.inputRef}
70
+ value={state.input}
71
+ maxLength={meta.maxLength}
72
+ onChange={(e) => update((s) => ({ ...s, input: e.target.value }))}
73
+ />
74
+ );
75
+ }
76
+ ```
77
+
78
+ **서로 다른 Provider가 같은 인터페이스 구현:**
79
+
80
+ ```tsx
81
+ // Provider A: 임시 폼을 위한 로컬 상태
82
+ function ForwardMessageProvider({ children }: { children: React.ReactNode }) {
83
+ const [state, setState] = useState(initialState);
84
+ const inputRef = useRef<HTMLTextAreaElement>(null);
85
+ const submit = useForwardMessage();
86
+
87
+ return (
88
+ <ComposerContext value={{
89
+ state,
90
+ actions: { update: setState, submit, addAttachment: ... },
91
+ meta: { inputRef },
92
+ }}>
93
+ {children}
94
+ </ComposerContext>
95
+ );
96
+ }
97
+
98
+ // Provider B: 채널을 위한 전역 동기화 상태
99
+ function ChannelProvider({ channelId, children }: Props) {
100
+ const { state, update, submit } = useGlobalChannel(channelId);
101
+ const inputRef = useRef<HTMLTextAreaElement>(null);
102
+
103
+ return (
104
+ <ComposerContext value={{
105
+ state,
106
+ actions: { update, submit, addAttachment: ... },
107
+ meta: { inputRef, maxLength: 2000 },
108
+ }}>
109
+ {children}
110
+ </ComposerContext>
111
+ );
112
+ }
113
+ ```
114
+
115
+ **같은 UI가 두 Provider와 모두 작동:**
116
+
117
+ ```tsx
118
+ // ForwardMessageProvider와 작동 (로컬 상태)
119
+ <ForwardMessageProvider>
120
+ <Composer.Frame>
121
+ <Composer.Input />
122
+ <Composer.Submit />
123
+ </Composer.Frame>
124
+ </ForwardMessageProvider>
125
+
126
+ // ChannelProvider와 작동 (전역 동기화 상태)
127
+ <ChannelProvider channelId="abc">
128
+ <Composer.Frame>
129
+ <Composer.Input />
130
+ <Composer.Submit />
131
+ </Composer.Frame>
132
+ </ChannelProvider>
133
+ ```
134
+
135
+ ## Mandu Island에서의 활용
136
+
137
+ ```tsx
138
+ // Island 컴포넌트는 인터페이스만 알면 됨
139
+ // slot에서 어떤 Provider를 사용하든 같은 Island 재사용 가능
140
+
141
+ // spec/slots/forward.slot.ts → ForwardMessageProvider 사용
142
+ // spec/slots/channel.slot.ts → ChannelProvider 사용
143
+ // 둘 다 같은 Composer Island 컴포넌트 사용
144
+ ```
145
+
146
+ UI는 재사용 가능한 조각들이고, 상태는 Provider가 주입합니다. Provider를 바꾸면 UI는 그대로!
147
+
148
+ Reference: [Context Interface Pattern](https://kentcdodds.com/blog/how-to-use-react-context-effectively)
@@ -0,0 +1,150 @@
1
+ ---
2
+ title: Lift State into Provider for Sibling Access
3
+ impact: HIGH
4
+ impactDescription: Enables state sharing without prop drilling
5
+ tags: composition, state, provider, lift-state
6
+ ---
7
+
8
+ ## Lift State into Provider for Sibling Access
9
+
10
+ **Impact: HIGH (Enables state sharing without prop drilling)**
11
+
12
+ 형제 컴포넌트가 상태를 공유해야 할 때, 상태를 Provider로 끌어올리세요. Provider 경계 내의 모든 컴포넌트가 상태에 접근할 수 있습니다.
13
+
14
+ **Incorrect (prop drilling):**
15
+
16
+ ```tsx
17
+ // ❌ 상태를 여러 단계로 전달
18
+ function ChatPage() {
19
+ const [message, setMessage] = useState("");
20
+ const [isTyping, setIsTyping] = useState(false);
21
+
22
+ return (
23
+ <div>
24
+ <MessageList
25
+ isTyping={isTyping}
26
+ typingMessage={message} // prop drilling
27
+ />
28
+ <Composer
29
+ message={message}
30
+ setMessage={setMessage}
31
+ setIsTyping={setIsTyping}
32
+ />
33
+ <TypingIndicator isTyping={isTyping} /> // prop drilling
34
+ </div>
35
+ );
36
+ }
37
+ ```
38
+
39
+ **Correct (Provider로 끌어올리기):**
40
+
41
+ ```tsx
42
+ // ✅ Provider가 상태 관리
43
+ interface ChatContextValue {
44
+ state: { message: string; isTyping: boolean };
45
+ actions: { setMessage: (msg: string) => void; setIsTyping: (val: boolean) => void };
46
+ }
47
+
48
+ const ChatContext = createContext<ChatContextValue | null>(null);
49
+
50
+ function ChatProvider({ children }: { children: React.ReactNode }) {
51
+ const [message, setMessage] = useState("");
52
+ const [isTyping, setIsTyping] = useState(false);
53
+
54
+ return (
55
+ <ChatContext value={{
56
+ state: { message, isTyping },
57
+ actions: { setMessage, setIsTyping },
58
+ }}>
59
+ {children}
60
+ </ChatContext>
61
+ );
62
+ }
63
+
64
+ // 각 컴포넌트가 필요한 것만 가져감
65
+ function MessageList() {
66
+ const { state } = use(ChatContext)!;
67
+ return (
68
+ <div>
69
+ {messages.map(msg => <Message key={msg.id} {...msg} />)}
70
+ {state.isTyping && <TypingPreview text={state.message} />}
71
+ </div>
72
+ );
73
+ }
74
+
75
+ function Composer() {
76
+ const { state, actions } = use(ChatContext)!;
77
+ return (
78
+ <textarea
79
+ value={state.message}
80
+ onChange={(e) => {
81
+ actions.setMessage(e.target.value);
82
+ actions.setIsTyping(e.target.value.length > 0);
83
+ }}
84
+ />
85
+ );
86
+ }
87
+
88
+ function TypingIndicator() {
89
+ const { state } = use(ChatContext)!;
90
+ if (!state.isTyping) return null;
91
+ return <span>Someone is typing...</span>;
92
+ }
93
+ ```
94
+
95
+ **사용:**
96
+
97
+ ```tsx
98
+ function ChatPage() {
99
+ return (
100
+ <ChatProvider>
101
+ <div>
102
+ <MessageList /> {/* context에서 상태 읽음 */}
103
+ <Composer /> {/* context에서 상태 수정 */}
104
+ <TypingIndicator /> {/* context에서 상태 읽음 */}
105
+ </div>
106
+ </ChatProvider>
107
+ );
108
+ }
109
+ ```
110
+
111
+ ## Provider 경계 이해하기
112
+
113
+ Provider 경계 내라면 시각적 위치와 무관하게 상태 접근 가능:
114
+
115
+ ```tsx
116
+ <ChatProvider>
117
+ <Dialog>
118
+ {/* Dialog 내부 */}
119
+ <Composer.Frame>
120
+ <Composer.Input />
121
+ </Composer.Frame>
122
+
123
+ {/* Frame 외부지만 Provider 내부! */}
124
+ <MessagePreview /> {/* ✅ context 접근 가능 */}
125
+
126
+ <DialogActions>
127
+ <SendButton /> {/* ✅ context 접근 가능 */}
128
+ </DialogActions>
129
+ </Dialog>
130
+ </ChatProvider>
131
+ ```
132
+
133
+ ## Mandu Island에서의 적용
134
+
135
+ ```tsx
136
+ // app/chat/page.tsx
137
+ import { ChatIsland } from "./client";
138
+
139
+ export default function ChatPage({ data }) {
140
+ return (
141
+ <div>
142
+ <h1>Chat</h1>
143
+ {/* Island 내부에서 Provider로 상태 관리 */}
144
+ <ChatIsland initialMessages={data.messages} />
145
+ </div>
146
+ );
147
+ }
148
+ ```
149
+
150
+ Reference: [Lifting State Up](https://react.dev/learn/sharing-state-between-components)
@@ -0,0 +1,92 @@
1
+ ---
2
+ name: Mandu Deployment
3
+ description: Production deployment patterns for Mandu applications
4
+ metadata:
5
+ version: "1.0.0"
6
+ author: mandu
7
+ globs:
8
+ - "render.yaml"
9
+ - "Dockerfile"
10
+ - "docker-compose.yml"
11
+ - ".github/workflows/*.yml"
12
+ - "bunfig.toml"
13
+ ---
14
+
15
+ # Mandu Deployment Skill
16
+
17
+ Mandu 앱을 프로덕션 환경에 안전하고 효율적으로 배포하기 위한 가이드입니다.
18
+
19
+ ## 핵심 원칙
20
+
21
+ 1. **Bun 네이티브**: Bun 런타임과 번들러를 최대한 활용
22
+ 2. **환경 분리**: 개발/스테이징/프로덕션 환경 명확히 구분
23
+ 3. **자동화**: CI/CD를 통한 일관된 배포 프로세스
24
+ 4. **보안 우선**: 민감 정보는 환경 변수로 관리
25
+
26
+ ## 빠른 시작
27
+
28
+ ### Render 배포 (권장)
29
+
30
+ ```yaml
31
+ # render.yaml
32
+ services:
33
+ - type: web
34
+ name: mandu-app
35
+ runtime: node
36
+ buildCommand: bun install && bun run build
37
+ startCommand: bun run start
38
+ envVars:
39
+ - key: NODE_ENV
40
+ value: production
41
+ - key: BUN_ENV
42
+ value: production
43
+ ```
44
+
45
+ ### Docker 배포
46
+
47
+ ```dockerfile
48
+ FROM oven/bun:1.0
49
+
50
+ WORKDIR /app
51
+ COPY package.json bun.lockb ./
52
+ RUN bun install --frozen-lockfile --production
53
+
54
+ COPY . .
55
+ RUN bun run build
56
+
57
+ EXPOSE 3000
58
+ CMD ["bun", "run", "start"]
59
+ ```
60
+
61
+ ## 배포 체크리스트
62
+
63
+ ### 빌드 준비
64
+ - [ ] `bun run build` 성공 확인
65
+ - [ ] 번들 크기 최적화 (tree-shaking, code-splitting)
66
+ - [ ] 환경 변수 설정 완료
67
+
68
+ ### 플랫폼 설정
69
+ - [ ] Render/Docker 설정 파일 작성
70
+ - [ ] 헬스체크 엔드포인트 구현
71
+ - [ ] 로깅 설정 완료
72
+
73
+ ### 보안
74
+ - [ ] 민감 정보 환경 변수로 분리
75
+ - [ ] HTTPS 강제 적용
76
+ - [ ] 보안 헤더 설정
77
+
78
+ ### 모니터링
79
+ - [ ] 에러 트래킹 설정
80
+ - [ ] 성능 모니터링 구성
81
+ - [ ] 알림 설정
82
+
83
+ ## 규칙 카테고리
84
+
85
+ | Category | Description | Rules |
86
+ |----------|-------------|-------|
87
+ | Build | 프로덕션 빌드 최적화 | 2 |
88
+ | Platform | 플랫폼별 배포 설정 | 3 |
89
+ | Container | Docker 컨테이너화 | 2 |
90
+ | CI/CD | 자동화 파이프라인 | 1 |
91
+
92
+ → 세부 규칙은 `rules/` 폴더 참조
@@ -0,0 +1,41 @@
1
+ # Mandu Deployment - Rule Categories
2
+
3
+ ## Build
4
+ 프로덕션 빌드 최적화 및 번들링 설정
5
+
6
+ | Impact | Description |
7
+ |--------|-------------|
8
+ | CRITICAL | 빌드 실패 시 배포 불가 |
9
+ | HIGH | 번들 크기, 빌드 시간에 큰 영향 |
10
+
11
+ ## Platform
12
+ 배포 플랫폼별 설정 및 최적화
13
+
14
+ | Impact | Description |
15
+ |--------|-------------|
16
+ | CRITICAL | 플랫폼 호환성 필수 |
17
+ | HIGH | 성능, 비용에 큰 영향 |
18
+
19
+ ## Container
20
+ Docker 컨테이너화 및 오케스트레이션
21
+
22
+ | Impact | Description |
23
+ |--------|-------------|
24
+ | HIGH | 일관된 배포 환경 보장 |
25
+ | MEDIUM | 개발/프로덕션 환경 일치 |
26
+
27
+ ## CI/CD
28
+ 지속적 통합 및 배포 파이프라인
29
+
30
+ | Impact | Description |
31
+ |--------|-------------|
32
+ | HIGH | 자동화된 품질 보증 |
33
+ | MEDIUM | 배포 속도 및 안정성 향상 |
34
+
35
+ ## Environment
36
+ 환경 변수 및 설정 관리
37
+
38
+ | Impact | Description |
39
+ |--------|-------------|
40
+ | CRITICAL | 보안 민감 정보 보호 |
41
+ | HIGH | 환경별 설정 분리 |
@@ -0,0 +1,38 @@
1
+ ---
2
+ title: Rule Title Here
3
+ impact: CRITICAL | HIGH | MEDIUM | LOW
4
+ impactDescription: One-line description of why this matters
5
+ tags: deployment, tag2, tag3
6
+ ---
7
+
8
+ ## Rule Title Here
9
+
10
+ **Impact: LEVEL (Impact description)**
11
+
12
+ 규칙에 대한 간단한 설명.
13
+
14
+ **설정 예시:**
15
+
16
+ ```yaml
17
+ # 설정 파일 예시
18
+ key: value
19
+ ```
20
+
21
+ **구현 예시:**
22
+
23
+ ```typescript
24
+ // 코드 예시
25
+ ```
26
+
27
+ ## 추가 설정
28
+
29
+ ```bash
30
+ # 명령어 예시
31
+ ```
32
+
33
+ ## 주의사항
34
+
35
+ - 첫 번째 주의사항
36
+ - 두 번째 주의사항
37
+
38
+ Reference: [문서 링크](https://example.com)
@@ -0,0 +1,13 @@
1
+ {
2
+ "id": "mandu-deployment",
3
+ "name": "Mandu Deployment",
4
+ "version": "1.0.0",
5
+ "description": "Production deployment patterns for Mandu applications",
6
+ "author": "mandu",
7
+ "references": [
8
+ "https://bun.sh/docs/bundler",
9
+ "https://render.com/docs",
10
+ "https://docs.docker.com/"
11
+ ],
12
+ "abstract": "Mandu 앱을 프로덕션 환경에 배포하기 위한 패턴과 가이드. Bun 빌드 최적화, Render/Docker 배포, CI/CD 파이프라인, 환경 설정을 다룹니다."
13
+ }
@@ -0,0 +1,109 @@
1
+ ---
2
+ title: Bun Production Build
3
+ impact: CRITICAL
4
+ impactDescription: Build failure blocks deployment
5
+ tags: deployment, build, bun, bundler
6
+ ---
7
+
8
+ ## Bun Production Build
9
+
10
+ **Impact: CRITICAL (Build failure blocks deployment)**
11
+
12
+ Bun 번들러를 사용하여 프로덕션 최적화된 빌드를 생성하세요.
13
+
14
+ **bunfig.toml 설정:**
15
+
16
+ ```toml
17
+ [build]
18
+ target = "bun"
19
+ minify = true
20
+ sourcemap = "external"
21
+
22
+ [build.define]
23
+ "process.env.NODE_ENV" = "'production'"
24
+ ```
25
+
26
+ **빌드 스크립트:**
27
+
28
+ ```typescript
29
+ // scripts/build.ts
30
+ import { $ } from "bun";
31
+
32
+ // 클린 빌드
33
+ await $`rm -rf dist`;
34
+
35
+ // 서버 빌드
36
+ await Bun.build({
37
+ entrypoints: ["./src/server.ts"],
38
+ outdir: "./dist",
39
+ target: "bun",
40
+ minify: true,
41
+ sourcemap: "external",
42
+ define: {
43
+ "process.env.NODE_ENV": JSON.stringify("production"),
44
+ },
45
+ });
46
+
47
+ // 클라이언트 빌드 (Islands)
48
+ await Bun.build({
49
+ entrypoints: ["./app/**/client.tsx"],
50
+ outdir: "./dist/public",
51
+ target: "browser",
52
+ minify: true,
53
+ splitting: true,
54
+ sourcemap: "external",
55
+ });
56
+
57
+ console.log("✅ Build complete");
58
+ ```
59
+
60
+ ## package.json 스크립트
61
+
62
+ ```json
63
+ {
64
+ "scripts": {
65
+ "build": "bun run scripts/build.ts",
66
+ "start": "NODE_ENV=production bun run dist/server.js",
67
+ "preview": "bun run build && bun run start"
68
+ }
69
+ }
70
+ ```
71
+
72
+ ## 빌드 최적화 옵션
73
+
74
+ ```typescript
75
+ await Bun.build({
76
+ entrypoints: ["./src/index.ts"],
77
+ outdir: "./dist",
78
+
79
+ // 필수 최적화
80
+ minify: true, // 코드 압축
81
+ splitting: true, // 코드 분할
82
+
83
+ // 선택적 최적화
84
+ treeshaking: true, // 미사용 코드 제거 (기본값)
85
+
86
+ // 외부 패키지 처리
87
+ external: ["better-sqlite3"], // 네이티브 모듈 제외
88
+
89
+ // 환경 변수 주입
90
+ define: {
91
+ "process.env.API_URL": JSON.stringify(process.env.API_URL),
92
+ },
93
+ });
94
+ ```
95
+
96
+ ## 빌드 검증
97
+
98
+ ```bash
99
+ # 빌드 크기 확인
100
+ du -sh dist/
101
+
102
+ # 번들 분석
103
+ bun build --analyze ./src/server.ts
104
+
105
+ # 빌드 테스트
106
+ bun run dist/server.js
107
+ ```
108
+
109
+ Reference: [Bun Bundler](https://bun.sh/docs/bundler)
@@ -0,0 +1,115 @@
1
+ ---
2
+ title: Build Output Configuration
3
+ impact: HIGH
4
+ impactDescription: Affects bundle size and load performance
5
+ tags: deployment, build, output, optimization
6
+ ---
7
+
8
+ ## Build Output Configuration
9
+
10
+ **Impact: HIGH (Affects bundle size and load performance)**
11
+
12
+ 빌드 출력을 최적화하여 번들 크기를 줄이고 로딩 성능을 개선하세요.
13
+
14
+ **디렉토리 구조:**
15
+
16
+ ```
17
+ dist/
18
+ ├── server.js # 서버 엔트리포인트
19
+ ├── public/
20
+ │ ├── islands/ # Island 컴포넌트 청크
21
+ │ │ ├── counter-abc123.js
22
+ │ │ └── form-def456.js
23
+ │ ├── shared/ # 공유 청크
24
+ │ │ └── react-vendor-xyz789.js
25
+ │ └── assets/ # 정적 자산
26
+ │ ├── styles.css
27
+ │ └── images/
28
+ └── server.js.map # 소스맵 (프로덕션 디버깅용)
29
+ ```
30
+
31
+ **청크 분할 설정:**
32
+
33
+ ```typescript
34
+ // scripts/build.ts
35
+ await Bun.build({
36
+ entrypoints: ["./app/**/client.tsx"],
37
+ outdir: "./dist/public/islands",
38
+ target: "browser",
39
+ splitting: true, // 공유 코드 자동 분리
40
+ minify: true,
41
+ naming: {
42
+ chunk: "[name]-[hash].js",
43
+ entry: "[name]-[hash].js",
44
+ asset: "[name]-[hash][ext]",
45
+ },
46
+ });
47
+ ```
48
+
49
+ ## 정적 자산 처리
50
+
51
+ ```typescript
52
+ // 정적 파일 복사
53
+ import { $ } from "bun";
54
+
55
+ // public 폴더 복사
56
+ await $`cp -r public/* dist/public/`;
57
+
58
+ // CSS 최적화 (optional)
59
+ await $`bunx lightningcss --minify public/styles.css -o dist/public/styles.css`;
60
+ ```
61
+
62
+ ## Gzip/Brotli 압축
63
+
64
+ ```typescript
65
+ // 프로덕션 서버에서 압축
66
+ import { gzipSync } from "bun";
67
+
68
+ // 또는 빌드 시 사전 압축
69
+ import { $ } from "bun";
70
+
71
+ const files = await Array.fromAsync(
72
+ new Bun.Glob("dist/public/**/*.{js,css}").scan()
73
+ );
74
+
75
+ for (const file of files) {
76
+ const content = await Bun.file(file).arrayBuffer();
77
+ await Bun.write(`${file}.gz`, gzipSync(new Uint8Array(content)));
78
+ }
79
+ ```
80
+
81
+ ## 빌드 매니페스트
82
+
83
+ ```typescript
84
+ // 빌드 후 매니페스트 생성
85
+ const manifest = {
86
+ version: process.env.BUILD_VERSION || Date.now().toString(),
87
+ files: {},
88
+ };
89
+
90
+ const files = await Array.fromAsync(
91
+ new Bun.Glob("dist/public/**/*").scan()
92
+ );
93
+
94
+ for (const file of files) {
95
+ const hash = Bun.hash(await Bun.file(file).arrayBuffer());
96
+ manifest.files[file] = hash.toString(16);
97
+ }
98
+
99
+ await Bun.write("dist/manifest.json", JSON.stringify(manifest, null, 2));
100
+ ```
101
+
102
+ ## 번들 크기 모니터링
103
+
104
+ ```bash
105
+ # 번들 크기 리포트
106
+ bun run scripts/bundle-size.ts
107
+
108
+ # CI에서 크기 제한 체크
109
+ if [ $(du -sb dist/public | cut -f1) -gt 1048576 ]; then
110
+ echo "Bundle size exceeds 1MB limit"
111
+ exit 1
112
+ fi
113
+ ```
114
+
115
+ Reference: [Bun Build Naming](https://bun.sh/docs/bundler#naming)