Skip to content

Commit 67a1dba

Browse files
authored
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)
1 parent 98df151 commit 67a1dba

File tree

2 files changed

+0
-21
lines changed

2 files changed

+0
-21
lines changed

src/hooks/keyword-detector/index.ts

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ export * from "./detector"
66
export * from "./constants"
77
export * from "./types"
88

9-
const injectedSessions = new Set<string>()
10-
119
export function createKeywordDetectorHook() {
1210
return {
1311
"chat.message": async (
@@ -22,10 +20,6 @@ export function createKeywordDetectorHook() {
2220
parts: Array<{ type: string; text?: string; [key: string]: unknown }>
2321
}
2422
): Promise<void> => {
25-
if (injectedSessions.has(input.sessionID)) {
26-
return
27-
}
28-
2923
const promptText = extractPromptText(output.parts)
3024
const messages = detectKeywords(promptText)
3125

@@ -52,22 +46,8 @@ export function createKeywordDetectorHook() {
5246
})
5347

5448
if (success) {
55-
injectedSessions.add(input.sessionID)
5649
log("Keyword context injected", { sessionID: input.sessionID })
5750
}
5851
},
59-
60-
event: async ({
61-
event,
62-
}: {
63-
event: { type: string; properties?: unknown }
64-
}) => {
65-
if (event.type === "session.deleted") {
66-
const props = event.properties as { info?: { id?: string } } | undefined
67-
if (props?.info?.id) {
68-
injectedSessions.delete(props.info.id)
69-
}
70-
}
71-
},
7252
}
7353
}

src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,6 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
410410
await rulesInjector?.event(input);
411411
await thinkMode?.event(input);
412412
await anthropicAutoCompact?.event(input);
413-
await keywordDetector?.event(input);
414413
await agentUsageReminder?.event(input);
415414
await interactiveBashSession?.event(input);
416415

0 commit comments

Comments
 (0)