Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pkg/plans/service.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package plans

import (
"cmp"
"context"
"errors"
"fmt"
"io"
"io/fs"
"os"
"path/filepath"
"sort"
"slices"
"strings"
"time"

Expand Down Expand Up @@ -76,7 +77,7 @@ func (s *service) List(ctx context.Context, opts ListOptions) (ListResult, error
result.Warnings = append(result.Warnings, warnings...)
// The documented order is by name; enforce it here so it holds for any
// injected Storage, not only backends that happen to sort.
sort.SliceStable(summaries, func(i, j int) bool { return summaries[i].Name < summaries[j].Name })
slices.SortStableFunc(summaries, func(a, b plan.Summary) int { return cmp.Compare(a.Name, b.Name) })
for _, sum := range summaries {
result.Plans = append(result.Plans, Plan{
Scope: ScopeShared,
Expand Down
5 changes: 3 additions & 2 deletions pkg/sandbox/kit/kit.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
package kit

import (
"cmp"
"context"
"crypto/sha256"
"encoding/hex"
Expand Down Expand Up @@ -803,7 +804,7 @@ func (r *Result) PrintSummary(w io.Writer) {

skillFiles := r.skillFilesGrouped()
promptEntries := append([]Entry(nil), r.Manifest.PromptFiles...)
sort.Slice(promptEntries, func(i, j int) bool { return promptEntries[i].Target < promptEntries[j].Target })
slices.SortFunc(promptEntries, func(a, b Entry) int { return cmp.Compare(a.Target, b.Target) })

if len(skillFiles) == 0 && len(promptEntries) == 0 {
return
Expand Down Expand Up @@ -875,7 +876,7 @@ type skillGroup struct {
// it sees exactly what the sandbox will see.
func (r *Result) skillFilesGrouped() []skillGroup {
entries := append([]Entry(nil), r.Manifest.Skills...)
sort.Slice(entries, func(i, j int) bool { return entries[i].Target < entries[j].Target })
slices.SortFunc(entries, func(a, b Entry) int { return cmp.Compare(a.Target, b.Target) })

groups := make([]skillGroup, 0, len(entries))
for _, e := range entries {
Expand Down
8 changes: 5 additions & 3 deletions pkg/tools/builtin/mcpcatalog/mcpcatalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@
package mcpcatalog

import (
"cmp"
"context"
"encoding/json"
"errors"
"fmt"
"log/slog"
"slices"
"sort"
"strings"
"sync"
Expand Down Expand Up @@ -491,7 +493,7 @@ func (t *Toolset) Tools(ctx context.Context) ([]tools.Tool, error) {
// Tools() invocations, but for a given snapshot we want a deterministic
// merged list so model-side prompt caches and TUI rendering don't
// flicker on each turn.
sort.Slice(enabled, func(i, j int) bool { return enabled[i].id < enabled[j].id })
slices.SortFunc(enabled, func(a, b enabledServer) int { return cmp.Compare(a.id, b.id) })

for _, e := range enabled {
if err := ctx.Err(); err != nil {
Expand Down Expand Up @@ -645,7 +647,7 @@ func (t *Toolset) handleSearch(_ context.Context, args SearchArgs) (*tools.ToolC
return tools.ResultError(fmt.Sprintf("no remote MCP servers match %q (catalog has %d entries)", args.Query, t.catalog.Count)), nil
}

sort.Slice(matches, func(i, j int) bool { return matches[i].ID < matches[j].ID })
slices.SortFunc(matches, func(a, b SearchResult) int { return cmp.Compare(a.ID, b.ID) })

out, err := json.Marshal(matches)
if err != nil {
Expand Down Expand Up @@ -933,7 +935,7 @@ func (t *Toolset) handleList(_ context.Context, _ ListArgs) (*tools.ToolCallResu
Started: ts.IsStarted(),
})
}
sort.Slice(enabled, func(i, j int) bool { return enabled[i].ID < enabled[j].ID })
slices.SortFunc(enabled, func(a, b EnabledServer) int { return cmp.Compare(a.ID, b.ID) })

out, err := json.Marshal(enabled)
if err != nil {
Expand Down
7 changes: 4 additions & 3 deletions pkg/tools/builtin/plan/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package plan

import (
"bytes"
"cmp"
"context"
"encoding/json"
"errors"
Expand All @@ -28,7 +29,7 @@ import (
"os"
"path/filepath"
"regexp"
"sort"
"slices"
"strings"
"sync"
"time"
Expand Down Expand Up @@ -1098,8 +1099,8 @@ func (s *FilesystemStorage) List(ctx context.Context) ([]Summary, []string, erro
})
}

sort.Slice(plans, func(i, j int) bool {
return plans[i].Name < plans[j].Name
slices.SortFunc(plans, func(a, b Summary) int {
return cmp.Compare(a.Name, b.Name)
})

return plans, warnings, nil
Expand Down
Loading