edit

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrStaleRevision = errors.New("edit rejected: stale revision")

ErrStaleRevision is returned by ReplaceRange when expectedRevision no longer matches the workspace's current revision.

Functions

func FormatterName added in v0.0.7

func FormatterName(root string, path string) (string, bool)

FormatterName names the formatter an edit to path would run, if any.

Types

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service owns mutation operations.

func NewService

func NewService(
	workspaceManager *workspace.Manager,
	index *code.Index,
	diagnosticService *diagnostics.Service,
	runner *jobs.Runner,
) *Service

func (*Service) Apply

Apply performs several edits as one unit: all of them land, or none do.

jade edits one site per call, and adding a single tool to this repository touches six files. That made every such task cost six calls and six revision round trips, so the work got scripted in `python3` instead — bypassing revision checks entirely. That fallback caused the only outage of the dogfooding session: a scripted replace hit the wrong anchor, left a duplicate import, and broke the MCP server's own build.

Atomicity here is rollback-based rather than write-to-temp: every touched file is snapshotted before the first write and restored if any later step fails. That reuses the existing single-edit primitives unchanged, which matters more than avoiding a brief window of partial state in a single-process tool.

func (*Service) CreateFile

func (s *Service) CreateFile(path string, content string) (protocol.EditResponse, error)

CreateFile writes a brand-new file — docs/scope.md §29's MVP editing operation that, alongside DeleteFile, had no implementation at all until now. No revision precondition applies (there is nothing prior to be stale relative to); CreateFile itself refuses to overwrite an existing file.

func (*Service) DeleteFile

func (s *Service) DeleteFile(path string) (protocol.EditResponse, error)

DeleteFile removes a file — the other half of docs/scope.md §29's MVP gap.

func (*Service) DeleteSymbol

func (s *Service) DeleteSymbol(path string, symbolID string, expectedRevision string) (protocol.EditResponse, error)

DeleteSymbol removes a declaration entirely, with the same revision precondition as every other mutation.

func (*Service) Insert added in v0.0.2

func (s *Service) Insert(path string, expectedRevision string, anchor string, position string, text string) (protocol.EditResponse, error)

Insert adds text without replacing anything — the additive counterpart to ReplaceText, carrying the same revision precondition.

It existed only as an `apply` op until now, which meant additive work (a new test function, a section appended to a document) had no tool of its own and was reported as faster to do with a plain file edit. That is the same failure mode the op was written for: when jade has no cheap way to add something, adding it happens somewhere jade cannot see.

func (*Service) Rename

func (s *Service) Rename(path string, symbolID string, newName string, expectedRevision string) (protocol.EditResponse, error)

Rename renames a symbol repository-wide via gopls (7.2). It differs from every other mutation here in that jade does not compute the edit: the language server does, and jade's job is the revision precondition, the changed-file accounting and the validation job that follows. Because a rename touches files the caller never named, the revision check matters more here than anywhere else.

func (*Service) ReplaceFile

func (s *Service) ReplaceFile(path string, content string) (protocol.EditResponse, error)

ReplaceFile overwrites an existing file's entire contents.

Unlike CreateFile it reports RemovedLines, because the caller is destroying content and the size of what was destroyed is the one fact they cannot recover from the response otherwise.

func (*Service) ReplaceRange

func (s *Service) ReplaceRange(path string, expectedRevision string, start int, end int, newCode string) (protocol.EditResponse, error)

func (*Service) ReplaceSymbol

func (s *Service) ReplaceSymbol(symbolID string, expectedRevision string, newCode string) (protocol.EditResponse, error)

func (*Service) ReplaceText

func (s *Service) ReplaceText(path string, expectedRevision string, oldText string, newText string) (protocol.EditResponse, error)

ReplaceText replaces an exact, unique string — the string-anchored counterpart to ReplaceRange. It carries the same revision precondition: anchoring by text removes the line-drift problem, not the concurrent-edit problem.

Jump to

Keyboard shortcuts

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