Add context injection system (Milestone 3)
- Add src/core/context.ts with context gathering, ranking, and formatting - Add src/core/config.ts for persistent configuration storage - Add CLI commands: cortex context, cortex context-hook, cortex config - Add memory_context MCP tool for Claude Code integration - Add GET /api/context endpoint - Include summary.ts from main branch for heartbeat dependency
This commit is contained in:
@@ -367,6 +367,37 @@ server.tool(
|
||||
}
|
||||
);
|
||||
|
||||
// --- memory_context ---
|
||||
import { gatherContext, DEFAULT_CONTEXT_CONFIG } from '../core/context';
|
||||
|
||||
server.tool(
|
||||
'memory_context',
|
||||
'Get relevant context for a Claude session. Gathers recent activity, project-specific nodes, open tasks, and decisions. Use at session start.',
|
||||
{
|
||||
project: z.string().optional().describe('Project name to filter by (e.g. "cortex")'),
|
||||
query: z.string().optional().describe('Optional semantic search query'),
|
||||
maxTokens: z.number().optional().describe(`Max tokens in output (default ${DEFAULT_CONTEXT_CONFIG.maxTokens})`),
|
||||
maxNodes: z.number().optional().describe(`Max nodes to include (default ${DEFAULT_CONTEXT_CONFIG.maxNodes})`),
|
||||
},
|
||||
async ({ project, query: semanticQuery, maxTokens, maxNodes }) => {
|
||||
const result = await gatherContext({
|
||||
project,
|
||||
semanticQuery,
|
||||
config: {
|
||||
maxTokens: maxTokens ?? DEFAULT_CONTEXT_CONFIG.maxTokens,
|
||||
maxNodes: maxNodes ?? DEFAULT_CONTEXT_CONFIG.maxNodes,
|
||||
},
|
||||
});
|
||||
|
||||
return {
|
||||
content: [{
|
||||
type: 'text' as const,
|
||||
text: result.formatted,
|
||||
}],
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
// --- memory_summary ---
|
||||
import { getCachedSummary, generateSummary } from '../core/summary';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user