Skip to content

fix(init): keep the Hermes config patcher inside real plugins.enabled keys - #4764

Open
HetCreep wants to merge 1 commit into
rtk-ai:developfrom
HetCreep:fix/init-hermes-yaml-3405
Open

HetCreep wants to merge 1 commit into
rtk-ai:developfrom
HetCreep:fix/init-hermes-yaml-3405

Conversation

@HetCreep

Copy link
Copy Markdown

Summary

  • rtk init --agent hermes edits ~/.hermes/config.yaml line by line. It took the first enabled: anywhere under plugins: (so plugins: / some-plugin: / enabled: true was patched instead of the real plugins.enabled list, leaving invalid YAML), and it took any line starting with plugins: at any indent, including text inside a | / > block scalar or under another key such as agent:.
  • plugins: must now sit at column 0, enabled: must sit at the same indent as the other direct children of plugins:, and lines inside block scalar bodies are never treated as keys. When no real plugins: exists the block is appended as before; the uninstall path uses the same lookup, so it no longer edits scalar text either.
  • Not changed: no YAML parser is added (the crate has none; adding one is a dependency decision for maintainers), and no backup is added here because feat(init): route every init write through one guarded path #4269 already routes the Hermes config write through a .bak path. Post-write re-parse validation is not included for the same reason (needs a parser).

Fixes #3405

Test plan

  • cargo fmt --all --check && cargo clippy --all-targets && cargo test on Rust 1.99.1 (lib: 4439 passed, 1 failed; integration/doc suites 2+20+12+7+22 passed. The one failure is the known Windows find_cmd::tests::run_from_args_propagates_find_exit_status, unrelated to this change and not in a file touched here; clippy printed no warnings)
  • Manual testing: not run through the rtk binary. rtk init writes to a home directory, so the change is exercised only by unit tests on in-memory strings and the existing temp-dir tests in hermes.rs.
  • New test(s): test_hermes_config_patch_ignores_nested_enabled_key, test_hermes_config_patch_adds_enabled_beside_nested_enabled_key, test_hermes_config_patch_skips_plugins_text_in_block_scalar, test_hermes_config_patch_appends_when_plugins_only_in_block_scalar, test_hermes_config_unpatch_leaves_block_scalar_text_alone, test_hermes_config_patch_ignores_indented_plugins_key. All six fail on develop (32b2ec4) and pass here; the 24 existing hermes_config tests pass on both (cargo test --lib hermes: 45 passed after the change).
  • Not tested: a real Hermes install; flow-style plugins: {enabled: [...]}; multi-line quoted scalars containing plugins:; a - key: | list-item scalar header is measured from the key column.

Prepared with AI assistance (Claude Code) and reviewed by me (HetCreep) before submitting; the runs above were executed on Windows 11.

🤖 Generated with Claude Code

… keys

The line editor took the first `enabled:` at any depth under `plugins:` and
any `plugins:` at any indent, including text inside `|` / `>` block scalars.
That produced invalid YAML (nested `enabled: true` patched instead of the
list) or injected the plugin entry into a user's prompt text.

Require `plugins:` at column 0, `enabled:` at the indent of plugins' direct
children, and skip block scalar bodies. Uninstall shares the same lookup.

Fixes rtk-ai#3405

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 23, 2026 18:23

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@rtk-wshm-sync-bot rtk-wshm-sync-bot Bot added area:init bug Something isn't working hermes labels Oct 23, 2026
@rtk-wshm-sync-bot

Copy link
Copy Markdown

wshm · Automated triage by AI

📊 Automated PR Analysis

🐛 Type bug-fix
🟡 Risk medium

Summary

Fixes the Hermes config patcher in rtk init --agent hermes so it only matches the real top-level plugins: key and its direct enabled: child, instead of matching nested enabled: keys or plugins:/enabled: text that appears inside block scalars or under unrelated keys. Adds exact-indent key matching and a block-scalar line mask, plus six new regression tests; no YAML parser or backup mechanism was added.

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

Linked issues: #3405


Analyzed automatically by wshm · This is an automated analysis, not a human review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:init bug Something isn't working hermes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rtk init --agent hermes can write invalid YAML into ~/.hermes/config.yaml, or patch text inside a block scalar — with no backup

2 participants