From 7f1da393df1d62e37c796ff49ce75e0511f200e9 Mon Sep 17 00:00:00 2001 From: roboomp Date: Sat, 25 Jul 2026 05:35:08 +0000 Subject: [PATCH] fix(coding-agent): re-export estimateTokens from legacy pi shim Legacy pi's @earendil-works/pi-coding-agent re-exported estimateTokens from its coding-agent package root. In omp it lives in @oh-my-pi/pi-agent-core/compaction and the coding-agent barrel does not forward it, so the shim's `export * from "../index"` left it off the surface. A named import tripped Bun's static export check during plugin validation (e.g. `omp plugin install pi-blackhole`). Re-export estimateTokens from the shim and pin it with a regression test. Fixes #6583 --- packages/coding-agent/CHANGELOG.md | 4 ++++ .../legacy-pi-coding-agent-shim.ts | 7 +++++++ .../legacy-pi-compaction-helpers.test.ts | 19 +++++++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 packages/coding-agent/test/extensibility/legacy-pi-compaction-helpers.test.ts diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md index 7c9fcf50c..38ab9b1af 100644 --- a/packages/coding-agent/CHANGELOG.md +++ b/packages/coding-agent/CHANGELOG.md @@ -2,6 +2,10 @@ ## [Unreleased] +### Fixed + +- Fixed legacy pi extensions failing extension validation when importing `estimateTokens` from `@earendil-works/pi-coding-agent` (aliased to the legacy shim). Legacy pi re-exported `estimateTokens` from its coding-agent package root; in omp it lives in `@oh-my-pi/pi-agent-core/compaction` and the coding-agent barrel does not forward it, so the shim's `export * from "../index"` left it off the surface and a named import threw Bun's static "Export named 'estimateTokens' not found" error (e.g. `omp plugin install pi-blackhole`). The shim now re-exports it ([#6583](https://github.com/can1357/oh-my-pi/issues/6583)). + ## [17.1.3] - 2026-07-24 ### 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 f9fa65396..b2a7be365 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 @@ -1366,6 +1366,13 @@ export function getPackageDir(): string { return getOmpPackageDir() ?? (isCompiledBinary() ? path.dirname(process.execPath) : process.cwd()); } +// Legacy pi's `@earendil-works/pi-coding-agent` re-exported `estimateTokens` +// from its package root (via `./core/compaction/index.ts`). In omp it lives in +// `@oh-my-pi/pi-agent-core/compaction`, and the coding-agent barrel below does +// not forward it, so legacy extensions importing it fail Bun's static export +// check during validation (issue #6583). +export { estimateTokens } from "@oh-my-pi/pi-agent-core/compaction"; + export * from "../index"; export { formatBytes as formatSize } from "../tools/render-utils"; export { copyToClipboard } from "../utils/clipboard"; diff --git a/packages/coding-agent/test/extensibility/legacy-pi-compaction-helpers.test.ts b/packages/coding-agent/test/extensibility/legacy-pi-compaction-helpers.test.ts new file mode 100644 index 000000000..20fcf66a2 --- /dev/null +++ b/packages/coding-agent/test/extensibility/legacy-pi-compaction-helpers.test.ts @@ -0,0 +1,19 @@ +import { describe, expect, it } from "bun:test"; +import { estimateTokens } from "@oh-my-pi/pi-coding-agent/extensibility/legacy-pi-coding-agent-shim"; + +// Issue #6583: pi extensions import `estimateTokens` from +// `@earendil-works/pi-coding-agent`, which aliases to this shim. Legacy pi +// re-exported it from the coding-agent package root (via +// `./core/compaction/index.ts`); in omp it lives in +// `@oh-my-pi/pi-agent-core/compaction` and the coding-agent barrel does not +// forward it, so `export * from "../index"` left the symbol off the shim +// surface and a named import threw Bun's static "Export named X not found" +// during plugin validation (e.g. `omp plugin install pi-blackhole`). This pins +// the re-export through the public package specifier. +describe("legacy shim compaction helpers", () => { + it("re-exports estimateTokens as a callable token estimator", () => { + expect(typeof estimateTokens).toBe("function"); + const tokens = estimateTokens({ role: "user", content: "hello world", timestamp: Date.now() }); + expect(tokens).toBeGreaterThan(0); + }); +});