Skip to content

fix(tui): stub missing @opentui/core .js siblings on install#89

Open
tim-hilde wants to merge 1 commit into
slkiser:mainfrom
tim-hilde:fix/opentui-core-types-js-shim
Open

fix(tui): stub missing @opentui/core .js siblings on install#89
tim-hilde wants to merge 1 commit into
slkiser:mainfrom
tim-hilde:fix/opentui-core-types-js-shim

Conversation

@tim-hilde
Copy link
Copy Markdown
Contributor

Summary

Adds a postinstall script that creates empty export {} runtime stubs for any .d.ts in @opentui/core that lacks a matching .js/.tsx sibling. Without these stubs, OpenCode's Bun-based TUI host fails to load dist/tui.tsx with ENOENT: ... @opentui/core/types.js, and the sidebar panel and compact status line silently never register.

@opentui/core@0.2.x publishes types.d.ts etc. but not the matching types.js. Bun walks import type chains during tsx transpile (through @opentui/core/index.d.tsexport * from "./types.js") and aborts. Runtime symbols are actually re-exported from the bundled index.js, so empty stubs unblock resolution without affecting behavior. Verified locally: sidebar and compact status now render against OpenCode 1.14.48.

Linked Issue

Fixes #87

OpenCode Validation

  • Current production released OpenCode version tested: 1.14.48
  • Why this version is relevant to the fix: This is where the report originates and where the ENOENT failure was reproduced and verified.

Repro log line before the fix:

ERROR service=tui.plugin path=@slkiser/opencode-quota@3.8.2
  target=file:///.../@slkiser/opencode-quota@3.8.2/node_modules/@slkiser/opencode-quota/dist/tui.tsx
  error: ENOENT: no such file or directory, open
  '.../node_modules/@opentui/core/types.js'

After the fix: TUI plugin loads, sidebar + compact status appear.

Changes

  • scripts/shim-opentui-core.mjs — finds @opentui/core directories under node_modules (walking up from INIT_CWD, the repo, and cwd) and writes empty stubs for every missing .js sibling. Idempotent; never fails install.
  • package.json — adds postinstall hook (runs on consumer install), chains the script into build, and includes scripts/shim-opentui-core.mjs in files so the npm tarball ships it.
  • package-lock.json — single field update (hasInstallScript: true) reflecting the new postinstall.
  • tests/opentui-core-shim.test.ts — regression test: every .d.ts in @opentui/core must have a runtime sibling.

Quality Checklist

  • I ran npm run typecheck
  • I ran npm test (106 files, 922 tests passed)
  • I ran npm run build
  • This is the smallest safe root-cause fix (no unnecessary hook/output mutation logic)
  • I preserved behavioral invariants and added a boundary test
  • I updated docs for user-facing workflow/command/config changes — not applicable; no user-facing surface changes
  • For new API-key/token providers, I started from contributing/provider-template/ or explained why the template does not apply — N/A, no provider change
  • For provider setup/auth wording changes — N/A

@opentui/core@0.2.x publishes *.d.ts files without matching *.js
siblings (e.g. types.d.ts but no types.js). When OpenCode's Bun-based
TUI host loads dist/tui.tsx, it walks the type-import graph through
@opentui/core/index.d.ts (which contains `export * from "./types.js"`
and similar) and aborts with ENOENT on the missing runtime files. The
TUI plugin silently fails to register, so the sidebar panel and
compact status line never appear.

Add a postinstall script that writes empty `export {}` runtime stubs
next to any `.d.ts` in @opentui/core that lacks a sibling `.js` or
`.tsx`. The bundled runtime symbols are re-exported from index.js, so
empty stubs are sufficient to unblock Bun's resolver.

Also wire the script into the build pipeline so local dev installs
benefit, and add a packaging test that fails if any .d.ts in
@opentui/core lacks a runtime sibling.

Fixes slkiser#87
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.

[bug]: TUI SideBar does not show

1 participant