Update re-ingests or modifies an existing context. Empty fields keep the current value (mirrors /context update).
(name string, paths []string, mode, description string, tags []string)
| 250 | // Update re-ingests or modifies an existing context. Empty fields keep the |
| 251 | // current value (mirrors /context update). |
| 252 | func (a *contextPluginAdapter) Update(name string, paths []string, mode, description string, tags []string) (string, error) { |
| 253 | mgr := a.manager() |
| 254 | if mgr == nil { |
| 255 | return "", fmt.Errorf("context manager unavailable in this session") |
| 256 | } |
| 257 | if mode != "" { |
| 258 | if _, ok := validContextMode(mode); !ok { |
| 259 | return "", fmt.Errorf("invalid mode %q (valid: knowledge|full|summary|chunked|smart)", mode) |
| 260 | } |
| 261 | } |
| 262 | ctx, cancel := context.WithTimeout(context.Background(), contextOpTimeout) |
| 263 | defer cancel() |
| 264 | fc, err := mgr.UpdateContext(ctx, name, paths, ctxmgr.ProcessingMode(mode), tags, description) |
| 265 | if err != nil { |
| 266 | return "", err |
| 267 | } |
| 268 | var b strings.Builder |
| 269 | fmt.Fprintf(&b, "Updated context %q (mode=%s) — %d unit(s), %s.", fc.Name, fc.Mode, fc.FileCount, humanMB(fc.TotalSize)) |
| 270 | return b.String(), nil |
| 271 | } |
| 272 | |
| 273 | // Show renders one context's metadata. |
| 274 | func (a *contextPluginAdapter) Show(name string) (string, error) { |