mark3labs / mark3labs/kit

Export the extension event and result types from pkg/extensions so an extension can be tested outside Kit

Open
#136 1 comment 1 reaction 2 assignees View on GitHub

@ezynda3 is already working on this.

Since Sep 15, 2026.

  • #137 by @copilot-swe-agent — open
Dominant language
Go
Stars
134
Forks
24
Avg merge
8h 59m
Merged PRs (30d)
23

Description

The gap

A consumer cannot write a Go test for its own Kit extension using only the
public API.

pkg/extensions/test ships a test harness, and the path says pkg/, so it
reads as public. But every signature that matters is typed with
github.com/mark3labs/kit/internal/extensions, so no code outside Kit's own
module can call it.

Citations

Verified against v0.107.0 (unchanged since v0.106.0):

// pkg/extensions/test/harness.go
import "github.com/mark3labs/kit/internal/extensions"        // :43

func (h *Harness) LoadFile(path string) *extensions.LoadedExtension       // :72
func (h *Harness) Emit(event extensions.Event) (extensions.Result, error) // :152
func (h *Harness) EmitJSON(t string, in string) (*extensions.ToolCallResult, error) // :163
func (h *Harness) Runner() *extensions.Runner                             // :193
func (h *Harness) HasHandlers(t extensions.EventType) bool                // :198
func (h *Harness) RegisteredTools() []extensions.ToolDef                  // :206
func (h *Harness) RegisteredCommands() []extensions.CommandDef            // :214

pkg/extensions/ contains test/ and nothing else — there is no public
surface for the types themselves.

Reproduction

BONNIE enforces its "public Kit SDK
only" rule with a Kit extension, .kit/extensions/kit-boundary.go. It blocks
a write/edit that adds kit/internal/... to a Go file in that repository.

To test it, BONNIE must construct a ToolCallEvent and pass it to
Harness.Emit. That means importing internal/extensions — which is exactly
the import the extension under test exists to forbid. The test cannot be
written without violating the rule it verifies.

The cases were therefore run from a temporary test placed inside the Kit
checkout
, then deleted. The guard has no test in its own repository.

Why it is not cosmetic

That guard shipped with two defects a passing unit test did not catch: it read
a composite-literal element as an import, and it applied to Go files in other
checkouts, including Kit's own. Both were found by driving it by hand, because
no regression test could exist. An extension its author cannot test in their
own repository is an extension that rots.

The ask

Re-export the extension-facing types from pkg/extensions, the way pkg/kit
already re-exports the model types, and restate the harness signatures in terms
of the aliases:

// pkg/extensions/extensions.go
type Event = internalext.Event
type Result = internalext.Result
type EventType = internalext.EventType
type ToolCallEvent = internalext.ToolCallEvent
type ToolCallResult = internalext.ToolCallResult
type SessionStartEvent = internalext.SessionStartEvent
type ToolDef = internalext.ToolDef
type CommandDef = internalext.CommandDef
type LoadedExtension = internalext.LoadedExtension
type Runner = internalext.Runner

Aliases, not new types, so nothing inside Kit has to change and the harness
keeps working unmodified. New, Context(), LoadFile and Emit are already
the right shape — only the type names in their signatures need to move.

Context

BONNIE is Kit's first external SDK consumer, so a gap it hits is a gap every
extension author hits. Filed per Kit's own rule: check the public API, file
upstream, and only then work around it.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.