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

Method Get

cli/knowledge_adapter.go:75–91  ·  view source on GitHub ↗

Get returns one page of a document plus explicit pagination guidance.

(source, kb string, offset int)

Source from the content-addressed store, hash-verified

73
74// Get returns one page of a document plus explicit pagination guidance.
75func (a *knowledgePluginAdapter) Get(source, kb string, offset int) (string, error) {
76 mgr := a.manager()
77 if mgr == nil {
78 return "", fmt.Errorf("context manager unavailable in this session")
79 }
80 page, total, next, err := mgr.KnowledgeDocument(a.sessionID(), kb, source, offset)
81 if err != nil {
82 return "", err
83 }
84 var b strings.Builder
85 fmt.Fprintf(&b, "📄 %s (chars %d-%d of %d)\n\n", source, offset, offset+len(page), total)
86 b.WriteString(page)
87 if next > 0 {
88 fmt.Fprintf(&b, "\n\n[document continues — call get again with {\"source\":%q,\"offset\":%d}]", source, next)
89 }
90 return b.String(), nil
91}
92
93// TOC lists document paths, optionally narrowed by prefix.
94func (a *knowledgePluginAdapter) TOC(kb, prefix string) (string, error) {

Calls 5

managerMethod · 0.95
sessionIDMethod · 0.95
ErrorfMethod · 0.80
KnowledgeDocumentMethod · 0.80
StringMethod · 0.45

Tested by 2