textutil

package
v0.45.0 Latest Latest
Warning

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

Go to latest
Published: May 16, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SeverityHigh   = "high"
	SeverityMedium = "medium"
	SeverityLow    = "low"
)

Severity levels

Variables

View Source
var DeprecatedTools = map[string]string{
	"TaskOutput": "TaskOutput is deprecated (v2.1.83) — use Read on the background task's output file path instead",
}

DeprecatedTools maps tool names to their deprecation message.

View Source
var KnownTools = map[string]bool{

	"Read": true, "Write": true, "Edit": true, "MultiEdit": true,
	"Glob": true, "Grep": true, "LS": true,

	"Bash": true, "Task": true, "Agent": true,

	"WebFetch": true, "WebSearch": true,

	"AskUserQuestion": true, "TodoWrite": true,
	"TaskCreate": true, "TaskUpdate": true, "TaskList": true, "TaskGet": true, "TaskStop": true,

	"Skill": true, "LSP": true, "NotebookEdit": true,
	"EnterPlanMode": true, "ExitPlanMode": true,
	"EnterWorktree": true, "ExitWorktree": true,
	"KillShell": true, "TaskOutput": true, "SendMessage": true, "Monitor": true,
	"RemoteTrigger": true,

	"CronCreate": true, "CronDelete": true, "CronList": true,

	"*": true,
}

KnownTools is the set of valid Claude Code tool names. Source: Claude Code documentation.

Functions

func CountLines

func CountLines(content string) int

CountLines returns the total number of lines in content

func DetectSecrets

func DetectSecrets(contents string, filePath string) []types.ValidationError

DetectSecrets checks for hardcoded secrets in content

func DetermineSeverity

func DetermineSeverity(message string) string

DetermineSeverity determines issue severity based on the message

func ExtractBaseToolName

func ExtractBaseToolName(tool string) string

extractBaseToolName returns the base tool name from patterns like "Task(name)" or "Bash(npm:*)".

func FindFrontmatterFieldLine

func FindFrontmatterFieldLine(content, fieldName string) int

FindFrontmatterFieldLine finds the line number of a YAML frontmatter field

func FindLineNumber

func FindLineNumber(content, pattern string) int

FindLineNumber finds the line number (1-based) where a pattern first appears

func FindSectionLine

func FindSectionLine(content, sectionName string) int

FindSectionLine finds the line number of a markdown section header

func GetFrontmatterEndLine

func GetFrontmatterEndLine(content string) int

GetFrontmatterEndLine returns the line number where frontmatter ends

func ValidateAllowedTools

func ValidateAllowedTools(data map[string]any, filePath string, contents string) []types.ValidationError

ValidateAllowedTools validates that allowed-tools and tools fields contain known tool names

func ValidateToolFieldName

func ValidateToolFieldName(data map[string]any, filePath string, contents string, componentType string) []types.ValidationError

ValidateToolFieldName ensures components use correct field name (tools vs allowed-tools) - Agents MUST use 'tools:', not 'allowed-tools:' - Commands and Skills MUST use 'allowed-tools:', not 'tools:'

Types

type Frontmatter

type Frontmatter struct {
	Data map[string]any
	Body string
}

Frontmatter represents parsed frontmatter data

func ParseYAMLFrontmatter

func ParseYAMLFrontmatter(content string) (*Frontmatter, error)

ParseYAMLFrontmatter extracts YAML frontmatter from markdown content. Frontmatter must start at the beginning of the file with "---".

type ImprovementRecommendation

type ImprovementRecommendation struct {
	Description string
	PointValue  int
	Line        int
	Severity    string
}

ImprovementRecommendation represents a specific fix with point value

func GetAgentImprovements

func GetAgentImprovements(content string, data map[string]any) []ImprovementRecommendation

GetAgentImprovements returns specific improvement recommendations for agents

func GetCommandImprovements

func GetCommandImprovements(content string, data map[string]any) []ImprovementRecommendation

GetCommandImprovements returns specific improvement recommendations for commands

func GetSkillImprovements

func GetSkillImprovements(content string, data map[string]any) []ImprovementRecommendation

GetSkillImprovements returns specific improvement recommendations for skills

Jump to

Keyboard shortcuts

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