fix: bundle build & register workflow (#206) #208

Closed
xiaoju wants to merge 1 commits from fix/206-bundle-build-register into main
Owner

What

Fix the bundle build & register pipeline so scripts/build-bundles.sh works end-to-end.

Why

Bundle entry files couldn't resolve @uncaged/* workspace imports during bun build, and requireEnv at top level crashed workers when env vars were missing (#206).

Changes

  • scripts/build-bundles.sh — new build script with correct externals + optional --register flag
  • packages/workflow-template-develop/bundle-entry.ts — lazy agent creation via createLazyAgent() factory; requireEnv deferred to first invocation
  • packages/workflow-template-develop/package.json — add @uncaged/workflow-agent-cursor dependency
  • packages/workflow-template-solve-issue/package.json — add @uncaged/workflow-agent-hermes + @uncaged/workflow-execute dependencies
  • packages/workflow-register/ensure-uncaged-workflow-symlink.ts — add workflow-util, workflow-execute, workflow-register symlinks
  • .gitignore files — ignore bun workspace symlink artifacts in 6 packages
  • package.json — add build:bundles script

Tests

191/191 pass. bun run build:bundles produces valid bundles. Bundles register successfully without env vars set (lazy init).

Ref

Fixes #206

## What Fix the bundle build & register pipeline so `scripts/build-bundles.sh` works end-to-end. ## Why Bundle entry files couldn't resolve `@uncaged/*` workspace imports during `bun build`, and `requireEnv` at top level crashed workers when env vars were missing (#206). ## Changes - **`scripts/build-bundles.sh`** — new build script with correct externals + optional `--register` flag - **`packages/workflow-template-develop/bundle-entry.ts`** — lazy agent creation via `createLazyAgent()` factory; `requireEnv` deferred to first invocation - **`packages/workflow-template-develop/package.json`** — add `@uncaged/workflow-agent-cursor` dependency - **`packages/workflow-template-solve-issue/package.json`** — add `@uncaged/workflow-agent-hermes` + `@uncaged/workflow-execute` dependencies - **`packages/workflow-register/ensure-uncaged-workflow-symlink.ts`** — add workflow-util, workflow-execute, workflow-register symlinks - **`.gitignore` files** — ignore bun workspace symlink artifacts in 6 packages - **`package.json`** — add `build:bundles` script ## Tests 191/191 pass. `bun run build:bundles` produces valid bundles. Bundles register successfully without env vars set (lazy init). ## Ref Fixes #206
xiaoju added 1 commit 2026-05-12 02:59:05 +00:00
- Add missing agent deps to template package.json so bun workspace
  resolution works during `bun build` (workflow-agent-cursor for develop,
  workflow-agent-hermes + workflow-execute for solve-issue)
- Create scripts/build-bundles.sh that builds both template bundles into
  dist/*.esm.js with correct --external flags for runtime-symlinked packages
- Add build:bundles script to root package.json
- Extend ensureUncagedWorkflowSymlink to also symlink workflow-util,
  workflow-execute, and workflow-register (needed by externalized bundles)
- Defer agent creation in develop bundle-entry.ts via lazy init so
  requireEnv('WORKFLOW_LLM_API_KEY') only throws at first invocation,
  not at import() time (fixes workflowAsAgent crash)
- Document that env vars must be set before the first worker spawn
  (workers are persistent and don't inherit later env changes)

Fixes #206

Co-authored-by: Cursor <cursoragent@cursor.com>
xiaoju closed this pull request 2026-05-12 04:55:41 +00:00

Pull request closed

Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/workflow#208