permission

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BashMetadata

type BashMetadata struct {
	Command       string // The command to execute
	Description   string // Optional description of what the command does
	RunBackground bool   // Whether to run in background
	LineCount     int    // Number of lines in the command
}

BashMetadata contains metadata for Bash command permission requests

type DiffLine

type DiffLine struct {
	Type      DiffLineType // Type of diff line
	Content   string       // Line content (without +/- prefix)
	OldLineNo int          // Line number in old file (0 if not applicable)
	NewLineNo int          // Line number in new file (0 if not applicable)
}

DiffLine represents a single line in a diff

func ParseDiffLines

func ParseDiffLines(unifiedDiff string) []DiffLine

ParseDiffLines parses unified diff text into structured DiffLine slices

type DiffLineType

type DiffLineType int

DiffLineType represents the type of a diff line

const (
	DiffLineContext  DiffLineType = iota // Unchanged line (context)
	DiffLineAdded                        // Added line (+)
	DiffLineRemoved                      // Removed line (-)
	DiffLineHunk                         // Hunk header (@@ ... @@)
	DiffLineMetadata                     // Metadata line (\ No newline at end of file)
)

type DiffMetadata

type DiffMetadata struct {
	OldContent   string     // Original file content
	NewContent   string     // New file content after modification
	UnifiedDiff  string     // Unified diff format
	Lines        []DiffLine // Parsed diff lines
	IsNewFile    bool       // Whether this is a new file creation
	PreviewMode  bool       // True to show content preview instead of diff (for Write tool)
	AddedCount   int        // Number of lines added
	RemovedCount int        // Number of lines removed
}

DiffMetadata contains diff information for file modifications

func GenerateDiff

func GenerateDiff(filePath, oldContent, newContent string) *DiffMetadata

GenerateDiff creates a DiffMetadata from old and new file content

func GenerateNewFileDiff

func GenerateNewFileDiff(filePath, content string) *DiffMetadata

GenerateNewFileDiff creates a DiffMetadata for a new file (all lines are additions)

func GeneratePreview

func GeneratePreview(filePath, content string, isNewFile bool) *DiffMetadata

GeneratePreview creates a DiffMetadata for content preview (used by Write tool) Shows the content directly without diff format

type PermissionRequest

type PermissionRequest struct {
	ID          string        // Unique request ID
	ToolName    string        // Name of the tool requesting permission
	FilePath    string        // File path being modified
	Description string        // Human-readable description of the action
	DiffMeta    *DiffMetadata // Diff metadata (for Edit/Write tools)
	BashMeta    *BashMetadata // Bash metadata (for Bash tool)
}

PermissionRequest represents a request for user permission before executing a tool

type PermissionResponse

type PermissionResponse struct {
	RequestID string // ID of the original request
	Approved  bool   // Whether the action was approved
}

PermissionResponse represents the user's response to a permission request

Jump to

Keyboard shortcuts

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