engine

package
v1.65.2 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Version is the @coder plugin version.
	Version = "2.0.0"

	// DefaultMaxBytes is the default byte limit for file reads.
	DefaultMaxBytes = 200_000

	// DefaultMaxEntries is the default entry limit for tree listings.
	DefaultMaxEntries = 2_000
)

Variables

This section is empty.

Functions

func GetMetadataJSON

func GetMetadataJSON() string

GetMetadataJSON returns the metadata as a JSON string.

func GetSchema

func GetSchema() string

GetSchema returns the @coder plugin schema as a JSON string.

func IsUnsafeCommand

func IsUnsafeCommand(cmd string, allowSudo bool) (bool, string)

IsUnsafeCommand checks if a shell command matches known dangerous patterns.

Types

type Engine

type Engine struct {
	Out io.Writer // primary output (replaces os.Stdout)
	Err io.Writer // error/debug output (replaces os.Stderr)
}

Engine is the core execution engine for @coder commands. It is stdlib-only and writes all output to the provided io.Writer instances.

func NewEngine

func NewEngine(out, errOut io.Writer) *Engine

NewEngine creates an Engine that writes to the given writers.

func (*Engine) Execute

func (e *Engine) Execute(ctx context.Context, cmd string, args []string) error

Execute dispatches a subcommand with the given args.

type FlagDefinition

type FlagDefinition struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Type        string `json:"type"`
	Default     string `json:"default,omitempty"`
	Required    bool   `json:"required,omitempty"`
}

FlagDefinition describes a subcommand flag.

type Metadata

type Metadata struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Usage       string `json:"usage"`
	Version     string `json:"version"`
}

Metadata holds @coder plugin identification.

func GetMetadata

func GetMetadata() Metadata

GetMetadata returns the @coder plugin metadata.

type PluginSchema

type PluginSchema struct {
	Name        string                 `json:"name"`
	Description string                 `json:"description"`
	ArgsFormat  string                 `json:"args_format"`
	Subcommands []SubcommandDefinition `json:"subcommands"`
}

PluginSchema is the full plugin schema for LLM context.

type StreamWriter

type StreamWriter struct {
	// contains filtered or unexported fields
}

StreamWriter implements io.Writer and calls onOutput per complete line. Partial lines are buffered until a newline arrives or Flush() is called.

func NewStreamWriter

func NewStreamWriter(onOutput func(string)) *StreamWriter

NewStreamWriter creates a StreamWriter that calls onOutput for each line.

func (*StreamWriter) Flush

func (sw *StreamWriter) Flush()

Flush emits any remaining buffered content as a final line.

func (*StreamWriter) Write

func (sw *StreamWriter) Write(p []byte) (int, error)

type SubcommandDefinition

type SubcommandDefinition struct {
	Name        string           `json:"name"`
	Description string           `json:"description"`
	Flags       []FlagDefinition `json:"flags"`
	Examples    []string         `json:"examples,omitempty"`
}

SubcommandDefinition describes a plugin subcommand.

Jump to

Keyboard shortcuts

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