Skip to content

fix(adapters): read tool_input.* in signal-detect for Claude Code#522

Open
TanveerKahlon wants to merge 1 commit intoEvoMap:mainfrom
TanveerKahlon:fix/signal-detect-tool-input-shape
Open

fix(adapters): read tool_input.* in signal-detect for Claude Code#522
TanveerKahlon wants to merge 1 commit intoEvoMap:mainfrom
TanveerKahlon:fix/signal-detect-tool-input-shape

Conversation

@TanveerKahlon
Copy link
Copy Markdown

Summary

The Claude Code adapter's signal-detect hook (`src/adapters/scripts/evolver-signal-detect.js`) silently returns `{}` on every real `PostToolUse` event because it reads `content`/`file_path` from the top level of the JSON payload, but Claude Code nests tool args under `tool_input` (`tool_input.content`, `tool_input.file_path`).

Net effect on a default install: the `[Evolution Signal] Detected: [...]` context block never fires. Session-start and session-end hooks are unaffected; only signal-detect is silently dead.

The fix

Check `tool_input.*` and `tool_response.filePath` first, fall back to the legacy top-level shape for backward compatibility. Also pick up `new_string` so Edit-tool payloads are analysed (previously only Write was reachable).

```diff

  • const content = input.content || input.file_content || input.diff || '';
  • const filePath = input.path || input.file_path || '';
  • const ti = input.tool_input || {};
  • const tr = input.tool_response || {};
  • const content = ti.content || ti.new_string || ti.file_content
  • || input.content || input.file_content || input.diff || '';
  • const filePath = ti.file_path || tr.filePath
  • || input.path || input.file_path || '';
    ```

Verification

Pipe-tested against four payload shapes:

# Shape Before After
1 Claude Code `Write` (`tool_input.content`) `{}` signals detected
2 Claude Code `Edit` (`tool_input.new_string`) `{}` signals detected
3 Legacy top-level (`content`) signals detected signals detected (preserved)
4 Empty / no signal keywords `{}` `{}`

Reference for the Claude Code payload shape: https://docs.claude.com/en/docs/claude-code/hooks-guide#hook-input

Scope

  • Single file changed: `src/adapters/scripts/evolver-signal-detect.js` (+8/-2)
  • No behavior change for non-Claude-Code adapters or legacy callers
  • No docs needed; this restores intended documented behavior

Claude Code's PostToolUse hook payload nests tool args under
`tool_input` (e.g. `tool_input.content`, `tool_input.file_path`).
The previous lookup only checked top-level `content`/`file_path`,
so the hook silently returned `{}` on every real Write/Edit event
and never injected the `[Evolution Signal]` context block.

Fix the lookup to check `tool_input.*` and `tool_response.filePath`
first, then fall back to the legacy top-level shape for backward
compatibility. Also pick up `new_string` so Edit-tool payloads are
analysed (previously only Write was reachable).

Verified end-to-end against all four payload shapes: Claude Code
Write, Claude Code Edit, legacy top-level, and empty.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant