Merge pull request #4190 from herjarsa/feat/default-mode
feat(default-mode): auto-activate ultrawork and ralph loop without commands
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import type { PluginInput } from "@opencode-ai/plugin"
|
||||
import type { DefaultModeConfig } from "../../config/schema/default-mode"
|
||||
import type { KeywordDetectorConfig } from "../../config/schema/keyword-detector"
|
||||
import {
|
||||
getMainSessionID,
|
||||
@@ -20,6 +21,8 @@ import { isNonOmoAgent, isPlannerAgent } from "./constants"
|
||||
import type { DetectedKeyword } from "./detector"
|
||||
import { detectKeywordsWithType, extractPromptText, looksLikeSlashCommand } from "./detector"
|
||||
|
||||
const defaultModeUltraworkInjectedSessions = new Set<string>()
|
||||
|
||||
function suppressComboStandalones(detected: DetectedKeyword[]): DetectedKeyword[] {
|
||||
const hasCombo = detected.some((k) => k.type === "hyperplan-ultrawork")
|
||||
if (!hasCombo) return detected
|
||||
@@ -31,6 +34,7 @@ export function createKeywordDetectorHook(
|
||||
_collector?: ContextCollector,
|
||||
_ralphLoop?: Pick<RalphLoopHook, "startLoop">,
|
||||
config?: KeywordDetectorConfig,
|
||||
defaultMode?: DefaultModeConfig,
|
||||
) {
|
||||
const disabledKeywords = config?.disabled_keywords
|
||||
function getRuntimeVariant(input: { variant?: string }, message: Record<string, unknown>): string | undefined {
|
||||
@@ -74,13 +78,11 @@ export function createKeywordDetectorHook(
|
||||
|
||||
const currentAgent = getSessionAgent(input.sessionID) ?? input.agent
|
||||
|
||||
// Skip all keyword injection for non-OMO agents (e.g., OpenCode-Builder, Plan)
|
||||
if (isNonOmoAgent(currentAgent)) {
|
||||
log(`[keyword-detector] Skipping keyword injection for non-OMO agent`, { sessionID: input.sessionID, agent: currentAgent })
|
||||
return
|
||||
}
|
||||
|
||||
// Remove system-reminder content to prevent automated system messages from triggering mode keywords
|
||||
const cleanText = removeSystemReminders(promptText)
|
||||
const modelID = input.model?.modelID
|
||||
let detectedKeywords = detectKeywordsWithType(cleanText, currentAgent, modelID, disabledKeywords)
|
||||
@@ -96,19 +98,42 @@ export function createKeywordDetectorHook(
|
||||
}
|
||||
}
|
||||
|
||||
if (detectedKeywords.length === 0) {
|
||||
return
|
||||
}
|
||||
|
||||
const isBackgroundTaskSession = subagentSessions.has(input.sessionID)
|
||||
if (isBackgroundTaskSession) {
|
||||
log(`[keyword-detector] Skipping keyword injection for background task session`, { sessionID: input.sessionID })
|
||||
if (detectedKeywords.length > 0) {
|
||||
log(`[keyword-detector] Skipping keyword injection for background task session`, { sessionID: input.sessionID })
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
const mainSessionID = getMainSessionID()
|
||||
const isNonMainSession = mainSessionID && input.sessionID !== mainSessionID
|
||||
|
||||
if (detectedKeywords.length === 0) {
|
||||
if (defaultMode?.ultrawork && !isNonMainSession && !defaultModeUltraworkInjectedSessions.has(input.sessionID)) {
|
||||
defaultModeUltraworkInjectedSessions.add(input.sessionID)
|
||||
|
||||
log(`[keyword-detector] Default ultrawork mode auto-activated (injected via system prompt)`, { sessionID: input.sessionID })
|
||||
|
||||
ctx.client.tui
|
||||
.showToast({
|
||||
body: {
|
||||
title: "Ultrawork Mode Activated",
|
||||
message: "Default ultrawork mode enabled. All agents at your disposal.",
|
||||
variant: "success" as const,
|
||||
duration: 3000,
|
||||
},
|
||||
})
|
||||
.catch((err) =>
|
||||
log(`[keyword-detector] Failed to show toast`, {
|
||||
error: err,
|
||||
sessionID: input.sessionID,
|
||||
})
|
||||
)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if (isNonMainSession) {
|
||||
detectedKeywords = detectedKeywords.filter(
|
||||
(k) => k.type === "ultrawork" || k.type === "hyperplan-ultrawork"
|
||||
|
||||
@@ -6,16 +6,7 @@ function getMaxIterationsLabel(state: RalphLoopState): string {
|
||||
}
|
||||
|
||||
const CONTINUATION_PROMPT = `${SYSTEM_DIRECTIVE_PREFIX} - RALPH LOOP {{ITERATION}}/{{MAX}}]
|
||||
|
||||
Your previous attempt did not output the completion promise. Continue working on the task.
|
||||
|
||||
IMPORTANT:
|
||||
- Review your progress so far
|
||||
- Continue from where you left off
|
||||
- When FULLY complete, output: <promise>{{PROMISE}}</promise>
|
||||
- Do not stop until the task is truly done
|
||||
|
||||
Original task:
|
||||
Continue. Output <promise>{{PROMISE}}</promise> when done.
|
||||
{{PROMPT}}`
|
||||
|
||||
const ULTRAWORK_VERIFICATION_PROMPT = `${SYSTEM_DIRECTIVE_PREFIX} - ULTRAWORK LOOP VERIFICATION {{ITERATION}}/{{MAX}}]
|
||||
|
||||
Reference in New Issue
Block a user