feat: setup command + workspace build scripts (#216) #219

Merged
xiaomo merged 2 commits from feat/216-setup-and-build-scripts into main 2026-05-12 12:24:44 +00:00
Owner

What

Two improvements to the workspace init + onboarding flow:

  1. Workspace build scriptsinit workspace now generates scripts/bundle.ts + scripts.bundle in package.json. bun run bundle scans workflows/*-entry.ts, produces dist/*.esm.js + dist/*.d.ts via Bun.build().

  2. Setup command — new uncaged-workflow setup configures workflow.yaml providers and models.

    • CLI mode: --provider --base-url --api-key --default-model [--init-workspace]
    • Interactive mode: prompts for each value
    • Idempotent: updates without losing existing workflows

Why

init workspace produced scaffolding that couldn't build bundles. No setup command existed for configuring workflow.yaml, making it impossible for new users or agents to run workflows.

Changes

  • packages/cli-workflow/src/commands/init/workspace.ts — add bundle script generation
  • packages/cli-workflow/src/commands/setup/ — new setup command (types, setup, dispatch, index)
  • packages/cli-workflow/src/cli-dispatch.ts — wire setup command
  • packages/cli-workflow/src/cli-registry.ts — register setup in command groups
  • packages/cli-workflow/__tests__/setup-cli.test.ts — CLI mode + idempotency tests
  • packages/cli-workflow/__tests__/init-workspace.test.ts — verify bundle script generation
  • packages/cli-workflow/__tests__/help.test.ts — help output coverage

Ref

## What Two improvements to the workspace init + onboarding flow: 1. **Workspace build scripts** — `init workspace` now generates `scripts/bundle.ts` + `scripts.bundle` in package.json. `bun run bundle` scans `workflows/*-entry.ts`, produces `dist/*.esm.js` + `dist/*.d.ts` via `Bun.build()`. 2. **Setup command** — new `uncaged-workflow setup` configures `workflow.yaml` providers and models. - CLI mode: `--provider --base-url --api-key --default-model [--init-workspace]` - Interactive mode: prompts for each value - Idempotent: updates without losing existing workflows ## Why `init workspace` produced scaffolding that couldn't build bundles. No setup command existed for configuring `workflow.yaml`, making it impossible for new users or agents to run workflows. ## Changes - `packages/cli-workflow/src/commands/init/workspace.ts` — add bundle script generation - `packages/cli-workflow/src/commands/setup/` — new setup command (types, setup, dispatch, index) - `packages/cli-workflow/src/cli-dispatch.ts` — wire setup command - `packages/cli-workflow/src/cli-registry.ts` — register setup in command groups - `packages/cli-workflow/__tests__/setup-cli.test.ts` — CLI mode + idempotency tests - `packages/cli-workflow/__tests__/init-workspace.test.ts` — verify bundle script generation - `packages/cli-workflow/__tests__/help.test.ts` — help output coverage ## Ref - RFC: #216 - Phase 1 testing: #217 - Phase 2 testing: #218
xiaomo was assigned by xingyue 2026-05-12 12:18:53 +00:00
xingyue added 2 commits 2026-05-12 12:18:53 +00:00
- Add scripts.bundle to generated package.json
- Generate scripts/bundle.ts that scans workflows/*-entry.ts,
  uses Bun.build() to produce dist/*.esm.js + dist/*.d.ts
- External: @uncaged/workflow-* packages (per bundle contract)
- Add tests for new scaffold files

Testing: #217
Ref: #216
New command: uncaged-workflow setup

CLI mode (agent-friendly):
  uncaged-workflow setup \
    --provider <name> --base-url <url> --api-key <key> \
    --default-model <provider/model> [--init-workspace <name>]

Interactive mode: prompts for each value when no flags given.

- Reads/writes workflow.yaml config section
- Idempotent: updates provider without losing workflows
- Sets maxDepth=3, supervisorInterval=3 on fresh config
- Optional --init-workspace creates workspace in cwd

Testing: #218
Ref: #216
xiaomo approved these changes 2026-05-12 12:24:39 +00:00
xiaomo left a comment
Owner

Review: feat: setup command + workspace build scripts (#216)

LGTM — clean implementation of both phases.

Strengths

  • Type safety: SetupCliArgs type is well-defined, Result used consistently, discriminated union pattern (ParsedSetup) is clean
  • Idempotent config merge: mergeWorkflowConfig correctly preserves existing maxDepth/supervisorInterval/workflows when updating — well tested
  • Flag parsing: requireNext validates missing values, finalizeParsedSetup gives clear errors, unknown args rejected
  • Error handling: every fallible operation returns Result, errors propagate cleanly to dispatchSetup which maps to exit codes
  • Test coverage: 3 focused tests covering fresh setup, idempotent update, and CLI dispatch integration
  • Provider/model validation: splitProviderModelRef cross-check ensures default-model provider prefix matches provider flag

Minor observations (non-blocking)

  1. bundleTs() as string array: generating a ~100-line TS file as string[].join is functional but harder to maintain than a template literal. Acceptable for scaffolding users will own.
  2. Interactive mode readline: collectInteractiveSetup does not mask API key input. Low priority for dev CLI, worth noting.
  3. biome.json excludes scripts/bundle.ts: makes sense but a code comment explaining why would help future readers.
  4. Redundant null checks in finalizeParsedSetup: the secondary null check after missing.length is unreachable but serves as TypeScript narrowing — fine.

All tests pass (102, known flaky #209). Architecture is clean, changes well-scoped to RFC.

## Review: feat: setup command + workspace build scripts (#216) **LGTM — clean implementation of both phases.** ### Strengths - **Type safety**: SetupCliArgs type is well-defined, Result used consistently, discriminated union pattern (ParsedSetup) is clean - **Idempotent config merge**: mergeWorkflowConfig correctly preserves existing maxDepth/supervisorInterval/workflows when updating — well tested - **Flag parsing**: requireNext validates missing values, finalizeParsedSetup gives clear errors, unknown args rejected - **Error handling**: every fallible operation returns Result, errors propagate cleanly to dispatchSetup which maps to exit codes - **Test coverage**: 3 focused tests covering fresh setup, idempotent update, and CLI dispatch integration - **Provider/model validation**: splitProviderModelRef cross-check ensures default-model provider prefix matches provider flag ### Minor observations (non-blocking) 1. bundleTs() as string array: generating a ~100-line TS file as string[].join is functional but harder to maintain than a template literal. Acceptable for scaffolding users will own. 2. Interactive mode readline: collectInteractiveSetup does not mask API key input. Low priority for dev CLI, worth noting. 3. biome.json excludes scripts/bundle.ts: makes sense but a code comment explaining why would help future readers. 4. Redundant null checks in finalizeParsedSetup: the secondary null check after missing.length is unreachable but serves as TypeScript narrowing — fine. All tests pass (102, known flaky #209). Architecture is clean, changes well-scoped to RFC.
xiaomo merged commit d02d410dcd into main 2026-05-12 12:24:44 +00:00
Sign in to join this conversation.
No Reviewers
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/workflow#219