Problem
The looksLikeFilePath heuristic in cmd/precompact.go:260-270 matches any token that contains both / and .:
func looksLikeFilePath(s string) bool {
if len(s) < 3 || len(s) > 200 {
return false
}
if strings.HasPrefix(s, "http://") || strings.HasPrefix(s, "https://") || strings.HasPrefix(s, "ftp://") {
return false
}
// Must contain a slash and a dot to look like a file path
return strings.Contains(s, "/") && strings.Contains(s, ".")
}
This matches Go import paths such as github.com/supermodeltools/uncompact/internal/api, module paths, domain names without a scheme (e.g., pkg.go.dev/github.com/foo), and version strings like v1.2/path. In a typical Go project transcript, nearly every message discussing packages or imports will produce dozens of false-positive "file path" entries.
Impact
The "Files in focus" section of the session snapshot (cmd/precompact.go, written by the PreCompact hook) gets populated with Go import paths and domain names instead of actual local file paths. Claude then receives misleading context about which files were being worked on.
Fix
Tighten the heuristic to require that the path either:
- Starts with
/, ./, or ../ (absolute or relative local path), or
- Contains a path separator followed by a segment with a recognised source-file extension (
.go, .py, .ts, .js, .rs, .md, .json, .yaml, .toml, etc.)
Location: cmd/precompact.go, lines 260-270
@claude please implement this