Documentation
¶
Index ¶
- Constants
- Variables
- type Action
- type AddFile
- type ApplyInput
- type ApplyOutput
- type Change
- type DeleteFile
- type DiffInput
- type DiffOutput
- type DiffResult
- type DiffStats
- type EmptyInput
- type EmptyOutput
- type Hunk
- type Service
- type Session
- func (s *Session) Add(ctx context.Context, path string, data []byte) error
- func (s *Session) ApplyPatch(ctx context.Context, patchText string, directory ...string) error
- func (s *Session) Commit(ctx ...context.Context) error
- func (s *Session) Delete(ctx context.Context, path string) error
- func (s *Session) Move(ctx context.Context, src, dst string) error
- func (s *Session) Rollback(ctx ...context.Context) error
- func (s *Session) Snapshot(ctx context.Context) ([]Change, error)
- func (s *Session) Update(ctx context.Context, path string, newData []byte) error
- type SnapshotOutput
- type UpdateChunk
- type UpdateFile
Constants ¶
const Name = "system/patch"
Name of the system/patch action service.
Variables ¶
var ErrNoChange = errors.New("no change between old and new")
Functions ¶
This section is empty.
Types ¶
type ApplyInput ¶
type ApplyInput struct {
Patch string `json:"patch" description:"Patch text to apply (either unified-diff or simplified patch format)"`
Workdir string `json:"workdir" description:"Required. Base directory for all relative patch paths"`
}
ApplyInput is the payload for Service.Apply
type ApplyOutput ¶
type ApplyOutput struct {
Stats DiffStats `json:"stats,omitempty"`
Status string `json:"status,omitempty"`
Error string `json:"error,omitempty"`
}
ApplyOutput summarises changes applied.
type Change ¶
type Change struct {
Kind string `json:"kind"`
OrigURL string `json:"origUrl,omitempty"`
URL string `json:"url,omitempty"`
Diff string `json:"diff,omitempty"`
}
Change represents a single tracked change in the active session.
type DeleteFile ¶
type DeleteFile struct{ Path string }
DeleteFile operation (*** Delete File: path).
type DiffInput ¶
type DiffInput struct {
OldContent string `json:"old" description:"Original content."`
NewContent string `json:"new" description:"Updated content."`
Path string `json:"path,omitempty" description:"Optional logical path used in patch headers (e.g., src/file.go)."`
ContextLines int `json:"contextLines,omitempty" description:"Patch context lines (default 3)."`
}
DiffInput is the payload for Service.Diff
type DiffOutput ¶
DiffOutput mirrors DiffResult for JSON tags.
type DiffResult ¶
type DiffStats ¶
DiffStats summarizes additions/removals in a patch string.
func GenerateDiff ¶
func GenerateDiff(oldContent, newContent []byte, filePath string, contextLines int) (string, DiffStats, error)
GenerateDiff produces a GNU unified diff between old and new file contents. It returns the diff string along with insertion/deletion statistics. If the two inputs are identical, an empty diff string is returned.
type EmptyOutput ¶
type EmptyOutput struct{}
type Hunk ¶
type Hunk interface {
// contains filtered or unexported methods
}
Hunk represents any high-level patch operation.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service exposes filesystem patching capabilities as a Fluxor action service. It is stateless – every method call operates with its own ephemeral Session.
func (*Service) Method ¶
func (s *Service) Method(name string) (svc.Executable, error)
Method maps method names to executable handlers.
func (*Service) Methods ¶
func (s *Service) Methods() svc.Signatures
Methods returns service method catalogue.
type Session ¶
func NewSession ¶
func NewSessionFor ¶
NewSessionFor creates a session with backups stored under a conversation-scoped folder. The layout is: file://<tmp>/agently/<convID>/onpatch-<uuid>
func (*Session) ApplyPatch ¶
type SnapshotOutput ¶
type SnapshotOutput struct {
Workdir string `json:"workdir,omitempty"`
Changes []Change `json:"changes,omitempty"`
Status string `json:"status,omitempty"`
Error string `json:"error,omitempty"`
}
SnapshotOutput lists the current uncommitted changes captured by the active session.
type UpdateChunk ¶
type UpdateChunk struct {
ChangeContext string // optional text after @@
OldLines []string // '-' and ' ' lines (without prefix)
NewLines []string // '+' and ' ' lines (without prefix)
IsEOF bool // true when *** End of File terminator is present
}
UpdateChunk represents a contiguous diff chunk inside an UpdateFile hunk.
type UpdateFile ¶
type UpdateFile struct {
Path string
MovePath string
Chunks []UpdateChunk
}
UpdateFile operation (*** Update File: path).