refactor: unify system directive prefix for keyword-detector filtering

- Add shared/system-directive.ts with SYSTEM_DIRECTIVE_PREFIX constant
- Unify all system message prefixes to [SYSTEM DIRECTIVE: OH-MY-OPENCODE - ...]
- Add isSystemDirective() filter to keyword-detector to skip system messages
- Update prometheus-md-only tests to use new prefix constants
This commit is contained in:
justsisyphus
2026-01-16 11:20:45 +09:00
parent b933992e36
commit c7ca608b38
11 changed files with 74 additions and 17 deletions
+7
View File
@@ -1,6 +1,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 type { ContextCollector } from "../../features/context-injector"
@@ -23,6 +24,12 @@ export function createKeywordDetectorHook(ctx: PluginInput, collector?: ContextC
}
): Promise<void> => {
const promptText = extractPromptText(output.parts)
if (isSystemDirective(promptText)) {
log(`[keyword-detector] Skipping system directive message`, { sessionID: input.sessionID })
return
}
let detectedKeywords = detectKeywordsWithType(removeCodeBlocks(promptText), input.agent)
if (detectedKeywords.length === 0) {