Skip to main content
Glama

AI Conversation Logger

by fablefang
markdownFormatter.ts2.89 kB
import type { ConversationEntry } from '../types/index.js'; export class MarkdownFormatter { static formatConversationEntry(entry: ConversationEntry, conversationNumber: number): string { const timestamp = new Date(entry.timestamp); const timeStr = timestamp.toLocaleTimeString('zh-CN', { hour12: false }); const tagsStr = entry.tags.length > 0 ? entry.tags.map(tag => `#${tag}`).join(' ') : ''; // 新格式:使用emoji和详细结构 let content = ''; // 标题行:时间戳 + 标题 + 标签 const title = entry.title || `对话${conversationNumber}`; content += `## [${timeStr}] ${title} ${tagsStr}\n\n`; // 用户需求 content += `### 🗣️ 用户需求\n`; content += `${entry.userRequest}\n\n`; // AI执行计划 if (entry.aiTodoList && entry.aiTodoList.length > 0) { content += `### 📋 AI执行计划\n`; entry.aiTodoList.forEach(todo => { // 默认都标记为完成 content += `- [x] ${todo}\n`; }); content += '\n'; } // AI回复总结 content += `### 🤖 AI回复总结\n`; content += `${entry.aiSummary}\n\n`; // 文件操作总结 if (entry.fileOperations && entry.fileOperations.length > 0) { content += `### 📂 文件操作总结\n`; entry.fileOperations.forEach(operation => { // 解析格式:"动作 文件路径 - 说明" const parts = operation.split(' - '); if (parts.length >= 2) { const [actionAndPath, description] = parts; const actionParts = actionAndPath ? actionAndPath.split(' ') : []; if (actionParts.length >= 2) { const action = actionParts[0]; const path = actionParts.slice(1).join(' '); // 根据动作类型使用不同的标记 let prefix = '-'; if (action === '创建') { prefix = '- **创建**'; } else if (action === '修改') { prefix = '- **修改**'; } else if (action === '删除') { prefix = '- **删除**'; } content += `${prefix} \`${path}\` - ${description}\n`; } else { content += `- ${operation}\n`; } } else { content += `- ${operation}\n`; } }); content += '\n'; } // 标签部分 if (entry.tags && entry.tags.length > 0) { content += `### 🏷️ 标签\n`; content += entry.tags.map(tag => `#${tag}`).join(' ') + '\n\n'; } content += `---\n\n`; return content; } static formatDailyLogHeader(project: string, date: string, projectRoot?: string | null): string { return `# AI对话记录 - ${date} > 项目: ${project} > 日期: ${date} > 工作目录: ${projectRoot || '未检测到项目'} --- `; } }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/fablefang/ai-conversation-logger-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server