refactor(hermesagent): collapse repeated path expressions and align checks output root - #2484
Merged
Merged
Conversation
…hecks output root The remaining #2439 cleanups (findings 3, 4, 6, 7, 8): - HermesagentCommandAuxiliaryFile compared its own path against a rebuilt getHermesagentRelativeFilePath five times; a private matchesPath helper replaces the block and makes passing the wrong constant impossible. - getHermesagentRulesyncOutputRoot and getKimiCodeRulesyncOutputRoot differed only in which home getter they called, so both delegate to a shared getToolRulesyncOutputRoot parameterized by that getter. It lives in a new leaf module rather than tool-output-root.ts, which would have formed an import cycle with the two tool utils. The plugin dir expression repeated three times in hermesagent-command.ts and twice in hermesagent-subagent.ts is now one local const each. - Per-class getSettablePaths({ global: true }) coverage with HERMES_HOME both set and unset, on all five global Hermes classes. - generateChecksCore resolves the tool output root like convert.ts's buildChecksStrategy already did; generateIgnoreCore is left alone per its comment. - Documents that HERMES_HOME/KIMI_CODE_HOME override --output-roots in global scope, and that an unusable value is rejected naming the variable. Part of #2439 (findings 3, 4, 6, 7, 8). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ation Review follow-ups (all low): - The global settable-path tests compared against getHermesagentGlobalDir(), which restates the implementation rather than asserting it; both platform literals are pinned instead. Unit CI is ubuntu-only, so the win32 arm was otherwise unasserted anywhere. - getKimiCodeRulesyncOutputRoot gained a test: the shared helper extraction rewrote two call sites but only the hermes one was covered. - Records why generateIgnoreCore still passes outputRoot verbatim after checks was aligned — the tools with a home override are not global ignore targets. - The precedence note mentions convert as well as generate, and links to the Hermes profile description in supported-tools.md. Co-Authored-By: Claude Fable 5 <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.
Part of #2439 (findings 3, 4, 6, 7, 8) — the separable cleanups, following #2483 which took findings 1, 2, 5, 9 and 10. Finding 11 (the migration note about stale
~/.hermes/*files) is a release-notes item, not a code change, so the issue stays open for the maintainer to close.Finding 3 (mid) — the five-times-repeated path comparison
HermesagentCommandAuxiliaryFilerebuilt the samethis.getRelativePathFromCwd() === toPosixPath(getHermesagentRelativeFilePath({ global: this.global, relativeFilePath: <CONST> }))expression inshouldMergeExistingFileContent,setFileContent, and three branches ofgetFileContent. A privatematchesPath(relativeFilePath)collapses ~40 lines to five call sites and removes the chance of pairing a branch with the wrong constant.Finding 4 (low) — duplication against the kimi-code utility
getHermesagentRulesyncOutputRootandgetKimiCodeRulesyncOutputRootwere identical apart from the home getter, so both now delegate to a sharedgetToolRulesyncOutputRoot({ nativeOutputRoot, global, toolHome }).One deviation from the issue's suggestion: it lives in a new
src/utils/tool-home.tsrather than intool-output-root.ts.tool-output-root.tsimports both tool utils, so putting the helper there and importing it back would have created a genuinehermesagent → tool-output-root → hermesagentcycle. The new module is a leaf that imports onlygetHomeDirectory.The issue's local duplication is gone too:
getHermesagentRelativeDirPath({ global, relativeDirPath: <PLUGIN_DIR> })was spelled out three times inhermesagent-command.tsand twice inhermesagent-subagent.ts, and is now oneconst pluginDirPathper function.Finding 6 (low) — per-class global coverage
HermesagentMcp,HermesagentHooks,HermesagentPermissions,HermesagentSkillandHermesagentSubagenteach get agetSettablePaths({ global: true })case in both configurations: anchored on the platform profile directory whenHERMES_HOMEis unset, and de-prefixed when it names the profile root. Previously only the helper insrc/utils/hermesagent.tsand the e2e suite covered this.Finding 7 (low) — convert/generate disagreement on checks
generateChecksCorepassedoutputRootverbatim whileconvert.ts'sbuildChecksStrategyalready ran it throughresolveToolOutputRoot. Aligned.generateIgnoreCoreis deliberately left alone, per the comment justifying its verbatim pass-through.Finding 8 (low) — undocumented precedence
docs/reference/cli-commands.mdgains a short section stating thatHERMES_HOME/KIMI_CODE_HOMEoverrideoutputRootsand--output-rootsin global scope, why (the variable names where the tool itself looks), and that an unusable value is rejected with an error naming the variable. Skill docs synced.Verification
Full
pnpm cicheckis green (8054 unit tests). The Hermes-touching e2e specs pass locally. No behavior change is intended anywhere exceptgenerateChecksCore, which now matches the convert path.🤖 Generated with Claude Code