Skip to content

install --target hermes: upsertCodeGraphToolset hardcodes 4-space indent, corrupts YAML with mixed indentation #507

@TheChyeahhh

Description

@TheChyeahhh

Upstream bug: codegraph install --target hermes corrupts YAML indentation

  • Repo: colbymchenry/codegraph
  • Version: v0.9.4
  • File: src/installer/targets/hermes.ts → upsertCodeGraphToolset()

Repro

Given this Hermes config (~/.hermes/config.yaml):

platform_toolsets:
  cli:
  - hermes-cli
  - mcp-automator

Running codegraph install --target hermes produces:

platform_toolsets:
  cli:
  - hermes-cli
  - mcp-automator
    - mcp-codegraph

The inserted - mcp-codegraph uses 4-space indent, while
the existing cli: children use 2-space indent (aligned to the
cli: key). This mixed indentation can cause downstream YAML
parsers to misinterpret the structure.

Root cause

src/installer/targets/hermes.ts, upsertCodeGraphToolset():

// Line ~280: hardcoded 4-space indent, regardless of existing cli: style
lines.splice(cli.end, 0, '    - mcp-codegraph');

The same hardcoded 4-space indent appears at lines 268 and 272
for the fresh-creation paths.

Suggested fix

Detect the indentation of existing cli: children before appending.
Pseudo-diff:

// Detect existing indent from cli: children
const cliIndent = detectChildIndent(lines, cli);
// Use matching indent
lines.splice(cli.end, 0, `${cliIndent}- mcp-codegraph`);

Where detectChildIndent() looks at the whitespace prefix of
lines between cli.start+1 and cli.end to find the dominant
indentation level used by existing - prefixed items.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions