refactor: package code organization wave 10 - #2328
Conversation
…ow-definitions Behavior-preserving package organization after wave 9 (#2274): - types/agents.ts: agent permissions, entity, ratings, reflections, heartbeat runs - app/api: missions, messaging, plugins-and-skills, todo, insights, system-panel - rename remaining-ops-8 → task-store/workflow-definitions.ts Ratchet types.ts and legacy.ts line-count ceilings downward.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe change extracts agent contracts and dashboard API domains into dedicated modules, preserves legacy exports through re-exports, rewires workflow-definition imports, adds typed clients for missions, insights, messaging, plugins, system operations, and todos, and updates supporting declarations and line-count baselines. ChangesCore contract and workflow organization
Dashboard API extraction
Supporting updates
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryWave 10 of the package code organization refactor: splits
Confidence Score: 5/5Safe to merge — this is a pure structural refactor with no logic changes, no new behavior, and complete re-export shims preserving all public paths. Every moved function and type has a matching re-export in the originating file; value bindings and type-only bindings are correctly separated with No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
subgraph consumers["Consumers"]
DASH["Dashboard components"]
ENGINE["@fusion/engine"]
end
subgraph legacy["Shim Layer (legacy.ts)"]
LEGTS["legacy.ts\n(re-exports only)"]
end
subgraph newapi["New Dashboard API Modules"]
MISSIONS["missions.ts"]
MESSAGING["messaging.ts"]
PLUGINS["plugins-and-skills.ts"]
TODO["todo.ts"]
INSIGHTS["insights.ts"]
SYSPANEL["system-panel.ts"]
end
subgraph core["@fusion/core"]
TYPES["types.ts\n(re-exports)"]
AGENTST["types/agents.ts\n(permissions, Agent, ratings,\nreflections, heartbeat)"]
WFD["task-store/workflow-definitions.ts\n(renamed from remaining-ops-8)"]
STORE["store.ts"]
ROP1["remaining-ops-1.ts"]
ROP2["remaining-ops-2.ts"]
ROP5["remaining-ops-5.ts"]
end
DASH --> LEGTS
LEGTS --> MISSIONS
LEGTS --> MESSAGING
LEGTS --> PLUGINS
LEGTS --> TODO
LEGTS --> INSIGHTS
LEGTS --> SYSPANEL
MISSIONS --> AGENTST
MESSAGING --> AGENTST
TYPES --> AGENTST
STORE --> WFD
ROP1 --> WFD
ROP2 --> WFD
ROP5 --> WFD
ENGINE --> TYPES
TYPES -.->|"re-exports all\n(stable public API)"| AGENTST
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
subgraph consumers["Consumers"]
DASH["Dashboard components"]
ENGINE["@fusion/engine"]
end
subgraph legacy["Shim Layer (legacy.ts)"]
LEGTS["legacy.ts\n(re-exports only)"]
end
subgraph newapi["New Dashboard API Modules"]
MISSIONS["missions.ts"]
MESSAGING["messaging.ts"]
PLUGINS["plugins-and-skills.ts"]
TODO["todo.ts"]
INSIGHTS["insights.ts"]
SYSPANEL["system-panel.ts"]
end
subgraph core["@fusion/core"]
TYPES["types.ts\n(re-exports)"]
AGENTST["types/agents.ts\n(permissions, Agent, ratings,\nreflections, heartbeat)"]
WFD["task-store/workflow-definitions.ts\n(renamed from remaining-ops-8)"]
STORE["store.ts"]
ROP1["remaining-ops-1.ts"]
ROP2["remaining-ops-2.ts"]
ROP5["remaining-ops-5.ts"]
end
DASH --> LEGTS
LEGTS --> MISSIONS
LEGTS --> MESSAGING
LEGTS --> PLUGINS
LEGTS --> TODO
LEGTS --> INSIGHTS
LEGTS --> SYSPANEL
MISSIONS --> AGENTST
MESSAGING --> AGENTST
TYPES --> AGENTST
STORE --> WFD
ROP1 --> WFD
ROP2 --> WFD
ROP5 --> WFD
ENGINE --> TYPES
TYPES -.->|"re-exports all\n(stable public API)"| AGENTST
Reviews (5): Last reviewed commit: "fix: drop html2canvas Options index sign..." | Re-trigger Greptile |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/dashboard/app/api/legacy.ts`:
- Around line 6844-6873: Import MissionWithHierarchy as a local type binding at
the top level of legacy.ts, while retaining its existing re-export in the export
type block. Update createMissionFromInterview to resolve its return type through
that local import.
In `@packages/dashboard/app/api/messaging.ts`:
- Around line 5-14: Add ParticipantType, MessageType, and MessageMetadata to the
existing type import from `@fusion/core` in messaging.ts, alongside the other
message-related contracts, so the module’s existing usages typecheck.
In `@packages/dashboard/app/api/plugins-and-skills.ts`:
- Around line 190-194: Import the dedupe helper from "./dedupe.js" in the module
containing fetchPluginUiSlots, so its existing dedupe(path, ...) call resolves
correctly without changing the function’s behavior.
In `@packages/dashboard/app/api/todo.ts`:
- Around line 21-60: Import TodoListCreateInput, TodoListUpdateInput,
TodoItemCreateInput, and TodoItemUpdateInput from `@fusion/core` in the todo API
module so the request payload annotations used by createTodoList,
updateTodoList, createTodoItem, and updateTodoItem resolve correctly.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: babb012d-4e94-4fb8-9ef0-ea3e24f5dc73
📒 Files selected for processing (15)
packages/core/src/store.tspackages/core/src/task-store/remaining-ops-1.tspackages/core/src/task-store/remaining-ops-2.tspackages/core/src/task-store/remaining-ops-5.tspackages/core/src/task-store/workflow-definitions.tspackages/core/src/types.tspackages/core/src/types/agents.tspackages/dashboard/app/api/insights.tspackages/dashboard/app/api/legacy.tspackages/dashboard/app/api/messaging.tspackages/dashboard/app/api/missions.tspackages/dashboard/app/api/plugins-and-skills.tspackages/dashboard/app/api/system-panel.tspackages/dashboard/app/api/todo.tsscripts/line-count-baseline.json
- Import MissionWithHierarchy locally for createMissionFromInterview - Import message contract types in messaging.ts - Import dedupe for fetchPluginUiSlots - Import todo create/update input types in todo.ts
export type re-exports from missions.ts do not create local bindings; milestone/slice interview apply/skip handlers need the imports for typecheck.
Dashboard app typecheck failed with TS2307 on html2canvas under bundler resolution on CI. Ship an ambient module under app/types so capture-screenshot typechecks without relying on package typings resolution.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/dashboard/app/types/html2canvas.d.ts`:
- Around line 9-16: Remove the `[key: string]: unknown` index signature from the
`Options` type in the html2canvas declarations, leaving only the explicitly
supported option properties so typos and unsupported configuration keys are
rejected while optional fields remain supported.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 6f10cbf7-bb01-43ab-a70f-85d4f7f7cd56
📒 Files selected for processing (2)
packages/dashboard/app/api/legacy.tspackages/dashboard/app/types/html2canvas.d.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/dashboard/app/api/legacy.ts
|
Automated fix: removed Options index signature from html2canvas ambient types per CodeRabbit. |
## Summary Wave 11 of package code organization (continues #2328 / wave 10), after syncing main into the wave10 stack. ### Peels | New module | Parent | |---|---| | `app/api/event-source.ts` | resilient `EventSource` reconnect + pagehide cleanup | | `app/api/chat.ts` | chat sessions / rooms / streaming | | `app/api/projects.ts` | multi-project management client | | `app/api/agents.ts` | agent CRUD / soul / memory | | `app/api/workflows.ts` | workflow definition client | | `app/api/scheduling.ts` | automations + routines | | `app/api/ai-text.ts` | text refine / import translate / subtasks | | `app/api/ai-sessions.ts` | AI / planning session client + `startKeepAlive` | | `app/api/research.ts` | research + evals client | | `task-store/branch-and-pr-entities.ts` | rename of `remaining-ops-6` | Public paths stay stable via `legacy.ts` re-exports (`app/api.ts` → `legacy`). ### LOC - `legacy.ts` ~8921 → ~5670 ### Shims - `legacy.ts` → peels above (delete-when: dashboard imports domain modules) - `remaining-ops-6` → `branch-and-pr-entities` (rename complete) ## Test plan - [x] eslint on peeled API modules + legacy - [x] dashboard app typecheck (`app/api/*` clean) - [x] core typecheck - [x] `plugin-setup-api` tests - [ ] CI merge gate <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Expanded dashboard APIs for agents, AI sessions, chat rooms/sessions, research runs, projects, workflows, routines/automations, and scheduling. * Added AI text refinement/translation, planning title regeneration, and streamed subtask breakdown with task creation. * Introduced resilient server-sent-events streaming for chat and other live updates. * Added workflow export/import and workflow design support, plus scripts and workflow configuration controls. * Added research export and ability to attach research outputs to tasks. * **Enhancements** * Missions support clearing an auto-merge override back to project defaults. * Subtasks can now include an optional priority when creating tasks. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Summary
Wave 10 of package code organization (plan:
docs/plans/2026-07-14-001-refactor-package-code-organization-plan.md), after #2274.Peels
types/agents.tstypes.ts(permissions, Agent entity, ratings, reflections, heartbeat run types)app/api/missions.tslegacy.ts(hierarchy, assertions, validation, autopilot)app/api/messaging.tslegacy.ts(mailbox, approvals, reflections/ratings, budget)app/api/plugins-and-skills.tslegacy.tsapp/api/todo.tslegacy.tsapp/api/insights.tslegacy.tsapp/api/system-panel.tslegacy.tstask-store/workflow-definitions.tsremaining-ops-8Mission interview SSE streams stay in
legacy.tsuntilcreateResilientEventSourceis shared.Public paths stay stable via re-exports.
LOC
types.ts~7101 → ~6165legacy.ts~10273 → ~8913Shims
types.ts→types/agents.ts(delete-when: consumers import agents domain directly)legacy.ts→ peels above (delete-when: dashboard imports domain modules)remaining-ops-8→workflow-definitions(rename complete)Test plan
@fusion/coretypecheckpnpm check:line-countagent-permissions+agent-permission-policytestsplugin-setup-apitestsSummary by CodeRabbit