List describes every available context.
()
| 178 | |
| 179 | // List describes every available context. |
| 180 | func (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. |
| 207 | func (a *contextPluginAdapter) Status() (string, error) { |