From 4c1a89967910717a92efbf1ac09d288a47e64868 Mon Sep 17 00:00:00 2001 From: can1357 Date: Sun, 26 Apr 2026 09:05:47 +0200 Subject: [PATCH] chore: reformat --- packages/coding-agent/src/edit/index.ts | 8 +------ packages/coding-agent/src/edit/modes/atom.ts | 4 +--- packages/coding-agent/src/tools/grep.ts | 3 +-- packages/coding-agent/src/tools/poll-tool.ts | 24 +++++++++---------- packages/coding-agent/src/tools/read.ts | 8 +++---- packages/coding-agent/src/tools/renderers.ts | 2 +- packages/coding-agent/test/core/atom.test.ts | 12 +++------- packages/coding-agent/test/edit-diff.test.ts | 1 - .../typescript-edit-benchmark/src/runner.ts | 1 - 9 files changed, 22 insertions(+), 41 deletions(-) diff --git a/packages/coding-agent/src/edit/index.ts b/packages/coding-agent/src/edit/index.ts index a5499bd64..980845ca5 100644 --- a/packages/coding-agent/src/edit/index.ts +++ b/packages/coding-agent/src/edit/index.ts @@ -59,13 +59,7 @@ type TInput = | typeof applyPatchSchema; type VimParams = Static; -type EditParams = - | ReplaceParams - | PatchParams - | HashlineParams - | AtomParams - | VimParams - | ApplyPatchParams; +type EditParams = ReplaceParams | PatchParams | HashlineParams | AtomParams | VimParams | ApplyPatchParams; type EditToolResultDetails = EditToolDetails | VimToolDetails; type EditModeDefinition = { diff --git a/packages/coding-agent/src/edit/modes/atom.ts b/packages/coding-agent/src/edit/modes/atom.ts index 6d232fd85..dc9e427d0 100644 --- a/packages/coding-agent/src/edit/modes/atom.ts +++ b/packages/coding-agent/src/edit/modes/atom.ts @@ -790,9 +790,7 @@ export function applyAtomEdits( `Edit sed expression ${JSON.stringify(edit.expression)} failed to compile: ${lastCompileError}`, ); } - throw new Error( - `Edit sed expression ${JSON.stringify(edit.expression)} did not match any line in the file.`, - ); + throw new Error(`Edit sed expression ${JSON.stringify(edit.expression)} did not match any line in the file.`); } } diff --git a/packages/coding-agent/src/tools/grep.ts b/packages/coding-agent/src/tools/grep.ts index 74e825034..88e47efe4 100644 --- a/packages/coding-agent/src/tools/grep.ts +++ b/packages/coding-agent/src/tools/grep.ts @@ -7,11 +7,10 @@ import { Text } from "@oh-my-pi/pi-tui"; import { prompt, untilAborted } from "@oh-my-pi/pi-utils"; import { type Static, Type } from "@sinclair/typebox"; import type { RenderResultOptions } from "../extensibility/custom-tools/types"; -import { type Theme } from "../modes/theme/theme"; +import type { Theme } from "../modes/theme/theme"; import grepDescription from "../prompts/tools/grep.md" with { type: "text" }; import { DEFAULT_MAX_COLUMN, type TruncationResult, truncateHead } from "../session/streaming-output"; import { Ellipsis, Hasher, type RenderCache, renderStatusLine, renderTreeList, truncateToWidth } from "../tui"; -import { resolveEditMode } from "../utils/edit-mode"; import { resolveFileDisplayMode } from "../utils/file-display-mode"; import type { ToolSession } from "."; import { createFileRecorder } from "./file-recorder"; diff --git a/packages/coding-agent/src/tools/poll-tool.ts b/packages/coding-agent/src/tools/poll-tool.ts index 8c8ff20b0..969d4058c 100644 --- a/packages/coding-agent/src/tools/poll-tool.ts +++ b/packages/coding-agent/src/tools/poll-tool.ts @@ -1,13 +1,14 @@ +import type { AgentTool, AgentToolContext, AgentToolResult, AgentToolUpdateCallback } from "@oh-my-pi/pi-agent-core"; import type { Component } from "@oh-my-pi/pi-tui"; import { Text } from "@oh-my-pi/pi-tui"; -import type { AgentTool, AgentToolContext, AgentToolResult, AgentToolUpdateCallback } from "@oh-my-pi/pi-agent-core"; import { prompt } from "@oh-my-pi/pi-utils"; -import type { RenderResultOptions } from "../extensibility/custom-tools/types"; -import type { Theme } from "../modes/theme/theme"; -import { Ellipsis, Hasher, type RenderCache, renderStatusLine, renderTreeList, truncateToWidth } from "../tui"; import { type Static, Type } from "@sinclair/typebox"; import { isBackgroundJobSupportEnabled } from "../async"; +import type { RenderResultOptions } from "../extensibility/custom-tools/types"; +import type { Theme } from "../modes/theme/theme"; import pollDescription from "../prompts/tools/poll.md" with { type: "text" }; +import { Ellipsis, Hasher, type RenderCache, renderStatusLine, renderTreeList, truncateToWidth } from "../tui"; +import type { ToolSession } from "./index"; import { formatBadge, formatDuration, @@ -19,7 +20,6 @@ import { type ToolUIColor, type ToolUIStatus, } from "./render-utils"; -import type { ToolSession } from "./index"; const pollSchema = Type.Object({ jobs: Type.Optional( @@ -288,10 +288,7 @@ export const pollToolRenderer = { inline: true, renderCall(args: PollRenderArgs, _options: RenderResultOptions, uiTheme: Theme): Component { - const text = renderStatusLine( - { icon: "pending", title: "Poll", description: describeTarget(args) }, - uiTheme, - ); + const text = renderStatusLine({ icon: "pending", title: "Poll", description: describeTarget(args) }, uiTheme); return new Text(text, 0, 0); }, @@ -321,8 +318,7 @@ export const pollToolRenderer = { if (counts.cancelled > 0) meta.push(uiTheme.fg("warning", `${counts.cancelled} cancelled`)); if (counts.running > 0) meta.push(uiTheme.fg("accent", `${counts.running} running`)); - const headerIcon: ToolUIStatus = - counts.failed > 0 ? "warning" : counts.running > 0 ? "info" : "success"; + const headerIcon: ToolUIStatus = counts.failed > 0 ? "warning" : counts.running > 0 ? "info" : "success"; const description = counts.running > 0 ? `waiting on ${counts.running} of ${jobs.length}` @@ -375,7 +371,11 @@ export const pollToolRenderer = { ); const typeBadge = formatBadge(job.type, statusToColor(job.status), uiTheme); const idText = uiTheme.fg("muted", job.id); - const label = truncateToWidth(replaceTabs(job.label || "(no label)"), LABEL_MAX_WIDTH, Ellipsis.Unicode); + const label = truncateToWidth( + replaceTabs(job.label || "(no label)"), + LABEL_MAX_WIDTH, + Ellipsis.Unicode, + ); const labelText = uiTheme.fg("toolOutput", label); const durationText = uiTheme.fg("dim", formatDuration(job.durationMs)); lines.push(`${icon} ${idText} ${typeBadge} ${labelText} ${durationText}`); diff --git a/packages/coding-agent/src/tools/read.ts b/packages/coding-agent/src/tools/read.ts index acd6d8c53..39070f480 100644 --- a/packages/coding-agent/src/tools/read.ts +++ b/packages/coding-agent/src/tools/read.ts @@ -25,7 +25,6 @@ import { } from "../session/streaming-output"; import { renderCodeCell, renderStatusLine } from "../tui"; import { CachedOutputBlock } from "../tui/output-block"; -import { resolveEditMode } from "../utils/edit-mode"; import { resolveFileDisplayMode } from "../utils/file-display-mode"; import { ImageInputTooLargeError, loadImageInput, MAX_IMAGE_INPUT_BYTES } from "../utils/image-loading"; import { convertFileWithMarkit } from "../utils/markit"; @@ -1001,10 +1000,9 @@ export class ReadTool implements AgentTool { const imageMetadata = await readImageMetadata(absolutePath); const mimeType = imageMetadata?.mimeType; const ext = path.extname(absolutePath).toLowerCase(); - const hasEditTool = this.session.hasEditTool ?? true; - const language = getLanguageFromPath(absolutePath); - const shouldConvertWithMarkit = - CONVERTIBLE_EXTENSIONS.has(ext) || (ext === ".ipynb" && parsed.kind === "raw"); + const _hasEditTool = this.session.hasEditTool ?? true; + const _language = getLanguageFromPath(absolutePath); + const shouldConvertWithMarkit = CONVERTIBLE_EXTENSIONS.has(ext) || (ext === ".ipynb" && parsed.kind === "raw"); // Read the file based on type let content: Array; let details: ReadToolDetails = {}; diff --git a/packages/coding-agent/src/tools/renderers.ts b/packages/coding-agent/src/tools/renderers.ts index e0057a1b0..42177c191 100644 --- a/packages/coding-agent/src/tools/renderers.ts +++ b/packages/coding-agent/src/tools/renderers.ts @@ -21,10 +21,10 @@ import { githubToolRenderer } from "./gh-renderer"; import { grepToolRenderer } from "./grep"; import { inspectImageToolRenderer } from "./inspect-image-renderer"; import { notebookToolRenderer } from "./notebook"; +import { pollToolRenderer } from "./poll-tool"; import { pythonToolRenderer } from "./python"; import { readToolRenderer } from "./read"; import { resolveToolRenderer } from "./resolve"; -import { pollToolRenderer } from "./poll-tool"; import { searchToolBm25Renderer } from "./search-tool-bm25"; import { sshToolRenderer } from "./ssh"; import { todoWriteToolRenderer } from "./todo-write"; diff --git a/packages/coding-agent/test/core/atom.test.ts b/packages/coding-agent/test/core/atom.test.ts index 493bf179c..ed5d2dbb8 100644 --- a/packages/coding-agent/test/core/atom.test.ts +++ b/packages/coding-agent/test/core/atom.test.ts @@ -237,15 +237,11 @@ describe("parseAnchor (atom tolerant) + applyAtomEdits", () => { }); describe("atom range locators", () => { it("resolveAtomToolEdit rejects range loc with set", () => { - expect(() => resolveAtomToolEdit({ loc: "1xx-4yy", set: ["X"] })).toThrow( - /does not support line ranges/, - ); + expect(() => resolveAtomToolEdit({ loc: "1xx-4yy", set: ["X"] })).toThrow(/does not support line ranges/); }); it("resolveAtomToolEdit rejects range loc even when the verb would otherwise be valid", () => { - expect(() => resolveAtomToolEdit({ loc: "1xx-4yy", pre: ["X"] })).toThrow( - /does not support line ranges/, - ); + expect(() => resolveAtomToolEdit({ loc: "1xx-4yy", pre: ["X"] })).toThrow(/does not support line ranges/); }); it("resolveAtomEntryPaths still peels off a path override before range validation", () => { @@ -347,9 +343,7 @@ describe("applyAtomEdits — sed", () => { it("rejects malformed sed expressions", () => { const loc = "1ab"; - expect(() => resolveAtomToolEdit({ loc, sed: "foo/bar/" })).toThrow( - /sed delimiter must be|must start with/, - ); + expect(() => resolveAtomToolEdit({ loc, sed: "foo/bar/" })).toThrow(/sed delimiter must be|must start with/); expect(() => resolveAtomToolEdit({ loc, sed: "s/foo" })).toThrow(/Expected three/); expect(() => resolveAtomToolEdit({ loc, sed: "s/foo/bar/q" })).toThrow(/unknown sed flag/); }); diff --git a/packages/coding-agent/test/edit-diff.test.ts b/packages/coding-agent/test/edit-diff.test.ts index e3c3015a1..48d532633 100644 --- a/packages/coding-agent/test/edit-diff.test.ts +++ b/packages/coding-agent/test/edit-diff.test.ts @@ -158,7 +158,6 @@ describe("findMatch", () => { }); }); - describe("adjustIndentation", () => { test("adds indentation when actualText is more indented than oldText", () => { const oldText = "foo\nbar"; diff --git a/packages/typescript-edit-benchmark/src/runner.ts b/packages/typescript-edit-benchmark/src/runner.ts index 17e102255..21f7e642c 100644 --- a/packages/typescript-edit-benchmark/src/runner.ts +++ b/packages/typescript-edit-benchmark/src/runner.ts @@ -2124,7 +2124,6 @@ export async function runBenchmark( ) : undefined; - const denom = effectiveRuns || 1; const summary: BenchmarkSummary = { totalTasks: tasks.length,