Documentation
¶
Overview ¶
Package protocol defines the versioned framed stdio contract shared by Spice annotation tools and the compiler host.
Index ¶
- Constants
- func DecodeContribution(wire Contribution) (sdk.Contribution, error)
- func ReadMessage(reader *bufio.Reader, destination any) error
- func Serve(ctx context.Context, reader io.Reader, writer io.Writer, tool Tool) error
- func WriteMessage(writer io.Writer, value any) error
- type AnalyzeParams
- type AnalyzeResult
- type Argument
- type Contribution
- type Declaration
- type DescribeParams
- type DescribeResult
- type Diagnostic
- type Handler
- type InitializeParams
- type InitializeResult
- type Invocation
- type Request
- type Response
- type ResponseError
- type ShutdownParams
- type Tool
Constants ¶
const ( // VersionV1Alpha2 is the typed-handler JSON-RPC contribution protocol. VersionV1Alpha2 = sdk.ProtocolV1Alpha2 // MaximumMessageBytes bounds one decoded plugin message. MaximumMessageBytes = 16 << 20 )
Variables ¶
This section is empty.
Functions ¶
func DecodeContribution ¶
func DecodeContribution( wire Contribution, ) (sdk.Contribution, error)
DecodeContribution strictly decodes and validates one wire contribution. Unknown fields, trailing JSON, missing payloads, and invalid values fail before the contribution can enter compiler state.
func ReadMessage ¶
ReadMessage reads one Content-Length framed JSON message.
Types ¶
type AnalyzeParams ¶
type AnalyzeParams struct {
Descriptor sdk.Symbol `json:"descriptor"`
Invocation Invocation `json:"invocation"`
}
AnalyzeParams dispatches one invocation by its descriptor identity. The process owns the descriptor-to-typed-handler registration.
type AnalyzeResult ¶
type AnalyzeResult struct {
Contributions []Contribution `json:"contributions,omitempty"`
Diagnostics []Diagnostic `json:"diagnostics,omitempty"`
}
AnalyzeResult returns validated IR inputs and diagnostics.
type Argument ¶
type Argument = sdk.InvocationArgument
Argument is the normalized SDK invocation argument payload.
type Contribution ¶
type Contribution struct {
Kind sdk.ContributionKind `json:"kind"`
Value json.RawMessage `json:"value"`
}
Contribution is a versioned generic IR input. Kind is an SDK-defined capability and Value is decoded into the corresponding typed contribution by the host before it can enter the compiler IR.
func EncodeContribution ¶
func EncodeContribution( value sdk.Contribution, ) (Contribution, error)
EncodeContribution validates and serializes one typed SDK contribution for transport. Annotation tools should use this boundary instead of hand-writing raw JSON envelopes.
type Declaration ¶
type Declaration = sdk.Declaration
Declaration is the normalized SDK declaration payload.
type DescribeParams ¶
type DescribeParams struct{}
DescribeParams requests inspectable handler metadata.
type DescribeResult ¶
type DescribeResult struct {
DescriptorPackages []string `json:"descriptor_packages"`
Handlers []Handler `json:"handlers"`
}
DescribeResult reports every public descriptor package and handler owned by the process.
type Diagnostic ¶
type Diagnostic = sdk.HandlerDiagnostic
Diagnostic is one plugin-owned source diagnostic.
type Handler ¶
type Handler struct {
Descriptor sdk.Symbol `json:"descriptor"`
Capabilities []string `json:"capabilities"`
}
Handler describes one descriptor-to-implementation registration.
type InitializeParams ¶
type InitializeParams struct {
Protocol sdk.ProtocolVersion `json:"protocol"`
SpiceVersion string `json:"spice_version"`
WorkspaceRoot string `json:"workspace_root"`
ToolPath string `json:"tool_path"`
}
InitializeParams starts protocol and identity negotiation.
type InitializeResult ¶
type InitializeResult struct {
Protocol sdk.ProtocolVersion `json:"protocol"`
ToolPath string `json:"tool_path"`
ModulePath string `json:"module_path"`
ModuleVersion string `json:"module_version,omitempty"`
}
InitializeResult confirms the executable's build identity.
type Invocation ¶
type Invocation = sdk.Invocation
Invocation is the normalized SDK invocation payload.
type Request ¶
type Request struct {
JSONRPC string `json:"jsonrpc"`
ID uint64 `json:"id"`
Method string `json:"method"`
Params json.RawMessage `json:"params,omitempty"`
}
Request is one JSON-RPC 2.0 request.
type Response ¶
type Response struct {
JSONRPC string `json:"jsonrpc"`
ID uint64 `json:"id"`
Result json.RawMessage `json:"result,omitempty"`
Error *ResponseError `json:"error,omitempty"`
}
Response is one JSON-RPC 2.0 response.
type ResponseError ¶
type ResponseError struct {
Code int `json:"code"`
Message string `json:"message"`
Data json.RawMessage `json:"data,omitempty"`
}
ResponseError is a deterministic JSON-RPC failure.
type ShutdownParams ¶
type ShutdownParams struct{}
ShutdownParams requests graceful process termination.
type Tool ¶
type Tool interface {
Initialize(context.Context, InitializeParams) (InitializeResult, error)
Describe(context.Context, DescribeParams) (DescribeResult, error)
Analyze(context.Context, AnalyzeParams) (AnalyzeResult, error)
Shutdown(context.Context, ShutdownParams) error
}
Tool implements the public annotation process protocol.