@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.
- package/README.md +3 -3
- package/package.json +3 -5
- package/src/activity-adapter.ts +23 -23
- package/src/activity-monitor.ts +39 -10
- package/src/adapters/index.ts +20 -20
- package/src/adapters/monitor-adapter.ts +100 -100
- package/src/adapters/tool-adapter.ts +90 -90
- package/src/executor/index.ts +22 -22
- package/src/executor/tool-executor.ts +148 -148
- package/src/hooks/config-watcher.ts +173 -173
- package/src/hooks/index.ts +23 -23
- package/src/hooks/mcp-hooks.ts +227 -227
- package/src/index.ts +5 -5
- package/src/logging/index.ts +15 -15
- package/src/logging/mcp-transport.ts +134 -134
- package/src/new-resources.ts +2 -2
- package/src/profiles.ts +25 -54
- package/src/prompts.ts +4 -4
- package/src/registry/index.ts +13 -13
- package/src/registry/mcp-tool-registry.ts +298 -298
- package/src/resources/generated-skills/catalog.ts +36 -0
- package/src/resources/generated-skills/mandu-agent-workflow/SKILL.md +48 -0
- package/src/resources/generated-skills/mandu-contract/SKILL.md +20 -0
- package/src/resources/generated-skills/mandu-fs-routes/SKILL.md +19 -0
- package/src/resources/generated-skills/mandu-guard/SKILL.md +20 -0
- package/src/resources/generated-skills/mandu-hydration/SKILL.md +19 -0
- package/src/resources/generated-skills/mandu-testing/SKILL.md +20 -0
- package/src/resources/handlers.ts +3 -3
- package/src/resources/skills/guides.ts +49 -49
- package/src/resources/skills/index.ts +12 -12
- package/src/resources/skills/loader.ts +8 -35
- package/src/resources/skills/recipes.ts +28 -28
- package/src/server.ts +1 -1
- package/src/tools/agent.ts +479 -409
- package/src/tools/ate-exemplar.ts +92 -92
- package/src/tools/ate-flakes.ts +90 -90
- package/src/tools/ate-mutate.ts +103 -103
- package/src/tools/ate-mutation-report.ts +64 -64
- package/src/tools/ate-oracle-pending.ts +49 -49
- package/src/tools/ate-oracle-replay.ts +44 -44
- package/src/tools/ate-oracle-verdict.ts +70 -70
- package/src/tools/ate-prompt.ts +146 -146
- package/src/tools/ate-run.ts +1 -1
- package/src/tools/ate.ts +38 -38
- package/src/tools/brain.ts +6 -6
- package/src/tools/composite.ts +19 -61
- package/src/tools/contract.ts +11 -9
- package/src/tools/deploy-plan.ts +2 -2
- package/src/tools/deploy-preview.ts +316 -316
- package/src/tools/design.ts +825 -825
- package/src/tools/docs.ts +350 -350
- package/src/tools/generate.ts +4 -3
- package/src/tools/guard.ts +1 -1
- package/src/tools/history.ts +1 -1
- package/src/tools/hydration.ts +64 -64
- package/src/tools/index.ts +0 -118
- package/src/tools/kitchen.ts +72 -72
- package/src/tools/lint.ts +226 -226
- package/src/tools/loop-close.ts +175 -175
- package/src/tools/negotiate.ts +263 -263
- package/src/tools/resource.ts +1 -1
- package/src/tools/run-tests.ts +424 -424
- package/src/tools/runtime.ts +1 -1
- package/src/tools/seo.ts +1 -1
- package/src/tools/slot-validation.ts +19 -19
- package/src/tools/spec.ts +201 -201
- package/src/tools/transaction.ts +1 -1
- package/src/tx-lock.ts +73 -73
- package/src/utils/runtime-control.ts +52 -52
- package/src/utils/withWarnings.ts +1 -1
- package/src/resources/skills/mandu-agent-workflow/SKILL.md +0 -124
- package/src/resources/skills/mandu-agent-workflow/metadata.json +0 -7
- package/src/resources/skills/mandu-composition/SKILL.md +0 -131
- package/src/resources/skills/mandu-composition/metadata.json +0 -13
- package/src/resources/skills/mandu-composition/rules/_sections.md +0 -26
- package/src/resources/skills/mandu-composition/rules/_template.md +0 -77
- package/src/resources/skills/mandu-composition/rules/comp-arch-avoid-boolean-props.md +0 -146
- package/src/resources/skills/mandu-composition/rules/comp-arch-compound-components.md +0 -164
- package/src/resources/skills/mandu-composition/rules/comp-island-event.md +0 -161
- package/src/resources/skills/mandu-composition/rules/comp-island-slot-split.md +0 -167
- package/src/resources/skills/mandu-composition/rules/comp-pattern-children.md +0 -149
- package/src/resources/skills/mandu-composition/rules/comp-state-context-interface.md +0 -148
- package/src/resources/skills/mandu-composition/rules/comp-state-lift-state.md +0 -150
- package/src/resources/skills/mandu-deployment/SKILL.md +0 -135
- package/src/resources/skills/mandu-deployment/_sections.md +0 -41
- package/src/resources/skills/mandu-deployment/_template.md +0 -38
- package/src/resources/skills/mandu-deployment/metadata.json +0 -13
- package/src/resources/skills/mandu-deployment/rules/db-provider-supabase.md +0 -300
- package/src/resources/skills/mandu-deployment/rules/deploy-build-bun.md +0 -109
- package/src/resources/skills/mandu-deployment/rules/deploy-build-output.md +0 -115
- package/src/resources/skills/mandu-deployment/rules/deploy-cicd-github.md +0 -219
- package/src/resources/skills/mandu-deployment/rules/deploy-docker-bun.md +0 -150
- package/src/resources/skills/mandu-deployment/rules/deploy-docker-compose.md +0 -223
- package/src/resources/skills/mandu-deployment/rules/deploy-platform-fly.md +0 -152
- package/src/resources/skills/mandu-deployment/rules/deploy-platform-render.md +0 -179
- package/src/resources/skills/mandu-deployment/rules/deploy-platform-vercel.md +0 -140
- package/src/resources/skills/mandu-fs-routes/SKILL.md +0 -122
- package/src/resources/skills/mandu-fs-routes/metadata.json +0 -12
- package/src/resources/skills/mandu-fs-routes/rules/_sections.md +0 -36
- package/src/resources/skills/mandu-fs-routes/rules/_template.md +0 -69
- package/src/resources/skills/mandu-fs-routes/rules/routes-api-methods.md +0 -65
- package/src/resources/skills/mandu-fs-routes/rules/routes-dynamic-param.md +0 -93
- package/src/resources/skills/mandu-fs-routes/rules/routes-naming-page.md +0 -55
- package/src/resources/skills/mandu-guard/SKILL.md +0 -162
- package/src/resources/skills/mandu-guard/metadata.json +0 -12
- package/src/resources/skills/mandu-guard/rules/_sections.md +0 -36
- package/src/resources/skills/mandu-guard/rules/_template.md +0 -82
- package/src/resources/skills/mandu-guard/rules/guard-config-rules.md +0 -100
- package/src/resources/skills/mandu-guard/rules/guard-layer-direction.md +0 -76
- package/src/resources/skills/mandu-guard/rules/guard-preset-mandu.md +0 -81
- package/src/resources/skills/mandu-guard/rules/guard-validate-import.md +0 -80
- package/src/resources/skills/mandu-hydration/SKILL.md +0 -139
- package/src/resources/skills/mandu-hydration/metadata.json +0 -12
- package/src/resources/skills/mandu-hydration/rules/_sections.md +0 -31
- package/src/resources/skills/mandu-hydration/rules/_template.md +0 -72
- package/src/resources/skills/mandu-hydration/rules/hydration-data-event.md +0 -109
- package/src/resources/skills/mandu-hydration/rules/hydration-directive-use-client.md +0 -55
- package/src/resources/skills/mandu-hydration/rules/hydration-island-setup.md +0 -160
- package/src/resources/skills/mandu-hydration/rules/hydration-priority-visible.md +0 -91
- package/src/resources/skills/mandu-performance/SKILL.md +0 -125
- package/src/resources/skills/mandu-performance/metadata.json +0 -14
- package/src/resources/skills/mandu-performance/rules/_sections.md +0 -31
- package/src/resources/skills/mandu-performance/rules/_template.md +0 -64
- package/src/resources/skills/mandu-performance/rules/perf-async-defer-await.md +0 -103
- package/src/resources/skills/mandu-performance/rules/perf-async-parallel.md +0 -95
- package/src/resources/skills/mandu-performance/rules/perf-bun-file.md +0 -124
- package/src/resources/skills/mandu-performance/rules/perf-bun-serve.md +0 -125
- package/src/resources/skills/mandu-performance/rules/perf-bundle-imports.md +0 -80
- package/src/resources/skills/mandu-performance/rules/perf-bundle-island-lazy.md +0 -145
- package/src/resources/skills/mandu-performance/rules/perf-cache-react.md +0 -98
- package/src/resources/skills/mandu-performance/rules/perf-render-transitions.md +0 -154
- package/src/resources/skills/mandu-security/SKILL.md +0 -127
- package/src/resources/skills/mandu-security/metadata.json +0 -13
- package/src/resources/skills/mandu-security/rules/_sections.md +0 -31
- package/src/resources/skills/mandu-security/rules/_template.md +0 -74
- package/src/resources/skills/mandu-security/rules/sec-auth-guard.md +0 -127
- package/src/resources/skills/mandu-security/rules/sec-env-management.md +0 -133
- package/src/resources/skills/mandu-security/rules/sec-input-validate.md +0 -148
- package/src/resources/skills/mandu-security/rules/sec-protect-csrf.md +0 -146
- package/src/resources/skills/mandu-security/rules/sec-protect-headers.md +0 -138
- package/src/resources/skills/mandu-slot/SKILL.md +0 -125
- package/src/resources/skills/mandu-slot/metadata.json +0 -12
- package/src/resources/skills/mandu-slot/rules/_sections.md +0 -36
- package/src/resources/skills/mandu-slot/rules/_template.md +0 -63
- package/src/resources/skills/mandu-slot/rules/slot-basic-structure.md +0 -38
- package/src/resources/skills/mandu-slot/rules/slot-ctx-response.md +0 -56
- package/src/resources/skills/mandu-slot/rules/slot-guard-auth.md +0 -59
- package/src/resources/skills/mandu-slot/rules/slot-http-methods.md +0 -64
- package/src/resources/skills/mandu-styling/SKILL.md +0 -196
- package/src/resources/skills/mandu-styling/_sections.md +0 -43
- package/src/resources/skills/mandu-styling/_template.md +0 -32
- package/src/resources/skills/mandu-styling/metadata.json +0 -15
- package/src/resources/skills/mandu-styling/rules/style-component-compound.md +0 -235
- package/src/resources/skills/mandu-styling/rules/style-component-slots.md +0 -255
- package/src/resources/skills/mandu-styling/rules/style-component-tokens.md +0 -205
- package/src/resources/skills/mandu-styling/rules/style-island-animations.md +0 -272
- package/src/resources/skills/mandu-styling/rules/style-island-scoping.md +0 -167
- package/src/resources/skills/mandu-styling/rules/style-island-variants.md +0 -221
- package/src/resources/skills/mandu-styling/rules/style-perf-critical.md +0 -209
- package/src/resources/skills/mandu-styling/rules/style-perf-purge.md +0 -192
- package/src/resources/skills/mandu-styling/rules/style-setup-modules.md +0 -162
- package/src/resources/skills/mandu-styling/rules/style-setup-panda.md +0 -164
- package/src/resources/skills/mandu-styling/rules/style-setup-tailwind.md +0 -170
- package/src/resources/skills/mandu-styling/rules/style-tailwind-v4-gotchas.md +0 -179
- package/src/resources/skills/mandu-styling/rules/style-theme-darkmode.md +0 -229
- package/src/resources/skills/mandu-testing/SKILL.md +0 -132
- package/src/resources/skills/mandu-testing/metadata.json +0 -13
- package/src/resources/skills/mandu-testing/rules/_sections.md +0 -26
- package/src/resources/skills/mandu-testing/rules/_template.md +0 -65
- package/src/resources/skills/mandu-testing/rules/test-component-island.md +0 -195
- package/src/resources/skills/mandu-testing/rules/test-e2e-playwright.md +0 -196
- package/src/resources/skills/mandu-testing/rules/test-mock-fetch.md +0 -219
- package/src/resources/skills/mandu-testing/rules/test-slot-unit.md +0 -192
- package/src/resources/skills/mandu-ui/SKILL.md +0 -159
- package/src/resources/skills/mandu-ui/_sections.md +0 -23
- package/src/resources/skills/mandu-ui/_template.md +0 -32
- package/src/resources/skills/mandu-ui/metadata.json +0 -13
- package/src/resources/skills/mandu-ui/rules/ui-accessibility-aria.md +0 -232
- package/src/resources/skills/mandu-ui/rules/ui-accessibility-focus.md +0 -238
- package/src/resources/skills/mandu-ui/rules/ui-composition-patterns.md +0 -259
- package/src/resources/skills/mandu-ui/rules/ui-island-integration.md +0 -258
- package/src/resources/skills/mandu-ui/rules/ui-radix-patterns.md +0 -213
- 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
|
-
```
|