From f178cee9a9d23410b23fb87ab96f302034dba2ad Mon Sep 17 00:00:00 2001 From: roboomp Date: Mon, 10 Aug 2026 13:27:52 +0000 Subject: [PATCH 1/2] fix(coding-agent): restore is*ToolResult guards on legacy pi shim Legacy pi's @earendil-works/pi-coding-agent root exported an isToolResult family of ToolResultEvent type guards. omp dropped them from the public API in 10.2.3 and the legacy shim's `export * from "../index"` never forwarded them, so extensions importing them (pi-lean-ctx@3.9.18 uses isEditToolResult/isWriteToolResult) failed Bun's static export check and aborted `omp install`. Restore isBashToolResult, isReadToolResult, isEditToolResult, isWriteToolResult, and isGrepToolResult on the shim to match the upstream pi surface. Fixes #8161 --- packages/coding-agent/CHANGELOG.md | 4 ++ .../legacy-pi-coding-agent-shim.ts | 46 ++++++++++++++++- .../legacy-pi-tool-result-guards.test.ts | 51 +++++++++++++++++++ 3 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 packages/coding-agent/test/extensibility/legacy-pi-tool-result-guards.test.ts diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md index a4d66e8d2..f9edfb69f 100644 --- a/packages/coding-agent/CHANGELOG.md +++ b/packages/coding-agent/CHANGELOG.md @@ -2,6 +2,10 @@ ## [Unreleased] +### Fixed + +- Fixed `omp install` failing extension validation for pi extensions that import the `isToolResult` event guards from `@earendil-works/pi-coding-agent` (e.g. `pi-lean-ctx@3.9.18`, which uses `isEditToolResult`/`isWriteToolResult`). The legacy shim's `export * from "../index"` never forwarded the guard family (dropped from the public API in 10.2.3), so a named import threw Bun's static "Export named 'isEditToolResult' not found" error. Restored `isBashToolResult`, `isReadToolResult`, `isEditToolResult`, `isWriteToolResult`, and `isGrepToolResult` on the shim to match the upstream pi surface ([#8161](https://github.com/can1357/oh-my-pi/issues/8161)). + ## [17.2.12] - 2026-08-08 ### Fixed diff --git a/packages/coding-agent/src/extensibility/legacy-pi-coding-agent-shim.ts b/packages/coding-agent/src/extensibility/legacy-pi-coding-agent-shim.ts index 30f483184..826aa50db 100644 --- a/packages/coding-agent/src/extensibility/legacy-pi-coding-agent-shim.ts +++ b/packages/coding-agent/src/extensibility/legacy-pi-coding-agent-shim.ts @@ -57,7 +57,16 @@ import { EventBus } from "../utils/event-bus"; import { convertImageToPng } from "../utils/image-loading"; import { discoverExtensionPaths, loadExtensionFromFactory, loadExtensions } from "./extensions"; import { ExtensionRuntime } from "./extensions/loader"; -import type { ExtensionFactory, ToolDefinition } from "./extensions/types"; +import type { + BashToolResultEvent, + EditToolResultEvent, + ExtensionFactory, + GrepToolResultEvent, + ReadToolResultEvent, + ToolDefinition, + ToolResultEvent, + WriteToolResultEvent, +} from "./extensions/types"; import { Type } from "./legacy-typebox"; import { getEnabledPlugins, resolvePluginExtensionPaths, type ScopedInstalledPlugin } from "./plugins/loader"; import type { Skill } from "./skills"; @@ -1458,3 +1467,38 @@ export * from "../index"; export { formatBytes as formatSize } from "../tools/render-utils"; export { copyToClipboard } from "../utils/clipboard"; export { Type } from "./legacy-typebox"; + +// Legacy pi's `@earendil-works/pi-coding-agent` root exported an `isToolResult` +// family of type guards that narrow a `tool_result` event (`ToolResultEvent`) by +// tool name. omp removed them from the public API in 10.2.3, and the barrel above +// does not forward them, so legacy extensions importing them (e.g. +// `pi-lean-ctx@3.9.18`, which uses `isEditToolResult`/`isWriteToolResult` to +// invalidate its read cache after a native edit/write) fail Bun's static export +// check during validation (issue #8161). Restore the guards for the tools omp +// still surfaces as tool-result events; upstream's `isFindToolResult`/`isLsToolResult` +// have no omp counterpart and are intentionally absent. + +/** Narrow a `tool_result` event to the `bash` tool. */ +export function isBashToolResult(e: ToolResultEvent): e is BashToolResultEvent { + return e.toolName === "bash"; +} + +/** Narrow a `tool_result` event to the `read` tool. */ +export function isReadToolResult(e: ToolResultEvent): e is ReadToolResultEvent { + return e.toolName === "read"; +} + +/** Narrow a `tool_result` event to the `edit` tool. */ +export function isEditToolResult(e: ToolResultEvent): e is EditToolResultEvent { + return e.toolName === "edit"; +} + +/** Narrow a `tool_result` event to the `write` tool. */ +export function isWriteToolResult(e: ToolResultEvent): e is WriteToolResultEvent { + return e.toolName === "write"; +} + +/** Narrow a `tool_result` event to the `grep` tool. */ +export function isGrepToolResult(e: ToolResultEvent): e is GrepToolResultEvent { + return e.toolName === "grep"; +} diff --git a/packages/coding-agent/test/extensibility/legacy-pi-tool-result-guards.test.ts b/packages/coding-agent/test/extensibility/legacy-pi-tool-result-guards.test.ts new file mode 100644 index 000000000..3689d04c7 --- /dev/null +++ b/packages/coding-agent/test/extensibility/legacy-pi-tool-result-guards.test.ts @@ -0,0 +1,51 @@ +import { describe, expect, it } from "bun:test"; +import { + isBashToolResult, + isEditToolResult, + isGrepToolResult, + isReadToolResult, + isWriteToolResult, + type ToolResultEvent, +} from "@oh-my-pi/pi-coding-agent/extensibility/legacy-pi-coding-agent-shim"; + +// Issue #8161: pi-lean-ctx@3.9.18 imports `isEditToolResult`/`isWriteToolResult` +// from `@earendil-works/pi-coding-agent`, which aliases to this shim. The shim's +// `export * from "../index"` never forwarded the `isToolResult` guard +// family (dropped from the public API in 10.2.3), so a named import threw Bun's +// static "Export named X not found" error and aborted `omp install`. + +function resultEvent(toolName: string): ToolResultEvent { + return { + type: "tool_result", + toolCallId: "call-1", + input: {}, + content: [], + isError: false, + toolName, + details: undefined, + }; +} + +describe("legacy shim tool-result guards", () => { + it("exports the guard family as callable functions", () => { + expect(typeof isBashToolResult).toBe("function"); + expect(typeof isReadToolResult).toBe("function"); + expect(typeof isEditToolResult).toBe("function"); + expect(typeof isWriteToolResult).toBe("function"); + expect(typeof isGrepToolResult).toBe("function"); + }); + + it("narrows a tool_result event by tool name", () => { + expect(isEditToolResult(resultEvent("edit"))).toBe(true); + expect(isEditToolResult(resultEvent("write"))).toBe(false); + + expect(isWriteToolResult(resultEvent("write"))).toBe(true); + expect(isWriteToolResult(resultEvent("edit"))).toBe(false); + + expect(isBashToolResult(resultEvent("bash"))).toBe(true); + expect(isReadToolResult(resultEvent("read"))).toBe(true); + expect(isGrepToolResult(resultEvent("grep"))).toBe(true); + + expect(isBashToolResult(resultEvent("read"))).toBe(false); + }); +}); From 1fa80a89ad0629a6b8191cab044ae96915875ce6 Mon Sep 17 00:00:00 2001 From: roboomp Date: Mon, 10 Aug 2026 13:35:17 +0000 Subject: [PATCH 2/2] fix(coding-agent): preserved legacy find and ls result guards Legacy find and ls tool definitions still emit tool-result events through omp's custom-event branch. Export their historical named guards so static legacy imports validate, while narrowing only toolName and retaining unknown details. Fixes #8161 --- packages/coding-agent/CHANGELOG.md | 2 +- .../legacy-pi-coding-agent-shim.ts | 22 ++++++++++++++++--- .../legacy-pi-tool-result-guards.test.ts | 8 +++++++ 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md index f9edfb69f..d8b362f51 100644 --- a/packages/coding-agent/CHANGELOG.md +++ b/packages/coding-agent/CHANGELOG.md @@ -4,7 +4,7 @@ ### Fixed -- Fixed `omp install` failing extension validation for pi extensions that import the `isToolResult` event guards from `@earendil-works/pi-coding-agent` (e.g. `pi-lean-ctx@3.9.18`, which uses `isEditToolResult`/`isWriteToolResult`). The legacy shim's `export * from "../index"` never forwarded the guard family (dropped from the public API in 10.2.3), so a named import threw Bun's static "Export named 'isEditToolResult' not found" error. Restored `isBashToolResult`, `isReadToolResult`, `isEditToolResult`, `isWriteToolResult`, and `isGrepToolResult` on the shim to match the upstream pi surface ([#8161](https://github.com/can1357/oh-my-pi/issues/8161)). +- Fixed `omp install` failing extension validation for pi extensions that import the `isToolResult` event guards from `@earendil-works/pi-coding-agent` (e.g. `pi-lean-ctx@3.9.18`, which uses `isEditToolResult`/`isWriteToolResult`). The legacy shim's `export * from "../index"` never forwarded the guard family (dropped from the public API in 10.2.3), so a named import threw Bun's static "Export named 'isEditToolResult' not found" error. Restored `isBashToolResult`, `isReadToolResult`, `isEditToolResult`, `isWriteToolResult`, `isGrepToolResult`, `isFindToolResult`, and `isLsToolResult` on the shim to match the upstream pi surface ([#8161](https://github.com/can1357/oh-my-pi/issues/8161)). ## [17.2.12] - 2026-08-08 diff --git a/packages/coding-agent/src/extensibility/legacy-pi-coding-agent-shim.ts b/packages/coding-agent/src/extensibility/legacy-pi-coding-agent-shim.ts index 826aa50db..3df2e2730 100644 --- a/packages/coding-agent/src/extensibility/legacy-pi-coding-agent-shim.ts +++ b/packages/coding-agent/src/extensibility/legacy-pi-coding-agent-shim.ts @@ -1474,9 +1474,9 @@ export { Type } from "./legacy-typebox"; // does not forward them, so legacy extensions importing them (e.g. // `pi-lean-ctx@3.9.18`, which uses `isEditToolResult`/`isWriteToolResult` to // invalidate its read cache after a native edit/write) fail Bun's static export -// check during validation (issue #8161). Restore the guards for the tools omp -// still surfaces as tool-result events; upstream's `isFindToolResult`/`isLsToolResult` -// have no omp counterpart and are intentionally absent. +// check during validation (issue #8161). Restore the full guard family; legacy +// `find`/`ls` tool results arrive through omp's custom-event branch, so those +// guards narrow the tool name while leaving their details unknown. /** Narrow a `tool_result` event to the `bash` tool. */ export function isBashToolResult(e: ToolResultEvent): e is BashToolResultEvent { @@ -1502,3 +1502,19 @@ export function isWriteToolResult(e: ToolResultEvent): e is WriteToolResultEvent export function isGrepToolResult(e: ToolResultEvent): e is GrepToolResultEvent { return e.toolName === "grep"; } + +/** Legacy `find` result event represented by omp's custom-event branch. */ +export type FindToolResultEvent = ToolResultEvent & { toolName: "find" }; + +/** Narrow a `tool_result` event to the legacy `find` tool. */ +export function isFindToolResult(e: ToolResultEvent): e is FindToolResultEvent { + return e.toolName === "find"; +} + +/** Legacy `ls` result event represented by omp's custom-event branch. */ +export type LsToolResultEvent = ToolResultEvent & { toolName: "ls" }; + +/** Narrow a `tool_result` event to the legacy `ls` tool. */ +export function isLsToolResult(e: ToolResultEvent): e is LsToolResultEvent { + return e.toolName === "ls"; +} diff --git a/packages/coding-agent/test/extensibility/legacy-pi-tool-result-guards.test.ts b/packages/coding-agent/test/extensibility/legacy-pi-tool-result-guards.test.ts index 3689d04c7..b24346fae 100644 --- a/packages/coding-agent/test/extensibility/legacy-pi-tool-result-guards.test.ts +++ b/packages/coding-agent/test/extensibility/legacy-pi-tool-result-guards.test.ts @@ -2,7 +2,9 @@ import { describe, expect, it } from "bun:test"; import { isBashToolResult, isEditToolResult, + isFindToolResult, isGrepToolResult, + isLsToolResult, isReadToolResult, isWriteToolResult, type ToolResultEvent, @@ -33,6 +35,8 @@ describe("legacy shim tool-result guards", () => { expect(typeof isEditToolResult).toBe("function"); expect(typeof isWriteToolResult).toBe("function"); expect(typeof isGrepToolResult).toBe("function"); + expect(typeof isFindToolResult).toBe("function"); + expect(typeof isLsToolResult).toBe("function"); }); it("narrows a tool_result event by tool name", () => { @@ -45,6 +49,10 @@ describe("legacy shim tool-result guards", () => { expect(isBashToolResult(resultEvent("bash"))).toBe(true); expect(isReadToolResult(resultEvent("read"))).toBe(true); expect(isGrepToolResult(resultEvent("grep"))).toBe(true); + expect(isFindToolResult(resultEvent("find"))).toBe(true); + expect(isLsToolResult(resultEvent("ls"))).toBe(true); + expect(isFindToolResult(resultEvent("ls"))).toBe(false); + expect(isLsToolResult(resultEvent("find"))).toBe(false); expect(isBashToolResult(resultEvent("read"))).toBe(false); });