core

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: MIT Imports: 30 Imported by: 0

Documentation

Overview

Package core provides core CLI commands (doctor, completion, alias, enable, status, plugin, mcp, marketplace, trust).

Index

Constants

This section is empty.

Variables

View Source
var CommunityFilters = map[string]string{
	"jest":       "https://raw.githubusercontent.com/GrayCodeAI/tokman/main/filters/jest.toml",
	"vitest":     "https://raw.githubusercontent.com/GrayCodeAI/tokman/main/filters/vitest.toml",
	"playwright": "https://raw.githubusercontent.com/GrayCodeAI/tokman/main/filters/playwright.toml",
	"cypress":    "https://raw.githubusercontent.com/GrayCodeAI/tokman/main/filters/cypress.toml",
	"mocha":      "https://raw.githubusercontent.com/GrayCodeAI/tokman/main/filters/mocha.toml",
	"eslint":     "https://raw.githubusercontent.com/GrayCodeAI/tokman/main/filters/eslint.toml",
	"biome":      "https://raw.githubusercontent.com/GrayCodeAI/tokman/main/filters/biome.toml",
	"swc":        "https://raw.githubusercontent.com/GrayCodeAI/tokman/main/filters/swc.toml",
	"webpack":    "https://raw.githubusercontent.com/GrayCodeAI/tokman/main/filters/webpack.toml",
	"vite":       "https://raw.githubusercontent.com/GrayCodeAI/tokman/main/filters/vite.toml",
	"rollup":     "https://raw.githubusercontent.com/GrayCodeAI/tokman/main/filters/rollup.toml",
	"trivy":      "https://raw.githubusercontent.com/GrayCodeAI/tokman/main/filters/trivy.toml",
	"snyk":       "https://raw.githubusercontent.com/GrayCodeAI/tokman/main/filters/snyk.toml",
	"opentofu":   "https://raw.githubusercontent.com/GrayCodeAI/tokman/main/filters/opentofu.toml",
	"pulumi":     "https://raw.githubusercontent.com/GrayCodeAI/tokman/main/filters/pulumi.toml",
}

CommunityFilters is a registry of known community filters.

Functions

func CheckKillSwitch

func CheckKillSwitch(switches map[string]bool, model string) bool

CheckKillSwitch checks if a model is kill-switched.

func CheckQuota

func CheckQuota(quotas map[string]int, model string, used int) bool

CheckQuota checks if a model has exceeded its quota.

func FormatGatewayStatus

func FormatGatewayStatus(config GatewayConfig) string

FormatGatewayStatus returns a human-readable status string.

func GetTokmanSourceDir

func GetTokmanSourceDir() string

GetTokmanSourceDir returns the TokMan source directory for locating built-in filters. Returns empty string for installed binaries (filters loaded from embedded filesystem).

func ResolveModel

func ResolveModel(aliases map[string]string, fallbacks map[string][]string, model string) string

ResolveModel resolves a model through aliases and fallbacks.

Types

type GatewayConfig

type GatewayConfig struct {
	KillSwitches map[string]bool
	Quotas       map[string]int
	ModelAliases map[string]string
	Fallbacks    map[string][]string
}

GatewayConfig holds gateway configuration.

func DefaultGatewayConfig

func DefaultGatewayConfig() GatewayConfig

DefaultGatewayConfig returns default gateway configuration.

type MCPBundleResponse

type MCPBundleResponse struct {
	Path           string   `json:"path"`
	RelatedFiles   []string `json:"related_files"`
	Content        string   `json:"content"`
	OriginalTokens int      `json:"original_tokens"`
	FinalTokens    int      `json:"final_tokens"`
	SavedTokens    int      `json:"saved_tokens"`
	ReductionPct   float64  `json:"reduction_percent"`
}

MCPBundleResponse returns a graph-selected context bundle.

type MCPReadRequest

type MCPReadRequest struct {
	Path         string `json:"path"`
	Mode         string `json:"mode,omitempty"`
	Level        string `json:"level,omitempty"`
	StartLine    int    `json:"start_line,omitempty"`
	EndLine      int    `json:"end_line,omitempty"`
	MaxLines     int    `json:"max_lines,omitempty"`
	MaxTokens    int    `json:"max_tokens,omitempty"`
	LineNumbers  bool   `json:"line_numbers,omitempty"`
	SaveSnapshot bool   `json:"save_snapshot,omitempty"`
	RelatedFiles int    `json:"related_files,omitempty"`
}

MCPReadRequest is the request body for /read.

type MCPReadResponse

type MCPReadResponse struct {
	Path           string  `json:"path"`
	Mode           string  `json:"mode"`
	Content        string  `json:"content"`
	OriginalTokens int     `json:"original_tokens"`
	FinalTokens    int     `json:"final_tokens"`
	SavedTokens    int     `json:"saved_tokens"`
	ReductionPct   float64 `json:"reduction_percent"`
}

MCPReadResponse is the response body for /read.

type MCPRequest

type MCPRequest struct {
	Text    string `json:"text"`
	Command string `json:"command,omitempty"`
	Budget  int    `json:"budget,omitempty"`
	Mode    string `json:"mode,omitempty"`
	Query   string `json:"query,omitempty"`
}

MCPRequest is the request body for /compress.

type MCPResponse

type MCPResponse struct {
	Compressed       string  `json:"compressed"`
	OriginalTokens   int     `json:"original_tokens"`
	CompressedTokens int     `json:"compressed_tokens"`
	SavedTokens      int     `json:"saved_tokens"`
	ReductionPct     float64 `json:"reduction_percent"`
	Hash             string  `json:"hash,omitempty"`
}

MCPResponse is the response body.

Jump to

Keyboard shortcuts

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