v0.50.1 a637010

pins.go RawHistoryFolder

1package skills
2
3import (
4	"fmt"
5	"sort"
6	"strings"
7)
8
9// Pins records independent global and project selections by discovered name.
10type Pins struct {
11	Global  []string `json:"global,omitempty"`
12	Project []string `json:"project,omitempty"`
13}
14
15// Resolve returns each available pinned skill once, ordered by canonical
16// skill name (then path). A pin may be a skill's name or one of its aliases;
17// two pins that reach the same skill (for example a canonical name and its
18// slash alias, or the same name in both scopes) select it once. Names that
19// match nothing produce one warning each, in name order.
20func (p Pins) Resolve(available []*Skill) ([]*Skill, []string) {
21	names := make(map[string]bool)
22	for _, name := range append(append([]string(nil), p.Global...), p.Project...) {
23		if name != "" {
24			names[name] = true
25		}
26	}
27	sorted := make([]string, 0, len(names))
28	for name := range names {
29		sorted = append(sorted, name)
30	}
31	sort.Strings(sorted)
32	var selected []*Skill
33	chosen := make(map[*Skill]bool)
34	var warnings []string
35	for _, name := range sorted {
36		s := FindByName(available, name)
37		if s == nil {
38			warnings = append(warnings, fmt.Sprintf("pinned skill %q is unavailable", name))
39			continue
40		}
41		if !chosen[s] {
42			chosen[s] = true
43			selected = append(selected, s)
44		}
45	}
46	sort.SliceStable(selected, func(i, j int) bool {
47		if selected[i].Name != selected[j].Name {
48			return selected[i].Name < selected[j].Name
49		}
50		return selected[i].Path < selected[j].Path
51	})
52	return selected, warnings
53}
54
55// Scopes reports which scopes pin s, resolving aliases the same way Resolve
56// does: a pin counts when its name resolves to s among available.
57func (p Pins) Scopes(available []*Skill, s *Skill) (project, global bool) {
58	hit := func(names []string) bool {
59		for _, name := range names {
60			if name != "" && FindByName(available, name) == s {
61				return true
62			}
63		}
64		return false
65	}
66	return hit(p.Project), hit(p.Global)
67}
68
69// PreloadPrompt includes pinned instructions with the first real request.
70// It creates no synthetic tool calls and does not start a model turn.
71func PreloadPrompt(selected []*Skill, request string) string {
72	if len(selected) == 0 {
73		return request
74	}
75	var b strings.Builder
76	b.WriteString("Pinned skills for this conversation. Apply these instructions where relevant to the user's requests.\n\n")
77	for _, s := range selected {
78		b.WriteString(InvocationPrompt(s, ""))
79		b.WriteString("\n\n")
80	}
81	b.WriteString("---\n\nUser request:\n")
82	b.WriteString(request)
83	return b.String()
84}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 476

↑↓ moveenter openesc close