fix(keyword-detector): use session state for agent-specific ultrawork templates
Bug: When switching from Prometheus to Sisyphus, the Prometheus ultrawork template was still injected because: 1. setSessionAgent() only sets on first call, ignoring subsequent updates 2. keyword-detector relied solely on input.agent which could be stale Fix: - Use updateSessionAgent() instead of setSessionAgent() in index.ts - keyword-detector now uses getSessionAgent() as primary source, fallback to input.agent - Added tests for agent switch scenario
This commit is contained in:
@@ -2,7 +2,7 @@ import type { PluginInput } from "@opencode-ai/plugin"
|
||||
import { detectKeywordsWithType, extractPromptText, removeCodeBlocks } from "./detector"
|
||||
import { log } from "../../shared"
|
||||
import { isSystemDirective } from "../../shared/system-directive"
|
||||
import { getMainSessionID } from "../../features/claude-code-session-state"
|
||||
import { getMainSessionID, getSessionAgent } from "../../features/claude-code-session-state"
|
||||
import type { ContextCollector } from "../../features/context-injector"
|
||||
|
||||
export * from "./detector"
|
||||
@@ -30,7 +30,8 @@ export function createKeywordDetectorHook(ctx: PluginInput, collector?: ContextC
|
||||
return
|
||||
}
|
||||
|
||||
let detectedKeywords = detectKeywordsWithType(removeCodeBlocks(promptText), input.agent)
|
||||
const currentAgent = getSessionAgent(input.sessionID) ?? input.agent
|
||||
let detectedKeywords = detectKeywordsWithType(removeCodeBlocks(promptText), currentAgent)
|
||||
|
||||
if (detectedKeywords.length === 0) {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user