Skip to content
This repository was archived by the owner on Feb 1, 2026. It is now read-only.

Commit f89193d

Browse files
Eveclaude
andcommitted
feat(hooks): extend heuristic consultation to task management, web, and MCP tools
Closes #97 - adds pre-tool heuristic consultation coverage for: - Task management tools: TaskCreate, TaskUpdate, TaskList, TaskGet - Web tools: WebFetch, WebSearch - MCP tools: all mcp__* prefixed tools via pattern matching Domain extraction now analyzes task subjects/descriptions, web URLs/queries, and MCP tool parameters to surface relevant heuristics before execution. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 1dcbc70 commit f89193d

1 file changed

Lines changed: 30 additions & 3 deletions

File tree

src/hooks/learning-loop/pre_tool_learning.py

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ def score(cls, tool_name: str, tool_input: dict, domains: List[str]) -> Dict:
257257
"coordination": ["service-coordination", "multi-agent-coordination"],
258258
"cli": ["cli-architecture", "cli-design"],
259259
"file": ["file-io", "file-operations", "file-organization", "file-write-safety"],
260+
"task-management": ["task-management", "workflow", "project-management", "todo"],
260261
}
261262

262263

@@ -283,6 +284,21 @@ def extract_domain_from_context(tool_name: str, tool_input: dict) -> List[str]:
283284
elif tool_name in ("Edit", "Write"):
284285
# Include file path and content for Edit/Write operations
285286
text = tool_input.get("file_path", "") + " " + tool_input.get("old_string", "") + " " + tool_input.get("new_string", "") + " " + tool_input.get("content", "")
287+
elif tool_name in ("TaskCreate", "TaskUpdate"):
288+
# Include subject, description, and metadata for task management
289+
text = tool_input.get("subject", "") + " " + tool_input.get("description", "") + " " + tool_input.get("activeForm", "")
290+
elif tool_name in ("TaskList", "TaskGet"):
291+
# Task listing/getting - minimal context, mainly for workflow domain
292+
text = "task management workflow"
293+
elif tool_name == "WebFetch":
294+
# Web fetching - include URL and prompt for domain extraction
295+
text = tool_input.get("url", "") + " " + tool_input.get("prompt", "")
296+
elif tool_name == "WebSearch":
297+
# Web search - include query for domain extraction
298+
text = tool_input.get("query", "")
299+
elif tool_name.startswith("mcp__"):
300+
# MCP tools - extract from tool name and any text parameters
301+
text = tool_name + " " + " ".join(str(v) for v in tool_input.values() if isinstance(v, str))
286302

287303
text = text.lower()
288304

@@ -325,6 +341,11 @@ def extract_domain_from_context(tool_name: str, tool_input: dict) -> List[str]:
325341
"cli": ["cli", "command", "terminal", "shell"],
326342
"coordination": ["coordination", "handoff", "blackboard"],
327343
"documentation": ["document", "readme", "claude.md"],
344+
"task-management": ["task", "todo", "tracking", "progress", "checklist", "milestone", "backlog", "sprint"],
345+
"web": ["web", "http", "url", "fetch", "scrape", "crawl", "html", "website"],
346+
"api-integration": ["api", "endpoint", "rest", "graphql", "webhook", "integration"],
347+
"mcp": ["mcp", "model context protocol", "tool server", "context7"],
348+
"documentation": ["docs", "documentation", "readme", "guide", "tutorial", "reference"],
328349
"general": ["general", "misc"],
329350
}
330351

@@ -616,10 +637,16 @@ def main():
616637
})
617638
return
618639

619-
# Learning loop processes ALL investigation and modification tools
640+
# Learning loop processes investigation, modification, task management, and web/MCP tools
620641
# This enables learning from Grep, Read, Glob, Edit, Write, Bash operations
621-
INVESTIGATION_TOOLS = {"Task", "Bash", "Grep", "Read", "Glob", "Edit", "Write"}
622-
if tool_name not in INVESTIGATION_TOOLS:
642+
# Also includes task management tools (TaskCreate, TaskUpdate, TaskList, TaskGet)
643+
# And web/MCP tools (WebFetch, WebSearch, mcp__* tools)
644+
INVESTIGATION_TOOLS = {"Task", "Bash", "Grep", "Read", "Glob", "Edit", "Write",
645+
"TaskCreate", "TaskUpdate", "TaskList", "TaskGet",
646+
"WebFetch", "WebSearch"}
647+
# Check if tool is in set OR is an MCP tool (mcp__* prefix)
648+
is_mcp_tool = tool_name.startswith("mcp__")
649+
if tool_name not in INVESTIGATION_TOOLS and not is_mcp_tool:
623650
output_result({"decision": "approve"})
624651
return
625652

0 commit comments

Comments
 (0)