refactor(keyword-detector): inject keywords on every message (#99)

Remove first-message-only restriction and move keyword injection to chat.message
hook for consistent keyword presence across all messages.

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
This commit is contained in:
YeonGyu-Kim
2025-12-19 00:49:52 +09:00
committed by GitHub
parent 98df151d33
commit 67a1dba59b
2 changed files with 0 additions and 21 deletions

View File

@@ -6,8 +6,6 @@ export * from "./detector"
export * from "./constants"
export * from "./types"
const injectedSessions = new Set<string>()
export function createKeywordDetectorHook() {
return {
"chat.message": async (
@@ -22,10 +20,6 @@ export function createKeywordDetectorHook() {
parts: Array<{ type: string; text?: string; [key: string]: unknown }>
}
): Promise<void> => {
if (injectedSessions.has(input.sessionID)) {
return
}
const promptText = extractPromptText(output.parts)
const messages = detectKeywords(promptText)
@@ -52,22 +46,8 @@ export function createKeywordDetectorHook() {
})
if (success) {
injectedSessions.add(input.sessionID)
log("Keyword context injected", { sessionID: input.sessionID })
}
},
event: async ({
event,
}: {
event: { type: string; properties?: unknown }
}) => {
if (event.type === "session.deleted") {
const props = event.properties as { info?: { id?: string } } | undefined
if (props?.info?.id) {
injectedSessions.delete(props.info.id)
}
}
},
}
}