refactor(hooks): replace direct output.args mutation with replaceToolArgs (claude-code-hooks)
Replace output.args.todos = parsed and Object.assign(output.args, result.modifiedInput) with replaceToolArgs() calls that create a shallow clone instead of mutating the potentially-frozen args object. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -8,7 +8,7 @@ import {
|
|||||||
import { appendTranscriptEntry } from "../transcript"
|
import { appendTranscriptEntry } from "../transcript"
|
||||||
import { cacheToolInput } from "../tool-input-cache"
|
import { cacheToolInput } from "../tool-input-cache"
|
||||||
import type { PluginConfig } from "../types"
|
import type { PluginConfig } from "../types"
|
||||||
import { isHookDisabled, log } from "../../../shared"
|
import { isHookDisabled, log, replaceToolArgs } from "../../../shared"
|
||||||
|
|
||||||
export function createToolExecuteBeforeHandler(ctx: PluginInput, config: PluginConfig) {
|
export function createToolExecuteBeforeHandler(ctx: PluginInput, config: PluginConfig) {
|
||||||
return async (
|
return async (
|
||||||
@@ -39,7 +39,7 @@ export function createToolExecuteBeforeHandler(ctx: PluginInput, config: PluginC
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
output.args.todos = parsed
|
replaceToolArgs(output, { todos: parsed })
|
||||||
log("todowrite: parsed todos string to array", { sessionID: input.sessionID })
|
log("todowrite: parsed todos string to array", { sessionID: input.sessionID })
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,7 +87,7 @@ export function createToolExecuteBeforeHandler(ctx: PluginInput, config: PluginC
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (result.modifiedInput) {
|
if (result.modifiedInput) {
|
||||||
Object.assign(output.args, result.modifiedInput)
|
replaceToolArgs(output, result.modifiedInput as Record<string, unknown>)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user