Skip to content

fix(omp): resolve Bun redeclaration syntax error and add omp key - #594

Open
saeidakbari wants to merge 1 commit into
DietrichGebert:mainfrom
saeidakbari:fix/omp-install-bun-syntax-error
Open

fix(omp): resolve Bun redeclaration syntax error and add omp key#594
saeidakbari wants to merge 1 commit into
DietrichGebert:mainfrom
saeidakbari:fix/omp-install-bun-syntax-error

Conversation

@saeidakbari

Copy link
Copy Markdown

This PR fixes a syntax error when installing the ponytail extension under omp (Oh My Pi).

Problem

In the omp environment (which runs on Bun), require is pre-defined globally. Defining const require = createRequire(import.meta.url) in ESM files throws a SyntaxError: Cannot declare a const variable twice: 'require'. This triggers an installation rollback during validation.

Fix

  1. Renamed the local require variables to cjsRequire across all ESM files to avoid redeclaration syntax conflicts in Bun.
  2. Added the native/preferred "omp" manifest key alongside "pi" in package.json for proper native package resolution in Oh My Pi.

@TobiasFandrich

Copy link
Copy Markdown

Tested this against Oh My Pi (omp) 16.5.0 today (2026-07-14) and wanted to confirm this fix covers a second, related failure mode — not just the const require redeclaration syntax error described above.

Repro on unpatched main (14a0d79548d4de8fc2de95c1b94bb0de63a739d3), isolated $HOME:

$ omp plugin install github:DietrichGebert/ponytail
✘ Failed to install github:DietrichGebert/ponytail: Error: Plugin @dietrichgebert/ponytail extension validation failed:
.../node_modules/@dietrichgebert/ponytail/pi-extension/index.js: require() async module ".../node_modules/@dietrichgebert/ponytail/hooks/ponytail-config.js" is unsupported. use "await import()" instead.

Install rolls back cleanly (no half-installed state), but the extension never loads — omp plugin list shows nothing installed.

Tested this PR's branch directly (saeidakbari/ponytail#fix/omp-install-bun-syntax-error, 0cb52528a6764b0372d97bd78768386ad0a94e9b), same isolated $HOME:

$ omp plugin install "github:saeidakbari/ponytail#fix/omp-install-bun-syntax-error"
✔ Installed @dietrichgebert/ponytail@4.8.4

$ omp plugin doctor
✔ plugins_directory: Found
✔ package_manifest: Found
✔ node_modules: Found
✔ plugin:@dietrichgebert/ponytail: v4.8.4 - Lazy senior dev mode for AI agents...
Summary: 4 ok, 0 warnings, 0 errors

Installs and loads cleanly — the requirecjsRequire rename here also resolves the "async module unsupported" error, even though that error message is different from the syntax error in the PR description. Looks like the same underlying Bun require-in-ESM conflict just surfaces differently depending on omp's validation path. No new PR needed on my end — this one already covers both variants. Would be good to merge; happy to re-verify against main post-merge if useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants