MCPcopy Create free account
hub / github.com/diillson/chatcli / List

Method List

cli/context_adapter.go:180–204  ·  view source on GitHub ↗

List describes every available context.

()

Source from the content-addressed store, hash-verified

178
179// List describes every available context.
180func (a *contextPluginAdapter) List() (string, error) {
181 mgr := a.manager()
182 if mgr == nil {
183 return "", fmt.Errorf("context manager unavailable in this session")
184 }
185 all, err := mgr.ListContexts(nil)
186 if err != nil {
187 return "", err
188 }
189 if len(all) == 0 {
190 return "No contexts yet. Build one with @context create {\"name\":...,\"paths\":[...],\"mode\":\"knowledge\"}.", nil
191 }
192 attached := a.attachedIDs()
193 var b strings.Builder
194 fmt.Fprintf(&b, "%d context(s):\n", len(all))
195 for _, fc := range all {
196 mark := " "
197 if attached[fc.ID] {
198 mark = "*"
199 }
200 fmt.Fprintf(&b, "%s %s — mode=%s, %d unit(s), %s\n", mark, fc.Name, fc.Mode, fc.FileCount, humanMB(fc.TotalSize))
201 }
202 b.WriteString("(* = attached to this session)")
203 return b.String(), nil
204}
205
206// Status describes what is attached to the current session.
207func (a *contextPluginAdapter) Status() (string, error) {

Callers 2

Calls 6

managerMethod · 0.95
attachedIDsMethod · 0.95
humanMBFunction · 0.85
ErrorfMethod · 0.80
ListContextsMethod · 0.80
StringMethod · 0.45

Tested by 2