refactor(rules): decouple RulesProcessor from other features' internals#1962
Open
saitota wants to merge 1 commit into
Open
refactor(rules): decouple RulesProcessor from other features' internals#1962saitota wants to merge 1 commit into
saitota wants to merge 1 commit into
Conversation
RulesProcessor had become a god class holding cross-feature knowledge: direct calls into KiloMcp/OpencodeMcp.fromInstructions, hardcoded simulate-section wording for commands/subagents/skills, and 11 this.toolTarget === ... branches. - MCP integration inversion: register non-root rules via a declarative meta.mcpInstructionsRegistrar contract instead of importing and calling specific MCP classes inline. - Simulate extraction: move convention-section wording into each feature processor's getSimulatedConventionSection; rules only concatenates them. - Declarative flags: replace all 11 toolTarget string branches with meta flags (foldsNonRootIntoRoot, localRootMode/localRootFileName, mirrorsRootToAgentsMd).
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.
Background
RulesProcessorhad become a god class. While the other 7 feature processors keep 0–1 tool branches and import no other features,rules-processor.tsimported 10 other-feature classes and held 11this.toolTarget === "..."branches. It reached into the MCP feature's internals (KiloMcp/OpencodeMcp.fromInstructions) and hardcoded the simulate-section wording for commands/subagents/skills.So
convertRulesyncFilesToToolFilesforced a reader to hold many unrelated tools' behavior in their head at once, and adding a Kilo/OpenCode-style tool meant adding another branch here instead of in the owning feature.Changes
meta.mcpInstructionsRegistrarcontract instead of importing and calling specific MCP classes inline. The rules feature only knows it has a list of non-root paths; the MCP feature owns the file format.getSimulatedConventionSection; the rules feature only decides which features contribute and concatenates them.toolTargetstring branches replaced withmetaflags (foldsNonRootIntoRoot,mcpInstructionsRegistrar,localRootMode/localRootFileName,mirrorsRootToAgentsMd).this.toolTarget === "..."count is now 11 → 0.No runtime behavior changes — generated output is identical. This is a pure refactor.
Test plan
pnpm fmt:check/oxlint/typecheck— cleanpnpm test— 6800/6801 pass (1 pre-existing failure inwarp-permissions.test.ts, present onmainand unrelated to this change)