refactor(workflow-utils): reorganize — roles top-level, shared internals in shared/ #227

Closed
opened 2026-04-28 08:41:02 +00:00 by xiaomo · 0 comments
Owner

What

Reorganize packages/workflow-utils/src/ to make the package's core purpose (role factories) immediately obvious.

Current structure (flat, mixed concerns)

src/
  context.ts
  cursor-agent.ts
  hermes-agent.ts
  hermes-options.ts      # 29 lines, only used by role-factories
  index.ts
  llm-chat.ts
  llm-extract.ts
  role-factories.ts      # 223 lines, 4 roles crammed together
  role-types.ts
  schema-defaults.ts
  spawn-safe.ts
  start-step.ts           # 6 lines, only used by role-factories

Target structure

src/
  index.ts               # barrel exports (public API unchanged)
  role-cursor.ts          # createCursorRole
  role-hermes.ts          # createHermesRole
  role-llm.ts             # createLlmRole
  role-react.ts           # createReActRole
  role-types.ts           # all role types + isDryRun (absorb start-step.ts)

  shared/
    spawn-safe.ts
    cursor-agent.ts
    hermes-agent.ts       # absorb hermes-options.ts
    llm-extract.ts
    llm-chat.ts
    schema-defaults.ts
    context.ts

Rules

  • Public API (index.ts exports) must not change
  • Absorb start-step.ts (6 lines) into role-types.ts
  • Absorb hermes-options.ts (29 lines) into hermes-agent.ts
  • Split role-factories.ts into 4 role-*.ts files
  • Deduplicate cursor merge helpers (mergeMode/mergeCursorModel/etc.)
  • All existing tests must pass unchanged
## What Reorganize `packages/workflow-utils/src/` to make the package's core purpose (role factories) immediately obvious. ## Current structure (flat, mixed concerns) ``` src/ context.ts cursor-agent.ts hermes-agent.ts hermes-options.ts # 29 lines, only used by role-factories index.ts llm-chat.ts llm-extract.ts role-factories.ts # 223 lines, 4 roles crammed together role-types.ts schema-defaults.ts spawn-safe.ts start-step.ts # 6 lines, only used by role-factories ``` ## Target structure ``` src/ index.ts # barrel exports (public API unchanged) role-cursor.ts # createCursorRole role-hermes.ts # createHermesRole role-llm.ts # createLlmRole role-react.ts # createReActRole role-types.ts # all role types + isDryRun (absorb start-step.ts) shared/ spawn-safe.ts cursor-agent.ts hermes-agent.ts # absorb hermes-options.ts llm-extract.ts llm-chat.ts schema-defaults.ts context.ts ``` ## Rules - Public API (`index.ts` exports) must not change - Absorb `start-step.ts` (6 lines) into `role-types.ts` - Absorb `hermes-options.ts` (29 lines) into `hermes-agent.ts` - Split `role-factories.ts` into 4 `role-*.ts` files - Deduplicate cursor merge helpers (`mergeMode`/`mergeCursorModel`/etc.) - All existing tests must pass unchanged
This repo is archived. You cannot comment on issues.
No Label
1 Participants
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/nerve#227