- Migrate all : prefix commands (:cmd, :pico, :hipico, :edit, :usage, :help) to / prefix commands registered in the unified command registry - Remove handleExtensionCommand and handleModeCommand from loop.go - Add new commands: /clear (delete all chat history), /compact (summarize/compress history) - Add new commands: /cmd, /pico, /hipico, /edit, /usage as Definition in pkg/commands/ - Extend Runtime with session-mode callbacks (GetSessionMode, SetModeCmd, SetModePico), file editing (EditFile, GetWorkDir, GetWorkspace), token stats (GetTokenUsage), one-shot LLM query (RunOneShot), and session management (ClearSession, CompactSession) - All commands are auto-discoverable via /help and Telegram bot menu - Update editUsage() and handleEditCommand to use /edit prefix Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
42 lines
1.6 KiB
Go
42 lines
1.6 KiB
Go
package commands
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/sipeed/picoclaw/pkg/config"
|
|
)
|
|
|
|
// Runtime provides runtime dependencies to command handlers. It is constructed
|
|
// per-request by the agent loop so that per-request state (like session scope)
|
|
// can coexist with long-lived callbacks (like GetModelInfo).
|
|
type Runtime struct {
|
|
Config *config.Config
|
|
GetModelInfo func() (name, provider string)
|
|
ListAgentIDs func() []string
|
|
ListDefinitions func() []Definition
|
|
GetEnabledChannels func() []string
|
|
SwitchModel func(value string) (oldModel string, err error)
|
|
SwitchChannel func(value string) error
|
|
|
|
// Session mode control (session-scoped callbacks)
|
|
GetSessionMode func() string // returns "pico" or "cmd"
|
|
SetModeCmd func() string // switches to cmd mode, returns prompt string
|
|
SetModePico func() string // switches to pico mode, returns status string
|
|
|
|
// Working directory (session-scoped)
|
|
GetWorkDir func() string // current working directory for this session
|
|
GetWorkspace func() string // agent workspace root
|
|
|
|
// File editing — delegates to the loop's handleEditCommand with proper path resolution
|
|
EditFile func(content string) string
|
|
|
|
// Token and model usage stats
|
|
GetTokenUsage func() (promptTokens, completionTokens, requests int64)
|
|
|
|
// One-shot AI query from cmd mode (/hipico)
|
|
RunOneShot func(ctx context.Context, message string) (string, error)
|
|
|
|
// Session history management
|
|
ClearSession func() error // clears all history and summary, saves
|
|
CompactSession func() error // runs summarization synchronously
|
|
}
|