start_session
Initiate a development session with Hi-AI to restore context, load project memories, and access coding guides for AI-assisted programming tasks.
Instructions
hi-ai|hello|start|begin session - Start session with context
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| greeting | No | Greeting message that triggered this action (e.g., "hi-ai", "hello") | |
| loadMemory | No | Load relevant project memories (default: true) | |
| loadGuides | No | Load applicable coding guides (default: true) | |
| restoreContext | No | Restore previous session context (default: true) |
Implementation Reference
- src/tools/memory/startSession.ts:58-122 (handler)The async handler function `startSession` that implements the core logic for the `start_session` tool. It loads project memories, coding guides, and previous session context based on input parameters, constructs a session summary, and returns it as a ToolResult.export async function startSession(args: { greeting?: string; loadMemory?: boolean; loadGuides?: boolean; restoreContext?: boolean }): Promise<ToolResult> { const { greeting = '', loadMemory = true, loadGuides: shouldLoadGuides = true, restoreContext = true } = args; try { const memoryManager = MemoryManager.getInstance(); let summary = `${greeting ? greeting + '! ' : ''}Session started.\n`; // Load relevant project memories if (loadMemory) { const projectMemories = memoryManager.list('project'); const codeMemories = memoryManager.list('code'); const memories = [...projectMemories, ...codeMemories].slice(0, 5); if (memories.length > 0) { summary += `\nRecent Project Info:\n`; memories.forEach(mem => { const preview = mem.value.substring(0, 80); summary += ` • ${mem.key}: ${preview}${mem.value.length > 80 ? '...' : ''}\n`; }); } } // Load coding guides if (shouldLoadGuides) { const allGuides = await loadGuides(); const guides = allGuides .sort((a, b) => new Date(b.lastUpdated).getTime() - new Date(a.lastUpdated).getTime()) .slice(0, 3); if (guides.length > 0) { summary += `\nActive Coding Guides:\n`; guides.forEach(guide => { summary += ` • ${guide.name} (${guide.category}): ${guide.description}\n`; }); } } // Restore context if (restoreContext) { const contextMemories = memoryManager.list('context').slice(0, 3); if (contextMemories.length > 0) { summary += `\nPrevious Context:\n`; contextMemories.forEach(ctx => { try { const data = JSON.parse(ctx.value); summary += ` • ${data.urgency?.toUpperCase() || 'MEDIUM'} priority from ${new Date(ctx.timestamp).toLocaleString()}\n`; } catch { summary += ` • Context from ${new Date(ctx.timestamp).toLocaleString()}\n`; } }); } } summary += '\nReady to continue development! What would you like to work on?'; return { content: [{ type: 'text', text: summary }] }; } catch (error) { return { content: [{ type: 'text', text: `${greeting ? greeting + '! ' : ''}Session started.\n\nReady to begin! What can I help you with?` }] }; } }
- The `ToolDefinition` object `startSessionDefinition` defining the `start_session` tool, including name, description, inputSchema with parameters like greeting, loadMemory, loadGuides, restoreContext, and annotations.export const startSessionDefinition: ToolDefinition = { name: 'start_session', description: 'hi-ai|hello|start|begin session - Start session with context', inputSchema: { type: 'object', properties: { greeting: { type: 'string', description: 'Greeting message that triggered this action (e.g., "hi-ai", "hello")' }, loadMemory: { type: 'boolean', description: 'Load relevant project memories (default: true)' }, loadGuides: { type: 'boolean', description: 'Load applicable coding guides (default: true)' }, restoreContext: { type: 'boolean', description: 'Restore previous session context (default: true)' } }, required: [] }, annotations: { title: 'Start Session', audience: ['user', 'assistant'] } };
- src/index.ts:654-655 (registration)Registration of the `start_session` tool in the main switch statement that dispatches tool calls to the `startSession` handler function.case 'start_session': return await startSession(args as any) as CallToolResult;
- src/index.ts:134-134 (registration)Inclusion of `startSessionDefinition` in the `tools` array for tool listing and discovery.startSessionDefinition,
- src/index.ts:67-67 (registration)Import statement bringing in `startSession` handler and `startSessionDefinition` schema from the tool file.import { startSession, startSessionDefinition } from './tools/memory/startSession.js';