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

View File

@@ -11,7 +11,6 @@ interface ToolExecuteInput {
tool: string; tool: string;
sessionID: string; sessionID: string;
callID: string; callID: string;
parentSessionID?: string;
} }
interface ToolExecuteOutput { interface ToolExecuteOutput {
@@ -60,19 +59,15 @@ export function createAgentUsageReminderHook(_ctx: PluginInput) {
input: ToolExecuteInput, input: ToolExecuteInput,
output: ToolExecuteOutput, 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 (AGENT_TOOLS.has(toolLower)) {
if (parentSessionID) {
return;
}
if ((AGENT_TOOLS as readonly string[]).includes(tool)) {
markAgentUsed(sessionID); markAgentUsed(sessionID);
return; return;
} }
if (!(TARGET_TOOLS as readonly string[]).includes(tool)) { if (!TARGET_TOOLS.has(toolLower)) {
return; return;
} }