Documentation
¶
Overview ¶
Package commands provides a modular command registry for the iterate REPL. Each command group (session, git, safety, etc.) is in its own file.
Index ¶
- Variables
- func BuildProjectTree(repoPath string, maxDepth int) string
- func EvolutionHandler(fn func(Context, EvolutionContext) Result, evoCtx EvolutionContext) func(Context) Result
- func ExtractFirstMeaningfulLine(content string) string
- func FetchGoPkgDoc(pkg string) (string, error)
- func FormatProjectIndex(entries []IndexEntry) string
- func FormatTreeFromPaths(paths []string, maxDepth int) string
- func GenerateIterateMD(repoPath string) string
- func GetPendingImageAttachment() string
- func GetPendingTemplate() string
- func LastRunOutput() string
- func PreviewEdit(filename string, oldContent string, newContent string) error
- func RegisterASTCommands(r *Registry)
- func RegisterAgentCommands(r *Registry)
- func RegisterAll(r *Registry)
- func RegisterAnalysisCommands(r *Registry)
- func RegisterAutofixCommands(r *Registry)
- func RegisterBudgetCommands(r *Registry)
- func RegisterConfigCommands(r *Registry)
- func RegisterContextTemplateCommands(r *Registry)
- func RegisterDevCommands(r *Registry)
- func RegisterDocsCommands(r *Registry)
- func RegisterEvolutionCommands(r *Registry)
- func RegisterFileCommands(r *Registry)
- func RegisterGitCommands(r *Registry)
- func RegisterGitContextCommands(r *Registry)
- func RegisterGitHooksCommands(r *Registry)
- func RegisterGitHubCommands(r *Registry)
- func RegisterLearningCommands(r *Registry)
- func RegisterMemoryAnalyticsCommands(r *Registry)
- func RegisterMemoryCommands(r *Registry)
- func RegisterModeCommands(r *Registry)
- func RegisterProfileCommands(r *Registry)
- func RegisterSafetyCommands(r *Registry)
- func RegisterSessionCommands(r *Registry)
- func RegisterSnippetCommands(r *Registry)
- func RegisterTemplateCommands(r *Registry)
- func RegisterUtilityCommands(r *Registry)
- func StripHTMLTags(s string) string
- type AgentRuntime
- type Bookmark
- type Command
- type CommandInput
- type ConfigCallbacks
- type Context
- type DiffViewer
- func (dv *DiffViewer) BatchDiff(files []string) (approved []string, rejected []string, err error)
- func (dv *DiffViewer) ConfirmChange(filename string) (bool, error)
- func (dv *DiffViewer) ShowDiff(filename string, original []string, proposed []string)
- func (dv *DiffViewer) ShowGitDiff(filename string) error
- type EvolutionContext
- type IndexEntry
- type MCPServerEntry
- type Profile
- type PromptTemplate
- type REPLCallbacks
- type Registry
- type Result
- type RuntimeConfig
- type SafetyState
- type SessionCallbacks
- type Snapshot
- type SnapshotCallbacks
- type StateAccessors
- type TemplateCallbacks
- type TokenUsage
- type TreeNode
- type WatchCallbacks
Constants ¶
This section is empty.
Variables ¶
var BinaryExtensions = map[string]bool{ ".png": true, ".jpg": true, ".jpeg": true, ".gif": true, ".ico": true, ".svg": true, ".wasm": true, ".bin": true, ".exe": true, ".pdf": true, ".zip": true, ".tar": true, ".gz": true, ".so": true, ".a": true, ".dylib": true, ".dll": true, ".webp": true, ".mp4": true, ".mp3": true, }
var ErrUserQuit = errors.New("user quit")
ErrUserQuit is returned when the user chooses to quit during an interactive diff review session. Callers should handle this gracefully instead of calling os.Exit directly from library code.
var Stdout io.Writer = os.Stdout
Stdout is the default writer for commands.
Functions ¶
func BuildProjectTree ¶
func EvolutionHandler ¶
func EvolutionHandler(fn func(Context, EvolutionContext) Result, evoCtx EvolutionContext) func(Context) Result
EvolutionHandler wraps a function that needs evolution context.
func FetchGoPkgDoc ¶
func FormatProjectIndex ¶
func FormatProjectIndex(entries []IndexEntry) string
func FormatTreeFromPaths ¶
func GenerateIterateMD ¶
func GetPendingImageAttachment ¶
func GetPendingImageAttachment() string
GetPendingImageAttachment returns and clears any pending image attachment. Called by streamAndPrint before sending each request.
func GetPendingTemplate ¶
func GetPendingTemplate() string
GetPendingTemplate returns and clears any pending template injection.
func LastRunOutput ¶
func LastRunOutput() string
LastRunOutput returns the captured output of the most recent /run call.
func PreviewEdit ¶
PreviewEdit shows a preview of an edit before applying. Returns ErrUserQuit if the user chooses to quit.
func RegisterASTCommands ¶
func RegisterASTCommands(r *Registry)
RegisterASTCommands adds AST analysis commands
func RegisterAgentCommands ¶
func RegisterAgentCommands(r *Registry)
RegisterAgentCommands adds agent control commands.
func RegisterAll ¶
func RegisterAll(r *Registry)
RegisterAll adds all command groups to the registry. This is the single entry point for wiring up all modular commands.
func RegisterAnalysisCommands ¶
func RegisterAnalysisCommands(r *Registry)
RegisterAnalysisCommands adds repository analysis and benchmarking commands.
func RegisterAutofixCommands ¶
func RegisterAutofixCommands(r *Registry)
RegisterAutofixCommands adds the /autofix command.
func RegisterBudgetCommands ¶
func RegisterBudgetCommands(r *Registry)
RegisterBudgetCommands adds the /budget spending-limit command.
func RegisterConfigCommands ¶
func RegisterConfigCommands(r *Registry)
RegisterConfigCommands adds configuration and settings commands.
func RegisterContextTemplateCommands ¶
func RegisterContextTemplateCommands(r *Registry)
RegisterContextTemplateCommands adds context analytics.
func RegisterDevCommands ¶
func RegisterDevCommands(r *Registry)
RegisterDevCommands adds development commands.
func RegisterDocsCommands ¶
func RegisterDocsCommands(r *Registry)
RegisterDocsCommands adds dependency summary command.
func RegisterEvolutionCommands ¶
func RegisterEvolutionCommands(r *Registry)
RegisterEvolutionCommands adds evolution-related commands.
func RegisterFileCommands ¶
func RegisterFileCommands(r *Registry)
RegisterFileCommands adds file and search commands.
func RegisterGitCommands ¶
func RegisterGitCommands(r *Registry)
RegisterGitCommands adds git commands.
func RegisterGitContextCommands ¶
func RegisterGitContextCommands(r *Registry)
RegisterGitContextCommands adds git-aware context commands.
func RegisterGitHooksCommands ¶
func RegisterGitHooksCommands(r *Registry)
RegisterGitHooksCommands adds git hooks integration commands. Task 70: Git Hooks Integration (pre-commit, post-commit)
func RegisterGitHubCommands ¶
func RegisterGitHubCommands(r *Registry)
RegisterGitHubCommands adds GitHub-related commands.
func RegisterLearningCommands ¶
func RegisterLearningCommands(r *Registry)
RegisterLearningCommands adds pattern recognition and learning curation.
func RegisterMemoryAnalyticsCommands ¶
func RegisterMemoryAnalyticsCommands(r *Registry)
RegisterMemoryAnalyticsCommands adds memory search command.
func RegisterMemoryCommands ¶
func RegisterMemoryCommands(r *Registry)
RegisterMemoryCommands adds memory/note-taking commands.
func RegisterModeCommands ¶
func RegisterModeCommands(r *Registry)
RegisterModeCommands adds agent mode and display commands.
func RegisterProfileCommands ¶
func RegisterProfileCommands(r *Registry)
RegisterProfileCommands adds /profile commands.
func RegisterSafetyCommands ¶
func RegisterSafetyCommands(r *Registry)
RegisterSafetyCommands adds safety/config commands.
func RegisterSessionCommands ¶
func RegisterSessionCommands(r *Registry)
RegisterSessionCommands adds session management commands.
func RegisterSnippetCommands ¶
func RegisterSnippetCommands(r *Registry)
RegisterSnippetCommands adds code snippet commands
func RegisterTemplateCommands ¶
func RegisterTemplateCommands(r *Registry)
RegisterTemplateCommands adds /template and /t commands.
func RegisterUtilityCommands ¶
func RegisterUtilityCommands(r *Registry)
RegisterUtilityCommands adds utility/context management commands.
func StripHTMLTags ¶
Types ¶
type AgentRuntime ¶
type AgentRuntime struct {
Agent *iteragent.Agent
Provider iteragent.Provider
Thinking *iteragent.ThinkingLevel
Context context.Context
Pool *agent.Pool
}
AgentRuntime groups agent, provider, and pool fields.
type Command ¶
type Command struct {
Name string // primary name (e.g., "/save")
Aliases []string // aliases (e.g., "/exit", "/q" for "/quit")
Description string // short help text
Category string // grouping for help display
Handler func(Context) Result
}
Command represents a single REPL command.
type CommandInput ¶
CommandInput holds the parsed command line.
type ConfigCallbacks ¶
type ConfigCallbacks struct {
LoadConfig func() interface{}
SaveConfig func(cfg interface{})
ConfigPath func() string
HistoryFile *string
LoadAliases func() map[string]string
SaveAliases func(m map[string]string)
LoadMCPServers func() []MCPServerEntry
SaveMCPServers func(servers []MCPServerEntry)
}
ConfigCallbacks groups configuration and alias callbacks.
type Context ¶
type Context struct {
RepoPath string
Input CommandInput
Version string
Writer io.Writer
// Registry is the command registry — used by /help to generate dynamic output.
Registry *Registry
InputHistory *[]string
LastPrompt *string
RuntimeConfig *RuntimeConfig
ApplyTheme func(name string)
// Sub-struct groups
Runtime AgentRuntime
Tokens TokenUsage
Safety SafetyState
Watch WatchCallbacks
// Grouped callbacks
Session SessionCallbacks
Config ConfigCallbacks
REPL REPLCallbacks
State StateAccessors
Templates TemplateCallbacks
Snapshots SnapshotCallbacks
}
Context holds all state needed by commands.
type DiffViewer ¶
type DiffViewer struct {
ColorAdded *color.Color
ColorRemoved *color.Color
ColorContext *color.Color
ColorHeader *color.Color
}
DiffViewer shows unified diffs before applying changes
func NewDiffViewer ¶
func NewDiffViewer() *DiffViewer
NewDiffViewer creates a new diff viewer with colors
func (*DiffViewer) BatchDiff ¶
func (dv *DiffViewer) BatchDiff(files []string) (approved []string, rejected []string, err error)
BatchDiff shows diffs for multiple files. Returns ErrUserQuit if the user chooses to quit mid-review.
func (*DiffViewer) ConfirmChange ¶
func (dv *DiffViewer) ConfirmChange(filename string) (bool, error)
ConfirmChange prompts user to confirm a change. Returns (apply bool, err error). err is ErrUserQuit when user chooses to quit.
func (*DiffViewer) ShowDiff ¶
func (dv *DiffViewer) ShowDiff(filename string, original []string, proposed []string)
ShowDiff displays a unified diff between original and proposed content
func (*DiffViewer) ShowGitDiff ¶
func (dv *DiffViewer) ShowGitDiff(filename string) error
ShowGitDiff shows git-style diff for file changes
type EvolutionContext ¶
type EvolutionContext struct {
Logger *slog.Logger
StreamAndPrint func(ctx context.Context, a *iteragent.Agent, prompt, repoPath string)
EventSink chan iteragent.Event
}
EvolutionContext provides additional context for evolution commands.
type IndexEntry ¶
func BuildProjectIndex ¶
func BuildProjectIndex(repoPath string) []IndexEntry
type MCPServerEntry ¶
MCPServerEntry represents an MCP server configuration.
type Profile ¶
type Profile struct {
Name string `json:"name"`
Model string `json:"model,omitempty"`
Temperature float32 `json:"temperature,omitempty"`
MaxTokens int `json:"max_tokens,omitempty"`
SystemSuffix string `json:"system_suffix,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
Profile captures a named agent configuration snapshot.
type PromptTemplate ¶
PromptTemplate represents a saved prompt template.
type REPLCallbacks ¶
type REPLCallbacks struct {
StreamAndPrint func(ctx context.Context, a *iteragent.Agent, prompt, repoPath string)
RunShell func(repoPath string, name string, args ...string)
MakeAgent func() *iteragent.Agent
ReadMultiLine func() (string, bool)
PromptLine func(prompt string) (string, bool)
// Undo reverts the last agent file modifications.
// Returns the list of restored paths and an error (if any).
Undo func() ([]string, error)
// BuildRepoMap returns a structural summary of the repository.
// refresh=true forces a rebuild; false may return a cached result.
BuildRepoMap func(repoPath string, refresh bool) string
// InvalidateRepoMap clears the repo map cache.
InvalidateRepoMap func()
}
REPLCallbacks groups REPL interaction callbacks.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry holds all registered commands.
func DefaultRegistry ¶
func DefaultRegistry() *Registry
DefaultRegistry returns a fully populated registry.
func (*Registry) ByCategory ¶
ByCategory returns commands grouped by category.
type Result ¶
type Result struct {
Done bool // true = exit REPL
Handled bool // true = command was recognized
Err error // non-nil = error occurred
}
Result represents the outcome of a command execution.
type RuntimeConfig ¶
RuntimeConfig holds runtime settings for the agent.
type SafetyState ¶
type SafetyState struct {
SafeMode *bool
CurrentMode *int
DebugMode *bool
AutoCommitEnabled *bool
NotifyEnabled *bool
PersistConfig func()
}
SafetyState groups safety, mode, and notification toggles.
type SessionCallbacks ¶
type SessionCallbacks struct {
SaveSession func(name string, msgs []iteragent.Message) error
LoadSession func(name string) ([]iteragent.Message, error)
ListSessions func() []string
AddBookmark func(name string, msgs []iteragent.Message)
LoadBookmarks func() []Bookmark
SelectItem func(title string, items []string) (string, bool)
}
SessionCallbacks groups session management callbacks.
type SnapshotCallbacks ¶
type SnapshotCallbacks struct {
SaveSnapshot func(name string, msgs []iteragent.Message) error
ListSnapshots func() []Snapshot
}
SnapshotCallbacks groups snapshot management callbacks.
type StateAccessors ¶
type StateAccessors struct {
IsDenied func(name string) bool
DenyTool func(name string)
AllowTool func(name string)
GetDeniedList func() []string
GetPinnedMessages func() []iteragent.Message
SetPinnedMessages func(msgs []iteragent.Message)
GetConversationMark func(name string) (int, bool)
SetConversationMark func(name string, idx int)
GetConversationMarks func() map[string]int
ConversationMarksLen func() int
}
StateAccessors groups thread-safe state access callbacks.
type TemplateCallbacks ¶
type TemplateCallbacks struct {
LoadTemplates func() []PromptTemplate
AddTemplate func(name, prompt string)
FormatSessionChanges func() string
}
TemplateCallbacks groups template management callbacks.
type TokenUsage ¶
type TokenUsage struct {
InputTokens *int
OutputTokens *int
CacheRead *int
CacheWrite *int
ContextWindow *int
BudgetLimit *float64
CostUSD *float64
}
TokenUsage groups session token and budget tracking fields.
type WatchCallbacks ¶
type WatchCallbacks struct {
Start func(repoPath string)
Stop func()
}
WatchCallbacks groups file-watch start/stop callbacks.
Source Files
¶
- agent.go
- analysis.go
- ast.go
- autofix.go
- budget.go
- config.go
- context_templates.go
- dev.go
- diff.go
- docs.go
- evolution.go
- files.go
- files_navigation.go
- git.go
- git_advanced.go
- git_context.go
- git_hooks.go
- git_network.go
- github.go
- learning.go
- memory.go
- mode.go
- profile.go
- project_helpers.go
- register.go
- registry.go
- safety.go
- session.go
- snippets.go
- templates.go
- utility.go