refactor(registry): extract shared @pleaseai/registry-schema package#19
Conversation
Deploying ask-registry with
|
| Latest commit: |
aa43fee
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://3b13236e.ask-registry.pages.dev |
| Branch Preview URL: | https://14-track-extract-shared-regi.ask-registry.pages.dev |
There was a problem hiding this comment.
No issues found across 18 files
Requires human review: This is a significant architectural refactor that extracts shared logic into a new workspace package and modifies core schemas across multiple applications, requiring human review.
Architecture diagram
sequenceDiagram
participant CLI as CLI (@pleaseai/ask)
participant API as Registry API (Nitro)
participant Schema as NEW: Shared Registry Schema
participant Content as Nuxt Content Store
Note over CLI,Schema: CLI Execution Flow
CLI->>CLI: Initialize registry lookup
CLI->>Schema: NEW: expandStrategies(repo, docsPath)
alt Strategies explicitly provided
Schema-->>CLI: Return original strategies
else Only repo/docsPath provided
Schema->>Schema: Generate default GitHub strategy
Schema-->>CLI: Return inferred strategies
end
Note over API,Content: Registry Server Request Flow
API->>Content: Query registry collection
Content->>Schema: NEW: Validate entry using registryEntrySchema
Schema-->>Content: Validated Data (Typescript inferred)
Content-->>API: Entry Record
API->>Schema: NEW: expandStrategies(matchedEntry)
alt Empty strategies list
Schema->>Schema: Generate strategies from repo metadata
end
Schema-->>API: Concrete RegistryStrategy[]
API-->>API: CHANGED: Map aliases using RegistryAlias type
API-->>API: Return JSON response
There was a problem hiding this comment.
0 issues found across 3 files (changes from recent commits).
Requires human review: This is a significant refactor extracting core schemas and logic into a new shared package across workspaces, which requires human verification to ensure integration integrity.
Create packages/registry-schema with package.json, tsconfig.json, and eslint config for the shared registry schema package.
…egies Single source of truth for RegistryStrategy, RegistryAlias, and RegistryEntry using Zod schemas with z.infer<> derived types.
…hema - CLI: remove local interfaces, re-export types from shared package, delete registry-schema.ts - Registry: replace local Zod schemas in content.config.ts with shared registryEntrySchema - Registry API: replace duplicated expandStrategies() and local interfaces with imports from shared package
- Move zod from dependencies to peerDependencies to avoid dual Zod instance with @nuxt/content - Add aliasSchema validation tests (parse + reject) - Add fully-populated registryEntrySchema parse test
0fb4380 to
c0b5f2a
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
The CLI now depends on @pleaseai/registry-schema which needs to be built before tests can resolve the module.
There was a problem hiding this comment.
0 issues found across 1 file (changes from recent commits).
Requires human review: This is a cross-package refactor that creates a new workspace dependency and modifies core logic/schemas in both the CLI and Registry app. Refactors require human validation.
Summary
expandStrategies()intopackages/registry-schema(@pleaseai/registry-schema)Closes #14
Test plan
bun run buildsucceeds at monorepo root (all 3 packages)bun run --cwd packages/registry-schema test— 11 tests passbun run --cwd packages/cli test— 146 tests pass unchangedbun run lintpasses for registry-schema and CLI packagesgrep -r "interface RegistryStrategy" packages/cli/src/returns no matchesgrep "expandStrategies" apps/registry/server/api/registry/shows import from shared packageSummary by cubic
Extracted shared registry schemas, types, and
expandStrategies()into@pleaseai/registry-schema, updated the CLI and registry app to use it, and updated CI to build the package before CLI tests. Implements #14 to remove duplication and fix Nitro’s workspace import limitation by shipping a built package.Refactors
packages/registry-schemawith Zod schemas (strategy,alias,registryEntry), inferred types, andexpandStrategies()(+ unit tests).registryEntrySchemaincontent.config.tsandexpandStrategies/types in the API; removed local schemas and duplicated function.expandStrategiesfrom@pleaseai/registry-schema; removed local interfaces andregistry-schema.ts; updated test import path.Dependencies
@pleaseai/registry-schematopackages/cliandapps/registry.zodto peerDependencies in@pleaseai/registry-schemato avoid dual Zod instances with@nuxt/content.packages/registry-schemabefore running CLI tests to resolve the new dependency.Written for commit aa43fee. Summary will update on new commits.
Verification Checklist
Automated Tests
expandStrategies()unit tests pass in shared packagebun test --cwd packages/cli)Observable Outcomes
bun run buildat root succeeds with no errorsbun run lintat root succeeds with no errorsgrep -r "expandStrategies" apps/registry/server/shows import from@pleaseai/registry-schemagrep -r "interface RegistryStrategy" packages/cli/src/returns no matchesAcceptance Criteria
packages/registry-schemaexists with schemas, types, andexpandStrategies()@pleaseai/registry-schema@pleaseai/registry-schemabun run buildsucceedsbun run lintpasses