fix(rules-injector): respect claude_code config for user rule loading

When claude_code integration is disabled in oh-my-opencode.json, the
rules-injector now skips loading rules from ~/.claude/rules/ to prevent
Claude Code-specific instructions from leaking into non-Claude agents
(e.g., GPT-5.4 Sisyphus), which causes agent hallucination.

Also adds ~/.sisyphus/rules/ and ~/.opencode/rules/ as OpenCode-native
user rule directories that are always searched regardless of config.

Fixes #2920

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Tran Quang
2026-03-29 10:13:55 +07:00
parent 9fc56ab544
commit a1a2bb4b07
6 changed files with 52 additions and 18 deletions
+4
View File
@@ -32,6 +32,7 @@ const TRACKED_TOOLS = ["read", "write", "edit", "multiedit"];
export function createRulesInjectorHook(
ctx: PluginInput,
modelCacheState?: { anthropicContext1MEnabled: boolean },
options?: { skipClaudeUserRules?: boolean },
) {
const truncator = createDynamicTruncator(ctx, modelCacheState);
const { getSessionCache, clearSessionCache } = createSessionCacheStore();
@@ -39,6 +40,9 @@ export function createRulesInjectorHook(
workspaceDirectory: ctx.directory,
truncator,
getSessionCache,
ruleFinderOptions: options?.skipClaudeUserRules
? { skipClaudeUserRules: true }
: undefined,
});
const toolExecuteAfter = async (