processor

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package processor provides functionality for processing agent-sync tasks

Package processor provides functionality for processing agent-sync tasks

Package processor provides functionality for processing agent-sync tasks

Package processor provides functionality for processing agent-sync tasks

Package processor provides functionality for processing agent-sync tasks

Package processor provides functionality for processing agent-sync tasks

Package processor provides functionality for processing agent-sync tasks

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsDirectory

func IsDirectory(path string) bool

IsDirectory determines if a path represents a directory by checking if it ends with a path separator

func RemoveFileExtension

func RemoveFileExtension(path string) string

RemoveFileExtension returns the filename without its extension

Types

type BaseProcessor

type BaseProcessor struct {
	// contains filtered or unexported fields
}

BaseProcessor contains common functionality for all task processors

func NewBaseProcessor

func NewBaseProcessor(fs util.FileSystem, logger *zap.Logger, absInputRoot string, registry *agent.Registry, userScope bool) *BaseProcessor

NewBaseProcessor creates a new BaseProcessor with the given parameters

type CommandProcessor

type CommandProcessor struct {
	*BaseProcessor
}

CommandProcessor processes command tasks

func NewCommandProcessor

func NewCommandProcessor(base *BaseProcessor) *CommandProcessor

NewCommandProcessor creates a new CommandProcessor

func (*CommandProcessor) GetOutputPath

func (p *CommandProcessor) GetOutputPath(agent agent.Agent, outputPath string) string

GetOutputPath returns the appropriate output path for command tasks

func (*CommandProcessor) Process

func (p *CommandProcessor) Process(inputs []string, cfg *OutputConfig) (*TaskResult, error)

Process implements the task processing for command task type

type FSAdapter

type FSAdapter struct {
	// contains filtered or unexported fields
}

FSAdapter bridges util.FileSystem to template.FileResolver.

func NewFSAdapter

func NewFSAdapter(fs util.FileSystem) *FSAdapter

NewFSAdapter creates a new FSAdapter

func (*FSAdapter) Exists

func (a *FSAdapter) Exists(path string) bool

func (*FSAdapter) Glob

func (a *FSAdapter) Glob(patterns []string) ([]string, error)

func (*FSAdapter) Read

func (a *FSAdapter) Read(path string) ([]byte, error)

func (*FSAdapter) ResolvePath

func (a *FSAdapter) ResolvePath(path string) string

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager orchestrates task execution based on loaded configuration.

func NewManager

func NewManager(cfgPath string, logger *zap.Logger, output log.OutputWriter) (*Manager, error)

NewManager creates a new Manager by loading configuration from the given path.

func (*Manager) Apply

func (m *Manager) Apply(dryRun, force bool) error

Apply executes the apply pipeline for all projects and user scope.

type MemoryProcessor

type MemoryProcessor struct {
	*BaseProcessor
}

MemoryProcessor processes memory tasks

func NewMemoryProcessor

func NewMemoryProcessor(base *BaseProcessor) *MemoryProcessor

NewMemoryProcessor creates a new MemoryProcessor

func (*MemoryProcessor) GetOutputPath

func (p *MemoryProcessor) GetOutputPath(agent agent.Agent, outputPath string) string

GetOutputPath returns the appropriate output path for memory tasks

func (*MemoryProcessor) Process

func (p *MemoryProcessor) Process(inputs []string, cfg *OutputConfig) (*TaskResult, error)

Process implements the task processing for memory task type

type ModeProcessor added in v0.0.4

type ModeProcessor struct {
	*BaseProcessor
}

ModeProcessor processes mode tasks

func NewModeProcessor added in v0.0.4

func NewModeProcessor(base *BaseProcessor) *ModeProcessor

NewModeProcessor creates a new ModeProcessor

func (*ModeProcessor) GetOutputPath added in v0.0.4

func (p *ModeProcessor) GetOutputPath(agent agent.Agent, outputPath string) string

GetOutputPath returns the appropriate output path for mode tasks

func (*ModeProcessor) Process added in v0.0.4

func (p *ModeProcessor) Process(inputs []string, cfg *OutputConfig) (*TaskResult, error)

Process implements the task processing for mode task type

type OutputConfig

type OutputConfig struct {
	Agent agent.Agent
	// RelPath is the relative path from the output directory or file where the processed content will be written
	// If the path ends with "/", it indicates a directory output
	// If it does not end with "/", it indicates a file output
	RelPath     string
	IsDirectory bool
	AgentName   string // Original agent name from config
}

OutputConfig encapsulates output configuration settings

type Pipeline

type Pipeline struct {
	// Task contains the configuration for the current task being processed,
	// including its name, type, inputs, targets, and concatenation settings.
	Task config.Task

	// AbsInputRoot is the base directory path for resolving input files and determining
	// output paths. For user-scoped tasks, it represents the user's home directory.
	AbsInputRoot string

	// AbsOutputDirs is a list of output directory paths where the processed
	// content will be written. Each output directory will receive a copy of the output.
	AbsOutputDirs []string

	// UserScope indicates whether the task operates in user scope (true) or project
	// scope (false). This affects output path resolution and file organization.
	UserScope bool

	// DryRun indicates whether the pipeline should actually write files to disk.
	// When true, the pipeline will simulate file operations but not actually write files.
	DryRun bool

	// Force indicates whether to overwrite files without confirmation.
	// When true, existing files will be overwritten without prompting.
	Force bool
	// contains filtered or unexported fields
}

Pipeline represents the processing pipeline for a single task.

func NewPipeline

func NewPipeline(task config.Task, absInputRoot string, outputDirs []string, userScope bool, dryRun bool, force bool, logger *zap.Logger, output log.OutputWriter) (*Pipeline, error)

NewPipeline creates a new Pipeline with context and registers built-in agents.

func (*Pipeline) Execute

func (p *Pipeline) Execute() error

Execute runs the full pipeline: resolve inputs, process based on task type, and write outputs. This implementation uses polymorphism through TaskProcessor interface instead of type switching.

type ProcessedFile

type ProcessedFile struct {

	// Content is the processed file content
	Content string
	// AgentName is the name of the agent for this file
	AgentName string
	// contains filtered or unexported fields
}

ProcessedFile represents a processed output file

type ProcessorStrategy added in v0.0.4

type ProcessorStrategy[T any] interface {
	Parse(absPath string, raw []byte) (T, error)
	GetContent(item T) string
	SetContent(item T, content string) T
	FormatOne(a agent.Agent, item T) (string, error)
	FormatMany(a agent.Agent, items []T) (string, error)
}

ProcessorStrategy provides the per-task-type behavior plugged into the generic driver. T is the parsed item type (e.g., model.Command, model.Mode, or string for memory). The driver performs templating centrally using hooks to read/write the "content" portion.

type TaskProcessor

type TaskProcessor interface {
	// Process handles task-specific processing of inputs and returns the processed result
	Process(inputs []string, cfg *OutputConfig) (*TaskResult, error)

	// GetOutputPath returns the appropriate output path for the given agent and task type
	GetOutputPath(agent agent.Agent, outputPath string) string
}

TaskProcessor defines the interface for processing different types of tasks

type TaskResult

type TaskResult struct {
	Files []ProcessedFile
}

TaskResult represents the result of processing a task

Jump to

Keyboard shortcuts

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