permission

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 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 AgentMetadata added in v1.2.0

type AgentMetadata struct {
	AgentName      string   // Name of the agent type (Explore, Plan, etc.)
	Description    string   // Agent description
	Model          string   // Model to be used by the agent
	PermissionMode string   // Permission mode (plan, default, dontAsk, etc.)
	Tools          []string // List of tools available to the agent
	Prompt         string   // The task prompt
	Background     bool     // Whether running in background
}

AgentMetadata contains metadata for Task permission requests

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)
	SkillMeta   *SkillMetadata // Skill metadata (for Skill tool)
	AgentMeta   *AgentMetadata // Agent metadata (for Task 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

type SkillMetadata added in v1.2.0

type SkillMetadata struct {
	SkillName   string   // Full skill name (namespace:name)
	Description string   // Skill description
	Args        string   // Optional arguments passed to the skill
	ScriptCount int      // Number of available scripts
	RefCount    int      // Number of reference files
	Scripts     []string // Script file names
	References  []string // Reference file names
}

SkillMetadata contains metadata for Skill permission requests

Jump to

Keyboard shortcuts

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