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
+21 -2
View File
@@ -1,6 +1,25 @@
export function createSystemTransformHandler(): (
import type { DefaultModeConfig } from "../config/schema/default-mode"
const ULTRAWORK_MODE_TAG = "<ultrawork-mode>"
export function createSystemTransformHandler(
defaultMode?: DefaultModeConfig,
getUltraworkMessage?: (agentName?: string, modelID?: string) => string,
): (
input: { sessionID?: string; model: { id: string; providerID: string; [key: string]: unknown } },
output: { system: string[] },
) => Promise<void> {
return async (): Promise<void> => {}
return async (input, output): Promise<void> => {
if (!defaultMode?.ultrawork || !getUltraworkMessage) return
// Avoid re-injecting if the ultrawork prompt is already in the system prompt
// (e.g. after compaction the system prompt is rebuilt and this hook fires again)
if (output.system.some((part) => part.includes(ULTRAWORK_MODE_TAG))) return
const modelID = input.model?.id
const ultraworkMessage = getUltraworkMessage("sisyphus", modelID)
if (!ultraworkMessage) return
output.system.push(ultraworkMessage)
}
}