Ungenutzter Parameter toolName in extractTargetDirectory #137

Closed
opened 2026-01-24 09:48:03 +00:00 by jack · 0 comments
Owner

Problem

In packages/hooks/src/handlers/post-tool-use.ts akzeptiert die Funktion extractTargetDirectory einen Parameter toolName, der nicht verwendet wird.

Code (Zeile 62-85)

function extractTargetDirectory(toolName: string, toolInput: string): string | undefined {
  try {
    const input = JSON.parse(toolInput);

    // File-based tools: Read, Write, Edit, NotebookEdit
    if (input.file_path) {
      return path.dirname(input.file_path);
    }

    // Path-based tools: Glob, Grep
    if (input.path) {
      return input.path;
    }

    // Notebook tools
    if (input.notebook_path) {
      return path.dirname(input.notebook_path);
    }

    return undefined;
  } catch {
    return undefined;
  }
}

Der Docstring sagt "based on tool type", aber toolName wird nie verwendet - die Funktion prüft nur die Input-Properties.

Analyse

Mögliche Erklärungen:

  1. Dead Code - Der Parameter ist nicht nötig, da die Input-Properties ausreichen
  2. Unvollständige Implementierung - Für bestimmte Tools könnte spezielle Logik nötig sein (z.B. Bash-Commands parsen)

Optionen

Option A: Parameter entfernen

Wenn die aktuelle Logik ausreicht:

function extractTargetDirectory(toolInput: string): string | undefined {

Option B: Parameter verwenden

Falls tool-spezifische Logik sinnvoll wäre:

if (toolName === 'Bash' && input.command) {
  // Parse working directory from bash command
}

⚠️ Wichtig: Nicht einfach löschen! Prüfen ob der Parameter für zukünftige Tool-spezifische Logik gedacht war.

Betroffene Datei

packages/hooks/src/handlers/post-tool-use.ts - Zeile 62

## Problem In `packages/hooks/src/handlers/post-tool-use.ts` akzeptiert die Funktion `extractTargetDirectory` einen Parameter `toolName`, der nicht verwendet wird. ### Code (Zeile 62-85) ```typescript function extractTargetDirectory(toolName: string, toolInput: string): string | undefined { try { const input = JSON.parse(toolInput); // File-based tools: Read, Write, Edit, NotebookEdit if (input.file_path) { return path.dirname(input.file_path); } // Path-based tools: Glob, Grep if (input.path) { return input.path; } // Notebook tools if (input.notebook_path) { return path.dirname(input.notebook_path); } return undefined; } catch { return undefined; } } ``` Der Docstring sagt "based on tool type", aber `toolName` wird nie verwendet - die Funktion prüft nur die Input-Properties. ## Analyse Mögliche Erklärungen: 1. **Dead Code** - Der Parameter ist nicht nötig, da die Input-Properties ausreichen 2. **Unvollständige Implementierung** - Für bestimmte Tools könnte spezielle Logik nötig sein (z.B. Bash-Commands parsen) ## Optionen ### Option A: Parameter entfernen Wenn die aktuelle Logik ausreicht: ```typescript function extractTargetDirectory(toolInput: string): string | undefined { ``` ### Option B: Parameter verwenden Falls tool-spezifische Logik sinnvoll wäre: ```typescript if (toolName === 'Bash' && input.command) { // Parse working directory from bash command } ``` ⚠️ **Wichtig:** Nicht einfach löschen! Prüfen ob der Parameter für zukünftige Tool-spezifische Logik gedacht war. ## Betroffene Datei `packages/hooks/src/handlers/post-tool-use.ts` - Zeile 62
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
customable/claude-mem#137
No description provided.