fix(hooks): fix agent-usage-reminder case-sensitivity bug in tool name matching

- Change TARGET_TOOLS and AGENT_TOOLS to Set<string> for O(1) lookup
- Normalize tool names to lowercase for case-insensitive comparison
- Remove unnecessary parentSessionID guard that blocked main session triggers
- Fixes issue where Glob/Grep tool calls weren't showing agent usage reminder

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
This commit is contained in:
YeonGyu-Kim
2025-12-13 22:13:02 +09:00
parent 2c6dfeadce
commit f3b2fccba7
2 changed files with 14 additions and 18 deletions

View File

@@ -7,23 +7,24 @@ export const AGENT_USAGE_REMINDER_STORAGE = join(
"agent-usage-reminder",
);
export const TARGET_TOOLS = [
"Grep",
// All tool names normalized to lowercase for case-insensitive matching
export const TARGET_TOOLS = new Set([
"grep",
"safe_grep",
"Glob",
"glob",
"safe_glob",
"WebFetch",
"webfetch",
"context7_resolve-library-id",
"context7_get-library-docs",
"websearch_exa_web_search_exa",
"grep_app_searchGitHub",
] as const;
"grep_app_searchgithub",
]);
export const AGENT_TOOLS = [
"Task",
export const AGENT_TOOLS = new Set([
"task",
"call_omo_agent",
"background_task",
] as const;
]);
export const REMINDER_MESSAGE = `
[Agent Usage Reminder]

View File

@@ -11,7 +11,6 @@ interface ToolExecuteInput {
tool: string;
sessionID: string;
callID: string;
parentSessionID?: string;
}
interface ToolExecuteOutput {
@@ -60,19 +59,15 @@ export function createAgentUsageReminderHook(_ctx: PluginInput) {
input: ToolExecuteInput,
output: ToolExecuteOutput,
) => {
const { tool, sessionID, parentSessionID } = input;
const { tool, sessionID } = input;
const toolLower = tool.toLowerCase();
// Only run in root sessions (no parent = main session)
if (parentSessionID) {
return;
}
if ((AGENT_TOOLS as readonly string[]).includes(tool)) {
if (AGENT_TOOLS.has(toolLower)) {
markAgentUsed(sessionID);
return;
}
if (!(TARGET_TOOLS as readonly string[]).includes(tool)) {
if (!TARGET_TOOLS.has(toolLower)) {
return;
}