refactor(core): split types.ts into co-located types/ domain modules (#2024 PR 1)#2026
Conversation
Decompose the 2094-line types.ts god-file into per-domain modules under types/, organized along the existing section banners. types.ts becomes a barrel re-exporting all modules, so the public surface (index.ts re-export and the ./types subpath export) is unchanged. Pure move — no behavior or API change. Part of ComposioHQ#2024 (PR 1). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Restore and substantially extend the top-of-file documentation that the 2000-line god-file used to carry: the public-surface invariant (why this barrel must stay at this path), the 8 plugin slots + core services overview, a per-module map of what each types/ module owns, the type-vs-runtime-value note, and editing conventions. Comment-only — no API or behavior change. Part of ComposioHQ#2024 (PR 1). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Drive rollup's input map from package.json `exports` so each published "@aoagents/ao-core/<x>" entrypoint is an explicit entry point. Under preserveModules, rollup tree-shakes pure re-export barrels (no runtime side effects) — index's `export *` flattens to the underlying modules and the barrel's own chunk (e.g. dist/types.js) is never emitted, breaking the `./types` subpath export for bundlers/runtime even though tsc still emits the .d.ts. Entry points are never tree-shaken, so listing every export keeps barrel entrypoints emitted. Required for the types/ split (and the lifecycle-manager/session-manager/config barrels in later PRs). Part of ComposioHQ#2024 (PR 1). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Greptile SummaryThis PR decomposes the 2094-line
Confidence Score: 5/5Safe to merge — this is a pure relocation of type declarations with no API, runtime, or behavioral changes. Every moved declaration is byte-for-byte identical to the original; all cross-module references within No files require special attention. The
|
| Filename | Overview |
|---|---|
| packages/core/rollup.config.ts | Replaces two hardcoded input entries with exportEntryPoints(), which derives rollup inputs from package.json exports using import.meta.url-based path resolution; warns on exports lacking an import condition. |
| packages/core/src/types.ts | Converted from a 2094-line god-file to a documented barrel that re-exports 16 domain modules; no declarations remain here. |
| packages/core/src/types/session.ts | Session domain types extracted cleanly; cross-imports from runtime.js, agent.js, scm.js are all import type, avoiding runtime circular deps. |
| packages/core/src/types/agent.ts | Agent plugin interface and related types extracted correctly; all sibling imports use import type. |
| packages/core/src/types/config.ts | Configuration types extracted; correctly imports ObservabilityLevel from ../observability.js (parent src) rather than a sibling types module. |
| packages/core/src/types/errors.ts | Error classes and detection helpers extracted with no imports, making this a dependency-free leaf module. |
| packages/core/src/types/services.ts | Core non-pluggable service interfaces (SessionManager, LifecycleManager, PluginRegistry) and related option/result types extracted correctly with import type cross-references. |
| packages/web/server/tests/server-compatibility.test.ts | Updated the OrchestratorConfig source-text assertion to read from types/config.ts instead of the monolithic types.ts, correctly tracking the moved declaration. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["types.ts (barrel)"] --> B["types/session.ts"]
A --> C["types/runtime.ts"]
A --> D["types/agent.ts"]
A --> E["types/workspace.ts"]
A --> F["types/tracker.ts"]
A --> G["types/scm.ts"]
A --> H["types/notifier.ts"]
A --> I["types/terminal.ts"]
A --> J["types/events.ts"]
A --> K["types/reactions.ts"]
A --> L["types/config.ts"]
A --> M["types/plugin.ts"]
A --> N["types/metadata.ts"]
A --> O["types/services.ts"]
A --> P["types/errors.ts"]
A --> Q["types/portfolio.ts"]
B -. "import type" .-> C
B -. "import type" .-> D
B -. "import type" .-> G
D -. "import type" .-> B
D -. "import type" .-> C
D -. "import type" .-> L
D -. "import type" .-> M
L -. "import type (non-sibling)" .-> R["../observability.ts"]
R2["index.ts"] -->|"export * from './types.js'"| A
S["package.json exports"] -->|"./types -> dist/types.js"| A
T["rollup.config.ts"] -->|"exportEntryPoints()"| S
Reviews (3): Last reviewed commit: "refactor(core): warn on rollup export en..." | Re-trigger Greptile
There was a problem hiding this comment.
Pull request overview
Splits packages/core/src/types.ts into domain-focused modules under packages/core/src/types/ while keeping types.ts as the stable public barrel for @aoagents/ao-core/types. Updates the core Rollup build to emit a JS chunk for every published subpath export by deriving inputs from package.json#exports.
Changes:
- Moved the former
types.tsdeclarations into 16 co-locatedsrc/types/*.tsdomain modules and convertedsrc/types.tsinto a documented re-export barrel. - Updated
packages/core/rollup.config.tsto compute Rollupinputfrompackage.jsonexportsso barrels liketypes.tsalways producedist/*.js. - Kept the external type surface stable via re-exports (no signature changes intended).
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/core/src/types.ts | Replaced the god-file with a documented barrel re-exporting types/ domain modules. |
| packages/core/src/types/session.ts | Session lifecycle, activity, and session-related runtime constants/types. |
| packages/core/src/types/runtime.ts | Runtime plugin slot types (runtime handle, attach info, metrics, create config). |
| packages/core/src/types/agent.ts | Agent plugin slot types (launch config, session info, process probe helpers). |
| packages/core/src/types/workspace.ts | Workspace plugin slot types (create/destroy/list/restore contracts). |
| packages/core/src/types/tracker.ts | Tracker plugin slot types (issue CRUD + prompt/branch helpers). |
| packages/core/src/types/scm.ts | SCM plugin slot types (PR/CI/review/webhook/batch enrichment contracts). |
| packages/core/src/types/notifier.ts | Notifier plugin slot types (notifications + optional actions/posting). |
| packages/core/src/types/terminal.ts | Terminal plugin slot types (human session opening semantics). |
| packages/core/src/types/events.ts | Orchestrator event model (EventType/Priority + OrchestratorEvent). |
| packages/core/src/types/reactions.ts | Reaction engine config/result types. |
| packages/core/src/types/config.ts | Orchestrator + project configuration types and helpers. |
| packages/core/src/types/plugin.ts | Plugin system contracts (slot/manifest/module + preflight intent). |
| packages/core/src/types/metadata.ts | Persisted session metadata file schema. |
| packages/core/src/types/services.ts | Core service interfaces (SessionManager/LifecycleManager/PluginRegistry). |
| packages/core/src/types/errors.ts | Error helpers + exported error classes. |
| packages/core/src/types/portfolio.ts | Cross-project portfolio aggregation types. |
| packages/core/rollup.config.ts | Builds one Rollup entry point per package.json subpath export to ensure all dist/*.js targets are emitted. |
The server-compatibility test reads the raw source of the OrchestratorConfig interface to assert it has no `dataDir`. After the types.ts split that interface lives in types/config.ts, so the test must read the new path. Fixes the failing Test Web CI job. Part of ComposioHQ#2024 (PR 1). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Fix inaccurate per-module comments flagged in review: process-probe helpers/PROCESS_PROBE_INDETERMINATE are in agent.ts (not runtime.ts), normalizeAgentPermissionMode is in config.ts (not agent.ts), and the kill/claim/cleanup option & result types are in services.ts (metadata.ts holds only SessionMetadata). Part of ComposioHQ#2024 (PR 1). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Address review: the export-entrypoint reader used a CWD-relative
readFileSync("package.json"), which throws ENOENT if rollup is invoked
from a directory other than the package root. Pin the path to the config
file via fileURLToPath(new URL("./package.json", import.meta.url)) —
fileURLToPath (not URL.pathname) keeps it correct on Windows. Part of
ComposioHQ#2024 (PR 1).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Addressed the CI failure and review feedback:
Note: the test-path change touches |
|
All three items look good — thanks for the thorough follow-through. CI fix ( Rollup CWD fix ( Barrel annotation fix ( LGTM — happy to approve once CI passes. |
|
@greptile-apps can you approve PRs?? |
|
No, I can't approve PRs. I can submit reviews with |
…tion
Address review: exportEntryPoints() silently skipped any package.json
exports entry lacking an { import } field (e.g. a future string-form or
require-only export), which would drop its dist emit with no signal. Now
it warns with the entry name at build time. Part of ComposioHQ#2024 (PR 1).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Thanks for the thorough review. How each point was handled:
No changes to the type modules or public surface in this round — only the rollup warning. CI is green across Linux + Windows. |
Part of #2024 — PR 1 of the phased
packages/core/srcrestructure.What
Decompose the 2094-line
types.tsgod-file into 16 co-located domain modules undertypes/, organized along the file's existing section banners.types.tsbecomes a documented barrel that re-exports all of them.Surface-preserving by design
This is a pure relocation — no API or behavior change:
index.tsis untouched (stillexport * from "./types.js").@aoagents/ao-core/typessubpath export still resolves.Build fix (the one non-mechanical change)
rollup.config.tsnow derives itsinputfrompackage.jsonexportsinstead of two hardcoded entries.Why: the build uses
preserveModules, which tree-shakes a pure re-export barrel (no runtime side effects) —index.ts'sexport *flattens straight to the underlying modules, sodist/types.jswas never emitted.tscstill emitsdist/types.d.ts, so typecheck passes while bundler/runtime resolution of the subpath export fails (caught by a Next.js/webpack build, not by tsc). Making every published entrypoint an explicit input prevents this — entry points are never tree-shaken. This also pre-empts the same break for thelifecycle-manager/session-manager/configbarrels in later PRs.Verification
pnpm build(full graph incl. web/Next.js) — greenpnpm typecheck(all packages) — greenpnpm test(core) — 1323/1323 passdist/*.jstargets present on diskCommits
refactor(core): split types.ts → types/ modules + barreldocs(core): expand the barrel header into a full architecture mapfix(core): emit a dist chunk for every subpath export entrypoint