feat(tui): add k:kind filter tag for agent/skill filtering in list

This commit is contained in:
Willie
2026-04-07 18:49:27 +08:00
parent 30f8fb0131
commit be962fd557
2 changed files with 25 additions and 3 deletions
+3 -3
View File
@@ -136,7 +136,7 @@ func newListTUIModel(loadFn listLoadFn, skills []skillItem, totalCount int, mode
fi.Prompt = "/ "
fi.PromptStyle = tc.Filter
fi.Cursor.Style = tc.Filter
fi.Placeholder = "filter or t:tracked g:group r:repo"
fi.Placeholder = "filter or t:tracked g:group r:repo k:kind"
m := listTUIModel{
list: l,
@@ -566,7 +566,7 @@ func (m listTUIModel) viewSplit() string {
b.WriteString("\n")
helpText := "↑↓ navigate ←→ page / filter Ctrl+d/u detail Enter view A audit U update E enable/disable X uninstall q quit"
if m.filtering {
helpText = "t:type g:group r:repo Enter lock Esc clear q quit"
helpText = "t:type g:group r:repo k:kind Enter lock Esc clear q quit"
}
help := appendScrollInfo(helpText, scrollInfo)
b.WriteString(tc.Help.Render(help))
@@ -605,7 +605,7 @@ func (m listTUIModel) viewVertical() string {
b.WriteString("\n")
helpText := "↑↓ navigate ←→ page / filter Ctrl+d/u detail Enter view A audit U update E enable/disable X uninstall q quit"
if m.filtering {
helpText = "t:type g:group r:repo Enter lock Esc clear q quit"
helpText = "t:type g:group r:repo k:kind Enter lock Esc clear q quit"
}
help := appendScrollInfo(helpText, scrollInfo)
b.WriteString(tc.Help.Render(help))
+22
View File
@@ -10,6 +10,7 @@ type filterQuery struct {
TypeTag string // "tracked", "remote", "local" (empty = any)
GroupTag string // substring match against group segment
RepoTag string // substring match against RepoName
KindTag string // "skill" or "agent" (empty = any)
FreeText string // remaining text after removing known tags
}
@@ -34,6 +35,10 @@ func parseFilterQuery(raw string) filterQuery {
q.RepoTag = val
continue
}
if val, ok := cutTag(lower, "k:", "kind:"); ok {
q.KindTag = normalizeKindValue(val)
continue
}
freeTokens = append(freeTokens, strings.ToLower(token))
}
@@ -69,6 +74,18 @@ func normalizeTypeValue(val string) string {
}
}
// normalizeKindValue maps plural forms to canonical kind names.
func normalizeKindValue(val string) string {
switch val {
case "agent", "agents":
return "agent"
case "skill", "skills":
return "skill"
default:
return val
}
}
// matchSkillItem returns true if the skill item matches all non-empty conditions in the query (AND logic).
func matchSkillItem(item skillItem, q filterQuery) bool {
e := item.entry
@@ -97,6 +114,11 @@ func matchSkillItem(item skillItem, q filterQuery) bool {
}
}
// Kind tag — exact match on skill kind
if q.KindTag != "" && e.Kind != q.KindTag {
return false
}
// Free text — substring match on FilterValue
if q.FreeText != "" {
fv := strings.ToLower(item.FilterValue())