You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Welcome back to another episode of “What’s That Odor?” where your code makes my IDE cry. Today’s special: a potpourri of risky deletes, duplicated logic, mixed TOML dialects, and logs that sound like a garage band. Strap in, buttercup — we’re refactoring your despair into delight. 💅🔥
Keep only one selection function (prefer the dedicated core/agent-selection.ts).
Replace internal use in apply-engine.ts with the exported helper and delete the duplicate.
Add unit tests for edge-cases: invalid CLI names, overlapping substrings, per-agent overrides.
Mixed TOML Libraries + Hand-Rolled Serializer
🤹 You parse with toml and stringify with @iarna/toml, then manually glue strings in places. Choose one flavor. Please.
Parsing: toml in multiple modules; stringifying: @iarna/toml.
CodexCliAgent hand-writes TOML strings (arrays, inline tables, headers). That’s a vibe until someone adds a value with quotes and your TOML turns into modern art.
Collapse all existing Ruler blocks into one canonical block.
Base path normalization strictly on path.relative(projectRoot, p) for both absolute and relative inputs — no basename hacks.
Optionally support writing to .git/info/exclude via flag to avoid polluting repo files.
Directory Removal Race Conditions
🧨 You check a directory tree is empty, then call fs.rm(..., { recursive: true }). If files appear between checks, you can delete content you didn’t intend to.
The log says “Removed empty directory tree” but the OS does not care about your log messages.
It’s a tiny window, but that’s how “whoops” moments are born.
Use fs.rmdir without recursive for the final remove; if it fails, directory isn’t empty, so bail.
Alternatively, remove children bottom-up (non-recursive final call) to avoid TOCTOU footguns.
Unit test the “file appears mid-cleanup” scenario to prove safety.
If you made it this far without crying: congratulations, you’re ready to ship fewer regrets. Make these fixes, and your codebase will smell less like a burning data center and more like a freshly linted monorepo. 💐
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
This Codebase Smells!
Welcome back to another episode of “What’s That Odor?” where your code makes my IDE cry. Today’s special: a potpourri of risky deletes, duplicated logic, mixed TOML dialects, and logs that sound like a garage band. Strap in, buttercup — we’re refactoring your despair into delight. 💅🔥
Table of Contents
Overzealous Revert Deletes Real Files
☠️ Revert includes a generic
config.tomlin “extra cleanup” and will nuke it without a backup.config.tomlexists and wasn’t created by Ruler (no.bak), it’s removed anyway — welcome to Data Loss Land™.config.toml, but the revert’s “bonus delete” is agent‑agnostic. Brave. 🤦Files
src/core/revert-engine.tssrc/paths/mcp.tsCode
config.toml:config.toml:Suggestions
.bakexists, orapply.config.tomlfrom the generic list; if you must, gate it by “contains known OpenHands MCP markers”.--force-extra-cleanupflag and warn loudly before touching generic files.Home-Directory MCP Paths Are Footguns
🚫 MCP targets sometimes point to
$HOME, but writes are blocked if the result isn’t under the project root — net effect: silent “do nothing.”Windsurf,getNativeMcpPathonly proposes a homedir path;applyrefuses to write outside the project, so… you wrote nothing. Clap clap.~/.codeium/...and gets ghosted.Files
src/paths/mcp.tssrc/core/apply-engine.tsCode
$HOMEcandidate:Suggestions
.windsurf/mcp.json) and prefer it when absent.$HOMEwrites, gate behind--allow-home-mcpor TOML flag with big, neon warnings.Duplicated Agent Selection Logic
🪓 You implemented agent selection twice, in two places, with the same code. Why.
selectAgentsToRunandresolveSelectedAgentsduplicate logic, validation, and error wording — a lovely breeding ground for drift bugs.Files
src/core/apply-engine.tssrc/core/agent-selection.tsCode
apply-engine.ts:agent-selection.ts:Suggestions
core/agent-selection.ts).apply-engine.tswith the exported helper and delete the duplicate.Mixed TOML Libraries + Hand-Rolled Serializer
🤹 You parse with
tomland stringify with@iarna/toml, then manually glue strings in places. Choose one flavor. Please.tomlin multiple modules; stringifying:@iarna/toml.CodexCliAgenthand-writes TOML strings (arrays, inline tables, headers). That’s a vibe until someone adds a value with quotes and your TOML turns into modern art.Files
src/core/ConfigLoader.tssrc/core/UnifiedConfigLoader.tssrc/mcp/propagateOpenHandsMcp.tssrc/agents/CodexCliAgent.tsCode
Suggestions
@iarna/tomlfor both parse and stringify across the repo.stringify— do not manually format TOML.Recursive Scans Dive Into node_modules
🕳️ Your “find all .ruler directories” recurses into every folder not starting with a dot. That includes
node_modules. For fun. For hours. For heat. 🔥node_modules,dist,build, etc.Files
src/core/FileSystemUtils.tsCode
Suggestions
node_modules,dist,build,coverage,.next,out,target, etc.Logging Is Inconsistent And Loud
📣 Some messages use
console.log, othersconsole.warn, others a bespokelogVerboseto stderr. It’s a symphony of noise.--verboseis off.Files
src/core/apply-engine.tssrc/constants.tsCode
console.error:Suggestions
--verbose; reserve stdout for user‑visible outputs and summaries.actionPrefixand align on one style..gitignore Block Handling Is Brittle
🧱 Updating the Ruler block replaces only the first Ruler block and keeps any others. Because multiplying special blocks sounds like a great idea.
.gitignore; doesn’t consider.git/info/exclude, which some teams rely on.Files
src/core/GitignoreUtils.tsCode
Suggestions
path.relative(projectRoot, p)for both absolute and relative inputs — no basename hacks..git/info/excludevia flag to avoid polluting repo files.Directory Removal Race Conditions
🧨 You check a directory tree is empty, then call
fs.rm(..., { recursive: true }). If files appear between checks, you can delete content you didn’t intend to.Files
src/core/revert-engine.tsCode
executeDirectoryActionvia callers): https://github.com/intellectronica/ruler/blob/main/src/core/revert-engine.ts#L220-L265 and https://github.com/intellectronica/ruler/blob/main/src/core/revert-engine.ts#L164-L175Suggestions
fs.rmdirwithout recursive for the final remove; if it fails, directory isn’t empty, so bail.If you made it this far without crying: congratulations, you’re ready to ship fewer regrets. Make these fixes, and your codebase will smell less like a burning data center and more like a freshly linted monorepo. 💐
Beta Was this translation helpful? Give feedback.
All reactions