Skip to content

refactor(registry): extract shared @pleaseai/registry-schema package#19

Merged
amondnet merged 11 commits into
mainfrom
14-track-extract-shared-registry-20260408
Apr 8, 2026
Merged

refactor(registry): extract shared @pleaseai/registry-schema package#19
amondnet merged 11 commits into
mainfrom
14-track-extract-shared-registry-20260408

Conversation

@amondnet

@amondnet amondnet commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Extract duplicated registry types, Zod schemas, and expandStrategies() into packages/registry-schema (@pleaseai/registry-schema)
  • CLI and registry app now import from the shared package instead of maintaining parallel definitions
  • Resolves the intentional Nitro duplication constraint with a proper built workspace package

Closes #14

Test plan

  • bun run build succeeds at monorepo root (all 3 packages)
  • bun run --cwd packages/registry-schema test — 11 tests pass
  • bun run --cwd packages/cli test — 146 tests pass unchanged
  • bun run lint passes for registry-schema and CLI packages
  • grep -r "interface RegistryStrategy" packages/cli/src/ returns no matches
  • grep "expandStrategies" apps/registry/server/api/registry/ shows import from shared package

Summary 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

    • Added packages/registry-schema with Zod schemas (strategy, alias, registryEntry), inferred types, and expandStrategies() (+ unit tests).
    • Registry app imports registryEntrySchema in content.config.ts and expandStrategies/types in the API; removed local schemas and duplicated function.
    • CLI imports and re-exports types and expandStrategies from @pleaseai/registry-schema; removed local interfaces and registry-schema.ts; updated test import path.
  • Dependencies

    • Added @pleaseai/registry-schema to packages/cli and apps/registry.
    • Moved zod to peerDependencies in @pleaseai/registry-schema to avoid dual Zod instances with @nuxt/content.
    • CI builds packages/registry-schema before 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 package
  • Existing CLI tests pass unchanged (bun test --cwd packages/cli)

Observable Outcomes

  • bun run build at root succeeds with no errors
  • bun run lint at root succeeds with no errors
  • grep -r "expandStrategies" apps/registry/server/ shows import from @pleaseai/registry-schema
  • grep -r "interface RegistryStrategy" packages/cli/src/ returns no matches

Acceptance Criteria

  • SC-1: packages/registry-schema exists with schemas, types, and expandStrategies()
  • SC-2: CLI imports types from @pleaseai/registry-schema
  • SC-3: Registry imports schemas/functions from @pleaseai/registry-schema
  • SC-4: All CLI tests pass
  • SC-5: Registry builds successfully
  • SC-6: bun run build succeeds
  • SC-7: bun run lint passes

@amondnet amondnet linked an issue Apr 8, 2026 that may be closed by this pull request
7 tasks
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Apr 8, 2026

Copy link
Copy Markdown

Deploying ask-registry with  Cloudflare Pages  Cloudflare Pages

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

View logs

@amondnet
amondnet marked this pull request as ready for review April 8, 2026 04:13

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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
Loading

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

amondnet added 9 commits April 8, 2026 13:17
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
@amondnet
amondnet force-pushed the 14-track-extract-shared-registry-20260408 branch from 0fb4380 to c0b5f2a Compare April 8, 2026 04:17
@codecov

codecov Bot commented Apr 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@amondnet amondnet assigned amondnet and unassigned amondnet Apr 8, 2026
The CLI now depends on @pleaseai/registry-schema which needs to be
built before tests can resolve the module.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

@amondnet
amondnet merged commit b82e3e5 into main Apr 8, 2026
5 checks passed
@amondnet
amondnet deleted the 14-track-extract-shared-registry-20260408 branch April 8, 2026 04:37
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.

track: extract-shared-registry-20260408

1 participant