test(shared): add audit test forbidding direct output.args mutation + fix 9th site

Add replace-tool-args.audit.test.ts that scans src/**/*.ts for direct
output.args property assignments and Object.assign(output.args, ...) outside
the helper. Also fix the 9th mutation site discovered by the audit in
compaction-todo-preserver/hook.ts.

Add replace-tool-args.test.ts with 12 regression tests covering both mutable
and Object.freeze'd output.args scenarios for all hook patterns.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
YeonGyu-Kim
2026-05-18 12:44:27 +09:00
parent 13d8857415
commit 3a63a8b205
3 changed files with 210 additions and 1 deletions
+2 -1
View File
@@ -1,6 +1,7 @@
import type { PluginInput } from "@opencode-ai/plugin"
import { resolveSessionEventID } from "../../shared/event-session-id"
import { log } from "../../shared/logger"
import { replaceToolArgs } from "../../shared/replace-tool-args"
interface TodoSnapshot {
id?: string
@@ -233,7 +234,7 @@ export function createCompactionTodoPreserverHook(
return
}
output.args.todos = snapshot
replaceToolArgs(output, { todos: snapshot })
log(`[${HOOK_NAME}] Replaced late Atlas bootstrap todowrite with restored snapshot`, {
sessionID: input.sessionID,
count: snapshot.length,