@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,81 +0,0 @@
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
- ```
@@ -1,80 +0,0 @@
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
- ```
@@ -1,139 +0,0 @@
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
- ## Agent Workflow Contract
19
-
20
- This skill is a Domain addendum. It must not replace `mandu-agent-workflow`.
21
- Use it only after `mandu.agent.plan` selects the hydration, island, partial, or route domain.
22
-
23
- Canonical workflow step: `plan -> apply -> verify -> repair`.
24
-
25
- Preferred MCP tools:
26
-
27
- | Step | Tools |
28
- |------|-------|
29
- | plan | `mandu.agent.plan`, `mandu.island.list` |
30
- | apply | `mandu.agent.apply`, `mandu.hydration.set`, `mandu.hydration.addClientSlot` |
31
- | verify | `mandu.agent.verify`, `mandu.build`, `mandu.build.status` |
32
- | repair | `mandu.agent.repair` |
33
-
34
- Allowed file edits:
35
-
36
- - `app/**/*.partial.tsx`, `app/**/*.island.tsx`, route-local client components
37
- - Page hydration metadata only when the plan names the route
38
- - Shared client utilities only after inspecting existing client boundaries
39
-
40
- Verification command:
41
-
42
- ```bash
43
- mandu agent verify --changed --json --write
44
- ```
45
-
46
- Common failures:
47
-
48
- - Rendering page-level islands inline instead of using `partial().Render`
49
- - Forgetting route hydration metadata when a server page renders partials
50
- - Moving server-only imports into client bundles
51
-
52
- Repair path:
53
-
54
- ```bash
55
- mandu agent repair --from .mandu/agent-verify.json --json
56
- ```
57
-
58
- ## When to Apply
59
-
60
- Reference these guidelines when:
61
- - Creating interactive client components
62
- - Adding client-side state to pages
63
- - Implementing partial hydration
64
- - Setting up client-server data flow
65
- - Working with Island communication
66
-
67
- ## Rule Categories by Priority
68
-
69
- | Priority | Category | Impact | Prefix |
70
- |----------|----------|--------|--------|
71
- | 1 | Client Directive | CRITICAL | `hydration-directive-` |
72
- | 2 | Island Structure | HIGH | `hydration-island-` |
73
- | 3 | Hydration Priority | MEDIUM | `hydration-priority-` |
74
- | 4 | Data Flow | MEDIUM | `hydration-data-` |
75
-
76
- ## Quick Reference
77
-
78
- ### 1. Client Directive (CRITICAL)
79
-
80
- - `hydration-directive-use-client` - Add "use client" directive for client components
81
- - `hydration-directive-file-naming` - Use .client.tsx for client component files
82
-
83
- ### 2. Island Structure (HIGH)
84
-
85
- - `hydration-island-setup` - Use Mandu.island() with setup function
86
- - `hydration-island-render` - Separate state logic from render
87
-
88
- ### 3. Hydration Priority (MEDIUM)
89
-
90
- - `hydration-priority-immediate` - Load on page load (critical interactions)
91
- - `hydration-priority-visible` - Load when visible (default)
92
- - `hydration-priority-idle` - Load when browser idle
93
- - `hydration-priority-interaction` - Load on user interaction
94
-
95
- ### 4. Data Flow (MEDIUM)
96
-
97
- - `hydration-data-server` - Access server data with useServerData
98
- - `hydration-data-event` - Communicate between Islands with useIslandEvent
99
-
100
- ## Hydration Strategies
101
-
102
- | Strategy | Description | Use Case |
103
- |----------|-------------|----------|
104
- | `none` | No JavaScript | Pure static pages |
105
- | `island` | Partial hydration (default) | Static + interactive mix |
106
- | `full` | Full hydration | SPA-style pages |
107
-
108
- ## Runtime API Constraints
109
-
110
- - `island()` / `Mandu.island()` takes one definition object: `island({ setup, render })`.
111
- - Do not call `island("visible", Component)`; use `wrapComponent(Component)` for a simple page-level island wrapper.
112
- - Islands are page-level client bundles. Do not render them as inline JSX like `<MyIsland />`.
113
- - For an embedded interactive region inside a server page, use `partial()`: put it in `*.partial.tsx`, export `partial({ id, component })`, and render the returned `.Render` component from the server page.
114
- - A server page that renders partials must opt into hydration, for example `export const hydration = { strategy: "island", priority: "visible", preload: false }`.
115
-
116
- ## Client Hooks
117
-
118
- ```typescript
119
- import {
120
- useServerData,
121
- useHydrated,
122
- useIslandEvent,
123
- } from "@mandujs/core/client";
124
-
125
- // Access SSR data
126
- const data = useServerData<UserData>("user", defaultValue);
127
-
128
- // Check hydration status
129
- const isHydrated = useHydrated();
130
- ```
131
-
132
- ## How to Use
133
-
134
- Read individual rule files for detailed explanations:
135
-
136
- ```
137
- rules/hydration-directive-use-client.md
138
- rules/hydration-island-setup.md
139
- ```
@@ -1,12 +0,0 @@
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
- }
@@ -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. 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입니다.
@@ -1,72 +0,0 @@
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` | 사용자 액션 | 클릭해야 활성화 |
@@ -1,109 +0,0 @@
1
- ---
2
- title: Use useIslandEvent for Island Communication
3
- impact: MEDIUM
4
- impactDescription: Enables Island-to-Island data flow
5
- tags: hydration, event, communication
6
- ---
7
-
8
- ## Use useIslandEvent for Island Communication
9
-
10
- Islands are isolated by default. Use `useIslandEvent` to communicate between them.
11
-
12
- **Incorrect (shared global state):**
13
-
14
- ```tsx
15
- // ❌ Don't use global variables for Island communication
16
- let globalCount = 0;
17
-
18
- // Island A
19
- export function CounterIsland() {
20
- const [count, setCount] = useState(globalCount);
21
- // This won't sync with other Islands
22
- }
23
- ```
24
-
25
- **Correct (useIslandEvent):**
26
-
27
- ```tsx
28
- // Island A: Counter (emits updates)
29
- "use client";
30
-
31
- import { useState } from "react";
32
- import { useIslandEvent } from "@mandujs/core/client";
33
-
34
- export function CounterIsland() {
35
- const [count, setCount] = useState(0);
36
- const { emit } = useIslandEvent<{ count: number }>("counter-update");
37
-
38
- const increment = () => {
39
- const newCount = count + 1;
40
- setCount(newCount);
41
- emit({ count: newCount }); // Notify other Islands
42
- };
43
-
44
- return <button onClick={increment}>Count: {count}</button>;
45
- }
46
- ```
47
-
48
- ```tsx
49
- // Island B: Display (receives updates)
50
- "use client";
51
-
52
- import { useState } from "react";
53
- import { useIslandEvent } from "@mandujs/core/client";
54
-
55
- export function DisplayIsland() {
56
- const [lastCount, setLastCount] = useState(0);
57
-
58
- useIslandEvent<{ count: number }>("counter-update", (data) => {
59
- setLastCount(data.count); // React to counter updates
60
- });
61
-
62
- return <p>Last count received: {lastCount}</p>;
63
- }
64
- ```
65
-
66
- ## API Reference
67
-
68
- ```typescript
69
- // Emit events
70
- const { emit } = useIslandEvent<T>(eventName);
71
- emit(data);
72
-
73
- // Listen to events
74
- useIslandEvent<T>(eventName, (data) => {
75
- // Handle received data
76
- });
77
-
78
- // Both emit and listen
79
- const { emit } = useIslandEvent<T>(eventName, (data) => {
80
- // Handle received data
81
- });
82
- emit(otherData);
83
- ```
84
-
85
- ## Common Patterns
86
-
87
- ### Cart Updates
88
-
89
- ```tsx
90
- // Product Island
91
- emit({ action: "add", productId: 123 });
92
-
93
- // Cart Island
94
- useIslandEvent("cart-update", ({ action, productId }) => {
95
- if (action === "add") addToCart(productId);
96
- });
97
- ```
98
-
99
- ### Form Validation
100
-
101
- ```tsx
102
- // Form Field Island
103
- emit({ field: "email", valid: true, value: "user@example.com" });
104
-
105
- // Submit Button Island
106
- useIslandEvent("field-change", ({ field, valid }) => {
107
- updateFieldStatus(field, valid);
108
- });
109
- ```
@@ -1,55 +0,0 @@
1
- ---
2
- title: Add "use client" Directive for Client Components
3
- impact: CRITICAL
4
- impactDescription: Required for client-side interactivity
5
- tags: hydration, client, directive
6
- ---
7
-
8
- ## Add "use client" Directive for Client Components
9
-
10
- Client components must have `"use client"` directive at the top of the file.
11
-
12
- **Incorrect (missing directive):**
13
-
14
- ```tsx
15
- // app/counter/client.tsx
16
-
17
- import { useState } from "react";
18
-
19
- export default function Counter() {
20
- const [count, setCount] = useState(0); // ❌ Will error
21
- return <button onClick={() => setCount(c => c + 1)}>{count}</button>;
22
- }
23
- ```
24
-
25
- **Correct (with directive):**
26
-
27
- ```tsx
28
- // app/counter/client.tsx
29
-
30
- "use client";
31
-
32
- import { useState } from "react";
33
-
34
- export default function Counter() {
35
- const [count, setCount] = useState(0); // ✅ Works
36
- return <button onClick={() => setCount(c => c + 1)}>{count}</button>;
37
- }
38
- ```
39
-
40
- ## When to Use "use client"
41
-
42
- Use the directive when your component:
43
- - Uses React hooks (useState, useEffect, useRef, etc.)
44
- - Has event handlers (onClick, onChange, etc.)
45
- - Uses browser-only APIs (window, document, localStorage)
46
- - Needs client-side interactivity
47
-
48
- ## File Naming Convention
49
-
50
- ```
51
- app/
52
- ├── counter/
53
- │ ├── page.tsx # Server component (no directive needed)
54
- │ └── client.tsx # Client component ("use client" required)
55
- ```