chore: reformat
This commit is contained in:
@@ -59,13 +59,7 @@ type TInput =
|
||||
| typeof applyPatchSchema;
|
||||
|
||||
type VimParams = Static<typeof vimSchema>;
|
||||
type EditParams =
|
||||
| ReplaceParams
|
||||
| PatchParams
|
||||
| HashlineParams
|
||||
| AtomParams
|
||||
| VimParams
|
||||
| ApplyPatchParams;
|
||||
type EditParams = ReplaceParams | PatchParams | HashlineParams | AtomParams | VimParams | ApplyPatchParams;
|
||||
type EditToolResultDetails = EditToolDetails | VimToolDetails;
|
||||
|
||||
type EditModeDefinition = {
|
||||
|
||||
@@ -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.`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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}`);
|
||||
|
||||
@@ -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<typeof readSchema, ReadToolDetails> {
|
||||
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<TextContent | ImageContent>;
|
||||
let details: ReadToolDetails = {};
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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/);
|
||||
});
|
||||
|
||||
@@ -158,7 +158,6 @@ describe("findMatch", () => {
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe("adjustIndentation", () => {
|
||||
test("adds indentation when actualText is more indented than oldText", () => {
|
||||
const oldText = "foo\nbar";
|
||||
|
||||
@@ -2124,7 +2124,6 @@ export async function runBenchmark(
|
||||
)
|
||||
: undefined;
|
||||
|
||||
|
||||
const denom = effectiveRuns || 1;
|
||||
const summary: BenchmarkSummary = {
|
||||
totalTasks: tasks.length,
|
||||
|
||||
Reference in New Issue
Block a user