Skip to content

Add dynamic toolset filtering with expressions #3

@jonwraymond

Description

@jonwraymond

Problem

Toolset filtering in set package is basic. Can't express complex filters like:

  • "All file tools except delete"
  • "Tools matching regex pattern"
  • "Tools with specific annotations"

Proposal

Add expression-based filtering:

type FilterExpr interface {
    Matches(tool model.Tool) bool
}

// Built-in expressions
func NameMatches(pattern string) FilterExpr      // regex
func HasTag(tag string) FilterExpr
func InNamespace(ns string) FilterExpr
func HasAnnotation(key string) FilterExpr
func IsReadOnly() FilterExpr
func IsDestructive() FilterExpr

// Combinators
func And(exprs ...FilterExpr) FilterExpr
func Or(exprs ...FilterExpr) FilterExpr
func Not(expr FilterExpr) FilterExpr

// Usage
filter := And(
    InNamespace("filesystem"),
    Not(HasAnnotation("destructive")),
)
toolset := set.NewToolset(tools).Filter(filter)

Benefit

  • Expressive filtering
  • Safer tool exposure
  • Annotation-aware filtering

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions