List describes the attached knowledge bases.
()
| 101 | |
| 102 | // List describes the attached knowledge bases. |
| 103 | func (a *knowledgePluginAdapter) List() (string, error) { |
| 104 | mgr := a.manager() |
| 105 | if mgr == nil { |
| 106 | return "", fmt.Errorf("context manager unavailable in this session") |
| 107 | } |
| 108 | kbs := mgr.AttachedKnowledge(a.sessionID()) |
| 109 | if len(kbs) == 0 { |
| 110 | return "No knowledge base attached. Create one with /context create <name> <corpus.jsonl|dir> --mode knowledge, then /context attach <name>.", nil |
| 111 | } |
| 112 | var b strings.Builder |
| 113 | fmt.Fprintf(&b, "%d knowledge base(s) attached:\n", len(kbs)) |
| 114 | for _, fc := range kbs { |
| 115 | fmt.Fprintf(&b, "- %s — %d passage(s), %.2f MB indexed\n", fc.Name, fc.FileCount, float64(fc.TotalSize)/1024/1024) |
| 116 | } |
| 117 | return strings.TrimRight(b.String(), "\n"), nil |
| 118 | } |
| 119 | |
| 120 | // knowledgeAgentBlock renders the knowledge digests for the agent/coder |
| 121 | // system prompt: the index cards plus the pull instruction. Empty when no |