Skip to content

fix: tldr-read-enforcer hook ignored when Claude uses a relative file path#5

Merged
Lisztos merged 1 commit intomainfrom
fix/relative-path-read-enforcer
Mar 25, 2026
Merged

fix: tldr-read-enforcer hook ignored when Claude uses a relative file path#5
Lisztos merged 1 commit intomainfrom
fix/relative-path-read-enforcer

Conversation

@Lisztos
Copy link
Copy Markdown
Owner

@Lisztos Lisztos commented Mar 24, 2026

Ported from parcadei/Continuous-Claude-v3#152 by @marcuspuchalla


Problem

The hook checks file size with statSync(filePath) but needs an absolute path. If Claude passes a relative path like src/api/foo.ts, statSync can't find the file, throws, the catch block silently returns {}, and TLDR never kicks in.

Fix

Convert relative paths to absolute using input.cwd:

const rawFilePath = input.tool_input.file_path || '';
const filePath = isAbsolute(rawFilePath) ? rawFilePath : join(input.cwd, rawFilePath);

Also fixes pre-existing TypeScript compile errors in daemon-client and tsconfig.

Test plan

  • Reading a file via relative path correctly triggers TLDR context
  • Reading via absolute path still works

… path

The hook checks the file size before deciding whether to intercept a Read.
It does this with statSync(filePath). But statSync needs an absolute path —
if Claude passes a relative path like 'src/api/foo.ts', statSync can't find
the file (the hook process has a different working directory than the project).

It throws, the catch block silently returns {}, and the hook does nothing —
the raw file is read as normal, bypassing the TLDR token savings entirely.

Fix: convert relative paths to absolute using input.cwd (the project directory
that Claude Code provides in the hook payload):

  const filePath = isAbsolute(rawFilePath)
    ? rawFilePath
    : join(input.cwd, rawFilePath);

Also fixes pre-existing TypeScript compile errors:
- daemon-client import missing .js extension (required by NodeNext module resolution)
- DaemonResponse interface missing imports/importers fields (used in importsDaemon())
- tsconfig excludes src/__tests__ to stop test files breaking the build
@Lisztos Lisztos merged commit aba1cc3 into main Mar 25, 2026
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.

2 participants