fix(hermes): preserve YAML list indentation (2-space flush style)#345
fix(hermes): preserve YAML list indentation (2-space flush style)#345marcosdanielsf wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: be47413e6a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // - file | ||
| // A line beginning with " -" is still part of the current child, not | ||
| // the next platform key. Only a sibling mapping key ends this child. | ||
| if (/^ [A-Za-z_][A-Za-z0-9_-]*:\s*(?:#.*)?$/.test(line)) { |
There was a problem hiding this comment.
Detect sibling keys that have inline YAML values
The new sibling-boundary regex only matches lines like " key:" and ignores valid siblings such as " other: { ... }" or " discord: [ ... ]". In those configs, childRange() no longer stops at the next sibling, so calls like removeCodeGraphMcpServer()/upsertCodeGraphMcpServer() and upsertCodeGraphToolset() can treat subsequent sibling entries as part of the current block, leading to accidental deletion or malformed insertion when rewriting the file.
Useful? React with 👍 / 👎.
| // - file | ||
| // A line beginning with " -" is still part of the current child, not | ||
| // the next platform key. Only a sibling mapping key ends this child. | ||
| if (/^ [A-Za-z_][A-Za-z0-9_-]*:\s*(?:#.*)?$/.test(line)) { |
There was a problem hiding this comment.
Handle quoted and numeric sibling YAML keys
The new boundary check in childRange() assumes sibling keys must match [A-Za-z_][A-Za-z0-9_-]*, but YAML allows keys like 'x.y': and 1st:. In files that use those valid key forms under mcp_servers or platform_toolsets, range detection runs past the actual sibling boundary, so install/uninstall can splice through unrelated sections instead of only the target child block.
Useful? React with 👍 / 👎.
Summary
The Hermes installer target assumed list items were indented 4 spaces under their parent key, but YAML accepts both the 4-space style and the more common 2-space flush style:
```yaml
flush (2 spaces) — broke before this fix
platform_toolsets:
cli:
nested (4 spaces) — worked before, still works
platform_toolsets:
cli:
- hermes-cli
- mcp-codegraph
```
Two bugs surfaced on flush-style configs:
Fix
Test plan