fix(rules-injector): remove dead batch code, add .sisyphus support

- Remove non-functional batch tool handling (OpenCode has no batch tool)
- Keep working direct tool call path (read/write/edit/multiedit)
- Apply same cleanup to directory-agents-injector and directory-readme-injector
- Add .sisyphus/rules directory support
This commit is contained in:
justsisyphus 2026-02-01 15:01:09 +09:00
parent 3808fd3a4b
commit e48be69a62
4 changed files with 22 additions and 116 deletions

View File

@ -25,11 +25,6 @@ interface ToolExecuteBeforeOutput {
args: unknown; args: unknown;
} }
interface BatchToolCall {
tool: string;
parameters: Record<string, unknown>;
}
interface EventInput { interface EventInput {
event: { event: {
type: string; type: string;
@ -39,7 +34,6 @@ interface EventInput {
export function createDirectoryAgentsInjectorHook(ctx: PluginInput) { export function createDirectoryAgentsInjectorHook(ctx: PluginInput) {
const sessionCaches = new Map<string, Set<string>>(); const sessionCaches = new Map<string, Set<string>>();
const pendingBatchReads = new Map<string, string[]>();
const truncator = createDynamicTruncator(ctx); const truncator = createDynamicTruncator(ctx);
function getSessionCache(sessionID: string): Set<string> { function getSessionCache(sessionID: string): Set<string> {
@ -110,27 +104,6 @@ export function createDirectoryAgentsInjectorHook(ctx: PluginInput) {
saveInjectedPaths(sessionID, cache); saveInjectedPaths(sessionID, cache);
} }
const toolExecuteBefore = async (
input: ToolExecuteInput,
output: ToolExecuteBeforeOutput,
) => {
if (input.tool.toLowerCase() !== "batch") return;
const args = output.args as { tool_calls?: BatchToolCall[] } | undefined;
if (!args?.tool_calls) return;
const readFilePaths: string[] = [];
for (const call of args.tool_calls) {
if (call.tool.toLowerCase() === "read" && call.parameters?.filePath) {
readFilePaths.push(call.parameters.filePath as string);
}
}
if (readFilePaths.length > 0) {
pendingBatchReads.set(input.callID, readFilePaths);
}
};
const toolExecuteAfter = async ( const toolExecuteAfter = async (
input: ToolExecuteInput, input: ToolExecuteInput,
output: ToolExecuteOutput, output: ToolExecuteOutput,
@ -141,16 +114,14 @@ export function createDirectoryAgentsInjectorHook(ctx: PluginInput) {
await processFilePathForInjection(output.title, input.sessionID, output); await processFilePathForInjection(output.title, input.sessionID, output);
return; return;
} }
};
if (toolName === "batch") { const toolExecuteBefore = async (
const filePaths = pendingBatchReads.get(input.callID); input: ToolExecuteInput,
if (filePaths) { output: ToolExecuteBeforeOutput,
for (const filePath of filePaths) { ): Promise<void> => {
await processFilePathForInjection(filePath, input.sessionID, output); void input;
} void output;
pendingBatchReads.delete(input.callID);
}
}
}; };
const eventHandler = async ({ event }: EventInput) => { const eventHandler = async ({ event }: EventInput) => {

View File

@ -25,11 +25,6 @@ interface ToolExecuteBeforeOutput {
args: unknown; args: unknown;
} }
interface BatchToolCall {
tool: string;
parameters: Record<string, unknown>;
}
interface EventInput { interface EventInput {
event: { event: {
type: string; type: string;
@ -39,7 +34,6 @@ interface EventInput {
export function createDirectoryReadmeInjectorHook(ctx: PluginInput) { export function createDirectoryReadmeInjectorHook(ctx: PluginInput) {
const sessionCaches = new Map<string, Set<string>>(); const sessionCaches = new Map<string, Set<string>>();
const pendingBatchReads = new Map<string, string[]>();
const truncator = createDynamicTruncator(ctx); const truncator = createDynamicTruncator(ctx);
function getSessionCache(sessionID: string): Set<string> { function getSessionCache(sessionID: string): Set<string> {
@ -105,27 +99,6 @@ export function createDirectoryReadmeInjectorHook(ctx: PluginInput) {
saveInjectedPaths(sessionID, cache); saveInjectedPaths(sessionID, cache);
} }
const toolExecuteBefore = async (
input: ToolExecuteInput,
output: ToolExecuteBeforeOutput,
) => {
if (input.tool.toLowerCase() !== "batch") return;
const args = output.args as { tool_calls?: BatchToolCall[] } | undefined;
if (!args?.tool_calls) return;
const readFilePaths: string[] = [];
for (const call of args.tool_calls) {
if (call.tool.toLowerCase() === "read" && call.parameters?.filePath) {
readFilePaths.push(call.parameters.filePath as string);
}
}
if (readFilePaths.length > 0) {
pendingBatchReads.set(input.callID, readFilePaths);
}
};
const toolExecuteAfter = async ( const toolExecuteAfter = async (
input: ToolExecuteInput, input: ToolExecuteInput,
output: ToolExecuteOutput, output: ToolExecuteOutput,
@ -136,16 +109,14 @@ export function createDirectoryReadmeInjectorHook(ctx: PluginInput) {
await processFilePathForInjection(output.title, input.sessionID, output); await processFilePathForInjection(output.title, input.sessionID, output);
return; return;
} }
};
if (toolName === "batch") { const toolExecuteBefore = async (
const filePaths = pendingBatchReads.get(input.callID); input: ToolExecuteInput,
if (filePaths) { output: ToolExecuteBeforeOutput,
for (const filePath of filePaths) { ): Promise<void> => {
await processFilePathForInjection(filePath, input.sessionID, output); void input;
} void output;
pendingBatchReads.delete(input.callID);
}
}
}; };
const eventHandler = async ({ event }: EventInput) => { const eventHandler = async ({ event }: EventInput) => {

View File

@ -17,6 +17,7 @@ export const PROJECT_RULE_SUBDIRS: [string, string][] = [
[".github", "instructions"], [".github", "instructions"],
[".cursor", "rules"], [".cursor", "rules"],
[".claude", "rules"], [".claude", "rules"],
[".sisyphus", "rules"],
]; ];
export const PROJECT_RULE_FILES: string[] = [ export const PROJECT_RULE_FILES: string[] = [

View File

@ -33,11 +33,6 @@ interface ToolExecuteBeforeOutput {
args: unknown; args: unknown;
} }
interface BatchToolCall {
tool: string;
parameters: Record<string, unknown>;
}
interface EventInput { interface EventInput {
event: { event: {
type: string; type: string;
@ -59,7 +54,6 @@ export function createRulesInjectorHook(ctx: PluginInput) {
string, string,
{ contentHashes: Set<string>; realPaths: Set<string> } { contentHashes: Set<string>; realPaths: Set<string> }
>(); >();
const pendingBatchFiles = new Map<string, string[]>();
const truncator = createDynamicTruncator(ctx); const truncator = createDynamicTruncator(ctx);
function getSessionCache(sessionID: string): { function getSessionCache(sessionID: string): {
@ -143,35 +137,6 @@ export function createRulesInjectorHook(ctx: PluginInput) {
saveInjectedRules(sessionID, cache); saveInjectedRules(sessionID, cache);
} }
function extractFilePathFromToolCall(call: BatchToolCall): string | null {
const params = call.parameters;
return (params?.filePath ?? params?.file_path ?? params?.path) as string | null;
}
const toolExecuteBefore = async (
input: ToolExecuteInput,
output: ToolExecuteBeforeOutput
) => {
if (input.tool.toLowerCase() !== "batch") return;
const args = output.args as { tool_calls?: BatchToolCall[] } | undefined;
if (!args?.tool_calls) return;
const filePaths: string[] = [];
for (const call of args.tool_calls) {
if (TRACKED_TOOLS.includes(call.tool.toLowerCase())) {
const filePath = extractFilePathFromToolCall(call);
if (filePath) {
filePaths.push(filePath);
}
}
}
if (filePaths.length > 0) {
pendingBatchFiles.set(input.callID, filePaths);
}
};
const toolExecuteAfter = async ( const toolExecuteAfter = async (
input: ToolExecuteInput, input: ToolExecuteInput,
output: ToolExecuteOutput output: ToolExecuteOutput
@ -182,16 +147,14 @@ export function createRulesInjectorHook(ctx: PluginInput) {
await processFilePathForInjection(output.title, input.sessionID, output); await processFilePathForInjection(output.title, input.sessionID, output);
return; return;
} }
};
if (toolName === "batch") { const toolExecuteBefore = async (
const filePaths = pendingBatchFiles.get(input.callID); input: ToolExecuteInput,
if (filePaths) { output: ToolExecuteBeforeOutput
for (const filePath of filePaths) { ): Promise<void> => {
await processFilePathForInjection(filePath, input.sessionID, output); void input;
} void output;
pendingBatchFiles.delete(input.callID);
}
}
}; };
const eventHandler = async ({ event }: EventInput) => { const eventHandler = async ({ event }: EventInput) => {