Documentation
¶
Overview ¶
Package lifecycle provides session lifecycle utilities for AE-ADK. It handles auto-cleanup on SessionEnd and work state persistence between sessions.
Index ¶
- func ActivatePersistentMode(projectDir, workflow, specID string, maxMinutes int) error
- func DeactivatePersistentMode(projectDir string) error
- func NewSessionCleanup(config CleanupConfig) *sessionCleanupImpl
- func NewWorkState(config WorkStateConfig) *workStateImpl
- type CleanupConfig
- type CleanupResult
- type PersistentMode
- type SessionCleanup
- type WorkState
- type WorkStateConfig
- type WorkStateData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ActivatePersistentMode ¶ added in v1.3.0
ActivatePersistentMode writes a persistent-mode.json file to mark the mode as active. projectDir is the root of the project (CWD from the hook input).
func DeactivatePersistentMode ¶ added in v1.3.0
DeactivatePersistentMode sets active=false in the persistent-mode.json file. If the file does not exist or cannot be read, the function returns nil (no-op).
func NewSessionCleanup ¶
func NewSessionCleanup(config CleanupConfig) *sessionCleanupImpl
NewSessionCleanup creates a new SessionCleanup instance.
func NewWorkState ¶
func NewWorkState(config WorkStateConfig) *workStateImpl
NewWorkState creates a new WorkState instance.
Types ¶
type CleanupConfig ¶
type CleanupConfig struct {
// TempDir is the directory for temporary files.
TempDir string
// CacheDir is the directory for cache files.
CacheDir string
// LogDir is the directory for log files.
LogDir string
// SessionLogPattern is the pattern for session log files to clean.
SessionLogPattern string
// PreserveState indicates whether to preserve .ae/state/*.json files.
PreserveState bool
}
CleanupConfig configures cleanup behavior.
func DefaultCleanupConfig ¶
func DefaultCleanupConfig() CleanupConfig
DefaultCleanupConfig returns the default cleanup configuration.
type CleanupResult ¶
type CleanupResult struct {
FilesDeleted int `json:"filesDeleted"`
DirsDeleted int `json:"dirsDeleted"`
BytesFreed int64 `json:"bytesFreed"`
Errors []string `json:"errors"`
Duration time.Duration `json:"duration"`
}
CleanupResult represents the result of cleanup operations.
type PersistentMode ¶ added in v1.3.0
type PersistentMode struct {
Active bool `json:"active"`
Workflow string `json:"workflow"`
SpecID string `json:"spec_id"`
StartedAt time.Time `json:"started_at"`
MaxDurationMinutes int `json:"max_duration_minutes"`
}
PersistentMode holds the persistent mode state for a project. When active, the stop hook blocks Claude from stopping so that the workflow can continue until a completion marker is detected or the max duration expires.
func CheckPersistentMode ¶ added in v1.3.0
func CheckPersistentMode(projectDir string) (*PersistentMode, error)
CheckPersistentMode reads the persistent-mode.json file and returns the current state. Returns (nil, nil) if the file does not exist.
func (*PersistentMode) IsExpired ¶ added in v1.3.0
func (m *PersistentMode) IsExpired() bool
IsExpired reports whether the persistent mode session has exceeded its maximum duration. Returns false when MaxDurationMinutes is 0 (no limit).
type SessionCleanup ¶
type SessionCleanup interface {
// CleanTempFiles removes temporary files from .ae/temp/.
CleanTempFiles() (*CleanupResult, error)
// ClearCaches clears session-specific caches.
ClearCaches() error
// GenerateCleanupReport generates a human-readable cleanup report.
GenerateCleanupReport() string
}
SessionCleanup handles SessionEnd cleanup.
type WorkState ¶
type WorkState interface {
// Save persists the work state to storage.
Save(state *WorkStateData) error
// Load retrieves the work state from storage.
Load() (*WorkStateData, error)
}
WorkState persists work state between sessions.
type WorkStateConfig ¶
type WorkStateConfig struct {
// StoragePath is the path for work state storage.
StoragePath string
}
WorkStateConfig configures work state persistence.
func DefaultWorkStateConfig ¶
func DefaultWorkStateConfig() WorkStateConfig
DefaultWorkStateConfig returns the default work state configuration.
type WorkStateData ¶
type WorkStateData struct {
ActiveFiles []string `json:"activeFiles,omitempty"`
ContextSummary string `json:"contextSummary,omitempty"`
Timestamp time.Time `json:"timestamp"`
}
WorkStateData represents work session state. Simplified to focus on crash recovery rather than file position tracking.