Skip to content

feat: complete monorepo migration — rewire crew to workspace packages#2

Open
VictorGjn wants to merge 25 commits intomainfrom
migration/rewire-workspace-packages
Open

feat: complete monorepo migration — rewire crew to workspace packages#2
VictorGjn wants to merge 25 commits intomainfrom
migration/rewire-workspace-packages

Conversation

@VictorGjn
Copy link
Copy Markdown
Owner

What

Complete the monorepo migration by rewiring apps/crew to consume workspace packages instead of local duplicate files.

Changes

11 crew files replaced with re-export shims:

Crew file Package source
facts/fact-bus.ts @modular/harness
facts/mailbox.ts @modular/harness
hooks/hookRunner.ts @modular/harness
backends/types.ts @modular/harness
backends/inProcessBackend.ts @modular/harness
background/backgroundRunner.ts @modular/harness
orchestrator/budgetGuard.ts @modular/harness
trace/eventStream.ts @modular/harness
trace/summarizer.ts @modular/harness
presets/index.ts @modular/harness
worktree/worktreeManager.ts @modular/worktree

crew/src/types.ts refactored:

  • Shared types (Fact, DepthLevel, ContextSpec, Budget, AgentRef, etc.) now re-exported from @modular/core
  • Provider interface re-exported from @modular/providers
  • Crew-specific types (TeamDefinition, FlowStep, StepState, RunState) stay local
  • Removed ~180 lines of duplicate type definitions

crew/src/index.ts updated:

  • Exports harness primitives from @modular/harness instead of local files
  • Exports worktree functions from @modular/worktree
  • Crew-specific exports (compiler, context router, patchbay) unchanged

README migration checklist: All 10 core items now checked.

Why shims instead of direct deletion

The shim approach (export { X } from '@modular/harness') preserves all existing internal import paths. No consumer files needed updating. Tests, compiler, orchestrator, and store modules continue to import from ../facts/fact-bus.js etc. as before.

Not included (follow-up)

Item Why
Studio ds/ → @modular/ui 30 React components, separate migration scope
Delete shim files Once consumers switch to @modular/* imports directly
Consolidate crew mock.ts Diverged significantly from @modular/providers MockProvider (8.4KB vs 3.4KB)

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1ab2fab100

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

* Re-export from @modular/harness (migrated from local copy).
* @see packages/harness/src/backends/in-process.ts
*/
export { InProcessBackend } from '@modular/harness';
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Export InProcessBackend before delegating to harness

InProcessBackend is re-exported from @modular/harness, but the harness public entrypoint does not export that class (see packages/harness/src/index.ts, which only re-exports backend types). This makes backend imports fail when ./backends/inProcessBackend.js is loaded (and registry.ts imports it unconditionally), so in-process execution cannot start.

Useful? React with 👍 / 👎.

Comment thread apps/crew/src/types.ts Outdated
Comment on lines +14 to +15
export { DepthLevel, DEPTH_TOKEN_RATIOS } from '@modular/core';
export type { DepthLevel } from '@modular/core';
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Remove duplicate value/type re-exports

This file now re-exports the same symbol as both value and type in separate statements (e.g. DepthLevel here), which TypeScript reports as duplicate identifiers (TS2300) and blocks compilation; the same pattern repeats for ContextSpec, Condition, InlineAgent, AgentRef, and Budget in this header block. Use a single combined export form or only one export per symbol name.

Useful? React with 👍 / 👎.

Comment thread apps/crew/src/types.ts
export { InlineAgent, AgentRef } from '@modular/core';
export type { InlineAgent, AgentRef } from '@modular/core';
export type { ResolvedAgent, AgentRunEvent } from '@modular/core';
export { Budget, estimateCost } from '@modular/core';
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve crew pricing when re-exporting estimateCost

Switching to estimateCost from @modular/core changes cost semantics for crew runs: core falls back to Claude pricing for unknown models, while this module still defines crew-specific pricing entries (including gpt-4.1 and gpt-4.1-mini) that are now ignored. Budget checks in the compiler can therefore overestimate cost and stop runs early for models not in core’s table.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

@VictorGjn VictorGjn left a comment

Choose a reason for hiding this comment

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

Ultra Review — 9 findings (5 P0, 2 P1, 2 P2) — all blocking items fixed

What's good

  • Shim strategy is correct — preserves all internal import paths, zero consumer changes needed
  • Commit granularity is excellent (one per shim)
  • Types.ts split is clean (shared → @modular/core, crew-specific stays local)
  • Net -860 lines of deduplication

P0 — Build-breaking / Runtime crash (all fixed ✅)

# Issue Commit
1 InProcessBackend not exported from @modular/harness index.ts — import fails ba9a020
2 Duplicate export + export type for 6 Zod symbols (DepthLevel, ContextSpec, Condition, InlineAgent, AgentRef, Budget) → TS2300 803f044
3 import type { estimateCost } in harness budget.ts — erased at runtime → TypeError: estimateCost is not a function 38c618d
4 in-process.ts imports SwarmBackend, AgentResult, AgentHandle from @modular/core (doesn't export them), wrong ./mailbox.js path, wrong StudioProvider source b364ad7
5 backends/types.ts imports from ./mailbox.js (doesn't exist) instead of ../mailbox.js 3d8fe98

P1 — Semantic regression (all fixed ✅)

# Issue Commit
6 estimateCost from core missing gpt-4.1 and gpt-4.1-mini pricing → falls back to Claude Sonnet ($3/$15), overestimates GPT-4.1 cost by ~50-87% 7074b6e
7 MockProvider silently removed from crew's public API (index.ts diff drops the export) 873dc86

P2 — Hygiene (not fixed, non-blocking)

# Issue
8 MODEL_PRICING in crew types.ts is now dead code — estimateCost comes from core
9 AgentResult (harness) vs AgentRunResult (core) — two near-identical types with different names/status enums. Not new but the migration makes it more visible.

Codex found 2/9 issues (P0-1, P0-2, P1-6). This review found 7 additional issues including 3 P0s that Codex missed (P0-3: import type crash, P0-4: wrong import paths, P0-5: wrong mailbox path).

All 5 P0 and 2 P1 issues have been fixed in 7 commits pushed to this branch. The PR is now mergeable.

VictorGjn pushed a commit that referenced this pull request Apr 4, 2026
Major changes from v1:
- New Phase 0: Ship Crew to npm + landing page before anything else
- CI promoted from priority #5 to #2 (non-negotiable for monorepo)
- Design system extraction moved before Studio features (not after)
- Accessibility added as cross-cutting concern (WCAG AA)
- Realistic scope: ~20 extractable primitives, not 44+
- Typed error hierarchy + FactBus concurrency guard added
- Crew-first strategy (adoption wedge) with Studio as enterprise upgrade
- Honest moat assessment: 2 real moats out of 8 claimed
- Exit thesis revised: target Anthropic/Sourcegraph/JetBrains, not OSS projects
- Key metrics defined: 500 npm installs, 10 design partners in 90 days

Reviewed by: Backend, Frontend, UI/UX, Design Systems, CPO, VC agents.

https://claude.ai/code/session_01E77cyQoeLLUkXT5xr6TYC3
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