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
@@ -151,6 +151,11 @@ export const settingsDict = {
'settings.behavior.page.responseStyle.tooltip': 'Jeśli jest włączone, instrukcje te określają sposób odpowiadania asystenta w każdej nowej rozmowie. Są one przesyłane z Twoją pierwszą wiadomością i nie zmieniają Twoich globalnych reguł AGENTS.md.',
'settings.behavior.page.section.responseStyle': 'Styl odpowiedzi',
'settings.behavior.page.section.systemPrompt': 'Globalny AGENTS.md',
'settings.behavior.page.section.systemPromptOptimization': 'Optymalizacja promptu systemowego',
'settings.behavior.page.systemPromptOptimization.enable': 'Optymalizuj rozmiar promptu systemowego',
'settings.behavior.page.systemPromptOptimization.enableAria': 'Optymalizuj rozmiar promptu systemowego OpenCode',
'settings.behavior.page.systemPromptOptimization.info': 'Zmniejsza prompt systemowy o około 40% dla agentów build i plan. Inni agenci pozostają bez zmian. Może to usunąć niestandardowe definicje zastępujące build lub plan, dlatego nie włączaj tej opcji w takich przepływach pracy. Zmiana zostanie zastosowana po ponownym uruchomieniu OpenCode.',
'settings.behavior.page.systemPromptOptimization.restarting': 'Ponowne uruchamianie OpenCode w celu zastosowania optymalizacji promptu systemowego…',
'settings.behavior.page.title': 'Zachowanie',
'settings.behavior.page.toast.saveFailed': 'Nie udało się zapisać zachowania',
'settings.behavior.page.toast.saved': 'Zachowanie zostało zapisane pomyślnie',