Skip to content

Commit 80974e5

Browse files
committed
style(plugins): format shared tool helpers
1 parent 64b93c8 commit 80974e5

10 files changed

Lines changed: 34 additions & 30 deletions

‎src/io/bounded-read.ts‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,10 @@ export interface BoundedRead {
3838
// call-keying detectors see one ranged read per window, not a same-path
3939
// loop.
4040

41-
4241
function numberLine(lineNo: number, text: string): string {
4342
return `${String(lineNo).padStart(6, " ")}\t${text}`;
4443
}
4544

46-
4745
/**
4846
* Streams UTF-8 from `stream`, emitting up to `limit` line-numbered lines
4947
* after skipping `offset` lines (zero-based); never decodes the full text in
@@ -282,7 +280,6 @@ export function readStreamBounded(
282280
});
283281
}
284282

285-
286283
/**
287284
* Bounded read over an in-memory UTF-8 blob (tool-output spills). Feeds the
288285
* buffer in chunks so offset/limit never require a full-text split; overlong
@@ -316,7 +313,6 @@ export function readBytesBounded(
316313
);
317314
}
318315

319-
320316
function continuationNotice(
321317
reason: TruncReason,
322318
firstLine: number,
@@ -337,4 +333,3 @@ function continuationNotice(
337333
scanCeiling / (1024 * 1024)
338334
}MB scan limit. ${next}]`;
339335
}
340-

‎src/plugins/bounded-grep-fallback.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ function rejectBraceExpansion(pattern: string): string {
1919
return pattern;
2020
}
2121

22-
2322
/** Max file paths considered per search (directory walk). */
2423
export const BOUNDED_GREP_MAX_DIRECTORY_ENTRIES = 25_000;
2524

@@ -237,7 +236,10 @@ export async function runBoundedGrep(
237236
const basePath = resolve(baseCwd, args.path ?? ".");
238237
const contextLines = args.context ?? 0;
239238
const maxResults = args.max_results ?? BOUNDED_GREP_DEFAULT_MAX_RESULTS;
240-
const globFilter = args.glob !== undefined ? globToRegExp(rejectBraceExpansion(args.glob)) : null;
239+
const globFilter =
240+
args.glob !== undefined
241+
? globToRegExp(rejectBraceExpansion(args.glob))
242+
: null;
241243

242244
let info;
243245
try {

‎src/plugins/delete-file-plugin.ts‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ export function deleteFilePlugin(
5252
handler: async (call: ToolCall): Promise<ToolResult> => {
5353
const args = DeleteFileArgs(call.arguments);
5454
if (args instanceof type.errors) {
55-
return denyResult(call.id, "Failed to delete file: delete_file requires a non-empty path");
55+
return denyResult(
56+
call.id,
57+
"Failed to delete file: delete_file requires a non-empty path",
58+
);
5659
}
5760

5861
const allowOutside = resolveAllowOutside(options.allowOutside);
@@ -116,7 +119,10 @@ export function deleteFilePlugin(
116119
content: `File already absent: ${args.path} (no action needed)`,
117120
};
118121
}
119-
return denyResult(call.id, `Failed to delete file: ${failureDetail(error)}`);
122+
return denyResult(
123+
call.id,
124+
`Failed to delete file: ${failureDetail(error)}`,
125+
);
120126
}
121127
},
122128
};
@@ -127,9 +133,7 @@ export function deleteFilePlugin(
127133
function failureDetail(error: unknown): string {
128134
if (error instanceof Error) {
129135
const code =
130-
hasCode(error) && typeof error.code === "string"
131-
? error.code
132-
: undefined;
136+
hasCode(error) && typeof error.code === "string" ? error.code : undefined;
133137
return code === undefined ? error.message : `${code}: ${error.message}`;
134138
}
135139
return String(error);

‎src/plugins/evidence-archive-search-plugin.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@ export function evidenceArchiveSearchPlugin(
172172
if (pattern === undefined) {
173173
return denyResult(call.id, "Error: grep requires pattern (string).");
174174
}
175-
const maxResults = optionalNumber(call.arguments.max_results) ?? GREP_DEFAULT_MAX;
175+
const maxResults =
176+
optionalNumber(call.arguments.max_results) ?? GREP_DEFAULT_MAX;
176177
const glob = optionalString(call.arguments.glob);
177178
const contextArg = optionalNumber(call.arguments.context);
178179
const context =

‎src/plugins/path-escape-plugin.ts‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,8 @@ function escapeArgs(
8484
// pathEscapeBlockReason computes, so a surviving call is exactly one the
8585
// block-reason leg would have passed.
8686
const roots = rootsForEscape(toolName, rootsProvider, trustedPluginRoots);
87-
return walkPathArgs(
88-
args,
89-
undefined,
90-
(value) => sanitizePath(value, cwd, roots, allowOutside, toolName),
87+
return walkPathArgs(args, undefined, (value) =>
88+
sanitizePath(value, cwd, roots, allowOutside, toolName),
9189
) as Record<string, unknown>;
9290
}
9391

‎src/plugins/read-file-guard-plugin.ts‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@ import {
77
canonicalToolOutputUri,
88
isToolOutputLike,
99
} from "../util/tool-output-uri.js";
10-
import {
11-
denyResult,
12-
errorMessage,
13-
optionalNumber,
14-
} from "./tool-args.js";
10+
import { denyResult, errorMessage, optionalNumber } from "./tool-args.js";
1511
import {
1612
diagnoseBlockedFileInspection,
1713
inspectionKindFromFirstChunk,

‎src/plugins/ripgrep-plugin.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ export function ripgrepPlugin(
161161
const path = optionalString(call.arguments.path) ?? cwd;
162162
const context = optionalNumber(call.arguments.context) ?? 0;
163163
const glob = optionalString(call.arguments.glob);
164-
const maxResults = optionalNumber(call.arguments.max_results) ?? DEFAULT_GREP_MAX;
164+
const maxResults =
165+
optionalNumber(call.arguments.max_results) ?? DEFAULT_GREP_MAX;
165166
const { cwd: rgCwd, target } = searchLocation(path, cwd);
166167

167168
const rgArgs = ["--line-number", "--no-heading", "--color", "never"];

‎src/plugins/tool-output-uri-plugin.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import type { ToolPlugin } from "@intx/tools-posix";
2-
import { isToolOutputLike, normalizeToolOutputUri } from "../util/tool-output-uri.js";
2+
import {
3+
isToolOutputLike,
4+
normalizeToolOutputUri,
5+
} from "../util/tool-output-uri.js";
36
import { virtualRefVerdict } from "./path-escape-plugin.js";
47
import { denyResult } from "./tool-args.js";
58

‎src/plugins/tool-time-budget.ts‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@ const NOT_A_NO_MATCH_TAIL = 'This is not the same as "no matches".';
1313

1414
// Timeout notices carry whatever partial output already streamed so the agent
1515
// never loses the bytes it did get; empty partials attach the bare notice.
16-
function withPartialResult(
17-
notice: string,
18-
partialResult?: string,
19-
): string {
16+
function withPartialResult(notice: string, partialResult?: string): string {
2017
const trimmed = partialResult?.trim();
2118
if (trimmed === undefined || trimmed.length === 0) return notice;
2219
return `${trimmed}\n\n${notice}`;

‎src/shell/spawn-tree.ts‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import { spawn, type ChildProcess, type SpawnOptions } from "node:child_process";
1+
import {
2+
spawn,
3+
type ChildProcess,
4+
type SpawnOptions,
5+
} from "node:child_process";
26

37
// One process-group-kill policy for every spawned tool subprocess: the child
48
// is spawned detached so it becomes a group leader, and the kill reaches the
@@ -33,7 +37,10 @@ export function killProcessTree(child: TreeChild): void {
3337
}
3438

3539
/** Spawn options making the child a process-group leader (POSIX only). */
36-
export function processGroupLeaderSpawnOptions(): Pick<SpawnOptions, "detached"> {
40+
export function processGroupLeaderSpawnOptions(): Pick<
41+
SpawnOptions,
42+
"detached"
43+
> {
3744
return { detached: process.platform !== "win32" };
3845
}
3946

0 commit comments

Comments
 (0)