Skip to content

refactor(rules): decouple RulesProcessor from other features' internals#1962

Open
saitota wants to merge 1 commit into
dyoshikawa:mainfrom
saitota:m2i1
Open

refactor(rules): decouple RulesProcessor from other features' internals#1962
saitota wants to merge 1 commit into
dyoshikawa:mainfrom
saitota:m2i1

Conversation

@saitota

@saitota saitota commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Background

RulesProcessor had become a god class. While the other 7 feature processors keep 0–1 tool branches and import no other features, rules-processor.ts imported 10 other-feature classes and held 11 this.toolTarget === "..." branches. It reached into the MCP feature's internals (KiloMcp / OpencodeMcp.fromInstructions) and hardcoded the simulate-section wording for commands/subagents/skills.

So convertRulesyncFilesToToolFiles forced 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

  • MCP integration inversion — non-root rules are registered via a declarative meta.mcpInstructionsRegistrar contract 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.
  • Simulate extraction — convention-section wording moved into each feature processor's getSimulatedConventionSection; the rules feature only decides which features contribute and concatenates them.
  • Declarative flags — all 11 toolTarget string branches replaced with meta flags (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 — clean
  • pnpm test — 6800/6801 pass (1 pre-existing failure in warp-permissions.test.ts, present on main and unrelated to this change)

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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant