usecase

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2026 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultMaxBatchTUIReal   = 100
	DefaultMaxBatchTUIDryRun = 1000
)
View Source
const (
	DefaultMaxBatchReal   = 50
	DefaultMaxBatchDryRun = 500
)
View Source
const (
	DefaultPreviewMaxMessages = 600
)

Variables

View Source
var ErrPreviewEntryTooLong = errors.New("preview entry exceeds max line size")

Functions

func EffectiveMaxBatch

func EffectiveMaxBatch(flagChanged bool, configured int, dryRun bool) int

func EffectiveMaxBatchWithDefaults

func EffectiveMaxBatchWithDefaults(flagChanged bool, configured int, dryRun bool, realDefault, dryRunDefault int) int

func IsPreviewNoiseText

func IsPreviewNoiseText(v string) bool

func ParsePreviewLine

func ParsePreviewLine(line string) (role string, text string)

Types

type AgentsExplainInput added in v0.3.2

type AgentsExplainInput struct {
	CWD string
}

AgentsExplainInput controls AGENTS.md explain behavior.

type AgentsExplainResult added in v0.3.2

type AgentsExplainResult struct {
	CWD     string                `json:"cwd"`
	Sources []AgentsExplainSource `json:"sources"`
	Rules   []AgentsExplainRule   `json:"rules"`
	Summary AgentsExplainSummary  `json:"summary"`
}

AgentsExplainResult is the normalized AGENTS.md explain output.

func ExplainAgents added in v0.3.2

func ExplainAgents(in AgentsExplainInput) (AgentsExplainResult, error)

ExplainAgents discovers AGENTS.md sources and computes effective/shadowed rules.

type AgentsExplainRule added in v0.3.2

type AgentsExplainRule struct {
	ID         string `json:"id"`
	Key        string `json:"key"`
	Text       string `json:"text"`
	SourcePath string `json:"source_path"`
	Line       int    `json:"line"`
	Priority   int    `json:"priority"`
	Status     string `json:"status"`
	ShadowedBy string `json:"shadowed_by,omitempty"`
}

AgentsExplainRule is one extracted rule line.

type AgentsExplainSource added in v0.3.2

type AgentsExplainSource struct {
	Path     string `json:"path"`
	Priority int    `json:"priority"`
}

AgentsExplainSource is one discovered AGENTS.md source.

type AgentsExplainSummary added in v0.3.2

type AgentsExplainSummary struct {
	Sources   int `json:"sources"`
	Rules     int `json:"rules"`
	Effective int `json:"effective"`
	Shadowed  int `json:"shadowed"`
}

AgentsExplainSummary reports aggregate counters.

type AuditSink

type AuditSink interface {
	NewBatchID() (string, error)
	WriteActionLog(logFile string, rec audit.ActionRecord) error
}

AuditSink appends action records and can allocate operation batch IDs.

type DeleteActionInput

type DeleteActionInput struct {
	Sessions        []session.Session
	Selector        session.Selector
	DryRun          bool
	Confirm         bool
	Yes             bool
	Hard            bool
	SessionsRoot    string
	TrashRoot       string
	MaxBatch        int
	MaxBatchChanged bool
	RealDefault     int
	DryRunDefault   int
	Executor        DeleteExecutor
	LogFile         string
	AuditSink       AuditSink
	Now             time.Time
}

type DeleteActionResult

type DeleteActionResult struct {
	Summary         session.DeleteSummary
	AppliedMaxBatch int
	BatchID         string
	LogError        error
}

func RunDeleteAction

func RunDeleteAction(in DeleteActionInput) (DeleteActionResult, error)

type DeleteExecutor

type DeleteExecutor interface {
	Execute(candidates []session.Session, sel session.Selector, opts session.DeleteOptions) (session.DeleteSummary, error)
}

DeleteExecutor executes delete workflow over selected sessions.

type DeleteSelectInput added in v0.3.2

type DeleteSelectInput struct {
	SessionsRoot string
	Selector     session.Selector
	Now          time.Time
	Repository   core.SessionRepository
}

type DeleteSelectResult added in v0.3.2

type DeleteSelectResult struct {
	Sessions      []session.Session
	AffectedBytes int64
}

func SelectDeleteSessions added in v0.3.2

func SelectDeleteSessions(in DeleteSelectInput) (DeleteSelectResult, error)

type DoctorCheck

type DoctorCheck struct {
	Name   string
	Level  DoctorLevel
	Detail string
}

func CheckSessionHostPaths

func CheckSessionHostPaths(in DoctorHostPathInput) DoctorCheck

type DoctorHostPathInput

type DoctorHostPathInput struct {
	SessionsRoot string
	SessionsErr  error
	Repository   core.SessionRepository
	CompactPath  func(string, int) string
}

type DoctorLevel

type DoctorLevel string
const (
	DoctorPass DoctorLevel = "PASS"
	DoctorWarn DoctorLevel = "WARN"
	DoctorFail DoctorLevel = "FAIL"
)

type DoctorRiskInput

type DoctorRiskInput struct {
	SessionsRoot   string
	SampleLimit    int
	IntegrityCheck bool
	Repository     core.SessionRepository
	Evaluator      core.RiskEvaluator
}

type DoctorRiskReport

type DoctorRiskReport struct {
	SessionsTotal  int                `json:"sessions_total"`
	RiskTotal      int                `json:"risk_total"`
	RiskRate       float64            `json:"risk_rate"`
	High           int                `json:"high"`
	Medium         int                `json:"medium"`
	IntegrityCheck bool               `json:"integrity_check"`
	SampleLimit    int                `json:"sample_limit"`
	Samples        []DoctorRiskSample `json:"samples"`
}

func DoctorRisk

func DoctorRisk(in DoctorRiskInput) (DoctorRiskReport, error)

type DoctorRiskSample

type DoctorRiskSample struct {
	Level     session.RiskLevel  `json:"level"`
	Reason    session.RiskReason `json:"reason"`
	Health    session.Health     `json:"health"`
	SessionID string             `json:"session_id"`
	Path      string             `json:"path"`
	Detail    string             `json:"detail,omitempty"`
}

type GroupInput

type GroupInput struct {
	SessionsRoot string
	Selector     session.Selector
	Now          time.Time
	By           string
	SortBy       string
	Order        string
	Offset       int
	Limit        int
	Repository   core.SessionRepository
}

type GroupStat

type GroupStat struct {
	Group     string `json:"group"`
	Count     int    `json:"count"`
	SizeBytes int64  `json:"size_bytes"`
	Latest    string `json:"latest"`
}

func BuildGroupStats

func BuildGroupStats(sessions []session.Session, by, sortBy, order string) ([]GroupStat, error)

func GroupSessions

func GroupSessions(in GroupInput) ([]GroupStat, error)

type ListInput

type ListInput struct {
	SessionsRoot string
	Selector     session.Selector
	Now          time.Time
	SortBy       string
	Order        string
	Offset       int
	Limit        int
	Repository   core.SessionRepository
}

type ListResult

type ListResult struct {
	Total int
	Items []session.Session
}

func ListSessions

func ListSessions(in ListInput) (ListResult, error)

type LoadTUISessionsInput

type LoadTUISessionsInput struct {
	SessionsRoot string
	ScanLimit    int
	ViewLimit    int
	Now          time.Time
	Repository   core.SessionRepository
	Evaluator    core.RiskEvaluator
}

LoadTUISessionsInput describes TUI session-loading constraints.

type LoadTUISessionsResult

type LoadTUISessionsResult struct {
	Total int
	Items []session.Session
}

LoadTUISessionsResult is the normalized TUI session set.

func LoadTUISessions

func LoadTUISessions(in LoadTUISessionsInput) (LoadTUISessionsResult, error)

LoadTUISessions loads sessions for TUI and applies risk-first ordering.

type PreviewMessage

type PreviewMessage struct {
	Role string
	Text string
}

func ExtractPreviewMessages

func ExtractPreviewMessages(path string, maxMessages int) ([]PreviewMessage, error)

type RestoreActionInput

type RestoreActionInput struct {
	Sessions           []session.Session
	Selector           session.Selector
	DryRun             bool
	Confirm            bool
	Yes                bool
	SessionsRoot       string
	TrashSessionsRoot  string
	MaxBatch           int
	MaxBatchChanged    bool
	RealDefault        int
	DryRunDefault      int
	AllowEmptySelector bool
	Executor           RestoreExecutor
	LogFile            string
	AuditSink          AuditSink
	Now                time.Time
}

type RestoreActionResult

type RestoreActionResult struct {
	Summary         RestoreSummary
	AppliedMaxBatch int
	BatchID         string
	LogError        error
}

func RunRestoreAction

func RunRestoreAction(in RestoreActionInput) (RestoreActionResult, error)

type RestoreExecutor

type RestoreExecutor interface {
	Execute(candidates []session.Session, sel session.Selector, opts session.RestoreOptions) (session.RestoreSummary, error)
}

RestoreExecutor executes restore workflow over selected sessions.

type RestoreSelectInput added in v0.3.2

type RestoreSelectInput struct {
	TrashSessionsRoot string
	Selector          session.Selector
	BatchID           string
	LogFile           string
	Now               time.Time
	Repository        core.SessionRepository
	IDsForBatch       func(logFile, batchID string) ([]string, error)
}

type RestoreSelectResult added in v0.3.2

type RestoreSelectResult struct {
	Sessions      []session.Session
	AffectedBytes int64
}

func SelectRestoreSessions added in v0.3.2

func SelectRestoreSessions(in RestoreSelectInput) (RestoreSelectResult, error)

type RestoreSummary

type RestoreSummary = session.RestoreSummary

RestoreSummary is restore execution summary.

type SessionDeleteExecutor

type SessionDeleteExecutor struct{}

SessionDeleteExecutor is the default delete executor.

func (SessionDeleteExecutor) Execute

Execute runs the session delete operation.

type SessionRestoreExecutor

type SessionRestoreExecutor struct{}

SessionRestoreExecutor is the default restore executor.

func (SessionRestoreExecutor) Execute

Execute runs the restore operation.

Jump to

Keyboard shortcuts

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