feat(shared): add Claude hooks command executor and utilities
- Add snake-case.ts: objectToSnakeCase, objectToCamelCase utilities - Add tool-name.ts: transformToolName with PascalCase conversion - Add pattern-matcher.ts: findMatchingHooks for hook config matching - Add hook-disabled.ts: isHookDisabled for hook config validation - Add temporary stub types at src/hooks/claude-code-hooks/types.ts - Export all new utilities from src/shared/index.ts Stub types will be replaced with full implementation in Task 1. Import paths adjusted from opencode-cc-plugin structure to oh-my-opencode. 🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
This commit is contained in:
26
src/shared/tool-name.ts
Normal file
26
src/shared/tool-name.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
const SPECIAL_TOOL_MAPPINGS: Record<string, string> = {
|
||||
webfetch: "WebFetch",
|
||||
websearch: "WebSearch",
|
||||
todoread: "TodoRead",
|
||||
todowrite: "TodoWrite",
|
||||
}
|
||||
|
||||
function toPascalCase(str: string): string {
|
||||
return str
|
||||
.split(/[-_\s]+/)
|
||||
.map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
|
||||
.join("")
|
||||
}
|
||||
|
||||
export function transformToolName(toolName: string): string {
|
||||
const lower = toolName.toLowerCase()
|
||||
if (lower in SPECIAL_TOOL_MAPPINGS) {
|
||||
return SPECIAL_TOOL_MAPPINGS[lower]
|
||||
}
|
||||
|
||||
if (toolName.includes("-") || toolName.includes("_")) {
|
||||
return toPascalCase(toolName)
|
||||
}
|
||||
|
||||
return toolName.charAt(0).toUpperCase() + toolName.slice(1)
|
||||
}
|
||||
Reference in New Issue
Block a user