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

Method knowledgeAgentBlock

cli/knowledge_adapter.go:124–144  ·  view source on GitHub ↗

knowledgeAgentBlock renders the knowledge digests for the agent/coder system prompt: the index cards plus the pull instruction. Empty when no knowledge context is attached — the block then costs nothing. Deterministic for a given attachment set, so it can live in a cacheable prompt block.

()

Source from the content-addressed store, hash-verified

122// knowledge context is attached — the block then costs nothing. Deterministic
123// for a given attachment set, so it can live in a cacheable prompt block.
124func (cli *ChatCLI) knowledgeAgentBlock() string {
125 if cli.contextHandler == nil {
126 return ""
127 }
128 sessionID := cli.currentSessionName
129 if sessionID == "" {
130 sessionID = "default"
131 }
132 mgr := cli.contextHandler.GetManager()
133 kbs := mgr.AttachedKnowledge(sessionID)
134 if len(kbs) == 0 {
135 return ""
136 }
137 var b strings.Builder
138 for _, fc := range kbs {
139 b.WriteString(mgr.KnowledgeDigest(fc))
140 b.WriteString("\n")
141 }
142 b.WriteString("Use the @knowledge tool to work with these bases: search passages, read full documents with get (paged), inspect coverage with toc. Ground answers in retrieved content and cite source paths.")
143 return b.String()
144}

Callers 4

RunMethod · 0.80

Calls 4

AttachedKnowledgeMethod · 0.80
KnowledgeDigestMethod · 0.80
GetManagerMethod · 0.45
StringMethod · 0.45