GitLabgitlab-org

cli

main
ply7 git calls330 ms98 KiB5 cachedprotocol v2
97 lines3.1 KiBRaw
1package update
3import (
4 "strings"
6 "gitlab.com/gitlab-org/cli/internal/commands/skills/bundled"
7 "gitlab.com/gitlab-org/cli/internal/commands/skills/installed"
8 "gitlab.com/gitlab-org/cli/internal/commands/skills/remote"
9 "gitlab.com/gitlab-org/cli/internal/commands/skills/skill"
10 "gitlab.com/gitlab-org/cli/internal/config"
11 "gitlab.com/gitlab-org/cli/internal/dbg"
12 "gitlab.com/gitlab-org/cli/internal/iostreams"
15// Overridable so tests don't pick up the developer's ~/.agents/skills/.
16var discoverInstalled = installed.Discover
18// bundledSkillUpdates lists installed bundled skills whose on-disk content
19// does not match the version embedded in this binary.
20func bundledSkillUpdates(cfg config.Config) []string {
21 return skillUpdates(cfg, skill.SourceBundled, bundled.Get)
24// remoteSkillUpdates lists installed remote skills whose on-disk content
25// does not match the current upstream. Each name triggers a gitlab.com
26// request — gate on the 24h CheckUpdate cadence, not per command.
27func remoteSkillUpdates(cfg config.Config) []string {
28 return skillUpdates(cfg, skill.SourceRemote, remote.Get)
31// skillUpdates is best-effort: discovery or getter failures return nil
32// rather than an error so a stale check can't disrupt the user's command.
33// Surfaced via dbg.Debugf so the silent path is at least visible under
34// GLAB_DEBUG=1.
35func skillUpdates(cfg config.Config, source skill.Source, getSource func(string) (skill.Skill, error)) []string {
36 if !isSkillNotificationsEnabled(cfg) {
37 return nil
38 }
39 all, err := discoverInstalled()
40 if err != nil {
41 dbg.Debugf("skill update check (%s): discover failed: %s", source, err)
42 return nil
43 }
44 var out []string
45 seen := map[string]struct{}{}
46 for _, ins := range all {
47 if ins.Source != source {
48 continue
49 }
50 if _, ok := seen[ins.Name]; ok {
51 continue
52 }
53 src, err := getSource(ins.Name)
54 if err != nil {
55 dbg.Debugf("skill update check (%s): fetch %q failed: %s", source, ins.Name, err)
56 continue
57 }
58 if skill.ContentHash(src.Files) != ins.Hash {
59 out = append(out, ins.Name)
60 seen[ins.Name] = struct{}{}
61 }
62 }
63 return out
66// writeSkillUpdateBlock prints the agent-skill update nudge as its own
67// block, matching the shape of writeHumanUpdateBlock and the post-upgrade
68// banner: a colored header, an indented body listing the skills, and an
69// indented `Run:` line. A leading blank line separates it from whatever
70// preceded it on stderr.
71func writeSkillUpdateBlock(io *iostreams.IOStreams, names []string) {
72 if len(names) == 0 {
73 return
74 }
75 c := io.Color()
76 action := "glab skills update " + names[0]
77 if len(names) > 1 {
78 action = "glab skills update --all"
79 }
80 io.LogError("")
81 io.LogError(c.Yellow("Agent skill updates available"))
82 io.LogErrorf(" %s\n", strings.Join(names, ", "))
83 io.LogErrorf(" Run: %s\n", action)
86func isSkillNotificationsEnabled(cfg config.Config) bool {
87 // cfg.Get already consults GLAB_NOTIFY_SKILL_UPDATES via EnvKeyEquivalence.
88 val, err := cfg.Get("", "notify_skill_updates")
89 if err != nil || val == "" {
90 return true
91 }
92 switch strings.ToLower(strings.TrimSpace(val)) {
93 case "false", "no", "n", "0":
94 return false
95 }
96 return true
Diagnostics7 git calls · 330 ms
CallStatusSizeTime0330 ms
discover200185 B3 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=2
git.response.bytes=185
git.server.agent=git/2.56.g1891de4-Linux
git.server.object_format=sha1
git.server.caps=agent ls-refs fetch server-option object-format
git.server.fetch=shallow wait-for-done filter
git.protocol.version=2
git.pkt.frames=9
git.pkt.data=7
git.pkt.flush=2
git.pkt.delim=0
git.pkt.bytes=185
git.pkt.payload.max=35
ls-refs20058 KiB · hit2 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=2
git.response.bytes=59849
git.response.cache=HIT
git.response.duration_ms=2
git.protocol.version=2
git.pkt.frames=731
git.pkt.data=730
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=59849
git.pkt.payload.max=143
git.ls_refs.count=730
git.ls_refs.head=refs/heads/main
fetchtree:0 · deepen 1020032 KiB · hit2 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=3
git.response.bytes=32926
git.response.cache=HIT
git.response.duration_ms=2
git.fetch.filter=tree:0
git.fetch.wants=0dd7574dce9e385c5c30540e6c15657adc6bdce9
git.fetch.haves.count=0
git.fetch.deepen=10
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=22
git.pkt.data=20
git.pkt.flush=1
git.pkt.delim=1
git.pkt.bytes=32926
git.pkt.payload.max=32046
git.sideband.band1.bytes=32046
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=80
git.pack.bytes=32046
git.pack.ofs_delta=36
git.pack.ref_delta=0
git.pack.chain.max=2
git.pack.trailer=cb0bad5d7ffc514895d8b21c4dd470327f90bc91
git.pack.full=44
Open pack map
fetchcombine:blob:none+tree:2 · deepen 12004.2 KiB · hit3 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=7
git.response.bytes=4273
git.response.cache=HIT
git.response.duration_ms=3
git.fetch.filter=combine:blob:none+tree:2
git.fetch.wants=0dd7574dce9e385c5c30540e6c15657adc6bdce9
git.fetch.haves.count=0
git.fetch.deepen=1
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=7
git.pkt.data=5
git.pkt.flush=1
git.pkt.delim=1
git.pkt.bytes=4273
git.pkt.payload.max=4173
git.sideband.band1.bytes=4173
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=11
git.pack.bytes=4173
git.fetch.wide.objects=11
git.fetch.wide.extra_bytes=3930
git.fetch.wide.blobs=0
fetchtree:02001.8 KiB · hit7 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=18
git.response.bytes=1857
git.response.cache=HIT
git.response.duration_ms=7
git.fetch.filter=tree:0
git.fetch.wants=dce174ff8c632a19d17eea99c8a9b7c37fb2b592
git.fetch.haves.count=0
git.fetch.deepen=0
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=4
git.pkt.data=3
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=1857
git.pkt.payload.max=1830
git.sideband.band1.bytes=1830
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=1
git.pack.bytes=1830
git.pack.trailer=fb03183b7909876778f740d196d7516811003517
Open pack map
fetchtree:0200329 B · hit18 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=299
git.response.bytes=329
git.response.cache=HIT
git.response.duration_ms=18
git.fetch.filter=tree:0
git.fetch.wants=8b36f3db012b2c3ab0120649b10a85336c3bf03e
git.fetch.haves.count=0
git.fetch.deepen=0
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=4
git.pkt.data=3
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=329
git.pkt.payload.max=302
git.sideband.band1.bytes=302
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=1
git.pack.bytes=302
git.pack.trailer=616b294f8a6e9b6163f51633333a4ad7b16f0d98
Open pack map
fetch2001.3 KiB299 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=1370
git.response.cache=MISS
git.response.duration_ms=299
git.fetch.wants=170b6cc48d45ef07006d94c140ad95ba7b0e81ce
git.fetch.haves.count=0
git.fetch.deepen=0
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=4
git.pkt.data=3
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=1370
git.pkt.payload.max=1343
git.sideband.band1.bytes=1343
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0

Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.

Remote
https://gitlab.com/gitlab-org/cli
Ref
refs/heads/main
Commit
0dd7574dce9e385c5c30540e6c15657adc6bdce9
cf-ray
a5ea9353cec3a87d
Request
7c949a09…
Protocol
v2 · sha1
Agent
git/2.56.g1891de4-Linux
Filter
advertised
Fetch
shallow wait-for-done filter
Capabilities
agent ls-refs fetch server-option object-format