Adopt pm-cli 2026.7.26 typed authoring contracts and drop the any-cast defineExtension shim

Merged
UN
3mo ago
+50-15

What

Adopts the pm-cli 2026.7.26 typed authoring contracts and removes the forced-any defineExtension shim.

pm item: pm-github-zjxx

Why

This package carried:

import type { defineExtension as defineExtensionType } from "@unbrained/pm-cli/sdk";
const defineExtension: typeof defineExtensionType = ((extension: any) => extension) as any;

Two anys that existed only to bridge a type surface the SDK did not expose. 2026.7.26 adds @unbrained/pm-cli/sdk/authoring with the real contracts.

Approach: local declaration, not a value import

defineExtension is a pure identity function — <T extends ExtensionModule>(module: T) => T. So the shim is replaced with an equivalent locally declared, fully typed helper:

const defineExtension = <TModule extends ExtensionModule>(module: TModule): TModule => module;

Declared locally on purpose. This package's dependency on @unbrained/pm-cli is type-only, so every import erases at build time and the published extension carries no runtime module edge to the CLI. Importing defineExtension as a value would have introduced one. Contract checking is identical, since the constraint is the SDK's own ExtensionModule.

activate is now typed with the real ExtensionApi rather than any, so every api.register* call is checked against the host contract.

Verification

  • npm run typecheck — clean
  • npm test — 168 passing
  • dependency ranges moved to pm-cli 2026.7.26 (first release exposing sdk/authoring) and pm-changelog 2026.7.25

Summary by cubic

Adopts @unbrained/pm-cli 2026.7.26 typed authoring contracts and removes the any-cast defineExtension shim for better type safety with no runtime edge. Consumers need @unbrained/pm-cli >= 2026.7.26.

  • Refactors

    • Type-only import ExtensionApi and ExtensionModule from @unbrained/pm-cli/sdk/authoring.
    • Replace the shim with a local typed identity defineExtension<T extends ExtensionModule>(module).
    • Type activate(api: ExtensionApi) and remove remaining any casts.
    • Close the implementation record and regenerate CHANGELOG.md against v2026.07.26.
  • Dependencies

    • Bump @unbrained/pm-cli to ^2026.7.26 (peer: >=2026.7.26).
    • Bump pm-changelog to ^2026.7.25.