review: dedupe config filtering and picker multiselect construction · Entire
review: dedupe config filtering and picker multiselect construction
02a59b9→main·
Soph·2w ago·2 files·+44 added/-53 removed
nonZeroProfiles/nonZeroAgentConfigs were identical filters over two config types — back both with a generic nonZeroNamed keyed on IsZero. BuildReviewPickerFields built the built-in and plugin-skill multiselects (and their empty-state notes) twice; extract skillMultiSelectField. Covered by the existing picker structure/preselection tests.
Co-Authored-By: Claude Fable 5 noreply@anthropic.com
Sessions
4bfedc11ca7fView transcript
Changes
2
cmd/entire/cli/review
Mpicker.go+37/-43
Mprofile.go+7/-10
1198 unmodified lines
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1202
1203
1204
1205
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
49 unmodified lines
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1198 unmodified lines
builtinPreselected := preselectedSet(builtinPicksOut)
discoveredPreselected := preselectedSet(discoveredPicksOut)
if len(builtins) > 0 {
opts := make([]huh.Option[string], 0, len(builtins))
for _, b := range builtins {
opt := huh.NewOption(b.Name, b.Name)
if _, ok := builtinPreselected[b.Name]; ok {
opt = opt.Selected(true)
}
opts = append(opts, opt)
}
ms := huh.NewMultiSelect[string]().
Title("Built-in commands").
Options(opts...).
Height(len(opts) + 1)
if builtinPicksOut != nil {
ms = ms.Value(builtinPicksOut)
}
fields = append(fields, ms)
} else {
fields = append(fields, huh.NewNote().
Title("Built-in commands").
Description(fmt.Sprintf("No built-in review commands in %s.", agentName)))
}
builtinNames := make([]string, len(builtins))
for i, b := range builtins {
builtinNames[i] = b.Name
}
if len(discovered) > 0 {
opts := make([]huh.Option[string], 0, len(discovered))
for _, d := range discovered {
opt := huh.NewOption(d.Name, d.Name)
if _, ok := discoveredPreselected[d.Name]; ok {
opt = opt.Selected(true)
}
opts = append(opts, opt)
}
ms := huh.NewMultiSelect[string]().
Title("Installed plugin skills").
Options(opts...).
Height(len(opts) + 1)
if discoveredPicksOut != nil {
ms = ms.Value(discoveredPicksOut)
}
fields = append(fields, ms)
} else {
fields = append(fields, huh.NewNote().
Title("Installed plugin skills").
Description("No plugin review skills detected on disk."))
}
discoveredNames := make([]string, len(discovered))
for i, d := range discovered {
discoveredNames[i] = d.Name
}
fields = append(fields, skillMultiSelectField("Built-in commands",
fmt.Sprintf("No built-in review commands in %s.", agentName),
builtinNames, builtinPreselected, builtinPicksOut))
fields = append(fields, skillMultiSelectField("Installed plugin skills",
"No plugin review skills detected on disk.",
discoveredNames, discoveredPreselected, discoveredPicksOut))
if len(activeHints) > 0 {
var sb strings.Builder
for i, h := range activeHints {
49 unmodified lines
// preselectedSet turns a slice pointer's current contents into a lookup
// set for the picker's "previously-saved" pre-selection.
// skillMultiSelectField builds the multiselect for one skill group, or an
// explanatory note when the group is empty.
func skillMultiSelectField(title, emptyDesc string, names []string, preselected map[string]struct{}, picksOut *[]string) huh.Field {
if len(names) == 0 {
return huh.NewNote().Title(title).Description(emptyDesc)
}
opts := make([]huh.Option[string], 0, len(names))
for _, name := range names {
opt := huh.NewOption(name, name)
if _, ok := preselected[name]; ok {
opt = opt.Selected(true)
}
opts = append(opts, opt)
}
ms := huh.NewMultiSelect[string]().
Title(title).
Options(opts...).
Height(len(opts) + 1)
if picksOut != nil {
ms = ms.Value(picksOut)
}
return ms
}
func preselectedSet(slice *[]string) map[string]struct{} {
if slice == nil || len(*slice) == 0 {
return nil
}