Skip to content

extension types: derive tools from RegisterExtension, and stop hand-writing the augmentation #238

Closed

Description

@omridevk

What to build

An extension's tools are typed at the call site, derived from the extension itself, with nothing restated by hand.

The mechanism already exists for configuration. An extension declares itself in one line and the types follow from the builder:

declare module '@conciv/protocol/config-types' {
  interface ExtensionConfigRegistry extends RegisterExtension<typeof demo> {}
}

RegisterExtension reads the name and the config schema off the builder. It also already captures the extension's tools type in the same conditional — and discards it, as an underscore-prefixed inferred parameter. Projecting it instead is the whole change: an extension's tools become known to the typed client, so calling one is checked and autocompleted rather than a missing property.

The second thing to fix is a duplicate. A different registry interface is augmented by hand elsewhere in the tree, restating a shape the builder already knows. Two augmentation targets exist and only one of them derives. Converge on the derived one; do not add a third.

Independent of the registry work — the pieces this needs are already shipped — so it can start immediately and land in parallel.

Acceptance criteria

  • RegisterExtension projects an extension's tools and context alongside its config, all derived from the builder
  • An extension that declares itself in one derived line gets typed, autocompleted tool calls with no cast
  • No declaration restates a schema or a signature the builder already carries
  • The hand-written augmentation in the widget's own extension is replaced by the derived form
  • The two augmentation targets become one, or the remaining split is documented with a reason
  • A type test asserts all of the above, in the style of the existing config registry type test

Blocked by

  • None — can start immediately.

Activity

  1. added
    ready-for-agent
    on Aug 4, 2026
  2. omridevk commented on Aug 4, 2026

    @omridevk
    ContributorAuthor

    Library references — read the resolved source under node_modules/.pnpm/, not the docs alone. Earlier drafts of the design took doc statements at face value and were wrong three times; every claim that depends on library behaviour now carries a version and a path. The canonical table is in the spec under "Libraries: the exact versions, and where to read them". Versions assume the 0.43-line upgrade in #239.

    For this ticket the reference is in-repo, not a third party: packages/extension/src/define-extension.ts for RegisterExtension and the ExtensionBuilder type parameters it already captures, and packages/extension/test/config-registry.test-d.ts for the derived-augmentation pattern and the type-test style to copy. The type-generation limits that make schema pre-resolution necessary are in @tanstack/ai-code-mode@0.3.9 src/type-generator/json-schema-to-ts.ts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ready-for-agent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions