Repository navigation
refactor: migrate app imports to @stash/core package boundary - #5
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR migrates the monorepo from deep relative imports (packages/core/src/...) to a clean @stash/core package boundary, introducing a CoreServices factory pattern for dependency injection and switching to per-package builds.
Changes:
- Introduces
@stash/coreas a proper workspace package with exports map, aCoreServicesabstraction (createCoreServicesfactory + typed service interfaces), and per-packagetsconfig.build.jsonfiles forcore,api, andcli. - Migrates all API route handlers and CLI command handlers to consume services via injected interfaces (e.g.,
Pick<ItemsService, "saveItem">) instead of directly importing feature functions, with the CLI dynamically loading the API web stack module. - Updates all references to the compiled CLI path from
dist/apps/cli/src/cli.jstoapps/cli/dist/cli.jsacross scripts, docs, and tests, and adds integration tests for both API and CLI response shape stability.
Reviewed changes
Copilot reviewed 35 out of 36 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
packages/core/package.json |
Rename to @stash/core, add exports map and build script |
packages/core/tsconfig.build.json |
New package-local build config |
packages/core/src/index.ts |
Add named re-exports for migrate/paths members and export new services module |
packages/core/src/services/contracts.ts |
New service interface definitions (CoreServices, ItemsService, etc.) |
packages/core/src/services/create-core-services.ts |
New factory binding context to feature functions |
packages/core/src/services/index.ts |
Barrel export for services |
packages/core/test/core-services.test.ts |
Unit test verifying delegation through the factory |
apps/api/package.json |
Add @stash/core dependency and build script |
apps/api/tsconfig.build.json |
New package-local build config |
apps/api/src/app/create-api-app.ts |
Wire createCoreServices and inject service slices into routes |
apps/api/src/app/server.ts |
Migrate imports to @stash/core |
apps/api/src/app/error-handler.ts |
Migrate import to @stash/core |
apps/api/src/features/*/routes.ts |
Each route file now accepts typed service options instead of ApiRouteOptions |
apps/api/src/features/*/dto.ts |
Migrate imports to @stash/core |
apps/api/src/features/inbox/dto.ts |
Migrate type imports to @stash/core |
apps/api/test/integration.test.ts |
New API integration test covering endpoint response contracts |
apps/cli/package.json |
Add @stash/core dependency and build script |
apps/cli/tsconfig.build.json |
New package-local build config |
apps/cli/src/cli.ts |
Migrate to @stash/core, use createCoreServices, add dynamic API module loading |
apps/cli/test/integration.test.ts |
Update CLI path, add item shape stability test |
apps/web/vite.config.ts |
Exclude react-router-dom from dep optimizer |
package.json |
Update build/start/db scripts for new CLI path and per-package builds |
pnpm-lock.yaml |
Add workspace dependency links |
docs/CLI_REFERENCE.md |
Update CLI path references |
AGENTS.md |
Update CLI path and add DI convention notes |
.agents/notes.md |
Update sandbox notes |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
packages/core/src/...paths to root-only@stash/corepackages/corepackage identity to@stash/corewith root export mappackages/core,apps/api,apps/cli) and update root build orchestrationdist/apps/cli/src/cli.jstoapps/cli/dist/cli.jsreact-router-domchunk warningKey Changes
packages/core/package.json,packages/core/tsconfig.build.jsonapps/api/package.json,apps/api/tsconfig.build.jsonapps/cli/package.json,apps/cli/tsconfig.build.jsonpackage.jsonbuild/start/db scripts@stash/coreacross API and CLI sourcespackages/core/src/index.tsfor app call sitesapps/cli/dist/cli.js)Validation
pnpm run buildpnpm testpnpm run test:integrationSTASH_DB_PATH=/tmp/stash-core-pkg/stash.db pnpm run db:doctor -- --jsonnode apps/cli/dist/cli.js --helpContract Checks
packages/core/src/...imports remain in app source@stash/core/...subpath imports in app source