Files
kit/examples/extensions/README.md
T
Ed Zynda c5e6ca6e4d feat: Add kit install command for git-based extension distribution
Add comprehensive extension installation system for Kit:

Features:
- kit install <git-url> - Install extensions from git repos
- kit install <url> --local - Install to project .kit/git/ directory
- kit install <url> --select - Interactive selection for multi-extension repos
- kit install <url> --update - Update installed extensions
- kit install <url> --uninstall - Remove installed extensions
- Version pinning via @ref (tags, branches, commits)
- Support multiple URL formats (shorthand, git:, https, ssh)

Implementation:
- internal/extensions/installer.go - Git clone, checkout, validation
- internal/extensions/manifest.go - Package tracking with Include filtering
- internal/extensions/loader.go - Respect Include field when loading
- cmd/install.go - Cobra command with interactive prompts
- PromptMultiSelectConfig API - Multi-select prompts for extensions

Storage:
- Global: ~/.local/share/kit/git/<host>/<owner>/<repo>/
- Project: .kit/git/<host>/<owner>/<repo>/
- Manifests: packages.json tracking installed packages

Examples:
- Reorganized examples/extensions/ with README.md
- Added status-tools/ multi-file extension example
- Created comprehensive install guide in SKILL.md

Testing:
- Added installer_test.go with 15+ test cases
- All tests pass, build clean

Closes #extension-distribution
2026-03-18 16:21:31 +03:00

5.5 KiB

Kit Extension Examples

A collection of example extensions demonstrating various Kit capabilities. These can be installed individually or as a complete collection.

Installation

Install all examples

kit install github.com/mark3labs/kit/examples/extensions

Install with interactive selection

kit install github.com/mark3labs/kit/examples/extensions --select

Install locally in your project

kit install github.com/mark3labs/kit/examples/extensions --local

Extension Index

Core Concepts

Extension Description Key API
minimal.go Minimal viable extension Basic Init() function
plan-mode.go Restrict agent to read-only tools OnBeforeAgentStart, SetActiveTools
tool-logger.go Log all tool calls to file OnToolCall, OnToolResult
notify.go Display notifications PrintInfo, PrintBlock

UI & Widgets

Extension Description Key API
widget-status.go Persistent status widget SetWidget, RemoveWidget
header-footer-demo.go Custom header/footer SetHeader, SetFooter
overlay-demo.go Modal overlay dialogs ShowOverlay
compact-notify.go Compact mode notifications PrintBlock
branded-output.go Custom styled output PrintBlock with colors

Input & Editor

Extension Description Key API
custom-editor-demo.go Custom key handling SetEditor, EditorKeyAction
pirate.go Transform user input OnInput, InputResult
interactive-shell.go Custom command input Slash commands with prompts
inline-bash.go Execute bash inline Input handling, exec

Session & Context

Extension Description Key API
context-inject.go Inject context into prompts OnContextPrepare
bookmark.go Bookmark messages AppendEntry, GetEntries
project-rules.go Project-specific rules Session data, file reading
protected-paths.go Block dangerous operations OnToolCall with blocking
permission-gate.go Confirm destructive actions OnToolCall with confirmation

Tools & Commands

Extension Description Key API
auto-commit.go Auto-commit changes Custom tool, git operations
summarize.go Summarize conversation Custom tool with parameters
confirm-destructive.go Confirm destructive commands OnToolCall blocking
lsp-diagnostics.go LSP integration Complex extension, external process

Subagents & Background Tasks

Extension Description Key API
kit-kit.go Spawn Kit as subagent Subagent spawning
subagent-test.go Test subagent functionality SpawnSubagent
subagent-widget.go Widget with subagent updates Goroutines + widgets
dev-reload.go Hot reload extensions ReloadExtensions

Rendering

Extension Description Key API
tool-renderer-demo.go Custom tool output styling RegisterToolRenderer
prompt-demo.go Interactive prompts PromptSelect, PromptConfirm

Extension Details

minimal.go

The bare minimum extension showing the required structure:

  • Package main
  • Import kit/ext
  • Export Init(api ext.API) function

plan-mode.go

A complete example demonstrating:

  • Slash command (/plan)
  • Keyboard shortcut (ctrl+alt+p)
  • Option registration
  • Status bar indicators
  • System prompt injection
  • Tool filtering

widget-status.go

Shows how to create persistent UI elements:

  • Create widgets with SetWidget
  • Update content dynamically
  • Remove when done
  • Handle session lifecycle

context-inject.go

Advanced context manipulation:

  • Read project files
  • Inject into LLM context
  • Filter messages
  • Use negative indices for ephemeral content

lsp-diagnostics.go

Complex real-world example:

  • Multi-file extension
  • External process management (LSP server)
  • File watching
  • Diagnostics aggregation

Multi-File Extension Example

The kit-kit-agents/ directory demonstrates the multi-file pattern:

kit-kit-agents/
├── main.go          # Entry point with Init()
├── agent.go         # Agent configuration
├── manager.go       # Agent lifecycle management
└── README.md        # Documentation

When the repo is installed, all files in subdirectories with main.go are loaded as separate extensions.

Testing & Validation

After installing, test the extensions:

# List all loaded extensions
kit extensions list

# Validate all extensions
kit extensions validate

# Run with a specific extension
kit -e ~/.local/share/kit/git/github.com/mark3labs/kit/examples/extensions/plan-mode.go

Creating Your Own

  1. Copy minimal.go as a starting point
  2. Modify the Init() function to register your handlers
  3. Use the other examples for reference on specific APIs
  4. Test with kit -e your-extension.go
  5. Share by pushing to a git repository!

Update

To get the latest examples:

kit install github.com/mark3labs/kit/examples/extensions --update

See Also