Repository navigation
fix(hooks): read the XDG global config in the code-simplifier Stop hook - #4160
Merged
Yeachan-Heo merged 7 commits intoSep 29, 2026
Merged
Yeachan-Heo merged 7 commits into
Yeachan-Heo merged 7 commits into
Conversation
The shipped code-simplifier hooks (scripts/ for the plugin, templates/hooks/
for the standalone install) only read ~/.omc/config.json. The TypeScript
hook and docs/REFERENCE.md use getGlobalOmcConfigCandidates: $OMC_HOME,
else ${XDG_CONFIG_HOME:-~/.config}/omc/config.json on Linux/Unix, then the
legacy ~/.omc fallback. A Linux user who enables codeSimplifier where the
docs say got no simplifier at all.
Mirror that lookup in both .mjs copies.
These hook scripts legitimately construct global OMC config paths (~/.omc/config.json), which are per-user and not workspace-scoped. The gate should not flag global config path construction.
# Conflicts: # inventory/inventory-graph.json
Owner
|
Pushed two commits on top of your branch:
Your commits are unchanged. Locally the multirepo gate is OK, the inventory verify passes, and 29/29 pass across the code-simplifier and inventory-drift tests. We'll merge once CI is green on this head. — |
added 2 commits
September 29, 2026 05:43
# Conflicts: # inventory/inventory-graph.json
Owner
|
Thanks @JayOfTheKeyboard! 🚀 Merge Details:
— |
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.
Problem
docs/REFERENCE.mdsays to enable the code-simplifier in the global OMC config, and gives the Linux/Unix default as${XDG_CONFIG_HOME:-~/.config}/omc/config.json. The TypeScript hook (src/hooks/code-simplifier/index.ts) reads that path throughgetGlobalOmcConfigCandidates, which #1898 added. The hooks that actually run were not ported, though.scripts/code-simplifier.mjs(the plugin's Stop hook) andtemplates/hooks/code-simplifier.mjs(the standalone install) still read only~/.omc/config.json.I fed a Stop payload to
scripts/code-simplifier.mjsondevat 2db31f9. The setup was a scratchHOME, a git repo with one modifieda.ts, and{"codeSimplifier":{"enabled":true}}in the config file named in each row:scripts/code-simplifier.mjsondev~/.config/omc/config.jsona.ts{"continue":true}, nothing happens$XDG_CONFIG_HOME/omc/config.json{"continue":true}, nothing happens$OMC_HOME/config.json{"continue":true}, nothing happensenabled:false, legacy saystrue~/.omc/config.jsononlySo on Linux, a user who follows the docs gets no simplifier and no error. The template copy behaves the same way.
Fix
Both
.mjscopies now inline a mirror ofgetGlobalOmcConfigCandidates('config.json'):$OMC_HOME/config.jsonalone whenOMC_HOMEis set;${XDG_CONFIG_HOME:-~/.config}/omc/config.jsonon Linux/Unix, then the legacy~/.omc/config.json;It's inlined rather than imported from
dist/, so the hooks stay build-independent, the same wayscripts/lib/agent-model-config.mjsmirrorsgetConfigDir. The template copy can only import its ownlib/. The header comment in each file now names the real lookup.The inventory graph is regenerated in a separate commit, as before.
Not changed
scripts/persistent-mode.mjsgetIdleCooldownSeconds(and the unregisteredscripts/persistent-mode.cjs) still readnotificationCooldown.sessionIdleSecondsfrom~/.omc/config.jsononly. Fix XDG-aware global OMC config/state paths on Unix #1898 also moved that read to the XDG helper on the TS side. It's the same one-function change, but its only effect is the idle-notification cooldown, which I couldn't test cleanly through the script. I'm happy to add it here or send it separately.persistent-mode.mjsalso uses~/.omc/statefor its global state dir, where the TS side usesgetGlobalOmcStateRoot. That's state, not config, so I left it alone.Test
New file:
src/hooks/code-simplifier/__tests__/global-config-path.test.ts. It runs bothscripts/code-simplifier.mjsandtemplates/hooks/code-simplifier.mjsas subprocesses, with a scratchHOMEand a temp git repo holding one modified.tsfile. There are 6 cases per script, 12 in all. The three XDG cases are skipped on win32 and darwin.~/.configandOMC_HOMEcases fail withexpected undefined to be 'block', which means the hook returned{"continue":true}. The "XDG wins over legacy" case fails because the hook blocked from the legacy file. The legacy-only and no-config cases pass on the parent too; they guard against regressions.src/hooks/code-simplifier/(18 tests across 2 files). The test clearsOMC_HOME,OMC_STATE_DIR,XDG_CONFIG_HOME,GIT_DIRandGIT_WORK_TREEfrom the child environment, so it doesn't write into a developer's real state dir.~/.config, XDG-over-legacy)OMC_HOMEbranchXDG_CONFIG_HOMEignored (always~/.config)Validation
npx vitest run src/hooks/code-simplifier/: all passnpx vitest runon Linux: FILL_IN (branch) against FILL_IN (dev2db31f9, run the same way)npx tsc --noEmitandnpm run lintare clean, andnpm run generate:inventory:verifypassesdist/orbridge/changes