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
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed `omp install` failing extension validation for pi extensions that import the `is<Tool>ToolResult` 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 `is<Tool>ToolResult` 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
|
||||
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user