claude

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 25, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package claude provides the Claude Code plugin adapter.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

type Adapter struct{}

Adapter converts between canonical Plugin and Claude Code plugin format.

func (*Adapter) DefaultPaths

func (a *Adapter) DefaultPaths() []string

DefaultPaths returns default file paths for Claude plugin manifest.

func (*Adapter) Marshal

func (a *Adapter) Marshal(plugin *core.Plugin) ([]byte, error)

Marshal converts canonical Plugin to Claude plugin.json bytes.

func (*Adapter) Name

func (a *Adapter) Name() string

Name returns the adapter identifier.

func (*Adapter) Parse

func (a *Adapter) Parse(data []byte) (*core.Plugin, error)

Parse converts Claude plugin.json bytes to canonical Plugin.

func (*Adapter) ReadFile

func (a *Adapter) ReadFile(path string) (*core.Plugin, error)

ReadFile reads a Claude plugin.json file and returns canonical Plugin.

func (*Adapter) WriteFile

func (a *Adapter) WriteFile(plugin *core.Plugin, path string) error

WriteFile writes canonical Plugin to a Claude plugin.json file.

func (*Adapter) WritePlugin

func (a *Adapter) WritePlugin(plugin *core.Plugin, dir string) error

WritePlugin writes the complete Claude plugin structure to the given directory.

type ClaudePlugin

type ClaudePlugin struct {
	Name        string `json:"name"`
	Version     string `json:"version"`
	Description string `json:"description"`

	// Optional metadata
	Author     string `json:"author,omitempty"`
	License    string `json:"license,omitempty"`
	Repository string `json:"repository,omitempty"`
	Homepage   string `json:"homepage,omitempty"`

	// MCP Servers - embedded directly in plugin.json for consolidated config
	MCPServers map[string]MCPServerConfig `json:"mcpServers,omitempty"`

	// Hooks - embedded directly in plugin.json for consolidated config
	Hooks *HooksConfig `json:"hooks,omitempty"`

	// Component paths (relative to plugin root)
	Commands string `json:"commands,omitempty"` // e.g., "./commands/"
	Skills   string `json:"skills,omitempty"`   // e.g., "./skills/"
	Agents   string `json:"agents,omitempty"`   // e.g., "./agents/"
}

ClaudePlugin represents the Claude Code plugin.json format. See: https://docs.anthropic.com/en/docs/claude-code/plugins

func FromCanonical

func FromCanonical(p *core.Plugin) *ClaudePlugin

FromCanonical creates a ClaudePlugin from canonical Plugin.

func (*ClaudePlugin) SetHooks added in v0.6.0

func (cp *ClaudePlugin) SetHooks(hooks *HooksConfig)

SetHooks sets the hooks configuration on the plugin.

func (*ClaudePlugin) ToCanonical

func (cp *ClaudePlugin) ToCanonical() *core.Plugin

ToCanonical converts ClaudePlugin to canonical Plugin.

type Hook added in v0.6.0

type Hook struct {
	Type    string `json:"type"`              // "command" or "prompt"
	Command string `json:"command,omitempty"` // For command hooks
	Prompt  string `json:"prompt,omitempty"`  // For prompt hooks
}

Hook represents a single hook action.

type HookEntry added in v0.6.0

type HookEntry struct {
	Matcher string `json:"matcher,omitempty"`
	Hooks   []Hook `json:"hooks"`
}

HookEntry represents a hook entry with optional matcher.

type HooksConfig added in v0.6.0

type HooksConfig struct {
	// Event-based hooks (Claude Code format)
	PreToolUse   []HookEntry `json:"PreToolUse,omitempty"`
	PostToolUse  []HookEntry `json:"PostToolUse,omitempty"`
	Notification []HookEntry `json:"Notification,omitempty"`
	Stop         []HookEntry `json:"Stop,omitempty"`
	SubagentStop []HookEntry `json:"SubagentStop,omitempty"`
}

HooksConfig represents the hooks configuration embedded in plugin.json.

type MCPServerConfig added in v0.6.0

type MCPServerConfig struct {
	Command  string            `json:"command"`
	Args     []string          `json:"args,omitempty"`
	Env      map[string]string `json:"env,omitempty"`
	Cwd      string            `json:"cwd,omitempty"`
	Disabled bool              `json:"disabled,omitempty"`
}

MCPServerConfig represents an MCP server configuration in Claude format.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL