@mandujs/mcp 0.38.12 → 0.39.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. package/README.md +3 -3
  2. package/package.json +3 -5
  3. package/src/activity-adapter.ts +23 -23
  4. package/src/activity-monitor.ts +39 -10
  5. package/src/adapters/index.ts +20 -20
  6. package/src/adapters/monitor-adapter.ts +100 -100
  7. package/src/adapters/tool-adapter.ts +90 -90
  8. package/src/executor/index.ts +22 -22
  9. package/src/executor/tool-executor.ts +148 -148
  10. package/src/hooks/config-watcher.ts +173 -173
  11. package/src/hooks/index.ts +23 -23
  12. package/src/hooks/mcp-hooks.ts +227 -227
  13. package/src/index.ts +5 -5
  14. package/src/logging/index.ts +15 -15
  15. package/src/logging/mcp-transport.ts +134 -134
  16. package/src/new-resources.ts +2 -2
  17. package/src/profiles.ts +25 -54
  18. package/src/prompts.ts +4 -4
  19. package/src/registry/index.ts +13 -13
  20. package/src/registry/mcp-tool-registry.ts +298 -298
  21. package/src/resources/generated-skills/catalog.ts +36 -0
  22. package/src/resources/generated-skills/mandu-agent-workflow/SKILL.md +48 -0
  23. package/src/resources/generated-skills/mandu-contract/SKILL.md +20 -0
  24. package/src/resources/generated-skills/mandu-fs-routes/SKILL.md +19 -0
  25. package/src/resources/generated-skills/mandu-guard/SKILL.md +20 -0
  26. package/src/resources/generated-skills/mandu-hydration/SKILL.md +19 -0
  27. package/src/resources/generated-skills/mandu-testing/SKILL.md +20 -0
  28. package/src/resources/handlers.ts +3 -3
  29. package/src/resources/skills/guides.ts +49 -49
  30. package/src/resources/skills/index.ts +12 -12
  31. package/src/resources/skills/loader.ts +8 -35
  32. package/src/resources/skills/recipes.ts +28 -28
  33. package/src/server.ts +1 -1
  34. package/src/tools/agent.ts +479 -409
  35. package/src/tools/ate-exemplar.ts +92 -92
  36. package/src/tools/ate-flakes.ts +90 -90
  37. package/src/tools/ate-mutate.ts +103 -103
  38. package/src/tools/ate-mutation-report.ts +64 -64
  39. package/src/tools/ate-oracle-pending.ts +49 -49
  40. package/src/tools/ate-oracle-replay.ts +44 -44
  41. package/src/tools/ate-oracle-verdict.ts +70 -70
  42. package/src/tools/ate-prompt.ts +146 -146
  43. package/src/tools/ate-run.ts +1 -1
  44. package/src/tools/ate.ts +38 -38
  45. package/src/tools/brain.ts +6 -6
  46. package/src/tools/composite.ts +19 -61
  47. package/src/tools/contract.ts +11 -9
  48. package/src/tools/deploy-plan.ts +2 -2
  49. package/src/tools/deploy-preview.ts +316 -316
  50. package/src/tools/design.ts +825 -825
  51. package/src/tools/docs.ts +350 -350
  52. package/src/tools/generate.ts +4 -3
  53. package/src/tools/guard.ts +1 -1
  54. package/src/tools/history.ts +1 -1
  55. package/src/tools/hydration.ts +64 -64
  56. package/src/tools/index.ts +0 -118
  57. package/src/tools/kitchen.ts +72 -72
  58. package/src/tools/lint.ts +226 -226
  59. package/src/tools/loop-close.ts +175 -175
  60. package/src/tools/negotiate.ts +263 -263
  61. package/src/tools/resource.ts +1 -1
  62. package/src/tools/run-tests.ts +424 -424
  63. package/src/tools/runtime.ts +1 -1
  64. package/src/tools/seo.ts +1 -1
  65. package/src/tools/slot-validation.ts +19 -19
  66. package/src/tools/spec.ts +201 -201
  67. package/src/tools/transaction.ts +1 -1
  68. package/src/tx-lock.ts +73 -73
  69. package/src/utils/runtime-control.ts +52 -52
  70. package/src/utils/withWarnings.ts +1 -1
  71. package/src/resources/skills/mandu-agent-workflow/SKILL.md +0 -124
  72. package/src/resources/skills/mandu-agent-workflow/metadata.json +0 -7
  73. package/src/resources/skills/mandu-composition/SKILL.md +0 -131
  74. package/src/resources/skills/mandu-composition/metadata.json +0 -13
  75. package/src/resources/skills/mandu-composition/rules/_sections.md +0 -26
  76. package/src/resources/skills/mandu-composition/rules/_template.md +0 -77
  77. package/src/resources/skills/mandu-composition/rules/comp-arch-avoid-boolean-props.md +0 -146
  78. package/src/resources/skills/mandu-composition/rules/comp-arch-compound-components.md +0 -164
  79. package/src/resources/skills/mandu-composition/rules/comp-island-event.md +0 -161
  80. package/src/resources/skills/mandu-composition/rules/comp-island-slot-split.md +0 -167
  81. package/src/resources/skills/mandu-composition/rules/comp-pattern-children.md +0 -149
  82. package/src/resources/skills/mandu-composition/rules/comp-state-context-interface.md +0 -148
  83. package/src/resources/skills/mandu-composition/rules/comp-state-lift-state.md +0 -150
  84. package/src/resources/skills/mandu-deployment/SKILL.md +0 -135
  85. package/src/resources/skills/mandu-deployment/_sections.md +0 -41
  86. package/src/resources/skills/mandu-deployment/_template.md +0 -38
  87. package/src/resources/skills/mandu-deployment/metadata.json +0 -13
  88. package/src/resources/skills/mandu-deployment/rules/db-provider-supabase.md +0 -300
  89. package/src/resources/skills/mandu-deployment/rules/deploy-build-bun.md +0 -109
  90. package/src/resources/skills/mandu-deployment/rules/deploy-build-output.md +0 -115
  91. package/src/resources/skills/mandu-deployment/rules/deploy-cicd-github.md +0 -219
  92. package/src/resources/skills/mandu-deployment/rules/deploy-docker-bun.md +0 -150
  93. package/src/resources/skills/mandu-deployment/rules/deploy-docker-compose.md +0 -223
  94. package/src/resources/skills/mandu-deployment/rules/deploy-platform-fly.md +0 -152
  95. package/src/resources/skills/mandu-deployment/rules/deploy-platform-render.md +0 -179
  96. package/src/resources/skills/mandu-deployment/rules/deploy-platform-vercel.md +0 -140
  97. package/src/resources/skills/mandu-fs-routes/SKILL.md +0 -122
  98. package/src/resources/skills/mandu-fs-routes/metadata.json +0 -12
  99. package/src/resources/skills/mandu-fs-routes/rules/_sections.md +0 -36
  100. package/src/resources/skills/mandu-fs-routes/rules/_template.md +0 -69
  101. package/src/resources/skills/mandu-fs-routes/rules/routes-api-methods.md +0 -65
  102. package/src/resources/skills/mandu-fs-routes/rules/routes-dynamic-param.md +0 -93
  103. package/src/resources/skills/mandu-fs-routes/rules/routes-naming-page.md +0 -55
  104. package/src/resources/skills/mandu-guard/SKILL.md +0 -162
  105. package/src/resources/skills/mandu-guard/metadata.json +0 -12
  106. package/src/resources/skills/mandu-guard/rules/_sections.md +0 -36
  107. package/src/resources/skills/mandu-guard/rules/_template.md +0 -82
  108. package/src/resources/skills/mandu-guard/rules/guard-config-rules.md +0 -100
  109. package/src/resources/skills/mandu-guard/rules/guard-layer-direction.md +0 -76
  110. package/src/resources/skills/mandu-guard/rules/guard-preset-mandu.md +0 -81
  111. package/src/resources/skills/mandu-guard/rules/guard-validate-import.md +0 -80
  112. package/src/resources/skills/mandu-hydration/SKILL.md +0 -139
  113. package/src/resources/skills/mandu-hydration/metadata.json +0 -12
  114. package/src/resources/skills/mandu-hydration/rules/_sections.md +0 -31
  115. package/src/resources/skills/mandu-hydration/rules/_template.md +0 -72
  116. package/src/resources/skills/mandu-hydration/rules/hydration-data-event.md +0 -109
  117. package/src/resources/skills/mandu-hydration/rules/hydration-directive-use-client.md +0 -55
  118. package/src/resources/skills/mandu-hydration/rules/hydration-island-setup.md +0 -160
  119. package/src/resources/skills/mandu-hydration/rules/hydration-priority-visible.md +0 -91
  120. package/src/resources/skills/mandu-performance/SKILL.md +0 -125
  121. package/src/resources/skills/mandu-performance/metadata.json +0 -14
  122. package/src/resources/skills/mandu-performance/rules/_sections.md +0 -31
  123. package/src/resources/skills/mandu-performance/rules/_template.md +0 -64
  124. package/src/resources/skills/mandu-performance/rules/perf-async-defer-await.md +0 -103
  125. package/src/resources/skills/mandu-performance/rules/perf-async-parallel.md +0 -95
  126. package/src/resources/skills/mandu-performance/rules/perf-bun-file.md +0 -124
  127. package/src/resources/skills/mandu-performance/rules/perf-bun-serve.md +0 -125
  128. package/src/resources/skills/mandu-performance/rules/perf-bundle-imports.md +0 -80
  129. package/src/resources/skills/mandu-performance/rules/perf-bundle-island-lazy.md +0 -145
  130. package/src/resources/skills/mandu-performance/rules/perf-cache-react.md +0 -98
  131. package/src/resources/skills/mandu-performance/rules/perf-render-transitions.md +0 -154
  132. package/src/resources/skills/mandu-security/SKILL.md +0 -127
  133. package/src/resources/skills/mandu-security/metadata.json +0 -13
  134. package/src/resources/skills/mandu-security/rules/_sections.md +0 -31
  135. package/src/resources/skills/mandu-security/rules/_template.md +0 -74
  136. package/src/resources/skills/mandu-security/rules/sec-auth-guard.md +0 -127
  137. package/src/resources/skills/mandu-security/rules/sec-env-management.md +0 -133
  138. package/src/resources/skills/mandu-security/rules/sec-input-validate.md +0 -148
  139. package/src/resources/skills/mandu-security/rules/sec-protect-csrf.md +0 -146
  140. package/src/resources/skills/mandu-security/rules/sec-protect-headers.md +0 -138
  141. package/src/resources/skills/mandu-slot/SKILL.md +0 -125
  142. package/src/resources/skills/mandu-slot/metadata.json +0 -12
  143. package/src/resources/skills/mandu-slot/rules/_sections.md +0 -36
  144. package/src/resources/skills/mandu-slot/rules/_template.md +0 -63
  145. package/src/resources/skills/mandu-slot/rules/slot-basic-structure.md +0 -38
  146. package/src/resources/skills/mandu-slot/rules/slot-ctx-response.md +0 -56
  147. package/src/resources/skills/mandu-slot/rules/slot-guard-auth.md +0 -59
  148. package/src/resources/skills/mandu-slot/rules/slot-http-methods.md +0 -64
  149. package/src/resources/skills/mandu-styling/SKILL.md +0 -196
  150. package/src/resources/skills/mandu-styling/_sections.md +0 -43
  151. package/src/resources/skills/mandu-styling/_template.md +0 -32
  152. package/src/resources/skills/mandu-styling/metadata.json +0 -15
  153. package/src/resources/skills/mandu-styling/rules/style-component-compound.md +0 -235
  154. package/src/resources/skills/mandu-styling/rules/style-component-slots.md +0 -255
  155. package/src/resources/skills/mandu-styling/rules/style-component-tokens.md +0 -205
  156. package/src/resources/skills/mandu-styling/rules/style-island-animations.md +0 -272
  157. package/src/resources/skills/mandu-styling/rules/style-island-scoping.md +0 -167
  158. package/src/resources/skills/mandu-styling/rules/style-island-variants.md +0 -221
  159. package/src/resources/skills/mandu-styling/rules/style-perf-critical.md +0 -209
  160. package/src/resources/skills/mandu-styling/rules/style-perf-purge.md +0 -192
  161. package/src/resources/skills/mandu-styling/rules/style-setup-modules.md +0 -162
  162. package/src/resources/skills/mandu-styling/rules/style-setup-panda.md +0 -164
  163. package/src/resources/skills/mandu-styling/rules/style-setup-tailwind.md +0 -170
  164. package/src/resources/skills/mandu-styling/rules/style-tailwind-v4-gotchas.md +0 -179
  165. package/src/resources/skills/mandu-styling/rules/style-theme-darkmode.md +0 -229
  166. package/src/resources/skills/mandu-testing/SKILL.md +0 -132
  167. package/src/resources/skills/mandu-testing/metadata.json +0 -13
  168. package/src/resources/skills/mandu-testing/rules/_sections.md +0 -26
  169. package/src/resources/skills/mandu-testing/rules/_template.md +0 -65
  170. package/src/resources/skills/mandu-testing/rules/test-component-island.md +0 -195
  171. package/src/resources/skills/mandu-testing/rules/test-e2e-playwright.md +0 -196
  172. package/src/resources/skills/mandu-testing/rules/test-mock-fetch.md +0 -219
  173. package/src/resources/skills/mandu-testing/rules/test-slot-unit.md +0 -192
  174. package/src/resources/skills/mandu-ui/SKILL.md +0 -159
  175. package/src/resources/skills/mandu-ui/_sections.md +0 -23
  176. package/src/resources/skills/mandu-ui/_template.md +0 -32
  177. package/src/resources/skills/mandu-ui/metadata.json +0 -13
  178. package/src/resources/skills/mandu-ui/rules/ui-accessibility-aria.md +0 -232
  179. package/src/resources/skills/mandu-ui/rules/ui-accessibility-focus.md +0 -238
  180. package/src/resources/skills/mandu-ui/rules/ui-composition-patterns.md +0 -259
  181. package/src/resources/skills/mandu-ui/rules/ui-island-integration.md +0 -258
  182. package/src/resources/skills/mandu-ui/rules/ui-radix-patterns.md +0 -213
  183. package/src/resources/skills/mandu-ui/rules/ui-shadcn-setup.md +0 -209
@@ -1,160 +0,0 @@
1
- ---
2
- title: Use Mandu.island() with Setup Function
3
- impact: HIGH
4
- impactDescription: Proper Island structure
5
- tags: hydration, island, setup
6
- ---
7
-
8
- ## Use Mandu.island() with Setup Function
9
-
10
- For complex Islands, use `Mandu.island()` API to separate state logic from rendering.
11
- `Mandu.island()` takes a single definition object. The shorthand
12
- `island("visible", Component)` is not a supported Mandu runtime API.
13
-
14
- Islands are page-level client bundles. They are discovered and rendered by
15
- the framework wrapper, not embedded directly as inline JSX. Use `partial()`
16
- when a server page needs an inline interactive region.
17
-
18
- ```tsx
19
- // Simple page-level island wrapper
20
- "use client";
21
-
22
- import { wrapComponent } from "@mandujs/core/client";
23
-
24
- function Counter() {
25
- return <button>Count</button>;
26
- }
27
-
28
- export default wrapComponent(Counter);
29
- ```
30
-
31
- ```tsx
32
- // Inline client region inside a server-rendered page
33
- // app/Counter.partial.tsx
34
- import { partial } from "@mandujs/core/client";
35
- import { Counter } from "./counter.client";
36
-
37
- export default partial({
38
- id: "Counter",
39
- component: Counter,
40
- priority: "visible",
41
- });
42
- ```
43
-
44
- ```tsx
45
- // app/page.tsx
46
- import CounterPartial from "./Counter.partial";
47
-
48
- export const hydration = {
49
- strategy: "island",
50
- priority: "visible",
51
- preload: false,
52
- };
53
-
54
- export default function Page() {
55
- return <CounterPartial.Render initial={0} />;
56
- }
57
- ```
58
-
59
- **Incorrect (mixed concerns):**
60
-
61
- ```tsx
62
- "use client";
63
-
64
- export default function TodoList({ initialTodos }) {
65
- // State, handlers, and JSX all mixed together
66
- const [todos, setTodos] = useState(initialTodos);
67
- const [input, setInput] = useState("");
68
-
69
- const add = () => {
70
- setTodos([...todos, { id: Date.now(), text: input }]);
71
- setInput("");
72
- };
73
-
74
- return (
75
- <div>
76
- <input value={input} onChange={e => setInput(e.target.value)} />
77
- <button onClick={add}>Add</button>
78
- {todos.map(t => <li key={t.id}>{t.text}</li>)}
79
- </div>
80
- );
81
- }
82
- ```
83
-
84
- **Correct (Mandu.island pattern):**
85
-
86
- ```tsx
87
- // spec/slots/todos.client.ts
88
-
89
- import { Mandu } from "@mandujs/core/client";
90
- import { useState, useCallback } from "react";
91
-
92
- interface TodosData {
93
- todos: { id: number; text: string; done: boolean }[];
94
- }
95
-
96
- export default Mandu.island<TodosData>({
97
- // Setup: Initialize client state from server data
98
- setup: (serverData) => {
99
- const [todos, setTodos] = useState(serverData.todos);
100
- const [input, setInput] = useState("");
101
-
102
- const addTodo = useCallback(() => {
103
- if (!input.trim()) return;
104
- setTodos(prev => [...prev, { id: Date.now(), text: input, done: false }]);
105
- setInput("");
106
- }, [input]);
107
-
108
- const toggleTodo = useCallback((id: number) => {
109
- setTodos(prev => prev.map(t =>
110
- t.id === id ? { ...t, done: !t.done } : t
111
- ));
112
- }, []);
113
-
114
- return { todos, input, setInput, addTodo, toggleTodo };
115
- },
116
-
117
- // Render: Pure rendering logic
118
- render: ({ todos, input, setInput, addTodo, toggleTodo }) => (
119
- <div>
120
- <input
121
- value={input}
122
- onChange={e => setInput(e.target.value)}
123
- placeholder="New todo..."
124
- />
125
- <button onClick={addTodo}>Add</button>
126
- <ul>
127
- {todos.map(todo => (
128
- <li
129
- key={todo.id}
130
- onClick={() => toggleTodo(todo.id)}
131
- style={{ textDecoration: todo.done ? "line-through" : "none" }}
132
- >
133
- {todo.done ? "✅" : "⬜"} {todo.text}
134
- </li>
135
- ))}
136
- </ul>
137
- </div>
138
- ),
139
-
140
- // Optional: Error boundary
141
- errorBoundary: (error, reset) => (
142
- <div>
143
- <p>Error: {error.message}</p>
144
- <button onClick={reset}>Retry</button>
145
- </div>
146
- ),
147
-
148
- // Optional: Loading state
149
- loading: () => <p>Loading todos...</p>,
150
- });
151
- ```
152
-
153
- ## Mandu.island() Options
154
-
155
- | Option | Required | Description |
156
- |--------|----------|-------------|
157
- | `setup` | Yes | Initialize state from server data |
158
- | `render` | Yes | Pure render function |
159
- | `errorBoundary` | No | Error UI component |
160
- | `loading` | No | Loading UI component |
@@ -1,91 +0,0 @@
1
- ---
2
- title: Use Visible Priority for Below-Fold Content
3
- impact: MEDIUM
4
- impactDescription: Optimizes initial page load
5
- tags: hydration, priority, performance
6
- ---
7
-
8
- ## Use Visible Priority for Below-Fold Content
9
-
10
- Set hydration priority based on when the component needs to be interactive.
11
-
12
- ## Hydration Priorities
13
-
14
- | Priority | Load Time | Use Case |
15
- |----------|-----------|----------|
16
- | `immediate` | Page load | Critical interactions (header nav, auth forms) |
17
- | `visible` | Viewport entry (default) | Below-fold content |
18
- | `idle` | Browser idle | Non-critical features (analytics widgets) |
19
- | `interaction` | User action | Click-to-activate components |
20
-
21
- ## Examples
22
-
23
- Inline client regions live in `*.partial.tsx` files and use
24
- `partial({ id, component, priority })`, then render the returned `.Render`
25
- component from the server page. The page must export a non-`none` hydration
26
- config.
27
-
28
- ### Immediate: Always-visible interactions
29
-
30
- ```tsx
31
- // Header with navigation - needs to work immediately
32
- import { partial } from "@mandujs/core/client";
33
-
34
- const HeaderNavPartial = partial({
35
- id: "HeaderNav",
36
- component: HeaderNav,
37
- priority: "immediate",
38
- });
39
-
40
- <HeaderNavPartial.Render />
41
- ```
42
-
43
- ### Visible: Below-fold content (default)
44
-
45
- ```tsx
46
- // Comments section - load when scrolled into view
47
- const CommentsPartial = partial({
48
- id: "Comments",
49
- component: CommentsSection,
50
- priority: "visible",
51
- });
52
-
53
- <CommentsPartial.Render postId={postId} />
54
- ```
55
-
56
- ### Idle: Background features
57
-
58
- ```tsx
59
- // Chat widget - can wait until browser is idle
60
- const ChatPartial = partial({
61
- id: "Chat",
62
- component: ChatWidget,
63
- priority: "idle",
64
- });
65
-
66
- <ChatPartial.Render />
67
- ```
68
-
69
- ### Interaction: On-demand activation
70
-
71
- ```tsx
72
- // Video player - only hydrate when user clicks play
73
- const VideoPartial = partial({
74
- id: "Video",
75
- component: VideoPlayer,
76
- priority: "interaction",
77
- });
78
-
79
- <VideoPartial.Render videoId={videoId} />
80
- ```
81
-
82
- ## Performance Impact
83
-
84
- ```
85
- immediate: +JavaScript bundle at page load
86
- visible: +JavaScript when component enters viewport
87
- idle: +JavaScript during browser idle time
88
- interaction: +JavaScript on first user interaction
89
- ```
90
-
91
- **Rule of thumb**: Use `visible` (default) unless you have a specific reason to choose another priority.
@@ -1,125 +0,0 @@
1
- ---
2
- name: mandu-performance
3
- description: |
4
- Performance optimization patterns for Mandu applications. Use when optimizing
5
- slot handlers, Island components, bundle size, or Bun runtime. Triggers on
6
- tasks involving async/await, Promise.all, lazy loading, caching, or performance.
7
- license: MIT
8
- metadata:
9
- author: mandu
10
- version: "1.0.0"
11
- ---
12
-
13
- # Mandu Performance
14
-
15
- Mandu 애플리케이션의 성능 최적화 가이드. 워터폴 제거, 번들 최적화, 캐싱 패턴, Bun 런타임 활용법을 다룹니다. Vercel의 React Best Practices를 Mandu 컨텍스트로 변환하여 적용합니다.
16
-
17
- ## Agent Workflow Contract
18
-
19
- This skill is a Domain addendum. It must not replace `mandu-agent-workflow`.
20
- Use it only after `mandu.agent.plan` selects performance, hydration, route, API, or runtime domains.
21
-
22
- Canonical workflow step: `plan -> verify -> repair`.
23
-
24
- Preferred MCP tools:
25
-
26
- | Step | Tools |
27
- |------|-------|
28
- | plan | `mandu.agent.plan`, `mandu.agent.context` |
29
- | apply | `mandu.agent.apply` |
30
- | verify | `mandu.agent.verify`, `mandu.build`, `mandu.run.tests` |
31
- | repair | `mandu.agent.repair` |
32
-
33
- Allowed file edits:
34
-
35
- - Route, slot, island, or cache code named in the plan
36
- - Import boundaries that reduce bundle/runtime cost
37
- - Benchmark/test files scoped to the performance claim
38
-
39
- Verification command:
40
-
41
- ```bash
42
- mandu agent verify --changed --json --write
43
- ```
44
-
45
- Common failures:
46
-
47
- - Optimizing without a measurable route, bundle, or runtime target
48
- - Moving server-only code into client islands for convenience
49
- - Skipping typecheck or targeted tests after cache/import rewrites
50
-
51
- Repair path:
52
-
53
- ```bash
54
- mandu agent repair --from .mandu/agent-verify.json --json
55
- ```
56
-
57
- ## When to Apply
58
-
59
- Reference these guidelines when:
60
- - Optimizing slot handler response times
61
- - Reducing Island component bundle size
62
- - Implementing caching strategies
63
- - Working with async/await patterns
64
- - Leveraging Bun runtime features
65
-
66
- ## Rule Categories by Priority
67
-
68
- | Priority | Category | Impact | Prefix |
69
- |----------|----------|--------|--------|
70
- | 1 | Async Optimization | CRITICAL | `perf-async-` |
71
- | 2 | Bundle Optimization | CRITICAL | `perf-bundle-` |
72
- | 3 | Caching Strategies | HIGH | `perf-cache-` |
73
- | 4 | Bun Runtime | HIGH | `perf-bun-` |
74
- | 5 | Rendering | MEDIUM | `perf-render-` |
75
-
76
- ## Quick Reference
77
-
78
- ### 1. Async Optimization (CRITICAL)
79
-
80
- - `perf-async-parallel` - Use Promise.all() for independent operations
81
- - `perf-async-defer-await` - Move await into branches where actually used
82
- - `perf-async-early-start` - Start promises early, await late
83
-
84
- ### 2. Bundle Optimization (CRITICAL)
85
-
86
- - `perf-bundle-imports` - Import directly, avoid barrel files
87
- - `perf-bundle-island-lazy` - Lazy load Islands with dynamic import
88
- - `perf-bundle-preload` - Preload on hover/focus for perceived speed
89
-
90
- ### 3. Caching Strategies (HIGH)
91
-
92
- - `perf-cache-slot` - Cache slot responses with appropriate TTL
93
- - `perf-cache-react` - Use React.cache() for request deduplication
94
- - `perf-cache-lru` - Use LRU cache for cross-request caching
95
-
96
- ### 4. Bun Runtime (HIGH)
97
-
98
- - `perf-bun-serve` - Optimize Bun.serve() configuration
99
- - `perf-bun-file` - Use Bun.file() for efficient file operations
100
- - `perf-bun-sqlite` - Leverage bun:sqlite for fast database access
101
-
102
- ### 5. Rendering (MEDIUM)
103
-
104
- - `perf-render-island-priority` - Set appropriate hydration priority
105
- - `perf-render-transitions` - Use startTransition for non-urgent updates
106
-
107
- ## Performance Impact Summary
108
-
109
- | Optimization | Typical Improvement |
110
- |--------------|---------------------|
111
- | Promise.all() | 2-10× faster |
112
- | Direct imports | 15-70% faster dev boot |
113
- | Island lazy loading | 40-60% smaller initial bundle |
114
- | React.cache() | Eliminates duplicate queries |
115
- | Bun.file() | 10× faster than Node fs |
116
-
117
- ## How to Use
118
-
119
- Read individual rule files for detailed explanations:
120
-
121
- ```
122
- rules/perf-async-parallel.md
123
- rules/perf-bundle-imports.md
124
- rules/perf-bun-serve.md
125
- ```
@@ -1,14 +0,0 @@
1
- {
2
- "version": "1.0.0",
3
- "organization": "Mandu Framework",
4
- "date": "February 2026",
5
- "abstract": "Mandu 애플리케이션 성능 최적화 가이드. 워터폴 제거 (Promise.all), 번들 최적화 (직접 import, lazy loading), 캐싱 전략 (React.cache, LRU), Bun 런타임 활용 (Bun.serve, Bun.file)을 다룹니다. Vercel React Best Practices 기반으로 Mandu 컨텍스트에 맞게 변환되었습니다.",
6
- "references": [
7
- "https://vercel.com/blog/how-we-optimized-package-imports-in-next-js",
8
- "https://vercel.com/blog/how-we-made-the-vercel-dashboard-twice-as-fast",
9
- "https://bun.sh/docs/api/http",
10
- "https://bun.sh/docs/api/file-io",
11
- "https://react.dev/reference/react/cache"
12
- ],
13
- "tags": ["performance", "async", "bundle", "cache", "bun", "mandu"]
14
- }
@@ -1,31 +0,0 @@
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. Async Optimization (perf-async)
9
-
10
- **Impact:** CRITICAL
11
- **Description:** 워터폴은 성능의 #1 킬러입니다. 순차적 await는 매번 전체 네트워크 지연을 추가합니다. 워터폴 제거가 가장 큰 성능 향상을 가져옵니다.
12
-
13
- ## 2. Bundle Optimization (perf-bundle)
14
-
15
- **Impact:** CRITICAL
16
- **Description:** 초기 번들 크기 감소는 Time to Interactive와 Largest Contentful Paint를 개선합니다. Island lazy loading과 직접 import가 핵심입니다.
17
-
18
- ## 3. Caching Strategies (perf-cache)
19
-
20
- **Impact:** HIGH
21
- **Description:** 적절한 캐싱은 불필요한 연산과 네트워크 요청을 제거합니다. React.cache()는 요청 내 중복 제거, LRU는 요청 간 캐싱에 사용합니다.
22
-
23
- ## 4. Bun Runtime (perf-bun)
24
-
25
- **Impact:** HIGH
26
- **Description:** Bun의 네이티브 API (Bun.serve, Bun.file, bun:sqlite)는 Node.js 대비 현저히 빠릅니다. Mandu는 Bun 기반이므로 이를 최대한 활용해야 합니다.
27
-
28
- ## 5. Rendering Performance (perf-render)
29
-
30
- **Impact:** MEDIUM
31
- **Description:** Island hydration 우선순위 설정과 startTransition 활용으로 사용자 체감 성능을 개선합니다.
@@ -1,64 +0,0 @@
1
- # Rule Template
2
-
3
- Use this template when creating new rules for mandu-performance.
4
-
5
- ---
6
-
7
- ```markdown
8
- ---
9
- title: Rule Title Here
10
- impact: CRITICAL | HIGH | MEDIUM | LOW
11
- impactDescription: 개선 수치 (예: "2-10× improvement", "40% faster")
12
- tags: performance, tag1, tag2
13
- ---
14
-
15
- ## Rule Title Here
16
-
17
- **Impact: {LEVEL} ({impactDescription})**
18
-
19
- 규칙의 목적과 성능 영향을 설명합니다.
20
-
21
- **Incorrect (문제점 - 성능 영향 명시):**
22
-
23
- \`\`\`typescript
24
- // ❌ 순차 실행: 3번의 네트워크 왕복
25
- const user = await fetchUser();
26
- const posts = await fetchPosts();
27
- const comments = await fetchComments();
28
- // 총 시간: 100ms + 100ms + 100ms = 300ms
29
- \`\`\`
30
-
31
- **Correct (해결책 - 성능 개선 명시):**
32
-
33
- \`\`\`typescript
34
- // ✅ 병렬 실행: 1번의 네트워크 왕복
35
- const [user, posts, comments] = await Promise.all([
36
- fetchUser(),
37
- fetchPosts(),
38
- fetchComments(),
39
- ]);
40
- // 총 시간: max(100ms, 100ms, 100ms) = 100ms
41
- \`\`\`
42
-
43
- ## Mandu Context
44
-
45
- Mandu에서 이 규칙을 적용하는 구체적인 방법을 설명합니다.
46
-
47
- Reference: [관련 문서 링크](https://example.com)
48
- ```
49
-
50
- ---
51
-
52
- ## Naming Convention
53
-
54
- - 파일명: `perf-{category}-{rule-name}.md`
55
- - 예시: `perf-async-parallel.md`, `perf-bundle-imports.md`
56
-
57
- ## Impact Measurement
58
-
59
- | Level | Typical Improvement |
60
- |-------|---------------------|
61
- | CRITICAL | 2-10× or 50%+ |
62
- | HIGH | 20-50% |
63
- | MEDIUM | 10-20% |
64
- | LOW | < 10% |
@@ -1,103 +0,0 @@
1
- ---
2
- title: Defer await to Where Actually Used
3
- impact: CRITICAL
4
- impactDescription: Eliminates unnecessary blocking
5
- tags: performance, async, await, slot
6
- ---
7
-
8
- ## Defer await to Where Actually Used
9
-
10
- **Impact: CRITICAL (Eliminates unnecessary blocking)**
11
-
12
- await는 실제로 값이 필요한 시점까지 지연하세요. 함수 시작에서 모든 것을 await하면 불필요한 블로킹이 발생합니다.
13
-
14
- **Incorrect (너무 일찍 await):**
15
-
16
- ```typescript
17
- // spec/slots/user.slot.ts
18
- import { Mandu } from "@mandujs/core";
19
-
20
- export default Mandu.filling()
21
- .get(async (ctx) => {
22
- const userId = ctx.params.id;
23
-
24
- // ❌ 캐시 확인 전에 DB 쿼리 시작하고 대기
25
- const user = await fetchUserFromDB(userId);
26
-
27
- // 캐시에 있으면 DB 쿼리는 불필요했음
28
- const cached = cache.get(`user:${userId}`);
29
- if (cached) {
30
- return ctx.ok(cached);
31
- }
32
-
33
- return ctx.ok(user);
34
- });
35
- ```
36
-
37
- **Correct (필요한 시점에 await):**
38
-
39
- ```typescript
40
- // spec/slots/user.slot.ts
41
- import { Mandu } from "@mandujs/core";
42
-
43
- export default Mandu.filling()
44
- .get(async (ctx) => {
45
- const userId = ctx.params.id;
46
-
47
- // 캐시 먼저 확인
48
- const cached = cache.get(`user:${userId}`);
49
- if (cached) {
50
- return ctx.ok(cached); // DB 쿼리 안 함
51
- }
52
-
53
- // ✅ 캐시 미스일 때만 DB 쿼리
54
- const user = await fetchUserFromDB(userId);
55
- cache.set(`user:${userId}`, user);
56
-
57
- return ctx.ok(user);
58
- });
59
- ```
60
-
61
- ## Promise 시작은 일찍, await는 늦게
62
-
63
- ```typescript
64
- export default Mandu.filling()
65
- .get(async (ctx) => {
66
- // ✅ Promise 시작 (블로킹 없음)
67
- const userPromise = fetchUser(ctx.params.id);
68
- const configPromise = fetchConfig();
69
-
70
- // 동기 작업 수행
71
- const requestId = generateRequestId();
72
- const timestamp = Date.now();
73
- logRequest(requestId, timestamp);
74
-
75
- // ✅ 필요한 시점에 await
76
- const [user, config] = await Promise.all([userPromise, configPromise]);
77
-
78
- return ctx.ok({ user, config, requestId });
79
- });
80
- ```
81
-
82
- ## 조건부 분기에서의 활용
83
-
84
- ```typescript
85
- export default Mandu.filling()
86
- .get(async (ctx) => {
87
- const { type } = ctx.query;
88
-
89
- if (type === "summary") {
90
- // 요약만 필요하면 상세 데이터 불필요
91
- const summary = await fetchSummary(ctx.params.id);
92
- return ctx.ok({ summary });
93
- }
94
-
95
- // 상세 데이터가 필요한 경우에만 fetch
96
- const [summary, details] = await Promise.all([
97
- fetchSummary(ctx.params.id),
98
- fetchDetails(ctx.params.id),
99
- ]);
100
-
101
- return ctx.ok({ summary, details });
102
- });
103
- ```
@@ -1,95 +0,0 @@
1
- ---
2
- title: Use Promise.all() for Independent Operations
3
- impact: CRITICAL
4
- impactDescription: 2-10× improvement
5
- tags: performance, async, parallel, promises, slot
6
- ---
7
-
8
- ## Use Promise.all() for Independent Operations
9
-
10
- **Impact: CRITICAL (2-10× improvement)**
11
-
12
- 독립적인 비동기 작업은 `Promise.all()`로 병렬 실행하세요. 순차 실행은 각 await마다 전체 네트워크 지연을 추가합니다.
13
-
14
- **Incorrect (순차 실행, 3번의 왕복):**
15
-
16
- ```typescript
17
- // spec/slots/dashboard.slot.ts
18
- import { Mandu } from "@mandujs/core";
19
-
20
- export default Mandu.filling()
21
- .get(async (ctx) => {
22
- // ❌ 순차 실행: 300ms (100ms × 3)
23
- const user = await fetchUser(ctx.get("userId"));
24
- const posts = await fetchPosts(ctx.get("userId"));
25
- const notifications = await fetchNotifications(ctx.get("userId"));
26
-
27
- return ctx.ok({ user, posts, notifications });
28
- });
29
- ```
30
-
31
- **Correct (병렬 실행, 1번의 왕복):**
32
-
33
- ```typescript
34
- // spec/slots/dashboard.slot.ts
35
- import { Mandu } from "@mandujs/core";
36
-
37
- export default Mandu.filling()
38
- .get(async (ctx) => {
39
- const userId = ctx.get("userId");
40
-
41
- // ✅ 병렬 실행: 100ms (가장 느린 것 기준)
42
- const [user, posts, notifications] = await Promise.all([
43
- fetchUser(userId),
44
- fetchPosts(userId),
45
- fetchNotifications(userId),
46
- ]);
47
-
48
- return ctx.ok({ user, posts, notifications });
49
- });
50
- ```
51
-
52
- ## 부분 의존성이 있는 경우
53
-
54
- 일부 작업이 다른 작업의 결과에 의존하는 경우:
55
-
56
- ```typescript
57
- export default Mandu.filling()
58
- .get(async (ctx) => {
59
- // 1단계: 독립적인 작업 병렬 실행
60
- const [user, config] = await Promise.all([
61
- fetchUser(ctx.get("userId")),
62
- fetchConfig(),
63
- ]);
64
-
65
- // 2단계: user에 의존하는 작업 병렬 실행
66
- const [posts, followers] = await Promise.all([
67
- fetchPosts(user.id),
68
- fetchFollowers(user.id),
69
- ]);
70
-
71
- return ctx.ok({ user, config, posts, followers });
72
- });
73
- ```
74
-
75
- ## Promise.allSettled() 사용
76
-
77
- 일부 실패를 허용하는 경우:
78
-
79
- ```typescript
80
- const results = await Promise.allSettled([
81
- fetchUser(userId),
82
- fetchPosts(userId), // 실패해도 OK
83
- fetchNotifications(userId), // 실패해도 OK
84
- ]);
85
-
86
- const [userResult, postsResult, notificationsResult] = results;
87
-
88
- return ctx.ok({
89
- user: userResult.status === "fulfilled" ? userResult.value : null,
90
- posts: postsResult.status === "fulfilled" ? postsResult.value : [],
91
- notifications: notificationsResult.status === "fulfilled" ? notificationsResult.value : [],
92
- });
93
- ```
94
-
95
- Reference: [MDN Promise.all()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all)