kit

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: GPL-3.0 Imports: 31 Imported by: 0

Documentation

Overview

Package kit implements Ether's plugin conformance kit and copy linter (SPEC §5.1–§5.6, WS11g), shared across install previews, Studio, the `ether plugin` CLI, and catalogue CI.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckInstall

func CheckInstall(ctx context.Context, manifest []byte, files map[string][]byte) error

CheckInstall adapts the conformance report to the plugin host's validation error.

func GenerateTemplateFiles

func GenerateTemplateFiles(opts TemplateOptions) (map[string][]byte, error)

GenerateTemplateFiles returns the in-memory file map for a scaffolded plugin.

func Pack

func Pack(pkg *Package) ([]byte, error)

Pack compiles any TypeScript entry via wasm.Compile, bundles manifest, compiled JS/WASM, assets, schema, strings, and writes the verified `digest` entry into an installable .etherpkg archive.

func Scaffold

func Scaffold(opts TemplateOptions) error

Scaffold generates a minimal working plugin for the requested kind and language in opts.Dir. Every generated template passes kit.Check out of the box.

Types

type CaseResult

type CaseResult struct {
	Name       string  `json:"name"`
	OK         bool    `json:"ok"`
	Status     int     `json:"status"`
	DurationMS float64 `json:"durationMs"`
	Error      string  `json:"error,omitempty"`
}

CaseResult is the outcome of one fixture test case.

type FixtureCase

type FixtureCase struct {
	Name       string            `json:"name"`
	Method     string            `json:"method"`
	Path       string            `json:"path"`
	Query      map[string]string `json:"query,omitempty"`
	Headers    map[string]string `json:"headers,omitempty"`
	Body       json.RawMessage   `json:"body,omitempty"`
	WantStatus int               `json:"wantStatus"`
	WantFields map[string]any    `json:"wantFields,omitempty"`
}

FixtureCase is one recorded test fixture in tests/fixtures.json.

type FixtureSuite

type FixtureSuite struct {
	Cases []FixtureCase `json:"cases"`
}

FixtureSuite is the schema of tests/fixtures.json.

type HotTiming

type HotTiming struct {
	Candidates    int     `json:"candidates"`
	Batches       int     `json:"batches"`
	TotalMS       float64 `json:"totalMs"`
	MaxBatchMS    float64 `json:"maxBatchMs"`
	PerCandP95MS  float64 `json:"perCandidateP95Ms"`
	SlowCount     int     `json:"slowCandidates"`
	Deterministic bool    `json:"deterministic"`
}

HotTiming records the outcome and timing of the 10k-candidate hot-path check.

type Issue

type Issue struct {
	Rule    string `json:"rule"`
	Field   string `json:"field,omitempty"`
	Message string `json:"message"`
}

Issue is one error or warning found by the conformance kit.

func (Issue) String

func (i Issue) String() string

type Package

type Package struct {
	ManifestRaw json.RawMessage
	Manifest    plugins.Manifest
	Files       map[string][]byte
	Dir         string
}

Package holds an unpacked or directory-loaded plugin ready for checking or packing.

func FromFiles

func FromFiles(manifestRaw []byte, files map[string][]byte) (*Package, error)

FromFiles builds an in-memory Package from raw manifest JSON and a file map.

func Load

func Load(target string) (*Package, error)

Load reads a plugin from a directory path or an .etherpkg file path.

func LoadDir

func LoadDir(dir string) (*Package, error)

LoadDir loads a plugin package from a filesystem directory.

func LoadPkgBytes

func LoadPkgBytes(raw []byte) (*Package, error)

LoadPkgBytes loads a plugin package from .etherpkg zip bytes, verifying the digest entry when present.

type Report

type Report struct {
	PluginID      string          `json:"pluginId,omitempty"`
	Version       string          `json:"version,omitempty"`
	Kind          string          `json:"kind,omitempty"`
	OK            bool            `json:"ok"`
	Exports       map[string]bool `json:"exports,omitempty"`
	Errors        []Issue         `json:"errors,omitempty"`
	Warnings      []Issue         `json:"warnings,omitempty"`
	Routes        []RouteTiming   `json:"routes,omitempty"`
	HotPath       *HotTiming      `json:"hotPath,omitempty"`
	DeclaredHosts []string        `json:"declaredHosts,omitempty"`
	ObservedHosts []string        `json:"observedHosts,omitempty"`
	DurationMS    float64         `json:"durationMs"`
}

Report is the structured result of Check.

func Check

func Check(ctx context.Context, pkg *Package) (rep Report)

Check runs the full conformance kit against pkg and returns a structured Report.

func (Report) JSON

func (r Report) JSON() ([]byte, error)

JSON returns the report as indented JSON bytes.

func (Report) Text

func (r Report) Text() string

Text renders the report in plain human-readable text.

type RouteTiming

type RouteTiming struct {
	Method     string        `json:"method"`
	Route      string        `json:"route"`
	Status     int           `json:"status"`
	DurationMS float64       `json:"durationMs"`
	DeadlineMS int64         `json:"deadlineMs"`
	OK         bool          `json:"ok"`
	Skipped    bool          `json:"skipped,omitempty"`
	Error      string        `json:"error,omitempty"`
	Duration   time.Duration `json:"-"`
}

RouteTiming records the outcome and duration of one route check.

type TemplateOptions

type TemplateOptions struct {
	Kind string // source|integration|notification_channel|livetv_source|extension
	Lang string // ts|js|python
	Dir  string
	ID   string
	Name string
}

TemplateOptions configures a scaffolded plugin project.

type TestReport

type TestReport struct {
	PluginID    string       `json:"pluginId"`
	OK          bool         `json:"ok"`
	Cases       []CaseResult `json:"cases"`
	Integration *CaseResult  `json:"integration,omitempty"`
}

TestReport is the outcome of RunTests.

func RunTests

func RunTests(ctx context.Context, pkg *Package, etherBin string) (TestReport, error)

RunTests runs the plugin's recorded fixtures through the hosted runtime (or conformal check when no fixtures file is present), and when etherBin is non-empty, runs an integration check against a headless Ether process.

func (TestReport) Text

func (tr TestReport) Text() string

Text formats the test report as plain human-readable lines.

Jump to

Keyboard shortcuts

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