xonecas.io
79113
Ma

mini-coding-agent / commit 6924ae6

fix: dont dupe a symlinked CLAUDE.md file

xonecas2026-10-12 6924ae686d751840ab86ae3f1386e056869e710b parent 72084db

2 files changed

src/filesystem.zig+8−0
@@ -23,6 +23,14 @@ pub fn fileExists(path: []const u8) bool {
2323 return true;
2424 }
2525
26+pub fn realPath(a: std.mem.Allocator, path: []const u8) ?[]const u8 {
27+ var buf: [std.fs.max_path_bytes]u8 = undefined;
28+ const file = std.Io.Dir.cwd().openFile(platform.io, path, .{}) catch return null;
29+ defer file.close(platform.io);
30+ const n = file.realPath(platform.io, &buf) catch return null;
31+ return a.dupe(u8, buf[0..n]) catch null;
32+}
33+
2634 pub fn listDir(a: std.mem.Allocator, root: []const u8) ![]const []const u8 {
2735 var dir = try std.Io.Dir.cwd().openDir(platform.io, root, .{ .iterate = true });
2836 defer dir.close(platform.io);
src/prompt.zig+11−1
@@ -52,15 +52,25 @@ fn agentFiles(a: std.mem.Allocator) ![]const []const u8 {
5252 const cwd = try std.process.currentPathAlloc(platform.io, a);
5353 try roots.append(a, cwd);
5454 var found: std.ArrayList([]const u8) = .empty;
55+ var seen: std.ArrayList([]const u8) = .empty;
5556 for (roots.items) |root| {
5657 for ([_][]const u8{ "AGENTS.md", "CLAUDE.md" }) |name| {
5758 const path = try filesystem.join(a, &.{ root, name });
58- if (filesystem.fileExists(path)) try found.append(a, path);
59+ if (!filesystem.fileExists(path)) continue;
60+ const real = filesystem.realPath(a, path) orelse path;
61+ if (contains(seen.items, real)) continue;
62+ try seen.append(a, real);
63+ try found.append(a, path);
5964 }
6065 }
6166 return found.items;
6267 }
6368
69+fn contains(haystack: []const []const u8, needle: []const u8) bool {
70+ for (haystack) |item| if (std.mem.eql(u8, item, needle)) return true;
71+ return false;
72+}
73+
6474 pub const Loaded = struct { agent_files: usize = 0, skills: usize = 0 };
6575
6676 pub const Built = struct { prompt: []const u8, loaded: Loaded };