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.toml
in “extra cleanup” and will nuke it without a backup.config.toml
exists 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.ts
src/paths/mcp.ts
Code
config.toml
:config.toml
:Suggestions
.bak
exists, orapply
.config.toml
from the generic list; if you must, gate it by “contains known OpenHands MCP markers”.--force-extra-cleanup
flag 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
,getNativeMcpPath
only proposes a homedir path;apply
refuses to write outside the project, so… you wrote nothing. Clap clap.~/.codeium/...
and gets ghosted.Files
src/paths/mcp.ts
src/core/apply-engine.ts
Code
$HOME
candidate:Suggestions
.windsurf/mcp.json
) and prefer it when absent.$HOME
writes, gate behind--allow-home-mcp
or TOML flag with big, neon warnings.Duplicated Agent Selection Logic
🪓 You implemented agent selection twice, in two places, with the same code. Why.
selectAgentsToRun
andresolveSelectedAgents
duplicate logic, validation, and error wording — a lovely breeding ground for drift bugs.Files
src/core/apply-engine.ts
src/core/agent-selection.ts
Code
apply-engine.ts
:agent-selection.ts
:Suggestions
core/agent-selection.ts
).apply-engine.ts
with the exported helper and delete the duplicate.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.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.Files
src/core/ConfigLoader.ts
src/core/UnifiedConfigLoader.ts
src/mcp/propagateOpenHandsMcp.ts
src/agents/CodexCliAgent.ts
Code
Suggestions
@iarna/toml
for 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.ts
Code
Suggestions
node_modules
,dist
,build
,coverage
,.next
,out
,target
, etc.Logging Is Inconsistent And Loud
📣 Some messages use
console.log
, othersconsole.warn
, others a bespokelogVerbose
to stderr. It’s a symphony of noise.--verbose
is off.Files
src/core/apply-engine.ts
src/constants.ts
Code
console.error
:Suggestions
--verbose
; reserve stdout for user‑visible outputs and summaries.actionPrefix
and 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.ts
Code
Suggestions
path.relative(projectRoot, p)
for both absolute and relative inputs — no basename hacks..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.Files
src/core/revert-engine.ts
Code
executeDirectoryAction
via 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.rmdir
without 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