Documentation
¶
Overview ¶
Package protocol defines the headless Pencode client/server wire format. Payloads are borrowed until the reader's next Read. Readers and writers each have one owner; callers transfer owned data across goroutines.
Index ¶
- Constants
- Variables
- func EncodeExtension(e *Encoder, i ExtensionInfo)
- func IsBinaryFile(name string) bool
- func IsTextFile(name string) bool
- func SearchFlags(options textsearch.Options) uint32
- func SearchOptions(flags uint32) textsearch.Options
- func ValidPortHost(host string) bool
- type Code
- type Decoder
- type Document
- type DocumentMode
- type DocumentPage
- type Encoder
- type Entry
- type Error
- type ExtensionInfo
- type ExtensionManifest
- type FileChanges
- type FileEvent
- type FileOperation
- type Frame
- type IndexEntry
- type Kind
- type Operation
- type Port
- type Reader
- type SearchDocument
- type SearchFile
- type SearchResult
- type TerminalCommand
- type TextMatch
- type Workspace
- type WorkspaceChange
- type Writer
Constants ¶
const ( Version = 20 HeaderSize = 24 MaxPayload = 64 << 10 MaxMessage = 64 << 20 ChunkSize = 32 << 10 // StreamWindow bounds both buffered process output and each stream RPC. StreamWindow = 256 << 10 )
const ( IndexPageSize = 256 IndexEntryLimit = 262144 IndexDepthLimit = 256 )
const TextPageSize = 64 << 10
TextPageSize bounds text sent to and laid out by the editor. Larger files retain a disk-backed document and expose one page at a time.
const TextPagingThreshold = 4 << 20
const TextSearchFileLimit = 2 << 20
const TextSearchFilesLimit = 65536
const TextSearchLimit = 2000
Variables ¶
var ErrProtocol = errors.New("pencode: invalid client/server message")
Functions ¶
func EncodeExtension ¶
func EncodeExtension(e *Encoder, i ExtensionInfo)
func IsBinaryFile ¶
IsBinaryFile is a cheap search prefilter. Unknown types still undergo content checks during search, even though opening them requires an editor choice.
func IsTextFile ¶
IsTextFile recognizes built-in text associations. Unknown types need an extension or an explicit choice; content is checked again by the file service.
func SearchFlags ¶
func SearchFlags(options textsearch.Options) uint32
func SearchOptions ¶
func SearchOptions(flags uint32) textsearch.Options
func ValidPortHost ¶
Hosts are passed directly to the remote TCP dialer, never to a shell.
Types ¶
type Decoder ¶
func (*Decoder) DocumentPage ¶
func (d *Decoder) DocumentPage() DocumentPage
type Document ¶
type Document struct {
Content string
Page DocumentPage
ID, Version uint64
}
type DocumentMode ¶
type DocumentMode uint32
DocumentMode distinguishes path-only viewers, checked text, and an explicit user request to decode a resource in the code editor.
const ( DocumentFile DocumentMode = iota DocumentText DocumentTextForced )
func FileMode ¶
func FileMode(name string) DocumentMode
type DocumentPage ¶
type Encoder ¶
type Encoder struct{ Buffer []byte }
Encoder appends into caller-owned storage and can be reset without allocating.
func (*Encoder) DocumentPage ¶
func (e *Encoder) DocumentPage(p DocumentPage)
type ExtensionInfo ¶
type ExtensionInfo struct {
Path, Problem string
ExtensionManifest
}
func DecodeExtension ¶
func DecodeExtension(d *Decoder) ExtensionInfo
func (*ExtensionInfo) Label ¶
func (i *ExtensionInfo) Label() string
type ExtensionManifest ¶
type ExtensionManifest struct {
ID string `json:"id"`
Name string `json:"name,omitempty"`
Version string `json:"version,omitempty"`
Publisher string `json:"publisher,omitempty"`
Description string `json:"description,omitempty"`
Entry string `json:"entry"`
Args []string `json:"args,omitempty"`
Disabled bool `json:"disabled,omitempty"`
}
ExtensionManifest is installed on the server at resources/extension.json.
func (ExtensionManifest) JavaScript ¶
func (m ExtensionManifest) JavaScript() bool
JavaScript distinguishes bundled TypeScript/JavaScript entries from native executables. Runtime lookup belongs to the workspace host, never the GUI.
type FileChanges ¶
type FileChanges struct {
Files []FileEvent
Version uint64
Changes WorkspaceChange
Reset bool // Reconcile when history or native events overflowed.
}
type FileEvent ¶
type FileEvent struct {
Path string // Workspace-relative, slash-separated; never an external Git path.
Op FileOperation
Directory bool
}
type FileOperation ¶
type FileOperation uint8
FileOperation is shared by every native watcher and file-service consumer.
const ( FileCreated FileOperation = 1 << iota FileWritten FileRemoved FileRenamed FileMetadataChanged )
type IndexEntry ¶
func (IndexEntry) Name ¶
func (e IndexEntry) Name() string
type Operation ¶
type Operation uint32
Service operations share the connection's cancellation and chunking rules.
const ( GitCommand Operation = iota + 1 FileRead FileSave DiffPatch ProcessOpen TerminalOpen StreamRead StreamWrite StreamResize StreamClose StreamWait IndexOpen IndexNext IndexClose PathSearch SyntaxAnalyze SyntaxRelease ExtensionList ExtensionLoad ExtensionResource ExtensionProcess ExtensionLanguageProcess ExtensionBegin ExtensionWrite ExtensionPrepare ExtensionCommit ExtensionAbort ExtensionEnable ExtensionRemove ExtensionResources DirectoryBrowse ConfigurationRead SettingsSave PortList PortConnect StreamCloseWrite GitRepositories TextSearch DebugAdapterOpen DebugTerminalOpen WorkspaceWatch GitCheckIgnore GitRebasing LanguageTools )
type SearchDocument ¶
type SearchDocument struct{ Path, Content string }
type SearchFile ¶
type SearchResult ¶
type SearchResult struct {
Files []SearchFile
Truncated bool
Skipped int
}
type TerminalCommand ¶
type WorkspaceChange ¶
type WorkspaceChange uint32
const ( WorkspaceTreeChanged WorkspaceChange = 1 << iota WorkspaceGitChanged WorkspaceRepositoriesChanged WorkspaceIgnoreChanged )