protocol

package
v0.1.0-rc.4 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: MIT Imports: 7 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Pencode CS v13

GUI 和无头服务通过有序双向字节流通信。本地传输是子进程管道,远端传输是 OpenSSH 加密的 stdin/stdout;不监听或转发服务端端口,协议与具体传输无关。所有整数采用小端编码;不传递 Go 指针或渲染对象。旧版本不兼容。

每帧头部固定 24 字节:

偏移 长度 内容
0 4 pcs\0
4 2 协议版本,当前 13
6 2 Kind,见 protocol.go
8 8 非零 request ID
16 4 保留的 stream ID,当前必须为 0
20 4 payload 字节数,最大 64 KiB

payload 中的字符串为 u32 长度 + 原始字节,数组为 u32 元素数 + 元素,字段按序排列,不允许尾随字节。Reader 返回的 payload 借用其缓冲区,仅在下一次 Read 之前有效。大请求由同一 request ID 的若干 Data 帧和最终请求帧组成,大响应由 Data 帧和最终 Reply 帧组成,组装总量上限 64 MiB。客户端最多保留 64 个未完成请求,上传及未完成响应分别限制为 128 MiB 逻辑 payload;已取消但仍由写协程持有的上传继续计费,上传超限返回 Busy,响应超限关闭连接。不同请求的分块可以交错;客户端在大上传块之间轮转调度普通请求,取消优先。服务端未完成的上传合计上限 128 MiB。

v10 为 WorkspaceWatch 增加独立游标、工作区相对路径事件和完整校准标记;IndexOpen 保留 previous 字段。语法高亮使用 TextMate 逐行词法状态,名称表同时传输类别和完整 scope 栈,SyntaxRelease 没有 trim 字段。GUI 与 server 必须同时更新。扩展协议使用 peb v18,扩展注册格式保持不变。文本搜索匹配按 start:u32, end:u32, line:u32, column:u32, previewStart:u32, preview:string 编码。previewStart 是预览在原文中的 UTF-8 字节偏移,供客户端准确高亮截断预览中的命中。

首个请求必须是空 Hello,服务端返回空 Reply。之后支持:

请求 payload Reply
WorkspaceOpen path:string id:u64, path:string, name:string
WorkspaceClose id:u64 空
DirectoryRead workspace:u64, path:string count:u32, {name:string, mode:u32}[]
DocumentOpen workspace:u64, path:string, mode:u32 id:u64, version:u64, content:string, offset:u64, size:u64, paged:u32
DocumentChange id:u64, baseVersion:u64, pageOffset:u64, start:u32, end:u32, text:string version:u64
DocumentRead id:u64, version:u64, offset:u64 content:string, offset:u64, size:u64, paged:u32
DocumentSave id:u64, version:u64 空
DocumentClose id:u64 空
DocumentMove id:u64, workspace:u64, path:string 空
ResourceCreate workspace:u64, path:string, directory:u32 空
ResourceRemove workspace:u64, path:string 空
ResourceRename workspace:u64, from:string, to:string 空
ResourceTransfer source:u64, target:u64, from:string, directory:string, flags:u32 destination:string
ResourceImport target:u64, source:string, directory:string, overwrite:u32 destination:string

directory 只接受 0/1;DocumentOpen mode 接受 0(路径)、1(检查文本)、2(用户确认以文本打开);ResourceTransfer flags 的 bit 0 表示移动,bit 1 表示碰撞时生成副本名称。DocumentMove 在文件系统移动完成后重定位打开的文档,保留其未保存缓冲和磁盘基线。二进制文件打开只校验普通文件,返回零文档 ID 和空内容。

v12 新增 ResourceImport:source 是服务端主机的绝对原生路径,directory 是目标工作区内的目录,overwrite 只接受 0/1。未确认覆盖时遇到同名资源返回 Conflict;确认后目录合并,同名文件替换。GUI 只在本地工作区将系统剪贴板文件传给此请求,远端工作区不能使用本机路径。GUI 与 server 必须同时更新。

路径相对于工作区,采用 /,禁止绝对路径、..、反斜杠和 NUL;DirectoryRead 额外允许 .。工作区根目录由服务端规范化并通过 os.Root 持有;WorkspaceOpen 的 ~ 和 ~/... 在服务端展开,绝不使用 GUI 的 home。文档初始版本为 1,每个有效 Change 递增一次;范围为 UTF-8 字节边界。每份 GUI 增量作为一个 DocumentChange 发送,可包含多个 Data 帧,只在完整请求到达后原子应用并确认一次版本;合并 GUI 编辑时不得跳过版本确认。v13 移除打开文本文件的大小上限:超过 4 MiB 的文件保留磁盘句柄,首次和 DocumentRead 每次只读取最多 64 KiB 的 UTF-8 分段,优先在换行处结束;超长行仍有界。offset 与 size 为 64 位逻辑字节偏移及文档总字节数,DocumentChange 的 start/end 相对于 pageOffset,普通文档的 pageOffset 为零。修改保存在磁盘编辑暂存文件及分段引用中,切换分段不保存原文件;DocumentSave 流式原子写回所有内容,并检查文件身份、大小及修改时间以检测外部变更。GUI 的分段模式仅对当前段执行查找、撤销与语法高亮,不把部分内容发送给 LSP。超过 4 MiB 的强制文本模式仍要求各分段是有效 UTF-8。连接关闭释放大文件句柄和暂存修改。普通内存文档保留每连接 128 MiB 总量、128 个文档及 32 个工作区预算;这些不等于进程 RSS 上限。

失败使用 Failure 帧:code:u32 + message:string。错误码为 Invalid、NotFound、Conflict、VersionMismatch、Busy、IO。协议头错误会关闭连接。文档与文件资源操作按完整请求的接收顺序执行,Service 长任务最多并发 48 个,任务持有的请求 payload 合计不超过 128 MiB。Cancel 使用被取消请求的 ID 和空 payload,中断对应任务并丢弃未完成上传;客户端超时后发送取消,忽略迟到响应。独立响应写协程在 64 KiB 分块间轮转发送,避免大下载阻塞接收请求或独占响应链路;队列及发送中最多 64 个响应、缓冲容量合计最多 128 MiB,超限对生产者施加背压。取消会丢弃已排队响应的剩余分块,正在发送的一帧允许完成。此预算不包含服务构建结果、文档存储和缓冲池的额外内存。已经执行的文件修改不能回滚,不允许自动重放。当前语法解析在一次解析完成后检查取消,工作区关闭撤销派生的 Git 根并回收相关流与索引。连接关闭释放所有连接资源,协议不保留可跨连接使用的会话或句柄。连接管理器只能重新打开工作区和文档,检查磁盘基线后恢复 GUI 内存中的编辑;禁止重放保存、资源修改、Git 写入或终端输入。

Service

Service payload 为 operation:u32 + root:string + operation payload。根目录只接受本连接打开的工作区或通过 Git 查询得到的仓库根;基于句柄的流、索引和解析操作的 root 为空。DirectoryBrowse 的 root 为空,用于选择项目;directory 接受服务端路径与 ~,返回规范化路径、上级路径和按名称排序的子目录(含指向目录的符号链接),不创建工作区或改变已有文档。进程运行、路径规范化、PATH 查找均在服务端执行。响应仍使用 Reply/Data/Failure。

ConfigurationRead 与 SettingsSave 的 root 为空,分别读取和原子保存服务端用户配置目录下的 pencode/resources。读取返回目录路径及相对文件名和字节内容,包含 settings.json、highlights.json 与 themes/ 下的 JSON/JSONC 文件;总量限制 16 MiB、4096 个文件。保存只接受 JSON 对象并替换 settings.json,不接受文件名或目录参数。GUI 在打开远程项目时使用这份配置,系统字体仍由 GUI 主机提供。

WorkspaceWatch 首次调用安装根目录的原生监听:macOS 使用 FSEvents,Windows 使用递归 ReadDirectoryChangesW,Linux 使用 inotify;不依赖 fsnotify。事件统一进入文件服务的有界日志,由编辑器和扩展分别消费。每个订阅以 after 游标读取,首次或游标过期返回 reset=1,要求重新校准;慢订阅者不会抢走其他订阅者的事件。首次返回目录树、Git 状态和仓库集合三个变化位用于初始快照;后续调用阻塞到有事件或请求被取消。事件按 200 ms 固定窗口合并,不丢弃窗口内的尾部变化;持续写入也会定期交付,空闲时没有轮询或定时唤醒。跳过 node_modules、dist 以及 Git 的对象、日志、hooks 目录和锁文件。普通文件增删只使目录树与 Git 状态失效,目录或 .git 结构变化才重新发现仓库。工作区关闭或连接断开时释放监听。原生事件溢出时重建监听并强制完整校准;其他监听失败会释放失效实例,GUI 在首次失败时请求校准,以 100 ms 起步、上限 5 s 的指数退避重试,恢复后再校准一次。已有扫描与 Git 任务期间的变化合并成一次待刷新状态。日志最多 512 条记录,单批最多 128 个不同路径,溢出返回 reset。files 编码为 count:u32 + {path:string, op:u32, directory:u32}[count];path 为工作区相对路径,使用 / 分隔。op 位依次为创建、写入、删除、重命名、元数据变化;重命名可拆成旧路径和新路径事件。changes 位依次为目录树、Git 状态、仓库集合。

IndexOpen 的 previous=0 强制完整扫描;previous 非零时使用该成功快照与同一原生监听器积累的脏目录提示,只重读变化目录的直接子项,复用未变化子树,新目录才递归扫描。旧索引在新快照提交前继续支持文件搜索,GUI 提交后通过 IndexClose 释放旧句柄;每个工作区最多保留可见和在建两份索引,每连接索引预算为 64 个。提示独立于通知保留,直到创建下一份索引,并绑定最近启动的索引 ID;从更旧快照更新时完整扫描,避免取消的中间快照吞掉变化。最多保存 128 个目录,超限、事件溢出、监听器更换、缺少成功快照或上次扫描失败时退回完整扫描。自动更新在后台构建新树,成功后整体替换 GUI 快照,失败时保留已有树,不覆盖打开文档与未保存编辑。显式重新加载始终完整扫描,可用于校准未收到系统通知的变化。索引分页仍传输完整快照;此优化主要减少磁盘遍历与路径分配,不是增量传输协议。

operation 参数 Reply
DirectoryBrowse directory:string(root 为空) path:string, parent:string, count:u32, {name:string}[](只含子目录)
ConfigurationRead 空 directory:string, count:u32, {path:string, data:bytes}[]
SettingsSave data:bytes(JSON object) 空
GitCommand args:string[] output:bytes
GitRepositories 空 count:u32, {root:string}[](项目及其子目录内的仓库)
WorkspaceWatch after:u64(首次为 0;root 为工作区目录) version:u64, changes:u32, reset:u32, files[]
FileRead path:string, links:u32, limit:u32 content:bytes
FileSave path:string, diskBaseline:string, result:string 空
DiffPatch left:bytes, right:bytes unifiedPatch:bytes
ProcessOpen / TerminalOpen cols:u32, rows:u32, command:string, args:string[] stream:u64, stderrStream:u64
DebugAdapterOpen adapter:string(Delve / stdio / tcp), command:string, address:string, args:string[] stream:u64, stderrStream:u64
DebugTerminalOpen cwd:string, args:string[], count:u32, {key:string, present:u32, [value:string]}[] pid:u32, stream:u64, stderrStream:u64(零)
StreamRead stream:u64 eof:u32, data:bytes
StreamWrite stream:u64, data:bytes 空
PortList 空(root 为空) count:u32, {port:u32, host:string, pid:u32, process:string}[]
PortConnect port:u32, host:string(root 为空,远端 TCP 目标) stream:u64, stderrStream:u64(零)
StreamCloseWrite stream:u64(TCP 流) 空;关闭写方向,保留读取响应
StreamResize stream:u64, cols:u32, rows:u32 空
StreamClose / StreamWait stream:u64 空;Wait 非零退出码为 Failure
IndexOpen previous:u64(0:完整扫描;非零:基于该索引校准,保留其查询句柄直到 IndexClose) index:u64
IndexNext index:u64, offset:u32 done:u32, warning:string, count:u32, {path:string, name:string, depth:u32, directory:u32}[]
IndexClose index:u64 空
PathSearch index:u64, query:string, preferred:string[] paths:string[]
SyntaxAnalyze parser:u64, baseVersion:u64, filename:string, start:u32, end:u32, insert:string version:u64, language:string, captures(见下)
SyntaxRelease parser:u64 空
ExtensionList 空 directory:string, count:u32, ExtensionInfo[]
ExtensionLoad id:string handle:u64, ExtensionInfo, contributions:bytes, diagnostics:string
ExtensionBegin 空 upload:u64
ExtensionWrite upload:u64, path:string, offset:u64, mode:u32, final:u32, data:bytes 空;data 最大 32 KiB
ExtensionPrepare upload:u64 handle:u64, ExtensionInfo, contributions:bytes, diagnostics:string
ExtensionResources handle:u64, limit:u32, count:u32, path:string[] count:u32, {path:string, data:bytes}[];返回请求路径的有序前缀
ExtensionResource handle:u64, path:string, limit:u32 data:bytes
ExtensionEnable id:string, enabled:u32 enabled 时返回待提交注册;禁用时返回 ExtensionInfo
ExtensionCommit handle:u64 ExtensionInfo
ExtensionAbort handle:u64 空
ExtensionRemove id:string 空
ExtensionProcess handle:u64 stream:u64, stderrStream:u64
ExtensionLanguageProcess handle:u64, contributionID:string stream:u64, stderrStream:u64

所有布尔值只取 0/1。FileRead links=1 返回 Git 工作树中符号链接自身的文本,并把缺失文件视为空;普通源码读取跟随工作区内的链接,通过 os.Root 拒绝越界。FileSave 检查磁盘原文,写临时文件并替换。TerminalOpen 不使用 command/args,stderrStream 为零,因为 PTY 合并输出。

每条流有八个 32 KiB 服务端缓冲,输出窗口最多 256 KiB,按需接收并施加背压;StreamRead 等待首批数据后,立即合并已有数据返回(最多 256 KiB),不等待填满窗口;StreamWrite 最大 256 KiB,客户端串行发送完整 Write 内的批次,保持并发写入的消息顺序;每连接最多 16 条流(普通进程占 stdout、stderr 两条,PTY 占一条)。流关闭会终止并回收进程;正常连接退出先让服务端清理资源,再由传输层执行超时终止。标准流保持 LSP 原始 JSON-RPC,工作台收到的双向请求语义保持不变。

端口转发复用连接内的流传输,每个 TCP 连接占一条流;创建 TCP 流时总流预算为 32 条,创建进程时仍为 16 条。每个转发最多并发 16 个 TCP 连接,工作区最多 128 项转发。PortConnect 接受合法主机名或 IP 地址,使用服务端 DNS 与网络环境连接目标;主机和端口直接传给 TCP dialer,不经过 shell。本地默认监听 127.0.0.1,用户可以为单个端口切换为监听所有网络接口。

PortList 在 Linux 读取 /proc/net/tcp{,6} 并关联 /proc/<pid>/fd、cmdline,在 macOS 使用 lsof;返回当前用户监听端口的地址、PID 与进程信息。Ports 面板始终启用基于进程的自动转发,每 3 秒刷新,跳过 SSH 端口和无法确定所属进程的监听。远端停止监听时回收自动转发,手动停止的端口会被抑制,直至检测到监听消失。无变化的前台轮询不分配内存或重建行。

Ports 面板按 VS Code Remote SSH 的端口表格交互组织:行内添加端口号或 host:port,显示标签、转发地址、协议、运行进程、可见性和来源。工具栏的 + 按钮用于添加转发;协议列点击切换 HTTP/HTTPS,可见性列点击切换本机/局域网;行内按钮提供复制地址、浏览器打开、更改本地端口、设置标签和停止转发,工具栏提供刷新。新建或断线重连时优先使用指定本地端口,占用时自动分配其他端口;更改本地端口先创建新监听,再释放旧监听,目标端口被占用时提示失败并保留原转发。输入支持 Enter 确认、Escape 取消;选中行支持上下导航、F2 修改标签、Delete 停止转发。

转发状态仅保留在当前会话内。临时断线重连保留当前会话的端口、实际本地端口、标签、协议与可见性;重新打开工作区时重新检测监听端口。连接断开、切换工作区或退出时关闭本地监听及活跃 TCP 连接。Ports 表头固定,只有端口列表纵向滚动。

索引每页最多 256 项,每工作区最多 262144 项,目录深度最多 256;不递归符号链接,跳过 .git、dist、node_modules。同根的新索引替换旧扫描。PathSearch 按历史顺序优先、随后按树顺序返回最多 128 个文件(包括需确认打开的未知或二进制类型),支持不区分大小写的子串;扫描期间可以查询已索引部分。

解析会话由客户端分配 ID,每连接最多 8 个,初始 baseVersion 为 0。增量范围采用 UTF-8 字节边界;结果只包含语言和 capture,不含颜色、字体、HTML、ECS 或 GPU 数据。captures 编码为 prefix:u32, removed:u32, inserted:u32 + {start:u32, end:u32, captureID:u32, [name:string, scopes:string]}[inserted]。保留上次结果的前 prefix 项,将之后的 removed 项替换为传回的 inserted 项,并将剩余后缀的起止位置加上本次源码字节长度变化。服务端比较解析后的真实 capture,允许多行注释等语法变化扩大替换范围;初次返回完整列表。名称表在解析会话内保留,captureID 从零递增;ID 首次出现时紧跟类别名称和空格分隔的完整 TextMate scope 栈,后续复用 ID。释放会话后清空 capture 和名称表。本地按主题和 capture 映射着色,主题切换不发送解析请求。

ExtensionInfo 按顺序编码为 id:string, name:string, version:string, publisher:string, description:string, entry:string, args:string[], disabled:u32, path:string, problem:string。路径属于服务端文件系统;GUI 仅用于展示,不据此读取或执行。contributions 使用现有 peb v18 编码,CS 与 peb 的帧版本独立。

扩展安装是单连接事务:同时最多两个暂存包;文件路径必须是有效相对路径,拒绝符号链接和特殊文件,单包最多 256 MiB / 4096 项。Prepare 在暂存目录执行 peb 注册;GUI 完成字体、主题和图标验证后调用 Commit 发布,失败调用 Abort 清理。禁用、卸载和连接关闭撤销资源句柄并回收扩展进程,未提交的暂存包随连接释放。禁用扩展的 Load 返回零句柄,不执行扩展或占用注册预算。

资源单份最大 32 MiB,一个扩展最多缓存 64 MiB,连接内扩展缓存合计最多 128 MiB。ExtensionResources 的 limit 是每份资源的字节限制,最多请求 4096 条不重复路径;返回请求的有序前缀,响应目标大小为 16 MiB,单份超过此值时单独返回。客户端继续请求剩余路径直到取完。GUI 缓存已验证的图片;每视图最多 64 张,单张 4 MiB、总计 8 MiB / 4 MP,每边不超过 2048 像素。自定义编辑器 SVG 按原始尺寸栅格化,避免图标采样倍率扩大图片预算。

ExtensionLanguageProcess 的 root 必须是本连接工作区,可执行程序中的相对路径由服务端基于已发布的扩展目录解析,cwd 为工作区。action 进程允许空 root,生命周期属于连接。

DocumentOpen 的 mode:0 仅检查文件路径,供二进制查看器使用;1 检查文本内容,遇到 NUL 或无效 UTF-8 时返回空文档(id=0);2 表示用户明确选择代码编辑器,读取内容并将无效 UTF-8 替换为 U+FFFD。路径查看器和未确认的文件不会创建文本模型。

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

View Source
const (
	Version    = 13
	HeaderSize = 24
	MaxPayload = 64 << 10
	MaxMessage = 64 << 20
	ChunkSize  = 32 << 10
	// StreamWindow bounds both buffered process output and each stream RPC.
	StreamWindow = 256 << 10
)
View Source
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.

View Source
const TextPagingThreshold = 4 << 20
View Source
const TextSearchFileLimit = 2 << 20
View Source
const TextSearchFilesLimit = 65536
View Source
const TextSearchLimit = 2000

Variables

View Source
var ErrProtocol = errors.New("pencode: invalid client/server message")

Functions

func EncodeExtension

func EncodeExtension(e *Encoder, i ExtensionInfo)

func IsBinaryFile

func IsBinaryFile(name string) bool

IsBinaryFile is a cheap search prefilter. Unknown types still undergo content checks during search, even though opening them requires an editor choice.

func IsTextFile

func IsTextFile(name string) bool

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

func ValidPortHost(host string) bool

Hosts are passed directly to the remote TCP dialer, never to a shell.

Types

type Code

type Code uint32
const (
	Invalid Code = iota + 1
	NotFound
	Conflict
	VersionMismatch
	Busy
	IO
)

type Decoder

type Decoder struct {
	Err    error
	Buffer []byte
}

func (*Decoder) Bytes

func (d *Decoder) Bytes() []byte

func (*Decoder) DocumentPage

func (d *Decoder) DocumentPage() DocumentPage

func (*Decoder) Done

func (d *Decoder) Done() error

func (*Decoder) String

func (d *Decoder) String() string

func (*Decoder) U32

func (d *Decoder) U32() uint32

func (*Decoder) U64

func (d *Decoder) U64() uint64

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 DocumentPage struct {
	Offset, Size uint64
	Paged        bool
}

type Encoder

type Encoder struct{ Buffer []byte }

Encoder appends into caller-owned storage and can be reset without allocating.

func (*Encoder) Bytes

func (e *Encoder) Bytes(v []byte)

func (*Encoder) DocumentPage

func (e *Encoder) DocumentPage(p DocumentPage)

func (*Encoder) Reset

func (e *Encoder) Reset()

func (*Encoder) String

func (e *Encoder) String(v string)

func (*Encoder) U32

func (e *Encoder) U32(v uint32)

func (*Encoder) U64

func (e *Encoder) U64(v uint64)

type Entry

type Entry struct {
	Name string
	Mode uint32
}

type Error

type Error struct {
	Message string
	Code    Code
}

func (*Error) Error

func (e *Error) Error() string

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 Frame

type Frame struct {
	Payload []byte
	ID      uint64
	Stream  uint32
	Kind    Kind
}

type IndexEntry

type IndexEntry struct {
	Path, Name string
	Depth      int
	Directory  bool
}

type Kind

type Kind uint16
const (
	Hello Kind = iota + 1
	WorkspaceOpen
	WorkspaceClose
	DocumentOpen
	DocumentChange
	DocumentSave
	DocumentClose
	DocumentMove
	DocumentRead
	DirectoryRead
	ResourceCreate
	ResourceRemove
	ResourceRename
	ResourceTransfer
	ResourceImport
	Service
	Cancel
	Reply
	Data
	Failure
)

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
)

type Port

type Port struct {
	Host    string
	Process string
	PID     uint32
	Number  uint16
}

type Reader

type Reader struct {
	Source io.Reader
	// contains filtered or unexported fields
}

func (*Reader) Read

func (r *Reader) Read() (Frame, error)

type SearchDocument

type SearchDocument struct{ Path, Content string }

type SearchFile

type SearchFile struct {
	Path, Digest string
	Matches      []TextMatch
	Count        int
}

type SearchResult

type SearchResult struct {
	Files     []SearchFile
	Truncated bool
	Skipped   int
}

type TerminalCommand

type TerminalCommand struct {
	Env       map[string]*string
	Directory string
	Args      []string
}

type TextMatch

type TextMatch struct {
	Preview                  string
	Start, End, Line, Column int
	PreviewStart             int
}

type Workspace

type Workspace struct {
	Path, Name string
	ID         uint64
}

type WorkspaceChange

type WorkspaceChange uint32
const (
	WorkspaceTreeChanged WorkspaceChange = 1 << iota
	WorkspaceGitChanged
	WorkspaceRepositoriesChanged
)

type Writer

type Writer struct {
	Target io.Writer
	// contains filtered or unexported fields
}

func (*Writer) Write

func (w *Writer) Write(kind Kind, id uint64, payload []byte) error

Jump to

Keyboard shortcuts

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