@@ -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 };