Skip to content

Commit 517a134

Browse files
anandgupta42claude
andcommitted
refactor: address remaining LOW review nits (any → unknown)
- critic.ts: `Verifier.verify(args: Record<string, any>)` and `gate(args)` now use `Record<string, unknown>` — arbitrary tool args, but stricter than `any` (callers must narrow; `String(args["command"])` still compiles). - prompt.ts: the gate-block `args` cast updated to `Record<string, unknown>` to match; the metadata `as any` kept (open tool-metadata record, consistent with the surrounding tool-wrapper casts) with an explanatory comment per the no-bare-`any` guideline. 104 critic tests pass; typecheck clean. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
1 parent 50a0f6e commit 517a134

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

‎packages/opencode/src/session/prompt.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1526,10 +1526,12 @@ export namespace SessionPrompt {
15261526
// skip execution and feed the reason back so the model can retry, while
15271527
// still emitting tool.execute.after so observability sees the blocked call.
15281528
if (Critic.enabled()) {
1529-
const verdict = await Critic.gate(item.id, args as Record<string, any>, Critic.basicSafetyVerifier)
1529+
const verdict = await Critic.gate(item.id, args as Record<string, unknown>, Critic.basicSafetyVerifier)
15301530
if (!verdict.allow) {
15311531
const blocked = {
15321532
title: `Blocked: ${item.id}`,
1533+
// `as any`: tool metadata is an open Record per the tool-result
1534+
// contract; this matches the surrounding tool-wrapper casts.
15331535
metadata: { critic: { blocked: true, reason: verdict.feedback } } as any,
15341536
output: verdict.feedback ?? "Blocked by altimate verifier.",
15351537
attachments: [] as never[],

‎packages/opencode/src/tool/critic.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export namespace Critic {
4040

4141
/** The judgment interface. Default impl allows all (open). Product plugs a richer verifier. */
4242
export interface Verifier {
43-
verify(toolName: string, args: Record<string, any>): Verdict | Promise<Verdict>
43+
verify(toolName: string, args: Record<string, unknown>): Verdict | Promise<Verdict>
4444
}
4545

4646
export const ALLOW_ALL: Verifier = { verify: () => ({ ok: true }) }
@@ -238,7 +238,7 @@ export namespace Critic {
238238

239239
export async function gate(
240240
toolName: string,
241-
args: Record<string, any>,
241+
args: Record<string, unknown>,
242242
verifier: Verifier = ALLOW_ALL,
243243
gated: string[] = DEFAULT_GATED,
244244
timeoutMs: number = VERIFIER_TIMEOUT_MS,

0 commit comments

Comments
 (0)