MCPcopy Create free account
hub / github.com/cortexkit/magic-context / buildMagicContextBlock

Function buildMagicContextBlock

packages/pi-plugin/src/system-prompt.ts:59–80  ·  view source on GitHub ↗
(
	opts: BuildMagicContextBlockOptions,
)

Source from the content-addressed store, hash-verified

57 * legacy options are true.
58 */
59export function buildMagicContextBlock(
60 opts: BuildMagicContextBlockOptions,
61): string | null {
62 const existing = opts.existingSystemPrompt ?? "";
63 const includeGuidance =
64 (opts.includeGuidance ?? true) && !existing.includes(MAGIC_CONTEXT_MARKER);
65 if (!includeGuidance) return null;
66
67 return buildMagicContextSection(
68 null,
69 opts.protectedTags ?? 20,
70 opts.ctxReduceEnabled ?? true,
71 opts.dreamerEnabled ?? false,
72 opts.temporalAwarenessEnabled ?? false,
73 opts.cavemanTextCompressionEnabled ?? false,
74 false,
75 opts.language,
76 // Drop ctx_memory guidance when memory is off (the tool is gated via
77 // registerMagicContextTools memoryToolEnabled). ctx_search guidance stays.
78 opts.memoryEnabled !== false,
79 );
80}
81
82export interface SystemPromptHashResult {
83 /** The system prompt to send to the LLM, possibly with date frozen. */

Callers 2

index.tsFile · 0.90

Calls 1

buildMagicContextSectionFunction · 0.90

Tested by

no test coverage detected