@mandujs/mcp 0.12.2 → 0.13.0
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 +367 -367
- package/package.json +2 -2
- package/src/activity-monitor.ts +847 -847
- package/src/adapters/index.ts +20 -20
- package/src/adapters/monitor-adapter.ts +100 -100
- package/src/adapters/tool-adapter.ts +88 -88
- package/src/executor/error-handler.ts +250 -250
- package/src/executor/index.ts +22 -22
- package/src/executor/tool-executor.ts +148 -148
- package/src/hooks/config-watcher.ts +174 -174
- package/src/hooks/index.ts +23 -23
- package/src/hooks/mcp-hooks.ts +227 -227
- package/src/index.ts +106 -106
- package/src/logging/index.ts +15 -15
- package/src/logging/mcp-transport.ts +134 -134
- package/src/registry/index.ts +13 -13
- package/src/registry/mcp-tool-registry.ts +298 -298
- package/src/resources/skills/guides.ts +1136 -1136
- package/src/resources/skills/index.ts +12 -12
- package/src/resources/skills/loader.ts +218 -218
- package/src/resources/skills/mandu-composition/SKILL.md +91 -91
- package/src/resources/skills/mandu-composition/metadata.json +13 -13
- package/src/resources/skills/mandu-composition/rules/_sections.md +26 -26
- package/src/resources/skills/mandu-composition/rules/_template.md +77 -77
- package/src/resources/skills/mandu-composition/rules/comp-arch-avoid-boolean-props.md +146 -146
- package/src/resources/skills/mandu-composition/rules/comp-arch-compound-components.md +164 -164
- package/src/resources/skills/mandu-composition/rules/comp-island-event.md +161 -161
- package/src/resources/skills/mandu-composition/rules/comp-island-slot-split.md +167 -167
- package/src/resources/skills/mandu-composition/rules/comp-pattern-children.md +149 -149
- package/src/resources/skills/mandu-composition/rules/comp-state-context-interface.md +148 -148
- package/src/resources/skills/mandu-composition/rules/comp-state-lift-state.md +150 -150
- package/src/resources/skills/mandu-deployment/SKILL.md +92 -92
- package/src/resources/skills/mandu-deployment/_sections.md +41 -41
- package/src/resources/skills/mandu-deployment/_template.md +38 -38
- package/src/resources/skills/mandu-deployment/metadata.json +13 -13
- package/src/resources/skills/mandu-deployment/rules/deploy-build-bun.md +109 -109
- package/src/resources/skills/mandu-deployment/rules/deploy-build-output.md +115 -115
- package/src/resources/skills/mandu-deployment/rules/deploy-cicd-github.md +219 -219
- package/src/resources/skills/mandu-deployment/rules/deploy-docker-bun.md +150 -150
- package/src/resources/skills/mandu-deployment/rules/deploy-docker-compose.md +223 -223
- package/src/resources/skills/mandu-deployment/rules/deploy-platform-fly.md +152 -152
- package/src/resources/skills/mandu-deployment/rules/deploy-platform-render.md +179 -179
- package/src/resources/skills/mandu-deployment/rules/deploy-platform-supabase.md +323 -323
- package/src/resources/skills/mandu-deployment/rules/deploy-platform-vercel.md +140 -140
- package/src/resources/skills/mandu-fs-routes/SKILL.md +82 -82
- package/src/resources/skills/mandu-fs-routes/metadata.json +12 -12
- package/src/resources/skills/mandu-fs-routes/rules/_sections.md +36 -36
- package/src/resources/skills/mandu-fs-routes/rules/_template.md +69 -69
- package/src/resources/skills/mandu-fs-routes/rules/routes-api-methods.md +65 -65
- package/src/resources/skills/mandu-fs-routes/rules/routes-dynamic-param.md +93 -93
- package/src/resources/skills/mandu-fs-routes/rules/routes-naming-page.md +55 -55
- package/src/resources/skills/mandu-guard/SKILL.md +129 -129
- package/src/resources/skills/mandu-guard/metadata.json +12 -12
- package/src/resources/skills/mandu-guard/rules/_sections.md +36 -36
- package/src/resources/skills/mandu-guard/rules/_template.md +82 -82
- package/src/resources/skills/mandu-guard/rules/guard-config-rules.md +100 -100
- package/src/resources/skills/mandu-guard/rules/guard-layer-direction.md +76 -76
- package/src/resources/skills/mandu-guard/rules/guard-preset-mandu.md +81 -81
- package/src/resources/skills/mandu-guard/rules/guard-validate-import.md +80 -80
- package/src/resources/skills/mandu-hydration/SKILL.md +91 -91
- package/src/resources/skills/mandu-hydration/metadata.json +12 -12
- package/src/resources/skills/mandu-hydration/rules/_sections.md +31 -31
- package/src/resources/skills/mandu-hydration/rules/_template.md +72 -72
- package/src/resources/skills/mandu-hydration/rules/hydration-data-event.md +109 -109
- package/src/resources/skills/mandu-hydration/rules/hydration-directive-use-client.md +55 -55
- package/src/resources/skills/mandu-hydration/rules/hydration-island-setup.md +113 -113
- package/src/resources/skills/mandu-hydration/rules/hydration-priority-visible.md +68 -68
- package/src/resources/skills/mandu-performance/SKILL.md +85 -85
- package/src/resources/skills/mandu-performance/metadata.json +14 -14
- package/src/resources/skills/mandu-performance/rules/_sections.md +31 -31
- package/src/resources/skills/mandu-performance/rules/_template.md +64 -64
- package/src/resources/skills/mandu-performance/rules/perf-async-defer-await.md +103 -103
- package/src/resources/skills/mandu-performance/rules/perf-async-parallel.md +95 -95
- package/src/resources/skills/mandu-performance/rules/perf-bun-file.md +124 -124
- package/src/resources/skills/mandu-performance/rules/perf-bun-serve.md +125 -125
- package/src/resources/skills/mandu-performance/rules/perf-bundle-imports.md +80 -80
- package/src/resources/skills/mandu-performance/rules/perf-bundle-island-lazy.md +145 -145
- package/src/resources/skills/mandu-performance/rules/perf-cache-react.md +98 -98
- package/src/resources/skills/mandu-performance/rules/perf-render-transitions.md +154 -154
- package/src/resources/skills/mandu-security/SKILL.md +87 -87
- package/src/resources/skills/mandu-security/metadata.json +13 -13
- package/src/resources/skills/mandu-security/rules/_sections.md +31 -31
- package/src/resources/skills/mandu-security/rules/_template.md +74 -74
- package/src/resources/skills/mandu-security/rules/sec-auth-guard.md +127 -127
- package/src/resources/skills/mandu-security/rules/sec-env-management.md +133 -133
- package/src/resources/skills/mandu-security/rules/sec-input-validate.md +148 -148
- package/src/resources/skills/mandu-security/rules/sec-protect-csrf.md +146 -146
- package/src/resources/skills/mandu-security/rules/sec-protect-headers.md +138 -138
- package/src/resources/skills/mandu-slot/SKILL.md +85 -85
- package/src/resources/skills/mandu-slot/metadata.json +12 -12
- package/src/resources/skills/mandu-slot/rules/_sections.md +36 -36
- package/src/resources/skills/mandu-slot/rules/_template.md +63 -63
- package/src/resources/skills/mandu-slot/rules/slot-basic-structure.md +38 -38
- package/src/resources/skills/mandu-slot/rules/slot-ctx-response.md +56 -56
- package/src/resources/skills/mandu-slot/rules/slot-guard-auth.md +59 -59
- package/src/resources/skills/mandu-slot/rules/slot-http-methods.md +64 -64
- package/src/resources/skills/mandu-styling/SKILL.md +154 -154
- package/src/resources/skills/mandu-styling/_sections.md +43 -43
- package/src/resources/skills/mandu-styling/_template.md +32 -32
- package/src/resources/skills/mandu-styling/metadata.json +15 -15
- package/src/resources/skills/mandu-styling/rules/style-component-compound.md +235 -235
- package/src/resources/skills/mandu-styling/rules/style-component-slots.md +255 -255
- package/src/resources/skills/mandu-styling/rules/style-component-tokens.md +205 -205
- package/src/resources/skills/mandu-styling/rules/style-island-animations.md +272 -272
- package/src/resources/skills/mandu-styling/rules/style-island-scoping.md +167 -167
- package/src/resources/skills/mandu-styling/rules/style-island-variants.md +221 -221
- package/src/resources/skills/mandu-styling/rules/style-perf-critical.md +209 -209
- package/src/resources/skills/mandu-styling/rules/style-perf-purge.md +192 -192
- package/src/resources/skills/mandu-styling/rules/style-setup-modules.md +162 -162
- package/src/resources/skills/mandu-styling/rules/style-setup-panda.md +164 -164
- package/src/resources/skills/mandu-styling/rules/style-setup-tailwind.md +170 -170
- package/src/resources/skills/mandu-styling/rules/style-tailwind-v4-gotchas.md +179 -179
- package/src/resources/skills/mandu-styling/rules/style-theme-darkmode.md +229 -229
- package/src/resources/skills/mandu-testing/SKILL.md +99 -99
- package/src/resources/skills/mandu-testing/metadata.json +13 -13
- package/src/resources/skills/mandu-testing/rules/_sections.md +26 -26
- package/src/resources/skills/mandu-testing/rules/_template.md +65 -65
- package/src/resources/skills/mandu-testing/rules/test-component-island.md +195 -195
- package/src/resources/skills/mandu-testing/rules/test-e2e-playwright.md +196 -196
- package/src/resources/skills/mandu-testing/rules/test-mock-fetch.md +219 -219
- package/src/resources/skills/mandu-testing/rules/test-slot-unit.md +192 -192
- package/src/resources/skills/mandu-ui/SKILL.md +117 -117
- package/src/resources/skills/mandu-ui/_sections.md +23 -23
- package/src/resources/skills/mandu-ui/_template.md +32 -32
- package/src/resources/skills/mandu-ui/metadata.json +13 -13
- package/src/resources/skills/mandu-ui/rules/ui-accessibility-aria.md +232 -232
- package/src/resources/skills/mandu-ui/rules/ui-accessibility-focus.md +238 -238
- package/src/resources/skills/mandu-ui/rules/ui-composition-patterns.md +259 -259
- package/src/resources/skills/mandu-ui/rules/ui-island-integration.md +258 -258
- package/src/resources/skills/mandu-ui/rules/ui-radix-patterns.md +213 -213
- package/src/resources/skills/mandu-ui/rules/ui-shadcn-setup.md +209 -209
- package/src/resources/skills/recipes.ts +932 -932
- package/src/tools/generate.ts +7 -4
- package/src/tools/guard.ts +17 -4
- package/src/tools/hydration.ts +10 -10
- package/src/tools/project.ts +334 -334
- package/src/tools/runtime.ts +497 -497
- package/src/tools/seo.ts +417 -417
- package/src/tools/spec.ts +80 -159
- package/src/utils/project.ts +22 -12
- package/src/utils/withWarnings.ts +83 -83
|
@@ -1,138 +1,138 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: Configure Security Headers
|
|
3
|
-
impact: HIGH
|
|
4
|
-
impactDescription: Enables browser security features
|
|
5
|
-
tags: security, headers, csp, hsts
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
## Configure Security Headers
|
|
9
|
-
|
|
10
|
-
**Impact: HIGH (Enables browser security features)**
|
|
11
|
-
|
|
12
|
-
보안 헤더를 설정하여 브라우저의 보안 기능을 활성화하세요.
|
|
13
|
-
|
|
14
|
-
**기본 보안 헤더 설정:**
|
|
15
|
-
|
|
16
|
-
```typescript
|
|
17
|
-
// middleware/security.ts
|
|
18
|
-
export function securityHeaders(ctx: Context) {
|
|
19
|
-
// XSS 필터 활성화
|
|
20
|
-
ctx.header("X-XSS-Protection", "1; mode=block");
|
|
21
|
-
|
|
22
|
-
// MIME 타입 스니핑 방지
|
|
23
|
-
ctx.header("X-Content-Type-Options", "nosniff");
|
|
24
|
-
|
|
25
|
-
// Clickjacking 방지
|
|
26
|
-
ctx.header("X-Frame-Options", "DENY");
|
|
27
|
-
|
|
28
|
-
// Referrer 정보 제한
|
|
29
|
-
ctx.header("Referrer-Policy", "strict-origin-when-cross-origin");
|
|
30
|
-
|
|
31
|
-
// HTTPS 강제 (프로덕션)
|
|
32
|
-
if (process.env.NODE_ENV === "production") {
|
|
33
|
-
ctx.header("Strict-Transport-Security", "max-age=31536000; includeSubDomains");
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
## Content Security Policy (CSP)
|
|
39
|
-
|
|
40
|
-
```typescript
|
|
41
|
-
// 엄격한 CSP 설정
|
|
42
|
-
const csp = [
|
|
43
|
-
"default-src 'self'",
|
|
44
|
-
"script-src 'self' 'unsafe-inline'", // Island hydration 필요
|
|
45
|
-
"style-src 'self' 'unsafe-inline'",
|
|
46
|
-
"img-src 'self' data: https:",
|
|
47
|
-
"font-src 'self'",
|
|
48
|
-
"connect-src 'self' https://api.example.com",
|
|
49
|
-
"frame-ancestors 'none'",
|
|
50
|
-
"base-uri 'self'",
|
|
51
|
-
"form-action 'self'",
|
|
52
|
-
].join("; ");
|
|
53
|
-
|
|
54
|
-
ctx.header("Content-Security-Policy", csp);
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
## Nonce 기반 CSP (더 안전)
|
|
58
|
-
|
|
59
|
-
```typescript
|
|
60
|
-
// 요청마다 새 nonce 생성
|
|
61
|
-
import { randomBytes } from "crypto";
|
|
62
|
-
|
|
63
|
-
export function createCspNonce(): string {
|
|
64
|
-
return randomBytes(16).toString("base64");
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// 미들웨어에서 설정
|
|
68
|
-
const nonce = createCspNonce();
|
|
69
|
-
ctx.set("cspNonce", nonce);
|
|
70
|
-
|
|
71
|
-
const csp = [
|
|
72
|
-
"default-src 'self'",
|
|
73
|
-
`script-src 'self' 'nonce-${nonce}'`, // nonce가 있는 스크립트만 허용
|
|
74
|
-
"style-src 'self' 'unsafe-inline'",
|
|
75
|
-
// ...
|
|
76
|
-
].join("; ");
|
|
77
|
-
|
|
78
|
-
ctx.header("Content-Security-Policy", csp);
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
```html
|
|
82
|
-
<!-- HTML에서 nonce 사용 -->
|
|
83
|
-
<script nonce="${nonce}">
|
|
84
|
-
// 이 스크립트만 실행됨
|
|
85
|
-
</script>
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
## Permissions Policy
|
|
89
|
-
|
|
90
|
-
```typescript
|
|
91
|
-
// 브라우저 기능 제한
|
|
92
|
-
const permissions = [
|
|
93
|
-
"camera=()", // 카메라 비활성화
|
|
94
|
-
"microphone=()", // 마이크 비활성화
|
|
95
|
-
"geolocation=(self)", // 지오로케이션은 자체 도메인만
|
|
96
|
-
"payment=(self)", // 결제는 자체 도메인만
|
|
97
|
-
].join(", ");
|
|
98
|
-
|
|
99
|
-
ctx.header("Permissions-Policy", permissions);
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
## 전체 보안 헤더 미들웨어
|
|
103
|
-
|
|
104
|
-
```typescript
|
|
105
|
-
// middleware/security.ts
|
|
106
|
-
export function applySecurityHeaders(ctx: Context) {
|
|
107
|
-
const headers = {
|
|
108
|
-
"X-XSS-Protection": "1; mode=block",
|
|
109
|
-
"X-Content-Type-Options": "nosniff",
|
|
110
|
-
"X-Frame-Options": "DENY",
|
|
111
|
-
"Referrer-Policy": "strict-origin-when-cross-origin",
|
|
112
|
-
"Permissions-Policy": "camera=(), microphone=(), geolocation=(self)",
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
// 프로덕션 전용
|
|
116
|
-
if (process.env.NODE_ENV === "production") {
|
|
117
|
-
headers["Strict-Transport-Security"] = "max-age=31536000; includeSubDomains; preload";
|
|
118
|
-
headers["Content-Security-Policy"] = buildCsp();
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
Object.entries(headers).forEach(([key, value]) => {
|
|
122
|
-
ctx.header(key, value);
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
## 검증 도구
|
|
128
|
-
|
|
129
|
-
```bash
|
|
130
|
-
# 헤더 확인
|
|
131
|
-
curl -I https://your-site.com
|
|
132
|
-
|
|
133
|
-
# 보안 헤더 스캔
|
|
134
|
-
# https://securityheaders.com
|
|
135
|
-
# https://observatory.mozilla.org
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
Reference: [OWASP Secure Headers](https://owasp.org/www-project-secure-headers/)
|
|
1
|
+
---
|
|
2
|
+
title: Configure Security Headers
|
|
3
|
+
impact: HIGH
|
|
4
|
+
impactDescription: Enables browser security features
|
|
5
|
+
tags: security, headers, csp, hsts
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Configure Security Headers
|
|
9
|
+
|
|
10
|
+
**Impact: HIGH (Enables browser security features)**
|
|
11
|
+
|
|
12
|
+
보안 헤더를 설정하여 브라우저의 보안 기능을 활성화하세요.
|
|
13
|
+
|
|
14
|
+
**기본 보안 헤더 설정:**
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
// middleware/security.ts
|
|
18
|
+
export function securityHeaders(ctx: Context) {
|
|
19
|
+
// XSS 필터 활성화
|
|
20
|
+
ctx.header("X-XSS-Protection", "1; mode=block");
|
|
21
|
+
|
|
22
|
+
// MIME 타입 스니핑 방지
|
|
23
|
+
ctx.header("X-Content-Type-Options", "nosniff");
|
|
24
|
+
|
|
25
|
+
// Clickjacking 방지
|
|
26
|
+
ctx.header("X-Frame-Options", "DENY");
|
|
27
|
+
|
|
28
|
+
// Referrer 정보 제한
|
|
29
|
+
ctx.header("Referrer-Policy", "strict-origin-when-cross-origin");
|
|
30
|
+
|
|
31
|
+
// HTTPS 강제 (프로덕션)
|
|
32
|
+
if (process.env.NODE_ENV === "production") {
|
|
33
|
+
ctx.header("Strict-Transport-Security", "max-age=31536000; includeSubDomains");
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Content Security Policy (CSP)
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
// 엄격한 CSP 설정
|
|
42
|
+
const csp = [
|
|
43
|
+
"default-src 'self'",
|
|
44
|
+
"script-src 'self' 'unsafe-inline'", // Island hydration 필요
|
|
45
|
+
"style-src 'self' 'unsafe-inline'",
|
|
46
|
+
"img-src 'self' data: https:",
|
|
47
|
+
"font-src 'self'",
|
|
48
|
+
"connect-src 'self' https://api.example.com",
|
|
49
|
+
"frame-ancestors 'none'",
|
|
50
|
+
"base-uri 'self'",
|
|
51
|
+
"form-action 'self'",
|
|
52
|
+
].join("; ");
|
|
53
|
+
|
|
54
|
+
ctx.header("Content-Security-Policy", csp);
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Nonce 기반 CSP (더 안전)
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
// 요청마다 새 nonce 생성
|
|
61
|
+
import { randomBytes } from "crypto";
|
|
62
|
+
|
|
63
|
+
export function createCspNonce(): string {
|
|
64
|
+
return randomBytes(16).toString("base64");
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// 미들웨어에서 설정
|
|
68
|
+
const nonce = createCspNonce();
|
|
69
|
+
ctx.set("cspNonce", nonce);
|
|
70
|
+
|
|
71
|
+
const csp = [
|
|
72
|
+
"default-src 'self'",
|
|
73
|
+
`script-src 'self' 'nonce-${nonce}'`, // nonce가 있는 스크립트만 허용
|
|
74
|
+
"style-src 'self' 'unsafe-inline'",
|
|
75
|
+
// ...
|
|
76
|
+
].join("; ");
|
|
77
|
+
|
|
78
|
+
ctx.header("Content-Security-Policy", csp);
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
```html
|
|
82
|
+
<!-- HTML에서 nonce 사용 -->
|
|
83
|
+
<script nonce="${nonce}">
|
|
84
|
+
// 이 스크립트만 실행됨
|
|
85
|
+
</script>
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Permissions Policy
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
// 브라우저 기능 제한
|
|
92
|
+
const permissions = [
|
|
93
|
+
"camera=()", // 카메라 비활성화
|
|
94
|
+
"microphone=()", // 마이크 비활성화
|
|
95
|
+
"geolocation=(self)", // 지오로케이션은 자체 도메인만
|
|
96
|
+
"payment=(self)", // 결제는 자체 도메인만
|
|
97
|
+
].join(", ");
|
|
98
|
+
|
|
99
|
+
ctx.header("Permissions-Policy", permissions);
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## 전체 보안 헤더 미들웨어
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
// middleware/security.ts
|
|
106
|
+
export function applySecurityHeaders(ctx: Context) {
|
|
107
|
+
const headers = {
|
|
108
|
+
"X-XSS-Protection": "1; mode=block",
|
|
109
|
+
"X-Content-Type-Options": "nosniff",
|
|
110
|
+
"X-Frame-Options": "DENY",
|
|
111
|
+
"Referrer-Policy": "strict-origin-when-cross-origin",
|
|
112
|
+
"Permissions-Policy": "camera=(), microphone=(), geolocation=(self)",
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
// 프로덕션 전용
|
|
116
|
+
if (process.env.NODE_ENV === "production") {
|
|
117
|
+
headers["Strict-Transport-Security"] = "max-age=31536000; includeSubDomains; preload";
|
|
118
|
+
headers["Content-Security-Policy"] = buildCsp();
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
Object.entries(headers).forEach(([key, value]) => {
|
|
122
|
+
ctx.header(key, value);
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## 검증 도구
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
# 헤더 확인
|
|
131
|
+
curl -I https://your-site.com
|
|
132
|
+
|
|
133
|
+
# 보안 헤더 스캔
|
|
134
|
+
# https://securityheaders.com
|
|
135
|
+
# https://observatory.mozilla.org
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Reference: [OWASP Secure Headers](https://owasp.org/www-project-secure-headers/)
|
|
@@ -1,85 +1,85 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: mandu-slot
|
|
3
|
-
description: |
|
|
4
|
-
Mandu Slot API for writing business logic. Use when creating API handlers,
|
|
5
|
-
implementing authentication guards, adding lifecycle hooks, or working with
|
|
6
|
-
request/response context. Triggers on tasks involving Mandu.filling(),
|
|
7
|
-
ctx.ok(), ctx.error(), .guard(), .get(), .post(), or slot files.
|
|
8
|
-
license: MIT
|
|
9
|
-
metadata:
|
|
10
|
-
author: mandu
|
|
11
|
-
version: "1.0.0"
|
|
12
|
-
---
|
|
13
|
-
|
|
14
|
-
# Mandu Slot
|
|
15
|
-
|
|
16
|
-
Slot은 비즈니스 로직을 작성하는 파일입니다. `Mandu.filling()` API를 사용하여
|
|
17
|
-
API 핸들러, 인증 가드, 라이프사이클 훅을 구현합니다.
|
|
18
|
-
|
|
19
|
-
## When to Apply
|
|
20
|
-
|
|
21
|
-
Reference these guidelines when:
|
|
22
|
-
- Creating new API endpoints with business logic
|
|
23
|
-
- Implementing authentication or authorization
|
|
24
|
-
- Adding request/response lifecycle hooks
|
|
25
|
-
- Working with request body, params, or query
|
|
26
|
-
- Handling errors and responses
|
|
27
|
-
|
|
28
|
-
## Rule Categories by Priority
|
|
29
|
-
|
|
30
|
-
| Priority | Category | Impact | Prefix |
|
|
31
|
-
|----------|----------|--------|--------|
|
|
32
|
-
| 1 | Basic Structure | CRITICAL | `slot-basic-` |
|
|
33
|
-
| 2 | HTTP Methods | HIGH | `slot-http-` |
|
|
34
|
-
| 3 | Context API | HIGH | `slot-ctx-` |
|
|
35
|
-
| 4 | Guard Pattern | MEDIUM | `slot-guard-` |
|
|
36
|
-
| 5 | Lifecycle Hooks | MEDIUM | `slot-lifecycle-` |
|
|
37
|
-
|
|
38
|
-
## Quick Reference
|
|
39
|
-
|
|
40
|
-
### 1. Basic Structure (CRITICAL)
|
|
41
|
-
|
|
42
|
-
- `slot-basic-structure` - Always use Mandu.filling() as default export
|
|
43
|
-
- `slot-basic-location` - Place slot files in spec/slots/ directory
|
|
44
|
-
|
|
45
|
-
### 2. HTTP Methods (HIGH)
|
|
46
|
-
|
|
47
|
-
- `slot-http-get` - Use .get() for read operations
|
|
48
|
-
- `slot-http-post` - Use .post() for create operations
|
|
49
|
-
- `slot-http-put-patch` - Use .put()/.patch() for updates
|
|
50
|
-
- `slot-http-delete` - Use .delete() for removal
|
|
51
|
-
|
|
52
|
-
### 3. Context API (HIGH)
|
|
53
|
-
|
|
54
|
-
- `slot-ctx-response` - Use ctx.ok(), ctx.created(), ctx.error() for responses
|
|
55
|
-
- `slot-ctx-body` - Use ctx.body<T>() for typed request body
|
|
56
|
-
- `slot-ctx-params` - Use ctx.params for route parameters
|
|
57
|
-
- `slot-ctx-state` - Use ctx.set()/ctx.get() for request state
|
|
58
|
-
|
|
59
|
-
### 4. Guard Pattern (MEDIUM)
|
|
60
|
-
|
|
61
|
-
- `slot-guard-auth` - Use .guard() for authentication checks
|
|
62
|
-
- `slot-guard-early-return` - Return response to block, void to continue
|
|
63
|
-
|
|
64
|
-
### 5. Lifecycle Hooks (MEDIUM)
|
|
65
|
-
|
|
66
|
-
- `slot-lifecycle-request` - Use .onRequest() for request initialization
|
|
67
|
-
- `slot-lifecycle-after` - Use .afterHandle() for response modification
|
|
68
|
-
- `slot-lifecycle-middleware` - Use .middleware() for Koa-style chains
|
|
69
|
-
|
|
70
|
-
## How to Use
|
|
71
|
-
|
|
72
|
-
Read individual rule files for detailed explanations:
|
|
73
|
-
|
|
74
|
-
```
|
|
75
|
-
rules/slot-basic-structure.md
|
|
76
|
-
rules/slot-ctx-response.md
|
|
77
|
-
rules/slot-guard-auth.md
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
## File Location
|
|
81
|
-
|
|
82
|
-
```
|
|
83
|
-
spec/slots/{name}.slot.ts # Server logic
|
|
84
|
-
spec/slots/{name}.client.ts # Client logic (Island)
|
|
85
|
-
```
|
|
1
|
+
---
|
|
2
|
+
name: mandu-slot
|
|
3
|
+
description: |
|
|
4
|
+
Mandu Slot API for writing business logic. Use when creating API handlers,
|
|
5
|
+
implementing authentication guards, adding lifecycle hooks, or working with
|
|
6
|
+
request/response context. Triggers on tasks involving Mandu.filling(),
|
|
7
|
+
ctx.ok(), ctx.error(), .guard(), .get(), .post(), or slot files.
|
|
8
|
+
license: MIT
|
|
9
|
+
metadata:
|
|
10
|
+
author: mandu
|
|
11
|
+
version: "1.0.0"
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# Mandu Slot
|
|
15
|
+
|
|
16
|
+
Slot은 비즈니스 로직을 작성하는 파일입니다. `Mandu.filling()` API를 사용하여
|
|
17
|
+
API 핸들러, 인증 가드, 라이프사이클 훅을 구현합니다.
|
|
18
|
+
|
|
19
|
+
## When to Apply
|
|
20
|
+
|
|
21
|
+
Reference these guidelines when:
|
|
22
|
+
- Creating new API endpoints with business logic
|
|
23
|
+
- Implementing authentication or authorization
|
|
24
|
+
- Adding request/response lifecycle hooks
|
|
25
|
+
- Working with request body, params, or query
|
|
26
|
+
- Handling errors and responses
|
|
27
|
+
|
|
28
|
+
## Rule Categories by Priority
|
|
29
|
+
|
|
30
|
+
| Priority | Category | Impact | Prefix |
|
|
31
|
+
|----------|----------|--------|--------|
|
|
32
|
+
| 1 | Basic Structure | CRITICAL | `slot-basic-` |
|
|
33
|
+
| 2 | HTTP Methods | HIGH | `slot-http-` |
|
|
34
|
+
| 3 | Context API | HIGH | `slot-ctx-` |
|
|
35
|
+
| 4 | Guard Pattern | MEDIUM | `slot-guard-` |
|
|
36
|
+
| 5 | Lifecycle Hooks | MEDIUM | `slot-lifecycle-` |
|
|
37
|
+
|
|
38
|
+
## Quick Reference
|
|
39
|
+
|
|
40
|
+
### 1. Basic Structure (CRITICAL)
|
|
41
|
+
|
|
42
|
+
- `slot-basic-structure` - Always use Mandu.filling() as default export
|
|
43
|
+
- `slot-basic-location` - Place slot files in spec/slots/ directory
|
|
44
|
+
|
|
45
|
+
### 2. HTTP Methods (HIGH)
|
|
46
|
+
|
|
47
|
+
- `slot-http-get` - Use .get() for read operations
|
|
48
|
+
- `slot-http-post` - Use .post() for create operations
|
|
49
|
+
- `slot-http-put-patch` - Use .put()/.patch() for updates
|
|
50
|
+
- `slot-http-delete` - Use .delete() for removal
|
|
51
|
+
|
|
52
|
+
### 3. Context API (HIGH)
|
|
53
|
+
|
|
54
|
+
- `slot-ctx-response` - Use ctx.ok(), ctx.created(), ctx.error() for responses
|
|
55
|
+
- `slot-ctx-body` - Use ctx.body<T>() for typed request body
|
|
56
|
+
- `slot-ctx-params` - Use ctx.params for route parameters
|
|
57
|
+
- `slot-ctx-state` - Use ctx.set()/ctx.get() for request state
|
|
58
|
+
|
|
59
|
+
### 4. Guard Pattern (MEDIUM)
|
|
60
|
+
|
|
61
|
+
- `slot-guard-auth` - Use .guard() for authentication checks
|
|
62
|
+
- `slot-guard-early-return` - Return response to block, void to continue
|
|
63
|
+
|
|
64
|
+
### 5. Lifecycle Hooks (MEDIUM)
|
|
65
|
+
|
|
66
|
+
- `slot-lifecycle-request` - Use .onRequest() for request initialization
|
|
67
|
+
- `slot-lifecycle-after` - Use .afterHandle() for response modification
|
|
68
|
+
- `slot-lifecycle-middleware` - Use .middleware() for Koa-style chains
|
|
69
|
+
|
|
70
|
+
## How to Use
|
|
71
|
+
|
|
72
|
+
Read individual rule files for detailed explanations:
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
rules/slot-basic-structure.md
|
|
76
|
+
rules/slot-ctx-response.md
|
|
77
|
+
rules/slot-guard-auth.md
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## File Location
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
spec/slots/{name}.slot.ts # Server logic
|
|
84
|
+
spec/slots/{name}.client.ts # Client logic (Island)
|
|
85
|
+
```
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": "1.0.0",
|
|
3
|
-
"organization": "Mandu Framework",
|
|
4
|
-
"date": "February 2026",
|
|
5
|
-
"abstract": "Mandu Slot API를 사용한 비즈니스 로직 작성 가이드. Mandu.filling()을 통한 HTTP 핸들러 정의, ctx 응답 메서드, guard 인증, 라이프사이클 훅을 다룹니다. 4개 카테고리의 규칙으로 구성되어 있으며, 에이전트가 올바른 slot 코드를 생성할 수 있도록 안내합니다.",
|
|
6
|
-
"references": [
|
|
7
|
-
"https://github.com/aspect-build/rules_esbuild",
|
|
8
|
-
"https://bun.sh/docs/api/http",
|
|
9
|
-
"https://hono.dev/concepts/context"
|
|
10
|
-
],
|
|
11
|
-
"tags": ["slot", "api", "business-logic", "mandu"]
|
|
12
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"version": "1.0.0",
|
|
3
|
+
"organization": "Mandu Framework",
|
|
4
|
+
"date": "February 2026",
|
|
5
|
+
"abstract": "Mandu Slot API를 사용한 비즈니스 로직 작성 가이드. Mandu.filling()을 통한 HTTP 핸들러 정의, ctx 응답 메서드, guard 인증, 라이프사이클 훅을 다룹니다. 4개 카테고리의 규칙으로 구성되어 있으며, 에이전트가 올바른 slot 코드를 생성할 수 있도록 안내합니다.",
|
|
6
|
+
"references": [
|
|
7
|
+
"https://github.com/aspect-build/rules_esbuild",
|
|
8
|
+
"https://bun.sh/docs/api/http",
|
|
9
|
+
"https://hono.dev/concepts/context"
|
|
10
|
+
],
|
|
11
|
+
"tags": ["slot", "api", "business-logic", "mandu"]
|
|
12
|
+
}
|
|
@@ -1,36 +1,36 @@
|
|
|
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. Basic Structure (slot-basic)
|
|
9
|
-
|
|
10
|
-
**Impact:** CRITICAL
|
|
11
|
-
**Description:** Mandu.filling()을 default export로 사용하는 기본 구조. 이것 없이는 slot이 작동하지 않습니다.
|
|
12
|
-
|
|
13
|
-
## 2. Context Response (slot-ctx)
|
|
14
|
-
|
|
15
|
-
**Impact:** HIGH
|
|
16
|
-
**Description:** ctx 객체의 응답 메서드 (ok, created, error 등) 사용법. 올바른 HTTP 상태 코드 반환에 필수적입니다.
|
|
17
|
-
|
|
18
|
-
## 3. Guard & Auth (slot-guard)
|
|
19
|
-
|
|
20
|
-
**Impact:** HIGH
|
|
21
|
-
**Description:** guard()를 사용한 인증/인가 패턴. 보안이 필요한 API 엔드포인트에 필수입니다.
|
|
22
|
-
|
|
23
|
-
## 4. HTTP Methods (slot-http)
|
|
24
|
-
|
|
25
|
-
**Impact:** HIGH
|
|
26
|
-
**Description:** get(), post(), put(), patch(), delete() 메서드 체이닝. RESTful API 설계의 핵심입니다.
|
|
27
|
-
|
|
28
|
-
## 5. Lifecycle Hooks (slot-lifecycle)
|
|
29
|
-
|
|
30
|
-
**Impact:** MEDIUM
|
|
31
|
-
**Description:** onRequest, beforeHandle, afterHandle, afterResponse 훅. 로깅, 타이밍, 변환에 사용됩니다.
|
|
32
|
-
|
|
33
|
-
## 6. Request Data (slot-request)
|
|
34
|
-
|
|
35
|
-
**Impact:** MEDIUM
|
|
36
|
-
**Description:** ctx.body(), ctx.params, ctx.query, ctx.headers 접근법. 요청 데이터 처리에 필요합니다.
|
|
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. Basic Structure (slot-basic)
|
|
9
|
+
|
|
10
|
+
**Impact:** CRITICAL
|
|
11
|
+
**Description:** Mandu.filling()을 default export로 사용하는 기본 구조. 이것 없이는 slot이 작동하지 않습니다.
|
|
12
|
+
|
|
13
|
+
## 2. Context Response (slot-ctx)
|
|
14
|
+
|
|
15
|
+
**Impact:** HIGH
|
|
16
|
+
**Description:** ctx 객체의 응답 메서드 (ok, created, error 등) 사용법. 올바른 HTTP 상태 코드 반환에 필수적입니다.
|
|
17
|
+
|
|
18
|
+
## 3. Guard & Auth (slot-guard)
|
|
19
|
+
|
|
20
|
+
**Impact:** HIGH
|
|
21
|
+
**Description:** guard()를 사용한 인증/인가 패턴. 보안이 필요한 API 엔드포인트에 필수입니다.
|
|
22
|
+
|
|
23
|
+
## 4. HTTP Methods (slot-http)
|
|
24
|
+
|
|
25
|
+
**Impact:** HIGH
|
|
26
|
+
**Description:** get(), post(), put(), patch(), delete() 메서드 체이닝. RESTful API 설계의 핵심입니다.
|
|
27
|
+
|
|
28
|
+
## 5. Lifecycle Hooks (slot-lifecycle)
|
|
29
|
+
|
|
30
|
+
**Impact:** MEDIUM
|
|
31
|
+
**Description:** onRequest, beforeHandle, afterHandle, afterResponse 훅. 로깅, 타이밍, 변환에 사용됩니다.
|
|
32
|
+
|
|
33
|
+
## 6. Request Data (slot-request)
|
|
34
|
+
|
|
35
|
+
**Impact:** MEDIUM
|
|
36
|
+
**Description:** ctx.body(), ctx.params, ctx.query, ctx.headers 접근법. 요청 데이터 처리에 필요합니다.
|
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
# Rule Template
|
|
2
|
-
|
|
3
|
-
Use this template when creating new rules for mandu-slot.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
```markdown
|
|
8
|
-
---
|
|
9
|
-
title: Rule Title Here (명확하고 액션 가능한 제목)
|
|
10
|
-
impact: CRITICAL | HIGH | MEDIUM | LOW
|
|
11
|
-
impactDescription: 영향 설명 (예: "Required for slot to work", "2-5x improvement")
|
|
12
|
-
tags: slot, tag1, tag2
|
|
13
|
-
---
|
|
14
|
-
|
|
15
|
-
## Rule Title Here
|
|
16
|
-
|
|
17
|
-
**Impact: {LEVEL} ({impactDescription})**
|
|
18
|
-
|
|
19
|
-
규칙의 목적과 중요성을 1-2문장으로 설명합니다.
|
|
20
|
-
|
|
21
|
-
**Incorrect (문제점 설명):**
|
|
22
|
-
|
|
23
|
-
\`\`\`typescript
|
|
24
|
-
// 잘못된 예시 코드
|
|
25
|
-
export default function handler(req) {
|
|
26
|
-
// 문제가 되는 패턴
|
|
27
|
-
}
|
|
28
|
-
\`\`\`
|
|
29
|
-
|
|
30
|
-
**Correct (올바른 방법):**
|
|
31
|
-
|
|
32
|
-
\`\`\`typescript
|
|
33
|
-
// 올바른 예시 코드
|
|
34
|
-
import { Mandu } from "@mandujs/core";
|
|
35
|
-
|
|
36
|
-
export default Mandu.filling()
|
|
37
|
-
.get((ctx) => {
|
|
38
|
-
return ctx.ok({ message: "Hello" });
|
|
39
|
-
});
|
|
40
|
-
\`\`\`
|
|
41
|
-
|
|
42
|
-
## Additional Context (선택사항)
|
|
43
|
-
|
|
44
|
-
추가 설명이 필요한 경우 여기에 작성합니다.
|
|
45
|
-
|
|
46
|
-
Reference: [관련 문서 링크](https://example.com)
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
---
|
|
50
|
-
|
|
51
|
-
## Naming Convention
|
|
52
|
-
|
|
53
|
-
- 파일명: `{section}-{rule-name}.md`
|
|
54
|
-
- 예시: `slot-basic-structure.md`, `slot-ctx-response.md`
|
|
55
|
-
|
|
56
|
-
## Impact Levels
|
|
57
|
-
|
|
58
|
-
| Level | When to Use |
|
|
59
|
-
|-------|-------------|
|
|
60
|
-
| CRITICAL | 없으면 기능이 작동하지 않음 |
|
|
61
|
-
| HIGH | 심각한 버그나 보안 문제 유발 |
|
|
62
|
-
| MEDIUM | 성능이나 유지보수성에 영향 |
|
|
63
|
-
| LOW | 모범 사례, 선택적 개선 |
|
|
1
|
+
# Rule Template
|
|
2
|
+
|
|
3
|
+
Use this template when creating new rules for mandu-slot.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
```markdown
|
|
8
|
+
---
|
|
9
|
+
title: Rule Title Here (명확하고 액션 가능한 제목)
|
|
10
|
+
impact: CRITICAL | HIGH | MEDIUM | LOW
|
|
11
|
+
impactDescription: 영향 설명 (예: "Required for slot to work", "2-5x improvement")
|
|
12
|
+
tags: slot, tag1, tag2
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Rule Title Here
|
|
16
|
+
|
|
17
|
+
**Impact: {LEVEL} ({impactDescription})**
|
|
18
|
+
|
|
19
|
+
규칙의 목적과 중요성을 1-2문장으로 설명합니다.
|
|
20
|
+
|
|
21
|
+
**Incorrect (문제점 설명):**
|
|
22
|
+
|
|
23
|
+
\`\`\`typescript
|
|
24
|
+
// 잘못된 예시 코드
|
|
25
|
+
export default function handler(req) {
|
|
26
|
+
// 문제가 되는 패턴
|
|
27
|
+
}
|
|
28
|
+
\`\`\`
|
|
29
|
+
|
|
30
|
+
**Correct (올바른 방법):**
|
|
31
|
+
|
|
32
|
+
\`\`\`typescript
|
|
33
|
+
// 올바른 예시 코드
|
|
34
|
+
import { Mandu } from "@mandujs/core";
|
|
35
|
+
|
|
36
|
+
export default Mandu.filling()
|
|
37
|
+
.get((ctx) => {
|
|
38
|
+
return ctx.ok({ message: "Hello" });
|
|
39
|
+
});
|
|
40
|
+
\`\`\`
|
|
41
|
+
|
|
42
|
+
## Additional Context (선택사항)
|
|
43
|
+
|
|
44
|
+
추가 설명이 필요한 경우 여기에 작성합니다.
|
|
45
|
+
|
|
46
|
+
Reference: [관련 문서 링크](https://example.com)
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Naming Convention
|
|
52
|
+
|
|
53
|
+
- 파일명: `{section}-{rule-name}.md`
|
|
54
|
+
- 예시: `slot-basic-structure.md`, `slot-ctx-response.md`
|
|
55
|
+
|
|
56
|
+
## Impact Levels
|
|
57
|
+
|
|
58
|
+
| Level | When to Use |
|
|
59
|
+
|-------|-------------|
|
|
60
|
+
| CRITICAL | 없으면 기능이 작동하지 않음 |
|
|
61
|
+
| HIGH | 심각한 버그나 보안 문제 유발 |
|
|
62
|
+
| MEDIUM | 성능이나 유지보수성에 영향 |
|
|
63
|
+
| LOW | 모범 사례, 선택적 개선 |
|