toolplugin

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: MIT Imports: 41 Imported by: 0

Documentation

Index

Constants

View Source
const (
	APIVersion = "mekugi-tool-plugin/v1"

	ExecutionOutputBudgetBytes = 16 << 20
)
View Source
const MaxOutputTokens = 15_500
View Source
const MaxTokensArgumentError = "--max-tokens requires one integer from 1 to 15500 and cannot repeat"

Variables

View Source
var LineRangePattern = regexp.MustCompile(`^[0-9]+[:-][0-9]+$`)

LineRangePattern identifies range operands before command-specific path handling.

Functions

func ConfigureProcessGroup

func ConfigureProcessGroup(command *exec.Cmd)

ConfigureProcessGroup makes command cancellation terminate descendants that inherited the command's standard streams instead of leaving Wait blocked.

func EnableFrontendOrphanCleanup

func EnableFrontendOrphanCleanup(ctx context.Context) (context.Context, error)

EnableFrontendOrphanCleanup is for a dedicated authenticated frontend process, not a router or test process that owns unrelated child commands.

func ExpandMaxTokensOption added in v0.3.0

func ExpandMaxTokensOption(arguments []string) []string

Expand only the next option, never operands owned by a command or -- boundary.

func InspectSource added in v0.3.0

func InspectSource(ctx context.Context, path string, bytes []byte) (string, error)

InspectSource uses the same structural renderer as inspect_file on a caller's already-opened snapshot, without reopening a path or executing a frontend.

func ParseLineRange added in v0.3.0

func ParseLineRange(span string) (int, int, error)

ParseLineRange parses canonical inclusive endpoints. Callers impose their own numeric ceiling; zero starts remain available for mcat's first-row convention.

func ParseMaxTokens added in v0.3.0

func ParseMaxTokens(value string) (int, error)

func SymbolQueryModes added in v0.3.0

func SymbolQueryModes(args []string) ([]string, error)

SymbolQueryModes projects the native parser's query modes for command display. It validates the complete invocation without loading sources or running resolvers.

func WithHostProcessGroup

func WithHostProcessGroup(ctx context.Context) context.Context

WithHostProcessGroup keeps executable frontend descendants in Codex's command group so stock cancellation can terminate the whole invocation.

Types

type ExecutionOutput

type ExecutionOutput struct {
	OmittedOutput *OmittedOutput `json:"omittedOutput,omitempty"`
	FailureClass  string         `json:"failureClass,omitempty"`
	Stdout        string         `json:"stdout"`
	Stderr        string         `json:"stderr"`
	ExitCode      int            `json:"exitCode"`
}

func Execute

func Execute(
	ctx context.Context,
	node, runtimeRoot, module string,
	index int,
	arguments []string,
	stdin *os.File,
	directory string,
	environment []string,
) (ExecutionOutput, error)

func ExecuteBuiltin

func ExecuteBuiltin(ctx context.Context, name string, args []string) (ExecutionOutput, error)

ExecuteBuiltin runs bundled readers in the authenticated frontend process. Configured plugins remain isolated JavaScript hosts, never native executors.

func FormatOutput

func FormatOutput(ctx context.Context, arguments []string) (ExecutionOutput, error)

FormatOutput formats bounded output entirely in the frontend process.

type OmittedOutput

type OmittedOutput struct {
	// Host-owned mcat provenance, not part of the plugin wire protocol.
	SourceRow  uint64 `json:"-"`
	MaxTokens  int    `json:"-"`
	StdoutKind string `json:"stdoutKind,omitempty"`
	StderrKind string `json:"stderrKind,omitempty"`
	Stdout     string `json:"stdout"`
	Stderr     string `json:"stderr"`
}

type Plugin

type Plugin struct {
	ID     string `json:"id"`
	Module string `json:"module"`
	Tools  []Tool `json:"tools"`
}

type ReaderOptions added in v0.3.0

type ReaderOptions struct {
	Budget, Lines int
	Tail, Number  bool
}

func ParseReaderOptions added in v0.3.0

func ParseReaderOptions(args []string, allowTail bool, defaultBudget int, takesValue string) (ReaderOptions, []string, error)

ParseReaderOptions removes shared reader options and retains the -- boundary and command-specific operands, including the value of takesValue. Source: plugins/common.ts:48:99@[543de4f3] readerOptions

type Snapshot

type Snapshot struct {
	Root           string
	NodeExecutable string
	Plugins        []Plugin
	Diagnostics    []string
}

func Load

func Load(ctx context.Context, pluginDirectory, snapshotRoot string) (Snapshot, error)

type Tool

type Tool struct {
	Specification  json.RawMessage `json:"specification"`
	NativeExecutor string          `json:"nativeExecutor,omitempty"`
}

Jump to

Keyboard shortcuts

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