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 DebugAdapterCommand
- 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 FileVersion
- type Frame
- type IndexEntry
- type Kind
- type Operation
- type Port
- type Reader
- type SearchDocument
- type SearchFile
- type SearchResult
- type StorageKind
- type StorageMask
- type StorageReport
- type StorageSize
- type TerminalCommand
- type TextMatch
- type Workspace
- type WorkspaceChange
- type Writer
Constants ¶
const ( Version = 26 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 FileComparisonLimit = 2 << 20
const FileHistoryPageSize = 100
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 BinarySearchGlob = "!*.{" + strings.Join(binaryExtensions, ",") + "}"
BinarySearchGlob excludes known binary extensions from ripgrep's directory walk.
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 undergo content checks.
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 DebugAdapterCommand ¶
DebugAdapterCommand resolves a project launcher on the workspace host. Override is the host-level adapter path from Settings. Command takes priority.
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 FileVersion ¶
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 FileHistoryList FileHistoryRestore FileHistoryRead DiskStorage )
type SearchDocument ¶
type SearchDocument struct{ Path, Content string }
type SearchFile ¶
type SearchResult ¶
type SearchResult struct {
Files []SearchFile
Truncated bool
Skipped int
}
type StorageKind ¶
type StorageKind uint8
const ( StorageLargeHistory StorageKind = iota StorageHistory StorageProfiles StorageSearchCache StorageOtherProfiles StorageExtensions StorageTools StorageOther StorageKinds )
func (StorageKind) Mask ¶
func (k StorageKind) Mask() StorageMask
type StorageMask ¶
type StorageMask uint32
const CleanableStorage StorageMask = 1<<StorageLargeHistory | 1<<StorageHistory | 1<<StorageProfiles | 1<<StorageSearchCache
type StorageReport ¶
type StorageReport struct {
Host string
Problem string
Sizes [StorageKinds]StorageSize
Removed StorageSize
}
Sizes are logical file lengths after any requested cleanup.
type StorageSize ¶
type TerminalCommand ¶
type WorkspaceChange ¶
type WorkspaceChange uint32
const ( WorkspaceTreeChanged WorkspaceChange = 1 << iota WorkspaceGitChanged WorkspaceRepositoriesChanged WorkspaceIgnoreChanged )