feat: add managed system prompt optimization

Add an opt-in OpenCode plugin that replaces the built-in provider behavioral prompt with a minimal identity while preserving environment, project, MCP, skill, history, and tool context.

Track the active agent per session and apply the transform only to build and plan. Keep plan/build mode reminders and permission enforcement owned by OpenCode, leave all other agents untouched, and fail safely when the expected prompt boundary is absent.

Expose the feature in Behavior settings with localized guidance, explicit Save + Reload application, settings search integration, persisted boolean validation, and managed-runtime lifecycle composition that does not load the plugin while disabled or on external OpenCode servers.

Document the runtime contract and cover plugin materialization, config preservation, build/plan selection, agent switching, unknown prompt formats, and settings sanitization.
This commit is contained in:
Bohdan Triapitsyn
2026-07-29 01:42:40 +03:00
parent 0259f11017
commit 3cf1d82106
21 changed files with 334 additions and 3 deletions
@@ -546,6 +546,11 @@ export const settingsDict = {
"settings.behavior.page.warning.title": "Regras globais são combinadas com regras do projeto",
"settings.behavior.page.warning.description": "As alterações feitas aqui atualizam {path}. O OpenCode também inclui qualquer AGENTS.md a nível de projeto quando existir.",
"settings.behavior.page.section.systemPrompt": "AGENTS.md global",
"settings.behavior.page.section.systemPromptOptimization": "Otimização do prompt do sistema",
"settings.behavior.page.systemPromptOptimization.enable": "Otimizar o tamanho do prompt do sistema",
"settings.behavior.page.systemPromptOptimization.enableAria": "Otimizar o tamanho do prompt do sistema do OpenCode",
"settings.behavior.page.systemPromptOptimization.info": "Reduz o prompt do sistema em cerca de 40% para os agentes build e plan. Os outros agentes não são alterados. Isso pode remover definições personalizadas que substituem build ou plan, portanto não ative nesses fluxos de trabalho. A alteração é aplicada após reiniciar o OpenCode.",
"settings.behavior.page.systemPromptOptimization.restarting": "Reiniciando o OpenCode para aplicar a otimização do prompt do sistema…",
"settings.behavior.page.field.systemPromptPlaceholder": "Você é um assistente de IA útil...\n\nUse este espaço para definir regras absolutas sobre como a IA deve se comportar em todas as sessões e provedores.",
"settings.behavior.page.section.responseStyle": "Estilo de resposta",
"settings.behavior.page.responseStyle.tooltip": "Quando habilitado, estas instruções orientam como o assistente responde em cada nova conversa. Elas são enviadas com sua primeira mensagem e não alteram suas regras globais de AGENTS.md.",