Skip to content

fix(packaging): ship dist/entry.js hub-daemon spawn target (#495) - #582

Open
bradrushworth wants to merge 1 commit into
cline:mainfrom
bradrushworth:fix/hub-daemon-entry-shim-495
Open

fix(packaging): ship dist/entry.js hub-daemon spawn target (#495)#582
bradrushworth wants to merge 1 commit into
cline:mainfrom
bradrushworth:fix/hub-daemon-entry-shim-495

Conversation

@bradrushworth

Copy link
Copy Markdown

Summary

The kanban CLI spawns the hub daemon from dist/entry.js, but the build only emits dist/cli.js and dist/index.js. On a fresh install, every spawn attempt crashes with:

Error: Cannot find module /usr/local/lib/node_modules/kanban/dist/entry.js

This crash-loops ~75 times on startup (see hub-daemon.log), hanging the CLI and freezing the frontend. The real daemon implementation already ships inside the embedded @clinebot/core SDK, whose exports map exposes it as the public subpath @clinebot/core/hub/daemon-entry./dist/hub/daemon/entry.js.

Fixes #495.

Root cause

scripts/build.mjs bundles two entry points (src/cli.tsdist/cli.js, src/index.tsdist/index.js) but there is no third entry point for the hub daemon spawn target. The daemon spawn code (inlined from @clinebot/core into dist/cli.js) resolves its own location relative to the package root and expects dist/entry.js to exist — but nothing builds it, so it's absent from the published tarball.

The fix

Add src/entry.ts as a thin re-export shim and a third esbuild.build() entry point in scripts/build.mjs so dist/entry.js is emitted and shipped in the tarball.

Two non-obvious traps that the shim handles

  1. ESM constraint: The kanban package declares "type": "module" (ESM). A CommonJS shim using require()/module.exports throws ReferenceError: require is not defined in ES module scope when Node loads it. The shim must use ESM import/export syntax.

  2. Exports-map gotcha: The deep path @clinebot/core/dist/hub/daemon/entry.js is blocked by the exports field in @clinebot/core/package.json. The shim uses the public exports-mapped subpath @clinebot/core/hub/daemon-entry as the primary import, with a import.meta.url-relative fallback to the nested file for environments that don't honor the exports map.

Changes

  • src/entry.ts (new): ESM re-export shim. Uses top-level await import("@clinebot/core/hub/daemon-entry") with a fallback that resolves node_modules/@clinebot/core/dist/hub/daemon/entry.js relative to import.meta.url (since __dirname is not defined in ESM). Exports default and re-exports all named exports.
  • scripts/build.mjs: Add a third esbuild.build() entry point (src/entry.tsdist/entry.js) to the existing Promise.all([...]), and update the completion log message.

Verification

This shim was validated against a live v0.1.70 install before porting to the build pipeline:

  • node dist/entry.js loads the core daemon module with no Cannot find module error.
  • hub-daemon.log goes to 0 bytes and stays clean — zero Cannot find module .../kanban/dist/entry.js entries.
  • The CLI no longer hangs on startup and the frontend loads.

Acceptance criteria

  • After npm run build, dist/entry.js exists.
  • npm pack --dry-run lists dist/entry.js in the tarball (files already includes dist).
  • A fresh npm install -g kanban starts the hub daemon cleanly with no manual patching.
  • hub-daemon.log contains zero Cannot find module .../kanban/dist/entry.js entries.

Out of scope

  • No changes to the minified cli.js spawn-target path (stays dist/entry.js).
  • No changes to @clinebot/core's exports map — @clinebot/core/hub/daemon-entry is the correct public entry.
  • This is a kanban package packaging fix only; no runtime/workspace code changes beyond the new shim.

The kanban CLI spawns the hub daemon from dist/entry.js, but the
published package only ships dist/cli.js and dist/index.js. On a fresh
install the spawn fails with:

  Error: Cannot find module '.../kanban/dist/entry.js'

This crash-loops the hub daemon (~75 repetitions in hub-daemon.log),
hangs the CLI on startup, and freezes the frontend before any task runs.

The daemon implementation already ships inside the embedded @clinebot/core
SDK, whose package.json exports map exposes it as the public subpath
"@clinebot/core/hub/daemon-entry". This commit adds a third esbuild
entry point (src/entry.ts -> dist/entry.js) that re-exports that entry,
so the file ships in the tarball and no post-install patching is needed.

The shim uses ESM import syntax (kanban package.json has "type":
"module"); CommonJS require() throws ReferenceError in this context.
The primary import uses the exports-mapped subpath because the deep
path @clinebot/core/dist/hub/daemon/entry.js is blocked by the exports
field. A __dirname-relative fallback covers environments that don't
honor the exports map.

Fixes cline#495
@greptile-apps

greptile-apps Bot commented Aug 6, 2026

Copy link
Copy Markdown

PR author is not in the allowed authors list.

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.

task start hangs ~30s with selectedAgentId=cline: published tarball is missing dist/entry.js, hub daemon spawn fails

1 participant