fix(hermes): preserve YAML list-at-same-indent style on install (#456)#461
Merged
Conversation
Hermes Agent writes ~/.hermes/config.yaml with PyYAML's default block
style, which puts list items at the SAME indent as the parent key:
platform_toolsets:
cli:
- hermes-cli # indent 2, same as `cli:`
- browser
The previous line-based YAML patcher used `^ \S` to find the end of
the `cli:` block, which mistook that first ` - hermes-cli` line for
the next sibling key, truncated the block, and spliced
` - mcp-codegraph` at indent 4 BEFORE the existing items. The
result was unparseable YAML: every subsequent item (`- browser`,
`- clarify`, …) and every sibling platform (`telegram:`, `discord:`)
appeared at the `platform_toolsets:` level. Hermes silently fell back
to the default config, dropping every user override.
The new `listChildBlock` helper recognizes ` - ` as a list-item
continuation (not a sibling key), finds the real end of the block at
the next sibling mapping key, and detects the existing item indent so
the new entry matches it. Two regression tests cover the PyYAML-default
style; the existing 4-space-nested test still passes.
End-to-end verified against a real `hermes-agent` install on the exact
bug-triggering config: `hermes mcp list` shows codegraph as enabled,
`hermes tools --summary` lists both `mcp-codegraph` and `codegraph` in
the CLI toolset, and `hermes mcp test codegraph` connects in 264ms and
discovers all 10 codegraph tools. Re-running `codegraph install`
reports `Unchanged` and the file still has exactly one entry. Closes #456.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced May 26, 2026
jorgerobles
pushed a commit
to jorgerobles/codegraph
that referenced
this pull request
Jun 1, 2026
…ymchenry#456) (colbymchenry#461) Hermes Agent writes ~/.hermes/config.yaml with PyYAML's default block style, which puts list items at the SAME indent as the parent key: platform_toolsets: cli: - hermes-cli # indent 2, same as `cli:` - browser The previous line-based YAML patcher used `^ \S` to find the end of the `cli:` block, which mistook that first ` - hermes-cli` line for the next sibling key, truncated the block, and spliced ` - mcp-codegraph` at indent 4 BEFORE the existing items. The result was unparseable YAML: every subsequent item (`- browser`, `- clarify`, …) and every sibling platform (`telegram:`, `discord:`) appeared at the `platform_toolsets:` level. Hermes silently fell back to the default config, dropping every user override. The new `listChildBlock` helper recognizes ` - ` as a list-item continuation (not a sibling key), finds the real end of the block at the next sibling mapping key, and detects the existing item indent so the new entry matches it. Two regression tests cover the PyYAML-default style; the existing 4-space-nested test still passes. End-to-end verified against a real `hermes-agent` install on the exact bug-triggering config: `hermes mcp list` shows codegraph as enabled, `hermes tools --summary` lists both `mcp-codegraph` and `codegraph` in the CLI toolset, and `hermes mcp test codegraph` connects in 264ms and discovers all 10 codegraph tools. Re-running `codegraph install` reports `Unchanged` and the file still has exactly one entry. Closes colbymchenry#456. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
codegraph install --target hermescorrupted~/.hermes/config.yaml. PyYAML's default block style writes list items at the same indent as the parent key (cli:and- hermes-cliboth at column 2). The line-based patcher mistook that first- hermes-clifor the next sibling key, truncated thecli:block, and spliced- mcp-codegraphat indent 4 before the existing items — promoting- browser,- clarify, …,telegram:to invalid positions and breaking YAML parse. Hermes silently fell back to default config, dropping every user override.listChildBlockhelper recognizes-as a list-item continuation (not a sibling key), finds the real end of the block at the next sibling key, and detects the existing item indent somcp-codegraphis appended at the same indent the file already uses. The 4-space-nested layout still works.Test plan
npx vitest run __tests__/installer-targets.test.ts— 116/116 pass (macOS)npm test— 982/982 pass (macOS)node:22-bookwormimage, ran installer suite — 116/116 pass; manual end-to-end install on the PyYAML-default config produces parseable YAMLnpx vitest run __tests__/installer-targets.test.ts— 116/116 pass; PowerShell end-to-end install reproduces the correct outputhermes-agentfrom main into a venv, dropped the exact bug-triggering config from the issue into$HERMES_HOME, ran the installer, and verified:hermes mcp list→codegraph codegraph serve --mcp all ✓ enabledhermes tools --summary→ bothcodegraphandmcp-codegraphenabled in the CLI toolset, alongside the user's original toolsets (browser, file, terminal, web, …)hermes mcp test codegraph→✓ Connected (264ms) ✓ Tools discovered: 10(search, context, callers, callees, impact, node, explore, status, files, trace)Unchanged; the file still has exactly onemcp-codegraphand onecodegraph:server blockCloses #456.
🤖 Generated with Claude Code