# Scratchpad — updater package target fix (#382)

- Objective: Fix `mosaic update` so modern installs query `@mosaicstack/mosaic` instead of stale `@mosaicstack/cli`.
- Scope: updater logic, user-facing update/install hints, tests, package version bump(s).
- Constraints: preserve backward compatibility for older `@mosaicstack/cli` installs if practical.
- Acceptance:
  - fresh installs using `@mosaicstack/mosaic` report latest correctly
  - older installs do not regress unnecessarily
  - tests cover package lookup behavior
  - release version bumped for changed package(s)

## Decisions

- Prefer `@mosaicstack/mosaic` when both modern and legacy packages are installed globally.
- For legacy `@mosaicstack/cli` installs, query `@mosaicstack/cli` first, then fall back to `@mosaicstack/mosaic` if the legacy package is not published.
- Share install-target selection from `packages/mosaic` so both the consolidated CLI and the legacy `packages/cli` entrypoint print/install the same package target.
- Extend the update cache to persist the resolved target package as well as the version so cached checks preserve the migration target.

## Validation

- `pnpm install`
- `pnpm --filter @mosaicstack/mosaic test -- __tests__/update-checker.test.ts`
- `pnpm exec eslint --no-warn-ignored packages/mosaic/src/runtime/update-checker.ts packages/mosaic/src/cli.ts packages/mosaic/src/index.ts packages/mosaic/__tests__/update-checker.test.ts packages/cli/src/cli.ts`
- `pnpm --filter @mosaicstack/mosaic lint`
- pre-push hooks: `typecheck`, `lint`, `format:check`

## Review

- Manual review of the updater diff caught and fixed a cache regression where fallback results would lose the resolved package target on subsequent cached checks.

## Risks / Notes

- Direct `pnpm --filter @mosaicstack/mosaic typecheck` and `pnpm --filter @mosaicstack/cli ...` checks were not representative in this worktree because `packages/cli` is excluded from `pnpm-workspace.yaml` and the standalone package check lacked the built workspace dependency graph.
- The repo's pre-push hooks provided the authoritative validation path here and passed: root `typecheck`, `lint`, and `format:check`.
