agent

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package agent implements read-only language-tooling requests against gopls.

Index

Constants

View Source
const MaxBatchOperations = 16

MaxBatchOperations bounds prepared source overlays retained by one session.

Variables

This section is empty.

Functions

func WriteText

func WriteText(w io.Writer, result Result) error

WriteText gives a compact view while JSON output preserves the complete LSP payload, including documentation, edits and location links.

Types

type Options

type Options struct {
	Workspace, File, Operation, Gopls, Insert string
	Line, Column                              int
}

type Position

type Position struct {
	Line      int `json:"line"`
	Character int `json:"character"`
}

Position uses LSP's zero-based UTF-16 coordinates, not byte or visual columns.

type Result

type Result struct {
	Operation string          `json:"operation"`
	Workspace string          `json:"workspace"`
	File      string          `json:"file"`
	Position  Position        `json:"position"`
	Server    ServerInfo      `json:"server"`
	Payload   json.RawMessage `json:"result"`
	Timing    Timing          `json:"timing"`
}

func Inspect

func Inspect(ctx context.Context, options Options) (Result, error)

Inspect launches an existing gopls executable, sends one unsaved document and returns its actual response. No source files or source-file probes are written.

func InspectBatch

func InspectBatch(ctx context.Context, options []Options, timeout time.Duration) ([]Result, error)

InspectBatch owns one fresh language-server session for a related scenario. Each operation opens its independently prepared overlay and closes it before the next operation. Initialization and each operation have separate deadlines; any failure stops the batch and closes the owned process. Returned results are the completed prefix; callers must still check the error, including cleanup. No server or unsaved state is shared between calls.

type ServerInfo

type ServerInfo struct {
	Name    string `json:"name"`
	Version string `json:"version,omitempty"`
}

type Timing

type Timing struct {
	InitializeNanoseconds int64 `json:"initialize_ns"`
	RequestNanoseconds    int64 `json:"request_ns"`
}

Timing separates protocol request latency from server startup. Request time includes any gopls package loading caused by that request; it is not CPU time. Process shutdown and document preparation belong to the caller's wall time.

Jump to

Keyboard shortcuts

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