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

Function registerMagicContextTools

packages/pi-plugin/src/tools/index.ts:62–126  ·  view source on GitHub ↗
(
	pi: ExtensionAPI,
	opts: RegisterToolsOptions,
)

Source from the content-addressed store, hash-verified

60}
61
62export function registerMagicContextTools(
63 pi: ExtensionAPI,
64 opts: RegisterToolsOptions,
65): void {
66 pi.registerTool(
67 createCtxSearchTool({
68 db: opts.db,
69 ensureProjectRegistered: opts.ensureProjectRegistered,
70 memoryEnabled: opts.memoryEnabled,
71 embeddingEnabled: opts.embeddingEnabled,
72 gitCommitsEnabled: opts.gitCommitsEnabled,
73 }),
74 );
75
76 if (opts.memoryToolEnabled !== false) {
77 pi.registerTool(
78 createCtxMemoryTool({
79 db: opts.db,
80 ensureProjectRegistered: opts.ensureProjectRegistered,
81 memoryEnabled: opts.memoryEnabled,
82 embeddingEnabled: opts.embeddingEnabled,
83 allowDreamerActions: opts.allowDreamerActions ?? false,
84 }),
85 );
86 }
87
88 // ctx_note and ctx_expand are session-scoped: they resolve the CURRENT
89 // session id at call time. For `--no-session` children that id is the hidden
90 // ephemeral child session, so a note would be orphaned and an expand would
91 // target the child's empty transcript. Omit them for those children; ctx_search
92 // stays available and ctx_memory is controlled above.
93 if (!opts.sessionScopedToolsDisabled) {
94 pi.registerTool(
95 createCtxNoteTool({
96 db: opts.db,
97 dreamerEnabled: opts.dreamerEnabled ?? false,
98 }),
99 );
100
101 pi.registerTool(createCtxExpandTool({ db: opts.db }));
102 }
103
104 // `todowrite` parity with OpenCode. Pi-coding-agent has no built-in
105 // task list tool, so without this the synthetic-todowrite injector
106 // would never have anything to surface. The tool just captures the
107 // `todos` arg and echoes a pretty-printed JSON ack; `message_end`
108 // in index.ts snapshots `params.todos` into `session_meta.last_todo_state`
109 // for downstream synthesis. See `tools/todowrite.ts` header for rationale.
110 pi.registerTool(createTodowriteTool());
111
112 // Conditionally register ctx_reduce. When ctxReduceEnabled is false:
113 // - tool not registered (agent gets "tool not found" if it tries
114 // to call ctx_reduce — but it shouldn't because the prompt
115 // guidance also drops all references)
116 // - §N§ tag prefix injection is also disabled upstream in
117 // transcript-pi.ts, matching OpenCode's transform.ts gate
118 if (opts.ctxReduceEnabled === true) {
119 pi.registerTool(

Callers 3

index.tsFile · 0.90
index.test.tsFile · 0.90

Calls 6

createCtxSearchToolFunction · 0.90
createCtxMemoryToolFunction · 0.90
createCtxNoteToolFunction · 0.90
createCtxExpandToolFunction · 0.90
createTodowriteToolFunction · 0.90
createCtxReduceToolFunction · 0.90

Tested by

no test coverage detected