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

Method BuildWorkspaceContextMode

cli/workspace/context_builder.go:195–224  ·  view source on GitHub ↗

BuildWorkspaceContextMode assembles the workspace context (bootstrap files + memory + path rules) honoring a memory injection mode: "full" — hint-driven full memory retrieval (default; the push model) "index" — only the compact, stable memory index, paired with recallHint so the agent

(
	ctx context.Context, query string, hints []string,
	augmenter *memory.HyDEAugmenter, mode string, recallHint string,
)

Source from the content-addressed store, hash-verified

193// that path stays byte-for-byte unchanged. recallHint (may be "") is appended
194// after the index in "index" mode only.
195func (cb *ContextBuilder) BuildWorkspaceContextMode(
196 ctx context.Context, query string, hints []string,
197 augmenter *memory.HyDEAugmenter, mode string, recallHint string,
198) string {
199 if mode == "" || mode == "full" {
200 if augmenter != nil || (cb.memory != nil && cb.memory.VectorIndex() != nil) {
201 return cb.BuildSystemPromptPrefixWithHyDE(ctx, query, hints, augmenter)
202 }
203 return cb.BuildSystemPromptPrefixWithHints(hints)
204 }
205
206 var parts []string
207 if bc := cb.bootstrap.LoadBootstrapContent(); bc != "" {
208 parts = append(parts, bc)
209 }
210 if mode == "index" && cb.memory != nil {
211 if idx := cb.memory.GetMemoryIndex(0); idx != "" {
212 block := idx
213 if strings.TrimSpace(recallHint) != "" {
214 block += "\n\n" + recallHint
215 }
216 parts = append(parts, block)
217 }
218 }
219 parts = appendMatchingRules(cb.rules, hints, parts)
220 if len(parts) == 0 {
221 return ""
222 }
223 return strings.Join(parts, "\n\n---\n\n")
224}
225
226// appendMatchingRules appends path-specific rules for any file-like hints,
227// mirroring the rule-loading logic shared by the prefix builders.

Calls 6

appendMatchingRulesFunction · 0.85
LoadBootstrapContentMethod · 0.80
VectorIndexMethod · 0.45
GetMemoryIndexMethod · 0.45