diff --git a/packages/coding-agent/src/lsp/render.ts b/packages/coding-agent/src/lsp/render.ts index 6d18d139b..08f7928e5 100644 --- a/packages/coding-agent/src/lsp/render.ts +++ b/packages/coding-agent/src/lsp/render.ts @@ -8,11 +8,7 @@ * - Collapsible/expandable views */ import type { RenderResultOptions } from "@oh-my-pi/pi-agent-core"; -import { - highlightCode as nativeHighlightCode, - type HighlightColors, - supportsLanguage, -} from "@oh-my-pi/pi-natives"; +import { type HighlightColors, highlightCode as nativeHighlightCode, supportsLanguage } from "@oh-my-pi/pi-natives"; import { type Component, Text } from "@oh-my-pi/pi-tui"; import { getLanguageFromPath, type Theme } from "../modes/theme/theme"; import { diff --git a/packages/coding-agent/src/modes/theme/theme.ts b/packages/coding-agent/src/modes/theme/theme.ts index 8b3d8b6a0..f43419ac0 100644 --- a/packages/coding-agent/src/modes/theme/theme.ts +++ b/packages/coding-agent/src/modes/theme/theme.ts @@ -1,14 +1,14 @@ import * as fs from "node:fs"; import * as path from "node:path"; +import { + type HighlightColors as NativeHighlightColors, + highlightCode as nativeHighlightCode, + supportsLanguage as nativeSupportsLanguage, +} from "@oh-my-pi/pi-natives"; import type { EditorTheme, MarkdownTheme, SelectListTheme, SymbolTheme } from "@oh-my-pi/pi-tui"; import { adjustHsv, isEnoent, logger } from "@oh-my-pi/pi-utils"; import { type Static, Type } from "@sinclair/typebox"; import { TypeCompiler } from "@sinclair/typebox/compiler"; -import { - highlightCode as nativeHighlightCode, - type HighlightColors as NativeHighlightColors, - supportsLanguage as nativeSupportsLanguage, -} from "@oh-my-pi/pi-natives"; import chalk from "chalk"; import { getCustomThemesDir } from "../../config"; // Embed theme JSON files at build time diff --git a/packages/coding-agent/src/tools/read.ts b/packages/coding-agent/src/tools/read.ts index 157def367..d430a01f5 100644 --- a/packages/coding-agent/src/tools/read.ts +++ b/packages/coding-agent/src/tools/read.ts @@ -74,7 +74,7 @@ async function streamLinesFromFile( let sawAnyByte = false; let endedWithNewline = false; let firstLinePreviewBytes = 0; - let firstLinePreviewChunks: Buffer[] = []; + const firstLinePreviewChunks: Buffer[] = []; let firstLineByteLength: number | undefined; let selectedBytesTotal = 0; let selectedLinesSeen = 0; @@ -727,7 +727,6 @@ export class ReadTool implements AgentTool { stoppedByByteLimit, firstLinePreview, firstLineByteLength, - selectedBytesTotal, } = streamResult; // Check if offset is out of bounds - return graceful message instead of throwing @@ -742,12 +741,10 @@ export class ReadTool implements AgentTool { } const selectedContent = collectedLines.join("\n"); - const userLimitedLines = - limit !== undefined ? Math.min(limit, Math.max(0, totalFileLines - startLine)) : undefined; + const userLimitedLines = limit !== undefined ? collectedLines.length : undefined; - const totalSelectedLines = - limit !== undefined ? Math.min(limit, Math.max(0, totalFileLines - startLine)) : totalFileLines - startLine; - const totalSelectedBytes = selectedBytesTotal; + const totalSelectedLines = totalFileLines - startLine; + const totalSelectedBytes = collectedBytes; const wasTruncated = collectedLines.length < totalSelectedLines || stoppedByByteLimit; const firstLineExceedsLimit = firstLineByteLength !== undefined && firstLineByteLength > DEFAULT_MAX_BYTES; diff --git a/packages/coding-agent/test/core/python-kernel-env.test.ts b/packages/coding-agent/test/core/python-kernel-env.test.ts index aaf88e58f..f3b22c382 100644 --- a/packages/coding-agent/test/core/python-kernel-env.test.ts +++ b/packages/coding-agent/test/core/python-kernel-env.test.ts @@ -1,7 +1,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "bun:test"; +import { SettingsManager } from "@oh-my-pi/pi-coding-agent"; import { PythonKernel } from "@oh-my-pi/pi-coding-agent/ipy/kernel"; import { PYTHON_PRELUDE } from "@oh-my-pi/pi-coding-agent/ipy/prelude"; -import * as shell from "@oh-my-pi/pi-coding-agent/utils/shell"; import * as shellSnapshot from "@oh-my-pi/pi-coding-agent/utils/shell-snapshot"; import { TempDir } from "@oh-my-pi/pi-utils"; @@ -70,7 +70,7 @@ describe("PythonKernel.start (local gateway)", () => { }); globalThis.fetch = fetchSpy as unknown as typeof fetch; - const shellSpy = vi.spyOn(shell, "getShellConfig").mockResolvedValue({ + const shellSpy = vi.spyOn(SettingsManager, "getGlobalShellConfig").mockResolvedValue({ shell: "/bin/bash", args: ["-lc"], env: {