Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/explore.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2479,6 +2479,18 @@ pub const Explorer = struct {
return .{ .data = data, .owned = true, .allocator = allocator };
}

/// Issue #626: nudge agents toward codedb_outline when they pull a whole
/// large file with no range — the grep+cat habit reads entire files and
/// burns tokens. Returns a static one-liner, or null for small files.
pub fn fullFileReadHint(content: []const u8) ?[]const u8 {
var lines: usize = 1;
for (content) |c| {
if (c == '\n') lines += 1;
}
if (lines < 400) return null;
return "↪ whole-file read: codedb_outline maps this file 4-15x smaller — get the structure, pick a line range, then codedb_read just that range.\n";
}

fn renderReadBytes(
path: []const u8,
content: []const u8,
Expand Down Expand Up @@ -2516,6 +2528,7 @@ pub const Explorer = struct {
const lang = detectLanguage(path);
try appendExtractedLines(content, start, end, true, opts.compact, lang, allocator, out);
} else {
if (fullFileReadHint(content)) |hint| try out.appendSlice(allocator, hint);
try out.appendSlice(allocator, content);
}
}
Expand Down
Loading
Loading