(cwd: string)
| 155 | * the model knows the linked codebase without exploring it first. |
| 156 | */ |
| 157 | export function renderLinkedReposSection(cwd: string): string { |
| 158 | const links = loadLinks(cwd).slice(0, MAX_LINKED_REPOS) |
| 159 | if (links.length === 0) return "" |
| 160 | |
| 161 | const parts: string[] = [ |
| 162 | "## Linked Repositories", |
| 163 | "", |
| 164 | "This repository is linked to the repositories below — separate codebases on disk that are coupled to this one. When you change this repo, consider whether the change ripples into a linked repo: inspect the linked code for impact and, when relevant, propose (or make, if the user asks) the matching changes there. You can read and edit files in these repos directly by their absolute paths.", |
| 165 | "", |
| 166 | ] |
| 167 | for (const link of links) { |
| 168 | const exists = isDir(link.path) |
| 169 | parts.push(`### ${path.basename(link.path)} — \`${link.path}\`${exists ? "" : " (path not found)"}`) |
| 170 | if (!exists) { |
| 171 | parts.push("") |
| 172 | continue |
| 173 | } |
| 174 | const agents = readLinkedAgents(link.path) |
| 175 | parts.push("") |
| 176 | if (agents) { |
| 177 | parts.push("Its AGENTS.md:") |
| 178 | parts.push("") |
| 179 | parts.push(truncate(agents.trim(), MAX_AGENTS_CHARS)) |
| 180 | } else { |
| 181 | parts.push("(no AGENTS.md found — explore the repo directly if you need its structure)") |
| 182 | } |
| 183 | parts.push("") |
| 184 | } |
| 185 | return parts.join("\n") |
| 186 | } |
no test coverage detected