(content: string)
| 273 | } |
| 274 | |
| 275 | function upsertCodeGraphMcpServer(content: string): string { |
| 276 | const lines = splitLines(content); |
| 277 | const parent = topLevelRange(lines, 'mcp_servers'); |
| 278 | const child = parent ? childRange(lines, parent, 'codegraph') : null; |
| 279 | const replacement = renderCodeGraphMcpChild(); |
| 280 | |
| 281 | if (!parent) { |
| 282 | if (lines.length > 0 && lines[lines.length - 1] === '') lines.pop(); |
| 283 | if (lines.length > 0) lines.push(''); |
| 284 | lines.push(...renderCodeGraphMcpBlock()); |
| 285 | return joinLines(lines); |
| 286 | } |
| 287 | |
| 288 | if (child) { |
| 289 | const existing = lines.slice(child.start, child.end); |
| 290 | if (arrayEqual(existing, replacement)) return joinLines(lines); |
| 291 | lines.splice(child.start, child.end - child.start, ...replacement); |
| 292 | return joinLines(lines); |
| 293 | } |
| 294 | |
| 295 | lines.splice(parent.end, 0, ...replacement); |
| 296 | return joinLines(lines); |
| 297 | } |
| 298 | |
| 299 | function removeCodeGraphMcpServer(content: string): string { |
| 300 | const lines = splitLines(content); |
no test coverage detected