Skip to content

fix(pkg): ship src/logger.ts and src/util for the raw-source ./tui entry#8

Open
iceteaSA wants to merge 1 commit into
cortexkit:mainfrom
iceteaSA:fix/tui-files-whitelist
Open

fix(pkg): ship src/logger.ts and src/util for the raw-source ./tui entry#8
iceteaSA wants to merge 1 commit into
cortexkit:mainfrom
iceteaSA:fix/tui-files-whitelist

Conversation

@iceteaSA

@iceteaSA iceteaSA commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Problem

In @cortexkit/opencode-openai-auth@0.1.4 the OpenAI provider half works (slash commands, OAuth, quota, RPC server), but the quota sidebar never renders.

Root cause is packaging, not logic. opencode loads the TUI plugin from raw source:

"exports": { "./tui": { "import": "./src/tui.tsx" } }

so every src/ file transitively imported by src/tui.tsx must be present in the published tarball. The files array enumerates individual src files but omits two that are reachable from tui.tsx:

  1. src/logger.tssrc/tui.tsx (import { createLogger } from './logger.js') and src/sidebar-state.ts.
  2. src/util/open-url.tssrc/tui/command-dialogs.tsx (import { openUrl } from '../util/open-url'); the whole src/util/ dir was absent.

At load the ./tui module throws ERR_MODULE_NOT_FOUND, so the TUI half dies silently — no sidebar slot, RPC poll never starts, stale RPC port files never cleaned. The server half is unaffected because it's consumed via the bundled dist/, where these modules are inlined (which is why the slash commands and quota state work while the sidebar doesn't).

Fix

Add the two missing paths to files:

     "src/tui-preferences.ts",
+    "src/logger.ts",
+    "src/util",
     "src/rpc",

exports is unchanged — the raw-source ./tui load is intentional and matches the sibling plugin.

Recurrence guard

New test src/tests/tui-packaging.test.ts makes this class of bug impossible to reintroduce silently. With no hardcoded list, it:

  1. reads exports["./tui"].import from package.json,
  2. BFS-walks the transitive relative-import graph from that entry (handling .js.ts/.tsx specifier rewrites, import/export … from, side-effect and dynamic imports, type-only imports),
  3. asserts every reachable src/ file is covered by a files entry (exact match or directory prefix).

Red-first proven: on the pre-fix files array it fails listing exactly src/logger.ts and src/util/open-url.ts; green after the fix.

Verification

  • Red-first: guard test fails on the old array with exactly the two files, passes after.
  • bun pm pack --dry-run now lists src/logger.ts and src/util/open-url.ts in the tarball.
  • bun run build clean · bun run types clean · bun test 394 pass / 0 fail · bunx biome check src 0 warnings.

Affects 0.1.4 (current latest). The Anthropic sibling is unaffected — its tui.tsx doesn't import ./logger or ../util/open-url.


View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.


Summary by cubic

Fixes the TUI sidebar not rendering by shipping the missing source files for the raw-source ./tui export. Restores the quota sidebar and ensures the TUI loads without module errors.

  • Bug Fixes
    • Added src/logger.ts and src/util to package.json:files so the ./tui entry resolves all transitive imports.
    • Added src/tests/tui-packaging.test.ts to walk imports from exports["./tui"].import and assert every reachable src/ file is covered by files.

Written for commit 5620e39. Summary will update on new commits.

Review in cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Re-trigger cubic

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.

1 participant