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:
@@ -25,11 +25,6 @@ interface ToolExecuteBeforeOutput {
|
||||
args: unknown;
|
||||
}
|
||||
|
||||
interface BatchToolCall {
|
||||
tool: string;
|
||||
parameters: Record<string, unknown>;
|
||||
}
|
||||
|
||||
interface EventInput {
|
||||
event: {
|
||||
type: string;
|
||||
@@ -39,7 +34,6 @@ interface EventInput {
|
||||
|
||||
export function createDirectoryAgentsInjectorHook(ctx: PluginInput) {
|
||||
const sessionCaches = new Map<string, Set<string>>();
|
||||
const pendingBatchReads = new Map<string, string[]>();
|
||||
const truncator = createDynamicTruncator(ctx);
|
||||
|
||||
function getSessionCache(sessionID: string): Set<string> {
|
||||
@@ -110,27 +104,6 @@ export function createDirectoryAgentsInjectorHook(ctx: PluginInput) {
|
||||
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 (
|
||||
input: ToolExecuteInput,
|
||||
output: ToolExecuteOutput,
|
||||
@@ -141,16 +114,14 @@ export function createDirectoryAgentsInjectorHook(ctx: PluginInput) {
|
||||
await processFilePathForInjection(output.title, input.sessionID, output);
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
if (toolName === "batch") {
|
||||
const filePaths = pendingBatchReads.get(input.callID);
|
||||
if (filePaths) {
|
||||
for (const filePath of filePaths) {
|
||||
await processFilePathForInjection(filePath, input.sessionID, output);
|
||||
}
|
||||
pendingBatchReads.delete(input.callID);
|
||||
}
|
||||
}
|
||||
const toolExecuteBefore = async (
|
||||
input: ToolExecuteInput,
|
||||
output: ToolExecuteBeforeOutput,
|
||||
): Promise<void> => {
|
||||
void input;
|
||||
void output;
|
||||
};
|
||||
|
||||
const eventHandler = async ({ event }: EventInput) => {
|
||||
|
||||
Reference in New Issue
Block a user