refactor(default-mode): inject ultrawork via system prompt instead of visible text

When default_mode.ultrawork is enabled, inject the ultrawork behavioral
instructions into the system prompt (experimental.chat.system.transform)
instead of prepending them to the user's visible chat message.

- system-transform.ts: No-op handler now injects ultrawork message into
  output.system[] when defaultMode.ultrawork is active. Checks for existing
  <ultrawork-mode> tag to avoid re-injection after compaction.
- keyword-detector/hook.ts: Removes the visible text injection
  (output.parts[].text prepend) for default_mode.ultrawork path. Only
  shows the toast as the user-facing indicator.
- plugin-interface.ts: Wires getUltraworkMessage from keyword-detector
  into createSystemTransformHandler.

Result: Ultrawork mode activates silently via system prompt — the chat
stays clean, and only a toast shows 'Ultrawork Mode Active'.
This commit is contained in:
herjarsa
2026-05-19 15:50:02 +02:00
parent e5463e2db7
commit 2f1380f52d
3 changed files with 28 additions and 12 deletions
+2 -9
View File
@@ -17,7 +17,7 @@ import {
removeSystemReminders,
} from "../../shared/system-directive"
import type { RalphLoopHook } from "../ralph-loop"
import { getUltraworkMessage, isNonOmoAgent, isPlannerAgent } from "./constants"
import { isNonOmoAgent, isPlannerAgent } from "./constants"
import type { DetectedKeyword } from "./detector"
import { detectKeywordsWithType, extractPromptText, looksLikeSlashCommand } from "./detector"
@@ -113,14 +113,7 @@ export function createKeywordDetectorHook(
if (defaultMode?.ultrawork && !isNonMainSession && !defaultModeUltraworkInjectedSessions.has(input.sessionID)) {
defaultModeUltraworkInjectedSessions.add(input.sessionID)
const ultraworkMessage = getUltraworkMessage(currentAgent, modelID)
const textPartIndex = output.parts.findIndex(isRealUserTextPart)
if (textPartIndex >= 0) {
const originalText = output.parts[textPartIndex].text ?? ""
output.parts[textPartIndex].text = `${ultraworkMessage}\n\n---\n\n${originalText}`
}
log(`[keyword-detector] Default ultrawork mode auto-activated`, { sessionID: input.sessionID })
log(`[keyword-detector] Default ultrawork mode auto-activated (injected via system prompt)`, { sessionID: input.sessionID })
ctx.client.tui
.showToast({