@fluencypassdevs/pulse 0.2.0 → 0.4.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/bin/cli.mjs +28 -0
- package/bin/init.mjs +103 -0
- package/bin/mcp.mjs +626 -0
- package/bin/propose.mjs +120 -0
- package/cli/CLAUDE-section.md +108 -0
- package/dist/buttons/cta-brand.js +3 -3
- package/dist/buttons/index.js +4 -4
- package/dist/buttons/link-brand.d.ts +1 -1
- package/dist/buttons/link-brand.js +2 -2
- package/dist/{chunk-N54YBISW.js → chunk-3YRUSLKP.js} +9 -9
- package/dist/{chunk-N54YBISW.js.map → chunk-3YRUSLKP.js.map} +1 -1
- package/dist/{chunk-PGXSBSQT.js → chunk-4AIUNX42.js} +3 -3
- package/dist/{chunk-PGXSBSQT.js.map → chunk-4AIUNX42.js.map} +1 -1
- package/dist/{chunk-YH3HWBLE.js → chunk-6LWT43J5.js} +6 -6
- package/dist/{chunk-YH3HWBLE.js.map → chunk-6LWT43J5.js.map} +1 -1
- package/dist/{chunk-XGV5OIPX.js → chunk-6M3I2HGX.js} +3 -3
- package/dist/{chunk-XGV5OIPX.js.map → chunk-6M3I2HGX.js.map} +1 -1
- package/dist/{chunk-RSCKN557.js → chunk-6UM5ZMQB.js} +3 -3
- package/dist/{chunk-RSCKN557.js.map → chunk-6UM5ZMQB.js.map} +1 -1
- package/dist/{chunk-KIXWOUY4.js → chunk-7WRWG5KX.js} +3 -3
- package/dist/{chunk-KIXWOUY4.js.map → chunk-7WRWG5KX.js.map} +1 -1
- package/dist/{chunk-JK3UYOM2.js → chunk-BEGHQZWX.js} +3 -3
- package/dist/{chunk-JK3UYOM2.js.map → chunk-BEGHQZWX.js.map} +1 -1
- package/dist/{chunk-KWQHWZI7.js → chunk-CBFKJPRU.js} +3 -3
- package/dist/{chunk-KWQHWZI7.js.map → chunk-CBFKJPRU.js.map} +1 -1
- package/dist/{chunk-5OLUQZFV.js → chunk-CTAPEUZ5.js} +3 -3
- package/dist/{chunk-5OLUQZFV.js.map → chunk-CTAPEUZ5.js.map} +1 -1
- package/dist/{chunk-44ESRMDK.js → chunk-DMMBOI74.js} +4 -4
- package/dist/{chunk-44ESRMDK.js.map → chunk-DMMBOI74.js.map} +1 -1
- package/dist/{chunk-WZIXM2X2.js → chunk-I5T7Q3VU.js} +3 -3
- package/dist/{chunk-WZIXM2X2.js.map → chunk-I5T7Q3VU.js.map} +1 -1
- package/dist/{chunk-ZRJFO4OW.js → chunk-K6QVUYFJ.js} +3 -3
- package/dist/{chunk-ZRJFO4OW.js.map → chunk-K6QVUYFJ.js.map} +1 -1
- package/dist/{chunk-WVYPNZFL.js → chunk-KBUMIJZ2.js} +3 -3
- package/dist/{chunk-WVYPNZFL.js.map → chunk-KBUMIJZ2.js.map} +1 -1
- package/dist/chunk-MGYKDGQ2.js +382 -0
- package/dist/chunk-MGYKDGQ2.js.map +1 -0
- package/dist/{chunk-GQURTO6D.js → chunk-MTYN7K34.js} +3 -3
- package/dist/{chunk-GQURTO6D.js.map → chunk-MTYN7K34.js.map} +1 -1
- package/dist/{chunk-RJRIFVYG.js → chunk-PVNEKUZV.js} +6 -6
- package/dist/{chunk-RJRIFVYG.js.map → chunk-PVNEKUZV.js.map} +1 -1
- package/dist/{chunk-CHSR2ETD.js → chunk-QJT2SYYH.js} +3 -3
- package/dist/{chunk-CHSR2ETD.js.map → chunk-QJT2SYYH.js.map} +1 -1
- package/dist/{chunk-2NMEKWO5.js → chunk-RMVMLLA7.js} +14 -3
- package/dist/{chunk-2NMEKWO5.js.map → chunk-RMVMLLA7.js.map} +1 -1
- package/dist/{chunk-XN2C725W.js → chunk-TNRD3EDD.js} +8 -8
- package/dist/{chunk-XN2C725W.js.map → chunk-TNRD3EDD.js.map} +1 -1
- package/dist/{chunk-VNGGZL6V.js → chunk-V5KDRNGX.js} +3 -3
- package/dist/{chunk-VNGGZL6V.js.map → chunk-V5KDRNGX.js.map} +1 -1
- package/dist/{chunk-YYH3A42F.js → chunk-VEK2WKTG.js} +3 -3
- package/dist/{chunk-YYH3A42F.js.map → chunk-VEK2WKTG.js.map} +1 -1
- package/dist/{chunk-SDJ6HXPX.js → chunk-YCMDWRT6.js} +3 -3
- package/dist/{chunk-SDJ6HXPX.js.map → chunk-YCMDWRT6.js.map} +1 -1
- package/dist/effects/card-dark-glow.js +2 -2
- package/dist/effects/circle-glow.js +2 -2
- package/dist/effects/hand-underline.js +2 -2
- package/dist/effects/index.js +7 -7
- package/dist/effects/magnetic-button.js +2 -2
- package/dist/effects/marquee.js +2 -2
- package/dist/effects/rotating-word.js +2 -2
- package/dist/hooks/use-intersection.js +1 -1
- package/dist/hooks/use-reduced-motion.js +1 -1
- package/dist/icons/index.d.ts +627 -0
- package/dist/icons/index.js +5 -0
- package/dist/icons/index.js.map +1 -0
- package/dist/icons/lucide.d.ts +1 -0
- package/dist/icons/lucide.js +15 -0
- package/dist/icons/lucide.js.map +1 -0
- package/dist/index.d.ts +11 -632
- package/dist/index.js +25 -398
- package/dist/index.js.map +1 -1
- package/dist/layout/index.js +2 -2
- package/dist/layout/section.js +2 -2
- package/dist/motion/animated-number.js +2 -2
- package/dist/motion/index.js +4 -4
- package/dist/motion/reveal-on-scroll.js +2 -2
- package/dist/motion/smooth-anchor.js +1 -1
- package/dist/motion/stagger-reveal.js +2 -2
- package/dist/sections/cta-band.js +9 -9
- package/dist/sections/faq-section.js +5 -5
- package/dist/sections/hero-section.js +10 -10
- package/dist/sections/index.js +15 -15
- package/dist/sections/logo-cloud.js +6 -6
- package/dist/typography/hero-heading.js +2 -2
- package/dist/typography/index.js +5 -5
- package/dist/typography/section-eyebrow.js +2 -2
- package/dist/typography/section-heading.js +2 -2
- package/dist/typography/section-subtitle.js +2 -2
- package/package.json +14 -1
package/bin/mcp.mjs
ADDED
|
@@ -0,0 +1,626 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Pulse Design System — MCP Server (JSON-RPC 2.0 sobre stdio, zero deps).
|
|
5
|
+
*
|
|
6
|
+
* Espelha o MCP do Cycle, adaptado ao Pulse (DS de marketing). Expõe tools
|
|
7
|
+
* pulse_* pra IA consultar componentes, tokens, regras e premissas em tempo real.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { createInterface } from "readline"
|
|
11
|
+
|
|
12
|
+
// ─── Catálogo de componentes ────────────────────────────────────────────────
|
|
13
|
+
|
|
14
|
+
const COMPONENTS = [
|
|
15
|
+
// ── Seções (dobras prontas) ──
|
|
16
|
+
{
|
|
17
|
+
name: "HeroSection",
|
|
18
|
+
import: 'import { HeroSection } from "@fluencypassdevs/pulse/sections"',
|
|
19
|
+
description: "Dobra de abertura de landing. Slot `aside` genérico (imagem, vídeo OU formulário) → 2 colunas; sem aside, centraliza. Serve os '3 primeiros segundos'.",
|
|
20
|
+
props: [
|
|
21
|
+
{ name: "title", type: "ReactNode", default: "— (obrigatório)" },
|
|
22
|
+
{ name: "eyebrow", type: "string", default: "-" },
|
|
23
|
+
{ name: "subtitle", type: "ReactNode", default: "-" },
|
|
24
|
+
{ name: "cta", type: "{ label, href, external? }", default: "-" },
|
|
25
|
+
{ name: "secondaryCta", type: "{ label, href, external? }", default: "-" },
|
|
26
|
+
{ name: "aside", type: "ReactNode (mídia OU form)", default: "-" },
|
|
27
|
+
{ name: "align", type: '"left" | "center"', default: "left c/ aside, center sem" },
|
|
28
|
+
{ name: "tone", type: '"dark" | "light"', default: '"dark"' },
|
|
29
|
+
{ name: "reveal", type: "boolean", default: "true" },
|
|
30
|
+
],
|
|
31
|
+
example: `<HeroSection
|
|
32
|
+
eyebrow="Para empresas"
|
|
33
|
+
title="Acelere o ingles do seu time"
|
|
34
|
+
subtitle="Do diagnostico ao certificado."
|
|
35
|
+
cta={{ label: "Falar com especialista", href: "#contato" }}
|
|
36
|
+
aside={<LeadForm />}
|
|
37
|
+
/>`,
|
|
38
|
+
keywords: ["hero", "dobra", "topo", "above the fold", "capa", "landing", "section"],
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: "CtaBand",
|
|
42
|
+
import: 'import { CtaBand } from "@fluencypassdevs/pulse/sections"',
|
|
43
|
+
description: "Faixa de conversão de fecho de página (título + CTA em destaque). Não ocupa a tela inteira.",
|
|
44
|
+
props: [
|
|
45
|
+
{ name: "title", type: "ReactNode", default: "— (obrigatório)" },
|
|
46
|
+
{ name: "subtitle", type: "ReactNode", default: "-" },
|
|
47
|
+
{ name: "cta", type: "{ label, href, external? }", default: "-" },
|
|
48
|
+
{ name: "secondaryCta", type: "{ label, href, external? }", default: "-" },
|
|
49
|
+
{ name: "align", type: '"left" | "center"', default: '"center"' },
|
|
50
|
+
{ name: "tone", type: '"dark" | "light"', default: '"dark"' },
|
|
51
|
+
],
|
|
52
|
+
example: `<CtaBand
|
|
53
|
+
title="Pronto pra acelerar o ingles do seu time?"
|
|
54
|
+
cta={{ label: "Comecar agora", href: "#contato" }}
|
|
55
|
+
/>`,
|
|
56
|
+
keywords: ["cta", "faixa", "band", "conversao", "fecho", "call to action", "banner"],
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: "LogoCloud",
|
|
60
|
+
import: 'import { LogoCloud } from "@fluencypassdevs/pulse/sections"',
|
|
61
|
+
description: "Prova social por logos (clientes/parceiros). Marquee infinito ou grid estático. Logos via children.",
|
|
62
|
+
props: [
|
|
63
|
+
{ name: "children", type: "ReactNode (logos)", default: "— (obrigatório)" },
|
|
64
|
+
{ name: "title", type: "string", default: "-" },
|
|
65
|
+
{ name: "variant", type: '"marquee" | "grid"', default: '"marquee"' },
|
|
66
|
+
{ name: "tone", type: '"dark" | "light"', default: '"dark"' },
|
|
67
|
+
],
|
|
68
|
+
example: `<LogoCloud title="Empresas que treinam com a gente">
|
|
69
|
+
<img src="/logos/a.svg" alt="Empresa A" />
|
|
70
|
+
<img src="/logos/b.svg" alt="Empresa B" />
|
|
71
|
+
</LogoCloud>`,
|
|
72
|
+
keywords: ["logo", "logos", "prova social", "parceiros", "clientes", "marquee", "social proof"],
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
name: "FaqSection",
|
|
76
|
+
import: 'import { FaqSection } from "@fluencypassdevs/pulse/sections"',
|
|
77
|
+
description: "Perguntas frequentes (Accordion) + dados estruturados FAQPage (JSON-LD) pro Google. Respostas em texto puro alimentam acordeão e SEO.",
|
|
78
|
+
props: [
|
|
79
|
+
{ name: "items", type: "{ question, answer }[]", default: "— (obrigatório)" },
|
|
80
|
+
{ name: "eyebrow", type: "string", default: "-" },
|
|
81
|
+
{ name: "title", type: "ReactNode", default: '"Perguntas frequentes"' },
|
|
82
|
+
{ name: "jsonLd", type: "boolean", default: "true" },
|
|
83
|
+
{ name: "multiple", type: "boolean", default: "false" },
|
|
84
|
+
{ name: "tone", type: '"dark" | "light"', default: '"dark"' },
|
|
85
|
+
],
|
|
86
|
+
example: `<FaqSection items={[
|
|
87
|
+
{ question: "Como funciona?", answer: "Voce faz um diagnostico e recebe um plano." },
|
|
88
|
+
{ question: "Tem certificado?", answer: "Sim, ao concluir cada nivel." },
|
|
89
|
+
]} />`,
|
|
90
|
+
keywords: ["faq", "perguntas", "duvidas", "accordion", "seo", "json-ld", "structured data"],
|
|
91
|
+
},
|
|
92
|
+
// ── Buttons ──
|
|
93
|
+
{
|
|
94
|
+
name: "CtaBrand",
|
|
95
|
+
import: 'import { CtaBrand } from "@fluencypassdevs/pulse/buttons"',
|
|
96
|
+
description: "CTA principal de marketing — gradient brand rose, rounded-full, glow, brightness hover e efeito magnético embutido. Sempre <a> com href.",
|
|
97
|
+
props: [
|
|
98
|
+
{ name: "href", type: "string", default: "— (obrigatório)" },
|
|
99
|
+
{ name: "external", type: "boolean", default: "false" },
|
|
100
|
+
{ name: "size", type: '"md" | "lg"', default: '"lg"' },
|
|
101
|
+
{ name: "disableMagnetic", type: "boolean", default: "false" },
|
|
102
|
+
],
|
|
103
|
+
example: `<CtaBrand href="#vendas">Solicitar demonstracao</CtaBrand>`,
|
|
104
|
+
keywords: ["cta", "botao", "button", "marca", "brand", "magnetic", "gradiente"],
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
name: "LinkBrand",
|
|
108
|
+
import: 'import { LinkBrand } from "@fluencypassdevs/pulse/buttons"',
|
|
109
|
+
description: "Link discreto da marca — text-brand com hover pra brand-dark. Renderiza <a> (default) ou <button>.",
|
|
110
|
+
props: [
|
|
111
|
+
{ name: "href", type: "string", default: "-" },
|
|
112
|
+
{ name: "as", type: '"a" | "button"', default: '"a"' },
|
|
113
|
+
{ name: "external", type: "boolean", default: "false" },
|
|
114
|
+
],
|
|
115
|
+
example: `<LinkBrand href="#como">Ver como funciona →</LinkBrand>`,
|
|
116
|
+
keywords: ["link", "brand", "secundario", "discreto"],
|
|
117
|
+
},
|
|
118
|
+
// ── Motion ──
|
|
119
|
+
{
|
|
120
|
+
name: "RevealOnScroll",
|
|
121
|
+
import: 'import { RevealOnScroll } from "@fluencypassdevs/pulse/motion"',
|
|
122
|
+
description: "Fade-up suave (translateY + opacity) quando o elemento entra no viewport. Respeita prefers-reduced-motion.",
|
|
123
|
+
props: [
|
|
124
|
+
{ name: "as", type: "tag", default: '"div"' },
|
|
125
|
+
{ name: "delay", type: "number (ms)", default: "0" },
|
|
126
|
+
{ name: "threshold", type: "number", default: "0.15" },
|
|
127
|
+
{ name: "repeat", type: "boolean", default: "false" },
|
|
128
|
+
],
|
|
129
|
+
example: `<RevealOnScroll><Card /></RevealOnScroll>`,
|
|
130
|
+
keywords: ["reveal", "scroll", "fade", "animacao", "entrada", "motion"],
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
name: "StaggerReveal",
|
|
134
|
+
import: 'import { StaggerReveal } from "@fluencypassdevs/pulse/motion"',
|
|
135
|
+
description: "Anima filhos em sequência (fade-up com delay incremental). Respeita prefers-reduced-motion.",
|
|
136
|
+
props: [
|
|
137
|
+
{ name: "step", type: "number (ms)", default: "100" },
|
|
138
|
+
{ name: "threshold", type: "number", default: "0.15" },
|
|
139
|
+
],
|
|
140
|
+
example: `<StaggerReveal>{cards}</StaggerReveal>`,
|
|
141
|
+
keywords: ["stagger", "sequencia", "lista", "reveal", "motion"],
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
name: "AnimatedNumber",
|
|
145
|
+
import: 'import { AnimatedNumber } from "@fluencypassdevs/pulse/motion"',
|
|
146
|
+
description: "Conta de `from` até `value` com easing ao entrar no viewport. Suporta prefix/suffix/decimals/locale. tabular-nums automático.",
|
|
147
|
+
props: [
|
|
148
|
+
{ name: "value", type: "number", default: "— (obrigatório)" },
|
|
149
|
+
{ name: "from", type: "number", default: "0" },
|
|
150
|
+
{ name: "suffix", type: "string", default: "-" },
|
|
151
|
+
{ name: "prefix", type: "string", default: "-" },
|
|
152
|
+
],
|
|
153
|
+
example: `<AnimatedNumber value={128} suffix="k" />`,
|
|
154
|
+
keywords: ["numero", "contador", "count", "stats", "metrica", "motion"],
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
name: "SmoothAnchor",
|
|
158
|
+
import: 'import { SmoothAnchor } from "@fluencypassdevs/pulse/motion"',
|
|
159
|
+
description: "Intercepta clicks em <a href='#X'> e faz scroll suave com easing. Componente raiz (renderiza null). Respeita prefers-reduced-motion.",
|
|
160
|
+
props: [
|
|
161
|
+
{ name: "headerOffset", type: "number", default: "96" },
|
|
162
|
+
{ name: "duration", type: "number (ms)", default: "900" },
|
|
163
|
+
],
|
|
164
|
+
example: `<SmoothAnchor headerOffset={80} />`,
|
|
165
|
+
keywords: ["anchor", "scroll", "suave", "ancora", "navegacao", "motion"],
|
|
166
|
+
},
|
|
167
|
+
// ── Effects ──
|
|
168
|
+
{
|
|
169
|
+
name: "Marquee",
|
|
170
|
+
import: 'import { Marquee } from "@fluencypassdevs/pulse/effects"',
|
|
171
|
+
description: "Scroll horizontal infinito (logo cloud, partner band). Duplica children pra loop seamless. Respeita prefers-reduced-motion.",
|
|
172
|
+
props: [
|
|
173
|
+
{ name: "speed", type: "number (s)", default: "40" },
|
|
174
|
+
{ name: "direction", type: '"left" | "right"', default: '"left"' },
|
|
175
|
+
{ name: "pauseOnHover", type: "boolean", default: "true" },
|
|
176
|
+
{ name: "gap", type: "number (px)", default: "48" },
|
|
177
|
+
],
|
|
178
|
+
example: `<Marquee gap={64}>{logos}</Marquee>`,
|
|
179
|
+
keywords: ["marquee", "scroll", "infinito", "logos", "esteira", "effect"],
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
name: "CircleGlow",
|
|
183
|
+
import: 'import { CircleGlow } from "@fluencypassdevs/pulse/effects"',
|
|
184
|
+
description: "Elipse radial pulsante atrás de cards. Absolute (container precisa ser relative). aria-hidden + pointer-events none.",
|
|
185
|
+
props: [{ name: "size", type: '"sm" | "md" | "lg"', default: '"md"' }],
|
|
186
|
+
example: `<div className="relative"><CircleGlow size="lg" /><Card /></div>`,
|
|
187
|
+
keywords: ["glow", "brilho", "circle", "fundo", "effect", "luz"],
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
name: "CardDarkGlow",
|
|
191
|
+
import: 'import { CardDarkGlow } from "@fluencypassdevs/pulse/effects"',
|
|
192
|
+
description: "Wrapper de card com inset highlight + glow rose sutil + hover lift opcional. Pareie com CircleGlow no container externo.",
|
|
193
|
+
props: [
|
|
194
|
+
{ name: "as", type: "tag", default: '"div"' },
|
|
195
|
+
{ name: "interactive", type: "boolean", default: "true" },
|
|
196
|
+
],
|
|
197
|
+
example: `<CardDarkGlow>{conteudo}</CardDarkGlow>`,
|
|
198
|
+
keywords: ["card", "glow", "dark", "hover", "lift", "effect"],
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
name: "MagneticButton",
|
|
202
|
+
import: 'import { MagneticButton } from "@fluencypassdevs/pulse/effects"',
|
|
203
|
+
description: "Wrapper que puxa o filho em direção ao cursor. RAF throttle + IO gating. Skip em prefers-reduced-motion e pointer:coarse. (O CtaBrand já usa embutido.)",
|
|
204
|
+
props: [
|
|
205
|
+
{ name: "strength", type: "number", default: "0.25" },
|
|
206
|
+
{ name: "radius", type: "number", default: "100" },
|
|
207
|
+
],
|
|
208
|
+
example: `<MagneticButton><a href="#">Botao</a></MagneticButton>`,
|
|
209
|
+
keywords: ["magnetic", "magnetico", "cursor", "hover", "effect"],
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
name: "RotatingWord",
|
|
213
|
+
import: 'import { RotatingWord } from "@fluencypassdevs/pulse/effects"',
|
|
214
|
+
description: "Typewriter de palavras em loop (typing → holding → erasing). Herda cor via currentColor. aria-live polite. reduced-motion mostra a 1ª palavra estática.",
|
|
215
|
+
props: [
|
|
216
|
+
{ name: "words", type: "string[]", default: "— (obrigatório)" },
|
|
217
|
+
{ name: "typingMs", type: "number", default: "80" },
|
|
218
|
+
{ name: "holdMs", type: "number", default: "1500" },
|
|
219
|
+
],
|
|
220
|
+
example: `<RotatingWord words={["Atraia", "Converta", "Retenha"]} />`,
|
|
221
|
+
keywords: ["typewriter", "rotating", "palavra", "texto", "loop", "effect"],
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
name: "HandUnderline",
|
|
225
|
+
import: 'import { HandUnderline } from "@fluencypassdevs/pulse/effects"',
|
|
226
|
+
description: "Desenha um SVG de underline em curva sutil abaixo do texto (stroke-dasharray). Herda cor via currentColor. reduced-motion desenha completo.",
|
|
227
|
+
props: [
|
|
228
|
+
{ name: "delay", type: "number (ms)", default: "600" },
|
|
229
|
+
{ name: "duration", type: "number (ms)", default: "780" },
|
|
230
|
+
],
|
|
231
|
+
example: `<HandUnderline>destaque</HandUnderline>`,
|
|
232
|
+
keywords: ["underline", "sublinhado", "mao", "hand", "destaque", "effect"],
|
|
233
|
+
},
|
|
234
|
+
// ── Layout / Typography ──
|
|
235
|
+
{
|
|
236
|
+
name: "Section",
|
|
237
|
+
import: 'import { Section } from "@fluencypassdevs/pulse/layout"',
|
|
238
|
+
description: "Wrapper de dobra. variant hero (min-h-screen) / default (py generoso). tone dark/light (light aplica .light-surface). Base dos blocos de seção.",
|
|
239
|
+
props: [
|
|
240
|
+
{ name: "as", type: '"section" | "div"', default: '"section"' },
|
|
241
|
+
{ name: "variant", type: '"hero" | "default"', default: '"default"' },
|
|
242
|
+
{ name: "tone", type: '"dark" | "light"', default: '"dark"' },
|
|
243
|
+
],
|
|
244
|
+
example: `<Section variant="default" tone="light"><SectionHeading>…</SectionHeading></Section>`,
|
|
245
|
+
keywords: ["section", "dobra", "wrapper", "layout", "tone"],
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
name: "HeroHeading",
|
|
249
|
+
import: 'import { HeroHeading } from "@fluencypassdevs/pulse/typography"',
|
|
250
|
+
description: "H1 dramático de hero (sizes grandes, bold, leading apertado, text-balance).",
|
|
251
|
+
props: [
|
|
252
|
+
{ name: "as", type: '"h1" | "h2" | "div"', default: '"h1"' },
|
|
253
|
+
{ name: "align", type: '"left" | "center"', default: '"left"' },
|
|
254
|
+
],
|
|
255
|
+
example: `<HeroHeading>Acelere o ingles do seu time</HeroHeading>`,
|
|
256
|
+
keywords: ["heading", "titulo", "hero", "h1", "typography"],
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
name: "SectionHeading",
|
|
260
|
+
import: 'import { SectionHeading } from "@fluencypassdevs/pulse/typography"',
|
|
261
|
+
description: "H2 de dobra. weight light (default) / bold; align; maxW wide/prose.",
|
|
262
|
+
props: [
|
|
263
|
+
{ name: "weight", type: '"light" | "bold"', default: '"light"' },
|
|
264
|
+
{ name: "align", type: '"left" | "center"', default: '"center"' },
|
|
265
|
+
{ name: "maxW", type: '"wide" | "prose"', default: '"wide"' },
|
|
266
|
+
],
|
|
267
|
+
example: `<SectionHeading weight="bold">3 pilares essenciais</SectionHeading>`,
|
|
268
|
+
keywords: ["heading", "titulo", "secao", "h2", "typography"],
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
name: "SectionEyebrow",
|
|
272
|
+
import: 'import { SectionEyebrow } from "@fluencypassdevs/pulse/typography"',
|
|
273
|
+
description: "Rótulo monospace acima do heading (categoriza a dobra).",
|
|
274
|
+
props: [{ name: "align", type: '"left" | "center"', default: '"left"' }],
|
|
275
|
+
example: `<SectionEyebrow>Para empresas</SectionEyebrow>`,
|
|
276
|
+
keywords: ["eyebrow", "rotulo", "label", "kicker", "typography"],
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
name: "SectionSubtitle",
|
|
280
|
+
import: 'import { SectionSubtitle } from "@fluencypassdevs/pulse/typography"',
|
|
281
|
+
description: "Body de apoio abaixo do heading. Cor muted, leading relaxado, max-width.",
|
|
282
|
+
props: [{ name: "align", type: '"left" | "center"', default: '"center"' }],
|
|
283
|
+
example: `<SectionSubtitle>Do diagnostico ao certificado.</SectionSubtitle>`,
|
|
284
|
+
keywords: ["subtitle", "subtitulo", "apoio", "lead", "typography"],
|
|
285
|
+
},
|
|
286
|
+
// ── Core (primitivos neutros, via barrel do pulse) ──
|
|
287
|
+
{
|
|
288
|
+
name: "Button",
|
|
289
|
+
import: 'import { Button } from "@fluencypassdevs/pulse"',
|
|
290
|
+
description: "Botão neutro do core. Pra CTA de marca use o CtaBrand. 6 variants, 8 sizes.",
|
|
291
|
+
props: [
|
|
292
|
+
{ name: "variant", type: '"default" | "destructive" | "outline" | "secondary" | "ghost" | "link"', default: '"default"' },
|
|
293
|
+
{ name: "size", type: '"xs" | "sm" | "default" | "lg" | "icon-*"', default: '"default"' },
|
|
294
|
+
],
|
|
295
|
+
example: `<Button variant="outline">Secundario</Button>`,
|
|
296
|
+
keywords: ["button", "botao", "core", "acao"],
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
name: "Input",
|
|
300
|
+
import: 'import { Input } from "@fluencypassdevs/pulse"',
|
|
301
|
+
description: "Campo de texto do core (lead forms). 2 variantes (outline, filled), 3 sizes.",
|
|
302
|
+
props: [
|
|
303
|
+
{ name: "variant", type: '"outline" | "filled"', default: '"outline"' },
|
|
304
|
+
{ name: "inputSize", type: '"sm" | "default" | "lg"', default: '"default"' },
|
|
305
|
+
],
|
|
306
|
+
example: `<Input variant="filled" placeholder="E-mail" />`,
|
|
307
|
+
keywords: ["input", "campo", "formulario", "lead", "core"],
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
name: "Badge",
|
|
311
|
+
import: 'import { Badge } from "@fluencypassdevs/pulse"',
|
|
312
|
+
description: "Selo/etiqueta do core. 10 variants, 3 sizes.",
|
|
313
|
+
props: [{ name: "variant", type: "string", default: '"default"' }, { name: "size", type: '"sm" | "default" | "lg"', default: '"default"' }],
|
|
314
|
+
example: `<Badge>Novo</Badge>`,
|
|
315
|
+
keywords: ["badge", "selo", "tag", "etiqueta", "core"],
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
name: "Sheet",
|
|
319
|
+
import: 'import { Sheet, SheetContent, SheetTrigger } from "@fluencypassdevs/pulse"',
|
|
320
|
+
description: "Painel lateral do core (menu mobile de landing). Sides top/right/bottom/left.",
|
|
321
|
+
props: [{ name: "side", type: '"top" | "right" | "bottom" | "left"', default: '"right"' }],
|
|
322
|
+
example: `<Sheet><SheetTrigger>Menu</SheetTrigger><SheetContent side="left">…</SheetContent></Sheet>`,
|
|
323
|
+
keywords: ["sheet", "menu", "mobile", "painel", "drawer", "core"],
|
|
324
|
+
},
|
|
325
|
+
{
|
|
326
|
+
name: "CorePrimitives",
|
|
327
|
+
import: 'import { Label, Textarea, Select, Checkbox, RadioGroup, Switch, Accordion, Tabs, Tooltip, Avatar, ScrollArea, Skeleton, Spinner, Empty, CycleIcon, cn } from "@fluencypassdevs/pulse"',
|
|
328
|
+
description: "Demais primitivos neutros do core, disponíveis pelo barrel do pulse (mesma implementação do Cycle). Use CycleIcon + @fluencypassdevs/pulse/icons/lucide pra ícones.",
|
|
329
|
+
props: [],
|
|
330
|
+
example: `import { Label, Select, Avatar, cn } from "@fluencypassdevs/pulse"`,
|
|
331
|
+
keywords: ["core", "primitivos", "label", "select", "checkbox", "switch", "tabs", "avatar", "tooltip", "skeleton", "spinner", "empty", "icon"],
|
|
332
|
+
},
|
|
333
|
+
]
|
|
334
|
+
|
|
335
|
+
// ─── Tokens ──────────────────────────────────────────────────────────────────
|
|
336
|
+
|
|
337
|
+
const TOKENS = {
|
|
338
|
+
colors: {
|
|
339
|
+
base: ["bg-page", "text-body", "text-support", "bg-panel", "border-line"],
|
|
340
|
+
brand: ["bg-brand", "text-brand", "text-on-brand", "bg-brand-soft"],
|
|
341
|
+
product: ["bg-product", "text-on-product", "bg-product-soft (dentro de .theme-*)"],
|
|
342
|
+
highlight: ["bg-highlight-positive", "bg-highlight-warning", "bg-highlight-critical", "bg-highlight-info"],
|
|
343
|
+
expressive: ["--gradient-brand-primary", "--gradient-brand-angled", "--glow-brand-circle", ".light-surface"],
|
|
344
|
+
},
|
|
345
|
+
radius: ["rounded-sm", "rounded-md", "rounded-lg", "rounded-xl"],
|
|
346
|
+
typography: {
|
|
347
|
+
body: ["body-sm (12px)", "body-md (14px)", "body-lg (16px)"],
|
|
348
|
+
heading: ["heading-lg (20px)", "heading-2xl (32px)", "heading-4xl (48px)"],
|
|
349
|
+
display: ["display-md (64px/700)", "display-lg (72px/700)", "display-lg-light (72px/300)"],
|
|
350
|
+
},
|
|
351
|
+
themes: [".theme-class", ".theme-private", ".theme-group", ".theme-impulse", ".theme-positive", ".theme-warning", ".theme-critical", ".dark"],
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
// ─── Tool Definitions ──────────────────────────────────────────────────────────
|
|
355
|
+
|
|
356
|
+
const TOOLS = [
|
|
357
|
+
{
|
|
358
|
+
name: "pulse_search_component",
|
|
359
|
+
description: "Search for a Pulse Design System (marketing) component by name or keyword. Use BEFORE creating any UI to check if it already exists.",
|
|
360
|
+
inputSchema: { type: "object", properties: { query: { type: "string", description: "Component name or keyword (e.g. 'hero', 'cta', 'faq', 'logos', 'reveal')" } }, required: ["query"] },
|
|
361
|
+
},
|
|
362
|
+
{
|
|
363
|
+
name: "pulse_get_component",
|
|
364
|
+
description: "Get full details of a specific Pulse component (props, variants, example).",
|
|
365
|
+
inputSchema: { type: "object", properties: { name: { type: "string", description: "Exact component name (e.g. 'HeroSection', 'CtaBrand')" } }, required: ["name"] },
|
|
366
|
+
},
|
|
367
|
+
{
|
|
368
|
+
name: "pulse_get_icon_usage",
|
|
369
|
+
description: "How to use icons in Pulse. NUNCA importar lucide-react diretamente.",
|
|
370
|
+
inputSchema: { type: "object", properties: {} },
|
|
371
|
+
},
|
|
372
|
+
{
|
|
373
|
+
name: "pulse_get_setup",
|
|
374
|
+
description: "Setup instructions for a marketing project using Pulse (npm install, Geist, CSS).",
|
|
375
|
+
inputSchema: { type: "object", properties: {} },
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
name: "pulse_get_tokens",
|
|
379
|
+
description: "Available Pulse design tokens (vocabulary of marketing). NUNCA usar cores hardcoded nem primitivos.",
|
|
380
|
+
inputSchema: { type: "object", properties: { category: { type: "string", enum: ["colors", "typography", "radius", "themes", "all"] } } },
|
|
381
|
+
},
|
|
382
|
+
{
|
|
383
|
+
name: "pulse_get_rules",
|
|
384
|
+
description: "Mandatory rules for AI using Pulse. Call at the start of any marketing UI task.",
|
|
385
|
+
inputSchema: { type: "object", properties: {} },
|
|
386
|
+
},
|
|
387
|
+
{
|
|
388
|
+
name: "pulse_get_design_principles",
|
|
389
|
+
description: "The 14 non-limiting design premises of Pulse (marketing/conversão). Call before creating marketing UI.",
|
|
390
|
+
inputSchema: { type: "object", properties: {} },
|
|
391
|
+
},
|
|
392
|
+
]
|
|
393
|
+
|
|
394
|
+
// ─── Tool Handlers ─────────────────────────────────────────────────────────────
|
|
395
|
+
|
|
396
|
+
function handleToolCall(name, args) {
|
|
397
|
+
switch (name) {
|
|
398
|
+
case "pulse_search_component": {
|
|
399
|
+
const query = (args.query || "").toLowerCase()
|
|
400
|
+
const results = COMPONENTS.filter((c) => {
|
|
401
|
+
const searchable = `${c.name} ${c.description} ${c.keywords.join(" ")}`.toLowerCase()
|
|
402
|
+
return query.split(/\s+/).every((word) => searchable.includes(word))
|
|
403
|
+
})
|
|
404
|
+
if (results.length === 0) {
|
|
405
|
+
return `No components found for "${args.query}". Este componente NAO existe no Pulse. NAO crie do zero — sinalize a lacuna ao dev e componha com os primitivos/seções existentes; se for reutilizável, proponha a entrada (ds-proposals/ + issue). Lembre da regra de superfície: marketing=Pulse, produto=Cycle.`
|
|
406
|
+
}
|
|
407
|
+
const list = results.map((c) => `### ${c.name}\n${c.import}\n${c.description}`).join("\n\n")
|
|
408
|
+
return `Found ${results.length} component(s) matching "${args.query}":\n\n${list}\n\nUse pulse_get_component for full details.`
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
case "pulse_get_component": {
|
|
412
|
+
const comp = COMPONENTS.find((c) => c.name.toLowerCase() === (args.name || "").toLowerCase())
|
|
413
|
+
if (!comp) return `Component "${args.name}" not found. Use pulse_search_component to search by keyword.`
|
|
414
|
+
const propsTable = comp.props.length > 0
|
|
415
|
+
? "Props:\n" + comp.props.map((p) => ` - ${p.name}: ${p.type} (default: ${p.default})`).join("\n")
|
|
416
|
+
: "Sem props configuraveis (ou composicao)."
|
|
417
|
+
return `# ${comp.name}\n\n${comp.import}\n\n${comp.description}\n\n${propsTable}\n\nExample:\n\`\`\`tsx\n${comp.example}\n\`\`\``
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
case "pulse_get_icon_usage":
|
|
421
|
+
return `# Icons no Pulse
|
|
422
|
+
|
|
423
|
+
**NUNCA importar de "lucide-react" diretamente.**
|
|
424
|
+
|
|
425
|
+
\`\`\`tsx
|
|
426
|
+
import { CycleIcon } from "@fluencypassdevs/pulse"
|
|
427
|
+
import { Home, ArrowRight } from "@fluencypassdevs/pulse/icons/lucide"
|
|
428
|
+
|
|
429
|
+
<CycleIcon icon={ArrowRight} size="sm" decorative />
|
|
430
|
+
<CycleIcon icon={Home} size="sm" aria-label="Inicio" />
|
|
431
|
+
\`\`\`
|
|
432
|
+
|
|
433
|
+
Icones custom (EdTech) direto do barrel, sem wrapper:
|
|
434
|
+
\`\`\`tsx
|
|
435
|
+
import { Live, Course } from "@fluencypassdevs/pulse"
|
|
436
|
+
<Live size="sm" decorative />
|
|
437
|
+
\`\`\`
|
|
438
|
+
|
|
439
|
+
Sizes: xs 16px · sm 24px · md 32px · lg 40px · xl 48px.`
|
|
440
|
+
|
|
441
|
+
case "pulse_get_setup":
|
|
442
|
+
return `# Setup do Pulse Design System (projeto de marketing)
|
|
443
|
+
|
|
444
|
+
## 1. Instalar:
|
|
445
|
+
\`\`\`bash
|
|
446
|
+
npm install @fluencypassdevs/pulse geist
|
|
447
|
+
\`\`\`
|
|
448
|
+
NAO instale o @fluencypassdevs/cycle junto — os primitivos core ja vem no Pulse.
|
|
449
|
+
|
|
450
|
+
## 2. Fonte Geist (OBRIGATORIO) no layout.tsx:
|
|
451
|
+
\`\`\`tsx
|
|
452
|
+
import { GeistSans } from "geist/font/sans"
|
|
453
|
+
import { GeistMono } from "geist/font/mono"
|
|
454
|
+
<html className={\`\${GeistSans.variable} \${GeistMono.variable}\`}>…</html>
|
|
455
|
+
\`\`\`
|
|
456
|
+
|
|
457
|
+
## 3. CSS (globals.css):
|
|
458
|
+
\`\`\`css
|
|
459
|
+
@import "tailwindcss";
|
|
460
|
+
@import "@fluencypassdevs/pulse/styles.css";
|
|
461
|
+
\`\`\`
|
|
462
|
+
Só tokens (e-mail): \`@fluencypassdevs/pulse/tokens.css\`.
|
|
463
|
+
|
|
464
|
+
## 4. Importar:
|
|
465
|
+
\`\`\`tsx
|
|
466
|
+
import { HeroSection, CtaBand, FaqSection } from "@fluencypassdevs/pulse/sections"
|
|
467
|
+
import { CtaBrand } from "@fluencypassdevs/pulse/buttons"
|
|
468
|
+
import { Button, Input } from "@fluencypassdevs/pulse"
|
|
469
|
+
\`\`\`
|
|
470
|
+
|
|
471
|
+
## 5. Regras de IA (opcional):
|
|
472
|
+
\`\`\`bash
|
|
473
|
+
npx pulse init
|
|
474
|
+
\`\`\`
|
|
475
|
+
|
|
476
|
+
## Tema
|
|
477
|
+
Escolha por pagina/secao via prop \`tone\` do Section (light e dark de 1a classe). Nao assuma dark-global.`
|
|
478
|
+
|
|
479
|
+
case "pulse_get_tokens": {
|
|
480
|
+
const cat = args.category || "all"
|
|
481
|
+
if (cat === "all") {
|
|
482
|
+
return `# Tokens do Pulse (vocabulario de marketing)\n\n## Cores base\n${TOKENS.colors.base.join(", ")}\n\n## Marca\n${TOKENS.colors.brand.join(", ")}\n\n## Produto (no tema ativo)\n${TOKENS.colors.product.join(", ")}\n\n## Destaques\n${TOKENS.colors.highlight.join(", ")}\n\n## Expressivos\n${TOKENS.colors.expressive.join(", ")}\n\n## Tipografia\nBody: ${TOKENS.typography.body.join(", ")}\nHeading: ${TOKENS.typography.heading.join(", ")}\nDisplay: ${TOKENS.typography.display.join(", ")}\n\n## Radius\n${TOKENS.radius.join(", ")}\n\n## Temas\n${TOKENS.themes.join(", ")}\n\n**NUNCA cor hardcoded nem primitivo (ex.: color-brand-400, #hex). Sempre o token semantico.**`
|
|
483
|
+
}
|
|
484
|
+
const data = TOKENS[cat]
|
|
485
|
+
if (!data) return `Unknown category "${cat}". Available: colors, typography, radius, themes, all.`
|
|
486
|
+
return `# ${cat} tokens (Pulse)\n\n${JSON.stringify(data, null, 2)}\n\n**Sempre estes tokens — nunca valores hardcoded.**`
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
case "pulse_get_design_principles":
|
|
490
|
+
return `# Premissas de Design — Pulse (marketing)
|
|
491
|
+
|
|
492
|
+
NAO-limitantes: guiam a decisao, mas NAO definem a estrutura da pagina (dobras, ordem, nº de CTAs, tom sao livres).
|
|
493
|
+
|
|
494
|
+
1. Uma pagina, uma intencao (attention ratio como norte).
|
|
495
|
+
2. Os 3 primeiros segundos (o topo responde "o que e?" + "o que faco?").
|
|
496
|
+
3. Beneficio antes de feature.
|
|
497
|
+
4. Chrome com proposito (motion/glow guiam atencao, nao decoram).
|
|
498
|
+
5. Hierarquia visual conduz a acao.
|
|
499
|
+
6. Prova social convence (depoimentos, logos, numeros).
|
|
500
|
+
7. Urgencia honesta (sem dark pattern).
|
|
501
|
+
8. Friccao e inimiga (menos campos/passos).
|
|
502
|
+
9. Consistencia de mensagem (message/design match com a campanha).
|
|
503
|
+
10. Performar e converter (LCP/velocidade sao design).
|
|
504
|
+
11. Marca expressiva sobre fundacao compartilhada.
|
|
505
|
+
12. Expressivo, mas acessivel (light E dark, contraste, reduced-motion).
|
|
506
|
+
13. Mensuravel e testavel (tracking e A/B desde o desenho).
|
|
507
|
+
14. Achavel e compartilhavel (SEO e social nativos).`
|
|
508
|
+
|
|
509
|
+
case "pulse_get_rules":
|
|
510
|
+
return `# Regras OBRIGATORIAS para IA — Pulse Design System
|
|
511
|
+
|
|
512
|
+
## Principal
|
|
513
|
+
NUNCA copiar/recriar componentes que ja existem. Sempre importar de \`@fluencypassdevs/pulse\`.
|
|
514
|
+
Uma superficie usa UM DS: marketing=Pulse, produto=Cycle. Nunca misture no mesmo render.
|
|
515
|
+
|
|
516
|
+
## Componentes
|
|
517
|
+
1. CTA de marca = \`CtaBrand\` — nunca re-skinar o Button com gradiente via className.
|
|
518
|
+
2. Prefira as secoes (HeroSection, CtaBand, LogoCloud, FaqSection) pra montar dobras.
|
|
519
|
+
3. Primitivos neutros (Button, Input, Badge…) vem do barrel do pulse — nao recriar.
|
|
520
|
+
|
|
521
|
+
## Estilo & tema
|
|
522
|
+
4. Só token semantico do Pulse (bg-page, text-body, bg-brand, bg-product, bg-highlight-*) — nunca hex/primitivo.
|
|
523
|
+
5. Tema por pagina/secao (prop tone do Section); light e dark de 1a classe.
|
|
524
|
+
6. Tipografia via classes do sistema (heading-*, display-*) — sem valores arbitrarios.
|
|
525
|
+
|
|
526
|
+
## Performance & a11y & SEO
|
|
527
|
+
7. RSC-first; "use client" so em ilha de interacao; next/image sempre.
|
|
528
|
+
8. prefers-reduced-motion em todo motion; contraste em light E dark; foco visivel.
|
|
529
|
+
9. generateMetadata + OG; JSON-LD nas secoes aplicaveis (FaqSection ja emite).
|
|
530
|
+
|
|
531
|
+
## Icones
|
|
532
|
+
10. NUNCA lucide-react direto — via CycleIcon + @fluencypassdevs/pulse/icons/lucide.
|
|
533
|
+
|
|
534
|
+
## Conteudo
|
|
535
|
+
11. Prova social com identidade real so em producao — mock em dev (LGPD).
|
|
536
|
+
12. Urgencia so com dado verdadeiro.
|
|
537
|
+
|
|
538
|
+
## Componente que falta
|
|
539
|
+
Crie em \`ds-proposals/\` (nao em components/ ui/), componha atomos+tokens, e proponha via issue
|
|
540
|
+
"Proposta de Componente". A necessidade flui pra camada certa por triagem — sem cross-import com o Cycle.`
|
|
541
|
+
|
|
542
|
+
default:
|
|
543
|
+
return `Unknown tool: ${name}`
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
// ─── JSON-RPC 2.0 over stdio ──────────────────────────────────────────────────
|
|
548
|
+
|
|
549
|
+
const SERVER_INFO = { name: "pulse-design-system", version: "0.3.0" }
|
|
550
|
+
|
|
551
|
+
function makeResponse(id, result) {
|
|
552
|
+
return JSON.stringify({ jsonrpc: "2.0", id, result })
|
|
553
|
+
}
|
|
554
|
+
function makeError(id, code, message) {
|
|
555
|
+
return JSON.stringify({ jsonrpc: "2.0", id, error: { code, message } })
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
function handleMessage(msg) {
|
|
559
|
+
const { id, method, params } = msg
|
|
560
|
+
switch (method) {
|
|
561
|
+
case "initialize":
|
|
562
|
+
return makeResponse(id, { protocolVersion: "2024-11-05", capabilities: { tools: {} }, serverInfo: SERVER_INFO })
|
|
563
|
+
case "notifications/initialized":
|
|
564
|
+
return null
|
|
565
|
+
case "tools/list":
|
|
566
|
+
return makeResponse(id, { tools: TOOLS })
|
|
567
|
+
case "tools/call": {
|
|
568
|
+
const toolName = params?.name
|
|
569
|
+
const toolArgs = params?.arguments || {}
|
|
570
|
+
try {
|
|
571
|
+
const result = handleToolCall(toolName, toolArgs)
|
|
572
|
+
return makeResponse(id, { content: [{ type: "text", text: result }] })
|
|
573
|
+
} catch (err) {
|
|
574
|
+
return makeResponse(id, { content: [{ type: "text", text: `Error: ${err.message}` }], isError: true })
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
case "ping":
|
|
578
|
+
return makeResponse(id, {})
|
|
579
|
+
default:
|
|
580
|
+
if (id != null) return makeError(id, -32601, `Method not found: ${method}`)
|
|
581
|
+
return null
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
// ─── Main ──────────────────────────────────────────────────────────────────────
|
|
586
|
+
|
|
587
|
+
const rl = createInterface({ input: process.stdin, terminal: false })
|
|
588
|
+
let buffer = ""
|
|
589
|
+
|
|
590
|
+
process.stdin.on("data", (chunk) => {
|
|
591
|
+
buffer += chunk.toString()
|
|
592
|
+
while (buffer.length > 0) {
|
|
593
|
+
const headerMatch = buffer.match(/^Content-Length:\s*(\d+)\r?\n\r?\n/)
|
|
594
|
+
if (headerMatch) {
|
|
595
|
+
const contentLength = parseInt(headerMatch[1], 10)
|
|
596
|
+
const headerLength = headerMatch[0].length
|
|
597
|
+
if (buffer.length >= headerLength + contentLength) {
|
|
598
|
+
const body = buffer.slice(headerLength, headerLength + contentLength)
|
|
599
|
+
buffer = buffer.slice(headerLength + contentLength)
|
|
600
|
+
try {
|
|
601
|
+
const response = handleMessage(JSON.parse(body))
|
|
602
|
+
if (response) {
|
|
603
|
+
const responseBytes = Buffer.byteLength(response, "utf-8")
|
|
604
|
+
process.stdout.write(`Content-Length: ${responseBytes}\r\n\r\n${response}`)
|
|
605
|
+
}
|
|
606
|
+
} catch {}
|
|
607
|
+
continue
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
const newlineIdx = buffer.indexOf("\n")
|
|
611
|
+
if (newlineIdx !== -1) {
|
|
612
|
+
const line = buffer.slice(0, newlineIdx).trim()
|
|
613
|
+
buffer = buffer.slice(newlineIdx + 1)
|
|
614
|
+
if (line.startsWith("{")) {
|
|
615
|
+
try {
|
|
616
|
+
const response = handleMessage(JSON.parse(line))
|
|
617
|
+
if (response) process.stdout.write(response + "\n")
|
|
618
|
+
} catch {}
|
|
619
|
+
}
|
|
620
|
+
continue
|
|
621
|
+
}
|
|
622
|
+
break
|
|
623
|
+
}
|
|
624
|
+
})
|
|
625
|
+
|
|
626
|
+
rl.on("close", () => process.exit(0))
|