MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / upsertCodeGraphToolset

Function upsertCodeGraphToolset

src/installer/targets/hermes.ts:308–332  ·  view source on GitHub ↗
(content: string)

Source from the content-addressed store, hash-verified

306}
307
308function 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
334function removeCodeGraphToolset(content: string): string {
335 const lines = splitLines(content);

Callers 1

writeHermesConfigFunction · 0.85

Calls 4

splitLinesFunction · 0.85
topLevelRangeFunction · 0.85
listChildBlockFunction · 0.85
joinLinesFunction · 0.85

Tested by

no test coverage detected