commands

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2026 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GitStaged     = "staged"
	GitModified   = "modified"
	GitUntracked  = "untracked"
	GitDeleted    = "deleted"
	GitConflicted = "conflicted"
)

Git status codes

Variables

View Source
var Version = "dev"

Version is set via ldflags during build

Functions

func AgentsCmd added in v1.2.0

func AgentsCmd() *cobra.Command

AgentsCmd returns the agents cobra command for registration.

func Execute

func Execute()

Execute adds all child commands to the root command and sets flags appropriately. Unknown commands are handled by the TOML filter fallback system.

func GetCompactionMaxTokens added in v1.2.0

func GetCompactionMaxTokens() int

GetCompactionMaxTokens returns the max summary tokens

func GetCompactionPreserveTurns added in v1.2.0

func GetCompactionPreserveTurns() int

GetCompactionPreserveTurns returns the number of turns to preserve

func GetCompactionThreshold added in v1.2.0

func GetCompactionThreshold() int

GetCompactionThreshold returns the compaction threshold

func GetConfig added in v1.2.0

func GetConfig() (*config.Config, error)

GetConfig returns the current configuration.

func GetQueryIntent added in v1.2.0

func GetQueryIntent() string

GetQueryIntent returns the query intent for query-aware compression Can be set via --query flag or TOKMAN_QUERY environment variable

func GetTokenBudget added in v1.2.0

func GetTokenBudget() int

GetTokenBudget returns the token budget for compression Can be set via --budget flag or TOKMAN_BUDGET environment variable

func IsCompactionAutoDetect added in v1.2.0

func IsCompactionAutoDetect() bool

IsCompactionAutoDetect returns whether auto-detect is enabled

func IsCompactionEnabled added in v1.2.0

func IsCompactionEnabled() bool

IsCompactionEnabled returns whether compaction is enabled

func IsCompactionSnapshotEnabled added in v1.2.0

func IsCompactionSnapshotEnabled() bool

IsCompactionSnapshotEnabled returns whether state snapshot format is enabled

func IsDryRun added in v1.2.0

func IsDryRun() bool

IsDryRun returns whether dry-run mode is enabled.

func IsLLMEnabled added in v1.2.0

func IsLLMEnabled() bool

IsLLMEnabled returns whether LLM-based compression is enabled

func IsSkipEnv added in v1.2.0

func IsSkipEnv() bool

IsSkipEnv returns whether SKIP_ENV_VALIDATION should be set.

func IsUltraCompact added in v1.2.0

func IsUltraCompact() bool

IsUltraCompact returns whether ultra-compact mode is enabled.

func IsVerbose added in v1.2.0

func IsVerbose() bool

IsVerbose returns whether verbose mode is enabled.

func TeeOnFailure added in v1.2.0

func TeeOnFailure(raw string, commandSlug string, err error) string

TeeOnFailure writes raw output to a file when a command fails. Returns a hint string to append to filtered output if tee was written.

func TeeOnFailureWithCode added in v1.2.0

func TeeOnFailureWithCode(raw string, commandSlug string, exitCode int) string

TeeOnFailureWithCode writes raw output to a file when exit code is non-zero.

func VerbosityLevel added in v1.2.0

func VerbosityLevel() int

VerbosityLevel returns the verbosity level (0-3).

Types

type AuditEntry added in v1.2.0

type AuditEntry struct {
	Timestamp    string
	Action       string
	OriginalCmd  string
	RewrittenCmd string
}

AuditEntry represents a single audit log entry

type CcusagePeriod added in v1.2.0

type CcusagePeriod struct {
	Key                 string  `json:"key"`
	InputTokens         uint64  `json:"inputTokens"`
	OutputTokens        uint64  `json:"outputTokens"`
	CacheCreationTokens uint64  `json:"cacheCreationTokens"`
	CacheReadTokens     uint64  `json:"cacheReadTokens"`
	TotalTokens         uint64  `json:"totalTokens"`
	TotalCost           float64 `json:"totalCost"`
}

CcusagePeriod represents usage data for a time period.

type CodeSummary added in v1.2.0

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

CodeSummary holds the 2-line summary.

type CommandBreakdown added in v1.2.0

type CommandBreakdown struct {
	Command string
	Count   int
	Saved   int
	AvgPct  float64
	AvgTime int64
}

CommandBreakdown represents stats for a single command

type Correction added in v1.2.0

type Correction struct {
	FailedCommand    string  `json:"failed_command"`
	CorrectedCommand string  `json:"corrected_command"`
	Count            int     `json:"count"`
	Confidence       float64 `json:"confidence"`
	Example          string  `json:"example,omitempty"`
	Category         string  `json:"category"`
}

Correction represents a learned correction pattern

type DayBreakdown added in v1.2.0

type DayBreakdown struct {
	Date     string
	Commands int
	Saved    int
	Original int
}

DayBreakdown represents stats for a single day

type DiscoverResult added in v1.2.0

type DiscoverResult struct {
	Project         string              `json:"project,omitempty"`
	TotalCommands   int                 `json:"total_commands"`
	MissedSavings   int                 `json:"missed_savings"`
	Opportunities   []DiscoveredCommand `json:"opportunities"`
	UnsupportedCmds []DiscoveredCommand `json:"unsupported_commands,omitempty"`
}

DiscoverResult represents the discovery results

type DiscoveredCommand added in v1.2.0

type DiscoveredCommand struct {
	Command   string `json:"command"`
	Count     int    `json:"count"`
	Category  string `json:"category"`
	CouldSave bool   `json:"could_save"`
	Example   string `json:"example,omitempty"`
}

DiscoveredCommand represents a discovered command pattern

type EslintMessage added in v1.2.0

type EslintMessage struct {
	RuleId   string `json:"ruleId"`
	Severity int    `json:"severity"`
	Message  string `json:"message"`
	Line     int    `json:"line"`
	Column   int    `json:"column"`
}

ESLint JSON structures

type EslintResult added in v1.2.0

type EslintResult struct {
	FilePath     string          `json:"filePath"`
	Messages     []EslintMessage `json:"messages"`
	ErrorCount   int             `json:"errorCount"`
	WarningCount int             `json:"warningCount"`
}

type ExtractedCommand added in v1.2.0

type ExtractedCommand struct {
	Command   string
	OutputLen int
	SessionID string
	IsError   bool
}

ExtractedCommand represents a command extracted from a session file

type FallbackHandler added in v1.2.0

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

FallbackHandler handles unknown commands by attempting TOML filter matching

func GetFallback added in v1.2.0

func GetFallback() *FallbackHandler

GetFallback returns the global fallback handler

func NewFallbackHandler added in v1.2.0

func NewFallbackHandler() *FallbackHandler

NewFallbackHandler creates a new fallback handler

func (*FallbackHandler) Handle added in v1.2.0

func (h *FallbackHandler) Handle(args []string) (string, bool, error)

Handle attempts to handle an unknown command Returns: output, wasHandled, error

type GainSummary added in v1.2.0

type GainSummary struct {
	TotalCommands int
	TotalInput    int
	TotalOutput   int
	TotalSaved    int
	AvgSavingsPct float64
	TotalTimeMs   int64
	AvgTimeMs     int64
	ByCommand     []CommandBreakdown
	ByDay         []DayBreakdown
}

GainSummary represents the summary statistics

type GhCheckRun added in v1.2.0

type GhCheckRun struct {
	Name       string `json:"name"`
	Status     string `json:"status"`
	Conclusion string `json:"conclusion"`
}

type GhIssue added in v1.2.0

type GhIssue struct {
	Number int    `json:"number"`
	Title  string `json:"title"`
	Author string `json:"author"`
	State  string `json:"state"`
}

type GhPR added in v1.2.0

type GhPR struct {
	Number      int    `json:"number"`
	Title       string `json:"title"`
	Author      string `json:"author"`
	HeadRefName string `json:"headRefName"`
	State       string `json:"state"`
}

type GhPRFile added in v1.2.0

type GhPRFile struct {
	Path string `json:"path"`
}

type GhPRView added in v1.2.0

type GhPRView struct {
	Number            int          `json:"number"`
	Title             string       `json:"title"`
	Author            string       `json:"author"`
	State             string       `json:"state"`
	HeadRefName       string       `json:"headRefName"`
	BaseRefName       string       `json:"baseRefName"`
	Additions         int          `json:"additions"`
	Deletions         int          `json:"deletions"`
	ChangedFiles      int          `json:"changedFiles"`
	Mergeable         string       `json:"mergeable"`
	MergeStateStatus  string       `json:"mergeStateStatus"`
	Commits           int          `json:"commits"`
	Files             []GhPRFile   `json:"files"`
	StatusCheckRollup []GhCheckRun `json:"statusCheckRollup"`
}

type GhRelease added in v1.2.0

type GhRelease struct {
	TagName      string `json:"tagName"`
	Name         string `json:"name"`
	CreatedAt    string `json:"createdAt"`
	IsDraft      bool   `json:"isDraft"`
	IsPrerelease bool   `json:"isPrerelease"`
}

type GhRun added in v1.2.0

type GhRun struct {
	DatabaseId   int    `json:"databaseId"`
	DisplayTitle string `json:"displayTitle"`
	Status       string `json:"status"`
	Conclusion   string `json:"conclusion"`
	CreatedAt    string `json:"createdAt"`
	Event        string `json:"event"`
}

type GitFile added in v1.2.0

type GitFile struct {
	Path string
	Code string
}

GitFile represents a file in git status

type GitStatus added in v1.2.0

type GitStatus struct {
	Branch         string
	TrackingBranch string // e.g., "origin/main"
	Ahead          int
	Behind         int
	Staged         []GitFile
	Modified       []GitFile
	Untracked      []GitFile
	Conflicted     []GitFile
}

GitStatus represents parsed git status output

type GoTestEvent added in v1.2.0

type GoTestEvent struct {
	Time    string  `json:"Time"`
	Action  string  `json:"Action"`
	Package string  `json:"Package"`
	Test    string  `json:"Test"`
	Elapsed float64 `json:"Elapsed"`
	Output  string  `json:"Output"`
}

type K8sContainerStatus added in v1.2.0

type K8sContainerStatus struct {
	Name         string                 `json:"name"`
	RestartCount int                    `json:"restartCount"`
	State        map[string]interface{} `json:"state"`
}

type K8sMetadata added in v1.2.0

type K8sMetadata struct {
	Name      string `json:"name"`
	Namespace string `json:"namespace"`
}

type K8sPod added in v1.2.0

type K8sPod struct {
	Metadata K8sMetadata  `json:"metadata"`
	Status   K8sPodStatus `json:"status"`
}

type K8sPodList added in v1.2.0

type K8sPodList struct {
	Items []K8sPod `json:"items"`
}

JSON structures for kubectl/aws

type K8sPodStatus added in v1.2.0

type K8sPodStatus struct {
	Phase             string               `json:"phase"`
	ContainerStatuses []K8sContainerStatus `json:"containerStatuses"`
}

type K8sService added in v1.2.0

type K8sService struct {
	Metadata K8sMetadata    `json:"metadata"`
	Spec     K8sServiceSpec `json:"spec"`
}

type K8sServiceList added in v1.2.0

type K8sServiceList struct {
	Items []K8sService `json:"items"`
}

type K8sServicePort added in v1.2.0

type K8sServicePort struct {
	Port       int    `json:"port"`
	TargetPort string `json:"targetPort"`
}

type K8sServiceSpec added in v1.2.0

type K8sServiceSpec struct {
	Type  string           `json:"type"`
	Ports []K8sServicePort `json:"ports"`
}

type LearnResult added in v1.2.0

type LearnResult struct {
	Project      string       `json:"project,omitempty"`
	TotalErrors  int          `json:"total_errors"`
	Corrections  []Correction `json:"corrections"`
	RulesWritten bool         `json:"rules_written,omitempty"`
}

LearnResult represents the learning results

type MypyError added in v1.2.0

type MypyError struct {
	File         string
	Line         int
	Code         string
	Message      string
	ContextLines []string
}

type OutputType added in v1.2.0

type OutputType int

OutputType categorizes command output for specialized summarization.

const (
	OutputTypeTest OutputType = iota
	OutputTypeBuild
	OutputTypeLog
	OutputTypeList
	OutputTypeJSON
	OutputTypeGeneric
)

type ParseState added in v1.2.0

type ParseState int
const (
	StateHeader ParseState = iota
	StateTestProgress
	StateFailures
	StateSummary
)

type PatchMode added in v1.2.0

type PatchMode int

PatchMode controls settings.json patching behavior

const (
	PatchModeAsk  PatchMode = iota // Default: prompt user [y/N]
	PatchModeAuto                  // --auto-patch: no prompt
	PatchModeSkip                  // --no-patch: manual instructions
)

type PatchResult added in v1.2.0

type PatchResult int

PatchResult describes the outcome of settings.json patching

const (
	PatchResultPatched        PatchResult = iota // Hook was added successfully
	PatchResultAlreadyPresent                    // Hook was already in settings.json
	PatchResultDeclined                          // User declined when prompted
	PatchResultSkipped                           // --no-patch flag used
)

type PylintDiagnostic added in v1.2.0

type PylintDiagnostic struct {
	Type      string `json:"type"`
	Module    string `json:"module"`
	Obj       string `json:"obj"`
	Line      int    `json:"line"`
	Column    int    `json:"column"`
	Path      string `json:"path"`
	Symbol    string `json:"symbol"`
	Message   string `json:"message"`
	MessageId string `json:"message-id"`
}

Pylint JSON structures

type RuffDiagnostic added in v1.2.0

type RuffDiagnostic struct {
	Code     string       `json:"code"`
	Message  string       `json:"message"`
	Location RuffLocation `json:"location"`
	Filename string       `json:"filename"`
	Fix      *RuffFix     `json:"fix"`
}

type RuffFix added in v1.2.0

type RuffFix struct {
	Applicability string `json:"applicability"`
}

type RuffLocation added in v1.2.0

type RuffLocation struct {
	Row    int `json:"row"`
	Column int `json:"column"`
}

type SessionSummary added in v1.2.0

type SessionSummary struct {
	ID           string
	Date         string
	TotalCmds    int
	TokmanCmds   int
	OutputTokens int
}

SessionSummary represents a summarized session for display

func (*SessionSummary) AdoptionPct added in v1.2.0

func (s *SessionSummary) AdoptionPct() float64

AdoptionPct returns the adoption percentage

type TestSuite added in v1.2.0

type TestSuite struct {
	Package     string
	Passed      int
	Failed      int
	Skipped     int
	Duration    time.Duration
	FailedTests []string
}

TestSuite represents aggregated test results

type TsError added in v1.2.0

type TsError struct {
	File         string
	Line         string
	Col          string
	Severity     string
	Code         string
	Message      string
	ContextLines []string
}

type WcMode added in v1.2.0

type WcMode int

WcMode represents which columns the user requested

const (
	WcModeFull  WcMode = iota // Default: lines, words, bytes (3 columns)
	WcModeLines               // Lines only (-l)
	WcModeWords               // Words only (-w)
	WcModeBytes               // Bytes only (-c)
	WcModeChars               // Chars only (-m)
	WcModeMixed               // Multiple flags combined
)

Jump to

Keyboard shortcuts

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