(content: string)
| 306 | } |
| 307 | |
| 308 | function upsertCodeGraphToolset(content: string): string { |
| 309 | const lines = splitLines(content); |
| 310 | const parent = topLevelRange(lines, 'platform_toolsets'); |
| 311 | const cli = parent ? listChildBlock(lines, parent, 'cli') : null; |
| 312 | |
| 313 | if (!parent) { |
| 314 | if (lines.length > 0 && lines[lines.length - 1] === '') lines.pop(); |
| 315 | if (lines.length > 0) lines.push(''); |
| 316 | lines.push('platform_toolsets:', ' cli:', ' - hermes-cli', ' - mcp-codegraph'); |
| 317 | return joinLines(lines); |
| 318 | } |
| 319 | |
| 320 | if (!cli) { |
| 321 | lines.splice(parent.end, 0, ' cli:', ' - hermes-cli', ' - mcp-codegraph'); |
| 322 | return joinLines(lines); |
| 323 | } |
| 324 | |
| 325 | const hasEntry = lines |
| 326 | .slice(cli.start + 1, cli.end) |
| 327 | .some((line) => line.trim() === '- mcp-codegraph'); |
| 328 | if (hasEntry) return joinLines(lines); |
| 329 | |
| 330 | lines.splice(cli.end, 0, `${cli.itemIndent}- mcp-codegraph`); |
| 331 | return joinLines(lines); |
| 332 | } |
| 333 | |
| 334 | function removeCodeGraphToolset(content: string): string { |
| 335 | const lines = splitLines(content); |
no test coverage detected