strapi-plugin-mcp-chat 0.1.0 → 0.3.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 +60 -4
- package/admin/src/components/AdminOverlays.tsx +35 -1
- package/admin/src/components/FloatingChat.tsx +14 -0
- package/admin/src/components/LangSwitcher.tsx +24 -0
- package/admin/src/components/Onboarding.tsx +192 -0
- package/admin/src/components/PreviewPanel.tsx +22 -1
- package/admin/src/components/StackLogos.tsx +60 -0
- package/admin/src/i18n.ts +214 -0
- package/admin/src/pages/HomePage.tsx +55 -24
- package/admin/src/pages/ProvisionPage.tsx +54 -59
- package/dist/server/index.js +60 -16
- package/package.json +1 -1
- package/server/src/content-tools.ts +26 -4
- package/server/src/controllers/chat.ts +2 -2
- package/server/src/provision/integrate.ts +15 -1
- package/server/src/services/chat.ts +28 -8
|
@@ -25,6 +25,12 @@ type ChatInput = {
|
|
|
25
25
|
lang?: Lang;
|
|
26
26
|
/** URL da página aberta no preview — contexto do "isso aqui". */
|
|
27
27
|
previewUrl?: string | null;
|
|
28
|
+
/**
|
|
29
|
+
* Política de publicação. `false` (default) = modo RASCUNHO: o agente edita o
|
|
30
|
+
* draft e NÃO publica, a menos que o usuário peça explicitamente. `true` =
|
|
31
|
+
* auto-publicar após cada edição (comportamento "live" antigo).
|
|
32
|
+
*/
|
|
33
|
+
autoPublish?: boolean;
|
|
28
34
|
};
|
|
29
35
|
|
|
30
36
|
const MODEL = process.env.OPENAI_CHAT_MODEL || 'gpt-4o';
|
|
@@ -42,9 +48,9 @@ Ferramentas de conteúdo:
|
|
|
42
48
|
Fluxo padrão quando o usuário pede uma mudança no site (por texto, voz ou mostrando a tela):
|
|
43
49
|
1. Use buscar_texto com um trecho distintivo do texto a alterar (sem rótulos de status).
|
|
44
50
|
2. Se houver mais de um resultado, escolha o mais provável pelo contexto (e diga qual escolheu); se ambíguo de verdade, pergunte.
|
|
45
|
-
3. editar_campo passando o mesmo uid, documentId e path do resultado, com o novo valor.
|
|
46
|
-
4.
|
|
47
|
-
5. Confirme em 1 frase o que foi alterado
|
|
51
|
+
3. editar_campo passando o mesmo uid, documentId e path do resultado, com o novo valor. Isso salva como RASCUNHO (não publica).
|
|
52
|
+
4. Decida se publica ou não conforme a POLÍTICA DE PUBLICAÇÃO indicada mais abaixo.
|
|
53
|
+
5. Confirme em 1 frase o que foi alterado (content-type, campo, antes → depois) e se ficou como rascunho ou foi publicado.
|
|
48
54
|
|
|
49
55
|
Ferramentas de tradução / idiomas (i18n):
|
|
50
56
|
- listar_locales(): mostra os idiomas configurados e o default.
|
|
@@ -58,6 +64,8 @@ Fluxo quando o usuário pede tradução (ex.: "quero o site todo em pt-BR"):
|
|
|
58
64
|
3. Após o restart, ao repetir, traduzir funciona e localiza tudo.
|
|
59
65
|
4. Confirme em 1 frase: idiomas, quantos documentos e campos foram traduzidos/publicados (use o resumo retornado, não despeje o conteúdo).
|
|
60
66
|
|
|
67
|
+
Draft & Publish: cada resultado de buscar_texto traz "draftAndPublish". Se for false, aquele tipo NÃO tem rascunho no Strapi — a edição já é o conteúdo vivo e NÃO há o que publicar; nesse caso, ao confirmar, avise que "esse conteúdo não tem rascunho, a alteração já está no ar" e NÃO chame publicar.
|
|
68
|
+
|
|
61
69
|
Se o usuário compartilhar a tela, uma imagem é anexada à última mensagem — use-a para entender exatamente o que ele está vendo e qual texto quer trocar.
|
|
62
70
|
|
|
63
71
|
Seja objetivo e acionável. Responda SEMPRE em português.`,
|
|
@@ -71,9 +79,9 @@ Content tools:
|
|
|
71
79
|
Default flow when the user asks for a site change (by text, voice or by showing their screen):
|
|
72
80
|
1. Use buscar_texto with a distinctive snippet of the text to change (no status labels).
|
|
73
81
|
2. If there is more than one result, pick the most likely from context (and say which); if truly ambiguous, ask.
|
|
74
|
-
3. editar_campo passing the same uid, documentId and path from the result, with the new value.
|
|
75
|
-
4.
|
|
76
|
-
5. Confirm in one sentence what was changed
|
|
82
|
+
3. editar_campo passing the same uid, documentId and path from the result, with the new value. This saves a DRAFT (does not publish).
|
|
83
|
+
4. Decide whether to publish based on the PUBLISH POLICY stated below.
|
|
84
|
+
5. Confirm in one sentence what was changed (content-type, field, before → after) and whether it stayed a draft or was published.
|
|
77
85
|
|
|
78
86
|
Translation / language tools (i18n):
|
|
79
87
|
- listar_locales(): shows configured languages and the default.
|
|
@@ -87,13 +95,15 @@ Flow when the user asks for translation (e.g. "I want the whole site in pt-BR"):
|
|
|
87
95
|
3. After the restart, repeating the request makes traduzir localize everything.
|
|
88
96
|
4. Confirm in one sentence: languages, how many documents and fields were translated/published (use the returned summary, don't dump the content).
|
|
89
97
|
|
|
98
|
+
Draft & Publish: each buscar_texto result includes "draftAndPublish". If it is false, that type has NO draft in Strapi — the edit IS the live content and there is nothing to publish; in that case, when confirming, warn that "this content has no draft, the change is already live" and do NOT call publicar.
|
|
99
|
+
|
|
90
100
|
If the user shares their screen, an image is attached to the last message — use it to understand exactly what they see and which text they want to change.
|
|
91
101
|
|
|
92
102
|
Be concise and actionable. ALWAYS answer in English.`,
|
|
93
103
|
};
|
|
94
104
|
|
|
95
105
|
export default ({ strapi }: { strapi: any }) => ({
|
|
96
|
-
async chat({ messages, image, lang = 'pt', previewUrl }: ChatInput) {
|
|
106
|
+
async chat({ messages, image, lang = 'pt', previewUrl, autoPublish = false }: ChatInput) {
|
|
97
107
|
const apiKey = process.env.OPENAI_API_KEY;
|
|
98
108
|
if (!apiKey) {
|
|
99
109
|
throw new Error(
|
|
@@ -156,7 +166,17 @@ export default ({ strapi }: { strapi: any }) => ({
|
|
|
156
166
|
pt: `\n\nVocê também controla um navegador real via ferramentas browser_* (Playwright), apontado para o ADMIN DA STRAPI em ${adminBase} (o backend — é aqui que o conteúdo muda de verdade, NÃO no site público). Pode navegar (browser_navigate), clicar, digitar, rolar, tirar seus próprios screenshots (browser_take_screenshot) e inspecionar console/erros. Prefira sempre suas ferramentas diretas (buscar_texto/editar_campo/publicar) para alterar conteúdo; use o navegador para VERIFICAR no admin que a edição/publicação ficou correta, ou para fluxos da UI que as ferramentas diretas não cobrem.`,
|
|
157
167
|
en: `\n\nYou also control a real browser via browser_* tools (Playwright), pointed at the STRAPI ADMIN at ${adminBase} (the backend — this is where content actually changes, NOT the public site). You can navigate (browser_navigate), click, type, scroll, take your own screenshots (browser_take_screenshot) and inspect console/errors. Always prefer your direct tools (buscar_texto/editar_campo/publicar) to change content; use the browser to VERIFY in the admin that the edit/publish landed, or for admin UI flows the direct tools don't cover.`,
|
|
158
168
|
};
|
|
159
|
-
|
|
169
|
+
// ── Política de publicação (draft-first por padrão) ───────────────────────
|
|
170
|
+
const PUBLISH_POLICY: Record<Lang, string> = {
|
|
171
|
+
pt: autoPublish
|
|
172
|
+
? `\n\nPOLÍTICA DE PUBLICAÇÃO: AUTO-PUBLICAR está LIGADO. Depois de editar_campo, chame publicar para deixar a mudança no ar. Em traduzir, use publish:true (default).`
|
|
173
|
+
: `\n\nPOLÍTICA DE PUBLICAÇÃO: MODO RASCUNHO (auto-publicar DESLIGADO). NÃO chame publicar a menos que o usuário peça explicitamente ("publica", "põe no ar", "publish"). Depois de editar_campo, PARE e avise que a alteração foi salva como RASCUNHO para revisão (ela já aparece no preview em modo rascunho, mas ainda não no site público). Em traduzir, passe publish:false. Se o usuário pedir para publicar, aí sim use publicar (ou traduzir com publish:true).`,
|
|
174
|
+
en: autoPublish
|
|
175
|
+
? `\n\nPUBLISH POLICY: AUTO-PUBLISH is ON. After editar_campo, call publicar to make the change live. For traduzir, use publish:true (default).`
|
|
176
|
+
: `\n\nPUBLISH POLICY: DRAFT MODE (auto-publish OFF). Do NOT call publicar unless the user explicitly asks ("publish", "make it live", "publica"). After editar_campo, STOP and tell them the change was saved as a DRAFT for review (it already shows in the preview when in draft mode, but not on the public site yet). For traduzir, pass publish:false. If the user asks to publish, then use publicar (or traduzir with publish:true).`,
|
|
177
|
+
};
|
|
178
|
+
const systemContent =
|
|
179
|
+
SYSTEM[language] + (hasBrowser ? BROWSER_NOTE[language] : '') + PUBLISH_POLICY[language];
|
|
160
180
|
|
|
161
181
|
// ── Monta a conversa; anexa imagem da tela à última mensagem do usuário ──
|
|
162
182
|
const convo: any[] = [{ role: 'system', content: systemContent }];
|